Staging: Merge branch 'tidspbridge-for-2.6.39' of git://dev.omapzoom.org/pub/scm...
[deliverable/linux.git] / include / linux / usb / cdc.h
1 /*
2 * USB Communications Device Class (CDC) definitions
3 *
4 * CDC says how to talk to lots of different types of network adapters,
5 * notably ethernet adapters and various modems. It's used mostly with
6 * firmware based USB peripherals.
7 */
8
9 #ifndef __LINUX_USB_CDC_H
10 #define __LINUX_USB_CDC_H
11
12 #include <linux/types.h>
13
14 #define USB_CDC_SUBCLASS_ACM 0x02
15 #define USB_CDC_SUBCLASS_ETHERNET 0x06
16 #define USB_CDC_SUBCLASS_WHCM 0x08
17 #define USB_CDC_SUBCLASS_DMM 0x09
18 #define USB_CDC_SUBCLASS_MDLM 0x0a
19 #define USB_CDC_SUBCLASS_OBEX 0x0b
20 #define USB_CDC_SUBCLASS_EEM 0x0c
21 #define USB_CDC_SUBCLASS_NCM 0x0d
22
23 #define USB_CDC_PROTO_NONE 0
24
25 #define USB_CDC_ACM_PROTO_AT_V25TER 1
26 #define USB_CDC_ACM_PROTO_AT_PCCA101 2
27 #define USB_CDC_ACM_PROTO_AT_PCCA101_WAKE 3
28 #define USB_CDC_ACM_PROTO_AT_GSM 4
29 #define USB_CDC_ACM_PROTO_AT_3G 5
30 #define USB_CDC_ACM_PROTO_AT_CDMA 6
31 #define USB_CDC_ACM_PROTO_VENDOR 0xff
32
33 #define USB_CDC_PROTO_EEM 7
34
35 #define USB_CDC_NCM_PROTO_NTB 1
36
37 /*-------------------------------------------------------------------------*/
38
39 /*
40 * Class-Specific descriptors ... there are a couple dozen of them
41 */
42
43 #define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
44 #define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
45 #define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
46 #define USB_CDC_UNION_TYPE 0x06 /* union_desc */
47 #define USB_CDC_COUNTRY_TYPE 0x07
48 #define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
49 #define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
50 #define USB_CDC_WHCM_TYPE 0x11
51 #define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
52 #define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
53 #define USB_CDC_DMM_TYPE 0x14
54 #define USB_CDC_OBEX_TYPE 0x15
55 #define USB_CDC_NCM_TYPE 0x1a
56
57 /* "Header Functional Descriptor" from CDC spec 5.2.3.1 */
58 struct usb_cdc_header_desc {
59 __u8 bLength;
60 __u8 bDescriptorType;
61 __u8 bDescriptorSubType;
62
63 __le16 bcdCDC;
64 } __attribute__ ((packed));
65
66 /* "Call Management Descriptor" from CDC spec 5.2.3.2 */
67 struct usb_cdc_call_mgmt_descriptor {
68 __u8 bLength;
69 __u8 bDescriptorType;
70 __u8 bDescriptorSubType;
71
72 __u8 bmCapabilities;
73 #define USB_CDC_CALL_MGMT_CAP_CALL_MGMT 0x01
74 #define USB_CDC_CALL_MGMT_CAP_DATA_INTF 0x02
75
76 __u8 bDataInterface;
77 } __attribute__ ((packed));
78
79 /* "Abstract Control Management Descriptor" from CDC spec 5.2.3.3 */
80 struct usb_cdc_acm_descriptor {
81 __u8 bLength;
82 __u8 bDescriptorType;
83 __u8 bDescriptorSubType;
84
85 __u8 bmCapabilities;
86 } __attribute__ ((packed));
87
88 /* capabilities from 5.2.3.3 */
89
90 #define USB_CDC_COMM_FEATURE 0x01
91 #define USB_CDC_CAP_LINE 0x02
92 #define USB_CDC_CAP_BRK 0x04
93 #define USB_CDC_CAP_NOTIFY 0x08
94
95 /* "Union Functional Descriptor" from CDC spec 5.2.3.8 */
96 struct usb_cdc_union_desc {
97 __u8 bLength;
98 __u8 bDescriptorType;
99 __u8 bDescriptorSubType;
100
101 __u8 bMasterInterface0;
102 __u8 bSlaveInterface0;
103 /* ... and there could be other slave interfaces */
104 } __attribute__ ((packed));
105
106 /* "Country Selection Functional Descriptor" from CDC spec 5.2.3.9 */
107 struct usb_cdc_country_functional_desc {
108 __u8 bLength;
109 __u8 bDescriptorType;
110 __u8 bDescriptorSubType;
111
112 __u8 iCountryCodeRelDate;
113 __le16 wCountyCode0;
114 /* ... and there can be a lot of country codes */
115 } __attribute__ ((packed));
116
117 /* "Network Channel Terminal Functional Descriptor" from CDC spec 5.2.3.11 */
118 struct usb_cdc_network_terminal_desc {
119 __u8 bLength;
120 __u8 bDescriptorType;
121 __u8 bDescriptorSubType;
122
123 __u8 bEntityId;
124 __u8 iName;
125 __u8 bChannelIndex;
126 __u8 bPhysicalInterface;
127 } __attribute__ ((packed));
128
129 /* "Ethernet Networking Functional Descriptor" from CDC spec 5.2.3.16 */
130 struct usb_cdc_ether_desc {
131 __u8 bLength;
132 __u8 bDescriptorType;
133 __u8 bDescriptorSubType;
134
135 __u8 iMACAddress;
136 __le32 bmEthernetStatistics;
137 __le16 wMaxSegmentSize;
138 __le16 wNumberMCFilters;
139 __u8 bNumberPowerFilters;
140 } __attribute__ ((packed));
141
142 /* "Telephone Control Model Functional Descriptor" from CDC WMC spec 6.3..3 */
143 struct usb_cdc_dmm_desc {
144 __u8 bFunctionLength;
145 __u8 bDescriptorType;
146 __u8 bDescriptorSubtype;
147 __u16 bcdVersion;
148 __le16 wMaxCommand;
149 } __attribute__ ((packed));
150
151 /* "MDLM Functional Descriptor" from CDC WMC spec 6.7.2.3 */
152 struct usb_cdc_mdlm_desc {
153 __u8 bLength;
154 __u8 bDescriptorType;
155 __u8 bDescriptorSubType;
156
157 __le16 bcdVersion;
158 __u8 bGUID[16];
159 } __attribute__ ((packed));
160
161 /* "MDLM Detail Functional Descriptor" from CDC WMC spec 6.7.2.4 */
162 struct usb_cdc_mdlm_detail_desc {
163 __u8 bLength;
164 __u8 bDescriptorType;
165 __u8 bDescriptorSubType;
166
167 /* type is associated with mdlm_desc.bGUID */
168 __u8 bGuidDescriptorType;
169 __u8 bDetailData[0];
170 } __attribute__ ((packed));
171
172 /* "OBEX Control Model Functional Descriptor" */
173 struct usb_cdc_obex_desc {
174 __u8 bLength;
175 __u8 bDescriptorType;
176 __u8 bDescriptorSubType;
177
178 __le16 bcdVersion;
179 } __attribute__ ((packed));
180
181 /* "NCM Control Model Functional Descriptor" */
182 struct usb_cdc_ncm_desc {
183 __u8 bLength;
184 __u8 bDescriptorType;
185 __u8 bDescriptorSubType;
186
187 __le16 bcdNcmVersion;
188 __u8 bmNetworkCapabilities;
189 } __attribute__ ((packed));
190 /*-------------------------------------------------------------------------*/
191
192 /*
193 * Class-Specific Control Requests (6.2)
194 *
195 * section 3.6.2.1 table 4 has the ACM profile, for modems.
196 * section 3.8.2 table 10 has the ethernet profile.
197 *
198 * Microsoft's RNDIS stack for Ethernet is a vendor-specific CDC ACM variant,
199 * heavily dependent on the encapsulated (proprietary) command mechanism.
200 */
201
202 #define USB_CDC_SEND_ENCAPSULATED_COMMAND 0x00
203 #define USB_CDC_GET_ENCAPSULATED_RESPONSE 0x01
204 #define USB_CDC_REQ_SET_LINE_CODING 0x20
205 #define USB_CDC_REQ_GET_LINE_CODING 0x21
206 #define USB_CDC_REQ_SET_CONTROL_LINE_STATE 0x22
207 #define USB_CDC_REQ_SEND_BREAK 0x23
208 #define USB_CDC_SET_ETHERNET_MULTICAST_FILTERS 0x40
209 #define USB_CDC_SET_ETHERNET_PM_PATTERN_FILTER 0x41
210 #define USB_CDC_GET_ETHERNET_PM_PATTERN_FILTER 0x42
211 #define USB_CDC_SET_ETHERNET_PACKET_FILTER 0x43
212 #define USB_CDC_GET_ETHERNET_STATISTIC 0x44
213 #define USB_CDC_GET_NTB_PARAMETERS 0x80
214 #define USB_CDC_GET_NET_ADDRESS 0x81
215 #define USB_CDC_SET_NET_ADDRESS 0x82
216 #define USB_CDC_GET_NTB_FORMAT 0x83
217 #define USB_CDC_SET_NTB_FORMAT 0x84
218 #define USB_CDC_GET_NTB_INPUT_SIZE 0x85
219 #define USB_CDC_SET_NTB_INPUT_SIZE 0x86
220 #define USB_CDC_GET_MAX_DATAGRAM_SIZE 0x87
221 #define USB_CDC_SET_MAX_DATAGRAM_SIZE 0x88
222 #define USB_CDC_GET_CRC_MODE 0x89
223 #define USB_CDC_SET_CRC_MODE 0x8a
224
225 /* Line Coding Structure from CDC spec 6.2.13 */
226 struct usb_cdc_line_coding {
227 __le32 dwDTERate;
228 __u8 bCharFormat;
229 #define USB_CDC_1_STOP_BITS 0
230 #define USB_CDC_1_5_STOP_BITS 1
231 #define USB_CDC_2_STOP_BITS 2
232
233 __u8 bParityType;
234 #define USB_CDC_NO_PARITY 0
235 #define USB_CDC_ODD_PARITY 1
236 #define USB_CDC_EVEN_PARITY 2
237 #define USB_CDC_MARK_PARITY 3
238 #define USB_CDC_SPACE_PARITY 4
239
240 __u8 bDataBits;
241 } __attribute__ ((packed));
242
243 /* table 62; bits in multicast filter */
244 #define USB_CDC_PACKET_TYPE_PROMISCUOUS (1 << 0)
245 #define USB_CDC_PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */
246 #define USB_CDC_PACKET_TYPE_DIRECTED (1 << 2)
247 #define USB_CDC_PACKET_TYPE_BROADCAST (1 << 3)
248 #define USB_CDC_PACKET_TYPE_MULTICAST (1 << 4) /* filtered */
249
250
251 /*-------------------------------------------------------------------------*/
252
253 /*
254 * Class-Specific Notifications (6.3) sent by interrupt transfers
255 *
256 * section 3.8.2 table 11 of the CDC spec lists Ethernet notifications
257 * section 3.6.2.1 table 5 specifies ACM notifications, accepted by RNDIS
258 * RNDIS also defines its own bit-incompatible notifications
259 */
260
261 #define USB_CDC_NOTIFY_NETWORK_CONNECTION 0x00
262 #define USB_CDC_NOTIFY_RESPONSE_AVAILABLE 0x01
263 #define USB_CDC_NOTIFY_SERIAL_STATE 0x20
264 #define USB_CDC_NOTIFY_SPEED_CHANGE 0x2a
265
266 struct usb_cdc_notification {
267 __u8 bmRequestType;
268 __u8 bNotificationType;
269 __le16 wValue;
270 __le16 wIndex;
271 __le16 wLength;
272 } __attribute__ ((packed));
273
274 /*-------------------------------------------------------------------------*/
275
276 /*
277 * Class Specific structures and constants
278 *
279 * CDC NCM NTB parameters structure, CDC NCM subclass 6.2.1
280 *
281 */
282
283 struct usb_cdc_ncm_ntb_parameters {
284 __le16 wLength;
285 __le16 bmNtbFormatsSupported;
286 __le32 dwNtbInMaxSize;
287 __le16 wNdpInDivisor;
288 __le16 wNdpInPayloadRemainder;
289 __le16 wNdpInAlignment;
290 __le16 wPadding1;
291 __le32 dwNtbOutMaxSize;
292 __le16 wNdpOutDivisor;
293 __le16 wNdpOutPayloadRemainder;
294 __le16 wNdpOutAlignment;
295 __le16 wPadding2;
296 } __attribute__ ((packed));
297
298 /*
299 * CDC NCM transfer headers, CDC NCM subclass 3.2
300 */
301
302 #define USB_CDC_NCM_NTH16_SIGN 0x484D434E /* NCMH */
303 #define USB_CDC_NCM_NTH32_SIGN 0x686D636E /* ncmh */
304
305 struct usb_cdc_ncm_nth16 {
306 __le32 dwSignature;
307 __le16 wHeaderLength;
308 __le16 wSequence;
309 __le16 wBlockLength;
310 __le16 wFpIndex;
311 } __attribute__ ((packed));
312
313 struct usb_cdc_ncm_nth32 {
314 __le32 dwSignature;
315 __le16 wHeaderLength;
316 __le16 wSequence;
317 __le32 dwBlockLength;
318 __le32 dwFpIndex;
319 } __attribute__ ((packed));
320
321 /*
322 * CDC NCM datagram pointers, CDC NCM subclass 3.3
323 */
324
325 #define USB_CDC_NCM_NDP16_CRC_SIGN 0x314D434E /* NCM1 */
326 #define USB_CDC_NCM_NDP16_NOCRC_SIGN 0x304D434E /* NCM0 */
327 #define USB_CDC_NCM_NDP32_CRC_SIGN 0x316D636E /* ncm1 */
328 #define USB_CDC_NCM_NDP32_NOCRC_SIGN 0x306D636E /* ncm0 */
329
330 /* 16-bit NCM Datagram Pointer Entry */
331 struct usb_cdc_ncm_dpe16 {
332 __le16 wDatagramIndex;
333 __le16 wDatagramLength;
334 } __attribute__((__packed__));
335
336 /* 16-bit NCM Datagram Pointer Table */
337 struct usb_cdc_ncm_ndp16 {
338 __le32 dwSignature;
339 __le16 wLength;
340 __le16 wNextFpIndex;
341 struct usb_cdc_ncm_dpe16 dpe16[0];
342 } __attribute__ ((packed));
343
344 /* 32-bit NCM Datagram Pointer Entry */
345 struct usb_cdc_ncm_dpe32 {
346 __le32 dwDatagramIndex;
347 __le32 dwDatagramLength;
348 } __attribute__((__packed__));
349
350 /* 32-bit NCM Datagram Pointer Table */
351 struct usb_cdc_ncm_ndp32 {
352 __le32 dwSignature;
353 __le16 wLength;
354 __le16 wReserved6;
355 __le32 dwNextNdpIndex;
356 __le32 dwReserved12;
357 struct usb_cdc_ncm_dpe32 dpe32[0];
358 } __attribute__ ((packed));
359
360 /* CDC NCM subclass 3.2.1 and 3.2.2 */
361 #define USB_CDC_NCM_NDP16_INDEX_MIN 0x000C
362 #define USB_CDC_NCM_NDP32_INDEX_MIN 0x0010
363
364 /* CDC NCM subclass 3.3.3 Datagram Formatting */
365 #define USB_CDC_NCM_DATAGRAM_FORMAT_CRC 0x30
366 #define USB_CDC_NCM_DATAGRAM_FORMAT_NOCRC 0X31
367
368 /* CDC NCM subclass 4.2 NCM Communications Interface Protocol Code */
369 #define USB_CDC_NCM_PROTO_CODE_NO_ENCAP_COMMANDS 0x00
370 #define USB_CDC_NCM_PROTO_CODE_EXTERN_PROTO 0xFE
371
372 /* CDC NCM subclass 5.2.1 NCM Functional Descriptor, bmNetworkCapabilities */
373 #define USB_CDC_NCM_NCAP_ETH_FILTER (1 << 0)
374 #define USB_CDC_NCM_NCAP_NET_ADDRESS (1 << 1)
375 #define USB_CDC_NCM_NCAP_ENCAP_COMMAND (1 << 2)
376 #define USB_CDC_NCM_NCAP_MAX_DATAGRAM_SIZE (1 << 3)
377 #define USB_CDC_NCM_NCAP_CRC_MODE (1 << 4)
378
379 /* CDC NCM subclass Table 6-3: NTB Parameter Structure */
380 #define USB_CDC_NCM_NTB16_SUPPORTED (1 << 0)
381 #define USB_CDC_NCM_NTB32_SUPPORTED (1 << 1)
382
383 /* CDC NCM subclass Table 6-3: NTB Parameter Structure */
384 #define USB_CDC_NCM_NDP_ALIGN_MIN_SIZE 0x04
385 #define USB_CDC_NCM_NTB_MAX_LENGTH 0x1C
386
387 /* CDC NCM subclass 6.2.5 SetNtbFormat */
388 #define USB_CDC_NCM_NTB16_FORMAT 0x00
389 #define USB_CDC_NCM_NTB32_FORMAT 0x01
390
391 /* CDC NCM subclass 6.2.7 SetNtbInputSize */
392 #define USB_CDC_NCM_NTB_MIN_IN_SIZE 2048
393 #define USB_CDC_NCM_NTB_MIN_OUT_SIZE 2048
394
395 /* CDC NCM subclass 6.2.11 SetCrcMode */
396 #define USB_CDC_NCM_CRC_NOT_APPENDED 0x00
397 #define USB_CDC_NCM_CRC_APPENDED 0x01
398
399 #endif /* __LINUX_USB_CDC_H */
This page took 0.041827 seconds and 5 git commands to generate.