blob: 4062e6a52256409ca6281c27c40b47b6d7d1f8e6 [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>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080050#ifdef IPA_OFFLOAD
51#include <wlan_hdd_ipa.h>
52#endif
53
54/* Preprocessor definitions and constants */
55#undef QCA_HDD_SAP_DUMP_SK_BUFF
56
57/* Type declarations */
58
59/* Function definitions and documenation */
60#ifdef QCA_HDD_SAP_DUMP_SK_BUFF
61/**
62 * hdd_softap_dump_sk_buff() - Dump an skb
63 * @skb: skb to dump
64 *
65 * Return: None
66 */
67static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
68{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053069 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 "%s: head = %p ", __func__, skb->head);
Srinivas Girigowdae806a822017-03-25 11:25:30 -070071 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072 "%s: tail = %p ", __func__, skb->tail);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053073 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074 "%s: end = %p ", __func__, skb->end);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053075 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076 "%s: len = %d ", __func__, skb->len);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053077 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080078 "%s: data_len = %d ", __func__, skb->data_len);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053079 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 "%s: mac_len = %d", __func__, skb->mac_len);
81
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053082 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ", skb->data[0],
84 skb->data[1], skb->data[2], skb->data[3], skb->data[4],
85 skb->data[5], skb->data[6], skb->data[7]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053086 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[8],
88 skb->data[9], skb->data[10], skb->data[11], skb->data[12],
89 skb->data[13], skb->data[14], skb->data[15]);
90}
91#else
92static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
93{
94}
95#endif
96
97#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
98/**
99 * hdd_softap_tx_resume_timer_expired_handler() - TX Q resume timer handler
100 * @adapter_context: pointer to vdev adapter
101 *
102 * TX Q resume timer handler for SAP and P2P GO interface. If Blocked
103 * OS Q is not resumed during timeout period, to prevent permanent
104 * stall, resume OS Q forcefully for SAP and P2P GO interface.
105 *
106 * Return: None
107 */
108void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context)
109{
110 hdd_adapter_t *pAdapter = (hdd_adapter_t *) adapter_context;
111
112 if (!pAdapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800113 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 return;
115 }
116
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800117 hdd_notice("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118 wlan_hdd_netif_queue_control(pAdapter, WLAN_WAKE_ALL_NETIF_QUEUE,
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800119 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800120}
121
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530122#if defined(CONFIG_PER_VDEV_TX_DESC_POOL)
123
124/**
125 * hdd_softap_tx_resume_false() - Resume OS TX Q false leads to queue disabling
126 * @pAdapter: pointer to hdd adapter
127 * @tx_resume: TX Q resume trigger
128 *
129 *
130 * Return: None
131 */
132static void
133hdd_softap_tx_resume_false(hdd_adapter_t *pAdapter, bool tx_resume)
134{
135 if (true == tx_resume)
136 return;
137
138 hdd_notice("Disabling queues");
139 wlan_hdd_netif_queue_control(pAdapter, WLAN_STOP_ALL_NETIF_QUEUE,
140 WLAN_DATA_FLOW_CONTROL);
141
142 if (QDF_TIMER_STATE_STOPPED ==
143 qdf_mc_timer_get_current_state(&pAdapter->
144 tx_flow_control_timer)) {
145 QDF_STATUS status;
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700146
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530147 status = qdf_mc_timer_start(&pAdapter->tx_flow_control_timer,
148 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
149
150 if (!QDF_IS_STATUS_SUCCESS(status))
151 hdd_err("Failed to start tx_flow_control_timer");
152 else
153 pAdapter->hdd_stats.hddTxRxStats.txflow_timer_cnt++;
154 }
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530155}
156#else
157
158static inline void
159hdd_softap_tx_resume_false(hdd_adapter_t *pAdapter, bool tx_resume)
160{
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530161}
162#endif
163
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164/**
165 * hdd_softap_tx_resume_cb() - Resume OS TX Q.
166 * @adapter_context: pointer to vdev apdapter
167 * @tx_resume: TX Q resume trigger
168 *
169 * Q was stopped due to WLAN TX path low resource condition
170 *
171 * Return: None
172 */
173void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume)
174{
175 hdd_adapter_t *pAdapter = (hdd_adapter_t *) adapter_context;
176
177 if (!pAdapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800178 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 return;
180 }
181
182 /* Resume TX */
183 if (true == tx_resume) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530184 if (QDF_TIMER_STATE_STOPPED !=
185 qdf_mc_timer_get_current_state(&pAdapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 tx_flow_control_timer)) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530187 qdf_mc_timer_stop(&pAdapter->tx_flow_control_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800188 }
189
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800190 hdd_notice("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191 wlan_hdd_netif_queue_control(pAdapter,
192 WLAN_WAKE_ALL_NETIF_QUEUE,
193 WLAN_DATA_FLOW_CONTROL);
194 }
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530195 hdd_softap_tx_resume_false(pAdapter, tx_resume);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196}
gbianec670c592016-11-24 11:21:30 +0800197
198static inline struct sk_buff *hdd_skb_orphan(hdd_adapter_t *pAdapter,
199 struct sk_buff *skb)
200{
201 if (pAdapter->tx_flow_low_watermark > 0)
202 skb_orphan(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700203 else
gbianec670c592016-11-24 11:21:30 +0800204 skb = skb_unshare(skb, GFP_ATOMIC);
gbianec670c592016-11-24 11:21:30 +0800205
206 return skb;
207}
208
209#else
Mohit Khannad0b63f52017-02-18 18:05:52 -0800210/**
211 * hdd_skb_orphan() - skb_unshare a cloned packed else skb_orphan
212 * @pAdapter: pointer to HDD adapter
213 * @skb: pointer to skb data packet
214 *
215 * Return: pointer to skb structure
216 */
Mohit Khannaebf4ca32017-03-14 22:02:35 -0700217static inline struct sk_buff *hdd_skb_orphan(hdd_adapter_t *pAdapter,
Mohit Khannad0b63f52017-02-18 18:05:52 -0800218 struct sk_buff *skb) {
gbianec670c592016-11-24 11:21:30 +0800219
Mohit Khannad0b63f52017-02-18 18:05:52 -0800220 struct sk_buff *nskb;
221 nskb = skb_unshare(skb, GFP_ATOMIC);
222
223 if (nskb == skb) {
224 /*
225 * For UDP packets we want to orphan the packet to allow the app
226 * to send more packets. The flow would ultimately be controlled
227 * by the limited number of tx descriptors for the vdev.
228 */
229 ++pAdapter->hdd_stats.hddTxRxStats.txXmitOrphaned;
230 skb_orphan(skb);
231 }
232 return nskb;
gbianec670c592016-11-24 11:21:30 +0800233}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
235
236/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530237 * __hdd_softap_hard_start_xmit() - Transmit a frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 * @skb: pointer to OS packet (sk_buff)
239 * @dev: pointer to network device
240 *
241 * Function registered with the Linux OS for transmitting
242 * packets. This version of the function directly passes
243 * the packet to Transport Layer.
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530244 * In case of any packet drop or error, log the error with
245 * INFO HIGH/LOW/MEDIUM to avoid excessive logging in kmsg.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 *
247 * Return: Always returns NETDEV_TX_OK
248 */
Jeff Johnson6376abe2016-10-05 16:24:56 -0700249static int __hdd_softap_hard_start_xmit(struct sk_buff *skb,
250 struct net_device *dev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251{
252 sme_ac_enum_type ac = SME_AC_BE;
253 hdd_adapter_t *pAdapter = (hdd_adapter_t *) netdev_priv(dev);
254 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530255 struct qdf_mac_addr *pDestMacAddress;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800256 uint8_t STAId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257
258 ++pAdapter->hdd_stats.hddTxRxStats.txXmitCalled;
259 /* Prevent this function from being called during SSR since TL
260 * context may not be reinitialized at this time which may
261 * lead to a crash.
262 */
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800263 if (cds_is_driver_recovering()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530264 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800265 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266 goto drop_pkt;
267 }
268
269 /*
270 * If the device is operating on a DFS Channel
271 * then check if SAP is in CAC WAIT state and
272 * drop the packets. In CAC WAIT state device
273 * is expected not to transmit any frames.
274 * SAP starts Tx only after the BSS START is
275 * done.
276 */
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700277 if (pHddApCtx->dfs_cac_block_tx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800280 /*
Jeff Johnson4fca3b52017-01-12 08:44:18 -0800281 * If a transmit function is not registered, drop packet
282 */
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800283 if (!pAdapter->tx_fn) {
284 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
285 "%s: TX function not registered by the data path",
286 __func__);
287 goto drop_pkt;
288 }
289
Nirav Shah5e74bb82016-07-20 16:01:27 +0530290 wlan_hdd_classify_pkt(skb);
291
Anurag Chouhan6d760662016-02-20 16:05:43 +0530292 pDestMacAddress = (struct qdf_mac_addr *) skb->data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800293
Nirav Shah5e74bb82016-07-20 16:01:27 +0530294 if (QDF_NBUF_CB_GET_IS_BCAST(skb) ||
295 QDF_NBUF_CB_GET_IS_MCAST(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296 /* The BC/MC station ID is assigned during BSS
297 * starting phase. SAP will return the station ID
298 * used for BC/MC traffic.
299 */
300 STAId = pHddApCtx->uBCStaId;
301 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530302 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 hdd_softap_get_sta_id(pAdapter,
304 pDestMacAddress, &STAId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530305 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530306 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 "%s: Failed to find right station", __func__);
308 goto drop_pkt;
309 }
310
Prakash Dhavali3107b752016-11-28 14:35:06 +0530311 if (STAId >= WLAN_MAX_STA_COUNT) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530312 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530313 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314 "%s: Failed to find right station", __func__);
315 goto drop_pkt;
316 } else if (false == pAdapter->aStaInfo[STAId].isUsed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530317 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530318 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 "%s: STA %d is unregistered", __func__,
320 STAId);
321 goto drop_pkt;
Poddar, Siddartha5075462017-03-16 19:20:09 +0530322 } else if (true == pAdapter->aStaInfo[STAId].
323 isDeauthInProgress) {
324 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530325 QDF_TRACE_LEVEL_INFO_HIGH,
Poddar, Siddartha5075462017-03-16 19:20:09 +0530326 "%s: STA %d deauth in progress", __func__,
327 STAId);
328 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 }
330
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800331 if ((OL_TXRX_PEER_STATE_CONN !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 pAdapter->aStaInfo[STAId].tlSTAState)
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800333 && (OL_TXRX_PEER_STATE_AUTH !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334 pAdapter->aStaInfo[STAId].tlSTAState)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530335 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530336 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 "%s: Station not connected yet", __func__);
338 goto drop_pkt;
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800339 } else if (OL_TXRX_PEER_STATE_CONN ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 pAdapter->aStaInfo[STAId].tlSTAState) {
341 if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530342 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530343 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 "%s: NON-EAPOL packet in non-Authenticated state",
345 __func__);
346 goto drop_pkt;
347 }
348 }
349 }
350
351 hdd_get_tx_resource(pAdapter, STAId,
352 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
353
354 /* Get TL AC corresponding to Qdisc queue index/AC. */
355 ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping];
356 ++pAdapter->hdd_stats.hddTxRxStats.txXmitClassifiedAC[ac];
357
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700358#if defined(IPA_OFFLOAD)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530359 if (!qdf_nbuf_ipa_owned_get(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360#endif
gbianec670c592016-11-24 11:21:30 +0800361
362#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
363 /*
Jeff Johnson4fca3b52017-01-12 08:44:18 -0800364 * The TCP TX throttling logic is changed a little after
365 * 3.19-rc1 kernel, the TCP sending limit will be smaller,
366 * which will throttle the TCP packets to the host driver.
367 * The TCP UP LINK throughput will drop heavily. In order to
368 * fix this issue, need to orphan the socket buffer asap, which
369 * will call skb's destructor to notify the TCP stack that the
370 * SKB buffer is unowned. And then the TCP stack will pump more
371 * packets to host driver.
372 *
373 * The TX packets might be dropped for UDP case in the iperf
374 * testing. So need to be protected by follow control.
375 */
gbianec670c592016-11-24 11:21:30 +0800376 skb = hdd_skb_orphan(pAdapter, skb);
377#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 /* Check if the buffer has enough header room */
379 skb = skb_unshare(skb, GFP_ATOMIC);
gbianec670c592016-11-24 11:21:30 +0800380#endif
381
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 if (!skb)
Jeff Johnsonedeff232015-11-11 17:19:42 -0800383 goto drop_pkt_accounting;
gbianec670c592016-11-24 11:21:30 +0800384
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700385#if defined(IPA_OFFLOAD)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 }
387#endif
388
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530389 /*
390 * Add SKB to internal tracking table before further processing
391 * in WLAN driver.
392 */
393 qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__);
394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 pAdapter->stats.tx_bytes += skb->len;
Mohit Khannab1dd1e82017-02-04 15:14:38 -0800396
397 if (qdf_nbuf_is_tso(skb))
398 pAdapter->stats.tx_packets += qdf_nbuf_get_tso_num_seg(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700399 else
Mohit Khannab1dd1e82017-02-04 15:14:38 -0800400 ++pAdapter->stats.tx_packets;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401
Nirav Shah5e74bb82016-07-20 16:01:27 +0530402 hdd_event_eapol_log(skb, QDF_TX);
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530403 qdf_dp_trace_log_pkt(pAdapter->sessionId, skb, QDF_TX);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530404 QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
405 QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530407 qdf_dp_trace_set_track(skb, QDF_TX);
408 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530409 qdf_nbuf_data_addr(skb), sizeof(qdf_nbuf_data(skb)),
410 QDF_TX));
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530411 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
412 (uint8_t *)skb->data, qdf_nbuf_len(skb), QDF_TX));
Nirav Shahcbc6d722016-03-01 16:24:53 +0530413 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530414 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
415 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
416 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417
Leo Changfdb45c32016-10-28 11:09:23 -0700418 if (pAdapter->tx_fn(pAdapter->txrx_vdev,
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800419 (qdf_nbuf_t) skb) != NULL) {
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530420 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421 "%s: Failed to send packet to txrx for staid:%d",
422 __func__, STAId);
423 ++pAdapter->hdd_stats.hddTxRxStats.txXmitDroppedAC[ac];
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530424 goto drop_pkt_and_release_skb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425 }
Dustin Browne0024fa2016-10-14 16:29:21 -0700426 netif_trans_update(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427
428 return NETDEV_TX_OK;
429
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530430drop_pkt_and_release_skb:
431 qdf_net_buf_debug_release_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432drop_pkt:
433
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530434 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530435 (uint8_t *)skb->data, qdf_nbuf_len(skb), QDF_TX));
Nirav Shahcbc6d722016-03-01 16:24:53 +0530436 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530437 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530438 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
439 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX));
Jeff Johnsonedeff232015-11-11 17:19:42 -0800440 kfree_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441
Jeff Johnsonedeff232015-11-11 17:19:42 -0800442drop_pkt_accounting:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 ++pAdapter->stats.tx_dropped;
444 ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445
446 return NETDEV_TX_OK;
447}
448
449/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530450 * hdd_softap_hard_start_xmit() - Wrapper function to protect
451 * __hdd_softap_hard_start_xmit from SSR
452 * @skb: pointer to OS packet
453 * @dev: pointer to net_device structure
454 *
455 * Function called by OS if any packet needs to transmit.
456 *
457 * Return: Always returns NETDEV_TX_OK
458 */
459int hdd_softap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
460{
461 int ret;
462
463 cds_ssr_protect(__func__);
464 ret = __hdd_softap_hard_start_xmit(skb, dev);
465 cds_ssr_unprotect(__func__);
466
467 return ret;
468}
469
Sen, Devendra154b3c42017-02-13 20:44:15 +0530470#ifdef FEATURE_WLAN_DIAG_SUPPORT
471/**
472 * hdd_wlan_datastall_sap_event()- Send SAP datastall information
473 *
474 * This Function send send SAP datastall diag event
475 *
476 * Return: void.
477 */
478static void hdd_wlan_datastall_sap_event(void)
479{
480 WLAN_HOST_DIAG_EVENT_DEF(sap_data_stall,
481 struct host_event_wlan_datastall);
482 qdf_mem_zero(&sap_data_stall, sizeof(sap_data_stall));
483 sap_data_stall.reason = SOFTAP_TX_TIMEOUT;
484 WLAN_HOST_DIAG_EVENT_REPORT(&sap_data_stall,
485 EVENT_WLAN_SOFTAP_DATASTALL);
486}
487#else
488static inline void hdd_wlan_datastall_sap_event(void)
489{
490
491}
492#endif
493
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530494/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495 * __hdd_softap_tx_timeout() - TX timeout handler
496 * @dev: pointer to network device
497 *
498 * This function is registered as a netdev ndo_tx_timeout method, and
499 * is invoked by the kernel if the driver takes too long to transmit a
500 * frame.
501 *
502 * Return: None
503 */
504static void __hdd_softap_tx_timeout(struct net_device *dev)
505{
506 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
507 hdd_context_t *hdd_ctx;
Nirav Shah89223f72016-03-01 18:10:38 +0530508 struct netdev_queue *txq;
509 int i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530511 DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530512 NULL, 0, QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513 /* Getting here implies we disabled the TX queues for too
514 * long. Queues are disabled either because of disassociation
515 * or low resource scenarios. In case of disassociation it is
516 * ok to ignore this. But if associated, we have do possible
517 * recovery here
518 */
519 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800520 if (cds_is_driver_recovering()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530521 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800522 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523 return;
524 }
Nirav Shah89223f72016-03-01 18:10:38 +0530525
Dustin Browne0024fa2016-10-14 16:29:21 -0700526 TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA);
Nirav Shah89223f72016-03-01 18:10:38 +0530527
528 for (i = 0; i < NUM_TX_QUEUES; i++) {
529 txq = netdev_get_tx_queue(dev, i);
530 QDF_TRACE(QDF_MODULE_ID_HDD_DATA,
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800531 QDF_TRACE_LEVEL_DEBUG,
532 "Queue: %d status: %d txq->trans_start: %lu",
Nirav Shah89223f72016-03-01 18:10:38 +0530533 i, netif_tx_queue_stopped(txq), txq->trans_start);
534 }
535
536 wlan_hdd_display_netif_queue_history(hdd_ctx);
Leo Changfdb45c32016-10-28 11:09:23 -0700537 cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC));
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800538 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Nirav Shah89223f72016-03-01 18:10:38 +0530539 "carrier state: %d", netif_carrier_ok(dev));
Sen, Devendra154b3c42017-02-13 20:44:15 +0530540 hdd_wlan_datastall_sap_event();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800541}
542
543/**
544 * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout
545 * @dev: pointer to net_device
546 *
547 * Return: none
548 */
549void hdd_softap_tx_timeout(struct net_device *dev)
550{
551 cds_ssr_protect(__func__);
552 __hdd_softap_tx_timeout(dev);
553 cds_ssr_unprotect(__func__);
554}
555
556/**
557 * @hdd_softap_init_tx_rx() - Initialize Tx/RX module
558 * @pAdapter: pointer to adapter context
559 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530560 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
561 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530563QDF_STATUS hdd_softap_init_tx_rx(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530565 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566
567 uint8_t STAId = 0;
568
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530569 qdf_mem_zero(&pAdapter->stats, sizeof(struct net_device_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570
571 spin_lock_init(&pAdapter->staInfo_lock);
572
573 for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530574 qdf_mem_zero(&pAdapter->aStaInfo[STAId],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 sizeof(hdd_station_info_t));
576 }
577
578 return status;
579}
580
581/**
582 * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module
583 * @pAdapter: pointer to adapter context
584 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530585 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
586 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800587 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530588QDF_STATUS hdd_softap_deinit_tx_rx(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589{
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800590 if (pAdapter == NULL) {
591 hdd_err("Called with pAdapter = NULL.");
592 return QDF_STATUS_E_FAILURE;
593 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800595 pAdapter->txrx_vdev = NULL;
596 pAdapter->tx_fn = NULL;
597 hdd_info("Deregistering TX function hook !");
598 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599}
600
601/**
602 * hdd_softap_init_tx_rx_sta() - Initialize tx/rx for a softap station
603 * @pAdapter: pointer to adapter context
604 * @STAId: Station ID to initialize
605 * @pmacAddrSTA: pointer to the MAC address of the station
606 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530607 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
608 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530610QDF_STATUS hdd_softap_init_tx_rx_sta(hdd_adapter_t *pAdapter, uint8_t STAId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530611 struct qdf_mac_addr *pmacAddrSTA)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612{
613 spin_lock_bh(&pAdapter->staInfo_lock);
614 if (pAdapter->aStaInfo[STAId].isUsed) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 spin_unlock_bh(&pAdapter->staInfo_lock);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800616 hdd_err("Reinit of in use station %d", STAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530617 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 }
619
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530620 qdf_mem_zero(&pAdapter->aStaInfo[STAId], sizeof(hdd_station_info_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621
622 pAdapter->aStaInfo[STAId].isUsed = true;
623 pAdapter->aStaInfo[STAId].isDeauthInProgress = false;
Anurag Chouhanc5548422016-02-24 18:33:27 +0530624 qdf_copy_macaddr(&pAdapter->aStaInfo[STAId].macAddrSTA, pmacAddrSTA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625
626 spin_unlock_bh(&pAdapter->staInfo_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530627 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800628}
629
630/**
631 * hdd_softap_deinit_tx_rx_sta() - Deinitialize tx/rx for a softap station
632 * @pAdapter: pointer to adapter context
633 * @STAId: Station ID to deinitialize
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 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530638QDF_STATUS hdd_softap_deinit_tx_rx_sta(hdd_adapter_t *pAdapter, uint8_t STAId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530640 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641 hdd_hostapd_state_t *pHostapdState;
642
643 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
644
645 spin_lock_bh(&pAdapter->staInfo_lock);
646
647 if (false == pAdapter->aStaInfo[STAId].isUsed) {
648 spin_unlock_bh(&pAdapter->staInfo_lock);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800649 hdd_err("Deinit station not inited %d", STAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530650 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651 }
652
653 pAdapter->aStaInfo[STAId].isUsed = false;
654 pAdapter->aStaInfo[STAId].isDeauthInProgress = false;
655
656 spin_unlock_bh(&pAdapter->staInfo_lock);
657 return status;
658}
659
660/**
661 * hdd_softap_rx_packet_cbk() - Receive packet handler
Dhanashri Atre182b0272016-02-17 15:35:07 -0800662 * @context: pointer to HDD context
Nirav Shahcbc6d722016-03-01 16:24:53 +0530663 * @rxBuf: pointer to rx qdf_nbuf
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664 *
665 * Receive callback registered with TL. TL will call this to notify
666 * the HDD when one or more packets were received for a registered
667 * STA.
668 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530669 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
670 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800672QDF_STATUS hdd_softap_rx_packet_cbk(void *context, qdf_nbuf_t rxBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673{
674 hdd_adapter_t *pAdapter = NULL;
675 int rxstat;
676 unsigned int cpu_index;
677 struct sk_buff *skb = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800678 struct sk_buff *next = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 hdd_context_t *pHddCtx = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680
681 /* Sanity check on inputs */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800682 if (unlikely((NULL == context) || (NULL == rxBuf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530683 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 "%s: Null params being passed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530685 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 }
687
Dhanashri Atre182b0272016-02-17 15:35:07 -0800688 pAdapter = (hdd_adapter_t *)context;
689 if (unlikely(WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800690 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre182b0272016-02-17 15:35:07 -0800691 "Magic cookie(%x) for adapter sanity verification is invalid",
692 pAdapter->magic);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530693 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800694 }
695
Dhanashri Atre182b0272016-02-17 15:35:07 -0800696 pHddCtx = pAdapter->pHddCtx;
697 if (unlikely(NULL == pHddCtx)) {
698 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
699 "%s: HDD context is Null", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530700 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701 }
702
703 /* walk the chain until all are processed */
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800704 next = (struct sk_buff *)rxBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800706 while (next) {
707 skb = next;
708 next = skb->next;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800709 skb->next = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800710
711#ifdef QCA_WIFI_NAPIER_EMULATION /* Debug code, remove later */
712 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
713 "%s: skb %p skb->len %d\n", __func__, skb, skb->len);
714#endif
715
Dhanashri Atre63d98022017-01-24 18:22:09 -0800716 hdd_softap_dump_sk_buff(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717
Dhanashri Atre63d98022017-01-24 18:22:09 -0800718 skb->dev = pAdapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719
Dhanashri Atre63d98022017-01-24 18:22:09 -0800720 if (unlikely(skb->dev == NULL)) {
721
722 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
723 "%s: ERROR!!Invalid netdevice", __func__);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800724 continue;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800725 }
726 cpu_index = wlan_hdd_get_cpu();
727 ++pAdapter->hdd_stats.hddTxRxStats.rxPackets[cpu_index];
728 ++pAdapter->stats.rx_packets;
729 pAdapter->stats.rx_bytes += skb->len;
730
731 hdd_event_eapol_log(skb, QDF_RX);
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530732 DPTRACE(qdf_dp_trace(skb,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800733 QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530734 qdf_nbuf_data_addr(skb),
735 sizeof(qdf_nbuf_data(skb)), QDF_RX));
736 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
737 (uint8_t *)skb->data, qdf_nbuf_len(skb), QDF_RX));
738 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
739 DPTRACE(qdf_dp_trace(skb,
740 QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
741 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
742 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE),
743 QDF_RX));
Dhanashri Atre63d98022017-01-24 18:22:09 -0800744
745 skb->protocol = eth_type_trans(skb, skb->dev);
746
747 /* hold configurable wakelock for unicast traffic */
748 if (pHddCtx->config->rx_wakelock_timeout &&
749 skb->pkt_type != PACKET_BROADCAST &&
750 skb->pkt_type != PACKET_MULTICAST) {
751 cds_host_diag_log_work(&pHddCtx->rx_wake_lock,
752 pHddCtx->config->rx_wakelock_timeout,
753 WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
754 qdf_wake_lock_timeout_acquire(&pHddCtx->rx_wake_lock,
755 pHddCtx->config->
756 rx_wakelock_timeout);
757 }
758
759 /* Remove SKB from internal tracking table before submitting
760 * it to stack
761 */
762 qdf_net_buf_debug_release_skb(rxBuf);
763 if (hdd_napi_enabled(HDD_NAPI_ANY) &&
764 !pHddCtx->enableRxThread)
765 rxstat = netif_receive_skb(skb);
766 else
767 rxstat = netif_rx_ni(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700768 if (NET_RX_SUCCESS == rxstat)
Dhanashri Atre63d98022017-01-24 18:22:09 -0800769 ++pAdapter->hdd_stats.hddTxRxStats.rxDelivered[cpu_index];
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700770 else
Dhanashri Atre63d98022017-01-24 18:22:09 -0800771 ++pAdapter->hdd_stats.hddTxRxStats.rxRefused[cpu_index];
Dhanashri Atre63d98022017-01-24 18:22:09 -0800772
773 pAdapter->dev->last_rx = jiffies;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530776 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777}
778
779/**
780 * hdd_softap_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
781 * @pAdapter: pointer to adapter context
782 * @staId: Station ID to deregister
783 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530784 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530786QDF_STATUS hdd_softap_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530788 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789 hdd_context_t *pHddCtx;
Abhishek Singh07c627e2017-03-20 17:56:34 +0530790 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791
792 if (NULL == pAdapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800793 hdd_err("NULL adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530794 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795 }
796
797 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800798 hdd_err("Invalid adapter magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530799 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800 }
801
802 pHddCtx = (hdd_context_t *) (pAdapter->pHddCtx);
803 /* Clear station in TL and then update HDD data
804 * structures. This helps to block RX frames from other
805 * station to this station.
806 */
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800807 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800808 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
809 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530810 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800811 hdd_err("cdp_clear_peer failed for staID %d, Status=%d [0x%08X]",
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800812 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 }
814
Dustin Brown7d043f62017-03-27 12:07:36 -0700815 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
816 pAdapter->aStaInfo[staId].
817 macAddrSTA.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +0530818 if (ret)
819 hdd_err("Peer obj %pM delete fails",
820 pAdapter->aStaInfo[staId].macAddrSTA.bytes);
821
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 if (pAdapter->aStaInfo[staId].isUsed) {
823 spin_lock_bh(&pAdapter->staInfo_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530824 qdf_mem_zero(&pAdapter->aStaInfo[staId],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 sizeof(hdd_station_info_t));
826 spin_unlock_bh(&pAdapter->staInfo_lock);
827 }
Abhishek Singh07c627e2017-03-20 17:56:34 +0530828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 pHddCtx->sta_to_adapter[staId] = NULL;
830
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530831 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832}
833
834/**
835 * hdd_softap_register_sta() - Register a SoftAP STA
836 * @pAdapter: pointer to adapter context
837 * @fAuthRequired: is additional authentication required?
838 * @fPrivacyBit: should 802.11 privacy bit be set?
839 * @staId: station ID assigned to this station
840 * @ucastSig: unicast security signature
841 * @bcastSig: broadcast security signature
842 * @pPeerMacAddress: station MAC address
843 * @fWmmEnabled: is WMM enabled for this STA?
844 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530845 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800846 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530847QDF_STATUS hdd_softap_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 bool fAuthRequired,
849 bool fPrivacyBit,
850 uint8_t staId,
851 uint8_t ucastSig,
852 uint8_t bcastSig,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530853 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 bool fWmmEnabled)
855{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530856 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 struct ol_txrx_desc_type staDesc = { 0 };
858 hdd_context_t *pHddCtx = pAdapter->pHddCtx;
Dhanashri Atre182b0272016-02-17 15:35:07 -0800859 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -0700860 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
861 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800863 hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u",
864 staId, fAuthRequired, fPrivacyBit, fWmmEnabled);
865
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866 /*
867 * Clean up old entry if it is not cleaned up properly
868 */
869 if (pAdapter->aStaInfo[staId].isUsed) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800870 hdd_info("clean up old entry for STA %d", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 hdd_softap_deregister_sta(pAdapter, staId);
872 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800874 /* Get the Station ID from the one saved during the assocation. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 staDesc.sta_id = staId;
876
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800877 /* Save the pAdapter Pointer for this staId */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 pHddCtx->sta_to_adapter[staId] = pAdapter;
879
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530880 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 hdd_softap_init_tx_rx_sta(pAdapter, staId,
882 pPeerMacAddress);
883
884 staDesc.is_qos_enabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885
Dhanashri Atre182b0272016-02-17 15:35:07 -0800886 /* Register the vdev transmit and receive functions */
887 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
888 txrx_ops.rx.rx = hdd_softap_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -0700889 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800890 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
891 (struct cdp_pdev *)pdev, pAdapter->sessionId),
892 pAdapter, &txrx_ops);
893 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
894 (struct cdp_pdev *)pdev,
Leo Changfdb45c32016-10-28 11:09:23 -0700895 pAdapter->sessionId);
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800896 pAdapter->tx_fn = txrx_ops.tx.tx;
Dhanashri Atre182b0272016-02-17 15:35:07 -0800897
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800898 qdf_status = cdp_peer_register(soc,
899 (struct cdp_pdev *)pdev, &staDesc);
Dhanashri Atre50141c52016-04-07 13:15:29 -0700900 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800901 hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]",
902 qdf_status, qdf_status);
Dhanashri Atre50141c52016-04-07 13:15:29 -0700903 return qdf_status;
904 }
905
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 /* if ( WPA ), tell TL to go to 'connected' and after keys come to the
907 * driver then go to 'authenticated'. For all other authentication
908 * types (those that do not require upper layer authentication) we can
909 * put TL directly into 'authenticated' state
910 */
911
912 pAdapter->aStaInfo[staId].ucSTAId = staId;
913 pAdapter->aStaInfo[staId].isQosEnabled = fWmmEnabled;
914
915 if (!fAuthRequired) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800916 hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time",
917 pAdapter->aStaInfo[staId].ucSTAId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918
919 /* Connections that do not need Upper layer auth,
920 * transition TL directly to 'Authenticated' state.
921 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530922 qdf_status = hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800923 OL_TXRX_PEER_STATE_AUTH, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800925 pAdapter->aStaInfo[staId].tlSTAState = OL_TXRX_PEER_STATE_AUTH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 pAdapter->sessionCtx.ap.uIsAuthenticated = true;
927 } else {
928
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800929 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
930 pAdapter->aStaInfo[staId].ucSTAId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530932 qdf_status = hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800933 OL_TXRX_PEER_STATE_CONN, false);
934 pAdapter->aStaInfo[staId].tlSTAState = OL_TXRX_PEER_STATE_CONN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935
936 pAdapter->sessionCtx.ap.uIsAuthenticated = false;
937
938 }
939
940 /* Enable Tx queue */
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800941 hdd_notice("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 wlan_hdd_netif_queue_control(pAdapter,
943 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
944 WLAN_CONTROL_PATH);
945
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530946 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947}
948
949/**
950 * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA
951 * @pAdapter: pointer to adapter context
952 * @fPrivacyBit: should 802.11 privacy bit be set?
953 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530954 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530956QDF_STATUS hdd_softap_register_bc_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 bool fPrivacyBit)
958{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530959 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530961 struct qdf_mac_addr broadcastMacAddr =
962 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 hdd_ap_ctx_t *pHddApCtx;
964
965 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
966
967 pHddCtx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = pAdapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 pHddCtx->sta_to_adapter[pHddApCtx->uBCStaId] = pAdapter;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530969 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 hdd_softap_register_sta(pAdapter, false, fPrivacyBit,
971 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->
972 uBCStaId, 0, 1, &broadcastMacAddr, 0);
973
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530974 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975}
976
977/**
978 * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA
979 * @pAdapter: pointer to adapter context
980 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530981 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530983QDF_STATUS hdd_softap_deregister_bc_sta(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984{
985 return hdd_softap_deregister_sta(pAdapter,
986 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->
987 uBCStaId);
988}
989
990/**
991 * hdd_softap_stop_bss() - Stop the BSS
992 * @pAdapter: pointer to adapter context
993 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530994 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530996QDF_STATUS hdd_softap_stop_bss(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530998 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 uint8_t staId = 0;
1000 hdd_context_t *pHddCtx;
Srinivas Girigowdae806a822017-03-25 11:25:30 -07001001
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1003
1004 /* bss deregister is not allowed during wlan driver loading or
1005 * unloading
1006 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001007 if (cds_is_load_or_unload_in_progress()) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001008 hdd_err("Loading_unloading in Progress, state: 0x%x. Ignore!!!",
1009 cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301010 return QDF_STATUS_E_PERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011 }
1012
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301013 qdf_status = hdd_softap_deregister_bc_sta(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301015 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001016 hdd_err("Failed to deregister BC sta Id %d",
1017 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->uBCStaId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018 }
1019
1020 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
1021 /* This excludes BC sta as it is already deregistered */
1022 if (pAdapter->aStaInfo[staId].isUsed) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301023 qdf_status = hdd_softap_deregister_sta(pAdapter, staId);
1024 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001025 hdd_err("Failed to deregister sta Id %d",
1026 staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 }
1028 }
1029 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301030 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031}
1032
1033/**
1034 * hdd_softap_change_sta_state() - Change the state of a SoftAP station
1035 * @pAdapter: pointer to adapter context
1036 * @pDestMacAddress: MAC address of the station
1037 * @state: new state of the station
1038 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301039 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301041QDF_STATUS hdd_softap_change_sta_state(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301042 struct qdf_mac_addr *pDestMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 enum ol_txrx_peer_state state)
1044{
1045 uint8_t ucSTAId = WLAN_MAX_STA_COUNT;
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001046 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001048 ENTER_DEV(pAdapter->dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001050 qdf_status = hdd_softap_get_sta_id(pAdapter, pDestMacAddress, &ucSTAId);
1051 if (QDF_STATUS_SUCCESS != qdf_status) {
1052 hdd_err("Failed to find right station");
1053 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 }
1055
1056 if (false ==
Anurag Chouhanc5548422016-02-24 18:33:27 +05301057 qdf_is_macaddr_equal(&pAdapter->aStaInfo[ucSTAId].macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 pDestMacAddress)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001059 hdd_err("Station %u MAC address not matching", ucSTAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301060 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061 }
1062
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301063 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 hdd_change_peer_state(pAdapter, ucSTAId, state, false);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001065 hdd_info("Station %u changed to state %d", ucSTAId, state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301067 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 pAdapter->aStaInfo[ucSTAId].tlSTAState =
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001069 OL_TXRX_PEER_STATE_AUTH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 }
1071
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001072 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301073 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074}
1075
1076/*
1077 * hdd_softap_get_sta_id() - Find station ID from MAC address
1078 * @pAdapter: pointer to adapter context
1079 * @pDestMacAddress: MAC address of the destination
1080 * @staId: Station ID associated with the MAC address
1081 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301082 * Return: QDF_STATUS_SUCCESS if a match was found, in which case
1083 * staId is populated, QDF_STATUS_E_FAILURE if a match is
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 * not found
1085 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301086QDF_STATUS hdd_softap_get_sta_id(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301087 struct qdf_mac_addr *pMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 uint8_t *staId)
1089{
1090 uint8_t i;
1091
1092 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301093 if (!qdf_mem_cmp
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 (&pAdapter->aStaInfo[i].macAddrSTA, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301095 QDF_MAC_ADDR_SIZE) && pAdapter->aStaInfo[i].isUsed) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 *staId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301097 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001098 }
1099 }
1100
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301101 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102}