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