xref: /wlan-driver/qca-wifi-host-cmn/dp/wifi3.0/monitor/1.0/dp_rx_mon_1.0.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for any
6*5113495bSYour Name  * purpose with or without fee is hereby granted, provided that the above
7*5113495bSYour Name  * copyright notice and this permission notice appear in all copies.
8*5113495bSYour Name  *
9*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*5113495bSYour Name  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*5113495bSYour Name  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*5113495bSYour Name  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*5113495bSYour Name  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*5113495bSYour Name  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*5113495bSYour Name  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*5113495bSYour Name  */
17*5113495bSYour Name #ifndef _DP_RX_MON_1_0_H_
18*5113495bSYour Name #define _DP_RX_MON_1_0_H_
19*5113495bSYour Name 
20*5113495bSYour Name #include <dp_rx.h>
21*5113495bSYour Name /*
22*5113495bSYour Name  * MON_BUF_MIN_ENTRIES macro defines minimum number of network buffers
23*5113495bSYour Name  * to be refilled in the RXDMA monitor buffer ring at init, remaining
24*5113495bSYour Name  * buffers are replenished at the time of monitor vap creation
25*5113495bSYour Name  */
26*5113495bSYour Name #define MON_BUF_MIN_ENTRIES 64
27*5113495bSYour Name 
28*5113495bSYour Name /*
29*5113495bSYour Name  * The below macro defines the maximum number of ring entries that would
30*5113495bSYour Name  * be processed in a single instance when processing each of the non-monitoring
31*5113495bSYour Name  * RXDMA2SW ring.
32*5113495bSYour Name  */
33*5113495bSYour Name #define MON_DROP_REAP_LIMIT 64
34*5113495bSYour Name 
35*5113495bSYour Name QDF_STATUS dp_rx_pdev_mon_status_buffers_alloc(struct dp_pdev *pdev,
36*5113495bSYour Name 					       uint32_t mac_id);
37*5113495bSYour Name QDF_STATUS dp_rx_pdev_mon_status_desc_pool_alloc(struct dp_pdev *pdev,
38*5113495bSYour Name 						 uint32_t mac_id);
39*5113495bSYour Name void dp_rx_pdev_mon_status_desc_pool_init(struct dp_pdev *pdev,
40*5113495bSYour Name 					  uint32_t mac_id);
41*5113495bSYour Name void dp_rx_pdev_mon_status_desc_pool_deinit(struct dp_pdev *pdev,
42*5113495bSYour Name 					    uint32_t mac_id);
43*5113495bSYour Name void dp_rx_pdev_mon_status_desc_pool_free(struct dp_pdev *pdev,
44*5113495bSYour Name 					  uint32_t mac_id);
45*5113495bSYour Name void dp_rx_pdev_mon_status_buffers_free(struct dp_pdev *pdev, uint32_t mac_id);
46*5113495bSYour Name 
47*5113495bSYour Name QDF_STATUS dp_rx_pdev_mon_desc_pool_alloc(struct dp_pdev *pdev);
48*5113495bSYour Name QDF_STATUS dp_rx_pdev_mon_buffers_alloc(struct dp_pdev *pdev);
49*5113495bSYour Name void dp_rx_pdev_mon_buffers_free(struct dp_pdev *pdev);
50*5113495bSYour Name void dp_rx_pdev_mon_desc_pool_init(struct dp_pdev *pdev);
51*5113495bSYour Name void dp_rx_pdev_mon_desc_pool_deinit(struct dp_pdev *pdev);
52*5113495bSYour Name void dp_rx_pdev_mon_desc_pool_free(struct dp_pdev *pdev);
53*5113495bSYour Name 
54*5113495bSYour Name /**
55*5113495bSYour Name  * dp_rx_mon_dest_process() - Brain of the Rx processing functionality
56*5113495bSYour Name  *	Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
57*5113495bSYour Name  * @soc: core txrx main context
58*5113495bSYour Name  * @int_ctx: interrupt context
59*5113495bSYour Name  * @mac_id: mac id
60*5113495bSYour Name  * @quota: No. of units (packets) that can be serviced in one shot.
61*5113495bSYour Name  *
62*5113495bSYour Name  * This function implements the core of Rx functionality. This is
63*5113495bSYour Name  * expected to handle only non-error frames.
64*5113495bSYour Name  *
65*5113495bSYour Name  * Return: none
66*5113495bSYour Name  */
67*5113495bSYour Name #ifdef QCA_MONITOR_PKT_SUPPORT
68*5113495bSYour Name void dp_rx_mon_dest_process(struct dp_soc *soc, struct dp_intr *int_ctx,
69*5113495bSYour Name 			    uint32_t mac_id, uint32_t quota);
70*5113495bSYour Name 
71*5113495bSYour Name void dp_rx_pdev_mon_buf_buffers_free(struct dp_pdev *pdev, uint32_t mac_id);
72*5113495bSYour Name QDF_STATUS
73*5113495bSYour Name dp_rx_pdev_mon_buf_buffers_alloc(struct dp_pdev *pdev, uint32_t mac_id,
74*5113495bSYour Name 				 bool delayed_replenish);
75*5113495bSYour Name QDF_STATUS
76*5113495bSYour Name dp_rx_pdev_mon_buf_desc_pool_alloc(struct dp_pdev *pdev, uint32_t mac_id);
77*5113495bSYour Name void
78*5113495bSYour Name dp_rx_pdev_mon_buf_desc_pool_init(struct dp_pdev *pdev, uint32_t mac_id);
79*5113495bSYour Name #else
80*5113495bSYour Name static inline
dp_rx_mon_dest_process(struct dp_soc * soc,struct dp_intr * int_ctx,uint32_t mac_id,uint32_t quota)81*5113495bSYour Name void dp_rx_mon_dest_process(struct dp_soc *soc, struct dp_intr *int_ctx,
82*5113495bSYour Name 			    uint32_t mac_id, uint32_t quota)
83*5113495bSYour Name {
84*5113495bSYour Name }
85*5113495bSYour Name 
86*5113495bSYour Name static inline
dp_rx_pdev_mon_buf_buffers_free(struct dp_pdev * pdev,uint32_t mac_id)87*5113495bSYour Name void dp_rx_pdev_mon_buf_buffers_free(struct dp_pdev *pdev, uint32_t mac_id)
88*5113495bSYour Name {
89*5113495bSYour Name }
90*5113495bSYour Name 
91*5113495bSYour Name static inline QDF_STATUS
dp_rx_pdev_mon_buf_buffers_alloc(struct dp_pdev * pdev,uint32_t mac_id,bool delayed_replenish)92*5113495bSYour Name dp_rx_pdev_mon_buf_buffers_alloc(struct dp_pdev *pdev, uint32_t mac_id,
93*5113495bSYour Name 				 bool delayed_replenish)
94*5113495bSYour Name {
95*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
96*5113495bSYour Name }
97*5113495bSYour Name 
98*5113495bSYour Name static inline QDF_STATUS
dp_rx_pdev_mon_buf_desc_pool_alloc(struct dp_pdev * pdev,uint32_t mac_id)99*5113495bSYour Name dp_rx_pdev_mon_buf_desc_pool_alloc(struct dp_pdev *pdev, uint32_t mac_id)
100*5113495bSYour Name {
101*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
102*5113495bSYour Name }
103*5113495bSYour Name 
104*5113495bSYour Name static inline void
dp_rx_pdev_mon_buf_desc_pool_init(struct dp_pdev * pdev,uint32_t mac_id)105*5113495bSYour Name dp_rx_pdev_mon_buf_desc_pool_init(struct dp_pdev *pdev, uint32_t mac_id)
106*5113495bSYour Name {
107*5113495bSYour Name }
108*5113495bSYour Name #endif
109*5113495bSYour Name 
110*5113495bSYour Name #if !defined(DISABLE_MON_CONFIG) && defined(MON_ENABLE_DROP_FOR_MAC)
111*5113495bSYour Name /**
112*5113495bSYour Name  * dp_mon_dest_srng_drop_for_mac() - Drop the mon dest ring packets for
113*5113495bSYour Name  *  a given mac
114*5113495bSYour Name  * @pdev: DP pdev
115*5113495bSYour Name  * @mac_id: mac id
116*5113495bSYour Name  * @force_flush: Force flush ring
117*5113495bSYour Name  *
118*5113495bSYour Name  * Return: None
119*5113495bSYour Name  */
120*5113495bSYour Name uint32_t
121*5113495bSYour Name dp_mon_dest_srng_drop_for_mac(struct dp_pdev *pdev, uint32_t mac_id,
122*5113495bSYour Name 			      bool force_flush);
123*5113495bSYour Name #else
124*5113495bSYour Name #ifdef QCA_SUPPORT_FULL_MON
125*5113495bSYour Name /**
126*5113495bSYour Name  * dp_mon_dest_srng_drop_for_mac() - Drop the mon dest ring packets for
127*5113495bSYour Name  *  a given mac
128*5113495bSYour Name  * @pdev: DP pdev
129*5113495bSYour Name  * @mac_id: mac id
130*5113495bSYour Name  *
131*5113495bSYour Name  * Return: None
132*5113495bSYour Name  */
133*5113495bSYour Name uint32_t
134*5113495bSYour Name dp_mon_dest_srng_drop_for_mac(struct dp_pdev *pdev, uint32_t mac_id);
135*5113495bSYour Name #endif
136*5113495bSYour Name #endif
137*5113495bSYour Name 
138*5113495bSYour Name /**
139*5113495bSYour Name  * dp_rxdma_err_process() - RxDMA error processing functionality
140*5113495bSYour Name  * @int_ctx: interrupt context
141*5113495bSYour Name  * @soc: core txrx main context
142*5113495bSYour Name  * @mac_id: mac id
143*5113495bSYour Name  * @quota: No. of units (packets) that can be serviced in one shot.
144*5113495bSYour Name  *
145*5113495bSYour Name  * Return: num of buffers processed
146*5113495bSYour Name  */
147*5113495bSYour Name uint32_t dp_rxdma_err_process(struct dp_intr *int_ctx, struct dp_soc *soc,
148*5113495bSYour Name 			      uint32_t mac_id, uint32_t quota);
149*5113495bSYour Name 
150*5113495bSYour Name /**
151*5113495bSYour Name  * dp_mon_buf_delayed_replenish() - Helper routine to replenish monitor dest buf
152*5113495bSYour Name  * @pdev: DP pdev object
153*5113495bSYour Name  *
154*5113495bSYour Name  * Return: None
155*5113495bSYour Name  */
156*5113495bSYour Name void dp_mon_buf_delayed_replenish(struct dp_pdev *pdev);
157*5113495bSYour Name 
158*5113495bSYour Name #ifdef QCA_MONITOR_PKT_SUPPORT
159*5113495bSYour Name /**
160*5113495bSYour Name  * dp_rx_mon_link_desc_return() - Return a MPDU link descriptor to HW
161*5113495bSYour Name  *			      (WBM), following error handling
162*5113495bSYour Name  *
163*5113495bSYour Name  * @dp_pdev: core txrx pdev context
164*5113495bSYour Name  * @buf_addr_info: void pointer to monitor link descriptor buf addr info
165*5113495bSYour Name  * @mac_id: mac id which is one of 3 mac_ids
166*5113495bSYour Name  *
167*5113495bSYour Name  * Return: QDF_STATUS
168*5113495bSYour Name  */
169*5113495bSYour Name QDF_STATUS
170*5113495bSYour Name dp_rx_mon_link_desc_return(struct dp_pdev *dp_pdev,
171*5113495bSYour Name 			   hal_buff_addrinfo_t buf_addr_info,
172*5113495bSYour Name 			   int mac_id);
173*5113495bSYour Name #else
174*5113495bSYour Name static inline QDF_STATUS
dp_rx_mon_link_desc_return(struct dp_pdev * dp_pdev,hal_buff_addrinfo_t buf_addr_info,int mac_id)175*5113495bSYour Name dp_rx_mon_link_desc_return(struct dp_pdev *dp_pdev,
176*5113495bSYour Name 			   hal_buff_addrinfo_t buf_addr_info,
177*5113495bSYour Name 			   int mac_id)
178*5113495bSYour Name {
179*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
180*5113495bSYour Name }
181*5113495bSYour Name #endif
182*5113495bSYour Name 
183*5113495bSYour Name #if defined(WLAN_MAX_PDEVS) && (WLAN_MAX_PDEVS == 1)
dp_rx_mon_get_rx_pkt_tlv_size(struct dp_soc * soc)184*5113495bSYour Name static inline uint16_t dp_rx_mon_get_rx_pkt_tlv_size(struct dp_soc *soc)
185*5113495bSYour Name {
186*5113495bSYour Name 	return soc->curr_rx_pkt_tlv_size;
187*5113495bSYour Name }
188*5113495bSYour Name #else
dp_rx_mon_get_rx_pkt_tlv_size(struct dp_soc * soc)189*5113495bSYour Name static inline uint16_t dp_rx_mon_get_rx_pkt_tlv_size(struct dp_soc *soc)
190*5113495bSYour Name {
191*5113495bSYour Name 	return soc->rx_mon_pkt_tlv_size;
192*5113495bSYour Name }
193*5113495bSYour Name #endif
194*5113495bSYour Name 
195*5113495bSYour Name /**
196*5113495bSYour Name  * dp_mon_adjust_frag_len() - MPDU and MSDU may spread across
197*5113495bSYour Name  *				multiple nbufs. This function
198*5113495bSYour Name  *                              is to return data length in
199*5113495bSYour Name  *				fragmented buffer
200*5113495bSYour Name  * @soc: Datapath soc handle
201*5113495bSYour Name  * @total_len: pointer to remaining data length.
202*5113495bSYour Name  * @frag_len: pointer to data length in this fragment.
203*5113495bSYour Name  * @l2_hdr_pad: l2 header padding
204*5113495bSYour Name  */
dp_mon_adjust_frag_len(struct dp_soc * soc,uint32_t * total_len,uint32_t * frag_len,uint16_t l2_hdr_pad)205*5113495bSYour Name static inline void dp_mon_adjust_frag_len(struct dp_soc *soc,
206*5113495bSYour Name 					  uint32_t *total_len,
207*5113495bSYour Name 					  uint32_t *frag_len,
208*5113495bSYour Name 					  uint16_t l2_hdr_pad)
209*5113495bSYour Name {
210*5113495bSYour Name 	uint32_t rx_pkt_tlv_len = soc->rx_mon_pkt_tlv_size;
211*5113495bSYour Name 
212*5113495bSYour Name 	if (*total_len >= (RX_MONITOR_BUFFER_SIZE - rx_pkt_tlv_len)) {
213*5113495bSYour Name 		*frag_len = RX_MONITOR_BUFFER_SIZE - rx_pkt_tlv_len -
214*5113495bSYour Name 					l2_hdr_pad;
215*5113495bSYour Name 		*total_len -= *frag_len;
216*5113495bSYour Name 	} else {
217*5113495bSYour Name 		*frag_len = *total_len;
218*5113495bSYour Name 		*total_len = 0;
219*5113495bSYour Name 	}
220*5113495bSYour Name }
221*5113495bSYour Name 
222*5113495bSYour Name /**
223*5113495bSYour Name  * dp_rx_mon_frag_adjust_frag_len() - MPDU and MSDU may spread across
224*5113495bSYour Name  * multiple nbufs. This function is to return data length in
225*5113495bSYour Name  * fragmented buffer.
226*5113495bSYour Name  * It takes input as max_limit for any buffer(as it changes based
227*5113495bSYour Name  * on decap type and buffer sequence in MSDU.
228*5113495bSYour Name  *
229*5113495bSYour Name  * If MSDU is divided into multiple buffer then below format will
230*5113495bSYour Name  * be max limit.
231*5113495bSYour Name  * Decap type Non-Raw
232*5113495bSYour Name  *--------------------------------
233*5113495bSYour Name  *|  1st  |  2nd  | ...  | Last   |
234*5113495bSYour Name  *| 1662  |  1664 | 1664 | <=1664 |
235*5113495bSYour Name  *--------------------------------
236*5113495bSYour Name  * Decap type Raw
237*5113495bSYour Name  *--------------------------------
238*5113495bSYour Name  *|  1st  |  2nd  | ...  | Last   |
239*5113495bSYour Name  *| 1664  |  1664 | 1664 | <=1664 |
240*5113495bSYour Name  *--------------------------------
241*5113495bSYour Name  *
242*5113495bSYour Name  * It also calculate if current buffer has placeholder to keep padding byte.
243*5113495bSYour Name  *  --------------------------------
244*5113495bSYour Name  * |       MAX LIMIT(1662/1664)     |
245*5113495bSYour Name  *  --------------------------------
246*5113495bSYour Name  * | Actual Data | Pad byte Pholder |
247*5113495bSYour Name  *  --------------------------------
248*5113495bSYour Name  *
249*5113495bSYour Name  * @total_len: Remaining data length.
250*5113495bSYour Name  * @frag_len:  Data length in this fragment.
251*5113495bSYour Name  * @max_limit: Max limit of current buffer/MSDU.
252*5113495bSYour Name  */
253*5113495bSYour Name #ifdef DP_RX_MON_MEM_FRAG
254*5113495bSYour Name static inline
dp_rx_mon_frag_adjust_frag_len(uint32_t * total_len,uint32_t * frag_len,uint32_t max_limit)255*5113495bSYour Name void dp_rx_mon_frag_adjust_frag_len(uint32_t *total_len, uint32_t *frag_len,
256*5113495bSYour Name 				    uint32_t max_limit)
257*5113495bSYour Name {
258*5113495bSYour Name 	if (*total_len >= max_limit) {
259*5113495bSYour Name 		*frag_len = max_limit;
260*5113495bSYour Name 		*total_len -= *frag_len;
261*5113495bSYour Name 	} else {
262*5113495bSYour Name 		*frag_len = *total_len;
263*5113495bSYour Name 		*total_len = 0;
264*5113495bSYour Name 	}
265*5113495bSYour Name }
266*5113495bSYour Name 
267*5113495bSYour Name /**
268*5113495bSYour Name  * DP_RX_MON_GET_NBUF_FROM_DESC() - Get nbuf from desc
269*5113495bSYour Name  * @rx_desc: RX descriptor
270*5113495bSYour Name  *
271*5113495bSYour Name  * Return: nbuf address
272*5113495bSYour Name  */
273*5113495bSYour Name #define DP_RX_MON_GET_NBUF_FROM_DESC(rx_desc) \
274*5113495bSYour Name 	NULL
275*5113495bSYour Name 
276*5113495bSYour Name /**
277*5113495bSYour Name  * dp_rx_mon_add_msdu_to_list_failure_handler() - Handler for nbuf buffer
278*5113495bSYour Name  *                                                  attach failure
279*5113495bSYour Name  *
280*5113495bSYour Name  * @rx_tlv_hdr: rx_tlv_hdr
281*5113495bSYour Name  * @pdev: struct dp_pdev *
282*5113495bSYour Name  * @last: skb pointing to last skb in chained list at any moment
283*5113495bSYour Name  * @head_msdu: parent skb in the chained list
284*5113495bSYour Name  * @tail_msdu: Last skb in the chained list
285*5113495bSYour Name  * @func_name: caller function name
286*5113495bSYour Name  *
287*5113495bSYour Name  * Return: void
288*5113495bSYour Name  */
289*5113495bSYour Name static inline void
dp_rx_mon_add_msdu_to_list_failure_handler(void * rx_tlv_hdr,struct dp_pdev * pdev,qdf_nbuf_t * last,qdf_nbuf_t * head_msdu,qdf_nbuf_t * tail_msdu,const char * func_name)290*5113495bSYour Name dp_rx_mon_add_msdu_to_list_failure_handler(void *rx_tlv_hdr,
291*5113495bSYour Name 					   struct dp_pdev *pdev,
292*5113495bSYour Name 					   qdf_nbuf_t *last,
293*5113495bSYour Name 					   qdf_nbuf_t *head_msdu,
294*5113495bSYour Name 					   qdf_nbuf_t *tail_msdu,
295*5113495bSYour Name 					   const char *func_name)
296*5113495bSYour Name {
297*5113495bSYour Name 	DP_STATS_INC(pdev, replenish.nbuf_alloc_fail, 1);
298*5113495bSYour Name 	qdf_frag_free(rx_tlv_hdr);
299*5113495bSYour Name 	if (head_msdu)
300*5113495bSYour Name 		qdf_nbuf_list_free(*head_msdu);
301*5113495bSYour Name 	dp_err("[%s] failed to allocate subsequent parent buffer to hold all frag",
302*5113495bSYour Name 	       func_name);
303*5113495bSYour Name 	if (head_msdu)
304*5113495bSYour Name 		*head_msdu = NULL;
305*5113495bSYour Name 	if (last)
306*5113495bSYour Name 		*last = NULL;
307*5113495bSYour Name 	if (tail_msdu)
308*5113495bSYour Name 		*tail_msdu = NULL;
309*5113495bSYour Name }
310*5113495bSYour Name 
311*5113495bSYour Name /**
312*5113495bSYour Name  * dp_rx_mon_get_paddr_from_desc() - Get paddr from desc
313*5113495bSYour Name  * @rx_desc: RX descriptor
314*5113495bSYour Name  *
315*5113495bSYour Name  * Return: Physical address of the buffer
316*5113495bSYour Name  */
317*5113495bSYour Name static inline
dp_rx_mon_get_paddr_from_desc(struct dp_rx_desc * rx_desc)318*5113495bSYour Name qdf_dma_addr_t dp_rx_mon_get_paddr_from_desc(struct dp_rx_desc *rx_desc)
319*5113495bSYour Name {
320*5113495bSYour Name 	return rx_desc->paddr_buf_start;
321*5113495bSYour Name }
322*5113495bSYour Name 
323*5113495bSYour Name /**
324*5113495bSYour Name  * DP_RX_MON_IS_BUFFER_ADDR_NULL() - Is Buffer received from hw is NULL
325*5113495bSYour Name  * @rx_desc: RX descriptor
326*5113495bSYour Name  *
327*5113495bSYour Name  * Return: true if the buffer is NULL, otherwise false
328*5113495bSYour Name  */
329*5113495bSYour Name #define DP_RX_MON_IS_BUFFER_ADDR_NULL(rx_desc) \
330*5113495bSYour Name 	(!(rx_desc->rx_buf_start))
331*5113495bSYour Name 
332*5113495bSYour Name #define DP_RX_MON_IS_MSDU_NOT_NULL(msdu) \
333*5113495bSYour Name 	true
334*5113495bSYour Name 
335*5113495bSYour Name /**
336*5113495bSYour Name  * dp_rx_mon_buffer_free() - Free nbuf or frag memory
337*5113495bSYour Name  * Free nbuf if feature is disabled, else free frag.
338*5113495bSYour Name  *
339*5113495bSYour Name  * @rx_desc: Rx desc
340*5113495bSYour Name  */
341*5113495bSYour Name static inline void
dp_rx_mon_buffer_free(struct dp_rx_desc * rx_desc)342*5113495bSYour Name dp_rx_mon_buffer_free(struct dp_rx_desc *rx_desc)
343*5113495bSYour Name {
344*5113495bSYour Name 	qdf_frag_free(rx_desc->rx_buf_start);
345*5113495bSYour Name }
346*5113495bSYour Name 
347*5113495bSYour Name /**
348*5113495bSYour Name  * dp_rx_mon_buffer_unmap() - Unmap nbuf or frag memory
349*5113495bSYour Name  * Unmap nbuf if feature is disabled, else unmap frag.
350*5113495bSYour Name  *
351*5113495bSYour Name  * @soc: struct dp_soc *
352*5113495bSYour Name  * @rx_desc: struct dp_rx_desc *
353*5113495bSYour Name  * @size: Size to be unmapped
354*5113495bSYour Name  */
355*5113495bSYour Name static inline void
dp_rx_mon_buffer_unmap(struct dp_soc * soc,struct dp_rx_desc * rx_desc,uint16_t size)356*5113495bSYour Name dp_rx_mon_buffer_unmap(struct dp_soc *soc, struct dp_rx_desc *rx_desc,
357*5113495bSYour Name 		       uint16_t size)
358*5113495bSYour Name {
359*5113495bSYour Name 	qdf_mem_unmap_page(soc->osdev, rx_desc->paddr_buf_start,
360*5113495bSYour Name 			   size, QDF_DMA_FROM_DEVICE);
361*5113495bSYour Name }
362*5113495bSYour Name 
363*5113495bSYour Name /**
364*5113495bSYour Name  * dp_rx_mon_alloc_parent_buffer() - Allocate parent buffer to hold
365*5113495bSYour Name  * radiotap header and accommodate all frag memory in nr_frag.
366*5113495bSYour Name  *
367*5113495bSYour Name  * @head_msdu: Ptr to hold allocated Msdu
368*5113495bSYour Name  *
369*5113495bSYour Name  * Return: QDF_STATUS
370*5113495bSYour Name  */
371*5113495bSYour Name static inline
dp_rx_mon_alloc_parent_buffer(qdf_nbuf_t * head_msdu)372*5113495bSYour Name QDF_STATUS dp_rx_mon_alloc_parent_buffer(qdf_nbuf_t *head_msdu)
373*5113495bSYour Name {
374*5113495bSYour Name 	/*
375*5113495bSYour Name 	 * Headroom should accommodate radiotap header
376*5113495bSYour Name 	 * and protocol and flow tag for all frag
377*5113495bSYour Name 	 * Length reserved to accommodate Radiotap header
378*5113495bSYour Name 	 * is 128 bytes and length reserved for Protocol
379*5113495bSYour Name 	 * flow tag will vary based on QDF_NBUF_MAX_FRAGS.
380*5113495bSYour Name 	 */
381*5113495bSYour Name 	/*  -------------------------------------------------
382*5113495bSYour Name 	 * |       Protocol & Flow TAG      | Radiotap header|
383*5113495bSYour Name 	 * |                                |  Length(128 B) |
384*5113495bSYour Name 	 * |  ((4* QDF_NBUF_MAX_FRAGS) * 2) |                |
385*5113495bSYour Name 	 *  -------------------------------------------------
386*5113495bSYour Name 	 */
387*5113495bSYour Name 
388*5113495bSYour Name 	*head_msdu = qdf_nbuf_alloc_no_recycler(DP_RX_MON_MAX_MONITOR_HEADER,
389*5113495bSYour Name 						DP_RX_MON_MAX_MONITOR_HEADER, 4);
390*5113495bSYour Name 
391*5113495bSYour Name 	if (!(*head_msdu))
392*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
393*5113495bSYour Name 
394*5113495bSYour Name 	qdf_mem_zero(qdf_nbuf_head(*head_msdu), qdf_nbuf_headroom(*head_msdu));
395*5113495bSYour Name 
396*5113495bSYour Name 	/* Set *head_msdu->next as NULL as all msdus are
397*5113495bSYour Name 	 * mapped via nr frags
398*5113495bSYour Name 	 */
399*5113495bSYour Name 	qdf_nbuf_set_next(*head_msdu, NULL);
400*5113495bSYour Name 
401*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
402*5113495bSYour Name }
403*5113495bSYour Name 
404*5113495bSYour Name /**
405*5113495bSYour Name  * dp_rx_mon_parse_desc_buffer() - Parse desc buffer based.
406*5113495bSYour Name  * @dp_soc:             struct dp_soc*
407*5113495bSYour Name  * @msdu_info:          struct hal_rx_msdu_desc_info*
408*5113495bSYour Name  * @is_frag_p:          is_frag *
409*5113495bSYour Name  * @total_frag_len_p:   Remaining frag len to be updated
410*5113495bSYour Name  * @frag_len_p:         frag len
411*5113495bSYour Name  * @l2_hdr_offset_p:    l2 hdr offset
412*5113495bSYour Name  * @rx_desc_tlv:        rx_desc_tlv
413*5113495bSYour Name  * @first_rx_desc_tlv:
414*5113495bSYour Name  * @is_frag_non_raw_p:  Non raw frag
415*5113495bSYour Name  * @data:               NBUF Data
416*5113495bSYour Name  *
417*5113495bSYour Name  * Below code will parse desc buffer, handle continuation frame,
418*5113495bSYour Name  * adjust frag length and update l2_hdr_padding
419*5113495bSYour Name  *
420*5113495bSYour Name  */
421*5113495bSYour Name static inline void
dp_rx_mon_parse_desc_buffer(struct dp_soc * dp_soc,struct hal_rx_msdu_desc_info * msdu_info,bool * is_frag_p,uint32_t * total_frag_len_p,uint32_t * frag_len_p,uint16_t * l2_hdr_offset_p,qdf_frag_t rx_desc_tlv,void ** first_rx_desc_tlv,bool * is_frag_non_raw_p,void * data)422*5113495bSYour Name dp_rx_mon_parse_desc_buffer(struct dp_soc *dp_soc,
423*5113495bSYour Name 			    struct hal_rx_msdu_desc_info *msdu_info,
424*5113495bSYour Name 			    bool *is_frag_p, uint32_t *total_frag_len_p,
425*5113495bSYour Name 			    uint32_t *frag_len_p, uint16_t *l2_hdr_offset_p,
426*5113495bSYour Name 			    qdf_frag_t rx_desc_tlv,
427*5113495bSYour Name 			    void **first_rx_desc_tlv,
428*5113495bSYour Name 			    bool *is_frag_non_raw_p, void *data)
429*5113495bSYour Name {
430*5113495bSYour Name 	struct hal_rx_mon_dest_buf_info frame_info;
431*5113495bSYour Name 	uint16_t tot_payload_len =
432*5113495bSYour Name 			RX_MONITOR_BUFFER_SIZE - dp_soc->rx_mon_pkt_tlv_size;
433*5113495bSYour Name 
434*5113495bSYour Name 	if (msdu_info->msdu_flags & HAL_MSDU_F_MSDU_CONTINUATION) {
435*5113495bSYour Name 		/* First buffer of MSDU */
436*5113495bSYour Name 		if (!(*is_frag_p)) {
437*5113495bSYour Name 			/* Set total frag_len from msdu_len */
438*5113495bSYour Name 			*total_frag_len_p = msdu_info->msdu_len;
439*5113495bSYour Name 
440*5113495bSYour Name 			*is_frag_p = true;
441*5113495bSYour Name 			if (HAL_HW_RX_DECAP_FORMAT_RAW ==
442*5113495bSYour Name 			    hal_rx_tlv_decap_format_get(dp_soc->hal_soc,
443*5113495bSYour Name 							rx_desc_tlv)) {
444*5113495bSYour Name 				*l2_hdr_offset_p =
445*5113495bSYour Name 					DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
446*5113495bSYour Name 				frame_info.is_decap_raw = 1;
447*5113495bSYour Name 			} else {
448*5113495bSYour Name 				*l2_hdr_offset_p =
449*5113495bSYour Name 					DP_RX_MON_NONRAW_L2_HDR_PAD_BYTE;
450*5113495bSYour Name 				frame_info.is_decap_raw = 0;
451*5113495bSYour Name 				*is_frag_non_raw_p = true;
452*5113495bSYour Name 			}
453*5113495bSYour Name 			dp_rx_mon_frag_adjust_frag_len(total_frag_len_p,
454*5113495bSYour Name 						       frag_len_p,
455*5113495bSYour Name 						       tot_payload_len -
456*5113495bSYour Name 						       *l2_hdr_offset_p);
457*5113495bSYour Name 
458*5113495bSYour Name 			frame_info.first_buffer = 1;
459*5113495bSYour Name 			frame_info.last_buffer = 0;
460*5113495bSYour Name 			hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
461*5113495bSYour Name 						    rx_desc_tlv,
462*5113495bSYour Name 						    (uint8_t *)&frame_info,
463*5113495bSYour Name 						    sizeof(frame_info));
464*5113495bSYour Name 		} else {
465*5113495bSYour Name 			/*
466*5113495bSYour Name 			 * Continuation Middle frame
467*5113495bSYour Name 			 * Here max limit will be same for Raw and Non raw case.
468*5113495bSYour Name 			 */
469*5113495bSYour Name 			*l2_hdr_offset_p = DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
470*5113495bSYour Name 			dp_rx_mon_frag_adjust_frag_len(total_frag_len_p,
471*5113495bSYour Name 						       frag_len_p,
472*5113495bSYour Name 						       tot_payload_len);
473*5113495bSYour Name 
474*5113495bSYour Name 			/* Update frame info if is non raw frame */
475*5113495bSYour Name 			if (*is_frag_non_raw_p)
476*5113495bSYour Name 				frame_info.is_decap_raw = 0;
477*5113495bSYour Name 			else
478*5113495bSYour Name 				frame_info.is_decap_raw = 1;
479*5113495bSYour Name 
480*5113495bSYour Name 			frame_info.first_buffer = 0;
481*5113495bSYour Name 			frame_info.last_buffer = 0;
482*5113495bSYour Name 			hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
483*5113495bSYour Name 						    rx_desc_tlv,
484*5113495bSYour Name 						    (uint8_t *)&frame_info,
485*5113495bSYour Name 						    sizeof(frame_info));
486*5113495bSYour Name 		}
487*5113495bSYour Name 	} else {
488*5113495bSYour Name 		/**
489*5113495bSYour Name 		 * Last buffer of MSDU spread among multiple buffer
490*5113495bSYour Name 		 * Here max limit will be same for Raw and Non raw case.
491*5113495bSYour Name 		 */
492*5113495bSYour Name 		if (*is_frag_p) {
493*5113495bSYour Name 			*l2_hdr_offset_p = DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
494*5113495bSYour Name 
495*5113495bSYour Name 			dp_rx_mon_frag_adjust_frag_len(total_frag_len_p,
496*5113495bSYour Name 						       frag_len_p,
497*5113495bSYour Name 						       tot_payload_len);
498*5113495bSYour Name 
499*5113495bSYour Name 			/* Update frame info if is non raw frame */
500*5113495bSYour Name 			if (*is_frag_non_raw_p)
501*5113495bSYour Name 				frame_info.is_decap_raw = 0;
502*5113495bSYour Name 			else
503*5113495bSYour Name 				frame_info.is_decap_raw = 1;
504*5113495bSYour Name 
505*5113495bSYour Name 			frame_info.first_buffer = 0;
506*5113495bSYour Name 			frame_info.last_buffer = 1;
507*5113495bSYour Name 			hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
508*5113495bSYour Name 						    rx_desc_tlv,
509*5113495bSYour Name 						    (uint8_t *)&frame_info,
510*5113495bSYour Name 						    sizeof(frame_info));
511*5113495bSYour Name 		} else {
512*5113495bSYour Name 			/* MSDU with single buffer */
513*5113495bSYour Name 			*frag_len_p = msdu_info->msdu_len;
514*5113495bSYour Name 			if (HAL_HW_RX_DECAP_FORMAT_RAW ==
515*5113495bSYour Name 			    hal_rx_tlv_decap_format_get(dp_soc->hal_soc,
516*5113495bSYour Name 							rx_desc_tlv)) {
517*5113495bSYour Name 				*l2_hdr_offset_p =
518*5113495bSYour Name 					DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
519*5113495bSYour Name 				frame_info.is_decap_raw = 1;
520*5113495bSYour Name 			} else {
521*5113495bSYour Name 				*l2_hdr_offset_p =
522*5113495bSYour Name 					DP_RX_MON_NONRAW_L2_HDR_PAD_BYTE;
523*5113495bSYour Name 				frame_info.is_decap_raw = 0;
524*5113495bSYour Name 			}
525*5113495bSYour Name 
526*5113495bSYour Name 			frame_info.first_buffer = 1;
527*5113495bSYour Name 			frame_info.last_buffer = 1;
528*5113495bSYour Name 			hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
529*5113495bSYour Name 						    rx_desc_tlv,
530*5113495bSYour Name 						    (uint8_t *)&frame_info,
531*5113495bSYour Name 						    sizeof(frame_info));
532*5113495bSYour Name 		}
533*5113495bSYour Name 		/* Reset bool after complete processing of MSDU */
534*5113495bSYour Name 		*is_frag_p = false;
535*5113495bSYour Name 		*is_frag_non_raw_p = false;
536*5113495bSYour Name 	}
537*5113495bSYour Name }
538*5113495bSYour Name 
539*5113495bSYour Name /**
540*5113495bSYour Name  * dp_rx_mon_buffer_set_pktlen() - set pktlen for buffer
541*5113495bSYour Name  * @msdu: MSDU
542*5113495bSYour Name  * @size: MSDU size
543*5113495bSYour Name  */
dp_rx_mon_buffer_set_pktlen(qdf_nbuf_t msdu,uint32_t size)544*5113495bSYour Name static inline void dp_rx_mon_buffer_set_pktlen(qdf_nbuf_t msdu, uint32_t size)
545*5113495bSYour Name {
546*5113495bSYour Name }
547*5113495bSYour Name 
548*5113495bSYour Name /**
549*5113495bSYour Name  * dp_rx_mon_add_msdu_to_list()- Add msdu to list and update head_msdu
550*5113495bSYour Name  *      It will add reaped buffer frag to nr frag of parent msdu.
551*5113495bSYour Name  * @soc: DP soc handle
552*5113495bSYour Name  * @head_msdu: NULL if first time called else &msdu
553*5113495bSYour Name  * @msdu: Msdu where frag address needs to be added via nr_frag
554*5113495bSYour Name  * @last: Used to traverse in list if this feature is disabled.
555*5113495bSYour Name  * @rx_desc_tlv: Frag address
556*5113495bSYour Name  * @frag_len: Frag len
557*5113495bSYour Name  * @l2_hdr_offset: l2 hdr padding
558*5113495bSYour Name  */
559*5113495bSYour Name static inline
dp_rx_mon_add_msdu_to_list(struct dp_soc * soc,qdf_nbuf_t * head_msdu,qdf_nbuf_t msdu,qdf_nbuf_t * last,qdf_frag_t rx_desc_tlv,uint32_t frag_len,uint32_t l2_hdr_offset)560*5113495bSYour Name QDF_STATUS dp_rx_mon_add_msdu_to_list(struct dp_soc *soc, qdf_nbuf_t *head_msdu,
561*5113495bSYour Name 				      qdf_nbuf_t msdu, qdf_nbuf_t *last,
562*5113495bSYour Name 				      qdf_frag_t rx_desc_tlv, uint32_t frag_len,
563*5113495bSYour Name 				      uint32_t l2_hdr_offset)
564*5113495bSYour Name {
565*5113495bSYour Name 	uint32_t num_frags;
566*5113495bSYour Name 	qdf_nbuf_t msdu_curr;
567*5113495bSYour Name 
568*5113495bSYour Name 	/* Here head_msdu and *head_msdu must not be NULL */
569*5113495bSYour Name 	/* Dont add frag to skb if frag length is zero. Drop frame */
570*5113495bSYour Name 	if (qdf_unlikely(!frag_len || !head_msdu || !(*head_msdu))) {
571*5113495bSYour Name 		dp_err("[%s] frag_len[%d] || head_msdu[%pK] || *head_msdu is Null while adding frag to skb",
572*5113495bSYour Name 		       __func__, frag_len, head_msdu);
573*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
574*5113495bSYour Name 	}
575*5113495bSYour Name 
576*5113495bSYour Name 	/* In case of first desc of MPDU, assign curr msdu to *head_msdu */
577*5113495bSYour Name 	if (!qdf_nbuf_get_nr_frags(*head_msdu))
578*5113495bSYour Name 		msdu_curr = *head_msdu;
579*5113495bSYour Name 	else
580*5113495bSYour Name 		msdu_curr = *last;
581*5113495bSYour Name 
582*5113495bSYour Name 	/* Current msdu must not be NULL */
583*5113495bSYour Name 	if (qdf_unlikely(!msdu_curr)) {
584*5113495bSYour Name 		dp_err("[%s] Current msdu can't be Null while adding frag to skb",
585*5113495bSYour Name 		       __func__);
586*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
587*5113495bSYour Name 	}
588*5113495bSYour Name 
589*5113495bSYour Name 	num_frags = qdf_nbuf_get_nr_frags(msdu_curr);
590*5113495bSYour Name 	if (num_frags < QDF_NBUF_MAX_FRAGS) {
591*5113495bSYour Name 		qdf_nbuf_add_rx_frag(rx_desc_tlv, msdu_curr,
592*5113495bSYour Name 				     soc->rx_mon_pkt_tlv_size,
593*5113495bSYour Name 				     frag_len + l2_hdr_offset,
594*5113495bSYour Name 				     RX_MONITOR_BUFFER_SIZE,
595*5113495bSYour Name 				     false);
596*5113495bSYour Name 		if (*last != msdu_curr)
597*5113495bSYour Name 			*last = msdu_curr;
598*5113495bSYour Name 		return QDF_STATUS_SUCCESS;
599*5113495bSYour Name 	}
600*5113495bSYour Name 
601*5113495bSYour Name 	/* Execution will reach here only if num_frags == QDF_NBUF_MAX_FRAGS */
602*5113495bSYour Name 	msdu_curr = NULL;
603*5113495bSYour Name 	if ((dp_rx_mon_alloc_parent_buffer(&msdu_curr))
604*5113495bSYour Name 	    != QDF_STATUS_SUCCESS)
605*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
606*5113495bSYour Name 
607*5113495bSYour Name 	qdf_nbuf_add_rx_frag(rx_desc_tlv, msdu_curr, soc->rx_mon_pkt_tlv_size,
608*5113495bSYour Name 			     frag_len + l2_hdr_offset, RX_MONITOR_BUFFER_SIZE,
609*5113495bSYour Name 			     false);
610*5113495bSYour Name 
611*5113495bSYour Name 	/* Add allocated nbuf in the chain */
612*5113495bSYour Name 	qdf_nbuf_set_next(*last, msdu_curr);
613*5113495bSYour Name 
614*5113495bSYour Name 	/* Assign current msdu to last to avoid traversal */
615*5113495bSYour Name 	*last = msdu_curr;
616*5113495bSYour Name 
617*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
618*5113495bSYour Name }
619*5113495bSYour Name 
620*5113495bSYour Name /**
621*5113495bSYour Name  * dp_rx_mon_init_tail_msdu() - Initialize tail msdu
622*5113495bSYour Name  *
623*5113495bSYour Name  * @head_msdu: Parent buffer to hold MPDU data
624*5113495bSYour Name  * @msdu: Msdu to be updated in tail_msdu
625*5113495bSYour Name  * @last: last msdu
626*5113495bSYour Name  * @tail_msdu: Last msdu
627*5113495bSYour Name  */
628*5113495bSYour Name static inline
dp_rx_mon_init_tail_msdu(qdf_nbuf_t * head_msdu,qdf_nbuf_t msdu,qdf_nbuf_t last,qdf_nbuf_t * tail_msdu)629*5113495bSYour Name void dp_rx_mon_init_tail_msdu(qdf_nbuf_t *head_msdu, qdf_nbuf_t msdu,
630*5113495bSYour Name 			      qdf_nbuf_t last, qdf_nbuf_t *tail_msdu)
631*5113495bSYour Name {
632*5113495bSYour Name 	if (!head_msdu || !(*head_msdu)) {
633*5113495bSYour Name 		*tail_msdu = NULL;
634*5113495bSYour Name 		return;
635*5113495bSYour Name 	}
636*5113495bSYour Name 
637*5113495bSYour Name 	if (last)
638*5113495bSYour Name 		qdf_nbuf_set_next(last, NULL);
639*5113495bSYour Name 	*tail_msdu = last;
640*5113495bSYour Name }
641*5113495bSYour Name 
642*5113495bSYour Name /**
643*5113495bSYour Name  * dp_rx_mon_remove_raw_frame_fcs_len() - Remove FCS length for Raw Frame
644*5113495bSYour Name  *
645*5113495bSYour Name  * If feature is disabled, then removal happens in restitch logic.
646*5113495bSYour Name  *
647*5113495bSYour Name  * @soc: Datapath soc handle
648*5113495bSYour Name  * @head_msdu: Head msdu
649*5113495bSYour Name  * @tail_msdu: Tail msdu
650*5113495bSYour Name  */
651*5113495bSYour Name static inline
dp_rx_mon_remove_raw_frame_fcs_len(struct dp_soc * soc,qdf_nbuf_t * head_msdu,qdf_nbuf_t * tail_msdu)652*5113495bSYour Name void dp_rx_mon_remove_raw_frame_fcs_len(struct dp_soc *soc,
653*5113495bSYour Name 					qdf_nbuf_t *head_msdu,
654*5113495bSYour Name 					qdf_nbuf_t *tail_msdu)
655*5113495bSYour Name {
656*5113495bSYour Name 	qdf_frag_t addr;
657*5113495bSYour Name 
658*5113495bSYour Name 	if (qdf_unlikely(!head_msdu || !tail_msdu || !(*head_msdu)))
659*5113495bSYour Name 		return;
660*5113495bSYour Name 
661*5113495bSYour Name 	/* If *head_msdu is valid, then *tail_msdu must be valid */
662*5113495bSYour Name 	/* If head_msdu is valid, then it must have nr_frags */
663*5113495bSYour Name 	/* If tail_msdu is valid, then it must have nr_frags */
664*5113495bSYour Name 
665*5113495bSYour Name 	/* Strip FCS_LEN for Raw frame */
666*5113495bSYour Name 	addr = qdf_nbuf_get_frag_addr(*head_msdu, 0);
667*5113495bSYour Name 	addr -= soc->rx_mon_pkt_tlv_size;
668*5113495bSYour Name 	if (hal_rx_tlv_decap_format_get(soc->hal_soc, addr) ==
669*5113495bSYour Name 		HAL_HW_RX_DECAP_FORMAT_RAW) {
670*5113495bSYour Name 		qdf_nbuf_trim_add_frag_size(*tail_msdu,
671*5113495bSYour Name 			qdf_nbuf_get_nr_frags(*tail_msdu) - 1,
672*5113495bSYour Name 					-HAL_RX_FCS_LEN, 0);
673*5113495bSYour Name 	}
674*5113495bSYour Name }
675*5113495bSYour Name 
676*5113495bSYour Name /**
677*5113495bSYour Name  * dp_rx_mon_get_buffer_data()- Get data from desc buffer
678*5113495bSYour Name  * @rx_desc: desc
679*5113495bSYour Name  *
680*5113495bSYour Name  * Return address containing actual tlv content
681*5113495bSYour Name  */
682*5113495bSYour Name static inline
dp_rx_mon_get_buffer_data(struct dp_rx_desc * rx_desc)683*5113495bSYour Name uint8_t *dp_rx_mon_get_buffer_data(struct dp_rx_desc *rx_desc)
684*5113495bSYour Name {
685*5113495bSYour Name 	return rx_desc->rx_buf_start;
686*5113495bSYour Name }
687*5113495bSYour Name 
688*5113495bSYour Name #else
689*5113495bSYour Name 
690*5113495bSYour Name #define DP_RX_MON_GET_NBUF_FROM_DESC(rx_desc) \
691*5113495bSYour Name 	(rx_desc->nbuf)
692*5113495bSYour Name 
693*5113495bSYour Name static inline void
dp_rx_mon_add_msdu_to_list_failure_handler(void * rx_tlv_hdr,struct dp_pdev * pdev,qdf_nbuf_t * last,qdf_nbuf_t * head_msdu,qdf_nbuf_t * tail_msdu,const char * func_name)694*5113495bSYour Name dp_rx_mon_add_msdu_to_list_failure_handler(void *rx_tlv_hdr,
695*5113495bSYour Name 					   struct dp_pdev *pdev,
696*5113495bSYour Name 					   qdf_nbuf_t *last,
697*5113495bSYour Name 					   qdf_nbuf_t *head_msdu,
698*5113495bSYour Name 					   qdf_nbuf_t *tail_msdu,
699*5113495bSYour Name 					   const char *func_name)
700*5113495bSYour Name {
701*5113495bSYour Name }
702*5113495bSYour Name 
703*5113495bSYour Name static inline
dp_rx_mon_get_paddr_from_desc(struct dp_rx_desc * rx_desc)704*5113495bSYour Name qdf_dma_addr_t dp_rx_mon_get_paddr_from_desc(struct dp_rx_desc *rx_desc)
705*5113495bSYour Name {
706*5113495bSYour Name 	qdf_dma_addr_t paddr = 0;
707*5113495bSYour Name 	qdf_nbuf_t msdu = NULL;
708*5113495bSYour Name 
709*5113495bSYour Name 	msdu = rx_desc->nbuf;
710*5113495bSYour Name 	if (msdu)
711*5113495bSYour Name 		paddr = qdf_nbuf_get_frag_paddr(msdu, 0);
712*5113495bSYour Name 
713*5113495bSYour Name 	return paddr;
714*5113495bSYour Name }
715*5113495bSYour Name 
716*5113495bSYour Name #define DP_RX_MON_IS_BUFFER_ADDR_NULL(rx_desc) \
717*5113495bSYour Name 	(!(rx_desc->nbuf))
718*5113495bSYour Name 
719*5113495bSYour Name #define DP_RX_MON_IS_MSDU_NOT_NULL(msdu) \
720*5113495bSYour Name 	(msdu)
721*5113495bSYour Name 
722*5113495bSYour Name static inline void
dp_rx_mon_buffer_free(struct dp_rx_desc * rx_desc)723*5113495bSYour Name dp_rx_mon_buffer_free(struct dp_rx_desc *rx_desc)
724*5113495bSYour Name {
725*5113495bSYour Name 	qdf_nbuf_free(rx_desc->nbuf);
726*5113495bSYour Name }
727*5113495bSYour Name 
728*5113495bSYour Name static inline void
dp_rx_mon_buffer_unmap(struct dp_soc * soc,struct dp_rx_desc * rx_desc,uint16_t size)729*5113495bSYour Name dp_rx_mon_buffer_unmap(struct dp_soc *soc, struct dp_rx_desc *rx_desc,
730*5113495bSYour Name 		       uint16_t size)
731*5113495bSYour Name {
732*5113495bSYour Name 	qdf_nbuf_unmap_nbytes_single(soc->osdev, rx_desc->nbuf,
733*5113495bSYour Name 				     QDF_DMA_FROM_DEVICE, size);
734*5113495bSYour Name }
735*5113495bSYour Name 
736*5113495bSYour Name static inline
dp_rx_mon_alloc_parent_buffer(qdf_nbuf_t * head_msdu)737*5113495bSYour Name QDF_STATUS dp_rx_mon_alloc_parent_buffer(qdf_nbuf_t *head_msdu)
738*5113495bSYour Name {
739*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
740*5113495bSYour Name }
741*5113495bSYour Name 
742*5113495bSYour Name #ifdef QCA_WIFI_MONITOR_MODE_NO_MSDU_START_TLV_SUPPORT
743*5113495bSYour Name 
744*5113495bSYour Name #define RXDMA_DATA_DMA_BLOCK_SIZE 128
745*5113495bSYour Name static inline void
dp_rx_mon_parse_desc_buffer(struct dp_soc * dp_soc,struct hal_rx_msdu_desc_info * msdu_info,bool * is_frag_p,uint32_t * total_frag_len_p,uint32_t * frag_len_p,uint16_t * l2_hdr_offset_p,qdf_frag_t rx_desc_tlv,void ** first_rx_desc_tlv,bool * is_frag_non_raw_p,void * data)746*5113495bSYour Name dp_rx_mon_parse_desc_buffer(struct dp_soc *dp_soc,
747*5113495bSYour Name 			    struct hal_rx_msdu_desc_info *msdu_info,
748*5113495bSYour Name 			    bool *is_frag_p, uint32_t *total_frag_len_p,
749*5113495bSYour Name 			    uint32_t *frag_len_p,
750*5113495bSYour Name 			    uint16_t *l2_hdr_offset_p,
751*5113495bSYour Name 			    qdf_frag_t rx_desc_tlv,
752*5113495bSYour Name 			    void **first_rx_desc_tlv,
753*5113495bSYour Name 			    bool *is_frag_non_raw_p, void *data)
754*5113495bSYour Name {
755*5113495bSYour Name 	struct hal_rx_mon_dest_buf_info frame_info;
756*5113495bSYour Name 	uint32_t rx_pkt_tlv_len = dp_rx_mon_get_rx_pkt_tlv_size(dp_soc);
757*5113495bSYour Name 
758*5113495bSYour Name 	/*
759*5113495bSYour Name 	 * HW structures call this L3 header padding
760*5113495bSYour Name 	 * -- even though this is actually the offset
761*5113495bSYour Name 	 * from the buffer beginning where the L2
762*5113495bSYour Name 	 * header begins.
763*5113495bSYour Name 	 */
764*5113495bSYour Name 	*l2_hdr_offset_p =
765*5113495bSYour Name 	hal_rx_msdu_end_l3_hdr_padding_get(dp_soc->hal_soc, data);
766*5113495bSYour Name 
767*5113495bSYour Name 	if (msdu_info->msdu_flags & HAL_MSDU_F_MSDU_CONTINUATION) {
768*5113495bSYour Name 		/*
769*5113495bSYour Name 		 * Set l3_hdr_pad for first frag. This can be later
770*5113495bSYour Name 		 * changed based on decap format, detected in last frag
771*5113495bSYour Name 		 */
772*5113495bSYour Name 		*l2_hdr_offset_p = DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
773*5113495bSYour Name 		if (!(*is_frag_p)) {
774*5113495bSYour Name 			*l2_hdr_offset_p = DP_RX_MON_RAW_L2_HDR_PAD_BYTE;
775*5113495bSYour Name 			*first_rx_desc_tlv = rx_desc_tlv;
776*5113495bSYour Name 		}
777*5113495bSYour Name 
778*5113495bSYour Name 		*is_frag_p = true;
779*5113495bSYour Name 		*frag_len_p = (RX_MONITOR_BUFFER_SIZE - rx_pkt_tlv_len -
780*5113495bSYour Name 			       *l2_hdr_offset_p) &
781*5113495bSYour Name 			      ~(RXDMA_DATA_DMA_BLOCK_SIZE - 1);
782*5113495bSYour Name 		*total_frag_len_p += *frag_len_p;
783*5113495bSYour Name 	} else {
784*5113495bSYour Name 		if (hal_rx_tlv_decap_format_get(dp_soc->hal_soc, rx_desc_tlv) ==
785*5113495bSYour Name 		    HAL_HW_RX_DECAP_FORMAT_RAW)
786*5113495bSYour Name 			frame_info.is_decap_raw = 1;
787*5113495bSYour Name 
788*5113495bSYour Name 		if (hal_rx_tlv_mpdu_len_err_get(dp_soc->hal_soc, rx_desc_tlv))
789*5113495bSYour Name 			frame_info.mpdu_len_err = 1;
790*5113495bSYour Name 
791*5113495bSYour Name 		frame_info.l2_hdr_pad = hal_rx_msdu_end_l3_hdr_padding_get(
792*5113495bSYour Name 						dp_soc->hal_soc, rx_desc_tlv);
793*5113495bSYour Name 
794*5113495bSYour Name 		if (*is_frag_p) {
795*5113495bSYour Name 			/* Last fragment of msdu */
796*5113495bSYour Name 			*frag_len_p = msdu_info->msdu_len - *total_frag_len_p;
797*5113495bSYour Name 
798*5113495bSYour Name 			/* Set this in the first frag priv data */
799*5113495bSYour Name 			hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
800*5113495bSYour Name 						    *first_rx_desc_tlv,
801*5113495bSYour Name 						    (uint8_t *)&frame_info,
802*5113495bSYour Name 						    sizeof(frame_info));
803*5113495bSYour Name 		} else {
804*5113495bSYour Name 			*frag_len_p = msdu_info->msdu_len;
805*5113495bSYour Name 			hal_rx_priv_info_set_in_tlv(dp_soc->hal_soc,
806*5113495bSYour Name 						    rx_desc_tlv,
807*5113495bSYour Name 						    (uint8_t *)&frame_info,
808*5113495bSYour Name 						    sizeof(frame_info));
809*5113495bSYour Name 		}
810*5113495bSYour Name 		*is_frag_p = false;
811*5113495bSYour Name 		*first_rx_desc_tlv = NULL;
812*5113495bSYour Name 	}
813*5113495bSYour Name }
814*5113495bSYour Name #else
815*5113495bSYour Name 
816*5113495bSYour Name static inline void
dp_rx_mon_parse_desc_buffer(struct dp_soc * dp_soc,struct hal_rx_msdu_desc_info * msdu_info,bool * is_frag_p,uint32_t * total_frag_len_p,uint32_t * frag_len_p,uint16_t * l2_hdr_offset_p,qdf_frag_t rx_desc_tlv,qdf_frag_t first_rx_desc_tlv,bool * is_frag_non_raw_p,void * data)817*5113495bSYour Name dp_rx_mon_parse_desc_buffer(struct dp_soc *dp_soc,
818*5113495bSYour Name 			    struct hal_rx_msdu_desc_info *msdu_info,
819*5113495bSYour Name 			    bool *is_frag_p, uint32_t *total_frag_len_p,
820*5113495bSYour Name 			    uint32_t *frag_len_p,
821*5113495bSYour Name 			    uint16_t *l2_hdr_offset_p,
822*5113495bSYour Name 			    qdf_frag_t rx_desc_tlv,
823*5113495bSYour Name 			    qdf_frag_t first_rx_desc_tlv,
824*5113495bSYour Name 			    bool *is_frag_non_raw_p, void *data)
825*5113495bSYour Name {
826*5113495bSYour Name 	/*
827*5113495bSYour Name 	 * HW structures call this L3 header padding
828*5113495bSYour Name 	 * -- even though this is actually the offset
829*5113495bSYour Name 	 * from the buffer beginning where the L2
830*5113495bSYour Name 	 * header begins.
831*5113495bSYour Name 	 */
832*5113495bSYour Name 	*l2_hdr_offset_p =
833*5113495bSYour Name 	hal_rx_msdu_end_l3_hdr_padding_get(dp_soc->hal_soc, data);
834*5113495bSYour Name 
835*5113495bSYour Name 	if (msdu_info->msdu_flags & HAL_MSDU_F_MSDU_CONTINUATION) {
836*5113495bSYour Name 		if (!*(is_frag_p)) {
837*5113495bSYour Name 			*total_frag_len_p = msdu_info->msdu_len;
838*5113495bSYour Name 			*is_frag_p = true;
839*5113495bSYour Name 		}
840*5113495bSYour Name 		dp_mon_adjust_frag_len(dp_soc, total_frag_len_p, frag_len_p,
841*5113495bSYour Name 				       *l2_hdr_offset_p);
842*5113495bSYour Name 	} else {
843*5113495bSYour Name 		if (*is_frag_p) {
844*5113495bSYour Name 			dp_mon_adjust_frag_len(dp_soc, total_frag_len_p,
845*5113495bSYour Name 					       frag_len_p,
846*5113495bSYour Name 					       *l2_hdr_offset_p);
847*5113495bSYour Name 		} else {
848*5113495bSYour Name 			*frag_len_p = msdu_info->msdu_len;
849*5113495bSYour Name 		}
850*5113495bSYour Name 		*is_frag_p = false;
851*5113495bSYour Name 	}
852*5113495bSYour Name }
853*5113495bSYour Name #endif
854*5113495bSYour Name 
dp_rx_mon_buffer_set_pktlen(qdf_nbuf_t msdu,uint32_t size)855*5113495bSYour Name static inline void dp_rx_mon_buffer_set_pktlen(qdf_nbuf_t msdu, uint32_t size)
856*5113495bSYour Name {
857*5113495bSYour Name 	qdf_nbuf_set_pktlen(msdu, size);
858*5113495bSYour Name }
859*5113495bSYour Name 
860*5113495bSYour Name static inline
dp_rx_mon_add_msdu_to_list(struct dp_soc * soc,qdf_nbuf_t * head_msdu,qdf_nbuf_t msdu,qdf_nbuf_t * last,qdf_frag_t rx_desc_tlv,uint32_t frag_len,uint32_t l2_hdr_offset)861*5113495bSYour Name QDF_STATUS dp_rx_mon_add_msdu_to_list(struct dp_soc *soc, qdf_nbuf_t *head_msdu,
862*5113495bSYour Name 				      qdf_nbuf_t msdu, qdf_nbuf_t *last,
863*5113495bSYour Name 				      qdf_frag_t rx_desc_tlv, uint32_t frag_len,
864*5113495bSYour Name 				      uint32_t l2_hdr_offset)
865*5113495bSYour Name {
866*5113495bSYour Name 	if (head_msdu && !*head_msdu) {
867*5113495bSYour Name 		*head_msdu = msdu;
868*5113495bSYour Name 	} else {
869*5113495bSYour Name 		if (*last)
870*5113495bSYour Name 			qdf_nbuf_set_next(*last, msdu);
871*5113495bSYour Name 	}
872*5113495bSYour Name 	*last = msdu;
873*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
874*5113495bSYour Name }
875*5113495bSYour Name 
876*5113495bSYour Name static inline
dp_rx_mon_init_tail_msdu(qdf_nbuf_t * head_msdu,qdf_nbuf_t msdu,qdf_nbuf_t last,qdf_nbuf_t * tail_msdu)877*5113495bSYour Name void dp_rx_mon_init_tail_msdu(qdf_nbuf_t *head_msdu, qdf_nbuf_t msdu,
878*5113495bSYour Name 			      qdf_nbuf_t last, qdf_nbuf_t *tail_msdu)
879*5113495bSYour Name {
880*5113495bSYour Name 	if (last)
881*5113495bSYour Name 		qdf_nbuf_set_next(last, NULL);
882*5113495bSYour Name 
883*5113495bSYour Name 	*tail_msdu = msdu;
884*5113495bSYour Name }
885*5113495bSYour Name 
886*5113495bSYour Name static inline
dp_rx_mon_remove_raw_frame_fcs_len(struct dp_soc * soc,qdf_nbuf_t * head_msdu,qdf_nbuf_t * tail_msdu)887*5113495bSYour Name void dp_rx_mon_remove_raw_frame_fcs_len(struct dp_soc *soc,
888*5113495bSYour Name 					qdf_nbuf_t *head_msdu,
889*5113495bSYour Name 					qdf_nbuf_t *tail_msdu)
890*5113495bSYour Name {
891*5113495bSYour Name }
892*5113495bSYour Name 
893*5113495bSYour Name static inline
dp_rx_mon_get_buffer_data(struct dp_rx_desc * rx_desc)894*5113495bSYour Name uint8_t *dp_rx_mon_get_buffer_data(struct dp_rx_desc *rx_desc)
895*5113495bSYour Name {
896*5113495bSYour Name 	qdf_nbuf_t msdu = NULL;
897*5113495bSYour Name 	uint8_t *data = NULL;
898*5113495bSYour Name 
899*5113495bSYour Name 	msdu = rx_desc->nbuf;
900*5113495bSYour Name 	if (qdf_likely(msdu))
901*5113495bSYour Name 		data = qdf_nbuf_data(msdu);
902*5113495bSYour Name 	return data;
903*5113495bSYour Name }
904*5113495bSYour Name 
905*5113495bSYour Name #endif
906*5113495bSYour Name 
907*5113495bSYour Name #ifndef WLAN_SOFTUMAC_SUPPORT
908*5113495bSYour Name /**
909*5113495bSYour Name  * dp_rx_cookie_2_mon_link_desc() - Retrieve Link descriptor based on target
910*5113495bSYour Name  * @pdev: core physical device context
911*5113495bSYour Name  * @buf_info: ptr to structure holding the buffer info
912*5113495bSYour Name  * @mac_id: mac number
913*5113495bSYour Name  *
914*5113495bSYour Name  * Return: link descriptor address
915*5113495bSYour Name  */
916*5113495bSYour Name static inline
dp_rx_cookie_2_mon_link_desc(struct dp_pdev * pdev,struct hal_buf_info * buf_info,uint8_t mac_id)917*5113495bSYour Name void *dp_rx_cookie_2_mon_link_desc(struct dp_pdev *pdev,
918*5113495bSYour Name 				   struct hal_buf_info *buf_info,
919*5113495bSYour Name 				   uint8_t mac_id)
920*5113495bSYour Name {
921*5113495bSYour Name 	if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
922*5113495bSYour Name 		return dp_rx_cookie_2_mon_link_desc_va(pdev, buf_info,
923*5113495bSYour Name 						       mac_id);
924*5113495bSYour Name 
925*5113495bSYour Name 	return dp_rx_cookie_2_link_desc_va(pdev->soc, buf_info);
926*5113495bSYour Name }
927*5113495bSYour Name 
928*5113495bSYour Name /**
929*5113495bSYour Name  * dp_rx_monitor_link_desc_return() - Return Link descriptor based on target
930*5113495bSYour Name  * @pdev: core physical device context
931*5113495bSYour Name  * @p_last_buf_addr_info: MPDU Link descriptor
932*5113495bSYour Name  * @mac_id: mac number
933*5113495bSYour Name  * @bm_action:
934*5113495bSYour Name  *
935*5113495bSYour Name  * Return: QDF_STATUS
936*5113495bSYour Name  */
937*5113495bSYour Name static inline
dp_rx_monitor_link_desc_return(struct dp_pdev * pdev,hal_buff_addrinfo_t p_last_buf_addr_info,uint8_t mac_id,uint8_t bm_action)938*5113495bSYour Name QDF_STATUS dp_rx_monitor_link_desc_return(struct dp_pdev *pdev,
939*5113495bSYour Name 					  hal_buff_addrinfo_t
940*5113495bSYour Name 					  p_last_buf_addr_info,
941*5113495bSYour Name 					  uint8_t mac_id, uint8_t bm_action)
942*5113495bSYour Name {
943*5113495bSYour Name 	if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
944*5113495bSYour Name 		return dp_rx_mon_link_desc_return(pdev, p_last_buf_addr_info,
945*5113495bSYour Name 						  mac_id);
946*5113495bSYour Name 
947*5113495bSYour Name 	return dp_rx_link_desc_return_by_addr(pdev->soc, p_last_buf_addr_info,
948*5113495bSYour Name 				      bm_action);
949*5113495bSYour Name }
950*5113495bSYour Name #else
951*5113495bSYour Name static inline
dp_rx_cookie_2_mon_link_desc(struct dp_pdev * pdev,struct hal_buf_info * buf_info,uint8_t mac_id)952*5113495bSYour Name void *dp_rx_cookie_2_mon_link_desc(struct dp_pdev *pdev,
953*5113495bSYour Name 				   struct hal_buf_info *buf_info,
954*5113495bSYour Name 				   uint8_t mac_id)
955*5113495bSYour Name {
956*5113495bSYour Name 	return dp_rx_cookie_2_mon_link_desc_va(pdev, buf_info, mac_id);
957*5113495bSYour Name }
958*5113495bSYour Name 
959*5113495bSYour Name static inline
dp_rx_monitor_link_desc_return(struct dp_pdev * pdev,hal_buff_addrinfo_t p_last_buf_addr_info,uint8_t mac_id,uint8_t bm_action)960*5113495bSYour Name QDF_STATUS dp_rx_monitor_link_desc_return(struct dp_pdev *pdev,
961*5113495bSYour Name 					  hal_buff_addrinfo_t
962*5113495bSYour Name 					  p_last_buf_addr_info,
963*5113495bSYour Name 					  uint8_t mac_id, uint8_t bm_action)
964*5113495bSYour Name {
965*5113495bSYour Name 	return dp_rx_mon_link_desc_return(pdev, p_last_buf_addr_info,
966*5113495bSYour Name 					  mac_id);
967*5113495bSYour Name }
968*5113495bSYour Name #endif
969*5113495bSYour Name 
dp_is_rxdma_dst_ring_common(struct dp_pdev * pdev)970*5113495bSYour Name static inline bool dp_is_rxdma_dst_ring_common(struct dp_pdev *pdev)
971*5113495bSYour Name {
972*5113495bSYour Name 	struct dp_soc *soc = pdev->soc;
973*5113495bSYour Name 
974*5113495bSYour Name 	return (soc->wlan_cfg_ctx->num_rxdma_dst_rings_per_pdev == 1);
975*5113495bSYour Name }
976*5113495bSYour Name 
977*5113495bSYour Name /**
978*5113495bSYour Name  * dp_rxdma_get_mon_dst_ring() - Return the pointer to rxdma_err_dst_ring
979*5113495bSYour Name  *					or mon_dst_ring based on the target
980*5113495bSYour Name  * @pdev: core physical device context
981*5113495bSYour Name  * @mac_for_pdev: mac_id number
982*5113495bSYour Name  *
983*5113495bSYour Name  * Return: ring address
984*5113495bSYour Name  */
985*5113495bSYour Name static inline
dp_rxdma_get_mon_dst_ring(struct dp_pdev * pdev,uint8_t mac_for_pdev)986*5113495bSYour Name void *dp_rxdma_get_mon_dst_ring(struct dp_pdev *pdev,
987*5113495bSYour Name 				uint8_t mac_for_pdev)
988*5113495bSYour Name {
989*5113495bSYour Name 	if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
990*5113495bSYour Name 		return pdev->soc->rxdma_mon_dst_ring[mac_for_pdev].hal_srng;
991*5113495bSYour Name 
992*5113495bSYour Name 	/* For targets with 1 RXDMA DST ring for both mac */
993*5113495bSYour Name 	if (dp_is_rxdma_dst_ring_common(pdev))
994*5113495bSYour Name 		return pdev->soc->rxdma_err_dst_ring[0].hal_srng;
995*5113495bSYour Name 
996*5113495bSYour Name 	return pdev->soc->rxdma_err_dst_ring[mac_for_pdev].hal_srng;
997*5113495bSYour Name }
998*5113495bSYour Name 
999*5113495bSYour Name /**
1000*5113495bSYour Name  * dp_rxdma_get_mon_buf_ring() - Return monitor buf ring address
1001*5113495bSYour Name  *				    based on target
1002*5113495bSYour Name  * @pdev: core physical device context
1003*5113495bSYour Name  * @mac_for_pdev: mac id number
1004*5113495bSYour Name  *
1005*5113495bSYour Name  * Return: ring address
1006*5113495bSYour Name  */
1007*5113495bSYour Name static inline
dp_rxdma_get_mon_buf_ring(struct dp_pdev * pdev,uint8_t mac_for_pdev)1008*5113495bSYour Name struct dp_srng *dp_rxdma_get_mon_buf_ring(struct dp_pdev *pdev,
1009*5113495bSYour Name 					  uint8_t mac_for_pdev)
1010*5113495bSYour Name {
1011*5113495bSYour Name 	if (pdev->soc->wlan_cfg_ctx->rxdma1_enable)
1012*5113495bSYour Name 		return &pdev->soc->rxdma_mon_buf_ring[mac_for_pdev];
1013*5113495bSYour Name 
1014*5113495bSYour Name 	/* For MCL there is only 1 rx refill ring */
1015*5113495bSYour Name 	return &pdev->soc->rx_refill_buf_ring[0];
1016*5113495bSYour Name }
1017*5113495bSYour Name 
1018*5113495bSYour Name /**
1019*5113495bSYour Name  * dp_rx_get_mon_desc() - Return Rx descriptor based on target
1020*5113495bSYour Name  * @soc: soc handle
1021*5113495bSYour Name  * @cookie: cookie value
1022*5113495bSYour Name  *
1023*5113495bSYour Name  * Return: Rx descriptor
1024*5113495bSYour Name  */
1025*5113495bSYour Name static inline
dp_rx_get_mon_desc(struct dp_soc * soc,uint32_t cookie)1026*5113495bSYour Name struct dp_rx_desc *dp_rx_get_mon_desc(struct dp_soc *soc,
1027*5113495bSYour Name 				      uint32_t cookie)
1028*5113495bSYour Name {
1029*5113495bSYour Name 	if (soc->wlan_cfg_ctx->rxdma1_enable)
1030*5113495bSYour Name 		return dp_rx_cookie_2_va_mon_buf(soc, cookie);
1031*5113495bSYour Name 
1032*5113495bSYour Name 	return soc->arch_ops.dp_rx_desc_cookie_2_va(soc, cookie);
1033*5113495bSYour Name }
1034*5113495bSYour Name 
1035*5113495bSYour Name #ifdef QCA_MONITOR_PKT_SUPPORT
1036*5113495bSYour Name /*
1037*5113495bSYour Name  * dp_mon_htt_dest_srng_setup(): monitor dest srng setup
1038*5113495bSYour Name  * @soc: DP SOC handle
1039*5113495bSYour Name  * @pdev: DP PDEV handle
1040*5113495bSYour Name  * @mac_id: MAC ID
1041*5113495bSYour Name  * @mac_for_pdev: PDEV mac
1042*5113495bSYour Name  *
1043*5113495bSYour Name  * Return: status: QDF_STATUS_SUCCESS - Success, non-zero: Failure
1044*5113495bSYour Name  */
1045*5113495bSYour Name QDF_STATUS dp_mon_htt_dest_srng_setup(struct dp_soc *soc,
1046*5113495bSYour Name 				      struct dp_pdev *pdev,
1047*5113495bSYour Name 				      int mac_id,
1048*5113495bSYour Name 				      int mac_for_pdev);
1049*5113495bSYour Name 
1050*5113495bSYour Name /*
1051*5113495bSYour Name  * dp_mon_dest_rings_deinit(): deinit monitor dest rings
1052*5113495bSYour Name  * @pdev: DP PDEV handle
1053*5113495bSYour Name  * @lmac_id: MAC ID
1054*5113495bSYour Name  *
1055*5113495bSYour Name  * Return: status: None
1056*5113495bSYour Name  */
1057*5113495bSYour Name void dp_mon_dest_rings_deinit(struct dp_pdev *pdev, int lmac_id);
1058*5113495bSYour Name 
1059*5113495bSYour Name /*
1060*5113495bSYour Name  * dp_mon_dest_rings_free(): free monitor dest rings
1061*5113495bSYour Name  * @pdev: DP PDEV handle
1062*5113495bSYour Name  * @lmac_id: MAC ID
1063*5113495bSYour Name  *
1064*5113495bSYour Name  * Return: status: None
1065*5113495bSYour Name  */
1066*5113495bSYour Name void dp_mon_dest_rings_free(struct dp_pdev *pdev, int lmac_id);
1067*5113495bSYour Name 
1068*5113495bSYour Name /*
1069*5113495bSYour Name  * dp_mon_dest_rings_init(): init monitor dest rings
1070*5113495bSYour Name  * @pdev: DP PDEV handle
1071*5113495bSYour Name  * @lmac_id: MAC ID
1072*5113495bSYour Name  *
1073*5113495bSYour Name  * Return: status: QDF_STATUS_SUCCESS - Success, non-zero: Failure
1074*5113495bSYour Name  */
1075*5113495bSYour Name QDF_STATUS dp_mon_dest_rings_init(struct dp_pdev *pdev, int lmac_id);
1076*5113495bSYour Name 
1077*5113495bSYour Name /*
1078*5113495bSYour Name  * dp_mon_dest_rings_allocate(): allocate monitor dest rings
1079*5113495bSYour Name  * @pdev: DP PDEV handle
1080*5113495bSYour Name  * @lmac_id: MAC ID
1081*5113495bSYour Name  *
1082*5113495bSYour Name  * Return: status: QDF_STATUS_SUCCESS - Success, non-zero: Failure
1083*5113495bSYour Name  */
1084*5113495bSYour Name QDF_STATUS dp_mon_dest_rings_alloc(struct dp_pdev *pdev, int lmac_id);
1085*5113495bSYour Name 
1086*5113495bSYour Name #else
dp_mon_htt_dest_srng_setup(struct dp_soc * soc,struct dp_pdev * pdev,int mac_id,int mac_for_pdev)1087*5113495bSYour Name QDF_STATUS dp_mon_htt_dest_srng_setup(struct dp_soc *soc,
1088*5113495bSYour Name 				      struct dp_pdev *pdev,
1089*5113495bSYour Name 				      int mac_id,
1090*5113495bSYour Name 				      int mac_for_pdev)
1091*5113495bSYour Name {
1092*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1093*5113495bSYour Name }
1094*5113495bSYour Name 
dp_mon_dest_rings_deinit(struct dp_pdev * pdev,int lmac_id)1095*5113495bSYour Name static void dp_mon_dest_rings_deinit(struct dp_pdev *pdev, int lmac_id)
1096*5113495bSYour Name {
1097*5113495bSYour Name }
1098*5113495bSYour Name 
dp_mon_dest_rings_free(struct dp_pdev * pdev,int lmac_id)1099*5113495bSYour Name static void dp_mon_dest_rings_free(struct dp_pdev *pdev, int lmac_id)
1100*5113495bSYour Name {
1101*5113495bSYour Name }
1102*5113495bSYour Name 
1103*5113495bSYour Name static
dp_mon_dest_rings_init(struct dp_pdev * pdev,int lmac_id)1104*5113495bSYour Name QDF_STATUS dp_mon_dest_rings_init(struct dp_pdev *pdev, int lmac_id)
1105*5113495bSYour Name {
1106*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1107*5113495bSYour Name }
1108*5113495bSYour Name 
1109*5113495bSYour Name static
dp_mon_dest_rings_alloc(struct dp_pdev * pdev,int lmac_id)1110*5113495bSYour Name QDF_STATUS dp_mon_dest_rings_alloc(struct dp_pdev *pdev, int lmac_id)
1111*5113495bSYour Name {
1112*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
1113*5113495bSYour Name }
1114*5113495bSYour Name #endif /* QCA_MONITOR_PKT_SUPPORT */
1115*5113495bSYour Name 
1116*5113495bSYour Name #endif /* _DP_RX_MON_1_0_H_ */
1117