htt.h 61 KB

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