USB: wusb: annotate association types withe proper endianness
[linux-2.6.git] / include / linux / usb / association.h
1 /*
2  * Wireless USB - Cable Based Association
3  *
4  * Copyright (C) 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  */
12 #ifndef __LINUX_USB_ASSOCIATION_H
13 #define __LINUX_USB_ASSOCIATION_H
14
15
16 /*
17  * Association attributes
18  *
19  * Association Models Supplement to WUSB 1.0 T[3-1]
20  *
21  * Each field in the structures has it's ID, it's length and then the
22  * value. This is the actual definition of the field's ID and its
23  * length.
24  */
25 struct wusb_am_attr {
26         __u8 id;
27         __u8 len;
28 };
29
30 /* Different fields defined by the spec */
31 #define WUSB_AR_AssociationTypeId       { .id = cpu_to_le16(0x0000), .len = cpu_to_le16(2) }
32 #define WUSB_AR_AssociationSubTypeId    { .id = cpu_to_le16(0x0001), .len = cpu_to_le16(2) }
33 #define WUSB_AR_Length                  { .id = cpu_to_le16(0x0002), .len = cpu_to_le16(4) }
34 #define WUSB_AR_AssociationStatus       { .id = cpu_to_le16(0x0004), .len = cpu_to_le16(4) }
35 #define WUSB_AR_LangID                  { .id = cpu_to_le16(0x0008), .len = cpu_to_le16(2) }
36 #define WUSB_AR_DeviceFriendlyName      { .id = cpu_to_le16(0x000b), .len = cpu_to_le16(64) } /* max */
37 #define WUSB_AR_HostFriendlyName        { .id = cpu_to_le16(0x000c), .len = cpu_to_le16(64) } /* max */
38 #define WUSB_AR_CHID                    { .id = cpu_to_le16(0x1000), .len = cpu_to_le16(16) }
39 #define WUSB_AR_CDID                    { .id = cpu_to_le16(0x1001), .len = cpu_to_le16(16) }
40 #define WUSB_AR_ConnectionContext       { .id = cpu_to_le16(0x1002), .len = cpu_to_le16(48) }
41 #define WUSB_AR_BandGroups              { .id = cpu_to_le16(0x1004), .len = cpu_to_le16(2) }
42
43 /* CBAF Control Requests (AMS1.0[T4-1] */
44 enum {
45         CBAF_REQ_GET_ASSOCIATION_INFORMATION = 0x01,
46         CBAF_REQ_GET_ASSOCIATION_REQUEST,
47         CBAF_REQ_SET_ASSOCIATION_RESPONSE
48 };
49
50 /*
51  * CBAF USB-interface defitions
52  *
53  * No altsettings, one optional interrupt endpoint.
54  */
55 enum {
56         CBAF_IFACECLASS    = 0xef,
57         CBAF_IFACESUBCLASS = 0x03,
58         CBAF_IFACEPROTOCOL = 0x01,
59 };
60
61 /* Association Information (AMS1.0[T4-3]) */
62 struct wusb_cbaf_assoc_info {
63         __le16 Length;
64         __u8 NumAssociationRequests;
65         __le16 Flags;
66         __u8 AssociationRequestsArray[];
67 } __attribute__((packed));
68
69 /* Association Request (AMS1.0[T4-4]) */
70 struct wusb_cbaf_assoc_request {
71         __u8 AssociationDataIndex;
72         __u8 Reserved;
73         __le16 AssociationTypeId;
74         __le16 AssociationSubTypeId;
75         __le32 AssociationTypeInfoSize;
76 } __attribute__((packed));
77
78 enum {
79         AR_TYPE_WUSB                    = 0x0001,
80         AR_TYPE_WUSB_RETRIEVE_HOST_INFO = 0x0000,
81         AR_TYPE_WUSB_ASSOCIATE          = 0x0001,
82 };
83
84 /* Association Attribute header (AMS1.0[3.8]) */
85 struct wusb_cbaf_attr_hdr {
86         __le16 id;
87         __le16 len;
88 } __attribute__((packed));
89
90 /* Host Info (AMS1.0[T4-7]) (yeah, more headers and fields...) */
91 struct wusb_cbaf_host_info {
92         struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
93         __le16 AssociationTypeId;
94         struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
95         __le16 AssociationSubTypeId;
96         struct wusb_cbaf_attr_hdr CHID_hdr;
97         struct wusb_ckhdid CHID;
98         struct wusb_cbaf_attr_hdr LangID_hdr;
99         __le16 LangID;
100         struct wusb_cbaf_attr_hdr HostFriendlyName_hdr;
101         __u8 HostFriendlyName[];
102 } __attribute__((packed));
103
104 /* Device Info (AMS1.0[T4-8])
105  *
106  * I still don't get this tag'n'header stuff for each goddamn
107  * field...
108  */
109 struct wusb_cbaf_device_info {
110         struct wusb_cbaf_attr_hdr Length_hdr;
111         __le32 Length;
112         struct wusb_cbaf_attr_hdr CDID_hdr;
113         struct wusb_ckhdid CDID;
114         struct wusb_cbaf_attr_hdr BandGroups_hdr;
115         __le16 BandGroups;
116         struct wusb_cbaf_attr_hdr LangID_hdr;
117         __le16 LangID;
118         struct wusb_cbaf_attr_hdr DeviceFriendlyName_hdr;
119         __u8 DeviceFriendlyName[];
120 } __attribute__((packed));
121
122 /* Connection Context; CC_DATA - Success case (AMS1.0[T4-9]) */
123 struct wusb_cbaf_cc_data {
124         struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
125         __le16 AssociationTypeId;
126         struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
127         __le16 AssociationSubTypeId;
128         struct wusb_cbaf_attr_hdr Length_hdr;
129         __le32 Length;
130         struct wusb_cbaf_attr_hdr ConnectionContext_hdr;
131         struct wusb_ckhdid CHID;
132         struct wusb_ckhdid CDID;
133         struct wusb_ckhdid CK;
134         struct wusb_cbaf_attr_hdr BandGroups_hdr;
135         __le16 BandGroups;
136 } __attribute__((packed));
137
138 /* CC_DATA - Failure case (AMS1.0[T4-10]) */
139 struct wusb_cbaf_cc_data_fail {
140         struct wusb_cbaf_attr_hdr AssociationTypeId_hdr;
141         __le16 AssociationTypeId;
142         struct wusb_cbaf_attr_hdr AssociationSubTypeId_hdr;
143         __le16 AssociationSubTypeId;
144         struct wusb_cbaf_attr_hdr Length_hdr;
145         __le16 Length;
146         struct wusb_cbaf_attr_hdr AssociationStatus_hdr;
147         __u32 AssociationStatus;
148 } __attribute__((packed));
149
150 #endif  /* __LINUX_USB_ASSOCIATION_H */