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