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