0001
0002
0003
0004
0005
0006
0007 #ifndef __USBIP_VHCI_H
0008 #define __USBIP_VHCI_H
0009
0010 #include <linux/device.h>
0011 #include <linux/list.h>
0012 #include <linux/spinlock.h>
0013 #include <linux/sysfs.h>
0014 #include <linux/types.h>
0015 #include <linux/usb.h>
0016 #include <linux/usb/hcd.h>
0017 #include <linux/wait.h>
0018
0019 struct vhci_device {
0020 struct usb_device *udev;
0021
0022
0023
0024
0025
0026 __u32 devid;
0027
0028
0029 enum usb_device_speed speed;
0030
0031
0032 __u32 rhport;
0033
0034 struct usbip_device ud;
0035
0036
0037 spinlock_t priv_lock;
0038
0039
0040 struct list_head priv_tx;
0041 struct list_head priv_rx;
0042
0043
0044 struct list_head unlink_tx;
0045 struct list_head unlink_rx;
0046
0047
0048 wait_queue_head_t waitq_tx;
0049 };
0050
0051
0052 struct vhci_priv {
0053 unsigned long seqnum;
0054 struct list_head list;
0055
0056 struct vhci_device *vdev;
0057 struct urb *urb;
0058 };
0059
0060 struct vhci_unlink {
0061
0062 unsigned long seqnum;
0063
0064 struct list_head list;
0065
0066
0067 unsigned long unlink_seqnum;
0068 };
0069
0070 enum hub_speed {
0071 HUB_SPEED_HIGH = 0,
0072 HUB_SPEED_SUPER,
0073 };
0074
0075
0076 #ifdef CONFIG_USBIP_VHCI_HC_PORTS
0077 #define VHCI_HC_PORTS CONFIG_USBIP_VHCI_HC_PORTS
0078 #else
0079 #define VHCI_HC_PORTS 8
0080 #endif
0081
0082
0083 #define VHCI_PORTS (VHCI_HC_PORTS*2)
0084
0085 #ifdef CONFIG_USBIP_VHCI_NR_HCS
0086 #define VHCI_NR_HCS CONFIG_USBIP_VHCI_NR_HCS
0087 #else
0088 #define VHCI_NR_HCS 1
0089 #endif
0090
0091 #define MAX_STATUS_NAME 16
0092
0093 struct vhci {
0094 spinlock_t lock;
0095
0096 struct platform_device *pdev;
0097
0098 struct vhci_hcd *vhci_hcd_hs;
0099 struct vhci_hcd *vhci_hcd_ss;
0100 };
0101
0102
0103 struct vhci_hcd {
0104 struct vhci *vhci;
0105
0106 u32 port_status[VHCI_HC_PORTS];
0107
0108 unsigned resuming:1;
0109 unsigned long re_timeout;
0110
0111 atomic_t seqnum;
0112
0113
0114
0115
0116
0117
0118 struct vhci_device vdev[VHCI_HC_PORTS];
0119 };
0120
0121 extern int vhci_num_controllers;
0122 extern struct vhci *vhcis;
0123 extern struct attribute_group vhci_attr_group;
0124
0125
0126 void rh_port_connect(struct vhci_device *vdev, enum usb_device_speed speed);
0127
0128
0129 int vhci_init_attr_group(void);
0130 void vhci_finish_attr_group(void);
0131
0132
0133 struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum);
0134 int vhci_rx_loop(void *data);
0135
0136
0137 int vhci_tx_loop(void *data);
0138
0139 static inline __u32 port_to_rhport(__u32 port)
0140 {
0141 return port % VHCI_HC_PORTS;
0142 }
0143
0144 static inline int port_to_pdev_nr(__u32 port)
0145 {
0146 return port / VHCI_PORTS;
0147 }
0148
0149 static inline struct vhci_hcd *hcd_to_vhci_hcd(struct usb_hcd *hcd)
0150 {
0151 return (struct vhci_hcd *) (hcd->hcd_priv);
0152 }
0153
0154 static inline struct device *hcd_dev(struct usb_hcd *hcd)
0155 {
0156 return (hcd)->self.controller;
0157 }
0158
0159 static inline const char *hcd_name(struct usb_hcd *hcd)
0160 {
0161 return (hcd)->self.bus_name;
0162 }
0163
0164 static inline struct usb_hcd *vhci_hcd_to_hcd(struct vhci_hcd *vhci_hcd)
0165 {
0166 return container_of((void *) vhci_hcd, struct usb_hcd, hcd_priv);
0167 }
0168
0169 static inline struct vhci_hcd *vdev_to_vhci_hcd(struct vhci_device *vdev)
0170 {
0171 return container_of((void *)(vdev - vdev->rhport), struct vhci_hcd, vdev);
0172 }
0173
0174 #endif