examples/fips_validation: separate ECB and CBC init
[dpdk.git] / examples / bpf / mbuf.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation.
3  * Copyright 2014 6WIND S.A.
4  */
5
6 /*
7  * Snipper from dpdk.org rte_mbuf.h.
8  * used to provide BPF programs information about rte_mbuf layout.
9  */
10
11 #ifndef _MBUF_H_
12 #define _MBUF_H_
13
14 #include <stdint.h>
15 #include <rte_common.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /*
22  * Packet Offload Features Flags. It also carry packet type information.
23  * Critical resources. Both rx/tx shared these bits. Be cautious on any change
24  *
25  * - RX flags start at bit position zero, and get added to the left of previous
26  *   flags.
27  * - The most-significant 3 bits are reserved for generic mbuf flags
28  * - TX flags therefore start at bit position 60 (i.e. 63-3), and new flags get
29  *   added to the right of the previously defined flags i.e. they should count
30  *   downwards, not upwards.
31  *
32  * Keep these flags synchronized with rte_get_rx_ol_flag_name() and
33  * rte_get_tx_ol_flag_name().
34  */
35
36 /**
37  * RX packet is a 802.1q VLAN packet. This flag was set by PMDs when
38  * the packet is recognized as a VLAN, but the behavior between PMDs
39  * was not the same. This flag is kept for some time to avoid breaking
40  * applications and should be replaced by PKT_RX_VLAN_STRIPPED.
41  */
42 #define PKT_RX_VLAN_PKT      (1ULL << 0)
43
44 #define PKT_RX_RSS_HASH      (1ULL << 1)
45 /**< RX packet with RSS hash result. */
46 #define PKT_RX_FDIR          (1ULL << 2)
47 /**< RX packet with FDIR match indicate. */
48
49 /**
50  * Deprecated.
51  * Checking this flag alone is deprecated: check the 2 bits of
52  * PKT_RX_L4_CKSUM_MASK.
53  * This flag was set when the L4 checksum of a packet was detected as
54  * wrong by the hardware.
55  */
56 #define PKT_RX_L4_CKSUM_BAD  (1ULL << 3)
57
58 /**
59  * Deprecated.
60  * Checking this flag alone is deprecated: check the 2 bits of
61  * PKT_RX_IP_CKSUM_MASK.
62  * This flag was set when the IP checksum of a packet was detected as
63  * wrong by the hardware.
64  */
65 #define PKT_RX_IP_CKSUM_BAD  (1ULL << 4)
66
67 #define PKT_RX_EIP_CKSUM_BAD (1ULL << 5)
68 /**< External IP header checksum error. */
69
70 /**
71  * A vlan has been stripped by the hardware and its tci is saved in
72  * mbuf->vlan_tci. This can only happen if vlan stripping is enabled
73  * in the RX configuration of the PMD.
74  */
75 #define PKT_RX_VLAN_STRIPPED (1ULL << 6)
76
77 /**
78  * Mask of bits used to determine the status of RX IP checksum.
79  * - PKT_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum
80  * - PKT_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong
81  * - PKT_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid
82  * - PKT_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet
83  *   data, but the integrity of the IP header is verified.
84  */
85 #define PKT_RX_IP_CKSUM_MASK ((1ULL << 4) | (1ULL << 7))
86
87 #define PKT_RX_IP_CKSUM_UNKNOWN 0
88 #define PKT_RX_IP_CKSUM_BAD     (1ULL << 4)
89 #define PKT_RX_IP_CKSUM_GOOD    (1ULL << 7)
90 #define PKT_RX_IP_CKSUM_NONE    ((1ULL << 4) | (1ULL << 7))
91
92 /**
93  * Mask of bits used to determine the status of RX L4 checksum.
94  * - PKT_RX_L4_CKSUM_UNKNOWN: no information about the RX L4 checksum
95  * - PKT_RX_L4_CKSUM_BAD: the L4 checksum in the packet is wrong
96  * - PKT_RX_L4_CKSUM_GOOD: the L4 checksum in the packet is valid
97  * - PKT_RX_L4_CKSUM_NONE: the L4 checksum is not correct in the packet
98  *   data, but the integrity of the L4 data is verified.
99  */
100 #define PKT_RX_L4_CKSUM_MASK ((1ULL << 3) | (1ULL << 8))
101
102 #define PKT_RX_L4_CKSUM_UNKNOWN 0
103 #define PKT_RX_L4_CKSUM_BAD     (1ULL << 3)
104 #define PKT_RX_L4_CKSUM_GOOD    (1ULL << 8)
105 #define PKT_RX_L4_CKSUM_NONE    ((1ULL << 3) | (1ULL << 8))
106
107 #define PKT_RX_IEEE1588_PTP  (1ULL << 9)
108 /**< RX IEEE1588 L2 Ethernet PT Packet. */
109 #define PKT_RX_IEEE1588_TMST (1ULL << 10)
110 /**< RX IEEE1588 L2/L4 timestamped packet.*/
111 #define PKT_RX_FDIR_ID       (1ULL << 13)
112 /**< FD id reported if FDIR match. */
113 #define PKT_RX_FDIR_FLX      (1ULL << 14)
114 /**< Flexible bytes reported if FDIR match. */
115
116 /**
117  * The 2 vlans have been stripped by the hardware and their tci are
118  * saved in mbuf->vlan_tci (inner) and mbuf->vlan_tci_outer (outer).
119  * This can only happen if vlan stripping is enabled in the RX
120  * configuration of the PMD. If this flag is set, PKT_RX_VLAN_STRIPPED
121  * must also be set.
122  */
123 #define PKT_RX_QINQ_STRIPPED (1ULL << 15)
124
125 /**
126  * Deprecated.
127  * RX packet with double VLAN stripped.
128  * This flag is replaced by PKT_RX_QINQ_STRIPPED.
129  */
130 #define PKT_RX_QINQ_PKT      PKT_RX_QINQ_STRIPPED
131
132 /**
133  * When packets are coalesced by a hardware or virtual driver, this flag
134  * can be set in the RX mbuf, meaning that the m->tso_segsz field is
135  * valid and is set to the segment size of original packets.
136  */
137 #define PKT_RX_LRO           (1ULL << 16)
138
139 /**
140  * Indicate that the timestamp field in the mbuf is valid.
141  */
142 #define PKT_RX_TIMESTAMP     (1ULL << 17)
143
144 /* add new RX flags here */
145
146 /* add new TX flags here */
147
148 /**
149  * Offload the MACsec. This flag must be set by the application to enable
150  * this offload feature for a packet to be transmitted.
151  */
152 #define PKT_TX_MACSEC        (1ULL << 44)
153
154 /**
155  * Bits 45:48 used for the tunnel type.
156  * When doing Tx offload like TSO or checksum, the HW needs to configure the
157  * tunnel type into the HW descriptors.
158  */
159 #define PKT_TX_TUNNEL_VXLAN   (0x1ULL << 45)
160 #define PKT_TX_TUNNEL_GRE     (0x2ULL << 45)
161 #define PKT_TX_TUNNEL_IPIP    (0x3ULL << 45)
162 #define PKT_TX_TUNNEL_GENEVE  (0x4ULL << 45)
163 /**< TX packet with MPLS-in-UDP RFC 7510 header. */
164 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
165 /* add new TX TUNNEL type here */
166 #define PKT_TX_TUNNEL_MASK    (0xFULL << 45)
167
168 /**
169  * Second VLAN insertion (QinQ) flag.
170  */
171 #define PKT_TX_QINQ_PKT    (1ULL << 49)
172 /**< TX packet with double VLAN inserted. */
173
174 /**
175  * TCP segmentation offload. To enable this offload feature for a
176  * packet to be transmitted on hardware supporting TSO:
177  *  - set the PKT_TX_TCP_SEG flag in mbuf->ol_flags (this flag implies
178  *    PKT_TX_TCP_CKSUM)
179  *  - set the flag PKT_TX_IPV4 or PKT_TX_IPV6
180  *  - if it's IPv4, set the PKT_TX_IP_CKSUM flag and write the IP checksum
181  *    to 0 in the packet
182  *  - fill the mbuf offload information: l2_len, l3_len, l4_len, tso_segsz
183  *  - calculate the pseudo header checksum without taking ip_len in account,
184  *    and set it in the TCP header. Refer to rte_ipv4_phdr_cksum() and
185  *    rte_ipv6_phdr_cksum() that can be used as helpers.
186  */
187 #define PKT_TX_TCP_SEG       (1ULL << 50)
188
189 #define PKT_TX_IEEE1588_TMST (1ULL << 51)
190 /**< TX IEEE1588 packet to timestamp. */
191
192 /**
193  * Bits 52+53 used for L4 packet type with checksum enabled: 00: Reserved,
194  * 01: TCP checksum, 10: SCTP checksum, 11: UDP checksum. To use hardware
195  * L4 checksum offload, the user needs to:
196  *  - fill l2_len and l3_len in mbuf
197  *  - set the flags PKT_TX_TCP_CKSUM, PKT_TX_SCTP_CKSUM or PKT_TX_UDP_CKSUM
198  *  - set the flag PKT_TX_IPV4 or PKT_TX_IPV6
199  *  - calculate the pseudo header checksum and set it in the L4 header (only
200  *    for TCP or UDP). See rte_ipv4_phdr_cksum() and rte_ipv6_phdr_cksum().
201  *    For SCTP, set the crc field to 0.
202  */
203 #define PKT_TX_L4_NO_CKSUM   (0ULL << 52)
204 /**< Disable L4 cksum of TX pkt. */
205 #define PKT_TX_TCP_CKSUM     (1ULL << 52)
206 /**< TCP cksum of TX pkt. computed by NIC. */
207 #define PKT_TX_SCTP_CKSUM    (2ULL << 52)
208 /**< SCTP cksum of TX pkt. computed by NIC. */
209 #define PKT_TX_UDP_CKSUM     (3ULL << 52)
210 /**< UDP cksum of TX pkt. computed by NIC. */
211 #define PKT_TX_L4_MASK       (3ULL << 52)
212 /**< Mask for L4 cksum offload request. */
213
214 /**
215  * Offload the IP checksum in the hardware. The flag PKT_TX_IPV4 should
216  * also be set by the application, although a PMD will only check
217  * PKT_TX_IP_CKSUM.
218  *  - set the IP checksum field in the packet to 0
219  *  - fill the mbuf offload information: l2_len, l3_len
220  */
221 #define PKT_TX_IP_CKSUM      (1ULL << 54)
222
223 /**
224  * Packet is IPv4. This flag must be set when using any offload feature
225  * (TSO, L3 or L4 checksum) to tell the NIC that the packet is an IPv4
226  * packet. If the packet is a tunneled packet, this flag is related to
227  * the inner headers.
228  */
229 #define PKT_TX_IPV4          (1ULL << 55)
230
231 /**
232  * Packet is IPv6. This flag must be set when using an offload feature
233  * (TSO or L4 checksum) to tell the NIC that the packet is an IPv6
234  * packet. If the packet is a tunneled packet, this flag is related to
235  * the inner headers.
236  */
237 #define PKT_TX_IPV6          (1ULL << 56)
238
239 #define PKT_TX_VLAN_PKT      (1ULL << 57)
240 /**< TX packet is a 802.1q VLAN packet. */
241
242 /**
243  * Offload the IP checksum of an external header in the hardware. The
244  * flag PKT_TX_OUTER_IPV4 should also be set by the application, alto ugh
245  * a PMD will only check PKT_TX_IP_CKSUM.  The IP checksum field in the
246  * packet must be set to 0.
247  *  - set the outer IP checksum field in the packet to 0
248  *  - fill the mbuf offload information: outer_l2_len, outer_l3_len
249  */
250 #define PKT_TX_OUTER_IP_CKSUM   (1ULL << 58)
251
252 /**
253  * Packet outer header is IPv4. This flag must be set when using any
254  * outer offload feature (L3 or L4 checksum) to tell the NIC that the
255  * outer header of the tunneled packet is an IPv4 packet.
256  */
257 #define PKT_TX_OUTER_IPV4   (1ULL << 59)
258
259 /**
260  * Packet outer header is IPv6. This flag must be set when using any
261  * outer offload feature (L4 checksum) to tell the NIC that the outer
262  * header of the tunneled packet is an IPv6 packet.
263  */
264 #define PKT_TX_OUTER_IPV6    (1ULL << 60)
265
266 /**
267  * Bitmask of all supported packet Tx offload features flags,
268  * which can be set for packet.
269  */
270 #define PKT_TX_OFFLOAD_MASK (    \
271                 PKT_TX_IP_CKSUM |        \
272                 PKT_TX_L4_MASK |         \
273                 PKT_TX_OUTER_IP_CKSUM |  \
274                 PKT_TX_TCP_SEG |         \
275                 PKT_TX_IEEE1588_TMST |   \
276                 PKT_TX_QINQ_PKT |        \
277                 PKT_TX_VLAN_PKT |        \
278                 PKT_TX_TUNNEL_MASK |     \
279                 PKT_TX_MACSEC)
280
281 #define __RESERVED           (1ULL << 61) /**< reserved for future mbuf use */
282
283 #define IND_ATTACHED_MBUF    (1ULL << 62) /**< Indirect attached mbuf */
284
285 /* Use final bit of flags to indicate a control mbuf */
286 #define CTRL_MBUF_FLAG       (1ULL << 63) /**< Mbuf contains control data */
287
288 /** Alignment constraint of mbuf private area. */
289 #define RTE_MBUF_PRIV_ALIGN 8
290
291 /**
292  * Get the name of a RX offload flag
293  *
294  * @param mask
295  *   The mask describing the flag.
296  * @return
297  *   The name of this flag, or NULL if it's not a valid RX flag.
298  */
299 const char *rte_get_rx_ol_flag_name(uint64_t mask);
300
301 /**
302  * Dump the list of RX offload flags in a buffer
303  *
304  * @param mask
305  *   The mask describing the RX flags.
306  * @param buf
307  *   The output buffer.
308  * @param buflen
309  *   The length of the buffer.
310  * @return
311  *   0 on success, (-1) on error.
312  */
313 int rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
314
315 /**
316  * Get the name of a TX offload flag
317  *
318  * @param mask
319  *   The mask describing the flag. Usually only one bit must be set.
320  *   Several bits can be given if they belong to the same mask.
321  *   Ex: PKT_TX_L4_MASK.
322  * @return
323  *   The name of this flag, or NULL if it's not a valid TX flag.
324  */
325 const char *rte_get_tx_ol_flag_name(uint64_t mask);
326
327 /**
328  * Dump the list of TX offload flags in a buffer
329  *
330  * @param mask
331  *   The mask describing the TX flags.
332  * @param buf
333  *   The output buffer.
334  * @param buflen
335  *   The length of the buffer.
336  * @return
337  *   0 on success, (-1) on error.
338  */
339 int rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
340
341 /**
342  * Some NICs need at least 2KB buffer to RX standard Ethernet frame without
343  * splitting it into multiple segments.
344  * So, for mbufs that planned to be involved into RX/TX, the recommended
345  * minimal buffer length is 2KB + RTE_PKTMBUF_HEADROOM.
346  */
347 #define RTE_MBUF_DEFAULT_DATAROOM       2048
348 #define RTE_MBUF_DEFAULT_BUF_SIZE       \
349         (RTE_MBUF_DEFAULT_DATAROOM + RTE_PKTMBUF_HEADROOM)
350
351 /* define a set of marker types that can be used to refer to set points in the
352  * mbuf.
353  */
354 __extension__
355 typedef void    *MARKER[0];   /**< generic marker for a point in a structure */
356 __extension__
357 typedef uint8_t  MARKER8[0];  /**< generic marker with 1B alignment */
358 __extension__
359 typedef uint64_t MARKER64[0];
360 /**< marker that allows us to overwrite 8 bytes with a single assignment */
361
362 typedef struct {
363         volatile int16_t cnt; /**< An internal counter value. */
364 } rte_atomic16_t;
365
366 #define RTE_CACHE_LINE_MIN_SIZE 64      /**< Minimum Cache line size. */
367
368 /**
369  * Force minimum cache line alignment.
370  */
371 #define __rte_cache_min_aligned __rte_aligned(RTE_CACHE_LINE_MIN_SIZE)
372
373 /**
374  * IO virtual address type.
375  * When the physical addressing mode (IOVA as PA) is in use,
376  * the translation from an IO virtual address (IOVA) to a physical address
377  * is a direct mapping, i.e. the same value.
378  * Otherwise, in virtual mode (IOVA as VA), an IOMMU may do the translation.
379  */
380 typedef uint64_t rte_iova_t;
381 #define RTE_BAD_IOVA ((rte_iova_t)-1)
382
383 /**
384  * The generic rte_mbuf, containing a packet mbuf.
385  */
386 struct rte_mbuf {
387         MARKER cacheline0;
388
389         void *buf_addr;           /**< Virtual address of segment buffer. */
390         /**
391          * Physical address of segment buffer.
392          * Force alignment to 8-bytes, so as to ensure we have the exact
393          * same mbuf cacheline0 layout for 32-bit and 64-bit. This makes
394          * working on vector drivers easier.
395          */
396         RTE_STD_C11
397         union {
398                 rte_iova_t buf_iova;
399                 rte_iova_t buf_physaddr; /**< deprecated */
400         } __rte_aligned(sizeof(rte_iova_t));
401
402         /* next 8 bytes are initialised on RX descriptor rearm */
403         MARKER64 rearm_data;
404         uint16_t data_off;
405
406         /**
407          * Reference counter. Its size should at least equal to the size
408          * of port field (16 bits), to support zero-copy broadcast.
409          * It should only be accessed using the following functions:
410          * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and
411          * rte_mbuf_refcnt_set(). The functionality of these functions (atomic,
412          * or non-atomic) is controlled by the CONFIG_RTE_MBUF_REFCNT_ATOMIC
413          * config option.
414          */
415         RTE_STD_C11
416         union {
417                 rte_atomic16_t refcnt_atomic; /**< Atomically accessed refcnt */
418                 uint16_t refcnt;
419                 /**< Non-atomically accessed refcnt */
420         };
421         uint16_t nb_segs;         /**< Number of segments. */
422
423         /** Input port (16 bits to support more than 256 virtual ports). */
424         uint16_t port;
425
426         uint64_t ol_flags;        /**< Offload features. */
427
428         /* remaining bytes are set on RX when pulling packet from descriptor */
429         MARKER rx_descriptor_fields1;
430
431         /*
432          * The packet type, which is the combination of outer/inner L2, L3, L4
433          * and tunnel types. The packet_type is about data really present in the
434          * mbuf. Example: if vlan stripping is enabled, a received vlan packet
435          * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
436          * vlan is stripped from the data.
437          */
438         RTE_STD_C11
439         union {
440                 uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
441                 struct {
442                         uint32_t l2_type:4; /**< (Outer) L2 type. */
443                         uint32_t l3_type:4; /**< (Outer) L3 type. */
444                         uint32_t l4_type:4; /**< (Outer) L4 type. */
445                         uint32_t tun_type:4; /**< Tunnel type. */
446                         uint32_t inner_l2_type:4; /**< Inner L2 type. */
447                         uint32_t inner_l3_type:4; /**< Inner L3 type. */
448                         uint32_t inner_l4_type:4; /**< Inner L4 type. */
449                 };
450         };
451
452         uint32_t pkt_len;         /**< Total pkt len: sum of all segments. */
453         uint16_t data_len;        /**< Amount of data in segment buffer. */
454         /** VLAN TCI (CPU order), valid if PKT_RX_VLAN_STRIPPED is set. */
455         uint16_t vlan_tci;
456
457         union {
458                 uint32_t rss;     /**< RSS hash result if RSS enabled */
459                 struct {
460                         RTE_STD_C11
461                         union {
462                                 struct {
463                                         uint16_t hash;
464                                         uint16_t id;
465                                 };
466                                 uint32_t lo;
467                                 /**< Second 4 flexible bytes */
468                         };
469                         uint32_t hi;
470                         /**< First 4 flexible bytes or FD ID, dependent on
471                          *   PKT_RX_FDIR_* flag in ol_flags.
472                          */
473                 } fdir;           /**< Filter identifier if FDIR enabled */
474                 struct {
475                         uint32_t lo;
476                         uint32_t hi;
477                 } sched;          /**< Hierarchical scheduler */
478                 uint32_t usr;
479                 /**< User defined tags. See rte_distributor_process() */
480         } hash;                   /**< hash information */
481
482         /** Outer VLAN TCI (CPU order), valid if PKT_RX_QINQ_STRIPPED is set. */
483         uint16_t vlan_tci_outer;
484
485         uint16_t buf_len;         /**< Length of segment buffer. */
486
487         /** Valid if PKT_RX_TIMESTAMP is set. The unit and time reference
488          * are not normalized but are always the same for a given port.
489          */
490         uint64_t timestamp;
491
492         /* second cache line - fields only used in slow path or on TX */
493         MARKER cacheline1 __rte_cache_min_aligned;
494
495         RTE_STD_C11
496         union {
497                 void *userdata;   /**< Can be used for external metadata */
498                 uint64_t udata64; /**< Allow 8-byte userdata on 32-bit */
499         };
500
501         struct rte_mempool *pool; /**< Pool from which mbuf was allocated. */
502         struct rte_mbuf *next;    /**< Next segment of scattered packet. */
503
504         /* fields to support TX offloads */
505         RTE_STD_C11
506         union {
507                 uint64_t tx_offload;       /**< combined for easy fetch */
508                 __extension__
509                 struct {
510                         uint64_t l2_len:7;
511                         /**< L2 (MAC) Header Length for non-tunneling pkt.
512                          * Outer_L4_len + ... + Inner_L2_len for tunneling pkt.
513                          */
514                         uint64_t l3_len:9; /**< L3 (IP) Header Length. */
515                         uint64_t l4_len:8; /**< L4 (TCP/UDP) Header Length. */
516                         uint64_t tso_segsz:16; /**< TCP TSO segment size */
517
518                         /* fields for TX offloading of tunnels */
519                         uint64_t outer_l3_len:9;
520                         /**< Outer L3 (IP) Hdr Length. */
521                         uint64_t outer_l2_len:7;
522                         /**< Outer L2 (MAC) Hdr Length. */
523
524                         /* uint64_t unused:8; */
525                 };
526         };
527
528         /** Size of the application private data. In case of an indirect
529          * mbuf, it stores the direct mbuf private data size.
530          */
531         uint16_t priv_size;
532
533         /** Timesync flags for use with IEEE1588. */
534         uint16_t timesync;
535
536         /** Sequence number. See also rte_reorder_insert(). */
537         uint32_t seqn;
538
539 } __rte_cache_aligned;
540
541
542 /**
543  * Returns TRUE if given mbuf is cloned by mbuf indirection, or FALSE
544  * otherwise.
545  *
546  * If a mbuf has its data in another mbuf and references it by mbuf
547  * indirection, this mbuf can be defined as a cloned mbuf.
548  */
549 #define RTE_MBUF_CLONED(mb)     ((mb)->ol_flags & IND_ATTACHED_MBUF)
550
551 /**
552  * Returns TRUE if given mbuf is direct, or FALSE otherwise.
553  *
554  * If a mbuf embeds its own data after the rte_mbuf structure, this mbuf
555  * can be defined as a direct mbuf.
556  */
557 #define RTE_MBUF_DIRECT(mb)     (!RTE_MBUF_CLONED(mb))
558
559 /**
560  * Private data in case of pktmbuf pool.
561  *
562  * A structure that contains some pktmbuf_pool-specific data that are
563  * appended after the mempool structure (in private data).
564  */
565 struct rte_pktmbuf_pool_private {
566         uint16_t mbuf_data_room_size; /**< Size of data space in each mbuf. */
567         uint16_t mbuf_priv_size;      /**< Size of private area in each mbuf. */
568 };
569
570 /**
571  * A macro that points to an offset into the data in the mbuf.
572  *
573  * The returned pointer is cast to type t. Before using this
574  * function, the user must ensure that the first segment is large
575  * enough to accommodate its data.
576  *
577  * @param m
578  *   The packet mbuf.
579  * @param o
580  *   The offset into the mbuf data.
581  * @param t
582  *   The type to cast the result into.
583  */
584 #define rte_pktmbuf_mtod_offset(m, t, o)        \
585         ((t)((char *)(m)->buf_addr + (m)->data_off + (o)))
586
587 /**
588  * A macro that points to the start of the data in the mbuf.
589  *
590  * The returned pointer is cast to type t. Before using this
591  * function, the user must ensure that the first segment is large
592  * enough to accommodate its data.
593  *
594  * @param m
595  *   The packet mbuf.
596  * @param t
597  *   The type to cast the result into.
598  */
599 #define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0)
600
601 #ifdef __cplusplus
602 }
603 #endif
604
605 #endif /* _MBUF_H_ */