blob: 09b862d6849ac720751ec5e0caf8ce57e239acbe [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Orhan K AKYILDIZ4f20db52015-12-30 12:35:44 -08002 * Copyright (c) 2012-2016 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
28/* Include files */
29#include <linux/semaphore.h>
30#include <wlan_hdd_tx_rx.h>
31#include <wlan_hdd_softap_tx_rx.h>
32#include <linux/netdevice.h>
33#include <linux/skbuff.h>
34#include <linux/etherdevice.h>
Anurag Chouhan6d760662016-02-20 16:05:43 +053035#include <qdf_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080036#include <ani_global.h>
Anurag Chouhan6d760662016-02-20 16:05:43 +053037#include <qdf_types.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038#include <net/ieee80211_radiotap.h>
39#include <cds_sched.h>
40#include <wlan_hdd_napi.h>
Dhanashri Atre182b0272016-02-17 15:35:07 -080041#include <ol_txrx.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042
43#ifdef IPA_OFFLOAD
44#include <wlan_hdd_ipa.h>
45#endif
46
47/* Preprocessor definitions and constants */
48#undef QCA_HDD_SAP_DUMP_SK_BUFF
49
50/* Type declarations */
51
52/* Function definitions and documenation */
53#ifdef QCA_HDD_SAP_DUMP_SK_BUFF
54/**
55 * hdd_softap_dump_sk_buff() - Dump an skb
56 * @skb: skb to dump
57 *
58 * Return: None
59 */
60static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
61{
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053062 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063 "%s: head = %p ", __func__, skb->head);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053064 /* QDF_TRACE( QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,"%s: data = %p ", __func__, skb->data); */
65 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066 "%s: tail = %p ", __func__, skb->tail);
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: end = %p ", __func__, skb->end);
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: len = %d ", __func__, skb->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: data_len = %d ", __func__, skb->data_len);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053073 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080074 "%s: mac_len = %d", __func__, skb->mac_len);
75
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 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x ", skb->data[0],
78 skb->data[1], skb->data[2], skb->data[3], skb->data[4],
79 skb->data[5], skb->data[6], skb->data[7]);
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 "0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x 0x%x", skb->data[8],
82 skb->data[9], skb->data[10], skb->data[11], skb->data[12],
83 skb->data[13], skb->data[14], skb->data[15]);
84}
85#else
86static void hdd_softap_dump_sk_buff(struct sk_buff *skb)
87{
88}
89#endif
90
91#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
92/**
93 * hdd_softap_tx_resume_timer_expired_handler() - TX Q resume timer handler
94 * @adapter_context: pointer to vdev adapter
95 *
96 * TX Q resume timer handler for SAP and P2P GO interface. If Blocked
97 * OS Q is not resumed during timeout period, to prevent permanent
98 * stall, resume OS Q forcefully for SAP and P2P GO interface.
99 *
100 * Return: None
101 */
102void hdd_softap_tx_resume_timer_expired_handler(void *adapter_context)
103{
104 hdd_adapter_t *pAdapter = (hdd_adapter_t *) adapter_context;
105
106 if (!pAdapter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530107 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108 "%s: INV ARG", __func__);
109 /* INVALID ARG */
110 return;
111 }
112
113 hddLog(LOG1, FL("Enabling queues"));
114 wlan_hdd_netif_queue_control(pAdapter, WLAN_WAKE_ALL_NETIF_QUEUE,
115 WLAN_CONTROL_PATH);
116 return;
117}
118
119/**
120 * hdd_softap_tx_resume_cb() - Resume OS TX Q.
121 * @adapter_context: pointer to vdev apdapter
122 * @tx_resume: TX Q resume trigger
123 *
124 * Q was stopped due to WLAN TX path low resource condition
125 *
126 * Return: None
127 */
128void hdd_softap_tx_resume_cb(void *adapter_context, bool tx_resume)
129{
130 hdd_adapter_t *pAdapter = (hdd_adapter_t *) adapter_context;
131
132 if (!pAdapter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530133 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800134 "%s: INV ARG", __func__);
135 /* INVALID ARG */
136 return;
137 }
138
139 /* Resume TX */
140 if (true == tx_resume) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530141 if (QDF_TIMER_STATE_STOPPED !=
142 qdf_mc_timer_get_current_state(&pAdapter->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800143 tx_flow_control_timer)) {
Anurag Chouhan210db072016-02-22 18:42:15 +0530144 qdf_mc_timer_stop(&pAdapter->tx_flow_control_timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145 }
146
147 hddLog(LOG1, FL("Enabling queues"));
148 wlan_hdd_netif_queue_control(pAdapter,
149 WLAN_WAKE_ALL_NETIF_QUEUE,
150 WLAN_DATA_FLOW_CONTROL);
151 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152 return;
153}
154#endif /* QCA_LL_LEGACY_TX_FLOW_CONTROL */
155
156/**
157 * hdd_softap_hard_start_xmit() - Transmit a frame
158 * @skb: pointer to OS packet (sk_buff)
159 * @dev: pointer to network device
160 *
161 * Function registered with the Linux OS for transmitting
162 * packets. This version of the function directly passes
163 * the packet to Transport Layer.
164 *
165 * Return: Always returns NETDEV_TX_OK
166 */
167int hdd_softap_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
168{
169 sme_ac_enum_type ac = SME_AC_BE;
170 hdd_adapter_t *pAdapter = (hdd_adapter_t *) netdev_priv(dev);
171 hdd_ap_ctx_t *pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530172 struct qdf_mac_addr *pDestMacAddress;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173 uint8_t STAId;
174 uint8_t proto_type = 0;
175#ifdef QCA_PKT_PROTO_TRACE
176 hdd_context_t *hddCtxt = (hdd_context_t *) pAdapter->pHddCtx;
177#endif /* QCA_PKT_PROTO_TRACE */
178
179 ++pAdapter->hdd_stats.hddTxRxStats.txXmitCalled;
180 /* Prevent this function from being called during SSR since TL
181 * context may not be reinitialized at this time which may
182 * lead to a crash.
183 */
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800184 if (cds_is_driver_recovering()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530185 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO_HIGH,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800186 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 goto drop_pkt;
188 }
189
190 /*
191 * If the device is operating on a DFS Channel
192 * then check if SAP is in CAC WAIT state and
193 * drop the packets. In CAC WAIT state device
194 * is expected not to transmit any frames.
195 * SAP starts Tx only after the BSS START is
196 * done.
197 */
198 if (pHddApCtx->dfs_cac_block_tx) {
199 goto drop_pkt;
200 }
201
Anurag Chouhan6d760662016-02-20 16:05:43 +0530202 pDestMacAddress = (struct qdf_mac_addr *) skb->data;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203
Anurag Chouhanc5548422016-02-24 18:33:27 +0530204 if (qdf_is_macaddr_broadcast(pDestMacAddress) ||
205 qdf_is_macaddr_group(pDestMacAddress)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 /* The BC/MC station ID is assigned during BSS
207 * starting phase. SAP will return the station ID
208 * used for BC/MC traffic.
209 */
210 STAId = pHddApCtx->uBCStaId;
211 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530212 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 hdd_softap_get_sta_id(pAdapter,
214 pDestMacAddress, &STAId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530215 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
216 QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217 "%s: Failed to find right station", __func__);
218 goto drop_pkt;
219 }
220
221 if (STAId == HDD_WLAN_INVALID_STA_ID) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530222 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
223 QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 "%s: Failed to find right station", __func__);
225 goto drop_pkt;
226 } else if (false == pAdapter->aStaInfo[STAId].isUsed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530227 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
228 QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 "%s: STA %d is unregistered", __func__,
230 STAId);
231 goto drop_pkt;
232 }
233
234 if ((ol_txrx_peer_state_conn !=
235 pAdapter->aStaInfo[STAId].tlSTAState)
236 && (ol_txrx_peer_state_auth !=
237 pAdapter->aStaInfo[STAId].tlSTAState)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530238 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
239 QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 "%s: Station not connected yet", __func__);
241 goto drop_pkt;
242 } else if (ol_txrx_peer_state_conn ==
243 pAdapter->aStaInfo[STAId].tlSTAState) {
244 if (ntohs(skb->protocol) != HDD_ETHERTYPE_802_1_X) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530245 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
246 QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 "%s: NON-EAPOL packet in non-Authenticated state",
248 __func__);
249 goto drop_pkt;
250 }
251 }
252 }
253
254 hdd_get_tx_resource(pAdapter, STAId,
255 WLAN_SAP_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME);
256
257 /* Get TL AC corresponding to Qdisc queue index/AC. */
258 ac = hdd_qdisc_ac_to_tl_ac[skb->queue_mapping];
259 ++pAdapter->hdd_stats.hddTxRxStats.txXmitClassifiedAC[ac];
260
261#if defined (IPA_OFFLOAD)
Nirav Shahcbc6d722016-03-01 16:24:53 +0530262 if (!qdf_nbuf_ipa_owned_get(skb)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263#endif
264 /* Check if the buffer has enough header room */
265 skb = skb_unshare(skb, GFP_ATOMIC);
266 if (!skb)
Jeff Johnsonedeff232015-11-11 17:19:42 -0800267 goto drop_pkt_accounting;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268
269 if (skb_headroom(skb) < dev->hard_header_len) {
270 struct sk_buff *tmp;
271 tmp = skb;
272 skb = skb_realloc_headroom(tmp, dev->hard_header_len);
273 dev_kfree_skb(tmp);
274 if (!skb)
Jeff Johnsonedeff232015-11-11 17:19:42 -0800275 goto drop_pkt_accounting;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 }
277#if defined (IPA_OFFLOAD)
278 }
279#endif
280
281 wlan_hdd_log_eapol(skb,
282 WIFI_EVENT_DRIVER_EAPOL_FRAME_TRANSMIT_REQUESTED);
283
284#ifdef QCA_PKT_PROTO_TRACE
285 if ((hddCtxt->config->gEnableDebugLog & CDS_PKT_TRAC_TYPE_EAPOL) ||
286 (hddCtxt->config->gEnableDebugLog & CDS_PKT_TRAC_TYPE_DHCP)) {
287 /* Proto Trace enabled */
288 proto_type = cds_pkt_get_proto_type(skb,
289 hddCtxt->config->
290 gEnableDebugLog, 0);
291 if (CDS_PKT_TRAC_TYPE_EAPOL & proto_type) {
292 cds_pkt_trace_buf_update("HA:T:EPL");
293 } else if (CDS_PKT_TRAC_TYPE_DHCP & proto_type) {
294 cds_pkt_trace_buf_update("HA:T:DHC");
295 }
296 }
297#endif /* QCA_PKT_PROTO_TRACE */
298 pAdapter->stats.tx_bytes += skb->len;
299 ++pAdapter->stats.tx_packets;
300
301 /* Zero out skb's context buffer for the driver to use */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530302 qdf_mem_set(skb->cb, sizeof(skb->cb), 0);
Nirav Shahcbc6d722016-03-01 16:24:53 +0530303 QDF_NBUF_CB_TX_PACKET_TRACK(skb) = QDF_NBUF_TX_PKT_DATA_TRACK;
304 QDF_NBUF_UPDATE_TX_PKT_COUNT(skb, QDF_NBUF_TX_PKT_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530306 qdf_dp_trace_set_track(skb);
307 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_PACKET_PTR_RECORD,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 (uint8_t *)skb->data, sizeof(skb->data)));
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530309 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_PACKET_RECORD,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530310 (uint8_t *)skb->data, qdf_nbuf_len(skb)));
311 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530312 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_HDD_PACKET_RECORD,
313 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
Nirav Shahcbc6d722016-03-01 16:24:53 +0530314 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE)));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315
316 if (ol_tx_send_data_frame(STAId, skb,
317 proto_type) != NULL) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530318 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_WARN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 "%s: Failed to send packet to txrx for staid:%d",
320 __func__, STAId);
321 ++pAdapter->hdd_stats.hddTxRxStats.txXmitDroppedAC[ac];
322 goto drop_pkt;
323 }
324 dev->trans_start = jiffies;
325
326 return NETDEV_TX_OK;
327
328drop_pkt:
329
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530330 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
Nirav Shahcbc6d722016-03-01 16:24:53 +0530331 (uint8_t *)skb->data, qdf_nbuf_len(skb)));
332 if (qdf_nbuf_len(skb) > QDF_DP_TRACE_RECORD_SIZE)
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530333 DPTRACE(qdf_dp_trace(skb, QDF_DP_TRACE_DROP_PACKET_RECORD,
334 (uint8_t *)&skb->data[QDF_DP_TRACE_RECORD_SIZE],
Nirav Shahcbc6d722016-03-01 16:24:53 +0530335 (qdf_nbuf_len(skb)-QDF_DP_TRACE_RECORD_SIZE)));
Jeff Johnsonedeff232015-11-11 17:19:42 -0800336 kfree_skb(skb);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337
Jeff Johnsonedeff232015-11-11 17:19:42 -0800338drop_pkt_accounting:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 ++pAdapter->stats.tx_dropped;
340 ++pAdapter->hdd_stats.hddTxRxStats.txXmitDropped;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341
342 return NETDEV_TX_OK;
343}
344
345/**
346 * __hdd_softap_tx_timeout() - TX timeout handler
347 * @dev: pointer to network device
348 *
349 * This function is registered as a netdev ndo_tx_timeout method, and
350 * is invoked by the kernel if the driver takes too long to transmit a
351 * frame.
352 *
353 * Return: None
354 */
355static void __hdd_softap_tx_timeout(struct net_device *dev)
356{
357 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
358 hdd_context_t *hdd_ctx;
359
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530360 DPTRACE(qdf_dp_trace(NULL, QDF_DP_TRACE_HDD_SOFTAP_TX_TIMEOUT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361 NULL, 0));
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530362 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 "%s: Transmission timeout occurred", __func__);
364 /* Getting here implies we disabled the TX queues for too
365 * long. Queues are disabled either because of disassociation
366 * or low resource scenarios. In case of disassociation it is
367 * ok to ignore this. But if associated, we have do possible
368 * recovery here
369 */
370 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800371 if (cds_is_driver_recovering()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530372 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800373 "%s: Recovery in Progress. Ignore!!!", __func__);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374 return;
375 }
376}
377
378/**
379 * hdd_softap_tx_timeout() - SSR wrapper for __hdd_softap_tx_timeout
380 * @dev: pointer to net_device
381 *
382 * Return: none
383 */
384void hdd_softap_tx_timeout(struct net_device *dev)
385{
386 cds_ssr_protect(__func__);
387 __hdd_softap_tx_timeout(dev);
388 cds_ssr_unprotect(__func__);
389}
390
391/**
392 * @hdd_softap_init_tx_rx() - Initialize Tx/RX module
393 * @pAdapter: pointer to adapter context
394 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530395 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
396 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530398QDF_STATUS hdd_softap_init_tx_rx(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530400 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401
402 uint8_t STAId = 0;
403
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530404 qdf_mem_zero(&pAdapter->stats, sizeof(struct net_device_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405
406 spin_lock_init(&pAdapter->staInfo_lock);
407
408 for (STAId = 0; STAId < WLAN_MAX_STA_COUNT; STAId++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530409 qdf_mem_zero(&pAdapter->aStaInfo[STAId],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410 sizeof(hdd_station_info_t));
411 }
412
413 return status;
414}
415
416/**
417 * @hdd_softap_deinit_tx_rx() - Deinitialize Tx/RX module
418 * @pAdapter: pointer to adapter context
419 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530420 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
421 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530423QDF_STATUS hdd_softap_deinit_tx_rx(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530425 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426
427 return status;
428}
429
430/**
431 * hdd_softap_init_tx_rx_sta() - Initialize tx/rx for a softap station
432 * @pAdapter: pointer to adapter context
433 * @STAId: Station ID to initialize
434 * @pmacAddrSTA: pointer to the MAC address of the station
435 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530436 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
437 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800438 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530439QDF_STATUS hdd_softap_init_tx_rx_sta(hdd_adapter_t *pAdapter, uint8_t STAId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530440 struct qdf_mac_addr *pmacAddrSTA)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441{
442 spin_lock_bh(&pAdapter->staInfo_lock);
443 if (pAdapter->aStaInfo[STAId].isUsed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530444 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 "%s: Reinit station %d", __func__, STAId);
446 spin_unlock_bh(&pAdapter->staInfo_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530447 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 }
449
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530450 qdf_mem_zero(&pAdapter->aStaInfo[STAId], sizeof(hdd_station_info_t));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451
452 pAdapter->aStaInfo[STAId].isUsed = true;
453 pAdapter->aStaInfo[STAId].isDeauthInProgress = false;
Anurag Chouhanc5548422016-02-24 18:33:27 +0530454 qdf_copy_macaddr(&pAdapter->aStaInfo[STAId].macAddrSTA, pmacAddrSTA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455
456 spin_unlock_bh(&pAdapter->staInfo_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530457 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458}
459
460/**
461 * hdd_softap_deinit_tx_rx_sta() - Deinitialize tx/rx for a softap station
462 * @pAdapter: pointer to adapter context
463 * @STAId: Station ID to deinitialize
464 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530465 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
466 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530468QDF_STATUS hdd_softap_deinit_tx_rx_sta(hdd_adapter_t *pAdapter, uint8_t STAId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530470 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 hdd_hostapd_state_t *pHostapdState;
472
473 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
474
475 spin_lock_bh(&pAdapter->staInfo_lock);
476
477 if (false == pAdapter->aStaInfo[STAId].isUsed) {
478 spin_unlock_bh(&pAdapter->staInfo_lock);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530479 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 "%s: Deinit station not inited %d", __func__, STAId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530481 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482 }
483
484 pAdapter->aStaInfo[STAId].isUsed = false;
485 pAdapter->aStaInfo[STAId].isDeauthInProgress = false;
486
487 spin_unlock_bh(&pAdapter->staInfo_lock);
488 return status;
489}
490
491/**
492 * hdd_softap_rx_packet_cbk() - Receive packet handler
Dhanashri Atre182b0272016-02-17 15:35:07 -0800493 * @context: pointer to HDD context
Nirav Shahcbc6d722016-03-01 16:24:53 +0530494 * @rxBuf: pointer to rx qdf_nbuf
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495 *
496 * Receive callback registered with TL. TL will call this to notify
497 * the HDD when one or more packets were received for a registered
498 * STA.
499 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530500 * Return: QDF_STATUS_E_FAILURE if any errors encountered,
501 * QDF_STATUS_SUCCESS otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800503QDF_STATUS hdd_softap_rx_packet_cbk(void *context, qdf_nbuf_t rxBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800504{
505 hdd_adapter_t *pAdapter = NULL;
506 int rxstat;
507 unsigned int cpu_index;
508 struct sk_buff *skb = NULL;
509 hdd_context_t *pHddCtx = NULL;
510#ifdef QCA_PKT_PROTO_TRACE
511 uint8_t proto_type;
512#endif /* QCA_PKT_PROTO_TRACE */
513
514 /* Sanity check on inputs */
Dhanashri Atre182b0272016-02-17 15:35:07 -0800515 if (unlikely((NULL == context) || (NULL == rxBuf))) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530516 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 "%s: Null params being passed", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530518 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 }
520
Dhanashri Atre182b0272016-02-17 15:35:07 -0800521 pAdapter = (hdd_adapter_t *)context;
522 if (unlikely(WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
523 QDF_TRACE(QDF_MODULE_ID_HDD_DATA, QDF_TRACE_LEVEL_FATAL,
524 "Magic cookie(%x) for adapter sanity verification is invalid",
525 pAdapter->magic);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530526 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 }
528
Dhanashri Atre182b0272016-02-17 15:35:07 -0800529 pHddCtx = pAdapter->pHddCtx;
530 if (unlikely(NULL == pHddCtx)) {
531 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
532 "%s: HDD context is Null", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530533 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534 }
535
536 /* walk the chain until all are processed */
537 skb = (struct sk_buff *)rxBuf;
538
539 hdd_softap_dump_sk_buff(skb);
540
541 skb->dev = pAdapter->dev;
542
Dhanashri Atre182b0272016-02-17 15:35:07 -0800543 if (unlikely(skb->dev == NULL)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530545 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546 "%s: ERROR!!Invalid netdevice", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530547 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800548 }
549 cpu_index = wlan_hdd_get_cpu();
550 ++pAdapter->hdd_stats.hddTxRxStats.rxPackets[cpu_index];
551 ++pAdapter->stats.rx_packets;
552 pAdapter->stats.rx_bytes += skb->len;
553
554 wlan_hdd_log_eapol(skb, WIFI_EVENT_DRIVER_EAPOL_FRAME_RECEIVED);
555
556#ifdef QCA_PKT_PROTO_TRACE
557 if ((pHddCtx->config->gEnableDebugLog & CDS_PKT_TRAC_TYPE_EAPOL) ||
558 (pHddCtx->config->gEnableDebugLog & CDS_PKT_TRAC_TYPE_DHCP)) {
559 proto_type = cds_pkt_get_proto_type(skb,
560 pHddCtx->config->
561 gEnableDebugLog, 0);
562 if (CDS_PKT_TRAC_TYPE_EAPOL & proto_type) {
563 cds_pkt_trace_buf_update("HA:R:EPL");
564 } else if (CDS_PKT_TRAC_TYPE_DHCP & proto_type) {
565 cds_pkt_trace_buf_update("HA:R:DHC");
566 }
567 }
568#endif /* QCA_PKT_PROTO_TRACE */
569
570 skb->protocol = eth_type_trans(skb, skb->dev);
571#ifdef WLAN_FEATURE_HOLD_RX_WAKELOCK
Anurag Chouhana37b5b72016-02-21 14:53:42 +0530572 qdf_wake_lock_timeout_acquire(&pHddCtx->rx_wake_lock,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573 HDD_WAKE_LOCK_DURATION,
574 WIFI_POWER_EVENT_WAKELOCK_HOLD_RX);
575#endif
576
577 /* Remove SKB from internal tracking table before submitting
578 * it to stack
579 */
Nirav Shahcbc6d722016-03-01 16:24:53 +0530580 qdf_net_buf_debug_release_skb(rxBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581
Orhan K AKYILDIZ4f20db52015-12-30 12:35:44 -0800582 if (hdd_napi_enabled(HDD_NAPI_ANY) && !pHddCtx->config->enableRxThread)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 rxstat = netif_receive_skb(skb);
584 else
585 rxstat = netif_rx_ni(skb);
586 if (NET_RX_SUCCESS == rxstat) {
587 ++pAdapter->hdd_stats.hddTxRxStats.rxDelivered[cpu_index];
588 } else {
589 ++pAdapter->hdd_stats.hddTxRxStats.rxRefused[cpu_index];
590 }
591
592 pAdapter->dev->last_rx = jiffies;
593
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530594 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595}
596
597/**
598 * hdd_softap_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
599 * @pAdapter: pointer to adapter context
600 * @staId: Station ID to deregister
601 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530602 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530604QDF_STATUS hdd_softap_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800605{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530606 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 hdd_context_t *pHddCtx;
608
609 if (NULL == pAdapter) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530610 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 "%s: pAdapter is NULL", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530612 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 }
614
615 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530616 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 "%s: Invalid pAdapter magic", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530618 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 }
620
621 pHddCtx = (hdd_context_t *) (pAdapter->pHddCtx);
622 /* Clear station in TL and then update HDD data
623 * structures. This helps to block RX frames from other
624 * station to this station.
625 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530626 qdf_status = ol_txrx_clear_peer(staId);
627 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530628 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800629 "ol_txrx_clear_peer() failed to for staID %d. "
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530630 "Status= %d [0x%08X]", staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 }
632
633 if (pAdapter->aStaInfo[staId].isUsed) {
634 spin_lock_bh(&pAdapter->staInfo_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530635 qdf_mem_zero(&pAdapter->aStaInfo[staId],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 sizeof(hdd_station_info_t));
637 spin_unlock_bh(&pAdapter->staInfo_lock);
638 }
639 pHddCtx->sta_to_adapter[staId] = NULL;
640
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530641 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642}
643
644/**
645 * hdd_softap_register_sta() - Register a SoftAP STA
646 * @pAdapter: pointer to adapter context
647 * @fAuthRequired: is additional authentication required?
648 * @fPrivacyBit: should 802.11 privacy bit be set?
649 * @staId: station ID assigned to this station
650 * @ucastSig: unicast security signature
651 * @bcastSig: broadcast security signature
652 * @pPeerMacAddress: station MAC address
653 * @fWmmEnabled: is WMM enabled for this STA?
654 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530655 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530657QDF_STATUS hdd_softap_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 bool fAuthRequired,
659 bool fPrivacyBit,
660 uint8_t staId,
661 uint8_t ucastSig,
662 uint8_t bcastSig,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530663 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664 bool fWmmEnabled)
665{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530666 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 struct ol_txrx_desc_type staDesc = { 0 };
668 hdd_context_t *pHddCtx = pAdapter->pHddCtx;
Dhanashri Atre182b0272016-02-17 15:35:07 -0800669 struct ol_txrx_ops txrx_ops;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670
671 /*
672 * Clean up old entry if it is not cleaned up properly
673 */
674 if (pAdapter->aStaInfo[staId].isUsed) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530675 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 "clean up old entry for STA %d", staId);
677 hdd_softap_deregister_sta(pAdapter, staId);
678 }
679 /* Get the Station ID from the one saved during the assocation. */
680
681 staDesc.sta_id = staId;
682
683 /*Save the pAdapter Pointer for this staId */
684 pHddCtx->sta_to_adapter[staId] = pAdapter;
685
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530686 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 hdd_softap_init_tx_rx_sta(pAdapter, staId,
688 pPeerMacAddress);
689
690 staDesc.is_qos_enabled = fWmmEnabled;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530691 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 "HDD SOFTAP register TL QoS_enabled=%d",
693 staDesc.is_qos_enabled);
694
Dhanashri Atre182b0272016-02-17 15:35:07 -0800695 qdf_status = ol_txrx_register_peer(&staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530696 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530697 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 "SOFTAP ol_txrx_register_peer() failed to register. Status= %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530699 qdf_status, qdf_status);
700 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701 }
702
Dhanashri Atre182b0272016-02-17 15:35:07 -0800703 /* Register the vdev transmit and receive functions */
704 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
705 txrx_ops.rx.rx = hdd_softap_rx_packet_cbk;
706 ol_txrx_vdev_register(
707 ol_txrx_get_vdev_from_vdev_id(pAdapter->sessionId),
708 pAdapter, &txrx_ops);
709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 /* if ( WPA ), tell TL to go to 'connected' and after keys come to the
711 * driver then go to 'authenticated'. For all other authentication
712 * types (those that do not require upper layer authentication) we can
713 * put TL directly into 'authenticated' state
714 */
715
716 pAdapter->aStaInfo[staId].ucSTAId = staId;
717 pAdapter->aStaInfo[staId].isQosEnabled = fWmmEnabled;
718
719 if (!fAuthRequired) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530720 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721 "open/shared auth StaId= %d. Changing TL state to AUTHENTICATED at Join time",
722 pAdapter->aStaInfo[staId].ucSTAId);
723
724 /* Connections that do not need Upper layer auth,
725 * transition TL directly to 'Authenticated' state.
726 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530727 qdf_status = hdd_change_peer_state(pAdapter, staDesc.sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 ol_txrx_peer_state_auth, false);
729
730 pAdapter->aStaInfo[staId].tlSTAState = ol_txrx_peer_state_auth;
731 pAdapter->sessionCtx.ap.uIsAuthenticated = true;
732 } else {
733
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530734 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735 "ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
736 pAdapter->aStaInfo[staId].ucSTAId);
737
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530738 qdf_status = hdd_change_peer_state(pAdapter, staDesc.sta_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 ol_txrx_peer_state_conn, false);
740 pAdapter->aStaInfo[staId].tlSTAState = ol_txrx_peer_state_conn;
741
742 pAdapter->sessionCtx.ap.uIsAuthenticated = false;
743
744 }
745
746 /* Enable Tx queue */
747 hddLog(LOG1, FL("Enabling queues"));
748 wlan_hdd_netif_queue_control(pAdapter,
749 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
750 WLAN_CONTROL_PATH);
751
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530752 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753}
754
755/**
756 * hdd_softap_register_bc_sta() - Register the SoftAP broadcast STA
757 * @pAdapter: pointer to adapter context
758 * @fPrivacyBit: should 802.11 privacy bit be set?
759 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530760 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530762QDF_STATUS hdd_softap_register_bc_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763 bool fPrivacyBit)
764{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530765 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530767 struct qdf_mac_addr broadcastMacAddr =
768 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769 hdd_ap_ctx_t *pHddApCtx;
770
771 pHddApCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
772
773 pHddCtx->sta_to_adapter[WLAN_RX_BCMC_STA_ID] = pAdapter;
774#ifdef WLAN_FEATURE_MBSSID
775 pHddCtx->sta_to_adapter[pHddApCtx->uBCStaId] = pAdapter;
776#else
777 pHddCtx->sta_to_adapter[WLAN_RX_SAP_SELF_STA_ID] = pAdapter;
778#endif
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530779 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800780 hdd_softap_register_sta(pAdapter, false, fPrivacyBit,
781 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->
782 uBCStaId, 0, 1, &broadcastMacAddr, 0);
783
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530784 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800785}
786
787/**
788 * hdd_softap_deregister_bc_sta() - Deregister the SoftAP broadcast STA
789 * @pAdapter: pointer to adapter context
790 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530791 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530793QDF_STATUS hdd_softap_deregister_bc_sta(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794{
795 return hdd_softap_deregister_sta(pAdapter,
796 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->
797 uBCStaId);
798}
799
800/**
801 * hdd_softap_stop_bss() - Stop the BSS
802 * @pAdapter: pointer to adapter context
803 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530804 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530806QDF_STATUS hdd_softap_stop_bss(hdd_adapter_t *pAdapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530808 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 uint8_t staId = 0;
810 hdd_context_t *pHddCtx;
811 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
812
813 /* bss deregister is not allowed during wlan driver loading or
814 * unloading
815 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -0800816 if (cds_is_load_or_unload_in_progress()) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530817 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prashanth Bhatta9e143052015-12-04 11:56:47 -0800818 "%s: Loading_unloading in Progress, state: 0x%x. Ignore!!!",
819 __func__, cds_get_driver_state());
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530820 return QDF_STATUS_E_PERM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 }
822
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530823 qdf_status = hdd_softap_deregister_bc_sta(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530825 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530826 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 "%s: Failed to deregister BC sta Id %d", __func__,
828 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->uBCStaId);
829 }
830
831 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++) {
832 /* This excludes BC sta as it is already deregistered */
833 if (pAdapter->aStaInfo[staId].isUsed) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530834 qdf_status = hdd_softap_deregister_sta(pAdapter, staId);
835 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530836 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA,
837 QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 "%s: Failed to deregister sta Id %d",
839 __func__, staId);
840 }
841 }
842 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530843 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844}
845
846/**
847 * hdd_softap_change_sta_state() - Change the state of a SoftAP station
848 * @pAdapter: pointer to adapter context
849 * @pDestMacAddress: MAC address of the station
850 * @state: new state of the station
851 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530852 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530854QDF_STATUS hdd_softap_change_sta_state(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530855 struct qdf_mac_addr *pDestMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 enum ol_txrx_peer_state state)
857{
858 uint8_t ucSTAId = WLAN_MAX_STA_COUNT;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530859 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530861 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 "%s: enter", __func__);
863
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530864 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 hdd_softap_get_sta_id(pAdapter,
866 pDestMacAddress, &ucSTAId)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530867 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 "%s: Failed to find right station", __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530869 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 }
871
872 if (false ==
Anurag Chouhanc5548422016-02-24 18:33:27 +0530873 qdf_is_macaddr_equal(&pAdapter->aStaInfo[ucSTAId].macAddrSTA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 pDestMacAddress)) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530875 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_ERROR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 "%s: Station MAC address does not matching",
877 __func__);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530878 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879 }
880
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530881 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 hdd_change_peer_state(pAdapter, ucSTAId, state, false);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530883 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 "%s: change station to state %d succeed", __func__, state);
885
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530886 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 pAdapter->aStaInfo[ucSTAId].tlSTAState =
888 ol_txrx_peer_state_auth;
889 }
890
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530891 QDF_TRACE(QDF_MODULE_ID_HDD_SAP_DATA, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 "%s exit", __func__);
893
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530894 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895}
896
897/*
898 * hdd_softap_get_sta_id() - Find station ID from MAC address
899 * @pAdapter: pointer to adapter context
900 * @pDestMacAddress: MAC address of the destination
901 * @staId: Station ID associated with the MAC address
902 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530903 * Return: QDF_STATUS_SUCCESS if a match was found, in which case
904 * staId is populated, QDF_STATUS_E_FAILURE if a match is
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 * not found
906 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530907QDF_STATUS hdd_softap_get_sta_id(hdd_adapter_t *pAdapter,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530908 struct qdf_mac_addr *pMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 uint8_t *staId)
910{
911 uint8_t i;
912
913 for (i = 0; i < WLAN_MAX_STA_COUNT; i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530914 if (!qdf_mem_cmp
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 (&pAdapter->aStaInfo[i].macAddrSTA, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530916 QDF_MAC_ADDR_SIZE) && pAdapter->aStaInfo[i].isUsed) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917 *staId = i;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530918 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919 }
920 }
921
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530922 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923}