Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1 | /* |
Lior David | c5a157e | 2016-01-17 12:39:06 +0200 | [diff] [blame] | 2 | * Copyright (c) 2012-2016 Qualcomm Atheros, Inc. |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
Vladimir Kondratiev | a82553bb | 2015-03-15 16:00:21 +0200 | [diff] [blame] | 17 | #include <linux/etherdevice.h> |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 18 | #include "wil6210.h" |
| 19 | #include "wmi.h" |
| 20 | |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 21 | #define WIL_MAX_ROC_DURATION_MS 5000 |
| 22 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 23 | #define CHAN60G(_channel, _flags) { \ |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 24 | .band = NL80211_BAND_60GHZ, \ |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 25 | .center_freq = 56160 + (2160 * (_channel)), \ |
| 26 | .hw_value = (_channel), \ |
| 27 | .flags = (_flags), \ |
| 28 | .max_antenna_gain = 0, \ |
| 29 | .max_power = 40, \ |
| 30 | } |
| 31 | |
| 32 | static struct ieee80211_channel wil_60ghz_channels[] = { |
| 33 | CHAN60G(1, 0), |
| 34 | CHAN60G(2, 0), |
| 35 | CHAN60G(3, 0), |
| 36 | /* channel 4 not supported yet */ |
| 37 | }; |
| 38 | |
| 39 | static struct ieee80211_supported_band wil_band_60ghz = { |
| 40 | .channels = wil_60ghz_channels, |
| 41 | .n_channels = ARRAY_SIZE(wil_60ghz_channels), |
| 42 | .ht_cap = { |
| 43 | .ht_supported = true, |
| 44 | .cap = 0, /* TODO */ |
| 45 | .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K, /* TODO */ |
| 46 | .ampdu_density = IEEE80211_HT_MPDU_DENSITY_8, /* TODO */ |
| 47 | .mcs = { |
| 48 | /* MCS 1..12 - SC PHY */ |
| 49 | .rx_mask = {0xfe, 0x1f}, /* 1..12 */ |
| 50 | .tx_params = IEEE80211_HT_MCS_TX_DEFINED, /* TODO */ |
| 51 | }, |
| 52 | }, |
| 53 | }; |
| 54 | |
| 55 | static const struct ieee80211_txrx_stypes |
| 56 | wil_mgmt_stypes[NUM_NL80211_IFTYPES] = { |
| 57 | [NL80211_IFTYPE_STATION] = { |
| 58 | .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 59 | BIT(IEEE80211_STYPE_PROBE_RESP >> 4), |
| 60 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 61 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
| 62 | }, |
| 63 | [NL80211_IFTYPE_AP] = { |
| 64 | .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 65 | BIT(IEEE80211_STYPE_PROBE_RESP >> 4), |
| 66 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 67 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
| 68 | }, |
| 69 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 70 | .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 71 | BIT(IEEE80211_STYPE_PROBE_RESP >> 4), |
| 72 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 73 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
| 74 | }, |
| 75 | [NL80211_IFTYPE_P2P_GO] = { |
| 76 | .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 77 | BIT(IEEE80211_STYPE_PROBE_RESP >> 4), |
| 78 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 79 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
| 80 | }, |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 81 | [NL80211_IFTYPE_P2P_DEVICE] = { |
| 82 | .tx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 83 | BIT(IEEE80211_STYPE_PROBE_RESP >> 4), |
| 84 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 85 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
| 86 | }, |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | static const u32 wil_cipher_suites[] = { |
| 90 | WLAN_CIPHER_SUITE_GCMP, |
| 91 | }; |
| 92 | |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 93 | static const char * const key_usage_str[] = { |
| 94 | [WMI_KEY_USE_PAIRWISE] = "PTK", |
| 95 | [WMI_KEY_USE_RX_GROUP] = "RX_GTK", |
| 96 | [WMI_KEY_USE_TX_GROUP] = "TX_GTK", |
| 97 | }; |
| 98 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 99 | int wil_iftype_nl2wmi(enum nl80211_iftype type) |
| 100 | { |
| 101 | static const struct { |
| 102 | enum nl80211_iftype nl; |
| 103 | enum wmi_network_type wmi; |
| 104 | } __nl2wmi[] = { |
| 105 | {NL80211_IFTYPE_ADHOC, WMI_NETTYPE_ADHOC}, |
| 106 | {NL80211_IFTYPE_STATION, WMI_NETTYPE_INFRA}, |
| 107 | {NL80211_IFTYPE_AP, WMI_NETTYPE_AP}, |
| 108 | {NL80211_IFTYPE_P2P_CLIENT, WMI_NETTYPE_P2P}, |
| 109 | {NL80211_IFTYPE_P2P_GO, WMI_NETTYPE_P2P}, |
| 110 | {NL80211_IFTYPE_MONITOR, WMI_NETTYPE_ADHOC}, /* FIXME */ |
| 111 | }; |
| 112 | uint i; |
| 113 | |
| 114 | for (i = 0; i < ARRAY_SIZE(__nl2wmi); i++) { |
| 115 | if (__nl2wmi[i].nl == type) |
| 116 | return __nl2wmi[i].wmi; |
| 117 | } |
| 118 | |
| 119 | return -EOPNOTSUPP; |
| 120 | } |
| 121 | |
Vladimir Kondratiev | 9eb82d4 | 2014-06-16 19:37:13 +0300 | [diff] [blame] | 122 | int wil_cid_fill_sinfo(struct wil6210_priv *wil, int cid, |
| 123 | struct station_info *sinfo) |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 124 | { |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 125 | struct wmi_notify_req_cmd cmd = { |
Vladimir Kondratiev | 3df2cd36 | 2014-02-27 16:20:43 +0200 | [diff] [blame] | 126 | .cid = cid, |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 127 | .interval_usec = 0, |
| 128 | }; |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 129 | struct { |
Lior David | b874dde | 2016-03-01 19:18:09 +0200 | [diff] [blame] | 130 | struct wmi_cmd_hdr wmi; |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 131 | struct wmi_notify_req_done_event evt; |
| 132 | } __packed reply; |
Vladimir Kondratiev | c8b78b5 | 2014-02-27 16:20:49 +0200 | [diff] [blame] | 133 | struct wil_net_stats *stats = &wil->sta[cid].stats; |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 134 | int rc; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 135 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 136 | rc = wmi_call(wil, WMI_NOTIFY_REQ_CMDID, &cmd, sizeof(cmd), |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 137 | WMI_NOTIFY_REQ_DONE_EVENTID, &reply, sizeof(reply), 20); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 138 | if (rc) |
| 139 | return rc; |
| 140 | |
Vladimir Kondratiev | c8b78b5 | 2014-02-27 16:20:49 +0200 | [diff] [blame] | 141 | wil_dbg_wmi(wil, "Link status for CID %d: {\n" |
| 142 | " MCS %d TSF 0x%016llx\n" |
Vladimir Kondratiev | b8b33a3 | 2014-02-27 16:20:52 +0200 | [diff] [blame] | 143 | " BF status 0x%08x SNR 0x%08x SQI %d%%\n" |
Vladimir Kondratiev | c8b78b5 | 2014-02-27 16:20:49 +0200 | [diff] [blame] | 144 | " Tx Tpt %d goodput %d Rx goodput %d\n" |
| 145 | " Sectors(rx:tx) my %d:%d peer %d:%d\n""}\n", |
| 146 | cid, le16_to_cpu(reply.evt.bf_mcs), |
| 147 | le64_to_cpu(reply.evt.tsf), reply.evt.status, |
| 148 | le32_to_cpu(reply.evt.snr_val), |
Vladimir Kondratiev | b8b33a3 | 2014-02-27 16:20:52 +0200 | [diff] [blame] | 149 | reply.evt.sqi, |
Vladimir Kondratiev | c8b78b5 | 2014-02-27 16:20:49 +0200 | [diff] [blame] | 150 | le32_to_cpu(reply.evt.tx_tpt), |
| 151 | le32_to_cpu(reply.evt.tx_goodput), |
| 152 | le32_to_cpu(reply.evt.rx_goodput), |
| 153 | le16_to_cpu(reply.evt.my_rx_sector), |
| 154 | le16_to_cpu(reply.evt.my_tx_sector), |
| 155 | le16_to_cpu(reply.evt.other_rx_sector), |
| 156 | le16_to_cpu(reply.evt.other_tx_sector)); |
| 157 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 158 | sinfo->generation = wil->sinfo_gen; |
| 159 | |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 160 | sinfo->filled = BIT(NL80211_STA_INFO_RX_BYTES) | |
| 161 | BIT(NL80211_STA_INFO_TX_BYTES) | |
| 162 | BIT(NL80211_STA_INFO_RX_PACKETS) | |
| 163 | BIT(NL80211_STA_INFO_TX_PACKETS) | |
| 164 | BIT(NL80211_STA_INFO_RX_BITRATE) | |
| 165 | BIT(NL80211_STA_INFO_TX_BITRATE) | |
| 166 | BIT(NL80211_STA_INFO_RX_DROP_MISC) | |
| 167 | BIT(NL80211_STA_INFO_TX_FAILED); |
Vladimir Kondratiev | c8b78b5 | 2014-02-27 16:20:49 +0200 | [diff] [blame] | 168 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 169 | sinfo->txrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G; |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 170 | sinfo->txrate.mcs = le16_to_cpu(reply.evt.bf_mcs); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 171 | sinfo->rxrate.flags = RATE_INFO_FLAGS_MCS | RATE_INFO_FLAGS_60G; |
Vladimir Kondratiev | c8b78b5 | 2014-02-27 16:20:49 +0200 | [diff] [blame] | 172 | sinfo->rxrate.mcs = stats->last_mcs_rx; |
| 173 | sinfo->rx_bytes = stats->rx_bytes; |
| 174 | sinfo->rx_packets = stats->rx_packets; |
| 175 | sinfo->rx_dropped_misc = stats->rx_dropped; |
| 176 | sinfo->tx_bytes = stats->tx_bytes; |
| 177 | sinfo->tx_packets = stats->tx_packets; |
| 178 | sinfo->tx_failed = stats->tx_errors; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 179 | |
Vladimir Kondratiev | 9419b6a | 2014-12-23 09:47:14 +0200 | [diff] [blame] | 180 | if (test_bit(wil_status_fwconnected, wil->status)) { |
Johannes Berg | 319090b | 2014-11-17 14:08:11 +0100 | [diff] [blame] | 181 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); |
Vladimir Kondratiev | b8b33a3 | 2014-02-27 16:20:52 +0200 | [diff] [blame] | 182 | sinfo->signal = reply.evt.sqi; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 183 | } |
| 184 | |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 185 | return rc; |
| 186 | } |
| 187 | |
| 188 | static int wil_cfg80211_get_station(struct wiphy *wiphy, |
| 189 | struct net_device *ndev, |
Johannes Berg | 3b3a016 | 2014-05-19 17:19:31 +0200 | [diff] [blame] | 190 | const u8 *mac, struct station_info *sinfo) |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 191 | { |
| 192 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 193 | int rc; |
| 194 | |
| 195 | int cid = wil_find_cid(wil, mac); |
| 196 | |
Vladimir Kondratiev | fa4a18e | 2014-03-17 15:34:16 +0200 | [diff] [blame] | 197 | wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid); |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 198 | if (cid < 0) |
Vladimir Kondratiev | c14c5d9 | 2014-03-02 11:20:51 +0200 | [diff] [blame] | 199 | return cid; |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 200 | |
| 201 | rc = wil_cid_fill_sinfo(wil, cid, sinfo); |
| 202 | |
| 203 | return rc; |
| 204 | } |
| 205 | |
| 206 | /* |
| 207 | * Find @idx-th active STA for station dump. |
| 208 | */ |
| 209 | static int wil_find_cid_by_idx(struct wil6210_priv *wil, int idx) |
| 210 | { |
| 211 | int i; |
| 212 | |
| 213 | for (i = 0; i < ARRAY_SIZE(wil->sta); i++) { |
| 214 | if (wil->sta[i].status == wil_sta_unused) |
| 215 | continue; |
| 216 | if (idx == 0) |
| 217 | return i; |
| 218 | idx--; |
| 219 | } |
| 220 | |
| 221 | return -ENOENT; |
| 222 | } |
| 223 | |
| 224 | static int wil_cfg80211_dump_station(struct wiphy *wiphy, |
| 225 | struct net_device *dev, int idx, |
| 226 | u8 *mac, struct station_info *sinfo) |
| 227 | { |
| 228 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 229 | int rc; |
| 230 | int cid = wil_find_cid_by_idx(wil, idx); |
| 231 | |
| 232 | if (cid < 0) |
| 233 | return -ENOENT; |
| 234 | |
Vladimir Kondratiev | a82553bb | 2015-03-15 16:00:21 +0200 | [diff] [blame] | 235 | ether_addr_copy(mac, wil->sta[cid].addr); |
Vladimir Kondratiev | fa4a18e | 2014-03-17 15:34:16 +0200 | [diff] [blame] | 236 | wil_dbg_misc(wil, "%s(%pM) CID %d\n", __func__, mac, cid); |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 237 | |
| 238 | rc = wil_cid_fill_sinfo(wil, cid, sinfo); |
| 239 | |
| 240 | return rc; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 241 | } |
| 242 | |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 243 | static struct wireless_dev * |
| 244 | wil_cfg80211_add_iface(struct wiphy *wiphy, const char *name, |
| 245 | unsigned char name_assign_type, |
| 246 | enum nl80211_iftype type, |
| 247 | u32 *flags, struct vif_params *params) |
| 248 | { |
| 249 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 250 | struct net_device *ndev = wil_to_ndev(wil); |
| 251 | struct wireless_dev *p2p_wdev; |
| 252 | |
| 253 | wil_dbg_misc(wil, "%s()\n", __func__); |
| 254 | |
| 255 | if (type != NL80211_IFTYPE_P2P_DEVICE) { |
| 256 | wil_err(wil, "%s: unsupported iftype %d\n", __func__, type); |
| 257 | return ERR_PTR(-EINVAL); |
| 258 | } |
| 259 | |
| 260 | if (wil->p2p_wdev) { |
| 261 | wil_err(wil, "%s: P2P_DEVICE interface already created\n", |
| 262 | __func__); |
| 263 | return ERR_PTR(-EINVAL); |
| 264 | } |
| 265 | |
| 266 | p2p_wdev = kzalloc(sizeof(*p2p_wdev), GFP_KERNEL); |
| 267 | if (!p2p_wdev) |
| 268 | return ERR_PTR(-ENOMEM); |
| 269 | |
| 270 | p2p_wdev->iftype = type; |
| 271 | p2p_wdev->wiphy = wiphy; |
| 272 | /* use our primary ethernet address */ |
| 273 | ether_addr_copy(p2p_wdev->address, ndev->perm_addr); |
| 274 | |
| 275 | wil->p2p_wdev = p2p_wdev; |
| 276 | |
| 277 | return p2p_wdev; |
| 278 | } |
| 279 | |
| 280 | static int wil_cfg80211_del_iface(struct wiphy *wiphy, |
| 281 | struct wireless_dev *wdev) |
| 282 | { |
| 283 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 284 | |
| 285 | wil_dbg_misc(wil, "%s()\n", __func__); |
| 286 | |
| 287 | if (wdev != wil->p2p_wdev) { |
| 288 | wil_err(wil, "%s: delete of incorrect interface 0x%p\n", |
| 289 | __func__, wdev); |
| 290 | return -EINVAL; |
| 291 | } |
| 292 | |
| 293 | wil_p2p_wdev_free(wil); |
| 294 | |
| 295 | return 0; |
| 296 | } |
| 297 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 298 | static int wil_cfg80211_change_iface(struct wiphy *wiphy, |
| 299 | struct net_device *ndev, |
| 300 | enum nl80211_iftype type, u32 *flags, |
| 301 | struct vif_params *params) |
| 302 | { |
| 303 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 304 | struct wireless_dev *wdev = wil_to_wdev(wil); |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 305 | int rc; |
| 306 | |
| 307 | wil_dbg_misc(wil, "%s() type=%d\n", __func__, type); |
| 308 | |
Lior David | 375a173 | 2016-03-01 19:18:16 +0200 | [diff] [blame] | 309 | if (netif_running(wil_to_ndev(wil)) && !wil_is_recovery_blocked(wil)) { |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 310 | wil_dbg_misc(wil, "interface is up. resetting...\n"); |
| 311 | mutex_lock(&wil->mutex); |
| 312 | __wil_down(wil); |
| 313 | rc = __wil_up(wil); |
| 314 | mutex_unlock(&wil->mutex); |
| 315 | |
| 316 | if (rc) |
| 317 | return rc; |
| 318 | } |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 319 | |
| 320 | switch (type) { |
| 321 | case NL80211_IFTYPE_STATION: |
| 322 | case NL80211_IFTYPE_AP: |
| 323 | case NL80211_IFTYPE_P2P_CLIENT: |
| 324 | case NL80211_IFTYPE_P2P_GO: |
| 325 | break; |
| 326 | case NL80211_IFTYPE_MONITOR: |
| 327 | if (flags) |
| 328 | wil->monitor_flags = *flags; |
| 329 | else |
| 330 | wil->monitor_flags = 0; |
| 331 | |
| 332 | break; |
| 333 | default: |
| 334 | return -EOPNOTSUPP; |
| 335 | } |
| 336 | |
| 337 | wdev->iftype = type; |
| 338 | |
| 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | static int wil_cfg80211_scan(struct wiphy *wiphy, |
| 343 | struct cfg80211_scan_request *request) |
| 344 | { |
| 345 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 346 | struct wireless_dev *wdev = request->wdev; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 347 | struct { |
| 348 | struct wmi_start_scan_cmd cmd; |
| 349 | u16 chnl[4]; |
| 350 | } __packed cmd; |
| 351 | uint i, n; |
Vladimir Kondratiev | ed6f9dc | 2014-03-17 15:34:19 +0200 | [diff] [blame] | 352 | int rc; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 353 | |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 354 | wil_dbg_misc(wil, "%s(), wdev=0x%p iftype=%d\n", |
| 355 | __func__, wdev, wdev->iftype); |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 356 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 357 | /* check we are client side */ |
| 358 | switch (wdev->iftype) { |
| 359 | case NL80211_IFTYPE_STATION: |
| 360 | case NL80211_IFTYPE_P2P_CLIENT: |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 361 | case NL80211_IFTYPE_P2P_DEVICE: |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 362 | break; |
| 363 | default: |
| 364 | return -EOPNOTSUPP; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | /* FW don't support scan after connection attempt */ |
Vladimir Kondratiev | 9419b6a | 2014-12-23 09:47:14 +0200 | [diff] [blame] | 368 | if (test_bit(wil_status_dontscan, wil->status)) { |
Vladimir Kondratiev | e83eb2f | 2014-03-17 15:34:07 +0200 | [diff] [blame] | 369 | wil_err(wil, "Can't scan now\n"); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 370 | return -EBUSY; |
| 371 | } |
| 372 | |
Lior David | bb6743f7 | 2016-11-28 13:49:00 +0200 | [diff] [blame] | 373 | mutex_lock(&wil->mutex); |
| 374 | |
| 375 | mutex_lock(&wil->p2p_wdev_mutex); |
| 376 | if (wil->scan_request || wil->p2p.discovery_started) { |
| 377 | wil_err(wil, "Already scanning\n"); |
| 378 | mutex_unlock(&wil->p2p_wdev_mutex); |
| 379 | rc = -EAGAIN; |
| 380 | goto out; |
| 381 | } |
| 382 | mutex_unlock(&wil->p2p_wdev_mutex); |
| 383 | |
Lior David | 321a000 | 2016-04-26 14:41:38 +0300 | [diff] [blame] | 384 | /* social scan on P2P_DEVICE is handled as p2p search */ |
| 385 | if (wdev->iftype == NL80211_IFTYPE_P2P_DEVICE && |
| 386 | wil_p2p_is_social_scan(request)) { |
Lior David | eb57a5b | 2016-06-08 20:07:48 +0300 | [diff] [blame] | 387 | if (!wil->p2p.p2p_dev_started) { |
| 388 | wil_err(wil, "P2P search requested on stopped P2P device\n"); |
Lior David | bb6743f7 | 2016-11-28 13:49:00 +0200 | [diff] [blame] | 389 | rc = -EIO; |
| 390 | goto out; |
Lior David | eb57a5b | 2016-06-08 20:07:48 +0300 | [diff] [blame] | 391 | } |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 392 | wil->scan_request = request; |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 393 | wil->radio_wdev = wdev; |
| 394 | rc = wil_p2p_search(wil, request); |
| 395 | if (rc) { |
| 396 | wil->radio_wdev = wil_to_wdev(wil); |
| 397 | wil->scan_request = NULL; |
| 398 | } |
Lior David | bb6743f7 | 2016-11-28 13:49:00 +0200 | [diff] [blame] | 399 | goto out; |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 400 | } |
| 401 | |
Lior David | 280ab98 | 2016-03-01 19:18:14 +0200 | [diff] [blame] | 402 | (void)wil_p2p_stop_discovery(wil); |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 403 | |
Vladimir Kondratiev | 2a91d7d | 2014-06-16 19:37:11 +0300 | [diff] [blame] | 404 | wil_dbg_misc(wil, "Start scan_request 0x%p\n", request); |
Hamad Kadmany | 8e52fe3 | 2015-06-09 14:11:18 +0300 | [diff] [blame] | 405 | wil_dbg_misc(wil, "SSID count: %d", request->n_ssids); |
| 406 | |
| 407 | for (i = 0; i < request->n_ssids; i++) { |
| 408 | wil_dbg_misc(wil, "SSID[%d]", i); |
| 409 | print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET, |
| 410 | request->ssids[i].ssid, |
| 411 | request->ssids[i].ssid_len); |
| 412 | } |
| 413 | |
| 414 | if (request->n_ssids) |
| 415 | rc = wmi_set_ssid(wil, request->ssids[0].ssid_len, |
| 416 | request->ssids[0].ssid); |
| 417 | else |
| 418 | rc = wmi_set_ssid(wil, 0, NULL); |
| 419 | |
| 420 | if (rc) { |
| 421 | wil_err(wil, "set SSID for scan request failed: %d\n", rc); |
Lior David | bb6743f7 | 2016-11-28 13:49:00 +0200 | [diff] [blame] | 422 | goto out; |
Hamad Kadmany | 8e52fe3 | 2015-06-09 14:11:18 +0300 | [diff] [blame] | 423 | } |
| 424 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 425 | wil->scan_request = request; |
Vladimir Kondratiev | 047e5d7 | 2014-05-27 14:45:48 +0300 | [diff] [blame] | 426 | mod_timer(&wil->scan_timer, jiffies + WIL6210_SCAN_TO); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 427 | |
| 428 | memset(&cmd, 0, sizeof(cmd)); |
Lior David | 74997a5 | 2016-03-01 19:18:08 +0200 | [diff] [blame] | 429 | cmd.cmd.scan_type = WMI_ACTIVE_SCAN; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 430 | cmd.cmd.num_channels = 0; |
| 431 | n = min(request->n_channels, 4U); |
| 432 | for (i = 0; i < n; i++) { |
| 433 | int ch = request->channels[i]->hw_value; |
Vladimir Kondratiev | 8fe5962 | 2014-09-10 16:34:34 +0300 | [diff] [blame] | 434 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 435 | if (ch == 0) { |
| 436 | wil_err(wil, |
| 437 | "Scan requested for unknown frequency %dMhz\n", |
| 438 | request->channels[i]->center_freq); |
| 439 | continue; |
| 440 | } |
| 441 | /* 0-based channel indexes */ |
| 442 | cmd.cmd.channel_list[cmd.cmd.num_channels++].channel = ch - 1; |
Vladimir Kondratiev | 7743882 | 2013-01-28 18:31:06 +0200 | [diff] [blame] | 443 | wil_dbg_misc(wil, "Scan for ch %d : %d MHz\n", ch, |
Vladimir Kondratiev | 2057ebb | 2013-01-28 18:30:58 +0200 | [diff] [blame] | 444 | request->channels[i]->center_freq); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 445 | } |
| 446 | |
Vladimir Kondratiev | 77c9129 | 2014-09-10 16:34:47 +0300 | [diff] [blame] | 447 | if (request->ie_len) |
| 448 | print_hex_dump_bytes("Scan IE ", DUMP_PREFIX_OFFSET, |
| 449 | request->ie, request->ie_len); |
| 450 | else |
| 451 | wil_dbg_misc(wil, "Scan has no IE's\n"); |
| 452 | |
Vladimir Kondratiev | 5421bf0 | 2015-07-30 13:52:00 +0300 | [diff] [blame] | 453 | rc = wmi_set_ie(wil, WMI_FRAME_PROBE_REQ, request->ie_len, request->ie); |
| 454 | if (rc) |
Lior David | bb6743f7 | 2016-11-28 13:49:00 +0200 | [diff] [blame] | 455 | goto out_restore; |
Vladimir Kondratiev | 77c9129 | 2014-09-10 16:34:47 +0300 | [diff] [blame] | 456 | |
Lior David | 74997a5 | 2016-03-01 19:18:08 +0200 | [diff] [blame] | 457 | if (wil->discovery_mode && cmd.cmd.scan_type == WMI_ACTIVE_SCAN) { |
| 458 | cmd.cmd.discovery_mode = 1; |
| 459 | wil_dbg_misc(wil, "active scan with discovery_mode=1\n"); |
| 460 | } |
| 461 | |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 462 | wil->radio_wdev = wdev; |
Vladimir Kondratiev | ed6f9dc | 2014-03-17 15:34:19 +0200 | [diff] [blame] | 463 | rc = wmi_send(wil, WMI_START_SCAN_CMDID, &cmd, sizeof(cmd.cmd) + |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 464 | cmd.cmd.num_channels * sizeof(cmd.cmd.channel_list[0])); |
Vladimir Kondratiev | ed6f9dc | 2014-03-17 15:34:19 +0200 | [diff] [blame] | 465 | |
Lior David | bb6743f7 | 2016-11-28 13:49:00 +0200 | [diff] [blame] | 466 | out_restore: |
Vladimir Kondratiev | a214208 | 2014-08-06 10:31:57 +0300 | [diff] [blame] | 467 | if (rc) { |
| 468 | del_timer_sync(&wil->scan_timer); |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 469 | wil->radio_wdev = wil_to_wdev(wil); |
Vladimir Kondratiev | ed6f9dc | 2014-03-17 15:34:19 +0200 | [diff] [blame] | 470 | wil->scan_request = NULL; |
Vladimir Kondratiev | a214208 | 2014-08-06 10:31:57 +0300 | [diff] [blame] | 471 | } |
Lior David | bb6743f7 | 2016-11-28 13:49:00 +0200 | [diff] [blame] | 472 | out: |
| 473 | mutex_unlock(&wil->mutex); |
Vladimir Kondratiev | ed6f9dc | 2014-03-17 15:34:19 +0200 | [diff] [blame] | 474 | return rc; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 475 | } |
| 476 | |
Maya Erez | 035859a | 2016-11-23 16:06:42 +0200 | [diff] [blame] | 477 | static void wil_cfg80211_abort_scan(struct wiphy *wiphy, |
| 478 | struct wireless_dev *wdev) |
| 479 | { |
| 480 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 481 | |
| 482 | wil_dbg_misc(wil, "wdev=0x%p iftype=%d\n", wdev, wdev->iftype); |
| 483 | |
| 484 | mutex_lock(&wil->mutex); |
| 485 | mutex_lock(&wil->p2p_wdev_mutex); |
| 486 | |
| 487 | if (!wil->scan_request) |
| 488 | goto out; |
| 489 | |
| 490 | if (wdev != wil->scan_request->wdev) { |
| 491 | wil_dbg_misc(wil, "abort scan was called on the wrong iface\n"); |
| 492 | goto out; |
| 493 | } |
| 494 | |
| 495 | if (wil->radio_wdev == wil->p2p_wdev) |
| 496 | wil_p2p_stop_radio_operations(wil); |
| 497 | else |
| 498 | wil_abort_scan(wil, true); |
| 499 | |
| 500 | out: |
| 501 | mutex_unlock(&wil->p2p_wdev_mutex); |
| 502 | mutex_unlock(&wil->mutex); |
| 503 | } |
| 504 | |
Vladimir Kondratiev | feeac22 | 2015-02-01 10:55:15 +0200 | [diff] [blame] | 505 | static void wil_print_crypto(struct wil6210_priv *wil, |
| 506 | struct cfg80211_crypto_settings *c) |
| 507 | { |
| 508 | int i, n; |
| 509 | |
| 510 | wil_dbg_misc(wil, "WPA versions: 0x%08x cipher group 0x%08x\n", |
| 511 | c->wpa_versions, c->cipher_group); |
| 512 | wil_dbg_misc(wil, "Pairwise ciphers [%d] {\n", c->n_ciphers_pairwise); |
| 513 | n = min_t(int, c->n_ciphers_pairwise, ARRAY_SIZE(c->ciphers_pairwise)); |
| 514 | for (i = 0; i < n; i++) |
| 515 | wil_dbg_misc(wil, " [%d] = 0x%08x\n", i, |
| 516 | c->ciphers_pairwise[i]); |
| 517 | wil_dbg_misc(wil, "}\n"); |
| 518 | wil_dbg_misc(wil, "AKM suites [%d] {\n", c->n_akm_suites); |
| 519 | n = min_t(int, c->n_akm_suites, ARRAY_SIZE(c->akm_suites)); |
| 520 | for (i = 0; i < n; i++) |
| 521 | wil_dbg_misc(wil, " [%d] = 0x%08x\n", i, |
| 522 | c->akm_suites[i]); |
| 523 | wil_dbg_misc(wil, "}\n"); |
| 524 | wil_dbg_misc(wil, "Control port : %d, eth_type 0x%04x no_encrypt %d\n", |
| 525 | c->control_port, be16_to_cpu(c->control_port_ethertype), |
| 526 | c->control_port_no_encrypt); |
| 527 | } |
| 528 | |
Vladimir Kondratiev | 8ca2616 | 2014-09-10 16:34:32 +0300 | [diff] [blame] | 529 | static void wil_print_connect_params(struct wil6210_priv *wil, |
| 530 | struct cfg80211_connect_params *sme) |
| 531 | { |
| 532 | wil_info(wil, "Connecting to:\n"); |
| 533 | if (sme->channel) { |
| 534 | wil_info(wil, " Channel: %d freq %d\n", |
| 535 | sme->channel->hw_value, sme->channel->center_freq); |
| 536 | } |
| 537 | if (sme->bssid) |
| 538 | wil_info(wil, " BSSID: %pM\n", sme->bssid); |
| 539 | if (sme->ssid) |
| 540 | print_hex_dump(KERN_INFO, " SSID: ", DUMP_PREFIX_OFFSET, |
| 541 | 16, 1, sme->ssid, sme->ssid_len, true); |
| 542 | wil_info(wil, " Privacy: %s\n", sme->privacy ? "secure" : "open"); |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 543 | wil_info(wil, " PBSS: %d\n", sme->pbss); |
Vladimir Kondratiev | feeac22 | 2015-02-01 10:55:15 +0200 | [diff] [blame] | 544 | wil_print_crypto(wil, &sme->crypto); |
Vladimir Kondratiev | 8ca2616 | 2014-09-10 16:34:32 +0300 | [diff] [blame] | 545 | } |
| 546 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 547 | static int wil_cfg80211_connect(struct wiphy *wiphy, |
| 548 | struct net_device *ndev, |
| 549 | struct cfg80211_connect_params *sme) |
| 550 | { |
| 551 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 552 | struct cfg80211_bss *bss; |
| 553 | struct wmi_connect_cmd conn; |
| 554 | const u8 *ssid_eid; |
| 555 | const u8 *rsn_eid; |
| 556 | int ch; |
| 557 | int rc = 0; |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 558 | enum ieee80211_bss_type bss_type = IEEE80211_BSS_TYPE_ESS; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 559 | |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 560 | wil_dbg_misc(wil, "%s()\n", __func__); |
Vladimir Kondratiev | 344a702 | 2015-02-15 14:02:37 +0200 | [diff] [blame] | 561 | wil_print_connect_params(wil, sme); |
| 562 | |
Vladimir Kondratiev | 9419b6a | 2014-12-23 09:47:14 +0200 | [diff] [blame] | 563 | if (test_bit(wil_status_fwconnecting, wil->status) || |
| 564 | test_bit(wil_status_fwconnected, wil->status)) |
Vladimir Kondratiev | 4cd9e83 | 2014-03-17 15:34:20 +0200 | [diff] [blame] | 565 | return -EALREADY; |
| 566 | |
Vladimir Kondratiev | 344a702 | 2015-02-15 14:02:37 +0200 | [diff] [blame] | 567 | if (sme->ie_len > WMI_MAX_IE_LEN) { |
| 568 | wil_err(wil, "IE too large (%td bytes)\n", sme->ie_len); |
| 569 | return -ERANGE; |
| 570 | } |
| 571 | |
| 572 | rsn_eid = sme->ie ? |
| 573 | cfg80211_find_ie(WLAN_EID_RSN, sme->ie, sme->ie_len) : |
| 574 | NULL; |
Vladimir Kondratiev | 27aa6b7 | 2015-04-30 16:25:11 +0300 | [diff] [blame] | 575 | if (sme->privacy && !rsn_eid) |
| 576 | wil_info(wil, "WSC connection\n"); |
Vladimir Kondratiev | 8ca2616 | 2014-09-10 16:34:32 +0300 | [diff] [blame] | 577 | |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 578 | if (sme->pbss) |
| 579 | bss_type = IEEE80211_BSS_TYPE_PBSS; |
Lior David | 34d5051 | 2016-01-28 10:58:25 +0200 | [diff] [blame] | 580 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 581 | bss = cfg80211_get_bss(wiphy, sme->channel, sme->bssid, |
| 582 | sme->ssid, sme->ssid_len, |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 583 | bss_type, IEEE80211_PRIVACY_ANY); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 584 | if (!bss) { |
| 585 | wil_err(wil, "Unable to find BSS\n"); |
| 586 | return -ENOENT; |
| 587 | } |
| 588 | |
| 589 | ssid_eid = ieee80211_bss_get_ie(bss, WLAN_EID_SSID); |
| 590 | if (!ssid_eid) { |
| 591 | wil_err(wil, "No SSID\n"); |
| 592 | rc = -ENOENT; |
| 593 | goto out; |
| 594 | } |
Vladimir Kondratiev | 344a702 | 2015-02-15 14:02:37 +0200 | [diff] [blame] | 595 | wil->privacy = sme->privacy; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 596 | |
Vladimir Kondratiev | 344a702 | 2015-02-15 14:02:37 +0200 | [diff] [blame] | 597 | if (wil->privacy) { |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 598 | /* For secure assoc, remove old keys */ |
| 599 | rc = wmi_del_cipher_key(wil, 0, bss->bssid, |
| 600 | WMI_KEY_USE_PAIRWISE); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 601 | if (rc) { |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 602 | wil_err(wil, "WMI_DELETE_CIPHER_KEY_CMD(PTK) failed\n"); |
| 603 | goto out; |
| 604 | } |
| 605 | rc = wmi_del_cipher_key(wil, 0, bss->bssid, |
| 606 | WMI_KEY_USE_RX_GROUP); |
| 607 | if (rc) { |
| 608 | wil_err(wil, "WMI_DELETE_CIPHER_KEY_CMD(GTK) failed\n"); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 609 | goto out; |
| 610 | } |
Vladimir Kondratiev | ac4acdb | 2014-09-10 16:34:43 +0300 | [diff] [blame] | 611 | } |
| 612 | |
| 613 | /* WMI_SET_APPIE_CMD. ie may contain rsn info as well as other info |
| 614 | * elements. Send it also in case it's empty, to erase previously set |
| 615 | * ies in FW. |
| 616 | */ |
| 617 | rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_REQ, sme->ie_len, sme->ie); |
Vladimir Kondratiev | 5421bf0 | 2015-07-30 13:52:00 +0300 | [diff] [blame] | 618 | if (rc) |
Vladimir Kondratiev | ac4acdb | 2014-09-10 16:34:43 +0300 | [diff] [blame] | 619 | goto out; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 620 | |
| 621 | /* WMI_CONNECT_CMD */ |
| 622 | memset(&conn, 0, sizeof(conn)); |
Vladimir Kondratiev | acc9780 | 2013-03-13 14:12:47 +0200 | [diff] [blame] | 623 | switch (bss->capability & WLAN_CAPABILITY_DMG_TYPE_MASK) { |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 624 | case WLAN_CAPABILITY_DMG_TYPE_AP: |
| 625 | conn.network_type = WMI_NETTYPE_INFRA; |
| 626 | break; |
| 627 | case WLAN_CAPABILITY_DMG_TYPE_PBSS: |
| 628 | conn.network_type = WMI_NETTYPE_P2P; |
| 629 | break; |
| 630 | default: |
| 631 | wil_err(wil, "Unsupported BSS type, capability= 0x%04x\n", |
| 632 | bss->capability); |
| 633 | goto out; |
| 634 | } |
Vladimir Kondratiev | 344a702 | 2015-02-15 14:02:37 +0200 | [diff] [blame] | 635 | if (wil->privacy) { |
Vladimir Kondratiev | 27aa6b7 | 2015-04-30 16:25:11 +0300 | [diff] [blame] | 636 | if (rsn_eid) { /* regular secure connection */ |
| 637 | conn.dot11_auth_mode = WMI_AUTH11_SHARED; |
| 638 | conn.auth_mode = WMI_AUTH_WPA2_PSK; |
| 639 | conn.pairwise_crypto_type = WMI_CRYPT_AES_GCMP; |
| 640 | conn.pairwise_crypto_len = 16; |
| 641 | conn.group_crypto_type = WMI_CRYPT_AES_GCMP; |
| 642 | conn.group_crypto_len = 16; |
| 643 | } else { /* WSC */ |
| 644 | conn.dot11_auth_mode = WMI_AUTH11_WSC; |
| 645 | conn.auth_mode = WMI_AUTH_NONE; |
| 646 | } |
| 647 | } else { /* insecure connection */ |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 648 | conn.dot11_auth_mode = WMI_AUTH11_OPEN; |
| 649 | conn.auth_mode = WMI_AUTH_NONE; |
| 650 | } |
| 651 | |
| 652 | conn.ssid_len = min_t(u8, ssid_eid[1], 32); |
| 653 | memcpy(conn.ssid, ssid_eid+2, conn.ssid_len); |
| 654 | |
| 655 | ch = bss->channel->hw_value; |
| 656 | if (ch == 0) { |
| 657 | wil_err(wil, "BSS at unknown frequency %dMhz\n", |
| 658 | bss->channel->center_freq); |
| 659 | rc = -EOPNOTSUPP; |
| 660 | goto out; |
| 661 | } |
| 662 | conn.channel = ch - 1; |
| 663 | |
Vladimir Kondratiev | a82553bb | 2015-03-15 16:00:21 +0200 | [diff] [blame] | 664 | ether_addr_copy(conn.bssid, bss->bssid); |
| 665 | ether_addr_copy(conn.dst_mac, bss->bssid); |
Vladimir Kondratiev | e83eb2f | 2014-03-17 15:34:07 +0200 | [diff] [blame] | 666 | |
Vladimir Kondratiev | 9419b6a | 2014-12-23 09:47:14 +0200 | [diff] [blame] | 667 | set_bit(wil_status_fwconnecting, wil->status); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 668 | |
| 669 | rc = wmi_send(wil, WMI_CONNECT_CMDID, &conn, sizeof(conn)); |
| 670 | if (rc == 0) { |
Dedy Lansky | c5e96c9 | 2015-01-25 10:52:43 +0200 | [diff] [blame] | 671 | netif_carrier_on(ndev); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 672 | /* Connect can take lots of time */ |
| 673 | mod_timer(&wil->connect_timer, |
| 674 | jiffies + msecs_to_jiffies(2000)); |
Vladimir Kondratiev | b338f74 | 2013-05-28 15:17:53 +0300 | [diff] [blame] | 675 | } else { |
Vladimir Kondratiev | 9419b6a | 2014-12-23 09:47:14 +0200 | [diff] [blame] | 676 | clear_bit(wil_status_fwconnecting, wil->status); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | out: |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 680 | cfg80211_put_bss(wiphy, bss); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 681 | |
| 682 | return rc; |
| 683 | } |
| 684 | |
| 685 | static int wil_cfg80211_disconnect(struct wiphy *wiphy, |
| 686 | struct net_device *ndev, |
| 687 | u16 reason_code) |
| 688 | { |
| 689 | int rc; |
| 690 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 691 | |
Vladimir Kondratiev | de9084e | 2015-03-30 11:28:52 +0300 | [diff] [blame] | 692 | wil_dbg_misc(wil, "%s(reason=%d)\n", __func__, reason_code); |
| 693 | |
Vladimir Kondratiev | 78771d7 | 2016-01-28 19:24:03 +0200 | [diff] [blame] | 694 | if (!(test_bit(wil_status_fwconnecting, wil->status) || |
| 695 | test_bit(wil_status_fwconnected, wil->status))) { |
| 696 | wil_err(wil, "%s: Disconnect was called while disconnected\n", |
| 697 | __func__); |
| 698 | return 0; |
| 699 | } |
| 700 | |
| 701 | rc = wmi_call(wil, WMI_DISCONNECT_CMDID, NULL, 0, |
| 702 | WMI_DISCONNECT_EVENTID, NULL, 0, |
| 703 | WIL6210_DISCONNECT_TO_MS); |
| 704 | if (rc) |
| 705 | wil_err(wil, "%s: disconnect error %d\n", __func__, rc); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 706 | |
| 707 | return rc; |
| 708 | } |
| 709 | |
Lior David | 3fea18d | 2016-11-23 16:06:43 +0200 | [diff] [blame] | 710 | static int wil_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed) |
| 711 | { |
| 712 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 713 | int rc; |
| 714 | |
| 715 | /* these parameters are explicitly not supported */ |
| 716 | if (changed & (WIPHY_PARAM_RETRY_LONG | |
| 717 | WIPHY_PARAM_FRAG_THRESHOLD | |
| 718 | WIPHY_PARAM_RTS_THRESHOLD)) |
| 719 | return -ENOTSUPP; |
| 720 | |
| 721 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 722 | rc = wmi_set_mgmt_retry(wil, wiphy->retry_short); |
| 723 | if (rc) |
| 724 | return rc; |
| 725 | } |
| 726 | |
| 727 | return 0; |
| 728 | } |
| 729 | |
Vladimir Kondratiev | 0b39aaf | 2014-06-16 19:36:59 +0300 | [diff] [blame] | 730 | int wil_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 731 | struct cfg80211_mgmt_tx_params *params, |
| 732 | u64 *cookie) |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 733 | { |
| 734 | const u8 *buf = params->buf; |
| 735 | size_t len = params->len; |
| 736 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 737 | int rc; |
Vladimir Kondratiev | 304464f | 2014-06-16 19:37:00 +0300 | [diff] [blame] | 738 | bool tx_status = false; |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 739 | struct ieee80211_mgmt *mgmt_frame = (void *)buf; |
| 740 | struct wmi_sw_tx_req_cmd *cmd; |
| 741 | struct { |
Lior David | b874dde | 2016-03-01 19:18:09 +0200 | [diff] [blame] | 742 | struct wmi_cmd_hdr wmi; |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 743 | struct wmi_sw_tx_complete_event evt; |
| 744 | } __packed evt; |
| 745 | |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 746 | /* Note, currently we do not support the "wait" parameter, user-space |
| 747 | * must call remain_on_channel before mgmt_tx or listen on a channel |
| 748 | * another way (AP/PCP or connected station) |
| 749 | * in addition we need to check if specified "chan" argument is |
| 750 | * different from currently "listened" channel and fail if it is. |
| 751 | */ |
| 752 | |
| 753 | wil_dbg_misc(wil, "%s()\n", __func__); |
| 754 | print_hex_dump_bytes("mgmt tx frame ", DUMP_PREFIX_OFFSET, buf, len); |
| 755 | |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 756 | cmd = kmalloc(sizeof(*cmd) + len, GFP_KERNEL); |
Vladimir Kondratiev | 304464f | 2014-06-16 19:37:00 +0300 | [diff] [blame] | 757 | if (!cmd) { |
| 758 | rc = -ENOMEM; |
| 759 | goto out; |
| 760 | } |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 761 | |
| 762 | memcpy(cmd->dst_mac, mgmt_frame->da, WMI_MAC_LEN); |
| 763 | cmd->len = cpu_to_le16(len); |
| 764 | memcpy(cmd->payload, buf, len); |
| 765 | |
| 766 | rc = wmi_call(wil, WMI_SW_TX_REQ_CMDID, cmd, sizeof(*cmd) + len, |
| 767 | WMI_SW_TX_COMPLETE_EVENTID, &evt, sizeof(evt), 2000); |
| 768 | if (rc == 0) |
Vladimir Kondratiev | 304464f | 2014-06-16 19:37:00 +0300 | [diff] [blame] | 769 | tx_status = !evt.evt.status; |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 770 | |
| 771 | kfree(cmd); |
Vladimir Kondratiev | 304464f | 2014-06-16 19:37:00 +0300 | [diff] [blame] | 772 | out: |
| 773 | cfg80211_mgmt_tx_status(wdev, cookie ? *cookie : 0, buf, len, |
| 774 | tx_status, GFP_KERNEL); |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 775 | return rc; |
| 776 | } |
| 777 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 778 | static int wil_cfg80211_set_channel(struct wiphy *wiphy, |
| 779 | struct cfg80211_chan_def *chandef) |
| 780 | { |
| 781 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 782 | struct wireless_dev *wdev = wil_to_wdev(wil); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 783 | |
| 784 | wdev->preset_chandef = *chandef; |
| 785 | |
| 786 | return 0; |
| 787 | } |
| 788 | |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 789 | static enum wmi_key_usage wil_detect_key_usage(struct wil6210_priv *wil, |
| 790 | bool pairwise) |
| 791 | { |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 792 | struct wireless_dev *wdev = wil_to_wdev(wil); |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 793 | enum wmi_key_usage rc; |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 794 | |
| 795 | if (pairwise) { |
| 796 | rc = WMI_KEY_USE_PAIRWISE; |
| 797 | } else { |
| 798 | switch (wdev->iftype) { |
| 799 | case NL80211_IFTYPE_STATION: |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 800 | case NL80211_IFTYPE_P2P_CLIENT: |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 801 | rc = WMI_KEY_USE_RX_GROUP; |
| 802 | break; |
| 803 | case NL80211_IFTYPE_AP: |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 804 | case NL80211_IFTYPE_P2P_GO: |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 805 | rc = WMI_KEY_USE_TX_GROUP; |
| 806 | break; |
| 807 | default: |
| 808 | /* TODO: Rx GTK or Tx GTK? */ |
| 809 | wil_err(wil, "Can't determine GTK type\n"); |
| 810 | rc = WMI_KEY_USE_RX_GROUP; |
| 811 | break; |
| 812 | } |
| 813 | } |
| 814 | wil_dbg_misc(wil, "%s() -> %s\n", __func__, key_usage_str[rc]); |
| 815 | |
| 816 | return rc; |
| 817 | } |
| 818 | |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 819 | static struct wil_sta_info * |
| 820 | wil_find_sta_by_key_usage(struct wil6210_priv *wil, |
| 821 | enum wmi_key_usage key_usage, const u8 *mac_addr) |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 822 | { |
| 823 | int cid = -EINVAL; |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 824 | |
| 825 | if (key_usage == WMI_KEY_USE_TX_GROUP) |
| 826 | return NULL; /* not needed */ |
| 827 | |
| 828 | /* supplicant provides Rx group key in STA mode with NULL MAC address */ |
| 829 | if (mac_addr) |
| 830 | cid = wil_find_cid(wil, mac_addr); |
| 831 | else if (key_usage == WMI_KEY_USE_RX_GROUP) |
| 832 | cid = wil_find_cid_by_idx(wil, 0); |
| 833 | if (cid < 0) { |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 834 | wil_err(wil, "No CID for %pM %s\n", mac_addr, |
| 835 | key_usage_str[key_usage]); |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 836 | return ERR_PTR(cid); |
| 837 | } |
| 838 | |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 839 | return &wil->sta[cid]; |
| 840 | } |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 841 | |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 842 | static void wil_set_crypto_rx(u8 key_index, enum wmi_key_usage key_usage, |
| 843 | struct wil_sta_info *cs, |
| 844 | struct key_params *params) |
| 845 | { |
| 846 | struct wil_tid_crypto_rx_single *cc; |
| 847 | int tid; |
| 848 | |
| 849 | if (!cs) |
| 850 | return; |
| 851 | |
| 852 | switch (key_usage) { |
| 853 | case WMI_KEY_USE_PAIRWISE: |
| 854 | for (tid = 0; tid < WIL_STA_TID_NUM; tid++) { |
| 855 | cc = &cs->tid_crypto_rx[tid].key_id[key_index]; |
| 856 | if (params->seq) |
| 857 | memcpy(cc->pn, params->seq, |
| 858 | IEEE80211_GCMP_PN_LEN); |
| 859 | else |
| 860 | memset(cc->pn, 0, IEEE80211_GCMP_PN_LEN); |
| 861 | cc->key_set = true; |
| 862 | } |
| 863 | break; |
| 864 | case WMI_KEY_USE_RX_GROUP: |
| 865 | cc = &cs->group_crypto_rx.key_id[key_index]; |
| 866 | if (params->seq) |
| 867 | memcpy(cc->pn, params->seq, IEEE80211_GCMP_PN_LEN); |
| 868 | else |
| 869 | memset(cc->pn, 0, IEEE80211_GCMP_PN_LEN); |
| 870 | cc->key_set = true; |
| 871 | break; |
| 872 | default: |
| 873 | break; |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | static void wil_del_rx_key(u8 key_index, enum wmi_key_usage key_usage, |
| 878 | struct wil_sta_info *cs) |
| 879 | { |
| 880 | struct wil_tid_crypto_rx_single *cc; |
| 881 | int tid; |
| 882 | |
| 883 | if (!cs) |
| 884 | return; |
| 885 | |
| 886 | switch (key_usage) { |
| 887 | case WMI_KEY_USE_PAIRWISE: |
| 888 | for (tid = 0; tid < WIL_STA_TID_NUM; tid++) { |
| 889 | cc = &cs->tid_crypto_rx[tid].key_id[key_index]; |
| 890 | cc->key_set = false; |
| 891 | } |
| 892 | break; |
| 893 | case WMI_KEY_USE_RX_GROUP: |
| 894 | cc = &cs->group_crypto_rx.key_id[key_index]; |
| 895 | cc->key_set = false; |
| 896 | break; |
| 897 | default: |
| 898 | break; |
| 899 | } |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 900 | } |
| 901 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 902 | static int wil_cfg80211_add_key(struct wiphy *wiphy, |
| 903 | struct net_device *ndev, |
| 904 | u8 key_index, bool pairwise, |
| 905 | const u8 *mac_addr, |
| 906 | struct key_params *params) |
| 907 | { |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 908 | int rc; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 909 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 910 | enum wmi_key_usage key_usage = wil_detect_key_usage(wil, pairwise); |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 911 | struct wil_sta_info *cs = wil_find_sta_by_key_usage(wil, key_usage, |
| 912 | mac_addr); |
| 913 | |
| 914 | if (!params) { |
| 915 | wil_err(wil, "NULL params\n"); |
| 916 | return -EINVAL; |
| 917 | } |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 918 | |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 919 | wil_dbg_misc(wil, "%s(%pM %s[%d] PN %*phN)\n", __func__, |
| 920 | mac_addr, key_usage_str[key_usage], key_index, |
| 921 | params->seq_len, params->seq); |
Vladimir Kondratiev | db8adcb | 2015-03-30 11:28:51 +0300 | [diff] [blame] | 922 | |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 923 | if (IS_ERR(cs)) { |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 924 | wil_err(wil, "Not connected, %s(%pM %s[%d] PN %*phN)\n", |
| 925 | __func__, mac_addr, key_usage_str[key_usage], key_index, |
| 926 | params->seq_len, params->seq); |
| 927 | return -EINVAL; |
| 928 | } |
| 929 | |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 930 | wil_del_rx_key(key_index, key_usage, cs); |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 931 | |
| 932 | if (params->seq && params->seq_len != IEEE80211_GCMP_PN_LEN) { |
| 933 | wil_err(wil, |
| 934 | "Wrong PN len %d, %s(%pM %s[%d] PN %*phN)\n", |
| 935 | params->seq_len, __func__, mac_addr, |
| 936 | key_usage_str[key_usage], key_index, |
| 937 | params->seq_len, params->seq); |
| 938 | return -EINVAL; |
| 939 | } |
| 940 | |
| 941 | rc = wmi_add_cipher_key(wil, key_index, mac_addr, params->key_len, |
| 942 | params->key, key_usage); |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 943 | if (!rc) |
| 944 | wil_set_crypto_rx(key_index, key_usage, cs, params); |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 945 | |
| 946 | return rc; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 947 | } |
| 948 | |
| 949 | static int wil_cfg80211_del_key(struct wiphy *wiphy, |
| 950 | struct net_device *ndev, |
| 951 | u8 key_index, bool pairwise, |
| 952 | const u8 *mac_addr) |
| 953 | { |
| 954 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 955 | enum wmi_key_usage key_usage = wil_detect_key_usage(wil, pairwise); |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 956 | struct wil_sta_info *cs = wil_find_sta_by_key_usage(wil, key_usage, |
| 957 | mac_addr); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 958 | |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 959 | wil_dbg_misc(wil, "%s(%pM %s[%d])\n", __func__, mac_addr, |
| 960 | key_usage_str[key_usage], key_index); |
| 961 | |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 962 | if (IS_ERR(cs)) |
Vladimir Kondratiev | 5852742 | 2016-03-01 19:18:07 +0200 | [diff] [blame] | 963 | wil_info(wil, "Not connected, %s(%pM %s[%d])\n", __func__, |
| 964 | mac_addr, key_usage_str[key_usage], key_index); |
| 965 | |
Maya Erez | 74b6ac5 | 2016-08-18 16:52:12 +0300 | [diff] [blame] | 966 | if (!IS_ERR_OR_NULL(cs)) |
| 967 | wil_del_rx_key(key_index, key_usage, cs); |
Vladimir Kondratiev | db8adcb | 2015-03-30 11:28:51 +0300 | [diff] [blame] | 968 | |
Vladimir Kondratiev | 230d844 | 2015-04-30 16:25:10 +0300 | [diff] [blame] | 969 | return wmi_del_cipher_key(wil, key_index, mac_addr, key_usage); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 970 | } |
| 971 | |
| 972 | /* Need to be present or wiphy_new() will WARN */ |
| 973 | static int wil_cfg80211_set_default_key(struct wiphy *wiphy, |
| 974 | struct net_device *ndev, |
| 975 | u8 key_index, bool unicast, |
| 976 | bool multicast) |
| 977 | { |
Lior David | 280ab98 | 2016-03-01 19:18:14 +0200 | [diff] [blame] | 978 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 979 | |
| 980 | wil_dbg_misc(wil, "%s: entered\n", __func__); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 981 | return 0; |
| 982 | } |
| 983 | |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 984 | static int wil_remain_on_channel(struct wiphy *wiphy, |
| 985 | struct wireless_dev *wdev, |
| 986 | struct ieee80211_channel *chan, |
| 987 | unsigned int duration, |
| 988 | u64 *cookie) |
| 989 | { |
| 990 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 991 | int rc; |
| 992 | |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 993 | wil_dbg_misc(wil, "%s() center_freq=%d, duration=%d iftype=%d\n", |
| 994 | __func__, chan->center_freq, duration, wdev->iftype); |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 995 | |
Lior David | bb6743f7 | 2016-11-28 13:49:00 +0200 | [diff] [blame] | 996 | rc = wil_p2p_listen(wil, wdev, duration, chan, cookie); |
| 997 | return rc; |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 998 | } |
| 999 | |
| 1000 | static int wil_cancel_remain_on_channel(struct wiphy *wiphy, |
| 1001 | struct wireless_dev *wdev, |
| 1002 | u64 cookie) |
| 1003 | { |
| 1004 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 1005 | |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 1006 | wil_dbg_misc(wil, "%s()\n", __func__); |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 1007 | |
Lior David | 280ab98 | 2016-03-01 19:18:14 +0200 | [diff] [blame] | 1008 | return wil_p2p_cancel_listen(wil, cookie); |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 1009 | } |
| 1010 | |
Lior David | c100c88 | 2016-01-17 12:39:07 +0200 | [diff] [blame] | 1011 | /** |
| 1012 | * find a specific IE in a list of IEs |
| 1013 | * return a pointer to the beginning of IE in the list |
| 1014 | * or NULL if not found |
| 1015 | */ |
| 1016 | static const u8 *_wil_cfg80211_find_ie(const u8 *ies, u16 ies_len, const u8 *ie, |
| 1017 | u16 ie_len) |
| 1018 | { |
| 1019 | struct ieee80211_vendor_ie *vie; |
| 1020 | u32 oui; |
| 1021 | |
| 1022 | /* IE tag at offset 0, length at offset 1 */ |
| 1023 | if (ie_len < 2 || 2 + ie[1] > ie_len) |
| 1024 | return NULL; |
| 1025 | |
| 1026 | if (ie[0] != WLAN_EID_VENDOR_SPECIFIC) |
| 1027 | return cfg80211_find_ie(ie[0], ies, ies_len); |
| 1028 | |
| 1029 | /* make sure there is room for 3 bytes OUI + 1 byte OUI type */ |
| 1030 | if (ie[1] < 4) |
| 1031 | return NULL; |
| 1032 | vie = (struct ieee80211_vendor_ie *)ie; |
| 1033 | oui = vie->oui[0] << 16 | vie->oui[1] << 8 | vie->oui[2]; |
| 1034 | return cfg80211_find_vendor_ie(oui, vie->oui_type, ies, |
| 1035 | ies_len); |
| 1036 | } |
| 1037 | |
| 1038 | /** |
| 1039 | * merge the IEs in two lists into a single list. |
| 1040 | * do not include IEs from the second list which exist in the first list. |
| 1041 | * add only vendor specific IEs from second list to keep |
| 1042 | * the merged list sorted (since vendor-specific IE has the |
| 1043 | * highest tag number) |
| 1044 | * caller must free the allocated memory for merged IEs |
| 1045 | */ |
| 1046 | static int _wil_cfg80211_merge_extra_ies(const u8 *ies1, u16 ies1_len, |
| 1047 | const u8 *ies2, u16 ies2_len, |
| 1048 | u8 **merged_ies, u16 *merged_len) |
| 1049 | { |
| 1050 | u8 *buf, *dpos; |
| 1051 | const u8 *spos; |
| 1052 | |
| 1053 | if (ies1_len == 0 && ies2_len == 0) { |
| 1054 | *merged_ies = NULL; |
| 1055 | *merged_len = 0; |
| 1056 | return 0; |
| 1057 | } |
| 1058 | |
| 1059 | buf = kmalloc(ies1_len + ies2_len, GFP_KERNEL); |
| 1060 | if (!buf) |
| 1061 | return -ENOMEM; |
| 1062 | memcpy(buf, ies1, ies1_len); |
| 1063 | dpos = buf + ies1_len; |
| 1064 | spos = ies2; |
| 1065 | while (spos + 1 < ies2 + ies2_len) { |
| 1066 | /* IE tag at offset 0, length at offset 1 */ |
| 1067 | u16 ielen = 2 + spos[1]; |
| 1068 | |
| 1069 | if (spos + ielen > ies2 + ies2_len) |
| 1070 | break; |
| 1071 | if (spos[0] == WLAN_EID_VENDOR_SPECIFIC && |
| 1072 | !_wil_cfg80211_find_ie(ies1, ies1_len, spos, ielen)) { |
| 1073 | memcpy(dpos, spos, ielen); |
| 1074 | dpos += ielen; |
| 1075 | } |
| 1076 | spos += ielen; |
| 1077 | } |
| 1078 | |
| 1079 | *merged_ies = buf; |
| 1080 | *merged_len = dpos - buf; |
| 1081 | return 0; |
| 1082 | } |
| 1083 | |
Vladimir Kondratiev | ca95977 | 2014-06-16 19:37:01 +0300 | [diff] [blame] | 1084 | static void wil_print_bcon_data(struct cfg80211_beacon_data *b) |
| 1085 | { |
| 1086 | print_hex_dump_bytes("head ", DUMP_PREFIX_OFFSET, |
| 1087 | b->head, b->head_len); |
| 1088 | print_hex_dump_bytes("tail ", DUMP_PREFIX_OFFSET, |
| 1089 | b->tail, b->tail_len); |
| 1090 | print_hex_dump_bytes("BCON IE ", DUMP_PREFIX_OFFSET, |
| 1091 | b->beacon_ies, b->beacon_ies_len); |
| 1092 | print_hex_dump_bytes("PROBE ", DUMP_PREFIX_OFFSET, |
| 1093 | b->probe_resp, b->probe_resp_len); |
| 1094 | print_hex_dump_bytes("PROBE IE ", DUMP_PREFIX_OFFSET, |
| 1095 | b->proberesp_ies, b->proberesp_ies_len); |
| 1096 | print_hex_dump_bytes("ASSOC IE ", DUMP_PREFIX_OFFSET, |
| 1097 | b->assocresp_ies, b->assocresp_ies_len); |
| 1098 | } |
| 1099 | |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1100 | /* internal functions for device reset and starting AP */ |
| 1101 | static int _wil_cfg80211_set_ies(struct wiphy *wiphy, |
Vladimir Kondratiev | cab5abb | 2015-07-30 13:51:59 +0300 | [diff] [blame] | 1102 | struct cfg80211_beacon_data *bcon) |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1103 | { |
| 1104 | int rc; |
| 1105 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Lior David | c100c88 | 2016-01-17 12:39:07 +0200 | [diff] [blame] | 1106 | u16 len = 0, proberesp_len = 0; |
| 1107 | u8 *ies = NULL, *proberesp = NULL; |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1108 | |
Lior David | c100c88 | 2016-01-17 12:39:07 +0200 | [diff] [blame] | 1109 | if (bcon->probe_resp) { |
| 1110 | struct ieee80211_mgmt *f = |
| 1111 | (struct ieee80211_mgmt *)bcon->probe_resp; |
| 1112 | size_t hlen = offsetof(struct ieee80211_mgmt, |
| 1113 | u.probe_resp.variable); |
| 1114 | proberesp = f->u.probe_resp.variable; |
| 1115 | proberesp_len = bcon->probe_resp_len - hlen; |
| 1116 | } |
| 1117 | rc = _wil_cfg80211_merge_extra_ies(proberesp, |
| 1118 | proberesp_len, |
| 1119 | bcon->proberesp_ies, |
| 1120 | bcon->proberesp_ies_len, |
| 1121 | &ies, &len); |
| 1122 | |
Vladimir Kondratiev | 5421bf0 | 2015-07-30 13:52:00 +0300 | [diff] [blame] | 1123 | if (rc) |
Lior David | c100c88 | 2016-01-17 12:39:07 +0200 | [diff] [blame] | 1124 | goto out; |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1125 | |
Lior David | c100c88 | 2016-01-17 12:39:07 +0200 | [diff] [blame] | 1126 | rc = wmi_set_ie(wil, WMI_FRAME_PROBE_RESP, len, ies); |
| 1127 | if (rc) |
| 1128 | goto out; |
| 1129 | |
| 1130 | if (bcon->assocresp_ies) |
| 1131 | rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP, |
| 1132 | bcon->assocresp_ies_len, bcon->assocresp_ies); |
| 1133 | else |
| 1134 | rc = wmi_set_ie(wil, WMI_FRAME_ASSOC_RESP, len, ies); |
Vladimir Kondratiev | cab5abb | 2015-07-30 13:51:59 +0300 | [diff] [blame] | 1135 | #if 0 /* to use beacon IE's, remove this #if 0 */ |
Vladimir Kondratiev | 5421bf0 | 2015-07-30 13:52:00 +0300 | [diff] [blame] | 1136 | if (rc) |
Lior David | c100c88 | 2016-01-17 12:39:07 +0200 | [diff] [blame] | 1137 | goto out; |
Vladimir Kondratiev | 5421bf0 | 2015-07-30 13:52:00 +0300 | [diff] [blame] | 1138 | |
| 1139 | rc = wmi_set_ie(wil, WMI_FRAME_BEACON, bcon->tail_len, bcon->tail); |
Vladimir Kondratiev | cab5abb | 2015-07-30 13:51:59 +0300 | [diff] [blame] | 1140 | #endif |
Lior David | c100c88 | 2016-01-17 12:39:07 +0200 | [diff] [blame] | 1141 | out: |
| 1142 | kfree(ies); |
Vladimir Kondratiev | 5421bf0 | 2015-07-30 13:52:00 +0300 | [diff] [blame] | 1143 | return rc; |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1144 | } |
| 1145 | |
| 1146 | static int _wil_cfg80211_start_ap(struct wiphy *wiphy, |
| 1147 | struct net_device *ndev, |
| 1148 | const u8 *ssid, size_t ssid_len, u32 privacy, |
| 1149 | int bi, u8 chan, |
Vladimir Kondratiev | cab5abb | 2015-07-30 13:51:59 +0300 | [diff] [blame] | 1150 | struct cfg80211_beacon_data *bcon, |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 1151 | u8 hidden_ssid, u32 pbss) |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1152 | { |
| 1153 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 1154 | int rc; |
| 1155 | struct wireless_dev *wdev = ndev->ieee80211_ptr; |
| 1156 | u8 wmi_nettype = wil_iftype_nl2wmi(wdev->iftype); |
Lior David | b4944f2 | 2016-03-01 19:18:17 +0200 | [diff] [blame] | 1157 | u8 is_go = (wdev->iftype == NL80211_IFTYPE_P2P_GO); |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1158 | |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 1159 | if (pbss) |
| 1160 | wmi_nettype = WMI_NETTYPE_P2P; |
| 1161 | |
Lior David | b4944f2 | 2016-03-01 19:18:17 +0200 | [diff] [blame] | 1162 | wil_dbg_misc(wil, "%s: is_go=%d\n", __func__, is_go); |
| 1163 | if (is_go && !pbss) { |
| 1164 | wil_err(wil, "%s: P2P GO must be in PBSS\n", __func__); |
| 1165 | return -ENOTSUPP; |
| 1166 | } |
| 1167 | |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1168 | wil_set_recovery_state(wil, fw_recovery_idle); |
| 1169 | |
| 1170 | mutex_lock(&wil->mutex); |
| 1171 | |
| 1172 | __wil_down(wil); |
| 1173 | rc = __wil_up(wil); |
| 1174 | if (rc) |
| 1175 | goto out; |
| 1176 | |
| 1177 | rc = wmi_set_ssid(wil, ssid_len, ssid); |
| 1178 | if (rc) |
| 1179 | goto out; |
| 1180 | |
Vladimir Kondratiev | cab5abb | 2015-07-30 13:51:59 +0300 | [diff] [blame] | 1181 | rc = _wil_cfg80211_set_ies(wiphy, bcon); |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1182 | if (rc) |
| 1183 | goto out; |
| 1184 | |
| 1185 | wil->privacy = privacy; |
| 1186 | wil->channel = chan; |
| 1187 | wil->hidden_ssid = hidden_ssid; |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 1188 | wil->pbss = pbss; |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1189 | |
| 1190 | netif_carrier_on(ndev); |
| 1191 | |
Lior David | b4944f2 | 2016-03-01 19:18:17 +0200 | [diff] [blame] | 1192 | rc = wmi_pcp_start(wil, bi, wmi_nettype, chan, hidden_ssid, is_go); |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1193 | if (rc) |
| 1194 | goto err_pcp_start; |
| 1195 | |
| 1196 | rc = wil_bcast_init(wil); |
| 1197 | if (rc) |
| 1198 | goto err_bcast; |
| 1199 | |
| 1200 | goto out; /* success */ |
| 1201 | |
| 1202 | err_bcast: |
| 1203 | wmi_pcp_stop(wil); |
| 1204 | err_pcp_start: |
| 1205 | netif_carrier_off(ndev); |
| 1206 | out: |
| 1207 | mutex_unlock(&wil->mutex); |
| 1208 | return rc; |
| 1209 | } |
| 1210 | |
Vladimir Kondratiev | 1bd922f | 2014-09-10 16:34:44 +0300 | [diff] [blame] | 1211 | static int wil_cfg80211_change_beacon(struct wiphy *wiphy, |
| 1212 | struct net_device *ndev, |
| 1213 | struct cfg80211_beacon_data *bcon) |
| 1214 | { |
| 1215 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 1216 | int rc; |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1217 | u32 privacy = 0; |
Vladimir Kondratiev | 1bd922f | 2014-09-10 16:34:44 +0300 | [diff] [blame] | 1218 | |
| 1219 | wil_dbg_misc(wil, "%s()\n", __func__); |
Vladimir Kondratiev | 1e7e5a0 | 2015-04-30 16:25:08 +0300 | [diff] [blame] | 1220 | wil_print_bcon_data(bcon); |
| 1221 | |
Lior David | c5a157e | 2016-01-17 12:39:06 +0200 | [diff] [blame] | 1222 | if (bcon->tail && |
| 1223 | cfg80211_find_ie(WLAN_EID_RSN, bcon->tail, |
| 1224 | bcon->tail_len)) |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1225 | privacy = 1; |
| 1226 | |
| 1227 | /* in case privacy has changed, need to restart the AP */ |
| 1228 | if (wil->privacy != privacy) { |
| 1229 | struct wireless_dev *wdev = ndev->ieee80211_ptr; |
| 1230 | |
| 1231 | wil_dbg_misc(wil, "privacy changed %d=>%d. Restarting AP\n", |
| 1232 | wil->privacy, privacy); |
| 1233 | |
| 1234 | rc = _wil_cfg80211_start_ap(wiphy, ndev, wdev->ssid, |
| 1235 | wdev->ssid_len, privacy, |
| 1236 | wdev->beacon_interval, |
Vladimir Kondratiev | cab5abb | 2015-07-30 13:51:59 +0300 | [diff] [blame] | 1237 | wil->channel, bcon, |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 1238 | wil->hidden_ssid, |
| 1239 | wil->pbss); |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1240 | } else { |
Vladimir Kondratiev | cab5abb | 2015-07-30 13:51:59 +0300 | [diff] [blame] | 1241 | rc = _wil_cfg80211_set_ies(wiphy, bcon); |
Vladimir Kondratiev | 1bd922f | 2014-09-10 16:34:44 +0300 | [diff] [blame] | 1242 | } |
| 1243 | |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1244 | return rc; |
Vladimir Kondratiev | 1bd922f | 2014-09-10 16:34:44 +0300 | [diff] [blame] | 1245 | } |
| 1246 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1247 | static int wil_cfg80211_start_ap(struct wiphy *wiphy, |
| 1248 | struct net_device *ndev, |
| 1249 | struct cfg80211_ap_settings *info) |
| 1250 | { |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1251 | int rc; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1252 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1253 | struct ieee80211_channel *channel = info->chandef.chan; |
| 1254 | struct cfg80211_beacon_data *bcon = &info->beacon; |
Vladimir Kondratiev | ca95977 | 2014-06-16 19:37:01 +0300 | [diff] [blame] | 1255 | struct cfg80211_crypto_settings *crypto = &info->crypto; |
Hamad Kadmany | 8e52fe3 | 2015-06-09 14:11:18 +0300 | [diff] [blame] | 1256 | u8 hidden_ssid; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1257 | |
Vladimir Kondratiev | ca95977 | 2014-06-16 19:37:01 +0300 | [diff] [blame] | 1258 | wil_dbg_misc(wil, "%s()\n", __func__); |
| 1259 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1260 | if (!channel) { |
| 1261 | wil_err(wil, "AP: No channel???\n"); |
| 1262 | return -EINVAL; |
| 1263 | } |
| 1264 | |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1265 | switch (info->hidden_ssid) { |
| 1266 | case NL80211_HIDDEN_SSID_NOT_IN_USE: |
| 1267 | hidden_ssid = WMI_HIDDEN_SSID_DISABLED; |
| 1268 | break; |
| 1269 | |
| 1270 | case NL80211_HIDDEN_SSID_ZERO_LEN: |
| 1271 | hidden_ssid = WMI_HIDDEN_SSID_SEND_EMPTY; |
| 1272 | break; |
| 1273 | |
| 1274 | case NL80211_HIDDEN_SSID_ZERO_CONTENTS: |
| 1275 | hidden_ssid = WMI_HIDDEN_SSID_CLEAR; |
| 1276 | break; |
| 1277 | |
| 1278 | default: |
| 1279 | wil_err(wil, "AP: Invalid hidden SSID %d\n", info->hidden_ssid); |
| 1280 | return -EOPNOTSUPP; |
| 1281 | } |
Vladimir Kondratiev | 7743882 | 2013-01-28 18:31:06 +0200 | [diff] [blame] | 1282 | wil_dbg_misc(wil, "AP on Channel %d %d MHz, %s\n", channel->hw_value, |
Vladimir Kondratiev | 2057ebb | 2013-01-28 18:30:58 +0200 | [diff] [blame] | 1283 | channel->center_freq, info->privacy ? "secure" : "open"); |
Vladimir Kondratiev | ca95977 | 2014-06-16 19:37:01 +0300 | [diff] [blame] | 1284 | wil_dbg_misc(wil, "Privacy: %d auth_type %d\n", |
| 1285 | info->privacy, info->auth_type); |
Hamad Kadmany | 8e52fe3 | 2015-06-09 14:11:18 +0300 | [diff] [blame] | 1286 | wil_dbg_misc(wil, "Hidden SSID mode: %d\n", |
| 1287 | info->hidden_ssid); |
Vladimir Kondratiev | ca95977 | 2014-06-16 19:37:01 +0300 | [diff] [blame] | 1288 | wil_dbg_misc(wil, "BI %d DTIM %d\n", info->beacon_interval, |
| 1289 | info->dtim_period); |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 1290 | wil_dbg_misc(wil, "PBSS %d\n", info->pbss); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1291 | print_hex_dump_bytes("SSID ", DUMP_PREFIX_OFFSET, |
| 1292 | info->ssid, info->ssid_len); |
Vladimir Kondratiev | ca95977 | 2014-06-16 19:37:01 +0300 | [diff] [blame] | 1293 | wil_print_bcon_data(bcon); |
| 1294 | wil_print_crypto(wil, crypto); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1295 | |
Vladimir Kondratiev | 33190eb | 2015-06-15 17:42:32 +0300 | [diff] [blame] | 1296 | rc = _wil_cfg80211_start_ap(wiphy, ndev, |
| 1297 | info->ssid, info->ssid_len, info->privacy, |
| 1298 | info->beacon_interval, channel->hw_value, |
Lior David | eabb03b | 2016-03-01 19:18:10 +0200 | [diff] [blame] | 1299 | bcon, hidden_ssid, info->pbss); |
Vladimir Kondratiev | c33407a | 2014-10-01 15:05:24 +0300 | [diff] [blame] | 1300 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1301 | return rc; |
| 1302 | } |
| 1303 | |
| 1304 | static int wil_cfg80211_stop_ap(struct wiphy *wiphy, |
| 1305 | struct net_device *ndev) |
| 1306 | { |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1307 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1308 | |
Vladimir Kondratiev | ca95977 | 2014-06-16 19:37:01 +0300 | [diff] [blame] | 1309 | wil_dbg_misc(wil, "%s()\n", __func__); |
| 1310 | |
Dedy Lansky | c5e96c9 | 2015-01-25 10:52:43 +0200 | [diff] [blame] | 1311 | netif_carrier_off(ndev); |
Vladimir Kondratiev | c33407a | 2014-10-01 15:05:24 +0300 | [diff] [blame] | 1312 | wil_set_recovery_state(wil, fw_recovery_idle); |
| 1313 | |
Vladimir Kondratiev | 9c3bde5 | 2014-03-17 15:34:21 +0200 | [diff] [blame] | 1314 | mutex_lock(&wil->mutex); |
| 1315 | |
Dedy Lansky | 32a20d4 | 2015-01-25 10:52:44 +0200 | [diff] [blame] | 1316 | wmi_pcp_stop(wil); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1317 | |
Vladimir Kondratiev | 73d839a | 2014-09-10 16:34:50 +0300 | [diff] [blame] | 1318 | __wil_down(wil); |
Vladimir Kondratiev | 73d839a | 2014-09-10 16:34:50 +0300 | [diff] [blame] | 1319 | |
Vladimir Kondratiev | 9c3bde5 | 2014-03-17 15:34:21 +0200 | [diff] [blame] | 1320 | mutex_unlock(&wil->mutex); |
Vladimir Kondratiev | 73d839a | 2014-09-10 16:34:50 +0300 | [diff] [blame] | 1321 | |
Dedy Lansky | 32a20d4 | 2015-01-25 10:52:44 +0200 | [diff] [blame] | 1322 | return 0; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1323 | } |
| 1324 | |
Vladimir Kondratiev | 4d55a0a | 2014-02-27 16:20:54 +0200 | [diff] [blame] | 1325 | static int wil_cfg80211_del_station(struct wiphy *wiphy, |
Jouni Malinen | 89c771e | 2014-10-10 20:52:40 +0300 | [diff] [blame] | 1326 | struct net_device *dev, |
| 1327 | struct station_del_parameters *params) |
Vladimir Kondratiev | 4d55a0a | 2014-02-27 16:20:54 +0200 | [diff] [blame] | 1328 | { |
| 1329 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Vladimir Kondratiev | 097638a | 2014-03-17 15:34:25 +0200 | [diff] [blame] | 1330 | |
Vladimir Kondratiev | de9084e | 2015-03-30 11:28:52 +0300 | [diff] [blame] | 1331 | wil_dbg_misc(wil, "%s(%pM, reason=%d)\n", __func__, params->mac, |
| 1332 | params->reason_code); |
| 1333 | |
Vladimir Kondratiev | 097638a | 2014-03-17 15:34:25 +0200 | [diff] [blame] | 1334 | mutex_lock(&wil->mutex); |
Vladimir Kondratiev | 4821e6d | 2014-12-01 15:33:15 +0200 | [diff] [blame] | 1335 | wil6210_disconnect(wil, params->mac, params->reason_code, false); |
Vladimir Kondratiev | 097638a | 2014-03-17 15:34:25 +0200 | [diff] [blame] | 1336 | mutex_unlock(&wil->mutex); |
| 1337 | |
Vladimir Kondratiev | 4d55a0a | 2014-02-27 16:20:54 +0200 | [diff] [blame] | 1338 | return 0; |
| 1339 | } |
| 1340 | |
Vladimir Kondratiev | 40822a9 | 2015-01-25 10:52:50 +0200 | [diff] [blame] | 1341 | /* probe_client handling */ |
| 1342 | static void wil_probe_client_handle(struct wil6210_priv *wil, |
| 1343 | struct wil_probe_client_req *req) |
| 1344 | { |
| 1345 | struct net_device *ndev = wil_to_ndev(wil); |
| 1346 | struct wil_sta_info *sta = &wil->sta[req->cid]; |
| 1347 | /* assume STA is alive if it is still connected, |
| 1348 | * else FW will disconnect it |
| 1349 | */ |
| 1350 | bool alive = (sta->status == wil_sta_connected); |
| 1351 | |
| 1352 | cfg80211_probe_status(ndev, sta->addr, req->cookie, alive, GFP_KERNEL); |
| 1353 | } |
| 1354 | |
| 1355 | static struct list_head *next_probe_client(struct wil6210_priv *wil) |
| 1356 | { |
| 1357 | struct list_head *ret = NULL; |
| 1358 | |
| 1359 | mutex_lock(&wil->probe_client_mutex); |
| 1360 | |
| 1361 | if (!list_empty(&wil->probe_client_pending)) { |
| 1362 | ret = wil->probe_client_pending.next; |
| 1363 | list_del(ret); |
| 1364 | } |
| 1365 | |
| 1366 | mutex_unlock(&wil->probe_client_mutex); |
| 1367 | |
| 1368 | return ret; |
| 1369 | } |
| 1370 | |
| 1371 | void wil_probe_client_worker(struct work_struct *work) |
| 1372 | { |
| 1373 | struct wil6210_priv *wil = container_of(work, struct wil6210_priv, |
| 1374 | probe_client_worker); |
| 1375 | struct wil_probe_client_req *req; |
| 1376 | struct list_head *lh; |
| 1377 | |
| 1378 | while ((lh = next_probe_client(wil)) != NULL) { |
| 1379 | req = list_entry(lh, struct wil_probe_client_req, list); |
| 1380 | |
| 1381 | wil_probe_client_handle(wil, req); |
| 1382 | kfree(req); |
| 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | void wil_probe_client_flush(struct wil6210_priv *wil) |
| 1387 | { |
| 1388 | struct wil_probe_client_req *req, *t; |
| 1389 | |
| 1390 | wil_dbg_misc(wil, "%s()\n", __func__); |
| 1391 | |
| 1392 | mutex_lock(&wil->probe_client_mutex); |
| 1393 | |
| 1394 | list_for_each_entry_safe(req, t, &wil->probe_client_pending, list) { |
| 1395 | list_del(&req->list); |
| 1396 | kfree(req); |
| 1397 | } |
| 1398 | |
| 1399 | mutex_unlock(&wil->probe_client_mutex); |
| 1400 | } |
| 1401 | |
| 1402 | static int wil_cfg80211_probe_client(struct wiphy *wiphy, |
| 1403 | struct net_device *dev, |
| 1404 | const u8 *peer, u64 *cookie) |
| 1405 | { |
| 1406 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 1407 | struct wil_probe_client_req *req; |
| 1408 | int cid = wil_find_cid(wil, peer); |
| 1409 | |
| 1410 | wil_dbg_misc(wil, "%s(%pM => CID %d)\n", __func__, peer, cid); |
| 1411 | |
| 1412 | if (cid < 0) |
| 1413 | return -ENOLINK; |
| 1414 | |
| 1415 | req = kzalloc(sizeof(*req), GFP_KERNEL); |
| 1416 | if (!req) |
| 1417 | return -ENOMEM; |
| 1418 | |
| 1419 | req->cid = cid; |
| 1420 | req->cookie = cid; |
| 1421 | |
| 1422 | mutex_lock(&wil->probe_client_mutex); |
| 1423 | list_add_tail(&req->list, &wil->probe_client_pending); |
| 1424 | mutex_unlock(&wil->probe_client_mutex); |
| 1425 | |
| 1426 | *cookie = req->cookie; |
| 1427 | queue_work(wil->wq_service, &wil->probe_client_worker); |
| 1428 | return 0; |
| 1429 | } |
| 1430 | |
Vladimir Kondratiev | 02beaf1 | 2015-03-08 15:42:03 +0200 | [diff] [blame] | 1431 | static int wil_cfg80211_change_bss(struct wiphy *wiphy, |
| 1432 | struct net_device *dev, |
| 1433 | struct bss_parameters *params) |
| 1434 | { |
| 1435 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 1436 | |
| 1437 | if (params->ap_isolate >= 0) { |
| 1438 | wil_dbg_misc(wil, "%s(ap_isolate %d => %d)\n", __func__, |
| 1439 | wil->ap_isolate, params->ap_isolate); |
| 1440 | wil->ap_isolate = params->ap_isolate; |
| 1441 | } |
| 1442 | |
| 1443 | return 0; |
| 1444 | } |
| 1445 | |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1446 | static int wil_cfg80211_start_p2p_device(struct wiphy *wiphy, |
| 1447 | struct wireless_dev *wdev) |
| 1448 | { |
| 1449 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 1450 | |
| 1451 | wil_dbg_misc(wil, "%s: entered\n", __func__); |
Lior David | eb57a5b | 2016-06-08 20:07:48 +0300 | [diff] [blame] | 1452 | wil->p2p.p2p_dev_started = 1; |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1453 | return 0; |
| 1454 | } |
| 1455 | |
| 1456 | static void wil_cfg80211_stop_p2p_device(struct wiphy *wiphy, |
| 1457 | struct wireless_dev *wdev) |
| 1458 | { |
| 1459 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
Maya Erez | d35c2b6 | 2016-08-18 16:52:14 +0300 | [diff] [blame] | 1460 | struct wil_p2p_info *p2p = &wil->p2p; |
| 1461 | |
| 1462 | if (!p2p->p2p_dev_started) |
| 1463 | return; |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1464 | |
| 1465 | wil_dbg_misc(wil, "%s: entered\n", __func__); |
Lior David | eb57a5b | 2016-06-08 20:07:48 +0300 | [diff] [blame] | 1466 | mutex_lock(&wil->mutex); |
Maya Erez | 035859a | 2016-11-23 16:06:42 +0200 | [diff] [blame] | 1467 | mutex_lock(&wil->p2p_wdev_mutex); |
Maya Erez | d35c2b6 | 2016-08-18 16:52:14 +0300 | [diff] [blame] | 1468 | wil_p2p_stop_radio_operations(wil); |
| 1469 | p2p->p2p_dev_started = 0; |
Maya Erez | 035859a | 2016-11-23 16:06:42 +0200 | [diff] [blame] | 1470 | mutex_unlock(&wil->p2p_wdev_mutex); |
Lior David | eb57a5b | 2016-06-08 20:07:48 +0300 | [diff] [blame] | 1471 | mutex_unlock(&wil->mutex); |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1472 | } |
| 1473 | |
Maya Erez | 2c207eb | 2016-11-23 16:06:40 +0200 | [diff] [blame] | 1474 | static int wil_cfg80211_set_power_mgmt(struct wiphy *wiphy, |
| 1475 | struct net_device *dev, |
| 1476 | bool enabled, int timeout) |
| 1477 | { |
| 1478 | struct wil6210_priv *wil = wiphy_to_wil(wiphy); |
| 1479 | enum wmi_ps_profile_type ps_profile; |
| 1480 | int rc; |
| 1481 | |
| 1482 | if (!test_bit(WMI_FW_CAPABILITY_PS_CONFIG, wil->fw_capabilities)) { |
| 1483 | wil_err(wil, "set_power_mgmt not supported\n"); |
| 1484 | return -EOPNOTSUPP; |
| 1485 | } |
| 1486 | |
| 1487 | wil_dbg_misc(wil, "enabled=%d, timeout=%d\n", |
| 1488 | enabled, timeout); |
| 1489 | |
| 1490 | if (enabled) |
| 1491 | ps_profile = WMI_PS_PROFILE_TYPE_DEFAULT; |
| 1492 | else |
| 1493 | ps_profile = WMI_PS_PROFILE_TYPE_PS_DISABLED; |
| 1494 | |
| 1495 | rc = wmi_ps_dev_profile_cfg(wil, ps_profile); |
| 1496 | if (rc) |
| 1497 | wil_err(wil, "wmi_ps_dev_profile_cfg failed (%d)\n", rc); |
| 1498 | |
| 1499 | return rc; |
| 1500 | } |
| 1501 | |
Bhumika Goyal | b59eb96 | 2017-01-11 16:32:12 +0200 | [diff] [blame^] | 1502 | static const struct cfg80211_ops wil_cfg80211_ops = { |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1503 | .add_virtual_intf = wil_cfg80211_add_iface, |
| 1504 | .del_virtual_intf = wil_cfg80211_del_iface, |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1505 | .scan = wil_cfg80211_scan, |
Maya Erez | 035859a | 2016-11-23 16:06:42 +0200 | [diff] [blame] | 1506 | .abort_scan = wil_cfg80211_abort_scan, |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1507 | .connect = wil_cfg80211_connect, |
| 1508 | .disconnect = wil_cfg80211_disconnect, |
Lior David | 3fea18d | 2016-11-23 16:06:43 +0200 | [diff] [blame] | 1509 | .set_wiphy_params = wil_cfg80211_set_wiphy_params, |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1510 | .change_virtual_intf = wil_cfg80211_change_iface, |
| 1511 | .get_station = wil_cfg80211_get_station, |
Vladimir Kondratiev | ef28afd | 2014-02-27 16:20:48 +0200 | [diff] [blame] | 1512 | .dump_station = wil_cfg80211_dump_station, |
Vladimir Kondratiev | 1647f12 | 2014-02-27 16:20:40 +0200 | [diff] [blame] | 1513 | .remain_on_channel = wil_remain_on_channel, |
| 1514 | .cancel_remain_on_channel = wil_cancel_remain_on_channel, |
| 1515 | .mgmt_tx = wil_cfg80211_mgmt_tx, |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1516 | .set_monitor_channel = wil_cfg80211_set_channel, |
| 1517 | .add_key = wil_cfg80211_add_key, |
| 1518 | .del_key = wil_cfg80211_del_key, |
| 1519 | .set_default_key = wil_cfg80211_set_default_key, |
| 1520 | /* AP mode */ |
Vladimir Kondratiev | 1bd922f | 2014-09-10 16:34:44 +0300 | [diff] [blame] | 1521 | .change_beacon = wil_cfg80211_change_beacon, |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1522 | .start_ap = wil_cfg80211_start_ap, |
| 1523 | .stop_ap = wil_cfg80211_stop_ap, |
Vladimir Kondratiev | 4d55a0a | 2014-02-27 16:20:54 +0200 | [diff] [blame] | 1524 | .del_station = wil_cfg80211_del_station, |
Vladimir Kondratiev | 40822a9 | 2015-01-25 10:52:50 +0200 | [diff] [blame] | 1525 | .probe_client = wil_cfg80211_probe_client, |
Vladimir Kondratiev | 02beaf1 | 2015-03-08 15:42:03 +0200 | [diff] [blame] | 1526 | .change_bss = wil_cfg80211_change_bss, |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1527 | /* P2P device */ |
| 1528 | .start_p2p_device = wil_cfg80211_start_p2p_device, |
| 1529 | .stop_p2p_device = wil_cfg80211_stop_p2p_device, |
Maya Erez | 2c207eb | 2016-11-23 16:06:40 +0200 | [diff] [blame] | 1530 | .set_power_mgmt = wil_cfg80211_set_power_mgmt, |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1531 | }; |
| 1532 | |
| 1533 | static void wil_wiphy_init(struct wiphy *wiphy) |
| 1534 | { |
Hamad Kadmany | 8e52fe3 | 2015-06-09 14:11:18 +0300 | [diff] [blame] | 1535 | wiphy->max_scan_ssids = 1; |
Vladimir Kondratiev | 77c9129 | 2014-09-10 16:34:47 +0300 | [diff] [blame] | 1536 | wiphy->max_scan_ie_len = WMI_MAX_IE_LEN; |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 1537 | wiphy->max_remain_on_channel_duration = WIL_MAX_ROC_DURATION_MS; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1538 | wiphy->max_num_pmkids = 0 /* TODO: */; |
| 1539 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | |
| 1540 | BIT(NL80211_IFTYPE_AP) | |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 1541 | BIT(NL80211_IFTYPE_P2P_CLIENT) | |
| 1542 | BIT(NL80211_IFTYPE_P2P_GO) | |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1543 | BIT(NL80211_IFTYPE_P2P_DEVICE) | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1544 | BIT(NL80211_IFTYPE_MONITOR); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1545 | wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME | |
Dedy Lansky | e6d6834 | 2016-03-01 19:18:12 +0200 | [diff] [blame] | 1546 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL | |
Maya Erez | 2c207eb | 2016-11-23 16:06:40 +0200 | [diff] [blame] | 1547 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD | |
| 1548 | WIPHY_FLAG_PS_ON_BY_DEFAULT; |
Vladimir Kondratiev | 9cf10d6 | 2014-09-10 16:34:36 +0300 | [diff] [blame] | 1549 | dev_dbg(wiphy_dev(wiphy), "%s : flags = 0x%08x\n", |
| 1550 | __func__, wiphy->flags); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1551 | wiphy->probe_resp_offload = |
| 1552 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | |
| 1553 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 | |
| 1554 | NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P; |
| 1555 | |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 1556 | wiphy->bands[NL80211_BAND_60GHZ] = &wil_band_60ghz; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1557 | |
| 1558 | /* TODO: figure this out */ |
Vladimir Kondratiev | b8b33a3 | 2014-02-27 16:20:52 +0200 | [diff] [blame] | 1559 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1560 | |
| 1561 | wiphy->cipher_suites = wil_cipher_suites; |
| 1562 | wiphy->n_cipher_suites = ARRAY_SIZE(wil_cipher_suites); |
| 1563 | wiphy->mgmt_stypes = wil_mgmt_stypes; |
Vladimir Kondratiev | 713c8a2 | 2015-01-25 10:52:49 +0200 | [diff] [blame] | 1564 | wiphy->features |= NL80211_FEATURE_SK_TX_STATUS; |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1565 | } |
| 1566 | |
| 1567 | struct wireless_dev *wil_cfg80211_init(struct device *dev) |
| 1568 | { |
| 1569 | int rc = 0; |
| 1570 | struct wireless_dev *wdev; |
| 1571 | |
Vladimir Kondratiev | 9cf10d6 | 2014-09-10 16:34:36 +0300 | [diff] [blame] | 1572 | dev_dbg(dev, "%s()\n", __func__); |
| 1573 | |
Vladimir Kondratiev | 8fe5962 | 2014-09-10 16:34:34 +0300 | [diff] [blame] | 1574 | wdev = kzalloc(sizeof(*wdev), GFP_KERNEL); |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1575 | if (!wdev) |
| 1576 | return ERR_PTR(-ENOMEM); |
| 1577 | |
| 1578 | wdev->wiphy = wiphy_new(&wil_cfg80211_ops, |
| 1579 | sizeof(struct wil6210_priv)); |
| 1580 | if (!wdev->wiphy) { |
| 1581 | rc = -ENOMEM; |
| 1582 | goto out; |
| 1583 | } |
| 1584 | |
| 1585 | set_wiphy_dev(wdev->wiphy, dev); |
| 1586 | wil_wiphy_init(wdev->wiphy); |
| 1587 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1588 | return wdev; |
| 1589 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1590 | out: |
| 1591 | kfree(wdev); |
| 1592 | |
| 1593 | return ERR_PTR(rc); |
| 1594 | } |
| 1595 | |
| 1596 | void wil_wdev_free(struct wil6210_priv *wil) |
| 1597 | { |
| 1598 | struct wireless_dev *wdev = wil_to_wdev(wil); |
| 1599 | |
Vladimir Kondratiev | 9cf10d6 | 2014-09-10 16:34:36 +0300 | [diff] [blame] | 1600 | dev_dbg(wil_to_dev(wil), "%s()\n", __func__); |
| 1601 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1602 | if (!wdev) |
| 1603 | return; |
| 1604 | |
Vladimir Kondratiev | 2be7d22 | 2012-12-20 13:13:19 -0800 | [diff] [blame] | 1605 | wiphy_free(wdev->wiphy); |
| 1606 | kfree(wdev); |
| 1607 | } |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1608 | |
| 1609 | void wil_p2p_wdev_free(struct wil6210_priv *wil) |
| 1610 | { |
| 1611 | struct wireless_dev *p2p_wdev; |
| 1612 | |
| 1613 | mutex_lock(&wil->p2p_wdev_mutex); |
| 1614 | p2p_wdev = wil->p2p_wdev; |
Maya Erez | d35c2b6 | 2016-08-18 16:52:14 +0300 | [diff] [blame] | 1615 | wil->p2p_wdev = NULL; |
| 1616 | wil->radio_wdev = wil_to_wdev(wil); |
| 1617 | mutex_unlock(&wil->p2p_wdev_mutex); |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1618 | if (p2p_wdev) { |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1619 | cfg80211_unregister_wdev(p2p_wdev); |
| 1620 | kfree(p2p_wdev); |
| 1621 | } |
Lior David | 4332cac | 2016-03-01 19:18:13 +0200 | [diff] [blame] | 1622 | } |