Merge tag 'rdma-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[cascardo/linux.git] / include / linux / usb / wusb-wa.h
1 /*
2  * Wireless USB Wire Adapter constants and structures.
3  *
4  * Copyright (C) 2005-2006 Intel Corporation.
5  * Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License version
9  * 2 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  *
21  *
22  * FIXME: docs
23  * FIXME: organize properly, group logically
24  *
25  * All the event structures are defined in uwb/spec.h, as they are
26  * common to the WHCI and WUSB radio control interfaces.
27  *
28  * References:
29  *   [WUSB] Wireless Universal Serial Bus Specification, revision 1.0, ch8
30  */
31 #ifndef __LINUX_USB_WUSB_WA_H
32 #define __LINUX_USB_WUSB_WA_H
33
34 /**
35  * Radio Command Request for the Radio Control Interface
36  *
37  * Radio Control Interface command and event codes are the same as
38  * WHCI, and listed in include/linux/uwb.h:UWB_RC_{CMD,EVT}_*
39  */
40 enum {
41         WA_EXEC_RC_CMD = 40,    /* Radio Control command Request */
42 };
43
44 /* Wireless Adapter Requests ([WUSB] table 8-51) */
45 enum {
46         WUSB_REQ_ADD_MMC_IE     = 20,
47         WUSB_REQ_REMOVE_MMC_IE  = 21,
48         WUSB_REQ_SET_NUM_DNTS   = 22,
49         WUSB_REQ_SET_CLUSTER_ID = 23,
50         WUSB_REQ_SET_DEV_INFO   = 24,
51         WUSB_REQ_GET_TIME       = 25,
52         WUSB_REQ_SET_STREAM_IDX = 26,
53         WUSB_REQ_SET_WUSB_MAS   = 27,
54         WUSB_REQ_CHAN_STOP      = 28,
55 };
56
57
58 /* Wireless Adapter WUSB Channel Time types ([WUSB] table 8-52) */
59 enum {
60         WUSB_TIME_ADJ   = 0,
61         WUSB_TIME_BPST  = 1,
62         WUSB_TIME_WUSB  = 2,
63 };
64
65 enum {
66         WA_ENABLE = 0x01,
67         WA_RESET = 0x02,
68         RPIPE_PAUSE = 0x1,
69 };
70
71 /* Responses from Get Status request ([WUSB] section 8.3.1.6) */
72 enum {
73         WA_STATUS_ENABLED = 0x01,
74         WA_STATUS_RESETTING = 0x02
75 };
76
77 enum rpipe_crs {
78         RPIPE_CRS_CTL = 0x01,
79         RPIPE_CRS_ISO = 0x02,
80         RPIPE_CRS_BULK = 0x04,
81         RPIPE_CRS_INTR = 0x08
82 };
83
84 /**
85  * RPipe descriptor ([WUSB] section 8.5.2.11)
86  *
87  * FIXME: explain rpipes
88  */
89 struct usb_rpipe_descriptor {
90         u8      bLength;
91         u8      bDescriptorType;
92         __le16  wRPipeIndex;
93         __le16  wRequests;
94         __le16  wBlocks;                /* rw if 0 */
95         __le16  wMaxPacketSize;         /* rw */
96         union {
97                 u8      dwa_bHSHubAddress;              /* rw: DWA. */
98                 u8      hwa_bMaxBurst;                  /* rw: HWA. */
99         };
100         union {
101                 u8      dwa_bHSHubPort;         /*  rw: DWA. */
102                 u8      hwa_bDeviceInfoIndex;   /*  rw: HWA. */
103         };
104         u8      bSpeed;                 /* rw: xfer rate 'enum uwb_phy_rate' */
105         union {
106                 u8 dwa_bDeviceAddress;  /* rw: DWA Target device address. */
107                 u8 hwa_reserved;                /* rw: HWA. */
108         };
109         u8      bEndpointAddress;       /* rw: Target EP address */
110         u8      bDataSequence;          /* ro: Current Data sequence */
111         __le32  dwCurrentWindow;        /* ro */
112         u8      bMaxDataSequence;       /* ro?: max supported seq */
113         u8      bInterval;              /* rw:  */
114         u8      bOverTheAirInterval;    /* rw:  */
115         u8      bmAttribute;            /* ro?  */
116         u8      bmCharacteristics;      /* ro? enum rpipe_attr, supported xsactions */
117         u8      bmRetryOptions;         /* rw? */
118         __le16  wNumTransactionErrors;  /* rw */
119 } __attribute__ ((packed));
120
121 /**
122  * Wire Adapter Notification types ([WUSB] sections 8.4.5 & 8.5.4)
123  *
124  * These are the notifications coming on the notification endpoint of
125  * an HWA and a DWA.
126  */
127 enum wa_notif_type {
128         DWA_NOTIF_RWAKE = 0x91,
129         DWA_NOTIF_PORTSTATUS = 0x92,
130         WA_NOTIF_TRANSFER = 0x93,
131         HWA_NOTIF_BPST_ADJ = 0x94,
132         HWA_NOTIF_DN = 0x95,
133 };
134
135 /**
136  * Wire Adapter notification header
137  *
138  * Notifications coming from a wire adapter use a common header
139  * defined in [WUSB] sections 8.4.5 & 8.5.4.
140  */
141 struct wa_notif_hdr {
142         u8 bLength;
143         u8 bNotifyType;                 /* enum wa_notif_type */
144 } __attribute__((packed));
145
146 /**
147  * HWA DN Received notification [(WUSB] section 8.5.4.2)
148  *
149  * The DNData is specified in WUSB1.0[7.6]. For each device
150  * notification we received, we just need to dispatch it.
151  *
152  * @dndata:  this is really an array of notifications, but all start
153  *           with the same header.
154  */
155 struct hwa_notif_dn {
156         struct wa_notif_hdr hdr;
157         u8 bSourceDeviceAddr;           /* from errata 2005/07 */
158         u8 bmAttributes;
159         struct wusb_dn_hdr dndata[];
160 } __attribute__((packed));
161
162 /* [WUSB] section 8.3.3 */
163 enum wa_xfer_type {
164         WA_XFER_TYPE_CTL = 0x80,
165         WA_XFER_TYPE_BI = 0x81,         /* bulk/interrupt */
166         WA_XFER_TYPE_ISO = 0x82,
167         WA_XFER_RESULT = 0x83,
168         WA_XFER_ABORT = 0x84,
169 };
170
171 /* [WUSB] section 8.3.3 */
172 struct wa_xfer_hdr {
173         u8 bLength;                     /* 0x18 */
174         u8 bRequestType;                /* 0x80 WA_REQUEST_TYPE_CTL */
175         __le16 wRPipe;                  /* RPipe index */
176         __le32 dwTransferID;            /* Host-assigned ID */
177         __le32 dwTransferLength;        /* Length of data to xfer */
178         u8 bTransferSegment;
179 } __attribute__((packed));
180
181 struct wa_xfer_ctl {
182         struct wa_xfer_hdr hdr;
183         u8 bmAttribute;
184         __le16 wReserved;
185         struct usb_ctrlrequest baSetupData;
186 } __attribute__((packed));
187
188 struct wa_xfer_bi {
189         struct wa_xfer_hdr hdr;
190         u8 bReserved;
191         __le16 wReserved;
192 } __attribute__((packed));
193
194 struct wa_xfer_hwaiso {
195         struct wa_xfer_hdr hdr;
196         u8 bReserved;
197         __le16 wPresentationTime;
198         __le32 dwNumOfPackets;
199         /* FIXME: u8 pktdata[]? */
200 } __attribute__((packed));
201
202 /* [WUSB] section 8.3.3.5 */
203 struct wa_xfer_abort {
204         u8 bLength;
205         u8 bRequestType;
206         __le16 wRPipe;                  /* RPipe index */
207         __le32 dwTransferID;            /* Host-assigned ID */
208 } __attribute__((packed));
209
210 /**
211  * WA Transfer Complete notification ([WUSB] section 8.3.3.3)
212  *
213  */
214 struct wa_notif_xfer {
215         struct wa_notif_hdr hdr;
216         u8 bEndpoint;
217         u8 Reserved;
218 } __attribute__((packed));
219
220 /** Transfer result basic codes [WUSB] table 8-15 */
221 enum {
222         WA_XFER_STATUS_SUCCESS,
223         WA_XFER_STATUS_HALTED,
224         WA_XFER_STATUS_DATA_BUFFER_ERROR,
225         WA_XFER_STATUS_BABBLE,
226         WA_XFER_RESERVED,
227         WA_XFER_STATUS_NOT_FOUND,
228         WA_XFER_STATUS_INSUFFICIENT_RESOURCE,
229         WA_XFER_STATUS_TRANSACTION_ERROR,
230         WA_XFER_STATUS_ABORTED,
231         WA_XFER_STATUS_RPIPE_NOT_READY,
232         WA_XFER_INVALID_FORMAT,
233         WA_XFER_UNEXPECTED_SEGMENT_NUMBER,
234         WA_XFER_STATUS_RPIPE_TYPE_MISMATCH,
235 };
236
237 /** [WUSB] section 8.3.3.4 */
238 struct wa_xfer_result {
239         struct wa_notif_hdr hdr;
240         __le32 dwTransferID;
241         __le32 dwTransferLength;
242         u8     bTransferSegment;
243         u8     bTransferStatus;
244         __le32 dwNumOfPackets;
245 } __attribute__((packed));
246
247 /**
248  * Wire Adapter Class Descriptor ([WUSB] section 8.5.2.7).
249  *
250  * NOTE: u16 fields are read Little Endian from the hardware.
251  *
252  * @bNumPorts is the original max number of devices that the host can
253  *            connect; we might chop this so the stack can handle
254  *            it. In case you need to access it, use wusbhc->ports_max
255  *            if it is a Wireless USB WA.
256  */
257 struct usb_wa_descriptor {
258         u8      bLength;
259         u8      bDescriptorType;
260         u16     bcdWAVersion;
261         u8      bNumPorts;              /* don't use!! */
262         u8      bmAttributes;           /* Reserved == 0 */
263         u16     wNumRPipes;
264         u16     wRPipeMaxBlock;
265         u8      bRPipeBlockSize;
266         u8      bPwrOn2PwrGood;
267         u8      bNumMMCIEs;
268         u8      DeviceRemovable;        /* FIXME: in DWA this is up to 16 bytes */
269 } __attribute__((packed));
270
271 /**
272  * HWA Device Information Buffer (WUSB1.0[T8.54])
273  */
274 struct hwa_dev_info {
275         u8      bmDeviceAvailability[32];       /* FIXME: ignored for now */
276         u8      bDeviceAddress;
277         __le16  wPHYRates;
278         u8      bmDeviceAttribute;
279 } __attribute__((packed));
280
281 #endif /* #ifndef __LINUX_USB_WUSB_WA_H */