Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
usb:usbperiphapi [2009/05/22 05:53] – AndrewThompsonusb:usbperiphapi [2009/05/22 06:14] (current) – AndrewThompson
Line 16: Line 16:
 void            usb_pipe_close(struct usb_pipe **, int count); void            usb_pipe_close(struct usb_pipe **, int count);
 void            usb_clear_stall(struct usb_pipe *); void            usb_clear_stall(struct usb_pipe *);
-struct usb_urb *usb_alloc_urb(struct usb_pipe *, int flags);+struct usb_urb *usb_get_urb(struct usb_pipe *, int flags);
 int             usb_set_frame_data(struct usb_urb *, int index, void *, int len); int             usb_set_frame_data(struct usb_urb *, int index, void *, int len);
 int             usb_copyin_urb(struct usb_urb *, void *, int offset, int len); int             usb_copyin_urb(struct usb_urb *, void *, int offset, int len);
Line 25: Line 25:
  
 </code> </code>
 +
 +===== Structs =====
 +==== struct usb_pipe ====
 +A queue for processing urb pointers. Has one dma map and will reload the dma if the current urb is different to the one previously loaded. The pipe has a private mutex for queueing and dequeueing, it does not need to share the mutex with the driver.
 +
 +==== struct usb_urb ====
 +A data buffer. The memory can be preallocated (fixed size) or passed in from an external buffer. The urb has a single reference and does not need to be locked.
  
 Notes: Notes:
   * usb_pipe_open() will preallocate the requested number of urb structures and keep on a free list   * usb_pipe_open() will preallocate the requested number of urb structures and keep on a free list
-  * usb_alloc_urb() will get a urb from the free list, or allocate if none available (bounds limited).+  * usb_get_urb() will get a urb from the free list.
   * usb_free_urb() does not actually free the memory, it puts the urb on the pipe free list   * usb_free_urb() does not actually free the memory, it puts the urb on the pipe free list
   * usb_pipe_halt() cancels all pending urbs and sets the pipe to blocking   * usb_pipe_halt() cancels all pending urbs and sets the pipe to blocking
Line 70: Line 77:
 init() init()
  /* will return up to 'max_urb' times */  /* will return up to 'max_urb' times */
- while((urb = usb_alloc_urb(sc->sc_readxfer) != NULL) {+ while((urb = usb_get_urb(sc->sc_readxfer) != NULL) {
    m = m_getcl(M_WAIT, MT_DATA, M_PKTHDR);    m = m_getcl(M_WAIT, MT_DATA, M_PKTHDR);
    usb_set_frame_data(urb, 0, m->data, m->len);    usb_set_frame_data(urb, 0, m->data, m->len);
Line 84: Line 91:
  
 start(m) start(m)
- urb = usb_alloc_urb(sc->sc_writexfer);+ urb = usb_get_urb(sc->sc_writexfer); 
 + if (urb == NULL) 
 +   return;
  usb_set_frame_data(urb, 0, m->data, m->len);  usb_set_frame_data(urb, 0, m->data, m->len);
  usb_set_priv(urb, m);  usb_set_priv(urb, m);
Line 104: Line 113:
  m = usb_get_priv(urb);  m = usb_get_priv(urb);
  mnew = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);  mnew = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
- if (mnew) {+ if (!mnew) {
     ifp->if_ierrors++;     ifp->if_ierrors++;
     goto skip;     goto skip;
Line 148: Line 157:
 ttyopen() ttyopen()
  /* will return up to 'max_urb' times */  /* will return up to 'max_urb' times */
- while((urb = usb_alloc_urb(sc->sc_readxfer) != NULL) {+ while((urb = usb_get_urb(sc->sc_readxfer) != NULL) {
    usb_submit_urb(urb);    usb_submit_urb(urb);
  }  }
Line 159: Line 168:
  
 ttywakeup() ttywakeup()
- urb = usb_alloc_urb(sc->sc_writexfer);+ urb = usb_get_urb(sc->sc_writexfer);
  if (urb == NULL)  if (urb == NULL)
    return; /* all buffers in flight */    return; /* all buffers in flight */
  • usb/usbperiphapi.1242971620.txt.gz
  • Last modified: 2009/05/22 05:53
  • by AndrewThompson