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