htt.h 55 KB

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