blob: f269d09b3017193bdccff8b5b6f44cc964c831a7 [file] [log] [blame]
Kai Chen6eca1a62017-01-12 10:17:53 -08001/*
Pranita Solankeed0aba62018-01-12 19:14:31 +05302 * Copyright (c) 2017-2018 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 */
18#include "dp_types.h"
19#include "dp_rx.h"
20#include "dp_peer.h"
21#include "hal_rx.h"
22#include "hal_api.h"
23#include "qdf_trace.h"
24#include "qdf_nbuf.h"
25#include "hal_api_mon.h"
Kai Chen6eca1a62017-01-12 10:17:53 -080026#include "dp_rx_mon.h"
Keyur Parekhfad6d082017-05-07 08:54:47 -070027#include "dp_internal.h"
28#include "qdf_mem.h" /* qdf_mem_malloc,free */
Kai Chen6eca1a62017-01-12 10:17:53 -080029
Kai Chen6eca1a62017-01-12 10:17:53 -080030/**
Anish Nataraj38a29562017-08-18 19:41:17 +053031* dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
32* @soc: core txrx main context
33* @ppdu_info: ppdu info structure from ppdu ring
34* @ppdu_nbuf: qdf nbuf abstraction for linux skb
35*
36* Return: none
37*/
38#ifdef FEATURE_PERPKT_INFO
39static inline void
40dp_rx_populate_cdp_indication_ppdu(struct dp_soc *soc,
41 struct hal_rx_ppdu_info *ppdu_info,
42 qdf_nbuf_t ppdu_nbuf)
43{
44 struct dp_peer *peer;
45 struct dp_ast_entry *ast_entry;
46 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
47 uint32_t ast_index;
48
49 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
50
51 ast_index = ppdu_info->rx_status.ast_index;
52 if (ast_index > (WLAN_UMAC_PSOC_MAX_PEERS * 2)) {
53 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
54 return;
55 }
56
57 ast_entry = soc->ast_table[ast_index];
58 if (!ast_entry) {
59 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
60 return;
61 }
62 peer = ast_entry->peer;
63 if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
64 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
65 return;
66 }
67
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +053068 qdf_mem_copy(cdp_rx_ppdu->mac_addr,
69 peer->mac_addr.raw, DP_MAC_ADDR_LEN);
70 cdp_rx_ppdu->first_data_seq_ctrl =
71 ppdu_info->rx_status.first_data_seq_ctrl;
Anish Nataraj38a29562017-08-18 19:41:17 +053072 cdp_rx_ppdu->peer_id = peer->peer_ids[0];
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +053073 cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
Anish Nataraj38a29562017-08-18 19:41:17 +053074 cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
nobelj9ab76e22018-02-13 18:10:54 -080075 cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
Anish Nataraj38a29562017-08-18 19:41:17 +053076 cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
77 cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +053078 cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
79 cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
80 cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
Anish Nataraj38a29562017-08-18 19:41:17 +053081 cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
82 cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
Anish Nataraj072d8972018-01-09 18:23:33 +053083 cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
Anish Nataraj50347012018-03-06 21:12:45 +053084 cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
Anish Nataraj38a29562017-08-18 19:41:17 +053085 cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
Anish Nataraj28490c42018-01-19 19:34:54 +053086 cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
Anish Nataraj38a29562017-08-18 19:41:17 +053087 cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
Anish Nataraj57614da2018-02-07 23:04:24 +053088 cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
89 cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +053090 cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
91 cdp_rx_ppdu->udp_msdu_count +
92 cdp_rx_ppdu->other_msdu_count);
Pranita Solankeed0aba62018-01-12 19:14:31 +053093
Anish Nataraj57614da2018-02-07 23:04:24 +053094 cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
Pranita Solankeed0aba62018-01-12 19:14:31 +053095 if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
96 cdp_rx_ppdu->is_ampdu = 1;
97 else
98 cdp_rx_ppdu->is_ampdu = 0;
Anish Nataraj45d282c2017-12-30 01:03:38 +053099
100 cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
Anish Nataraj57614da2018-02-07 23:04:24 +0530101 cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
Anish Nataraj38a29562017-08-18 19:41:17 +0530102}
103#else
104static inline void
105dp_rx_populate_cdp_indication_ppdu(struct dp_soc *soc,
106 struct hal_rx_ppdu_info *ppdu_info,
107 qdf_nbuf_t ppdu_nbuf)
108{
109}
110#endif
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530111/**
112 * dp_rx_stats_update() - Update per-peer statistics
113 * @soc: Datapath SOC handle
114 * @peer: Datapath peer handle
115 * @ppdu: PPDU Descriptor
116 *
117 * Return: None
118 */
119#ifdef FEATURE_PERPKT_INFO
120static void dp_rx_stats_update(struct dp_soc *soc, struct dp_peer *peer,
121 struct cdp_rx_indication_ppdu *ppdu)
122{
123 struct dp_pdev *pdev = NULL;
Anish Nataraj28490c42018-01-19 19:34:54 +0530124 uint8_t mcs, preamble, ac = 0;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530125 uint16_t num_msdu;
126
127 mcs = ppdu->u.mcs;
128 preamble = ppdu->u.preamble;
129 num_msdu = ppdu->num_msdu;
130
131 if (!peer)
132 return;
133
134 pdev = peer->vdev->pdev;
135
Subhranil Choudhuryeea67382018-01-18 20:24:36 +0530136 dp_mark_peer_inact(peer, false);
137
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530138 if (soc->process_rx_status)
139 return;
Pranita Solankefc2ff392017-12-15 19:25:13 +0530140
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530141 DP_STATS_UPD(peer, rx.rssi, ppdu->rssi);
Pranita Solankeed0aba62018-01-12 19:14:31 +0530142
143 if ((preamble == DOT11_A) || (preamble == DOT11_B))
144 ppdu->u.nss = 1;
145
146 if (ppdu->u.nss)
147 DP_STATS_INC(peer, rx.nss[ppdu->u.nss - 1], num_msdu);
148
Pranita Solankea12b4b32017-11-20 23:04:14 +0530149 DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530150 DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
Anish Nataraj28490c42018-01-19 19:34:54 +0530151 DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type], num_msdu);
Pranita Solankea12b4b32017-11-20 23:04:14 +0530152 DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu, ppdu->is_ampdu);
153 DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu));
154 DP_STATS_UPD(peer, rx.rx_rate, mcs);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530155 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530156 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530157 ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
158 DP_STATS_INCC(peer,
159 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530160 ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530161 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530162 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530163 ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
164 DP_STATS_INCC(peer,
165 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530166 ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530167 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530168 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530169 ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
170 DP_STATS_INCC(peer,
171 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530172 ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530173 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530174 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530175 ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
176 DP_STATS_INCC(peer,
177 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
178 ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
179 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530180 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530181 ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
182 DP_STATS_INCC(peer,
183 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
184 ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
Anish Nataraj28490c42018-01-19 19:34:54 +0530185 /*
186 * If invalid TID, it could be a non-qos frame, hence do not update
187 * any AC counters
188 */
189 ac = TID_TO_WME_AC(ppdu->tid);
190 if (ppdu->tid != HAL_TID_INVALID)
191 DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
192
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530193 if (soc->cdp_soc.ol_ops->update_dp_stats) {
194 soc->cdp_soc.ol_ops->update_dp_stats(pdev->osif_pdev,
195 &peer->stats, ppdu->peer_id,
196 UPDATE_PEER_STATS);
Pranita Solankefc2ff392017-12-15 19:25:13 +0530197
198 dp_aggregate_vdev_stats(peer->vdev);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530199 }
200}
201#endif
Anish Nataraj38a29562017-08-18 19:41:17 +0530202
203/**
Soumya Bhat7422db82017-12-15 13:48:53 +0530204 * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
Pranita Solankefc2ff392017-12-15 19:25:13 +0530205 * @soc: core txrx main context
206 * @pdev: pdev strcuture
207 * @ppdu_info: structure for rx ppdu ring
208 *
209 * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
210 * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
Soumya Bhat7422db82017-12-15 13:48:53 +0530211 */
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530212#ifdef FEATURE_PERPKT_INFO
213static inline QDF_STATUS
Soumya Bhat7422db82017-12-15 13:48:53 +0530214dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530215 struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
216{
217 uint8_t size = 0;
218
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530219 if (ppdu_info->msdu_info.first_msdu_payload == NULL)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530220 return QDF_STATUS_SUCCESS;
221
Soumya Bhat2f54de22018-02-21 09:54:28 +0530222 if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530223 return QDF_STATUS_SUCCESS;
224
Soumya Bhat2f54de22018-02-21 09:54:28 +0530225 pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530226
Soumya Bhat2f54de22018-02-21 09:54:28 +0530227 /* Include 2 bytes of reserved space appended to the msdu payload */
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530228 size = (ppdu_info->msdu_info.first_msdu_payload -
229 qdf_nbuf_data(nbuf)) + 2;
230 ppdu_info->msdu_info.first_msdu_payload = NULL;
Soumya Bhat7422db82017-12-15 13:48:53 +0530231
232 if (qdf_nbuf_pull_head(nbuf, size) == NULL)
233 return QDF_STATUS_SUCCESS;
234
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530235 /* only retain RX MSDU payload in the skb */
236 qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
237 ppdu_info->msdu_info.payload_len);
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530238 dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
239 nbuf, HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id);
240 return QDF_STATUS_E_ALREADY;
241}
242#else
243static inline QDF_STATUS
Soumya Bhat7422db82017-12-15 13:48:53 +0530244dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530245 struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
246{
247 return QDF_STATUS_SUCCESS;
248}
249#endif
250
251
252/**
Anish Nataraj38a29562017-08-18 19:41:17 +0530253* dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
254* @soc: core txrx main context
255* @pdev: pdev strcuture
256* @ppdu_info: structure for rx ppdu ring
257*
258* Return: none
259*/
260#ifdef FEATURE_PERPKT_INFO
261static inline void
262dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
263 struct hal_rx_ppdu_info *ppdu_info)
264{
265 qdf_nbuf_t ppdu_nbuf;
266 struct dp_peer *peer;
267 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
268
Anish Nataraj28490c42018-01-19 19:34:54 +0530269 /*
270 * Do not allocate if fcs error,
271 * ast idx invalid / fctl invalid
272 */
Anish Nataraj28490c42018-01-19 19:34:54 +0530273 if (!ppdu_info->rx_status.frame_control_info_valid)
274 return;
275
276 if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
277 return;
278
279 if (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)
280 return;
281
Tallapragada Kalyana867edf2017-11-14 12:26:41 +0530282 ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
Anish Nataraj38a29562017-08-18 19:41:17 +0530283 sizeof(struct hal_rx_ppdu_info), 0, 0, FALSE);
284 if (ppdu_nbuf) {
285 dp_rx_populate_cdp_indication_ppdu(soc, ppdu_info, ppdu_nbuf);
286 qdf_nbuf_put_tail(ppdu_nbuf,
287 sizeof(struct cdp_rx_indication_ppdu));
288 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
289
290 peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id);
291 if (peer && cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530292 dp_rx_stats_update(soc, peer, cdp_rx_ppdu);
Anish Nataraj38a29562017-08-18 19:41:17 +0530293 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
294 ppdu_nbuf, cdp_rx_ppdu->peer_id,
295 WDI_NO_VAL, pdev->pdev_id);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530296 } else if (pdev->mcopy_mode) {
297 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
298 ppdu_nbuf, HTT_INVALID_PEER,
299 WDI_NO_VAL, pdev->pdev_id);
300 } else {
Anish Nataraj38a29562017-08-18 19:41:17 +0530301 qdf_nbuf_free(ppdu_nbuf);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530302 }
Anish Nataraj38a29562017-08-18 19:41:17 +0530303 }
304}
305#else
306static inline void
307dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
308 struct hal_rx_ppdu_info *ppdu_info)
309{
310}
311#endif
312
313/**
Kai Chen6eca1a62017-01-12 10:17:53 -0800314* dp_rx_mon_status_process_tlv() - Process status TLV in status
315* buffer on Rx status Queue posted by status SRNG processing.
316* @soc: core txrx main context
317* @mac_id: mac_id which is one of 3 mac_ids _ring
318*
319* Return: none
320*/
321static inline void
Karunakar Dasineni40555682017-03-26 22:44:39 -0700322dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
323 uint32_t quota)
324{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800325 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800326 struct hal_rx_ppdu_info *ppdu_info;
327 qdf_nbuf_t status_nbuf;
328 uint8_t *rx_tlv;
329 uint8_t *rx_tlv_start;
Kai Chenad516ae2017-09-08 18:35:47 -0700330 uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
Soumya Bhat2f54de22018-02-21 09:54:28 +0530331 QDF_STATUS m_copy_status = QDF_STATUS_SUCCESS;
Kai Chen6eca1a62017-01-12 10:17:53 -0800332
Kai Chen6eca1a62017-01-12 10:17:53 -0800333 ppdu_info = &pdev->ppdu_info;
334
335 if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
336 return;
337
338 while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
339
340 status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
341 rx_tlv = qdf_nbuf_data(status_nbuf);
342 rx_tlv_start = rx_tlv;
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -0700343
Keyur Parekhfad6d082017-05-07 08:54:47 -0700344#ifndef REMOVE_PKT_LOG
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -0700345#if defined(WDI_EVENT_ENABLE)
Keyur Parekhfad6d082017-05-07 08:54:47 -0700346 dp_wdi_event_handler(WDI_EVENT_RX_DESC, soc,
Keyur Parekhdb0fa142017-07-13 19:40:22 -0700347 status_nbuf, HTT_INVALID_PEER, WDI_NO_VAL, mac_id);
Keyur Parekhfad6d082017-05-07 08:54:47 -0700348#endif
349#endif
Soumya Bhat2f54de22018-02-21 09:54:28 +0530350 if ((pdev->monitor_vdev != NULL) || (pdev->enhanced_stats_en) ||
351 pdev->mcopy_mode) {
Kai Chen6eca1a62017-01-12 10:17:53 -0800352
Keyur Parekhfad6d082017-05-07 08:54:47 -0700353 do {
354 tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
355 ppdu_info);
356 rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
Kai Chen6eca1a62017-01-12 10:17:53 -0800357
Keyur Parekhfad6d082017-05-07 08:54:47 -0700358 if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE)
359 break;
Kai Chen6eca1a62017-01-12 10:17:53 -0800360
Keyur Parekhfad6d082017-05-07 08:54:47 -0700361 } while (tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE);
362 }
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530363
Soumya Bhat7422db82017-12-15 13:48:53 +0530364 if (pdev->mcopy_mode) {
Soumya Bhat2f54de22018-02-21 09:54:28 +0530365 m_copy_status = dp_rx_handle_mcopy_mode(soc,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530366 pdev, ppdu_info, status_nbuf);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530367 if (m_copy_status == QDF_STATUS_SUCCESS)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530368 qdf_nbuf_free(status_nbuf);
369 } else {
370 qdf_nbuf_free(status_nbuf);
371 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800372
373 if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
nobelj9ab76e22018-02-13 18:10:54 -0800374 pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
375 dp_rx_mon_dest_process(soc, mac_id, quota);
Soumya Bhat5c60deb2017-12-12 16:42:04 +0530376 if (pdev->enhanced_stats_en ||
Soumya Bhat7422db82017-12-15 13:48:53 +0530377 pdev->mcopy_mode)
Anish Nataraj38a29562017-08-18 19:41:17 +0530378 dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530379
Kai Chencbe4c342017-06-12 20:06:35 -0700380 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Karunakar Dasineni65b626e2017-12-18 22:17:29 -0800381 pdev->ppdu_info.com_info.last_ppdu_id =
382 pdev->ppdu_info.com_info.ppdu_id;
nobelj9ab76e22018-02-13 18:10:54 -0800383
384 qdf_mem_zero(&(pdev->ppdu_info.rx_status),
385 sizeof(pdev->ppdu_info.rx_status));
Kai Chen6eca1a62017-01-12 10:17:53 -0800386 }
387 }
388 return;
389}
390
391/*
392 * dp_rx_mon_status_srng_process() - Process monitor status ring
393 * post the status ring buffer to Rx status Queue for later
394 * processing when status ring is filled with status TLV.
395 * Allocate a new buffer to status ring if the filled buffer
396 * is posted.
397 *
398 * @soc: core txrx main context
399 * @mac_id: mac_id which is one of 3 mac_ids
400 * @quota: No. of ring entry that can be serviced in one shot.
401
402 * Return: uint32_t: No. of ring entry that is processed.
403 */
404static inline uint32_t
405dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
406 uint32_t quota)
407{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800408 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800409 void *hal_soc;
410 void *mon_status_srng;
411 void *rxdma_mon_status_ring_entry;
412 QDF_STATUS status;
413 uint32_t work_done = 0;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800414 int mac_for_pdev = dp_get_mac_id_for_mac(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800415
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800416 mon_status_srng = pdev->rxdma_mon_status_ring[mac_for_pdev].hal_srng;
Kai Chen6eca1a62017-01-12 10:17:53 -0800417
418 qdf_assert(mon_status_srng);
Houston Hoffman648a9182017-05-21 23:27:50 -0700419 if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
420
421 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Mohit Khanna9a6fdd52017-12-12 10:55:48 +0800422 "%s %d : HAL Monitor Status Ring Init Failed -- %pK\n",
Houston Hoffman648a9182017-05-21 23:27:50 -0700423 __func__, __LINE__, mon_status_srng);
424 return work_done;
425 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800426
427 hal_soc = soc->hal_soc;
428
429 qdf_assert(hal_soc);
430
431 if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
432 goto done;
433
434 /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
435 * BUFFER_ADDR_INFO STRUCT
436 */
437 while (qdf_likely((rxdma_mon_status_ring_entry =
438 hal_srng_src_peek(hal_soc, mon_status_srng))
439 && quota--)) {
440 uint32_t rx_buf_cookie;
441 qdf_nbuf_t status_nbuf;
442 struct dp_rx_desc *rx_desc;
443 uint8_t *status_buf;
444 qdf_dma_addr_t paddr;
445 uint64_t buf_addr;
446
447 buf_addr =
448 (HAL_RX_BUFFER_ADDR_31_0_GET(
449 rxdma_mon_status_ring_entry) |
450 ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
451 rxdma_mon_status_ring_entry)) << 32));
452
453 if (qdf_likely(buf_addr)) {
454
455 rx_buf_cookie =
456 HAL_RX_BUF_COOKIE_GET(
457 rxdma_mon_status_ring_entry);
458 rx_desc = dp_rx_cookie_2_va_mon_status(soc,
459 rx_buf_cookie);
460
461 qdf_assert(rx_desc);
462
463 status_nbuf = rx_desc->nbuf;
464
465 qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
466 QDF_DMA_FROM_DEVICE);
467
468 status_buf = qdf_nbuf_data(status_nbuf);
469
470 status = hal_get_rx_status_done(status_buf);
471
472 if (status != QDF_STATUS_SUCCESS) {
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800473 uint32_t hp, tp;
474 hal_api_get_tphp(hal_soc, mon_status_srng,
475 &tp, &hp);
Kai Chen6eca1a62017-01-12 10:17:53 -0800476 QDF_TRACE(QDF_MODULE_ID_DP,
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800477 QDF_TRACE_LEVEL_ERROR,
478 "[%s][%d] status not done - hp:%u, tp:%u",
479 __func__, __LINE__, hp, tp);
480 /* WAR for missing status: Skip status entry */
481 hal_srng_src_get_next(hal_soc, mon_status_srng);
482 continue;
Kai Chen6eca1a62017-01-12 10:17:53 -0800483 }
484 qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE);
485
486 qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
487 QDF_DMA_FROM_DEVICE);
488
489 /* Put the status_nbuf to queue */
490 qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
491
492 } else {
493 union dp_rx_desc_list_elem_t *desc_list = NULL;
494 union dp_rx_desc_list_elem_t *tail = NULL;
495 struct rx_desc_pool *rx_desc_pool;
496 uint32_t num_alloc_desc;
497
498 rx_desc_pool = &soc->rx_desc_status[mac_id];
499
500 num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
501 rx_desc_pool,
502 1,
503 &desc_list,
504 &tail);
505
506 rx_desc = &desc_list->rx_desc;
507 }
508
jinweic chenc3546322018-02-02 15:03:41 +0800509 status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -0800510
jinweic chenc3546322018-02-02 15:03:41 +0800511 /*
512 * qdf_nbuf alloc or map failed,
513 * free the dp rx desc to free list,
514 * fill in NULL dma address at current HP entry,
515 * keep HP in mon_status_ring unchanged,
516 * wait next time dp_rx_mon_status_srng_process
517 * to fill in buffer at current HP.
518 */
519 if (qdf_unlikely(status_nbuf == NULL)) {
520 union dp_rx_desc_list_elem_t *desc_list = NULL;
521 union dp_rx_desc_list_elem_t *tail = NULL;
522 struct rx_desc_pool *rx_desc_pool;
Kai Chen6eca1a62017-01-12 10:17:53 -0800523
jinweic chenc3546322018-02-02 15:03:41 +0800524 rx_desc_pool = &soc->rx_desc_status[mac_id];
Kai Chen6eca1a62017-01-12 10:17:53 -0800525
jinweic chenc3546322018-02-02 15:03:41 +0800526 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
527 "%s: fail to allocate or map qdf_nbuf",
528 __func__);
529 dp_rx_add_to_free_desc_list(&desc_list,
530 &tail, rx_desc);
531 dp_rx_add_desc_list_to_free_list(soc, &desc_list,
532 &tail, mac_id, rx_desc_pool);
533
534 hal_rxdma_buff_addr_info_set(
535 rxdma_mon_status_ring_entry,
536 0, 0, HAL_RX_BUF_RBM_SW3_BM);
537 work_done++;
538 break;
539 }
540
Kai Chen6eca1a62017-01-12 10:17:53 -0800541 paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
542
543 rx_desc->nbuf = status_nbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700544 rx_desc->in_use = 1;
Kai Chen6eca1a62017-01-12 10:17:53 -0800545
546 hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
547 paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
548
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800549 hal_srng_src_get_next(hal_soc, mon_status_srng);
Kai Chen6eca1a62017-01-12 10:17:53 -0800550 work_done++;
551 }
552done:
553
554 hal_srng_access_end(hal_soc, mon_status_srng);
555
556 return work_done;
557
558}
559/*
560 * dp_rx_mon_status_process() - Process monitor status ring and
561 * TLV in status ring.
562 *
563 * @soc: core txrx main context
564 * @mac_id: mac_id which is one of 3 mac_ids
565 * @quota: No. of ring entry that can be serviced in one shot.
566
567 * Return: uint32_t: No. of ring entry that is processed.
568 */
569static inline uint32_t
570dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
571 uint32_t work_done;
572
573 work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
Karunakar Dasineni40555682017-03-26 22:44:39 -0700574 quota -= work_done;
575 dp_rx_mon_status_process_tlv(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800576
577 return work_done;
578}
579/**
580 * dp_mon_process() - Main monitor mode processing roution.
581 * This call monitor status ring process then monitor
582 * destination ring process.
583 * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
584 * @soc: core txrx main context
585 * @mac_id: mac_id which is one of 3 mac_ids
586 * @quota: No. of status ring entry that can be serviced in one shot.
587
588 * Return: uint32_t: No. of ring entry that is processed.
589 */
590uint32_t
591dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
Karunakar Dasineni40555682017-03-26 22:44:39 -0700592 return dp_rx_mon_status_process(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800593}
Karunakar Dasineni40555682017-03-26 22:44:39 -0700594
Kai Chen6eca1a62017-01-12 10:17:53 -0800595/**
596 * dp_rx_pdev_mon_detach() - detach dp rx for status ring
597 * @pdev: core txrx pdev context
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800598 * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
Kai Chen6eca1a62017-01-12 10:17:53 -0800599 *
600 * This function will detach DP RX status ring from
601 * main device context. will free DP Rx resources for
602 * status ring
603 *
604 * Return: QDF_STATUS_SUCCESS: success
605 * QDF_STATUS_E_RESOURCES: Error return
606 */
607QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800608dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id)
Kai Chen6eca1a62017-01-12 10:17:53 -0800609{
Kai Chen6eca1a62017-01-12 10:17:53 -0800610 struct dp_soc *soc = pdev->soc;
611 struct rx_desc_pool *rx_desc_pool;
612
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800613 rx_desc_pool = &soc->rx_desc_status[mac_id];
614 if (rx_desc_pool->pool_size != 0)
615 dp_rx_desc_pool_free(soc, mac_id, rx_desc_pool);
Kai Chen6eca1a62017-01-12 10:17:53 -0800616
617 return QDF_STATUS_SUCCESS;
618}
619
620/*
621 * dp_rx_buffers_replenish() - replenish monitor status ring with
622 * rx nbufs called during dp rx
623 * monitor status ring initialization
624 *
625 * @soc: core txrx main context
626 * @mac_id: mac_id which is one of 3 mac_ids
627 * @dp_rxdma_srng: dp monitor status circular ring
628 * @rx_desc_pool; Pointer to Rx descriptor pool
629 * @num_req_buffers: number of buffer to be replenished
630 * @desc_list: list of descs if called from dp rx monitor status
631 * process or NULL during dp rx initialization or
632 * out of buffer interrupt
633 * @tail: tail of descs list
634 * @owner: who owns the nbuf (host, NSS etc...)
635 * Return: return success or failure
636 */
637static inline
638QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
639 uint32_t mac_id,
640 struct dp_srng *dp_rxdma_srng,
641 struct rx_desc_pool *rx_desc_pool,
642 uint32_t num_req_buffers,
643 union dp_rx_desc_list_elem_t **desc_list,
644 union dp_rx_desc_list_elem_t **tail,
645 uint8_t owner)
646{
647 uint32_t num_alloc_desc;
648 uint16_t num_desc_to_free = 0;
649 uint32_t num_entries_avail;
jinweic chenc3546322018-02-02 15:03:41 +0800650 uint32_t count = 0;
Kai Chen6eca1a62017-01-12 10:17:53 -0800651 int sync_hw_ptr = 1;
652 qdf_dma_addr_t paddr;
653 qdf_nbuf_t rx_netbuf;
654 void *rxdma_ring_entry;
655 union dp_rx_desc_list_elem_t *next;
656 void *rxdma_srng;
jinweic chenc3546322018-02-02 15:03:41 +0800657 struct dp_pdev *dp_pdev = dp_get_pdev_for_mac_id(dp_soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800658
659 rxdma_srng = dp_rxdma_srng->hal_srng;
660
661 qdf_assert(rxdma_srng);
662
Houston Hoffmanae850c62017-08-11 16:47:50 -0700663 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800664 "[%s][%d] requested %d buffers for replenish\n",
665 __func__, __LINE__, num_req_buffers);
666
667 /*
668 * if desc_list is NULL, allocate the descs from freelist
669 */
670 if (!(*desc_list)) {
671
672 num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
673 rx_desc_pool,
674 num_req_buffers,
675 desc_list,
676 tail);
677
678 if (!num_alloc_desc) {
679 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
680 "[%s][%d] no free rx_descs in freelist\n",
681 __func__, __LINE__);
682 return QDF_STATUS_E_NOMEM;
683 }
684
Houston Hoffmanae850c62017-08-11 16:47:50 -0700685 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800686 "[%s][%d] %d rx desc allocated\n", __func__, __LINE__,
687 num_alloc_desc);
Houston Hoffmanae850c62017-08-11 16:47:50 -0700688
Kai Chen6eca1a62017-01-12 10:17:53 -0800689 num_req_buffers = num_alloc_desc;
690 }
691
692 hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
693 num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
694 rxdma_srng, sync_hw_ptr);
695
Houston Hoffmanae850c62017-08-11 16:47:50 -0700696 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800697 "[%s][%d] no of availble entries in rxdma ring: %d\n",
698 __func__, __LINE__, num_entries_avail);
699
700 if (num_entries_avail < num_req_buffers) {
701 num_desc_to_free = num_req_buffers - num_entries_avail;
702 num_req_buffers = num_entries_avail;
703 }
704
jinweic chenc3546322018-02-02 15:03:41 +0800705 while (count < num_req_buffers) {
706 rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -0800707
jinweic chenc3546322018-02-02 15:03:41 +0800708 /*
709 * qdf_nbuf alloc or map failed,
710 * keep HP in mon_status_ring unchanged,
711 * wait dp_rx_mon_status_srng_process
712 * to fill in buffer at current HP.
713 */
714 if (qdf_unlikely(rx_netbuf == NULL)) {
715 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
716 "%s: qdf_nbuf allocate or map fail, count %d",
717 __func__, count);
718 break;
719 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800720
721 paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
722
723 next = (*desc_list)->next;
724
725 (*desc_list)->rx_desc.nbuf = rx_netbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700726 (*desc_list)->rx_desc.in_use = 1;
jinweic chenc3546322018-02-02 15:03:41 +0800727
728 count++;
729 rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc,
730 rxdma_srng);
731
Kai Chen6eca1a62017-01-12 10:17:53 -0800732 hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
733 (*desc_list)->rx_desc.cookie, owner);
734
Karunakar Dasineni40555682017-03-26 22:44:39 -0700735 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -0700736 "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
jinweic chenc3546322018-02-02 15:03:41 +0800737 paddr=%pK\n",
Kai Chen6eca1a62017-01-12 10:17:53 -0800738 __func__, __LINE__, &(*desc_list)->rx_desc,
739 (*desc_list)->rx_desc.cookie, rx_netbuf,
jinweic chenc3546322018-02-02 15:03:41 +0800740 (void *)paddr);
Kai Chen6eca1a62017-01-12 10:17:53 -0800741
742 *desc_list = next;
743 }
744
745 hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
746
Houston Hoffmanae850c62017-08-11 16:47:50 -0700747 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800748 "successfully replenished %d buffers\n", num_req_buffers);
749
Houston Hoffmanae850c62017-08-11 16:47:50 -0700750 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800751 "%d rx desc added back to free list\n", num_desc_to_free);
752
Houston Hoffmanae850c62017-08-11 16:47:50 -0700753 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -0700754 "[%s][%d] desc_list=%pK, tail=%pK rx_desc=%pK, cookie=%d\n",
Kai Chen6eca1a62017-01-12 10:17:53 -0800755 __func__, __LINE__, desc_list, tail, &(*desc_list)->rx_desc,
756 (*desc_list)->rx_desc.cookie);
757
758 /*
759 * add any available free desc back to the free list
760 */
761 if (*desc_list) {
762 dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
763 mac_id, rx_desc_pool);
764 }
765
766 return QDF_STATUS_SUCCESS;
767}
768/**
769 * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
770 * @pdev: core txrx pdev context
771 *
772 * This function will attach a DP RX monitor status ring into pDEV
773 * and replenish monitor status ring with buffer.
774 *
775 * Return: QDF_STATUS_SUCCESS: success
776 * QDF_STATUS_E_RESOURCES: Error return
777 */
778QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800779dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int ring_id) {
Kai Chen6eca1a62017-01-12 10:17:53 -0800780 struct dp_soc *soc = pdev->soc;
781 union dp_rx_desc_list_elem_t *desc_list = NULL;
782 union dp_rx_desc_list_elem_t *tail = NULL;
783 struct dp_srng *rxdma_srng;
784 uint32_t rxdma_entries;
785 struct rx_desc_pool *rx_desc_pool;
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700786 QDF_STATUS status;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800787 int mac_for_pdev = dp_get_mac_id_for_mac(soc, ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800788
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800789 rxdma_srng = &pdev->rxdma_mon_status_ring[mac_for_pdev];
Kai Chen6eca1a62017-01-12 10:17:53 -0800790
791 rxdma_entries = rxdma_srng->alloc_size/hal_srng_get_entrysize(
792 soc->hal_soc, RXDMA_MONITOR_STATUS);
793
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800794 rx_desc_pool = &soc->rx_desc_status[ring_id];
Kai Chen6eca1a62017-01-12 10:17:53 -0800795
Houston Hoffman41b912c2017-08-30 14:27:51 -0700796 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
Kai Chen6eca1a62017-01-12 10:17:53 -0800797 "%s: Mon RX Status Pool[%d] allocation size=%d\n",
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800798 __func__, ring_id, rxdma_entries);
Kai Chen6eca1a62017-01-12 10:17:53 -0800799
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800800 status = dp_rx_desc_pool_alloc(soc, ring_id, rxdma_entries+1,
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700801 rx_desc_pool);
Ravi Joshi73a05512017-07-10 13:53:32 -0700802 if (!QDF_IS_STATUS_SUCCESS(status)) {
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700803 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
804 "%s: dp_rx_desc_pool_alloc() failed \n", __func__);
805 return status;
806 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800807
Houston Hoffman41b912c2017-08-30 14:27:51 -0700808 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800809 "%s: Mon RX Status Buffers Replenish ring_id=%d\n",
810 __func__, ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800811
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800812 status = dp_rx_mon_status_buffers_replenish(soc, ring_id, rxdma_srng,
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700813 rx_desc_pool, rxdma_entries, &desc_list, &tail,
814 HAL_RX_BUF_RBM_SW3_BM);
Ravi Joshi73a05512017-07-10 13:53:32 -0700815 if (!QDF_IS_STATUS_SUCCESS(status)) {
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700816 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
817 "%s: dp_rx_buffers_replenish() failed \n", __func__);
818 return status;
819 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800820
821 qdf_nbuf_queue_init(&pdev->rx_status_q);
822
823 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Karunakar Dasineni65b626e2017-12-18 22:17:29 -0800824 pdev->ppdu_info.com_info.last_ppdu_id = 0;
Karunakar Dasineni40555682017-03-26 22:44:39 -0700825 qdf_mem_zero(&(pdev->ppdu_info.rx_status),
826 sizeof(pdev->ppdu_info.rx_status));
Kai Chen6eca1a62017-01-12 10:17:53 -0800827
828 return QDF_STATUS_SUCCESS;
829}