blob: 0af5a6f197266e3de5b6c90bdd01c6c2945da25e [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,
Jeff Johnson36e74c42017-09-18 08:15:42 -070071 "%s: head = %pK ", __func__, skb->head);
Srinivas Girigowdae806a822017-03-25 11:25:30 -070072 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Jeff Johnson36e74c42017-09-18 08:15:42 -070073 "%s: tail = %pK ", __func__, skb->tail);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053074 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Jeff Johnson36e74c42017-09-18 08:15:42 -070075 "%s: end = %pK ", __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 Johnsond31ab6a2017-10-02 13:23:51 -0700111 struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700113 if (!adapter) {
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");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700119 wlan_hdd_netif_queue_control(adapter, 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
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700127 * @adapter: pointer to hdd adapter
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530128 * @tx_resume: TX Q resume trigger
129 *
130 *
131 * Return: None
132 */
133static void
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700134hdd_softap_tx_resume_false(struct hdd_adapter *adapter, 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");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700140 wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE,
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530141 WLAN_DATA_FLOW_CONTROL);
142
143 if (QDF_TIMER_STATE_STOPPED ==
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700144 qdf_mc_timer_get_current_state(&adapter->
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530145 tx_flow_control_timer)) {
146 QDF_STATUS status;
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700147
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700148 status = qdf_mc_timer_start(&adapter->tx_flow_control_timer,
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530149 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
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700154 adapter->hdd_stats.hddTxRxStats.txflow_timer_cnt++;
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530155 }
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530156}
157#else
158
159static inline void
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700160hdd_softap_tx_resume_false(struct hdd_adapter *adapter, 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 Johnsond31ab6a2017-10-02 13:23:51 -0700176 struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700178 if (!adapter) {
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 !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700186 qdf_mc_timer_get_current_state(&adapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 tx_flow_control_timer)) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700188 qdf_mc_timer_stop(&adapter->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");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700192 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 WLAN_WAKE_ALL_NETIF_QUEUE,
194 WLAN_DATA_FLOW_CONTROL);
195 }
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700196 hdd_softap_tx_resume_false(adapter, tx_resume);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197}
gbianec670c592016-11-24 11:21:30 +0800198
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700199static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter,
gbianec670c592016-11-24 11:21:30 +0800200 struct sk_buff *skb)
201{
tfyubdf453e2017-09-27 13:34:30 +0800202#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 19, 0))
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700203 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800204#endif
205 int need_orphan = 0;
206
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700207 if (adapter->tx_flow_low_watermark > 0) {
tfyubdf453e2017-09-27 13:34:30 +0800208#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
209 /*
210 * The TCP TX throttling logic is changed a little after
211 * 3.19-rc1 kernel, the TCP sending limit will be smaller,
212 * which will throttle the TCP packets to the host driver.
213 * The TCP UP LINK throughput will drop heavily. In order to
214 * fix this issue, need to orphan the socket buffer asap, which
215 * will call skb's destructor to notify the TCP stack that the
216 * SKB buffer is unowned. And then the TCP stack will pump more
217 * packets to host driver.
218 *
219 * The TX packets might be dropped for UDP case in the iperf
220 * testing. So need to be protected by follow control.
221 */
222 need_orphan = 1;
223#else
224 if (hdd_ctx->config->tx_orphan_enable)
225 need_orphan = 1;
226#endif
227 }
228
229 if (need_orphan)
gbianec670c592016-11-24 11:21:30 +0800230 skb_orphan(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700231 else
gbianec670c592016-11-24 11:21:30 +0800232 skb = skb_unshare(skb, GFP_ATOMIC);
gbianec670c592016-11-24 11:21:30 +0800233
234 return skb;
235}
236
237#else
Mohit Khannad0b63f52017-02-18 18:05:52 -0800238/**
239 * hdd_skb_orphan() - skb_unshare a cloned packed else skb_orphan
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700240 * @adapter: pointer to HDD adapter
Mohit Khannad0b63f52017-02-18 18:05:52 -0800241 * @skb: pointer to skb data packet
242 *
243 * Return: pointer to skb structure
244 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700245static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter,
Mohit Khannad0b63f52017-02-18 18:05:52 -0800246 struct sk_buff *skb) {
gbianec670c592016-11-24 11:21:30 +0800247
Mohit Khannad0b63f52017-02-18 18:05:52 -0800248 struct sk_buff *nskb;
tfyubdf453e2017-09-27 13:34:30 +0800249#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700250 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800251#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800252
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700253 nskb = skb_unshare(skb, GFP_ATOMIC);
tfyubdf453e2017-09-27 13:34:30 +0800254#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700255 if (unlikely(hdd_ctx->config->tx_orphan_enable) && (nskb == skb)) {
Mohit Khannad0b63f52017-02-18 18:05:52 -0800256 /*
257 * For UDP packets we want to orphan the packet to allow the app
258 * to send more packets. The flow would ultimately be controlled
259 * by the limited number of tx descriptors for the vdev.
260 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700261 ++adapter->hdd_stats.hddTxRxStats.txXmitOrphaned;
Mohit Khannad0b63f52017-02-18 18:05:52 -0800262 skb_orphan(skb);
263 }
tfyubdf453e2017-09-27 13:34:30 +0800264#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800265 return nskb;
gbianec670c592016-11-24 11:21:30 +0800266}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
268
269/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530270 * __hdd_softap_hard_start_xmit() - Transmit a frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800271 * @skb: pointer to OS packet (sk_buff)
272 * @dev: pointer to network device
273 *
274 * Function registered with the Linux OS for transmitting
275 * packets. This version of the function directly passes
276 * the packet to Transport Layer.
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530277 * In case of any packet drop or error, log the error with
278 * INFO HIGH/LOW/MEDIUM to avoid excessive logging in kmsg.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 *
280 * Return: Always returns NETDEV_TX_OK
281 */
Jeff Johnson6376abe2016-10-05 16:24:56 -0700282static int __hdd_softap_hard_start_xmit(struct sk_buff *skb,
283 struct net_device *dev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284{
285 sme_ac_enum_type ac = SME_AC_BE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700286 struct hdd_adapter *adapter = (struct hdd_adapter *) netdev_priv(dev);
287 struct hdd_ap_ctx *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530288 struct qdf_mac_addr *pDestMacAddress;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289 uint8_t STAId;
Will Huang496b36c2017-07-11 16:38:50 +0800290 uint32_t num_seg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700292 ++adapter->hdd_stats.hddTxRxStats.txXmitCalled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800293 /* Prevent this function from being called during SSR since TL
294 * context may not be reinitialized at this time which may
295 * lead to a crash.
296 */
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +0530297 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530298 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800299 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 goto drop_pkt;
301 }
302
303 /*
304 * If the device is operating on a DFS Channel
305 * then check if SAP is in CAC WAIT state and
306 * drop the packets. In CAC WAIT state device
307 * is expected not to transmit any frames.
308 * SAP starts Tx only after the BSS START is
309 * done.
310 */
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700311 if (pHddApCtx->dfs_cac_block_tx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800314 /*
Jeff Johnson4fca3b52017-01-12 08:44:18 -0800315 * If a transmit function is not registered, drop packet
316 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700317 if (!adapter->tx_fn) {
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800318 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
319 "%s: TX function not registered by the data path",
320 __func__);
321 goto drop_pkt;
322 }
323
Nirav Shah5e74bb82016-07-20 16:01:27 +0530324 wlan_hdd_classify_pkt(skb);
325
Anurag Chouhan6d760662016-02-20 16:05:43 +0530326 pDestMacAddress = (struct qdf_mac_addr *) skb->data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327
Nirav Shah5e74bb82016-07-20 16:01:27 +0530328 if (QDF_NBUF_CB_GET_IS_BCAST(skb) ||
329 QDF_NBUF_CB_GET_IS_MCAST(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 /* The BC/MC station ID is assigned during BSS
331 * starting phase. SAP will return the station ID
332 * used for BC/MC traffic.
333 */
334 STAId = pHddApCtx->uBCStaId;
335 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530336 if (QDF_STATUS_SUCCESS !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700337 hdd_softap_get_sta_id(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 pDestMacAddress, &STAId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530339 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530340 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 "%s: Failed to find right station", __func__);
342 goto drop_pkt;
343 }
344
Prakash Dhavali3107b752016-11-28 14:35:06 +0530345 if (STAId >= WLAN_MAX_STA_COUNT) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530346 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530347 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 "%s: Failed to find right station", __func__);
349 goto drop_pkt;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700350 } else if (false == adapter->aStaInfo[STAId].isUsed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530351 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530352 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 "%s: STA %d is unregistered", __func__,
354 STAId);
355 goto drop_pkt;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700356 } else if (true == adapter->aStaInfo[STAId].
Poddar, Siddartha5075462017-03-16 19:20:09 +0530357 isDeauthInProgress) {
358 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530359 QDF_TRACE_LEVEL_INFO_HIGH,
Poddar, Siddartha5075462017-03-16 19:20:09 +0530360 "%s: STA %d deauth in progress", __func__,
361 STAId);
362 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 }
364
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800365 if ((OL_TXRX_PEER_STATE_CONN !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700366 adapter->aStaInfo[STAId].tlSTAState)
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800367 && (OL_TXRX_PEER_STATE_AUTH !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700368 adapter->aStaInfo[STAId].tlSTAState)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530369 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530370 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 "%s: Station not connected yet", __func__);
372 goto drop_pkt;
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800373 } else if (OL_TXRX_PEER_STATE_CONN ==
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700374 adapter->aStaInfo[STAId].tlSTAState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530376 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530377 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 "%s: NON-EAPOL packet in non-Authenticated state",
379 __func__);
380 goto drop_pkt;
381 }
382 }
383 }
384
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700385 hdd_get_tx_resource(adapter, STAId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
387
388 /* Get TL AC corresponding to Qdisc queue index/AC. */
389 ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping];
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700390 ++adapter->hdd_stats.hddTxRxStats.txXmitClassifiedAC[ac];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700392#if defined(IPA_OFFLOAD)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530393 if (!qdf_nbuf_ipa_owned_get(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394#endif
gbianec670c592016-11-24 11:21:30 +0800395
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700396 skb = hdd_skb_orphan(adapter, skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 if (!skb)
Jeff Johnsonedeff232015-11-11 17:19:42 -0800398 goto drop_pkt_accounting;
gbianec670c592016-11-24 11:21:30 +0800399
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700400#if defined(IPA_OFFLOAD)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401 }
402#endif
403
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530404 /*
405 * Add SKB to internal tracking table before further processing
406 * in WLAN driver.
407 */
408 qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__);
409
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700410 adapter->stats.tx_bytes += skb->len;
411 adapter->aStaInfo[STAId].tx_bytes += skb->len;
Mohit Khannab1dd1e82017-02-04 15:14:38 -0800412
Will Huang496b36c2017-07-11 16:38:50 +0800413 if (qdf_nbuf_is_tso(skb)) {
414 num_seg = qdf_nbuf_get_tso_num_seg(skb);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700415 adapter->stats.tx_packets += num_seg;
416 adapter->aStaInfo[STAId].tx_packets += num_seg;
Will Huang496b36c2017-07-11 16:38:50 +0800417 } else {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700418 ++adapter->stats.tx_packets;
419 adapter->aStaInfo[STAId].tx_packets++;
Will Huang496b36c2017-07-11 16:38:50 +0800420 }
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700421 adapter->aStaInfo[STAId].last_tx_rx_ts = qdf_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422
Nirav Shah5e74bb82016-07-20 16:01:27 +0530423 hdd_event_eapol_log(skb, QDF_TX);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700424 qdf_dp_trace_log_pkt(adapter->sessionId, skb, QDF_TX,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700425 QDF_TRACE_DEFAULT_PDEV_ID);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530426 QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
427 QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530429 qdf_dp_trace_set_track(skb, QDF_TX);
430 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700431 QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(skb),
432 sizeof(qdf_nbuf_data(skb)),
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530433 QDF_TX));
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530434 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700435 QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)skb->data,
436 qdf_nbuf_len(skb), QDF_TX));
Nirav Shahcbc6d722016-03-01 16:24:53 +0530437 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530438 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700439 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530440 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
441 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700443 if (adapter->tx_fn(adapter->txrx_vdev,
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800444 (qdf_nbuf_t) skb) != NULL) {
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530445 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 "%s: Failed to send packet to txrx for staid:%d",
447 __func__, STAId);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700448 ++adapter->hdd_stats.hddTxRxStats.txXmitDroppedAC[ac];
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530449 goto drop_pkt_and_release_skb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450 }
Dustin Browne0024fa2016-10-14 16:29:21 -0700451 netif_trans_update(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452
453 return NETDEV_TX_OK;
454
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530455drop_pkt_and_release_skb:
456 qdf_net_buf_debug_release_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457drop_pkt:
458
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530459 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700460 QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)skb->data,
461 qdf_nbuf_len(skb), QDF_TX));
Nirav Shahcbc6d722016-03-01 16:24:53 +0530462 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530463 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700464 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530465 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
466 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX));
Jeff Johnsonedeff232015-11-11 17:19:42 -0800467 kfree_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468
Jeff Johnsonedeff232015-11-11 17:19:42 -0800469drop_pkt_accounting:
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700470 ++adapter->stats.tx_dropped;
471 ++adapter->hdd_stats.hddTxRxStats.txXmitDropped;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472
473 return NETDEV_TX_OK;
474}
475
476/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530477 * hdd_softap_hard_start_xmit() - Wrapper function to protect
478 * __hdd_softap_hard_start_xmit from SSR
479 * @skb: pointer to OS packet
480 * @dev: pointer to net_device structure
481 *
482 * Function called by OS if any packet needs to transmit.
483 *
484 * Return: Always returns NETDEV_TX_OK
485 */
486int hdd_softap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
487{
488 int ret;
489
490 cds_ssr_protect(__func__);
491 ret = __hdd_softap_hard_start_xmit(skb, dev);
492 cds_ssr_unprotect(__func__);
493
494 return ret;
495}
496
Sen, Devendra154b3c42017-02-13 20:44:15 +0530497#ifdef FEATURE_WLAN_DIAG_SUPPORT
498/**
499 * hdd_wlan_datastall_sap_event()- Send SAP datastall information
500 *
501 * This Function send send SAP datastall diag event
502 *
503 * Return: void.
504 */
505static void hdd_wlan_datastall_sap_event(void)
506{
507 WLAN_HOST_DIAG_EVENT_DEF(sap_data_stall,
508 struct host_event_wlan_datastall);
509 qdf_mem_zero(&sap_data_stall, sizeof(sap_data_stall));
510 sap_data_stall.reason = SOFTAP_TX_TIMEOUT;
511 WLAN_HOST_DIAG_EVENT_REPORT(&sap_data_stall,
512 EVENT_WLAN_SOFTAP_DATASTALL);
513}
514#else
515static inline void hdd_wlan_datastall_sap_event(void)
516{
517
518}
519#endif
520
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530521/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522 * __hdd_softap_tx_timeout() - TX timeout handler
523 * @dev: pointer to network device
524 *
525 * This function is registered as a netdev ndo_tx_timeout method, and
526 * is invoked by the kernel if the driver takes too long to transmit a
527 * frame.
528 *
529 * Return: None
530 */
531static void __hdd_softap_tx_timeout(struct net_device *dev)
532{
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700533 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsonf7726872017-08-28 11:38:31 -0700534 struct hdd_context *hdd_ctx;
Nirav Shah89223f72016-03-01 18:10:38 +0530535 struct netdev_queue *txq;
536 int i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530538 DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700539 QDF_TRACE_DEFAULT_PDEV_ID,
540 NULL, 0, QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541 /* Getting here implies we disabled the TX queues for too
542 * long. Queues are disabled either because of disassociation
543 * or low resource scenarios. In case of disassociation it is
544 * ok to ignore this. But if associated, we have do possible
545 * recovery here
546 */
547 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +0530548 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530549 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800550 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 return;
552 }
Nirav Shah89223f72016-03-01 18:10:38 +0530553
Dustin Browne0024fa2016-10-14 16:29:21 -0700554 TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA);
Nirav Shah89223f72016-03-01 18:10:38 +0530555
556 for (i = 0; i < NUM_TX_QUEUES; i++) {
557 txq = netdev_get_tx_queue(dev, i);
558 QDF_TRACE(QDF_MODULE_ID_HDD_DATA,
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800559 QDF_TRACE_LEVEL_DEBUG,
560 "Queue: %d status: %d txq->trans_start: %lu",
Nirav Shah89223f72016-03-01 18:10:38 +0530561 i, netif_tx_queue_stopped(txq), txq->trans_start);
562 }
563
564 wlan_hdd_display_netif_queue_history(hdd_ctx);
Leo Changfdb45c32016-10-28 11:09:23 -0700565 cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC));
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800566 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Nirav Shah89223f72016-03-01 18:10:38 +0530567 "carrier state: %d", netif_carrier_ok(dev));
Sen, Devendra154b3c42017-02-13 20:44:15 +0530568 hdd_wlan_datastall_sap_event();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569}
570
571/**
572 * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout
573 * @dev: pointer to net_device
574 *
575 * Return: none
576 */
577void hdd_softap_tx_timeout(struct net_device *dev)
578{
579 cds_ssr_protect(__func__);
580 __hdd_softap_tx_timeout(dev);
581 cds_ssr_unprotect(__func__);
582}
583
584/**
585 * @hdd_softap_init_tx_rx() - Initialize Tx/RX module
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700586 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800587 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530588 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
589 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700591QDF_STATUS hdd_softap_init_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530593 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594
595 uint8_t STAId = 0;
596
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700597 qdf_mem_zero(&adapter->stats, sizeof(struct net_device_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700599 spin_lock_init(&adapter->staInfo_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600
601 for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700602 qdf_mem_zero(&adapter->aStaInfo[STAId],
Jeff Johnson82155922017-09-30 16:54:14 -0700603 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604 }
605
606 return status;
607}
608
609/**
610 * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700611 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530613 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
614 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700616QDF_STATUS hdd_softap_deinit_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700618 if (adapter == NULL) {
619 hdd_err("Called with adapter = NULL.");
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800620 return QDF_STATUS_E_FAILURE;
621 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700623 adapter->txrx_vdev = NULL;
624 adapter->tx_fn = NULL;
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800625 hdd_info("Deregistering TX function hook !");
626 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627}
628
629/**
630 * hdd_softap_init_tx_rx_sta() - Initialize tx/rx for a softap station
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700631 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 * @STAId: Station ID to initialize
633 * @pmacAddrSTA: pointer to the MAC address of the station
634 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530635 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
636 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700638QDF_STATUS hdd_softap_init_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700639 uint8_t STAId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530640 struct qdf_mac_addr *pmacAddrSTA)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700642 spin_lock_bh(&adapter->staInfo_lock);
643 if (adapter->aStaInfo[STAId].isUsed) {
644 spin_unlock_bh(&adapter->staInfo_lock);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800645 hdd_err("Reinit of in use station %d", STAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530646 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 }
648
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700649 qdf_mem_zero(&adapter->aStaInfo[STAId],
Jeff Johnson82155922017-09-30 16:54:14 -0700650 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700652 adapter->aStaInfo[STAId].isUsed = true;
653 adapter->aStaInfo[STAId].isDeauthInProgress = false;
654 qdf_copy_macaddr(&adapter->aStaInfo[STAId].macAddrSTA, pmacAddrSTA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700656 spin_unlock_bh(&adapter->staInfo_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530657 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658}
659
660/**
661 * hdd_softap_deinit_tx_rx_sta() - Deinitialize tx/rx for a softap station
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700662 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 * @STAId: Station ID to deinitialize
664 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530665 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
666 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700668QDF_STATUS hdd_softap_deinit_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700669 uint8_t STAId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530671 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnsonca2530c2017-09-30 18:25:40 -0700672 struct hdd_hostapd_state *pHostapdState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700674 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700676 spin_lock_bh(&adapter->staInfo_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700678 if (false == adapter->aStaInfo[STAId].isUsed) {
679 spin_unlock_bh(&adapter->staInfo_lock);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800680 hdd_err("Deinit station not inited %d", STAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530681 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 }
683
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700684 adapter->aStaInfo[STAId].isUsed = false;
685 adapter->aStaInfo[STAId].isDeauthInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700687 spin_unlock_bh(&adapter->staInfo_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 return status;
689}
690
691/**
692 * hdd_softap_rx_packet_cbk() - Receive packet handler
Dhanashri Atre182b0272016-02-17 15:35:07 -0800693 * @context: pointer to HDD context
Nirav Shahcbc6d722016-03-01 16:24:53 +0530694 * @rxBuf: pointer to rx qdf_nbuf
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 *
696 * Receive callback registered with TL. TL will call this to notify
697 * the HDD when one or more packets were received for a registered
698 * STA.
699 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530700 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
701 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800703QDF_STATUS hdd_softap_rx_packet_cbk(void *context, qdf_nbuf_t rxBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700705 struct hdd_adapter *adapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706 int rxstat;
707 unsigned int cpu_index;
708 struct sk_buff *skb = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800709 struct sk_buff *next = NULL;
Jeff Johnson92402872017-09-03 09:25:37 -0700710 struct hdd_context *hdd_ctx = NULL;
Will Huang496b36c2017-07-11 16:38:50 +0800711 struct qdf_mac_addr src_mac;
712 uint8_t staid;
Mohit Khannaf8f96822017-05-17 17:11:59 -0700713 bool proto_pkt_logged = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714
715 /* Sanity check on inputs */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800716 if (unlikely((NULL == context) || (NULL == rxBuf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530717 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718 "%s: Null params being passed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530719 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720 }
721
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700722 adapter = (struct hdd_adapter *)context;
723 if (unlikely(WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800724 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre182b0272016-02-17 15:35:07 -0800725 "Magic cookie(%x) for adapter sanity verification is invalid",
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700726 adapter->magic);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530727 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 }
729
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700730 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson92402872017-09-03 09:25:37 -0700731 if (unlikely(NULL == hdd_ctx)) {
Dhanashri Atre182b0272016-02-17 15:35:07 -0800732 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
733 "%s: HDD context is Null", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530734 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 }
736
737 /* walk the chain until all are processed */
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800738 next = (struct sk_buff *)rxBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800740 while (next) {
741 skb = next;
742 next = skb->next;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800743 skb->next = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800744
psimha884025c2017-08-01 15:07:32 -0700745#ifdef QCA_WIFI_QCA6290 /* Debug code, remove later */
Venkata Sharath Chandra Manchalacc789172017-07-25 23:28:45 -0700746 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_INFO,
Jeff Johnson36e74c42017-09-18 08:15:42 -0700747 "%s: skb %pK skb->len %d\n", __func__, skb, skb->len);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800748#endif
749
Dhanashri Atre63d98022017-01-24 18:22:09 -0800750 hdd_softap_dump_sk_buff(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700752 skb->dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753
Dhanashri Atre63d98022017-01-24 18:22:09 -0800754 if (unlikely(skb->dev == NULL)) {
755
756 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
757 "%s: ERROR!!Invalid netdevice", __func__);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800758 continue;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800759 }
760 cpu_index = wlan_hdd_get_cpu();
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700761 ++adapter->hdd_stats.hddTxRxStats.rxPackets[cpu_index];
762 ++adapter->stats.rx_packets;
763 adapter->stats.rx_bytes += skb->len;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800764
Will Huang496b36c2017-07-11 16:38:50 +0800765 qdf_mem_copy(&src_mac, skb->data + QDF_NBUF_SRC_MAC_OFFSET,
766 sizeof(src_mac));
767 if (QDF_STATUS_SUCCESS ==
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700768 hdd_softap_get_sta_id(adapter, &src_mac, &staid)) {
Will Huang496b36c2017-07-11 16:38:50 +0800769 if (staid < WLAN_MAX_STA_COUNT) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700770 adapter->aStaInfo[staid].rx_packets++;
771 adapter->aStaInfo[staid].rx_bytes += skb->len;
772 adapter->aStaInfo[staid].last_tx_rx_ts =
Will Huang496b36c2017-07-11 16:38:50 +0800773 qdf_system_ticks();
774 }
775 }
Dhanashri Atre63d98022017-01-24 18:22:09 -0800776 hdd_event_eapol_log(skb, QDF_RX);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700777 proto_pkt_logged = qdf_dp_trace_log_pkt(adapter->sessionId,
Mohit Khannaf8f96822017-05-17 17:11:59 -0700778 skb, QDF_RX,
779 QDF_TRACE_DEFAULT_PDEV_ID);
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530780 DPTRACE(qdf_dp_trace(skb,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800781 QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700782 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530783 qdf_nbuf_data_addr(skb),
784 sizeof(qdf_nbuf_data(skb)), QDF_RX));
Mohit Khannaf8f96822017-05-17 17:11:59 -0700785 if (!proto_pkt_logged) {
786 DPTRACE(qdf_dp_trace(skb,
787 QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700788 QDF_TRACE_DEFAULT_PDEV_ID,
789 (uint8_t *)skb->data, qdf_nbuf_len(skb),
790 QDF_RX));
Mohit Khannaf8f96822017-05-17 17:11:59 -0700791 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
792 DPTRACE(qdf_dp_trace(skb,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530793 QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700794 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530795 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
796 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE),
797 QDF_RX));
Mohit Khannaf8f96822017-05-17 17:11:59 -0700798 }
Dhanashri Atre63d98022017-01-24 18:22:09 -0800799
800 skb->protocol = eth_type_trans(skb, skb->dev);
801
802 /* hold configurable wakelock for unicast traffic */
Jeff Johnson92402872017-09-03 09:25:37 -0700803 if (hdd_ctx->config->rx_wakelock_timeout &&
Dhanashri Atre63d98022017-01-24 18:22:09 -0800804 skb->pkt_type != PACKET_BROADCAST &&
805 skb->pkt_type != PACKET_MULTICAST) {
Jeff Johnson92402872017-09-03 09:25:37 -0700806 cds_host_diag_log_work(&hdd_ctx->rx_wake_lock,
807 hdd_ctx->config->rx_wakelock_timeout,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800808 WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
Jeff Johnson92402872017-09-03 09:25:37 -0700809 qdf_wake_lock_timeout_acquire(&hdd_ctx->rx_wake_lock,
810 hdd_ctx->config->
Dhanashri Atre63d98022017-01-24 18:22:09 -0800811 rx_wakelock_timeout);
812 }
813
814 /* Remove SKB from internal tracking table before submitting
815 * it to stack
816 */
Manjunathappa Prakash17c07bd2017-04-27 21:24:28 -0700817 qdf_net_buf_debug_release_skb(skb);
Dhanashri Atre63d98022017-01-24 18:22:09 -0800818 if (hdd_napi_enabled(HDD_NAPI_ANY) &&
Jeff Johnson92402872017-09-03 09:25:37 -0700819 !hdd_ctx->enableRxThread)
Dhanashri Atre63d98022017-01-24 18:22:09 -0800820 rxstat = netif_receive_skb(skb);
821 else
822 rxstat = netif_rx_ni(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700823 if (NET_RX_SUCCESS == rxstat)
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700824 ++adapter->hdd_stats.hddTxRxStats.rxDelivered[cpu_index];
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700825 else
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700826 ++adapter->hdd_stats.hddTxRxStats.rxRefused[cpu_index];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530829 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830}
831
832/**
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700833 * hdd_softap_deregister_sta(struct hdd_adapter *adapter, uint8_t staId)
834 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835 * @staId: Station ID to deregister
836 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530837 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700839QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700840 uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530842 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Jeff Johnson92402872017-09-03 09:25:37 -0700843 struct hdd_context *hdd_ctx;
Abhishek Singh07c627e2017-03-20 17:56:34 +0530844 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700846 if (NULL == adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800847 hdd_err("NULL adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530848 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849 }
850
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700851 if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800852 hdd_err("Invalid adapter magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530853 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 }
855
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700856 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 /* Clear station in TL and then update HDD data
858 * structures. This helps to block RX frames from other
859 * station to this station.
860 */
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800861 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800862 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
863 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530864 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800865 hdd_err("cdp_clear_peer failed for staID %d, Status=%d [0x%08X]",
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800866 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 }
868
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700869 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev,
870 adapter->aStaInfo[staId].
Dustin Brown7d043f62017-03-27 12:07:36 -0700871 macAddrSTA.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +0530872 if (ret)
873 hdd_err("Peer obj %pM delete fails",
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700874 adapter->aStaInfo[staId].macAddrSTA.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +0530875
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700876 if (adapter->aStaInfo[staId].isUsed) {
877 spin_lock_bh(&adapter->staInfo_lock);
878 qdf_mem_zero(&adapter->aStaInfo[staId],
Jeff Johnson82155922017-09-30 16:54:14 -0700879 sizeof(struct hdd_station_info));
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700880 spin_unlock_bh(&adapter->staInfo_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 }
Abhishek Singh07c627e2017-03-20 17:56:34 +0530882
Jeff Johnson92402872017-09-03 09:25:37 -0700883 hdd_ctx->sta_to_adapter[staId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530885 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886}
887
888/**
889 * hdd_softap_register_sta() - Register a SoftAP STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700890 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 * @fAuthRequired: is additional authentication required?
892 * @fPrivacyBit: should 802.11 privacy bit be set?
893 * @staId: station ID assigned to this station
894 * @ucastSig: unicast security signature
895 * @bcastSig: broadcast security signature
896 * @pPeerMacAddress: station MAC address
897 * @fWmmEnabled: is WMM enabled for this STA?
898 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530899 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700901QDF_STATUS hdd_softap_register_sta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 bool fAuthRequired,
903 bool fPrivacyBit,
904 uint8_t staId,
905 uint8_t ucastSig,
906 uint8_t bcastSig,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530907 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 bool fWmmEnabled)
909{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530910 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700912 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -0800913 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -0700914 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
915 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800917 hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u",
918 staId, fAuthRequired, fPrivacyBit, fWmmEnabled);
919
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 /*
921 * Clean up old entry if it is not cleaned up properly
922 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700923 if (adapter->aStaInfo[staId].isUsed) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800924 hdd_info("clean up old entry for STA %d", staId);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700925 hdd_softap_deregister_sta(adapter, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800928 /* Get the Station ID from the one saved during the assocation. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 staDesc.sta_id = staId;
930
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700931 /* Save the adapter Pointer for this staId */
932 hdd_ctx->sta_to_adapter[staId] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530934 qdf_status =
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700935 hdd_softap_init_tx_rx_sta(adapter, staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 pPeerMacAddress);
937
938 staDesc.is_qos_enabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939
Dhanashri Atre182b0272016-02-17 15:35:07 -0800940 /* Register the vdev transmit and receive functions */
941 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
942 txrx_ops.rx.rx = hdd_softap_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -0700943 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800944 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700945 (struct cdp_pdev *)pdev, adapter->sessionId),
946 adapter, &txrx_ops);
947 adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800948 (struct cdp_pdev *)pdev,
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700949 adapter->sessionId);
950 adapter->tx_fn = txrx_ops.tx.tx;
Dhanashri Atre182b0272016-02-17 15:35:07 -0800951
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800952 qdf_status = cdp_peer_register(soc,
953 (struct cdp_pdev *)pdev, &staDesc);
Dhanashri Atre50141c52016-04-07 13:15:29 -0700954 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800955 hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]",
956 qdf_status, qdf_status);
Dhanashri Atre50141c52016-04-07 13:15:29 -0700957 return qdf_status;
958 }
959
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 /* if ( WPA ), tell TL to go to 'connected' and after keys come to the
961 * driver then go to 'authenticated'. For all other authentication
962 * types (those that do not require upper layer authentication) we can
963 * put TL directly into 'authenticated' state
964 */
965
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700966 adapter->aStaInfo[staId].ucSTAId = staId;
967 adapter->aStaInfo[staId].isQosEnabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968
969 if (!fAuthRequired) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800970 hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time",
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700971 adapter->aStaInfo[staId].ucSTAId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972
973 /* Connections that do not need Upper layer auth,
974 * transition TL directly to 'Authenticated' state.
975 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700976 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800977 OL_TXRX_PEER_STATE_AUTH, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700979 adapter->aStaInfo[staId].tlSTAState = OL_TXRX_PEER_STATE_AUTH;
980 adapter->sessionCtx.ap.uIsAuthenticated = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 } else {
982
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800983 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700984 adapter->aStaInfo[staId].ucSTAId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700986 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800987 OL_TXRX_PEER_STATE_CONN, false);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700988 adapter->aStaInfo[staId].tlSTAState = OL_TXRX_PEER_STATE_CONN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700990 adapter->sessionCtx.ap.uIsAuthenticated = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991
992 }
993
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700994 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700995 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
997 WLAN_CONTROL_PATH);
998
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530999 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000}
1001
1002/**
1003 * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001004 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005 * @fPrivacyBit: should 802.11 privacy bit be set?
1006 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301007 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001009QDF_STATUS hdd_softap_register_bc_sta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 bool fPrivacyBit)
1011{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301012 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001013 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05301014 struct qdf_mac_addr broadcastMacAddr =
1015 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Jeff Johnson87251032017-08-29 13:31:11 -07001016 struct hdd_ap_ctx *pHddApCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001017
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001018 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001020 hdd_ctx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = adapter;
1021 hdd_ctx->sta_to_adapter[pHddApCtx->uBCStaId] = adapter;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301022 qdf_status =
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001023 hdd_softap_register_sta(adapter, false, fPrivacyBit,
1024 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 uBCStaId, 0, 1, &broadcastMacAddr, 0);
1026
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301027 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028}
1029
1030/**
1031 * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001032 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301034 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001036QDF_STATUS hdd_softap_deregister_bc_sta(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001038 return hdd_softap_deregister_sta(adapter,
1039 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 uBCStaId);
1041}
1042
1043/**
1044 * hdd_softap_stop_bss() - Stop the BSS
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001045 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301047 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001049QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301051 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 uint8_t staId = 0;
Jeff Johnson92402872017-09-03 09:25:37 -07001053 struct hdd_context *hdd_ctx;
Srinivas Girigowdae806a822017-03-25 11:25:30 -07001054
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001055 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056
1057 /* bss deregister is not allowed during wlan driver loading or
1058 * unloading
1059 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001060 if (cds_is_load_or_unload_in_progress()) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001061 hdd_err("Loading_unloading in Progress, state: 0x%x. Ignore!!!",
1062 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301063 return QDF_STATUS_E_PERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 }
1065
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001066 qdf_status = hdd_softap_deregister_bc_sta(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301068 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001069 hdd_err("Failed to deregister BC sta Id %d",
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001070 (WLAN_HDD_GET_AP_CTX_PTR(adapter))->uBCStaId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 }
1072
1073 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
1074 /* This excludes BC sta as it is already deregistered */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001075 if (adapter->aStaInfo[staId].isUsed) {
1076 qdf_status = hdd_softap_deregister_sta(adapter, staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301077 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001078 hdd_err("Failed to deregister sta Id %d",
1079 staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 }
1081 }
1082 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301083 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084}
1085
1086/**
1087 * hdd_softap_change_sta_state() - Change the state of a SoftAP station
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001088 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 * @pDestMacAddress: MAC address of the station
1090 * @state: new state of the station
1091 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301092 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001094QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301095 struct qdf_mac_addr *pDestMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 enum ol_txrx_peer_state state)
1097{
1098 uint8_t ucSTAId = WLAN_MAX_STA_COUNT;
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001099 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001100
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001101 ENTER_DEV(adapter->dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001103 qdf_status = hdd_softap_get_sta_id(adapter, pDestMacAddress, &ucSTAId);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001104 if (QDF_STATUS_SUCCESS != qdf_status) {
1105 hdd_err("Failed to find right station");
1106 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 }
1108
1109 if (false ==
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001110 qdf_is_macaddr_equal(&adapter->aStaInfo[ucSTAId].macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111 pDestMacAddress)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001112 hdd_err("Station %u MAC address not matching", ucSTAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301113 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001114 }
1115
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301116 qdf_status =
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001117 hdd_change_peer_state(adapter, ucSTAId, state, false);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001118 hdd_info("Station %u changed to state %d", ucSTAId, state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301120 if (QDF_STATUS_SUCCESS == qdf_status) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001121 adapter->aStaInfo[ucSTAId].tlSTAState =
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001122 OL_TXRX_PEER_STATE_AUTH;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001123 p2p_peer_authorized(adapter->hdd_vdev, pDestMacAddress->bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 }
1125
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001126 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301127 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128}
1129
1130/*
1131 * hdd_softap_get_sta_id() - Find station ID from MAC address
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001132 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133 * @pDestMacAddress: MAC address of the destination
1134 * @staId: Station ID associated with the MAC address
1135 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301136 * Return: QDF_STATUS_SUCCESS if a match was found, in which case
1137 * staId is populated, QDF_STATUS_E_FAILURE if a match is
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 * not found
1139 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001140QDF_STATUS hdd_softap_get_sta_id(struct hdd_adapter *adapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301141 struct qdf_mac_addr *pMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142 uint8_t *staId)
1143{
1144 uint8_t i;
1145
1146 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301147 if (!qdf_mem_cmp
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001148 (&adapter->aStaInfo[i].macAddrSTA, pMacAddress,
1149 QDF_MAC_ADDR_SIZE) && adapter->aStaInfo[i].isUsed) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 *staId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301151 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 }
1153 }
1154
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301155 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156}