blob: edb3c2af36a30b61559abd3965d6b7b8a6457477 [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
Soumya Bhat560f90c2018-03-30 13:53:26 +053032* @pdev: pdev ctx
Anish Nataraj38a29562017-08-18 19:41:17 +053033* @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
Soumya Bhat560f90c2018-03-30 13:53:26 +053040dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
Anish Nataraj38a29562017-08-18 19:41:17 +053041 struct hal_rx_ppdu_info *ppdu_info,
42 qdf_nbuf_t ppdu_nbuf)
43{
44 struct dp_peer *peer;
Soumya Bhat560f90c2018-03-30 13:53:26 +053045 struct dp_soc *soc = pdev->soc;
Anish Nataraj38a29562017-08-18 19:41:17 +053046 struct dp_ast_entry *ast_entry;
47 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
48 uint32_t ast_index;
49
50 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
51
Pamidipati, Vijayd7eb83e2017-09-20 21:19:56 +053052 cdp_rx_ppdu->first_data_seq_ctrl =
53 ppdu_info->rx_status.first_data_seq_ctrl;
Anish Nataraj38a29562017-08-18 19:41:17 +053054 cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id;
nobelj9ab76e22018-02-13 18:10:54 -080055 cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len;
Anish Nataraj38a29562017-08-18 19:41:17 +053056 cdp_rx_ppdu->duration = ppdu_info->rx_status.duration;
57 cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +053058 cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count;
59 cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count;
60 cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count;
Anish Nataraj38a29562017-08-18 19:41:17 +053061 cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss;
62 cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs;
Anish Nataraj072d8972018-01-09 18:23:33 +053063 cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi;
Anish Nataraj50347012018-03-06 21:12:45 +053064 cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc;
Anish Nataraj38a29562017-08-18 19:41:17 +053065 cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type;
Anish Nataraj28490c42018-01-19 19:34:54 +053066 cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type;
Anish Nataraj38a29562017-08-18 19:41:17 +053067 cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb;
Anish Nataraj57614da2018-02-07 23:04:24 +053068 cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft;
69 cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +053070 cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count +
71 cdp_rx_ppdu->udp_msdu_count +
72 cdp_rx_ppdu->other_msdu_count);
Pranita Solankeed0aba62018-01-12 19:14:31 +053073
Anish Nataraj57614da2018-02-07 23:04:24 +053074 cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok;
Pranita Solankeed0aba62018-01-12 19:14:31 +053075 if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1)
76 cdp_rx_ppdu->is_ampdu = 1;
77 else
78 cdp_rx_ppdu->is_ampdu = 0;
Anish Nataraj45d282c2017-12-30 01:03:38 +053079
80 cdp_rx_ppdu->tid = ppdu_info->rx_status.tid;
Anish Nataraj57614da2018-02-07 23:04:24 +053081 cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate;
Soumya Bhat560f90c2018-03-30 13:53:26 +053082
83 ast_index = ppdu_info->rx_status.ast_index;
84 if (ast_index > (WLAN_UMAC_PSOC_MAX_PEERS * 2)) {
85 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
86 return;
87 }
88
89 ast_entry = soc->ast_table[ast_index];
90 if (!ast_entry) {
91 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
92 return;
93 }
94 peer = ast_entry->peer;
95 if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) {
96 cdp_rx_ppdu->peer_id = HTT_INVALID_PEER;
97 return;
98 }
99
100 qdf_mem_copy(cdp_rx_ppdu->mac_addr,
101 peer->mac_addr.raw, DP_MAC_ADDR_LEN);
102 cdp_rx_ppdu->peer_id = peer->peer_ids[0];
103 cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id;
Anish Nataraj38a29562017-08-18 19:41:17 +0530104}
105#else
106static inline void
Soumya Bhat560f90c2018-03-30 13:53:26 +0530107dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev,
Anish Nataraj38a29562017-08-18 19:41:17 +0530108 struct hal_rx_ppdu_info *ppdu_info,
109 qdf_nbuf_t ppdu_nbuf)
110{
111}
112#endif
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530113/**
114 * dp_rx_stats_update() - Update per-peer statistics
115 * @soc: Datapath SOC handle
116 * @peer: Datapath peer handle
117 * @ppdu: PPDU Descriptor
118 *
119 * Return: None
120 */
121#ifdef FEATURE_PERPKT_INFO
122static void dp_rx_stats_update(struct dp_soc *soc, struct dp_peer *peer,
123 struct cdp_rx_indication_ppdu *ppdu)
124{
125 struct dp_pdev *pdev = NULL;
Anish Nataraj28490c42018-01-19 19:34:54 +0530126 uint8_t mcs, preamble, ac = 0;
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530127 uint16_t num_msdu;
128
129 mcs = ppdu->u.mcs;
130 preamble = ppdu->u.preamble;
131 num_msdu = ppdu->num_msdu;
132
133 if (!peer)
134 return;
135
136 pdev = peer->vdev->pdev;
137
Subhranil Choudhuryeea67382018-01-18 20:24:36 +0530138 dp_mark_peer_inact(peer, false);
139
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530140 if (soc->process_rx_status)
141 return;
Pranita Solankefc2ff392017-12-15 19:25:13 +0530142
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530143 DP_STATS_UPD(peer, rx.rssi, ppdu->rssi);
Pranita Solankeed0aba62018-01-12 19:14:31 +0530144
145 if ((preamble == DOT11_A) || (preamble == DOT11_B))
146 ppdu->u.nss = 1;
147
148 if (ppdu->u.nss)
149 DP_STATS_INC(peer, rx.nss[ppdu->u.nss - 1], num_msdu);
150
Pranita Solankea12b4b32017-11-20 23:04:14 +0530151 DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530152 DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu);
Anish Nataraj28490c42018-01-19 19:34:54 +0530153 DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type], num_msdu);
Pranita Solankea12b4b32017-11-20 23:04:14 +0530154 DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu, ppdu->is_ampdu);
155 DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu));
156 DP_STATS_UPD(peer, rx.rx_rate, mcs);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530157 DP_STATS_INCC(peer,
Pranita Solankeed0aba62018-01-12 19:14:31 +0530158 rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu,
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530159 ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A)));
160 DP_STATS_INCC(peer,
161 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
Pranita Solankea12b4b32017-11-20 23:04:14 +0530162 ((mcs < MAX_MCS_11A) && (preamble == DOT11_A)));
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_11B) && (preamble == DOT11_B)));
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_11B) && (preamble == DOT11_B)));
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_11A) && (preamble == DOT11_N)));
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_11A) && (preamble == DOT11_N)));
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_11AC) && (preamble == DOT11_AC)));
178 DP_STATS_INCC(peer,
179 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
180 ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC)));
181 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 - 1)) && (preamble == DOT11_AX)));
184 DP_STATS_INCC(peer,
185 rx.pkt_type[preamble].mcs_count[mcs], num_msdu,
186 ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX)));
Anish Nataraj28490c42018-01-19 19:34:54 +0530187 /*
188 * If invalid TID, it could be a non-qos frame, hence do not update
189 * any AC counters
190 */
191 ac = TID_TO_WME_AC(ppdu->tid);
192 if (ppdu->tid != HAL_TID_INVALID)
193 DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu);
194
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530195 if (soc->cdp_soc.ol_ops->update_dp_stats) {
196 soc->cdp_soc.ol_ops->update_dp_stats(pdev->osif_pdev,
197 &peer->stats, ppdu->peer_id,
198 UPDATE_PEER_STATS);
Pranita Solankefc2ff392017-12-15 19:25:13 +0530199
200 dp_aggregate_vdev_stats(peer->vdev);
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530201 }
202}
203#endif
Anish Nataraj38a29562017-08-18 19:41:17 +0530204
205/**
Soumya Bhat7422db82017-12-15 13:48:53 +0530206 * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload
Pranita Solankefc2ff392017-12-15 19:25:13 +0530207 * @soc: core txrx main context
208 * @pdev: pdev strcuture
209 * @ppdu_info: structure for rx ppdu ring
210 *
211 * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller
212 * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller
Soumya Bhat7422db82017-12-15 13:48:53 +0530213 */
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530214#ifdef FEATURE_PERPKT_INFO
215static inline QDF_STATUS
Soumya Bhat7422db82017-12-15 13:48:53 +0530216dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530217 struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
218{
219 uint8_t size = 0;
220
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530221 if (ppdu_info->msdu_info.first_msdu_payload == NULL)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530222 return QDF_STATUS_SUCCESS;
223
Soumya Bhat2f54de22018-02-21 09:54:28 +0530224 if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530225 return QDF_STATUS_SUCCESS;
226
Soumya Bhat2f54de22018-02-21 09:54:28 +0530227 pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id;
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530228
Soumya Bhat2f54de22018-02-21 09:54:28 +0530229 /* Include 2 bytes of reserved space appended to the msdu payload */
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530230 size = (ppdu_info->msdu_info.first_msdu_payload -
231 qdf_nbuf_data(nbuf)) + 2;
232 ppdu_info->msdu_info.first_msdu_payload = NULL;
Soumya Bhat7422db82017-12-15 13:48:53 +0530233
234 if (qdf_nbuf_pull_head(nbuf, size) == NULL)
235 return QDF_STATUS_SUCCESS;
236
Soumya Bhatdc8aca82018-03-13 14:10:24 +0530237 /* only retain RX MSDU payload in the skb */
238 qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) -
239 ppdu_info->msdu_info.payload_len);
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530240 dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc,
241 nbuf, HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id);
242 return QDF_STATUS_E_ALREADY;
243}
244#else
245static inline QDF_STATUS
Soumya Bhat7422db82017-12-15 13:48:53 +0530246dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530247 struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf)
248{
249 return QDF_STATUS_SUCCESS;
250}
251#endif
252
253
254/**
Anish Nataraj38a29562017-08-18 19:41:17 +0530255* dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer
256* @soc: core txrx main context
257* @pdev: pdev strcuture
258* @ppdu_info: structure for rx ppdu ring
259*
260* Return: none
261*/
262#ifdef FEATURE_PERPKT_INFO
263static inline void
264dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
265 struct hal_rx_ppdu_info *ppdu_info)
266{
267 qdf_nbuf_t ppdu_nbuf;
268 struct dp_peer *peer;
269 struct cdp_rx_indication_ppdu *cdp_rx_ppdu;
270
Anish Nataraj28490c42018-01-19 19:34:54 +0530271 /*
272 * Do not allocate if fcs error,
273 * ast idx invalid / fctl invalid
274 */
Anish Nataraj28490c42018-01-19 19:34:54 +0530275 if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0)
276 return;
277
Soumya Bhat560f90c2018-03-30 13:53:26 +0530278 if (!pdev->mcopy_mode) {
279 if (!ppdu_info->rx_status.frame_control_info_valid)
280 return;
Anish Nataraj28490c42018-01-19 19:34:54 +0530281
Soumya Bhat560f90c2018-03-30 13:53:26 +0530282 if (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID)
283 return;
284 }
Tallapragada Kalyana867edf2017-11-14 12:26:41 +0530285 ppdu_nbuf = qdf_nbuf_alloc(soc->osdev,
Anish Nataraj38a29562017-08-18 19:41:17 +0530286 sizeof(struct hal_rx_ppdu_info), 0, 0, FALSE);
287 if (ppdu_nbuf) {
Soumya Bhat560f90c2018-03-30 13:53:26 +0530288 dp_rx_populate_cdp_indication_ppdu(pdev, ppdu_info, ppdu_nbuf);
Anish Nataraj38a29562017-08-18 19:41:17 +0530289 qdf_nbuf_put_tail(ppdu_nbuf,
290 sizeof(struct cdp_rx_indication_ppdu));
291 cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data;
292
293 peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id);
294 if (peer && cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) {
Pamidipati, Vijay57a435a2017-10-17 11:03:39 +0530295 dp_rx_stats_update(soc, peer, cdp_rx_ppdu);
Anish Nataraj38a29562017-08-18 19:41:17 +0530296 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
297 ppdu_nbuf, cdp_rx_ppdu->peer_id,
298 WDI_NO_VAL, pdev->pdev_id);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530299 } else if (pdev->mcopy_mode) {
300 dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc,
301 ppdu_nbuf, HTT_INVALID_PEER,
302 WDI_NO_VAL, pdev->pdev_id);
303 } else {
Anish Nataraj38a29562017-08-18 19:41:17 +0530304 qdf_nbuf_free(ppdu_nbuf);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530305 }
Anish Nataraj38a29562017-08-18 19:41:17 +0530306 }
307}
308#else
309static inline void
310dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev,
311 struct hal_rx_ppdu_info *ppdu_info)
312{
313}
314#endif
315
316/**
Kai Chen6eca1a62017-01-12 10:17:53 -0800317* dp_rx_mon_status_process_tlv() - Process status TLV in status
318* buffer on Rx status Queue posted by status SRNG processing.
319* @soc: core txrx main context
320* @mac_id: mac_id which is one of 3 mac_ids _ring
321*
322* Return: none
323*/
324static inline void
Karunakar Dasineni40555682017-03-26 22:44:39 -0700325dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id,
326 uint32_t quota)
327{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800328 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800329 struct hal_rx_ppdu_info *ppdu_info;
330 qdf_nbuf_t status_nbuf;
331 uint8_t *rx_tlv;
332 uint8_t *rx_tlv_start;
Kai Chenad516ae2017-09-08 18:35:47 -0700333 uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE;
Soumya Bhat2f54de22018-02-21 09:54:28 +0530334 QDF_STATUS m_copy_status = QDF_STATUS_SUCCESS;
Kai Chen6eca1a62017-01-12 10:17:53 -0800335
Kai Chen6eca1a62017-01-12 10:17:53 -0800336 ppdu_info = &pdev->ppdu_info;
337
338 if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START)
339 return;
340
341 while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) {
342
343 status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q);
344 rx_tlv = qdf_nbuf_data(status_nbuf);
345 rx_tlv_start = rx_tlv;
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -0700346
Keyur Parekhfad6d082017-05-07 08:54:47 -0700347#ifndef REMOVE_PKT_LOG
Venkata Sharath Chandra Manchala5a6f4292017-11-03 14:57:41 -0700348#if defined(WDI_EVENT_ENABLE)
Keyur Parekhfad6d082017-05-07 08:54:47 -0700349 dp_wdi_event_handler(WDI_EVENT_RX_DESC, soc,
Keyur Parekhdb0fa142017-07-13 19:40:22 -0700350 status_nbuf, HTT_INVALID_PEER, WDI_NO_VAL, mac_id);
Keyur Parekhfad6d082017-05-07 08:54:47 -0700351#endif
352#endif
Soumya Bhat2f54de22018-02-21 09:54:28 +0530353 if ((pdev->monitor_vdev != NULL) || (pdev->enhanced_stats_en) ||
354 pdev->mcopy_mode) {
Kai Chen6eca1a62017-01-12 10:17:53 -0800355
Keyur Parekhfad6d082017-05-07 08:54:47 -0700356 do {
357 tlv_status = hal_rx_status_get_tlv_info(rx_tlv,
358 ppdu_info);
359 rx_tlv = hal_rx_status_get_next_tlv(rx_tlv);
Kai Chen6eca1a62017-01-12 10:17:53 -0800360
Keyur Parekhfad6d082017-05-07 08:54:47 -0700361 if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE)
362 break;
Kai Chen6eca1a62017-01-12 10:17:53 -0800363
Keyur Parekhfad6d082017-05-07 08:54:47 -0700364 } while (tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE);
365 }
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530366
Soumya Bhat7422db82017-12-15 13:48:53 +0530367 if (pdev->mcopy_mode) {
Soumya Bhat2f54de22018-02-21 09:54:28 +0530368 m_copy_status = dp_rx_handle_mcopy_mode(soc,
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530369 pdev, ppdu_info, status_nbuf);
Soumya Bhat2f54de22018-02-21 09:54:28 +0530370 if (m_copy_status == QDF_STATUS_SUCCESS)
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530371 qdf_nbuf_free(status_nbuf);
372 } else {
373 qdf_nbuf_free(status_nbuf);
374 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800375
376 if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) {
nobelj9ab76e22018-02-13 18:10:54 -0800377 pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE;
378 dp_rx_mon_dest_process(soc, mac_id, quota);
Soumya Bhat5c60deb2017-12-12 16:42:04 +0530379 if (pdev->enhanced_stats_en ||
Soumya Bhat7422db82017-12-15 13:48:53 +0530380 pdev->mcopy_mode)
Anish Nataraj38a29562017-08-18 19:41:17 +0530381 dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info);
Soumya Bhat6fee59c2017-10-31 13:12:37 +0530382
Kai Chencbe4c342017-06-12 20:06:35 -0700383 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Karunakar Dasineni65b626e2017-12-18 22:17:29 -0800384 pdev->ppdu_info.com_info.last_ppdu_id =
385 pdev->ppdu_info.com_info.ppdu_id;
nobelj9ab76e22018-02-13 18:10:54 -0800386
387 qdf_mem_zero(&(pdev->ppdu_info.rx_status),
388 sizeof(pdev->ppdu_info.rx_status));
Kai Chen6eca1a62017-01-12 10:17:53 -0800389 }
390 }
391 return;
392}
393
394/*
395 * dp_rx_mon_status_srng_process() - Process monitor status ring
396 * post the status ring buffer to Rx status Queue for later
397 * processing when status ring is filled with status TLV.
398 * Allocate a new buffer to status ring if the filled buffer
399 * is posted.
400 *
401 * @soc: core txrx main context
402 * @mac_id: mac_id which is one of 3 mac_ids
403 * @quota: No. of ring entry that can be serviced in one shot.
404
405 * Return: uint32_t: No. of ring entry that is processed.
406 */
407static inline uint32_t
408dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id,
409 uint32_t quota)
410{
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800411 struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800412 void *hal_soc;
413 void *mon_status_srng;
414 void *rxdma_mon_status_ring_entry;
415 QDF_STATUS status;
416 uint32_t work_done = 0;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800417 int mac_for_pdev = dp_get_mac_id_for_mac(soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800418
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800419 mon_status_srng = pdev->rxdma_mon_status_ring[mac_for_pdev].hal_srng;
Kai Chen6eca1a62017-01-12 10:17:53 -0800420
421 qdf_assert(mon_status_srng);
Houston Hoffman648a9182017-05-21 23:27:50 -0700422 if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) {
423
424 QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
Mohit Khanna9a6fdd52017-12-12 10:55:48 +0800425 "%s %d : HAL Monitor Status Ring Init Failed -- %pK\n",
Houston Hoffman648a9182017-05-21 23:27:50 -0700426 __func__, __LINE__, mon_status_srng);
427 return work_done;
428 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800429
430 hal_soc = soc->hal_soc;
431
432 qdf_assert(hal_soc);
433
434 if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng)))
435 goto done;
436
437 /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT =>
438 * BUFFER_ADDR_INFO STRUCT
439 */
440 while (qdf_likely((rxdma_mon_status_ring_entry =
441 hal_srng_src_peek(hal_soc, mon_status_srng))
442 && quota--)) {
443 uint32_t rx_buf_cookie;
444 qdf_nbuf_t status_nbuf;
445 struct dp_rx_desc *rx_desc;
446 uint8_t *status_buf;
447 qdf_dma_addr_t paddr;
448 uint64_t buf_addr;
449
450 buf_addr =
451 (HAL_RX_BUFFER_ADDR_31_0_GET(
452 rxdma_mon_status_ring_entry) |
453 ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET(
454 rxdma_mon_status_ring_entry)) << 32));
455
456 if (qdf_likely(buf_addr)) {
457
458 rx_buf_cookie =
459 HAL_RX_BUF_COOKIE_GET(
460 rxdma_mon_status_ring_entry);
461 rx_desc = dp_rx_cookie_2_va_mon_status(soc,
462 rx_buf_cookie);
463
464 qdf_assert(rx_desc);
465
466 status_nbuf = rx_desc->nbuf;
467
468 qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf,
469 QDF_DMA_FROM_DEVICE);
470
471 status_buf = qdf_nbuf_data(status_nbuf);
472
473 status = hal_get_rx_status_done(status_buf);
474
475 if (status != QDF_STATUS_SUCCESS) {
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800476 uint32_t hp, tp;
477 hal_api_get_tphp(hal_soc, mon_status_srng,
478 &tp, &hp);
Kai Chen6eca1a62017-01-12 10:17:53 -0800479 QDF_TRACE(QDF_MODULE_ID_DP,
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800480 QDF_TRACE_LEVEL_ERROR,
481 "[%s][%d] status not done - hp:%u, tp:%u",
482 __func__, __LINE__, hp, tp);
483 /* WAR for missing status: Skip status entry */
484 hal_srng_src_get_next(hal_soc, mon_status_srng);
485 continue;
Kai Chen6eca1a62017-01-12 10:17:53 -0800486 }
487 qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE);
488
489 qdf_nbuf_unmap_single(soc->osdev, status_nbuf,
490 QDF_DMA_FROM_DEVICE);
491
492 /* Put the status_nbuf to queue */
493 qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf);
494
495 } else {
496 union dp_rx_desc_list_elem_t *desc_list = NULL;
497 union dp_rx_desc_list_elem_t *tail = NULL;
498 struct rx_desc_pool *rx_desc_pool;
499 uint32_t num_alloc_desc;
500
501 rx_desc_pool = &soc->rx_desc_status[mac_id];
502
503 num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id,
504 rx_desc_pool,
505 1,
506 &desc_list,
507 &tail);
508
509 rx_desc = &desc_list->rx_desc;
510 }
511
jinweic chenc3546322018-02-02 15:03:41 +0800512 status_nbuf = dp_rx_nbuf_prepare(soc, pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -0800513
jinweic chenc3546322018-02-02 15:03:41 +0800514 /*
515 * qdf_nbuf alloc or map failed,
516 * free the dp rx desc to free list,
517 * fill in NULL dma address at current HP entry,
518 * keep HP in mon_status_ring unchanged,
519 * wait next time dp_rx_mon_status_srng_process
520 * to fill in buffer at current HP.
521 */
522 if (qdf_unlikely(status_nbuf == NULL)) {
523 union dp_rx_desc_list_elem_t *desc_list = NULL;
524 union dp_rx_desc_list_elem_t *tail = NULL;
525 struct rx_desc_pool *rx_desc_pool;
Kai Chen6eca1a62017-01-12 10:17:53 -0800526
jinweic chenc3546322018-02-02 15:03:41 +0800527 rx_desc_pool = &soc->rx_desc_status[mac_id];
Kai Chen6eca1a62017-01-12 10:17:53 -0800528
jinweic chenc3546322018-02-02 15:03:41 +0800529 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
530 "%s: fail to allocate or map qdf_nbuf",
531 __func__);
532 dp_rx_add_to_free_desc_list(&desc_list,
533 &tail, rx_desc);
534 dp_rx_add_desc_list_to_free_list(soc, &desc_list,
535 &tail, mac_id, rx_desc_pool);
536
537 hal_rxdma_buff_addr_info_set(
538 rxdma_mon_status_ring_entry,
539 0, 0, HAL_RX_BUF_RBM_SW3_BM);
540 work_done++;
541 break;
542 }
543
Kai Chen6eca1a62017-01-12 10:17:53 -0800544 paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0);
545
546 rx_desc->nbuf = status_nbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700547 rx_desc->in_use = 1;
Kai Chen6eca1a62017-01-12 10:17:53 -0800548
549 hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry,
550 paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM);
551
Karunakar Dasineni37995ac2018-02-06 12:37:30 -0800552 hal_srng_src_get_next(hal_soc, mon_status_srng);
Kai Chen6eca1a62017-01-12 10:17:53 -0800553 work_done++;
554 }
555done:
556
557 hal_srng_access_end(hal_soc, mon_status_srng);
558
559 return work_done;
560
561}
562/*
563 * dp_rx_mon_status_process() - Process monitor status ring and
564 * TLV in status ring.
565 *
566 * @soc: core txrx main context
567 * @mac_id: mac_id which is one of 3 mac_ids
568 * @quota: No. of ring entry that can be serviced in one shot.
569
570 * Return: uint32_t: No. of ring entry that is processed.
571 */
572static inline uint32_t
573dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
574 uint32_t work_done;
575
576 work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota);
Karunakar Dasineni40555682017-03-26 22:44:39 -0700577 quota -= work_done;
578 dp_rx_mon_status_process_tlv(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800579
580 return work_done;
581}
582/**
583 * dp_mon_process() - Main monitor mode processing roution.
584 * This call monitor status ring process then monitor
585 * destination ring process.
586 * Called from the bottom half (tasklet/NET_RX_SOFTIRQ)
587 * @soc: core txrx main context
588 * @mac_id: mac_id which is one of 3 mac_ids
589 * @quota: No. of status ring entry that can be serviced in one shot.
590
591 * Return: uint32_t: No. of ring entry that is processed.
592 */
593uint32_t
594dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) {
Karunakar Dasineni40555682017-03-26 22:44:39 -0700595 return dp_rx_mon_status_process(soc, mac_id, quota);
Kai Chen6eca1a62017-01-12 10:17:53 -0800596}
Karunakar Dasineni40555682017-03-26 22:44:39 -0700597
Kai Chen6eca1a62017-01-12 10:17:53 -0800598/**
599 * dp_rx_pdev_mon_detach() - detach dp rx for status ring
600 * @pdev: core txrx pdev context
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800601 * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN
Kai Chen6eca1a62017-01-12 10:17:53 -0800602 *
603 * This function will detach DP RX status ring from
604 * main device context. will free DP Rx resources for
605 * status ring
606 *
607 * Return: QDF_STATUS_SUCCESS: success
608 * QDF_STATUS_E_RESOURCES: Error return
609 */
610QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800611dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id)
Kai Chen6eca1a62017-01-12 10:17:53 -0800612{
Kai Chen6eca1a62017-01-12 10:17:53 -0800613 struct dp_soc *soc = pdev->soc;
614 struct rx_desc_pool *rx_desc_pool;
615
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800616 rx_desc_pool = &soc->rx_desc_status[mac_id];
617 if (rx_desc_pool->pool_size != 0)
618 dp_rx_desc_pool_free(soc, mac_id, rx_desc_pool);
Kai Chen6eca1a62017-01-12 10:17:53 -0800619
620 return QDF_STATUS_SUCCESS;
621}
622
623/*
624 * dp_rx_buffers_replenish() - replenish monitor status ring with
625 * rx nbufs called during dp rx
626 * monitor status ring initialization
627 *
628 * @soc: core txrx main context
629 * @mac_id: mac_id which is one of 3 mac_ids
630 * @dp_rxdma_srng: dp monitor status circular ring
631 * @rx_desc_pool; Pointer to Rx descriptor pool
632 * @num_req_buffers: number of buffer to be replenished
633 * @desc_list: list of descs if called from dp rx monitor status
634 * process or NULL during dp rx initialization or
635 * out of buffer interrupt
636 * @tail: tail of descs list
637 * @owner: who owns the nbuf (host, NSS etc...)
638 * Return: return success or failure
639 */
640static inline
641QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc,
642 uint32_t mac_id,
643 struct dp_srng *dp_rxdma_srng,
644 struct rx_desc_pool *rx_desc_pool,
645 uint32_t num_req_buffers,
646 union dp_rx_desc_list_elem_t **desc_list,
647 union dp_rx_desc_list_elem_t **tail,
648 uint8_t owner)
649{
650 uint32_t num_alloc_desc;
651 uint16_t num_desc_to_free = 0;
652 uint32_t num_entries_avail;
jinweic chenc3546322018-02-02 15:03:41 +0800653 uint32_t count = 0;
Kai Chen6eca1a62017-01-12 10:17:53 -0800654 int sync_hw_ptr = 1;
655 qdf_dma_addr_t paddr;
656 qdf_nbuf_t rx_netbuf;
657 void *rxdma_ring_entry;
658 union dp_rx_desc_list_elem_t *next;
659 void *rxdma_srng;
jinweic chenc3546322018-02-02 15:03:41 +0800660 struct dp_pdev *dp_pdev = dp_get_pdev_for_mac_id(dp_soc, mac_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800661
662 rxdma_srng = dp_rxdma_srng->hal_srng;
663
664 qdf_assert(rxdma_srng);
665
Houston Hoffmanae850c62017-08-11 16:47:50 -0700666 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800667 "[%s][%d] requested %d buffers for replenish\n",
668 __func__, __LINE__, num_req_buffers);
669
670 /*
671 * if desc_list is NULL, allocate the descs from freelist
672 */
673 if (!(*desc_list)) {
674
675 num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id,
676 rx_desc_pool,
677 num_req_buffers,
678 desc_list,
679 tail);
680
681 if (!num_alloc_desc) {
682 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
683 "[%s][%d] no free rx_descs in freelist\n",
684 __func__, __LINE__);
685 return QDF_STATUS_E_NOMEM;
686 }
687
Houston Hoffmanae850c62017-08-11 16:47:50 -0700688 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800689 "[%s][%d] %d rx desc allocated\n", __func__, __LINE__,
690 num_alloc_desc);
Houston Hoffmanae850c62017-08-11 16:47:50 -0700691
Kai Chen6eca1a62017-01-12 10:17:53 -0800692 num_req_buffers = num_alloc_desc;
693 }
694
695 hal_srng_access_start(dp_soc->hal_soc, rxdma_srng);
696 num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc,
697 rxdma_srng, sync_hw_ptr);
698
Houston Hoffmanae850c62017-08-11 16:47:50 -0700699 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800700 "[%s][%d] no of availble entries in rxdma ring: %d\n",
701 __func__, __LINE__, num_entries_avail);
702
703 if (num_entries_avail < num_req_buffers) {
704 num_desc_to_free = num_req_buffers - num_entries_avail;
705 num_req_buffers = num_entries_avail;
706 }
707
jinweic chenc3546322018-02-02 15:03:41 +0800708 while (count < num_req_buffers) {
709 rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev);
Kai Chen6eca1a62017-01-12 10:17:53 -0800710
jinweic chenc3546322018-02-02 15:03:41 +0800711 /*
712 * qdf_nbuf alloc or map failed,
713 * keep HP in mon_status_ring unchanged,
714 * wait dp_rx_mon_status_srng_process
715 * to fill in buffer at current HP.
716 */
717 if (qdf_unlikely(rx_netbuf == NULL)) {
718 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
719 "%s: qdf_nbuf allocate or map fail, count %d",
720 __func__, count);
721 break;
722 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800723
724 paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0);
725
726 next = (*desc_list)->next;
727
728 (*desc_list)->rx_desc.nbuf = rx_netbuf;
Pramod Simha59fcb312017-06-22 17:43:16 -0700729 (*desc_list)->rx_desc.in_use = 1;
jinweic chenc3546322018-02-02 15:03:41 +0800730
731 count++;
732 rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc,
733 rxdma_srng);
734
Kai Chen6eca1a62017-01-12 10:17:53 -0800735 hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr,
736 (*desc_list)->rx_desc.cookie, owner);
737
Karunakar Dasineni40555682017-03-26 22:44:39 -0700738 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -0700739 "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \
jinweic chenc3546322018-02-02 15:03:41 +0800740 paddr=%pK\n",
Kai Chen6eca1a62017-01-12 10:17:53 -0800741 __func__, __LINE__, &(*desc_list)->rx_desc,
742 (*desc_list)->rx_desc.cookie, rx_netbuf,
jinweic chenc3546322018-02-02 15:03:41 +0800743 (void *)paddr);
Kai Chen6eca1a62017-01-12 10:17:53 -0800744
745 *desc_list = next;
746 }
747
748 hal_srng_access_end(dp_soc->hal_soc, rxdma_srng);
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 "successfully replenished %d buffers\n", num_req_buffers);
752
Houston Hoffmanae850c62017-08-11 16:47:50 -0700753 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Kai Chen6eca1a62017-01-12 10:17:53 -0800754 "%d rx desc added back to free list\n", num_desc_to_free);
755
Houston Hoffmanae850c62017-08-11 16:47:50 -0700756 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson3f217e22017-09-18 10:13:35 -0700757 "[%s][%d] desc_list=%pK, tail=%pK rx_desc=%pK, cookie=%d\n",
Kai Chen6eca1a62017-01-12 10:17:53 -0800758 __func__, __LINE__, desc_list, tail, &(*desc_list)->rx_desc,
759 (*desc_list)->rx_desc.cookie);
760
761 /*
762 * add any available free desc back to the free list
763 */
764 if (*desc_list) {
765 dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail,
766 mac_id, rx_desc_pool);
767 }
768
769 return QDF_STATUS_SUCCESS;
770}
771/**
772 * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring
773 * @pdev: core txrx pdev context
774 *
775 * This function will attach a DP RX monitor status ring into pDEV
776 * and replenish monitor status ring with buffer.
777 *
778 * Return: QDF_STATUS_SUCCESS: success
779 * QDF_STATUS_E_RESOURCES: Error return
780 */
781QDF_STATUS
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800782dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int ring_id) {
Kai Chen6eca1a62017-01-12 10:17:53 -0800783 struct dp_soc *soc = pdev->soc;
784 union dp_rx_desc_list_elem_t *desc_list = NULL;
785 union dp_rx_desc_list_elem_t *tail = NULL;
786 struct dp_srng *rxdma_srng;
787 uint32_t rxdma_entries;
788 struct rx_desc_pool *rx_desc_pool;
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700789 QDF_STATUS status;
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800790 int mac_for_pdev = dp_get_mac_id_for_mac(soc, ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800791
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800792 rxdma_srng = &pdev->rxdma_mon_status_ring[mac_for_pdev];
Kai Chen6eca1a62017-01-12 10:17:53 -0800793
794 rxdma_entries = rxdma_srng->alloc_size/hal_srng_get_entrysize(
795 soc->hal_soc, RXDMA_MONITOR_STATUS);
796
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800797 rx_desc_pool = &soc->rx_desc_status[ring_id];
Kai Chen6eca1a62017-01-12 10:17:53 -0800798
Houston Hoffman41b912c2017-08-30 14:27:51 -0700799 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
Kai Chen6eca1a62017-01-12 10:17:53 -0800800 "%s: Mon RX Status Pool[%d] allocation size=%d\n",
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800801 __func__, ring_id, rxdma_entries);
Kai Chen6eca1a62017-01-12 10:17:53 -0800802
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800803 status = dp_rx_desc_pool_alloc(soc, ring_id, rxdma_entries+1,
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700804 rx_desc_pool);
Ravi Joshi73a05512017-07-10 13:53:32 -0700805 if (!QDF_IS_STATUS_SUCCESS(status)) {
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700806 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
807 "%s: dp_rx_desc_pool_alloc() failed \n", __func__);
808 return status;
809 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800810
Houston Hoffman41b912c2017-08-30 14:27:51 -0700811 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW,
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800812 "%s: Mon RX Status Buffers Replenish ring_id=%d\n",
813 __func__, ring_id);
Kai Chen6eca1a62017-01-12 10:17:53 -0800814
Manjunathappa Prakashd9ce3502018-02-05 14:09:17 -0800815 status = dp_rx_mon_status_buffers_replenish(soc, ring_id, rxdma_srng,
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700816 rx_desc_pool, rxdma_entries, &desc_list, &tail,
817 HAL_RX_BUF_RBM_SW3_BM);
Ravi Joshi73a05512017-07-10 13:53:32 -0700818 if (!QDF_IS_STATUS_SUCCESS(status)) {
Ravi Joshia9ebe0a2017-06-17 16:43:02 -0700819 QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
820 "%s: dp_rx_buffers_replenish() failed \n", __func__);
821 return status;
822 }
Kai Chen6eca1a62017-01-12 10:17:53 -0800823
824 qdf_nbuf_queue_init(&pdev->rx_status_q);
825
826 pdev->mon_ppdu_status = DP_PPDU_STATUS_START;
Karunakar Dasineni65b626e2017-12-18 22:17:29 -0800827 pdev->ppdu_info.com_info.last_ppdu_id = 0;
Karunakar Dasineni40555682017-03-26 22:44:39 -0700828 qdf_mem_zero(&(pdev->ppdu_info.rx_status),
829 sizeof(pdev->ppdu_info.rx_status));
Kai Chen6eca1a62017-01-12 10:17:53 -0800830
831 return QDF_STATUS_SUCCESS;
832}