blob: 70f3d8db59fa139d59a325fc632532f7ef8b5d35 [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
90/**
91 * hdd_softap_tx_resume_timer_expired_handler() - TX Q resume timer handler
92 * @adapter_context: pointer to vdev adapter
93 *
94 * TX Q resume timer handler for SAP and P2P GO interface. If Blocked
95 * OS Q is not resumed during timeout period, to prevent permanent
96 * stall, resume OS Q forcefully for SAP and P2P GO interface.
97 *
98 * Return: None
99 */
100void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context)
101{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700102 struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700104 if (!adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800105 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106 return;
107 }
108
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700109 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700110 wlan_hdd_netif_queue_control(adapter, WLAN_WAKE_ALL_NETIF_QUEUE,
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800111 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112}
113
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530114#if defined(CONFIG_PER_VDEV_TX_DESC_POOL)
115
116/**
117 * hdd_softap_tx_resume_false() - Resume OS TX Q false leads to queue disabling
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700118 * @adapter: pointer to hdd adapter
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530119 * @tx_resume: TX Q resume trigger
120 *
121 *
122 * Return: None
123 */
124static void
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700125hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume)
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530126{
127 if (true == tx_resume)
128 return;
129
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700130 hdd_debug("Disabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700131 wlan_hdd_netif_queue_control(adapter, WLAN_STOP_ALL_NETIF_QUEUE,
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530132 WLAN_DATA_FLOW_CONTROL);
133
134 if (QDF_TIMER_STATE_STOPPED ==
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700135 qdf_mc_timer_get_current_state(&adapter->
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530136 tx_flow_control_timer)) {
137 QDF_STATUS status;
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700138
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700139 status = qdf_mc_timer_start(&adapter->tx_flow_control_timer,
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530140 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
141
142 if (!QDF_IS_STATUS_SUCCESS(status))
143 hdd_err("Failed to start tx_flow_control_timer");
144 else
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700145 adapter->hdd_stats.tx_rx_stats.txflow_timer_cnt++;
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530146 }
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530147}
148#else
149
150static inline void
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700151hdd_softap_tx_resume_false(struct hdd_adapter *adapter, bool tx_resume)
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530152{
Poddar, Siddarthb61cf642016-04-28 16:02:39 +0530153}
154#endif
155
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156/**
157 * hdd_softap_tx_resume_cb() - Resume OS TX Q.
158 * @adapter_context: pointer to vdev apdapter
159 * @tx_resume: TX Q resume trigger
160 *
161 * Q was stopped due to WLAN TX path low resource condition
162 *
163 * Return: None
164 */
165void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume)
166{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700167 struct hdd_adapter *adapter = (struct hdd_adapter *) adapter_context;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700169 if (!adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800170 hdd_err("NULL adapter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 return;
172 }
173
174 /* Resume TX */
175 if (true == tx_resume) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530176 if (QDF_TIMER_STATE_STOPPED !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700177 qdf_mc_timer_get_current_state(&adapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 tx_flow_control_timer)) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700179 qdf_mc_timer_stop(&adapter->tx_flow_control_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 }
181
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -0700182 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700183 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 WLAN_WAKE_ALL_NETIF_QUEUE,
185 WLAN_DATA_FLOW_CONTROL);
186 }
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700187 hdd_softap_tx_resume_false(adapter, tx_resume);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800188}
gbianec670c592016-11-24 11:21:30 +0800189
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700190static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter,
gbianec670c592016-11-24 11:21:30 +0800191 struct sk_buff *skb)
192{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700193 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800194 int need_orphan = 0;
195
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700196 if (adapter->tx_flow_low_watermark > 0) {
tfyubdf453e2017-09-27 13:34:30 +0800197#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
198 /*
199 * The TCP TX throttling logic is changed a little after
200 * 3.19-rc1 kernel, the TCP sending limit will be smaller,
201 * which will throttle the TCP packets to the host driver.
202 * The TCP UP LINK throughput will drop heavily. In order to
203 * fix this issue, need to orphan the socket buffer asap, which
204 * will call skb's destructor to notify the TCP stack that the
205 * SKB buffer is unowned. And then the TCP stack will pump more
206 * packets to host driver.
207 *
208 * The TX packets might be dropped for UDP case in the iperf
209 * testing. So need to be protected by follow control.
210 */
211 need_orphan = 1;
212#else
213 if (hdd_ctx->config->tx_orphan_enable)
214 need_orphan = 1;
215#endif
tfyu5f01db22017-10-11 13:51:04 +0800216 } else if (hdd_ctx->config->tx_orphan_enable) {
217 if (qdf_nbuf_is_ipv4_tcp_pkt(skb) ||
Tiger Yu438c6482017-10-13 11:07:00 +0800218 qdf_nbuf_is_ipv6_tcp_pkt(skb))
tfyu5f01db22017-10-11 13:51:04 +0800219 need_orphan = 1;
tfyubdf453e2017-09-27 13:34:30 +0800220 }
221
tfyu5f01db22017-10-11 13:51:04 +0800222 if (need_orphan) {
gbianec670c592016-11-24 11:21:30 +0800223 skb_orphan(skb);
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700224 ++adapter->hdd_stats.tx_rx_stats.tx_orphaned;
Tiger Yu438c6482017-10-13 11:07:00 +0800225 } else
gbianec670c592016-11-24 11:21:30 +0800226 skb = skb_unshare(skb, GFP_ATOMIC);
gbianec670c592016-11-24 11:21:30 +0800227
228 return skb;
229}
230
231#else
Mohit Khannad0b63f52017-02-18 18:05:52 -0800232/**
233 * hdd_skb_orphan() - skb_unshare a cloned packed else skb_orphan
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700234 * @adapter: pointer to HDD adapter
Mohit Khannad0b63f52017-02-18 18:05:52 -0800235 * @skb: pointer to skb data packet
236 *
237 * Return: pointer to skb structure
238 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700239static inline struct sk_buff *hdd_skb_orphan(struct hdd_adapter *adapter,
Mohit Khannad0b63f52017-02-18 18:05:52 -0800240 struct sk_buff *skb) {
gbianec670c592016-11-24 11:21:30 +0800241
Mohit Khannad0b63f52017-02-18 18:05:52 -0800242 struct sk_buff *nskb;
tfyubdf453e2017-09-27 13:34:30 +0800243#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700244 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
tfyubdf453e2017-09-27 13:34:30 +0800245#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800246
Mohit Khanna87493732017-08-27 23:26:44 -0700247 hdd_skb_fill_gso_size(adapter->dev, skb);
248
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700249 nskb = skb_unshare(skb, GFP_ATOMIC);
tfyubdf453e2017-09-27 13:34:30 +0800250#if (LINUX_VERSION_CODE > KERNEL_VERSION(3, 19, 0))
Manjunathappa Prakashdab74fa2017-06-19 12:11:03 -0700251 if (unlikely(hdd_ctx->config->tx_orphan_enable) && (nskb == skb)) {
Mohit Khannad0b63f52017-02-18 18:05:52 -0800252 /*
253 * For UDP packets we want to orphan the packet to allow the app
254 * to send more packets. The flow would ultimately be controlled
255 * by the limited number of tx descriptors for the vdev.
256 */
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700257 ++adapter->hdd_stats.tx_rx_stats.tx_orphaned;
Mohit Khannad0b63f52017-02-18 18:05:52 -0800258 skb_orphan(skb);
259 }
tfyubdf453e2017-09-27 13:34:30 +0800260#endif
Mohit Khannad0b63f52017-02-18 18:05:52 -0800261 return nskb;
gbianec670c592016-11-24 11:21:30 +0800262}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
264
265/**
Yun Parkc3e35562018-03-08 12:05:52 -0800266 * hdd_post_dhcp_ind() - Send DHCP START/STOP indication to FW
267 * @adapter: pointer to hdd adapter
268 * @sta_id: peer station ID
269 * @type: WMA message type
270 *
271 * Return: error number
272 */
273int hdd_post_dhcp_ind(struct hdd_adapter *adapter,
274 uint8_t sta_id, uint16_t type)
275{
276 tAniDHCPInd pmsg;
277 QDF_STATUS status = QDF_STATUS_SUCCESS;
278
279 hdd_debug("Post DHCP indication,sta_id=%d, type=%d", sta_id, type);
280
281 if (!adapter) {
282 hdd_err("NULL adapter");
283 return -EINVAL;
284 }
285
286 pmsg.msgType = type;
287 pmsg.msgLen = (uint16_t) sizeof(tAniDHCPInd);
288 pmsg.device_mode = adapter->device_mode;
289 qdf_mem_copy(pmsg.adapterMacAddr.bytes,
290 adapter->mac_addr.bytes,
291 QDF_MAC_ADDR_SIZE);
292 qdf_mem_copy(pmsg.peerMacAddr.bytes,
293 adapter->sta_info[sta_id].sta_mac.bytes,
294 QDF_MAC_ADDR_SIZE);
295
296 status = wma_process_dhcp_ind(cds_get_context(QDF_MODULE_ID_WMA),
297 &pmsg);
298 if (!QDF_IS_STATUS_SUCCESS(status)) {
299 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
300 "%s: Post DHCP Ind MSG fail", __func__);
301 return -EFAULT;
302 }
303
304 return 0;
305}
306
307/**
308 * hdd_inspect_dhcp_packet() - Inspect DHCP packet
309 * @adapter: pointer to hdd adapter
310 * @sta_id: peer station ID
311 * @skb: pointer to OS packet (sk_buff)
312 * @dir: direction
313 *
314 * Inspect the Tx/Rx frame, and send DHCP START/STOP notification to the FW
315 * through WMI message, during DHCP based IP address acquisition phase.
316 *
317 * - Send DHCP_START notification to FW when SAP gets DHCP Discovery
318 * - Send DHCP_STOP notification to FW when SAP sends DHCP ACK/NAK
319 *
320 * DHCP subtypes are determined by a status octet in the DHCP Message type
321 * option (option code 53 (0x35)).
322 *
323 * Each peer will be in one of 4 DHCP phases, starts from QDF_DHCP_PHASE_ACK,
324 * and transitioned per DHCP message type as it arrives.
325 *
326 * - QDF_DHCP_PHASE_DISCOVER: upon receiving DHCP_DISCOVER message in ACK phase
327 * - QDF_DHCP_PHASE_OFFER: upon receiving DHCP_OFFER message in DISCOVER phase
328 * - QDF_DHCP_PHASE_REQUEST: upon receiving DHCP_REQUEST message in OFFER phase
329 * or ACK phase (Renewal process)
330 * - QDF_DHCP_PHASE_ACK : upon receiving DHCP_ACK/NAK message in REQUEST phase
331 * or DHCP_DELINE message in OFFER phase
332 *
333 * Return: error number
334 */
335int hdd_inspect_dhcp_packet(struct hdd_adapter *adapter,
336 uint8_t sta_id,
337 struct sk_buff *skb,
338 enum qdf_proto_dir dir)
339{
340 enum qdf_proto_subtype subtype = QDF_PROTO_INVALID;
341 struct hdd_station_info *hdd_sta_info;
342 int errno = 0;
343
344 hdd_debug("sta_id=%d, dir=%d", sta_id, dir);
345
346 if ((adapter->device_mode == QDF_SAP_MODE) &&
347 ((dir == QDF_TX && QDF_NBUF_CB_PACKET_TYPE_DHCP ==
348 QDF_NBUF_CB_GET_PACKET_TYPE(skb)) ||
349 (dir == QDF_RX && qdf_nbuf_is_ipv4_dhcp_pkt(skb) == true))) {
350
351 subtype = qdf_nbuf_get_dhcp_subtype(skb);
352 hdd_sta_info = &adapter->sta_info[sta_id];
353
354 hdd_debug("ENTER: type=%d, phase=%d, nego_status=%d",
355 subtype,
356 hdd_sta_info->dhcp_phase,
357 hdd_sta_info->dhcp_nego_status);
358
359 switch (subtype) {
360 case QDF_PROTO_DHCP_DISCOVER:
361 if (dir != QDF_RX)
362 break;
363 if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP)
364 errno = hdd_post_dhcp_ind(adapter, sta_id,
365 WMA_DHCP_START_IND);
366 hdd_sta_info->dhcp_phase = DHCP_PHASE_DISCOVER;
367 hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS;
368 break;
369 case QDF_PROTO_DHCP_OFFER:
370 hdd_sta_info->dhcp_phase = DHCP_PHASE_OFFER;
371 break;
372 case QDF_PROTO_DHCP_REQUEST:
373 if (dir != QDF_RX)
374 break;
375 if (hdd_sta_info->dhcp_nego_status == DHCP_NEGO_STOP)
376 errno = hdd_post_dhcp_ind(adapter, sta_id,
377 WMA_DHCP_START_IND);
378 hdd_sta_info->dhcp_nego_status = DHCP_NEGO_IN_PROGRESS;
379 case QDF_PROTO_DHCP_DECLINE:
380 if (dir == QDF_RX)
381 hdd_sta_info->dhcp_phase = DHCP_PHASE_REQUEST;
382 break;
383 case QDF_PROTO_DHCP_ACK:
384 case QDF_PROTO_DHCP_NACK:
385 hdd_sta_info->dhcp_phase = DHCP_PHASE_ACK;
Yun Park0ac12822018-04-02 11:18:04 -0700386 if (hdd_sta_info->dhcp_nego_status ==
387 DHCP_NEGO_IN_PROGRESS)
Yun Parkc3e35562018-03-08 12:05:52 -0800388 errno = hdd_post_dhcp_ind(adapter, sta_id,
389 WMA_DHCP_STOP_IND);
390 hdd_sta_info->dhcp_nego_status = DHCP_NEGO_STOP;
391 break;
392 default:
393 break;
394 }
395
396 hdd_debug("EXIT: phase=%d, nego_status=%d",
397 hdd_sta_info->dhcp_phase,
398 hdd_sta_info->dhcp_nego_status);
399 }
400
401 return errno;
402}
403
404/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530405 * __hdd_softap_hard_start_xmit() - Transmit a frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406 * @skb: pointer to OS packet (sk_buff)
407 * @dev: pointer to network device
408 *
409 * Function registered with the Linux OS for transmitting
410 * packets. This version of the function directly passes
411 * the packet to Transport Layer.
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530412 * In case of any packet drop or error, log the error with
413 * INFO HIGH/LOW/MEDIUM to avoid excessive logging in kmsg.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414 *
415 * Return: Always returns NETDEV_TX_OK
416 */
Srinivas Girigowda49b48b22018-04-05 09:23:28 -0700417static netdev_tx_t __hdd_softap_hard_start_xmit(struct sk_buff *skb,
418 struct net_device *dev)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800419{
420 sme_ac_enum_type ac = SME_AC_BE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700421 struct hdd_adapter *adapter = (struct hdd_adapter *) netdev_priv(dev);
Jeff Johnson9bf24972017-10-04 09:26:58 -0700422 struct hdd_ap_ctx *ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530423 struct qdf_mac_addr *pDestMacAddress;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424 uint8_t STAId;
Will Huang496b36c2017-07-11 16:38:50 +0800425 uint32_t num_seg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700427 ++adapter->hdd_stats.tx_rx_stats.tx_called;
428 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530429
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 /* Prevent this function from being called during SSR since TL
431 * context may not be reinitialized at this time which may
432 * lead to a crash.
433 */
Will Huang20de9432018-02-06 17:01:03 +0800434 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state() ||
435 cds_is_load_or_unload_in_progress()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530436 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Will Huang20de9432018-02-06 17:01:03 +0800437 "%s: Recovery/(Un)load in Progress. Ignore!!!",
438 __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 goto drop_pkt;
440 }
441
442 /*
443 * If the device is operating on a DFS Channel
444 * then check if SAP is in CAC WAIT state and
445 * drop the packets. In CAC WAIT state device
446 * is expected not to transmit any frames.
447 * SAP starts Tx only after the BSS START is
448 * done.
449 */
Jeff Johnson9bf24972017-10-04 09:26:58 -0700450 if (ap_ctx->dfs_cac_block_tx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800453 /*
Jeff Johnson4fca3b52017-01-12 08:44:18 -0800454 * If a transmit function is not registered, drop packet
455 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700456 if (!adapter->tx_fn) {
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800457 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
458 "%s: TX function not registered by the data path",
459 __func__);
460 goto drop_pkt;
461 }
462
Nirav Shah5e74bb82016-07-20 16:01:27 +0530463 wlan_hdd_classify_pkt(skb);
464
Anurag Chouhan6d760662016-02-20 16:05:43 +0530465 pDestMacAddress = (struct qdf_mac_addr *) skb->data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466
Nirav Shah5e74bb82016-07-20 16:01:27 +0530467 if (QDF_NBUF_CB_GET_IS_BCAST(skb) ||
468 QDF_NBUF_CB_GET_IS_MCAST(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469 /* The BC/MC station ID is assigned during BSS
470 * starting phase. SAP will return the station ID
471 * used for BC/MC traffic.
472 */
Jeff Johnson42518cf2017-10-26 13:33:29 -0700473 STAId = ap_ctx->broadcast_sta_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800474 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530475 if (QDF_STATUS_SUCCESS !=
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700476 hdd_softap_get_sta_id(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 pDestMacAddress, &STAId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530478 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530479 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 "%s: Failed to find right station", __func__);
481 goto drop_pkt;
482 }
483
Prakash Dhavali3107b752016-11-28 14:35:06 +0530484 if (STAId >= WLAN_MAX_STA_COUNT) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530485 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530486 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487 "%s: Failed to find right station", __func__);
488 goto drop_pkt;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700489 } else if (false == adapter->sta_info[STAId].in_use) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530490 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530491 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 "%s: STA %d is unregistered", __func__,
493 STAId);
494 goto drop_pkt;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700495 } else if (true == adapter->sta_info[STAId].
Jeff Johnsone4f5d932017-10-21 13:21:15 -0700496 is_deauth_in_progress) {
Poddar, Siddartha5075462017-03-16 19:20:09 +0530497 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530498 QDF_TRACE_LEVEL_INFO_HIGH,
Poddar, Siddartha5075462017-03-16 19:20:09 +0530499 "%s: STA %d deauth in progress", __func__,
500 STAId);
501 goto drop_pkt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 }
503
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800504 if ((OL_TXRX_PEER_STATE_CONN !=
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700505 adapter->sta_info[STAId].peer_state)
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800506 && (OL_TXRX_PEER_STATE_AUTH !=
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700507 adapter->sta_info[STAId].peer_state)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530508 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530509 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 "%s: Station not connected yet", __func__);
511 goto drop_pkt;
Dhanashri Atreb08959a2016-03-01 17:28:03 -0800512 } else if (OL_TXRX_PEER_STATE_CONN ==
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700513 adapter->sta_info[STAId].peer_state) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514 if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530515 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530516 QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 "%s: NON-EAPOL packet in non-Authenticated state",
518 __func__);
519 goto drop_pkt;
520 }
521 }
522 }
523
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700524 hdd_get_tx_resource(adapter, STAId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
526
527 /* Get TL AC corresponding to Qdisc queue index/AC. */
528 ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping];
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700529 ++adapter->hdd_stats.tx_rx_stats.tx_classified_ac[ac];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700531#if defined(IPA_OFFLOAD)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530532 if (!qdf_nbuf_ipa_owned_get(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533#endif
gbianec670c592016-11-24 11:21:30 +0800534
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700535 skb = hdd_skb_orphan(adapter, skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 if (!skb)
Jeff Johnsonedeff232015-11-11 17:19:42 -0800537 goto drop_pkt_accounting;
gbianec670c592016-11-24 11:21:30 +0800538
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700539#if defined(IPA_OFFLOAD)
Yun Park01deb2c2017-06-14 15:21:44 -0700540 } else {
541 /*
542 * Clear the IPA ownership after check it to avoid ipa_free_skb
543 * is called when Tx completed for intra-BSS Tx packets
544 */
545 qdf_nbuf_ipa_owned_clear(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546 }
547#endif
548
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530549 /*
550 * Add SKB to internal tracking table before further processing
551 * in WLAN driver.
552 */
553 qdf_net_buf_debug_acquire_skb(skb, __FILE__, __LINE__);
554
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700555 adapter->stats.tx_bytes += skb->len;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700556 adapter->sta_info[STAId].tx_bytes += skb->len;
Mohit Khannab1dd1e82017-02-04 15:14:38 -0800557
Will Huang496b36c2017-07-11 16:38:50 +0800558 if (qdf_nbuf_is_tso(skb)) {
559 num_seg = qdf_nbuf_get_tso_num_seg(skb);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700560 adapter->stats.tx_packets += num_seg;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700561 adapter->sta_info[STAId].tx_packets += num_seg;
Will Huang496b36c2017-07-11 16:38:50 +0800562 } else {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700563 ++adapter->stats.tx_packets;
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700564 adapter->sta_info[STAId].tx_packets++;
Will Huang496b36c2017-07-11 16:38:50 +0800565 }
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700566 adapter->sta_info[STAId].last_tx_rx_ts = qdf_system_ticks();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800567
Yun Parkc3e35562018-03-08 12:05:52 -0800568 if (STAId != ap_ctx->broadcast_sta_id)
569 hdd_inspect_dhcp_packet(adapter, STAId, skb, QDF_TX);
570
Nirav Shah5e74bb82016-07-20 16:01:27 +0530571 hdd_event_eapol_log(skb, QDF_TX);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530572 QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
573 QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD);
Nirav Shah0d58a7e2016-04-26 22:54:12 +0530574 qdf_dp_trace_set_track(skb, QDF_TX);
575 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_TX_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700576 QDF_TRACE_DEFAULT_PDEV_ID, qdf_nbuf_data_addr(skb),
577 sizeof(qdf_nbuf_data(skb)),
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530578 QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579
jinweic chen51046012018-04-11 16:02:22 +0800580 /* check whether need to linearize skb, like non-linear udp data */
581 if (hdd_skb_nontso_linearize(skb) != QDF_STATUS_SUCCESS) {
582 QDF_TRACE(QDF_MODULE_ID_HDD_DATA,
583 QDF_TRACE_LEVEL_INFO_HIGH,
584 "%s: skb %pK linearize failed. drop the pkt",
585 __func__, skb);
586 ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac];
587 goto drop_pkt_and_release_skb;
588 }
589
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700590 if (adapter->tx_fn(adapter->txrx_vdev,
Dhanashri Atre168d2b42016-02-22 14:43:06 -0800591 (qdf_nbuf_t) skb) != NULL) {
Poddar, Siddarth31b9b8b2017-04-07 12:04:55 +0530592 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 "%s: Failed to send packet to txrx for staid:%d",
594 __func__, STAId);
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700595 ++adapter->hdd_stats.tx_rx_stats.tx_dropped_ac[ac];
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530596 goto drop_pkt_and_release_skb;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 }
Dustin Browne0024fa2016-10-14 16:29:21 -0700598 netif_trans_update(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599
600 return NETDEV_TX_OK;
601
Himanshu Agarwal53298d12017-02-20 19:14:17 +0530602drop_pkt_and_release_skb:
603 qdf_net_buf_debug_release_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604drop_pkt:
605
Mohit Khanna02281da2017-08-27 09:40:55 -0700606 qdf_dp_trace_data_pkt(skb, QDF_TRACE_DEFAULT_PDEV_ID,
607 QDF_DP_TRACE_DROP_PACKET_RECORD, 0,
608 QDF_TX);
Jeff Johnsonedeff232015-11-11 17:19:42 -0800609 kfree_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610
Jeff Johnsonedeff232015-11-11 17:19:42 -0800611drop_pkt_accounting:
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700612 ++adapter->stats.tx_dropped;
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700613 ++adapter->hdd_stats.tx_rx_stats.tx_dropped;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614
615 return NETDEV_TX_OK;
616}
617
618/**
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530619 * hdd_softap_hard_start_xmit() - Wrapper function to protect
620 * __hdd_softap_hard_start_xmit from SSR
621 * @skb: pointer to OS packet
622 * @dev: pointer to net_device structure
623 *
624 * Function called by OS if any packet needs to transmit.
625 *
626 * Return: Always returns NETDEV_TX_OK
627 */
Srinivas Girigowda49b48b22018-04-05 09:23:28 -0700628netdev_tx_t hdd_softap_hard_start_xmit(struct sk_buff *skb,
629 struct net_device *dev)
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530630{
Srinivas Girigowda49b48b22018-04-05 09:23:28 -0700631 netdev_tx_t ret;
Mukul Sharmac4de4ef2016-09-12 15:39:00 +0530632
633 cds_ssr_protect(__func__);
634 ret = __hdd_softap_hard_start_xmit(skb, dev);
635 cds_ssr_unprotect(__func__);
636
637 return ret;
638}
639
640/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641 * __hdd_softap_tx_timeout() - TX timeout handler
642 * @dev: pointer to network device
643 *
644 * This function is registered as a netdev ndo_tx_timeout method, and
645 * is invoked by the kernel if the driver takes too long to transmit a
646 * frame.
647 *
648 * Return: None
649 */
650static void __hdd_softap_tx_timeout(struct net_device *dev)
651{
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700652 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsonf7726872017-08-28 11:38:31 -0700653 struct hdd_context *hdd_ctx;
Nirav Shah89223f72016-03-01 18:10:38 +0530654 struct netdev_queue *txq;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530655 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Nirav Shah89223f72016-03-01 18:10:38 +0530656 int i;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530658 DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700659 QDF_TRACE_DEFAULT_PDEV_ID,
660 NULL, 0, QDF_TX));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661 /* Getting here implies we disabled the TX queues for too
662 * long. Queues are disabled either because of disassociation
663 * or low resource scenarios. In case of disassociation it is
664 * ok to ignore this. But if associated, we have do possible
665 * recovery here
666 */
667 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Hanumanth Reddy Pothula2a8a7402017-07-03 14:06:11 +0530668 if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530669 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800670 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 return;
672 }
Nirav Shah89223f72016-03-01 18:10:38 +0530673
Dustin Browne0024fa2016-10-14 16:29:21 -0700674 TX_TIMEOUT_TRACE(dev, QDF_MODULE_ID_HDD_SAP_DATA);
Nirav Shah89223f72016-03-01 18:10:38 +0530675
676 for (i = 0; i < NUM_TX_QUEUES; i++) {
677 txq = netdev_get_tx_queue(dev, i);
678 QDF_TRACE(QDF_MODULE_ID_HDD_DATA,
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800679 QDF_TRACE_LEVEL_DEBUG,
680 "Queue: %d status: %d txq->trans_start: %lu",
Nirav Shah89223f72016-03-01 18:10:38 +0530681 i, netif_tx_queue_stopped(txq), txq->trans_start);
682 }
683
Mohit Khannaca4173b2017-09-12 21:52:19 -0700684 wlan_hdd_display_netif_queue_history(hdd_ctx,
685 QDF_STATS_VERBOSITY_LEVEL_HIGH);
Leo Changfdb45c32016-10-28 11:09:23 -0700686 cdp_dump_flow_pool_info(cds_get_context(QDF_MODULE_ID_SOC));
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800687 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Nirav Shah89223f72016-03-01 18:10:38 +0530688 "carrier state: %d", netif_carrier_ok(dev));
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530689
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700690 ++adapter->hdd_stats.tx_rx_stats.tx_timeout_cnt;
691 ++adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530692
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700693 if (adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt >
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530694 HDD_TX_STALL_THRESHOLD) {
695 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
696 "Detected data stall due to continuous TX timeouts");
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700697 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Poddar, Siddarth37033032017-10-11 15:47:40 +0530698 if (hdd_ctx->config->enable_data_stall_det)
699 cdp_post_data_stall_event(soc,
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +0530700 DATA_STALL_LOG_INDICATOR_HOST_DRIVER,
701 DATA_STALL_LOG_HOST_SOFTAP_TX_TIMEOUT,
702 0xFF, 0xFF,
703 DATA_STALL_LOG_RECOVERY_TRIGGER_PDR);
704 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705}
706
707/**
708 * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout
709 * @dev: pointer to net_device
710 *
711 * Return: none
712 */
713void hdd_softap_tx_timeout(struct net_device *dev)
714{
715 cds_ssr_protect(__func__);
716 __hdd_softap_tx_timeout(dev);
717 cds_ssr_unprotect(__func__);
718}
719
720/**
721 * @hdd_softap_init_tx_rx() - Initialize Tx/RX module
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700722 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530724 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
725 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700727QDF_STATUS hdd_softap_init_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530729 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730
731 uint8_t STAId = 0;
732
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700733 qdf_mem_zero(&adapter->stats, sizeof(struct net_device_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700735 spin_lock_init(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736
737 for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) {
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700738 qdf_mem_zero(&adapter->sta_info[STAId],
Jeff Johnson82155922017-09-30 16:54:14 -0700739 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 }
741
742 return status;
743}
744
745/**
746 * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700747 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530749 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
750 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700752QDF_STATUS hdd_softap_deinit_tx_rx(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700754 if (adapter == NULL) {
755 hdd_err("Called with adapter = NULL.");
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800756 return QDF_STATUS_E_FAILURE;
757 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700759 adapter->txrx_vdev = NULL;
760 adapter->tx_fn = NULL;
Dhanashri Atreed3bf512017-02-21 12:25:53 -0800761 hdd_info("Deregistering TX function hook !");
762 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763}
764
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700765QDF_STATUS hdd_softap_init_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnson349d9a92017-10-21 15:38:03 -0700766 uint8_t sta_id,
767 struct qdf_mac_addr *sta_mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768{
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700769 spin_lock_bh(&adapter->sta_info_lock);
770 if (adapter->sta_info[sta_id].in_use) {
771 spin_unlock_bh(&adapter->sta_info_lock);
Jeff Johnson349d9a92017-10-21 15:38:03 -0700772 hdd_err("Reinit of in use station %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530773 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 }
775
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700776 qdf_mem_zero(&adapter->sta_info[sta_id],
Jeff Johnson82155922017-09-30 16:54:14 -0700777 sizeof(struct hdd_station_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700779 adapter->sta_info[sta_id].in_use = true;
780 adapter->sta_info[sta_id].is_deauth_in_progress = false;
781 qdf_copy_macaddr(&adapter->sta_info[sta_id].sta_mac, sta_mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800782
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700783 spin_unlock_bh(&adapter->sta_info_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530784 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785}
786
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700787QDF_STATUS hdd_softap_deinit_tx_rx_sta(struct hdd_adapter *adapter,
Jeff Johnsonb157c722017-10-21 15:46:42 -0700788 uint8_t sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530790 QDF_STATUS status = QDF_STATUS_SUCCESS;
Jeff Johnson5c19ade2017-10-04 09:52:12 -0700791 struct hdd_hostapd_state *hostapd_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792
Jeff Johnson5c19ade2017-10-04 09:52:12 -0700793 hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700795 spin_lock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700797 if (false == adapter->sta_info[sta_id].in_use) {
798 spin_unlock_bh(&adapter->sta_info_lock);
Jeff Johnsonb157c722017-10-21 15:46:42 -0700799 hdd_err("Deinit station not inited %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530800 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 }
802
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700803 adapter->sta_info[sta_id].in_use = false;
804 adapter->sta_info[sta_id].is_deauth_in_progress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700806 spin_unlock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 return status;
808}
809
810/**
811 * hdd_softap_rx_packet_cbk() - Receive packet handler
Dhanashri Atre182b0272016-02-17 15:35:07 -0800812 * @context: pointer to HDD context
Nirav Shahcbc6d722016-03-01 16:24:53 +0530813 * @rxBuf: pointer to rx qdf_nbuf
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 *
815 * Receive callback registered with TL. TL will call this to notify
816 * the HDD when one or more packets were received for a registered
817 * STA.
818 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530819 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
820 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800822QDF_STATUS hdd_softap_rx_packet_cbk(void *context, qdf_nbuf_t rxBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823{
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700824 struct hdd_adapter *adapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 int rxstat;
826 unsigned int cpu_index;
827 struct sk_buff *skb = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800828 struct sk_buff *next = NULL;
Jeff Johnson92402872017-09-03 09:25:37 -0700829 struct hdd_context *hdd_ctx = NULL;
Yun Parkc3e35562018-03-08 12:05:52 -0800830 struct qdf_mac_addr *src_mac;
Mohit Khanna02281da2017-08-27 09:40:55 -0700831
Will Huang496b36c2017-07-11 16:38:50 +0800832 uint8_t staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800833
834 /* Sanity check on inputs */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800835 if (unlikely((NULL == context) || (NULL == rxBuf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530836 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 "%s: Null params being passed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530838 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 }
840
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700841 adapter = (struct hdd_adapter *)context;
842 if (unlikely(WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda028c4482017-03-09 18:52:02 -0800843 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre182b0272016-02-17 15:35:07 -0800844 "Magic cookie(%x) for adapter sanity verification is invalid",
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700845 adapter->magic);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530846 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 }
848
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700849 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnson92402872017-09-03 09:25:37 -0700850 if (unlikely(NULL == hdd_ctx)) {
Dhanashri Atre182b0272016-02-17 15:35:07 -0800851 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
852 "%s: HDD context is Null", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530853 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 }
855
856 /* walk the chain until all are processed */
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800857 next = (struct sk_buff *)rxBuf;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800859 while (next) {
860 skb = next;
861 next = skb->next;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800862 skb->next = NULL;
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800863
psimha884025c2017-08-01 15:07:32 -0700864#ifdef QCA_WIFI_QCA6290 /* Debug code, remove later */
Yun Parke4239802018-01-09 11:01:40 -0800865 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson36e74c42017-09-18 08:15:42 -0700866 "%s: skb %pK skb->len %d\n", __func__, skb, skb->len);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800867#endif
868
Dhanashri Atre63d98022017-01-24 18:22:09 -0800869 hdd_softap_dump_sk_buff(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700871 skb->dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872
Dhanashri Atre63d98022017-01-24 18:22:09 -0800873 if (unlikely(skb->dev == NULL)) {
Yun Parkc3e35562018-03-08 12:05:52 -0800874 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
875 QDF_TRACE_LEVEL_ERROR,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800876 "%s: ERROR!!Invalid netdevice", __func__);
Dhanashri Atrecefa8802017-02-02 16:17:14 -0800877 continue;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800878 }
879 cpu_index = wlan_hdd_get_cpu();
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700880 ++adapter->hdd_stats.tx_rx_stats.rx_packets[cpu_index];
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700881 ++adapter->stats.rx_packets;
882 adapter->stats.rx_bytes += skb->len;
Dhanashri Atre63d98022017-01-24 18:22:09 -0800883
Yun Parkc3e35562018-03-08 12:05:52 -0800884 /* Send DHCP Indication to FW */
885 src_mac = (struct qdf_mac_addr *)(skb->data +
886 QDF_NBUF_SRC_MAC_OFFSET);
887 if (QDF_STATUS_SUCCESS ==
888 hdd_softap_get_sta_id(adapter, src_mac, &staid)) {
889 if (staid < WLAN_MAX_STA_COUNT) {
890 adapter->sta_info[staid].rx_packets++;
891 adapter->sta_info[staid].rx_bytes += skb->len;
892 adapter->sta_info[staid].last_tx_rx_ts =
893 qdf_system_ticks();
894 }
Will Huang496b36c2017-07-11 16:38:50 +0800895 }
Yun Parkc3e35562018-03-08 12:05:52 -0800896
897 hdd_inspect_dhcp_packet(adapter, staid, skb, QDF_RX);
898
Dhanashri Atre63d98022017-01-24 18:22:09 -0800899 hdd_event_eapol_log(skb, QDF_RX);
Mohit Khanna02281da2017-08-27 09:40:55 -0700900 qdf_dp_trace_log_pkt(adapter->session_id,
901 skb, QDF_RX, QDF_TRACE_DEFAULT_PDEV_ID);
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530902 DPTRACE(qdf_dp_trace(skb,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800903 QDF_DP_TRACE_RX_HDD_PACKET_PTR_RECORD,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -0700904 QDF_TRACE_DEFAULT_PDEV_ID,
Himanshu Agarwalee3411a2017-01-31 12:56:47 +0530905 qdf_nbuf_data_addr(skb),
906 sizeof(qdf_nbuf_data(skb)), QDF_RX));
Mohit Khanna02281da2017-08-27 09:40:55 -0700907 DPTRACE(qdf_dp_trace_data_pkt(skb, QDF_TRACE_DEFAULT_PDEV_ID,
908 QDF_DP_TRACE_RX_PACKET_RECORD, 0, QDF_RX));
Dhanashri Atre63d98022017-01-24 18:22:09 -0800909
910 skb->protocol = eth_type_trans(skb, skb->dev);
911
912 /* hold configurable wakelock for unicast traffic */
Jeff Johnson92402872017-09-03 09:25:37 -0700913 if (hdd_ctx->config->rx_wakelock_timeout &&
Dhanashri Atre63d98022017-01-24 18:22:09 -0800914 skb->pkt_type != PACKET_BROADCAST &&
915 skb->pkt_type != PACKET_MULTICAST) {
Jeff Johnson92402872017-09-03 09:25:37 -0700916 cds_host_diag_log_work(&hdd_ctx->rx_wake_lock,
917 hdd_ctx->config->rx_wakelock_timeout,
Dhanashri Atre63d98022017-01-24 18:22:09 -0800918 WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
Jeff Johnson92402872017-09-03 09:25:37 -0700919 qdf_wake_lock_timeout_acquire(&hdd_ctx->rx_wake_lock,
920 hdd_ctx->config->
Dhanashri Atre63d98022017-01-24 18:22:09 -0800921 rx_wakelock_timeout);
922 }
923
924 /* Remove SKB from internal tracking table before submitting
925 * it to stack
926 */
Manjunathappa Prakash17c07bd2017-04-27 21:24:28 -0700927 qdf_net_buf_debug_release_skb(skb);
Dhanashri Atre63d98022017-01-24 18:22:09 -0800928 if (hdd_napi_enabled(HDD_NAPI_ANY) &&
Jeff Johnsone2ba3cd2017-10-30 20:02:09 -0700929 !hdd_ctx->enable_rxthread)
Dhanashri Atre63d98022017-01-24 18:22:09 -0800930 rxstat = netif_receive_skb(skb);
931 else
932 rxstat = netif_rx_ni(skb);
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700933 if (NET_RX_SUCCESS == rxstat)
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700934 ++adapter->hdd_stats.tx_rx_stats.rx_delivered[cpu_index];
Srinivas Girigowdae806a822017-03-25 11:25:30 -0700935 else
Jeff Johnson6ced42c2017-10-20 12:48:11 -0700936 ++adapter->hdd_stats.tx_rx_stats.rx_refused[cpu_index];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530939 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940}
941
942/**
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700943 * hdd_softap_deregister_sta(struct hdd_adapter *adapter, uint8_t staId)
944 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945 * @staId: Station ID to deregister
946 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530947 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700949QDF_STATUS hdd_softap_deregister_sta(struct hdd_adapter *adapter,
Jeff Johnson18dd7e12017-08-29 14:22:28 -0700950 uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530952 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Jeff Johnson92402872017-09-03 09:25:37 -0700953 struct hdd_context *hdd_ctx;
Abhishek Singh07c627e2017-03-20 17:56:34 +0530954 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700956 if (NULL == adapter) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800957 hdd_err("NULL adapter");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530958 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 }
960
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700961 if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800962 hdd_err("Invalid adapter magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530963 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 }
965
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700966 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 /* Clear station in TL and then update HDD data
968 * structures. This helps to block RX frames from other
969 * station to this station.
970 */
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800971 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -0800972 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
973 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530974 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -0800975 hdd_err("cdp_clear_peer failed for staID %d, Status=%d [0x%08X]",
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -0800976 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 }
978
Jeff Johnsond31ab6a2017-10-02 13:23:51 -0700979 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev,
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700980 adapter->sta_info[staId].
Jeff Johnsonf2356512017-10-21 16:04:12 -0700981 sta_mac.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +0530982 if (ret)
983 hdd_err("Peer obj %pM delete fails",
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700984 adapter->sta_info[staId].sta_mac.bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +0530985
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700986 if (adapter->sta_info[staId].in_use) {
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +0530987 if (ucfg_ipa_is_enabled()) {
Yun Parka9d0c112018-03-07 14:11:27 -0800988 if (ucfg_ipa_wlan_evt(hdd_ctx->hdd_pdev, adapter->dev,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +0530989 adapter->device_mode,
990 adapter->sta_info[staId].sta_id,
991 adapter->session_id,
992 WLAN_IPA_CLIENT_DISCONNECT,
993 adapter->sta_info[staId].sta_mac.
Yun Parka9d0c112018-03-07 14:11:27 -0800994 bytes) != QDF_STATUS_SUCCESS)
995 hdd_err("WLAN_CLIENT_DISCONNECT event failed");
Will Huangac3fd9a2017-11-01 16:18:12 +0800996 }
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -0700997 spin_lock_bh(&adapter->sta_info_lock);
998 qdf_mem_zero(&adapter->sta_info[staId],
Jeff Johnson82155922017-09-30 16:54:14 -0700999 sizeof(struct hdd_station_info));
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001000 spin_unlock_bh(&adapter->sta_info_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05301002
Jeff Johnson92402872017-09-03 09:25:37 -07001003 hdd_ctx->sta_to_adapter[staId] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301005 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006}
1007
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001008QDF_STATUS hdd_softap_register_sta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 bool fAuthRequired,
1010 bool fPrivacyBit,
1011 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301012 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 bool fWmmEnabled)
1014{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301015 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001017 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001018 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001019 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1020 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001022 hdd_info("STA:%u, Auth:%u, Priv:%u, WMM:%u",
1023 staId, fAuthRequired, fPrivacyBit, fWmmEnabled);
1024
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 /*
1026 * Clean up old entry if it is not cleaned up properly
1027 */
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001028 if (adapter->sta_info[staId].in_use) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001029 hdd_info("clean up old entry for STA %d", staId);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001030 hdd_softap_deregister_sta(adapter, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001033 /* Get the Station ID from the one saved during the assocation. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 staDesc.sta_id = staId;
1035
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001036 /* Save the adapter Pointer for this staId */
1037 hdd_ctx->sta_to_adapter[staId] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301039 qdf_status =
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001040 hdd_softap_init_tx_rx_sta(adapter, staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 pPeerMacAddress);
1042
1043 staDesc.is_qos_enabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044
Dhanashri Atre182b0272016-02-17 15:35:07 -08001045 /* Register the vdev transmit and receive functions */
1046 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1047 txrx_ops.rx.rx = hdd_softap_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001048 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001049 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001050 (struct cdp_pdev *)pdev, adapter->session_id),
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001051 adapter, &txrx_ops);
1052 adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001053 (struct cdp_pdev *)pdev,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001054 adapter->session_id);
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001055 adapter->tx_fn = txrx_ops.tx.tx;
Dhanashri Atre182b0272016-02-17 15:35:07 -08001056
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001057 qdf_status = cdp_peer_register(soc,
1058 (struct cdp_pdev *)pdev, &staDesc);
Dhanashri Atre50141c52016-04-07 13:15:29 -07001059 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001060 hdd_err("cdp_peer_register() failed to register. Status = %d [0x%08X]",
1061 qdf_status, qdf_status);
Dhanashri Atre50141c52016-04-07 13:15:29 -07001062 return qdf_status;
1063 }
1064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065 /* if ( WPA ), tell TL to go to 'connected' and after keys come to the
1066 * driver then go to 'authenticated'. For all other authentication
1067 * types (those that do not require upper layer authentication) we can
1068 * put TL directly into 'authenticated' state
1069 */
1070
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001071 adapter->sta_info[staId].sta_id = staId;
1072 adapter->sta_info[staId].is_qos_enabled = fWmmEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073
1074 if (!fAuthRequired) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001075 hdd_info("open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time",
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001076 adapter->sta_info[staId].sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077
1078 /* Connections that do not need Upper layer auth,
1079 * transition TL directly to 'Authenticated' state.
1080 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001081 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001082 OL_TXRX_PEER_STATE_AUTH, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001084 adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_AUTH;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 } else {
1086
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001087 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001088 adapter->sta_info[staId].sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001090 qdf_status = hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001091 OL_TXRX_PEER_STATE_CONN, false);
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001092 adapter->sta_info[staId].peer_state = OL_TXRX_PEER_STATE_CONN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 }
1094
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001095 hdd_debug("Enabling queues");
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001096 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001097 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
1098 WLAN_CONTROL_PATH);
1099
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301100 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101}
1102
1103/**
1104 * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001105 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 * @fPrivacyBit: should 802.11 privacy bit be set?
1107 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301108 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001110QDF_STATUS hdd_softap_register_bc_sta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111 bool fPrivacyBit)
1112{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301113 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001114 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Dustin Brownce5b3d32018-01-17 15:07:38 -08001115 struct qdf_mac_addr broadcastMacAddr = QDF_MAC_ADDR_BCAST_INIT;
Jeff Johnson9bf24972017-10-04 09:26:58 -07001116 struct hdd_ap_ctx *ap_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117
Jeff Johnson9bf24972017-10-04 09:26:58 -07001118 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001120 hdd_ctx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = adapter;
Jeff Johnson42518cf2017-10-26 13:33:29 -07001121 hdd_ctx->sta_to_adapter[ap_ctx->broadcast_sta_id] = adapter;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301122 qdf_status =
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001123 hdd_softap_register_sta(adapter, false, fPrivacyBit,
Jeff Johnson42518cf2017-10-26 13:33:29 -07001124 ap_ctx->broadcast_sta_id,
Jeff Johnson3f6c89f2018-03-01 14:27:38 -08001125 &broadcastMacAddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301127 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128}
1129
1130/**
1131 * hdd_softap_deregister_bc_sta() - Deregister 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 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301134 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001136QDF_STATUS hdd_softap_deregister_bc_sta(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137{
Jeff Johnson42518cf2017-10-26 13:33:29 -07001138 struct hdd_ap_ctx *ap_ctx;
1139
1140 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
1141 return hdd_softap_deregister_sta(adapter, ap_ctx->broadcast_sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142}
1143
1144/**
1145 * hdd_softap_stop_bss() - Stop the BSS
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001146 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301148 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001150QDF_STATUS hdd_softap_stop_bss(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301152 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 uint8_t staId = 0;
Jeff Johnson92402872017-09-03 09:25:37 -07001154 struct hdd_context *hdd_ctx;
Yun Parka9d0c112018-03-07 14:11:27 -08001155 struct hdd_ap_ctx *ap_ctx;
Srinivas Girigowdae806a822017-03-25 11:25:30 -07001156
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001157 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Yun Parka9d0c112018-03-07 14:11:27 -08001158 ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001159
Rajeev Kumar07bbe122017-10-24 13:06:05 -07001160 /* This is stop bss callback running in scheduler thread so do not
1161 * driver unload in progress check otherwise it can lead to peer
1162 * object leak
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001164 qdf_status = hdd_softap_deregister_bc_sta(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001165
Yun Parka9d0c112018-03-07 14:11:27 -08001166 if (!QDF_IS_STATUS_SUCCESS(qdf_status))
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001167 hdd_err("Failed to deregister BC sta Id %d",
Jeff Johnson42518cf2017-10-26 13:33:29 -07001168 ap_ctx->broadcast_sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169
1170 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
1171 /* This excludes BC sta as it is already deregistered */
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001172 if (adapter->sta_info[staId].in_use) {
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001173 qdf_status = hdd_softap_deregister_sta(adapter, staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301174 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001175 hdd_err("Failed to deregister sta Id %d",
1176 staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 }
1178 }
1179 }
Mukul Sharmaecf8e092017-12-19 22:36:31 +05301180
1181 /* Mark the indoor channel (passive) to enable */
1182 if (hdd_ctx->config->force_ssc_disable_indoor_channel) {
1183 hdd_update_indoor_channel(hdd_ctx, false);
1184 sme_update_channel_list(hdd_ctx->hHal);
1185 }
1186
Yun Parka9d0c112018-03-07 14:11:27 -08001187 if (ucfg_ipa_is_enabled()) {
1188 if (ucfg_ipa_wlan_evt(hdd_ctx->hdd_pdev,
1189 adapter->dev, adapter->device_mode,
1190 ap_ctx->broadcast_sta_id,
1191 adapter->session_id,
1192 WLAN_IPA_AP_DISCONNECT,
1193 adapter->dev->dev_addr) != QDF_STATUS_SUCCESS)
1194 hdd_err("WLAN_AP_DISCONNECT event failed");
1195 }
1196
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301197 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198}
1199
1200/**
1201 * hdd_softap_change_sta_state() - Change the state of a SoftAP station
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001202 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 * @pDestMacAddress: MAC address of the station
1204 * @state: new state of the station
1205 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301206 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001208QDF_STATUS hdd_softap_change_sta_state(struct hdd_adapter *adapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301209 struct qdf_mac_addr *pDestMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 enum ol_txrx_peer_state state)
1211{
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001212 uint8_t sta_id = WLAN_MAX_STA_COUNT;
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001213 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214
Dustin Brownfdf17c12018-03-14 12:55:34 -07001215 hdd_enter_dev(adapter->dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001217 qdf_status = hdd_softap_get_sta_id(adapter, pDestMacAddress, &sta_id);
Jeff Johnsond5bd6fd2016-12-05 12:29:21 -08001218 if (QDF_STATUS_SUCCESS != qdf_status) {
1219 hdd_err("Failed to find right station");
1220 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221 }
1222
1223 if (false ==
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001224 qdf_is_macaddr_equal(&adapter->sta_info[sta_id].sta_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 pDestMacAddress)) {
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001226 hdd_err("Station %u MAC address not matching", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301227 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228 }
1229
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301230 qdf_status =
Jeff Johnson4c0ab7b2017-10-21 16:13:09 -07001231 hdd_change_peer_state(adapter, sta_id, state, false);
1232 hdd_info("Station %u changed to state %d", sta_id, state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301234 if (QDF_STATUS_SUCCESS == qdf_status) {
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001235 adapter->sta_info[sta_id].peer_state =
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001236 OL_TXRX_PEER_STATE_AUTH;
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001237 p2p_peer_authorized(adapter->hdd_vdev, pDestMacAddress->bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 }
1239
Dustin Browne74003f2018-03-14 12:51:58 -07001240 hdd_exit();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301241 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242}
1243
1244/*
1245 * hdd_softap_get_sta_id() - Find station ID from MAC address
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001246 * @adapter: pointer to adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 * @pDestMacAddress: MAC address of the destination
1248 * @staId: Station ID associated with the MAC address
1249 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301250 * Return: QDF_STATUS_SUCCESS if a match was found, in which case
1251 * staId is populated, QDF_STATUS_E_FAILURE if a match is
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 * not found
1253 */
Jeff Johnsond31ab6a2017-10-02 13:23:51 -07001254QDF_STATUS hdd_softap_get_sta_id(struct hdd_adapter *adapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301255 struct qdf_mac_addr *pMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 uint8_t *staId)
1257{
1258 uint8_t i;
1259
1260 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301261 if (!qdf_mem_cmp
Jeff Johnsonbb8b56a2017-10-23 07:02:36 -07001262 (&adapter->sta_info[i].sta_mac, pMacAddress,
1263 QDF_MAC_ADDR_SIZE) && adapter->sta_info[i].in_use) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 *staId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301265 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266 }
1267 }
1268
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301269 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270}