htt_internal.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. /*
  2. * Copyright (c) 2011, 2014-2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #ifndef _HTT_INTERNAL__H_
  27. #define _HTT_INTERNAL__H_
  28. #include <athdefs.h> /* A_STATUS */
  29. #include <cdf_nbuf.h> /* cdf_nbuf_t */
  30. #include <cdf_util.h> /* cdf_assert */
  31. #include <htc_api.h> /* HTC_PACKET */
  32. #include <htt_types.h>
  33. #ifndef offsetof
  34. #define offsetof(type, field) ((size_t)(&((type *)0)->field))
  35. #endif
  36. #undef MS
  37. #define MS(_v, _f) (((_v) & _f ## _MASK) >> _f ## _LSB)
  38. #undef SM
  39. #define SM(_v, _f) (((_v) << _f ## _LSB) & _f ## _MASK)
  40. #undef WO
  41. #define WO(_f) ((_f ## _OFFSET) >> 2)
  42. #define GET_FIELD(_addr, _f) MS(*((A_UINT32 *)(_addr) + WO(_f)), _f)
  43. #include <rx_desc.h>
  44. #include <wal_rx_desc.h> /* struct rx_attention, etc */
  45. struct htt_host_fw_desc_base {
  46. union {
  47. struct fw_rx_desc_base val;
  48. A_UINT32 dummy_pad; /* make sure it is DOWRD aligned */
  49. } u;
  50. };
  51. /*
  52. * This struct defines the basic descriptor information used by host,
  53. * which is written either by the 11ac HW MAC into the host Rx data
  54. * buffer ring directly or generated by FW and copied from Rx indication
  55. */
  56. #define RX_HTT_HDR_STATUS_LEN 64
  57. struct htt_host_rx_desc_base {
  58. struct htt_host_fw_desc_base fw_desc;
  59. struct rx_attention attention;
  60. struct rx_frag_info frag_info;
  61. struct rx_mpdu_start mpdu_start;
  62. struct rx_msdu_start msdu_start;
  63. struct rx_msdu_end msdu_end;
  64. struct rx_mpdu_end mpdu_end;
  65. struct rx_ppdu_start ppdu_start;
  66. struct rx_ppdu_end ppdu_end;
  67. char rx_hdr_status[RX_HTT_HDR_STATUS_LEN];
  68. };
  69. #define RX_STD_DESC_ATTN_OFFSET \
  70. (offsetof(struct htt_host_rx_desc_base, attention))
  71. #define RX_STD_DESC_FRAG_INFO_OFFSET \
  72. (offsetof(struct htt_host_rx_desc_base, frag_info))
  73. #define RX_STD_DESC_MPDU_START_OFFSET \
  74. (offsetof(struct htt_host_rx_desc_base, mpdu_start))
  75. #define RX_STD_DESC_MSDU_START_OFFSET \
  76. (offsetof(struct htt_host_rx_desc_base, msdu_start))
  77. #define RX_STD_DESC_MSDU_END_OFFSET \
  78. (offsetof(struct htt_host_rx_desc_base, msdu_end))
  79. #define RX_STD_DESC_MPDU_END_OFFSET \
  80. (offsetof(struct htt_host_rx_desc_base, mpdu_end))
  81. #define RX_STD_DESC_PPDU_START_OFFSET \
  82. (offsetof(struct htt_host_rx_desc_base, ppdu_start))
  83. #define RX_STD_DESC_PPDU_END_OFFSET \
  84. (offsetof(struct htt_host_rx_desc_base, ppdu_end))
  85. #define RX_STD_DESC_HDR_STATUS_OFFSET \
  86. (offsetof(struct htt_host_rx_desc_base, rx_hdr_status))
  87. #define RX_STD_DESC_FW_MSDU_OFFSET \
  88. (offsetof(struct htt_host_rx_desc_base, fw_desc))
  89. #define RX_STD_DESC_SIZE (sizeof(struct htt_host_rx_desc_base))
  90. #define RX_DESC_ATTN_OFFSET32 (RX_STD_DESC_ATTN_OFFSET >> 2)
  91. #define RX_DESC_FRAG_INFO_OFFSET32 (RX_STD_DESC_FRAG_INFO_OFFSET >> 2)
  92. #define RX_DESC_MPDU_START_OFFSET32 (RX_STD_DESC_MPDU_START_OFFSET >> 2)
  93. #define RX_DESC_MSDU_START_OFFSET32 (RX_STD_DESC_MSDU_START_OFFSET >> 2)
  94. #define RX_DESC_MSDU_END_OFFSET32 (RX_STD_DESC_MSDU_END_OFFSET >> 2)
  95. #define RX_DESC_MPDU_END_OFFSET32 (RX_STD_DESC_MPDU_END_OFFSET >> 2)
  96. #define RX_DESC_PPDU_START_OFFSET32 (RX_STD_DESC_PPDU_START_OFFSET >> 2)
  97. #define RX_DESC_PPDU_END_OFFSET32 (RX_STD_DESC_PPDU_END_OFFSET >> 2)
  98. #define RX_DESC_HDR_STATUS_OFFSET32 (RX_STD_DESC_HDR_STATUS_OFFSET >> 2)
  99. #define RX_STD_DESC_SIZE_DWORD (RX_STD_DESC_SIZE >> 2)
  100. /*
  101. * Make sure there is a minimum headroom provided in the rx netbufs
  102. * for use by the OS shim and OS and rx data consumers.
  103. */
  104. #define HTT_RX_BUF_OS_MIN_HEADROOM 32
  105. #define HTT_RX_STD_DESC_RESERVATION \
  106. ((HTT_RX_BUF_OS_MIN_HEADROOM > RX_STD_DESC_SIZE) ? \
  107. HTT_RX_BUF_OS_MIN_HEADROOM : RX_STD_DESC_SIZE)
  108. #define HTT_RX_DESC_RESERVATION32 \
  109. (HTT_RX_STD_DESC_RESERVATION >> 2)
  110. #define HTT_RX_DESC_ALIGN_MASK 7 /* 8-byte alignment */
  111. #ifdef DEBUG_RX_RING_BUFFER
  112. #define HTT_RX_RING_BUFF_DBG_LIST 1024
  113. struct rx_buf_debug {
  114. uint32_t paddr;
  115. void *vaddr;
  116. bool in_use;
  117. };
  118. #endif
  119. static inline struct htt_host_rx_desc_base *htt_rx_desc(cdf_nbuf_t msdu)
  120. {
  121. return (struct htt_host_rx_desc_base *)
  122. (((size_t) (cdf_nbuf_head(msdu) + HTT_RX_DESC_ALIGN_MASK)) &
  123. ~HTT_RX_DESC_ALIGN_MASK);
  124. }
  125. #if defined(FEATURE_LRO)
  126. /**
  127. * htt_print_rx_desc_lro() - print LRO information in the rx
  128. * descriptor
  129. * @rx_desc: HTT rx descriptor
  130. *
  131. * Prints the LRO related fields in the HTT rx descriptor
  132. *
  133. * Return: none
  134. */
  135. static inline void htt_print_rx_desc_lro(struct htt_host_rx_desc_base *rx_desc)
  136. {
  137. cdf_print
  138. ("----------------------RX DESC LRO----------------------\n");
  139. cdf_print("msdu_end.lro_eligible:0x%x\n",
  140. rx_desc->msdu_end.lro_eligible);
  141. cdf_print("msdu_start.tcp_only_ack:0x%x\n",
  142. rx_desc->msdu_start.tcp_only_ack);
  143. cdf_print("msdu_end.tcp_udp_chksum:0x%x\n",
  144. rx_desc->msdu_end.tcp_udp_chksum);
  145. cdf_print("msdu_end.tcp_seq_number:0x%x\n",
  146. rx_desc->msdu_end.tcp_seq_number);
  147. cdf_print("msdu_end.tcp_ack_number:0x%x\n",
  148. rx_desc->msdu_end.tcp_ack_number);
  149. cdf_print("msdu_start.tcp_proto:0x%x\n",
  150. rx_desc->msdu_start.tcp_proto);
  151. cdf_print("msdu_start.ipv6_proto:0x%x\n",
  152. rx_desc->msdu_start.ipv6_proto);
  153. cdf_print("msdu_start.ipv4_proto:0x%x\n",
  154. rx_desc->msdu_start.ipv4_proto);
  155. cdf_print("msdu_start.l3_offset:0x%x\n",
  156. rx_desc->msdu_start.l3_offset);
  157. cdf_print("msdu_start.l4_offset:0x%x\n",
  158. rx_desc->msdu_start.l4_offset);
  159. cdf_print("msdu_start.flow_id_toeplitz:0x%x\n",
  160. rx_desc->msdu_start.flow_id_toeplitz);
  161. cdf_print
  162. ("---------------------------------------------------------\n");
  163. }
  164. /**
  165. * htt_print_rx_desc_lro() - extract LRO information from the rx
  166. * descriptor
  167. * @msdu: network buffer
  168. * @rx_desc: HTT rx descriptor
  169. *
  170. * Extracts the LRO related fields from the HTT rx descriptor
  171. * and stores them in the network buffer's control block
  172. *
  173. * Return: none
  174. */
  175. static inline void htt_rx_extract_lro_info(cdf_nbuf_t msdu,
  176. struct htt_host_rx_desc_base *rx_desc)
  177. {
  178. NBUF_LRO_ELIGIBLE(msdu) = rx_desc->msdu_end.lro_eligible;
  179. if (rx_desc->msdu_end.lro_eligible) {
  180. NBUF_TCP_PURE_ACK(msdu) = rx_desc->msdu_start.tcp_only_ack;
  181. NBUF_TCP_CHKSUM(msdu) = rx_desc->msdu_end.tcp_udp_chksum;
  182. NBUF_TCP_SEQ_NUM(msdu) = rx_desc->msdu_end.tcp_seq_number;
  183. NBUF_TCP_ACK_NUM(msdu) = rx_desc->msdu_end.tcp_ack_number;
  184. NBUF_TCP_WIN(msdu) = rx_desc->msdu_end.window_size;
  185. NBUF_TCP_PROTO(msdu) = rx_desc->msdu_start.tcp_proto;
  186. NBUF_IPV6_PROTO(msdu) = rx_desc->msdu_start.ipv6_proto;
  187. NBUF_IP_OFFSET(msdu) = rx_desc->msdu_start.l3_offset;
  188. NBUF_TCP_OFFSET(msdu) = rx_desc->msdu_start.l4_offset;
  189. NBUF_FLOW_ID_TOEPLITZ(msdu) =
  190. rx_desc->msdu_start.flow_id_toeplitz;
  191. }
  192. }
  193. #else
  194. static inline void htt_print_rx_desc_lro(struct htt_host_rx_desc_base *rx_desc)
  195. {}
  196. static inline void htt_rx_extract_lro_info(cdf_nbuf_t msdu,
  197. struct htt_host_rx_desc_base *rx_desc) {}
  198. #endif /* FEATURE_LRO */
  199. static inline void htt_print_rx_desc(struct htt_host_rx_desc_base *rx_desc)
  200. {
  201. cdf_print
  202. ("----------------------RX DESC----------------------------\n");
  203. cdf_print("attention: %#010x\n",
  204. (unsigned int)(*(uint32_t *) &rx_desc->attention));
  205. cdf_print("frag_info: %#010x\n",
  206. (unsigned int)(*(uint32_t *) &rx_desc->frag_info));
  207. cdf_print("mpdu_start: %#010x %#010x %#010x\n",
  208. (unsigned int)(((uint32_t *) &rx_desc->mpdu_start)[0]),
  209. (unsigned int)(((uint32_t *) &rx_desc->mpdu_start)[1]),
  210. (unsigned int)(((uint32_t *) &rx_desc->mpdu_start)[2]));
  211. cdf_print("msdu_start: %#010x %#010x %#010x\n",
  212. (unsigned int)(((uint32_t *) &rx_desc->msdu_start)[0]),
  213. (unsigned int)(((uint32_t *) &rx_desc->msdu_start)[1]),
  214. (unsigned int)(((uint32_t *) &rx_desc->msdu_start)[2]));
  215. cdf_print("msdu_end: %#010x %#010x %#010x %#010x %#010x\n",
  216. (unsigned int)(((uint32_t *) &rx_desc->msdu_end)[0]),
  217. (unsigned int)(((uint32_t *) &rx_desc->msdu_end)[1]),
  218. (unsigned int)(((uint32_t *) &rx_desc->msdu_end)[2]),
  219. (unsigned int)(((uint32_t *) &rx_desc->msdu_end)[3]),
  220. (unsigned int)(((uint32_t *) &rx_desc->msdu_end)[4]));
  221. cdf_print("mpdu_end: %#010x\n",
  222. (unsigned int)(*(uint32_t *) &rx_desc->mpdu_end));
  223. cdf_print("ppdu_start: " "%#010x %#010x %#010x %#010x %#010x\n"
  224. "%#010x %#010x %#010x %#010x %#010x\n",
  225. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[0]),
  226. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[1]),
  227. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[2]),
  228. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[3]),
  229. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[4]),
  230. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[5]),
  231. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[6]),
  232. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[7]),
  233. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[8]),
  234. (unsigned int)(((uint32_t *) &rx_desc->ppdu_start)[9]));
  235. cdf_print("ppdu_end:" "%#010x %#010x %#010x %#010x %#010x\n"
  236. "%#010x %#010x %#010x %#010x %#010x\n"
  237. "%#010x,%#010x %#010x %#010x %#010x\n"
  238. "%#010x %#010x %#010x %#010x %#010x\n" "%#010x %#010x\n",
  239. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[0]),
  240. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[1]),
  241. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[2]),
  242. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[3]),
  243. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[4]),
  244. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[5]),
  245. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[6]),
  246. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[7]),
  247. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[8]),
  248. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[9]),
  249. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[10]),
  250. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[11]),
  251. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[12]),
  252. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[13]),
  253. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[14]),
  254. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[15]),
  255. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[16]),
  256. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[17]),
  257. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[18]),
  258. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[19]),
  259. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[20]),
  260. (unsigned int)(((uint32_t *) &rx_desc->ppdu_end)[21]));
  261. cdf_print
  262. ("---------------------------------------------------------\n");
  263. }
  264. #ifndef HTT_ASSERT_LEVEL
  265. #define HTT_ASSERT_LEVEL 3
  266. #endif
  267. #define HTT_ASSERT_ALWAYS(condition) cdf_assert_always((condition))
  268. #define HTT_ASSERT0(condition) cdf_assert((condition))
  269. #if HTT_ASSERT_LEVEL > 0
  270. #define HTT_ASSERT1(condition) cdf_assert((condition))
  271. #else
  272. #define HTT_ASSERT1(condition)
  273. #endif
  274. #if HTT_ASSERT_LEVEL > 1
  275. #define HTT_ASSERT2(condition) cdf_assert((condition))
  276. #else
  277. #define HTT_ASSERT2(condition)
  278. #endif
  279. #if HTT_ASSERT_LEVEL > 2
  280. #define HTT_ASSERT3(condition) cdf_assert((condition))
  281. #else
  282. #define HTT_ASSERT3(condition)
  283. #endif
  284. #define HTT_MAC_ADDR_LEN 6
  285. /*
  286. * HTT_MAX_SEND_QUEUE_DEPTH -
  287. * How many packets HTC should allow to accumulate in a send queue
  288. * before calling the EpSendFull callback to see whether to retain
  289. * or drop packets.
  290. * This is not relevant for LL, where tx descriptors should be immediately
  291. * downloaded to the target.
  292. * This is not very relevant for HL either, since it is anticipated that
  293. * the HL tx download scheduler will not work this far in advance - rather,
  294. * it will make its decisions just-in-time, so it can be responsive to
  295. * changing conditions.
  296. * Hence, this queue depth threshold spec is mostly just a formality.
  297. */
  298. #define HTT_MAX_SEND_QUEUE_DEPTH 64
  299. #define IS_PWR2(value) (((value) ^ ((value)-1)) == ((value) << 1) - 1)
  300. /* FIX THIS
  301. * Should be: sizeof(struct htt_host_rx_desc) + max rx MSDU size,
  302. * rounded up to a cache line size.
  303. */
  304. #define HTT_RX_BUF_SIZE 1920
  305. /*
  306. * DMA_MAP expects the buffer to be an integral number of cache lines.
  307. * Rather than checking the actual cache line size, this code makes a
  308. * conservative estimate of what the cache line size could be.
  309. */
  310. #define HTT_LOG2_MAX_CACHE_LINE_SIZE 7 /* 2^7 = 128 */
  311. #define HTT_MAX_CACHE_LINE_SIZE_MASK ((1 << HTT_LOG2_MAX_CACHE_LINE_SIZE) - 1)
  312. #ifdef BIG_ENDIAN_HOST
  313. /*
  314. * big-endian: bytes within a 4-byte "word" are swapped:
  315. * pre-swap post-swap
  316. * index index
  317. * 0 3
  318. * 1 2
  319. * 2 1
  320. * 3 0
  321. * 4 7
  322. * 5 6
  323. * etc.
  324. * To compute the post-swap index from the pre-swap index, compute
  325. * the byte offset for the start of the word (index & ~0x3) and add
  326. * the swapped byte offset within the word (3 - (index & 0x3)).
  327. */
  328. #define HTT_ENDIAN_BYTE_IDX_SWAP(idx) (((idx) & ~0x3) + (3 - ((idx) & 0x3)))
  329. #else
  330. /* little-endian: no adjustment needed */
  331. #define HTT_ENDIAN_BYTE_IDX_SWAP(idx) idx
  332. #endif
  333. #define HTT_TX_MUTEX_INIT(_mutex) \
  334. cdf_spinlock_init(_mutex)
  335. #define HTT_TX_MUTEX_ACQUIRE(_mutex) \
  336. cdf_spin_lock_bh(_mutex)
  337. #define HTT_TX_MUTEX_RELEASE(_mutex) \
  338. cdf_spin_unlock_bh(_mutex)
  339. #define HTT_TX_MUTEX_DESTROY(_mutex) \
  340. cdf_spinlock_destroy(_mutex)
  341. #define HTT_TX_DESC_PADDR(_pdev, _tx_desc_vaddr) \
  342. ((_pdev)->tx_descs.pool_paddr + (uint32_t) \
  343. ((char *)(_tx_desc_vaddr) - \
  344. (char *)((_pdev)->tx_descs.pool_vaddr)))
  345. #ifdef ATH_11AC_TXCOMPACT
  346. #define HTT_TX_NBUF_QUEUE_MUTEX_INIT(_pdev) \
  347. cdf_spinlock_init(&_pdev->txnbufq_mutex)
  348. #define HTT_TX_NBUF_QUEUE_MUTEX_DESTROY(_pdev) \
  349. HTT_TX_MUTEX_DESTROY(&_pdev->txnbufq_mutex)
  350. #define HTT_TX_NBUF_QUEUE_REMOVE(_pdev, _msdu) do { \
  351. HTT_TX_MUTEX_ACQUIRE(&_pdev->txnbufq_mutex); \
  352. _msdu = cdf_nbuf_queue_remove(&_pdev->txnbufq);\
  353. HTT_TX_MUTEX_RELEASE(&_pdev->txnbufq_mutex); \
  354. } while (0)
  355. #define HTT_TX_NBUF_QUEUE_ADD(_pdev, _msdu) do { \
  356. HTT_TX_MUTEX_ACQUIRE(&_pdev->txnbufq_mutex); \
  357. cdf_nbuf_queue_add(&_pdev->txnbufq, _msdu); \
  358. HTT_TX_MUTEX_RELEASE(&_pdev->txnbufq_mutex); \
  359. } while (0)
  360. #define HTT_TX_NBUF_QUEUE_INSERT_HEAD(_pdev, _msdu) do { \
  361. HTT_TX_MUTEX_ACQUIRE(&_pdev->txnbufq_mutex); \
  362. cdf_nbuf_queue_insert_head(&_pdev->txnbufq, _msdu);\
  363. HTT_TX_MUTEX_RELEASE(&_pdev->txnbufq_mutex); \
  364. } while (0)
  365. #else
  366. #define HTT_TX_NBUF_QUEUE_MUTEX_INIT(_pdev)
  367. #define HTT_TX_NBUF_QUEUE_REMOVE(_pdev, _msdu)
  368. #define HTT_TX_NBUF_QUEUE_ADD(_pdev, _msdu)
  369. #define HTT_TX_NBUF_QUEUE_INSERT_HEAD(_pdev, _msdu)
  370. #define HTT_TX_NBUF_QUEUE_MUTEX_DESTROY(_pdev)
  371. #endif
  372. void htt_tx_resume_handler(void *);
  373. #ifdef ATH_11AC_TXCOMPACT
  374. #define HTT_TX_SCHED htt_tx_sched
  375. #else
  376. #define HTT_TX_SCHED(pdev) /* no-op */
  377. #endif
  378. int htt_tx_attach(struct htt_pdev_t *pdev, int desc_pool_elems);
  379. void htt_tx_detach(struct htt_pdev_t *pdev);
  380. int htt_rx_attach(struct htt_pdev_t *pdev);
  381. void htt_rx_detach(struct htt_pdev_t *pdev);
  382. int htt_htc_attach(struct htt_pdev_t *pdev);
  383. void htt_t2h_msg_handler(void *context, HTC_PACKET *pkt);
  384. void htt_h2t_send_complete(void *context, HTC_PACKET *pkt);
  385. A_STATUS htt_h2t_ver_req_msg(struct htt_pdev_t *pdev);
  386. #if defined(HELIUMPLUS_PADDR64)
  387. A_STATUS
  388. htt_h2t_frag_desc_bank_cfg_msg(struct htt_pdev_t *pdev);
  389. #endif /* defined(HELIUMPLUS_PADDR64) */
  390. extern A_STATUS htt_h2t_rx_ring_cfg_msg_ll(struct htt_pdev_t *pdev);
  391. extern A_STATUS (*htt_h2t_rx_ring_cfg_msg)(struct htt_pdev_t *pdev);
  392. HTC_SEND_FULL_ACTION htt_h2t_full(void *context, HTC_PACKET *pkt);
  393. struct htt_htc_pkt *htt_htc_pkt_alloc(struct htt_pdev_t *pdev);
  394. void htt_htc_pkt_free(struct htt_pdev_t *pdev, struct htt_htc_pkt *pkt);
  395. void htt_htc_pkt_pool_free(struct htt_pdev_t *pdev);
  396. #ifdef ATH_11AC_TXCOMPACT
  397. void
  398. htt_htc_misc_pkt_list_add(struct htt_pdev_t *pdev, struct htt_htc_pkt *pkt);
  399. void htt_htc_misc_pkt_pool_free(struct htt_pdev_t *pdev);
  400. #endif
  401. void htt_htc_disable_aspm(void);
  402. int
  403. htt_rx_hash_list_insert(struct htt_pdev_t *pdev, uint32_t paddr,
  404. cdf_nbuf_t netbuf);
  405. cdf_nbuf_t htt_rx_hash_list_lookup(struct htt_pdev_t *pdev, uint32_t paddr);
  406. #ifdef IPA_OFFLOAD
  407. int
  408. htt_tx_ipa_uc_attach(struct htt_pdev_t *pdev,
  409. unsigned int uc_tx_buf_sz,
  410. unsigned int uc_tx_buf_cnt,
  411. unsigned int uc_tx_partition_base);
  412. int
  413. htt_rx_ipa_uc_attach(struct htt_pdev_t *pdev, unsigned int rx_ind_ring_size);
  414. int htt_tx_ipa_uc_detach(struct htt_pdev_t *pdev);
  415. int htt_rx_ipa_uc_detach(struct htt_pdev_t *pdev);
  416. #else
  417. /**
  418. * htt_tx_ipa_uc_attach() - attach htt ipa uc tx resource
  419. * @pdev: htt context
  420. * @uc_tx_buf_sz: single tx buffer size
  421. * @uc_tx_buf_cnt: total tx buffer count
  422. * @uc_tx_partition_base: tx buffer partition start
  423. *
  424. * Return: 0 success
  425. */
  426. static inline int
  427. htt_tx_ipa_uc_attach(struct htt_pdev_t *pdev,
  428. unsigned int uc_tx_buf_sz,
  429. unsigned int uc_tx_buf_cnt,
  430. unsigned int uc_tx_partition_base)
  431. {
  432. return 0;
  433. }
  434. /**
  435. * htt_rx_ipa_uc_attach() - attach htt ipa uc rx resource
  436. * @pdev: htt context
  437. * @rx_ind_ring_size: rx ring size
  438. *
  439. * Return: 0 success
  440. */
  441. static inline int
  442. htt_rx_ipa_uc_attach(struct htt_pdev_t *pdev, unsigned int rx_ind_ring_size)
  443. {
  444. return 0;
  445. }
  446. static inline int htt_tx_ipa_uc_detach(struct htt_pdev_t *pdev)
  447. {
  448. return 0;
  449. }
  450. static inline int htt_rx_ipa_uc_detach(struct htt_pdev_t *pdev)
  451. {
  452. return 0;
  453. }
  454. #endif /* IPA_OFFLOAD */
  455. #ifdef DEBUG_RX_RING_BUFFER
  456. /**
  457. * htt_rx_dbg_rxbuf_init() - init debug rx buff list
  458. * @pdev: pdev handle
  459. *
  460. * Return: none
  461. */
  462. static inline
  463. void htt_rx_dbg_rxbuf_init(struct htt_pdev_t *pdev)
  464. {
  465. pdev->rx_buff_list = cdf_mem_malloc(
  466. HTT_RX_RING_BUFF_DBG_LIST *
  467. sizeof(struct rx_buf_debug));
  468. if (!pdev->rx_buff_list) {
  469. cdf_print("HTT: debug RX buffer allocation failed\n");
  470. CDF_ASSERT(0);
  471. }
  472. }
  473. /**
  474. * htt_rx_dbg_rxbuf_set() - set element of rx buff list
  475. * @pdev: pdev handle
  476. * @paddr: physical address of netbuf
  477. * @rx_netbuf: received netbuf
  478. *
  479. * Return: none
  480. */
  481. static inline
  482. void htt_rx_dbg_rxbuf_set(struct htt_pdev_t *pdev,
  483. uint32_t paddr,
  484. cdf_nbuf_t rx_netbuf)
  485. {
  486. if (pdev->rx_buff_list) {
  487. pdev->rx_buff_list[pdev->rx_buff_index].paddr =
  488. paddr;
  489. pdev->rx_buff_list[pdev->rx_buff_index].in_use =
  490. true;
  491. pdev->rx_buff_list[pdev->rx_buff_index].vaddr =
  492. rx_netbuf;
  493. NBUF_MAP_ID(rx_netbuf) = pdev->rx_buff_index;
  494. if (++pdev->rx_buff_index ==
  495. HTT_RX_RING_BUFF_DBG_LIST)
  496. pdev->rx_buff_index = 0;
  497. }
  498. }
  499. /**
  500. * htt_rx_dbg_rxbuf_set() - reset element of rx buff list
  501. * @pdev: pdev handle
  502. * @netbuf: rx sk_buff
  503. * Return: none
  504. */
  505. static inline
  506. void htt_rx_dbg_rxbuf_reset(struct htt_pdev_t *pdev,
  507. cdf_nbuf_t netbuf)
  508. {
  509. uint32_t index;
  510. if (pdev->rx_buff_list) {
  511. index = NBUF_MAP_ID(netbuf);
  512. if (index < HTT_RX_RING_BUFF_DBG_LIST) {
  513. pdev->rx_buff_list[index].in_use =
  514. false;
  515. pdev->rx_buff_list[index].paddr = 0;
  516. pdev->rx_buff_list[index].vaddr = NULL;
  517. }
  518. }
  519. }
  520. /**
  521. * htt_rx_dbg_rxbuf_deinit() - deinit debug rx buff list
  522. * @pdev: pdev handle
  523. *
  524. * Return: none
  525. */
  526. static inline
  527. void htt_rx_dbg_rxbuf_deinit(struct htt_pdev_t *pdev)
  528. {
  529. if (pdev->rx_buff_list)
  530. cdf_mem_free(pdev->rx_buff_list);
  531. }
  532. #else
  533. static inline
  534. void htt_rx_dbg_rxbuf_init(struct htt_pdev_t *pdev)
  535. {
  536. return;
  537. }
  538. static inline
  539. void htt_rx_dbg_rxbuf_set(struct htt_pdev_t *pdev,
  540. uint32_t paddr,
  541. cdf_nbuf_t rx_netbuf)
  542. {
  543. return;
  544. }
  545. static inline
  546. void htt_rx_dbg_rxbuf_reset(struct htt_pdev_t *pdev,
  547. cdf_nbuf_t netbuf)
  548. {
  549. return;
  550. }
  551. static inline
  552. void htt_rx_dbg_rxbuf_deinit(struct htt_pdev_t *pdev)
  553. {
  554. return;
  555. }
  556. #endif
  557. #endif /* _HTT_INTERNAL__H_ */