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