Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1 | /* |
phadiman | ebf4cde | 2019-01-28 17:50:37 +0530 | [diff] [blame] | 2 | * Copyright (c) 2017-2019 The Linux Foundation. All rights reserved. |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 3 | * |
| 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 Mahalingam | d015964 | 2018-07-11 15:02:29 +0530 | [diff] [blame] | 18 | #include "hal_hw_headers.h" |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 19 | #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 Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 27 | #include "dp_rx_mon.h" |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 28 | #include "dp_internal.h" |
| 29 | #include "qdf_mem.h" /* qdf_mem_malloc,free */ |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 30 | |
y | db24745 | 2018-08-08 00:23:16 +0530 | [diff] [blame] | 31 | #ifdef FEATURE_PERPKT_INFO |
| 32 | #include "dp_ratetable.h" |
| 33 | #endif |
| 34 | |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 35 | #ifdef WLAN_RX_PKT_CAPTURE_ENH |
| 36 | #include "dp_rx_mon_feature.h" |
| 37 | #else |
| 38 | static QDF_STATUS |
| 39 | dp_rx_handle_enh_capture(struct dp_soc *soc, struct dp_pdev *pdev, |
| 40 | struct hal_rx_ppdu_info *ppdu_info) |
| 41 | { |
| 42 | return QDF_STATUS_SUCCESS; |
| 43 | } |
| 44 | |
| 45 | static void |
| 46 | dp_rx_mon_enh_capture_process(struct dp_pdev *pdev, uint32_t tlv_status, |
| 47 | qdf_nbuf_t status_nbuf, |
| 48 | struct hal_rx_ppdu_info *ppdu_info, |
Karunakar Dasineni | acc8b56 | 2019-05-07 07:00:24 -0700 | [diff] [blame] | 49 | bool *nbuf_used) |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 50 | { |
| 51 | } |
| 52 | #endif |
| 53 | |
Amir Patel | 1d4ac98 | 2019-04-25 11:49:01 +0530 | [diff] [blame] | 54 | #ifdef FEATURE_PERPKT_INFO |
| 55 | static inline void |
| 56 | dp_rx_populate_rx_rssi_chain(struct hal_rx_ppdu_info *ppdu_info, |
| 57 | struct cdp_rx_indication_ppdu *cdp_rx_ppdu) |
| 58 | { |
| 59 | uint8_t chain, bw; |
| 60 | int8_t rssi; |
| 61 | |
| 62 | for (chain = 0; chain < SS_COUNT; chain++) { |
| 63 | for (bw = 0; bw < MAX_BW; bw++) { |
| 64 | rssi = ppdu_info->rx_status.rssi_chain[chain][bw]; |
| 65 | if (rssi != DP_RSSI_INVAL) |
| 66 | cdp_rx_ppdu->rssi_chain[chain][bw] = rssi; |
| 67 | else |
| 68 | cdp_rx_ppdu->rssi_chain[chain][bw] = 0; |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
Amir Patel | 5a8bbbe | 2019-07-17 21:59:39 +0530 | [diff] [blame^] | 73 | /* |
| 74 | * dp_rx_populate_su_evm_details() - Populate su evm info |
| 75 | * @ppdu_info: ppdu info structure from ppdu ring |
| 76 | * @cdp_rx_ppdu: rx ppdu indication structure |
| 77 | */ |
| 78 | static inline void |
| 79 | dp_rx_populate_su_evm_details(struct hal_rx_ppdu_info *ppdu_info, |
| 80 | struct cdp_rx_indication_ppdu *cdp_rx_ppdu) |
| 81 | { |
| 82 | uint8_t pilot_evm; |
| 83 | uint8_t nss_count; |
| 84 | uint8_t pilot_count; |
| 85 | |
| 86 | nss_count = ppdu_info->evm_info.nss_count; |
| 87 | pilot_count = ppdu_info->evm_info.pilot_count; |
| 88 | |
| 89 | if ((nss_count * pilot_count) > DP_RX_MAX_SU_EVM_COUNT) { |
| 90 | qdf_err("pilot evm count is more than expected"); |
| 91 | return; |
| 92 | } |
| 93 | cdp_rx_ppdu->evm_info.pilot_count = pilot_count; |
| 94 | cdp_rx_ppdu->evm_info.nss_count = nss_count; |
| 95 | |
| 96 | /* Populate evm for pilot_evm = nss_count*pilot_count */ |
| 97 | for (pilot_evm = 0; pilot_evm < nss_count * pilot_count; pilot_evm++) { |
| 98 | cdp_rx_ppdu->evm_info.pilot_evm[pilot_evm] = |
| 99 | ppdu_info->evm_info.pilot_evm[pilot_evm]; |
| 100 | } |
| 101 | } |
| 102 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 103 | /** |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 104 | * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 105 | * @pdev: pdev ctx |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 106 | * @ppdu_info: ppdu info structure from ppdu ring |
| 107 | * @ppdu_nbuf: qdf nbuf abstraction for linux skb |
| 108 | * |
| 109 | * Return: none |
| 110 | */ |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 111 | static inline void |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 112 | dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev, |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 113 | struct hal_rx_ppdu_info *ppdu_info, |
| 114 | qdf_nbuf_t ppdu_nbuf) |
| 115 | { |
| 116 | struct dp_peer *peer; |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 117 | struct dp_soc *soc = pdev->soc; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 118 | struct dp_ast_entry *ast_entry; |
| 119 | struct cdp_rx_indication_ppdu *cdp_rx_ppdu; |
| 120 | uint32_t ast_index; |
| 121 | |
| 122 | cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data; |
| 123 | |
Pamidipati, Vijay | d7eb83e | 2017-09-20 21:19:56 +0530 | [diff] [blame] | 124 | cdp_rx_ppdu->first_data_seq_ctrl = |
| 125 | ppdu_info->rx_status.first_data_seq_ctrl; |
Anish Nataraj | eb30aa7 | 2018-09-20 16:34:01 +0530 | [diff] [blame] | 126 | cdp_rx_ppdu->frame_ctrl = |
| 127 | ppdu_info->rx_status.frame_control; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 128 | cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id; |
nobelj | 9ab76e2 | 2018-02-13 18:10:54 -0800 | [diff] [blame] | 129 | cdp_rx_ppdu->length = ppdu_info->rx_status.ppdu_len; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 130 | cdp_rx_ppdu->duration = ppdu_info->rx_status.duration; |
| 131 | cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw; |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 132 | cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count; |
| 133 | cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count; |
| 134 | cdp_rx_ppdu->other_msdu_count = ppdu_info->rx_status.other_msdu_count; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 135 | cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss; |
| 136 | cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs; |
Keyur Parekh | 49cdc74 | 2018-05-09 10:59:03 -0700 | [diff] [blame] | 137 | if ((ppdu_info->rx_status.sgi == VHT_SGI_NYSM) && |
| 138 | (ppdu_info->rx_status.preamble_type == HAL_RX_PKT_TYPE_11AC)) |
| 139 | cdp_rx_ppdu->u.gi = CDP_SGI_0_4_US; |
| 140 | else |
| 141 | cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi; |
Anish Nataraj | 5034701 | 2018-03-06 21:12:45 +0530 | [diff] [blame] | 142 | cdp_rx_ppdu->u.ldpc = ppdu_info->rx_status.ldpc; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 143 | cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type; |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 144 | cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type; |
Pamidipati, Vijay | ba4b57f | 2019-02-13 16:47:23 +0530 | [diff] [blame] | 145 | cdp_rx_ppdu->u.ltf_size = (ppdu_info->rx_status.he_data5 >> |
| 146 | QDF_MON_STATUS_HE_LTF_SIZE_SHIFT) & 0x3; |
| 147 | cdp_rx_ppdu->num_mpdu = ppdu_info->com_info.mpdu_cnt_fcs_ok; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 148 | cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb; |
Anish Nataraj | 57614da | 2018-02-07 23:04:24 +0530 | [diff] [blame] | 149 | cdp_rx_ppdu->timestamp = ppdu_info->rx_status.tsft; |
| 150 | cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_num; |
nobelj | d803959 | 2018-03-13 16:59:42 -0700 | [diff] [blame] | 151 | cdp_rx_ppdu->beamformed = ppdu_info->rx_status.beamformed; |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 152 | cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count + |
| 153 | cdp_rx_ppdu->udp_msdu_count + |
| 154 | cdp_rx_ppdu->other_msdu_count); |
Amir Patel | 468bded | 2019-03-21 11:42:31 +0530 | [diff] [blame] | 155 | cdp_rx_ppdu->num_bytes = ppdu_info->rx_status.ppdu_len; |
Amir Patel | ac7d946 | 2019-03-28 16:16:01 +0530 | [diff] [blame] | 156 | cdp_rx_ppdu->retries = CDP_FC_IS_RETRY_SET(cdp_rx_ppdu->frame_ctrl) ? |
| 157 | ppdu_info->com_info.mpdu_cnt_fcs_ok : 0; |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 158 | |
| 159 | if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1) |
| 160 | cdp_rx_ppdu->is_ampdu = 1; |
| 161 | else |
| 162 | cdp_rx_ppdu->is_ampdu = 0; |
Anish Nataraj | 45d282c | 2017-12-30 01:03:38 +0530 | [diff] [blame] | 163 | |
| 164 | cdp_rx_ppdu->tid = ppdu_info->rx_status.tid; |
Anish Nataraj | 57614da | 2018-02-07 23:04:24 +0530 | [diff] [blame] | 165 | cdp_rx_ppdu->lsig_a = ppdu_info->rx_status.rate; |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 166 | |
| 167 | ast_index = ppdu_info->rx_status.ast_index; |
Tallapragada Kalyan | a702362 | 2018-12-03 19:29:52 +0530 | [diff] [blame] | 168 | if (ast_index >= wlan_cfg_get_max_ast_idx(soc->wlan_cfg_ctx)) { |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 169 | cdp_rx_ppdu->peer_id = HTT_INVALID_PEER; |
| 170 | return; |
| 171 | } |
| 172 | |
| 173 | ast_entry = soc->ast_table[ast_index]; |
| 174 | if (!ast_entry) { |
| 175 | cdp_rx_ppdu->peer_id = HTT_INVALID_PEER; |
| 176 | return; |
| 177 | } |
| 178 | peer = ast_entry->peer; |
| 179 | if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) { |
| 180 | cdp_rx_ppdu->peer_id = HTT_INVALID_PEER; |
| 181 | return; |
| 182 | } |
| 183 | |
| 184 | qdf_mem_copy(cdp_rx_ppdu->mac_addr, |
Srinivas Girigowda | 2751b6d | 2019-02-27 12:28:13 -0800 | [diff] [blame] | 185 | peer->mac_addr.raw, QDF_MAC_ADDR_SIZE); |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 186 | cdp_rx_ppdu->peer_id = peer->peer_ids[0]; |
| 187 | cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id; |
Keyur Parekh | 44d8f8f | 2019-03-12 12:39:41 -0700 | [diff] [blame] | 188 | cdp_rx_ppdu->u.ltf_size = ppdu_info->rx_status.ltf_size; |
Amir Patel | 1d4ac98 | 2019-04-25 11:49:01 +0530 | [diff] [blame] | 189 | |
| 190 | dp_rx_populate_rx_rssi_chain(ppdu_info, cdp_rx_ppdu); |
Amir Patel | 5a8bbbe | 2019-07-17 21:59:39 +0530 | [diff] [blame^] | 191 | dp_rx_populate_su_evm_details(ppdu_info, cdp_rx_ppdu); |
| 192 | cdp_rx_ppdu->rx_antenna = ppdu_info->rx_status.rx_antenna; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 193 | } |
| 194 | #else |
| 195 | static inline void |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 196 | dp_rx_populate_cdp_indication_ppdu(struct dp_pdev *pdev, |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 197 | struct hal_rx_ppdu_info *ppdu_info, |
| 198 | qdf_nbuf_t ppdu_nbuf) |
| 199 | { |
| 200 | } |
| 201 | #endif |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 202 | /** |
| 203 | * dp_rx_stats_update() - Update per-peer statistics |
| 204 | * @soc: Datapath SOC handle |
| 205 | * @peer: Datapath peer handle |
| 206 | * @ppdu: PPDU Descriptor |
| 207 | * |
| 208 | * Return: None |
| 209 | */ |
| 210 | #ifdef FEATURE_PERPKT_INFO |
y | db24745 | 2018-08-08 00:23:16 +0530 | [diff] [blame] | 211 | static inline void dp_rx_rate_stats_update(struct dp_peer *peer, |
| 212 | struct cdp_rx_indication_ppdu *ppdu) |
| 213 | { |
| 214 | uint32_t ratekbps = 0; |
| 215 | uint32_t ppdu_rx_rate = 0; |
| 216 | uint32_t nss = 0; |
Amir Patel | 78824b1 | 2019-02-23 10:54:32 +0530 | [diff] [blame] | 217 | uint32_t rix; |
y | db24745 | 2018-08-08 00:23:16 +0530 | [diff] [blame] | 218 | |
| 219 | if (!peer || !ppdu) |
| 220 | return; |
| 221 | |
| 222 | if (ppdu->u.nss == 0) |
| 223 | nss = 0; |
| 224 | else |
| 225 | nss = ppdu->u.nss - 1; |
| 226 | |
Anish Nataraj | 376d9b1 | 2018-08-13 14:12:01 +0530 | [diff] [blame] | 227 | ratekbps = dp_getrateindex(ppdu->u.gi, |
| 228 | ppdu->u.mcs, |
y | db24745 | 2018-08-08 00:23:16 +0530 | [diff] [blame] | 229 | nss, |
| 230 | ppdu->u.preamble, |
Amir Patel | 78824b1 | 2019-02-23 10:54:32 +0530 | [diff] [blame] | 231 | ppdu->u.bw, |
| 232 | &rix); |
y | db24745 | 2018-08-08 00:23:16 +0530 | [diff] [blame] | 233 | |
| 234 | if (!ratekbps) |
| 235 | return; |
| 236 | |
Amir Patel | 468bded | 2019-03-21 11:42:31 +0530 | [diff] [blame] | 237 | ppdu->rix = rix; |
y | db24745 | 2018-08-08 00:23:16 +0530 | [diff] [blame] | 238 | DP_STATS_UPD(peer, rx.last_rx_rate, ratekbps); |
| 239 | dp_ath_rate_lpf(peer->stats.rx.avg_rx_rate, ratekbps); |
| 240 | ppdu_rx_rate = dp_ath_rate_out(peer->stats.rx.avg_rx_rate); |
| 241 | DP_STATS_UPD(peer, rx.rnd_avg_rx_rate, ppdu_rx_rate); |
Amir Patel | ac7d946 | 2019-03-28 16:16:01 +0530 | [diff] [blame] | 242 | ppdu->rx_ratekbps = ratekbps; |
Amir Patel | 5a8bbbe | 2019-07-17 21:59:39 +0530 | [diff] [blame^] | 243 | ppdu->rx_ratecode = CDP_TXRX_RATECODE(ppdu->u.mcs, |
| 244 | nss, |
| 245 | ppdu->u.preamble); |
y | db24745 | 2018-08-08 00:23:16 +0530 | [diff] [blame] | 246 | |
| 247 | if (peer->vdev) |
| 248 | peer->vdev->stats.rx.last_rx_rate = ratekbps; |
| 249 | } |
| 250 | |
Ruchi, Agrawal | 4c5ade6 | 2018-09-27 21:52:11 +0530 | [diff] [blame] | 251 | static void dp_rx_stats_update(struct dp_pdev *pdev, struct dp_peer *peer, |
| 252 | struct cdp_rx_indication_ppdu *ppdu) |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 253 | { |
Ruchi, Agrawal | 4c5ade6 | 2018-09-27 21:52:11 +0530 | [diff] [blame] | 254 | struct dp_soc *soc = NULL; |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 255 | uint8_t mcs, preamble, ac = 0; |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 256 | uint16_t num_msdu; |
Ruchi, Agrawal | 4c5ade6 | 2018-09-27 21:52:11 +0530 | [diff] [blame] | 257 | bool is_invalid_peer = false; |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 258 | |
| 259 | mcs = ppdu->u.mcs; |
| 260 | preamble = ppdu->u.preamble; |
| 261 | num_msdu = ppdu->num_msdu; |
| 262 | |
Ruchi, Agrawal | 4c5ade6 | 2018-09-27 21:52:11 +0530 | [diff] [blame] | 263 | if (pdev) |
| 264 | soc = pdev->soc; |
| 265 | else |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 266 | return; |
| 267 | |
Ruchi, Agrawal | 4c5ade6 | 2018-09-27 21:52:11 +0530 | [diff] [blame] | 268 | if (!peer) { |
| 269 | is_invalid_peer = true; |
| 270 | peer = pdev->invalid_peer; |
| 271 | } |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 272 | |
Ruchi, Agrawal | 4c5ade6 | 2018-09-27 21:52:11 +0530 | [diff] [blame] | 273 | if (!soc || soc->process_rx_status) |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 274 | return; |
Pranita Solanke | fc2ff39 | 2017-12-15 19:25:13 +0530 | [diff] [blame] | 275 | |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 276 | DP_STATS_UPD(peer, rx.rssi, ppdu->rssi); |
Surya Prakash | 07c81e7 | 2019-04-29 10:08:01 +0530 | [diff] [blame] | 277 | if (peer->stats.rx.avg_rssi == INVALID_RSSI) |
Amir Patel | bb69cfa | 2019-03-28 16:16:01 +0530 | [diff] [blame] | 278 | peer->stats.rx.avg_rssi = ppdu->rssi; |
| 279 | else |
| 280 | peer->stats.rx.avg_rssi = |
| 281 | DP_GET_AVG_RSSI(peer->stats.rx.avg_rssi, ppdu->rssi); |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 282 | |
| 283 | if ((preamble == DOT11_A) || (preamble == DOT11_B)) |
| 284 | ppdu->u.nss = 1; |
| 285 | |
| 286 | if (ppdu->u.nss) |
| 287 | DP_STATS_INC(peer, rx.nss[ppdu->u.nss - 1], num_msdu); |
| 288 | |
Pranita Solanke | a12b4b3 | 2017-11-20 23:04:14 +0530 | [diff] [blame] | 289 | DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 290 | DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu); |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 291 | DP_STATS_INC(peer, rx.reception_type[ppdu->u.ppdu_type], num_msdu); |
Pranita Solanke | a12b4b3 | 2017-11-20 23:04:14 +0530 | [diff] [blame] | 292 | DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu, ppdu->is_ampdu); |
| 293 | DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu)); |
| 294 | DP_STATS_UPD(peer, rx.rx_rate, mcs); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 295 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 296 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 297 | ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A))); |
| 298 | DP_STATS_INCC(peer, |
| 299 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
Pranita Solanke | a12b4b3 | 2017-11-20 23:04:14 +0530 | [diff] [blame] | 300 | ((mcs < MAX_MCS_11A) && (preamble == DOT11_A))); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 301 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 302 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 303 | ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B))); |
| 304 | DP_STATS_INCC(peer, |
| 305 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
Pranita Solanke | a12b4b3 | 2017-11-20 23:04:14 +0530 | [diff] [blame] | 306 | ((mcs < MAX_MCS_11B) && (preamble == DOT11_B))); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 307 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 308 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 309 | ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N))); |
| 310 | DP_STATS_INCC(peer, |
| 311 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
Pranita Solanke | a12b4b3 | 2017-11-20 23:04:14 +0530 | [diff] [blame] | 312 | ((mcs < MAX_MCS_11A) && (preamble == DOT11_N))); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 313 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 314 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 315 | ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC))); |
| 316 | DP_STATS_INCC(peer, |
| 317 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
| 318 | ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC))); |
| 319 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 320 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 321 | ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX))); |
| 322 | DP_STATS_INCC(peer, |
| 323 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
| 324 | ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX))); |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 325 | /* |
| 326 | * If invalid TID, it could be a non-qos frame, hence do not update |
| 327 | * any AC counters |
| 328 | */ |
| 329 | ac = TID_TO_WME_AC(ppdu->tid); |
| 330 | if (ppdu->tid != HAL_TID_INVALID) |
| 331 | DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu); |
Amir Patel | 52c6b73 | 2018-08-03 12:13:22 +0530 | [diff] [blame] | 332 | dp_peer_stats_notify(peer); |
| 333 | DP_STATS_UPD(peer, rx.last_rssi, ppdu->rssi); |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 334 | |
Ruchi, Agrawal | 4c5ade6 | 2018-09-27 21:52:11 +0530 | [diff] [blame] | 335 | if (is_invalid_peer) |
| 336 | return; |
| 337 | |
Jeffin Mammen | 1514e79 | 2019-05-20 10:30:44 +0530 | [diff] [blame] | 338 | if (dp_is_subtype_data(ppdu->frame_ctrl)) |
| 339 | dp_rx_rate_stats_update(peer, ppdu); |
y | db24745 | 2018-08-08 00:23:16 +0530 | [diff] [blame] | 340 | |
Amir Patel | 756d05e | 2018-10-10 12:35:30 +0530 | [diff] [blame] | 341 | #if defined(FEATURE_PERPKT_INFO) && WDI_EVENT_ENABLE |
| 342 | dp_wdi_event_handler(WDI_EVENT_UPDATE_DP_STATS, pdev->soc, |
| 343 | &peer->stats, ppdu->peer_id, |
| 344 | UPDATE_PEER_STATS, pdev->pdev_id); |
| 345 | #endif |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 346 | } |
| 347 | #endif |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 348 | |
Amir Patel | 57e7e05 | 2019-05-15 20:49:57 +0530 | [diff] [blame] | 349 | /* |
| 350 | * dp_rx_get_fcs_ok_msdu() - get ppdu status buffer containing fcs_ok msdu |
| 351 | * @pdev: pdev object |
| 352 | * @ppdu_info: ppdu info object |
| 353 | * |
| 354 | * Return: nbuf |
| 355 | */ |
| 356 | |
| 357 | static inline qdf_nbuf_t |
| 358 | dp_rx_get_fcs_ok_msdu(struct dp_pdev *pdev, |
| 359 | struct hal_rx_ppdu_info *ppdu_info) |
| 360 | { |
| 361 | uint16_t mpdu_fcs_ok; |
| 362 | qdf_nbuf_t status_nbuf = NULL; |
| 363 | unsigned long int fcs_ok_bitmap; |
| 364 | |
| 365 | /* If fcs_ok_bitmap is zero, no need to procees further */ |
| 366 | if (qdf_unlikely(!ppdu_info->com_info.mpdu_fcs_ok_bitmap)) |
| 367 | return NULL; |
| 368 | |
| 369 | /* Obtain fcs_ok passed index from bitmap |
| 370 | * this index is used to get fcs passed first msdu payload |
| 371 | */ |
| 372 | |
| 373 | fcs_ok_bitmap = ppdu_info->com_info.mpdu_fcs_ok_bitmap; |
| 374 | mpdu_fcs_ok = qdf_find_first_bit(&fcs_ok_bitmap, HAL_RX_MAX_MPDU); |
| 375 | |
| 376 | /* Get status buffer by indexing mpdu_fcs_ok index |
| 377 | * containing first msdu payload with fcs passed |
| 378 | * and clone the buffer |
| 379 | */ |
| 380 | status_nbuf = ppdu_info->ppdu_msdu_info[mpdu_fcs_ok].nbuf; |
| 381 | /* Take ref of status nbuf as this nbuf is to be |
| 382 | * freeed by upper layer. |
| 383 | */ |
| 384 | qdf_nbuf_ref(status_nbuf); |
| 385 | |
| 386 | /* Free the ppdu status buffer queue */ |
| 387 | qdf_nbuf_queue_free(&pdev->rx_ppdu_buf_q); |
| 388 | |
| 389 | return status_nbuf; |
| 390 | } |
| 391 | |
| 392 | static inline void |
| 393 | dp_rx_handle_ppdu_status_buf(struct dp_pdev *pdev, |
| 394 | struct hal_rx_ppdu_info *ppdu_info, |
| 395 | qdf_nbuf_t status_nbuf) |
| 396 | { |
| 397 | qdf_nbuf_queue_add(&pdev->rx_ppdu_buf_q, status_nbuf); |
| 398 | } |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 399 | /** |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 400 | * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload |
Pranita Solanke | fc2ff39 | 2017-12-15 19:25:13 +0530 | [diff] [blame] | 401 | * @soc: core txrx main context |
| 402 | * @pdev: pdev strcuture |
| 403 | * @ppdu_info: structure for rx ppdu ring |
| 404 | * |
| 405 | * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller |
| 406 | * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 407 | */ |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 408 | #ifdef FEATURE_PERPKT_INFO |
| 409 | static inline QDF_STATUS |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 410 | dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev, |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 411 | struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf) |
| 412 | { |
| 413 | uint8_t size = 0; |
Chaithanya Garrepalli | 7ab76ae | 2018-07-05 14:53:50 +0530 | [diff] [blame] | 414 | struct ieee80211_frame *wh; |
| 415 | uint32_t *nbuf_data; |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 416 | |
Amir Patel | 57e7e05 | 2019-05-15 20:49:57 +0530 | [diff] [blame] | 417 | if (!ppdu_info->fcs_ok_msdu_info.first_msdu_payload) |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 418 | return QDF_STATUS_SUCCESS; |
| 419 | |
Soumya Bhat | 2f54de2 | 2018-02-21 09:54:28 +0530 | [diff] [blame] | 420 | if (pdev->m_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id) |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 421 | return QDF_STATUS_SUCCESS; |
| 422 | |
Soumya Bhat | 2f54de2 | 2018-02-21 09:54:28 +0530 | [diff] [blame] | 423 | pdev->m_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id; |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 424 | |
Amir Patel | 57e7e05 | 2019-05-15 20:49:57 +0530 | [diff] [blame] | 425 | wh = (struct ieee80211_frame *) |
| 426 | (ppdu_info->fcs_ok_msdu_info.first_msdu_payload + 4); |
| 427 | |
| 428 | size = (ppdu_info->fcs_ok_msdu_info.first_msdu_payload - |
Chaithanya Garrepalli | 7ab76ae | 2018-07-05 14:53:50 +0530 | [diff] [blame] | 429 | qdf_nbuf_data(nbuf)); |
Amir Patel | 57e7e05 | 2019-05-15 20:49:57 +0530 | [diff] [blame] | 430 | ppdu_info->fcs_ok_msdu_info.first_msdu_payload = NULL; |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 431 | |
| 432 | if (qdf_nbuf_pull_head(nbuf, size) == NULL) |
| 433 | return QDF_STATUS_SUCCESS; |
| 434 | |
Chaithanya Garrepalli | 7ab76ae | 2018-07-05 14:53:50 +0530 | [diff] [blame] | 435 | if (((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == |
| 436 | IEEE80211_FC0_TYPE_MGT) || |
| 437 | ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == |
| 438 | IEEE80211_FC0_TYPE_CTL)) { |
| 439 | return QDF_STATUS_SUCCESS; |
| 440 | } |
| 441 | |
| 442 | nbuf_data = (uint32_t *)qdf_nbuf_data(nbuf); |
| 443 | *nbuf_data = pdev->ppdu_info.com_info.ppdu_id; |
Soumya Bhat | dc8aca8 | 2018-03-13 14:10:24 +0530 | [diff] [blame] | 444 | /* only retain RX MSDU payload in the skb */ |
| 445 | qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - |
Amir Patel | 57e7e05 | 2019-05-15 20:49:57 +0530 | [diff] [blame] | 446 | ppdu_info->fcs_ok_msdu_info.payload_len); |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 447 | dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc, |
| 448 | nbuf, HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id); |
| 449 | return QDF_STATUS_E_ALREADY; |
| 450 | } |
| 451 | #else |
| 452 | static inline QDF_STATUS |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 453 | dp_rx_handle_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev, |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 454 | struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf) |
| 455 | { |
| 456 | return QDF_STATUS_SUCCESS; |
| 457 | } |
| 458 | #endif |
| 459 | |
Amir Patel | 57e7e05 | 2019-05-15 20:49:57 +0530 | [diff] [blame] | 460 | #ifdef FEATURE_PERPKT_INFO |
| 461 | static inline void |
| 462 | dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev, |
| 463 | struct hal_rx_ppdu_info *ppdu_info, |
| 464 | uint32_t tlv_status, |
| 465 | qdf_nbuf_t status_nbuf) |
| 466 | { |
| 467 | QDF_STATUS mcopy_status; |
| 468 | |
| 469 | if (qdf_unlikely(!ppdu_info->com_info.mpdu_cnt)) { |
| 470 | qdf_nbuf_free(status_nbuf); |
| 471 | return; |
| 472 | } |
| 473 | /* Add buffers to queue until we receive |
| 474 | * HAL_TLV_STATUS_PPDU_DONE |
| 475 | */ |
| 476 | dp_rx_handle_ppdu_status_buf(pdev, ppdu_info, status_nbuf); |
| 477 | |
| 478 | /* If tlv_status is PPDU_DONE, process rx_ppdu_buf_q |
| 479 | * and devliver fcs_ok msdu buffer |
| 480 | */ |
| 481 | if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) { |
| 482 | /* Get rx ppdu status buffer having fcs ok msdu */ |
| 483 | status_nbuf = dp_rx_get_fcs_ok_msdu(pdev, ppdu_info); |
| 484 | if (status_nbuf) { |
| 485 | mcopy_status = dp_rx_handle_mcopy_mode(soc, pdev, |
| 486 | ppdu_info, |
| 487 | status_nbuf); |
| 488 | if (mcopy_status == QDF_STATUS_SUCCESS) |
| 489 | qdf_nbuf_free(status_nbuf); |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | #else |
| 494 | static inline void |
| 495 | dp_rx_process_mcopy_mode(struct dp_soc *soc, struct dp_pdev *pdev, |
| 496 | struct hal_rx_ppdu_info *ppdu_info, |
| 497 | uint32_t tlv_status, |
| 498 | qdf_nbuf_t status_nbuf) |
| 499 | { |
| 500 | } |
| 501 | #endif |
| 502 | |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 503 | /** |
| 504 | * dp_rx_handle_smart_mesh_mode() - Deliver header for smart mesh |
| 505 | * @soc: Datapath SOC handle |
| 506 | * @pdev: Datapath PDEV handle |
| 507 | * @ppdu_info: Structure for rx ppdu info |
| 508 | * @nbuf: Qdf nbuf abstraction for linux skb |
| 509 | * |
| 510 | * Return: 0 on success, 1 on failure |
| 511 | */ |
| 512 | static inline int |
| 513 | dp_rx_handle_smart_mesh_mode(struct dp_soc *soc, struct dp_pdev *pdev, |
| 514 | struct hal_rx_ppdu_info *ppdu_info, |
| 515 | qdf_nbuf_t nbuf) |
| 516 | { |
| 517 | uint8_t size = 0; |
| 518 | |
| 519 | if (!pdev->monitor_vdev) { |
| 520 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 521 | "[%s]:[%d] Monitor vdev is NULL !!", |
| 522 | __func__, __LINE__); |
| 523 | return 1; |
| 524 | } |
Jeff Johnson | a8edf33 | 2019-03-18 09:51:52 -0700 | [diff] [blame] | 525 | if (!ppdu_info->msdu_info.first_msdu_payload) { |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 526 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 527 | "[%s]:[%d] First msdu payload not present", |
| 528 | __func__, __LINE__); |
| 529 | return 1; |
| 530 | } |
| 531 | |
sumedh baikady | da15920 | 2018-11-01 17:31:23 -0700 | [diff] [blame] | 532 | /* Adding 4 bytes to get to start of 802.11 frame after phy_ppdu_id */ |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 533 | size = (ppdu_info->msdu_info.first_msdu_payload - |
sumedh baikady | da15920 | 2018-11-01 17:31:23 -0700 | [diff] [blame] | 534 | qdf_nbuf_data(nbuf)) + 4; |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 535 | ppdu_info->msdu_info.first_msdu_payload = NULL; |
| 536 | |
| 537 | if (qdf_nbuf_pull_head(nbuf, size) == NULL) { |
| 538 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 539 | "[%s]:[%d] No header present", |
| 540 | __func__, __LINE__); |
| 541 | return 1; |
| 542 | } |
| 543 | |
sumedh baikady | da15920 | 2018-11-01 17:31:23 -0700 | [diff] [blame] | 544 | /* Only retain RX MSDU payload in the skb */ |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 545 | qdf_nbuf_trim_tail(nbuf, qdf_nbuf_len(nbuf) - |
| 546 | ppdu_info->msdu_info.payload_len); |
Shashikala Prabhu | 0843438 | 2019-07-16 15:42:03 +0530 | [diff] [blame] | 547 | if (!qdf_nbuf_update_radiotap(&pdev->ppdu_info.rx_status, nbuf, |
| 548 | qdf_nbuf_headroom(nbuf))) { |
| 549 | DP_STATS_INC(pdev, dropped.mon_radiotap_update_err, 1); |
| 550 | return 1; |
| 551 | } |
| 552 | |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 553 | pdev->monitor_vdev->osif_rx_mon(pdev->monitor_vdev->osif_vdev, |
| 554 | nbuf, NULL); |
sumedh baikady | da15920 | 2018-11-01 17:31:23 -0700 | [diff] [blame] | 555 | pdev->ppdu_info.rx_status.monitor_direct_used = 0; |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 556 | return 0; |
| 557 | } |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 558 | |
| 559 | /** |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 560 | * dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer |
| 561 | * @soc: core txrx main context |
| 562 | * @pdev: pdev strcuture |
| 563 | * @ppdu_info: structure for rx ppdu ring |
| 564 | * |
| 565 | * Return: none |
| 566 | */ |
| 567 | #ifdef FEATURE_PERPKT_INFO |
| 568 | static inline void |
| 569 | dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev, |
| 570 | struct hal_rx_ppdu_info *ppdu_info) |
| 571 | { |
| 572 | qdf_nbuf_t ppdu_nbuf; |
| 573 | struct dp_peer *peer; |
| 574 | struct cdp_rx_indication_ppdu *cdp_rx_ppdu; |
| 575 | |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 576 | /* |
| 577 | * Do not allocate if fcs error, |
| 578 | * ast idx invalid / fctl invalid |
| 579 | */ |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 580 | if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0) |
| 581 | return; |
| 582 | |
Chaithanya Garrepalli | 95fc62f | 2018-07-24 18:52:27 +0530 | [diff] [blame] | 583 | if (ppdu_info->nac_info.fc_valid && |
| 584 | ppdu_info->nac_info.to_ds_flag && |
| 585 | ppdu_info->nac_info.mac_addr2_valid) { |
| 586 | struct dp_neighbour_peer *peer = NULL; |
| 587 | uint8_t rssi = ppdu_info->rx_status.rssi_comb; |
| 588 | |
| 589 | qdf_spin_lock_bh(&pdev->neighbour_peer_mutex); |
| 590 | if (pdev->neighbour_peers_added) { |
| 591 | TAILQ_FOREACH(peer, &pdev->neighbour_peers_list, |
| 592 | neighbour_peer_list_elem) { |
| 593 | if (!qdf_mem_cmp(&peer->neighbour_peers_macaddr, |
| 594 | &ppdu_info->nac_info.mac_addr2, |
Srinivas Girigowda | 2751b6d | 2019-02-27 12:28:13 -0800 | [diff] [blame] | 595 | QDF_MAC_ADDR_SIZE)) { |
Chaithanya Garrepalli | 95fc62f | 2018-07-24 18:52:27 +0530 | [diff] [blame] | 596 | peer->rssi = rssi; |
| 597 | break; |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | qdf_spin_unlock_bh(&pdev->neighbour_peer_mutex); |
| 602 | } |
| 603 | |
Chaithanya Garrepalli | 3e4ac1c | 2018-12-12 20:50:45 +0530 | [diff] [blame] | 604 | /* need not generate wdi event when mcopy and |
| 605 | * enhanced stats are not enabled |
| 606 | */ |
| 607 | if (!pdev->mcopy_mode && !pdev->enhanced_stats_en) |
| 608 | return; |
| 609 | |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 610 | if (!pdev->mcopy_mode) { |
| 611 | if (!ppdu_info->rx_status.frame_control_info_valid) |
| 612 | return; |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 613 | |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 614 | if (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID) |
| 615 | return; |
| 616 | } |
Tallapragada Kalyan | a867edf | 2017-11-14 12:26:41 +0530 | [diff] [blame] | 617 | ppdu_nbuf = qdf_nbuf_alloc(soc->osdev, |
Kiran Venkatappa | 4b50f33 | 2019-03-20 18:14:17 +0530 | [diff] [blame] | 618 | sizeof(struct cdp_rx_indication_ppdu), 0, 0, FALSE); |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 619 | if (ppdu_nbuf) { |
Soumya Bhat | 560f90c | 2018-03-30 13:53:26 +0530 | [diff] [blame] | 620 | dp_rx_populate_cdp_indication_ppdu(pdev, ppdu_info, ppdu_nbuf); |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 621 | qdf_nbuf_put_tail(ppdu_nbuf, |
| 622 | sizeof(struct cdp_rx_indication_ppdu)); |
| 623 | cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data; |
Ruchi, Agrawal | 4c5ade6 | 2018-09-27 21:52:11 +0530 | [diff] [blame] | 624 | peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id); |
chenguo | b21a49a | 2018-11-19 19:17:12 +0800 | [diff] [blame] | 625 | if (peer) { |
Amir Patel | 468bded | 2019-03-21 11:42:31 +0530 | [diff] [blame] | 626 | cdp_rx_ppdu->cookie = (void *)peer->wlanstats_ctx; |
Ruchi, Agrawal | 4c5ade6 | 2018-09-27 21:52:11 +0530 | [diff] [blame] | 627 | dp_rx_stats_update(pdev, peer, cdp_rx_ppdu); |
chenguo | b21a49a | 2018-11-19 19:17:12 +0800 | [diff] [blame] | 628 | dp_peer_unref_del_find_by_id(peer); |
| 629 | } |
| 630 | if (cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) { |
| 631 | dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, |
| 632 | soc, ppdu_nbuf, |
| 633 | cdp_rx_ppdu->peer_id, |
| 634 | WDI_NO_VAL, pdev->pdev_id); |
| 635 | } else if (pdev->mcopy_mode) { |
Soumya Bhat | 2f54de2 | 2018-02-21 09:54:28 +0530 | [diff] [blame] | 636 | dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc, |
| 637 | ppdu_nbuf, HTT_INVALID_PEER, |
| 638 | WDI_NO_VAL, pdev->pdev_id); |
| 639 | } else { |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 640 | qdf_nbuf_free(ppdu_nbuf); |
Soumya Bhat | 2f54de2 | 2018-02-21 09:54:28 +0530 | [diff] [blame] | 641 | } |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 642 | } |
| 643 | } |
| 644 | #else |
| 645 | static inline void |
| 646 | dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev, |
| 647 | struct hal_rx_ppdu_info *ppdu_info) |
| 648 | { |
| 649 | } |
| 650 | #endif |
| 651 | |
| 652 | /** |
Keyur Parekh | c28f839 | 2018-11-21 02:50:56 -0800 | [diff] [blame] | 653 | * dp_rx_process_peer_based_pktlog() - Process Rx pktlog if peer based |
| 654 | * filtering enabled |
| 655 | * @soc: core txrx main context |
| 656 | * @ppdu_info: Structure for rx ppdu info |
| 657 | * @status_nbuf: Qdf nbuf abstraction for linux skb |
| 658 | * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN |
| 659 | * |
| 660 | * Return: none |
| 661 | */ |
| 662 | static inline void |
| 663 | dp_rx_process_peer_based_pktlog(struct dp_soc *soc, |
| 664 | struct hal_rx_ppdu_info *ppdu_info, |
| 665 | qdf_nbuf_t status_nbuf, uint32_t mac_id) |
| 666 | { |
| 667 | struct dp_peer *peer; |
| 668 | struct dp_ast_entry *ast_entry; |
| 669 | uint32_t ast_index; |
| 670 | |
| 671 | ast_index = ppdu_info->rx_status.ast_index; |
| 672 | if (ast_index < (WLAN_UMAC_PSOC_MAX_PEERS * 2)) { |
| 673 | ast_entry = soc->ast_table[ast_index]; |
| 674 | if (ast_entry) { |
| 675 | peer = ast_entry->peer; |
| 676 | if (peer && (peer->peer_ids[0] != HTT_INVALID_PEER)) { |
| 677 | if (peer->peer_based_pktlog_filter) { |
| 678 | dp_wdi_event_handler( |
| 679 | WDI_EVENT_RX_DESC, soc, |
| 680 | status_nbuf, |
| 681 | peer->peer_ids[0], |
| 682 | WDI_NO_VAL, mac_id); |
| 683 | } |
| 684 | } |
| 685 | } |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | /** |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 690 | * dp_rx_mon_status_process_tlv() - Process status TLV in status |
| 691 | * buffer on Rx status Queue posted by status SRNG processing. |
| 692 | * @soc: core txrx main context |
| 693 | * @mac_id: mac_id which is one of 3 mac_ids _ring |
| 694 | * |
| 695 | * Return: none |
| 696 | */ |
| 697 | static inline void |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 698 | dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id, |
| 699 | uint32_t quota) |
| 700 | { |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 701 | struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 702 | struct hal_rx_ppdu_info *ppdu_info; |
| 703 | qdf_nbuf_t status_nbuf; |
| 704 | uint8_t *rx_tlv; |
| 705 | uint8_t *rx_tlv_start; |
Kai Chen | ad516ae | 2017-09-08 18:35:47 -0700 | [diff] [blame] | 706 | uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE; |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 707 | QDF_STATUS enh_log_status = QDF_STATUS_SUCCESS; |
Kai Chen | 783e038 | 2018-01-25 16:29:08 -0800 | [diff] [blame] | 708 | struct cdp_pdev_mon_stats *rx_mon_stats; |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 709 | int smart_mesh_status; |
Venkata Sharath Chandra Manchala | cad74ad | 2019-01-28 11:36:47 -0800 | [diff] [blame] | 710 | enum WDI_EVENT pktlog_mode = WDI_NO_VAL; |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 711 | bool nbuf_used; |
| 712 | uint32_t rx_enh_capture_mode; |
| 713 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 714 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 715 | ppdu_info = &pdev->ppdu_info; |
Kai Chen | 783e038 | 2018-01-25 16:29:08 -0800 | [diff] [blame] | 716 | rx_mon_stats = &pdev->rx_mon_stats; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 717 | |
| 718 | if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START) |
| 719 | return; |
| 720 | |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 721 | rx_enh_capture_mode = pdev->rx_enh_capture_mode; |
| 722 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 723 | while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) { |
| 724 | |
| 725 | status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q); |
phadiman | 4975730 | 2018-12-18 16:13:59 +0530 | [diff] [blame] | 726 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 727 | rx_tlv = qdf_nbuf_data(status_nbuf); |
| 728 | rx_tlv_start = rx_tlv; |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 729 | nbuf_used = false; |
Venkata Sharath Chandra Manchala | 5a6f429 | 2017-11-03 14:57:41 -0700 | [diff] [blame] | 730 | |
Jeff Johnson | a8edf33 | 2019-03-18 09:51:52 -0700 | [diff] [blame] | 731 | if ((pdev->monitor_vdev) || (pdev->enhanced_stats_en) || |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 732 | pdev->mcopy_mode || |
| 733 | (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED)) { |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 734 | do { |
| 735 | tlv_status = hal_rx_status_get_tlv_info(rx_tlv, |
Amir Patel | 57e7e05 | 2019-05-15 20:49:57 +0530 | [diff] [blame] | 736 | ppdu_info, pdev->soc->hal_soc, |
| 737 | status_nbuf); |
Kai Chen | 783e038 | 2018-01-25 16:29:08 -0800 | [diff] [blame] | 738 | |
| 739 | dp_rx_mon_update_dbg_ppdu_stats(ppdu_info, |
| 740 | rx_mon_stats); |
| 741 | |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 742 | dp_rx_mon_enh_capture_process(pdev, tlv_status, |
| 743 | status_nbuf, ppdu_info, |
Karunakar Dasineni | acc8b56 | 2019-05-07 07:00:24 -0700 | [diff] [blame] | 744 | &nbuf_used); |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 745 | |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 746 | rx_tlv = hal_rx_status_get_next_tlv(rx_tlv); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 747 | |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 748 | if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE) |
| 749 | break; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 750 | |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 751 | } while ((tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE) || |
| 752 | (tlv_status == HAL_TLV_STATUS_HEADER) || |
Karunakar Dasineni | acc8b56 | 2019-05-07 07:00:24 -0700 | [diff] [blame] | 753 | (tlv_status == HAL_TLV_STATUS_MPDU_END) || |
| 754 | (tlv_status == HAL_TLV_STATUS_MSDU_END)); |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 755 | } |
Keyur Parekh | c28f839 | 2018-11-21 02:50:56 -0800 | [diff] [blame] | 756 | if (pdev->dp_peer_based_pktlog) { |
| 757 | dp_rx_process_peer_based_pktlog(soc, ppdu_info, |
| 758 | status_nbuf, mac_id); |
| 759 | } else { |
Venkata Sharath Chandra Manchala | cad74ad | 2019-01-28 11:36:47 -0800 | [diff] [blame] | 760 | if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_FULL) |
| 761 | pktlog_mode = WDI_EVENT_RX_DESC; |
| 762 | else if (pdev->rx_pktlog_mode == DP_RX_PKTLOG_LITE) |
| 763 | pktlog_mode = WDI_EVENT_LITE_RX; |
| 764 | |
| 765 | if (pktlog_mode != WDI_NO_VAL) |
| 766 | dp_wdi_event_handler(pktlog_mode, soc, |
| 767 | status_nbuf, |
| 768 | HTT_INVALID_PEER, |
| 769 | WDI_NO_VAL, mac_id); |
Keyur Parekh | c28f839 | 2018-11-21 02:50:56 -0800 | [diff] [blame] | 770 | } |
Chaithanya Garrepalli | 3e4ac1c | 2018-12-12 20:50:45 +0530 | [diff] [blame] | 771 | |
| 772 | /* smart monitor vap and m_copy cannot co-exist */ |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 773 | if (ppdu_info->rx_status.monitor_direct_used && pdev->neighbour_peers_added |
| 774 | && pdev->monitor_vdev) { |
| 775 | smart_mesh_status = dp_rx_handle_smart_mesh_mode(soc, |
| 776 | pdev, ppdu_info, status_nbuf); |
| 777 | if (smart_mesh_status) |
| 778 | qdf_nbuf_free(status_nbuf); |
Amir Patel | 57e7e05 | 2019-05-15 20:49:57 +0530 | [diff] [blame] | 779 | } else if (qdf_unlikely(pdev->mcopy_mode)) { |
| 780 | dp_rx_process_mcopy_mode(soc, pdev, |
| 781 | ppdu_info, tlv_status, |
| 782 | status_nbuf); |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 783 | } else if (rx_enh_capture_mode != CDP_RX_ENH_CAPTURE_DISABLED) { |
| 784 | if (!nbuf_used) |
| 785 | qdf_nbuf_free(status_nbuf); |
| 786 | |
| 787 | if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) |
| 788 | enh_log_status = |
| 789 | dp_rx_handle_enh_capture(soc, |
| 790 | pdev, ppdu_info); |
Chaithanya Garrepalli | 3e4ac1c | 2018-12-12 20:50:45 +0530 | [diff] [blame] | 791 | } else { |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 792 | qdf_nbuf_free(status_nbuf); |
Chaithanya Garrepalli | 3e4ac1c | 2018-12-12 20:50:45 +0530 | [diff] [blame] | 793 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 794 | |
chenguo | 1b88046 | 2018-07-11 15:34:56 +0800 | [diff] [blame] | 795 | if (tlv_status == HAL_TLV_STATUS_PPDU_NON_STD_DONE) { |
| 796 | dp_rx_mon_deliver_non_std(soc, mac_id); |
| 797 | } else if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) { |
Kai Chen | 783e038 | 2018-01-25 16:29:08 -0800 | [diff] [blame] | 798 | rx_mon_stats->status_ppdu_done++; |
Soumya Bhat | 5c60deb | 2017-12-12 16:42:04 +0530 | [diff] [blame] | 799 | if (pdev->enhanced_stats_en || |
sumedh baikady | 59a2d33 | 2018-05-22 01:50:38 -0700 | [diff] [blame] | 800 | pdev->mcopy_mode || pdev->neighbour_peers_added) |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 801 | dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info); |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 802 | |
nobelj | 1c31fee | 2018-03-21 11:47:05 -0700 | [diff] [blame] | 803 | pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE; |
| 804 | dp_rx_mon_dest_process(soc, mac_id, quota); |
Kai Chen | cbe4c34 | 2017-06-12 20:06:35 -0700 | [diff] [blame] | 805 | pdev->mon_ppdu_status = DP_PPDU_STATUS_START; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 806 | } |
| 807 | } |
| 808 | return; |
| 809 | } |
| 810 | |
| 811 | /* |
| 812 | * dp_rx_mon_status_srng_process() - Process monitor status ring |
| 813 | * post the status ring buffer to Rx status Queue for later |
| 814 | * processing when status ring is filled with status TLV. |
| 815 | * Allocate a new buffer to status ring if the filled buffer |
| 816 | * is posted. |
| 817 | * |
| 818 | * @soc: core txrx main context |
| 819 | * @mac_id: mac_id which is one of 3 mac_ids |
| 820 | * @quota: No. of ring entry that can be serviced in one shot. |
| 821 | |
| 822 | * Return: uint32_t: No. of ring entry that is processed. |
| 823 | */ |
| 824 | static inline uint32_t |
| 825 | dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id, |
| 826 | uint32_t quota) |
| 827 | { |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 828 | struct dp_pdev *pdev = dp_get_pdev_for_mac_id(soc, mac_id); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 829 | void *hal_soc; |
| 830 | void *mon_status_srng; |
| 831 | void *rxdma_mon_status_ring_entry; |
| 832 | QDF_STATUS status; |
| 833 | uint32_t work_done = 0; |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 834 | int mac_for_pdev = dp_get_mac_id_for_mac(soc, mac_id); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 835 | |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 836 | mon_status_srng = pdev->rxdma_mon_status_ring[mac_for_pdev].hal_srng; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 837 | |
| 838 | qdf_assert(mon_status_srng); |
Houston Hoffman | 648a918 | 2017-05-21 23:27:50 -0700 | [diff] [blame] | 839 | if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) { |
| 840 | |
| 841 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Aditya Sathish | ded018e | 2018-07-02 16:25:21 +0530 | [diff] [blame] | 842 | "%s %d : HAL Monitor Status Ring Init Failed -- %pK", |
Houston Hoffman | 648a918 | 2017-05-21 23:27:50 -0700 | [diff] [blame] | 843 | __func__, __LINE__, mon_status_srng); |
| 844 | return work_done; |
| 845 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 846 | |
| 847 | hal_soc = soc->hal_soc; |
| 848 | |
| 849 | qdf_assert(hal_soc); |
| 850 | |
| 851 | if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng))) |
| 852 | goto done; |
| 853 | |
| 854 | /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT => |
| 855 | * BUFFER_ADDR_INFO STRUCT |
| 856 | */ |
| 857 | while (qdf_likely((rxdma_mon_status_ring_entry = |
| 858 | hal_srng_src_peek(hal_soc, mon_status_srng)) |
| 859 | && quota--)) { |
| 860 | uint32_t rx_buf_cookie; |
| 861 | qdf_nbuf_t status_nbuf; |
| 862 | struct dp_rx_desc *rx_desc; |
| 863 | uint8_t *status_buf; |
| 864 | qdf_dma_addr_t paddr; |
| 865 | uint64_t buf_addr; |
| 866 | |
| 867 | buf_addr = |
| 868 | (HAL_RX_BUFFER_ADDR_31_0_GET( |
| 869 | rxdma_mon_status_ring_entry) | |
| 870 | ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET( |
| 871 | rxdma_mon_status_ring_entry)) << 32)); |
| 872 | |
| 873 | if (qdf_likely(buf_addr)) { |
| 874 | |
| 875 | rx_buf_cookie = |
| 876 | HAL_RX_BUF_COOKIE_GET( |
| 877 | rxdma_mon_status_ring_entry); |
| 878 | rx_desc = dp_rx_cookie_2_va_mon_status(soc, |
| 879 | rx_buf_cookie); |
| 880 | |
| 881 | qdf_assert(rx_desc); |
| 882 | |
| 883 | status_nbuf = rx_desc->nbuf; |
| 884 | |
| 885 | qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf, |
| 886 | QDF_DMA_FROM_DEVICE); |
| 887 | |
| 888 | status_buf = qdf_nbuf_data(status_nbuf); |
| 889 | |
| 890 | status = hal_get_rx_status_done(status_buf); |
| 891 | |
| 892 | if (status != QDF_STATUS_SUCCESS) { |
Karunakar Dasineni | 37995ac | 2018-02-06 12:37:30 -0800 | [diff] [blame] | 893 | uint32_t hp, tp; |
Venkata Sharath Chandra Manchala | 443b9b4 | 2018-10-10 12:04:54 -0700 | [diff] [blame] | 894 | hal_get_sw_hptp(hal_soc, mon_status_srng, |
| 895 | &tp, &hp); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 896 | QDF_TRACE(QDF_MODULE_ID_DP, |
Karunakar Dasineni | 37995ac | 2018-02-06 12:37:30 -0800 | [diff] [blame] | 897 | QDF_TRACE_LEVEL_ERROR, |
| 898 | "[%s][%d] status not done - hp:%u, tp:%u", |
| 899 | __func__, __LINE__, hp, tp); |
| 900 | /* WAR for missing status: Skip status entry */ |
| 901 | hal_srng_src_get_next(hal_soc, mon_status_srng); |
| 902 | continue; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 903 | } |
| 904 | qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE); |
| 905 | |
| 906 | qdf_nbuf_unmap_single(soc->osdev, status_nbuf, |
| 907 | QDF_DMA_FROM_DEVICE); |
| 908 | |
| 909 | /* Put the status_nbuf to queue */ |
| 910 | qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf); |
| 911 | |
| 912 | } else { |
| 913 | union dp_rx_desc_list_elem_t *desc_list = NULL; |
| 914 | union dp_rx_desc_list_elem_t *tail = NULL; |
| 915 | struct rx_desc_pool *rx_desc_pool; |
| 916 | uint32_t num_alloc_desc; |
| 917 | |
| 918 | rx_desc_pool = &soc->rx_desc_status[mac_id]; |
| 919 | |
| 920 | num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id, |
| 921 | rx_desc_pool, |
| 922 | 1, |
| 923 | &desc_list, |
| 924 | &tail); |
phadiman | ebf4cde | 2019-01-28 17:50:37 +0530 | [diff] [blame] | 925 | /* |
| 926 | * No free descriptors available |
| 927 | */ |
| 928 | if (qdf_unlikely(num_alloc_desc == 0)) { |
| 929 | work_done++; |
| 930 | break; |
| 931 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 932 | |
| 933 | rx_desc = &desc_list->rx_desc; |
| 934 | } |
| 935 | |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 936 | status_nbuf = dp_rx_nbuf_prepare(soc, pdev); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 937 | |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 938 | /* |
| 939 | * qdf_nbuf alloc or map failed, |
| 940 | * free the dp rx desc to free list, |
| 941 | * fill in NULL dma address at current HP entry, |
| 942 | * keep HP in mon_status_ring unchanged, |
| 943 | * wait next time dp_rx_mon_status_srng_process |
| 944 | * to fill in buffer at current HP. |
| 945 | */ |
Jeff Johnson | a8edf33 | 2019-03-18 09:51:52 -0700 | [diff] [blame] | 946 | if (qdf_unlikely(!status_nbuf)) { |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 947 | union dp_rx_desc_list_elem_t *desc_list = NULL; |
| 948 | union dp_rx_desc_list_elem_t *tail = NULL; |
| 949 | struct rx_desc_pool *rx_desc_pool; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 950 | |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 951 | rx_desc_pool = &soc->rx_desc_status[mac_id]; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 952 | |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 953 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 954 | "%s: fail to allocate or map qdf_nbuf", |
| 955 | __func__); |
| 956 | dp_rx_add_to_free_desc_list(&desc_list, |
| 957 | &tail, rx_desc); |
| 958 | dp_rx_add_desc_list_to_free_list(soc, &desc_list, |
| 959 | &tail, mac_id, rx_desc_pool); |
| 960 | |
| 961 | hal_rxdma_buff_addr_info_set( |
| 962 | rxdma_mon_status_ring_entry, |
| 963 | 0, 0, HAL_RX_BUF_RBM_SW3_BM); |
| 964 | work_done++; |
| 965 | break; |
| 966 | } |
| 967 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 968 | paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0); |
| 969 | |
| 970 | rx_desc->nbuf = status_nbuf; |
Pramod Simha | 59fcb31 | 2017-06-22 17:43:16 -0700 | [diff] [blame] | 971 | rx_desc->in_use = 1; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 972 | |
| 973 | hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry, |
| 974 | paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM); |
| 975 | |
Karunakar Dasineni | 37995ac | 2018-02-06 12:37:30 -0800 | [diff] [blame] | 976 | hal_srng_src_get_next(hal_soc, mon_status_srng); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 977 | work_done++; |
| 978 | } |
| 979 | done: |
| 980 | |
| 981 | hal_srng_access_end(hal_soc, mon_status_srng); |
| 982 | |
| 983 | return work_done; |
| 984 | |
| 985 | } |
| 986 | /* |
| 987 | * dp_rx_mon_status_process() - Process monitor status ring and |
| 988 | * TLV in status ring. |
| 989 | * |
| 990 | * @soc: core txrx main context |
| 991 | * @mac_id: mac_id which is one of 3 mac_ids |
| 992 | * @quota: No. of ring entry that can be serviced in one shot. |
| 993 | |
| 994 | * Return: uint32_t: No. of ring entry that is processed. |
| 995 | */ |
| 996 | static inline uint32_t |
| 997 | dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) { |
| 998 | uint32_t work_done; |
| 999 | |
| 1000 | work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota); |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 1001 | quota -= work_done; |
| 1002 | dp_rx_mon_status_process_tlv(soc, mac_id, quota); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1003 | |
| 1004 | return work_done; |
| 1005 | } |
| 1006 | /** |
| 1007 | * dp_mon_process() - Main monitor mode processing roution. |
| 1008 | * This call monitor status ring process then monitor |
| 1009 | * destination ring process. |
| 1010 | * Called from the bottom half (tasklet/NET_RX_SOFTIRQ) |
| 1011 | * @soc: core txrx main context |
| 1012 | * @mac_id: mac_id which is one of 3 mac_ids |
| 1013 | * @quota: No. of status ring entry that can be serviced in one shot. |
| 1014 | |
| 1015 | * Return: uint32_t: No. of ring entry that is processed. |
| 1016 | */ |
| 1017 | uint32_t |
| 1018 | dp_mon_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) { |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 1019 | return dp_rx_mon_status_process(soc, mac_id, quota); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1020 | } |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 1021 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1022 | /** |
Venkata Sharath Chandra Manchala | 8747958 | 2018-08-01 12:45:34 -0700 | [diff] [blame] | 1023 | * dp_rx_pdev_mon_status_detach() - detach dp rx for status ring |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1024 | * @pdev: core txrx pdev context |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 1025 | * @mac_id: mac_id/pdev_id correspondinggly for MCL and WIN |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1026 | * |
| 1027 | * This function will detach DP RX status ring from |
| 1028 | * main device context. will free DP Rx resources for |
| 1029 | * status ring |
| 1030 | * |
| 1031 | * Return: QDF_STATUS_SUCCESS: success |
| 1032 | * QDF_STATUS_E_RESOURCES: Error return |
| 1033 | */ |
| 1034 | QDF_STATUS |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 1035 | dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev, int mac_id) |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1036 | { |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1037 | struct dp_soc *soc = pdev->soc; |
| 1038 | struct rx_desc_pool *rx_desc_pool; |
| 1039 | |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 1040 | rx_desc_pool = &soc->rx_desc_status[mac_id]; |
phadiman | 449a268 | 2019-02-20 14:00:00 +0530 | [diff] [blame] | 1041 | if (rx_desc_pool->pool_size != 0) { |
| 1042 | if (!dp_is_soc_reinit(soc)) |
Varun Reddy Yeturu | a7c21dc | 2019-05-16 14:03:46 -0700 | [diff] [blame] | 1043 | dp_rx_desc_nbuf_and_pool_free(soc, mac_id, |
| 1044 | rx_desc_pool); |
phadiman | 449a268 | 2019-02-20 14:00:00 +0530 | [diff] [blame] | 1045 | else |
Varun Reddy Yeturu | a7c21dc | 2019-05-16 14:03:46 -0700 | [diff] [blame] | 1046 | dp_rx_desc_nbuf_free(soc, rx_desc_pool); |
phadiman | 449a268 | 2019-02-20 14:00:00 +0530 | [diff] [blame] | 1047 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1048 | |
| 1049 | return QDF_STATUS_SUCCESS; |
| 1050 | } |
| 1051 | |
| 1052 | /* |
| 1053 | * dp_rx_buffers_replenish() - replenish monitor status ring with |
| 1054 | * rx nbufs called during dp rx |
| 1055 | * monitor status ring initialization |
| 1056 | * |
| 1057 | * @soc: core txrx main context |
| 1058 | * @mac_id: mac_id which is one of 3 mac_ids |
| 1059 | * @dp_rxdma_srng: dp monitor status circular ring |
| 1060 | * @rx_desc_pool; Pointer to Rx descriptor pool |
| 1061 | * @num_req_buffers: number of buffer to be replenished |
| 1062 | * @desc_list: list of descs if called from dp rx monitor status |
| 1063 | * process or NULL during dp rx initialization or |
| 1064 | * out of buffer interrupt |
| 1065 | * @tail: tail of descs list |
| 1066 | * @owner: who owns the nbuf (host, NSS etc...) |
| 1067 | * Return: return success or failure |
| 1068 | */ |
| 1069 | static inline |
| 1070 | QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc, |
| 1071 | uint32_t mac_id, |
| 1072 | struct dp_srng *dp_rxdma_srng, |
| 1073 | struct rx_desc_pool *rx_desc_pool, |
| 1074 | uint32_t num_req_buffers, |
| 1075 | union dp_rx_desc_list_elem_t **desc_list, |
| 1076 | union dp_rx_desc_list_elem_t **tail, |
| 1077 | uint8_t owner) |
| 1078 | { |
| 1079 | uint32_t num_alloc_desc; |
| 1080 | uint16_t num_desc_to_free = 0; |
| 1081 | uint32_t num_entries_avail; |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 1082 | uint32_t count = 0; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1083 | int sync_hw_ptr = 1; |
| 1084 | qdf_dma_addr_t paddr; |
| 1085 | qdf_nbuf_t rx_netbuf; |
| 1086 | void *rxdma_ring_entry; |
| 1087 | union dp_rx_desc_list_elem_t *next; |
| 1088 | void *rxdma_srng; |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 1089 | struct dp_pdev *dp_pdev = dp_get_pdev_for_mac_id(dp_soc, mac_id); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1090 | |
| 1091 | rxdma_srng = dp_rxdma_srng->hal_srng; |
| 1092 | |
| 1093 | qdf_assert(rxdma_srng); |
| 1094 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 1095 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Aditya Sathish | ded018e | 2018-07-02 16:25:21 +0530 | [diff] [blame] | 1096 | "[%s][%d] requested %d buffers for replenish", |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1097 | __func__, __LINE__, num_req_buffers); |
| 1098 | |
| 1099 | /* |
| 1100 | * if desc_list is NULL, allocate the descs from freelist |
| 1101 | */ |
| 1102 | if (!(*desc_list)) { |
| 1103 | |
| 1104 | num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id, |
| 1105 | rx_desc_pool, |
| 1106 | num_req_buffers, |
| 1107 | desc_list, |
| 1108 | tail); |
| 1109 | |
| 1110 | if (!num_alloc_desc) { |
| 1111 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
Aditya Sathish | ded018e | 2018-07-02 16:25:21 +0530 | [diff] [blame] | 1112 | "[%s][%d] no free rx_descs in freelist", |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1113 | __func__, __LINE__); |
| 1114 | return QDF_STATUS_E_NOMEM; |
| 1115 | } |
| 1116 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 1117 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Aditya Sathish | ded018e | 2018-07-02 16:25:21 +0530 | [diff] [blame] | 1118 | "[%s][%d] %d rx desc allocated", __func__, __LINE__, |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1119 | num_alloc_desc); |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 1120 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1121 | num_req_buffers = num_alloc_desc; |
| 1122 | } |
| 1123 | |
| 1124 | hal_srng_access_start(dp_soc->hal_soc, rxdma_srng); |
| 1125 | num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc, |
| 1126 | rxdma_srng, sync_hw_ptr); |
| 1127 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 1128 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Aditya Sathish | ded018e | 2018-07-02 16:25:21 +0530 | [diff] [blame] | 1129 | "[%s][%d] no of available entries in rxdma ring: %d", |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1130 | __func__, __LINE__, num_entries_avail); |
| 1131 | |
| 1132 | if (num_entries_avail < num_req_buffers) { |
| 1133 | num_desc_to_free = num_req_buffers - num_entries_avail; |
| 1134 | num_req_buffers = num_entries_avail; |
| 1135 | } |
| 1136 | |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 1137 | while (count < num_req_buffers) { |
| 1138 | rx_netbuf = dp_rx_nbuf_prepare(dp_soc, dp_pdev); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1139 | |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 1140 | /* |
| 1141 | * qdf_nbuf alloc or map failed, |
| 1142 | * keep HP in mon_status_ring unchanged, |
| 1143 | * wait dp_rx_mon_status_srng_process |
| 1144 | * to fill in buffer at current HP. |
| 1145 | */ |
Jeff Johnson | a8edf33 | 2019-03-18 09:51:52 -0700 | [diff] [blame] | 1146 | if (qdf_unlikely(!rx_netbuf)) { |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 1147 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 1148 | "%s: qdf_nbuf allocate or map fail, count %d", |
| 1149 | __func__, count); |
| 1150 | break; |
| 1151 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1152 | |
| 1153 | paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0); |
| 1154 | |
| 1155 | next = (*desc_list)->next; |
sumedh baikady | eca2de6 | 2018-04-11 14:20:38 -0700 | [diff] [blame] | 1156 | rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc, |
| 1157 | rxdma_srng); |
| 1158 | |
Jeff Johnson | a8edf33 | 2019-03-18 09:51:52 -0700 | [diff] [blame] | 1159 | if (qdf_unlikely(!rxdma_ring_entry)) { |
sumedh baikady | eca2de6 | 2018-04-11 14:20:38 -0700 | [diff] [blame] | 1160 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
Aditya Sathish | ded018e | 2018-07-02 16:25:21 +0530 | [diff] [blame] | 1161 | "[%s][%d] rxdma_ring_entry is NULL, count - %d", |
sumedh baikady | eca2de6 | 2018-04-11 14:20:38 -0700 | [diff] [blame] | 1162 | __func__, __LINE__, count); |
| 1163 | qdf_nbuf_unmap_single(dp_soc->osdev, rx_netbuf, |
Ankit Kumar | 0ae4abc | 2019-05-02 15:08:42 +0530 | [diff] [blame] | 1164 | QDF_DMA_FROM_DEVICE); |
sumedh baikady | eca2de6 | 2018-04-11 14:20:38 -0700 | [diff] [blame] | 1165 | qdf_nbuf_free(rx_netbuf); |
| 1166 | break; |
| 1167 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1168 | |
| 1169 | (*desc_list)->rx_desc.nbuf = rx_netbuf; |
Pramod Simha | 59fcb31 | 2017-06-22 17:43:16 -0700 | [diff] [blame] | 1170 | (*desc_list)->rx_desc.in_use = 1; |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 1171 | count++; |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 1172 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1173 | hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr, |
| 1174 | (*desc_list)->rx_desc.cookie, owner); |
| 1175 | |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 1176 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Jeff Johnson | 3f217e2 | 2017-09-18 10:13:35 -0700 | [diff] [blame] | 1177 | "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \ |
Aditya Sathish | ded018e | 2018-07-02 16:25:21 +0530 | [diff] [blame] | 1178 | paddr=%pK", |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1179 | __func__, __LINE__, &(*desc_list)->rx_desc, |
| 1180 | (*desc_list)->rx_desc.cookie, rx_netbuf, |
jinweic chen | c354632 | 2018-02-02 15:03:41 +0800 | [diff] [blame] | 1181 | (void *)paddr); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1182 | |
| 1183 | *desc_list = next; |
| 1184 | } |
| 1185 | |
| 1186 | hal_srng_access_end(dp_soc->hal_soc, rxdma_srng); |
| 1187 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 1188 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Aditya Sathish | ded018e | 2018-07-02 16:25:21 +0530 | [diff] [blame] | 1189 | "successfully replenished %d buffers", num_req_buffers); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1190 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 1191 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Aditya Sathish | ded018e | 2018-07-02 16:25:21 +0530 | [diff] [blame] | 1192 | "%d rx desc added back to free list", num_desc_to_free); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1193 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1194 | /* |
| 1195 | * add any available free desc back to the free list |
| 1196 | */ |
| 1197 | if (*desc_list) { |
| 1198 | dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail, |
| 1199 | mac_id, rx_desc_pool); |
| 1200 | } |
| 1201 | |
| 1202 | return QDF_STATUS_SUCCESS; |
| 1203 | } |
| 1204 | /** |
| 1205 | * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring |
| 1206 | * @pdev: core txrx pdev context |
Venkata Sharath Chandra Manchala | 8747958 | 2018-08-01 12:45:34 -0700 | [diff] [blame] | 1207 | * @ring_id: ring number |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1208 | * This function will attach a DP RX monitor status ring into pDEV |
| 1209 | * and replenish monitor status ring with buffer. |
| 1210 | * |
| 1211 | * Return: QDF_STATUS_SUCCESS: success |
| 1212 | * QDF_STATUS_E_RESOURCES: Error return |
| 1213 | */ |
| 1214 | QDF_STATUS |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 1215 | dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev, int ring_id) { |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1216 | struct dp_soc *soc = pdev->soc; |
| 1217 | union dp_rx_desc_list_elem_t *desc_list = NULL; |
| 1218 | union dp_rx_desc_list_elem_t *tail = NULL; |
Mohit Khanna | 7051499 | 2018-11-12 18:39:03 -0800 | [diff] [blame] | 1219 | struct dp_srng *mon_status_ring; |
| 1220 | uint32_t num_entries; |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 1221 | uint32_t i; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1222 | struct rx_desc_pool *rx_desc_pool; |
Ravi Joshi | a9ebe0a | 2017-06-17 16:43:02 -0700 | [diff] [blame] | 1223 | QDF_STATUS status; |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 1224 | int mac_for_pdev = dp_get_mac_id_for_mac(soc, ring_id); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1225 | |
Mohit Khanna | 7051499 | 2018-11-12 18:39:03 -0800 | [diff] [blame] | 1226 | mon_status_ring = &pdev->rxdma_mon_status_ring[mac_for_pdev]; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1227 | |
Mohit Khanna | 7051499 | 2018-11-12 18:39:03 -0800 | [diff] [blame] | 1228 | num_entries = mon_status_ring->num_entries; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1229 | |
Manjunathappa Prakash | d9ce350 | 2018-02-05 14:09:17 -0800 | [diff] [blame] | 1230 | rx_desc_pool = &soc->rx_desc_status[ring_id]; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1231 | |
Mohit Khanna | 7051499 | 2018-11-12 18:39:03 -0800 | [diff] [blame] | 1232 | dp_info("Mon RX Status Pool[%d] entries=%d", |
| 1233 | ring_id, num_entries); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1234 | |
Mohit Khanna | 7051499 | 2018-11-12 18:39:03 -0800 | [diff] [blame] | 1235 | status = dp_rx_desc_pool_alloc(soc, ring_id, num_entries + 1, |
| 1236 | rx_desc_pool); |
| 1237 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Ravi Joshi | a9ebe0a | 2017-06-17 16:43:02 -0700 | [diff] [blame] | 1238 | return status; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1239 | |
Mohit Khanna | 7051499 | 2018-11-12 18:39:03 -0800 | [diff] [blame] | 1240 | dp_debug("Mon RX Status Buffers Replenish ring_id=%d", ring_id); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1241 | |
Mohit Khanna | 7051499 | 2018-11-12 18:39:03 -0800 | [diff] [blame] | 1242 | status = dp_rx_mon_status_buffers_replenish(soc, ring_id, |
| 1243 | mon_status_ring, |
| 1244 | rx_desc_pool, |
| 1245 | num_entries, |
| 1246 | &desc_list, &tail, |
| 1247 | HAL_RX_BUF_RBM_SW3_BM); |
| 1248 | |
| 1249 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Ravi Joshi | a9ebe0a | 2017-06-17 16:43:02 -0700 | [diff] [blame] | 1250 | return status; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1251 | |
| 1252 | qdf_nbuf_queue_init(&pdev->rx_status_q); |
Amir Patel | 57e7e05 | 2019-05-15 20:49:57 +0530 | [diff] [blame] | 1253 | qdf_nbuf_queue_init(&pdev->rx_ppdu_buf_q); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1254 | |
| 1255 | pdev->mon_ppdu_status = DP_PPDU_STATUS_START; |
Kai Chen | 783e038 | 2018-01-25 16:29:08 -0800 | [diff] [blame] | 1256 | |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 1257 | qdf_mem_zero(&(pdev->ppdu_info.rx_status), |
Mohit Khanna | 7051499 | 2018-11-12 18:39:03 -0800 | [diff] [blame] | 1258 | sizeof(pdev->ppdu_info.rx_status)); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1259 | |
Kai Chen | 783e038 | 2018-01-25 16:29:08 -0800 | [diff] [blame] | 1260 | qdf_mem_zero(&pdev->rx_mon_stats, |
| 1261 | sizeof(pdev->rx_mon_stats)); |
| 1262 | |
| 1263 | dp_rx_mon_init_dbg_ppdu_stats(&pdev->ppdu_info, |
| 1264 | &pdev->rx_mon_stats); |
| 1265 | |
Kai Chen | 52ef33f | 2019-03-05 18:33:40 -0800 | [diff] [blame] | 1266 | for (i = 0; i < MAX_MU_USERS; i++) { |
| 1267 | qdf_nbuf_queue_init(&pdev->mpdu_q[i]); |
| 1268 | pdev->is_mpdu_hdr[i] = true; |
| 1269 | } |
| 1270 | qdf_mem_zero(pdev->msdu_list, sizeof(pdev->msdu_list[MAX_MU_USERS])); |
| 1271 | |
| 1272 | pdev->rx_enh_capture_mode = CDP_RX_ENH_CAPTURE_DISABLED; |
| 1273 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 1274 | return QDF_STATUS_SUCCESS; |
| 1275 | } |