35 #include <rte_compat.h>
37 #include <rte_config.h>
71 #define PKT_RX_VLAN (1ULL << 0)
73 #define PKT_RX_RSS_HASH (1ULL << 1)
74 #define PKT_RX_FDIR (1ULL << 2)
83 #define PKT_RX_L4_CKSUM_BAD (1ULL << 3)
92 #define PKT_RX_IP_CKSUM_BAD (1ULL << 4)
94 #define PKT_RX_EIP_CKSUM_BAD (1ULL << 5)
102 #define PKT_RX_VLAN_STRIPPED (1ULL << 6)
112 #define PKT_RX_IP_CKSUM_MASK ((1ULL << 4) | (1ULL << 7))
114 #define PKT_RX_IP_CKSUM_UNKNOWN 0
115 #define PKT_RX_IP_CKSUM_BAD (1ULL << 4)
116 #define PKT_RX_IP_CKSUM_GOOD (1ULL << 7)
117 #define PKT_RX_IP_CKSUM_NONE ((1ULL << 4) | (1ULL << 7))
127 #define PKT_RX_L4_CKSUM_MASK ((1ULL << 3) | (1ULL << 8))
129 #define PKT_RX_L4_CKSUM_UNKNOWN 0
130 #define PKT_RX_L4_CKSUM_BAD (1ULL << 3)
131 #define PKT_RX_L4_CKSUM_GOOD (1ULL << 8)
132 #define PKT_RX_L4_CKSUM_NONE ((1ULL << 3) | (1ULL << 8))
134 #define PKT_RX_IEEE1588_PTP (1ULL << 9)
135 #define PKT_RX_IEEE1588_TMST (1ULL << 10)
136 #define PKT_RX_FDIR_ID (1ULL << 13)
137 #define PKT_RX_FDIR_FLX (1ULL << 14)
147 #define PKT_RX_QINQ_STRIPPED (1ULL << 15)
154 #define PKT_RX_LRO (1ULL << 16)
159 #define PKT_RX_TIMESTAMP (1ULL << 17)
164 #define PKT_RX_SEC_OFFLOAD (1ULL << 18)
169 #define PKT_RX_SEC_OFFLOAD_FAILED (1ULL << 19)
179 #define PKT_RX_QINQ (1ULL << 20)
193 #define PKT_RX_OUTER_L4_CKSUM_MASK ((1ULL << 21) | (1ULL << 22))
195 #define PKT_RX_OUTER_L4_CKSUM_UNKNOWN 0
196 #define PKT_RX_OUTER_L4_CKSUM_BAD (1ULL << 21)
197 #define PKT_RX_OUTER_L4_CKSUM_GOOD (1ULL << 22)
198 #define PKT_RX_OUTER_L4_CKSUM_INVALID ((1ULL << 21) | (1ULL << 22))
207 #define PKT_TX_METADATA (1ULL << 40)
218 #define PKT_TX_OUTER_UDP_CKSUM (1ULL << 41)
225 #define PKT_TX_UDP_SEG (1ULL << 42)
230 #define PKT_TX_SEC_OFFLOAD (1ULL << 43)
236 #define PKT_TX_MACSEC (1ULL << 44)
246 #define PKT_TX_TUNNEL_VXLAN (0x1ULL << 45)
247 #define PKT_TX_TUNNEL_GRE (0x2ULL << 45)
248 #define PKT_TX_TUNNEL_IPIP (0x3ULL << 45)
249 #define PKT_TX_TUNNEL_GENEVE (0x4ULL << 45)
251 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
252 #define PKT_TX_TUNNEL_VXLAN_GPE (0x6ULL << 45)
264 #define PKT_TX_TUNNEL_IP (0xDULL << 45)
277 #define PKT_TX_TUNNEL_UDP (0xEULL << 45)
279 #define PKT_TX_TUNNEL_MASK (0xFULL << 45)
284 #define PKT_TX_QINQ (1ULL << 49)
286 #define PKT_TX_QINQ_PKT PKT_TX_QINQ
297 #define PKT_TX_TCP_SEG (1ULL << 50)
299 #define PKT_TX_IEEE1588_TMST (1ULL << 51)
309 #define PKT_TX_L4_NO_CKSUM (0ULL << 52)
310 #define PKT_TX_TCP_CKSUM (1ULL << 52)
311 #define PKT_TX_SCTP_CKSUM (2ULL << 52)
312 #define PKT_TX_UDP_CKSUM (3ULL << 52)
313 #define PKT_TX_L4_MASK (3ULL << 52)
321 #define PKT_TX_IP_CKSUM (1ULL << 54)
329 #define PKT_TX_IPV4 (1ULL << 55)
337 #define PKT_TX_IPV6 (1ULL << 56)
342 #define PKT_TX_VLAN (1ULL << 57)
344 #define PKT_TX_VLAN_PKT PKT_TX_VLAN
352 #define PKT_TX_OUTER_IP_CKSUM (1ULL << 58)
359 #define PKT_TX_OUTER_IPV4 (1ULL << 59)
366 #define PKT_TX_OUTER_IPV6 (1ULL << 60)
372 #define PKT_TX_OFFLOAD_MASK ( \
373 PKT_TX_OUTER_IPV6 | \
374 PKT_TX_OUTER_IPV4 | \
375 PKT_TX_OUTER_IP_CKSUM | \
381 PKT_TX_IEEE1588_TMST | \
384 PKT_TX_TUNNEL_MASK | \
386 PKT_TX_SEC_OFFLOAD | \
388 PKT_TX_OUTER_UDP_CKSUM | \
394 #define EXT_ATTACHED_MBUF (1ULL << 61)
396 #define IND_ATTACHED_MBUF (1ULL << 62)
399 #define RTE_MBUF_PRIV_ALIGN 8
457 #define RTE_MBUF_DEFAULT_DATAROOM 2048
458 #define RTE_MBUF_DEFAULT_BUF_SIZE \
459 (RTE_MBUF_DEFAULT_DATAROOM + RTE_PKTMBUF_HEADROOM)
529 MARKER rx_descriptor_fields1;
626 MARKER cacheline1 __rte_cache_min_aligned;
691 #define RTE_MBUF_MAX_NB_SEGS UINT16_MAX
723 #if RTE_CACHE_LINE_SIZE == 64
744 return mb->buf_iova + mb->data_off;
749 rte_mbuf_data_dma_addr(
const struct rte_mbuf *mb)
769 return mb->buf_iova + RTE_PKTMBUF_HEADROOM;
774 rte_mbuf_data_dma_addr_default(
const struct rte_mbuf *mb)
813 static inline char * __rte_experimental
830 static inline char * __rte_experimental
852 #ifdef ALLOW_EXPERIMENTAL_API
873 static inline void * __rte_experimental
886 #define RTE_MBUF_CLONED(mb) ((mb)->ol_flags & IND_ATTACHED_MBUF)
893 #define RTE_MBUF_HAS_EXTBUF(mb) ((mb)->ol_flags & EXT_ATTACHED_MBUF)
901 #define RTE_MBUF_DIRECT(mb) \
902 (!((mb)->ol_flags & (IND_ATTACHED_MBUF | EXT_ATTACHED_MBUF)))
915 #ifdef RTE_LIBRTE_MBUF_DEBUG
918 #define __rte_mbuf_sanity_check(m, is_h) rte_mbuf_sanity_check(m, is_h)
923 #define __rte_mbuf_sanity_check(m, is_h) do { } while (0)
927 #ifdef RTE_MBUF_REFCNT_ATOMIC
936 static inline uint16_t
956 static inline uint16_t
957 __rte_mbuf_refcnt_update(
struct rte_mbuf *m, int16_t value)
971 static inline uint16_t
984 return (uint16_t)value;
987 return __rte_mbuf_refcnt_update(m, value);
993 static inline uint16_t
994 __rte_mbuf_refcnt_update(
struct rte_mbuf *m, int16_t value)
1003 static inline uint16_t
1006 return __rte_mbuf_refcnt_update(m, value);
1012 static inline uint16_t
1037 static inline uint16_t
1069 static inline uint16_t
1076 return (uint16_t)value;
1083 #define RTE_MBUF_PREFETCH_TO_FREE(m) do { \
1125 const char **reason);
1127 #define MBUF_RAW_ALLOC_CHECK(m) do { \
1128 RTE_ASSERT(rte_mbuf_refcnt_read(m) == 1); \
1129 RTE_ASSERT((m)->next == NULL); \
1130 RTE_ASSERT((m)->nb_segs == 1); \
1131 __rte_mbuf_sanity_check(m, 0); \
1159 MBUF_RAW_ALLOC_CHECK(m);
1182 RTE_ASSERT(m->
next == NULL);
1208 void *m,
unsigned i);
1266 unsigned cache_size, uint16_t priv_size, uint16_t data_room_size,
1308 unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size,
1322 static inline uint16_t
1343 static inline uint16_t
1362 m->data_off = (uint16_t)
RTE_MIN((uint16_t)RTE_PKTMBUF_HEADROOM,
1374 #define MBUF_INVALID_PORT UINT16_MAX
1376 static inline void rte_pktmbuf_reset(
struct rte_mbuf *m)
1411 rte_pktmbuf_reset(m);
1430 struct rte_mbuf **mbufs,
unsigned count)
1444 switch (count % 4) {
1446 while (idx != count) {
1447 MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
1448 rte_pktmbuf_reset(mbufs[idx]);
1452 MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
1453 rte_pktmbuf_reset(mbufs[idx]);
1457 MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
1458 rte_pktmbuf_reset(mbufs[idx]);
1462 MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
1463 rte_pktmbuf_reset(mbufs[idx]);
1513 if (addr <= buf_addr)
1588 RTE_ASSERT(shinfo->
free_cb != NULL);
1591 m->buf_iova = buf_iova;
1608 #define rte_pktmbuf_detach_extbuf(m) rte_pktmbuf_detach(m)
1647 mi->buf_iova = m->buf_iova;
1651 mi->data_off = m->data_off;
1677 __rte_pktmbuf_free_extbuf(
struct rte_mbuf *m)
1680 RTE_ASSERT(m->
shinfo != NULL);
1693 __rte_pktmbuf_free_direct(
struct rte_mbuf *m)
1725 uint32_t mbuf_size, buf_len;
1729 __rte_pktmbuf_free_extbuf(m);
1731 __rte_pktmbuf_free_direct(m);
1734 mbuf_size = (uint32_t)(
sizeof(
struct rte_mbuf) + priv_size);
1738 m->
buf_addr = (
char *)m + mbuf_size;
1740 m->
buf_len = (uint16_t)buf_len;
1770 if (m->
next != NULL) {
1777 }
else if (__rte_mbuf_refcnt_update(m, -1) == 0) {
1782 if (m->
next != NULL) {
1870 }
while ((md = md->
next) != NULL &&
1904 }
while ((m = m->
next) != NULL);
1947 while (m->
next != NULL)
1966 #define rte_pktmbuf_mtod_offset(m, t, o) \
1967 ((t)((char *)(m)->buf_addr + (m)->data_off + (o)))
1981 #define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0)
1992 #define rte_pktmbuf_iova_offset(m, o) \
1993 (rte_iova_t)((m)->buf_iova + (m)->data_off + (o))
1996 #define rte_pktmbuf_mtophys_offset(m, o) \
1997 rte_pktmbuf_iova_offset(m, o)
2006 #define rte_pktmbuf_iova(m) rte_pktmbuf_iova_offset(m, 0)
2009 #define rte_pktmbuf_mtophys(m) rte_pktmbuf_iova(m)
2019 #define rte_pktmbuf_pkt_len(m) ((m)->pkt_len)
2029 #define rte_pktmbuf_data_len(m) ((m)->data_len)
2057 m->data_off = (uint16_t)(m->data_off - len);
2061 return (
char *)m->
buf_addr + m->data_off;
2093 return (
char*) tail;
2121 m->data_off = (uint16_t)(m->data_off + len);
2123 return (
char *)m->
buf_addr + m->data_off;
2173 const void *__rte_pktmbuf_read(
const struct rte_mbuf *m, uint32_t off,
2174 uint32_t len,
void *buf);
2197 uint32_t off, uint32_t len,
void *buf)
2202 return __rte_pktmbuf_read(m, off, len, buf);
2231 cur_tail->
next = tail;
2260 uint64_t inner_l3_offset = m->
l2_len;
2290 !(ol_flags & PKT_TX_IP_CKSUM)))
2294 if ((ol_flags & PKT_TX_OUTER_IP_CKSUM) &&
2316 size_t seg_len, copy_len;
2371 static inline uint32_t
2374 return m->hash.sched.queue_id;
2380 static inline uint8_t
2383 return m->hash.sched.traffic_class;
2389 static inline uint8_t
2392 return m->hash.sched.color;
2409 uint8_t *traffic_class,
2416 *color = sched.
color;
2443 m->hash.sched.color =
color;