Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Re: io-pkt-v4 crashes when devnp driver hands ethernet packet over (qnx 6.4.0) -- WTP is null!! -- hmmm ...: (3 Items)
   
Re: io-pkt-v4 crashes when devnp driver hands ethernet packet over (qnx 6.4.0) -- WTP is null!! -- hmmm ...  
Hello,

I am writing a devnp ethernet network driver for a usb based card. No shim.
I am using the qnx usb stack and the corresponding usbd_...() api.

The usb stack calls back when there is an ethernet packet to be received. In this routine I got a packet in my hand, I 
create an mbuf, stuff it, and hand it over to io-pkt-v4 with (*ifp->if_input)(ifp, m). WTP is zero because this is not 
an io-pkt-v4 registered thread (the usb stack client creates it underneath the qnx usbd_...() api, I don't have control 
over the thread).
WTP is null and the mbuf macros/functions use it. If I use the ..._wtp() macros/functions only I am OK in the driver but
 io-pkt-v4 crashes later at forwarding. Hmmm ...

Code:
static void hsoncusb_bulk_cbf( struct usbd_urb *urb, struct usbd_pipe *pipe, void *hdl )
{
...
                m = m_getcl_wtp(M_DONTWAIT, MT_DATA, M_PKTHDR, wtp);
                m_copyback(m, 0, hsoncusbdev->len_bulkin, hsoncusbdev->buffer_bulkin);
...
                ifp->if_ipackets++;
                (*ifp->if_input)(ifp, m);
...
}

How do you hand over (receive) an ethernet packet to io-pkt-v4 from a non-registered devnp driver thread correctly? Is 
there some sample code I can use?

Comments? Suggestions?

Thanks.
Andor
7/24/2009

--

Andor Nas
andor.nas@andrew.com
Re: io-pkt-v4 crashes when devnp driver hands ethernet packet over (qnx 6.4.0) -- WTP is null!! -- hmmm ...  
I suspect that you're calling io-pkt routines in the USB callback thread.  Unfortunately, this isn't supported.  io-pkt 
routines can only be called in threads that have been created by io-pkt.  What you have to do is have the callback 
thread wake up an io-pkt thread.  

This isn't for the faint of heart.  Take a look at 
http://community.qnx.com/integration/viewvc/viewvc.cgi/trunk/sys/lib/libnbdrvr/usb/usb_conv_qnx.c?root=core_networking&
system=exsy1001&view=log

which shows how the QNX USB layer was hooked into the NetBSD USB drivers.

    Robert.
Re: io-pkt-v4 crashes when devnp driver hands ethernet packet over (qnx 6.4.0) -- WTP is null!! -- hmmm ...  
> I suspect that you're calling io-pkt routines in the USB callback thread.
Yes.

> io-pkt routines can only be called in threads that have been created by io-pkt.
Yes, I came to the same conclusion.
WTP has to work.

> What you have to do is have the callback thread wake up an io-pkt thread.
Yep.

> This isn't for the faint of heart.
OK

> ... which shows how the QNX USB layer was hooked into
> the NetBSD USB drivers.
OK

Thanks!
Andor
7/31/2009