* 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. */
| 2975 | * an interrupt. |
| 2976 | */ |
| 2977 | static __inline item_p |
| 2978 | ng_alloc_item(int type, int flags) |
| 2979 | { |
| 2980 | item_p item; |
| 2981 | |
| 2982 | KASSERT(((type & ~NGQF_TYPE) == 0), |
| 2983 | ("%s: incorrect item type: %d", __func__, type)); |
| 2984 | |
| 2985 | item = uma_zalloc((type == NGQF_DATA) ? ng_qdzone : ng_qzone, |
| 2986 | ((flags & NG_WAITOK) ? M_WAITOK : M_NOWAIT) | M_ZERO); |
| 2987 | |
| 2988 | if (item) { |
| 2989 | item->el_flags = type; |
| 2990 | #ifdef NETGRAPH_DEBUG |
| 2991 | mtx_lock(&ngq_mtx); |
| 2992 | TAILQ_INSERT_TAIL(&ng_itemlist, item, all); |
| 2993 | allocated++; |
| 2994 | mtx_unlock(&ngq_mtx); |
| 2995 | #endif |
| 2996 | } |
| 2997 | |
| 2998 | return (item); |
| 2999 | } |
| 3000 | |
| 3001 | /* |
| 3002 | * Release a queue entry |
no test coverage detected