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