Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1 | #include "wilc_wfi_cfgoperations.h" |
Arnd Bergmann | 491880e | 2015-11-16 15:04:55 +0100 | [diff] [blame] | 2 | #include "host_interface.h" |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3 | #include <linux/errno.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4 | |
Arnd Bergmann | 15162fb | 2015-11-16 15:04:57 +0100 | [diff] [blame] | 5 | #define NO_ENCRYPT 0 |
| 6 | #define ENCRYPT_ENABLED BIT(0) |
| 7 | #define WEP BIT(1) |
| 8 | #define WEP_EXTENDED BIT(2) |
| 9 | #define WPA BIT(3) |
| 10 | #define WPA2 BIT(4) |
| 11 | #define AES BIT(5) |
| 12 | #define TKIP BIT(6) |
| 13 | |
Arnd Bergmann | 15162fb | 2015-11-16 15:04:57 +0100 | [diff] [blame] | 14 | #define FRAME_TYPE_ID 0 |
| 15 | #define ACTION_CAT_ID 24 |
| 16 | #define ACTION_SUBTYPE_ID 25 |
| 17 | #define P2P_PUB_ACTION_SUBTYPE 30 |
| 18 | |
Arnd Bergmann | 15162fb | 2015-11-16 15:04:57 +0100 | [diff] [blame] | 19 | #define ACTION_FRAME 0xd0 |
| 20 | #define GO_INTENT_ATTR_ID 0x04 |
| 21 | #define CHANLIST_ATTR_ID 0x0b |
| 22 | #define OPERCHAN_ATTR_ID 0x11 |
| 23 | #define PUB_ACTION_ATTR_ID 0x04 |
| 24 | #define P2PELEM_ATTR_ID 0xdd |
| 25 | |
Arnd Bergmann | 15162fb | 2015-11-16 15:04:57 +0100 | [diff] [blame] | 26 | #define GO_NEG_REQ 0x00 |
| 27 | #define GO_NEG_RSP 0x01 |
| 28 | #define GO_NEG_CONF 0x02 |
| 29 | #define P2P_INV_REQ 0x03 |
| 30 | #define P2P_INV_RSP 0x04 |
| 31 | #define PUBLIC_ACT_VENDORSPEC 0x09 |
| 32 | #define GAS_INTIAL_REQ 0x0a |
| 33 | #define GAS_INTIAL_RSP 0x0b |
| 34 | |
| 35 | #define INVALID_CHANNEL 0 |
| 36 | |
| 37 | #define nl80211_SCAN_RESULT_EXPIRE (3 * HZ) |
| 38 | #define SCAN_RESULT_EXPIRE (40 * HZ) |
| 39 | |
| 40 | static const u32 cipher_suites[] = { |
| 41 | WLAN_CIPHER_SUITE_WEP40, |
| 42 | WLAN_CIPHER_SUITE_WEP104, |
| 43 | WLAN_CIPHER_SUITE_TKIP, |
| 44 | WLAN_CIPHER_SUITE_CCMP, |
| 45 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 46 | }; |
| 47 | |
| 48 | static const struct ieee80211_txrx_stypes |
| 49 | wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = { |
| 50 | [NL80211_IFTYPE_STATION] = { |
| 51 | .tx = 0xffff, |
| 52 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 53 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
| 54 | }, |
| 55 | [NL80211_IFTYPE_AP] = { |
| 56 | .tx = 0xffff, |
| 57 | .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | |
| 58 | BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | |
| 59 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | |
| 60 | BIT(IEEE80211_STYPE_DISASSOC >> 4) | |
| 61 | BIT(IEEE80211_STYPE_AUTH >> 4) | |
| 62 | BIT(IEEE80211_STYPE_DEAUTH >> 4) | |
| 63 | BIT(IEEE80211_STYPE_ACTION >> 4) |
| 64 | }, |
| 65 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 66 | .tx = 0xffff, |
| 67 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 68 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | |
| 69 | BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | |
| 70 | BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | |
| 71 | BIT(IEEE80211_STYPE_DISASSOC >> 4) | |
| 72 | BIT(IEEE80211_STYPE_AUTH >> 4) | |
| 73 | BIT(IEEE80211_STYPE_DEAUTH >> 4) |
| 74 | } |
| 75 | }; |
| 76 | |
Glen Lee | 73584a4 | 2016-01-25 16:35:10 +0900 | [diff] [blame] | 77 | static const struct wiphy_wowlan_support wowlan_support = { |
| 78 | .flags = WIPHY_WOWLAN_ANY |
| 79 | }; |
| 80 | |
Arnd Bergmann | 15162fb | 2015-11-16 15:04:57 +0100 | [diff] [blame] | 81 | #define WILC_WFI_DWELL_PASSIVE 100 |
| 82 | #define WILC_WFI_DWELL_ACTIVE 40 |
| 83 | |
| 84 | #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 |
| 85 | #define DEFAULT_LINK_SPEED 72 |
| 86 | |
| 87 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 88 | #define IS_MANAGMEMENT 0x100 |
| 89 | #define IS_MANAGMEMENT_CALLBACK 0x080 |
| 90 | #define IS_MGMT_STATUS_SUCCES 0x040 |
| 91 | #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) |
| 92 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 93 | extern int wilc_mac_open(struct net_device *ndev); |
| 94 | extern int wilc_mac_close(struct net_device *ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 95 | |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 96 | static struct network_info last_scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW]; |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 97 | static u32 last_scanned_cnt; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 98 | struct timer_list wilc_during_ip_timer; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 99 | static struct timer_list hAgingTimer; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 100 | static u8 op_ifcs; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 101 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 102 | u8 wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 103 | |
| 104 | #define CHAN2G(_channel, _freq, _flags) { \ |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 105 | .band = NL80211_BAND_2GHZ, \ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 106 | .center_freq = (_freq), \ |
| 107 | .hw_value = (_channel), \ |
| 108 | .flags = (_flags), \ |
| 109 | .max_antenna_gain = 0, \ |
| 110 | .max_power = 30, \ |
| 111 | } |
| 112 | |
Leo Kim | 2736f47 | 2015-11-19 15:56:12 +0900 | [diff] [blame] | 113 | static struct ieee80211_channel ieee80211_2ghz_channels[] = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 114 | CHAN2G(1, 2412, 0), |
| 115 | CHAN2G(2, 2417, 0), |
| 116 | CHAN2G(3, 2422, 0), |
| 117 | CHAN2G(4, 2427, 0), |
| 118 | CHAN2G(5, 2432, 0), |
| 119 | CHAN2G(6, 2437, 0), |
| 120 | CHAN2G(7, 2442, 0), |
| 121 | CHAN2G(8, 2447, 0), |
| 122 | CHAN2G(9, 2452, 0), |
| 123 | CHAN2G(10, 2457, 0), |
| 124 | CHAN2G(11, 2462, 0), |
| 125 | CHAN2G(12, 2467, 0), |
| 126 | CHAN2G(13, 2472, 0), |
| 127 | CHAN2G(14, 2484, 0), |
| 128 | }; |
| 129 | |
| 130 | #define RATETAB_ENT(_rate, _hw_value, _flags) { \ |
| 131 | .bitrate = (_rate), \ |
| 132 | .hw_value = (_hw_value), \ |
| 133 | .flags = (_flags), \ |
| 134 | } |
| 135 | |
Leo Kim | 8d48b5b | 2015-11-19 15:56:13 +0900 | [diff] [blame] | 136 | static struct ieee80211_rate ieee80211_bitrates[] = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 137 | RATETAB_ENT(10, 0, 0), |
| 138 | RATETAB_ENT(20, 1, 0), |
| 139 | RATETAB_ENT(55, 2, 0), |
| 140 | RATETAB_ENT(110, 3, 0), |
| 141 | RATETAB_ENT(60, 9, 0), |
| 142 | RATETAB_ENT(90, 6, 0), |
| 143 | RATETAB_ENT(120, 7, 0), |
| 144 | RATETAB_ENT(180, 8, 0), |
| 145 | RATETAB_ENT(240, 9, 0), |
| 146 | RATETAB_ENT(360, 10, 0), |
| 147 | RATETAB_ENT(480, 11, 0), |
| 148 | RATETAB_ENT(540, 12, 0), |
| 149 | }; |
| 150 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 151 | struct p2p_mgmt_data { |
| 152 | int size; |
| 153 | u8 *buff; |
| 154 | }; |
| 155 | |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 156 | static u8 wlan_channel = INVALID_CHANNEL; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 157 | static u8 curr_channel; |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 158 | static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09}; |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 159 | static u8 p2p_local_random = 0x01; |
Eva Rachel Retuya | d38f5ba | 2016-02-15 13:34:17 +0800 | [diff] [blame] | 160 | static u8 p2p_recv_random; |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 161 | static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 162 | static bool wilc_ie; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 163 | |
| 164 | static struct ieee80211_supported_band WILC_WFI_band_2ghz = { |
Leo Kim | 2736f47 | 2015-11-19 15:56:12 +0900 | [diff] [blame] | 165 | .channels = ieee80211_2ghz_channels, |
| 166 | .n_channels = ARRAY_SIZE(ieee80211_2ghz_channels), |
Leo Kim | 8d48b5b | 2015-11-19 15:56:13 +0900 | [diff] [blame] | 167 | .bitrates = ieee80211_bitrates, |
| 168 | .n_bitrates = ARRAY_SIZE(ieee80211_bitrates), |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 169 | }; |
| 170 | |
| 171 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 172 | struct add_key_params { |
| 173 | u8 key_idx; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 174 | bool pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 175 | u8 *mac_addr; |
| 176 | }; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 177 | static struct add_key_params g_add_gtk_key_params; |
| 178 | static struct wilc_wfi_key g_key_gtk_params; |
| 179 | static struct add_key_params g_add_ptk_key_params; |
| 180 | static struct wilc_wfi_key g_key_ptk_params; |
| 181 | static struct wilc_wfi_wep_key g_key_wep_params; |
| 182 | static bool g_ptk_keys_saved; |
| 183 | static bool g_gtk_keys_saved; |
| 184 | static bool g_wep_keys_saved; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 185 | |
| 186 | #define AGING_TIME (9 * 1000) |
Leo Kim | 7e872df | 2015-11-19 15:56:20 +0900 | [diff] [blame] | 187 | #define during_ip_time 15000 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 188 | |
Leo Kim | d14991a | 2015-11-19 15:56:22 +0900 | [diff] [blame] | 189 | static void clear_shadow_scan(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 190 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 191 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 192 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 193 | if (op_ifcs == 0) { |
Greg Kroah-Hartman | 4183e97 | 2015-08-14 20:11:16 -0700 | [diff] [blame] | 194 | del_timer_sync(&hAgingTimer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 195 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 196 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | 390b6db | 2016-02-04 18:24:23 +0900 | [diff] [blame] | 197 | if (last_scanned_shadow[last_scanned_cnt].ies) { |
| 198 | kfree(last_scanned_shadow[i].ies); |
| 199 | last_scanned_shadow[last_scanned_cnt].ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 200 | } |
| 201 | |
Leo Kim | cb64de7 | 2016-02-04 18:24:24 +0900 | [diff] [blame] | 202 | kfree(last_scanned_shadow[i].join_params); |
| 203 | last_scanned_shadow[i].join_params = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 204 | } |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 205 | last_scanned_cnt = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 206 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 207 | } |
| 208 | |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 209 | static u32 get_rssi_avg(struct network_info *network_info) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 210 | { |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 211 | u8 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 212 | int rssi_v = 0; |
Leo Kim | f2050a1 | 2016-02-04 18:24:25 +0900 | [diff] [blame] | 213 | u8 num_rssi = (network_info->str_rssi.u8Full) ? |
| 214 | NUM_RSSI : (network_info->str_rssi.u8Index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 215 | |
| 216 | for (i = 0; i < num_rssi; i++) |
Leo Kim | f2050a1 | 2016-02-04 18:24:25 +0900 | [diff] [blame] | 217 | rssi_v += network_info->str_rssi.as8RSSI[i]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 218 | |
| 219 | rssi_v /= num_rssi; |
| 220 | return rssi_v; |
| 221 | } |
| 222 | |
Leo Kim | 48ee7ba | 2015-11-19 15:56:24 +0900 | [diff] [blame] | 223 | static void refresh_scan(void *user_void, u8 all, bool direct_scan) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 224 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 225 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 226 | struct wiphy *wiphy; |
| 227 | struct cfg80211_bss *bss = NULL; |
| 228 | int i; |
| 229 | int rssi = 0; |
| 230 | |
Alison Schofield | 4375cad | 2016-02-12 22:54:08 -0800 | [diff] [blame] | 231 | priv = user_void; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 232 | wiphy = priv->dev->ieee80211_ptr->wiphy; |
| 233 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 234 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 235 | struct network_info *network_info; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 236 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 237 | network_info = &last_scanned_shadow[i]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 238 | |
Leo Kim | a35d6e2d | 2016-02-04 18:24:21 +0900 | [diff] [blame] | 239 | if (!network_info->found || all) { |
Leo Kim | c6f5e3a | 2015-11-19 15:56:26 +0900 | [diff] [blame] | 240 | s32 freq; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 241 | struct ieee80211_channel *channel; |
| 242 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 243 | if (network_info) { |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 244 | freq = ieee80211_channel_to_frequency((s32)network_info->ch, NL80211_BAND_2GHZ); |
Leo Kim | c6f5e3a | 2015-11-19 15:56:26 +0900 | [diff] [blame] | 245 | channel = ieee80211_get_channel(wiphy, freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 246 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 247 | rssi = get_rssi_avg(network_info); |
Leo Kim | 2a3ff58 | 2016-02-04 18:24:13 +0900 | [diff] [blame] | 248 | if (memcmp("DIRECT-", network_info->ssid, 7) || |
Leo Kim | 48ee7ba | 2015-11-19 15:56:24 +0900 | [diff] [blame] | 249 | direct_scan) { |
Leo Kim | fa5e2d1 | 2016-02-04 18:24:12 +0900 | [diff] [blame] | 250 | bss = cfg80211_inform_bss(wiphy, |
| 251 | channel, |
| 252 | CFG80211_BSS_FTYPE_UNKNOWN, |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 253 | network_info->bssid, |
Leo Kim | 17d2f2b | 2016-02-04 18:24:26 +0900 | [diff] [blame] | 254 | network_info->tsf_hi, |
Leo Kim | fa5e2d1 | 2016-02-04 18:24:12 +0900 | [diff] [blame] | 255 | network_info->cap_info, |
Leo Kim | 4b313e9 | 2016-02-04 18:24:16 +0900 | [diff] [blame] | 256 | network_info->beacon_period, |
Leo Kim | 390b6db | 2016-02-04 18:24:23 +0900 | [diff] [blame] | 257 | (const u8 *)network_info->ies, |
| 258 | (size_t)network_info->ies_len, |
Leo Kim | fa5e2d1 | 2016-02-04 18:24:12 +0900 | [diff] [blame] | 259 | (s32)rssi * 100, |
| 260 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 261 | cfg80211_put_bss(wiphy, bss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 262 | } |
| 263 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 264 | } |
| 265 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 266 | } |
| 267 | |
Leo Kim | 12b0138 | 2015-11-19 15:56:27 +0900 | [diff] [blame] | 268 | static void reset_shadow_found(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 269 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 270 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 271 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 272 | for (i = 0; i < last_scanned_cnt; i++) |
Leo Kim | a35d6e2d | 2016-02-04 18:24:21 +0900 | [diff] [blame] | 273 | last_scanned_shadow[i].found = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 274 | } |
| 275 | |
Leo Kim | 5e51d8b | 2015-11-19 15:56:28 +0900 | [diff] [blame] | 276 | static void update_scan_time(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 277 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 278 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 279 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 280 | for (i = 0; i < last_scanned_cnt; i++) |
Leo Kim | 264d70f | 2016-02-04 18:24:19 +0900 | [diff] [blame] | 281 | last_scanned_shadow[i].time_scan = jiffies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 282 | } |
| 283 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 284 | static void remove_network_from_shadow(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 285 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 286 | unsigned long now = jiffies; |
| 287 | int i, j; |
| 288 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 289 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 290 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | 264d70f | 2016-02-04 18:24:19 +0900 | [diff] [blame] | 291 | if (time_after(now, last_scanned_shadow[i].time_scan + |
| 292 | (unsigned long)(SCAN_RESULT_EXPIRE))) { |
Leo Kim | 390b6db | 2016-02-04 18:24:23 +0900 | [diff] [blame] | 293 | kfree(last_scanned_shadow[i].ies); |
| 294 | last_scanned_shadow[i].ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 295 | |
Leo Kim | cb64de7 | 2016-02-04 18:24:24 +0900 | [diff] [blame] | 296 | kfree(last_scanned_shadow[i].join_params); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 297 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 298 | for (j = i; (j < last_scanned_cnt - 1); j++) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 299 | last_scanned_shadow[j] = last_scanned_shadow[j + 1]; |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 300 | |
| 301 | last_scanned_cnt--; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 302 | } |
| 303 | } |
| 304 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 305 | if (last_scanned_cnt != 0) { |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 306 | hAgingTimer.data = arg; |
| 307 | mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 308 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 309 | } |
| 310 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 311 | static void clear_duringIP(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 312 | { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 313 | wilc_optaining_ip = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 314 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 315 | |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 316 | static int is_network_in_shadow(struct network_info *pstrNetworkInfo, |
Leo Kim | 157814f | 2015-11-19 15:56:29 +0900 | [diff] [blame] | 317 | void *user_void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 318 | { |
Chaehyun Lim | a74cc6b | 2015-10-02 16:41:17 +0900 | [diff] [blame] | 319 | int state = -1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 320 | int i; |
| 321 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 322 | if (last_scanned_cnt == 0) { |
Leo Kim | 157814f | 2015-11-19 15:56:29 +0900 | [diff] [blame] | 323 | hAgingTimer.data = (unsigned long)user_void; |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 324 | mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 325 | state = -1; |
| 326 | } else { |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 327 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 328 | if (memcmp(last_scanned_shadow[i].bssid, |
| 329 | pstrNetworkInfo->bssid, 6) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 330 | state = i; |
| 331 | break; |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | return state; |
| 336 | } |
| 337 | |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 338 | static void add_network_to_shadow(struct network_info *pstrNetworkInfo, |
Leo Kim | 5c4cf0d | 2015-11-19 15:56:30 +0900 | [diff] [blame] | 339 | void *user_void, void *pJoinParams) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 340 | { |
Leo Kim | 5c4cf0d | 2015-11-19 15:56:30 +0900 | [diff] [blame] | 341 | int ap_found = is_network_in_shadow(pstrNetworkInfo, user_void); |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 342 | u32 ap_index = 0; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 343 | u8 rssi_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 344 | |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 345 | if (last_scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 346 | return; |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 347 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 348 | if (ap_found == -1) { |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 349 | ap_index = last_scanned_cnt; |
| 350 | last_scanned_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 351 | } else { |
| 352 | ap_index = ap_found; |
| 353 | } |
Leo Kim | f2050a1 | 2016-02-04 18:24:25 +0900 | [diff] [blame] | 354 | rssi_index = last_scanned_shadow[ap_index].str_rssi.u8Index; |
| 355 | last_scanned_shadow[ap_index].str_rssi.as8RSSI[rssi_index++] = pstrNetworkInfo->rssi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 356 | if (rssi_index == NUM_RSSI) { |
| 357 | rssi_index = 0; |
Leo Kim | f2050a1 | 2016-02-04 18:24:25 +0900 | [diff] [blame] | 358 | last_scanned_shadow[ap_index].str_rssi.u8Full = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 359 | } |
Leo Kim | f2050a1 | 2016-02-04 18:24:25 +0900 | [diff] [blame] | 360 | last_scanned_shadow[ap_index].str_rssi.u8Index = rssi_index; |
Leo Kim | 5c23a29 | 2016-02-04 18:24:11 +0900 | [diff] [blame] | 361 | last_scanned_shadow[ap_index].rssi = pstrNetworkInfo->rssi; |
Leo Kim | fa5e2d1 | 2016-02-04 18:24:12 +0900 | [diff] [blame] | 362 | last_scanned_shadow[ap_index].cap_info = pstrNetworkInfo->cap_info; |
Leo Kim | a36e89e | 2016-02-04 18:24:14 +0900 | [diff] [blame] | 363 | last_scanned_shadow[ap_index].ssid_len = pstrNetworkInfo->ssid_len; |
Leo Kim | 2a3ff58 | 2016-02-04 18:24:13 +0900 | [diff] [blame] | 364 | memcpy(last_scanned_shadow[ap_index].ssid, |
Leo Kim | a36e89e | 2016-02-04 18:24:14 +0900 | [diff] [blame] | 365 | pstrNetworkInfo->ssid, pstrNetworkInfo->ssid_len); |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 366 | memcpy(last_scanned_shadow[ap_index].bssid, |
| 367 | pstrNetworkInfo->bssid, ETH_ALEN); |
Leo Kim | 4b313e9 | 2016-02-04 18:24:16 +0900 | [diff] [blame] | 368 | last_scanned_shadow[ap_index].beacon_period = pstrNetworkInfo->beacon_period; |
Leo Kim | df340fd | 2016-02-04 18:24:17 +0900 | [diff] [blame] | 369 | last_scanned_shadow[ap_index].dtim_period = pstrNetworkInfo->dtim_period; |
Leo Kim | 405a8c7 | 2016-02-04 18:24:18 +0900 | [diff] [blame] | 370 | last_scanned_shadow[ap_index].ch = pstrNetworkInfo->ch; |
Leo Kim | 390b6db | 2016-02-04 18:24:23 +0900 | [diff] [blame] | 371 | last_scanned_shadow[ap_index].ies_len = pstrNetworkInfo->ies_len; |
Leo Kim | 17d2f2b | 2016-02-04 18:24:26 +0900 | [diff] [blame] | 372 | last_scanned_shadow[ap_index].tsf_hi = pstrNetworkInfo->tsf_hi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 373 | if (ap_found != -1) |
Leo Kim | 390b6db | 2016-02-04 18:24:23 +0900 | [diff] [blame] | 374 | kfree(last_scanned_shadow[ap_index].ies); |
| 375 | last_scanned_shadow[ap_index].ies = kmalloc(pstrNetworkInfo->ies_len, |
| 376 | GFP_KERNEL); |
| 377 | memcpy(last_scanned_shadow[ap_index].ies, |
| 378 | pstrNetworkInfo->ies, pstrNetworkInfo->ies_len); |
Leo Kim | 264d70f | 2016-02-04 18:24:19 +0900 | [diff] [blame] | 379 | last_scanned_shadow[ap_index].time_scan = jiffies; |
| 380 | last_scanned_shadow[ap_index].time_scan_cached = jiffies; |
Leo Kim | a35d6e2d | 2016-02-04 18:24:21 +0900 | [diff] [blame] | 381 | last_scanned_shadow[ap_index].found = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 382 | if (ap_found != -1) |
Leo Kim | cb64de7 | 2016-02-04 18:24:24 +0900 | [diff] [blame] | 383 | kfree(last_scanned_shadow[ap_index].join_params); |
| 384 | last_scanned_shadow[ap_index].join_params = pJoinParams; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 385 | } |
| 386 | |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 387 | static void CfgScanResult(enum scan_event scan_event, |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 388 | struct network_info *network_info, |
Leo Kim | 30cd10c | 2015-11-19 15:56:33 +0900 | [diff] [blame] | 389 | void *user_void, |
Leo Kim | bdd3460 | 2015-11-19 15:56:34 +0900 | [diff] [blame] | 390 | void *join_params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 391 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 392 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 393 | struct wiphy *wiphy; |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 394 | s32 s32Freq; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 395 | struct ieee80211_channel *channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 396 | struct cfg80211_bss *bss = NULL; |
| 397 | |
Alison Schofield | 4375cad | 2016-02-12 22:54:08 -0800 | [diff] [blame] | 398 | priv = user_void; |
Luis de Bethencourt | 7e4e87d | 2015-10-16 16:32:26 +0100 | [diff] [blame] | 399 | if (priv->bCfgScanning) { |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 400 | if (scan_event == SCAN_EVENT_NETWORK_FOUND) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 401 | wiphy = priv->dev->ieee80211_ptr->wiphy; |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 402 | |
| 403 | if (!wiphy) |
| 404 | return; |
| 405 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 406 | if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC && |
Leo Kim | 5c23a29 | 2016-02-04 18:24:11 +0900 | [diff] [blame] | 407 | (((s32)network_info->rssi * 100) < 0 || |
| 408 | ((s32)network_info->rssi * 100) > 100)) |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 409 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 410 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 411 | if (network_info) { |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 412 | s32Freq = ieee80211_channel_to_frequency((s32)network_info->ch, NL80211_BAND_2GHZ); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 413 | channel = ieee80211_get_channel(wiphy, s32Freq); |
| 414 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 415 | if (!channel) |
| 416 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 417 | |
Leo Kim | d402076 | 2016-02-04 18:24:20 +0900 | [diff] [blame] | 418 | if (network_info->new_network) { |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 419 | if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 420 | priv->u32RcvdChCount++; |
| 421 | |
Leo Kim | bdd3460 | 2015-11-19 15:56:34 +0900 | [diff] [blame] | 422 | add_network_to_shadow(network_info, priv, join_params); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 423 | |
Leo Kim | 2a3ff58 | 2016-02-04 18:24:13 +0900 | [diff] [blame] | 424 | if (!(memcmp("DIRECT-", network_info->ssid, 7))) { |
Leo Kim | fa5e2d1 | 2016-02-04 18:24:12 +0900 | [diff] [blame] | 425 | bss = cfg80211_inform_bss(wiphy, |
| 426 | channel, |
| 427 | CFG80211_BSS_FTYPE_UNKNOWN, |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 428 | network_info->bssid, |
Leo Kim | 17d2f2b | 2016-02-04 18:24:26 +0900 | [diff] [blame] | 429 | network_info->tsf_hi, |
Leo Kim | fa5e2d1 | 2016-02-04 18:24:12 +0900 | [diff] [blame] | 430 | network_info->cap_info, |
Leo Kim | 4b313e9 | 2016-02-04 18:24:16 +0900 | [diff] [blame] | 431 | network_info->beacon_period, |
Leo Kim | 390b6db | 2016-02-04 18:24:23 +0900 | [diff] [blame] | 432 | (const u8 *)network_info->ies, |
| 433 | (size_t)network_info->ies_len, |
Leo Kim | fa5e2d1 | 2016-02-04 18:24:12 +0900 | [diff] [blame] | 434 | (s32)network_info->rssi * 100, |
| 435 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 436 | cfg80211_put_bss(wiphy, bss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 437 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 438 | } |
| 439 | } else { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 440 | u32 i; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 441 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 442 | for (i = 0; i < priv->u32RcvdChCount; i++) { |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 443 | if (memcmp(last_scanned_shadow[i].bssid, network_info->bssid, 6) == 0) { |
Leo Kim | 5c23a29 | 2016-02-04 18:24:11 +0900 | [diff] [blame] | 444 | last_scanned_shadow[i].rssi = network_info->rssi; |
Leo Kim | 264d70f | 2016-02-04 18:24:19 +0900 | [diff] [blame] | 445 | last_scanned_shadow[i].time_scan = jiffies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 446 | break; |
| 447 | } |
| 448 | } |
| 449 | } |
| 450 | } |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 451 | } else if (scan_event == SCAN_EVENT_DONE) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 452 | refresh_scan(priv, 1, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 453 | |
Chaehyun Lim | 0866209 | 2016-03-28 13:56:00 +0900 | [diff] [blame] | 454 | mutex_lock(&priv->scan_req_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 455 | |
Leo Kim | 369a1d3 | 2015-12-21 14:18:23 +0900 | [diff] [blame] | 456 | if (priv->pstrScanReq) { |
Avraham Stern | 1d76250 | 2016-07-05 17:10:13 +0300 | [diff] [blame] | 457 | struct cfg80211_scan_info info = { |
| 458 | .aborted = false, |
| 459 | }; |
| 460 | |
| 461 | cfg80211_scan_done(priv->pstrScanReq, &info); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 462 | priv->u32RcvdChCount = 0; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 463 | priv->bCfgScanning = false; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 464 | priv->pstrScanReq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 465 | } |
Chaehyun Lim | 0866209 | 2016-03-28 13:56:00 +0900 | [diff] [blame] | 466 | mutex_unlock(&priv->scan_req_lock); |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 467 | } else if (scan_event == SCAN_EVENT_ABORTED) { |
Chaehyun Lim | 0866209 | 2016-03-28 13:56:00 +0900 | [diff] [blame] | 468 | mutex_lock(&priv->scan_req_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 469 | |
Leo Kim | 369a1d3 | 2015-12-21 14:18:23 +0900 | [diff] [blame] | 470 | if (priv->pstrScanReq) { |
Avraham Stern | 1d76250 | 2016-07-05 17:10:13 +0300 | [diff] [blame] | 471 | struct cfg80211_scan_info info = { |
| 472 | .aborted = false, |
| 473 | }; |
| 474 | |
Leo Kim | 5e51d8b | 2015-11-19 15:56:28 +0900 | [diff] [blame] | 475 | update_scan_time(); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 476 | refresh_scan(priv, 1, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 477 | |
Avraham Stern | 1d76250 | 2016-07-05 17:10:13 +0300 | [diff] [blame] | 478 | cfg80211_scan_done(priv->pstrScanReq, &info); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 479 | priv->bCfgScanning = false; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 480 | priv->pstrScanReq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 481 | } |
Chaehyun Lim | 0866209 | 2016-03-28 13:56:00 +0900 | [diff] [blame] | 482 | mutex_unlock(&priv->scan_req_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 483 | } |
| 484 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 485 | } |
| 486 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 487 | int wilc_connecting; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 488 | |
Leo Kim | ed3f037 | 2015-10-12 16:56:01 +0900 | [diff] [blame] | 489 | static void CfgConnectResult(enum conn_event enuConnDisconnEvent, |
Chaehyun Lim | 3b0437e | 2016-02-25 09:15:42 +0900 | [diff] [blame] | 490 | struct connect_info *pstrConnectInfo, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 491 | u8 u8MacStatus, |
Chaehyun Lim | bb76df5 | 2016-02-25 09:15:49 +0900 | [diff] [blame] | 492 | struct disconnect_info *pstrDisconnectNotifInfo, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 493 | void *pUserVoid) |
| 494 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 495 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 496 | struct net_device *dev; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 497 | struct host_if_drv *pstrWFIDrv; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 498 | u8 NullBssid[ETH_ALEN] = {0}; |
Glen Lee | c1ec2c1 | 2015-10-20 17:13:58 +0900 | [diff] [blame] | 499 | struct wilc *wl; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 500 | struct wilc_vif *vif; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 501 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 502 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 503 | |
Alison Schofield | 4375cad | 2016-02-12 22:54:08 -0800 | [diff] [blame] | 504 | priv = pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 505 | dev = priv->dev; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 506 | vif = netdev_priv(dev); |
| 507 | wl = vif->wilc; |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 508 | pstrWFIDrv = (struct host_if_drv *)priv->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 509 | |
| 510 | if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) { |
Amitoj Kaur Chawla | baba7c7 | 2015-10-15 13:48:29 +0530 | [diff] [blame] | 511 | u16 u16ConnectStatus; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 512 | |
Chaehyun Lim | 134b4cf | 2016-02-25 09:15:48 +0900 | [diff] [blame] | 513 | u16ConnectStatus = pstrConnectInfo->status; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 514 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 515 | if ((u8MacStatus == MAC_DISCONNECTED) && |
Chaehyun Lim | 134b4cf | 2016-02-25 09:15:48 +0900 | [diff] [blame] | 516 | (pstrConnectInfo->status == SUCCESSFUL_STATUSCODE)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 517 | u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE; |
Glen Lee | ba615f1 | 2016-01-25 16:35:15 +0900 | [diff] [blame] | 518 | wilc_wlan_set_bssid(priv->dev, NullBssid, |
| 519 | STATION_MODE); |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 520 | eth_zero_addr(wilc_connected_ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 521 | |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 522 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 523 | wlan_channel = INVALID_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 524 | |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 525 | netdev_err(dev, "Unspecified failure\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | if (u16ConnectStatus == WLAN_STATUS_SUCCESS) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 529 | bool bNeedScanRefresh = false; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 530 | u32 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 531 | |
Chaehyun Lim | d4a24e0 | 2016-02-25 09:15:43 +0900 | [diff] [blame] | 532 | memcpy(priv->au8AssociatedBss, pstrConnectInfo->bssid, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 533 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 534 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 535 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 536 | if (memcmp(last_scanned_shadow[i].bssid, |
Chaehyun Lim | d4a24e0 | 2016-02-25 09:15:43 +0900 | [diff] [blame] | 537 | pstrConnectInfo->bssid, |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 538 | ETH_ALEN) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 539 | unsigned long now = jiffies; |
| 540 | |
| 541 | if (time_after(now, |
Leo Kim | 264d70f | 2016-02-04 18:24:19 +0900 | [diff] [blame] | 542 | last_scanned_shadow[i].time_scan_cached + |
| 543 | (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 544 | bNeedScanRefresh = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 545 | |
| 546 | break; |
| 547 | } |
| 548 | } |
| 549 | |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 550 | if (bNeedScanRefresh) |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 551 | refresh_scan(priv, 1, true); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 552 | } |
| 553 | |
Chaehyun Lim | d4a24e0 | 2016-02-25 09:15:43 +0900 | [diff] [blame] | 554 | cfg80211_connect_result(dev, pstrConnectInfo->bssid, |
Chaehyun Lim | 4607f9c | 2016-02-25 09:15:45 +0900 | [diff] [blame] | 555 | pstrConnectInfo->req_ies, pstrConnectInfo->req_ies_len, |
Chaehyun Lim | 3e7477c | 2016-02-25 09:15:47 +0900 | [diff] [blame] | 556 | pstrConnectInfo->resp_ies, pstrConnectInfo->resp_ies_len, |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 557 | u16ConnectStatus, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 558 | } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 559 | wilc_optaining_ip = false; |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 560 | p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 561 | p2p_recv_random = 0x00; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 562 | wilc_ie = false; |
Shraddha Barke | bcf0265 | 2015-10-05 17:00:32 +0530 | [diff] [blame] | 563 | eth_zero_addr(priv->au8AssociatedBss); |
Glen Lee | ba615f1 | 2016-01-25 16:35:15 +0900 | [diff] [blame] | 564 | wilc_wlan_set_bssid(priv->dev, NullBssid, STATION_MODE); |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 565 | eth_zero_addr(wilc_connected_ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 566 | |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 567 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 568 | wlan_channel = INVALID_CHANNEL; |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 569 | if ((pstrWFIDrv->IFC_UP) && (dev == wl->vif[1]->ndev)) |
Chaehyun Lim | 90f209d | 2016-02-25 09:15:50 +0900 | [diff] [blame] | 570 | pstrDisconnectNotifInfo->reason = 3; |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 571 | else if ((!pstrWFIDrv->IFC_UP) && (dev == wl->vif[1]->ndev)) |
Chaehyun Lim | 90f209d | 2016-02-25 09:15:50 +0900 | [diff] [blame] | 572 | pstrDisconnectNotifInfo->reason = 1; |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 573 | |
Chaehyun Lim | 90f209d | 2016-02-25 09:15:50 +0900 | [diff] [blame] | 574 | cfg80211_disconnected(dev, pstrDisconnectNotifInfo->reason, pstrDisconnectNotifInfo->ie, |
Sudip Mukherjee | e26bb71 | 2015-06-30 13:51:51 +0530 | [diff] [blame] | 575 | pstrDisconnectNotifInfo->ie_len, false, |
| 576 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 577 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 578 | } |
| 579 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 580 | static int set_channel(struct wiphy *wiphy, |
| 581 | struct cfg80211_chan_def *chandef) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 582 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 583 | u32 channelnum = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 584 | struct wilc_priv *priv; |
Chaehyun Lim | dd739ea | 2015-10-02 16:41:20 +0900 | [diff] [blame] | 585 | int result = 0; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 586 | struct wilc_vif *vif; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 587 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 588 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 589 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 590 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 591 | channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 592 | |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 593 | curr_channel = channelnum; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 594 | result = wilc_set_mac_chnl_num(vif, channelnum); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 595 | |
Chaehyun Lim | dd739ea | 2015-10-02 16:41:20 +0900 | [diff] [blame] | 596 | if (result != 0) |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 597 | netdev_err(priv->dev, "Error in setting channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 598 | |
Chaehyun Lim | dd739ea | 2015-10-02 16:41:20 +0900 | [diff] [blame] | 599 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 600 | } |
| 601 | |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 602 | static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 603 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 604 | struct wilc_priv *priv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 605 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 606 | s32 s32Error = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 607 | u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS]; |
Leo Kim | 607db44 | 2015-10-05 15:25:37 +0900 | [diff] [blame] | 608 | struct hidden_network strHiddenNetwork; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 609 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 610 | |
| 611 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 612 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 613 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 614 | priv->pstrScanReq = request; |
| 615 | |
| 616 | priv->u32RcvdChCount = 0; |
| 617 | |
Leo Kim | 12b0138 | 2015-11-19 15:56:27 +0900 | [diff] [blame] | 618 | reset_shadow_found(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 619 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 620 | priv->bCfgScanning = true; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 621 | if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 622 | for (i = 0; i < request->n_channels; i++) |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 623 | au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 624 | |
| 625 | if (request->n_ssids >= 1) { |
Janani Ravichandran | 8459af6 | 2016-02-16 17:27:03 -0500 | [diff] [blame] | 626 | strHiddenNetwork.net_info = |
| 627 | kmalloc_array(request->n_ssids, |
| 628 | sizeof(struct hidden_network), |
| 629 | GFP_KERNEL); |
Leo Kim | 396fa30 | 2016-02-22 13:11:50 +0900 | [diff] [blame] | 630 | if (!strHiddenNetwork.net_info) |
| 631 | return -ENOMEM; |
Chaehyun Lim | 40e05e8 | 2016-01-05 13:26:33 +0900 | [diff] [blame] | 632 | strHiddenNetwork.n_ssids = request->n_ssids; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 633 | |
| 634 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 635 | for (i = 0; i < request->n_ssids; i++) { |
Luis de Bethencourt | 4562d22 | 2016-06-23 18:57:09 +0100 | [diff] [blame] | 636 | if (request->ssids[i].ssid_len != 0) { |
Chaehyun Lim | 245a186 | 2016-01-05 13:26:32 +0900 | [diff] [blame] | 637 | strHiddenNetwork.net_info[i].ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL); |
| 638 | memcpy(strHiddenNetwork.net_info[i].ssid, request->ssids[i].ssid, request->ssids[i].ssid_len); |
| 639 | strHiddenNetwork.net_info[i].ssid_len = request->ssids[i].ssid_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 640 | } else { |
Chaehyun Lim | 40e05e8 | 2016-01-05 13:26:33 +0900 | [diff] [blame] | 641 | strHiddenNetwork.n_ssids -= 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 642 | } |
| 643 | } |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 644 | s32Error = wilc_scan(vif, USER_SCAN, ACTIVE_SCAN, |
| 645 | au8ScanChanList, |
| 646 | request->n_channels, |
| 647 | (const u8 *)request->ie, |
| 648 | request->ie_len, CfgScanResult, |
| 649 | (void *)priv, &strHiddenNetwork); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 650 | } else { |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 651 | s32Error = wilc_scan(vif, USER_SCAN, ACTIVE_SCAN, |
| 652 | au8ScanChanList, |
| 653 | request->n_channels, |
| 654 | (const u8 *)request->ie, |
| 655 | request->ie_len, CfgScanResult, |
| 656 | (void *)priv, NULL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 657 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 658 | } else { |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 659 | netdev_err(priv->dev, "Requested scanned channels over\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 660 | } |
| 661 | |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 662 | if (s32Error != 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 663 | s32Error = -EBUSY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 664 | |
| 665 | return s32Error; |
| 666 | } |
| 667 | |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 668 | static int connect(struct wiphy *wiphy, struct net_device *dev, |
| 669 | struct cfg80211_connect_params *sme) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 670 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 671 | s32 s32Error = 0; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 672 | u32 i; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 673 | u8 u8security = NO_ENCRYPT; |
Leo Kim | 841dfc4 | 2015-10-05 15:25:39 +0900 | [diff] [blame] | 674 | enum AUTHTYPE tenuAuth_type = ANY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 675 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 676 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 677 | struct host_if_drv *pstrWFIDrv; |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 678 | struct network_info *pstrNetworkInfo = NULL; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 679 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 680 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 681 | wilc_connecting = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 682 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 683 | vif = netdev_priv(priv->dev); |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 684 | pstrWFIDrv = (struct host_if_drv *)priv->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 685 | |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 686 | if (!(strncmp(sme->ssid, "DIRECT-", 7))) |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 687 | pstrWFIDrv->p2p_connect = 1; |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 688 | else |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 689 | pstrWFIDrv->p2p_connect = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 690 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 691 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | a36e89e | 2016-02-04 18:24:14 +0900 | [diff] [blame] | 692 | if ((sme->ssid_len == last_scanned_shadow[i].ssid_len) && |
Leo Kim | 2a3ff58 | 2016-02-04 18:24:13 +0900 | [diff] [blame] | 693 | memcmp(last_scanned_shadow[i].ssid, |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 694 | sme->ssid, |
| 695 | sme->ssid_len) == 0) { |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 696 | if (!sme->bssid) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 697 | break; |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 698 | else |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 699 | if (memcmp(last_scanned_shadow[i].bssid, |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 700 | sme->bssid, |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 701 | ETH_ALEN) == 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 702 | break; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 703 | } |
| 704 | } |
| 705 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 706 | if (i < last_scanned_cnt) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 707 | pstrNetworkInfo = &last_scanned_shadow[i]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 708 | } else { |
| 709 | s32Error = -ENOENT; |
Glen Lee | 430e640 | 2016-02-04 18:15:21 +0900 | [diff] [blame] | 710 | wilc_connecting = 0; |
| 711 | return s32Error; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 712 | } |
| 713 | |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 714 | memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key)); |
| 715 | memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 716 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 717 | if (sme->crypto.cipher_group != NO_ENCRYPT) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 718 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 719 | u8security = ENCRYPT_ENABLED | WEP; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 720 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 721 | priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 722 | memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 723 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 724 | g_key_wep_params.key_len = sme->key_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 725 | g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 726 | memcpy(g_key_wep_params.key, sme->key, sme->key_len); |
| 727 | g_key_wep_params.key_idx = sme->key_idx; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 728 | g_wep_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 729 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 730 | wilc_set_wep_default_keyid(vif, sme->key_idx); |
| 731 | wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len, |
| 732 | sme->key_idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 733 | } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 734 | u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 735 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 736 | priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 737 | memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 738 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 739 | g_key_wep_params.key_len = sme->key_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 740 | g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 741 | memcpy(g_key_wep_params.key, sme->key, sme->key_len); |
| 742 | g_key_wep_params.key_idx = sme->key_idx; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 743 | g_wep_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 744 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 745 | wilc_set_wep_default_keyid(vif, sme->key_idx); |
| 746 | wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len, |
| 747 | sme->key_idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 748 | } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 749 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 750 | u8security = ENCRYPT_ENABLED | WPA2 | TKIP; |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 751 | else |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 752 | u8security = ENCRYPT_ENABLED | WPA2 | AES; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 753 | } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) { |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 754 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 755 | u8security = ENCRYPT_ENABLED | WPA | TKIP; |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 756 | else |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 757 | u8security = ENCRYPT_ENABLED | WPA | AES; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 758 | } else { |
| 759 | s32Error = -ENOTSUPP; |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 760 | netdev_err(dev, "Not supported cipher\n"); |
Glen Lee | 430e640 | 2016-02-04 18:15:21 +0900 | [diff] [blame] | 761 | wilc_connecting = 0; |
| 762 | return s32Error; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 763 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 764 | } |
| 765 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 766 | if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) |
| 767 | || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) { |
| 768 | for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) { |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 769 | if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 770 | u8security = u8security | TKIP; |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 771 | else |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 772 | u8security = u8security | AES; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 773 | } |
| 774 | } |
| 775 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 776 | switch (sme->auth_type) { |
| 777 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 778 | tenuAuth_type = OPEN_SYSTEM; |
| 779 | break; |
| 780 | |
| 781 | case NL80211_AUTHTYPE_SHARED_KEY: |
| 782 | tenuAuth_type = SHARED_KEY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 783 | break; |
| 784 | |
| 785 | default: |
Chris Park | 40bbaac | 2016-02-22 13:11:58 +0900 | [diff] [blame] | 786 | break; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 787 | } |
| 788 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 789 | if (sme->crypto.n_akm_suites) { |
| 790 | switch (sme->crypto.akm_suites[0]) { |
| 791 | case WLAN_AKM_SUITE_8021X: |
| 792 | tenuAuth_type = IEEE8021; |
| 793 | break; |
| 794 | |
| 795 | default: |
| 796 | break; |
| 797 | } |
| 798 | } |
| 799 | |
Leo Kim | 405a8c7 | 2016-02-04 18:24:18 +0900 | [diff] [blame] | 800 | curr_channel = pstrNetworkInfo->ch; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 801 | |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 802 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 405a8c7 | 2016-02-04 18:24:18 +0900 | [diff] [blame] | 803 | wlan_channel = pstrNetworkInfo->ch; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 804 | |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 805 | wilc_wlan_set_bssid(dev, pstrNetworkInfo->bssid, STATION_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 806 | |
Leo Kim | 38d3bb7 | 2016-02-04 18:24:15 +0900 | [diff] [blame] | 807 | s32Error = wilc_set_join_req(vif, pstrNetworkInfo->bssid, sme->ssid, |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 808 | sme->ssid_len, sme->ie, sme->ie_len, |
| 809 | CfgConnectResult, (void *)priv, |
| 810 | u8security, tenuAuth_type, |
Leo Kim | 405a8c7 | 2016-02-04 18:24:18 +0900 | [diff] [blame] | 811 | pstrNetworkInfo->ch, |
Leo Kim | cb64de7 | 2016-02-04 18:24:24 +0900 | [diff] [blame] | 812 | pstrNetworkInfo->join_params); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 813 | if (s32Error != 0) { |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 814 | netdev_err(dev, "wilc_set_join_req(): Error\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 815 | s32Error = -ENOENT; |
Glen Lee | 430e640 | 2016-02-04 18:15:21 +0900 | [diff] [blame] | 816 | wilc_connecting = 0; |
| 817 | return s32Error; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 818 | } |
| 819 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 820 | return s32Error; |
| 821 | } |
| 822 | |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 823 | static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 824 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 825 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 826 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 827 | struct host_if_drv *pstrWFIDrv; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 828 | struct wilc_vif *vif; |
Leo Kim | 8006109 | 2016-04-01 17:44:18 +0900 | [diff] [blame] | 829 | struct wilc *wilc; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 830 | u8 NullBssid[ETH_ALEN] = {0}; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 831 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 832 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 833 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 834 | vif = netdev_priv(priv->dev); |
Leo Kim | 8006109 | 2016-04-01 17:44:18 +0900 | [diff] [blame] | 835 | wilc = vif->wilc; |
| 836 | |
| 837 | if (!wilc) |
| 838 | return -EIO; |
| 839 | |
| 840 | if (wilc->close) { |
| 841 | /* already disconnected done */ |
| 842 | cfg80211_disconnected(dev, 0, NULL, 0, true, GFP_KERNEL); |
| 843 | return 0; |
| 844 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 845 | |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 846 | pstrWFIDrv = (struct host_if_drv *)priv->hif_drv; |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 847 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 848 | wlan_channel = INVALID_CHANNEL; |
Glen Lee | ba615f1 | 2016-01-25 16:35:15 +0900 | [diff] [blame] | 849 | wilc_wlan_set_bssid(priv->dev, NullBssid, STATION_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 850 | |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 851 | p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 852 | p2p_recv_random = 0x00; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 853 | wilc_ie = false; |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 854 | pstrWFIDrv->p2p_timeout = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 855 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 856 | s32Error = wilc_disconnect(vif, reason_code); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 857 | if (s32Error != 0) { |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 858 | netdev_err(priv->dev, "Error in disconnecting\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 859 | s32Error = -EINVAL; |
| 860 | } |
| 861 | |
| 862 | return s32Error; |
| 863 | } |
| 864 | |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 865 | static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 866 | bool pairwise, |
| 867 | const u8 *mac_addr, struct key_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 868 | |
| 869 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 870 | s32 s32Error = 0, KeyLen = params->key_len; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 871 | struct wilc_priv *priv; |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 872 | const u8 *pu8RxMic = NULL; |
| 873 | const u8 *pu8TxMic = NULL; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 874 | u8 u8mode = NO_ENCRYPT; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 875 | u8 u8gmode = NO_ENCRYPT; |
| 876 | u8 u8pmode = NO_ENCRYPT; |
Leo Kim | 841dfc4 | 2015-10-05 15:25:39 +0900 | [diff] [blame] | 877 | enum AUTHTYPE tenuAuth_type = ANY; |
Glen Lee | 7646920 | 2015-10-20 17:13:59 +0900 | [diff] [blame] | 878 | struct wilc *wl; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 879 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 880 | |
| 881 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 882 | vif = netdev_priv(netdev); |
| 883 | wl = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 884 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 885 | switch (params->cipher) { |
| 886 | case WLAN_CIPHER_SUITE_WEP40: |
| 887 | case WLAN_CIPHER_SUITE_WEP104: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 888 | if (priv->wdev->iftype == NL80211_IFTYPE_AP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 889 | priv->WILC_WFI_wep_key_len[key_index] = params->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 890 | memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 891 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 892 | tenuAuth_type = OPEN_SYSTEM; |
| 893 | |
| 894 | if (params->cipher == WLAN_CIPHER_SUITE_WEP40) |
| 895 | u8mode = ENCRYPT_ENABLED | WEP; |
| 896 | else |
| 897 | u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; |
| 898 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 899 | wilc_add_wep_key_bss_ap(vif, params->key, |
| 900 | params->key_len, key_index, |
| 901 | u8mode, tenuAuth_type); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 902 | break; |
| 903 | } |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 904 | if (memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 905 | priv->WILC_WFI_wep_key_len[key_index] = params->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 906 | memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 907 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 908 | wilc_add_wep_key_bss_sta(vif, params->key, |
| 909 | params->key_len, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | break; |
| 913 | |
| 914 | case WLAN_CIPHER_SUITE_TKIP: |
| 915 | case WLAN_CIPHER_SUITE_CCMP: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 916 | if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) { |
Leo Kim | 369a1d3 | 2015-12-21 14:18:23 +0900 | [diff] [blame] | 917 | if (!priv->wilc_gtk[key_index]) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 918 | priv->wilc_gtk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 919 | priv->wilc_gtk[key_index]->key = NULL; |
| 920 | priv->wilc_gtk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 921 | } |
Leo Kim | 369a1d3 | 2015-12-21 14:18:23 +0900 | [diff] [blame] | 922 | if (!priv->wilc_ptk[key_index]) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 923 | priv->wilc_ptk[key_index] = kmalloc(sizeof(struct wilc_wfi_key), GFP_KERNEL); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 924 | priv->wilc_ptk[key_index]->key = NULL; |
| 925 | priv->wilc_ptk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | |
| 929 | |
Daniel Machon | 1913221 | 2015-08-05 08:18:31 +0200 | [diff] [blame] | 930 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 931 | if (params->cipher == WLAN_CIPHER_SUITE_TKIP) |
| 932 | u8gmode = ENCRYPT_ENABLED | WPA | TKIP; |
| 933 | else |
| 934 | u8gmode = ENCRYPT_ENABLED | WPA2 | AES; |
| 935 | |
| 936 | priv->wilc_groupkey = u8gmode; |
| 937 | |
| 938 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 939 | pu8TxMic = params->key + 24; |
| 940 | pu8RxMic = params->key + 16; |
| 941 | KeyLen = params->key_len - 16; |
| 942 | } |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 943 | kfree(priv->wilc_gtk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 944 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 945 | priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 946 | memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len); |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 947 | kfree(priv->wilc_gtk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 948 | |
| 949 | if ((params->seq_len) > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 950 | priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 951 | memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | priv->wilc_gtk[key_index]->cipher = params->cipher; |
| 955 | priv->wilc_gtk[key_index]->key_len = params->key_len; |
| 956 | priv->wilc_gtk[key_index]->seq_len = params->seq_len; |
| 957 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 958 | wilc_add_rx_gtk(vif, params->key, KeyLen, |
| 959 | key_index, params->seq_len, |
| 960 | params->seq, pu8RxMic, |
| 961 | pu8TxMic, AP_MODE, u8gmode); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 962 | |
| 963 | } else { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 964 | if (params->cipher == WLAN_CIPHER_SUITE_TKIP) |
| 965 | u8pmode = ENCRYPT_ENABLED | WPA | TKIP; |
| 966 | else |
| 967 | u8pmode = priv->wilc_groupkey | AES; |
| 968 | |
| 969 | |
| 970 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 971 | pu8TxMic = params->key + 24; |
| 972 | pu8RxMic = params->key + 16; |
| 973 | KeyLen = params->key_len - 16; |
| 974 | } |
| 975 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 976 | kfree(priv->wilc_ptk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 977 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 978 | priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 979 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 980 | kfree(priv->wilc_ptk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 981 | |
| 982 | if ((params->seq_len) > 0) |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 983 | priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 984 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 985 | memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 986 | |
| 987 | if ((params->seq_len) > 0) |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 988 | memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 989 | |
| 990 | priv->wilc_ptk[key_index]->cipher = params->cipher; |
| 991 | priv->wilc_ptk[key_index]->key_len = params->key_len; |
| 992 | priv->wilc_ptk[key_index]->seq_len = params->seq_len; |
| 993 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 994 | wilc_add_ptk(vif, params->key, KeyLen, |
| 995 | mac_addr, pu8RxMic, pu8TxMic, |
| 996 | AP_MODE, u8pmode, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 997 | } |
| 998 | break; |
| 999 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1000 | |
| 1001 | { |
| 1002 | u8mode = 0; |
Daniel Machon | 1913221 | 2015-08-05 08:18:31 +0200 | [diff] [blame] | 1003 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1004 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1005 | pu8RxMic = params->key + 24; |
| 1006 | pu8TxMic = params->key + 16; |
| 1007 | KeyLen = params->key_len - 16; |
| 1008 | } |
| 1009 | |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1010 | if (!g_gtk_keys_saved && netdev == wl->vif[0]->ndev) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1011 | g_add_gtk_key_params.key_idx = key_index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1012 | g_add_gtk_key_params.pairwise = pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1013 | if (!mac_addr) { |
| 1014 | g_add_gtk_key_params.mac_addr = NULL; |
| 1015 | } else { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1016 | g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1017 | memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN); |
| 1018 | } |
| 1019 | g_key_gtk_params.key_len = params->key_len; |
| 1020 | g_key_gtk_params.seq_len = params->seq_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1021 | g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1022 | memcpy(g_key_gtk_params.key, params->key, params->key_len); |
| 1023 | if (params->seq_len > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1024 | g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1025 | memcpy(g_key_gtk_params.seq, params->seq, params->seq_len); |
| 1026 | } |
| 1027 | g_key_gtk_params.cipher = params->cipher; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1028 | g_gtk_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1029 | } |
| 1030 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1031 | wilc_add_rx_gtk(vif, params->key, KeyLen, |
| 1032 | key_index, params->seq_len, |
| 1033 | params->seq, pu8RxMic, |
| 1034 | pu8TxMic, STATION_MODE, |
| 1035 | u8mode); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1036 | } else { |
| 1037 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1038 | pu8RxMic = params->key + 24; |
| 1039 | pu8TxMic = params->key + 16; |
| 1040 | KeyLen = params->key_len - 16; |
| 1041 | } |
| 1042 | |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1043 | if (!g_ptk_keys_saved && netdev == wl->vif[0]->ndev) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1044 | g_add_ptk_key_params.key_idx = key_index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1045 | g_add_ptk_key_params.pairwise = pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1046 | if (!mac_addr) { |
| 1047 | g_add_ptk_key_params.mac_addr = NULL; |
| 1048 | } else { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1049 | g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1050 | memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN); |
| 1051 | } |
| 1052 | g_key_ptk_params.key_len = params->key_len; |
| 1053 | g_key_ptk_params.seq_len = params->seq_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1054 | g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1055 | memcpy(g_key_ptk_params.key, params->key, params->key_len); |
| 1056 | if (params->seq_len > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1057 | g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1058 | memcpy(g_key_ptk_params.seq, params->seq, params->seq_len); |
| 1059 | } |
| 1060 | g_key_ptk_params.cipher = params->cipher; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1061 | g_ptk_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1062 | } |
| 1063 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1064 | wilc_add_ptk(vif, params->key, KeyLen, |
| 1065 | mac_addr, pu8RxMic, pu8TxMic, |
| 1066 | STATION_MODE, u8mode, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1067 | } |
| 1068 | } |
| 1069 | break; |
| 1070 | |
| 1071 | default: |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1072 | netdev_err(netdev, "Not supported cipher\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1073 | s32Error = -ENOTSUPP; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | return s32Error; |
| 1077 | } |
| 1078 | |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 1079 | static int del_key(struct wiphy *wiphy, struct net_device *netdev, |
| 1080 | u8 key_index, |
| 1081 | bool pairwise, |
| 1082 | const u8 *mac_addr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1083 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1084 | struct wilc_priv *priv; |
Glen Lee | 692e2ac | 2015-10-20 17:14:00 +0900 | [diff] [blame] | 1085 | struct wilc *wl; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1086 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1087 | |
| 1088 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1089 | vif = netdev_priv(netdev); |
| 1090 | wl = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1091 | |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1092 | if (netdev == wl->vif[0]->ndev) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1093 | g_ptk_keys_saved = false; |
| 1094 | g_gtk_keys_saved = false; |
| 1095 | g_wep_keys_saved = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1096 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1097 | kfree(g_key_wep_params.key); |
| 1098 | g_key_wep_params.key = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1099 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1100 | if ((priv->wilc_gtk[key_index]) != NULL) { |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1101 | kfree(priv->wilc_gtk[key_index]->key); |
| 1102 | priv->wilc_gtk[key_index]->key = NULL; |
| 1103 | kfree(priv->wilc_gtk[key_index]->seq); |
| 1104 | priv->wilc_gtk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1105 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1106 | kfree(priv->wilc_gtk[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1107 | priv->wilc_gtk[key_index] = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1108 | } |
| 1109 | |
| 1110 | if ((priv->wilc_ptk[key_index]) != NULL) { |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1111 | kfree(priv->wilc_ptk[key_index]->key); |
| 1112 | priv->wilc_ptk[key_index]->key = NULL; |
| 1113 | kfree(priv->wilc_ptk[key_index]->seq); |
| 1114 | priv->wilc_ptk[key_index]->seq = NULL; |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1115 | kfree(priv->wilc_ptk[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1116 | priv->wilc_ptk[key_index] = NULL; |
| 1117 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1118 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1119 | kfree(g_key_ptk_params.key); |
| 1120 | g_key_ptk_params.key = NULL; |
| 1121 | kfree(g_key_ptk_params.seq); |
| 1122 | g_key_ptk_params.seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1123 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1124 | kfree(g_key_gtk_params.key); |
| 1125 | g_key_gtk_params.key = NULL; |
| 1126 | kfree(g_key_gtk_params.seq); |
| 1127 | g_key_gtk_params.seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1128 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1129 | } |
| 1130 | |
| 1131 | if (key_index >= 0 && key_index <= 3) { |
Leo Kim | b0f1836 | 2016-04-01 17:44:19 +0900 | [diff] [blame] | 1132 | if (priv->WILC_WFI_wep_key_len[key_index]) { |
| 1133 | memset(priv->WILC_WFI_wep_key[key_index], 0, |
| 1134 | priv->WILC_WFI_wep_key_len[key_index]); |
| 1135 | priv->WILC_WFI_wep_key_len[key_index] = 0; |
| 1136 | wilc_remove_wep_key(vif, key_index); |
| 1137 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1138 | } else { |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 1139 | wilc_remove_key(priv->hif_drv, mac_addr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1140 | } |
| 1141 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1142 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1143 | } |
| 1144 | |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 1145 | static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1146 | bool pairwise, |
| 1147 | const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1148 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1149 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1150 | struct key_params key_params; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1151 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1152 | priv = wiphy_priv(wiphy); |
| 1153 | |
| 1154 | |
Alison Schofield | 3604af5 | 2015-10-12 13:22:44 -0700 | [diff] [blame] | 1155 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1156 | key_params.key = priv->wilc_gtk[key_index]->key; |
| 1157 | key_params.cipher = priv->wilc_gtk[key_index]->cipher; |
| 1158 | key_params.key_len = priv->wilc_gtk[key_index]->key_len; |
| 1159 | key_params.seq = priv->wilc_gtk[key_index]->seq; |
| 1160 | key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1161 | } else { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1162 | key_params.key = priv->wilc_ptk[key_index]->key; |
| 1163 | key_params.cipher = priv->wilc_ptk[key_index]->cipher; |
| 1164 | key_params.key_len = priv->wilc_ptk[key_index]->key_len; |
| 1165 | key_params.seq = priv->wilc_ptk[key_index]->seq; |
| 1166 | key_params.seq_len = priv->wilc_ptk[key_index]->seq_len; |
| 1167 | } |
| 1168 | |
| 1169 | callback(cookie, &key_params); |
| 1170 | |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 1171 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1172 | } |
| 1173 | |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 1174 | static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1175 | bool unicast, bool multicast) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1176 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1177 | struct wilc_priv *priv; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1178 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1179 | |
| 1180 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1181 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1182 | |
Glen Lee | ec45048 | 2016-02-04 18:15:28 +0900 | [diff] [blame] | 1183 | wilc_set_wep_default_keyid(vif, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1184 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1185 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1186 | } |
| 1187 | |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 1188 | static int get_station(struct wiphy *wiphy, struct net_device *dev, |
| 1189 | const u8 *mac, struct station_info *sinfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1190 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1191 | struct wilc_priv *priv; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1192 | struct wilc_vif *vif; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1193 | u32 i = 0; |
Colin Ian King | 6c08fda | 2016-08-15 17:09:52 +0100 | [diff] [blame] | 1194 | u32 associatedsta = ~0; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1195 | u32 inactive_time = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1196 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1197 | vif = netdev_priv(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1198 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1199 | if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1200 | for (i = 0; i < NUM_STA_ASSOCIATED; i++) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1201 | if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) { |
| 1202 | associatedsta = i; |
| 1203 | break; |
| 1204 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1205 | } |
| 1206 | |
Colin Ian King | 6c08fda | 2016-08-15 17:09:52 +0100 | [diff] [blame] | 1207 | if (associatedsta == ~0) { |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1208 | netdev_err(dev, "sta required is not associated\n"); |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1209 | return -ENOENT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1210 | } |
| 1211 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1212 | sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1213 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1214 | wilc_get_inactive_time(vif, mac, &inactive_time); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1215 | sinfo->inactive_time = 1000 * inactive_time; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1216 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1217 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1218 | if (vif->iftype == STATION_MODE) { |
Leo Kim | 03e7b9c | 2015-10-12 16:55:58 +0900 | [diff] [blame] | 1219 | struct rf_info strStatistics; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1220 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1221 | wilc_get_statistics(vif, &strStatistics); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1222 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1223 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) | |
Chandra S Gorentla | 6212990 | 2015-08-05 22:11:57 +0530 | [diff] [blame] | 1224 | BIT(NL80211_STA_INFO_RX_PACKETS) | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1225 | BIT(NL80211_STA_INFO_TX_PACKETS) | |
| 1226 | BIT(NL80211_STA_INFO_TX_FAILED) | |
| 1227 | BIT(NL80211_STA_INFO_TX_BITRATE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1228 | |
Leo Kim | 00c8dfc | 2015-10-29 12:05:30 +0900 | [diff] [blame] | 1229 | sinfo->signal = strStatistics.rssi; |
Leo Kim | 9b99274 | 2015-10-29 12:05:32 +0900 | [diff] [blame] | 1230 | sinfo->rx_packets = strStatistics.rx_cnt; |
Leo Kim | 5416037 | 2015-10-29 12:05:33 +0900 | [diff] [blame] | 1231 | sinfo->tx_packets = strStatistics.tx_cnt + strStatistics.tx_fail_cnt; |
| 1232 | sinfo->tx_failed = strStatistics.tx_fail_cnt; |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1233 | sinfo->txrate.legacy = strStatistics.link_speed * 10; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1234 | |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1235 | if ((strStatistics.link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && |
| 1236 | (strStatistics.link_speed != DEFAULT_LINK_SPEED)) |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1237 | wilc_enable_tcp_ack_filter(true); |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1238 | else if (strStatistics.link_speed != DEFAULT_LINK_SPEED) |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1239 | wilc_enable_tcp_ack_filter(false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1240 | } |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1241 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1242 | } |
| 1243 | |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 1244 | static int change_bss(struct wiphy *wiphy, struct net_device *dev, |
| 1245 | struct bss_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1246 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1247 | return 0; |
| 1248 | } |
| 1249 | |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 1250 | static int set_wiphy_params(struct wiphy *wiphy, u32 changed) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1251 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1252 | s32 s32Error = 0; |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 1253 | struct cfg_param_attr pstrCfgParamVal; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1254 | struct wilc_priv *priv; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1255 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1256 | |
| 1257 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1258 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1259 | |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1260 | pstrCfgParamVal.flag = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1261 | |
| 1262 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1263 | pstrCfgParamVal.flag |= RETRY_SHORT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1264 | pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short; |
| 1265 | } |
| 1266 | if (changed & WIPHY_PARAM_RETRY_LONG) { |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1267 | pstrCfgParamVal.flag |= RETRY_LONG; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1268 | pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1269 | } |
| 1270 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1271 | pstrCfgParamVal.flag |= FRAG_THRESHOLD; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1272 | pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1273 | } |
| 1274 | |
| 1275 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1276 | pstrCfgParamVal.flag |= RTS_THRESHOLD; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1277 | pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1278 | } |
| 1279 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1280 | s32Error = wilc_hif_set_cfg(vif, &pstrCfgParamVal); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1281 | if (s32Error) |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1282 | netdev_err(priv->dev, "Error in setting WIPHY PARAMS\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1283 | |
| 1284 | return s32Error; |
| 1285 | } |
Arnd Bergmann | e5af056 | 2015-05-29 22:52:12 +0200 | [diff] [blame] | 1286 | |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 1287 | static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, |
| 1288 | struct cfg80211_pmksa *pmksa) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1289 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1290 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1291 | s32 s32Error = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1292 | u8 flag = 0; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1293 | struct wilc_vif *vif; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1294 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1295 | |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1296 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1297 | |
| 1298 | |
| 1299 | for (i = 0; i < priv->pmkid_list.numpmkid; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1300 | if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1301 | ETH_ALEN)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1302 | flag = PMKID_FOUND; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1303 | break; |
| 1304 | } |
| 1305 | } |
| 1306 | if (i < WILC_MAX_NUM_PMKIDS) { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1307 | memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1308 | ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1309 | memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1310 | PMKID_LEN); |
| 1311 | if (!(flag == PMKID_FOUND)) |
| 1312 | priv->pmkid_list.numpmkid++; |
| 1313 | } else { |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1314 | netdev_err(netdev, "Invalid PMKID index\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1315 | s32Error = -EINVAL; |
| 1316 | } |
| 1317 | |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 1318 | if (!s32Error) |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1319 | s32Error = wilc_set_pmkid_info(vif, &priv->pmkid_list); |
Chris Park | 64d3546 | 2016-02-22 13:11:57 +0900 | [diff] [blame] | 1320 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1321 | return s32Error; |
| 1322 | } |
| 1323 | |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 1324 | static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, |
| 1325 | struct cfg80211_pmksa *pmksa) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1326 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1327 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1328 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1329 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1330 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1331 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1332 | for (i = 0; i < priv->pmkid_list.numpmkid; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1333 | if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1334 | ETH_ALEN)) { |
Leo Kim | cd1e6cb | 2015-10-05 15:25:45 +0900 | [diff] [blame] | 1335 | memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1336 | break; |
| 1337 | } |
| 1338 | } |
| 1339 | |
| 1340 | if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) { |
| 1341 | for (; i < (priv->pmkid_list.numpmkid - 1); i++) { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1342 | memcpy(priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1343 | priv->pmkid_list.pmkidlist[i + 1].bssid, |
| 1344 | ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1345 | memcpy(priv->pmkid_list.pmkidlist[i].pmkid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1346 | priv->pmkid_list.pmkidlist[i].pmkid, |
| 1347 | PMKID_LEN); |
| 1348 | } |
| 1349 | priv->pmkid_list.numpmkid--; |
| 1350 | } else { |
| 1351 | s32Error = -EINVAL; |
| 1352 | } |
| 1353 | |
| 1354 | return s32Error; |
| 1355 | } |
| 1356 | |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 1357 | static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1358 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1359 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1360 | |
Leo Kim | a949f90 | 2015-10-05 15:25:44 +0900 | [diff] [blame] | 1361 | memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1362 | |
| 1363 | return 0; |
| 1364 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1365 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 1366 | static void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1367 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1368 | u32 index = 0; |
| 1369 | u32 i = 0, j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1370 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1371 | u8 op_channel_attr_index = 0; |
| 1372 | u8 channel_list_attr_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1373 | |
| 1374 | while (index < len) { |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 1375 | if (buf[index] == GO_INTENT_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1376 | buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1377 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1378 | if (buf[index] == CHANLIST_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1379 | channel_list_attr_index = index; |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1380 | else if (buf[index] == OPERCHAN_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1381 | op_channel_attr_index = index; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 1382 | index += buf[index + 1] + 3; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1383 | } |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1384 | if (wlan_channel != INVALID_CHANNEL) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1385 | if (channel_list_attr_index) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1386 | for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { |
| 1387 | if (buf[i] == 0x51) { |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 1388 | for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1389 | buf[j] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1390 | break; |
| 1391 | } |
| 1392 | } |
| 1393 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 1394 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1395 | if (op_channel_attr_index) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1396 | buf[op_channel_attr_index + 6] = 0x51; |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1397 | buf[op_channel_attr_index + 7] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1398 | } |
| 1399 | } |
| 1400 | } |
| 1401 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 1402 | static void WILC_WFI_CfgParseTxAction(u8 *buf, u32 len, bool bOperChan, u8 iftype) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1403 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1404 | u32 index = 0; |
| 1405 | u32 i = 0, j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1406 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1407 | u8 op_channel_attr_index = 0; |
| 1408 | u8 channel_list_attr_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1409 | |
| 1410 | while (index < len) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1411 | if (buf[index] == GO_INTENT_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1412 | buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1413 | |
| 1414 | break; |
| 1415 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1416 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1417 | if (buf[index] == CHANLIST_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1418 | channel_list_attr_index = index; |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1419 | else if (buf[index] == OPERCHAN_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1420 | op_channel_attr_index = index; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 1421 | index += buf[index + 1] + 3; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1422 | } |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1423 | if (wlan_channel != INVALID_CHANNEL && bOperChan) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1424 | if (channel_list_attr_index) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1425 | for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { |
| 1426 | if (buf[i] == 0x51) { |
Roger H. Newell | d5e27e8 | 2016-03-19 12:49:21 -0230 | [diff] [blame] | 1427 | for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1428 | buf[j] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1429 | break; |
| 1430 | } |
| 1431 | } |
| 1432 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 1433 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1434 | if (op_channel_attr_index) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1435 | buf[op_channel_attr_index + 6] = 0x51; |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1436 | buf[op_channel_attr_index + 7] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1437 | } |
| 1438 | } |
| 1439 | } |
| 1440 | |
Anchal Jain | 63f8035 | 2016-03-02 21:12:19 +0530 | [diff] [blame] | 1441 | void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1442 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1443 | struct wilc_priv *priv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1444 | u32 header, pkt_offset; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1445 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1446 | u32 i = 0; |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 1447 | s32 s32Freq; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1448 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1449 | priv = wiphy_priv(dev->ieee80211_ptr->wiphy); |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 1450 | pstrWFIDrv = (struct host_if_drv *)priv->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1451 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1452 | memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1453 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1454 | pkt_offset = GET_PKT_OFFSET(header); |
| 1455 | |
| 1456 | if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { |
| 1457 | if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1458 | cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1459 | return; |
| 1460 | } else { |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1461 | if (pkt_offset & IS_MGMT_STATUS_SUCCES) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1462 | cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL); |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1463 | else |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1464 | cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1465 | return; |
| 1466 | } |
| 1467 | } else { |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 1468 | s32Freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1469 | |
| 1470 | if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1471 | if (priv->bCfgScanning && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->p2p_timeout)) { |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1472 | netdev_dbg(dev, "Receiving action wrong ch\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1473 | return; |
| 1474 | } |
| 1475 | if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1476 | switch (buff[ACTION_SUBTYPE_ID]) { |
| 1477 | case GAS_INTIAL_REQ: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1478 | break; |
| 1479 | |
| 1480 | case GAS_INTIAL_RSP: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1481 | break; |
| 1482 | |
| 1483 | case PUBLIC_ACT_VENDORSPEC: |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 1484 | if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1485 | if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) { |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 1486 | if (!wilc_ie) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1487 | for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 1488 | if (!memcmp(p2p_vendor_spec, &buff[i], 6)) { |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1489 | p2p_recv_random = buff[i + 6]; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 1490 | wilc_ie = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1491 | break; |
| 1492 | } |
| 1493 | } |
| 1494 | } |
| 1495 | } |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1496 | if (p2p_local_random > p2p_recv_random) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1497 | if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP |
| 1498 | || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) { |
| 1499 | for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) { |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 1500 | if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(p2p_oui, &buff[i + 2], 4))) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1501 | WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6)); |
| 1502 | break; |
| 1503 | } |
| 1504 | } |
| 1505 | } |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 1506 | } else { |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1507 | netdev_dbg(dev, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random, p2p_recv_random); |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 1508 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1509 | } |
| 1510 | |
| 1511 | |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 1512 | if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (wilc_ie)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1513 | cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1514 | return; |
| 1515 | } |
| 1516 | break; |
| 1517 | |
| 1518 | default: |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1519 | netdev_dbg(dev, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1520 | break; |
| 1521 | } |
| 1522 | } |
| 1523 | } |
| 1524 | |
Glen Lee | 783d07c | 2016-02-04 18:15:26 +0900 | [diff] [blame] | 1525 | cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1526 | } |
| 1527 | } |
| 1528 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1529 | static void WILC_WFI_mgmt_tx_complete(void *priv, int status) |
| 1530 | { |
Alison Schofield | 4375cad | 2016-02-12 22:54:08 -0800 | [diff] [blame] | 1531 | struct p2p_mgmt_data *pv_data = priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1532 | |
| 1533 | |
| 1534 | kfree(pv_data->buff); |
| 1535 | kfree(pv_data); |
| 1536 | } |
| 1537 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1538 | static void WILC_WFI_RemainOnChannelReady(void *pUserVoid) |
| 1539 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1540 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1541 | |
Alison Schofield | 4375cad | 2016-02-12 22:54:08 -0800 | [diff] [blame] | 1542 | priv = pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1543 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1544 | priv->bInP2PlistenState = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1545 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1546 | cfg80211_ready_on_channel(priv->wdev, |
| 1547 | priv->strRemainOnChanParams.u64ListenCookie, |
| 1548 | priv->strRemainOnChanParams.pstrListenChan, |
| 1549 | priv->strRemainOnChanParams.u32ListenDuration, |
| 1550 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1551 | } |
| 1552 | |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1553 | static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1554 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1555 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1556 | |
Alison Schofield | 4375cad | 2016-02-12 22:54:08 -0800 | [diff] [blame] | 1557 | priv = pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1558 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1559 | if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1560 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1561 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1562 | cfg80211_remain_on_channel_expired(priv->wdev, |
| 1563 | priv->strRemainOnChanParams.u64ListenCookie, |
| 1564 | priv->strRemainOnChanParams.pstrListenChan, |
| 1565 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1566 | } |
| 1567 | } |
| 1568 | |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 1569 | static int remain_on_channel(struct wiphy *wiphy, |
| 1570 | struct wireless_dev *wdev, |
| 1571 | struct ieee80211_channel *chan, |
| 1572 | unsigned int duration, u64 *cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1573 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1574 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1575 | struct wilc_priv *priv; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1576 | struct wilc_vif *vif; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1577 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1578 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1579 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1580 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1581 | if (wdev->iftype == NL80211_IFTYPE_AP) { |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1582 | netdev_dbg(vif->ndev, "Required while in AP mode\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1583 | return s32Error; |
| 1584 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1585 | |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 1586 | curr_channel = chan->hw_value; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1587 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1588 | priv->strRemainOnChanParams.pstrListenChan = chan; |
| 1589 | priv->strRemainOnChanParams.u64ListenCookie = *cookie; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1590 | priv->strRemainOnChanParams.u32ListenDuration = duration; |
| 1591 | priv->strRemainOnChanParams.u32ListenSessionID++; |
| 1592 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1593 | s32Error = wilc_remain_on_channel(vif, |
| 1594 | priv->strRemainOnChanParams.u32ListenSessionID, |
| 1595 | duration, chan->hw_value, |
| 1596 | WILC_WFI_RemainOnChannelExpired, |
| 1597 | WILC_WFI_RemainOnChannelReady, (void *)priv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1598 | |
| 1599 | return s32Error; |
| 1600 | } |
| 1601 | |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 1602 | static int cancel_remain_on_channel(struct wiphy *wiphy, |
| 1603 | struct wireless_dev *wdev, |
| 1604 | u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1605 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1606 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1607 | struct wilc_priv *priv; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1608 | struct wilc_vif *vif; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1609 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1610 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1611 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1612 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1613 | s32Error = wilc_listen_state_expired(vif, priv->strRemainOnChanParams.u32ListenSessionID); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1614 | return s32Error; |
| 1615 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 1616 | |
Chaehyun Lim | c156032 | 2015-09-22 18:34:51 +0900 | [diff] [blame] | 1617 | static int mgmt_tx(struct wiphy *wiphy, |
| 1618 | struct wireless_dev *wdev, |
| 1619 | struct cfg80211_mgmt_tx_params *params, |
| 1620 | u64 *cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1621 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1622 | struct ieee80211_channel *chan = params->chan; |
| 1623 | unsigned int wait = params->wait; |
| 1624 | const u8 *buf = params->buf; |
| 1625 | size_t len = params->len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1626 | const struct ieee80211_mgmt *mgmt; |
| 1627 | struct p2p_mgmt_data *mgmt_tx; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1628 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1629 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1630 | u32 i; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1631 | struct wilc_vif *vif; |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 1632 | u32 buf_len = len + sizeof(p2p_vendor_spec) + sizeof(p2p_local_random); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1633 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1634 | vif = netdev_priv(wdev->netdev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1635 | priv = wiphy_priv(wiphy); |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 1636 | pstrWFIDrv = (struct host_if_drv *)priv->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1637 | |
| 1638 | *cookie = (unsigned long)buf; |
| 1639 | priv->u64tx_cookie = *cookie; |
| 1640 | mgmt = (const struct ieee80211_mgmt *) buf; |
| 1641 | |
| 1642 | if (ieee80211_is_mgmt(mgmt->frame_control)) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1643 | mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL); |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1644 | if (!mgmt_tx) |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1645 | return -EFAULT; |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1646 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1647 | mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL); |
Dan Carpenter | d99ee28 | 2016-02-10 12:05:40 +0300 | [diff] [blame] | 1648 | if (!mgmt_tx->buff) { |
Tony Cho | f638dd3 | 2015-09-07 19:09:31 +0900 | [diff] [blame] | 1649 | kfree(mgmt_tx); |
Dan Carpenter | d99ee28 | 2016-02-10 12:05:40 +0300 | [diff] [blame] | 1650 | return -ENOMEM; |
| 1651 | } |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1652 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1653 | memcpy(mgmt_tx->buff, buf, len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1654 | mgmt_tx->size = len; |
| 1655 | |
| 1656 | |
| 1657 | if (ieee80211_is_probe_resp(mgmt->frame_control)) { |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1658 | wilc_set_mac_chnl_num(vif, chan->hw_value); |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 1659 | curr_channel = chan->hw_value; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1660 | } else if (ieee80211_is_action(mgmt->frame_control)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1661 | if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1662 | if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC || |
| 1663 | buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) { |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1664 | wilc_set_mac_chnl_num(vif, |
| 1665 | chan->hw_value); |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 1666 | curr_channel = chan->hw_value; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1667 | } |
| 1668 | switch (buf[ACTION_SUBTYPE_ID]) { |
| 1669 | case GAS_INTIAL_REQ: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1670 | break; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1671 | |
| 1672 | case GAS_INTIAL_RSP: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1673 | break; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1674 | |
| 1675 | case PUBLIC_ACT_VENDORSPEC: |
| 1676 | { |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 1677 | if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1678 | if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) { |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1679 | if (p2p_local_random == 1 && p2p_recv_random < p2p_local_random) { |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 1680 | get_random_bytes(&p2p_local_random, 1); |
| 1681 | p2p_local_random++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1682 | } |
| 1683 | } |
| 1684 | |
| 1685 | if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP |
| 1686 | || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) { |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1687 | if (p2p_local_random > p2p_recv_random) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1688 | for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) { |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 1689 | if (buf[i] == P2PELEM_ATTR_ID && !(memcmp(p2p_oui, &buf[i + 2], 4))) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1690 | if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP) |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1691 | WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, vif->iftype); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1692 | else |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1693 | WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, vif->iftype); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1694 | break; |
| 1695 | } |
| 1696 | } |
| 1697 | |
| 1698 | if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) { |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 1699 | memcpy(&mgmt_tx->buff[len], p2p_vendor_spec, sizeof(p2p_vendor_spec)); |
| 1700 | mgmt_tx->buff[len + sizeof(p2p_vendor_spec)] = p2p_local_random; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1701 | mgmt_tx->size = buf_len; |
| 1702 | } |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 1703 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1704 | } |
| 1705 | |
| 1706 | } else { |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1707 | netdev_dbg(vif->ndev, "Not a P2P public action frame\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1708 | } |
| 1709 | |
| 1710 | break; |
| 1711 | } |
| 1712 | |
| 1713 | default: |
| 1714 | { |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1715 | netdev_dbg(vif->ndev, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1716 | break; |
| 1717 | } |
| 1718 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1719 | } |
| 1720 | |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1721 | pstrWFIDrv->p2p_timeout = (jiffies + msecs_to_jiffies(wait)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1722 | } |
| 1723 | |
Glen Lee | 829c477 | 2015-10-29 12:18:44 +0900 | [diff] [blame] | 1724 | wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx, |
| 1725 | mgmt_tx->buff, mgmt_tx->size, |
Glen Lee | c9d4834 | 2015-10-01 16:03:43 +0900 | [diff] [blame] | 1726 | WILC_WFI_mgmt_tx_complete); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1727 | } |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1728 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1729 | } |
| 1730 | |
Chaehyun Lim | 85c587a | 2015-09-22 18:34:50 +0900 | [diff] [blame] | 1731 | static int mgmt_tx_cancel_wait(struct wiphy *wiphy, |
| 1732 | struct wireless_dev *wdev, |
| 1733 | u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1734 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1735 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1736 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1737 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1738 | priv = wiphy_priv(wiphy); |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 1739 | pstrWFIDrv = (struct host_if_drv *)priv->hif_drv; |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1740 | pstrWFIDrv->p2p_timeout = jiffies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1741 | |
Luis de Bethencourt | 7e4e87d | 2015-10-16 16:32:26 +0100 | [diff] [blame] | 1742 | if (!priv->bInP2PlistenState) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1743 | cfg80211_remain_on_channel_expired(priv->wdev, |
| 1744 | priv->strRemainOnChanParams.u64ListenCookie, |
| 1745 | priv->strRemainOnChanParams.pstrListenChan, |
| 1746 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1747 | } |
| 1748 | |
| 1749 | return 0; |
| 1750 | } |
| 1751 | |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 1752 | void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 1753 | u16 frame_type, bool reg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1754 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1755 | struct wilc_priv *priv; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1756 | struct wilc_vif *vif; |
Glen Lee | 1b86935 | 2015-10-20 17:14:01 +0900 | [diff] [blame] | 1757 | struct wilc *wl; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1758 | |
| 1759 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1760 | vif = netdev_priv(priv->wdev->netdev); |
| 1761 | wl = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1762 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1763 | if (!frame_type) |
| 1764 | return; |
| 1765 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1766 | switch (frame_type) { |
| 1767 | case PROBE_REQ: |
| 1768 | { |
Leo Kim | 340a84f | 2016-03-25 21:16:50 +0900 | [diff] [blame] | 1769 | vif->frame_reg[0].type = frame_type; |
Leo Kim | 89febb2 | 2016-03-25 21:16:49 +0900 | [diff] [blame] | 1770 | vif->frame_reg[0].reg = reg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1771 | } |
| 1772 | break; |
| 1773 | |
| 1774 | case ACTION: |
| 1775 | { |
Leo Kim | 340a84f | 2016-03-25 21:16:50 +0900 | [diff] [blame] | 1776 | vif->frame_reg[1].type = frame_type; |
Leo Kim | 89febb2 | 2016-03-25 21:16:49 +0900 | [diff] [blame] | 1777 | vif->frame_reg[1].reg = reg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1778 | } |
| 1779 | break; |
| 1780 | |
| 1781 | default: |
| 1782 | { |
| 1783 | break; |
| 1784 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1785 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 1786 | |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1787 | if (!wl->initialized) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1788 | return; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1789 | wilc_frame_register(vif, frame_type, reg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1790 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1791 | |
Chaehyun Lim | a8047e2 | 2015-09-22 18:34:48 +0900 | [diff] [blame] | 1792 | static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev, |
| 1793 | s32 rssi_thold, u32 rssi_hyst) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1794 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1795 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1796 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 1797 | |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 1798 | static int dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 1799 | int idx, u8 *mac, struct station_info *sinfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1800 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1801 | struct wilc_priv *priv; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1802 | struct wilc_vif *vif; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1803 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1804 | if (idx != 0) |
| 1805 | return -ENOENT; |
| 1806 | |
| 1807 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1808 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1809 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1810 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1811 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1812 | wilc_get_rssi(vif, &sinfo->signal); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1813 | |
Kangjie Lu | d138296 | 2016-05-03 21:36:11 -0400 | [diff] [blame] | 1814 | memcpy(mac, priv->au8AssociatedBss, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1815 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1816 | } |
| 1817 | |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 1818 | static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 1819 | bool enabled, int timeout) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1820 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1821 | struct wilc_priv *priv; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1822 | struct wilc_vif *vif; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1823 | |
Leo Kim | 369a1d3 | 2015-12-21 14:18:23 +0900 | [diff] [blame] | 1824 | if (!wiphy) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1825 | return -ENOENT; |
| 1826 | |
| 1827 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1828 | vif = netdev_priv(priv->dev); |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1829 | if (!priv->hif_drv) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1830 | return -EIO; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1831 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1832 | if (wilc_enable_ps) |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1833 | wilc_set_power_mgmt(vif, enabled, timeout); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1834 | |
| 1835 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1836 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1837 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 1838 | |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 1839 | static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, |
| 1840 | enum nl80211_iftype type, u32 *flags, struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1841 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1842 | struct wilc_priv *priv; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1843 | struct wilc_vif *vif; |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 1844 | struct wilc *wl; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1845 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1846 | vif = netdev_priv(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1847 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1848 | wl = vif->wilc; |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 1849 | p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1850 | p2p_recv_random = 0x00; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 1851 | wilc_ie = false; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1852 | wilc_optaining_ip = false; |
| 1853 | del_timer(&wilc_during_ip_timer); |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 1854 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1855 | switch (type) { |
| 1856 | case NL80211_IFTYPE_STATION: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1857 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1858 | dev->ieee80211_ptr->iftype = type; |
| 1859 | priv->wdev->iftype = type; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1860 | vif->monitor_flag = 0; |
| 1861 | vif->iftype = STATION_MODE; |
Glen Lee | 86bff01 | 2016-01-25 16:35:17 +0900 | [diff] [blame] | 1862 | wilc_set_operation_mode(vif, STATION_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1863 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1864 | memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1865 | |
Glen Lee | 86bff01 | 2016-01-25 16:35:17 +0900 | [diff] [blame] | 1866 | wilc_enable_ps = true; |
| 1867 | wilc_set_power_mgmt(vif, 1, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1868 | break; |
| 1869 | |
| 1870 | case NL80211_IFTYPE_P2P_CLIENT: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1871 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1872 | dev->ieee80211_ptr->iftype = type; |
| 1873 | priv->wdev->iftype = type; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1874 | vif->monitor_flag = 0; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1875 | vif->iftype = CLIENT_MODE; |
Glen Lee | 86bff01 | 2016-01-25 16:35:17 +0900 | [diff] [blame] | 1876 | wilc_set_operation_mode(vif, STATION_MODE); |
Glen Lee | ee63230 | 2016-01-25 16:35:18 +0900 | [diff] [blame] | 1877 | |
| 1878 | wilc_enable_ps = false; |
| 1879 | wilc_set_power_mgmt(vif, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1880 | break; |
| 1881 | |
| 1882 | case NL80211_IFTYPE_AP: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1883 | wilc_enable_ps = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1884 | dev->ieee80211_ptr->iftype = type; |
| 1885 | priv->wdev->iftype = type; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1886 | vif->iftype = AP_MODE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1887 | |
Glen Lee | 86bff01 | 2016-01-25 16:35:17 +0900 | [diff] [blame] | 1888 | if (wl->initialized) { |
Glen Lee | b330686 | 2016-02-04 18:15:18 +0900 | [diff] [blame] | 1889 | wilc_set_wfi_drv_handler(vif, wilc_get_vif_idx(vif), |
| 1890 | 0); |
Glen Lee | 86bff01 | 2016-01-25 16:35:17 +0900 | [diff] [blame] | 1891 | wilc_set_operation_mode(vif, AP_MODE); |
| 1892 | wilc_set_power_mgmt(vif, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1893 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1894 | break; |
| 1895 | |
| 1896 | case NL80211_IFTYPE_P2P_GO: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1897 | wilc_optaining_ip = true; |
Leo Kim | 7e872df | 2015-11-19 15:56:20 +0900 | [diff] [blame] | 1898 | mod_timer(&wilc_during_ip_timer, |
| 1899 | jiffies + msecs_to_jiffies(during_ip_time)); |
Glen Lee | 86bff01 | 2016-01-25 16:35:17 +0900 | [diff] [blame] | 1900 | wilc_set_operation_mode(vif, AP_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1901 | dev->ieee80211_ptr->iftype = type; |
| 1902 | priv->wdev->iftype = type; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1903 | vif->iftype = GO_MODE; |
Glen Lee | ee63230 | 2016-01-25 16:35:18 +0900 | [diff] [blame] | 1904 | |
| 1905 | wilc_enable_ps = false; |
| 1906 | wilc_set_power_mgmt(vif, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1907 | break; |
| 1908 | |
| 1909 | default: |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1910 | netdev_err(dev, "Unknown interface type= %d\n", type); |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1911 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1912 | } |
| 1913 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1914 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1915 | } |
| 1916 | |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 1917 | static int start_ap(struct wiphy *wiphy, struct net_device *dev, |
| 1918 | struct cfg80211_ap_settings *settings) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1919 | { |
| 1920 | struct cfg80211_beacon_data *beacon = &(settings->beacon); |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1921 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1922 | s32 s32Error = 0; |
Glen Lee | 684dc18 | 2015-10-20 17:14:02 +0900 | [diff] [blame] | 1923 | struct wilc *wl; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1924 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1925 | |
| 1926 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1927 | vif = netdev_priv(dev); |
Leo Kim | 79f7dfa | 2016-02-23 21:10:54 +0900 | [diff] [blame] | 1928 | wl = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1929 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 1930 | s32Error = set_channel(wiphy, &settings->chandef); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1931 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1932 | if (s32Error != 0) |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1933 | netdev_err(dev, "Error in setting channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1934 | |
Leo Kim | 6750140 | 2016-02-04 18:15:39 +0900 | [diff] [blame] | 1935 | wilc_wlan_set_bssid(dev, wl->vif[vif->idx]->src_addr, AP_MODE); |
Glen Lee | cba352a | 2016-02-04 18:15:25 +0900 | [diff] [blame] | 1936 | wilc_set_power_mgmt(vif, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1937 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1938 | s32Error = wilc_add_beacon(vif, settings->beacon_interval, |
| 1939 | settings->dtim_period, beacon->head_len, |
| 1940 | (u8 *)beacon->head, beacon->tail_len, |
| 1941 | (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1942 | |
| 1943 | return s32Error; |
| 1944 | } |
| 1945 | |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 1946 | static int change_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 1947 | struct cfg80211_beacon_data *beacon) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1948 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1949 | struct wilc_priv *priv; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1950 | struct wilc_vif *vif; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1951 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1952 | |
| 1953 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1954 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1955 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1956 | s32Error = wilc_add_beacon(vif, 0, 0, beacon->head_len, |
| 1957 | (u8 *)beacon->head, beacon->tail_len, |
| 1958 | (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1959 | |
| 1960 | return s32Error; |
| 1961 | } |
| 1962 | |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 1963 | static int stop_ap(struct wiphy *wiphy, struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1964 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1965 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1966 | struct wilc_priv *priv; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1967 | struct wilc_vif *vif; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1968 | u8 NullBssid[ETH_ALEN] = {0}; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1969 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 1970 | if (!wiphy) |
| 1971 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1972 | |
| 1973 | priv = wiphy_priv(wiphy); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1974 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1975 | |
Glen Lee | ba615f1 | 2016-01-25 16:35:15 +0900 | [diff] [blame] | 1976 | wilc_wlan_set_bssid(dev, NullBssid, AP_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1977 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1978 | s32Error = wilc_del_beacon(vif); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1979 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 1980 | if (s32Error) |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 1981 | netdev_err(dev, "Host delete beacon fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1982 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1983 | return s32Error; |
| 1984 | } |
| 1985 | |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 1986 | static int add_station(struct wiphy *wiphy, struct net_device *dev, |
| 1987 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1988 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1989 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1990 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 1991 | struct add_sta_param strStaParams = { {0} }; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1992 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1993 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 1994 | if (!wiphy) |
| 1995 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1996 | |
| 1997 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1998 | vif = netdev_priv(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1999 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2000 | if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { |
Leo Kim | 2353c38 | 2015-10-29 12:05:41 +0900 | [diff] [blame] | 2001 | memcpy(strStaParams.bssid, mac, ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 2002 | memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 2003 | strStaParams.aid = params->aid; |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2004 | strStaParams.rates_len = params->supported_rates_len; |
Leo Kim | a622e01 | 2015-10-29 12:05:44 +0900 | [diff] [blame] | 2005 | strStaParams.rates = params->supported_rates; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2006 | |
Leo Kim | 369a1d3 | 2015-12-21 14:18:23 +0900 | [diff] [blame] | 2007 | if (!params->ht_capa) { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2008 | strStaParams.ht_supported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2009 | } else { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2010 | strStaParams.ht_supported = true; |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 2011 | strStaParams.ht_capa_info = params->ht_capa->cap_info; |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 2012 | strStaParams.ht_ampdu_params = params->ht_capa->ampdu_params_info; |
Leo Kim | 5ebbf4f | 2015-10-29 12:05:48 +0900 | [diff] [blame] | 2013 | memcpy(strStaParams.ht_supp_mcs_set, |
| 2014 | ¶ms->ht_capa->mcs, |
| 2015 | WILC_SUPP_MCS_SET_SIZE); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 2016 | strStaParams.ht_ext_params = params->ht_capa->extended_ht_cap_info; |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 2017 | strStaParams.ht_tx_bf_cap = params->ht_capa->tx_BF_cap_info; |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 2018 | strStaParams.ht_ante_sel = params->ht_capa->antenna_selection_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2019 | } |
| 2020 | |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 2021 | strStaParams.flags_mask = params->sta_flags_mask; |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 2022 | strStaParams.flags_set = params->sta_flags_set; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2023 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2024 | s32Error = wilc_add_station(vif, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 2025 | if (s32Error) |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2026 | netdev_err(dev, "Host add station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2027 | } |
| 2028 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2029 | return s32Error; |
| 2030 | } |
| 2031 | |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 2032 | static int del_station(struct wiphy *wiphy, struct net_device *dev, |
| 2033 | struct station_del_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2034 | { |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 2035 | const u8 *mac = params->mac; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2036 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2037 | struct wilc_priv *priv; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2038 | struct wilc_vif *vif; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2039 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2040 | if (!wiphy) |
| 2041 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2042 | |
| 2043 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2044 | vif = netdev_priv(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2045 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2046 | if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { |
Chris Park | a1b56a4 | 2016-02-22 13:11:54 +0900 | [diff] [blame] | 2047 | if (!mac) |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2048 | s32Error = wilc_del_allstation(vif, |
| 2049 | priv->assoc_stainfo.au8Sta_AssociatedBss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2050 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2051 | s32Error = wilc_del_station(vif, mac); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2052 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 2053 | if (s32Error) |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2054 | netdev_err(dev, "Host delete station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2055 | } |
| 2056 | return s32Error; |
| 2057 | } |
| 2058 | |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 2059 | static int change_station(struct wiphy *wiphy, struct net_device *dev, |
| 2060 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2061 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2062 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2063 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 2064 | struct add_sta_param strStaParams = { {0} }; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2065 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2066 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2067 | if (!wiphy) |
| 2068 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2069 | |
| 2070 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2071 | vif = netdev_priv(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2072 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2073 | if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { |
Leo Kim | 2353c38 | 2015-10-29 12:05:41 +0900 | [diff] [blame] | 2074 | memcpy(strStaParams.bssid, mac, ETH_ALEN); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 2075 | strStaParams.aid = params->aid; |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2076 | strStaParams.rates_len = params->supported_rates_len; |
Leo Kim | a622e01 | 2015-10-29 12:05:44 +0900 | [diff] [blame] | 2077 | strStaParams.rates = params->supported_rates; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2078 | |
Leo Kim | 369a1d3 | 2015-12-21 14:18:23 +0900 | [diff] [blame] | 2079 | if (!params->ht_capa) { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2080 | strStaParams.ht_supported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2081 | } else { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2082 | strStaParams.ht_supported = true; |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 2083 | strStaParams.ht_capa_info = params->ht_capa->cap_info; |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 2084 | strStaParams.ht_ampdu_params = params->ht_capa->ampdu_params_info; |
Leo Kim | 5ebbf4f | 2015-10-29 12:05:48 +0900 | [diff] [blame] | 2085 | memcpy(strStaParams.ht_supp_mcs_set, |
| 2086 | ¶ms->ht_capa->mcs, |
| 2087 | WILC_SUPP_MCS_SET_SIZE); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 2088 | strStaParams.ht_ext_params = params->ht_capa->extended_ht_cap_info; |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 2089 | strStaParams.ht_tx_bf_cap = params->ht_capa->tx_BF_cap_info; |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 2090 | strStaParams.ht_ante_sel = params->ht_capa->antenna_selection_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2091 | } |
| 2092 | |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 2093 | strStaParams.flags_mask = params->sta_flags_mask; |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 2094 | strStaParams.flags_set = params->sta_flags_set; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2095 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2096 | s32Error = wilc_edit_station(vif, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 2097 | if (s32Error) |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2098 | netdev_err(dev, "Host edit station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2099 | } |
| 2100 | return s32Error; |
| 2101 | } |
| 2102 | |
Chaehyun Lim | 37316e8 | 2015-09-22 18:34:52 +0900 | [diff] [blame] | 2103 | static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, |
| 2104 | const char *name, |
| 2105 | unsigned char name_assign_type, |
| 2106 | enum nl80211_iftype type, |
| 2107 | u32 *flags, |
| 2108 | struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2109 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2110 | struct wilc_vif *vif; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2111 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2112 | struct net_device *new_ifc = NULL; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2113 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2114 | priv = wiphy_priv(wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2115 | vif = netdev_priv(priv->wdev->netdev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2116 | |
| 2117 | |
| 2118 | if (type == NL80211_IFTYPE_MONITOR) { |
Glen Lee | 1006b5c | 2015-12-21 14:18:38 +0900 | [diff] [blame] | 2119 | new_ifc = WILC_WFI_init_mon_interface(name, vif->ndev); |
Leo Kim | 369a1d3 | 2015-12-21 14:18:23 +0900 | [diff] [blame] | 2120 | if (new_ifc) { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 2121 | vif = netdev_priv(priv->wdev->netdev); |
| 2122 | vif->monitor_flag = 1; |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2123 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2124 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2125 | return priv->wdev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2126 | } |
| 2127 | |
Chaehyun Lim | 956d721 | 2015-09-22 18:34:49 +0900 | [diff] [blame] | 2128 | static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2129 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2130 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2131 | } |
| 2132 | |
Glen Lee | 73584a4 | 2016-01-25 16:35:10 +0900 | [diff] [blame] | 2133 | static int wilc_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow) |
| 2134 | { |
| 2135 | struct wilc_priv *priv = wiphy_priv(wiphy); |
| 2136 | struct wilc_vif *vif = netdev_priv(priv->dev); |
| 2137 | |
| 2138 | if (!wow && wilc_wlan_get_num_conn_ifcs(vif->wilc)) |
| 2139 | vif->wilc->suspend_event = true; |
| 2140 | else |
| 2141 | vif->wilc->suspend_event = false; |
| 2142 | |
| 2143 | return 0; |
| 2144 | } |
| 2145 | |
| 2146 | static int wilc_resume(struct wiphy *wiphy) |
| 2147 | { |
| 2148 | struct wilc_priv *priv = wiphy_priv(wiphy); |
| 2149 | struct wilc_vif *vif = netdev_priv(priv->dev); |
| 2150 | |
| 2151 | netdev_info(vif->ndev, "cfg resume\n"); |
| 2152 | return 0; |
| 2153 | } |
| 2154 | |
| 2155 | static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled) |
| 2156 | { |
| 2157 | struct wilc_priv *priv = wiphy_priv(wiphy); |
| 2158 | struct wilc_vif *vif = netdev_priv(priv->dev); |
| 2159 | |
| 2160 | netdev_info(vif->ndev, "cfg set wake up = %d\n", enabled); |
| 2161 | } |
| 2162 | |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 2163 | static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 2164 | enum nl80211_tx_power_setting type, int mbm) |
| 2165 | { |
| 2166 | int ret; |
| 2167 | s32 tx_power = MBM_TO_DBM(mbm); |
| 2168 | struct wilc_priv *priv = wiphy_priv(wiphy); |
| 2169 | struct wilc_vif *vif = netdev_priv(priv->dev); |
| 2170 | |
| 2171 | if (tx_power < 0) |
| 2172 | tx_power = 0; |
| 2173 | else if (tx_power > 18) |
| 2174 | tx_power = 18; |
| 2175 | ret = wilc_set_tx_power(vif, tx_power); |
| 2176 | if (ret) |
| 2177 | netdev_err(vif->ndev, "Failed to set tx power\n"); |
| 2178 | |
| 2179 | return ret; |
| 2180 | } |
| 2181 | |
| 2182 | static int get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 2183 | int *dbm) |
| 2184 | { |
| 2185 | int ret; |
| 2186 | struct wilc_priv *priv = wiphy_priv(wiphy); |
| 2187 | struct wilc_vif *vif = netdev_priv(priv->dev); |
Leo Kim | 8827bd8 | 2016-03-18 21:23:16 +0900 | [diff] [blame] | 2188 | struct wilc *wl; |
| 2189 | |
| 2190 | wl = vif->wilc; |
| 2191 | |
| 2192 | /* If firmware is not started, return. */ |
| 2193 | if (!wl->initialized) |
| 2194 | return -EIO; |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 2195 | |
| 2196 | ret = wilc_get_tx_power(vif, (u8 *)dbm); |
| 2197 | if (ret) |
| 2198 | netdev_err(vif->ndev, "Failed to get tx power\n"); |
| 2199 | |
| 2200 | return ret; |
| 2201 | } |
| 2202 | |
Chaehyun Lim | 0824192 | 2015-09-15 14:06:12 +0900 | [diff] [blame] | 2203 | static struct cfg80211_ops wilc_cfg80211_ops = { |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 2204 | .set_monitor_channel = set_channel, |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 2205 | .scan = scan, |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 2206 | .connect = connect, |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 2207 | .disconnect = disconnect, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2208 | .add_key = add_key, |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 2209 | .del_key = del_key, |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 2210 | .get_key = get_key, |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 2211 | .set_default_key = set_default_key, |
Chaehyun Lim | 69deb4c | 2015-09-14 12:24:09 +0900 | [diff] [blame] | 2212 | .add_virtual_intf = add_virtual_intf, |
Chaehyun Lim | b4a7335 | 2015-09-14 12:24:10 +0900 | [diff] [blame] | 2213 | .del_virtual_intf = del_virtual_intf, |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 2214 | .change_virtual_intf = change_virtual_intf, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2215 | |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 2216 | .start_ap = start_ap, |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 2217 | .change_beacon = change_beacon, |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 2218 | .stop_ap = stop_ap, |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 2219 | .add_station = add_station, |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 2220 | .del_station = del_station, |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 2221 | .change_station = change_station, |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 2222 | .get_station = get_station, |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 2223 | .dump_station = dump_station, |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 2224 | .change_bss = change_bss, |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 2225 | .set_wiphy_params = set_wiphy_params, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2226 | |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 2227 | .set_pmksa = set_pmksa, |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 2228 | .del_pmksa = del_pmksa, |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 2229 | .flush_pmksa = flush_pmksa, |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 2230 | .remain_on_channel = remain_on_channel, |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 2231 | .cancel_remain_on_channel = cancel_remain_on_channel, |
Chaehyun Lim | 4a2f9b3 | 2015-09-14 12:24:27 +0900 | [diff] [blame] | 2232 | .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait, |
Chaehyun Lim | 12a26a3 | 2015-09-14 12:24:28 +0900 | [diff] [blame] | 2233 | .mgmt_tx = mgmt_tx, |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 2234 | .mgmt_frame_register = wilc_mgmt_frame_register, |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 2235 | .set_power_mgmt = set_power_mgmt, |
Chaehyun Lim | a8047e2 | 2015-09-22 18:34:48 +0900 | [diff] [blame] | 2236 | .set_cqm_rssi_config = set_cqm_rssi_config, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2237 | |
Glen Lee | 73584a4 | 2016-01-25 16:35:10 +0900 | [diff] [blame] | 2238 | .suspend = wilc_suspend, |
| 2239 | .resume = wilc_resume, |
| 2240 | .set_wakeup = wilc_set_wakeup, |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 2241 | .set_tx_power = set_tx_power, |
| 2242 | .get_tx_power = get_tx_power, |
Glen Lee | 73584a4 | 2016-01-25 16:35:10 +0900 | [diff] [blame] | 2243 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2244 | }; |
| 2245 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 2246 | static struct wireless_dev *WILC_WFI_CfgAlloc(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2247 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2248 | struct wireless_dev *wdev; |
| 2249 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2250 | wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2251 | if (!wdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2252 | goto _fail_; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2253 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2254 | wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv)); |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2255 | if (!wdev->wiphy) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2256 | goto _fail_mem_; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2257 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2258 | WILC_WFI_band_2ghz.ht_cap.ht_supported = 1; |
| 2259 | WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); |
| 2260 | WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; |
| 2261 | WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; |
| 2262 | WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2263 | |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 2264 | wdev->wiphy->bands[NL80211_BAND_2GHZ] = &WILC_WFI_band_2ghz; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2265 | |
| 2266 | return wdev; |
| 2267 | |
| 2268 | _fail_mem_: |
| 2269 | kfree(wdev); |
| 2270 | _fail_: |
| 2271 | return NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2272 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 2273 | |
Arnd Bergmann | 2e7d537 | 2015-11-16 15:05:03 +0100 | [diff] [blame] | 2274 | struct wireless_dev *wilc_create_wiphy(struct net_device *net, struct device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2275 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2276 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2277 | struct wireless_dev *wdev; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2278 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2279 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2280 | wdev = WILC_WFI_CfgAlloc(); |
Leo Kim | 369a1d3 | 2015-12-21 14:18:23 +0900 | [diff] [blame] | 2281 | if (!wdev) { |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2282 | netdev_err(net, "wiphy new allocate failed\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2283 | return NULL; |
| 2284 | } |
| 2285 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2286 | priv = wdev_priv(wdev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2287 | priv->wdev = wdev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2288 | wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID; |
Sudip Mukherjee | abb4f8a | 2016-02-05 15:26:54 +0530 | [diff] [blame] | 2289 | #ifdef CONFIG_PM |
Glen Lee | 73584a4 | 2016-01-25 16:35:10 +0900 | [diff] [blame] | 2290 | wdev->wiphy->wowlan = &wowlan_support; |
Sudip Mukherjee | abb4f8a | 2016-02-05 15:26:54 +0530 | [diff] [blame] | 2291 | #endif |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2292 | wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2293 | wdev->wiphy->max_scan_ie_len = 1000; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2294 | wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2295 | wdev->wiphy->cipher_suites = cipher_suites; |
| 2296 | wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2297 | wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2298 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2299 | wdev->wiphy->max_remain_on_channel_duration = 500; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2300 | wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) | |
| 2301 | BIT(NL80211_IFTYPE_P2P_CLIENT); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2302 | wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2303 | wdev->iftype = NL80211_IFTYPE_STATION; |
| 2304 | |
Arnd Bergmann | 2e7d537 | 2015-11-16 15:05:03 +0100 | [diff] [blame] | 2305 | set_wiphy_dev(wdev->wiphy, dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2306 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2307 | s32Error = wiphy_register(wdev->wiphy); |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2308 | if (s32Error) |
| 2309 | netdev_err(net, "Cannot register wiphy device\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2310 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2311 | priv->dev = net; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2312 | return wdev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2313 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame] | 2314 | |
Chaehyun Lim | dd4b6a8 | 2015-09-20 15:51:25 +0900 | [diff] [blame] | 2315 | int wilc_init_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2316 | { |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 2317 | int s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2318 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2319 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2320 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2321 | priv = wdev_priv(net->ieee80211_ptr); |
| 2322 | if (op_ifcs == 0) { |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 2323 | setup_timer(&hAgingTimer, remove_network_from_shadow, 0); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2324 | setup_timer(&wilc_during_ip_timer, clear_duringIP, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2325 | } |
| 2326 | op_ifcs++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2327 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2328 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2329 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2330 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2331 | |
Chaehyun Lim | 0866209 | 2016-03-28 13:56:00 +0900 | [diff] [blame] | 2332 | mutex_init(&priv->scan_req_lock); |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 2333 | s32Error = wilc_init(net, &priv->hif_drv); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 2334 | if (s32Error) |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2335 | netdev_err(net, "Error while initializing hostinterface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 2336 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2337 | return s32Error; |
| 2338 | } |
| 2339 | |
Chaehyun Lim | a9a1682 | 2015-09-20 15:51:24 +0900 | [diff] [blame] | 2340 | int wilc_deinit_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2341 | { |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 2342 | int s32Error = 0; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2343 | struct wilc_vif *vif; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2344 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2345 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2346 | priv = wdev_priv(net->ieee80211_ptr); |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2347 | vif = netdev_priv(priv->dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2348 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2349 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2350 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2351 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2352 | |
| 2353 | op_ifcs--; |
| 2354 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2355 | s32Error = wilc_deinit(vif); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2356 | |
Leo Kim | d14991a | 2015-11-19 15:56:22 +0900 | [diff] [blame] | 2357 | clear_shadow_scan(); |
Chris Park | 368949a | 2016-02-04 18:24:03 +0900 | [diff] [blame] | 2358 | if (op_ifcs == 0) |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2359 | del_timer_sync(&wilc_during_ip_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2360 | |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 2361 | if (s32Error) |
Leo Kim | 06fb933 | 2016-02-04 18:15:55 +0900 | [diff] [blame] | 2362 | netdev_err(net, "Error while deintializing host interface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 2363 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2364 | return s32Error; |
| 2365 | } |
| 2366 | |
Chaehyun Lim | 96da20a | 2015-09-20 15:51:08 +0900 | [diff] [blame] | 2367 | void wilc_free_wiphy(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2368 | { |
Chris Park | d9766d5 | 2016-02-22 13:12:04 +0900 | [diff] [blame] | 2369 | if (!net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2370 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2371 | |
Chris Park | d9766d5 | 2016-02-22 13:12:04 +0900 | [diff] [blame] | 2372 | if (!net->ieee80211_ptr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2373 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2374 | |
Chris Park | d9766d5 | 2016-02-22 13:12:04 +0900 | [diff] [blame] | 2375 | if (!net->ieee80211_ptr->wiphy) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2376 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2377 | |
| 2378 | wiphy_unregister(net->ieee80211_ptr->wiphy); |
| 2379 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2380 | wiphy_free(net->ieee80211_ptr->wiphy); |
| 2381 | kfree(net->ieee80211_ptr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2382 | } |