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