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