ol_tx_desc.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. * Copyright (c) 2011, 2014 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. /**
  27. * @file ol_tx_desc.h
  28. * @brief API definitions for the tx descriptor module within the data SW.
  29. */
  30. #ifndef _OL_TX_DESC__H_
  31. #define _OL_TX_DESC__H_
  32. #include <cds_queue.h> /* TAILQ_HEAD */
  33. #include <cdf_nbuf.h> /* cdf_nbuf_t */
  34. #include <ol_txrx_types.h> /* ol_tx_desc_t */
  35. #include <ol_txrx_internal.h> /*TXRX_ASSERT2 */
  36. struct ol_tx_desc_t *
  37. ol_tx_desc_alloc_wrapper(struct ol_txrx_pdev_t *pdev,
  38. struct ol_txrx_vdev_t *vdev,
  39. struct ol_txrx_msdu_info_t *msdu_info);
  40. /**
  41. * @brief Allocate and initialize a tx descriptor for a LL system.
  42. * @details
  43. * Allocate a tx descriptor pair for a new tx frame - a SW tx descriptor
  44. * for private use within the host data SW, and a HTT tx descriptor for
  45. * downloading tx meta-data to the target FW/HW.
  46. * Fill in the fields of this pair of tx descriptors based on the
  47. * information in the netbuf.
  48. * For LL, this includes filling in a fragmentation descriptor to
  49. * specify to the MAC HW where to find the tx frame's fragments.
  50. *
  51. * @param pdev - the data physical device sending the data
  52. * (for accessing the tx desc pool)
  53. * @param vdev - the virtual device sending the data
  54. * (for specifying the transmitter address for multicast / broadcast data)
  55. * @param netbuf - the tx frame
  56. * @param msdu_info - tx meta-data
  57. */
  58. struct ol_tx_desc_t *ol_tx_desc_ll(struct ol_txrx_pdev_t *pdev,
  59. struct ol_txrx_vdev_t *vdev,
  60. cdf_nbuf_t netbuf,
  61. struct ol_txrx_msdu_info_t *msdu_info);
  62. /**
  63. * @brief Use a tx descriptor ID to find the corresponding desriptor object.
  64. *
  65. * @param pdev - the data physical device sending the data
  66. * @param tx_desc_id - the ID of the descriptor in question
  67. * @return the descriptor object that has the specified ID
  68. */
  69. static inline struct ol_tx_desc_t *ol_tx_desc_find(
  70. struct ol_txrx_pdev_t *pdev, uint16_t tx_desc_id)
  71. {
  72. void **td_base = (void **)pdev->tx_desc.desc_pages.cacheable_pages;
  73. return &((union ol_tx_desc_list_elem_t *)
  74. (td_base[tx_desc_id >> pdev->tx_desc.page_divider] +
  75. (pdev->tx_desc.desc_reserved_size *
  76. (tx_desc_id & pdev->tx_desc.offset_filter))))->tx_desc;
  77. }
  78. /**
  79. * @brief Free a list of tx descriptors and the tx frames they refer to.
  80. * @details
  81. * Free a batch of "standard" tx descriptors and their tx frames.
  82. * Free each tx descriptor, by returning it to the freelist.
  83. * Unmap each netbuf, and free the netbufs as a batch.
  84. * Irregular tx frames like TSO or managment frames that require
  85. * special handling are processed by the ol_tx_desc_frame_free_nonstd
  86. * function rather than this function.
  87. *
  88. * @param pdev - the data physical device that sent the data
  89. * @param tx_descs - a list of SW tx descriptors for the tx frames
  90. * @param had_error - bool indication of whether the transmission failed.
  91. * This is provided to callback functions that get notified of
  92. * the tx frame completion.
  93. */
  94. void ol_tx_desc_frame_list_free(struct ol_txrx_pdev_t *pdev,
  95. ol_tx_desc_list *tx_descs, int had_error);
  96. /**
  97. * @brief Free a non-standard tx frame and its tx descriptor.
  98. * @details
  99. * Check the tx frame type (e.g. TSO vs. management) to determine what
  100. * special steps, if any, need to be performed prior to freeing the
  101. * tx frame and its tx descriptor.
  102. * This function can also be used to free single standard tx frames.
  103. * After performing any special steps based on tx frame type, free the
  104. * tx descriptor, i.e. return it to the freelist, and unmap and
  105. * free the netbuf referenced by the tx descriptor.
  106. *
  107. * @param pdev - the data physical device that sent the data
  108. * @param tx_desc - the SW tx descriptor for the tx frame that was sent
  109. * @param had_error - bool indication of whether the transmission failed.
  110. * This is provided to callback functions that get notified of
  111. * the tx frame completion.
  112. */
  113. void ol_tx_desc_frame_free_nonstd(struct ol_txrx_pdev_t *pdev,
  114. struct ol_tx_desc_t *tx_desc, int had_error);
  115. /*
  116. * @brief Determine the ID of a tx descriptor.
  117. *
  118. * @param pdev - the physical device that is sending the data
  119. * @param tx_desc - the descriptor whose ID is being determined
  120. * @return numeric ID that uniquely identifies the tx descriptor
  121. */
  122. static inline uint16_t
  123. ol_tx_desc_id(struct ol_txrx_pdev_t *pdev, struct ol_tx_desc_t *tx_desc)
  124. {
  125. TXRX_ASSERT2(tx_desc->id < pdev->tx_desc.pool_size);
  126. return tx_desc->id;
  127. }
  128. /*
  129. * @brief Retrieves the beacon headr for the vdev
  130. * @param pdev - opaque pointe to scn
  131. * @param vdevid - vdev id
  132. * @return void pointer to the beacon header for the given vdev
  133. */
  134. void *ol_ath_get_bcn_header(ol_pdev_handle pdev, A_UINT32 vdev_id);
  135. /*
  136. * @brief Free a tx descriptor, without freeing the matching frame.
  137. * @details
  138. * This function is using during the function call that submits tx frames
  139. * into the txrx layer, for cases where a tx descriptor is successfully
  140. * allocated, but for other reasons the frame could not be accepted.
  141. *
  142. * @param pdev - the data physical device that is sending the data
  143. * @param tx_desc - the descriptor being freed
  144. */
  145. void ol_tx_desc_free(struct ol_txrx_pdev_t *pdev, struct ol_tx_desc_t *tx_desc);
  146. #if defined(FEATURE_TSO)
  147. struct cdf_tso_seg_elem_t *ol_tso_alloc_segment(struct ol_txrx_pdev_t *pdev);
  148. void ol_tso_free_segment(struct ol_txrx_pdev_t *pdev,
  149. struct cdf_tso_seg_elem_t *tso_seg);
  150. #endif
  151. /**
  152. * ol_tx_get_desc_global_pool() - get descriptor from global pool
  153. * @pdev: pdev handler
  154. *
  155. * Caller needs to take lock and do sanity checks.
  156. *
  157. * Return: tx descriptor
  158. */
  159. static inline
  160. struct ol_tx_desc_t *ol_tx_get_desc_global_pool(struct ol_txrx_pdev_t *pdev)
  161. {
  162. struct ol_tx_desc_t *tx_desc = &pdev->tx_desc.freelist->tx_desc;
  163. pdev->tx_desc.freelist = pdev->tx_desc.freelist->next;
  164. pdev->tx_desc.num_free--;
  165. return tx_desc;
  166. }
  167. /**
  168. * ol_tx_put_desc_global_pool() - put descriptor to global pool freelist
  169. * @pdev: pdev handle
  170. * @tx_desc: tx descriptor
  171. *
  172. * Caller needs to take lock and do sanity checks.
  173. *
  174. * Return: none
  175. */
  176. static inline
  177. void ol_tx_put_desc_global_pool(struct ol_txrx_pdev_t *pdev,
  178. struct ol_tx_desc_t *tx_desc)
  179. {
  180. ((union ol_tx_desc_list_elem_t *)tx_desc)->next =
  181. pdev->tx_desc.freelist;
  182. pdev->tx_desc.freelist =
  183. (union ol_tx_desc_list_elem_t *)tx_desc;
  184. pdev->tx_desc.num_free++;
  185. return;
  186. }
  187. #ifdef QCA_LL_TX_FLOW_CONTROL_V2
  188. int ol_tx_free_invalid_flow_pool(struct ol_tx_flow_pool_t *pool);
  189. /**
  190. * ol_tx_get_desc_flow_pool() - get descriptor from flow pool
  191. * @pool: flow pool
  192. *
  193. * Caller needs to take lock and do sanity checks.
  194. *
  195. * Return: tx descriptor
  196. */
  197. static inline
  198. struct ol_tx_desc_t *ol_tx_get_desc_flow_pool(struct ol_tx_flow_pool_t *pool)
  199. {
  200. struct ol_tx_desc_t *tx_desc = &pool->freelist->tx_desc;
  201. pool->freelist = pool->freelist->next;
  202. pool->avail_desc--;
  203. return tx_desc;
  204. }
  205. /**
  206. * ol_tx_put_desc_flow_pool() - put descriptor to flow pool freelist
  207. * @pool: flow pool
  208. * @tx_desc: tx descriptor
  209. *
  210. * Caller needs to take lock and do sanity checks.
  211. *
  212. * Return: none
  213. */
  214. static inline
  215. void ol_tx_put_desc_flow_pool(struct ol_tx_flow_pool_t *pool,
  216. struct ol_tx_desc_t *tx_desc)
  217. {
  218. tx_desc->pool = pool;
  219. ((union ol_tx_desc_list_elem_t *)tx_desc)->next = pool->freelist;
  220. pool->freelist = (union ol_tx_desc_list_elem_t *)tx_desc;
  221. pool->avail_desc++;
  222. return;
  223. }
  224. #else
  225. static inline int ol_tx_free_invalid_flow_pool(void *pool)
  226. {
  227. return 0;
  228. }
  229. #endif
  230. #endif /* _OL_TX_DESC__H_ */