* Queue a packet to be picked up later by someone else. * If the queue could be run now, add node to the queue handler's worklist. */
| 2010 | * If the queue could be run now, add node to the queue handler's worklist. |
| 2011 | */ |
| 2012 | static __inline void |
| 2013 | ng_queue_rw(node_p node, item_p item, int rw) |
| 2014 | { |
| 2015 | struct ng_queue *ngq = &node->nd_input_queue; |
| 2016 | if (rw == NGQRW_W) |
| 2017 | NGI_SET_WRITER(item); |
| 2018 | else |
| 2019 | NGI_SET_READER(item); |
| 2020 | item->depth = 1; |
| 2021 | |
| 2022 | NG_QUEUE_LOCK(ngq); |
| 2023 | /* Set OP_PENDING flag and enqueue the item. */ |
| 2024 | atomic_set_int(&ngq->q_flags, OP_PENDING); |
| 2025 | STAILQ_INSERT_TAIL(&ngq->queue, item, el_next); |
| 2026 | |
| 2027 | CTR5(KTR_NET, "%20s: node [%x] (%p) queued item %p as %s", __func__, |
| 2028 | node->nd_ID, node, item, rw ? "WRITER" : "READER" ); |
| 2029 | |
| 2030 | /* |
| 2031 | * We can take the worklist lock with the node locked |
| 2032 | * BUT NOT THE REVERSE! |
| 2033 | */ |
| 2034 | if (NEXT_QUEUED_ITEM_CAN_PROCEED(ngq)) |
| 2035 | ng_worklist_add(node); |
| 2036 | NG_QUEUE_UNLOCK(ngq); |
| 2037 | } |
| 2038 | |
| 2039 | /* Acquire reader lock on node. If node is busy, queue the packet. */ |
| 2040 | static __inline item_p |
no test coverage detected