blob: d8b733d03bacef893180994faf711794e42c3cde [file] [log] [blame]
Kai Chen6eca1a62017-01-12 10:17:53 -08001/*
phadimanebf4cde2019-01-28 17:50:37 +05302 * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved.
Kai Chen6eca1a62017-01-12 10:17:53 -08003 *
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 */
Balamurugan Mahalingamd0159642018-07-11 15:02:29 +053018#include "hal_hw_headers.h"
Kai Chen6eca1a62017-01-12 10:17:53 -080019#include "dp_types.h"
20#include "dp_rx.h"
21#include "dp_peer.h"
22#include "hal_rx.h"
23#include "hal_api.h"
24#include "qdf_trace.h"
25#include "qdf_nbuf.h"
26#include "hal_api_mon.h"
Kai Chen6eca1a62017-01-12 10:17:53 -080027#include "dp_rx_mon.h"
Keyur Parekhfad6d082017-05-07 08:54:47 -070028#include "dp_internal.h"
29#include "qdf_mem.h" /* qdf_mem_malloc,free */
Kai Chen6eca1a62017-01-12 10:17:53 -080030
ydb247452018-08-08 00:23:16 +053031#ifdef FEATURE_PERPKT_INFO
32#include "dp_ratetable.h"
33#endif
34
Kai Chen52ef33f2019-03-05 18:33:40 -080035#ifdef WLAN_RX_PKT_CAPTURE_ENH
36#include "dp_rx_mon_feature.h"
37#else
38static QDF_STATUS
39dp_rx_handle_enh_capture(struct dp_soc *soc, struct dp_pdev *pdev,
40 struct hal_rx_ppdu_info *ppdu_info)
41{
42 return QDF_STATUS_SUCCESS;
43}
44
45static void
46dp_rx_mon_enh_capture_process(struct dp_pdev *pdev, uint32_t tlv_status,
47 qdf_nbuf_t status_nbuf,
48 struct hal_rx_ppdu_info *ppdu_info,
Karunakar Dasineniacc8b562019-05-07 07:00:24 -070049 bool *nbuf_used)
Kai Chen52ef33f2019-03-05 18:33:40 -080050{
51}
52#endif
53
Amir Patel1d4ac982019-04-25 11:49:01 +053054#ifdef FEATURE_PERPKT_INFO
55static inline void
56dp_rx_populate_rx_rssi_chain(struct hal_rx_ppdu_info *ppdu_info,
57 struct cdp_rx_indication_ppdu *cdp_rx_ppdu)
58{
59 uint8_t chain, bw;
60 int8_t rssi;
61
62 for (chain = 0; chain < SS_COUNT; chain++) {
63 for (bw = 0; bw < MAX_BW; bw++) {
64 rssi = ppdu_info->rx_status.rssi_chain[chain][bw];
65 if (rssi != DP_RSSI_INVAL)
66 cdp_rx_ppdu->rssi_chain[chain][bw] = rssi;
67 else
68 cdp_rx_ppdu->rssi_chain[chain][bw] = 0;
69 }
70 }
71}
72
Kai Chen6eca1a62017-01-12 10:17:53 -080073/**
Anish Nataraj38a29562017-08-18 19:41:17 +053074* dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
Soumya Bhat560f90c2018-03-30 13:53:26 +053075* @pdev: pdev ctx
Anish Nataraj38a29562017-08-18 19:41:17 +053076* @ppdu_info: ppdu info structure from ppdu ring
77* @ppdu_nbuf: qdf nbuf abstraction for linux skb
78*
79* Return: none
80*/
Anish Nataraj38a29562017-08-18 19:41:17 +053081static inline void
Soumya Bhat560f90c2018-03-30 13:53:26 +053082dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
Anish Nataraj38a29562017-08-18 19:41:17 +053083 struct hal_rx_ppdu_info *ppdu_info,
84 qdf_nbuf_t ppdu_nbuf)
85{
86 struct dp_peer *peer;
Soumya Bhat560f90c2018-03-30 13:53:26 +053087 struct dp_soc *soc = pdev->soc;
Anish Nataraj38a29562017-08-18 19:41:17 +053088 struct dp_ast_entry *ast_entry;
89 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
90 uint32_t ast_index;
91
92 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
93
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +053094 cdp_rx_ppdu->first_data_seq_ctrl =
95 ppdu_info->rx_status.first_data_seq_ctrl;
Anish Natarajeb30aa72018-09-20 16:34:01 +053096 cdp_rx_ppdu->frame_ctrl =
97 ppdu_info->rx_status.frame_control;
Anish Nataraj38a29562017-08-18 19:41:17 +053098 cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
nobelj9ab76e22018-02-13 18:10:54 -080099 cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
Anish Nataraj38a29562017-08-18 19:41:17 +0530100 cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
101 cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530102 cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
103 cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
104 cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
Anish Nataraj38a29562017-08-18 19:41:17 +0530105 cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
106 cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
Keyur Parekh49cdc742018-05-09 10:59:03 -0700107 if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
108 (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
109 cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
110 else
111 cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
Anish Nataraj50347012018-03-06 21:12:45 +0530112 cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
Anish Nataraj38a29562017-08-18 19:41:17 +0530113 cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
Anish Nataraj28490c42018-01-19 19:34:54 +0530114 cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
Pamidipati, Vijayba4b57f2019-02-13 16:47:23 +0530115 cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >>
116 QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3;
117 cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
Anish Nataraj38a29562017-08-18 19:41:17 +0530118 cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
Anish Nataraj57614da2018-02-07 23:04:24 +0530119 cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
120 cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
nobeljd8039592018-03-13 16:59:42 -0700121 cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530122 cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
123 cdp_rx_ppdu->udp_msdu_count +
124 cdp_rx_ppdu->other_msdu_count);
Amir Patel468bded2019-03-21 11:42:31 +0530125 cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len;
Amir Patelac7d9462019-03-28 16:16:01 +0530126 cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ?
127 ppdu_info->com_info.mpdu_cnt_fcs_ok : 0;
Pranita Solankeed0aba62018-01-12 19:14:31 +0530128
129 if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
130 cdp_rx_ppdu->is_ampdu = 1;
131 else
132 cdp_rx_ppdu->is_ampdu = 0;
Anish Nataraj45d282c2017-12-30 01:03:38 +0530133
134 cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
Anish Nataraj57614da2018-02-07 23:04:24 +0530135 cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
Soumya Bhat560f90c2018-03-30 13:53:26 +0530136
137 ast_index = ppdu_info->rx_status.ast_index;
Tallapragada Kalyana7023622018-12-03 19:29:52 +0530138 if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) {
Soumya Bhat560f90c2018-03-30 13:53:26 +0530139 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
140 return;
141 }
142
143 ast_entry = soc->ast_table[ast_index];
144 if (!ast_entry) {
145 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
146 return;
147 }
148 peer = ast_entry->peer;
149 if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
150 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
151 return;
152 }
153
154 qdf_mem_copy(cdp_rx_ppdu->mac_addr,
Srinivas Girigowda2751b6d2019-02-27 12:28:13 -0800155 peer->mac_addr.raw, QDF_MAC_ADDR_SIZE);
Soumya Bhat560f90c2018-03-30 13:53:26 +0530156 cdp_rx_ppdu->peer_id = peer->peer_ids[0];
157 cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
Keyur Parekh44d8f8f2019-03-12 12:39:41 -0700158 cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size;
Amir Patel1d4ac982019-04-25 11:49:01 +0530159
160 dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu);
Anish Nataraj38a29562017-08-18 19:41:17 +0530161}
162#else
163static inline void
Soumya Bhat560f90c2018-03-30 13:53:26 +0530164dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
Anish Nataraj38a29562017-08-18 19:41:17 +0530165 struct hal_rx_ppdu_info *ppdu_info,
166 qdf_nbuf_t ppdu_nbuf)
167{
168}
169#endif
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530170/**
171 * dp_rx_stats_update() - Update per-peer statistics
172 * @soc: Datapath SOC handle
173 * @peer: Datapath peer handle
174 * @ppdu: PPDU Descriptor
175 *
176 * Return: None
177 */
178#ifdef FEATURE_PERPKT_INFO
ydb247452018-08-08 00:23:16 +0530179static inline void dp_rx_rate_stats_update(struct dp_peer *peer,
180 struct cdp_rx_indication_ppdu *ppdu)
181{
182 uint32_t ratekbps = 0;
183 uint32_t ppdu_rx_rate = 0;
184 uint32_t nss = 0;
Amir Patel78824b12019-02-23 10:54:32 +0530185 uint32_t rix;
ydb247452018-08-08 00:23:16 +0530186
187 if (!peer || !ppdu)
188 return;
189
190 if (ppdu->u.nss == 0)
191 nss = 0;
192 else
193 nss = ppdu->u.nss - 1;
194
Anish Nataraj376d9b12018-08-13 14:12:01 +0530195 ratekbps = dp_getrateindex(ppdu->u.gi,
196 ppdu->u.mcs,
ydb247452018-08-08 00:23:16 +0530197 nss,
198 ppdu->u.preamble,
Amir Patel78824b12019-02-23 10:54:32 +0530199 ppdu->u.bw,
200 &rix);
ydb247452018-08-08 00:23:16 +0530201
202 if (!ratekbps)
203 return;
204
Amir Patel468bded2019-03-21 11:42:31 +0530205 ppdu->rix = rix;
ydb247452018-08-08 00:23:16 +0530206 DP_STATS_UPD(peer, rx.last_rx_rate, ratekbps);
207 dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps);
208 ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate);
209 DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate);
Amir Patelac7d9462019-03-28 16:16:01 +0530210 ppdu->rx_ratekbps = ratekbps;
ydb247452018-08-08 00:23:16 +0530211
212 if (peer->vdev)
213 peer->vdev->stats.rx.last_rx_rate = ratekbps;
214}
215
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530216static void dp_rx_stats_update(struct dp_pdev *pdev, struct dp_peer *peer,
217 struct cdp_rx_indication_ppdu *ppdu)
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530218{
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530219 struct dp_soc *soc = NULL;
Anish Nataraj28490c42018-01-19 19:34:54 +0530220 uint8_t mcs, preamble, ac = 0;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530221 uint16_t num_msdu;
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530222 bool is_invalid_peer = false;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530223
224 mcs = ppdu->u.mcs;
225 preamble = ppdu->u.preamble;
226 num_msdu = ppdu->num_msdu;
227
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530228 if (pdev)
229 soc = pdev->soc;
230 else
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530231 return;
232
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530233 if (!peer) {
234 is_invalid_peer = true;
235 peer = pdev->invalid_peer;
236 }
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530237
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530238 if (!soc || soc->process_rx_status)
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530239 return;
Pranita Solankefc2ff392017-12-15 19:25:13 +0530240
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530241 DP_STATS_UPD(peer, rx.rssi, ppdu->rssi);
Surya Prakash07c81e72019-04-29 10:08:01 +0530242 if (peer->stats.rx.avg_rssi == INVALID_RSSI)
Amir Patelbb69cfa2019-03-28 16:16:01 +0530243 peer->stats.rx.avg_rssi = ppdu->rssi;
244 else
245 peer->stats.rx.avg_rssi =
246 DP_GET_AVG_RSSI(peer->stats.rx.avg_rssi, ppdu->rssi);
Pranita Solankeed0aba62018-01-12 19:14:31 +0530247
248 if ((preamble == DOT11_A) || (preamble == DOT11_B))
249 ppdu->u.nss = 1;
250
251 if (ppdu->u.nss)
252 DP_STATS_INC(peer, rx.nss[ppdu->u.nss - 1], num_msdu);
253
Pranita Solankea12b4b32017-11-20 23:04:14 +0530254 DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530255 DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
Anish Nataraj28490c42018-01-19 19:34:54 +0530256 DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type], num_msdu);
Pranita Solankea12b4b32017-11-20 23:04:14 +0530257 DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu, ppdu->is_ampdu);
258 DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu));
259 DP_STATS_UPD(peer, rx.rx_rate, mcs);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530260 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530261 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530262 ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
263 DP_STATS_INCC(peer,
264 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530265 ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530266 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530267 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530268 ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
269 DP_STATS_INCC(peer,
270 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530271 ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530272 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530273 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530274 ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
275 DP_STATS_INCC(peer,
276 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530277 ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530278 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530279 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530280 ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
281 DP_STATS_INCC(peer,
282 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
283 ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
284 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530285 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530286 ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
287 DP_STATS_INCC(peer,
288 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
289 ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
Anish Nataraj28490c42018-01-19 19:34:54 +0530290 /*
291 * If invalid TID, it could be a non-qos frame, hence do not update
292 * any AC counters
293 */
294 ac = TID_TO_WME_AC(ppdu->tid);
295 if (ppdu->tid != HAL_TID_INVALID)
296 DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
Amir Patel52c6b732018-08-03 12:13:22 +0530297 dp_peer_stats_notify(peer);
298 DP_STATS_UPD(peer, rx.last_rssi, ppdu->rssi);
Anish Nataraj28490c42018-01-19 19:34:54 +0530299
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530300 if (is_invalid_peer)
301 return;
302
Jeffin Mammen1514e792019-05-20 10:30:44 +0530303 if (dp_is_subtype_data(ppdu->frame_ctrl))
304 dp_rx_rate_stats_update(peer, ppdu);
ydb247452018-08-08 00:23:16 +0530305
Amir Patel756d05e2018-10-10 12:35:30 +0530306#if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE
307 dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc,
308 &peer->stats, ppdu->peer_id,
309 UPDATE_PEER_STATS, pdev->pdev_id);
310#endif
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530311}
312#endif
Anish Nataraj38a29562017-08-18 19:41:17 +0530313
Amir Patel57e7e052019-05-15 20:49:57 +0530314/*
315 * dp_rx_get_fcs_ok_msdu() - get ppdu status buffer containing fcs_ok msdu
316 * @pdev: pdev object
317 * @ppdu_info: ppdu info object
318 *
319 * Return: nbuf
320 */
321
322static inline qdf_nbuf_t
323dp_rx_get_fcs_ok_msdu(struct dp_pdev *pdev,
324 struct hal_rx_ppdu_info *ppdu_info)
325{
326 uint16_t mpdu_fcs_ok;
327 qdf_nbuf_t status_nbuf = NULL;
328 unsigned long int fcs_ok_bitmap;
329
330 /* If fcs_ok_bitmap is zero, no need to procees further */
331 if (qdf_unlikely(!ppdu_info->com_info.mpdu_fcs_ok_bitmap))
332 return NULL;
333
334 /* Obtain fcs_ok passed index from bitmap
335 * this index is used to get fcs passed first msdu payload
336 */
337
338 fcs_ok_bitmap = ppdu_info->com_info.mpdu_fcs_ok_bitmap;
339 mpdu_fcs_ok = qdf_find_first_bit(&fcs_ok_bitmap, HAL_RX_MAX_MPDU);
340
341 /* Get status buffer by indexing mpdu_fcs_ok index
342 * containing first msdu payload with fcs passed
343 * and clone the buffer
344 */
345 status_nbuf = ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].nbuf;
346 /* Take ref of status nbuf as this nbuf is to be
347 * freeed by upper layer.
348 */
349 qdf_nbuf_ref(status_nbuf);
350
351 /* Free the ppdu status buffer queue */
352 qdf_nbuf_queue_free(&pdev->rx_ppdu_buf_q);
353
354 return status_nbuf;
355}
356
357static inline void
358dp_rx_handle_ppdu_status_buf(struct dp_pdev *pdev,
359 struct hal_rx_ppdu_info *ppdu_info,
360 qdf_nbuf_t status_nbuf)
361{
362 qdf_nbuf_queue_add(&pdev->rx_ppdu_buf_q, status_nbuf);
363}
Anish Nataraj38a29562017-08-18 19:41:17 +0530364/**
Soumya Bhat7422db82017-12-15 13:48:53 +0530365 * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
Pranita Solankefc2ff392017-12-15 19:25:13 +0530366 * @soc: core txrx main context
367 * @pdev: pdev strcuture
368 * @ppdu_info: structure for rx ppdu ring
369 *
370 * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
371 * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
Soumya Bhat7422db82017-12-15 13:48:53 +0530372 */
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530373#ifdef FEATURE_PERPKT_INFO
374static inline QDF_STATUS
Soumya Bhat7422db82017-12-15 13:48:53 +0530375dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530376 struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
377{
378 uint8_t size = 0;
Chaithanya Garrepalli7ab76ae2018-07-05 14:53:50 +0530379 struct ieee80211_frame *wh;
380 uint32_t *nbuf_data;
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530381
Amir Patel57e7e052019-05-15 20:49:57 +0530382 if (!ppdu_info->fcs_ok_msdu_info.first_msdu_payload)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530383 return QDF_STATUS_SUCCESS;
384
Soumya Bhat2f54de22018-02-21 09:54:28 +0530385 if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530386 return QDF_STATUS_SUCCESS;
387
Soumya Bhat2f54de22018-02-21 09:54:28 +0530388 pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530389
Amir Patel57e7e052019-05-15 20:49:57 +0530390 wh = (struct ieee80211_frame *)
391 (ppdu_info->fcs_ok_msdu_info.first_msdu_payload + 4);
392
393 size = (ppdu_info->fcs_ok_msdu_info.first_msdu_payload -
Chaithanya Garrepalli7ab76ae2018-07-05 14:53:50 +0530394 qdf_nbuf_data(nbuf));
Amir Patel57e7e052019-05-15 20:49:57 +0530395 ppdu_info->fcs_ok_msdu_info.first_msdu_payload = NULL;
Soumya Bhat7422db82017-12-15 13:48:53 +0530396
397 if (qdf_nbuf_pull_head(nbuf, size) == NULL)
398 return QDF_STATUS_SUCCESS;
399
Chaithanya Garrepalli7ab76ae2018-07-05 14:53:50 +0530400 if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
401 IEEE80211_FC0_TYPE_MGT) ||
402 ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) ==
403 IEEE80211_FC0_TYPE_CTL)) {
404 return QDF_STATUS_SUCCESS;
405 }
406
407 nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf);
408 *nbuf_data = pdev->ppdu_info.com_info.ppdu_id;
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530409 /* only retain RX MSDU payload in the skb */
410 qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
Amir Patel57e7e052019-05-15 20:49:57 +0530411 ppdu_info->fcs_ok_msdu_info.payload_len);
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530412 dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
413 nbuf, HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id);
414 return QDF_STATUS_E_ALREADY;
415}
416#else
417static inline QDF_STATUS
Soumya Bhat7422db82017-12-15 13:48:53 +0530418dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530419 struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
420{
421 return QDF_STATUS_SUCCESS;
422}
423#endif
424
Amir Patel57e7e052019-05-15 20:49:57 +0530425#ifdef FEATURE_PERPKT_INFO
426static inline void
427dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
428 struct hal_rx_ppdu_info *ppdu_info,
429 uint32_t tlv_status,
430 qdf_nbuf_t status_nbuf)
431{
432 QDF_STATUS mcopy_status;
433
434 if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt)) {
435 qdf_nbuf_free(status_nbuf);
436 return;
437 }
438 /* Add buffers to queue until we receive
439 * HAL_TLV_STATUS_PPDU_DONE
440 */
441 dp_rx_handle_ppdu_status_buf(pdev, ppdu_info, status_nbuf);
442
443 /* If tlv_status is PPDU_DONE, process rx_ppdu_buf_q
444 * and devliver fcs_ok msdu buffer
445 */
446 if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
447 /* Get rx ppdu status buffer having fcs ok msdu */
448 status_nbuf = dp_rx_get_fcs_ok_msdu(pdev, ppdu_info);
449 if (status_nbuf) {
450 mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev,
451 ppdu_info,
452 status_nbuf);
453 if (mcopy_status == QDF_STATUS_SUCCESS)
454 qdf_nbuf_free(status_nbuf);
455 }
456 }
457}
458#else
459static inline void
460dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
461 struct hal_rx_ppdu_info *ppdu_info,
462 uint32_t tlv_status,
463 qdf_nbuf_t status_nbuf)
464{
465}
466#endif
467
sumedh baikady59a2d332018-05-22 01:50:38 -0700468/**
469 * dp_rx_handle_smart_mesh_mode() - Deliver header for smart mesh
470 * @soc: Datapath SOC handle
471 * @pdev: Datapath PDEV handle
472 * @ppdu_info: Structure for rx ppdu info
473 * @nbuf: Qdf nbuf abstraction for linux skb
474 *
475 * Return: 0 on success, 1 on failure
476 */
477static inline int
478dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev,
479 struct hal_rx_ppdu_info *ppdu_info,
480 qdf_nbuf_t nbuf)
481{
482 uint8_t size = 0;
483
484 if (!pdev->monitor_vdev) {
485 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
486 "[%s]:[%d] Monitor vdev is NULL !!",
487 __func__, __LINE__);
488 return 1;
489 }
Jeff Johnsona8edf332019-03-18 09:51:52 -0700490 if (!ppdu_info->msdu_info.first_msdu_payload) {
sumedh baikady59a2d332018-05-22 01:50:38 -0700491 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
492 "[%s]:[%d] First msdu payload not present",
493 __func__, __LINE__);
494 return 1;
495 }
496
sumedh baikadyda159202018-11-01 17:31:23 -0700497 /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */
sumedh baikady59a2d332018-05-22 01:50:38 -0700498 size = (ppdu_info->msdu_info.first_msdu_payload -
sumedh baikadyda159202018-11-01 17:31:23 -0700499 qdf_nbuf_data(nbuf)) + 4;
sumedh baikady59a2d332018-05-22 01:50:38 -0700500 ppdu_info->msdu_info.first_msdu_payload = NULL;
501
502 if (qdf_nbuf_pull_head(nbuf, size) == NULL) {
503 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
504 "[%s]:[%d] No header present",
505 __func__, __LINE__);
506 return 1;
507 }
508
sumedh baikadyda159202018-11-01 17:31:23 -0700509 /* Only retain RX MSDU payload in the skb */
sumedh baikady59a2d332018-05-22 01:50:38 -0700510 qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
511 ppdu_info->msdu_info.payload_len);
Shashikala Prabhu08434382019-07-16 15:42:03 +0530512 if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status, nbuf,
513 qdf_nbuf_headroom(nbuf))) {
514 DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1);
515 return 1;
516 }
517
sumedh baikady59a2d332018-05-22 01:50:38 -0700518 pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
519 nbuf, NULL);
sumedh baikadyda159202018-11-01 17:31:23 -0700520 pdev->ppdu_info.rx_status.monitor_direct_used = 0;
sumedh baikady59a2d332018-05-22 01:50:38 -0700521 return 0;
522}
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530523
524/**
Anish Nataraj38a29562017-08-18 19:41:17 +0530525* dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
526* @soc: core txrx main context
527* @pdev: pdev strcuture
528* @ppdu_info: structure for rx ppdu ring
529*
530* Return: none
531*/
532#ifdef FEATURE_PERPKT_INFO
533static inline void
534dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
535 struct hal_rx_ppdu_info *ppdu_info)
536{
537 qdf_nbuf_t ppdu_nbuf;
538 struct dp_peer *peer;
539 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
540
Anish Nataraj28490c42018-01-19 19:34:54 +0530541 /*
542 * Do not allocate if fcs error,
543 * ast idx invalid / fctl invalid
544 */
Anish Nataraj28490c42018-01-19 19:34:54 +0530545 if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
546 return;
547
Chaithanya Garrepalli95fc62f2018-07-24 18:52:27 +0530548 if (ppdu_info->nac_info.fc_valid &&
549 ppdu_info->nac_info.to_ds_flag &&
550 ppdu_info->nac_info.mac_addr2_valid) {
551 struct dp_neighbour_peer *peer = NULL;
552 uint8_t rssi = ppdu_info->rx_status.rssi_comb;
553
554 qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
555 if (pdev->neighbour_peers_added) {
556 TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
557 neighbour_peer_list_elem) {
558 if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
559 &ppdu_info->nac_info.mac_addr2,
Srinivas Girigowda2751b6d2019-02-27 12:28:13 -0800560 QDF_MAC_ADDR_SIZE)) {
Chaithanya Garrepalli95fc62f2018-07-24 18:52:27 +0530561 peer->rssi = rssi;
562 break;
563 }
564 }
565 }
566 qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
567 }
568
Chaithanya Garrepalli3e4ac1c2018-12-12 20:50:45 +0530569 /* need not generate wdi event when mcopy and
570 * enhanced stats are not enabled
571 */
572 if (!pdev->mcopy_mode && !pdev->enhanced_stats_en)
573 return;
574
Soumya Bhat560f90c2018-03-30 13:53:26 +0530575 if (!pdev->mcopy_mode) {
576 if (!ppdu_info->rx_status.frame_control_info_valid)
577 return;
Anish Nataraj28490c42018-01-19 19:34:54 +0530578
Soumya Bhat560f90c2018-03-30 13:53:26 +0530579 if (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)
580 return;
581 }
Tallapragada Kalyana867edf2017-11-14 12:26:41 +0530582 ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
Kiran Venkatappa4b50f332019-03-20 18:14:17 +0530583 sizeof(struct cdp_rx_indication_ppdu), 0, 0, FALSE);
Anish Nataraj38a29562017-08-18 19:41:17 +0530584 if (ppdu_nbuf) {
Soumya Bhat560f90c2018-03-30 13:53:26 +0530585 dp_rx_populate_cdp_indication_ppdu(pdev, ppdu_info, ppdu_nbuf);
Anish Nataraj38a29562017-08-18 19:41:17 +0530586 qdf_nbuf_put_tail(ppdu_nbuf,
587 sizeof(struct cdp_rx_indication_ppdu));
588 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530589 peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id);
chenguob21a49a2018-11-19 19:17:12 +0800590 if (peer) {
Amir Patel468bded2019-03-21 11:42:31 +0530591 cdp_rx_ppdu->cookie = (void *)peer->wlanstats_ctx;
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530592 dp_rx_stats_update(pdev, peer, cdp_rx_ppdu);
chenguob21a49a2018-11-19 19:17:12 +0800593 dp_peer_unref_del_find_by_id(peer);
594 }
595 if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
596 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
597 soc, ppdu_nbuf,
598 cdp_rx_ppdu->peer_id,
599 WDI_NO_VAL, pdev->pdev_id);
600 } else if (pdev->mcopy_mode) {
Soumya Bhat2f54de22018-02-21 09:54:28 +0530601 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
602 ppdu_nbuf, HTT_INVALID_PEER,
603 WDI_NO_VAL, pdev->pdev_id);
604 } else {
Anish Nataraj38a29562017-08-18 19:41:17 +0530605 qdf_nbuf_free(ppdu_nbuf);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530606 }
Anish Nataraj38a29562017-08-18 19:41:17 +0530607 }
608}
609#else
610static inline void
611dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
612 struct hal_rx_ppdu_info *ppdu_info)
613{
614}
615#endif
616
617/**
Keyur Parekhc28f8392018-11-21 02:50:56 -0800618* dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
619* filtering enabled
620* @soc: core txrx main context
621* @ppdu_info: Structure for rx ppdu info
622* @status_nbuf: Qdf nbuf abstraction for linux skb
623* @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
624*
625* Return: none
626*/
627static inline void
628dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
629 struct hal_rx_ppdu_info *ppdu_info,
630 qdf_nbuf_t status_nbuf, uint32_t mac_id)
631{
632 struct dp_peer *peer;
633 struct dp_ast_entry *ast_entry;
634 uint32_t ast_index;
635
636 ast_index = ppdu_info->rx_status.ast_index;
637 if (ast_index < (WLAN_UMAC_PSOC_MAX_PEERS * 2)) {
638 ast_entry = soc->ast_table[ast_index];
639 if (ast_entry) {
640 peer = ast_entry->peer;
641 if (peer && (peer->peer_ids[0] != HTT_INVALID_PEER)) {
642 if (peer->peer_based_pktlog_filter) {
643 dp_wdi_event_handler(
644 WDI_EVENT_RX_DESC, soc,
645 status_nbuf,
646 peer->peer_ids[0],
647 WDI_NO_VAL, mac_id);
648 }
649 }
650 }
651 }
652}
653
654/**
Kai Chen6eca1a62017-01-12 10:17:53 -0800655* dp_rx_mon_status_process_tlv() - Process status TLV in status
656* buffer on Rx status Queue posted by status SRNG processing.
657* @soc: core txrx main context
658* @mac_id: mac_id which is one of 3 mac_ids _ring
659*
660* Return: none
661*/
662static inline void
Karunakar Dasineni40555682017-03-26 22:44:39 -0700663dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
664 uint32_t quota)
665{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800666 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800667 struct hal_rx_ppdu_info *ppdu_info;
668 qdf_nbuf_t status_nbuf;
669 uint8_t *rx_tlv;
670 uint8_t *rx_tlv_start;
Kai Chenad516ae2017-09-08 18:35:47 -0700671 uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
Kai Chen52ef33f2019-03-05 18:33:40 -0800672 QDF_STATUS enh_log_status = QDF_STATUS_SUCCESS;
Kai Chen783e0382018-01-25 16:29:08 -0800673 struct cdp_pdev_mon_stats *rx_mon_stats;
sumedh baikady59a2d332018-05-22 01:50:38 -0700674 int smart_mesh_status;
Venkata Sharath Chandra Manchalacad74ad2019-01-28 11:36:47 -0800675 enum WDI_EVENT pktlog_mode = WDI_NO_VAL;
Kai Chen52ef33f2019-03-05 18:33:40 -0800676 bool nbuf_used;
677 uint32_t rx_enh_capture_mode;
678
Kai Chen6eca1a62017-01-12 10:17:53 -0800679
Kai Chen6eca1a62017-01-12 10:17:53 -0800680 ppdu_info = &pdev->ppdu_info;
Kai Chen783e0382018-01-25 16:29:08 -0800681 rx_mon_stats = &pdev->rx_mon_stats;
Kai Chen6eca1a62017-01-12 10:17:53 -0800682
683 if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
684 return;
685
Kai Chen52ef33f2019-03-05 18:33:40 -0800686 rx_enh_capture_mode = pdev->rx_enh_capture_mode;
687
Kai Chen6eca1a62017-01-12 10:17:53 -0800688 while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
689
690 status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
phadiman49757302018-12-18 16:13:59 +0530691
Kai Chen6eca1a62017-01-12 10:17:53 -0800692 rx_tlv = qdf_nbuf_data(status_nbuf);
693 rx_tlv_start = rx_tlv;
Kai Chen52ef33f2019-03-05 18:33:40 -0800694 nbuf_used = false;
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -0700695
Jeff Johnsona8edf332019-03-18 09:51:52 -0700696 if ((pdev->monitor_vdev) || (pdev->enhanced_stats_en) ||
Kai Chen52ef33f2019-03-05 18:33:40 -0800697 pdev->mcopy_mode ||
698 (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) {
Keyur Parekhfad6d082017-05-07 08:54:47 -0700699 do {
700 tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
Amir Patel57e7e052019-05-15 20:49:57 +0530701 ppdu_info, pdev->soc->hal_soc,
702 status_nbuf);
Kai Chen783e0382018-01-25 16:29:08 -0800703
704 dp_rx_mon_update_dbg_ppdu_stats(ppdu_info,
705 rx_mon_stats);
706
Kai Chen52ef33f2019-03-05 18:33:40 -0800707 dp_rx_mon_enh_capture_process(pdev, tlv_status,
708 status_nbuf, ppdu_info,
Karunakar Dasineniacc8b562019-05-07 07:00:24 -0700709 &nbuf_used);
Kai Chen52ef33f2019-03-05 18:33:40 -0800710
Keyur Parekhfad6d082017-05-07 08:54:47 -0700711 rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
Kai Chen6eca1a62017-01-12 10:17:53 -0800712
Keyur Parekhfad6d082017-05-07 08:54:47 -0700713 if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE)
714 break;
Kai Chen6eca1a62017-01-12 10:17:53 -0800715
Kai Chen52ef33f2019-03-05 18:33:40 -0800716 } while ((tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE) ||
717 (tlv_status == HAL_TLV_STATUS_HEADER) ||
Karunakar Dasineniacc8b562019-05-07 07:00:24 -0700718 (tlv_status == HAL_TLV_STATUS_MPDU_END) ||
719 (tlv_status == HAL_TLV_STATUS_MSDU_END));
Keyur Parekhfad6d082017-05-07 08:54:47 -0700720 }
Keyur Parekhc28f8392018-11-21 02:50:56 -0800721 if (pdev->dp_peer_based_pktlog) {
722 dp_rx_process_peer_based_pktlog(soc, ppdu_info,
723 status_nbuf, mac_id);
724 } else {
Venkata Sharath Chandra Manchalacad74ad2019-01-28 11:36:47 -0800725 if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL)
726 pktlog_mode = WDI_EVENT_RX_DESC;
727 else if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE)
728 pktlog_mode = WDI_EVENT_LITE_RX;
729
730 if (pktlog_mode != WDI_NO_VAL)
731 dp_wdi_event_handler(pktlog_mode, soc,
732 status_nbuf,
733 HTT_INVALID_PEER,
734 WDI_NO_VAL, mac_id);
Keyur Parekhc28f8392018-11-21 02:50:56 -0800735 }
Chaithanya Garrepalli3e4ac1c2018-12-12 20:50:45 +0530736
737 /* smart monitor vap and m_copy cannot co-exist */
sumedh baikady59a2d332018-05-22 01:50:38 -0700738 if (ppdu_info->rx_status.monitor_direct_used && pdev->neighbour_peers_added
739 && pdev->monitor_vdev) {
740 smart_mesh_status = dp_rx_handle_smart_mesh_mode(soc,
741 pdev, ppdu_info, status_nbuf);
742 if (smart_mesh_status)
743 qdf_nbuf_free(status_nbuf);
Amir Patel57e7e052019-05-15 20:49:57 +0530744 } else if (qdf_unlikely(pdev->mcopy_mode)) {
745 dp_rx_process_mcopy_mode(soc, pdev,
746 ppdu_info, tlv_status,
747 status_nbuf);
Kai Chen52ef33f2019-03-05 18:33:40 -0800748 } else if (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED) {
749 if (!nbuf_used)
750 qdf_nbuf_free(status_nbuf);
751
752 if (tlv_status == HAL_TLV_STATUS_PPDU_DONE)
753 enh_log_status =
754 dp_rx_handle_enh_capture(soc,
755 pdev, ppdu_info);
Chaithanya Garrepalli3e4ac1c2018-12-12 20:50:45 +0530756 } else {
sumedh baikady59a2d332018-05-22 01:50:38 -0700757 qdf_nbuf_free(status_nbuf);
Chaithanya Garrepalli3e4ac1c2018-12-12 20:50:45 +0530758 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800759
chenguo1b880462018-07-11 15:34:56 +0800760 if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) {
761 dp_rx_mon_deliver_non_std(soc, mac_id);
762 } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
Kai Chen783e0382018-01-25 16:29:08 -0800763 rx_mon_stats->status_ppdu_done++;
Soumya Bhat5c60deb2017-12-12 16:42:04 +0530764 if (pdev->enhanced_stats_en ||
sumedh baikady59a2d332018-05-22 01:50:38 -0700765 pdev->mcopy_mode || pdev->neighbour_peers_added)
Anish Nataraj38a29562017-08-18 19:41:17 +0530766 dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530767
nobelj1c31fee2018-03-21 11:47:05 -0700768 pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
769 dp_rx_mon_dest_process(soc, mac_id, quota);
Kai Chencbe4c342017-06-12 20:06:35 -0700770 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Kai Chen6eca1a62017-01-12 10:17:53 -0800771 }
772 }
773 return;
774}
775
776/*
777 * dp_rx_mon_status_srng_process() - Process monitor status ring
778 * post the status ring buffer to Rx status Queue for later
779 * processing when status ring is filled with status TLV.
780 * Allocate a new buffer to status ring if the filled buffer
781 * is posted.
782 *
783 * @soc: core txrx main context
784 * @mac_id: mac_id which is one of 3 mac_ids
785 * @quota: No. of ring entry that can be serviced in one shot.
786
787 * Return: uint32_t: No. of ring entry that is processed.
788 */
789static inline uint32_t
790dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
791 uint32_t quota)
792{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800793 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800794 void *hal_soc;
795 void *mon_status_srng;
796 void *rxdma_mon_status_ring_entry;
797 QDF_STATUS status;
798 uint32_t work_done = 0;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800799 int mac_for_pdev = dp_get_mac_id_for_mac(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800800
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800801 mon_status_srng = pdev->rxdma_mon_status_ring[mac_for_pdev].hal_srng;
Kai Chen6eca1a62017-01-12 10:17:53 -0800802
803 qdf_assert(mon_status_srng);
Houston Hoffman648a9182017-05-21 23:27:50 -0700804 if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
805
806 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Aditya Sathishded018e2018-07-02 16:25:21 +0530807 "%s %d : HAL Monitor Status Ring Init Failed -- %pK",
Houston Hoffman648a9182017-05-21 23:27:50 -0700808 __func__, __LINE__, mon_status_srng);
809 return work_done;
810 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800811
812 hal_soc = soc->hal_soc;
813
814 qdf_assert(hal_soc);
815
816 if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
817 goto done;
818
819 /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
820 * BUFFER_ADDR_INFO STRUCT
821 */
822 while (qdf_likely((rxdma_mon_status_ring_entry =
823 hal_srng_src_peek(hal_soc, mon_status_srng))
824 && quota--)) {
825 uint32_t rx_buf_cookie;
826 qdf_nbuf_t status_nbuf;
827 struct dp_rx_desc *rx_desc;
828 uint8_t *status_buf;
829 qdf_dma_addr_t paddr;
830 uint64_t buf_addr;
831
832 buf_addr =
833 (HAL_RX_BUFFER_ADDR_31_0_GET(
834 rxdma_mon_status_ring_entry) |
835 ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
836 rxdma_mon_status_ring_entry)) << 32));
837
838 if (qdf_likely(buf_addr)) {
839
840 rx_buf_cookie =
841 HAL_RX_BUF_COOKIE_GET(
842 rxdma_mon_status_ring_entry);
843 rx_desc = dp_rx_cookie_2_va_mon_status(soc,
844 rx_buf_cookie);
845
846 qdf_assert(rx_desc);
847
848 status_nbuf = rx_desc->nbuf;
849
850 qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
851 QDF_DMA_FROM_DEVICE);
852
853 status_buf = qdf_nbuf_data(status_nbuf);
854
855 status = hal_get_rx_status_done(status_buf);
856
857 if (status != QDF_STATUS_SUCCESS) {
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800858 uint32_t hp, tp;
Venkata Sharath Chandra Manchala443b9b42018-10-10 12:04:54 -0700859 hal_get_sw_hptp(hal_soc, mon_status_srng,
860 &tp, &hp);
Kai Chen6eca1a62017-01-12 10:17:53 -0800861 QDF_TRACE(QDF_MODULE_ID_DP,
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800862 QDF_TRACE_LEVEL_ERROR,
863 "[%s][%d] status not done - hp:%u, tp:%u",
864 __func__, __LINE__, hp, tp);
865 /* WAR for missing status: Skip status entry */
866 hal_srng_src_get_next(hal_soc, mon_status_srng);
867 continue;
Kai Chen6eca1a62017-01-12 10:17:53 -0800868 }
869 qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE);
870
871 qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
872 QDF_DMA_FROM_DEVICE);
873
874 /* Put the status_nbuf to queue */
875 qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
876
877 } else {
878 union dp_rx_desc_list_elem_t *desc_list = NULL;
879 union dp_rx_desc_list_elem_t *tail = NULL;
880 struct rx_desc_pool *rx_desc_pool;
881 uint32_t num_alloc_desc;
882
883 rx_desc_pool = &soc->rx_desc_status[mac_id];
884
885 num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
886 rx_desc_pool,
887 1,
888 &desc_list,
889 &tail);
phadimanebf4cde2019-01-28 17:50:37 +0530890 /*
891 * No free descriptors available
892 */
893 if (qdf_unlikely(num_alloc_desc == 0)) {
894 work_done++;
895 break;
896 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800897
898 rx_desc = &desc_list->rx_desc;
899 }
900
jinweic chenc3546322018-02-02 15:03:41 +0800901 status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -0800902
jinweic chenc3546322018-02-02 15:03:41 +0800903 /*
904 * qdf_nbuf alloc or map failed,
905 * free the dp rx desc to free list,
906 * fill in NULL dma address at current HP entry,
907 * keep HP in mon_status_ring unchanged,
908 * wait next time dp_rx_mon_status_srng_process
909 * to fill in buffer at current HP.
910 */
Jeff Johnsona8edf332019-03-18 09:51:52 -0700911 if (qdf_unlikely(!status_nbuf)) {
jinweic chenc3546322018-02-02 15:03:41 +0800912 union dp_rx_desc_list_elem_t *desc_list = NULL;
913 union dp_rx_desc_list_elem_t *tail = NULL;
914 struct rx_desc_pool *rx_desc_pool;
Kai Chen6eca1a62017-01-12 10:17:53 -0800915
jinweic chenc3546322018-02-02 15:03:41 +0800916 rx_desc_pool = &soc->rx_desc_status[mac_id];
Kai Chen6eca1a62017-01-12 10:17:53 -0800917
jinweic chenc3546322018-02-02 15:03:41 +0800918 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
919 "%s: fail to allocate or map qdf_nbuf",
920 __func__);
921 dp_rx_add_to_free_desc_list(&desc_list,
922 &tail, rx_desc);
923 dp_rx_add_desc_list_to_free_list(soc, &desc_list,
924 &tail, mac_id, rx_desc_pool);
925
926 hal_rxdma_buff_addr_info_set(
927 rxdma_mon_status_ring_entry,
928 0, 0, HAL_RX_BUF_RBM_SW3_BM);
929 work_done++;
930 break;
931 }
932
Kai Chen6eca1a62017-01-12 10:17:53 -0800933 paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
934
935 rx_desc->nbuf = status_nbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700936 rx_desc->in_use = 1;
Kai Chen6eca1a62017-01-12 10:17:53 -0800937
938 hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
939 paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
940
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800941 hal_srng_src_get_next(hal_soc, mon_status_srng);
Kai Chen6eca1a62017-01-12 10:17:53 -0800942 work_done++;
943 }
944done:
945
946 hal_srng_access_end(hal_soc, mon_status_srng);
947
948 return work_done;
949
950}
951/*
952 * dp_rx_mon_status_process() - Process monitor status ring and
953 * TLV in status ring.
954 *
955 * @soc: core txrx main context
956 * @mac_id: mac_id which is one of 3 mac_ids
957 * @quota: No. of ring entry that can be serviced in one shot.
958
959 * Return: uint32_t: No. of ring entry that is processed.
960 */
961static inline uint32_t
962dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
963 uint32_t work_done;
964
965 work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
Karunakar Dasineni40555682017-03-26 22:44:39 -0700966 quota -= work_done;
967 dp_rx_mon_status_process_tlv(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800968
969 return work_done;
970}
971/**
972 * dp_mon_process() - Main monitor mode processing roution.
973 * This call monitor status ring process then monitor
974 * destination ring process.
975 * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
976 * @soc: core txrx main context
977 * @mac_id: mac_id which is one of 3 mac_ids
978 * @quota: No. of status ring entry that can be serviced in one shot.
979
980 * Return: uint32_t: No. of ring entry that is processed.
981 */
982uint32_t
983dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
Karunakar Dasineni40555682017-03-26 22:44:39 -0700984 return dp_rx_mon_status_process(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800985}
Karunakar Dasineni40555682017-03-26 22:44:39 -0700986
Kai Chen6eca1a62017-01-12 10:17:53 -0800987/**
Venkata Sharath Chandra Manchala87479582018-08-01 12:45:34 -0700988 * dp_rx_pdev_mon_status_detach() - detach dp rx for status ring
Kai Chen6eca1a62017-01-12 10:17:53 -0800989 * @pdev: core txrx pdev context
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800990 * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
Kai Chen6eca1a62017-01-12 10:17:53 -0800991 *
992 * This function will detach DP RX status ring from
993 * main device context. will free DP Rx resources for
994 * status ring
995 *
996 * Return: QDF_STATUS_SUCCESS: success
997 * QDF_STATUS_E_RESOURCES: Error return
998 */
999QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -08001000dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id)
Kai Chen6eca1a62017-01-12 10:17:53 -08001001{
Kai Chen6eca1a62017-01-12 10:17:53 -08001002 struct dp_soc *soc = pdev->soc;
1003 struct rx_desc_pool *rx_desc_pool;
1004
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -08001005 rx_desc_pool = &soc->rx_desc_status[mac_id];
phadiman449a2682019-02-20 14:00:00 +05301006 if (rx_desc_pool->pool_size != 0) {
1007 if (!dp_is_soc_reinit(soc))
Varun Reddy Yeturua7c21dc2019-05-16 14:03:46 -07001008 dp_rx_desc_nbuf_and_pool_free(soc, mac_id,
1009 rx_desc_pool);
phadiman449a2682019-02-20 14:00:00 +05301010 else
Varun Reddy Yeturua7c21dc2019-05-16 14:03:46 -07001011 dp_rx_desc_nbuf_free(soc, rx_desc_pool);
phadiman449a2682019-02-20 14:00:00 +05301012 }
Kai Chen6eca1a62017-01-12 10:17:53 -08001013
1014 return QDF_STATUS_SUCCESS;
1015}
1016
1017/*
1018 * dp_rx_buffers_replenish() - replenish monitor status ring with
1019 * rx nbufs called during dp rx
1020 * monitor status ring initialization
1021 *
1022 * @soc: core txrx main context
1023 * @mac_id: mac_id which is one of 3 mac_ids
1024 * @dp_rxdma_srng: dp monitor status circular ring
1025 * @rx_desc_pool; Pointer to Rx descriptor pool
1026 * @num_req_buffers: number of buffer to be replenished
1027 * @desc_list: list of descs if called from dp rx monitor status
1028 * process or NULL during dp rx initialization or
1029 * out of buffer interrupt
1030 * @tail: tail of descs list
1031 * @owner: who owns the nbuf (host, NSS etc...)
1032 * Return: return success or failure
1033 */
1034static inline
1035QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
1036 uint32_t mac_id,
1037 struct dp_srng *dp_rxdma_srng,
1038 struct rx_desc_pool *rx_desc_pool,
1039 uint32_t num_req_buffers,
1040 union dp_rx_desc_list_elem_t **desc_list,
1041 union dp_rx_desc_list_elem_t **tail,
1042 uint8_t owner)
1043{
1044 uint32_t num_alloc_desc;
1045 uint16_t num_desc_to_free = 0;
1046 uint32_t num_entries_avail;
jinweic chenc3546322018-02-02 15:03:41 +08001047 uint32_t count = 0;
Kai Chen6eca1a62017-01-12 10:17:53 -08001048 int sync_hw_ptr = 1;
1049 qdf_dma_addr_t paddr;
1050 qdf_nbuf_t rx_netbuf;
1051 void *rxdma_ring_entry;
1052 union dp_rx_desc_list_elem_t *next;
1053 void *rxdma_srng;
jinweic chenc3546322018-02-02 15:03:41 +08001054 struct dp_pdev *dp_pdev = dp_get_pdev_for_mac_id(dp_soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -08001055
1056 rxdma_srng = dp_rxdma_srng->hal_srng;
1057
1058 qdf_assert(rxdma_srng);
1059
Houston Hoffmanae850c62017-08-11 16:47:50 -07001060 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301061 "[%s][%d] requested %d buffers for replenish",
Kai Chen6eca1a62017-01-12 10:17:53 -08001062 __func__, __LINE__, num_req_buffers);
1063
1064 /*
1065 * if desc_list is NULL, allocate the descs from freelist
1066 */
1067 if (!(*desc_list)) {
1068
1069 num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
1070 rx_desc_pool,
1071 num_req_buffers,
1072 desc_list,
1073 tail);
1074
1075 if (!num_alloc_desc) {
1076 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
Aditya Sathishded018e2018-07-02 16:25:21 +05301077 "[%s][%d] no free rx_descs in freelist",
Kai Chen6eca1a62017-01-12 10:17:53 -08001078 __func__, __LINE__);
1079 return QDF_STATUS_E_NOMEM;
1080 }
1081
Houston Hoffmanae850c62017-08-11 16:47:50 -07001082 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301083 "[%s][%d] %d rx desc allocated", __func__, __LINE__,
Kai Chen6eca1a62017-01-12 10:17:53 -08001084 num_alloc_desc);
Houston Hoffmanae850c62017-08-11 16:47:50 -07001085
Kai Chen6eca1a62017-01-12 10:17:53 -08001086 num_req_buffers = num_alloc_desc;
1087 }
1088
1089 hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
1090 num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
1091 rxdma_srng, sync_hw_ptr);
1092
Houston Hoffmanae850c62017-08-11 16:47:50 -07001093 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301094 "[%s][%d] no of available entries in rxdma ring: %d",
Kai Chen6eca1a62017-01-12 10:17:53 -08001095 __func__, __LINE__, num_entries_avail);
1096
1097 if (num_entries_avail < num_req_buffers) {
1098 num_desc_to_free = num_req_buffers - num_entries_avail;
1099 num_req_buffers = num_entries_avail;
1100 }
1101
jinweic chenc3546322018-02-02 15:03:41 +08001102 while (count < num_req_buffers) {
1103 rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -08001104
jinweic chenc3546322018-02-02 15:03:41 +08001105 /*
1106 * qdf_nbuf alloc or map failed,
1107 * keep HP in mon_status_ring unchanged,
1108 * wait dp_rx_mon_status_srng_process
1109 * to fill in buffer at current HP.
1110 */
Jeff Johnsona8edf332019-03-18 09:51:52 -07001111 if (qdf_unlikely(!rx_netbuf)) {
jinweic chenc3546322018-02-02 15:03:41 +08001112 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
1113 "%s: qdf_nbuf allocate or map fail, count %d",
1114 __func__, count);
1115 break;
1116 }
Kai Chen6eca1a62017-01-12 10:17:53 -08001117
1118 paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
1119
1120 next = (*desc_list)->next;
sumedh baikadyeca2de62018-04-11 14:20:38 -07001121 rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc,
1122 rxdma_srng);
1123
Jeff Johnsona8edf332019-03-18 09:51:52 -07001124 if (qdf_unlikely(!rxdma_ring_entry)) {
sumedh baikadyeca2de62018-04-11 14:20:38 -07001125 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
Aditya Sathishded018e2018-07-02 16:25:21 +05301126 "[%s][%d] rxdma_ring_entry is NULL, count - %d",
sumedh baikadyeca2de62018-04-11 14:20:38 -07001127 __func__, __LINE__, count);
1128 qdf_nbuf_unmap_single(dp_soc->osdev, rx_netbuf,
Ankit Kumar0ae4abc2019-05-02 15:08:42 +05301129 QDF_DMA_FROM_DEVICE);
sumedh baikadyeca2de62018-04-11 14:20:38 -07001130 qdf_nbuf_free(rx_netbuf);
1131 break;
1132 }
Kai Chen6eca1a62017-01-12 10:17:53 -08001133
1134 (*desc_list)->rx_desc.nbuf = rx_netbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -07001135 (*desc_list)->rx_desc.in_use = 1;
jinweic chenc3546322018-02-02 15:03:41 +08001136 count++;
jinweic chenc3546322018-02-02 15:03:41 +08001137
Kai Chen6eca1a62017-01-12 10:17:53 -08001138 hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
1139 (*desc_list)->rx_desc.cookie, owner);
1140
Karunakar Dasineni40555682017-03-26 22:44:39 -07001141 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -07001142 "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
Aditya Sathishded018e2018-07-02 16:25:21 +05301143 paddr=%pK",
Kai Chen6eca1a62017-01-12 10:17:53 -08001144 __func__, __LINE__, &(*desc_list)->rx_desc,
1145 (*desc_list)->rx_desc.cookie, rx_netbuf,
jinweic chenc3546322018-02-02 15:03:41 +08001146 (void *)paddr);
Kai Chen6eca1a62017-01-12 10:17:53 -08001147
1148 *desc_list = next;
1149 }
1150
1151 hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
1152
Houston Hoffmanae850c62017-08-11 16:47:50 -07001153 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301154 "successfully replenished %d buffers", num_req_buffers);
Kai Chen6eca1a62017-01-12 10:17:53 -08001155
Houston Hoffmanae850c62017-08-11 16:47:50 -07001156 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301157 "%d rx desc added back to free list", num_desc_to_free);
Kai Chen6eca1a62017-01-12 10:17:53 -08001158
Kai Chen6eca1a62017-01-12 10:17:53 -08001159 /*
1160 * add any available free desc back to the free list
1161 */
1162 if (*desc_list) {
1163 dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
1164 mac_id, rx_desc_pool);
1165 }
1166
1167 return QDF_STATUS_SUCCESS;
1168}
1169/**
1170 * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
1171 * @pdev: core txrx pdev context
Venkata Sharath Chandra Manchala87479582018-08-01 12:45:34 -07001172 * @ring_id: ring number
Kai Chen6eca1a62017-01-12 10:17:53 -08001173 * This function will attach a DP RX monitor status ring into pDEV
1174 * and replenish monitor status ring with buffer.
1175 *
1176 * Return: QDF_STATUS_SUCCESS: success
1177 * QDF_STATUS_E_RESOURCES: Error return
1178 */
1179QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -08001180dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int ring_id) {
Kai Chen6eca1a62017-01-12 10:17:53 -08001181 struct dp_soc *soc = pdev->soc;
1182 union dp_rx_desc_list_elem_t *desc_list = NULL;
1183 union dp_rx_desc_list_elem_t *tail = NULL;
Mohit Khanna70514992018-11-12 18:39:03 -08001184 struct dp_srng *mon_status_ring;
1185 uint32_t num_entries;
Kai Chen52ef33f2019-03-05 18:33:40 -08001186 uint32_t i;
Kai Chen6eca1a62017-01-12 10:17:53 -08001187 struct rx_desc_pool *rx_desc_pool;
Ravi Joshia9ebe0a2017-06-17 16:43:02 -07001188 QDF_STATUS status;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -08001189 int mac_for_pdev = dp_get_mac_id_for_mac(soc, ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -08001190
Mohit Khanna70514992018-11-12 18:39:03 -08001191 mon_status_ring = &pdev->rxdma_mon_status_ring[mac_for_pdev];
Kai Chen6eca1a62017-01-12 10:17:53 -08001192
Mohit Khanna70514992018-11-12 18:39:03 -08001193 num_entries = mon_status_ring->num_entries;
Kai Chen6eca1a62017-01-12 10:17:53 -08001194
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -08001195 rx_desc_pool = &soc->rx_desc_status[ring_id];
Kai Chen6eca1a62017-01-12 10:17:53 -08001196
Mohit Khanna70514992018-11-12 18:39:03 -08001197 dp_info("Mon RX Status Pool[%d] entries=%d",
1198 ring_id, num_entries);
Kai Chen6eca1a62017-01-12 10:17:53 -08001199
Mohit Khanna70514992018-11-12 18:39:03 -08001200 status = dp_rx_desc_pool_alloc(soc, ring_id, num_entries + 1,
1201 rx_desc_pool);
1202 if (!QDF_IS_STATUS_SUCCESS(status))
Ravi Joshia9ebe0a2017-06-17 16:43:02 -07001203 return status;
Kai Chen6eca1a62017-01-12 10:17:53 -08001204
Mohit Khanna70514992018-11-12 18:39:03 -08001205 dp_debug("Mon RX Status Buffers Replenish ring_id=%d", ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -08001206
Mohit Khanna70514992018-11-12 18:39:03 -08001207 status = dp_rx_mon_status_buffers_replenish(soc, ring_id,
1208 mon_status_ring,
1209 rx_desc_pool,
1210 num_entries,
1211 &desc_list, &tail,
1212 HAL_RX_BUF_RBM_SW3_BM);
1213
1214 if (!QDF_IS_STATUS_SUCCESS(status))
Ravi Joshia9ebe0a2017-06-17 16:43:02 -07001215 return status;
Kai Chen6eca1a62017-01-12 10:17:53 -08001216
1217 qdf_nbuf_queue_init(&pdev->rx_status_q);
Amir Patel57e7e052019-05-15 20:49:57 +05301218 qdf_nbuf_queue_init(&pdev->rx_ppdu_buf_q);
Kai Chen6eca1a62017-01-12 10:17:53 -08001219
1220 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Kai Chen783e0382018-01-25 16:29:08 -08001221
Karunakar Dasineni40555682017-03-26 22:44:39 -07001222 qdf_mem_zero(&(pdev->ppdu_info.rx_status),
Mohit Khanna70514992018-11-12 18:39:03 -08001223 sizeof(pdev->ppdu_info.rx_status));
Kai Chen6eca1a62017-01-12 10:17:53 -08001224
Kai Chen783e0382018-01-25 16:29:08 -08001225 qdf_mem_zero(&pdev->rx_mon_stats,
1226 sizeof(pdev->rx_mon_stats));
1227
1228 dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info,
1229 &pdev->rx_mon_stats);
1230
Kai Chen52ef33f2019-03-05 18:33:40 -08001231 for (i = 0; i < MAX_MU_USERS; i++) {
1232 qdf_nbuf_queue_init(&pdev->mpdu_q[i]);
1233 pdev->is_mpdu_hdr[i] = true;
1234 }
1235 qdf_mem_zero(pdev->msdu_list, sizeof(pdev->msdu_list[MAX_MU_USERS]));
1236
1237 pdev->rx_enh_capture_mode = CDP_RX_ENH_CAPTURE_DISABLED;
1238
Kai Chen6eca1a62017-01-12 10:17:53 -08001239 return QDF_STATUS_SUCCESS;
1240}