htt.h 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  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 <net/mac80211.h>
  23. #include "htc.h"
  24. #include "rx_desc.h"
  25. enum htt_dbg_stats_type {
  26. HTT_DBG_STATS_WAL_PDEV_TXRX = 1 << 0,
  27. HTT_DBG_STATS_RX_REORDER = 1 << 1,
  28. HTT_DBG_STATS_RX_RATE_INFO = 1 << 2,
  29. HTT_DBG_STATS_TX_PPDU_LOG = 1 << 3,
  30. HTT_DBG_STATS_TX_RATE_INFO = 1 << 4,
  31. /* bits 5-23 currently reserved */
  32. HTT_DBG_NUM_STATS /* keep this last */
  33. };
  34. enum htt_h2t_msg_type { /* host-to-target */
  35. HTT_H2T_MSG_TYPE_VERSION_REQ = 0,
  36. HTT_H2T_MSG_TYPE_TX_FRM = 1,
  37. HTT_H2T_MSG_TYPE_RX_RING_CFG = 2,
  38. HTT_H2T_MSG_TYPE_STATS_REQ = 3,
  39. HTT_H2T_MSG_TYPE_SYNC = 4,
  40. HTT_H2T_MSG_TYPE_AGGR_CFG = 5,
  41. HTT_H2T_MSG_TYPE_FRAG_DESC_BANK_CFG = 6,
  42. /* This command is used for sending management frames in HTT < 3.0.
  43. * HTT >= 3.0 uses TX_FRM for everything. */
  44. HTT_H2T_MSG_TYPE_MGMT_TX = 7,
  45. HTT_H2T_NUM_MSGS /* keep this last */
  46. };
  47. struct htt_cmd_hdr {
  48. u8 msg_type;
  49. } __packed;
  50. struct htt_ver_req {
  51. u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
  52. } __packed;
  53. /*
  54. * HTT tx MSDU descriptor
  55. *
  56. * The HTT tx MSDU descriptor is created by the host HTT SW for each
  57. * tx MSDU. The HTT tx MSDU descriptor contains the information that
  58. * the target firmware needs for the FW's tx processing, particularly
  59. * for creating the HW msdu descriptor.
  60. * The same HTT tx descriptor is used for HL and LL systems, though
  61. * a few fields within the tx descriptor are used only by LL or
  62. * only by HL.
  63. * The HTT tx descriptor is defined in two manners: by a struct with
  64. * bitfields, and by a series of [dword offset, bit mask, bit shift]
  65. * definitions.
  66. * The target should use the struct def, for simplicitly and clarity,
  67. * but the host shall use the bit-mast + bit-shift defs, to be endian-
  68. * neutral. Specifically, the host shall use the get/set macros built
  69. * around the mask + shift defs.
  70. */
  71. struct htt_data_tx_desc_frag {
  72. __le32 paddr;
  73. __le32 len;
  74. } __packed;
  75. enum htt_data_tx_desc_flags0 {
  76. HTT_DATA_TX_DESC_FLAGS0_MAC_HDR_PRESENT = 1 << 0,
  77. HTT_DATA_TX_DESC_FLAGS0_NO_AGGR = 1 << 1,
  78. HTT_DATA_TX_DESC_FLAGS0_NO_ENCRYPT = 1 << 2,
  79. HTT_DATA_TX_DESC_FLAGS0_NO_CLASSIFY = 1 << 3,
  80. HTT_DATA_TX_DESC_FLAGS0_RSVD0 = 1 << 4
  81. #define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_MASK 0xE0
  82. #define HTT_DATA_TX_DESC_FLAGS0_PKT_TYPE_LSB 5
  83. };
  84. enum htt_data_tx_desc_flags1 {
  85. #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_BITS 6
  86. #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_MASK 0x003F
  87. #define HTT_DATA_TX_DESC_FLAGS1_VDEV_ID_LSB 0
  88. #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_BITS 5
  89. #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_MASK 0x07C0
  90. #define HTT_DATA_TX_DESC_FLAGS1_EXT_TID_LSB 6
  91. HTT_DATA_TX_DESC_FLAGS1_POSTPONED = 1 << 11,
  92. HTT_DATA_TX_DESC_FLAGS1_MORE_IN_BATCH = 1 << 12,
  93. HTT_DATA_TX_DESC_FLAGS1_CKSUM_L3_OFFLOAD = 1 << 13,
  94. HTT_DATA_TX_DESC_FLAGS1_CKSUM_L4_OFFLOAD = 1 << 14,
  95. HTT_DATA_TX_DESC_FLAGS1_RSVD1 = 1 << 15
  96. };
  97. enum htt_data_tx_ext_tid {
  98. HTT_DATA_TX_EXT_TID_NON_QOS_MCAST_BCAST = 16,
  99. HTT_DATA_TX_EXT_TID_MGMT = 17,
  100. HTT_DATA_TX_EXT_TID_INVALID = 31
  101. };
  102. #define HTT_INVALID_PEERID 0xFFFF
  103. /*
  104. * htt_data_tx_desc - used for data tx path
  105. *
  106. * Note: vdev_id irrelevant for pkt_type == raw and no_classify == 1.
  107. * ext_tid: for qos-data frames (0-15), see %HTT_DATA_TX_EXT_TID_
  108. * for special kinds of tids
  109. * postponed: only for HL hosts. indicates if this is a resend
  110. * (HL hosts manage queues on the host )
  111. * more_in_batch: only for HL hosts. indicates if more packets are
  112. * pending. this allows target to wait and aggregate
  113. * freq: 0 means home channel of given vdev. intended for offchannel
  114. */
  115. struct htt_data_tx_desc {
  116. u8 flags0; /* %HTT_DATA_TX_DESC_FLAGS0_ */
  117. __le16 flags1; /* %HTT_DATA_TX_DESC_FLAGS1_ */
  118. __le16 len;
  119. __le16 id;
  120. __le32 frags_paddr;
  121. __le16 peerid;
  122. __le16 freq;
  123. u8 prefetch[0]; /* start of frame, for FW classification engine */
  124. } __packed;
  125. enum htt_rx_ring_flags {
  126. HTT_RX_RING_FLAGS_MAC80211_HDR = 1 << 0,
  127. HTT_RX_RING_FLAGS_MSDU_PAYLOAD = 1 << 1,
  128. HTT_RX_RING_FLAGS_PPDU_START = 1 << 2,
  129. HTT_RX_RING_FLAGS_PPDU_END = 1 << 3,
  130. HTT_RX_RING_FLAGS_MPDU_START = 1 << 4,
  131. HTT_RX_RING_FLAGS_MPDU_END = 1 << 5,
  132. HTT_RX_RING_FLAGS_MSDU_START = 1 << 6,
  133. HTT_RX_RING_FLAGS_MSDU_END = 1 << 7,
  134. HTT_RX_RING_FLAGS_RX_ATTENTION = 1 << 8,
  135. HTT_RX_RING_FLAGS_FRAG_INFO = 1 << 9,
  136. HTT_RX_RING_FLAGS_UNICAST_RX = 1 << 10,
  137. HTT_RX_RING_FLAGS_MULTICAST_RX = 1 << 11,
  138. HTT_RX_RING_FLAGS_CTRL_RX = 1 << 12,
  139. HTT_RX_RING_FLAGS_MGMT_RX = 1 << 13,
  140. HTT_RX_RING_FLAGS_NULL_RX = 1 << 14,
  141. HTT_RX_RING_FLAGS_PHY_DATA_RX = 1 << 15
  142. };
  143. #define HTT_RX_RING_SIZE_MIN 128
  144. #define HTT_RX_RING_SIZE_MAX 2048
  145. struct htt_rx_ring_setup_ring {
  146. __le32 fw_idx_shadow_reg_paddr;
  147. __le32 rx_ring_base_paddr;
  148. __le16 rx_ring_len; /* in 4-byte words */
  149. __le16 rx_ring_bufsize; /* rx skb size - in bytes */
  150. __le16 flags; /* %HTT_RX_RING_FLAGS_ */
  151. __le16 fw_idx_init_val;
  152. /* the following offsets are in 4-byte units */
  153. __le16 mac80211_hdr_offset;
  154. __le16 msdu_payload_offset;
  155. __le16 ppdu_start_offset;
  156. __le16 ppdu_end_offset;
  157. __le16 mpdu_start_offset;
  158. __le16 mpdu_end_offset;
  159. __le16 msdu_start_offset;
  160. __le16 msdu_end_offset;
  161. __le16 rx_attention_offset;
  162. __le16 frag_info_offset;
  163. } __packed;
  164. struct htt_rx_ring_setup_hdr {
  165. u8 num_rings; /* supported values: 1, 2 */
  166. __le16 rsvd0;
  167. } __packed;
  168. struct htt_rx_ring_setup {
  169. struct htt_rx_ring_setup_hdr hdr;
  170. struct htt_rx_ring_setup_ring rings[0];
  171. } __packed;
  172. /*
  173. * htt_stats_req - request target to send specified statistics
  174. *
  175. * @msg_type: hardcoded %HTT_H2T_MSG_TYPE_STATS_REQ
  176. * @upload_types: see %htt_dbg_stats_type. this is 24bit field actually
  177. * so make sure its little-endian.
  178. * @reset_types: see %htt_dbg_stats_type. this is 24bit field actually
  179. * so make sure its little-endian.
  180. * @cfg_val: stat_type specific configuration
  181. * @stat_type: see %htt_dbg_stats_type
  182. * @cookie_lsb: used for confirmation message from target->host
  183. * @cookie_msb: ditto as %cookie
  184. */
  185. struct htt_stats_req {
  186. u8 upload_types[3];
  187. u8 rsvd0;
  188. u8 reset_types[3];
  189. struct {
  190. u8 mpdu_bytes;
  191. u8 mpdu_num_msdus;
  192. u8 msdu_bytes;
  193. } __packed;
  194. u8 stat_type;
  195. __le32 cookie_lsb;
  196. __le32 cookie_msb;
  197. } __packed;
  198. #define HTT_STATS_REQ_CFG_STAT_TYPE_INVALID 0xff
  199. /*
  200. * htt_oob_sync_req - request out-of-band sync
  201. *
  202. * The HTT SYNC tells the target to suspend processing of subsequent
  203. * HTT host-to-target messages until some other target agent locally
  204. * informs the target HTT FW that the current sync counter is equal to
  205. * or greater than (in a modulo sense) the sync counter specified in
  206. * the SYNC message.
  207. *
  208. * This allows other host-target components to synchronize their operation
  209. * with HTT, e.g. to ensure that tx frames don't get transmitted until a
  210. * security key has been downloaded to and activated by the target.
  211. * In the absence of any explicit synchronization counter value
  212. * specification, the target HTT FW will use zero as the default current
  213. * sync value.
  214. *
  215. * The HTT target FW will suspend its host->target message processing as long
  216. * as 0 < (in-band sync counter - out-of-band sync counter) & 0xff < 128.
  217. */
  218. struct htt_oob_sync_req {
  219. u8 sync_count;
  220. __le16 rsvd0;
  221. } __packed;
  222. struct htt_aggr_conf {
  223. u8 max_num_ampdu_subframes;
  224. /* amsdu_subframes is limited by 0x1F mask */
  225. u8 max_num_amsdu_subframes;
  226. } __packed;
  227. #define HTT_MGMT_FRM_HDR_DOWNLOAD_LEN 32
  228. struct htt_mgmt_tx_desc {
  229. u8 pad[sizeof(u32) - sizeof(struct htt_cmd_hdr)];
  230. __le32 msdu_paddr;
  231. __le32 desc_id;
  232. __le32 len;
  233. __le32 vdev_id;
  234. u8 hdr[HTT_MGMT_FRM_HDR_DOWNLOAD_LEN];
  235. } __packed;
  236. enum htt_mgmt_tx_status {
  237. HTT_MGMT_TX_STATUS_OK = 0,
  238. HTT_MGMT_TX_STATUS_RETRY = 1,
  239. HTT_MGMT_TX_STATUS_DROP = 2
  240. };
  241. /*=== target -> host messages ===============================================*/
  242. enum htt_t2h_msg_type {
  243. HTT_T2H_MSG_TYPE_VERSION_CONF = 0x0,
  244. HTT_T2H_MSG_TYPE_RX_IND = 0x1,
  245. HTT_T2H_MSG_TYPE_RX_FLUSH = 0x2,
  246. HTT_T2H_MSG_TYPE_PEER_MAP = 0x3,
  247. HTT_T2H_MSG_TYPE_PEER_UNMAP = 0x4,
  248. HTT_T2H_MSG_TYPE_RX_ADDBA = 0x5,
  249. HTT_T2H_MSG_TYPE_RX_DELBA = 0x6,
  250. HTT_T2H_MSG_TYPE_TX_COMPL_IND = 0x7,
  251. HTT_T2H_MSG_TYPE_PKTLOG = 0x8,
  252. HTT_T2H_MSG_TYPE_STATS_CONF = 0x9,
  253. HTT_T2H_MSG_TYPE_RX_FRAG_IND = 0xa,
  254. HTT_T2H_MSG_TYPE_SEC_IND = 0xb,
  255. HTT_T2H_MSG_TYPE_RC_UPDATE_IND = 0xc,
  256. HTT_T2H_MSG_TYPE_TX_INSPECT_IND = 0xd,
  257. HTT_T2H_MSG_TYPE_MGMT_TX_COMPLETION = 0xe,
  258. HTT_T2H_MSG_TYPE_TEST,
  259. /* keep this last */
  260. HTT_T2H_NUM_MSGS
  261. };
  262. /*
  263. * htt_resp_hdr - header for target-to-host messages
  264. *
  265. * msg_type: see htt_t2h_msg_type
  266. */
  267. struct htt_resp_hdr {
  268. u8 msg_type;
  269. } __packed;
  270. #define HTT_RESP_HDR_MSG_TYPE_OFFSET 0
  271. #define HTT_RESP_HDR_MSG_TYPE_MASK 0xff
  272. #define HTT_RESP_HDR_MSG_TYPE_LSB 0
  273. /* htt_ver_resp - response sent for htt_ver_req */
  274. struct htt_ver_resp {
  275. u8 minor;
  276. u8 major;
  277. u8 rsvd0;
  278. } __packed;
  279. struct htt_mgmt_tx_completion {
  280. u8 rsvd0;
  281. u8 rsvd1;
  282. u8 rsvd2;
  283. __le32 desc_id;
  284. __le32 status;
  285. } __packed;
  286. #define HTT_RX_INDICATION_INFO0_EXT_TID_MASK (0x3F)
  287. #define HTT_RX_INDICATION_INFO0_EXT_TID_LSB (0)
  288. #define HTT_RX_INDICATION_INFO0_FLUSH_VALID (1 << 6)
  289. #define HTT_RX_INDICATION_INFO0_RELEASE_VALID (1 << 7)
  290. #define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_MASK 0x0000003F
  291. #define HTT_RX_INDICATION_INFO1_FLUSH_START_SEQNO_LSB 0
  292. #define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_MASK 0x00000FC0
  293. #define HTT_RX_INDICATION_INFO1_FLUSH_END_SEQNO_LSB 6
  294. #define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_MASK 0x0003F000
  295. #define HTT_RX_INDICATION_INFO1_RELEASE_START_SEQNO_LSB 12
  296. #define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_MASK 0x00FC0000
  297. #define HTT_RX_INDICATION_INFO1_RELEASE_END_SEQNO_LSB 18
  298. #define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_MASK 0xFF000000
  299. #define HTT_RX_INDICATION_INFO1_NUM_MPDU_RANGES_LSB 24
  300. struct htt_rx_indication_hdr {
  301. u8 info0; /* %HTT_RX_INDICATION_INFO0_ */
  302. __le16 peer_id;
  303. __le32 info1; /* %HTT_RX_INDICATION_INFO1_ */
  304. } __packed;
  305. #define HTT_RX_INDICATION_INFO0_PHY_ERR_VALID (1 << 0)
  306. #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_MASK (0x1E)
  307. #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_LSB (1)
  308. #define HTT_RX_INDICATION_INFO0_LEGACY_RATE_CCK (1 << 5)
  309. #define HTT_RX_INDICATION_INFO0_END_VALID (1 << 6)
  310. #define HTT_RX_INDICATION_INFO0_START_VALID (1 << 7)
  311. #define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_MASK 0x00FFFFFF
  312. #define HTT_RX_INDICATION_INFO1_VHT_SIG_A1_LSB 0
  313. #define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_MASK 0xFF000000
  314. #define HTT_RX_INDICATION_INFO1_PREAMBLE_TYPE_LSB 24
  315. #define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_MASK 0x00FFFFFF
  316. #define HTT_RX_INDICATION_INFO2_VHT_SIG_A1_LSB 0
  317. #define HTT_RX_INDICATION_INFO2_SERVICE_MASK 0xFF000000
  318. #define HTT_RX_INDICATION_INFO2_SERVICE_LSB 24
  319. enum htt_rx_legacy_rate {
  320. HTT_RX_OFDM_48 = 0,
  321. HTT_RX_OFDM_24 = 1,
  322. HTT_RX_OFDM_12,
  323. HTT_RX_OFDM_6,
  324. HTT_RX_OFDM_54,
  325. HTT_RX_OFDM_36,
  326. HTT_RX_OFDM_18,
  327. HTT_RX_OFDM_9,
  328. /* long preamble */
  329. HTT_RX_CCK_11_LP = 0,
  330. HTT_RX_CCK_5_5_LP = 1,
  331. HTT_RX_CCK_2_LP,
  332. HTT_RX_CCK_1_LP,
  333. /* short preamble */
  334. HTT_RX_CCK_11_SP,
  335. HTT_RX_CCK_5_5_SP,
  336. HTT_RX_CCK_2_SP
  337. };
  338. enum htt_rx_legacy_rate_type {
  339. HTT_RX_LEGACY_RATE_OFDM = 0,
  340. HTT_RX_LEGACY_RATE_CCK
  341. };
  342. enum htt_rx_preamble_type {
  343. HTT_RX_LEGACY = 0x4,
  344. HTT_RX_HT = 0x8,
  345. HTT_RX_HT_WITH_TXBF = 0x9,
  346. HTT_RX_VHT = 0xC,
  347. HTT_RX_VHT_WITH_TXBF = 0xD,
  348. };
  349. /*
  350. * Fields: phy_err_valid, phy_err_code, tsf,
  351. * usec_timestamp, sub_usec_timestamp
  352. * ..are valid only if end_valid == 1.
  353. *
  354. * Fields: rssi_chains, legacy_rate_type,
  355. * legacy_rate_cck, preamble_type, service,
  356. * vht_sig_*
  357. * ..are valid only if start_valid == 1;
  358. */
  359. struct htt_rx_indication_ppdu {
  360. u8 combined_rssi;
  361. u8 sub_usec_timestamp;
  362. u8 phy_err_code;
  363. u8 info0; /* HTT_RX_INDICATION_INFO0_ */
  364. struct {
  365. u8 pri20_db;
  366. u8 ext20_db;
  367. u8 ext40_db;
  368. u8 ext80_db;
  369. } __packed rssi_chains[4];
  370. __le32 tsf;
  371. __le32 usec_timestamp;
  372. __le32 info1; /* HTT_RX_INDICATION_INFO1_ */
  373. __le32 info2; /* HTT_RX_INDICATION_INFO2_ */
  374. } __packed;
  375. enum htt_rx_mpdu_status {
  376. HTT_RX_IND_MPDU_STATUS_UNKNOWN = 0x0,
  377. HTT_RX_IND_MPDU_STATUS_OK,
  378. HTT_RX_IND_MPDU_STATUS_ERR_FCS,
  379. HTT_RX_IND_MPDU_STATUS_ERR_DUP,
  380. HTT_RX_IND_MPDU_STATUS_ERR_REPLAY,
  381. HTT_RX_IND_MPDU_STATUS_ERR_INV_PEER,
  382. /* only accept EAPOL frames */
  383. HTT_RX_IND_MPDU_STATUS_UNAUTH_PEER,
  384. HTT_RX_IND_MPDU_STATUS_OUT_OF_SYNC,
  385. /* Non-data in promiscous mode */
  386. HTT_RX_IND_MPDU_STATUS_MGMT_CTRL,
  387. HTT_RX_IND_MPDU_STATUS_TKIP_MIC_ERR,
  388. HTT_RX_IND_MPDU_STATUS_DECRYPT_ERR,
  389. HTT_RX_IND_MPDU_STATUS_MPDU_LENGTH_ERR,
  390. HTT_RX_IND_MPDU_STATUS_ENCRYPT_REQUIRED_ERR,
  391. HTT_RX_IND_MPDU_STATUS_PRIVACY_ERR,
  392. /*
  393. * MISC: discard for unspecified reasons.
  394. * Leave this enum value last.
  395. */
  396. HTT_RX_IND_MPDU_STATUS_ERR_MISC = 0xFF
  397. };
  398. struct htt_rx_indication_mpdu_range {
  399. u8 mpdu_count;
  400. u8 mpdu_range_status; /* %htt_rx_mpdu_status */
  401. u8 pad0;
  402. u8 pad1;
  403. } __packed;
  404. struct htt_rx_indication_prefix {
  405. __le16 fw_rx_desc_bytes;
  406. u8 pad0;
  407. u8 pad1;
  408. };
  409. struct htt_rx_indication {
  410. struct htt_rx_indication_hdr hdr;
  411. struct htt_rx_indication_ppdu ppdu;
  412. struct htt_rx_indication_prefix prefix;
  413. /*
  414. * the following fields are both dynamically sized, so
  415. * take care addressing them
  416. */
  417. /* the size of this is %fw_rx_desc_bytes */
  418. struct fw_rx_desc_base fw_desc;
  419. /*
  420. * %mpdu_ranges starts after &%prefix + roundup(%fw_rx_desc_bytes, 4)
  421. * and has %num_mpdu_ranges elements.
  422. */
  423. struct htt_rx_indication_mpdu_range mpdu_ranges[0];
  424. } __packed;
  425. static inline struct htt_rx_indication_mpdu_range *
  426. htt_rx_ind_get_mpdu_ranges(struct htt_rx_indication *rx_ind)
  427. {
  428. void *ptr = rx_ind;
  429. ptr += sizeof(rx_ind->hdr)
  430. + sizeof(rx_ind->ppdu)
  431. + sizeof(rx_ind->prefix)
  432. + roundup(__le16_to_cpu(rx_ind->prefix.fw_rx_desc_bytes), 4);
  433. return ptr;
  434. }
  435. enum htt_rx_flush_mpdu_status {
  436. HTT_RX_FLUSH_MPDU_DISCARD = 0,
  437. HTT_RX_FLUSH_MPDU_REORDER = 1,
  438. };
  439. /*
  440. * htt_rx_flush - discard or reorder given range of mpdus
  441. *
  442. * Note: host must check if all sequence numbers between
  443. * [seq_num_start, seq_num_end-1] are valid.
  444. */
  445. struct htt_rx_flush {
  446. __le16 peer_id;
  447. u8 tid;
  448. u8 rsvd0;
  449. u8 mpdu_status; /* %htt_rx_flush_mpdu_status */
  450. u8 seq_num_start; /* it is 6 LSBs of 802.11 seq no */
  451. u8 seq_num_end; /* it is 6 LSBs of 802.11 seq no */
  452. };
  453. struct htt_rx_peer_map {
  454. u8 vdev_id;
  455. __le16 peer_id;
  456. u8 addr[6];
  457. u8 rsvd0;
  458. u8 rsvd1;
  459. } __packed;
  460. struct htt_rx_peer_unmap {
  461. u8 rsvd0;
  462. __le16 peer_id;
  463. } __packed;
  464. enum htt_security_types {
  465. HTT_SECURITY_NONE,
  466. HTT_SECURITY_WEP128,
  467. HTT_SECURITY_WEP104,
  468. HTT_SECURITY_WEP40,
  469. HTT_SECURITY_TKIP,
  470. HTT_SECURITY_TKIP_NOMIC,
  471. HTT_SECURITY_AES_CCMP,
  472. HTT_SECURITY_WAPI,
  473. HTT_NUM_SECURITY_TYPES /* keep this last! */
  474. };
  475. enum htt_security_flags {
  476. #define HTT_SECURITY_TYPE_MASK 0x7F
  477. #define HTT_SECURITY_TYPE_LSB 0
  478. HTT_SECURITY_IS_UNICAST = 1 << 7
  479. };
  480. struct htt_security_indication {
  481. union {
  482. /* dont use bitfields; undefined behaviour */
  483. u8 flags; /* %htt_security_flags */
  484. struct {
  485. u8 security_type:7, /* %htt_security_types */
  486. is_unicast:1;
  487. } __packed;
  488. } __packed;
  489. __le16 peer_id;
  490. u8 michael_key[8];
  491. u8 wapi_rsc[16];
  492. } __packed;
  493. #define HTT_RX_BA_INFO0_TID_MASK 0x000F
  494. #define HTT_RX_BA_INFO0_TID_LSB 0
  495. #define HTT_RX_BA_INFO0_PEER_ID_MASK 0xFFF0
  496. #define HTT_RX_BA_INFO0_PEER_ID_LSB 4
  497. struct htt_rx_addba {
  498. u8 window_size;
  499. __le16 info0; /* %HTT_RX_BA_INFO0_ */
  500. } __packed;
  501. struct htt_rx_delba {
  502. u8 rsvd0;
  503. __le16 info0; /* %HTT_RX_BA_INFO0_ */
  504. } __packed;
  505. enum htt_data_tx_status {
  506. HTT_DATA_TX_STATUS_OK = 0,
  507. HTT_DATA_TX_STATUS_DISCARD = 1,
  508. HTT_DATA_TX_STATUS_NO_ACK = 2,
  509. HTT_DATA_TX_STATUS_POSTPONE = 3, /* HL only */
  510. HTT_DATA_TX_STATUS_DOWNLOAD_FAIL = 128
  511. };
  512. enum htt_data_tx_flags {
  513. #define HTT_DATA_TX_STATUS_MASK 0x07
  514. #define HTT_DATA_TX_STATUS_LSB 0
  515. #define HTT_DATA_TX_TID_MASK 0x78
  516. #define HTT_DATA_TX_TID_LSB 3
  517. HTT_DATA_TX_TID_INVALID = 1 << 7
  518. };
  519. #define HTT_TX_COMPL_INV_MSDU_ID 0xFFFF
  520. struct htt_data_tx_completion {
  521. union {
  522. u8 flags;
  523. struct {
  524. u8 status:3,
  525. tid:4,
  526. tid_invalid:1;
  527. } __packed;
  528. } __packed;
  529. u8 num_msdus;
  530. u8 rsvd0;
  531. __le16 msdus[0]; /* variable length based on %num_msdus */
  532. } __packed;
  533. struct htt_tx_compl_ind_base {
  534. u32 hdr;
  535. u16 payload[1/*or more*/];
  536. } __packed;
  537. struct htt_rc_tx_done_params {
  538. u32 rate_code;
  539. u32 rate_code_flags;
  540. u32 flags;
  541. u32 num_enqued; /* 1 for non-AMPDU */
  542. u32 num_retries;
  543. u32 num_failed; /* for AMPDU */
  544. u32 ack_rssi;
  545. u32 time_stamp;
  546. u32 is_probe;
  547. };
  548. struct htt_rc_update {
  549. u8 vdev_id;
  550. __le16 peer_id;
  551. u8 addr[6];
  552. u8 num_elems;
  553. u8 rsvd0;
  554. struct htt_rc_tx_done_params params[0]; /* variable length %num_elems */
  555. } __packed;
  556. /* see htt_rx_indication for similar fields and descriptions */
  557. struct htt_rx_fragment_indication {
  558. union {
  559. u8 info0; /* %HTT_RX_FRAG_IND_INFO0_ */
  560. struct {
  561. u8 ext_tid:5,
  562. flush_valid:1;
  563. } __packed;
  564. } __packed;
  565. __le16 peer_id;
  566. __le32 info1; /* %HTT_RX_FRAG_IND_INFO1_ */
  567. __le16 fw_rx_desc_bytes;
  568. __le16 rsvd0;
  569. u8 fw_msdu_rx_desc[0];
  570. } __packed;
  571. #define HTT_RX_FRAG_IND_INFO0_EXT_TID_MASK 0x1F
  572. #define HTT_RX_FRAG_IND_INFO0_EXT_TID_LSB 0
  573. #define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_MASK 0x20
  574. #define HTT_RX_FRAG_IND_INFO0_FLUSH_VALID_LSB 5
  575. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_MASK 0x0000003F
  576. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_START_LSB 0
  577. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_MASK 0x00000FC0
  578. #define HTT_RX_FRAG_IND_INFO1_FLUSH_SEQ_NUM_END_LSB 6
  579. /*
  580. * target -> host test message definition
  581. *
  582. * The following field definitions describe the format of the test
  583. * message sent from the target to the host.
  584. * The message consists of a 4-octet header, followed by a variable
  585. * number of 32-bit integer values, followed by a variable number
  586. * of 8-bit character values.
  587. *
  588. * |31 16|15 8|7 0|
  589. * |-----------------------------------------------------------|
  590. * | num chars | num ints | msg type |
  591. * |-----------------------------------------------------------|
  592. * | int 0 |
  593. * |-----------------------------------------------------------|
  594. * | int 1 |
  595. * |-----------------------------------------------------------|
  596. * | ... |
  597. * |-----------------------------------------------------------|
  598. * | char 3 | char 2 | char 1 | char 0 |
  599. * |-----------------------------------------------------------|
  600. * | | | ... | char 4 |
  601. * |-----------------------------------------------------------|
  602. * - MSG_TYPE
  603. * Bits 7:0
  604. * Purpose: identifies this as a test message
  605. * Value: HTT_MSG_TYPE_TEST
  606. * - NUM_INTS
  607. * Bits 15:8
  608. * Purpose: indicate how many 32-bit integers follow the message header
  609. * - NUM_CHARS
  610. * Bits 31:16
  611. * Purpose: indicate how many 8-bit charaters follow the series of integers
  612. */
  613. struct htt_rx_test {
  614. u8 num_ints;
  615. __le16 num_chars;
  616. /* payload consists of 2 lists:
  617. * a) num_ints * sizeof(__le32)
  618. * b) num_chars * sizeof(u8) aligned to 4bytes */
  619. u8 payload[0];
  620. } __packed;
  621. static inline __le32 *htt_rx_test_get_ints(struct htt_rx_test *rx_test)
  622. {
  623. return (__le32 *)rx_test->payload;
  624. }
  625. static inline u8 *htt_rx_test_get_chars(struct htt_rx_test *rx_test)
  626. {
  627. return rx_test->payload + (rx_test->num_ints * sizeof(__le32));
  628. }
  629. /*
  630. * target -> host packet log message
  631. *
  632. * The following field definitions describe the format of the packet log
  633. * message sent from the target to the host.
  634. * The message consists of a 4-octet header,followed by a variable number
  635. * of 32-bit character values.
  636. *
  637. * |31 24|23 16|15 8|7 0|
  638. * |-----------------------------------------------------------|
  639. * | | | | msg type |
  640. * |-----------------------------------------------------------|
  641. * | payload |
  642. * |-----------------------------------------------------------|
  643. * - MSG_TYPE
  644. * Bits 7:0
  645. * Purpose: identifies this as a test message
  646. * Value: HTT_MSG_TYPE_PACKETLOG
  647. */
  648. struct htt_pktlog_msg {
  649. u8 pad[3];
  650. u8 payload[0];
  651. } __packed;
  652. struct htt_dbg_stats_rx_reorder_stats {
  653. /* Non QoS MPDUs received */
  654. __le32 deliver_non_qos;
  655. /* MPDUs received in-order */
  656. __le32 deliver_in_order;
  657. /* Flush due to reorder timer expired */
  658. __le32 deliver_flush_timeout;
  659. /* Flush due to move out of window */
  660. __le32 deliver_flush_oow;
  661. /* Flush due to DELBA */
  662. __le32 deliver_flush_delba;
  663. /* MPDUs dropped due to FCS error */
  664. __le32 fcs_error;
  665. /* MPDUs dropped due to monitor mode non-data packet */
  666. __le32 mgmt_ctrl;
  667. /* MPDUs dropped due to invalid peer */
  668. __le32 invalid_peer;
  669. /* MPDUs dropped due to duplication (non aggregation) */
  670. __le32 dup_non_aggr;
  671. /* MPDUs dropped due to processed before */
  672. __le32 dup_past;
  673. /* MPDUs dropped due to duplicate in reorder queue */
  674. __le32 dup_in_reorder;
  675. /* Reorder timeout happened */
  676. __le32 reorder_timeout;
  677. /* invalid bar ssn */
  678. __le32 invalid_bar_ssn;
  679. /* reorder reset due to bar ssn */
  680. __le32 ssn_reset;
  681. };
  682. struct htt_dbg_stats_wal_tx_stats {
  683. /* Num HTT cookies queued to dispatch list */
  684. __le32 comp_queued;
  685. /* Num HTT cookies dispatched */
  686. __le32 comp_delivered;
  687. /* Num MSDU queued to WAL */
  688. __le32 msdu_enqued;
  689. /* Num MPDU queue to WAL */
  690. __le32 mpdu_enqued;
  691. /* Num MSDUs dropped by WMM limit */
  692. __le32 wmm_drop;
  693. /* Num Local frames queued */
  694. __le32 local_enqued;
  695. /* Num Local frames done */
  696. __le32 local_freed;
  697. /* Num queued to HW */
  698. __le32 hw_queued;
  699. /* Num PPDU reaped from HW */
  700. __le32 hw_reaped;
  701. /* Num underruns */
  702. __le32 underrun;
  703. /* Num PPDUs cleaned up in TX abort */
  704. __le32 tx_abort;
  705. /* Num MPDUs requed by SW */
  706. __le32 mpdus_requed;
  707. /* excessive retries */
  708. __le32 tx_ko;
  709. /* data hw rate code */
  710. __le32 data_rc;
  711. /* Scheduler self triggers */
  712. __le32 self_triggers;
  713. /* frames dropped due to excessive sw retries */
  714. __le32 sw_retry_failure;
  715. /* illegal rate phy errors */
  716. __le32 illgl_rate_phy_err;
  717. /* wal pdev continous xretry */
  718. __le32 pdev_cont_xretry;
  719. /* wal pdev continous xretry */
  720. __le32 pdev_tx_timeout;
  721. /* wal pdev resets */
  722. __le32 pdev_resets;
  723. __le32 phy_underrun;
  724. /* MPDU is more than txop limit */
  725. __le32 txop_ovf;
  726. } __packed;
  727. struct htt_dbg_stats_wal_rx_stats {
  728. /* Cnts any change in ring routing mid-ppdu */
  729. __le32 mid_ppdu_route_change;
  730. /* Total number of statuses processed */
  731. __le32 status_rcvd;
  732. /* Extra frags on rings 0-3 */
  733. __le32 r0_frags;
  734. __le32 r1_frags;
  735. __le32 r2_frags;
  736. __le32 r3_frags;
  737. /* MSDUs / MPDUs delivered to HTT */
  738. __le32 htt_msdus;
  739. __le32 htt_mpdus;
  740. /* MSDUs / MPDUs delivered to local stack */
  741. __le32 loc_msdus;
  742. __le32 loc_mpdus;
  743. /* AMSDUs that have more MSDUs than the status ring size */
  744. __le32 oversize_amsdu;
  745. /* Number of PHY errors */
  746. __le32 phy_errs;
  747. /* Number of PHY errors drops */
  748. __le32 phy_err_drop;
  749. /* Number of mpdu errors - FCS, MIC, ENC etc. */
  750. __le32 mpdu_errs;
  751. } __packed;
  752. struct htt_dbg_stats_wal_peer_stats {
  753. __le32 dummy; /* REMOVE THIS ONCE REAL PEER STAT COUNTERS ARE ADDED */
  754. } __packed;
  755. struct htt_dbg_stats_wal_pdev_txrx {
  756. struct htt_dbg_stats_wal_tx_stats tx_stats;
  757. struct htt_dbg_stats_wal_rx_stats rx_stats;
  758. struct htt_dbg_stats_wal_peer_stats peer_stats;
  759. } __packed;
  760. struct htt_dbg_stats_rx_rate_info {
  761. __le32 mcs[10];
  762. __le32 sgi[10];
  763. __le32 nss[4];
  764. __le32 stbc[10];
  765. __le32 bw[3];
  766. __le32 pream[6];
  767. __le32 ldpc;
  768. __le32 txbf;
  769. };
  770. /*
  771. * htt_dbg_stats_status -
  772. * present - The requested stats have been delivered in full.
  773. * This indicates that either the stats information was contained
  774. * in its entirety within this message, or else this message
  775. * completes the delivery of the requested stats info that was
  776. * partially delivered through earlier STATS_CONF messages.
  777. * partial - The requested stats have been delivered in part.
  778. * One or more subsequent STATS_CONF messages with the same
  779. * cookie value will be sent to deliver the remainder of the
  780. * information.
  781. * error - The requested stats could not be delivered, for example due
  782. * to a shortage of memory to construct a message holding the
  783. * requested stats.
  784. * invalid - The requested stat type is either not recognized, or the
  785. * target is configured to not gather the stats type in question.
  786. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  787. * series_done - This special value indicates that no further stats info
  788. * elements are present within a series of stats info elems
  789. * (within a stats upload confirmation message).
  790. */
  791. enum htt_dbg_stats_status {
  792. HTT_DBG_STATS_STATUS_PRESENT = 0,
  793. HTT_DBG_STATS_STATUS_PARTIAL = 1,
  794. HTT_DBG_STATS_STATUS_ERROR = 2,
  795. HTT_DBG_STATS_STATUS_INVALID = 3,
  796. HTT_DBG_STATS_STATUS_SERIES_DONE = 7
  797. };
  798. /*
  799. * target -> host statistics upload
  800. *
  801. * The following field definitions describe the format of the HTT target
  802. * to host stats upload confirmation message.
  803. * The message contains a cookie echoed from the HTT host->target stats
  804. * upload request, which identifies which request the confirmation is
  805. * for, and a series of tag-length-value stats information elements.
  806. * The tag-length header for each stats info element also includes a
  807. * status field, to indicate whether the request for the stat type in
  808. * question was fully met, partially met, unable to be met, or invalid
  809. * (if the stat type in question is disabled in the target).
  810. * A special value of all 1's in this status field is used to indicate
  811. * the end of the series of stats info elements.
  812. *
  813. *
  814. * |31 16|15 8|7 5|4 0|
  815. * |------------------------------------------------------------|
  816. * | reserved | msg type |
  817. * |------------------------------------------------------------|
  818. * | cookie LSBs |
  819. * |------------------------------------------------------------|
  820. * | cookie MSBs |
  821. * |------------------------------------------------------------|
  822. * | stats entry length | reserved | S |stat type|
  823. * |------------------------------------------------------------|
  824. * | |
  825. * | type-specific stats info |
  826. * | |
  827. * |------------------------------------------------------------|
  828. * | stats entry length | reserved | S |stat type|
  829. * |------------------------------------------------------------|
  830. * | |
  831. * | type-specific stats info |
  832. * | |
  833. * |------------------------------------------------------------|
  834. * | n/a | reserved | 111 | n/a |
  835. * |------------------------------------------------------------|
  836. * Header fields:
  837. * - MSG_TYPE
  838. * Bits 7:0
  839. * Purpose: identifies this is a statistics upload confirmation message
  840. * Value: 0x9
  841. * - COOKIE_LSBS
  842. * Bits 31:0
  843. * Purpose: Provide a mechanism to match a target->host stats confirmation
  844. * message with its preceding host->target stats request message.
  845. * Value: LSBs of the opaque cookie specified by the host-side requestor
  846. * - COOKIE_MSBS
  847. * Bits 31:0
  848. * Purpose: Provide a mechanism to match a target->host stats confirmation
  849. * message with its preceding host->target stats request message.
  850. * Value: MSBs of the opaque cookie specified by the host-side requestor
  851. *
  852. * Stats Information Element tag-length header fields:
  853. * - STAT_TYPE
  854. * Bits 4:0
  855. * Purpose: identifies the type of statistics info held in the
  856. * following information element
  857. * Value: htt_dbg_stats_type
  858. * - STATUS
  859. * Bits 7:5
  860. * Purpose: indicate whether the requested stats are present
  861. * Value: htt_dbg_stats_status, including a special value (0x7) to mark
  862. * the completion of the stats entry series
  863. * - LENGTH
  864. * Bits 31:16
  865. * Purpose: indicate the stats information size
  866. * Value: This field specifies the number of bytes of stats information
  867. * that follows the element tag-length header.
  868. * It is expected but not required that this length is a multiple of
  869. * 4 bytes. Even if the length is not an integer multiple of 4, the
  870. * subsequent stats entry header will begin on a 4-byte aligned
  871. * boundary.
  872. */
  873. #define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_MASK 0x1F
  874. #define HTT_STATS_CONF_ITEM_INFO_STAT_TYPE_LSB 0
  875. #define HTT_STATS_CONF_ITEM_INFO_STATUS_MASK 0xE0
  876. #define HTT_STATS_CONF_ITEM_INFO_STATUS_LSB 5
  877. struct htt_stats_conf_item {
  878. union {
  879. u8 info;
  880. struct {
  881. u8 stat_type:5; /* %HTT_DBG_STATS_ */
  882. u8 status:3; /* %HTT_DBG_STATS_STATUS_ */
  883. } __packed;
  884. } __packed;
  885. u8 pad;
  886. __le16 length;
  887. u8 payload[0]; /* roundup(length, 4) long */
  888. } __packed;
  889. struct htt_stats_conf {
  890. u8 pad[3];
  891. __le32 cookie_lsb;
  892. __le32 cookie_msb;
  893. /* each item has variable length! */
  894. struct htt_stats_conf_item items[0];
  895. } __packed;
  896. static inline struct htt_stats_conf_item *htt_stats_conf_next_item(
  897. const struct htt_stats_conf_item *item)
  898. {
  899. return (void *)item + sizeof(*item) + roundup(item->length, 4);
  900. }
  901. /*
  902. * host -> target FRAG DESCRIPTOR/MSDU_EXT DESC bank
  903. *
  904. * The following field definitions describe the format of the HTT host
  905. * to target frag_desc/msdu_ext bank configuration message.
  906. * The message contains the based address and the min and max id of the
  907. * MSDU_EXT/FRAG_DESC that will be used by the HTT to map MSDU DESC and
  908. * MSDU_EXT/FRAG_DESC.
  909. * HTT will use id in HTT descriptor instead sending the frag_desc_ptr.
  910. * For QCA988X HW the firmware will use fragment_desc_ptr but in WIFI2.0
  911. * the hardware does the mapping/translation.
  912. *
  913. * Total banks that can be configured is configured to 16.
  914. *
  915. * This should be called before any TX has be initiated by the HTT
  916. *
  917. * |31 16|15 8|7 5|4 0|
  918. * |------------------------------------------------------------|
  919. * | DESC_SIZE | NUM_BANKS | RES |SWP|pdev| msg type |
  920. * |------------------------------------------------------------|
  921. * | BANK0_BASE_ADDRESS |
  922. * |------------------------------------------------------------|
  923. * | ... |
  924. * |------------------------------------------------------------|
  925. * | BANK15_BASE_ADDRESS |
  926. * |------------------------------------------------------------|
  927. * | BANK0_MAX_ID | BANK0_MIN_ID |
  928. * |------------------------------------------------------------|
  929. * | ... |
  930. * |------------------------------------------------------------|
  931. * | BANK15_MAX_ID | BANK15_MIN_ID |
  932. * |------------------------------------------------------------|
  933. * Header fields:
  934. * - MSG_TYPE
  935. * Bits 7:0
  936. * Value: 0x6
  937. * - BANKx_BASE_ADDRESS
  938. * Bits 31:0
  939. * Purpose: Provide a mechanism to specify the base address of the MSDU_EXT
  940. * bank physical/bus address.
  941. * - BANKx_MIN_ID
  942. * Bits 15:0
  943. * Purpose: Provide a mechanism to specify the min index that needs to
  944. * mapped.
  945. * - BANKx_MAX_ID
  946. * Bits 31:16
  947. * Purpose: Provide a mechanism to specify the max index that needs to
  948. *
  949. */
  950. struct htt_frag_desc_bank_id {
  951. __le16 bank_min_id;
  952. __le16 bank_max_id;
  953. } __packed;
  954. /* real is 16 but it wouldn't fit in the max htt message size
  955. * so we use a conservatively safe value for now */
  956. #define HTT_FRAG_DESC_BANK_MAX 4
  957. #define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_MASK 0x03
  958. #define HTT_FRAG_DESC_BANK_CFG_INFO_PDEV_ID_LSB 0
  959. #define HTT_FRAG_DESC_BANK_CFG_INFO_SWAP (1 << 2)
  960. struct htt_frag_desc_bank_cfg {
  961. u8 info; /* HTT_FRAG_DESC_BANK_CFG_INFO_ */
  962. u8 num_banks;
  963. u8 desc_size;
  964. __le32 bank_base_addrs[HTT_FRAG_DESC_BANK_MAX];
  965. struct htt_frag_desc_bank_id bank_id[HTT_FRAG_DESC_BANK_MAX];
  966. } __packed;
  967. union htt_rx_pn_t {
  968. /* WEP: 24-bit PN */
  969. u32 pn24;
  970. /* TKIP or CCMP: 48-bit PN */
  971. u_int64_t pn48;
  972. /* WAPI: 128-bit PN */
  973. u_int64_t pn128[2];
  974. };
  975. struct htt_cmd {
  976. struct htt_cmd_hdr hdr;
  977. union {
  978. struct htt_ver_req ver_req;
  979. struct htt_mgmt_tx_desc mgmt_tx;
  980. struct htt_data_tx_desc data_tx;
  981. struct htt_rx_ring_setup rx_setup;
  982. struct htt_stats_req stats_req;
  983. struct htt_oob_sync_req oob_sync_req;
  984. struct htt_aggr_conf aggr_conf;
  985. struct htt_frag_desc_bank_cfg frag_desc_bank_cfg;
  986. };
  987. } __packed;
  988. struct htt_resp {
  989. struct htt_resp_hdr hdr;
  990. union {
  991. struct htt_ver_resp ver_resp;
  992. struct htt_mgmt_tx_completion mgmt_tx_completion;
  993. struct htt_data_tx_completion data_tx_completion;
  994. struct htt_rx_indication rx_ind;
  995. struct htt_rx_fragment_indication rx_frag_ind;
  996. struct htt_rx_peer_map peer_map;
  997. struct htt_rx_peer_unmap peer_unmap;
  998. struct htt_rx_flush rx_flush;
  999. struct htt_rx_addba rx_addba;
  1000. struct htt_rx_delba rx_delba;
  1001. struct htt_security_indication security_indication;
  1002. struct htt_rc_update rc_update;
  1003. struct htt_rx_test rx_test;
  1004. struct htt_pktlog_msg pktlog_msg;
  1005. struct htt_stats_conf stats_conf;
  1006. };
  1007. } __packed;
  1008. /*** host side structures follow ***/
  1009. struct htt_tx_done {
  1010. u32 msdu_id;
  1011. bool discard;
  1012. bool no_ack;
  1013. };
  1014. struct htt_peer_map_event {
  1015. u8 vdev_id;
  1016. u16 peer_id;
  1017. u8 addr[ETH_ALEN];
  1018. };
  1019. struct htt_peer_unmap_event {
  1020. u16 peer_id;
  1021. };
  1022. struct ath10k_htt_txbuf {
  1023. struct htt_data_tx_desc_frag frags[2];
  1024. struct ath10k_htc_hdr htc_hdr;
  1025. struct htt_cmd_hdr cmd_hdr;
  1026. struct htt_data_tx_desc cmd_tx;
  1027. } __packed;
  1028. struct ath10k_htt {
  1029. struct ath10k *ar;
  1030. enum ath10k_htc_ep_id eid;
  1031. int max_throughput_mbps;
  1032. u8 target_version_major;
  1033. u8 target_version_minor;
  1034. struct completion target_version_received;
  1035. struct {
  1036. /*
  1037. * Ring of network buffer objects - This ring is
  1038. * used exclusively by the host SW. This ring
  1039. * mirrors the dev_addrs_ring that is shared
  1040. * between the host SW and the MAC HW. The host SW
  1041. * uses this netbufs ring to locate the network
  1042. * buffer objects whose data buffers the HW has
  1043. * filled.
  1044. */
  1045. struct sk_buff **netbufs_ring;
  1046. /*
  1047. * Ring of buffer addresses -
  1048. * This ring holds the "physical" device address of the
  1049. * rx buffers the host SW provides for the MAC HW to
  1050. * fill.
  1051. */
  1052. __le32 *paddrs_ring;
  1053. /*
  1054. * Base address of ring, as a "physical" device address
  1055. * rather than a CPU address.
  1056. */
  1057. dma_addr_t base_paddr;
  1058. /* how many elems in the ring (power of 2) */
  1059. int size;
  1060. /* size - 1 */
  1061. unsigned size_mask;
  1062. /* how many rx buffers to keep in the ring */
  1063. int fill_level;
  1064. /* how many rx buffers (full+empty) are in the ring */
  1065. int fill_cnt;
  1066. /*
  1067. * alloc_idx - where HTT SW has deposited empty buffers
  1068. * This is allocated in consistent mem, so that the FW can
  1069. * read this variable, and program the HW's FW_IDX reg with
  1070. * the value of this shadow register.
  1071. */
  1072. struct {
  1073. __le32 *vaddr;
  1074. dma_addr_t paddr;
  1075. } alloc_idx;
  1076. /* where HTT SW has processed bufs filled by rx MAC DMA */
  1077. struct {
  1078. unsigned msdu_payld;
  1079. } sw_rd_idx;
  1080. /*
  1081. * refill_retry_timer - timer triggered when the ring is
  1082. * not refilled to the level expected
  1083. */
  1084. struct timer_list refill_retry_timer;
  1085. /* Protects access to all rx ring buffer state variables */
  1086. spinlock_t lock;
  1087. } rx_ring;
  1088. unsigned int prefetch_len;
  1089. /* Protects access to %pending_tx, %used_msdu_ids */
  1090. spinlock_t tx_lock;
  1091. int max_num_pending_tx;
  1092. int num_pending_tx;
  1093. struct sk_buff **pending_tx;
  1094. unsigned long *used_msdu_ids; /* bitmap */
  1095. wait_queue_head_t empty_tx_wq;
  1096. struct dma_pool *tx_pool;
  1097. /* set if host-fw communication goes haywire
  1098. * used to avoid further failures */
  1099. bool rx_confused;
  1100. struct tasklet_struct rx_replenish_task;
  1101. /* This is used to group tx/rx completions separately and process them
  1102. * in batches to reduce cache stalls */
  1103. struct tasklet_struct txrx_compl_task;
  1104. struct sk_buff_head tx_compl_q;
  1105. struct sk_buff_head rx_compl_q;
  1106. /* rx_status template */
  1107. struct ieee80211_rx_status rx_status;
  1108. };
  1109. #define RX_HTT_HDR_STATUS_LEN 64
  1110. /* This structure layout is programmed via rx ring setup
  1111. * so that FW knows how to transfer the rx descriptor to the host.
  1112. * Buffers like this are placed on the rx ring. */
  1113. struct htt_rx_desc {
  1114. union {
  1115. /* This field is filled on the host using the msdu buffer
  1116. * from htt_rx_indication */
  1117. struct fw_rx_desc_base fw_desc;
  1118. u32 pad;
  1119. } __packed;
  1120. struct {
  1121. struct rx_attention attention;
  1122. struct rx_frag_info frag_info;
  1123. struct rx_mpdu_start mpdu_start;
  1124. struct rx_msdu_start msdu_start;
  1125. struct rx_msdu_end msdu_end;
  1126. struct rx_mpdu_end mpdu_end;
  1127. struct rx_ppdu_start ppdu_start;
  1128. struct rx_ppdu_end ppdu_end;
  1129. } __packed;
  1130. u8 rx_hdr_status[RX_HTT_HDR_STATUS_LEN];
  1131. u8 msdu_payload[0];
  1132. };
  1133. #define HTT_RX_DESC_ALIGN 8
  1134. #define HTT_MAC_ADDR_LEN 6
  1135. /*
  1136. * FIX THIS
  1137. * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,
  1138. * rounded up to a cache line size.
  1139. */
  1140. #define HTT_RX_BUF_SIZE 1920
  1141. #define HTT_RX_MSDU_SIZE (HTT_RX_BUF_SIZE - (int)sizeof(struct htt_rx_desc))
  1142. /* Refill a bunch of RX buffers for each refill round so that FW/HW can handle
  1143. * aggregated traffic more nicely. */
  1144. #define ATH10K_HTT_MAX_NUM_REFILL 16
  1145. /*
  1146. * DMA_MAP expects the buffer to be an integral number of cache lines.
  1147. * Rather than checking the actual cache line size, this code makes a
  1148. * conservative estimate of what the cache line size could be.
  1149. */
  1150. #define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */
  1151. #define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)
  1152. int ath10k_htt_connect(struct ath10k_htt *htt);
  1153. int ath10k_htt_init(struct ath10k *ar);
  1154. int ath10k_htt_setup(struct ath10k_htt *htt);
  1155. int ath10k_htt_tx_alloc(struct ath10k_htt *htt);
  1156. void ath10k_htt_tx_free(struct ath10k_htt *htt);
  1157. int ath10k_htt_rx_alloc(struct ath10k_htt *htt);
  1158. void ath10k_htt_rx_free(struct ath10k_htt *htt);
  1159. void ath10k_htt_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb);
  1160. void ath10k_htt_t2h_msg_handler(struct ath10k *ar, struct sk_buff *skb);
  1161. int ath10k_htt_h2t_ver_req_msg(struct ath10k_htt *htt);
  1162. int ath10k_htt_h2t_stats_req(struct ath10k_htt *htt, u8 mask, u64 cookie);
  1163. int ath10k_htt_send_rx_ring_cfg_ll(struct ath10k_htt *htt);
  1164. int ath10k_htt_h2t_aggr_cfg_msg(struct ath10k_htt *htt,
  1165. u8 max_subfrms_ampdu,
  1166. u8 max_subfrms_amsdu);
  1167. void __ath10k_htt_tx_dec_pending(struct ath10k_htt *htt);
  1168. int ath10k_htt_tx_alloc_msdu_id(struct ath10k_htt *htt);
  1169. void ath10k_htt_tx_free_msdu_id(struct ath10k_htt *htt, u16 msdu_id);
  1170. int ath10k_htt_mgmt_tx(struct ath10k_htt *htt, struct sk_buff *);
  1171. int ath10k_htt_tx(struct ath10k_htt *htt, struct sk_buff *);
  1172. #endif