MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_alloc_item

Function ng_alloc_item

lib/ff_ng_base.c:3001–3023  ·  view source on GitHub ↗

* Get a queue entry. * This is usually called when a packet first enters netgraph. * By definition, this is usually from an interrupt, or from a user. * Users are not so important, but try be quick for the times that it's * an interrupt. */

Source from the content-addressed store, hash-verified

2999 * an interrupt.
3000 */
3001static __inline item_p
3002ng_alloc_item(int type, int flags)
3003{
3004 item_p item;
3005
3006 KASSERT(((type & ~NGQF_TYPE) == 0),
3007 ("%s: incorrect item type: %d", __func__, type));
3008
3009 item = uma_zalloc((type == NGQF_DATA) ? ng_qdzone : ng_qzone,
3010 ((flags & NG_WAITOK) ? M_WAITOK : M_NOWAIT) | M_ZERO);
3011
3012 if (item) {
3013 item->el_flags = type;
3014#ifdef NETGRAPH_DEBUG
3015 mtx_lock(&ngq_mtx);
3016 TAILQ_INSERT_TAIL(&ng_itemlist, item, all);
3017 allocated++;
3018 mtx_unlock(&ngq_mtx);
3019#endif
3020 }
3021
3022 return (item);
3023}
3024
3025/*
3026 * Release a queue entry

Callers 7

ng_realloc_itemFunction · 0.70
ng_package_dataFunction · 0.70
ng_package_msgFunction · 0.70
ng_package_msg_selfFunction · 0.70
ng_send_fn1Function · 0.70
ng_send_fn2Function · 0.70
ng_calloutFunction · 0.70

Calls 3

uma_zallocFunction · 0.50
mtx_lockFunction · 0.50
mtx_unlockFunction · 0.50

Tested by

no test coverage detected