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