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