Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Komal Seelam | 7fde14c | 2016-02-02 13:05:57 +0530 | [diff] [blame] | 2 | * Copyright (c) 2011-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 | /* OS abstraction libraries */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 29 | #include <qdf_nbuf.h> /* qdf_nbuf_t, etc. */ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 30 | #include <qdf_atomic.h> /* qdf_atomic_read, etc. */ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 31 | #include <qdf_util.h> /* qdf_unlikely */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 32 | |
| 33 | /* APIs for other modules */ |
| 34 | #include <htt.h> /* HTT_TX_EXT_TID_MGMT */ |
| 35 | #include <ol_htt_tx_api.h> /* htt_tx_desc_tid */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 36 | |
| 37 | /* internal header files relevant for all systems */ |
| 38 | #include <ol_txrx_internal.h> /* TXRX_ASSERT1 */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 39 | #include <ol_tx_desc.h> /* ol_tx_desc */ |
| 40 | #include <ol_tx_send.h> /* ol_tx_send */ |
| 41 | #include <ol_txrx.h> |
| 42 | |
| 43 | /* internal header files relevant only for HL systems */ |
| 44 | #include <ol_tx_queue.h> /* ol_tx_enqueue */ |
| 45 | |
| 46 | /* internal header files relevant only for specific systems (Pronto) */ |
| 47 | #include <ol_txrx_encap.h> /* OL_TX_ENCAP, etc */ |
| 48 | #include <ol_tx.h> |
| 49 | |
| 50 | #ifdef WLAN_FEATURE_FASTPATH |
| 51 | #include <hif.h> /* HIF_DEVICE */ |
| 52 | #include <htc_api.h> /* Layering violation, but required for fast path */ |
| 53 | #include <htt_internal.h> |
| 54 | #include <htt_types.h> /* htc_endpoint */ |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 55 | #include <cdp_txrx_peer_ops.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 56 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 57 | int ce_send_fast(struct CE_handle *copyeng, qdf_nbuf_t *msdus, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 58 | unsigned int num_msdus, unsigned int transfer_id); |
| 59 | #endif /* WLAN_FEATURE_FASTPATH */ |
| 60 | |
| 61 | /* |
| 62 | * The TXRX module doesn't accept tx frames unless the target has |
| 63 | * enough descriptors for them. |
| 64 | * For LL, the TXRX descriptor pool is sized to match the target's |
| 65 | * descriptor pool. Hence, if the descriptor allocation in TXRX |
| 66 | * succeeds, that guarantees that the target has room to accept |
| 67 | * the new tx frame. |
| 68 | */ |
| 69 | #define ol_tx_prepare_ll(tx_desc, vdev, msdu, msdu_info) \ |
| 70 | do { \ |
| 71 | struct ol_txrx_pdev_t *pdev = vdev->pdev; \ |
| 72 | (msdu_info)->htt.info.frame_type = pdev->htt_pkt_type; \ |
| 73 | tx_desc = ol_tx_desc_ll(pdev, vdev, msdu, msdu_info); \ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 74 | if (qdf_unlikely(!tx_desc)) { \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 75 | TXRX_STATS_MSDU_LIST_INCR( \ |
| 76 | pdev, tx.dropped.host_reject, msdu); \ |
| 77 | return msdu; /* the list of unaccepted MSDUs */ \ |
| 78 | } \ |
| 79 | } while (0) |
| 80 | |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 81 | #if defined(FEATURE_TSO) |
| 82 | /** |
| 83 | * ol_tx_prepare_tso() - Given a jumbo msdu, prepare the TSO |
| 84 | * related information in the msdu_info meta data |
| 85 | * @vdev: virtual device handle |
| 86 | * @msdu: network buffer |
| 87 | * @msdu_info: meta data associated with the msdu |
| 88 | * |
| 89 | * Return: 0 - success, >0 - error |
| 90 | */ |
| 91 | static inline uint8_t ol_tx_prepare_tso(ol_txrx_vdev_handle vdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 92 | qdf_nbuf_t msdu, struct ol_txrx_msdu_info_t *msdu_info) |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 93 | { |
| 94 | msdu_info->tso_info.curr_seg = NULL; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 95 | if (qdf_nbuf_is_tso(msdu)) { |
| 96 | int num_seg = qdf_nbuf_get_tso_num_seg(msdu); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 97 | msdu_info->tso_info.tso_seg_list = NULL; |
| 98 | msdu_info->tso_info.num_segs = num_seg; |
| 99 | while (num_seg) { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 100 | struct qdf_tso_seg_elem_t *tso_seg = |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 101 | ol_tso_alloc_segment(vdev->pdev); |
| 102 | if (tso_seg) { |
| 103 | tso_seg->next = |
| 104 | msdu_info->tso_info.tso_seg_list; |
| 105 | msdu_info->tso_info.tso_seg_list |
| 106 | = tso_seg; |
| 107 | num_seg--; |
| 108 | } else { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 109 | struct qdf_tso_seg_elem_t *next_seg; |
| 110 | struct qdf_tso_seg_elem_t *free_seg = |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 111 | msdu_info->tso_info.tso_seg_list; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 112 | qdf_print("TSO seg alloc failed!\n"); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 113 | while (free_seg) { |
| 114 | next_seg = free_seg->next; |
| 115 | ol_tso_free_segment(vdev->pdev, |
| 116 | free_seg); |
| 117 | free_seg = next_seg; |
| 118 | } |
| 119 | return 1; |
| 120 | } |
| 121 | } |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 122 | qdf_nbuf_get_tso_info(vdev->pdev->osdev, |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 123 | msdu, &(msdu_info->tso_info)); |
| 124 | msdu_info->tso_info.curr_seg = |
| 125 | msdu_info->tso_info.tso_seg_list; |
| 126 | num_seg = msdu_info->tso_info.num_segs; |
| 127 | } else { |
| 128 | msdu_info->tso_info.is_tso = 0; |
| 129 | msdu_info->tso_info.num_segs = 1; |
| 130 | } |
| 131 | return 0; |
| 132 | } |
| 133 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 134 | |
| 135 | /** |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 136 | * ol_tx_data() - send data frame |
| 137 | * @vdev: virtual device handle |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 138 | * @skb: skb |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 139 | * |
| 140 | * Return: skb/NULL for success |
| 141 | */ |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 142 | qdf_nbuf_t ol_tx_data(ol_txrx_vdev_handle vdev, qdf_nbuf_t skb) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 143 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 144 | void *qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 145 | struct ol_txrx_pdev_t *pdev = vdev->pdev; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 146 | qdf_nbuf_t ret; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 147 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 148 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 149 | if (qdf_unlikely(!pdev)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 150 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 151 | "%s:pdev is null", __func__); |
| 152 | return skb; |
| 153 | } |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 154 | if (qdf_unlikely(!qdf_ctx)) { |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 155 | TXRX_PRINT(TXRX_PRINT_LEVEL_ERR, |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 156 | "%s:qdf_ctx is null", __func__); |
Orhan K AKYILDIZ | c409461 | 2015-11-11 18:01:15 -0800 | [diff] [blame] | 157 | return skb; |
| 158 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 159 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 160 | status = qdf_nbuf_map_single(qdf_ctx, skb, QDF_DMA_TO_DEVICE); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 161 | if (qdf_unlikely(status != QDF_STATUS_SUCCESS)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 162 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 163 | "%s: nbuf map failed", __func__); |
| 164 | return skb; |
| 165 | } |
| 166 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 167 | if ((ol_cfg_is_ip_tcp_udp_checksum_offload_enabled(pdev->ctrl_pdev)) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 168 | && (qdf_nbuf_get_protocol(skb) == htons(ETH_P_IP)) |
| 169 | && (qdf_nbuf_get_ip_summed(skb) == CHECKSUM_PARTIAL)) |
| 170 | qdf_nbuf_set_ip_summed(skb, CHECKSUM_COMPLETE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 171 | |
| 172 | /* Terminate the (single-element) list of tx frames */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 173 | qdf_nbuf_set_next(skb, NULL); |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 174 | ret = OL_TX_LL(vdev, skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 175 | if (ret) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 176 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 177 | "%s: Failed to tx", __func__); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 178 | qdf_nbuf_unmap_single(qdf_ctx, ret, QDF_DMA_TO_DEVICE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 179 | return ret; |
| 180 | } |
| 181 | |
| 182 | return NULL; |
| 183 | } |
| 184 | |
| 185 | #ifdef IPA_OFFLOAD |
| 186 | /** |
| 187 | * ol_tx_send_ipa_data_frame() - send IPA data frame |
| 188 | * @vdev: vdev |
| 189 | * @skb: skb |
| 190 | * |
| 191 | * Return: skb/ NULL is for success |
| 192 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 193 | qdf_nbuf_t ol_tx_send_ipa_data_frame(void *vdev, |
| 194 | qdf_nbuf_t skb) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 195 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 196 | ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 197 | qdf_nbuf_t ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 198 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 199 | if (qdf_unlikely(!pdev)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 200 | TXRX_PRINT(TXRX_PRINT_LEVEL_ERR, |
| 201 | "%s: pdev is NULL", __func__); |
| 202 | return skb; |
| 203 | } |
| 204 | |
| 205 | if ((ol_cfg_is_ip_tcp_udp_checksum_offload_enabled(pdev->ctrl_pdev)) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 206 | && (qdf_nbuf_get_protocol(skb) == htons(ETH_P_IP)) |
| 207 | && (qdf_nbuf_get_ip_summed(skb) == CHECKSUM_PARTIAL)) |
| 208 | qdf_nbuf_set_ip_summed(skb, CHECKSUM_COMPLETE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 209 | |
| 210 | /* Terminate the (single-element) list of tx frames */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 211 | qdf_nbuf_set_next(skb, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 212 | ret = OL_TX_LL((struct ol_txrx_vdev_t *)vdev, skb); |
| 213 | if (ret) { |
| 214 | TXRX_PRINT(TXRX_PRINT_LEVEL_WARN, |
| 215 | "%s: Failed to tx", __func__); |
| 216 | return ret; |
| 217 | } |
| 218 | |
| 219 | return NULL; |
| 220 | } |
| 221 | #endif |
| 222 | |
| 223 | |
| 224 | #if defined(FEATURE_TSO) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 225 | qdf_nbuf_t ol_tx_ll(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 226 | { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 227 | qdf_nbuf_t msdu = msdu_list; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 228 | struct ol_txrx_msdu_info_t msdu_info; |
| 229 | |
| 230 | msdu_info.htt.info.l2_hdr_type = vdev->pdev->htt_pkt_type; |
| 231 | msdu_info.htt.action.tx_comp_req = 0; |
| 232 | /* |
| 233 | * The msdu_list variable could be used instead of the msdu var, |
| 234 | * but just to clarify which operations are done on a single MSDU |
| 235 | * vs. a list of MSDUs, use a distinct variable for single MSDUs |
| 236 | * within the list. |
| 237 | */ |
| 238 | while (msdu) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 239 | qdf_nbuf_t next; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 240 | struct ol_tx_desc_t *tx_desc; |
| 241 | int segments = 1; |
| 242 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 243 | msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 244 | msdu_info.peer = NULL; |
| 245 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 246 | if (qdf_unlikely(ol_tx_prepare_tso(vdev, msdu, &msdu_info))) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 247 | qdf_print("ol_tx_prepare_tso failed\n"); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 248 | TXRX_STATS_MSDU_LIST_INCR(vdev->pdev, |
| 249 | tx.dropped.host_reject, msdu); |
| 250 | return msdu; |
| 251 | } |
| 252 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 253 | segments = msdu_info.tso_info.num_segs; |
| 254 | |
| 255 | /* |
| 256 | * The netbuf may get linked into a different list inside the |
| 257 | * ol_tx_send function, so store the next pointer before the |
| 258 | * tx_send call. |
| 259 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 260 | next = qdf_nbuf_next(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 261 | /* init the current segment to the 1st segment in the list */ |
| 262 | while (segments) { |
| 263 | |
| 264 | if (msdu_info.tso_info.curr_seg) |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 265 | QDF_NBUF_CB_PADDR(msdu) = |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 266 | msdu_info.tso_info.curr_seg-> |
| 267 | seg.tso_frags[0].paddr_low_32; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 268 | |
| 269 | segments--; |
| 270 | |
| 271 | /** |
| 272 | * if this is a jumbo nbuf, then increment the number |
| 273 | * of nbuf users for each additional segment of the msdu. |
| 274 | * This will ensure that the skb is freed only after |
| 275 | * receiving tx completion for all segments of an nbuf |
| 276 | */ |
| 277 | if (segments) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 278 | qdf_nbuf_inc_users(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 279 | |
| 280 | ol_tx_prepare_ll(tx_desc, vdev, msdu, &msdu_info); |
| 281 | |
| 282 | /* |
| 283 | * If debug display is enabled, show the meta-data being |
| 284 | * downloaded to the target via the HTT tx descriptor. |
| 285 | */ |
| 286 | htt_tx_desc_display(tx_desc->htt_tx_desc); |
| 287 | |
| 288 | ol_tx_send(vdev->pdev, tx_desc, msdu); |
| 289 | |
| 290 | if (msdu_info.tso_info.curr_seg) { |
| 291 | msdu_info.tso_info.curr_seg = |
| 292 | msdu_info.tso_info.curr_seg->next; |
| 293 | } |
| 294 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 295 | qdf_nbuf_reset_num_frags(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 296 | |
| 297 | if (msdu_info.tso_info.is_tso) { |
| 298 | TXRX_STATS_TSO_INC_SEG(vdev->pdev); |
| 299 | TXRX_STATS_TSO_INC_SEG_IDX(vdev->pdev); |
| 300 | } |
| 301 | } /* while segments */ |
| 302 | |
| 303 | msdu = next; |
| 304 | if (msdu_info.tso_info.is_tso) { |
| 305 | TXRX_STATS_TSO_INC_MSDU_IDX(vdev->pdev); |
| 306 | TXRX_STATS_TSO_RESET_MSDU(vdev->pdev); |
| 307 | } |
| 308 | } /* while msdus */ |
| 309 | return NULL; /* all MSDUs were accepted */ |
| 310 | } |
| 311 | #else /* TSO */ |
| 312 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 313 | qdf_nbuf_t ol_tx_ll(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 314 | { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 315 | qdf_nbuf_t msdu = msdu_list; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 316 | struct ol_txrx_msdu_info_t msdu_info; |
| 317 | |
| 318 | msdu_info.htt.info.l2_hdr_type = vdev->pdev->htt_pkt_type; |
| 319 | msdu_info.htt.action.tx_comp_req = 0; |
| 320 | msdu_info.tso_info.is_tso = 0; |
| 321 | /* |
| 322 | * The msdu_list variable could be used instead of the msdu var, |
| 323 | * but just to clarify which operations are done on a single MSDU |
| 324 | * vs. a list of MSDUs, use a distinct variable for single MSDUs |
| 325 | * within the list. |
| 326 | */ |
| 327 | while (msdu) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 328 | qdf_nbuf_t next; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 329 | struct ol_tx_desc_t *tx_desc; |
| 330 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 331 | msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 332 | msdu_info.peer = NULL; |
| 333 | ol_tx_prepare_ll(tx_desc, vdev, msdu, &msdu_info); |
| 334 | |
| 335 | /* |
| 336 | * If debug display is enabled, show the meta-data being |
| 337 | * downloaded to the target via the HTT tx descriptor. |
| 338 | */ |
| 339 | htt_tx_desc_display(tx_desc->htt_tx_desc); |
| 340 | /* |
| 341 | * The netbuf may get linked into a different list inside the |
| 342 | * ol_tx_send function, so store the next pointer before the |
| 343 | * tx_send call. |
| 344 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 345 | next = qdf_nbuf_next(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 346 | ol_tx_send(vdev->pdev, tx_desc, msdu); |
| 347 | msdu = next; |
| 348 | } |
| 349 | return NULL; /* all MSDUs were accepted */ |
| 350 | } |
| 351 | #endif /* TSO */ |
| 352 | |
| 353 | #ifdef WLAN_FEATURE_FASTPATH |
| 354 | /** |
| 355 | * ol_tx_prepare_ll_fast() Alloc and prepare Tx descriptor |
| 356 | * |
| 357 | * Allocate and prepare Tx descriptor with msdu and fragment descritor |
| 358 | * inforamtion. |
| 359 | * |
| 360 | * @pdev: pointer to ol pdev handle |
| 361 | * @vdev: pointer to ol vdev handle |
| 362 | * @msdu: linked list of msdu packets |
| 363 | * @pkt_download_len: packet download length |
| 364 | * @ep_id: endpoint ID |
| 365 | * @msdu_info: Handle to msdu_info |
| 366 | * |
| 367 | * Return: Pointer to Tx descriptor |
| 368 | */ |
| 369 | static inline struct ol_tx_desc_t * |
| 370 | ol_tx_prepare_ll_fast(struct ol_txrx_pdev_t *pdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 371 | ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 372 | uint32_t pkt_download_len, uint32_t ep_id, |
| 373 | struct ol_txrx_msdu_info_t *msdu_info) |
| 374 | { |
| 375 | struct ol_tx_desc_t *tx_desc = NULL; |
| 376 | uint32_t *htt_tx_desc; |
| 377 | void *htc_hdr_vaddr; |
| 378 | u_int32_t num_frags, i; |
| 379 | |
| 380 | tx_desc = ol_tx_desc_alloc_wrapper(pdev, vdev, msdu_info); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 381 | if (qdf_unlikely(!tx_desc)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 382 | return NULL; |
| 383 | |
| 384 | tx_desc->netbuf = msdu; |
| 385 | if (msdu_info->tso_info.is_tso) { |
| 386 | tx_desc->tso_desc = msdu_info->tso_info.curr_seg; |
| 387 | tx_desc->pkt_type = ol_tx_frm_tso; |
| 388 | TXRX_STATS_MSDU_INCR(pdev, tx.tso.tso_pkts, msdu); |
| 389 | } else { |
| 390 | tx_desc->pkt_type = ol_tx_frm_std; |
| 391 | } |
| 392 | |
| 393 | htt_tx_desc = tx_desc->htt_tx_desc; |
| 394 | |
| 395 | /* Make sure frags num is set to 0 */ |
| 396 | /* |
| 397 | * Do this here rather than in hardstart, so |
| 398 | * that we can hopefully take only one cache-miss while |
| 399 | * accessing skb->cb. |
| 400 | */ |
| 401 | |
| 402 | /* HTT Header */ |
| 403 | /* TODO : Take care of multiple fragments */ |
| 404 | |
| 405 | /* TODO: Precompute and store paddr in ol_tx_desc_t */ |
| 406 | /* Virtual address of the HTT/HTC header, added by driver */ |
| 407 | htc_hdr_vaddr = (char *)htt_tx_desc - HTC_HEADER_LEN; |
| 408 | htt_tx_desc_init(pdev->htt_pdev, htt_tx_desc, |
| 409 | tx_desc->htt_tx_desc_paddr, tx_desc->id, msdu, |
| 410 | &msdu_info->htt, &msdu_info->tso_info, |
| 411 | NULL, vdev->opmode == wlan_op_mode_ocb); |
| 412 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 413 | num_frags = qdf_nbuf_get_num_frags(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 414 | /* num_frags are expected to be 2 max */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 415 | num_frags = (num_frags > QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS) |
| 416 | ? QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 417 | : num_frags; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 418 | #if defined(HELIUMPLUS_PADDR64) |
| 419 | /* |
| 420 | * Use num_frags - 1, since 1 frag is used to store |
| 421 | * the HTT/HTC descriptor |
| 422 | * Refer to htt_tx_desc_init() |
| 423 | */ |
| 424 | htt_tx_desc_num_frags(pdev->htt_pdev, tx_desc->htt_frag_desc, |
| 425 | num_frags - 1); |
| 426 | #else /* ! defined(HELIUMPLUSPADDR64) */ |
| 427 | htt_tx_desc_num_frags(pdev->htt_pdev, tx_desc->htt_tx_desc, |
| 428 | num_frags-1); |
| 429 | #endif /* defined(HELIUMPLUS_PADDR64) */ |
| 430 | if (msdu_info->tso_info.is_tso) { |
| 431 | htt_tx_desc_fill_tso_info(pdev->htt_pdev, |
| 432 | tx_desc->htt_frag_desc, &msdu_info->tso_info); |
| 433 | TXRX_STATS_TSO_SEG_UPDATE(pdev, |
| 434 | msdu_info->tso_info.curr_seg->seg); |
| 435 | } else { |
| 436 | for (i = 1; i < num_frags; i++) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 437 | qdf_size_t frag_len; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 438 | qdf_dma_addr_t frag_paddr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 439 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 440 | frag_len = qdf_nbuf_get_frag_len(msdu, i); |
| 441 | frag_paddr = qdf_nbuf_get_frag_paddr(msdu, i); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 442 | #if defined(HELIUMPLUS_PADDR64) |
| 443 | htt_tx_desc_frag(pdev->htt_pdev, tx_desc->htt_frag_desc, |
| 444 | i - 1, frag_paddr, frag_len); |
| 445 | #if defined(HELIUMPLUS_DEBUG) |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 446 | qdf_print("%s:%d: htt_fdesc=%p frag=%d frag_paddr=0x%0llx len=%zu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 447 | __func__, __LINE__, tx_desc->htt_frag_desc, |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 448 | i-1, frag_paddr, frag_len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 449 | dump_pkt(netbuf, frag_paddr, 64); |
| 450 | #endif /* HELIUMPLUS_DEBUG */ |
| 451 | #else /* ! defined(HELIUMPLUSPADDR64) */ |
| 452 | htt_tx_desc_frag(pdev->htt_pdev, tx_desc->htt_tx_desc, |
| 453 | i - 1, frag_paddr, frag_len); |
| 454 | #endif /* defined(HELIUMPLUS_PADDR64) */ |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | /* |
| 459 | * Do we want to turn on word_stream bit-map here ? For linux, non-TSO |
| 460 | * this is not required. We still have to mark the swap bit correctly, |
| 461 | * when posting to the ring |
| 462 | */ |
| 463 | /* Check to make sure, data download length is correct */ |
| 464 | |
| 465 | /* |
| 466 | * TODO : Can we remove this check and always download a fixed length ? |
| 467 | * */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 468 | if (qdf_unlikely(qdf_nbuf_len(msdu) < pkt_download_len)) |
| 469 | pkt_download_len = qdf_nbuf_len(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 470 | |
| 471 | /* Fill the HTC header information */ |
| 472 | /* |
| 473 | * Passing 0 as the seq_no field, we can probably get away |
| 474 | * with it for the time being, since this is not checked in f/w |
| 475 | */ |
| 476 | /* TODO : Prefill this, look at multi-fragment case */ |
| 477 | HTC_TX_DESC_FILL(htc_hdr_vaddr, pkt_download_len, ep_id, 0); |
| 478 | |
| 479 | return tx_desc; |
| 480 | } |
| 481 | #if defined(FEATURE_TSO) |
| 482 | /** |
| 483 | * ol_tx_ll_fast() Update metadata information and send msdu to HIF/CE |
| 484 | * |
| 485 | * @vdev: handle to ol_txrx_vdev_t |
| 486 | * @msdu_list: msdu list to be sent out. |
| 487 | * |
| 488 | * Return: on success return NULL, pointer to nbuf when it fails to send. |
| 489 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 490 | qdf_nbuf_t |
| 491 | ol_tx_ll_fast(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 492 | { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 493 | qdf_nbuf_t msdu = msdu_list; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 494 | struct ol_txrx_pdev_t *pdev = vdev->pdev; |
| 495 | uint32_t pkt_download_len = |
| 496 | ((struct htt_pdev_t *)(pdev->htt_pdev))->download_len; |
| 497 | uint32_t ep_id = HTT_EPID_GET(pdev->htt_pdev); |
| 498 | struct ol_txrx_msdu_info_t msdu_info; |
| 499 | |
| 500 | msdu_info.htt.info.l2_hdr_type = vdev->pdev->htt_pkt_type; |
| 501 | msdu_info.htt.action.tx_comp_req = 0; |
| 502 | /* |
| 503 | * The msdu_list variable could be used instead of the msdu var, |
| 504 | * but just to clarify which operations are done on a single MSDU |
| 505 | * vs. a list of MSDUs, use a distinct variable for single MSDUs |
| 506 | * within the list. |
| 507 | */ |
| 508 | while (msdu) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 509 | qdf_nbuf_t next; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 510 | struct ol_tx_desc_t *tx_desc; |
| 511 | int segments = 1; |
| 512 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 513 | msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 514 | msdu_info.peer = NULL; |
| 515 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 516 | if (qdf_unlikely(ol_tx_prepare_tso(vdev, msdu, &msdu_info))) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 517 | qdf_print("ol_tx_prepare_tso failed\n"); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 518 | TXRX_STATS_MSDU_LIST_INCR(vdev->pdev, |
| 519 | tx.dropped.host_reject, msdu); |
| 520 | return msdu; |
| 521 | } |
| 522 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 523 | segments = msdu_info.tso_info.num_segs; |
| 524 | |
| 525 | /* |
| 526 | * The netbuf may get linked into a different list |
| 527 | * inside the ce_send_fast function, so store the next |
| 528 | * pointer before the ce_send call. |
| 529 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 530 | next = qdf_nbuf_next(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 531 | /* init the current segment to the 1st segment in the list */ |
| 532 | while (segments) { |
| 533 | |
| 534 | if (msdu_info.tso_info.curr_seg) |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 535 | QDF_NBUF_CB_PADDR(msdu) = msdu_info.tso_info. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 536 | curr_seg->seg.tso_frags[0].paddr_low_32; |
| 537 | |
| 538 | segments--; |
| 539 | |
| 540 | /** |
| 541 | * if this is a jumbo nbuf, then increment the number |
| 542 | * of nbuf users for each additional segment of the msdu. |
| 543 | * This will ensure that the skb is freed only after |
| 544 | * receiving tx completion for all segments of an nbuf |
| 545 | */ |
| 546 | if (segments) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 547 | qdf_nbuf_inc_users(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 548 | |
| 549 | msdu_info.htt.info.frame_type = pdev->htt_pkt_type; |
| 550 | msdu_info.htt.info.vdev_id = vdev->vdev_id; |
| 551 | msdu_info.htt.action.cksum_offload = |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 552 | qdf_nbuf_get_tx_cksum(msdu); |
| 553 | switch (qdf_nbuf_get_exemption_type(msdu)) { |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 554 | case QDF_NBUF_EXEMPT_NO_EXEMPTION: |
| 555 | case QDF_NBUF_EXEMPT_ON_KEY_MAPPING_KEY_UNAVAILABLE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 556 | /* We want to encrypt this frame */ |
| 557 | msdu_info.htt.action.do_encrypt = 1; |
| 558 | break; |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 559 | case QDF_NBUF_EXEMPT_ALWAYS: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 560 | /* We don't want to encrypt this frame */ |
| 561 | msdu_info.htt.action.do_encrypt = 0; |
| 562 | break; |
| 563 | default: |
| 564 | msdu_info.htt.action.do_encrypt = 1; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 565 | qdf_assert(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 566 | break; |
| 567 | } |
| 568 | |
| 569 | tx_desc = ol_tx_prepare_ll_fast(pdev, vdev, msdu, |
| 570 | pkt_download_len, ep_id, |
| 571 | &msdu_info); |
| 572 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 573 | if (qdf_likely(tx_desc)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 574 | /* |
| 575 | * If debug display is enabled, show the meta |
| 576 | * data being downloaded to the target via the |
| 577 | * HTT tx descriptor. |
| 578 | */ |
| 579 | htt_tx_desc_display(tx_desc->htt_tx_desc); |
| 580 | if ((0 == ce_send_fast(pdev->ce_tx_hdl, &msdu, |
| 581 | 1, ep_id))) { |
| 582 | /* |
| 583 | * The packet could not be sent. |
| 584 | * Free the descriptor, return the |
| 585 | * packet to the caller. |
| 586 | */ |
| 587 | ol_tx_desc_free(pdev, tx_desc); |
| 588 | return msdu; |
| 589 | } |
| 590 | if (msdu_info.tso_info.curr_seg) { |
| 591 | msdu_info.tso_info.curr_seg = |
| 592 | msdu_info.tso_info.curr_seg->next; |
| 593 | } |
| 594 | |
| 595 | if (msdu_info.tso_info.is_tso) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 596 | qdf_nbuf_reset_num_frags(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 597 | TXRX_STATS_TSO_INC_SEG(vdev->pdev); |
| 598 | TXRX_STATS_TSO_INC_SEG_IDX(vdev->pdev); |
| 599 | } |
| 600 | } else { |
| 601 | TXRX_STATS_MSDU_LIST_INCR( |
| 602 | pdev, tx.dropped.host_reject, msdu); |
| 603 | /* the list of unaccepted MSDUs */ |
| 604 | return msdu; |
| 605 | } |
| 606 | } /* while segments */ |
| 607 | |
| 608 | msdu = next; |
| 609 | if (msdu_info.tso_info.is_tso) { |
| 610 | TXRX_STATS_TSO_INC_MSDU_IDX(vdev->pdev); |
| 611 | TXRX_STATS_TSO_RESET_MSDU(vdev->pdev); |
| 612 | } |
| 613 | } /* while msdus */ |
| 614 | return NULL; /* all MSDUs were accepted */ |
| 615 | } |
| 616 | #else |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 617 | qdf_nbuf_t |
| 618 | ol_tx_ll_fast(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 619 | { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 620 | qdf_nbuf_t msdu = msdu_list; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 621 | struct ol_txrx_pdev_t *pdev = vdev->pdev; |
| 622 | uint32_t pkt_download_len = |
| 623 | ((struct htt_pdev_t *)(pdev->htt_pdev))->download_len; |
| 624 | uint32_t ep_id = HTT_EPID_GET(pdev->htt_pdev); |
| 625 | struct ol_txrx_msdu_info_t msdu_info; |
| 626 | |
| 627 | msdu_info.htt.info.l2_hdr_type = vdev->pdev->htt_pkt_type; |
| 628 | msdu_info.htt.action.tx_comp_req = 0; |
| 629 | msdu_info.tso_info.is_tso = 0; |
| 630 | /* |
| 631 | * The msdu_list variable could be used instead of the msdu var, |
| 632 | * but just to clarify which operations are done on a single MSDU |
| 633 | * vs. a list of MSDUs, use a distinct variable for single MSDUs |
| 634 | * within the list. |
| 635 | */ |
| 636 | while (msdu) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 637 | qdf_nbuf_t next; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 638 | struct ol_tx_desc_t *tx_desc; |
| 639 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 640 | msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 641 | msdu_info.peer = NULL; |
| 642 | |
| 643 | msdu_info.htt.info.frame_type = pdev->htt_pkt_type; |
| 644 | msdu_info.htt.info.vdev_id = vdev->vdev_id; |
| 645 | msdu_info.htt.action.cksum_offload = |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 646 | qdf_nbuf_get_tx_cksum(msdu); |
| 647 | switch (qdf_nbuf_get_exemption_type(msdu)) { |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 648 | case QDF_NBUF_EXEMPT_NO_EXEMPTION: |
| 649 | case QDF_NBUF_EXEMPT_ON_KEY_MAPPING_KEY_UNAVAILABLE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 650 | /* We want to encrypt this frame */ |
| 651 | msdu_info.htt.action.do_encrypt = 1; |
| 652 | break; |
Anurag Chouhan | c73697b | 2016-02-21 15:05:43 +0530 | [diff] [blame] | 653 | case QDF_NBUF_EXEMPT_ALWAYS: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 654 | /* We don't want to encrypt this frame */ |
| 655 | msdu_info.htt.action.do_encrypt = 0; |
| 656 | break; |
| 657 | default: |
| 658 | msdu_info.htt.action.do_encrypt = 1; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 659 | qdf_assert(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 660 | break; |
| 661 | } |
| 662 | |
| 663 | tx_desc = ol_tx_prepare_ll_fast(pdev, vdev, msdu, |
| 664 | pkt_download_len, ep_id, |
| 665 | &msdu_info); |
| 666 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 667 | if (qdf_likely(tx_desc)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 668 | /* |
| 669 | * If debug display is enabled, show the meta-data being |
| 670 | * downloaded to the target via the HTT tx descriptor. |
| 671 | */ |
| 672 | htt_tx_desc_display(tx_desc->htt_tx_desc); |
| 673 | /* |
| 674 | * The netbuf may get linked into a different list |
| 675 | * inside the ce_send_fast function, so store the next |
| 676 | * pointer before the ce_send call. |
| 677 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 678 | next = qdf_nbuf_next(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 679 | if ((0 == ce_send_fast(pdev->ce_tx_hdl, &msdu, 1, |
| 680 | ep_id))) { |
| 681 | /* The packet could not be sent */ |
| 682 | /* Free the descriptor, return the packet to the |
| 683 | * caller */ |
| 684 | ol_tx_desc_free(pdev, tx_desc); |
| 685 | return msdu; |
| 686 | } |
| 687 | msdu = next; |
| 688 | } else { |
| 689 | TXRX_STATS_MSDU_LIST_INCR( |
| 690 | pdev, tx.dropped.host_reject, msdu); |
| 691 | return msdu; /* the list of unaccepted MSDUs */ |
| 692 | } |
| 693 | } |
| 694 | |
| 695 | return NULL; /* all MSDUs were accepted */ |
| 696 | } |
| 697 | #endif /* FEATURE_TSO */ |
| 698 | #endif /* WLAN_FEATURE_FASTPATH */ |
| 699 | |
| 700 | #ifdef WLAN_FEATURE_FASTPATH |
| 701 | /** |
| 702 | * ol_tx_ll_wrapper() wrapper to ol_tx_ll |
| 703 | * |
| 704 | */ |
Manjunathappa Prakash | 7e16b0a | 2016-03-08 15:24:48 -0800 | [diff] [blame^] | 705 | qdf_nbuf_t |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 706 | ol_tx_ll_wrapper(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 707 | { |
Komal Seelam | 3d20286 | 2016-02-24 18:43:24 +0530 | [diff] [blame] | 708 | struct hif_opaque_softc *hif_device = |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 709 | (struct hif_opaque_softc *)cds_get_context(QDF_MODULE_ID_HIF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 710 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 711 | if (qdf_likely(hif_device && hif_is_fastpath_mode_enabled(hif_device))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 712 | msdu_list = ol_tx_ll_fast(vdev, msdu_list); |
| 713 | else |
| 714 | msdu_list = ol_tx_ll(vdev, msdu_list); |
| 715 | |
| 716 | return msdu_list; |
| 717 | } |
| 718 | #else |
Manjunathappa Prakash | 7e16b0a | 2016-03-08 15:24:48 -0800 | [diff] [blame^] | 719 | qdf_nbuf_t |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 720 | ol_tx_ll_wrapper(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 721 | { |
| 722 | return ol_tx_ll(vdev, msdu_list); |
| 723 | } |
| 724 | #endif /* WLAN_FEATURE_FASTPATH */ |
| 725 | |
| 726 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 727 | |
| 728 | #define OL_TX_VDEV_PAUSE_QUEUE_SEND_MARGIN 400 |
| 729 | #define OL_TX_VDEV_PAUSE_QUEUE_SEND_PERIOD_MS 5 |
| 730 | static void ol_tx_vdev_ll_pause_queue_send_base(struct ol_txrx_vdev_t *vdev) |
| 731 | { |
| 732 | int max_to_accept; |
| 733 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 734 | qdf_spin_lock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 735 | if (vdev->ll_pause.paused_reason) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 736 | qdf_spin_unlock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 737 | return; |
| 738 | } |
| 739 | |
| 740 | /* |
| 741 | * Send as much of the backlog as possible, but leave some margin |
| 742 | * of unallocated tx descriptors that can be used for new frames |
| 743 | * being transmitted by other vdevs. |
| 744 | * Ideally there would be a scheduler, which would not only leave |
| 745 | * some margin for new frames for other vdevs, but also would |
| 746 | * fairly apportion the tx descriptors between multiple vdevs that |
| 747 | * have backlogs in their pause queues. |
| 748 | * However, the fairness benefit of having a scheduler for frames |
| 749 | * from multiple vdev's pause queues is not sufficient to outweigh |
| 750 | * the extra complexity. |
| 751 | */ |
| 752 | max_to_accept = vdev->pdev->tx_desc.num_free - |
| 753 | OL_TX_VDEV_PAUSE_QUEUE_SEND_MARGIN; |
| 754 | while (max_to_accept > 0 && vdev->ll_pause.txq.depth) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 755 | qdf_nbuf_t tx_msdu; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 756 | max_to_accept--; |
| 757 | vdev->ll_pause.txq.depth--; |
| 758 | tx_msdu = vdev->ll_pause.txq.head; |
| 759 | if (tx_msdu) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 760 | vdev->ll_pause.txq.head = qdf_nbuf_next(tx_msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 761 | if (NULL == vdev->ll_pause.txq.head) |
| 762 | vdev->ll_pause.txq.tail = NULL; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 763 | qdf_nbuf_set_next(tx_msdu, NULL); |
| 764 | QDF_NBUF_UPDATE_TX_PKT_COUNT(tx_msdu, |
| 765 | QDF_NBUF_TX_PKT_TXRX_DEQUEUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 766 | tx_msdu = ol_tx_ll_wrapper(vdev, tx_msdu); |
| 767 | /* |
| 768 | * It is unexpected that ol_tx_ll would reject the frame |
| 769 | * since we checked that there's room for it, though |
| 770 | * there's an infinitesimal possibility that between the |
| 771 | * time we checked the room available and now, a |
| 772 | * concurrent batch of tx frames used up all the room. |
| 773 | * For simplicity, just drop the frame. |
| 774 | */ |
| 775 | if (tx_msdu) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 776 | qdf_nbuf_unmap(vdev->pdev->osdev, tx_msdu, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 777 | QDF_DMA_TO_DEVICE); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 778 | qdf_nbuf_tx_free(tx_msdu, QDF_NBUF_PKT_ERROR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 779 | } |
| 780 | } |
| 781 | } |
| 782 | if (vdev->ll_pause.txq.depth) { |
Anurag Chouhan | 754fbd8 | 2016-02-19 17:00:08 +0530 | [diff] [blame] | 783 | qdf_timer_stop(&vdev->ll_pause.timer); |
| 784 | qdf_timer_start(&vdev->ll_pause.timer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 785 | OL_TX_VDEV_PAUSE_QUEUE_SEND_PERIOD_MS); |
| 786 | vdev->ll_pause.is_q_timer_on = true; |
| 787 | if (vdev->ll_pause.txq.depth >= vdev->ll_pause.max_q_depth) |
| 788 | vdev->ll_pause.q_overflow_cnt++; |
| 789 | } |
| 790 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 791 | qdf_spin_unlock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 792 | } |
| 793 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 794 | static qdf_nbuf_t |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 795 | ol_tx_vdev_pause_queue_append(struct ol_txrx_vdev_t *vdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 796 | qdf_nbuf_t msdu_list, uint8_t start_timer) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 797 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 798 | qdf_spin_lock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 799 | while (msdu_list && |
| 800 | vdev->ll_pause.txq.depth < vdev->ll_pause.max_q_depth) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 801 | qdf_nbuf_t next = qdf_nbuf_next(msdu_list); |
| 802 | QDF_NBUF_UPDATE_TX_PKT_COUNT(msdu_list, |
| 803 | QDF_NBUF_TX_PKT_TXRX_ENQUEUE); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 804 | DPTRACE(qdf_dp_trace(msdu_list, |
| 805 | QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 806 | (uint8_t *)(qdf_nbuf_data(msdu_list)), |
| 807 | sizeof(qdf_nbuf_data(msdu_list)))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 808 | |
| 809 | vdev->ll_pause.txq.depth++; |
| 810 | if (!vdev->ll_pause.txq.head) { |
| 811 | vdev->ll_pause.txq.head = msdu_list; |
| 812 | vdev->ll_pause.txq.tail = msdu_list; |
| 813 | } else { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 814 | qdf_nbuf_set_next(vdev->ll_pause.txq.tail, msdu_list); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 815 | } |
| 816 | vdev->ll_pause.txq.tail = msdu_list; |
| 817 | |
| 818 | msdu_list = next; |
| 819 | } |
| 820 | if (vdev->ll_pause.txq.tail) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 821 | qdf_nbuf_set_next(vdev->ll_pause.txq.tail, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 822 | |
| 823 | if (start_timer) { |
Anurag Chouhan | 754fbd8 | 2016-02-19 17:00:08 +0530 | [diff] [blame] | 824 | qdf_timer_stop(&vdev->ll_pause.timer); |
| 825 | qdf_timer_start(&vdev->ll_pause.timer, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 826 | OL_TX_VDEV_PAUSE_QUEUE_SEND_PERIOD_MS); |
| 827 | vdev->ll_pause.is_q_timer_on = true; |
| 828 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 829 | qdf_spin_unlock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 830 | |
| 831 | return msdu_list; |
| 832 | } |
| 833 | |
| 834 | /* |
| 835 | * Store up the tx frame in the vdev's tx queue if the vdev is paused. |
| 836 | * If there are too many frames in the tx queue, reject it. |
| 837 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 838 | qdf_nbuf_t ol_tx_ll_queue(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 839 | { |
| 840 | uint16_t eth_type; |
| 841 | uint32_t paused_reason; |
| 842 | |
| 843 | if (msdu_list == NULL) |
| 844 | return NULL; |
| 845 | |
| 846 | paused_reason = vdev->ll_pause.paused_reason; |
| 847 | if (paused_reason) { |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 848 | if (qdf_unlikely((paused_reason & |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 849 | OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED) == |
| 850 | paused_reason)) { |
| 851 | eth_type = (((struct ethernet_hdr_t *) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 852 | qdf_nbuf_data(msdu_list))-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 853 | ethertype[0] << 8) | |
| 854 | (((struct ethernet_hdr_t *) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 855 | qdf_nbuf_data(msdu_list))->ethertype[1]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 856 | if (ETHERTYPE_IS_EAPOL_WAPI(eth_type)) { |
| 857 | msdu_list = ol_tx_ll_wrapper(vdev, msdu_list); |
| 858 | return msdu_list; |
| 859 | } |
| 860 | } |
| 861 | msdu_list = ol_tx_vdev_pause_queue_append(vdev, msdu_list, 1); |
| 862 | } else { |
| 863 | if (vdev->ll_pause.txq.depth > 0 || |
| 864 | vdev->pdev->tx_throttle.current_throttle_level != |
| 865 | THROTTLE_LEVEL_0) { |
| 866 | /* not paused, but there is a backlog of frms |
| 867 | from a prior pause or throttle off phase */ |
| 868 | msdu_list = ol_tx_vdev_pause_queue_append( |
| 869 | vdev, msdu_list, 0); |
| 870 | /* if throttle is disabled or phase is "on", |
| 871 | send the frame */ |
| 872 | if (vdev->pdev->tx_throttle.current_throttle_level == |
| 873 | THROTTLE_LEVEL_0 || |
| 874 | vdev->pdev->tx_throttle.current_throttle_phase == |
| 875 | THROTTLE_PHASE_ON) { |
| 876 | /* send as many frames as possible |
| 877 | from the vdevs backlog */ |
| 878 | ol_tx_vdev_ll_pause_queue_send_base(vdev); |
| 879 | } |
| 880 | } else { |
| 881 | /* not paused, no throttle and no backlog - |
| 882 | send the new frames */ |
| 883 | msdu_list = ol_tx_ll_wrapper(vdev, msdu_list); |
| 884 | } |
| 885 | } |
| 886 | return msdu_list; |
| 887 | } |
| 888 | |
| 889 | /* |
| 890 | * Run through the transmit queues for all the vdevs and |
| 891 | * send the pending frames |
| 892 | */ |
| 893 | void ol_tx_pdev_ll_pause_queue_send_all(struct ol_txrx_pdev_t *pdev) |
| 894 | { |
| 895 | int max_to_send; /* tracks how many frames have been sent */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 896 | qdf_nbuf_t tx_msdu; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 897 | struct ol_txrx_vdev_t *vdev = NULL; |
| 898 | uint8_t more; |
| 899 | |
| 900 | if (NULL == pdev) |
| 901 | return; |
| 902 | |
| 903 | if (pdev->tx_throttle.current_throttle_phase == THROTTLE_PHASE_OFF) |
| 904 | return; |
| 905 | |
| 906 | /* ensure that we send no more than tx_threshold frames at once */ |
| 907 | max_to_send = pdev->tx_throttle.tx_threshold; |
| 908 | |
| 909 | /* round robin through the vdev queues for the given pdev */ |
| 910 | |
| 911 | /* Potential improvement: download several frames from the same vdev |
| 912 | at a time, since it is more likely that those frames could be |
| 913 | aggregated together, remember which vdev was serviced last, |
| 914 | so the next call this function can resume the round-robin |
| 915 | traversing where the current invocation left off */ |
| 916 | do { |
| 917 | more = 0; |
| 918 | TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { |
| 919 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 920 | qdf_spin_lock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | if (vdev->ll_pause.txq.depth) { |
| 922 | if (vdev->ll_pause.paused_reason) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 923 | qdf_spin_unlock_bh(&vdev->ll_pause. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 924 | mutex); |
| 925 | continue; |
| 926 | } |
| 927 | |
| 928 | tx_msdu = vdev->ll_pause.txq.head; |
| 929 | if (NULL == tx_msdu) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 930 | qdf_spin_unlock_bh(&vdev->ll_pause. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 931 | mutex); |
| 932 | continue; |
| 933 | } |
| 934 | |
| 935 | max_to_send--; |
| 936 | vdev->ll_pause.txq.depth--; |
| 937 | |
| 938 | vdev->ll_pause.txq.head = |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 939 | qdf_nbuf_next(tx_msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 940 | |
| 941 | if (NULL == vdev->ll_pause.txq.head) |
| 942 | vdev->ll_pause.txq.tail = NULL; |
| 943 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 944 | qdf_nbuf_set_next(tx_msdu, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 945 | tx_msdu = ol_tx_ll_wrapper(vdev, tx_msdu); |
| 946 | /* |
| 947 | * It is unexpected that ol_tx_ll would reject |
| 948 | * the frame, since we checked that there's |
| 949 | * room for it, though there's an infinitesimal |
| 950 | * possibility that between the time we checked |
| 951 | * the room available and now, a concurrent |
| 952 | * batch of tx frames used up all the room. |
| 953 | * For simplicity, just drop the frame. |
| 954 | */ |
| 955 | if (tx_msdu) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 956 | qdf_nbuf_unmap(pdev->osdev, tx_msdu, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 957 | QDF_DMA_TO_DEVICE); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 958 | qdf_nbuf_tx_free(tx_msdu, |
| 959 | QDF_NBUF_PKT_ERROR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 960 | } |
| 961 | } |
| 962 | /*check if there are more msdus to transmit */ |
| 963 | if (vdev->ll_pause.txq.depth) |
| 964 | more = 1; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 965 | qdf_spin_unlock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 966 | } |
| 967 | } while (more && max_to_send); |
| 968 | |
| 969 | vdev = NULL; |
| 970 | TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 971 | qdf_spin_lock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 972 | if (vdev->ll_pause.txq.depth) { |
Anurag Chouhan | 754fbd8 | 2016-02-19 17:00:08 +0530 | [diff] [blame] | 973 | qdf_timer_stop(&pdev->tx_throttle.tx_timer); |
| 974 | qdf_timer_start( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 975 | &pdev->tx_throttle.tx_timer, |
| 976 | OL_TX_VDEV_PAUSE_QUEUE_SEND_PERIOD_MS); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 977 | qdf_spin_unlock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 978 | return; |
| 979 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 980 | qdf_spin_unlock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 981 | } |
| 982 | } |
| 983 | |
| 984 | void ol_tx_vdev_ll_pause_queue_send(void *context) |
| 985 | { |
| 986 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)context; |
| 987 | struct ol_txrx_pdev_t *pdev = vdev->pdev; |
| 988 | |
| 989 | if (pdev->tx_throttle.current_throttle_level != THROTTLE_LEVEL_0 && |
| 990 | pdev->tx_throttle.current_throttle_phase == THROTTLE_PHASE_OFF) |
| 991 | return; |
| 992 | ol_tx_vdev_ll_pause_queue_send_base(vdev); |
| 993 | } |
| 994 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 995 | |
| 996 | static inline int ol_txrx_tx_is_raw(enum ol_tx_spec tx_spec) |
| 997 | { |
| 998 | return |
| 999 | tx_spec & |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1000 | (OL_TX_SPEC_RAW | OL_TX_SPEC_NO_AGGR | OL_TX_SPEC_NO_ENCRYPT); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1001 | } |
| 1002 | |
| 1003 | static inline uint8_t ol_txrx_tx_raw_subtype(enum ol_tx_spec tx_spec) |
| 1004 | { |
| 1005 | uint8_t sub_type = 0x1; /* 802.11 MAC header present */ |
| 1006 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1007 | if (tx_spec & OL_TX_SPEC_NO_AGGR) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1008 | sub_type |= 0x1 << HTT_TX_MSDU_DESC_RAW_SUBTYPE_NO_AGGR_S; |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1009 | if (tx_spec & OL_TX_SPEC_NO_ENCRYPT) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1010 | sub_type |= 0x1 << HTT_TX_MSDU_DESC_RAW_SUBTYPE_NO_ENCRYPT_S; |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1011 | if (tx_spec & OL_TX_SPEC_NWIFI_NO_ENCRYPT) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1012 | sub_type |= 0x1 << HTT_TX_MSDU_DESC_RAW_SUBTYPE_NO_ENCRYPT_S; |
| 1013 | return sub_type; |
| 1014 | } |
| 1015 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1016 | qdf_nbuf_t |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1017 | ol_tx_non_std_ll(ol_txrx_vdev_handle vdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1018 | enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1019 | { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1020 | qdf_nbuf_t msdu = msdu_list; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1021 | htt_pdev_handle htt_pdev = vdev->pdev->htt_pdev; |
| 1022 | struct ol_txrx_msdu_info_t msdu_info; |
| 1023 | |
| 1024 | msdu_info.htt.info.l2_hdr_type = vdev->pdev->htt_pkt_type; |
| 1025 | msdu_info.htt.action.tx_comp_req = 0; |
| 1026 | |
| 1027 | /* |
| 1028 | * The msdu_list variable could be used instead of the msdu var, |
| 1029 | * but just to clarify which operations are done on a single MSDU |
| 1030 | * vs. a list of MSDUs, use a distinct variable for single MSDUs |
| 1031 | * within the list. |
| 1032 | */ |
| 1033 | while (msdu) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1034 | qdf_nbuf_t next; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1035 | struct ol_tx_desc_t *tx_desc; |
| 1036 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1037 | msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | msdu_info.peer = NULL; |
| 1039 | msdu_info.tso_info.is_tso = 0; |
| 1040 | |
| 1041 | ol_tx_prepare_ll(tx_desc, vdev, msdu, &msdu_info); |
| 1042 | |
| 1043 | /* |
| 1044 | * The netbuf may get linked into a different list inside the |
| 1045 | * ol_tx_send function, so store the next pointer before the |
| 1046 | * tx_send call. |
| 1047 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1048 | next = qdf_nbuf_next(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1049 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1050 | if (tx_spec != OL_TX_SPEC_STD) { |
| 1051 | if (tx_spec & OL_TX_SPEC_NO_FREE) { |
| 1052 | tx_desc->pkt_type = OL_TX_SPEC_NO_FREE; |
| 1053 | } else if (tx_spec & OL_TX_SPEC_TSO) { |
| 1054 | tx_desc->pkt_type = OL_TX_SPEC_TSO; |
| 1055 | } else if (tx_spec & OL_TX_SPEC_NWIFI_NO_ENCRYPT) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1056 | uint8_t sub_type = |
| 1057 | ol_txrx_tx_raw_subtype(tx_spec); |
| 1058 | htt_tx_desc_type(htt_pdev, tx_desc->htt_tx_desc, |
| 1059 | htt_pkt_type_native_wifi, |
| 1060 | sub_type); |
| 1061 | } else if (ol_txrx_tx_is_raw(tx_spec)) { |
| 1062 | /* different types of raw frames */ |
| 1063 | uint8_t sub_type = |
| 1064 | ol_txrx_tx_raw_subtype(tx_spec); |
| 1065 | htt_tx_desc_type(htt_pdev, tx_desc->htt_tx_desc, |
| 1066 | htt_pkt_type_raw, sub_type); |
| 1067 | } |
| 1068 | } |
| 1069 | /* |
| 1070 | * If debug display is enabled, show the meta-data being |
| 1071 | * downloaded to the target via the HTT tx descriptor. |
| 1072 | */ |
| 1073 | htt_tx_desc_display(tx_desc->htt_tx_desc); |
| 1074 | ol_tx_send(vdev->pdev, tx_desc, msdu); |
| 1075 | msdu = next; |
| 1076 | } |
| 1077 | return NULL; /* all MSDUs were accepted */ |
| 1078 | } |
| 1079 | |
| 1080 | #ifdef QCA_SUPPORT_SW_TXRX_ENCAP |
| 1081 | #define OL_TX_ENCAP_WRAPPER(pdev, vdev, tx_desc, msdu, tx_msdu_info) \ |
| 1082 | do { \ |
| 1083 | if (OL_TX_ENCAP(vdev, tx_desc, msdu, &tx_msdu_info) != A_OK) { \ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 1084 | qdf_atomic_inc(&pdev->tx_queue.rsrc_cnt); \ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1085 | ol_tx_desc_frame_free_nonstd(pdev, tx_desc, 1); \ |
| 1086 | if (tx_msdu_info.peer) { \ |
| 1087 | /* remove the peer reference added above */ \ |
| 1088 | ol_txrx_peer_unref_delete(tx_msdu_info.peer); \ |
| 1089 | } \ |
| 1090 | goto MSDU_LOOP_BOTTOM; \ |
| 1091 | } \ |
| 1092 | } while (0) |
| 1093 | #else |
| 1094 | #define OL_TX_ENCAP_WRAPPER(pdev, vdev, tx_desc, msdu, tx_msdu_info) /* no-op */ |
| 1095 | #endif |
| 1096 | |
| 1097 | /* tx filtering is handled within the target FW */ |
| 1098 | #define TX_FILTER_CHECK(tx_msdu_info) 0 /* don't filter */ |
| 1099 | |
| 1100 | /** |
| 1101 | * parse_ocb_tx_header() - Function to check for OCB |
| 1102 | * TX control header on a packet and extract it if present |
| 1103 | * |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1104 | * @msdu: Pointer to OS packet (qdf_nbuf_t) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1105 | */ |
| 1106 | #define OCB_HEADER_VERSION 1 |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1107 | bool parse_ocb_tx_header(qdf_nbuf_t msdu, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1108 | struct ocb_tx_ctrl_hdr_t *tx_ctrl) |
| 1109 | { |
| 1110 | struct ether_header *eth_hdr_p; |
| 1111 | struct ocb_tx_ctrl_hdr_t *tx_ctrl_hdr; |
| 1112 | |
| 1113 | /* Check if TX control header is present */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1114 | eth_hdr_p = (struct ether_header *) qdf_nbuf_data(msdu); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1115 | if (eth_hdr_p->ether_type != QDF_SWAP_U16(ETHERTYPE_OCB_TX)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1116 | /* TX control header is not present. Nothing to do.. */ |
| 1117 | return true; |
| 1118 | |
| 1119 | /* Remove the ethernet header */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1120 | qdf_nbuf_pull_head(msdu, sizeof(struct ether_header)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1121 | |
| 1122 | /* Parse the TX control header */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1123 | tx_ctrl_hdr = (struct ocb_tx_ctrl_hdr_t *) qdf_nbuf_data(msdu); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1124 | |
| 1125 | if (tx_ctrl_hdr->version == OCB_HEADER_VERSION) { |
| 1126 | if (tx_ctrl) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1127 | qdf_mem_copy(tx_ctrl, tx_ctrl_hdr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1128 | sizeof(*tx_ctrl_hdr)); |
| 1129 | } else { |
| 1130 | /* The TX control header is invalid. */ |
| 1131 | return false; |
| 1132 | } |
| 1133 | |
| 1134 | /* Remove the TX control header */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1135 | qdf_nbuf_pull_head(msdu, tx_ctrl_hdr->length); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1136 | return true; |
| 1137 | } |
| 1138 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1139 | /** |
| 1140 | * ol_tx_non_std - Allow the control-path SW to send data frames |
| 1141 | * |
| 1142 | * @data_vdev - which vdev should transmit the tx data frames |
| 1143 | * @tx_spec - what non-standard handling to apply to the tx data frames |
| 1144 | * @msdu_list - NULL-terminated list of tx MSDUs |
| 1145 | * |
| 1146 | * Generally, all tx data frames come from the OS shim into the txrx layer. |
| 1147 | * However, there are rare cases such as TDLS messaging where the UMAC |
| 1148 | * control-path SW creates tx data frames. |
| 1149 | * This UMAC SW can call this function to provide the tx data frames to |
| 1150 | * the txrx layer. |
| 1151 | * The UMAC SW can request a callback for these data frames after their |
| 1152 | * transmission completes, by using the ol_txrx_data_tx_cb_set function |
| 1153 | * to register a tx completion callback, and by specifying |
| 1154 | * ol_tx_spec_no_free as the tx_spec arg when giving the frames to |
| 1155 | * ol_tx_non_std. |
| 1156 | * The MSDUs need to have the appropriate L2 header type (802.3 vs. 802.11), |
| 1157 | * as specified by ol_cfg_frame_type(). |
| 1158 | * |
| 1159 | * Return: null - success, skb - failure |
| 1160 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1161 | qdf_nbuf_t |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1162 | ol_tx_non_std(ol_txrx_vdev_handle vdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1163 | enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1164 | { |
| 1165 | return ol_tx_non_std_ll(vdev, tx_spec, msdu_list); |
| 1166 | } |
| 1167 | |
| 1168 | void |
| 1169 | ol_txrx_data_tx_cb_set(ol_txrx_vdev_handle vdev, |
| 1170 | ol_txrx_data_tx_cb callback, void *ctxt) |
| 1171 | { |
| 1172 | struct ol_txrx_pdev_t *pdev = vdev->pdev; |
| 1173 | pdev->tx_data_callback.func = callback; |
| 1174 | pdev->tx_data_callback.ctxt = ctxt; |
| 1175 | } |
| 1176 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1177 | /** |
| 1178 | * ol_txrx_mgmt_tx_cb_set() - Store a callback for delivery |
| 1179 | * notifications for management frames. |
| 1180 | * |
| 1181 | * @pdev - the data physical device object |
| 1182 | * @type - the type of mgmt frame the callback is used for |
| 1183 | * @download_cb - the callback for notification of delivery to the target |
| 1184 | * @ota_ack_cb - the callback for notification of delivery to the peer |
| 1185 | * @ctxt - context to use with the callback |
| 1186 | * |
| 1187 | * When the txrx SW receives notifications from the target that a tx frame |
| 1188 | * has been delivered to its recipient, it will check if the tx frame |
| 1189 | * is a management frame. If so, the txrx SW will check the management |
| 1190 | * frame type specified when the frame was submitted for transmission. |
| 1191 | * If there is a callback function registered for the type of managment |
| 1192 | * frame in question, the txrx code will invoke the callback to inform |
| 1193 | * the management + control SW that the mgmt frame was delivered. |
| 1194 | * This function is used by the control SW to store a callback pointer |
| 1195 | * for a given type of management frame. |
| 1196 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1197 | void |
| 1198 | ol_txrx_mgmt_tx_cb_set(ol_txrx_pdev_handle pdev, |
| 1199 | uint8_t type, |
| 1200 | ol_txrx_mgmt_tx_cb download_cb, |
| 1201 | ol_txrx_mgmt_tx_cb ota_ack_cb, void *ctxt) |
| 1202 | { |
| 1203 | TXRX_ASSERT1(type < OL_TXRX_MGMT_NUM_TYPES); |
| 1204 | pdev->tx_mgmt.callbacks[type].download_cb = download_cb; |
| 1205 | pdev->tx_mgmt.callbacks[type].ota_ack_cb = ota_ack_cb; |
| 1206 | pdev->tx_mgmt.callbacks[type].ctxt = ctxt; |
| 1207 | } |
| 1208 | |
| 1209 | #if defined(HELIUMPLUS_PADDR64) |
| 1210 | void dump_frag_desc(char *msg, struct ol_tx_desc_t *tx_desc) |
| 1211 | { |
| 1212 | uint32_t *frag_ptr_i_p; |
| 1213 | int i; |
| 1214 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1215 | qdf_print("OL TX Descriptor 0x%p msdu_id %d\n", |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1216 | tx_desc, tx_desc->id); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1217 | qdf_print("HTT TX Descriptor vaddr: 0x%p paddr: 0x%llx", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1218 | tx_desc->htt_tx_desc, tx_desc->htt_tx_desc_paddr); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1219 | qdf_print("%s %d: Fragment Descriptor 0x%p (paddr=0x%llx)", |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 1220 | __func__, __LINE__, tx_desc->htt_frag_desc, tx_desc->htt_frag_desc_paddr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1221 | |
| 1222 | /* it looks from htt_tx_desc_frag() that tx_desc->htt_frag_desc |
| 1223 | is already de-referrable (=> in virtual address space) */ |
| 1224 | frag_ptr_i_p = tx_desc->htt_frag_desc; |
| 1225 | |
| 1226 | /* Dump 6 words of TSO flags */ |
| 1227 | print_hex_dump(KERN_DEBUG, "MLE Desc:TSO Flags: ", |
| 1228 | DUMP_PREFIX_NONE, 8, 4, |
| 1229 | frag_ptr_i_p, 24, true); |
| 1230 | |
| 1231 | frag_ptr_i_p += 6; /* Skip 6 words of TSO flags */ |
| 1232 | |
| 1233 | i = 0; |
| 1234 | while (*frag_ptr_i_p) { |
| 1235 | print_hex_dump(KERN_DEBUG, "MLE Desc:Frag Ptr: ", |
| 1236 | DUMP_PREFIX_NONE, 8, 4, |
| 1237 | frag_ptr_i_p, 8, true); |
| 1238 | i++; |
| 1239 | if (i > 5) /* max 6 times: frag_ptr0 to frag_ptr5 */ |
| 1240 | break; |
| 1241 | else /* jump to next pointer - skip length */ |
| 1242 | frag_ptr_i_p += 2; |
| 1243 | } |
| 1244 | return; |
| 1245 | } |
| 1246 | #endif /* HELIUMPLUS_PADDR64 */ |
| 1247 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1248 | /** |
| 1249 | * ol_txrx_mgmt_send_ext() - Transmit a management frame |
| 1250 | * |
| 1251 | * @vdev - virtual device transmitting the frame |
| 1252 | * @tx_mgmt_frm - management frame to transmit |
| 1253 | * @type - the type of managment frame (determines what callback to use) |
| 1254 | * @use_6mbps - specify whether management frame to transmit should |
| 1255 | * use 6 Mbps rather than 1 Mbps min rate(for 5GHz band or P2P) |
| 1256 | * @chanfreq - channel to transmit the frame on |
| 1257 | * |
| 1258 | * Send the specified management frame from the specified virtual device. |
| 1259 | * The type is used for determining whether to invoke a callback to inform |
| 1260 | * the sender that the tx mgmt frame was delivered, and if so, which |
| 1261 | * callback to use. |
| 1262 | * |
| 1263 | * Return: 0 - the frame is accepted for transmission |
| 1264 | * 1 - the frame was not accepted |
| 1265 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1266 | int |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1267 | ol_txrx_mgmt_send_ext(ol_txrx_vdev_handle vdev, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1268 | qdf_nbuf_t tx_mgmt_frm, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1269 | uint8_t type, uint8_t use_6mbps, uint16_t chanfreq) |
| 1270 | { |
| 1271 | struct ol_txrx_pdev_t *pdev = vdev->pdev; |
| 1272 | struct ol_tx_desc_t *tx_desc; |
| 1273 | struct ol_txrx_msdu_info_t tx_msdu_info; |
| 1274 | |
| 1275 | tx_msdu_info.tso_info.is_tso = 0; |
| 1276 | |
| 1277 | tx_msdu_info.htt.action.use_6mbps = use_6mbps; |
| 1278 | tx_msdu_info.htt.info.ext_tid = HTT_TX_EXT_TID_MGMT; |
| 1279 | tx_msdu_info.htt.info.vdev_id = vdev->vdev_id; |
| 1280 | tx_msdu_info.htt.action.do_tx_complete = |
| 1281 | pdev->tx_mgmt.callbacks[type].ota_ack_cb ? 1 : 0; |
| 1282 | |
| 1283 | /* |
| 1284 | * FIX THIS: l2_hdr_type should only specify L2 header type |
| 1285 | * The Peregrine/Rome HTT layer provides the FW with a "pkt type" |
| 1286 | * that is a combination of L2 header type and 802.11 frame type. |
| 1287 | * If the 802.11 frame type is "mgmt", then the HTT pkt type is "mgmt". |
| 1288 | * But if the 802.11 frame type is "data", then the HTT pkt type is |
| 1289 | * the L2 header type (more or less): 802.3 vs. Native WiFi |
| 1290 | * (basic 802.11). |
| 1291 | * (Or the header type can be "raw", which is any version of the 802.11 |
| 1292 | * header, and also implies that some of the offloaded tx data |
| 1293 | * processing steps may not apply.) |
| 1294 | * For efficiency, the Peregrine/Rome HTT uses the msdu_info's |
| 1295 | * l2_hdr_type field to program the HTT pkt type. Thus, this txrx SW |
| 1296 | * needs to overload the l2_hdr_type to indicate whether the frame is |
| 1297 | * data vs. mgmt, as well as 802.3 L2 header vs. 802.11 L2 header. |
| 1298 | * To fix this, the msdu_info's l2_hdr_type should be left specifying |
| 1299 | * just the L2 header type. For mgmt frames, there should be a |
| 1300 | * separate function to patch the HTT pkt type to store a "mgmt" value |
| 1301 | * rather than the L2 header type. Then the HTT pkt type can be |
| 1302 | * programmed efficiently for data frames, and the msdu_info's |
| 1303 | * l2_hdr_type field won't be confusingly overloaded to hold the 802.11 |
| 1304 | * frame type rather than the L2 header type. |
| 1305 | */ |
| 1306 | /* |
| 1307 | * FIX THIS: remove duplication of htt_frm_type_mgmt and |
| 1308 | * htt_pkt_type_mgmt |
| 1309 | * The htt module expects a "enum htt_pkt_type" value. |
| 1310 | * The htt_dxe module expects a "enum htt_frm_type" value. |
| 1311 | * This needs to be cleaned up, so both versions of htt use a |
| 1312 | * consistent method of specifying the frame type. |
| 1313 | */ |
| 1314 | #ifdef QCA_SUPPORT_INTEGRATED_SOC |
| 1315 | /* tx mgmt frames always come with a 802.11 header */ |
| 1316 | tx_msdu_info.htt.info.l2_hdr_type = htt_pkt_type_native_wifi; |
| 1317 | tx_msdu_info.htt.info.frame_type = htt_frm_type_mgmt; |
| 1318 | #else |
| 1319 | tx_msdu_info.htt.info.l2_hdr_type = htt_pkt_type_mgmt; |
| 1320 | tx_msdu_info.htt.info.frame_type = htt_pkt_type_mgmt; |
| 1321 | #endif |
| 1322 | |
| 1323 | tx_msdu_info.peer = NULL; |
| 1324 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1325 | qdf_nbuf_map_single(pdev->osdev, tx_mgmt_frm, QDF_DMA_TO_DEVICE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | /* For LL tx_comp_req is not used so initialized to 0 */ |
| 1327 | tx_msdu_info.htt.action.tx_comp_req = 0; |
| 1328 | tx_desc = ol_tx_desc_ll(pdev, vdev, tx_mgmt_frm, &tx_msdu_info); |
| 1329 | /* FIX THIS - |
| 1330 | * The FW currently has trouble using the host's fragments table |
| 1331 | * for management frames. Until this is fixed, rather than |
| 1332 | * specifying the fragment table to the FW, specify just the |
| 1333 | * address of the initial fragment. |
| 1334 | */ |
| 1335 | #if defined(HELIUMPLUS_PADDR64) |
| 1336 | /* dump_frag_desc("ol_txrx_mgmt_send(): after ol_tx_desc_ll", |
| 1337 | tx_desc); */ |
| 1338 | #endif /* defined(HELIUMPLUS_PADDR64) */ |
| 1339 | if (tx_desc) { |
| 1340 | /* |
| 1341 | * Following the call to ol_tx_desc_ll, frag 0 is the |
| 1342 | * HTT tx HW descriptor, and the frame payload is in |
| 1343 | * frag 1. |
| 1344 | */ |
| 1345 | htt_tx_desc_frags_table_set( |
| 1346 | pdev->htt_pdev, |
| 1347 | tx_desc->htt_tx_desc, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1348 | qdf_nbuf_get_frag_paddr(tx_mgmt_frm, 1), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1349 | 0, 0); |
| 1350 | #if defined(HELIUMPLUS_PADDR64) && defined(HELIUMPLUS_DEBUG) |
| 1351 | dump_frag_desc( |
| 1352 | "after htt_tx_desc_frags_table_set", |
| 1353 | tx_desc); |
| 1354 | #endif /* defined(HELIUMPLUS_PADDR64) */ |
| 1355 | } |
| 1356 | if (!tx_desc) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1357 | qdf_nbuf_unmap_single(pdev->osdev, tx_mgmt_frm, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1358 | QDF_DMA_TO_DEVICE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1359 | return -EINVAL; /* can't accept the tx mgmt frame */ |
| 1360 | } |
| 1361 | TXRX_STATS_MSDU_INCR(pdev, tx.mgmt, tx_mgmt_frm); |
| 1362 | TXRX_ASSERT1(type < OL_TXRX_MGMT_NUM_TYPES); |
| 1363 | tx_desc->pkt_type = type + OL_TXRX_MGMT_TYPE_BASE; |
| 1364 | |
| 1365 | htt_tx_desc_set_chanfreq(tx_desc->htt_tx_desc, chanfreq); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1366 | QDF_NBUF_CB_TX_PACKET_TRACK(tx_desc->netbuf) = |
| 1367 | QDF_NBUF_TX_PKT_MGMT_TRACK; |
| 1368 | ol_tx_send_nonstd(pdev, tx_desc, tx_mgmt_frm, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1369 | htt_pkt_type_mgmt); |
| 1370 | |
| 1371 | return 0; /* accepted the tx mgmt frame */ |
| 1372 | } |
| 1373 | |
| 1374 | void ol_txrx_sync(ol_txrx_pdev_handle pdev, uint8_t sync_cnt) |
| 1375 | { |
| 1376 | htt_h2t_sync_msg(pdev->htt_pdev, sync_cnt); |
| 1377 | } |
| 1378 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 1379 | qdf_nbuf_t ol_tx_reinject(struct ol_txrx_vdev_t *vdev, |
| 1380 | qdf_nbuf_t msdu, uint16_t peer_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1381 | { |
| 1382 | struct ol_tx_desc_t *tx_desc; |
| 1383 | struct ol_txrx_msdu_info_t msdu_info; |
| 1384 | |
| 1385 | msdu_info.htt.info.l2_hdr_type = vdev->pdev->htt_pkt_type; |
| 1386 | msdu_info.htt.info.ext_tid = HTT_TX_EXT_TID_INVALID; |
| 1387 | msdu_info.peer = NULL; |
| 1388 | msdu_info.htt.action.tx_comp_req = 0; |
| 1389 | msdu_info.tso_info.is_tso = 0; |
| 1390 | |
| 1391 | ol_tx_prepare_ll(tx_desc, vdev, msdu, &msdu_info); |
| 1392 | HTT_TX_DESC_POSTPONED_SET(*((uint32_t *) (tx_desc->htt_tx_desc)), true); |
| 1393 | |
| 1394 | htt_tx_desc_set_peer_id(tx_desc->htt_tx_desc, peer_id); |
| 1395 | |
| 1396 | ol_tx_send(vdev->pdev, tx_desc, msdu); |
| 1397 | |
| 1398 | return NULL; |
| 1399 | } |
| 1400 | |
| 1401 | #if defined(FEATURE_TSO) |
| 1402 | void ol_tso_seg_list_init(struct ol_txrx_pdev_t *pdev, uint32_t num_seg) |
| 1403 | { |
| 1404 | int i; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1405 | struct qdf_tso_seg_elem_t *c_element; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1406 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1407 | c_element = qdf_mem_malloc(sizeof(struct qdf_tso_seg_elem_t)); |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1408 | pdev->tso_seg_pool.freelist = c_element; |
| 1409 | for (i = 0; i < (num_seg - 1); i++) { |
| 1410 | c_element->next = |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1411 | qdf_mem_malloc(sizeof(struct qdf_tso_seg_elem_t)); |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1412 | c_element = c_element->next; |
| 1413 | c_element->next = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1414 | } |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1415 | pdev->tso_seg_pool.pool_size = num_seg; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1416 | qdf_spinlock_create(&pdev->tso_seg_pool.tso_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1417 | } |
| 1418 | |
| 1419 | void ol_tso_seg_list_deinit(struct ol_txrx_pdev_t *pdev) |
| 1420 | { |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1421 | int i; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1422 | struct qdf_tso_seg_elem_t *c_element; |
| 1423 | struct qdf_tso_seg_elem_t *temp; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1424 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1425 | qdf_spin_lock_bh(&pdev->tso_seg_pool.tso_mutex); |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1426 | c_element = pdev->tso_seg_pool.freelist; |
| 1427 | for (i = 0; i < pdev->tso_seg_pool.pool_size; i++) { |
| 1428 | temp = c_element->next; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1429 | qdf_mem_free(c_element); |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1430 | c_element = temp; |
| 1431 | if (!c_element) |
| 1432 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1433 | } |
| 1434 | |
| 1435 | pdev->tso_seg_pool.freelist = NULL; |
| 1436 | pdev->tso_seg_pool.num_free = 0; |
| 1437 | pdev->tso_seg_pool.pool_size = 0; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1438 | qdf_spin_unlock_bh(&pdev->tso_seg_pool.tso_mutex); |
| 1439 | qdf_spinlock_destroy(&pdev->tso_seg_pool.tso_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | } |
| 1441 | #endif /* FEATURE_TSO */ |