xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/dp_internal.h (revision a175314c51a4ce5cec2835cc8a8c7dc0c1810915)
1 /*
2  * Copyright (c) 2016-2018 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 _DP_INTERNAL_H_
20 #define _DP_INTERNAL_H_
21 
22 #include "dp_types.h"
23 
24 #define RX_BUFFER_SIZE_PKTLOG_LITE 1024
25 
26 /* Macro For NYSM value received in VHT TLV */
27 #define VHT_SGI_NYSM 3
28 
29 #if DP_PRINT_ENABLE
30 #include <stdarg.h>       /* va_list */
31 #include <qdf_types.h> /* qdf_vprint */
32 #include <cdp_txrx_handle.h>
33 
34 enum {
35 	/* FATAL_ERR - print only irrecoverable error messages */
36 	DP_PRINT_LEVEL_FATAL_ERR,
37 
38 	/* ERR - include non-fatal err messages */
39 	DP_PRINT_LEVEL_ERR,
40 
41 	/* WARN - include warnings */
42 	DP_PRINT_LEVEL_WARN,
43 
44 	/* INFO1 - include fundamental, infrequent events */
45 	DP_PRINT_LEVEL_INFO1,
46 
47 	/* INFO2 - include non-fundamental but infrequent events */
48 	DP_PRINT_LEVEL_INFO2,
49 };
50 
51 
52 #define dp_print(level, fmt, ...) do { \
53 	if (level <= g_txrx_print_level) \
54 		qdf_print(fmt, ## __VA_ARGS__); \
55 while (0)
56 #define DP_PRINT(level, fmt, ...) do { \
57 	dp_print(level, "DP: " fmt, ## __VA_ARGS__); \
58 while (0)
59 #else
60 #define DP_PRINT(level, fmt, ...)
61 #endif /* DP_PRINT_ENABLE */
62 
63 #define DP_TRACE(LVL, fmt, args ...)                             \
64 	QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL,       \
65 		fmt, ## args)
66 
67 #define DP_TRACE_STATS(LVL, fmt, args ...)                             \
68 	QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_##LVL,       \
69 		fmt, ## args)
70 
71 #define DP_PRINT_STATS(fmt, args ...)	\
72 	QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,       \
73 		fmt, ## args)
74 
75 #define DP_STATS_INIT(_handle) \
76 	qdf_mem_set(&((_handle)->stats), sizeof((_handle)->stats), 0x0)
77 
78 #define DP_STATS_CLR(_handle) \
79 	qdf_mem_set(&((_handle)->stats), sizeof((_handle)->stats), 0x0)
80 
81 #ifndef DISABLE_DP_STATS
82 #define DP_STATS_INC(_handle, _field, _delta) \
83 { \
84 	if (likely(_handle)) \
85 		_handle->stats._field += _delta; \
86 }
87 
88 #define DP_STATS_INCC(_handle, _field, _delta, _cond) \
89 { \
90 	if (_cond && likely(_handle)) \
91 		_handle->stats._field += _delta; \
92 }
93 
94 #define DP_STATS_DEC(_handle, _field, _delta) \
95 { \
96 	if (likely(_handle)) \
97 		_handle->stats._field -= _delta; \
98 }
99 
100 #define DP_STATS_UPD(_handle, _field, _delta) \
101 { \
102 	if (likely(_handle)) \
103 		_handle->stats._field = _delta; \
104 }
105 
106 #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes) \
107 { \
108 	DP_STATS_INC(_handle, _field.num, _count); \
109 	DP_STATS_INC(_handle, _field.bytes, _bytes) \
110 }
111 
112 #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond) \
113 { \
114 	DP_STATS_INCC(_handle, _field.num, _count, _cond); \
115 	DP_STATS_INCC(_handle, _field.bytes, _bytes, _cond) \
116 }
117 
118 #define DP_STATS_AGGR(_handle_a, _handle_b, _field) \
119 { \
120 	_handle_a->stats._field += _handle_b->stats._field; \
121 }
122 
123 #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field) \
124 { \
125 	DP_STATS_AGGR(_handle_a, _handle_b, _field.num); \
126 	DP_STATS_AGGR(_handle_a, _handle_b, _field.bytes);\
127 }
128 
129 #define DP_STATS_UPD_STRUCT(_handle_a, _handle_b, _field) \
130 { \
131 	_handle_a->stats._field = _handle_b->stats._field; \
132 }
133 
134 #define DP_HIST_INIT() \
135 	uint32_t num_of_packets[MAX_PDEV_CNT] = {0};
136 
137 #define DP_HIST_PACKET_COUNT_INC(_pdev_id) \
138 { \
139 		++num_of_packets[_pdev_id]; \
140 }
141 
142 #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
143 	do {                                                              \
144 		if (_p_cntrs == 1) {                                      \
145 			DP_STATS_INC(_pdev,                               \
146 				tx_comp_histogram.pkts_1, 1);             \
147 		} else if (_p_cntrs > 1 && _p_cntrs <= 20) {              \
148 			DP_STATS_INC(_pdev,                               \
149 				tx_comp_histogram.pkts_2_20, 1);          \
150 		} else if (_p_cntrs > 20 && _p_cntrs <= 40) {             \
151 			DP_STATS_INC(_pdev,                               \
152 				tx_comp_histogram.pkts_21_40, 1);         \
153 		} else if (_p_cntrs > 40 && _p_cntrs <= 60) {             \
154 			DP_STATS_INC(_pdev,                               \
155 				tx_comp_histogram.pkts_41_60, 1);         \
156 		} else if (_p_cntrs > 60 && _p_cntrs <= 80) {             \
157 			DP_STATS_INC(_pdev,                               \
158 				tx_comp_histogram.pkts_61_80, 1);         \
159 		} else if (_p_cntrs > 80 && _p_cntrs <= 100) {            \
160 			DP_STATS_INC(_pdev,                               \
161 				tx_comp_histogram.pkts_81_100, 1);        \
162 		} else if (_p_cntrs > 100 && _p_cntrs <= 200) {           \
163 			DP_STATS_INC(_pdev,                               \
164 				tx_comp_histogram.pkts_101_200, 1);       \
165 		} else if (_p_cntrs > 200) {                              \
166 			DP_STATS_INC(_pdev,                               \
167 				tx_comp_histogram.pkts_201_plus, 1);      \
168 		}                                                         \
169 	} while (0)
170 
171 #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs) \
172 	do {                                                              \
173 		if (_p_cntrs == 1) {                                      \
174 			DP_STATS_INC(_pdev,                               \
175 				rx_ind_histogram.pkts_1, 1);              \
176 		} else if (_p_cntrs > 1 && _p_cntrs <= 20) {              \
177 			DP_STATS_INC(_pdev,                               \
178 				rx_ind_histogram.pkts_2_20, 1);           \
179 		} else if (_p_cntrs > 20 && _p_cntrs <= 40) {             \
180 			DP_STATS_INC(_pdev,                               \
181 				rx_ind_histogram.pkts_21_40, 1);          \
182 		} else if (_p_cntrs > 40 && _p_cntrs <= 60) {             \
183 			DP_STATS_INC(_pdev,                               \
184 				rx_ind_histogram.pkts_41_60, 1);          \
185 		} else if (_p_cntrs > 60 && _p_cntrs <= 80) {             \
186 			DP_STATS_INC(_pdev,                               \
187 				rx_ind_histogram.pkts_61_80, 1);          \
188 		} else if (_p_cntrs > 80 && _p_cntrs <= 100) {            \
189 			DP_STATS_INC(_pdev,                               \
190 				rx_ind_histogram.pkts_81_100, 1);         \
191 		} else if (_p_cntrs > 100 && _p_cntrs <= 200) {           \
192 			DP_STATS_INC(_pdev,                               \
193 				rx_ind_histogram.pkts_101_200, 1);        \
194 		} else if (_p_cntrs > 200) {                              \
195 			DP_STATS_INC(_pdev,                               \
196 				rx_ind_histogram.pkts_201_plus, 1);       \
197 		}                                                         \
198 	} while (0)
199 
200 #define DP_TX_HIST_STATS_PER_PDEV() \
201 	do { \
202 		uint8_t hist_stats = 0; \
203 		for (hist_stats = 0; hist_stats < soc->pdev_count; \
204 				hist_stats++) { \
205 			DP_TX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
206 					num_of_packets[hist_stats]); \
207 		} \
208 	}  while (0)
209 
210 
211 #define DP_RX_HIST_STATS_PER_PDEV() \
212 	do { \
213 		uint8_t hist_stats = 0; \
214 		for (hist_stats = 0; hist_stats < soc->pdev_count; \
215 				hist_stats++) { \
216 			DP_RX_HISTOGRAM_UPDATE(soc->pdev_list[hist_stats], \
217 					num_of_packets[hist_stats]); \
218 		} \
219 	}  while (0)
220 
221 
222 #else
223 #define DP_STATS_INC(_handle, _field, _delta)
224 #define DP_STATS_INCC(_handle, _field, _delta, _cond)
225 #define DP_STATS_DEC(_handle, _field, _delta)
226 #define DP_STATS_UPD(_handle, _field, _delta)
227 #define DP_STATS_INC_PKT(_handle, _field, _count, _bytes)
228 #define DP_STATS_INCC_PKT(_handle, _field, _count, _bytes, _cond)
229 #define DP_STATS_AGGR(_handle_a, _handle_b, _field)
230 #define DP_STATS_AGGR_PKT(_handle_a, _handle_b, _field)
231 #define DP_HIST_INIT()
232 #define DP_HIST_PACKET_COUNT_INC(_pdev_id)
233 #define DP_TX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
234 #define DP_RX_HISTOGRAM_UPDATE(_pdev, _p_cntrs)
235 #define DP_RX_HIST_STATS_PER_PDEV()
236 #define DP_TX_HIST_STATS_PER_PDEV()
237 #endif
238 
239 #define DP_HTT_T2H_HP_PIPE 5
240 
241 #define DP_UPDATE_STATS(_tgtobj, _srcobj)	\
242 	do {				\
243 		uint8_t i;		\
244 		uint8_t pream_type;	\
245 		for (pream_type = 0; pream_type < DOT11_MAX; pream_type++) { \
246 			for (i = 0; i < MAX_MCS; i++) { \
247 				DP_STATS_AGGR(_tgtobj, _srcobj, \
248 					tx.pkt_type[pream_type].mcs_count[i]); \
249 				DP_STATS_AGGR(_tgtobj, _srcobj, \
250 					rx.pkt_type[pream_type].mcs_count[i]); \
251 			} \
252 		} \
253 		  \
254 		for (i = 0; i < MAX_BW; i++) { \
255 			DP_STATS_AGGR(_tgtobj, _srcobj, tx.bw[i]); \
256 			DP_STATS_AGGR(_tgtobj, _srcobj, rx.bw[i]); \
257 		} \
258 		  \
259 		for (i = 0; i < SS_COUNT; i++) { \
260 			DP_STATS_AGGR(_tgtobj, _srcobj, rx.nss[i]); \
261 			DP_STATS_AGGR(_tgtobj, _srcobj, tx.nss[i]); \
262 		} \
263 		for (i = 0; i < WME_AC_MAX; i++) { \
264 			DP_STATS_AGGR(_tgtobj, _srcobj, tx.wme_ac_type[i]); \
265 			DP_STATS_AGGR(_tgtobj, _srcobj, rx.wme_ac_type[i]); \
266 			DP_STATS_AGGR(_tgtobj, _srcobj, tx.excess_retries_per_ac[i]); \
267 		\
268 		} \
269 		\
270 		for (i = 0; i < MAX_GI; i++) { \
271 			DP_STATS_AGGR(_tgtobj, _srcobj, tx.sgi_count[i]); \
272 			DP_STATS_AGGR(_tgtobj, _srcobj, rx.sgi_count[i]); \
273 		} \
274 		\
275 		for (i = 0; i < MAX_RECEPTION_TYPES; i++) \
276 			DP_STATS_AGGR(_tgtobj, _srcobj, rx.reception_type[i]); \
277 		\
278 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.comp_pkt); \
279 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.ucast); \
280 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.mcast); \
281 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.bcast); \
282 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.tx_success); \
283 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, tx.nawds_mcast); \
284 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.tx_failed); \
285 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.ofdma); \
286 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.stbc); \
287 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.ldpc); \
288 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.retries); \
289 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.non_amsdu_cnt); \
290 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.amsdu_cnt); \
291 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem); \
292 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_tx); \
293 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_rem_notx); \
294 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason1); \
295 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason2); \
296 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.fw_reason3); \
297 		DP_STATS_AGGR(_tgtobj, _srcobj, tx.dropped.age_out); \
298 								\
299 		DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.mic_err); \
300 		DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.rssi); \
301 		DP_STATS_UPD_STRUCT(_tgtobj, _srcobj, rx.rx_rate); \
302 		DP_STATS_AGGR(_tgtobj, _srcobj, rx.err.decrypt_err); \
303 		DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_ampdu_cnt); \
304 		DP_STATS_AGGR(_tgtobj, _srcobj, rx.ampdu_cnt); \
305 		DP_STATS_AGGR(_tgtobj, _srcobj, rx.non_amsdu_cnt); \
306 		DP_STATS_AGGR(_tgtobj, _srcobj, rx.amsdu_cnt); \
307 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.to_stack); \
308 								\
309 		for (i = 0; i <  CDP_MAX_RX_RINGS; i++)	\
310 			DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.rcvd_reo[i]); \
311 									\
312 		_srcobj->stats.rx.unicast.num = \
313 			_srcobj->stats.rx.to_stack.num - \
314 					(_srcobj->stats.rx.multicast.num +  \
315 					_srcobj->stats.rx.bcast.num); \
316 		_srcobj->stats.rx.unicast.bytes = \
317 			_srcobj->stats.rx.to_stack.bytes - \
318 					(_srcobj->stats.rx.multicast.bytes + \
319 					_srcobj->stats.rx.bcast.bytes); \
320 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.unicast); \
321 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.multicast); \
322 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.bcast); \
323 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.raw); \
324 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.pkts); \
325 		DP_STATS_AGGR_PKT(_tgtobj, _srcobj, rx.intra_bss.fail); \
326 								  \
327 		_tgtobj->stats.tx.last_ack_rssi =	\
328 			_srcobj->stats.tx.last_ack_rssi; \
329 	}  while (0)
330 
331 extern int dp_peer_find_attach(struct dp_soc *soc);
332 extern void dp_peer_find_detach(struct dp_soc *soc);
333 extern void dp_peer_find_hash_add(struct dp_soc *soc, struct dp_peer *peer);
334 extern void dp_peer_find_hash_remove(struct dp_soc *soc, struct dp_peer *peer);
335 extern void dp_peer_find_hash_erase(struct dp_soc *soc);
336 extern void dp_peer_rx_init(struct dp_pdev *pdev, struct dp_peer *peer);
337 extern void dp_peer_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
338 extern void dp_peer_rx_cleanup(struct dp_vdev *vdev, struct dp_peer *peer);
339 extern void dp_peer_unref_delete(void *peer_handle);
340 extern void dp_rx_discard(struct dp_vdev *vdev, struct dp_peer *peer,
341 	unsigned tid, qdf_nbuf_t msdu_list);
342 extern void *dp_find_peer_by_addr(struct cdp_pdev *dev,
343 	uint8_t *peer_mac_addr, uint8_t *peer_id);
344 extern struct dp_peer *dp_peer_find_hash_find(struct dp_soc *soc,
345 	uint8_t *peer_mac_addr, int mac_addr_is_aligned, uint8_t vdev_id);
346 
347 #ifndef CONFIG_WIN
348 QDF_STATUS dp_register_peer(struct cdp_pdev *pdev_handle,
349 		struct ol_txrx_desc_type *sta_desc);
350 QDF_STATUS dp_clear_peer(struct cdp_pdev *pdev_handle, uint8_t local_id);
351 void *dp_find_peer_by_addr_and_vdev(struct cdp_pdev *pdev_handle,
352 		struct cdp_vdev *vdev,
353 		uint8_t *peer_addr, uint8_t *local_id);
354 uint16_t dp_local_peer_id(void *peer);
355 void *dp_peer_find_by_local_id(struct cdp_pdev *pdev_handle, uint8_t local_id);
356 QDF_STATUS dp_peer_state_update(struct cdp_pdev *pdev_handle, uint8_t *peer_mac,
357 		enum ol_txrx_peer_state state);
358 QDF_STATUS dp_get_vdevid(void *peer_handle, uint8_t *vdev_id);
359 struct cdp_vdev *dp_get_vdev_by_sta_id(struct cdp_pdev *pdev_handle,
360 		uint8_t sta_id);
361 struct cdp_vdev *dp_get_vdev_for_peer(void *peer);
362 uint8_t *dp_peer_get_peer_mac_addr(void *peer);
363 int dp_get_peer_state(void *peer_handle);
364 void dp_local_peer_id_pool_init(struct dp_pdev *pdev);
365 void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer);
366 void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer);
367 qdf_time_t *dp_get_last_assoc_received(void *peer_handle);
368 qdf_time_t *dp_get_last_disassoc_received(void *peer_handle);
369 qdf_time_t *dp_get_last_deauth_received(void *peer_handle);
370 #else
371 static inline void dp_local_peer_id_pool_init(struct dp_pdev *pdev)
372 {
373 }
374 
375 static inline
376 void dp_local_peer_id_alloc(struct dp_pdev *pdev, struct dp_peer *peer)
377 {
378 }
379 
380 static inline
381 void dp_local_peer_id_free(struct dp_pdev *pdev, struct dp_peer *peer)
382 {
383 }
384 #endif
385 extern int dp_addba_requestprocess_wifi3(void *peer_handle,
386 	uint8_t dialogtoken, uint16_t tid, uint16_t batimeout,
387 	uint16_t buffersize, uint16_t startseqnum);
388 extern void dp_addba_responsesetup_wifi3(void *peer_handle, uint8_t tid,
389 	uint8_t *dialogtoken, uint16_t *statuscode,
390 	uint16_t *buffersize, uint16_t *batimeout);
391 extern void dp_set_addba_response(void *peer_handle, uint8_t tid,
392 	uint16_t statuscode);
393 extern int dp_delba_process_wifi3(void *peer_handle,
394 	int tid, uint16_t reasoncode);
395 
396 extern int dp_rx_tid_setup_wifi3(struct dp_peer *peer, int tid,
397 	uint32_t ba_window_size, uint32_t start_seq);
398 
399 extern QDF_STATUS dp_reo_send_cmd(struct dp_soc *soc,
400 	enum hal_reo_cmd_type type, struct hal_reo_cmd_params *params,
401 	void (*callback_fn), void *data);
402 
403 extern void dp_reo_cmdlist_destroy(struct dp_soc *soc);
404 extern void dp_reo_status_ring_handler(struct dp_soc *soc);
405 void dp_aggregate_vdev_stats(struct dp_vdev *vdev);
406 void dp_rx_tid_stats_cb(struct dp_soc *soc, void *cb_ctxt,
407 	union hal_reo_status *reo_status);
408 void dp_rx_bar_stats_cb(struct dp_soc *soc, void *cb_ctxt,
409 		union hal_reo_status *reo_status);
410 uint16_t dp_tx_me_send_convert_ucast(struct cdp_vdev *vdev_handle,
411 		qdf_nbuf_t nbuf, uint8_t newmac[][DP_MAC_ADDR_LEN],
412 		uint8_t new_mac_cnt);
413 void dp_tx_me_alloc_descriptor(struct cdp_pdev *pdev);
414 
415 void dp_tx_me_free_descriptor(struct cdp_pdev *pdev);
416 QDF_STATUS dp_h2t_ext_stats_msg_send(struct dp_pdev *pdev,
417 		uint32_t stats_type_upload_mask, uint32_t config_param_0,
418 		uint32_t config_param_1, uint32_t config_param_2,
419 		uint32_t config_param_3, int cookie, int cookie_msb,
420 		uint8_t mac_id);
421 void dp_htt_stats_print_tag(uint8_t tag_type, uint32_t *tag_buf);
422 void dp_htt_stats_copy_tag(struct dp_pdev *pdev, uint8_t tag_type, uint32_t *tag_buf);
423 void dp_peer_rxtid_stats(struct dp_peer *peer, void (*callback_fn),
424 		void *cb_ctxt);
425 void dp_set_pn_check_wifi3(struct cdp_vdev *vdev_handle,
426 	struct cdp_peer *peer_handle, enum cdp_sec_type sec_type,
427 	 uint32_t *rx_pn);
428 
429 void *dp_get_pdev_for_mac_id(struct dp_soc *soc, uint32_t mac_id);
430 void dp_mark_peer_inact(void *peer_handle, bool inactive);
431 bool dp_set_inact_params(struct cdp_pdev *pdev_handle,
432 		 u_int16_t inact_check_interval,
433 		 u_int16_t inact_normal, u_int16_t inact_overload);
434 bool dp_start_inact_timer(struct cdp_pdev *pdev_handle, bool enable);
435 void dp_set_overload(struct cdp_pdev *pdev_handle, bool overload);
436 bool dp_peer_is_inact(void *peer_handle);
437 void dp_init_inact_timer(struct dp_soc *soc);
438 void dp_free_inact_timer(struct dp_soc *soc);
439 void dp_set_michael_key(struct cdp_peer *peer_handle,
440 			bool is_unicast, uint32_t *key);
441 
442 /*
443  * dp_get_mac_id_for_pdev() -  Return mac corresponding to pdev for mac
444  *
445  * @mac_id: MAC id
446  * @pdev_id: pdev_id corresponding to pdev, 0 for MCL
447  *
448  * Single pdev using both MACs will operate on both MAC rings,
449  * which is the case for MCL.
450  * For WIN each PDEV will operate one ring, so index is zero.
451  *
452  */
453 static inline int dp_get_mac_id_for_pdev(uint32_t mac_id, uint32_t pdev_id)
454 {
455 	if (mac_id && pdev_id) {
456 		qdf_print("Both mac_id and pdev_id cannot be non zero");
457 		QDF_BUG(0);
458 		return 0;
459 	}
460 	return (mac_id + pdev_id);
461 }
462 
463 /*
464  * dp_get_mac_id_for_mac() -  Return mac corresponding WIN and MCL mac_ids
465  *
466  * @soc: handle to DP soc
467  * @mac_id: MAC id
468  *
469  * Single pdev using both MACs will operate on both MAC rings,
470  * which is the case for MCL.
471  * For WIN each PDEV will operate one ring, so index is zero.
472  *
473  */
474 static inline int dp_get_mac_id_for_mac(struct dp_soc *soc, uint32_t mac_id)
475 {
476 	/*
477 	 * Single pdev using both MACs will operate on both MAC rings,
478 	 * which is the case for MCL.
479 	 */
480 	if (!wlan_cfg_per_pdev_lmac_ring(soc->wlan_cfg_ctx))
481 		return mac_id;
482 
483 	/* For WIN each PDEV will operate one ring, so index is zero. */
484 	return 0;
485 }
486 
487 #ifdef WDI_EVENT_ENABLE
488 QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
489 				uint32_t stats_type_upload_mask,
490 				uint8_t mac_id);
491 
492 int dp_wdi_event_unsub(struct cdp_pdev *txrx_pdev_handle,
493 	void *event_cb_sub_handle,
494 	uint32_t event);
495 
496 int dp_wdi_event_sub(struct cdp_pdev *txrx_pdev_handle,
497 	void *event_cb_sub_handle,
498 	uint32_t event);
499 
500 void dp_wdi_event_handler(enum WDI_EVENT event, void *soc,
501 		void *data, u_int16_t peer_id,
502 		int status, u_int8_t pdev_id);
503 
504 int dp_wdi_event_attach(struct dp_pdev *txrx_pdev);
505 int dp_wdi_event_detach(struct dp_pdev *txrx_pdev);
506 int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
507 	bool enable);
508 void *dp_get_pldev(struct cdp_pdev *txrx_pdev);
509 void dp_pkt_log_init(struct cdp_pdev *ppdev, void *scn);
510 
511 static inline void dp_hif_update_pipe_callback(void *soc, void *cb_context,
512 	QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t), uint8_t pipe_id)
513 {
514 	struct hif_msg_callbacks hif_pipe_callbacks;
515 	struct dp_soc *dp_soc = (struct dp_soc *)soc;
516 
517 	/* TODO: Temporary change to bypass HTC connection for this new
518 	 * HIF pipe, which will be used for packet log and other high-
519 	 * priority HTT messages. Proper HTC connection to be added
520 	 * later once required FW changes are available
521 	 */
522 	hif_pipe_callbacks.rxCompletionHandler = callback;
523 	hif_pipe_callbacks.Context = cb_context;
524 	hif_update_pipe_callback(dp_soc->hif_handle,
525 		DP_HTT_T2H_HP_PIPE, &hif_pipe_callbacks);
526 }
527 
528 #else
529 static inline int dp_wdi_event_unsub(struct cdp_pdev *txrx_pdev_handle,
530 	void *event_cb_sub_handle,
531 	uint32_t event)
532 {
533 	return 0;
534 }
535 
536 static inline int dp_wdi_event_sub(struct cdp_pdev *txrx_pdev_handle,
537 	void *event_cb_sub_handle,
538 	uint32_t event)
539 {
540 	return 0;
541 }
542 
543 static inline void dp_wdi_event_handler(enum WDI_EVENT event, void *soc,
544 		void *data, u_int16_t peer_id,
545 		int status, u_int8_t pdev_id)
546 {
547 }
548 
549 static inline int dp_wdi_event_attach(struct dp_pdev *txrx_pdev)
550 {
551 	return 0;
552 }
553 
554 static inline int dp_wdi_event_detach(struct dp_pdev *txrx_pdev)
555 {
556 	return 0;
557 }
558 
559 static inline int dp_set_pktlog_wifi3(struct dp_pdev *pdev, uint32_t event,
560 	bool enable)
561 {
562 	return 0;
563 }
564 static inline QDF_STATUS dp_h2t_cfg_stats_msg_send(struct dp_pdev *pdev,
565 		uint32_t stats_type_upload_mask, uint8_t mac_id)
566 {
567 	return 0;
568 }
569 static inline void dp_hif_update_pipe_callback(void *soc, void *cb_context,
570 	QDF_STATUS (*callback)(void *, qdf_nbuf_t, uint8_t), uint8_t pipe_id)
571 {
572 }
573 #endif /* CONFIG_WIN */
574 #ifdef QCA_LL_TX_FLOW_CONTROL_V2
575 void dp_tx_dump_flow_pool_info(void *soc);
576 int dp_tx_delete_flow_pool(struct dp_soc *soc, struct dp_tx_desc_pool_s *pool,
577 	bool force);
578 #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */
579 #endif /* #ifndef _DP_INTERNAL_H_ */
580