Commit | Line | Data |
---|---|---|
c52661d6 SAS |
1 | #ifndef __TARGET_USB_GADGET_H__ |
2 | #define __TARGET_USB_GADGET_H__ | |
3 | ||
4 | #include <linux/kref.h> | |
5 | /* #include <linux/usb/uas.h> */ | |
6 | #include <linux/usb/composite.h> | |
7 | #include <linux/usb/uas.h> | |
8 | #include <linux/usb/storage.h> | |
c52661d6 SAS |
9 | #include <target/target_core_base.h> |
10 | #include <target/target_core_fabric.h> | |
11 | ||
12 | #define USBG_NAMELEN 32 | |
13 | ||
14 | #define fuas_to_gadget(f) (f->function.config->cdev->gadget) | |
15 | #define UASP_SS_EP_COMP_LOG_STREAMS 4 | |
16 | #define UASP_SS_EP_COMP_NUM_STREAMS (1 << UASP_SS_EP_COMP_LOG_STREAMS) | |
17 | ||
18786da4 | 18 | enum { |
276e2e4f | 19 | USB_G_STR_CONFIG = USB_GADGET_FIRST_AVAIL_IDX, |
18786da4 SAS |
20 | USB_G_STR_INT_UAS, |
21 | USB_G_STR_INT_BBB, | |
22 | }; | |
c52661d6 SAS |
23 | |
24 | #define USB_G_ALT_INT_BBB 0 | |
25 | #define USB_G_ALT_INT_UAS 1 | |
26 | ||
c52661d6 SAS |
27 | struct tcm_usbg_nexus { |
28 | struct se_session *tvn_se_sess; | |
29 | }; | |
30 | ||
31 | struct usbg_tpg { | |
32 | struct mutex tpg_mutex; | |
33 | /* SAS port target portal group tag for TCM */ | |
34 | u16 tport_tpgt; | |
35 | /* Pointer back to usbg_tport */ | |
36 | struct usbg_tport *tport; | |
37 | struct workqueue_struct *workqueue; | |
38 | /* Returned by usbg_make_tpg() */ | |
39 | struct se_portal_group se_tpg; | |
40 | u32 gadget_connect; | |
41 | struct tcm_usbg_nexus *tpg_nexus; | |
42 | atomic_t tpg_port_count; | |
43 | }; | |
44 | ||
45 | struct usbg_tport { | |
c52661d6 SAS |
46 | /* Binary World Wide unique Port Name for SAS Target port */ |
47 | u64 tport_wwpn; | |
48 | /* ASCII formatted WWPN for SAS Target port */ | |
49 | char tport_name[USBG_NAMELEN]; | |
50 | /* Returned by usbg_make_tport() */ | |
51 | struct se_wwn tport_wwn; | |
52 | }; | |
53 | ||
54 | enum uas_state { | |
55 | UASP_SEND_DATA, | |
56 | UASP_RECEIVE_DATA, | |
57 | UASP_SEND_STATUS, | |
58 | UASP_QUEUE_COMMAND, | |
59 | }; | |
60 | ||
61 | #define USBG_MAX_CMD 64 | |
62 | struct usbg_cmd { | |
63 | /* common */ | |
64 | u8 cmd_buf[USBG_MAX_CMD]; | |
65 | u32 data_len; | |
66 | struct work_struct work; | |
67 | int unpacked_lun; | |
68 | struct se_cmd se_cmd; | |
69 | void *data_buf; /* used if no sg support available */ | |
70 | struct f_uas *fu; | |
71 | struct completion write_complete; | |
72 | struct kref ref; | |
73 | ||
74 | /* UAS only */ | |
75 | u16 tag; | |
76 | u16 prio_attr; | |
77 | struct sense_iu sense_iu; | |
78 | enum uas_state state; | |
79 | struct uas_stream *stream; | |
80 | ||
81 | /* BOT only */ | |
82 | __le32 bot_tag; | |
83 | unsigned int csw_code; | |
84 | unsigned is_read:1; | |
85 | ||
86 | }; | |
87 | ||
88 | struct uas_stream { | |
89 | struct usb_request *req_in; | |
90 | struct usb_request *req_out; | |
91 | struct usb_request *req_status; | |
92 | }; | |
93 | ||
94 | struct usbg_cdb { | |
95 | struct usb_request *req; | |
96 | void *buf; | |
97 | }; | |
98 | ||
99 | struct bot_status { | |
100 | struct usb_request *req; | |
101 | struct bulk_cs_wrap csw; | |
102 | }; | |
103 | ||
104 | struct f_uas { | |
105 | struct usbg_tpg *tpg; | |
106 | struct usb_function function; | |
107 | u16 iface; | |
108 | ||
109 | u32 flags; | |
110 | #define USBG_ENABLED (1 << 0) | |
111 | #define USBG_IS_UAS (1 << 1) | |
112 | #define USBG_USE_STREAMS (1 << 2) | |
113 | #define USBG_IS_BOT (1 << 3) | |
114 | #define USBG_BOT_CMD_PEND (1 << 4) | |
115 | ||
116 | struct usbg_cdb cmd; | |
117 | struct usb_ep *ep_in; | |
118 | struct usb_ep *ep_out; | |
119 | ||
120 | /* UAS */ | |
121 | struct usb_ep *ep_status; | |
122 | struct usb_ep *ep_cmd; | |
123 | struct uas_stream stream[UASP_SS_EP_COMP_NUM_STREAMS]; | |
124 | ||
125 | /* BOT */ | |
126 | struct bot_status bot_status; | |
127 | struct usb_request *bot_req_in; | |
128 | struct usb_request *bot_req_out; | |
129 | }; | |
130 | ||
131 | extern struct usbg_tpg *the_only_tpg_I_currently_have; | |
132 | ||
133 | #endif |