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 | |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 28 | #include <qdf_net_types.h> /* QDF_NBUF_EXEMPT_NO_EXEMPTION, etc. */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 29 | #include <qdf_nbuf.h> /* qdf_nbuf_t, etc. */ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 30 | #include <qdf_util.h> /* qdf_assert */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 31 | #include <qdf_lock.h> /* qdf_spinlock */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 32 | #ifdef QCA_COMPUTE_TX_DELAY |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 33 | #include <qdf_time.h> /* qdf_system_ticks */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 34 | #endif |
| 35 | |
| 36 | #include <ol_htt_tx_api.h> /* htt_tx_desc_id */ |
| 37 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 38 | #include <ol_tx_desc.h> |
| 39 | #include <ol_txrx_internal.h> |
| 40 | #ifdef QCA_SUPPORT_SW_TXRX_ENCAP |
| 41 | #include <ol_txrx_encap.h> /* OL_TX_RESTORE_HDR, etc */ |
| 42 | #endif |
| 43 | #include <ol_txrx.h> |
| 44 | |
| 45 | #ifdef QCA_SUPPORT_TXDESC_SANITY_CHECKS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 46 | static inline void ol_tx_desc_sanity_checks(struct ol_txrx_pdev_t *pdev, |
| 47 | struct ol_tx_desc_t *tx_desc) |
| 48 | { |
gbian | e55c956 | 2016-11-01 14:47:47 +0800 | [diff] [blame^] | 49 | if (tx_desc->pkt_type != ol_tx_frm_freed) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 50 | TXRX_PRINT(TXRX_PRINT_LEVEL_ERR, |
| 51 | "%s Potential tx_desc corruption pkt_type:0x%x pdev:0x%p", |
| 52 | __func__, tx_desc->pkt_type, pdev); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 53 | qdf_assert(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 54 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 55 | } |
| 56 | static inline void ol_tx_desc_reset_pkt_type(struct ol_tx_desc_t *tx_desc) |
| 57 | { |
gbian | e55c956 | 2016-11-01 14:47:47 +0800 | [diff] [blame^] | 58 | tx_desc->pkt_type = ol_tx_frm_freed; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 59 | } |
| 60 | #ifdef QCA_COMPUTE_TX_DELAY |
| 61 | static inline void ol_tx_desc_compute_delay(struct ol_tx_desc_t *tx_desc) |
| 62 | { |
| 63 | if (tx_desc->entry_timestamp_ticks != 0xffffffff) { |
| 64 | TXRX_PRINT(TXRX_PRINT_LEVEL_ERR, "%s Timestamp:0x%x\n", |
| 65 | __func__, tx_desc->entry_timestamp_ticks); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 66 | qdf_assert(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 67 | } |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 68 | tx_desc->entry_timestamp_ticks = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 69 | } |
| 70 | static inline void ol_tx_desc_reset_timestamp(struct ol_tx_desc_t *tx_desc) |
| 71 | { |
| 72 | tx_desc->entry_timestamp_ticks = 0xffffffff; |
| 73 | } |
| 74 | #endif |
| 75 | #else |
| 76 | static inline void ol_tx_desc_sanity_checks(struct ol_txrx_pdev_t *pdev, |
| 77 | struct ol_tx_desc_t *tx_desc) |
| 78 | { |
| 79 | return; |
| 80 | } |
| 81 | static inline void ol_tx_desc_reset_pkt_type(struct ol_tx_desc_t *tx_desc) |
| 82 | { |
| 83 | return; |
| 84 | } |
| 85 | static inline void ol_tx_desc_compute_delay(struct ol_tx_desc_t *tx_desc) |
| 86 | { |
| 87 | return; |
| 88 | } |
| 89 | static inline void ol_tx_desc_reset_timestamp(struct ol_tx_desc_t *tx_desc) |
| 90 | { |
| 91 | return; |
| 92 | } |
| 93 | #endif |
| 94 | |
Manjunathappa Prakash | af88fc7 | 2016-11-02 17:26:22 -0700 | [diff] [blame] | 95 | #ifdef CONFIG_HL_SUPPORT |
| 96 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 97 | /** |
| 98 | * ol_tx_desc_vdev_update() - vedv assign. |
| 99 | * @tx_desc: tx descriptor pointer |
| 100 | * @vdev: vdev handle |
| 101 | * |
| 102 | * Return: None |
| 103 | */ |
| 104 | static inline void |
| 105 | ol_tx_desc_vdev_update(struct ol_tx_desc_t *tx_desc, |
| 106 | struct ol_txrx_vdev_t *vdev) |
| 107 | { |
| 108 | tx_desc->vdev = vdev; |
| 109 | } |
Manjunathappa Prakash | af88fc7 | 2016-11-02 17:26:22 -0700 | [diff] [blame] | 110 | #else |
| 111 | |
| 112 | static inline void |
| 113 | ol_tx_desc_vdev_update(struct ol_tx_desc_t *tx_desc, |
| 114 | struct ol_txrx_vdev_t *vdev) |
| 115 | { |
| 116 | return; |
| 117 | } |
| 118 | #endif |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 119 | |
| 120 | #ifdef CONFIG_PER_VDEV_TX_DESC_POOL |
| 121 | |
| 122 | /** |
| 123 | * ol_tx_desc_count_inc() - tx desc count increment for desc allocation. |
| 124 | * @vdev: vdev handle |
| 125 | * |
| 126 | * Return: None |
| 127 | */ |
| 128 | static inline void |
| 129 | ol_tx_desc_count_inc(struct ol_txrx_vdev_t *vdev) |
| 130 | { |
| 131 | qdf_atomic_inc(&vdev->tx_desc_count); |
| 132 | } |
| 133 | #else |
| 134 | |
| 135 | static inline void |
| 136 | ol_tx_desc_count_inc(struct ol_txrx_vdev_t *vdev) |
| 137 | { |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | #endif |
| 142 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 143 | #ifndef QCA_LL_TX_FLOW_CONTROL_V2 |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 144 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 145 | /** |
| 146 | * ol_tx_desc_alloc() - allocate descriptor from freelist |
| 147 | * @pdev: pdev handle |
| 148 | * @vdev: vdev handle |
| 149 | * |
| 150 | * Return: tx descriptor pointer/ NULL in case of error |
| 151 | */ |
| 152 | static |
| 153 | struct ol_tx_desc_t *ol_tx_desc_alloc(struct ol_txrx_pdev_t *pdev, |
| 154 | struct ol_txrx_vdev_t *vdev) |
| 155 | { |
| 156 | struct ol_tx_desc_t *tx_desc = NULL; |
| 157 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 158 | qdf_spin_lock_bh(&pdev->tx_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 159 | if (pdev->tx_desc.freelist) { |
Nirav Shah | 9d7f2e8 | 2015-09-28 11:09:09 -0700 | [diff] [blame] | 160 | tx_desc = ol_tx_get_desc_global_pool(pdev); |
Nirav Shah | 7629196 | 2016-04-25 10:50:37 +0530 | [diff] [blame] | 161 | ol_tx_desc_dup_detect_set(pdev, tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 162 | ol_tx_desc_sanity_checks(pdev, tx_desc); |
| 163 | ol_tx_desc_compute_delay(tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 164 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 165 | qdf_spin_unlock_bh(&pdev->tx_mutex); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 166 | |
| 167 | if (!tx_desc) |
| 168 | return NULL; |
| 169 | |
| 170 | ol_tx_desc_vdev_update(tx_desc, vdev); |
| 171 | ol_tx_desc_count_inc(vdev); |
Himanshu Agarwal | 749e0f2 | 2016-10-26 21:12:59 +0530 | [diff] [blame] | 172 | qdf_atomic_inc(&tx_desc->ref_cnt); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 173 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 174 | return tx_desc; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * ol_tx_desc_alloc_wrapper() -allocate tx descriptor |
| 179 | * @pdev: pdev handler |
| 180 | * @vdev: vdev handler |
| 181 | * @msdu_info: msdu handler |
| 182 | * |
| 183 | * Return: tx descriptor or NULL |
| 184 | */ |
| 185 | struct ol_tx_desc_t * |
| 186 | ol_tx_desc_alloc_wrapper(struct ol_txrx_pdev_t *pdev, |
| 187 | struct ol_txrx_vdev_t *vdev, |
| 188 | struct ol_txrx_msdu_info_t *msdu_info) |
| 189 | { |
| 190 | return ol_tx_desc_alloc(pdev, vdev); |
| 191 | } |
| 192 | |
| 193 | #else |
| 194 | /** |
| 195 | * ol_tx_desc_alloc() -allocate tx descriptor |
| 196 | * @pdev: pdev handler |
| 197 | * @vdev: vdev handler |
| 198 | * @pool: flow pool |
| 199 | * |
| 200 | * Return: tx descriptor or NULL |
| 201 | */ |
| 202 | static |
| 203 | struct ol_tx_desc_t *ol_tx_desc_alloc(struct ol_txrx_pdev_t *pdev, |
| 204 | struct ol_txrx_vdev_t *vdev, |
| 205 | struct ol_tx_flow_pool_t *pool) |
| 206 | { |
| 207 | struct ol_tx_desc_t *tx_desc = NULL; |
| 208 | |
| 209 | if (pool) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 210 | qdf_spin_lock_bh(&pool->flow_pool_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 211 | if (pool->avail_desc) { |
Nirav Shah | 9d7f2e8 | 2015-09-28 11:09:09 -0700 | [diff] [blame] | 212 | tx_desc = ol_tx_get_desc_flow_pool(pool); |
Nirav Shah | 7629196 | 2016-04-25 10:50:37 +0530 | [diff] [blame] | 213 | ol_tx_desc_dup_detect_set(pdev, tx_desc); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 214 | if (qdf_unlikely(pool->avail_desc < pool->stop_th)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 215 | pool->status = FLOW_POOL_ACTIVE_PAUSED; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 216 | qdf_spin_unlock_bh(&pool->flow_pool_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 217 | /* pause network queues */ |
| 218 | pdev->pause_cb(vdev->vdev_id, |
| 219 | WLAN_STOP_ALL_NETIF_QUEUE, |
| 220 | WLAN_DATA_FLOW_CONTROL); |
| 221 | } else { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 222 | qdf_spin_unlock_bh(&pool->flow_pool_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 223 | } |
| 224 | ol_tx_desc_sanity_checks(pdev, tx_desc); |
| 225 | ol_tx_desc_compute_delay(tx_desc); |
Himanshu Agarwal | 749e0f2 | 2016-10-26 21:12:59 +0530 | [diff] [blame] | 226 | qdf_atomic_inc(&tx_desc->ref_cnt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 227 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 228 | pool->pkt_drop_no_desc++; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 229 | qdf_spin_unlock_bh(&pool->flow_pool_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 230 | } |
| 231 | } else { |
| 232 | pdev->pool_stats.pkt_drop_no_pool++; |
| 233 | } |
| 234 | |
| 235 | return tx_desc; |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * ol_tx_desc_alloc_wrapper() -allocate tx descriptor |
| 240 | * @pdev: pdev handler |
| 241 | * @vdev: vdev handler |
| 242 | * @msdu_info: msdu handler |
| 243 | * |
| 244 | * Return: tx descriptor or NULL |
| 245 | */ |
| 246 | #ifdef QCA_LL_TX_FLOW_GLOBAL_MGMT_POOL |
| 247 | struct ol_tx_desc_t * |
| 248 | ol_tx_desc_alloc_wrapper(struct ol_txrx_pdev_t *pdev, |
| 249 | struct ol_txrx_vdev_t *vdev, |
| 250 | struct ol_txrx_msdu_info_t *msdu_info) |
| 251 | { |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 252 | if (qdf_unlikely(msdu_info->htt.info.frame_type == htt_pkt_type_mgmt)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 253 | return ol_tx_desc_alloc(pdev, vdev, pdev->mgmt_pool); |
| 254 | else |
| 255 | return ol_tx_desc_alloc(pdev, vdev, vdev->pool); |
| 256 | } |
| 257 | #else |
| 258 | struct ol_tx_desc_t * |
| 259 | ol_tx_desc_alloc_wrapper(struct ol_txrx_pdev_t *pdev, |
| 260 | struct ol_txrx_vdev_t *vdev, |
| 261 | struct ol_txrx_msdu_info_t *msdu_info) |
| 262 | { |
| 263 | return ol_tx_desc_alloc(pdev, vdev, vdev->pool); |
| 264 | } |
| 265 | #endif |
| 266 | #endif |
| 267 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 268 | /** |
| 269 | * ol_tx_desc_alloc_hl() - allocate tx descriptor |
| 270 | * @pdev: pdev handle |
| 271 | * @vdev: vdev handle |
| 272 | * @msdu_info: tx msdu info |
| 273 | * |
| 274 | * Return: tx descriptor pointer/ NULL in case of error |
| 275 | */ |
| 276 | static struct ol_tx_desc_t * |
| 277 | ol_tx_desc_alloc_hl(struct ol_txrx_pdev_t *pdev, |
| 278 | struct ol_txrx_vdev_t *vdev, |
| 279 | struct ol_txrx_msdu_info_t *msdu_info) |
| 280 | { |
| 281 | struct ol_tx_desc_t *tx_desc; |
| 282 | |
| 283 | tx_desc = ol_tx_desc_alloc_wrapper(pdev, vdev, msdu_info); |
| 284 | if (!tx_desc) |
| 285 | return NULL; |
| 286 | |
| 287 | qdf_atomic_dec(&pdev->tx_queue.rsrc_cnt); |
| 288 | |
| 289 | return tx_desc; |
| 290 | } |
| 291 | |
| 292 | #if defined(CONFIG_PER_VDEV_TX_DESC_POOL) && defined(CONFIG_HL_SUPPORT) |
| 293 | |
| 294 | /** |
| 295 | * ol_tx_desc_vdev_rm() - decrement the tx desc count for vdev. |
| 296 | * @tx_desc: tx desc |
| 297 | * |
| 298 | * Return: None |
| 299 | */ |
| 300 | static inline void |
| 301 | ol_tx_desc_vdev_rm(struct ol_tx_desc_t *tx_desc) |
| 302 | { |
| 303 | qdf_atomic_dec(&tx_desc->vdev->tx_desc_count); |
| 304 | tx_desc->vdev = NULL; |
| 305 | } |
| 306 | #else |
| 307 | |
| 308 | static inline void |
| 309 | ol_tx_desc_vdev_rm(struct ol_tx_desc_t *tx_desc) |
| 310 | { |
| 311 | return; |
| 312 | } |
| 313 | #endif |
| 314 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 315 | #ifndef QCA_LL_TX_FLOW_CONTROL_V2 |
| 316 | /** |
| 317 | * ol_tx_desc_free() - put descriptor to freelist |
| 318 | * @pdev: pdev handle |
| 319 | * @tx_desc: tx descriptor |
| 320 | * |
| 321 | * Return: None |
| 322 | */ |
| 323 | void ol_tx_desc_free(struct ol_txrx_pdev_t *pdev, struct ol_tx_desc_t *tx_desc) |
| 324 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 325 | qdf_spin_lock_bh(&pdev->tx_mutex); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 326 | |
Prakash Manjunathappa | 6dc1a96 | 2016-05-05 19:32:53 -0700 | [diff] [blame] | 327 | if (tx_desc->pkt_type == OL_TX_FRM_TSO) { |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 328 | if (qdf_unlikely(tx_desc->tso_desc == NULL)) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 329 | qdf_print("%s %d TSO desc is NULL!\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 330 | __func__, __LINE__); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 331 | qdf_assert(0); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 332 | } else { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 333 | ol_tso_free_segment(pdev, tx_desc->tso_desc); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 334 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 335 | } |
Nirav Shah | 7629196 | 2016-04-25 10:50:37 +0530 | [diff] [blame] | 336 | ol_tx_desc_dup_detect_reset(pdev, tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 337 | ol_tx_desc_reset_pkt_type(tx_desc); |
| 338 | ol_tx_desc_reset_timestamp(tx_desc); |
| 339 | |
Nirav Shah | 9d7f2e8 | 2015-09-28 11:09:09 -0700 | [diff] [blame] | 340 | ol_tx_put_desc_global_pool(pdev, tx_desc); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 341 | ol_tx_desc_vdev_rm(tx_desc); |
| 342 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 343 | qdf_spin_unlock_bh(&pdev->tx_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | #else |
| 347 | /** |
| 348 | * ol_tx_desc_free() - put descriptor to pool freelist |
| 349 | * @pdev: pdev handle |
| 350 | * @tx_desc: tx descriptor |
| 351 | * |
| 352 | * Return: None |
| 353 | */ |
| 354 | void ol_tx_desc_free(struct ol_txrx_pdev_t *pdev, struct ol_tx_desc_t *tx_desc) |
| 355 | { |
| 356 | struct ol_tx_flow_pool_t *pool = tx_desc->pool; |
| 357 | |
| 358 | #if defined(FEATURE_TSO) |
Prakash Manjunathappa | 6dc1a96 | 2016-05-05 19:32:53 -0700 | [diff] [blame] | 359 | if (tx_desc->pkt_type == OL_TX_FRM_TSO) { |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 360 | if (qdf_unlikely(tx_desc->tso_desc == NULL)) |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 361 | qdf_print("%s %d TSO desc is NULL!\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 362 | __func__, __LINE__); |
| 363 | else |
| 364 | ol_tso_free_segment(pdev, tx_desc->tso_desc); |
| 365 | } |
| 366 | #endif |
| 367 | ol_tx_desc_reset_pkt_type(tx_desc); |
| 368 | ol_tx_desc_reset_timestamp(tx_desc); |
| 369 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 370 | qdf_spin_lock_bh(&pool->flow_pool_lock); |
Nirav Shah | 7629196 | 2016-04-25 10:50:37 +0530 | [diff] [blame] | 371 | ol_tx_desc_dup_detect_reset(pdev, tx_desc); |
Nirav Shah | 9d7f2e8 | 2015-09-28 11:09:09 -0700 | [diff] [blame] | 372 | ol_tx_put_desc_flow_pool(pool, tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 373 | switch (pool->status) { |
| 374 | case FLOW_POOL_ACTIVE_PAUSED: |
| 375 | if (pool->avail_desc > pool->start_th) { |
| 376 | pdev->pause_cb(pool->member_flow_id, |
| 377 | WLAN_WAKE_ALL_NETIF_QUEUE, |
| 378 | WLAN_DATA_FLOW_CONTROL); |
| 379 | pool->status = FLOW_POOL_ACTIVE_UNPAUSED; |
| 380 | } |
| 381 | break; |
| 382 | case FLOW_POOL_INVALID: |
| 383 | if (pool->avail_desc == pool->flow_pool_size) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 384 | qdf_spin_unlock_bh(&pool->flow_pool_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 385 | ol_tx_free_invalid_flow_pool(pool); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 386 | qdf_print("%s %d pool is INVALID State!!\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 387 | __func__, __LINE__); |
| 388 | return; |
| 389 | } |
| 390 | break; |
| 391 | case FLOW_POOL_ACTIVE_UNPAUSED: |
| 392 | break; |
| 393 | default: |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 394 | qdf_print("%s %d pool is INACTIVE State!!\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 395 | __func__, __LINE__); |
| 396 | break; |
| 397 | }; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 398 | qdf_spin_unlock_bh(&pool->flow_pool_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 399 | |
| 400 | } |
| 401 | #endif |
| 402 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 403 | void |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 404 | dump_pkt(qdf_nbuf_t nbuf, qdf_dma_addr_t nbuf_paddr, int len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 405 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 406 | qdf_print("%s: Pkt: VA 0x%p PA 0x%llx len %d\n", __func__, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 407 | qdf_nbuf_data(nbuf), (long long unsigned int)nbuf_paddr, len); |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 408 | print_hex_dump(KERN_DEBUG, "Pkt: ", DUMP_PREFIX_ADDRESS, 16, 4, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 409 | qdf_nbuf_data(nbuf), len, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | const uint32_t htt_to_ce_pkt_type[] = { |
| 413 | [htt_pkt_type_raw] = tx_pkt_type_raw, |
| 414 | [htt_pkt_type_native_wifi] = tx_pkt_type_native_wifi, |
| 415 | [htt_pkt_type_ethernet] = tx_pkt_type_802_3, |
| 416 | [htt_pkt_type_mgmt] = tx_pkt_type_mgmt, |
| 417 | [htt_pkt_type_eth2] = tx_pkt_type_eth2, |
| 418 | [htt_pkt_num_types] = 0xffffffff |
| 419 | }; |
| 420 | |
Nirav Shah | 2e583a0 | 2016-04-30 14:06:12 +0530 | [diff] [blame] | 421 | #define WISA_DEST_PORT_6MBPS 50000 |
| 422 | #define WISA_DEST_PORT_24MBPS 50001 |
| 423 | |
| 424 | /** |
| 425 | * ol_tx_get_wisa_ext_hdr_type() - get header type for WiSA mode |
| 426 | * @netbuf: network buffer |
| 427 | * |
| 428 | * Return: extension header type |
| 429 | */ |
| 430 | enum extension_header_type |
| 431 | ol_tx_get_wisa_ext_hdr_type(qdf_nbuf_t netbuf) |
| 432 | { |
| 433 | uint8_t *buf = qdf_nbuf_data(netbuf); |
| 434 | uint16_t dport; |
| 435 | |
| 436 | if (qdf_is_macaddr_group( |
| 437 | (struct qdf_mac_addr *)(buf + QDF_NBUF_DEST_MAC_OFFSET))) { |
| 438 | |
| 439 | dport = (uint16_t)(*(uint16_t *)(buf + |
| 440 | QDF_NBUF_TRAC_IPV4_OFFSET + |
| 441 | QDF_NBUF_TRAC_IPV4_HEADER_SIZE + sizeof(uint16_t))); |
| 442 | |
| 443 | if (dport == QDF_SWAP_U16(WISA_DEST_PORT_6MBPS)) |
| 444 | return WISA_MODE_EXT_HEADER_6MBPS; |
| 445 | else if (dport == QDF_SWAP_U16(WISA_DEST_PORT_24MBPS)) |
| 446 | return WISA_MODE_EXT_HEADER_24MBPS; |
| 447 | else |
| 448 | return EXT_HEADER_NOT_PRESENT; |
| 449 | } else { |
| 450 | return EXT_HEADER_NOT_PRESENT; |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * ol_tx_get_ext_header_type() - extension header is required or not |
| 456 | * @vdev: vdev pointer |
| 457 | * @netbuf: network buffer |
| 458 | * |
| 459 | * This function returns header type and if extension header is |
| 460 | * not required than returns EXT_HEADER_NOT_PRESENT. |
| 461 | * |
| 462 | * Return: extension header type |
| 463 | */ |
| 464 | enum extension_header_type |
| 465 | ol_tx_get_ext_header_type(struct ol_txrx_vdev_t *vdev, |
| 466 | qdf_nbuf_t netbuf) |
| 467 | { |
| 468 | if (vdev->is_wisa_mode_enable == true) |
| 469 | return ol_tx_get_wisa_ext_hdr_type(netbuf); |
| 470 | else |
| 471 | return EXT_HEADER_NOT_PRESENT; |
| 472 | } |
| 473 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 474 | struct ol_tx_desc_t *ol_tx_desc_ll(struct ol_txrx_pdev_t *pdev, |
| 475 | struct ol_txrx_vdev_t *vdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 476 | qdf_nbuf_t netbuf, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 477 | struct ol_txrx_msdu_info_t *msdu_info) |
| 478 | { |
| 479 | struct ol_tx_desc_t *tx_desc; |
| 480 | unsigned int i; |
| 481 | uint32_t num_frags; |
Nirav Shah | 2e583a0 | 2016-04-30 14:06:12 +0530 | [diff] [blame] | 482 | enum extension_header_type type; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 483 | |
| 484 | msdu_info->htt.info.vdev_id = vdev->vdev_id; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 485 | msdu_info->htt.action.cksum_offload = qdf_nbuf_get_tx_cksum(netbuf); |
| 486 | switch (qdf_nbuf_get_exemption_type(netbuf)) { |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 487 | case QDF_NBUF_EXEMPT_NO_EXEMPTION: |
| 488 | case QDF_NBUF_EXEMPT_ON_KEY_MAPPING_KEY_UNAVAILABLE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 489 | /* We want to encrypt this frame */ |
| 490 | msdu_info->htt.action.do_encrypt = 1; |
| 491 | break; |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 492 | case QDF_NBUF_EXEMPT_ALWAYS: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 493 | /* We don't want to encrypt this frame */ |
| 494 | msdu_info->htt.action.do_encrypt = 0; |
| 495 | break; |
| 496 | default: |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 497 | qdf_assert(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 498 | break; |
| 499 | } |
| 500 | |
| 501 | /* allocate the descriptor */ |
| 502 | tx_desc = ol_tx_desc_alloc_wrapper(pdev, vdev, msdu_info); |
| 503 | if (!tx_desc) |
| 504 | return NULL; |
| 505 | |
| 506 | /* initialize the SW tx descriptor */ |
| 507 | tx_desc->netbuf = netbuf; |
| 508 | |
| 509 | if (msdu_info->tso_info.is_tso) { |
| 510 | tx_desc->tso_desc = msdu_info->tso_info.curr_seg; |
Prakash Manjunathappa | 6dc1a96 | 2016-05-05 19:32:53 -0700 | [diff] [blame] | 511 | tx_desc->pkt_type = OL_TX_FRM_TSO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 512 | TXRX_STATS_MSDU_INCR(pdev, tx.tso.tso_pkts, netbuf); |
| 513 | } else { |
Prakash Manjunathappa | 6dc1a96 | 2016-05-05 19:32:53 -0700 | [diff] [blame] | 514 | tx_desc->pkt_type = OL_TX_FRM_STD; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 515 | } |
| 516 | |
Nirav Shah | 2e583a0 | 2016-04-30 14:06:12 +0530 | [diff] [blame] | 517 | type = ol_tx_get_ext_header_type(vdev, netbuf); |
| 518 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 519 | /* initialize the HW tx descriptor */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 520 | htt_tx_desc_init(pdev->htt_pdev, tx_desc->htt_tx_desc, |
| 521 | tx_desc->htt_tx_desc_paddr, |
| 522 | ol_tx_desc_id(pdev, tx_desc), netbuf, &msdu_info->htt, |
Nirav Shah | 2e583a0 | 2016-04-30 14:06:12 +0530 | [diff] [blame] | 523 | &msdu_info->tso_info, NULL, type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 524 | |
| 525 | /* |
| 526 | * Initialize the fragmentation descriptor. |
| 527 | * Skip the prefix fragment (HTT tx descriptor) that was added |
| 528 | * during the call to htt_tx_desc_init above. |
| 529 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 530 | num_frags = qdf_nbuf_get_num_frags(netbuf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 531 | /* num_frags are expected to be 2 max */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 532 | num_frags = (num_frags > QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS) |
| 533 | ? QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 534 | : num_frags; |
| 535 | #if defined(HELIUMPLUS_PADDR64) |
| 536 | /* |
| 537 | * Use num_frags - 1, since 1 frag is used to store |
| 538 | * the HTT/HTC descriptor |
| 539 | * Refer to htt_tx_desc_init() |
| 540 | */ |
| 541 | htt_tx_desc_num_frags(pdev->htt_pdev, tx_desc->htt_frag_desc, |
| 542 | num_frags - 1); |
| 543 | #else /* ! defined(HELIUMPLUSPADDR64) */ |
| 544 | htt_tx_desc_num_frags(pdev->htt_pdev, tx_desc->htt_tx_desc, |
| 545 | num_frags - 1); |
| 546 | #endif /* defined(HELIUMPLUS_PADDR64) */ |
| 547 | |
| 548 | if (msdu_info->tso_info.is_tso) { |
| 549 | htt_tx_desc_fill_tso_info(pdev->htt_pdev, |
| 550 | tx_desc->htt_frag_desc, &msdu_info->tso_info); |
| 551 | TXRX_STATS_TSO_SEG_UPDATE(pdev, |
| 552 | msdu_info->tso_info.curr_seg->seg); |
| 553 | } else { |
| 554 | for (i = 1; i < num_frags; i++) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 555 | qdf_size_t frag_len; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 556 | qdf_dma_addr_t frag_paddr; |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 557 | #ifdef HELIUMPLUS_DEBUG |
| 558 | void *frag_vaddr; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 559 | frag_vaddr = qdf_nbuf_get_frag_vaddr(netbuf, i); |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 560 | #endif |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 561 | frag_len = qdf_nbuf_get_frag_len(netbuf, i); |
| 562 | frag_paddr = qdf_nbuf_get_frag_paddr(netbuf, i); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 563 | #if defined(HELIUMPLUS_PADDR64) |
| 564 | htt_tx_desc_frag(pdev->htt_pdev, tx_desc->htt_frag_desc, i - 1, |
| 565 | frag_paddr, frag_len); |
| 566 | #if defined(HELIUMPLUS_DEBUG) |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 567 | qdf_print("%s:%d: htt_fdesc=%p frag=%d frag_vaddr=0x%p frag_paddr=0x%llx len=%zu\n", |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 568 | __func__, __LINE__, tx_desc->htt_frag_desc, |
| 569 | i-1, frag_vaddr, frag_paddr, frag_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 570 | dump_pkt(netbuf, frag_paddr, 64); |
| 571 | #endif /* HELIUMPLUS_DEBUG */ |
| 572 | #else /* ! defined(HELIUMPLUSPADDR64) */ |
| 573 | htt_tx_desc_frag(pdev->htt_pdev, tx_desc->htt_tx_desc, i - 1, |
| 574 | frag_paddr, frag_len); |
| 575 | #endif /* defined(HELIUMPLUS_PADDR64) */ |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | #if defined(HELIUMPLUS_DEBUG) |
Himanshu Agarwal | fd68172 | 2016-10-27 19:07:25 +0530 | [diff] [blame] | 580 | ol_txrx_dump_frag_desc("ol_tx_desc_ll()", tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 581 | #endif |
| 582 | return tx_desc; |
| 583 | } |
| 584 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 585 | struct ol_tx_desc_t * |
| 586 | ol_tx_desc_hl( |
| 587 | struct ol_txrx_pdev_t *pdev, |
| 588 | struct ol_txrx_vdev_t *vdev, |
| 589 | qdf_nbuf_t netbuf, |
| 590 | struct ol_txrx_msdu_info_t *msdu_info) |
| 591 | { |
| 592 | struct ol_tx_desc_t *tx_desc; |
| 593 | |
| 594 | /* FIX THIS: these inits should probably be done by tx classify */ |
| 595 | msdu_info->htt.info.vdev_id = vdev->vdev_id; |
| 596 | msdu_info->htt.info.frame_type = pdev->htt_pkt_type; |
| 597 | msdu_info->htt.action.cksum_offload = qdf_nbuf_get_tx_cksum(netbuf); |
| 598 | switch (qdf_nbuf_get_exemption_type(netbuf)) { |
| 599 | case QDF_NBUF_EXEMPT_NO_EXEMPTION: |
| 600 | case QDF_NBUF_EXEMPT_ON_KEY_MAPPING_KEY_UNAVAILABLE: |
| 601 | /* We want to encrypt this frame */ |
| 602 | msdu_info->htt.action.do_encrypt = 1; |
| 603 | break; |
| 604 | case QDF_NBUF_EXEMPT_ALWAYS: |
| 605 | /* We don't want to encrypt this frame */ |
| 606 | msdu_info->htt.action.do_encrypt = 0; |
| 607 | break; |
| 608 | default: |
| 609 | qdf_assert(0); |
| 610 | break; |
| 611 | } |
| 612 | |
| 613 | /* allocate the descriptor */ |
| 614 | tx_desc = ol_tx_desc_alloc_hl(pdev, vdev, msdu_info); |
| 615 | if (!tx_desc) |
| 616 | return NULL; |
| 617 | |
| 618 | /* initialize the SW tx descriptor */ |
| 619 | tx_desc->netbuf = netbuf; |
| 620 | /* fix this - get pkt_type from msdu_info */ |
| 621 | tx_desc->pkt_type = OL_TX_FRM_STD; |
| 622 | |
| 623 | #ifdef QCA_SUPPORT_SW_TXRX_ENCAP |
| 624 | tx_desc->orig_l2_hdr_bytes = 0; |
| 625 | #endif |
| 626 | /* the HW tx descriptor will be initialized later by the caller */ |
| 627 | |
| 628 | return tx_desc; |
| 629 | } |
| 630 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 631 | void ol_tx_desc_frame_list_free(struct ol_txrx_pdev_t *pdev, |
| 632 | ol_tx_desc_list *tx_descs, int had_error) |
| 633 | { |
| 634 | struct ol_tx_desc_t *tx_desc, *tmp; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 635 | qdf_nbuf_t msdus = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 636 | |
| 637 | TAILQ_FOREACH_SAFE(tx_desc, tx_descs, tx_desc_list_elem, tmp) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 638 | qdf_nbuf_t msdu = tx_desc->netbuf; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 639 | |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 640 | qdf_atomic_init(&tx_desc->ref_cnt); /* clear the ref cnt */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 641 | #ifdef QCA_SUPPORT_SW_TXRX_ENCAP |
| 642 | /* restore original hdr offset */ |
| 643 | OL_TX_RESTORE_HDR(tx_desc, msdu); |
| 644 | #endif |
Mohit Khanna | 38d0e93 | 2016-08-31 19:49:22 -0700 | [diff] [blame] | 645 | if (qdf_nbuf_get_users(msdu) <= 1) |
| 646 | qdf_nbuf_unmap(pdev->osdev, msdu, QDF_DMA_TO_DEVICE); |
| 647 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 648 | /* free the tx desc */ |
| 649 | ol_tx_desc_free(pdev, tx_desc); |
| 650 | /* link the netbuf into a list to free as a batch */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 651 | qdf_nbuf_set_next(msdu, msdus); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 652 | msdus = msdu; |
| 653 | } |
| 654 | /* free the netbufs as a batch */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 655 | qdf_nbuf_tx_free(msdus, had_error); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | void ol_tx_desc_frame_free_nonstd(struct ol_txrx_pdev_t *pdev, |
| 659 | struct ol_tx_desc_t *tx_desc, int had_error) |
| 660 | { |
| 661 | int mgmt_type; |
| 662 | ol_txrx_mgmt_tx_cb ota_ack_cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 663 | |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 664 | qdf_atomic_init(&tx_desc->ref_cnt); /* clear the ref cnt */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 665 | #ifdef QCA_SUPPORT_SW_TXRX_ENCAP |
| 666 | /* restore original hdr offset */ |
| 667 | OL_TX_RESTORE_HDR(tx_desc, (tx_desc->netbuf)); |
| 668 | #endif |
Prakash Manjunathappa | 6dc1a96 | 2016-05-05 19:32:53 -0700 | [diff] [blame] | 669 | if (tx_desc->pkt_type == OL_TX_FRM_NO_FREE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 670 | /* free the tx desc but don't unmap or free the frame */ |
| 671 | if (pdev->tx_data_callback.func) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 672 | qdf_nbuf_set_next(tx_desc->netbuf, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 673 | pdev->tx_data_callback.func(pdev->tx_data_callback.ctxt, |
| 674 | tx_desc->netbuf, had_error); |
| 675 | ol_tx_desc_free(pdev, tx_desc); |
| 676 | return; |
| 677 | } |
| 678 | /* let the code below unmap and free the frame */ |
| 679 | } |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 680 | qdf_nbuf_unmap(pdev->osdev, tx_desc->netbuf, QDF_DMA_TO_DEVICE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 681 | /* check the frame type to see what kind of special steps are needed */ |
| 682 | if ((tx_desc->pkt_type >= OL_TXRX_MGMT_TYPE_BASE) && |
gbian | e55c956 | 2016-11-01 14:47:47 +0800 | [diff] [blame^] | 683 | (tx_desc->pkt_type != ol_tx_frm_freed)) { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 684 | qdf_dma_addr_t frag_desc_paddr = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 685 | |
| 686 | #if defined(HELIUMPLUS_PADDR64) |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 687 | frag_desc_paddr = tx_desc->htt_frag_desc_paddr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 688 | /* FIX THIS - |
| 689 | * The FW currently has trouble using the host's fragments |
| 690 | * table for management frames. Until this is fixed, |
| 691 | * rather than specifying the fragment table to the FW, |
| 692 | * the host SW will specify just the address of the initial |
| 693 | * fragment. |
| 694 | * Now that the mgmt frame is done, the HTT tx desc's frags |
| 695 | * table pointer needs to be reset. |
| 696 | */ |
| 697 | #if defined(HELIUMPLUS_DEBUG) |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 698 | qdf_print("%s %d: Frag Descriptor Reset [%d] to 0x%x\n", |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 699 | __func__, __LINE__, tx_desc->id, |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 700 | frag_desc_paddr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 701 | #endif /* HELIUMPLUS_DEBUG */ |
| 702 | #endif /* HELIUMPLUS_PADDR64 */ |
| 703 | htt_tx_desc_frags_table_set(pdev->htt_pdev, |
| 704 | tx_desc->htt_tx_desc, 0, |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 705 | frag_desc_paddr, 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 706 | |
| 707 | mgmt_type = tx_desc->pkt_type - OL_TXRX_MGMT_TYPE_BASE; |
| 708 | /* |
| 709 | * we already checked the value when the mgmt frame was |
| 710 | * provided to the txrx layer. |
| 711 | * no need to check it a 2nd time. |
| 712 | */ |
| 713 | ota_ack_cb = pdev->tx_mgmt.callbacks[mgmt_type].ota_ack_cb; |
| 714 | if (ota_ack_cb) { |
| 715 | void *ctxt; |
| 716 | ctxt = pdev->tx_mgmt.callbacks[mgmt_type].ctxt; |
| 717 | ota_ack_cb(ctxt, tx_desc->netbuf, had_error); |
| 718 | } |
| 719 | /* free the netbuf */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 720 | qdf_nbuf_free(tx_desc->netbuf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 721 | } else { |
| 722 | /* single regular frame */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 723 | qdf_nbuf_set_next(tx_desc->netbuf, NULL); |
| 724 | qdf_nbuf_tx_free(tx_desc->netbuf, had_error); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 725 | } |
| 726 | /* free the tx desc */ |
| 727 | ol_tx_desc_free(pdev, tx_desc); |
| 728 | } |
| 729 | |
| 730 | #if defined(FEATURE_TSO) |
| 731 | /** |
| 732 | * htt_tso_alloc_segment() - function to allocate a TSO segment |
| 733 | * element |
| 734 | * @pdev: HTT pdev |
| 735 | * @tso_seg: This is the output. The TSO segment element. |
| 736 | * |
| 737 | * Allocates a TSO segment element from the free list held in |
| 738 | * the HTT pdev |
| 739 | * |
| 740 | * Return: none |
| 741 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 742 | 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] | 743 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 744 | struct qdf_tso_seg_elem_t *tso_seg = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 745 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 746 | qdf_spin_lock_bh(&pdev->tso_seg_pool.tso_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 747 | if (pdev->tso_seg_pool.freelist) { |
| 748 | pdev->tso_seg_pool.num_free--; |
| 749 | tso_seg = pdev->tso_seg_pool.freelist; |
| 750 | pdev->tso_seg_pool.freelist = pdev->tso_seg_pool.freelist->next; |
| 751 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 752 | qdf_spin_unlock_bh(&pdev->tso_seg_pool.tso_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 753 | |
| 754 | return tso_seg; |
| 755 | } |
| 756 | |
| 757 | /** |
| 758 | * ol_tso_free_segment() - function to free a TSO segment |
| 759 | * element |
| 760 | * @pdev: HTT pdev |
| 761 | * @tso_seg: The TSO segment element to be freed |
| 762 | * |
| 763 | * Returns a TSO segment element to the free list held in the |
| 764 | * HTT pdev |
| 765 | * |
| 766 | * Return: none |
| 767 | */ |
| 768 | |
| 769 | void ol_tso_free_segment(struct ol_txrx_pdev_t *pdev, |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 770 | struct qdf_tso_seg_elem_t *tso_seg) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 771 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 772 | qdf_spin_lock_bh(&pdev->tso_seg_pool.tso_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 773 | tso_seg->next = pdev->tso_seg_pool.freelist; |
| 774 | pdev->tso_seg_pool.freelist = tso_seg; |
| 775 | pdev->tso_seg_pool.num_free++; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 776 | qdf_spin_unlock_bh(&pdev->tso_seg_pool.tso_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 777 | } |
| 778 | #endif |