blob: 2496df84b67a119fd3eb58238dfa87b23299c7f0 [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 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -080028/* denote that this file does not allow legacy hddLog */
29#define HDD_DISALLOW_LEGACY_HDDLOG 1
30
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031/* Include files */
32#include <linux/semaphore.h>
33#include <wlan_hdd_tx_rx.h>
34#include <wlan_hdd_softap_tx_rx.h>
35#include <linux/netdevice.h>
36#include <linux/skbuff.h>
37#include <linux/etherdevice.h>
Anurag Chouhan6d760662016-02-20 16:05:43 +053038#include <qdf_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039#include <ani_global.h>
Anurag Chouhan6d760662016-02-20 16:05:43 +053040#include <qdf_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080041#include <net/ieee80211_radiotap.h>
42#include <cds_sched.h>
43#include <wlan_hdd_napi.h>
Leo Changfdb45c32016-10-28 11:09:23 -070044#include <cdp_txrx_cmn.h>
Dhanashri Atreb08959a2016-03-01 17:28:03 -080045#include <cdp_txrx_peer_ops.h>
Manjunathappa Prakash779e4862016-09-12 17:00:11 -070046#include <cds_utils.h>
Leo Changfdb45c32016-10-28 11:09:23 -070047#include <cdp_txrx_flow_ctrl_v2.h>
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +053048#include <cdp_txrx_misc.h>
Abhishek Singh07c627e2017-03-20 17:56:34 +053049#include <wlan_hdd_object_manager.h>
Rachit Kankane2487f8f2017-04-19 14:30:19 +053050#include "wlan_p2p_ucfg_api.h"
Mukul Sharmaecf8e092017-12-19 22:36:31 +053051#include <wlan_hdd_regulatory.h>
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +053052#include "wlan_ipa_ucfg_api.h"
Yun Parkc3e35562018-03-08 12:05:52 -080053#include <wma_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054
55/* Preprocessor definitions and constants */
56#undef QCA_HDD_SAP_DUMP_SK_BUFF
57
58/* Type declarations */
59
60/* Function definitions and documenation */
61#ifdef QCA_HDD_SAP_DUMP_SK_BUFF
62/**
63 * hdd_softap_dump_sk_buff() - Dump an skb
64 * @skb: skb to dump
65 *
66 * Return: None
67 */
68static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
69{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053070 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Jeff Johnson36e74c42017-09-18 08:15:42 -070071 "%s: head = %pK ", __func__, skb->head);
Srinivas Girigowdae806a822017-03-25 11:25:30 -070072 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Jeff Johnson36e74c42017-09-18 08:15:42 -070073 "%s: tail = %pK ", __func__, skb->tail);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053074 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Jeff Johnson36e74c42017-09-18 08:15:42 -070075 "%s: end = %pK ", __func__, skb->end);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053076 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080077 "%s: len = %d ", __func__, skb->len);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053078 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080079 "%s: data_len = %d ", __func__, skb->data_len);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053080 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081 "%s: mac_len = %d", __func__, skb->mac_len);
82
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053083 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ", skb->data[0],
85 skb->data[1], skb->data[2], skb->data[3], skb->data[4],
86 skb->data[5], skb->data[6], skb->data[7]);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053087 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[8],
89 skb->data[9], skb->data[10], skb->data[11], skb->data[12],
90 skb->data[13], skb->data[14], skb->data[15]);
91}
92#else
93static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
94{
95}
96#endif
97
98#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
99/**
100 * hdd_softap_tx_resume_timer_expired_handler() - TX Q resume timer handler
101 * @adapter_context: pointer to vdev adapter
102 *
103 * TX Q resume timer handler for SAP and P2P GO interface. If Blocked
104 * OS Q is not resumed during timeout period, to prevent permanent
105 * stall, resume OS Q forcefully for SAP and P2P GO interface.
106 *
107 * Return: None
108 */
109void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context)
110{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700111 struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700113 if (!adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800114 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115 return;
116 }
117
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700118 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700119 wlan_hdd_netif_queue_control(adapter, WLAN_WAKE_ALL_NETIF_QUEUE,
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800120 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121}
122
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530123#if defined(CONFIG_PER_VDEV_TX_DESC_POOL)
124
125/**
126 * hdd_softap_tx_resume_false() - Resume OS TX Q false leads to queue disabling
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700127 * @adapter: pointer to hdd adapter
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530128 * @tx_resume: TX Q resume trigger
129 *
130 *
131 * Return: None
132 */
133static void
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700134hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume)
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530135{
136 if (true == tx_resume)
137 return;
138
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700139 hdd_debug("Disabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700140 wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE,
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530141 WLAN_DATA_FLOW_CONTROL);
142
143 if (QDF_TIMER_STATE_STOPPED ==
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700144 qdf_mc_timer_get_current_state(&adapter->
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530145 tx_flow_control_timer)) {
146 QDF_STATUS status;
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700147
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700148 status = qdf_mc_timer_start(&adapter->tx_flow_control_timer,
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530149 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
150
151 if (!QDF_IS_STATUS_SUCCESS(status))
152 hdd_err("Failed to start tx_flow_control_timer");
153 else
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700154 adapter->hdd_stats.tx_rx_stats.txflow_timer_cnt++;
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530155 }
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530156}
157#else
158
159static inline void
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700160hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume)
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530161{
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530162}
163#endif
164
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800165/**
166 * hdd_softap_tx_resume_cb() - Resume OS TX Q.
167 * @adapter_context: pointer to vdev apdapter
168 * @tx_resume: TX Q resume trigger
169 *
170 * Q was stopped due to WLAN TX path low resource condition
171 *
172 * Return: None
173 */
174void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume)
175{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700176 struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700178 if (!adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800179 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 return;
181 }
182
183 /* Resume TX */
184 if (true == tx_resume) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530185 if (QDF_TIMER_STATE_STOPPED !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700186 qdf_mc_timer_get_current_state(&adapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 tx_flow_control_timer)) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700188 qdf_mc_timer_stop(&adapter->tx_flow_control_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189 }
190
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700191 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700192 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 WLAN_WAKE_ALL_NETIF_QUEUE,
194 WLAN_DATA_FLOW_CONTROL);
195 }
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700196 hdd_softap_tx_resume_false(adapter, tx_resume);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197}
gbianec670c592016-11-24 11:21:30 +0800198
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700199static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter,
gbianec670c592016-11-24 11:21:30 +0800200 struct sk_buff *skb)
201{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700202 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800203 int need_orphan = 0;
204
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700205 if (adapter->tx_flow_low_watermark > 0) {
tfyubdf453e2017-09-27 13:34:30 +0800206#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
207 /*
208 * The TCP TX throttling logic is changed a little after
209 * 3.19-rc1 kernel, the TCP sending limit will be smaller,
210 * which will throttle the TCP packets to the host driver.
211 * The TCP UP LINK throughput will drop heavily. In order to
212 * fix this issue, need to orphan the socket buffer asap, which
213 * will call skb's destructor to notify the TCP stack that the
214 * SKB buffer is unowned. And then the TCP stack will pump more
215 * packets to host driver.
216 *
217 * The TX packets might be dropped for UDP case in the iperf
218 * testing. So need to be protected by follow control.
219 */
220 need_orphan = 1;
221#else
222 if (hdd_ctx->config->tx_orphan_enable)
223 need_orphan = 1;
224#endif
tfyu5f01db22017-10-11 13:51:04 +0800225 } else if (hdd_ctx->config->tx_orphan_enable) {
226 if (qdf_nbuf_is_ipv4_tcp_pkt(skb) ||
Tiger Yu438c6482017-10-13 11:07:00 +0800227 qdf_nbuf_is_ipv6_tcp_pkt(skb))
tfyu5f01db22017-10-11 13:51:04 +0800228 need_orphan = 1;
tfyubdf453e2017-09-27 13:34:30 +0800229 }
230
tfyu5f01db22017-10-11 13:51:04 +0800231 if (need_orphan) {
gbianec670c592016-11-24 11:21:30 +0800232 skb_orphan(skb);
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700233 ++adapter->hdd_stats.tx_rx_stats.tx_orphaned;
Tiger Yu438c6482017-10-13 11:07:00 +0800234 } else
gbianec670c592016-11-24 11:21:30 +0800235 skb = skb_unshare(skb, GFP_ATOMIC);
gbianec670c592016-11-24 11:21:30 +0800236
237 return skb;
238}
239
240#else
Mohit Khannad0b63f52017-02-18 18:05:52 -0800241/**
242 * hdd_skb_orphan() - skb_unshare a cloned packed else skb_orphan
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700243 * @adapter: pointer to HDD adapter
Mohit Khannad0b63f52017-02-18 18:05:52 -0800244 * @skb: pointer to skb data packet
245 *
246 * Return: pointer to skb structure
247 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700248static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter,
Mohit Khannad0b63f52017-02-18 18:05:52 -0800249 struct sk_buff *skb) {
gbianec670c592016-11-24 11:21:30 +0800250
Mohit Khannad0b63f52017-02-18 18:05:52 -0800251 struct sk_buff *nskb;
tfyubdf453e2017-09-27 13:34:30 +0800252#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700253 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800254#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800255
Mohit Khanna87493732017-08-27 23:26:44 -0700256 hdd_skb_fill_gso_size(adapter->dev, skb);
257
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700258 nskb = skb_unshare(skb, GFP_ATOMIC);
tfyubdf453e2017-09-27 13:34:30 +0800259#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700260 if (unlikely(hdd_ctx->config->tx_orphan_enable) && (nskb == skb)) {
Mohit Khannad0b63f52017-02-18 18:05:52 -0800261 /*
262 * For UDP packets we want to orphan the packet to allow the app
263 * to send more packets. The flow would ultimately be controlled
264 * by the limited number of tx descriptors for the vdev.
265 */
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700266 ++adapter->hdd_stats.tx_rx_stats.tx_orphaned;
Mohit Khannad0b63f52017-02-18 18:05:52 -0800267 skb_orphan(skb);
268 }
tfyubdf453e2017-09-27 13:34:30 +0800269#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800270 return nskb;
gbianec670c592016-11-24 11:21:30 +0800271}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
273
274/**
Yun Parkc3e35562018-03-08 12:05:52 -0800275 * hdd_post_dhcp_ind() - Send DHCP START/STOP indication to FW
276 * @adapter: pointer to hdd adapter
277 * @sta_id: peer station ID
278 * @type: WMA message type
279 *
280 * Return: error number
281 */
282int hdd_post_dhcp_ind(struct hdd_adapter *adapter,
283 uint8_t sta_id, uint16_t type)
284{
285 tAniDHCPInd pmsg;
286 QDF_STATUS status = QDF_STATUS_SUCCESS;
287
288 hdd_debug("Post DHCP indication,sta_id=%d, type=%d", sta_id, type);
289
290 if (!adapter) {
291 hdd_err("NULL adapter");
292 return -EINVAL;
293 }
294
295 pmsg.msgType = type;
296 pmsg.msgLen = (uint16_t) sizeof(tAniDHCPInd);
297 pmsg.device_mode = adapter->device_mode;
298 qdf_mem_copy(pmsg.adapterMacAddr.bytes,
299 adapter->mac_addr.bytes,
300 QDF_MAC_ADDR_SIZE);
301 qdf_mem_copy(pmsg.peerMacAddr.bytes,
302 adapter->sta_info[sta_id].sta_mac.bytes,
303 QDF_MAC_ADDR_SIZE);
304
305 status = wma_process_dhcp_ind(cds_get_context(QDF_MODULE_ID_WMA),
306 &pmsg);
307 if (!QDF_IS_STATUS_SUCCESS(status)) {
308 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
309 "%s: Post DHCP Ind MSG fail", __func__);
310 return -EFAULT;
311 }
312
313 return 0;
314}
315
316/**
317 * hdd_inspect_dhcp_packet() - Inspect DHCP packet
318 * @adapter: pointer to hdd adapter
319 * @sta_id: peer station ID
320 * @skb: pointer to OS packet (sk_buff)
321 * @dir: direction
322 *
323 * Inspect the Tx/Rx frame, and send DHCP START/STOP notification to the FW
324 * through WMI message, during DHCP based IP address acquisition phase.
325 *
326 * - Send DHCP_START notification to FW when SAP gets DHCP Discovery
327 * - Send DHCP_STOP notification to FW when SAP sends DHCP ACK/NAK
328 *
329 * DHCP subtypes are determined by a status octet in the DHCP Message type
330 * option (option code 53 (0x35)).
331 *
332 * Each peer will be in one of 4 DHCP phases, starts from QDF_DHCP_PHASE_ACK,
333 * and transitioned per DHCP message type as it arrives.
334 *
335 * - QDF_DHCP_PHASE_DISCOVER: upon receiving DHCP_DISCOVER message in ACK phase
336 * - QDF_DHCP_PHASE_OFFER: upon receiving DHCP_OFFER message in DISCOVER phase
337 * - QDF_DHCP_PHASE_REQUEST: upon receiving DHCP_REQUEST message in OFFER phase
338 * or ACK phase (Renewal process)
339 * - QDF_DHCP_PHASE_ACK : upon receiving DHCP_ACK/NAK message in REQUEST phase
340 * or DHCP_DELINE message in OFFER phase
341 *
342 * Return: error number
343 */
344int hdd_inspect_dhcp_packet(struct hdd_adapter *adapter,
345 uint8_t sta_id,
346 struct sk_buff *skb,
347 enum qdf_proto_dir dir)
348{
349 enum qdf_proto_subtype subtype = QDF_PROTO_INVALID;
350 struct hdd_station_info *hdd_sta_info;
351 int errno = 0;
352
353 hdd_debug("sta_id=%d, dir=%d", sta_id, dir);
354
355 if ((adapter->device_mode == QDF_SAP_MODE) &&
356 ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_DHCP ==
357 QDF_NBUF_CB_GET_PACKET_TYPE(skb)) ||
358 (dir == QDF_RX && qdf_nbuf_is_ipv4_dhcp_pkt(skb) == true))) {
359
360 subtype = qdf_nbuf_get_dhcp_subtype(skb);
361 hdd_sta_info = &adapter->sta_info[sta_id];
362
363 hdd_debug("ENTER: type=%d, phase=%d, nego_status=%d",
364 subtype,
365 hdd_sta_info->dhcp_phase,
366 hdd_sta_info->dhcp_nego_status);
367
368 switch (subtype) {
369 case QDF_PROTO_DHCP_DISCOVER:
370 if (dir != QDF_RX)
371 break;
372 if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP)
373 errno = hdd_post_dhcp_ind(adapter, sta_id,
374 WMA_DHCP_START_IND);
375 hdd_sta_info->dhcp_phase = DHCP_PHASE_DISCOVER;
376 hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS;
377 break;
378 case QDF_PROTO_DHCP_OFFER:
379 hdd_sta_info->dhcp_phase = DHCP_PHASE_OFFER;
380 break;
381 case QDF_PROTO_DHCP_REQUEST:
382 if (dir != QDF_RX)
383 break;
384 if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP)
385 errno = hdd_post_dhcp_ind(adapter, sta_id,
386 WMA_DHCP_START_IND);
387 hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS;
388 case QDF_PROTO_DHCP_DECLINE:
389 if (dir == QDF_RX)
390 hdd_sta_info->dhcp_phase = DHCP_PHASE_REQUEST;
391 break;
392 case QDF_PROTO_DHCP_ACK:
393 case QDF_PROTO_DHCP_NACK:
394 hdd_sta_info->dhcp_phase = DHCP_PHASE_ACK;
Yun Park0ac12822018-04-02 11:18:04 -0700395 if (hdd_sta_info->dhcp_nego_status ==
396 DHCP_NEGO_IN_PROGRESS)
Yun Parkc3e35562018-03-08 12:05:52 -0800397 errno = hdd_post_dhcp_ind(adapter, sta_id,
398 WMA_DHCP_STOP_IND);
399 hdd_sta_info->dhcp_nego_status = DHCP_NEGO_STOP;
400 break;
401 default:
402 break;
403 }
404
405 hdd_debug("EXIT: phase=%d, nego_status=%d",
406 hdd_sta_info->dhcp_phase,
407 hdd_sta_info->dhcp_nego_status);
408 }
409
410 return errno;
411}
412
413/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530414 * __hdd_softap_hard_start_xmit() - Transmit a frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 * @skb: pointer to OS packet (sk_buff)
416 * @dev: pointer to network device
417 *
418 * Function registered with the Linux OS for transmitting
419 * packets. This version of the function directly passes
420 * the packet to Transport Layer.
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530421 * In case of any packet drop or error, log the error with
422 * INFO HIGH/LOW/MEDIUM to avoid excessive logging in kmsg.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 *
424 * Return: Always returns NETDEV_TX_OK
425 */
Srinivas Girigowda49b48b22018-04-05 09:23:28 -0700426static netdev_tx_t __hdd_softap_hard_start_xmit(struct sk_buff *skb,
427 struct net_device *dev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428{
429 sme_ac_enum_type ac = SME_AC_BE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700430 struct hdd_adapter *adapter = (struct hdd_adapter *) netdev_priv(dev);
Jeff Johnson9bf24972017-10-04 09:26:58 -0700431 struct hdd_ap_ctx *ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530432 struct qdf_mac_addr *pDestMacAddress;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433 uint8_t STAId;
Will Huang496b36c2017-07-11 16:38:50 +0800434 uint32_t num_seg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700436 ++adapter->hdd_stats.tx_rx_stats.tx_called;
437 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530438
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 /* Prevent this function from being called during SSR since TL
440 * context may not be reinitialized at this time which may
441 * lead to a crash.
442 */
Will Huang20de9432018-02-06 17:01:03 +0800443 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state() ||
444 cds_is_load_or_unload_in_progress()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530445 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Will Huang20de9432018-02-06 17:01:03 +0800446 "%s: Recovery/(Un)load in Progress. Ignore!!!",
447 __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 goto drop_pkt;
449 }
450
451 /*
452 * If the device is operating on a DFS Channel
453 * then check if SAP is in CAC WAIT state and
454 * drop the packets. In CAC WAIT state device
455 * is expected not to transmit any frames.
456 * SAP starts Tx only after the BSS START is
457 * done.
458 */
Jeff Johnson9bf24972017-10-04 09:26:58 -0700459 if (ap_ctx->dfs_cac_block_tx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800462 /*
Jeff Johnson4fca3b52017-01-12 08:44:18 -0800463 * If a transmit function is not registered, drop packet
464 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700465 if (!adapter->tx_fn) {
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800466 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
467 "%s: TX function not registered by the data path",
468 __func__);
469 goto drop_pkt;
470 }
471
Nirav Shah5e74bb82016-07-20 16:01:27 +0530472 wlan_hdd_classify_pkt(skb);
473
Anurag Chouhan6d760662016-02-20 16:05:43 +0530474 pDestMacAddress = (struct qdf_mac_addr *) skb->data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475
Nirav Shah5e74bb82016-07-20 16:01:27 +0530476 if (QDF_NBUF_CB_GET_IS_BCAST(skb) ||
477 QDF_NBUF_CB_GET_IS_MCAST(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478 /* The BC/MC station ID is assigned during BSS
479 * starting phase. SAP will return the station ID
480 * used for BC/MC traffic.
481 */
Jeff Johnson42518cf2017-10-26 13:33:29 -0700482 STAId = ap_ctx->broadcast_sta_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530484 if (QDF_STATUS_SUCCESS !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700485 hdd_softap_get_sta_id(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 pDestMacAddress, &STAId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530487 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530488 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489 "%s: Failed to find right station", __func__);
490 goto drop_pkt;
491 }
492
Prakash Dhavali3107b752016-11-28 14:35:06 +0530493 if (STAId >= WLAN_MAX_STA_COUNT) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530494 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530495 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800496 "%s: Failed to find right station", __func__);
497 goto drop_pkt;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700498 } else if (false == adapter->sta_info[STAId].in_use) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530499 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530500 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800501 "%s: STA %d is unregistered", __func__,
502 STAId);
503 goto drop_pkt;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700504 } else if (true == adapter->sta_info[STAId].
Jeff Johnsone4f5d932017-10-21 13:21:15 -0700505 is_deauth_in_progress) {
Poddar, Siddartha5075462017-03-16 19:20:09 +0530506 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530507 QDF_TRACE_LEVEL_INFO_HIGH,
Poddar, Siddartha5075462017-03-16 19:20:09 +0530508 "%s: STA %d deauth in progress", __func__,
509 STAId);
510 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 }
512
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800513 if ((OL_TXRX_PEER_STATE_CONN !=
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700514 adapter->sta_info[STAId].peer_state)
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800515 && (OL_TXRX_PEER_STATE_AUTH !=
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700516 adapter->sta_info[STAId].peer_state)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530517 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530518 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 "%s: Station not connected yet", __func__);
520 goto drop_pkt;
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800521 } else if (OL_TXRX_PEER_STATE_CONN ==
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700522 adapter->sta_info[STAId].peer_state) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523 if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
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: NON-EAPOL packet in non-Authenticated state",
527 __func__);
528 goto drop_pkt;
529 }
530 }
531 }
532
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700533 hdd_get_tx_resource(adapter, STAId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
535
536 /* Get TL AC corresponding to Qdisc queue index/AC. */
537 ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping];
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700538 ++adapter->hdd_stats.tx_rx_stats.tx_classified_ac[ac];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700540#if defined(IPA_OFFLOAD)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530541 if (!qdf_nbuf_ipa_owned_get(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800542#endif
gbianec670c592016-11-24 11:21:30 +0800543
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700544 skb = hdd_skb_orphan(adapter, skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 if (!skb)
Jeff Johnsonedeff232015-11-11 17:19:42 -0800546 goto drop_pkt_accounting;
gbianec670c592016-11-24 11:21:30 +0800547
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700548#if defined(IPA_OFFLOAD)
Yun Park01deb2c2017-06-14 15:21:44 -0700549 } else {
550 /*
551 * Clear the IPA ownership after check it to avoid ipa_free_skb
552 * is called when Tx completed for intra-BSS Tx packets
553 */
554 qdf_nbuf_ipa_owned_clear(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800555 }
556#endif
557
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530558 /*
559 * Add SKB to internal tracking table before further processing
560 * in WLAN driver.
561 */
562 qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__);
563
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700564 adapter->stats.tx_bytes += skb->len;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700565 adapter->sta_info[STAId].tx_bytes += skb->len;
Mohit Khannab1dd1e82017-02-04 15:14:38 -0800566
Will Huang496b36c2017-07-11 16:38:50 +0800567 if (qdf_nbuf_is_tso(skb)) {
568 num_seg = qdf_nbuf_get_tso_num_seg(skb);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700569 adapter->stats.tx_packets += num_seg;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700570 adapter->sta_info[STAId].tx_packets += num_seg;
Will Huang496b36c2017-07-11 16:38:50 +0800571 } else {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700572 ++adapter->stats.tx_packets;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700573 adapter->sta_info[STAId].tx_packets++;
Will Huang496b36c2017-07-11 16:38:50 +0800574 }
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700575 adapter->sta_info[STAId].last_tx_rx_ts = qdf_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576
Yun Parkc3e35562018-03-08 12:05:52 -0800577 if (STAId != ap_ctx->broadcast_sta_id)
578 hdd_inspect_dhcp_packet(adapter, STAId, skb, QDF_TX);
579
Nirav Shah5e74bb82016-07-20 16:01:27 +0530580 hdd_event_eapol_log(skb, QDF_TX);
Jeff Johnson1b780e42017-10-31 14:11:45 -0700581 qdf_dp_trace_log_pkt(adapter->session_id, skb, QDF_TX,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700582 QDF_TRACE_DEFAULT_PDEV_ID);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530583 QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
584 QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530586 qdf_dp_trace_set_track(skb, QDF_TX);
587 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700588 QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(skb),
589 sizeof(qdf_nbuf_data(skb)),
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530590 QDF_TX));
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530591 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700592 QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)skb->data,
593 qdf_nbuf_len(skb), QDF_TX));
Nirav Shahcbc6d722016-03-01 16:24:53 +0530594 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530595 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700596 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530597 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
598 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700600 if (adapter->tx_fn(adapter->txrx_vdev,
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800601 (qdf_nbuf_t) skb) != NULL) {
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530602 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603 "%s: Failed to send packet to txrx for staid:%d",
604 __func__, STAId);
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700605 ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac];
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530606 goto drop_pkt_and_release_skb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 }
Dustin Browne0024fa2016-10-14 16:29:21 -0700608 netif_trans_update(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609
610 return NETDEV_TX_OK;
611
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530612drop_pkt_and_release_skb:
613 qdf_net_buf_debug_release_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614drop_pkt:
615
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530616 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700617 QDF_TRACE_DEFAULT_PDEV_ID, (uint8_t *)skb->data,
618 qdf_nbuf_len(skb), QDF_TX));
Nirav Shahcbc6d722016-03-01 16:24:53 +0530619 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530620 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700621 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530622 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
623 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE), QDF_TX));
Jeff Johnsonedeff232015-11-11 17:19:42 -0800624 kfree_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625
Jeff Johnsonedeff232015-11-11 17:19:42 -0800626drop_pkt_accounting:
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700627 ++adapter->stats.tx_dropped;
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700628 ++adapter->hdd_stats.tx_rx_stats.tx_dropped;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800629
630 return NETDEV_TX_OK;
631}
632
633/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530634 * hdd_softap_hard_start_xmit() - Wrapper function to protect
635 * __hdd_softap_hard_start_xmit from SSR
636 * @skb: pointer to OS packet
637 * @dev: pointer to net_device structure
638 *
639 * Function called by OS if any packet needs to transmit.
640 *
641 * Return: Always returns NETDEV_TX_OK
642 */
Srinivas Girigowda49b48b22018-04-05 09:23:28 -0700643netdev_tx_t hdd_softap_hard_start_xmit(struct sk_buff *skb,
644 struct net_device *dev)
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530645{
Srinivas Girigowda49b48b22018-04-05 09:23:28 -0700646 netdev_tx_t ret;
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530647
648 cds_ssr_protect(__func__);
649 ret = __hdd_softap_hard_start_xmit(skb, dev);
650 cds_ssr_unprotect(__func__);
651
652 return ret;
653}
654
655/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656 * __hdd_softap_tx_timeout() - TX timeout handler
657 * @dev: pointer to network device
658 *
659 * This function is registered as a netdev ndo_tx_timeout method, and
660 * is invoked by the kernel if the driver takes too long to transmit a
661 * frame.
662 *
663 * Return: None
664 */
665static void __hdd_softap_tx_timeout(struct net_device *dev)
666{
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700667 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsonf7726872017-08-28 11:38:31 -0700668 struct hdd_context *hdd_ctx;
Nirav Shah89223f72016-03-01 18:10:38 +0530669 struct netdev_queue *txq;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530670 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Nirav Shah89223f72016-03-01 18:10:38 +0530671 int i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530673 DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700674 QDF_TRACE_DEFAULT_PDEV_ID,
675 NULL, 0, QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 /* Getting here implies we disabled the TX queues for too
677 * long. Queues are disabled either because of disassociation
678 * or low resource scenarios. In case of disassociation it is
679 * ok to ignore this. But if associated, we have do possible
680 * recovery here
681 */
682 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +0530683 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530684 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800685 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 return;
687 }
Nirav Shah89223f72016-03-01 18:10:38 +0530688
Dustin Browne0024fa2016-10-14 16:29:21 -0700689 TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA);
Nirav Shah89223f72016-03-01 18:10:38 +0530690
691 for (i = 0; i < NUM_TX_QUEUES; i++) {
692 txq = netdev_get_tx_queue(dev, i);
693 QDF_TRACE(QDF_MODULE_ID_HDD_DATA,
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800694 QDF_TRACE_LEVEL_DEBUG,
695 "Queue: %d status: %d txq->trans_start: %lu",
Nirav Shah89223f72016-03-01 18:10:38 +0530696 i, netif_tx_queue_stopped(txq), txq->trans_start);
697 }
698
Mohit Khannaca4173b2017-09-12 21:52:19 -0700699 wlan_hdd_display_netif_queue_history(hdd_ctx,
700 QDF_STATS_VERBOSITY_LEVEL_HIGH);
Leo Changfdb45c32016-10-28 11:09:23 -0700701 cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC));
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800702 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Nirav Shah89223f72016-03-01 18:10:38 +0530703 "carrier state: %d", netif_carrier_ok(dev));
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530704
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700705 ++adapter->hdd_stats.tx_rx_stats.tx_timeout_cnt;
706 ++adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530707
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700708 if (adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt >
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530709 HDD_TX_STALL_THRESHOLD) {
710 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
711 "Detected data stall due to continuous TX timeouts");
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700712 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Poddar, Siddarth37033032017-10-11 15:47:40 +0530713 if (hdd_ctx->config->enable_data_stall_det)
714 cdp_post_data_stall_event(soc,
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530715 DATA_STALL_LOG_INDICATOR_HOST_DRIVER,
716 DATA_STALL_LOG_HOST_SOFTAP_TX_TIMEOUT,
717 0xFF, 0xFF,
718 DATA_STALL_LOG_RECOVERY_TRIGGER_PDR);
719 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720}
721
722/**
723 * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout
724 * @dev: pointer to net_device
725 *
726 * Return: none
727 */
728void hdd_softap_tx_timeout(struct net_device *dev)
729{
730 cds_ssr_protect(__func__);
731 __hdd_softap_tx_timeout(dev);
732 cds_ssr_unprotect(__func__);
733}
734
735/**
736 * @hdd_softap_init_tx_rx() - Initialize Tx/RX module
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700737 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530739 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
740 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700742QDF_STATUS hdd_softap_init_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530744 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745
746 uint8_t STAId = 0;
747
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700748 qdf_mem_zero(&adapter->stats, sizeof(struct net_device_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700750 spin_lock_init(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751
752 for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) {
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700753 qdf_mem_zero(&adapter->sta_info[STAId],
Jeff Johnson82155922017-09-30 16:54:14 -0700754 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 }
756
757 return status;
758}
759
760/**
761 * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700762 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530764 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
765 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700767QDF_STATUS hdd_softap_deinit_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700769 if (adapter == NULL) {
770 hdd_err("Called with adapter = NULL.");
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800771 return QDF_STATUS_E_FAILURE;
772 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700774 adapter->txrx_vdev = NULL;
775 adapter->tx_fn = NULL;
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800776 hdd_info("Deregistering TX function hook !");
777 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778}
779
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700780QDF_STATUS hdd_softap_init_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnson349d9a92017-10-21 15:38:03 -0700781 uint8_t sta_id,
782 struct qdf_mac_addr *sta_mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783{
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700784 spin_lock_bh(&adapter->sta_info_lock);
785 if (adapter->sta_info[sta_id].in_use) {
786 spin_unlock_bh(&adapter->sta_info_lock);
Jeff Johnson349d9a92017-10-21 15:38:03 -0700787 hdd_err("Reinit of in use station %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530788 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789 }
790
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700791 qdf_mem_zero(&adapter->sta_info[sta_id],
Jeff Johnson82155922017-09-30 16:54:14 -0700792 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700794 adapter->sta_info[sta_id].in_use = true;
795 adapter->sta_info[sta_id].is_deauth_in_progress = false;
796 qdf_copy_macaddr(&adapter->sta_info[sta_id].sta_mac, sta_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700798 spin_unlock_bh(&adapter->sta_info_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530799 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800}
801
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700802QDF_STATUS hdd_softap_deinit_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnsonb157c722017-10-21 15:46:42 -0700803 uint8_t sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530805 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson5c19ade2017-10-04 09:52:12 -0700806 struct hdd_hostapd_state *hostapd_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807
Jeff Johnson5c19ade2017-10-04 09:52:12 -0700808 hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700810 spin_lock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700812 if (false == adapter->sta_info[sta_id].in_use) {
813 spin_unlock_bh(&adapter->sta_info_lock);
Jeff Johnsonb157c722017-10-21 15:46:42 -0700814 hdd_err("Deinit station not inited %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530815 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 }
817
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700818 adapter->sta_info[sta_id].in_use = false;
819 adapter->sta_info[sta_id].is_deauth_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700821 spin_unlock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 return status;
823}
824
825/**
826 * hdd_softap_rx_packet_cbk() - Receive packet handler
Dhanashri Atre182b0272016-02-17 15:35:07 -0800827 * @context: pointer to HDD context
Nirav Shahcbc6d722016-03-01 16:24:53 +0530828 * @rxBuf: pointer to rx qdf_nbuf
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 *
830 * Receive callback registered with TL. TL will call this to notify
831 * the HDD when one or more packets were received for a registered
832 * STA.
833 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530834 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
835 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800837QDF_STATUS hdd_softap_rx_packet_cbk(void *context, qdf_nbuf_t rxBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700839 struct hdd_adapter *adapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840 int rxstat;
841 unsigned int cpu_index;
842 struct sk_buff *skb = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800843 struct sk_buff *next = NULL;
Jeff Johnson92402872017-09-03 09:25:37 -0700844 struct hdd_context *hdd_ctx = NULL;
Yun Parkc3e35562018-03-08 12:05:52 -0800845 struct qdf_mac_addr *src_mac;
Will Huang496b36c2017-07-11 16:38:50 +0800846 uint8_t staid;
Mohit Khannaf8f96822017-05-17 17:11:59 -0700847 bool proto_pkt_logged = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
849 /* Sanity check on inputs */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800850 if (unlikely((NULL == context) || (NULL == rxBuf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530851 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 "%s: Null params being passed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530853 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 }
855
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700856 adapter = (struct hdd_adapter *)context;
857 if (unlikely(WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800858 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre182b0272016-02-17 15:35:07 -0800859 "Magic cookie(%x) for adapter sanity verification is invalid",
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700860 adapter->magic);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530861 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 }
863
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700864 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson92402872017-09-03 09:25:37 -0700865 if (unlikely(NULL == hdd_ctx)) {
Dhanashri Atre182b0272016-02-17 15:35:07 -0800866 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
867 "%s: HDD context is Null", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530868 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 }
870
871 /* walk the chain until all are processed */
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800872 next = (struct sk_buff *)rxBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800874 while (next) {
875 skb = next;
876 next = skb->next;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800877 skb->next = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800878
psimha884025c2017-08-01 15:07:32 -0700879#ifdef QCA_WIFI_QCA6290 /* Debug code, remove later */
Yun Parke4239802018-01-09 11:01:40 -0800880 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson36e74c42017-09-18 08:15:42 -0700881 "%s: skb %pK skb->len %d\n", __func__, skb, skb->len);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800882#endif
883
Dhanashri Atre63d98022017-01-24 18:22:09 -0800884 hdd_softap_dump_sk_buff(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700886 skb->dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887
Dhanashri Atre63d98022017-01-24 18:22:09 -0800888 if (unlikely(skb->dev == NULL)) {
Yun Parkc3e35562018-03-08 12:05:52 -0800889 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
890 QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800891 "%s: ERROR!!Invalid netdevice", __func__);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800892 continue;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800893 }
894 cpu_index = wlan_hdd_get_cpu();
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700895 ++adapter->hdd_stats.tx_rx_stats.rx_packets[cpu_index];
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700896 ++adapter->stats.rx_packets;
897 adapter->stats.rx_bytes += skb->len;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800898
Yun Parkc3e35562018-03-08 12:05:52 -0800899 /* Send DHCP Indication to FW */
900 src_mac = (struct qdf_mac_addr *)(skb->data +
901 QDF_NBUF_SRC_MAC_OFFSET);
902 if (QDF_STATUS_SUCCESS ==
903 hdd_softap_get_sta_id(adapter, src_mac, &staid)) {
904 if (staid < WLAN_MAX_STA_COUNT) {
905 adapter->sta_info[staid].rx_packets++;
906 adapter->sta_info[staid].rx_bytes += skb->len;
907 adapter->sta_info[staid].last_tx_rx_ts =
908 qdf_system_ticks();
909 }
Will Huang496b36c2017-07-11 16:38:50 +0800910 }
Yun Parkc3e35562018-03-08 12:05:52 -0800911
912 hdd_inspect_dhcp_packet(adapter, staid, skb, QDF_RX);
913
Dhanashri Atre63d98022017-01-24 18:22:09 -0800914 hdd_event_eapol_log(skb, QDF_RX);
Jeff Johnson1b780e42017-10-31 14:11:45 -0700915 proto_pkt_logged = qdf_dp_trace_log_pkt(adapter->session_id,
Mohit Khannaf8f96822017-05-17 17:11:59 -0700916 skb, QDF_RX,
917 QDF_TRACE_DEFAULT_PDEV_ID);
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530918 DPTRACE(qdf_dp_trace(skb,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800919 QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700920 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530921 qdf_nbuf_data_addr(skb),
922 sizeof(qdf_nbuf_data(skb)), QDF_RX));
Mohit Khannaf8f96822017-05-17 17:11:59 -0700923 if (!proto_pkt_logged) {
924 DPTRACE(qdf_dp_trace(skb,
925 QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700926 QDF_TRACE_DEFAULT_PDEV_ID,
927 (uint8_t *)skb->data, qdf_nbuf_len(skb),
928 QDF_RX));
Mohit Khannaf8f96822017-05-17 17:11:59 -0700929 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
930 DPTRACE(qdf_dp_trace(skb,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530931 QDF_DP_TRACE_HDD_RX_PACKET_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700932 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530933 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
934 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE),
935 QDF_RX));
Mohit Khannaf8f96822017-05-17 17:11:59 -0700936 }
Dhanashri Atre63d98022017-01-24 18:22:09 -0800937
938 skb->protocol = eth_type_trans(skb, skb->dev);
939
940 /* hold configurable wakelock for unicast traffic */
Jeff Johnson92402872017-09-03 09:25:37 -0700941 if (hdd_ctx->config->rx_wakelock_timeout &&
Dhanashri Atre63d98022017-01-24 18:22:09 -0800942 skb->pkt_type != PACKET_BROADCAST &&
943 skb->pkt_type != PACKET_MULTICAST) {
Jeff Johnson92402872017-09-03 09:25:37 -0700944 cds_host_diag_log_work(&hdd_ctx->rx_wake_lock,
945 hdd_ctx->config->rx_wakelock_timeout,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800946 WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
Jeff Johnson92402872017-09-03 09:25:37 -0700947 qdf_wake_lock_timeout_acquire(&hdd_ctx->rx_wake_lock,
948 hdd_ctx->config->
Dhanashri Atre63d98022017-01-24 18:22:09 -0800949 rx_wakelock_timeout);
950 }
951
952 /* Remove SKB from internal tracking table before submitting
953 * it to stack
954 */
Manjunathappa Prakash17c07bd2017-04-27 21:24:28 -0700955 qdf_net_buf_debug_release_skb(skb);
Dhanashri Atre63d98022017-01-24 18:22:09 -0800956 if (hdd_napi_enabled(HDD_NAPI_ANY) &&
Jeff Johnsone2ba3cd2017-10-30 20:02:09 -0700957 !hdd_ctx->enable_rxthread)
Dhanashri Atre63d98022017-01-24 18:22:09 -0800958 rxstat = netif_receive_skb(skb);
959 else
960 rxstat = netif_rx_ni(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700961 if (NET_RX_SUCCESS == rxstat)
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700962 ++adapter->hdd_stats.tx_rx_stats.rx_delivered[cpu_index];
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700963 else
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700964 ++adapter->hdd_stats.tx_rx_stats.rx_refused[cpu_index];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530967 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968}
969
970/**
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700971 * hdd_softap_deregister_sta(struct hdd_adapter *adapter, uint8_t staId)
972 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 * @staId: Station ID to deregister
974 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530975 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700977QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700978 uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530980 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Jeff Johnson92402872017-09-03 09:25:37 -0700981 struct hdd_context *hdd_ctx;
Abhishek Singh07c627e2017-03-20 17:56:34 +0530982 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700984 if (NULL == adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800985 hdd_err("NULL adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530986 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 }
988
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700989 if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800990 hdd_err("Invalid adapter magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530991 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 }
993
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700994 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 /* Clear station in TL and then update HDD data
996 * structures. This helps to block RX frames from other
997 * station to this station.
998 */
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800999 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001000 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
1001 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301002 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001003 hdd_err("cdp_clear_peer failed for staID %d, Status=%d [0x%08X]",
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001004 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005 }
1006
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001007 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev,
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001008 adapter->sta_info[staId].
Jeff Johnsonf2356512017-10-21 16:04:12 -07001009 sta_mac.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301010 if (ret)
1011 hdd_err("Peer obj %pM delete fails",
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001012 adapter->sta_info[staId].sta_mac.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301013
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001014 if (adapter->sta_info[staId].in_use) {
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05301015 if (ucfg_ipa_is_enabled()) {
1016 ucfg_ipa_wlan_evt(hdd_ctx->hdd_pdev, adapter->dev,
1017 adapter->device_mode,
1018 adapter->sta_info[staId].sta_id,
1019 adapter->session_id,
1020 WLAN_IPA_CLIENT_DISCONNECT,
1021 adapter->sta_info[staId].sta_mac.
1022 bytes);
Will Huangac3fd9a2017-11-01 16:18:12 +08001023 }
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001024 spin_lock_bh(&adapter->sta_info_lock);
1025 qdf_mem_zero(&adapter->sta_info[staId],
Jeff Johnson82155922017-09-30 16:54:14 -07001026 sizeof(struct hdd_station_info));
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001027 spin_unlock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05301029
Jeff Johnson92402872017-09-03 09:25:37 -07001030 hdd_ctx->sta_to_adapter[staId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301032 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033}
1034
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001035QDF_STATUS hdd_softap_register_sta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 bool fAuthRequired,
1037 bool fPrivacyBit,
1038 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301039 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 bool fWmmEnabled)
1041{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301042 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001043 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001044 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001045 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001046 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1047 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001049 hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u",
1050 staId, fAuthRequired, fPrivacyBit, fWmmEnabled);
1051
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 /*
1053 * Clean up old entry if it is not cleaned up properly
1054 */
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001055 if (adapter->sta_info[staId].in_use) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001056 hdd_info("clean up old entry for STA %d", staId);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001057 hdd_softap_deregister_sta(adapter, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001060 /* Get the Station ID from the one saved during the assocation. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061 staDesc.sta_id = staId;
1062
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001063 /* Save the adapter Pointer for this staId */
1064 hdd_ctx->sta_to_adapter[staId] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301066 qdf_status =
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001067 hdd_softap_init_tx_rx_sta(adapter, staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 pPeerMacAddress);
1069
1070 staDesc.is_qos_enabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071
Dhanashri Atre182b0272016-02-17 15:35:07 -08001072 /* Register the vdev transmit and receive functions */
1073 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1074 txrx_ops.rx.rx = hdd_softap_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001075 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001076 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001077 (struct cdp_pdev *)pdev, adapter->session_id),
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001078 adapter, &txrx_ops);
1079 adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001080 (struct cdp_pdev *)pdev,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001081 adapter->session_id);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001082 adapter->tx_fn = txrx_ops.tx.tx;
Dhanashri Atre182b0272016-02-17 15:35:07 -08001083
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001084 qdf_status = cdp_peer_register(soc,
1085 (struct cdp_pdev *)pdev, &staDesc);
Dhanashri Atre50141c52016-04-07 13:15:29 -07001086 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001087 hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]",
1088 qdf_status, qdf_status);
Dhanashri Atre50141c52016-04-07 13:15:29 -07001089 return qdf_status;
1090 }
1091
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 /* if ( WPA ), tell TL to go to 'connected' and after keys come to the
1093 * driver then go to 'authenticated'. For all other authentication
1094 * types (those that do not require upper layer authentication) we can
1095 * put TL directly into 'authenticated' state
1096 */
1097
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001098 adapter->sta_info[staId].sta_id = staId;
1099 adapter->sta_info[staId].is_qos_enabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001100
1101 if (!fAuthRequired) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001102 hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time",
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001103 adapter->sta_info[staId].sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104
1105 /* Connections that do not need Upper layer auth,
1106 * transition TL directly to 'Authenticated' state.
1107 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001108 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001109 OL_TXRX_PEER_STATE_AUTH, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001111 adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_AUTH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112 } else {
1113
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001114 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001115 adapter->sta_info[staId].sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001116
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001117 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001118 OL_TXRX_PEER_STATE_CONN, false);
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001119 adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_CONN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120 }
1121
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001122 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001123 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
1125 WLAN_CONTROL_PATH);
1126
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301127 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128}
1129
1130/**
1131 * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001132 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133 * @fPrivacyBit: should 802.11 privacy bit be set?
1134 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301135 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001137QDF_STATUS hdd_softap_register_bc_sta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 bool fPrivacyBit)
1139{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301140 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001141 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Dustin Brownce5b3d32018-01-17 15:07:38 -08001142 struct qdf_mac_addr broadcastMacAddr = QDF_MAC_ADDR_BCAST_INIT;
Jeff Johnson9bf24972017-10-04 09:26:58 -07001143 struct hdd_ap_ctx *ap_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144
Jeff Johnson9bf24972017-10-04 09:26:58 -07001145 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001147 hdd_ctx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = adapter;
Jeff Johnson42518cf2017-10-26 13:33:29 -07001148 hdd_ctx->sta_to_adapter[ap_ctx->broadcast_sta_id] = adapter;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301149 qdf_status =
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001150 hdd_softap_register_sta(adapter, false, fPrivacyBit,
Jeff Johnson42518cf2017-10-26 13:33:29 -07001151 ap_ctx->broadcast_sta_id,
Jeff Johnson3f6c89f2018-03-01 14:27:38 -08001152 &broadcastMacAddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301154 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155}
1156
1157/**
1158 * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001159 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301161 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001163QDF_STATUS hdd_softap_deregister_bc_sta(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164{
Jeff Johnson42518cf2017-10-26 13:33:29 -07001165 struct hdd_ap_ctx *ap_ctx;
1166
1167 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
1168 return hdd_softap_deregister_sta(adapter, ap_ctx->broadcast_sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169}
1170
1171/**
1172 * hdd_softap_stop_bss() - Stop the BSS
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001173 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301175 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001177QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301179 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 uint8_t staId = 0;
Jeff Johnson92402872017-09-03 09:25:37 -07001181 struct hdd_context *hdd_ctx;
Srinivas Girigowdae806a822017-03-25 11:25:30 -07001182
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001183 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184
Rajeev Kumar07bbe122017-10-24 13:06:05 -07001185 /* This is stop bss callback running in scheduler thread so do not
1186 * driver unload in progress check otherwise it can lead to peer
1187 * object leak
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001189 qdf_status = hdd_softap_deregister_bc_sta(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301191 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson42518cf2017-10-26 13:33:29 -07001192 struct hdd_ap_ctx *ap_ctx;
1193
1194 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001195 hdd_err("Failed to deregister BC sta Id %d",
Jeff Johnson42518cf2017-10-26 13:33:29 -07001196 ap_ctx->broadcast_sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 }
1198
1199 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
1200 /* This excludes BC sta as it is already deregistered */
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001201 if (adapter->sta_info[staId].in_use) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001202 qdf_status = hdd_softap_deregister_sta(adapter, staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301203 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001204 hdd_err("Failed to deregister sta Id %d",
1205 staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206 }
1207 }
1208 }
Mukul Sharmaecf8e092017-12-19 22:36:31 +05301209
1210 /* Mark the indoor channel (passive) to enable */
1211 if (hdd_ctx->config->force_ssc_disable_indoor_channel) {
1212 hdd_update_indoor_channel(hdd_ctx, false);
1213 sme_update_channel_list(hdd_ctx->hHal);
1214 }
1215
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301216 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217}
1218
1219/**
1220 * hdd_softap_change_sta_state() - Change the state of a SoftAP station
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001221 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 * @pDestMacAddress: MAC address of the station
1223 * @state: new state of the station
1224 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301225 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001227QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301228 struct qdf_mac_addr *pDestMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 enum ol_txrx_peer_state state)
1230{
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001231 uint8_t sta_id = WLAN_MAX_STA_COUNT;
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001232 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233
Dustin Brownfdf17c12018-03-14 12:55:34 -07001234 hdd_enter_dev(adapter->dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001236 qdf_status = hdd_softap_get_sta_id(adapter, pDestMacAddress, &sta_id);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001237 if (QDF_STATUS_SUCCESS != qdf_status) {
1238 hdd_err("Failed to find right station");
1239 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 }
1241
1242 if (false ==
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001243 qdf_is_macaddr_equal(&adapter->sta_info[sta_id].sta_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 pDestMacAddress)) {
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001245 hdd_err("Station %u MAC address not matching", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301246 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 }
1248
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301249 qdf_status =
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001250 hdd_change_peer_state(adapter, sta_id, state, false);
1251 hdd_info("Station %u changed to state %d", sta_id, state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301253 if (QDF_STATUS_SUCCESS == qdf_status) {
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001254 adapter->sta_info[sta_id].peer_state =
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001255 OL_TXRX_PEER_STATE_AUTH;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001256 p2p_peer_authorized(adapter->hdd_vdev, pDestMacAddress->bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257 }
1258
Dustin Browne74003f2018-03-14 12:51:58 -07001259 hdd_exit();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301260 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261}
1262
1263/*
1264 * hdd_softap_get_sta_id() - Find station ID from MAC address
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001265 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266 * @pDestMacAddress: MAC address of the destination
1267 * @staId: Station ID associated with the MAC address
1268 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301269 * Return: QDF_STATUS_SUCCESS if a match was found, in which case
1270 * staId is populated, QDF_STATUS_E_FAILURE if a match is
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 * not found
1272 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001273QDF_STATUS hdd_softap_get_sta_id(struct hdd_adapter *adapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301274 struct qdf_mac_addr *pMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 uint8_t *staId)
1276{
1277 uint8_t i;
1278
1279 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301280 if (!qdf_mem_cmp
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001281 (&adapter->sta_info[i].sta_mac, pMacAddress,
1282 QDF_MAC_ADDR_SIZE) && adapter->sta_info[i].in_use) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283 *staId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301284 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 }
1286 }
1287
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301288 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289}