htt.h 53 KB

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