1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * NXP Wireless LAN device driver: station event handling
4  *
5  * Copyright 2011-2020 NXP
6  */
7 
8 #include "decl.h"
9 #include "ioctl.h"
10 #include "util.h"
11 #include "fw.h"
12 #include "main.h"
13 #include "wmm.h"
14 #include "11n.h"
15 
16 #define MWIFIEX_IBSS_CONNECT_EVT_FIX_SIZE    12
17 
mwifiex_check_ibss_peer_capabilities(struct mwifiex_private * priv,struct mwifiex_sta_node * sta_ptr,struct sk_buff * event)18 static int mwifiex_check_ibss_peer_capabilities(struct mwifiex_private *priv,
19 					        struct mwifiex_sta_node *sta_ptr,
20 					        struct sk_buff *event)
21 {
22 	int evt_len, ele_len;
23 	u8 *curr;
24 	struct ieee_types_header *ele_hdr;
25 	struct mwifiex_ie_types_mgmt_frame *tlv_mgmt_frame;
26 	const struct ieee80211_ht_cap *ht_cap;
27 	const struct ieee80211_vht_cap *vht_cap;
28 
29 	skb_pull(event, MWIFIEX_IBSS_CONNECT_EVT_FIX_SIZE);
30 	evt_len = event->len;
31 	curr = event->data;
32 
33 	mwifiex_dbg_dump(priv->adapter, EVT_D, "ibss peer capabilities:",
34 			 event->data, event->len);
35 
36 	skb_push(event, MWIFIEX_IBSS_CONNECT_EVT_FIX_SIZE);
37 
38 	tlv_mgmt_frame = (void *)curr;
39 	if (evt_len >= sizeof(*tlv_mgmt_frame) &&
40 	    le16_to_cpu(tlv_mgmt_frame->header.type) ==
41 	    TLV_TYPE_UAP_MGMT_FRAME) {
42 		/* Locate curr pointer to the start of beacon tlv,
43 		 * timestamp 8 bytes, beacon intervel 2 bytes,
44 		 * capability info 2 bytes, totally 12 byte beacon header
45 		 */
46 		evt_len = le16_to_cpu(tlv_mgmt_frame->header.len);
47 		curr += (sizeof(*tlv_mgmt_frame) + 12);
48 	} else {
49 		mwifiex_dbg(priv->adapter, MSG,
50 			    "management frame tlv not found!\n");
51 		return 0;
52 	}
53 
54 	while (evt_len >= sizeof(*ele_hdr)) {
55 		ele_hdr = (struct ieee_types_header *)curr;
56 		ele_len = ele_hdr->len;
57 
58 		if (evt_len < ele_len + sizeof(*ele_hdr))
59 			break;
60 
61 		switch (ele_hdr->element_id) {
62 		case WLAN_EID_HT_CAPABILITY:
63 			sta_ptr->is_11n_enabled = true;
64 			ht_cap = (void *)(ele_hdr + 2);
65 			sta_ptr->max_amsdu = le16_to_cpu(ht_cap->cap_info) &
66 				IEEE80211_HT_CAP_MAX_AMSDU ?
67 				MWIFIEX_TX_DATA_BUF_SIZE_8K :
68 				MWIFIEX_TX_DATA_BUF_SIZE_4K;
69 			mwifiex_dbg(priv->adapter, INFO,
70 				    "11n enabled!, max_amsdu : %d\n",
71 				    sta_ptr->max_amsdu);
72 			break;
73 
74 		case WLAN_EID_VHT_CAPABILITY:
75 			sta_ptr->is_11ac_enabled = true;
76 			vht_cap = (void *)(ele_hdr + 2);
77 			/* check VHT MAXMPDU capability */
78 			switch (le32_to_cpu(vht_cap->vht_cap_info) & 0x3) {
79 			case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454:
80 				sta_ptr->max_amsdu =
81 					MWIFIEX_TX_DATA_BUF_SIZE_12K;
82 				break;
83 			case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991:
84 				sta_ptr->max_amsdu =
85 					MWIFIEX_TX_DATA_BUF_SIZE_8K;
86 				break;
87 			case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895:
88 				sta_ptr->max_amsdu =
89 					MWIFIEX_TX_DATA_BUF_SIZE_4K;
90 				break;
91 			default:
92 				break;
93 			}
94 
95 			mwifiex_dbg(priv->adapter, INFO,
96 				    "11ac enabled!, max_amsdu : %d\n",
97 				    sta_ptr->max_amsdu);
98 			break;
99 		default:
100 			break;
101 		}
102 
103 		curr += (ele_len + sizeof(*ele_hdr));
104 		evt_len -= (ele_len + sizeof(*ele_hdr));
105 	}
106 
107 	return 0;
108 }
109 
110 /*
111  * This function resets the connection state.
112  *
113  * The function is invoked after receiving a disconnect event from firmware,
114  * and performs the following actions -
115  *      - Set media status to disconnected
116  *      - Clean up Tx and Rx packets
117  *      - Resets SNR/NF/RSSI value in driver
118  *      - Resets security configurations in driver
119  *      - Enables auto data rate
120  *      - Saves the previous SSID and BSSID so that they can
121  *        be used for re-association, if required
122  *      - Erases current SSID and BSSID information
123  *      - Sends a disconnect event to upper layers/applications.
124  */
mwifiex_reset_connect_state(struct mwifiex_private * priv,u16 reason_code,bool from_ap)125 void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code,
126 				 bool from_ap)
127 {
128 	struct mwifiex_adapter *adapter = priv->adapter;
129 
130 	if (!priv->media_connected)
131 		return;
132 
133 	mwifiex_dbg(adapter, INFO,
134 		    "info: handles disconnect event\n");
135 
136 	priv->media_connected = false;
137 
138 	priv->scan_block = false;
139 	priv->port_open = false;
140 
141 	if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
142 	    ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info)) {
143 		mwifiex_disable_all_tdls_links(priv);
144 
145 		if (priv->adapter->auto_tdls)
146 			mwifiex_clean_auto_tdls(priv);
147 	}
148 
149 	/* Free Tx and Rx packets, report disconnect to upper layer */
150 	mwifiex_clean_txrx(priv);
151 
152 	/* Reset SNR/NF/RSSI values */
153 	priv->data_rssi_last = 0;
154 	priv->data_nf_last = 0;
155 	priv->data_rssi_avg = 0;
156 	priv->data_nf_avg = 0;
157 	priv->bcn_rssi_last = 0;
158 	priv->bcn_nf_last = 0;
159 	priv->bcn_rssi_avg = 0;
160 	priv->bcn_nf_avg = 0;
161 	priv->rxpd_rate = 0;
162 	priv->rxpd_htinfo = 0;
163 	priv->sec_info.wpa_enabled = false;
164 	priv->sec_info.wpa2_enabled = false;
165 	priv->wpa_ie_len = 0;
166 
167 	priv->sec_info.wapi_enabled = false;
168 	priv->wapi_ie_len = 0;
169 	priv->sec_info.wapi_key_on = false;
170 
171 	priv->sec_info.encryption_mode = 0;
172 
173 	/* Enable auto data rate */
174 	priv->is_data_rate_auto = true;
175 	priv->data_rate = 0;
176 
177 	priv->assoc_resp_ht_param = 0;
178 	priv->ht_param_present = false;
179 
180 	if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA ||
181 	     GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) && priv->hist_data)
182 		mwifiex_hist_data_reset(priv);
183 
184 	if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
185 		priv->adhoc_state = ADHOC_IDLE;
186 		priv->adhoc_is_link_sensed = false;
187 	}
188 
189 	/*
190 	 * Memorize the previous SSID and BSSID so
191 	 * it could be used for re-assoc
192 	 */
193 
194 	mwifiex_dbg(adapter, INFO,
195 		    "info: previous SSID=%s, SSID len=%u\n",
196 		    priv->prev_ssid.ssid, priv->prev_ssid.ssid_len);
197 
198 	mwifiex_dbg(adapter, INFO,
199 		    "info: current SSID=%s, SSID len=%u\n",
200 		    priv->curr_bss_params.bss_descriptor.ssid.ssid,
201 		    priv->curr_bss_params.bss_descriptor.ssid.ssid_len);
202 
203 	memcpy(&priv->prev_ssid,
204 	       &priv->curr_bss_params.bss_descriptor.ssid,
205 	       sizeof(struct cfg80211_ssid));
206 
207 	memcpy(priv->prev_bssid,
208 	       priv->curr_bss_params.bss_descriptor.mac_address, ETH_ALEN);
209 
210 	/* Need to erase the current SSID and BSSID info */
211 	memset(&priv->curr_bss_params, 0x00, sizeof(priv->curr_bss_params));
212 
213 	adapter->tx_lock_flag = false;
214 	adapter->pps_uapsd_mode = false;
215 
216 	if (test_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags) &&
217 	    adapter->curr_cmd)
218 		return;
219 	priv->media_connected = false;
220 	mwifiex_dbg(adapter, MSG,
221 		    "info: successfully disconnected from %pM: reason code %d\n",
222 		    priv->cfg_bssid, reason_code);
223 	if (priv->bss_mode == NL80211_IFTYPE_STATION ||
224 	    priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) {
225 		cfg80211_disconnected(priv->netdev, reason_code, NULL, 0,
226 				      !from_ap, GFP_KERNEL);
227 	}
228 	eth_zero_addr(priv->cfg_bssid);
229 
230 	mwifiex_stop_net_dev_queue(priv->netdev, adapter);
231 	if (netif_carrier_ok(priv->netdev))
232 		netif_carrier_off(priv->netdev);
233 
234 	if (!ISSUPP_FIRMWARE_SUPPLICANT(priv->adapter->fw_cap_info))
235 		return;
236 
237 	mwifiex_send_cmd(priv, HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG,
238 			 HostCmd_ACT_GEN_REMOVE, 0, NULL, false);
239 }
240 
mwifiex_parse_tdls_event(struct mwifiex_private * priv,struct sk_buff * event_skb)241 static int mwifiex_parse_tdls_event(struct mwifiex_private *priv,
242 				    struct sk_buff *event_skb)
243 {
244 	int ret = 0;
245 	struct mwifiex_adapter *adapter = priv->adapter;
246 	struct mwifiex_sta_node *sta_ptr;
247 	struct mwifiex_tdls_generic_event *tdls_evt =
248 			(void *)event_skb->data + sizeof(adapter->event_cause);
249 	u8 *mac = tdls_evt->peer_mac;
250 
251 	/* reserved 2 bytes are not mandatory in tdls event */
252 	if (event_skb->len < (sizeof(struct mwifiex_tdls_generic_event) -
253 			      sizeof(u16) - sizeof(adapter->event_cause))) {
254 		mwifiex_dbg(adapter, ERROR, "Invalid event length!\n");
255 		return -1;
256 	}
257 
258 	sta_ptr = mwifiex_get_sta_entry(priv, tdls_evt->peer_mac);
259 	if (!sta_ptr) {
260 		mwifiex_dbg(adapter, ERROR, "cannot get sta entry!\n");
261 		return -1;
262 	}
263 
264 	switch (le16_to_cpu(tdls_evt->type)) {
265 	case TDLS_EVENT_LINK_TEAR_DOWN:
266 		cfg80211_tdls_oper_request(priv->netdev,
267 					   tdls_evt->peer_mac,
268 					   NL80211_TDLS_TEARDOWN,
269 					   le16_to_cpu(tdls_evt->u.reason_code),
270 					   GFP_KERNEL);
271 		break;
272 	case TDLS_EVENT_CHAN_SWITCH_RESULT:
273 		mwifiex_dbg(adapter, EVENT, "tdls channel switch result :\n");
274 		mwifiex_dbg(adapter, EVENT,
275 			    "status=0x%x, reason=0x%x cur_chan=%d\n",
276 			    tdls_evt->u.switch_result.status,
277 			    tdls_evt->u.switch_result.reason,
278 			    tdls_evt->u.switch_result.cur_chan);
279 
280 		/* tdls channel switch failed */
281 		if (tdls_evt->u.switch_result.status != 0) {
282 			switch (tdls_evt->u.switch_result.cur_chan) {
283 			case TDLS_BASE_CHANNEL:
284 				sta_ptr->tdls_status = TDLS_IN_BASE_CHAN;
285 				break;
286 			case TDLS_OFF_CHANNEL:
287 				sta_ptr->tdls_status = TDLS_IN_OFF_CHAN;
288 				break;
289 			default:
290 				break;
291 			}
292 			return ret;
293 		}
294 
295 		/* tdls channel switch success */
296 		switch (tdls_evt->u.switch_result.cur_chan) {
297 		case TDLS_BASE_CHANNEL:
298 			if (sta_ptr->tdls_status == TDLS_IN_BASE_CHAN)
299 				break;
300 			mwifiex_update_ralist_tx_pause_in_tdls_cs(priv, mac,
301 								  false);
302 			sta_ptr->tdls_status = TDLS_IN_BASE_CHAN;
303 			break;
304 		case TDLS_OFF_CHANNEL:
305 			if (sta_ptr->tdls_status == TDLS_IN_OFF_CHAN)
306 				break;
307 			mwifiex_update_ralist_tx_pause_in_tdls_cs(priv, mac,
308 								  true);
309 			sta_ptr->tdls_status = TDLS_IN_OFF_CHAN;
310 			break;
311 		default:
312 			break;
313 		}
314 
315 		break;
316 	case TDLS_EVENT_START_CHAN_SWITCH:
317 		mwifiex_dbg(adapter, EVENT, "tdls start channel switch...\n");
318 		sta_ptr->tdls_status = TDLS_CHAN_SWITCHING;
319 		break;
320 	case TDLS_EVENT_CHAN_SWITCH_STOPPED:
321 		mwifiex_dbg(adapter, EVENT,
322 			    "tdls chan switch stopped, reason=%d\n",
323 			    tdls_evt->u.cs_stop_reason);
324 		break;
325 	default:
326 		break;
327 	}
328 
329 	return ret;
330 }
331 
mwifiex_process_uap_tx_pause(struct mwifiex_private * priv,struct mwifiex_ie_types_header * tlv)332 static void mwifiex_process_uap_tx_pause(struct mwifiex_private *priv,
333 					 struct mwifiex_ie_types_header *tlv)
334 {
335 	struct mwifiex_tx_pause_tlv *tp;
336 	struct mwifiex_sta_node *sta_ptr;
337 
338 	tp = (void *)tlv;
339 	mwifiex_dbg(priv->adapter, EVENT,
340 		    "uap tx_pause: %pM pause=%d, pkts=%d\n",
341 		    tp->peermac, tp->tx_pause,
342 		    tp->pkt_cnt);
343 
344 	if (ether_addr_equal(tp->peermac, priv->netdev->dev_addr)) {
345 		if (tp->tx_pause)
346 			priv->port_open = false;
347 		else
348 			priv->port_open = true;
349 	} else if (is_multicast_ether_addr(tp->peermac)) {
350 		mwifiex_update_ralist_tx_pause(priv, tp->peermac, tp->tx_pause);
351 	} else {
352 		spin_lock_bh(&priv->sta_list_spinlock);
353 		sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac);
354 		if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) {
355 			sta_ptr->tx_pause = tp->tx_pause;
356 			spin_unlock_bh(&priv->sta_list_spinlock);
357 			mwifiex_update_ralist_tx_pause(priv, tp->peermac,
358 						       tp->tx_pause);
359 		} else {
360 			spin_unlock_bh(&priv->sta_list_spinlock);
361 		}
362 	}
363 }
364 
mwifiex_process_sta_tx_pause(struct mwifiex_private * priv,struct mwifiex_ie_types_header * tlv)365 static void mwifiex_process_sta_tx_pause(struct mwifiex_private *priv,
366 					 struct mwifiex_ie_types_header *tlv)
367 {
368 	struct mwifiex_tx_pause_tlv *tp;
369 	struct mwifiex_sta_node *sta_ptr;
370 	int status;
371 
372 	tp = (void *)tlv;
373 	mwifiex_dbg(priv->adapter, EVENT,
374 		    "sta tx_pause: %pM pause=%d, pkts=%d\n",
375 		    tp->peermac, tp->tx_pause,
376 		    tp->pkt_cnt);
377 
378 	if (ether_addr_equal(tp->peermac, priv->cfg_bssid)) {
379 		if (tp->tx_pause)
380 			priv->port_open = false;
381 		else
382 			priv->port_open = true;
383 	} else {
384 		if (!ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info))
385 			return;
386 
387 		status = mwifiex_get_tdls_link_status(priv, tp->peermac);
388 		if (mwifiex_is_tdls_link_setup(status)) {
389 			spin_lock_bh(&priv->sta_list_spinlock);
390 			sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac);
391 			if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) {
392 				sta_ptr->tx_pause = tp->tx_pause;
393 				spin_unlock_bh(&priv->sta_list_spinlock);
394 				mwifiex_update_ralist_tx_pause(priv,
395 							       tp->peermac,
396 							       tp->tx_pause);
397 			} else {
398 				spin_unlock_bh(&priv->sta_list_spinlock);
399 			}
400 		}
401 	}
402 }
403 
mwifiex_process_multi_chan_event(struct mwifiex_private * priv,struct sk_buff * event_skb)404 void mwifiex_process_multi_chan_event(struct mwifiex_private *priv,
405 				      struct sk_buff *event_skb)
406 {
407 	struct mwifiex_ie_types_multi_chan_info *chan_info;
408 	struct mwifiex_ie_types_mc_group_info *grp_info;
409 	struct mwifiex_adapter *adapter = priv->adapter;
410 	struct mwifiex_ie_types_header *tlv;
411 	u16 tlv_buf_left, tlv_type, tlv_len;
412 	int intf_num, bss_type, bss_num, i;
413 	struct mwifiex_private *intf_priv;
414 
415 	tlv_buf_left = event_skb->len - sizeof(u32);
416 	chan_info = (void *)event_skb->data + sizeof(u32);
417 
418 	if (le16_to_cpu(chan_info->header.type) != TLV_TYPE_MULTI_CHAN_INFO ||
419 	    tlv_buf_left < sizeof(struct mwifiex_ie_types_multi_chan_info)) {
420 		mwifiex_dbg(adapter, ERROR,
421 			    "unknown TLV in chan_info event\n");
422 		return;
423 	}
424 
425 	adapter->usb_mc_status = le16_to_cpu(chan_info->status);
426 	mwifiex_dbg(adapter, EVENT, "multi chan operation %s\n",
427 		    adapter->usb_mc_status ? "started" : "over");
428 
429 	tlv_buf_left -= sizeof(struct mwifiex_ie_types_multi_chan_info);
430 	tlv = (struct mwifiex_ie_types_header *)chan_info->tlv_buffer;
431 
432 	while (tlv_buf_left >= (int)sizeof(struct mwifiex_ie_types_header)) {
433 		tlv_type = le16_to_cpu(tlv->type);
434 		tlv_len  = le16_to_cpu(tlv->len);
435 		if ((sizeof(struct mwifiex_ie_types_header) + tlv_len) >
436 		    tlv_buf_left) {
437 			mwifiex_dbg(adapter, ERROR, "wrong tlv: tlvLen=%d,\t"
438 				    "tlvBufLeft=%d\n", tlv_len, tlv_buf_left);
439 			break;
440 		}
441 		if (tlv_type != TLV_TYPE_MC_GROUP_INFO) {
442 			mwifiex_dbg(adapter, ERROR, "wrong tlv type: 0x%x\n",
443 				    tlv_type);
444 			break;
445 		}
446 
447 		grp_info = (struct mwifiex_ie_types_mc_group_info *)tlv;
448 		intf_num = grp_info->intf_num;
449 		for (i = 0; i < intf_num; i++) {
450 			bss_type = grp_info->bss_type_numlist[i] >> 4;
451 			bss_num = grp_info->bss_type_numlist[i] & BSS_NUM_MASK;
452 			intf_priv = mwifiex_get_priv_by_id(adapter, bss_num,
453 							   bss_type);
454 			if (!intf_priv) {
455 				mwifiex_dbg(adapter, ERROR,
456 					    "Invalid bss_type bss_num\t"
457 					    "in multi channel event\n");
458 				continue;
459 			}
460 			if (adapter->iface_type == MWIFIEX_USB) {
461 				u8 ep;
462 
463 				ep = grp_info->hid_num.usb_ep_num;
464 				if (ep == MWIFIEX_USB_EP_DATA ||
465 				    ep == MWIFIEX_USB_EP_DATA_CH2)
466 					intf_priv->usb_port = ep;
467 			}
468 		}
469 
470 		tlv_buf_left -= sizeof(struct mwifiex_ie_types_header) +
471 				tlv_len;
472 		tlv = (void *)((u8 *)tlv + tlv_len +
473 			       sizeof(struct mwifiex_ie_types_header));
474 	}
475 
476 	if (adapter->iface_type == MWIFIEX_USB) {
477 		adapter->tx_lock_flag = true;
478 		adapter->usb_mc_setup = true;
479 		mwifiex_multi_chan_resync(adapter);
480 	}
481 }
482 
mwifiex_process_tx_pause_event(struct mwifiex_private * priv,struct sk_buff * event_skb)483 void mwifiex_process_tx_pause_event(struct mwifiex_private *priv,
484 				    struct sk_buff *event_skb)
485 {
486 	struct mwifiex_ie_types_header *tlv;
487 	u16 tlv_type, tlv_len;
488 	int tlv_buf_left;
489 
490 	if (!priv->media_connected) {
491 		mwifiex_dbg(priv->adapter, ERROR,
492 			    "tx_pause event while disconnected; bss_role=%d\n",
493 			    priv->bss_role);
494 		return;
495 	}
496 
497 	tlv_buf_left = event_skb->len - sizeof(u32);
498 	tlv = (void *)event_skb->data + sizeof(u32);
499 
500 	while (tlv_buf_left >= (int)sizeof(struct mwifiex_ie_types_header)) {
501 		tlv_type = le16_to_cpu(tlv->type);
502 		tlv_len  = le16_to_cpu(tlv->len);
503 		if ((sizeof(struct mwifiex_ie_types_header) + tlv_len) >
504 		    tlv_buf_left) {
505 			mwifiex_dbg(priv->adapter, ERROR,
506 				    "wrong tlv: tlvLen=%d, tlvBufLeft=%d\n",
507 				    tlv_len, tlv_buf_left);
508 			break;
509 		}
510 		if (tlv_type == TLV_TYPE_TX_PAUSE) {
511 			if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA)
512 				mwifiex_process_sta_tx_pause(priv, tlv);
513 			else
514 				mwifiex_process_uap_tx_pause(priv, tlv);
515 		}
516 
517 		tlv_buf_left -= sizeof(struct mwifiex_ie_types_header) +
518 				tlv_len;
519 		tlv = (void *)((u8 *)tlv + tlv_len +
520 			       sizeof(struct mwifiex_ie_types_header));
521 	}
522 
523 }
524 
525 /*
526 * This function handles coex events generated by firmware
527 */
mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private * priv,struct sk_buff * event_skb)528 void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
529 					     struct sk_buff *event_skb)
530 {
531 	struct mwifiex_adapter *adapter = priv->adapter;
532 	struct mwifiex_ie_types_header *tlv;
533 	struct mwifiex_ie_types_btcoex_aggr_win_size *winsizetlv;
534 	struct mwifiex_ie_types_btcoex_scan_time *scantlv;
535 	s32 len = event_skb->len - sizeof(u32);
536 	u8 *cur_ptr = event_skb->data + sizeof(u32);
537 	u16 tlv_type, tlv_len;
538 
539 	while (len >= sizeof(struct mwifiex_ie_types_header)) {
540 		tlv = (struct mwifiex_ie_types_header *)cur_ptr;
541 		tlv_len = le16_to_cpu(tlv->len);
542 		tlv_type = le16_to_cpu(tlv->type);
543 
544 		if ((tlv_len + sizeof(struct mwifiex_ie_types_header)) > len)
545 			break;
546 		switch (tlv_type) {
547 		case TLV_BTCOEX_WL_AGGR_WINSIZE:
548 			winsizetlv =
549 			    (struct mwifiex_ie_types_btcoex_aggr_win_size *)tlv;
550 			adapter->coex_win_size = winsizetlv->coex_win_size;
551 			adapter->coex_tx_win_size =
552 				winsizetlv->tx_win_size;
553 			adapter->coex_rx_win_size =
554 				winsizetlv->rx_win_size;
555 			mwifiex_coex_ampdu_rxwinsize(adapter);
556 			mwifiex_update_ampdu_txwinsize(adapter);
557 			break;
558 
559 		case TLV_BTCOEX_WL_SCANTIME:
560 			scantlv =
561 			    (struct mwifiex_ie_types_btcoex_scan_time *)tlv;
562 			adapter->coex_scan = scantlv->coex_scan;
563 			adapter->coex_min_scan_time = le16_to_cpu(scantlv->min_scan_time);
564 			adapter->coex_max_scan_time = le16_to_cpu(scantlv->max_scan_time);
565 			break;
566 
567 		default:
568 			break;
569 		}
570 
571 		len -= tlv_len + sizeof(struct mwifiex_ie_types_header);
572 		cur_ptr += tlv_len +
573 			sizeof(struct mwifiex_ie_types_header);
574 	}
575 
576 	dev_dbg(adapter->dev, "coex_scan=%d min_scan=%d coex_win=%d, tx_win=%d rx_win=%d\n",
577 		adapter->coex_scan, adapter->coex_min_scan_time,
578 		adapter->coex_win_size, adapter->coex_tx_win_size,
579 		adapter->coex_rx_win_size);
580 }
581 
582 static void
mwifiex_fw_dump_info_event(struct mwifiex_private * priv,struct sk_buff * event_skb)583 mwifiex_fw_dump_info_event(struct mwifiex_private *priv,
584 			   struct sk_buff *event_skb)
585 {
586 	struct mwifiex_adapter *adapter = priv->adapter;
587 	struct mwifiex_fw_dump_header *fw_dump_hdr =
588 				(void *)adapter->event_body;
589 
590 	if (adapter->iface_type != MWIFIEX_USB) {
591 		mwifiex_dbg(adapter, MSG,
592 			    "event is not on usb interface, ignore it\n");
593 		return;
594 	}
595 
596 	if (!adapter->devdump_data) {
597 		/* When receive the first event, allocate device dump
598 		 * buffer, dump driver info.
599 		 */
600 		adapter->devdump_data = vzalloc(MWIFIEX_FW_DUMP_SIZE);
601 		if (!adapter->devdump_data) {
602 			mwifiex_dbg(adapter, ERROR,
603 				    "vzalloc devdump data failure!\n");
604 			return;
605 		}
606 
607 		mwifiex_drv_info_dump(adapter);
608 
609 		/* If no proceeded event arrive in 10s, upload device
610 		 * dump data, this will be useful if the end of
611 		 * transmission event get lost, in this cornel case,
612 		 * user would still get partial of the dump.
613 		 */
614 		schedule_delayed_work(&adapter->devdump_work,
615 				      msecs_to_jiffies(MWIFIEX_TIMER_10S));
616 	}
617 
618 	/* Overflow check */
619 	if (adapter->devdump_len + event_skb->len >= MWIFIEX_FW_DUMP_SIZE)
620 		goto upload_dump;
621 
622 	memmove(adapter->devdump_data + adapter->devdump_len,
623 		adapter->event_skb->data, event_skb->len);
624 	adapter->devdump_len += event_skb->len;
625 
626 	if (le16_to_cpu(fw_dump_hdr->type) == FW_DUMP_INFO_ENDED) {
627 		mwifiex_dbg(adapter, MSG,
628 			    "receive end of transmission flag event!\n");
629 		goto upload_dump;
630 	}
631 	return;
632 
633 upload_dump:
634 	cancel_delayed_work_sync(&adapter->devdump_work);
635 	mwifiex_upload_device_dump(adapter);
636 }
637 
638 /*
639  * This function handles events generated by firmware.
640  *
641  * This is a generic function and handles all events.
642  *
643  * Event specific routines are called by this function based
644  * upon the generated event cause.
645  *
646  * For the following events, the function just forwards them to upper
647  * layers, optionally recording the change -
648  *      - EVENT_LINK_SENSED
649  *      - EVENT_MIC_ERR_UNICAST
650  *      - EVENT_MIC_ERR_MULTICAST
651  *      - EVENT_PORT_RELEASE
652  *      - EVENT_RSSI_LOW
653  *      - EVENT_SNR_LOW
654  *      - EVENT_MAX_FAIL
655  *      - EVENT_RSSI_HIGH
656  *      - EVENT_SNR_HIGH
657  *      - EVENT_DATA_RSSI_LOW
658  *      - EVENT_DATA_SNR_LOW
659  *      - EVENT_DATA_RSSI_HIGH
660  *      - EVENT_DATA_SNR_HIGH
661  *      - EVENT_LINK_QUALITY
662  *      - EVENT_PRE_BEACON_LOST
663  *      - EVENT_IBSS_COALESCED
664  *      - EVENT_IBSS_STA_CONNECT
665  *      - EVENT_IBSS_STA_DISCONNECT
666  *      - EVENT_WEP_ICV_ERR
667  *      - EVENT_BW_CHANGE
668  *      - EVENT_HOSTWAKE_STAIE
669   *
670  * For the following events, no action is taken -
671  *      - EVENT_MIB_CHANGED
672  *      - EVENT_INIT_DONE
673  *      - EVENT_DUMMY_HOST_WAKEUP_SIGNAL
674  *
675  * Rest of the supported events requires driver handling -
676  *      - EVENT_DEAUTHENTICATED
677  *      - EVENT_DISASSOCIATED
678  *      - EVENT_LINK_LOST
679  *      - EVENT_PS_SLEEP
680  *      - EVENT_PS_AWAKE
681  *      - EVENT_DEEP_SLEEP_AWAKE
682  *      - EVENT_HS_ACT_REQ
683  *      - EVENT_ADHOC_BCN_LOST
684  *      - EVENT_BG_SCAN_REPORT
685  *      - EVENT_WMM_STATUS_CHANGE
686  *      - EVENT_ADDBA
687  *      - EVENT_DELBA
688  *      - EVENT_BA_STREAM_TIEMOUT
689  *      - EVENT_AMSDU_AGGR_CTRL
690  *      - EVENT_FW_DUMP_INFO
691  */
mwifiex_process_sta_event(struct mwifiex_private * priv)692 int mwifiex_process_sta_event(struct mwifiex_private *priv)
693 {
694 	struct mwifiex_adapter *adapter = priv->adapter;
695 	int ret = 0, i;
696 	u32 eventcause = adapter->event_cause;
697 	u16 ctrl, reason_code;
698 	u8 ibss_sta_addr[ETH_ALEN];
699 	struct mwifiex_sta_node *sta_ptr;
700 
701 	switch (eventcause) {
702 	case EVENT_DUMMY_HOST_WAKEUP_SIGNAL:
703 		mwifiex_dbg(adapter, ERROR,
704 			    "invalid EVENT: DUMMY_HOST_WAKEUP_SIGNAL, ignore it\n");
705 		break;
706 	case EVENT_LINK_SENSED:
707 		mwifiex_dbg(adapter, EVENT, "event: LINK_SENSED\n");
708 		if (!netif_carrier_ok(priv->netdev))
709 			netif_carrier_on(priv->netdev);
710 		mwifiex_wake_up_net_dev_queue(priv->netdev, adapter);
711 		break;
712 
713 	case EVENT_DEAUTHENTICATED:
714 		mwifiex_dbg(adapter, EVENT, "event: Deauthenticated\n");
715 		if (priv->wps.session_enable) {
716 			mwifiex_dbg(adapter, INFO,
717 				    "info: receive deauth event in wps session\n");
718 			break;
719 		}
720 		adapter->dbg.num_event_deauth++;
721 		if (priv->media_connected) {
722 			reason_code =
723 				get_unaligned_le16(adapter->event_body);
724 			mwifiex_reset_connect_state(priv, reason_code, true);
725 		}
726 		break;
727 
728 	case EVENT_DISASSOCIATED:
729 		mwifiex_dbg(adapter, EVENT, "event: Disassociated\n");
730 		if (priv->wps.session_enable) {
731 			mwifiex_dbg(adapter, INFO,
732 				    "info: receive disassoc event in wps session\n");
733 			break;
734 		}
735 		adapter->dbg.num_event_disassoc++;
736 		if (priv->media_connected) {
737 			reason_code =
738 				get_unaligned_le16(adapter->event_body);
739 			mwifiex_reset_connect_state(priv, reason_code, true);
740 		}
741 		break;
742 
743 	case EVENT_LINK_LOST:
744 		mwifiex_dbg(adapter, EVENT, "event: Link lost\n");
745 		adapter->dbg.num_event_link_lost++;
746 		if (priv->media_connected) {
747 			reason_code =
748 				get_unaligned_le16(adapter->event_body);
749 			mwifiex_reset_connect_state(priv, reason_code, true);
750 		}
751 		break;
752 
753 	case EVENT_PS_SLEEP:
754 		mwifiex_dbg(adapter, EVENT, "info: EVENT: SLEEP\n");
755 
756 		adapter->ps_state = PS_STATE_PRE_SLEEP;
757 
758 		mwifiex_check_ps_cond(adapter);
759 		break;
760 
761 	case EVENT_PS_AWAKE:
762 		mwifiex_dbg(adapter, EVENT, "info: EVENT: AWAKE\n");
763 		if (!adapter->pps_uapsd_mode &&
764 		    (priv->port_open ||
765 		     (priv->bss_mode == NL80211_IFTYPE_ADHOC)) &&
766 		    priv->media_connected && adapter->sleep_period.period) {
767 			adapter->pps_uapsd_mode = true;
768 			mwifiex_dbg(adapter, EVENT,
769 				    "event: PPS/UAPSD mode activated\n");
770 		}
771 		adapter->tx_lock_flag = false;
772 		if (adapter->pps_uapsd_mode && adapter->gen_null_pkt) {
773 			if (mwifiex_check_last_packet_indication(priv)) {
774 				if (adapter->data_sent ||
775 				    (adapter->if_ops.is_port_ready &&
776 				     !adapter->if_ops.is_port_ready(priv))) {
777 					adapter->ps_state = PS_STATE_AWAKE;
778 					adapter->pm_wakeup_card_req = false;
779 					adapter->pm_wakeup_fw_try = false;
780 					del_timer(&adapter->wakeup_timer);
781 					break;
782 				}
783 				if (!mwifiex_send_null_packet
784 					(priv,
785 					 MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET |
786 					 MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET))
787 						adapter->ps_state =
788 							PS_STATE_SLEEP;
789 					return 0;
790 			}
791 		}
792 		adapter->ps_state = PS_STATE_AWAKE;
793 		adapter->pm_wakeup_card_req = false;
794 		adapter->pm_wakeup_fw_try = false;
795 		del_timer(&adapter->wakeup_timer);
796 
797 		break;
798 
799 	case EVENT_DEEP_SLEEP_AWAKE:
800 		adapter->if_ops.wakeup_complete(adapter);
801 		mwifiex_dbg(adapter, EVENT, "event: DS_AWAKE\n");
802 		if (adapter->is_deep_sleep)
803 			adapter->is_deep_sleep = false;
804 		break;
805 
806 	case EVENT_HS_ACT_REQ:
807 		mwifiex_dbg(adapter, EVENT, "event: HS_ACT_REQ\n");
808 		ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_HS_CFG_ENH,
809 				       0, 0, NULL, false);
810 		break;
811 
812 	case EVENT_MIC_ERR_UNICAST:
813 		mwifiex_dbg(adapter, EVENT, "event: UNICAST MIC ERROR\n");
814 		cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
815 					     NL80211_KEYTYPE_PAIRWISE,
816 					     -1, NULL, GFP_KERNEL);
817 		break;
818 
819 	case EVENT_MIC_ERR_MULTICAST:
820 		mwifiex_dbg(adapter, EVENT, "event: MULTICAST MIC ERROR\n");
821 		cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
822 					     NL80211_KEYTYPE_GROUP,
823 					     -1, NULL, GFP_KERNEL);
824 		break;
825 	case EVENT_MIB_CHANGED:
826 	case EVENT_INIT_DONE:
827 		break;
828 
829 	case EVENT_ADHOC_BCN_LOST:
830 		mwifiex_dbg(adapter, EVENT, "event: ADHOC_BCN_LOST\n");
831 		priv->adhoc_is_link_sensed = false;
832 		mwifiex_clean_txrx(priv);
833 		mwifiex_stop_net_dev_queue(priv->netdev, adapter);
834 		if (netif_carrier_ok(priv->netdev))
835 			netif_carrier_off(priv->netdev);
836 		break;
837 
838 	case EVENT_BG_SCAN_REPORT:
839 		mwifiex_dbg(adapter, EVENT, "event: BGS_REPORT\n");
840 		ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_BG_SCAN_QUERY,
841 				       HostCmd_ACT_GEN_GET, 0, NULL, false);
842 		break;
843 
844 	case EVENT_BG_SCAN_STOPPED:
845 		dev_dbg(adapter->dev, "event: BGS_STOPPED\n");
846 		cfg80211_sched_scan_stopped(priv->wdev.wiphy, 0);
847 		if (priv->sched_scanning)
848 			priv->sched_scanning = false;
849 		break;
850 
851 	case EVENT_PORT_RELEASE:
852 		mwifiex_dbg(adapter, EVENT, "event: PORT RELEASE\n");
853 		priv->port_open = true;
854 		break;
855 
856 	case EVENT_EXT_SCAN_REPORT:
857 		mwifiex_dbg(adapter, EVENT, "event: EXT_SCAN Report\n");
858 		/* We intend to skip this event during suspend, but handle
859 		 * it in interface disabled case
860 		 */
861 		if (adapter->ext_scan && (!priv->scan_aborting ||
862 					  !netif_running(priv->netdev)))
863 			ret = mwifiex_handle_event_ext_scan_report(priv,
864 						adapter->event_skb->data);
865 
866 		break;
867 
868 	case EVENT_WMM_STATUS_CHANGE:
869 		mwifiex_dbg(adapter, EVENT, "event: WMM status changed\n");
870 		ret = mwifiex_send_cmd(priv, HostCmd_CMD_WMM_GET_STATUS,
871 				       0, 0, NULL, false);
872 		break;
873 
874 	case EVENT_RSSI_LOW:
875 		cfg80211_cqm_rssi_notify(priv->netdev,
876 					 NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
877 					 0, GFP_KERNEL);
878 		mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
879 				 HostCmd_ACT_GEN_GET, 0, NULL, false);
880 		priv->subsc_evt_rssi_state = RSSI_LOW_RECVD;
881 		mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_LOW\n");
882 		break;
883 	case EVENT_SNR_LOW:
884 		mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_LOW\n");
885 		break;
886 	case EVENT_MAX_FAIL:
887 		mwifiex_dbg(adapter, EVENT, "event: MAX_FAIL\n");
888 		break;
889 	case EVENT_RSSI_HIGH:
890 		cfg80211_cqm_rssi_notify(priv->netdev,
891 					 NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
892 					 0, GFP_KERNEL);
893 		mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
894 				 HostCmd_ACT_GEN_GET, 0, NULL, false);
895 		priv->subsc_evt_rssi_state = RSSI_HIGH_RECVD;
896 		mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_HIGH\n");
897 		break;
898 	case EVENT_SNR_HIGH:
899 		mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_HIGH\n");
900 		break;
901 	case EVENT_DATA_RSSI_LOW:
902 		mwifiex_dbg(adapter, EVENT, "event: Data RSSI_LOW\n");
903 		break;
904 	case EVENT_DATA_SNR_LOW:
905 		mwifiex_dbg(adapter, EVENT, "event: Data SNR_LOW\n");
906 		break;
907 	case EVENT_DATA_RSSI_HIGH:
908 		mwifiex_dbg(adapter, EVENT, "event: Data RSSI_HIGH\n");
909 		break;
910 	case EVENT_DATA_SNR_HIGH:
911 		mwifiex_dbg(adapter, EVENT, "event: Data SNR_HIGH\n");
912 		break;
913 	case EVENT_LINK_QUALITY:
914 		mwifiex_dbg(adapter, EVENT, "event: Link Quality\n");
915 		break;
916 	case EVENT_PRE_BEACON_LOST:
917 		mwifiex_dbg(adapter, EVENT, "event: Pre-Beacon Lost\n");
918 		break;
919 	case EVENT_IBSS_COALESCED:
920 		mwifiex_dbg(adapter, EVENT, "event: IBSS_COALESCED\n");
921 		ret = mwifiex_send_cmd(priv,
922 				HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
923 				HostCmd_ACT_GEN_GET, 0, NULL, false);
924 		break;
925 	case EVENT_IBSS_STA_CONNECT:
926 		ether_addr_copy(ibss_sta_addr, adapter->event_body + 2);
927 		mwifiex_dbg(adapter, EVENT, "event: IBSS_STA_CONNECT %pM\n",
928 			    ibss_sta_addr);
929 		sta_ptr = mwifiex_add_sta_entry(priv, ibss_sta_addr);
930 		if (sta_ptr && adapter->adhoc_11n_enabled) {
931 			mwifiex_check_ibss_peer_capabilities(priv, sta_ptr,
932 							     adapter->event_skb);
933 			if (sta_ptr->is_11n_enabled)
934 				for (i = 0; i < MAX_NUM_TID; i++)
935 					sta_ptr->ampdu_sta[i] =
936 					priv->aggr_prio_tbl[i].ampdu_user;
937 			else
938 				for (i = 0; i < MAX_NUM_TID; i++)
939 					sta_ptr->ampdu_sta[i] =
940 						BA_STREAM_NOT_ALLOWED;
941 			memset(sta_ptr->rx_seq, 0xff, sizeof(sta_ptr->rx_seq));
942 		}
943 
944 		break;
945 	case EVENT_IBSS_STA_DISCONNECT:
946 		ether_addr_copy(ibss_sta_addr, adapter->event_body + 2);
947 		mwifiex_dbg(adapter, EVENT, "event: IBSS_STA_DISCONNECT %pM\n",
948 			    ibss_sta_addr);
949 		sta_ptr = mwifiex_get_sta_entry(priv, ibss_sta_addr);
950 		if (sta_ptr && sta_ptr->is_11n_enabled) {
951 			mwifiex_11n_del_rx_reorder_tbl_by_ta(priv,
952 							     ibss_sta_addr);
953 			mwifiex_del_tx_ba_stream_tbl_by_ra(priv, ibss_sta_addr);
954 		}
955 		mwifiex_wmm_del_peer_ra_list(priv, ibss_sta_addr);
956 		mwifiex_del_sta_entry(priv, ibss_sta_addr);
957 		break;
958 	case EVENT_ADDBA:
959 		mwifiex_dbg(adapter, EVENT, "event: ADDBA Request\n");
960 		mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_RSP,
961 				 HostCmd_ACT_GEN_SET, 0,
962 				 adapter->event_body, false);
963 		break;
964 	case EVENT_DELBA:
965 		mwifiex_dbg(adapter, EVENT, "event: DELBA Request\n");
966 		mwifiex_11n_delete_ba_stream(priv, adapter->event_body);
967 		break;
968 	case EVENT_BA_STREAM_TIEMOUT:
969 		mwifiex_dbg(adapter, EVENT, "event:  BA Stream timeout\n");
970 		mwifiex_11n_ba_stream_timeout(priv,
971 					      (struct host_cmd_ds_11n_batimeout
972 					       *)
973 					      adapter->event_body);
974 		break;
975 	case EVENT_AMSDU_AGGR_CTRL:
976 		ctrl = get_unaligned_le16(adapter->event_body);
977 		mwifiex_dbg(adapter, EVENT,
978 			    "event: AMSDU_AGGR_CTRL %d\n", ctrl);
979 
980 		adapter->tx_buf_size =
981 				min_t(u16, adapter->curr_tx_buf_size, ctrl);
982 		mwifiex_dbg(adapter, EVENT, "event: tx_buf_size %d\n",
983 			    adapter->tx_buf_size);
984 		break;
985 
986 	case EVENT_WEP_ICV_ERR:
987 		mwifiex_dbg(adapter, EVENT, "event: WEP ICV error\n");
988 		break;
989 
990 	case EVENT_BW_CHANGE:
991 		mwifiex_dbg(adapter, EVENT, "event: BW Change\n");
992 		break;
993 
994 	case EVENT_HOSTWAKE_STAIE:
995 		mwifiex_dbg(adapter, EVENT,
996 			    "event: HOSTWAKE_STAIE %d\n", eventcause);
997 		break;
998 
999 	case EVENT_REMAIN_ON_CHAN_EXPIRED:
1000 		mwifiex_dbg(adapter, EVENT,
1001 			    "event: Remain on channel expired\n");
1002 		cfg80211_remain_on_channel_expired(&priv->wdev,
1003 						   priv->roc_cfg.cookie,
1004 						   &priv->roc_cfg.chan,
1005 						   GFP_ATOMIC);
1006 
1007 		memset(&priv->roc_cfg, 0x00, sizeof(struct mwifiex_roc_cfg));
1008 
1009 		break;
1010 
1011 	case EVENT_CHANNEL_SWITCH_ANN:
1012 		mwifiex_dbg(adapter, EVENT, "event: Channel Switch Announcement\n");
1013 		priv->csa_expire_time =
1014 				jiffies + msecs_to_jiffies(DFS_CHAN_MOVE_TIME);
1015 		priv->csa_chan = priv->curr_bss_params.bss_descriptor.channel;
1016 		ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_DEAUTHENTICATE,
1017 			HostCmd_ACT_GEN_SET, 0,
1018 			priv->curr_bss_params.bss_descriptor.mac_address,
1019 			false);
1020 		break;
1021 
1022 	case EVENT_TDLS_GENERIC_EVENT:
1023 		ret = mwifiex_parse_tdls_event(priv, adapter->event_skb);
1024 		break;
1025 
1026 	case EVENT_TX_DATA_PAUSE:
1027 		mwifiex_dbg(adapter, EVENT, "event: TX DATA PAUSE\n");
1028 		mwifiex_process_tx_pause_event(priv, adapter->event_skb);
1029 		break;
1030 
1031 	case EVENT_MULTI_CHAN_INFO:
1032 		mwifiex_dbg(adapter, EVENT, "event: multi-chan info\n");
1033 		mwifiex_process_multi_chan_event(priv, adapter->event_skb);
1034 		break;
1035 
1036 	case EVENT_TX_STATUS_REPORT:
1037 		mwifiex_dbg(adapter, EVENT, "event: TX_STATUS Report\n");
1038 		mwifiex_parse_tx_status_event(priv, adapter->event_body);
1039 		break;
1040 
1041 	case EVENT_CHANNEL_REPORT_RDY:
1042 		mwifiex_dbg(adapter, EVENT, "event: Channel Report\n");
1043 		ret = mwifiex_11h_handle_chanrpt_ready(priv,
1044 						       adapter->event_skb);
1045 		break;
1046 	case EVENT_RADAR_DETECTED:
1047 		mwifiex_dbg(adapter, EVENT, "event: Radar detected\n");
1048 		ret = mwifiex_11h_handle_radar_detected(priv,
1049 							adapter->event_skb);
1050 		break;
1051 	case EVENT_BT_COEX_WLAN_PARA_CHANGE:
1052 		dev_dbg(adapter->dev, "EVENT: BT coex wlan param update\n");
1053 		if (adapter->ignore_btcoex_events)
1054 			break;
1055 
1056 		mwifiex_bt_coex_wlan_param_update_event(priv,
1057 							adapter->event_skb);
1058 		break;
1059 	case EVENT_RXBA_SYNC:
1060 		dev_dbg(adapter->dev, "EVENT: RXBA_SYNC\n");
1061 		mwifiex_11n_rxba_sync_event(priv, adapter->event_body,
1062 					    adapter->event_skb->len -
1063 					    sizeof(eventcause));
1064 		break;
1065 	case EVENT_FW_DUMP_INFO:
1066 		mwifiex_dbg(adapter, EVENT, "event: firmware debug info\n");
1067 		mwifiex_fw_dump_info_event(priv, adapter->event_skb);
1068 		break;
1069 	/* Debugging event; not used, but let's not print an ERROR for it. */
1070 	case EVENT_UNKNOWN_DEBUG:
1071 		mwifiex_dbg(adapter, EVENT, "event: debug\n");
1072 		break;
1073 	default:
1074 		mwifiex_dbg(adapter, ERROR, "event: unknown event id: %#x\n",
1075 			    eventcause);
1076 		break;
1077 	}
1078 
1079 	return ret;
1080 }
1081