blob: 73e579fd40bcf94cdd2324f8227297da361fe0b3 [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 */
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
Kai Chen6eca1a62017-01-12 10:17:53 -080031/**
Anish Nataraj38a29562017-08-18 19:41:17 +053032* dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure
Soumya Bhat560f90c2018-03-30 13:53:26 +053033* @pdev: pdev ctx
Anish Nataraj38a29562017-08-18 19:41:17 +053034* @ppdu_info: ppdu info structure from ppdu ring
35* @ppdu_nbuf: qdf nbuf abstraction for linux skb
36*
37* Return: none
38*/
39#ifdef FEATURE_PERPKT_INFO
40static inline void
Soumya Bhat560f90c2018-03-30 13:53:26 +053041dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
Anish Nataraj38a29562017-08-18 19:41:17 +053042 struct hal_rx_ppdu_info *ppdu_info,
43 qdf_nbuf_t ppdu_nbuf)
44{
45 struct dp_peer *peer;
Soumya Bhat560f90c2018-03-30 13:53:26 +053046 struct dp_soc *soc = pdev->soc;
Anish Nataraj38a29562017-08-18 19:41:17 +053047 struct dp_ast_entry *ast_entry;
48 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
49 uint32_t ast_index;
50
51 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
52
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +053053 cdp_rx_ppdu->first_data_seq_ctrl =
54 ppdu_info->rx_status.first_data_seq_ctrl;
Anish Nataraj38a29562017-08-18 19:41:17 +053055 cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
nobelj9ab76e22018-02-13 18:10:54 -080056 cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
Anish Nataraj38a29562017-08-18 19:41:17 +053057 cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
58 cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +053059 cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
60 cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
61 cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
Anish Nataraj38a29562017-08-18 19:41:17 +053062 cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
63 cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
Keyur Parekh49cdc742018-05-09 10:59:03 -070064 if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) &&
65 (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC))
66 cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US;
67 else
68 cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
Anish Nataraj50347012018-03-06 21:12:45 +053069 cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
Anish Nataraj38a29562017-08-18 19:41:17 +053070 cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
Anish Nataraj28490c42018-01-19 19:34:54 +053071 cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
Anish Nataraj38a29562017-08-18 19:41:17 +053072 cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
Anish Nataraj57614da2018-02-07 23:04:24 +053073 cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
74 cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
nobeljd8039592018-03-13 16:59:42 -070075 cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +053076 cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
77 cdp_rx_ppdu->udp_msdu_count +
78 cdp_rx_ppdu->other_msdu_count);
Pranita Solankeed0aba62018-01-12 19:14:31 +053079
Anish Nataraj57614da2018-02-07 23:04:24 +053080 cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
Pranita Solankeed0aba62018-01-12 19:14:31 +053081 if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
82 cdp_rx_ppdu->is_ampdu = 1;
83 else
84 cdp_rx_ppdu->is_ampdu = 0;
Anish Nataraj45d282c2017-12-30 01:03:38 +053085
86 cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
Anish Nataraj57614da2018-02-07 23:04:24 +053087 cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
Soumya Bhat560f90c2018-03-30 13:53:26 +053088
89 ast_index = ppdu_info->rx_status.ast_index;
90 if (ast_index > (WLAN_UMAC_PSOC_MAX_PEERS * 2)) {
91 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
92 return;
93 }
94
95 ast_entry = soc->ast_table[ast_index];
96 if (!ast_entry) {
97 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
98 return;
99 }
100 peer = ast_entry->peer;
101 if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
102 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
103 return;
104 }
105
106 qdf_mem_copy(cdp_rx_ppdu->mac_addr,
107 peer->mac_addr.raw, DP_MAC_ADDR_LEN);
108 cdp_rx_ppdu->peer_id = peer->peer_ids[0];
109 cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
Anish Nataraj38a29562017-08-18 19:41:17 +0530110}
111#else
112static inline void
Soumya Bhat560f90c2018-03-30 13:53:26 +0530113dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
Anish Nataraj38a29562017-08-18 19:41:17 +0530114 struct hal_rx_ppdu_info *ppdu_info,
115 qdf_nbuf_t ppdu_nbuf)
116{
117}
118#endif
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530119/**
120 * dp_rx_stats_update() - Update per-peer statistics
121 * @soc: Datapath SOC handle
122 * @peer: Datapath peer handle
123 * @ppdu: PPDU Descriptor
124 *
125 * Return: None
126 */
127#ifdef FEATURE_PERPKT_INFO
128static void dp_rx_stats_update(struct dp_soc *soc, struct dp_peer *peer,
129 struct cdp_rx_indication_ppdu *ppdu)
130{
131 struct dp_pdev *pdev = NULL;
Anish Nataraj28490c42018-01-19 19:34:54 +0530132 uint8_t mcs, preamble, ac = 0;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530133 uint16_t num_msdu;
134
135 mcs = ppdu->u.mcs;
136 preamble = ppdu->u.preamble;
137 num_msdu = ppdu->num_msdu;
138
139 if (!peer)
140 return;
141
142 pdev = peer->vdev->pdev;
143
Subhranil Choudhuryeea67382018-01-18 20:24:36 +0530144 dp_mark_peer_inact(peer, false);
145
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530146 if (soc->process_rx_status)
147 return;
Pranita Solankefc2ff392017-12-15 19:25:13 +0530148
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530149 DP_STATS_UPD(peer, rx.rssi, ppdu->rssi);
Pranita Solankeed0aba62018-01-12 19:14:31 +0530150
151 if ((preamble == DOT11_A) || (preamble == DOT11_B))
152 ppdu->u.nss = 1;
153
154 if (ppdu->u.nss)
155 DP_STATS_INC(peer, rx.nss[ppdu->u.nss - 1], num_msdu);
156
Pranita Solankea12b4b32017-11-20 23:04:14 +0530157 DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530158 DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
Anish Nataraj28490c42018-01-19 19:34:54 +0530159 DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type], num_msdu);
Pranita Solankea12b4b32017-11-20 23:04:14 +0530160 DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu, ppdu->is_ampdu);
161 DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu));
162 DP_STATS_UPD(peer, rx.rx_rate, mcs);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530163 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530164 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530165 ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
166 DP_STATS_INCC(peer,
167 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530168 ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530169 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530170 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530171 ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B)));
172 DP_STATS_INCC(peer,
173 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530174 ((mcs < MAX_MCS_11B) && (preamble == DOT11_B)));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530175 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530176 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530177 ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N)));
178 DP_STATS_INCC(peer,
179 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530180 ((mcs < MAX_MCS_11A) && (preamble == DOT11_N)));
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530181 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530182 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530183 ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC)));
184 DP_STATS_INCC(peer,
185 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
186 ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
187 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530188 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530189 ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX)));
190 DP_STATS_INCC(peer,
191 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
192 ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
Anish Nataraj28490c42018-01-19 19:34:54 +0530193 /*
194 * If invalid TID, it could be a non-qos frame, hence do not update
195 * any AC counters
196 */
197 ac = TID_TO_WME_AC(ppdu->tid);
198 if (ppdu->tid != HAL_TID_INVALID)
199 DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
Amir Patel52c6b732018-08-03 12:13:22 +0530200 dp_peer_stats_notify(peer);
201 DP_STATS_UPD(peer, rx.last_rssi, ppdu->rssi);
Anish Nataraj28490c42018-01-19 19:34:54 +0530202
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530203 if (soc->cdp_soc.ol_ops->update_dp_stats) {
Akshay Kosigi1a9c6d12018-04-26 00:54:23 +0530204 soc->cdp_soc.ol_ops->update_dp_stats(pdev->ctrl_pdev,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530205 &peer->stats, ppdu->peer_id,
206 UPDATE_PEER_STATS);
Pranita Solankefc2ff392017-12-15 19:25:13 +0530207
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530208 }
209}
210#endif
Anish Nataraj38a29562017-08-18 19:41:17 +0530211
212/**
Soumya Bhat7422db82017-12-15 13:48:53 +0530213 * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
Pranita Solankefc2ff392017-12-15 19:25:13 +0530214 * @soc: core txrx main context
215 * @pdev: pdev strcuture
216 * @ppdu_info: structure for rx ppdu ring
217 *
218 * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
219 * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
Soumya Bhat7422db82017-12-15 13:48:53 +0530220 */
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530221#ifdef FEATURE_PERPKT_INFO
222static inline QDF_STATUS
Soumya Bhat7422db82017-12-15 13:48:53 +0530223dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530224 struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
225{
226 uint8_t size = 0;
227
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530228 if (ppdu_info->msdu_info.first_msdu_payload == NULL)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530229 return QDF_STATUS_SUCCESS;
230
Soumya Bhat2f54de22018-02-21 09:54:28 +0530231 if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530232 return QDF_STATUS_SUCCESS;
233
Soumya Bhat2f54de22018-02-21 09:54:28 +0530234 pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530235
Soumya Bhat2f54de22018-02-21 09:54:28 +0530236 /* Include 2 bytes of reserved space appended to the msdu payload */
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530237 size = (ppdu_info->msdu_info.first_msdu_payload -
238 qdf_nbuf_data(nbuf)) + 2;
239 ppdu_info->msdu_info.first_msdu_payload = NULL;
Soumya Bhat7422db82017-12-15 13:48:53 +0530240
241 if (qdf_nbuf_pull_head(nbuf, size) == NULL)
242 return QDF_STATUS_SUCCESS;
243
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530244 /* only retain RX MSDU payload in the skb */
245 qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
246 ppdu_info->msdu_info.payload_len);
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530247 dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
248 nbuf, HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id);
249 return QDF_STATUS_E_ALREADY;
250}
251#else
252static inline QDF_STATUS
Soumya Bhat7422db82017-12-15 13:48:53 +0530253dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530254 struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
255{
256 return QDF_STATUS_SUCCESS;
257}
258#endif
259
260
261/**
Anish Nataraj38a29562017-08-18 19:41:17 +0530262* dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
263* @soc: core txrx main context
264* @pdev: pdev strcuture
265* @ppdu_info: structure for rx ppdu ring
266*
267* Return: none
268*/
269#ifdef FEATURE_PERPKT_INFO
270static inline void
271dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
272 struct hal_rx_ppdu_info *ppdu_info)
273{
274 qdf_nbuf_t ppdu_nbuf;
275 struct dp_peer *peer;
276 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
277
Anish Nataraj28490c42018-01-19 19:34:54 +0530278 /*
279 * Do not allocate if fcs error,
280 * ast idx invalid / fctl invalid
281 */
Anish Nataraj28490c42018-01-19 19:34:54 +0530282 if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
283 return;
284
Chaithanya Garrepalli95fc62f2018-07-24 18:52:27 +0530285 if (ppdu_info->nac_info.fc_valid &&
286 ppdu_info->nac_info.to_ds_flag &&
287 ppdu_info->nac_info.mac_addr2_valid) {
288 struct dp_neighbour_peer *peer = NULL;
289 uint8_t rssi = ppdu_info->rx_status.rssi_comb;
290
291 qdf_spin_lock_bh(&pdev->neighbour_peer_mutex);
292 if (pdev->neighbour_peers_added) {
293 TAILQ_FOREACH(peer, &pdev->neighbour_peers_list,
294 neighbour_peer_list_elem) {
295 if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr,
296 &ppdu_info->nac_info.mac_addr2,
297 DP_MAC_ADDR_LEN)) {
298 peer->rssi = rssi;
299 break;
300 }
301 }
302 }
303 qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex);
304 }
305
Soumya Bhat560f90c2018-03-30 13:53:26 +0530306 if (!pdev->mcopy_mode) {
307 if (!ppdu_info->rx_status.frame_control_info_valid)
308 return;
Anish Nataraj28490c42018-01-19 19:34:54 +0530309
Soumya Bhat560f90c2018-03-30 13:53:26 +0530310 if (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)
311 return;
312 }
Tallapragada Kalyana867edf2017-11-14 12:26:41 +0530313 ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
Anish Nataraj38a29562017-08-18 19:41:17 +0530314 sizeof(struct hal_rx_ppdu_info), 0, 0, FALSE);
315 if (ppdu_nbuf) {
Soumya Bhat560f90c2018-03-30 13:53:26 +0530316 dp_rx_populate_cdp_indication_ppdu(pdev, ppdu_info, ppdu_nbuf);
Anish Nataraj38a29562017-08-18 19:41:17 +0530317 qdf_nbuf_put_tail(ppdu_nbuf,
318 sizeof(struct cdp_rx_indication_ppdu));
319 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
320
321 peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id);
322 if (peer && cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530323 dp_rx_stats_update(soc, peer, cdp_rx_ppdu);
Anish Nataraj38a29562017-08-18 19:41:17 +0530324 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
325 ppdu_nbuf, cdp_rx_ppdu->peer_id,
326 WDI_NO_VAL, pdev->pdev_id);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530327 } else if (pdev->mcopy_mode) {
328 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
329 ppdu_nbuf, HTT_INVALID_PEER,
330 WDI_NO_VAL, pdev->pdev_id);
331 } else {
Anish Nataraj38a29562017-08-18 19:41:17 +0530332 qdf_nbuf_free(ppdu_nbuf);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530333 }
Anish Nataraj38a29562017-08-18 19:41:17 +0530334 }
335}
336#else
337static inline void
338dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
339 struct hal_rx_ppdu_info *ppdu_info)
340{
341}
342#endif
343
344/**
Kai Chen6eca1a62017-01-12 10:17:53 -0800345* dp_rx_mon_status_process_tlv() - Process status TLV in status
346* buffer on Rx status Queue posted by status SRNG processing.
347* @soc: core txrx main context
348* @mac_id: mac_id which is one of 3 mac_ids _ring
349*
350* Return: none
351*/
352static inline void
Karunakar Dasineni40555682017-03-26 22:44:39 -0700353dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
354 uint32_t quota)
355{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800356 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800357 struct hal_rx_ppdu_info *ppdu_info;
358 qdf_nbuf_t status_nbuf;
359 uint8_t *rx_tlv;
360 uint8_t *rx_tlv_start;
Kai Chenad516ae2017-09-08 18:35:47 -0700361 uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
Soumya Bhat2f54de22018-02-21 09:54:28 +0530362 QDF_STATUS m_copy_status = QDF_STATUS_SUCCESS;
Kai Chen783e0382018-01-25 16:29:08 -0800363 struct cdp_pdev_mon_stats *rx_mon_stats;
Kai Chen6eca1a62017-01-12 10:17:53 -0800364
Kai Chen6eca1a62017-01-12 10:17:53 -0800365 ppdu_info = &pdev->ppdu_info;
Kai Chen783e0382018-01-25 16:29:08 -0800366 rx_mon_stats = &pdev->rx_mon_stats;
Kai Chen6eca1a62017-01-12 10:17:53 -0800367
368 if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
369 return;
370
371 while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
372
373 status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
374 rx_tlv = qdf_nbuf_data(status_nbuf);
375 rx_tlv_start = rx_tlv;
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -0700376
Keyur Parekhfad6d082017-05-07 08:54:47 -0700377#ifndef REMOVE_PKT_LOG
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -0700378#if defined(WDI_EVENT_ENABLE)
Keyur Parekhfad6d082017-05-07 08:54:47 -0700379 dp_wdi_event_handler(WDI_EVENT_RX_DESC, soc,
Keyur Parekhdb0fa142017-07-13 19:40:22 -0700380 status_nbuf, HTT_INVALID_PEER, WDI_NO_VAL, mac_id);
Keyur Parekhfad6d082017-05-07 08:54:47 -0700381#endif
382#endif
Soumya Bhat2f54de22018-02-21 09:54:28 +0530383 if ((pdev->monitor_vdev != NULL) || (pdev->enhanced_stats_en) ||
384 pdev->mcopy_mode) {
Kai Chen6eca1a62017-01-12 10:17:53 -0800385
Keyur Parekhfad6d082017-05-07 08:54:47 -0700386 do {
387 tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
Balamurugan Mahalingamd0159642018-07-11 15:02:29 +0530388 ppdu_info, pdev->soc->hal_soc);
Kai Chen783e0382018-01-25 16:29:08 -0800389
390 dp_rx_mon_update_dbg_ppdu_stats(ppdu_info,
391 rx_mon_stats);
392
Keyur Parekhfad6d082017-05-07 08:54:47 -0700393 rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
Kai Chen6eca1a62017-01-12 10:17:53 -0800394
Keyur Parekhfad6d082017-05-07 08:54:47 -0700395 if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE)
396 break;
Kai Chen6eca1a62017-01-12 10:17:53 -0800397
Keyur Parekhfad6d082017-05-07 08:54:47 -0700398 } while (tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE);
399 }
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530400
Soumya Bhat7422db82017-12-15 13:48:53 +0530401 if (pdev->mcopy_mode) {
Soumya Bhat2f54de22018-02-21 09:54:28 +0530402 m_copy_status = dp_rx_handle_mcopy_mode(soc,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530403 pdev, ppdu_info, status_nbuf);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530404 if (m_copy_status == QDF_STATUS_SUCCESS)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530405 qdf_nbuf_free(status_nbuf);
406 } else {
407 qdf_nbuf_free(status_nbuf);
408 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800409
chenguo1b880462018-07-11 15:34:56 +0800410 if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) {
411 dp_rx_mon_deliver_non_std(soc, mac_id);
412 } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
Kai Chen783e0382018-01-25 16:29:08 -0800413 rx_mon_stats->status_ppdu_done++;
Soumya Bhat5c60deb2017-12-12 16:42:04 +0530414 if (pdev->enhanced_stats_en ||
Soumya Bhat7422db82017-12-15 13:48:53 +0530415 pdev->mcopy_mode)
Anish Nataraj38a29562017-08-18 19:41:17 +0530416 dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530417
nobelj1c31fee2018-03-21 11:47:05 -0700418 pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
419 dp_rx_mon_dest_process(soc, mac_id, quota);
Kai Chencbe4c342017-06-12 20:06:35 -0700420 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Karunakar Dasineni65b626e2017-12-18 22:17:29 -0800421 pdev->ppdu_info.com_info.last_ppdu_id =
422 pdev->ppdu_info.com_info.ppdu_id;
Kai Chen6eca1a62017-01-12 10:17:53 -0800423 }
424 }
425 return;
426}
427
428/*
429 * dp_rx_mon_status_srng_process() - Process monitor status ring
430 * post the status ring buffer to Rx status Queue for later
431 * processing when status ring is filled with status TLV.
432 * Allocate a new buffer to status ring if the filled buffer
433 * is posted.
434 *
435 * @soc: core txrx main context
436 * @mac_id: mac_id which is one of 3 mac_ids
437 * @quota: No. of ring entry that can be serviced in one shot.
438
439 * Return: uint32_t: No. of ring entry that is processed.
440 */
441static inline uint32_t
442dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
443 uint32_t quota)
444{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800445 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800446 void *hal_soc;
447 void *mon_status_srng;
448 void *rxdma_mon_status_ring_entry;
449 QDF_STATUS status;
450 uint32_t work_done = 0;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800451 int mac_for_pdev = dp_get_mac_id_for_mac(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800452
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800453 mon_status_srng = pdev->rxdma_mon_status_ring[mac_for_pdev].hal_srng;
Kai Chen6eca1a62017-01-12 10:17:53 -0800454
455 qdf_assert(mon_status_srng);
Houston Hoffman648a9182017-05-21 23:27:50 -0700456 if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
457
458 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Mohit Khanna9a6fdd52017-12-12 10:55:48 +0800459 "%s %d : HAL Monitor Status Ring Init Failed -- %pK\n",
Houston Hoffman648a9182017-05-21 23:27:50 -0700460 __func__, __LINE__, mon_status_srng);
461 return work_done;
462 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800463
464 hal_soc = soc->hal_soc;
465
466 qdf_assert(hal_soc);
467
468 if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
469 goto done;
470
471 /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
472 * BUFFER_ADDR_INFO STRUCT
473 */
474 while (qdf_likely((rxdma_mon_status_ring_entry =
475 hal_srng_src_peek(hal_soc, mon_status_srng))
476 && quota--)) {
477 uint32_t rx_buf_cookie;
478 qdf_nbuf_t status_nbuf;
479 struct dp_rx_desc *rx_desc;
480 uint8_t *status_buf;
481 qdf_dma_addr_t paddr;
482 uint64_t buf_addr;
483
484 buf_addr =
485 (HAL_RX_BUFFER_ADDR_31_0_GET(
486 rxdma_mon_status_ring_entry) |
487 ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
488 rxdma_mon_status_ring_entry)) << 32));
489
490 if (qdf_likely(buf_addr)) {
491
492 rx_buf_cookie =
493 HAL_RX_BUF_COOKIE_GET(
494 rxdma_mon_status_ring_entry);
495 rx_desc = dp_rx_cookie_2_va_mon_status(soc,
496 rx_buf_cookie);
497
498 qdf_assert(rx_desc);
499
500 status_nbuf = rx_desc->nbuf;
501
502 qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
503 QDF_DMA_FROM_DEVICE);
504
505 status_buf = qdf_nbuf_data(status_nbuf);
506
507 status = hal_get_rx_status_done(status_buf);
508
509 if (status != QDF_STATUS_SUCCESS) {
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800510 uint32_t hp, tp;
511 hal_api_get_tphp(hal_soc, mon_status_srng,
512 &tp, &hp);
Kai Chen6eca1a62017-01-12 10:17:53 -0800513 QDF_TRACE(QDF_MODULE_ID_DP,
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800514 QDF_TRACE_LEVEL_ERROR,
515 "[%s][%d] status not done - hp:%u, tp:%u",
516 __func__, __LINE__, hp, tp);
517 /* WAR for missing status: Skip status entry */
518 hal_srng_src_get_next(hal_soc, mon_status_srng);
519 continue;
Kai Chen6eca1a62017-01-12 10:17:53 -0800520 }
521 qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE);
522
523 qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
524 QDF_DMA_FROM_DEVICE);
525
526 /* Put the status_nbuf to queue */
527 qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
528
529 } else {
530 union dp_rx_desc_list_elem_t *desc_list = NULL;
531 union dp_rx_desc_list_elem_t *tail = NULL;
532 struct rx_desc_pool *rx_desc_pool;
533 uint32_t num_alloc_desc;
534
535 rx_desc_pool = &soc->rx_desc_status[mac_id];
536
537 num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
538 rx_desc_pool,
539 1,
540 &desc_list,
541 &tail);
542
543 rx_desc = &desc_list->rx_desc;
544 }
545
jinweic chenc3546322018-02-02 15:03:41 +0800546 status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -0800547
jinweic chenc3546322018-02-02 15:03:41 +0800548 /*
549 * qdf_nbuf alloc or map failed,
550 * free the dp rx desc to free list,
551 * fill in NULL dma address at current HP entry,
552 * keep HP in mon_status_ring unchanged,
553 * wait next time dp_rx_mon_status_srng_process
554 * to fill in buffer at current HP.
555 */
556 if (qdf_unlikely(status_nbuf == NULL)) {
557 union dp_rx_desc_list_elem_t *desc_list = NULL;
558 union dp_rx_desc_list_elem_t *tail = NULL;
559 struct rx_desc_pool *rx_desc_pool;
Kai Chen6eca1a62017-01-12 10:17:53 -0800560
jinweic chenc3546322018-02-02 15:03:41 +0800561 rx_desc_pool = &soc->rx_desc_status[mac_id];
Kai Chen6eca1a62017-01-12 10:17:53 -0800562
jinweic chenc3546322018-02-02 15:03:41 +0800563 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
564 "%s: fail to allocate or map qdf_nbuf",
565 __func__);
566 dp_rx_add_to_free_desc_list(&desc_list,
567 &tail, rx_desc);
568 dp_rx_add_desc_list_to_free_list(soc, &desc_list,
569 &tail, mac_id, rx_desc_pool);
570
571 hal_rxdma_buff_addr_info_set(
572 rxdma_mon_status_ring_entry,
573 0, 0, HAL_RX_BUF_RBM_SW3_BM);
574 work_done++;
575 break;
576 }
577
Kai Chen6eca1a62017-01-12 10:17:53 -0800578 paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
579
580 rx_desc->nbuf = status_nbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700581 rx_desc->in_use = 1;
Kai Chen6eca1a62017-01-12 10:17:53 -0800582
583 hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
584 paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
585
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800586 hal_srng_src_get_next(hal_soc, mon_status_srng);
Kai Chen6eca1a62017-01-12 10:17:53 -0800587 work_done++;
588 }
589done:
590
591 hal_srng_access_end(hal_soc, mon_status_srng);
592
593 return work_done;
594
595}
596/*
597 * dp_rx_mon_status_process() - Process monitor status ring and
598 * TLV in status ring.
599 *
600 * @soc: core txrx main context
601 * @mac_id: mac_id which is one of 3 mac_ids
602 * @quota: No. of ring entry that can be serviced in one shot.
603
604 * Return: uint32_t: No. of ring entry that is processed.
605 */
606static inline uint32_t
607dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
608 uint32_t work_done;
609
610 work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
Karunakar Dasineni40555682017-03-26 22:44:39 -0700611 quota -= work_done;
612 dp_rx_mon_status_process_tlv(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800613
614 return work_done;
615}
616/**
617 * dp_mon_process() - Main monitor mode processing roution.
618 * This call monitor status ring process then monitor
619 * destination ring process.
620 * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
621 * @soc: core txrx main context
622 * @mac_id: mac_id which is one of 3 mac_ids
623 * @quota: No. of status ring entry that can be serviced in one shot.
624
625 * Return: uint32_t: No. of ring entry that is processed.
626 */
627uint32_t
628dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
Karunakar Dasineni40555682017-03-26 22:44:39 -0700629 return dp_rx_mon_status_process(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800630}
Karunakar Dasineni40555682017-03-26 22:44:39 -0700631
Kai Chen6eca1a62017-01-12 10:17:53 -0800632/**
633 * dp_rx_pdev_mon_detach() - detach dp rx for status ring
634 * @pdev: core txrx pdev context
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800635 * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
Kai Chen6eca1a62017-01-12 10:17:53 -0800636 *
637 * This function will detach DP RX status ring from
638 * main device context. will free DP Rx resources for
639 * status ring
640 *
641 * Return: QDF_STATUS_SUCCESS: success
642 * QDF_STATUS_E_RESOURCES: Error return
643 */
Venkata Sharath Chandra Manchala30e442b2018-06-26 12:29:24 -0700644#ifndef QCA_WIFI_QCA6390
Kai Chen6eca1a62017-01-12 10:17:53 -0800645QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800646dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id)
Kai Chen6eca1a62017-01-12 10:17:53 -0800647{
Kai Chen6eca1a62017-01-12 10:17:53 -0800648 struct dp_soc *soc = pdev->soc;
649 struct rx_desc_pool *rx_desc_pool;
650
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800651 rx_desc_pool = &soc->rx_desc_status[mac_id];
652 if (rx_desc_pool->pool_size != 0)
653 dp_rx_desc_pool_free(soc, mac_id, rx_desc_pool);
Kai Chen6eca1a62017-01-12 10:17:53 -0800654
655 return QDF_STATUS_SUCCESS;
656}
Venkata Sharath Chandra Manchala30e442b2018-06-26 12:29:24 -0700657#endif
Kai Chen6eca1a62017-01-12 10:17:53 -0800658
659/*
660 * dp_rx_buffers_replenish() - replenish monitor status ring with
661 * rx nbufs called during dp rx
662 * monitor status ring initialization
663 *
664 * @soc: core txrx main context
665 * @mac_id: mac_id which is one of 3 mac_ids
666 * @dp_rxdma_srng: dp monitor status circular ring
667 * @rx_desc_pool; Pointer to Rx descriptor pool
668 * @num_req_buffers: number of buffer to be replenished
669 * @desc_list: list of descs if called from dp rx monitor status
670 * process or NULL during dp rx initialization or
671 * out of buffer interrupt
672 * @tail: tail of descs list
673 * @owner: who owns the nbuf (host, NSS etc...)
674 * Return: return success or failure
675 */
676static inline
677QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
678 uint32_t mac_id,
679 struct dp_srng *dp_rxdma_srng,
680 struct rx_desc_pool *rx_desc_pool,
681 uint32_t num_req_buffers,
682 union dp_rx_desc_list_elem_t **desc_list,
683 union dp_rx_desc_list_elem_t **tail,
684 uint8_t owner)
685{
686 uint32_t num_alloc_desc;
687 uint16_t num_desc_to_free = 0;
688 uint32_t num_entries_avail;
jinweic chenc3546322018-02-02 15:03:41 +0800689 uint32_t count = 0;
Kai Chen6eca1a62017-01-12 10:17:53 -0800690 int sync_hw_ptr = 1;
691 qdf_dma_addr_t paddr;
692 qdf_nbuf_t rx_netbuf;
693 void *rxdma_ring_entry;
694 union dp_rx_desc_list_elem_t *next;
695 void *rxdma_srng;
jinweic chenc3546322018-02-02 15:03:41 +0800696 struct dp_pdev *dp_pdev = dp_get_pdev_for_mac_id(dp_soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800697
698 rxdma_srng = dp_rxdma_srng->hal_srng;
699
700 qdf_assert(rxdma_srng);
701
Houston Hoffmanae850c62017-08-11 16:47:50 -0700702 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800703 "[%s][%d] requested %d buffers for replenish\n",
704 __func__, __LINE__, num_req_buffers);
705
706 /*
707 * if desc_list is NULL, allocate the descs from freelist
708 */
709 if (!(*desc_list)) {
710
711 num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
712 rx_desc_pool,
713 num_req_buffers,
714 desc_list,
715 tail);
716
717 if (!num_alloc_desc) {
718 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
719 "[%s][%d] no free rx_descs in freelist\n",
720 __func__, __LINE__);
721 return QDF_STATUS_E_NOMEM;
722 }
723
Houston Hoffmanae850c62017-08-11 16:47:50 -0700724 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800725 "[%s][%d] %d rx desc allocated\n", __func__, __LINE__,
726 num_alloc_desc);
Houston Hoffmanae850c62017-08-11 16:47:50 -0700727
Kai Chen6eca1a62017-01-12 10:17:53 -0800728 num_req_buffers = num_alloc_desc;
729 }
730
731 hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
732 num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
733 rxdma_srng, sync_hw_ptr);
734
Houston Hoffmanae850c62017-08-11 16:47:50 -0700735 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnsonff2dfb22018-05-12 10:27:57 -0700736 "[%s][%d] no of available entries in rxdma ring: %d\n",
Kai Chen6eca1a62017-01-12 10:17:53 -0800737 __func__, __LINE__, num_entries_avail);
738
739 if (num_entries_avail < num_req_buffers) {
740 num_desc_to_free = num_req_buffers - num_entries_avail;
741 num_req_buffers = num_entries_avail;
742 }
743
jinweic chenc3546322018-02-02 15:03:41 +0800744 while (count < num_req_buffers) {
745 rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -0800746
jinweic chenc3546322018-02-02 15:03:41 +0800747 /*
748 * qdf_nbuf alloc or map failed,
749 * keep HP in mon_status_ring unchanged,
750 * wait dp_rx_mon_status_srng_process
751 * to fill in buffer at current HP.
752 */
753 if (qdf_unlikely(rx_netbuf == NULL)) {
754 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
755 "%s: qdf_nbuf allocate or map fail, count %d",
756 __func__, count);
757 break;
758 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800759
760 paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
761
762 next = (*desc_list)->next;
sumedh baikadyeca2de62018-04-11 14:20:38 -0700763 rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc,
764 rxdma_srng);
765
766 if (qdf_unlikely(rxdma_ring_entry == NULL)) {
767 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
768 "[%s][%d] rxdma_ring_entry is NULL, count - %d\n",
769 __func__, __LINE__, count);
770 qdf_nbuf_unmap_single(dp_soc->osdev, rx_netbuf,
771 QDF_DMA_BIDIRECTIONAL);
772 qdf_nbuf_free(rx_netbuf);
773 break;
774 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800775
776 (*desc_list)->rx_desc.nbuf = rx_netbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700777 (*desc_list)->rx_desc.in_use = 1;
jinweic chenc3546322018-02-02 15:03:41 +0800778 count++;
jinweic chenc3546322018-02-02 15:03:41 +0800779
Kai Chen6eca1a62017-01-12 10:17:53 -0800780 hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
781 (*desc_list)->rx_desc.cookie, owner);
782
Karunakar Dasineni40555682017-03-26 22:44:39 -0700783 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -0700784 "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
jinweic chenc3546322018-02-02 15:03:41 +0800785 paddr=%pK\n",
Kai Chen6eca1a62017-01-12 10:17:53 -0800786 __func__, __LINE__, &(*desc_list)->rx_desc,
787 (*desc_list)->rx_desc.cookie, rx_netbuf,
jinweic chenc3546322018-02-02 15:03:41 +0800788 (void *)paddr);
Kai Chen6eca1a62017-01-12 10:17:53 -0800789
790 *desc_list = next;
791 }
792
793 hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
794
Houston Hoffmanae850c62017-08-11 16:47:50 -0700795 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800796 "successfully replenished %d buffers\n", num_req_buffers);
797
Houston Hoffmanae850c62017-08-11 16:47:50 -0700798 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800799 "%d rx desc added back to free list\n", num_desc_to_free);
800
Houston Hoffmanae850c62017-08-11 16:47:50 -0700801 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -0700802 "[%s][%d] desc_list=%pK, tail=%pK rx_desc=%pK, cookie=%d\n",
Kai Chen6eca1a62017-01-12 10:17:53 -0800803 __func__, __LINE__, desc_list, tail, &(*desc_list)->rx_desc,
804 (*desc_list)->rx_desc.cookie);
805
806 /*
807 * add any available free desc back to the free list
808 */
809 if (*desc_list) {
810 dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
811 mac_id, rx_desc_pool);
812 }
813
814 return QDF_STATUS_SUCCESS;
815}
816/**
817 * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
818 * @pdev: core txrx pdev context
819 *
820 * This function will attach a DP RX monitor status ring into pDEV
821 * and replenish monitor status ring with buffer.
822 *
823 * Return: QDF_STATUS_SUCCESS: success
824 * QDF_STATUS_E_RESOURCES: Error return
825 */
Venkata Sharath Chandra Manchala30e442b2018-06-26 12:29:24 -0700826#ifndef QCA_WIFI_QCA6390
Kai Chen6eca1a62017-01-12 10:17:53 -0800827QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800828dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int ring_id) {
Kai Chen6eca1a62017-01-12 10:17:53 -0800829 struct dp_soc *soc = pdev->soc;
830 union dp_rx_desc_list_elem_t *desc_list = NULL;
831 union dp_rx_desc_list_elem_t *tail = NULL;
832 struct dp_srng *rxdma_srng;
833 uint32_t rxdma_entries;
834 struct rx_desc_pool *rx_desc_pool;
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700835 QDF_STATUS status;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800836 int mac_for_pdev = dp_get_mac_id_for_mac(soc, ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800837
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800838 rxdma_srng = &pdev->rxdma_mon_status_ring[mac_for_pdev];
Kai Chen6eca1a62017-01-12 10:17:53 -0800839
840 rxdma_entries = rxdma_srng->alloc_size/hal_srng_get_entrysize(
841 soc->hal_soc, RXDMA_MONITOR_STATUS);
842
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800843 rx_desc_pool = &soc->rx_desc_status[ring_id];
Kai Chen6eca1a62017-01-12 10:17:53 -0800844
Houston Hoffman41b912c2017-08-30 14:27:51 -0700845 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
Kai Chen6eca1a62017-01-12 10:17:53 -0800846 "%s: Mon RX Status Pool[%d] allocation size=%d\n",
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800847 __func__, ring_id, rxdma_entries);
Kai Chen6eca1a62017-01-12 10:17:53 -0800848
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800849 status = dp_rx_desc_pool_alloc(soc, ring_id, rxdma_entries+1,
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700850 rx_desc_pool);
Ravi Joshi73a05512017-07-10 13:53:32 -0700851 if (!QDF_IS_STATUS_SUCCESS(status)) {
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700852 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
853 "%s: dp_rx_desc_pool_alloc() failed \n", __func__);
854 return status;
855 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800856
Houston Hoffman41b912c2017-08-30 14:27:51 -0700857 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800858 "%s: Mon RX Status Buffers Replenish ring_id=%d\n",
859 __func__, ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800860
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800861 status = dp_rx_mon_status_buffers_replenish(soc, ring_id, rxdma_srng,
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700862 rx_desc_pool, rxdma_entries, &desc_list, &tail,
863 HAL_RX_BUF_RBM_SW3_BM);
Ravi Joshi73a05512017-07-10 13:53:32 -0700864 if (!QDF_IS_STATUS_SUCCESS(status)) {
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700865 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
866 "%s: dp_rx_buffers_replenish() failed \n", __func__);
867 return status;
868 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800869
870 qdf_nbuf_queue_init(&pdev->rx_status_q);
871
872 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Karunakar Dasineni65b626e2017-12-18 22:17:29 -0800873 pdev->ppdu_info.com_info.last_ppdu_id = 0;
Kai Chen783e0382018-01-25 16:29:08 -0800874
Karunakar Dasineni40555682017-03-26 22:44:39 -0700875 qdf_mem_zero(&(pdev->ppdu_info.rx_status),
876 sizeof(pdev->ppdu_info.rx_status));
Kai Chen6eca1a62017-01-12 10:17:53 -0800877
Kai Chen783e0382018-01-25 16:29:08 -0800878 qdf_mem_zero(&pdev->rx_mon_stats,
879 sizeof(pdev->rx_mon_stats));
880
881 dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info,
882 &pdev->rx_mon_stats);
883
Kai Chen6eca1a62017-01-12 10:17:53 -0800884 return QDF_STATUS_SUCCESS;
885}
Venkata Sharath Chandra Manchala30e442b2018-06-26 12:29:24 -0700886#endif