sta_event.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  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. #include "decl.h"
  20. #include "ioctl.h"
  21. #include "util.h"
  22. #include "fw.h"
  23. #include "main.h"
  24. #include "wmm.h"
  25. #include "11n.h"
  26. /*
  27. * This function resets the connection state.
  28. *
  29. * The function is invoked after receiving a disconnect event from firmware,
  30. * and performs the following actions -
  31. * - Set media status to disconnected
  32. * - Clean up Tx and Rx packets
  33. * - Resets SNR/NF/RSSI value in driver
  34. * - Resets security configurations in driver
  35. * - Enables auto data rate
  36. * - Saves the previous SSID and BSSID so that they can
  37. * be used for re-association, if required
  38. * - Erases current SSID and BSSID information
  39. * - Sends a disconnect event to upper layers/applications.
  40. */
  41. void
  42. mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason_code)
  43. {
  44. struct mwifiex_adapter *adapter = priv->adapter;
  45. if (!priv->media_connected)
  46. return;
  47. mwifiex_dbg(adapter, INFO,
  48. "info: handles disconnect event\n");
  49. priv->media_connected = false;
  50. priv->scan_block = false;
  51. priv->port_open = false;
  52. if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
  53. ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info)) {
  54. mwifiex_disable_all_tdls_links(priv);
  55. if (priv->adapter->auto_tdls)
  56. mwifiex_clean_auto_tdls(priv);
  57. }
  58. /* Free Tx and Rx packets, report disconnect to upper layer */
  59. mwifiex_clean_txrx(priv);
  60. /* Reset SNR/NF/RSSI values */
  61. priv->data_rssi_last = 0;
  62. priv->data_nf_last = 0;
  63. priv->data_rssi_avg = 0;
  64. priv->data_nf_avg = 0;
  65. priv->bcn_rssi_last = 0;
  66. priv->bcn_nf_last = 0;
  67. priv->bcn_rssi_avg = 0;
  68. priv->bcn_nf_avg = 0;
  69. priv->rxpd_rate = 0;
  70. priv->rxpd_htinfo = 0;
  71. priv->sec_info.wpa_enabled = false;
  72. priv->sec_info.wpa2_enabled = false;
  73. priv->wpa_ie_len = 0;
  74. priv->sec_info.wapi_enabled = false;
  75. priv->wapi_ie_len = 0;
  76. priv->sec_info.wapi_key_on = false;
  77. priv->sec_info.encryption_mode = 0;
  78. /* Enable auto data rate */
  79. priv->is_data_rate_auto = true;
  80. priv->data_rate = 0;
  81. if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA ||
  82. GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) && priv->hist_data)
  83. mwifiex_hist_data_reset(priv);
  84. if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
  85. priv->adhoc_state = ADHOC_IDLE;
  86. priv->adhoc_is_link_sensed = false;
  87. }
  88. /*
  89. * Memorize the previous SSID and BSSID so
  90. * it could be used for re-assoc
  91. */
  92. mwifiex_dbg(adapter, INFO,
  93. "info: previous SSID=%s, SSID len=%u\n",
  94. priv->prev_ssid.ssid, priv->prev_ssid.ssid_len);
  95. mwifiex_dbg(adapter, INFO,
  96. "info: current SSID=%s, SSID len=%u\n",
  97. priv->curr_bss_params.bss_descriptor.ssid.ssid,
  98. priv->curr_bss_params.bss_descriptor.ssid.ssid_len);
  99. memcpy(&priv->prev_ssid,
  100. &priv->curr_bss_params.bss_descriptor.ssid,
  101. sizeof(struct cfg80211_ssid));
  102. memcpy(priv->prev_bssid,
  103. priv->curr_bss_params.bss_descriptor.mac_address, ETH_ALEN);
  104. /* Need to erase the current SSID and BSSID info */
  105. memset(&priv->curr_bss_params, 0x00, sizeof(priv->curr_bss_params));
  106. adapter->tx_lock_flag = false;
  107. adapter->pps_uapsd_mode = false;
  108. if (adapter->is_cmd_timedout && adapter->curr_cmd)
  109. return;
  110. priv->media_connected = false;
  111. mwifiex_dbg(adapter, MSG,
  112. "info: successfully disconnected from %pM: reason code %d\n",
  113. priv->cfg_bssid, reason_code);
  114. if (priv->bss_mode == NL80211_IFTYPE_STATION ||
  115. priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) {
  116. cfg80211_disconnected(priv->netdev, reason_code, NULL, 0,
  117. false, GFP_KERNEL);
  118. }
  119. eth_zero_addr(priv->cfg_bssid);
  120. mwifiex_stop_net_dev_queue(priv->netdev, adapter);
  121. if (netif_carrier_ok(priv->netdev))
  122. netif_carrier_off(priv->netdev);
  123. }
  124. static int mwifiex_parse_tdls_event(struct mwifiex_private *priv,
  125. struct sk_buff *event_skb)
  126. {
  127. int ret = 0;
  128. struct mwifiex_adapter *adapter = priv->adapter;
  129. struct mwifiex_sta_node *sta_ptr;
  130. struct mwifiex_tdls_generic_event *tdls_evt =
  131. (void *)event_skb->data + sizeof(adapter->event_cause);
  132. u8 *mac = tdls_evt->peer_mac;
  133. /* reserved 2 bytes are not mandatory in tdls event */
  134. if (event_skb->len < (sizeof(struct mwifiex_tdls_generic_event) -
  135. sizeof(u16) - sizeof(adapter->event_cause))) {
  136. mwifiex_dbg(adapter, ERROR, "Invalid event length!\n");
  137. return -1;
  138. }
  139. sta_ptr = mwifiex_get_sta_entry(priv, tdls_evt->peer_mac);
  140. if (!sta_ptr) {
  141. mwifiex_dbg(adapter, ERROR, "cannot get sta entry!\n");
  142. return -1;
  143. }
  144. switch (le16_to_cpu(tdls_evt->type)) {
  145. case TDLS_EVENT_LINK_TEAR_DOWN:
  146. cfg80211_tdls_oper_request(priv->netdev,
  147. tdls_evt->peer_mac,
  148. NL80211_TDLS_TEARDOWN,
  149. le16_to_cpu(tdls_evt->u.reason_code),
  150. GFP_KERNEL);
  151. break;
  152. case TDLS_EVENT_CHAN_SWITCH_RESULT:
  153. mwifiex_dbg(adapter, EVENT, "tdls channel switch result :\n");
  154. mwifiex_dbg(adapter, EVENT,
  155. "status=0x%x, reason=0x%x cur_chan=%d\n",
  156. tdls_evt->u.switch_result.status,
  157. tdls_evt->u.switch_result.reason,
  158. tdls_evt->u.switch_result.cur_chan);
  159. /* tdls channel switch failed */
  160. if (tdls_evt->u.switch_result.status != 0) {
  161. switch (tdls_evt->u.switch_result.cur_chan) {
  162. case TDLS_BASE_CHANNEL:
  163. sta_ptr->tdls_status = TDLS_IN_BASE_CHAN;
  164. break;
  165. case TDLS_OFF_CHANNEL:
  166. sta_ptr->tdls_status = TDLS_IN_OFF_CHAN;
  167. break;
  168. default:
  169. break;
  170. }
  171. return ret;
  172. }
  173. /* tdls channel switch success */
  174. switch (tdls_evt->u.switch_result.cur_chan) {
  175. case TDLS_BASE_CHANNEL:
  176. if (sta_ptr->tdls_status == TDLS_IN_BASE_CHAN)
  177. break;
  178. mwifiex_update_ralist_tx_pause_in_tdls_cs(priv, mac,
  179. false);
  180. sta_ptr->tdls_status = TDLS_IN_BASE_CHAN;
  181. break;
  182. case TDLS_OFF_CHANNEL:
  183. if (sta_ptr->tdls_status == TDLS_IN_OFF_CHAN)
  184. break;
  185. mwifiex_update_ralist_tx_pause_in_tdls_cs(priv, mac,
  186. true);
  187. sta_ptr->tdls_status = TDLS_IN_OFF_CHAN;
  188. break;
  189. default:
  190. break;
  191. }
  192. break;
  193. case TDLS_EVENT_START_CHAN_SWITCH:
  194. mwifiex_dbg(adapter, EVENT, "tdls start channel switch...\n");
  195. sta_ptr->tdls_status = TDLS_CHAN_SWITCHING;
  196. break;
  197. case TDLS_EVENT_CHAN_SWITCH_STOPPED:
  198. mwifiex_dbg(adapter, EVENT,
  199. "tdls chan switch stopped, reason=%d\n",
  200. tdls_evt->u.cs_stop_reason);
  201. break;
  202. default:
  203. break;
  204. }
  205. return ret;
  206. }
  207. static void mwifiex_process_uap_tx_pause(struct mwifiex_private *priv,
  208. struct mwifiex_ie_types_header *tlv)
  209. {
  210. struct mwifiex_tx_pause_tlv *tp;
  211. struct mwifiex_sta_node *sta_ptr;
  212. unsigned long flags;
  213. tp = (void *)tlv;
  214. mwifiex_dbg(priv->adapter, EVENT,
  215. "uap tx_pause: %pM pause=%d, pkts=%d\n",
  216. tp->peermac, tp->tx_pause,
  217. tp->pkt_cnt);
  218. if (ether_addr_equal(tp->peermac, priv->netdev->dev_addr)) {
  219. if (tp->tx_pause)
  220. priv->port_open = false;
  221. else
  222. priv->port_open = true;
  223. } else if (is_multicast_ether_addr(tp->peermac)) {
  224. mwifiex_update_ralist_tx_pause(priv, tp->peermac, tp->tx_pause);
  225. } else {
  226. spin_lock_irqsave(&priv->sta_list_spinlock, flags);
  227. sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac);
  228. spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
  229. if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) {
  230. sta_ptr->tx_pause = tp->tx_pause;
  231. mwifiex_update_ralist_tx_pause(priv, tp->peermac,
  232. tp->tx_pause);
  233. }
  234. }
  235. }
  236. static void mwifiex_process_sta_tx_pause(struct mwifiex_private *priv,
  237. struct mwifiex_ie_types_header *tlv)
  238. {
  239. struct mwifiex_tx_pause_tlv *tp;
  240. struct mwifiex_sta_node *sta_ptr;
  241. int status;
  242. unsigned long flags;
  243. tp = (void *)tlv;
  244. mwifiex_dbg(priv->adapter, EVENT,
  245. "sta tx_pause: %pM pause=%d, pkts=%d\n",
  246. tp->peermac, tp->tx_pause,
  247. tp->pkt_cnt);
  248. if (ether_addr_equal(tp->peermac, priv->cfg_bssid)) {
  249. if (tp->tx_pause)
  250. priv->port_open = false;
  251. else
  252. priv->port_open = true;
  253. } else {
  254. if (!ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info))
  255. return;
  256. status = mwifiex_get_tdls_link_status(priv, tp->peermac);
  257. if (mwifiex_is_tdls_link_setup(status)) {
  258. spin_lock_irqsave(&priv->sta_list_spinlock, flags);
  259. sta_ptr = mwifiex_get_sta_entry(priv, tp->peermac);
  260. spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
  261. if (sta_ptr && sta_ptr->tx_pause != tp->tx_pause) {
  262. sta_ptr->tx_pause = tp->tx_pause;
  263. mwifiex_update_ralist_tx_pause(priv,
  264. tp->peermac,
  265. tp->tx_pause);
  266. }
  267. }
  268. }
  269. }
  270. void mwifiex_process_multi_chan_event(struct mwifiex_private *priv,
  271. struct sk_buff *event_skb)
  272. {
  273. struct mwifiex_ie_types_multi_chan_info *chan_info;
  274. struct mwifiex_ie_types_mc_group_info *grp_info;
  275. struct mwifiex_adapter *adapter = priv->adapter;
  276. struct mwifiex_ie_types_header *tlv;
  277. u16 tlv_buf_left, tlv_type, tlv_len;
  278. int intf_num, bss_type, bss_num, i;
  279. struct mwifiex_private *intf_priv;
  280. tlv_buf_left = event_skb->len - sizeof(u32);
  281. chan_info = (void *)event_skb->data + sizeof(u32);
  282. if (le16_to_cpu(chan_info->header.type) != TLV_TYPE_MULTI_CHAN_INFO ||
  283. tlv_buf_left < sizeof(struct mwifiex_ie_types_multi_chan_info)) {
  284. mwifiex_dbg(adapter, ERROR,
  285. "unknown TLV in chan_info event\n");
  286. return;
  287. }
  288. adapter->usb_mc_status = le16_to_cpu(chan_info->status);
  289. mwifiex_dbg(adapter, EVENT, "multi chan operation %s\n",
  290. adapter->usb_mc_status ? "started" : "over");
  291. tlv_buf_left -= sizeof(struct mwifiex_ie_types_multi_chan_info);
  292. tlv = (struct mwifiex_ie_types_header *)chan_info->tlv_buffer;
  293. while (tlv_buf_left >= (int)sizeof(struct mwifiex_ie_types_header)) {
  294. tlv_type = le16_to_cpu(tlv->type);
  295. tlv_len = le16_to_cpu(tlv->len);
  296. if ((sizeof(struct mwifiex_ie_types_header) + tlv_len) >
  297. tlv_buf_left) {
  298. mwifiex_dbg(adapter, ERROR, "wrong tlv: tlvLen=%d,\t"
  299. "tlvBufLeft=%d\n", tlv_len, tlv_buf_left);
  300. break;
  301. }
  302. if (tlv_type != TLV_TYPE_MC_GROUP_INFO) {
  303. mwifiex_dbg(adapter, ERROR, "wrong tlv type: 0x%x\n",
  304. tlv_type);
  305. break;
  306. }
  307. grp_info = (struct mwifiex_ie_types_mc_group_info *)tlv;
  308. intf_num = grp_info->intf_num;
  309. for (i = 0; i < intf_num; i++) {
  310. bss_type = grp_info->bss_type_numlist[i] >> 4;
  311. bss_num = grp_info->bss_type_numlist[i] & BSS_NUM_MASK;
  312. intf_priv = mwifiex_get_priv_by_id(adapter, bss_num,
  313. bss_type);
  314. if (!intf_priv) {
  315. mwifiex_dbg(adapter, ERROR,
  316. "Invalid bss_type bss_num\t"
  317. "in multi channel event\n");
  318. continue;
  319. }
  320. if (adapter->iface_type == MWIFIEX_USB) {
  321. u8 ep;
  322. ep = grp_info->hid_num.usb_ep_num;
  323. if (ep == MWIFIEX_USB_EP_DATA ||
  324. ep == MWIFIEX_USB_EP_DATA_CH2)
  325. intf_priv->usb_port = ep;
  326. }
  327. }
  328. tlv_buf_left -= sizeof(struct mwifiex_ie_types_header) +
  329. tlv_len;
  330. tlv = (void *)((u8 *)tlv + tlv_len +
  331. sizeof(struct mwifiex_ie_types_header));
  332. }
  333. if (adapter->iface_type == MWIFIEX_USB) {
  334. adapter->tx_lock_flag = true;
  335. adapter->usb_mc_setup = true;
  336. mwifiex_multi_chan_resync(adapter);
  337. }
  338. }
  339. void mwifiex_process_tx_pause_event(struct mwifiex_private *priv,
  340. struct sk_buff *event_skb)
  341. {
  342. struct mwifiex_ie_types_header *tlv;
  343. u16 tlv_type, tlv_len;
  344. int tlv_buf_left;
  345. if (!priv->media_connected) {
  346. mwifiex_dbg(priv->adapter, ERROR,
  347. "tx_pause event while disconnected; bss_role=%d\n",
  348. priv->bss_role);
  349. return;
  350. }
  351. tlv_buf_left = event_skb->len - sizeof(u32);
  352. tlv = (void *)event_skb->data + sizeof(u32);
  353. while (tlv_buf_left >= (int)sizeof(struct mwifiex_ie_types_header)) {
  354. tlv_type = le16_to_cpu(tlv->type);
  355. tlv_len = le16_to_cpu(tlv->len);
  356. if ((sizeof(struct mwifiex_ie_types_header) + tlv_len) >
  357. tlv_buf_left) {
  358. mwifiex_dbg(priv->adapter, ERROR,
  359. "wrong tlv: tlvLen=%d, tlvBufLeft=%d\n",
  360. tlv_len, tlv_buf_left);
  361. break;
  362. }
  363. if (tlv_type == TLV_TYPE_TX_PAUSE) {
  364. if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA)
  365. mwifiex_process_sta_tx_pause(priv, tlv);
  366. else
  367. mwifiex_process_uap_tx_pause(priv, tlv);
  368. }
  369. tlv_buf_left -= sizeof(struct mwifiex_ie_types_header) +
  370. tlv_len;
  371. tlv = (void *)((u8 *)tlv + tlv_len +
  372. sizeof(struct mwifiex_ie_types_header));
  373. }
  374. }
  375. /*
  376. * This function handles coex events generated by firmware
  377. */
  378. void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
  379. struct sk_buff *event_skb)
  380. {
  381. struct mwifiex_adapter *adapter = priv->adapter;
  382. struct mwifiex_ie_types_header *tlv;
  383. struct mwifiex_ie_types_btcoex_aggr_win_size *winsizetlv;
  384. struct mwifiex_ie_types_btcoex_scan_time *scantlv;
  385. s32 len = event_skb->len - sizeof(u32);
  386. u8 *cur_ptr = event_skb->data + sizeof(u32);
  387. u16 tlv_type, tlv_len;
  388. while (len >= sizeof(struct mwifiex_ie_types_header)) {
  389. tlv = (struct mwifiex_ie_types_header *)cur_ptr;
  390. tlv_len = le16_to_cpu(tlv->len);
  391. tlv_type = le16_to_cpu(tlv->type);
  392. if ((tlv_len + sizeof(struct mwifiex_ie_types_header)) > len)
  393. break;
  394. switch (tlv_type) {
  395. case TLV_BTCOEX_WL_AGGR_WINSIZE:
  396. winsizetlv =
  397. (struct mwifiex_ie_types_btcoex_aggr_win_size *)tlv;
  398. adapter->coex_win_size = winsizetlv->coex_win_size;
  399. adapter->coex_tx_win_size =
  400. winsizetlv->tx_win_size;
  401. adapter->coex_rx_win_size =
  402. winsizetlv->rx_win_size;
  403. mwifiex_coex_ampdu_rxwinsize(adapter);
  404. mwifiex_update_ampdu_txwinsize(adapter);
  405. break;
  406. case TLV_BTCOEX_WL_SCANTIME:
  407. scantlv =
  408. (struct mwifiex_ie_types_btcoex_scan_time *)tlv;
  409. adapter->coex_scan = scantlv->coex_scan;
  410. adapter->coex_min_scan_time = scantlv->min_scan_time;
  411. adapter->coex_max_scan_time = scantlv->max_scan_time;
  412. break;
  413. default:
  414. break;
  415. }
  416. len -= tlv_len + sizeof(struct mwifiex_ie_types_header);
  417. cur_ptr += tlv_len +
  418. sizeof(struct mwifiex_ie_types_header);
  419. }
  420. dev_dbg(adapter->dev, "coex_scan=%d min_scan=%d coex_win=%d, tx_win=%d rx_win=%d\n",
  421. adapter->coex_scan, adapter->coex_min_scan_time,
  422. adapter->coex_win_size, adapter->coex_tx_win_size,
  423. adapter->coex_rx_win_size);
  424. }
  425. /*
  426. * This function handles events generated by firmware.
  427. *
  428. * This is a generic function and handles all events.
  429. *
  430. * Event specific routines are called by this function based
  431. * upon the generated event cause.
  432. *
  433. * For the following events, the function just forwards them to upper
  434. * layers, optionally recording the change -
  435. * - EVENT_LINK_SENSED
  436. * - EVENT_MIC_ERR_UNICAST
  437. * - EVENT_MIC_ERR_MULTICAST
  438. * - EVENT_PORT_RELEASE
  439. * - EVENT_RSSI_LOW
  440. * - EVENT_SNR_LOW
  441. * - EVENT_MAX_FAIL
  442. * - EVENT_RSSI_HIGH
  443. * - EVENT_SNR_HIGH
  444. * - EVENT_DATA_RSSI_LOW
  445. * - EVENT_DATA_SNR_LOW
  446. * - EVENT_DATA_RSSI_HIGH
  447. * - EVENT_DATA_SNR_HIGH
  448. * - EVENT_LINK_QUALITY
  449. * - EVENT_PRE_BEACON_LOST
  450. * - EVENT_IBSS_COALESCED
  451. * - EVENT_WEP_ICV_ERR
  452. * - EVENT_BW_CHANGE
  453. * - EVENT_HOSTWAKE_STAIE
  454. *
  455. * For the following events, no action is taken -
  456. * - EVENT_MIB_CHANGED
  457. * - EVENT_INIT_DONE
  458. * - EVENT_DUMMY_HOST_WAKEUP_SIGNAL
  459. *
  460. * Rest of the supported events requires driver handling -
  461. * - EVENT_DEAUTHENTICATED
  462. * - EVENT_DISASSOCIATED
  463. * - EVENT_LINK_LOST
  464. * - EVENT_PS_SLEEP
  465. * - EVENT_PS_AWAKE
  466. * - EVENT_DEEP_SLEEP_AWAKE
  467. * - EVENT_HS_ACT_REQ
  468. * - EVENT_ADHOC_BCN_LOST
  469. * - EVENT_BG_SCAN_REPORT
  470. * - EVENT_WMM_STATUS_CHANGE
  471. * - EVENT_ADDBA
  472. * - EVENT_DELBA
  473. * - EVENT_BA_STREAM_TIEMOUT
  474. * - EVENT_AMSDU_AGGR_CTRL
  475. */
  476. int mwifiex_process_sta_event(struct mwifiex_private *priv)
  477. {
  478. struct mwifiex_adapter *adapter = priv->adapter;
  479. int ret = 0;
  480. u32 eventcause = adapter->event_cause;
  481. u16 ctrl, reason_code;
  482. switch (eventcause) {
  483. case EVENT_DUMMY_HOST_WAKEUP_SIGNAL:
  484. mwifiex_dbg(adapter, ERROR,
  485. "invalid EVENT: DUMMY_HOST_WAKEUP_SIGNAL, ignore it\n");
  486. break;
  487. case EVENT_LINK_SENSED:
  488. mwifiex_dbg(adapter, EVENT, "event: LINK_SENSED\n");
  489. if (!netif_carrier_ok(priv->netdev))
  490. netif_carrier_on(priv->netdev);
  491. mwifiex_wake_up_net_dev_queue(priv->netdev, adapter);
  492. break;
  493. case EVENT_DEAUTHENTICATED:
  494. mwifiex_dbg(adapter, EVENT, "event: Deauthenticated\n");
  495. if (priv->wps.session_enable) {
  496. mwifiex_dbg(adapter, INFO,
  497. "info: receive deauth event in wps session\n");
  498. break;
  499. }
  500. adapter->dbg.num_event_deauth++;
  501. if (priv->media_connected) {
  502. reason_code =
  503. le16_to_cpu(*(__le16 *)adapter->event_body);
  504. mwifiex_reset_connect_state(priv, reason_code);
  505. }
  506. break;
  507. case EVENT_DISASSOCIATED:
  508. mwifiex_dbg(adapter, EVENT, "event: Disassociated\n");
  509. if (priv->wps.session_enable) {
  510. mwifiex_dbg(adapter, INFO,
  511. "info: receive disassoc event in wps session\n");
  512. break;
  513. }
  514. adapter->dbg.num_event_disassoc++;
  515. if (priv->media_connected) {
  516. reason_code =
  517. le16_to_cpu(*(__le16 *)adapter->event_body);
  518. mwifiex_reset_connect_state(priv, reason_code);
  519. }
  520. break;
  521. case EVENT_LINK_LOST:
  522. mwifiex_dbg(adapter, EVENT, "event: Link lost\n");
  523. adapter->dbg.num_event_link_lost++;
  524. if (priv->media_connected) {
  525. reason_code =
  526. le16_to_cpu(*(__le16 *)adapter->event_body);
  527. mwifiex_reset_connect_state(priv, reason_code);
  528. }
  529. break;
  530. case EVENT_PS_SLEEP:
  531. mwifiex_dbg(adapter, EVENT, "info: EVENT: SLEEP\n");
  532. adapter->ps_state = PS_STATE_PRE_SLEEP;
  533. mwifiex_check_ps_cond(adapter);
  534. break;
  535. case EVENT_PS_AWAKE:
  536. mwifiex_dbg(adapter, EVENT, "info: EVENT: AWAKE\n");
  537. if (!adapter->pps_uapsd_mode && priv->port_open &&
  538. priv->media_connected && adapter->sleep_period.period) {
  539. adapter->pps_uapsd_mode = true;
  540. mwifiex_dbg(adapter, EVENT,
  541. "event: PPS/UAPSD mode activated\n");
  542. }
  543. adapter->tx_lock_flag = false;
  544. if (adapter->pps_uapsd_mode && adapter->gen_null_pkt) {
  545. if (mwifiex_check_last_packet_indication(priv)) {
  546. if (adapter->data_sent ||
  547. (adapter->if_ops.is_port_ready &&
  548. !adapter->if_ops.is_port_ready(priv))) {
  549. adapter->ps_state = PS_STATE_AWAKE;
  550. adapter->pm_wakeup_card_req = false;
  551. adapter->pm_wakeup_fw_try = false;
  552. del_timer(&adapter->wakeup_timer);
  553. break;
  554. }
  555. if (!mwifiex_send_null_packet
  556. (priv,
  557. MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET |
  558. MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET))
  559. adapter->ps_state =
  560. PS_STATE_SLEEP;
  561. return 0;
  562. }
  563. }
  564. adapter->ps_state = PS_STATE_AWAKE;
  565. adapter->pm_wakeup_card_req = false;
  566. adapter->pm_wakeup_fw_try = false;
  567. del_timer(&adapter->wakeup_timer);
  568. break;
  569. case EVENT_DEEP_SLEEP_AWAKE:
  570. adapter->if_ops.wakeup_complete(adapter);
  571. mwifiex_dbg(adapter, EVENT, "event: DS_AWAKE\n");
  572. if (adapter->is_deep_sleep)
  573. adapter->is_deep_sleep = false;
  574. break;
  575. case EVENT_HS_ACT_REQ:
  576. mwifiex_dbg(adapter, EVENT, "event: HS_ACT_REQ\n");
  577. ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_HS_CFG_ENH,
  578. 0, 0, NULL, false);
  579. break;
  580. case EVENT_MIC_ERR_UNICAST:
  581. mwifiex_dbg(adapter, EVENT, "event: UNICAST MIC ERROR\n");
  582. cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
  583. NL80211_KEYTYPE_PAIRWISE,
  584. -1, NULL, GFP_KERNEL);
  585. break;
  586. case EVENT_MIC_ERR_MULTICAST:
  587. mwifiex_dbg(adapter, EVENT, "event: MULTICAST MIC ERROR\n");
  588. cfg80211_michael_mic_failure(priv->netdev, priv->cfg_bssid,
  589. NL80211_KEYTYPE_GROUP,
  590. -1, NULL, GFP_KERNEL);
  591. break;
  592. case EVENT_MIB_CHANGED:
  593. case EVENT_INIT_DONE:
  594. break;
  595. case EVENT_ADHOC_BCN_LOST:
  596. mwifiex_dbg(adapter, EVENT, "event: ADHOC_BCN_LOST\n");
  597. priv->adhoc_is_link_sensed = false;
  598. mwifiex_clean_txrx(priv);
  599. mwifiex_stop_net_dev_queue(priv->netdev, adapter);
  600. if (netif_carrier_ok(priv->netdev))
  601. netif_carrier_off(priv->netdev);
  602. break;
  603. case EVENT_BG_SCAN_REPORT:
  604. mwifiex_dbg(adapter, EVENT, "event: BGS_REPORT\n");
  605. ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_BG_SCAN_QUERY,
  606. HostCmd_ACT_GEN_GET, 0, NULL, false);
  607. break;
  608. case EVENT_PORT_RELEASE:
  609. mwifiex_dbg(adapter, EVENT, "event: PORT RELEASE\n");
  610. priv->port_open = true;
  611. break;
  612. case EVENT_EXT_SCAN_REPORT:
  613. mwifiex_dbg(adapter, EVENT, "event: EXT_SCAN Report\n");
  614. if (adapter->ext_scan)
  615. ret = mwifiex_handle_event_ext_scan_report(priv,
  616. adapter->event_skb->data);
  617. break;
  618. case EVENT_WMM_STATUS_CHANGE:
  619. mwifiex_dbg(adapter, EVENT, "event: WMM status changed\n");
  620. ret = mwifiex_send_cmd(priv, HostCmd_CMD_WMM_GET_STATUS,
  621. 0, 0, NULL, false);
  622. break;
  623. case EVENT_RSSI_LOW:
  624. cfg80211_cqm_rssi_notify(priv->netdev,
  625. NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW,
  626. GFP_KERNEL);
  627. mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
  628. HostCmd_ACT_GEN_GET, 0, NULL, false);
  629. priv->subsc_evt_rssi_state = RSSI_LOW_RECVD;
  630. mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_LOW\n");
  631. break;
  632. case EVENT_SNR_LOW:
  633. mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_LOW\n");
  634. break;
  635. case EVENT_MAX_FAIL:
  636. mwifiex_dbg(adapter, EVENT, "event: MAX_FAIL\n");
  637. break;
  638. case EVENT_RSSI_HIGH:
  639. cfg80211_cqm_rssi_notify(priv->netdev,
  640. NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH,
  641. GFP_KERNEL);
  642. mwifiex_send_cmd(priv, HostCmd_CMD_RSSI_INFO,
  643. HostCmd_ACT_GEN_GET, 0, NULL, false);
  644. priv->subsc_evt_rssi_state = RSSI_HIGH_RECVD;
  645. mwifiex_dbg(adapter, EVENT, "event: Beacon RSSI_HIGH\n");
  646. break;
  647. case EVENT_SNR_HIGH:
  648. mwifiex_dbg(adapter, EVENT, "event: Beacon SNR_HIGH\n");
  649. break;
  650. case EVENT_DATA_RSSI_LOW:
  651. mwifiex_dbg(adapter, EVENT, "event: Data RSSI_LOW\n");
  652. break;
  653. case EVENT_DATA_SNR_LOW:
  654. mwifiex_dbg(adapter, EVENT, "event: Data SNR_LOW\n");
  655. break;
  656. case EVENT_DATA_RSSI_HIGH:
  657. mwifiex_dbg(adapter, EVENT, "event: Data RSSI_HIGH\n");
  658. break;
  659. case EVENT_DATA_SNR_HIGH:
  660. mwifiex_dbg(adapter, EVENT, "event: Data SNR_HIGH\n");
  661. break;
  662. case EVENT_LINK_QUALITY:
  663. mwifiex_dbg(adapter, EVENT, "event: Link Quality\n");
  664. break;
  665. case EVENT_PRE_BEACON_LOST:
  666. mwifiex_dbg(adapter, EVENT, "event: Pre-Beacon Lost\n");
  667. break;
  668. case EVENT_IBSS_COALESCED:
  669. mwifiex_dbg(adapter, EVENT, "event: IBSS_COALESCED\n");
  670. ret = mwifiex_send_cmd(priv,
  671. HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
  672. HostCmd_ACT_GEN_GET, 0, NULL, false);
  673. break;
  674. case EVENT_ADDBA:
  675. mwifiex_dbg(adapter, EVENT, "event: ADDBA Request\n");
  676. mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_RSP,
  677. HostCmd_ACT_GEN_SET, 0,
  678. adapter->event_body, false);
  679. break;
  680. case EVENT_DELBA:
  681. mwifiex_dbg(adapter, EVENT, "event: DELBA Request\n");
  682. mwifiex_11n_delete_ba_stream(priv, adapter->event_body);
  683. break;
  684. case EVENT_BA_STREAM_TIEMOUT:
  685. mwifiex_dbg(adapter, EVENT, "event: BA Stream timeout\n");
  686. mwifiex_11n_ba_stream_timeout(priv,
  687. (struct host_cmd_ds_11n_batimeout
  688. *)
  689. adapter->event_body);
  690. break;
  691. case EVENT_AMSDU_AGGR_CTRL:
  692. ctrl = le16_to_cpu(*(__le16 *)adapter->event_body);
  693. mwifiex_dbg(adapter, EVENT,
  694. "event: AMSDU_AGGR_CTRL %d\n", ctrl);
  695. adapter->tx_buf_size =
  696. min_t(u16, adapter->curr_tx_buf_size, ctrl);
  697. mwifiex_dbg(adapter, EVENT, "event: tx_buf_size %d\n",
  698. adapter->tx_buf_size);
  699. break;
  700. case EVENT_WEP_ICV_ERR:
  701. mwifiex_dbg(adapter, EVENT, "event: WEP ICV error\n");
  702. break;
  703. case EVENT_BW_CHANGE:
  704. mwifiex_dbg(adapter, EVENT, "event: BW Change\n");
  705. break;
  706. case EVENT_HOSTWAKE_STAIE:
  707. mwifiex_dbg(adapter, EVENT,
  708. "event: HOSTWAKE_STAIE %d\n", eventcause);
  709. break;
  710. case EVENT_REMAIN_ON_CHAN_EXPIRED:
  711. mwifiex_dbg(adapter, EVENT,
  712. "event: Remain on channel expired\n");
  713. cfg80211_remain_on_channel_expired(&priv->wdev,
  714. priv->roc_cfg.cookie,
  715. &priv->roc_cfg.chan,
  716. GFP_ATOMIC);
  717. memset(&priv->roc_cfg, 0x00, sizeof(struct mwifiex_roc_cfg));
  718. break;
  719. case EVENT_CHANNEL_SWITCH_ANN:
  720. mwifiex_dbg(adapter, EVENT, "event: Channel Switch Announcement\n");
  721. priv->csa_expire_time =
  722. jiffies + msecs_to_jiffies(DFS_CHAN_MOVE_TIME);
  723. priv->csa_chan = priv->curr_bss_params.bss_descriptor.channel;
  724. ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_DEAUTHENTICATE,
  725. HostCmd_ACT_GEN_SET, 0,
  726. priv->curr_bss_params.bss_descriptor.mac_address,
  727. false);
  728. break;
  729. case EVENT_TDLS_GENERIC_EVENT:
  730. ret = mwifiex_parse_tdls_event(priv, adapter->event_skb);
  731. break;
  732. case EVENT_TX_DATA_PAUSE:
  733. mwifiex_dbg(adapter, EVENT, "event: TX DATA PAUSE\n");
  734. mwifiex_process_tx_pause_event(priv, adapter->event_skb);
  735. break;
  736. case EVENT_MULTI_CHAN_INFO:
  737. mwifiex_dbg(adapter, EVENT, "event: multi-chan info\n");
  738. mwifiex_process_multi_chan_event(priv, adapter->event_skb);
  739. break;
  740. case EVENT_TX_STATUS_REPORT:
  741. mwifiex_dbg(adapter, EVENT, "event: TX_STATUS Report\n");
  742. mwifiex_parse_tx_status_event(priv, adapter->event_body);
  743. break;
  744. case EVENT_CHANNEL_REPORT_RDY:
  745. mwifiex_dbg(adapter, EVENT, "event: Channel Report\n");
  746. ret = mwifiex_11h_handle_chanrpt_ready(priv,
  747. adapter->event_skb);
  748. break;
  749. case EVENT_RADAR_DETECTED:
  750. mwifiex_dbg(adapter, EVENT, "event: Radar detected\n");
  751. ret = mwifiex_11h_handle_radar_detected(priv,
  752. adapter->event_skb);
  753. break;
  754. case EVENT_BT_COEX_WLAN_PARA_CHANGE:
  755. dev_dbg(adapter->dev, "EVENT: BT coex wlan param update\n");
  756. mwifiex_bt_coex_wlan_param_update_event(priv,
  757. adapter->event_skb);
  758. break;
  759. default:
  760. mwifiex_dbg(adapter, ERROR, "event: unknown event id: %#x\n",
  761. eventcause);
  762. break;
  763. }
  764. return ret;
  765. }