htt.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337
  1. /*
  2. * Copyright (c) 2005-2011 Atheros Communications Inc.
  3. * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef _HTT_H_
  18. #define _HTT_H_
  19. #include <linux/bug.h>
  20. #include "htc.h"
  21. #include "rx_desc.h"
  22. #define HTT_CURRENT_VERSION_MAJOR 2
  23. #define HTT_CURRENT_VERSION_MINOR 1
  24. enum htt_dbg_stats_type {
  25. HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0,
  26. HTT_DBG_STATS_RX_REORDER = 1 << 1,
  27. HTT_DBG_STATS_RX_RATE_INFO = 1 << 2,
  28. HTT_DBG_STATS_TX_PPDU_LOG = 1 << 3,
  29. HTT_DBG_STATS_TX_RATE_INFO = 1 << 4,
  30. /* bits 5-23 currently reserved */
  31. HTT_DBG_NUM_STATS /* keep this last */
  32. };
  33. enum htt_h2t_msg_type { /* host-to-target */
  34. HTT_H2T_MSG_TYPE_VERSION_REQ = 0,
  35. HTT_H2T_MSG_TYPE_TX_FRM = 1,
  36. HTT_H2T_MSG_TYPE_RX_RING_CFG = 2,
  37. HTT_H2T_MSG_TYPE_STATS_REQ = 3,
  38. HTT_H2T_MSG_TYPE_SYNC = 4,
  39. HTT_H2T_MSG_TYPE_AGGR_CFG = 5,
  40. HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG = 6,
  41. HTT_H2T_MSG_TYPE_MGMT_TX = 7,
  42. HTT_H2T_NUM_MSGS /* keep this last */
  43. };
  44. struct htt_cmd_hdr {
  45. u8 msg_type;
  46. } __packed;
  47. struct htt_ver_req {
  48. u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
  49. } __packed;
  50. /*
  51. * HTT tx MSDU descriptor
  52. *
  53. * The HTT tx MSDU descriptor is created by the host HTT SW for each
  54. * tx MSDU. The HTT tx MSDU descriptor contains the information that
  55. * the target firmware needs for the FW's tx processing, particularly
  56. * for creating the HW msdu descriptor.
  57. * The same HTT tx descriptor is used for HL and LL systems, though
  58. * a few fields within the tx descriptor are used only by LL or
  59. * only by HL.
  60. * The HTT tx descriptor is defined in two manners: by a struct with
  61. * bitfields, and by a series of [dword offset, bit mask, bit shift]
  62. * definitions.
  63. * The target should use the struct def, for simplicitly and clarity,
  64. * but the host shall use the bit-mast + bit-shift defs, to be endian-
  65. * neutral. Specifically, the host shall use the get/set macros built
  66. * around the mask + shift defs.
  67. */
  68. struct htt_data_tx_desc_frag {
  69. __le32 paddr;
  70. __le32 len;
  71. } __packed;
  72. enum htt_data_tx_desc_flags0 {
  73. HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT = 1 << 0,
  74. HTT_DATA_TX_DESC_FLAGS0_NO_AGGR = 1 << 1,
  75. HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT = 1 << 2,
  76. HTT_DATA_TX_DESC_FLAGS0_NO_CLASSIFY = 1 << 3,
  77. HTT_DATA_TX_DESC_FLAGS0_RSVD0 = 1 << 4
  78. #define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_MASK 0xE0
  79. #define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_LSB 5
  80. };
  81. enum htt_data_tx_desc_flags1 {
  82. #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_BITS 6
  83. #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_MASK 0x003F
  84. #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_LSB 0
  85. #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_BITS 5
  86. #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_MASK 0x07C0
  87. #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_LSB 6
  88. HTT_DATA_TX_DESC_FLAGS1_POSTPONED = 1 << 11,
  89. HTT_DATA_TX_DESC_FLAGS1_MORE_IN_BATCH = 1 << 12,
  90. HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD = 1 << 13,
  91. HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD = 1 << 14,
  92. HTT_DATA_TX_DESC_FLAGS1_RSVD1 = 1 << 15
  93. };
  94. enum htt_data_tx_ext_tid {
  95. HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST = 16,
  96. HTT_DATA_TX_EXT_TID_MGMT = 17,
  97. HTT_DATA_TX_EXT_TID_INVALID = 31
  98. };
  99. #define HTT_INVALID_PEERID 0xFFFF
  100. /*
  101. * htt_data_tx_desc - used for data tx path
  102. *
  103. * Note: vdev_id irrelevant for pkt_type == raw and no_classify == 1.
  104. * ext_tid: for qos-data frames (0-15), see %HTT_DATA_TX_EXT_TID_
  105. * for special kinds of tids
  106. * postponed: only for HL hosts. indicates if this is a resend
  107. * (HL hosts manage queues on the host )
  108. * more_in_batch: only for HL hosts. indicates if more packets are
  109. * pending. this allows target to wait and aggregate
  110. */
  111. struct htt_data_tx_desc {
  112. u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */
  113. __le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */
  114. __le16 len;
  115. __le16 id;
  116. __le32 frags_paddr;
  117. __le32 peerid;
  118. u8 prefetch[0]; /* start of frame, for FW classification engine */
  119. } __packed;
  120. enum htt_rx_ring_flags {
  121. HTT_RX_RING_FLAGS_MAC80211_HDR = 1 << 0,
  122. HTT_RX_RING_FLAGS_MSDU_PAYLOAD = 1 << 1,
  123. HTT_RX_RING_FLAGS_PPDU_START = 1 << 2,
  124. HTT_RX_RING_FLAGS_PPDU_END = 1 << 3,
  125. HTT_RX_RING_FLAGS_MPDU_START = 1 << 4,
  126. HTT_RX_RING_FLAGS_MPDU_END = 1 << 5,
  127. HTT_RX_RING_FLAGS_MSDU_START = 1 << 6,
  128. HTT_RX_RING_FLAGS_MSDU_END = 1 << 7,
  129. HTT_RX_RING_FLAGS_RX_ATTENTION = 1 << 8,
  130. HTT_RX_RING_FLAGS_FRAG_INFO = 1 << 9,
  131. HTT_RX_RING_FLAGS_UNICAST_RX = 1 << 10,
  132. HTT_RX_RING_FLAGS_MULTICAST_RX = 1 << 11,
  133. HTT_RX_RING_FLAGS_CTRL_RX = 1 << 12,
  134. HTT_RX_RING_FLAGS_MGMT_RX = 1 << 13,
  135. HTT_RX_RING_FLAGS_NULL_RX = 1 << 14,
  136. HTT_RX_RING_FLAGS_PHY_DATA_RX = 1 << 15
  137. };
  138. struct htt_rx_ring_setup_ring {
  139. __le32 fw_idx_shadow_reg_paddr;
  140. __le32 rx_ring_base_paddr;
  141. __le16 rx_ring_len; /* in 4-byte words */
  142. __le16 rx_ring_bufsize; /* rx skb size - in bytes */
  143. __le16 flags; /* %HTT_RX_RING_FLAGS_ */
  144. __le16 fw_idx_init_val;
  145. /* the following offsets are in 4-byte units */
  146. __le16 mac80211_hdr_offset;
  147. __le16 msdu_payload_offset;
  148. __le16 ppdu_start_offset;
  149. __le16 ppdu_end_offset;
  150. __le16 mpdu_start_offset;
  151. __le16 mpdu_end_offset;
  152. __le16 msdu_start_offset;
  153. __le16 msdu_end_offset;
  154. __le16 rx_attention_offset;
  155. __le16 frag_info_offset;
  156. } __packed;
  157. struct htt_rx_ring_setup_hdr {
  158. u8 num_rings; /* supported values: 1, 2 */
  159. __le16 rsvd0;
  160. } __packed;
  161. struct htt_rx_ring_setup {
  162. struct htt_rx_ring_setup_hdr hdr;
  163. struct htt_rx_ring_setup_ring rings[0];
  164. } __packed;
  165. /*
  166. * htt_stats_req - request target to send specified statistics
  167. *
  168. * @msg_type: hardcoded %HTT_H2T_MSG_TYPE_STATS_REQ
  169. * @upload_types: see %htt_dbg_stats_type. this is 24bit field actually
  170. * so make sure its little-endian.
  171. * @reset_types: see %htt_dbg_stats_type. this is 24bit field actually
  172. * so make sure its little-endian.
  173. * @cfg_val: stat_type specific configuration
  174. * @stat_type: see %htt_dbg_stats_type
  175. * @cookie_lsb: used for confirmation message from target->host
  176. * @cookie_msb: ditto as %cookie
  177. */
  178. struct htt_stats_req {
  179. u8 upload_types[3];
  180. u8 rsvd0;
  181. u8 reset_types[3];
  182. struct {
  183. u8 mpdu_bytes;
  184. u8 mpdu_num_msdus;
  185. u8 msdu_bytes;
  186. } __packed;
  187. u8 stat_type;
  188. __le32 cookie_lsb;
  189. __le32 cookie_msb;
  190. } __packed;
  191. #define HTT_STATS_REQ_CFG_STAT_TYPE_INVALID 0xff
  192. /*
  193. * htt_oob_sync_req - request out-of-band sync
  194. *
  195. * The HTT SYNC tells the target to suspend processing of subsequent
  196. * HTT host-to-target messages until some other target agent locally
  197. * informs the target HTT FW that the current sync counter is equal to
  198. * or greater than (in a modulo sense) the sync counter specified in
  199. * the SYNC message.
  200. *
  201. * This allows other host-target components to synchronize their operation
  202. * with HTT, e.g. to ensure that tx frames don't get transmitted until a
  203. * security key has been downloaded to and activated by the target.
  204. * In the absence of any explicit synchronization counter value
  205. * specification, the target HTT FW will use zero as the default current
  206. * sync value.
  207. *
  208. * The HTT target FW will suspend its host->target message processing as long
  209. * as 0 < (in-band sync counter - out-of-band sync counter) & 0xff < 128.
  210. */
  211. struct htt_oob_sync_req {
  212. u8 sync_count;
  213. __le16 rsvd0;
  214. } __packed;
  215. #define HTT_AGGR_CONF_MAX_NUM_AMSDU_SUBFRAMES_MASK 0x1F
  216. #define HTT_AGGR_CONF_MAX_NUM_AMSDU_SUBFRAMES_LSB 0
  217. struct htt_aggr_conf {
  218. u8 max_num_ampdu_subframes;
  219. union {
  220. /* dont use bitfields; undefined behaviour */
  221. u8 flags; /* see %HTT_AGGR_CONF_MAX_NUM_AMSDU_SUBFRAMES_ */
  222. u8 max_num_amsdu_subframes:5;
  223. } __packed;
  224. } __packed;
  225. #define HTT_MGMT_FRM_HDR_DOWNLOAD_LEN 32
  226. struct htt_mgmt_tx_desc {
  227. u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
  228. __le32 msdu_paddr;
  229. __le32 desc_id;
  230. __le32 len;
  231. __le32 vdev_id;
  232. u8 hdr[HTT_MGMT_FRM_HDR_DOWNLOAD_LEN];
  233. } __packed;
  234. enum htt_mgmt_tx_status {
  235. HTT_MGMT_TX_STATUS_OK = 0,
  236. HTT_MGMT_TX_STATUS_RETRY = 1,
  237. HTT_MGMT_TX_STATUS_DROP = 2
  238. };
  239. /*=== target -> host messages ===============================================*/
  240. enum htt_t2h_msg_type {
  241. HTT_T2H_MSG_TYPE_VERSION_CONF = 0x0,
  242. HTT_T2H_MSG_TYPE_RX_IND = 0x1,
  243. HTT_T2H_MSG_TYPE_RX_FLUSH = 0x2,
  244. HTT_T2H_MSG_TYPE_PEER_MAP = 0x3,
  245. HTT_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
  246. HTT_T2H_MSG_TYPE_RX_ADDBA = 0x5,
  247. HTT_T2H_MSG_TYPE_RX_DELBA = 0x6,
  248. HTT_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
  249. HTT_T2H_MSG_TYPE_PKTLOG = 0x8,
  250. HTT_T2H_MSG_TYPE_STATS_CONF = 0x9,
  251. HTT_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
  252. HTT_T2H_MSG_TYPE_SEC_IND = 0xb,
  253. HTT_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
  254. HTT_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
  255. HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION = 0xe,
  256. HTT_T2H_MSG_TYPE_TEST,
  257. /* keep this last */
  258. HTT_T2H_NUM_MSGS
  259. };
  260. /*
  261. * htt_resp_hdr - header for target-to-host messages
  262. *
  263. * msg_type: see htt_t2h_msg_type
  264. */
  265. struct htt_resp_hdr {
  266. u8 msg_type;
  267. } __packed;
  268. #define HTT_RESP_HDR_MSG_TYPE_OFFSET 0
  269. #define HTT_RESP_HDR_MSG_TYPE_MASK 0xff
  270. #define HTT_RESP_HDR_MSG_TYPE_LSB 0
  271. /* htt_ver_resp - response sent for htt_ver_req */
  272. struct htt_ver_resp {
  273. u8 minor;
  274. u8 major;
  275. u8 rsvd0;
  276. } __packed;
  277. struct htt_mgmt_tx_completion {
  278. u8 rsvd0;
  279. u8 rsvd1;
  280. u8 rsvd2;
  281. __le32 desc_id;
  282. __le32 status;
  283. } __packed;
  284. #define HTT_RX_INDICATION_INFO0_EXT_TID_MASK (0x3F)
  285. #define HTT_RX_INDICATION_INFO0_EXT_TID_LSB (0)
  286. #define HTT_RX_INDICATION_INFO0_FLUSH_VALID (1 << 6)
  287. #define HTT_RX_INDICATION_INFO0_RELEASE_VALID (1 << 7)
  288. #define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_MASK 0x0000003F
  289. #define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_LSB 0
  290. #define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_MASK 0x00000FC0
  291. #define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_LSB 6
  292. #define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_MASK 0x0003F000
  293. #define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_LSB 12
  294. #define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_MASK 0x00FC0000
  295. #define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_LSB 18
  296. #define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_MASK 0xFF000000
  297. #define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_LSB 24
  298. struct htt_rx_indication_hdr {
  299. u8 info0; /* %HTT_RX_INDICATION_INFO0_ */
  300. __le16 peer_id;
  301. __le32 info1; /* %HTT_RX_INDICATION_INFO1_ */
  302. } __packed;
  303. #define HTT_RX_INDICATION_INFO0_PHY_ERR_VALID (1 << 0)
  304. #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_MASK (0x1E)
  305. #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_LSB (1)
  306. #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK (1 << 5)
  307. #define HTT_RX_INDICATION_INFO0_END_VALID (1 << 6)
  308. #define HTT_RX_INDICATION_INFO0_START_VALID (1 << 7)
  309. #define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_MASK 0x00FFFFFF
  310. #define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_LSB 0
  311. #define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_MASK 0xFF000000
  312. #define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_LSB 24
  313. #define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_MASK 0x00FFFFFF
  314. #define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_LSB 0
  315. #define HTT_RX_INDICATION_INFO2_SERVICE_MASK 0xFF000000
  316. #define HTT_RX_INDICATION_INFO2_SERVICE_LSB 24
  317. enum htt_rx_legacy_rate {
  318. HTT_RX_OFDM_48 = 0,
  319. HTT_RX_OFDM_24 = 1,
  320. HTT_RX_OFDM_12,
  321. HTT_RX_OFDM_6,
  322. HTT_RX_OFDM_54,
  323. HTT_RX_OFDM_36,
  324. HTT_RX_OFDM_18,
  325. HTT_RX_OFDM_9,
  326. /* long preamble */
  327. HTT_RX_CCK_11_LP = 0,
  328. HTT_RX_CCK_5_5_LP = 1,
  329. HTT_RX_CCK_2_LP,
  330. HTT_RX_CCK_1_LP,
  331. /* short preamble */
  332. HTT_RX_CCK_11_SP,
  333. HTT_RX_CCK_5_5_SP,
  334. HTT_RX_CCK_2_SP
  335. };
  336. enum htt_rx_legacy_rate_type {
  337. HTT_RX_LEGACY_RATE_OFDM = 0,
  338. HTT_RX_LEGACY_RATE_CCK
  339. };
  340. enum htt_rx_preamble_type {
  341. HTT_RX_LEGACY = 0x4,
  342. HTT_RX_HT = 0x8,
  343. HTT_RX_HT_WITH_TXBF = 0x9,
  344. HTT_RX_VHT = 0xC,
  345. HTT_RX_VHT_WITH_TXBF = 0xD,
  346. };
  347. /*
  348. * Fields: phy_err_valid, phy_err_code, tsf,
  349. * usec_timestamp, sub_usec_timestamp
  350. * ..are valid only if end_valid == 1.
  351. *
  352. * Fields: rssi_chains, legacy_rate_type,
  353. * legacy_rate_cck, preamble_type, service,
  354. * vht_sig_*
  355. * ..are valid only if start_valid == 1;
  356. */
  357. struct htt_rx_indication_ppdu {
  358. u8 combined_rssi;
  359. u8 sub_usec_timestamp;
  360. u8 phy_err_code;
  361. u8 info0; /* HTT_RX_INDICATION_INFO0_ */
  362. struct {
  363. u8 pri20_db;
  364. u8 ext20_db;
  365. u8 ext40_db;
  366. u8 ext80_db;
  367. } __packed rssi_chains[4];
  368. __le32 tsf;
  369. __le32 usec_timestamp;
  370. __le32 info1; /* HTT_RX_INDICATION_INFO1_ */
  371. __le32 info2; /* HTT_RX_INDICATION_INFO2_ */
  372. } __packed;
  373. enum htt_rx_mpdu_status {
  374. HTT_RX_IND_MPDU_STATUS_UNKNOWN = 0x0,
  375. HTT_RX_IND_MPDU_STATUS_OK,
  376. HTT_RX_IND_MPDU_STATUS_ERR_FCS,
  377. HTT_RX_IND_MPDU_STATUS_ERR_DUP,
  378. HTT_RX_IND_MPDU_STATUS_ERR_REPLAY,
  379. HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER,
  380. /* only accept EAPOL frames */
  381. HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER,
  382. HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC,
  383. /* Non-data in promiscous mode */
  384. HTT_RX_IND_MPDU_STATUS_MGMT_CTRL,
  385. HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR,
  386. HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR,
  387. HTT_RX_IND_MPDU_STATUS_MPDU_LENGTH_ERR,
  388. HTT_RX_IND_MPDU_STATUS_ENCRYPT_REQUIRED_ERR,
  389. HTT_RX_IND_MPDU_STATUS_PRIVACY_ERR,
  390. /*
  391. * MISC: discard for unspecified reasons.
  392. * Leave this enum value last.
  393. */
  394. HTT_RX_IND_MPDU_STATUS_ERR_MISC = 0xFF
  395. };
  396. struct htt_rx_indication_mpdu_range {
  397. u8 mpdu_count;
  398. u8 mpdu_range_status; /* %htt_rx_mpdu_status */
  399. u8 pad0;
  400. u8 pad1;
  401. } __packed;
  402. struct htt_rx_indication_prefix {
  403. __le16 fw_rx_desc_bytes;
  404. u8 pad0;
  405. u8 pad1;
  406. };
  407. struct htt_rx_indication {
  408. struct htt_rx_indication_hdr hdr;
  409. struct htt_rx_indication_ppdu ppdu;
  410. struct htt_rx_indication_prefix prefix;
  411. /*
  412. * the following fields are both dynamically sized, so
  413. * take care addressing them
  414. */
  415. /* the size of this is %fw_rx_desc_bytes */
  416. struct fw_rx_desc_base fw_desc;
  417. /*
  418. * %mpdu_ranges starts after &%prefix + roundup(%fw_rx_desc_bytes, 4)
  419. * and has %num_mpdu_ranges elements.
  420. */
  421. struct htt_rx_indication_mpdu_range mpdu_ranges[0];
  422. } __packed;
  423. static inline struct htt_rx_indication_mpdu_range *
  424. htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication *rx_ind)
  425. {
  426. void *ptr = rx_ind;
  427. ptr += sizeof(rx_ind->hdr)
  428. + sizeof(rx_ind->ppdu)
  429. + sizeof(rx_ind->prefix)
  430. + roundup(__le16_to_cpu(rx_ind->prefix.fw_rx_desc_bytes), 4);
  431. return ptr;
  432. }
  433. enum htt_rx_flush_mpdu_status {
  434. HTT_RX_FLUSH_MPDU_DISCARD = 0,
  435. HTT_RX_FLUSH_MPDU_REORDER = 1,
  436. };
  437. /*
  438. * htt_rx_flush - discard or reorder given range of mpdus
  439. *
  440. * Note: host must check if all sequence numbers between
  441. * [seq_num_start, seq_num_end-1] are valid.
  442. */
  443. struct htt_rx_flush {
  444. __le16 peer_id;
  445. u8 tid;
  446. u8 rsvd0;
  447. u8 mpdu_status; /* %htt_rx_flush_mpdu_status */
  448. u8 seq_num_start; /* it is 6 LSBs of 802.11 seq no */
  449. u8 seq_num_end; /* it is 6 LSBs of 802.11 seq no */
  450. };
  451. struct htt_rx_peer_map {
  452. u8 vdev_id;
  453. __le16 peer_id;
  454. u8 addr[6];
  455. u8 rsvd0;
  456. u8 rsvd1;
  457. } __packed;
  458. struct htt_rx_peer_unmap {
  459. u8 rsvd0;
  460. __le16 peer_id;
  461. } __packed;
  462. enum htt_security_types {
  463. HTT_SECURITY_NONE,
  464. HTT_SECURITY_WEP128,
  465. HTT_SECURITY_WEP104,
  466. HTT_SECURITY_WEP40,
  467. HTT_SECURITY_TKIP,
  468. HTT_SECURITY_TKIP_NOMIC,
  469. HTT_SECURITY_AES_CCMP,
  470. HTT_SECURITY_WAPI,
  471. HTT_NUM_SECURITY_TYPES /* keep this last! */
  472. };
  473. enum htt_security_flags {
  474. #define HTT_SECURITY_TYPE_MASK 0x7F
  475. #define HTT_SECURITY_TYPE_LSB 0
  476. HTT_SECURITY_IS_UNICAST = 1 << 7
  477. };
  478. struct htt_security_indication {
  479. union {
  480. /* dont use bitfields; undefined behaviour */
  481. u8 flags; /* %htt_security_flags */
  482. struct {
  483. u8 security_type:7, /* %htt_security_types */
  484. is_unicast:1;
  485. } __packed;
  486. } __packed;
  487. __le16 peer_id;
  488. u8 michael_key[8];
  489. u8 wapi_rsc[16];
  490. } __packed;
  491. #define HTT_RX_BA_INFO0_TID_MASK 0x000F
  492. #define HTT_RX_BA_INFO0_TID_LSB 0
  493. #define HTT_RX_BA_INFO0_PEER_ID_MASK 0xFFF0
  494. #define HTT_RX_BA_INFO0_PEER_ID_LSB 4
  495. struct htt_rx_addba {
  496. u8 window_size;
  497. __le16 info0; /* %HTT_RX_BA_INFO0_ */
  498. } __packed;
  499. struct htt_rx_delba {
  500. u8 rsvd0;
  501. __le16 info0; /* %HTT_RX_BA_INFO0_ */
  502. } __packed;
  503. enum htt_data_tx_status {
  504. HTT_DATA_TX_STATUS_OK = 0,
  505. HTT_DATA_TX_STATUS_DISCARD = 1,
  506. HTT_DATA_TX_STATUS_NO_ACK = 2,
  507. HTT_DATA_TX_STATUS_POSTPONE = 3, /* HL only */
  508. HTT_DATA_TX_STATUS_DOWNLOAD_FAIL = 128
  509. };
  510. enum htt_data_tx_flags {
  511. #define HTT_DATA_TX_STATUS_MASK 0x07
  512. #define HTT_DATA_TX_STATUS_LSB 0
  513. #define HTT_DATA_TX_TID_MASK 0x78
  514. #define HTT_DATA_TX_TID_LSB 3
  515. HTT_DATA_TX_TID_INVALID = 1 << 7
  516. };
  517. #define HTT_TX_COMPL_INV_MSDU_ID 0xFFFF
  518. struct htt_data_tx_completion {
  519. union {
  520. u8 flags;
  521. struct {
  522. u8 status:3,
  523. tid:4,
  524. tid_invalid:1;
  525. } __packed;
  526. } __packed;
  527. u8 num_msdus;
  528. u8 rsvd0;
  529. __le16 msdus[0]; /* variable length based on %num_msdus */
  530. } __packed;
  531. struct htt_tx_compl_ind_base {
  532. u32 hdr;
  533. u16 payload[1/*or more*/];
  534. } __packed;
  535. struct htt_rc_tx_done_params {
  536. u32 rate_code;
  537. u32 rate_code_flags;
  538. u32 flags;
  539. u32 num_enqued; /* 1 for non-AMPDU */
  540. u32 num_retries;
  541. u32 num_failed; /* for AMPDU */
  542. u32 ack_rssi;
  543. u32 time_stamp;
  544. u32 is_probe;
  545. };
  546. struct htt_rc_update {
  547. u8 vdev_id;
  548. __le16 peer_id;
  549. u8 addr[6];
  550. u8 num_elems;
  551. u8 rsvd0;
  552. struct htt_rc_tx_done_params params[0]; /* variable length %num_elems */
  553. } __packed;
  554. /* see htt_rx_indication for similar fields and descriptions */
  555. struct htt_rx_fragment_indication {
  556. union {
  557. u8 info0; /* %HTT_RX_FRAG_IND_INFO0_ */
  558. struct {
  559. u8 ext_tid:5,
  560. flush_valid:1;
  561. } __packed;
  562. } __packed;
  563. __le16 peer_id;
  564. __le32 info1; /* %HTT_RX_FRAG_IND_INFO1_ */
  565. __le16 fw_rx_desc_bytes;
  566. __le16 rsvd0;
  567. u8 fw_msdu_rx_desc[0];
  568. } __packed;
  569. #define HTT_RX_FRAG_IND_INFO0_EXT_TID_MASK 0x1F
  570. #define HTT_RX_FRAG_IND_INFO0_EXT_TID_LSB 0
  571. #define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_MASK 0x20
  572. #define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_LSB 5
  573. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_MASK 0x0000003F
  574. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_LSB 0
  575. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_MASK 0x00000FC0
  576. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_LSB 6
  577. /*
  578. * target -> host test message definition
  579. *
  580. * The following field definitions describe the format of the test
  581. * message sent from the target to the host.
  582. * The message consists of a 4-octet header, followed by a variable
  583. * number of 32-bit integer values, followed by a variable number
  584. * of 8-bit character values.
  585. *
  586. * |31 16|15 8|7 0|
  587. * |-----------------------------------------------------------|
  588. * | num chars | num ints | msg type |
  589. * |-----------------------------------------------------------|
  590. * | int 0 |
  591. * |-----------------------------------------------------------|
  592. * | int 1 |
  593. * |-----------------------------------------------------------|
  594. * | ... |
  595. * |-----------------------------------------------------------|
  596. * | char 3 | char 2 | char 1 | char 0 |
  597. * |-----------------------------------------------------------|
  598. * | | | ... | char 4 |
  599. * |-----------------------------------------------------------|
  600. * - MSG_TYPE
  601. * Bits 7:0
  602. * Purpose: identifies this as a test message
  603. * Value: HTT_MSG_TYPE_TEST
  604. * - NUM_INTS
  605. * Bits 15:8
  606. * Purpose: indicate how many 32-bit integers follow the message header
  607. * - NUM_CHARS
  608. * Bits 31:16
  609. * Purpose: indicate how many 8-bit charaters follow the series of integers
  610. */
  611. struct htt_rx_test {
  612. u8 num_ints;
  613. __le16 num_chars;
  614. /* payload consists of 2 lists:
  615. * a) num_ints * sizeof(__le32)
  616. * b) num_chars * sizeof(u8) aligned to 4bytes */
  617. u8 payload[0];
  618. } __packed;
  619. static inline __le32 *htt_rx_test_get_ints(struct htt_rx_test *rx_test)
  620. {
  621. return (__le32 *)rx_test->payload;
  622. }
  623. static inline u8 *htt_rx_test_get_chars(struct htt_rx_test *rx_test)
  624. {
  625. return rx_test->payload + (rx_test->num_ints * sizeof(__le32));
  626. }
  627. /*
  628. * target -> host packet log message
  629. *
  630. * The following field definitions describe the format of the packet log
  631. * message sent from the target to the host.
  632. * The message consists of a 4-octet header,followed by a variable number
  633. * of 32-bit character values.
  634. *
  635. * |31 24|23 16|15 8|7 0|
  636. * |-----------------------------------------------------------|
  637. * | | | | msg type |
  638. * |-----------------------------------------------------------|
  639. * | payload |
  640. * |-----------------------------------------------------------|
  641. * - MSG_TYPE
  642. * Bits 7:0
  643. * Purpose: identifies this as a test message
  644. * Value: HTT_MSG_TYPE_PACKETLOG
  645. */
  646. struct htt_pktlog_msg {
  647. u8 pad[3];
  648. __le32 payload[1 /* or more */];
  649. } __packed;
  650. struct htt_dbg_stats_rx_reorder_stats {
  651. /* Non QoS MPDUs received */
  652. __le32 deliver_non_qos;
  653. /* MPDUs received in-order */
  654. __le32 deliver_in_order;
  655. /* Flush due to reorder timer expired */
  656. __le32 deliver_flush_timeout;
  657. /* Flush due to move out of window */
  658. __le32 deliver_flush_oow;
  659. /* Flush due to DELBA */
  660. __le32 deliver_flush_delba;
  661. /* MPDUs dropped due to FCS error */
  662. __le32 fcs_error;
  663. /* MPDUs dropped due to monitor mode non-data packet */
  664. __le32 mgmt_ctrl;
  665. /* MPDUs dropped due to invalid peer */
  666. __le32 invalid_peer;
  667. /* MPDUs dropped due to duplication (non aggregation) */
  668. __le32 dup_non_aggr;
  669. /* MPDUs dropped due to processed before */
  670. __le32 dup_past;
  671. /* MPDUs dropped due to duplicate in reorder queue */
  672. __le32 dup_in_reorder;
  673. /* Reorder timeout happened */
  674. __le32 reorder_timeout;
  675. /* invalid bar ssn */
  676. __le32 invalid_bar_ssn;
  677. /* reorder reset due to bar ssn */
  678. __le32 ssn_reset;
  679. };
  680. struct htt_dbg_stats_wal_tx_stats {
  681. /* Num HTT cookies queued to dispatch list */
  682. __le32 comp_queued;
  683. /* Num HTT cookies dispatched */
  684. __le32 comp_delivered;
  685. /* Num MSDU queued to WAL */
  686. __le32 msdu_enqued;
  687. /* Num MPDU queue to WAL */
  688. __le32 mpdu_enqued;
  689. /* Num MSDUs dropped by WMM limit */
  690. __le32 wmm_drop;
  691. /* Num Local frames queued */
  692. __le32 local_enqued;
  693. /* Num Local frames done */
  694. __le32 local_freed;
  695. /* Num queued to HW */
  696. __le32 hw_queued;
  697. /* Num PPDU reaped from HW */
  698. __le32 hw_reaped;
  699. /* Num underruns */
  700. __le32 underrun;
  701. /* Num PPDUs cleaned up in TX abort */
  702. __le32 tx_abort;
  703. /* Num MPDUs requed by SW */
  704. __le32 mpdus_requed;
  705. /* excessive retries */
  706. __le32 tx_ko;
  707. /* data hw rate code */
  708. __le32 data_rc;
  709. /* Scheduler self triggers */
  710. __le32 self_triggers;
  711. /* frames dropped due to excessive sw retries */
  712. __le32 sw_retry_failure;
  713. /* illegal rate phy errors */
  714. __le32 illgl_rate_phy_err;
  715. /* wal pdev continous xretry */
  716. __le32 pdev_cont_xretry;
  717. /* wal pdev continous xretry */
  718. __le32 pdev_tx_timeout;
  719. /* wal pdev resets */
  720. __le32 pdev_resets;
  721. __le32 phy_underrun;
  722. /* MPDU is more than txop limit */
  723. __le32 txop_ovf;
  724. } __packed;
  725. struct htt_dbg_stats_wal_rx_stats {
  726. /* Cnts any change in ring routing mid-ppdu */
  727. __le32 mid_ppdu_route_change;
  728. /* Total number of statuses processed */
  729. __le32 status_rcvd;
  730. /* Extra frags on rings 0-3 */
  731. __le32 r0_frags;
  732. __le32 r1_frags;
  733. __le32 r2_frags;
  734. __le32 r3_frags;
  735. /* MSDUs / MPDUs delivered to HTT */
  736. __le32 htt_msdus;
  737. __le32 htt_mpdus;
  738. /* MSDUs / MPDUs delivered to local stack */
  739. __le32 loc_msdus;
  740. __le32 loc_mpdus;
  741. /* AMSDUs that have more MSDUs than the status ring size */
  742. __le32 oversize_amsdu;
  743. /* Number of PHY errors */
  744. __le32 phy_errs;
  745. /* Number of PHY errors drops */
  746. __le32 phy_err_drop;
  747. /* Number of mpdu errors - FCS, MIC, ENC etc. */
  748. __le32 mpdu_errs;
  749. } __packed;
  750. struct htt_dbg_stats_wal_peer_stats {
  751. __le32 dummy; /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */
  752. } __packed;
  753. struct htt_dbg_stats_wal_pdev_txrx {
  754. struct htt_dbg_stats_wal_tx_stats tx_stats;
  755. struct htt_dbg_stats_wal_rx_stats rx_stats;
  756. struct htt_dbg_stats_wal_peer_stats peer_stats;
  757. } __packed;
  758. struct htt_dbg_stats_rx_rate_info {
  759. __le32 mcs[10];
  760. __le32 sgi[10];
  761. __le32 nss[4];
  762. __le32 stbc[10];
  763. __le32 bw[3];
  764. __le32 pream[6];
  765. __le32 ldpc;
  766. __le32 txbf;
  767. };
  768. /*
  769. * htt_dbg_stats_status -
  770. * present - The requested stats have been delivered in full.
  771. * This indicates that either the stats information was contained
  772. * in its entirety within this message, or else this message
  773. * completes the delivery of the requested stats info that was
  774. * partially delivered through earlier STATS_CONF messages.
  775. * partial - The requested stats have been delivered in part.
  776. * One or more subsequent STATS_CONF messages with the same
  777. * cookie value will be sent to deliver the remainder of the
  778. * information.
  779. * error - The requested stats could not be delivered, for example due
  780. * to a shortage of memory to construct a message holding the
  781. * requested stats.
  782. * invalid - The requested stat type is either not recognized, or the
  783. * target is configured to not gather the stats type in question.
  784. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  785. * series_done - This special value indicates that no further stats info
  786. * elements are present within a series of stats info elems
  787. * (within a stats upload confirmation message).
  788. */
  789. enum htt_dbg_stats_status {
  790. HTT_DBG_STATS_STATUS_PRESENT = 0,
  791. HTT_DBG_STATS_STATUS_PARTIAL = 1,
  792. HTT_DBG_STATS_STATUS_ERROR = 2,
  793. HTT_DBG_STATS_STATUS_INVALID = 3,
  794. HTT_DBG_STATS_STATUS_SERIES_DONE = 7
  795. };
  796. /*
  797. * target -> host statistics upload
  798. *
  799. * The following field definitions describe the format of the HTT target
  800. * to host stats upload confirmation message.
  801. * The message contains a cookie echoed from the HTT host->target stats
  802. * upload request, which identifies which request the confirmation is
  803. * for, and a series of tag-length-value stats information elements.
  804. * The tag-length header for each stats info element also includes a
  805. * status field, to indicate whether the request for the stat type in
  806. * question was fully met, partially met, unable to be met, or invalid
  807. * (if the stat type in question is disabled in the target).
  808. * A special value of all 1's in this status field is used to indicate
  809. * the end of the series of stats info elements.
  810. *
  811. *
  812. * |31 16|15 8|7 5|4 0|
  813. * |------------------------------------------------------------|
  814. * | reserved | msg type |
  815. * |------------------------------------------------------------|
  816. * | cookie LSBs |
  817. * |------------------------------------------------------------|
  818. * | cookie MSBs |
  819. * |------------------------------------------------------------|
  820. * | stats entry length | reserved | S |stat type|
  821. * |------------------------------------------------------------|
  822. * | |
  823. * | type-specific stats info |
  824. * | |
  825. * |------------------------------------------------------------|
  826. * | stats entry length | reserved | S |stat type|
  827. * |------------------------------------------------------------|
  828. * | |
  829. * | type-specific stats info |
  830. * | |
  831. * |------------------------------------------------------------|
  832. * | n/a | reserved | 111 | n/a |
  833. * |------------------------------------------------------------|
  834. * Header fields:
  835. * - MSG_TYPE
  836. * Bits 7:0
  837. * Purpose: identifies this is a statistics upload confirmation message
  838. * Value: 0x9
  839. * - COOKIE_LSBS
  840. * Bits 31:0
  841. * Purpose: Provide a mechanism to match a target->host stats confirmation
  842. * message with its preceding host->target stats request message.
  843. * Value: LSBs of the opaque cookie specified by the host-side requestor
  844. * - COOKIE_MSBS
  845. * Bits 31:0
  846. * Purpose: Provide a mechanism to match a target->host stats confirmation
  847. * message with its preceding host->target stats request message.
  848. * Value: MSBs of the opaque cookie specified by the host-side requestor
  849. *
  850. * Stats Information Element tag-length header fields:
  851. * - STAT_TYPE
  852. * Bits 4:0
  853. * Purpose: identifies the type of statistics info held in the
  854. * following information element
  855. * Value: htt_dbg_stats_type
  856. * - STATUS
  857. * Bits 7:5
  858. * Purpose: indicate whether the requested stats are present
  859. * Value: htt_dbg_stats_status, including a special value (0x7) to mark
  860. * the completion of the stats entry series
  861. * - LENGTH
  862. * Bits 31:16
  863. * Purpose: indicate the stats information size
  864. * Value: This field specifies the number of bytes of stats information
  865. * that follows the element tag-length header.
  866. * It is expected but not required that this length is a multiple of
  867. * 4 bytes. Even if the length is not an integer multiple of 4, the
  868. * subsequent stats entry header will begin on a 4-byte aligned
  869. * boundary.
  870. */
  871. #define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_MASK 0x1F
  872. #define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_LSB 0
  873. #define HTT_STATS_CONF_ITEM_INFO_STATUS_MASK 0xE0
  874. #define HTT_STATS_CONF_ITEM_INFO_STATUS_LSB 5
  875. struct htt_stats_conf_item {
  876. union {
  877. u8 info;
  878. struct {
  879. u8 stat_type:5; /* %HTT_DBG_STATS_ */
  880. u8 status:3; /* %HTT_DBG_STATS_STATUS_ */
  881. } __packed;
  882. } __packed;
  883. u8 pad;
  884. __le16 length;
  885. u8 payload[0]; /* roundup(length, 4) long */
  886. } __packed;
  887. struct htt_stats_conf {
  888. u8 pad[3];
  889. __le32 cookie_lsb;
  890. __le32 cookie_msb;
  891. /* each item has variable length! */
  892. struct htt_stats_conf_item items[0];
  893. } __packed;
  894. static inline struct htt_stats_conf_item *htt_stats_conf_next_item(
  895. const struct htt_stats_conf_item *item)
  896. {
  897. return (void *)item + sizeof(*item) + roundup(item->length, 4);
  898. }
  899. /*
  900. * host -> target FRAG DESCRIPTOR/MSDU_EXT DESC bank
  901. *
  902. * The following field definitions describe the format of the HTT host
  903. * to target frag_desc/msdu_ext bank configuration message.
  904. * The message contains the based address and the min and max id of the
  905. * MSDU_EXT/FRAG_DESC that will be used by the HTT to map MSDU DESC and
  906. * MSDU_EXT/FRAG_DESC.
  907. * HTT will use id in HTT descriptor instead sending the frag_desc_ptr.
  908. * For QCA988X HW the firmware will use fragment_desc_ptr but in WIFI2.0
  909. * the hardware does the mapping/translation.
  910. *
  911. * Total banks that can be configured is configured to 16.
  912. *
  913. * This should be called before any TX has be initiated by the HTT
  914. *
  915. * |31 16|15 8|7 5|4 0|
  916. * |------------------------------------------------------------|
  917. * | DESC_SIZE | NUM_BANKS | RES |SWP|pdev| msg type |
  918. * |------------------------------------------------------------|
  919. * | BANK0_BASE_ADDRESS |
  920. * |------------------------------------------------------------|
  921. * | ... |
  922. * |------------------------------------------------------------|
  923. * | BANK15_BASE_ADDRESS |
  924. * |------------------------------------------------------------|
  925. * | BANK0_MAX_ID | BANK0_MIN_ID |
  926. * |------------------------------------------------------------|
  927. * | ... |
  928. * |------------------------------------------------------------|
  929. * | BANK15_MAX_ID | BANK15_MIN_ID |
  930. * |------------------------------------------------------------|
  931. * Header fields:
  932. * - MSG_TYPE
  933. * Bits 7:0
  934. * Value: 0x6
  935. * - BANKx_BASE_ADDRESS
  936. * Bits 31:0
  937. * Purpose: Provide a mechanism to specify the base address of the MSDU_EXT
  938. * bank physical/bus address.
  939. * - BANKx_MIN_ID
  940. * Bits 15:0
  941. * Purpose: Provide a mechanism to specify the min index that needs to
  942. * mapped.
  943. * - BANKx_MAX_ID
  944. * Bits 31:16
  945. * Purpose: Provide a mechanism to specify the max index that needs to
  946. *
  947. */
  948. struct htt_frag_desc_bank_id {
  949. __le16 bank_min_id;
  950. __le16 bank_max_id;
  951. } __packed;
  952. /* real is 16 but it wouldn't fit in the max htt message size
  953. * so we use a conservatively safe value for now */
  954. #define HTT_FRAG_DESC_BANK_MAX 4
  955. #define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_MASK 0x03
  956. #define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_LSB 0
  957. #define HTT_FRAG_DESC_BANK_CFG_INFO_SWAP (1 << 2)
  958. struct htt_frag_desc_bank_cfg {
  959. u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */
  960. u8 num_banks;
  961. u8 desc_size;
  962. __le32 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];
  963. struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];
  964. } __packed;
  965. union htt_rx_pn_t {
  966. /* WEP: 24-bit PN */
  967. u32 pn24;
  968. /* TKIP or CCMP: 48-bit PN */
  969. u_int64_t pn48;
  970. /* WAPI: 128-bit PN */
  971. u_int64_t pn128[2];
  972. };
  973. struct htt_cmd {
  974. struct htt_cmd_hdr hdr;
  975. union {
  976. struct htt_ver_req ver_req;
  977. struct htt_mgmt_tx_desc mgmt_tx;
  978. struct htt_data_tx_desc data_tx;
  979. struct htt_rx_ring_setup rx_setup;
  980. struct htt_stats_req stats_req;
  981. struct htt_oob_sync_req oob_sync_req;
  982. struct htt_aggr_conf aggr_conf;
  983. struct htt_frag_desc_bank_cfg frag_desc_bank_cfg;
  984. };
  985. } __packed;
  986. struct htt_resp {
  987. struct htt_resp_hdr hdr;
  988. union {
  989. struct htt_ver_resp ver_resp;
  990. struct htt_mgmt_tx_completion mgmt_tx_completion;
  991. struct htt_data_tx_completion data_tx_completion;
  992. struct htt_rx_indication rx_ind;
  993. struct htt_rx_fragment_indication rx_frag_ind;
  994. struct htt_rx_peer_map peer_map;
  995. struct htt_rx_peer_unmap peer_unmap;
  996. struct htt_rx_flush rx_flush;
  997. struct htt_rx_addba rx_addba;
  998. struct htt_rx_delba rx_delba;
  999. struct htt_security_indication security_indication;
  1000. struct htt_rc_update rc_update;
  1001. struct htt_rx_test rx_test;
  1002. struct htt_pktlog_msg pktlog_msg;
  1003. struct htt_stats_conf stats_conf;
  1004. };
  1005. } __packed;
  1006. /*** host side structures follow ***/
  1007. struct htt_tx_done {
  1008. u32 msdu_id;
  1009. bool discard;
  1010. bool no_ack;
  1011. };
  1012. struct htt_peer_map_event {
  1013. u8 vdev_id;
  1014. u16 peer_id;
  1015. u8 addr[ETH_ALEN];
  1016. };
  1017. struct htt_peer_unmap_event {
  1018. u16 peer_id;
  1019. };
  1020. struct htt_rx_info {
  1021. struct sk_buff *skb;
  1022. enum htt_rx_mpdu_status status;
  1023. enum htt_rx_mpdu_encrypt_type encrypt_type;
  1024. s8 signal;
  1025. struct {
  1026. u8 info0;
  1027. u32 info1;
  1028. u32 info2;
  1029. } rate;
  1030. bool fcs_err;
  1031. };
  1032. struct ath10k_htt {
  1033. struct ath10k *ar;
  1034. enum ath10k_htc_ep_id eid;
  1035. int max_throughput_mbps;
  1036. u8 target_version_major;
  1037. u8 target_version_minor;
  1038. struct completion target_version_received;
  1039. struct {
  1040. /*
  1041. * Ring of network buffer objects - This ring is
  1042. * used exclusively by the host SW. This ring
  1043. * mirrors the dev_addrs_ring that is shared
  1044. * between the host SW and the MAC HW. The host SW
  1045. * uses this netbufs ring to locate the network
  1046. * buffer objects whose data buffers the HW has
  1047. * filled.
  1048. */
  1049. struct sk_buff **netbufs_ring;
  1050. /*
  1051. * Ring of buffer addresses -
  1052. * This ring holds the "physical" device address of the
  1053. * rx buffers the host SW provides for the MAC HW to
  1054. * fill.
  1055. */
  1056. __le32 *paddrs_ring;
  1057. /*
  1058. * Base address of ring, as a "physical" device address
  1059. * rather than a CPU address.
  1060. */
  1061. dma_addr_t base_paddr;
  1062. /* how many elems in the ring (power of 2) */
  1063. int size;
  1064. /* size - 1 */
  1065. unsigned size_mask;
  1066. /* how many rx buffers to keep in the ring */
  1067. int fill_level;
  1068. /* how many rx buffers (full+empty) are in the ring */
  1069. int fill_cnt;
  1070. /*
  1071. * alloc_idx - where HTT SW has deposited empty buffers
  1072. * This is allocated in consistent mem, so that the FW can
  1073. * read this variable, and program the HW's FW_IDX reg with
  1074. * the value of this shadow register.
  1075. */
  1076. struct {
  1077. __le32 *vaddr;
  1078. dma_addr_t paddr;
  1079. } alloc_idx;
  1080. /* where HTT SW has processed bufs filled by rx MAC DMA */
  1081. struct {
  1082. unsigned msdu_payld;
  1083. } sw_rd_idx;
  1084. /*
  1085. * refill_retry_timer - timer triggered when the ring is
  1086. * not refilled to the level expected
  1087. */
  1088. struct timer_list refill_retry_timer;
  1089. /* Protects access to all rx ring buffer state variables */
  1090. spinlock_t lock;
  1091. } rx_ring;
  1092. unsigned int prefetch_len;
  1093. /* Protects access to %pending_tx, %used_msdu_ids */
  1094. spinlock_t tx_lock;
  1095. int max_num_pending_tx;
  1096. int num_pending_tx;
  1097. struct sk_buff **pending_tx;
  1098. unsigned long *used_msdu_ids; /* bitmap */
  1099. wait_queue_head_t empty_tx_wq;
  1100. /* set if host-fw communication goes haywire
  1101. * used to avoid further failures */
  1102. bool rx_confused;
  1103. };
  1104. #define RX_HTT_HDR_STATUS_LEN 64
  1105. /* This structure layout is programmed via rx ring setup
  1106. * so that FW knows how to transfer the rx descriptor to the host.
  1107. * Buffers like this are placed on the rx ring. */
  1108. struct htt_rx_desc {
  1109. union {
  1110. /* This field is filled on the host using the msdu buffer
  1111. * from htt_rx_indication */
  1112. struct fw_rx_desc_base fw_desc;
  1113. u32 pad;
  1114. } __packed;
  1115. struct {
  1116. struct rx_attention attention;
  1117. struct rx_frag_info frag_info;
  1118. struct rx_mpdu_start mpdu_start;
  1119. struct rx_msdu_start msdu_start;
  1120. struct rx_msdu_end msdu_end;
  1121. struct rx_mpdu_end mpdu_end;
  1122. struct rx_ppdu_start ppdu_start;
  1123. struct rx_ppdu_end ppdu_end;
  1124. } __packed;
  1125. u8 rx_hdr_status[RX_HTT_HDR_STATUS_LEN];
  1126. u8 msdu_payload[0];
  1127. };
  1128. #define HTT_RX_DESC_ALIGN 8
  1129. #define HTT_MAC_ADDR_LEN 6
  1130. /*
  1131. * FIX THIS
  1132. * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,
  1133. * rounded up to a cache line size.
  1134. */
  1135. #define HTT_RX_BUF_SIZE 1920
  1136. #define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc))
  1137. /*
  1138. * DMA_MAP expects the buffer to be an integral number of cache lines.
  1139. * Rather than checking the actual cache line size, this code makes a
  1140. * conservative estimate of what the cache line size could be.
  1141. */
  1142. #define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */
  1143. #define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)
  1144. int ath10k_htt_attach(struct ath10k *ar);
  1145. int ath10k_htt_attach_target(struct ath10k_htt *htt);
  1146. void ath10k_htt_detach(struct ath10k_htt *htt);
  1147. int ath10k_htt_tx_attach(struct ath10k_htt *htt);
  1148. void ath10k_htt_tx_detach(struct ath10k_htt *htt);
  1149. int ath10k_htt_rx_attach(struct ath10k_htt *htt);
  1150. void ath10k_htt_rx_detach(struct ath10k_htt *htt);
  1151. void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);
  1152. void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
  1153. int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
  1154. int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt);
  1155. void __ath10k_htt_tx_dec_pending(struct ath10k_htt *htt);
  1156. int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt);
  1157. void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);
  1158. int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *);
  1159. int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *);
  1160. #endif