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