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