1 /* -----------------------------------------------------------------------------
2 * Copyright (c) 2011 Ozmo Inc
3 * Released under the GNU General Public License Version 2 (GPLv2).
4 * -----------------------------------------------------------------------------
9 #define PACKED __packed
11 #define OZ_ETHERTYPE 0x892e
15 #define OZ_STATUS_SUCCESS 0
16 #define OZ_STATUS_INVALID_PARAM 1
17 #define OZ_STATUS_TOO_MANY_PDS 2
18 #define OZ_STATUS_NOT_ALLOWED 4
19 #define OZ_STATUS_SESSION_MISMATCH 5
20 #define OZ_STATUS_SESSION_TEARDOWN 6
22 /* This is the generic element header.
23 Every element starts with this.
30 #define oz_next_elt(__elt) \
31 (struct oz_elt *)((u8 *)((__elt) + 1) + (__elt)->length)
33 /* Protocol element IDs.
35 #define OZ_ELT_CONNECT_REQ 0x06
36 #define OZ_ELT_CONNECT_RSP 0x07
37 #define OZ_ELT_DISCONNECT 0x08
38 #define OZ_ELT_UPDATE_PARAM_REQ 0x11
39 #define OZ_ELT_FAREWELL_REQ 0x12
40 #define OZ_ELT_APP_DATA 0x31
42 /* This is the Ozmo header which is the first Ozmo specific part
43 * of a frame and comes after the MAC header.
51 #define OZ_PROTOCOL_VERSION 0x1
52 /* Bits in the control field. */
53 #define OZ_VERSION_MASK 0xc
54 #define OZ_VERSION_SHIFT 2
56 #define OZ_F_ISOC 0x20
57 #define OZ_F_MORE_DATA 0x40
58 #define OZ_F_ACK_REQUESTED 0x80
60 #define oz_get_prot_ver(__x) (((__x) & OZ_VERSION_MASK) >> OZ_VERSION_SHIFT)
62 /* Used to select the bits of packet number to put in the last_pkt_num.
64 #define OZ_LAST_PN_MASK 0x00ff
66 #define OZ_LAST_PN_HALF_CYCLE 127
68 /* Connect request data structure.
70 struct oz_elt_connect_req {
87 #define OZ_MODE_POLLED 0x0
88 #define OZ_MODE_TRIGGERED 0x1
89 #define OZ_MODE_MASK 0xf
90 #define OZ_F_ISOC_NO_ELTS 0x40
91 #define OZ_F_ISOC_ANYTIME 0x80
95 #define OZ_KALIVE_TYPE_MASK 0xc0
96 #define OZ_KALIVE_VALUE_MASK 0x3f
97 #define OZ_KALIVE_SPECIAL 0x00
98 #define OZ_KALIVE_SECS 0x40
99 #define OZ_KALIVE_MINS 0x80
100 #define OZ_KALIVE_HOURS 0xc0
102 /* Connect response data structure.
104 struct oz_elt_connect_rsp {
113 struct oz_elt_farewell {
119 struct oz_elt_update_param {
127 /* Header common to all application elements.
134 /* Values for app_id.
136 #define OZ_APPID_USB 0x1
137 #define OZ_APPID_UNUSED1 0x2
138 #define OZ_APPID_UNUSED2 0x3
139 #define OZ_APPID_SERIAL 0x4
140 #define OZ_APPID_MAX OZ_APPID_SERIAL
141 #define OZ_NB_APPS (OZ_APPID_MAX+1)
143 /* USB header common to all elements for the USB application.
144 * This header extends the oz_app_hdr and comes directly after
145 * the element header in a USB application.
155 /* USB requests element subtypes (type field of hs_usb_hdr).
157 #define OZ_GET_DESC_REQ 1
158 #define OZ_GET_DESC_RSP 2
159 #define OZ_SET_CONFIG_REQ 3
160 #define OZ_SET_CONFIG_RSP 4
161 #define OZ_SET_INTERFACE_REQ 5
162 #define OZ_SET_INTERFACE_RSP 6
163 #define OZ_VENDOR_CLASS_REQ 7
164 #define OZ_VENDOR_CLASS_RSP 8
165 #define OZ_GET_STATUS_REQ 9
166 #define OZ_GET_STATUS_RSP 10
167 #define OZ_CLEAR_FEATURE_REQ 11
168 #define OZ_CLEAR_FEATURE_RSP 12
169 #define OZ_SET_FEATURE_REQ 13
170 #define OZ_SET_FEATURE_RSP 14
171 #define OZ_GET_CONFIGURATION_REQ 15
172 #define OZ_GET_CONFIGURATION_RSP 16
173 #define OZ_GET_INTERFACE_REQ 17
174 #define OZ_GET_INTERFACE_RSP 18
175 #define OZ_SYNCH_FRAME_REQ 19
176 #define OZ_SYNCH_FRAME_RSP 20
177 #define OZ_USB_ENDPOINT_DATA 23
179 #define OZ_REQD_D2H 0x80
181 struct oz_get_desc_req {
194 /* Values for desc_type field.
196 #define OZ_DESC_DEVICE 0x01
197 #define OZ_DESC_CONFIG 0x02
198 #define OZ_DESC_STRING 0x03
200 /* Values for req_type field.
202 #define OZ_RECP_MASK 0x1F
203 #define OZ_RECP_DEVICE 0x00
204 #define OZ_RECP_INTERFACE 0x01
205 #define OZ_RECP_ENDPOINT 0x02
207 #define OZ_REQT_MASK 0x60
208 #define OZ_REQT_STD 0x00
209 #define OZ_REQT_CLASS 0x20
210 #define OZ_REQT_VENDOR 0x40
212 struct oz_get_desc_rsp {
223 struct oz_feature_req {
233 struct oz_feature_rsp {
241 struct oz_set_config_req {
249 struct oz_set_config_rsp {
257 struct oz_set_interface_req {
266 struct oz_set_interface_rsp {
274 struct oz_get_interface_req {
282 struct oz_get_interface_rsp {
291 struct oz_vendor_class_req {
303 struct oz_vendor_class_rsp {
320 struct oz_isoc_fixed {
331 struct oz_multiple_fixed {
341 struct oz_fragmented {
352 /* Note: the following does not get packaged in an element in the same way
353 * that other data formats are packaged. Instead the data is put in a frame
354 * directly after the oz_header and is the only permitted data in such a
355 * frame. The length of the data is directly determined from the frame size.
357 struct oz_isoc_large {
364 #define OZ_DATA_F_TYPE_MASK 0xF
365 #define OZ_DATA_F_MULTIPLE_FIXED 0x1
366 #define OZ_DATA_F_MULTIPLE_VAR 0x2
367 #define OZ_DATA_F_ISOC_FIXED 0x3
368 #define OZ_DATA_F_ISOC_VAR 0x4
369 #define OZ_DATA_F_FRAGMENTED 0x5
370 #define OZ_DATA_F_ISOC_LARGE 0x7
372 #endif /* _OZPROTOCOL_H */