Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Orhan K AKYILDIZ | 4f20db5 | 2015-12-30 12:35:44 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 28 | /* denote that this file does not allow legacy hddLog */ |
| 29 | #define HDD_DISALLOW_LEGACY_HDDLOG 1 |
| 30 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 31 | /* Include files */ |
| 32 | #include <linux/semaphore.h> |
| 33 | #include <wlan_hdd_tx_rx.h> |
| 34 | #include <wlan_hdd_softap_tx_rx.h> |
| 35 | #include <linux/netdevice.h> |
| 36 | #include <linux/skbuff.h> |
| 37 | #include <linux/etherdevice.h> |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 38 | #include <qdf_types.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 39 | #include <ani_global.h> |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 40 | #include <qdf_types.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 41 | #include <net/ieee80211_radiotap.h> |
| 42 | #include <cds_sched.h> |
| 43 | #include <wlan_hdd_napi.h> |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 44 | #include <cdp_txrx_cmn.h> |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 45 | #include <cdp_txrx_peer_ops.h> |
Manjunathappa Prakash | 779e486 | 2016-09-12 17:00:11 -0700 | [diff] [blame] | 46 | #include <cds_utils.h> |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 47 | #include <cdp_txrx_flow_ctrl_v2.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 48 | |
| 49 | #ifdef IPA_OFFLOAD |
| 50 | #include <wlan_hdd_ipa.h> |
| 51 | #endif |
| 52 | |
| 53 | /* Preprocessor definitions and constants */ |
| 54 | #undef QCA_HDD_SAP_DUMP_SK_BUFF |
| 55 | |
| 56 | /* Type declarations */ |
| 57 | |
| 58 | /* Function definitions and documenation */ |
| 59 | #ifdef QCA_HDD_SAP_DUMP_SK_BUFF |
| 60 | /** |
| 61 | * hdd_softap_dump_sk_buff() - Dump an skb |
| 62 | * @skb: skb to dump |
| 63 | * |
| 64 | * Return: None |
| 65 | */ |
| 66 | static void hdd_softap_dump_sk_buff(struct sk_buff *skb) |
| 67 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 68 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 69 | "%s: head = %p ", __func__, skb->head); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 70 | /* QDF_TRACE( QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,"%s: data = %p ", __func__, skb->data); */ |
| 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: tail = %p ", __func__, skb->tail); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 73 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 74 | "%s: end = %p ", __func__, skb->end); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 75 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 76 | "%s: len = %d ", __func__, skb->len); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 77 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 78 | "%s: data_len = %d ", __func__, skb->data_len); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 79 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 80 | "%s: mac_len = %d", __func__, skb->mac_len); |
| 81 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 82 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 83 | "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ", skb->data[0], |
| 84 | skb->data[1], skb->data[2], skb->data[3], skb->data[4], |
| 85 | skb->data[5], skb->data[6], skb->data[7]); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 86 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 87 | "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[8], |
| 88 | skb->data[9], skb->data[10], skb->data[11], skb->data[12], |
| 89 | skb->data[13], skb->data[14], skb->data[15]); |
| 90 | } |
| 91 | #else |
| 92 | static void hdd_softap_dump_sk_buff(struct sk_buff *skb) |
| 93 | { |
| 94 | } |
| 95 | #endif |
| 96 | |
| 97 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 98 | /** |
| 99 | * hdd_softap_tx_resume_timer_expired_handler() - TX Q resume timer handler |
| 100 | * @adapter_context: pointer to vdev adapter |
| 101 | * |
| 102 | * TX Q resume timer handler for SAP and P2P GO interface. If Blocked |
| 103 | * OS Q is not resumed during timeout period, to prevent permanent |
| 104 | * stall, resume OS Q forcefully for SAP and P2P GO interface. |
| 105 | * |
| 106 | * Return: None |
| 107 | */ |
| 108 | void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context) |
| 109 | { |
| 110 | hdd_adapter_t *pAdapter = (hdd_adapter_t *) adapter_context; |
| 111 | |
| 112 | if (!pAdapter) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 113 | hdd_err("NULL adapter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 114 | return; |
| 115 | } |
| 116 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 117 | hdd_notice("Enabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 118 | wlan_hdd_netif_queue_control(pAdapter, WLAN_WAKE_ALL_NETIF_QUEUE, |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 119 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 120 | return; |
| 121 | } |
| 122 | |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 123 | #if defined(CONFIG_PER_VDEV_TX_DESC_POOL) |
| 124 | |
| 125 | /** |
| 126 | * hdd_softap_tx_resume_false() - Resume OS TX Q false leads to queue disabling |
| 127 | * @pAdapter: pointer to hdd adapter |
| 128 | * @tx_resume: TX Q resume trigger |
| 129 | * |
| 130 | * |
| 131 | * Return: None |
| 132 | */ |
| 133 | static void |
| 134 | hdd_softap_tx_resume_false(hdd_adapter_t *pAdapter, bool tx_resume) |
| 135 | { |
| 136 | if (true == tx_resume) |
| 137 | return; |
| 138 | |
| 139 | hdd_notice("Disabling queues"); |
| 140 | wlan_hdd_netif_queue_control(pAdapter, WLAN_STOP_ALL_NETIF_QUEUE, |
| 141 | WLAN_DATA_FLOW_CONTROL); |
| 142 | |
| 143 | if (QDF_TIMER_STATE_STOPPED == |
| 144 | qdf_mc_timer_get_current_state(&pAdapter-> |
| 145 | tx_flow_control_timer)) { |
| 146 | QDF_STATUS status; |
| 147 | status = qdf_mc_timer_start(&pAdapter->tx_flow_control_timer, |
| 148 | WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 149 | |
| 150 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 151 | hdd_err("Failed to start tx_flow_control_timer"); |
| 152 | else |
| 153 | pAdapter->hdd_stats.hddTxRxStats.txflow_timer_cnt++; |
| 154 | } |
| 155 | return; |
| 156 | } |
| 157 | #else |
| 158 | |
| 159 | static inline void |
| 160 | hdd_softap_tx_resume_false(hdd_adapter_t *pAdapter, bool tx_resume) |
| 161 | { |
| 162 | return; |
| 163 | } |
| 164 | #endif |
| 165 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 166 | /** |
| 167 | * hdd_softap_tx_resume_cb() - Resume OS TX Q. |
| 168 | * @adapter_context: pointer to vdev apdapter |
| 169 | * @tx_resume: TX Q resume trigger |
| 170 | * |
| 171 | * Q was stopped due to WLAN TX path low resource condition |
| 172 | * |
| 173 | * Return: None |
| 174 | */ |
| 175 | void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume) |
| 176 | { |
| 177 | hdd_adapter_t *pAdapter = (hdd_adapter_t *) adapter_context; |
| 178 | |
| 179 | if (!pAdapter) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 180 | hdd_err("NULL adapter"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 181 | return; |
| 182 | } |
| 183 | |
| 184 | /* Resume TX */ |
| 185 | if (true == tx_resume) { |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 186 | if (QDF_TIMER_STATE_STOPPED != |
| 187 | qdf_mc_timer_get_current_state(&pAdapter-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 188 | tx_flow_control_timer)) { |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 189 | qdf_mc_timer_stop(&pAdapter->tx_flow_control_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 190 | } |
| 191 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 192 | hdd_notice("Enabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 193 | wlan_hdd_netif_queue_control(pAdapter, |
| 194 | WLAN_WAKE_ALL_NETIF_QUEUE, |
| 195 | WLAN_DATA_FLOW_CONTROL); |
| 196 | } |
Poddar, Siddarth | b61cf64 | 2016-04-28 16:02:39 +0530 | [diff] [blame] | 197 | hdd_softap_tx_resume_false(pAdapter, tx_resume); |
| 198 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 199 | return; |
| 200 | } |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 201 | |
| 202 | static inline struct sk_buff *hdd_skb_orphan(hdd_adapter_t *pAdapter, |
| 203 | struct sk_buff *skb) |
| 204 | { |
| 205 | if (pAdapter->tx_flow_low_watermark > 0) |
| 206 | skb_orphan(skb); |
| 207 | else { |
| 208 | skb = skb_unshare(skb, GFP_ATOMIC); |
| 209 | } |
| 210 | |
| 211 | return skb; |
| 212 | } |
| 213 | |
| 214 | #else |
| 215 | |
| 216 | static inline struct sk_buff *hdd_skb_orphan(hdd_adapter_t *pAdapter, |
| 217 | struct sk_buff *skb) |
| 218 | { |
| 219 | return skb_unshare(skb, GFP_ATOMIC); |
| 220 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 221 | #endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */ |
| 222 | |
| 223 | /** |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 224 | * __hdd_softap_hard_start_xmit() - Transmit a frame |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 225 | * @skb: pointer to OS packet (sk_buff) |
| 226 | * @dev: pointer to network device |
| 227 | * |
| 228 | * Function registered with the Linux OS for transmitting |
| 229 | * packets. This version of the function directly passes |
| 230 | * the packet to Transport Layer. |
| 231 | * |
| 232 | * Return: Always returns NETDEV_TX_OK |
| 233 | */ |
Jeff Johnson | 6376abe | 2016-10-05 16:24:56 -0700 | [diff] [blame] | 234 | static int __hdd_softap_hard_start_xmit(struct sk_buff *skb, |
| 235 | struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 236 | { |
| 237 | sme_ac_enum_type ac = SME_AC_BE; |
| 238 | hdd_adapter_t *pAdapter = (hdd_adapter_t *) netdev_priv(dev); |
| 239 | hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 240 | struct qdf_mac_addr *pDestMacAddress; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 241 | uint8_t STAId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 242 | |
| 243 | ++pAdapter->hdd_stats.hddTxRxStats.txXmitCalled; |
| 244 | /* Prevent this function from being called during SSR since TL |
| 245 | * context may not be reinitialized at this time which may |
| 246 | * lead to a crash. |
| 247 | */ |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 248 | if (cds_is_driver_recovering()) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 249 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH, |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 250 | "%s: Recovery in Progress. Ignore!!!", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 251 | goto drop_pkt; |
| 252 | } |
| 253 | |
| 254 | /* |
| 255 | * If the device is operating on a DFS Channel |
| 256 | * then check if SAP is in CAC WAIT state and |
| 257 | * drop the packets. In CAC WAIT state device |
| 258 | * is expected not to transmit any frames. |
| 259 | * SAP starts Tx only after the BSS START is |
| 260 | * done. |
| 261 | */ |
| 262 | if (pHddApCtx->dfs_cac_block_tx) { |
| 263 | goto drop_pkt; |
| 264 | } |
| 265 | |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 266 | /* |
| 267 | * If a transmit function is not registered, drop packet |
| 268 | */ |
| 269 | if (!pAdapter->tx_fn) { |
| 270 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH, |
| 271 | "%s: TX function not registered by the data path", |
| 272 | __func__); |
| 273 | goto drop_pkt; |
| 274 | } |
| 275 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 276 | wlan_hdd_classify_pkt(skb); |
| 277 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 278 | pDestMacAddress = (struct qdf_mac_addr *) skb->data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 279 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 280 | if (QDF_NBUF_CB_GET_IS_BCAST(skb) || |
| 281 | QDF_NBUF_CB_GET_IS_MCAST(skb)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 282 | /* The BC/MC station ID is assigned during BSS |
| 283 | * starting phase. SAP will return the station ID |
| 284 | * used for BC/MC traffic. |
| 285 | */ |
| 286 | STAId = pHddApCtx->uBCStaId; |
| 287 | } else { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 288 | if (QDF_STATUS_SUCCESS != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 289 | hdd_softap_get_sta_id(pAdapter, |
| 290 | pDestMacAddress, &STAId)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 291 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
| 292 | QDF_TRACE_LEVEL_WARN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 293 | "%s: Failed to find right station", __func__); |
| 294 | goto drop_pkt; |
| 295 | } |
| 296 | |
Prakash Dhavali | 3107b75 | 2016-11-28 14:35:06 +0530 | [diff] [blame] | 297 | if (STAId >= WLAN_MAX_STA_COUNT) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 298 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
| 299 | QDF_TRACE_LEVEL_WARN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 300 | "%s: Failed to find right station", __func__); |
| 301 | goto drop_pkt; |
| 302 | } else if (false == pAdapter->aStaInfo[STAId].isUsed) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 303 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
| 304 | QDF_TRACE_LEVEL_WARN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 305 | "%s: STA %d is unregistered", __func__, |
| 306 | STAId); |
| 307 | goto drop_pkt; |
| 308 | } |
| 309 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 310 | if ((OL_TXRX_PEER_STATE_CONN != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 311 | pAdapter->aStaInfo[STAId].tlSTAState) |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 312 | && (OL_TXRX_PEER_STATE_AUTH != |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 313 | pAdapter->aStaInfo[STAId].tlSTAState)) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 314 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
| 315 | QDF_TRACE_LEVEL_WARN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 316 | "%s: Station not connected yet", __func__); |
| 317 | goto drop_pkt; |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 318 | } else if (OL_TXRX_PEER_STATE_CONN == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 319 | pAdapter->aStaInfo[STAId].tlSTAState) { |
| 320 | if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 321 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, |
| 322 | QDF_TRACE_LEVEL_WARN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 323 | "%s: NON-EAPOL packet in non-Authenticated state", |
| 324 | __func__); |
| 325 | goto drop_pkt; |
| 326 | } |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | hdd_get_tx_resource(pAdapter, STAId, |
| 331 | WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 332 | |
| 333 | /* Get TL AC corresponding to Qdisc queue index/AC. */ |
| 334 | ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping]; |
| 335 | ++pAdapter->hdd_stats.hddTxRxStats.txXmitClassifiedAC[ac]; |
| 336 | |
| 337 | #if defined (IPA_OFFLOAD) |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 338 | if (!qdf_nbuf_ipa_owned_get(skb)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 339 | #endif |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 340 | |
| 341 | #if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0)) |
| 342 | /* |
| 343 | * The TCP TX throttling logic is changed a little after |
| 344 | * 3.19-rc1 kernel, the TCP sending limit will be smaller, |
| 345 | * which will throttle the TCP packets to the host driver. |
| 346 | * The TCP UP LINK throughput will drop heavily. In order to |
| 347 | * fix this issue, need to orphan the socket buffer asap, which |
| 348 | * will call skb's destructor to notify the TCP stack that the |
| 349 | * SKB buffer is unowned. And then the TCP stack will pump more |
| 350 | * packets to host driver. |
| 351 | * |
| 352 | * The TX packets might be dropped for UDP case in the iperf |
| 353 | * testing. So need to be protected by follow control. |
| 354 | */ |
| 355 | skb = hdd_skb_orphan(pAdapter, skb); |
| 356 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 357 | /* Check if the buffer has enough header room */ |
| 358 | skb = skb_unshare(skb, GFP_ATOMIC); |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 359 | #endif |
| 360 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 361 | if (!skb) |
Jeff Johnson | edeff23 | 2015-11-11 17:19:42 -0800 | [diff] [blame] | 362 | goto drop_pkt_accounting; |
gbian | ec670c59 | 2016-11-24 11:21:30 +0800 | [diff] [blame] | 363 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 364 | #if defined (IPA_OFFLOAD) |
| 365 | } |
| 366 | #endif |
| 367 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 368 | pAdapter->stats.tx_bytes += skb->len; |
| 369 | ++pAdapter->stats.tx_packets; |
| 370 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 371 | hdd_event_eapol_log(skb, QDF_TX); |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 372 | qdf_dp_trace_log_pkt(pAdapter->sessionId, skb, QDF_TX); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 373 | QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK; |
| 374 | QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 375 | |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 376 | qdf_dp_trace_set_track(skb, QDF_TX); |
| 377 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD, |
| 378 | (uint8_t *)&skb->data, sizeof(skb->data), QDF_TX)); |
| 379 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD, |
| 380 | (uint8_t *)skb->data, qdf_nbuf_len(skb), QDF_TX)); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 381 | if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE) |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 382 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD, |
| 383 | (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE], |
| 384 | (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 385 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 386 | if (pAdapter->tx_fn(pAdapter->txrx_vdev, |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 387 | (qdf_nbuf_t) skb) != NULL) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 388 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_WARN, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 389 | "%s: Failed to send packet to txrx for staid:%d", |
| 390 | __func__, STAId); |
| 391 | ++pAdapter->hdd_stats.hddTxRxStats.txXmitDroppedAC[ac]; |
| 392 | goto drop_pkt; |
| 393 | } |
Dustin Brown | e0024fa | 2016-10-14 16:29:21 -0700 | [diff] [blame] | 394 | netif_trans_update(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 395 | |
| 396 | return NETDEV_TX_OK; |
| 397 | |
| 398 | drop_pkt: |
| 399 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 400 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD, |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 401 | (uint8_t *)skb->data, qdf_nbuf_len(skb), QDF_TX)); |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 402 | if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE) |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 403 | DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD, |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 404 | (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE], |
| 405 | (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX)); |
Jeff Johnson | edeff23 | 2015-11-11 17:19:42 -0800 | [diff] [blame] | 406 | kfree_skb(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 407 | |
Jeff Johnson | edeff23 | 2015-11-11 17:19:42 -0800 | [diff] [blame] | 408 | drop_pkt_accounting: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 409 | ++pAdapter->stats.tx_dropped; |
| 410 | ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 411 | |
| 412 | return NETDEV_TX_OK; |
| 413 | } |
| 414 | |
| 415 | /** |
Mukul Sharma | c4de4ef | 2016-09-12 15:39:00 +0530 | [diff] [blame] | 416 | * hdd_softap_hard_start_xmit() - Wrapper function to protect |
| 417 | * __hdd_softap_hard_start_xmit from SSR |
| 418 | * @skb: pointer to OS packet |
| 419 | * @dev: pointer to net_device structure |
| 420 | * |
| 421 | * Function called by OS if any packet needs to transmit. |
| 422 | * |
| 423 | * Return: Always returns NETDEV_TX_OK |
| 424 | */ |
| 425 | int hdd_softap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) |
| 426 | { |
| 427 | int ret; |
| 428 | |
| 429 | cds_ssr_protect(__func__); |
| 430 | ret = __hdd_softap_hard_start_xmit(skb, dev); |
| 431 | cds_ssr_unprotect(__func__); |
| 432 | |
| 433 | return ret; |
| 434 | } |
| 435 | |
| 436 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 437 | * __hdd_softap_tx_timeout() - TX timeout handler |
| 438 | * @dev: pointer to network device |
| 439 | * |
| 440 | * This function is registered as a netdev ndo_tx_timeout method, and |
| 441 | * is invoked by the kernel if the driver takes too long to transmit a |
| 442 | * frame. |
| 443 | * |
| 444 | * Return: None |
| 445 | */ |
| 446 | static void __hdd_softap_tx_timeout(struct net_device *dev) |
| 447 | { |
| 448 | hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 449 | hdd_context_t *hdd_ctx; |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 450 | struct netdev_queue *txq; |
| 451 | int i; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 452 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 453 | DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT, |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 454 | NULL, 0, QDF_TX)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 455 | /* Getting here implies we disabled the TX queues for too |
| 456 | * long. Queues are disabled either because of disassociation |
| 457 | * or low resource scenarios. In case of disassociation it is |
| 458 | * ok to ignore this. But if associated, we have do possible |
| 459 | * recovery here |
| 460 | */ |
| 461 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 462 | if (cds_is_driver_recovering()) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 463 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 464 | "%s: Recovery in Progress. Ignore!!!", __func__); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 465 | return; |
| 466 | } |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 467 | |
Dustin Brown | e0024fa | 2016-10-14 16:29:21 -0700 | [diff] [blame] | 468 | TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA); |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 469 | |
| 470 | for (i = 0; i < NUM_TX_QUEUES; i++) { |
| 471 | txq = netdev_get_tx_queue(dev, i); |
| 472 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, |
| 473 | QDF_TRACE_LEVEL_ERROR, |
| 474 | "Queue%d status: %d txq->trans_start %lu", |
| 475 | i, netif_tx_queue_stopped(txq), txq->trans_start); |
| 476 | } |
| 477 | |
| 478 | wlan_hdd_display_netif_queue_history(hdd_ctx); |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 479 | cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC)); |
Nirav Shah | 89223f7 | 2016-03-01 18:10:38 +0530 | [diff] [blame] | 480 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR, |
| 481 | "carrier state: %d", netif_carrier_ok(dev)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 482 | } |
| 483 | |
| 484 | /** |
| 485 | * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout |
| 486 | * @dev: pointer to net_device |
| 487 | * |
| 488 | * Return: none |
| 489 | */ |
| 490 | void hdd_softap_tx_timeout(struct net_device *dev) |
| 491 | { |
| 492 | cds_ssr_protect(__func__); |
| 493 | __hdd_softap_tx_timeout(dev); |
| 494 | cds_ssr_unprotect(__func__); |
| 495 | } |
| 496 | |
| 497 | /** |
| 498 | * @hdd_softap_init_tx_rx() - Initialize Tx/RX module |
| 499 | * @pAdapter: pointer to adapter context |
| 500 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 501 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 502 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 503 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 504 | QDF_STATUS hdd_softap_init_tx_rx(hdd_adapter_t *pAdapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 505 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 506 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 507 | |
| 508 | uint8_t STAId = 0; |
| 509 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 510 | qdf_mem_zero(&pAdapter->stats, sizeof(struct net_device_stats)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 511 | |
| 512 | spin_lock_init(&pAdapter->staInfo_lock); |
| 513 | |
| 514 | for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 515 | qdf_mem_zero(&pAdapter->aStaInfo[STAId], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 516 | sizeof(hdd_station_info_t)); |
| 517 | } |
| 518 | |
| 519 | return status; |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module |
| 524 | * @pAdapter: pointer to adapter context |
| 525 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 526 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 527 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 528 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 529 | QDF_STATUS hdd_softap_deinit_tx_rx(hdd_adapter_t *pAdapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 530 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 531 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 532 | |
| 533 | return status; |
| 534 | } |
| 535 | |
| 536 | /** |
| 537 | * hdd_softap_init_tx_rx_sta() - Initialize tx/rx for a softap station |
| 538 | * @pAdapter: pointer to adapter context |
| 539 | * @STAId: Station ID to initialize |
| 540 | * @pmacAddrSTA: pointer to the MAC address of the station |
| 541 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 542 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 543 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 544 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 545 | QDF_STATUS hdd_softap_init_tx_rx_sta(hdd_adapter_t *pAdapter, uint8_t STAId, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 546 | struct qdf_mac_addr *pmacAddrSTA) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 547 | { |
| 548 | spin_lock_bh(&pAdapter->staInfo_lock); |
| 549 | if (pAdapter->aStaInfo[STAId].isUsed) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 550 | spin_unlock_bh(&pAdapter->staInfo_lock); |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 551 | hdd_err("Reinit of in use station %d", STAId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 552 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 553 | } |
| 554 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 555 | qdf_mem_zero(&pAdapter->aStaInfo[STAId], sizeof(hdd_station_info_t)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 556 | |
| 557 | pAdapter->aStaInfo[STAId].isUsed = true; |
| 558 | pAdapter->aStaInfo[STAId].isDeauthInProgress = false; |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 559 | qdf_copy_macaddr(&pAdapter->aStaInfo[STAId].macAddrSTA, pmacAddrSTA); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 560 | |
| 561 | spin_unlock_bh(&pAdapter->staInfo_lock); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 562 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | /** |
| 566 | * hdd_softap_deinit_tx_rx_sta() - Deinitialize tx/rx for a softap station |
| 567 | * @pAdapter: pointer to adapter context |
| 568 | * @STAId: Station ID to deinitialize |
| 569 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 570 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 571 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 572 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 573 | QDF_STATUS hdd_softap_deinit_tx_rx_sta(hdd_adapter_t *pAdapter, uint8_t STAId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 574 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 575 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 576 | hdd_hostapd_state_t *pHostapdState; |
| 577 | |
| 578 | pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter); |
| 579 | |
| 580 | spin_lock_bh(&pAdapter->staInfo_lock); |
| 581 | |
| 582 | if (false == pAdapter->aStaInfo[STAId].isUsed) { |
| 583 | spin_unlock_bh(&pAdapter->staInfo_lock); |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 584 | hdd_err("Deinit station not inited %d", STAId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 585 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | pAdapter->aStaInfo[STAId].isUsed = false; |
| 589 | pAdapter->aStaInfo[STAId].isDeauthInProgress = false; |
| 590 | |
| 591 | spin_unlock_bh(&pAdapter->staInfo_lock); |
| 592 | return status; |
| 593 | } |
| 594 | |
| 595 | /** |
| 596 | * hdd_softap_rx_packet_cbk() - Receive packet handler |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 597 | * @context: pointer to HDD context |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 598 | * @rxBuf: pointer to rx qdf_nbuf |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 599 | * |
| 600 | * Receive callback registered with TL. TL will call this to notify |
| 601 | * the HDD when one or more packets were received for a registered |
| 602 | * STA. |
| 603 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 604 | * Return: QDF_STATUS_E_FAILURE if any errors encountered, |
| 605 | * QDF_STATUS_SUCCESS otherwise |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 606 | */ |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 607 | 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] | 608 | { |
| 609 | hdd_adapter_t *pAdapter = NULL; |
| 610 | int rxstat; |
| 611 | unsigned int cpu_index; |
| 612 | struct sk_buff *skb = NULL; |
| 613 | hdd_context_t *pHddCtx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 614 | |
| 615 | /* Sanity check on inputs */ |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 616 | if (unlikely((NULL == context) || (NULL == rxBuf))) { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 617 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 618 | "%s: Null params being passed", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 619 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 620 | } |
| 621 | |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 622 | pAdapter = (hdd_adapter_t *)context; |
| 623 | if (unlikely(WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) { |
| 624 | QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_FATAL, |
| 625 | "Magic cookie(%x) for adapter sanity verification is invalid", |
| 626 | pAdapter->magic); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 627 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 628 | } |
| 629 | |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 630 | pHddCtx = pAdapter->pHddCtx; |
| 631 | if (unlikely(NULL == pHddCtx)) { |
| 632 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
| 633 | "%s: HDD context is Null", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 634 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | /* walk the chain until all are processed */ |
| 638 | skb = (struct sk_buff *)rxBuf; |
| 639 | |
| 640 | hdd_softap_dump_sk_buff(skb); |
| 641 | |
| 642 | skb->dev = pAdapter->dev; |
| 643 | |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 644 | if (unlikely(skb->dev == NULL)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 645 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 646 | QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 647 | "%s: ERROR!!Invalid netdevice", __func__); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 648 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 649 | } |
| 650 | cpu_index = wlan_hdd_get_cpu(); |
| 651 | ++pAdapter->hdd_stats.hddTxRxStats.rxPackets[cpu_index]; |
| 652 | ++pAdapter->stats.rx_packets; |
| 653 | pAdapter->stats.rx_bytes += skb->len; |
| 654 | |
Nirav Shah | 5e74bb8 | 2016-07-20 16:01:27 +0530 | [diff] [blame] | 655 | hdd_event_eapol_log(skb, QDF_RX); |
Nirav Shah | 0d58a7e | 2016-04-26 22:54:12 +0530 | [diff] [blame] | 656 | DPTRACE(qdf_dp_trace(rxBuf, |
| 657 | QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD, |
| 658 | qdf_nbuf_data_addr(rxBuf), |
| 659 | sizeof(qdf_nbuf_data(rxBuf)), QDF_RX)); |
| 660 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 661 | skb->protocol = eth_type_trans(skb, skb->dev); |
Dustin Brown | cd75694 | 2016-11-23 12:25:33 -0800 | [diff] [blame] | 662 | |
| 663 | /* hold configurable wakelock for unicast traffic */ |
| 664 | if (pHddCtx->config->rx_wakelock_timeout && |
| 665 | skb->pkt_type != PACKET_BROADCAST && |
| 666 | skb->pkt_type != PACKET_MULTICAST) { |
| 667 | cds_host_diag_log_work(&pHddCtx->rx_wake_lock, |
| 668 | pHddCtx->config->rx_wakelock_timeout, |
| 669 | WIFI_POWER_EVENT_WAKELOCK_HOLD_RX); |
| 670 | qdf_wake_lock_timeout_acquire(&pHddCtx->rx_wake_lock, |
| 671 | pHddCtx->config-> |
| 672 | rx_wakelock_timeout); |
| 673 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 674 | |
| 675 | /* Remove SKB from internal tracking table before submitting |
| 676 | * it to stack |
| 677 | */ |
Nirav Shah | cbc6d72 | 2016-03-01 16:24:53 +0530 | [diff] [blame] | 678 | qdf_net_buf_debug_release_skb(rxBuf); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 679 | if (hdd_napi_enabled(HDD_NAPI_ANY) && |
| 680 | !pHddCtx->enableRxThread) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 681 | rxstat = netif_receive_skb(skb); |
| 682 | else |
| 683 | rxstat = netif_rx_ni(skb); |
| 684 | if (NET_RX_SUCCESS == rxstat) { |
| 685 | ++pAdapter->hdd_stats.hddTxRxStats.rxDelivered[cpu_index]; |
| 686 | } else { |
| 687 | ++pAdapter->hdd_stats.hddTxRxStats.rxRefused[cpu_index]; |
| 688 | } |
| 689 | |
| 690 | pAdapter->dev->last_rx = jiffies; |
| 691 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 692 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 693 | } |
| 694 | |
| 695 | /** |
| 696 | * hdd_softap_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId) |
| 697 | * @pAdapter: pointer to adapter context |
| 698 | * @staId: Station ID to deregister |
| 699 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 700 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 701 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 702 | QDF_STATUS hdd_softap_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 703 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 704 | QDF_STATUS qdf_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 705 | hdd_context_t *pHddCtx; |
| 706 | |
| 707 | if (NULL == pAdapter) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 708 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 709 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 713 | hdd_err("Invalid adapter magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 714 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 715 | } |
| 716 | |
| 717 | pHddCtx = (hdd_context_t *) (pAdapter->pHddCtx); |
| 718 | /* Clear station in TL and then update HDD data |
| 719 | * structures. This helps to block RX frames from other |
| 720 | * station to this station. |
| 721 | */ |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 722 | qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC), |
| 723 | cds_get_context(QDF_MODULE_ID_TXRX), staId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 724 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 725 | hdd_err("cdp_peer_clear failed for staID %d, Status=%d [0x%08X]", |
| 726 | staId, qdf_status, qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | if (pAdapter->aStaInfo[staId].isUsed) { |
| 730 | spin_lock_bh(&pAdapter->staInfo_lock); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 731 | qdf_mem_zero(&pAdapter->aStaInfo[staId], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 732 | sizeof(hdd_station_info_t)); |
| 733 | spin_unlock_bh(&pAdapter->staInfo_lock); |
| 734 | } |
| 735 | pHddCtx->sta_to_adapter[staId] = NULL; |
| 736 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 737 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 738 | } |
| 739 | |
| 740 | /** |
| 741 | * hdd_softap_register_sta() - Register a SoftAP STA |
| 742 | * @pAdapter: pointer to adapter context |
| 743 | * @fAuthRequired: is additional authentication required? |
| 744 | * @fPrivacyBit: should 802.11 privacy bit be set? |
| 745 | * @staId: station ID assigned to this station |
| 746 | * @ucastSig: unicast security signature |
| 747 | * @bcastSig: broadcast security signature |
| 748 | * @pPeerMacAddress: station MAC address |
| 749 | * @fWmmEnabled: is WMM enabled for this STA? |
| 750 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 751 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 752 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 753 | QDF_STATUS hdd_softap_register_sta(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 754 | bool fAuthRequired, |
| 755 | bool fPrivacyBit, |
| 756 | uint8_t staId, |
| 757 | uint8_t ucastSig, |
| 758 | uint8_t bcastSig, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 759 | struct qdf_mac_addr *pPeerMacAddress, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | bool fWmmEnabled) |
| 761 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 762 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 763 | struct ol_txrx_desc_type staDesc = { 0 }; |
| 764 | hdd_context_t *pHddCtx = pAdapter->pHddCtx; |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 765 | struct ol_txrx_ops txrx_ops; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 766 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 767 | void *pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 768 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 769 | hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u", |
| 770 | staId, fAuthRequired, fPrivacyBit, fWmmEnabled); |
| 771 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 772 | /* |
| 773 | * Clean up old entry if it is not cleaned up properly |
| 774 | */ |
| 775 | if (pAdapter->aStaInfo[staId].isUsed) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 776 | hdd_info("clean up old entry for STA %d", staId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 777 | hdd_softap_deregister_sta(pAdapter, staId); |
| 778 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 779 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 780 | /* Get the Station ID from the one saved during the assocation. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 781 | staDesc.sta_id = staId; |
| 782 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 783 | /* Save the pAdapter Pointer for this staId */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 784 | pHddCtx->sta_to_adapter[staId] = pAdapter; |
| 785 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 786 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 787 | hdd_softap_init_tx_rx_sta(pAdapter, staId, |
| 788 | pPeerMacAddress); |
| 789 | |
| 790 | staDesc.is_qos_enabled = fWmmEnabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 791 | |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 792 | /* Register the vdev transmit and receive functions */ |
| 793 | qdf_mem_zero(&txrx_ops, sizeof(txrx_ops)); |
| 794 | txrx_ops.rx.rx = hdd_softap_rx_packet_cbk; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 795 | cdp_vdev_register(soc, |
| 796 | cdp_get_vdev_from_vdev_id(soc, pdev, pAdapter->sessionId), |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 797 | pAdapter, &txrx_ops); |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 798 | pAdapter->txrx_vdev = cdp_get_vdev_from_vdev_id(soc, pdev, |
| 799 | pAdapter->sessionId); |
Dhanashri Atre | 168d2b4 | 2016-02-22 14:43:06 -0800 | [diff] [blame] | 800 | pAdapter->tx_fn = txrx_ops.tx.tx; |
Dhanashri Atre | 182b027 | 2016-02-17 15:35:07 -0800 | [diff] [blame] | 801 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 802 | qdf_status = cdp_peer_register(soc, pdev, &staDesc); |
Dhanashri Atre | 50141c5 | 2016-04-07 13:15:29 -0700 | [diff] [blame] | 803 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 804 | hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]", |
| 805 | qdf_status, qdf_status); |
Dhanashri Atre | 50141c5 | 2016-04-07 13:15:29 -0700 | [diff] [blame] | 806 | return qdf_status; |
| 807 | } |
| 808 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 809 | /* if ( WPA ), tell TL to go to 'connected' and after keys come to the |
| 810 | * driver then go to 'authenticated'. For all other authentication |
| 811 | * types (those that do not require upper layer authentication) we can |
| 812 | * put TL directly into 'authenticated' state |
| 813 | */ |
| 814 | |
| 815 | pAdapter->aStaInfo[staId].ucSTAId = staId; |
| 816 | pAdapter->aStaInfo[staId].isQosEnabled = fWmmEnabled; |
| 817 | |
| 818 | if (!fAuthRequired) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 819 | hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time", |
| 820 | pAdapter->aStaInfo[staId].ucSTAId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 821 | |
| 822 | /* Connections that do not need Upper layer auth, |
| 823 | * transition TL directly to 'Authenticated' state. |
| 824 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 825 | qdf_status = hdd_change_peer_state(pAdapter, staDesc.sta_id, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 826 | OL_TXRX_PEER_STATE_AUTH, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 827 | |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 828 | pAdapter->aStaInfo[staId].tlSTAState = OL_TXRX_PEER_STATE_AUTH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 829 | pAdapter->sessionCtx.ap.uIsAuthenticated = true; |
| 830 | } else { |
| 831 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 832 | hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time", |
| 833 | pAdapter->aStaInfo[staId].ucSTAId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 834 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 835 | qdf_status = hdd_change_peer_state(pAdapter, staDesc.sta_id, |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 836 | OL_TXRX_PEER_STATE_CONN, false); |
| 837 | pAdapter->aStaInfo[staId].tlSTAState = OL_TXRX_PEER_STATE_CONN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 838 | |
| 839 | pAdapter->sessionCtx.ap.uIsAuthenticated = false; |
| 840 | |
| 841 | } |
| 842 | |
| 843 | /* Enable Tx queue */ |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 844 | hdd_notice("Enabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 845 | wlan_hdd_netif_queue_control(pAdapter, |
| 846 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 847 | WLAN_CONTROL_PATH); |
| 848 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 849 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | /** |
| 853 | * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA |
| 854 | * @pAdapter: pointer to adapter context |
| 855 | * @fPrivacyBit: should 802.11 privacy bit be set? |
| 856 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 857 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 858 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 859 | QDF_STATUS hdd_softap_register_bc_sta(hdd_adapter_t *pAdapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 860 | bool fPrivacyBit) |
| 861 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 862 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 863 | hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 864 | struct qdf_mac_addr broadcastMacAddr = |
| 865 | QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | hdd_ap_ctx_t *pHddApCtx; |
| 867 | |
| 868 | pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter); |
| 869 | |
| 870 | pHddCtx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = pAdapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 871 | pHddCtx->sta_to_adapter[pHddApCtx->uBCStaId] = pAdapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 872 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 873 | hdd_softap_register_sta(pAdapter, false, fPrivacyBit, |
| 874 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))-> |
| 875 | uBCStaId, 0, 1, &broadcastMacAddr, 0); |
| 876 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 877 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 878 | } |
| 879 | |
| 880 | /** |
| 881 | * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA |
| 882 | * @pAdapter: pointer to adapter context |
| 883 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 884 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 885 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 886 | QDF_STATUS hdd_softap_deregister_bc_sta(hdd_adapter_t *pAdapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 887 | { |
| 888 | return hdd_softap_deregister_sta(pAdapter, |
| 889 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))-> |
| 890 | uBCStaId); |
| 891 | } |
| 892 | |
| 893 | /** |
| 894 | * hdd_softap_stop_bss() - Stop the BSS |
| 895 | * @pAdapter: pointer to adapter context |
| 896 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 897 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 898 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 899 | QDF_STATUS hdd_softap_stop_bss(hdd_adapter_t *pAdapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 900 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 901 | QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 902 | uint8_t staId = 0; |
| 903 | hdd_context_t *pHddCtx; |
| 904 | pHddCtx = WLAN_HDD_GET_CTX(pAdapter); |
| 905 | |
| 906 | /* bss deregister is not allowed during wlan driver loading or |
| 907 | * unloading |
| 908 | */ |
Rajeev Kumar | fec3dbe | 2016-01-19 15:23:52 -0800 | [diff] [blame] | 909 | if (cds_is_load_or_unload_in_progress()) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 910 | hdd_err("Loading_unloading in Progress, state: 0x%x. Ignore!!!", |
| 911 | cds_get_driver_state()); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 912 | return QDF_STATUS_E_PERM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 913 | } |
| 914 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 915 | qdf_status = hdd_softap_deregister_bc_sta(pAdapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 916 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 917 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 918 | hdd_err("Failed to deregister BC sta Id %d", |
| 919 | (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->uBCStaId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | } |
| 921 | |
| 922 | for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) { |
| 923 | /* This excludes BC sta as it is already deregistered */ |
| 924 | if (pAdapter->aStaInfo[staId].isUsed) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 925 | qdf_status = hdd_softap_deregister_sta(pAdapter, staId); |
| 926 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 927 | hdd_err("Failed to deregister sta Id %d", |
| 928 | staId); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 929 | } |
| 930 | } |
| 931 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 932 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | /** |
| 936 | * hdd_softap_change_sta_state() - Change the state of a SoftAP station |
| 937 | * @pAdapter: pointer to adapter context |
| 938 | * @pDestMacAddress: MAC address of the station |
| 939 | * @state: new state of the station |
| 940 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 941 | * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 942 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 943 | QDF_STATUS hdd_softap_change_sta_state(hdd_adapter_t *pAdapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 944 | struct qdf_mac_addr *pDestMacAddress, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 945 | enum ol_txrx_peer_state state) |
| 946 | { |
| 947 | uint8_t ucSTAId = WLAN_MAX_STA_COUNT; |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 948 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 949 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 950 | ENTER_DEV(pAdapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 951 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 952 | qdf_status = hdd_softap_get_sta_id(pAdapter, pDestMacAddress, &ucSTAId); |
| 953 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 954 | hdd_err("Failed to find right station"); |
| 955 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | if (false == |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 959 | qdf_is_macaddr_equal(&pAdapter->aStaInfo[ucSTAId].macAddrSTA, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 960 | pDestMacAddress)) { |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 961 | hdd_err("Station %u MAC address not matching", ucSTAId); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 962 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 963 | } |
| 964 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 965 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 966 | hdd_change_peer_state(pAdapter, ucSTAId, state, false); |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 967 | hdd_info("Station %u changed to state %d", ucSTAId, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 968 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 969 | if (QDF_STATUS_SUCCESS == qdf_status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 970 | pAdapter->aStaInfo[ucSTAId].tlSTAState = |
Dhanashri Atre | b08959a | 2016-03-01 17:28:03 -0800 | [diff] [blame] | 971 | OL_TXRX_PEER_STATE_AUTH; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 972 | } |
| 973 | |
Jeff Johnson | d5bd6fd | 2016-12-05 12:29:21 -0800 | [diff] [blame^] | 974 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 975 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 976 | } |
| 977 | |
| 978 | /* |
| 979 | * hdd_softap_get_sta_id() - Find station ID from MAC address |
| 980 | * @pAdapter: pointer to adapter context |
| 981 | * @pDestMacAddress: MAC address of the destination |
| 982 | * @staId: Station ID associated with the MAC address |
| 983 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 984 | * Return: QDF_STATUS_SUCCESS if a match was found, in which case |
| 985 | * staId is populated, QDF_STATUS_E_FAILURE if a match is |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 986 | * not found |
| 987 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 988 | QDF_STATUS hdd_softap_get_sta_id(hdd_adapter_t *pAdapter, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 989 | struct qdf_mac_addr *pMacAddress, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 990 | uint8_t *staId) |
| 991 | { |
| 992 | uint8_t i; |
| 993 | |
| 994 | for (i = 0; i < WLAN_MAX_STA_COUNT; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 995 | if (!qdf_mem_cmp |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 996 | (&pAdapter->aStaInfo[i].macAddrSTA, pMacAddress, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 997 | QDF_MAC_ADDR_SIZE) && pAdapter->aStaInfo[i].isUsed) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 998 | *staId = i; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 999 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1000 | } |
| 1001 | } |
| 1002 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1003 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1004 | } |