Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: functions for station ioctl |
| 3 | * |
Xinming Hu | 65da33f | 2014-06-19 21:38:57 -0700 | [diff] [blame] | 4 | * Copyright (C) 2011-2014, Marvell International Ltd. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 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 | #include "cfg80211.h" |
| 28 | |
Bing Zhao | ef0a68a | 2014-06-06 19:47:44 -0700 | [diff] [blame] | 29 | static int disconnect_on_suspend; |
Amitkumar Karwar | 22c22d2 | 2012-09-20 20:23:17 -0700 | [diff] [blame] | 30 | module_param(disconnect_on_suspend, int, 0644); |
| 31 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 32 | /* |
| 33 | * Copies the multicast address list from device to driver. |
| 34 | * |
| 35 | * This function does not validate the destination memory for |
| 36 | * size, and the calling function must ensure enough memory is |
| 37 | * available. |
| 38 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 39 | int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist, |
| 40 | struct net_device *dev) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 41 | { |
| 42 | int i = 0; |
| 43 | struct netdev_hw_addr *ha; |
| 44 | |
| 45 | netdev_for_each_mc_addr(ha, dev) |
| 46 | memcpy(&mlist->mac_list[i++], ha->addr, ETH_ALEN); |
| 47 | |
| 48 | return i; |
| 49 | } |
| 50 | |
| 51 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 52 | * Wait queue completion handler. |
| 53 | * |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 54 | * This function waits on a cmd wait queue. It also cancels the pending |
| 55 | * request after waking up, in case of errors. |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 56 | */ |
Amitkumar Karwar | 00d7ea1 | 2013-03-15 18:47:05 -0700 | [diff] [blame] | 57 | int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter, |
| 58 | struct cmd_ctrl_node *cmd_queued) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 59 | { |
Amitkumar Karwar | b7097eb | 2012-02-01 20:41:43 -0800 | [diff] [blame] | 60 | int status; |
Amitkumar Karwar | b015dbc | 2012-01-02 16:18:40 -0800 | [diff] [blame] | 61 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 62 | /* Wait for completion */ |
Amitkumar Karwar | f8d2b92 | 2014-04-14 15:31:06 -0700 | [diff] [blame] | 63 | status = wait_event_interruptible_timeout(adapter->cmd_wait_q.wait, |
| 64 | *(cmd_queued->condition), |
| 65 | (12 * HZ)); |
| 66 | if (status <= 0) { |
Dmitry Torokhov | 4e0ff94 | 2015-04-30 16:52:02 -0700 | [diff] [blame] | 67 | if (status == 0) |
| 68 | status = -ETIMEDOUT; |
Andreas Fenkart | c5bc15f | 2015-07-17 09:13:06 +0200 | [diff] [blame] | 69 | mwifiex_dbg(adapter, ERROR, "cmd_wait_q terminated: %d\n", |
| 70 | status); |
Amitkumar Karwar | 3d026d0 | 2014-03-20 16:23:49 -0700 | [diff] [blame] | 71 | mwifiex_cancel_all_pending_cmd(adapter); |
Bing Zhao | 9c969d8 | 2013-01-02 16:07:35 -0800 | [diff] [blame] | 72 | return status; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 73 | } |
Amitkumar Karwar | b7097eb | 2012-02-01 20:41:43 -0800 | [diff] [blame] | 74 | |
| 75 | status = adapter->cmd_wait_q.status; |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 76 | adapter->cmd_wait_q.status = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 77 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 78 | return status; |
| 79 | } |
| 80 | |
| 81 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 82 | * This function prepares the correct firmware command and |
| 83 | * issues it to set the multicast list. |
| 84 | * |
| 85 | * This function can be used to enable promiscuous mode, or enable all |
| 86 | * multicast packets, or to enable selective multicast. |
| 87 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 88 | int mwifiex_request_set_multicast_list(struct mwifiex_private *priv, |
| 89 | struct mwifiex_multicast_list *mcast_list) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 90 | { |
| 91 | int ret = 0; |
| 92 | u16 old_pkt_filter; |
| 93 | |
| 94 | old_pkt_filter = priv->curr_pkt_filter; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 95 | |
| 96 | if (mcast_list->mode == MWIFIEX_PROMISC_MODE) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 97 | mwifiex_dbg(priv->adapter, INFO, |
| 98 | "info: Enable Promiscuous mode\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 99 | priv->curr_pkt_filter |= HostCmd_ACT_MAC_PROMISCUOUS_ENABLE; |
| 100 | priv->curr_pkt_filter &= |
| 101 | ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE; |
| 102 | } else { |
| 103 | /* Multicast */ |
| 104 | priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE; |
Daniel Drake | ccd384b | 2013-05-08 15:37:19 -0400 | [diff] [blame] | 105 | if (mcast_list->mode == MWIFIEX_ALL_MULTI_MODE) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 106 | mwifiex_dbg(priv->adapter, INFO, |
| 107 | "info: Enabling All Multicast!\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 108 | priv->curr_pkt_filter |= |
| 109 | HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE; |
| 110 | } else { |
| 111 | priv->curr_pkt_filter &= |
| 112 | ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 113 | mwifiex_dbg(priv->adapter, INFO, |
| 114 | "info: Set multicast list=%d\n", |
| 115 | mcast_list->num_multicast_addr); |
Daniel Drake | 6390d88 | 2013-06-14 15:24:24 -0400 | [diff] [blame] | 116 | /* Send multicast addresses to firmware */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 117 | ret = mwifiex_send_cmd(priv, |
| 118 | HostCmd_CMD_MAC_MULTICAST_ADR, |
| 119 | HostCmd_ACT_GEN_SET, 0, |
| 120 | mcast_list, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 121 | } |
| 122 | } |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 123 | mwifiex_dbg(priv->adapter, INFO, |
| 124 | "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n", |
| 125 | old_pkt_filter, priv->curr_pkt_filter); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 126 | if (old_pkt_filter != priv->curr_pkt_filter) { |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 127 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL, |
| 128 | HostCmd_ACT_GEN_SET, |
| 129 | 0, &priv->curr_pkt_filter, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | return ret; |
| 133 | } |
| 134 | |
| 135 | /* |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 136 | * This function fills bss descriptor structure using provided |
| 137 | * information. |
Bing Zhao | d837a2a | 2013-04-12 10:34:17 -0700 | [diff] [blame] | 138 | * beacon_ie buffer is allocated in this function. It is caller's |
| 139 | * responsibility to free the memory. |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 140 | */ |
| 141 | int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv, |
Amitkumar Karwar | 9558a40 | 2012-04-16 21:36:51 -0700 | [diff] [blame] | 142 | struct cfg80211_bss *bss, |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 143 | struct mwifiex_bssdescriptor *bss_desc) |
| 144 | { |
Amitkumar Karwar | 9558a40 | 2012-04-16 21:36:51 -0700 | [diff] [blame] | 145 | u8 *beacon_ie; |
John W. Linville | 403e167 | 2012-12-06 14:58:41 -0500 | [diff] [blame] | 146 | size_t beacon_ie_len; |
Amitkumar Karwar | b5abcf0 | 2012-04-16 21:36:52 -0700 | [diff] [blame] | 147 | struct mwifiex_bss_priv *bss_priv = (void *)bss->priv; |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 148 | const struct cfg80211_bss_ies *ies; |
Amitkumar Karwar | bcc920e | 2016-04-11 07:52:41 -0700 | [diff] [blame] | 149 | int ret; |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 150 | |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 151 | rcu_read_lock(); |
| 152 | ies = rcu_dereference(bss->ies); |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 153 | beacon_ie = kmemdup(ies->data, ies->len, GFP_ATOMIC); |
| 154 | beacon_ie_len = ies->len; |
Johannes Berg | 8cef2c9 | 2013-02-05 16:54:31 +0100 | [diff] [blame] | 155 | bss_desc->timestamp = ies->tsf; |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 156 | rcu_read_unlock(); |
| 157 | |
Amitkumar Karwar | 9558a40 | 2012-04-16 21:36:51 -0700 | [diff] [blame] | 158 | if (!beacon_ie) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 159 | mwifiex_dbg(priv->adapter, ERROR, |
| 160 | " failed to alloc beacon_ie\n"); |
Amitkumar Karwar | 9558a40 | 2012-04-16 21:36:51 -0700 | [diff] [blame] | 161 | return -ENOMEM; |
| 162 | } |
| 163 | |
| 164 | memcpy(bss_desc->mac_address, bss->bssid, ETH_ALEN); |
| 165 | bss_desc->rssi = bss->signal; |
Bing Zhao | d837a2a | 2013-04-12 10:34:17 -0700 | [diff] [blame] | 166 | /* The caller of this function will free beacon_ie */ |
Amitkumar Karwar | 9558a40 | 2012-04-16 21:36:51 -0700 | [diff] [blame] | 167 | bss_desc->beacon_buf = beacon_ie; |
Johannes Berg | 904f137 | 2012-11-28 21:53:45 +0100 | [diff] [blame] | 168 | bss_desc->beacon_buf_size = beacon_ie_len; |
Amitkumar Karwar | 9558a40 | 2012-04-16 21:36:51 -0700 | [diff] [blame] | 169 | bss_desc->beacon_period = bss->beacon_interval; |
| 170 | bss_desc->cap_info_bitmap = bss->capability; |
Amitkumar Karwar | b5abcf0 | 2012-04-16 21:36:52 -0700 | [diff] [blame] | 171 | bss_desc->bss_band = bss_priv->band; |
| 172 | bss_desc->fw_tsf = bss_priv->fw_tsf; |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 173 | if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 174 | mwifiex_dbg(priv->adapter, INFO, |
| 175 | "info: InterpretIE: AP WEP enabled\n"); |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 176 | bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP; |
| 177 | } else { |
| 178 | bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL; |
| 179 | } |
| 180 | if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_IBSS) |
| 181 | bss_desc->bss_mode = NL80211_IFTYPE_ADHOC; |
| 182 | else |
| 183 | bss_desc->bss_mode = NL80211_IFTYPE_STATION; |
| 184 | |
Bing Zhao | c43933e | 2013-04-12 10:34:18 -0700 | [diff] [blame] | 185 | /* Disable 11ac by default. Enable it only where there |
| 186 | * exist VHT_CAP IE in AP beacon |
| 187 | */ |
| 188 | bss_desc->disable_11ac = true; |
| 189 | |
Amitkumar Karwar | 2a7305c | 2013-06-19 08:49:05 -0700 | [diff] [blame] | 190 | if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_SPECTRUM_MGMT) |
| 191 | bss_desc->sensed_11h = true; |
| 192 | |
Amitkumar Karwar | bcc920e | 2016-04-11 07:52:41 -0700 | [diff] [blame] | 193 | ret = mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc); |
| 194 | if (ret) |
| 195 | return ret; |
| 196 | |
| 197 | /* Update HT40 capability based on current channel information */ |
| 198 | if (bss_desc->bcn_ht_oper && bss_desc->bcn_ht_cap) { |
| 199 | u8 ht_param = bss_desc->bcn_ht_oper->ht_param; |
| 200 | u8 radio = mwifiex_band_to_radio_type(bss_desc->bss_band); |
| 201 | struct ieee80211_supported_band *sband = |
| 202 | priv->wdev.wiphy->bands[radio]; |
| 203 | int freq = ieee80211_channel_to_frequency(bss_desc->channel, |
| 204 | radio); |
| 205 | struct ieee80211_channel *chan = |
| 206 | ieee80211_get_channel(priv->adapter->wiphy, freq); |
| 207 | |
| 208 | switch (ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { |
| 209 | case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: |
| 210 | if (chan->flags & IEEE80211_CHAN_NO_HT40PLUS) { |
| 211 | sband->ht_cap.cap &= |
| 212 | ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 213 | sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 214 | } else { |
| 215 | sband->ht_cap.cap |= |
| 216 | IEEE80211_HT_CAP_SUP_WIDTH_20_40 | |
| 217 | IEEE80211_HT_CAP_SGI_40; |
| 218 | } |
| 219 | break; |
| 220 | case IEEE80211_HT_PARAM_CHA_SEC_BELOW: |
| 221 | if (chan->flags & IEEE80211_CHAN_NO_HT40MINUS) { |
| 222 | sband->ht_cap.cap &= |
| 223 | ~IEEE80211_HT_CAP_SUP_WIDTH_20_40; |
| 224 | sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40; |
| 225 | } else { |
| 226 | sband->ht_cap.cap |= |
| 227 | IEEE80211_HT_CAP_SUP_WIDTH_20_40 | |
| 228 | IEEE80211_HT_CAP_SGI_40; |
| 229 | } |
| 230 | break; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | return 0; |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Bing Zhao | b58df44 | 2014-01-08 15:45:57 -0800 | [diff] [blame] | 237 | void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv) |
| 238 | { |
| 239 | if (priv->adapter->dt_node) { |
| 240 | char txpwr[] = {"marvell,00_txpwrlimit"}; |
| 241 | |
| 242 | memcpy(&txpwr[8], priv->adapter->country_code, 2); |
| 243 | mwifiex_dnld_dt_cfgdata(priv, priv->adapter->dt_node, txpwr); |
| 244 | } |
| 245 | } |
| 246 | |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 247 | static int mwifiex_process_country_ie(struct mwifiex_private *priv, |
| 248 | struct cfg80211_bss *bss) |
| 249 | { |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 250 | const u8 *country_ie; |
| 251 | u8 country_ie_len; |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 252 | struct mwifiex_802_11d_domain_reg *domain_info = |
| 253 | &priv->adapter->domain_reg; |
| 254 | |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 255 | rcu_read_lock(); |
| 256 | country_ie = ieee80211_bss_get_ie(bss, WLAN_EID_COUNTRY); |
| 257 | if (!country_ie) { |
| 258 | rcu_read_unlock(); |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 259 | return 0; |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 260 | } |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 261 | |
| 262 | country_ie_len = country_ie[1]; |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 263 | if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN) { |
| 264 | rcu_read_unlock(); |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 265 | return 0; |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 266 | } |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 267 | |
Bing Zhao | dd4a9ac | 2013-12-13 18:32:59 -0800 | [diff] [blame] | 268 | if (!strncmp(priv->adapter->country_code, &country_ie[2], 2)) { |
| 269 | rcu_read_unlock(); |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 270 | mwifiex_dbg(priv->adapter, INFO, |
| 271 | "11D: skip setting domain info in FW\n"); |
Bing Zhao | dd4a9ac | 2013-12-13 18:32:59 -0800 | [diff] [blame] | 272 | return 0; |
| 273 | } |
| 274 | memcpy(priv->adapter->country_code, &country_ie[2], 2); |
| 275 | |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 276 | domain_info->country_code[0] = country_ie[2]; |
| 277 | domain_info->country_code[1] = country_ie[3]; |
| 278 | domain_info->country_code[2] = ' '; |
| 279 | |
| 280 | country_ie_len -= IEEE80211_COUNTRY_STRING_LEN; |
| 281 | |
| 282 | domain_info->no_of_triplet = |
| 283 | country_ie_len / sizeof(struct ieee80211_country_ie_triplet); |
| 284 | |
| 285 | memcpy((u8 *)domain_info->triplet, |
| 286 | &country_ie[2] + IEEE80211_COUNTRY_STRING_LEN, country_ie_len); |
| 287 | |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 288 | rcu_read_unlock(); |
| 289 | |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 290 | if (mwifiex_send_cmd(priv, HostCmd_CMD_802_11D_DOMAIN_INFO, |
| 291 | HostCmd_ACT_GEN_SET, 0, NULL, false)) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 292 | mwifiex_dbg(priv->adapter, ERROR, |
| 293 | "11D: setting domain info in FW fail\n"); |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 294 | return -1; |
| 295 | } |
| 296 | |
Bing Zhao | b58df44 | 2014-01-08 15:45:57 -0800 | [diff] [blame] | 297 | mwifiex_dnld_txpwr_table(priv); |
Bing Zhao | 82efa16 | 2013-12-13 18:33:02 -0800 | [diff] [blame] | 298 | |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 299 | return 0; |
| 300 | } |
| 301 | |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 302 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 303 | * In Ad-Hoc mode, the IBSS is created if not found in scan list. |
| 304 | * In both Ad-Hoc and infra mode, an deauthentication is performed |
| 305 | * first. |
| 306 | */ |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 307 | int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, |
Amitkumar Karwar | b9be5f3 | 2012-02-27 22:04:14 -0800 | [diff] [blame] | 308 | struct cfg80211_ssid *req_ssid) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 309 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 310 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 311 | struct mwifiex_adapter *adapter = priv->adapter; |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 312 | struct mwifiex_bssdescriptor *bss_desc = NULL; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 313 | |
| 314 | priv->scan_block = false; |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 315 | |
| 316 | if (bss) { |
Amitkumar Karwar | 947d315 | 2015-12-04 06:13:05 -0800 | [diff] [blame] | 317 | if (adapter->region_code == 0x00) |
| 318 | mwifiex_process_country_ie(priv, bss); |
Amitkumar Karwar | e89e2da | 2012-09-10 18:30:45 -0700 | [diff] [blame] | 319 | |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 320 | /* Allocate and fill new bss descriptor */ |
| 321 | bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor), |
Joe Perches | 0d2e7a5 | 2013-02-03 17:28:14 +0000 | [diff] [blame] | 322 | GFP_KERNEL); |
| 323 | if (!bss_desc) |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 324 | return -ENOMEM; |
Yogesh Ashok Powar | 5982b47 | 2011-08-29 13:21:10 -0700 | [diff] [blame] | 325 | |
Amitkumar Karwar | 9558a40 | 2012-04-16 21:36:51 -0700 | [diff] [blame] | 326 | ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc); |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 327 | if (ret) |
| 328 | goto done; |
| 329 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 330 | |
Stone Piao | 6621fe1 | 2013-07-29 16:32:39 -0700 | [diff] [blame] | 331 | if (priv->bss_mode == NL80211_IFTYPE_STATION || |
| 332 | priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) { |
Amitkumar Karwar | f2bbb07 | 2013-06-18 16:36:56 -0700 | [diff] [blame] | 333 | u8 config_bands; |
| 334 | |
Amitkumar Karwar | f2bbb07 | 2013-06-18 16:36:56 -0700 | [diff] [blame] | 335 | if (!bss_desc) |
| 336 | return -1; |
Amitkumar Karwar | d7b9c52 | 2013-01-08 17:53:10 -0800 | [diff] [blame] | 337 | |
Amitkumar Karwar | f2bbb07 | 2013-06-18 16:36:56 -0700 | [diff] [blame] | 338 | if (mwifiex_band_to_radio_type(bss_desc->bss_band) == |
Xinming Hu | a659c43 | 2014-09-12 20:08:50 +0530 | [diff] [blame] | 339 | HostCmd_SCAN_RADIO_TYPE_BG) { |
Bing Zhao | f25b143 | 2014-02-07 16:21:01 -0800 | [diff] [blame] | 340 | config_bands = BAND_B | BAND_G | BAND_GN; |
Xinming Hu | a659c43 | 2014-09-12 20:08:50 +0530 | [diff] [blame] | 341 | } else { |
| 342 | config_bands = BAND_A | BAND_AN; |
| 343 | if (adapter->fw_bands & BAND_AAC) |
| 344 | config_bands |= BAND_AAC; |
| 345 | } |
Amitkumar Karwar | d7b9c52 | 2013-01-08 17:53:10 -0800 | [diff] [blame] | 346 | |
Amitkumar Karwar | f2bbb07 | 2013-06-18 16:36:56 -0700 | [diff] [blame] | 347 | if (!((config_bands | adapter->fw_bands) & ~adapter->fw_bands)) |
| 348 | adapter->config_bands = config_bands; |
Amitkumar Karwar | d7b9c52 | 2013-01-08 17:53:10 -0800 | [diff] [blame] | 349 | |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 350 | ret = mwifiex_check_network_compatibility(priv, bss_desc); |
| 351 | if (ret) |
| 352 | goto done; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 353 | |
Amitkumar Karwar | b887664 | 2013-06-18 16:36:58 -0700 | [diff] [blame] | 354 | if (mwifiex_11h_get_csa_closed_channel(priv) == |
| 355 | (u8)bss_desc->channel) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 356 | mwifiex_dbg(adapter, ERROR, |
| 357 | "Attempt to reconnect on csa closed chan(%d)\n", |
| 358 | bss_desc->channel); |
Amitkumar Karwar | a6139b6 | 2016-02-23 05:16:17 -0800 | [diff] [blame] | 359 | ret = -1; |
Amitkumar Karwar | b887664 | 2013-06-18 16:36:58 -0700 | [diff] [blame] | 360 | goto done; |
| 361 | } |
| 362 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 363 | mwifiex_dbg(adapter, INFO, |
| 364 | "info: SSID found in scan list ...\t" |
| 365 | "associating...\n"); |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 366 | |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 367 | mwifiex_stop_net_dev_queue(priv->netdev, adapter); |
Amitkumar Karwar | b7097eb | 2012-02-01 20:41:43 -0800 | [diff] [blame] | 368 | if (netif_carrier_ok(priv->netdev)) |
| 369 | netif_carrier_off(priv->netdev); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 370 | |
| 371 | /* Clear any past association response stored for |
| 372 | * application retrieval */ |
| 373 | priv->assoc_rsp_size = 0; |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 374 | ret = mwifiex_associate(priv, bss_desc); |
Amitkumar Karwar | a0f6d6c | 2012-02-24 21:36:05 -0800 | [diff] [blame] | 375 | |
| 376 | /* If auth type is auto and association fails using open mode, |
| 377 | * try to connect using shared mode */ |
| 378 | if (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG && |
| 379 | priv->sec_info.is_authtype_auto && |
| 380 | priv->sec_info.wep_enabled) { |
| 381 | priv->sec_info.authentication_mode = |
| 382 | NL80211_AUTHTYPE_SHARED_KEY; |
| 383 | ret = mwifiex_associate(priv, bss_desc); |
| 384 | } |
| 385 | |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 386 | if (bss) |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 387 | cfg80211_put_bss(priv->adapter->wiphy, bss); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 388 | } else { |
| 389 | /* Adhoc mode */ |
| 390 | /* If the requested SSID matches current SSID, return */ |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 391 | if (bss_desc && bss_desc->ssid.ssid_len && |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 392 | (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor. |
| 393 | ssid, &bss_desc->ssid))) { |
Ujjal Roy | 517543f | 2013-11-21 11:08:56 -0800 | [diff] [blame] | 394 | ret = 0; |
| 395 | goto done; |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 396 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 397 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 398 | priv->adhoc_is_link_sensed = false; |
| 399 | |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 400 | ret = mwifiex_check_network_compatibility(priv, bss_desc); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 401 | |
Avinash Patil | 47411a0 | 2012-11-01 18:44:16 -0700 | [diff] [blame] | 402 | mwifiex_stop_net_dev_queue(priv->netdev, adapter); |
Amitkumar Karwar | b7097eb | 2012-02-01 20:41:43 -0800 | [diff] [blame] | 403 | if (netif_carrier_ok(priv->netdev)) |
| 404 | netif_carrier_off(priv->netdev); |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 405 | |
| 406 | if (!ret) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 407 | mwifiex_dbg(adapter, INFO, |
| 408 | "info: network found in scan\t" |
| 409 | " list. Joining...\n"); |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 410 | ret = mwifiex_adhoc_join(priv, bss_desc); |
| 411 | if (bss) |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 412 | cfg80211_put_bss(priv->adapter->wiphy, bss); |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 413 | } else { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 414 | mwifiex_dbg(adapter, INFO, |
| 415 | "info: Network not found in\t" |
| 416 | "the list, creating adhoc with ssid = %s\n", |
| 417 | req_ssid->ssid); |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 418 | ret = mwifiex_adhoc_start(priv, req_ssid); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 419 | } |
| 420 | } |
| 421 | |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 422 | done: |
Bing Zhao | d837a2a | 2013-04-12 10:34:17 -0700 | [diff] [blame] | 423 | /* beacon_ie buffer was allocated in function |
| 424 | * mwifiex_fill_new_bss_desc(). Free it now. |
| 425 | */ |
| 426 | if (bss_desc) |
| 427 | kfree(bss_desc->beacon_buf); |
Amitkumar Karwar | 7c6fa2a | 2011-08-10 18:53:57 -0700 | [diff] [blame] | 428 | kfree(bss_desc); |
Ganapathi Bhat | 4699fc3 | 2016-06-16 18:52:21 +0530 | [diff] [blame] | 429 | |
| 430 | if (ret < 0) |
| 431 | priv->attempted_bss_desc = NULL; |
| 432 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 433 | return ret; |
| 434 | } |
| 435 | |
| 436 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 437 | * IOCTL request handler to set host sleep configuration. |
| 438 | * |
| 439 | * This function prepares the correct firmware command and |
| 440 | * issues it. |
| 441 | */ |
Xinming Hu | 937a504 | 2014-06-19 21:38:56 -0700 | [diff] [blame] | 442 | int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action, |
| 443 | int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg) |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 444 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 445 | { |
| 446 | struct mwifiex_adapter *adapter = priv->adapter; |
| 447 | int status = 0; |
| 448 | u32 prev_cond = 0; |
| 449 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 450 | if (!hs_cfg) |
| 451 | return -ENOMEM; |
| 452 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 453 | switch (action) { |
| 454 | case HostCmd_ACT_GEN_SET: |
| 455 | if (adapter->pps_uapsd_mode) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 456 | mwifiex_dbg(adapter, INFO, |
| 457 | "info: Host Sleep IOCTL\t" |
| 458 | "is blocked in UAPSD/PPS mode\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 459 | status = -1; |
| 460 | break; |
| 461 | } |
| 462 | if (hs_cfg->is_invoke_hostcmd) { |
Amitkumar Karwar | cc0b5a6 | 2013-03-04 16:27:57 -0800 | [diff] [blame] | 463 | if (hs_cfg->conditions == HS_CFG_CANCEL) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 464 | if (!adapter->is_hs_configured) |
| 465 | /* Already cancelled */ |
| 466 | break; |
| 467 | /* Save previous condition */ |
| 468 | prev_cond = le32_to_cpu(adapter->hs_cfg |
| 469 | .conditions); |
| 470 | adapter->hs_cfg.conditions = |
| 471 | cpu_to_le32(hs_cfg->conditions); |
| 472 | } else if (hs_cfg->conditions) { |
| 473 | adapter->hs_cfg.conditions = |
| 474 | cpu_to_le32(hs_cfg->conditions); |
| 475 | adapter->hs_cfg.gpio = (u8)hs_cfg->gpio; |
| 476 | if (hs_cfg->gap) |
| 477 | adapter->hs_cfg.gap = (u8)hs_cfg->gap; |
Amitkumar Karwar | cc0b5a6 | 2013-03-04 16:27:57 -0800 | [diff] [blame] | 478 | } else if (adapter->hs_cfg.conditions == |
| 479 | cpu_to_le32(HS_CFG_CANCEL)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 480 | /* Return failure if no parameters for HS |
| 481 | enable */ |
| 482 | status = -1; |
| 483 | break; |
| 484 | } |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 485 | |
| 486 | status = mwifiex_send_cmd(priv, |
| 487 | HostCmd_CMD_802_11_HS_CFG_ENH, |
| 488 | HostCmd_ACT_GEN_SET, 0, |
| 489 | &adapter->hs_cfg, |
| 490 | cmd_type == MWIFIEX_SYNC_CMD); |
| 491 | |
Amitkumar Karwar | cc0b5a6 | 2013-03-04 16:27:57 -0800 | [diff] [blame] | 492 | if (hs_cfg->conditions == HS_CFG_CANCEL) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 493 | /* Restore previous condition */ |
| 494 | adapter->hs_cfg.conditions = |
| 495 | cpu_to_le32(prev_cond); |
| 496 | } else { |
| 497 | adapter->hs_cfg.conditions = |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 498 | cpu_to_le32(hs_cfg->conditions); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 499 | adapter->hs_cfg.gpio = (u8)hs_cfg->gpio; |
| 500 | adapter->hs_cfg.gap = (u8)hs_cfg->gap; |
| 501 | } |
| 502 | break; |
| 503 | case HostCmd_ACT_GEN_GET: |
| 504 | hs_cfg->conditions = le32_to_cpu(adapter->hs_cfg.conditions); |
| 505 | hs_cfg->gpio = adapter->hs_cfg.gpio; |
| 506 | hs_cfg->gap = adapter->hs_cfg.gap; |
| 507 | break; |
| 508 | default: |
| 509 | status = -1; |
| 510 | break; |
| 511 | } |
| 512 | |
| 513 | return status; |
| 514 | } |
| 515 | |
| 516 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 517 | * Sends IOCTL request to cancel the existing Host Sleep configuration. |
| 518 | * |
| 519 | * This function allocates the IOCTL request buffer, fills it |
| 520 | * with requisite parameters and calls the IOCTL handler. |
| 521 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 522 | int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 523 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 524 | struct mwifiex_ds_hs_cfg hscfg; |
| 525 | |
Amitkumar Karwar | cc0b5a6 | 2013-03-04 16:27:57 -0800 | [diff] [blame] | 526 | hscfg.conditions = HS_CFG_CANCEL; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 527 | hscfg.is_invoke_hostcmd = true; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 528 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 529 | return mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET, |
| 530 | cmd_type, &hscfg); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 531 | } |
| 532 | EXPORT_SYMBOL_GPL(mwifiex_cancel_hs); |
| 533 | |
| 534 | /* |
| 535 | * Sends IOCTL request to cancel the existing Host Sleep configuration. |
| 536 | * |
| 537 | * This function allocates the IOCTL request buffer, fills it |
| 538 | * with requisite parameters and calls the IOCTL handler. |
| 539 | */ |
| 540 | int mwifiex_enable_hs(struct mwifiex_adapter *adapter) |
| 541 | { |
| 542 | struct mwifiex_ds_hs_cfg hscfg; |
Amitkumar Karwar | 22c22d2 | 2012-09-20 20:23:17 -0700 | [diff] [blame] | 543 | struct mwifiex_private *priv; |
| 544 | int i; |
| 545 | |
| 546 | if (disconnect_on_suspend) { |
| 547 | for (i = 0; i < adapter->priv_num; i++) { |
| 548 | priv = adapter->priv[i]; |
| 549 | if (priv) |
| 550 | mwifiex_deauthenticate(priv, NULL); |
| 551 | } |
| 552 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 553 | |
Xinming Hu | 0c9b7f2 | 2016-01-13 01:26:52 -0800 | [diff] [blame] | 554 | priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA); |
chunfan chen | 7d7f07d | 2016-01-13 01:26:54 -0800 | [diff] [blame] | 555 | |
Xinming Hu | 0c9b7f2 | 2016-01-13 01:26:52 -0800 | [diff] [blame] | 556 | if (priv && priv->sched_scanning) { |
chunfan chen | 7d7f07d | 2016-01-13 01:26:54 -0800 | [diff] [blame] | 557 | #ifdef CONFIG_PM |
Wei-Ning Huang | a5c92f0 | 2016-03-30 18:14:55 +0800 | [diff] [blame] | 558 | if (priv->wdev.wiphy->wowlan_config && |
| 559 | !priv->wdev.wiphy->wowlan_config->nd_config) { |
chunfan chen | 7d7f07d | 2016-01-13 01:26:54 -0800 | [diff] [blame] | 560 | #endif |
| 561 | mwifiex_dbg(adapter, CMD, "aborting bgscan!\n"); |
| 562 | mwifiex_stop_bg_scan(priv); |
| 563 | cfg80211_sched_scan_stopped(priv->wdev.wiphy); |
| 564 | #ifdef CONFIG_PM |
| 565 | } |
| 566 | #endif |
Xinming Hu | 0c9b7f2 | 2016-01-13 01:26:52 -0800 | [diff] [blame] | 567 | } |
| 568 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 569 | if (adapter->hs_activated) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 570 | mwifiex_dbg(adapter, CMD, |
| 571 | "cmd: HS Already activated\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 572 | return true; |
| 573 | } |
| 574 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 575 | adapter->hs_activate_wait_q_woken = false; |
| 576 | |
Amitkumar Karwar | b093863 | 2012-03-13 19:36:49 -0700 | [diff] [blame] | 577 | memset(&hscfg, 0, sizeof(struct mwifiex_ds_hs_cfg)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 578 | hscfg.is_invoke_hostcmd = true; |
| 579 | |
Amitkumar Karwar | c0dbba6 | 2014-03-25 19:01:20 -0700 | [diff] [blame] | 580 | adapter->hs_enabling = true; |
| 581 | mwifiex_cancel_all_pending_cmd(adapter); |
| 582 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 583 | if (mwifiex_set_hs_params(mwifiex_get_priv(adapter, |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 584 | MWIFIEX_BSS_ROLE_STA), |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 585 | HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD, |
| 586 | &hscfg)) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 587 | mwifiex_dbg(adapter, ERROR, |
| 588 | "IOCTL request HS enable failed\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 589 | return false; |
| 590 | } |
| 591 | |
Amitkumar Karwar | 52250cb | 2014-03-20 16:23:50 -0700 | [diff] [blame] | 592 | if (wait_event_interruptible_timeout(adapter->hs_activate_wait_q, |
| 593 | adapter->hs_activate_wait_q_woken, |
| 594 | (10 * HZ)) <= 0) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 595 | mwifiex_dbg(adapter, ERROR, |
| 596 | "hs_activate_wait_q terminated\n"); |
Bing Zhao | 9c969d8 | 2013-01-02 16:07:35 -0800 | [diff] [blame] | 597 | return false; |
| 598 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 599 | |
| 600 | return true; |
| 601 | } |
| 602 | EXPORT_SYMBOL_GPL(mwifiex_enable_hs); |
| 603 | |
| 604 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 605 | * IOCTL request handler to get BSS information. |
| 606 | * |
| 607 | * This function collates the information from different driver structures |
| 608 | * to send to the user. |
| 609 | */ |
| 610 | int mwifiex_get_bss_info(struct mwifiex_private *priv, |
| 611 | struct mwifiex_bss_info *info) |
| 612 | { |
| 613 | struct mwifiex_adapter *adapter = priv->adapter; |
| 614 | struct mwifiex_bssdescriptor *bss_desc; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 615 | |
| 616 | if (!info) |
| 617 | return -1; |
| 618 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 619 | bss_desc = &priv->curr_bss_params.bss_descriptor; |
| 620 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 621 | info->bss_mode = priv->bss_mode; |
| 622 | |
Amitkumar Karwar | b9be5f3 | 2012-02-27 22:04:14 -0800 | [diff] [blame] | 623 | memcpy(&info->ssid, &bss_desc->ssid, sizeof(struct cfg80211_ssid)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 624 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 625 | memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN); |
| 626 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 627 | info->bss_chan = bss_desc->channel; |
| 628 | |
Avinash Patil | 67fdf39 | 2012-05-08 18:30:17 -0700 | [diff] [blame] | 629 | memcpy(info->country_code, adapter->country_code, |
Amitkumar Karwar | 5e218b7 | 2012-04-09 20:06:55 -0700 | [diff] [blame] | 630 | IEEE80211_COUNTRY_STRING_LEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 631 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 632 | info->media_connected = priv->media_connected; |
| 633 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 634 | info->max_power_level = priv->max_tx_power_level; |
| 635 | info->min_power_level = priv->min_tx_power_level; |
| 636 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 637 | info->adhoc_state = priv->adhoc_state; |
| 638 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 639 | info->bcn_nf_last = priv->bcn_nf_last; |
| 640 | |
Amitkumar Karwar | 5eb02e4 | 2012-02-24 21:36:04 -0800 | [diff] [blame] | 641 | if (priv->sec_info.wep_enabled) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 642 | info->wep_status = true; |
| 643 | else |
| 644 | info->wep_status = false; |
| 645 | |
| 646 | info->is_hs_configured = adapter->is_hs_configured; |
| 647 | info->is_deep_sleep = adapter->is_deep_sleep; |
| 648 | |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | /* |
Amitkumar Karwar | a049093 | 2011-07-13 20:51:59 -0700 | [diff] [blame] | 653 | * The function disables auto deep sleep mode. |
| 654 | */ |
| 655 | int mwifiex_disable_auto_ds(struct mwifiex_private *priv) |
| 656 | { |
| 657 | struct mwifiex_ds_auto_ds auto_ds; |
| 658 | |
| 659 | auto_ds.auto_ds = DEEP_SLEEP_OFF; |
| 660 | |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 661 | return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH, |
| 662 | DIS_AUTO_PS, BITMAP_AUTO_DS, &auto_ds, true); |
Amitkumar Karwar | a049093 | 2011-07-13 20:51:59 -0700 | [diff] [blame] | 663 | } |
| 664 | EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds); |
| 665 | |
| 666 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 667 | * Sends IOCTL request to get the data rate. |
| 668 | * |
| 669 | * This function allocates the IOCTL request buffer, fills it |
| 670 | * with requisite parameters and calls the IOCTL handler. |
| 671 | */ |
Amitkumar Karwar | 006606c | 2012-07-13 20:09:31 -0700 | [diff] [blame] | 672 | int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 673 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 674 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 675 | |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 676 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_TX_RATE_QUERY, |
| 677 | HostCmd_ACT_GEN_GET, 0, NULL, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 678 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 679 | if (!ret) { |
Amitkumar Karwar | 006606c | 2012-07-13 20:09:31 -0700 | [diff] [blame] | 680 | if (priv->is_data_rate_auto) |
| 681 | *rate = mwifiex_index_to_data_rate(priv, priv->tx_rate, |
| 682 | priv->tx_htinfo); |
Dan Carpenter | 4975312 | 2011-09-21 10:13:56 +0300 | [diff] [blame] | 683 | else |
Amitkumar Karwar | 006606c | 2012-07-13 20:09:31 -0700 | [diff] [blame] | 684 | *rate = priv->data_rate; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 685 | } |
| 686 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 687 | return ret; |
| 688 | } |
| 689 | |
| 690 | /* |
| 691 | * IOCTL request handler to set tx power configuration. |
| 692 | * |
| 693 | * This function prepares the correct firmware command and |
| 694 | * issues it. |
| 695 | * |
| 696 | * For non-auto power mode, all the following power groups are set - |
| 697 | * - Modulation class HR/DSSS |
| 698 | * - Modulation class OFDM |
| 699 | * - Modulation class HTBW20 |
| 700 | * - Modulation class HTBW40 |
| 701 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 702 | int mwifiex_set_tx_power(struct mwifiex_private *priv, |
| 703 | struct mwifiex_power_cfg *power_cfg) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 704 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 705 | int ret; |
| 706 | struct host_cmd_ds_txpwr_cfg *txp_cfg; |
| 707 | struct mwifiex_types_power_group *pg_tlv; |
| 708 | struct mwifiex_power_group *pg; |
| 709 | u8 *buf; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 710 | u16 dbm = 0; |
| 711 | |
| 712 | if (!power_cfg->is_power_auto) { |
| 713 | dbm = (u16) power_cfg->power_level; |
| 714 | if ((dbm < priv->min_tx_power_level) || |
| 715 | (dbm > priv->max_tx_power_level)) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 716 | mwifiex_dbg(priv->adapter, ERROR, |
| 717 | "txpower value %d dBm\t" |
| 718 | "is out of range (%d dBm-%d dBm)\n", |
| 719 | dbm, priv->min_tx_power_level, |
| 720 | priv->max_tx_power_level); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 721 | return -1; |
| 722 | } |
| 723 | } |
| 724 | buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL); |
Joe Perches | 0d2e7a5 | 2013-02-03 17:28:14 +0000 | [diff] [blame] | 725 | if (!buf) |
Christoph Fritz | b53575e | 2011-05-08 22:50:09 +0200 | [diff] [blame] | 726 | return -ENOMEM; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 727 | |
| 728 | txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf; |
| 729 | txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET); |
| 730 | if (!power_cfg->is_power_auto) { |
| 731 | txp_cfg->mode = cpu_to_le32(1); |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 732 | pg_tlv = (struct mwifiex_types_power_group *) |
| 733 | (buf + sizeof(struct host_cmd_ds_txpwr_cfg)); |
Amitkumar Karwar | 930fd35 | 2013-10-22 15:24:43 -0700 | [diff] [blame] | 734 | pg_tlv->type = cpu_to_le16(TLV_TYPE_POWER_GROUP); |
| 735 | pg_tlv->length = |
| 736 | cpu_to_le16(4 * sizeof(struct mwifiex_power_group)); |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 737 | pg = (struct mwifiex_power_group *) |
| 738 | (buf + sizeof(struct host_cmd_ds_txpwr_cfg) |
| 739 | + sizeof(struct mwifiex_types_power_group)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 740 | /* Power group for modulation class HR/DSSS */ |
| 741 | pg->first_rate_code = 0x00; |
| 742 | pg->last_rate_code = 0x03; |
| 743 | pg->modulation_class = MOD_CLASS_HR_DSSS; |
| 744 | pg->power_step = 0; |
| 745 | pg->power_min = (s8) dbm; |
| 746 | pg->power_max = (s8) dbm; |
| 747 | pg++; |
| 748 | /* Power group for modulation class OFDM */ |
| 749 | pg->first_rate_code = 0x00; |
| 750 | pg->last_rate_code = 0x07; |
| 751 | pg->modulation_class = MOD_CLASS_OFDM; |
| 752 | pg->power_step = 0; |
| 753 | pg->power_min = (s8) dbm; |
| 754 | pg->power_max = (s8) dbm; |
| 755 | pg++; |
| 756 | /* Power group for modulation class HTBW20 */ |
| 757 | pg->first_rate_code = 0x00; |
| 758 | pg->last_rate_code = 0x20; |
| 759 | pg->modulation_class = MOD_CLASS_HT; |
| 760 | pg->power_step = 0; |
| 761 | pg->power_min = (s8) dbm; |
| 762 | pg->power_max = (s8) dbm; |
| 763 | pg->ht_bandwidth = HT_BW_20; |
| 764 | pg++; |
| 765 | /* Power group for modulation class HTBW40 */ |
| 766 | pg->first_rate_code = 0x00; |
| 767 | pg->last_rate_code = 0x20; |
| 768 | pg->modulation_class = MOD_CLASS_HT; |
| 769 | pg->power_step = 0; |
| 770 | pg->power_min = (s8) dbm; |
| 771 | pg->power_max = (s8) dbm; |
| 772 | pg->ht_bandwidth = HT_BW_40; |
| 773 | } |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 774 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_TXPWR_CFG, |
| 775 | HostCmd_ACT_GEN_SET, 0, buf, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 776 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 777 | kfree(buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 778 | return ret; |
| 779 | } |
| 780 | |
| 781 | /* |
| 782 | * IOCTL request handler to get power save mode. |
| 783 | * |
| 784 | * This function prepares the correct firmware command and |
| 785 | * issues it. |
| 786 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 787 | int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 788 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 789 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 790 | struct mwifiex_adapter *adapter = priv->adapter; |
| 791 | u16 sub_cmd; |
| 792 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 793 | if (*ps_mode) |
| 794 | adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; |
| 795 | else |
| 796 | adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM; |
| 797 | sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS; |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 798 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH, |
| 799 | sub_cmd, BITMAP_STA_PS, NULL, true); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 800 | if ((!ret) && (sub_cmd == DIS_AUTO_PS)) |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 801 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH, |
| 802 | GET_PS, 0, NULL, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 803 | |
| 804 | return ret; |
| 805 | } |
| 806 | |
| 807 | /* |
| 808 | * IOCTL request handler to set/reset WPA IE. |
| 809 | * |
| 810 | * The supplied WPA IE is treated as a opaque buffer. Only the first field |
| 811 | * is checked to determine WPA version. If buffer length is zero, the existing |
| 812 | * WPA IE is reset. |
| 813 | */ |
| 814 | static int mwifiex_set_wpa_ie_helper(struct mwifiex_private *priv, |
| 815 | u8 *ie_data_ptr, u16 ie_len) |
| 816 | { |
| 817 | if (ie_len) { |
| 818 | if (ie_len > sizeof(priv->wpa_ie)) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 819 | mwifiex_dbg(priv->adapter, ERROR, |
| 820 | "failed to copy WPA IE, too big\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 821 | return -1; |
| 822 | } |
| 823 | memcpy(priv->wpa_ie, ie_data_ptr, ie_len); |
chunfan chen | 1d8f5c1 | 2015-12-16 04:21:42 -0800 | [diff] [blame] | 824 | priv->wpa_ie_len = ie_len; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 825 | mwifiex_dbg(priv->adapter, CMD, |
| 826 | "cmd: Set Wpa_ie_len=%d IE=%#x\n", |
| 827 | priv->wpa_ie_len, priv->wpa_ie[0]); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 828 | |
Arend van Spriel | 04b2312 | 2012-10-12 12:28:14 +0200 | [diff] [blame] | 829 | if (priv->wpa_ie[0] == WLAN_EID_VENDOR_SPECIFIC) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 830 | priv->sec_info.wpa_enabled = true; |
| 831 | } else if (priv->wpa_ie[0] == WLAN_EID_RSN) { |
| 832 | priv->sec_info.wpa2_enabled = true; |
| 833 | } else { |
| 834 | priv->sec_info.wpa_enabled = false; |
| 835 | priv->sec_info.wpa2_enabled = false; |
| 836 | } |
| 837 | } else { |
| 838 | memset(priv->wpa_ie, 0, sizeof(priv->wpa_ie)); |
| 839 | priv->wpa_ie_len = 0; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 840 | mwifiex_dbg(priv->adapter, INFO, |
| 841 | "info: reset wpa_ie_len=%d IE=%#x\n", |
| 842 | priv->wpa_ie_len, priv->wpa_ie[0]); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 843 | priv->sec_info.wpa_enabled = false; |
| 844 | priv->sec_info.wpa2_enabled = false; |
| 845 | } |
| 846 | |
| 847 | return 0; |
| 848 | } |
| 849 | |
| 850 | /* |
| 851 | * IOCTL request handler to set/reset WAPI IE. |
| 852 | * |
| 853 | * The supplied WAPI IE is treated as a opaque buffer. Only the first field |
| 854 | * is checked to internally enable WAPI. If buffer length is zero, the existing |
| 855 | * WAPI IE is reset. |
| 856 | */ |
| 857 | static int mwifiex_set_wapi_ie(struct mwifiex_private *priv, |
| 858 | u8 *ie_data_ptr, u16 ie_len) |
| 859 | { |
| 860 | if (ie_len) { |
| 861 | if (ie_len > sizeof(priv->wapi_ie)) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 862 | mwifiex_dbg(priv->adapter, ERROR, |
| 863 | "info: failed to copy WAPI IE, too big\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 864 | return -1; |
| 865 | } |
| 866 | memcpy(priv->wapi_ie, ie_data_ptr, ie_len); |
| 867 | priv->wapi_ie_len = ie_len; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 868 | mwifiex_dbg(priv->adapter, CMD, |
| 869 | "cmd: Set wapi_ie_len=%d IE=%#x\n", |
| 870 | priv->wapi_ie_len, priv->wapi_ie[0]); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 871 | |
| 872 | if (priv->wapi_ie[0] == WLAN_EID_BSS_AC_ACCESS_DELAY) |
| 873 | priv->sec_info.wapi_enabled = true; |
| 874 | } else { |
| 875 | memset(priv->wapi_ie, 0, sizeof(priv->wapi_ie)); |
| 876 | priv->wapi_ie_len = ie_len; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 877 | mwifiex_dbg(priv->adapter, INFO, |
| 878 | "info: Reset wapi_ie_len=%d IE=%#x\n", |
| 879 | priv->wapi_ie_len, priv->wapi_ie[0]); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 880 | priv->sec_info.wapi_enabled = false; |
| 881 | } |
| 882 | return 0; |
| 883 | } |
| 884 | |
| 885 | /* |
Avinash Patil | 13d7ba78 | 2012-04-09 20:06:56 -0700 | [diff] [blame] | 886 | * IOCTL request handler to set/reset WPS IE. |
| 887 | * |
| 888 | * The supplied WPS IE is treated as a opaque buffer. Only the first field |
| 889 | * is checked to internally enable WPS. If buffer length is zero, the existing |
| 890 | * WPS IE is reset. |
| 891 | */ |
| 892 | static int mwifiex_set_wps_ie(struct mwifiex_private *priv, |
| 893 | u8 *ie_data_ptr, u16 ie_len) |
| 894 | { |
| 895 | if (ie_len) { |
Avinash Patil | 8795ca6 | 2013-07-22 19:17:46 -0700 | [diff] [blame] | 896 | if (ie_len > MWIFIEX_MAX_VSIE_LEN) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 897 | mwifiex_dbg(priv->adapter, ERROR, |
| 898 | "info: failed to copy WPS IE, too big\n"); |
Avinash Patil | 8795ca6 | 2013-07-22 19:17:46 -0700 | [diff] [blame] | 899 | return -1; |
| 900 | } |
| 901 | |
Avinash Patil | 13d7ba78 | 2012-04-09 20:06:56 -0700 | [diff] [blame] | 902 | priv->wps_ie = kzalloc(MWIFIEX_MAX_VSIE_LEN, GFP_KERNEL); |
| 903 | if (!priv->wps_ie) |
| 904 | return -ENOMEM; |
Avinash Patil | 8795ca6 | 2013-07-22 19:17:46 -0700 | [diff] [blame] | 905 | |
Avinash Patil | 13d7ba78 | 2012-04-09 20:06:56 -0700 | [diff] [blame] | 906 | memcpy(priv->wps_ie, ie_data_ptr, ie_len); |
| 907 | priv->wps_ie_len = ie_len; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 908 | mwifiex_dbg(priv->adapter, CMD, |
| 909 | "cmd: Set wps_ie_len=%d IE=%#x\n", |
| 910 | priv->wps_ie_len, priv->wps_ie[0]); |
Avinash Patil | 13d7ba78 | 2012-04-09 20:06:56 -0700 | [diff] [blame] | 911 | } else { |
| 912 | kfree(priv->wps_ie); |
| 913 | priv->wps_ie_len = ie_len; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 914 | mwifiex_dbg(priv->adapter, INFO, |
| 915 | "info: Reset wps_ie_len=%d\n", priv->wps_ie_len); |
Avinash Patil | 13d7ba78 | 2012-04-09 20:06:56 -0700 | [diff] [blame] | 916 | } |
| 917 | return 0; |
| 918 | } |
| 919 | |
| 920 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 921 | * IOCTL request handler to set WAPI key. |
| 922 | * |
| 923 | * This function prepares the correct firmware command and |
| 924 | * issues it. |
| 925 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 926 | static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 927 | struct mwifiex_ds_encrypt_key *encrypt_key) |
| 928 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 929 | |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 930 | return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, |
| 931 | HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, |
| 932 | encrypt_key, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 933 | } |
| 934 | |
| 935 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 936 | * IOCTL request handler to set WEP network key. |
| 937 | * |
| 938 | * This function prepares the correct firmware command and |
| 939 | * issues it, after validation checks. |
| 940 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 941 | static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 942 | struct mwifiex_ds_encrypt_key *encrypt_key) |
| 943 | { |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 944 | struct mwifiex_adapter *adapter = priv->adapter; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 945 | int ret; |
| 946 | struct mwifiex_wep_key *wep_key; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 947 | int index; |
| 948 | |
| 949 | if (priv->wep_key_curr_index >= NUM_WEP_KEYS) |
| 950 | priv->wep_key_curr_index = 0; |
| 951 | wep_key = &priv->wep_key[priv->wep_key_curr_index]; |
| 952 | index = encrypt_key->key_index; |
| 953 | if (encrypt_key->key_disable) { |
Amitkumar Karwar | 5eb02e4 | 2012-02-24 21:36:04 -0800 | [diff] [blame] | 954 | priv->sec_info.wep_enabled = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 955 | } else if (!encrypt_key->key_len) { |
| 956 | /* Copy the required key as the current key */ |
| 957 | wep_key = &priv->wep_key[index]; |
| 958 | if (!wep_key->key_length) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 959 | mwifiex_dbg(adapter, ERROR, |
| 960 | "key not set, so cannot enable it\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 961 | return -1; |
| 962 | } |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 963 | |
Amitkumar Karwar | 4b9fede | 2014-08-19 08:24:25 -0400 | [diff] [blame] | 964 | if (adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2) { |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 965 | memcpy(encrypt_key->key_material, |
| 966 | wep_key->key_material, wep_key->key_length); |
| 967 | encrypt_key->key_len = wep_key->key_length; |
| 968 | } |
| 969 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 970 | priv->wep_key_curr_index = (u16) index; |
Amitkumar Karwar | 5eb02e4 | 2012-02-24 21:36:04 -0800 | [diff] [blame] | 971 | priv->sec_info.wep_enabled = 1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 972 | } else { |
| 973 | wep_key = &priv->wep_key[index]; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 974 | memset(wep_key, 0, sizeof(struct mwifiex_wep_key)); |
| 975 | /* Copy the key in the driver */ |
| 976 | memcpy(wep_key->key_material, |
| 977 | encrypt_key->key_material, |
| 978 | encrypt_key->key_len); |
| 979 | wep_key->key_index = index; |
| 980 | wep_key->key_length = encrypt_key->key_len; |
Amitkumar Karwar | 5eb02e4 | 2012-02-24 21:36:04 -0800 | [diff] [blame] | 981 | priv->sec_info.wep_enabled = 1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 982 | } |
| 983 | if (wep_key->key_length) { |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 984 | void *enc_key; |
| 985 | |
Xinming Hu | 2ab87d5 | 2014-12-26 03:02:32 -0800 | [diff] [blame] | 986 | if (encrypt_key->key_disable) { |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 987 | memset(&priv->wep_key[index], 0, |
| 988 | sizeof(struct mwifiex_wep_key)); |
Dan Carpenter | 97276c1 | 2015-12-04 16:17:15 +0300 | [diff] [blame] | 989 | goto done; |
| 990 | } |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 991 | |
Amitkumar Karwar | 4b9fede | 2014-08-19 08:24:25 -0400 | [diff] [blame] | 992 | if (adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2) |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 993 | enc_key = encrypt_key; |
| 994 | else |
| 995 | enc_key = NULL; |
| 996 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 997 | /* Send request to firmware */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 998 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, |
| 999 | HostCmd_ACT_GEN_SET, 0, enc_key, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1000 | if (ret) |
| 1001 | return ret; |
| 1002 | } |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 1003 | |
Xinming Hu | 2ab87d5 | 2014-12-26 03:02:32 -0800 | [diff] [blame] | 1004 | done: |
Amitkumar Karwar | 5eb02e4 | 2012-02-24 21:36:04 -0800 | [diff] [blame] | 1005 | if (priv->sec_info.wep_enabled) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1006 | priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE; |
| 1007 | else |
| 1008 | priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE; |
| 1009 | |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1010 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL, |
| 1011 | HostCmd_ACT_GEN_SET, 0, |
| 1012 | &priv->curr_pkt_filter, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1013 | |
| 1014 | return ret; |
| 1015 | } |
| 1016 | |
| 1017 | /* |
| 1018 | * IOCTL request handler to set WPA key. |
| 1019 | * |
| 1020 | * This function prepares the correct firmware command and |
| 1021 | * issues it, after validation checks. |
| 1022 | * |
| 1023 | * Current driver only supports key length of up to 32 bytes. |
| 1024 | * |
| 1025 | * This function can also be used to disable a currently set key. |
| 1026 | */ |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1027 | static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1028 | struct mwifiex_ds_encrypt_key *encrypt_key) |
| 1029 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 1030 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1031 | u8 remove_key = false; |
| 1032 | struct host_cmd_ds_802_11_key_material *ibss_key; |
| 1033 | |
| 1034 | /* Current driver only supports key length of up to 32 bytes */ |
Amitkumar Karwar | a373165 | 2011-04-15 20:50:41 -0700 | [diff] [blame] | 1035 | if (encrypt_key->key_len > WLAN_MAX_KEY_LEN) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1036 | mwifiex_dbg(priv->adapter, ERROR, |
| 1037 | "key length too long\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1038 | return -1; |
| 1039 | } |
| 1040 | |
Bing Zhao | eecd825 | 2011-03-28 17:55:41 -0700 | [diff] [blame] | 1041 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1042 | /* |
| 1043 | * IBSS/WPA-None uses only one key (Group) for both receiving |
| 1044 | * and sending unicast and multicast packets. |
| 1045 | */ |
| 1046 | /* Send the key as PTK to firmware */ |
| 1047 | encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST; |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1048 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, |
| 1049 | HostCmd_ACT_GEN_SET, |
| 1050 | KEY_INFO_ENABLED, encrypt_key, false); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1051 | if (ret) |
| 1052 | return ret; |
| 1053 | |
| 1054 | ibss_key = &priv->aes_key; |
| 1055 | memset(ibss_key, 0, |
| 1056 | sizeof(struct host_cmd_ds_802_11_key_material)); |
| 1057 | /* Copy the key in the driver */ |
| 1058 | memcpy(ibss_key->key_param_set.key, encrypt_key->key_material, |
| 1059 | encrypt_key->key_len); |
| 1060 | memcpy(&ibss_key->key_param_set.key_len, &encrypt_key->key_len, |
| 1061 | sizeof(ibss_key->key_param_set.key_len)); |
| 1062 | ibss_key->key_param_set.key_type_id |
| 1063 | = cpu_to_le16(KEY_TYPE_ID_TKIP); |
Yogesh Ashok Powar | 6a35a0a | 2011-04-06 16:46:56 -0700 | [diff] [blame] | 1064 | ibss_key->key_param_set.key_info = cpu_to_le16(KEY_ENABLED); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1065 | |
| 1066 | /* Send the key as GTK to firmware */ |
| 1067 | encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST; |
| 1068 | } |
| 1069 | |
| 1070 | if (!encrypt_key->key_index) |
| 1071 | encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST; |
| 1072 | |
| 1073 | if (remove_key) |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1074 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, |
| 1075 | HostCmd_ACT_GEN_SET, |
| 1076 | !KEY_INFO_ENABLED, encrypt_key, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1077 | else |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1078 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, |
| 1079 | HostCmd_ACT_GEN_SET, |
| 1080 | KEY_INFO_ENABLED, encrypt_key, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1081 | |
| 1082 | return ret; |
| 1083 | } |
| 1084 | |
| 1085 | /* |
| 1086 | * IOCTL request handler to set/get network keys. |
| 1087 | * |
| 1088 | * This is a generic key handling function which supports WEP, WPA |
| 1089 | * and WAPI. |
| 1090 | */ |
| 1091 | static int |
| 1092 | mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1093 | struct mwifiex_ds_encrypt_key *encrypt_key) |
| 1094 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 1095 | int status; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1096 | |
| 1097 | if (encrypt_key->is_wapi_key) |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1098 | status = mwifiex_sec_ioctl_set_wapi_key(priv, encrypt_key); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1099 | else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104) |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1100 | status = mwifiex_sec_ioctl_set_wpa_key(priv, encrypt_key); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1101 | else |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1102 | status = mwifiex_sec_ioctl_set_wep_key(priv, encrypt_key); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1103 | return status; |
| 1104 | } |
| 1105 | |
| 1106 | /* |
| 1107 | * This function returns the driver version. |
| 1108 | */ |
| 1109 | int |
| 1110 | mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version, |
| 1111 | int max_len) |
| 1112 | { |
| 1113 | union { |
Amitkumar Karwar | 0d4b5c7 | 2014-11-07 02:14:52 -0800 | [diff] [blame] | 1114 | __le32 l; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1115 | u8 c[4]; |
| 1116 | } ver; |
| 1117 | char fw_ver[32]; |
| 1118 | |
Amitkumar Karwar | 0d4b5c7 | 2014-11-07 02:14:52 -0800 | [diff] [blame] | 1119 | ver.l = cpu_to_le32(adapter->fw_release_number); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1120 | sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]); |
| 1121 | |
| 1122 | snprintf(version, max_len, driver_version, fw_ver); |
| 1123 | |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1124 | mwifiex_dbg(adapter, MSG, "info: MWIFIEX VERSION: %s\n", version); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1125 | |
| 1126 | return 0; |
| 1127 | } |
| 1128 | |
| 1129 | /* |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1130 | * Sends IOCTL request to set encoding parameters. |
| 1131 | * |
| 1132 | * This function allocates the IOCTL request buffer, fills it |
| 1133 | * with requisite parameters and calls the IOCTL handler. |
| 1134 | */ |
Ying Luo | 53b1123 | 2012-08-03 18:06:13 -0700 | [diff] [blame] | 1135 | int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp, |
| 1136 | const u8 *key, int key_len, u8 key_index, |
| 1137 | const u8 *mac_addr, int disable) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1138 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1139 | struct mwifiex_ds_encrypt_key encrypt_key; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1140 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1141 | memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key)); |
| 1142 | encrypt_key.key_len = key_len; |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 1143 | encrypt_key.key_index = key_index; |
Ying Luo | 53b1123 | 2012-08-03 18:06:13 -0700 | [diff] [blame] | 1144 | |
| 1145 | if (kp && kp->cipher == WLAN_CIPHER_SUITE_AES_CMAC) |
| 1146 | encrypt_key.is_igtk_key = true; |
| 1147 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1148 | if (!disable) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1149 | if (key_len) |
| 1150 | memcpy(encrypt_key.key_material, key, key_len); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 1151 | else |
| 1152 | encrypt_key.is_current_wep_key = true; |
| 1153 | |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 1154 | if (mac_addr) |
| 1155 | memcpy(encrypt_key.mac_addr, mac_addr, ETH_ALEN); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 1156 | if (kp && kp->seq && kp->seq_len) { |
Ying Luo | 53b1123 | 2012-08-03 18:06:13 -0700 | [diff] [blame] | 1157 | memcpy(encrypt_key.pn, kp->seq, kp->seq_len); |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 1158 | encrypt_key.pn_len = kp->seq_len; |
| 1159 | encrypt_key.is_rx_seq_valid = true; |
| 1160 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1161 | } else { |
Avinash Patil | e57f173 | 2014-02-07 16:32:35 -0800 | [diff] [blame] | 1162 | if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) |
| 1163 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1164 | encrypt_key.key_disable = true; |
Avinash Patil | 75edd2c | 2012-05-08 18:30:18 -0700 | [diff] [blame] | 1165 | if (mac_addr) |
| 1166 | memcpy(encrypt_key.mac_addr, mac_addr, ETH_ALEN); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1167 | } |
| 1168 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1169 | return mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1170 | } |
| 1171 | |
| 1172 | /* |
| 1173 | * Sends IOCTL request to get extended version. |
| 1174 | * |
| 1175 | * This function allocates the IOCTL request buffer, fills it |
| 1176 | * with requisite parameters and calls the IOCTL handler. |
| 1177 | */ |
| 1178 | int |
Xinming Hu | 17934b6 | 2016-01-06 23:40:49 -0800 | [diff] [blame] | 1179 | mwifiex_get_ver_ext(struct mwifiex_private *priv, u32 version_str_sel) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1180 | { |
| 1181 | struct mwifiex_ver_ext ver_ext; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1182 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1183 | memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext)); |
Xinming Hu | 17934b6 | 2016-01-06 23:40:49 -0800 | [diff] [blame] | 1184 | ver_ext.version_str_sel = version_str_sel; |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1185 | if (mwifiex_send_cmd(priv, HostCmd_CMD_VERSION_EXT, |
| 1186 | HostCmd_ACT_GEN_GET, 0, &ver_ext, true)) |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1187 | return -1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1188 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1189 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1190 | } |
| 1191 | |
Stone Piao | 7feb4c4 | 2012-09-25 20:23:36 -0700 | [diff] [blame] | 1192 | int |
| 1193 | mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action, |
| 1194 | struct ieee80211_channel *chan, |
Stone Piao | 7feb4c4 | 2012-09-25 20:23:36 -0700 | [diff] [blame] | 1195 | unsigned int duration) |
| 1196 | { |
| 1197 | struct host_cmd_ds_remain_on_chan roc_cfg; |
| 1198 | u8 sc; |
| 1199 | |
| 1200 | memset(&roc_cfg, 0, sizeof(roc_cfg)); |
| 1201 | roc_cfg.action = cpu_to_le16(action); |
| 1202 | if (action == HostCmd_ACT_GEN_SET) { |
| 1203 | roc_cfg.band_cfg = chan->band; |
Johannes Berg | 42d97a5 | 2012-11-08 18:31:02 +0100 | [diff] [blame] | 1204 | sc = mwifiex_chan_type_to_sec_chan_offset(NL80211_CHAN_NO_HT); |
Stone Piao | 7feb4c4 | 2012-09-25 20:23:36 -0700 | [diff] [blame] | 1205 | roc_cfg.band_cfg |= (sc << 2); |
| 1206 | |
| 1207 | roc_cfg.channel = |
| 1208 | ieee80211_frequency_to_channel(chan->center_freq); |
| 1209 | roc_cfg.duration = cpu_to_le32(duration); |
| 1210 | } |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1211 | if (mwifiex_send_cmd(priv, HostCmd_CMD_REMAIN_ON_CHAN, |
| 1212 | action, 0, &roc_cfg, true)) { |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1213 | mwifiex_dbg(priv->adapter, ERROR, |
| 1214 | "failed to remain on channel\n"); |
Stone Piao | 7feb4c4 | 2012-09-25 20:23:36 -0700 | [diff] [blame] | 1215 | return -1; |
| 1216 | } |
| 1217 | |
| 1218 | return roc_cfg.status; |
| 1219 | } |
| 1220 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1221 | /* |
| 1222 | * Sends IOCTL request to get statistics information. |
| 1223 | * |
| 1224 | * This function allocates the IOCTL request buffer, fills it |
| 1225 | * with requisite parameters and calls the IOCTL handler. |
| 1226 | */ |
| 1227 | int |
| 1228 | mwifiex_get_stats_info(struct mwifiex_private *priv, |
| 1229 | struct mwifiex_ds_get_stats *log) |
| 1230 | { |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1231 | return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_GET_LOG, |
| 1232 | HostCmd_ACT_GEN_GET, 0, log, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1233 | } |
| 1234 | |
| 1235 | /* |
| 1236 | * IOCTL request handler to read/write register. |
| 1237 | * |
| 1238 | * This function prepares the correct firmware command and |
| 1239 | * issues it. |
| 1240 | * |
| 1241 | * Access to the following registers are supported - |
| 1242 | * - MAC |
| 1243 | * - BBP |
| 1244 | * - RF |
| 1245 | * - PMIC |
| 1246 | * - CAU |
| 1247 | */ |
| 1248 | static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1249 | struct mwifiex_ds_reg_rw *reg_rw, |
| 1250 | u16 action) |
| 1251 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1252 | u16 cmd_no; |
| 1253 | |
Prasun Maiti | 8cfb860 | 2016-06-27 15:43:22 +0530 | [diff] [blame] | 1254 | switch (reg_rw->type) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1255 | case MWIFIEX_REG_MAC: |
| 1256 | cmd_no = HostCmd_CMD_MAC_REG_ACCESS; |
| 1257 | break; |
| 1258 | case MWIFIEX_REG_BBP: |
| 1259 | cmd_no = HostCmd_CMD_BBP_REG_ACCESS; |
| 1260 | break; |
| 1261 | case MWIFIEX_REG_RF: |
| 1262 | cmd_no = HostCmd_CMD_RF_REG_ACCESS; |
| 1263 | break; |
| 1264 | case MWIFIEX_REG_PMIC: |
| 1265 | cmd_no = HostCmd_CMD_PMIC_REG_ACCESS; |
| 1266 | break; |
| 1267 | case MWIFIEX_REG_CAU: |
| 1268 | cmd_no = HostCmd_CMD_CAU_REG_ACCESS; |
| 1269 | break; |
| 1270 | default: |
| 1271 | return -1; |
| 1272 | } |
| 1273 | |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1274 | return mwifiex_send_cmd(priv, cmd_no, action, 0, reg_rw, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | /* |
| 1278 | * Sends IOCTL request to write to a register. |
| 1279 | * |
| 1280 | * This function allocates the IOCTL request buffer, fills it |
| 1281 | * with requisite parameters and calls the IOCTL handler. |
| 1282 | */ |
| 1283 | int |
| 1284 | mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type, |
| 1285 | u32 reg_offset, u32 reg_value) |
| 1286 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1287 | struct mwifiex_ds_reg_rw reg_rw; |
| 1288 | |
Prasun Maiti | 8cfb860 | 2016-06-27 15:43:22 +0530 | [diff] [blame] | 1289 | reg_rw.type = reg_type; |
| 1290 | reg_rw.offset = reg_offset; |
| 1291 | reg_rw.value = reg_value; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1292 | |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1293 | return mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_SET); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1294 | } |
| 1295 | |
| 1296 | /* |
| 1297 | * Sends IOCTL request to read from a register. |
| 1298 | * |
| 1299 | * This function allocates the IOCTL request buffer, fills it |
| 1300 | * with requisite parameters and calls the IOCTL handler. |
| 1301 | */ |
| 1302 | int |
| 1303 | mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type, |
| 1304 | u32 reg_offset, u32 *value) |
| 1305 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 1306 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1307 | struct mwifiex_ds_reg_rw reg_rw; |
| 1308 | |
Prasun Maiti | 8cfb860 | 2016-06-27 15:43:22 +0530 | [diff] [blame] | 1309 | reg_rw.type = reg_type; |
| 1310 | reg_rw.offset = reg_offset; |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1311 | ret = mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_GET); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1312 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1313 | if (ret) |
| 1314 | goto done; |
| 1315 | |
Prasun Maiti | 8cfb860 | 2016-06-27 15:43:22 +0530 | [diff] [blame] | 1316 | *value = reg_rw.value; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1317 | |
| 1318 | done: |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1319 | return ret; |
| 1320 | } |
| 1321 | |
| 1322 | /* |
| 1323 | * Sends IOCTL request to read from EEPROM. |
| 1324 | * |
| 1325 | * This function allocates the IOCTL request buffer, fills it |
| 1326 | * with requisite parameters and calls the IOCTL handler. |
| 1327 | */ |
| 1328 | int |
| 1329 | mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes, |
| 1330 | u8 *value) |
| 1331 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 1332 | int ret; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1333 | struct mwifiex_ds_read_eeprom rd_eeprom; |
| 1334 | |
Prasun Maiti | 8cfb860 | 2016-06-27 15:43:22 +0530 | [diff] [blame] | 1335 | rd_eeprom.offset = offset; |
| 1336 | rd_eeprom.byte_count = bytes; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1337 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1338 | /* Send request to firmware */ |
Bing Zhao | fa0ecbb | 2014-02-27 19:35:12 -0800 | [diff] [blame] | 1339 | ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_EEPROM_ACCESS, |
| 1340 | HostCmd_ACT_GEN_GET, 0, &rd_eeprom, true); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1341 | |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 1342 | if (!ret) |
Prasun Maiti | 8cfb860 | 2016-06-27 15:43:22 +0530 | [diff] [blame] | 1343 | memcpy(value, rd_eeprom.value, min((u16)MAX_EEPROM_DATA, |
| 1344 | rd_eeprom.byte_count)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1345 | return ret; |
| 1346 | } |
| 1347 | |
| 1348 | /* |
| 1349 | * This function sets a generic IE. In addition to generic IE, it can |
| 1350 | * also handle WPA, WPA2 and WAPI IEs. |
| 1351 | */ |
| 1352 | static int |
| 1353 | mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr, |
| 1354 | u16 ie_len) |
| 1355 | { |
| 1356 | int ret = 0; |
| 1357 | struct ieee_types_vendor_header *pvendor_ie; |
| 1358 | const u8 wpa_oui[] = { 0x00, 0x50, 0xf2, 0x01 }; |
| 1359 | const u8 wps_oui[] = { 0x00, 0x50, 0xf2, 0x04 }; |
chunfan chen | 84a38fb | 2015-12-14 04:15:15 -0800 | [diff] [blame] | 1360 | u16 unparsed_len = ie_len; |
| 1361 | int find_wpa_ie = 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1362 | |
| 1363 | /* If the passed length is zero, reset the buffer */ |
| 1364 | if (!ie_len) { |
| 1365 | priv->gen_ie_buf_len = 0; |
| 1366 | priv->wps.session_enable = false; |
| 1367 | |
| 1368 | return 0; |
| 1369 | } else if (!ie_data_ptr) { |
| 1370 | return -1; |
| 1371 | } |
| 1372 | pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1373 | |
chunfan chen | 84a38fb | 2015-12-14 04:15:15 -0800 | [diff] [blame] | 1374 | while (pvendor_ie) { |
| 1375 | if (pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC) { |
| 1376 | /* Test to see if it is a WPA IE, if not, then it is a |
| 1377 | * gen IE |
| 1378 | */ |
| 1379 | if (!memcmp(pvendor_ie->oui, wpa_oui, |
| 1380 | sizeof(wpa_oui))) { |
| 1381 | find_wpa_ie = 1; |
| 1382 | break; |
| 1383 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1384 | |
chunfan chen | 84a38fb | 2015-12-14 04:15:15 -0800 | [diff] [blame] | 1385 | /* Test to see if it is a WPS IE, if so, enable |
| 1386 | * wps session flag |
| 1387 | */ |
| 1388 | if (!memcmp(pvendor_ie->oui, wps_oui, |
| 1389 | sizeof(wps_oui))) { |
| 1390 | priv->wps.session_enable = true; |
| 1391 | mwifiex_dbg(priv->adapter, MSG, |
| 1392 | "info: WPS Session Enabled.\n"); |
| 1393 | ret = mwifiex_set_wps_ie(priv, |
| 1394 | (u8 *)pvendor_ie, |
| 1395 | unparsed_len); |
| 1396 | } |
| 1397 | } |
| 1398 | |
| 1399 | if (pvendor_ie->element_id == WLAN_EID_RSN) { |
| 1400 | find_wpa_ie = 1; |
| 1401 | break; |
| 1402 | } |
| 1403 | |
| 1404 | if (pvendor_ie->element_id == WLAN_EID_BSS_AC_ACCESS_DELAY) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1405 | /* IE is a WAPI IE so call set_wapi function */ |
chunfan chen | 84a38fb | 2015-12-14 04:15:15 -0800 | [diff] [blame] | 1406 | ret = mwifiex_set_wapi_ie(priv, (u8 *)pvendor_ie, |
| 1407 | unparsed_len); |
| 1408 | return ret; |
| 1409 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1410 | |
chunfan chen | 84a38fb | 2015-12-14 04:15:15 -0800 | [diff] [blame] | 1411 | unparsed_len -= (pvendor_ie->len + |
| 1412 | sizeof(struct ieee_types_header)); |
| 1413 | |
| 1414 | if (unparsed_len <= sizeof(struct ieee_types_header)) |
| 1415 | pvendor_ie = NULL; |
| 1416 | else |
| 1417 | pvendor_ie = (struct ieee_types_vendor_header *) |
| 1418 | (((u8 *)pvendor_ie) + pvendor_ie->len + |
| 1419 | sizeof(struct ieee_types_header)); |
| 1420 | } |
| 1421 | |
| 1422 | if (find_wpa_ie) { |
| 1423 | /* IE is a WPA/WPA2 IE so call set_wpa function */ |
| 1424 | ret = mwifiex_set_wpa_ie_helper(priv, (u8 *)pvendor_ie, |
| 1425 | unparsed_len); |
| 1426 | priv->wps.session_enable = false; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1427 | return ret; |
| 1428 | } |
chunfan chen | 84a38fb | 2015-12-14 04:15:15 -0800 | [diff] [blame] | 1429 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1430 | /* |
| 1431 | * Verify that the passed length is not larger than the |
| 1432 | * available space remaining in the buffer |
| 1433 | */ |
| 1434 | if (ie_len < (sizeof(priv->gen_ie_buf) - priv->gen_ie_buf_len)) { |
| 1435 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1436 | /* Append the passed data to the end of the |
| 1437 | genIeBuffer */ |
| 1438 | memcpy(priv->gen_ie_buf + priv->gen_ie_buf_len, ie_data_ptr, |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 1439 | ie_len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1440 | /* Increment the stored buffer length by the |
| 1441 | size passed */ |
| 1442 | priv->gen_ie_buf_len += ie_len; |
| 1443 | } else { |
| 1444 | /* Passed data does not fit in the remaining |
| 1445 | buffer space */ |
| 1446 | ret = -1; |
| 1447 | } |
| 1448 | |
| 1449 | /* Return 0, or -1 for error case */ |
| 1450 | return ret; |
| 1451 | } |
| 1452 | |
| 1453 | /* |
| 1454 | * IOCTL request handler to set/get generic IE. |
| 1455 | * |
| 1456 | * In addition to various generic IEs, this function can also be |
| 1457 | * used to set the ARP filter. |
| 1458 | */ |
| 1459 | static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private *priv, |
| 1460 | struct mwifiex_ds_misc_gen_ie *gen_ie, |
| 1461 | u16 action) |
| 1462 | { |
| 1463 | struct mwifiex_adapter *adapter = priv->adapter; |
| 1464 | |
| 1465 | switch (gen_ie->type) { |
| 1466 | case MWIFIEX_IE_TYPE_GEN_IE: |
| 1467 | if (action == HostCmd_ACT_GEN_GET) { |
| 1468 | gen_ie->len = priv->wpa_ie_len; |
| 1469 | memcpy(gen_ie->ie_data, priv->wpa_ie, gen_ie->len); |
| 1470 | } else { |
| 1471 | mwifiex_set_gen_ie_helper(priv, gen_ie->ie_data, |
| 1472 | (u16) gen_ie->len); |
| 1473 | } |
| 1474 | break; |
| 1475 | case MWIFIEX_IE_TYPE_ARP_FILTER: |
| 1476 | memset(adapter->arp_filter, 0, sizeof(adapter->arp_filter)); |
| 1477 | if (gen_ie->len > ARP_FILTER_MAX_BUF_SIZE) { |
| 1478 | adapter->arp_filter_size = 0; |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1479 | mwifiex_dbg(adapter, ERROR, |
| 1480 | "invalid ARP filter size\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1481 | return -1; |
| 1482 | } else { |
| 1483 | memcpy(adapter->arp_filter, gen_ie->ie_data, |
Yogesh Ashok Powar | 500f747 | 2012-03-13 19:22:41 -0700 | [diff] [blame] | 1484 | gen_ie->len); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1485 | adapter->arp_filter_size = gen_ie->len; |
| 1486 | } |
| 1487 | break; |
| 1488 | default: |
Zhaoyang Liu | acebe8c | 2015-05-12 00:48:20 +0530 | [diff] [blame] | 1489 | mwifiex_dbg(adapter, ERROR, "invalid IE type\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1490 | return -1; |
| 1491 | } |
| 1492 | return 0; |
| 1493 | } |
| 1494 | |
| 1495 | /* |
| 1496 | * Sends IOCTL request to set a generic IE. |
| 1497 | * |
| 1498 | * This function allocates the IOCTL request buffer, fills it |
| 1499 | * with requisite parameters and calls the IOCTL handler. |
| 1500 | */ |
| 1501 | int |
Johannes Berg | 4b5800f | 2014-01-15 14:55:59 +0100 | [diff] [blame] | 1502 | mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1503 | { |
| 1504 | struct mwifiex_ds_misc_gen_ie gen_ie; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1505 | |
Bing Zhao | 67a5003 | 2011-07-13 18:38:34 -0700 | [diff] [blame] | 1506 | if (ie_len > IEEE_MAX_IE_SIZE) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1507 | return -EFAULT; |
| 1508 | |
| 1509 | gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE; |
| 1510 | gen_ie.len = ie_len; |
| 1511 | memcpy(gen_ie.ie_data, ie, ie_len); |
Yogesh Ashok Powar | 636c459 | 2011-04-15 20:50:40 -0700 | [diff] [blame] | 1512 | if (mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET)) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1513 | return -EFAULT; |
| 1514 | |
| 1515 | return 0; |
| 1516 | } |
chunfan chen | 8de00f1 | 2016-01-13 01:26:55 -0800 | [diff] [blame] | 1517 | |
| 1518 | /* This function get Host Sleep wake up reason. |
| 1519 | * |
| 1520 | */ |
| 1521 | int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action, |
| 1522 | int cmd_type, |
| 1523 | struct mwifiex_ds_wakeup_reason *wakeup_reason) |
| 1524 | { |
| 1525 | int status = 0; |
| 1526 | |
| 1527 | status = mwifiex_send_cmd(priv, HostCmd_CMD_HS_WAKEUP_REASON, |
| 1528 | HostCmd_ACT_GEN_GET, 0, wakeup_reason, |
| 1529 | cmd_type == MWIFIEX_SYNC_CMD); |
| 1530 | |
| 1531 | return status; |
| 1532 | } |