htt.h 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802
  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 <linux/hashtable.h>
  23. #include <linux/kfifo.h>
  24. #include <net/mac80211.h>
  25. #include "htc.h"
  26. #include "hw.h"
  27. #include "rx_desc.h"
  28. #include "hw.h"
  29. enum htt_dbg_stats_type {
  30. HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0,
  31. HTT_DBG_STATS_RX_REORDER = 1 << 1,
  32. HTT_DBG_STATS_RX_RATE_INFO = 1 << 2,
  33. HTT_DBG_STATS_TX_PPDU_LOG = 1 << 3,
  34. HTT_DBG_STATS_TX_RATE_INFO = 1 << 4,
  35. /* bits 5-23 currently reserved */
  36. HTT_DBG_NUM_STATS /* keep this last */
  37. };
  38. enum htt_h2t_msg_type { /* host-to-target */
  39. HTT_H2T_MSG_TYPE_VERSION_REQ = 0,
  40. HTT_H2T_MSG_TYPE_TX_FRM = 1,
  41. HTT_H2T_MSG_TYPE_RX_RING_CFG = 2,
  42. HTT_H2T_MSG_TYPE_STATS_REQ = 3,
  43. HTT_H2T_MSG_TYPE_SYNC = 4,
  44. HTT_H2T_MSG_TYPE_AGGR_CFG = 5,
  45. HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG = 6,
  46. /* This command is used for sending management frames in HTT < 3.0.
  47. * HTT >= 3.0 uses TX_FRM for everything. */
  48. HTT_H2T_MSG_TYPE_MGMT_TX = 7,
  49. HTT_H2T_MSG_TYPE_TX_FETCH_RESP = 11,
  50. HTT_H2T_NUM_MSGS /* keep this last */
  51. };
  52. struct htt_cmd_hdr {
  53. u8 msg_type;
  54. } __packed;
  55. struct htt_ver_req {
  56. u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
  57. } __packed;
  58. /*
  59. * HTT tx MSDU descriptor
  60. *
  61. * The HTT tx MSDU descriptor is created by the host HTT SW for each
  62. * tx MSDU. The HTT tx MSDU descriptor contains the information that
  63. * the target firmware needs for the FW's tx processing, particularly
  64. * for creating the HW msdu descriptor.
  65. * The same HTT tx descriptor is used for HL and LL systems, though
  66. * a few fields within the tx descriptor are used only by LL or
  67. * only by HL.
  68. * The HTT tx descriptor is defined in two manners: by a struct with
  69. * bitfields, and by a series of [dword offset, bit mask, bit shift]
  70. * definitions.
  71. * The target should use the struct def, for simplicitly and clarity,
  72. * but the host shall use the bit-mast + bit-shift defs, to be endian-
  73. * neutral. Specifically, the host shall use the get/set macros built
  74. * around the mask + shift defs.
  75. */
  76. struct htt_data_tx_desc_frag {
  77. union {
  78. struct double_word_addr {
  79. __le32 paddr;
  80. __le32 len;
  81. } __packed dword_addr;
  82. struct triple_word_addr {
  83. __le32 paddr_lo;
  84. __le16 paddr_hi;
  85. __le16 len_16;
  86. } __packed tword_addr;
  87. } __packed;
  88. } __packed;
  89. struct htt_msdu_ext_desc {
  90. __le32 tso_flag[3];
  91. __le16 ip_identification;
  92. u8 flags;
  93. u8 reserved;
  94. struct htt_data_tx_desc_frag frags[6];
  95. };
  96. #define HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE BIT(0)
  97. #define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE BIT(1)
  98. #define HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE BIT(2)
  99. #define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE BIT(3)
  100. #define HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE BIT(4)
  101. #define HTT_MSDU_CHECKSUM_ENABLE (HTT_MSDU_EXT_DESC_FLAG_IPV4_CSUM_ENABLE \
  102. | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV4_CSUM_ENABLE \
  103. | HTT_MSDU_EXT_DESC_FLAG_UDP_IPV6_CSUM_ENABLE \
  104. | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV4_CSUM_ENABLE \
  105. | HTT_MSDU_EXT_DESC_FLAG_TCP_IPV6_CSUM_ENABLE)
  106. enum htt_data_tx_desc_flags0 {
  107. HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT = 1 << 0,
  108. HTT_DATA_TX_DESC_FLAGS0_NO_AGGR = 1 << 1,
  109. HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT = 1 << 2,
  110. HTT_DATA_TX_DESC_FLAGS0_NO_CLASSIFY = 1 << 3,
  111. HTT_DATA_TX_DESC_FLAGS0_RSVD0 = 1 << 4
  112. #define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_MASK 0xE0
  113. #define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_LSB 5
  114. };
  115. enum htt_data_tx_desc_flags1 {
  116. #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_BITS 6
  117. #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_MASK 0x003F
  118. #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_LSB 0
  119. #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_BITS 5
  120. #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_MASK 0x07C0
  121. #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_LSB 6
  122. HTT_DATA_TX_DESC_FLAGS1_POSTPONED = 1 << 11,
  123. HTT_DATA_TX_DESC_FLAGS1_MORE_IN_BATCH = 1 << 12,
  124. HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD = 1 << 13,
  125. HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD = 1 << 14,
  126. HTT_DATA_TX_DESC_FLAGS1_RSVD1 = 1 << 15
  127. };
  128. enum htt_data_tx_ext_tid {
  129. HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST = 16,
  130. HTT_DATA_TX_EXT_TID_MGMT = 17,
  131. HTT_DATA_TX_EXT_TID_INVALID = 31
  132. };
  133. #define HTT_INVALID_PEERID 0xFFFF
  134. /*
  135. * htt_data_tx_desc - used for data tx path
  136. *
  137. * Note: vdev_id irrelevant for pkt_type == raw and no_classify == 1.
  138. * ext_tid: for qos-data frames (0-15), see %HTT_DATA_TX_EXT_TID_
  139. * for special kinds of tids
  140. * postponed: only for HL hosts. indicates if this is a resend
  141. * (HL hosts manage queues on the host )
  142. * more_in_batch: only for HL hosts. indicates if more packets are
  143. * pending. this allows target to wait and aggregate
  144. * freq: 0 means home channel of given vdev. intended for offchannel
  145. */
  146. struct htt_data_tx_desc {
  147. u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */
  148. __le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */
  149. __le16 len;
  150. __le16 id;
  151. __le32 frags_paddr;
  152. union {
  153. __le32 peerid;
  154. struct {
  155. __le16 peerid;
  156. __le16 freq;
  157. } __packed offchan_tx;
  158. } __packed;
  159. u8 prefetch[0]; /* start of frame, for FW classification engine */
  160. } __packed;
  161. enum htt_rx_ring_flags {
  162. HTT_RX_RING_FLAGS_MAC80211_HDR = 1 << 0,
  163. HTT_RX_RING_FLAGS_MSDU_PAYLOAD = 1 << 1,
  164. HTT_RX_RING_FLAGS_PPDU_START = 1 << 2,
  165. HTT_RX_RING_FLAGS_PPDU_END = 1 << 3,
  166. HTT_RX_RING_FLAGS_MPDU_START = 1 << 4,
  167. HTT_RX_RING_FLAGS_MPDU_END = 1 << 5,
  168. HTT_RX_RING_FLAGS_MSDU_START = 1 << 6,
  169. HTT_RX_RING_FLAGS_MSDU_END = 1 << 7,
  170. HTT_RX_RING_FLAGS_RX_ATTENTION = 1 << 8,
  171. HTT_RX_RING_FLAGS_FRAG_INFO = 1 << 9,
  172. HTT_RX_RING_FLAGS_UNICAST_RX = 1 << 10,
  173. HTT_RX_RING_FLAGS_MULTICAST_RX = 1 << 11,
  174. HTT_RX_RING_FLAGS_CTRL_RX = 1 << 12,
  175. HTT_RX_RING_FLAGS_MGMT_RX = 1 << 13,
  176. HTT_RX_RING_FLAGS_NULL_RX = 1 << 14,
  177. HTT_RX_RING_FLAGS_PHY_DATA_RX = 1 << 15
  178. };
  179. #define HTT_RX_RING_SIZE_MIN 128
  180. #define HTT_RX_RING_SIZE_MAX 2048
  181. struct htt_rx_ring_setup_ring {
  182. __le32 fw_idx_shadow_reg_paddr;
  183. __le32 rx_ring_base_paddr;
  184. __le16 rx_ring_len; /* in 4-byte words */
  185. __le16 rx_ring_bufsize; /* rx skb size - in bytes */
  186. __le16 flags; /* %HTT_RX_RING_FLAGS_ */
  187. __le16 fw_idx_init_val;
  188. /* the following offsets are in 4-byte units */
  189. __le16 mac80211_hdr_offset;
  190. __le16 msdu_payload_offset;
  191. __le16 ppdu_start_offset;
  192. __le16 ppdu_end_offset;
  193. __le16 mpdu_start_offset;
  194. __le16 mpdu_end_offset;
  195. __le16 msdu_start_offset;
  196. __le16 msdu_end_offset;
  197. __le16 rx_attention_offset;
  198. __le16 frag_info_offset;
  199. } __packed;
  200. struct htt_rx_ring_setup_hdr {
  201. u8 num_rings; /* supported values: 1, 2 */
  202. __le16 rsvd0;
  203. } __packed;
  204. struct htt_rx_ring_setup {
  205. struct htt_rx_ring_setup_hdr hdr;
  206. struct htt_rx_ring_setup_ring rings[0];
  207. } __packed;
  208. /*
  209. * htt_stats_req - request target to send specified statistics
  210. *
  211. * @msg_type: hardcoded %HTT_H2T_MSG_TYPE_STATS_REQ
  212. * @upload_types: see %htt_dbg_stats_type. this is 24bit field actually
  213. * so make sure its little-endian.
  214. * @reset_types: see %htt_dbg_stats_type. this is 24bit field actually
  215. * so make sure its little-endian.
  216. * @cfg_val: stat_type specific configuration
  217. * @stat_type: see %htt_dbg_stats_type
  218. * @cookie_lsb: used for confirmation message from target->host
  219. * @cookie_msb: ditto as %cookie
  220. */
  221. struct htt_stats_req {
  222. u8 upload_types[3];
  223. u8 rsvd0;
  224. u8 reset_types[3];
  225. struct {
  226. u8 mpdu_bytes;
  227. u8 mpdu_num_msdus;
  228. u8 msdu_bytes;
  229. } __packed;
  230. u8 stat_type;
  231. __le32 cookie_lsb;
  232. __le32 cookie_msb;
  233. } __packed;
  234. #define HTT_STATS_REQ_CFG_STAT_TYPE_INVALID 0xff
  235. /*
  236. * htt_oob_sync_req - request out-of-band sync
  237. *
  238. * The HTT SYNC tells the target to suspend processing of subsequent
  239. * HTT host-to-target messages until some other target agent locally
  240. * informs the target HTT FW that the current sync counter is equal to
  241. * or greater than (in a modulo sense) the sync counter specified in
  242. * the SYNC message.
  243. *
  244. * This allows other host-target components to synchronize their operation
  245. * with HTT, e.g. to ensure that tx frames don't get transmitted until a
  246. * security key has been downloaded to and activated by the target.
  247. * In the absence of any explicit synchronization counter value
  248. * specification, the target HTT FW will use zero as the default current
  249. * sync value.
  250. *
  251. * The HTT target FW will suspend its host->target message processing as long
  252. * as 0 < (in-band sync counter - out-of-band sync counter) & 0xff < 128.
  253. */
  254. struct htt_oob_sync_req {
  255. u8 sync_count;
  256. __le16 rsvd0;
  257. } __packed;
  258. struct htt_aggr_conf {
  259. u8 max_num_ampdu_subframes;
  260. /* amsdu_subframes is limited by 0x1F mask */
  261. u8 max_num_amsdu_subframes;
  262. } __packed;
  263. #define HTT_MGMT_FRM_HDR_DOWNLOAD_LEN 32
  264. struct htt_mgmt_tx_desc_qca99x0 {
  265. __le32 rate;
  266. } __packed;
  267. struct htt_mgmt_tx_desc {
  268. u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
  269. __le32 msdu_paddr;
  270. __le32 desc_id;
  271. __le32 len;
  272. __le32 vdev_id;
  273. u8 hdr[HTT_MGMT_FRM_HDR_DOWNLOAD_LEN];
  274. union {
  275. struct htt_mgmt_tx_desc_qca99x0 qca99x0;
  276. } __packed;
  277. } __packed;
  278. enum htt_mgmt_tx_status {
  279. HTT_MGMT_TX_STATUS_OK = 0,
  280. HTT_MGMT_TX_STATUS_RETRY = 1,
  281. HTT_MGMT_TX_STATUS_DROP = 2
  282. };
  283. /*=== target -> host messages ===============================================*/
  284. enum htt_main_t2h_msg_type {
  285. HTT_MAIN_T2H_MSG_TYPE_VERSION_CONF = 0x0,
  286. HTT_MAIN_T2H_MSG_TYPE_RX_IND = 0x1,
  287. HTT_MAIN_T2H_MSG_TYPE_RX_FLUSH = 0x2,
  288. HTT_MAIN_T2H_MSG_TYPE_PEER_MAP = 0x3,
  289. HTT_MAIN_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
  290. HTT_MAIN_T2H_MSG_TYPE_RX_ADDBA = 0x5,
  291. HTT_MAIN_T2H_MSG_TYPE_RX_DELBA = 0x6,
  292. HTT_MAIN_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
  293. HTT_MAIN_T2H_MSG_TYPE_PKTLOG = 0x8,
  294. HTT_MAIN_T2H_MSG_TYPE_STATS_CONF = 0x9,
  295. HTT_MAIN_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
  296. HTT_MAIN_T2H_MSG_TYPE_SEC_IND = 0xb,
  297. HTT_MAIN_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
  298. HTT_MAIN_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
  299. HTT_MAIN_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,
  300. HTT_MAIN_T2H_MSG_TYPE_RX_PN_IND = 0x10,
  301. HTT_MAIN_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,
  302. HTT_MAIN_T2H_MSG_TYPE_TEST,
  303. /* keep this last */
  304. HTT_MAIN_T2H_NUM_MSGS
  305. };
  306. enum htt_10x_t2h_msg_type {
  307. HTT_10X_T2H_MSG_TYPE_VERSION_CONF = 0x0,
  308. HTT_10X_T2H_MSG_TYPE_RX_IND = 0x1,
  309. HTT_10X_T2H_MSG_TYPE_RX_FLUSH = 0x2,
  310. HTT_10X_T2H_MSG_TYPE_PEER_MAP = 0x3,
  311. HTT_10X_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
  312. HTT_10X_T2H_MSG_TYPE_RX_ADDBA = 0x5,
  313. HTT_10X_T2H_MSG_TYPE_RX_DELBA = 0x6,
  314. HTT_10X_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
  315. HTT_10X_T2H_MSG_TYPE_PKTLOG = 0x8,
  316. HTT_10X_T2H_MSG_TYPE_STATS_CONF = 0x9,
  317. HTT_10X_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
  318. HTT_10X_T2H_MSG_TYPE_SEC_IND = 0xb,
  319. HTT_10X_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
  320. HTT_10X_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
  321. HTT_10X_T2H_MSG_TYPE_TEST = 0xe,
  322. HTT_10X_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,
  323. HTT_10X_T2H_MSG_TYPE_AGGR_CONF = 0x11,
  324. HTT_10X_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x12,
  325. HTT_10X_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0x13,
  326. /* keep this last */
  327. HTT_10X_T2H_NUM_MSGS
  328. };
  329. enum htt_tlv_t2h_msg_type {
  330. HTT_TLV_T2H_MSG_TYPE_VERSION_CONF = 0x0,
  331. HTT_TLV_T2H_MSG_TYPE_RX_IND = 0x1,
  332. HTT_TLV_T2H_MSG_TYPE_RX_FLUSH = 0x2,
  333. HTT_TLV_T2H_MSG_TYPE_PEER_MAP = 0x3,
  334. HTT_TLV_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
  335. HTT_TLV_T2H_MSG_TYPE_RX_ADDBA = 0x5,
  336. HTT_TLV_T2H_MSG_TYPE_RX_DELBA = 0x6,
  337. HTT_TLV_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
  338. HTT_TLV_T2H_MSG_TYPE_PKTLOG = 0x8,
  339. HTT_TLV_T2H_MSG_TYPE_STATS_CONF = 0x9,
  340. HTT_TLV_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
  341. HTT_TLV_T2H_MSG_TYPE_SEC_IND = 0xb,
  342. HTT_TLV_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc, /* deprecated */
  343. HTT_TLV_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
  344. HTT_TLV_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
  345. HTT_TLV_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0xf,
  346. HTT_TLV_T2H_MSG_TYPE_RX_PN_IND = 0x10,
  347. HTT_TLV_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x11,
  348. HTT_TLV_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND = 0x12,
  349. /* 0x13 reservd */
  350. HTT_TLV_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE = 0x14,
  351. HTT_TLV_T2H_MSG_TYPE_CHAN_CHANGE = 0x15,
  352. HTT_TLV_T2H_MSG_TYPE_RX_OFLD_PKT_ERR = 0x16,
  353. HTT_TLV_T2H_MSG_TYPE_TEST,
  354. /* keep this last */
  355. HTT_TLV_T2H_NUM_MSGS
  356. };
  357. enum htt_10_4_t2h_msg_type {
  358. HTT_10_4_T2H_MSG_TYPE_VERSION_CONF = 0x0,
  359. HTT_10_4_T2H_MSG_TYPE_RX_IND = 0x1,
  360. HTT_10_4_T2H_MSG_TYPE_RX_FLUSH = 0x2,
  361. HTT_10_4_T2H_MSG_TYPE_PEER_MAP = 0x3,
  362. HTT_10_4_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
  363. HTT_10_4_T2H_MSG_TYPE_RX_ADDBA = 0x5,
  364. HTT_10_4_T2H_MSG_TYPE_RX_DELBA = 0x6,
  365. HTT_10_4_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
  366. HTT_10_4_T2H_MSG_TYPE_PKTLOG = 0x8,
  367. HTT_10_4_T2H_MSG_TYPE_STATS_CONF = 0x9,
  368. HTT_10_4_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
  369. HTT_10_4_T2H_MSG_TYPE_SEC_IND = 0xb,
  370. HTT_10_4_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
  371. HTT_10_4_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
  372. HTT_10_4_T2H_MSG_TYPE_MGMT_TX_COMPL_IND = 0xe,
  373. HTT_10_4_T2H_MSG_TYPE_CHAN_CHANGE = 0xf,
  374. HTT_10_4_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND = 0x10,
  375. HTT_10_4_T2H_MSG_TYPE_RX_PN_IND = 0x11,
  376. HTT_10_4_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND = 0x12,
  377. HTT_10_4_T2H_MSG_TYPE_TEST = 0x13,
  378. HTT_10_4_T2H_MSG_TYPE_EN_STATS = 0x14,
  379. HTT_10_4_T2H_MSG_TYPE_AGGR_CONF = 0x15,
  380. HTT_10_4_T2H_MSG_TYPE_TX_FETCH_IND = 0x16,
  381. HTT_10_4_T2H_MSG_TYPE_TX_FETCH_CONFIRM = 0x17,
  382. HTT_10_4_T2H_MSG_TYPE_STATS_NOUPLOAD = 0x18,
  383. /* 0x19 to 0x2f are reserved */
  384. HTT_10_4_T2H_MSG_TYPE_TX_MODE_SWITCH_IND = 0x30,
  385. /* keep this last */
  386. HTT_10_4_T2H_NUM_MSGS
  387. };
  388. enum htt_t2h_msg_type {
  389. HTT_T2H_MSG_TYPE_VERSION_CONF,
  390. HTT_T2H_MSG_TYPE_RX_IND,
  391. HTT_T2H_MSG_TYPE_RX_FLUSH,
  392. HTT_T2H_MSG_TYPE_PEER_MAP,
  393. HTT_T2H_MSG_TYPE_PEER_UNMAP,
  394. HTT_T2H_MSG_TYPE_RX_ADDBA,
  395. HTT_T2H_MSG_TYPE_RX_DELBA,
  396. HTT_T2H_MSG_TYPE_TX_COMPL_IND,
  397. HTT_T2H_MSG_TYPE_PKTLOG,
  398. HTT_T2H_MSG_TYPE_STATS_CONF,
  399. HTT_T2H_MSG_TYPE_RX_FRAG_IND,
  400. HTT_T2H_MSG_TYPE_SEC_IND,
  401. HTT_T2H_MSG_TYPE_RC_UPDATE_IND,
  402. HTT_T2H_MSG_TYPE_TX_INSPECT_IND,
  403. HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION,
  404. HTT_T2H_MSG_TYPE_TX_CREDIT_UPDATE_IND,
  405. HTT_T2H_MSG_TYPE_RX_PN_IND,
  406. HTT_T2H_MSG_TYPE_RX_OFFLOAD_DELIVER_IND,
  407. HTT_T2H_MSG_TYPE_RX_IN_ORD_PADDR_IND,
  408. HTT_T2H_MSG_TYPE_WDI_IPA_OP_RESPONSE,
  409. HTT_T2H_MSG_TYPE_CHAN_CHANGE,
  410. HTT_T2H_MSG_TYPE_RX_OFLD_PKT_ERR,
  411. HTT_T2H_MSG_TYPE_AGGR_CONF,
  412. HTT_T2H_MSG_TYPE_STATS_NOUPLOAD,
  413. HTT_T2H_MSG_TYPE_TEST,
  414. HTT_T2H_MSG_TYPE_EN_STATS,
  415. HTT_T2H_MSG_TYPE_TX_FETCH_IND,
  416. HTT_T2H_MSG_TYPE_TX_FETCH_CONFIRM,
  417. HTT_T2H_MSG_TYPE_TX_MODE_SWITCH_IND,
  418. /* keep this last */
  419. HTT_T2H_NUM_MSGS
  420. };
  421. /*
  422. * htt_resp_hdr - header for target-to-host messages
  423. *
  424. * msg_type: see htt_t2h_msg_type
  425. */
  426. struct htt_resp_hdr {
  427. u8 msg_type;
  428. } __packed;
  429. #define HTT_RESP_HDR_MSG_TYPE_OFFSET 0
  430. #define HTT_RESP_HDR_MSG_TYPE_MASK 0xff
  431. #define HTT_RESP_HDR_MSG_TYPE_LSB 0
  432. /* htt_ver_resp - response sent for htt_ver_req */
  433. struct htt_ver_resp {
  434. u8 minor;
  435. u8 major;
  436. u8 rsvd0;
  437. } __packed;
  438. struct htt_mgmt_tx_completion {
  439. u8 rsvd0;
  440. u8 rsvd1;
  441. u8 rsvd2;
  442. __le32 desc_id;
  443. __le32 status;
  444. } __packed;
  445. #define HTT_RX_INDICATION_INFO0_EXT_TID_MASK (0x1F)
  446. #define HTT_RX_INDICATION_INFO0_EXT_TID_LSB (0)
  447. #define HTT_RX_INDICATION_INFO0_FLUSH_VALID (1 << 5)
  448. #define HTT_RX_INDICATION_INFO0_RELEASE_VALID (1 << 6)
  449. #define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_MASK 0x0000003F
  450. #define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_LSB 0
  451. #define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_MASK 0x00000FC0
  452. #define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_LSB 6
  453. #define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_MASK 0x0003F000
  454. #define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_LSB 12
  455. #define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_MASK 0x00FC0000
  456. #define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_LSB 18
  457. #define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_MASK 0xFF000000
  458. #define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_LSB 24
  459. struct htt_rx_indication_hdr {
  460. u8 info0; /* %HTT_RX_INDICATION_INFO0_ */
  461. __le16 peer_id;
  462. __le32 info1; /* %HTT_RX_INDICATION_INFO1_ */
  463. } __packed;
  464. #define HTT_RX_INDICATION_INFO0_PHY_ERR_VALID (1 << 0)
  465. #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_MASK (0x1E)
  466. #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_LSB (1)
  467. #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK (1 << 5)
  468. #define HTT_RX_INDICATION_INFO0_END_VALID (1 << 6)
  469. #define HTT_RX_INDICATION_INFO0_START_VALID (1 << 7)
  470. #define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_MASK 0x00FFFFFF
  471. #define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_LSB 0
  472. #define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_MASK 0xFF000000
  473. #define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_LSB 24
  474. #define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_MASK 0x00FFFFFF
  475. #define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_LSB 0
  476. #define HTT_RX_INDICATION_INFO2_SERVICE_MASK 0xFF000000
  477. #define HTT_RX_INDICATION_INFO2_SERVICE_LSB 24
  478. enum htt_rx_legacy_rate {
  479. HTT_RX_OFDM_48 = 0,
  480. HTT_RX_OFDM_24 = 1,
  481. HTT_RX_OFDM_12,
  482. HTT_RX_OFDM_6,
  483. HTT_RX_OFDM_54,
  484. HTT_RX_OFDM_36,
  485. HTT_RX_OFDM_18,
  486. HTT_RX_OFDM_9,
  487. /* long preamble */
  488. HTT_RX_CCK_11_LP = 0,
  489. HTT_RX_CCK_5_5_LP = 1,
  490. HTT_RX_CCK_2_LP,
  491. HTT_RX_CCK_1_LP,
  492. /* short preamble */
  493. HTT_RX_CCK_11_SP,
  494. HTT_RX_CCK_5_5_SP,
  495. HTT_RX_CCK_2_SP
  496. };
  497. enum htt_rx_legacy_rate_type {
  498. HTT_RX_LEGACY_RATE_OFDM = 0,
  499. HTT_RX_LEGACY_RATE_CCK
  500. };
  501. enum htt_rx_preamble_type {
  502. HTT_RX_LEGACY = 0x4,
  503. HTT_RX_HT = 0x8,
  504. HTT_RX_HT_WITH_TXBF = 0x9,
  505. HTT_RX_VHT = 0xC,
  506. HTT_RX_VHT_WITH_TXBF = 0xD,
  507. };
  508. /*
  509. * Fields: phy_err_valid, phy_err_code, tsf,
  510. * usec_timestamp, sub_usec_timestamp
  511. * ..are valid only if end_valid == 1.
  512. *
  513. * Fields: rssi_chains, legacy_rate_type,
  514. * legacy_rate_cck, preamble_type, service,
  515. * vht_sig_*
  516. * ..are valid only if start_valid == 1;
  517. */
  518. struct htt_rx_indication_ppdu {
  519. u8 combined_rssi;
  520. u8 sub_usec_timestamp;
  521. u8 phy_err_code;
  522. u8 info0; /* HTT_RX_INDICATION_INFO0_ */
  523. struct {
  524. u8 pri20_db;
  525. u8 ext20_db;
  526. u8 ext40_db;
  527. u8 ext80_db;
  528. } __packed rssi_chains[4];
  529. __le32 tsf;
  530. __le32 usec_timestamp;
  531. __le32 info1; /* HTT_RX_INDICATION_INFO1_ */
  532. __le32 info2; /* HTT_RX_INDICATION_INFO2_ */
  533. } __packed;
  534. enum htt_rx_mpdu_status {
  535. HTT_RX_IND_MPDU_STATUS_UNKNOWN = 0x0,
  536. HTT_RX_IND_MPDU_STATUS_OK,
  537. HTT_RX_IND_MPDU_STATUS_ERR_FCS,
  538. HTT_RX_IND_MPDU_STATUS_ERR_DUP,
  539. HTT_RX_IND_MPDU_STATUS_ERR_REPLAY,
  540. HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER,
  541. /* only accept EAPOL frames */
  542. HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER,
  543. HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC,
  544. /* Non-data in promiscous mode */
  545. HTT_RX_IND_MPDU_STATUS_MGMT_CTRL,
  546. HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR,
  547. HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR,
  548. HTT_RX_IND_MPDU_STATUS_MPDU_LENGTH_ERR,
  549. HTT_RX_IND_MPDU_STATUS_ENCRYPT_REQUIRED_ERR,
  550. HTT_RX_IND_MPDU_STATUS_PRIVACY_ERR,
  551. /*
  552. * MISC: discard for unspecified reasons.
  553. * Leave this enum value last.
  554. */
  555. HTT_RX_IND_MPDU_STATUS_ERR_MISC = 0xFF
  556. };
  557. struct htt_rx_indication_mpdu_range {
  558. u8 mpdu_count;
  559. u8 mpdu_range_status; /* %htt_rx_mpdu_status */
  560. u8 pad0;
  561. u8 pad1;
  562. } __packed;
  563. struct htt_rx_indication_prefix {
  564. __le16 fw_rx_desc_bytes;
  565. u8 pad0;
  566. u8 pad1;
  567. };
  568. struct htt_rx_indication {
  569. struct htt_rx_indication_hdr hdr;
  570. struct htt_rx_indication_ppdu ppdu;
  571. struct htt_rx_indication_prefix prefix;
  572. /*
  573. * the following fields are both dynamically sized, so
  574. * take care addressing them
  575. */
  576. /* the size of this is %fw_rx_desc_bytes */
  577. struct fw_rx_desc_base fw_desc;
  578. /*
  579. * %mpdu_ranges starts after &%prefix + roundup(%fw_rx_desc_bytes, 4)
  580. * and has %num_mpdu_ranges elements.
  581. */
  582. struct htt_rx_indication_mpdu_range mpdu_ranges[0];
  583. } __packed;
  584. static inline struct htt_rx_indication_mpdu_range *
  585. htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication *rx_ind)
  586. {
  587. void *ptr = rx_ind;
  588. ptr += sizeof(rx_ind->hdr)
  589. + sizeof(rx_ind->ppdu)
  590. + sizeof(rx_ind->prefix)
  591. + roundup(__le16_to_cpu(rx_ind->prefix.fw_rx_desc_bytes), 4);
  592. return ptr;
  593. }
  594. enum htt_rx_flush_mpdu_status {
  595. HTT_RX_FLUSH_MPDU_DISCARD = 0,
  596. HTT_RX_FLUSH_MPDU_REORDER = 1,
  597. };
  598. /*
  599. * htt_rx_flush - discard or reorder given range of mpdus
  600. *
  601. * Note: host must check if all sequence numbers between
  602. * [seq_num_start, seq_num_end-1] are valid.
  603. */
  604. struct htt_rx_flush {
  605. __le16 peer_id;
  606. u8 tid;
  607. u8 rsvd0;
  608. u8 mpdu_status; /* %htt_rx_flush_mpdu_status */
  609. u8 seq_num_start; /* it is 6 LSBs of 802.11 seq no */
  610. u8 seq_num_end; /* it is 6 LSBs of 802.11 seq no */
  611. };
  612. struct htt_rx_peer_map {
  613. u8 vdev_id;
  614. __le16 peer_id;
  615. u8 addr[6];
  616. u8 rsvd0;
  617. u8 rsvd1;
  618. } __packed;
  619. struct htt_rx_peer_unmap {
  620. u8 rsvd0;
  621. __le16 peer_id;
  622. } __packed;
  623. enum htt_security_types {
  624. HTT_SECURITY_NONE,
  625. HTT_SECURITY_WEP128,
  626. HTT_SECURITY_WEP104,
  627. HTT_SECURITY_WEP40,
  628. HTT_SECURITY_TKIP,
  629. HTT_SECURITY_TKIP_NOMIC,
  630. HTT_SECURITY_AES_CCMP,
  631. HTT_SECURITY_WAPI,
  632. HTT_NUM_SECURITY_TYPES /* keep this last! */
  633. };
  634. enum htt_security_flags {
  635. #define HTT_SECURITY_TYPE_MASK 0x7F
  636. #define HTT_SECURITY_TYPE_LSB 0
  637. HTT_SECURITY_IS_UNICAST = 1 << 7
  638. };
  639. struct htt_security_indication {
  640. union {
  641. /* dont use bitfields; undefined behaviour */
  642. u8 flags; /* %htt_security_flags */
  643. struct {
  644. u8 security_type:7, /* %htt_security_types */
  645. is_unicast:1;
  646. } __packed;
  647. } __packed;
  648. __le16 peer_id;
  649. u8 michael_key[8];
  650. u8 wapi_rsc[16];
  651. } __packed;
  652. #define HTT_RX_BA_INFO0_TID_MASK 0x000F
  653. #define HTT_RX_BA_INFO0_TID_LSB 0
  654. #define HTT_RX_BA_INFO0_PEER_ID_MASK 0xFFF0
  655. #define HTT_RX_BA_INFO0_PEER_ID_LSB 4
  656. struct htt_rx_addba {
  657. u8 window_size;
  658. __le16 info0; /* %HTT_RX_BA_INFO0_ */
  659. } __packed;
  660. struct htt_rx_delba {
  661. u8 rsvd0;
  662. __le16 info0; /* %HTT_RX_BA_INFO0_ */
  663. } __packed;
  664. enum htt_data_tx_status {
  665. HTT_DATA_TX_STATUS_OK = 0,
  666. HTT_DATA_TX_STATUS_DISCARD = 1,
  667. HTT_DATA_TX_STATUS_NO_ACK = 2,
  668. HTT_DATA_TX_STATUS_POSTPONE = 3, /* HL only */
  669. HTT_DATA_TX_STATUS_DOWNLOAD_FAIL = 128
  670. };
  671. enum htt_data_tx_flags {
  672. #define HTT_DATA_TX_STATUS_MASK 0x07
  673. #define HTT_DATA_TX_STATUS_LSB 0
  674. #define HTT_DATA_TX_TID_MASK 0x78
  675. #define HTT_DATA_TX_TID_LSB 3
  676. HTT_DATA_TX_TID_INVALID = 1 << 7
  677. };
  678. #define HTT_TX_COMPL_INV_MSDU_ID 0xFFFF
  679. struct htt_data_tx_completion {
  680. union {
  681. u8 flags;
  682. struct {
  683. u8 status:3,
  684. tid:4,
  685. tid_invalid:1;
  686. } __packed;
  687. } __packed;
  688. u8 num_msdus;
  689. u8 rsvd0;
  690. __le16 msdus[0]; /* variable length based on %num_msdus */
  691. } __packed;
  692. struct htt_tx_compl_ind_base {
  693. u32 hdr;
  694. u16 payload[1/*or more*/];
  695. } __packed;
  696. struct htt_rc_tx_done_params {
  697. u32 rate_code;
  698. u32 rate_code_flags;
  699. u32 flags;
  700. u32 num_enqued; /* 1 for non-AMPDU */
  701. u32 num_retries;
  702. u32 num_failed; /* for AMPDU */
  703. u32 ack_rssi;
  704. u32 time_stamp;
  705. u32 is_probe;
  706. };
  707. struct htt_rc_update {
  708. u8 vdev_id;
  709. __le16 peer_id;
  710. u8 addr[6];
  711. u8 num_elems;
  712. u8 rsvd0;
  713. struct htt_rc_tx_done_params params[0]; /* variable length %num_elems */
  714. } __packed;
  715. /* see htt_rx_indication for similar fields and descriptions */
  716. struct htt_rx_fragment_indication {
  717. union {
  718. u8 info0; /* %HTT_RX_FRAG_IND_INFO0_ */
  719. struct {
  720. u8 ext_tid:5,
  721. flush_valid:1;
  722. } __packed;
  723. } __packed;
  724. __le16 peer_id;
  725. __le32 info1; /* %HTT_RX_FRAG_IND_INFO1_ */
  726. __le16 fw_rx_desc_bytes;
  727. __le16 rsvd0;
  728. u8 fw_msdu_rx_desc[0];
  729. } __packed;
  730. #define HTT_RX_FRAG_IND_INFO0_EXT_TID_MASK 0x1F
  731. #define HTT_RX_FRAG_IND_INFO0_EXT_TID_LSB 0
  732. #define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_MASK 0x20
  733. #define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_LSB 5
  734. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_MASK 0x0000003F
  735. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_LSB 0
  736. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_MASK 0x00000FC0
  737. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_LSB 6
  738. struct htt_rx_pn_ind {
  739. __le16 peer_id;
  740. u8 tid;
  741. u8 seqno_start;
  742. u8 seqno_end;
  743. u8 pn_ie_count;
  744. u8 reserved;
  745. u8 pn_ies[0];
  746. } __packed;
  747. struct htt_rx_offload_msdu {
  748. __le16 msdu_len;
  749. __le16 peer_id;
  750. u8 vdev_id;
  751. u8 tid;
  752. u8 fw_desc;
  753. u8 payload[0];
  754. } __packed;
  755. struct htt_rx_offload_ind {
  756. u8 reserved;
  757. __le16 msdu_count;
  758. } __packed;
  759. struct htt_rx_in_ord_msdu_desc {
  760. __le32 msdu_paddr;
  761. __le16 msdu_len;
  762. u8 fw_desc;
  763. u8 reserved;
  764. } __packed;
  765. struct htt_rx_in_ord_ind {
  766. u8 info;
  767. __le16 peer_id;
  768. u8 vdev_id;
  769. u8 reserved;
  770. __le16 msdu_count;
  771. struct htt_rx_in_ord_msdu_desc msdu_descs[0];
  772. } __packed;
  773. #define HTT_RX_IN_ORD_IND_INFO_TID_MASK 0x0000001f
  774. #define HTT_RX_IN_ORD_IND_INFO_TID_LSB 0
  775. #define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_MASK 0x00000020
  776. #define HTT_RX_IN_ORD_IND_INFO_OFFLOAD_LSB 5
  777. #define HTT_RX_IN_ORD_IND_INFO_FRAG_MASK 0x00000040
  778. #define HTT_RX_IN_ORD_IND_INFO_FRAG_LSB 6
  779. /*
  780. * target -> host test message definition
  781. *
  782. * The following field definitions describe the format of the test
  783. * message sent from the target to the host.
  784. * The message consists of a 4-octet header, followed by a variable
  785. * number of 32-bit integer values, followed by a variable number
  786. * of 8-bit character values.
  787. *
  788. * |31 16|15 8|7 0|
  789. * |-----------------------------------------------------------|
  790. * | num chars | num ints | msg type |
  791. * |-----------------------------------------------------------|
  792. * | int 0 |
  793. * |-----------------------------------------------------------|
  794. * | int 1 |
  795. * |-----------------------------------------------------------|
  796. * | ... |
  797. * |-----------------------------------------------------------|
  798. * | char 3 | char 2 | char 1 | char 0 |
  799. * |-----------------------------------------------------------|
  800. * | | | ... | char 4 |
  801. * |-----------------------------------------------------------|
  802. * - MSG_TYPE
  803. * Bits 7:0
  804. * Purpose: identifies this as a test message
  805. * Value: HTT_MSG_TYPE_TEST
  806. * - NUM_INTS
  807. * Bits 15:8
  808. * Purpose: indicate how many 32-bit integers follow the message header
  809. * - NUM_CHARS
  810. * Bits 31:16
  811. * Purpose: indicate how many 8-bit charaters follow the series of integers
  812. */
  813. struct htt_rx_test {
  814. u8 num_ints;
  815. __le16 num_chars;
  816. /* payload consists of 2 lists:
  817. * a) num_ints * sizeof(__le32)
  818. * b) num_chars * sizeof(u8) aligned to 4bytes */
  819. u8 payload[0];
  820. } __packed;
  821. static inline __le32 *htt_rx_test_get_ints(struct htt_rx_test *rx_test)
  822. {
  823. return (__le32 *)rx_test->payload;
  824. }
  825. static inline u8 *htt_rx_test_get_chars(struct htt_rx_test *rx_test)
  826. {
  827. return rx_test->payload + (rx_test->num_ints * sizeof(__le32));
  828. }
  829. /*
  830. * target -> host packet log message
  831. *
  832. * The following field definitions describe the format of the packet log
  833. * message sent from the target to the host.
  834. * The message consists of a 4-octet header,followed by a variable number
  835. * of 32-bit character values.
  836. *
  837. * |31 24|23 16|15 8|7 0|
  838. * |-----------------------------------------------------------|
  839. * | | | | msg type |
  840. * |-----------------------------------------------------------|
  841. * | payload |
  842. * |-----------------------------------------------------------|
  843. * - MSG_TYPE
  844. * Bits 7:0
  845. * Purpose: identifies this as a test message
  846. * Value: HTT_MSG_TYPE_PACKETLOG
  847. */
  848. struct htt_pktlog_msg {
  849. u8 pad[3];
  850. u8 payload[0];
  851. } __packed;
  852. struct htt_dbg_stats_rx_reorder_stats {
  853. /* Non QoS MPDUs received */
  854. __le32 deliver_non_qos;
  855. /* MPDUs received in-order */
  856. __le32 deliver_in_order;
  857. /* Flush due to reorder timer expired */
  858. __le32 deliver_flush_timeout;
  859. /* Flush due to move out of window */
  860. __le32 deliver_flush_oow;
  861. /* Flush due to DELBA */
  862. __le32 deliver_flush_delba;
  863. /* MPDUs dropped due to FCS error */
  864. __le32 fcs_error;
  865. /* MPDUs dropped due to monitor mode non-data packet */
  866. __le32 mgmt_ctrl;
  867. /* MPDUs dropped due to invalid peer */
  868. __le32 invalid_peer;
  869. /* MPDUs dropped due to duplication (non aggregation) */
  870. __le32 dup_non_aggr;
  871. /* MPDUs dropped due to processed before */
  872. __le32 dup_past;
  873. /* MPDUs dropped due to duplicate in reorder queue */
  874. __le32 dup_in_reorder;
  875. /* Reorder timeout happened */
  876. __le32 reorder_timeout;
  877. /* invalid bar ssn */
  878. __le32 invalid_bar_ssn;
  879. /* reorder reset due to bar ssn */
  880. __le32 ssn_reset;
  881. };
  882. struct htt_dbg_stats_wal_tx_stats {
  883. /* Num HTT cookies queued to dispatch list */
  884. __le32 comp_queued;
  885. /* Num HTT cookies dispatched */
  886. __le32 comp_delivered;
  887. /* Num MSDU queued to WAL */
  888. __le32 msdu_enqued;
  889. /* Num MPDU queue to WAL */
  890. __le32 mpdu_enqued;
  891. /* Num MSDUs dropped by WMM limit */
  892. __le32 wmm_drop;
  893. /* Num Local frames queued */
  894. __le32 local_enqued;
  895. /* Num Local frames done */
  896. __le32 local_freed;
  897. /* Num queued to HW */
  898. __le32 hw_queued;
  899. /* Num PPDU reaped from HW */
  900. __le32 hw_reaped;
  901. /* Num underruns */
  902. __le32 underrun;
  903. /* Num PPDUs cleaned up in TX abort */
  904. __le32 tx_abort;
  905. /* Num MPDUs requed by SW */
  906. __le32 mpdus_requed;
  907. /* excessive retries */
  908. __le32 tx_ko;
  909. /* data hw rate code */
  910. __le32 data_rc;
  911. /* Scheduler self triggers */
  912. __le32 self_triggers;
  913. /* frames dropped due to excessive sw retries */
  914. __le32 sw_retry_failure;
  915. /* illegal rate phy errors */
  916. __le32 illgl_rate_phy_err;
  917. /* wal pdev continous xretry */
  918. __le32 pdev_cont_xretry;
  919. /* wal pdev continous xretry */
  920. __le32 pdev_tx_timeout;
  921. /* wal pdev resets */
  922. __le32 pdev_resets;
  923. __le32 phy_underrun;
  924. /* MPDU is more than txop limit */
  925. __le32 txop_ovf;
  926. } __packed;
  927. struct htt_dbg_stats_wal_rx_stats {
  928. /* Cnts any change in ring routing mid-ppdu */
  929. __le32 mid_ppdu_route_change;
  930. /* Total number of statuses processed */
  931. __le32 status_rcvd;
  932. /* Extra frags on rings 0-3 */
  933. __le32 r0_frags;
  934. __le32 r1_frags;
  935. __le32 r2_frags;
  936. __le32 r3_frags;
  937. /* MSDUs / MPDUs delivered to HTT */
  938. __le32 htt_msdus;
  939. __le32 htt_mpdus;
  940. /* MSDUs / MPDUs delivered to local stack */
  941. __le32 loc_msdus;
  942. __le32 loc_mpdus;
  943. /* AMSDUs that have more MSDUs than the status ring size */
  944. __le32 oversize_amsdu;
  945. /* Number of PHY errors */
  946. __le32 phy_errs;
  947. /* Number of PHY errors drops */
  948. __le32 phy_err_drop;
  949. /* Number of mpdu errors - FCS, MIC, ENC etc. */
  950. __le32 mpdu_errs;
  951. } __packed;
  952. struct htt_dbg_stats_wal_peer_stats {
  953. __le32 dummy; /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */
  954. } __packed;
  955. struct htt_dbg_stats_wal_pdev_txrx {
  956. struct htt_dbg_stats_wal_tx_stats tx_stats;
  957. struct htt_dbg_stats_wal_rx_stats rx_stats;
  958. struct htt_dbg_stats_wal_peer_stats peer_stats;
  959. } __packed;
  960. struct htt_dbg_stats_rx_rate_info {
  961. __le32 mcs[10];
  962. __le32 sgi[10];
  963. __le32 nss[4];
  964. __le32 stbc[10];
  965. __le32 bw[3];
  966. __le32 pream[6];
  967. __le32 ldpc;
  968. __le32 txbf;
  969. };
  970. /*
  971. * htt_dbg_stats_status -
  972. * present - The requested stats have been delivered in full.
  973. * This indicates that either the stats information was contained
  974. * in its entirety within this message, or else this message
  975. * completes the delivery of the requested stats info that was
  976. * partially delivered through earlier STATS_CONF messages.
  977. * partial - The requested stats have been delivered in part.
  978. * One or more subsequent STATS_CONF messages with the same
  979. * cookie value will be sent to deliver the remainder of the
  980. * information.
  981. * error - The requested stats could not be delivered, for example due
  982. * to a shortage of memory to construct a message holding the
  983. * requested stats.
  984. * invalid - The requested stat type is either not recognized, or the
  985. * target is configured to not gather the stats type in question.
  986. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  987. * series_done - This special value indicates that no further stats info
  988. * elements are present within a series of stats info elems
  989. * (within a stats upload confirmation message).
  990. */
  991. enum htt_dbg_stats_status {
  992. HTT_DBG_STATS_STATUS_PRESENT = 0,
  993. HTT_DBG_STATS_STATUS_PARTIAL = 1,
  994. HTT_DBG_STATS_STATUS_ERROR = 2,
  995. HTT_DBG_STATS_STATUS_INVALID = 3,
  996. HTT_DBG_STATS_STATUS_SERIES_DONE = 7
  997. };
  998. /*
  999. * target -> host statistics upload
  1000. *
  1001. * The following field definitions describe the format of the HTT target
  1002. * to host stats upload confirmation message.
  1003. * The message contains a cookie echoed from the HTT host->target stats
  1004. * upload request, which identifies which request the confirmation is
  1005. * for, and a series of tag-length-value stats information elements.
  1006. * The tag-length header for each stats info element also includes a
  1007. * status field, to indicate whether the request for the stat type in
  1008. * question was fully met, partially met, unable to be met, or invalid
  1009. * (if the stat type in question is disabled in the target).
  1010. * A special value of all 1's in this status field is used to indicate
  1011. * the end of the series of stats info elements.
  1012. *
  1013. *
  1014. * |31 16|15 8|7 5|4 0|
  1015. * |------------------------------------------------------------|
  1016. * | reserved | msg type |
  1017. * |------------------------------------------------------------|
  1018. * | cookie LSBs |
  1019. * |------------------------------------------------------------|
  1020. * | cookie MSBs |
  1021. * |------------------------------------------------------------|
  1022. * | stats entry length | reserved | S |stat type|
  1023. * |------------------------------------------------------------|
  1024. * | |
  1025. * | type-specific stats info |
  1026. * | |
  1027. * |------------------------------------------------------------|
  1028. * | stats entry length | reserved | S |stat type|
  1029. * |------------------------------------------------------------|
  1030. * | |
  1031. * | type-specific stats info |
  1032. * | |
  1033. * |------------------------------------------------------------|
  1034. * | n/a | reserved | 111 | n/a |
  1035. * |------------------------------------------------------------|
  1036. * Header fields:
  1037. * - MSG_TYPE
  1038. * Bits 7:0
  1039. * Purpose: identifies this is a statistics upload confirmation message
  1040. * Value: 0x9
  1041. * - COOKIE_LSBS
  1042. * Bits 31:0
  1043. * Purpose: Provide a mechanism to match a target->host stats confirmation
  1044. * message with its preceding host->target stats request message.
  1045. * Value: LSBs of the opaque cookie specified by the host-side requestor
  1046. * - COOKIE_MSBS
  1047. * Bits 31:0
  1048. * Purpose: Provide a mechanism to match a target->host stats confirmation
  1049. * message with its preceding host->target stats request message.
  1050. * Value: MSBs of the opaque cookie specified by the host-side requestor
  1051. *
  1052. * Stats Information Element tag-length header fields:
  1053. * - STAT_TYPE
  1054. * Bits 4:0
  1055. * Purpose: identifies the type of statistics info held in the
  1056. * following information element
  1057. * Value: htt_dbg_stats_type
  1058. * - STATUS
  1059. * Bits 7:5
  1060. * Purpose: indicate whether the requested stats are present
  1061. * Value: htt_dbg_stats_status, including a special value (0x7) to mark
  1062. * the completion of the stats entry series
  1063. * - LENGTH
  1064. * Bits 31:16
  1065. * Purpose: indicate the stats information size
  1066. * Value: This field specifies the number of bytes of stats information
  1067. * that follows the element tag-length header.
  1068. * It is expected but not required that this length is a multiple of
  1069. * 4 bytes. Even if the length is not an integer multiple of 4, the
  1070. * subsequent stats entry header will begin on a 4-byte aligned
  1071. * boundary.
  1072. */
  1073. #define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_MASK 0x1F
  1074. #define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_LSB 0
  1075. #define HTT_STATS_CONF_ITEM_INFO_STATUS_MASK 0xE0
  1076. #define HTT_STATS_CONF_ITEM_INFO_STATUS_LSB 5
  1077. struct htt_stats_conf_item {
  1078. union {
  1079. u8 info;
  1080. struct {
  1081. u8 stat_type:5; /* %HTT_DBG_STATS_ */
  1082. u8 status:3; /* %HTT_DBG_STATS_STATUS_ */
  1083. } __packed;
  1084. } __packed;
  1085. u8 pad;
  1086. __le16 length;
  1087. u8 payload[0]; /* roundup(length, 4) long */
  1088. } __packed;
  1089. struct htt_stats_conf {
  1090. u8 pad[3];
  1091. __le32 cookie_lsb;
  1092. __le32 cookie_msb;
  1093. /* each item has variable length! */
  1094. struct htt_stats_conf_item items[0];
  1095. } __packed;
  1096. static inline struct htt_stats_conf_item *htt_stats_conf_next_item(
  1097. const struct htt_stats_conf_item *item)
  1098. {
  1099. return (void *)item + sizeof(*item) + roundup(item->length, 4);
  1100. }
  1101. /*
  1102. * host -> target FRAG DESCRIPTOR/MSDU_EXT DESC bank
  1103. *
  1104. * The following field definitions describe the format of the HTT host
  1105. * to target frag_desc/msdu_ext bank configuration message.
  1106. * The message contains the based address and the min and max id of the
  1107. * MSDU_EXT/FRAG_DESC that will be used by the HTT to map MSDU DESC and
  1108. * MSDU_EXT/FRAG_DESC.
  1109. * HTT will use id in HTT descriptor instead sending the frag_desc_ptr.
  1110. * For QCA988X HW the firmware will use fragment_desc_ptr but in WIFI2.0
  1111. * the hardware does the mapping/translation.
  1112. *
  1113. * Total banks that can be configured is configured to 16.
  1114. *
  1115. * This should be called before any TX has be initiated by the HTT
  1116. *
  1117. * |31 16|15 8|7 5|4 0|
  1118. * |------------------------------------------------------------|
  1119. * | DESC_SIZE | NUM_BANKS | RES |SWP|pdev| msg type |
  1120. * |------------------------------------------------------------|
  1121. * | BANK0_BASE_ADDRESS |
  1122. * |------------------------------------------------------------|
  1123. * | ... |
  1124. * |------------------------------------------------------------|
  1125. * | BANK15_BASE_ADDRESS |
  1126. * |------------------------------------------------------------|
  1127. * | BANK0_MAX_ID | BANK0_MIN_ID |
  1128. * |------------------------------------------------------------|
  1129. * | ... |
  1130. * |------------------------------------------------------------|
  1131. * | BANK15_MAX_ID | BANK15_MIN_ID |
  1132. * |------------------------------------------------------------|
  1133. * Header fields:
  1134. * - MSG_TYPE
  1135. * Bits 7:0
  1136. * Value: 0x6
  1137. * - BANKx_BASE_ADDRESS
  1138. * Bits 31:0
  1139. * Purpose: Provide a mechanism to specify the base address of the MSDU_EXT
  1140. * bank physical/bus address.
  1141. * - BANKx_MIN_ID
  1142. * Bits 15:0
  1143. * Purpose: Provide a mechanism to specify the min index that needs to
  1144. * mapped.
  1145. * - BANKx_MAX_ID
  1146. * Bits 31:16
  1147. * Purpose: Provide a mechanism to specify the max index that needs to
  1148. *
  1149. */
  1150. struct htt_frag_desc_bank_id {
  1151. __le16 bank_min_id;
  1152. __le16 bank_max_id;
  1153. } __packed;
  1154. /* real is 16 but it wouldn't fit in the max htt message size
  1155. * so we use a conservatively safe value for now */
  1156. #define HTT_FRAG_DESC_BANK_MAX 4
  1157. #define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_MASK 0x03
  1158. #define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_LSB 0
  1159. #define HTT_FRAG_DESC_BANK_CFG_INFO_SWAP BIT(2)
  1160. #define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_VALID BIT(3)
  1161. #define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE_MASK BIT(4)
  1162. #define HTT_FRAG_DESC_BANK_CFG_INFO_Q_STATE_DEPTH_TYPE_LSB 4
  1163. enum htt_q_depth_type {
  1164. HTT_Q_DEPTH_TYPE_BYTES = 0,
  1165. HTT_Q_DEPTH_TYPE_MSDUS = 1,
  1166. };
  1167. #define HTT_TX_Q_STATE_NUM_PEERS (TARGET_10_4_NUM_QCACHE_PEERS_MAX + \
  1168. TARGET_10_4_NUM_VDEVS)
  1169. #define HTT_TX_Q_STATE_NUM_TIDS 8
  1170. #define HTT_TX_Q_STATE_ENTRY_SIZE 1
  1171. #define HTT_TX_Q_STATE_ENTRY_MULTIPLIER 0
  1172. /**
  1173. * htt_q_state_conf - part of htt_frag_desc_bank_cfg for host q state config
  1174. *
  1175. * Defines host q state format and behavior. See htt_q_state.
  1176. *
  1177. * @record_size: Defines the size of each host q entry in bytes. In practice
  1178. * however firmware (at least 10.4.3-00191) ignores this host
  1179. * configuration value and uses hardcoded value of 1.
  1180. * @record_multiplier: This is valid only when q depth type is MSDUs. It
  1181. * defines the exponent for the power of 2 multiplication.
  1182. */
  1183. struct htt_q_state_conf {
  1184. __le32 paddr;
  1185. __le16 num_peers;
  1186. __le16 num_tids;
  1187. u8 record_size;
  1188. u8 record_multiplier;
  1189. u8 pad[2];
  1190. } __packed;
  1191. struct htt_frag_desc_bank_cfg {
  1192. u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */
  1193. u8 num_banks;
  1194. u8 desc_size;
  1195. __le32 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];
  1196. struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];
  1197. struct htt_q_state_conf q_state;
  1198. } __packed;
  1199. #define HTT_TX_Q_STATE_ENTRY_COEFFICIENT 128
  1200. #define HTT_TX_Q_STATE_ENTRY_FACTOR_MASK 0x3f
  1201. #define HTT_TX_Q_STATE_ENTRY_FACTOR_LSB 0
  1202. #define HTT_TX_Q_STATE_ENTRY_EXP_MASK 0xc0
  1203. #define HTT_TX_Q_STATE_ENTRY_EXP_LSB 6
  1204. /**
  1205. * htt_q_state - shared between host and firmware via DMA
  1206. *
  1207. * This structure is used for the host to expose it's software queue state to
  1208. * firmware so that its rate control can schedule fetch requests for optimized
  1209. * performance. This is most notably used for MU-MIMO aggregation when multiple
  1210. * MU clients are connected.
  1211. *
  1212. * @count: Each element defines the host queue depth. When q depth type was
  1213. * configured as HTT_Q_DEPTH_TYPE_BYTES then each entry is defined as:
  1214. * FACTOR * 128 * 8^EXP (see HTT_TX_Q_STATE_ENTRY_FACTOR_MASK and
  1215. * HTT_TX_Q_STATE_ENTRY_EXP_MASK). When q depth type was configured as
  1216. * HTT_Q_DEPTH_TYPE_MSDUS the number of packets is scaled by 2 **
  1217. * record_multiplier (see htt_q_state_conf).
  1218. * @map: Used by firmware to quickly check which host queues are not empty. It
  1219. * is a bitmap simply saying.
  1220. * @seq: Used by firmware to quickly check if the host queues were updated
  1221. * since it last checked.
  1222. *
  1223. * FIXME: Is the q_state map[] size calculation really correct?
  1224. */
  1225. struct htt_q_state {
  1226. u8 count[HTT_TX_Q_STATE_NUM_TIDS][HTT_TX_Q_STATE_NUM_PEERS];
  1227. u32 map[HTT_TX_Q_STATE_NUM_TIDS][(HTT_TX_Q_STATE_NUM_PEERS + 31) / 32];
  1228. __le32 seq;
  1229. } __packed;
  1230. #define HTT_TX_FETCH_RECORD_INFO_PEER_ID_MASK 0x0fff
  1231. #define HTT_TX_FETCH_RECORD_INFO_PEER_ID_LSB 0
  1232. #define HTT_TX_FETCH_RECORD_INFO_TID_MASK 0xf000
  1233. #define HTT_TX_FETCH_RECORD_INFO_TID_LSB 12
  1234. struct htt_tx_fetch_record {
  1235. __le16 info; /* HTT_TX_FETCH_IND_RECORD_INFO_ */
  1236. __le16 num_msdus;
  1237. __le32 num_bytes;
  1238. } __packed;
  1239. struct htt_tx_fetch_ind {
  1240. u8 pad0;
  1241. __le16 fetch_seq_num;
  1242. __le32 token;
  1243. __le16 num_resp_ids;
  1244. __le16 num_records;
  1245. struct htt_tx_fetch_record records[0];
  1246. __le32 resp_ids[0]; /* ath10k_htt_get_tx_fetch_ind_resp_ids() */
  1247. } __packed;
  1248. static inline void *
  1249. ath10k_htt_get_tx_fetch_ind_resp_ids(struct htt_tx_fetch_ind *ind)
  1250. {
  1251. return (void *)&ind->records[le16_to_cpu(ind->num_records)];
  1252. }
  1253. struct htt_tx_fetch_resp {
  1254. u8 pad0;
  1255. __le16 resp_id;
  1256. __le16 fetch_seq_num;
  1257. __le16 num_records;
  1258. __le32 token;
  1259. struct htt_tx_fetch_record records[0];
  1260. } __packed;
  1261. struct htt_tx_fetch_confirm {
  1262. u8 pad0;
  1263. __le16 num_resp_ids;
  1264. __le32 resp_ids[0];
  1265. } __packed;
  1266. enum htt_tx_mode_switch_mode {
  1267. HTT_TX_MODE_SWITCH_PUSH = 0,
  1268. HTT_TX_MODE_SWITCH_PUSH_PULL = 1,
  1269. };
  1270. #define HTT_TX_MODE_SWITCH_IND_INFO0_ENABLE BIT(0)
  1271. #define HTT_TX_MODE_SWITCH_IND_INFO0_NUM_RECORDS_MASK 0xfffe
  1272. #define HTT_TX_MODE_SWITCH_IND_INFO0_NUM_RECORDS_LSB 1
  1273. #define HTT_TX_MODE_SWITCH_IND_INFO1_MODE_MASK 0x0003
  1274. #define HTT_TX_MODE_SWITCH_IND_INFO1_MODE_LSB 0
  1275. #define HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD_MASK 0xfffc
  1276. #define HTT_TX_MODE_SWITCH_IND_INFO1_THRESHOLD_LSB 2
  1277. #define HTT_TX_MODE_SWITCH_RECORD_INFO0_PEER_ID_MASK 0x0fff
  1278. #define HTT_TX_MODE_SWITCH_RECORD_INFO0_PEER_ID_LSB 0
  1279. #define HTT_TX_MODE_SWITCH_RECORD_INFO0_TID_MASK 0xf000
  1280. #define HTT_TX_MODE_SWITCH_RECORD_INFO0_TID_LSB 12
  1281. struct htt_tx_mode_switch_record {
  1282. __le16 info0; /* HTT_TX_MODE_SWITCH_RECORD_INFO0_ */
  1283. __le16 num_max_msdus;
  1284. } __packed;
  1285. struct htt_tx_mode_switch_ind {
  1286. u8 pad0;
  1287. __le16 info0; /* HTT_TX_MODE_SWITCH_IND_INFO0_ */
  1288. __le16 info1; /* HTT_TX_MODE_SWITCH_IND_INFO1_ */
  1289. u8 pad1[2];
  1290. struct htt_tx_mode_switch_record records[0];
  1291. } __packed;
  1292. struct htt_channel_change {
  1293. u8 pad[3];
  1294. __le32 freq;
  1295. __le32 center_freq1;
  1296. __le32 center_freq2;
  1297. __le32 phymode;
  1298. } __packed;
  1299. union htt_rx_pn_t {
  1300. /* WEP: 24-bit PN */
  1301. u32 pn24;
  1302. /* TKIP or CCMP: 48-bit PN */
  1303. u64 pn48;
  1304. /* WAPI: 128-bit PN */
  1305. u64 pn128[2];
  1306. };
  1307. struct htt_cmd {
  1308. struct htt_cmd_hdr hdr;
  1309. union {
  1310. struct htt_ver_req ver_req;
  1311. struct htt_mgmt_tx_desc mgmt_tx;
  1312. struct htt_data_tx_desc data_tx;
  1313. struct htt_rx_ring_setup rx_setup;
  1314. struct htt_stats_req stats_req;
  1315. struct htt_oob_sync_req oob_sync_req;
  1316. struct htt_aggr_conf aggr_conf;
  1317. struct htt_frag_desc_bank_cfg frag_desc_bank_cfg;
  1318. struct htt_tx_fetch_resp tx_fetch_resp;
  1319. };
  1320. } __packed;
  1321. struct htt_resp {
  1322. struct htt_resp_hdr hdr;
  1323. union {
  1324. struct htt_ver_resp ver_resp;
  1325. struct htt_mgmt_tx_completion mgmt_tx_completion;
  1326. struct htt_data_tx_completion data_tx_completion;
  1327. struct htt_rx_indication rx_ind;
  1328. struct htt_rx_fragment_indication rx_frag_ind;
  1329. struct htt_rx_peer_map peer_map;
  1330. struct htt_rx_peer_unmap peer_unmap;
  1331. struct htt_rx_flush rx_flush;
  1332. struct htt_rx_addba rx_addba;
  1333. struct htt_rx_delba rx_delba;
  1334. struct htt_security_indication security_indication;
  1335. struct htt_rc_update rc_update;
  1336. struct htt_rx_test rx_test;
  1337. struct htt_pktlog_msg pktlog_msg;
  1338. struct htt_stats_conf stats_conf;
  1339. struct htt_rx_pn_ind rx_pn_ind;
  1340. struct htt_rx_offload_ind rx_offload_ind;
  1341. struct htt_rx_in_ord_ind rx_in_ord_ind;
  1342. struct htt_tx_fetch_ind tx_fetch_ind;
  1343. struct htt_tx_fetch_confirm tx_fetch_confirm;
  1344. struct htt_tx_mode_switch_ind tx_mode_switch_ind;
  1345. struct htt_channel_change chan_change;
  1346. };
  1347. } __packed;
  1348. /*** host side structures follow ***/
  1349. struct htt_tx_done {
  1350. u16 msdu_id;
  1351. u16 status;
  1352. };
  1353. enum htt_tx_compl_state {
  1354. HTT_TX_COMPL_STATE_NONE,
  1355. HTT_TX_COMPL_STATE_ACK,
  1356. HTT_TX_COMPL_STATE_NOACK,
  1357. HTT_TX_COMPL_STATE_DISCARD,
  1358. };
  1359. struct htt_peer_map_event {
  1360. u8 vdev_id;
  1361. u16 peer_id;
  1362. u8 addr[ETH_ALEN];
  1363. };
  1364. struct htt_peer_unmap_event {
  1365. u16 peer_id;
  1366. };
  1367. struct ath10k_htt_txbuf {
  1368. struct htt_data_tx_desc_frag frags[2];
  1369. struct ath10k_htc_hdr htc_hdr;
  1370. struct htt_cmd_hdr cmd_hdr;
  1371. struct htt_data_tx_desc cmd_tx;
  1372. } __packed;
  1373. struct ath10k_htt {
  1374. struct ath10k *ar;
  1375. enum ath10k_htc_ep_id eid;
  1376. u8 target_version_major;
  1377. u8 target_version_minor;
  1378. struct completion target_version_received;
  1379. u8 max_num_amsdu;
  1380. u8 max_num_ampdu;
  1381. const enum htt_t2h_msg_type *t2h_msg_types;
  1382. u32 t2h_msg_types_max;
  1383. struct {
  1384. /*
  1385. * Ring of network buffer objects - This ring is
  1386. * used exclusively by the host SW. This ring
  1387. * mirrors the dev_addrs_ring that is shared
  1388. * between the host SW and the MAC HW. The host SW
  1389. * uses this netbufs ring to locate the network
  1390. * buffer objects whose data buffers the HW has
  1391. * filled.
  1392. */
  1393. struct sk_buff **netbufs_ring;
  1394. /* This is used only with firmware supporting IN_ORD_IND.
  1395. *
  1396. * With Full Rx Reorder the HTT Rx Ring is more of a temporary
  1397. * buffer ring from which buffer addresses are copied by the
  1398. * firmware to MAC Rx ring. Firmware then delivers IN_ORD_IND
  1399. * pointing to specific (re-ordered) buffers.
  1400. *
  1401. * FIXME: With kernel generic hashing functions there's a lot
  1402. * of hash collisions for sk_buffs.
  1403. */
  1404. bool in_ord_rx;
  1405. DECLARE_HASHTABLE(skb_table, 4);
  1406. /*
  1407. * Ring of buffer addresses -
  1408. * This ring holds the "physical" device address of the
  1409. * rx buffers the host SW provides for the MAC HW to
  1410. * fill.
  1411. */
  1412. __le32 *paddrs_ring;
  1413. /*
  1414. * Base address of ring, as a "physical" device address
  1415. * rather than a CPU address.
  1416. */
  1417. dma_addr_t base_paddr;
  1418. /* how many elems in the ring (power of 2) */
  1419. int size;
  1420. /* size - 1 */
  1421. unsigned size_mask;
  1422. /* how many rx buffers to keep in the ring */
  1423. int fill_level;
  1424. /* how many rx buffers (full+empty) are in the ring */
  1425. int fill_cnt;
  1426. /*
  1427. * alloc_idx - where HTT SW has deposited empty buffers
  1428. * This is allocated in consistent mem, so that the FW can
  1429. * read this variable, and program the HW's FW_IDX reg with
  1430. * the value of this shadow register.
  1431. */
  1432. struct {
  1433. __le32 *vaddr;
  1434. dma_addr_t paddr;
  1435. } alloc_idx;
  1436. /* where HTT SW has processed bufs filled by rx MAC DMA */
  1437. struct {
  1438. unsigned msdu_payld;
  1439. } sw_rd_idx;
  1440. /*
  1441. * refill_retry_timer - timer triggered when the ring is
  1442. * not refilled to the level expected
  1443. */
  1444. struct timer_list refill_retry_timer;
  1445. /* Protects access to all rx ring buffer state variables */
  1446. spinlock_t lock;
  1447. } rx_ring;
  1448. unsigned int prefetch_len;
  1449. /* Protects access to pending_tx, num_pending_tx */
  1450. spinlock_t tx_lock;
  1451. int max_num_pending_tx;
  1452. int num_pending_tx;
  1453. int num_pending_mgmt_tx;
  1454. struct idr pending_tx;
  1455. wait_queue_head_t empty_tx_wq;
  1456. /* FIFO for storing tx done status {ack, no-ack, discard} and msdu id */
  1457. DECLARE_KFIFO_PTR(txdone_fifo, struct htt_tx_done);
  1458. /* set if host-fw communication goes haywire
  1459. * used to avoid further failures */
  1460. bool rx_confused;
  1461. atomic_t num_mpdus_ready;
  1462. /* This is used to group tx/rx completions separately and process them
  1463. * in batches to reduce cache stalls */
  1464. struct tasklet_struct txrx_compl_task;
  1465. struct sk_buff_head rx_compl_q;
  1466. struct sk_buff_head rx_in_ord_compl_q;
  1467. struct sk_buff_head tx_fetch_ind_q;
  1468. /* rx_status template */
  1469. struct ieee80211_rx_status rx_status;
  1470. struct {
  1471. dma_addr_t paddr;
  1472. struct htt_msdu_ext_desc *vaddr;
  1473. } frag_desc;
  1474. struct {
  1475. dma_addr_t paddr;
  1476. struct ath10k_htt_txbuf *vaddr;
  1477. } txbuf;
  1478. struct {
  1479. bool enabled;
  1480. struct htt_q_state *vaddr;
  1481. dma_addr_t paddr;
  1482. u16 num_push_allowed;
  1483. u16 num_peers;
  1484. u16 num_tids;
  1485. enum htt_tx_mode_switch_mode mode;
  1486. enum htt_q_depth_type type;
  1487. } tx_q_state;
  1488. };
  1489. #define RX_HTT_HDR_STATUS_LEN 64
  1490. /* This structure layout is programmed via rx ring setup
  1491. * so that FW knows how to transfer the rx descriptor to the host.
  1492. * Buffers like this are placed on the rx ring. */
  1493. struct htt_rx_desc {
  1494. union {
  1495. /* This field is filled on the host using the msdu buffer
  1496. * from htt_rx_indication */
  1497. struct fw_rx_desc_base fw_desc;
  1498. u32 pad;
  1499. } __packed;
  1500. struct {
  1501. struct rx_attention attention;
  1502. struct rx_frag_info frag_info;
  1503. struct rx_mpdu_start mpdu_start;
  1504. struct rx_msdu_start msdu_start;
  1505. struct rx_msdu_end msdu_end;
  1506. struct rx_mpdu_end mpdu_end;
  1507. struct rx_ppdu_start ppdu_start;
  1508. struct rx_ppdu_end ppdu_end;
  1509. } __packed;
  1510. u8 rx_hdr_status[RX_HTT_HDR_STATUS_LEN];
  1511. u8 msdu_payload[0];
  1512. };
  1513. #define HTT_RX_DESC_ALIGN 8
  1514. #define HTT_MAC_ADDR_LEN 6
  1515. /*
  1516. * FIX THIS
  1517. * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,
  1518. * rounded up to a cache line size.
  1519. */
  1520. #define HTT_RX_BUF_SIZE 1920
  1521. #define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc))
  1522. /* Refill a bunch of RX buffers for each refill round so that FW/HW can handle
  1523. * aggregated traffic more nicely. */
  1524. #define ATH10K_HTT_MAX_NUM_REFILL 100
  1525. /*
  1526. * DMA_MAP expects the buffer to be an integral number of cache lines.
  1527. * Rather than checking the actual cache line size, this code makes a
  1528. * conservative estimate of what the cache line size could be.
  1529. */
  1530. #define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */
  1531. #define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)
  1532. /* These values are default in most firmware revisions and apparently are a
  1533. * sweet spot performance wise.
  1534. */
  1535. #define ATH10K_HTT_MAX_NUM_AMSDU_DEFAULT 3
  1536. #define ATH10K_HTT_MAX_NUM_AMPDU_DEFAULT 64
  1537. int ath10k_htt_connect(struct ath10k_htt *htt);
  1538. int ath10k_htt_init(struct ath10k *ar);
  1539. int ath10k_htt_setup(struct ath10k_htt *htt);
  1540. int ath10k_htt_tx_alloc(struct ath10k_htt *htt);
  1541. void ath10k_htt_tx_free(struct ath10k_htt *htt);
  1542. int ath10k_htt_rx_alloc(struct ath10k_htt *htt);
  1543. int ath10k_htt_rx_ring_refill(struct ath10k *ar);
  1544. void ath10k_htt_rx_free(struct ath10k_htt *htt);
  1545. void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);
  1546. void ath10k_htt_htc_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
  1547. bool ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
  1548. int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
  1549. int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie);
  1550. int ath10k_htt_send_frag_desc_bank_cfg(struct ath10k_htt *htt);
  1551. int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt);
  1552. int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
  1553. u8 max_subfrms_ampdu,
  1554. u8 max_subfrms_amsdu);
  1555. void ath10k_htt_hif_tx_complete(struct ath10k *ar, struct sk_buff *skb);
  1556. int ath10k_htt_tx_fetch_resp(struct ath10k *ar,
  1557. __le32 token,
  1558. __le16 fetch_seq_num,
  1559. struct htt_tx_fetch_record *records,
  1560. size_t num_records);
  1561. void ath10k_htt_tx_txq_update(struct ieee80211_hw *hw,
  1562. struct ieee80211_txq *txq);
  1563. void ath10k_htt_tx_txq_recalc(struct ieee80211_hw *hw,
  1564. struct ieee80211_txq *txq);
  1565. void ath10k_htt_tx_txq_sync(struct ath10k *ar);
  1566. void ath10k_htt_tx_dec_pending(struct ath10k_htt *htt);
  1567. int ath10k_htt_tx_inc_pending(struct ath10k_htt *htt);
  1568. void ath10k_htt_tx_mgmt_dec_pending(struct ath10k_htt *htt);
  1569. int ath10k_htt_tx_mgmt_inc_pending(struct ath10k_htt *htt, bool is_mgmt,
  1570. bool is_presp);
  1571. int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt, struct sk_buff *skb);
  1572. void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);
  1573. int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *);
  1574. int ath10k_htt_tx(struct ath10k_htt *htt,
  1575. enum ath10k_hw_txrx_mode txmode,
  1576. struct sk_buff *msdu);
  1577. void ath10k_htt_rx_pktlog_completion_handler(struct ath10k *ar,
  1578. struct sk_buff *skb);
  1579. #endif