blob: f38c5fc44df9fa71d10c09ab6c86a3af3c21bd5e [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jeff Johnson4fca3b52017-01-12 08:44:18 -08002 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -080028/* denote that this file does not allow legacy hddLog */
29#define HDD_DISALLOW_LEGACY_HDDLOG 1
30
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031/* Include files */
32#include <linux/semaphore.h>
33#include <wlan_hdd_tx_rx.h>
34#include <wlan_hdd_softap_tx_rx.h>
35#include <linux/netdevice.h>
36#include <linux/skbuff.h>
37#include <linux/etherdevice.h>
Anurag Chouhan6d760662016-02-20 16:05:43 +053038#include <qdf_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039#include <ani_global.h>
Anurag Chouhan6d760662016-02-20 16:05:43 +053040#include <qdf_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080041#include <net/ieee80211_radiotap.h>
42#include <cds_sched.h>
43#include <wlan_hdd_napi.h>
Leo Changfdb45c32016-10-28 11:09:23 -070044#include <cdp_txrx_cmn.h>
Dhanashri Atreb08959a2016-03-01 17:28:03 -080045#include <cdp_txrx_peer_ops.h>
Manjunathappa Prakash779e4862016-09-12 17:00:11 -070046#include <cds_utils.h>
Leo Changfdb45c32016-10-28 11:09:23 -070047#include <cdp_txrx_flow_ctrl_v2.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080048#include <cdp_txrx_handle.h>
Abhishek Singh07c627e2017-03-20 17:56:34 +053049#include <wlan_hdd_object_manager.h>
Rachit Kankane2487f8f2017-04-19 14:30:19 +053050#include "wlan_p2p_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080051#ifdef IPA_OFFLOAD
52#include <wlan_hdd_ipa.h>
53#endif
54
55/* Preprocessor definitions and constants */
56#undef QCA_HDD_SAP_DUMP_SK_BUFF
57
58/* Type declarations */
59
60/* Function definitions and documenation */
61#ifdef QCA_HDD_SAP_DUMP_SK_BUFF
62/**
63 * hdd_softap_dump_sk_buff() - Dump an skb
64 * @skb: skb to dump
65 *
66 * Return: None
67 */
68static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
69{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053070 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080071 "%s: head = %p ", __func__, skb->head);
Srinivas Girigowdae806a822017-03-25 11:25:30 -070072 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073 "%s: tail = %p ", __func__, skb->tail);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053074 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075 "%s: end = %p ", __func__, skb->end);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053076 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077 "%s: len = %d ", __func__, skb->len);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053078 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079 "%s: data_len = %d ", __func__, skb->data_len);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053080 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081 "%s: mac_len = %d", __func__, skb->mac_len);
82
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053083 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ", skb->data[0],
85 skb->data[1], skb->data[2], skb->data[3], skb->data[4],
86 skb->data[5], skb->data[6], skb->data[7]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053087 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[8],
89 skb->data[9], skb->data[10], skb->data[11], skb->data[12],
90 skb->data[13], skb->data[14], skb->data[15]);
91}
92#else
93static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
94{
95}
96#endif
97
98#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
99/**
100 * hdd_softap_tx_resume_timer_expired_handler() - TX Q resume timer handler
101 * @adapter_context: pointer to vdev adapter
102 *
103 * TX Q resume timer handler for SAP and P2P GO interface. If Blocked
104 * OS Q is not resumed during timeout period, to prevent permanent
105 * stall, resume OS Q forcefully for SAP and P2P GO interface.
106 *
107 * Return: None
108 */
109void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context)
110{
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700111 struct hdd_adapter *pAdapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112
113 if (!pAdapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800114 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115 return;
116 }
117
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700118 hdd_debug("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800119 wlan_hdd_netif_queue_control(pAdapter, WLAN_WAKE_ALL_NETIF_QUEUE,
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800120 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121}
122
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530123#if defined(CONFIG_PER_VDEV_TX_DESC_POOL)
124
125/**
126 * hdd_softap_tx_resume_false() - Resume OS TX Q false leads to queue disabling
127 * @pAdapter: pointer to hdd adapter
128 * @tx_resume: TX Q resume trigger
129 *
130 *
131 * Return: None
132 */
133static void
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700134hdd_softap_tx_resume_false(struct hdd_adapter *pAdapter, bool tx_resume)
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530135{
136 if (true == tx_resume)
137 return;
138
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700139 hdd_debug("Disabling queues");
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530140 wlan_hdd_netif_queue_control(pAdapter, WLAN_STOP_ALL_NETIF_QUEUE,
141 WLAN_DATA_FLOW_CONTROL);
142
143 if (QDF_TIMER_STATE_STOPPED ==
144 qdf_mc_timer_get_current_state(&pAdapter->
145 tx_flow_control_timer)) {
146 QDF_STATUS status;
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700147
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530148 status = qdf_mc_timer_start(&pAdapter->tx_flow_control_timer,
149 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
150
151 if (!QDF_IS_STATUS_SUCCESS(status))
152 hdd_err("Failed to start tx_flow_control_timer");
153 else
154 pAdapter->hdd_stats.hddTxRxStats.txflow_timer_cnt++;
155 }
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530156}
157#else
158
159static inline void
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700160hdd_softap_tx_resume_false(struct hdd_adapter *pAdapter, bool tx_resume)
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530161{
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530162}
163#endif
164
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165/**
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 */
174void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume)
175{
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700176 struct hdd_adapter *pAdapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177
178 if (!pAdapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800179 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 return;
181 }
182
183 /* Resume TX */
184 if (true == tx_resume) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530185 if (QDF_TIMER_STATE_STOPPED !=
186 qdf_mc_timer_get_current_state(&pAdapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 tx_flow_control_timer)) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530188 qdf_mc_timer_stop(&pAdapter->tx_flow_control_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189 }
190
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700191 hdd_debug("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800192 wlan_hdd_netif_queue_control(pAdapter,
193 WLAN_WAKE_ALL_NETIF_QUEUE,
194 WLAN_DATA_FLOW_CONTROL);
195 }
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530196 hdd_softap_tx_resume_false(pAdapter, tx_resume);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197}
gbianec670c592016-11-24 11:21:30 +0800198
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700199static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *pAdapter,
gbianec670c592016-11-24 11:21:30 +0800200 struct sk_buff *skb)
201{
202 if (pAdapter->tx_flow_low_watermark > 0)
203 skb_orphan(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700204 else
gbianec670c592016-11-24 11:21:30 +0800205 skb = skb_unshare(skb, GFP_ATOMIC);
gbianec670c592016-11-24 11:21:30 +0800206
207 return skb;
208}
209
210#else
Mohit Khannad0b63f52017-02-18 18:05:52 -0800211/**
212 * hdd_skb_orphan() - skb_unshare a cloned packed else skb_orphan
213 * @pAdapter: pointer to HDD adapter
214 * @skb: pointer to skb data packet
215 *
216 * Return: pointer to skb structure
217 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700218static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *pAdapter,
Mohit Khannad0b63f52017-02-18 18:05:52 -0800219 struct sk_buff *skb) {
gbianec670c592016-11-24 11:21:30 +0800220
Mohit Khannad0b63f52017-02-18 18:05:52 -0800221 struct sk_buff *nskb;
Jeff Johnsonf7726872017-08-28 11:38:31 -0700222 struct hdd_context *hdd_ctx = pAdapter->pHddCtx;
Mohit Khannad0b63f52017-02-18 18:05:52 -0800223
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700224 nskb = skb_unshare(skb, GFP_ATOMIC);
225 if (unlikely(hdd_ctx->config->tx_orphan_enable) && (nskb == skb)) {
Mohit Khannad0b63f52017-02-18 18:05:52 -0800226 /*
227 * For UDP packets we want to orphan the packet to allow the app
228 * to send more packets. The flow would ultimately be controlled
229 * by the limited number of tx descriptors for the vdev.
230 */
231 ++pAdapter->hdd_stats.hddTxRxStats.txXmitOrphaned;
232 skb_orphan(skb);
233 }
234 return nskb;
gbianec670c592016-11-24 11:21:30 +0800235}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
237
238/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530239 * __hdd_softap_hard_start_xmit() - Transmit a frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 * @skb: pointer to OS packet (sk_buff)
241 * @dev: pointer to network device
242 *
243 * Function registered with the Linux OS for transmitting
244 * packets. This version of the function directly passes
245 * the packet to Transport Layer.
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530246 * In case of any packet drop or error, log the error with
247 * INFO HIGH/LOW/MEDIUM to avoid excessive logging in kmsg.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 *
249 * Return: Always returns NETDEV_TX_OK
250 */
Jeff Johnson6376abe2016-10-05 16:24:56 -0700251static int __hdd_softap_hard_start_xmit(struct sk_buff *skb,
252 struct net_device *dev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253{
254 sme_ac_enum_type ac = SME_AC_BE;
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700255 struct hdd_adapter *pAdapter = (struct hdd_adapter *) netdev_priv(dev);
Jeff Johnson87251032017-08-29 13:31:11 -0700256 struct hdd_ap_ctx *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530257 struct qdf_mac_addr *pDestMacAddress;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 uint8_t STAId;
Will Huang496b36c2017-07-11 16:38:50 +0800259 uint32_t num_seg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260
261 ++pAdapter->hdd_stats.hddTxRxStats.txXmitCalled;
262 /* Prevent this function from being called during SSR since TL
263 * context may not be reinitialized at this time which may
264 * lead to a crash.
265 */
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +0530266 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530267 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800268 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269 goto drop_pkt;
270 }
271
272 /*
273 * If the device is operating on a DFS Channel
274 * then check if SAP is in CAC WAIT state and
275 * drop the packets. In CAC WAIT state device
276 * is expected not to transmit any frames.
277 * SAP starts Tx only after the BSS START is
278 * done.
279 */
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700280 if (pHddApCtx->dfs_cac_block_tx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800283 /*
Jeff Johnson4fca3b52017-01-12 08:44:18 -0800284 * If a transmit function is not registered, drop packet
285 */
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800286 if (!pAdapter->tx_fn) {
287 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
288 "%s: TX function not registered by the data path",
289 __func__);
290 goto drop_pkt;
291 }
292
Nirav Shah5e74bb82016-07-20 16:01:27 +0530293 wlan_hdd_classify_pkt(skb);
294
Anurag Chouhan6d760662016-02-20 16:05:43 +0530295 pDestMacAddress = (struct qdf_mac_addr *) skb->data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296
Nirav Shah5e74bb82016-07-20 16:01:27 +0530297 if (QDF_NBUF_CB_GET_IS_BCAST(skb) ||
298 QDF_NBUF_CB_GET_IS_MCAST(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 /* The BC/MC station ID is assigned during BSS
300 * starting phase. SAP will return the station ID
301 * used for BC/MC traffic.
302 */
303 STAId = pHddApCtx->uBCStaId;
304 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530305 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 hdd_softap_get_sta_id(pAdapter,
307 pDestMacAddress, &STAId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530308 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530309 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 "%s: Failed to find right station", __func__);
311 goto drop_pkt;
312 }
313
Prakash Dhavali3107b752016-11-28 14:35:06 +0530314 if (STAId >= WLAN_MAX_STA_COUNT) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530315 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530316 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800317 "%s: Failed to find right station", __func__);
318 goto drop_pkt;
319 } else if (false == pAdapter->aStaInfo[STAId].isUsed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530320 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530321 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322 "%s: STA %d is unregistered", __func__,
323 STAId);
324 goto drop_pkt;
Poddar, Siddartha5075462017-03-16 19:20:09 +0530325 } else if (true == pAdapter->aStaInfo[STAId].
326 isDeauthInProgress) {
327 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530328 QDF_TRACE_LEVEL_INFO_HIGH,
Poddar, Siddartha5075462017-03-16 19:20:09 +0530329 "%s: STA %d deauth in progress", __func__,
330 STAId);
331 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 }
333
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800334 if ((OL_TXRX_PEER_STATE_CONN !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 pAdapter->aStaInfo[STAId].tlSTAState)
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800336 && (OL_TXRX_PEER_STATE_AUTH !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 pAdapter->aStaInfo[STAId].tlSTAState)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530338 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530339 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 "%s: Station not connected yet", __func__);
341 goto drop_pkt;
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800342 } else if (OL_TXRX_PEER_STATE_CONN ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343 pAdapter->aStaInfo[STAId].tlSTAState) {
344 if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530345 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530346 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347 "%s: NON-EAPOL packet in non-Authenticated state",
348 __func__);
349 goto drop_pkt;
350 }
351 }
352 }
353
354 hdd_get_tx_resource(pAdapter, STAId,
355 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
356
357 /* Get TL AC corresponding to Qdisc queue index/AC. */
358 ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping];
359 ++pAdapter->hdd_stats.hddTxRxStats.txXmitClassifiedAC[ac];
360
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700361#if defined(IPA_OFFLOAD)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530362 if (!qdf_nbuf_ipa_owned_get(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363#endif
gbianec670c592016-11-24 11:21:30 +0800364
365#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
366 /*
Jeff Johnson4fca3b52017-01-12 08:44:18 -0800367 * The TCP TX throttling logic is changed a little after
368 * 3.19-rc1 kernel, the TCP sending limit will be smaller,
369 * which will throttle the TCP packets to the host driver.
370 * The TCP UP LINK throughput will drop heavily. In order to
371 * fix this issue, need to orphan the socket buffer asap, which
372 * will call skb's destructor to notify the TCP stack that the
373 * SKB buffer is unowned. And then the TCP stack will pump more
374 * packets to host driver.
375 *
376 * The TX packets might be dropped for UDP case in the iperf
377 * testing. So need to be protected by follow control.
378 */
gbianec670c592016-11-24 11:21:30 +0800379 skb = hdd_skb_orphan(pAdapter, skb);
380#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 /* Check if the buffer has enough header room */
382 skb = skb_unshare(skb, GFP_ATOMIC);
gbianec670c592016-11-24 11:21:30 +0800383#endif
384
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 if (!skb)
Jeff Johnsonedeff232015-11-11 17:19:42 -0800386 goto drop_pkt_accounting;
gbianec670c592016-11-24 11:21:30 +0800387
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700388#if defined(IPA_OFFLOAD)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 }
390#endif
391
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530392 /*
393 * Add SKB to internal tracking table before further processing
394 * in WLAN driver.
395 */
396 qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__);
397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 pAdapter->stats.tx_bytes += skb->len;
Will Huang496b36c2017-07-11 16:38:50 +0800399 pAdapter->aStaInfo[STAId].tx_bytes += skb->len;
Mohit Khannab1dd1e82017-02-04 15:14:38 -0800400
Will Huang496b36c2017-07-11 16:38:50 +0800401 if (qdf_nbuf_is_tso(skb)) {
402 num_seg = qdf_nbuf_get_tso_num_seg(skb);
403 pAdapter->stats.tx_packets += num_seg;
404 pAdapter->aStaInfo[STAId].tx_packets += num_seg;
405 } else {
Mohit Khannab1dd1e82017-02-04 15:14:38 -0800406 ++pAdapter->stats.tx_packets;
Will Huang496b36c2017-07-11 16:38:50 +0800407 pAdapter->aStaInfo[STAId].tx_packets++;
408 }
409 pAdapter->aStaInfo[STAId].last_tx_rx_ts = qdf_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410
Nirav Shah5e74bb82016-07-20 16:01:27 +0530411 hdd_event_eapol_log(skb, QDF_TX);
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700412 qdf_dp_trace_log_pkt(pAdapter->sessionId, skb, QDF_TX,
413 QDF_TRACE_DEFAULT_PDEV_ID);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530414 QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
415 QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530417 qdf_dp_trace_set_track(skb, QDF_TX);
418 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700419 QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(skb),
420 sizeof(qdf_nbuf_data(skb)),
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530421 QDF_TX));
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530422 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700423 QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)skb->data,
424 qdf_nbuf_len(skb), QDF_TX));
Nirav Shahcbc6d722016-03-01 16:24:53 +0530425 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530426 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700427 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530428 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
429 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430
Leo Changfdb45c32016-10-28 11:09:23 -0700431 if (pAdapter->tx_fn(pAdapter->txrx_vdev,
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800432 (qdf_nbuf_t) skb) != NULL) {
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530433 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 "%s: Failed to send packet to txrx for staid:%d",
435 __func__, STAId);
436 ++pAdapter->hdd_stats.hddTxRxStats.txXmitDroppedAC[ac];
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530437 goto drop_pkt_and_release_skb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800438 }
Dustin Browne0024fa2016-10-14 16:29:21 -0700439 netif_trans_update(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440
441 return NETDEV_TX_OK;
442
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530443drop_pkt_and_release_skb:
444 qdf_net_buf_debug_release_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445drop_pkt:
446
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530447 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700448 QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)skb->data,
449 qdf_nbuf_len(skb), QDF_TX));
Nirav Shahcbc6d722016-03-01 16:24:53 +0530450 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530451 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700452 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530453 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
454 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX));
Jeff Johnsonedeff232015-11-11 17:19:42 -0800455 kfree_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456
Jeff Johnsonedeff232015-11-11 17:19:42 -0800457drop_pkt_accounting:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458 ++pAdapter->stats.tx_dropped;
459 ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460
461 return NETDEV_TX_OK;
462}
463
464/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530465 * hdd_softap_hard_start_xmit() - Wrapper function to protect
466 * __hdd_softap_hard_start_xmit from SSR
467 * @skb: pointer to OS packet
468 * @dev: pointer to net_device structure
469 *
470 * Function called by OS if any packet needs to transmit.
471 *
472 * Return: Always returns NETDEV_TX_OK
473 */
474int hdd_softap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
475{
476 int ret;
477
478 cds_ssr_protect(__func__);
479 ret = __hdd_softap_hard_start_xmit(skb, dev);
480 cds_ssr_unprotect(__func__);
481
482 return ret;
483}
484
Sen, Devendra154b3c42017-02-13 20:44:15 +0530485#ifdef FEATURE_WLAN_DIAG_SUPPORT
486/**
487 * hdd_wlan_datastall_sap_event()- Send SAP datastall information
488 *
489 * This Function send send SAP datastall diag event
490 *
491 * Return: void.
492 */
493static void hdd_wlan_datastall_sap_event(void)
494{
495 WLAN_HOST_DIAG_EVENT_DEF(sap_data_stall,
496 struct host_event_wlan_datastall);
497 qdf_mem_zero(&sap_data_stall, sizeof(sap_data_stall));
498 sap_data_stall.reason = SOFTAP_TX_TIMEOUT;
499 WLAN_HOST_DIAG_EVENT_REPORT(&sap_data_stall,
500 EVENT_WLAN_SOFTAP_DATASTALL);
501}
502#else
503static inline void hdd_wlan_datastall_sap_event(void)
504{
505
506}
507#endif
508
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530509/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 * __hdd_softap_tx_timeout() - TX timeout handler
511 * @dev: pointer to network device
512 *
513 * This function is registered as a netdev ndo_tx_timeout method, and
514 * is invoked by the kernel if the driver takes too long to transmit a
515 * frame.
516 *
517 * Return: None
518 */
519static void __hdd_softap_tx_timeout(struct net_device *dev)
520{
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700521 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsonf7726872017-08-28 11:38:31 -0700522 struct hdd_context *hdd_ctx;
Nirav Shah89223f72016-03-01 18:10:38 +0530523 struct netdev_queue *txq;
524 int i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530526 DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700527 QDF_TRACE_DEFAULT_PDEV_ID,
528 NULL, 0, QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529 /* Getting here implies we disabled the TX queues for too
530 * long. Queues are disabled either because of disassociation
531 * or low resource scenarios. In case of disassociation it is
532 * ok to ignore this. But if associated, we have do possible
533 * recovery here
534 */
535 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +0530536 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530537 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800538 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539 return;
540 }
Nirav Shah89223f72016-03-01 18:10:38 +0530541
Dustin Browne0024fa2016-10-14 16:29:21 -0700542 TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA);
Nirav Shah89223f72016-03-01 18:10:38 +0530543
544 for (i = 0; i < NUM_TX_QUEUES; i++) {
545 txq = netdev_get_tx_queue(dev, i);
546 QDF_TRACE(QDF_MODULE_ID_HDD_DATA,
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800547 QDF_TRACE_LEVEL_DEBUG,
548 "Queue: %d status: %d txq->trans_start: %lu",
Nirav Shah89223f72016-03-01 18:10:38 +0530549 i, netif_tx_queue_stopped(txq), txq->trans_start);
550 }
551
552 wlan_hdd_display_netif_queue_history(hdd_ctx);
Leo Changfdb45c32016-10-28 11:09:23 -0700553 cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC));
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800554 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Nirav Shah89223f72016-03-01 18:10:38 +0530555 "carrier state: %d", netif_carrier_ok(dev));
Sen, Devendra154b3c42017-02-13 20:44:15 +0530556 hdd_wlan_datastall_sap_event();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800557}
558
559/**
560 * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout
561 * @dev: pointer to net_device
562 *
563 * Return: none
564 */
565void hdd_softap_tx_timeout(struct net_device *dev)
566{
567 cds_ssr_protect(__func__);
568 __hdd_softap_tx_timeout(dev);
569 cds_ssr_unprotect(__func__);
570}
571
572/**
573 * @hdd_softap_init_tx_rx() - Initialize Tx/RX module
574 * @pAdapter: pointer to adapter context
575 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530576 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
577 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700579QDF_STATUS hdd_softap_init_tx_rx(struct hdd_adapter *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530581 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582
583 uint8_t STAId = 0;
584
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530585 qdf_mem_zero(&pAdapter->stats, sizeof(struct net_device_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586
587 spin_lock_init(&pAdapter->staInfo_lock);
588
589 for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530590 qdf_mem_zero(&pAdapter->aStaInfo[STAId],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 sizeof(hdd_station_info_t));
592 }
593
594 return status;
595}
596
597/**
598 * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module
599 * @pAdapter: pointer to adapter context
600 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530601 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
602 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700604QDF_STATUS hdd_softap_deinit_tx_rx(struct hdd_adapter *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800605{
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800606 if (pAdapter == NULL) {
607 hdd_err("Called with pAdapter = NULL.");
608 return QDF_STATUS_E_FAILURE;
609 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800611 pAdapter->txrx_vdev = NULL;
612 pAdapter->tx_fn = NULL;
613 hdd_info("Deregistering TX function hook !");
614 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615}
616
617/**
618 * hdd_softap_init_tx_rx_sta() - Initialize tx/rx for a softap station
619 * @pAdapter: pointer to adapter context
620 * @STAId: Station ID to initialize
621 * @pmacAddrSTA: pointer to the MAC address of the station
622 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530623 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
624 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700626QDF_STATUS hdd_softap_init_tx_rx_sta(struct hdd_adapter *pAdapter,
627 uint8_t STAId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530628 struct qdf_mac_addr *pmacAddrSTA)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800629{
630 spin_lock_bh(&pAdapter->staInfo_lock);
631 if (pAdapter->aStaInfo[STAId].isUsed) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 spin_unlock_bh(&pAdapter->staInfo_lock);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800633 hdd_err("Reinit of in use station %d", STAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530634 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 }
636
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530637 qdf_mem_zero(&pAdapter->aStaInfo[STAId], sizeof(hdd_station_info_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638
639 pAdapter->aStaInfo[STAId].isUsed = true;
640 pAdapter->aStaInfo[STAId].isDeauthInProgress = false;
Anurag Chouhanc5548422016-02-24 18:33:27 +0530641 qdf_copy_macaddr(&pAdapter->aStaInfo[STAId].macAddrSTA, pmacAddrSTA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642
643 spin_unlock_bh(&pAdapter->staInfo_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530644 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645}
646
647/**
648 * hdd_softap_deinit_tx_rx_sta() - Deinitialize tx/rx for a softap station
649 * @pAdapter: pointer to adapter context
650 * @STAId: Station ID to deinitialize
651 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530652 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
653 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700655QDF_STATUS hdd_softap_deinit_tx_rx_sta(struct hdd_adapter *pAdapter,
656 uint8_t STAId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530658 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659 hdd_hostapd_state_t *pHostapdState;
660
661 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
662
663 spin_lock_bh(&pAdapter->staInfo_lock);
664
665 if (false == pAdapter->aStaInfo[STAId].isUsed) {
666 spin_unlock_bh(&pAdapter->staInfo_lock);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800667 hdd_err("Deinit station not inited %d", STAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530668 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 }
670
671 pAdapter->aStaInfo[STAId].isUsed = false;
672 pAdapter->aStaInfo[STAId].isDeauthInProgress = false;
673
674 spin_unlock_bh(&pAdapter->staInfo_lock);
675 return status;
676}
677
678/**
679 * hdd_softap_rx_packet_cbk() - Receive packet handler
Dhanashri Atre182b0272016-02-17 15:35:07 -0800680 * @context: pointer to HDD context
Nirav Shahcbc6d722016-03-01 16:24:53 +0530681 * @rxBuf: pointer to rx qdf_nbuf
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 *
683 * Receive callback registered with TL. TL will call this to notify
684 * the HDD when one or more packets were received for a registered
685 * STA.
686 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530687 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
688 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800690QDF_STATUS hdd_softap_rx_packet_cbk(void *context, qdf_nbuf_t rxBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691{
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700692 struct hdd_adapter *pAdapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800693 int rxstat;
694 unsigned int cpu_index;
695 struct sk_buff *skb = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800696 struct sk_buff *next = NULL;
Jeff Johnsonf7726872017-08-28 11:38:31 -0700697 struct hdd_context *pHddCtx = NULL;
Will Huang496b36c2017-07-11 16:38:50 +0800698 struct qdf_mac_addr src_mac;
699 uint8_t staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700
701 /* Sanity check on inputs */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800702 if (unlikely((NULL == context) || (NULL == rxBuf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530703 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 "%s: Null params being passed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530705 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706 }
707
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700708 pAdapter = (struct hdd_adapter *)context;
Dhanashri Atre182b0272016-02-17 15:35:07 -0800709 if (unlikely(WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800710 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre182b0272016-02-17 15:35:07 -0800711 "Magic cookie(%x) for adapter sanity verification is invalid",
712 pAdapter->magic);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530713 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714 }
715
Dhanashri Atre182b0272016-02-17 15:35:07 -0800716 pHddCtx = pAdapter->pHddCtx;
717 if (unlikely(NULL == pHddCtx)) {
718 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
719 "%s: HDD context is Null", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530720 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721 }
722
723 /* walk the chain until all are processed */
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800724 next = (struct sk_buff *)rxBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800726 while (next) {
727 skb = next;
728 next = skb->next;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800729 skb->next = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800730
psimha884025c2017-08-01 15:07:32 -0700731#ifdef QCA_WIFI_QCA6290 /* Debug code, remove later */
Venkata Sharath Chandra Manchalacc789172017-07-25 23:28:45 -0700732 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_INFO,
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800733 "%s: skb %p skb->len %d\n", __func__, skb, skb->len);
734#endif
735
Dhanashri Atre63d98022017-01-24 18:22:09 -0800736 hdd_softap_dump_sk_buff(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737
Dhanashri Atre63d98022017-01-24 18:22:09 -0800738 skb->dev = pAdapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739
Dhanashri Atre63d98022017-01-24 18:22:09 -0800740 if (unlikely(skb->dev == NULL)) {
741
742 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
743 "%s: ERROR!!Invalid netdevice", __func__);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800744 continue;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800745 }
746 cpu_index = wlan_hdd_get_cpu();
747 ++pAdapter->hdd_stats.hddTxRxStats.rxPackets[cpu_index];
748 ++pAdapter->stats.rx_packets;
749 pAdapter->stats.rx_bytes += skb->len;
750
Will Huang496b36c2017-07-11 16:38:50 +0800751 qdf_mem_copy(&src_mac, skb->data + QDF_NBUF_SRC_MAC_OFFSET,
752 sizeof(src_mac));
753 if (QDF_STATUS_SUCCESS ==
754 hdd_softap_get_sta_id(pAdapter, &src_mac, &staid)) {
755 if (staid < WLAN_MAX_STA_COUNT) {
756 pAdapter->aStaInfo[staid].rx_packets++;
757 pAdapter->aStaInfo[staid].rx_bytes += skb->len;
758 pAdapter->aStaInfo[staid].last_tx_rx_ts =
759 qdf_system_ticks();
760 }
761 }
Dhanashri Atre63d98022017-01-24 18:22:09 -0800762 hdd_event_eapol_log(skb, QDF_RX);
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530763 DPTRACE(qdf_dp_trace(skb,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800764 QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700765 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530766 qdf_nbuf_data_addr(skb),
767 sizeof(qdf_nbuf_data(skb)), QDF_RX));
768 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700769 QDF_TRACE_DEFAULT_PDEV_ID,
770 (uint8_t *)skb->data, qdf_nbuf_len(skb),
771 QDF_RX));
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530772 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
773 DPTRACE(qdf_dp_trace(skb,
774 QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700775 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530776 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
777 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE),
778 QDF_RX));
Dhanashri Atre63d98022017-01-24 18:22:09 -0800779
780 skb->protocol = eth_type_trans(skb, skb->dev);
781
782 /* hold configurable wakelock for unicast traffic */
783 if (pHddCtx->config->rx_wakelock_timeout &&
784 skb->pkt_type != PACKET_BROADCAST &&
785 skb->pkt_type != PACKET_MULTICAST) {
786 cds_host_diag_log_work(&pHddCtx->rx_wake_lock,
787 pHddCtx->config->rx_wakelock_timeout,
788 WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
789 qdf_wake_lock_timeout_acquire(&pHddCtx->rx_wake_lock,
790 pHddCtx->config->
791 rx_wakelock_timeout);
792 }
793
794 /* Remove SKB from internal tracking table before submitting
795 * it to stack
796 */
Manjunathappa Prakash17c07bd2017-04-27 21:24:28 -0700797 qdf_net_buf_debug_release_skb(skb);
Dhanashri Atre63d98022017-01-24 18:22:09 -0800798 if (hdd_napi_enabled(HDD_NAPI_ANY) &&
799 !pHddCtx->enableRxThread)
800 rxstat = netif_receive_skb(skb);
801 else
802 rxstat = netif_rx_ni(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700803 if (NET_RX_SUCCESS == rxstat)
Dhanashri Atre63d98022017-01-24 18:22:09 -0800804 ++pAdapter->hdd_stats.hddTxRxStats.rxDelivered[cpu_index];
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700805 else
Dhanashri Atre63d98022017-01-24 18:22:09 -0800806 ++pAdapter->hdd_stats.hddTxRxStats.rxRefused[cpu_index];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530809 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810}
811
812/**
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700813 * hdd_softap_deregister_sta(struct hdd_adapter *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 * @pAdapter: pointer to adapter context
815 * @staId: Station ID to deregister
816 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530817 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700819QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *pAdapter,
820 uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530822 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Jeff Johnsonf7726872017-08-28 11:38:31 -0700823 struct hdd_context *pHddCtx;
Abhishek Singh07c627e2017-03-20 17:56:34 +0530824 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825
826 if (NULL == pAdapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800827 hdd_err("NULL adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530828 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 }
830
831 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800832 hdd_err("Invalid adapter magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530833 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 }
835
Jeff Johnsonf7726872017-08-28 11:38:31 -0700836 pHddCtx = (struct hdd_context *) (pAdapter->pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 /* Clear station in TL and then update HDD data
838 * structures. This helps to block RX frames from other
839 * station to this station.
840 */
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800841 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800842 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
843 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530844 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800845 hdd_err("cdp_clear_peer failed for staID %d, Status=%d [0x%08X]",
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800846 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 }
848
Dustin Brown7d043f62017-03-27 12:07:36 -0700849 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
850 pAdapter->aStaInfo[staId].
851 macAddrSTA.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +0530852 if (ret)
853 hdd_err("Peer obj %pM delete fails",
854 pAdapter->aStaInfo[staId].macAddrSTA.bytes);
855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 if (pAdapter->aStaInfo[staId].isUsed) {
857 spin_lock_bh(&pAdapter->staInfo_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530858 qdf_mem_zero(&pAdapter->aStaInfo[staId],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 sizeof(hdd_station_info_t));
860 spin_unlock_bh(&pAdapter->staInfo_lock);
861 }
Abhishek Singh07c627e2017-03-20 17:56:34 +0530862
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 pHddCtx->sta_to_adapter[staId] = NULL;
864
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530865 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866}
867
868/**
869 * hdd_softap_register_sta() - Register a SoftAP STA
870 * @pAdapter: pointer to adapter context
871 * @fAuthRequired: is additional authentication required?
872 * @fPrivacyBit: should 802.11 privacy bit be set?
873 * @staId: station ID assigned to this station
874 * @ucastSig: unicast security signature
875 * @bcastSig: broadcast security signature
876 * @pPeerMacAddress: station MAC address
877 * @fWmmEnabled: is WMM enabled for this STA?
878 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530879 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700881QDF_STATUS hdd_softap_register_sta(struct hdd_adapter *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 bool fAuthRequired,
883 bool fPrivacyBit,
884 uint8_t staId,
885 uint8_t ucastSig,
886 uint8_t bcastSig,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530887 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 bool fWmmEnabled)
889{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530890 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnsonf7726872017-08-28 11:38:31 -0700892 struct hdd_context *pHddCtx = pAdapter->pHddCtx;
Dhanashri Atre182b0272016-02-17 15:35:07 -0800893 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -0700894 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
895 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800897 hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u",
898 staId, fAuthRequired, fPrivacyBit, fWmmEnabled);
899
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 /*
901 * Clean up old entry if it is not cleaned up properly
902 */
903 if (pAdapter->aStaInfo[staId].isUsed) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800904 hdd_info("clean up old entry for STA %d", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 hdd_softap_deregister_sta(pAdapter, staId);
906 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800908 /* Get the Station ID from the one saved during the assocation. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 staDesc.sta_id = staId;
910
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800911 /* Save the pAdapter Pointer for this staId */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 pHddCtx->sta_to_adapter[staId] = pAdapter;
913
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530914 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 hdd_softap_init_tx_rx_sta(pAdapter, staId,
916 pPeerMacAddress);
917
918 staDesc.is_qos_enabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919
Dhanashri Atre182b0272016-02-17 15:35:07 -0800920 /* Register the vdev transmit and receive functions */
921 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
922 txrx_ops.rx.rx = hdd_softap_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -0700923 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800924 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
925 (struct cdp_pdev *)pdev, pAdapter->sessionId),
926 pAdapter, &txrx_ops);
927 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
928 (struct cdp_pdev *)pdev,
Leo Changfdb45c32016-10-28 11:09:23 -0700929 pAdapter->sessionId);
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800930 pAdapter->tx_fn = txrx_ops.tx.tx;
Dhanashri Atre182b0272016-02-17 15:35:07 -0800931
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800932 qdf_status = cdp_peer_register(soc,
933 (struct cdp_pdev *)pdev, &staDesc);
Dhanashri Atre50141c52016-04-07 13:15:29 -0700934 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800935 hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]",
936 qdf_status, qdf_status);
Dhanashri Atre50141c52016-04-07 13:15:29 -0700937 return qdf_status;
938 }
939
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940 /* if ( WPA ), tell TL to go to 'connected' and after keys come to the
941 * driver then go to 'authenticated'. For all other authentication
942 * types (those that do not require upper layer authentication) we can
943 * put TL directly into 'authenticated' state
944 */
945
946 pAdapter->aStaInfo[staId].ucSTAId = staId;
947 pAdapter->aStaInfo[staId].isQosEnabled = fWmmEnabled;
948
949 if (!fAuthRequired) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800950 hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time",
951 pAdapter->aStaInfo[staId].ucSTAId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952
953 /* Connections that do not need Upper layer auth,
954 * transition TL directly to 'Authenticated' state.
955 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530956 qdf_status = hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800957 OL_TXRX_PEER_STATE_AUTH, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800959 pAdapter->aStaInfo[staId].tlSTAState = OL_TXRX_PEER_STATE_AUTH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 pAdapter->sessionCtx.ap.uIsAuthenticated = true;
961 } else {
962
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800963 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
964 pAdapter->aStaInfo[staId].ucSTAId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530966 qdf_status = hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800967 OL_TXRX_PEER_STATE_CONN, false);
968 pAdapter->aStaInfo[staId].tlSTAState = OL_TXRX_PEER_STATE_CONN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969
970 pAdapter->sessionCtx.ap.uIsAuthenticated = false;
971
972 }
973
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700974 hdd_debug("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 wlan_hdd_netif_queue_control(pAdapter,
976 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
977 WLAN_CONTROL_PATH);
978
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530979 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980}
981
982/**
983 * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA
984 * @pAdapter: pointer to adapter context
985 * @fPrivacyBit: should 802.11 privacy bit be set?
986 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530987 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700989QDF_STATUS hdd_softap_register_bc_sta(struct hdd_adapter *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 bool fPrivacyBit)
991{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530992 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsonf7726872017-08-28 11:38:31 -0700993 struct hdd_context *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530994 struct qdf_mac_addr broadcastMacAddr =
995 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Jeff Johnson87251032017-08-29 13:31:11 -0700996 struct hdd_ap_ctx *pHddApCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997
998 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
999
1000 pHddCtx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = pAdapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 pHddCtx->sta_to_adapter[pHddApCtx->uBCStaId] = pAdapter;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301002 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 hdd_softap_register_sta(pAdapter, false, fPrivacyBit,
1004 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->
1005 uBCStaId, 0, 1, &broadcastMacAddr, 0);
1006
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301007 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008}
1009
1010/**
1011 * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA
1012 * @pAdapter: pointer to adapter context
1013 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301014 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -07001016QDF_STATUS hdd_softap_deregister_bc_sta(struct hdd_adapter *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017{
1018 return hdd_softap_deregister_sta(pAdapter,
1019 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->
1020 uBCStaId);
1021}
1022
1023/**
1024 * hdd_softap_stop_bss() - Stop the BSS
1025 * @pAdapter: pointer to adapter context
1026 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301027 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -07001029QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301031 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 uint8_t staId = 0;
Jeff Johnsonf7726872017-08-28 11:38:31 -07001033 struct hdd_context *pHddCtx;
Srinivas Girigowdae806a822017-03-25 11:25:30 -07001034
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1036
1037 /* bss deregister is not allowed during wlan driver loading or
1038 * unloading
1039 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001040 if (cds_is_load_or_unload_in_progress()) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001041 hdd_err("Loading_unloading in Progress, state: 0x%x. Ignore!!!",
1042 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301043 return QDF_STATUS_E_PERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 }
1045
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301046 qdf_status = hdd_softap_deregister_bc_sta(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301048 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001049 hdd_err("Failed to deregister BC sta Id %d",
1050 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->uBCStaId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 }
1052
1053 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
1054 /* This excludes BC sta as it is already deregistered */
1055 if (pAdapter->aStaInfo[staId].isUsed) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301056 qdf_status = hdd_softap_deregister_sta(pAdapter, staId);
1057 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001058 hdd_err("Failed to deregister sta Id %d",
1059 staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060 }
1061 }
1062 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301063 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064}
1065
1066/**
1067 * hdd_softap_change_sta_state() - Change the state of a SoftAP station
1068 * @pAdapter: pointer to adapter context
1069 * @pDestMacAddress: MAC address of the station
1070 * @state: new state of the station
1071 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301072 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -07001074QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301075 struct qdf_mac_addr *pDestMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 enum ol_txrx_peer_state state)
1077{
1078 uint8_t ucSTAId = WLAN_MAX_STA_COUNT;
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001079 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001081 ENTER_DEV(pAdapter->dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001083 qdf_status = hdd_softap_get_sta_id(pAdapter, pDestMacAddress, &ucSTAId);
1084 if (QDF_STATUS_SUCCESS != qdf_status) {
1085 hdd_err("Failed to find right station");
1086 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 }
1088
1089 if (false ==
Anurag Chouhanc5548422016-02-24 18:33:27 +05301090 qdf_is_macaddr_equal(&pAdapter->aStaInfo[ucSTAId].macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 pDestMacAddress)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001092 hdd_err("Station %u MAC address not matching", ucSTAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301093 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 }
1095
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301096 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001097 hdd_change_peer_state(pAdapter, ucSTAId, state, false);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001098 hdd_info("Station %u changed to state %d", ucSTAId, state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301100 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 pAdapter->aStaInfo[ucSTAId].tlSTAState =
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001102 OL_TXRX_PEER_STATE_AUTH;
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301103 p2p_peer_authorized(pAdapter->hdd_vdev, pDestMacAddress->bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 }
1105
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001106 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301107 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108}
1109
1110/*
1111 * hdd_softap_get_sta_id() - Find station ID from MAC address
1112 * @pAdapter: pointer to adapter context
1113 * @pDestMacAddress: MAC address of the destination
1114 * @staId: Station ID associated with the MAC address
1115 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301116 * Return: QDF_STATUS_SUCCESS if a match was found, in which case
1117 * staId is populated, QDF_STATUS_E_FAILURE if a match is
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001118 * not found
1119 */
Jeff Johnson18dd7e12017-08-29 14:22:28 -07001120QDF_STATUS hdd_softap_get_sta_id(struct hdd_adapter *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301121 struct qdf_mac_addr *pMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122 uint8_t *staId)
1123{
1124 uint8_t i;
1125
1126 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301127 if (!qdf_mem_cmp
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 (&pAdapter->aStaInfo[i].macAddrSTA, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301129 QDF_MAC_ADDR_SIZE) && pAdapter->aStaInfo[i].isUsed) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130 *staId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301131 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132 }
1133 }
1134
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301135 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136}