blob: 4dc92159ebe99a020424cfeabcb31d33741d2505 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Yun Parke4239802018-01-09 11:01:40 -08002 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -080019/* denote that this file does not allow legacy hddLog */
20#define HDD_DISALLOW_LEGACY_HDDLOG 1
21
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080022/* Include files */
23#include <linux/semaphore.h>
24#include <wlan_hdd_tx_rx.h>
25#include <wlan_hdd_softap_tx_rx.h>
26#include <linux/netdevice.h>
27#include <linux/skbuff.h>
28#include <linux/etherdevice.h>
Anurag Chouhan6d760662016-02-20 16:05:43 +053029#include <qdf_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080030#include <ani_global.h>
Anurag Chouhan6d760662016-02-20 16:05:43 +053031#include <qdf_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080032#include <net/ieee80211_radiotap.h>
33#include <cds_sched.h>
34#include <wlan_hdd_napi.h>
Leo Changfdb45c32016-10-28 11:09:23 -070035#include <cdp_txrx_cmn.h>
Dhanashri Atreb08959a2016-03-01 17:28:03 -080036#include <cdp_txrx_peer_ops.h>
Manjunathappa Prakash779e4862016-09-12 17:00:11 -070037#include <cds_utils.h>
Leo Changfdb45c32016-10-28 11:09:23 -070038#include <cdp_txrx_flow_ctrl_v2.h>
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +053039#include <cdp_txrx_misc.h>
Abhishek Singh07c627e2017-03-20 17:56:34 +053040#include <wlan_hdd_object_manager.h>
Rachit Kankane2487f8f2017-04-19 14:30:19 +053041#include "wlan_p2p_ucfg_api.h"
Mukul Sharmaecf8e092017-12-19 22:36:31 +053042#include <wlan_hdd_regulatory.h>
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +053043#include "wlan_ipa_ucfg_api.h"
Yun Parkc3e35562018-03-08 12:05:52 -080044#include <wma_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045
46/* Preprocessor definitions and constants */
47#undef QCA_HDD_SAP_DUMP_SK_BUFF
48
49/* Type declarations */
50
51/* Function definitions and documenation */
52#ifdef QCA_HDD_SAP_DUMP_SK_BUFF
53/**
54 * hdd_softap_dump_sk_buff() - Dump an skb
55 * @skb: skb to dump
56 *
57 * Return: None
58 */
59static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
60{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053061 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Jeff Johnson36e74c42017-09-18 08:15:42 -070062 "%s: head = %pK ", __func__, skb->head);
Srinivas Girigowdae806a822017-03-25 11:25:30 -070063 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Jeff Johnson36e74c42017-09-18 08:15:42 -070064 "%s: tail = %pK ", __func__, skb->tail);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053065 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Jeff Johnson36e74c42017-09-18 08:15:42 -070066 "%s: end = %pK ", __func__, skb->end);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053067 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068 "%s: len = %d ", __func__, skb->len);
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: data_len = %d ", __func__, skb->data_len);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053071 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072 "%s: mac_len = %d", __func__, skb->mac_len);
73
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053074 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ", skb->data[0],
76 skb->data[1], skb->data[2], skb->data[3], skb->data[4],
77 skb->data[5], skb->data[6], skb->data[7]);
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 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[8],
80 skb->data[9], skb->data[10], skb->data[11], skb->data[12],
81 skb->data[13], skb->data[14], skb->data[15]);
82}
83#else
84static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
85{
86}
87#endif
88
89#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context)
91{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -070092 struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093
Jeff Johnsond31ab6a2017-10-02 13:23:51 -070094 if (!adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -080095 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096 return;
97 }
98
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -070099 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700100 wlan_hdd_netif_queue_control(adapter, WLAN_WAKE_ALL_NETIF_QUEUE,
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800101 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102}
103
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530104#if defined(CONFIG_PER_VDEV_TX_DESC_POOL)
105
106/**
107 * hdd_softap_tx_resume_false() - Resume OS TX Q false leads to queue disabling
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700108 * @adapter: pointer to hdd adapter
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530109 * @tx_resume: TX Q resume trigger
110 *
111 *
112 * Return: None
113 */
114static void
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700115hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume)
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530116{
117 if (true == tx_resume)
118 return;
119
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700120 hdd_debug("Disabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700121 wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE,
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530122 WLAN_DATA_FLOW_CONTROL);
123
124 if (QDF_TIMER_STATE_STOPPED ==
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700125 qdf_mc_timer_get_current_state(&adapter->
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530126 tx_flow_control_timer)) {
127 QDF_STATUS status;
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700128
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700129 status = qdf_mc_timer_start(&adapter->tx_flow_control_timer,
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530130 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
131
132 if (!QDF_IS_STATUS_SUCCESS(status))
133 hdd_err("Failed to start tx_flow_control_timer");
134 else
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700135 adapter->hdd_stats.tx_rx_stats.txflow_timer_cnt++;
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530136 }
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530137}
138#else
139
140static inline void
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700141hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume)
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530142{
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530143}
144#endif
145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume)
147{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700148 struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700150 if (!adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800151 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 return;
153 }
154
155 /* Resume TX */
156 if (true == tx_resume) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530157 if (QDF_TIMER_STATE_STOPPED !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700158 qdf_mc_timer_get_current_state(&adapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 tx_flow_control_timer)) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700160 qdf_mc_timer_stop(&adapter->tx_flow_control_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800161 }
162
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700163 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700164 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165 WLAN_WAKE_ALL_NETIF_QUEUE,
166 WLAN_DATA_FLOW_CONTROL);
167 }
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700168 hdd_softap_tx_resume_false(adapter, tx_resume);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169}
gbianec670c592016-11-24 11:21:30 +0800170
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700171static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter,
gbianec670c592016-11-24 11:21:30 +0800172 struct sk_buff *skb)
173{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700174 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800175 int need_orphan = 0;
176
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700177 if (adapter->tx_flow_low_watermark > 0) {
tfyubdf453e2017-09-27 13:34:30 +0800178#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
179 /*
180 * The TCP TX throttling logic is changed a little after
181 * 3.19-rc1 kernel, the TCP sending limit will be smaller,
182 * which will throttle the TCP packets to the host driver.
183 * The TCP UP LINK throughput will drop heavily. In order to
184 * fix this issue, need to orphan the socket buffer asap, which
185 * will call skb's destructor to notify the TCP stack that the
186 * SKB buffer is unowned. And then the TCP stack will pump more
187 * packets to host driver.
188 *
189 * The TX packets might be dropped for UDP case in the iperf
190 * testing. So need to be protected by follow control.
191 */
192 need_orphan = 1;
193#else
194 if (hdd_ctx->config->tx_orphan_enable)
195 need_orphan = 1;
196#endif
tfyu5f01db22017-10-11 13:51:04 +0800197 } else if (hdd_ctx->config->tx_orphan_enable) {
198 if (qdf_nbuf_is_ipv4_tcp_pkt(skb) ||
Tiger Yu438c6482017-10-13 11:07:00 +0800199 qdf_nbuf_is_ipv6_tcp_pkt(skb))
tfyu5f01db22017-10-11 13:51:04 +0800200 need_orphan = 1;
tfyubdf453e2017-09-27 13:34:30 +0800201 }
202
tfyu5f01db22017-10-11 13:51:04 +0800203 if (need_orphan) {
gbianec670c592016-11-24 11:21:30 +0800204 skb_orphan(skb);
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700205 ++adapter->hdd_stats.tx_rx_stats.tx_orphaned;
Tiger Yu438c6482017-10-13 11:07:00 +0800206 } else
gbianec670c592016-11-24 11:21:30 +0800207 skb = skb_unshare(skb, GFP_ATOMIC);
gbianec670c592016-11-24 11:21:30 +0800208
209 return skb;
210}
211
212#else
Mohit Khannad0b63f52017-02-18 18:05:52 -0800213/**
214 * hdd_skb_orphan() - skb_unshare a cloned packed else skb_orphan
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700215 * @adapter: pointer to HDD adapter
Mohit Khannad0b63f52017-02-18 18:05:52 -0800216 * @skb: pointer to skb data packet
217 *
218 * Return: pointer to skb structure
219 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700220static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter,
Mohit Khannad0b63f52017-02-18 18:05:52 -0800221 struct sk_buff *skb) {
gbianec670c592016-11-24 11:21:30 +0800222
Mohit Khannad0b63f52017-02-18 18:05:52 -0800223 struct sk_buff *nskb;
tfyubdf453e2017-09-27 13:34:30 +0800224#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700225 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800226#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800227
Mohit Khanna87493732017-08-27 23:26:44 -0700228 hdd_skb_fill_gso_size(adapter->dev, skb);
229
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700230 nskb = skb_unshare(skb, GFP_ATOMIC);
tfyubdf453e2017-09-27 13:34:30 +0800231#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700232 if (unlikely(hdd_ctx->config->tx_orphan_enable) && (nskb == skb)) {
Mohit Khannad0b63f52017-02-18 18:05:52 -0800233 /*
234 * For UDP packets we want to orphan the packet to allow the app
235 * to send more packets. The flow would ultimately be controlled
236 * by the limited number of tx descriptors for the vdev.
237 */
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700238 ++adapter->hdd_stats.tx_rx_stats.tx_orphaned;
Mohit Khannad0b63f52017-02-18 18:05:52 -0800239 skb_orphan(skb);
240 }
tfyubdf453e2017-09-27 13:34:30 +0800241#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800242 return nskb;
gbianec670c592016-11-24 11:21:30 +0800243}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
245
246/**
Yun Parkc3e35562018-03-08 12:05:52 -0800247 * hdd_post_dhcp_ind() - Send DHCP START/STOP indication to FW
248 * @adapter: pointer to hdd adapter
249 * @sta_id: peer station ID
250 * @type: WMA message type
251 *
252 * Return: error number
253 */
254int hdd_post_dhcp_ind(struct hdd_adapter *adapter,
255 uint8_t sta_id, uint16_t type)
256{
257 tAniDHCPInd pmsg;
258 QDF_STATUS status = QDF_STATUS_SUCCESS;
259
260 hdd_debug("Post DHCP indication,sta_id=%d, type=%d", sta_id, type);
261
262 if (!adapter) {
263 hdd_err("NULL adapter");
264 return -EINVAL;
265 }
266
267 pmsg.msgType = type;
268 pmsg.msgLen = (uint16_t) sizeof(tAniDHCPInd);
269 pmsg.device_mode = adapter->device_mode;
270 qdf_mem_copy(pmsg.adapterMacAddr.bytes,
271 adapter->mac_addr.bytes,
272 QDF_MAC_ADDR_SIZE);
273 qdf_mem_copy(pmsg.peerMacAddr.bytes,
274 adapter->sta_info[sta_id].sta_mac.bytes,
275 QDF_MAC_ADDR_SIZE);
276
277 status = wma_process_dhcp_ind(cds_get_context(QDF_MODULE_ID_WMA),
278 &pmsg);
279 if (!QDF_IS_STATUS_SUCCESS(status)) {
280 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
281 "%s: Post DHCP Ind MSG fail", __func__);
282 return -EFAULT;
283 }
284
285 return 0;
286}
287
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700288/**
289 * hdd_softap_notify_dhcp_ind() - Notify SAP for DHCP indication for tx desc
290 * @context: pointer to HDD context
291 * @netbuf: pointer to OS packet (sk_buff)
292 *
293 * Return: None
294 */
295static void hdd_softap_notify_dhcp_ind(void *context, struct sk_buff *netbuf)
Alok Kumar4696fb02018-06-06 00:10:18 +0530296{
297 struct hdd_ap_ctx *hdd_ap_ctx;
298 struct qdf_mac_addr *dest_mac_addr;
299 uint8_t sta_id;
300 struct hdd_adapter *adapter = context;
301
Dustin Browna8700cc2018-08-07 12:04:47 -0700302 if (hdd_validate_adapter(adapter))
Alok Kumar4696fb02018-06-06 00:10:18 +0530303 return;
Alok Kumar4696fb02018-06-06 00:10:18 +0530304
305 hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
306 if (!hdd_ap_ctx) {
307 hdd_err("HDD sap context is NULL");
308 return;
309 }
310
311 dest_mac_addr = (struct qdf_mac_addr *)netbuf->data;
312
313 if (QDF_NBUF_CB_GET_IS_BCAST(netbuf) ||
314 QDF_NBUF_CB_GET_IS_MCAST(netbuf)) {
315 /* The BC/MC station ID is assigned during BSS
316 * starting phase. SAP will return the station ID
317 * used for BC/MC traffic.
318 */
319 sta_id = hdd_ap_ctx->broadcast_sta_id;
320 } else {
321 if (QDF_STATUS_SUCCESS !=
322 hdd_softap_get_sta_id(adapter,
323 dest_mac_addr, &sta_id)) {
324 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
325 QDF_TRACE_LEVEL_INFO_HIGH,
326 "%s: Failed to find right station", __func__);
327 return;
328 }
329 }
330 hdd_post_dhcp_ind(adapter, sta_id, WMA_DHCP_STOP_IND);
331}
332
Yun Parkc3e35562018-03-08 12:05:52 -0800333/**
334 * hdd_inspect_dhcp_packet() - Inspect DHCP packet
335 * @adapter: pointer to hdd adapter
336 * @sta_id: peer station ID
337 * @skb: pointer to OS packet (sk_buff)
338 * @dir: direction
339 *
340 * Inspect the Tx/Rx frame, and send DHCP START/STOP notification to the FW
341 * through WMI message, during DHCP based IP address acquisition phase.
342 *
343 * - Send DHCP_START notification to FW when SAP gets DHCP Discovery
344 * - Send DHCP_STOP notification to FW when SAP sends DHCP ACK/NAK
345 *
346 * DHCP subtypes are determined by a status octet in the DHCP Message type
347 * option (option code 53 (0x35)).
348 *
349 * Each peer will be in one of 4 DHCP phases, starts from QDF_DHCP_PHASE_ACK,
350 * and transitioned per DHCP message type as it arrives.
351 *
352 * - QDF_DHCP_PHASE_DISCOVER: upon receiving DHCP_DISCOVER message in ACK phase
353 * - QDF_DHCP_PHASE_OFFER: upon receiving DHCP_OFFER message in DISCOVER phase
354 * - QDF_DHCP_PHASE_REQUEST: upon receiving DHCP_REQUEST message in OFFER phase
355 * or ACK phase (Renewal process)
356 * - QDF_DHCP_PHASE_ACK : upon receiving DHCP_ACK/NAK message in REQUEST phase
357 * or DHCP_DELINE message in OFFER phase
358 *
359 * Return: error number
360 */
361int hdd_inspect_dhcp_packet(struct hdd_adapter *adapter,
Alok Kumar4696fb02018-06-06 00:10:18 +0530362 uint8_t sta_id,
363 struct sk_buff *skb,
364 enum qdf_proto_dir dir)
Yun Parkc3e35562018-03-08 12:05:52 -0800365{
366 enum qdf_proto_subtype subtype = QDF_PROTO_INVALID;
367 struct hdd_station_info *hdd_sta_info;
368 int errno = 0;
369
Alok Kumar4696fb02018-06-06 00:10:18 +0530370 hdd_debug("sta_id=%d, dir=%d", sta_id, dir);
371
Alok Kumarcee3cf22018-07-15 18:22:36 +0530372 if (sta_id >= WLAN_MAX_STA_COUNT) {
373 hdd_err("Invalid sta id: %d", sta_id);
374 return -EINVAL;
375 }
376
Alok Kumar4696fb02018-06-06 00:10:18 +0530377 if (((adapter->device_mode == QDF_SAP_MODE) ||
378 (adapter->device_mode == QDF_P2P_GO_MODE)) &&
Yun Parkc3e35562018-03-08 12:05:52 -0800379 ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_DHCP ==
380 QDF_NBUF_CB_GET_PACKET_TYPE(skb)) ||
381 (dir == QDF_RX && qdf_nbuf_is_ipv4_dhcp_pkt(skb) == true))) {
382
383 subtype = qdf_nbuf_get_dhcp_subtype(skb);
384 hdd_sta_info = &adapter->sta_info[sta_id];
385
386 hdd_debug("ENTER: type=%d, phase=%d, nego_status=%d",
387 subtype,
388 hdd_sta_info->dhcp_phase,
389 hdd_sta_info->dhcp_nego_status);
390
391 switch (subtype) {
392 case QDF_PROTO_DHCP_DISCOVER:
393 if (dir != QDF_RX)
394 break;
395 if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP)
396 errno = hdd_post_dhcp_ind(adapter, sta_id,
397 WMA_DHCP_START_IND);
398 hdd_sta_info->dhcp_phase = DHCP_PHASE_DISCOVER;
399 hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS;
400 break;
401 case QDF_PROTO_DHCP_OFFER:
402 hdd_sta_info->dhcp_phase = DHCP_PHASE_OFFER;
403 break;
404 case QDF_PROTO_DHCP_REQUEST:
405 if (dir != QDF_RX)
406 break;
407 if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP)
408 errno = hdd_post_dhcp_ind(adapter, sta_id,
409 WMA_DHCP_START_IND);
410 hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS;
411 case QDF_PROTO_DHCP_DECLINE:
412 if (dir == QDF_RX)
413 hdd_sta_info->dhcp_phase = DHCP_PHASE_REQUEST;
414 break;
415 case QDF_PROTO_DHCP_ACK:
416 case QDF_PROTO_DHCP_NACK:
417 hdd_sta_info->dhcp_phase = DHCP_PHASE_ACK;
Yun Park0ac12822018-04-02 11:18:04 -0700418 if (hdd_sta_info->dhcp_nego_status ==
Alok Kumar4696fb02018-06-06 00:10:18 +0530419 DHCP_NEGO_IN_PROGRESS) {
420 hdd_debug("Setting NOTIFY_COMP Flag");
421 QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_NOTIFY_COMP(skb)
422 = 1;
423 }
Yun Parkc3e35562018-03-08 12:05:52 -0800424 hdd_sta_info->dhcp_nego_status = DHCP_NEGO_STOP;
425 break;
426 default:
427 break;
428 }
429
430 hdd_debug("EXIT: phase=%d, nego_status=%d",
431 hdd_sta_info->dhcp_phase,
432 hdd_sta_info->dhcp_nego_status);
433 }
434
435 return errno;
436}
437
438/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530439 * __hdd_softap_hard_start_xmit() - Transmit a frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440 * @skb: pointer to OS packet (sk_buff)
441 * @dev: pointer to network device
442 *
443 * Function registered with the Linux OS for transmitting
444 * packets. This version of the function directly passes
445 * the packet to Transport Layer.
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530446 * In case of any packet drop or error, log the error with
447 * INFO HIGH/LOW/MEDIUM to avoid excessive logging in kmsg.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 *
449 * Return: Always returns NETDEV_TX_OK
450 */
Srinivas Girigowda49b48b22018-04-05 09:23:28 -0700451static netdev_tx_t __hdd_softap_hard_start_xmit(struct sk_buff *skb,
452 struct net_device *dev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453{
454 sme_ac_enum_type ac = SME_AC_BE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700455 struct hdd_adapter *adapter = (struct hdd_adapter *) netdev_priv(dev);
Jeff Johnson9bf24972017-10-04 09:26:58 -0700456 struct hdd_ap_ctx *ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Alok Kumar4696fb02018-06-06 00:10:18 +0530457 struct qdf_mac_addr *dest_mac_addr;
458 uint8_t sta_id;
Will Huang496b36c2017-07-11 16:38:50 +0800459 uint32_t num_seg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700461 ++adapter->hdd_stats.tx_rx_stats.tx_called;
462 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 /* Prevent this function from being called during SSR since TL
465 * context may not be reinitialized at this time which may
466 * lead to a crash.
467 */
Will Huang20de9432018-02-06 17:01:03 +0800468 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state() ||
469 cds_is_load_or_unload_in_progress()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530470 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Will Huang20de9432018-02-06 17:01:03 +0800471 "%s: Recovery/(Un)load in Progress. Ignore!!!",
472 __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800473 goto drop_pkt;
474 }
475
476 /*
477 * If the device is operating on a DFS Channel
478 * then check if SAP is in CAC WAIT state and
479 * drop the packets. In CAC WAIT state device
480 * is expected not to transmit any frames.
481 * SAP starts Tx only after the BSS START is
482 * done.
483 */
Jeff Johnson9bf24972017-10-04 09:26:58 -0700484 if (ap_ctx->dfs_cac_block_tx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800487 /*
Jeff Johnson4fca3b52017-01-12 08:44:18 -0800488 * If a transmit function is not registered, drop packet
489 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700490 if (!adapter->tx_fn) {
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800491 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
492 "%s: TX function not registered by the data path",
493 __func__);
494 goto drop_pkt;
495 }
496
Nirav Shah5e74bb82016-07-20 16:01:27 +0530497 wlan_hdd_classify_pkt(skb);
498
Alok Kumar4696fb02018-06-06 00:10:18 +0530499 dest_mac_addr = (struct qdf_mac_addr *)skb->data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500
Nirav Shah5e74bb82016-07-20 16:01:27 +0530501 if (QDF_NBUF_CB_GET_IS_BCAST(skb) ||
502 QDF_NBUF_CB_GET_IS_MCAST(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 /* The BC/MC station ID is assigned during BSS
504 * starting phase. SAP will return the station ID
505 * used for BC/MC traffic.
506 */
Alok Kumar4696fb02018-06-06 00:10:18 +0530507 sta_id = ap_ctx->broadcast_sta_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530509 if (QDF_STATUS_SUCCESS !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700510 hdd_softap_get_sta_id(adapter,
Alok Kumar4696fb02018-06-06 00:10:18 +0530511 dest_mac_addr, &sta_id)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530512 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530513 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514 "%s: Failed to find right station", __func__);
515 goto drop_pkt;
516 }
517
Alok Kumar4696fb02018-06-06 00:10:18 +0530518 if (sta_id >= WLAN_MAX_STA_COUNT) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530519 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530520 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 "%s: Failed to find right station", __func__);
522 goto drop_pkt;
Alok Kumar4696fb02018-06-06 00:10:18 +0530523 } else if (!adapter->sta_info[sta_id].in_use) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530524 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530525 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800526 "%s: STA %d is unregistered", __func__,
Alok Kumar4696fb02018-06-06 00:10:18 +0530527 sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 goto drop_pkt;
Alok Kumar4696fb02018-06-06 00:10:18 +0530529 } else if (adapter->sta_info[sta_id].
Jeff Johnsone4f5d932017-10-21 13:21:15 -0700530 is_deauth_in_progress) {
Poddar, Siddartha5075462017-03-16 19:20:09 +0530531 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530532 QDF_TRACE_LEVEL_INFO_HIGH,
Poddar, Siddartha5075462017-03-16 19:20:09 +0530533 "%s: STA %d deauth in progress", __func__,
Alok Kumar4696fb02018-06-06 00:10:18 +0530534 sta_id);
Poddar, Siddartha5075462017-03-16 19:20:09 +0530535 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 }
537
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800538 if ((OL_TXRX_PEER_STATE_CONN !=
Alok Kumar4696fb02018-06-06 00:10:18 +0530539 adapter->sta_info[sta_id].peer_state)
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800540 && (OL_TXRX_PEER_STATE_AUTH !=
Alok Kumar4696fb02018-06-06 00:10:18 +0530541 adapter->sta_info[sta_id].peer_state)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530542 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530543 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544 "%s: Station not connected yet", __func__);
545 goto drop_pkt;
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800546 } else if (OL_TXRX_PEER_STATE_CONN ==
Alok Kumar4696fb02018-06-06 00:10:18 +0530547 adapter->sta_info[sta_id].peer_state) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800548 if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530549 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530550 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 "%s: NON-EAPOL packet in non-Authenticated state",
552 __func__);
553 goto drop_pkt;
554 }
555 }
556 }
557
Alok Kumar4696fb02018-06-06 00:10:18 +0530558 hdd_get_tx_resource(adapter, sta_id,
559 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560
561 /* Get TL AC corresponding to Qdisc queue index/AC. */
562 ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping];
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700563 ++adapter->hdd_stats.tx_rx_stats.tx_classified_ac[ac];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700565#if defined(IPA_OFFLOAD)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530566 if (!qdf_nbuf_ipa_owned_get(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800567#endif
gbianec670c592016-11-24 11:21:30 +0800568
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700569 skb = hdd_skb_orphan(adapter, skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 if (!skb)
Jeff Johnsonedeff232015-11-11 17:19:42 -0800571 goto drop_pkt_accounting;
gbianec670c592016-11-24 11:21:30 +0800572
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700573#if defined(IPA_OFFLOAD)
Yun Park01deb2c2017-06-14 15:21:44 -0700574 } else {
575 /*
576 * Clear the IPA ownership after check it to avoid ipa_free_skb
577 * is called when Tx completed for intra-BSS Tx packets
578 */
579 qdf_nbuf_ipa_owned_clear(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 }
581#endif
582
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530583 /*
584 * Add SKB to internal tracking table before further processing
585 * in WLAN driver.
586 */
587 qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__);
588
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700589 adapter->stats.tx_bytes += skb->len;
Alok Kumar4696fb02018-06-06 00:10:18 +0530590 adapter->sta_info[sta_id].tx_bytes += skb->len;
Mohit Khannab1dd1e82017-02-04 15:14:38 -0800591
Will Huang496b36c2017-07-11 16:38:50 +0800592 if (qdf_nbuf_is_tso(skb)) {
593 num_seg = qdf_nbuf_get_tso_num_seg(skb);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700594 adapter->stats.tx_packets += num_seg;
Alok Kumar4696fb02018-06-06 00:10:18 +0530595 adapter->sta_info[sta_id].tx_packets += num_seg;
Will Huang496b36c2017-07-11 16:38:50 +0800596 } else {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700597 ++adapter->stats.tx_packets;
Alok Kumar4696fb02018-06-06 00:10:18 +0530598 adapter->sta_info[sta_id].tx_packets++;
Will Huang496b36c2017-07-11 16:38:50 +0800599 }
Alok Kumar4696fb02018-06-06 00:10:18 +0530600 adapter->sta_info[sta_id].last_tx_rx_ts = qdf_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601
Alok Kumar4696fb02018-06-06 00:10:18 +0530602 QDF_NBUF_CB_TX_EXTRA_FRAG_FLAGS_NOTIFY_COMP(skb) = 0;
603
604 if (sta_id != ap_ctx->broadcast_sta_id)
605 hdd_inspect_dhcp_packet(adapter, sta_id, skb, QDF_TX);
Yun Parkc3e35562018-03-08 12:05:52 -0800606
Nirav Shah5e74bb82016-07-20 16:01:27 +0530607 hdd_event_eapol_log(skb, QDF_TX);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530608 QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
609 QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD);
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530610 qdf_dp_trace_set_track(skb, QDF_TX);
611 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700612 QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(skb),
613 sizeof(qdf_nbuf_data(skb)),
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530614 QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615
jinweic chen51046012018-04-11 16:02:22 +0800616 /* check whether need to linearize skb, like non-linear udp data */
617 if (hdd_skb_nontso_linearize(skb) != QDF_STATUS_SUCCESS) {
618 QDF_TRACE(QDF_MODULE_ID_HDD_DATA,
619 QDF_TRACE_LEVEL_INFO_HIGH,
620 "%s: skb %pK linearize failed. drop the pkt",
621 __func__, skb);
622 ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac];
623 goto drop_pkt_and_release_skb;
624 }
625
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700626 if (adapter->tx_fn(adapter->txrx_vdev,
Alok Kumar4696fb02018-06-06 00:10:18 +0530627 (qdf_nbuf_t)skb) != NULL) {
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530628 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800629 "%s: Failed to send packet to txrx for staid:%d",
Alok Kumar4696fb02018-06-06 00:10:18 +0530630 __func__, sta_id);
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700631 ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac];
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530632 goto drop_pkt_and_release_skb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 }
Dustin Browne0024fa2016-10-14 16:29:21 -0700634 netif_trans_update(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635
636 return NETDEV_TX_OK;
637
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530638drop_pkt_and_release_skb:
639 qdf_net_buf_debug_release_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640drop_pkt:
641
Mohit Khanna02281da2017-08-27 09:40:55 -0700642 qdf_dp_trace_data_pkt(skb, QDF_TRACE_DEFAULT_PDEV_ID,
643 QDF_DP_TRACE_DROP_PACKET_RECORD, 0,
644 QDF_TX);
Jeff Johnsonedeff232015-11-11 17:19:42 -0800645 kfree_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800646
Jeff Johnsonedeff232015-11-11 17:19:42 -0800647drop_pkt_accounting:
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700648 ++adapter->stats.tx_dropped;
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700649 ++adapter->hdd_stats.tx_rx_stats.tx_dropped;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650
651 return NETDEV_TX_OK;
652}
653
Srinivas Girigowda49b48b22018-04-05 09:23:28 -0700654netdev_tx_t hdd_softap_hard_start_xmit(struct sk_buff *skb,
655 struct net_device *dev)
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530656{
Srinivas Girigowda49b48b22018-04-05 09:23:28 -0700657 netdev_tx_t ret;
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530658
659 cds_ssr_protect(__func__);
660 ret = __hdd_softap_hard_start_xmit(skb, dev);
661 cds_ssr_unprotect(__func__);
662
663 return ret;
664}
665
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666static void __hdd_softap_tx_timeout(struct net_device *dev)
667{
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700668 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsonf7726872017-08-28 11:38:31 -0700669 struct hdd_context *hdd_ctx;
Nirav Shah89223f72016-03-01 18:10:38 +0530670 struct netdev_queue *txq;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530671 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Nirav Shah89223f72016-03-01 18:10:38 +0530672 int i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530674 DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700675 QDF_TRACE_DEFAULT_PDEV_ID,
676 NULL, 0, QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 /* Getting here implies we disabled the TX queues for too
678 * long. Queues are disabled either because of disassociation
679 * or low resource scenarios. In case of disassociation it is
680 * ok to ignore this. But if associated, we have do possible
681 * recovery here
682 */
683 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +0530684 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530685 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800686 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 return;
688 }
Nirav Shah89223f72016-03-01 18:10:38 +0530689
Dustin Browne0024fa2016-10-14 16:29:21 -0700690 TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA);
Nirav Shah89223f72016-03-01 18:10:38 +0530691
692 for (i = 0; i < NUM_TX_QUEUES; i++) {
693 txq = netdev_get_tx_queue(dev, i);
694 QDF_TRACE(QDF_MODULE_ID_HDD_DATA,
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800695 QDF_TRACE_LEVEL_DEBUG,
696 "Queue: %d status: %d txq->trans_start: %lu",
Nirav Shah89223f72016-03-01 18:10:38 +0530697 i, netif_tx_queue_stopped(txq), txq->trans_start);
698 }
699
Mohit Khannaca4173b2017-09-12 21:52:19 -0700700 wlan_hdd_display_netif_queue_history(hdd_ctx,
701 QDF_STATS_VERBOSITY_LEVEL_HIGH);
Leo Changfdb45c32016-10-28 11:09:23 -0700702 cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC));
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800703 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Nirav Shah89223f72016-03-01 18:10:38 +0530704 "carrier state: %d", netif_carrier_ok(dev));
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530705
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700706 ++adapter->hdd_stats.tx_rx_stats.tx_timeout_cnt;
707 ++adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530708
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700709 if (adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt >
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530710 HDD_TX_STALL_THRESHOLD) {
711 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
712 "Detected data stall due to continuous TX timeouts");
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700713 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Poddar, Siddarth37033032017-10-11 15:47:40 +0530714 if (hdd_ctx->config->enable_data_stall_det)
715 cdp_post_data_stall_event(soc,
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530716 DATA_STALL_LOG_INDICATOR_HOST_DRIVER,
717 DATA_STALL_LOG_HOST_SOFTAP_TX_TIMEOUT,
718 0xFF, 0xFF,
719 DATA_STALL_LOG_RECOVERY_TRIGGER_PDR);
720 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721}
722
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723void hdd_softap_tx_timeout(struct net_device *dev)
724{
725 cds_ssr_protect(__func__);
726 __hdd_softap_tx_timeout(dev);
727 cds_ssr_unprotect(__func__);
728}
729
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700730QDF_STATUS hdd_softap_init_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530732 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733
734 uint8_t STAId = 0;
735
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700736 qdf_mem_zero(&adapter->stats, sizeof(struct net_device_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700738 spin_lock_init(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739
740 for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) {
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700741 qdf_mem_zero(&adapter->sta_info[STAId],
Jeff Johnson82155922017-09-30 16:54:14 -0700742 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 }
744
745 return status;
746}
747
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700748QDF_STATUS hdd_softap_deinit_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749{
Dustin Brownb0b240a2018-07-30 14:16:30 -0700750 QDF_BUG(adapter);
751 if (!adapter)
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800752 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700754 adapter->txrx_vdev = NULL;
755 adapter->tx_fn = NULL;
Dustin Brownb0b240a2018-07-30 14:16:30 -0700756
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800757 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758}
759
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700760QDF_STATUS hdd_softap_init_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnson349d9a92017-10-21 15:38:03 -0700761 uint8_t sta_id,
762 struct qdf_mac_addr *sta_mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763{
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700764 spin_lock_bh(&adapter->sta_info_lock);
765 if (adapter->sta_info[sta_id].in_use) {
766 spin_unlock_bh(&adapter->sta_info_lock);
Jeff Johnson349d9a92017-10-21 15:38:03 -0700767 hdd_err("Reinit of in use station %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530768 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769 }
770
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700771 qdf_mem_zero(&adapter->sta_info[sta_id],
Jeff Johnson82155922017-09-30 16:54:14 -0700772 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700774 adapter->sta_info[sta_id].in_use = true;
775 adapter->sta_info[sta_id].is_deauth_in_progress = false;
776 qdf_copy_macaddr(&adapter->sta_info[sta_id].sta_mac, sta_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700778 spin_unlock_bh(&adapter->sta_info_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530779 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780}
781
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700782QDF_STATUS hdd_softap_deinit_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnsonb157c722017-10-21 15:46:42 -0700783 uint8_t sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530785 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson5c19ade2017-10-04 09:52:12 -0700786 struct hdd_hostapd_state *hostapd_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787
Jeff Johnson5c19ade2017-10-04 09:52:12 -0700788 hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700790 spin_lock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700792 if (false == adapter->sta_info[sta_id].in_use) {
793 spin_unlock_bh(&adapter->sta_info_lock);
Jeff Johnsonb157c722017-10-21 15:46:42 -0700794 hdd_err("Deinit station not inited %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530795 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 }
797
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700798 adapter->sta_info[sta_id].in_use = false;
799 adapter->sta_info[sta_id].is_deauth_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700801 spin_unlock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 return status;
803}
804
805/**
Alok Kumar4696fb02018-06-06 00:10:18 +0530806 * hdd_softap_notify_tx_compl_cbk() - callback to notify tx completion
807 * @skb: pointer to skb data
808 * @adapter: pointer to vdev apdapter
809 *
810 * Return: None
811 */
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700812static void hdd_softap_notify_tx_compl_cbk(struct sk_buff *skb,
813 void *context)
Alok Kumar4696fb02018-06-06 00:10:18 +0530814{
815 int errno;
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700816 struct hdd_adapter *adapter = context;
Alok Kumar4696fb02018-06-06 00:10:18 +0530817
Alok Kumar4696fb02018-06-06 00:10:18 +0530818 errno = hdd_validate_adapter(adapter);
819 if (errno)
820 return;
821
822 if (QDF_NBUF_CB_PACKET_TYPE_DHCP == QDF_NBUF_CB_GET_PACKET_TYPE(skb)) {
823 hdd_debug("sending DHCP indication");
824 hdd_softap_notify_dhcp_ind(context, skb);
825 }
826}
827
Mohit Khanna70322002018-05-15 19:21:32 -0700828QDF_STATUS hdd_softap_rx_packet_cbk(void *adapter_context, qdf_nbuf_t rx_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700830 struct hdd_adapter *adapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 int rxstat;
832 unsigned int cpu_index;
833 struct sk_buff *skb = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800834 struct sk_buff *next = NULL;
Jeff Johnson92402872017-09-03 09:25:37 -0700835 struct hdd_context *hdd_ctx = NULL;
Yun Parkc3e35562018-03-08 12:05:52 -0800836 struct qdf_mac_addr *src_mac;
Will Huang496b36c2017-07-11 16:38:50 +0800837 uint8_t staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838
839 /* Sanity check on inputs */
Mohit Khanna70322002018-05-15 19:21:32 -0700840 if (unlikely((!adapter_context) || (!rx_buf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530841 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 "%s: Null params being passed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530843 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 }
845
Mohit Khanna70322002018-05-15 19:21:32 -0700846 adapter = (struct hdd_adapter *)adapter_context;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700847 if (unlikely(WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800848 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre182b0272016-02-17 15:35:07 -0800849 "Magic cookie(%x) for adapter sanity verification is invalid",
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700850 adapter->magic);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530851 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 }
853
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700854 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson92402872017-09-03 09:25:37 -0700855 if (unlikely(NULL == hdd_ctx)) {
Dhanashri Atre182b0272016-02-17 15:35:07 -0800856 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
857 "%s: HDD context is Null", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530858 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 }
860
861 /* walk the chain until all are processed */
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700862 next = (struct sk_buff *)rx_buf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800864 while (next) {
865 skb = next;
866 next = skb->next;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800867 skb->next = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800868
Venkata Sharath Chandra Manchala27a42962018-06-08 17:51:44 -0700869/* Debug code, remove later */
870#if defined(QCA_WIFI_QCA6290) || defined(QCA_WIFI_QCA6390)
Yun Parke4239802018-01-09 11:01:40 -0800871 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson36e74c42017-09-18 08:15:42 -0700872 "%s: skb %pK skb->len %d\n", __func__, skb, skb->len);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800873#endif
874
Dhanashri Atre63d98022017-01-24 18:22:09 -0800875 hdd_softap_dump_sk_buff(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700877 skb->dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878
Dhanashri Atre63d98022017-01-24 18:22:09 -0800879 if (unlikely(skb->dev == NULL)) {
Yun Parkc3e35562018-03-08 12:05:52 -0800880 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
881 QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800882 "%s: ERROR!!Invalid netdevice", __func__);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800883 continue;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800884 }
885 cpu_index = wlan_hdd_get_cpu();
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700886 ++adapter->hdd_stats.tx_rx_stats.rx_packets[cpu_index];
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700887 ++adapter->stats.rx_packets;
888 adapter->stats.rx_bytes += skb->len;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800889
Yun Parkc3e35562018-03-08 12:05:52 -0800890 /* Send DHCP Indication to FW */
891 src_mac = (struct qdf_mac_addr *)(skb->data +
892 QDF_NBUF_SRC_MAC_OFFSET);
893 if (QDF_STATUS_SUCCESS ==
894 hdd_softap_get_sta_id(adapter, src_mac, &staid)) {
895 if (staid < WLAN_MAX_STA_COUNT) {
896 adapter->sta_info[staid].rx_packets++;
897 adapter->sta_info[staid].rx_bytes += skb->len;
898 adapter->sta_info[staid].last_tx_rx_ts =
899 qdf_system_ticks();
Alok Kumarcee3cf22018-07-15 18:22:36 +0530900 hdd_inspect_dhcp_packet(adapter, staid,
901 skb, QDF_RX);
Yun Parkc3e35562018-03-08 12:05:52 -0800902 }
Will Huang496b36c2017-07-11 16:38:50 +0800903 }
Yun Parkc3e35562018-03-08 12:05:52 -0800904
Dhanashri Atre63d98022017-01-24 18:22:09 -0800905 hdd_event_eapol_log(skb, QDF_RX);
Mohit Khanna02281da2017-08-27 09:40:55 -0700906 qdf_dp_trace_log_pkt(adapter->session_id,
907 skb, QDF_RX, QDF_TRACE_DEFAULT_PDEV_ID);
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530908 DPTRACE(qdf_dp_trace(skb,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800909 QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700910 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530911 qdf_nbuf_data_addr(skb),
912 sizeof(qdf_nbuf_data(skb)), QDF_RX));
Mohit Khanna02281da2017-08-27 09:40:55 -0700913 DPTRACE(qdf_dp_trace_data_pkt(skb, QDF_TRACE_DEFAULT_PDEV_ID,
914 QDF_DP_TRACE_RX_PACKET_RECORD, 0, QDF_RX));
Dhanashri Atre63d98022017-01-24 18:22:09 -0800915
916 skb->protocol = eth_type_trans(skb, skb->dev);
917
918 /* hold configurable wakelock for unicast traffic */
Jeff Johnson92402872017-09-03 09:25:37 -0700919 if (hdd_ctx->config->rx_wakelock_timeout &&
Dhanashri Atre63d98022017-01-24 18:22:09 -0800920 skb->pkt_type != PACKET_BROADCAST &&
921 skb->pkt_type != PACKET_MULTICAST) {
Jeff Johnson92402872017-09-03 09:25:37 -0700922 cds_host_diag_log_work(&hdd_ctx->rx_wake_lock,
923 hdd_ctx->config->rx_wakelock_timeout,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800924 WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
Jeff Johnson92402872017-09-03 09:25:37 -0700925 qdf_wake_lock_timeout_acquire(&hdd_ctx->rx_wake_lock,
926 hdd_ctx->config->
Dhanashri Atre63d98022017-01-24 18:22:09 -0800927 rx_wakelock_timeout);
928 }
929
930 /* Remove SKB from internal tracking table before submitting
931 * it to stack
932 */
Manjunathappa Prakash17c07bd2017-04-27 21:24:28 -0700933 qdf_net_buf_debug_release_skb(skb);
Dhanashri Atre63d98022017-01-24 18:22:09 -0800934 if (hdd_napi_enabled(HDD_NAPI_ANY) &&
Jeff Johnsone2ba3cd2017-10-30 20:02:09 -0700935 !hdd_ctx->enable_rxthread)
Dhanashri Atre63d98022017-01-24 18:22:09 -0800936 rxstat = netif_receive_skb(skb);
937 else
938 rxstat = netif_rx_ni(skb);
Manjunathappa Prakash3a21bea2018-05-29 20:41:12 -0700939
940 hdd_ctx->no_rx_offload_pkt_cnt++;
941
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700942 if (NET_RX_SUCCESS == rxstat)
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700943 ++adapter->hdd_stats.tx_rx_stats.rx_delivered[cpu_index];
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700944 else
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700945 ++adapter->hdd_stats.tx_rx_stats.rx_refused[cpu_index];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530948 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949}
950
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700951QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700952 uint8_t sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530954 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Jeff Johnson92402872017-09-03 09:25:37 -0700955 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700957 if (NULL == adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800958 hdd_err("NULL adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530959 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 }
961
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700962 if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800963 hdd_err("Invalid adapter magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530964 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 }
966
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700967 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 /* Clear station in TL and then update HDD data
969 * structures. This helps to block RX frames from other
970 * station to this station.
971 */
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800972 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800973 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700974 sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530975 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800976 hdd_err("cdp_clear_peer failed for staID %d, Status=%d [0x%08X]",
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700977 sta_id, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 }
979
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700980 if (adapter->sta_info[sta_id].in_use) {
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +0530981 if (ucfg_ipa_is_enabled()) {
Yun Parka9d0c112018-03-07 14:11:27 -0800982 if (ucfg_ipa_wlan_evt(hdd_ctx->hdd_pdev, adapter->dev,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +0530983 adapter->device_mode,
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700984 adapter->sta_info[sta_id].sta_id,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +0530985 adapter->session_id,
986 WLAN_IPA_CLIENT_DISCONNECT,
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700987 adapter->sta_info[sta_id].sta_mac.
Yun Parka9d0c112018-03-07 14:11:27 -0800988 bytes) != QDF_STATUS_SUCCESS)
989 hdd_err("WLAN_CLIENT_DISCONNECT event failed");
Will Huangac3fd9a2017-11-01 16:18:12 +0800990 }
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700991 spin_lock_bh(&adapter->sta_info_lock);
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700992 qdf_mem_zero(&adapter->sta_info[sta_id],
Jeff Johnson82155922017-09-30 16:54:14 -0700993 sizeof(struct hdd_station_info));
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700994 spin_unlock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 }
Abhishek Singh07c627e2017-03-20 17:56:34 +0530996
Jeff Johnsonfb0857d2018-07-08 13:23:04 -0700997 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530999 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000}
1001
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001002QDF_STATUS hdd_softap_register_sta(struct hdd_adapter *adapter,
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001003 bool auth_required,
1004 bool privacy_required,
1005 uint8_t sta_id,
1006 struct qdf_mac_addr *sta_mac,
1007 bool wmm_enabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301009 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001011 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001012 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001013 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1014 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001016 hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u",
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001017 sta_id, auth_required, privacy_required, wmm_enabled);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001018
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001019 /*
1020 * Clean up old entry if it is not cleaned up properly
1021 */
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001022 if (adapter->sta_info[sta_id].in_use) {
1023 hdd_info("clean up old entry for STA %d", sta_id);
1024 hdd_softap_deregister_sta(adapter, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026
Jeff Johnson6c6d27c2018-05-06 17:19:22 -07001027 /* Get the Station ID from the one saved during the association. */
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001028 staDesc.sta_id = sta_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001030 /* Save the adapter Pointer for this sta_id */
1031 hdd_ctx->sta_to_adapter[sta_id] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001033 qdf_status = hdd_softap_init_tx_rx_sta(adapter, sta_id, sta_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001035 staDesc.is_qos_enabled = wmm_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036
Dhanashri Atre182b0272016-02-17 15:35:07 -08001037 /* Register the vdev transmit and receive functions */
1038 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
Mohit Khanna70322002018-05-15 19:21:32 -07001039
Alok Kumar4696fb02018-06-06 00:10:18 +05301040 txrx_ops.tx.tx_comp = hdd_softap_notify_tx_compl_cbk;
Mohit Khanna70322002018-05-15 19:21:32 -07001041
1042 if (adapter->hdd_ctx->enable_dp_rx_threads) {
1043 txrx_ops.rx.rx = hdd_rx_pkt_thread_enqueue_cbk;
1044 txrx_ops.rx.rx_stack = hdd_softap_rx_packet_cbk;
1045 } else {
1046 txrx_ops.rx.rx = hdd_softap_rx_packet_cbk;
1047 txrx_ops.rx.rx_stack = NULL;
1048 }
1049
Leo Changfdb45c32016-10-28 11:09:23 -07001050 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001051 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001052 (struct cdp_pdev *)pdev, adapter->session_id),
Sravan Kumar Kairam43f191b2018-05-04 17:00:39 +05301053 adapter, (struct cdp_ctrl_objmgr_vdev *)adapter->hdd_vdev,
1054 &txrx_ops);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001055 adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001056 (struct cdp_pdev *)pdev,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001057 adapter->session_id);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001058 adapter->tx_fn = txrx_ops.tx.tx;
Dhanashri Atre182b0272016-02-17 15:35:07 -08001059
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001060 qdf_status = cdp_peer_register(soc,
1061 (struct cdp_pdev *)pdev, &staDesc);
Dhanashri Atre50141c52016-04-07 13:15:29 -07001062 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001063 hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]",
1064 qdf_status, qdf_status);
Dhanashri Atre50141c52016-04-07 13:15:29 -07001065 return qdf_status;
1066 }
1067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 /* if ( WPA ), tell TL to go to 'connected' and after keys come to the
1069 * driver then go to 'authenticated'. For all other authentication
1070 * types (those that do not require upper layer authentication) we can
1071 * put TL directly into 'authenticated' state
1072 */
1073
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001074 adapter->sta_info[sta_id].sta_id = sta_id;
1075 adapter->sta_info[sta_id].is_qos_enabled = wmm_enabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001077 if (!auth_required) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001078 hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time",
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001079 adapter->sta_info[sta_id].sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080
1081 /* Connections that do not need Upper layer auth,
1082 * transition TL directly to 'Authenticated' state.
1083 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001084 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001085 OL_TXRX_PEER_STATE_AUTH, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001087 adapter->sta_info[sta_id].peer_state = OL_TXRX_PEER_STATE_AUTH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 } else {
1089
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001090 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001091 adapter->sta_info[sta_id].sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001093 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001094 OL_TXRX_PEER_STATE_CONN, false);
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001095 adapter->sta_info[sta_id].peer_state = OL_TXRX_PEER_STATE_CONN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 }
1097
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001098 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001099 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001100 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
1101 WLAN_CONTROL_PATH);
1102
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301103 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104}
1105
1106/**
1107 * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001108 * @adapter: pointer to adapter context
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001109 * @privacy_required: should 802.11 privacy bit be set?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301111 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001113QDF_STATUS hdd_softap_register_bc_sta(struct hdd_adapter *adapter,
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001114 bool privacy_required)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301116 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001117 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Dustin Brownce5b3d32018-01-17 15:07:38 -08001118 struct qdf_mac_addr broadcastMacAddr = QDF_MAC_ADDR_BCAST_INIT;
Jeff Johnson9bf24972017-10-04 09:26:58 -07001119 struct hdd_ap_ctx *ap_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120
Jeff Johnson9bf24972017-10-04 09:26:58 -07001121 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001123 hdd_ctx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = adapter;
Jeff Johnson42518cf2017-10-26 13:33:29 -07001124 hdd_ctx->sta_to_adapter[ap_ctx->broadcast_sta_id] = adapter;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301125 qdf_status =
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001126 hdd_softap_register_sta(adapter, false, privacy_required,
Jeff Johnson42518cf2017-10-26 13:33:29 -07001127 ap_ctx->broadcast_sta_id,
Jeff Johnson3f6c89f2018-03-01 14:27:38 -08001128 &broadcastMacAddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301130 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131}
1132
1133/**
1134 * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001135 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301137 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 */
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001139static QDF_STATUS hdd_softap_deregister_bc_sta(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140{
Jeff Johnson42518cf2017-10-26 13:33:29 -07001141 struct hdd_ap_ctx *ap_ctx;
1142
1143 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
1144 return hdd_softap_deregister_sta(adapter, ap_ctx->broadcast_sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145}
1146
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001147QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301149 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001150 uint8_t sta_id = 0;
Jeff Johnson92402872017-09-03 09:25:37 -07001151 struct hdd_context *hdd_ctx;
Yun Parka9d0c112018-03-07 14:11:27 -08001152 struct hdd_ap_ctx *ap_ctx;
Srinivas Girigowdae806a822017-03-25 11:25:30 -07001153
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001154 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Yun Parka9d0c112018-03-07 14:11:27 -08001155 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156
Rajeev Kumar07bbe122017-10-24 13:06:05 -07001157 /* This is stop bss callback running in scheduler thread so do not
1158 * driver unload in progress check otherwise it can lead to peer
1159 * object leak
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001161 qdf_status = hdd_softap_deregister_bc_sta(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162
Yun Parka9d0c112018-03-07 14:11:27 -08001163 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001164 hdd_err("Failed to deregister BC sta Id %d",
Jeff Johnson42518cf2017-10-26 13:33:29 -07001165 ap_ctx->broadcast_sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001167 for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001168 /* This excludes BC sta as it is already deregistered */
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001169 if (adapter->sta_info[sta_id].in_use) {
1170 qdf_status = hdd_softap_deregister_sta(adapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301171 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001172 hdd_err("Failed to deregister sta Id %d",
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001173 sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174 }
1175 }
1176 }
Ashish Kumar Dhanotiya3f78e682018-03-14 11:19:27 +05301177 if (adapter->device_mode == QDF_SAP_MODE)
1178 wlan_hdd_restore_channels(hdd_ctx, true);
Mukul Sharmaecf8e092017-12-19 22:36:31 +05301179
1180 /* Mark the indoor channel (passive) to enable */
1181 if (hdd_ctx->config->force_ssc_disable_indoor_channel) {
1182 hdd_update_indoor_channel(hdd_ctx, false);
Jeff Johnson049f4622018-06-14 11:09:41 -07001183 sme_update_channel_list(hdd_ctx->mac_handle);
Mukul Sharmaecf8e092017-12-19 22:36:31 +05301184 }
1185
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301186 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187}
1188
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001189QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter,
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001190 struct qdf_mac_addr *sta_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 enum ol_txrx_peer_state state)
1192{
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001193 uint8_t sta_id = WLAN_MAX_STA_COUNT;
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001194 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195
Dustin Brownfdf17c12018-03-14 12:55:34 -07001196 hdd_enter_dev(adapter->dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001198 qdf_status = hdd_softap_get_sta_id(adapter, sta_mac, &sta_id);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001199 if (QDF_STATUS_SUCCESS != qdf_status) {
1200 hdd_err("Failed to find right station");
1201 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202 }
1203
1204 if (false ==
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001205 qdf_is_macaddr_equal(&adapter->sta_info[sta_id].sta_mac,
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001206 sta_mac)) {
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001207 hdd_err("Station %u MAC address not matching", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301208 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 }
1210
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301211 qdf_status =
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001212 hdd_change_peer_state(adapter, sta_id, state, false);
1213 hdd_info("Station %u changed to state %d", sta_id, state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301215 if (QDF_STATUS_SUCCESS == qdf_status) {
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001216 adapter->sta_info[sta_id].peer_state =
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001217 OL_TXRX_PEER_STATE_AUTH;
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001218 p2p_peer_authorized(adapter->hdd_vdev, sta_mac->bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219 }
1220
Dustin Browne74003f2018-03-14 12:51:58 -07001221 hdd_exit();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301222 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223}
1224
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001225QDF_STATUS hdd_softap_get_sta_id(struct hdd_adapter *adapter,
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001226 struct qdf_mac_addr *sta_mac,
1227 uint8_t *sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228{
1229 uint8_t i;
1230
1231 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301232 if (!qdf_mem_cmp
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001233 (&adapter->sta_info[i].sta_mac, sta_mac,
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001234 QDF_MAC_ADDR_SIZE) && adapter->sta_info[i].in_use) {
Jeff Johnsonfb0857d2018-07-08 13:23:04 -07001235 *sta_id = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301236 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 }
1238 }
1239
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301240 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241}