htt.h 55 KB

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