htt.h 58 KB

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