Lines Matching refs:item

224 static int    ng_generic_msg(node_p here, item_p item, hook_p lasthook);
231 static int ng_apply_item(node_p node, item_p item, int rw);
236 static int ng_con_nodes(item_p item, node_p node, const char *name,
238 static int ng_con_part2(node_p node, item_p item, hook_p hook);
239 static int ng_con_part3(node_p node, item_p item, hook_p hook);
1347 ng_con_part3(node_p node, item_p item, hook_p hook) in ng_con_part3() argument
1385 NG_FREE_ITEM(item); in ng_con_part3()
1390 ng_con_part2(node_p node, item_p item, hook_p hook) in ng_con_part2() argument
1466 if ((error = ng_send_fn2(peer->hk_node, peer, item, &ng_con_part3, in ng_con_part2()
1475 NG_FREE_ITEM(item); in ng_con_part2()
1484 ng_con_nodes(item_p item, node_p node, const char *name, in ng_con_nodes() argument
1518 if ((error = ng_send_fn2(node2, hook2, item, &ng_con_part2, NULL, 0, in ng_con_nodes()
1863 static __inline void ng_queue_rw(node_p node, item_p item, int rw);
1865 static __inline item_p ng_acquire_read(node_p node, item_p item);
1866 static __inline item_p ng_acquire_write(node_p node, item_p item);
1953 item_p item; in ng_dequeue() local
2005 item = STAILQ_FIRST(&ngq->queue); in ng_dequeue()
2010 "flags 0x%lx", __func__, node->nd_ID, node, item, *rw ? "WRITER" : in ng_dequeue()
2012 return (item); in ng_dequeue()
2020 ng_queue_rw(node_p node, item_p item, int rw) in ng_queue_rw() argument
2024 NGI_SET_WRITER(item); in ng_queue_rw()
2026 NGI_SET_READER(item); in ng_queue_rw()
2027 item->depth = 1; in ng_queue_rw()
2032 STAILQ_INSERT_TAIL(&ngq->queue, item, el_next); in ng_queue_rw()
2035 node->nd_ID, node, item, rw ? "WRITER" : "READER" ); in ng_queue_rw()
2048 ng_acquire_read(node_p node, item_p item) in ng_acquire_read() argument
2062 __func__, node->nd_ID, node, item); in ng_acquire_read()
2063 return (item); in ng_acquire_read()
2069 ng_queue_rw(node, item, NGQRW_R); in ng_acquire_read()
2076 ng_acquire_write(node_p node, item_p item) in ng_acquire_write() argument
2086 __func__, node->nd_ID, node, item); in ng_acquire_write()
2087 return (item); in ng_acquire_write()
2091 ng_queue_rw(node, item, NGQRW_W); in ng_acquire_write()
2098 ng_upgrade_write(node_p node, item_p item)
2104 NGI_SET_WRITER(item);
2124 ng_apply_item(node, item, 0);
2149 STAILQ_INSERT_HEAD(&ngq->queue, item, el_next);
2151 __func__, node->nd_ID, node, item );
2182 item_p item; in ng_flush_input_queue() local
2185 while ((item = STAILQ_FIRST(&ngq->queue)) != NULL) { in ng_flush_input_queue()
2192 if (item->apply != NULL) { in ng_flush_input_queue()
2193 if (item->depth == 1) in ng_flush_input_queue()
2194 item->apply->error = ENOENT; in ng_flush_input_queue()
2195 if (refcount_release(&item->apply->refs)) { in ng_flush_input_queue()
2196 (*item->apply->apply)(item->apply->context, in ng_flush_input_queue()
2197 item->apply->error); in ng_flush_input_queue()
2200 NG_FREE_ITEM(item); in ng_flush_input_queue()
2231 ng_snd_item(item_p item, int flags) in ng_snd_item() argument
2242 KASSERT(item != NULL, ("ng_snd_item: item is NULL")); in ng_snd_item()
2245 _ngi_check(item, __FILE__, __LINE__); in ng_snd_item()
2249 if (item->apply) in ng_snd_item()
2250 refcount_acquire(&item->apply->refs); in ng_snd_item()
2252 node = NGI_NODE(item); in ng_snd_item()
2256 hook = NGI_HOOK(item); in ng_snd_item()
2258 if ((item->el_flags & NGQF_TYPE) == NGQF_DATA) { in ng_snd_item()
2260 if (NGI_M(item) == NULL) in ng_snd_item()
2262 CHECK_DATA_MBUF(NGI_M(item)); in ng_snd_item()
2271 if (((item->el_flags & NGQF_RW) == NGQF_WRITER) || in ng_snd_item()
2311 ng_queue_rw(node, item, rw); in ng_snd_item()
2320 item = ng_acquire_read(node, item); in ng_snd_item()
2322 item = ng_acquire_write(node, item); in ng_snd_item()
2325 if (item == NULL) in ng_snd_item()
2329 NGI_GET_NODE(item, node); /* zaps stored node */ in ng_snd_item()
2331 item->depth++; in ng_snd_item()
2333 error = ng_apply_item(node, item, rw); /* drops r/w lock when done */ in ng_snd_item()
2335 error = ng_apply_item(node, item, 0); in ng_snd_item()
2359 if (item->apply != NULL) { in ng_snd_item()
2360 if (item->depth == 0 && error != 0) in ng_snd_item()
2361 item->apply->error = error; in ng_snd_item()
2362 if (refcount_release(&item->apply->refs)) { in ng_snd_item()
2363 (*item->apply->apply)(item->apply->context, in ng_snd_item()
2364 item->apply->error); in ng_snd_item()
2368 NG_FREE_ITEM(item); in ng_snd_item()
2379 ng_apply_item(node_p node, item_p item, int rw) in ng_apply_item() argument
2389 KASSERT(item != NULL, ("ng_apply_item: item is NULL")); in ng_apply_item()
2391 NGI_GET_HOOK(item, hook); /* clears stored hook */ in ng_apply_item()
2393 _ngi_check(item, __FILE__, __LINE__); in ng_apply_item()
2396 apply = item->apply; in ng_apply_item()
2397 depth = item->depth; in ng_apply_item()
2399 switch (item->el_flags & NGQF_TYPE) { in ng_apply_item()
2408 NG_FREE_ITEM(item); in ng_apply_item()
2418 NG_FREE_ITEM(item); in ng_apply_item()
2421 error = (*rcvdata)(hook, item); in ng_apply_item()
2440 NG_FREE_ITEM(item); in ng_apply_item()
2453 if ((NGI_MSG(item)->header.typecookie == NGM_GENERIC_COOKIE) && in ng_apply_item()
2454 ((NGI_MSG(item)->header.flags & NGF_RESP) == 0)) { in ng_apply_item()
2455 error = ng_generic_msg(node, item, hook); in ng_apply_item()
2462 NG_FREE_ITEM(item); in ng_apply_item()
2465 error = (*rcvmsg)(node, item, hook); in ng_apply_item()
2474 NGI_FN(item) != &ng_rmnode) { in ng_apply_item()
2477 NG_FREE_ITEM(item); in ng_apply_item()
2482 NGI_FN2(item) != &ng_con_part2 && in ng_apply_item()
2483 NGI_FN2(item) != &ng_con_part3 && in ng_apply_item()
2484 NGI_FN(item) != &ng_rmhook_part2) { in ng_apply_item()
2487 NG_FREE_ITEM(item); in ng_apply_item()
2491 if ((item->el_flags & NGQF_TYPE) == NGQF_FN) { in ng_apply_item()
2492 (*NGI_FN(item))(node, hook, NGI_ARG1(item), in ng_apply_item()
2493 NGI_ARG2(item)); in ng_apply_item()
2494 NG_FREE_ITEM(item); in ng_apply_item()
2496 error = (*NGI_FN2(item))(node, item, hook); in ng_apply_item()
2529 ng_generic_msg(node_p here, item_p item, hook_p lasthook) in ng_generic_msg() argument
2535 NGI_GET_MSG(item, msg); in ng_generic_msg()
2578 error = ng_con_nodes(item, here, con->ourhook, in ng_generic_msg()
2946 NGI_MSG(item) = msg; /* put it back as we found it */ in ng_generic_msg()
2947 return((*here->nd_type->rcvmsg)(here, item, lasthook)); in ng_generic_msg()
2963 NG_RESPOND_MSG(error, here, item, resp); in ng_generic_msg()
3004 item_p item; in ng_alloc_item() local
3009 item = uma_zalloc((type == NGQF_DATA) ? ng_qdzone : ng_qzone, in ng_alloc_item()
3012 if (item) { in ng_alloc_item()
3013 item->el_flags = type; in ng_alloc_item()
3016 TAILQ_INSERT_TAIL(&ng_itemlist, item, all); in ng_alloc_item()
3022 return (item); in ng_alloc_item()
3029 ng_free_item(item_p item) in ng_free_item() argument
3038 switch (item->el_flags & NGQF_TYPE) { in ng_free_item()
3041 NG_FREE_M(_NGI_M(item)); in ng_free_item()
3044 _NGI_RETADDR(item) = 0; in ng_free_item()
3045 NG_FREE_MSG(_NGI_MSG(item)); in ng_free_item()
3050 _NGI_FN(item) = NULL; in ng_free_item()
3051 _NGI_ARG1(item) = NULL; in ng_free_item()
3052 _NGI_ARG2(item) = 0; in ng_free_item()
3056 _NGI_CLR_NODE(item); in ng_free_item()
3057 _NGI_CLR_HOOK(item); in ng_free_item()
3061 TAILQ_REMOVE(&ng_itemlist, item, all); in ng_free_item()
3065 uma_zfree(((item->el_flags & NGQF_TYPE) == NGQF_DATA) ? in ng_free_item()
3066 ng_qdzone : ng_qzone, item); in ng_free_item()
3076 item_p item; in ng_realloc_item() local
3087 if ((item = ng_alloc_item(type, flags)) == NULL) { in ng_realloc_item()
3091 *item = *pitem; in ng_realloc_item()
3094 item = pitem; in ng_realloc_item()
3095 item->el_flags = (item->el_flags & ~NGQF_TYPE) | type; in ng_realloc_item()
3097 return (item); in ng_realloc_item()
3317 dumpitem(item_p item, char *file, int line) in dumpitem() argument
3320 item->lastfile, item->lastline); in dumpitem()
3321 switch(item->el_flags & NGQF_TYPE) { in dumpitem()
3326 printf(" - retaddr[%d]:\n", _NGI_RETADDR(item)); in dumpitem()
3330 _NGI_FN(item), in dumpitem()
3331 _NGI_NODE(item), in dumpitem()
3332 _NGI_HOOK(item), in dumpitem()
3333 item->body.fn.fn_arg1, in dumpitem()
3334 item->body.fn.fn_arg2, in dumpitem()
3335 item->body.fn.fn_arg2); in dumpitem()
3339 _NGI_FN2(item), in dumpitem()
3340 _NGI_NODE(item), in dumpitem()
3341 _NGI_HOOK(item), in dumpitem()
3342 item->body.fn.fn_arg1, in dumpitem()
3343 item->body.fn.fn_arg2, in dumpitem()
3344 item->body.fn.fn_arg2); in dumpitem()
3349 if (_NGI_NODE(item)) { in dumpitem()
3351 _NGI_NODE(item), ng_node2ID(_NGI_NODE(item))); in dumpitem()
3359 item_p item; in ng_dumpitems() local
3361 TAILQ_FOREACH(item, &ng_itemlist, all) { in ng_dumpitems()
3363 dumpitem(item, NULL, 0); in ng_dumpitems()
3454 item_p item; in ngthread() local
3458 item = ng_dequeue(node, &rw); in ngthread()
3459 if (item == NULL) { in ngthread()
3465 NGI_GET_NODE(item, node); /* zaps stored node */ in ngthread()
3466 ng_apply_item(node, item, rw); in ngthread()
3514 if (NGI_NODE(item) ) { \
3517 NGI_CLR_NODE(item); \
3519 if (NGI_HOOK(item) ) { \
3522 NGI_CLR_HOOK(item); \
3545 item_p item; in ng_package_data() local
3547 if ((item = ng_alloc_item(NGQF_DATA, flags)) == NULL) { in ng_package_data()
3552 item->el_flags |= NGQF_READER; in ng_package_data()
3553 NGI_M(item) = m; in ng_package_data()
3554 return (item); in ng_package_data()
3567 item_p item; in ng_package_msg() local
3569 if ((item = ng_alloc_item(NGQF_MESG, flags)) == NULL) { in ng_package_msg()
3576 item->el_flags |= NGQF_READER; in ng_package_msg()
3578 item->el_flags |= NGQF_WRITER; in ng_package_msg()
3582 NGI_MSG(item) = msg; in ng_package_msg()
3583 NGI_RETADDR(item) = 0; in ng_package_msg()
3584 return (item); in ng_package_msg()
3587 #define SET_RETADDR(item, here, retaddr) \ argument
3589 if ((item->el_flags & NGQF_TYPE) == NGQF_MESG) { \
3591 NGI_RETADDR(item) = retaddr; \
3598 if (NGI_RETADDR(item) == 0) { \
3599 NGI_RETADDR(item) \
3607 ng_address_hook(node_p here, item_p item, hook_p hook, ng_ID_t retaddr) in ng_address_hook() argument
3622 NG_FREE_ITEM(item); in ng_address_hook()
3633 NGI_SET_HOOK(item, peer); in ng_address_hook()
3634 NGI_SET_NODE(item, peernode); in ng_address_hook()
3635 SET_RETADDR(item, here, retaddr); in ng_address_hook()
3643 ng_address_path(node_p here, item_p item, const char *address, ng_ID_t retaddr) in ng_address_path() argument
3656 NG_FREE_ITEM(item); in ng_address_path()
3659 NGI_SET_NODE(item, dest); in ng_address_path()
3661 NGI_SET_HOOK(item, hook); in ng_address_path()
3663 SET_RETADDR(item, here, retaddr); in ng_address_path()
3668 ng_address_ID(node_p here, item_p item, ng_ID_t ID, ng_ID_t retaddr) in ng_address_ID() argument
3678 NG_FREE_ITEM(item); in ng_address_ID()
3683 NGI_SET_NODE(item, dest); in ng_address_ID()
3684 NGI_CLR_HOOK(item); in ng_address_ID()
3685 SET_RETADDR(item, here, retaddr); in ng_address_ID()
3697 item_p item; in ng_package_msg_self() local
3704 if ((item = ng_alloc_item(NGQF_MESG, NG_NOFLAGS)) == NULL) { in ng_package_msg_self()
3710 item->el_flags |= NGQF_WRITER; in ng_package_msg_self()
3712 NGI_SET_NODE(item, here); in ng_package_msg_self()
3715 NGI_SET_HOOK(item, hook); in ng_package_msg_self()
3717 NGI_MSG(item) = msg; in ng_package_msg_self()
3718 NGI_RETADDR(item) = ng_node2ID(here); in ng_package_msg_self()
3719 return (item); in ng_package_msg_self()
3737 item_p item; in ng_send_fn1() local
3739 if ((item = ng_alloc_item(NGQF_FN, flags)) == NULL) { in ng_send_fn1()
3742 item->el_flags |= NGQF_WRITER; in ng_send_fn1()
3744 NGI_SET_NODE(item, node); in ng_send_fn1()
3747 NGI_SET_HOOK(item, hook); in ng_send_fn1()
3749 NGI_FN(item) = fn; in ng_send_fn1()
3750 NGI_ARG1(item) = arg1; in ng_send_fn1()
3751 NGI_ARG2(item) = arg2; in ng_send_fn1()
3752 return(ng_snd_item(item, flags)); in ng_send_fn1()
3767 item_p item; in ng_send_fn2() local
3777 if ((item = ng_alloc_item(NGQF_FN2, flags)) == NULL) in ng_send_fn2()
3780 item->apply = pitem->apply; in ng_send_fn2()
3782 if ((item = ng_realloc_item(pitem, NGQF_FN2, flags)) == NULL) in ng_send_fn2()
3786 item->el_flags = (item->el_flags & ~NGQF_RW) | NGQF_WRITER; in ng_send_fn2()
3788 NGI_SET_NODE(item, node); in ng_send_fn2()
3791 NGI_SET_HOOK(item, hook); in ng_send_fn2()
3793 NGI_FN2(item) = fn; in ng_send_fn2()
3794 NGI_ARG1(item) = arg1; in ng_send_fn2()
3795 NGI_ARG2(item) = arg2; in ng_send_fn2()
3796 return(ng_snd_item(item, flags)); in ng_send_fn2()
3806 item_p item = arg; in ng_callout_trampoline() local
3809 CURVNET_SET(NGI_NODE(item)->nd_vnet); in ng_callout_trampoline()
3810 ng_snd_item(item, 0); in ng_callout_trampoline()
3819 item_p item, oitem; in ng_callout() local
3821 if ((item = ng_alloc_item(NGQF_FN, NG_NOFLAGS)) == NULL) in ng_callout()
3824 item->el_flags |= NGQF_WRITER; in ng_callout()
3826 NGI_SET_NODE(item, node); in ng_callout()
3829 NGI_SET_HOOK(item, hook); in ng_callout()
3831 NGI_FN(item) = fn; in ng_callout()
3832 NGI_ARG1(item) = arg1; in ng_callout()
3833 NGI_ARG2(item) = arg2; in ng_callout()
3835 if (callout_reset(c, ticks, &ng_callout_trampoline, item) == 1 && in ng_callout()
3845 item_p item; in ng_uncallout() local
3852 item = c->c_arg; in ng_uncallout()
3855 (item != NULL) && (NGI_NODE(item) == node)) { in ng_uncallout()
3861 NG_FREE_ITEM(item); in ng_uncallout()
3876 ng_replace_retaddr(node_p here, item_p item, ng_ID_t retaddr) in ng_replace_retaddr() argument
3879 NGI_RETADDR(item) = retaddr; in ng_replace_retaddr()
3885 NGI_RETADDR(item) = ng_node2ID(here); in ng_replace_retaddr()