Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Yun Park | e423980 | 2018-01-09 11:01:40 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 19 | /* denote that this file does not allow legacy hddLog */ |
| 20 | #define HDD_DISALLOW_LEGACY_HDDLOG 1 |
| 21 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 22 | /* Include files */ |
| 23 | #include <linux/semaphore.h> |
| 24 | #include <wlan_hdd_tx_rx.h> |
| 25 | #include <wlan_hdd_softap_tx_rx.h> |
| 26 | #include <linux/netdevice.h> |
| 27 | #include <linux/skbuff.h> |
| 28 | #include <linux/etherdevice.h> |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 29 | #include <qdf_types.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 30 | #include <ani_global.h> |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 31 | #include <qdf_types.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 32 | #include <net/ieee80211_radiotap.h> |
| 33 | #include <cds_sched.h> |
| 34 | #include <wlan_hdd_napi.h> |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 35 | #include <cdp_txrx_cmn.h> |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 36 | #include <cdp_txrx_peer_ops.h> |
Manjunathappa Prakash | 779e486 | 2016-09-12 17:00:11 -0700 | [diff] [blame] | 37 | #include <cds_utils.h> |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 38 | #include <cdp_txrx_flow_ctrl_v2.h> |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 39 | #include <cdp_txrx_misc.h> |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 40 | #include <wlan_hdd_object_manager.h> |
Rachit Kankane | 2487f8f | 2017-04-19 14:30:19 +0530 | [diff] [blame] | 41 | #include "wlan_p2p_ucfg_api.h" |
Mukul Sharma | ecf8e09 | 2017-12-19 22:36:31 +0530 | [diff] [blame] | 42 | #include <wlan_hdd_regulatory.h> |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 43 | #include "wlan_ipa_ucfg_api.h" |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 44 | #include <wma_types.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 45 | |
| 46 | /* Preprocessor definitions and constants */ |
| 47 | #undef QCA_HDD_SAP_DUMP_SK_BUFF |
| 48 | |
| 49 | /* Type declarations */ |
| 50 | |
| 51 | /* Function definitions and documenation */ |
| 52 | #ifdef QCA_HDD_SAP_DUMP_SK_BUFF |
| 53 | /** |
| 54 | * hdd_softap_dump_sk_buff() - Dump an skb |
| 55 | * @skb: skb to dump |
| 56 | * |
| 57 | * Return: None |
| 58 | */ |
| 59 | static void hdd_softap_dump_sk_buff(struct sk_buff *skb) |
| 60 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 61 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 62 | "%s: head = %pK ", __func__, skb->head); |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 63 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO, |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 64 | "%s: tail = %pK ", __func__, skb->tail); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 65 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 66 | "%s: end = %pK ", __func__, skb->end); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 67 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 68 | "%s: len = %d ", __func__, skb->len); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 69 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 70 | "%s: data_len = %d ", __func__, skb->data_len); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 71 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 72 | "%s: mac_len = %d", __func__, skb->mac_len); |
| 73 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 74 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 75 | "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ", skb->data[0], |
| 76 | skb->data[1], skb->data[2], skb->data[3], skb->data[4], |
| 77 | skb->data[5], skb->data[6], skb->data[7]); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 78 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[8], |
| 80 | skb->data[9], skb->data[10], skb->data[11], skb->data[12], |
| 81 | skb->data[13], skb->data[14], skb->data[15]); |
| 82 | } |
| 83 | #else |
| 84 | static void hdd_softap_dump_sk_buff(struct sk_buff *skb) |
| 85 | { |
| 86 | } |
| 87 | #endif |
| 88 | |
| 89 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 90 | /** |
| 91 | * hdd_softap_tx_resume_timer_expired_handler() - TX Q resume timer handler |
| 92 | * @adapter_context: pointer to vdev adapter |
| 93 | * |
| 94 | * TX Q resume timer handler for SAP and P2P GO interface. If Blocked |
| 95 | * OS Q is not resumed during timeout period, to prevent permanent |
| 96 | * stall, resume OS Q forcefully for SAP and P2P GO interface. |
| 97 | * |
| 98 | * Return: None |
| 99 | */ |
| 100 | void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context) |
| 101 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 102 | struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 103 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 104 | if (!adapter) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 105 | hdd_err("NULL adapter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 106 | return; |
| 107 | } |
| 108 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 109 | hdd_debug("Enabling queues"); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 110 | wlan_hdd_netif_queue_control(adapter, WLAN_WAKE_ALL_NETIF_QUEUE, |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 111 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 112 | } |
| 113 | |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 114 | #if defined(CONFIG_PER_VDEV_TX_DESC_POOL) |
| 115 | |
| 116 | /** |
| 117 | * hdd_softap_tx_resume_false() - Resume OS TX Q false leads to queue disabling |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 118 | * @adapter: pointer to hdd adapter |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 119 | * @tx_resume: TX Q resume trigger |
| 120 | * |
| 121 | * |
| 122 | * Return: None |
| 123 | */ |
| 124 | static void |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 125 | hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume) |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 126 | { |
| 127 | if (true == tx_resume) |
| 128 | return; |
| 129 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 130 | hdd_debug("Disabling queues"); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 131 | wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE, |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 132 | WLAN_DATA_FLOW_CONTROL); |
| 133 | |
| 134 | if (QDF_TIMER_STATE_STOPPED == |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 135 | qdf_mc_timer_get_current_state(&adapter-> |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 136 | tx_flow_control_timer)) { |
| 137 | QDF_STATUS status; |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 138 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 139 | status = qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 140 | WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 141 | |
| 142 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 143 | hdd_err("Failed to start tx_flow_control_timer"); |
| 144 | else |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 145 | adapter->hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 146 | } |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 147 | } |
| 148 | #else |
| 149 | |
| 150 | static inline void |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 151 | hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume) |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 152 | { |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 153 | } |
| 154 | #endif |
| 155 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 156 | /** |
| 157 | * hdd_softap_tx_resume_cb() - Resume OS TX Q. |
| 158 | * @adapter_context: pointer to vdev apdapter |
| 159 | * @tx_resume: TX Q resume trigger |
| 160 | * |
| 161 | * Q was stopped due to WLAN TX path low resource condition |
| 162 | * |
| 163 | * Return: None |
| 164 | */ |
| 165 | void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume) |
| 166 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 167 | struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 168 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 169 | if (!adapter) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 170 | hdd_err("NULL adapter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 171 | return; |
| 172 | } |
| 173 | |
| 174 | /* Resume TX */ |
| 175 | if (true == tx_resume) { |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 176 | if (QDF_TIMER_STATE_STOPPED != |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 177 | qdf_mc_timer_get_current_state(&adapter-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 178 | tx_flow_control_timer)) { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 179 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 180 | } |
| 181 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 182 | hdd_debug("Enabling queues"); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 183 | wlan_hdd_netif_queue_control(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 184 | WLAN_WAKE_ALL_NETIF_QUEUE, |
| 185 | WLAN_DATA_FLOW_CONTROL); |
| 186 | } |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 187 | hdd_softap_tx_resume_false(adapter, tx_resume); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 188 | } |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 189 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 190 | static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter, |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 191 | struct sk_buff *skb) |
| 192 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 193 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 194 | int need_orphan = 0; |
| 195 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 196 | if (adapter->tx_flow_low_watermark > 0) { |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 197 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0)) |
| 198 | /* |
| 199 | * The TCP TX throttling logic is changed a little after |
| 200 | * 3.19-rc1 kernel, the TCP sending limit will be smaller, |
| 201 | * which will throttle the TCP packets to the host driver. |
| 202 | * The TCP UP LINK throughput will drop heavily. In order to |
| 203 | * fix this issue, need to orphan the socket buffer asap, which |
| 204 | * will call skb's destructor to notify the TCP stack that the |
| 205 | * SKB buffer is unowned. And then the TCP stack will pump more |
| 206 | * packets to host driver. |
| 207 | * |
| 208 | * The TX packets might be dropped for UDP case in the iperf |
| 209 | * testing. So need to be protected by follow control. |
| 210 | */ |
| 211 | need_orphan = 1; |
| 212 | #else |
| 213 | if (hdd_ctx->config->tx_orphan_enable) |
| 214 | need_orphan = 1; |
| 215 | #endif |
tfyu | 5f01db2 | 2017-10-11 13:51:04 +0800 | [diff] [blame] | 216 | } else if (hdd_ctx->config->tx_orphan_enable) { |
| 217 | if (qdf_nbuf_is_ipv4_tcp_pkt(skb) || |
Tiger Yu | 438c648 | 2017-10-13 11:07:00 +0800 | [diff] [blame] | 218 | qdf_nbuf_is_ipv6_tcp_pkt(skb)) |
tfyu | 5f01db2 | 2017-10-11 13:51:04 +0800 | [diff] [blame] | 219 | need_orphan = 1; |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 220 | } |
| 221 | |
tfyu | 5f01db2 | 2017-10-11 13:51:04 +0800 | [diff] [blame] | 222 | if (need_orphan) { |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 223 | skb_orphan(skb); |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 224 | ++adapter->hdd_stats.tx_rx_stats.tx_orphaned; |
Tiger Yu | 438c648 | 2017-10-13 11:07:00 +0800 | [diff] [blame] | 225 | } else |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 226 | skb = skb_unshare(skb, GFP_ATOMIC); |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 227 | |
| 228 | return skb; |
| 229 | } |
| 230 | |
| 231 | #else |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 232 | /** |
| 233 | * hdd_skb_orphan() - skb_unshare a cloned packed else skb_orphan |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 234 | * @adapter: pointer to HDD adapter |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 235 | * @skb: pointer to skb data packet |
| 236 | * |
| 237 | * Return: pointer to skb structure |
| 238 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 239 | static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter, |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 240 | struct sk_buff *skb) { |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 241 | |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 242 | struct sk_buff *nskb; |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 243 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0)) |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 244 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 245 | #endif |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 246 | |
Mohit Khanna | 8749373 | 2017-08-27 23:26:44 -0700 | [diff] [blame] | 247 | hdd_skb_fill_gso_size(adapter->dev, skb); |
| 248 | |
Manjunathappa Prakash | dab74fa | 2017-06-19 12:11:03 -0700 | [diff] [blame] | 249 | nskb = skb_unshare(skb, GFP_ATOMIC); |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 250 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0)) |
Manjunathappa Prakash | dab74fa | 2017-06-19 12:11:03 -0700 | [diff] [blame] | 251 | if (unlikely(hdd_ctx->config->tx_orphan_enable) && (nskb == skb)) { |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 252 | /* |
| 253 | * For UDP packets we want to orphan the packet to allow the app |
| 254 | * to send more packets. The flow would ultimately be controlled |
| 255 | * by the limited number of tx descriptors for the vdev. |
| 256 | */ |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 257 | ++adapter->hdd_stats.tx_rx_stats.tx_orphaned; |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 258 | skb_orphan(skb); |
| 259 | } |
tfyu | bdf453e | 2017-09-27 13:34:30 +0800 | [diff] [blame] | 260 | #endif |
Mohit Khanna | d0b63f5 | 2017-02-18 18:05:52 -0800 | [diff] [blame] | 261 | return nskb; |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 262 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 263 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 264 | |
| 265 | /** |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 266 | * hdd_post_dhcp_ind() - Send DHCP START/STOP indication to FW |
| 267 | * @adapter: pointer to hdd adapter |
| 268 | * @sta_id: peer station ID |
| 269 | * @type: WMA message type |
| 270 | * |
| 271 | * Return: error number |
| 272 | */ |
| 273 | int hdd_post_dhcp_ind(struct hdd_adapter *adapter, |
| 274 | uint8_t sta_id, uint16_t type) |
| 275 | { |
| 276 | tAniDHCPInd pmsg; |
| 277 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 278 | |
| 279 | hdd_debug("Post DHCP indication,sta_id=%d, type=%d", sta_id, type); |
| 280 | |
| 281 | if (!adapter) { |
| 282 | hdd_err("NULL adapter"); |
| 283 | return -EINVAL; |
| 284 | } |
| 285 | |
| 286 | pmsg.msgType = type; |
| 287 | pmsg.msgLen = (uint16_t) sizeof(tAniDHCPInd); |
| 288 | pmsg.device_mode = adapter->device_mode; |
| 289 | qdf_mem_copy(pmsg.adapterMacAddr.bytes, |
| 290 | adapter->mac_addr.bytes, |
| 291 | QDF_MAC_ADDR_SIZE); |
| 292 | qdf_mem_copy(pmsg.peerMacAddr.bytes, |
| 293 | adapter->sta_info[sta_id].sta_mac.bytes, |
| 294 | QDF_MAC_ADDR_SIZE); |
| 295 | |
| 296 | status = wma_process_dhcp_ind(cds_get_context(QDF_MODULE_ID_WMA), |
| 297 | &pmsg); |
| 298 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 299 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
| 300 | "%s: Post DHCP Ind MSG fail", __func__); |
| 301 | return -EFAULT; |
| 302 | } |
| 303 | |
| 304 | return 0; |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * hdd_inspect_dhcp_packet() - Inspect DHCP packet |
| 309 | * @adapter: pointer to hdd adapter |
| 310 | * @sta_id: peer station ID |
| 311 | * @skb: pointer to OS packet (sk_buff) |
| 312 | * @dir: direction |
| 313 | * |
| 314 | * Inspect the Tx/Rx frame, and send DHCP START/STOP notification to the FW |
| 315 | * through WMI message, during DHCP based IP address acquisition phase. |
| 316 | * |
| 317 | * - Send DHCP_START notification to FW when SAP gets DHCP Discovery |
| 318 | * - Send DHCP_STOP notification to FW when SAP sends DHCP ACK/NAK |
| 319 | * |
| 320 | * DHCP subtypes are determined by a status octet in the DHCP Message type |
| 321 | * option (option code 53 (0x35)). |
| 322 | * |
| 323 | * Each peer will be in one of 4 DHCP phases, starts from QDF_DHCP_PHASE_ACK, |
| 324 | * and transitioned per DHCP message type as it arrives. |
| 325 | * |
| 326 | * - QDF_DHCP_PHASE_DISCOVER: upon receiving DHCP_DISCOVER message in ACK phase |
| 327 | * - QDF_DHCP_PHASE_OFFER: upon receiving DHCP_OFFER message in DISCOVER phase |
| 328 | * - QDF_DHCP_PHASE_REQUEST: upon receiving DHCP_REQUEST message in OFFER phase |
| 329 | * or ACK phase (Renewal process) |
| 330 | * - QDF_DHCP_PHASE_ACK : upon receiving DHCP_ACK/NAK message in REQUEST phase |
| 331 | * or DHCP_DELINE message in OFFER phase |
| 332 | * |
| 333 | * Return: error number |
| 334 | */ |
| 335 | int hdd_inspect_dhcp_packet(struct hdd_adapter *adapter, |
| 336 | uint8_t sta_id, |
| 337 | struct sk_buff *skb, |
| 338 | enum qdf_proto_dir dir) |
| 339 | { |
| 340 | enum qdf_proto_subtype subtype = QDF_PROTO_INVALID; |
| 341 | struct hdd_station_info *hdd_sta_info; |
| 342 | int errno = 0; |
| 343 | |
| 344 | hdd_debug("sta_id=%d, dir=%d", sta_id, dir); |
| 345 | |
| 346 | if ((adapter->device_mode == QDF_SAP_MODE) && |
| 347 | ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_DHCP == |
| 348 | QDF_NBUF_CB_GET_PACKET_TYPE(skb)) || |
| 349 | (dir == QDF_RX && qdf_nbuf_is_ipv4_dhcp_pkt(skb) == true))) { |
| 350 | |
| 351 | subtype = qdf_nbuf_get_dhcp_subtype(skb); |
| 352 | hdd_sta_info = &adapter->sta_info[sta_id]; |
| 353 | |
| 354 | hdd_debug("ENTER: type=%d, phase=%d, nego_status=%d", |
| 355 | subtype, |
| 356 | hdd_sta_info->dhcp_phase, |
| 357 | hdd_sta_info->dhcp_nego_status); |
| 358 | |
| 359 | switch (subtype) { |
| 360 | case QDF_PROTO_DHCP_DISCOVER: |
| 361 | if (dir != QDF_RX) |
| 362 | break; |
| 363 | if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP) |
| 364 | errno = hdd_post_dhcp_ind(adapter, sta_id, |
| 365 | WMA_DHCP_START_IND); |
| 366 | hdd_sta_info->dhcp_phase = DHCP_PHASE_DISCOVER; |
| 367 | hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS; |
| 368 | break; |
| 369 | case QDF_PROTO_DHCP_OFFER: |
| 370 | hdd_sta_info->dhcp_phase = DHCP_PHASE_OFFER; |
| 371 | break; |
| 372 | case QDF_PROTO_DHCP_REQUEST: |
| 373 | if (dir != QDF_RX) |
| 374 | break; |
| 375 | if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP) |
| 376 | errno = hdd_post_dhcp_ind(adapter, sta_id, |
| 377 | WMA_DHCP_START_IND); |
| 378 | hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS; |
| 379 | case QDF_PROTO_DHCP_DECLINE: |
| 380 | if (dir == QDF_RX) |
| 381 | hdd_sta_info->dhcp_phase = DHCP_PHASE_REQUEST; |
| 382 | break; |
| 383 | case QDF_PROTO_DHCP_ACK: |
| 384 | case QDF_PROTO_DHCP_NACK: |
| 385 | hdd_sta_info->dhcp_phase = DHCP_PHASE_ACK; |
Yun Park | 0ac1282 | 2018-04-02 11:18:04 -0700 | [diff] [blame] | 386 | if (hdd_sta_info->dhcp_nego_status == |
| 387 | DHCP_NEGO_IN_PROGRESS) |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 388 | errno = hdd_post_dhcp_ind(adapter, sta_id, |
| 389 | WMA_DHCP_STOP_IND); |
| 390 | hdd_sta_info->dhcp_nego_status = DHCP_NEGO_STOP; |
| 391 | break; |
| 392 | default: |
| 393 | break; |
| 394 | } |
| 395 | |
| 396 | hdd_debug("EXIT: phase=%d, nego_status=%d", |
| 397 | hdd_sta_info->dhcp_phase, |
| 398 | hdd_sta_info->dhcp_nego_status); |
| 399 | } |
| 400 | |
| 401 | return errno; |
| 402 | } |
| 403 | |
| 404 | /** |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 405 | * __hdd_softap_hard_start_xmit() - Transmit a frame |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 406 | * @skb: pointer to OS packet (sk_buff) |
| 407 | * @dev: pointer to network device |
| 408 | * |
| 409 | * Function registered with the Linux OS for transmitting |
| 410 | * packets. This version of the function directly passes |
| 411 | * the packet to Transport Layer. |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 412 | * In case of any packet drop or error, log the error with |
| 413 | * INFO HIGH/LOW/MEDIUM to avoid excessive logging in kmsg. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 414 | * |
| 415 | * Return: Always returns NETDEV_TX_OK |
| 416 | */ |
Srinivas Girigowda | 49b48b2 | 2018-04-05 09:23:28 -0700 | [diff] [blame] | 417 | static netdev_tx_t __hdd_softap_hard_start_xmit(struct sk_buff *skb, |
| 418 | struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 419 | { |
| 420 | sme_ac_enum_type ac = SME_AC_BE; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 421 | struct hdd_adapter *adapter = (struct hdd_adapter *) netdev_priv(dev); |
Jeff Johnson | 9bf2497 | 2017-10-04 09:26:58 -0700 | [diff] [blame] | 422 | struct hdd_ap_ctx *ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 423 | struct qdf_mac_addr *pDestMacAddress; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 424 | uint8_t STAId; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 425 | uint32_t num_seg; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 426 | |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 427 | ++adapter->hdd_stats.tx_rx_stats.tx_called; |
| 428 | adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0; |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 429 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 430 | /* Prevent this function from being called during SSR since TL |
| 431 | * context may not be reinitialized at this time which may |
| 432 | * lead to a crash. |
| 433 | */ |
Will Huang | 20de943 | 2018-02-06 17:01:03 +0800 | [diff] [blame] | 434 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state() || |
| 435 | cds_is_load_or_unload_in_progress()) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 436 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH, |
Will Huang | 20de943 | 2018-02-06 17:01:03 +0800 | [diff] [blame] | 437 | "%s: Recovery/(Un)load in Progress. Ignore!!!", |
| 438 | __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 439 | goto drop_pkt; |
| 440 | } |
| 441 | |
| 442 | /* |
| 443 | * If the device is operating on a DFS Channel |
| 444 | * then check if SAP is in CAC WAIT state and |
| 445 | * drop the packets. In CAC WAIT state device |
| 446 | * is expected not to transmit any frames. |
| 447 | * SAP starts Tx only after the BSS START is |
| 448 | * done. |
| 449 | */ |
Jeff Johnson | 9bf2497 | 2017-10-04 09:26:58 -0700 | [diff] [blame] | 450 | if (ap_ctx->dfs_cac_block_tx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 451 | goto drop_pkt; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 452 | |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 453 | /* |
Jeff Johnson | 4fca3b5 | 2017-01-12 08:44:18 -0800 | [diff] [blame] | 454 | * If a transmit function is not registered, drop packet |
| 455 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 456 | if (!adapter->tx_fn) { |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 457 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH, |
| 458 | "%s: TX function not registered by the data path", |
| 459 | __func__); |
| 460 | goto drop_pkt; |
| 461 | } |
| 462 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 463 | wlan_hdd_classify_pkt(skb); |
| 464 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 465 | pDestMacAddress = (struct qdf_mac_addr *) skb->data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 466 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 467 | if (QDF_NBUF_CB_GET_IS_BCAST(skb) || |
| 468 | QDF_NBUF_CB_GET_IS_MCAST(skb)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 469 | /* The BC/MC station ID is assigned during BSS |
| 470 | * starting phase. SAP will return the station ID |
| 471 | * used for BC/MC traffic. |
| 472 | */ |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 473 | STAId = ap_ctx->broadcast_sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 474 | } else { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 475 | if (QDF_STATUS_SUCCESS != |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 476 | hdd_softap_get_sta_id(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 477 | pDestMacAddress, &STAId)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 478 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 479 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 480 | "%s: Failed to find right station", __func__); |
| 481 | goto drop_pkt; |
| 482 | } |
| 483 | |
Prakash Dhavali | 3107b75 | 2016-11-28 14:35:06 +0530 | [diff] [blame] | 484 | if (STAId >= WLAN_MAX_STA_COUNT) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 485 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 486 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 487 | "%s: Failed to find right station", __func__); |
| 488 | goto drop_pkt; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 489 | } else if (false == adapter->sta_info[STAId].in_use) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 490 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 491 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 492 | "%s: STA %d is unregistered", __func__, |
| 493 | STAId); |
| 494 | goto drop_pkt; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 495 | } else if (true == adapter->sta_info[STAId]. |
Jeff Johnson | e4f5d93 | 2017-10-21 13:21:15 -0700 | [diff] [blame] | 496 | is_deauth_in_progress) { |
Poddar, Siddarth | a507546 | 2017-03-16 19:20:09 +0530 | [diff] [blame] | 497 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 498 | QDF_TRACE_LEVEL_INFO_HIGH, |
Poddar, Siddarth | a507546 | 2017-03-16 19:20:09 +0530 | [diff] [blame] | 499 | "%s: STA %d deauth in progress", __func__, |
| 500 | STAId); |
| 501 | goto drop_pkt; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 502 | } |
| 503 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 504 | if ((OL_TXRX_PEER_STATE_CONN != |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 505 | adapter->sta_info[STAId].peer_state) |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 506 | && (OL_TXRX_PEER_STATE_AUTH != |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 507 | adapter->sta_info[STAId].peer_state)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 508 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 509 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 510 | "%s: Station not connected yet", __func__); |
| 511 | goto drop_pkt; |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 512 | } else if (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 513 | adapter->sta_info[STAId].peer_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 514 | if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 515 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 516 | QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 517 | "%s: NON-EAPOL packet in non-Authenticated state", |
| 518 | __func__); |
| 519 | goto drop_pkt; |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 524 | hdd_get_tx_resource(adapter, STAId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 525 | WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 526 | |
| 527 | /* Get TL AC corresponding to Qdisc queue index/AC. */ |
| 528 | ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping]; |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 529 | ++adapter->hdd_stats.tx_rx_stats.tx_classified_ac[ac]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 530 | |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 531 | #if defined(IPA_OFFLOAD) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 532 | if (!qdf_nbuf_ipa_owned_get(skb)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 533 | #endif |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 534 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 535 | skb = hdd_skb_orphan(adapter, skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 536 | if (!skb) |
Jeff Johnson | edeff23 | 2015-11-11 17:19:42 -0800 | [diff] [blame] | 537 | goto drop_pkt_accounting; |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 538 | |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 539 | #if defined(IPA_OFFLOAD) |
Yun Park | 01deb2c | 2017-06-14 15:21:44 -0700 | [diff] [blame] | 540 | } else { |
| 541 | /* |
| 542 | * Clear the IPA ownership after check it to avoid ipa_free_skb |
| 543 | * is called when Tx completed for intra-BSS Tx packets |
| 544 | */ |
| 545 | qdf_nbuf_ipa_owned_clear(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | } |
| 547 | #endif |
| 548 | |
Himanshu Agarwal | 53298d1 | 2017-02-20 19:14:17 +0530 | [diff] [blame] | 549 | /* |
| 550 | * Add SKB to internal tracking table before further processing |
| 551 | * in WLAN driver. |
| 552 | */ |
| 553 | qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__); |
| 554 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 555 | adapter->stats.tx_bytes += skb->len; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 556 | adapter->sta_info[STAId].tx_bytes += skb->len; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 557 | |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 558 | if (qdf_nbuf_is_tso(skb)) { |
| 559 | num_seg = qdf_nbuf_get_tso_num_seg(skb); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 560 | adapter->stats.tx_packets += num_seg; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 561 | adapter->sta_info[STAId].tx_packets += num_seg; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 562 | } else { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 563 | ++adapter->stats.tx_packets; |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 564 | adapter->sta_info[STAId].tx_packets++; |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 565 | } |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 566 | adapter->sta_info[STAId].last_tx_rx_ts = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 567 | |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 568 | if (STAId != ap_ctx->broadcast_sta_id) |
| 569 | hdd_inspect_dhcp_packet(adapter, STAId, skb, QDF_TX); |
| 570 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 571 | hdd_event_eapol_log(skb, QDF_TX); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 572 | QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK; |
| 573 | QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD); |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 574 | qdf_dp_trace_set_track(skb, QDF_TX); |
| 575 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 576 | QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(skb), |
| 577 | sizeof(qdf_nbuf_data(skb)), |
Himanshu Agarwal | ee3411a | 2017-01-31 12:56:47 +0530 | [diff] [blame] | 578 | QDF_TX)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 579 | |
jinweic chen | 5104601 | 2018-04-11 16:02:22 +0800 | [diff] [blame] | 580 | /* check whether need to linearize skb, like non-linear udp data */ |
| 581 | if (hdd_skb_nontso_linearize(skb) != QDF_STATUS_SUCCESS) { |
| 582 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, |
| 583 | QDF_TRACE_LEVEL_INFO_HIGH, |
| 584 | "%s: skb %pK linearize failed. drop the pkt", |
| 585 | __func__, skb); |
| 586 | ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac]; |
| 587 | goto drop_pkt_and_release_skb; |
| 588 | } |
| 589 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 590 | if (adapter->tx_fn(adapter->txrx_vdev, |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 591 | (qdf_nbuf_t) skb) != NULL) { |
Poddar, Siddarth | 31b9b8b | 2017-04-07 12:04:55 +0530 | [diff] [blame] | 592 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 593 | "%s: Failed to send packet to txrx for staid:%d", |
| 594 | __func__, STAId); |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 595 | ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac]; |
Himanshu Agarwal | 53298d1 | 2017-02-20 19:14:17 +0530 | [diff] [blame] | 596 | goto drop_pkt_and_release_skb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 597 | } |
Dustin Brown | e0024fa | 2016-10-14 16:29:21 -0700 | [diff] [blame] | 598 | netif_trans_update(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 599 | |
| 600 | return NETDEV_TX_OK; |
| 601 | |
Himanshu Agarwal | 53298d1 | 2017-02-20 19:14:17 +0530 | [diff] [blame] | 602 | drop_pkt_and_release_skb: |
| 603 | qdf_net_buf_debug_release_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 604 | drop_pkt: |
| 605 | |
Mohit Khanna | 02281da | 2017-08-27 09:40:55 -0700 | [diff] [blame^] | 606 | qdf_dp_trace_data_pkt(skb, QDF_TRACE_DEFAULT_PDEV_ID, |
| 607 | QDF_DP_TRACE_DROP_PACKET_RECORD, 0, |
| 608 | QDF_TX); |
Jeff Johnson | edeff23 | 2015-11-11 17:19:42 -0800 | [diff] [blame] | 609 | kfree_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 610 | |
Jeff Johnson | edeff23 | 2015-11-11 17:19:42 -0800 | [diff] [blame] | 611 | drop_pkt_accounting: |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 612 | ++adapter->stats.tx_dropped; |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 613 | ++adapter->hdd_stats.tx_rx_stats.tx_dropped; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 614 | |
| 615 | return NETDEV_TX_OK; |
| 616 | } |
| 617 | |
| 618 | /** |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 619 | * hdd_softap_hard_start_xmit() - Wrapper function to protect |
| 620 | * __hdd_softap_hard_start_xmit from SSR |
| 621 | * @skb: pointer to OS packet |
| 622 | * @dev: pointer to net_device structure |
| 623 | * |
| 624 | * Function called by OS if any packet needs to transmit. |
| 625 | * |
| 626 | * Return: Always returns NETDEV_TX_OK |
| 627 | */ |
Srinivas Girigowda | 49b48b2 | 2018-04-05 09:23:28 -0700 | [diff] [blame] | 628 | netdev_tx_t hdd_softap_hard_start_xmit(struct sk_buff *skb, |
| 629 | struct net_device *dev) |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 630 | { |
Srinivas Girigowda | 49b48b2 | 2018-04-05 09:23:28 -0700 | [diff] [blame] | 631 | netdev_tx_t ret; |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 632 | |
| 633 | cds_ssr_protect(__func__); |
| 634 | ret = __hdd_softap_hard_start_xmit(skb, dev); |
| 635 | cds_ssr_unprotect(__func__); |
| 636 | |
| 637 | return ret; |
| 638 | } |
| 639 | |
| 640 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 641 | * __hdd_softap_tx_timeout() - TX timeout handler |
| 642 | * @dev: pointer to network device |
| 643 | * |
| 644 | * This function is registered as a netdev ndo_tx_timeout method, and |
| 645 | * is invoked by the kernel if the driver takes too long to transmit a |
| 646 | * frame. |
| 647 | * |
| 648 | * Return: None |
| 649 | */ |
| 650 | static void __hdd_softap_tx_timeout(struct net_device *dev) |
| 651 | { |
Jeff Johnson | 18dd7e1 | 2017-08-29 14:22:28 -0700 | [diff] [blame] | 652 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | f772687 | 2017-08-28 11:38:31 -0700 | [diff] [blame] | 653 | struct hdd_context *hdd_ctx; |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 654 | struct netdev_queue *txq; |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 655 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 656 | int i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 657 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 658 | DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 659 | QDF_TRACE_DEFAULT_PDEV_ID, |
| 660 | NULL, 0, QDF_TX)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 661 | /* Getting here implies we disabled the TX queues for too |
| 662 | * long. Queues are disabled either because of disassociation |
| 663 | * or low resource scenarios. In case of disassociation it is |
| 664 | * ok to ignore this. But if associated, we have do possible |
| 665 | * recovery here |
| 666 | */ |
| 667 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 668 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 669 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 670 | "%s: Recovery in Progress. Ignore!!!", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 671 | return; |
| 672 | } |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 673 | |
Dustin Brown | e0024fa | 2016-10-14 16:29:21 -0700 | [diff] [blame] | 674 | TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA); |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 675 | |
| 676 | for (i = 0; i < NUM_TX_QUEUES; i++) { |
| 677 | txq = netdev_get_tx_queue(dev, i); |
| 678 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, |
Srinivas Girigowda | 028c448 | 2017-03-09 18:52:02 -0800 | [diff] [blame] | 679 | QDF_TRACE_LEVEL_DEBUG, |
| 680 | "Queue: %d status: %d txq->trans_start: %lu", |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 681 | i, netif_tx_queue_stopped(txq), txq->trans_start); |
| 682 | } |
| 683 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 684 | wlan_hdd_display_netif_queue_history(hdd_ctx, |
| 685 | QDF_STATS_VERBOSITY_LEVEL_HIGH); |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 686 | cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC)); |
Srinivas Girigowda | 028c448 | 2017-03-09 18:52:02 -0800 | [diff] [blame] | 687 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG, |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 688 | "carrier state: %d", netif_carrier_ok(dev)); |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 689 | |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 690 | ++adapter->hdd_stats.tx_rx_stats.tx_timeout_cnt; |
| 691 | ++adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt; |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 692 | |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 693 | if (adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt > |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 694 | HDD_TX_STALL_THRESHOLD) { |
| 695 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR, |
| 696 | "Detected data stall due to continuous TX timeouts"); |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 697 | adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0; |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 698 | if (hdd_ctx->config->enable_data_stall_det) |
| 699 | cdp_post_data_stall_event(soc, |
Sravan Kumar Kairam | 3a69831 | 2017-10-16 14:16:16 +0530 | [diff] [blame] | 700 | DATA_STALL_LOG_INDICATOR_HOST_DRIVER, |
| 701 | DATA_STALL_LOG_HOST_SOFTAP_TX_TIMEOUT, |
| 702 | 0xFF, 0xFF, |
| 703 | DATA_STALL_LOG_RECOVERY_TRIGGER_PDR); |
| 704 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | /** |
| 708 | * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout |
| 709 | * @dev: pointer to net_device |
| 710 | * |
| 711 | * Return: none |
| 712 | */ |
| 713 | void hdd_softap_tx_timeout(struct net_device *dev) |
| 714 | { |
| 715 | cds_ssr_protect(__func__); |
| 716 | __hdd_softap_tx_timeout(dev); |
| 717 | cds_ssr_unprotect(__func__); |
| 718 | } |
| 719 | |
| 720 | /** |
| 721 | * @hdd_softap_init_tx_rx() - Initialize Tx/RX module |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 722 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 723 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 724 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 725 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 726 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 727 | QDF_STATUS hdd_softap_init_tx_rx(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 728 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 729 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 730 | |
| 731 | uint8_t STAId = 0; |
| 732 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 733 | qdf_mem_zero(&adapter->stats, sizeof(struct net_device_stats)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 734 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 735 | spin_lock_init(&adapter->sta_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 736 | |
| 737 | for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 738 | qdf_mem_zero(&adapter->sta_info[STAId], |
Jeff Johnson | 8215592 | 2017-09-30 16:54:14 -0700 | [diff] [blame] | 739 | sizeof(struct hdd_station_info)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | return status; |
| 743 | } |
| 744 | |
| 745 | /** |
| 746 | * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 747 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 748 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 749 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 750 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 751 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 752 | QDF_STATUS hdd_softap_deinit_tx_rx(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 753 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 754 | if (adapter == NULL) { |
| 755 | hdd_err("Called with adapter = NULL."); |
Dhanashri Atre | ed3bf51 | 2017-02-21 12:25:53 -0800 | [diff] [blame] | 756 | return QDF_STATUS_E_FAILURE; |
| 757 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 759 | adapter->txrx_vdev = NULL; |
| 760 | adapter->tx_fn = NULL; |
Dhanashri Atre | ed3bf51 | 2017-02-21 12:25:53 -0800 | [diff] [blame] | 761 | hdd_info("Deregistering TX function hook !"); |
| 762 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 763 | } |
| 764 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 765 | QDF_STATUS hdd_softap_init_tx_rx_sta(struct hdd_adapter *adapter, |
Jeff Johnson | 349d9a9 | 2017-10-21 15:38:03 -0700 | [diff] [blame] | 766 | uint8_t sta_id, |
| 767 | struct qdf_mac_addr *sta_mac) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 768 | { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 769 | spin_lock_bh(&adapter->sta_info_lock); |
| 770 | if (adapter->sta_info[sta_id].in_use) { |
| 771 | spin_unlock_bh(&adapter->sta_info_lock); |
Jeff Johnson | 349d9a9 | 2017-10-21 15:38:03 -0700 | [diff] [blame] | 772 | hdd_err("Reinit of in use station %d", sta_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 773 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 774 | } |
| 775 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 776 | qdf_mem_zero(&adapter->sta_info[sta_id], |
Jeff Johnson | 8215592 | 2017-09-30 16:54:14 -0700 | [diff] [blame] | 777 | sizeof(struct hdd_station_info)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 778 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 779 | adapter->sta_info[sta_id].in_use = true; |
| 780 | adapter->sta_info[sta_id].is_deauth_in_progress = false; |
| 781 | qdf_copy_macaddr(&adapter->sta_info[sta_id].sta_mac, sta_mac); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 782 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 783 | spin_unlock_bh(&adapter->sta_info_lock); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 784 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 785 | } |
| 786 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 787 | QDF_STATUS hdd_softap_deinit_tx_rx_sta(struct hdd_adapter *adapter, |
Jeff Johnson | b157c72 | 2017-10-21 15:46:42 -0700 | [diff] [blame] | 788 | uint8_t sta_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 789 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 790 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 791 | struct hdd_hostapd_state *hostapd_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 792 | |
Jeff Johnson | 5c19ade | 2017-10-04 09:52:12 -0700 | [diff] [blame] | 793 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 794 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 795 | spin_lock_bh(&adapter->sta_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 796 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 797 | if (false == adapter->sta_info[sta_id].in_use) { |
| 798 | spin_unlock_bh(&adapter->sta_info_lock); |
Jeff Johnson | b157c72 | 2017-10-21 15:46:42 -0700 | [diff] [blame] | 799 | hdd_err("Deinit station not inited %d", sta_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 800 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 801 | } |
| 802 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 803 | adapter->sta_info[sta_id].in_use = false; |
| 804 | adapter->sta_info[sta_id].is_deauth_in_progress = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 805 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 806 | spin_unlock_bh(&adapter->sta_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 807 | return status; |
| 808 | } |
| 809 | |
| 810 | /** |
| 811 | * hdd_softap_rx_packet_cbk() - Receive packet handler |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 812 | * @context: pointer to HDD context |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 813 | * @rxBuf: pointer to rx qdf_nbuf |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 814 | * |
| 815 | * Receive callback registered with TL. TL will call this to notify |
| 816 | * the HDD when one or more packets were received for a registered |
| 817 | * STA. |
| 818 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 819 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 820 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 821 | */ |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 822 | QDF_STATUS hdd_softap_rx_packet_cbk(void *context, qdf_nbuf_t rxBuf) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 823 | { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 824 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 825 | int rxstat; |
| 826 | unsigned int cpu_index; |
| 827 | struct sk_buff *skb = NULL; |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 828 | struct sk_buff *next = NULL; |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 829 | struct hdd_context *hdd_ctx = NULL; |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 830 | struct qdf_mac_addr *src_mac; |
Mohit Khanna | 02281da | 2017-08-27 09:40:55 -0700 | [diff] [blame^] | 831 | |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 832 | uint8_t staid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 833 | |
| 834 | /* Sanity check on inputs */ |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 835 | if (unlikely((NULL == context) || (NULL == rxBuf))) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 836 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 837 | "%s: Null params being passed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 838 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 839 | } |
| 840 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 841 | adapter = (struct hdd_adapter *)context; |
| 842 | if (unlikely(WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Srinivas Girigowda | 028c448 | 2017-03-09 18:52:02 -0800 | [diff] [blame] | 843 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR, |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 844 | "Magic cookie(%x) for adapter sanity verification is invalid", |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 845 | adapter->magic); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 846 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 847 | } |
| 848 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 849 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 850 | if (unlikely(NULL == hdd_ctx)) { |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 851 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
| 852 | "%s: HDD context is Null", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 853 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | /* walk the chain until all are processed */ |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 857 | next = (struct sk_buff *)rxBuf; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 858 | |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 859 | while (next) { |
| 860 | skb = next; |
| 861 | next = skb->next; |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 862 | skb->next = NULL; |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 863 | |
psimha | 884025c | 2017-08-01 15:07:32 -0700 | [diff] [blame] | 864 | #ifdef QCA_WIFI_QCA6290 /* Debug code, remove later */ |
Yun Park | e423980 | 2018-01-09 11:01:40 -0800 | [diff] [blame] | 865 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG, |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 866 | "%s: skb %pK skb->len %d\n", __func__, skb, skb->len); |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 867 | #endif |
| 868 | |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 869 | hdd_softap_dump_sk_buff(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 870 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 871 | skb->dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 872 | |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 873 | if (unlikely(skb->dev == NULL)) { |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 874 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
| 875 | QDF_TRACE_LEVEL_ERROR, |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 876 | "%s: ERROR!!Invalid netdevice", __func__); |
Dhanashri Atre | cefa880 | 2017-02-02 16:17:14 -0800 | [diff] [blame] | 877 | continue; |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 878 | } |
| 879 | cpu_index = wlan_hdd_get_cpu(); |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 880 | ++adapter->hdd_stats.tx_rx_stats.rx_packets[cpu_index]; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 881 | ++adapter->stats.rx_packets; |
| 882 | adapter->stats.rx_bytes += skb->len; |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 883 | |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 884 | /* Send DHCP Indication to FW */ |
| 885 | src_mac = (struct qdf_mac_addr *)(skb->data + |
| 886 | QDF_NBUF_SRC_MAC_OFFSET); |
| 887 | if (QDF_STATUS_SUCCESS == |
| 888 | hdd_softap_get_sta_id(adapter, src_mac, &staid)) { |
| 889 | if (staid < WLAN_MAX_STA_COUNT) { |
| 890 | adapter->sta_info[staid].rx_packets++; |
| 891 | adapter->sta_info[staid].rx_bytes += skb->len; |
| 892 | adapter->sta_info[staid].last_tx_rx_ts = |
| 893 | qdf_system_ticks(); |
| 894 | } |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 895 | } |
Yun Park | c3e3556 | 2018-03-08 12:05:52 -0800 | [diff] [blame] | 896 | |
| 897 | hdd_inspect_dhcp_packet(adapter, staid, skb, QDF_RX); |
| 898 | |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 899 | hdd_event_eapol_log(skb, QDF_RX); |
Mohit Khanna | 02281da | 2017-08-27 09:40:55 -0700 | [diff] [blame^] | 900 | qdf_dp_trace_log_pkt(adapter->session_id, |
| 901 | skb, QDF_RX, QDF_TRACE_DEFAULT_PDEV_ID); |
Himanshu Agarwal | ee3411a | 2017-01-31 12:56:47 +0530 | [diff] [blame] | 902 | DPTRACE(qdf_dp_trace(skb, |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 903 | QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD, |
Venkata Sharath Chandra Manchala | 0b9fc63 | 2017-05-15 14:35:15 -0700 | [diff] [blame] | 904 | QDF_TRACE_DEFAULT_PDEV_ID, |
Himanshu Agarwal | ee3411a | 2017-01-31 12:56:47 +0530 | [diff] [blame] | 905 | qdf_nbuf_data_addr(skb), |
| 906 | sizeof(qdf_nbuf_data(skb)), QDF_RX)); |
Mohit Khanna | 02281da | 2017-08-27 09:40:55 -0700 | [diff] [blame^] | 907 | DPTRACE(qdf_dp_trace_data_pkt(skb, QDF_TRACE_DEFAULT_PDEV_ID, |
| 908 | QDF_DP_TRACE_RX_PACKET_RECORD, 0, QDF_RX)); |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 909 | |
| 910 | skb->protocol = eth_type_trans(skb, skb->dev); |
| 911 | |
| 912 | /* hold configurable wakelock for unicast traffic */ |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 913 | if (hdd_ctx->config->rx_wakelock_timeout && |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 914 | skb->pkt_type != PACKET_BROADCAST && |
| 915 | skb->pkt_type != PACKET_MULTICAST) { |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 916 | cds_host_diag_log_work(&hdd_ctx->rx_wake_lock, |
| 917 | hdd_ctx->config->rx_wakelock_timeout, |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 918 | WIFI_POWER_EVENT_WAKELOCK_HOLD_RX); |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 919 | qdf_wake_lock_timeout_acquire(&hdd_ctx->rx_wake_lock, |
| 920 | hdd_ctx->config-> |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 921 | rx_wakelock_timeout); |
| 922 | } |
| 923 | |
| 924 | /* Remove SKB from internal tracking table before submitting |
| 925 | * it to stack |
| 926 | */ |
Manjunathappa Prakash | 17c07bd | 2017-04-27 21:24:28 -0700 | [diff] [blame] | 927 | qdf_net_buf_debug_release_skb(skb); |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 928 | if (hdd_napi_enabled(HDD_NAPI_ANY) && |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 929 | !hdd_ctx->enable_rxthread) |
Dhanashri Atre | 63d9802 | 2017-01-24 18:22:09 -0800 | [diff] [blame] | 930 | rxstat = netif_receive_skb(skb); |
| 931 | else |
| 932 | rxstat = netif_rx_ni(skb); |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 933 | if (NET_RX_SUCCESS == rxstat) |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 934 | ++adapter->hdd_stats.tx_rx_stats.rx_delivered[cpu_index]; |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 935 | else |
Jeff Johnson | 6ced42c | 2017-10-20 12:48:11 -0700 | [diff] [blame] | 936 | ++adapter->hdd_stats.tx_rx_stats.rx_refused[cpu_index]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 937 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 938 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 939 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | /** |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 943 | * hdd_softap_deregister_sta(struct hdd_adapter *adapter, uint8_t staId) |
| 944 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 945 | * @staId: Station ID to deregister |
| 946 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 947 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 948 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 949 | QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter, |
Jeff Johnson | 18dd7e1 | 2017-08-29 14:22:28 -0700 | [diff] [blame] | 950 | uint8_t staId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 951 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 952 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 953 | struct hdd_context *hdd_ctx; |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 954 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 955 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 956 | if (NULL == adapter) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 957 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 958 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 959 | } |
| 960 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 961 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 962 | hdd_err("Invalid adapter magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 963 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | } |
| 965 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 966 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 967 | /* Clear station in TL and then update HDD data |
| 968 | * structures. This helps to block RX frames from other |
| 969 | * station to this station. |
| 970 | */ |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 971 | qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 972 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
| 973 | staId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 974 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 975 | hdd_err("cdp_clear_peer failed for staID %d, Status=%d [0x%08X]", |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 976 | staId, qdf_status, qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 977 | } |
| 978 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 979 | ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 980 | adapter->sta_info[staId]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 981 | sta_mac.bytes); |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 982 | if (ret) |
| 983 | hdd_err("Peer obj %pM delete fails", |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 984 | adapter->sta_info[staId].sta_mac.bytes); |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 985 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 986 | if (adapter->sta_info[staId].in_use) { |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 987 | if (ucfg_ipa_is_enabled()) { |
Yun Park | a9d0c11 | 2018-03-07 14:11:27 -0800 | [diff] [blame] | 988 | if (ucfg_ipa_wlan_evt(hdd_ctx->hdd_pdev, adapter->dev, |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 989 | adapter->device_mode, |
| 990 | adapter->sta_info[staId].sta_id, |
| 991 | adapter->session_id, |
| 992 | WLAN_IPA_CLIENT_DISCONNECT, |
| 993 | adapter->sta_info[staId].sta_mac. |
Yun Park | a9d0c11 | 2018-03-07 14:11:27 -0800 | [diff] [blame] | 994 | bytes) != QDF_STATUS_SUCCESS) |
| 995 | hdd_err("WLAN_CLIENT_DISCONNECT event failed"); |
Will Huang | ac3fd9a | 2017-11-01 16:18:12 +0800 | [diff] [blame] | 996 | } |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 997 | spin_lock_bh(&adapter->sta_info_lock); |
| 998 | qdf_mem_zero(&adapter->sta_info[staId], |
Jeff Johnson | 8215592 | 2017-09-30 16:54:14 -0700 | [diff] [blame] | 999 | sizeof(struct hdd_station_info)); |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1000 | spin_unlock_bh(&adapter->sta_info_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1001 | } |
Abhishek Singh | 07c627e | 2017-03-20 17:56:34 +0530 | [diff] [blame] | 1002 | |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 1003 | hdd_ctx->sta_to_adapter[staId] = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1004 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1005 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1006 | } |
| 1007 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1008 | QDF_STATUS hdd_softap_register_sta(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1009 | bool fAuthRequired, |
| 1010 | bool fPrivacyBit, |
| 1011 | uint8_t staId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1012 | struct qdf_mac_addr *pPeerMacAddress, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1013 | bool fWmmEnabled) |
| 1014 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1015 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1016 | struct ol_txrx_desc_type staDesc = { 0 }; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1017 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 1018 | struct ol_txrx_ops txrx_ops; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 1019 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 1020 | void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1021 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1022 | hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u", |
| 1023 | staId, fAuthRequired, fPrivacyBit, fWmmEnabled); |
| 1024 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1025 | /* |
| 1026 | * Clean up old entry if it is not cleaned up properly |
| 1027 | */ |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1028 | if (adapter->sta_info[staId].in_use) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1029 | hdd_info("clean up old entry for STA %d", staId); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1030 | hdd_softap_deregister_sta(adapter, staId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1031 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1032 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1033 | /* Get the Station ID from the one saved during the assocation. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1034 | staDesc.sta_id = staId; |
| 1035 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1036 | /* Save the adapter Pointer for this staId */ |
| 1037 | hdd_ctx->sta_to_adapter[staId] = adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1039 | qdf_status = |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1040 | hdd_softap_init_tx_rx_sta(adapter, staId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1041 | pPeerMacAddress); |
| 1042 | |
| 1043 | staDesc.is_qos_enabled = fWmmEnabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1044 | |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 1045 | /* Register the vdev transmit and receive functions */ |
| 1046 | qdf_mem_zero(&txrx_ops, sizeof(txrx_ops)); |
| 1047 | txrx_ops.rx.rx = hdd_softap_rx_packet_cbk; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 1048 | cdp_vdev_register(soc, |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1049 | (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1050 | (struct cdp_pdev *)pdev, adapter->session_id), |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1051 | adapter, &txrx_ops); |
| 1052 | adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc, |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1053 | (struct cdp_pdev *)pdev, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1054 | adapter->session_id); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1055 | adapter->tx_fn = txrx_ops.tx.tx; |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 1056 | |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 1057 | qdf_status = cdp_peer_register(soc, |
| 1058 | (struct cdp_pdev *)pdev, &staDesc); |
Dhanashri Atre | 50141c5 | 2016-04-07 13:15:29 -0700 | [diff] [blame] | 1059 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1060 | hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]", |
| 1061 | qdf_status, qdf_status); |
Dhanashri Atre | 50141c5 | 2016-04-07 13:15:29 -0700 | [diff] [blame] | 1062 | return qdf_status; |
| 1063 | } |
| 1064 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1065 | /* if ( WPA ), tell TL to go to 'connected' and after keys come to the |
| 1066 | * driver then go to 'authenticated'. For all other authentication |
| 1067 | * types (those that do not require upper layer authentication) we can |
| 1068 | * put TL directly into 'authenticated' state |
| 1069 | */ |
| 1070 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1071 | adapter->sta_info[staId].sta_id = staId; |
| 1072 | adapter->sta_info[staId].is_qos_enabled = fWmmEnabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1073 | |
| 1074 | if (!fAuthRequired) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1075 | hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time", |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1076 | adapter->sta_info[staId].sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1077 | |
| 1078 | /* Connections that do not need Upper layer auth, |
| 1079 | * transition TL directly to 'Authenticated' state. |
| 1080 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1081 | qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1082 | OL_TXRX_PEER_STATE_AUTH, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1083 | |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1084 | adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_AUTH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1085 | } else { |
| 1086 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1087 | hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time", |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1088 | adapter->sta_info[staId].sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1089 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1090 | qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1091 | OL_TXRX_PEER_STATE_CONN, false); |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1092 | adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_CONN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1093 | } |
| 1094 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 1095 | hdd_debug("Enabling queues"); |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1096 | wlan_hdd_netif_queue_control(adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1097 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 1098 | WLAN_CONTROL_PATH); |
| 1099 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1100 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | /** |
| 1104 | * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1105 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1106 | * @fPrivacyBit: should 802.11 privacy bit be set? |
| 1107 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1108 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1109 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1110 | QDF_STATUS hdd_softap_register_bc_sta(struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1111 | bool fPrivacyBit) |
| 1112 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1113 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1114 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 1115 | struct qdf_mac_addr broadcastMacAddr = QDF_MAC_ADDR_BCAST_INIT; |
Jeff Johnson | 9bf2497 | 2017-10-04 09:26:58 -0700 | [diff] [blame] | 1116 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1117 | |
Jeff Johnson | 9bf2497 | 2017-10-04 09:26:58 -0700 | [diff] [blame] | 1118 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1119 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1120 | hdd_ctx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = adapter; |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 1121 | hdd_ctx->sta_to_adapter[ap_ctx->broadcast_sta_id] = adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1122 | qdf_status = |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1123 | hdd_softap_register_sta(adapter, false, fPrivacyBit, |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 1124 | ap_ctx->broadcast_sta_id, |
Jeff Johnson | 3f6c89f | 2018-03-01 14:27:38 -0800 | [diff] [blame] | 1125 | &broadcastMacAddr, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1126 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1127 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1128 | } |
| 1129 | |
| 1130 | /** |
| 1131 | * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1132 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1133 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1134 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1135 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1136 | QDF_STATUS hdd_softap_deregister_bc_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1137 | { |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 1138 | struct hdd_ap_ctx *ap_ctx; |
| 1139 | |
| 1140 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1141 | return hdd_softap_deregister_sta(adapter, ap_ctx->broadcast_sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1142 | } |
| 1143 | |
| 1144 | /** |
| 1145 | * hdd_softap_stop_bss() - Stop the BSS |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1146 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1147 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1148 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1149 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1150 | QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1151 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1152 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1153 | uint8_t staId = 0; |
Jeff Johnson | 9240287 | 2017-09-03 09:25:37 -0700 | [diff] [blame] | 1154 | struct hdd_context *hdd_ctx; |
Yun Park | a9d0c11 | 2018-03-07 14:11:27 -0800 | [diff] [blame] | 1155 | struct hdd_ap_ctx *ap_ctx; |
Srinivas Girigowda | e806a82 | 2017-03-25 11:25:30 -0700 | [diff] [blame] | 1156 | |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1157 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Yun Park | a9d0c11 | 2018-03-07 14:11:27 -0800 | [diff] [blame] | 1158 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1159 | |
Rajeev Kumar | 07bbe12 | 2017-10-24 13:06:05 -0700 | [diff] [blame] | 1160 | /* This is stop bss callback running in scheduler thread so do not |
| 1161 | * driver unload in progress check otherwise it can lead to peer |
| 1162 | * object leak |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1163 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1164 | qdf_status = hdd_softap_deregister_bc_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1165 | |
Yun Park | a9d0c11 | 2018-03-07 14:11:27 -0800 | [diff] [blame] | 1166 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1167 | hdd_err("Failed to deregister BC sta Id %d", |
Jeff Johnson | 42518cf | 2017-10-26 13:33:29 -0700 | [diff] [blame] | 1168 | ap_ctx->broadcast_sta_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1169 | |
| 1170 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) { |
| 1171 | /* This excludes BC sta as it is already deregistered */ |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1172 | if (adapter->sta_info[staId].in_use) { |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1173 | qdf_status = hdd_softap_deregister_sta(adapter, staId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1174 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1175 | hdd_err("Failed to deregister sta Id %d", |
| 1176 | staId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1177 | } |
| 1178 | } |
| 1179 | } |
Mukul Sharma | ecf8e09 | 2017-12-19 22:36:31 +0530 | [diff] [blame] | 1180 | |
| 1181 | /* Mark the indoor channel (passive) to enable */ |
| 1182 | if (hdd_ctx->config->force_ssc_disable_indoor_channel) { |
| 1183 | hdd_update_indoor_channel(hdd_ctx, false); |
| 1184 | sme_update_channel_list(hdd_ctx->hHal); |
| 1185 | } |
| 1186 | |
Yun Park | a9d0c11 | 2018-03-07 14:11:27 -0800 | [diff] [blame] | 1187 | if (ucfg_ipa_is_enabled()) { |
| 1188 | if (ucfg_ipa_wlan_evt(hdd_ctx->hdd_pdev, |
| 1189 | adapter->dev, adapter->device_mode, |
| 1190 | ap_ctx->broadcast_sta_id, |
| 1191 | adapter->session_id, |
| 1192 | WLAN_IPA_AP_DISCONNECT, |
| 1193 | adapter->dev->dev_addr) != QDF_STATUS_SUCCESS) |
| 1194 | hdd_err("WLAN_AP_DISCONNECT event failed"); |
| 1195 | } |
| 1196 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1197 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1198 | } |
| 1199 | |
| 1200 | /** |
| 1201 | * hdd_softap_change_sta_state() - Change the state of a SoftAP station |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1202 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1203 | * @pDestMacAddress: MAC address of the station |
| 1204 | * @state: new state of the station |
| 1205 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 1206 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1207 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1208 | QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1209 | struct qdf_mac_addr *pDestMacAddress, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1210 | enum ol_txrx_peer_state state) |
| 1211 | { |
Jeff Johnson | 4c0ab7b | 2017-10-21 16:13:09 -0700 | [diff] [blame] | 1212 | uint8_t sta_id = WLAN_MAX_STA_COUNT; |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1213 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1214 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 1215 | hdd_enter_dev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1216 | |
Jeff Johnson | 4c0ab7b | 2017-10-21 16:13:09 -0700 | [diff] [blame] | 1217 | qdf_status = hdd_softap_get_sta_id(adapter, pDestMacAddress, &sta_id); |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame] | 1218 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 1219 | hdd_err("Failed to find right station"); |
| 1220 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | if (false == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1224 | qdf_is_macaddr_equal(&adapter->sta_info[sta_id].sta_mac, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1225 | pDestMacAddress)) { |
Jeff Johnson | 4c0ab7b | 2017-10-21 16:13:09 -0700 | [diff] [blame] | 1226 | hdd_err("Station %u MAC address not matching", sta_id); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1227 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1228 | } |
| 1229 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1230 | qdf_status = |
Jeff Johnson | 4c0ab7b | 2017-10-21 16:13:09 -0700 | [diff] [blame] | 1231 | hdd_change_peer_state(adapter, sta_id, state, false); |
| 1232 | hdd_info("Station %u changed to state %d", sta_id, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1233 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1234 | if (QDF_STATUS_SUCCESS == qdf_status) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1235 | adapter->sta_info[sta_id].peer_state = |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 1236 | OL_TXRX_PEER_STATE_AUTH; |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1237 | p2p_peer_authorized(adapter->hdd_vdev, pDestMacAddress->bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1238 | } |
| 1239 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 1240 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1241 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1242 | } |
| 1243 | |
| 1244 | /* |
| 1245 | * hdd_softap_get_sta_id() - Find station ID from MAC address |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1246 | * @adapter: pointer to adapter context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1247 | * @pDestMacAddress: MAC address of the destination |
| 1248 | * @staId: Station ID associated with the MAC address |
| 1249 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1250 | * Return: QDF_STATUS_SUCCESS if a match was found, in which case |
| 1251 | * staId is populated, QDF_STATUS_E_FAILURE if a match is |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1252 | * not found |
| 1253 | */ |
Jeff Johnson | d31ab6a | 2017-10-02 13:23:51 -0700 | [diff] [blame] | 1254 | QDF_STATUS hdd_softap_get_sta_id(struct hdd_adapter *adapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1255 | struct qdf_mac_addr *pMacAddress, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1256 | uint8_t *staId) |
| 1257 | { |
| 1258 | uint8_t i; |
| 1259 | |
| 1260 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1261 | if (!qdf_mem_cmp |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 1262 | (&adapter->sta_info[i].sta_mac, pMacAddress, |
| 1263 | QDF_MAC_ADDR_SIZE) && adapter->sta_info[i].in_use) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1264 | *staId = i; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1265 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1266 | } |
| 1267 | } |
| 1268 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1269 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1270 | } |