Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
wadesong | 9f2b110 | 2017-12-20 22:58:35 +0800 | [diff] [blame] | 2 | * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /*=== includes ===*/ |
| 29 | /* header files for OS primitives */ |
| 30 | #include <osdep.h> /* uint32_t, etc. */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 31 | #include <qdf_mem.h> /* qdf_mem_malloc,free */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 32 | #include <qdf_types.h> /* qdf_device_t, qdf_print */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 33 | #include <qdf_lock.h> /* qdf_spinlock */ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 34 | #include <qdf_atomic.h> /* qdf_atomic_read */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 35 | |
Poddar, Siddarth | 27b1a60 | 2016-04-29 11:01:33 +0530 | [diff] [blame] | 36 | #if defined(HIF_PCI) || defined(HIF_SNOC) || defined(HIF_AHB) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 37 | /* Required for WLAN_FEATURE_FASTPATH */ |
| 38 | #include <ce_api.h> |
Poddar, Siddarth | 27b1a60 | 2016-04-29 11:01:33 +0530 | [diff] [blame] | 39 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 40 | /* header files for utilities */ |
| 41 | #include <cds_queue.h> /* TAILQ */ |
| 42 | |
| 43 | /* header files for configuration API */ |
| 44 | #include <ol_cfg.h> /* ol_cfg_is_high_latency */ |
| 45 | #include <ol_if_athvar.h> |
| 46 | |
| 47 | /* header files for HTT API */ |
| 48 | #include <ol_htt_api.h> |
| 49 | #include <ol_htt_tx_api.h> |
| 50 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 51 | /* header files for our own APIs */ |
| 52 | #include <ol_txrx_api.h> |
| 53 | #include <ol_txrx_dbg.h> |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 54 | #include <cdp_txrx_ocb.h> |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 55 | #include <ol_txrx_ctrl_api.h> |
| 56 | #include <cdp_txrx_stats.h> |
| 57 | #include <ol_txrx_osif_api.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 58 | /* header files for our internal definitions */ |
| 59 | #include <ol_txrx_internal.h> /* TXRX_ASSERT, etc. */ |
| 60 | #include <wdi_event.h> /* WDI events */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 61 | #include <ol_tx.h> /* ol_tx_ll */ |
| 62 | #include <ol_rx.h> /* ol_rx_deliver */ |
| 63 | #include <ol_txrx_peer_find.h> /* ol_txrx_peer_find_attach, etc. */ |
| 64 | #include <ol_rx_pn.h> /* ol_rx_pn_check, etc. */ |
| 65 | #include <ol_rx_fwd.h> /* ol_rx_fwd_check, etc. */ |
| 66 | #include <ol_rx_reorder_timeout.h> /* OL_RX_REORDER_TIMEOUT_INIT, etc. */ |
| 67 | #include <ol_rx_reorder.h> |
| 68 | #include <ol_tx_send.h> /* ol_tx_discard_target_frms */ |
| 69 | #include <ol_tx_desc.h> /* ol_tx_desc_frame_free */ |
| 70 | #include <ol_tx_queue.h> |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 71 | #include <ol_tx_sched.h> /* ol_tx_sched_attach, etc. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 72 | #include <ol_txrx.h> |
Manjunathappa Prakash | 04f2644 | 2016-10-13 14:46:49 -0700 | [diff] [blame] | 73 | #include <ol_txrx_types.h> |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 74 | #include <cdp_txrx_flow_ctrl_legacy.h> |
Jeff Johnson | f89f58f | 2016-10-14 09:58:29 -0700 | [diff] [blame] | 75 | #include <cdp_txrx_bus.h> |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 76 | #include <cdp_txrx_ipa.h> |
Jeff Johnson | f89f58f | 2016-10-14 09:58:29 -0700 | [diff] [blame] | 77 | #include <cdp_txrx_pmf.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 78 | #include "wma.h" |
Poddar, Siddarth | 27b1a60 | 2016-04-29 11:01:33 +0530 | [diff] [blame] | 79 | #include "hif.h" |
wadesong | 9e95bd9 | 2017-04-14 14:28:40 +0800 | [diff] [blame] | 80 | #include "hif_main.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 81 | #include <cdp_txrx_peer_ops.h> |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 82 | #ifndef REMOVE_PKT_LOG |
| 83 | #include "pktlog_ac.h" |
| 84 | #endif |
Tushnim Bhattacharyya | 12b4874 | 2017-03-13 12:46:45 -0700 | [diff] [blame] | 85 | #include <wlan_policy_mgr_api.h> |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 86 | #include "epping_main.h" |
Govind Singh | 8c46db9 | 2016-05-10 14:17:16 +0530 | [diff] [blame] | 87 | #include <a_types.h> |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 88 | #include <cdp_txrx_handle.h> |
Poddar, Siddarth | db56816 | 2017-07-27 18:16:38 +0530 | [diff] [blame] | 89 | #include "wlan_qct_sys.h" |
| 90 | |
Orhan K AKYILDIZ | fdd74de | 2016-12-15 12:08:04 -0800 | [diff] [blame] | 91 | #include <htt_internal.h> |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame] | 92 | #include <ol_txrx_ipa.h> |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 93 | #include "wlan_roam_debug.h" |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame] | 94 | |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 95 | #ifdef QCA_SUPPORT_TXRX_LOCAL_PEER_ID |
| 96 | ol_txrx_peer_handle |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 97 | ol_txrx_peer_find_by_local_id(struct cdp_pdev *pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 98 | uint8_t local_peer_id); |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 99 | ol_txrx_peer_handle |
| 100 | ol_txrx_peer_get_ref_by_local_id(struct cdp_pdev *ppdev, |
| 101 | uint8_t local_peer_id, |
| 102 | enum peer_debug_id_type dbg_id); |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 103 | #endif /* QCA_SUPPORT_TXRX_LOCAL_PEER_ID */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 104 | QDF_STATUS ol_txrx_peer_state_update(struct cdp_pdev *pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 105 | uint8_t *peer_mac, |
| 106 | enum ol_txrx_peer_state state); |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 107 | static void ol_vdev_rx_set_intrabss_fwd(struct cdp_vdev *vdev, |
| 108 | bool val); |
| 109 | int ol_txrx_get_tx_pending(struct cdp_pdev *pdev_handle); |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 110 | extern void |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 111 | ol_txrx_set_wmm_param(struct cdp_pdev *data_pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 112 | struct ol_tx_wmm_param_t wmm_param); |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 113 | |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 114 | extern void ol_txrx_get_pn_info(void *ppeer, uint8_t **last_pn_valid, |
| 115 | uint64_t **last_pn, uint32_t **rmf_pn_replays); |
| 116 | |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 117 | /* thresh for peer's cached buf queue beyond which the elements are dropped */ |
| 118 | #define OL_TXRX_CACHED_BUFQ_THRESH 128 |
| 119 | |
Yu Wang | 053d3e7 | 2017-02-08 18:48:24 +0800 | [diff] [blame] | 120 | #if defined(CONFIG_HL_SUPPORT) && defined(FEATURE_WLAN_TDLS) |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * ol_txrx_copy_mac_addr_raw() - copy raw mac addr |
| 124 | * @vdev: the data virtual device |
| 125 | * @bss_addr: bss address |
| 126 | * |
| 127 | * Return: None |
| 128 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 129 | static void |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 130 | ol_txrx_copy_mac_addr_raw(struct cdp_vdev *pvdev, uint8_t *bss_addr) |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 131 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 132 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 133 | |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 134 | qdf_spin_lock_bh(&vdev->pdev->last_real_peer_mutex); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 135 | if (bss_addr && vdev->last_real_peer && |
Ankit Gupta | a507601 | 2016-09-14 11:32:19 -0700 | [diff] [blame] | 136 | !qdf_mem_cmp((u8 *)bss_addr, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 137 | vdev->last_real_peer->mac_addr.raw, |
Ankit Gupta | a507601 | 2016-09-14 11:32:19 -0700 | [diff] [blame] | 138 | IEEE80211_ADDR_LEN)) |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 139 | qdf_mem_copy(vdev->hl_tdls_ap_mac_addr.raw, |
| 140 | vdev->last_real_peer->mac_addr.raw, |
| 141 | OL_TXRX_MAC_ADDR_LEN); |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 142 | qdf_spin_unlock_bh(&vdev->pdev->last_real_peer_mutex); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | /** |
| 146 | * ol_txrx_add_last_real_peer() - add last peer |
| 147 | * @pdev: the data physical device |
| 148 | * @vdev: virtual device |
| 149 | * @peer_id: peer id |
| 150 | * |
| 151 | * Return: None |
| 152 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 153 | static void |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 154 | ol_txrx_add_last_real_peer(struct cdp_pdev *ppdev, |
| 155 | struct cdp_vdev *pvdev, uint8_t *peer_id) |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 156 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 157 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
| 158 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 159 | ol_txrx_peer_handle peer; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 160 | |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 161 | peer = ol_txrx_find_peer_by_addr( |
| 162 | (struct cdp_pdev *)pdev, |
| 163 | vdev->hl_tdls_ap_mac_addr.raw, |
| 164 | peer_id); |
| 165 | |
| 166 | qdf_spin_lock_bh(&pdev->last_real_peer_mutex); |
| 167 | if (!vdev->last_real_peer && peer && |
| 168 | (peer->peer_ids[0] != HTT_INVALID_PEER_ID)) |
| 169 | vdev->last_real_peer = peer; |
| 170 | qdf_spin_unlock_bh(&pdev->last_real_peer_mutex); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | /** |
| 174 | * is_vdev_restore_last_peer() - check for vdev last peer |
| 175 | * @peer: peer object |
| 176 | * |
| 177 | * Return: true if last peer is not null |
| 178 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 179 | static bool |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 180 | is_vdev_restore_last_peer(void *ppeer) |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 181 | { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 182 | struct ol_txrx_peer_t *peer = ppeer; |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 183 | struct ol_txrx_vdev_t *vdev; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 184 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 185 | vdev = peer->vdev; |
| 186 | return vdev->last_real_peer && (vdev->last_real_peer == peer); |
| 187 | } |
| 188 | |
| 189 | /** |
| 190 | * ol_txrx_update_last_real_peer() - check for vdev last peer |
| 191 | * @pdev: the data physical device |
| 192 | * @peer: peer device |
| 193 | * @peer_id: peer id |
| 194 | * @restore_last_peer: restore last peer flag |
| 195 | * |
| 196 | * Return: None |
| 197 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 198 | static void |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 199 | ol_txrx_update_last_real_peer(struct cdp_pdev *ppdev, void *ppeer, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 200 | uint8_t *peer_id, bool restore_last_peer) |
| 201 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 202 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 203 | struct ol_txrx_peer_t *peer = ppeer; |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 204 | struct ol_txrx_vdev_t *vdev; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 205 | |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 206 | if (!restore_last_peer) |
| 207 | return; |
| 208 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 209 | vdev = peer->vdev; |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 210 | peer = ol_txrx_find_peer_by_addr((struct cdp_pdev *)pdev, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 211 | vdev->hl_tdls_ap_mac_addr.raw, peer_id); |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 212 | |
| 213 | qdf_spin_lock_bh(&pdev->last_real_peer_mutex); |
| 214 | if (!vdev->last_real_peer && peer && |
| 215 | (peer->peer_ids[0] != HTT_INVALID_PEER_ID)) |
| 216 | vdev->last_real_peer = peer; |
| 217 | qdf_spin_unlock_bh(&pdev->last_real_peer_mutex); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 218 | } |
| 219 | #endif |
| 220 | |
Himanshu Agarwal | 19141bb | 2016-07-20 20:15:48 +0530 | [diff] [blame] | 221 | /** |
| 222 | * ol_tx_mark_first_wakeup_packet() - set flag to indicate that |
| 223 | * fw is compatible for marking first packet after wow wakeup |
| 224 | * @value: 1 for enabled/ 0 for disabled |
| 225 | * |
| 226 | * Return: None |
| 227 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 228 | static void ol_tx_mark_first_wakeup_packet(uint8_t value) |
Himanshu Agarwal | 19141bb | 2016-07-20 20:15:48 +0530 | [diff] [blame] | 229 | { |
| 230 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 231 | |
| 232 | if (!pdev) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 233 | ol_txrx_err( |
Himanshu Agarwal | 19141bb | 2016-07-20 20:15:48 +0530 | [diff] [blame] | 234 | "%s: pdev is NULL\n", __func__); |
| 235 | return; |
| 236 | } |
| 237 | |
| 238 | htt_mark_first_wakeup_packet(pdev->htt_pdev, value); |
| 239 | } |
| 240 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 241 | u_int16_t |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 242 | ol_tx_desc_pool_size_hl(struct cdp_cfg *ctrl_pdev) |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 243 | { |
| 244 | u_int16_t desc_pool_size; |
| 245 | u_int16_t steady_state_tx_lifetime_ms; |
| 246 | u_int16_t safety_factor; |
| 247 | |
| 248 | /* |
| 249 | * Steady-state tx latency: |
| 250 | * roughly 1-2 ms flight time |
| 251 | * + roughly 1-2 ms prep time, |
| 252 | * + roughly 1-2 ms target->host notification time. |
| 253 | * = roughly 6 ms total |
| 254 | * Thus, steady state number of frames = |
| 255 | * steady state max throughput / frame size * tx latency, e.g. |
| 256 | * 1 Gbps / 1500 bytes * 6 ms = 500 |
| 257 | * |
| 258 | */ |
| 259 | steady_state_tx_lifetime_ms = 6; |
| 260 | |
| 261 | safety_factor = 8; |
| 262 | |
| 263 | desc_pool_size = |
| 264 | ol_cfg_max_thruput_mbps(ctrl_pdev) * |
| 265 | 1000 /* 1e6 bps/mbps / 1e3 ms per sec = 1000 */ / |
| 266 | (8 * OL_TX_AVG_FRM_BYTES) * |
| 267 | steady_state_tx_lifetime_ms * |
| 268 | safety_factor; |
| 269 | |
| 270 | /* minimum */ |
| 271 | if (desc_pool_size < OL_TX_DESC_POOL_SIZE_MIN_HL) |
| 272 | desc_pool_size = OL_TX_DESC_POOL_SIZE_MIN_HL; |
| 273 | |
| 274 | /* maximum */ |
| 275 | if (desc_pool_size > OL_TX_DESC_POOL_SIZE_MAX_HL) |
| 276 | desc_pool_size = OL_TX_DESC_POOL_SIZE_MAX_HL; |
| 277 | |
| 278 | return desc_pool_size; |
| 279 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 280 | |
| 281 | /*=== function definitions ===*/ |
| 282 | |
Nirav Shah | 22bf44d | 2015-12-10 15:39:48 +0530 | [diff] [blame] | 283 | /** |
| 284 | * ol_tx_set_is_mgmt_over_wmi_enabled() - set flag to indicate that mgmt over |
| 285 | * wmi is enabled or not. |
| 286 | * @value: 1 for enabled/ 0 for disable |
| 287 | * |
| 288 | * Return: None |
| 289 | */ |
| 290 | void ol_tx_set_is_mgmt_over_wmi_enabled(uint8_t value) |
| 291 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 292 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 293 | |
Nirav Shah | 22bf44d | 2015-12-10 15:39:48 +0530 | [diff] [blame] | 294 | if (!pdev) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 295 | qdf_print("%s: pdev is NULL\n", __func__); |
Nirav Shah | 22bf44d | 2015-12-10 15:39:48 +0530 | [diff] [blame] | 296 | return; |
| 297 | } |
| 298 | pdev->is_mgmt_over_wmi_enabled = value; |
Nirav Shah | 22bf44d | 2015-12-10 15:39:48 +0530 | [diff] [blame] | 299 | } |
| 300 | |
| 301 | /** |
| 302 | * ol_tx_get_is_mgmt_over_wmi_enabled() - get value of is_mgmt_over_wmi_enabled |
| 303 | * |
| 304 | * Return: is_mgmt_over_wmi_enabled |
| 305 | */ |
| 306 | uint8_t ol_tx_get_is_mgmt_over_wmi_enabled(void) |
| 307 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 308 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 309 | |
Nirav Shah | 22bf44d | 2015-12-10 15:39:48 +0530 | [diff] [blame] | 310 | if (!pdev) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 311 | qdf_print("%s: pdev is NULL\n", __func__); |
Nirav Shah | 22bf44d | 2015-12-10 15:39:48 +0530 | [diff] [blame] | 312 | return 0; |
| 313 | } |
| 314 | return pdev->is_mgmt_over_wmi_enabled; |
| 315 | } |
| 316 | |
| 317 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 318 | #ifdef QCA_SUPPORT_TXRX_LOCAL_PEER_ID |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 319 | static void * |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 320 | ol_txrx_find_peer_by_addr_and_vdev(struct cdp_pdev *ppdev, |
| 321 | struct cdp_vdev *pvdev, uint8_t *peer_addr, uint8_t *peer_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 322 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 323 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
| 324 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 325 | struct ol_txrx_peer_t *peer; |
| 326 | |
| 327 | peer = ol_txrx_peer_vdev_find_hash(pdev, vdev, peer_addr, 0, 1); |
| 328 | if (!peer) |
| 329 | return NULL; |
| 330 | *peer_id = peer->local_id; |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 331 | ol_txrx_peer_release_ref(peer, PEER_DEBUG_ID_OL_INTERNAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 332 | return peer; |
| 333 | } |
| 334 | |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 335 | static QDF_STATUS ol_txrx_get_vdevid(void *ppeer, uint8_t *vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 336 | { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 337 | struct ol_txrx_peer_t *peer = ppeer; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 338 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 339 | if (!peer) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 340 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 341 | "peer argument is null!!"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 342 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | *vdev_id = peer->vdev->vdev_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 346 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 347 | } |
| 348 | |
Yun Park | 0dad100 | 2017-07-14 14:57:01 -0700 | [diff] [blame] | 349 | static struct cdp_vdev *ol_txrx_get_vdev_by_sta_id(struct cdp_pdev *ppdev, |
| 350 | uint8_t sta_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 351 | { |
Yun Park | 0dad100 | 2017-07-14 14:57:01 -0700 | [diff] [blame] | 352 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 353 | struct ol_txrx_peer_t *peer = NULL; |
Yun Park | 5dd9a12 | 2018-01-12 15:00:12 -0800 | [diff] [blame] | 354 | ol_txrx_vdev_handle vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 355 | |
| 356 | if (sta_id >= WLAN_MAX_STA_COUNT) { |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 357 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 358 | "Invalid sta id passed"); |
| 359 | return NULL; |
| 360 | } |
| 361 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 362 | if (!pdev) { |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 363 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 364 | "PDEV not found for sta_id [%d]", sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 365 | return NULL; |
| 366 | } |
| 367 | |
Yun Park | 5dd9a12 | 2018-01-12 15:00:12 -0800 | [diff] [blame] | 368 | peer = ol_txrx_peer_get_ref_by_local_id((struct cdp_pdev *)pdev, sta_id, |
| 369 | PEER_DEBUG_ID_OL_INTERNAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 370 | if (!peer) { |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 371 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 372 | "PEER [%d] not found", sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 373 | return NULL; |
| 374 | } |
| 375 | |
Yun Park | 5dd9a12 | 2018-01-12 15:00:12 -0800 | [diff] [blame] | 376 | vdev = peer->vdev; |
| 377 | ol_txrx_peer_release_ref(peer, PEER_DEBUG_ID_OL_INTERNAL); |
| 378 | |
| 379 | return (struct cdp_vdev *)vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 380 | } |
| 381 | |
Mohit Khanna | babadb8 | 2017-02-21 18:54:19 -0800 | [diff] [blame] | 382 | /** |
| 383 | * ol_txrx_find_peer_by_addr() - find peer via peer mac addr and peer_id |
| 384 | * @ppdev: pointer of type cdp_pdev |
| 385 | * @peer_addr: peer mac addr |
| 386 | * @peer_id: pointer to fill in the value of peer->local_id for caller |
| 387 | * |
| 388 | * This function finds a peer with given mac address and returns its peer_id. |
| 389 | * Note that this function does not increment the peer->ref_cnt. |
| 390 | * This means that the peer may be deleted in some other parallel context after |
| 391 | * its been found. |
| 392 | * |
| 393 | * Return: peer handle if peer is found, NULL if peer is not found. |
| 394 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 395 | void *ol_txrx_find_peer_by_addr(struct cdp_pdev *ppdev, |
Yun Park | 0dad100 | 2017-07-14 14:57:01 -0700 | [diff] [blame] | 396 | uint8_t *peer_addr, |
| 397 | uint8_t *peer_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 398 | { |
| 399 | struct ol_txrx_peer_t *peer; |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 400 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 401 | |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 402 | peer = ol_txrx_peer_find_hash_find_get_ref(pdev, peer_addr, 0, 1, |
| 403 | PEER_DEBUG_ID_OL_INTERNAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 404 | if (!peer) |
| 405 | return NULL; |
| 406 | *peer_id = peer->local_id; |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 407 | ol_txrx_peer_release_ref(peer, PEER_DEBUG_ID_OL_INTERNAL); |
Mohit Khanna | babadb8 | 2017-02-21 18:54:19 -0800 | [diff] [blame] | 408 | return peer; |
| 409 | } |
| 410 | |
| 411 | /** |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 412 | * ol_txrx_peer_get_ref_by_addr() - get peer ref via peer mac addr and peer_id |
Mohit Khanna | babadb8 | 2017-02-21 18:54:19 -0800 | [diff] [blame] | 413 | * @pdev: pointer of type ol_txrx_pdev_handle |
| 414 | * @peer_addr: peer mac addr |
| 415 | * @peer_id: pointer to fill in the value of peer->local_id for caller |
| 416 | * |
| 417 | * This function finds the peer with given mac address and returns its peer_id. |
| 418 | * Note that this function increments the peer->ref_cnt. |
| 419 | * This makes sure that peer will be valid. This also means the caller needs to |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 420 | * call the corresponding API - ol_txrx_peer_release_ref to delete the peer |
Mohit Khanna | babadb8 | 2017-02-21 18:54:19 -0800 | [diff] [blame] | 421 | * reference. |
| 422 | * Sample usage: |
| 423 | * { |
| 424 | * //the API call below increments the peer->ref_cnt |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 425 | * peer = ol_txrx_peer_get_ref_by_addr(pdev, peer_addr, peer_id, dbg_id); |
Mohit Khanna | babadb8 | 2017-02-21 18:54:19 -0800 | [diff] [blame] | 426 | * |
| 427 | * // Once peer usage is done |
| 428 | * |
| 429 | * //the API call below decrements the peer->ref_cnt |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 430 | * ol_txrx_peer_release_ref(peer, dbg_id); |
Mohit Khanna | babadb8 | 2017-02-21 18:54:19 -0800 | [diff] [blame] | 431 | * } |
| 432 | * |
| 433 | * Return: peer handle if the peer is found, NULL if peer is not found. |
| 434 | */ |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 435 | ol_txrx_peer_handle ol_txrx_peer_get_ref_by_addr(ol_txrx_pdev_handle pdev, |
| 436 | u8 *peer_addr, |
| 437 | u8 *peer_id, |
| 438 | enum peer_debug_id_type dbg_id) |
Mohit Khanna | babadb8 | 2017-02-21 18:54:19 -0800 | [diff] [blame] | 439 | { |
| 440 | struct ol_txrx_peer_t *peer; |
| 441 | |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 442 | peer = ol_txrx_peer_find_hash_find_get_ref(pdev, peer_addr, 0, 1, |
| 443 | dbg_id); |
Mohit Khanna | babadb8 | 2017-02-21 18:54:19 -0800 | [diff] [blame] | 444 | if (!peer) |
| 445 | return NULL; |
| 446 | *peer_id = peer->local_id; |
Mohit Khanna | b04dfcd | 2017-02-13 18:54:35 -0800 | [diff] [blame] | 447 | return peer; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 448 | } |
| 449 | |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 450 | static uint16_t ol_txrx_local_peer_id(void *ppeer) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 451 | { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 452 | ol_txrx_peer_handle peer = ppeer; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 453 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 454 | return peer->local_id; |
| 455 | } |
| 456 | |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 457 | /** |
| 458 | * @brief Find a txrx peer handle from a peer's local ID |
| 459 | * @details |
| 460 | * The control SW typically uses the txrx peer handle to refer to the peer. |
| 461 | * In unusual circumstances, if it is infeasible for the control SW maintain |
| 462 | * the txrx peer handle but it can maintain a small integer local peer ID, |
| 463 | * this function allows the peer handled to be retrieved, based on the local |
| 464 | * peer ID. |
| 465 | * |
| 466 | * @param pdev - the data physical device object |
| 467 | * @param local_peer_id - the ID txrx assigned locally to the peer in question |
| 468 | * @return handle to the txrx peer object |
| 469 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 470 | ol_txrx_peer_handle |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 471 | ol_txrx_peer_find_by_local_id(struct cdp_pdev *ppdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 472 | uint8_t local_peer_id) |
| 473 | { |
| 474 | struct ol_txrx_peer_t *peer; |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 475 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 476 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 477 | if ((local_peer_id == OL_TXRX_INVALID_LOCAL_PEER_ID) || |
| 478 | (local_peer_id >= OL_TXRX_NUM_LOCAL_PEER_IDS)) { |
| 479 | return NULL; |
| 480 | } |
| 481 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 482 | qdf_spin_lock_bh(&pdev->local_peer_ids.lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 483 | peer = pdev->local_peer_ids.map[local_peer_id]; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 484 | qdf_spin_unlock_bh(&pdev->local_peer_ids.lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 485 | return peer; |
| 486 | } |
| 487 | |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 488 | /** |
| 489 | * @brief Find a txrx peer handle from a peer's local ID |
| 490 | * @param pdev - the data physical device object |
| 491 | * @param local_peer_id - the ID txrx assigned locally to the peer in question |
| 492 | * @dbg_id - debug_id to track caller |
| 493 | * @return handle to the txrx peer object |
| 494 | * @details |
| 495 | * The control SW typically uses the txrx peer handle to refer to the peer. |
| 496 | * In unusual circumstances, if it is infeasible for the control SW maintain |
| 497 | * the txrx peer handle but it can maintain a small integer local peer ID, |
| 498 | * this function allows the peer handled to be retrieved, based on the local |
| 499 | * peer ID. |
| 500 | * |
| 501 | * Note that this function increments the peer->ref_cnt. |
| 502 | * This makes sure that peer will be valid. This also means the caller needs to |
| 503 | * call the corresponding API - |
| 504 | * ol_txrx_peer_release_ref |
| 505 | * |
| 506 | * reference. |
| 507 | * Sample usage: |
| 508 | * { |
| 509 | * //the API call below increments the peer->ref_cnt |
| 510 | * peer = ol_txrx_peer_get_ref_by_local_id(pdev,local_peer_id, dbg_id); |
| 511 | * |
| 512 | * // Once peer usage is done |
| 513 | * |
| 514 | * //the API call below decrements the peer->ref_cnt |
| 515 | * ol_txrx_peer_release_ref(peer, dbg_id); |
| 516 | * } |
| 517 | * |
| 518 | * Return: peer handle if the peer is found, NULL if peer is not found. |
| 519 | */ |
| 520 | ol_txrx_peer_handle |
| 521 | ol_txrx_peer_get_ref_by_local_id(struct cdp_pdev *ppdev, |
| 522 | uint8_t local_peer_id, |
| 523 | enum peer_debug_id_type dbg_id) |
| 524 | { |
| 525 | struct ol_txrx_peer_t *peer = NULL; |
| 526 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
| 527 | |
| 528 | if ((local_peer_id == OL_TXRX_INVALID_LOCAL_PEER_ID) || |
| 529 | (local_peer_id >= OL_TXRX_NUM_LOCAL_PEER_IDS)) { |
| 530 | return NULL; |
| 531 | } |
| 532 | |
| 533 | qdf_spin_lock_bh(&pdev->peer_ref_mutex); |
| 534 | qdf_spin_lock_bh(&pdev->local_peer_ids.lock); |
| 535 | peer = pdev->local_peer_ids.map[local_peer_id]; |
| 536 | qdf_spin_unlock_bh(&pdev->local_peer_ids.lock); |
| 537 | if (peer && peer->valid) |
| 538 | ol_txrx_peer_get_ref(peer, dbg_id); |
Jingxiang Ge | 9f29706 | 2018-01-24 13:31:31 +0800 | [diff] [blame] | 539 | else |
| 540 | peer = NULL; |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 541 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
| 542 | |
| 543 | return peer; |
| 544 | } |
| 545 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | static void ol_txrx_local_peer_id_pool_init(struct ol_txrx_pdev_t *pdev) |
| 547 | { |
| 548 | int i; |
| 549 | |
| 550 | /* point the freelist to the first ID */ |
| 551 | pdev->local_peer_ids.freelist = 0; |
| 552 | |
| 553 | /* link each ID to the next one */ |
| 554 | for (i = 0; i < OL_TXRX_NUM_LOCAL_PEER_IDS; i++) { |
| 555 | pdev->local_peer_ids.pool[i] = i + 1; |
| 556 | pdev->local_peer_ids.map[i] = NULL; |
| 557 | } |
| 558 | |
| 559 | /* link the last ID to itself, to mark the end of the list */ |
| 560 | i = OL_TXRX_NUM_LOCAL_PEER_IDS; |
| 561 | pdev->local_peer_ids.pool[i] = i; |
| 562 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 563 | qdf_spinlock_create(&pdev->local_peer_ids.lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | static void |
| 567 | ol_txrx_local_peer_id_alloc(struct ol_txrx_pdev_t *pdev, |
| 568 | struct ol_txrx_peer_t *peer) |
| 569 | { |
| 570 | int i; |
| 571 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 572 | qdf_spin_lock_bh(&pdev->local_peer_ids.lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 573 | i = pdev->local_peer_ids.freelist; |
| 574 | if (pdev->local_peer_ids.pool[i] == i) { |
| 575 | /* the list is empty, except for the list-end marker */ |
| 576 | peer->local_id = OL_TXRX_INVALID_LOCAL_PEER_ID; |
| 577 | } else { |
| 578 | /* take the head ID and advance the freelist */ |
| 579 | peer->local_id = i; |
| 580 | pdev->local_peer_ids.freelist = pdev->local_peer_ids.pool[i]; |
| 581 | pdev->local_peer_ids.map[i] = peer; |
| 582 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 583 | qdf_spin_unlock_bh(&pdev->local_peer_ids.lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 584 | } |
| 585 | |
| 586 | static void |
| 587 | ol_txrx_local_peer_id_free(struct ol_txrx_pdev_t *pdev, |
| 588 | struct ol_txrx_peer_t *peer) |
| 589 | { |
| 590 | int i = peer->local_id; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 591 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 592 | if ((i == OL_TXRX_INVALID_LOCAL_PEER_ID) || |
| 593 | (i >= OL_TXRX_NUM_LOCAL_PEER_IDS)) { |
| 594 | return; |
| 595 | } |
| 596 | /* put this ID on the head of the freelist */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 597 | qdf_spin_lock_bh(&pdev->local_peer_ids.lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 598 | pdev->local_peer_ids.pool[i] = pdev->local_peer_ids.freelist; |
| 599 | pdev->local_peer_ids.freelist = i; |
| 600 | pdev->local_peer_ids.map[i] = NULL; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 601 | qdf_spin_unlock_bh(&pdev->local_peer_ids.lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | static void ol_txrx_local_peer_id_cleanup(struct ol_txrx_pdev_t *pdev) |
| 605 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 606 | qdf_spinlock_destroy(&pdev->local_peer_ids.lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | #else |
| 610 | #define ol_txrx_local_peer_id_pool_init(pdev) /* no-op */ |
| 611 | #define ol_txrx_local_peer_id_alloc(pdev, peer) /* no-op */ |
| 612 | #define ol_txrx_local_peer_id_free(pdev, peer) /* no-op */ |
| 613 | #define ol_txrx_local_peer_id_cleanup(pdev) /* no-op */ |
| 614 | #endif |
| 615 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 616 | #ifdef FEATURE_HL_GROUP_CREDIT_FLOW_CONTROL |
| 617 | |
| 618 | /** |
| 619 | * ol_txrx_update_group_credit() - update group credit for tx queue |
| 620 | * @group: for which credit needs to be updated |
| 621 | * @credit: credits |
| 622 | * @absolute: TXQ group absolute |
| 623 | * |
| 624 | * Return: allocated pool size |
| 625 | */ |
| 626 | void ol_txrx_update_group_credit( |
| 627 | struct ol_tx_queue_group_t *group, |
| 628 | int32_t credit, |
| 629 | u_int8_t absolute) |
| 630 | { |
| 631 | if (absolute) |
| 632 | qdf_atomic_set(&group->credit, credit); |
| 633 | else |
| 634 | qdf_atomic_add(credit, &group->credit); |
| 635 | } |
| 636 | |
| 637 | /** |
| 638 | * ol_txrx_update_tx_queue_groups() - update vdev tx queue group if |
| 639 | * vdev id mask and ac mask is not matching |
| 640 | * @pdev: the data physical device |
| 641 | * @group_id: TXQ group id |
| 642 | * @credit: TXQ group credit count |
| 643 | * @absolute: TXQ group absolute |
| 644 | * @vdev_id_mask: TXQ vdev group id mask |
| 645 | * @ac_mask: TQX access category mask |
| 646 | * |
| 647 | * Return: None |
| 648 | */ |
| 649 | void ol_txrx_update_tx_queue_groups( |
| 650 | ol_txrx_pdev_handle pdev, |
| 651 | u_int8_t group_id, |
| 652 | int32_t credit, |
| 653 | u_int8_t absolute, |
| 654 | u_int32_t vdev_id_mask, |
| 655 | u_int32_t ac_mask |
| 656 | ) |
| 657 | { |
| 658 | struct ol_tx_queue_group_t *group; |
| 659 | u_int32_t group_vdev_bit_mask, vdev_bit_mask, group_vdev_id_mask; |
| 660 | u_int32_t membership; |
| 661 | struct ol_txrx_vdev_t *vdev; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 662 | |
Tiger Yu | 1e553e5 | 2018-01-18 16:48:00 +0800 | [diff] [blame] | 663 | if (group_id >= OL_TX_MAX_TXQ_GROUPS) { |
| 664 | ol_txrx_warn("%s: invalid group_id=%u, ignore update.\n", |
| 665 | __func__, |
| 666 | group_id); |
| 667 | return; |
| 668 | } |
| 669 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 670 | group = &pdev->txq_grps[group_id]; |
| 671 | |
| 672 | membership = OL_TXQ_GROUP_MEMBERSHIP_GET(vdev_id_mask, ac_mask); |
| 673 | |
| 674 | qdf_spin_lock_bh(&pdev->tx_queue_spinlock); |
| 675 | /* |
| 676 | * if the membership (vdev id mask and ac mask) |
| 677 | * matches then no need to update tx qeue groups. |
| 678 | */ |
| 679 | if (group->membership == membership) |
| 680 | /* Update Credit Only */ |
| 681 | goto credit_update; |
| 682 | |
| 683 | |
| 684 | /* |
| 685 | * membership (vdev id mask and ac mask) is not matching |
| 686 | * TODO: ignoring ac mask for now |
| 687 | */ |
| 688 | group_vdev_id_mask = |
| 689 | OL_TXQ_GROUP_VDEV_ID_MASK_GET(group->membership); |
| 690 | |
| 691 | TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { |
| 692 | group_vdev_bit_mask = |
| 693 | OL_TXQ_GROUP_VDEV_ID_BIT_MASK_GET( |
| 694 | group_vdev_id_mask, vdev->vdev_id); |
| 695 | vdev_bit_mask = |
| 696 | OL_TXQ_GROUP_VDEV_ID_BIT_MASK_GET( |
| 697 | vdev_id_mask, vdev->vdev_id); |
| 698 | |
| 699 | if (group_vdev_bit_mask != vdev_bit_mask) { |
| 700 | /* |
| 701 | * Change in vdev tx queue group |
| 702 | */ |
| 703 | if (!vdev_bit_mask) { |
| 704 | /* Set Group Pointer (vdev and peer) to NULL */ |
| 705 | ol_tx_set_vdev_group_ptr( |
| 706 | pdev, vdev->vdev_id, NULL); |
| 707 | } else { |
| 708 | /* Set Group Pointer (vdev and peer) */ |
| 709 | ol_tx_set_vdev_group_ptr( |
| 710 | pdev, vdev->vdev_id, group); |
| 711 | } |
| 712 | } |
| 713 | } |
| 714 | /* Update membership */ |
| 715 | group->membership = membership; |
| 716 | credit_update: |
| 717 | /* Update Credit */ |
| 718 | ol_txrx_update_group_credit(group, credit, absolute); |
| 719 | qdf_spin_unlock_bh(&pdev->tx_queue_spinlock); |
| 720 | } |
| 721 | #endif |
| 722 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 723 | #ifdef WLAN_FEATURE_FASTPATH |
| 724 | /** |
| 725 | * setup_fastpath_ce_handles() Update pdev with ce_handle for fastpath use. |
| 726 | * |
| 727 | * @osc: pointer to HIF context |
| 728 | * @pdev: pointer to ol pdev |
| 729 | * |
| 730 | * Return: void |
| 731 | */ |
Komal Seelam | 3d20286 | 2016-02-24 18:43:24 +0530 | [diff] [blame] | 732 | static inline void setup_fastpath_ce_handles(struct hif_opaque_softc *osc, |
| 733 | struct ol_txrx_pdev_t *pdev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 734 | { |
| 735 | /* |
| 736 | * Before the HTT attach, set up the CE handles |
| 737 | * CE handles are (struct CE_state *) |
| 738 | * This is only required in the fast path |
| 739 | */ |
Komal Seelam | 7fde14c | 2016-02-02 13:05:57 +0530 | [diff] [blame] | 740 | pdev->ce_tx_hdl = hif_get_ce_handle(osc, CE_HTT_H2T_MSG); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 741 | |
| 742 | } |
| 743 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 744 | #else /* not WLAN_FEATURE_FASTPATH */ |
Komal Seelam | 3d20286 | 2016-02-24 18:43:24 +0530 | [diff] [blame] | 745 | static inline void setup_fastpath_ce_handles(struct hif_opaque_softc *osc, |
| 746 | struct ol_txrx_pdev_t *pdev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 747 | { |
| 748 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 749 | #endif /* WLAN_FEATURE_FASTPATH */ |
| 750 | |
| 751 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 752 | /** |
| 753 | * ol_tx_set_desc_global_pool_size() - set global pool size |
| 754 | * @num_msdu_desc: total number of descriptors |
| 755 | * |
| 756 | * Return: none |
| 757 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 758 | static void ol_tx_set_desc_global_pool_size(uint32_t num_msdu_desc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 759 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 760 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 761 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 762 | if (!pdev) { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 763 | qdf_print("%s: pdev is NULL\n", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 764 | return; |
| 765 | } |
Nirav Shah | 2ae038d | 2015-12-23 20:36:11 +0530 | [diff] [blame] | 766 | pdev->num_msdu_desc = num_msdu_desc; |
| 767 | if (!ol_tx_get_is_mgmt_over_wmi_enabled()) |
| 768 | pdev->num_msdu_desc += TX_FLOW_MGMT_POOL_SIZE; |
Kapil Gupta | 53d9b57 | 2017-06-28 17:53:25 +0530 | [diff] [blame] | 769 | ol_txrx_info_high("Global pool size: %d\n", |
Nirav Shah | 2ae038d | 2015-12-23 20:36:11 +0530 | [diff] [blame] | 770 | pdev->num_msdu_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 771 | } |
| 772 | |
| 773 | /** |
| 774 | * ol_tx_get_desc_global_pool_size() - get global pool size |
| 775 | * @pdev: pdev handle |
| 776 | * |
| 777 | * Return: global pool size |
| 778 | */ |
| 779 | static inline |
| 780 | uint32_t ol_tx_get_desc_global_pool_size(struct ol_txrx_pdev_t *pdev) |
| 781 | { |
| 782 | return pdev->num_msdu_desc; |
| 783 | } |
Nirav Shah | 55b45a0 | 2016-01-21 10:00:16 +0530 | [diff] [blame] | 784 | |
| 785 | /** |
| 786 | * ol_tx_get_total_free_desc() - get total free descriptors |
| 787 | * @pdev: pdev handle |
| 788 | * |
| 789 | * Return: total free descriptors |
| 790 | */ |
| 791 | static inline |
| 792 | uint32_t ol_tx_get_total_free_desc(struct ol_txrx_pdev_t *pdev) |
| 793 | { |
| 794 | struct ol_tx_flow_pool_t *pool = NULL; |
| 795 | uint32_t free_desc; |
| 796 | |
| 797 | free_desc = pdev->tx_desc.num_free; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 798 | qdf_spin_lock_bh(&pdev->tx_desc.flow_pool_list_lock); |
Nirav Shah | 55b45a0 | 2016-01-21 10:00:16 +0530 | [diff] [blame] | 799 | TAILQ_FOREACH(pool, &pdev->tx_desc.flow_pool_list, |
| 800 | flow_pool_list_elem) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 801 | qdf_spin_lock_bh(&pool->flow_pool_lock); |
Nirav Shah | 55b45a0 | 2016-01-21 10:00:16 +0530 | [diff] [blame] | 802 | free_desc += pool->avail_desc; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 803 | qdf_spin_unlock_bh(&pool->flow_pool_lock); |
Nirav Shah | 55b45a0 | 2016-01-21 10:00:16 +0530 | [diff] [blame] | 804 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 805 | qdf_spin_unlock_bh(&pdev->tx_desc.flow_pool_list_lock); |
Nirav Shah | 55b45a0 | 2016-01-21 10:00:16 +0530 | [diff] [blame] | 806 | |
| 807 | return free_desc; |
| 808 | } |
| 809 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 810 | #else |
| 811 | /** |
| 812 | * ol_tx_get_desc_global_pool_size() - get global pool size |
| 813 | * @pdev: pdev handle |
| 814 | * |
| 815 | * Return: global pool size |
| 816 | */ |
| 817 | static inline |
| 818 | uint32_t ol_tx_get_desc_global_pool_size(struct ol_txrx_pdev_t *pdev) |
| 819 | { |
| 820 | return ol_cfg_target_tx_credit(pdev->ctrl_pdev); |
| 821 | } |
Nirav Shah | 55b45a0 | 2016-01-21 10:00:16 +0530 | [diff] [blame] | 822 | |
| 823 | /** |
| 824 | * ol_tx_get_total_free_desc() - get total free descriptors |
| 825 | * @pdev: pdev handle |
| 826 | * |
| 827 | * Return: total free descriptors |
| 828 | */ |
| 829 | static inline |
| 830 | uint32_t ol_tx_get_total_free_desc(struct ol_txrx_pdev_t *pdev) |
| 831 | { |
| 832 | return pdev->tx_desc.num_free; |
| 833 | } |
| 834 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 835 | #endif |
| 836 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 837 | #if defined(CONFIG_HL_SUPPORT) && defined(CONFIG_PER_VDEV_TX_DESC_POOL) |
| 838 | |
| 839 | /** |
| 840 | * ol_txrx_rsrc_threshold_lo() - set threshold low - when to start tx desc |
| 841 | * margin replenishment |
| 842 | * @desc_pool_size: tx desc pool size |
| 843 | * |
| 844 | * Return: threshold low |
| 845 | */ |
| 846 | static inline uint16_t |
| 847 | ol_txrx_rsrc_threshold_lo(int desc_pool_size) |
| 848 | { |
| 849 | int threshold_low; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 850 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 851 | /* |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 852 | * 5% margin of unallocated desc is too much for per |
| 853 | * vdev mechanism. |
| 854 | * Define the value seperately. |
| 855 | */ |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 856 | threshold_low = TXRX_HL_TX_FLOW_CTRL_MGMT_RESERVED; |
| 857 | |
| 858 | return threshold_low; |
| 859 | } |
| 860 | |
| 861 | /** |
| 862 | * ol_txrx_rsrc_threshold_hi() - set threshold high - where to stop |
| 863 | * during tx desc margin replenishment |
| 864 | * @desc_pool_size: tx desc pool size |
| 865 | * |
| 866 | * Return: threshold high |
| 867 | */ |
| 868 | static inline uint16_t |
| 869 | ol_txrx_rsrc_threshold_hi(int desc_pool_size) |
| 870 | { |
| 871 | int threshold_high; |
| 872 | /* when freeing up descriptors, |
| 873 | * keep going until there's a 7.5% margin |
| 874 | */ |
| 875 | threshold_high = ((15 * desc_pool_size)/100)/2; |
| 876 | |
| 877 | return threshold_high; |
| 878 | } |
| 879 | #else |
| 880 | |
| 881 | static inline uint16_t |
| 882 | ol_txrx_rsrc_threshold_lo(int desc_pool_size) |
| 883 | { |
| 884 | int threshold_low; |
| 885 | /* always maintain a 5% margin of unallocated descriptors */ |
| 886 | threshold_low = (5 * desc_pool_size)/100; |
| 887 | |
| 888 | return threshold_low; |
| 889 | } |
| 890 | |
| 891 | static inline uint16_t |
| 892 | ol_txrx_rsrc_threshold_hi(int desc_pool_size) |
| 893 | { |
| 894 | int threshold_high; |
| 895 | /* when freeing up descriptors, keep going until |
| 896 | * there's a 15% margin |
| 897 | */ |
| 898 | threshold_high = (15 * desc_pool_size)/100; |
| 899 | |
| 900 | return threshold_high; |
| 901 | } |
| 902 | #endif |
| 903 | |
| 904 | #if defined(CONFIG_HL_SUPPORT) && defined(DEBUG_HL_LOGGING) |
| 905 | |
| 906 | /** |
| 907 | * ol_txrx_pdev_txq_log_init() - initialise pdev txq logs |
| 908 | * @pdev: the physical device object |
| 909 | * |
| 910 | * Return: None |
| 911 | */ |
| 912 | static void |
| 913 | ol_txrx_pdev_txq_log_init(struct ol_txrx_pdev_t *pdev) |
| 914 | { |
| 915 | qdf_spinlock_create(&pdev->txq_log_spinlock); |
| 916 | pdev->txq_log.size = OL_TXQ_LOG_SIZE; |
| 917 | pdev->txq_log.oldest_record_offset = 0; |
| 918 | pdev->txq_log.offset = 0; |
| 919 | pdev->txq_log.allow_wrap = 1; |
| 920 | pdev->txq_log.wrapped = 0; |
| 921 | } |
| 922 | |
| 923 | /** |
| 924 | * ol_txrx_pdev_txq_log_destroy() - remove txq log spinlock for pdev |
| 925 | * @pdev: the physical device object |
| 926 | * |
| 927 | * Return: None |
| 928 | */ |
| 929 | static inline void |
| 930 | ol_txrx_pdev_txq_log_destroy(struct ol_txrx_pdev_t *pdev) |
| 931 | { |
| 932 | qdf_spinlock_destroy(&pdev->txq_log_spinlock); |
| 933 | } |
| 934 | |
| 935 | #else |
| 936 | |
| 937 | static inline void |
| 938 | ol_txrx_pdev_txq_log_init(struct ol_txrx_pdev_t *pdev) |
| 939 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | static inline void |
| 943 | ol_txrx_pdev_txq_log_destroy(struct ol_txrx_pdev_t *pdev) |
| 944 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | |
| 948 | #endif |
| 949 | |
| 950 | #if defined(DEBUG_HL_LOGGING) |
| 951 | |
| 952 | /** |
| 953 | * ol_txrx_pdev_grp_stats_init() - initialise group stat spinlock for pdev |
| 954 | * @pdev: the physical device object |
| 955 | * |
| 956 | * Return: None |
| 957 | */ |
| 958 | static inline void |
| 959 | ol_txrx_pdev_grp_stats_init(struct ol_txrx_pdev_t *pdev) |
| 960 | { |
| 961 | qdf_spinlock_create(&pdev->grp_stat_spinlock); |
| 962 | pdev->grp_stats.last_valid_index = -1; |
| 963 | pdev->grp_stats.wrap_around = 0; |
| 964 | } |
| 965 | |
| 966 | /** |
| 967 | * ol_txrx_pdev_grp_stat_destroy() - destroy group stat spinlock for pdev |
| 968 | * @pdev: the physical device object |
| 969 | * |
| 970 | * Return: None |
| 971 | */ |
| 972 | static inline void |
| 973 | ol_txrx_pdev_grp_stat_destroy(struct ol_txrx_pdev_t *pdev) |
| 974 | { |
| 975 | qdf_spinlock_destroy(&pdev->grp_stat_spinlock); |
| 976 | } |
| 977 | #else |
| 978 | |
| 979 | static inline void |
| 980 | ol_txrx_pdev_grp_stats_init(struct ol_txrx_pdev_t *pdev) |
| 981 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 982 | } |
| 983 | |
| 984 | static inline void |
| 985 | ol_txrx_pdev_grp_stat_destroy(struct ol_txrx_pdev_t *pdev) |
| 986 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 987 | } |
| 988 | #endif |
| 989 | |
| 990 | #if defined(CONFIG_HL_SUPPORT) && defined(FEATURE_WLAN_TDLS) |
| 991 | |
| 992 | /** |
| 993 | * ol_txrx_hl_tdls_flag_reset() - reset tdls flag for vdev |
| 994 | * @vdev: the virtual device object |
| 995 | * @flag: flag |
| 996 | * |
| 997 | * Return: None |
| 998 | */ |
| 999 | void |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1000 | ol_txrx_hl_tdls_flag_reset(struct cdp_vdev *pvdev, bool flag) |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1001 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1002 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 1003 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1004 | vdev->hlTdlsFlag = flag; |
| 1005 | } |
| 1006 | #endif |
| 1007 | |
| 1008 | #if defined(CONFIG_HL_SUPPORT) |
| 1009 | |
| 1010 | /** |
| 1011 | * ol_txrx_vdev_txqs_init() - initialise vdev tx queues |
| 1012 | * @vdev: the virtual device object |
| 1013 | * |
| 1014 | * Return: None |
| 1015 | */ |
| 1016 | static void |
| 1017 | ol_txrx_vdev_txqs_init(struct ol_txrx_vdev_t *vdev) |
| 1018 | { |
| 1019 | u_int8_t i; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 1020 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1021 | for (i = 0; i < OL_TX_VDEV_NUM_QUEUES; i++) { |
| 1022 | TAILQ_INIT(&vdev->txqs[i].head); |
| 1023 | vdev->txqs[i].paused_count.total = 0; |
| 1024 | vdev->txqs[i].frms = 0; |
| 1025 | vdev->txqs[i].bytes = 0; |
| 1026 | vdev->txqs[i].ext_tid = OL_TX_NUM_TIDS + i; |
| 1027 | vdev->txqs[i].flag = ol_tx_queue_empty; |
| 1028 | /* aggregation is not applicable for vdev tx queues */ |
| 1029 | vdev->txqs[i].aggr_state = ol_tx_aggr_disabled; |
| 1030 | ol_tx_txq_set_group_ptr(&vdev->txqs[i], NULL); |
| 1031 | ol_txrx_set_txq_peer(&vdev->txqs[i], NULL); |
| 1032 | } |
| 1033 | } |
| 1034 | |
| 1035 | /** |
| 1036 | * ol_txrx_vdev_tx_queue_free() - free vdev tx queues |
| 1037 | * @vdev: the virtual device object |
| 1038 | * |
| 1039 | * Return: None |
| 1040 | */ |
| 1041 | static void |
| 1042 | ol_txrx_vdev_tx_queue_free(struct ol_txrx_vdev_t *vdev) |
| 1043 | { |
| 1044 | struct ol_txrx_pdev_t *pdev = vdev->pdev; |
| 1045 | struct ol_tx_frms_queue_t *txq; |
| 1046 | int i; |
| 1047 | |
| 1048 | for (i = 0; i < OL_TX_VDEV_NUM_QUEUES; i++) { |
| 1049 | txq = &vdev->txqs[i]; |
Poddar, Siddarth | 74178df | 2016-08-09 17:32:50 +0530 | [diff] [blame] | 1050 | ol_tx_queue_free(pdev, txq, (i + OL_TX_NUM_TIDS), false); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1051 | } |
| 1052 | } |
| 1053 | |
| 1054 | /** |
| 1055 | * ol_txrx_peer_txqs_init() - initialise peer tx queues |
| 1056 | * @pdev: the physical device object |
| 1057 | * @peer: peer object |
| 1058 | * |
| 1059 | * Return: None |
| 1060 | */ |
| 1061 | static void |
| 1062 | ol_txrx_peer_txqs_init(struct ol_txrx_pdev_t *pdev, |
| 1063 | struct ol_txrx_peer_t *peer) |
| 1064 | { |
| 1065 | uint8_t i; |
| 1066 | struct ol_txrx_vdev_t *vdev = peer->vdev; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 1067 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1068 | qdf_spin_lock_bh(&pdev->tx_queue_spinlock); |
| 1069 | for (i = 0; i < OL_TX_NUM_TIDS; i++) { |
| 1070 | TAILQ_INIT(&peer->txqs[i].head); |
| 1071 | peer->txqs[i].paused_count.total = 0; |
| 1072 | peer->txqs[i].frms = 0; |
| 1073 | peer->txqs[i].bytes = 0; |
| 1074 | peer->txqs[i].ext_tid = i; |
| 1075 | peer->txqs[i].flag = ol_tx_queue_empty; |
| 1076 | peer->txqs[i].aggr_state = ol_tx_aggr_untried; |
| 1077 | ol_tx_set_peer_group_ptr(pdev, peer, vdev->vdev_id, i); |
| 1078 | ol_txrx_set_txq_peer(&peer->txqs[i], peer); |
| 1079 | } |
| 1080 | qdf_spin_unlock_bh(&pdev->tx_queue_spinlock); |
| 1081 | |
| 1082 | /* aggregation is not applicable for mgmt and non-QoS tx queues */ |
| 1083 | for (i = OL_TX_NUM_QOS_TIDS; i < OL_TX_NUM_TIDS; i++) |
| 1084 | peer->txqs[i].aggr_state = ol_tx_aggr_disabled; |
| 1085 | |
| 1086 | ol_txrx_peer_pause(peer); |
| 1087 | } |
| 1088 | |
| 1089 | /** |
| 1090 | * ol_txrx_peer_tx_queue_free() - free peer tx queues |
| 1091 | * @pdev: the physical device object |
| 1092 | * @peer: peer object |
| 1093 | * |
| 1094 | * Return: None |
| 1095 | */ |
| 1096 | static void |
| 1097 | ol_txrx_peer_tx_queue_free(struct ol_txrx_pdev_t *pdev, |
| 1098 | struct ol_txrx_peer_t *peer) |
| 1099 | { |
| 1100 | struct ol_tx_frms_queue_t *txq; |
| 1101 | uint8_t i; |
| 1102 | |
| 1103 | for (i = 0; i < OL_TX_NUM_TIDS; i++) { |
| 1104 | txq = &peer->txqs[i]; |
Poddar, Siddarth | 74178df | 2016-08-09 17:32:50 +0530 | [diff] [blame] | 1105 | ol_tx_queue_free(pdev, txq, i, true); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1106 | } |
| 1107 | } |
| 1108 | #else |
| 1109 | |
| 1110 | static inline void |
| 1111 | ol_txrx_vdev_txqs_init(struct ol_txrx_vdev_t *vdev) |
| 1112 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | static inline void |
| 1116 | ol_txrx_vdev_tx_queue_free(struct ol_txrx_vdev_t *vdev) |
| 1117 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1118 | } |
| 1119 | |
| 1120 | static inline void |
| 1121 | ol_txrx_peer_txqs_init(struct ol_txrx_pdev_t *pdev, |
| 1122 | struct ol_txrx_peer_t *peer) |
| 1123 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | static inline void |
| 1127 | ol_txrx_peer_tx_queue_free(struct ol_txrx_pdev_t *pdev, |
| 1128 | struct ol_txrx_peer_t *peer) |
| 1129 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1130 | } |
| 1131 | #endif |
| 1132 | |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1133 | #if defined(FEATURE_TSO) && defined(FEATURE_TSO_DEBUG) |
| 1134 | static void ol_txrx_tso_stats_init(ol_txrx_pdev_handle pdev) |
| 1135 | { |
| 1136 | qdf_spinlock_create(&pdev->stats.pub.tx.tso.tso_stats_lock); |
| 1137 | } |
| 1138 | |
| 1139 | static void ol_txrx_tso_stats_deinit(ol_txrx_pdev_handle pdev) |
| 1140 | { |
| 1141 | qdf_spinlock_destroy(&pdev->stats.pub.tx.tso.tso_stats_lock); |
| 1142 | } |
| 1143 | |
| 1144 | static void ol_txrx_stats_display_tso(ol_txrx_pdev_handle pdev) |
| 1145 | { |
| 1146 | int msdu_idx; |
| 1147 | int seg_idx; |
| 1148 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 1149 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 1150 | "TSO Statistics:"); |
| 1151 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 1152 | "TSO pkts %lld, bytes %lld\n", |
| 1153 | pdev->stats.pub.tx.tso.tso_pkts.pkts, |
| 1154 | pdev->stats.pub.tx.tso.tso_pkts.bytes); |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1155 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 1156 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 1157 | "TSO Histogram for numbers of segments:\n" |
| 1158 | "Single segment %d\n" |
| 1159 | " 2-5 segments %d\n" |
| 1160 | " 6-10 segments %d\n" |
| 1161 | "11-15 segments %d\n" |
| 1162 | "16-20 segments %d\n" |
| 1163 | " 20+ segments %d\n", |
| 1164 | pdev->stats.pub.tx.tso.tso_hist.pkts_1, |
| 1165 | pdev->stats.pub.tx.tso.tso_hist.pkts_2_5, |
| 1166 | pdev->stats.pub.tx.tso.tso_hist.pkts_6_10, |
| 1167 | pdev->stats.pub.tx.tso.tso_hist.pkts_11_15, |
| 1168 | pdev->stats.pub.tx.tso.tso_hist.pkts_16_20, |
| 1169 | pdev->stats.pub.tx.tso.tso_hist.pkts_20_plus); |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1170 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 1171 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 1172 | "TSO History Buffer: Total size %d, current_index %d", |
| 1173 | NUM_MAX_TSO_MSDUS, |
| 1174 | TXRX_STATS_TSO_MSDU_IDX(pdev)); |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1175 | |
| 1176 | for (msdu_idx = 0; msdu_idx < NUM_MAX_TSO_MSDUS; msdu_idx++) { |
| 1177 | if (TXRX_STATS_TSO_MSDU_TOTAL_LEN(pdev, msdu_idx) == 0) |
| 1178 | continue; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 1179 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 1180 | "jumbo pkt idx: %d num segs %d gso_len %d total_len %d nr_frags %d", |
| 1181 | msdu_idx, |
| 1182 | TXRX_STATS_TSO_MSDU_NUM_SEG(pdev, msdu_idx), |
| 1183 | TXRX_STATS_TSO_MSDU_GSO_SIZE(pdev, msdu_idx), |
| 1184 | TXRX_STATS_TSO_MSDU_TOTAL_LEN(pdev, msdu_idx), |
| 1185 | TXRX_STATS_TSO_MSDU_NR_FRAGS(pdev, msdu_idx)); |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1186 | |
| 1187 | for (seg_idx = 0; |
| 1188 | ((seg_idx < TXRX_STATS_TSO_MSDU_NUM_SEG(pdev, |
| 1189 | msdu_idx)) && (seg_idx < NUM_MAX_TSO_SEGS)); |
| 1190 | seg_idx++) { |
| 1191 | struct qdf_tso_seg_t tso_seg = |
| 1192 | TXRX_STATS_TSO_SEG(pdev, msdu_idx, seg_idx); |
| 1193 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 1194 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 1195 | "seg idx: %d", seg_idx); |
| 1196 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 1197 | "tso_enable: %d", |
| 1198 | tso_seg.tso_flags.tso_enable); |
| 1199 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 1200 | "fin %d syn %d rst %d psh %d ack %d urg %d ece %d cwr %d ns %d", |
| 1201 | tso_seg.tso_flags.fin, tso_seg.tso_flags.syn, |
| 1202 | tso_seg.tso_flags.rst, tso_seg.tso_flags.psh, |
| 1203 | tso_seg.tso_flags.ack, tso_seg.tso_flags.urg, |
| 1204 | tso_seg.tso_flags.ece, tso_seg.tso_flags.cwr, |
| 1205 | tso_seg.tso_flags.ns); |
| 1206 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 1207 | "tcp_seq_num: 0x%x ip_id: %d", |
| 1208 | tso_seg.tso_flags.tcp_seq_num, |
| 1209 | tso_seg.tso_flags.ip_id); |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1210 | } |
| 1211 | } |
| 1212 | } |
Yun Park | 1027e8c | 2017-10-13 15:17:37 -0700 | [diff] [blame] | 1213 | |
| 1214 | static void ol_txrx_tso_stats_clear(ol_txrx_pdev_handle pdev) |
| 1215 | { |
| 1216 | qdf_mem_zero(&pdev->stats.pub.tx.tso.tso_pkts, |
| 1217 | sizeof(struct ol_txrx_stats_elem)); |
| 1218 | #if defined(FEATURE_TSO) |
| 1219 | qdf_mem_zero(&pdev->stats.pub.tx.tso.tso_info, |
| 1220 | sizeof(struct ol_txrx_stats_tso_info)); |
| 1221 | qdf_mem_zero(&pdev->stats.pub.tx.tso.tso_hist, |
| 1222 | sizeof(struct ol_txrx_tso_histogram)); |
| 1223 | #endif |
| 1224 | } |
| 1225 | |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1226 | #else |
Yun Park | 1027e8c | 2017-10-13 15:17:37 -0700 | [diff] [blame] | 1227 | |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1228 | static void ol_txrx_stats_display_tso(ol_txrx_pdev_handle pdev) |
| 1229 | { |
| 1230 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 1231 | "TSO is not supported\n"); |
| 1232 | } |
| 1233 | |
| 1234 | static void ol_txrx_tso_stats_init(ol_txrx_pdev_handle pdev) |
| 1235 | { |
| 1236 | /* |
| 1237 | * keeping the body empty and not keeping an error print as print will |
| 1238 | * will show up everytime during driver load if TSO is not enabled. |
| 1239 | */ |
| 1240 | } |
| 1241 | |
| 1242 | static void ol_txrx_tso_stats_deinit(ol_txrx_pdev_handle pdev) |
| 1243 | { |
| 1244 | /* |
| 1245 | * keeping the body empty and not keeping an error print as print will |
| 1246 | * will show up everytime during driver unload if TSO is not enabled. |
| 1247 | */ |
| 1248 | } |
| 1249 | |
Yun Park | 1027e8c | 2017-10-13 15:17:37 -0700 | [diff] [blame] | 1250 | static void ol_txrx_tso_stats_clear(ol_txrx_pdev_handle pdev) |
| 1251 | { |
| 1252 | /* |
| 1253 | * keeping the body empty and not keeping an error print as print will |
| 1254 | * will show up everytime during driver unload if TSO is not enabled. |
| 1255 | */ |
| 1256 | } |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1257 | #endif /* defined(FEATURE_TSO) && defined(FEATURE_TSO_DEBUG) */ |
| 1258 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1259 | /** |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1260 | * ol_txrx_pdev_attach() - allocate txrx pdev |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1261 | * @ctrl_pdev: cfg pdev |
| 1262 | * @htc_pdev: HTC pdev |
| 1263 | * @osdev: os dev |
| 1264 | * |
| 1265 | * Return: txrx pdev handle |
| 1266 | * NULL for failure |
| 1267 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1268 | static struct cdp_pdev * |
| 1269 | ol_txrx_pdev_attach(ol_txrx_soc_handle soc, struct cdp_cfg *ctrl_pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 1270 | HTC_HANDLE htc_pdev, qdf_device_t osdev, uint8_t pdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1271 | { |
| 1272 | struct ol_txrx_pdev_t *pdev; |
hqu | fd227fe | 2017-06-26 17:01:14 +0800 | [diff] [blame] | 1273 | int i, tid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1274 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1275 | pdev = qdf_mem_malloc(sizeof(*pdev)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1276 | if (!pdev) |
| 1277 | goto fail0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1278 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1279 | /* init LL/HL cfg here */ |
| 1280 | pdev->cfg.is_high_latency = ol_cfg_is_high_latency(ctrl_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1281 | pdev->cfg.default_tx_comp_req = !ol_cfg_tx_free_at_download(ctrl_pdev); |
| 1282 | |
| 1283 | /* store provided params */ |
| 1284 | pdev->ctrl_pdev = ctrl_pdev; |
| 1285 | pdev->osdev = osdev; |
| 1286 | |
| 1287 | for (i = 0; i < htt_num_sec_types; i++) |
| 1288 | pdev->sec_types[i] = (enum ol_sec_type)i; |
| 1289 | |
| 1290 | TXRX_STATS_INIT(pdev); |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1291 | ol_txrx_tso_stats_init(pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1292 | |
| 1293 | TAILQ_INIT(&pdev->vdev_list); |
| 1294 | |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 1295 | TAILQ_INIT(&pdev->req_list); |
| 1296 | pdev->req_list_depth = 0; |
| 1297 | qdf_spinlock_create(&pdev->req_list_spinlock); |
| 1298 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1299 | /* do initial set up of the peer ID -> peer object lookup map */ |
| 1300 | if (ol_txrx_peer_find_attach(pdev)) |
| 1301 | goto fail1; |
| 1302 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1303 | /* initialize the counter of the target's tx buffer availability */ |
| 1304 | qdf_atomic_init(&pdev->target_tx_credit); |
| 1305 | qdf_atomic_init(&pdev->orig_target_tx_credit); |
| 1306 | |
| 1307 | if (ol_cfg_is_high_latency(ctrl_pdev)) { |
| 1308 | qdf_spinlock_create(&pdev->tx_queue_spinlock); |
| 1309 | pdev->tx_sched.scheduler = ol_tx_sched_attach(pdev); |
| 1310 | if (pdev->tx_sched.scheduler == NULL) |
| 1311 | goto fail2; |
| 1312 | } |
| 1313 | ol_txrx_pdev_txq_log_init(pdev); |
| 1314 | ol_txrx_pdev_grp_stats_init(pdev); |
| 1315 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1316 | pdev->htt_pdev = |
| 1317 | htt_pdev_alloc(pdev, ctrl_pdev, htc_pdev, osdev); |
| 1318 | if (!pdev->htt_pdev) |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1319 | goto fail3; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1320 | |
Himanshu Agarwal | f65bd4c | 2016-12-05 17:21:12 +0530 | [diff] [blame] | 1321 | htt_register_rx_pkt_dump_callback(pdev->htt_pdev, |
| 1322 | ol_rx_pkt_dump_call); |
hqu | fd227fe | 2017-06-26 17:01:14 +0800 | [diff] [blame] | 1323 | |
| 1324 | /* |
| 1325 | * Init the tid --> category table. |
| 1326 | * Regular tids (0-15) map to their AC. |
| 1327 | * Extension tids get their own categories. |
| 1328 | */ |
| 1329 | for (tid = 0; tid < OL_TX_NUM_QOS_TIDS; tid++) { |
| 1330 | int ac = TXRX_TID_TO_WMM_AC(tid); |
| 1331 | |
| 1332 | pdev->tid_to_ac[tid] = ac; |
| 1333 | } |
| 1334 | pdev->tid_to_ac[OL_TX_NON_QOS_TID] = |
| 1335 | OL_TX_SCHED_WRR_ADV_CAT_NON_QOS_DATA; |
| 1336 | pdev->tid_to_ac[OL_TX_MGMT_TID] = |
| 1337 | OL_TX_SCHED_WRR_ADV_CAT_UCAST_MGMT; |
| 1338 | pdev->tid_to_ac[OL_TX_NUM_TIDS + OL_TX_VDEV_MCAST_BCAST] = |
| 1339 | OL_TX_SCHED_WRR_ADV_CAT_MCAST_DATA; |
| 1340 | pdev->tid_to_ac[OL_TX_NUM_TIDS + OL_TX_VDEV_DEFAULT_MGMT] = |
| 1341 | OL_TX_SCHED_WRR_ADV_CAT_MCAST_MGMT; |
| 1342 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1343 | return (struct cdp_pdev *)pdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1344 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1345 | fail3: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1346 | ol_txrx_peer_find_detach(pdev); |
| 1347 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1348 | fail2: |
| 1349 | if (ol_cfg_is_high_latency(ctrl_pdev)) |
| 1350 | qdf_spinlock_destroy(&pdev->tx_queue_spinlock); |
| 1351 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1352 | fail1: |
Himanshu Agarwal | 5501c19 | 2017-02-14 11:39:39 +0530 | [diff] [blame] | 1353 | ol_txrx_tso_stats_deinit(pdev); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1354 | qdf_mem_free(pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1355 | |
| 1356 | fail0: |
| 1357 | return NULL; |
| 1358 | } |
| 1359 | |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1360 | #if !defined(REMOVE_PKT_LOG) && !defined(QVIT) |
| 1361 | /** |
| 1362 | * htt_pkt_log_init() - API to initialize packet log |
| 1363 | * @handle: pdev handle |
| 1364 | * @scn: HIF context |
| 1365 | * |
| 1366 | * Return: void |
| 1367 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1368 | void htt_pkt_log_init(struct cdp_pdev *ppdev, void *scn) |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1369 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1370 | struct ol_txrx_pdev_t *handle = (struct ol_txrx_pdev_t *)ppdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 1371 | |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1372 | if (handle->pkt_log_init) |
| 1373 | return; |
| 1374 | |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 1375 | if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE && |
Houston Hoffman | 371d4a9 | 2016-04-14 17:02:37 -0700 | [diff] [blame] | 1376 | !QDF_IS_EPPING_ENABLED(cds_get_conparam())) { |
Venkata Sharath Chandra Manchala | 1240fc7 | 2017-10-26 17:32:29 -0700 | [diff] [blame] | 1377 | pktlog_sethandle(&handle->pl_dev, scn); |
Venkata Sharath Chandra Manchala | 2996517 | 2018-01-18 14:17:29 -0800 | [diff] [blame] | 1378 | pktlog_set_callback_regtype(PKTLOG_DEFAULT_CALLBACK_REGISTRATION); |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1379 | if (pktlogmod_init(scn)) |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 1380 | qdf_print("%s: pktlogmod_init failed", __func__); |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1381 | else |
| 1382 | handle->pkt_log_init = true; |
| 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | /** |
| 1387 | * htt_pktlogmod_exit() - API to cleanup pktlog info |
| 1388 | * @handle: Pdev handle |
| 1389 | * @scn: HIF Context |
| 1390 | * |
| 1391 | * Return: void |
| 1392 | */ |
Houston Hoffman | 8c48504 | 2017-02-08 13:40:21 -0800 | [diff] [blame] | 1393 | static void htt_pktlogmod_exit(struct ol_txrx_pdev_t *handle) |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1394 | { |
Houston Hoffman | 8c48504 | 2017-02-08 13:40:21 -0800 | [diff] [blame] | 1395 | if (cds_get_conparam() != QDF_GLOBAL_FTM_MODE && |
Houston Hoffman | 371d4a9 | 2016-04-14 17:02:37 -0700 | [diff] [blame] | 1396 | !QDF_IS_EPPING_ENABLED(cds_get_conparam()) && |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1397 | handle->pkt_log_init) { |
Houston Hoffman | 8c48504 | 2017-02-08 13:40:21 -0800 | [diff] [blame] | 1398 | pktlogmod_exit(handle); |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1399 | handle->pkt_log_init = false; |
| 1400 | } |
| 1401 | } |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1402 | |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1403 | #else |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1404 | void htt_pkt_log_init(struct cdp_pdev *pdev_handle, void *ol_sc) { } |
Houston Hoffman | 8c48504 | 2017-02-08 13:40:21 -0800 | [diff] [blame] | 1405 | static void htt_pktlogmod_exit(ol_txrx_pdev_handle handle) { } |
Komal Seelam | c4b2863 | 2016-02-03 15:02:18 +0530 | [diff] [blame] | 1406 | #endif |
| 1407 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1408 | /** |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1409 | * ol_txrx_pdev_post_attach() - attach txrx pdev |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1410 | * @pdev: txrx pdev |
| 1411 | * |
| 1412 | * Return: 0 for success |
| 1413 | */ |
| 1414 | int |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1415 | ol_txrx_pdev_post_attach(struct cdp_pdev *ppdev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1416 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1417 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1418 | uint16_t i; |
| 1419 | uint16_t fail_idx = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1420 | int ret = 0; |
| 1421 | uint16_t desc_pool_size; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1422 | struct hif_opaque_softc *osc = cds_get_context(QDF_MODULE_ID_HIF); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1423 | |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1424 | uint16_t desc_element_size = sizeof(union ol_tx_desc_list_elem_t); |
| 1425 | union ol_tx_desc_list_elem_t *c_element; |
| 1426 | unsigned int sig_bit; |
| 1427 | uint16_t desc_per_page; |
| 1428 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1429 | if (!osc) { |
| 1430 | ret = -EINVAL; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1431 | goto ol_attach_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1432 | } |
| 1433 | |
| 1434 | /* |
| 1435 | * For LL, limit the number of host's tx descriptors to match |
| 1436 | * the number of target FW tx descriptors. |
| 1437 | * This simplifies the FW, by ensuring the host will never |
| 1438 | * download more tx descriptors than the target has space for. |
| 1439 | * The FW will drop/free low-priority tx descriptors when it |
| 1440 | * starts to run low, so that in theory the host should never |
| 1441 | * run out of tx descriptors. |
| 1442 | */ |
| 1443 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1444 | /* |
| 1445 | * LL - initialize the target credit outselves. |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1446 | * HL - wait for a HTT target credit initialization |
| 1447 | * during htt_attach. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1448 | */ |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1449 | if (pdev->cfg.is_high_latency) { |
| 1450 | desc_pool_size = ol_tx_desc_pool_size_hl(pdev->ctrl_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1451 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1452 | qdf_atomic_init(&pdev->tx_queue.rsrc_cnt); |
| 1453 | qdf_atomic_add(desc_pool_size, &pdev->tx_queue.rsrc_cnt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1454 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1455 | pdev->tx_queue.rsrc_threshold_lo = |
| 1456 | ol_txrx_rsrc_threshold_lo(desc_pool_size); |
| 1457 | pdev->tx_queue.rsrc_threshold_hi = |
| 1458 | ol_txrx_rsrc_threshold_hi(desc_pool_size); |
| 1459 | |
| 1460 | for (i = 0 ; i < OL_TX_MAX_TXQ_GROUPS; i++) |
| 1461 | qdf_atomic_init(&pdev->txq_grps[i].credit); |
| 1462 | |
| 1463 | ol_tx_target_credit_init(pdev, desc_pool_size); |
| 1464 | } else { |
| 1465 | qdf_atomic_add(ol_cfg_target_tx_credit(pdev->ctrl_pdev), |
| 1466 | &pdev->target_tx_credit); |
| 1467 | desc_pool_size = ol_tx_get_desc_global_pool_size(pdev); |
| 1468 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1469 | |
Nirav Shah | 7629196 | 2016-04-25 10:50:37 +0530 | [diff] [blame] | 1470 | ol_tx_desc_dup_detect_init(pdev, desc_pool_size); |
| 1471 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1472 | setup_fastpath_ce_handles(osc, pdev); |
| 1473 | |
| 1474 | ret = htt_attach(pdev->htt_pdev, desc_pool_size); |
| 1475 | if (ret) |
Himanshu Agarwal | f8f43a7 | 2017-03-24 15:27:29 +0530 | [diff] [blame] | 1476 | goto htt_attach_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1477 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1478 | /* Attach micro controller data path offload resource */ |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1479 | if (ol_cfg_ipa_uc_offload_enabled(pdev->ctrl_pdev)) { |
| 1480 | ret = htt_ipa_uc_attach(pdev->htt_pdev); |
| 1481 | if (ret) |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1482 | goto uc_attach_fail; |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1483 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1484 | |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1485 | /* Calculate single element reserved size power of 2 */ |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1486 | pdev->tx_desc.desc_reserved_size = qdf_get_pwr2(desc_element_size); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1487 | qdf_mem_multi_pages_alloc(pdev->osdev, &pdev->tx_desc.desc_pages, |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1488 | pdev->tx_desc.desc_reserved_size, desc_pool_size, 0, true); |
| 1489 | if ((0 == pdev->tx_desc.desc_pages.num_pages) || |
| 1490 | (NULL == pdev->tx_desc.desc_pages.cacheable_pages)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1491 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1492 | "Page alloc fail"); |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1493 | ret = -ENOMEM; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1494 | goto page_alloc_fail; |
| 1495 | } |
| 1496 | desc_per_page = pdev->tx_desc.desc_pages.num_element_per_page; |
| 1497 | pdev->tx_desc.offset_filter = desc_per_page - 1; |
| 1498 | /* Calculate page divider to find page number */ |
| 1499 | sig_bit = 0; |
| 1500 | while (desc_per_page) { |
| 1501 | sig_bit++; |
| 1502 | desc_per_page = desc_per_page >> 1; |
| 1503 | } |
| 1504 | pdev->tx_desc.page_divider = (sig_bit - 1); |
Srinivas Girigowda | b8ecec2 | 2017-03-09 15:02:59 -0800 | [diff] [blame] | 1505 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG, |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1506 | "page_divider 0x%x, offset_filter 0x%x num elem %d, ol desc num page %d, ol desc per page %d", |
| 1507 | pdev->tx_desc.page_divider, pdev->tx_desc.offset_filter, |
| 1508 | desc_pool_size, pdev->tx_desc.desc_pages.num_pages, |
| 1509 | pdev->tx_desc.desc_pages.num_element_per_page); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1510 | |
| 1511 | /* |
| 1512 | * Each SW tx desc (used only within the tx datapath SW) has a |
| 1513 | * matching HTT tx desc (used for downloading tx meta-data to FW/HW). |
| 1514 | * Go ahead and allocate the HTT tx desc and link it with the SW tx |
| 1515 | * desc now, to avoid doing it during time-critical transmit. |
| 1516 | */ |
| 1517 | pdev->tx_desc.pool_size = desc_pool_size; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1518 | pdev->tx_desc.freelist = |
| 1519 | (union ol_tx_desc_list_elem_t *) |
| 1520 | (*pdev->tx_desc.desc_pages.cacheable_pages); |
| 1521 | c_element = pdev->tx_desc.freelist; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1522 | for (i = 0; i < desc_pool_size; i++) { |
| 1523 | void *htt_tx_desc; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1524 | void *htt_frag_desc = NULL; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1525 | qdf_dma_addr_t frag_paddr = 0; |
| 1526 | qdf_dma_addr_t paddr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1527 | |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1528 | if (i == (desc_pool_size - 1)) |
| 1529 | c_element->next = NULL; |
| 1530 | else |
| 1531 | c_element->next = (union ol_tx_desc_list_elem_t *) |
| 1532 | ol_tx_desc_find(pdev, i + 1); |
| 1533 | |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 1534 | htt_tx_desc = htt_tx_desc_alloc(pdev->htt_pdev, &paddr, i); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1535 | if (!htt_tx_desc) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1536 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1537 | "%s: failed to alloc HTT tx desc (%d of %d)", |
| 1538 | __func__, i, desc_pool_size); |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1539 | fail_idx = i; |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1540 | ret = -ENOMEM; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1541 | goto desc_alloc_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1543 | |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1544 | c_element->tx_desc.htt_tx_desc = htt_tx_desc; |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 1545 | c_element->tx_desc.htt_tx_desc_paddr = paddr; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1546 | ret = htt_tx_frag_alloc(pdev->htt_pdev, |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 1547 | i, &frag_paddr, &htt_frag_desc); |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1548 | if (ret) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1549 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1550 | "%s: failed to alloc HTT frag dsc (%d/%d)", |
| 1551 | __func__, i, desc_pool_size); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1552 | /* Is there a leak here, is this handling correct? */ |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1553 | fail_idx = i; |
| 1554 | goto desc_alloc_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1555 | } |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1556 | if (!ret && htt_frag_desc) { |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 1557 | /* |
| 1558 | * Initialize the first 6 words (TSO flags) |
| 1559 | * of the frag descriptor |
| 1560 | */ |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1561 | memset(htt_frag_desc, 0, 6 * sizeof(uint32_t)); |
| 1562 | c_element->tx_desc.htt_frag_desc = htt_frag_desc; |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 1563 | c_element->tx_desc.htt_frag_desc_paddr = frag_paddr; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1564 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1565 | #ifdef QCA_SUPPORT_TXDESC_SANITY_CHECKS |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1566 | c_element->tx_desc.pkt_type = 0xff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1567 | #ifdef QCA_COMPUTE_TX_DELAY |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1568 | c_element->tx_desc.entry_timestamp_ticks = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1569 | 0xffffffff; |
| 1570 | #endif |
| 1571 | #endif |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1572 | c_element->tx_desc.id = i; |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 1573 | qdf_atomic_init(&c_element->tx_desc.ref_cnt); |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1574 | c_element = c_element->next; |
| 1575 | fail_idx = i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1576 | } |
| 1577 | |
| 1578 | /* link SW tx descs into a freelist */ |
| 1579 | pdev->tx_desc.num_free = desc_pool_size; |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 1580 | ol_txrx_dbg( |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 1581 | "%s first tx_desc:0x%pK Last tx desc:0x%pK\n", __func__, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1582 | (uint32_t *) pdev->tx_desc.freelist, |
| 1583 | (uint32_t *) (pdev->tx_desc.freelist + desc_pool_size)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1584 | |
| 1585 | /* check what format of frames are expected to be delivered by the OS */ |
| 1586 | pdev->frame_format = ol_cfg_frame_type(pdev->ctrl_pdev); |
| 1587 | if (pdev->frame_format == wlan_frm_fmt_native_wifi) |
| 1588 | pdev->htt_pkt_type = htt_pkt_type_native_wifi; |
| 1589 | else if (pdev->frame_format == wlan_frm_fmt_802_3) { |
| 1590 | if (ol_cfg_is_ce_classify_enabled(pdev->ctrl_pdev)) |
| 1591 | pdev->htt_pkt_type = htt_pkt_type_eth2; |
| 1592 | else |
| 1593 | pdev->htt_pkt_type = htt_pkt_type_ethernet; |
| 1594 | } else { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1595 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1596 | "%s Invalid standard frame type: %d", |
| 1597 | __func__, pdev->frame_format); |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1598 | ret = -EINVAL; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1599 | goto control_init_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1600 | } |
| 1601 | |
| 1602 | /* setup the global rx defrag waitlist */ |
| 1603 | TAILQ_INIT(&pdev->rx.defrag.waitlist); |
| 1604 | |
| 1605 | /* configure where defrag timeout and duplicate detection is handled */ |
| 1606 | pdev->rx.flags.defrag_timeout_check = |
| 1607 | pdev->rx.flags.dup_check = |
| 1608 | ol_cfg_rx_host_defrag_timeout_duplicate_check(pdev->ctrl_pdev); |
| 1609 | |
| 1610 | #ifdef QCA_SUPPORT_SW_TXRX_ENCAP |
| 1611 | /* Need to revisit this part. Currently,hardcode to riva's caps */ |
| 1612 | pdev->target_tx_tran_caps = wlan_frm_tran_cap_raw; |
| 1613 | pdev->target_rx_tran_caps = wlan_frm_tran_cap_raw; |
| 1614 | /* |
| 1615 | * The Riva HW de-aggregate doesn't have capability to generate 802.11 |
| 1616 | * header for non-first subframe of A-MSDU. |
| 1617 | */ |
| 1618 | pdev->sw_subfrm_hdr_recovery_enable = 1; |
| 1619 | /* |
| 1620 | * The Riva HW doesn't have the capability to set Protected Frame bit |
| 1621 | * in the MAC header for encrypted data frame. |
| 1622 | */ |
| 1623 | pdev->sw_pf_proc_enable = 1; |
| 1624 | |
| 1625 | if (pdev->frame_format == wlan_frm_fmt_802_3) { |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 1626 | /* |
| 1627 | * sw llc process is only needed in |
| 1628 | * 802.3 to 802.11 transform case |
| 1629 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1630 | pdev->sw_tx_llc_proc_enable = 1; |
| 1631 | pdev->sw_rx_llc_proc_enable = 1; |
| 1632 | } else { |
| 1633 | pdev->sw_tx_llc_proc_enable = 0; |
| 1634 | pdev->sw_rx_llc_proc_enable = 0; |
| 1635 | } |
| 1636 | |
| 1637 | switch (pdev->frame_format) { |
| 1638 | case wlan_frm_fmt_raw: |
| 1639 | pdev->sw_tx_encap = |
| 1640 | pdev->target_tx_tran_caps & wlan_frm_tran_cap_raw |
| 1641 | ? 0 : 1; |
| 1642 | pdev->sw_rx_decap = |
| 1643 | pdev->target_rx_tran_caps & wlan_frm_tran_cap_raw |
| 1644 | ? 0 : 1; |
| 1645 | break; |
| 1646 | case wlan_frm_fmt_native_wifi: |
| 1647 | pdev->sw_tx_encap = |
| 1648 | pdev-> |
| 1649 | target_tx_tran_caps & wlan_frm_tran_cap_native_wifi |
| 1650 | ? 0 : 1; |
| 1651 | pdev->sw_rx_decap = |
| 1652 | pdev-> |
| 1653 | target_rx_tran_caps & wlan_frm_tran_cap_native_wifi |
| 1654 | ? 0 : 1; |
| 1655 | break; |
| 1656 | case wlan_frm_fmt_802_3: |
| 1657 | pdev->sw_tx_encap = |
| 1658 | pdev->target_tx_tran_caps & wlan_frm_tran_cap_8023 |
| 1659 | ? 0 : 1; |
| 1660 | pdev->sw_rx_decap = |
| 1661 | pdev->target_rx_tran_caps & wlan_frm_tran_cap_8023 |
| 1662 | ? 0 : 1; |
| 1663 | break; |
| 1664 | default: |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1665 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1666 | "Invalid std frame type; [en/de]cap: f:%x t:%x r:%x", |
| 1667 | pdev->frame_format, |
| 1668 | pdev->target_tx_tran_caps, pdev->target_rx_tran_caps); |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1669 | ret = -EINVAL; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1670 | goto control_init_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1671 | } |
| 1672 | #endif |
| 1673 | |
| 1674 | /* |
| 1675 | * Determine what rx processing steps are done within the host. |
| 1676 | * Possibilities: |
| 1677 | * 1. Nothing - rx->tx forwarding and rx PN entirely within target. |
| 1678 | * (This is unlikely; even if the target is doing rx->tx forwarding, |
| 1679 | * the host should be doing rx->tx forwarding too, as a back up for |
| 1680 | * the target's rx->tx forwarding, in case the target runs short on |
| 1681 | * memory, and can't store rx->tx frames that are waiting for |
| 1682 | * missing prior rx frames to arrive.) |
| 1683 | * 2. Just rx -> tx forwarding. |
| 1684 | * This is the typical configuration for HL, and a likely |
| 1685 | * configuration for LL STA or small APs (e.g. retail APs). |
| 1686 | * 3. Both PN check and rx -> tx forwarding. |
| 1687 | * This is the typical configuration for large LL APs. |
| 1688 | * Host-side PN check without rx->tx forwarding is not a valid |
| 1689 | * configuration, since the PN check needs to be done prior to |
| 1690 | * the rx->tx forwarding. |
| 1691 | */ |
| 1692 | if (ol_cfg_is_full_reorder_offload(pdev->ctrl_pdev)) { |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 1693 | /* |
| 1694 | * PN check, rx-tx forwarding and rx reorder is done by |
| 1695 | * the target |
| 1696 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1697 | if (ol_cfg_rx_fwd_disabled(pdev->ctrl_pdev)) |
| 1698 | pdev->rx_opt_proc = ol_rx_in_order_deliver; |
| 1699 | else |
| 1700 | pdev->rx_opt_proc = ol_rx_fwd_check; |
| 1701 | } else { |
| 1702 | if (ol_cfg_rx_pn_check(pdev->ctrl_pdev)) { |
| 1703 | if (ol_cfg_rx_fwd_disabled(pdev->ctrl_pdev)) { |
| 1704 | /* |
| 1705 | * PN check done on host, |
| 1706 | * rx->tx forwarding not done at all. |
| 1707 | */ |
| 1708 | pdev->rx_opt_proc = ol_rx_pn_check_only; |
| 1709 | } else if (ol_cfg_rx_fwd_check(pdev->ctrl_pdev)) { |
| 1710 | /* |
| 1711 | * Both PN check and rx->tx forwarding done |
| 1712 | * on host. |
| 1713 | */ |
| 1714 | pdev->rx_opt_proc = ol_rx_pn_check; |
| 1715 | } else { |
| 1716 | #define TRACESTR01 "invalid config: if rx PN check is on the host,"\ |
| 1717 | "rx->tx forwarding check needs to also be on the host" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 1718 | QDF_TRACE(QDF_MODULE_ID_TXRX, |
| 1719 | QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1720 | "%s: %s", __func__, TRACESTR01); |
| 1721 | #undef TRACESTR01 |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1722 | ret = -EINVAL; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1723 | goto control_init_fail; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1724 | } |
| 1725 | } else { |
| 1726 | /* PN check done on target */ |
| 1727 | if ((!ol_cfg_rx_fwd_disabled(pdev->ctrl_pdev)) && |
| 1728 | ol_cfg_rx_fwd_check(pdev->ctrl_pdev)) { |
| 1729 | /* |
| 1730 | * rx->tx forwarding done on host (possibly as |
| 1731 | * back-up for target-side primary rx->tx |
| 1732 | * forwarding) |
| 1733 | */ |
| 1734 | pdev->rx_opt_proc = ol_rx_fwd_check; |
| 1735 | } else { |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 1736 | /* |
| 1737 | * rx->tx forwarding either done in target, |
| 1738 | * or not done at all |
| 1739 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1740 | pdev->rx_opt_proc = ol_rx_deliver; |
| 1741 | } |
| 1742 | } |
| 1743 | } |
| 1744 | |
| 1745 | /* initialize mutexes for tx desc alloc and peer lookup */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1746 | qdf_spinlock_create(&pdev->tx_mutex); |
| 1747 | qdf_spinlock_create(&pdev->peer_ref_mutex); |
| 1748 | qdf_spinlock_create(&pdev->rx.mutex); |
| 1749 | qdf_spinlock_create(&pdev->last_real_peer_mutex); |
Mohit Khanna | 37ffb29 | 2016-08-08 16:20:01 -0700 | [diff] [blame] | 1750 | qdf_spinlock_create(&pdev->peer_map_unmap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1751 | OL_TXRX_PEER_STATS_MUTEX_INIT(pdev); |
| 1752 | |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1753 | if (OL_RX_REORDER_TRACE_ATTACH(pdev) != A_OK) { |
| 1754 | ret = -ENOMEM; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1755 | goto reorder_trace_attach_fail; |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1756 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1757 | |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1758 | if (OL_RX_PN_TRACE_ATTACH(pdev) != A_OK) { |
| 1759 | ret = -ENOMEM; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1760 | goto pn_trace_attach_fail; |
Yun Park | f01f6e2 | 2017-01-18 17:27:02 -0800 | [diff] [blame] | 1761 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1762 | |
| 1763 | #ifdef PERE_IP_HDR_ALIGNMENT_WAR |
| 1764 | pdev->host_80211_enable = ol_scn_host_80211_enable_get(pdev->ctrl_pdev); |
| 1765 | #endif |
| 1766 | |
| 1767 | /* |
| 1768 | * WDI event attach |
| 1769 | */ |
| 1770 | wdi_event_attach(pdev); |
| 1771 | |
| 1772 | /* |
| 1773 | * Initialize rx PN check characteristics for different security types. |
| 1774 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1775 | qdf_mem_set(&pdev->rx_pn[0], sizeof(pdev->rx_pn), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1776 | |
| 1777 | /* TKIP: 48-bit TSC, CCMP: 48-bit PN */ |
| 1778 | pdev->rx_pn[htt_sec_type_tkip].len = |
| 1779 | pdev->rx_pn[htt_sec_type_tkip_nomic].len = |
| 1780 | pdev->rx_pn[htt_sec_type_aes_ccmp].len = 48; |
| 1781 | pdev->rx_pn[htt_sec_type_tkip].cmp = |
| 1782 | pdev->rx_pn[htt_sec_type_tkip_nomic].cmp = |
| 1783 | pdev->rx_pn[htt_sec_type_aes_ccmp].cmp = ol_rx_pn_cmp48; |
| 1784 | |
| 1785 | /* WAPI: 128-bit PN */ |
| 1786 | pdev->rx_pn[htt_sec_type_wapi].len = 128; |
| 1787 | pdev->rx_pn[htt_sec_type_wapi].cmp = ol_rx_pn_wapi_cmp; |
| 1788 | |
| 1789 | OL_RX_REORDER_TIMEOUT_INIT(pdev); |
| 1790 | |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 1791 | ol_txrx_dbg("Created pdev %pK\n", pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1792 | |
| 1793 | pdev->cfg.host_addba = ol_cfg_host_addba(pdev->ctrl_pdev); |
| 1794 | |
| 1795 | #ifdef QCA_SUPPORT_PEER_DATA_RX_RSSI |
| 1796 | #define OL_TXRX_RSSI_UPDATE_SHIFT_DEFAULT 3 |
| 1797 | |
| 1798 | /* #if 1 -- TODO: clean this up */ |
| 1799 | #define OL_TXRX_RSSI_NEW_WEIGHT_DEFAULT \ |
| 1800 | /* avg = 100% * new + 0% * old */ \ |
| 1801 | (1 << OL_TXRX_RSSI_UPDATE_SHIFT_DEFAULT) |
| 1802 | /* |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 1803 | * #else |
| 1804 | * #define OL_TXRX_RSSI_NEW_WEIGHT_DEFAULT |
| 1805 | * //avg = 25% * new + 25% * old |
| 1806 | * (1 << (OL_TXRX_RSSI_UPDATE_SHIFT_DEFAULT-2)) |
| 1807 | * #endif |
| 1808 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1809 | pdev->rssi_update_shift = OL_TXRX_RSSI_UPDATE_SHIFT_DEFAULT; |
| 1810 | pdev->rssi_new_weight = OL_TXRX_RSSI_NEW_WEIGHT_DEFAULT; |
| 1811 | #endif |
| 1812 | |
| 1813 | ol_txrx_local_peer_id_pool_init(pdev); |
| 1814 | |
| 1815 | pdev->cfg.ll_pause_txq_limit = |
| 1816 | ol_tx_cfg_max_tx_queue_depth_ll(pdev->ctrl_pdev); |
| 1817 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 1818 | /* TX flow control for peer who is in very bad link status */ |
| 1819 | ol_tx_badpeer_flow_cl_init(pdev); |
| 1820 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1821 | #ifdef QCA_COMPUTE_TX_DELAY |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1822 | qdf_mem_zero(&pdev->tx_delay, sizeof(pdev->tx_delay)); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1823 | qdf_spinlock_create(&pdev->tx_delay.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1824 | |
| 1825 | /* initialize compute interval with 5 seconds (ESE default) */ |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 1826 | pdev->tx_delay.avg_period_ticks = qdf_system_msecs_to_ticks(5000); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1827 | { |
| 1828 | uint32_t bin_width_1000ticks; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 1829 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1830 | bin_width_1000ticks = |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 1831 | qdf_system_msecs_to_ticks |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1832 | (QCA_TX_DELAY_HIST_INTERNAL_BIN_WIDTH_MS |
| 1833 | * 1000); |
| 1834 | /* |
| 1835 | * Compute a factor and shift that together are equal to the |
| 1836 | * inverse of the bin_width time, so that rather than dividing |
| 1837 | * by the bin width time, approximately the same result can be |
| 1838 | * obtained much more efficiently by a multiply + shift. |
| 1839 | * multiply_factor >> shift = 1 / bin_width_time, so |
| 1840 | * multiply_factor = (1 << shift) / bin_width_time. |
| 1841 | * |
| 1842 | * Pick the shift semi-arbitrarily. |
| 1843 | * If we knew statically what the bin_width would be, we could |
| 1844 | * choose a shift that minimizes the error. |
| 1845 | * Since the bin_width is determined dynamically, simply use a |
| 1846 | * shift that is about half of the uint32_t size. This should |
| 1847 | * result in a relatively large multiplier value, which |
| 1848 | * minimizes error from rounding the multiplier to an integer. |
| 1849 | * The rounding error only becomes significant if the tick units |
| 1850 | * are on the order of 1 microsecond. In most systems, it is |
| 1851 | * expected that the tick units will be relatively low-res, |
| 1852 | * on the order of 1 millisecond. In such systems the rounding |
| 1853 | * error is negligible. |
| 1854 | * It would be more accurate to dynamically try out different |
| 1855 | * shifts and choose the one that results in the smallest |
| 1856 | * rounding error, but that extra level of fidelity is |
| 1857 | * not needed. |
| 1858 | */ |
| 1859 | pdev->tx_delay.hist_internal_bin_width_shift = 16; |
| 1860 | pdev->tx_delay.hist_internal_bin_width_mult = |
| 1861 | ((1 << pdev->tx_delay.hist_internal_bin_width_shift) * |
| 1862 | 1000 + (bin_width_1000ticks >> 1)) / |
| 1863 | bin_width_1000ticks; |
| 1864 | } |
| 1865 | #endif /* QCA_COMPUTE_TX_DELAY */ |
| 1866 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1867 | /* Thermal Mitigation */ |
| 1868 | ol_tx_throttle_init(pdev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 1869 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1870 | ol_tso_seg_list_init(pdev, desc_pool_size); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 1871 | |
Poddar, Siddarth | 3f1fb13 | 2017-01-12 17:25:52 +0530 | [diff] [blame] | 1872 | ol_tso_num_seg_list_init(pdev, desc_pool_size); |
| 1873 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1874 | ol_tx_register_flow_control(pdev); |
| 1875 | |
| 1876 | return 0; /* success */ |
| 1877 | |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1878 | pn_trace_attach_fail: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1879 | OL_RX_REORDER_TRACE_DETACH(pdev); |
| 1880 | |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1881 | reorder_trace_attach_fail: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 1882 | qdf_spinlock_destroy(&pdev->tx_mutex); |
| 1883 | qdf_spinlock_destroy(&pdev->peer_ref_mutex); |
| 1884 | qdf_spinlock_destroy(&pdev->rx.mutex); |
| 1885 | qdf_spinlock_destroy(&pdev->last_real_peer_mutex); |
Himanshu Agarwal | f8f43a7 | 2017-03-24 15:27:29 +0530 | [diff] [blame] | 1886 | qdf_spinlock_destroy(&pdev->peer_map_unmap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1887 | OL_TXRX_PEER_STATS_MUTEX_DESTROY(pdev); |
| 1888 | |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1889 | control_init_fail: |
| 1890 | desc_alloc_fail: |
| 1891 | for (i = 0; i < fail_idx; i++) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1892 | htt_tx_desc_free(pdev->htt_pdev, |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1893 | (ol_tx_desc_find(pdev, i))->htt_tx_desc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1894 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1895 | qdf_mem_multi_pages_free(pdev->osdev, |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1896 | &pdev->tx_desc.desc_pages, 0, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1897 | |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1898 | page_alloc_fail: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1899 | if (ol_cfg_ipa_uc_offload_enabled(pdev->ctrl_pdev)) |
| 1900 | htt_ipa_uc_detach(pdev->htt_pdev); |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1901 | uc_attach_fail: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1902 | htt_detach(pdev->htt_pdev); |
Himanshu Agarwal | f8f43a7 | 2017-03-24 15:27:29 +0530 | [diff] [blame] | 1903 | htt_attach_fail: |
| 1904 | ol_tx_desc_dup_detect_deinit(pdev); |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1905 | ol_attach_fail: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | return ret; /* fail */ |
| 1907 | } |
| 1908 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1909 | /** |
| 1910 | * ol_txrx_pdev_attach_target() - send target configuration |
| 1911 | * |
| 1912 | * @pdev - the physical device being initialized |
| 1913 | * |
| 1914 | * The majority of the data SW setup are done by the pdev_attach |
| 1915 | * functions, but this function completes the data SW setup by |
| 1916 | * sending datapath configuration messages to the target. |
| 1917 | * |
| 1918 | * Return: 0 - success 1 - failure |
| 1919 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1920 | static A_STATUS ol_txrx_pdev_attach_target(struct cdp_pdev *ppdev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1921 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1922 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 1923 | |
Rakesh Pillai | 7fb7a1f | 2017-06-23 14:46:36 +0530 | [diff] [blame] | 1924 | return htt_attach_target(pdev->htt_pdev) == QDF_STATUS_SUCCESS ? 0:1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1925 | } |
| 1926 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1927 | /** |
Mohit Khanna | 54f3a38 | 2017-03-13 17:56:32 -0700 | [diff] [blame] | 1928 | * ol_tx_free_descs_inuse - free tx descriptors which are in use |
| 1929 | * @pdev - the physical device for which tx descs need to be freed |
| 1930 | * |
| 1931 | * Cycle through the list of TX descriptors (for a pdev) which are in use, |
| 1932 | * for which TX completion has not been received and free them. Should be |
| 1933 | * called only when the interrupts are off and all lower layer RX is stopped. |
| 1934 | * Otherwise there may be a race condition with TX completions. |
| 1935 | * |
| 1936 | * Return: None |
| 1937 | */ |
| 1938 | static void ol_tx_free_descs_inuse(ol_txrx_pdev_handle pdev) |
| 1939 | { |
| 1940 | int i; |
| 1941 | void *htt_tx_desc; |
| 1942 | struct ol_tx_desc_t *tx_desc; |
| 1943 | int num_freed_tx_desc = 0; |
| 1944 | |
| 1945 | for (i = 0; i < pdev->tx_desc.pool_size; i++) { |
| 1946 | tx_desc = ol_tx_desc_find(pdev, i); |
| 1947 | /* |
| 1948 | * Confirm that each tx descriptor is "empty", i.e. it has |
| 1949 | * no tx frame attached. |
| 1950 | * In particular, check that there are no frames that have |
| 1951 | * been given to the target to transmit, for which the |
| 1952 | * target has never provided a response. |
| 1953 | */ |
| 1954 | if (qdf_atomic_read(&tx_desc->ref_cnt)) { |
| 1955 | ol_txrx_dbg("Warning: freeing tx frame (no compltn)"); |
| 1956 | ol_tx_desc_frame_free_nonstd(pdev, |
| 1957 | tx_desc, 1); |
| 1958 | num_freed_tx_desc++; |
| 1959 | } |
| 1960 | htt_tx_desc = tx_desc->htt_tx_desc; |
| 1961 | htt_tx_desc_free(pdev->htt_pdev, htt_tx_desc); |
| 1962 | } |
| 1963 | |
| 1964 | if (num_freed_tx_desc) |
| 1965 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO, |
| 1966 | "freed %d tx frames for which no resp from target", |
| 1967 | num_freed_tx_desc); |
| 1968 | |
| 1969 | } |
| 1970 | |
| 1971 | /** |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 1972 | * ol_txrx_pdev_pre_detach() - detach the data SW state |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1973 | * @pdev - the data physical device object being removed |
| 1974 | * @force - delete the pdev (and its vdevs and peers) even if |
| 1975 | * there are outstanding references by the target to the vdevs |
| 1976 | * and peers within the pdev |
| 1977 | * |
| 1978 | * This function is used when the WLAN driver is being removed to |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 1979 | * detach the host data component within the driver. |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1980 | * |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 1981 | * Return: None |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 1982 | */ |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 1983 | static void ol_txrx_pdev_pre_detach(struct cdp_pdev *ppdev, int force) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1984 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1985 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 1986 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1987 | /* preconditions */ |
| 1988 | TXRX_ASSERT2(pdev); |
| 1989 | |
| 1990 | /* check that the pdev has no vdevs allocated */ |
| 1991 | TXRX_ASSERT1(TAILQ_EMPTY(&pdev->vdev_list)); |
| 1992 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1993 | #ifdef QCA_SUPPORT_TX_THROTTLE |
| 1994 | /* Thermal Mitigation */ |
Anurag Chouhan | 754fbd8 | 2016-02-19 17:00:08 +0530 | [diff] [blame] | 1995 | qdf_timer_stop(&pdev->tx_throttle.phase_timer); |
| 1996 | qdf_timer_free(&pdev->tx_throttle.phase_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1997 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
Anurag Chouhan | 754fbd8 | 2016-02-19 17:00:08 +0530 | [diff] [blame] | 1998 | qdf_timer_stop(&pdev->tx_throttle.tx_timer); |
| 1999 | qdf_timer_free(&pdev->tx_throttle.tx_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2000 | #endif |
| 2001 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2002 | |
| 2003 | if (force) { |
| 2004 | /* |
| 2005 | * The assertion above confirms that all vdevs within this pdev |
| 2006 | * were detached. However, they may not have actually been |
| 2007 | * deleted. |
| 2008 | * If the vdev had peers which never received a PEER_UNMAP msg |
| 2009 | * from the target, then there are still zombie peer objects, |
| 2010 | * and the vdev parents of the zombie peers are also zombies, |
| 2011 | * hanging around until their final peer gets deleted. |
| 2012 | * Go through the peer hash table and delete any peers left. |
| 2013 | * As a side effect, this will complete the deletion of any |
| 2014 | * vdevs that are waiting for their peers to finish deletion. |
| 2015 | */ |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 2016 | ol_txrx_dbg("Force delete for pdev %pK\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2017 | pdev); |
| 2018 | ol_txrx_peer_find_hash_erase(pdev); |
| 2019 | } |
| 2020 | |
Himanshu Agarwal | 749e0f2 | 2016-10-26 21:12:59 +0530 | [diff] [blame] | 2021 | /* to get flow pool status before freeing descs */ |
Manjunathappa Prakash | 6c54736 | 2017-03-30 20:11:47 -0700 | [diff] [blame] | 2022 | ol_tx_dump_flow_pool_info((void *)pdev); |
Mohit Khanna | 54f3a38 | 2017-03-13 17:56:32 -0700 | [diff] [blame] | 2023 | ol_tx_free_descs_inuse(pdev); |
Himanshu Agarwal | 749e0f2 | 2016-10-26 21:12:59 +0530 | [diff] [blame] | 2024 | ol_tx_deregister_flow_control(pdev); |
Mohit Khanna | 54f3a38 | 2017-03-13 17:56:32 -0700 | [diff] [blame] | 2025 | |
| 2026 | /* |
| 2027 | * ol_tso_seg_list_deinit should happen after |
| 2028 | * ol_tx_deinit_tx_desc_inuse as it tries to access the tso seg freelist |
| 2029 | * which is being de-initilized in ol_tso_seg_list_deinit |
| 2030 | */ |
| 2031 | ol_tso_seg_list_deinit(pdev); |
| 2032 | ol_tso_num_seg_list_deinit(pdev); |
| 2033 | |
Himanshu Agarwal | 749e0f2 | 2016-10-26 21:12:59 +0530 | [diff] [blame] | 2034 | /* Stop the communication between HTT and target at first */ |
| 2035 | htt_detach_target(pdev->htt_pdev); |
| 2036 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2037 | qdf_mem_multi_pages_free(pdev->osdev, |
Leo Chang | 376398b | 2015-10-23 14:19:02 -0700 | [diff] [blame] | 2038 | &pdev->tx_desc.desc_pages, 0, true); |
| 2039 | pdev->tx_desc.freelist = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2040 | |
| 2041 | /* Detach micro controller data path offload resource */ |
| 2042 | if (ol_cfg_ipa_uc_offload_enabled(pdev->ctrl_pdev)) |
| 2043 | htt_ipa_uc_detach(pdev->htt_pdev); |
| 2044 | |
| 2045 | htt_detach(pdev->htt_pdev); |
Nirav Shah | 7629196 | 2016-04-25 10:50:37 +0530 | [diff] [blame] | 2046 | ol_tx_desc_dup_detect_deinit(pdev); |
| 2047 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2048 | qdf_spinlock_destroy(&pdev->tx_mutex); |
| 2049 | qdf_spinlock_destroy(&pdev->peer_ref_mutex); |
| 2050 | qdf_spinlock_destroy(&pdev->last_real_peer_mutex); |
| 2051 | qdf_spinlock_destroy(&pdev->rx.mutex); |
Mohit Khanna | 37ffb29 | 2016-08-08 16:20:01 -0700 | [diff] [blame] | 2052 | qdf_spinlock_destroy(&pdev->peer_map_unmap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2053 | #ifdef QCA_SUPPORT_TX_THROTTLE |
| 2054 | /* Thermal Mitigation */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2055 | qdf_spinlock_destroy(&pdev->tx_throttle.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2056 | #endif |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2057 | |
| 2058 | /* TX flow control for peer who is in very bad link status */ |
| 2059 | ol_tx_badpeer_flow_cl_deinit(pdev); |
| 2060 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2061 | OL_TXRX_PEER_STATS_MUTEX_DESTROY(pdev); |
| 2062 | |
| 2063 | OL_RX_REORDER_TRACE_DETACH(pdev); |
| 2064 | OL_RX_PN_TRACE_DETACH(pdev); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2065 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2066 | /* |
| 2067 | * WDI event detach |
| 2068 | */ |
| 2069 | wdi_event_detach(pdev); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2070 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2071 | ol_txrx_local_peer_id_cleanup(pdev); |
| 2072 | |
| 2073 | #ifdef QCA_COMPUTE_TX_DELAY |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2074 | qdf_spinlock_destroy(&pdev->tx_delay.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2075 | #endif |
Houston Hoffman | e5ec049 | 2017-01-30 12:28:32 -0800 | [diff] [blame] | 2076 | qdf_mem_free(ppdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2077 | } |
| 2078 | |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2079 | /** |
| 2080 | * ol_txrx_pdev_detach() - delete the data SW state |
| 2081 | * @ppdev - the data physical device object being removed |
| 2082 | * @force - delete the pdev (and its vdevs and peers) even if |
| 2083 | * there are outstanding references by the target to the vdevs |
| 2084 | * and peers within the pdev |
| 2085 | * |
| 2086 | * This function is used when the WLAN driver is being removed to |
| 2087 | * remove the host data component within the driver. |
| 2088 | * All virtual devices within the physical device need to be deleted |
| 2089 | * (ol_txrx_vdev_detach) before the physical device itself is deleted. |
| 2090 | * |
| 2091 | * Return: None |
| 2092 | */ |
| 2093 | static void ol_txrx_pdev_detach(struct cdp_pdev *ppdev, int force) |
| 2094 | { |
| 2095 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 2096 | struct ol_txrx_stats_req_internal *req; |
| 2097 | int i = 0; |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2098 | |
| 2099 | /*checking to ensure txrx pdev structure is not NULL */ |
| 2100 | if (!pdev) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 2101 | ol_txrx_err( |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2102 | "NULL pdev passed to %s\n", __func__); |
| 2103 | return; |
| 2104 | } |
| 2105 | |
| 2106 | htt_pktlogmod_exit(pdev); |
| 2107 | |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 2108 | qdf_spin_lock_bh(&pdev->req_list_spinlock); |
| 2109 | if (pdev->req_list_depth > 0) |
| 2110 | ol_txrx_err( |
| 2111 | "Warning: the txrx req list is not empty, depth=%d\n", |
| 2112 | pdev->req_list_depth |
| 2113 | ); |
| 2114 | TAILQ_FOREACH(req, &pdev->req_list, req_list_elem) { |
| 2115 | TAILQ_REMOVE(&pdev->req_list, req, req_list_elem); |
| 2116 | pdev->req_list_depth--; |
| 2117 | ol_txrx_err( |
Alok Kumar | bf47b99 | 2017-10-27 16:30:32 +0530 | [diff] [blame] | 2118 | "%d: %pK,verbose(%d), concise(%d), up_m(0x%x), reset_m(0x%x)\n", |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 2119 | i++, |
| 2120 | req, |
| 2121 | req->base.print.verbose, |
| 2122 | req->base.print.concise, |
| 2123 | req->base.stats_type_upload_mask, |
| 2124 | req->base.stats_type_reset_mask |
| 2125 | ); |
| 2126 | qdf_mem_free(req); |
| 2127 | } |
| 2128 | qdf_spin_unlock_bh(&pdev->req_list_spinlock); |
| 2129 | |
| 2130 | qdf_spinlock_destroy(&pdev->req_list_spinlock); |
| 2131 | |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2132 | OL_RX_REORDER_TIMEOUT_CLEANUP(pdev); |
| 2133 | |
| 2134 | if (pdev->cfg.is_high_latency) |
| 2135 | ol_tx_sched_detach(pdev); |
| 2136 | |
| 2137 | htt_deregister_rx_pkt_dump_callback(pdev->htt_pdev); |
| 2138 | |
| 2139 | htt_pdev_free(pdev->htt_pdev); |
| 2140 | ol_txrx_peer_find_detach(pdev); |
| 2141 | ol_txrx_tso_stats_deinit(pdev); |
| 2142 | |
| 2143 | ol_txrx_pdev_txq_log_destroy(pdev); |
| 2144 | ol_txrx_pdev_grp_stat_destroy(pdev); |
| 2145 | } |
| 2146 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2147 | #if defined(CONFIG_PER_VDEV_TX_DESC_POOL) |
| 2148 | |
| 2149 | /** |
| 2150 | * ol_txrx_vdev_tx_desc_cnt_init() - initialise tx descriptor count for vdev |
| 2151 | * @vdev: the virtual device object |
| 2152 | * |
| 2153 | * Return: None |
| 2154 | */ |
| 2155 | static inline void |
| 2156 | ol_txrx_vdev_tx_desc_cnt_init(struct ol_txrx_vdev_t *vdev) |
| 2157 | { |
| 2158 | qdf_atomic_init(&vdev->tx_desc_count); |
| 2159 | } |
| 2160 | #else |
| 2161 | |
| 2162 | static inline void |
| 2163 | ol_txrx_vdev_tx_desc_cnt_init(struct ol_txrx_vdev_t *vdev) |
| 2164 | { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2165 | } |
| 2166 | #endif |
| 2167 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 2168 | /** |
| 2169 | * ol_txrx_vdev_attach - Allocate and initialize the data object |
| 2170 | * for a new virtual device. |
| 2171 | * |
| 2172 | * @data_pdev - the physical device the virtual device belongs to |
| 2173 | * @vdev_mac_addr - the MAC address of the virtual device |
| 2174 | * @vdev_id - the ID used to identify the virtual device to the target |
| 2175 | * @op_mode - whether this virtual device is operating as an AP, |
| 2176 | * an IBSS, or a STA |
| 2177 | * |
| 2178 | * Return: success: handle to new data vdev object, failure: NULL |
| 2179 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2180 | static struct cdp_vdev * |
| 2181 | ol_txrx_vdev_attach(struct cdp_pdev *ppdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2182 | uint8_t *vdev_mac_addr, |
| 2183 | uint8_t vdev_id, enum wlan_op_mode op_mode) |
| 2184 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2185 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2186 | struct ol_txrx_vdev_t *vdev; |
Deepak Dhamdhere | 561cdb9 | 2016-09-02 20:12:58 -0700 | [diff] [blame] | 2187 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2188 | |
| 2189 | /* preconditions */ |
| 2190 | TXRX_ASSERT2(pdev); |
| 2191 | TXRX_ASSERT2(vdev_mac_addr); |
| 2192 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2193 | vdev = qdf_mem_malloc(sizeof(*vdev)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2194 | if (!vdev) |
| 2195 | return NULL; /* failure */ |
| 2196 | |
| 2197 | /* store provided params */ |
| 2198 | vdev->pdev = pdev; |
| 2199 | vdev->vdev_id = vdev_id; |
| 2200 | vdev->opmode = op_mode; |
| 2201 | |
| 2202 | vdev->delete.pending = 0; |
| 2203 | vdev->safemode = 0; |
| 2204 | vdev->drop_unenc = 1; |
| 2205 | vdev->num_filters = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 2206 | vdev->fwd_tx_packets = 0; |
| 2207 | vdev->fwd_rx_packets = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2208 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2209 | ol_txrx_vdev_tx_desc_cnt_init(vdev); |
| 2210 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2211 | qdf_mem_copy(&vdev->mac_addr.raw[0], vdev_mac_addr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2212 | OL_TXRX_MAC_ADDR_LEN); |
| 2213 | |
| 2214 | TAILQ_INIT(&vdev->peer_list); |
| 2215 | vdev->last_real_peer = NULL; |
| 2216 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2217 | ol_txrx_hl_tdls_flag_reset((struct cdp_vdev *)vdev, false); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2218 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2219 | #ifdef QCA_IBSS_SUPPORT |
| 2220 | vdev->ibss_peer_num = 0; |
| 2221 | vdev->ibss_peer_heart_beat_timer = 0; |
| 2222 | #endif |
| 2223 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2224 | ol_txrx_vdev_txqs_init(vdev); |
| 2225 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2226 | qdf_spinlock_create(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2227 | vdev->ll_pause.paused_reason = 0; |
| 2228 | vdev->ll_pause.txq.head = vdev->ll_pause.txq.tail = NULL; |
| 2229 | vdev->ll_pause.txq.depth = 0; |
wadesong | 5e2e801 | 2017-08-21 16:56:03 +0800 | [diff] [blame] | 2230 | qdf_atomic_init(&vdev->delete.detaching); |
Anurag Chouhan | 754fbd8 | 2016-02-19 17:00:08 +0530 | [diff] [blame] | 2231 | qdf_timer_init(pdev->osdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2232 | &vdev->ll_pause.timer, |
| 2233 | ol_tx_vdev_ll_pause_queue_send, vdev, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 2234 | QDF_TIMER_TYPE_SW); |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 2235 | qdf_atomic_init(&vdev->os_q_paused); |
| 2236 | qdf_atomic_set(&vdev->os_q_paused, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2237 | vdev->tx_fl_lwm = 0; |
| 2238 | vdev->tx_fl_hwm = 0; |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 2239 | vdev->rx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2240 | vdev->wait_on_peer_id = OL_TXRX_INVALID_LOCAL_PEER_ID; |
Abhishek Singh | 217d978 | 2017-04-28 23:49:11 +0530 | [diff] [blame] | 2241 | qdf_mem_zero(&vdev->last_peer_mac_addr, |
| 2242 | sizeof(union ol_txrx_align_mac_addr_t)); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2243 | qdf_spinlock_create(&vdev->flow_control_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2244 | vdev->osif_flow_control_cb = NULL; |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 2245 | vdev->osif_flow_control_is_pause = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2246 | vdev->osif_fc_ctx = NULL; |
| 2247 | |
| 2248 | /* Default MAX Q depth for every VDEV */ |
| 2249 | vdev->ll_pause.max_q_depth = |
| 2250 | ol_tx_cfg_max_tx_queue_depth_ll(vdev->pdev->ctrl_pdev); |
Deepak Dhamdhere | 561cdb9 | 2016-09-02 20:12:58 -0700 | [diff] [blame] | 2251 | qdf_status = qdf_event_create(&vdev->wait_delete_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2252 | /* add this vdev into the pdev's list */ |
| 2253 | TAILQ_INSERT_TAIL(&pdev->vdev_list, vdev, vdev_list_elem); |
| 2254 | |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 2255 | ol_txrx_dbg( |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 2256 | "Created vdev %pK (%02x:%02x:%02x:%02x:%02x:%02x)\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2257 | vdev, |
| 2258 | vdev->mac_addr.raw[0], vdev->mac_addr.raw[1], |
| 2259 | vdev->mac_addr.raw[2], vdev->mac_addr.raw[3], |
| 2260 | vdev->mac_addr.raw[4], vdev->mac_addr.raw[5]); |
| 2261 | |
| 2262 | /* |
| 2263 | * We've verified that htt_op_mode == wlan_op_mode, |
| 2264 | * so no translation is needed. |
| 2265 | */ |
| 2266 | htt_vdev_attach(pdev->htt_pdev, vdev_id, op_mode); |
| 2267 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2268 | return (struct cdp_vdev *)vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2269 | } |
| 2270 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 2271 | /** |
| 2272 | *ol_txrx_vdev_register - Link a vdev's data object with the |
| 2273 | * matching OS shim vdev object. |
| 2274 | * |
| 2275 | * @txrx_vdev: the virtual device's data object |
| 2276 | * @osif_vdev: the virtual device's OS shim object |
| 2277 | * @txrx_ops: (pointers to)functions used for tx and rx data xfer |
| 2278 | * |
| 2279 | * The data object for a virtual device is created by the |
| 2280 | * function ol_txrx_vdev_attach. However, rather than fully |
| 2281 | * linking the data vdev object with the vdev objects from the |
| 2282 | * other subsystems that the data vdev object interacts with, |
| 2283 | * the txrx_vdev_attach function focuses primarily on creating |
| 2284 | * the data vdev object. After the creation of both the data |
| 2285 | * vdev object and the OS shim vdev object, this |
| 2286 | * txrx_osif_vdev_attach function is used to connect the two |
| 2287 | * vdev objects, so the data SW can use the OS shim vdev handle |
| 2288 | * when passing rx data received by a vdev up to the OS shim. |
| 2289 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2290 | static void ol_txrx_vdev_register(struct cdp_vdev *pvdev, |
| 2291 | void *osif_vdev, |
| 2292 | struct ol_txrx_ops *txrx_ops) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2293 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2294 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 2295 | |
Dhanashri Atre | 41c0d28 | 2016-06-28 14:09:59 -0700 | [diff] [blame] | 2296 | if (qdf_unlikely(!vdev) || qdf_unlikely(!txrx_ops)) { |
| 2297 | qdf_print("%s: vdev/txrx_ops is NULL!\n", __func__); |
| 2298 | qdf_assert(0); |
| 2299 | return; |
| 2300 | } |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 2301 | |
Dhanashri Atre | 41c0d28 | 2016-06-28 14:09:59 -0700 | [diff] [blame] | 2302 | vdev->osif_dev = osif_vdev; |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 2303 | vdev->rx = txrx_ops->rx.rx; |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 2304 | txrx_ops->tx.tx = ol_tx_data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2305 | } |
| 2306 | |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 2307 | #ifdef currently_unused |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 2308 | /** |
| 2309 | * ol_txrx_set_curchan - Setup the current operating channel of |
| 2310 | * the device |
| 2311 | * @pdev - the data physical device object |
| 2312 | * @chan_mhz - the channel frequency (mhz) packets on |
| 2313 | * |
| 2314 | * Mainly used when populating monitor mode status that requires |
| 2315 | * the current operating channel |
| 2316 | * |
| 2317 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2318 | void ol_txrx_set_curchan(ol_txrx_pdev_handle pdev, uint32_t chan_mhz) |
| 2319 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2320 | } |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 2321 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2322 | |
| 2323 | void ol_txrx_set_safemode(ol_txrx_vdev_handle vdev, uint32_t val) |
| 2324 | { |
| 2325 | vdev->safemode = val; |
| 2326 | } |
| 2327 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 2328 | /** |
| 2329 | * ol_txrx_set_privacy_filters - set the privacy filter |
| 2330 | * @vdev - the data virtual device object |
| 2331 | * @filter - filters to be set |
| 2332 | * @num - the number of filters |
| 2333 | * |
| 2334 | * Rx related. Set the privacy filters. When rx packets, check |
| 2335 | * the ether type, filter type and packet type to decide whether |
| 2336 | * discard these packets. |
| 2337 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 2338 | static void |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2339 | ol_txrx_set_privacy_filters(ol_txrx_vdev_handle vdev, |
| 2340 | void *filters, uint32_t num) |
| 2341 | { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2342 | qdf_mem_copy(vdev->privacy_filters, filters, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2343 | num * sizeof(struct privacy_exemption)); |
| 2344 | vdev->num_filters = num; |
| 2345 | } |
| 2346 | |
| 2347 | void ol_txrx_set_drop_unenc(ol_txrx_vdev_handle vdev, uint32_t val) |
| 2348 | { |
| 2349 | vdev->drop_unenc = val; |
| 2350 | } |
| 2351 | |
gbian | 016a42e | 2017-03-01 18:49:11 +0800 | [diff] [blame] | 2352 | #if defined(CONFIG_HL_SUPPORT) |
| 2353 | |
| 2354 | static void |
| 2355 | ol_txrx_tx_desc_reset_vdev(ol_txrx_vdev_handle vdev) |
| 2356 | { |
| 2357 | struct ol_txrx_pdev_t *pdev = vdev->pdev; |
| 2358 | int i; |
| 2359 | struct ol_tx_desc_t *tx_desc; |
| 2360 | |
| 2361 | qdf_spin_lock_bh(&pdev->tx_mutex); |
| 2362 | for (i = 0; i < pdev->tx_desc.pool_size; i++) { |
| 2363 | tx_desc = ol_tx_desc_find(pdev, i); |
| 2364 | if (tx_desc->vdev == vdev) |
| 2365 | tx_desc->vdev = NULL; |
| 2366 | } |
| 2367 | qdf_spin_unlock_bh(&pdev->tx_mutex); |
| 2368 | } |
| 2369 | |
| 2370 | #else |
| 2371 | |
| 2372 | static void |
| 2373 | ol_txrx_tx_desc_reset_vdev(ol_txrx_vdev_handle vdev) |
| 2374 | { |
| 2375 | |
| 2376 | } |
| 2377 | |
| 2378 | #endif |
| 2379 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 2380 | /** |
| 2381 | * ol_txrx_vdev_detach - Deallocate the specified data virtual |
| 2382 | * device object. |
| 2383 | * @data_vdev: data object for the virtual device in question |
| 2384 | * @callback: function to call (if non-NULL) once the vdev has |
| 2385 | * been wholly deleted |
| 2386 | * @callback_context: context to provide in the callback |
| 2387 | * |
| 2388 | * All peers associated with the virtual device need to be deleted |
| 2389 | * (ol_txrx_peer_detach) before the virtual device itself is deleted. |
| 2390 | * However, for the peers to be fully deleted, the peer deletion has to |
| 2391 | * percolate through the target data FW and back up to the host data SW. |
| 2392 | * Thus, even though the host control SW may have issued a peer_detach |
| 2393 | * call for each of the vdev's peers, the peer objects may still be |
| 2394 | * allocated, pending removal of all references to them by the target FW. |
| 2395 | * In this case, though the vdev_detach function call will still return |
| 2396 | * immediately, the vdev itself won't actually be deleted, until the |
| 2397 | * deletions of all its peers complete. |
| 2398 | * The caller can provide a callback function pointer to be notified when |
| 2399 | * the vdev deletion actually happens - whether it's directly within the |
| 2400 | * vdev_detach call, or if it's deferred until all in-progress peer |
| 2401 | * deletions have completed. |
| 2402 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 2403 | static void |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2404 | ol_txrx_vdev_detach(struct cdp_vdev *pvdev, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2405 | ol_txrx_vdev_delete_cb callback, void *context) |
| 2406 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2407 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
wadesong | 5e2e801 | 2017-08-21 16:56:03 +0800 | [diff] [blame] | 2408 | struct ol_txrx_pdev_t *pdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2409 | |
| 2410 | /* preconditions */ |
| 2411 | TXRX_ASSERT2(vdev); |
wadesong | 5e2e801 | 2017-08-21 16:56:03 +0800 | [diff] [blame] | 2412 | pdev = vdev->pdev; |
| 2413 | |
| 2414 | /* prevent anyone from restarting the ll_pause timer again */ |
| 2415 | qdf_atomic_set(&vdev->delete.detaching, 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2416 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2417 | ol_txrx_vdev_tx_queue_free(vdev); |
| 2418 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2419 | qdf_spin_lock_bh(&vdev->ll_pause.mutex); |
Anurag Chouhan | 754fbd8 | 2016-02-19 17:00:08 +0530 | [diff] [blame] | 2420 | qdf_timer_stop(&vdev->ll_pause.timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2421 | vdev->ll_pause.is_q_timer_on = false; |
| 2422 | while (vdev->ll_pause.txq.head) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 2423 | qdf_nbuf_t next = qdf_nbuf_next(vdev->ll_pause.txq.head); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 2424 | |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 2425 | qdf_nbuf_set_next(vdev->ll_pause.txq.head, NULL); |
| 2426 | qdf_nbuf_unmap(pdev->osdev, vdev->ll_pause.txq.head, |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 2427 | QDF_DMA_TO_DEVICE); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 2428 | qdf_nbuf_tx_free(vdev->ll_pause.txq.head, QDF_NBUF_PKT_ERROR); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2429 | vdev->ll_pause.txq.head = next; |
| 2430 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2431 | qdf_spin_unlock_bh(&vdev->ll_pause.mutex); |
wadesong | 5e2e801 | 2017-08-21 16:56:03 +0800 | [diff] [blame] | 2432 | |
| 2433 | /* ll_pause timer should be deleted without any locks held, and |
| 2434 | * no timer function should be executed after this point because |
| 2435 | * qdf_timer_free is deleting the timer synchronously. |
| 2436 | */ |
| 2437 | qdf_timer_free(&vdev->ll_pause.timer); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2438 | qdf_spinlock_destroy(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2439 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2440 | qdf_spin_lock_bh(&vdev->flow_control_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2441 | vdev->osif_flow_control_cb = NULL; |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 2442 | vdev->osif_flow_control_is_pause = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2443 | vdev->osif_fc_ctx = NULL; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2444 | qdf_spin_unlock_bh(&vdev->flow_control_lock); |
| 2445 | qdf_spinlock_destroy(&vdev->flow_control_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2446 | |
| 2447 | /* remove the vdev from its parent pdev's list */ |
| 2448 | TAILQ_REMOVE(&pdev->vdev_list, vdev, vdev_list_elem); |
| 2449 | |
| 2450 | /* |
| 2451 | * Use peer_ref_mutex while accessing peer_list, in case |
| 2452 | * a peer is in the process of being removed from the list. |
| 2453 | */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2454 | qdf_spin_lock_bh(&pdev->peer_ref_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2455 | /* check that the vdev has no peers allocated */ |
| 2456 | if (!TAILQ_EMPTY(&vdev->peer_list)) { |
| 2457 | /* debug print - will be removed later */ |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 2458 | ol_txrx_dbg( |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 2459 | "%s: not deleting vdev object %pK (%02x:%02x:%02x:%02x:%02x:%02x) until deletion finishes for all its peers\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2460 | __func__, vdev, |
| 2461 | vdev->mac_addr.raw[0], vdev->mac_addr.raw[1], |
| 2462 | vdev->mac_addr.raw[2], vdev->mac_addr.raw[3], |
| 2463 | vdev->mac_addr.raw[4], vdev->mac_addr.raw[5]); |
| 2464 | /* indicate that the vdev needs to be deleted */ |
| 2465 | vdev->delete.pending = 1; |
| 2466 | vdev->delete.callback = callback; |
| 2467 | vdev->delete.context = context; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2468 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2469 | return; |
| 2470 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2471 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
Deepak Dhamdhere | 561cdb9 | 2016-09-02 20:12:58 -0700 | [diff] [blame] | 2472 | qdf_event_destroy(&vdev->wait_delete_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2473 | |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 2474 | ol_txrx_dbg( |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 2475 | "%s: deleting vdev obj %pK (%02x:%02x:%02x:%02x:%02x:%02x)\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2476 | __func__, vdev, |
| 2477 | vdev->mac_addr.raw[0], vdev->mac_addr.raw[1], |
| 2478 | vdev->mac_addr.raw[2], vdev->mac_addr.raw[3], |
| 2479 | vdev->mac_addr.raw[4], vdev->mac_addr.raw[5]); |
| 2480 | |
| 2481 | htt_vdev_detach(pdev->htt_pdev, vdev->vdev_id); |
| 2482 | |
| 2483 | /* |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 2484 | * The ol_tx_desc_free might access the invalid content of vdev referred |
| 2485 | * by tx desc, since this vdev might be detached in another thread |
| 2486 | * asynchronous. |
| 2487 | * |
| 2488 | * Go through tx desc pool to set corresponding tx desc's vdev to NULL |
| 2489 | * when detach this vdev, and add vdev checking in the ol_tx_desc_free |
| 2490 | * to avoid crash. |
| 2491 | * |
| 2492 | */ |
gbian | 016a42e | 2017-03-01 18:49:11 +0800 | [diff] [blame] | 2493 | ol_txrx_tx_desc_reset_vdev(vdev); |
| 2494 | |
| 2495 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2496 | * Doesn't matter if there are outstanding tx frames - |
| 2497 | * they will be freed once the target sends a tx completion |
| 2498 | * message for them. |
| 2499 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2500 | qdf_mem_free(vdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2501 | if (callback) |
| 2502 | callback(context); |
| 2503 | } |
| 2504 | |
| 2505 | /** |
| 2506 | * ol_txrx_flush_rx_frames() - flush cached rx frames |
| 2507 | * @peer: peer |
| 2508 | * @drop: set flag to drop frames |
| 2509 | * |
| 2510 | * Return: None |
| 2511 | */ |
| 2512 | void ol_txrx_flush_rx_frames(struct ol_txrx_peer_t *peer, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2513 | bool drop) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2514 | { |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 2515 | struct ol_txrx_cached_bufq_t *bufqi; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2516 | struct ol_rx_cached_buf *cache_buf; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2517 | QDF_STATUS ret; |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 2518 | ol_txrx_rx_fp data_rx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2519 | |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 2520 | if (qdf_atomic_inc_return(&peer->flush_in_progress) > 1) { |
| 2521 | qdf_atomic_dec(&peer->flush_in_progress); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2522 | return; |
| 2523 | } |
| 2524 | |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 2525 | qdf_assert(peer->vdev); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2526 | qdf_spin_lock_bh(&peer->peer_info_lock); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 2527 | bufqi = &peer->bufq_info; |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 2528 | |
Dhanashri Atre | 50141c5 | 2016-04-07 13:15:29 -0700 | [diff] [blame] | 2529 | if (peer->state >= OL_TXRX_PEER_STATE_CONN && peer->vdev->rx) |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 2530 | data_rx = peer->vdev->rx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2531 | else |
| 2532 | drop = true; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2533 | qdf_spin_unlock_bh(&peer->peer_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2534 | |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 2535 | qdf_spin_lock_bh(&bufqi->bufq_lock); |
| 2536 | cache_buf = list_entry((&bufqi->cached_bufq)->next, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2537 | typeof(*cache_buf), list); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 2538 | while (!list_empty(&bufqi->cached_bufq)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2539 | list_del(&cache_buf->list); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 2540 | bufqi->curr--; |
| 2541 | qdf_assert(bufqi->curr >= 0); |
| 2542 | qdf_spin_unlock_bh(&bufqi->bufq_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2543 | if (drop) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 2544 | qdf_nbuf_free(cache_buf->buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2545 | } else { |
| 2546 | /* Flush the cached frames to HDD */ |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 2547 | ret = data_rx(peer->vdev->osif_dev, cache_buf->buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 2548 | if (ret != QDF_STATUS_SUCCESS) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 2549 | qdf_nbuf_free(cache_buf->buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2550 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2551 | qdf_mem_free(cache_buf); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 2552 | qdf_spin_lock_bh(&bufqi->bufq_lock); |
| 2553 | cache_buf = list_entry((&bufqi->cached_bufq)->next, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2554 | typeof(*cache_buf), list); |
| 2555 | } |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 2556 | bufqi->qdepth_no_thresh = bufqi->curr; |
| 2557 | qdf_spin_unlock_bh(&bufqi->bufq_lock); |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 2558 | qdf_atomic_dec(&peer->flush_in_progress); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2559 | } |
| 2560 | |
Manikandan Mohan | 8b4e201 | 2017-03-22 11:15:55 -0700 | [diff] [blame] | 2561 | static void ol_txrx_flush_cache_rx_queue(void) |
Poddar, Siddarth | a78cac3 | 2016-12-29 20:08:34 +0530 | [diff] [blame] | 2562 | { |
| 2563 | uint8_t sta_id; |
| 2564 | struct ol_txrx_peer_t *peer; |
| 2565 | struct ol_txrx_pdev_t *pdev; |
| 2566 | |
| 2567 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 2568 | if (!pdev) |
| 2569 | return; |
| 2570 | |
| 2571 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2572 | peer = ol_txrx_peer_find_by_local_id((struct cdp_pdev *)pdev, |
| 2573 | sta_id); |
Poddar, Siddarth | a78cac3 | 2016-12-29 20:08:34 +0530 | [diff] [blame] | 2574 | if (!peer) |
| 2575 | continue; |
| 2576 | ol_txrx_flush_rx_frames(peer, 1); |
| 2577 | } |
| 2578 | } |
| 2579 | |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 2580 | /* Define short name to use in cds_trigger_recovery */ |
| 2581 | #define PEER_DEL_TIMEOUT QDF_PEER_DELETION_TIMEDOUT |
| 2582 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 2583 | /** |
Naveen Rawat | 17c42a8 | 2018-02-01 19:18:27 -0800 | [diff] [blame] | 2584 | * ol_txrx_dump_peer_access_list() - dump peer access list |
| 2585 | * @peer: peer handle |
| 2586 | * |
| 2587 | * This function will dump if any peer debug ids are still accessing peer |
| 2588 | * |
| 2589 | * Return: None |
| 2590 | */ |
| 2591 | static void ol_txrx_dump_peer_access_list(ol_txrx_peer_handle peer) |
| 2592 | { |
| 2593 | u32 i; |
| 2594 | u32 pending_ref; |
| 2595 | |
| 2596 | for (i = 0; i < PEER_DEBUG_ID_MAX; i++) { |
| 2597 | pending_ref = qdf_atomic_read(&peer->access_list[i]); |
| 2598 | if (pending_ref) |
| 2599 | ol_txrx_info_high("id %d pending refs %d", |
| 2600 | i, pending_ref); |
| 2601 | } |
| 2602 | } |
| 2603 | |
| 2604 | /** |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 2605 | * ol_txrx_peer_attach - Allocate and set up references for a |
| 2606 | * data peer object. |
| 2607 | * @data_pdev: data physical device object that will indirectly |
| 2608 | * own the data_peer object |
| 2609 | * @data_vdev - data virtual device object that will directly |
| 2610 | * own the data_peer object |
| 2611 | * @peer_mac_addr - MAC address of the new peer |
| 2612 | * |
| 2613 | * When an association with a peer starts, the host's control SW |
| 2614 | * uses this function to inform the host data SW. |
| 2615 | * The host data SW allocates its own peer object, and stores a |
| 2616 | * reference to the control peer object within the data peer object. |
| 2617 | * The host data SW also stores a reference to the virtual device |
| 2618 | * that the peer is associated with. This virtual device handle is |
| 2619 | * used when the data SW delivers rx data frames to the OS shim layer. |
| 2620 | * The host data SW returns a handle to the new peer data object, |
| 2621 | * so a reference within the control peer object can be set to the |
| 2622 | * data peer object. |
| 2623 | * |
| 2624 | * Return: handle to new data peer object, or NULL if the attach |
| 2625 | * fails |
| 2626 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 2627 | static void * |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2628 | ol_txrx_peer_attach(struct cdp_vdev *pvdev, uint8_t *peer_mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2629 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2630 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2631 | struct ol_txrx_peer_t *peer; |
| 2632 | struct ol_txrx_peer_t *temp_peer; |
| 2633 | uint8_t i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2634 | bool wait_on_deletion = false; |
| 2635 | unsigned long rc; |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 2636 | struct ol_txrx_pdev_t *pdev; |
Abhishek Singh | 217d978 | 2017-04-28 23:49:11 +0530 | [diff] [blame] | 2637 | bool cmp_wait_mac = false; |
| 2638 | uint8_t zero_mac_addr[QDF_MAC_ADDR_SIZE] = { 0, 0, 0, 0, 0, 0 }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2639 | |
| 2640 | /* preconditions */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2641 | TXRX_ASSERT2(vdev); |
| 2642 | TXRX_ASSERT2(peer_mac_addr); |
| 2643 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 2644 | pdev = vdev->pdev; |
| 2645 | TXRX_ASSERT2(pdev); |
| 2646 | |
Abhishek Singh | 217d978 | 2017-04-28 23:49:11 +0530 | [diff] [blame] | 2647 | if (qdf_mem_cmp(&zero_mac_addr, &vdev->last_peer_mac_addr, |
| 2648 | QDF_MAC_ADDR_SIZE)) |
| 2649 | cmp_wait_mac = true; |
| 2650 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2651 | qdf_spin_lock_bh(&pdev->peer_ref_mutex); |
Mohit Khanna | 8ee37c6 | 2017-08-07 17:15:20 -0700 | [diff] [blame] | 2652 | /* check for duplicate existing peer */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2653 | TAILQ_FOREACH(temp_peer, &vdev->peer_list, peer_list_elem) { |
| 2654 | if (!ol_txrx_peer_find_mac_addr_cmp(&temp_peer->mac_addr, |
| 2655 | (union ol_txrx_align_mac_addr_t *)peer_mac_addr)) { |
Kapil Gupta | 53d9b57 | 2017-06-28 17:53:25 +0530 | [diff] [blame] | 2656 | ol_txrx_info_high( |
Mohit Khanna | 8ee37c6 | 2017-08-07 17:15:20 -0700 | [diff] [blame] | 2657 | "vdev_id %d (%02x:%02x:%02x:%02x:%02x:%02x) already exists.\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2658 | vdev->vdev_id, |
| 2659 | peer_mac_addr[0], peer_mac_addr[1], |
| 2660 | peer_mac_addr[2], peer_mac_addr[3], |
| 2661 | peer_mac_addr[4], peer_mac_addr[5]); |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 2662 | if (qdf_atomic_read(&temp_peer->delete_in_progress)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2663 | vdev->wait_on_peer_id = temp_peer->local_id; |
Deepak Dhamdhere | 561cdb9 | 2016-09-02 20:12:58 -0700 | [diff] [blame] | 2664 | qdf_event_reset(&vdev->wait_delete_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2665 | wait_on_deletion = true; |
Abhishek Singh | 217d978 | 2017-04-28 23:49:11 +0530 | [diff] [blame] | 2666 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2667 | } else { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2668 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2669 | return NULL; |
| 2670 | } |
| 2671 | } |
Abhishek Singh | 217d978 | 2017-04-28 23:49:11 +0530 | [diff] [blame] | 2672 | if (cmp_wait_mac && !ol_txrx_peer_find_mac_addr_cmp( |
| 2673 | &temp_peer->mac_addr, |
| 2674 | &vdev->last_peer_mac_addr)) { |
Kapil Gupta | 53d9b57 | 2017-06-28 17:53:25 +0530 | [diff] [blame] | 2675 | ol_txrx_info_high( |
Mohit Khanna | 8ee37c6 | 2017-08-07 17:15:20 -0700 | [diff] [blame] | 2676 | "vdev_id %d (%02x:%02x:%02x:%02x:%02x:%02x) old peer exists.\n", |
Abhishek Singh | 217d978 | 2017-04-28 23:49:11 +0530 | [diff] [blame] | 2677 | vdev->vdev_id, |
| 2678 | vdev->last_peer_mac_addr.raw[0], |
| 2679 | vdev->last_peer_mac_addr.raw[1], |
| 2680 | vdev->last_peer_mac_addr.raw[2], |
| 2681 | vdev->last_peer_mac_addr.raw[3], |
| 2682 | vdev->last_peer_mac_addr.raw[4], |
| 2683 | vdev->last_peer_mac_addr.raw[5]); |
| 2684 | if (qdf_atomic_read(&temp_peer->delete_in_progress)) { |
| 2685 | vdev->wait_on_peer_id = temp_peer->local_id; |
| 2686 | qdf_event_reset(&vdev->wait_delete_comp); |
| 2687 | wait_on_deletion = true; |
| 2688 | break; |
| 2689 | } else { |
| 2690 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
| 2691 | ol_txrx_err("peer not found"); |
| 2692 | return NULL; |
| 2693 | } |
| 2694 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2695 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2696 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2697 | |
Abhishek Singh | 217d978 | 2017-04-28 23:49:11 +0530 | [diff] [blame] | 2698 | qdf_mem_zero(&vdev->last_peer_mac_addr, |
| 2699 | sizeof(union ol_txrx_align_mac_addr_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2700 | if (wait_on_deletion) { |
| 2701 | /* wait for peer deletion */ |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 2702 | rc = qdf_wait_for_event_completion(&vdev->wait_delete_comp, |
Prakash Manjunathappa | d3ccca2 | 2016-05-05 19:23:19 -0700 | [diff] [blame] | 2703 | PEER_DELETION_TIMEOUT); |
Deepak Dhamdhere | 561cdb9 | 2016-09-02 20:12:58 -0700 | [diff] [blame] | 2704 | if (QDF_STATUS_SUCCESS != rc) { |
Mohit Khanna | 8ee37c6 | 2017-08-07 17:15:20 -0700 | [diff] [blame] | 2705 | ol_txrx_err("error waiting for peer_id(%d) deletion, status %d\n", |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 2706 | vdev->wait_on_peer_id, (int) rc); |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 2707 | /* Added for debugging only */ |
Naveen Rawat | 17c42a8 | 2018-02-01 19:18:27 -0800 | [diff] [blame] | 2708 | ol_txrx_dump_peer_access_list(temp_peer); |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 2709 | wlan_roam_debug_dump_table(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2710 | vdev->wait_on_peer_id = OL_TXRX_INVALID_LOCAL_PEER_ID; |
Dustin Brown | 100201e | 2017-07-10 11:48:40 -0700 | [diff] [blame] | 2711 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2712 | return NULL; |
| 2713 | } |
| 2714 | } |
| 2715 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2716 | peer = qdf_mem_malloc(sizeof(*peer)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2717 | if (!peer) |
| 2718 | return NULL; /* failure */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2719 | |
| 2720 | /* store provided params */ |
| 2721 | peer->vdev = vdev; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 2722 | qdf_mem_copy(&peer->mac_addr.raw[0], peer_mac_addr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2723 | OL_TXRX_MAC_ADDR_LEN); |
| 2724 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 2725 | ol_txrx_peer_txqs_init(pdev, peer); |
| 2726 | |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 2727 | INIT_LIST_HEAD(&peer->bufq_info.cached_bufq); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2728 | qdf_spin_lock_bh(&pdev->peer_ref_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2729 | /* add this peer into the vdev's list */ |
| 2730 | TAILQ_INSERT_TAIL(&vdev->peer_list, peer, peer_list_elem); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2731 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2732 | /* check whether this is a real peer (peer mac addr != vdev mac addr) */ |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 2733 | if (ol_txrx_peer_find_mac_addr_cmp(&vdev->mac_addr, &peer->mac_addr)) { |
| 2734 | qdf_spin_lock_bh(&pdev->last_real_peer_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2735 | vdev->last_real_peer = peer; |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 2736 | qdf_spin_unlock_bh(&pdev->last_real_peer_mutex); |
| 2737 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2738 | |
| 2739 | peer->rx_opt_proc = pdev->rx_opt_proc; |
| 2740 | |
| 2741 | ol_rx_peer_init(pdev, peer); |
| 2742 | |
| 2743 | /* initialize the peer_id */ |
| 2744 | for (i = 0; i < MAX_NUM_PEER_ID_PER_PEER; i++) |
| 2745 | peer->peer_ids[i] = HTT_INVALID_PEER; |
| 2746 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 2747 | qdf_spinlock_create(&peer->peer_info_lock); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 2748 | qdf_spinlock_create(&peer->bufq_info.bufq_lock); |
| 2749 | |
| 2750 | peer->bufq_info.thresh = OL_TXRX_CACHED_BUFQ_THRESH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2751 | |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 2752 | qdf_atomic_init(&peer->delete_in_progress); |
| 2753 | qdf_atomic_init(&peer->flush_in_progress); |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 2754 | qdf_atomic_init(&peer->ref_cnt); |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 2755 | |
| 2756 | for (i = 0; i < PEER_DEBUG_ID_MAX; i++) |
| 2757 | qdf_atomic_init(&peer->access_list[i]); |
| 2758 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2759 | /* keep one reference for attach */ |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 2760 | ol_txrx_peer_get_ref(peer, PEER_DEBUG_ID_OL_INTERNAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2761 | |
Mohit Khanna | 8ee37c6 | 2017-08-07 17:15:20 -0700 | [diff] [blame] | 2762 | /* Set a flag to indicate peer create is pending in firmware */ |
Prakash Dhavali | 0d3f1d6 | 2016-11-20 23:48:24 -0800 | [diff] [blame] | 2763 | qdf_atomic_init(&peer->fw_create_pending); |
| 2764 | qdf_atomic_set(&peer->fw_create_pending, 1); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2765 | |
| 2766 | peer->valid = 1; |
Deepak Dhamdhere | 2b283c6 | 2017-03-30 17:51:53 -0700 | [diff] [blame] | 2767 | qdf_timer_init(pdev->osdev, &peer->peer_unmap_timer, |
| 2768 | peer_unmap_timer_handler, peer, QDF_TIMER_TYPE_SW); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2769 | |
| 2770 | ol_txrx_peer_find_hash_add(pdev, peer); |
| 2771 | |
Mohit Khanna | 47384bc | 2016-08-15 15:37:05 -0700 | [diff] [blame] | 2772 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH, |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 2773 | "vdev %pK created peer %pK ref_cnt %d (%02x:%02x:%02x:%02x:%02x:%02x)\n", |
Mohit Khanna | 47384bc | 2016-08-15 15:37:05 -0700 | [diff] [blame] | 2774 | vdev, peer, qdf_atomic_read(&peer->ref_cnt), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2775 | peer->mac_addr.raw[0], peer->mac_addr.raw[1], |
| 2776 | peer->mac_addr.raw[2], peer->mac_addr.raw[3], |
| 2777 | peer->mac_addr.raw[4], peer->mac_addr.raw[5]); |
| 2778 | /* |
| 2779 | * For every peer MAp message search and set if bss_peer |
| 2780 | */ |
Ankit Gupta | a507601 | 2016-09-14 11:32:19 -0700 | [diff] [blame] | 2781 | if (qdf_mem_cmp(peer->mac_addr.raw, vdev->mac_addr.raw, |
| 2782 | OL_TXRX_MAC_ADDR_LEN)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2783 | peer->bss_peer = 1; |
| 2784 | |
| 2785 | /* |
| 2786 | * The peer starts in the "disc" state while association is in progress. |
| 2787 | * Once association completes, the peer will get updated to "auth" state |
| 2788 | * by a call to ol_txrx_peer_state_update if the peer is in open mode, |
| 2789 | * or else to the "conn" state. For non-open mode, the peer will |
| 2790 | * progress to "auth" state once the authentication completes. |
| 2791 | */ |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 2792 | peer->state = OL_TXRX_PEER_STATE_INVALID; |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2793 | ol_txrx_peer_state_update((struct cdp_pdev *)pdev, peer->mac_addr.raw, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 2794 | OL_TXRX_PEER_STATE_DISC); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2795 | |
| 2796 | #ifdef QCA_SUPPORT_PEER_DATA_RX_RSSI |
| 2797 | peer->rssi_dbm = HTT_RSSI_INVALID; |
| 2798 | #endif |
Manjunathappa Prakash | b757372 | 2016-04-21 11:24:07 -0700 | [diff] [blame] | 2799 | if ((QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) && |
| 2800 | !pdev->self_peer) { |
| 2801 | pdev->self_peer = peer; |
| 2802 | /* |
| 2803 | * No Tx in monitor mode, otherwise results in target assert. |
| 2804 | * Setting disable_intrabss_fwd to true |
| 2805 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2806 | ol_vdev_rx_set_intrabss_fwd((struct cdp_vdev *)vdev, true); |
Manjunathappa Prakash | b757372 | 2016-04-21 11:24:07 -0700 | [diff] [blame] | 2807 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2808 | |
| 2809 | ol_txrx_local_peer_id_alloc(pdev, peer); |
| 2810 | |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 2811 | return (void *)peer; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2812 | } |
| 2813 | |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 2814 | #undef PEER_DEL_TIMEOUT |
| 2815 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2816 | /* |
| 2817 | * Discarding tx filter - removes all data frames (disconnected state) |
| 2818 | */ |
| 2819 | static A_STATUS ol_tx_filter_discard(struct ol_txrx_msdu_info_t *tx_msdu_info) |
| 2820 | { |
| 2821 | return A_ERROR; |
| 2822 | } |
| 2823 | |
| 2824 | /* |
| 2825 | * Non-autentication tx filter - filters out data frames that are not |
| 2826 | * related to authentication, but allows EAPOL (PAE) or WAPI (WAI) |
| 2827 | * data frames (connected state) |
| 2828 | */ |
| 2829 | static A_STATUS ol_tx_filter_non_auth(struct ol_txrx_msdu_info_t *tx_msdu_info) |
| 2830 | { |
| 2831 | return |
| 2832 | (tx_msdu_info->htt.info.ethertype == ETHERTYPE_PAE || |
| 2833 | tx_msdu_info->htt.info.ethertype == |
| 2834 | ETHERTYPE_WAI) ? A_OK : A_ERROR; |
| 2835 | } |
| 2836 | |
| 2837 | /* |
| 2838 | * Pass-through tx filter - lets all data frames through (authenticated state) |
| 2839 | */ |
| 2840 | static A_STATUS ol_tx_filter_pass_thru(struct ol_txrx_msdu_info_t *tx_msdu_info) |
| 2841 | { |
| 2842 | return A_OK; |
| 2843 | } |
| 2844 | |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2845 | /** |
| 2846 | * ol_txrx_peer_get_peer_mac_addr() - return mac_addr from peer handle. |
| 2847 | * @peer: handle to peer |
| 2848 | * |
| 2849 | * returns mac addrs for module which do not know peer type |
| 2850 | * |
| 2851 | * Return: the mac_addr from peer |
| 2852 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 2853 | static uint8_t * |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 2854 | ol_txrx_peer_get_peer_mac_addr(void *ppeer) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2855 | { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 2856 | ol_txrx_peer_handle peer = ppeer; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 2857 | |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2858 | if (!peer) |
| 2859 | return NULL; |
| 2860 | |
| 2861 | return peer->mac_addr.raw; |
| 2862 | } |
| 2863 | |
Abhishek Singh | cfb4448 | 2017-03-10 12:42:37 +0530 | [diff] [blame] | 2864 | #ifdef WLAN_FEATURE_11W |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2865 | /** |
| 2866 | * ol_txrx_get_pn_info() - Returns pn info from peer |
| 2867 | * @peer: handle to peer |
| 2868 | * @last_pn_valid: return last_rmf_pn_valid value from peer. |
| 2869 | * @last_pn: return last_rmf_pn value from peer. |
| 2870 | * @rmf_pn_replays: return rmf_pn_replays value from peer. |
| 2871 | * |
| 2872 | * Return: NONE |
| 2873 | */ |
| 2874 | void |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 2875 | ol_txrx_get_pn_info(void *ppeer, uint8_t **last_pn_valid, |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2876 | uint64_t **last_pn, uint32_t **rmf_pn_replays) |
| 2877 | { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 2878 | ol_txrx_peer_handle peer = ppeer; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2879 | *last_pn_valid = &peer->last_rmf_pn_valid; |
| 2880 | *last_pn = &peer->last_rmf_pn; |
| 2881 | *rmf_pn_replays = &peer->rmf_pn_replays; |
| 2882 | } |
Abhishek Singh | cfb4448 | 2017-03-10 12:42:37 +0530 | [diff] [blame] | 2883 | #else |
| 2884 | void |
| 2885 | ol_txrx_get_pn_info(void *ppeer, uint8_t **last_pn_valid, |
| 2886 | uint64_t **last_pn, uint32_t **rmf_pn_replays) |
| 2887 | { |
| 2888 | } |
| 2889 | #endif |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2890 | |
| 2891 | /** |
| 2892 | * ol_txrx_get_opmode() - Return operation mode of vdev |
| 2893 | * @vdev: vdev handle |
| 2894 | * |
| 2895 | * Return: operation mode. |
| 2896 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2897 | static int ol_txrx_get_opmode(struct cdp_vdev *pvdev) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2898 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2899 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 2900 | |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2901 | return vdev->opmode; |
| 2902 | } |
| 2903 | |
| 2904 | /** |
| 2905 | * ol_txrx_get_peer_state() - Return peer state of peer |
| 2906 | * @peer: peer handle |
| 2907 | * |
| 2908 | * Return: return peer state |
| 2909 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 2910 | static int ol_txrx_get_peer_state(void *ppeer) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2911 | { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 2912 | ol_txrx_peer_handle peer = ppeer; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 2913 | |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2914 | return peer->state; |
| 2915 | } |
| 2916 | |
| 2917 | /** |
| 2918 | * ol_txrx_get_vdev_for_peer() - Return vdev from peer handle |
| 2919 | * @peer: peer handle |
| 2920 | * |
| 2921 | * Return: vdev handle from peer |
| 2922 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2923 | static struct cdp_vdev *ol_txrx_get_vdev_for_peer(void *ppeer) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2924 | { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 2925 | ol_txrx_peer_handle peer = ppeer; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 2926 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2927 | return (struct cdp_vdev *)peer->vdev; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2928 | } |
| 2929 | |
| 2930 | /** |
| 2931 | * ol_txrx_get_vdev_mac_addr() - Return mac addr of vdev |
| 2932 | * @vdev: vdev handle |
| 2933 | * |
| 2934 | * Return: vdev mac address |
| 2935 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 2936 | static uint8_t * |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2937 | ol_txrx_get_vdev_mac_addr(struct cdp_vdev *pvdev) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2938 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2939 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 2940 | |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2941 | if (!vdev) |
| 2942 | return NULL; |
| 2943 | |
| 2944 | return vdev->mac_addr.raw; |
| 2945 | } |
| 2946 | |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 2947 | #ifdef currently_unused |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2948 | /** |
Manjunathappa Prakash | 2593a64 | 2016-04-01 08:53:35 -0700 | [diff] [blame] | 2949 | * ol_txrx_get_vdev_struct_mac_addr() - Return handle to struct qdf_mac_addr of |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2950 | * vdev |
| 2951 | * @vdev: vdev handle |
| 2952 | * |
Manjunathappa Prakash | 2593a64 | 2016-04-01 08:53:35 -0700 | [diff] [blame] | 2953 | * Return: Handle to struct qdf_mac_addr |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2954 | */ |
Manjunathappa Prakash | 2593a64 | 2016-04-01 08:53:35 -0700 | [diff] [blame] | 2955 | struct qdf_mac_addr * |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2956 | ol_txrx_get_vdev_struct_mac_addr(ol_txrx_vdev_handle vdev) |
| 2957 | { |
Manjunathappa Prakash | 2593a64 | 2016-04-01 08:53:35 -0700 | [diff] [blame] | 2958 | return (struct qdf_mac_addr *)&(vdev->mac_addr); |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2959 | } |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 2960 | #endif |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2961 | |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 2962 | #ifdef currently_unused |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2963 | /** |
| 2964 | * ol_txrx_get_pdev_from_vdev() - Return handle to pdev of vdev |
| 2965 | * @vdev: vdev handle |
| 2966 | * |
| 2967 | * Return: Handle to pdev |
| 2968 | */ |
| 2969 | ol_txrx_pdev_handle ol_txrx_get_pdev_from_vdev(ol_txrx_vdev_handle vdev) |
| 2970 | { |
| 2971 | return vdev->pdev; |
| 2972 | } |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 2973 | #endif |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2974 | |
| 2975 | /** |
| 2976 | * ol_txrx_get_ctrl_pdev_from_vdev() - Return control pdev of vdev |
| 2977 | * @vdev: vdev handle |
| 2978 | * |
| 2979 | * Return: Handle to control pdev |
| 2980 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2981 | static struct cdp_cfg * |
| 2982 | ol_txrx_get_ctrl_pdev_from_vdev(struct cdp_vdev *pvdev) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2983 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2984 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 2985 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2986 | return vdev->pdev->ctrl_pdev; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2987 | } |
| 2988 | |
| 2989 | /** |
| 2990 | * ol_txrx_is_rx_fwd_disabled() - returns the rx_fwd_disabled status on vdev |
| 2991 | * @vdev: vdev handle |
| 2992 | * |
| 2993 | * Return: Rx Fwd disabled status |
| 2994 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 2995 | static uint8_t |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2996 | ol_txrx_is_rx_fwd_disabled(struct cdp_vdev *pvdev) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2997 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 2998 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 2999 | struct txrx_pdev_cfg_t *cfg = (struct txrx_pdev_cfg_t *) |
| 3000 | vdev->pdev->ctrl_pdev; |
| 3001 | return cfg->rx_fwd_disabled; |
| 3002 | } |
| 3003 | |
Mahesh Kumar Kalikot Veetil | 32e4fc7 | 2016-09-09 17:05:22 -0700 | [diff] [blame] | 3004 | #ifdef QCA_IBSS_SUPPORT |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3005 | /** |
| 3006 | * ol_txrx_update_ibss_add_peer_num_of_vdev() - update and return peer num |
| 3007 | * @vdev: vdev handle |
| 3008 | * @peer_num_delta: peer nums to be adjusted |
| 3009 | * |
| 3010 | * Return: -1 for failure or total peer nums after adjustment. |
| 3011 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 3012 | static int16_t |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3013 | ol_txrx_update_ibss_add_peer_num_of_vdev(struct cdp_vdev *pvdev, |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3014 | int16_t peer_num_delta) |
| 3015 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3016 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3017 | int16_t new_peer_num; |
| 3018 | |
| 3019 | new_peer_num = vdev->ibss_peer_num + peer_num_delta; |
Naveen Rawat | c45d162 | 2016-07-05 12:20:09 -0700 | [diff] [blame] | 3020 | if (new_peer_num > MAX_PEERS || new_peer_num < 0) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3021 | return OL_TXRX_INVALID_NUM_PEERS; |
| 3022 | |
| 3023 | vdev->ibss_peer_num = new_peer_num; |
| 3024 | |
| 3025 | return new_peer_num; |
| 3026 | } |
| 3027 | |
| 3028 | /** |
| 3029 | * ol_txrx_set_ibss_vdev_heart_beat_timer() - Update ibss vdev heart |
| 3030 | * beat timer |
| 3031 | * @vdev: vdev handle |
| 3032 | * @timer_value_sec: new heart beat timer value |
| 3033 | * |
| 3034 | * Return: Old timer value set in vdev. |
| 3035 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3036 | static uint16_t ol_txrx_set_ibss_vdev_heart_beat_timer(struct cdp_vdev *pvdev, |
| 3037 | uint16_t timer_value_sec) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3038 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3039 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3040 | uint16_t old_timer_value = vdev->ibss_peer_heart_beat_timer; |
| 3041 | |
| 3042 | vdev->ibss_peer_heart_beat_timer = timer_value_sec; |
| 3043 | |
| 3044 | return old_timer_value; |
| 3045 | } |
Mahesh Kumar Kalikot Veetil | 32e4fc7 | 2016-09-09 17:05:22 -0700 | [diff] [blame] | 3046 | #endif |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3047 | |
| 3048 | /** |
| 3049 | * ol_txrx_remove_peers_for_vdev() - remove all vdev peers with lock held |
| 3050 | * @vdev: vdev handle |
| 3051 | * @callback: callback function to remove the peer. |
| 3052 | * @callback_context: handle for callback function |
| 3053 | * @remove_last_peer: Does it required to last peer. |
| 3054 | * |
| 3055 | * Return: NONE |
| 3056 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 3057 | static void |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3058 | ol_txrx_remove_peers_for_vdev(struct cdp_vdev *pvdev, |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3059 | ol_txrx_vdev_peer_remove_cb callback, |
| 3060 | void *callback_context, bool remove_last_peer) |
| 3061 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3062 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3063 | ol_txrx_peer_handle peer, temp; |
Orhan K AKYILDIZ | ecf401c | 2017-04-28 14:10:27 -0700 | [diff] [blame] | 3064 | int self_removed = 0; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3065 | /* remove all remote peers for vdev */ |
Manjunathappa Prakash | 2593a64 | 2016-04-01 08:53:35 -0700 | [diff] [blame] | 3066 | qdf_spin_lock_bh(&vdev->pdev->peer_ref_mutex); |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3067 | |
| 3068 | temp = NULL; |
| 3069 | TAILQ_FOREACH_REVERSE(peer, &vdev->peer_list, peer_list_t, |
| 3070 | peer_list_elem) { |
Poddar, Siddarth | 3f97e3d | 2017-12-18 15:11:13 +0530 | [diff] [blame] | 3071 | if (qdf_atomic_read(&peer->delete_in_progress)) |
| 3072 | continue; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3073 | if (temp) { |
Manjunathappa Prakash | 2593a64 | 2016-04-01 08:53:35 -0700 | [diff] [blame] | 3074 | qdf_spin_unlock_bh(&vdev->pdev->peer_ref_mutex); |
Poddar, Siddarth | 3f97e3d | 2017-12-18 15:11:13 +0530 | [diff] [blame] | 3075 | callback(callback_context, temp->mac_addr.raw, |
Jiachao Wu | 641760e | 2018-01-21 12:11:31 +0800 | [diff] [blame] | 3076 | vdev->vdev_id, temp); |
Manjunathappa Prakash | 2593a64 | 2016-04-01 08:53:35 -0700 | [diff] [blame] | 3077 | qdf_spin_lock_bh(&vdev->pdev->peer_ref_mutex); |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3078 | } |
| 3079 | /* self peer is deleted last */ |
| 3080 | if (peer == TAILQ_FIRST(&vdev->peer_list)) { |
Orhan K AKYILDIZ | ecf401c | 2017-04-28 14:10:27 -0700 | [diff] [blame] | 3081 | self_removed = 1; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3082 | break; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 3083 | } |
| 3084 | temp = peer; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3085 | } |
| 3086 | |
Mohit Khanna | 137b97d | 2016-04-21 16:11:33 -0700 | [diff] [blame] | 3087 | qdf_spin_unlock_bh(&vdev->pdev->peer_ref_mutex); |
| 3088 | |
Orhan K AKYILDIZ | ecf401c | 2017-04-28 14:10:27 -0700 | [diff] [blame] | 3089 | if (self_removed) |
| 3090 | ol_txrx_info("%s: self peer removed by caller ", |
| 3091 | __func__); |
| 3092 | |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3093 | if (remove_last_peer) { |
| 3094 | /* remove IBSS bss peer last */ |
| 3095 | peer = TAILQ_FIRST(&vdev->peer_list); |
| 3096 | callback(callback_context, (uint8_t *) &vdev->mac_addr, |
Jiachao Wu | 641760e | 2018-01-21 12:11:31 +0800 | [diff] [blame] | 3097 | vdev->vdev_id, peer); |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3098 | } |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3099 | } |
| 3100 | |
| 3101 | /** |
| 3102 | * ol_txrx_remove_peers_for_vdev_no_lock() - remove vdev peers with no lock. |
| 3103 | * @vdev: vdev handle |
| 3104 | * @callback: callback function to remove the peer. |
| 3105 | * @callback_context: handle for callback function |
| 3106 | * |
| 3107 | * Return: NONE |
| 3108 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 3109 | static void |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3110 | ol_txrx_remove_peers_for_vdev_no_lock(struct cdp_vdev *pvdev, |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3111 | ol_txrx_vdev_peer_remove_cb callback, |
| 3112 | void *callback_context) |
| 3113 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3114 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3115 | ol_txrx_peer_handle peer = NULL; |
Jiachao Wu | 641760e | 2018-01-21 12:11:31 +0800 | [diff] [blame] | 3116 | ol_txrx_peer_handle tmp_peer = NULL; |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3117 | |
Jiachao Wu | 641760e | 2018-01-21 12:11:31 +0800 | [diff] [blame] | 3118 | TAILQ_FOREACH_SAFE(peer, &vdev->peer_list, peer_list_elem, tmp_peer) { |
Kapil Gupta | 53d9b57 | 2017-06-28 17:53:25 +0530 | [diff] [blame] | 3119 | ol_txrx_info_high( |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3120 | "%s: peer found for vdev id %d. deleting the peer", |
| 3121 | __func__, vdev->vdev_id); |
| 3122 | callback(callback_context, (uint8_t *)&vdev->mac_addr, |
Jiachao Wu | 641760e | 2018-01-21 12:11:31 +0800 | [diff] [blame] | 3123 | vdev->vdev_id, peer); |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3124 | } |
| 3125 | } |
| 3126 | |
| 3127 | /** |
| 3128 | * ol_txrx_set_ocb_chan_info() - set OCB channel info to vdev. |
| 3129 | * @vdev: vdev handle |
| 3130 | * @ocb_set_chan: OCB channel information to be set in vdev. |
| 3131 | * |
| 3132 | * Return: NONE |
| 3133 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3134 | static void ol_txrx_set_ocb_chan_info(struct cdp_vdev *pvdev, |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3135 | struct ol_txrx_ocb_set_chan ocb_set_chan) |
| 3136 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3137 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 3138 | |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3139 | vdev->ocb_channel_info = ocb_set_chan.ocb_channel_info; |
| 3140 | vdev->ocb_channel_count = ocb_set_chan.ocb_channel_count; |
| 3141 | } |
| 3142 | |
| 3143 | /** |
| 3144 | * ol_txrx_get_ocb_chan_info() - return handle to vdev ocb_channel_info |
| 3145 | * @vdev: vdev handle |
| 3146 | * |
| 3147 | * Return: handle to struct ol_txrx_ocb_chan_info |
| 3148 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 3149 | static struct ol_txrx_ocb_chan_info * |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3150 | ol_txrx_get_ocb_chan_info(struct cdp_vdev *pvdev) |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3151 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3152 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 3153 | |
Manjunathappa Prakash | 10d357a | 2016-03-31 19:20:49 -0700 | [diff] [blame] | 3154 | return vdev->ocb_channel_info; |
| 3155 | } |
| 3156 | |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 3157 | /** |
| 3158 | * @brief specify the peer's authentication state |
| 3159 | * @details |
| 3160 | * Specify the peer's authentication state (none, connected, authenticated) |
| 3161 | * to allow the data SW to determine whether to filter out invalid data frames. |
| 3162 | * (In the "connected" state, where security is enabled, but authentication |
| 3163 | * has not completed, tx and rx data frames other than EAPOL or WAPI should |
| 3164 | * be discarded.) |
| 3165 | * This function is only relevant for systems in which the tx and rx filtering |
| 3166 | * are done in the host rather than in the target. |
| 3167 | * |
| 3168 | * @param data_peer - which peer has changed its state |
| 3169 | * @param state - the new state of the peer |
| 3170 | * |
Manjunathappa Prakash | 2593a64 | 2016-04-01 08:53:35 -0700 | [diff] [blame] | 3171 | * Return: QDF Status |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 3172 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3173 | QDF_STATUS ol_txrx_peer_state_update(struct cdp_pdev *ppdev, |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 3174 | uint8_t *peer_mac, |
| 3175 | enum ol_txrx_peer_state state) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3176 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3177 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3178 | struct ol_txrx_peer_t *peer; |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3179 | int peer_ref_cnt; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3180 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3181 | if (qdf_unlikely(!pdev)) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3182 | ol_txrx_err("Pdev is NULL"); |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 3183 | qdf_assert(0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3184 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3185 | } |
| 3186 | |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3187 | peer = ol_txrx_peer_find_hash_find_get_ref(pdev, peer_mac, 0, 1, |
| 3188 | PEER_DEBUG_ID_OL_INTERNAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3189 | if (NULL == peer) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3190 | ol_txrx_err( |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 3191 | "%s: peer is null for peer_mac 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x\n", |
| 3192 | __func__, |
| 3193 | peer_mac[0], peer_mac[1], peer_mac[2], peer_mac[3], |
| 3194 | peer_mac[4], peer_mac[5]); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3195 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3196 | } |
| 3197 | |
| 3198 | /* TODO: Should we send WMI command of the connection state? */ |
| 3199 | /* avoid multiple auth state change. */ |
| 3200 | if (peer->state == state) { |
| 3201 | #ifdef TXRX_PRINT_VERBOSE_ENABLE |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3202 | ol_txrx_dbg( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3203 | "%s: no state change, returns directly\n", |
| 3204 | __func__); |
| 3205 | #endif |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3206 | peer_ref_cnt = ol_txrx_peer_release_ref |
| 3207 | (peer, |
| 3208 | PEER_DEBUG_ID_OL_INTERNAL); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3209 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3210 | } |
| 3211 | |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3212 | ol_txrx_dbg("%s: change from %d to %d\n", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3213 | __func__, peer->state, state); |
| 3214 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 3215 | peer->tx_filter = (state == OL_TXRX_PEER_STATE_AUTH) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3216 | ? ol_tx_filter_pass_thru |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 3217 | : ((state == OL_TXRX_PEER_STATE_CONN) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3218 | ? ol_tx_filter_non_auth |
| 3219 | : ol_tx_filter_discard); |
| 3220 | |
| 3221 | if (peer->vdev->pdev->cfg.host_addba) { |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 3222 | if (state == OL_TXRX_PEER_STATE_AUTH) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3223 | int tid; |
| 3224 | /* |
| 3225 | * Pause all regular (non-extended) TID tx queues until |
| 3226 | * data arrives and ADDBA negotiation has completed. |
| 3227 | */ |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3228 | ol_txrx_dbg( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3229 | "%s: pause peer and unpause mgmt/non-qos\n", |
| 3230 | __func__); |
| 3231 | ol_txrx_peer_pause(peer); /* pause all tx queues */ |
| 3232 | /* unpause mgmt and non-QoS tx queues */ |
| 3233 | for (tid = OL_TX_NUM_QOS_TIDS; |
| 3234 | tid < OL_TX_NUM_TIDS; tid++) |
| 3235 | ol_txrx_peer_tid_unpause(peer, tid); |
| 3236 | } |
| 3237 | } |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3238 | peer_ref_cnt = ol_txrx_peer_release_ref(peer, |
| 3239 | PEER_DEBUG_ID_OL_INTERNAL); |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3240 | /* |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3241 | * after ol_txrx_peer_release_ref, peer object cannot be accessed |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3242 | * if the return code was 0 |
| 3243 | */ |
Mohit Khanna | b04dfcd | 2017-02-13 18:54:35 -0800 | [diff] [blame] | 3244 | if (peer_ref_cnt > 0) |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3245 | /* |
| 3246 | * Set the state after the Pause to avoid the race condiction |
| 3247 | * with ADDBA check in tx path |
| 3248 | */ |
| 3249 | peer->state = state; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3250 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3251 | } |
| 3252 | |
| 3253 | void |
| 3254 | ol_txrx_peer_keyinstalled_state_update(struct ol_txrx_peer_t *peer, uint8_t val) |
| 3255 | { |
| 3256 | peer->keyinstalled = val; |
| 3257 | } |
| 3258 | |
| 3259 | void |
| 3260 | ol_txrx_peer_update(ol_txrx_vdev_handle vdev, |
| 3261 | uint8_t *peer_mac, |
| 3262 | union ol_txrx_peer_update_param_t *param, |
| 3263 | enum ol_txrx_peer_update_select_t select) |
| 3264 | { |
| 3265 | struct ol_txrx_peer_t *peer; |
| 3266 | |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3267 | peer = ol_txrx_peer_find_hash_find_get_ref(vdev->pdev, peer_mac, 0, 1, |
| 3268 | PEER_DEBUG_ID_OL_INTERNAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3269 | if (!peer) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3270 | ol_txrx_dbg("%s: peer is null", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3271 | __func__); |
| 3272 | return; |
| 3273 | } |
| 3274 | |
| 3275 | switch (select) { |
| 3276 | case ol_txrx_peer_update_qos_capable: |
| 3277 | { |
| 3278 | /* save qos_capable here txrx peer, |
| 3279 | * when HTT_ISOC_T2H_MSG_TYPE_PEER_INFO comes then save. |
| 3280 | */ |
| 3281 | peer->qos_capable = param->qos_capable; |
| 3282 | /* |
| 3283 | * The following function call assumes that the peer has a |
| 3284 | * single ID. This is currently true, and |
| 3285 | * is expected to remain true. |
| 3286 | */ |
| 3287 | htt_peer_qos_update(peer->vdev->pdev->htt_pdev, |
| 3288 | peer->peer_ids[0], |
| 3289 | peer->qos_capable); |
| 3290 | break; |
| 3291 | } |
| 3292 | case ol_txrx_peer_update_uapsdMask: |
| 3293 | { |
| 3294 | peer->uapsd_mask = param->uapsd_mask; |
| 3295 | htt_peer_uapsdmask_update(peer->vdev->pdev->htt_pdev, |
| 3296 | peer->peer_ids[0], |
| 3297 | peer->uapsd_mask); |
| 3298 | break; |
| 3299 | } |
| 3300 | case ol_txrx_peer_update_peer_security: |
| 3301 | { |
| 3302 | enum ol_sec_type sec_type = param->sec_type; |
| 3303 | enum htt_sec_type peer_sec_type = htt_sec_type_none; |
| 3304 | |
| 3305 | switch (sec_type) { |
| 3306 | case ol_sec_type_none: |
| 3307 | peer_sec_type = htt_sec_type_none; |
| 3308 | break; |
| 3309 | case ol_sec_type_wep128: |
| 3310 | peer_sec_type = htt_sec_type_wep128; |
| 3311 | break; |
| 3312 | case ol_sec_type_wep104: |
| 3313 | peer_sec_type = htt_sec_type_wep104; |
| 3314 | break; |
| 3315 | case ol_sec_type_wep40: |
| 3316 | peer_sec_type = htt_sec_type_wep40; |
| 3317 | break; |
| 3318 | case ol_sec_type_tkip: |
| 3319 | peer_sec_type = htt_sec_type_tkip; |
| 3320 | break; |
| 3321 | case ol_sec_type_tkip_nomic: |
| 3322 | peer_sec_type = htt_sec_type_tkip_nomic; |
| 3323 | break; |
| 3324 | case ol_sec_type_aes_ccmp: |
| 3325 | peer_sec_type = htt_sec_type_aes_ccmp; |
| 3326 | break; |
| 3327 | case ol_sec_type_wapi: |
| 3328 | peer_sec_type = htt_sec_type_wapi; |
| 3329 | break; |
| 3330 | default: |
| 3331 | peer_sec_type = htt_sec_type_none; |
| 3332 | break; |
| 3333 | } |
| 3334 | |
| 3335 | peer->security[txrx_sec_ucast].sec_type = |
| 3336 | peer->security[txrx_sec_mcast].sec_type = |
| 3337 | peer_sec_type; |
| 3338 | |
| 3339 | break; |
| 3340 | } |
| 3341 | default: |
| 3342 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3343 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3344 | "ERROR: unknown param %d in %s", select, |
| 3345 | __func__); |
| 3346 | break; |
| 3347 | } |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3348 | } /* switch */ |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3349 | ol_txrx_peer_release_ref(peer, PEER_DEBUG_ID_OL_INTERNAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3350 | } |
| 3351 | |
| 3352 | uint8_t |
| 3353 | ol_txrx_peer_uapsdmask_get(struct ol_txrx_pdev_t *txrx_pdev, uint16_t peer_id) |
| 3354 | { |
| 3355 | |
| 3356 | struct ol_txrx_peer_t *peer; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 3357 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3358 | peer = ol_txrx_peer_find_by_id(txrx_pdev, peer_id); |
| 3359 | if (peer) |
| 3360 | return peer->uapsd_mask; |
| 3361 | return 0; |
| 3362 | } |
| 3363 | |
| 3364 | uint8_t |
| 3365 | ol_txrx_peer_qoscapable_get(struct ol_txrx_pdev_t *txrx_pdev, uint16_t peer_id) |
| 3366 | { |
| 3367 | |
| 3368 | struct ol_txrx_peer_t *peer_t = |
| 3369 | ol_txrx_peer_find_by_id(txrx_pdev, peer_id); |
| 3370 | if (peer_t != NULL) |
| 3371 | return peer_t->qos_capable; |
| 3372 | return 0; |
| 3373 | } |
| 3374 | |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3375 | /** |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3376 | * ol_txrx_peer_free_tids() - free tids for the peer |
| 3377 | * @peer: peer handle |
| 3378 | * |
| 3379 | * Return: None |
| 3380 | */ |
| 3381 | static inline void ol_txrx_peer_free_tids(ol_txrx_peer_handle peer) |
| 3382 | { |
| 3383 | int i = 0; |
| 3384 | /* |
| 3385 | * 'array' is allocated in addba handler and is supposed to be |
| 3386 | * freed in delba handler. There is the case (for example, in |
| 3387 | * SSR) where delba handler is not called. Because array points |
| 3388 | * to address of 'base' by default and is reallocated in addba |
| 3389 | * handler later, only free the memory when the array does not |
| 3390 | * point to base. |
| 3391 | */ |
| 3392 | for (i = 0; i < OL_TXRX_NUM_EXT_TIDS; i++) { |
| 3393 | if (peer->tids_rx_reorder[i].array != |
| 3394 | &peer->tids_rx_reorder[i].base) { |
| 3395 | ol_txrx_dbg( |
| 3396 | "%s, delete reorder arr, tid:%d\n", |
| 3397 | __func__, i); |
| 3398 | qdf_mem_free(peer->tids_rx_reorder[i].array); |
| 3399 | ol_rx_reorder_init(&peer->tids_rx_reorder[i], |
| 3400 | (uint8_t)i); |
| 3401 | } |
| 3402 | } |
| 3403 | } |
| 3404 | |
| 3405 | /** |
| 3406 | * ol_txrx_peer_release_ref() - release peer reference |
| 3407 | * @peer: peer handle |
| 3408 | * |
| 3409 | * Release peer reference and delete peer if refcount is 0 |
| 3410 | * |
wadesong | 9f2b110 | 2017-12-20 22:58:35 +0800 | [diff] [blame] | 3411 | * Return: Resulting peer ref_cnt after this function is invoked |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3412 | */ |
| 3413 | int ol_txrx_peer_release_ref(ol_txrx_peer_handle peer, |
| 3414 | enum peer_debug_id_type debug_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3415 | { |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3416 | int rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3417 | struct ol_txrx_vdev_t *vdev; |
| 3418 | struct ol_txrx_pdev_t *pdev; |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 3419 | bool ref_silent = false; |
Jingxiang Ge | 190679b | 2018-01-30 08:56:19 +0800 | [diff] [blame] | 3420 | int access_list = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3421 | |
| 3422 | /* preconditions */ |
| 3423 | TXRX_ASSERT2(peer); |
| 3424 | |
| 3425 | vdev = peer->vdev; |
| 3426 | if (NULL == vdev) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3427 | ol_txrx_dbg( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3428 | "The vdev is not present anymore\n"); |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3429 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3430 | } |
| 3431 | |
| 3432 | pdev = vdev->pdev; |
| 3433 | if (NULL == pdev) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3434 | ol_txrx_dbg( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3435 | "The pdev is not present anymore\n"); |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3436 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3437 | } |
| 3438 | |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3439 | if (debug_id >= PEER_DEBUG_ID_MAX || debug_id < 0) { |
| 3440 | ol_txrx_err("incorrect debug_id %d ", debug_id); |
| 3441 | return -EINVAL; |
| 3442 | } |
| 3443 | |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 3444 | if (debug_id == PEER_DEBUG_ID_OL_RX_THREAD) |
| 3445 | ref_silent = true; |
| 3446 | |
| 3447 | if (!ref_silent) |
| 3448 | wlan_roam_debug_log(vdev->vdev_id, DEBUG_PEER_UNREF_DELETE, |
| 3449 | DEBUG_INVALID_PEER_ID, &peer->mac_addr.raw, |
| 3450 | peer, 0, |
| 3451 | qdf_atomic_read(&peer->ref_cnt)); |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 3452 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3453 | |
| 3454 | /* |
| 3455 | * Hold the lock all the way from checking if the peer ref count |
| 3456 | * is zero until the peer references are removed from the hash |
| 3457 | * table and vdev list (if the peer ref count is zero). |
| 3458 | * This protects against a new HL tx operation starting to use the |
| 3459 | * peer object just after this function concludes it's done being used. |
| 3460 | * Furthermore, the lock needs to be held while checking whether the |
| 3461 | * vdev's list of peers is empty, to make sure that list is not modified |
| 3462 | * concurrently with the empty check. |
| 3463 | */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3464 | qdf_spin_lock_bh(&pdev->peer_ref_mutex); |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3465 | |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3466 | /* |
| 3467 | * Check for the reference count before deleting the peer |
| 3468 | * as we noticed that sometimes we are re-entering this |
| 3469 | * function again which is leading to dead-lock. |
| 3470 | * (A double-free should never happen, so assert if it does.) |
| 3471 | */ |
| 3472 | rc = qdf_atomic_read(&(peer->ref_cnt)); |
| 3473 | |
| 3474 | if (rc == 0) { |
| 3475 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
| 3476 | ol_txrx_err("The Peer is not present anymore\n"); |
| 3477 | qdf_assert(0); |
| 3478 | return -EACCES; |
| 3479 | } |
| 3480 | /* |
| 3481 | * now decrement rc; this will be the return code. |
| 3482 | * 0 : peer deleted |
| 3483 | * >0: peer ref removed, but still has other references |
| 3484 | * <0: sanity failed - no changes to the state of the peer |
| 3485 | */ |
| 3486 | rc--; |
| 3487 | |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3488 | if (!qdf_atomic_read(&peer->access_list[debug_id])) { |
| 3489 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
| 3490 | ol_txrx_err("peer %p ref was not taken by %d", |
| 3491 | peer, debug_id); |
| 3492 | ol_txrx_dump_peer_access_list(peer); |
| 3493 | QDF_BUG(0); |
| 3494 | return -EACCES; |
| 3495 | } |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3496 | qdf_atomic_dec(&peer->access_list[debug_id]); |
| 3497 | |
Deepak Dhamdhere | c47cfe8 | 2016-08-22 01:00:13 -0700 | [diff] [blame] | 3498 | if (qdf_atomic_dec_and_test(&peer->ref_cnt)) { |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3499 | u16 peer_id; |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 3500 | wlan_roam_debug_log(vdev->vdev_id, |
| 3501 | DEBUG_DELETING_PEER_OBJ, |
| 3502 | DEBUG_INVALID_PEER_ID, |
| 3503 | &peer->mac_addr.raw, peer, 0, |
| 3504 | qdf_atomic_read(&peer->ref_cnt)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3505 | peer_id = peer->local_id; |
| 3506 | /* remove the reference to the peer from the hash table */ |
| 3507 | ol_txrx_peer_find_hash_remove(pdev, peer); |
| 3508 | |
| 3509 | /* remove the peer from its parent vdev's list */ |
| 3510 | TAILQ_REMOVE(&peer->vdev->peer_list, peer, peer_list_elem); |
| 3511 | |
| 3512 | /* cleanup the Rx reorder queues for this peer */ |
| 3513 | ol_rx_peer_cleanup(vdev, peer); |
| 3514 | |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 3515 | qdf_spinlock_destroy(&peer->peer_info_lock); |
| 3516 | qdf_spinlock_destroy(&peer->bufq_info.bufq_lock); |
| 3517 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | /* peer is removed from peer_list */ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 3519 | qdf_atomic_set(&peer->delete_in_progress, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3520 | |
| 3521 | /* |
| 3522 | * Set wait_delete_comp event if the current peer id matches |
| 3523 | * with registered peer id. |
| 3524 | */ |
| 3525 | if (peer_id == vdev->wait_on_peer_id) { |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 3526 | qdf_event_set(&vdev->wait_delete_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3527 | vdev->wait_on_peer_id = OL_TXRX_INVALID_LOCAL_PEER_ID; |
| 3528 | } |
| 3529 | |
Deepak Dhamdhere | 2b283c6 | 2017-03-30 17:51:53 -0700 | [diff] [blame] | 3530 | qdf_timer_sync_cancel(&peer->peer_unmap_timer); |
| 3531 | qdf_timer_free(&peer->peer_unmap_timer); |
Deepak Dhamdhere | e1c2e21 | 2017-01-13 01:54:02 -0800 | [diff] [blame] | 3532 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3533 | /* check whether the parent vdev has no peers left */ |
| 3534 | if (TAILQ_EMPTY(&vdev->peer_list)) { |
| 3535 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3536 | * Check if the parent vdev was waiting for its peers |
| 3537 | * to be deleted, in order for it to be deleted too. |
| 3538 | */ |
| 3539 | if (vdev->delete.pending) { |
| 3540 | ol_txrx_vdev_delete_cb vdev_delete_cb = |
| 3541 | vdev->delete.callback; |
| 3542 | void *vdev_delete_context = |
| 3543 | vdev->delete.context; |
Himanshu Agarwal | 31f2856 | 2015-12-11 10:35:10 +0530 | [diff] [blame] | 3544 | /* |
| 3545 | * Now that there are no references to the peer, |
| 3546 | * we can release the peer reference lock. |
| 3547 | */ |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3548 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
Himanshu Agarwal | 31f2856 | 2015-12-11 10:35:10 +0530 | [diff] [blame] | 3549 | |
gbian | 016a42e | 2017-03-01 18:49:11 +0800 | [diff] [blame] | 3550 | /* |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 3551 | * The ol_tx_desc_free might access the invalid |
| 3552 | * content of vdev referred by tx desc, since |
| 3553 | * this vdev might be detached in another thread |
| 3554 | * asynchronous. |
| 3555 | * |
| 3556 | * Go through tx desc pool to set corresponding |
| 3557 | * tx desc's vdev to NULL when detach this vdev, |
| 3558 | * and add vdev checking in the ol_tx_desc_free |
| 3559 | * to avoid crash. |
| 3560 | */ |
gbian | 016a42e | 2017-03-01 18:49:11 +0800 | [diff] [blame] | 3561 | ol_txrx_tx_desc_reset_vdev(vdev); |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3562 | ol_txrx_dbg( |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 3563 | "%s: deleting vdev object %pK (%02x:%02x:%02x:%02x:%02x:%02x) - its last peer is done", |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 3564 | __func__, vdev, |
| 3565 | vdev->mac_addr.raw[0], |
| 3566 | vdev->mac_addr.raw[1], |
| 3567 | vdev->mac_addr.raw[2], |
| 3568 | vdev->mac_addr.raw[3], |
| 3569 | vdev->mac_addr.raw[4], |
| 3570 | vdev->mac_addr.raw[5]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3571 | /* all peers are gone, go ahead and delete it */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3572 | qdf_mem_free(vdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3573 | if (vdev_delete_cb) |
| 3574 | vdev_delete_cb(vdev_delete_context); |
Himanshu Agarwal | 31f2856 | 2015-12-11 10:35:10 +0530 | [diff] [blame] | 3575 | } else { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3576 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3577 | } |
Himanshu Agarwal | 31f2856 | 2015-12-11 10:35:10 +0530 | [diff] [blame] | 3578 | } else { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3579 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
Himanshu Agarwal | 31f2856 | 2015-12-11 10:35:10 +0530 | [diff] [blame] | 3580 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3581 | |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3582 | ol_txrx_info_high("[%d][%d]: Deleting peer %p ref_cnt -> %d %s", |
| 3583 | debug_id, |
| 3584 | qdf_atomic_read(&peer->access_list[debug_id]), |
| 3585 | peer, rc, |
| 3586 | qdf_atomic_read(&peer->fw_create_pending) |
| 3587 | == 1 ? |
| 3588 | "(No Maps received)" : ""); |
Mohit Khanna | 8ee37c6 | 2017-08-07 17:15:20 -0700 | [diff] [blame] | 3589 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 3590 | ol_txrx_peer_tx_queue_free(pdev, peer); |
| 3591 | |
Deepak Dhamdhere | b0d2dda | 2017-04-03 01:01:50 -0700 | [diff] [blame] | 3592 | /* Remove mappings from peer_id to peer object */ |
| 3593 | ol_txrx_peer_clear_map_peer(pdev, peer); |
| 3594 | |
wadesong | 9f2b110 | 2017-12-20 22:58:35 +0800 | [diff] [blame] | 3595 | /* Remove peer pointer from local peer ID map */ |
| 3596 | ol_txrx_local_peer_id_free(pdev, peer); |
| 3597 | |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3598 | ol_txrx_peer_free_tids(peer); |
| 3599 | |
| 3600 | ol_txrx_dump_peer_access_list(peer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3601 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 3602 | qdf_mem_free(peer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3603 | } else { |
Jingxiang Ge | 190679b | 2018-01-30 08:56:19 +0800 | [diff] [blame] | 3604 | access_list = qdf_atomic_read( |
| 3605 | &peer->access_list[debug_id]); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3606 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 3607 | if (!ref_silent) |
| 3608 | ol_txrx_info_high("[%d][%d]: ref delete peer %p ref_cnt -> %d", |
| 3609 | debug_id, |
Jingxiang Ge | 190679b | 2018-01-30 08:56:19 +0800 | [diff] [blame] | 3610 | access_list, |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 3611 | peer, rc); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3612 | } |
Orhan K AKYILDIZ | 0278cd0 | 2016-12-08 18:19:58 -0800 | [diff] [blame] | 3613 | return rc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3614 | } |
| 3615 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 3616 | /** |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3617 | * ol_txrx_clear_peer_internal() - ol internal function to clear peer |
| 3618 | * @peer: pointer to ol txrx peer structure |
| 3619 | * |
| 3620 | * Return: QDF Status |
| 3621 | */ |
| 3622 | static QDF_STATUS |
| 3623 | ol_txrx_clear_peer_internal(struct ol_txrx_peer_t *peer) |
| 3624 | { |
| 3625 | p_cds_sched_context sched_ctx = get_cds_sched_ctxt(); |
| 3626 | /* Drop pending Rx frames in CDS */ |
| 3627 | if (sched_ctx) |
| 3628 | cds_drop_rxpkt_by_staid(sched_ctx, peer->local_id); |
| 3629 | |
| 3630 | /* Purge the cached rx frame queue */ |
| 3631 | ol_txrx_flush_rx_frames(peer, 1); |
| 3632 | |
| 3633 | qdf_spin_lock_bh(&peer->peer_info_lock); |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3634 | peer->state = OL_TXRX_PEER_STATE_DISC; |
| 3635 | qdf_spin_unlock_bh(&peer->peer_info_lock); |
| 3636 | |
| 3637 | return QDF_STATUS_SUCCESS; |
| 3638 | } |
| 3639 | |
| 3640 | /** |
| 3641 | * ol_txrx_clear_peer() - clear peer |
| 3642 | * @sta_id: sta id |
| 3643 | * |
| 3644 | * Return: QDF Status |
| 3645 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3646 | static QDF_STATUS ol_txrx_clear_peer(struct cdp_pdev *ppdev, uint8_t sta_id) |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3647 | { |
| 3648 | struct ol_txrx_peer_t *peer; |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3649 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3650 | |
| 3651 | if (!pdev) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3652 | ol_txrx_err("%s: Unable to find pdev!", |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3653 | __func__); |
| 3654 | return QDF_STATUS_E_FAILURE; |
| 3655 | } |
| 3656 | |
| 3657 | if (sta_id >= WLAN_MAX_STA_COUNT) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3658 | ol_txrx_err("Invalid sta id %d", sta_id); |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3659 | return QDF_STATUS_E_INVAL; |
| 3660 | } |
| 3661 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3662 | peer = ol_txrx_peer_find_by_local_id((struct cdp_pdev *)pdev, sta_id); |
Kabilan Kannan | fa16398 | 2018-01-30 12:03:41 -0800 | [diff] [blame] | 3663 | |
| 3664 | /* Return success, if the peer is already cleared by |
| 3665 | * data path via peer detach function. |
| 3666 | */ |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3667 | if (!peer) |
Kabilan Kannan | fa16398 | 2018-01-30 12:03:41 -0800 | [diff] [blame] | 3668 | return QDF_STATUS_SUCCESS; |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3669 | |
| 3670 | return ol_txrx_clear_peer_internal(peer); |
| 3671 | |
| 3672 | } |
| 3673 | |
Deepak Dhamdhere | 64bfe97 | 2017-06-14 18:04:53 -0700 | [diff] [blame] | 3674 | void peer_unmap_timer_work_function(void *param) |
| 3675 | { |
| 3676 | WMA_LOGE("Enter: %s", __func__); |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 3677 | /* Added for debugging only */ |
Naveen Rawat | 17c42a8 | 2018-02-01 19:18:27 -0800 | [diff] [blame] | 3678 | ol_txrx_dump_peer_access_list(param); |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 3679 | wlan_roam_debug_dump_table(); |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 3680 | cds_trigger_recovery(QDF_PEER_UNMAP_TIMEDOUT); |
Deepak Dhamdhere | 64bfe97 | 2017-06-14 18:04:53 -0700 | [diff] [blame] | 3681 | } |
| 3682 | |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3683 | /** |
Deepak Dhamdhere | 64bfe97 | 2017-06-14 18:04:53 -0700 | [diff] [blame] | 3684 | * peer_unmap_timer_handler() - peer unmap timer function |
Deepak Dhamdhere | e1c2e21 | 2017-01-13 01:54:02 -0800 | [diff] [blame] | 3685 | * @data: peer object pointer |
| 3686 | * |
| 3687 | * Return: none |
| 3688 | */ |
| 3689 | void peer_unmap_timer_handler(void *data) |
| 3690 | { |
| 3691 | ol_txrx_peer_handle peer = (ol_txrx_peer_handle)data; |
Deepak Dhamdhere | 64bfe97 | 2017-06-14 18:04:53 -0700 | [diff] [blame] | 3692 | ol_txrx_pdev_handle txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Deepak Dhamdhere | e1c2e21 | 2017-01-13 01:54:02 -0800 | [diff] [blame] | 3693 | |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 3694 | ol_txrx_err("all unmap events not received for peer %pK, ref_cnt %d", |
Deepak Dhamdhere | e1c2e21 | 2017-01-13 01:54:02 -0800 | [diff] [blame] | 3695 | peer, qdf_atomic_read(&peer->ref_cnt)); |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 3696 | ol_txrx_err("peer %pK (%02x:%02x:%02x:%02x:%02x:%02x)", |
Deepak Dhamdhere | e1c2e21 | 2017-01-13 01:54:02 -0800 | [diff] [blame] | 3697 | peer, |
| 3698 | peer->mac_addr.raw[0], peer->mac_addr.raw[1], |
| 3699 | peer->mac_addr.raw[2], peer->mac_addr.raw[3], |
| 3700 | peer->mac_addr.raw[4], peer->mac_addr.raw[5]); |
Nachiket Kukade | a48fd77 | 2017-07-28 18:48:57 +0530 | [diff] [blame] | 3701 | if (!cds_is_driver_recovering() && !cds_is_fw_down()) { |
Deepak Dhamdhere | 64bfe97 | 2017-06-14 18:04:53 -0700 | [diff] [blame] | 3702 | qdf_create_work(0, &txrx_pdev->peer_unmap_timer_work, |
| 3703 | peer_unmap_timer_work_function, |
Naveen Rawat | 17c42a8 | 2018-02-01 19:18:27 -0800 | [diff] [blame] | 3704 | peer); |
Deepak Dhamdhere | 64bfe97 | 2017-06-14 18:04:53 -0700 | [diff] [blame] | 3705 | qdf_sched_work(0, &txrx_pdev->peer_unmap_timer_work); |
Deepak Dhamdhere | d42ab7c | 2017-04-13 19:32:16 -0700 | [diff] [blame] | 3706 | } else { |
| 3707 | ol_txrx_err("Recovery is in progress, ignore!"); |
| 3708 | } |
Deepak Dhamdhere | e1c2e21 | 2017-01-13 01:54:02 -0800 | [diff] [blame] | 3709 | } |
| 3710 | |
| 3711 | |
| 3712 | /** |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3713 | * ol_txrx_peer_detach() - Delete a peer's data object. |
| 3714 | * @peer - the object to detach |
Naveen Rawat | f4ada15 | 2017-09-05 14:56:12 -0700 | [diff] [blame] | 3715 | * @bitmap - bitmap indicating special handling of request. |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 3716 | * |
| 3717 | * When the host's control SW disassociates a peer, it calls |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3718 | * this function to detach and delete the peer. The reference |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 3719 | * stored in the control peer object to the data peer |
| 3720 | * object (set up by a call to ol_peer_store()) is provided. |
| 3721 | * |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3722 | * Return: None |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 3723 | */ |
Naveen Rawat | f4ada15 | 2017-09-05 14:56:12 -0700 | [diff] [blame] | 3724 | static void ol_txrx_peer_detach(void *ppeer, uint32_t bitmap) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3725 | { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 3726 | ol_txrx_peer_handle peer = ppeer; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3727 | struct ol_txrx_vdev_t *vdev = peer->vdev; |
| 3728 | |
| 3729 | /* redirect peer's rx delivery function to point to a discard func */ |
| 3730 | peer->rx_opt_proc = ol_rx_discard; |
| 3731 | |
| 3732 | peer->valid = 0; |
| 3733 | |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 3734 | /* flush all rx packets before clearing up the peer local_id */ |
| 3735 | ol_txrx_clear_peer_internal(peer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3736 | |
| 3737 | /* debug print to dump rx reorder state */ |
| 3738 | /* htt_rx_reorder_log_print(vdev->pdev->htt_pdev); */ |
| 3739 | |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3740 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO, |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 3741 | "%s:peer %pK (%02x:%02x:%02x:%02x:%02x:%02x)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3742 | __func__, peer, |
| 3743 | peer->mac_addr.raw[0], peer->mac_addr.raw[1], |
| 3744 | peer->mac_addr.raw[2], peer->mac_addr.raw[3], |
| 3745 | peer->mac_addr.raw[4], peer->mac_addr.raw[5]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3746 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3747 | qdf_spin_lock_bh(&vdev->pdev->last_real_peer_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3748 | if (vdev->last_real_peer == peer) |
| 3749 | vdev->last_real_peer = NULL; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 3750 | qdf_spin_unlock_bh(&vdev->pdev->last_real_peer_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3751 | htt_rx_reorder_log_print(peer->vdev->pdev->htt_pdev); |
| 3752 | |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3753 | /* |
| 3754 | * set delete_in_progress to identify that wma |
| 3755 | * is waiting for unmap massage for this peer |
| 3756 | */ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 3757 | qdf_atomic_set(&peer->delete_in_progress, 1); |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3758 | |
Lin Bai | 973e692 | 2018-01-08 17:59:19 +0800 | [diff] [blame] | 3759 | if (!(bitmap & (1 << CDP_PEER_DO_NOT_START_UNMAP_TIMER))) { |
Naveen Rawat | f4ada15 | 2017-09-05 14:56:12 -0700 | [diff] [blame] | 3760 | if (vdev->opmode == wlan_op_mode_sta) { |
| 3761 | qdf_mem_copy(&peer->vdev->last_peer_mac_addr, |
| 3762 | &peer->mac_addr, |
| 3763 | sizeof(union ol_txrx_align_mac_addr_t)); |
Abhishek Singh | 217d978 | 2017-04-28 23:49:11 +0530 | [diff] [blame] | 3764 | |
Lin Bai | 973e692 | 2018-01-08 17:59:19 +0800 | [diff] [blame] | 3765 | /* |
| 3766 | * Create a timer to track unmap events when the |
| 3767 | * sta peer gets deleted. |
| 3768 | */ |
Naveen Rawat | f4ada15 | 2017-09-05 14:56:12 -0700 | [diff] [blame] | 3769 | qdf_timer_start(&peer->peer_unmap_timer, |
| 3770 | OL_TXRX_PEER_UNMAP_TIMEOUT); |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3771 | ol_txrx_info_high |
| 3772 | ("started peer_unmap_timer for peer %pK", |
| 3773 | peer); |
Naveen Rawat | f4ada15 | 2017-09-05 14:56:12 -0700 | [diff] [blame] | 3774 | } |
Deepak Dhamdhere | e1c2e21 | 2017-01-13 01:54:02 -0800 | [diff] [blame] | 3775 | } |
| 3776 | |
| 3777 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3778 | * Remove the reference added during peer_attach. |
| 3779 | * The peer will still be left allocated until the |
| 3780 | * PEER_UNMAP message arrives to remove the other |
| 3781 | * reference, added by the PEER_MAP message. |
| 3782 | */ |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 3783 | ol_txrx_peer_release_ref(peer, PEER_DEBUG_ID_OL_INTERNAL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3784 | } |
| 3785 | |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3786 | /** |
| 3787 | * ol_txrx_peer_detach_force_delete() - Detach and delete a peer's data object |
Lin Bai | 973e692 | 2018-01-08 17:59:19 +0800 | [diff] [blame] | 3788 | * @ppeer - the object to detach |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3789 | * |
Deepak Dhamdhere | d40f4b1 | 2017-03-24 11:07:45 -0700 | [diff] [blame] | 3790 | * Detach a peer and force peer object to be removed. It is called during |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3791 | * roaming scenario when the firmware has already deleted a peer. |
Deepak Dhamdhere | d40f4b1 | 2017-03-24 11:07:45 -0700 | [diff] [blame] | 3792 | * Remove it from the peer_id_to_object map. Peer object is actually freed |
| 3793 | * when last reference is deleted. |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3794 | * |
| 3795 | * Return: None |
| 3796 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 3797 | static void ol_txrx_peer_detach_force_delete(void *ppeer) |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3798 | { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 3799 | ol_txrx_peer_handle peer = ppeer; |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3800 | ol_txrx_pdev_handle pdev = peer->vdev->pdev; |
| 3801 | |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 3802 | ol_txrx_info_high("%s peer %pK, peer->ref_cnt %d", |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3803 | __func__, peer, qdf_atomic_read(&peer->ref_cnt)); |
| 3804 | |
| 3805 | /* Clear the peer_id_to_obj map entries */ |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3806 | ol_txrx_peer_remove_obj_map_entries(pdev, peer); |
Lin Bai | 973e692 | 2018-01-08 17:59:19 +0800 | [diff] [blame] | 3807 | ol_txrx_peer_detach(peer, 1 << CDP_PEER_DELETE_NO_SPECIAL); |
Deepak Dhamdhere | f74d6f8 | 2016-09-16 02:47:01 -0700 | [diff] [blame] | 3808 | } |
| 3809 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3810 | /** |
| 3811 | * ol_txrx_dump_tx_desc() - dump tx desc total and free count |
| 3812 | * @txrx_pdev: Pointer to txrx pdev |
| 3813 | * |
| 3814 | * Return: none |
| 3815 | */ |
| 3816 | static void ol_txrx_dump_tx_desc(ol_txrx_pdev_handle pdev_handle) |
| 3817 | { |
| 3818 | struct ol_txrx_pdev_t *pdev = (ol_txrx_pdev_handle) pdev_handle; |
Houston Hoffman | 02d1e8e | 2016-10-13 18:54:52 -0700 | [diff] [blame] | 3819 | uint32_t total, num_free; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3820 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 3821 | if (ol_cfg_is_high_latency(pdev->ctrl_pdev)) |
| 3822 | total = qdf_atomic_read(&pdev->orig_target_tx_credit); |
| 3823 | else |
| 3824 | total = ol_tx_get_desc_global_pool_size(pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3825 | |
Houston Hoffman | 02d1e8e | 2016-10-13 18:54:52 -0700 | [diff] [blame] | 3826 | num_free = ol_tx_get_total_free_desc(pdev); |
| 3827 | |
Kapil Gupta | 53d9b57 | 2017-06-28 17:53:25 +0530 | [diff] [blame] | 3828 | ol_txrx_info_high( |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 3829 | "total tx credit %d num_free %d", |
Houston Hoffman | 02d1e8e | 2016-10-13 18:54:52 -0700 | [diff] [blame] | 3830 | total, num_free); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3831 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3832 | } |
| 3833 | |
| 3834 | /** |
| 3835 | * ol_txrx_wait_for_pending_tx() - wait for tx queue to be empty |
| 3836 | * @timeout: timeout in ms |
| 3837 | * |
| 3838 | * Wait for tx queue to be empty, return timeout error if |
| 3839 | * queue doesn't empty before timeout occurs. |
| 3840 | * |
| 3841 | * Return: |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3842 | * QDF_STATUS_SUCCESS if the queue empties, |
| 3843 | * QDF_STATUS_E_TIMEOUT in case of timeout, |
| 3844 | * QDF_STATUS_E_FAULT in case of missing handle |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3845 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 3846 | static QDF_STATUS ol_txrx_wait_for_pending_tx(int timeout) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3847 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3848 | struct ol_txrx_pdev_t *txrx_pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3849 | |
| 3850 | if (txrx_pdev == NULL) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3851 | ol_txrx_err( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3852 | "%s: txrx context is null", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3853 | return QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3854 | } |
| 3855 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3856 | while (ol_txrx_get_tx_pending((struct cdp_pdev *)txrx_pdev)) { |
Anurag Chouhan | 512c7d5 | 2016-02-19 15:49:46 +0530 | [diff] [blame] | 3857 | qdf_sleep(OL_ATH_TX_DRAIN_WAIT_DELAY); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3858 | if (timeout <= 0) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 3859 | ol_txrx_err( |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 3860 | "%s: tx frames are pending", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3861 | ol_txrx_dump_tx_desc(txrx_pdev); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3862 | return QDF_STATUS_E_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3863 | } |
| 3864 | timeout = timeout - OL_ATH_TX_DRAIN_WAIT_DELAY; |
| 3865 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3866 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3867 | } |
| 3868 | |
| 3869 | #ifndef QCA_WIFI_3_0_EMU |
Himanshu Agarwal | 83a8757 | 2017-05-25 14:09:50 +0530 | [diff] [blame] | 3870 | #define SUSPEND_DRAIN_WAIT 500 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3871 | #else |
| 3872 | #define SUSPEND_DRAIN_WAIT 3000 |
| 3873 | #endif |
| 3874 | |
Yue Ma | 1e11d79 | 2016-02-26 18:58:44 -0800 | [diff] [blame] | 3875 | #ifdef FEATURE_RUNTIME_PM |
| 3876 | /** |
| 3877 | * ol_txrx_runtime_suspend() - ensure TXRX is ready to runtime suspend |
| 3878 | * @txrx_pdev: TXRX pdev context |
| 3879 | * |
| 3880 | * TXRX is ready to runtime suspend if there are no pending packets |
| 3881 | * in the tx queue. |
| 3882 | * |
| 3883 | * Return: QDF_STATUS |
| 3884 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3885 | static QDF_STATUS ol_txrx_runtime_suspend(struct cdp_pdev *ppdev) |
Yue Ma | 1e11d79 | 2016-02-26 18:58:44 -0800 | [diff] [blame] | 3886 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3887 | struct ol_txrx_pdev_t *txrx_pdev = (struct ol_txrx_pdev_t *)ppdev; |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 3888 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3889 | if (ol_txrx_get_tx_pending((struct cdp_pdev *)txrx_pdev)) |
Yue Ma | 1e11d79 | 2016-02-26 18:58:44 -0800 | [diff] [blame] | 3890 | return QDF_STATUS_E_BUSY; |
| 3891 | else |
| 3892 | return QDF_STATUS_SUCCESS; |
| 3893 | } |
| 3894 | |
| 3895 | /** |
| 3896 | * ol_txrx_runtime_resume() - ensure TXRX is ready to runtime resume |
| 3897 | * @txrx_pdev: TXRX pdev context |
| 3898 | * |
| 3899 | * This is a dummy function for symmetry. |
| 3900 | * |
| 3901 | * Return: QDF_STATUS_SUCCESS |
| 3902 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3903 | static QDF_STATUS ol_txrx_runtime_resume(struct cdp_pdev *ppdev) |
Yue Ma | 1e11d79 | 2016-02-26 18:58:44 -0800 | [diff] [blame] | 3904 | { |
| 3905 | return QDF_STATUS_SUCCESS; |
| 3906 | } |
| 3907 | #endif |
| 3908 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3909 | /** |
| 3910 | * ol_txrx_bus_suspend() - bus suspend |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 3911 | * @ppdev: TXRX pdev context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3912 | * |
| 3913 | * Ensure that ol_txrx is ready for bus suspend |
| 3914 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3915 | * Return: QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3916 | */ |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 3917 | static QDF_STATUS ol_txrx_bus_suspend(struct cdp_pdev *ppdev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3918 | { |
| 3919 | return ol_txrx_wait_for_pending_tx(SUSPEND_DRAIN_WAIT); |
| 3920 | } |
| 3921 | |
| 3922 | /** |
| 3923 | * ol_txrx_bus_resume() - bus resume |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 3924 | * @ppdev: TXRX pdev context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3925 | * |
| 3926 | * Dummy function for symetry |
| 3927 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3928 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3929 | */ |
Dustin Brown | 7ff24dd | 2017-05-10 15:49:59 -0700 | [diff] [blame] | 3930 | static QDF_STATUS ol_txrx_bus_resume(struct cdp_pdev *ppdev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3931 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3932 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3933 | } |
| 3934 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 3935 | /** |
| 3936 | * ol_txrx_get_tx_pending - Get the number of pending transmit |
| 3937 | * frames that are awaiting completion. |
| 3938 | * |
| 3939 | * @pdev - the data physical device object |
| 3940 | * Mainly used in clean up path to make sure all buffers have been freed |
| 3941 | * |
| 3942 | * Return: count of pending frames |
| 3943 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3944 | int ol_txrx_get_tx_pending(struct cdp_pdev *ppdev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3945 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 3946 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3947 | uint32_t total; |
| 3948 | |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 3949 | if (ol_cfg_is_high_latency(pdev->ctrl_pdev)) |
| 3950 | total = qdf_atomic_read(&pdev->orig_target_tx_credit); |
| 3951 | else |
| 3952 | total = ol_tx_get_desc_global_pool_size(pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3953 | |
Nirav Shah | 55b45a0 | 2016-01-21 10:00:16 +0530 | [diff] [blame] | 3954 | return total - ol_tx_get_total_free_desc(pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3955 | } |
| 3956 | |
| 3957 | void ol_txrx_discard_tx_pending(ol_txrx_pdev_handle pdev_handle) |
| 3958 | { |
| 3959 | ol_tx_desc_list tx_descs; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 3960 | /* |
| 3961 | * First let hif do the qdf_atomic_dec_and_test(&tx_desc->ref_cnt) |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 3962 | * then let htt do the qdf_atomic_dec_and_test(&tx_desc->ref_cnt) |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 3963 | * which is tha same with normal data send complete path |
| 3964 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3965 | htt_tx_pending_discard(pdev_handle->htt_pdev); |
| 3966 | |
| 3967 | TAILQ_INIT(&tx_descs); |
| 3968 | ol_tx_queue_discard(pdev_handle, true, &tx_descs); |
| 3969 | /* Discard Frames in Discard List */ |
| 3970 | ol_tx_desc_frame_list_free(pdev_handle, &tx_descs, 1 /* error */); |
| 3971 | |
| 3972 | ol_tx_discard_target_frms(pdev_handle); |
| 3973 | } |
| 3974 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3975 | static inline |
| 3976 | uint64_t ol_txrx_stats_ptr_to_u64(struct ol_txrx_stats_req_internal *req) |
| 3977 | { |
| 3978 | return (uint64_t) ((size_t) req); |
| 3979 | } |
| 3980 | |
| 3981 | static inline |
| 3982 | struct ol_txrx_stats_req_internal *ol_txrx_u64_to_stats_ptr(uint64_t cookie) |
| 3983 | { |
| 3984 | return (struct ol_txrx_stats_req_internal *)((size_t) cookie); |
| 3985 | } |
| 3986 | |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 3987 | #ifdef currently_unused |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3988 | void |
| 3989 | ol_txrx_fw_stats_cfg(ol_txrx_vdev_handle vdev, |
| 3990 | uint8_t cfg_stats_type, uint32_t cfg_val) |
| 3991 | { |
| 3992 | uint64_t dummy_cookie = 0; |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 3993 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3994 | htt_h2t_dbg_stats_get(vdev->pdev->htt_pdev, 0 /* upload mask */, |
| 3995 | 0 /* reset mask */, |
| 3996 | cfg_stats_type, cfg_val, dummy_cookie); |
| 3997 | } |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 3998 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3999 | |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 4000 | static A_STATUS |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4001 | ol_txrx_fw_stats_get(struct cdp_vdev *pvdev, struct ol_txrx_stats_req *req, |
Dhanashri Atre | 52f7133 | 2016-08-22 12:12:36 -0700 | [diff] [blame] | 4002 | bool per_vdev, bool response_expected) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4003 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4004 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4005 | struct ol_txrx_pdev_t *pdev = vdev->pdev; |
| 4006 | uint64_t cookie; |
| 4007 | struct ol_txrx_stats_req_internal *non_volatile_req; |
| 4008 | |
| 4009 | if (!pdev || |
| 4010 | req->stats_type_upload_mask >= 1 << HTT_DBG_NUM_STATS || |
| 4011 | req->stats_type_reset_mask >= 1 << HTT_DBG_NUM_STATS) { |
| 4012 | return A_ERROR; |
| 4013 | } |
| 4014 | |
| 4015 | /* |
| 4016 | * Allocate a non-transient stats request object. |
| 4017 | * (The one provided as an argument is likely allocated on the stack.) |
| 4018 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4019 | non_volatile_req = qdf_mem_malloc(sizeof(*non_volatile_req)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4020 | if (!non_volatile_req) |
| 4021 | return A_NO_MEMORY; |
| 4022 | |
| 4023 | /* copy the caller's specifications */ |
| 4024 | non_volatile_req->base = *req; |
| 4025 | non_volatile_req->serviced = 0; |
| 4026 | non_volatile_req->offset = 0; |
| 4027 | |
| 4028 | /* use the non-volatile request object's address as the cookie */ |
| 4029 | cookie = ol_txrx_stats_ptr_to_u64(non_volatile_req); |
| 4030 | |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 4031 | if (response_expected) { |
| 4032 | qdf_spin_lock_bh(&pdev->req_list_spinlock); |
| 4033 | TAILQ_INSERT_TAIL(&pdev->req_list, non_volatile_req, req_list_elem); |
| 4034 | pdev->req_list_depth++; |
| 4035 | qdf_spin_unlock_bh(&pdev->req_list_spinlock); |
| 4036 | } |
| 4037 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4038 | if (htt_h2t_dbg_stats_get(pdev->htt_pdev, |
| 4039 | req->stats_type_upload_mask, |
| 4040 | req->stats_type_reset_mask, |
| 4041 | HTT_H2T_STATS_REQ_CFG_STAT_TYPE_INVALID, 0, |
| 4042 | cookie)) { |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 4043 | if (response_expected) { |
| 4044 | qdf_spin_lock_bh(&pdev->req_list_spinlock); |
| 4045 | TAILQ_REMOVE(&pdev->req_list, non_volatile_req, req_list_elem); |
| 4046 | pdev->req_list_depth--; |
| 4047 | qdf_spin_unlock_bh(&pdev->req_list_spinlock); |
| 4048 | } |
| 4049 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4050 | qdf_mem_free(non_volatile_req); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4051 | return A_ERROR; |
| 4052 | } |
| 4053 | |
Nirav Shah | d231042 | 2016-01-21 18:58:06 +0530 | [diff] [blame] | 4054 | if (response_expected == false) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4055 | qdf_mem_free(non_volatile_req); |
Nirav Shah | d231042 | 2016-01-21 18:58:06 +0530 | [diff] [blame] | 4056 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4057 | return A_OK; |
| 4058 | } |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 4059 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4060 | void |
| 4061 | ol_txrx_fw_stats_handler(ol_txrx_pdev_handle pdev, |
| 4062 | uint64_t cookie, uint8_t *stats_info_list) |
| 4063 | { |
| 4064 | enum htt_dbg_stats_type type; |
| 4065 | enum htt_dbg_stats_status status; |
| 4066 | int length; |
| 4067 | uint8_t *stats_data; |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 4068 | struct ol_txrx_stats_req_internal *req, *tmp; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4069 | int more = 0; |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 4070 | int found = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4071 | |
| 4072 | req = ol_txrx_u64_to_stats_ptr(cookie); |
| 4073 | |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 4074 | qdf_spin_lock_bh(&pdev->req_list_spinlock); |
| 4075 | TAILQ_FOREACH(tmp, &pdev->req_list, req_list_elem) { |
| 4076 | if (req == tmp) { |
| 4077 | found = 1; |
| 4078 | break; |
| 4079 | } |
| 4080 | } |
| 4081 | qdf_spin_unlock_bh(&pdev->req_list_spinlock); |
| 4082 | |
| 4083 | if (!found) { |
| 4084 | ol_txrx_err( |
Alok Kumar | bf47b99 | 2017-10-27 16:30:32 +0530 | [diff] [blame] | 4085 | "req(%pK) from firmware can't be found in the list\n", req); |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 4086 | return; |
| 4087 | } |
| 4088 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4089 | do { |
| 4090 | htt_t2h_dbg_stats_hdr_parse(stats_info_list, &type, &status, |
| 4091 | &length, &stats_data); |
| 4092 | if (status == HTT_DBG_STATS_STATUS_SERIES_DONE) |
| 4093 | break; |
| 4094 | if (status == HTT_DBG_STATS_STATUS_PRESENT || |
| 4095 | status == HTT_DBG_STATS_STATUS_PARTIAL) { |
| 4096 | uint8_t *buf; |
| 4097 | int bytes = 0; |
| 4098 | |
| 4099 | if (status == HTT_DBG_STATS_STATUS_PARTIAL) |
| 4100 | more = 1; |
| 4101 | if (req->base.print.verbose || req->base.print.concise) |
| 4102 | /* provide the header along with the data */ |
| 4103 | htt_t2h_stats_print(stats_info_list, |
| 4104 | req->base.print.concise); |
| 4105 | |
| 4106 | switch (type) { |
| 4107 | case HTT_DBG_STATS_WAL_PDEV_TXRX: |
| 4108 | bytes = sizeof(struct wlan_dbg_stats); |
| 4109 | if (req->base.copy.buf) { |
| 4110 | int lmt; |
| 4111 | |
| 4112 | lmt = sizeof(struct wlan_dbg_stats); |
| 4113 | if (req->base.copy.byte_limit < lmt) |
| 4114 | lmt = req->base.copy.byte_limit; |
| 4115 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4116 | qdf_mem_copy(buf, stats_data, lmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4117 | } |
| 4118 | break; |
| 4119 | case HTT_DBG_STATS_RX_REORDER: |
| 4120 | bytes = sizeof(struct rx_reorder_stats); |
| 4121 | if (req->base.copy.buf) { |
| 4122 | int lmt; |
| 4123 | |
| 4124 | lmt = sizeof(struct rx_reorder_stats); |
| 4125 | if (req->base.copy.byte_limit < lmt) |
| 4126 | lmt = req->base.copy.byte_limit; |
| 4127 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4128 | qdf_mem_copy(buf, stats_data, lmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4129 | } |
| 4130 | break; |
| 4131 | case HTT_DBG_STATS_RX_RATE_INFO: |
| 4132 | bytes = sizeof(wlan_dbg_rx_rate_info_t); |
| 4133 | if (req->base.copy.buf) { |
| 4134 | int lmt; |
| 4135 | |
| 4136 | lmt = sizeof(wlan_dbg_rx_rate_info_t); |
| 4137 | if (req->base.copy.byte_limit < lmt) |
| 4138 | lmt = req->base.copy.byte_limit; |
| 4139 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4140 | qdf_mem_copy(buf, stats_data, lmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4141 | } |
| 4142 | break; |
| 4143 | |
| 4144 | case HTT_DBG_STATS_TX_RATE_INFO: |
| 4145 | bytes = sizeof(wlan_dbg_tx_rate_info_t); |
| 4146 | if (req->base.copy.buf) { |
| 4147 | int lmt; |
| 4148 | |
| 4149 | lmt = sizeof(wlan_dbg_tx_rate_info_t); |
| 4150 | if (req->base.copy.byte_limit < lmt) |
| 4151 | lmt = req->base.copy.byte_limit; |
| 4152 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4153 | qdf_mem_copy(buf, stats_data, lmt); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4154 | } |
| 4155 | break; |
| 4156 | |
| 4157 | case HTT_DBG_STATS_TX_PPDU_LOG: |
| 4158 | bytes = 0; |
| 4159 | /* TO DO: specify how many bytes are present */ |
| 4160 | /* TO DO: add copying to the requestor's buf */ |
| 4161 | |
| 4162 | case HTT_DBG_STATS_RX_REMOTE_RING_BUFFER_INFO: |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4163 | bytes = sizeof(struct |
| 4164 | rx_remote_buffer_mgmt_stats); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4165 | if (req->base.copy.buf) { |
| 4166 | int limit; |
| 4167 | |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4168 | limit = sizeof(struct |
| 4169 | rx_remote_buffer_mgmt_stats); |
| 4170 | if (req->base.copy.byte_limit < limit) |
| 4171 | limit = req->base.copy. |
| 4172 | byte_limit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4173 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4174 | qdf_mem_copy(buf, stats_data, limit); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4175 | } |
| 4176 | break; |
| 4177 | |
| 4178 | case HTT_DBG_STATS_TXBF_INFO: |
| 4179 | bytes = sizeof(struct wlan_dbg_txbf_data_stats); |
| 4180 | if (req->base.copy.buf) { |
| 4181 | int limit; |
| 4182 | |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4183 | limit = sizeof(struct |
| 4184 | wlan_dbg_txbf_data_stats); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4185 | if (req->base.copy.byte_limit < limit) |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4186 | limit = req->base.copy. |
| 4187 | byte_limit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4188 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4189 | qdf_mem_copy(buf, stats_data, limit); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4190 | } |
| 4191 | break; |
| 4192 | |
| 4193 | case HTT_DBG_STATS_SND_INFO: |
| 4194 | bytes = sizeof(struct wlan_dbg_txbf_snd_stats); |
| 4195 | if (req->base.copy.buf) { |
| 4196 | int limit; |
| 4197 | |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4198 | limit = sizeof(struct |
| 4199 | wlan_dbg_txbf_snd_stats); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4200 | if (req->base.copy.byte_limit < limit) |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4201 | limit = req->base.copy. |
| 4202 | byte_limit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4203 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4204 | qdf_mem_copy(buf, stats_data, limit); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4205 | } |
| 4206 | break; |
| 4207 | |
| 4208 | case HTT_DBG_STATS_TX_SELFGEN_INFO: |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4209 | bytes = sizeof(struct |
| 4210 | wlan_dbg_tx_selfgen_stats); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4211 | if (req->base.copy.buf) { |
| 4212 | int limit; |
| 4213 | |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4214 | limit = sizeof(struct |
| 4215 | wlan_dbg_tx_selfgen_stats); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4216 | if (req->base.copy.byte_limit < limit) |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4217 | limit = req->base.copy. |
| 4218 | byte_limit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4219 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4220 | qdf_mem_copy(buf, stats_data, limit); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4221 | } |
| 4222 | break; |
| 4223 | |
| 4224 | case HTT_DBG_STATS_ERROR_INFO: |
| 4225 | bytes = |
| 4226 | sizeof(struct wlan_dbg_wifi2_error_stats); |
| 4227 | if (req->base.copy.buf) { |
| 4228 | int limit; |
| 4229 | |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4230 | limit = sizeof(struct |
| 4231 | wlan_dbg_wifi2_error_stats); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4232 | if (req->base.copy.byte_limit < limit) |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4233 | limit = req->base.copy. |
| 4234 | byte_limit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4235 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4236 | qdf_mem_copy(buf, stats_data, limit); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4237 | } |
| 4238 | break; |
| 4239 | |
| 4240 | case HTT_DBG_STATS_TXBF_MUSU_NDPA_PKT: |
| 4241 | bytes = |
| 4242 | sizeof(struct rx_txbf_musu_ndpa_pkts_stats); |
| 4243 | if (req->base.copy.buf) { |
| 4244 | int limit; |
| 4245 | |
| 4246 | limit = sizeof(struct |
| 4247 | rx_txbf_musu_ndpa_pkts_stats); |
| 4248 | if (req->base.copy.byte_limit < limit) |
| 4249 | limit = |
| 4250 | req->base.copy.byte_limit; |
| 4251 | buf = req->base.copy.buf + req->offset; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4252 | qdf_mem_copy(buf, stats_data, limit); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4253 | } |
| 4254 | break; |
| 4255 | |
| 4256 | default: |
| 4257 | break; |
| 4258 | } |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4259 | buf = req->base.copy.buf ? |
| 4260 | req->base.copy.buf : stats_data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4261 | if (req->base.callback.fp) |
| 4262 | req->base.callback.fp(req->base.callback.ctxt, |
| 4263 | type, buf, bytes); |
| 4264 | } |
| 4265 | stats_info_list += length; |
| 4266 | } while (1); |
| 4267 | |
| 4268 | if (!more) { |
tfyu | 9fcabd7 | 2017-09-26 17:46:48 +0800 | [diff] [blame] | 4269 | qdf_spin_lock_bh(&pdev->req_list_spinlock); |
| 4270 | TAILQ_FOREACH(tmp, &pdev->req_list, req_list_elem) { |
| 4271 | if (req == tmp) { |
| 4272 | TAILQ_REMOVE(&pdev->req_list, req, req_list_elem); |
| 4273 | pdev->req_list_depth--; |
| 4274 | qdf_mem_free(req); |
| 4275 | break; |
| 4276 | } |
| 4277 | } |
| 4278 | qdf_spin_unlock_bh(&pdev->req_list_spinlock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4279 | } |
| 4280 | } |
| 4281 | |
| 4282 | #ifndef ATH_PERF_PWR_OFFLOAD /*---------------------------------------------*/ |
| 4283 | int ol_txrx_debug(ol_txrx_vdev_handle vdev, int debug_specs) |
| 4284 | { |
| 4285 | if (debug_specs & TXRX_DBG_MASK_OBJS) { |
| 4286 | #if defined(TXRX_DEBUG_LEVEL) && TXRX_DEBUG_LEVEL > 5 |
| 4287 | ol_txrx_pdev_display(vdev->pdev, 0); |
| 4288 | #else |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4289 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4290 | "The pdev,vdev,peer display functions are disabled.\n To enable them, recompile with TXRX_DEBUG_LEVEL > 5"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4291 | #endif |
| 4292 | } |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4293 | if (debug_specs & TXRX_DBG_MASK_STATS) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4294 | ol_txrx_stats_display(vdev->pdev, |
| 4295 | QDF_STATS_VERBOSITY_LEVEL_HIGH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4296 | if (debug_specs & TXRX_DBG_MASK_PROT_ANALYZE) { |
| 4297 | #if defined(ENABLE_TXRX_PROT_ANALYZE) |
| 4298 | ol_txrx_prot_ans_display(vdev->pdev); |
| 4299 | #else |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4300 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4301 | "txrx protocol analysis is disabled.\n To enable it, recompile with ENABLE_TXRX_PROT_ANALYZE defined"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4302 | #endif |
| 4303 | } |
| 4304 | if (debug_specs & TXRX_DBG_MASK_RX_REORDER_TRACE) { |
| 4305 | #if defined(ENABLE_RX_REORDER_TRACE) |
| 4306 | ol_rx_reorder_trace_display(vdev->pdev, 0, 0); |
| 4307 | #else |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4308 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_FATAL, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4309 | "rx reorder seq num trace is disabled.\n To enable it, recompile with ENABLE_RX_REORDER_TRACE defined"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4310 | #endif |
| 4311 | |
| 4312 | } |
| 4313 | return 0; |
| 4314 | } |
| 4315 | #endif |
| 4316 | |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 4317 | #ifdef currently_unused |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4318 | int ol_txrx_aggr_cfg(ol_txrx_vdev_handle vdev, |
| 4319 | int max_subfrms_ampdu, int max_subfrms_amsdu) |
| 4320 | { |
| 4321 | return htt_h2t_aggr_cfg_msg(vdev->pdev->htt_pdev, |
| 4322 | max_subfrms_ampdu, max_subfrms_amsdu); |
| 4323 | } |
Jeff Johnson | 6f9aa56 | 2017-01-17 13:52:18 -0800 | [diff] [blame] | 4324 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4325 | |
| 4326 | #if defined(TXRX_DEBUG_LEVEL) && TXRX_DEBUG_LEVEL > 5 |
| 4327 | void ol_txrx_pdev_display(ol_txrx_pdev_handle pdev, int indent) |
| 4328 | { |
| 4329 | struct ol_txrx_vdev_t *vdev; |
| 4330 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4331 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4332 | "%*s%s:\n", indent, " ", "txrx pdev"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4333 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 4334 | "%*spdev object: %pK", indent + 4, " ", pdev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4335 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4336 | "%*svdev list:", indent + 4, " "); |
| 4337 | TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4338 | ol_txrx_vdev_display(vdev, indent + 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4339 | } |
| 4340 | ol_txrx_peer_find_display(pdev, indent + 4); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4341 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 4342 | "%*stx desc pool: %d elems @ %pK", indent + 4, " ", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4343 | pdev->tx_desc.pool_size, pdev->tx_desc.array); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4344 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, " "); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4345 | htt_display(pdev->htt_pdev, indent); |
| 4346 | } |
| 4347 | |
| 4348 | void ol_txrx_vdev_display(ol_txrx_vdev_handle vdev, int indent) |
| 4349 | { |
| 4350 | struct ol_txrx_peer_t *peer; |
| 4351 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4352 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 4353 | "%*stxrx vdev: %pK\n", indent, " ", vdev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4354 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4355 | "%*sID: %d\n", indent + 4, " ", vdev->vdev_id); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4356 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4357 | "%*sMAC addr: %d:%d:%d:%d:%d:%d", |
| 4358 | indent + 4, " ", |
| 4359 | vdev->mac_addr.raw[0], vdev->mac_addr.raw[1], |
| 4360 | vdev->mac_addr.raw[2], vdev->mac_addr.raw[3], |
| 4361 | vdev->mac_addr.raw[4], vdev->mac_addr.raw[5]); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4362 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4363 | "%*speer list:", indent + 4, " "); |
| 4364 | TAILQ_FOREACH(peer, &vdev->peer_list, peer_list_elem) { |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4365 | ol_txrx_peer_display(peer, indent + 8); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4366 | } |
| 4367 | } |
| 4368 | |
| 4369 | void ol_txrx_peer_display(ol_txrx_peer_handle peer, int indent) |
| 4370 | { |
| 4371 | int i; |
| 4372 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4373 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 4374 | "%*stxrx peer: %pK", indent, " ", peer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4375 | for (i = 0; i < MAX_NUM_PEER_ID_PER_PEER; i++) { |
| 4376 | if (peer->peer_ids[i] != HTT_INVALID_PEER) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4377 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4378 | "%*sID: %d", indent + 4, " ", |
| 4379 | peer->peer_ids[i]); |
| 4380 | } |
| 4381 | } |
| 4382 | } |
| 4383 | #endif /* TXRX_DEBUG_LEVEL */ |
| 4384 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4385 | /** |
| 4386 | * ol_txrx_stats() - update ol layer stats |
| 4387 | * @vdev_id: vdev_id |
| 4388 | * @buffer: pointer to buffer |
| 4389 | * @buf_len: length of the buffer |
| 4390 | * |
| 4391 | * Return: length of string |
| 4392 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 4393 | static int |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4394 | ol_txrx_stats(uint8_t vdev_id, char *buffer, unsigned int buf_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4395 | { |
| 4396 | uint32_t len = 0; |
| 4397 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4398 | struct ol_txrx_vdev_t *vdev = |
| 4399 | (struct ol_txrx_vdev_t *) |
| 4400 | ol_txrx_get_vdev_from_vdev_id(vdev_id); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4401 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4402 | if (!vdev) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4403 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4404 | "%s: vdev is NULL", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4405 | snprintf(buffer, buf_len, "vdev not found"); |
| 4406 | return len; |
| 4407 | } |
| 4408 | |
| 4409 | len = scnprintf(buffer, buf_len, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4410 | "\n\nTXRX stats:\nllQueue State : %s\npause %u unpause %u\noverflow %u\nllQueue timer state : %s", |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4411 | ((vdev->ll_pause.is_q_paused == false) ? |
| 4412 | "UNPAUSED" : "PAUSED"), |
| 4413 | vdev->ll_pause.q_pause_cnt, |
| 4414 | vdev->ll_pause.q_unpause_cnt, |
| 4415 | vdev->ll_pause.q_overflow_cnt, |
| 4416 | ((vdev->ll_pause.is_q_timer_on == false) |
| 4417 | ? "NOT-RUNNING" : "RUNNING")); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4418 | return len; |
| 4419 | } |
| 4420 | |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4421 | #ifdef QCA_SUPPORT_TXRX_LOCAL_PEER_ID |
| 4422 | /** |
| 4423 | * ol_txrx_disp_peer_cached_bufq_stats() - display peer cached_bufq stats |
| 4424 | * @peer: peer pointer |
| 4425 | * |
| 4426 | * Return: None |
| 4427 | */ |
| 4428 | static void ol_txrx_disp_peer_cached_bufq_stats(struct ol_txrx_peer_t *peer) |
| 4429 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4430 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 4431 | "cached_bufq: curr %d drops %d hwm %d whatifs %d thresh %d", |
| 4432 | peer->bufq_info.curr, |
| 4433 | peer->bufq_info.dropped, |
| 4434 | peer->bufq_info.high_water_mark, |
| 4435 | peer->bufq_info.qdepth_no_thresh, |
| 4436 | peer->bufq_info.thresh); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4437 | } |
| 4438 | |
| 4439 | /** |
| 4440 | * ol_txrx_disp_peer_stats() - display peer stats |
| 4441 | * @pdev: pdev pointer |
| 4442 | * |
| 4443 | * Return: None |
| 4444 | */ |
| 4445 | static void ol_txrx_disp_peer_stats(ol_txrx_pdev_handle pdev) |
| 4446 | { int i; |
| 4447 | struct ol_txrx_peer_t *peer; |
| 4448 | struct hif_opaque_softc *osc = cds_get_context(QDF_MODULE_ID_HIF); |
| 4449 | |
| 4450 | if (osc && hif_is_load_or_unload_in_progress(HIF_GET_SOFTC(osc))) |
| 4451 | return; |
| 4452 | |
| 4453 | for (i = 0; i < OL_TXRX_NUM_LOCAL_PEER_IDS; i++) { |
| 4454 | qdf_spin_lock_bh(&pdev->local_peer_ids.lock); |
| 4455 | peer = pdev->local_peer_ids.map[i]; |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 4456 | if (peer) { |
| 4457 | qdf_spin_lock_bh(&pdev->peer_ref_mutex); |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 4458 | ol_txrx_peer_get_ref(peer, PEER_DEBUG_ID_OL_INTERNAL); |
Frank Liu | 4362e46 | 2018-01-16 11:51:55 +0800 | [diff] [blame] | 4459 | qdf_spin_unlock_bh(&pdev->peer_ref_mutex); |
| 4460 | } |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4461 | qdf_spin_unlock_bh(&pdev->local_peer_ids.lock); |
| 4462 | |
| 4463 | if (peer) { |
| 4464 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 4465 | "stats: peer 0x%pK local peer id %d", peer, i); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4466 | ol_txrx_disp_peer_cached_bufq_stats(peer); |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 4467 | ol_txrx_peer_release_ref(peer, |
| 4468 | PEER_DEBUG_ID_OL_INTERNAL); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4469 | } |
| 4470 | } |
| 4471 | } |
| 4472 | #else |
| 4473 | static void ol_txrx_disp_peer_stats(ol_txrx_pdev_handle pdev) |
| 4474 | { |
| 4475 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4476 | "peer stats not supported w/o QCA_SUPPORT_TXRX_LOCAL_PEER_ID"); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4477 | } |
| 4478 | #endif |
| 4479 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4480 | void ol_txrx_stats_display(ol_txrx_pdev_handle pdev, |
| 4481 | enum qdf_stats_verbosity_level level) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4482 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4483 | u64 tx_dropped = |
| 4484 | pdev->stats.pub.tx.dropped.download_fail.pkts |
| 4485 | + pdev->stats.pub.tx.dropped.target_discard.pkts |
| 4486 | + pdev->stats.pub.tx.dropped.no_ack.pkts |
| 4487 | + pdev->stats.pub.tx.dropped.others.pkts; |
| 4488 | |
| 4489 | if (level == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 4490 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 4491 | "STATS |%u %u|TX: %lld tso %lld ok %lld drops(%u-%lld %u-%lld %u-%lld ?-%lld hR-%lld)|RX: %lld drops(E %lld PI %lld ME %lld) fwd(S %d F %d SF %d)|", |
| 4492 | pdev->tx_desc.num_free, |
| 4493 | pdev->tx_desc.pool_size, |
| 4494 | pdev->stats.pub.tx.from_stack.pkts, |
| 4495 | pdev->stats.pub.tx.tso.tso_pkts.pkts, |
| 4496 | pdev->stats.pub.tx.delivered.pkts, |
| 4497 | htt_tx_status_download_fail, |
| 4498 | pdev->stats.pub.tx.dropped.download_fail.pkts, |
| 4499 | htt_tx_status_discard, |
| 4500 | pdev->stats.pub.tx.dropped.target_discard.pkts, |
| 4501 | htt_tx_status_no_ack, |
| 4502 | pdev->stats.pub.tx.dropped.no_ack.pkts, |
| 4503 | pdev->stats.pub.tx.dropped.others.pkts, |
| 4504 | pdev->stats.pub.tx.dropped.host_reject.pkts, |
| 4505 | pdev->stats.pub.rx.delivered.pkts, |
| 4506 | pdev->stats.pub.rx.dropped_err.pkts, |
| 4507 | pdev->stats.pub.rx.dropped_peer_invalid.pkts, |
| 4508 | pdev->stats.pub.rx.dropped_mic_err.pkts, |
| 4509 | pdev->stats.pub.rx.intra_bss_fwd.packets_stack, |
| 4510 | pdev->stats.pub.rx.intra_bss_fwd.packets_fwd, |
| 4511 | pdev->stats.pub.rx.intra_bss_fwd.packets_stack_n_fwd); |
| 4512 | return; |
| 4513 | } |
| 4514 | |
| 4515 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Nirav Shah | 6a4eee6 | 2016-04-25 10:15:04 +0530 | [diff] [blame] | 4516 | "TX PATH Statistics:"); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4517 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 4518 | "sent %lld msdus (%lld B), host rejected %lld (%lld B), dropped %lld (%lld B)", |
| 4519 | pdev->stats.pub.tx.from_stack.pkts, |
| 4520 | pdev->stats.pub.tx.from_stack.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4521 | pdev->stats.pub.tx.dropped.host_reject.pkts, |
| 4522 | pdev->stats.pub.tx.dropped.host_reject.bytes, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4523 | tx_dropped, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4524 | pdev->stats.pub.tx.dropped.download_fail.bytes |
| 4525 | + pdev->stats.pub.tx.dropped.target_discard.bytes |
| 4526 | + pdev->stats.pub.tx.dropped.no_ack.bytes); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4527 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
| 4528 | "successfully delivered: %lld (%lld B), download fail: %lld (%lld B), target discard: %lld (%lld B), no ack: %lld (%lld B) others: %lld (%lld B)", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 4529 | pdev->stats.pub.tx.delivered.pkts, |
| 4530 | pdev->stats.pub.tx.delivered.bytes, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4531 | pdev->stats.pub.tx.dropped.download_fail.pkts, |
| 4532 | pdev->stats.pub.tx.dropped.download_fail.bytes, |
| 4533 | pdev->stats.pub.tx.dropped.target_discard.pkts, |
| 4534 | pdev->stats.pub.tx.dropped.target_discard.bytes, |
| 4535 | pdev->stats.pub.tx.dropped.no_ack.pkts, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4536 | pdev->stats.pub.tx.dropped.no_ack.bytes, |
| 4537 | pdev->stats.pub.tx.dropped.others.pkts, |
| 4538 | pdev->stats.pub.tx.dropped.others.bytes); |
| 4539 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 4540 | "Tx completions per HTT message:\n" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4541 | "Single Packet %d\n" |
| 4542 | " 2-10 Packets %d\n" |
| 4543 | "11-20 Packets %d\n" |
| 4544 | "21-30 Packets %d\n" |
| 4545 | "31-40 Packets %d\n" |
| 4546 | "41-50 Packets %d\n" |
| 4547 | "51-60 Packets %d\n" |
| 4548 | " 60+ Packets %d\n", |
| 4549 | pdev->stats.pub.tx.comp_histogram.pkts_1, |
| 4550 | pdev->stats.pub.tx.comp_histogram.pkts_2_10, |
| 4551 | pdev->stats.pub.tx.comp_histogram.pkts_11_20, |
| 4552 | pdev->stats.pub.tx.comp_histogram.pkts_21_30, |
| 4553 | pdev->stats.pub.tx.comp_histogram.pkts_31_40, |
| 4554 | pdev->stats.pub.tx.comp_histogram.pkts_41_50, |
| 4555 | pdev->stats.pub.tx.comp_histogram.pkts_51_60, |
| 4556 | pdev->stats.pub.tx.comp_histogram.pkts_61_plus); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 4557 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4558 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Nirav Shah | 6a4eee6 | 2016-04-25 10:15:04 +0530 | [diff] [blame] | 4559 | "RX PATH Statistics:"); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4560 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Nirav Shah | 6a4eee6 | 2016-04-25 10:15:04 +0530 | [diff] [blame] | 4561 | "%lld ppdus, %lld mpdus, %lld msdus, %lld bytes\n" |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 4562 | "dropped: err %lld (%lld B), peer_invalid %lld (%lld B), mic_err %lld (%lld B)\n" |
| 4563 | "msdus with frag_ind: %d msdus with offload_ind: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4564 | pdev->stats.priv.rx.normal.ppdus, |
| 4565 | pdev->stats.priv.rx.normal.mpdus, |
| 4566 | pdev->stats.pub.rx.delivered.pkts, |
| 4567 | pdev->stats.pub.rx.delivered.bytes, |
Nirav Shah | 6a4eee6 | 2016-04-25 10:15:04 +0530 | [diff] [blame] | 4568 | pdev->stats.pub.rx.dropped_err.pkts, |
| 4569 | pdev->stats.pub.rx.dropped_err.bytes, |
| 4570 | pdev->stats.pub.rx.dropped_peer_invalid.pkts, |
| 4571 | pdev->stats.pub.rx.dropped_peer_invalid.bytes, |
| 4572 | pdev->stats.pub.rx.dropped_mic_err.pkts, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 4573 | pdev->stats.pub.rx.dropped_mic_err.bytes, |
| 4574 | pdev->stats.pub.rx.msdus_with_frag_ind, |
| 4575 | pdev->stats.pub.rx.msdus_with_offload_ind); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4576 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4577 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4578 | " fwd to stack %d, fwd to fw %d, fwd to stack & fw %d\n", |
| 4579 | pdev->stats.pub.rx.intra_bss_fwd.packets_stack, |
| 4580 | pdev->stats.pub.rx.intra_bss_fwd.packets_fwd, |
| 4581 | pdev->stats.pub.rx.intra_bss_fwd.packets_stack_n_fwd); |
Nirav Shah | 6a4eee6 | 2016-04-25 10:15:04 +0530 | [diff] [blame] | 4582 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4583 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_LOW, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 4584 | "Rx packets per HTT message:\n" |
Nirav Shah | 6a4eee6 | 2016-04-25 10:15:04 +0530 | [diff] [blame] | 4585 | "Single Packet %d\n" |
| 4586 | " 2-10 Packets %d\n" |
| 4587 | "11-20 Packets %d\n" |
| 4588 | "21-30 Packets %d\n" |
| 4589 | "31-40 Packets %d\n" |
| 4590 | "41-50 Packets %d\n" |
| 4591 | "51-60 Packets %d\n" |
| 4592 | " 60+ Packets %d\n", |
| 4593 | pdev->stats.pub.rx.rx_ind_histogram.pkts_1, |
| 4594 | pdev->stats.pub.rx.rx_ind_histogram.pkts_2_10, |
| 4595 | pdev->stats.pub.rx.rx_ind_histogram.pkts_11_20, |
| 4596 | pdev->stats.pub.rx.rx_ind_histogram.pkts_21_30, |
| 4597 | pdev->stats.pub.rx.rx_ind_histogram.pkts_31_40, |
| 4598 | pdev->stats.pub.rx.rx_ind_histogram.pkts_41_50, |
| 4599 | pdev->stats.pub.rx.rx_ind_histogram.pkts_51_60, |
| 4600 | pdev->stats.pub.rx.rx_ind_histogram.pkts_61_plus); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4601 | |
| 4602 | ol_txrx_disp_peer_stats(pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4603 | } |
| 4604 | |
| 4605 | void ol_txrx_stats_clear(ol_txrx_pdev_handle pdev) |
| 4606 | { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4607 | qdf_mem_zero(&pdev->stats, sizeof(pdev->stats)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4608 | } |
| 4609 | |
| 4610 | #if defined(ENABLE_TXRX_PROT_ANALYZE) |
| 4611 | |
| 4612 | void ol_txrx_prot_ans_display(ol_txrx_pdev_handle pdev) |
| 4613 | { |
| 4614 | ol_txrx_prot_an_display(pdev->prot_an_tx_sent); |
| 4615 | ol_txrx_prot_an_display(pdev->prot_an_rx_sent); |
| 4616 | } |
| 4617 | |
| 4618 | #endif /* ENABLE_TXRX_PROT_ANALYZE */ |
| 4619 | |
| 4620 | #ifdef QCA_SUPPORT_PEER_DATA_RX_RSSI |
| 4621 | int16_t ol_txrx_peer_rssi(ol_txrx_peer_handle peer) |
| 4622 | { |
| 4623 | return (peer->rssi_dbm == HTT_RSSI_INVALID) ? |
| 4624 | OL_TXRX_RSSI_INVALID : peer->rssi_dbm; |
| 4625 | } |
| 4626 | #endif /* #ifdef QCA_SUPPORT_PEER_DATA_RX_RSSI */ |
| 4627 | |
| 4628 | #ifdef QCA_ENABLE_OL_TXRX_PEER_STATS |
| 4629 | A_STATUS |
| 4630 | ol_txrx_peer_stats_copy(ol_txrx_pdev_handle pdev, |
| 4631 | ol_txrx_peer_handle peer, ol_txrx_peer_stats_t *stats) |
| 4632 | { |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4633 | qdf_assert(pdev && peer && stats); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4634 | qdf_spin_lock_bh(&pdev->peer_stat_mutex); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 4635 | qdf_mem_copy(stats, &peer->stats, sizeof(*stats)); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4636 | qdf_spin_unlock_bh(&pdev->peer_stat_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4637 | return A_OK; |
| 4638 | } |
| 4639 | #endif /* QCA_ENABLE_OL_TXRX_PEER_STATS */ |
| 4640 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4641 | static void ol_vdev_rx_set_intrabss_fwd(struct cdp_vdev *pvdev, bool val) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4642 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4643 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 4644 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4645 | if (NULL == vdev) |
| 4646 | return; |
| 4647 | |
| 4648 | vdev->disable_intrabss_fwd = val; |
| 4649 | } |
| 4650 | |
Nirav Shah | c657ef5 | 2016-07-26 14:22:38 +0530 | [diff] [blame] | 4651 | /** |
| 4652 | * ol_txrx_update_mac_id() - update mac_id for vdev |
| 4653 | * @vdev_id: vdev id |
| 4654 | * @mac_id: mac id |
| 4655 | * |
| 4656 | * Return: none |
| 4657 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 4658 | static void ol_txrx_update_mac_id(uint8_t vdev_id, uint8_t mac_id) |
Nirav Shah | c657ef5 | 2016-07-26 14:22:38 +0530 | [diff] [blame] | 4659 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4660 | struct ol_txrx_vdev_t *vdev = |
| 4661 | (struct ol_txrx_vdev_t *) |
| 4662 | ol_txrx_get_vdev_from_vdev_id(vdev_id); |
Nirav Shah | c657ef5 | 2016-07-26 14:22:38 +0530 | [diff] [blame] | 4663 | |
| 4664 | if (NULL == vdev) { |
| 4665 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 4666 | "%s: Invalid vdev_id %d", __func__, vdev_id); |
| 4667 | return; |
| 4668 | } |
| 4669 | vdev->mac_id = mac_id; |
| 4670 | } |
| 4671 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4672 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 4673 | |
| 4674 | /** |
| 4675 | * ol_txrx_get_vdev_from_sta_id() - get vdev from sta_id |
| 4676 | * @sta_id: sta_id |
| 4677 | * |
| 4678 | * Return: vdev handle |
| 4679 | * NULL if not found. |
| 4680 | */ |
| 4681 | static ol_txrx_vdev_handle ol_txrx_get_vdev_from_sta_id(uint8_t sta_id) |
| 4682 | { |
| 4683 | struct ol_txrx_peer_t *peer = NULL; |
| 4684 | ol_txrx_pdev_handle pdev = NULL; |
| 4685 | |
| 4686 | if (sta_id >= WLAN_MAX_STA_COUNT) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4687 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4688 | "Invalid sta id passed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4689 | return NULL; |
| 4690 | } |
| 4691 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4692 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4693 | if (!pdev) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4694 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4695 | "PDEV not found for sta_id [%d]", sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4696 | return NULL; |
| 4697 | } |
| 4698 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4699 | peer = ol_txrx_peer_find_by_local_id((struct cdp_pdev *)pdev, sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4700 | |
| 4701 | if (!peer) { |
Zhu Jianmin | f7ffe94 | 2017-08-24 10:24:15 +0800 | [diff] [blame] | 4702 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4703 | "PEER [%d] not found", sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4704 | return NULL; |
| 4705 | } |
| 4706 | |
| 4707 | return peer->vdev; |
| 4708 | } |
| 4709 | |
| 4710 | /** |
| 4711 | * ol_txrx_register_tx_flow_control() - register tx flow control callback |
| 4712 | * @vdev_id: vdev_id |
| 4713 | * @flowControl: flow control callback |
| 4714 | * @osif_fc_ctx: callback context |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 4715 | * @flow_control_is_pause: is vdev paused by flow control |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4716 | * |
| 4717 | * Return: 0 for sucess or error code |
| 4718 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 4719 | static int ol_txrx_register_tx_flow_control(uint8_t vdev_id, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 4720 | ol_txrx_tx_flow_control_fp flowControl, void *osif_fc_ctx, |
| 4721 | ol_txrx_tx_flow_control_is_pause_fp flow_control_is_pause) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4722 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4723 | struct ol_txrx_vdev_t *vdev = |
| 4724 | (struct ol_txrx_vdev_t *)ol_txrx_get_vdev_from_vdev_id(vdev_id); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4725 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4726 | if (NULL == vdev) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4727 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4728 | "%s: Invalid vdev_id %d", __func__, vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4729 | return -EINVAL; |
| 4730 | } |
| 4731 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4732 | qdf_spin_lock_bh(&vdev->flow_control_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4733 | vdev->osif_flow_control_cb = flowControl; |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 4734 | vdev->osif_flow_control_is_pause = flow_control_is_pause; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4735 | vdev->osif_fc_ctx = osif_fc_ctx; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4736 | qdf_spin_unlock_bh(&vdev->flow_control_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4737 | return 0; |
| 4738 | } |
| 4739 | |
| 4740 | /** |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4741 | * ol_txrx_de_register_tx_flow_control_cb() - deregister tx flow control |
| 4742 | * callback |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4743 | * @vdev_id: vdev_id |
| 4744 | * |
| 4745 | * Return: 0 for success or error code |
| 4746 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 4747 | static int ol_txrx_deregister_tx_flow_control_cb(uint8_t vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4748 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4749 | struct ol_txrx_vdev_t *vdev = |
| 4750 | (struct ol_txrx_vdev_t *)ol_txrx_get_vdev_from_vdev_id(vdev_id); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4751 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4752 | if (NULL == vdev) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4753 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4754 | "%s: Invalid vdev_id", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4755 | return -EINVAL; |
| 4756 | } |
| 4757 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4758 | qdf_spin_lock_bh(&vdev->flow_control_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4759 | vdev->osif_flow_control_cb = NULL; |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 4760 | vdev->osif_flow_control_is_pause = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4761 | vdev->osif_fc_ctx = NULL; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4762 | qdf_spin_unlock_bh(&vdev->flow_control_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4763 | return 0; |
| 4764 | } |
| 4765 | |
| 4766 | /** |
| 4767 | * ol_txrx_get_tx_resource() - if tx resource less than low_watermark |
| 4768 | * @sta_id: sta id |
| 4769 | * @low_watermark: low watermark |
| 4770 | * @high_watermark_offset: high watermark offset value |
| 4771 | * |
| 4772 | * Return: true/false |
| 4773 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 4774 | static bool |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4775 | ol_txrx_get_tx_resource(uint8_t sta_id, |
| 4776 | unsigned int low_watermark, |
| 4777 | unsigned int high_watermark_offset) |
| 4778 | { |
| 4779 | ol_txrx_vdev_handle vdev = ol_txrx_get_vdev_from_sta_id(sta_id); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4780 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4781 | if (NULL == vdev) { |
Zhu Jianmin | f7ffe94 | 2017-08-24 10:24:15 +0800 | [diff] [blame] | 4782 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4783 | "%s: Invalid sta_id %d", __func__, sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4784 | /* Return true so caller do not understand that resource |
| 4785 | * is less than low_watermark. |
| 4786 | * sta_id validation will be done in ol_tx_send_data_frame |
| 4787 | * and if sta_id is not registered then host will drop |
| 4788 | * packet. |
| 4789 | */ |
| 4790 | return true; |
| 4791 | } |
| 4792 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4793 | qdf_spin_lock_bh(&vdev->pdev->tx_mutex); |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4794 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4795 | if (vdev->pdev->tx_desc.num_free < (uint16_t) low_watermark) { |
| 4796 | vdev->tx_fl_lwm = (uint16_t) low_watermark; |
| 4797 | vdev->tx_fl_hwm = |
| 4798 | (uint16_t) (low_watermark + high_watermark_offset); |
| 4799 | /* Not enough free resource, stop TX OS Q */ |
Anurag Chouhan | 8e0ccd3 | 2016-02-19 15:30:20 +0530 | [diff] [blame] | 4800 | qdf_atomic_set(&vdev->os_q_paused, 1); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4801 | qdf_spin_unlock_bh(&vdev->pdev->tx_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4802 | return false; |
| 4803 | } |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4804 | qdf_spin_unlock_bh(&vdev->pdev->tx_mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4805 | return true; |
| 4806 | } |
| 4807 | |
| 4808 | /** |
| 4809 | * ol_txrx_ll_set_tx_pause_q_depth() - set pause queue depth |
| 4810 | * @vdev_id: vdev id |
| 4811 | * @pause_q_depth: pause queue depth |
| 4812 | * |
| 4813 | * Return: 0 for success or error code |
| 4814 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 4815 | static int |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4816 | ol_txrx_ll_set_tx_pause_q_depth(uint8_t vdev_id, int pause_q_depth) |
| 4817 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4818 | struct ol_txrx_vdev_t *vdev = |
| 4819 | (struct ol_txrx_vdev_t *)ol_txrx_get_vdev_from_vdev_id(vdev_id); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 4820 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4821 | if (NULL == vdev) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4822 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4823 | "%s: Invalid vdev_id %d", __func__, vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4824 | return -EINVAL; |
| 4825 | } |
| 4826 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4827 | qdf_spin_lock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4828 | vdev->ll_pause.max_q_depth = pause_q_depth; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 4829 | qdf_spin_unlock_bh(&vdev->ll_pause.mutex); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4830 | |
| 4831 | return 0; |
| 4832 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4833 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 4834 | |
Leo Chang | 8e07361 | 2015-11-13 10:55:34 -0800 | [diff] [blame] | 4835 | /** |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4836 | * ol_txrx_display_stats() - Display OL TXRX display stats |
| 4837 | * @value: Module id for which stats needs to be displayed |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 4838 | * |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4839 | * Return: status |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 4840 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4841 | static QDF_STATUS |
| 4842 | ol_txrx_display_stats(void *soc, uint16_t value, |
| 4843 | enum qdf_stats_verbosity_level verb_level) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4844 | { |
| 4845 | ol_txrx_pdev_handle pdev; |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4846 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4847 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4848 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4849 | if (!pdev) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4850 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4851 | "%s: pdev is NULL", __func__); |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4852 | return QDF_STATUS_E_NULL_VALUE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4853 | } |
| 4854 | |
| 4855 | switch (value) { |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4856 | case CDP_TXRX_PATH_STATS: |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 4857 | ol_txrx_stats_display(pdev, verb_level); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4858 | break; |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4859 | case CDP_TXRX_TSO_STATS: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4860 | ol_txrx_stats_display_tso(pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4861 | break; |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4862 | case CDP_DUMP_TX_FLOW_POOL_INFO: |
Manjunathappa Prakash | 6c54736 | 2017-03-30 20:11:47 -0700 | [diff] [blame] | 4863 | ol_tx_dump_flow_pool_info((void *)pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4864 | break; |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4865 | case CDP_TXRX_DESC_STATS: |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4866 | qdf_nbuf_tx_desc_count_display(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4867 | break; |
Orhan K AKYILDIZ | fdd74de | 2016-12-15 12:08:04 -0800 | [diff] [blame] | 4868 | case CDP_WLAN_RX_BUF_DEBUG_STATS: |
| 4869 | htt_display_rx_buf_debug(pdev->htt_pdev); |
| 4870 | break; |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4871 | #ifdef CONFIG_HL_SUPPORT |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4872 | case CDP_SCHEDULER_STATS: |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4873 | ol_tx_sched_cur_state_display(pdev); |
| 4874 | ol_tx_sched_stats_display(pdev); |
| 4875 | break; |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4876 | case CDP_TX_QUEUE_STATS: |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4877 | ol_tx_queue_log_display(pdev); |
| 4878 | break; |
| 4879 | #ifdef FEATURE_HL_GROUP_CREDIT_FLOW_CONTROL |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4880 | case CDP_CREDIT_STATS: |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4881 | ol_tx_dump_group_credit_stats(pdev); |
| 4882 | break; |
| 4883 | #endif |
| 4884 | |
| 4885 | #ifdef DEBUG_HL_LOGGING |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame^] | 4886 | case CDP_BUNDLE_STATS: |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4887 | htt_dump_bundle_stats(pdev->htt_pdev); |
| 4888 | break; |
| 4889 | #endif |
| 4890 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4891 | default: |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4892 | status = QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4893 | break; |
| 4894 | } |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4895 | return status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4896 | } |
| 4897 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4898 | /** |
| 4899 | * ol_txrx_clear_stats() - Clear OL TXRX stats |
| 4900 | * @value: Module id for which stats needs to be cleared |
| 4901 | * |
| 4902 | * Return: None |
| 4903 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 4904 | static void ol_txrx_clear_stats(uint16_t value) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | { |
| 4906 | ol_txrx_pdev_handle pdev; |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4907 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4908 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4909 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4910 | if (!pdev) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4911 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4912 | "%s: pdev is NULL", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4913 | return; |
| 4914 | } |
| 4915 | |
| 4916 | switch (value) { |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4917 | case CDP_TXRX_PATH_STATS: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4918 | ol_txrx_stats_clear(pdev); |
| 4919 | break; |
Yun Park | 1027e8c | 2017-10-13 15:17:37 -0700 | [diff] [blame] | 4920 | case CDP_TXRX_TSO_STATS: |
| 4921 | ol_txrx_tso_stats_clear(pdev); |
| 4922 | break; |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4923 | case CDP_DUMP_TX_FLOW_POOL_INFO: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4924 | ol_tx_clear_flow_pool_stats(); |
| 4925 | break; |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4926 | case CDP_TXRX_DESC_STATS: |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4927 | qdf_nbuf_tx_desc_count_clear(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4928 | break; |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4929 | #ifdef CONFIG_HL_SUPPORT |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4930 | case CDP_SCHEDULER_STATS: |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4931 | ol_tx_sched_stats_clear(pdev); |
| 4932 | break; |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4933 | case CDP_TX_QUEUE_STATS: |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4934 | ol_tx_queue_log_clear(pdev); |
| 4935 | break; |
| 4936 | #ifdef FEATURE_HL_GROUP_CREDIT_FLOW_CONTROL |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4937 | case CDP_CREDIT_STATS: |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4938 | ol_tx_clear_group_credit_stats(pdev); |
| 4939 | break; |
| 4940 | #endif |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 4941 | case CDP_BUNDLE_STATS: |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 4942 | htt_clear_bundle_stats(pdev->htt_pdev); |
| 4943 | break; |
| 4944 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4945 | default: |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4946 | status = QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4947 | break; |
| 4948 | } |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 4949 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4950 | } |
| 4951 | |
| 4952 | /** |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4953 | * ol_txrx_drop_nbuf_list() - drop an nbuf list |
| 4954 | * @buf_list: buffer list to be dropepd |
| 4955 | * |
| 4956 | * Return: int (number of bufs dropped) |
| 4957 | */ |
| 4958 | static inline int ol_txrx_drop_nbuf_list(qdf_nbuf_t buf_list) |
| 4959 | { |
| 4960 | int num_dropped = 0; |
| 4961 | qdf_nbuf_t buf, next_buf; |
| 4962 | ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 4963 | |
| 4964 | buf = buf_list; |
| 4965 | while (buf) { |
Himanshu Agarwal | dd2196a | 2017-07-31 11:38:14 +0530 | [diff] [blame] | 4966 | QDF_NBUF_CB_RX_PEER_CACHED_FRM(buf) = 1; |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4967 | next_buf = qdf_nbuf_queue_next(buf); |
| 4968 | if (pdev) |
| 4969 | TXRX_STATS_MSDU_INCR(pdev, |
| 4970 | rx.dropped_peer_invalid, buf); |
| 4971 | qdf_nbuf_free(buf); |
| 4972 | buf = next_buf; |
| 4973 | num_dropped++; |
| 4974 | } |
| 4975 | return num_dropped; |
| 4976 | } |
| 4977 | |
| 4978 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4979 | * ol_rx_data_cb() - data rx callback |
| 4980 | * @peer: peer |
| 4981 | * @buf_list: buffer list |
Nirav Shah | 36a87bf | 2016-02-22 12:38:46 +0530 | [diff] [blame] | 4982 | * @staid: Station id |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4983 | * |
| 4984 | * Return: None |
| 4985 | */ |
Nirav Shah | 36a87bf | 2016-02-22 12:38:46 +0530 | [diff] [blame] | 4986 | static void ol_rx_data_cb(struct ol_txrx_pdev_t *pdev, |
| 4987 | qdf_nbuf_t buf_list, uint16_t staid) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4988 | { |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 4989 | void *osif_dev; |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 4990 | uint8_t drop_count = 0; |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 4991 | qdf_nbuf_t buf, next_buf; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4992 | QDF_STATUS ret; |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 4993 | ol_txrx_rx_fp data_rx = NULL; |
Nirav Shah | 36a87bf | 2016-02-22 12:38:46 +0530 | [diff] [blame] | 4994 | struct ol_txrx_peer_t *peer; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4995 | |
Jeff Johnson | dac9e38 | 2017-09-24 10:36:08 -0700 | [diff] [blame] | 4996 | if (qdf_unlikely(!pdev)) |
Nirav Shah | 36a87bf | 2016-02-22 12:38:46 +0530 | [diff] [blame] | 4997 | goto free_buf; |
| 4998 | |
| 4999 | /* Do not use peer directly. Derive peer from staid to |
| 5000 | * make sure that peer is valid. |
| 5001 | */ |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 5002 | peer = ol_txrx_peer_get_ref_by_local_id((struct cdp_pdev *)pdev, |
| 5003 | staid, PEER_DEBUG_ID_OL_RX_THREAD); |
Nirav Shah | 36a87bf | 2016-02-22 12:38:46 +0530 | [diff] [blame] | 5004 | if (!peer) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5005 | goto free_buf; |
| 5006 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5007 | qdf_spin_lock_bh(&peer->peer_info_lock); |
Dhanashri Atre | 50141c5 | 2016-04-07 13:15:29 -0700 | [diff] [blame] | 5008 | if (qdf_unlikely(!(peer->state >= OL_TXRX_PEER_STATE_CONN) || |
| 5009 | !peer->vdev->rx)) { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5010 | qdf_spin_unlock_bh(&peer->peer_info_lock); |
Jingxiang Ge | 9f29706 | 2018-01-24 13:31:31 +0800 | [diff] [blame] | 5011 | ol_txrx_peer_release_ref(peer, PEER_DEBUG_ID_OL_RX_THREAD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5012 | goto free_buf; |
| 5013 | } |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 5014 | |
| 5015 | data_rx = peer->vdev->rx; |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 5016 | osif_dev = peer->vdev->osif_dev; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5017 | qdf_spin_unlock_bh(&peer->peer_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5018 | |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5019 | qdf_spin_lock_bh(&peer->bufq_info.bufq_lock); |
| 5020 | if (!list_empty(&peer->bufq_info.cached_bufq)) { |
| 5021 | qdf_spin_unlock_bh(&peer->bufq_info.bufq_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5022 | /* Flush the cached frames to HDD before passing new rx frame */ |
| 5023 | ol_txrx_flush_rx_frames(peer, 0); |
| 5024 | } else |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5025 | qdf_spin_unlock_bh(&peer->bufq_info.bufq_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5026 | |
Jingxiang Ge | 3badb98 | 2018-01-02 17:39:01 +0800 | [diff] [blame] | 5027 | ol_txrx_peer_release_ref(peer, PEER_DEBUG_ID_OL_RX_THREAD); |
| 5028 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5029 | buf = buf_list; |
| 5030 | while (buf) { |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 5031 | next_buf = qdf_nbuf_queue_next(buf); |
| 5032 | qdf_nbuf_set_next(buf, NULL); /* Add NULL terminator */ |
Mohit Khanna | 0696eef | 2016-04-14 16:14:08 -0700 | [diff] [blame] | 5033 | ret = data_rx(osif_dev, buf); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5034 | if (ret != QDF_STATUS_SUCCESS) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 5035 | ol_txrx_err("Frame Rx to HDD failed"); |
Nirav Shah | 6a4eee6 | 2016-04-25 10:15:04 +0530 | [diff] [blame] | 5036 | if (pdev) |
| 5037 | TXRX_STATS_MSDU_INCR(pdev, rx.dropped_err, buf); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 5038 | qdf_nbuf_free(buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5039 | } |
| 5040 | buf = next_buf; |
| 5041 | } |
| 5042 | return; |
| 5043 | |
| 5044 | free_buf: |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5045 | drop_count = ol_txrx_drop_nbuf_list(buf_list); |
| 5046 | ol_txrx_warn("%s:Dropped frames %u", __func__, drop_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5047 | } |
| 5048 | |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5049 | /* print for every 16th packet */ |
| 5050 | #define OL_TXRX_PRINT_RATE_LIMIT_THRESH 0x0f |
| 5051 | struct ol_rx_cached_buf *cache_buf; |
Himanshu Agarwal | d8cffb3 | 2017-04-27 15:41:29 +0530 | [diff] [blame] | 5052 | |
| 5053 | /** helper function to drop packets |
| 5054 | * Note: caller must hold the cached buq lock before invoking |
| 5055 | * this function. Also, it assumes that the pointers passed in |
| 5056 | * are valid (non-NULL) |
| 5057 | */ |
| 5058 | static inline void ol_txrx_drop_frames( |
| 5059 | struct ol_txrx_cached_bufq_t *bufqi, |
| 5060 | qdf_nbuf_t rx_buf_list) |
| 5061 | { |
| 5062 | uint32_t dropped = ol_txrx_drop_nbuf_list(rx_buf_list); |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 5063 | |
Himanshu Agarwal | d8cffb3 | 2017-04-27 15:41:29 +0530 | [diff] [blame] | 5064 | bufqi->dropped += dropped; |
| 5065 | bufqi->qdepth_no_thresh += dropped; |
| 5066 | |
| 5067 | if (bufqi->qdepth_no_thresh > bufqi->high_water_mark) |
| 5068 | bufqi->high_water_mark = bufqi->qdepth_no_thresh; |
| 5069 | } |
| 5070 | |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5071 | static QDF_STATUS ol_txrx_enqueue_rx_frames( |
Himanshu Agarwal | d8cffb3 | 2017-04-27 15:41:29 +0530 | [diff] [blame] | 5072 | struct ol_txrx_peer_t *peer, |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5073 | struct ol_txrx_cached_bufq_t *bufqi, |
| 5074 | qdf_nbuf_t rx_buf_list) |
| 5075 | { |
| 5076 | struct ol_rx_cached_buf *cache_buf; |
| 5077 | qdf_nbuf_t buf, next_buf; |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5078 | static uint32_t count; |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5079 | |
| 5080 | if ((count++ & OL_TXRX_PRINT_RATE_LIMIT_THRESH) == 0) |
| 5081 | ol_txrx_info_high( |
| 5082 | "Data on the peer before it is registered bufq->curr %d bufq->drops %d", |
| 5083 | bufqi->curr, bufqi->dropped); |
| 5084 | |
| 5085 | qdf_spin_lock_bh(&bufqi->bufq_lock); |
| 5086 | if (bufqi->curr >= bufqi->thresh) { |
Himanshu Agarwal | d8cffb3 | 2017-04-27 15:41:29 +0530 | [diff] [blame] | 5087 | ol_txrx_drop_frames(bufqi, rx_buf_list); |
| 5088 | qdf_spin_unlock_bh(&bufqi->bufq_lock); |
| 5089 | return QDF_STATUS_E_FAULT; |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5090 | } |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5091 | qdf_spin_unlock_bh(&bufqi->bufq_lock); |
| 5092 | |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5093 | buf = rx_buf_list; |
| 5094 | while (buf) { |
| 5095 | next_buf = qdf_nbuf_queue_next(buf); |
| 5096 | cache_buf = qdf_mem_malloc(sizeof(*cache_buf)); |
| 5097 | if (!cache_buf) { |
| 5098 | ol_txrx_err( |
| 5099 | "Failed to allocate buf to cache the rx frames"); |
| 5100 | qdf_nbuf_free(buf); |
| 5101 | } else { |
| 5102 | /* Add NULL terminator */ |
| 5103 | qdf_nbuf_set_next(buf, NULL); |
| 5104 | cache_buf->buf = buf; |
Himanshu Agarwal | d8cffb3 | 2017-04-27 15:41:29 +0530 | [diff] [blame] | 5105 | if (peer && peer->valid) { |
| 5106 | qdf_spin_lock_bh(&bufqi->bufq_lock); |
| 5107 | list_add_tail(&cache_buf->list, |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5108 | &bufqi->cached_bufq); |
Himanshu Agarwal | d8cffb3 | 2017-04-27 15:41:29 +0530 | [diff] [blame] | 5109 | bufqi->curr++; |
| 5110 | qdf_spin_unlock_bh(&bufqi->bufq_lock); |
| 5111 | } else { |
| 5112 | qdf_mem_free(cache_buf); |
| 5113 | rx_buf_list = buf; |
| 5114 | qdf_nbuf_set_next(rx_buf_list, next_buf); |
| 5115 | qdf_spin_lock_bh(&bufqi->bufq_lock); |
| 5116 | ol_txrx_drop_frames(bufqi, rx_buf_list); |
| 5117 | qdf_spin_unlock_bh(&bufqi->bufq_lock); |
| 5118 | return QDF_STATUS_E_FAULT; |
| 5119 | } |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5120 | } |
| 5121 | buf = next_buf; |
| 5122 | } |
Himanshu Agarwal | d8cffb3 | 2017-04-27 15:41:29 +0530 | [diff] [blame] | 5123 | return QDF_STATUS_SUCCESS; |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5124 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5125 | /** |
| 5126 | * ol_rx_data_process() - process rx frame |
| 5127 | * @peer: peer |
| 5128 | * @rx_buf_list: rx buffer list |
| 5129 | * |
| 5130 | * Return: None |
| 5131 | */ |
| 5132 | void ol_rx_data_process(struct ol_txrx_peer_t *peer, |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 5133 | qdf_nbuf_t rx_buf_list) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5134 | { |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 5135 | /* |
| 5136 | * Firmware data path active response will use shim RX thread |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5137 | * T2H MSG running on SIRQ context, |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 5138 | * IPA kernel module API should not be called on SIRQ CTXT |
| 5139 | */ |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 5140 | ol_txrx_rx_fp data_rx = NULL; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5141 | ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5142 | uint8_t drop_count; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5143 | |
| 5144 | if ((!peer) || (!pdev)) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 5145 | ol_txrx_err("peer/pdev is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5146 | goto drop_rx_buf; |
| 5147 | } |
| 5148 | |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 5149 | qdf_assert(peer->vdev); |
| 5150 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5151 | qdf_spin_lock_bh(&peer->peer_info_lock); |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 5152 | if (peer->state >= OL_TXRX_PEER_STATE_CONN) |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 5153 | data_rx = peer->vdev->rx; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5154 | qdf_spin_unlock_bh(&peer->peer_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5155 | |
| 5156 | /* |
| 5157 | * If there is a data frame from peer before the peer is |
| 5158 | * registered for data service, enqueue them on to pending queue |
| 5159 | * which will be flushed to HDD once that station is registered. |
| 5160 | */ |
| 5161 | if (!data_rx) { |
Himanshu Agarwal | d8cffb3 | 2017-04-27 15:41:29 +0530 | [diff] [blame] | 5162 | if (ol_txrx_enqueue_rx_frames(peer, &peer->bufq_info, |
| 5163 | rx_buf_list) |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5164 | != QDF_STATUS_SUCCESS) |
Poddar, Siddarth | 07eebf3 | 2017-04-19 12:40:26 +0530 | [diff] [blame] | 5165 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_INFO_HIGH, |
| 5166 | "%s: failed to enqueue rx frm to cached_bufq", |
| 5167 | __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5168 | } else { |
| 5169 | #ifdef QCA_CONFIG_SMP |
| 5170 | /* |
| 5171 | * If the kernel is SMP, schedule rx thread to |
| 5172 | * better use multicores. |
| 5173 | */ |
| 5174 | if (!ol_cfg_is_rx_thread_enabled(pdev->ctrl_pdev)) { |
Nirav Shah | 36a87bf | 2016-02-22 12:38:46 +0530 | [diff] [blame] | 5175 | ol_rx_data_cb(pdev, rx_buf_list, peer->local_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5176 | } else { |
| 5177 | p_cds_sched_context sched_ctx = |
| 5178 | get_cds_sched_ctxt(); |
| 5179 | struct cds_ol_rx_pkt *pkt; |
| 5180 | |
| 5181 | if (unlikely(!sched_ctx)) |
| 5182 | goto drop_rx_buf; |
| 5183 | |
| 5184 | pkt = cds_alloc_ol_rx_pkt(sched_ctx); |
| 5185 | if (!pkt) { |
Kapil Gupta | 53d9b57 | 2017-06-28 17:53:25 +0530 | [diff] [blame] | 5186 | ol_txrx_info_high( |
Siddarth Poddar | b2011f6 | 2016-04-27 20:45:42 +0530 | [diff] [blame] | 5187 | "No available Rx message buffer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5188 | goto drop_rx_buf; |
| 5189 | } |
| 5190 | pkt->callback = (cds_ol_rx_thread_cb) |
| 5191 | ol_rx_data_cb; |
Nirav Shah | 36a87bf | 2016-02-22 12:38:46 +0530 | [diff] [blame] | 5192 | pkt->context = (void *)pdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5193 | pkt->Rxpkt = (void *)rx_buf_list; |
| 5194 | pkt->staId = peer->local_id; |
| 5195 | cds_indicate_rxpkt(sched_ctx, pkt); |
| 5196 | } |
| 5197 | #else /* QCA_CONFIG_SMP */ |
Nirav Shah | 36a87bf | 2016-02-22 12:38:46 +0530 | [diff] [blame] | 5198 | ol_rx_data_cb(pdev, rx_buf_list, peer->local_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5199 | #endif /* QCA_CONFIG_SMP */ |
| 5200 | } |
| 5201 | |
| 5202 | return; |
| 5203 | |
| 5204 | drop_rx_buf: |
Mohit Khanna | 78cb6bb | 2017-03-31 17:05:14 -0700 | [diff] [blame] | 5205 | drop_count = ol_txrx_drop_nbuf_list(rx_buf_list); |
| 5206 | ol_txrx_info_high("Dropped rx packets %u", drop_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5207 | } |
| 5208 | |
| 5209 | /** |
| 5210 | * ol_txrx_register_peer() - register peer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5211 | * @sta_desc: sta descriptor |
| 5212 | * |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 5213 | * Return: QDF Status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5214 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 5215 | static QDF_STATUS ol_txrx_register_peer(struct ol_txrx_desc_type *sta_desc) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5216 | { |
| 5217 | struct ol_txrx_peer_t *peer; |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5218 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5219 | union ol_txrx_peer_update_param_t param; |
| 5220 | struct privacy_exemption privacy_filter; |
| 5221 | |
| 5222 | if (!pdev) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 5223 | ol_txrx_err("Pdev is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5224 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5225 | } |
| 5226 | |
| 5227 | if (sta_desc->sta_id >= WLAN_MAX_STA_COUNT) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 5228 | ol_txrx_err("Invalid sta id :%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5229 | sta_desc->sta_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5230 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5231 | } |
| 5232 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5233 | peer = ol_txrx_peer_find_by_local_id((struct cdp_pdev *)pdev, |
| 5234 | sta_desc->sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5235 | if (!peer) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5236 | return QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5237 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5238 | qdf_spin_lock_bh(&peer->peer_info_lock); |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 5239 | peer->state = OL_TXRX_PEER_STATE_CONN; |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 5240 | qdf_spin_unlock_bh(&peer->peer_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5241 | |
| 5242 | param.qos_capable = sta_desc->is_qos_enabled; |
| 5243 | ol_txrx_peer_update(peer->vdev, peer->mac_addr.raw, ¶m, |
| 5244 | ol_txrx_peer_update_qos_capable); |
| 5245 | |
| 5246 | if (sta_desc->is_wapi_supported) { |
| 5247 | /*Privacy filter to accept unencrypted WAI frames */ |
| 5248 | privacy_filter.ether_type = ETHERTYPE_WAI; |
| 5249 | privacy_filter.filter_type = PRIVACY_FILTER_ALWAYS; |
| 5250 | privacy_filter.packet_type = PRIVACY_FILTER_PACKET_BOTH; |
| 5251 | ol_txrx_set_privacy_filters(peer->vdev, &privacy_filter, 1); |
| 5252 | } |
| 5253 | |
| 5254 | ol_txrx_flush_rx_frames(peer, 0); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5255 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5256 | } |
| 5257 | |
| 5258 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5259 | * ol_txrx_register_ocb_peer - Function to register the OCB peer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5260 | * @mac_addr: MAC address of the self peer |
| 5261 | * @peer_id: Pointer to the peer ID |
| 5262 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5263 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_FAILURE on failure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5264 | */ |
Jeff Johnson | 382bce0 | 2017-09-01 14:21:07 -0700 | [diff] [blame] | 5265 | static QDF_STATUS ol_txrx_register_ocb_peer(uint8_t *mac_addr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5266 | uint8_t *peer_id) |
| 5267 | { |
| 5268 | ol_txrx_pdev_handle pdev; |
| 5269 | ol_txrx_peer_handle peer; |
| 5270 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5271 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5272 | if (!pdev) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 5273 | ol_txrx_err("%s: Unable to find pdev!", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5274 | __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5275 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5276 | } |
| 5277 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5278 | peer = ol_txrx_find_peer_by_addr((struct cdp_pdev *)pdev, |
| 5279 | mac_addr, peer_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5280 | if (!peer) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 5281 | ol_txrx_err("%s: Unable to find OCB peer!", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5282 | __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5283 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5284 | } |
| 5285 | |
| 5286 | ol_txrx_set_ocb_peer(pdev, peer); |
| 5287 | |
| 5288 | /* Set peer state to connected */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5289 | ol_txrx_peer_state_update((struct cdp_pdev *)pdev, peer->mac_addr.raw, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 5290 | OL_TXRX_PEER_STATE_AUTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5291 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5292 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5293 | } |
| 5294 | |
| 5295 | /** |
| 5296 | * ol_txrx_set_ocb_peer - Function to store the OCB peer |
| 5297 | * @pdev: Handle to the HTT instance |
| 5298 | * @peer: Pointer to the peer |
| 5299 | */ |
| 5300 | void ol_txrx_set_ocb_peer(struct ol_txrx_pdev_t *pdev, |
| 5301 | struct ol_txrx_peer_t *peer) |
| 5302 | { |
| 5303 | if (pdev == NULL) |
| 5304 | return; |
| 5305 | |
| 5306 | pdev->ocb_peer = peer; |
| 5307 | pdev->ocb_peer_valid = (NULL != peer); |
| 5308 | } |
| 5309 | |
| 5310 | /** |
| 5311 | * ol_txrx_get_ocb_peer - Function to retrieve the OCB peer |
| 5312 | * @pdev: Handle to the HTT instance |
| 5313 | * @peer: Pointer to the returned peer |
| 5314 | * |
| 5315 | * Return: true if the peer is valid, false if not |
| 5316 | */ |
| 5317 | bool ol_txrx_get_ocb_peer(struct ol_txrx_pdev_t *pdev, |
| 5318 | struct ol_txrx_peer_t **peer) |
| 5319 | { |
| 5320 | int rc; |
| 5321 | |
| 5322 | if ((pdev == NULL) || (peer == NULL)) { |
| 5323 | rc = false; |
| 5324 | goto exit; |
| 5325 | } |
| 5326 | |
| 5327 | if (pdev->ocb_peer_valid) { |
| 5328 | *peer = pdev->ocb_peer; |
| 5329 | rc = true; |
| 5330 | } else { |
| 5331 | rc = false; |
| 5332 | } |
| 5333 | |
| 5334 | exit: |
| 5335 | return rc; |
| 5336 | } |
| 5337 | |
| 5338 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 5339 | /** |
| 5340 | * ol_txrx_register_pause_cb() - register pause callback |
| 5341 | * @pause_cb: pause callback |
| 5342 | * |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 5343 | * Return: QDF status |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5344 | */ |
Manjunathappa Prakash | 6c54736 | 2017-03-30 20:11:47 -0700 | [diff] [blame] | 5345 | static QDF_STATUS ol_txrx_register_pause_cb(struct cdp_soc_t *soc, |
| 5346 | tx_pause_callback pause_cb) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5347 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5348 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Yun Park | eaea863 | 2017-04-09 09:53:45 -0700 | [diff] [blame] | 5349 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5350 | if (!pdev || !pause_cb) { |
Poddar, Siddarth | 1452179 | 2017-03-14 21:19:42 +0530 | [diff] [blame] | 5351 | ol_txrx_err("pdev or pause_cb is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5352 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5353 | } |
| 5354 | pdev->pause_cb = pause_cb; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5355 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5356 | } |
| 5357 | #endif |
| 5358 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 5359 | /** |
| 5360 | * ol_register_data_stall_detect_cb() - register data stall callback |
| 5361 | * @data_stall_detect_callback: data stall callback function |
| 5362 | * |
| 5363 | * |
| 5364 | * Return: QDF_STATUS Enumeration |
| 5365 | */ |
| 5366 | static QDF_STATUS ol_register_data_stall_detect_cb( |
| 5367 | data_stall_detect_cb data_stall_detect_callback) |
| 5368 | { |
| 5369 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 5370 | |
| 5371 | if (pdev == NULL) { |
| 5372 | ol_txrx_err("%s: pdev NULL!", __func__); |
| 5373 | return QDF_STATUS_E_INVAL; |
| 5374 | } |
| 5375 | pdev->data_stall_detect_callback = data_stall_detect_callback; |
| 5376 | return QDF_STATUS_SUCCESS; |
| 5377 | } |
| 5378 | |
| 5379 | /** |
| 5380 | * ol_deregister_data_stall_detect_cb() - de-register data stall callback |
| 5381 | * @data_stall_detect_callback: data stall callback function |
| 5382 | * |
| 5383 | * |
| 5384 | * Return: QDF_STATUS Enumeration |
| 5385 | */ |
| 5386 | static QDF_STATUS ol_deregister_data_stall_detect_cb( |
| 5387 | data_stall_detect_cb data_stall_detect_callback) |
| 5388 | { |
| 5389 | struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 5390 | |
| 5391 | if (pdev == NULL) { |
| 5392 | ol_txrx_err("%s: pdev NULL!", __func__); |
| 5393 | return QDF_STATUS_E_INVAL; |
| 5394 | } |
| 5395 | pdev->data_stall_detect_callback = NULL; |
| 5396 | return QDF_STATUS_SUCCESS; |
| 5397 | } |
| 5398 | |
Poddar, Siddarth | db56816 | 2017-07-27 18:16:38 +0530 | [diff] [blame] | 5399 | /** |
| 5400 | * ol_txrx_post_data_stall_event() - post data stall event |
| 5401 | * @indicator: Module triggering data stall |
| 5402 | * @data_stall_type: data stall event type |
| 5403 | * @pdev_id: pdev id |
| 5404 | * @vdev_id_bitmap: vdev id bitmap |
| 5405 | * @recovery_type: data stall recovery type |
| 5406 | * |
| 5407 | * Return: None |
| 5408 | */ |
| 5409 | static void ol_txrx_post_data_stall_event( |
| 5410 | enum data_stall_log_event_indicator indicator, |
| 5411 | enum data_stall_log_event_type data_stall_type, |
| 5412 | uint32_t pdev_id, uint32_t vdev_id_bitmap, |
| 5413 | enum data_stall_log_recovery_type recovery_type) |
| 5414 | { |
| 5415 | struct scheduler_msg msg = {0}; |
| 5416 | QDF_STATUS status; |
| 5417 | struct data_stall_event_info *data_stall_info; |
| 5418 | ol_txrx_pdev_handle pdev; |
| 5419 | |
| 5420 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 5421 | if (!pdev) { |
| 5422 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 5423 | "%s: pdev is NULL.", __func__); |
| 5424 | return; |
| 5425 | } |
| 5426 | data_stall_info = qdf_mem_malloc(sizeof(*data_stall_info)); |
| 5427 | if (!data_stall_info) { |
| 5428 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 5429 | "%s: data_stall_info is NULL.", __func__); |
| 5430 | return; |
| 5431 | } |
| 5432 | data_stall_info->indicator = indicator; |
| 5433 | data_stall_info->data_stall_type = data_stall_type; |
| 5434 | data_stall_info->vdev_id_bitmap = vdev_id_bitmap; |
| 5435 | data_stall_info->pdev_id = pdev_id; |
| 5436 | data_stall_info->recovery_type = recovery_type; |
| 5437 | |
Poddar, Siddarth | b904759 | 2017-10-05 15:48:28 +0530 | [diff] [blame] | 5438 | if (data_stall_info->data_stall_type == |
| 5439 | DATA_STALL_LOG_FW_RX_REFILL_FAILED) |
| 5440 | htt_log_rx_ring_info(pdev->htt_pdev); |
| 5441 | |
Poddar, Siddarth | db56816 | 2017-07-27 18:16:38 +0530 | [diff] [blame] | 5442 | sys_build_message_header(SYS_MSG_ID_DATA_STALL_MSG, &msg); |
| 5443 | /* Save callback and data */ |
| 5444 | msg.callback = pdev->data_stall_detect_callback; |
| 5445 | msg.bodyptr = data_stall_info; |
| 5446 | msg.bodyval = 0; |
| 5447 | |
| 5448 | status = scheduler_post_msg(QDF_MODULE_ID_SYS, &msg); |
| 5449 | |
| 5450 | if (status != QDF_STATUS_SUCCESS) { |
| 5451 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 5452 | "%s: failed to post data stall msg to SYS", __func__); |
| 5453 | qdf_mem_free(data_stall_info); |
| 5454 | } |
| 5455 | } |
| 5456 | |
Poddar, Siddarth | bd80420 | 2016-11-23 18:19:49 +0530 | [diff] [blame] | 5457 | void |
| 5458 | ol_txrx_dump_pkt(qdf_nbuf_t nbuf, uint32_t nbuf_paddr, int len) |
| 5459 | { |
Jeff Johnson | c13bfe0 | 2017-09-18 08:16:17 -0700 | [diff] [blame] | 5460 | qdf_print("%s: Pkt: VA 0x%pK PA 0x%llx len %d\n", __func__, |
Poddar, Siddarth | bd80420 | 2016-11-23 18:19:49 +0530 | [diff] [blame] | 5461 | qdf_nbuf_data(nbuf), (unsigned long long int)nbuf_paddr, len); |
| 5462 | print_hex_dump(KERN_DEBUG, "Pkt: ", DUMP_PREFIX_ADDRESS, 16, 4, |
| 5463 | qdf_nbuf_data(nbuf), len, true); |
| 5464 | } |
| 5465 | |
Poddar, Siddarth | 8e3ee2d | 2016-11-29 20:17:01 +0530 | [diff] [blame] | 5466 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 5467 | bool |
| 5468 | ol_txrx_fwd_desc_thresh_check(struct ol_txrx_vdev_t *vdev) |
| 5469 | { |
Yun Park | 6366101 | 2018-01-04 15:04:22 -0800 | [diff] [blame] | 5470 | struct ol_tx_flow_pool_t *pool; |
Poddar, Siddarth | 8e3ee2d | 2016-11-29 20:17:01 +0530 | [diff] [blame] | 5471 | bool enough_desc_flag; |
| 5472 | |
| 5473 | if (!vdev) |
Yun Park | ff5da56 | 2017-01-18 14:44:20 -0800 | [diff] [blame] | 5474 | return false; |
Poddar, Siddarth | 8e3ee2d | 2016-11-29 20:17:01 +0530 | [diff] [blame] | 5475 | |
| 5476 | pool = vdev->pool; |
| 5477 | |
Yun Park | ff5da56 | 2017-01-18 14:44:20 -0800 | [diff] [blame] | 5478 | if (!pool) |
| 5479 | return false; |
| 5480 | |
Poddar, Siddarth | 8e3ee2d | 2016-11-29 20:17:01 +0530 | [diff] [blame] | 5481 | qdf_spin_lock_bh(&pool->flow_pool_lock); |
| 5482 | enough_desc_flag = (pool->avail_desc < (pool->stop_th + |
Yun Park | ff5da56 | 2017-01-18 14:44:20 -0800 | [diff] [blame] | 5483 | OL_TX_NON_FWD_RESERVE)) |
| 5484 | ? false : true; |
Poddar, Siddarth | 8e3ee2d | 2016-11-29 20:17:01 +0530 | [diff] [blame] | 5485 | qdf_spin_unlock_bh(&pool->flow_pool_lock); |
| 5486 | return enough_desc_flag; |
| 5487 | } |
| 5488 | #else |
| 5489 | bool ol_txrx_fwd_desc_thresh_check(struct ol_txrx_vdev_t *vdev) |
| 5490 | { |
| 5491 | return true; |
| 5492 | } |
| 5493 | #endif |
| 5494 | |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 5495 | /** |
| 5496 | * ol_txrx_get_vdev_from_vdev_id() - get vdev from vdev_id |
| 5497 | * @vdev_id: vdev_id |
| 5498 | * |
| 5499 | * Return: vdev handle |
| 5500 | * NULL if not found. |
| 5501 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5502 | struct cdp_vdev *ol_txrx_get_vdev_from_vdev_id(uint8_t vdev_id) |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 5503 | { |
| 5504 | ol_txrx_pdev_handle pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 5505 | ol_txrx_vdev_handle vdev = NULL; |
| 5506 | |
| 5507 | if (qdf_unlikely(!pdev)) |
| 5508 | return NULL; |
| 5509 | |
| 5510 | TAILQ_FOREACH(vdev, &pdev->vdev_list, vdev_list_elem) { |
| 5511 | if (vdev->vdev_id == vdev_id) |
| 5512 | break; |
| 5513 | } |
| 5514 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5515 | return (struct cdp_vdev *)vdev; |
Dhanashri Atre | 12a0839 | 2016-02-17 13:10:34 -0800 | [diff] [blame] | 5516 | } |
Nirav Shah | 2e583a0 | 2016-04-30 14:06:12 +0530 | [diff] [blame] | 5517 | |
| 5518 | /** |
| 5519 | * ol_txrx_set_wisa_mode() - set wisa mode |
| 5520 | * @vdev: vdev handle |
| 5521 | * @enable: enable flag |
| 5522 | * |
| 5523 | * Return: QDF STATUS |
| 5524 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5525 | static QDF_STATUS ol_txrx_set_wisa_mode(struct cdp_vdev *pvdev, bool enable) |
Nirav Shah | 2e583a0 | 2016-04-30 14:06:12 +0530 | [diff] [blame] | 5526 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5527 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5528 | |
Nirav Shah | 2e583a0 | 2016-04-30 14:06:12 +0530 | [diff] [blame] | 5529 | if (!vdev) |
| 5530 | return QDF_STATUS_E_INVAL; |
| 5531 | |
| 5532 | vdev->is_wisa_mode_enable = enable; |
| 5533 | return QDF_STATUS_SUCCESS; |
| 5534 | } |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5535 | |
| 5536 | /** |
| 5537 | * ol_txrx_get_vdev_id() - get interface id from interface context |
| 5538 | * @pvdev: vdev handle |
| 5539 | * |
| 5540 | * Return: virtual interface id |
| 5541 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5542 | static uint16_t ol_txrx_get_vdev_id(struct cdp_vdev *pvdev) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5543 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5544 | struct ol_txrx_vdev_t *vdev = (struct ol_txrx_vdev_t *)pvdev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 5545 | |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5546 | return vdev->vdev_id; |
| 5547 | } |
| 5548 | |
| 5549 | /** |
| 5550 | * ol_txrx_last_assoc_received() - get time of last assoc received |
| 5551 | * @ppeer: peer handle |
| 5552 | * |
| 5553 | * Return: pointer of the time of last assoc received |
| 5554 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 5555 | static qdf_time_t *ol_txrx_last_assoc_received(void *ppeer) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5556 | { |
| 5557 | ol_txrx_peer_handle peer = ppeer; |
| 5558 | |
| 5559 | return &peer->last_assoc_rcvd; |
| 5560 | } |
| 5561 | |
| 5562 | /** |
| 5563 | * ol_txrx_last_disassoc_received() - get time of last disassoc received |
| 5564 | * @ppeer: peer handle |
| 5565 | * |
| 5566 | * Return: pointer of the time of last disassoc received |
| 5567 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 5568 | static qdf_time_t *ol_txrx_last_disassoc_received(void *ppeer) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5569 | { |
| 5570 | ol_txrx_peer_handle peer = ppeer; |
| 5571 | |
| 5572 | return &peer->last_disassoc_rcvd; |
| 5573 | } |
| 5574 | |
| 5575 | /** |
| 5576 | * ol_txrx_last_deauth_received() - get time of last deauth received |
| 5577 | * @ppeer: peer handle |
| 5578 | * |
| 5579 | * Return: pointer of the time of last deauth received |
| 5580 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 5581 | static qdf_time_t *ol_txrx_last_deauth_received(void *ppeer) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5582 | { |
| 5583 | ol_txrx_peer_handle peer = ppeer; |
| 5584 | |
| 5585 | return &peer->last_deauth_rcvd; |
| 5586 | } |
| 5587 | |
| 5588 | /** |
| 5589 | * ol_txrx_soc_attach_target() - attach soc target |
| 5590 | * @soc: soc handle |
| 5591 | * |
| 5592 | * MCL legacy OL do nothing here |
| 5593 | * |
| 5594 | * Return: 0 |
| 5595 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 5596 | static int ol_txrx_soc_attach_target(ol_txrx_soc_handle soc) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5597 | { |
| 5598 | /* MCL legacy OL do nothing here */ |
| 5599 | return 0; |
| 5600 | } |
| 5601 | |
| 5602 | /** |
| 5603 | * ol_txrx_soc_detach() - detach soc target |
| 5604 | * @soc: soc handle |
| 5605 | * |
| 5606 | * MCL legacy OL do nothing here |
| 5607 | * |
| 5608 | * Return: noe |
| 5609 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 5610 | static void ol_txrx_soc_detach(void *soc) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5611 | { |
Venkata Sharath Chandra Manchala | 0c2eece | 2017-03-09 17:30:52 -0800 | [diff] [blame] | 5612 | qdf_mem_free(soc); |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5613 | } |
| 5614 | |
| 5615 | /** |
| 5616 | * ol_txrx_pkt_log_con_service() - connect packet log service |
| 5617 | * @ppdev: physical device handle |
| 5618 | * @scn: device context |
| 5619 | * |
| 5620 | * Return: noe |
| 5621 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5622 | static void ol_txrx_pkt_log_con_service(struct cdp_pdev *ppdev, void *scn) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5623 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5624 | struct ol_txrx_pdev_t *pdev = (struct ol_txrx_pdev_t *)ppdev; |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5625 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5626 | htt_pkt_log_init((struct cdp_pdev *)pdev, scn); |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5627 | pktlog_htc_attach(); |
| 5628 | } |
| 5629 | |
| 5630 | /* OL wrapper functions for CDP abstraction */ |
| 5631 | /** |
| 5632 | * ol_txrx_wrapper_flush_rx_frames() - flush rx frames on the queue |
| 5633 | * @peer: peer handle |
| 5634 | * @drop: rx packets drop or deliver |
| 5635 | * |
| 5636 | * Return: none |
| 5637 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 5638 | static void ol_txrx_wrapper_flush_rx_frames(void *peer, bool drop) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5639 | { |
| 5640 | ol_txrx_flush_rx_frames((ol_txrx_peer_handle)peer, drop); |
| 5641 | } |
| 5642 | |
| 5643 | /** |
| 5644 | * ol_txrx_wrapper_get_vdev_from_vdev_id() - get vdev instance from vdev id |
| 5645 | * @ppdev: pdev handle |
| 5646 | * @vdev_id: interface id |
| 5647 | * |
| 5648 | * Return: virtual interface instance |
| 5649 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5650 | static |
| 5651 | struct cdp_vdev *ol_txrx_wrapper_get_vdev_from_vdev_id(struct cdp_pdev *ppdev, |
| 5652 | uint8_t vdev_id) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5653 | { |
| 5654 | return ol_txrx_get_vdev_from_vdev_id(vdev_id); |
| 5655 | } |
| 5656 | |
| 5657 | /** |
| 5658 | * ol_txrx_wrapper_register_peer() - register peer |
| 5659 | * @pdev: pdev handle |
| 5660 | * @sta_desc: peer description |
| 5661 | * |
| 5662 | * Return: QDF STATUS |
| 5663 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5664 | static QDF_STATUS ol_txrx_wrapper_register_peer(struct cdp_pdev *pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5665 | struct ol_txrx_desc_type *sta_desc) |
| 5666 | { |
| 5667 | return ol_txrx_register_peer(sta_desc); |
| 5668 | } |
| 5669 | |
| 5670 | /** |
| 5671 | * ol_txrx_wrapper_peer_find_by_local_id() - Find a txrx peer handle |
| 5672 | * @pdev - the data physical device object |
| 5673 | * @local_peer_id - the ID txrx assigned locally to the peer in question |
| 5674 | * |
| 5675 | * The control SW typically uses the txrx peer handle to refer to the peer. |
| 5676 | * In unusual circumstances, if it is infeasible for the control SW maintain |
| 5677 | * the txrx peer handle but it can maintain a small integer local peer ID, |
| 5678 | * this function allows the peer handled to be retrieved, based on the local |
| 5679 | * peer ID. |
| 5680 | * |
| 5681 | * @return handle to the txrx peer object |
| 5682 | */ |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 5683 | static void * |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5684 | ol_txrx_wrapper_peer_find_by_local_id(struct cdp_pdev *pdev, |
| 5685 | uint8_t local_peer_id) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5686 | { |
| 5687 | return (void *)ol_txrx_peer_find_by_local_id( |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5688 | pdev, local_peer_id); |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5689 | } |
| 5690 | |
| 5691 | /** |
| 5692 | * ol_txrx_wrapper_cfg_is_high_latency() - device is high or low latency device |
| 5693 | * @pdev: pdev handle |
| 5694 | * |
| 5695 | * Return: 1 high latency bus |
| 5696 | * 0 low latency bus |
| 5697 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5698 | static int ol_txrx_wrapper_cfg_is_high_latency(struct cdp_cfg *cfg_pdev) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5699 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5700 | return ol_cfg_is_high_latency(cfg_pdev); |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5701 | } |
| 5702 | |
| 5703 | /** |
| 5704 | * ol_txrx_wrapper_peer_state_update() - specify the peer's authentication state |
| 5705 | * @data_peer - which peer has changed its state |
| 5706 | * @state - the new state of the peer |
| 5707 | * |
| 5708 | * Specify the peer's authentication state (none, connected, authenticated) |
| 5709 | * to allow the data SW to determine whether to filter out invalid data frames. |
| 5710 | * (In the "connected" state, where security is enabled, but authentication |
| 5711 | * has not completed, tx and rx data frames other than EAPOL or WAPI should |
| 5712 | * be discarded.) |
| 5713 | * This function is only relevant for systems in which the tx and rx filtering |
| 5714 | * are done in the host rather than in the target. |
| 5715 | * |
| 5716 | * Return: QDF Status |
| 5717 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5718 | static QDF_STATUS ol_txrx_wrapper_peer_state_update(struct cdp_pdev *pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5719 | uint8_t *peer_mac, enum ol_txrx_peer_state state) |
| 5720 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5721 | return ol_txrx_peer_state_update(pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5722 | peer_mac, state); |
| 5723 | } |
| 5724 | |
| 5725 | /** |
| 5726 | * ol_txrx_wrapper_find_peer_by_addr() - find peer instance by address |
| 5727 | * @pdev: pdev handle |
| 5728 | * @peer_addr: peer address wnat to find |
| 5729 | * @peer_id: peer id |
| 5730 | * |
| 5731 | * Return: peer instance pointer |
| 5732 | */ |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5733 | static void *ol_txrx_wrapper_find_peer_by_addr(struct cdp_pdev *pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5734 | uint8_t *peer_addr, uint8_t *peer_id) |
| 5735 | { |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5736 | return ol_txrx_find_peer_by_addr(pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5737 | peer_addr, peer_id); |
| 5738 | } |
| 5739 | |
| 5740 | /** |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 5741 | * ol_txrx_wrapper_peer_get_ref_by_addr() - get peer reference by address |
| 5742 | * @pdev: pdev handle |
| 5743 | * @peer_addr: peer address we want to find |
| 5744 | * @peer_id: peer id |
| 5745 | * @debug_id: peer debug id for tracking |
| 5746 | * |
| 5747 | * Return: peer instance pointer |
| 5748 | */ |
| 5749 | static void * |
| 5750 | ol_txrx_wrapper_peer_get_ref_by_addr(struct cdp_pdev *pdev, |
| 5751 | u8 *peer_addr, uint8_t *peer_id, |
| 5752 | enum peer_debug_id_type debug_id) |
| 5753 | { |
| 5754 | return ol_txrx_peer_get_ref_by_addr((ol_txrx_pdev_handle)pdev, |
| 5755 | peer_addr, peer_id, debug_id); |
| 5756 | } |
| 5757 | |
| 5758 | /** |
| 5759 | * ol_txrx_wrapper_peer_release_ref() - release peer reference |
| 5760 | * @peer: peer handle |
| 5761 | * @debug_id: peer debug id for tracking |
| 5762 | * |
| 5763 | * Release peer ref acquired by peer get ref api |
| 5764 | * |
| 5765 | * Return: void |
| 5766 | */ |
| 5767 | static void ol_txrx_wrapper_peer_release_ref(void *peer, |
| 5768 | enum peer_debug_id_type debug_id) |
| 5769 | { |
| 5770 | ol_txrx_peer_release_ref(peer, debug_id); |
| 5771 | } |
| 5772 | |
| 5773 | /** |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5774 | * ol_txrx_wrapper_set_flow_control_parameters() - set flow control parameters |
| 5775 | * @cfg_ctx: cfg context |
| 5776 | * @cfg_param: cfg parameters |
| 5777 | * |
| 5778 | * Return: none |
| 5779 | */ |
Jeff Johnson | ffa9afc | 2016-12-19 15:34:41 -0800 | [diff] [blame] | 5780 | static void |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5781 | ol_txrx_wrapper_set_flow_control_parameters(struct cdp_cfg *cfg_pdev, |
| 5782 | void *cfg_param) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5783 | { |
| 5784 | return ol_tx_set_flow_control_parameters( |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5785 | cfg_pdev, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5786 | (struct txrx_pdev_cfg_param_t *)cfg_param); |
| 5787 | } |
| 5788 | |
Venkata Sharath Chandra Manchala | 2996517 | 2018-01-18 14:17:29 -0800 | [diff] [blame] | 5789 | #ifdef WDI_EVENT_ENABLE |
| 5790 | void *ol_get_pldev(struct cdp_pdev *txrx_pdev) |
| 5791 | { |
| 5792 | struct ol_txrx_pdev_t *pdev = |
| 5793 | (struct ol_txrx_pdev_t *)txrx_pdev; |
| 5794 | if (pdev != NULL) |
| 5795 | return pdev->pl_dev; |
| 5796 | |
| 5797 | return NULL; |
| 5798 | } |
| 5799 | #endif |
| 5800 | |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5801 | static struct cdp_cmn_ops ol_ops_cmn = { |
| 5802 | .txrx_soc_attach_target = ol_txrx_soc_attach_target, |
| 5803 | .txrx_vdev_attach = ol_txrx_vdev_attach, |
| 5804 | .txrx_vdev_detach = ol_txrx_vdev_detach, |
| 5805 | .txrx_pdev_attach = ol_txrx_pdev_attach, |
| 5806 | .txrx_pdev_attach_target = ol_txrx_pdev_attach_target, |
| 5807 | .txrx_pdev_post_attach = ol_txrx_pdev_post_attach, |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 5808 | .txrx_pdev_pre_detach = ol_txrx_pdev_pre_detach, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5809 | .txrx_pdev_detach = ol_txrx_pdev_detach, |
Dhanashri Atre | 272fd23 | 2016-11-10 16:20:46 -0800 | [diff] [blame] | 5810 | .txrx_peer_create = ol_txrx_peer_attach, |
| 5811 | .txrx_peer_setup = NULL, |
| 5812 | .txrx_peer_teardown = NULL, |
| 5813 | .txrx_peer_delete = ol_txrx_peer_detach, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5814 | .txrx_vdev_register = ol_txrx_vdev_register, |
| 5815 | .txrx_soc_detach = ol_txrx_soc_detach, |
| 5816 | .txrx_get_vdev_mac_addr = ol_txrx_get_vdev_mac_addr, |
| 5817 | .txrx_get_vdev_from_vdev_id = ol_txrx_wrapper_get_vdev_from_vdev_id, |
| 5818 | .txrx_get_ctrl_pdev_from_vdev = ol_txrx_get_ctrl_pdev_from_vdev, |
Krishna Kumaar Natarajan | 5fb9ac1 | 2016-12-06 14:28:35 -0800 | [diff] [blame] | 5819 | .txrx_mgmt_send_ext = ol_txrx_mgmt_send_ext, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5820 | .txrx_mgmt_tx_cb_set = ol_txrx_mgmt_tx_cb_set, |
| 5821 | .txrx_data_tx_cb_set = ol_txrx_data_tx_cb_set, |
| 5822 | .txrx_get_tx_pending = ol_txrx_get_tx_pending, |
Manikandan Mohan | 8b4e201 | 2017-03-22 11:15:55 -0700 | [diff] [blame] | 5823 | .flush_cache_rx_queue = ol_txrx_flush_cache_rx_queue, |
Venkata Sharath Chandra Manchala | 71032b6 | 2017-03-29 12:30:45 -0700 | [diff] [blame] | 5824 | .txrx_fw_stats_get = ol_txrx_fw_stats_get, |
| 5825 | .display_stats = ol_txrx_display_stats, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5826 | /* TODO: Add other functions */ |
| 5827 | }; |
| 5828 | |
| 5829 | static struct cdp_misc_ops ol_ops_misc = { |
| 5830 | .set_ibss_vdev_heart_beat_timer = |
| 5831 | ol_txrx_set_ibss_vdev_heart_beat_timer, |
| 5832 | #ifdef CONFIG_HL_SUPPORT |
| 5833 | .set_wmm_param = ol_txrx_set_wmm_param, |
| 5834 | #endif /* CONFIG_HL_SUPPORT */ |
| 5835 | .bad_peer_txctl_set_setting = ol_txrx_bad_peer_txctl_set_setting, |
| 5836 | .bad_peer_txctl_update_threshold = |
| 5837 | ol_txrx_bad_peer_txctl_update_threshold, |
| 5838 | .hl_tdls_flag_reset = ol_txrx_hl_tdls_flag_reset, |
| 5839 | .tx_non_std = ol_tx_non_std, |
| 5840 | .get_vdev_id = ol_txrx_get_vdev_id, |
| 5841 | .set_wisa_mode = ol_txrx_set_wisa_mode, |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 5842 | .txrx_data_stall_cb_register = ol_register_data_stall_detect_cb, |
| 5843 | .txrx_data_stall_cb_deregister = ol_deregister_data_stall_detect_cb, |
Poddar, Siddarth | db56816 | 2017-07-27 18:16:38 +0530 | [diff] [blame] | 5844 | .txrx_post_data_stall_event = ol_txrx_post_data_stall_event, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5845 | #ifdef FEATURE_RUNTIME_PM |
| 5846 | .runtime_suspend = ol_txrx_runtime_suspend, |
| 5847 | .runtime_resume = ol_txrx_runtime_resume, |
| 5848 | #endif /* FEATURE_RUNTIME_PM */ |
| 5849 | .get_opmode = ol_txrx_get_opmode, |
| 5850 | .mark_first_wakeup_packet = ol_tx_mark_first_wakeup_packet, |
| 5851 | .update_mac_id = ol_txrx_update_mac_id, |
| 5852 | .flush_rx_frames = ol_txrx_wrapper_flush_rx_frames, |
| 5853 | .get_intra_bss_fwd_pkts_count = ol_get_intra_bss_fwd_pkts_count, |
| 5854 | .pkt_log_init = htt_pkt_log_init, |
| 5855 | .pkt_log_con_service = ol_txrx_pkt_log_con_service |
| 5856 | }; |
| 5857 | |
| 5858 | static struct cdp_flowctl_ops ol_ops_flowctl = { |
| 5859 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 5860 | .register_pause_cb = ol_txrx_register_pause_cb, |
| 5861 | .set_desc_global_pool_size = ol_tx_set_desc_global_pool_size, |
Manjunathappa Prakash | 6c54736 | 2017-03-30 20:11:47 -0700 | [diff] [blame] | 5862 | .dump_flow_pool_info = ol_tx_dump_flow_pool_info, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5863 | #endif /* QCA_LL_TX_FLOW_CONTROL_V2 */ |
| 5864 | }; |
| 5865 | |
| 5866 | static struct cdp_lflowctl_ops ol_ops_l_flowctl = { |
| 5867 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5868 | .register_tx_flow_control = ol_txrx_register_tx_flow_control, |
| 5869 | .deregister_tx_flow_control_cb = ol_txrx_deregister_tx_flow_control_cb, |
| 5870 | .flow_control_cb = ol_txrx_flow_control_cb, |
| 5871 | .get_tx_resource = ol_txrx_get_tx_resource, |
| 5872 | .ll_set_tx_pause_q_depth = ol_txrx_ll_set_tx_pause_q_depth, |
| 5873 | .vdev_flush = ol_txrx_vdev_flush, |
| 5874 | .vdev_pause = ol_txrx_vdev_pause, |
| 5875 | .vdev_unpause = ol_txrx_vdev_unpause |
| 5876 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 5877 | }; |
| 5878 | |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5879 | #ifdef IPA_OFFLOAD |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame] | 5880 | static struct cdp_ipa_ops ol_ops_ipa = { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5881 | .ipa_get_resource = ol_txrx_ipa_uc_get_resource, |
| 5882 | .ipa_set_doorbell_paddr = ol_txrx_ipa_uc_set_doorbell_paddr, |
| 5883 | .ipa_set_active = ol_txrx_ipa_uc_set_active, |
| 5884 | .ipa_op_response = ol_txrx_ipa_uc_op_response, |
| 5885 | .ipa_register_op_cb = ol_txrx_ipa_uc_register_op_cb, |
| 5886 | .ipa_get_stat = ol_txrx_ipa_uc_get_stat, |
| 5887 | .ipa_tx_data_frame = ol_tx_send_ipa_data_frame, |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 5888 | .ipa_set_uc_tx_partition_base = ol_cfg_set_ipa_uc_tx_partition_base, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame] | 5889 | .ipa_enable_autonomy = ol_txrx_ipa_enable_autonomy, |
| 5890 | .ipa_disable_autonomy = ol_txrx_ipa_disable_autonomy, |
| 5891 | .ipa_setup = ol_txrx_ipa_setup, |
| 5892 | .ipa_cleanup = ol_txrx_ipa_cleanup, |
| 5893 | .ipa_setup_iface = ol_txrx_ipa_setup_iface, |
| 5894 | .ipa_cleanup_iface = ol_txrx_ipa_cleanup_iface, |
| 5895 | .ipa_enable_pipes = ol_txrx_ipa_enable_pipes, |
| 5896 | .ipa_disable_pipes = ol_txrx_ipa_disable_pipes, |
| 5897 | .ipa_set_perf_level = ol_txrx_ipa_set_perf_level, |
| 5898 | #ifdef FEATURE_METERING |
Yun Park | 637d648 | 2016-10-05 10:51:33 -0700 | [diff] [blame] | 5899 | .ipa_uc_get_share_stats = ol_txrx_ipa_uc_get_share_stats, |
| 5900 | .ipa_uc_set_quota = ol_txrx_ipa_uc_set_quota |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame] | 5901 | #endif |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5902 | }; |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame] | 5903 | #endif |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5904 | |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5905 | static struct cdp_bus_ops ol_ops_bus = { |
| 5906 | .bus_suspend = ol_txrx_bus_suspend, |
| 5907 | .bus_resume = ol_txrx_bus_resume |
| 5908 | }; |
| 5909 | |
| 5910 | static struct cdp_ocb_ops ol_ops_ocb = { |
| 5911 | .set_ocb_chan_info = ol_txrx_set_ocb_chan_info, |
| 5912 | .get_ocb_chan_info = ol_txrx_get_ocb_chan_info |
| 5913 | }; |
| 5914 | |
| 5915 | static struct cdp_throttle_ops ol_ops_throttle = { |
Jeff Johnson | b13a501 | 2016-12-21 08:41:16 -0800 | [diff] [blame] | 5916 | #ifdef QCA_SUPPORT_TX_THROTTLE |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5917 | .throttle_init_period = ol_tx_throttle_init_period, |
| 5918 | .throttle_set_level = ol_tx_throttle_set_level |
Jeff Johnson | b13a501 | 2016-12-21 08:41:16 -0800 | [diff] [blame] | 5919 | #endif /* QCA_SUPPORT_TX_THROTTLE */ |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5920 | }; |
| 5921 | |
| 5922 | static struct cdp_mob_stats_ops ol_ops_mob_stats = { |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5923 | .clear_stats = ol_txrx_clear_stats, |
| 5924 | .stats = ol_txrx_stats |
| 5925 | }; |
| 5926 | |
| 5927 | static struct cdp_cfg_ops ol_ops_cfg = { |
| 5928 | .set_cfg_rx_fwd_disabled = ol_set_cfg_rx_fwd_disabled, |
| 5929 | .set_cfg_packet_log_enabled = ol_set_cfg_packet_log_enabled, |
| 5930 | .cfg_attach = ol_pdev_cfg_attach, |
| 5931 | .vdev_rx_set_intrabss_fwd = ol_vdev_rx_set_intrabss_fwd, |
| 5932 | .is_rx_fwd_disabled = ol_txrx_is_rx_fwd_disabled, |
| 5933 | .tx_set_is_mgmt_over_wmi_enabled = ol_tx_set_is_mgmt_over_wmi_enabled, |
| 5934 | .is_high_latency = ol_txrx_wrapper_cfg_is_high_latency, |
| 5935 | .set_flow_control_parameters = |
| 5936 | ol_txrx_wrapper_set_flow_control_parameters, |
| 5937 | .set_flow_steering = ol_set_cfg_flow_steering, |
Yu Wang | 66a250b | 2017-07-19 11:46:40 +0800 | [diff] [blame] | 5938 | .set_ptp_rx_opt_enabled = ol_set_cfg_ptp_rx_opt_enabled, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5939 | }; |
| 5940 | |
| 5941 | static struct cdp_peer_ops ol_ops_peer = { |
| 5942 | .register_peer = ol_txrx_wrapper_register_peer, |
| 5943 | .clear_peer = ol_txrx_clear_peer, |
Mohit Khanna | b7bec72 | 2017-11-10 11:43:44 -0800 | [diff] [blame] | 5944 | .peer_get_ref_by_addr = ol_txrx_wrapper_peer_get_ref_by_addr, |
| 5945 | .peer_release_ref = ol_txrx_wrapper_peer_release_ref, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5946 | .find_peer_by_addr = ol_txrx_wrapper_find_peer_by_addr, |
| 5947 | .find_peer_by_addr_and_vdev = ol_txrx_find_peer_by_addr_and_vdev, |
| 5948 | .local_peer_id = ol_txrx_local_peer_id, |
| 5949 | .peer_find_by_local_id = ol_txrx_wrapper_peer_find_by_local_id, |
| 5950 | .peer_state_update = ol_txrx_wrapper_peer_state_update, |
| 5951 | .get_vdevid = ol_txrx_get_vdevid, |
| 5952 | .get_vdev_by_sta_id = ol_txrx_get_vdev_by_sta_id, |
| 5953 | .register_ocb_peer = ol_txrx_register_ocb_peer, |
| 5954 | .peer_get_peer_mac_addr = ol_txrx_peer_get_peer_mac_addr, |
| 5955 | .get_peer_state = ol_txrx_get_peer_state, |
| 5956 | .get_vdev_for_peer = ol_txrx_get_vdev_for_peer, |
| 5957 | .update_ibss_add_peer_num_of_vdev = |
| 5958 | ol_txrx_update_ibss_add_peer_num_of_vdev, |
| 5959 | .remove_peers_for_vdev = ol_txrx_remove_peers_for_vdev, |
| 5960 | .remove_peers_for_vdev_no_lock = ol_txrx_remove_peers_for_vdev_no_lock, |
Yu Wang | 053d3e7 | 2017-02-08 18:48:24 +0800 | [diff] [blame] | 5961 | #if defined(CONFIG_HL_SUPPORT) && defined(FEATURE_WLAN_TDLS) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5962 | .copy_mac_addr_raw = ol_txrx_copy_mac_addr_raw, |
| 5963 | .add_last_real_peer = ol_txrx_add_last_real_peer, |
Jeff Johnson | 2338e1a | 2016-12-16 15:59:24 -0800 | [diff] [blame] | 5964 | .is_vdev_restore_last_peer = is_vdev_restore_last_peer, |
| 5965 | .update_last_real_peer = ol_txrx_update_last_real_peer, |
| 5966 | #endif /* CONFIG_HL_SUPPORT */ |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5967 | .last_assoc_received = ol_txrx_last_assoc_received, |
| 5968 | .last_disassoc_received = ol_txrx_last_disassoc_received, |
| 5969 | .last_deauth_received = ol_txrx_last_deauth_received, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5970 | .peer_detach_force_delete = ol_txrx_peer_detach_force_delete, |
| 5971 | }; |
| 5972 | |
| 5973 | static struct cdp_tx_delay_ops ol_ops_delay = { |
| 5974 | #ifdef QCA_COMPUTE_TX_DELAY |
| 5975 | .tx_delay = ol_tx_delay, |
| 5976 | .tx_delay_hist = ol_tx_delay_hist, |
| 5977 | .tx_packet_count = ol_tx_packet_count, |
| 5978 | .tx_set_compute_interval = ol_tx_set_compute_interval |
| 5979 | #endif /* QCA_COMPUTE_TX_DELAY */ |
| 5980 | }; |
| 5981 | |
| 5982 | static struct cdp_pmf_ops ol_ops_pmf = { |
| 5983 | .get_pn_info = ol_txrx_get_pn_info |
| 5984 | }; |
| 5985 | |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5986 | static struct cdp_ctrl_ops ol_ops_ctrl = { |
Hanumanth Reddy Pothula | 855f7ef | 2018-02-13 18:32:05 +0530 | [diff] [blame] | 5987 | .txrx_get_pldev = ol_get_pldev, |
Venkata Sharath Chandra Manchala | 2996517 | 2018-01-18 14:17:29 -0800 | [diff] [blame] | 5988 | .txrx_wdi_event_sub = wdi_event_sub, |
| 5989 | .txrx_wdi_event_unsub = wdi_event_unsub, |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5990 | }; |
| 5991 | |
Hanumanth Reddy Pothula | 855f7ef | 2018-02-13 18:32:05 +0530 | [diff] [blame] | 5992 | /* WINplatform specific structures */ |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 5993 | static struct cdp_me_ops ol_ops_me = { |
| 5994 | /* EMPTY FOR MCL */ |
| 5995 | }; |
| 5996 | |
| 5997 | static struct cdp_mon_ops ol_ops_mon = { |
| 5998 | /* EMPTY FOR MCL */ |
| 5999 | }; |
| 6000 | |
| 6001 | static struct cdp_host_stats_ops ol_ops_host_stats = { |
| 6002 | /* EMPTY FOR MCL */ |
| 6003 | }; |
| 6004 | |
| 6005 | static struct cdp_wds_ops ol_ops_wds = { |
| 6006 | /* EMPTY FOR MCL */ |
| 6007 | }; |
| 6008 | |
| 6009 | static struct cdp_raw_ops ol_ops_raw = { |
| 6010 | /* EMPTY FOR MCL */ |
| 6011 | }; |
| 6012 | |
| 6013 | static struct cdp_ops ol_txrx_ops = { |
| 6014 | .cmn_drv_ops = &ol_ops_cmn, |
| 6015 | .ctrl_ops = &ol_ops_ctrl, |
| 6016 | .me_ops = &ol_ops_me, |
| 6017 | .mon_ops = &ol_ops_mon, |
| 6018 | .host_stats_ops = &ol_ops_host_stats, |
| 6019 | .wds_ops = &ol_ops_wds, |
| 6020 | .raw_ops = &ol_ops_raw, |
| 6021 | .misc_ops = &ol_ops_misc, |
| 6022 | .cfg_ops = &ol_ops_cfg, |
| 6023 | .flowctl_ops = &ol_ops_flowctl, |
| 6024 | .l_flowctl_ops = &ol_ops_l_flowctl, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame] | 6025 | #ifdef IPA_OFFLOAD |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 6026 | .ipa_ops = &ol_ops_ipa, |
Yun Park | b4f591d | 2017-03-29 15:51:01 -0700 | [diff] [blame] | 6027 | #endif |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 6028 | .bus_ops = &ol_ops_bus, |
| 6029 | .ocb_ops = &ol_ops_ocb, |
| 6030 | .peer_ops = &ol_ops_peer, |
| 6031 | .throttle_ops = &ol_ops_throttle, |
| 6032 | .mob_stats_ops = &ol_ops_mob_stats, |
| 6033 | .delay_ops = &ol_ops_delay, |
| 6034 | .pmf_ops = &ol_ops_pmf |
| 6035 | }; |
| 6036 | |
Jeff Johnson | 02c37b4 | 2017-01-10 14:49:24 -0800 | [diff] [blame] | 6037 | /* |
| 6038 | * Local prototype added to temporarily address warning caused by |
| 6039 | * -Wmissing-prototypes. A more correct solution, namely to expose |
| 6040 | * a prototype in an appropriate header file, will come later. |
| 6041 | */ |
| 6042 | struct cdp_soc_t *ol_txrx_soc_attach(void *scn_handle, |
| 6043 | struct ol_if_ops *dp_ol_if_ops); |
| 6044 | struct cdp_soc_t *ol_txrx_soc_attach(void *scn_handle, |
| 6045 | struct ol_if_ops *dp_ol_if_ops) |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 6046 | { |
| 6047 | struct cdp_soc_t *soc = qdf_mem_malloc(sizeof(struct cdp_soc_t)); |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 6048 | |
Leo Chang | 9872676 | 2016-10-28 11:07:18 -0700 | [diff] [blame] | 6049 | if (!soc) { |
| 6050 | QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR, |
| 6051 | "%s: OL SOC memory allocation failed\n", __func__); |
| 6052 | return NULL; |
| 6053 | } |
| 6054 | |
| 6055 | soc->ops = &ol_txrx_ops; |
| 6056 | return soc; |
| 6057 | } |
| 6058 | |
| 6059 | |