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 | */ |
| 18 | #include "dp_types.h" |
| 19 | #include "dp_rx.h" |
| 20 | #include "dp_peer.h" |
| 21 | #include "hal_rx.h" |
| 22 | #include "hal_api.h" |
| 23 | #include "qdf_trace.h" |
| 24 | #include "qdf_nbuf.h" |
| 25 | #include "hal_api_mon.h" |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 26 | #include "dp_rx_mon.h" |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 27 | #include "dp_internal.h" |
| 28 | #include "qdf_mem.h" /* qdf_mem_malloc,free */ |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 29 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 30 | /** |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 31 | * dp_rx_populate_cdp_indication_ppdu() - Populate cdp rx indication structure |
| 32 | * @soc: core txrx main context |
| 33 | * @ppdu_info: ppdu info structure from ppdu ring |
| 34 | * @ppdu_nbuf: qdf nbuf abstraction for linux skb |
| 35 | * |
| 36 | * Return: none |
| 37 | */ |
| 38 | #ifdef FEATURE_PERPKT_INFO |
| 39 | static inline void |
| 40 | dp_rx_populate_cdp_indication_ppdu(struct dp_soc *soc, |
| 41 | struct hal_rx_ppdu_info *ppdu_info, |
| 42 | qdf_nbuf_t ppdu_nbuf) |
| 43 | { |
| 44 | struct dp_peer *peer; |
| 45 | struct dp_ast_entry *ast_entry; |
| 46 | struct cdp_rx_indication_ppdu *cdp_rx_ppdu; |
| 47 | uint32_t ast_index; |
| 48 | |
| 49 | cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data; |
| 50 | |
| 51 | ast_index = ppdu_info->rx_status.ast_index; |
| 52 | if (ast_index > (WLAN_UMAC_PSOC_MAX_PEERS * 2)) { |
| 53 | cdp_rx_ppdu->peer_id = HTT_INVALID_PEER; |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | ast_entry = soc->ast_table[ast_index]; |
| 58 | if (!ast_entry) { |
| 59 | cdp_rx_ppdu->peer_id = HTT_INVALID_PEER; |
| 60 | return; |
| 61 | } |
| 62 | peer = ast_entry->peer; |
| 63 | if (!peer || peer->peer_ids[0] == HTT_INVALID_PEER) { |
| 64 | cdp_rx_ppdu->peer_id = HTT_INVALID_PEER; |
| 65 | return; |
| 66 | } |
| 67 | |
Pamidipati, Vijay | d7eb83e | 2017-09-20 21:19:56 +0530 | [diff] [blame] | 68 | qdf_mem_copy(cdp_rx_ppdu->mac_addr, |
| 69 | peer->mac_addr.raw, DP_MAC_ADDR_LEN); |
| 70 | cdp_rx_ppdu->first_data_seq_ctrl = |
| 71 | ppdu_info->rx_status.first_data_seq_ctrl; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 72 | cdp_rx_ppdu->peer_id = peer->peer_ids[0]; |
Pamidipati, Vijay | d7eb83e | 2017-09-20 21:19:56 +0530 | [diff] [blame] | 73 | cdp_rx_ppdu->vdev_id = peer->vdev->vdev_id; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 74 | cdp_rx_ppdu->ppdu_id = ppdu_info->com_info.ppdu_id; |
| 75 | cdp_rx_ppdu->duration = ppdu_info->rx_status.duration; |
| 76 | cdp_rx_ppdu->u.bw = ppdu_info->rx_status.bw; |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 77 | cdp_rx_ppdu->tcp_msdu_count = ppdu_info->rx_status.tcp_msdu_count; |
| 78 | cdp_rx_ppdu->udp_msdu_count = ppdu_info->rx_status.udp_msdu_count; |
| 79 | 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] | 80 | cdp_rx_ppdu->u.nss = ppdu_info->rx_status.nss; |
| 81 | cdp_rx_ppdu->u.mcs = ppdu_info->rx_status.mcs; |
Anish Nataraj | 072d897 | 2018-01-09 18:23:33 +0530 | [diff] [blame] | 82 | cdp_rx_ppdu->u.gi = ppdu_info->rx_status.sgi; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 83 | cdp_rx_ppdu->u.preamble = ppdu_info->rx_status.preamble_type; |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 84 | cdp_rx_ppdu->u.ppdu_type = ppdu_info->rx_status.reception_type; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 85 | cdp_rx_ppdu->rssi = ppdu_info->rx_status.rssi_comb; |
| 86 | cdp_rx_ppdu->timestamp = ppdu_info->com_info.ppdu_timestamp; |
| 87 | cdp_rx_ppdu->channel = ppdu_info->rx_status.chan_freq; |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 88 | cdp_rx_ppdu->num_msdu = (cdp_rx_ppdu->tcp_msdu_count + |
| 89 | cdp_rx_ppdu->udp_msdu_count + |
| 90 | cdp_rx_ppdu->other_msdu_count); |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 91 | |
| 92 | if (ppdu_info->com_info.mpdu_cnt_fcs_ok > 1) |
| 93 | cdp_rx_ppdu->is_ampdu = 1; |
| 94 | else |
| 95 | cdp_rx_ppdu->is_ampdu = 0; |
Anish Nataraj | 45d282c | 2017-12-30 01:03:38 +0530 | [diff] [blame] | 96 | |
| 97 | cdp_rx_ppdu->tid = ppdu_info->rx_status.tid; |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 98 | } |
| 99 | #else |
| 100 | static inline void |
| 101 | dp_rx_populate_cdp_indication_ppdu(struct dp_soc *soc, |
| 102 | struct hal_rx_ppdu_info *ppdu_info, |
| 103 | qdf_nbuf_t ppdu_nbuf) |
| 104 | { |
| 105 | } |
| 106 | #endif |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 107 | /** |
| 108 | * dp_rx_stats_update() - Update per-peer statistics |
| 109 | * @soc: Datapath SOC handle |
| 110 | * @peer: Datapath peer handle |
| 111 | * @ppdu: PPDU Descriptor |
| 112 | * |
| 113 | * Return: None |
| 114 | */ |
| 115 | #ifdef FEATURE_PERPKT_INFO |
| 116 | static void dp_rx_stats_update(struct dp_soc *soc, struct dp_peer *peer, |
| 117 | struct cdp_rx_indication_ppdu *ppdu) |
| 118 | { |
| 119 | struct dp_pdev *pdev = NULL; |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 120 | uint8_t mcs, preamble, ac = 0; |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 121 | uint16_t num_msdu; |
| 122 | |
| 123 | mcs = ppdu->u.mcs; |
| 124 | preamble = ppdu->u.preamble; |
| 125 | num_msdu = ppdu->num_msdu; |
| 126 | |
| 127 | if (!peer) |
| 128 | return; |
| 129 | |
| 130 | pdev = peer->vdev->pdev; |
| 131 | |
Subhranil Choudhury | eea6738 | 2018-01-18 20:24:36 +0530 | [diff] [blame] | 132 | dp_mark_peer_inact(peer, false); |
| 133 | |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 134 | if (soc->process_rx_status) |
| 135 | return; |
Pranita Solanke | fc2ff39 | 2017-12-15 19:25:13 +0530 | [diff] [blame] | 136 | |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 137 | DP_STATS_UPD(peer, rx.rssi, ppdu->rssi); |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 138 | |
| 139 | if ((preamble == DOT11_A) || (preamble == DOT11_B)) |
| 140 | ppdu->u.nss = 1; |
| 141 | |
| 142 | if (ppdu->u.nss) |
| 143 | DP_STATS_INC(peer, rx.nss[ppdu->u.nss - 1], num_msdu); |
| 144 | |
Pranita Solanke | a12b4b3 | 2017-11-20 23:04:14 +0530 | [diff] [blame] | 145 | DP_STATS_INC(peer, rx.sgi_count[ppdu->u.gi], num_msdu); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 146 | DP_STATS_INC(peer, rx.bw[ppdu->u.bw], num_msdu); |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 147 | 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] | 148 | DP_STATS_INCC(peer, rx.ampdu_cnt, num_msdu, ppdu->is_ampdu); |
| 149 | DP_STATS_INCC(peer, rx.non_ampdu_cnt, num_msdu, !(ppdu->is_ampdu)); |
| 150 | DP_STATS_UPD(peer, rx.rx_rate, mcs); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 151 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 152 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 153 | ((mcs >= MAX_MCS_11A) && (preamble == DOT11_A))); |
| 154 | DP_STATS_INCC(peer, |
| 155 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
Pranita Solanke | a12b4b3 | 2017-11-20 23:04:14 +0530 | [diff] [blame] | 156 | ((mcs < MAX_MCS_11A) && (preamble == DOT11_A))); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 157 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 158 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 159 | ((mcs >= MAX_MCS_11B) && (preamble == DOT11_B))); |
| 160 | DP_STATS_INCC(peer, |
| 161 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
Pranita Solanke | a12b4b3 | 2017-11-20 23:04:14 +0530 | [diff] [blame] | 162 | ((mcs < MAX_MCS_11B) && (preamble == DOT11_B))); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 163 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 164 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 165 | ((mcs >= MAX_MCS_11A) && (preamble == DOT11_N))); |
| 166 | DP_STATS_INCC(peer, |
| 167 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
Pranita Solanke | a12b4b3 | 2017-11-20 23:04:14 +0530 | [diff] [blame] | 168 | ((mcs < MAX_MCS_11A) && (preamble == DOT11_N))); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 169 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 170 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 171 | ((mcs >= MAX_MCS_11AC) && (preamble == DOT11_AC))); |
| 172 | DP_STATS_INCC(peer, |
| 173 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
| 174 | ((mcs < MAX_MCS_11AC) && (preamble == DOT11_AC))); |
| 175 | DP_STATS_INCC(peer, |
Pranita Solanke | ed0aba6 | 2018-01-12 19:14:31 +0530 | [diff] [blame] | 176 | rx.pkt_type[preamble].mcs_count[MAX_MCS - 1], num_msdu, |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 177 | ((mcs >= (MAX_MCS - 1)) && (preamble == DOT11_AX))); |
| 178 | DP_STATS_INCC(peer, |
| 179 | rx.pkt_type[preamble].mcs_count[mcs], num_msdu, |
| 180 | ((mcs < (MAX_MCS - 1)) && (preamble == DOT11_AX))); |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 181 | /* |
| 182 | * If invalid TID, it could be a non-qos frame, hence do not update |
| 183 | * any AC counters |
| 184 | */ |
| 185 | ac = TID_TO_WME_AC(ppdu->tid); |
| 186 | if (ppdu->tid != HAL_TID_INVALID) |
| 187 | DP_STATS_INC(peer, rx.wme_ac_type[ac], num_msdu); |
| 188 | |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 189 | if (soc->cdp_soc.ol_ops->update_dp_stats) { |
| 190 | soc->cdp_soc.ol_ops->update_dp_stats(pdev->osif_pdev, |
| 191 | &peer->stats, ppdu->peer_id, |
| 192 | UPDATE_PEER_STATS); |
Pranita Solanke | fc2ff39 | 2017-12-15 19:25:13 +0530 | [diff] [blame] | 193 | |
| 194 | dp_aggregate_vdev_stats(peer->vdev); |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 195 | } |
| 196 | } |
| 197 | #endif |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 198 | |
| 199 | /** |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 200 | * dp_rx_handle_mcopy_mode() - Allocate and deliver first MSDU payload |
Pranita Solanke | fc2ff39 | 2017-12-15 19:25:13 +0530 | [diff] [blame] | 201 | * @soc: core txrx main context |
| 202 | * @pdev: pdev strcuture |
| 203 | * @ppdu_info: structure for rx ppdu ring |
| 204 | * |
| 205 | * Return: QDF_STATUS_SUCCESS - If nbuf to be freed by caller |
| 206 | * QDF_STATUS_E_ALREADY - If nbuf not to be freed by caller |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 207 | */ |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 208 | #ifdef FEATURE_PERPKT_INFO |
| 209 | static inline QDF_STATUS |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 210 | 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] | 211 | struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf) |
| 212 | { |
| 213 | uint8_t size = 0; |
| 214 | |
| 215 | if (ppdu_info->first_msdu_payload == NULL) |
| 216 | return QDF_STATUS_SUCCESS; |
| 217 | |
| 218 | if (pdev->am_copy_id.rx_ppdu_id == ppdu_info->com_info.ppdu_id) |
| 219 | return QDF_STATUS_SUCCESS; |
| 220 | |
| 221 | pdev->am_copy_id.rx_ppdu_id = ppdu_info->com_info.ppdu_id; |
| 222 | |
| 223 | size = ppdu_info->first_msdu_payload - qdf_nbuf_data(nbuf); |
| 224 | ppdu_info->first_msdu_payload = NULL; |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 225 | |
| 226 | if (qdf_nbuf_pull_head(nbuf, size) == NULL) |
| 227 | return QDF_STATUS_SUCCESS; |
| 228 | |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 229 | dp_wdi_event_handler(WDI_EVENT_RX_DATA, soc, |
| 230 | nbuf, HTT_INVALID_PEER, WDI_NO_VAL, pdev->pdev_id); |
| 231 | return QDF_STATUS_E_ALREADY; |
| 232 | } |
| 233 | #else |
| 234 | static inline QDF_STATUS |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 235 | 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] | 236 | struct hal_rx_ppdu_info *ppdu_info, qdf_nbuf_t nbuf) |
| 237 | { |
| 238 | return QDF_STATUS_SUCCESS; |
| 239 | } |
| 240 | #endif |
| 241 | |
| 242 | |
| 243 | /** |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 244 | * dp_rx_handle_ppdu_stats() - Allocate and deliver ppdu stats to cdp layer |
| 245 | * @soc: core txrx main context |
| 246 | * @pdev: pdev strcuture |
| 247 | * @ppdu_info: structure for rx ppdu ring |
| 248 | * |
| 249 | * Return: none |
| 250 | */ |
| 251 | #ifdef FEATURE_PERPKT_INFO |
| 252 | static inline void |
| 253 | dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev, |
| 254 | struct hal_rx_ppdu_info *ppdu_info) |
| 255 | { |
| 256 | qdf_nbuf_t ppdu_nbuf; |
| 257 | struct dp_peer *peer; |
| 258 | struct cdp_rx_indication_ppdu *cdp_rx_ppdu; |
| 259 | |
Anish Nataraj | 28490c4 | 2018-01-19 19:34:54 +0530 | [diff] [blame] | 260 | /* |
| 261 | * Do not allocate if fcs error, |
| 262 | * ast idx invalid / fctl invalid |
| 263 | */ |
| 264 | |
| 265 | if (!ppdu_info->rx_status.frame_control_info_valid) |
| 266 | return; |
| 267 | |
| 268 | if (ppdu_info->com_info.mpdu_cnt_fcs_ok == 0) |
| 269 | return; |
| 270 | |
| 271 | if (ppdu_info->rx_status.ast_index == HAL_AST_IDX_INVALID) |
| 272 | return; |
| 273 | |
Tallapragada Kalyan | a867edf | 2017-11-14 12:26:41 +0530 | [diff] [blame] | 274 | ppdu_nbuf = qdf_nbuf_alloc(soc->osdev, |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 275 | sizeof(struct hal_rx_ppdu_info), 0, 0, FALSE); |
| 276 | if (ppdu_nbuf) { |
| 277 | dp_rx_populate_cdp_indication_ppdu(soc, ppdu_info, ppdu_nbuf); |
| 278 | qdf_nbuf_put_tail(ppdu_nbuf, |
| 279 | sizeof(struct cdp_rx_indication_ppdu)); |
| 280 | cdp_rx_ppdu = (struct cdp_rx_indication_ppdu *)ppdu_nbuf->data; |
| 281 | |
| 282 | peer = dp_peer_find_by_id(soc, cdp_rx_ppdu->peer_id); |
| 283 | if (peer && cdp_rx_ppdu->peer_id != HTT_INVALID_PEER) { |
Pamidipati, Vijay | 57a435a | 2017-10-17 11:03:39 +0530 | [diff] [blame] | 284 | dp_rx_stats_update(soc, peer, cdp_rx_ppdu); |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 285 | dp_wdi_event_handler(WDI_EVENT_RX_PPDU_DESC, soc, |
| 286 | ppdu_nbuf, cdp_rx_ppdu->peer_id, |
| 287 | WDI_NO_VAL, pdev->pdev_id); |
| 288 | } else |
| 289 | qdf_nbuf_free(ppdu_nbuf); |
| 290 | } |
| 291 | } |
| 292 | #else |
| 293 | static inline void |
| 294 | dp_rx_handle_ppdu_stats(struct dp_soc *soc, struct dp_pdev *pdev, |
| 295 | struct hal_rx_ppdu_info *ppdu_info) |
| 296 | { |
| 297 | } |
| 298 | #endif |
| 299 | |
| 300 | /** |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 301 | * dp_rx_mon_status_process_tlv() - Process status TLV in status |
| 302 | * buffer on Rx status Queue posted by status SRNG processing. |
| 303 | * @soc: core txrx main context |
| 304 | * @mac_id: mac_id which is one of 3 mac_ids _ring |
| 305 | * |
| 306 | * Return: none |
| 307 | */ |
| 308 | static inline void |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 309 | dp_rx_mon_status_process_tlv(struct dp_soc *soc, uint32_t mac_id, |
| 310 | uint32_t quota) |
| 311 | { |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 312 | struct dp_pdev *pdev = soc->pdev_list[mac_id]; |
| 313 | struct hal_rx_ppdu_info *ppdu_info; |
| 314 | qdf_nbuf_t status_nbuf; |
| 315 | uint8_t *rx_tlv; |
| 316 | uint8_t *rx_tlv_start; |
Kai Chen | ad516ae | 2017-09-08 18:35:47 -0700 | [diff] [blame] | 317 | uint32_t tlv_status = HAL_TLV_STATUS_BUF_DONE; |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 318 | QDF_STATUS am_copy_status = QDF_STATUS_SUCCESS; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 319 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 320 | ppdu_info = &pdev->ppdu_info; |
| 321 | |
| 322 | if (pdev->mon_ppdu_status != DP_PPDU_STATUS_START) |
| 323 | return; |
| 324 | |
| 325 | while (!qdf_nbuf_is_queue_empty(&pdev->rx_status_q)) { |
| 326 | |
| 327 | status_nbuf = qdf_nbuf_queue_remove(&pdev->rx_status_q); |
| 328 | rx_tlv = qdf_nbuf_data(status_nbuf); |
| 329 | rx_tlv_start = rx_tlv; |
Venkata Sharath Chandra Manchala | 5a6f429 | 2017-11-03 14:57:41 -0700 | [diff] [blame] | 330 | |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 331 | #ifndef REMOVE_PKT_LOG |
Venkata Sharath Chandra Manchala | 5a6f429 | 2017-11-03 14:57:41 -0700 | [diff] [blame] | 332 | #if defined(WDI_EVENT_ENABLE) |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 333 | dp_wdi_event_handler(WDI_EVENT_RX_DESC, soc, |
Keyur Parekh | db0fa14 | 2017-07-13 19:40:22 -0700 | [diff] [blame] | 334 | status_nbuf, HTT_INVALID_PEER, WDI_NO_VAL, mac_id); |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 335 | #endif |
| 336 | #endif |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 337 | if ((pdev->monitor_vdev != NULL) || (pdev->enhanced_stats_en)) { |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 338 | |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 339 | do { |
| 340 | tlv_status = hal_rx_status_get_tlv_info(rx_tlv, |
| 341 | ppdu_info); |
| 342 | rx_tlv = hal_rx_status_get_next_tlv(rx_tlv); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 343 | |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 344 | if ((rx_tlv - rx_tlv_start) >= RX_BUFFER_SIZE) |
| 345 | break; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 346 | |
Keyur Parekh | fad6d08 | 2017-05-07 08:54:47 -0700 | [diff] [blame] | 347 | } while (tlv_status == HAL_TLV_STATUS_PPDU_NOT_DONE); |
| 348 | } |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 349 | |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 350 | if (pdev->mcopy_mode) { |
| 351 | am_copy_status = dp_rx_handle_mcopy_mode(soc, |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 352 | pdev, ppdu_info, status_nbuf); |
| 353 | if (am_copy_status == QDF_STATUS_SUCCESS) |
| 354 | qdf_nbuf_free(status_nbuf); |
| 355 | } else { |
| 356 | qdf_nbuf_free(status_nbuf); |
| 357 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 358 | |
| 359 | if (tlv_status == HAL_TLV_STATUS_PPDU_DONE) { |
Soumya Bhat | 5c60deb | 2017-12-12 16:42:04 +0530 | [diff] [blame] | 360 | if (pdev->enhanced_stats_en || |
Soumya Bhat | 7422db8 | 2017-12-15 13:48:53 +0530 | [diff] [blame] | 361 | pdev->mcopy_mode) |
Anish Nataraj | 38a2956 | 2017-08-18 19:41:17 +0530 | [diff] [blame] | 362 | dp_rx_handle_ppdu_stats(soc, pdev, ppdu_info); |
Soumya Bhat | 6fee59c | 2017-10-31 13:12:37 +0530 | [diff] [blame] | 363 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 364 | pdev->mon_ppdu_status = DP_PPDU_STATUS_DONE; |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 365 | dp_rx_mon_dest_process(soc, mac_id, quota); |
Kai Chen | cbe4c34 | 2017-06-12 20:06:35 -0700 | [diff] [blame] | 366 | pdev->mon_ppdu_status = DP_PPDU_STATUS_START; |
Karunakar Dasineni | 65b626e | 2017-12-18 22:17:29 -0800 | [diff] [blame] | 367 | pdev->ppdu_info.com_info.last_ppdu_id = |
| 368 | pdev->ppdu_info.com_info.ppdu_id; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 369 | } |
| 370 | } |
| 371 | return; |
| 372 | } |
| 373 | |
| 374 | /* |
| 375 | * dp_rx_mon_status_srng_process() - Process monitor status ring |
| 376 | * post the status ring buffer to Rx status Queue for later |
| 377 | * processing when status ring is filled with status TLV. |
| 378 | * Allocate a new buffer to status ring if the filled buffer |
| 379 | * is posted. |
| 380 | * |
| 381 | * @soc: core txrx main context |
| 382 | * @mac_id: mac_id which is one of 3 mac_ids |
| 383 | * @quota: No. of ring entry that can be serviced in one shot. |
| 384 | |
| 385 | * Return: uint32_t: No. of ring entry that is processed. |
| 386 | */ |
| 387 | static inline uint32_t |
| 388 | dp_rx_mon_status_srng_process(struct dp_soc *soc, uint32_t mac_id, |
| 389 | uint32_t quota) |
| 390 | { |
| 391 | struct dp_pdev *pdev = soc->pdev_list[mac_id]; |
| 392 | void *hal_soc; |
| 393 | void *mon_status_srng; |
| 394 | void *rxdma_mon_status_ring_entry; |
| 395 | QDF_STATUS status; |
| 396 | uint32_t work_done = 0; |
| 397 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 398 | mon_status_srng = pdev->rxdma_mon_status_ring.hal_srng; |
| 399 | |
| 400 | qdf_assert(mon_status_srng); |
Houston Hoffman | 648a918 | 2017-05-21 23:27:50 -0700 | [diff] [blame] | 401 | if (!mon_status_srng || !hal_srng_initialized(mon_status_srng)) { |
| 402 | |
| 403 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Jeff Johnson | 3f217e2 | 2017-09-18 10:13:35 -0700 | [diff] [blame] | 404 | "%s %d : HAL Monitor Destination Ring Init Failed -- %pK\n", |
Houston Hoffman | 648a918 | 2017-05-21 23:27:50 -0700 | [diff] [blame] | 405 | __func__, __LINE__, mon_status_srng); |
| 406 | return work_done; |
| 407 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 408 | |
| 409 | hal_soc = soc->hal_soc; |
| 410 | |
| 411 | qdf_assert(hal_soc); |
| 412 | |
| 413 | if (qdf_unlikely(hal_srng_access_start(hal_soc, mon_status_srng))) |
| 414 | goto done; |
| 415 | |
| 416 | /* mon_status_ring_desc => WBM_BUFFER_RING STRUCT => |
| 417 | * BUFFER_ADDR_INFO STRUCT |
| 418 | */ |
| 419 | while (qdf_likely((rxdma_mon_status_ring_entry = |
| 420 | hal_srng_src_peek(hal_soc, mon_status_srng)) |
| 421 | && quota--)) { |
| 422 | uint32_t rx_buf_cookie; |
| 423 | qdf_nbuf_t status_nbuf; |
| 424 | struct dp_rx_desc *rx_desc; |
| 425 | uint8_t *status_buf; |
| 426 | qdf_dma_addr_t paddr; |
| 427 | uint64_t buf_addr; |
| 428 | |
| 429 | buf_addr = |
| 430 | (HAL_RX_BUFFER_ADDR_31_0_GET( |
| 431 | rxdma_mon_status_ring_entry) | |
| 432 | ((uint64_t)(HAL_RX_BUFFER_ADDR_39_32_GET( |
| 433 | rxdma_mon_status_ring_entry)) << 32)); |
| 434 | |
| 435 | if (qdf_likely(buf_addr)) { |
| 436 | |
| 437 | rx_buf_cookie = |
| 438 | HAL_RX_BUF_COOKIE_GET( |
| 439 | rxdma_mon_status_ring_entry); |
| 440 | rx_desc = dp_rx_cookie_2_va_mon_status(soc, |
| 441 | rx_buf_cookie); |
| 442 | |
| 443 | qdf_assert(rx_desc); |
| 444 | |
| 445 | status_nbuf = rx_desc->nbuf; |
| 446 | |
| 447 | qdf_nbuf_sync_for_cpu(soc->osdev, status_nbuf, |
| 448 | QDF_DMA_FROM_DEVICE); |
| 449 | |
| 450 | status_buf = qdf_nbuf_data(status_nbuf); |
| 451 | |
| 452 | status = hal_get_rx_status_done(status_buf); |
| 453 | |
| 454 | if (status != QDF_STATUS_SUCCESS) { |
Karunakar Dasineni | 37995ac | 2018-02-06 12:37:30 -0800 | [diff] [blame^] | 455 | uint32_t hp, tp; |
| 456 | hal_api_get_tphp(hal_soc, mon_status_srng, |
| 457 | &tp, &hp); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 458 | QDF_TRACE(QDF_MODULE_ID_DP, |
Karunakar Dasineni | 37995ac | 2018-02-06 12:37:30 -0800 | [diff] [blame^] | 459 | QDF_TRACE_LEVEL_ERROR, |
| 460 | "[%s][%d] status not done - hp:%u, tp:%u", |
| 461 | __func__, __LINE__, hp, tp); |
| 462 | /* WAR for missing status: Skip status entry */ |
| 463 | hal_srng_src_get_next(hal_soc, mon_status_srng); |
| 464 | continue; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 465 | } |
| 466 | qdf_nbuf_set_pktlen(status_nbuf, RX_BUFFER_SIZE); |
| 467 | |
| 468 | qdf_nbuf_unmap_single(soc->osdev, status_nbuf, |
| 469 | QDF_DMA_FROM_DEVICE); |
| 470 | |
| 471 | /* Put the status_nbuf to queue */ |
| 472 | qdf_nbuf_queue_add(&pdev->rx_status_q, status_nbuf); |
| 473 | |
| 474 | } else { |
| 475 | union dp_rx_desc_list_elem_t *desc_list = NULL; |
| 476 | union dp_rx_desc_list_elem_t *tail = NULL; |
| 477 | struct rx_desc_pool *rx_desc_pool; |
| 478 | uint32_t num_alloc_desc; |
| 479 | |
| 480 | rx_desc_pool = &soc->rx_desc_status[mac_id]; |
| 481 | |
| 482 | num_alloc_desc = dp_rx_get_free_desc_list(soc, mac_id, |
| 483 | rx_desc_pool, |
| 484 | 1, |
| 485 | &desc_list, |
| 486 | &tail); |
| 487 | |
| 488 | rx_desc = &desc_list->rx_desc; |
| 489 | } |
| 490 | |
| 491 | /* Allocate a new skb */ |
Tallapragada Kalyan | a867edf | 2017-11-14 12:26:41 +0530 | [diff] [blame] | 492 | status_nbuf = qdf_nbuf_alloc(soc->osdev, RX_BUFFER_SIZE, |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 493 | RX_BUFFER_RESERVATION, RX_BUFFER_ALIGNMENT, FALSE); |
| 494 | |
| 495 | status_buf = qdf_nbuf_data(status_nbuf); |
| 496 | |
| 497 | hal_clear_rx_status_done(status_buf); |
| 498 | |
| 499 | qdf_nbuf_map_single(soc->osdev, status_nbuf, |
| 500 | QDF_DMA_BIDIRECTIONAL); |
| 501 | paddr = qdf_nbuf_get_frag_paddr(status_nbuf, 0); |
| 502 | |
| 503 | rx_desc->nbuf = status_nbuf; |
Pramod Simha | 59fcb31 | 2017-06-22 17:43:16 -0700 | [diff] [blame] | 504 | rx_desc->in_use = 1; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 505 | |
| 506 | hal_rxdma_buff_addr_info_set(rxdma_mon_status_ring_entry, |
| 507 | paddr, rx_desc->cookie, HAL_RX_BUF_RBM_SW3_BM); |
| 508 | |
Karunakar Dasineni | 37995ac | 2018-02-06 12:37:30 -0800 | [diff] [blame^] | 509 | hal_srng_src_get_next(hal_soc, mon_status_srng); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 510 | work_done++; |
| 511 | } |
| 512 | done: |
| 513 | |
| 514 | hal_srng_access_end(hal_soc, mon_status_srng); |
| 515 | |
| 516 | return work_done; |
| 517 | |
| 518 | } |
| 519 | /* |
| 520 | * dp_rx_mon_status_process() - Process monitor status ring and |
| 521 | * TLV in status ring. |
| 522 | * |
| 523 | * @soc: core txrx main context |
| 524 | * @mac_id: mac_id which is one of 3 mac_ids |
| 525 | * @quota: No. of ring entry that can be serviced in one shot. |
| 526 | |
| 527 | * Return: uint32_t: No. of ring entry that is processed. |
| 528 | */ |
| 529 | static inline uint32_t |
| 530 | dp_rx_mon_status_process(struct dp_soc *soc, uint32_t mac_id, uint32_t quota) { |
| 531 | uint32_t work_done; |
| 532 | |
| 533 | work_done = dp_rx_mon_status_srng_process(soc, mac_id, quota); |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 534 | quota -= work_done; |
| 535 | dp_rx_mon_status_process_tlv(soc, mac_id, quota); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 536 | |
| 537 | return work_done; |
| 538 | } |
| 539 | /** |
| 540 | * dp_mon_process() - Main monitor mode processing roution. |
| 541 | * This call monitor status ring process then monitor |
| 542 | * destination ring process. |
| 543 | * Called from the bottom half (tasklet/NET_RX_SOFTIRQ) |
| 544 | * @soc: core txrx main context |
| 545 | * @mac_id: mac_id which is one of 3 mac_ids |
| 546 | * @quota: No. of status ring entry that can be serviced in one shot. |
| 547 | |
| 548 | * Return: uint32_t: No. of ring entry that is processed. |
| 549 | */ |
| 550 | uint32_t |
| 551 | 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] | 552 | return dp_rx_mon_status_process(soc, mac_id, quota); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 553 | } |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 554 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 555 | /** |
| 556 | * dp_rx_pdev_mon_detach() - detach dp rx for status ring |
| 557 | * @pdev: core txrx pdev context |
| 558 | * |
| 559 | * This function will detach DP RX status ring from |
| 560 | * main device context. will free DP Rx resources for |
| 561 | * status ring |
| 562 | * |
| 563 | * Return: QDF_STATUS_SUCCESS: success |
| 564 | * QDF_STATUS_E_RESOURCES: Error return |
| 565 | */ |
| 566 | QDF_STATUS |
| 567 | dp_rx_pdev_mon_status_detach(struct dp_pdev *pdev) |
| 568 | { |
| 569 | uint8_t pdev_id = pdev->pdev_id; |
| 570 | struct dp_soc *soc = pdev->soc; |
| 571 | struct rx_desc_pool *rx_desc_pool; |
| 572 | |
| 573 | rx_desc_pool = &soc->rx_desc_status[pdev_id]; |
psimha | eae1b41 | 2017-08-25 16:10:13 -0700 | [diff] [blame] | 574 | if (rx_desc_pool->pool_size != 0) { |
| 575 | dp_rx_desc_pool_free(soc, pdev_id, rx_desc_pool); |
| 576 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 577 | |
| 578 | return QDF_STATUS_SUCCESS; |
| 579 | } |
| 580 | |
| 581 | /* |
| 582 | * dp_rx_buffers_replenish() - replenish monitor status ring with |
| 583 | * rx nbufs called during dp rx |
| 584 | * monitor status ring initialization |
| 585 | * |
| 586 | * @soc: core txrx main context |
| 587 | * @mac_id: mac_id which is one of 3 mac_ids |
| 588 | * @dp_rxdma_srng: dp monitor status circular ring |
| 589 | * @rx_desc_pool; Pointer to Rx descriptor pool |
| 590 | * @num_req_buffers: number of buffer to be replenished |
| 591 | * @desc_list: list of descs if called from dp rx monitor status |
| 592 | * process or NULL during dp rx initialization or |
| 593 | * out of buffer interrupt |
| 594 | * @tail: tail of descs list |
| 595 | * @owner: who owns the nbuf (host, NSS etc...) |
| 596 | * Return: return success or failure |
| 597 | */ |
| 598 | static inline |
| 599 | QDF_STATUS dp_rx_mon_status_buffers_replenish(struct dp_soc *dp_soc, |
| 600 | uint32_t mac_id, |
| 601 | struct dp_srng *dp_rxdma_srng, |
| 602 | struct rx_desc_pool *rx_desc_pool, |
| 603 | uint32_t num_req_buffers, |
| 604 | union dp_rx_desc_list_elem_t **desc_list, |
| 605 | union dp_rx_desc_list_elem_t **tail, |
| 606 | uint8_t owner) |
| 607 | { |
| 608 | uint32_t num_alloc_desc; |
| 609 | uint16_t num_desc_to_free = 0; |
| 610 | uint32_t num_entries_avail; |
| 611 | uint32_t count; |
| 612 | int sync_hw_ptr = 1; |
| 613 | qdf_dma_addr_t paddr; |
| 614 | qdf_nbuf_t rx_netbuf; |
| 615 | void *rxdma_ring_entry; |
| 616 | union dp_rx_desc_list_elem_t *next; |
| 617 | void *rxdma_srng; |
| 618 | uint8_t *status_buf; |
| 619 | |
| 620 | rxdma_srng = dp_rxdma_srng->hal_srng; |
| 621 | |
| 622 | qdf_assert(rxdma_srng); |
| 623 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 624 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 625 | "[%s][%d] requested %d buffers for replenish\n", |
| 626 | __func__, __LINE__, num_req_buffers); |
| 627 | |
| 628 | /* |
| 629 | * if desc_list is NULL, allocate the descs from freelist |
| 630 | */ |
| 631 | if (!(*desc_list)) { |
| 632 | |
| 633 | num_alloc_desc = dp_rx_get_free_desc_list(dp_soc, mac_id, |
| 634 | rx_desc_pool, |
| 635 | num_req_buffers, |
| 636 | desc_list, |
| 637 | tail); |
| 638 | |
| 639 | if (!num_alloc_desc) { |
| 640 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 641 | "[%s][%d] no free rx_descs in freelist\n", |
| 642 | __func__, __LINE__); |
| 643 | return QDF_STATUS_E_NOMEM; |
| 644 | } |
| 645 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 646 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 647 | "[%s][%d] %d rx desc allocated\n", __func__, __LINE__, |
| 648 | num_alloc_desc); |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 649 | |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 650 | num_req_buffers = num_alloc_desc; |
| 651 | } |
| 652 | |
| 653 | hal_srng_access_start(dp_soc->hal_soc, rxdma_srng); |
| 654 | num_entries_avail = hal_srng_src_num_avail(dp_soc->hal_soc, |
| 655 | rxdma_srng, sync_hw_ptr); |
| 656 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 657 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 658 | "[%s][%d] no of availble entries in rxdma ring: %d\n", |
| 659 | __func__, __LINE__, num_entries_avail); |
| 660 | |
| 661 | if (num_entries_avail < num_req_buffers) { |
| 662 | num_desc_to_free = num_req_buffers - num_entries_avail; |
| 663 | num_req_buffers = num_entries_avail; |
| 664 | } |
| 665 | |
| 666 | for (count = 0; count < num_req_buffers; count++) { |
| 667 | rxdma_ring_entry = hal_srng_src_get_next(dp_soc->hal_soc, |
| 668 | rxdma_srng); |
| 669 | |
| 670 | rx_netbuf = qdf_nbuf_alloc(dp_soc->osdev, |
| 671 | RX_BUFFER_SIZE, |
| 672 | RX_BUFFER_RESERVATION, |
| 673 | RX_BUFFER_ALIGNMENT, |
| 674 | FALSE); |
| 675 | |
| 676 | status_buf = qdf_nbuf_data(rx_netbuf); |
| 677 | hal_clear_rx_status_done(status_buf); |
| 678 | |
| 679 | memset(status_buf, 0, RX_BUFFER_SIZE); |
| 680 | |
| 681 | qdf_nbuf_map_single(dp_soc->osdev, rx_netbuf, |
| 682 | QDF_DMA_BIDIRECTIONAL); |
| 683 | |
| 684 | paddr = qdf_nbuf_get_frag_paddr(rx_netbuf, 0); |
| 685 | |
| 686 | next = (*desc_list)->next; |
| 687 | |
| 688 | (*desc_list)->rx_desc.nbuf = rx_netbuf; |
Pramod Simha | 59fcb31 | 2017-06-22 17:43:16 -0700 | [diff] [blame] | 689 | (*desc_list)->rx_desc.in_use = 1; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 690 | hal_rxdma_buff_addr_info_set(rxdma_ring_entry, paddr, |
| 691 | (*desc_list)->rx_desc.cookie, owner); |
| 692 | |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 693 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Jeff Johnson | 3f217e2 | 2017-09-18 10:13:35 -0700 | [diff] [blame] | 694 | "[%s][%d] rx_desc=%pK, cookie=%d, nbuf=%pK, \ |
| 695 | status_buf=%pK paddr=%pK\n", |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 696 | __func__, __LINE__, &(*desc_list)->rx_desc, |
| 697 | (*desc_list)->rx_desc.cookie, rx_netbuf, |
| 698 | status_buf, (void *)paddr); |
| 699 | |
| 700 | *desc_list = next; |
| 701 | } |
| 702 | |
| 703 | hal_srng_access_end(dp_soc->hal_soc, rxdma_srng); |
| 704 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 705 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 706 | "successfully replenished %d buffers\n", num_req_buffers); |
| 707 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 708 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 709 | "%d rx desc added back to free list\n", num_desc_to_free); |
| 710 | |
Houston Hoffman | ae850c6 | 2017-08-11 16:47:50 -0700 | [diff] [blame] | 711 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG, |
Jeff Johnson | 3f217e2 | 2017-09-18 10:13:35 -0700 | [diff] [blame] | 712 | "[%s][%d] desc_list=%pK, tail=%pK rx_desc=%pK, cookie=%d\n", |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 713 | __func__, __LINE__, desc_list, tail, &(*desc_list)->rx_desc, |
| 714 | (*desc_list)->rx_desc.cookie); |
| 715 | |
| 716 | /* |
| 717 | * add any available free desc back to the free list |
| 718 | */ |
| 719 | if (*desc_list) { |
| 720 | dp_rx_add_desc_list_to_free_list(dp_soc, desc_list, tail, |
| 721 | mac_id, rx_desc_pool); |
| 722 | } |
| 723 | |
| 724 | return QDF_STATUS_SUCCESS; |
| 725 | } |
| 726 | /** |
| 727 | * dp_rx_pdev_mon_status_attach() - attach DP RX monitor status ring |
| 728 | * @pdev: core txrx pdev context |
| 729 | * |
| 730 | * This function will attach a DP RX monitor status ring into pDEV |
| 731 | * and replenish monitor status ring with buffer. |
| 732 | * |
| 733 | * Return: QDF_STATUS_SUCCESS: success |
| 734 | * QDF_STATUS_E_RESOURCES: Error return |
| 735 | */ |
| 736 | QDF_STATUS |
| 737 | dp_rx_pdev_mon_status_attach(struct dp_pdev *pdev) { |
| 738 | uint8_t pdev_id = pdev->pdev_id; |
| 739 | struct dp_soc *soc = pdev->soc; |
| 740 | union dp_rx_desc_list_elem_t *desc_list = NULL; |
| 741 | union dp_rx_desc_list_elem_t *tail = NULL; |
| 742 | struct dp_srng *rxdma_srng; |
| 743 | uint32_t rxdma_entries; |
| 744 | struct rx_desc_pool *rx_desc_pool; |
Ravi Joshi | a9ebe0a | 2017-06-17 16:43:02 -0700 | [diff] [blame] | 745 | QDF_STATUS status; |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 746 | |
| 747 | rxdma_srng = &pdev->rxdma_mon_status_ring; |
| 748 | |
| 749 | rxdma_entries = rxdma_srng->alloc_size/hal_srng_get_entrysize( |
| 750 | soc->hal_soc, RXDMA_MONITOR_STATUS); |
| 751 | |
| 752 | rx_desc_pool = &soc->rx_desc_status[pdev_id]; |
| 753 | |
Houston Hoffman | 41b912c | 2017-08-30 14:27:51 -0700 | [diff] [blame] | 754 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW, |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 755 | "%s: Mon RX Status Pool[%d] allocation size=%d\n", |
| 756 | __func__, pdev_id, rxdma_entries); |
| 757 | |
Ravi Joshi | a9ebe0a | 2017-06-17 16:43:02 -0700 | [diff] [blame] | 758 | status = dp_rx_desc_pool_alloc(soc, pdev_id, rxdma_entries+1, |
| 759 | rx_desc_pool); |
Ravi Joshi | 73a0551 | 2017-07-10 13:53:32 -0700 | [diff] [blame] | 760 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Ravi Joshi | a9ebe0a | 2017-06-17 16:43:02 -0700 | [diff] [blame] | 761 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 762 | "%s: dp_rx_desc_pool_alloc() failed \n", __func__); |
| 763 | return status; |
| 764 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 765 | |
Houston Hoffman | 41b912c | 2017-08-30 14:27:51 -0700 | [diff] [blame] | 766 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_INFO_LOW, |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 767 | "%s: Mon RX Status Buffers Replenish pdev_id=%d\n", |
| 768 | __func__, pdev_id); |
| 769 | |
Ravi Joshi | a9ebe0a | 2017-06-17 16:43:02 -0700 | [diff] [blame] | 770 | status = dp_rx_mon_status_buffers_replenish(soc, pdev_id, rxdma_srng, |
| 771 | rx_desc_pool, rxdma_entries, &desc_list, &tail, |
| 772 | HAL_RX_BUF_RBM_SW3_BM); |
Ravi Joshi | 73a0551 | 2017-07-10 13:53:32 -0700 | [diff] [blame] | 773 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Ravi Joshi | a9ebe0a | 2017-06-17 16:43:02 -0700 | [diff] [blame] | 774 | QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR, |
| 775 | "%s: dp_rx_buffers_replenish() failed \n", __func__); |
| 776 | return status; |
| 777 | } |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 778 | |
| 779 | qdf_nbuf_queue_init(&pdev->rx_status_q); |
| 780 | |
| 781 | pdev->mon_ppdu_status = DP_PPDU_STATUS_START; |
Karunakar Dasineni | 65b626e | 2017-12-18 22:17:29 -0800 | [diff] [blame] | 782 | pdev->ppdu_info.com_info.last_ppdu_id = 0; |
Karunakar Dasineni | 4055568 | 2017-03-26 22:44:39 -0700 | [diff] [blame] | 783 | qdf_mem_zero(&(pdev->ppdu_info.rx_status), |
| 784 | sizeof(pdev->ppdu_info.rx_status)); |
Kai Chen | 6eca1a6 | 2017-01-12 10:17:53 -0800 | [diff] [blame] | 785 | |
| 786 | return QDF_STATUS_SUCCESS; |
| 787 | } |