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 | |
Arnd Bergmann | 15162fb | 2015-11-16 15:04:57 +0100 | [diff] [blame] | 77 | #define WILC_WFI_DWELL_PASSIVE 100 |
| 78 | #define WILC_WFI_DWELL_ACTIVE 40 |
| 79 | |
| 80 | #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 |
| 81 | #define DEFAULT_LINK_SPEED 72 |
| 82 | |
| 83 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 84 | #define IS_MANAGMEMENT 0x100 |
| 85 | #define IS_MANAGMEMENT_CALLBACK 0x080 |
| 86 | #define IS_MGMT_STATUS_SUCCES 0x040 |
| 87 | #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) |
| 88 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 89 | extern int wilc_mac_open(struct net_device *ndev); |
| 90 | extern int wilc_mac_close(struct net_device *ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 91 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 92 | static tstrNetworkInfo last_scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW]; |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 93 | static u32 last_scanned_cnt; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 94 | struct timer_list wilc_during_ip_timer; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 95 | static struct timer_list hAgingTimer; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 96 | static u8 op_ifcs; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 97 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 98 | u8 wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 99 | |
| 100 | #define CHAN2G(_channel, _freq, _flags) { \ |
| 101 | .band = IEEE80211_BAND_2GHZ, \ |
| 102 | .center_freq = (_freq), \ |
| 103 | .hw_value = (_channel), \ |
| 104 | .flags = (_flags), \ |
| 105 | .max_antenna_gain = 0, \ |
| 106 | .max_power = 30, \ |
| 107 | } |
| 108 | |
Leo Kim | 2736f47 | 2015-11-19 15:56:12 +0900 | [diff] [blame] | 109 | static struct ieee80211_channel ieee80211_2ghz_channels[] = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 110 | CHAN2G(1, 2412, 0), |
| 111 | CHAN2G(2, 2417, 0), |
| 112 | CHAN2G(3, 2422, 0), |
| 113 | CHAN2G(4, 2427, 0), |
| 114 | CHAN2G(5, 2432, 0), |
| 115 | CHAN2G(6, 2437, 0), |
| 116 | CHAN2G(7, 2442, 0), |
| 117 | CHAN2G(8, 2447, 0), |
| 118 | CHAN2G(9, 2452, 0), |
| 119 | CHAN2G(10, 2457, 0), |
| 120 | CHAN2G(11, 2462, 0), |
| 121 | CHAN2G(12, 2467, 0), |
| 122 | CHAN2G(13, 2472, 0), |
| 123 | CHAN2G(14, 2484, 0), |
| 124 | }; |
| 125 | |
| 126 | #define RATETAB_ENT(_rate, _hw_value, _flags) { \ |
| 127 | .bitrate = (_rate), \ |
| 128 | .hw_value = (_hw_value), \ |
| 129 | .flags = (_flags), \ |
| 130 | } |
| 131 | |
Leo Kim | 8d48b5b | 2015-11-19 15:56:13 +0900 | [diff] [blame] | 132 | static struct ieee80211_rate ieee80211_bitrates[] = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 133 | RATETAB_ENT(10, 0, 0), |
| 134 | RATETAB_ENT(20, 1, 0), |
| 135 | RATETAB_ENT(55, 2, 0), |
| 136 | RATETAB_ENT(110, 3, 0), |
| 137 | RATETAB_ENT(60, 9, 0), |
| 138 | RATETAB_ENT(90, 6, 0), |
| 139 | RATETAB_ENT(120, 7, 0), |
| 140 | RATETAB_ENT(180, 8, 0), |
| 141 | RATETAB_ENT(240, 9, 0), |
| 142 | RATETAB_ENT(360, 10, 0), |
| 143 | RATETAB_ENT(480, 11, 0), |
| 144 | RATETAB_ENT(540, 12, 0), |
| 145 | }; |
| 146 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 147 | struct p2p_mgmt_data { |
| 148 | int size; |
| 149 | u8 *buff; |
| 150 | }; |
| 151 | |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 152 | static u8 wlan_channel = INVALID_CHANNEL; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 153 | static u8 curr_channel; |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 154 | static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09}; |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 155 | static u8 p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 156 | static u8 p2p_recv_random = 0x00; |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 157 | static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 158 | static bool wilc_ie; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 159 | |
| 160 | static struct ieee80211_supported_band WILC_WFI_band_2ghz = { |
Leo Kim | 2736f47 | 2015-11-19 15:56:12 +0900 | [diff] [blame] | 161 | .channels = ieee80211_2ghz_channels, |
| 162 | .n_channels = ARRAY_SIZE(ieee80211_2ghz_channels), |
Leo Kim | 8d48b5b | 2015-11-19 15:56:13 +0900 | [diff] [blame] | 163 | .bitrates = ieee80211_bitrates, |
| 164 | .n_bitrates = ARRAY_SIZE(ieee80211_bitrates), |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 165 | }; |
| 166 | |
| 167 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 168 | struct add_key_params { |
| 169 | u8 key_idx; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 170 | bool pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 171 | u8 *mac_addr; |
| 172 | }; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 173 | static struct add_key_params g_add_gtk_key_params; |
| 174 | static struct wilc_wfi_key g_key_gtk_params; |
| 175 | static struct add_key_params g_add_ptk_key_params; |
| 176 | static struct wilc_wfi_key g_key_ptk_params; |
| 177 | static struct wilc_wfi_wep_key g_key_wep_params; |
| 178 | static bool g_ptk_keys_saved; |
| 179 | static bool g_gtk_keys_saved; |
| 180 | static bool g_wep_keys_saved; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 181 | |
| 182 | #define AGING_TIME (9 * 1000) |
Leo Kim | 7e872df | 2015-11-19 15:56:20 +0900 | [diff] [blame] | 183 | #define during_ip_time 15000 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 184 | |
Leo Kim | d14991a | 2015-11-19 15:56:22 +0900 | [diff] [blame] | 185 | static void clear_shadow_scan(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 186 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 187 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 188 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 189 | if (op_ifcs == 0) { |
Greg Kroah-Hartman | 4183e97 | 2015-08-14 20:11:16 -0700 | [diff] [blame] | 190 | del_timer_sync(&hAgingTimer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 191 | PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n"); |
| 192 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 193 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 194 | if (last_scanned_shadow[last_scanned_cnt].pu8IEs) { |
| 195 | kfree(last_scanned_shadow[i].pu8IEs); |
| 196 | last_scanned_shadow[last_scanned_cnt].pu8IEs = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 197 | } |
| 198 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 199 | wilc_free_join_params(last_scanned_shadow[i].pJoinParams); |
| 200 | last_scanned_shadow[i].pJoinParams = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 201 | } |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 202 | last_scanned_cnt = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | } |
| 206 | |
Leo Kim | 0b8bea1 | 2015-11-19 15:56:35 +0900 | [diff] [blame] | 207 | static u32 get_rssi_avg(tstrNetworkInfo *network_info) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 208 | { |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 209 | u8 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 210 | int rssi_v = 0; |
Leo Kim | 0b8bea1 | 2015-11-19 15:56:35 +0900 | [diff] [blame] | 211 | u8 num_rssi = (network_info->strRssi.u8Full) ? NUM_RSSI : (network_info->strRssi.u8Index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 212 | |
| 213 | for (i = 0; i < num_rssi; i++) |
Leo Kim | 0b8bea1 | 2015-11-19 15:56:35 +0900 | [diff] [blame] | 214 | rssi_v += network_info->strRssi.as8RSSI[i]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 215 | |
| 216 | rssi_v /= num_rssi; |
| 217 | return rssi_v; |
| 218 | } |
| 219 | |
Leo Kim | 48ee7ba | 2015-11-19 15:56:24 +0900 | [diff] [blame] | 220 | static void refresh_scan(void *user_void, u8 all, bool direct_scan) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 221 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 222 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 223 | struct wiphy *wiphy; |
| 224 | struct cfg80211_bss *bss = NULL; |
| 225 | int i; |
| 226 | int rssi = 0; |
| 227 | |
Leo Kim | 84df0e6 | 2015-11-19 15:56:23 +0900 | [diff] [blame] | 228 | priv = (struct wilc_priv *)user_void; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 229 | wiphy = priv->dev->ieee80211_ptr->wiphy; |
| 230 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 231 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 232 | tstrNetworkInfo *network_info; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 233 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 234 | network_info = &last_scanned_shadow[i]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 235 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 236 | if (!network_info->u8Found || all) { |
Leo Kim | c6f5e3a | 2015-11-19 15:56:26 +0900 | [diff] [blame] | 237 | s32 freq; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 238 | struct ieee80211_channel *channel; |
| 239 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 240 | if (network_info) { |
Leo Kim | c6f5e3a | 2015-11-19 15:56:26 +0900 | [diff] [blame] | 241 | freq = ieee80211_channel_to_frequency((s32)network_info->u8channel, IEEE80211_BAND_2GHZ); |
| 242 | channel = ieee80211_get_channel(wiphy, freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 243 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 244 | rssi = get_rssi_avg(network_info); |
| 245 | if (memcmp("DIRECT-", network_info->au8ssid, 7) || |
Leo Kim | 48ee7ba | 2015-11-19 15:56:24 +0900 | [diff] [blame] | 246 | direct_scan) { |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 247 | bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, network_info->au8bssid, network_info->u64Tsf, network_info->u16CapInfo, |
| 248 | network_info->u16BeaconPeriod, (const u8 *)network_info->pu8IEs, |
| 249 | (size_t)network_info->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 250 | cfg80211_put_bss(wiphy, bss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 251 | } |
| 252 | } |
| 253 | |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | } |
| 258 | |
Leo Kim | 12b0138 | 2015-11-19 15:56:27 +0900 | [diff] [blame] | 259 | static void reset_shadow_found(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 260 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 261 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 262 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 263 | for (i = 0; i < last_scanned_cnt; i++) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 264 | last_scanned_shadow[i].u8Found = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 265 | } |
| 266 | |
Leo Kim | 5e51d8b | 2015-11-19 15:56:28 +0900 | [diff] [blame] | 267 | static void update_scan_time(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 268 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 269 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 270 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 271 | for (i = 0; i < last_scanned_cnt; i++) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 272 | last_scanned_shadow[i].u32TimeRcvdInScan = jiffies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 273 | } |
| 274 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 275 | static void remove_network_from_shadow(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 276 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 277 | unsigned long now = jiffies; |
| 278 | int i, j; |
| 279 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 280 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 281 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 282 | if (time_after(now, last_scanned_shadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) { |
| 283 | PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s\n", last_scanned_shadow[i].au8ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 284 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 285 | kfree(last_scanned_shadow[i].pu8IEs); |
| 286 | last_scanned_shadow[i].pu8IEs = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 287 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 288 | wilc_free_join_params(last_scanned_shadow[i].pJoinParams); |
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 (j = i; (j < last_scanned_cnt - 1); j++) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 291 | last_scanned_shadow[j] = last_scanned_shadow[j + 1]; |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 292 | |
| 293 | last_scanned_cnt--; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 297 | PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", |
| 298 | last_scanned_cnt); |
| 299 | if (last_scanned_cnt != 0) { |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 300 | hAgingTimer.data = arg; |
| 301 | mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); |
| 302 | } else { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 303 | PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n"); |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 304 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 305 | } |
| 306 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 307 | static void clear_duringIP(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 308 | { |
| 309 | PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 310 | wilc_optaining_ip = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 311 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 312 | |
Leo Kim | 157814f | 2015-11-19 15:56:29 +0900 | [diff] [blame] | 313 | static int is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, |
| 314 | void *user_void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 315 | { |
Chaehyun Lim | a74cc6b | 2015-10-02 16:41:17 +0900 | [diff] [blame] | 316 | int state = -1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 317 | int i; |
| 318 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 319 | if (last_scanned_cnt == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 320 | PRINT_D(CFG80211_DBG, "Starting Aging timer\n"); |
Leo Kim | 157814f | 2015-11-19 15:56:29 +0900 | [diff] [blame] | 321 | hAgingTimer.data = (unsigned long)user_void; |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 322 | mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 323 | state = -1; |
| 324 | } else { |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 325 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 326 | if (memcmp(last_scanned_shadow[i].au8bssid, |
| 327 | pstrNetworkInfo->au8bssid, 6) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 328 | state = i; |
| 329 | break; |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | return state; |
| 334 | } |
| 335 | |
Leo Kim | 5c4cf0d | 2015-11-19 15:56:30 +0900 | [diff] [blame] | 336 | static void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, |
| 337 | void *user_void, void *pJoinParams) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 338 | { |
Leo Kim | 5c4cf0d | 2015-11-19 15:56:30 +0900 | [diff] [blame] | 339 | int ap_found = is_network_in_shadow(pstrNetworkInfo, user_void); |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 340 | u32 ap_index = 0; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 341 | u8 rssi_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 342 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 343 | if (last_scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 344 | PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n"); |
| 345 | return; |
| 346 | } |
| 347 | if (ap_found == -1) { |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 348 | ap_index = last_scanned_cnt; |
| 349 | last_scanned_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 350 | |
| 351 | } else { |
| 352 | ap_index = ap_found; |
| 353 | } |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 354 | rssi_index = last_scanned_shadow[ap_index].strRssi.u8Index; |
| 355 | last_scanned_shadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 356 | if (rssi_index == NUM_RSSI) { |
| 357 | rssi_index = 0; |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 358 | last_scanned_shadow[ap_index].strRssi.u8Full = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 359 | } |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 360 | last_scanned_shadow[ap_index].strRssi.u8Index = rssi_index; |
| 361 | last_scanned_shadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi; |
| 362 | last_scanned_shadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo; |
| 363 | last_scanned_shadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen; |
| 364 | memcpy(last_scanned_shadow[ap_index].au8ssid, |
| 365 | pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen); |
| 366 | memcpy(last_scanned_shadow[ap_index].au8bssid, |
| 367 | pstrNetworkInfo->au8bssid, ETH_ALEN); |
| 368 | last_scanned_shadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod; |
| 369 | last_scanned_shadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod; |
| 370 | last_scanned_shadow[ap_index].u8channel = pstrNetworkInfo->u8channel; |
| 371 | last_scanned_shadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen; |
| 372 | last_scanned_shadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 373 | if (ap_found != -1) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 374 | kfree(last_scanned_shadow[ap_index].pu8IEs); |
| 375 | last_scanned_shadow[ap_index].pu8IEs = |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 376 | kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 377 | memcpy(last_scanned_shadow[ap_index].pu8IEs, |
| 378 | pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen); |
| 379 | last_scanned_shadow[ap_index].u32TimeRcvdInScan = jiffies; |
| 380 | last_scanned_shadow[ap_index].u32TimeRcvdInScanCached = jiffies; |
| 381 | last_scanned_shadow[ap_index].u8Found = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 382 | if (ap_found != -1) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 383 | wilc_free_join_params(last_scanned_shadow[ap_index].pJoinParams); |
| 384 | last_scanned_shadow[ap_index].pJoinParams = 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 | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 388 | tstrNetworkInfo *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 | |
Leo Kim | 30cd10c | 2015-11-19 15:56:33 +0900 | [diff] [blame] | 398 | priv = (struct wilc_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 && |
| 407 | (((s32)network_info->s8rssi * 100) < 0 || |
| 408 | ((s32)network_info->s8rssi * 100) > 100)) { |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 409 | PRINT_ER("wiphy signal type fial\n"); |
| 410 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 411 | } |
| 412 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 413 | if (network_info) { |
| 414 | s32Freq = ieee80211_channel_to_frequency((s32)network_info->u8channel, IEEE80211_BAND_2GHZ); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 415 | channel = ieee80211_get_channel(wiphy, s32Freq); |
| 416 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 417 | if (!channel) |
| 418 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 419 | |
| 420 | PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d," |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 421 | "BeaconPeriod: %d\n", channel->center_freq, (((s32)network_info->s8rssi) * 100), |
| 422 | network_info->u16CapInfo, network_info->u16BeaconPeriod); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 423 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 424 | if (network_info->bNewNetwork) { |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 425 | if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 426 | PRINT_D(CFG80211_DBG, "Network %s found\n", network_info->au8ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 427 | priv->u32RcvdChCount++; |
| 428 | |
Leo Kim | bdd3460 | 2015-11-19 15:56:34 +0900 | [diff] [blame] | 429 | if (!join_params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 430 | PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n"); |
Leo Kim | bdd3460 | 2015-11-19 15:56:34 +0900 | [diff] [blame] | 431 | add_network_to_shadow(network_info, priv, join_params); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 432 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 433 | if (!(memcmp("DIRECT-", network_info->au8ssid, 7))) { |
| 434 | bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, network_info->au8bssid, network_info->u64Tsf, network_info->u16CapInfo, |
| 435 | network_info->u16BeaconPeriod, (const u8 *)network_info->pu8IEs, |
| 436 | (size_t)network_info->u16IEsLen, (((s32)network_info->s8rssi) * 100), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 437 | cfg80211_put_bss(wiphy, bss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | |
| 441 | } else { |
| 442 | PRINT_ER("Discovered networks exceeded the max limit\n"); |
| 443 | } |
| 444 | } else { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 445 | u32 i; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 446 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 447 | for (i = 0; i < priv->u32RcvdChCount; i++) { |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 448 | if (memcmp(last_scanned_shadow[i].au8bssid, network_info->au8bssid, 6) == 0) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 449 | PRINT_D(CFG80211_DBG, "Update RSSI of %s\n", last_scanned_shadow[i].au8ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 450 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 451 | last_scanned_shadow[i].s8rssi = network_info->s8rssi; |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 452 | last_scanned_shadow[i].u32TimeRcvdInScan = jiffies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 453 | break; |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | } |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 458 | } else if (scan_event == SCAN_EVENT_DONE) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 459 | PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev); |
| 460 | PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n"); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 461 | refresh_scan(priv, 1, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 462 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 463 | if (priv->u32RcvdChCount > 0) |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 464 | PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount); |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 465 | else |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 466 | PRINT_D(CFG80211_DBG, "No networks found\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 467 | |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 468 | down(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 469 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 470 | if (priv->pstrScanReq != NULL) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 471 | cfg80211_scan_done(priv->pstrScanReq, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 472 | priv->u32RcvdChCount = 0; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 473 | priv->bCfgScanning = false; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 474 | priv->pstrScanReq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 475 | } |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 476 | up(&(priv->hSemScanReq)); |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 477 | } else if (scan_event == SCAN_EVENT_ABORTED) { |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 478 | down(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 479 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 480 | PRINT_D(CFG80211_DBG, "Scan Aborted\n"); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 481 | if (priv->pstrScanReq != NULL) { |
Leo Kim | 5e51d8b | 2015-11-19 15:56:28 +0900 | [diff] [blame] | 482 | update_scan_time(); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 483 | refresh_scan(priv, 1, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 484 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 485 | cfg80211_scan_done(priv->pstrScanReq, false); |
| 486 | priv->bCfgScanning = false; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 487 | priv->pstrScanReq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 488 | } |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 489 | up(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 490 | } |
| 491 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 492 | } |
| 493 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 494 | int wilc_connecting; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 495 | |
Leo Kim | ed3f037 | 2015-10-12 16:56:01 +0900 | [diff] [blame] | 496 | static void CfgConnectResult(enum conn_event enuConnDisconnEvent, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 497 | tstrConnectInfo *pstrConnectInfo, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 498 | u8 u8MacStatus, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 499 | tstrDisconnectNotifInfo *pstrDisconnectNotifInfo, |
| 500 | void *pUserVoid) |
| 501 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 502 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 503 | struct net_device *dev; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 504 | struct host_if_drv *pstrWFIDrv; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 505 | u8 NullBssid[ETH_ALEN] = {0}; |
Glen Lee | c1ec2c1 | 2015-10-20 17:13:58 +0900 | [diff] [blame] | 506 | struct wilc *wl; |
| 507 | perInterface_wlan_t *nic; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 508 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 509 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 510 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 511 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 512 | dev = priv->dev; |
Glen Lee | c1ec2c1 | 2015-10-20 17:13:58 +0900 | [diff] [blame] | 513 | nic = netdev_priv(dev); |
| 514 | wl = nic->wilc; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 515 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 516 | |
| 517 | if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) { |
Amitoj Kaur Chawla | baba7c7 | 2015-10-15 13:48:29 +0530 | [diff] [blame] | 518 | u16 u16ConnectStatus; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 519 | |
| 520 | u16ConnectStatus = pstrConnectInfo->u16ConnectStatus; |
| 521 | |
| 522 | PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus); |
| 523 | |
| 524 | if ((u8MacStatus == MAC_DISCONNECTED) && |
| 525 | (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 526 | u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 527 | wilc_wlan_set_bssid(priv->dev, NullBssid); |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 528 | eth_zero_addr(wilc_connected_ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 529 | |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 530 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 531 | wlan_channel = INVALID_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 532 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 533 | PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d\n", u16ConnectStatus, u8MacStatus); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 534 | } |
| 535 | |
| 536 | if (u16ConnectStatus == WLAN_STATUS_SUCCESS) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 537 | bool bNeedScanRefresh = false; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 538 | u32 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 539 | |
| 540 | PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0], |
| 541 | pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 542 | memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 543 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 544 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 545 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 546 | if (memcmp(last_scanned_shadow[i].au8bssid, |
| 547 | pstrConnectInfo->au8bssid, ETH_ALEN) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 548 | unsigned long now = jiffies; |
| 549 | |
| 550 | if (time_after(now, |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 551 | last_scanned_shadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 552 | bNeedScanRefresh = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | break; |
| 556 | } |
| 557 | } |
| 558 | |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 559 | if (bNeedScanRefresh) |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 560 | refresh_scan(priv, 1, true); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | |
Sudip Mukherjee | 52db7520 | 2015-06-02 14:28:17 +0530 | [diff] [blame] | 564 | PRINT_D(CFG80211_DBG, "Association request info elements length = %zu\n", pstrConnectInfo->ReqIEsLen); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 565 | |
| 566 | PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen); |
| 567 | |
| 568 | cfg80211_connect_result(dev, pstrConnectInfo->au8bssid, |
| 569 | pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen, |
| 570 | pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen, |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 571 | u16ConnectStatus, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 572 | } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 573 | wilc_optaining_ip = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 574 | PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n", |
| 575 | pstrDisconnectNotifInfo->u16reason, priv->dev); |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 576 | p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 577 | p2p_recv_random = 0x00; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 578 | wilc_ie = false; |
Shraddha Barke | bcf0265 | 2015-10-05 17:00:32 +0530 | [diff] [blame] | 579 | eth_zero_addr(priv->au8AssociatedBss); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 580 | wilc_wlan_set_bssid(priv->dev, NullBssid); |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 581 | eth_zero_addr(wilc_connected_ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 582 | |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 583 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 584 | wlan_channel = INVALID_CHANNEL; |
Glen Lee | c1ec2c1 | 2015-10-20 17:13:58 +0900 | [diff] [blame] | 585 | if ((pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 586 | pstrDisconnectNotifInfo->u16reason = 3; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 587 | } else if ((!pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 588 | pstrDisconnectNotifInfo->u16reason = 1; |
| 589 | } |
| 590 | cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie, |
Sudip Mukherjee | e26bb71 | 2015-06-30 13:51:51 +0530 | [diff] [blame] | 591 | pstrDisconnectNotifInfo->ie_len, false, |
| 592 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 593 | |
| 594 | } |
| 595 | |
| 596 | } |
| 597 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 598 | static int set_channel(struct wiphy *wiphy, |
| 599 | struct cfg80211_chan_def *chandef) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 600 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 601 | u32 channelnum = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 602 | struct wilc_priv *priv; |
Chaehyun Lim | dd739ea | 2015-10-02 16:41:20 +0900 | [diff] [blame] | 603 | int result = 0; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 604 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 605 | priv = wiphy_priv(wiphy); |
| 606 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 607 | channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); |
| 608 | PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 609 | |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 610 | curr_channel = channelnum; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 611 | result = wilc_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 612 | |
Chaehyun Lim | dd739ea | 2015-10-02 16:41:20 +0900 | [diff] [blame] | 613 | if (result != 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 614 | PRINT_ER("Error in setting channel %d\n", channelnum); |
| 615 | |
Chaehyun Lim | dd739ea | 2015-10-02 16:41:20 +0900 | [diff] [blame] | 616 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 617 | } |
| 618 | |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 619 | static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 620 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 621 | struct wilc_priv *priv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 622 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 623 | s32 s32Error = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 624 | u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS]; |
Leo Kim | 607db44 | 2015-10-05 15:25:37 +0900 | [diff] [blame] | 625 | struct hidden_network strHiddenNetwork; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 626 | |
| 627 | priv = wiphy_priv(wiphy); |
| 628 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 629 | priv->pstrScanReq = request; |
| 630 | |
| 631 | priv->u32RcvdChCount = 0; |
| 632 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 633 | wilc_set_wfi_drv_handler(priv->hWILCWFIDrv); |
Leo Kim | 12b0138 | 2015-11-19 15:56:27 +0900 | [diff] [blame] | 634 | reset_shadow_found(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 635 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 636 | priv->bCfgScanning = true; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 637 | if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 638 | for (i = 0; i < request->n_channels; i++) { |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 639 | au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 640 | PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]); |
| 641 | } |
| 642 | |
| 643 | PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels); |
Sudip Mukherjee | 52db7520 | 2015-06-02 14:28:17 +0530 | [diff] [blame] | 644 | PRINT_D(CFG80211_DBG, "Scan Request IE len = %zu\n", request->ie_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 645 | |
| 646 | PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids); |
| 647 | |
| 648 | if (request->n_ssids >= 1) { |
| 649 | |
| 650 | |
Leo Kim | 607db44 | 2015-10-05 15:25:37 +0900 | [diff] [blame] | 651 | strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 652 | strHiddenNetwork.u8ssidnum = request->n_ssids; |
| 653 | |
| 654 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 655 | for (i = 0; i < request->n_ssids; i++) { |
| 656 | |
| 657 | if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 658 | strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 659 | memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 660 | strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len; |
| 661 | } else { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 662 | PRINT_D(CFG80211_DBG, "Received one NULL SSID\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 663 | strHiddenNetwork.u8ssidnum -= 1; |
| 664 | } |
| 665 | } |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 666 | PRINT_D(CFG80211_DBG, "Trigger Scan Request\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 667 | s32Error = wilc_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 668 | au8ScanChanList, request->n_channels, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 669 | (const u8 *)request->ie, request->ie_len, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 670 | CfgScanResult, (void *)priv, &strHiddenNetwork); |
| 671 | } else { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 672 | PRINT_D(CFG80211_DBG, "Trigger Scan Request\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 673 | s32Error = wilc_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 674 | au8ScanChanList, request->n_channels, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 675 | (const u8 *)request->ie, request->ie_len, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 676 | CfgScanResult, (void *)priv, NULL); |
| 677 | } |
| 678 | |
| 679 | } else { |
| 680 | PRINT_ER("Requested num of scanned channels is greater than the max, supported" |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 681 | " channels\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 682 | } |
| 683 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 684 | if (s32Error != 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 685 | s32Error = -EBUSY; |
| 686 | PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error); |
| 687 | } |
| 688 | |
| 689 | return s32Error; |
| 690 | } |
| 691 | |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 692 | static int connect(struct wiphy *wiphy, struct net_device *dev, |
| 693 | struct cfg80211_connect_params *sme) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 694 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 695 | s32 s32Error = 0; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 696 | u32 i; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 697 | u8 u8security = NO_ENCRYPT; |
Leo Kim | 841dfc4 | 2015-10-05 15:25:39 +0900 | [diff] [blame] | 698 | enum AUTHTYPE tenuAuth_type = ANY; |
Dean Lee | 576917a | 2015-06-15 11:58:57 +0900 | [diff] [blame] | 699 | char *pcgroup_encrypt_val = NULL; |
| 700 | char *pccipher_group = NULL; |
| 701 | char *pcwpa_version = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 702 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 703 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 704 | struct host_if_drv *pstrWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 705 | tstrNetworkInfo *pstrNetworkInfo = NULL; |
| 706 | |
| 707 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 708 | wilc_connecting = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 709 | priv = wiphy_priv(wiphy); |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 710 | pstrWFIDrv = (struct host_if_drv *)(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 711 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 712 | wilc_set_wfi_drv_handler(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 713 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 714 | PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%p]\n", sme->ssid, dev, priv->hWILCWFIDrv); |
Chaehyun Lim | 3f88289 | 2015-08-10 11:33:17 +0900 | [diff] [blame] | 715 | if (!(strncmp(sme->ssid, "DIRECT-", 7))) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 716 | PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n"); |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 717 | pstrWFIDrv->p2p_connect = 1; |
| 718 | } else { |
| 719 | pstrWFIDrv->p2p_connect = 0; |
| 720 | } |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 721 | PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d\n", sme->ssid, sme->auth_type); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 722 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 723 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 724 | if ((sme->ssid_len == last_scanned_shadow[i].u8SsidLen) && |
| 725 | memcmp(last_scanned_shadow[i].au8ssid, |
| 726 | sme->ssid, |
| 727 | sme->ssid_len) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 728 | PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid); |
| 729 | if (sme->bssid == NULL) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 730 | PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n"); |
| 731 | break; |
| 732 | } else { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 733 | if (memcmp(last_scanned_shadow[i].au8bssid, |
| 734 | sme->bssid, |
| 735 | ETH_ALEN) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 736 | PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n"); |
| 737 | break; |
| 738 | } |
| 739 | } |
| 740 | } |
| 741 | } |
| 742 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 743 | if (i < last_scanned_cnt) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 744 | PRINT_D(CFG80211_DBG, "Required bss is in scan results\n"); |
| 745 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 746 | pstrNetworkInfo = &last_scanned_shadow[i]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 747 | |
| 748 | PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n", |
| 749 | pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1], |
| 750 | pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3], |
| 751 | pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]); |
| 752 | } else { |
| 753 | s32Error = -ENOENT; |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 754 | if (last_scanned_cnt == 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 755 | PRINT_D(CFG80211_DBG, "No Scan results yet\n"); |
| 756 | else |
| 757 | PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error); |
| 758 | |
| 759 | goto done; |
| 760 | } |
| 761 | |
| 762 | priv->WILC_WFI_wep_default = 0; |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 763 | memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key)); |
| 764 | 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] | 765 | |
| 766 | PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions); |
| 767 | PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group); |
| 768 | |
| 769 | PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise); |
| 770 | |
| 771 | if (INFO) { |
| 772 | for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) |
| 773 | PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]); |
| 774 | } |
| 775 | |
| 776 | if (sme->crypto.cipher_group != NO_ENCRYPT) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 777 | pcwpa_version = "Default"; |
| 778 | PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 779 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 780 | u8security = ENCRYPT_ENABLED | WEP; |
| 781 | pcgroup_encrypt_val = "WEP40"; |
| 782 | pccipher_group = "WLAN_CIPHER_SUITE_WEP40"; |
| 783 | PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx); |
| 784 | |
| 785 | if (INFO) { |
| 786 | for (i = 0; i < sme->key_len; i++) |
| 787 | PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]); |
| 788 | } |
| 789 | priv->WILC_WFI_wep_default = sme->key_idx; |
| 790 | priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 791 | 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] | 792 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 793 | g_key_wep_params.key_len = sme->key_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 794 | g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 795 | memcpy(g_key_wep_params.key, sme->key, sme->key_len); |
| 796 | g_key_wep_params.key_idx = sme->key_idx; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 797 | g_wep_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 798 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 799 | wilc_set_wep_default_keyid(priv->hWILCWFIDrv, sme->key_idx); |
| 800 | wilc_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 801 | } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 802 | u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; |
| 803 | pcgroup_encrypt_val = "WEP104"; |
| 804 | pccipher_group = "WLAN_CIPHER_SUITE_WEP104"; |
| 805 | |
| 806 | priv->WILC_WFI_wep_default = sme->key_idx; |
| 807 | priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 808 | 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] | 809 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 810 | g_key_wep_params.key_len = sme->key_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 811 | g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 812 | memcpy(g_key_wep_params.key, sme->key, sme->key_len); |
| 813 | g_key_wep_params.key_idx = sme->key_idx; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 814 | g_wep_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 815 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 816 | wilc_set_wep_default_keyid(priv->hWILCWFIDrv, sme->key_idx); |
| 817 | wilc_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 818 | } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 819 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 820 | u8security = ENCRYPT_ENABLED | WPA2 | TKIP; |
| 821 | pcgroup_encrypt_val = "WPA2_TKIP"; |
| 822 | pccipher_group = "TKIP"; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 823 | } else { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 824 | u8security = ENCRYPT_ENABLED | WPA2 | AES; |
| 825 | pcgroup_encrypt_val = "WPA2_AES"; |
| 826 | pccipher_group = "AES"; |
| 827 | } |
| 828 | pcwpa_version = "WPA_VERSION_2"; |
| 829 | } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) { |
| 830 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 831 | u8security = ENCRYPT_ENABLED | WPA | TKIP; |
| 832 | pcgroup_encrypt_val = "WPA_TKIP"; |
| 833 | pccipher_group = "TKIP"; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 834 | } else { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 835 | u8security = ENCRYPT_ENABLED | WPA | AES; |
| 836 | pcgroup_encrypt_val = "WPA_AES"; |
| 837 | pccipher_group = "AES"; |
| 838 | |
| 839 | } |
| 840 | pcwpa_version = "WPA_VERSION_1"; |
| 841 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 842 | } else { |
| 843 | s32Error = -ENOTSUPP; |
| 844 | PRINT_ER("Not supported cipher: Error(%d)\n", s32Error); |
| 845 | |
| 846 | goto done; |
| 847 | } |
| 848 | |
| 849 | } |
| 850 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 851 | if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) |
| 852 | || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) { |
| 853 | for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) { |
| 854 | if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) { |
| 855 | u8security = u8security | TKIP; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 856 | } else { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 857 | u8security = u8security | AES; |
| 858 | } |
| 859 | } |
| 860 | } |
| 861 | |
| 862 | PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group); |
| 863 | |
| 864 | PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type); |
| 865 | switch (sme->auth_type) { |
| 866 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
| 867 | PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n"); |
| 868 | tenuAuth_type = OPEN_SYSTEM; |
| 869 | break; |
| 870 | |
| 871 | case NL80211_AUTHTYPE_SHARED_KEY: |
| 872 | tenuAuth_type = SHARED_KEY; |
| 873 | PRINT_D(CFG80211_DBG, "In SHARED KEY\n"); |
| 874 | break; |
| 875 | |
| 876 | default: |
| 877 | PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type); |
| 878 | } |
| 879 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 880 | if (sme->crypto.n_akm_suites) { |
| 881 | switch (sme->crypto.akm_suites[0]) { |
| 882 | case WLAN_AKM_SUITE_8021X: |
| 883 | tenuAuth_type = IEEE8021; |
| 884 | break; |
| 885 | |
| 886 | default: |
| 887 | break; |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | |
| 892 | PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel); |
| 893 | |
| 894 | PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n", |
| 895 | pcgroup_encrypt_val, pccipher_group, pcwpa_version); |
| 896 | |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 897 | curr_channel = pstrNetworkInfo->u8channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 898 | |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 899 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 900 | wlan_channel = pstrNetworkInfo->u8channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 901 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 902 | wilc_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 903 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 904 | s32Error = wilc_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 905 | sme->ssid_len, sme->ie, sme->ie_len, |
| 906 | CfgConnectResult, (void *)priv, u8security, |
| 907 | tenuAuth_type, pstrNetworkInfo->u8channel, |
| 908 | pstrNetworkInfo->pJoinParams); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 909 | if (s32Error != 0) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 910 | PRINT_ER("wilc_set_join_req(): Error(%d)\n", s32Error); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 911 | s32Error = -ENOENT; |
| 912 | goto done; |
| 913 | } |
| 914 | |
| 915 | done: |
| 916 | |
| 917 | return s32Error; |
| 918 | } |
| 919 | |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 920 | 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] | 921 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 922 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 923 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 924 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 925 | u8 NullBssid[ETH_ALEN] = {0}; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 926 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 927 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 928 | priv = wiphy_priv(wiphy); |
| 929 | |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 930 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 931 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 932 | wlan_channel = INVALID_CHANNEL; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 933 | wilc_wlan_set_bssid(priv->dev, NullBssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 934 | |
| 935 | PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code); |
| 936 | |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 937 | p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 938 | p2p_recv_random = 0x00; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 939 | wilc_ie = false; |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 940 | pstrWFIDrv->p2p_timeout = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 941 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 942 | s32Error = wilc_disconnect(priv->hWILCWFIDrv, reason_code); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 943 | if (s32Error != 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 944 | PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error); |
| 945 | s32Error = -EINVAL; |
| 946 | } |
| 947 | |
| 948 | return s32Error; |
| 949 | } |
| 950 | |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 951 | static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 952 | bool pairwise, |
| 953 | const u8 *mac_addr, struct key_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 954 | |
| 955 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 956 | s32 s32Error = 0, KeyLen = params->key_len; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 957 | u32 i; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 958 | struct wilc_priv *priv; |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 959 | const u8 *pu8RxMic = NULL; |
| 960 | const u8 *pu8TxMic = NULL; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 961 | u8 u8mode = NO_ENCRYPT; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 962 | u8 u8gmode = NO_ENCRYPT; |
| 963 | u8 u8pmode = NO_ENCRYPT; |
Leo Kim | 841dfc4 | 2015-10-05 15:25:39 +0900 | [diff] [blame] | 964 | enum AUTHTYPE tenuAuth_type = ANY; |
Glen Lee | 7646920 | 2015-10-20 17:13:59 +0900 | [diff] [blame] | 965 | struct wilc *wl; |
| 966 | perInterface_wlan_t *nic; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 967 | |
| 968 | priv = wiphy_priv(wiphy); |
Glen Lee | 7646920 | 2015-10-20 17:13:59 +0900 | [diff] [blame] | 969 | nic = netdev_priv(netdev); |
| 970 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 971 | |
| 972 | PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher); |
| 973 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 974 | PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 975 | |
| 976 | PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0], |
| 977 | params->key[1], |
| 978 | params->key[2]); |
| 979 | |
| 980 | |
| 981 | switch (params->cipher) { |
| 982 | case WLAN_CIPHER_SUITE_WEP40: |
| 983 | case WLAN_CIPHER_SUITE_WEP104: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 984 | if (priv->wdev->iftype == NL80211_IFTYPE_AP) { |
| 985 | |
| 986 | priv->WILC_WFI_wep_default = key_index; |
| 987 | priv->WILC_WFI_wep_key_len[key_index] = params->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 988 | 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] | 989 | |
| 990 | PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index); |
| 991 | PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len); |
| 992 | |
| 993 | for (i = 0; i < params->key_len; i++) |
| 994 | PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]); |
| 995 | |
| 996 | tenuAuth_type = OPEN_SYSTEM; |
| 997 | |
| 998 | if (params->cipher == WLAN_CIPHER_SUITE_WEP40) |
| 999 | u8mode = ENCRYPT_ENABLED | WEP; |
| 1000 | else |
| 1001 | u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; |
| 1002 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1003 | wilc_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1004 | break; |
| 1005 | } |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1006 | 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] | 1007 | priv->WILC_WFI_wep_default = key_index; |
| 1008 | priv->WILC_WFI_wep_key_len[key_index] = params->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1009 | 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] | 1010 | |
| 1011 | PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index); |
| 1012 | PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len); |
| 1013 | if (INFO) { |
| 1014 | for (i = 0; i < params->key_len; i++) |
| 1015 | PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]); |
| 1016 | } |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1017 | wilc_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1018 | } |
| 1019 | |
| 1020 | break; |
| 1021 | |
| 1022 | case WLAN_CIPHER_SUITE_TKIP: |
| 1023 | case WLAN_CIPHER_SUITE_CCMP: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1024 | if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) { |
| 1025 | |
| 1026 | if (priv->wilc_gtk[key_index] == NULL) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1027 | 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] | 1028 | priv->wilc_gtk[key_index]->key = NULL; |
| 1029 | priv->wilc_gtk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1030 | |
| 1031 | } |
| 1032 | if (priv->wilc_ptk[key_index] == NULL) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1033 | 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] | 1034 | priv->wilc_ptk[key_index]->key = NULL; |
| 1035 | priv->wilc_ptk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | |
| 1039 | |
Daniel Machon | 1913221 | 2015-08-05 08:18:31 +0200 | [diff] [blame] | 1040 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1041 | if (params->cipher == WLAN_CIPHER_SUITE_TKIP) |
| 1042 | u8gmode = ENCRYPT_ENABLED | WPA | TKIP; |
| 1043 | else |
| 1044 | u8gmode = ENCRYPT_ENABLED | WPA2 | AES; |
| 1045 | |
| 1046 | priv->wilc_groupkey = u8gmode; |
| 1047 | |
| 1048 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1049 | |
| 1050 | pu8TxMic = params->key + 24; |
| 1051 | pu8RxMic = params->key + 16; |
| 1052 | KeyLen = params->key_len - 16; |
| 1053 | } |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1054 | kfree(priv->wilc_gtk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1055 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1056 | priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1057 | memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len); |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1058 | kfree(priv->wilc_gtk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1059 | |
| 1060 | if ((params->seq_len) > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1061 | priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1062 | memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1063 | } |
| 1064 | |
| 1065 | priv->wilc_gtk[key_index]->cipher = params->cipher; |
| 1066 | priv->wilc_gtk[key_index]->key_len = params->key_len; |
| 1067 | priv->wilc_gtk[key_index]->seq_len = params->seq_len; |
| 1068 | |
| 1069 | if (INFO) { |
| 1070 | for (i = 0; i < params->key_len; i++) |
| 1071 | PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]); |
| 1072 | for (i = 0; i < params->seq_len; i++) |
| 1073 | PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); |
| 1074 | } |
| 1075 | |
| 1076 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1077 | wilc_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1078 | key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode); |
| 1079 | |
| 1080 | } else { |
| 1081 | PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]); |
| 1082 | |
| 1083 | if (params->cipher == WLAN_CIPHER_SUITE_TKIP) |
| 1084 | u8pmode = ENCRYPT_ENABLED | WPA | TKIP; |
| 1085 | else |
| 1086 | u8pmode = priv->wilc_groupkey | AES; |
| 1087 | |
| 1088 | |
| 1089 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1090 | |
| 1091 | pu8TxMic = params->key + 24; |
| 1092 | pu8RxMic = params->key + 16; |
| 1093 | KeyLen = params->key_len - 16; |
| 1094 | } |
| 1095 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1096 | kfree(priv->wilc_ptk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1097 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1098 | priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1099 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1100 | kfree(priv->wilc_ptk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1101 | |
| 1102 | if ((params->seq_len) > 0) |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1103 | priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1104 | |
| 1105 | if (INFO) { |
| 1106 | for (i = 0; i < params->key_len; i++) |
| 1107 | PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]); |
| 1108 | |
| 1109 | for (i = 0; i < params->seq_len; i++) |
| 1110 | PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); |
| 1111 | } |
| 1112 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1113 | memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1114 | |
| 1115 | if ((params->seq_len) > 0) |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1116 | memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1117 | |
| 1118 | priv->wilc_ptk[key_index]->cipher = params->cipher; |
| 1119 | priv->wilc_ptk[key_index]->key_len = params->key_len; |
| 1120 | priv->wilc_ptk[key_index]->seq_len = params->seq_len; |
| 1121 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1122 | wilc_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1123 | pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index); |
| 1124 | } |
| 1125 | break; |
| 1126 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1127 | |
| 1128 | { |
| 1129 | u8mode = 0; |
Daniel Machon | 1913221 | 2015-08-05 08:18:31 +0200 | [diff] [blame] | 1130 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1131 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1132 | pu8RxMic = params->key + 24; |
| 1133 | pu8TxMic = params->key + 16; |
| 1134 | KeyLen = params->key_len - 16; |
| 1135 | } |
| 1136 | |
Glen Lee | 7646920 | 2015-10-20 17:13:59 +0900 | [diff] [blame] | 1137 | if (!g_gtk_keys_saved && netdev == wl->vif[0].ndev) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1138 | g_add_gtk_key_params.key_idx = key_index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1139 | g_add_gtk_key_params.pairwise = pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1140 | if (!mac_addr) { |
| 1141 | g_add_gtk_key_params.mac_addr = NULL; |
| 1142 | } else { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1143 | g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1144 | memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN); |
| 1145 | } |
| 1146 | g_key_gtk_params.key_len = params->key_len; |
| 1147 | g_key_gtk_params.seq_len = params->seq_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1148 | g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1149 | memcpy(g_key_gtk_params.key, params->key, params->key_len); |
| 1150 | if (params->seq_len > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1151 | g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1152 | memcpy(g_key_gtk_params.seq, params->seq, params->seq_len); |
| 1153 | } |
| 1154 | g_key_gtk_params.cipher = params->cipher; |
| 1155 | |
| 1156 | PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0], |
| 1157 | g_key_gtk_params.key[1], |
| 1158 | g_key_gtk_params.key[2]); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1159 | g_gtk_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1160 | } |
| 1161 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1162 | wilc_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1163 | key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1164 | } else { |
| 1165 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1166 | pu8RxMic = params->key + 24; |
| 1167 | pu8TxMic = params->key + 16; |
| 1168 | KeyLen = params->key_len - 16; |
| 1169 | } |
| 1170 | |
Glen Lee | 7646920 | 2015-10-20 17:13:59 +0900 | [diff] [blame] | 1171 | if (!g_ptk_keys_saved && netdev == wl->vif[0].ndev) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1172 | g_add_ptk_key_params.key_idx = key_index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1173 | g_add_ptk_key_params.pairwise = pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1174 | if (!mac_addr) { |
| 1175 | g_add_ptk_key_params.mac_addr = NULL; |
| 1176 | } else { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1177 | g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1178 | memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN); |
| 1179 | } |
| 1180 | g_key_ptk_params.key_len = params->key_len; |
| 1181 | g_key_ptk_params.seq_len = params->seq_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1182 | g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1183 | memcpy(g_key_ptk_params.key, params->key, params->key_len); |
| 1184 | if (params->seq_len > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1185 | g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1186 | memcpy(g_key_ptk_params.seq, params->seq, params->seq_len); |
| 1187 | } |
| 1188 | g_key_ptk_params.cipher = params->cipher; |
| 1189 | |
| 1190 | PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0], |
| 1191 | g_key_ptk_params.key[1], |
| 1192 | g_key_ptk_params.key[2]); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1193 | g_ptk_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1194 | } |
| 1195 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1196 | wilc_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1197 | pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index); |
| 1198 | PRINT_D(CFG80211_DBG, "Adding pairwise key\n"); |
| 1199 | if (INFO) { |
| 1200 | for (i = 0; i < params->key_len; i++) |
| 1201 | PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]); |
| 1202 | } |
| 1203 | } |
| 1204 | } |
| 1205 | break; |
| 1206 | |
| 1207 | default: |
| 1208 | PRINT_ER("Not supported cipher: Error(%d)\n", s32Error); |
| 1209 | s32Error = -ENOTSUPP; |
| 1210 | |
| 1211 | } |
| 1212 | |
| 1213 | return s32Error; |
| 1214 | } |
| 1215 | |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 1216 | static int del_key(struct wiphy *wiphy, struct net_device *netdev, |
| 1217 | u8 key_index, |
| 1218 | bool pairwise, |
| 1219 | const u8 *mac_addr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1220 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1221 | struct wilc_priv *priv; |
Glen Lee | 692e2ac | 2015-10-20 17:14:00 +0900 | [diff] [blame] | 1222 | struct wilc *wl; |
| 1223 | perInterface_wlan_t *nic; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1224 | |
| 1225 | priv = wiphy_priv(wiphy); |
Glen Lee | 692e2ac | 2015-10-20 17:14:00 +0900 | [diff] [blame] | 1226 | nic = netdev_priv(netdev); |
| 1227 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1228 | |
Glen Lee | 692e2ac | 2015-10-20 17:14:00 +0900 | [diff] [blame] | 1229 | if (netdev == wl->vif[0].ndev) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1230 | g_ptk_keys_saved = false; |
| 1231 | g_gtk_keys_saved = false; |
| 1232 | g_wep_keys_saved = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1233 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1234 | kfree(g_key_wep_params.key); |
| 1235 | g_key_wep_params.key = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1236 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1237 | if ((priv->wilc_gtk[key_index]) != NULL) { |
| 1238 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1239 | kfree(priv->wilc_gtk[key_index]->key); |
| 1240 | priv->wilc_gtk[key_index]->key = NULL; |
| 1241 | kfree(priv->wilc_gtk[key_index]->seq); |
| 1242 | priv->wilc_gtk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1243 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1244 | kfree(priv->wilc_gtk[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1245 | priv->wilc_gtk[key_index] = NULL; |
| 1246 | |
| 1247 | } |
| 1248 | |
| 1249 | if ((priv->wilc_ptk[key_index]) != NULL) { |
| 1250 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1251 | kfree(priv->wilc_ptk[key_index]->key); |
| 1252 | priv->wilc_ptk[key_index]->key = NULL; |
| 1253 | kfree(priv->wilc_ptk[key_index]->seq); |
| 1254 | priv->wilc_ptk[key_index]->seq = NULL; |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1255 | kfree(priv->wilc_ptk[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1256 | priv->wilc_ptk[key_index] = NULL; |
| 1257 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1258 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1259 | kfree(g_key_ptk_params.key); |
| 1260 | g_key_ptk_params.key = NULL; |
| 1261 | kfree(g_key_ptk_params.seq); |
| 1262 | g_key_ptk_params.seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1263 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1264 | kfree(g_key_gtk_params.key); |
| 1265 | g_key_gtk_params.key = NULL; |
| 1266 | kfree(g_key_gtk_params.seq); |
| 1267 | g_key_gtk_params.seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1268 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1269 | wilc_set_machw_change_vir_if(netdev, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1270 | } |
| 1271 | |
| 1272 | if (key_index >= 0 && key_index <= 3) { |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 1273 | memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1274 | priv->WILC_WFI_wep_key_len[key_index] = 0; |
| 1275 | |
| 1276 | PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1277 | wilc_remove_wep_key(priv->hWILCWFIDrv, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1278 | } else { |
| 1279 | PRINT_D(CFG80211_DBG, "Removing all installed keys\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1280 | wilc_remove_key(priv->hWILCWFIDrv, mac_addr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1281 | } |
| 1282 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1283 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1284 | } |
| 1285 | |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 1286 | static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1287 | bool pairwise, |
| 1288 | 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] | 1289 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1290 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1291 | struct key_params key_params; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1292 | u32 i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1293 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1294 | priv = wiphy_priv(wiphy); |
| 1295 | |
| 1296 | |
Alison Schofield | 3604af5 | 2015-10-12 13:22:44 -0700 | [diff] [blame] | 1297 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1298 | PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index); |
| 1299 | |
| 1300 | key_params.key = priv->wilc_gtk[key_index]->key; |
| 1301 | key_params.cipher = priv->wilc_gtk[key_index]->cipher; |
| 1302 | key_params.key_len = priv->wilc_gtk[key_index]->key_len; |
| 1303 | key_params.seq = priv->wilc_gtk[key_index]->seq; |
| 1304 | key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; |
| 1305 | if (INFO) { |
| 1306 | for (i = 0; i < key_params.key_len; i++) |
| 1307 | PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]); |
| 1308 | } |
| 1309 | } else { |
| 1310 | PRINT_D(CFG80211_DBG, "Getting pairwise key\n"); |
| 1311 | |
| 1312 | key_params.key = priv->wilc_ptk[key_index]->key; |
| 1313 | key_params.cipher = priv->wilc_ptk[key_index]->cipher; |
| 1314 | key_params.key_len = priv->wilc_ptk[key_index]->key_len; |
| 1315 | key_params.seq = priv->wilc_ptk[key_index]->seq; |
| 1316 | key_params.seq_len = priv->wilc_ptk[key_index]->seq_len; |
| 1317 | } |
| 1318 | |
| 1319 | callback(cookie, &key_params); |
| 1320 | |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 1321 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1322 | } |
| 1323 | |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 1324 | static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1325 | bool unicast, bool multicast) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1326 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1327 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1328 | |
| 1329 | |
| 1330 | priv = wiphy_priv(wiphy); |
| 1331 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 1332 | PRINT_D(CFG80211_DBG, "Setting default key with idx = %d\n", key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1333 | |
| 1334 | if (key_index != priv->WILC_WFI_wep_default) { |
| 1335 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1336 | wilc_set_wep_default_keyid(priv->hWILCWFIDrv, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1337 | } |
| 1338 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1339 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1340 | } |
| 1341 | |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 1342 | static int get_station(struct wiphy *wiphy, struct net_device *dev, |
| 1343 | const u8 *mac, struct station_info *sinfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1344 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1345 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1346 | perInterface_wlan_t *nic; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1347 | u32 i = 0; |
| 1348 | u32 associatedsta = 0; |
| 1349 | u32 inactive_time = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1350 | priv = wiphy_priv(wiphy); |
| 1351 | nic = netdev_priv(dev); |
| 1352 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1353 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
| 1354 | PRINT_D(HOSTAPD_DBG, "Getting station parameters\n"); |
| 1355 | |
| 1356 | PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]); |
| 1357 | |
| 1358 | for (i = 0; i < NUM_STA_ASSOCIATED; i++) { |
| 1359 | |
| 1360 | if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) { |
| 1361 | associatedsta = i; |
| 1362 | break; |
| 1363 | } |
| 1364 | |
| 1365 | } |
| 1366 | |
| 1367 | if (associatedsta == -1) { |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1368 | PRINT_ER("Station required is not associated\n"); |
| 1369 | return -ENOENT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1370 | } |
| 1371 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1372 | sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1373 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1374 | wilc_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1375 | sinfo->inactive_time = 1000 * inactive_time; |
| 1376 | PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time); |
| 1377 | |
| 1378 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1379 | |
| 1380 | if (nic->iftype == STATION_MODE) { |
Leo Kim | 03e7b9c | 2015-10-12 16:55:58 +0900 | [diff] [blame] | 1381 | struct rf_info strStatistics; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1382 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1383 | wilc_get_statistics(priv->hWILCWFIDrv, &strStatistics); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1384 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1385 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) | |
Chandra S Gorentla | 6212990 | 2015-08-05 22:11:57 +0530 | [diff] [blame] | 1386 | BIT(NL80211_STA_INFO_RX_PACKETS) | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1387 | BIT(NL80211_STA_INFO_TX_PACKETS) | |
| 1388 | BIT(NL80211_STA_INFO_TX_FAILED) | |
| 1389 | BIT(NL80211_STA_INFO_TX_BITRATE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1390 | |
Leo Kim | 00c8dfc | 2015-10-29 12:05:30 +0900 | [diff] [blame] | 1391 | sinfo->signal = strStatistics.rssi; |
Leo Kim | 9b99274 | 2015-10-29 12:05:32 +0900 | [diff] [blame] | 1392 | sinfo->rx_packets = strStatistics.rx_cnt; |
Leo Kim | 5416037 | 2015-10-29 12:05:33 +0900 | [diff] [blame] | 1393 | sinfo->tx_packets = strStatistics.tx_cnt + strStatistics.tx_fail_cnt; |
| 1394 | sinfo->tx_failed = strStatistics.tx_fail_cnt; |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1395 | sinfo->txrate.legacy = strStatistics.link_speed * 10; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1396 | |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1397 | if ((strStatistics.link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && |
| 1398 | (strStatistics.link_speed != DEFAULT_LINK_SPEED)) |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1399 | wilc_enable_tcp_ack_filter(true); |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1400 | else if (strStatistics.link_speed != DEFAULT_LINK_SPEED) |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1401 | wilc_enable_tcp_ack_filter(false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1402 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1403 | PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets, |
| 1404 | sinfo->tx_failed, sinfo->txrate.legacy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1405 | } |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1406 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1407 | } |
| 1408 | |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 1409 | static int change_bss(struct wiphy *wiphy, struct net_device *dev, |
| 1410 | struct bss_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1411 | { |
| 1412 | PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n"); |
| 1413 | return 0; |
| 1414 | } |
| 1415 | |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 1416 | static int set_wiphy_params(struct wiphy *wiphy, u32 changed) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1417 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1418 | s32 s32Error = 0; |
Leo Kim | 9529650 | 2015-10-05 15:25:46 +0900 | [diff] [blame] | 1419 | struct cfg_param_val pstrCfgParamVal; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1420 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1421 | |
| 1422 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1423 | |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1424 | pstrCfgParamVal.flag = 0; |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 1425 | PRINT_D(CFG80211_DBG, "Setting Wiphy params\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1426 | |
| 1427 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 1428 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n", |
| 1429 | priv->dev->ieee80211_ptr->wiphy->retry_short); |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1430 | pstrCfgParamVal.flag |= RETRY_SHORT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1431 | pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short; |
| 1432 | } |
| 1433 | if (changed & WIPHY_PARAM_RETRY_LONG) { |
| 1434 | |
| 1435 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long); |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1436 | pstrCfgParamVal.flag |= RETRY_LONG; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1437 | pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long; |
| 1438 | |
| 1439 | } |
| 1440 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 1441 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold); |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1442 | pstrCfgParamVal.flag |= FRAG_THRESHOLD; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1443 | pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold; |
| 1444 | |
| 1445 | } |
| 1446 | |
| 1447 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
| 1448 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold); |
| 1449 | |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1450 | pstrCfgParamVal.flag |= RTS_THRESHOLD; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1451 | pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold; |
| 1452 | |
| 1453 | } |
| 1454 | |
| 1455 | PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1456 | s32Error = wilc_hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1457 | if (s32Error) |
| 1458 | PRINT_ER("Error in setting WIPHY PARAMS\n"); |
| 1459 | |
| 1460 | |
| 1461 | return s32Error; |
| 1462 | } |
Arnd Bergmann | e5af056 | 2015-05-29 22:52:12 +0200 | [diff] [blame] | 1463 | |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 1464 | static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, |
| 1465 | struct cfg80211_pmksa *pmksa) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1466 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1467 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1468 | s32 s32Error = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1469 | u8 flag = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1470 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1471 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1472 | |
| 1473 | PRINT_D(CFG80211_DBG, "Setting PMKSA\n"); |
| 1474 | |
| 1475 | |
| 1476 | for (i = 0; i < priv->pmkid_list.numpmkid; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1477 | if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1478 | ETH_ALEN)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1479 | flag = PMKID_FOUND; |
| 1480 | PRINT_D(CFG80211_DBG, "PMKID already exists\n"); |
| 1481 | break; |
| 1482 | } |
| 1483 | } |
| 1484 | if (i < WILC_MAX_NUM_PMKIDS) { |
| 1485 | PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n"); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1486 | memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1487 | ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1488 | memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1489 | PMKID_LEN); |
| 1490 | if (!(flag == PMKID_FOUND)) |
| 1491 | priv->pmkid_list.numpmkid++; |
| 1492 | } else { |
| 1493 | PRINT_ER("Invalid PMKID index\n"); |
| 1494 | s32Error = -EINVAL; |
| 1495 | } |
| 1496 | |
| 1497 | if (!s32Error) { |
| 1498 | PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1499 | s32Error = wilc_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1500 | } |
| 1501 | return s32Error; |
| 1502 | } |
| 1503 | |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 1504 | static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, |
| 1505 | struct cfg80211_pmksa *pmksa) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1506 | { |
| 1507 | |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1508 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1509 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1510 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1511 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1512 | |
| 1513 | PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n"); |
| 1514 | |
| 1515 | for (i = 0; i < priv->pmkid_list.numpmkid; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1516 | if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1517 | ETH_ALEN)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1518 | PRINT_D(CFG80211_DBG, "Reseting PMKID values\n"); |
Leo Kim | cd1e6cb | 2015-10-05 15:25:45 +0900 | [diff] [blame] | 1519 | memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1520 | break; |
| 1521 | } |
| 1522 | } |
| 1523 | |
| 1524 | if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) { |
| 1525 | for (; i < (priv->pmkid_list.numpmkid - 1); i++) { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1526 | memcpy(priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1527 | priv->pmkid_list.pmkidlist[i + 1].bssid, |
| 1528 | ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1529 | memcpy(priv->pmkid_list.pmkidlist[i].pmkid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1530 | priv->pmkid_list.pmkidlist[i].pmkid, |
| 1531 | PMKID_LEN); |
| 1532 | } |
| 1533 | priv->pmkid_list.numpmkid--; |
| 1534 | } else { |
| 1535 | s32Error = -EINVAL; |
| 1536 | } |
| 1537 | |
| 1538 | return s32Error; |
| 1539 | } |
| 1540 | |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 1541 | static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1542 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1543 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1544 | |
| 1545 | PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n"); |
| 1546 | |
Leo Kim | a949f90 | 2015-10-05 15:25:44 +0900 | [diff] [blame] | 1547 | memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1548 | |
| 1549 | return 0; |
| 1550 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1551 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 1552 | static void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1553 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1554 | u32 index = 0; |
| 1555 | u32 i = 0, j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1556 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1557 | u8 op_channel_attr_index = 0; |
| 1558 | u8 channel_list_attr_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1559 | |
| 1560 | while (index < len) { |
| 1561 | if (buf[index] == GO_INTENT_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1562 | buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1563 | } |
| 1564 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1565 | if (buf[index] == CHANLIST_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1566 | channel_list_attr_index = index; |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1567 | else if (buf[index] == OPERCHAN_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1568 | op_channel_attr_index = index; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 1569 | index += buf[index + 1] + 3; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1570 | } |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1571 | if (wlan_channel != INVALID_CHANNEL) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1572 | if (channel_list_attr_index) { |
| 1573 | PRINT_D(GENERIC_DBG, "Modify channel list attribute\n"); |
| 1574 | for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { |
| 1575 | if (buf[i] == 0x51) { |
| 1576 | for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) { |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1577 | buf[j] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1578 | } |
| 1579 | break; |
| 1580 | } |
| 1581 | } |
| 1582 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 1583 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1584 | if (op_channel_attr_index) { |
| 1585 | PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n"); |
| 1586 | buf[op_channel_attr_index + 6] = 0x51; |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1587 | buf[op_channel_attr_index + 7] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1588 | } |
| 1589 | } |
| 1590 | } |
| 1591 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 1592 | 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] | 1593 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1594 | u32 index = 0; |
| 1595 | u32 i = 0, j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1596 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1597 | u8 op_channel_attr_index = 0; |
| 1598 | u8 channel_list_attr_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1599 | |
| 1600 | while (index < len) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1601 | if (buf[index] == GO_INTENT_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1602 | buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1603 | |
| 1604 | break; |
| 1605 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1606 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1607 | if (buf[index] == CHANLIST_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1608 | channel_list_attr_index = index; |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1609 | else if (buf[index] == OPERCHAN_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1610 | op_channel_attr_index = index; |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 1611 | index += buf[index + 1] + 3; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1612 | } |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1613 | if (wlan_channel != INVALID_CHANNEL && bOperChan) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1614 | if (channel_list_attr_index) { |
| 1615 | PRINT_D(GENERIC_DBG, "Modify channel list attribute\n"); |
| 1616 | for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { |
| 1617 | if (buf[i] == 0x51) { |
| 1618 | for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) { |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1619 | buf[j] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1620 | } |
| 1621 | break; |
| 1622 | } |
| 1623 | } |
| 1624 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 1625 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1626 | if (op_channel_attr_index) { |
| 1627 | PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n"); |
| 1628 | buf[op_channel_attr_index + 6] = 0x51; |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1629 | buf[op_channel_attr_index + 7] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1630 | } |
| 1631 | } |
| 1632 | } |
| 1633 | |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 1634 | 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] | 1635 | { |
| 1636 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1637 | struct wilc_priv *priv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1638 | u32 header, pkt_offset; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1639 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1640 | u32 i = 0; |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 1641 | s32 s32Freq; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1642 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1643 | priv = wiphy_priv(dev->ieee80211_ptr->wiphy); |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1644 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1645 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1646 | memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1647 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1648 | pkt_offset = GET_PKT_OFFSET(header); |
| 1649 | |
| 1650 | if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { |
| 1651 | if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) { |
| 1652 | PRINT_D(GENERIC_DBG, "Probe response ACK\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1653 | 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] | 1654 | return; |
| 1655 | } else { |
| 1656 | if (pkt_offset & IS_MGMT_STATUS_SUCCES) { |
| 1657 | PRINT_D(GENERIC_DBG, "Success Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID], |
| 1658 | buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1659 | 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] | 1660 | } else { |
| 1661 | PRINT_D(GENERIC_DBG, "Fail Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID], |
| 1662 | buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1663 | 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] | 1664 | } |
| 1665 | return; |
| 1666 | } |
| 1667 | } else { |
| 1668 | |
| 1669 | PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]); |
| 1670 | |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 1671 | s32Freq = ieee80211_channel_to_frequency(curr_channel, IEEE80211_BAND_2GHZ); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1672 | |
| 1673 | if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { |
| 1674 | PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]); |
| 1675 | |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1676 | if (priv->bCfgScanning && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->p2p_timeout)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1677 | PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n"); |
| 1678 | return; |
| 1679 | } |
| 1680 | if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { |
| 1681 | |
| 1682 | switch (buff[ACTION_SUBTYPE_ID]) { |
| 1683 | case GAS_INTIAL_REQ: |
| 1684 | PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]); |
| 1685 | break; |
| 1686 | |
| 1687 | case GAS_INTIAL_RSP: |
| 1688 | PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]); |
| 1689 | break; |
| 1690 | |
| 1691 | case PUBLIC_ACT_VENDORSPEC: |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 1692 | if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1693 | 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] | 1694 | if (!wilc_ie) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1695 | for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 1696 | if (!memcmp(p2p_vendor_spec, &buff[i], 6)) { |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1697 | p2p_recv_random = buff[i + 6]; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 1698 | wilc_ie = true; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1699 | PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", p2p_recv_random); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1700 | break; |
| 1701 | } |
| 1702 | } |
| 1703 | } |
| 1704 | } |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1705 | if (p2p_local_random > p2p_recv_random) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1706 | if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP |
| 1707 | || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) { |
| 1708 | for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) { |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 1709 | 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] | 1710 | WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6)); |
| 1711 | break; |
| 1712 | } |
| 1713 | } |
| 1714 | } |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 1715 | } else { |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1716 | PRINT_D(GENERIC_DBG, "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] | 1717 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1718 | } |
| 1719 | |
| 1720 | |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 1721 | 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] | 1722 | PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1723 | cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1724 | return; |
| 1725 | } |
| 1726 | break; |
| 1727 | |
| 1728 | default: |
| 1729 | PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]); |
| 1730 | break; |
| 1731 | } |
| 1732 | } |
| 1733 | } |
| 1734 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1735 | cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1736 | } |
| 1737 | } |
| 1738 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1739 | static void WILC_WFI_mgmt_tx_complete(void *priv, int status) |
| 1740 | { |
| 1741 | struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv; |
| 1742 | |
| 1743 | |
| 1744 | kfree(pv_data->buff); |
| 1745 | kfree(pv_data); |
| 1746 | } |
| 1747 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1748 | static void WILC_WFI_RemainOnChannelReady(void *pUserVoid) |
| 1749 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1750 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1751 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1752 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1753 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 1754 | PRINT_D(HOSTINF_DBG, "Remain on channel ready\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1755 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1756 | priv->bInP2PlistenState = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1757 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1758 | cfg80211_ready_on_channel(priv->wdev, |
| 1759 | priv->strRemainOnChanParams.u64ListenCookie, |
| 1760 | priv->strRemainOnChanParams.pstrListenChan, |
| 1761 | priv->strRemainOnChanParams.u32ListenDuration, |
| 1762 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1763 | } |
| 1764 | |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1765 | static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1766 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1767 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1768 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1769 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1770 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1771 | if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 1772 | PRINT_D(GENERIC_DBG, "Remain on channel expired\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1773 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1774 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1775 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1776 | cfg80211_remain_on_channel_expired(priv->wdev, |
| 1777 | priv->strRemainOnChanParams.u64ListenCookie, |
| 1778 | priv->strRemainOnChanParams.pstrListenChan, |
| 1779 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1780 | } else { |
| 1781 | PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID |
| 1782 | , priv->strRemainOnChanParams.u32ListenSessionID); |
| 1783 | } |
| 1784 | } |
| 1785 | |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 1786 | static int remain_on_channel(struct wiphy *wiphy, |
| 1787 | struct wireless_dev *wdev, |
| 1788 | struct ieee80211_channel *chan, |
| 1789 | unsigned int duration, u64 *cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1790 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1791 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1792 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1793 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1794 | priv = wiphy_priv(wiphy); |
| 1795 | |
| 1796 | PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value); |
| 1797 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1798 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1799 | if (wdev->iftype == NL80211_IFTYPE_AP) { |
| 1800 | PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode"); |
| 1801 | return s32Error; |
| 1802 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1803 | |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 1804 | curr_channel = chan->hw_value; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1805 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1806 | priv->strRemainOnChanParams.pstrListenChan = chan; |
| 1807 | priv->strRemainOnChanParams.u64ListenCookie = *cookie; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1808 | priv->strRemainOnChanParams.u32ListenDuration = duration; |
| 1809 | priv->strRemainOnChanParams.u32ListenSessionID++; |
| 1810 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1811 | s32Error = wilc_remain_on_channel(priv->hWILCWFIDrv |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1812 | , priv->strRemainOnChanParams.u32ListenSessionID |
| 1813 | , duration |
| 1814 | , chan->hw_value |
| 1815 | , WILC_WFI_RemainOnChannelExpired |
| 1816 | , WILC_WFI_RemainOnChannelReady |
| 1817 | , (void *)priv); |
| 1818 | |
| 1819 | return s32Error; |
| 1820 | } |
| 1821 | |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 1822 | static int cancel_remain_on_channel(struct wiphy *wiphy, |
| 1823 | struct wireless_dev *wdev, |
| 1824 | u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1825 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1826 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1827 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1828 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1829 | priv = wiphy_priv(wiphy); |
| 1830 | |
| 1831 | PRINT_D(CFG80211_DBG, "Cancel remain on channel\n"); |
| 1832 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1833 | s32Error = wilc_listen_state_expired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1834 | return s32Error; |
| 1835 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 1836 | |
Chaehyun Lim | c156032 | 2015-09-22 18:34:51 +0900 | [diff] [blame] | 1837 | static int mgmt_tx(struct wiphy *wiphy, |
| 1838 | struct wireless_dev *wdev, |
| 1839 | struct cfg80211_mgmt_tx_params *params, |
| 1840 | u64 *cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1841 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1842 | struct ieee80211_channel *chan = params->chan; |
| 1843 | unsigned int wait = params->wait; |
| 1844 | const u8 *buf = params->buf; |
| 1845 | size_t len = params->len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1846 | const struct ieee80211_mgmt *mgmt; |
| 1847 | struct p2p_mgmt_data *mgmt_tx; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1848 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1849 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1850 | u32 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1851 | perInterface_wlan_t *nic; |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 1852 | u32 buf_len = len + sizeof(p2p_vendor_spec) + sizeof(p2p_local_random); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1853 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1854 | nic = netdev_priv(wdev->netdev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1855 | priv = wiphy_priv(wiphy); |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1856 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1857 | |
| 1858 | *cookie = (unsigned long)buf; |
| 1859 | priv->u64tx_cookie = *cookie; |
| 1860 | mgmt = (const struct ieee80211_mgmt *) buf; |
| 1861 | |
| 1862 | if (ieee80211_is_mgmt(mgmt->frame_control)) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1863 | mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1864 | if (mgmt_tx == NULL) { |
| 1865 | PRINT_ER("Failed to allocate memory for mgmt_tx structure\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1866 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1867 | } |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1868 | mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1869 | if (mgmt_tx->buff == NULL) { |
| 1870 | PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); |
Tony Cho | f638dd3 | 2015-09-07 19:09:31 +0900 | [diff] [blame] | 1871 | kfree(mgmt_tx); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1872 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1873 | } |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1874 | memcpy(mgmt_tx->buff, buf, len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1875 | mgmt_tx->size = len; |
| 1876 | |
| 1877 | |
| 1878 | if (ieee80211_is_probe_resp(mgmt->frame_control)) { |
| 1879 | PRINT_D(GENERIC_DBG, "TX: Probe Response\n"); |
| 1880 | PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1881 | wilc_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value); |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 1882 | curr_channel = chan->hw_value; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1883 | } else if (ieee80211_is_action(mgmt->frame_control)) { |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 1884 | PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1885 | |
| 1886 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1887 | if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1888 | if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC || |
| 1889 | buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) { |
| 1890 | PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1891 | wilc_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value); |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 1892 | curr_channel = chan->hw_value; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1893 | } |
| 1894 | switch (buf[ACTION_SUBTYPE_ID]) { |
| 1895 | case GAS_INTIAL_REQ: |
| 1896 | { |
| 1897 | PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]); |
| 1898 | break; |
| 1899 | } |
| 1900 | |
| 1901 | case GAS_INTIAL_RSP: |
| 1902 | { |
| 1903 | PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]); |
| 1904 | break; |
| 1905 | } |
| 1906 | |
| 1907 | case PUBLIC_ACT_VENDORSPEC: |
| 1908 | { |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 1909 | if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1910 | 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] | 1911 | if (p2p_local_random == 1 && p2p_recv_random < p2p_local_random) { |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 1912 | get_random_bytes(&p2p_local_random, 1); |
| 1913 | p2p_local_random++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1914 | } |
| 1915 | } |
| 1916 | |
| 1917 | if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP |
| 1918 | || 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] | 1919 | if (p2p_local_random > p2p_recv_random) { |
| 1920 | PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random, p2p_recv_random); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1921 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1922 | for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) { |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 1923 | 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] | 1924 | if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP) |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1925 | WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1926 | else |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1927 | WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1928 | break; |
| 1929 | } |
| 1930 | } |
| 1931 | |
| 1932 | 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] | 1933 | memcpy(&mgmt_tx->buff[len], p2p_vendor_spec, sizeof(p2p_vendor_spec)); |
| 1934 | mgmt_tx->buff[len + sizeof(p2p_vendor_spec)] = p2p_local_random; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1935 | mgmt_tx->size = buf_len; |
| 1936 | } |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 1937 | } else { |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1938 | PRINT_D(GENERIC_DBG, "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] | 1939 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1940 | } |
| 1941 | |
| 1942 | } else { |
| 1943 | PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n"); |
| 1944 | } |
| 1945 | |
| 1946 | break; |
| 1947 | } |
| 1948 | |
| 1949 | default: |
| 1950 | { |
| 1951 | PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]); |
| 1952 | break; |
| 1953 | } |
| 1954 | } |
| 1955 | |
| 1956 | } |
| 1957 | |
| 1958 | PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value); |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1959 | pstrWFIDrv->p2p_timeout = (jiffies + msecs_to_jiffies(wait)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1960 | |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1961 | PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", |
| 1962 | jiffies, pstrWFIDrv->p2p_timeout); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1963 | } |
| 1964 | |
Glen Lee | 829c477 | 2015-10-29 12:18:44 +0900 | [diff] [blame] | 1965 | wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx, |
| 1966 | mgmt_tx->buff, mgmt_tx->size, |
Glen Lee | c9d4834 | 2015-10-01 16:03:43 +0900 | [diff] [blame] | 1967 | WILC_WFI_mgmt_tx_complete); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1968 | } else { |
| 1969 | PRINT_D(GENERIC_DBG, "This function transmits only management frames\n"); |
| 1970 | } |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1971 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1972 | } |
| 1973 | |
Chaehyun Lim | 85c587a | 2015-09-22 18:34:50 +0900 | [diff] [blame] | 1974 | static int mgmt_tx_cancel_wait(struct wiphy *wiphy, |
| 1975 | struct wireless_dev *wdev, |
| 1976 | u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1977 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1978 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1979 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1980 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1981 | priv = wiphy_priv(wiphy); |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1982 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1983 | |
| 1984 | |
| 1985 | PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies); |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1986 | pstrWFIDrv->p2p_timeout = jiffies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1987 | |
Luis de Bethencourt | 7e4e87d | 2015-10-16 16:32:26 +0100 | [diff] [blame] | 1988 | if (!priv->bInP2PlistenState) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1989 | cfg80211_remain_on_channel_expired(priv->wdev, |
| 1990 | priv->strRemainOnChanParams.u64ListenCookie, |
| 1991 | priv->strRemainOnChanParams.pstrListenChan, |
| 1992 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1993 | } |
| 1994 | |
| 1995 | return 0; |
| 1996 | } |
| 1997 | |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 1998 | void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 1999 | u16 frame_type, bool reg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2000 | { |
| 2001 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2002 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2003 | perInterface_wlan_t *nic; |
Glen Lee | 1b86935 | 2015-10-20 17:14:01 +0900 | [diff] [blame] | 2004 | struct wilc *wl; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2005 | |
| 2006 | priv = wiphy_priv(wiphy); |
| 2007 | nic = netdev_priv(priv->wdev->netdev); |
Glen Lee | 1b86935 | 2015-10-20 17:14:01 +0900 | [diff] [blame] | 2008 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2009 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2010 | if (!frame_type) |
| 2011 | return; |
| 2012 | |
| 2013 | PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg); |
| 2014 | switch (frame_type) { |
| 2015 | case PROBE_REQ: |
| 2016 | { |
| 2017 | nic->g_struct_frame_reg[0].frame_type = frame_type; |
| 2018 | nic->g_struct_frame_reg[0].reg = reg; |
| 2019 | } |
| 2020 | break; |
| 2021 | |
| 2022 | case ACTION: |
| 2023 | { |
| 2024 | nic->g_struct_frame_reg[1].frame_type = frame_type; |
| 2025 | nic->g_struct_frame_reg[1].reg = reg; |
| 2026 | } |
| 2027 | break; |
| 2028 | |
| 2029 | default: |
| 2030 | { |
| 2031 | break; |
| 2032 | } |
| 2033 | |
| 2034 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 2035 | |
Glen Lee | 1b86935 | 2015-10-20 17:14:01 +0900 | [diff] [blame] | 2036 | if (!wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2037 | PRINT_D(GENERIC_DBG, "Return since mac is closed\n"); |
| 2038 | return; |
| 2039 | } |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2040 | wilc_frame_register(priv->hWILCWFIDrv, frame_type, reg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2041 | |
| 2042 | |
| 2043 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2044 | |
Chaehyun Lim | a8047e2 | 2015-09-22 18:34:48 +0900 | [diff] [blame] | 2045 | static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev, |
| 2046 | s32 rssi_thold, u32 rssi_hyst) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2047 | { |
| 2048 | PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n"); |
| 2049 | return 0; |
| 2050 | |
| 2051 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 2052 | |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 2053 | static int dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 2054 | int idx, u8 *mac, struct station_info *sinfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2055 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2056 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2057 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2058 | PRINT_D(CFG80211_DBG, "Dumping station information\n"); |
| 2059 | |
| 2060 | if (idx != 0) |
| 2061 | return -ENOENT; |
| 2062 | |
| 2063 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2064 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2065 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2066 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2067 | wilc_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2068 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2069 | return 0; |
| 2070 | |
| 2071 | } |
| 2072 | |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 2073 | static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 2074 | bool enabled, int timeout) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2075 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2076 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2077 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2078 | PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout); |
| 2079 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 2080 | if (wiphy == NULL) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2081 | return -ENOENT; |
| 2082 | |
| 2083 | priv = wiphy_priv(wiphy); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 2084 | if (priv->hWILCWFIDrv == NULL) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2085 | PRINT_ER("Driver is NULL\n"); |
| 2086 | return -EIO; |
| 2087 | } |
| 2088 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2089 | if (wilc_enable_ps) |
| 2090 | wilc_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2091 | |
| 2092 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2093 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2094 | |
| 2095 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 2096 | |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 2097 | static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, |
| 2098 | enum nl80211_iftype type, u32 *flags, struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2099 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2100 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2101 | perInterface_wlan_t *nic; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2102 | u8 interface_type; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 2103 | u16 TID = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2104 | u8 i; |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2105 | struct wilc *wl; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2106 | |
| 2107 | nic = netdev_priv(dev); |
| 2108 | priv = wiphy_priv(wiphy); |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2109 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2110 | |
| 2111 | PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n"); |
| 2112 | PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name); |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 2113 | p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 2114 | p2p_recv_random = 0x00; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 2115 | wilc_ie = false; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2116 | wilc_optaining_ip = false; |
| 2117 | del_timer(&wilc_during_ip_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2118 | PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n"); |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 2119 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2120 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2121 | wilc_set_machw_change_vir_if(dev, true); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2122 | } |
| 2123 | |
| 2124 | switch (type) { |
| 2125 | case NL80211_IFTYPE_STATION: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2126 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2127 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2128 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2129 | dev->ieee80211_ptr->iftype = type; |
| 2130 | priv->wdev->iftype = type; |
| 2131 | nic->monitor_flag = 0; |
| 2132 | nic->iftype = STATION_MODE; |
| 2133 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2134 | memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2135 | interface_type = nic->iftype; |
| 2136 | nic->iftype = STATION_MODE; |
| 2137 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2138 | if (wl->initialized) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2139 | wilc_del_all_rx_ba_session(priv->hWILCWFIDrv, |
| 2140 | wl->vif[0].bssid, TID); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2141 | wilc_wait_msg_queue_idle(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2142 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2143 | up(&wl->cfg_event); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2144 | |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 2145 | wilc1000_wlan_deinit(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2146 | wilc1000_wlan_init(dev, nic); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2147 | wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2148 | nic->iftype = interface_type; |
| 2149 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2150 | wilc_set_wfi_drv_handler(wl->vif[0].hif_drv); |
| 2151 | wilc_set_mac_address(wl->vif[0].hif_drv, |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2152 | wl->vif[0].src_addr); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2153 | wilc_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2154 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2155 | if (g_wep_keys_saved) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2156 | wilc_set_wep_default_keyid(wl->vif[0].hif_drv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2157 | g_key_wep_params.key_idx); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2158 | wilc_add_wep_key_bss_sta(wl->vif[0].hif_drv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2159 | g_key_wep_params.key, |
| 2160 | g_key_wep_params.key_len, |
| 2161 | g_key_wep_params.key_idx); |
| 2162 | } |
| 2163 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2164 | wilc_flush_join_req(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2165 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2166 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2167 | PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], |
| 2168 | g_key_ptk_params.key[1], |
| 2169 | g_key_ptk_params.key[2]); |
| 2170 | PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], |
| 2171 | g_key_gtk_params.key[1], |
| 2172 | g_key_gtk_params.key[2]); |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2173 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2174 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2175 | g_add_ptk_key_params.key_idx, |
| 2176 | g_add_ptk_key_params.pairwise, |
| 2177 | g_add_ptk_key_params.mac_addr, |
| 2178 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2179 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2180 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2181 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2182 | g_add_gtk_key_params.key_idx, |
| 2183 | g_add_gtk_key_params.pairwise, |
| 2184 | g_add_gtk_key_params.mac_addr, |
| 2185 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2186 | } |
| 2187 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2188 | if (wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2189 | for (i = 0; i < num_reg_frame; i++) { |
| 2190 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2191 | nic->g_struct_frame_reg[i].reg); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2192 | wilc_frame_register(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2193 | nic->g_struct_frame_reg[i].frame_type, |
| 2194 | nic->g_struct_frame_reg[i].reg); |
| 2195 | } |
| 2196 | } |
| 2197 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2198 | wilc_enable_ps = true; |
| 2199 | wilc_set_power_mgmt(priv->hWILCWFIDrv, 1, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2200 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2201 | break; |
| 2202 | |
| 2203 | case NL80211_IFTYPE_P2P_CLIENT: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2204 | wilc_enable_ps = false; |
| 2205 | wilc_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); |
| 2206 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2207 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2208 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2209 | wilc_del_all_rx_ba_session(priv->hWILCWFIDrv, |
| 2210 | wl->vif[0].bssid, TID); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2211 | |
| 2212 | dev->ieee80211_ptr->iftype = type; |
| 2213 | priv->wdev->iftype = type; |
| 2214 | nic->monitor_flag = 0; |
| 2215 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2216 | PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); |
| 2217 | nic->iftype = CLIENT_MODE; |
| 2218 | |
| 2219 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2220 | if (wl->initialized) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2221 | wilc_wait_msg_queue_idle(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2222 | |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 2223 | wilc1000_wlan_deinit(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2224 | wilc1000_wlan_init(dev, nic); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2225 | wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2226 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2227 | wilc_set_wfi_drv_handler(wl->vif[0].hif_drv); |
| 2228 | wilc_set_mac_address(wl->vif[0].hif_drv, |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2229 | wl->vif[0].src_addr); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2230 | wilc_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2231 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2232 | if (g_wep_keys_saved) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2233 | wilc_set_wep_default_keyid(wl->vif[0].hif_drv, |
| 2234 | g_key_wep_params.key_idx); |
| 2235 | wilc_add_wep_key_bss_sta(wl->vif[0].hif_drv, |
| 2236 | g_key_wep_params.key, |
| 2237 | g_key_wep_params.key_len, |
| 2238 | g_key_wep_params.key_idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2239 | } |
| 2240 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2241 | wilc_flush_join_req(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2242 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2243 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2244 | PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], |
| 2245 | g_key_ptk_params.key[1], |
| 2246 | g_key_ptk_params.key[2]); |
| 2247 | PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], |
| 2248 | g_key_gtk_params.key[1], |
| 2249 | g_key_gtk_params.key[2]); |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2250 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2251 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2252 | g_add_ptk_key_params.key_idx, |
| 2253 | g_add_ptk_key_params.pairwise, |
| 2254 | g_add_ptk_key_params.mac_addr, |
| 2255 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2256 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2257 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2258 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2259 | g_add_gtk_key_params.key_idx, |
| 2260 | g_add_gtk_key_params.pairwise, |
| 2261 | g_add_gtk_key_params.mac_addr, |
| 2262 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2263 | } |
| 2264 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2265 | refresh_scan(priv, 1, true); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2266 | wilc_set_machw_change_vir_if(dev, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2267 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2268 | if (wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2269 | for (i = 0; i < num_reg_frame; i++) { |
| 2270 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2271 | nic->g_struct_frame_reg[i].reg); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2272 | wilc_frame_register(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2273 | nic->g_struct_frame_reg[i].frame_type, |
| 2274 | nic->g_struct_frame_reg[i].reg); |
| 2275 | } |
| 2276 | } |
| 2277 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2278 | break; |
| 2279 | |
| 2280 | case NL80211_IFTYPE_AP: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2281 | wilc_enable_ps = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2282 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2283 | dev->ieee80211_ptr->iftype = type; |
| 2284 | priv->wdev->iftype = type; |
| 2285 | nic->iftype = AP_MODE; |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 2286 | PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2287 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2288 | PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2289 | wilc_wlan_get_firmware(dev); |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 2290 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2291 | if (wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2292 | nic->iftype = AP_MODE; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2293 | wilc_mac_close(dev); |
| 2294 | wilc_mac_open(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2295 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2296 | for (i = 0; i < num_reg_frame; i++) { |
| 2297 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2298 | nic->g_struct_frame_reg[i].reg); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2299 | wilc_frame_register(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2300 | nic->g_struct_frame_reg[i].frame_type, |
| 2301 | nic->g_struct_frame_reg[i].reg); |
| 2302 | } |
| 2303 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2304 | break; |
| 2305 | |
| 2306 | case NL80211_IFTYPE_P2P_GO: |
| 2307 | PRINT_D(GENERIC_DBG, "start duringIP timer\n"); |
| 2308 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2309 | wilc_optaining_ip = true; |
Leo Kim | 7e872df | 2015-11-19 15:56:20 +0900 | [diff] [blame] | 2310 | mod_timer(&wilc_during_ip_timer, |
| 2311 | jiffies + msecs_to_jiffies(during_ip_time)); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2312 | wilc_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2313 | wilc_del_all_rx_ba_session(priv->hWILCWFIDrv, |
| 2314 | wl->vif[0].bssid, TID); |
| 2315 | wilc_enable_ps = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2316 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2317 | dev->ieee80211_ptr->iftype = type; |
| 2318 | priv->wdev->iftype = type; |
| 2319 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 2320 | PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2321 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2322 | PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); |
| 2323 | |
| 2324 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2325 | nic->iftype = GO_MODE; |
| 2326 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2327 | wilc_wait_msg_queue_idle(); |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 2328 | wilc1000_wlan_deinit(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2329 | wilc1000_wlan_init(dev, nic); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2330 | wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2331 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2332 | wilc_set_wfi_drv_handler(wl->vif[0].hif_drv); |
| 2333 | wilc_set_mac_address(wl->vif[0].hif_drv, |
| 2334 | wl->vif[0].src_addr); |
| 2335 | wilc_set_operation_mode(priv->hWILCWFIDrv, AP_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2336 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2337 | if (g_wep_keys_saved) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2338 | wilc_set_wep_default_keyid(wl->vif[0].hif_drv, |
| 2339 | g_key_wep_params.key_idx); |
| 2340 | wilc_add_wep_key_bss_sta(wl->vif[0].hif_drv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2341 | g_key_wep_params.key, |
| 2342 | g_key_wep_params.key_len, |
| 2343 | g_key_wep_params.key_idx); |
| 2344 | } |
| 2345 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2346 | wilc_flush_join_req(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2347 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2348 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2349 | PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0], |
| 2350 | g_key_ptk_params.key[1], |
| 2351 | g_key_ptk_params.key[2], |
| 2352 | g_key_ptk_params.cipher); |
| 2353 | PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0], |
| 2354 | g_key_gtk_params.key[1], |
| 2355 | g_key_gtk_params.key[2], |
| 2356 | g_key_gtk_params.cipher); |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2357 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2358 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2359 | g_add_ptk_key_params.key_idx, |
| 2360 | g_add_ptk_key_params.pairwise, |
| 2361 | g_add_ptk_key_params.mac_addr, |
| 2362 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2363 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2364 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2365 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2366 | g_add_gtk_key_params.key_idx, |
| 2367 | g_add_gtk_key_params.pairwise, |
| 2368 | g_add_gtk_key_params.mac_addr, |
| 2369 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2370 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2371 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2372 | if (wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2373 | for (i = 0; i < num_reg_frame; i++) { |
| 2374 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2375 | nic->g_struct_frame_reg[i].reg); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2376 | wilc_frame_register(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2377 | nic->g_struct_frame_reg[i].frame_type, |
| 2378 | nic->g_struct_frame_reg[i].reg); |
| 2379 | } |
| 2380 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2381 | break; |
| 2382 | |
| 2383 | default: |
| 2384 | PRINT_ER("Unknown interface type= %d\n", type); |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 2385 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2386 | } |
| 2387 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 2388 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2389 | } |
| 2390 | |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 2391 | static int start_ap(struct wiphy *wiphy, struct net_device *dev, |
| 2392 | struct cfg80211_ap_settings *settings) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2393 | { |
| 2394 | struct cfg80211_beacon_data *beacon = &(settings->beacon); |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2395 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2396 | s32 s32Error = 0; |
Glen Lee | 684dc18 | 2015-10-20 17:14:02 +0900 | [diff] [blame] | 2397 | struct wilc *wl; |
| 2398 | perInterface_wlan_t *nic; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2399 | |
| 2400 | priv = wiphy_priv(wiphy); |
Glen Lee | 684dc18 | 2015-10-20 17:14:02 +0900 | [diff] [blame] | 2401 | nic = netdev_priv(dev); |
| 2402 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2403 | PRINT_D(HOSTAPD_DBG, "Starting ap\n"); |
| 2404 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 2405 | PRINT_D(HOSTAPD_DBG, "Interval = %d\n DTIM period = %d\n Head length = %zu Tail length = %zu\n", |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2406 | settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len); |
| 2407 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 2408 | s32Error = set_channel(wiphy, &settings->chandef); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2409 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2410 | if (s32Error != 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2411 | PRINT_ER("Error in setting channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2412 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2413 | wilc_wlan_set_bssid(dev, wl->vif[0].src_addr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2414 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2415 | s32Error = wilc_add_beacon(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2416 | settings->beacon_interval, |
| 2417 | settings->dtim_period, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2418 | beacon->head_len, (u8 *)beacon->head, |
| 2419 | beacon->tail_len, (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2420 | |
| 2421 | return s32Error; |
| 2422 | } |
| 2423 | |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 2424 | static int change_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 2425 | struct cfg80211_beacon_data *beacon) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2426 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2427 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2428 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2429 | |
| 2430 | priv = wiphy_priv(wiphy); |
| 2431 | PRINT_D(HOSTAPD_DBG, "Setting beacon\n"); |
| 2432 | |
| 2433 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2434 | s32Error = wilc_add_beacon(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2435 | 0, |
| 2436 | 0, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2437 | beacon->head_len, (u8 *)beacon->head, |
| 2438 | beacon->tail_len, (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2439 | |
| 2440 | return s32Error; |
| 2441 | } |
| 2442 | |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 2443 | static int stop_ap(struct wiphy *wiphy, struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2444 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2445 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2446 | struct wilc_priv *priv; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2447 | u8 NullBssid[ETH_ALEN] = {0}; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2448 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2449 | if (!wiphy) |
| 2450 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2451 | |
| 2452 | priv = wiphy_priv(wiphy); |
| 2453 | |
| 2454 | PRINT_D(HOSTAPD_DBG, "Deleting beacon\n"); |
| 2455 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2456 | wilc_wlan_set_bssid(dev, NullBssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2457 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2458 | s32Error = wilc_del_beacon(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2459 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 2460 | if (s32Error) |
| 2461 | PRINT_ER("Host delete beacon fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2462 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2463 | return s32Error; |
| 2464 | } |
| 2465 | |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 2466 | static int add_station(struct wiphy *wiphy, struct net_device *dev, |
| 2467 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2468 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2469 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2470 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 2471 | struct add_sta_param strStaParams = { {0} }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2472 | perInterface_wlan_t *nic; |
| 2473 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2474 | if (!wiphy) |
| 2475 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2476 | |
| 2477 | priv = wiphy_priv(wiphy); |
| 2478 | nic = netdev_priv(dev); |
| 2479 | |
| 2480 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
Leo Kim | 2353c38 | 2015-10-29 12:05:41 +0900 | [diff] [blame] | 2481 | memcpy(strStaParams.bssid, mac, ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 2482 | memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 2483 | strStaParams.aid = params->aid; |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2484 | strStaParams.rates_len = params->supported_rates_len; |
Leo Kim | a622e01 | 2015-10-29 12:05:44 +0900 | [diff] [blame] | 2485 | strStaParams.rates = params->supported_rates; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2486 | |
| 2487 | PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid); |
| 2488 | |
| 2489 | PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4], |
| 2490 | priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 2491 | PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.aid); |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2492 | PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", |
| 2493 | strStaParams.rates_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2494 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 2495 | if (params->ht_capa == NULL) { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2496 | strStaParams.ht_supported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2497 | } else { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2498 | strStaParams.ht_supported = true; |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 2499 | strStaParams.ht_capa_info = params->ht_capa->cap_info; |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 2500 | strStaParams.ht_ampdu_params = params->ht_capa->ampdu_params_info; |
Leo Kim | 5ebbf4f | 2015-10-29 12:05:48 +0900 | [diff] [blame] | 2501 | memcpy(strStaParams.ht_supp_mcs_set, |
| 2502 | ¶ms->ht_capa->mcs, |
| 2503 | WILC_SUPP_MCS_SET_SIZE); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 2504 | strStaParams.ht_ext_params = params->ht_capa->extended_ht_cap_info; |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 2505 | strStaParams.ht_tx_bf_cap = params->ht_capa->tx_BF_cap_info; |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 2506 | strStaParams.ht_ante_sel = params->ht_capa->antenna_selection_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2507 | } |
| 2508 | |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 2509 | strStaParams.flags_mask = params->sta_flags_mask; |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 2510 | strStaParams.flags_set = params->sta_flags_set; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2511 | |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2512 | PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", |
| 2513 | strStaParams.ht_supported); |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 2514 | PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", |
| 2515 | strStaParams.ht_capa_info); |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 2516 | PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", |
| 2517 | strStaParams.ht_ampdu_params); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 2518 | PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", |
| 2519 | strStaParams.ht_ext_params); |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 2520 | PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", |
| 2521 | strStaParams.ht_tx_bf_cap); |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 2522 | PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", |
| 2523 | strStaParams.ht_ante_sel); |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 2524 | PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", |
| 2525 | strStaParams.flags_mask); |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 2526 | PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", |
| 2527 | strStaParams.flags_set); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2528 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2529 | s32Error = wilc_add_station(priv->hWILCWFIDrv, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 2530 | if (s32Error) |
| 2531 | PRINT_ER("Host add station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2532 | } |
| 2533 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2534 | return s32Error; |
| 2535 | } |
| 2536 | |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 2537 | static int del_station(struct wiphy *wiphy, struct net_device *dev, |
| 2538 | struct station_del_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2539 | { |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 2540 | const u8 *mac = params->mac; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2541 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2542 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2543 | perInterface_wlan_t *nic; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2544 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2545 | if (!wiphy) |
| 2546 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2547 | |
| 2548 | priv = wiphy_priv(wiphy); |
| 2549 | nic = netdev_priv(dev); |
| 2550 | |
| 2551 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
| 2552 | PRINT_D(HOSTAPD_DBG, "Deleting station\n"); |
| 2553 | |
| 2554 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 2555 | if (mac == NULL) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 2556 | PRINT_D(HOSTAPD_DBG, "All associated stations\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2557 | s32Error = wilc_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2558 | } else { |
| 2559 | PRINT_D(HOSTAPD_DBG, "With mac address: %x%x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
| 2560 | } |
| 2561 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2562 | s32Error = wilc_del_station(priv->hWILCWFIDrv, mac); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2563 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 2564 | if (s32Error) |
| 2565 | PRINT_ER("Host delete station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2566 | } |
| 2567 | return s32Error; |
| 2568 | } |
| 2569 | |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 2570 | static int change_station(struct wiphy *wiphy, struct net_device *dev, |
| 2571 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2572 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2573 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2574 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 2575 | struct add_sta_param strStaParams = { {0} }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2576 | perInterface_wlan_t *nic; |
| 2577 | |
| 2578 | |
| 2579 | PRINT_D(HOSTAPD_DBG, "Change station paramters\n"); |
| 2580 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2581 | if (!wiphy) |
| 2582 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2583 | |
| 2584 | priv = wiphy_priv(wiphy); |
| 2585 | nic = netdev_priv(dev); |
| 2586 | |
| 2587 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
Leo Kim | 2353c38 | 2015-10-29 12:05:41 +0900 | [diff] [blame] | 2588 | memcpy(strStaParams.bssid, mac, ETH_ALEN); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 2589 | strStaParams.aid = params->aid; |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2590 | strStaParams.rates_len = params->supported_rates_len; |
Leo Kim | a622e01 | 2015-10-29 12:05:44 +0900 | [diff] [blame] | 2591 | strStaParams.rates = params->supported_rates; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2592 | |
Leo Kim | 2353c38 | 2015-10-29 12:05:41 +0900 | [diff] [blame] | 2593 | PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n", |
| 2594 | strStaParams.bssid[0], strStaParams.bssid[1], |
| 2595 | strStaParams.bssid[2], strStaParams.bssid[3], |
| 2596 | strStaParams.bssid[4], strStaParams.bssid[5]); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 2597 | PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.aid); |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2598 | PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", |
| 2599 | strStaParams.rates_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2600 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 2601 | if (params->ht_capa == NULL) { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2602 | strStaParams.ht_supported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2603 | } else { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2604 | strStaParams.ht_supported = true; |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 2605 | strStaParams.ht_capa_info = params->ht_capa->cap_info; |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 2606 | strStaParams.ht_ampdu_params = params->ht_capa->ampdu_params_info; |
Leo Kim | 5ebbf4f | 2015-10-29 12:05:48 +0900 | [diff] [blame] | 2607 | memcpy(strStaParams.ht_supp_mcs_set, |
| 2608 | ¶ms->ht_capa->mcs, |
| 2609 | WILC_SUPP_MCS_SET_SIZE); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 2610 | strStaParams.ht_ext_params = params->ht_capa->extended_ht_cap_info; |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 2611 | strStaParams.ht_tx_bf_cap = params->ht_capa->tx_BF_cap_info; |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 2612 | strStaParams.ht_ante_sel = params->ht_capa->antenna_selection_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2613 | } |
| 2614 | |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 2615 | strStaParams.flags_mask = params->sta_flags_mask; |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 2616 | strStaParams.flags_set = params->sta_flags_set; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2617 | |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2618 | PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", |
| 2619 | strStaParams.ht_supported); |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 2620 | PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", |
| 2621 | strStaParams.ht_capa_info); |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 2622 | PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", |
| 2623 | strStaParams.ht_ampdu_params); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 2624 | PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", |
| 2625 | strStaParams.ht_ext_params); |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 2626 | PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", |
| 2627 | strStaParams.ht_tx_bf_cap); |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 2628 | PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", |
| 2629 | strStaParams.ht_ante_sel); |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 2630 | PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", |
| 2631 | strStaParams.flags_mask); |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 2632 | PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", |
| 2633 | strStaParams.flags_set); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2634 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2635 | s32Error = wilc_edit_station(priv->hWILCWFIDrv, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 2636 | if (s32Error) |
| 2637 | PRINT_ER("Host edit station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2638 | } |
| 2639 | return s32Error; |
| 2640 | } |
| 2641 | |
Chaehyun Lim | 37316e8 | 2015-09-22 18:34:52 +0900 | [diff] [blame] | 2642 | static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, |
| 2643 | const char *name, |
| 2644 | unsigned char name_assign_type, |
| 2645 | enum nl80211_iftype type, |
| 2646 | u32 *flags, |
| 2647 | struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2648 | { |
| 2649 | perInterface_wlan_t *nic; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2650 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2651 | struct net_device *new_ifc = NULL; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2652 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2653 | priv = wiphy_priv(wiphy); |
| 2654 | |
| 2655 | |
| 2656 | |
| 2657 | PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev); |
| 2658 | |
| 2659 | nic = netdev_priv(priv->wdev->netdev); |
| 2660 | |
| 2661 | |
| 2662 | if (type == NL80211_IFTYPE_MONITOR) { |
| 2663 | PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n"); |
| 2664 | PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev); |
| 2665 | new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev); |
| 2666 | if (new_ifc != NULL) { |
| 2667 | PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2668 | nic = netdev_priv(priv->wdev->netdev); |
| 2669 | nic->monitor_flag = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2670 | } else |
| 2671 | PRINT_ER("Error in initializing monitor interface\n "); |
| 2672 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2673 | return priv->wdev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2674 | } |
| 2675 | |
Chaehyun Lim | 956d721 | 2015-09-22 18:34:49 +0900 | [diff] [blame] | 2676 | static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2677 | { |
| 2678 | PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2679 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2680 | } |
| 2681 | |
Chaehyun Lim | 0824192 | 2015-09-15 14:06:12 +0900 | [diff] [blame] | 2682 | static struct cfg80211_ops wilc_cfg80211_ops = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2683 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 2684 | .set_monitor_channel = set_channel, |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 2685 | .scan = scan, |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 2686 | .connect = connect, |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 2687 | .disconnect = disconnect, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2688 | .add_key = add_key, |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 2689 | .del_key = del_key, |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 2690 | .get_key = get_key, |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 2691 | .set_default_key = set_default_key, |
Chaehyun Lim | 69deb4c | 2015-09-14 12:24:09 +0900 | [diff] [blame] | 2692 | .add_virtual_intf = add_virtual_intf, |
Chaehyun Lim | b4a7335 | 2015-09-14 12:24:10 +0900 | [diff] [blame] | 2693 | .del_virtual_intf = del_virtual_intf, |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 2694 | .change_virtual_intf = change_virtual_intf, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2695 | |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 2696 | .start_ap = start_ap, |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 2697 | .change_beacon = change_beacon, |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 2698 | .stop_ap = stop_ap, |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 2699 | .add_station = add_station, |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 2700 | .del_station = del_station, |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 2701 | .change_station = change_station, |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 2702 | .get_station = get_station, |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 2703 | .dump_station = dump_station, |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 2704 | .change_bss = change_bss, |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 2705 | .set_wiphy_params = set_wiphy_params, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2706 | |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 2707 | .set_pmksa = set_pmksa, |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 2708 | .del_pmksa = del_pmksa, |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 2709 | .flush_pmksa = flush_pmksa, |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 2710 | .remain_on_channel = remain_on_channel, |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 2711 | .cancel_remain_on_channel = cancel_remain_on_channel, |
Chaehyun Lim | 4a2f9b3 | 2015-09-14 12:24:27 +0900 | [diff] [blame] | 2712 | .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait, |
Chaehyun Lim | 12a26a3 | 2015-09-14 12:24:28 +0900 | [diff] [blame] | 2713 | .mgmt_tx = mgmt_tx, |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 2714 | .mgmt_frame_register = wilc_mgmt_frame_register, |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 2715 | .set_power_mgmt = set_power_mgmt, |
Chaehyun Lim | a8047e2 | 2015-09-22 18:34:48 +0900 | [diff] [blame] | 2716 | .set_cqm_rssi_config = set_cqm_rssi_config, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2717 | |
| 2718 | }; |
| 2719 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2720 | int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) |
| 2721 | { |
| 2722 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2723 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2724 | |
| 2725 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2726 | switch (changed) { |
| 2727 | |
| 2728 | case WILC_WFI_RX_PKT: |
| 2729 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2730 | priv->netstats.rx_packets++; |
| 2731 | priv->netstats.rx_bytes += pktlen; |
| 2732 | priv->netstats.rx_time = get_jiffies_64(); |
| 2733 | } |
| 2734 | break; |
| 2735 | |
| 2736 | case WILC_WFI_TX_PKT: |
| 2737 | { |
| 2738 | priv->netstats.tx_packets++; |
| 2739 | priv->netstats.tx_bytes += pktlen; |
| 2740 | priv->netstats.tx_time = get_jiffies_64(); |
| 2741 | |
| 2742 | } |
| 2743 | break; |
| 2744 | |
| 2745 | default: |
| 2746 | break; |
| 2747 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2748 | return 0; |
| 2749 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2750 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 2751 | static struct wireless_dev *WILC_WFI_CfgAlloc(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2752 | { |
| 2753 | |
| 2754 | struct wireless_dev *wdev; |
| 2755 | |
| 2756 | |
| 2757 | PRINT_D(CFG80211_DBG, "Allocating wireless device\n"); |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 2758 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2759 | wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); |
| 2760 | if (!wdev) { |
| 2761 | PRINT_ER("Cannot allocate wireless device\n"); |
| 2762 | goto _fail_; |
| 2763 | } |
| 2764 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2765 | wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2766 | if (!wdev->wiphy) { |
| 2767 | PRINT_ER("Cannot allocate wiphy\n"); |
| 2768 | goto _fail_mem_; |
| 2769 | |
| 2770 | } |
| 2771 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2772 | WILC_WFI_band_2ghz.ht_cap.ht_supported = 1; |
| 2773 | WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); |
| 2774 | WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; |
| 2775 | WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; |
| 2776 | 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] | 2777 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2778 | wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz; |
| 2779 | |
| 2780 | return wdev; |
| 2781 | |
| 2782 | _fail_mem_: |
| 2783 | kfree(wdev); |
| 2784 | _fail_: |
| 2785 | return NULL; |
| 2786 | |
| 2787 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 2788 | |
Arnd Bergmann | 2e7d537 | 2015-11-16 15:05:03 +0100 | [diff] [blame] | 2789 | 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] | 2790 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2791 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2792 | struct wireless_dev *wdev; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2793 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2794 | |
| 2795 | PRINT_D(CFG80211_DBG, "Registering wifi device\n"); |
| 2796 | |
| 2797 | wdev = WILC_WFI_CfgAlloc(); |
| 2798 | if (wdev == NULL) { |
| 2799 | PRINT_ER("CfgAlloc Failed\n"); |
| 2800 | return NULL; |
| 2801 | } |
| 2802 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2803 | priv = wdev_priv(wdev); |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 2804 | sema_init(&(priv->SemHandleUpdateStats), 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2805 | priv->wdev = wdev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2806 | wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2807 | wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; |
| 2808 | PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2809 | |
| 2810 | wdev->wiphy->max_scan_ie_len = 1000; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2811 | wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2812 | wdev->wiphy->cipher_suites = cipher_suites; |
| 2813 | wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2814 | wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2815 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2816 | wdev->wiphy->max_remain_on_channel_duration = 500; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2817 | wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) | |
| 2818 | BIT(NL80211_IFTYPE_P2P_CLIENT); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2819 | wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2820 | wdev->iftype = NL80211_IFTYPE_STATION; |
| 2821 | |
| 2822 | |
| 2823 | |
| 2824 | PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n", |
| 2825 | wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type, |
| 2826 | wdev->wiphy->interface_modes, wdev->iftype); |
| 2827 | |
Arnd Bergmann | 2e7d537 | 2015-11-16 15:05:03 +0100 | [diff] [blame] | 2828 | set_wiphy_dev(wdev->wiphy, dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2829 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2830 | s32Error = wiphy_register(wdev->wiphy); |
| 2831 | if (s32Error) { |
| 2832 | PRINT_ER("Cannot register wiphy device\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2833 | } else { |
| 2834 | PRINT_D(CFG80211_DBG, "Successful Registering\n"); |
| 2835 | } |
| 2836 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2837 | priv->dev = net; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2838 | return wdev; |
| 2839 | |
| 2840 | |
| 2841 | } |
Leo Kim | a89f7c5 | 2015-11-25 11:59:41 +0900 | [diff] [blame^] | 2842 | |
Chaehyun Lim | dd4b6a8 | 2015-09-20 15:51:25 +0900 | [diff] [blame] | 2843 | int wilc_init_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2844 | { |
| 2845 | |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 2846 | int s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2847 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2848 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2849 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2850 | PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr); |
| 2851 | priv = wdev_priv(net->ieee80211_ptr); |
| 2852 | if (op_ifcs == 0) { |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 2853 | setup_timer(&hAgingTimer, remove_network_from_shadow, 0); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2854 | setup_timer(&wilc_during_ip_timer, clear_duringIP, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2855 | } |
| 2856 | op_ifcs++; |
| 2857 | if (s32Error < 0) { |
| 2858 | PRINT_ER("Failed to creat refresh Timer\n"); |
| 2859 | return s32Error; |
| 2860 | } |
| 2861 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2862 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2863 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2864 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2865 | |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 2866 | sema_init(&(priv->hSemScanReq), 1); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2867 | s32Error = wilc_init(net, &priv->hWILCWFIDrv); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 2868 | if (s32Error) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2869 | PRINT_ER("Error while initializing hostinterface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 2870 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2871 | return s32Error; |
| 2872 | } |
| 2873 | |
Chaehyun Lim | a9a1682 | 2015-09-20 15:51:24 +0900 | [diff] [blame] | 2874 | int wilc_deinit_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2875 | { |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 2876 | int s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2877 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2878 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2879 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2880 | priv = wdev_priv(net->ieee80211_ptr); |
| 2881 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2882 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2883 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2884 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2885 | |
| 2886 | op_ifcs--; |
| 2887 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2888 | s32Error = wilc_deinit(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2889 | |
Leo Kim | d14991a | 2015-11-19 15:56:22 +0900 | [diff] [blame] | 2890 | clear_shadow_scan(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2891 | if (op_ifcs == 0) { |
| 2892 | PRINT_D(CORECONFIG_DBG, "destroy during ip\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2893 | del_timer_sync(&wilc_during_ip_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2894 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2895 | |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 2896 | if (s32Error) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2897 | PRINT_ER("Error while deintializing host interface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 2898 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2899 | return s32Error; |
| 2900 | } |
| 2901 | |
Chaehyun Lim | 96da20a | 2015-09-20 15:51:08 +0900 | [diff] [blame] | 2902 | void wilc_free_wiphy(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2903 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2904 | PRINT_D(CFG80211_DBG, "Unregistering wiphy\n"); |
| 2905 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 2906 | if (!net) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2907 | PRINT_D(INIT_DBG, "net_device is NULL\n"); |
| 2908 | return; |
| 2909 | } |
| 2910 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 2911 | if (!net->ieee80211_ptr) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2912 | PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n"); |
| 2913 | return; |
| 2914 | } |
| 2915 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 2916 | if (!net->ieee80211_ptr->wiphy) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2917 | PRINT_D(INIT_DBG, "wiphy is NULL\n"); |
| 2918 | return; |
| 2919 | } |
| 2920 | |
| 2921 | wiphy_unregister(net->ieee80211_ptr->wiphy); |
| 2922 | |
| 2923 | PRINT_D(INIT_DBG, "Freeing wiphy\n"); |
| 2924 | wiphy_free(net->ieee80211_ptr->wiphy); |
| 2925 | kfree(net->ieee80211_ptr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2926 | } |