CNDP 22.08.0
Loading...
Searching...
No Matches
pktmbuf.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2019-2022 Intel Corporation.
3 * Copyright (c) 2019-2020 6WIND S.A.
4 */
5
6#ifndef _PKTMBUF_H_
7#define _PKTMBUF_H_
8
33
34#include <errno.h> // for EINVAL
35#include <stdint.h> // for uint16_t, uint32_t, uint8_t, UINT...
36#include <stdio.h> // for NULL, FILE
37#include <bsd/string.h> // for strlcpy
38#include <cne_atomic.h> // for atomic_uint_least16_t
39#include <cne_common.h> // for CNDP_API, CNE_STD_C11, __cne_alwa...
40#include <cne_branch_prediction.h> // for likely, unlikely
41#include <cne_log.h> // for CNE_ASSERT
42#include <cne_mmap.h> // for mmap_type_t
43#include <cne_prefetch.h> // for cne_prefetch0
44#include <mempool.h> // for mempool_t, mempool_get, mempool_g...
45
46#include "pktmbuf_ops.h" // for mbuf_ops_t
47#include "pktmbuf_offload.h"
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52
53enum {
55 DEFAULT_MBUF_COUNT = (16 * 1024),
59};
60
61struct pktmbuf_info_s;
62struct pktmbuf_s;
63
64typedef struct pktmbuf_pool_cfg {
65 char *addr;
66 uint32_t bufcnt;
67 uint32_t bufsz;
68 uint32_t cache_sz;
69 uint32_t metadata_bufsz;
70 char *metadata;
71 mbuf_ops_t *ops;
72} pktmbuf_pool_cfg_t;
73
89
96#define CNE_MBUF_DEFAULT_DATAROOM (2 * 1024)
97#define CNE_MBUF_DEFAULT_BUF_SIZE CNE_MBUF_DEFAULT_DATAROOM
98
102struct pktmbuf_s {
103 void *pooldata;
104 void *buf_addr;
105 uint32_t hash;
106 uint32_t meta_index;
107 uint16_t data_off;
108 uint16_t lport;
109 uint16_t buf_len;
110 uint16_t data_len;
111
112 /*
113 * The packet type, which is the combination of outer/inner L2, L3, L4
114 * and tunnel types. The packet_type is about data really present in the
115 * pktmbuf. Example: if vlan stripping is enabled, a received vlan packet
116 * would have CNE_PTYPE_L2_ETHER and not CNE_PTYPE_L2_VLAN because the
117 * vlan is stripped from the data.
118 */
120 union {
121 uint32_t packet_type;
123 struct {
124 uint8_t l2_type : 4;
125 uint8_t l3_type : 4;
126 uint8_t l4_type : 4;
127 uint8_t tun_type : 4;
129 union {
130 uint8_t inner_esp_next_proto;
136 struct {
137 uint8_t inner_l2_type : 4;
138 uint8_t inner_l3_type : 4;
139 };
140 };
141 uint8_t inner_l4_type : 4;
142 };
143 };
144
155 union {
156 CNE_ATOMIC(uint_least16_t) refcnt_atomic;
157 uint16_t refcnt;
158 };
159
160 uint16_t rsvd16;
161
162 /* fields to support TX offloads */
164 union {
165 uint64_t tx_offload;
167 struct {
168 uint64_t l2_len : CNE_MBUF_L2_LEN_BITS;
172 uint64_t l3_len : CNE_MBUF_L3_LEN_BITS;
173 uint64_t l4_len : CNE_MBUF_L4_LEN_BITS;
174 uint64_t tso_segsz : CNE_MBUF_TSO_SEGSZ_BITS;
175
176 /*
177 * Fields for Tx offloading of tunnels.
178 * These are undefined for packets which don't request
179 * any tunnel offloads (outer IP or UDP checksum,
180 * tunnel TSO).
181 *
182 * PMDs should not use these fields unconditionally
183 * when calculating offsets.
184 *
185 * Applications are expected to set appropriate tunnel
186 * offload flags when they fill in these fields.
187 */
188 uint64_t outer_l3_len : CNE_MBUF_OUTL3_LEN_BITS;
189 uint64_t outer_l2_len : CNE_MBUF_OUTL2_LEN_BITS;
190
191 /* uint64_t unused:CNE_MBUF_TXOFLD_UNUSED_BITS; */
192 };
193 };
194
195 uint64_t ol_flags;
196
198 union {
199 void *userptr;
200 uint64_t udata64;
201 };
203
204typedef struct pktmbuf_s pktmbuf_t;
205
219
227
245CNDP_API pktmbuf_info_t *pktmbuf_pool_create(char *addr, uint32_t bufcnt, uint32_t bufsz,
246 uint32_t cache_sz, mbuf_ops_t *ops);
247
264CNDP_API pktmbuf_info_t *pktmbuf_pool_cfg_create(const pktmbuf_pool_cfg_t *cfg);
265
282typedef int (*pktmbuf_cb_t)(pktmbuf_info_t *pi, pktmbuf_t *buf, uint32_t sz, uint32_t idx,
283 void *ud);
284
298CNDP_API int pktmbuf_iterate(pktmbuf_info_t *pi, pktmbuf_cb_t cb, void *ud);
299
306#define pktmbuf_hash(m) ((m)->hash)
307
314#define pktmbuf_pooldata(m) ((m)->pooldata)
315
322#define pktmbuf_buf_addr(m) ((m)->buf_addr)
323
330#define pktmbuf_port(m) ((m)->lport)
331
338#define pktmbuf_buf_len(m) ((m)->buf_len)
339
346#define pktmbuf_tx_offload(m) ((m)->tx_offload)
347
354#define pktmbuf_userptr(m) ((m)->userptr)
355
362#define pktmbuf_udata64(m) ((m)->udata64)
363
370#define pktmbuf_data_len(m) ((m)->data_len)
371
378#define pktmbuf_data_off(m) ((m)->data_off)
379
386#define pktmbuf_refcnt(m) ((m)->refcnt)
387
402#define pktmbuf_mtod_offset(m, t, o) ((t)((char *)pktmbuf_buf_addr(m) + pktmbuf_data_off(m) + (o)))
403
416#define pktmbuf_mtod(m, t) pktmbuf_mtod_offset(m, t, 0)
417
424#define pktmbuf_meta_index(m) ((m)->meta_index)
425
436static inline void
437pktmbuf_prefetch(pktmbuf_t *m)
438{
439 cne_prefetch0(m);
440}
441
450static inline char *
452{
453 /* gcc complains about calling this function even
454 * when not using it.
455 */
456 return (char *)pktmbuf_buf_addr(mb) + CNE_PKTMBUF_HEADROOM;
457}
458
459#ifdef CNE_LIBCNE_MBUF_DEBUG
460
462#define __pktmbuf_sanity_check(m, is_h) pktmbuf_sanity_check(m, is_h)
463
464#else /* CNE_LIBCNE_MBUF_DEBUG */
465
466// clang-format off
468#define __pktmbuf_sanity_check(m, is_h) do { } while (0)
469// clang-format on
470
471#endif /* CNE_LIBCNE_MBUF_DEBUG */
472
480static inline uint16_t
481pktmbuf_refcnt_read(const pktmbuf_t *m)
482{
483 return atomic_load_explicit(&m->refcnt_atomic, CNE_MEMORY_ORDER(relaxed));
484}
485
493static inline void
494pktmbuf_refcnt_set(pktmbuf_t *m, uint16_t new_value)
495{
496 atomic_store_explicit(&m->refcnt_atomic, new_value, CNE_MEMORY_ORDER(relaxed));
497}
498
499/* internal */
500static inline uint16_t
501__pktmbuf_refcnt_update(pktmbuf_t *m, int16_t value)
502{
503 return atomic_fetch_add_explicit(&m->refcnt_atomic, (uint16_t)value, CNE_MEMORY_ORDER(relaxed));
504}
505
515static inline uint16_t
516pktmbuf_refcnt_update(pktmbuf_t *m, int16_t value)
517{
518 uint16_t refcnt;
519
520 /*
521 * The atomic_add is an expensive operation, so we don't want to
522 * call it in the case where we know we are the unique holder of
523 * this mbuf (i.e. ref_cnt == 1). Otherwise, an atomic
524 * operation has to be used because concurrent accesses on the
525 * reference counter can occur.
526 */
527 refcnt = pktmbuf_refcnt_read(m);
528 if (likely(refcnt == 1)) {
529 refcnt = refcnt + value;
530 pktmbuf_refcnt_set(m, refcnt);
531 return (uint16_t)refcnt;
532 }
533
534 __pktmbuf_refcnt_update(m, value);
535
536 return pktmbuf_refcnt_read(m);
537}
538
539// clang-format off
541#define CNE_MBUF_PREFETCH_TO_FREE(m) do { \
542 if ((m) != NULL) \
543 cne_prefetch0(m); \
544 } while (0)
545// clang-format on
546
559CNDP_API void pktmbuf_sanity_check(const pktmbuf_t *m, int is_header);
560
580CNDP_API int pktmbuf_check(const pktmbuf_t *m, int is_header, const char **reason);
581
595static inline void
597{
598 if (pi) {
599 if (!str)
600 memset(pi->name, 0, sizeof(pi->name));
601 else
602 strlcpy(pi->name, str, sizeof(pi->name));
603 }
604}
605
614static inline const char *
616{
617 return (!pi) ? NULL : pi->name;
618}
619
626static inline void
628{
629 m->data_off = (uint16_t)CNE_MIN((uint16_t)CNE_PKTMBUF_HEADROOM, (uint16_t)pktmbuf_buf_len(m));
630}
631
638#define CNE_MBUF_INVALID_PORT UINT16_MAX
639
643static inline void
644pktmbuf_reset(pktmbuf_t *m)
645{
647
648 pktmbuf_data_len(m) = 0;
650 m->packet_type = 0;
651 m->tx_offload = 0;
652 m->ol_flags = 0;
653 m->hash = 0;
654}
655
669static inline int
670pktmbuf_alloc_bulk(pktmbuf_info_t *pi, pktmbuf_t **mbufs, unsigned count)
671{
672 return (!pi) ? -EINVAL : pi->ops.mbuf_alloc(pi, mbufs, count);
673}
674
688static inline pktmbuf_t *
690{
691 pktmbuf_t *m = NULL;
692
693 if (pktmbuf_alloc_bulk(pi, &m, 1) <= 0)
694 return NULL;
695
696 pktmbuf_reset(m);
697
698 return m;
699}
700
701/* internal */
702static inline void
703__pktmbuf_copy_hdr(pktmbuf_t *mdst, const pktmbuf_t *msrc)
704{
705 pktmbuf_port(mdst) = pktmbuf_port(msrc);
706}
707
720static __cne_always_inline pktmbuf_t *
722{
723 if (m) {
724 if (likely(pktmbuf_refcnt_read(m) == 1))
725 return m;
726 else if (__pktmbuf_refcnt_update(m, -1) == 0) {
727 pktmbuf_refcnt_set(m, 1);
728 return m;
729 }
730 }
731 return NULL;
732}
733
740static __cne_always_inline void
741pktmbuf_free(pktmbuf_t *m)
742{
743 m = pktmbuf_refcnt_free(m);
744 if (likely(m != NULL)) {
746
747 (void)pi->ops.mbuf_free(pi, &m, 1);
748 }
749}
750
751static __cne_always_inline void
752__pktmbuf_flush_pending(pktmbuf_pending_t *p)
753{
755
756 (void)pi->ops.mbuf_free(pi, p->pending, p->nb_pending);
757 p->nb_pending = 0;
758}
759
776static __cne_always_inline void
777__pktmbuf_free_bulk(pktmbuf_pending_t *p, pktmbuf_t *m)
778{
779 m = pktmbuf_refcnt_free(m);
780
781 if (likely(m != NULL)) {
782 if (p->nb_pending == p->pending_sz || (p->nb_pending > 0 && m->pooldata != p->pooldata)) {
783 __pktmbuf_flush_pending(p);
784 p->pooldata = m->pooldata;
785 }
786
787 p->pending[p->nb_pending++] = m;
788 }
789}
790
800static inline void
801pktmbuf_free_bulk(pktmbuf_t **mbufs, unsigned int count)
802{
804
805 memset(&pend, 0, sizeof(pend));
807
808 if (count == 0)
809 return;
810
811 pend.pooldata = mbufs[0]->pooldata;
812
813 for (unsigned int idx = 0; idx < count; idx++)
814 __pktmbuf_free_bulk(&pend, mbufs[idx]);
815
816 if (pend.nb_pending)
817 __pktmbuf_flush_pending(&pend);
818}
819
841CNDP_API pktmbuf_t *pktmbuf_copy(const pktmbuf_t *m, pktmbuf_info_t *pi, uint32_t offset,
842 uint32_t length);
843
852static inline uint16_t
853pktmbuf_headroom(const pktmbuf_t *m)
854{
856 return pktmbuf_data_off(m);
857}
858
867static inline uint16_t
868pktmbuf_tailroom(const pktmbuf_t *m)
869{
871 return (uint16_t)(pktmbuf_buf_len(m) - pktmbuf_data_off(m) - pktmbuf_data_len(m));
872}
873
884static inline char *
885pktmbuf_mtod_last(const pktmbuf_t *m)
886{
888 return pktmbuf_mtod_offset(m, char *, pktmbuf_data_len(m));
889}
890
901static inline char *
902pktmbuf_mtod_end(const pktmbuf_t *m)
903{
905 return (char *)CNE_PTR_ADD((char *)(uintptr_t)m, pktmbuf_buf_len(m) + sizeof(pktmbuf_t));
906}
907
923static inline char *
924pktmbuf_prepend(pktmbuf_t *m, uint16_t len)
925{
927
928 if (unlikely(len > pktmbuf_headroom(m)))
929 return NULL;
930
931 /* NB: elaborating the subtraction like this instead of using
932 * -= allows us to ensure the result type is uint16_t
933 * avoiding compiler warnings on gcc 8.1 at least */
934 pktmbuf_data_off(m) = (uint16_t)(pktmbuf_data_off(m) - len);
935 pktmbuf_data_len(m) = (uint16_t)(pktmbuf_data_len(m) + len);
936
937 return pktmbuf_mtod(m, char *);
938}
939
954static inline char *
955pktmbuf_adj_offset(pktmbuf_t *m, int16_t len)
956{
957 uint16_t alen = abs(len);
958
960
961 if (likely(len >= 0)) {
962 if (unlikely(alen > pktmbuf_data_len(m)))
963 return NULL;
964 if (unlikely((alen + pktmbuf_data_off(m)) > pktmbuf_buf_len(m)))
965 return NULL;
966
967 /* NB: elaborating the subtraction like this instead of using
968 * -= allows us to ensure the result type is uint16_t
969 * avoiding compiler warnings on gcc 8.1 at least */
970 pktmbuf_data_off(m) = (uint16_t)(pktmbuf_data_off(m) + alen);
971 pktmbuf_data_len(m) = (uint16_t)(pktmbuf_data_len(m) - alen);
972 } else {
973 if (unlikely(alen > pktmbuf_data_off(m)))
974 return NULL;
975
976 /* NB: elaborating the subtraction like this instead of using
977 * -= allows us to ensure the result type is uint16_t
978 * avoiding compiler warnings on gcc 8.1 at least */
979 pktmbuf_data_off(m) = (uint16_t)(pktmbuf_data_off(m) - alen);
980 pktmbuf_data_len(m) = (uint16_t)(pktmbuf_data_len(m) + alen);
981 }
982 return pktmbuf_mtod(m, char *);
983}
984
985#define pktmbuf_adjust(m, t, len) (t) pktmbuf_adj_offset(m, len)
986
1001static inline char *
1002pktmbuf_append(pktmbuf_t *m, uint16_t len)
1003{
1004 void *tail;
1005
1007
1008 if (unlikely(len > pktmbuf_tailroom(m)))
1009 return NULL;
1010
1011 tail = (char *)pktmbuf_buf_addr(m) + pktmbuf_data_off(m) + pktmbuf_data_len(m);
1012 pktmbuf_data_len(m) = (uint16_t)(pktmbuf_data_len(m) + len);
1013 return (char *)tail;
1014}
1015
1030static inline int
1031pktmbuf_trim(pktmbuf_t *m, uint16_t len)
1032{
1034
1035 if (unlikely(len > pktmbuf_data_len(m)))
1036 return -1;
1037
1038 pktmbuf_data_len(m) = (uint16_t)(pktmbuf_data_len(m) - len);
1039
1040 return 0;
1041}
1042
1046const void *__pktmbuf_read(const pktmbuf_t *m, uint32_t off, uint32_t len, void *buf);
1047
1065static inline const void *
1066pktmbuf_read(const pktmbuf_t *m, uint32_t off, uint32_t len, void *buf)
1067{
1068 if (likely(off + len <= pktmbuf_data_len(m)))
1069 return pktmbuf_mtod_offset(m, char *, off);
1070 else
1071 return __pktmbuf_read(m, off, len, buf);
1072}
1073
1077const void *__pktmbuf_write(const void *buf, uint32_t len, pktmbuf_t *m, uint32_t off);
1078
1096static inline const void *
1097pktmbuf_write(const void *buf, uint32_t len, pktmbuf_t *m, uint32_t off)
1098{
1099 if (likely((len + off) > pktmbuf_tailroom(m)))
1100 return NULL;
1101 else
1102 return __pktmbuf_write(buf, len, m, off);
1103}
1104
1116static inline uint16_t
1118{
1119 return mempool_objsz(mp) - sizeof(pktmbuf_t);
1120}
1121
1132CNDP_API pktmbuf_t *pktmbuf_clone(pktmbuf_t *md, pktmbuf_info_t *pi);
1133
1148CNDP_API void pktmbuf_dump(const char *msg, const pktmbuf_t *m, unsigned dump_len);
1149
1158const char *cne_get_rx_ol_flag_name(uint64_t mask);
1159
1172int cne_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
1173
1184const char *cne_get_tx_ol_flag_name(uint64_t mask);
1185
1198int cne_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen);
1199
1208static inline void *
1209pktmbuf_metadata(const pktmbuf_t *m)
1210{
1211 pktmbuf_info_t *p;
1212
1213 if (!m)
1214 return NULL;
1215
1216 if (((p = (pktmbuf_info_t *)m->pooldata) != NULL) && p->metadata)
1217 return CNE_PTR_ADD(p->metadata, (m->meta_index * p->metadata_bufsz));
1218 else
1219 return CNE_PTR_ADD(m, sizeof(pktmbuf_t)); /* default to metadata in pktmbuf headroom */
1220}
1221
1230static inline int32_t
1231pktmbuf_metadata_bufsz(const pktmbuf_t *m)
1232{
1233 pktmbuf_info_t *p;
1234
1235 if (!m)
1236 return -1;
1237
1238 if (((p = (pktmbuf_info_t *)m->pooldata) != NULL) && p->metadata)
1239 return (int32_t)p->metadata_bufsz;
1240 else
1241 return (int32_t)pktmbuf_headroom(m);
1242}
1243
1267CNDP_API int pktmbuf_pool_cfg(pktmbuf_pool_cfg_t *c, void *addr, uint32_t bufcnt, uint32_t bufsz,
1268 uint32_t cache_sz, void *metadata, uint32_t metadata_bufsz,
1269 mbuf_ops_t *ops);
1270
1277CNDP_API void pktmbuf_info_dump(void);
1278
1279#ifdef __cplusplus
1280}
1281#endif
1282
1283#endif /* _PKTMBUF_H_ */
#define likely(x)
#define unlikely(x)
#define CNE_PTR_ADD(ptr, x)
Definition cne_common.h:235
#define CNE_STD_C11
Definition cne_common.h:91
#define CNE_MIN(a, b)
Definition cne_common.h:550
#define __cne_cache_aligned
Definition cne_common.h:379
#define __cne_always_inline
Definition cne_common.h:218
void mempool_t
Definition mempool.h:45
CNDP_API int mempool_objsz(mempool_t *mp)
const char * cne_get_rx_ol_flag_name(uint64_t mask)
#define pktmbuf_data_len(m)
Definition pktmbuf.h:370
static void pktmbuf_info_name_set(pktmbuf_info_t *pi, const char *str)
Definition pktmbuf.h:596
@ DEFAULT_MBUF_SIZE
Definition pktmbuf.h:56
@ DEFAULT_BURST_SIZE
Definition pktmbuf.h:54
@ PKTMBUF_INFO_NAME_SZ
Definition pktmbuf.h:58
@ DEFAULT_MBUF_COUNT
Definition pktmbuf.h:55
@ PKTMBUF_PENDING_SZ
Definition pktmbuf.h:57
const char * cne_get_tx_ol_flag_name(uint64_t mask)
static __cne_always_inline void pktmbuf_free(pktmbuf_t *m)
Definition pktmbuf.h:741
static const void * pktmbuf_read(const pktmbuf_t *m, uint32_t off, uint32_t len, void *buf)
Definition pktmbuf.h:1066
CNDP_API void pktmbuf_info_dump(void)
static uint16_t pktmbuf_refcnt_read(const pktmbuf_t *m)
Definition pktmbuf.h:481
int cne_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
struct pktmbuf_pending pktmbuf_pending_t
#define pktmbuf_buf_addr(m)
Definition pktmbuf.h:322
static char * pktmbuf_append(pktmbuf_t *m, uint16_t len)
Definition pktmbuf.h:1002
static void pktmbuf_refcnt_set(pktmbuf_t *m, uint16_t new_value)
Definition pktmbuf.h:494
static char * pktmbuf_mtod_end(const pktmbuf_t *m)
Definition pktmbuf.h:902
static char * pktmbuf_prepend(pktmbuf_t *m, uint16_t len)
Definition pktmbuf.h:924
CNDP_API void pktmbuf_sanity_check(const pktmbuf_t *m, int is_header)
static __cne_always_inline pktmbuf_t * pktmbuf_refcnt_free(pktmbuf_t *m)
Definition pktmbuf.h:721
int cne_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
static void pktmbuf_reset(pktmbuf_t *m)
Definition pktmbuf.h:644
static char * pktmbuf_adj_offset(pktmbuf_t *m, int16_t len)
Definition pktmbuf.h:955
#define pktmbuf_mtod(m, t)
Definition pktmbuf.h:416
static void pktmbuf_reset_headroom(pktmbuf_t *m)
Definition pktmbuf.h:627
CNDP_API pktmbuf_info_t * pktmbuf_pool_create(char *addr, uint32_t bufcnt, uint32_t bufsz, uint32_t cache_sz, mbuf_ops_t *ops)
static int pktmbuf_alloc_bulk(pktmbuf_info_t *pi, pktmbuf_t **mbufs, unsigned count)
Definition pktmbuf.h:670
static int32_t pktmbuf_metadata_bufsz(const pktmbuf_t *m)
Definition pktmbuf.h:1231
static uint16_t pktmbuf_tailroom(const pktmbuf_t *m)
Definition pktmbuf.h:868
static char * pktmbuf_data_addr_default(pktmbuf_t *mb)
Definition pktmbuf.h:451
#define pktmbuf_port(m)
Definition pktmbuf.h:330
static const char * pktmbuf_info_name_get(pktmbuf_info_t *pi)
Definition pktmbuf.h:615
#define pktmbuf_mtod_offset(m, t, o)
Definition pktmbuf.h:402
static void pktmbuf_free_bulk(pktmbuf_t **mbufs, unsigned int count)
Definition pktmbuf.h:801
int(*) pktmbuf_cb_t(pktmbuf_info_t *pi, pktmbuf_t *buf, uint32_t sz, uint32_t idx, void *ud)
Definition pktmbuf.h:282
#define CNE_MBUF_INVALID_PORT
Definition pktmbuf.h:638
CNDP_API pktmbuf_t * pktmbuf_clone(pktmbuf_t *md, pktmbuf_info_t *pi)
static char * pktmbuf_mtod_last(const pktmbuf_t *m)
Definition pktmbuf.h:885
#define __pktmbuf_sanity_check(m, is_h)
Definition pktmbuf.h:468
static int pktmbuf_trim(pktmbuf_t *m, uint16_t len)
Definition pktmbuf.h:1031
static void pktmbuf_prefetch(pktmbuf_t *m)
Definition pktmbuf.h:437
CNDP_API pktmbuf_t * pktmbuf_copy(const pktmbuf_t *m, pktmbuf_info_t *pi, uint32_t offset, uint32_t length)
static const void * pktmbuf_write(const void *buf, uint32_t len, pktmbuf_t *m, uint32_t off)
Definition pktmbuf.h:1097
#define pktmbuf_buf_len(m)
Definition pktmbuf.h:338
CNDP_API void pktmbuf_destroy(pktmbuf_info_t *pi)
static uint16_t pktmbuf_refcnt_update(pktmbuf_t *m, int16_t value)
Definition pktmbuf.h:516
static uint16_t pktmbuf_headroom(const pktmbuf_t *m)
Definition pktmbuf.h:853
CNDP_API int pktmbuf_check(const pktmbuf_t *m, int is_header, const char **reason)
CNDP_API pktmbuf_info_t * pktmbuf_pool_cfg_create(const pktmbuf_pool_cfg_t *cfg)
static uint16_t pktmbuf_data_room_size(mempool_t *mp)
Definition pktmbuf.h:1117
struct pktmbuf_info_s pktmbuf_info_t
#define pktmbuf_data_off(m)
Definition pktmbuf.h:378
CNDP_API int pktmbuf_iterate(pktmbuf_info_t *pi, pktmbuf_cb_t cb, void *ud)
static pktmbuf_t * pktmbuf_alloc(pktmbuf_info_t *pi)
Definition pktmbuf.h:689
CNDP_API void pktmbuf_dump(const char *msg, const pktmbuf_t *m, unsigned dump_len)
static void * pktmbuf_metadata(const pktmbuf_t *m)
Definition pktmbuf.h:1209
struct mbuf_ops mbuf_ops_t
mbuf_alloc_t mbuf_alloc
Definition pktmbuf_ops.h:75
mbuf_free_t mbuf_free
Definition pktmbuf_ops.h:76
uint32_t bufsz
Definition pktmbuf.h:84
char name[PKTMBUF_INFO_NAME_SZ]
Definition pktmbuf.h:79
uint32_t metadata_bufsz
Definition pktmbuf.h:86
TAILQ_ENTRY(pktmbuf_info_s) next
void * pd
Definition pktmbuf.h:81
uint32_t cache_sz
Definition pktmbuf.h:85
uint32_t bufcnt
Definition pktmbuf.h:83
mbuf_ops_t ops
Definition pktmbuf.h:82
char * metadata
Definition pktmbuf.h:87
void * addr
Definition pktmbuf.h:80
pktmbuf_t * pending[PKTMBUF_PENDING_SZ]
Definition pktmbuf.h:217
uint16_t nb_pending
Definition pktmbuf.h:214
void * pooldata
Definition pktmbuf.h:216
uint16_t pending_sz
Definition pktmbuf.h:215
uint32_t hash
Definition pktmbuf.h:105
uint64_t ol_flags
Definition pktmbuf.h:195
uint32_t meta_index
Definition pktmbuf.h:106
uint16_t data_off
Definition pktmbuf.h:107
uint16_t lport
Definition pktmbuf.h:108
uint16_t buf_len
Definition pktmbuf.h:109
void * pooldata
Definition pktmbuf.h:103
void * buf_addr
Definition pktmbuf.h:104
uint16_t data_len
Definition pktmbuf.h:110