htt.h 41 KB

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