htt.h 39 KB

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