uap_event.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * Marvell Wireless LAN device driver: AP event handling
  3. *
  4. * Copyright (C) 2012-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 "main.h"
  21. #include "11n.h"
  22. /*
  23. * This function handles AP interface specific events generated by firmware.
  24. *
  25. * Event specific routines are called by this function based
  26. * upon the generated event cause.
  27. *
  28. *
  29. * Events supported for AP -
  30. * - EVENT_UAP_STA_ASSOC
  31. * - EVENT_UAP_STA_DEAUTH
  32. * - EVENT_UAP_BSS_ACTIVE
  33. * - EVENT_UAP_BSS_START
  34. * - EVENT_UAP_BSS_IDLE
  35. * - EVENT_UAP_MIC_COUNTERMEASURES:
  36. */
  37. int mwifiex_process_uap_event(struct mwifiex_private *priv)
  38. {
  39. struct mwifiex_adapter *adapter = priv->adapter;
  40. int len, i;
  41. u32 eventcause = adapter->event_cause;
  42. struct station_info sinfo;
  43. struct mwifiex_assoc_event *event;
  44. struct mwifiex_sta_node *node;
  45. u8 *deauth_mac;
  46. struct host_cmd_ds_11n_batimeout *ba_timeout;
  47. u16 ctrl;
  48. switch (eventcause) {
  49. case EVENT_UAP_STA_ASSOC:
  50. memset(&sinfo, 0, sizeof(sinfo));
  51. event = (struct mwifiex_assoc_event *)
  52. (adapter->event_body + MWIFIEX_UAP_EVENT_EXTRA_HEADER);
  53. if (le16_to_cpu(event->type) == TLV_TYPE_UAP_MGMT_FRAME) {
  54. len = -1;
  55. if (ieee80211_is_assoc_req(event->frame_control))
  56. len = 0;
  57. else if (ieee80211_is_reassoc_req(event->frame_control))
  58. /* There will be ETH_ALEN bytes of
  59. * current_ap_addr before the re-assoc ies.
  60. */
  61. len = ETH_ALEN;
  62. if (len != -1) {
  63. sinfo.filled = STATION_INFO_ASSOC_REQ_IES;
  64. sinfo.assoc_req_ies = &event->data[len];
  65. len = (u8 *)sinfo.assoc_req_ies -
  66. (u8 *)&event->frame_control;
  67. sinfo.assoc_req_ies_len =
  68. le16_to_cpu(event->len) - (u16)len;
  69. }
  70. }
  71. cfg80211_new_sta(priv->netdev, event->sta_addr, &sinfo,
  72. GFP_KERNEL);
  73. node = mwifiex_add_sta_entry(priv, event->sta_addr);
  74. if (!node) {
  75. dev_warn(adapter->dev,
  76. "could not create station entry!\n");
  77. return -1;
  78. }
  79. if (!priv->ap_11n_enabled)
  80. break;
  81. mwifiex_set_sta_ht_cap(priv, sinfo.assoc_req_ies,
  82. sinfo.assoc_req_ies_len, node);
  83. for (i = 0; i < MAX_NUM_TID; i++) {
  84. if (node->is_11n_enabled)
  85. node->ampdu_sta[i] =
  86. priv->aggr_prio_tbl[i].ampdu_user;
  87. else
  88. node->ampdu_sta[i] = BA_STREAM_NOT_ALLOWED;
  89. }
  90. memset(node->rx_seq, 0xff, sizeof(node->rx_seq));
  91. break;
  92. case EVENT_UAP_STA_DEAUTH:
  93. deauth_mac = adapter->event_body +
  94. MWIFIEX_UAP_EVENT_EXTRA_HEADER;
  95. cfg80211_del_sta(priv->netdev, deauth_mac, GFP_KERNEL);
  96. if (priv->ap_11n_enabled) {
  97. mwifiex_11n_del_rx_reorder_tbl_by_ta(priv, deauth_mac);
  98. mwifiex_del_tx_ba_stream_tbl_by_ra(priv, deauth_mac);
  99. }
  100. mwifiex_wmm_del_peer_ra_list(priv, deauth_mac);
  101. mwifiex_del_sta_entry(priv, deauth_mac);
  102. break;
  103. case EVENT_UAP_BSS_IDLE:
  104. priv->media_connected = false;
  105. if (netif_carrier_ok(priv->netdev))
  106. netif_carrier_off(priv->netdev);
  107. mwifiex_stop_net_dev_queue(priv->netdev, adapter);
  108. mwifiex_clean_txrx(priv);
  109. mwifiex_del_all_sta_list(priv);
  110. break;
  111. case EVENT_UAP_BSS_ACTIVE:
  112. priv->media_connected = true;
  113. if (!netif_carrier_ok(priv->netdev))
  114. netif_carrier_on(priv->netdev);
  115. mwifiex_wake_up_net_dev_queue(priv->netdev, adapter);
  116. break;
  117. case EVENT_UAP_BSS_START:
  118. dev_dbg(adapter->dev, "AP EVENT: event id: %#x\n", eventcause);
  119. memcpy(priv->netdev->dev_addr, adapter->event_body + 2,
  120. ETH_ALEN);
  121. break;
  122. case EVENT_UAP_MIC_COUNTERMEASURES:
  123. /* For future development */
  124. dev_dbg(adapter->dev, "AP EVENT: event id: %#x\n", eventcause);
  125. break;
  126. case EVENT_AMSDU_AGGR_CTRL:
  127. ctrl = le16_to_cpu(*(__le16 *)adapter->event_body);
  128. dev_dbg(adapter->dev, "event: AMSDU_AGGR_CTRL %d\n", ctrl);
  129. if (priv->media_connected) {
  130. adapter->tx_buf_size =
  131. min_t(u16, adapter->curr_tx_buf_size, ctrl);
  132. dev_dbg(adapter->dev, "event: tx_buf_size %d\n",
  133. adapter->tx_buf_size);
  134. }
  135. break;
  136. case EVENT_ADDBA:
  137. dev_dbg(adapter->dev, "event: ADDBA Request\n");
  138. if (priv->media_connected)
  139. mwifiex_send_cmd(priv, HostCmd_CMD_11N_ADDBA_RSP,
  140. HostCmd_ACT_GEN_SET, 0,
  141. adapter->event_body, false);
  142. break;
  143. case EVENT_DELBA:
  144. dev_dbg(adapter->dev, "event: DELBA Request\n");
  145. if (priv->media_connected)
  146. mwifiex_11n_delete_ba_stream(priv, adapter->event_body);
  147. break;
  148. case EVENT_BA_STREAM_TIEMOUT:
  149. dev_dbg(adapter->dev, "event: BA Stream timeout\n");
  150. if (priv->media_connected) {
  151. ba_timeout = (void *)adapter->event_body;
  152. mwifiex_11n_ba_stream_timeout(priv, ba_timeout);
  153. }
  154. break;
  155. case EVENT_EXT_SCAN_REPORT:
  156. dev_dbg(adapter->dev, "event: EXT_SCAN Report\n");
  157. if (adapter->ext_scan)
  158. return mwifiex_handle_event_ext_scan_report(priv,
  159. adapter->event_skb->data);
  160. break;
  161. case EVENT_TX_STATUS_REPORT:
  162. dev_dbg(adapter->dev, "event: TX_STATUS Report\n");
  163. mwifiex_parse_tx_status_event(priv, adapter->event_body);
  164. break;
  165. default:
  166. dev_dbg(adapter->dev, "event: unknown event id: %#x\n",
  167. eventcause);
  168. break;
  169. }
  170. return 0;
  171. }
  172. /* This function deletes station entry from associated station list.
  173. * Also if both AP and STA are 11n enabled, RxReorder tables and TxBA stream
  174. * tables created for this station are deleted.
  175. */
  176. void mwifiex_uap_del_sta_data(struct mwifiex_private *priv,
  177. struct mwifiex_sta_node *node)
  178. {
  179. if (priv->ap_11n_enabled && node->is_11n_enabled) {
  180. mwifiex_11n_del_rx_reorder_tbl_by_ta(priv, node->mac_addr);
  181. mwifiex_del_tx_ba_stream_tbl_by_ra(priv, node->mac_addr);
  182. }
  183. mwifiex_del_sta_entry(priv, node->mac_addr);
  184. return;
  185. }