xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_mob_def.h (revision 6d768494e5ce14eb1603a695c86739d12ecc6ec2)
1 /*
2  * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef __CDP_TXRX_MOB_DEF_H
20 #define __CDP_TXRX_MOB_DEF_H
21 #include <sir_types.h>
22 #include <htt.h>
23 
24 #define TX_WMM_AC_NUM	4
25 #define ENABLE_DP_HIST_STATS
26 #define DP_MEMORY_OPT
27 #define DP_RX_DISABLE_NDI_MDNS_FORWARDING
28 
29 #define OL_TXQ_PAUSE_REASON_FW                (1 << 0)
30 #define OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED (1 << 1)
31 #define OL_TXQ_PAUSE_REASON_TX_ABORT          (1 << 2)
32 #define OL_TXQ_PAUSE_REASON_VDEV_STOP         (1 << 3)
33 #define OL_TXQ_PAUSE_REASON_THERMAL_MITIGATION (1 << 4)
34 
35 #define OL_TXRX_INVALID_NUM_PEERS (-1)
36 
37 
38 /* Maximum number of station supported by data path, including BC. */
39 #define WLAN_MAX_STA_COUNT  (HAL_NUM_STA)
40 
41 /* The symbolic station ID return to HDD to specify the packet is bc/mc */
42 #define WLAN_RX_BCMC_STA_ID (WLAN_MAX_STA_COUNT + 1)
43 
44 /* The symbolic station ID return to HDD to specify the packet is
45        to soft-AP itself */
46 #define WLAN_RX_SAP_SELF_STA_ID (WLAN_MAX_STA_COUNT + 2)
47 
48 /* is 802.11 address multicast/broadcast? */
49 #define IEEE80211_IS_MULTICAST(_a)  (*(_a) & 0x01)
50 
51 #define MAX_PEERS 32
52 
53 /*
54  * Bins used for reporting delay histogram:
55  * bin 0:  0 - 10  ms delay
56  * bin 1: 10 - 20  ms delay
57  * bin 2: 20 - 40  ms delay
58  * bin 3: 40 - 80  ms delay
59  * bin 4: 80 - 160 ms delay
60  * bin 5: > 160 ms delay
61  */
62 #define QCA_TX_DELAY_HIST_REPORT_BINS 6
63 
64 /* BA actions */
65 #define IEEE80211_ACTION_BA_ADDBA_REQUEST       0       /* ADDBA request */
66 #define IEEE80211_ACTION_BA_ADDBA_RESPONSE      1       /* ADDBA response */
67 #define IEEE80211_ACTION_BA_DELBA               2       /* DELBA */
68 
69 #define IEEE80211_BA_POLICY_DELAYED      0
70 #define IEEE80211_BA_POLICY_IMMEDIATE    1
71 #define IEEE80211_BA_AMSDU_SUPPORTED     1
72 
73 /**
74  * enum netif_action_type - Type of actions on netif queues
75  * @WLAN_STOP_ALL_NETIF_QUEUE: stop all netif queues
76  * @WLAN_START_ALL_NETIF_QUEUE: start all netif queues
77  * @WLAN_WAKE_ALL_NETIF_QUEUE: wake all netif queues
78  * @WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER: stop all queues and off carrier
79  * @WLAN_START_ALL_NETIF_QUEUE_N_CARRIER: start all queues and on carrier
80  * @WLAN_NETIF_TX_DISABLE: disable tx
81  * @WLAN_NETIF_TX_DISABLE_N_CARRIER: disable tx and off carrier
82  * @WLAN_NETIF_CARRIER_ON: on carrier
83  * @WLAN_NETIF_CARRIER_OFF: off carrier
84  * @WLAN_NETIF_PRIORITY_QUEUE_ON: start priority netif queues
85  * @WLAN_NETIF_PRIORITY_QUEUE_OFF: stop priority netif queues
86  * @WLAN_WAKE_NON_PRIORITY_QUEUE: wake non priority netif queues
87  * @WLAN_STOP_NON_PRIORITY_QUEUE: stop non priority netif queues
88  */
89 enum netif_action_type {
90 	WLAN_NETIF_ACTION_TYPE_NONE = 0,
91 	WLAN_STOP_ALL_NETIF_QUEUE = 1,
92 	WLAN_START_ALL_NETIF_QUEUE = 2,
93 	WLAN_WAKE_ALL_NETIF_QUEUE = 3,
94 	WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER = 4,
95 	WLAN_START_ALL_NETIF_QUEUE_N_CARRIER = 5,
96 	WLAN_NETIF_TX_DISABLE = 6,
97 	WLAN_NETIF_TX_DISABLE_N_CARRIER = 7,
98 	WLAN_NETIF_CARRIER_ON = 8,
99 	WLAN_NETIF_CARRIER_OFF = 9,
100 	WLAN_NETIF_PRIORITY_QUEUE_ON = 10,
101 	WLAN_NETIF_PRIORITY_QUEUE_OFF = 11,
102 	WLAN_NETIF_VO_QUEUE_ON = 12,
103 	WLAN_NETIF_VO_QUEUE_OFF = 13,
104 	WLAN_NETIF_VI_QUEUE_ON = 14,
105 	WLAN_NETIF_VI_QUEUE_OFF = 15,
106 	WLAN_NETIF_BE_BK_QUEUE_OFF = 16,
107 	WLAN_WAKE_NON_PRIORITY_QUEUE = 17,
108 	WLAN_STOP_NON_PRIORITY_QUEUE = 18,
109 	WLAN_NETIF_ACTION_TYPE_MAX,
110 };
111 
112 /**
113  * enum netif_reason_type - reason for netif queue action
114  * @WLAN_CONTROL_PATH: action from control path
115  * @WLAN_DATA_FLOW_CONTROL: because of flow control
116  * @WLAN_FW_PAUSE: because of firmware pause
117  * @WLAN_TX_ABORT: because of tx abort
118  * @WLAN_VDEV_STOP: because of vdev stop
119  * @WLAN_PEER_UNAUTHORISED: because of peer is unauthorised
120  * @WLAN_THERMAL_MITIGATION: because of thermal mitigation
121  */
122 enum netif_reason_type {
123 	WLAN_CONTROL_PATH = 1,
124 	WLAN_DATA_FLOW_CONTROL,
125 	WLAN_FW_PAUSE,
126 	WLAN_TX_ABORT,
127 	WLAN_VDEV_STOP,
128 	WLAN_PEER_UNAUTHORISED,
129 	WLAN_THERMAL_MITIGATION,
130 	WLAN_DATA_FLOW_CONTROL_PRIORITY,
131 	WLAN_REASON_TYPE_MAX,
132 };
133 
134 enum ol_rx_err_type {
135 	OL_RX_ERR_DEFRAG_MIC,
136 	OL_RX_ERR_PN,
137 	OL_RX_ERR_UNKNOWN_PEER,
138 	OL_RX_ERR_MALFORMED,
139 	OL_RX_ERR_TKIP_MIC,
140 	OL_RX_ERR_DECRYPT,
141 	OL_RX_ERR_MPDU_LENGTH,
142 	OL_RX_ERR_ENCRYPT_REQUIRED,
143 	OL_RX_ERR_DUP,
144 	OL_RX_ERR_UNKNOWN,
145 	OL_RX_ERR_FCS,
146 	OL_RX_ERR_PRIVACY,
147 	OL_RX_ERR_NONE_FRAG,
148 	OL_RX_ERR_NONE = 0xFF
149 };
150 
151 enum throttle_level {
152 	THROTTLE_LEVEL_0,
153 	THROTTLE_LEVEL_1,
154 	THROTTLE_LEVEL_2,
155 	THROTTLE_LEVEL_3,
156 	/* Invalid */
157 	THROTTLE_LEVEL_MAX,
158 };
159 
160 enum {
161 	OL_TX_WMM_AC_BE,
162 	OL_TX_WMM_AC_BK,
163 	OL_TX_WMM_AC_VI,
164 	OL_TX_WMM_AC_VO,
165 	OL_TX_NUM_WMM_AC
166 };
167 
168 /**
169  * @enum ol_tx_spec
170  * @brief indicate what non-standard transmission actions to apply
171  * @details
172  *  Indicate one or more of the following:
173  *    - The tx frame already has a complete 802.11 header.
174  *      Thus, skip 802.3/native-WiFi to 802.11 header encapsulation and
175  *      A-MSDU aggregation.
176  *    - The tx frame should not be aggregated (A-MPDU or A-MSDU)
177  *    - The tx frame is already encrypted - don't attempt encryption.
178  *    - The tx frame is a segment of a TCP jumbo frame.
179  *    - This tx frame should not be unmapped and freed by the txrx layer
180  *      after transmission, but instead given to a registered tx completion
181  *      callback.
182  *  More than one of these specification can apply, though typically
183  *  only a single specification is applied to a tx frame.
184  *  A compound specification can be created, as a bit-OR of these
185  *  specifications.
186  */
187 enum ol_tx_spec {
188 	OL_TX_SPEC_STD = 0x0,   /* do regular processing */
189 	OL_TX_SPEC_RAW = 0x1,   /* skip encap + A-MSDU aggr */
190 	OL_TX_SPEC_NO_AGGR = 0x2,       /* skip encap + all aggr */
191 	OL_TX_SPEC_NO_ENCRYPT = 0x4,    /* skip encap + encrypt */
192 	OL_TX_SPEC_TSO = 0x8,   /* TCP segmented */
193 	OL_TX_SPEC_NWIFI_NO_ENCRYPT = 0x10,     /* skip encrypt for nwifi */
194 	OL_TX_SPEC_NO_FREE = 0x20,      /* give to cb rather than free */
195 };
196 
197 /**
198  * @enum peer_debug_id_type: debug ids to track peer get_ref and release_ref
199  * @brief Unique peer debug IDs to track the callers. Each new usage can add to
200  *        this enum list to create a new "PEER_DEBUG_ID_".
201  * @PEER_DEBUG_ID_OL_INTERNAL: debug id for OL internal usage
202  * @PEER_DEBUG_ID_WMA_PKT_DROP: debug id for wma_is_pkt_drop_candidate API
203  * @PEER_DEBUG_ID_WMA_ADDBA_REQ: debug id for ADDBA request
204  * @PEER_DEBUG_ID_WMA_DELBA_REQ: debug id for DELBA request
205  * @PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP: debug id for send ADDBA response
206  * @PEER_DEBUG_ID_OL_RX_THREAD: debug id for rx thread
207  * @PEER_DEBUG_ID_WMA_CCMP_REPLAY_ATTACK: debug id for CCMP replay
208  * @PEER_DEBUG_ID_WMA_DEL_BSS:debug id for remove BSS
209  * @PEER_DEBUG_ID_WMA_VDEV_STOP_RESP:debug id for vdev stop response handler
210  * @PEER_DEBUG_ID_OL_PEER_MAP:debug id for peer map/unmap
211  * @PEER_DEBUG_ID_OL_PEER_ATTACH: debug id for peer attach/detach
212  * @PEER_DEBUG_ID_OL_TXQ_VDEV_FL: debug id for vdev flush
213  * @PEER_DEBUG_ID_OL_HASH_ERS:debug id for peer find hash erase
214  * @PEER_DEBUG_ID_MAX: debug id MAX
215  */
216 enum peer_debug_id_type {
217 	PEER_DEBUG_ID_OL_INTERNAL,
218 	PEER_DEBUG_ID_WMA_PKT_DROP,
219 	PEER_DEBUG_ID_WMA_ADDBA_REQ,
220 	PEER_DEBUG_ID_WMA_DELBA_REQ,
221 	PEER_DEBUG_ID_LIM_SEND_ADDBA_RESP,
222 	PEER_DEBUG_ID_OL_RX_THREAD,
223 	PEER_DEBUG_ID_WMA_CCMP_REPLAY_ATTACK,
224 	PEER_DEBUG_ID_WMA_DEL_BSS,
225 	PEER_DEBUG_ID_WMA_VDEV_STOP_RESP,
226 	PEER_DEBUG_ID_OL_PEER_MAP,
227 	PEER_DEBUG_ID_OL_PEER_ATTACH,
228 	PEER_DEBUG_ID_OL_TXQ_VDEV_FL,
229 	PEER_DEBUG_ID_OL_HASH_ERS,
230 	PEER_DEBUG_ID_OL_UNMAP_TIMER_WORK,
231 	PEER_DEBUG_ID_MAX
232 };
233 
234 /**
235  * struct ol_txrx_desc_type - txrx descriptor type
236  * @is_qos_enabled: is station qos enabled
237  * @is_wapi_supported: is station wapi supported
238  * @peer_addr: peer mac address
239  */
240 struct ol_txrx_desc_type {
241 	uint8_t is_qos_enabled;
242 	uint8_t is_wapi_supported;
243 	struct qdf_mac_addr peer_addr;
244 };
245 
246 /**
247  * struct ol_tx_sched_wrr_ac_specs_t - the wrr ac specs params structure
248  * @wrr_skip_weight: map to ol_tx_sched_wrr_adv_category_info_t.specs.
249  *                            wrr_skip_weight
250  * @credit_threshold: map to ol_tx_sched_wrr_adv_category_info_t.specs.
251  *                            credit_threshold
252  * @send_limit: map to ol_tx_sched_wrr_adv_category_info_t.specs.
253  *                            send_limit
254  * @credit_reserve: map to ol_tx_sched_wrr_adv_category_info_t.specs.
255  *                            credit_reserve
256  * @discard_weight: map to ol_tx_sched_wrr_adv_category_info_t.specs.
257  *                            discard_weight
258  *
259  * This structure is for wrr ac specs params set from user, it will update
260  * its content corresponding to the ol_tx_sched_wrr_adv_category_info_t.specs.
261  */
262 struct ol_tx_sched_wrr_ac_specs_t {
263 	int wrr_skip_weight;
264 	uint32_t credit_threshold;
265 	uint16_t send_limit;
266 	int credit_reserve;
267 	int discard_weight;
268 };
269 
270 /**
271  * struct txrx_pdev_cfg_param_t - configuration information
272  * passed to the data path
273  */
274 struct txrx_pdev_cfg_param_t {
275 	uint8_t is_full_reorder_offload;
276 	/* IPA Micro controller data path offload enable flag */
277 	uint8_t is_uc_offload_enabled;
278 	/* IPA Micro controller data path offload TX buffer count */
279 	uint32_t uc_tx_buffer_count;
280 	/* IPA Micro controller data path offload TX buffer size */
281 	uint32_t uc_tx_buffer_size;
282 	/* IPA Micro controller data path offload RX indication ring count */
283 	uint32_t uc_rx_indication_ring_count;
284 	/* IPA Micro controller data path offload TX partition base */
285 	uint32_t uc_tx_partition_base;
286 	/* IP, TCP and UDP checksum offload */
287 	bool ip_tcp_udp_checksum_offload;
288 	/* IP, TCP and UDP checksum offload for NAN Mode*/
289 	bool nan_ip_tcp_udp_checksum_offload;
290 	/* Rx processing in thread from TXRX */
291 	bool enable_rxthread;
292 	/* CE classification enabled through INI */
293 	bool ce_classify_enabled;
294 #if defined(QCA_LL_TX_FLOW_CONTROL_V2) || defined(QCA_LL_PDEV_TX_FLOW_CONTROL)
295 	/* Threshold to stop queue in percentage */
296 	uint32_t tx_flow_stop_queue_th;
297 	/* Start queue offset in percentage */
298 	uint32_t tx_flow_start_queue_offset;
299 #endif
300 
301 #ifdef QCA_SUPPORT_TXRX_DRIVER_TCP_DEL_ACK
302 	/* enable the tcp delay ack feature in the driver */
303 	bool  del_ack_enable;
304 	/* timeout if no more tcp ack frames, unit is ms */
305 	uint16_t del_ack_timer_value;
306 	/* the maximum number of replaced tcp ack frames */
307 	uint16_t del_ack_pkt_count;
308 #endif
309 
310 	struct ol_tx_sched_wrr_ac_specs_t ac_specs[TX_WMM_AC_NUM];
311 	bool gro_enable;
312 	bool tso_enable;
313 	bool lro_enable;
314 	bool enable_data_stall_detection;
315 	bool enable_flow_steering;
316 	bool disable_intra_bss_fwd;
317 
318 #ifdef WLAN_SUPPORT_TXRX_HL_BUNDLE
319 	uint16_t bundle_timer_value;
320 	uint16_t bundle_size;
321 #endif
322 	uint8_t pktlog_buffer_size;
323 };
324 
325 #ifdef IPA_OFFLOAD
326 /**
327  * ol_txrx_ipa_resources - Resources needed for IPA
328  */
329 struct ol_txrx_ipa_resources {
330 	qdf_shared_mem_t *ce_sr;
331 	uint32_t ce_sr_ring_size;
332 	qdf_dma_addr_t ce_reg_paddr;
333 
334 	qdf_shared_mem_t *tx_comp_ring;
335 	uint32_t tx_num_alloc_buffer;
336 
337 	qdf_shared_mem_t *rx_rdy_ring;
338 	qdf_shared_mem_t *rx_proc_done_idx;
339 
340 	qdf_shared_mem_t *rx2_rdy_ring;
341 	qdf_shared_mem_t *rx2_proc_done_idx;
342 
343 	/* IPA UC doorbell registers paddr */
344 	qdf_dma_addr_t tx_comp_doorbell_dmaaddr;
345 	qdf_dma_addr_t rx_ready_doorbell_dmaaddr;
346 
347 	uint32_t tx_pipe_handle;
348 	uint32_t rx_pipe_handle;
349 };
350 #endif
351 
352 struct ol_txrx_ocb_chan_info {
353 	uint32_t chan_freq;
354 	uint16_t disable_rx_stats_hdr:1;
355 };
356 
357 /**
358  * ol_mic_error_info - carries the information associated with
359  * a MIC error
360  * @vdev_id: virtual device ID
361  * @key_id: Key ID
362  * @pn: packet number
363  * @sa: source address
364  * @da: destination address
365  * @ta: transmitter address
366  */
367 struct ol_mic_error_info {
368 	uint8_t vdev_id;
369 	uint32_t key_id;
370 	uint64_t pn;
371 	uint8_t sa[QDF_MAC_ADDR_SIZE];
372 	uint8_t da[QDF_MAC_ADDR_SIZE];
373 	uint8_t ta[QDF_MAC_ADDR_SIZE];
374 };
375 
376 /**
377  * ol_error_info - carries the information associated with an
378  * error indicated by the firmware
379  * @mic_err: MIC error information
380  */
381 struct ol_error_info {
382 	union {
383 		struct ol_mic_error_info mic_err;
384 	} u;
385 };
386 
387 
388 /**
389  * struct ol_txrx_ocb_set_chan - txrx OCB channel info
390  * @ocb_channel_count: Channel count
391  * @ocb_channel_info: OCB channel info
392  */
393 struct ol_txrx_ocb_set_chan {
394 	uint32_t ocb_channel_count;
395 	struct ol_txrx_ocb_chan_info *ocb_channel_info;
396 };
397 
398 /**
399  * @brief Parameter type to pass WMM setting to ol_txrx_set_wmm_param
400  * @details
401  *   The struct is used to specify informaiton to update TX WMM scheduler.
402  */
403 struct ol_tx_ac_param_t {
404 	uint32_t aifs;
405 	uint32_t cwmin;
406 	uint32_t cwmax;
407 };
408 
409 struct ol_tx_wmm_param_t {
410 	struct ol_tx_ac_param_t ac[OL_TX_NUM_WMM_AC];
411 };
412 
413 struct ieee80211_ba_parameterset {
414 #if _BYTE_ORDER == _BIG_ENDIAN
415 	uint16_t buffersize:10, /* B6-15  buffer size */
416 		 tid:4,       /* B2-5   TID */
417 		 bapolicy:1,  /* B1   block ack policy */
418 		 amsdusupported:1; /* B0   amsdu supported */
419 #else
420 	uint16_t amsdusupported:1,      /* B0   amsdu supported */
421 		 bapolicy:1,  /* B1   block ack policy */
422 		 tid:4,       /* B2-5   TID */
423 		 buffersize:10; /* B6-15  buffer size */
424 #endif
425 } __packed;
426 
427 struct ieee80211_ba_seqctrl {
428 #if _BYTE_ORDER == _BIG_ENDIAN
429 	uint16_t startseqnum:12,        /* B4-15  starting sequence number */
430 		 fragnum:4;   /* B0-3  fragment number */
431 #else
432 	uint16_t fragnum:4,     /* B0-3  fragment number */
433 		 startseqnum:12; /* B4-15  starting sequence number */
434 #endif
435 } __packed;
436 
437 struct ieee80211_delba_parameterset {
438 #if _BYTE_ORDER == _BIG_ENDIAN
439 	uint16_t tid:4,         /* B12-15  tid */
440 		 initiator:1, /* B11     initiator */
441 		 reserved0:11; /* B0-10   reserved */
442 #else
443 	uint16_t reserved0:11,  /* B0-10   reserved */
444 		 initiator:1, /* B11     initiator */
445 		 tid:4;       /* B12-15  tid */
446 #endif
447 } __packed;
448 
449 /**
450  * ol_txrx_vdev_peer_remove_cb - wma_remove_peer callback
451  */
452 typedef void (*ol_txrx_vdev_peer_remove_cb)(void *handle, uint8_t *bssid,
453 		uint8_t vdev_id, void *peer);
454 
455 /**
456  * @typedef tx_pause_callback
457  * @brief OSIF function registered with the data path
458  */
459 typedef void (*tx_pause_callback)(uint8_t vdev_id,
460 		enum netif_action_type action,
461 		enum netif_reason_type reason);
462 
463 typedef void (*ipa_uc_op_cb_type)(uint8_t *op_msg,
464 			void *osif_ctxt);
465 
466 /**
467  * struct ol_rx_inv_peer_params - rx invalid peer data parameters
468  * @vdev_id: Virtual device ID
469  * @ra: RX data receiver MAC address
470  * @ta: RX data transmitter MAC address
471  */
472 struct ol_rx_inv_peer_params {
473 	uint8_t vdev_id;
474 	uint8_t ra[QDF_MAC_ADDR_SIZE];
475 	uint8_t ta[QDF_MAC_ADDR_SIZE];
476 };
477 
478 /**
479  * cdp_txrx_ext_stats: dp extended stats
480  * tx_msdu_enqueue: tx msdu queued to hw
481  * tx_msdu_overflow: tx msdu overflow
482  * rx_mpdu_received: rx mpdu processed by hw
483  * rx_mpdu_delivered: rx mpdu received from hw
484  * rx_mpdu_error: rx mpdu error count
485  * rx_mpdu_missed: rx mpdu missed by hw
486  */
487 struct cdp_txrx_ext_stats {
488 	uint32_t tx_msdu_enqueue;
489 	uint32_t tx_msdu_overflow;
490 	uint32_t rx_mpdu_received;
491 	uint32_t rx_mpdu_delivered;
492 	uint32_t rx_mpdu_error;
493 	uint32_t rx_mpdu_missed;
494 };
495 
496 #endif /* __CDP_TXRX_MOB_DEF_H */
497