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