1  /*
2   * Copyright (c) 2012, 2014-2016, 2018 The Linux Foundation. All rights reserved.
3   *
4   * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5   *
6   *
7   * Permission to use, copy, modify, and/or distribute this software for
8   * any purpose with or without fee is hereby granted, provided that the
9   * above copyright notice and this permission notice appear in all
10   * copies.
11   *
12   * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13   * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14   * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15   * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16   * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17   * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18   * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19   * PERFORMANCE OF THIS SOFTWARE.
20   */
21  
22  /*
23   * This file was originally distributed by Qualcomm Atheros, Inc.
24   * under proprietary terms before Copyright ownership was assigned
25   * to the Linux Foundation.
26   */
27  
28  #ifndef __HTC_H__
29  #define __HTC_H__
30  
31  #ifndef ATH_TARGET
32  #include "athstartpack.h"
33  #endif
34  #ifdef ATHR_WIN_NWF
35  #pragma warning( disable:4214 ) //bit field types other than int
36  #endif
37  #undef MS
38  #define MS(_v, _f) (((_v) & _f##_MASK) >> _f##_LSB)
39  #undef SM
40  #define SM(_v, _f) (((_v) << _f##_LSB) & _f##_MASK)
41  #undef WO
42  #define WO(_f)      ((_f##_OFFSET) >> 2)
43  
44  #undef GET_FIELD
45  #define GET_FIELD(_addr, _f) MS(*((A_UINT32 *)(_addr) + WO(_f)), _f)
46  #undef SET_FIELD
47  #define SET_FIELD(_addr, _f, _val)  \
48      (*((A_UINT32 *)(_addr) + WO(_f)) = \
49       (*((A_UINT32 *)(_addr) + WO(_f)) & ~_f##_MASK) | SM(_val, _f))
50  
51  #define HTC_GET_FIELD(_msg_buf, _msg_type, _f) \
52      GET_FIELD(_msg_buf, _msg_type ## _ ## _f)
53  
54  #define HTC_SET_FIELD(_msg_buf, _msg_type, _f, _val) \
55      SET_FIELD(_msg_buf, _msg_type ## _ ## _f, _val)
56  
57  #define HTC_WRITE32(_addr, _val) \
58      (*(A_UINT32 *)(_addr) = (_val))
59  
60  #ifndef A_OFFSETOF
61  #define A_OFFSETOF(type,field) (unsigned long)(&(((type *)NULL)->field))
62  #endif
63  
64  #define ASSEMBLE_UNALIGNED_UINT16(p,highbyte,lowbyte) \
65          (((A_UINT16)(((A_UINT8 *)(p))[(highbyte)])) << 8 | (A_UINT16)(((A_UINT8 *)(p))[(lowbyte)]))
66  
67  /****** DANGER DANGER ***************
68   *
69   *   The frame header length and message formats defined herein were
70   *   selected to accommodate optimal alignment for target processing.  This reduces code
71   *   size and improves performance.
72   *
73   *   Any changes to the header length may alter the alignment and cause exceptions
74   *   on the target. When adding to the message structures insure that fields are
75   *   properly aligned.
76   *
77   */
78  
79  /* HTC frame header */
80  typedef PREPACK struct _HTC_FRAME_HDR{
81          /* do not remove or re-arrange these fields, these are minimally required
82           * to take advantage of 4-byte lookaheads in some hardware implementations */
83      A_UINT32   EndpointID : 8,
84                 Flags : 8,
85                 PayloadLen : 16; /* length of data (including trailer) that follows the header */
86  
87      /***** end of 4-byte lookahead ****/
88  
89      A_UINT32   ControlBytes0 : 8, /* used for CRC check if CRC_CHECK flag set */
90                 ControlBytes1 : 8, /* used for seq check if SEQ_CHECK flag set */
91                 reserved : 16; /* used by bundle processing in SDIO systems */
92  
93      /* message payload starts after the header */
94  
95  } POSTPACK HTC_FRAME_HDR;
96  
97  #define HTC_FRAME_HDR_ENDPOINTID_LSB                0
98  #define HTC_FRAME_HDR_ENDPOINTID_MASK               0x000000ff
99  #define HTC_FRAME_HDR_ENDPOINTID_OFFSET             0x00000000
100  #define HTC_FRAME_HDR_FLAGS_LSB                     8
101  #define HTC_FRAME_HDR_FLAGS_MASK                    0x0000ff00
102  #define HTC_FRAME_HDR_FLAGS_OFFSET                  0x00000000
103  #define HTC_FRAME_HDR_PAYLOADLEN_LSB                16
104  #define HTC_FRAME_HDR_PAYLOADLEN_MASK               0xffff0000
105  #define HTC_FRAME_HDR_PAYLOADLEN_OFFSET             0x00000000
106  #define HTC_FRAME_HDR_CONTROLBYTES0_LSB             0
107  #define HTC_FRAME_HDR_CONTROLBYTES0_MASK            0x000000ff
108  #define HTC_FRAME_HDR_CONTROLBYTES0_OFFSET          0x00000004
109  #define HTC_FRAME_HDR_CONTROLBYTES1_LSB             8
110  #define HTC_FRAME_HDR_CONTROLBYTES1_MASK            0x0000ff00
111  #define HTC_FRAME_HDR_CONTROLBYTES1_OFFSET          0x00000004
112  #define HTC_FRAME_HDR_RESERVED_LSB                  16
113  #define HTC_FRAME_HDR_RESERVED_MASK                 0xffff0000
114  #define HTC_FRAME_HDR_RESERVED_OFFSET               0x00000004
115  
116  /* frame header flags */
117  
118      /* send direction */
119  #define HTC_FLAGS_NEED_CREDIT_UPDATE (1 << 0)
120  #define HTC_FLAGS_SEND_BUNDLE        (1 << 1) /* start or part of bundle */
121  #define HTC_FLAGS_SEQ_CHECK          (1 << 2) /* seq check on rx side */
122  #define HTC_FLAGS_CRC_CHECK          (1 << 3) /* CRC check on rx side */
123  /* HTC_FLAGS_PADDING_CHECK
124   * Set by the sender to inform the receiver that the HTC packet begins
125   * with continuation (block) alignment padding from the prior HTC packet.
126   */
127  #define HTC_FLAGS_PADDING_CHECK      (1 << 4)
128      /* receive direction */
129  #define HTC_FLAGS_RECV_1MORE_BLOCK   (1 << 0) /* bit 0 bundle trailer present */
130  #define HTC_FLAGS_RECV_TRAILER       (1 << 1) /* bit 1 trailer data present */
131  #define HTC_FLAGS_RECV_BUNDLE_CNT_MASK   (0xFC)    /* bits 7..2  */
132  #define HTC_FLAGS_RECV_BUNDLE_CNT_SHIFT  2
133  /*
134   * To be compatible with an older definition of a smaller (4-bit)
135   * bundle count field, the bundle count is stored in a segmented
136   * format - the 4 LSbs of the bundle count value are stored in bits 5:2
137   * of the BUNDLE_CNT field, which is bits 7:4 of the HTC_FLAGS word;
138   * the next 2 bits of the bundle count value are stored in bits 1:0 of
139   * the BUNDLE_CNT field, which is bits 3:2 of the HTC_FLAGS word.
140   */
141  #define HTC_FLAGS_RECV_BUNDLE_CNT_SET(x)  \
142    ((((x) << 2) | ((x) >> 4)) << HTC_FLAGS_RECV_BUNDLE_CNT_SHIFT)
143  #define HTC_FLAGS_RECV_BUNDLE_CNT_GET(x)  \
144    ((((x) & HTC_FLAGS_RECV_BUNDLE_CNT_MASK) >> (HTC_FLAGS_RECV_BUNDLE_CNT_SHIFT + 2)) | \
145    ((((x) >> HTC_FLAGS_RECV_BUNDLE_CNT_SHIFT) & 0x3) << 4))
146  
147  #define HTC_HDR_LENGTH  (sizeof(HTC_FRAME_HDR))
148  #define HTC_HDR_ALIGNMENT_PADDING           \
149      (((sizeof(HTC_FRAME_HDR) + 3) & (~0x3)) - sizeof(HTC_FRAME_HDR))
150  #define HTC_MAX_TRAILER_LENGTH   255
151  #define HTC_MAX_PAYLOAD_LENGTH   (4096 - sizeof(HTC_FRAME_HDR))
152  
153  /* HTC control message IDs */
154  
155  #define HTC_MSG_READY_ID                    1
156  #define HTC_MSG_CONNECT_SERVICE_ID          2
157  #define HTC_MSG_CONNECT_SERVICE_RESPONSE_ID 3
158  #define HTC_MSG_SETUP_COMPLETE_ID           4
159  #define HTC_MSG_SETUP_COMPLETE_EX_ID        5
160  #define HTC_MSG_SEND_SUSPEND_COMPLETE       6
161  #define HTC_MSG_NACK_SUSPEND                7
162  #define HTC_MSG_WAKEUP_FROM_SUSPEND_ID      8
163  
164  #define HTC_MAX_CONTROL_MESSAGE_LENGTH  256
165  
166  /* base message ID header */
167  typedef PREPACK struct {
168      A_UINT32 MessageID: 16,
169               MetaData:   8,
170               reserved:   8;
171  } POSTPACK HTC_UNKNOWN_MSG;
172  
173  #define HTC_UNKNOWN_MSG_MESSAGEID_LSB                 0
174  #define HTC_UNKNOWN_MSG_MESSAGEID_MASK                0x0000ffff
175  #define HTC_UNKNOWN_MSG_MESSAGEID_OFFSET              0x00000000
176  #define HTC_UNKNOWN_MSG_METADATA_LSB                  16
177  #define HTC_UNKNOWN_MSG_METADATA_MASK                 0X00ff0000
178  #define HTC_UNKNOWN_MSG_METADATA_OFFSET               0x00000000
179  
180  /* HTC ready message
181   * direction : target-to-host  */
182  typedef PREPACK struct {
183      A_UINT32  MessageID : 16, /* ID */
184                CreditCount: 16;  /* number of credits the target can offer */
185      A_UINT32  CreditSize : 16,   /* size of each credit */
186                MaxEndpoints : 8, /* maximum number of endpoints the target has resources for */
187                _Pad1 : 8;
188  } POSTPACK HTC_READY_MSG;
189  
190  #define HTC_READY_MSG_MESSAGEID_LSB                   0
191  #define HTC_READY_MSG_MESSAGEID_MASK                  0x0000ffff
192  #define HTC_READY_MSG_MESSAGEID_OFFSET                0x00000000
193  #define HTC_READY_MSG_CREDITCOUNT_LSB                 16
194  #define HTC_READY_MSG_CREDITCOUNT_MASK                0xffff0000
195  #define HTC_READY_MSG_CREDITCOUNT_OFFSET              0x00000000
196  #define HTC_READY_MSG_CREDITSIZE_LSB                  0
197  #define HTC_READY_MSG_CREDITSIZE_MASK                 0x0000ffff
198  #define HTC_READY_MSG_CREDITSIZE_OFFSET               0x00000004
199  #define HTC_READY_MSG_MAXENDPOINTS_LSB                16
200  #define HTC_READY_MSG_MAXENDPOINTS_MASK               0x00ff0000
201  #define HTC_READY_MSG_MAXENDPOINTS_OFFSET             0x00000004
202  
203      /* extended HTC ready message */
204  typedef PREPACK struct {
205      HTC_READY_MSG   Version2_0_Info;   /* legacy version 2.0 information at the front... */
206      /* extended information */
207      A_UINT32        HTCVersion : 8,
208                      MaxMsgsPerHTCBundle : 8, /* used in SDIO systems */
209                      AltDataCreditSize : 12,  /* used in HL (SDIO/USB) systems */
210                      reserved : 4;
211  } POSTPACK HTC_READY_EX_MSG;
212  
213  #define HTC_READY_EX_MSG_HTCVERSION_LSB               0
214  #define HTC_READY_EX_MSG_HTCVERSION_MASK              0x000000ff
215  #define HTC_READY_EX_MSG_HTCVERSION_OFFSET            sizeof(HTC_READY_MSG)
216  #define HTC_READY_EX_MSG_MAXMSGSPERHTCBUNDLE_LSB      8
217  #define HTC_READY_EX_MSG_MAXMSGSPERHTCBUNDLE_MASK     0x0000ff00
218  #define HTC_READY_EX_MSG_MAXMSGSPERHTCBUNDLE_OFFSET   sizeof(HTC_READY_MSG)
219  
220  #define HTC_VERSION_2P0  0x00
221  #define HTC_VERSION_2P1  0x01  /* HTC 2.1 */
222  
223  #define HTC_SERVICE_META_DATA_MAX_LENGTH 128
224  
225  /* connect service
226   * direction : host-to-target */
227  typedef PREPACK struct {
228      A_UINT32  MessageID : 16,
229                ServiceID : 16;           /* service ID of the service to connect to */
230      A_UINT32  ConnectionFlags : 16,     /* connection flags */
231  
232  #define HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE (1 << 2)  /* reduce credit dribbling when
233                                                               the host needs credits */
234  #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK             (0x3)
235  #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_FOURTH        0x0
236  #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_HALF          0x1
237  #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_THREE_FOURTHS     0x2
238  #define HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_UNITY             0x3
239      /* disable credit flow control on a specific service */
240  #define HTC_CONNECT_FLAGS_DISABLE_CREDIT_FLOW_CTRL          (1 << 3)
241      /* enable htc schedule on a specific service */
242  #define HTC_CONNECT_FLAGS_ENABLE_HTC_SCHEDULE          (1 << 4)
243  
244                ServiceMetaLength : 8,   /* length of meta data that follows */
245                LookAheadV2 : 1, /* 1 if host supports HTC_LOOKAHEAD_REPORT_V2 */
246                _Pad1 : 7;
247  
248      /* service-specific meta data starts after the header */
249  
250  } POSTPACK HTC_CONNECT_SERVICE_MSG;
251  
252  #define HTC_CONNECT_SERVICE_MSG_MESSAGEID_LSB             0
253  #define HTC_CONNECT_SERVICE_MSG_MESSAGEID_MASK            0x0000ffff
254  #define HTC_CONNECT_SERVICE_MSG_MESSAGEID_OFFSET          0x00000000
255  #define HTC_CONNECT_SERVICE_MSG_SERVICE_ID_LSB            16
256  #define HTC_CONNECT_SERVICE_MSG_SERVICE_ID_MASK           0xffff0000
257  #define HTC_CONNECT_SERVICE_MSG_SERVICE_ID_OFFSET         0x00000000
258  #define HTC_CONNECT_SERVICE_MSG_CONNECTIONFLAGS_LSB       0
259  #define HTC_CONNECT_SERVICE_MSG_CONNECTIONFLAGS_MASK      0x0000ffff
260  #define HTC_CONNECT_SERVICE_MSG_CONNECTIONFLAGS_OFFSET    0x00000004
261  #define HTC_CONNECT_SERVICE_MSG_SERVICEMETALENGTH_LSB     16
262  #define HTC_CONNECT_SERVICE_MSG_SERVICEMETALENGTH_MASK    0x00ff0000
263  #define HTC_CONNECT_SERVICE_MSG_SERVICEMETALENGTH_OFFSET  0x00000004
264  
265  #define HTC_SET_RECV_ALLOC_SHIFT    8
266  #define HTC_SET_RECV_ALLOC_MASK     0xFF00
267  #define HTC_CONNECT_FLAGS_SET_RECV_ALLOCATION(value) (((A_UINT8)value) << HTC_SET_RECV_ALLOC_SHIFT)
268  #define HTC_CONNECT_FLAGS_GET_RECV_ALLOCATION(value) (A_UINT8)(((value) & HTC_SET_RECV_ALLOC_MASK) >> HTC_SET_RECV_ALLOC_SHIFT)
269  
270  /* connect response
271   * direction : target-to-host */
272  typedef PREPACK struct {
273      A_UINT32  MessageID : 16,
274                ServiceID : 16;       /* service ID that the connection request was made */
275      A_UINT32  Status : 8,           /* service connection status */
276                EndpointID : 8,       /* assigned endpoint ID */
277                MaxMsgSize : 16;      /* maximum expected message size on this endpoint */
278      A_UINT32  ServiceMetaLength : 8,    /* length of meta data that follows */
279                LookAheadV2 : 1,/* 1 if target supports HTC_LOOKAHEAD_REPORT_V2 */
280                _Pad1 : 7,
281                reserved : 16;
282  
283      /* service-specific meta data starts after the header */
284  
285  } POSTPACK HTC_CONNECT_SERVICE_RESPONSE_MSG;
286  
287  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_MESSAGEID_LSB            0
288  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_MESSAGEID_MASK           0x0000ffff
289  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_MESSAGEID_OFFSET         0x00000000
290  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_SERVICEID_LSB            16
291  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_SERVICEID_MASK           0xffff0000
292  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_SERVICEID_OFFSET         0x00000000
293  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_STATUS_LSB               0
294  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_STATUS_MASK              0x000000ff
295  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_STATUS_OFFSET            0x00000004
296  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_ENDPOINTID_LSB           8
297  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_ENDPOINTID_MASK          0x0000ff00
298  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_ENDPOINTID_OFFSET        0x00000004
299  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_MAXMSGSIZE_LSB           16
300  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_MAXMSGSIZE_MASK          0xffff0000
301  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_MAXMSGSIZE_OFFSET        0x00000004
302  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_SERVICEMETALENGTH_LSB    0
303  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_SERVICEMETALENGTH_MASK   0x000000ff
304  #define HTC_CONNECT_SERVICE_RESPONSE_MSG_SERVICEMETALENGTH_OFFSET 0x00000008
305  
306  typedef PREPACK struct {
307      A_UINT32  MessageID : 16,
308                reserved : 16;
309      /* currently, no other fields */
310  } POSTPACK HTC_SETUP_COMPLETE_MSG;
311  
312  #define HTC_SETUP_COMPLETE_MSG_MESSAGEID_LSB          0
313  #define HTC_SETUP_COMPLETE_MSG_MESSAGEID_MASK         0x0000ffff
314  #define HTC_SETUP_COMPLETE_MSG_MESSAGEID_OFFSET       0x00000000
315  
316      /* extended setup completion message */
317  typedef PREPACK struct {
318      A_UINT32  MessageID : 16,
319                reserved : 16;
320      A_UINT32  SetupFlags : 32;
321      A_UINT32  MaxMsgsPerBundledRecv : 8,
322                Rsvd0 : 8,
323                Rsvd1 : 8,
324                Rsvd2 : 8;
325  } POSTPACK HTC_SETUP_COMPLETE_EX_MSG;
326  
327  #define HTC_SETUP_COMPLETE_EX_MSG_MESSAGEID_LSB               0
328  #define HTC_SETUP_COMPLETE_EX_MSG_MESSAGEID_MASK              0x0000ffff
329  #define HTC_SETUP_COMPLETE_EX_MSG_MESSAGEID_OFFSET            0x00000000
330  #define HTC_SETUP_COMPLETE_EX_MSG_SETUPFLAGS_LSB              0
331  #define HTC_SETUP_COMPLETE_EX_MSG_SETUPFLAGS_MASK             0xffffffff
332  #define HTC_SETUP_COMPLETE_EX_MSG_SETUPFLAGS_OFFSET           0x00000004
333  #define HTC_SETUP_COMPLETE_EX_MSG_MAXMSGSPERBUNDLEDRECV_LSB       0
334  #define HTC_SETUP_COMPLETE_EX_MSG_MAXMSGSPERBUNDLEDRECV_MASK      0x000000ff
335  #define HTC_SETUP_COMPLETE_EX_MSG_MAXMSGSPERBUNDLEDRECV_OFFSET    0x00000008
336  #define HTC_SETUP_COMPLETE_EX_MSG_RSVD0_LSB                   8
337  #define HTC_SETUP_COMPLETE_EX_MSG_RSVD0_MASK                  0x0000ff00
338  #define HTC_SETUP_COMPLETE_EX_MSG_RSVD0_OFFSET                0x00000008
339  #define HTC_SETUP_COMPLETE_EX_MSG_RSVD1_LSB                   16
340  #define HTC_SETUP_COMPLETE_EX_MSG_RSVD1_MASK                  0x00ff0000
341  #define HTC_SETUP_COMPLETE_EX_MSG_RSVD1_OFFSET                0x00000008
342  #define HTC_SETUP_COMPLETE_EX_MSG_RSVD2_LSB                   24
343  #define HTC_SETUP_COMPLETE_EX_MSG_RSVD2_MASK                  0xff000000
344  #define HTC_SETUP_COMPLETE_EX_MSG_RSVD2_OFFSET                0x00000008
345  
346  #define HTC_SETUP_COMPLETE_FLAGS_ENABLE_BUNDLE_RECV     (1 << 0)    /* enable recv bundling from target */
347  #define HTC_SETUP_COMPLETE_FLAGS_DISABLE_TX_CREDIT_FLOW (1 << 1)    /* disable credit based flow control,
348                                                                         only supported on some interconnects */
349  
350  /* connect response status codes */
351  #define HTC_SERVICE_SUCCESS      0  /* success */
352  #define HTC_SERVICE_NOT_FOUND    1  /* service could not be found */
353  #define HTC_SERVICE_FAILED       2  /* specific service failed the connect */
354  #define HTC_SERVICE_NO_RESOURCES 3  /* no resources (i.e. no more endpoints) */
355  #define HTC_SERVICE_NO_MORE_EP   4  /* specific service is not allowing any more
356                                         endpoints */
357  
358  /* report record IDs */
359  
360  #define HTC_RECORD_NULL             0
361  #define HTC_RECORD_CREDITS          1
362  #define HTC_RECORD_LOOKAHEAD        2
363  #define HTC_RECORD_LOOKAHEAD_BUNDLE 3
364  
365  typedef PREPACK struct {
366      A_UINT32 RecordID : 8, /* Record ID */
367               Length : 8,   /* Length of record */
368               reserved : 16;
369  } POSTPACK HTC_RECORD_HDR;
370  
371  #define HTC_RECORD_HDR_RECORDID_LSB           0
372  #define HTC_RECORD_HDR_RECORDID_MASK          0x000000ff
373  #define HTC_RECORD_HDR_RECORDID_OFFSET        0x00000000
374  #define HTC_RECORD_HDR_LENGTH_LSB             8
375  #define HTC_RECORD_HDR_LENGTH_MASK            0x0000ff00
376  #define HTC_RECORD_HDR_LENGTH_OFFSET          0x00000000
377  
378  typedef PREPACK struct {
379      A_UINT32 EndpointID : 8,     /* Endpoint that owns these credits */
380               Credits : 8,        /* credits to report since last report */
381               reserved : 16;
382  } POSTPACK HTC_CREDIT_REPORT;
383  
384  #define HTC_CREDIT_REPORT_ENDPOINTID_LSB      0
385  #define HTC_CREDIT_REPORT_ENDPOINTID_MASK     0x000000ff
386  #define HTC_CREDIT_REPORT_ENDPOINTID_OFFSET   0x00000000
387  #define HTC_CREDIT_REPORT_CREDITS_LSB         8
388  #define HTC_CREDIT_REPORT_CREDITS_MASK        0x0000ff00
389  #define HTC_CREDIT_REPORT_CREDITS_OFFSET      0x00000000
390  
391  typedef PREPACK struct {
392      A_UINT32 PreValid : 8,      /* pre valid guard */
393               reserved0 : 24;
394      A_UINT32 LookAhead0 : 8,    /* 4 byte lookahead */
395               LookAhead1 : 8,
396               LookAhead2 : 8,
397               LookAhead3 : 8;
398      A_UINT32 PostValid : 8,     /* post valid guard */
399               reserved1 : 24;
400  
401     /* NOTE: the LookAhead array is guarded by a PreValid and Post Valid guard bytes.
402      * The PreValid bytes must equal the inverse of the PostValid byte */
403  
404  } POSTPACK HTC_LOOKAHEAD_REPORT;
405  
406  /*
407   * If the host sets the HTC_CONNECT_SERVICE_MSG.LookAheadV2 flag and the
408   * target sets the HTC_CONNECT_SERVICE_RESPONSE_MSG.LookAheadV2 flag,
409   * HTC_LOOKAHEAD_REPORT_V2 is used; otherwise HTC_LOOKAHEAD_REPORT is used.
410   */
411  typedef PREPACK struct {
412      A_UINT32 PreValid : 8,   /* pre valid guard */
413          reserved0 : 24;
414      A_UINT32 LookAhead0 : 8,  /* 8 byte lookahead */
415          LookAhead1 : 8,
416          LookAhead2 : 8,
417          LookAhead3 : 8;
418      A_UINT32 LookAhead4 : 8,  /* 8 byte lookahead */
419          LookAhead5 : 8,
420          LookAhead6 : 8,
421          LookAhead7 : 8;
422      A_UINT32 PostValid : 8,   /* post valid guard */
423          reserved1 : 24;
424      /* NOTE: the LookAhead array is guarded by PreValid and Post Valid
425       * guard bytes.
426       * The PreValid byte must equal the inverse of the PostValid byte.
427       */
428  } POSTPACK HTC_LOOKAHEAD_REPORT_V2;
429  
430  #define HTC_LOOKAHEAD_REPORT_PREVALID_LSB         0
431  #define HTC_LOOKAHEAD_REPORT_PREVALID_MASK        0x000000ff
432  #define HTC_LOOKAHEAD_REPORT_PREVALID_OFFSET      0x00000000
433  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD0_LSB       0
434  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD0_MASK      0x000000ff
435  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD0_OFFSET    0x00000004
436  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD1_LSB       8
437  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD1_MASK      0x0000ff00
438  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD1_OFFSET    0x00000004
439  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD2_LSB       16
440  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD2_MASK      0x00ff0000
441  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD2_OFFSET    0x00000004
442  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD3_LSB       24
443  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD3_MASK      0xff000000
444  #define HTC_LOOKAHEAD_REPORT_LOOKAHEAD3_OFFSET    0x00000004
445  #define HTC_LOOKAHEAD_REPORT_POSTVALID_LSB        0
446  #define HTC_LOOKAHEAD_REPORT_POSTVALID_MASK       0x000000ff
447  #define HTC_LOOKAHEAD_REPORT_POSTVALID_OFFSET     0x00000008
448  
449  typedef PREPACK struct {
450      A_UINT32 LookAhead0 : 8,    /* 4 byte lookahead */
451               LookAhead1 : 8,
452               LookAhead2 : 8,
453               LookAhead3 : 8;
454  } POSTPACK HTC_BUNDLED_LOOKAHEAD_REPORT;
455  
456  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD0_LSB           0
457  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD0_MASK          0x000000ff
458  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD0_OFFSET        0x00000000
459  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD1_LSB           8
460  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD1_MASK          0x0000ff00
461  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD1_OFFSET        0x00000000
462  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD2_LSB           16
463  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD2_MASK          0x00ff0000
464  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD2_OFFSET        0x00000000
465  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD3_LSB           24
466  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD3_MASK          0xff000000
467  #define HTC_BUNDLED_LOOKAHEAD_REPORT_LOOKAHEAD3_OFFSET        0x00000000
468  
469  #ifndef ATH_TARGET
470  #include "athendpack.h"
471  #endif
472  
473  
474  #endif /* __HTC_H__ */
475  
476