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)
178 #define PKT_RX_QINQ (1ULL << 20)
189 #define PKT_TX_UDP_SEG (1ULL << 42)
194 #define PKT_TX_SEC_OFFLOAD (1ULL << 43)
200 #define PKT_TX_MACSEC (1ULL << 44)
210 #define PKT_TX_TUNNEL_VXLAN (0x1ULL << 45)
211 #define PKT_TX_TUNNEL_GRE (0x2ULL << 45)
212 #define PKT_TX_TUNNEL_IPIP (0x3ULL << 45)
213 #define PKT_TX_TUNNEL_GENEVE (0x4ULL << 45)
215 #define PKT_TX_TUNNEL_MPLSINUDP (0x5ULL << 45)
217 #define PKT_TX_TUNNEL_MASK (0xFULL << 45)
222 #define PKT_TX_QINQ (1ULL << 49)
224 #define PKT_TX_QINQ_PKT PKT_TX_QINQ
235 #define PKT_TX_TCP_SEG (1ULL << 50)
237 #define PKT_TX_IEEE1588_TMST (1ULL << 51)
247 #define PKT_TX_L4_NO_CKSUM (0ULL << 52)
248 #define PKT_TX_TCP_CKSUM (1ULL << 52)
249 #define PKT_TX_SCTP_CKSUM (2ULL << 52)
250 #define PKT_TX_UDP_CKSUM (3ULL << 52)
251 #define PKT_TX_L4_MASK (3ULL << 52)
259 #define PKT_TX_IP_CKSUM (1ULL << 54)
267 #define PKT_TX_IPV4 (1ULL << 55)
275 #define PKT_TX_IPV6 (1ULL << 56)
280 #define PKT_TX_VLAN (1ULL << 57)
282 #define PKT_TX_VLAN_PKT PKT_TX_VLAN
290 #define PKT_TX_OUTER_IP_CKSUM (1ULL << 58)
297 #define PKT_TX_OUTER_IPV4 (1ULL << 59)
304 #define PKT_TX_OUTER_IPV6 (1ULL << 60)
310 #define PKT_TX_OFFLOAD_MASK ( \
313 PKT_TX_OUTER_IP_CKSUM | \
315 PKT_TX_IEEE1588_TMST | \
318 PKT_TX_TUNNEL_MASK | \
322 #define __RESERVED (1ULL << 61)
324 #define IND_ATTACHED_MBUF (1ULL << 62)
327 #define CTRL_MBUF_FLAG (1ULL << 63)
330 #define RTE_MBUF_PRIV_ALIGN 8
388 #define RTE_MBUF_DEFAULT_DATAROOM 2048
389 #define RTE_MBUF_DEFAULT_BUF_SIZE \
390 (RTE_MBUF_DEFAULT_DATAROOM + RTE_PKTMBUF_HEADROOM)
447 MARKER rx_descriptor_fields1;
522 MARKER cacheline1 __rte_cache_min_aligned;
568 #define RTE_MBUF_MAX_NB_SEGS UINT16_MAX
600 #if RTE_CACHE_LINE_SIZE == 64
621 return mb->buf_iova + mb->data_off;
626 rte_mbuf_data_dma_addr(
const struct rte_mbuf *mb)
646 return mb->buf_iova + RTE_PKTMBUF_HEADROOM;
651 rte_mbuf_data_dma_addr_default(
const struct rte_mbuf *mb)
689 #define RTE_MBUF_INDIRECT(mb) ((mb)->ol_flags & IND_ATTACHED_MBUF)
694 #define RTE_MBUF_DIRECT(mb) (!RTE_MBUF_INDIRECT(mb))
707 #ifdef RTE_LIBRTE_MBUF_DEBUG
710 #define __rte_mbuf_sanity_check(m, is_h) rte_mbuf_sanity_check(m, is_h)
715 #define __rte_mbuf_sanity_check(m, is_h) do { } while (0)
719 #ifdef RTE_MBUF_REFCNT_ATOMIC
728 static inline uint16_t
748 static inline uint16_t
749 __rte_mbuf_refcnt_update(
struct rte_mbuf *m, int16_t value)
763 static inline uint16_t
776 return (uint16_t)value;
779 return __rte_mbuf_refcnt_update(m, value);
785 static inline uint16_t
786 __rte_mbuf_refcnt_update(
struct rte_mbuf *m, int16_t value)
795 static inline uint16_t
798 return __rte_mbuf_refcnt_update(m, value);
804 static inline uint16_t
822 #define RTE_MBUF_PREFETCH_TO_FREE(m) do { \
843 #define MBUF_RAW_ALLOC_CHECK(m) do { \
844 RTE_ASSERT(rte_mbuf_refcnt_read(m) == 1); \
845 RTE_ASSERT((m)->next == NULL); \
846 RTE_ASSERT((m)->nb_segs == 1); \
847 __rte_mbuf_sanity_check(m, 0); \
875 MBUF_RAW_ALLOC_CHECK(m);
898 RTE_ASSERT(m->
next == NULL);
907 __rte_mbuf_raw_free(
struct rte_mbuf *m)
934 void *m,
unsigned i);
948 #define rte_ctrlmbuf_alloc(mp) rte_pktmbuf_alloc(mp)
956 #define rte_ctrlmbuf_free(m) rte_pktmbuf_free(m)
966 #define rte_ctrlmbuf_data(m) ((char *)((m)->buf_addr) + (m)->data_off)
976 #define rte_ctrlmbuf_len(m) rte_pktmbuf_data_len(m)
1015 void *m,
unsigned i);
1073 unsigned cache_size, uint16_t priv_size, uint16_t data_room_size,
1115 unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size,
1129 static inline uint16_t
1150 static inline uint16_t
1169 m->data_off = (uint16_t)
RTE_MIN((uint16_t)RTE_PKTMBUF_HEADROOM,
1181 #define MBUF_INVALID_PORT UINT16_MAX
1183 static inline void rte_pktmbuf_reset(
struct rte_mbuf *m)
1218 rte_pktmbuf_reset(m);
1237 struct rte_mbuf **mbufs,
unsigned count)
1251 switch (count % 4) {
1253 while (idx != count) {
1254 MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
1255 rte_pktmbuf_reset(mbufs[idx]);
1259 MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
1260 rte_pktmbuf_reset(mbufs[idx]);
1264 MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
1265 rte_pktmbuf_reset(mbufs[idx]);
1269 MBUF_RAW_ALLOC_CHECK(mbufs[idx]);
1270 rte_pktmbuf_reset(mbufs[idx]);
1310 mi->buf_iova = m->buf_iova;
1314 mi->data_off = m->data_off;
1350 uint32_t mbuf_size, buf_len;
1354 mbuf_size = (uint32_t)(
sizeof(
struct rte_mbuf) + priv_size);
1358 m->
buf_addr = (
char *)m + mbuf_size;
1360 m->
buf_len = (uint16_t)buf_len;
1397 if (m->
next != NULL) {
1404 }
else if (__rte_mbuf_refcnt_update(m, -1) == 0) {
1409 if (m->
next != NULL) {
1423 __rte_pktmbuf_prefree_seg(
struct rte_mbuf *m)
1505 }
while ((md = md->
next) != NULL &&
1539 }
while ((m = m->
next) != NULL);
1582 while (m->
next != NULL)
1601 #define rte_pktmbuf_mtod_offset(m, t, o) \
1602 ((t)((char *)(m)->buf_addr + (m)->data_off + (o)))
1616 #define rte_pktmbuf_mtod(m, t) rte_pktmbuf_mtod_offset(m, t, 0)
1627 #define rte_pktmbuf_iova_offset(m, o) \
1628 (rte_iova_t)((m)->buf_iova + (m)->data_off + (o))
1631 #define rte_pktmbuf_mtophys_offset(m, o) \
1632 rte_pktmbuf_iova_offset(m, o)
1641 #define rte_pktmbuf_iova(m) rte_pktmbuf_iova_offset(m, 0)
1644 #define rte_pktmbuf_mtophys(m) rte_pktmbuf_iova(m)
1654 #define rte_pktmbuf_pkt_len(m) ((m)->pkt_len)
1664 #define rte_pktmbuf_data_len(m) ((m)->data_len)
1692 m->data_off = (uint16_t)(m->data_off - len);
1696 return (
char *)m->
buf_addr + m->data_off;
1728 return (
char*) tail;
1756 m->data_off = (uint16_t)(m->data_off + len);
1758 return (
char *)m->
buf_addr + m->data_off;
1808 const void *__rte_pktmbuf_read(
const struct rte_mbuf *m, uint32_t off,
1809 uint32_t len,
void *buf);
1832 uint32_t off, uint32_t len,
void *buf)
1837 return __rte_pktmbuf_read(m, off, len, buf);
1866 cur_tail->
next = tail;
1895 uint64_t inner_l3_offset = m->
l2_len;
1925 !(ol_flags & PKT_TX_IP_CKSUM)))
1929 if ((ol_flags & PKT_TX_OUTER_IP_CKSUM) &&
1951 size_t seg_len, copy_len;