37 #include <bsd/string.h>                    
   69     uint32_t metadata_bufsz; 
 
   96 #define CNE_MBUF_DEFAULT_DATAROOM (2 * 1024) 
   97 #define CNE_MBUF_DEFAULT_BUF_SIZE CNE_MBUF_DEFAULT_DATAROOM 
  156         CNE_ATOMIC(uint_least16_t) refcnt_atomic; 
 
  202 } __cne_cache_aligned;
 
  306 #define pktmbuf_hash(m) ((m)->hash) 
  314 #define pktmbuf_pooldata(m) ((m)->pooldata) 
  322 #define pktmbuf_buf_addr(m) ((m)->buf_addr) 
  330 #define pktmbuf_port(m) ((m)->lport) 
  338 #define pktmbuf_buf_len(m) ((m)->buf_len) 
  346 #define pktmbuf_tx_offload(m) ((m)->tx_offload) 
  354 #define pktmbuf_userptr(m) ((m)->userptr) 
  362 #define pktmbuf_udata64(m) ((m)->udata64) 
  370 #define pktmbuf_data_len(m) ((m)->data_len) 
  378 #define pktmbuf_data_off(m) ((m)->data_off) 
  386 #define pktmbuf_refcnt(m) ((m)->refcnt) 
  402 #define pktmbuf_mtod_offset(m, t, o) ((t)((char *)pktmbuf_buf_addr(m) + pktmbuf_data_off(m) + (o))) 
  416 #define pktmbuf_mtod(m, t) pktmbuf_mtod_offset(m, t, 0) 
  424 #define pktmbuf_meta_index(m) ((m)->meta_index) 
  459 #ifdef CNE_LIBCNE_MBUF_DEBUG 
  462 #define __pktmbuf_sanity_check(m, is_h) pktmbuf_sanity_check(m, is_h) 
  468 #define __pktmbuf_sanity_check(m, is_h) do { } while (0) 
  480 static inline uint16_t
 
  483     return atomic_load_explicit(&m->refcnt_atomic, CNE_MEMORY_ORDER(relaxed));
 
  496     atomic_store_explicit(&m->refcnt_atomic, new_value, CNE_MEMORY_ORDER(relaxed));
 
  500 static inline uint16_t
 
  501 __pktmbuf_refcnt_update(
pktmbuf_t *m, int16_t value)
 
  503     return atomic_fetch_add_explicit(&m->refcnt_atomic, (uint16_t)value, CNE_MEMORY_ORDER(relaxed));
 
  515 static inline uint16_t
 
  528     if (
likely(refcnt == 1)) {
 
  529         refcnt = refcnt + value;
 
  531         return (uint16_t)refcnt;
 
  534     __pktmbuf_refcnt_update(m, value);
 
  541 #define CNE_MBUF_PREFETCH_TO_FREE(m) do {       \ 
  600             memset(pi->
name, 0, 
sizeof(pi->
name));
 
  602             strlcpy(pi->
name, str, 
sizeof(pi->
name));
 
  614 static inline const char *
 
  617     return (!pi) ? NULL : pi->
name;
 
  638 #define CNE_MBUF_INVALID_PORT UINT16_MAX 
  672     return (!pi) ? -EINVAL : pi->
ops.
mbuf_alloc(pi, mbufs, count);
 
  726         else if (__pktmbuf_refcnt_update(m, -1) == 0) {
 
  783             __pktmbuf_flush_pending(p);
 
  805     memset(&pend, 0, 
sizeof(pend));
 
  813     for (
unsigned int idx = 0; idx < count; idx++)
 
  814         __pktmbuf_free_bulk(&pend, mbufs[idx]);
 
  817         __pktmbuf_flush_pending(&pend);
 
  852 static inline uint16_t
 
  867 static inline uint16_t
 
  957     uint16_t alen = abs(len);
 
  985 #define pktmbuf_adjust(m, t, len) (t) pktmbuf_adj_offset(m, len) 
 1001 static inline char *
 
 1013     return (
char *)tail;
 
 1046 const void *__pktmbuf_read(
const pktmbuf_t *m, uint32_t off, uint32_t len, 
void *buf);
 
 1065 static inline const void *
 
 1071         return __pktmbuf_read(m, off, len, buf);
 
 1077 const void *__pktmbuf_write(
const void *buf, uint32_t len, 
pktmbuf_t *m, uint32_t off);
 
 1096 static inline const void *
 
 1102         return __pktmbuf_write(buf, len, m, off);
 
 1116 static inline uint16_t
 
 1208 static inline void *
 
 1230 static inline int32_t
 
 1267 CNDP_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,
 
#define CNE_PTR_ADD(ptr, x)
 
#define __cne_always_inline
 
static void cne_prefetch0(const volatile void *p)
 
CNDP_API int mempool_objsz(mempool_t *mp)
 
#define pktmbuf_data_len(m)
 
static void pktmbuf_info_name_set(pktmbuf_info_t *pi, const char *str)
 
static __cne_always_inline void pktmbuf_free(pktmbuf_t *m)
 
CNDP_API void pktmbuf_info_dump(void)
 
static pktmbuf_t * pktmbuf_alloc(pktmbuf_info_t *pi)
 
static char * pktmbuf_data_addr_default(pktmbuf_t *mb)
 
static uint16_t pktmbuf_refcnt_read(const pktmbuf_t *m)
 
int cne_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 
struct pktmbuf_pending pktmbuf_pending_t
 
static char * pktmbuf_adj_offset(pktmbuf_t *m, int16_t len)
 
#define pktmbuf_buf_addr(m)
 
static void pktmbuf_refcnt_set(pktmbuf_t *m, uint16_t new_value)
 
CNDP_API void pktmbuf_sanity_check(const pktmbuf_t *m, int is_header)
 
static void * pktmbuf_metadata(const pktmbuf_t *m)
 
static __cne_always_inline pktmbuf_t * pktmbuf_refcnt_free(pktmbuf_t *m)
 
int cne_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
 
static void pktmbuf_reset(pktmbuf_t *m)
 
const char * cne_get_rx_ol_flag_name(uint64_t mask)
 
static const void * pktmbuf_read(const pktmbuf_t *m, uint32_t off, uint32_t len, void *buf)
 
static char * pktmbuf_mtod_end(const pktmbuf_t *m)
 
#define pktmbuf_mtod(m, t)
 
static void pktmbuf_reset_headroom(pktmbuf_t *m)
 
static int pktmbuf_alloc_bulk(pktmbuf_info_t *pi, pktmbuf_t **mbufs, unsigned count)
 
static int32_t pktmbuf_metadata_bufsz(const pktmbuf_t *m)
 
static uint16_t pktmbuf_tailroom(const pktmbuf_t *m)
 
static char * pktmbuf_mtod_last(const pktmbuf_t *m)
 
CNDP_API pktmbuf_t * pktmbuf_clone(pktmbuf_t *md, pktmbuf_info_t *pi)
 
int(* pktmbuf_cb_t)(pktmbuf_info_t *pi, pktmbuf_t *buf, uint32_t sz, uint32_t idx, void *ud)
 
#define pktmbuf_mtod_offset(m, t, o)
 
static void pktmbuf_free_bulk(pktmbuf_t **mbufs, unsigned int count)
 
#define CNE_MBUF_INVALID_PORT
 
static const void * pktmbuf_write(const void *buf, uint32_t len, pktmbuf_t *m, uint32_t off)
 
CNDP_API pktmbuf_t * pktmbuf_copy(const pktmbuf_t *m, pktmbuf_info_t *pi, uint32_t offset, uint32_t length)
 
const char * cne_get_tx_ol_flag_name(uint64_t mask)
 
#define __pktmbuf_sanity_check(m, is_h)
 
static int pktmbuf_trim(pktmbuf_t *m, uint16_t len)
 
static void pktmbuf_prefetch(pktmbuf_t *m)
 
static const char * pktmbuf_info_name_get(pktmbuf_info_t *pi)
 
CNDP_API int pktmbuf_pool_cfg(pktmbuf_pool_cfg_t *c, void *addr, uint32_t bufcnt, uint32_t bufsz, uint32_t cache_sz, void *metadata, uint32_t metadata_bufsz, mbuf_ops_t *ops)
 
#define pktmbuf_buf_len(m)
 
static char * pktmbuf_prepend(pktmbuf_t *m, uint16_t len)
 
CNDP_API void pktmbuf_destroy(pktmbuf_info_t *pi)
 
CNDP_API pktmbuf_info_t * pktmbuf_pool_cfg_create(const pktmbuf_pool_cfg_t *cfg)
 
static uint16_t pktmbuf_refcnt_update(pktmbuf_t *m, int16_t value)
 
static uint16_t pktmbuf_headroom(const pktmbuf_t *m)
 
CNDP_API int pktmbuf_check(const pktmbuf_t *m, int is_header, const char **reason)
 
static uint16_t pktmbuf_data_room_size(mempool_t *mp)
 
CNDP_API pktmbuf_info_t * pktmbuf_pool_create(char *addr, uint32_t bufcnt, uint32_t bufsz, uint32_t cache_sz, mbuf_ops_t *ops)
 
struct pktmbuf_info_s pktmbuf_info_t
 
#define pktmbuf_data_off(m)
 
CNDP_API int pktmbuf_iterate(pktmbuf_info_t *pi, pktmbuf_cb_t cb, void *ud)
 
CNDP_API void pktmbuf_dump(const char *msg, const pktmbuf_t *m, unsigned dump_len)
 
static char * pktmbuf_append(pktmbuf_t *m, uint16_t len)
 
char name[PKTMBUF_INFO_NAME_SZ]
 
TAILQ_ENTRY(pktmbuf_info_s) next
 
pktmbuf_t * pending[PKTMBUF_PENDING_SZ]
 
uint8_t inner_esp_next_proto