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