PageRenderTime 55ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/hal/FirmwareApi/public_descriptors.h

https://bitbucket.org/cyanogenmod/cm-kernel
C Header | 384 lines | 129 code | 70 blank | 185 comment | 0 complexity | 1c648c11032950abc2202770f45001db MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
  5. **| All rights reserved. |**
  6. **| |**
  7. **| Redistribution and use in source and binary forms, with or without |**
  8. **| modification, are permitted provided that the following conditions |**
  9. **| are met: |**
  10. **| |**
  11. **| * Redistributions of source code must retain the above copyright |**
  12. **| notice, this list of conditions and the following disclaimer. |**
  13. **| * Redistributions in binary form must reproduce the above copyright |**
  14. **| notice, this list of conditions and the following disclaimer in |**
  15. **| the documentation and/or other materials provided with the |**
  16. **| distribution. |**
  17. **| * Neither the name Texas Instruments nor the names of its |**
  18. **| contributors may be used to endorse or promote products derived |**
  19. **| from this software without specific prior written permission. |**
  20. **| |**
  21. **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
  22. **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
  23. **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
  24. **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
  25. **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
  26. **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
  27. **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
  28. **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
  29. **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
  30. **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
  31. **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
  32. **| |**
  33. **+-----------------------------------------------------------------------+**
  34. ****************************************************************************/
  35. #ifndef PUBLIC_DESCRIPTORS_H
  36. #define PUBLIC_DESCRIPTORS_H
  37. #include "public_types.h"
  38. /******************************************************************************
  39. TX PATH
  40. The Tx path uses a double buffer and a TxControl structure, each located at a
  41. fixed address in the device's memory. On startup, the host retrieves the pointers
  42. to these addresses. A double buffer allows for continuous data flow towards the
  43. device. The host keeps track of which buffer is available and alternates between
  44. these two buffers on a per packet basis.
  45. The size of each of the two buffers is large enough to hold the longest 802.3
  46. packet - maximum size Ethernet packet + header + descriptor.
  47. TX complete indication will be received a-synchronously in a TX done cyclic buffer
  48. (txDoneRing) which is composed of 16 Tx Result Descriptors structures
  49. and is used in a cyclic manner. refer to TxResultDescriptor_t structure.
  50. The TX (HOST) procedure is as follows:
  51. 1. Read the Tx path status (DataOutCount in TxPathStatus).
  52. 2. goto 1, if not possible.
  53. i.e. if DataInCount - DataOutCount >= HwBuffer size (2 for double buffer)).
  54. 3. Copy the packet (preceded by TxDescriptor), if possible.
  55. i.e. if DataInCount - DataOutCount < HwBuffer size (2 for double buffer).
  56. 4. increment DataInCount.
  57. 5. Inform the firmware by generating a firmware internal interrupt.
  58. 6. FW will increment DataOutCount after it reads the buffer.
  59. The TX Complete procedure:
  60. 1. To get a TX complete indication the host enables the Tx Complete flag in the
  61. TX Descriptor Structure (Refer to the Ctrl field in TxDescriptor_t).
  62. 2. For each packet with a Tx Complete field set, the firmware adds the transmit
  63. results to the cyclic buffer (txDoneRing) and sets both done1and done2 to 1 to
  64. indicate driver ownership.
  65. 3. The firmware sends a Tx Complete interrupt to the host to trigger the host to
  66. process the new data. Note: interrupt will be send per packet if TX complete
  67. indication was requested in TxDescriptor_t (see 1.) or per crossing Aggregation
  68. threashold.
  69. 4. After receiving the Tx Complete interrupt, the host reads the TxDescriptorDone
  70. information in a cyclic manner and clears both done1 and done2 fields.
  71. ******************************************************************************/
  72. /******************************************************************************
  73. TxDescriptor_t
  74. the structure of the transmit Tx descriptor passed from the host, ahead of
  75. the transmitted packet.
  76. ******************************************************************************/
  77. /* Because we are using a bit map, It is safer to enable the exact bits instead of field assignment */
  78. /* It is IMPORTENT to check that the bit defenitions are alligned to the bit map struct */
  79. #define TX_COMPLETE_REQUIRED_BIT 0x80
  80. /* TX attribute fields (txAttr of TxDesriptor structure)*/
  81. /* ******************************************************/
  82. typedef struct
  83. {
  84. unsigned ratePolicy :3; /* Rate Policy (class) index */
  85. unsigned ackPolicy :1; /* When set, no ack policy is expected*/
  86. unsigned pktType :2; /* packet type: */
  87. /* 0 - 802.11, */
  88. /* 1 - 802.3,*/
  89. /* 2 - IP, */
  90. /* 3 - raw codec */
  91. unsigned qosFrame :1; /* If set, this is QoS-Null or QoS-Data*/
  92. unsigned txCmpltRequired :1; /* If set, the FW should trigger the TxComplete*/
  93. /* interrupt for this packet*/
  94. unsigned xferPadding :1; /* If set, there is 2 bytes padding before */
  95. /* packet header*/
  96. unsigned reserved :7; /* padding*/
  97. } TxDescCtrl_t;
  98. #ifdef HOST_COMPILE
  99. typedef uint16 TxAttr_t;
  100. #else
  101. typedef TxDescCtrl_t TxAttr_t;
  102. #endif
  103. /**************************************/
  104. /* Double Buffer Descriptor Fields */
  105. /**************************************/
  106. #define DoubleBufferDesc uint16 length; /* Length of payload, including headers. */ \
  107. TxdRateSet_t rate; /* A bit mask that specifies the initial rate to be */ \
  108. /* used. Possible values are: */ \
  109. /* 0x0001 - 1Mbits */ \
  110. /* 0x0002 - 2Mbits */ \
  111. /* 0x0004 - 5.5Mbits */ \
  112. /* 0x0008 - 6Mbits */ \
  113. /* 0x0010 - 9Mbits */ \
  114. /* 0x0020 - 11Mbits */ \
  115. /* 0x0040 - 12Mbits */ \
  116. /* 0x0080 - 18Mbits */ \
  117. /* 0x0100 - 22Mbits */ \
  118. /* 0x0200 - 24Mbits */ \
  119. /* 0x0400 - 36Mbits */ \
  120. /* 0x0800 - 48Mbits */ \
  121. /* 0x1000 - 54Mbits */ \
  122. uint32 expiryTime; /* Time (in us) the packet can stay in the device */ \
  123. /* before the packet expires. */ \
  124. uint8 xmitQueue; /* The index of the Tx queue used for this packet. */ \
  125. uint8 descID; /* Identifier of the packet. This ID is used by the */ \
  126. /* host for identifying the Tx Result of packet. */ \
  127. TxAttr_t txAttr; /* Bitwise fields - see TxDescCtrl_tdefinition above */ \
  128. uint16 fragThreshold; /* The FW should cut the packet to fragments by */ \
  129. /* this size. */ \
  130. uint8 numMemBlks; /* Number of HW queue blocks to allocate for this */ \
  131. /* packet. */ \
  132. uint8 reserved; /* for padding to 32 bits boundry. */ \
  133. typedef struct
  134. {
  135. DoubleBufferDesc
  136. }DbTescriptor;
  137. /******************************************************************************
  138. TxResultDescriptor_t
  139. the structure of the Tx result retrieved from FW upon TX completion.
  140. ******************************************************************************/
  141. typedef enum
  142. {
  143. TX_SUCCESS = 0,
  144. TX_DMA_ERROR = BIT_7,
  145. TX_DISABLED = BIT_6,
  146. TX_RETRY_EXCEEDED = BIT_5,
  147. TX_TIMEOUT = BIT_4,
  148. TX_KEY_NOT_FOUND = BIT_3,
  149. TX_ENCRYPT_FAIL = BIT_2,
  150. TX_UNAVAILABLE_PRIORITY = BIT_1
  151. } TxDescStatus_enum;
  152. #ifdef HOST_COMPILE
  153. typedef uint8 TxDescStatus_e;
  154. #else
  155. typedef TxDescStatus_enum TxDescStatus_e;
  156. #endif
  157. typedef struct
  158. {
  159. uint8 done1; /* Ownership synchronization between the host and */
  160. /* the firmware. If done1 and done2 are cleared, */
  161. /* owned by the FW (no info ready). */
  162. uint8 descID; /* Packet Identifier - same value used in the Tx */
  163. /* descriptor.*/
  164. uint16 mediumUsage; /* Total air access duration consumed by this */
  165. /* packet, including all retrys and overheads.*/
  166. uint32 mediumDelay; /* Total media delay (from 1st EDCA AIFS counter until TX Complete). */
  167. uint32 fwHandlingTime; /* The time passed from host xfer to Tx-complete.*/
  168. uint8 lsbSecuritySequenceNumber; /* The LS-byte of the last TKIP sequence number. */
  169. /* Saved per queue for recovery.*/
  170. uint8 ackFailures; /* Retry count - The number of transmissions */
  171. /* without successful ACK reception.*/
  172. TxdRateSet_t actualRate; /* The rate that succeeded getting ACK - */
  173. /* Valid only if status=TX_SUCCESS.*/
  174. uint16 reserved;
  175. TxDescStatus_e status; /* The status of the transmission, indicating */
  176. /* success or one of several possible reasons for */
  177. /* failure. Refer to TxDescStatus_enum, above.*/
  178. uint8 done2; /* Refer to done1.*/
  179. } TxResultDescriptor_t;
  180. /******************************************************************************
  181. RX PATH
  182. The Rx path uses a double buffer and an RxControl structure, each located at
  183. a fixed address in the device memory. On startup, the host retrieves the
  184. pointers to these addresses. A double buffer allows for continuous data flow
  185. towards the device. The host keeps track of which buffer is available and
  186. alternates between them on a per packet basis.
  187. The size of each of the two buffers is large enough to hold the longest 802.3
  188. packet.
  189. A dedicated control block is used to manage the flow control between the host
  190. and the device. The procedure is interrupt driven.
  191. The RX procedure is as follows:
  192. 1. The device generates an interrupt each time a new packet is received and
  193. the corresponding interrupt is enabled in the host. There are two different
  194. interrupt sources, one for each buffer. It is possible that both interrupt
  195. sources are set when both buffers in the double buffer are pending with Rx
  196. data.
  197. 2. Depending on flow control conditions, the host reads a packet from the
  198. appropriate buffer in the double buffer.
  199. 3. The host triggers an interrupt in the device (using the HW mechanism of EOT),
  200. indicating the address of the buffer which has been read.
  201. 4. The device services the complete interrupt and prepares the next Rx packet,
  202. if available. In addition, the device updates the control block and issues
  203. an interrupt to the host.
  204. ******************************************************************************/
  205. /******************************************************************************
  206. RxPathStatusReg_t
  207. The structure of the Rx Path Status register. This status register
  208. represents both the status of the double-buffer (xfer protocol) and the
  209. number of the pending packet in receive queue.
  210. ******************************************************************************/
  211. #ifdef HOST_COMPILE
  212. #define RX_DESC_VALID_FCS 0x0001
  213. #define RX_DESC_MATCH_RXADDR1 0x0002
  214. #define RX_DESC_MCAST 0x0004
  215. #define RX_DESC_STAINTIM 0x0008
  216. #define RX_DESC_VIRTUAL_BM 0x0010
  217. #define RX_DESC_BCAST 0x0020
  218. #define RX_DESC_MATCH_SSID 0x0040
  219. #define RX_DESC_MATCH_BSSID 0x0080
  220. #define RX_DESC_ENCRYPTION_MASK 0x0300
  221. #define RX_DESC_MEASURMENT 0x0400
  222. #define RX_DESC_SEQNUM_MASK 0x1800
  223. #define RX_DESC_MIC_FAIL 0x2000
  224. #define RX_DESC_DECRYPT_FAIL 0x4000
  225. typedef uint16 RxFlags_t;
  226. #else
  227. typedef struct
  228. {
  229. unsigned validFcs : 1; /* Indicates whether a received frame had a valid FCS*/
  230. unsigned matchRxAddr1 : 1; /* Indicates whether a received frame contained a */
  231. /* matching receive address in Address 1.*/
  232. unsigned mcast : 1; /* Indicates whether a received frame contains a */
  233. /* unicast/directed or group receive address, bit 40*/
  234. /* of Addr1 (0 = individual, 1 = group).*/
  235. unsigned StaInTIM : 1; /* Indicates that the TIM in a Beacon frame contained*/
  236. /* a 1 in the bit position representing this STA */
  237. /* (i.e. the AP contains one or more buffered frame(s)*/
  238. /* for this STA).*/
  239. unsigned virtualBM : 1; /* If asserted, the VBM in a Beacon frame contained */
  240. /* more than 1 asserted bit*/
  241. unsigned bcast : 1; /* Indicates whether the received frame’s address 1 */
  242. /* is a broadcast address.*/
  243. unsigned matchSSID : 1; /* Indicates whether the received frame containing */
  244. /* a matching SSID (either broadcast or specific).*/
  245. unsigned matchBSSID : 1; /* Indicates whether the received frame containing */
  246. /* a matching BSSID (either broadcast or specific).*/
  247. unsigned encryption : 2; /* This field indicates the encryption type of the */
  248. /* packet: 00 - None, 01 - WEP, 10 - TKIP, 11 - AES*/
  249. unsigned measurement : 1; /* Indicates whether the packet was received during */
  250. /* measurement process or not*/
  251. unsigned seqnum : 2; /* Sequence number of the current frame*/
  252. unsigned micFail : 1; /* MIC Fail indication */
  253. unsigned decryptFail : 1; /* DECRYPT Fail indication */
  254. unsigned reserved2 : 1;
  255. } RxFlags_t;
  256. #endif
  257. /******************************************************************************
  258. RxIfDescriptor_t
  259. the structure of the Rx Descriptor recieved by HOST.
  260. ******************************************************************************/
  261. typedef struct
  262. {
  263. uint32 timestamp; /* Timestamp in microseconds, */
  264. uint16 length; /* Length of payload (including headers)*/
  265. RxFlags_t flags; /* See RxFlags_t for details. */
  266. uint8 type; /* Protocol type: */
  267. /* 0 - 802.11*/
  268. /* 1 - 802.3*/
  269. /* 2 - IP*/
  270. /* 3 - Raw Codec*/
  271. uint8 rate; /* Recevied Rate:*/
  272. /* 0x0A - 1MBPS*/
  273. /* 0x14 - 2MBPS */
  274. /* 0x37 - 5_5MBPS */
  275. /* 0x0B - 6MBPS */
  276. /* 0x0F - 9MBPS */
  277. /* 0x6E - 11MBPS */
  278. /* 0x0A - 12MBPS */
  279. /* 0x0E - 18MBPS */
  280. /* 0xDC - 22MBPS */
  281. /* 0x09 - 24MBPS */
  282. /* 0x0D - 36MBPS */
  283. /* 0x08 - 48MBPS */
  284. /* 0x0C - 54MBPS */
  285. uint8 modPre; /* Modulation and Preamble of received packet*/
  286. uint8 chanNum; /* The received channel*/
  287. uint8 band; /* 0 - 2.4Ghz*/
  288. /* 1 - 5Ghz*/
  289. int8 rssi; /* RSSI value in db */
  290. uint8 rcpi; /* RCPI value in db */
  291. uint8 snr; /* SNR in db*/
  292. } RxIfDescriptor_t;
  293. #endif /* PUBLIC_DESCRIPTORS_H*/