linux/drivers/staging/usbip/vhci.h
<<
>>
Prefs
   1/*
   2 * Copyright (C) 2003-2008 Takahiro Hirofuchi
   3 *
   4 * This is free software; you can redistribute it and/or modify
   5 * it under the terms of the GNU General Public License as published by
   6 * the Free Software Foundation; either version 2 of the License, or
   7 * (at your option) any later version.
   8 *
   9 * This is distributed in the hope that it will be useful,
  10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12 * GNU General Public License for more details.
  13 *
  14 * You should have received a copy of the GNU General Public License
  15 * along with this program; if not, write to the Free Software
  16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  17 * USA.
  18 */
  19
  20#include <linux/platform_device.h>
  21#include "../../usb/core/hcd.h"
  22
  23
  24struct vhci_device {
  25        struct usb_device *udev;
  26
  27        /*
  28         * devid specifies a remote usb device uniquely instead
  29         * of combination of busnum and devnum.
  30         */
  31        __u32 devid;
  32
  33        /* speed of a remote device */
  34        enum usb_device_speed speed;
  35
  36        /*  vhci root-hub port to which this device is attached  */
  37        __u32 rhport;
  38
  39        struct usbip_device ud;
  40
  41
  42        /* lock for the below link lists */
  43        spinlock_t priv_lock;
  44
  45        /* vhci_priv is linked to one of them. */
  46        struct list_head priv_tx;
  47        struct list_head priv_rx;
  48
  49        /* vhci_unlink is linked to one of them */
  50        struct list_head unlink_tx;
  51        struct list_head unlink_rx;
  52
  53        /* vhci_tx thread sleeps for this queue */
  54        wait_queue_head_t waitq_tx;
  55};
  56
  57
  58/* urb->hcpriv, use container_of() */
  59struct vhci_priv {
  60        unsigned long seqnum;
  61        struct list_head list;
  62
  63        struct vhci_device *vdev;
  64        struct urb *urb;
  65};
  66
  67
  68struct vhci_unlink {
  69        /* seqnum of this request */
  70        unsigned long seqnum;
  71
  72        struct list_head list;
  73
  74        /* seqnum of the unlink target */
  75        unsigned long unlink_seqnum;
  76};
  77
  78/*
  79 * The number of ports is less than 16 ?
  80 * USB_MAXCHILDREN is statically defined to 16 in usb.h.  Its maximum value
  81 * would be 31 because the event_bits[1] of struct usb_hub is defined as
  82 * unsigned long in hub.h
  83 */
  84#define VHCI_NPORTS 8
  85
  86/* for usb_bus.hcpriv */
  87struct vhci_hcd {
  88        spinlock_t      lock;
  89
  90        u32     port_status[VHCI_NPORTS];
  91
  92        unsigned        resuming:1;
  93        unsigned long   re_timeout;
  94
  95        atomic_t seqnum;
  96
  97        /*
  98         * NOTE:
  99         * wIndex shows the port number and begins from 1.
 100         * But, the index of this array begins from 0.
 101         */
 102        struct vhci_device vdev[VHCI_NPORTS];
 103
 104        /* vhci_device which has not been assiged its address yet */
 105        int pending_port;
 106};
 107
 108
 109extern struct vhci_hcd *the_controller;
 110extern struct attribute_group dev_attr_group;
 111
 112
 113/*-------------------------------------------------------------------------*/
 114/* prototype declaration */
 115
 116/* vhci_hcd.c */
 117void rh_port_connect(int rhport, enum usb_device_speed speed);
 118void rh_port_disconnect(int rhport);
 119void vhci_rx_loop(struct usbip_task *ut);
 120void vhci_tx_loop(struct usbip_task *ut);
 121
 122#define hardware                (&the_controller->pdev.dev)
 123
 124static inline struct vhci_device *port_to_vdev(__u32 port)
 125{
 126        return &the_controller->vdev[port];
 127}
 128
 129static inline struct vhci_hcd *hcd_to_vhci(struct usb_hcd *hcd)
 130{
 131        return (struct vhci_hcd *) (hcd->hcd_priv);
 132}
 133
 134static inline struct usb_hcd *vhci_to_hcd(struct vhci_hcd *vhci)
 135{
 136        return container_of((void *) vhci, struct usb_hcd, hcd_priv);
 137}
 138
 139static inline struct device *vhci_dev(struct vhci_hcd *vhci)
 140{
 141        return vhci_to_hcd(vhci)->self.controller;
 142}
 143