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