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