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