blob: 4e59ea397d3023fef2a2cd3ef2140beb7f4f8469 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2011-2015 The Linux Foundation. All rights reserved.
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#ifndef _OL_CFG__H_
29#define _OL_CFG__H_
30
31#include <cdf_types.h> /* uint32_t */
32#include <ol_ctrl_api.h> /* ol_pdev_handle */
33#include <cds_ieee80211_common.h> /* ieee80211_qosframe_htc_addr4 */
34#include <enet.h> /* LLC_SNAP_HDR_LEN */
35#include "wlan_tgt_def_config.h"
36
37/**
38 * @brief format of data frames delivered to/from the WLAN driver by/to the OS
39 */
40enum wlan_frm_fmt {
41 wlan_frm_fmt_unknown,
42 wlan_frm_fmt_raw,
43 wlan_frm_fmt_native_wifi,
44 wlan_frm_fmt_802_3,
45};
46
47struct wlan_ipa_uc_rsc_t {
48 u8 uc_offload_enabled;
49 u32 tx_max_buf_cnt;
50 u32 tx_buf_size;
51 u32 rx_ind_ring_size;
52 u32 tx_partition_base;
53};
54
55/* Config parameters for txrx_pdev */
56struct txrx_pdev_cfg_t {
57 u8 is_high_latency;
58 u8 defrag_timeout_check;
59 u8 rx_pn_check;
60 u8 pn_rx_fwd_check;
61 u8 host_addba;
62 u8 tx_free_at_download;
63 u8 rx_fwd_inter_bss;
64 u32 max_thruput_mbps;
65 u32 target_tx_credit;
66 u32 vow_config;
67 u32 tx_download_size;
68 u32 max_peer_id;
69 u32 max_vdev;
70 u32 max_nbuf_frags;
71 u32 throttle_period_ms;
72 enum wlan_frm_fmt frame_type;
73 u8 rx_fwd_disabled;
74 u8 is_packet_log_enabled;
75 u8 is_full_reorder_offload;
76 struct wlan_ipa_uc_rsc_t ipa_uc_rsc;
77 bool ip_tcp_udp_checksum_offload;
78 bool enable_rxthread;
79 bool ce_classify_enabled;
80#ifdef QCA_LL_TX_FLOW_CONTROL_V2
81 uint32_t tx_flow_stop_queue_th;
82 uint32_t tx_flow_start_queue_offset;
83#endif
84};
85
86/**
87 * @brief Specify whether the system is high-latency or low-latency.
88 * @details
89 * Indicate whether the system is operating in high-latency (message
90 * based, e.g. USB) mode or low-latency (memory-mapped, e.g. PCIe) mode.
91 * Some chips support just one type of host / target interface.
92 * Other chips support both LL and HL interfaces (e.g. PCIe and USB),
93 * so the selection will be made based on which bus HW is present, or
94 * which is preferred if both are present.
95 *
96 * @param pdev - handle to the physical device
97 * @return 1 -> high-latency -OR- 0 -> low-latency
98 */
99int ol_cfg_is_high_latency(ol_pdev_handle pdev);
100
101/**
102 * @brief Specify the range of peer IDs.
103 * @details
104 * Specify the maximum peer ID. This is the maximum number of peers,
105 * minus one.
106 * This is used by the host to determine the size of arrays indexed by
107 * peer ID.
108 *
109 * @param pdev - handle to the physical device
110 * @return maximum peer ID
111 */
112int ol_cfg_max_peer_id(ol_pdev_handle pdev);
113
114/**
115 * @brief Specify the max number of virtual devices within a physical device.
116 * @details
117 * Specify how many virtual devices may exist within a physical device.
118 *
119 * @param pdev - handle to the physical device
120 * @return maximum number of virtual devices
121 */
122int ol_cfg_max_vdevs(ol_pdev_handle pdev);
123
124/**
125 * @brief Check whether host-side rx PN check is enabled or disabled.
126 * @details
127 * Choose whether to allocate rx PN state information and perform
128 * rx PN checks (if applicable, based on security type) on the host.
129 * If the rx PN check is specified to be done on the host, the host SW
130 * will determine which peers are using a security type (e.g. CCMP) that
131 * requires a PN check.
132 *
133 * @param pdev - handle to the physical device
134 * @return 1 -> host performs rx PN check -OR- 0 -> no host-side rx PN check
135 */
136int ol_cfg_rx_pn_check(ol_pdev_handle pdev);
137
138/**
139 * @brief Check whether host-side rx forwarding is enabled or disabled.
140 * @details
141 * Choose whether to check whether to forward rx frames to tx on the host.
142 * For LL systems, this rx -> tx host-side forwarding check is typically
143 * enabled.
144 * For HL systems, the rx -> tx forwarding check is typically done on the
145 * target. However, even in HL systems, the host-side rx -> tx forwarding
146 * will typically be enabled, as a second-tier safety net in case the
147 * target doesn't have enough memory to store all rx -> tx forwarded frames.
148 *
149 * @param pdev - handle to the physical device
150 * @return 1 -> host does rx->tx forward -OR- 0 -> no host-side rx->tx forward
151 */
152int ol_cfg_rx_fwd_check(ol_pdev_handle pdev);
153
154/**
155 * @brief set rx fwd disable/enable.
156 * @details
157 * Choose whether to forward rx frames to tx (where applicable) within the
158 * WLAN driver, or to leave all forwarding up to the operating system.
159 * currently only intra-bss fwd is supported.
160 *
161 * @param pdev - handle to the physical device
162 * @param disable_rx_fwd 1 -> no rx->tx forward -> rx->tx forward
163 */
164void ol_set_cfg_rx_fwd_disabled(ol_pdev_handle pdev, uint8_t disalbe_rx_fwd);
165
166/**
167 * @brief Check whether rx forwarding is enabled or disabled.
168 * @details
169 * Choose whether to forward rx frames to tx (where applicable) within the
170 * WLAN driver, or to leave all forwarding up to the operating system.
171 *
172 * @param pdev - handle to the physical device
173 * @return 1 -> no rx->tx forward -OR- 0 -> rx->tx forward (in host or target)
174 */
175int ol_cfg_rx_fwd_disabled(ol_pdev_handle pdev);
176
177/**
178 * @brief Check whether to perform inter-BSS or intra-BSS rx->tx forwarding.
179 * @details
180 * Check whether data received by an AP on one virtual device destined
181 * to a STA associated with a different virtual device within the same
182 * physical device should be forwarded within the driver, or whether
183 * forwarding should only be done within a virtual device.
184 *
185 * @param pdev - handle to the physical device
186 * @return
187 * 1 -> forward both within and between vdevs
188 * -OR-
189 * 0 -> forward only within a vdev
190 */
191int ol_cfg_rx_fwd_inter_bss(ol_pdev_handle pdev);
192
193/**
194 * @brief Specify data frame format used by the OS.
195 * @details
196 * Specify what type of frame (802.3 or native WiFi) the host data SW
197 * should expect from and provide to the OS shim.
198 *
199 * @param pdev - handle to the physical device
200 * @return enumerated data frame format
201 */
202enum wlan_frm_fmt ol_cfg_frame_type(ol_pdev_handle pdev);
203
204/**
205 * @brief Specify the peak throughput.
206 * @details
207 * Specify the peak throughput that a system is expected to support.
208 * The data SW uses this configuration to help choose the size for its
209 * tx descriptor pool and rx buffer ring.
210 * The data SW assumes that the peak throughput applies to either rx or tx,
211 * rather than having separate specs of the rx max throughput vs. the tx
212 * max throughput.
213 *
214 * @param pdev - handle to the physical device
215 * @return maximum supported throughput in Mbps (not MBps)
216 */
217int ol_cfg_max_thruput_mbps(ol_pdev_handle pdev);
218
219/**
220 * @brief Specify the maximum number of fragments per tx network buffer.
221 * @details
222 * Specify the maximum number of fragments that a tx frame provided to
223 * the WLAN driver by the OS may contain.
224 * In LL systems, the host data SW uses this maximum fragment count to
225 * determine how many elements to allocate in the fragmentation descriptor
226 * it creates to specify to the tx MAC DMA where to locate the tx frame's
227 * data.
228 * This maximum fragments count is only for regular frames, not TSO frames,
229 * since TSO frames are sent in segments with a limited number of fragments
230 * per segment.
231 *
232 * @param pdev - handle to the physical device
233 * @return maximum number of fragments that can occur in a regular tx frame
234 */
235int ol_cfg_netbuf_frags_max(ol_pdev_handle pdev);
236
237/**
238 * @brief For HL systems, specify when to free tx frames.
239 * @details
240 * In LL systems, the host's tx frame is referenced by the MAC DMA, and
241 * thus cannot be freed until the target indicates that it is finished
242 * transmitting the frame.
243 * In HL systems, the entire tx frame is downloaded to the target.
244 * Consequently, the target has its own copy of the tx frame, and the
245 * host can free the tx frame as soon as the download completes.
246 * Alternatively, the HL host can keep the frame allocated until the
247 * target explicitly tells the HL host it is done transmitting the frame.
248 * This gives the target the option of discarding its copy of the tx
249 * frame, and then later getting a new copy from the host.
250 * This function tells the host whether it should retain its copy of the
251 * transmit frames until the target explicitly indicates it is finished
252 * transmitting them, or if it should free its copy as soon as the
253 * tx frame is downloaded to the target.
254 *
255 * @param pdev - handle to the physical device
256 * @return
257 * 0 -> retain the tx frame until the target indicates it is done
258 * transmitting the frame
259 * -OR-
260 * 1 -> free the tx frame as soon as the download completes
261 */
262int ol_cfg_tx_free_at_download(ol_pdev_handle pdev);
263
264/**
265 * @brief Low water mark for target tx credit.
266 * Tx completion handler is invoked to reap the buffers when the target tx
267 * credit goes below Low Water Mark.
268 */
269#define OL_CFG_NUM_MSDU_REAP 512
270#define ol_cfg_tx_credit_lwm(pdev) \
271 ((CFG_TGT_NUM_MSDU_DESC > OL_CFG_NUM_MSDU_REAP) ? \
272 (CFG_TGT_NUM_MSDU_DESC - OL_CFG_NUM_MSDU_REAP) : 0)
273
274/**
275 * @brief In a HL system, specify the target initial credit count.
276 * @details
277 * The HL host tx data SW includes a module for determining which tx frames
278 * to download to the target at a given time.
279 * To make this judgement, the HL tx download scheduler has to know
280 * how many buffers the HL target has available to hold tx frames.
281 * Due to the possibility that a single target buffer pool can be shared
282 * between rx and tx frames, the host may not be able to obtain a precise
283 * specification of the tx buffer space available in the target, but it
284 * uses the best estimate, as provided by this configuration function,
285 * to determine how best to schedule the tx frame downloads.
286 *
287 * @param pdev - handle to the physical device
288 * @return the number of tx buffers available in a HL target
289 */
290uint16_t ol_cfg_target_tx_credit(ol_pdev_handle pdev);
291
292/**
293 * @brief Specify the LL tx MSDU header download size.
294 * @details
295 * In LL systems, determine how many bytes from a tx frame to download,
296 * in order to provide the target FW's Descriptor Engine with enough of
297 * the packet's payload to interpret what kind of traffic this is,
298 * and who it is for.
299 * This download size specification does not include the 802.3 / 802.11
300 * frame encapsulation headers; it starts with the encapsulated IP packet
301 * (or whatever ethertype is carried within the ethernet-ish frame).
302 * The LL host data SW will determine how many bytes of the MSDU header to
303 * download by adding this download size specification to the size of the
304 * frame header format specified by the ol_cfg_frame_type configuration
305 * function.
306 *
307 * @param pdev - handle to the physical device
308 * @return the number of bytes beyond the 802.3 or native WiFi header to
309 * download to the target for tx classification
310 */
311int ol_cfg_tx_download_size(ol_pdev_handle pdev);
312
313/**
314 * brief Specify where defrag timeout and duplicate detection is handled
315 * @details
316 * non-aggregate duplicate detection and timing out stale fragments
317 * requires additional target memory. To reach max client
318 * configurations (128+), non-aggregate duplicate detection and the
319 * logic to time out stale fragments is moved to the host.
320 *
321 * @param pdev - handle to the physical device
322 * @return
323 * 0 -> target is responsible non-aggregate duplicate detection and
324 * timing out stale fragments.
325 *
326 * 1 -> host is responsible non-aggregate duplicate detection and
327 * timing out stale fragments.
328 */
329int ol_cfg_rx_host_defrag_timeout_duplicate_check(ol_pdev_handle pdev);
330
331/**
332 * brief Query for the period in ms used for throttling for
333 * thermal mitigation
334 * @details
335 * In LL systems, transmit data throttling is used for thermal
336 * mitigation where data is paused and resumed during the
337 * throttle period i.e. the throttle period consists of an
338 * "on" phase when transmit is allowed and an "off" phase when
339 * transmit is suspended. This function returns the total
340 * period used for throttling.
341 *
342 * @param pdev - handle to the physical device
343 * @return the total throttle period in ms
344 */
345int ol_cfg_throttle_period_ms(ol_pdev_handle pdev);
346
347/**
348 * brief Check whether full reorder offload is
349 * enabled/disable by the host
350 * @details
351 * If the host does not support receive reorder (i.e. the
352 * target performs full receive re-ordering) this will return
353 * "enabled"
354 *
355 * @param pdev - handle to the physical device
356 * @return 1 - enable, 0 - disable
357 */
358int ol_cfg_is_full_reorder_offload(ol_pdev_handle pdev);
359
360int ol_cfg_is_rx_thread_enabled(ol_pdev_handle pdev);
361
362/**
363 * ol_cfg_is_ip_tcp_udp_checksum_offload_enabled() - return
364 * ip_tcp_udp_checksum_offload is enable/disable
365 * @pdev : handle to the physical device
366 *
367 * Return: 1 - enable, 0 - disable
368 */
369static inline
370int ol_cfg_is_ip_tcp_udp_checksum_offload_enabled(ol_pdev_handle pdev)
371{
372 struct txrx_pdev_cfg_t *cfg = (struct txrx_pdev_cfg_t *)pdev;
373 return cfg->ip_tcp_udp_checksum_offload;
374}
375
376
377#ifdef QCA_LL_TX_FLOW_CONTROL_V2
378int ol_cfg_get_tx_flow_stop_queue_th(ol_pdev_handle pdev);
379
380int ol_cfg_get_tx_flow_start_queue_offset(ol_pdev_handle pdev);
381#endif
382
383bool ol_cfg_is_ce_classify_enabled(ol_pdev_handle pdev);
384
385enum wlan_target_fmt_translation_caps {
386 wlan_frm_tran_cap_raw = 0x01,
387 wlan_frm_tran_cap_native_wifi = 0x02,
388 wlan_frm_tran_cap_8023 = 0x04,
389};
390
391/**
392 * @brief Specify the maximum header size added by SW tx encapsulation
393 * @details
394 * This function returns the maximum size of the new L2 header, not the
395 * difference between the new and old L2 headers.
396 * Thus, this function returns the maximum 802.11 header size that the
397 * tx SW may need to add to tx data frames.
398 *
399 * @param pdev - handle to the physical device
400 */
401static inline int ol_cfg_sw_encap_hdr_max_size(ol_pdev_handle pdev)
402{
403 /*
404 * 24 byte basic 802.11 header
405 * + 6 byte 4th addr
406 * + 2 byte QoS control
407 * + 4 byte HT control
408 * + 8 byte LLC/SNAP
409 */
410 return sizeof(struct ieee80211_qosframe_htc_addr4) + LLC_SNAP_HDR_LEN;
411}
412
413static inline uint8_t ol_cfg_tx_encap(ol_pdev_handle pdev)
414{
415 /* tx encap done in HW */
416 return 0;
417}
418
419static inline int ol_cfg_host_addba(ol_pdev_handle pdev)
420{
421 /*
422 * ADDBA negotiation is handled by the target FW for Peregrine + Rome.
423 */
424 return 0;
425}
426
427/**
428 * @brief If the host SW's ADDBA negotiation fails, should it be retried?
429 *
430 * @param pdev - handle to the physical device
431 */
432static inline int ol_cfg_addba_retry(ol_pdev_handle pdev)
433{
434 return 0; /* disabled for now */
435}
436
437/**
438 * @brief How many frames to hold in a paused vdev's tx queue in LL systems
439 */
440static inline int ol_tx_cfg_max_tx_queue_depth_ll(ol_pdev_handle pdev)
441{
442 /*
443 * Store up to 1500 frames for a paused vdev.
444 * For example, if the vdev is sending 300 Mbps of traffic, and the
445 * PHY is capable of 600 Mbps, then it will take 56 ms for the PHY to
446 * drain both the 700 frames that are queued initially, plus the next
447 * 700 frames that come in while the PHY is catching up.
448 * So in this example scenario, the PHY will remain fully utilized
449 * in a MCC system that has a channel-switching period of 56 ms or less.
450 * 700 frames calculation was correct when FW drain packet without
451 * any overhead. Actual situation drain overhead will slowdown drain
452 * speed. And channel period is less than 56 msec
453 * Worst scenario, 1500 frames should be stored in host.
454 */
455 return 1500;
456}
457
458/**
459 * @brief Set packet log config in HTT config based on CFG ini configuration
460 */
461void ol_set_cfg_packet_log_enabled(ol_pdev_handle pdev, uint8_t val);
462
463/**
464 * @brief Get packet log config from HTT config
465 */
466uint8_t ol_cfg_is_packet_log_enabled(ol_pdev_handle pdev);
467
468#ifdef IPA_OFFLOAD
469/**
470 * @brief IPA micro controller data path offload enable or not
471 * @detail
472 * This function returns IPA micro controller data path offload
473 * feature enabled or not
474 *
475 * @param pdev - handle to the physical device
476 */
477unsigned int ol_cfg_ipa_uc_offload_enabled(ol_pdev_handle pdev);
478/**
479 * @brief IPA micro controller data path TX buffer size
480 * @detail
481 * This function returns IPA micro controller data path offload
482 * TX buffer size which should be pre-allocated by driver.
483 * Default buffer size is 2K
484 *
485 * @param pdev - handle to the physical device
486 */
487unsigned int ol_cfg_ipa_uc_tx_buf_size(ol_pdev_handle pdev);
488/**
489 * @brief IPA micro controller data path TX buffer size
490 * @detail
491 * This function returns IPA micro controller data path offload
492 * TX buffer count which should be pre-allocated by driver.
493 *
494 * @param pdev - handle to the physical device
495 */
496unsigned int ol_cfg_ipa_uc_tx_max_buf_cnt(ol_pdev_handle pdev);
497/**
498 * @brief IPA micro controller data path TX buffer size
499 * @detail
500 * This function returns IPA micro controller data path offload
501 * RX indication ring size which will notified by WLAN FW to IPA
502 * micro controller
503 *
504 * @param pdev - handle to the physical device
505 */
506unsigned int ol_cfg_ipa_uc_rx_ind_ring_size(ol_pdev_handle pdev);
507/**
508 * @brief IPA micro controller data path TX buffer size
509 * @param pdev - handle to the physical device
510 */
511unsigned int ol_cfg_ipa_uc_tx_partition_base(ol_pdev_handle pdev);
512#else
513static inline unsigned int ol_cfg_ipa_uc_offload_enabled(
514 ol_pdev_handle pdev)
515{
516 return 0;
517}
518
519static inline unsigned int ol_cfg_ipa_uc_tx_buf_size(
520 ol_pdev_handle pdev)
521{
522 return 0;
523}
524
525static inline unsigned int ol_cfg_ipa_uc_tx_max_buf_cnt(
526 ol_pdev_handle pdev)
527{
528 return 0;
529}
530
531static inline unsigned int ol_cfg_ipa_uc_rx_ind_ring_size(
532 ol_pdev_handle pdev)
533{
534 return 0;
535}
536
537static inline unsigned int ol_cfg_ipa_uc_tx_partition_base(
538 ol_pdev_handle pdev)
539{
540 return 0;
541}
542#endif /* IPA_OFFLOAD */
543#endif /* _OL_CFG__H_ */