htt.h 39 KB

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