blob: e8b5e9b7d2c0537f3926df2f511a4b0714f7a84a [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Komal Seelam7fde14c2016-02-02 13:05:57 +05302 * Copyright (c) 2011-2016 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
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 Shahcbc6d722016-03-01 16:24:53 +053029#include <qdf_nbuf.h> /* qdf_nbuf_t, etc. */
Anurag Chouhan8e0ccd32016-02-19 15:30:20 +053030#include <qdf_atomic.h> /* qdf_atomic_read, etc. */
Anurag Chouhanc5548422016-02-24 18:33:27 +053031#include <qdf_util.h> /* qdf_unlikely */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080032
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 Dhavali7090c5f2015-11-02 17:55:19 -080036
37/* internal header files relevant for all systems */
38#include <ol_txrx_internal.h> /* TXRX_ASSERT1 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039#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 Prakash3454fd62016-04-01 08:52:06 -070055#include <cdp_txrx_peer_ops.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056
Nirav Shahcbc6d722016-03-01 16:24:53 +053057int ce_send_fast(struct CE_handle *copyeng, qdf_nbuf_t *msdus,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080058 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 Chouhanc5548422016-02-24 18:33:27 +053074 if (qdf_unlikely(!tx_desc)) { \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075 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 Atre83d373d2015-07-28 16:45:59 -070081#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 */
91static inline uint8_t ol_tx_prepare_tso(ol_txrx_vdev_handle vdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +053092 qdf_nbuf_t msdu, struct ol_txrx_msdu_info_t *msdu_info)
Dhanashri Atre83d373d2015-07-28 16:45:59 -070093{
94 msdu_info->tso_info.curr_seg = NULL;
Nirav Shahcbc6d722016-03-01 16:24:53 +053095 if (qdf_nbuf_is_tso(msdu)) {
96 int num_seg = qdf_nbuf_get_tso_num_seg(msdu);
Dhanashri Atre83d373d2015-07-28 16:45:59 -070097 msdu_info->tso_info.tso_seg_list = NULL;
98 msdu_info->tso_info.num_segs = num_seg;
99 while (num_seg) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530100 struct qdf_tso_seg_elem_t *tso_seg =
Dhanashri Atre83d373d2015-07-28 16:45:59 -0700101 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 Chouhanf04e84f2016-03-03 10:12:12 +0530109 struct qdf_tso_seg_elem_t *next_seg;
110 struct qdf_tso_seg_elem_t *free_seg =
Dhanashri Atre83d373d2015-07-28 16:45:59 -0700111 msdu_info->tso_info.tso_seg_list;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530112 qdf_print("TSO seg alloc failed!\n");
Dhanashri Atre83d373d2015-07-28 16:45:59 -0700113 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 Shahcbc6d722016-03-01 16:24:53 +0530122 qdf_nbuf_get_tso_info(vdev->pdev->osdev,
Dhanashri Atre83d373d2015-07-28 16:45:59 -0700123 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 Dhavali7090c5f2015-11-02 17:55:19 -0800134
135/**
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800136 * ol_tx_data() - send data frame
137 * @vdev: virtual device handle
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138 * @skb: skb
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 *
140 * Return: skb/NULL for success
141 */
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800142qdf_nbuf_t ol_tx_data(ol_txrx_vdev_handle vdev, qdf_nbuf_t skb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800143{
Anurag Chouhandf2b2682016-02-29 14:15:27 +0530144 void *qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE);
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800145 struct ol_txrx_pdev_t *pdev = vdev->pdev;
Nirav Shahcbc6d722016-03-01 16:24:53 +0530146 qdf_nbuf_t ret;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530147 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148
Anurag Chouhanc5548422016-02-24 18:33:27 +0530149 if (qdf_unlikely(!pdev)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530150 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 "%s:pdev is null", __func__);
152 return skb;
153 }
Anurag Chouhandf2b2682016-02-29 14:15:27 +0530154 if (qdf_unlikely(!qdf_ctx)) {
Orhan K AKYILDIZc4094612015-11-11 18:01:15 -0800155 TXRX_PRINT(TXRX_PRINT_LEVEL_ERR,
Anurag Chouhandf2b2682016-02-29 14:15:27 +0530156 "%s:qdf_ctx is null", __func__);
Orhan K AKYILDIZc4094612015-11-11 18:01:15 -0800157 return skb;
158 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159
Nirav Shahcbc6d722016-03-01 16:24:53 +0530160 status = qdf_nbuf_map_single(qdf_ctx, skb, QDF_DMA_TO_DEVICE);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530161 if (qdf_unlikely(status != QDF_STATUS_SUCCESS)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530162 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163 "%s: nbuf map failed", __func__);
164 return skb;
165 }
166
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 if ((ol_cfg_is_ip_tcp_udp_checksum_offload_enabled(pdev->ctrl_pdev))
Nirav Shahcbc6d722016-03-01 16:24:53 +0530168 && (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 Dhavali7090c5f2015-11-02 17:55:19 -0800171
172 /* Terminate the (single-element) list of tx frames */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530173 qdf_nbuf_set_next(skb, NULL);
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800174 ret = OL_TX_LL(vdev, skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 if (ret) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530176 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 "%s: Failed to tx", __func__);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530178 qdf_nbuf_unmap_single(qdf_ctx, ret, QDF_DMA_TO_DEVICE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 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 Shahcbc6d722016-03-01 16:24:53 +0530193qdf_nbuf_t ol_tx_send_ipa_data_frame(void *vdev,
194 qdf_nbuf_t skb)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195{
Anurag Chouhan6d760662016-02-20 16:05:43 +0530196 ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530197 qdf_nbuf_t ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198
Anurag Chouhanc5548422016-02-24 18:33:27 +0530199 if (qdf_unlikely(!pdev)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200 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 Shahcbc6d722016-03-01 16:24:53 +0530206 && (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 Dhavali7090c5f2015-11-02 17:55:19 -0800209
210 /* Terminate the (single-element) list of tx frames */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530211 qdf_nbuf_set_next(skb, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 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 Shahcbc6d722016-03-01 16:24:53 +0530225qdf_nbuf_t ol_tx_ll(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226{
Nirav Shahcbc6d722016-03-01 16:24:53 +0530227 qdf_nbuf_t msdu = msdu_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 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 Shahcbc6d722016-03-01 16:24:53 +0530239 qdf_nbuf_t next;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 struct ol_tx_desc_t *tx_desc;
241 int segments = 1;
242
Nirav Shahcbc6d722016-03-01 16:24:53 +0530243 msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 msdu_info.peer = NULL;
245
Anurag Chouhanc5548422016-02-24 18:33:27 +0530246 if (qdf_unlikely(ol_tx_prepare_tso(vdev, msdu, &msdu_info))) {
Anurag Chouhan6d760662016-02-20 16:05:43 +0530247 qdf_print("ol_tx_prepare_tso failed\n");
Dhanashri Atre83d373d2015-07-28 16:45:59 -0700248 TXRX_STATS_MSDU_LIST_INCR(vdev->pdev,
249 tx.dropped.host_reject, msdu);
250 return msdu;
251 }
252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 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 Shahcbc6d722016-03-01 16:24:53 +0530260 next = qdf_nbuf_next(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261 /* init the current segment to the 1st segment in the list */
262 while (segments) {
263
264 if (msdu_info.tso_info.curr_seg)
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530265 QDF_NBUF_CB_PADDR(msdu) =
Houston Hoffman43d47fa2016-02-24 16:34:30 -0800266 msdu_info.tso_info.curr_seg->
267 seg.tso_frags[0].paddr_low_32;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268
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 Shahcbc6d722016-03-01 16:24:53 +0530278 qdf_nbuf_inc_users(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279
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 Shahcbc6d722016-03-01 16:24:53 +0530295 qdf_nbuf_reset_num_frags(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296
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 Shahcbc6d722016-03-01 16:24:53 +0530313qdf_nbuf_t ol_tx_ll(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314{
Nirav Shahcbc6d722016-03-01 16:24:53 +0530315 qdf_nbuf_t msdu = msdu_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316 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 Shahcbc6d722016-03-01 16:24:53 +0530328 qdf_nbuf_t next;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 struct ol_tx_desc_t *tx_desc;
330
Nirav Shahcbc6d722016-03-01 16:24:53 +0530331 msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 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 Shahcbc6d722016-03-01 16:24:53 +0530345 next = qdf_nbuf_next(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 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 */
369static inline struct ol_tx_desc_t *
370ol_tx_prepare_ll_fast(struct ol_txrx_pdev_t *pdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530371 ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 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 Chouhanc5548422016-02-24 18:33:27 +0530381 if (qdf_unlikely(!tx_desc))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 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 Shahcbc6d722016-03-01 16:24:53 +0530413 num_frags = qdf_nbuf_get_num_frags(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414 /* num_frags are expected to be 2 max */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530415 num_frags = (num_frags > QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS)
416 ? QDF_NBUF_CB_TX_MAX_EXTRA_FRAGS
Houston Hoffman43d47fa2016-02-24 16:34:30 -0800417 : num_frags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418#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 Chouhan6d760662016-02-20 16:05:43 +0530437 qdf_size_t frag_len;
Anurag Chouhandf2b2682016-02-29 14:15:27 +0530438 qdf_dma_addr_t frag_paddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439
Nirav Shahcbc6d722016-03-01 16:24:53 +0530440 frag_len = qdf_nbuf_get_frag_len(msdu, i);
441 frag_paddr = qdf_nbuf_get_frag_paddr(msdu, i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442#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 Chouhan6d760662016-02-20 16:05:43 +0530446 qdf_print("%s:%d: htt_fdesc=%p frag=%d frag_paddr=0x%0llx len=%zu",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800447 __func__, __LINE__, tx_desc->htt_frag_desc,
Houston Hoffman43d47fa2016-02-24 16:34:30 -0800448 i-1, frag_paddr, frag_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 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 Shahcbc6d722016-03-01 16:24:53 +0530468 if (qdf_unlikely(qdf_nbuf_len(msdu) < pkt_download_len))
469 pkt_download_len = qdf_nbuf_len(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470
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 Shahcbc6d722016-03-01 16:24:53 +0530490qdf_nbuf_t
491ol_tx_ll_fast(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492{
Nirav Shahcbc6d722016-03-01 16:24:53 +0530493 qdf_nbuf_t msdu = msdu_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494 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 Shahcbc6d722016-03-01 16:24:53 +0530509 qdf_nbuf_t next;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 struct ol_tx_desc_t *tx_desc;
511 int segments = 1;
512
Nirav Shahcbc6d722016-03-01 16:24:53 +0530513 msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514 msdu_info.peer = NULL;
515
Anurag Chouhanc5548422016-02-24 18:33:27 +0530516 if (qdf_unlikely(ol_tx_prepare_tso(vdev, msdu, &msdu_info))) {
Anurag Chouhan6d760662016-02-20 16:05:43 +0530517 qdf_print("ol_tx_prepare_tso failed\n");
Dhanashri Atre83d373d2015-07-28 16:45:59 -0700518 TXRX_STATS_MSDU_LIST_INCR(vdev->pdev,
519 tx.dropped.host_reject, msdu);
520 return msdu;
521 }
522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523 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 Shahcbc6d722016-03-01 16:24:53 +0530530 next = qdf_nbuf_next(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531 /* init the current segment to the 1st segment in the list */
532 while (segments) {
533
534 if (msdu_info.tso_info.curr_seg)
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530535 QDF_NBUF_CB_PADDR(msdu) = msdu_info.tso_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 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 Shahcbc6d722016-03-01 16:24:53 +0530547 qdf_nbuf_inc_users(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800548
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 Shahcbc6d722016-03-01 16:24:53 +0530552 qdf_nbuf_get_tx_cksum(msdu);
553 switch (qdf_nbuf_get_exemption_type(msdu)) {
Anurag Chouhanc73697b2016-02-21 15:05:43 +0530554 case QDF_NBUF_EXEMPT_NO_EXEMPTION:
555 case QDF_NBUF_EXEMPT_ON_KEY_MAPPING_KEY_UNAVAILABLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 /* We want to encrypt this frame */
557 msdu_info.htt.action.do_encrypt = 1;
558 break;
Anurag Chouhanc73697b2016-02-21 15:05:43 +0530559 case QDF_NBUF_EXEMPT_ALWAYS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560 /* 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 Chouhanc5548422016-02-24 18:33:27 +0530565 qdf_assert(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566 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 Chouhanc5548422016-02-24 18:33:27 +0530573 if (qdf_likely(tx_desc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 /*
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 Shahcbc6d722016-03-01 16:24:53 +0530596 qdf_nbuf_reset_num_frags(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 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 Shahcbc6d722016-03-01 16:24:53 +0530617qdf_nbuf_t
618ol_tx_ll_fast(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619{
Nirav Shahcbc6d722016-03-01 16:24:53 +0530620 qdf_nbuf_t msdu = msdu_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621 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 Shahcbc6d722016-03-01 16:24:53 +0530637 qdf_nbuf_t next;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638 struct ol_tx_desc_t *tx_desc;
639
Nirav Shahcbc6d722016-03-01 16:24:53 +0530640 msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641 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 Shahcbc6d722016-03-01 16:24:53 +0530646 qdf_nbuf_get_tx_cksum(msdu);
647 switch (qdf_nbuf_get_exemption_type(msdu)) {
Anurag Chouhanc73697b2016-02-21 15:05:43 +0530648 case QDF_NBUF_EXEMPT_NO_EXEMPTION:
649 case QDF_NBUF_EXEMPT_ON_KEY_MAPPING_KEY_UNAVAILABLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 /* We want to encrypt this frame */
651 msdu_info.htt.action.do_encrypt = 1;
652 break;
Anurag Chouhanc73697b2016-02-21 15:05:43 +0530653 case QDF_NBUF_EXEMPT_ALWAYS:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 /* 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 Chouhanc5548422016-02-24 18:33:27 +0530659 qdf_assert(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 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 Chouhanc5548422016-02-24 18:33:27 +0530667 if (qdf_likely(tx_desc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668 /*
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 Shahcbc6d722016-03-01 16:24:53 +0530678 next = qdf_nbuf_next(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 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 Prakash7e16b0a2016-03-08 15:24:48 -0800705qdf_nbuf_t
Nirav Shahcbc6d722016-03-01 16:24:53 +0530706ol_tx_ll_wrapper(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707{
Komal Seelam3d202862016-02-24 18:43:24 +0530708 struct hif_opaque_softc *hif_device =
Anurag Chouhan6d760662016-02-20 16:05:43 +0530709 (struct hif_opaque_softc *)cds_get_context(QDF_MODULE_ID_HIF);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710
Anurag Chouhanc5548422016-02-24 18:33:27 +0530711 if (qdf_likely(hif_device && hif_is_fastpath_mode_enabled(hif_device)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 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 Prakash7e16b0a2016-03-08 15:24:48 -0800719qdf_nbuf_t
Nirav Shahcbc6d722016-03-01 16:24:53 +0530720ol_tx_ll_wrapper(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721{
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
730static void ol_tx_vdev_ll_pause_queue_send_base(struct ol_txrx_vdev_t *vdev)
731{
732 int max_to_accept;
733
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530734 qdf_spin_lock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 if (vdev->ll_pause.paused_reason) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530736 qdf_spin_unlock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737 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 Shahcbc6d722016-03-01 16:24:53 +0530755 qdf_nbuf_t tx_msdu;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 max_to_accept--;
757 vdev->ll_pause.txq.depth--;
758 tx_msdu = vdev->ll_pause.txq.head;
759 if (tx_msdu) {
Nirav Shahcbc6d722016-03-01 16:24:53 +0530760 vdev->ll_pause.txq.head = qdf_nbuf_next(tx_msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761 if (NULL == vdev->ll_pause.txq.head)
762 vdev->ll_pause.txq.tail = NULL;
Nirav Shahcbc6d722016-03-01 16:24:53 +0530763 qdf_nbuf_set_next(tx_msdu, NULL);
764 QDF_NBUF_UPDATE_TX_PKT_COUNT(tx_msdu,
765 QDF_NBUF_TX_PKT_TXRX_DEQUEUE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 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 Shahcbc6d722016-03-01 16:24:53 +0530776 qdf_nbuf_unmap(vdev->pdev->osdev, tx_msdu,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530777 QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530778 qdf_nbuf_tx_free(tx_msdu, QDF_NBUF_PKT_ERROR);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 }
780 }
781 }
782 if (vdev->ll_pause.txq.depth) {
Anurag Chouhan754fbd82016-02-19 17:00:08 +0530783 qdf_timer_stop(&vdev->ll_pause.timer);
784 qdf_timer_start(&vdev->ll_pause.timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 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 Chouhana37b5b72016-02-21 14:53:42 +0530791 qdf_spin_unlock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792}
793
Nirav Shahcbc6d722016-03-01 16:24:53 +0530794static qdf_nbuf_t
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795ol_tx_vdev_pause_queue_append(struct ol_txrx_vdev_t *vdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530796 qdf_nbuf_t msdu_list, uint8_t start_timer)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797{
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530798 qdf_spin_lock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 while (msdu_list &&
800 vdev->ll_pause.txq.depth < vdev->ll_pause.max_q_depth) {
Nirav Shahcbc6d722016-03-01 16:24:53 +0530801 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 Chouhanb2dc16f2016-02-25 11:47:37 +0530804 DPTRACE(qdf_dp_trace(msdu_list,
805 QDF_DP_TRACE_TXRX_QUEUE_PACKET_PTR_RECORD,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530806 (uint8_t *)(qdf_nbuf_data(msdu_list)),
807 sizeof(qdf_nbuf_data(msdu_list))));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808
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 Shahcbc6d722016-03-01 16:24:53 +0530814 qdf_nbuf_set_next(vdev->ll_pause.txq.tail, msdu_list);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 }
816 vdev->ll_pause.txq.tail = msdu_list;
817
818 msdu_list = next;
819 }
820 if (vdev->ll_pause.txq.tail)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530821 qdf_nbuf_set_next(vdev->ll_pause.txq.tail, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822
823 if (start_timer) {
Anurag Chouhan754fbd82016-02-19 17:00:08 +0530824 qdf_timer_stop(&vdev->ll_pause.timer);
825 qdf_timer_start(&vdev->ll_pause.timer,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 OL_TX_VDEV_PAUSE_QUEUE_SEND_PERIOD_MS);
827 vdev->ll_pause.is_q_timer_on = true;
828 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530829 qdf_spin_unlock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830
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 Shahcbc6d722016-03-01 16:24:53 +0530838qdf_nbuf_t ol_tx_ll_queue(ol_txrx_vdev_handle vdev, qdf_nbuf_t msdu_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839{
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 Chouhanc5548422016-02-24 18:33:27 +0530848 if (qdf_unlikely((paused_reason &
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED) ==
850 paused_reason)) {
851 eth_type = (((struct ethernet_hdr_t *)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530852 qdf_nbuf_data(msdu_list))->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 ethertype[0] << 8) |
854 (((struct ethernet_hdr_t *)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530855 qdf_nbuf_data(msdu_list))->ethertype[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 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 */
893void 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 Shahcbc6d722016-03-01 16:24:53 +0530896 qdf_nbuf_t tx_msdu;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 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 Chouhana37b5b72016-02-21 14:53:42 +0530920 qdf_spin_lock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 if (vdev->ll_pause.txq.depth) {
922 if (vdev->ll_pause.paused_reason) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530923 qdf_spin_unlock_bh(&vdev->ll_pause.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924 mutex);
925 continue;
926 }
927
928 tx_msdu = vdev->ll_pause.txq.head;
929 if (NULL == tx_msdu) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530930 qdf_spin_unlock_bh(&vdev->ll_pause.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 mutex);
932 continue;
933 }
934
935 max_to_send--;
936 vdev->ll_pause.txq.depth--;
937
938 vdev->ll_pause.txq.head =
Nirav Shahcbc6d722016-03-01 16:24:53 +0530939 qdf_nbuf_next(tx_msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940
941 if (NULL == vdev->ll_pause.txq.head)
942 vdev->ll_pause.txq.tail = NULL;
943
Nirav Shahcbc6d722016-03-01 16:24:53 +0530944 qdf_nbuf_set_next(tx_msdu, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945 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 Shahcbc6d722016-03-01 16:24:53 +0530956 qdf_nbuf_unmap(pdev->osdev, tx_msdu,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530957 QDF_DMA_TO_DEVICE);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530958 qdf_nbuf_tx_free(tx_msdu,
959 QDF_NBUF_PKT_ERROR);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 }
961 }
962 /*check if there are more msdus to transmit */
963 if (vdev->ll_pause.txq.depth)
964 more = 1;
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530965 qdf_spin_unlock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 }
967 } while (more && max_to_send);
968
969 vdev = NULL;
970 TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530971 qdf_spin_lock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 if (vdev->ll_pause.txq.depth) {
Anurag Chouhan754fbd82016-02-19 17:00:08 +0530973 qdf_timer_stop(&pdev->tx_throttle.tx_timer);
974 qdf_timer_start(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 &pdev->tx_throttle.tx_timer,
976 OL_TX_VDEV_PAUSE_QUEUE_SEND_PERIOD_MS);
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530977 qdf_spin_unlock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 return;
979 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530980 qdf_spin_unlock_bh(&vdev->ll_pause.mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 }
982}
983
984void 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
996static inline int ol_txrx_tx_is_raw(enum ol_tx_spec tx_spec)
997{
998 return
999 tx_spec &
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001000 (OL_TX_SPEC_RAW | OL_TX_SPEC_NO_AGGR | OL_TX_SPEC_NO_ENCRYPT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001}
1002
1003static 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 Atreb08959a2016-03-01 17:28:03 -08001007 if (tx_spec & OL_TX_SPEC_NO_AGGR)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 sub_type |= 0x1 << HTT_TX_MSDU_DESC_RAW_SUBTYPE_NO_AGGR_S;
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001009 if (tx_spec & OL_TX_SPEC_NO_ENCRYPT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 sub_type |= 0x1 << HTT_TX_MSDU_DESC_RAW_SUBTYPE_NO_ENCRYPT_S;
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001011 if (tx_spec & OL_TX_SPEC_NWIFI_NO_ENCRYPT)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 sub_type |= 0x1 << HTT_TX_MSDU_DESC_RAW_SUBTYPE_NO_ENCRYPT_S;
1013 return sub_type;
1014}
1015
Nirav Shahcbc6d722016-03-01 16:24:53 +05301016qdf_nbuf_t
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017ol_tx_non_std_ll(ol_txrx_vdev_handle vdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +05301018 enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019{
Nirav Shahcbc6d722016-03-01 16:24:53 +05301020 qdf_nbuf_t msdu = msdu_list;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 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 Shahcbc6d722016-03-01 16:24:53 +05301034 qdf_nbuf_t next;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 struct ol_tx_desc_t *tx_desc;
1036
Nirav Shahcbc6d722016-03-01 16:24:53 +05301037 msdu_info.htt.info.ext_tid = qdf_nbuf_get_tid(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 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 Shahcbc6d722016-03-01 16:24:53 +05301048 next = qdf_nbuf_next(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001050 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 Dhavali7090c5f2015-11-02 17:55:19 -08001056 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 Chouhan8e0ccd32016-02-19 15:30:20 +05301084 qdf_atomic_inc(&pdev->tx_queue.rsrc_cnt); \
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 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 Shahcbc6d722016-03-01 16:24:53 +05301104 * @msdu: Pointer to OS packet (qdf_nbuf_t)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105 */
1106#define OCB_HEADER_VERSION 1
Nirav Shahcbc6d722016-03-01 16:24:53 +05301107bool parse_ocb_tx_header(qdf_nbuf_t msdu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 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 Shahcbc6d722016-03-01 16:24:53 +05301114 eth_hdr_p = (struct ether_header *) qdf_nbuf_data(msdu);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301115 if (eth_hdr_p->ether_type != QDF_SWAP_U16(ETHERTYPE_OCB_TX))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001116 /* TX control header is not present. Nothing to do.. */
1117 return true;
1118
1119 /* Remove the ethernet header */
Nirav Shahcbc6d722016-03-01 16:24:53 +05301120 qdf_nbuf_pull_head(msdu, sizeof(struct ether_header));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121
1122 /* Parse the TX control header */
Nirav Shahcbc6d722016-03-01 16:24:53 +05301123 tx_ctrl_hdr = (struct ocb_tx_ctrl_hdr_t *) qdf_nbuf_data(msdu);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124
1125 if (tx_ctrl_hdr->version == OCB_HEADER_VERSION) {
1126 if (tx_ctrl)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301127 qdf_mem_copy(tx_ctrl, tx_ctrl_hdr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 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 Shahcbc6d722016-03-01 16:24:53 +05301135 qdf_nbuf_pull_head(msdu, tx_ctrl_hdr->length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 return true;
1137}
1138
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001139/**
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 Shahcbc6d722016-03-01 16:24:53 +05301161qdf_nbuf_t
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162ol_tx_non_std(ol_txrx_vdev_handle vdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +05301163 enum ol_tx_spec tx_spec, qdf_nbuf_t msdu_list)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164{
1165 return ol_tx_non_std_ll(vdev, tx_spec, msdu_list);
1166}
1167
1168void
1169ol_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 Atre12a08392016-02-17 13:10:34 -08001177/**
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 Dhavali7090c5f2015-11-02 17:55:19 -08001197void
1198ol_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)
1210void 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 Chouhan6d760662016-02-20 16:05:43 +05301215 qdf_print("OL TX Descriptor 0x%p msdu_id %d\n",
Leo Chang376398b2015-10-23 14:19:02 -07001216 tx_desc, tx_desc->id);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301217 qdf_print("HTT TX Descriptor vaddr: 0x%p paddr: 0x%llx",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 tx_desc->htt_tx_desc, tx_desc->htt_tx_desc_paddr);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301219 qdf_print("%s %d: Fragment Descriptor 0x%p (paddr=0x%llx)",
Houston Hoffman43d47fa2016-02-24 16:34:30 -08001220 __func__, __LINE__, tx_desc->htt_frag_desc, tx_desc->htt_frag_desc_paddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221
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 Atre12a08392016-02-17 13:10:34 -08001248/**
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 Dhavali7090c5f2015-11-02 17:55:19 -08001266int
Dhanashri Atre12a08392016-02-17 13:10:34 -08001267ol_txrx_mgmt_send_ext(ol_txrx_vdev_handle vdev,
Nirav Shahcbc6d722016-03-01 16:24:53 +05301268 qdf_nbuf_t tx_mgmt_frm,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 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 Shahcbc6d722016-03-01 16:24:53 +05301325 qdf_nbuf_map_single(pdev->osdev, tx_mgmt_frm, QDF_DMA_TO_DEVICE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326 /* 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 Shahcbc6d722016-03-01 16:24:53 +05301348 qdf_nbuf_get_frag_paddr(tx_mgmt_frm, 1),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349 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 Shahcbc6d722016-03-01 16:24:53 +05301357 qdf_nbuf_unmap_single(pdev->osdev, tx_mgmt_frm,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301358 QDF_DMA_TO_DEVICE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359 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 Shahcbc6d722016-03-01 16:24:53 +05301366 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 Dhavali7090c5f2015-11-02 17:55:19 -08001369 htt_pkt_type_mgmt);
1370
1371 return 0; /* accepted the tx mgmt frame */
1372}
1373
1374void 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 Shahcbc6d722016-03-01 16:24:53 +05301379qdf_nbuf_t ol_tx_reinject(struct ol_txrx_vdev_t *vdev,
1380 qdf_nbuf_t msdu, uint16_t peer_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381{
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)
1402void ol_tso_seg_list_init(struct ol_txrx_pdev_t *pdev, uint32_t num_seg)
1403{
1404 int i;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301405 struct qdf_tso_seg_elem_t *c_element;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301407 c_element = qdf_mem_malloc(sizeof(struct qdf_tso_seg_elem_t));
Leo Chang376398b2015-10-23 14:19:02 -07001408 pdev->tso_seg_pool.freelist = c_element;
1409 for (i = 0; i < (num_seg - 1); i++) {
1410 c_element->next =
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301411 qdf_mem_malloc(sizeof(struct qdf_tso_seg_elem_t));
Leo Chang376398b2015-10-23 14:19:02 -07001412 c_element = c_element->next;
1413 c_element->next = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 }
Leo Chang376398b2015-10-23 14:19:02 -07001415 pdev->tso_seg_pool.pool_size = num_seg;
Anurag Chouhana37b5b72016-02-21 14:53:42 +05301416 qdf_spinlock_create(&pdev->tso_seg_pool.tso_mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417}
1418
1419void ol_tso_seg_list_deinit(struct ol_txrx_pdev_t *pdev)
1420{
Leo Chang376398b2015-10-23 14:19:02 -07001421 int i;
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301422 struct qdf_tso_seg_elem_t *c_element;
1423 struct qdf_tso_seg_elem_t *temp;
Leo Chang376398b2015-10-23 14:19:02 -07001424
Anurag Chouhana37b5b72016-02-21 14:53:42 +05301425 qdf_spin_lock_bh(&pdev->tso_seg_pool.tso_mutex);
Leo Chang376398b2015-10-23 14:19:02 -07001426 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 Chouhan600c3a02016-03-01 10:33:54 +05301429 qdf_mem_free(c_element);
Leo Chang376398b2015-10-23 14:19:02 -07001430 c_element = temp;
1431 if (!c_element)
1432 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 }
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 Chouhana37b5b72016-02-21 14:53:42 +05301438 qdf_spin_unlock_bh(&pdev->tso_seg_pool.tso_mutex);
1439 qdf_spinlock_destroy(&pdev->tso_seg_pool.tso_mutex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440}
1441#endif /* FEATURE_TSO */