blob: 58569d8eaa409efefbcc61234845acc36472a8bc [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>
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +053048#include <cdp_txrx_misc.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 Johnson6ced42c2017-10-20 12:48:11 -0700154 adapter->hdd_stats.tx_rx_stats.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{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700202 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800203 int need_orphan = 0;
204
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700205 if (adapter->tx_flow_low_watermark > 0) {
tfyubdf453e2017-09-27 13:34:30 +0800206#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
207 /*
208 * The TCP TX throttling logic is changed a little after
209 * 3.19-rc1 kernel, the TCP sending limit will be smaller,
210 * which will throttle the TCP packets to the host driver.
211 * The TCP UP LINK throughput will drop heavily. In order to
212 * fix this issue, need to orphan the socket buffer asap, which
213 * will call skb's destructor to notify the TCP stack that the
214 * SKB buffer is unowned. And then the TCP stack will pump more
215 * packets to host driver.
216 *
217 * The TX packets might be dropped for UDP case in the iperf
218 * testing. So need to be protected by follow control.
219 */
220 need_orphan = 1;
221#else
222 if (hdd_ctx->config->tx_orphan_enable)
223 need_orphan = 1;
224#endif
tfyu5f01db22017-10-11 13:51:04 +0800225 } else if (hdd_ctx->config->tx_orphan_enable) {
226 if (qdf_nbuf_is_ipv4_tcp_pkt(skb) ||
Tiger Yu438c6482017-10-13 11:07:00 +0800227 qdf_nbuf_is_ipv6_tcp_pkt(skb))
tfyu5f01db22017-10-11 13:51:04 +0800228 need_orphan = 1;
tfyubdf453e2017-09-27 13:34:30 +0800229 }
230
tfyu5f01db22017-10-11 13:51:04 +0800231 if (need_orphan) {
gbianec670c592016-11-24 11:21:30 +0800232 skb_orphan(skb);
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700233 ++adapter->hdd_stats.tx_rx_stats.tx_orphaned;
Tiger Yu438c6482017-10-13 11:07:00 +0800234 } else
gbianec670c592016-11-24 11:21:30 +0800235 skb = skb_unshare(skb, GFP_ATOMIC);
gbianec670c592016-11-24 11:21:30 +0800236
237 return skb;
238}
239
240#else
Mohit Khannad0b63f52017-02-18 18:05:52 -0800241/**
242 * hdd_skb_orphan() - skb_unshare a cloned packed else skb_orphan
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700243 * @adapter: pointer to HDD adapter
Mohit Khannad0b63f52017-02-18 18:05:52 -0800244 * @skb: pointer to skb data packet
245 *
246 * Return: pointer to skb structure
247 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700248static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter,
Mohit Khannad0b63f52017-02-18 18:05:52 -0800249 struct sk_buff *skb) {
gbianec670c592016-11-24 11:21:30 +0800250
Mohit Khannad0b63f52017-02-18 18:05:52 -0800251 struct sk_buff *nskb;
tfyubdf453e2017-09-27 13:34:30 +0800252#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700253 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800254#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800255
Mohit Khanna87493732017-08-27 23:26:44 -0700256 hdd_skb_fill_gso_size(adapter->dev, skb);
257
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700258 nskb = skb_unshare(skb, GFP_ATOMIC);
tfyubdf453e2017-09-27 13:34:30 +0800259#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700260 if (unlikely(hdd_ctx->config->tx_orphan_enable) && (nskb == skb)) {
Mohit Khannad0b63f52017-02-18 18:05:52 -0800261 /*
262 * For UDP packets we want to orphan the packet to allow the app
263 * to send more packets. The flow would ultimately be controlled
264 * by the limited number of tx descriptors for the vdev.
265 */
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700266 ++adapter->hdd_stats.tx_rx_stats.tx_orphaned;
Mohit Khannad0b63f52017-02-18 18:05:52 -0800267 skb_orphan(skb);
268 }
tfyubdf453e2017-09-27 13:34:30 +0800269#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800270 return nskb;
gbianec670c592016-11-24 11:21:30 +0800271}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
273
274/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530275 * __hdd_softap_hard_start_xmit() - Transmit a frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 * @skb: pointer to OS packet (sk_buff)
277 * @dev: pointer to network device
278 *
279 * Function registered with the Linux OS for transmitting
280 * packets. This version of the function directly passes
281 * the packet to Transport Layer.
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530282 * In case of any packet drop or error, log the error with
283 * INFO HIGH/LOW/MEDIUM to avoid excessive logging in kmsg.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 *
285 * Return: Always returns NETDEV_TX_OK
286 */
Jeff Johnson6376abe2016-10-05 16:24:56 -0700287static int __hdd_softap_hard_start_xmit(struct sk_buff *skb,
288 struct net_device *dev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289{
290 sme_ac_enum_type ac = SME_AC_BE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700291 struct hdd_adapter *adapter = (struct hdd_adapter *) netdev_priv(dev);
Jeff Johnson9bf24972017-10-04 09:26:58 -0700292 struct hdd_ap_ctx *ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530293 struct qdf_mac_addr *pDestMacAddress;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 uint8_t STAId;
Will Huang496b36c2017-07-11 16:38:50 +0800295 uint32_t num_seg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700297 ++adapter->hdd_stats.tx_rx_stats.tx_called;
298 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530299
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 /* Prevent this function from being called during SSR since TL
301 * context may not be reinitialized at this time which may
302 * lead to a crash.
303 */
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +0530304 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530305 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800306 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 goto drop_pkt;
308 }
309
310 /*
311 * If the device is operating on a DFS Channel
312 * then check if SAP is in CAC WAIT state and
313 * drop the packets. In CAC WAIT state device
314 * is expected not to transmit any frames.
315 * SAP starts Tx only after the BSS START is
316 * done.
317 */
Jeff Johnson9bf24972017-10-04 09:26:58 -0700318 if (ap_ctx->dfs_cac_block_tx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800321 /*
Jeff Johnson4fca3b52017-01-12 08:44:18 -0800322 * If a transmit function is not registered, drop packet
323 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700324 if (!adapter->tx_fn) {
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800325 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
326 "%s: TX function not registered by the data path",
327 __func__);
328 goto drop_pkt;
329 }
330
Nirav Shah5e74bb82016-07-20 16:01:27 +0530331 wlan_hdd_classify_pkt(skb);
332
Anurag Chouhan6d760662016-02-20 16:05:43 +0530333 pDestMacAddress = (struct qdf_mac_addr *) skb->data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334
Nirav Shah5e74bb82016-07-20 16:01:27 +0530335 if (QDF_NBUF_CB_GET_IS_BCAST(skb) ||
336 QDF_NBUF_CB_GET_IS_MCAST(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 /* The BC/MC station ID is assigned during BSS
338 * starting phase. SAP will return the station ID
339 * used for BC/MC traffic.
340 */
Jeff Johnson42518cf2017-10-26 13:33:29 -0700341 STAId = ap_ctx->broadcast_sta_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530343 if (QDF_STATUS_SUCCESS !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700344 hdd_softap_get_sta_id(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 pDestMacAddress, &STAId)) {
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;
350 }
351
Prakash Dhavali3107b752016-11-28 14:35:06 +0530352 if (STAId >= WLAN_MAX_STA_COUNT) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530353 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530354 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 "%s: Failed to find right station", __func__);
356 goto drop_pkt;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700357 } else if (false == adapter->sta_info[STAId].in_use) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530358 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530359 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 "%s: STA %d is unregistered", __func__,
361 STAId);
362 goto drop_pkt;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700363 } else if (true == adapter->sta_info[STAId].
Jeff Johnsone4f5d932017-10-21 13:21:15 -0700364 is_deauth_in_progress) {
Poddar, Siddartha5075462017-03-16 19:20:09 +0530365 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530366 QDF_TRACE_LEVEL_INFO_HIGH,
Poddar, Siddartha5075462017-03-16 19:20:09 +0530367 "%s: STA %d deauth in progress", __func__,
368 STAId);
369 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800370 }
371
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800372 if ((OL_TXRX_PEER_STATE_CONN !=
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700373 adapter->sta_info[STAId].peer_state)
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800374 && (OL_TXRX_PEER_STATE_AUTH !=
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700375 adapter->sta_info[STAId].peer_state)) {
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: Station not connected yet", __func__);
379 goto drop_pkt;
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800380 } else if (OL_TXRX_PEER_STATE_CONN ==
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700381 adapter->sta_info[STAId].peer_state) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530383 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530384 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385 "%s: NON-EAPOL packet in non-Authenticated state",
386 __func__);
387 goto drop_pkt;
388 }
389 }
390 }
391
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700392 hdd_get_tx_resource(adapter, STAId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
394
395 /* Get TL AC corresponding to Qdisc queue index/AC. */
396 ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping];
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700397 ++adapter->hdd_stats.tx_rx_stats.tx_classified_ac[ac];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700399#if defined(IPA_OFFLOAD)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530400 if (!qdf_nbuf_ipa_owned_get(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401#endif
gbianec670c592016-11-24 11:21:30 +0800402
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700403 skb = hdd_skb_orphan(adapter, skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404 if (!skb)
Jeff Johnsonedeff232015-11-11 17:19:42 -0800405 goto drop_pkt_accounting;
gbianec670c592016-11-24 11:21:30 +0800406
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700407#if defined(IPA_OFFLOAD)
Yun Park01deb2c2017-06-14 15:21:44 -0700408 } else {
409 /*
410 * Clear the IPA ownership after check it to avoid ipa_free_skb
411 * is called when Tx completed for intra-BSS Tx packets
412 */
413 qdf_nbuf_ipa_owned_clear(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414 }
415#endif
416
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530417 /*
418 * Add SKB to internal tracking table before further processing
419 * in WLAN driver.
420 */
421 qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__);
422
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700423 adapter->stats.tx_bytes += skb->len;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700424 adapter->sta_info[STAId].tx_bytes += skb->len;
Mohit Khannab1dd1e82017-02-04 15:14:38 -0800425
Will Huang496b36c2017-07-11 16:38:50 +0800426 if (qdf_nbuf_is_tso(skb)) {
427 num_seg = qdf_nbuf_get_tso_num_seg(skb);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700428 adapter->stats.tx_packets += num_seg;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700429 adapter->sta_info[STAId].tx_packets += num_seg;
Will Huang496b36c2017-07-11 16:38:50 +0800430 } else {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700431 ++adapter->stats.tx_packets;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700432 adapter->sta_info[STAId].tx_packets++;
Will Huang496b36c2017-07-11 16:38:50 +0800433 }
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700434 adapter->sta_info[STAId].last_tx_rx_ts = qdf_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435
Nirav Shah5e74bb82016-07-20 16:01:27 +0530436 hdd_event_eapol_log(skb, QDF_TX);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700437 qdf_dp_trace_log_pkt(adapter->sessionId, skb, QDF_TX,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700438 QDF_TRACE_DEFAULT_PDEV_ID);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530439 QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
440 QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530442 qdf_dp_trace_set_track(skb, QDF_TX);
443 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700444 QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(skb),
445 sizeof(qdf_nbuf_data(skb)),
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530446 QDF_TX));
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530447 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_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)
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530451 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_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));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700456 if (adapter->tx_fn(adapter->txrx_vdev,
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800457 (qdf_nbuf_t) skb) != NULL) {
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530458 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 "%s: Failed to send packet to txrx for staid:%d",
460 __func__, STAId);
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700461 ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac];
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530462 goto drop_pkt_and_release_skb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800463 }
Dustin Browne0024fa2016-10-14 16:29:21 -0700464 netif_trans_update(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465
466 return NETDEV_TX_OK;
467
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530468drop_pkt_and_release_skb:
469 qdf_net_buf_debug_release_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470drop_pkt:
471
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530472 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700473 QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)skb->data,
474 qdf_nbuf_len(skb), QDF_TX));
Nirav Shahcbc6d722016-03-01 16:24:53 +0530475 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530476 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700477 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530478 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
479 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX));
Jeff Johnsonedeff232015-11-11 17:19:42 -0800480 kfree_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481
Jeff Johnsonedeff232015-11-11 17:19:42 -0800482drop_pkt_accounting:
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700483 ++adapter->stats.tx_dropped;
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700484 ++adapter->hdd_stats.tx_rx_stats.tx_dropped;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485
486 return NETDEV_TX_OK;
487}
488
489/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530490 * hdd_softap_hard_start_xmit() - Wrapper function to protect
491 * __hdd_softap_hard_start_xmit from SSR
492 * @skb: pointer to OS packet
493 * @dev: pointer to net_device structure
494 *
495 * Function called by OS if any packet needs to transmit.
496 *
497 * Return: Always returns NETDEV_TX_OK
498 */
499int hdd_softap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
500{
501 int ret;
502
503 cds_ssr_protect(__func__);
504 ret = __hdd_softap_hard_start_xmit(skb, dev);
505 cds_ssr_unprotect(__func__);
506
507 return ret;
508}
509
510/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 * __hdd_softap_tx_timeout() - TX timeout handler
512 * @dev: pointer to network device
513 *
514 * This function is registered as a netdev ndo_tx_timeout method, and
515 * is invoked by the kernel if the driver takes too long to transmit a
516 * frame.
517 *
518 * Return: None
519 */
520static void __hdd_softap_tx_timeout(struct net_device *dev)
521{
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700522 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsonf7726872017-08-28 11:38:31 -0700523 struct hdd_context *hdd_ctx;
Nirav Shah89223f72016-03-01 18:10:38 +0530524 struct netdev_queue *txq;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530525 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Nirav Shah89223f72016-03-01 18:10:38 +0530526 int i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530528 DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700529 QDF_TRACE_DEFAULT_PDEV_ID,
530 NULL, 0, QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531 /* Getting here implies we disabled the TX queues for too
532 * long. Queues are disabled either because of disassociation
533 * or low resource scenarios. In case of disassociation it is
534 * ok to ignore this. But if associated, we have do possible
535 * recovery here
536 */
537 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +0530538 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530539 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800540 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541 return;
542 }
Nirav Shah89223f72016-03-01 18:10:38 +0530543
Dustin Browne0024fa2016-10-14 16:29:21 -0700544 TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA);
Nirav Shah89223f72016-03-01 18:10:38 +0530545
546 for (i = 0; i < NUM_TX_QUEUES; i++) {
547 txq = netdev_get_tx_queue(dev, i);
548 QDF_TRACE(QDF_MODULE_ID_HDD_DATA,
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800549 QDF_TRACE_LEVEL_DEBUG,
550 "Queue: %d status: %d txq->trans_start: %lu",
Nirav Shah89223f72016-03-01 18:10:38 +0530551 i, netif_tx_queue_stopped(txq), txq->trans_start);
552 }
553
554 wlan_hdd_display_netif_queue_history(hdd_ctx);
Leo Changfdb45c32016-10-28 11:09:23 -0700555 cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC));
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800556 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Nirav Shah89223f72016-03-01 18:10:38 +0530557 "carrier state: %d", netif_carrier_ok(dev));
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530558
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700559 ++adapter->hdd_stats.tx_rx_stats.tx_timeout_cnt;
560 ++adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530561
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700562 if (adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt >
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530563 HDD_TX_STALL_THRESHOLD) {
564 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
565 "Detected data stall due to continuous TX timeouts");
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700566 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530567 cdp_post_data_stall_event(soc,
568 DATA_STALL_LOG_INDICATOR_HOST_DRIVER,
569 DATA_STALL_LOG_HOST_SOFTAP_TX_TIMEOUT,
570 0xFF, 0xFF,
571 DATA_STALL_LOG_RECOVERY_TRIGGER_PDR);
572 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573}
574
575/**
576 * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout
577 * @dev: pointer to net_device
578 *
579 * Return: none
580 */
581void hdd_softap_tx_timeout(struct net_device *dev)
582{
583 cds_ssr_protect(__func__);
584 __hdd_softap_tx_timeout(dev);
585 cds_ssr_unprotect(__func__);
586}
587
588/**
589 * @hdd_softap_init_tx_rx() - Initialize Tx/RX module
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700590 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530592 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
593 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700595QDF_STATUS hdd_softap_init_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530597 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598
599 uint8_t STAId = 0;
600
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700601 qdf_mem_zero(&adapter->stats, sizeof(struct net_device_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800602
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700603 spin_lock_init(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604
605 for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) {
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700606 qdf_mem_zero(&adapter->sta_info[STAId],
Jeff Johnson82155922017-09-30 16:54:14 -0700607 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 }
609
610 return status;
611}
612
613/**
614 * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700615 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530617 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
618 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700620QDF_STATUS hdd_softap_deinit_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700622 if (adapter == NULL) {
623 hdd_err("Called with adapter = NULL.");
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800624 return QDF_STATUS_E_FAILURE;
625 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800626
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700627 adapter->txrx_vdev = NULL;
628 adapter->tx_fn = NULL;
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800629 hdd_info("Deregistering TX function hook !");
630 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631}
632
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700633QDF_STATUS hdd_softap_init_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnson349d9a92017-10-21 15:38:03 -0700634 uint8_t sta_id,
635 struct qdf_mac_addr *sta_mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636{
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700637 spin_lock_bh(&adapter->sta_info_lock);
638 if (adapter->sta_info[sta_id].in_use) {
639 spin_unlock_bh(&adapter->sta_info_lock);
Jeff Johnson349d9a92017-10-21 15:38:03 -0700640 hdd_err("Reinit of in use station %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530641 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 }
643
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700644 qdf_mem_zero(&adapter->sta_info[sta_id],
Jeff Johnson82155922017-09-30 16:54:14 -0700645 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800646
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700647 adapter->sta_info[sta_id].in_use = true;
648 adapter->sta_info[sta_id].is_deauth_in_progress = false;
649 qdf_copy_macaddr(&adapter->sta_info[sta_id].sta_mac, sta_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700651 spin_unlock_bh(&adapter->sta_info_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530652 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653}
654
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700655QDF_STATUS hdd_softap_deinit_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnsonb157c722017-10-21 15:46:42 -0700656 uint8_t sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530658 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson5c19ade2017-10-04 09:52:12 -0700659 struct hdd_hostapd_state *hostapd_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660
Jeff Johnson5c19ade2017-10-04 09:52:12 -0700661 hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700663 spin_lock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700665 if (false == adapter->sta_info[sta_id].in_use) {
666 spin_unlock_bh(&adapter->sta_info_lock);
Jeff Johnsonb157c722017-10-21 15:46:42 -0700667 hdd_err("Deinit station not inited %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530668 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 }
670
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700671 adapter->sta_info[sta_id].in_use = false;
672 adapter->sta_info[sta_id].is_deauth_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700674 spin_unlock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 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 Johnsond31ab6a2017-10-02 13:23:51 -0700692 struct hdd_adapter *adapter = 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 Johnson92402872017-09-03 09:25:37 -0700697 struct hdd_context *hdd_ctx = NULL;
Will Huang496b36c2017-07-11 16:38:50 +0800698 struct qdf_mac_addr src_mac;
699 uint8_t staid;
Mohit Khannaf8f96822017-05-17 17:11:59 -0700700 bool proto_pkt_logged = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701
702 /* Sanity check on inputs */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800703 if (unlikely((NULL == context) || (NULL == rxBuf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530704 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705 "%s: Null params being passed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530706 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707 }
708
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700709 adapter = (struct hdd_adapter *)context;
710 if (unlikely(WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800711 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre182b0272016-02-17 15:35:07 -0800712 "Magic cookie(%x) for adapter sanity verification is invalid",
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700713 adapter->magic);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530714 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800715 }
716
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700717 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson92402872017-09-03 09:25:37 -0700718 if (unlikely(NULL == hdd_ctx)) {
Dhanashri Atre182b0272016-02-17 15:35:07 -0800719 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
720 "%s: HDD context is Null", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530721 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722 }
723
724 /* walk the chain until all are processed */
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800725 next = (struct sk_buff *)rxBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800727 while (next) {
728 skb = next;
729 next = skb->next;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800730 skb->next = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800731
psimha884025c2017-08-01 15:07:32 -0700732#ifdef QCA_WIFI_QCA6290 /* Debug code, remove later */
Venkata Sharath Chandra Manchalacc789172017-07-25 23:28:45 -0700733 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_INFO,
Jeff Johnson36e74c42017-09-18 08:15:42 -0700734 "%s: skb %pK skb->len %d\n", __func__, skb, skb->len);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800735#endif
736
Dhanashri Atre63d98022017-01-24 18:22:09 -0800737 hdd_softap_dump_sk_buff(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700739 skb->dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740
Dhanashri Atre63d98022017-01-24 18:22:09 -0800741 if (unlikely(skb->dev == NULL)) {
742
743 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
744 "%s: ERROR!!Invalid netdevice", __func__);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800745 continue;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800746 }
747 cpu_index = wlan_hdd_get_cpu();
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700748 ++adapter->hdd_stats.tx_rx_stats.rx_packets[cpu_index];
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700749 ++adapter->stats.rx_packets;
750 adapter->stats.rx_bytes += skb->len;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800751
Will Huang496b36c2017-07-11 16:38:50 +0800752 qdf_mem_copy(&src_mac, skb->data + QDF_NBUF_SRC_MAC_OFFSET,
753 sizeof(src_mac));
754 if (QDF_STATUS_SUCCESS ==
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700755 hdd_softap_get_sta_id(adapter, &src_mac, &staid)) {
Will Huang496b36c2017-07-11 16:38:50 +0800756 if (staid < WLAN_MAX_STA_COUNT) {
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700757 adapter->sta_info[staid].rx_packets++;
758 adapter->sta_info[staid].rx_bytes += skb->len;
759 adapter->sta_info[staid].last_tx_rx_ts =
Will Huang496b36c2017-07-11 16:38:50 +0800760 qdf_system_ticks();
761 }
762 }
Dhanashri Atre63d98022017-01-24 18:22:09 -0800763 hdd_event_eapol_log(skb, QDF_RX);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700764 proto_pkt_logged = qdf_dp_trace_log_pkt(adapter->sessionId,
Mohit Khannaf8f96822017-05-17 17:11:59 -0700765 skb, QDF_RX,
766 QDF_TRACE_DEFAULT_PDEV_ID);
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530767 DPTRACE(qdf_dp_trace(skb,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800768 QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700769 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530770 qdf_nbuf_data_addr(skb),
771 sizeof(qdf_nbuf_data(skb)), QDF_RX));
Mohit Khannaf8f96822017-05-17 17:11:59 -0700772 if (!proto_pkt_logged) {
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,
776 (uint8_t *)skb->data, qdf_nbuf_len(skb),
777 QDF_RX));
Mohit Khannaf8f96822017-05-17 17:11:59 -0700778 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
779 DPTRACE(qdf_dp_trace(skb,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530780 QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700781 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530782 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
783 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE),
784 QDF_RX));
Mohit Khannaf8f96822017-05-17 17:11:59 -0700785 }
Dhanashri Atre63d98022017-01-24 18:22:09 -0800786
787 skb->protocol = eth_type_trans(skb, skb->dev);
788
789 /* hold configurable wakelock for unicast traffic */
Jeff Johnson92402872017-09-03 09:25:37 -0700790 if (hdd_ctx->config->rx_wakelock_timeout &&
Dhanashri Atre63d98022017-01-24 18:22:09 -0800791 skb->pkt_type != PACKET_BROADCAST &&
792 skb->pkt_type != PACKET_MULTICAST) {
Jeff Johnson92402872017-09-03 09:25:37 -0700793 cds_host_diag_log_work(&hdd_ctx->rx_wake_lock,
794 hdd_ctx->config->rx_wakelock_timeout,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800795 WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
Jeff Johnson92402872017-09-03 09:25:37 -0700796 qdf_wake_lock_timeout_acquire(&hdd_ctx->rx_wake_lock,
797 hdd_ctx->config->
Dhanashri Atre63d98022017-01-24 18:22:09 -0800798 rx_wakelock_timeout);
799 }
800
801 /* Remove SKB from internal tracking table before submitting
802 * it to stack
803 */
Manjunathappa Prakash17c07bd2017-04-27 21:24:28 -0700804 qdf_net_buf_debug_release_skb(skb);
Dhanashri Atre63d98022017-01-24 18:22:09 -0800805 if (hdd_napi_enabled(HDD_NAPI_ANY) &&
Jeff Johnsone2ba3cd2017-10-30 20:02:09 -0700806 !hdd_ctx->enable_rxthread)
Dhanashri Atre63d98022017-01-24 18:22:09 -0800807 rxstat = netif_receive_skb(skb);
808 else
809 rxstat = netif_rx_ni(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700810 if (NET_RX_SUCCESS == rxstat)
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700811 ++adapter->hdd_stats.tx_rx_stats.rx_delivered[cpu_index];
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700812 else
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700813 ++adapter->hdd_stats.tx_rx_stats.rx_refused[cpu_index];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530816 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817}
818
819/**
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700820 * hdd_softap_deregister_sta(struct hdd_adapter *adapter, uint8_t staId)
821 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 * @staId: Station ID to deregister
823 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530824 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700826QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700827 uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530829 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Jeff Johnson92402872017-09-03 09:25:37 -0700830 struct hdd_context *hdd_ctx;
Abhishek Singh07c627e2017-03-20 17:56:34 +0530831 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700833 if (NULL == adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800834 hdd_err("NULL adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530835 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 }
837
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700838 if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800839 hdd_err("Invalid adapter magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530840 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 }
842
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700843 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 /* Clear station in TL and then update HDD data
845 * structures. This helps to block RX frames from other
846 * station to this station.
847 */
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800848 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800849 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
850 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530851 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800852 hdd_err("cdp_clear_peer failed for staID %d, Status=%d [0x%08X]",
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800853 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 }
855
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700856 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev,
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700857 adapter->sta_info[staId].
Jeff Johnsonf2356512017-10-21 16:04:12 -0700858 sta_mac.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +0530859 if (ret)
860 hdd_err("Peer obj %pM delete fails",
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700861 adapter->sta_info[staId].sta_mac.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +0530862
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700863 if (adapter->sta_info[staId].in_use) {
864 spin_lock_bh(&adapter->sta_info_lock);
865 qdf_mem_zero(&adapter->sta_info[staId],
Jeff Johnson82155922017-09-30 16:54:14 -0700866 sizeof(struct hdd_station_info));
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700867 spin_unlock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 }
Abhishek Singh07c627e2017-03-20 17:56:34 +0530869
Jeff Johnson92402872017-09-03 09:25:37 -0700870 hdd_ctx->sta_to_adapter[staId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530872 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873}
874
875/**
876 * hdd_softap_register_sta() - Register a SoftAP STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700877 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 * @fAuthRequired: is additional authentication required?
879 * @fPrivacyBit: should 802.11 privacy bit be set?
880 * @staId: station ID assigned to this station
881 * @ucastSig: unicast security signature
882 * @bcastSig: broadcast security signature
883 * @pPeerMacAddress: station MAC address
884 * @fWmmEnabled: is WMM enabled for this STA?
885 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530886 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700888QDF_STATUS hdd_softap_register_sta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889 bool fAuthRequired,
890 bool fPrivacyBit,
891 uint8_t staId,
892 uint8_t ucastSig,
893 uint8_t bcastSig,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530894 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 bool fWmmEnabled)
896{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530897 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700899 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -0800900 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -0700901 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
902 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800904 hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u",
905 staId, fAuthRequired, fPrivacyBit, fWmmEnabled);
906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 /*
908 * Clean up old entry if it is not cleaned up properly
909 */
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700910 if (adapter->sta_info[staId].in_use) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800911 hdd_info("clean up old entry for STA %d", staId);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700912 hdd_softap_deregister_sta(adapter, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800915 /* Get the Station ID from the one saved during the assocation. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 staDesc.sta_id = staId;
917
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700918 /* Save the adapter Pointer for this staId */
919 hdd_ctx->sta_to_adapter[staId] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530921 qdf_status =
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700922 hdd_softap_init_tx_rx_sta(adapter, staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923 pPeerMacAddress);
924
925 staDesc.is_qos_enabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926
Dhanashri Atre182b0272016-02-17 15:35:07 -0800927 /* Register the vdev transmit and receive functions */
928 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
929 txrx_ops.rx.rx = hdd_softap_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -0700930 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800931 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700932 (struct cdp_pdev *)pdev, adapter->sessionId),
933 adapter, &txrx_ops);
934 adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800935 (struct cdp_pdev *)pdev,
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700936 adapter->sessionId);
937 adapter->tx_fn = txrx_ops.tx.tx;
Dhanashri Atre182b0272016-02-17 15:35:07 -0800938
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800939 qdf_status = cdp_peer_register(soc,
940 (struct cdp_pdev *)pdev, &staDesc);
Dhanashri Atre50141c52016-04-07 13:15:29 -0700941 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800942 hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]",
943 qdf_status, qdf_status);
Dhanashri Atre50141c52016-04-07 13:15:29 -0700944 return qdf_status;
945 }
946
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947 /* if ( WPA ), tell TL to go to 'connected' and after keys come to the
948 * driver then go to 'authenticated'. For all other authentication
949 * types (those that do not require upper layer authentication) we can
950 * put TL directly into 'authenticated' state
951 */
952
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700953 adapter->sta_info[staId].sta_id = staId;
954 adapter->sta_info[staId].is_qos_enabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955
956 if (!fAuthRequired) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800957 hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time",
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700958 adapter->sta_info[staId].sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959
960 /* Connections that do not need Upper layer auth,
961 * transition TL directly to 'Authenticated' state.
962 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700963 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800964 OL_TXRX_PEER_STATE_AUTH, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700966 adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_AUTH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 } else {
968
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800969 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700970 adapter->sta_info[staId].sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700972 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800973 OL_TXRX_PEER_STATE_CONN, false);
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700974 adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_CONN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 }
976
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700977 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700978 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
980 WLAN_CONTROL_PATH);
981
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530982 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983}
984
985/**
986 * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700987 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 * @fPrivacyBit: should 802.11 privacy bit be set?
989 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530990 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700992QDF_STATUS hdd_softap_register_bc_sta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 bool fPrivacyBit)
994{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530995 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700996 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530997 struct qdf_mac_addr broadcastMacAddr =
998 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Jeff Johnson9bf24972017-10-04 09:26:58 -0700999 struct hdd_ap_ctx *ap_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000
Jeff Johnson9bf24972017-10-04 09:26:58 -07001001 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001003 hdd_ctx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = adapter;
Jeff Johnson42518cf2017-10-26 13:33:29 -07001004 hdd_ctx->sta_to_adapter[ap_ctx->broadcast_sta_id] = adapter;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301005 qdf_status =
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001006 hdd_softap_register_sta(adapter, false, fPrivacyBit,
Jeff Johnson42518cf2017-10-26 13:33:29 -07001007 ap_ctx->broadcast_sta_id,
1008 0, 1, &broadcastMacAddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301010 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011}
1012
1013/**
1014 * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001015 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301017 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001019QDF_STATUS hdd_softap_deregister_bc_sta(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020{
Jeff Johnson42518cf2017-10-26 13:33:29 -07001021 struct hdd_ap_ctx *ap_ctx;
1022
1023 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
1024 return hdd_softap_deregister_sta(adapter, ap_ctx->broadcast_sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025}
1026
1027/**
1028 * hdd_softap_stop_bss() - Stop the BSS
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001029 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301031 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001033QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301035 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 uint8_t staId = 0;
Jeff Johnson92402872017-09-03 09:25:37 -07001037 struct hdd_context *hdd_ctx;
Srinivas Girigowdae806a822017-03-25 11:25:30 -07001038
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001039 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040
Rajeev Kumar07bbe122017-10-24 13:06:05 -07001041 /* This is stop bss callback running in scheduler thread so do not
1042 * driver unload in progress check otherwise it can lead to peer
1043 * object leak
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001045 qdf_status = hdd_softap_deregister_bc_sta(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301047 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson42518cf2017-10-26 13:33:29 -07001048 struct hdd_ap_ctx *ap_ctx;
1049
1050 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001051 hdd_err("Failed to deregister BC sta Id %d",
Jeff Johnson42518cf2017-10-26 13:33:29 -07001052 ap_ctx->broadcast_sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 }
1054
1055 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
1056 /* This excludes BC sta as it is already deregistered */
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001057 if (adapter->sta_info[staId].in_use) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001058 qdf_status = hdd_softap_deregister_sta(adapter, staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301059 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001060 hdd_err("Failed to deregister sta Id %d",
1061 staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 }
1063 }
1064 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301065 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066}
1067
1068/**
1069 * hdd_softap_change_sta_state() - Change the state of a SoftAP station
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001070 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 * @pDestMacAddress: MAC address of the station
1072 * @state: new state of the station
1073 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301074 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001076QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301077 struct qdf_mac_addr *pDestMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 enum ol_txrx_peer_state state)
1079{
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001080 uint8_t sta_id = WLAN_MAX_STA_COUNT;
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001081 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001083 ENTER_DEV(adapter->dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001085 qdf_status = hdd_softap_get_sta_id(adapter, pDestMacAddress, &sta_id);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001086 if (QDF_STATUS_SUCCESS != qdf_status) {
1087 hdd_err("Failed to find right station");
1088 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 }
1090
1091 if (false ==
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001092 qdf_is_macaddr_equal(&adapter->sta_info[sta_id].sta_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 pDestMacAddress)) {
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001094 hdd_err("Station %u MAC address not matching", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301095 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 }
1097
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301098 qdf_status =
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001099 hdd_change_peer_state(adapter, sta_id, state, false);
1100 hdd_info("Station %u changed to state %d", sta_id, state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301102 if (QDF_STATUS_SUCCESS == qdf_status) {
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001103 adapter->sta_info[sta_id].peer_state =
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001104 OL_TXRX_PEER_STATE_AUTH;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001105 p2p_peer_authorized(adapter->hdd_vdev, pDestMacAddress->bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 }
1107
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001108 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301109 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110}
1111
1112/*
1113 * hdd_softap_get_sta_id() - Find station ID from MAC address
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001114 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115 * @pDestMacAddress: MAC address of the destination
1116 * @staId: Station ID associated with the MAC address
1117 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301118 * Return: QDF_STATUS_SUCCESS if a match was found, in which case
1119 * staId is populated, QDF_STATUS_E_FAILURE if a match is
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120 * not found
1121 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001122QDF_STATUS hdd_softap_get_sta_id(struct hdd_adapter *adapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301123 struct qdf_mac_addr *pMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 uint8_t *staId)
1125{
1126 uint8_t i;
1127
1128 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301129 if (!qdf_mem_cmp
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001130 (&adapter->sta_info[i].sta_mac, pMacAddress,
1131 QDF_MAC_ADDR_SIZE) && adapter->sta_info[i].in_use) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132 *staId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301133 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 }
1135 }
1136
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301137 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138}