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