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