* 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. */
| 2999 | * an interrupt. |
| 3000 | */ |
| 3001 | static __inline item_p |
| 3002 | ng_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 |
no test coverage detected