0001
0002
0003
0004
0005
0006 #ifndef __USBIP_STUB_H
0007 #define __USBIP_STUB_H
0008
0009 #include <linux/list.h>
0010 #include <linux/slab.h>
0011 #include <linux/spinlock.h>
0012 #include <linux/types.h>
0013 #include <linux/usb.h>
0014 #include <linux/wait.h>
0015
0016 #define STUB_BUSID_OTHER 0
0017 #define STUB_BUSID_REMOV 1
0018 #define STUB_BUSID_ADDED 2
0019 #define STUB_BUSID_ALLOC 3
0020
0021 struct stub_device {
0022 struct usb_device *udev;
0023
0024 struct usbip_device ud;
0025 __u32 devid;
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 spinlock_t priv_lock;
0039 struct list_head priv_init;
0040 struct list_head priv_tx;
0041 struct list_head priv_free;
0042
0043
0044 struct list_head unlink_tx;
0045 struct list_head unlink_free;
0046
0047 wait_queue_head_t tx_waitq;
0048 };
0049
0050
0051 struct stub_priv {
0052 unsigned long seqnum;
0053 struct list_head list;
0054 struct stub_device *sdev;
0055 struct urb **urbs;
0056 struct scatterlist *sgl;
0057 int num_urbs;
0058 int completed_urbs;
0059 int urb_status;
0060
0061 int unlinking;
0062 };
0063
0064 struct stub_unlink {
0065 unsigned long seqnum;
0066 struct list_head list;
0067 __u32 status;
0068 };
0069
0070
0071 #define BUSID_SIZE 32
0072
0073 struct bus_id_priv {
0074 char name[BUSID_SIZE];
0075 char status;
0076 int interf_count;
0077 struct stub_device *sdev;
0078 struct usb_device *udev;
0079 char shutdown_busid;
0080 spinlock_t busid_lock;
0081 };
0082
0083
0084 extern struct kmem_cache *stub_priv_cache;
0085
0086
0087 extern struct usb_device_driver stub_driver;
0088
0089
0090 struct bus_id_priv *get_busid_priv(const char *busid);
0091 void put_busid_priv(struct bus_id_priv *bid);
0092 int del_match_busid(char *busid);
0093 void stub_free_priv_and_urb(struct stub_priv *priv);
0094 void stub_device_cleanup_urbs(struct stub_device *sdev);
0095
0096
0097 int stub_rx_loop(void *data);
0098
0099
0100 void stub_enqueue_ret_unlink(struct stub_device *sdev, __u32 seqnum,
0101 __u32 status);
0102 void stub_complete(struct urb *urb);
0103 int stub_tx_loop(void *data);
0104
0105 #endif