htt.h 39 KB

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