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