2 * Copyright (c) 1996-2000 Whistle Communications, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of author nor the names of its
14 * contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY NICK HIBMA AND CONTRIBUTORS
18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 /* Driver for arbitrary double bulk pipe devices.
35 * The driver assumes that there will be the same driver on the other side.
37 * XXX Some more information on what the framing of the IP packets looks like.
39 * To take full advantage of bulk transmission, packets should be chosen
40 * between 1k and 5k in size (1k to make sure the sending side starts
41 * streaming, and <5k to avoid overflowing the system with small TDs).
45 /* probe/attach/detach:
46 * Connect the driver to the hardware and netgraph
48 * The reason we submit a bulk in transfer is that USB does not know about
49 * interrupts. The bulk transfer continuously polls the device for data.
50 * While the device has no data available, the device NAKs the TDs. As soon
51 * as there is data, the transfer happens and the data comes flowing in.
53 * In case you were wondering, interrupt transfers happen exactly that way.
54 * It therefore doesn't make sense to use the interrupt pipe to signal
55 * 'data ready' and then schedule a bulk transfer to fetch it. That would
56 * incur a 2ms delay at least, without reducing bandwidth requirements.
61 #include <dev/usb/usb.h>
62 #include <dev/usb/usb_mfunc.h>
63 #include <dev/usb/usb_error.h>
65 #define USB_DEBUG_VAR udbp_debug
67 #include <dev/usb/usb_core.h>
68 #include <dev/usb/usb_debug.h>
69 #include <dev/usb/usb_parse.h>
70 #include <dev/usb/usb_lookup.h>
71 #include <dev/usb/usb_util.h>
72 #include <dev/usb/usb_busdma.h>
76 #include <netgraph/ng_message.h>
77 #include <netgraph/netgraph.h>
78 #include <netgraph/ng_parse.h>
79 #include <netgraph/bluetooth/include/ng_bluetooth.h>
81 #include <dev/usb/misc/udbp.h>
84 static int udbp_debug = 0;
86 SYSCTL_NODE(_hw_usb, OID_AUTO, udbp, CTLFLAG_RW, 0, "USB udbp");
87 SYSCTL_INT(_hw_usb_udbp, OID_AUTO, debug, CTLFLAG_RW,
88 &udbp_debug, 0, "udbp debug level");
91 #define UDBP_TIMEOUT 2000 /* timeout on outbound transfers, in
93 #define UDBP_BUFFERSIZE MCLBYTES /* maximum number of bytes in one
97 #define UDBP_T_WR_CS 2
98 #define UDBP_T_RD_CS 3
100 #define UDBP_Q_MAXLEN 50
105 struct ng_bt_mbufq sc_xmitq_hipri; /* hi-priority transmit queue */
106 struct ng_bt_mbufq sc_xmitq; /* low-priority transmit queue */
108 struct usb2_xfer *sc_xfer[UDBP_T_MAX];
109 node_p sc_node; /* back pointer to node */
110 hook_p sc_hook; /* pointer to the hook */
111 struct mbuf *sc_bulk_in_buffer;
113 uint32_t sc_packets_in; /* packets in from downstream */
114 uint32_t sc_packets_out; /* packets out towards downstream */
117 #define UDBP_FLAG_READ_STALL 0x01 /* read transfer stalled */
118 #define UDBP_FLAG_WRITE_STALL 0x02 /* write transfer stalled */
125 static int udbp_modload(module_t mod, int event, void *data);
127 static device_probe_t udbp_probe;
128 static device_attach_t udbp_attach;
129 static device_detach_t udbp_detach;
131 static usb2_callback_t udbp_bulk_read_callback;
132 static usb2_callback_t udbp_bulk_read_clear_stall_callback;
133 static usb2_callback_t udbp_bulk_write_callback;
134 static usb2_callback_t udbp_bulk_write_clear_stall_callback;
136 static void udbp_bulk_read_complete(node_p, hook_p, void *, int);
138 static ng_constructor_t ng_udbp_constructor;
139 static ng_rcvmsg_t ng_udbp_rcvmsg;
140 static ng_shutdown_t ng_udbp_rmnode;
141 static ng_newhook_t ng_udbp_newhook;
142 static ng_connect_t ng_udbp_connect;
143 static ng_rcvdata_t ng_udbp_rcvdata;
144 static ng_disconnect_t ng_udbp_disconnect;
146 /* Parse type for struct ngudbpstat */
147 static const struct ng_parse_struct_field
148 ng_udbp_stat_type_fields[] = NG_UDBP_STATS_TYPE_INFO;
150 static const struct ng_parse_type ng_udbp_stat_type = {
151 &ng_parse_struct_type,
152 &ng_udbp_stat_type_fields
155 /* List of commands and how to convert arguments to/from ASCII */
156 static const struct ng_cmdlist ng_udbp_cmdlist[] = {
168 &ng_parse_int32_type,
174 /* Netgraph node type descriptor */
175 static struct ng_type ng_udbp_typestruct = {
176 .version = NG_ABI_VERSION,
177 .name = NG_UDBP_NODE_TYPE,
178 .constructor = ng_udbp_constructor,
179 .rcvmsg = ng_udbp_rcvmsg,
180 .shutdown = ng_udbp_rmnode,
181 .newhook = ng_udbp_newhook,
182 .connect = ng_udbp_connect,
183 .rcvdata = ng_udbp_rcvdata,
184 .disconnect = ng_udbp_disconnect,
185 .cmdlist = ng_udbp_cmdlist,
189 static const struct usb2_config udbp_config[UDBP_T_MAX] = {
193 .endpoint = UE_ADDR_ANY,
194 .direction = UE_DIR_OUT,
195 .bufsize = UDBP_BUFFERSIZE,
196 .flags = {.pipe_bof = 1,.force_short_xfer = 1,},
197 .callback = &udbp_bulk_write_callback,
198 .timeout = UDBP_TIMEOUT,
203 .endpoint = UE_ADDR_ANY,
204 .direction = UE_DIR_IN,
205 .bufsize = UDBP_BUFFERSIZE,
206 .flags = {.pipe_bof = 1,.short_xfer_ok = 1,},
207 .callback = &udbp_bulk_read_callback,
212 .endpoint = 0x00, /* Control pipe */
213 .direction = UE_DIR_ANY,
214 .bufsize = sizeof(struct usb2_device_request),
215 .callback = &udbp_bulk_write_clear_stall_callback,
216 .timeout = 1000, /* 1 second */
217 .interval = 50, /* 50ms */
222 .endpoint = 0x00, /* Control pipe */
223 .direction = UE_DIR_ANY,
224 .bufsize = sizeof(struct usb2_device_request),
225 .callback = &udbp_bulk_read_clear_stall_callback,
226 .timeout = 1000, /* 1 second */
227 .interval = 50, /* 50ms */
231 static devclass_t udbp_devclass;
233 static device_method_t udbp_methods[] = {
234 /* Device interface */
235 DEVMETHOD(device_probe, udbp_probe),
236 DEVMETHOD(device_attach, udbp_attach),
237 DEVMETHOD(device_detach, udbp_detach),
241 static driver_t udbp_driver = {
243 .methods = udbp_methods,
244 .size = sizeof(struct udbp_softc),
247 DRIVER_MODULE(udbp, uhub, udbp_driver, udbp_devclass, udbp_modload, 0);
248 MODULE_DEPEND(udbp, netgraph, NG_ABI_VERSION, NG_ABI_VERSION, NG_ABI_VERSION);
249 MODULE_DEPEND(udbp, usb, 1, 1, 1);
252 udbp_modload(module_t mod, int event, void *data)
258 error = ng_newtype(&ng_udbp_typestruct);
260 printf("%s: Could not register "
261 "Netgraph node type, error=%d\n",
262 NG_UDBP_NODE_TYPE, error);
267 error = ng_rmtype(&ng_udbp_typestruct);
278 udbp_probe(device_t dev)
280 struct usb2_attach_arg *uaa = device_get_ivars(dev);
282 if (uaa->usb_mode != USB_MODE_HOST) {
286 * XXX Julian, add the id of the device if you have one to test
287 * things with. run 'usbdevs -v' and note the 3 ID's that appear.
288 * The Vendor Id and Product Id are in hex and the Revision Id is in
289 * bcd. But as usual if the revision is 0x101 then you should
290 * compare the revision id in the device descriptor with 0x101 Or go
291 * search the file usbdevs.h. Maybe the device is already in there.
293 if (((uaa->info.idVendor == USB_VENDOR_NETCHIP) &&
294 (uaa->info.idProduct == USB_PRODUCT_NETCHIP_TURBOCONNECT)))
297 if (((uaa->info.idVendor == USB_VENDOR_PROLIFIC) &&
298 ((uaa->info.idProduct == USB_PRODUCT_PROLIFIC_PL2301) ||
299 (uaa->info.idProduct == USB_PRODUCT_PROLIFIC_PL2302))))
302 if ((uaa->info.idVendor == USB_VENDOR_ANCHOR) &&
303 (uaa->info.idProduct == USB_PRODUCT_ANCHOR_EZLINK))
306 if ((uaa->info.idVendor == USB_VENDOR_GENESYS) &&
307 (uaa->info.idProduct == USB_PRODUCT_GENESYS_GL620USB))
314 udbp_attach(device_t dev)
316 struct usb2_attach_arg *uaa = device_get_ivars(dev);
317 struct udbp_softc *sc = device_get_softc(dev);
320 device_set_usb2_desc(dev);
322 snprintf(sc->sc_name, sizeof(sc->sc_name),
323 "%s", device_get_nameunit(dev));
325 mtx_init(&sc->sc_mtx, "udbp lock", NULL, MTX_DEF | MTX_RECURSE);
327 error = usb2_transfer_setup(uaa->device, &uaa->info.bIfaceIndex,
328 sc->sc_xfer, udbp_config, UDBP_T_MAX, sc, &sc->sc_mtx);
330 DPRINTF("error=%s\n", usb2_errstr(error));
333 NG_BT_MBUFQ_INIT(&sc->sc_xmitq, UDBP_Q_MAXLEN);
335 NG_BT_MBUFQ_INIT(&sc->sc_xmitq_hipri, UDBP_Q_MAXLEN);
337 /* create Netgraph node */
339 if (ng_make_node_common(&ng_udbp_typestruct, &sc->sc_node) != 0) {
340 printf("%s: Could not create Netgraph node\n",
347 if (ng_name_node(sc->sc_node, sc->sc_name) != 0) {
348 printf("%s: Could not name node\n",
350 NG_NODE_UNREF(sc->sc_node);
354 NG_NODE_SET_PRIVATE(sc->sc_node, sc);
356 /* the device is now operational */
358 return (0); /* success */
362 return (ENOMEM); /* failure */
366 udbp_detach(device_t dev)
368 struct udbp_softc *sc = device_get_softc(dev);
370 /* destroy Netgraph node */
372 if (sc->sc_node != NULL) {
373 NG_NODE_SET_PRIVATE(sc->sc_node, NULL);
374 ng_rmnode_self(sc->sc_node);
377 /* free USB transfers, if any */
379 usb2_transfer_unsetup(sc->sc_xfer, UDBP_T_MAX);
381 mtx_destroy(&sc->sc_mtx);
385 NG_BT_MBUFQ_DESTROY(&sc->sc_xmitq);
386 NG_BT_MBUFQ_DESTROY(&sc->sc_xmitq_hipri);
390 if (sc->sc_bulk_in_buffer) {
391 m_freem(sc->sc_bulk_in_buffer);
392 sc->sc_bulk_in_buffer = NULL;
394 return (0); /* success */
398 udbp_bulk_read_callback(struct usb2_xfer *xfer)
400 struct udbp_softc *sc = xfer->priv_sc;
403 switch (USB_GET_STATE(xfer)) {
404 case USB_ST_TRANSFERRED:
406 /* allocate new mbuf */
408 MGETHDR(m, M_DONTWAIT, MT_DATA);
413 MCLGET(m, M_DONTWAIT);
415 if (!(m->m_flags & M_EXT)) {
419 m->m_pkthdr.len = m->m_len = xfer->actlen;
421 usb2_copy_out(xfer->frbuffers, 0, m->m_data, xfer->actlen);
423 sc->sc_bulk_in_buffer = m;
425 DPRINTF("received package %d "
426 "bytes\n", xfer->actlen);
430 if (sc->sc_bulk_in_buffer) {
431 ng_send_fn(sc->sc_node, NULL, &udbp_bulk_read_complete, NULL, 0);
434 if (sc->sc_flags & UDBP_FLAG_READ_STALL) {
435 usb2_transfer_start(sc->sc_xfer[UDBP_T_RD_CS]);
438 xfer->frlengths[0] = xfer->max_data_length;
439 usb2_start_hardware(xfer);
443 if (xfer->error != USB_ERR_CANCELLED) {
444 /* try to clear stall first */
445 sc->sc_flags |= UDBP_FLAG_READ_STALL;
446 usb2_transfer_start(sc->sc_xfer[UDBP_T_RD_CS]);
454 udbp_bulk_read_clear_stall_callback(struct usb2_xfer *xfer)
456 struct udbp_softc *sc = xfer->priv_sc;
457 struct usb2_xfer *xfer_other = sc->sc_xfer[UDBP_T_RD];
459 if (usb2_clear_stall_callback(xfer, xfer_other)) {
460 DPRINTF("stall cleared\n");
461 sc->sc_flags &= ~UDBP_FLAG_READ_STALL;
462 usb2_transfer_start(xfer_other);
467 udbp_bulk_read_complete(node_p node, hook_p hook, void *arg1, int arg2)
469 struct udbp_softc *sc = NG_NODE_PRIVATE(node);
476 mtx_lock(&sc->sc_mtx);
478 m = sc->sc_bulk_in_buffer;
482 sc->sc_bulk_in_buffer = NULL;
484 if ((sc->sc_hook == NULL) ||
485 NG_HOOK_NOT_VALID(sc->sc_hook)) {
486 DPRINTF("No upstream hook\n");
491 NG_SEND_DATA_ONLY(error, sc->sc_hook, m);
499 /* start USB bulk-in transfer, if not already started */
501 usb2_transfer_start(sc->sc_xfer[UDBP_T_RD]);
503 mtx_unlock(&sc->sc_mtx);
507 udbp_bulk_write_callback(struct usb2_xfer *xfer)
509 struct udbp_softc *sc = xfer->priv_sc;
512 switch (USB_GET_STATE(xfer)) {
513 case USB_ST_TRANSFERRED:
515 sc->sc_packets_out++;
518 if (sc->sc_flags & UDBP_FLAG_WRITE_STALL) {
519 usb2_transfer_start(sc->sc_xfer[UDBP_T_WR_CS]);
522 /* get next mbuf, if any */
524 NG_BT_MBUFQ_DEQUEUE(&sc->sc_xmitq_hipri, m);
526 NG_BT_MBUFQ_DEQUEUE(&sc->sc_xmitq, m);
528 DPRINTF("Data queue is empty\n");
532 if (m->m_pkthdr.len > MCLBYTES) {
533 DPRINTF("truncating large packet "
534 "from %d to %d bytes\n", m->m_pkthdr.len,
536 m->m_pkthdr.len = MCLBYTES;
538 usb2_m_copy_in(xfer->frbuffers, 0, m, 0, m->m_pkthdr.len);
540 xfer->frlengths[0] = m->m_pkthdr.len;
544 DPRINTF("packet out: %d bytes\n",
547 usb2_start_hardware(xfer);
551 if (xfer->error != USB_ERR_CANCELLED) {
552 /* try to clear stall first */
553 sc->sc_flags |= UDBP_FLAG_WRITE_STALL;
554 usb2_transfer_start(sc->sc_xfer[UDBP_T_WR_CS]);
562 udbp_bulk_write_clear_stall_callback(struct usb2_xfer *xfer)
564 struct udbp_softc *sc = xfer->priv_sc;
565 struct usb2_xfer *xfer_other = sc->sc_xfer[UDBP_T_WR];
567 if (usb2_clear_stall_callback(xfer, xfer_other)) {
568 DPRINTF("stall cleared\n");
569 sc->sc_flags &= ~UDBP_FLAG_WRITE_STALL;
570 usb2_transfer_start(xfer_other);
574 /***********************************************************************
575 * Start of Netgraph methods
576 **********************************************************************/
579 * If this is a device node so this work is done in the attach()
580 * routine and the constructor will return EINVAL as you should not be able
581 * to create nodes that depend on hardware (unless you can add the hardware :)
584 ng_udbp_constructor(node_p node)
590 * Give our ok for a hook to be added...
591 * If we are not running this might kick a device into life.
592 * Possibly decode information out of the hook name.
593 * Add the hook's private info to the hook structure.
594 * (if we had some). In this example, we assume that there is a
595 * an array of structs, called 'channel' in the private info,
596 * one for each active channel. The private
597 * pointer of each hook points to the appropriate UDBP_hookinfo struct
598 * so that the source of an input packet is easily identified.
601 ng_udbp_newhook(node_p node, hook_p hook, const char *name)
603 struct udbp_softc *sc = NG_NODE_PRIVATE(node);
606 if (strcmp(name, NG_UDBP_HOOK_NAME)) {
609 mtx_lock(&sc->sc_mtx);
611 if (sc->sc_hook != NULL) {
615 NG_HOOK_SET_PRIVATE(hook, NULL);
618 mtx_unlock(&sc->sc_mtx);
624 * Get a netgraph control message.
625 * Check it is one we understand. If needed, send a response.
626 * We could save the address for an async action later, but don't here.
627 * Always free the message.
628 * The response should be in a malloc'd region that the caller can 'free'.
629 * A response is not required.
630 * Theoretically you could respond defferently to old message types if
631 * the cookie in the header didn't match what we consider to be current
632 * (so that old userland programs could continue to work).
635 ng_udbp_rcvmsg(node_p node, item_p item, hook_p lasthook)
637 struct udbp_softc *sc = NG_NODE_PRIVATE(node);
638 struct ng_mesg *resp = NULL;
642 NGI_GET_MSG(item, msg);
643 /* Deal with message according to cookie and command */
644 switch (msg->header.typecookie) {
645 case NGM_UDBP_COOKIE:
646 switch (msg->header.cmd) {
647 case NGM_UDBP_GET_STATUS:
649 struct ngudbpstat *stats;
651 NG_MKRESPONSE(resp, msg, sizeof(*stats), M_NOWAIT);
656 stats = (struct ngudbpstat *)resp->data;
657 mtx_lock(&sc->sc_mtx);
658 stats->packets_in = sc->sc_packets_in;
659 stats->packets_out = sc->sc_packets_out;
660 mtx_unlock(&sc->sc_mtx);
663 case NGM_UDBP_SET_FLAG:
664 if (msg->header.arglen != sizeof(uint32_t)) {
668 DPRINTF("flags = 0x%08x\n",
669 *((uint32_t *)msg->data));
672 error = EINVAL; /* unknown command */
677 error = EINVAL; /* unknown cookie type */
681 /* Take care of synchronous response, if any */
682 NG_RESPOND_MSG(error, node, item, resp);
688 * Accept data from the hook and queue it for output.
691 ng_udbp_rcvdata(hook_p hook, item_p item)
693 struct udbp_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
694 struct ng_bt_mbufq *queue_ptr;
696 struct ng_tag_prio *ptag;
707 * Now queue the data for when it can be sent
709 ptag = (void *)m_tag_locate(m, NGM_GENERIC_COOKIE,
712 if (ptag && (ptag->priority > NG_PRIO_CUTOFF))
713 queue_ptr = &sc->sc_xmitq_hipri;
715 queue_ptr = &sc->sc_xmitq;
717 mtx_lock(&sc->sc_mtx);
719 if (NG_BT_MBUFQ_FULL(queue_ptr)) {
720 NG_BT_MBUFQ_DROP(queue_ptr);
724 NG_BT_MBUFQ_ENQUEUE(queue_ptr, m);
726 * start bulk-out transfer, if not already started:
728 usb2_transfer_start(sc->sc_xfer[UDBP_T_WR]);
732 mtx_unlock(&sc->sc_mtx);
738 * Do local shutdown processing..
739 * We are a persistant device, we refuse to go away, and
740 * only remove our links and reset ourself.
743 ng_udbp_rmnode(node_p node)
745 struct udbp_softc *sc = NG_NODE_PRIVATE(node);
747 /* Let old node go */
748 NG_NODE_SET_PRIVATE(node, NULL);
749 NG_NODE_UNREF(node); /* forget it ever existed */
754 /* Create Netgraph node */
755 if (ng_make_node_common(&ng_udbp_typestruct, &sc->sc_node) != 0) {
756 printf("%s: Could not create Netgraph node\n",
762 if (ng_name_node(sc->sc_node, sc->sc_name) != 0) {
763 printf("%s: Could not name Netgraph node\n",
765 NG_NODE_UNREF(sc->sc_node);
769 NG_NODE_SET_PRIVATE(sc->sc_node, sc);
773 mtx_unlock(&sc->sc_mtx);
779 * This is called once we've already connected a new hook to the other node.
780 * It gives us a chance to balk at the last minute.
783 ng_udbp_connect(hook_p hook)
785 struct udbp_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
787 /* probably not at splnet, force outward queueing */
788 NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
790 mtx_lock(&sc->sc_mtx);
792 sc->sc_flags |= (UDBP_FLAG_READ_STALL |
793 UDBP_FLAG_WRITE_STALL);
795 /* start bulk-in transfer */
796 usb2_transfer_start(sc->sc_xfer[UDBP_T_RD]);
798 /* start bulk-out transfer */
799 usb2_transfer_start(sc->sc_xfer[UDBP_T_WR]);
801 mtx_unlock(&sc->sc_mtx);
809 * For this type, removal of the last link destroys the node
812 ng_udbp_disconnect(hook_p hook)
814 struct udbp_softc *sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
819 mtx_lock(&sc->sc_mtx);
821 if (hook != sc->sc_hook) {
825 /* stop bulk-in transfer */
826 usb2_transfer_stop(sc->sc_xfer[UDBP_T_RD_CS]);
827 usb2_transfer_stop(sc->sc_xfer[UDBP_T_RD]);
829 /* stop bulk-out transfer */
830 usb2_transfer_stop(sc->sc_xfer[UDBP_T_WR_CS]);
831 usb2_transfer_stop(sc->sc_xfer[UDBP_T_WR]);
834 NG_BT_MBUFQ_DRAIN(&sc->sc_xmitq);
835 NG_BT_MBUFQ_DRAIN(&sc->sc_xmitq_hipri);
837 if (sc->sc_bulk_in_buffer) {
838 m_freem(sc->sc_bulk_in_buffer);
839 sc->sc_bulk_in_buffer = NULL;
844 mtx_unlock(&sc->sc_mtx);
846 if ((NG_NODE_NUMHOOKS(NG_HOOK_NODE(hook)) == 0)
847 && (NG_NODE_IS_VALID(NG_HOOK_NODE(hook))))
848 ng_rmnode_self(NG_HOOK_NODE(hook));