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