blob: 2c58d11b861b5821216768fb3b42797303d0f62d [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);
512 qdf_nbuf_update_radiotap(&(pdev->ppdu_info.rx_status),
513 nbuf, sizeof(struct rx_pkt_tlvs));
514 pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev,
515 nbuf, NULL);
sumedh baikadyda159202018-11-01 17:31:23 -0700516 pdev->ppdu_info.rx_status.monitor_direct_used = 0;
sumedh baikady59a2d332018-05-22 01:50:38 -0700517 return 0;
518}
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530519
520/**
Anish Nataraj38a29562017-08-18 19:41:17 +0530521* dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
522* @soc: core txrx main context
523* @pdev: pdev strcuture
524* @ppdu_info: structure for rx ppdu ring
525*
526* Return: none
527*/
528#ifdef FEATURE_PERPKT_INFO
529static inline void
530dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
531 struct hal_rx_ppdu_info *ppdu_info)
532{
533 qdf_nbuf_t ppdu_nbuf;
534 struct dp_peer *peer;
535 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
536
Anish Nataraj28490c42018-01-19 19:34:54 +0530537 /*
538 * Do not allocate if fcs error,
539 * ast idx invalid / fctl invalid
540 */
Anish Nataraj28490c42018-01-19 19:34:54 +0530541 if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
542 return;
543
Chaithanya Garrepalli95fc62f2018-07-24 18:52:27 +0530544 if (ppdu_info->nac_info.fc_valid &&
545 ppdu_info->nac_info.to_ds_flag &&
546 ppdu_info->nac_info.mac_addr2_valid) {
547 struct dp_neighbour_peer *peer = NULL;
548 uint8_t rssi = ppdu_info->rx_status.rssi_comb;
549
550 qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
551 if (pdev->neighbour_peers_added) {
552 TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
553 neighbour_peer_list_elem) {
554 if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
555 &ppdu_info->nac_info.mac_addr2,
Srinivas Girigowda2751b6d2019-02-27 12:28:13 -0800556 QDF_MAC_ADDR_SIZE)) {
Chaithanya Garrepalli95fc62f2018-07-24 18:52:27 +0530557 peer->rssi = rssi;
558 break;
559 }
560 }
561 }
562 qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
563 }
564
Chaithanya Garrepalli3e4ac1c2018-12-12 20:50:45 +0530565 /* need not generate wdi event when mcopy and
566 * enhanced stats are not enabled
567 */
568 if (!pdev->mcopy_mode && !pdev->enhanced_stats_en)
569 return;
570
Soumya Bhat560f90c2018-03-30 13:53:26 +0530571 if (!pdev->mcopy_mode) {
572 if (!ppdu_info->rx_status.frame_control_info_valid)
573 return;
Anish Nataraj28490c42018-01-19 19:34:54 +0530574
Soumya Bhat560f90c2018-03-30 13:53:26 +0530575 if (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)
576 return;
577 }
Tallapragada Kalyana867edf2017-11-14 12:26:41 +0530578 ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
Kiran Venkatappa4b50f332019-03-20 18:14:17 +0530579 sizeof(struct cdp_rx_indication_ppdu), 0, 0, FALSE);
Anish Nataraj38a29562017-08-18 19:41:17 +0530580 if (ppdu_nbuf) {
Soumya Bhat560f90c2018-03-30 13:53:26 +0530581 dp_rx_populate_cdp_indication_ppdu(pdev, ppdu_info, ppdu_nbuf);
Anish Nataraj38a29562017-08-18 19:41:17 +0530582 qdf_nbuf_put_tail(ppdu_nbuf,
583 sizeof(struct cdp_rx_indication_ppdu));
584 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530585 peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id);
chenguob21a49a2018-11-19 19:17:12 +0800586 if (peer) {
Amir Patel468bded2019-03-21 11:42:31 +0530587 cdp_rx_ppdu->cookie = (void *)peer->wlanstats_ctx;
Ruchi, Agrawal4c5ade62018-09-27 21:52:11 +0530588 dp_rx_stats_update(pdev, peer, cdp_rx_ppdu);
chenguob21a49a2018-11-19 19:17:12 +0800589 dp_peer_unref_del_find_by_id(peer);
590 }
591 if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
592 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC,
593 soc, ppdu_nbuf,
594 cdp_rx_ppdu->peer_id,
595 WDI_NO_VAL, pdev->pdev_id);
596 } else if (pdev->mcopy_mode) {
Soumya Bhat2f54de22018-02-21 09:54:28 +0530597 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
598 ppdu_nbuf, HTT_INVALID_PEER,
599 WDI_NO_VAL, pdev->pdev_id);
600 } else {
Anish Nataraj38a29562017-08-18 19:41:17 +0530601 qdf_nbuf_free(ppdu_nbuf);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530602 }
Anish Nataraj38a29562017-08-18 19:41:17 +0530603 }
604}
605#else
606static inline void
607dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
608 struct hal_rx_ppdu_info *ppdu_info)
609{
610}
611#endif
612
613/**
Keyur Parekhc28f8392018-11-21 02:50:56 -0800614* dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based
615* filtering enabled
616* @soc: core txrx main context
617* @ppdu_info: Structure for rx ppdu info
618* @status_nbuf: Qdf nbuf abstraction for linux skb
619* @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
620*
621* Return: none
622*/
623static inline void
624dp_rx_process_peer_based_pktlog(struct dp_soc *soc,
625 struct hal_rx_ppdu_info *ppdu_info,
626 qdf_nbuf_t status_nbuf, uint32_t mac_id)
627{
628 struct dp_peer *peer;
629 struct dp_ast_entry *ast_entry;
630 uint32_t ast_index;
631
632 ast_index = ppdu_info->rx_status.ast_index;
633 if (ast_index < (WLAN_UMAC_PSOC_MAX_PEERS * 2)) {
634 ast_entry = soc->ast_table[ast_index];
635 if (ast_entry) {
636 peer = ast_entry->peer;
637 if (peer && (peer->peer_ids[0] != HTT_INVALID_PEER)) {
638 if (peer->peer_based_pktlog_filter) {
639 dp_wdi_event_handler(
640 WDI_EVENT_RX_DESC, soc,
641 status_nbuf,
642 peer->peer_ids[0],
643 WDI_NO_VAL, mac_id);
644 }
645 }
646 }
647 }
648}
649
650/**
Kai Chen6eca1a62017-01-12 10:17:53 -0800651* dp_rx_mon_status_process_tlv() - Process status TLV in status
652* buffer on Rx status Queue posted by status SRNG processing.
653* @soc: core txrx main context
654* @mac_id: mac_id which is one of 3 mac_ids _ring
655*
656* Return: none
657*/
658static inline void
Karunakar Dasineni40555682017-03-26 22:44:39 -0700659dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
660 uint32_t quota)
661{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800662 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800663 struct hal_rx_ppdu_info *ppdu_info;
664 qdf_nbuf_t status_nbuf;
665 uint8_t *rx_tlv;
666 uint8_t *rx_tlv_start;
Kai Chenad516ae2017-09-08 18:35:47 -0700667 uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
Kai Chen52ef33f2019-03-05 18:33:40 -0800668 QDF_STATUS enh_log_status = QDF_STATUS_SUCCESS;
Kai Chen783e0382018-01-25 16:29:08 -0800669 struct cdp_pdev_mon_stats *rx_mon_stats;
sumedh baikady59a2d332018-05-22 01:50:38 -0700670 int smart_mesh_status;
Venkata Sharath Chandra Manchalacad74ad2019-01-28 11:36:47 -0800671 enum WDI_EVENT pktlog_mode = WDI_NO_VAL;
Kai Chen52ef33f2019-03-05 18:33:40 -0800672 bool nbuf_used;
673 uint32_t rx_enh_capture_mode;
674
Kai Chen6eca1a62017-01-12 10:17:53 -0800675
Kai Chen6eca1a62017-01-12 10:17:53 -0800676 ppdu_info = &pdev->ppdu_info;
Kai Chen783e0382018-01-25 16:29:08 -0800677 rx_mon_stats = &pdev->rx_mon_stats;
Kai Chen6eca1a62017-01-12 10:17:53 -0800678
679 if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
680 return;
681
Kai Chen52ef33f2019-03-05 18:33:40 -0800682 rx_enh_capture_mode = pdev->rx_enh_capture_mode;
683
Kai Chen6eca1a62017-01-12 10:17:53 -0800684 while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
685
686 status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
phadiman49757302018-12-18 16:13:59 +0530687
Kai Chen6eca1a62017-01-12 10:17:53 -0800688 rx_tlv = qdf_nbuf_data(status_nbuf);
689 rx_tlv_start = rx_tlv;
Kai Chen52ef33f2019-03-05 18:33:40 -0800690 nbuf_used = false;
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -0700691
Jeff Johnsona8edf332019-03-18 09:51:52 -0700692 if ((pdev->monitor_vdev) || (pdev->enhanced_stats_en) ||
Kai Chen52ef33f2019-03-05 18:33:40 -0800693 pdev->mcopy_mode ||
694 (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) {
Keyur Parekhfad6d082017-05-07 08:54:47 -0700695 do {
696 tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
Amir Patel57e7e052019-05-15 20:49:57 +0530697 ppdu_info, pdev->soc->hal_soc,
698 status_nbuf);
Kai Chen783e0382018-01-25 16:29:08 -0800699
700 dp_rx_mon_update_dbg_ppdu_stats(ppdu_info,
701 rx_mon_stats);
702
Kai Chen52ef33f2019-03-05 18:33:40 -0800703 dp_rx_mon_enh_capture_process(pdev, tlv_status,
704 status_nbuf, ppdu_info,
Karunakar Dasineniacc8b562019-05-07 07:00:24 -0700705 &nbuf_used);
Kai Chen52ef33f2019-03-05 18:33:40 -0800706
Keyur Parekhfad6d082017-05-07 08:54:47 -0700707 rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
Kai Chen6eca1a62017-01-12 10:17:53 -0800708
Keyur Parekhfad6d082017-05-07 08:54:47 -0700709 if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE)
710 break;
Kai Chen6eca1a62017-01-12 10:17:53 -0800711
Kai Chen52ef33f2019-03-05 18:33:40 -0800712 } while ((tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE) ||
713 (tlv_status == HAL_TLV_STATUS_HEADER) ||
Karunakar Dasineniacc8b562019-05-07 07:00:24 -0700714 (tlv_status == HAL_TLV_STATUS_MPDU_END) ||
715 (tlv_status == HAL_TLV_STATUS_MSDU_END));
Keyur Parekhfad6d082017-05-07 08:54:47 -0700716 }
Keyur Parekhc28f8392018-11-21 02:50:56 -0800717 if (pdev->dp_peer_based_pktlog) {
718 dp_rx_process_peer_based_pktlog(soc, ppdu_info,
719 status_nbuf, mac_id);
720 } else {
Venkata Sharath Chandra Manchalacad74ad2019-01-28 11:36:47 -0800721 if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL)
722 pktlog_mode = WDI_EVENT_RX_DESC;
723 else if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE)
724 pktlog_mode = WDI_EVENT_LITE_RX;
725
726 if (pktlog_mode != WDI_NO_VAL)
727 dp_wdi_event_handler(pktlog_mode, soc,
728 status_nbuf,
729 HTT_INVALID_PEER,
730 WDI_NO_VAL, mac_id);
Keyur Parekhc28f8392018-11-21 02:50:56 -0800731 }
Chaithanya Garrepalli3e4ac1c2018-12-12 20:50:45 +0530732
733 /* smart monitor vap and m_copy cannot co-exist */
sumedh baikady59a2d332018-05-22 01:50:38 -0700734 if (ppdu_info->rx_status.monitor_direct_used && pdev->neighbour_peers_added
735 && pdev->monitor_vdev) {
736 smart_mesh_status = dp_rx_handle_smart_mesh_mode(soc,
737 pdev, ppdu_info, status_nbuf);
738 if (smart_mesh_status)
739 qdf_nbuf_free(status_nbuf);
Amir Patel57e7e052019-05-15 20:49:57 +0530740 } else if (qdf_unlikely(pdev->mcopy_mode)) {
741 dp_rx_process_mcopy_mode(soc, pdev,
742 ppdu_info, tlv_status,
743 status_nbuf);
Kai Chen52ef33f2019-03-05 18:33:40 -0800744 } else if (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED) {
745 if (!nbuf_used)
746 qdf_nbuf_free(status_nbuf);
747
748 if (tlv_status == HAL_TLV_STATUS_PPDU_DONE)
749 enh_log_status =
750 dp_rx_handle_enh_capture(soc,
751 pdev, ppdu_info);
Chaithanya Garrepalli3e4ac1c2018-12-12 20:50:45 +0530752 } else {
sumedh baikady59a2d332018-05-22 01:50:38 -0700753 qdf_nbuf_free(status_nbuf);
Chaithanya Garrepalli3e4ac1c2018-12-12 20:50:45 +0530754 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800755
chenguo1b880462018-07-11 15:34:56 +0800756 if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) {
757 dp_rx_mon_deliver_non_std(soc, mac_id);
758 } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
Kai Chen783e0382018-01-25 16:29:08 -0800759 rx_mon_stats->status_ppdu_done++;
Soumya Bhat5c60deb2017-12-12 16:42:04 +0530760 if (pdev->enhanced_stats_en ||
sumedh baikady59a2d332018-05-22 01:50:38 -0700761 pdev->mcopy_mode || pdev->neighbour_peers_added)
Anish Nataraj38a29562017-08-18 19:41:17 +0530762 dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530763
nobelj1c31fee2018-03-21 11:47:05 -0700764 pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
765 dp_rx_mon_dest_process(soc, mac_id, quota);
Kai Chencbe4c342017-06-12 20:06:35 -0700766 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Kai Chen6eca1a62017-01-12 10:17:53 -0800767 }
768 }
769 return;
770}
771
772/*
773 * dp_rx_mon_status_srng_process() - Process monitor status ring
774 * post the status ring buffer to Rx status Queue for later
775 * processing when status ring is filled with status TLV.
776 * Allocate a new buffer to status ring if the filled buffer
777 * is posted.
778 *
779 * @soc: core txrx main context
780 * @mac_id: mac_id which is one of 3 mac_ids
781 * @quota: No. of ring entry that can be serviced in one shot.
782
783 * Return: uint32_t: No. of ring entry that is processed.
784 */
785static inline uint32_t
786dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
787 uint32_t quota)
788{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800789 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800790 void *hal_soc;
791 void *mon_status_srng;
792 void *rxdma_mon_status_ring_entry;
793 QDF_STATUS status;
794 uint32_t work_done = 0;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800795 int mac_for_pdev = dp_get_mac_id_for_mac(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800796
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800797 mon_status_srng = pdev->rxdma_mon_status_ring[mac_for_pdev].hal_srng;
Kai Chen6eca1a62017-01-12 10:17:53 -0800798
799 qdf_assert(mon_status_srng);
Houston Hoffman648a9182017-05-21 23:27:50 -0700800 if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
801
802 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Aditya Sathishded018e2018-07-02 16:25:21 +0530803 "%s %d : HAL Monitor Status Ring Init Failed -- %pK",
Houston Hoffman648a9182017-05-21 23:27:50 -0700804 __func__, __LINE__, mon_status_srng);
805 return work_done;
806 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800807
808 hal_soc = soc->hal_soc;
809
810 qdf_assert(hal_soc);
811
812 if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
813 goto done;
814
815 /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
816 * BUFFER_ADDR_INFO STRUCT
817 */
818 while (qdf_likely((rxdma_mon_status_ring_entry =
819 hal_srng_src_peek(hal_soc, mon_status_srng))
820 && quota--)) {
821 uint32_t rx_buf_cookie;
822 qdf_nbuf_t status_nbuf;
823 struct dp_rx_desc *rx_desc;
824 uint8_t *status_buf;
825 qdf_dma_addr_t paddr;
826 uint64_t buf_addr;
827
828 buf_addr =
829 (HAL_RX_BUFFER_ADDR_31_0_GET(
830 rxdma_mon_status_ring_entry) |
831 ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
832 rxdma_mon_status_ring_entry)) << 32));
833
834 if (qdf_likely(buf_addr)) {
835
836 rx_buf_cookie =
837 HAL_RX_BUF_COOKIE_GET(
838 rxdma_mon_status_ring_entry);
839 rx_desc = dp_rx_cookie_2_va_mon_status(soc,
840 rx_buf_cookie);
841
842 qdf_assert(rx_desc);
843
844 status_nbuf = rx_desc->nbuf;
845
846 qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
847 QDF_DMA_FROM_DEVICE);
848
849 status_buf = qdf_nbuf_data(status_nbuf);
850
851 status = hal_get_rx_status_done(status_buf);
852
853 if (status != QDF_STATUS_SUCCESS) {
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800854 uint32_t hp, tp;
Venkata Sharath Chandra Manchala443b9b42018-10-10 12:04:54 -0700855 hal_get_sw_hptp(hal_soc, mon_status_srng,
856 &tp, &hp);
Kai Chen6eca1a62017-01-12 10:17:53 -0800857 QDF_TRACE(QDF_MODULE_ID_DP,
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800858 QDF_TRACE_LEVEL_ERROR,
859 "[%s][%d] status not done - hp:%u, tp:%u",
860 __func__, __LINE__, hp, tp);
861 /* WAR for missing status: Skip status entry */
862 hal_srng_src_get_next(hal_soc, mon_status_srng);
863 continue;
Kai Chen6eca1a62017-01-12 10:17:53 -0800864 }
865 qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE);
866
867 qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
868 QDF_DMA_FROM_DEVICE);
869
870 /* Put the status_nbuf to queue */
871 qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
872
873 } else {
874 union dp_rx_desc_list_elem_t *desc_list = NULL;
875 union dp_rx_desc_list_elem_t *tail = NULL;
876 struct rx_desc_pool *rx_desc_pool;
877 uint32_t num_alloc_desc;
878
879 rx_desc_pool = &soc->rx_desc_status[mac_id];
880
881 num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
882 rx_desc_pool,
883 1,
884 &desc_list,
885 &tail);
phadimanebf4cde2019-01-28 17:50:37 +0530886 /*
887 * No free descriptors available
888 */
889 if (qdf_unlikely(num_alloc_desc == 0)) {
890 work_done++;
891 break;
892 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800893
894 rx_desc = &desc_list->rx_desc;
895 }
896
jinweic chenc3546322018-02-02 15:03:41 +0800897 status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -0800898
jinweic chenc3546322018-02-02 15:03:41 +0800899 /*
900 * qdf_nbuf alloc or map failed,
901 * free the dp rx desc to free list,
902 * fill in NULL dma address at current HP entry,
903 * keep HP in mon_status_ring unchanged,
904 * wait next time dp_rx_mon_status_srng_process
905 * to fill in buffer at current HP.
906 */
Jeff Johnsona8edf332019-03-18 09:51:52 -0700907 if (qdf_unlikely(!status_nbuf)) {
jinweic chenc3546322018-02-02 15:03:41 +0800908 union dp_rx_desc_list_elem_t *desc_list = NULL;
909 union dp_rx_desc_list_elem_t *tail = NULL;
910 struct rx_desc_pool *rx_desc_pool;
Kai Chen6eca1a62017-01-12 10:17:53 -0800911
jinweic chenc3546322018-02-02 15:03:41 +0800912 rx_desc_pool = &soc->rx_desc_status[mac_id];
Kai Chen6eca1a62017-01-12 10:17:53 -0800913
jinweic chenc3546322018-02-02 15:03:41 +0800914 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
915 "%s: fail to allocate or map qdf_nbuf",
916 __func__);
917 dp_rx_add_to_free_desc_list(&desc_list,
918 &tail, rx_desc);
919 dp_rx_add_desc_list_to_free_list(soc, &desc_list,
920 &tail, mac_id, rx_desc_pool);
921
922 hal_rxdma_buff_addr_info_set(
923 rxdma_mon_status_ring_entry,
924 0, 0, HAL_RX_BUF_RBM_SW3_BM);
925 work_done++;
926 break;
927 }
928
Kai Chen6eca1a62017-01-12 10:17:53 -0800929 paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
930
931 rx_desc->nbuf = status_nbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700932 rx_desc->in_use = 1;
Kai Chen6eca1a62017-01-12 10:17:53 -0800933
934 hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
935 paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
936
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800937 hal_srng_src_get_next(hal_soc, mon_status_srng);
Kai Chen6eca1a62017-01-12 10:17:53 -0800938 work_done++;
939 }
940done:
941
942 hal_srng_access_end(hal_soc, mon_status_srng);
943
944 return work_done;
945
946}
947/*
948 * dp_rx_mon_status_process() - Process monitor status ring and
949 * TLV in status ring.
950 *
951 * @soc: core txrx main context
952 * @mac_id: mac_id which is one of 3 mac_ids
953 * @quota: No. of ring entry that can be serviced in one shot.
954
955 * Return: uint32_t: No. of ring entry that is processed.
956 */
957static inline uint32_t
958dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
959 uint32_t work_done;
960
961 work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
Karunakar Dasineni40555682017-03-26 22:44:39 -0700962 quota -= work_done;
963 dp_rx_mon_status_process_tlv(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800964
965 return work_done;
966}
967/**
968 * dp_mon_process() - Main monitor mode processing roution.
969 * This call monitor status ring process then monitor
970 * destination ring process.
971 * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
972 * @soc: core txrx main context
973 * @mac_id: mac_id which is one of 3 mac_ids
974 * @quota: No. of status ring entry that can be serviced in one shot.
975
976 * Return: uint32_t: No. of ring entry that is processed.
977 */
978uint32_t
979dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
Karunakar Dasineni40555682017-03-26 22:44:39 -0700980 return dp_rx_mon_status_process(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800981}
Karunakar Dasineni40555682017-03-26 22:44:39 -0700982
Kai Chen6eca1a62017-01-12 10:17:53 -0800983/**
Venkata Sharath Chandra Manchala87479582018-08-01 12:45:34 -0700984 * dp_rx_pdev_mon_status_detach() - detach dp rx for status ring
Kai Chen6eca1a62017-01-12 10:17:53 -0800985 * @pdev: core txrx pdev context
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800986 * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
Kai Chen6eca1a62017-01-12 10:17:53 -0800987 *
988 * This function will detach DP RX status ring from
989 * main device context. will free DP Rx resources for
990 * status ring
991 *
992 * Return: QDF_STATUS_SUCCESS: success
993 * QDF_STATUS_E_RESOURCES: Error return
994 */
995QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800996dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id)
Kai Chen6eca1a62017-01-12 10:17:53 -0800997{
Kai Chen6eca1a62017-01-12 10:17:53 -0800998 struct dp_soc *soc = pdev->soc;
999 struct rx_desc_pool *rx_desc_pool;
1000
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -08001001 rx_desc_pool = &soc->rx_desc_status[mac_id];
phadiman449a2682019-02-20 14:00:00 +05301002 if (rx_desc_pool->pool_size != 0) {
1003 if (!dp_is_soc_reinit(soc))
Varun Reddy Yeturua7c21dc2019-05-16 14:03:46 -07001004 dp_rx_desc_nbuf_and_pool_free(soc, mac_id,
1005 rx_desc_pool);
phadiman449a2682019-02-20 14:00:00 +05301006 else
Varun Reddy Yeturua7c21dc2019-05-16 14:03:46 -07001007 dp_rx_desc_nbuf_free(soc, rx_desc_pool);
phadiman449a2682019-02-20 14:00:00 +05301008 }
Kai Chen6eca1a62017-01-12 10:17:53 -08001009
1010 return QDF_STATUS_SUCCESS;
1011}
1012
1013/*
1014 * dp_rx_buffers_replenish() - replenish monitor status ring with
1015 * rx nbufs called during dp rx
1016 * monitor status ring initialization
1017 *
1018 * @soc: core txrx main context
1019 * @mac_id: mac_id which is one of 3 mac_ids
1020 * @dp_rxdma_srng: dp monitor status circular ring
1021 * @rx_desc_pool; Pointer to Rx descriptor pool
1022 * @num_req_buffers: number of buffer to be replenished
1023 * @desc_list: list of descs if called from dp rx monitor status
1024 * process or NULL during dp rx initialization or
1025 * out of buffer interrupt
1026 * @tail: tail of descs list
1027 * @owner: who owns the nbuf (host, NSS etc...)
1028 * Return: return success or failure
1029 */
1030static inline
1031QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
1032 uint32_t mac_id,
1033 struct dp_srng *dp_rxdma_srng,
1034 struct rx_desc_pool *rx_desc_pool,
1035 uint32_t num_req_buffers,
1036 union dp_rx_desc_list_elem_t **desc_list,
1037 union dp_rx_desc_list_elem_t **tail,
1038 uint8_t owner)
1039{
1040 uint32_t num_alloc_desc;
1041 uint16_t num_desc_to_free = 0;
1042 uint32_t num_entries_avail;
jinweic chenc3546322018-02-02 15:03:41 +08001043 uint32_t count = 0;
Kai Chen6eca1a62017-01-12 10:17:53 -08001044 int sync_hw_ptr = 1;
1045 qdf_dma_addr_t paddr;
1046 qdf_nbuf_t rx_netbuf;
1047 void *rxdma_ring_entry;
1048 union dp_rx_desc_list_elem_t *next;
1049 void *rxdma_srng;
jinweic chenc3546322018-02-02 15:03:41 +08001050 struct dp_pdev *dp_pdev = dp_get_pdev_for_mac_id(dp_soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -08001051
1052 rxdma_srng = dp_rxdma_srng->hal_srng;
1053
1054 qdf_assert(rxdma_srng);
1055
Houston Hoffmanae850c62017-08-11 16:47:50 -07001056 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301057 "[%s][%d] requested %d buffers for replenish",
Kai Chen6eca1a62017-01-12 10:17:53 -08001058 __func__, __LINE__, num_req_buffers);
1059
1060 /*
1061 * if desc_list is NULL, allocate the descs from freelist
1062 */
1063 if (!(*desc_list)) {
1064
1065 num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
1066 rx_desc_pool,
1067 num_req_buffers,
1068 desc_list,
1069 tail);
1070
1071 if (!num_alloc_desc) {
1072 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
Aditya Sathishded018e2018-07-02 16:25:21 +05301073 "[%s][%d] no free rx_descs in freelist",
Kai Chen6eca1a62017-01-12 10:17:53 -08001074 __func__, __LINE__);
1075 return QDF_STATUS_E_NOMEM;
1076 }
1077
Houston Hoffmanae850c62017-08-11 16:47:50 -07001078 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301079 "[%s][%d] %d rx desc allocated", __func__, __LINE__,
Kai Chen6eca1a62017-01-12 10:17:53 -08001080 num_alloc_desc);
Houston Hoffmanae850c62017-08-11 16:47:50 -07001081
Kai Chen6eca1a62017-01-12 10:17:53 -08001082 num_req_buffers = num_alloc_desc;
1083 }
1084
1085 hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
1086 num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
1087 rxdma_srng, sync_hw_ptr);
1088
Houston Hoffmanae850c62017-08-11 16:47:50 -07001089 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301090 "[%s][%d] no of available entries in rxdma ring: %d",
Kai Chen6eca1a62017-01-12 10:17:53 -08001091 __func__, __LINE__, num_entries_avail);
1092
1093 if (num_entries_avail < num_req_buffers) {
1094 num_desc_to_free = num_req_buffers - num_entries_avail;
1095 num_req_buffers = num_entries_avail;
1096 }
1097
jinweic chenc3546322018-02-02 15:03:41 +08001098 while (count < num_req_buffers) {
1099 rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -08001100
jinweic chenc3546322018-02-02 15:03:41 +08001101 /*
1102 * qdf_nbuf alloc or map failed,
1103 * keep HP in mon_status_ring unchanged,
1104 * wait dp_rx_mon_status_srng_process
1105 * to fill in buffer at current HP.
1106 */
Jeff Johnsona8edf332019-03-18 09:51:52 -07001107 if (qdf_unlikely(!rx_netbuf)) {
jinweic chenc3546322018-02-02 15:03:41 +08001108 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
1109 "%s: qdf_nbuf allocate or map fail, count %d",
1110 __func__, count);
1111 break;
1112 }
Kai Chen6eca1a62017-01-12 10:17:53 -08001113
1114 paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
1115
1116 next = (*desc_list)->next;
sumedh baikadyeca2de62018-04-11 14:20:38 -07001117 rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc,
1118 rxdma_srng);
1119
Jeff Johnsona8edf332019-03-18 09:51:52 -07001120 if (qdf_unlikely(!rxdma_ring_entry)) {
sumedh baikadyeca2de62018-04-11 14:20:38 -07001121 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
Aditya Sathishded018e2018-07-02 16:25:21 +05301122 "[%s][%d] rxdma_ring_entry is NULL, count - %d",
sumedh baikadyeca2de62018-04-11 14:20:38 -07001123 __func__, __LINE__, count);
1124 qdf_nbuf_unmap_single(dp_soc->osdev, rx_netbuf,
Ankit Kumar0ae4abc2019-05-02 15:08:42 +05301125 QDF_DMA_FROM_DEVICE);
sumedh baikadyeca2de62018-04-11 14:20:38 -07001126 qdf_nbuf_free(rx_netbuf);
1127 break;
1128 }
Kai Chen6eca1a62017-01-12 10:17:53 -08001129
1130 (*desc_list)->rx_desc.nbuf = rx_netbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -07001131 (*desc_list)->rx_desc.in_use = 1;
jinweic chenc3546322018-02-02 15:03:41 +08001132 count++;
jinweic chenc3546322018-02-02 15:03:41 +08001133
Kai Chen6eca1a62017-01-12 10:17:53 -08001134 hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
1135 (*desc_list)->rx_desc.cookie, owner);
1136
Karunakar Dasineni40555682017-03-26 22:44:39 -07001137 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -07001138 "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
Aditya Sathishded018e2018-07-02 16:25:21 +05301139 paddr=%pK",
Kai Chen6eca1a62017-01-12 10:17:53 -08001140 __func__, __LINE__, &(*desc_list)->rx_desc,
1141 (*desc_list)->rx_desc.cookie, rx_netbuf,
jinweic chenc3546322018-02-02 15:03:41 +08001142 (void *)paddr);
Kai Chen6eca1a62017-01-12 10:17:53 -08001143
1144 *desc_list = next;
1145 }
1146
1147 hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
1148
Houston Hoffmanae850c62017-08-11 16:47:50 -07001149 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301150 "successfully replenished %d buffers", num_req_buffers);
Kai Chen6eca1a62017-01-12 10:17:53 -08001151
Houston Hoffmanae850c62017-08-11 16:47:50 -07001152 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Aditya Sathishded018e2018-07-02 16:25:21 +05301153 "%d rx desc added back to free list", num_desc_to_free);
Kai Chen6eca1a62017-01-12 10:17:53 -08001154
Kai Chen6eca1a62017-01-12 10:17:53 -08001155 /*
1156 * add any available free desc back to the free list
1157 */
1158 if (*desc_list) {
1159 dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
1160 mac_id, rx_desc_pool);
1161 }
1162
1163 return QDF_STATUS_SUCCESS;
1164}
1165/**
1166 * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
1167 * @pdev: core txrx pdev context
Venkata Sharath Chandra Manchala87479582018-08-01 12:45:34 -07001168 * @ring_id: ring number
Kai Chen6eca1a62017-01-12 10:17:53 -08001169 * This function will attach a DP RX monitor status ring into pDEV
1170 * and replenish monitor status ring with buffer.
1171 *
1172 * Return: QDF_STATUS_SUCCESS: success
1173 * QDF_STATUS_E_RESOURCES: Error return
1174 */
1175QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -08001176dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int ring_id) {
Kai Chen6eca1a62017-01-12 10:17:53 -08001177 struct dp_soc *soc = pdev->soc;
1178 union dp_rx_desc_list_elem_t *desc_list = NULL;
1179 union dp_rx_desc_list_elem_t *tail = NULL;
Mohit Khanna70514992018-11-12 18:39:03 -08001180 struct dp_srng *mon_status_ring;
1181 uint32_t num_entries;
Kai Chen52ef33f2019-03-05 18:33:40 -08001182 uint32_t i;
Kai Chen6eca1a62017-01-12 10:17:53 -08001183 struct rx_desc_pool *rx_desc_pool;
Ravi Joshia9ebe0a2017-06-17 16:43:02 -07001184 QDF_STATUS status;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -08001185 int mac_for_pdev = dp_get_mac_id_for_mac(soc, ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -08001186
Mohit Khanna70514992018-11-12 18:39:03 -08001187 mon_status_ring = &pdev->rxdma_mon_status_ring[mac_for_pdev];
Kai Chen6eca1a62017-01-12 10:17:53 -08001188
Mohit Khanna70514992018-11-12 18:39:03 -08001189 num_entries = mon_status_ring->num_entries;
Kai Chen6eca1a62017-01-12 10:17:53 -08001190
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -08001191 rx_desc_pool = &soc->rx_desc_status[ring_id];
Kai Chen6eca1a62017-01-12 10:17:53 -08001192
Mohit Khanna70514992018-11-12 18:39:03 -08001193 dp_info("Mon RX Status Pool[%d] entries=%d",
1194 ring_id, num_entries);
Kai Chen6eca1a62017-01-12 10:17:53 -08001195
Mohit Khanna70514992018-11-12 18:39:03 -08001196 status = dp_rx_desc_pool_alloc(soc, ring_id, num_entries + 1,
1197 rx_desc_pool);
1198 if (!QDF_IS_STATUS_SUCCESS(status))
Ravi Joshia9ebe0a2017-06-17 16:43:02 -07001199 return status;
Kai Chen6eca1a62017-01-12 10:17:53 -08001200
Mohit Khanna70514992018-11-12 18:39:03 -08001201 dp_debug("Mon RX Status Buffers Replenish ring_id=%d", ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -08001202
Mohit Khanna70514992018-11-12 18:39:03 -08001203 status = dp_rx_mon_status_buffers_replenish(soc, ring_id,
1204 mon_status_ring,
1205 rx_desc_pool,
1206 num_entries,
1207 &desc_list, &tail,
1208 HAL_RX_BUF_RBM_SW3_BM);
1209
1210 if (!QDF_IS_STATUS_SUCCESS(status))
Ravi Joshia9ebe0a2017-06-17 16:43:02 -07001211 return status;
Kai Chen6eca1a62017-01-12 10:17:53 -08001212
1213 qdf_nbuf_queue_init(&pdev->rx_status_q);
Amir Patel57e7e052019-05-15 20:49:57 +05301214 qdf_nbuf_queue_init(&pdev->rx_ppdu_buf_q);
Kai Chen6eca1a62017-01-12 10:17:53 -08001215
1216 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Kai Chen783e0382018-01-25 16:29:08 -08001217
Karunakar Dasineni40555682017-03-26 22:44:39 -07001218 qdf_mem_zero(&(pdev->ppdu_info.rx_status),
Mohit Khanna70514992018-11-12 18:39:03 -08001219 sizeof(pdev->ppdu_info.rx_status));
Kai Chen6eca1a62017-01-12 10:17:53 -08001220
Kai Chen783e0382018-01-25 16:29:08 -08001221 qdf_mem_zero(&pdev->rx_mon_stats,
1222 sizeof(pdev->rx_mon_stats));
1223
1224 dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info,
1225 &pdev->rx_mon_stats);
1226
Kai Chen52ef33f2019-03-05 18:33:40 -08001227 for (i = 0; i < MAX_MU_USERS; i++) {
1228 qdf_nbuf_queue_init(&pdev->mpdu_q[i]);
1229 pdev->is_mpdu_hdr[i] = true;
1230 }
1231 qdf_mem_zero(pdev->msdu_list, sizeof(pdev->msdu_list[MAX_MU_USERS]));
1232
1233 pdev->rx_enh_capture_mode = CDP_RX_ENH_CAPTURE_DISABLED;
1234
Kai Chen6eca1a62017-01-12 10:17:53 -08001235 return QDF_STATUS_SUCCESS;
1236}