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