Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1 | /*! |
| 2 | * @file wilc_wfi_cfgopertaions.c |
| 3 | * @brief CFG80211 Function Implementation functionality |
| 4 | * @author aabouzaeid |
| 5 | * mabubakr |
| 6 | * mdaftedar |
| 7 | * zsalah |
| 8 | * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file |
| 9 | * @date 31 Aug 2010 |
| 10 | * @version 1.0 |
| 11 | */ |
| 12 | |
| 13 | #include "wilc_wfi_cfgoperations.h" |
Arnd Bergmann | 491880e | 2015-11-16 15:04:55 +0100 | [diff] [blame] | 14 | #include "host_interface.h" |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 15 | #include <linux/errno.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 16 | |
Arnd Bergmann | 15162fb | 2015-11-16 15:04:57 +0100 | [diff] [blame] | 17 | /* The following macros describe the bitfield map used by the firmware to determine its 11i mode */ |
| 18 | #define NO_ENCRYPT 0 |
| 19 | #define ENCRYPT_ENABLED BIT(0) |
| 20 | #define WEP BIT(1) |
| 21 | #define WEP_EXTENDED BIT(2) |
| 22 | #define WPA BIT(3) |
| 23 | #define WPA2 BIT(4) |
| 24 | #define AES BIT(5) |
| 25 | #define TKIP BIT(6) |
| 26 | |
| 27 | /*Public action frame index IDs*/ |
| 28 | #define FRAME_TYPE_ID 0 |
| 29 | #define ACTION_CAT_ID 24 |
| 30 | #define ACTION_SUBTYPE_ID 25 |
| 31 | #define P2P_PUB_ACTION_SUBTYPE 30 |
| 32 | |
| 33 | /*Public action frame Attribute IDs*/ |
| 34 | #define ACTION_FRAME 0xd0 |
| 35 | #define GO_INTENT_ATTR_ID 0x04 |
| 36 | #define CHANLIST_ATTR_ID 0x0b |
| 37 | #define OPERCHAN_ATTR_ID 0x11 |
| 38 | #define PUB_ACTION_ATTR_ID 0x04 |
| 39 | #define P2PELEM_ATTR_ID 0xdd |
| 40 | |
| 41 | /*Public action subtype values*/ |
| 42 | #define GO_NEG_REQ 0x00 |
| 43 | #define GO_NEG_RSP 0x01 |
| 44 | #define GO_NEG_CONF 0x02 |
| 45 | #define P2P_INV_REQ 0x03 |
| 46 | #define P2P_INV_RSP 0x04 |
| 47 | #define PUBLIC_ACT_VENDORSPEC 0x09 |
| 48 | #define GAS_INTIAL_REQ 0x0a |
| 49 | #define GAS_INTIAL_RSP 0x0b |
| 50 | |
| 51 | #define INVALID_CHANNEL 0 |
| 52 | |
| 53 | #define nl80211_SCAN_RESULT_EXPIRE (3 * HZ) |
| 54 | #define SCAN_RESULT_EXPIRE (40 * HZ) |
| 55 | |
| 56 | static const u32 cipher_suites[] = { |
| 57 | WLAN_CIPHER_SUITE_WEP40, |
| 58 | WLAN_CIPHER_SUITE_WEP104, |
| 59 | WLAN_CIPHER_SUITE_TKIP, |
| 60 | WLAN_CIPHER_SUITE_CCMP, |
| 61 | WLAN_CIPHER_SUITE_AES_CMAC, |
| 62 | }; |
| 63 | |
| 64 | static const struct ieee80211_txrx_stypes |
| 65 | wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = { |
| 66 | [NL80211_IFTYPE_STATION] = { |
| 67 | .tx = 0xffff, |
| 68 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 69 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
| 70 | }, |
| 71 | [NL80211_IFTYPE_AP] = { |
| 72 | .tx = 0xffff, |
| 73 | .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | |
| 74 | BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | |
| 75 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | |
| 76 | BIT(IEEE80211_STYPE_DISASSOC >> 4) | |
| 77 | BIT(IEEE80211_STYPE_AUTH >> 4) | |
| 78 | BIT(IEEE80211_STYPE_DEAUTH >> 4) | |
| 79 | BIT(IEEE80211_STYPE_ACTION >> 4) |
| 80 | }, |
| 81 | [NL80211_IFTYPE_P2P_CLIENT] = { |
| 82 | .tx = 0xffff, |
| 83 | .rx = BIT(IEEE80211_STYPE_ACTION >> 4) | |
| 84 | BIT(IEEE80211_STYPE_PROBE_REQ >> 4) | |
| 85 | BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) | |
| 86 | BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) | |
| 87 | BIT(IEEE80211_STYPE_DISASSOC >> 4) | |
| 88 | BIT(IEEE80211_STYPE_AUTH >> 4) | |
| 89 | BIT(IEEE80211_STYPE_DEAUTH >> 4) |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | /* Time to stay on the channel */ |
| 94 | #define WILC_WFI_DWELL_PASSIVE 100 |
| 95 | #define WILC_WFI_DWELL_ACTIVE 40 |
| 96 | |
| 97 | #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 |
| 98 | #define DEFAULT_LINK_SPEED 72 |
| 99 | |
| 100 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 101 | #define IS_MANAGMEMENT 0x100 |
| 102 | #define IS_MANAGMEMENT_CALLBACK 0x080 |
| 103 | #define IS_MGMT_STATUS_SUCCES 0x040 |
| 104 | #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff) |
| 105 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 106 | extern int wilc_mac_open(struct net_device *ndev); |
| 107 | extern int wilc_mac_close(struct net_device *ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 108 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 109 | static tstrNetworkInfo last_scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW]; |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 110 | static u32 last_scanned_cnt; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 111 | struct timer_list wilc_during_ip_timer; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 112 | static struct timer_list hAgingTimer; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 113 | static u8 op_ifcs; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 114 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 115 | u8 wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 116 | |
| 117 | #define CHAN2G(_channel, _freq, _flags) { \ |
| 118 | .band = IEEE80211_BAND_2GHZ, \ |
| 119 | .center_freq = (_freq), \ |
| 120 | .hw_value = (_channel), \ |
| 121 | .flags = (_flags), \ |
| 122 | .max_antenna_gain = 0, \ |
| 123 | .max_power = 30, \ |
| 124 | } |
| 125 | |
| 126 | /*Frequency range for channels*/ |
Leo Kim | 2736f47 | 2015-11-19 15:56:12 +0900 | [diff] [blame] | 127 | static struct ieee80211_channel ieee80211_2ghz_channels[] = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 128 | CHAN2G(1, 2412, 0), |
| 129 | CHAN2G(2, 2417, 0), |
| 130 | CHAN2G(3, 2422, 0), |
| 131 | CHAN2G(4, 2427, 0), |
| 132 | CHAN2G(5, 2432, 0), |
| 133 | CHAN2G(6, 2437, 0), |
| 134 | CHAN2G(7, 2442, 0), |
| 135 | CHAN2G(8, 2447, 0), |
| 136 | CHAN2G(9, 2452, 0), |
| 137 | CHAN2G(10, 2457, 0), |
| 138 | CHAN2G(11, 2462, 0), |
| 139 | CHAN2G(12, 2467, 0), |
| 140 | CHAN2G(13, 2472, 0), |
| 141 | CHAN2G(14, 2484, 0), |
| 142 | }; |
| 143 | |
| 144 | #define RATETAB_ENT(_rate, _hw_value, _flags) { \ |
| 145 | .bitrate = (_rate), \ |
| 146 | .hw_value = (_hw_value), \ |
| 147 | .flags = (_flags), \ |
| 148 | } |
| 149 | |
| 150 | |
| 151 | /* Table 6 in section 3.2.1.1 */ |
Leo Kim | 8d48b5b | 2015-11-19 15:56:13 +0900 | [diff] [blame] | 152 | static struct ieee80211_rate ieee80211_bitrates[] = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 153 | RATETAB_ENT(10, 0, 0), |
| 154 | RATETAB_ENT(20, 1, 0), |
| 155 | RATETAB_ENT(55, 2, 0), |
| 156 | RATETAB_ENT(110, 3, 0), |
| 157 | RATETAB_ENT(60, 9, 0), |
| 158 | RATETAB_ENT(90, 6, 0), |
| 159 | RATETAB_ENT(120, 7, 0), |
| 160 | RATETAB_ENT(180, 8, 0), |
| 161 | RATETAB_ENT(240, 9, 0), |
| 162 | RATETAB_ENT(360, 10, 0), |
| 163 | RATETAB_ENT(480, 11, 0), |
| 164 | RATETAB_ENT(540, 12, 0), |
| 165 | }; |
| 166 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 167 | struct p2p_mgmt_data { |
| 168 | int size; |
| 169 | u8 *buff; |
| 170 | }; |
| 171 | |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 172 | static u8 wlan_channel = INVALID_CHANNEL; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 173 | static u8 curr_channel; |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 174 | static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09}; |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 175 | static u8 p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 176 | static u8 p2p_recv_random = 0x00; |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 177 | static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 178 | static bool wilc_ie; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 179 | |
| 180 | static struct ieee80211_supported_band WILC_WFI_band_2ghz = { |
Leo Kim | 2736f47 | 2015-11-19 15:56:12 +0900 | [diff] [blame] | 181 | .channels = ieee80211_2ghz_channels, |
| 182 | .n_channels = ARRAY_SIZE(ieee80211_2ghz_channels), |
Leo Kim | 8d48b5b | 2015-11-19 15:56:13 +0900 | [diff] [blame] | 183 | .bitrates = ieee80211_bitrates, |
| 184 | .n_bitrates = ARRAY_SIZE(ieee80211_bitrates), |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 185 | }; |
| 186 | |
| 187 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 188 | struct add_key_params { |
| 189 | u8 key_idx; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 190 | bool pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 191 | u8 *mac_addr; |
| 192 | }; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 193 | static struct add_key_params g_add_gtk_key_params; |
| 194 | static struct wilc_wfi_key g_key_gtk_params; |
| 195 | static struct add_key_params g_add_ptk_key_params; |
| 196 | static struct wilc_wfi_key g_key_ptk_params; |
| 197 | static struct wilc_wfi_wep_key g_key_wep_params; |
| 198 | static bool g_ptk_keys_saved; |
| 199 | static bool g_gtk_keys_saved; |
| 200 | static bool g_wep_keys_saved; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 201 | |
| 202 | #define AGING_TIME (9 * 1000) |
Leo Kim | 7e872df | 2015-11-19 15:56:20 +0900 | [diff] [blame] | 203 | #define during_ip_time 15000 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 204 | |
Leo Kim | d14991a | 2015-11-19 15:56:22 +0900 | [diff] [blame] | 205 | static void clear_shadow_scan(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 206 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 207 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 208 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 209 | if (op_ifcs == 0) { |
Greg Kroah-Hartman | 4183e97 | 2015-08-14 20:11:16 -0700 | [diff] [blame] | 210 | del_timer_sync(&hAgingTimer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 211 | PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n"); |
| 212 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 213 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 214 | if (last_scanned_shadow[last_scanned_cnt].pu8IEs) { |
| 215 | kfree(last_scanned_shadow[i].pu8IEs); |
| 216 | last_scanned_shadow[last_scanned_cnt].pu8IEs = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 217 | } |
| 218 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 219 | wilc_free_join_params(last_scanned_shadow[i].pJoinParams); |
| 220 | last_scanned_shadow[i].pJoinParams = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 221 | } |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 222 | last_scanned_cnt = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | } |
| 226 | |
Leo Kim | 0b8bea1 | 2015-11-19 15:56:35 +0900 | [diff] [blame] | 227 | static u32 get_rssi_avg(tstrNetworkInfo *network_info) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 228 | { |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 229 | u8 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 230 | int rssi_v = 0; |
Leo Kim | 0b8bea1 | 2015-11-19 15:56:35 +0900 | [diff] [blame] | 231 | 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] | 232 | |
| 233 | for (i = 0; i < num_rssi; i++) |
Leo Kim | 0b8bea1 | 2015-11-19 15:56:35 +0900 | [diff] [blame] | 234 | rssi_v += network_info->strRssi.as8RSSI[i]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 235 | |
| 236 | rssi_v /= num_rssi; |
| 237 | return rssi_v; |
| 238 | } |
| 239 | |
Leo Kim | 48ee7ba | 2015-11-19 15:56:24 +0900 | [diff] [blame] | 240 | static void refresh_scan(void *user_void, u8 all, bool direct_scan) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 241 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 242 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 243 | struct wiphy *wiphy; |
| 244 | struct cfg80211_bss *bss = NULL; |
| 245 | int i; |
| 246 | int rssi = 0; |
| 247 | |
Leo Kim | 84df0e6 | 2015-11-19 15:56:23 +0900 | [diff] [blame] | 248 | priv = (struct wilc_priv *)user_void; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 249 | wiphy = priv->dev->ieee80211_ptr->wiphy; |
| 250 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 251 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 252 | tstrNetworkInfo *network_info; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 253 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 254 | network_info = &last_scanned_shadow[i]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 255 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 256 | if (!network_info->u8Found || all) { |
Leo Kim | c6f5e3a | 2015-11-19 15:56:26 +0900 | [diff] [blame] | 257 | s32 freq; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 258 | struct ieee80211_channel *channel; |
| 259 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 260 | if (network_info) { |
Leo Kim | c6f5e3a | 2015-11-19 15:56:26 +0900 | [diff] [blame] | 261 | freq = ieee80211_channel_to_frequency((s32)network_info->u8channel, IEEE80211_BAND_2GHZ); |
| 262 | channel = ieee80211_get_channel(wiphy, freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 263 | |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 264 | rssi = get_rssi_avg(network_info); |
| 265 | if (memcmp("DIRECT-", network_info->au8ssid, 7) || |
Leo Kim | 48ee7ba | 2015-11-19 15:56:24 +0900 | [diff] [blame] | 266 | direct_scan) { |
Leo Kim | ce3b1b5 | 2015-11-19 15:56:25 +0900 | [diff] [blame] | 267 | bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, network_info->au8bssid, network_info->u64Tsf, network_info->u16CapInfo, |
| 268 | network_info->u16BeaconPeriod, (const u8 *)network_info->pu8IEs, |
| 269 | (size_t)network_info->u16IEsLen, (((s32)rssi) * 100), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 270 | cfg80211_put_bss(wiphy, bss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 271 | } |
| 272 | } |
| 273 | |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | } |
| 278 | |
Leo Kim | 12b0138 | 2015-11-19 15:56:27 +0900 | [diff] [blame] | 279 | static void reset_shadow_found(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 280 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 281 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 282 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 283 | for (i = 0; i < last_scanned_cnt; i++) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 284 | last_scanned_shadow[i].u8Found = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 285 | } |
| 286 | |
Leo Kim | 5e51d8b | 2015-11-19 15:56:28 +0900 | [diff] [blame] | 287 | static void update_scan_time(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 288 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 289 | int i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 290 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 291 | for (i = 0; i < last_scanned_cnt; i++) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 292 | last_scanned_shadow[i].u32TimeRcvdInScan = jiffies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 293 | } |
| 294 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 295 | static void remove_network_from_shadow(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 296 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 297 | unsigned long now = jiffies; |
| 298 | int i, j; |
| 299 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 300 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 301 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 302 | if (time_after(now, last_scanned_shadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) { |
| 303 | 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] | 304 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 305 | kfree(last_scanned_shadow[i].pu8IEs); |
| 306 | last_scanned_shadow[i].pu8IEs = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 307 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 308 | wilc_free_join_params(last_scanned_shadow[i].pJoinParams); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 309 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 310 | for (j = i; (j < last_scanned_cnt - 1); j++) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 311 | last_scanned_shadow[j] = last_scanned_shadow[j + 1]; |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 312 | |
| 313 | last_scanned_cnt--; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 314 | } |
| 315 | } |
| 316 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 317 | PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", |
| 318 | last_scanned_cnt); |
| 319 | if (last_scanned_cnt != 0) { |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 320 | hAgingTimer.data = arg; |
| 321 | mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); |
| 322 | } else { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 323 | PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n"); |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 324 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 325 | } |
| 326 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 327 | static void clear_duringIP(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 328 | { |
| 329 | PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 330 | wilc_optaining_ip = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 331 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 332 | |
Leo Kim | 157814f | 2015-11-19 15:56:29 +0900 | [diff] [blame] | 333 | static int is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, |
| 334 | void *user_void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 335 | { |
Chaehyun Lim | a74cc6b | 2015-10-02 16:41:17 +0900 | [diff] [blame] | 336 | int state = -1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 337 | int i; |
| 338 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 339 | if (last_scanned_cnt == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 340 | PRINT_D(CFG80211_DBG, "Starting Aging timer\n"); |
Leo Kim | 157814f | 2015-11-19 15:56:29 +0900 | [diff] [blame] | 341 | hAgingTimer.data = (unsigned long)user_void; |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 342 | mod_timer(&hAgingTimer, jiffies + msecs_to_jiffies(AGING_TIME)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 343 | state = -1; |
| 344 | } else { |
| 345 | /* Linear search for now */ |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 346 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 347 | if (memcmp(last_scanned_shadow[i].au8bssid, |
| 348 | pstrNetworkInfo->au8bssid, 6) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 349 | state = i; |
| 350 | break; |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | return state; |
| 355 | } |
| 356 | |
Leo Kim | 5c4cf0d | 2015-11-19 15:56:30 +0900 | [diff] [blame] | 357 | static void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, |
| 358 | void *user_void, void *pJoinParams) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 359 | { |
Leo Kim | 5c4cf0d | 2015-11-19 15:56:30 +0900 | [diff] [blame] | 360 | int ap_found = is_network_in_shadow(pstrNetworkInfo, user_void); |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 361 | u32 ap_index = 0; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 362 | u8 rssi_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 363 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 364 | if (last_scanned_cnt >= MAX_NUM_SCANNED_NETWORKS_SHADOW) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 365 | PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n"); |
| 366 | return; |
| 367 | } |
| 368 | if (ap_found == -1) { |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 369 | ap_index = last_scanned_cnt; |
| 370 | last_scanned_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 371 | |
| 372 | } else { |
| 373 | ap_index = ap_found; |
| 374 | } |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 375 | rssi_index = last_scanned_shadow[ap_index].strRssi.u8Index; |
| 376 | last_scanned_shadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 377 | if (rssi_index == NUM_RSSI) { |
| 378 | rssi_index = 0; |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 379 | last_scanned_shadow[ap_index].strRssi.u8Full = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 380 | } |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 381 | last_scanned_shadow[ap_index].strRssi.u8Index = rssi_index; |
| 382 | last_scanned_shadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi; |
| 383 | last_scanned_shadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo; |
| 384 | last_scanned_shadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen; |
| 385 | memcpy(last_scanned_shadow[ap_index].au8ssid, |
| 386 | pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen); |
| 387 | memcpy(last_scanned_shadow[ap_index].au8bssid, |
| 388 | pstrNetworkInfo->au8bssid, ETH_ALEN); |
| 389 | last_scanned_shadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod; |
| 390 | last_scanned_shadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod; |
| 391 | last_scanned_shadow[ap_index].u8channel = pstrNetworkInfo->u8channel; |
| 392 | last_scanned_shadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen; |
| 393 | last_scanned_shadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 394 | if (ap_found != -1) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 395 | kfree(last_scanned_shadow[ap_index].pu8IEs); |
| 396 | last_scanned_shadow[ap_index].pu8IEs = |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 397 | kmalloc(pstrNetworkInfo->u16IEsLen, GFP_KERNEL); /* will be deallocated by the WILC_WFI_CfgScan() function */ |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 398 | memcpy(last_scanned_shadow[ap_index].pu8IEs, |
| 399 | pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen); |
| 400 | last_scanned_shadow[ap_index].u32TimeRcvdInScan = jiffies; |
| 401 | last_scanned_shadow[ap_index].u32TimeRcvdInScanCached = jiffies; |
| 402 | last_scanned_shadow[ap_index].u8Found = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 403 | if (ap_found != -1) |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 404 | wilc_free_join_params(last_scanned_shadow[ap_index].pJoinParams); |
| 405 | last_scanned_shadow[ap_index].pJoinParams = pJoinParams; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | |
| 409 | /** |
| 410 | * @brief CfgScanResult |
| 411 | * @details Callback function which returns the scan results found |
| 412 | * |
| 413 | * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is |
| 414 | * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE |
| 415 | * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information |
| 416 | * void* pUserVoid: Private structure associated with the wireless interface |
| 417 | * @return NONE |
| 418 | * @author mabubakr |
| 419 | * @date |
| 420 | * @version 1.0 |
| 421 | */ |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 422 | static void CfgScanResult(enum scan_event scan_event, |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 423 | tstrNetworkInfo *network_info, |
Leo Kim | 30cd10c | 2015-11-19 15:56:33 +0900 | [diff] [blame] | 424 | void *user_void, |
Leo Kim | bdd3460 | 2015-11-19 15:56:34 +0900 | [diff] [blame] | 425 | void *join_params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 426 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 427 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 428 | struct wiphy *wiphy; |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 429 | s32 s32Freq; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 430 | struct ieee80211_channel *channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 431 | struct cfg80211_bss *bss = NULL; |
| 432 | |
Leo Kim | 30cd10c | 2015-11-19 15:56:33 +0900 | [diff] [blame] | 433 | priv = (struct wilc_priv *)user_void; |
Luis de Bethencourt | 7e4e87d | 2015-10-16 16:32:26 +0100 | [diff] [blame] | 434 | if (priv->bCfgScanning) { |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 435 | if (scan_event == SCAN_EVENT_NETWORK_FOUND) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 436 | wiphy = priv->dev->ieee80211_ptr->wiphy; |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 437 | |
| 438 | if (!wiphy) |
| 439 | return; |
| 440 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 441 | if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC && |
| 442 | (((s32)network_info->s8rssi * 100) < 0 || |
| 443 | ((s32)network_info->s8rssi * 100) > 100)) { |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 444 | PRINT_ER("wiphy signal type fial\n"); |
| 445 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 446 | } |
| 447 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 448 | if (network_info) { |
| 449 | s32Freq = ieee80211_channel_to_frequency((s32)network_info->u8channel, IEEE80211_BAND_2GHZ); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 450 | channel = ieee80211_get_channel(wiphy, s32Freq); |
| 451 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 452 | if (!channel) |
| 453 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 454 | |
| 455 | 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] | 456 | "BeaconPeriod: %d\n", channel->center_freq, (((s32)network_info->s8rssi) * 100), |
| 457 | network_info->u16CapInfo, network_info->u16BeaconPeriod); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 458 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 459 | if (network_info->bNewNetwork) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 460 | if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */ |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 461 | PRINT_D(CFG80211_DBG, "Network %s found\n", network_info->au8ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 462 | priv->u32RcvdChCount++; |
| 463 | |
Leo Kim | bdd3460 | 2015-11-19 15:56:34 +0900 | [diff] [blame] | 464 | if (!join_params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 465 | PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n"); |
Leo Kim | bdd3460 | 2015-11-19 15:56:34 +0900 | [diff] [blame] | 466 | add_network_to_shadow(network_info, priv, join_params); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 467 | |
| 468 | /*P2P peers are sent to WPA supplicant and added to shadow table*/ |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 469 | if (!(memcmp("DIRECT-", network_info->au8ssid, 7))) { |
| 470 | bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, network_info->au8bssid, network_info->u64Tsf, network_info->u16CapInfo, |
| 471 | network_info->u16BeaconPeriod, (const u8 *)network_info->pu8IEs, |
| 472 | (size_t)network_info->u16IEsLen, (((s32)network_info->s8rssi) * 100), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 473 | cfg80211_put_bss(wiphy, bss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | |
| 477 | } else { |
| 478 | PRINT_ER("Discovered networks exceeded the max limit\n"); |
| 479 | } |
| 480 | } else { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 481 | u32 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 482 | /* So this network is discovered before, we'll just update its RSSI */ |
| 483 | for (i = 0; i < priv->u32RcvdChCount; i++) { |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 484 | if (memcmp(last_scanned_shadow[i].au8bssid, network_info->au8bssid, 6) == 0) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 485 | 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] | 486 | |
Leo Kim | 0551a72 | 2015-11-19 15:56:32 +0900 | [diff] [blame] | 487 | last_scanned_shadow[i].s8rssi = network_info->s8rssi; |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 488 | last_scanned_shadow[i].u32TimeRcvdInScan = jiffies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 489 | break; |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | } |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 494 | } else if (scan_event == SCAN_EVENT_DONE) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 495 | PRINT_D(CFG80211_DBG, "Scan Done[%p]\n", priv->dev); |
| 496 | PRINT_D(CFG80211_DBG, "Refreshing Scan ...\n"); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 497 | refresh_scan(priv, 1, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 498 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 499 | if (priv->u32RcvdChCount > 0) |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 500 | PRINT_D(CFG80211_DBG, "%d Network(s) found\n", priv->u32RcvdChCount); |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 501 | else |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 502 | PRINT_D(CFG80211_DBG, "No networks found\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 503 | |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 504 | down(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 505 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 506 | if (priv->pstrScanReq != NULL) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 507 | cfg80211_scan_done(priv->pstrScanReq, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 508 | priv->u32RcvdChCount = 0; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 509 | priv->bCfgScanning = false; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 510 | priv->pstrScanReq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 511 | } |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 512 | up(&(priv->hSemScanReq)); |
Leo Kim | 1a4c8ce | 2015-11-19 15:56:31 +0900 | [diff] [blame] | 513 | } else if (scan_event == SCAN_EVENT_ABORTED) { |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 514 | down(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 515 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 516 | PRINT_D(CFG80211_DBG, "Scan Aborted\n"); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 517 | if (priv->pstrScanReq != NULL) { |
Leo Kim | 5e51d8b | 2015-11-19 15:56:28 +0900 | [diff] [blame] | 518 | update_scan_time(); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 519 | refresh_scan(priv, 1, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 520 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 521 | cfg80211_scan_done(priv->pstrScanReq, false); |
| 522 | priv->bCfgScanning = false; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 523 | priv->pstrScanReq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 524 | } |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 525 | up(&(priv->hSemScanReq)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 526 | } |
| 527 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | |
| 531 | /** |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 532 | * @brief CfgConnectResult |
| 533 | * @details |
| 534 | * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either |
| 535 | * connection response or disconnection notification. |
| 536 | * tstrConnectInfo* pstrConnectInfo: COnnection information. |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 537 | * u8 u8MacStatus: Mac Status from firmware |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 538 | * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification |
| 539 | * void* pUserVoid: Private data associated with wireless interface |
| 540 | * @return NONE |
| 541 | * @author mabubakr |
| 542 | * @date 01 MAR 2012 |
| 543 | * @version 1.0 |
| 544 | */ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 545 | int wilc_connecting; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 546 | |
Leo Kim | ed3f037 | 2015-10-12 16:56:01 +0900 | [diff] [blame] | 547 | static void CfgConnectResult(enum conn_event enuConnDisconnEvent, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 548 | tstrConnectInfo *pstrConnectInfo, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 549 | u8 u8MacStatus, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 550 | tstrDisconnectNotifInfo *pstrDisconnectNotifInfo, |
| 551 | void *pUserVoid) |
| 552 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 553 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 554 | struct net_device *dev; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 555 | struct host_if_drv *pstrWFIDrv; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 556 | u8 NullBssid[ETH_ALEN] = {0}; |
Glen Lee | c1ec2c1 | 2015-10-20 17:13:58 +0900 | [diff] [blame] | 557 | struct wilc *wl; |
| 558 | perInterface_wlan_t *nic; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 559 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 560 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 561 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 562 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 563 | dev = priv->dev; |
Glen Lee | c1ec2c1 | 2015-10-20 17:13:58 +0900 | [diff] [blame] | 564 | nic = netdev_priv(dev); |
| 565 | wl = nic->wilc; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 566 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 567 | |
| 568 | if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) { |
| 569 | /*Initialization*/ |
Amitoj Kaur Chawla | baba7c7 | 2015-10-15 13:48:29 +0530 | [diff] [blame] | 570 | u16 u16ConnectStatus; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 571 | |
| 572 | u16ConnectStatus = pstrConnectInfo->u16ConnectStatus; |
| 573 | |
| 574 | PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus); |
| 575 | |
| 576 | if ((u8MacStatus == MAC_DISCONNECTED) && |
| 577 | (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) { |
| 578 | /* The case here is that our station was waiting for association response frame and has just received it containing status code |
| 579 | * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */ |
| 580 | u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 581 | wilc_wlan_set_bssid(priv->dev, NullBssid); |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 582 | eth_zero_addr(wilc_connected_ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 583 | |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 584 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 585 | wlan_channel = INVALID_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 586 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 587 | 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] | 588 | } |
| 589 | |
| 590 | if (u16ConnectStatus == WLAN_STATUS_SUCCESS) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 591 | bool bNeedScanRefresh = false; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 592 | u32 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 593 | |
| 594 | PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0], |
| 595 | 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] | 596 | memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 597 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 598 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 599 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 600 | if (memcmp(last_scanned_shadow[i].au8bssid, |
| 601 | pstrConnectInfo->au8bssid, ETH_ALEN) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 602 | unsigned long now = jiffies; |
| 603 | |
| 604 | if (time_after(now, |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 605 | 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] | 606 | bNeedScanRefresh = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 607 | } |
| 608 | |
| 609 | break; |
| 610 | } |
| 611 | } |
| 612 | |
Abdul Hussain | 5a66bf2 | 2015-06-16 09:44:06 +0000 | [diff] [blame] | 613 | if (bNeedScanRefresh) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 614 | /*Also, refrsh DIRECT- results if */ |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 615 | refresh_scan(priv, 1, true); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 616 | |
| 617 | } |
| 618 | |
| 619 | } |
| 620 | |
| 621 | |
Sudip Mukherjee | 52db7520 | 2015-06-02 14:28:17 +0530 | [diff] [blame] | 622 | 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] | 623 | |
| 624 | PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen); |
| 625 | |
| 626 | cfg80211_connect_result(dev, pstrConnectInfo->au8bssid, |
| 627 | pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen, |
| 628 | pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen, |
| 629 | u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */ |
| 630 | /* be replaced by pstrConnectInfo->u16ConnectStatus */ |
| 631 | } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 632 | wilc_optaining_ip = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 633 | PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n", |
| 634 | pstrDisconnectNotifInfo->u16reason, priv->dev); |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 635 | p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 636 | p2p_recv_random = 0x00; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 637 | wilc_ie = false; |
Shraddha Barke | bcf0265 | 2015-10-05 17:00:32 +0530 | [diff] [blame] | 638 | eth_zero_addr(priv->au8AssociatedBss); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 639 | wilc_wlan_set_bssid(priv->dev, NullBssid); |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 640 | eth_zero_addr(wilc_connected_ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 641 | |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 642 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 643 | wlan_channel = INVALID_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 644 | /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change |
| 645 | * virtual interface to station*/ |
Glen Lee | c1ec2c1 | 2015-10-20 17:13:58 +0900 | [diff] [blame] | 646 | if ((pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 647 | pstrDisconnectNotifInfo->u16reason = 3; |
| 648 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 649 | /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT |
| 650 | * to scan again and retry the connection*/ |
Glen Lee | c1ec2c1 | 2015-10-20 17:13:58 +0900 | [diff] [blame] | 651 | else if ((!pstrWFIDrv->IFC_UP) && (dev == wl->vif[1].ndev)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 652 | pstrDisconnectNotifInfo->u16reason = 1; |
| 653 | } |
| 654 | cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie, |
Sudip Mukherjee | e26bb71 | 2015-06-30 13:51:51 +0530 | [diff] [blame] | 655 | pstrDisconnectNotifInfo->ie_len, false, |
| 656 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 657 | |
| 658 | } |
| 659 | |
| 660 | } |
| 661 | |
| 662 | |
| 663 | /** |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 664 | * @brief set_channel |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 665 | * @details Set channel for a given wireless interface. Some devices |
| 666 | * may support multi-channel operation (by channel hopping) so cfg80211 |
| 667 | * doesn't verify much. Note, however, that the passed netdev may be |
| 668 | * %NULL as well if the user requested changing the channel for the |
| 669 | * device itself, or for a monitor interface. |
| 670 | * @param[in] |
| 671 | * @return int : Return 0 on Success |
| 672 | * @author mdaftedar |
| 673 | * @date 01 MAR 2012 |
| 674 | * @version 1.0 |
| 675 | */ |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 676 | static int set_channel(struct wiphy *wiphy, |
| 677 | struct cfg80211_chan_def *chandef) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 678 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 679 | u32 channelnum = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 680 | struct wilc_priv *priv; |
Chaehyun Lim | dd739ea | 2015-10-02 16:41:20 +0900 | [diff] [blame] | 681 | int result = 0; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 682 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 683 | priv = wiphy_priv(wiphy); |
| 684 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 685 | channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); |
| 686 | 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] | 687 | |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 688 | curr_channel = channelnum; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 689 | result = wilc_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 690 | |
Chaehyun Lim | dd739ea | 2015-10-02 16:41:20 +0900 | [diff] [blame] | 691 | if (result != 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 692 | PRINT_ER("Error in setting channel %d\n", channelnum); |
| 693 | |
Chaehyun Lim | dd739ea | 2015-10-02 16:41:20 +0900 | [diff] [blame] | 694 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 695 | } |
| 696 | |
| 697 | /** |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 698 | * @brief scan |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 699 | * @details Request to do a scan. If returning zero, the scan request is given |
| 700 | * the driver, and will be valid until passed to cfg80211_scan_done(). |
| 701 | * For scan results, call cfg80211_inform_bss(); you can call this outside |
| 702 | * the scan/scan_done bracket too. |
| 703 | * @param[in] |
| 704 | * @return int : Return 0 on Success |
| 705 | * @author mabubakr |
| 706 | * @date 01 MAR 2012 |
| 707 | * @version 1.0 |
| 708 | */ |
| 709 | |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 710 | static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 711 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 712 | struct wilc_priv *priv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 713 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 714 | s32 s32Error = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 715 | u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS]; |
Leo Kim | 607db44 | 2015-10-05 15:25:37 +0900 | [diff] [blame] | 716 | struct hidden_network strHiddenNetwork; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 717 | |
| 718 | priv = wiphy_priv(wiphy); |
| 719 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 720 | priv->pstrScanReq = request; |
| 721 | |
| 722 | priv->u32RcvdChCount = 0; |
| 723 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 724 | wilc_set_wfi_drv_handler(priv->hWILCWFIDrv); |
Leo Kim | 12b0138 | 2015-11-19 15:56:27 +0900 | [diff] [blame] | 725 | reset_shadow_found(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 726 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 727 | priv->bCfgScanning = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 728 | if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */ |
| 729 | /* max_scan_ssids */ |
| 730 | for (i = 0; i < request->n_channels; i++) { |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 731 | au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 732 | PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]); |
| 733 | } |
| 734 | |
| 735 | 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] | 736 | 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] | 737 | |
| 738 | PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids); |
| 739 | |
| 740 | if (request->n_ssids >= 1) { |
| 741 | |
| 742 | |
Leo Kim | 607db44 | 2015-10-05 15:25:37 +0900 | [diff] [blame] | 743 | strHiddenNetwork.pstrHiddenNetworkInfo = kmalloc(request->n_ssids * sizeof(struct hidden_network), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 744 | strHiddenNetwork.u8ssidnum = request->n_ssids; |
| 745 | |
| 746 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 747 | for (i = 0; i < request->n_ssids; i++) { |
| 748 | |
| 749 | if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 750 | strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = kmalloc(request->ssids[i].ssid_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 751 | 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] | 752 | strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len; |
| 753 | } else { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 754 | PRINT_D(CFG80211_DBG, "Received one NULL SSID\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 755 | strHiddenNetwork.u8ssidnum -= 1; |
| 756 | } |
| 757 | } |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 758 | PRINT_D(CFG80211_DBG, "Trigger Scan Request\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 759 | s32Error = wilc_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 760 | au8ScanChanList, request->n_channels, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 761 | (const u8 *)request->ie, request->ie_len, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 762 | CfgScanResult, (void *)priv, &strHiddenNetwork); |
| 763 | } else { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 764 | PRINT_D(CFG80211_DBG, "Trigger Scan Request\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 765 | s32Error = wilc_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 766 | au8ScanChanList, request->n_channels, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 767 | (const u8 *)request->ie, request->ie_len, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 768 | CfgScanResult, (void *)priv, NULL); |
| 769 | } |
| 770 | |
| 771 | } else { |
| 772 | 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] | 773 | " channels\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 774 | } |
| 775 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 776 | if (s32Error != 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 777 | s32Error = -EBUSY; |
| 778 | PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error); |
| 779 | } |
| 780 | |
| 781 | return s32Error; |
| 782 | } |
| 783 | |
| 784 | /** |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 785 | * @brief connect |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 786 | * @details Connect to the ESS with the specified parameters. When connected, |
| 787 | * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS. |
| 788 | * If the connection fails for some reason, call cfg80211_connect_result() |
| 789 | * with the status from the AP. |
| 790 | * @param[in] |
| 791 | * @return int : Return 0 on Success |
| 792 | * @author mabubakr |
| 793 | * @date 01 MAR 2012 |
| 794 | * @version 1.0 |
| 795 | */ |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 796 | static int connect(struct wiphy *wiphy, struct net_device *dev, |
| 797 | struct cfg80211_connect_params *sme) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 798 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 799 | s32 s32Error = 0; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 800 | u32 i; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 801 | u8 u8security = NO_ENCRYPT; |
Leo Kim | 841dfc4 | 2015-10-05 15:25:39 +0900 | [diff] [blame] | 802 | enum AUTHTYPE tenuAuth_type = ANY; |
Dean Lee | 576917a | 2015-06-15 11:58:57 +0900 | [diff] [blame] | 803 | char *pcgroup_encrypt_val = NULL; |
| 804 | char *pccipher_group = NULL; |
| 805 | char *pcwpa_version = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 806 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 807 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 808 | struct host_if_drv *pstrWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 809 | tstrNetworkInfo *pstrNetworkInfo = NULL; |
| 810 | |
| 811 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 812 | wilc_connecting = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 813 | priv = wiphy_priv(wiphy); |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 814 | pstrWFIDrv = (struct host_if_drv *)(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 815 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 816 | wilc_set_wfi_drv_handler(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 817 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 818 | 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] | 819 | if (!(strncmp(sme->ssid, "DIRECT-", 7))) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 820 | PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n"); |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 821 | pstrWFIDrv->p2p_connect = 1; |
| 822 | } else { |
| 823 | pstrWFIDrv->p2p_connect = 0; |
| 824 | } |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 825 | 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] | 826 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 827 | for (i = 0; i < last_scanned_cnt; i++) { |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 828 | if ((sme->ssid_len == last_scanned_shadow[i].u8SsidLen) && |
| 829 | memcmp(last_scanned_shadow[i].au8ssid, |
| 830 | sme->ssid, |
| 831 | sme->ssid_len) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 832 | PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid); |
| 833 | if (sme->bssid == NULL) { |
| 834 | /* BSSID is not passed from the user, so decision of matching |
| 835 | * is done by SSID only */ |
| 836 | PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n"); |
| 837 | break; |
| 838 | } else { |
| 839 | /* BSSID is also passed from the user, so decision of matching |
| 840 | * should consider also this passed BSSID */ |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 841 | if (memcmp(last_scanned_shadow[i].au8bssid, |
| 842 | sme->bssid, |
| 843 | ETH_ALEN) == 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 844 | PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n"); |
| 845 | break; |
| 846 | } |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 851 | if (i < last_scanned_cnt) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 852 | PRINT_D(CFG80211_DBG, "Required bss is in scan results\n"); |
| 853 | |
Leo Kim | f1ab117 | 2015-11-19 15:56:11 +0900 | [diff] [blame] | 854 | pstrNetworkInfo = &last_scanned_shadow[i]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 855 | |
| 856 | PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n", |
| 857 | pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1], |
| 858 | pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3], |
| 859 | pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]); |
| 860 | } else { |
| 861 | s32Error = -ENOENT; |
Leo Kim | 771fbae | 2015-11-19 15:56:10 +0900 | [diff] [blame] | 862 | if (last_scanned_cnt == 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 863 | PRINT_D(CFG80211_DBG, "No Scan results yet\n"); |
| 864 | else |
| 865 | PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error); |
| 866 | |
| 867 | goto done; |
| 868 | } |
| 869 | |
| 870 | priv->WILC_WFI_wep_default = 0; |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 871 | memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key)); |
| 872 | 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] | 873 | |
| 874 | PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions); |
| 875 | PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group); |
| 876 | |
| 877 | PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise); |
| 878 | |
| 879 | if (INFO) { |
| 880 | for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) |
| 881 | PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]); |
| 882 | } |
| 883 | |
| 884 | if (sme->crypto.cipher_group != NO_ENCRYPT) { |
| 885 | /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2} |
| 886 | * we will add to it the pairwise cipher suite(s) */ |
| 887 | pcwpa_version = "Default"; |
| 888 | 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] | 889 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 890 | u8security = ENCRYPT_ENABLED | WEP; |
| 891 | pcgroup_encrypt_val = "WEP40"; |
| 892 | pccipher_group = "WLAN_CIPHER_SUITE_WEP40"; |
| 893 | PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx); |
| 894 | |
| 895 | if (INFO) { |
| 896 | for (i = 0; i < sme->key_len; i++) |
| 897 | PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]); |
| 898 | } |
| 899 | priv->WILC_WFI_wep_default = sme->key_idx; |
| 900 | priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 901 | 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] | 902 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 903 | g_key_wep_params.key_len = sme->key_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 904 | g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 905 | memcpy(g_key_wep_params.key, sme->key, sme->key_len); |
| 906 | g_key_wep_params.key_idx = sme->key_idx; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 907 | g_wep_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 908 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 909 | wilc_set_wep_default_keyid(priv->hWILCWFIDrv, sme->key_idx); |
| 910 | wilc_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 911 | } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 912 | u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; |
| 913 | pcgroup_encrypt_val = "WEP104"; |
| 914 | pccipher_group = "WLAN_CIPHER_SUITE_WEP104"; |
| 915 | |
| 916 | priv->WILC_WFI_wep_default = sme->key_idx; |
| 917 | priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 918 | 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] | 919 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 920 | g_key_wep_params.key_len = sme->key_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 921 | g_key_wep_params.key = kmalloc(sme->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 922 | memcpy(g_key_wep_params.key, sme->key, sme->key_len); |
| 923 | g_key_wep_params.key_idx = sme->key_idx; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 924 | g_wep_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 925 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 926 | wilc_set_wep_default_keyid(priv->hWILCWFIDrv, sme->key_idx); |
| 927 | wilc_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 928 | } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 929 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 930 | u8security = ENCRYPT_ENABLED | WPA2 | TKIP; |
| 931 | pcgroup_encrypt_val = "WPA2_TKIP"; |
| 932 | pccipher_group = "TKIP"; |
| 933 | } else { /* TODO: mostafa: here we assume that any other encryption type is AES */ |
| 934 | /* tenuSecurity_t = WPA2_AES; */ |
| 935 | u8security = ENCRYPT_ENABLED | WPA2 | AES; |
| 936 | pcgroup_encrypt_val = "WPA2_AES"; |
| 937 | pccipher_group = "AES"; |
| 938 | } |
| 939 | pcwpa_version = "WPA_VERSION_2"; |
| 940 | } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) { |
| 941 | if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 942 | u8security = ENCRYPT_ENABLED | WPA | TKIP; |
| 943 | pcgroup_encrypt_val = "WPA_TKIP"; |
| 944 | pccipher_group = "TKIP"; |
| 945 | } else { /* TODO: mostafa: here we assume that any other encryption type is AES */ |
| 946 | /* tenuSecurity_t = WPA_AES; */ |
| 947 | u8security = ENCRYPT_ENABLED | WPA | AES; |
| 948 | pcgroup_encrypt_val = "WPA_AES"; |
| 949 | pccipher_group = "AES"; |
| 950 | |
| 951 | } |
| 952 | pcwpa_version = "WPA_VERSION_1"; |
| 953 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 954 | } else { |
| 955 | s32Error = -ENOTSUPP; |
| 956 | PRINT_ER("Not supported cipher: Error(%d)\n", s32Error); |
| 957 | |
| 958 | goto done; |
| 959 | } |
| 960 | |
| 961 | } |
| 962 | |
| 963 | /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will |
| 964 | * add to it the pairwise cipher suite(s) */ |
| 965 | if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) |
| 966 | || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) { |
| 967 | for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) { |
| 968 | if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) { |
| 969 | u8security = u8security | TKIP; |
| 970 | } else { /* TODO: mostafa: here we assume that any other encryption type is AES */ |
| 971 | u8security = u8security | AES; |
| 972 | } |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group); |
| 977 | |
| 978 | PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type); |
| 979 | switch (sme->auth_type) { |
| 980 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
| 981 | PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n"); |
| 982 | tenuAuth_type = OPEN_SYSTEM; |
| 983 | break; |
| 984 | |
| 985 | case NL80211_AUTHTYPE_SHARED_KEY: |
| 986 | tenuAuth_type = SHARED_KEY; |
| 987 | PRINT_D(CFG80211_DBG, "In SHARED KEY\n"); |
| 988 | break; |
| 989 | |
| 990 | default: |
| 991 | PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type); |
| 992 | } |
| 993 | |
| 994 | |
| 995 | /* ai: key_mgmt: enterprise case */ |
| 996 | if (sme->crypto.n_akm_suites) { |
| 997 | switch (sme->crypto.akm_suites[0]) { |
| 998 | case WLAN_AKM_SUITE_8021X: |
| 999 | tenuAuth_type = IEEE8021; |
| 1000 | break; |
| 1001 | |
| 1002 | default: |
| 1003 | break; |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | |
| 1008 | PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel); |
| 1009 | |
| 1010 | PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n", |
| 1011 | pcgroup_encrypt_val, pccipher_group, pcwpa_version); |
| 1012 | |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 1013 | curr_channel = pstrNetworkInfo->u8channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1014 | |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 1015 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1016 | wlan_channel = pstrNetworkInfo->u8channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1017 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1018 | wilc_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1019 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1020 | s32Error = wilc_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1021 | sme->ssid_len, sme->ie, sme->ie_len, |
| 1022 | CfgConnectResult, (void *)priv, u8security, |
| 1023 | tenuAuth_type, pstrNetworkInfo->u8channel, |
| 1024 | pstrNetworkInfo->pJoinParams); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1025 | if (s32Error != 0) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1026 | PRINT_ER("wilc_set_join_req(): Error(%d)\n", s32Error); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1027 | s32Error = -ENOENT; |
| 1028 | goto done; |
| 1029 | } |
| 1030 | |
| 1031 | done: |
| 1032 | |
| 1033 | return s32Error; |
| 1034 | } |
| 1035 | |
| 1036 | |
| 1037 | /** |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 1038 | * @brief disconnect |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1039 | * @details Disconnect from the BSS/ESS. |
| 1040 | * @param[in] |
| 1041 | * @return int : Return 0 on Success |
| 1042 | * @author mdaftedar |
| 1043 | * @date 01 MAR 2012 |
| 1044 | * @version 1.0 |
| 1045 | */ |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 1046 | 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] | 1047 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1048 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1049 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1050 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 1051 | u8 NullBssid[ETH_ALEN] = {0}; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1052 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1053 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1054 | priv = wiphy_priv(wiphy); |
| 1055 | |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1056 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Leo Kim | ab16ec0 | 2015-10-29 12:05:40 +0900 | [diff] [blame] | 1057 | if (!pstrWFIDrv->p2p_connect) |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1058 | wlan_channel = INVALID_CHANNEL; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1059 | wilc_wlan_set_bssid(priv->dev, NullBssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1060 | |
| 1061 | PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code); |
| 1062 | |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 1063 | p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1064 | p2p_recv_random = 0x00; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 1065 | wilc_ie = false; |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1066 | pstrWFIDrv->p2p_timeout = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1067 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1068 | s32Error = wilc_disconnect(priv->hWILCWFIDrv, reason_code); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1069 | if (s32Error != 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1070 | PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error); |
| 1071 | s32Error = -EINVAL; |
| 1072 | } |
| 1073 | |
| 1074 | return s32Error; |
| 1075 | } |
| 1076 | |
| 1077 | /** |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 1078 | * @brief add_key |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1079 | * @details Add a key with the given parameters. @mac_addr will be %NULL |
| 1080 | * when adding a group key. |
| 1081 | * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key |
| 1082 | * @return int : Return 0 on Success |
| 1083 | * @author mdaftedar |
| 1084 | * @date 01 MAR 2012 |
| 1085 | * @version 1.0 |
| 1086 | */ |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 1087 | static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1088 | bool pairwise, |
| 1089 | const u8 *mac_addr, struct key_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1090 | |
| 1091 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1092 | s32 s32Error = 0, KeyLen = params->key_len; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1093 | u32 i; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1094 | struct wilc_priv *priv; |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 1095 | const u8 *pu8RxMic = NULL; |
| 1096 | const u8 *pu8TxMic = NULL; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1097 | u8 u8mode = NO_ENCRYPT; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1098 | u8 u8gmode = NO_ENCRYPT; |
| 1099 | u8 u8pmode = NO_ENCRYPT; |
Leo Kim | 841dfc4 | 2015-10-05 15:25:39 +0900 | [diff] [blame] | 1100 | enum AUTHTYPE tenuAuth_type = ANY; |
Glen Lee | 7646920 | 2015-10-20 17:13:59 +0900 | [diff] [blame] | 1101 | struct wilc *wl; |
| 1102 | perInterface_wlan_t *nic; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1103 | |
| 1104 | priv = wiphy_priv(wiphy); |
Glen Lee | 7646920 | 2015-10-20 17:13:59 +0900 | [diff] [blame] | 1105 | nic = netdev_priv(netdev); |
| 1106 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1107 | |
| 1108 | PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher); |
| 1109 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 1110 | PRINT_D(CFG80211_DBG, "%p %p %d\n", wiphy, netdev, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1111 | |
| 1112 | PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0], |
| 1113 | params->key[1], |
| 1114 | params->key[2]); |
| 1115 | |
| 1116 | |
| 1117 | switch (params->cipher) { |
| 1118 | case WLAN_CIPHER_SUITE_WEP40: |
| 1119 | case WLAN_CIPHER_SUITE_WEP104: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1120 | if (priv->wdev->iftype == NL80211_IFTYPE_AP) { |
| 1121 | |
| 1122 | priv->WILC_WFI_wep_default = key_index; |
| 1123 | priv->WILC_WFI_wep_key_len[key_index] = params->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1124 | 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] | 1125 | |
| 1126 | PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index); |
| 1127 | PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len); |
| 1128 | |
| 1129 | for (i = 0; i < params->key_len; i++) |
| 1130 | PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]); |
| 1131 | |
| 1132 | tenuAuth_type = OPEN_SYSTEM; |
| 1133 | |
| 1134 | if (params->cipher == WLAN_CIPHER_SUITE_WEP40) |
| 1135 | u8mode = ENCRYPT_ENABLED | WEP; |
| 1136 | else |
| 1137 | u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; |
| 1138 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1139 | wilc_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1140 | break; |
| 1141 | } |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1142 | 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] | 1143 | priv->WILC_WFI_wep_default = key_index; |
| 1144 | priv->WILC_WFI_wep_key_len[key_index] = params->key_len; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1145 | 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] | 1146 | |
| 1147 | PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index); |
| 1148 | PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len); |
| 1149 | if (INFO) { |
| 1150 | for (i = 0; i < params->key_len; i++) |
| 1151 | PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]); |
| 1152 | } |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1153 | wilc_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1154 | } |
| 1155 | |
| 1156 | break; |
| 1157 | |
| 1158 | case WLAN_CIPHER_SUITE_TKIP: |
| 1159 | case WLAN_CIPHER_SUITE_CCMP: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1160 | if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) { |
| 1161 | |
| 1162 | if (priv->wilc_gtk[key_index] == NULL) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1163 | 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] | 1164 | priv->wilc_gtk[key_index]->key = NULL; |
| 1165 | priv->wilc_gtk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1166 | |
| 1167 | } |
| 1168 | if (priv->wilc_ptk[key_index] == NULL) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1169 | 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] | 1170 | priv->wilc_ptk[key_index]->key = NULL; |
| 1171 | priv->wilc_ptk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1172 | } |
| 1173 | |
| 1174 | |
| 1175 | |
Daniel Machon | 1913221 | 2015-08-05 08:18:31 +0200 | [diff] [blame] | 1176 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1177 | if (params->cipher == WLAN_CIPHER_SUITE_TKIP) |
| 1178 | u8gmode = ENCRYPT_ENABLED | WPA | TKIP; |
| 1179 | else |
| 1180 | u8gmode = ENCRYPT_ENABLED | WPA2 | AES; |
| 1181 | |
| 1182 | priv->wilc_groupkey = u8gmode; |
| 1183 | |
| 1184 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1185 | |
| 1186 | pu8TxMic = params->key + 24; |
| 1187 | pu8RxMic = params->key + 16; |
| 1188 | KeyLen = params->key_len - 16; |
| 1189 | } |
| 1190 | /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/ |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1191 | kfree(priv->wilc_gtk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1192 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1193 | priv->wilc_gtk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1194 | memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1195 | |
| 1196 | /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/ |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1197 | kfree(priv->wilc_gtk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1198 | |
| 1199 | if ((params->seq_len) > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1200 | priv->wilc_gtk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1201 | memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1202 | } |
| 1203 | |
| 1204 | priv->wilc_gtk[key_index]->cipher = params->cipher; |
| 1205 | priv->wilc_gtk[key_index]->key_len = params->key_len; |
| 1206 | priv->wilc_gtk[key_index]->seq_len = params->seq_len; |
| 1207 | |
| 1208 | if (INFO) { |
| 1209 | for (i = 0; i < params->key_len; i++) |
| 1210 | PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]); |
| 1211 | for (i = 0; i < params->seq_len; i++) |
| 1212 | PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); |
| 1213 | } |
| 1214 | |
| 1215 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1216 | wilc_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1217 | key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode); |
| 1218 | |
| 1219 | } else { |
| 1220 | 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]); |
| 1221 | |
| 1222 | if (params->cipher == WLAN_CIPHER_SUITE_TKIP) |
| 1223 | u8pmode = ENCRYPT_ENABLED | WPA | TKIP; |
| 1224 | else |
| 1225 | u8pmode = priv->wilc_groupkey | AES; |
| 1226 | |
| 1227 | |
| 1228 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1229 | |
| 1230 | pu8TxMic = params->key + 24; |
| 1231 | pu8RxMic = params->key + 16; |
| 1232 | KeyLen = params->key_len - 16; |
| 1233 | } |
| 1234 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1235 | kfree(priv->wilc_ptk[key_index]->key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1236 | |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1237 | priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1238 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1239 | kfree(priv->wilc_ptk[key_index]->seq); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1240 | |
| 1241 | if ((params->seq_len) > 0) |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1242 | priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1243 | |
| 1244 | if (INFO) { |
| 1245 | for (i = 0; i < params->key_len; i++) |
| 1246 | PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]); |
| 1247 | |
| 1248 | for (i = 0; i < params->seq_len; i++) |
| 1249 | PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]); |
| 1250 | } |
| 1251 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1252 | memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1253 | |
| 1254 | if ((params->seq_len) > 0) |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1255 | memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1256 | |
| 1257 | priv->wilc_ptk[key_index]->cipher = params->cipher; |
| 1258 | priv->wilc_ptk[key_index]->key_len = params->key_len; |
| 1259 | priv->wilc_ptk[key_index]->seq_len = params->seq_len; |
| 1260 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1261 | wilc_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1262 | pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index); |
| 1263 | } |
| 1264 | break; |
| 1265 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1266 | |
| 1267 | { |
| 1268 | u8mode = 0; |
Daniel Machon | 1913221 | 2015-08-05 08:18:31 +0200 | [diff] [blame] | 1269 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1270 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1271 | /* swap the tx mic by rx mic */ |
| 1272 | pu8RxMic = params->key + 24; |
| 1273 | pu8TxMic = params->key + 16; |
| 1274 | KeyLen = params->key_len - 16; |
| 1275 | } |
| 1276 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1277 | /*save keys only on interface 0 (wifi interface)*/ |
Glen Lee | 7646920 | 2015-10-20 17:13:59 +0900 | [diff] [blame] | 1278 | if (!g_gtk_keys_saved && netdev == wl->vif[0].ndev) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1279 | g_add_gtk_key_params.key_idx = key_index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1280 | g_add_gtk_key_params.pairwise = pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1281 | if (!mac_addr) { |
| 1282 | g_add_gtk_key_params.mac_addr = NULL; |
| 1283 | } else { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1284 | g_add_gtk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1285 | memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN); |
| 1286 | } |
| 1287 | g_key_gtk_params.key_len = params->key_len; |
| 1288 | g_key_gtk_params.seq_len = params->seq_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1289 | g_key_gtk_params.key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1290 | memcpy(g_key_gtk_params.key, params->key, params->key_len); |
| 1291 | if (params->seq_len > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1292 | g_key_gtk_params.seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1293 | memcpy(g_key_gtk_params.seq, params->seq, params->seq_len); |
| 1294 | } |
| 1295 | g_key_gtk_params.cipher = params->cipher; |
| 1296 | |
| 1297 | PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0], |
| 1298 | g_key_gtk_params.key[1], |
| 1299 | g_key_gtk_params.key[2]); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1300 | g_gtk_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1301 | } |
| 1302 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1303 | wilc_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1304 | key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1305 | } else { |
| 1306 | if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { |
| 1307 | /* swap the tx mic by rx mic */ |
| 1308 | pu8RxMic = params->key + 24; |
| 1309 | pu8TxMic = params->key + 16; |
| 1310 | KeyLen = params->key_len - 16; |
| 1311 | } |
| 1312 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1313 | /*save keys only on interface 0 (wifi interface)*/ |
Glen Lee | 7646920 | 2015-10-20 17:13:59 +0900 | [diff] [blame] | 1314 | if (!g_ptk_keys_saved && netdev == wl->vif[0].ndev) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1315 | g_add_ptk_key_params.key_idx = key_index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1316 | g_add_ptk_key_params.pairwise = pairwise; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1317 | if (!mac_addr) { |
| 1318 | g_add_ptk_key_params.mac_addr = NULL; |
| 1319 | } else { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1320 | g_add_ptk_key_params.mac_addr = kmalloc(ETH_ALEN, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1321 | memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN); |
| 1322 | } |
| 1323 | g_key_ptk_params.key_len = params->key_len; |
| 1324 | g_key_ptk_params.seq_len = params->seq_len; |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1325 | g_key_ptk_params.key = kmalloc(params->key_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1326 | memcpy(g_key_ptk_params.key, params->key, params->key_len); |
| 1327 | if (params->seq_len > 0) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1328 | g_key_ptk_params.seq = kmalloc(params->seq_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1329 | memcpy(g_key_ptk_params.seq, params->seq, params->seq_len); |
| 1330 | } |
| 1331 | g_key_ptk_params.cipher = params->cipher; |
| 1332 | |
| 1333 | PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0], |
| 1334 | g_key_ptk_params.key[1], |
| 1335 | g_key_ptk_params.key[2]); |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1336 | g_ptk_keys_saved = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1337 | } |
| 1338 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1339 | wilc_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1340 | pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index); |
| 1341 | PRINT_D(CFG80211_DBG, "Adding pairwise key\n"); |
| 1342 | if (INFO) { |
| 1343 | for (i = 0; i < params->key_len; i++) |
| 1344 | PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]); |
| 1345 | } |
| 1346 | } |
| 1347 | } |
| 1348 | break; |
| 1349 | |
| 1350 | default: |
| 1351 | PRINT_ER("Not supported cipher: Error(%d)\n", s32Error); |
| 1352 | s32Error = -ENOTSUPP; |
| 1353 | |
| 1354 | } |
| 1355 | |
| 1356 | return s32Error; |
| 1357 | } |
| 1358 | |
| 1359 | /** |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 1360 | * @brief del_key |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1361 | * @details Remove a key given the @mac_addr (%NULL for a group key) |
| 1362 | * and @key_index, return -ENOENT if the key doesn't exist. |
| 1363 | * @param[in] |
| 1364 | * @return int : Return 0 on Success |
| 1365 | * @author mdaftedar |
| 1366 | * @date 01 MAR 2012 |
| 1367 | * @version 1.0 |
| 1368 | */ |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 1369 | static int del_key(struct wiphy *wiphy, struct net_device *netdev, |
| 1370 | u8 key_index, |
| 1371 | bool pairwise, |
| 1372 | const u8 *mac_addr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1373 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1374 | struct wilc_priv *priv; |
Glen Lee | 692e2ac | 2015-10-20 17:14:00 +0900 | [diff] [blame] | 1375 | struct wilc *wl; |
| 1376 | perInterface_wlan_t *nic; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1377 | |
| 1378 | priv = wiphy_priv(wiphy); |
Glen Lee | 692e2ac | 2015-10-20 17:14:00 +0900 | [diff] [blame] | 1379 | nic = netdev_priv(netdev); |
| 1380 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1381 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1382 | /*delete saved keys, if any*/ |
Glen Lee | 692e2ac | 2015-10-20 17:14:00 +0900 | [diff] [blame] | 1383 | if (netdev == wl->vif[0].ndev) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1384 | g_ptk_keys_saved = false; |
| 1385 | g_gtk_keys_saved = false; |
| 1386 | g_wep_keys_saved = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1387 | |
| 1388 | /*Delete saved WEP keys params, if any*/ |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1389 | kfree(g_key_wep_params.key); |
| 1390 | g_key_wep_params.key = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1391 | |
| 1392 | /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/ |
| 1393 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1394 | if ((priv->wilc_gtk[key_index]) != NULL) { |
| 1395 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1396 | kfree(priv->wilc_gtk[key_index]->key); |
| 1397 | priv->wilc_gtk[key_index]->key = NULL; |
| 1398 | kfree(priv->wilc_gtk[key_index]->seq); |
| 1399 | priv->wilc_gtk[key_index]->seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1400 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1401 | kfree(priv->wilc_gtk[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1402 | priv->wilc_gtk[key_index] = NULL; |
| 1403 | |
| 1404 | } |
| 1405 | |
| 1406 | if ((priv->wilc_ptk[key_index]) != NULL) { |
| 1407 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1408 | kfree(priv->wilc_ptk[key_index]->key); |
| 1409 | priv->wilc_ptk[key_index]->key = NULL; |
| 1410 | kfree(priv->wilc_ptk[key_index]->seq); |
| 1411 | priv->wilc_ptk[key_index]->seq = NULL; |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1412 | kfree(priv->wilc_ptk[key_index]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1413 | priv->wilc_ptk[key_index] = NULL; |
| 1414 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1415 | |
| 1416 | /*Delete saved PTK and GTK keys params, if any*/ |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1417 | kfree(g_key_ptk_params.key); |
| 1418 | g_key_ptk_params.key = NULL; |
| 1419 | kfree(g_key_ptk_params.seq); |
| 1420 | g_key_ptk_params.seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1421 | |
Shraddha Barke | cccfc39 | 2015-10-12 20:49:19 +0530 | [diff] [blame] | 1422 | kfree(g_key_gtk_params.key); |
| 1423 | g_key_gtk_params.key = NULL; |
| 1424 | kfree(g_key_gtk_params.seq); |
| 1425 | g_key_gtk_params.seq = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1426 | |
| 1427 | /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1428 | wilc_set_machw_change_vir_if(netdev, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1429 | } |
| 1430 | |
| 1431 | if (key_index >= 0 && key_index <= 3) { |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 1432 | 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] | 1433 | priv->WILC_WFI_wep_key_len[key_index] = 0; |
| 1434 | |
| 1435 | PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1436 | wilc_remove_wep_key(priv->hWILCWFIDrv, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1437 | } else { |
| 1438 | PRINT_D(CFG80211_DBG, "Removing all installed keys\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1439 | wilc_remove_key(priv->hWILCWFIDrv, mac_addr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1440 | } |
| 1441 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1442 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1443 | } |
| 1444 | |
| 1445 | /** |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 1446 | * @brief get_key |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1447 | * @details Get information about the key with the given parameters. |
| 1448 | * @mac_addr will be %NULL when requesting information for a group |
| 1449 | * key. All pointers given to the @callback function need not be valid |
| 1450 | * after it returns. This function should return an error if it is |
| 1451 | * not possible to retrieve the key, -ENOENT if it doesn't exist. |
| 1452 | * @param[in] |
| 1453 | * @return int : Return 0 on Success |
| 1454 | * @author mdaftedar |
| 1455 | * @date 01 MAR 2012 |
| 1456 | * @version 1.0 |
| 1457 | */ |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 1458 | static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1459 | bool pairwise, |
| 1460 | 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] | 1461 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1462 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1463 | struct key_params key_params; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1464 | u32 i; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1465 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1466 | priv = wiphy_priv(wiphy); |
| 1467 | |
| 1468 | |
Alison Schofield | 3604af5 | 2015-10-12 13:22:44 -0700 | [diff] [blame] | 1469 | if (!pairwise) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1470 | PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index); |
| 1471 | |
| 1472 | key_params.key = priv->wilc_gtk[key_index]->key; |
| 1473 | key_params.cipher = priv->wilc_gtk[key_index]->cipher; |
| 1474 | key_params.key_len = priv->wilc_gtk[key_index]->key_len; |
| 1475 | key_params.seq = priv->wilc_gtk[key_index]->seq; |
| 1476 | key_params.seq_len = priv->wilc_gtk[key_index]->seq_len; |
| 1477 | if (INFO) { |
| 1478 | for (i = 0; i < key_params.key_len; i++) |
| 1479 | PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]); |
| 1480 | } |
| 1481 | } else { |
| 1482 | PRINT_D(CFG80211_DBG, "Getting pairwise key\n"); |
| 1483 | |
| 1484 | key_params.key = priv->wilc_ptk[key_index]->key; |
| 1485 | key_params.cipher = priv->wilc_ptk[key_index]->cipher; |
| 1486 | key_params.key_len = priv->wilc_ptk[key_index]->key_len; |
| 1487 | key_params.seq = priv->wilc_ptk[key_index]->seq; |
| 1488 | key_params.seq_len = priv->wilc_ptk[key_index]->seq_len; |
| 1489 | } |
| 1490 | |
| 1491 | callback(cookie, &key_params); |
| 1492 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1493 | return 0; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1494 | } |
| 1495 | |
| 1496 | /** |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 1497 | * @brief set_default_key |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1498 | * @details Set the default management frame key on an interface |
| 1499 | * @param[in] |
| 1500 | * @return int : Return 0 on Success. |
| 1501 | * @author mdaftedar |
| 1502 | * @date 01 MAR 2012 |
| 1503 | * @version 1.0 |
| 1504 | */ |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 1505 | static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, |
| 1506 | bool unicast, bool multicast) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1507 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1508 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1509 | |
| 1510 | |
| 1511 | priv = wiphy_priv(wiphy); |
| 1512 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 1513 | 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] | 1514 | |
| 1515 | if (key_index != priv->WILC_WFI_wep_default) { |
| 1516 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1517 | wilc_set_wep_default_keyid(priv->hWILCWFIDrv, key_index); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1518 | } |
| 1519 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1520 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | /** |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 1524 | * @brief get_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1525 | * @details Get station information for the station identified by @mac |
| 1526 | * @param[in] NONE |
| 1527 | * @return int : Return 0 on Success. |
| 1528 | * @author mdaftedar |
| 1529 | * @date 01 MAR 2012 |
| 1530 | * @version 1.0 |
| 1531 | */ |
| 1532 | |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 1533 | static int get_station(struct wiphy *wiphy, struct net_device *dev, |
| 1534 | const u8 *mac, struct station_info *sinfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1535 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1536 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1537 | perInterface_wlan_t *nic; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1538 | u32 i = 0; |
| 1539 | u32 associatedsta = 0; |
| 1540 | u32 inactive_time = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1541 | priv = wiphy_priv(wiphy); |
| 1542 | nic = netdev_priv(dev); |
| 1543 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1544 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
| 1545 | PRINT_D(HOSTAPD_DBG, "Getting station parameters\n"); |
| 1546 | |
| 1547 | PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]); |
| 1548 | |
| 1549 | for (i = 0; i < NUM_STA_ASSOCIATED; i++) { |
| 1550 | |
| 1551 | if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) { |
| 1552 | associatedsta = i; |
| 1553 | break; |
| 1554 | } |
| 1555 | |
| 1556 | } |
| 1557 | |
| 1558 | if (associatedsta == -1) { |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1559 | PRINT_ER("Station required is not associated\n"); |
| 1560 | return -ENOENT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1561 | } |
| 1562 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1563 | sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1564 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1565 | wilc_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1566 | sinfo->inactive_time = 1000 * inactive_time; |
| 1567 | PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time); |
| 1568 | |
| 1569 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1570 | |
| 1571 | if (nic->iftype == STATION_MODE) { |
Leo Kim | 03e7b9c | 2015-10-12 16:55:58 +0900 | [diff] [blame] | 1572 | struct rf_info strStatistics; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1573 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1574 | wilc_get_statistics(priv->hWILCWFIDrv, &strStatistics); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1575 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1576 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) | |
Chandra S Gorentla | 6212990 | 2015-08-05 22:11:57 +0530 | [diff] [blame] | 1577 | BIT(NL80211_STA_INFO_RX_PACKETS) | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1578 | BIT(NL80211_STA_INFO_TX_PACKETS) | |
| 1579 | BIT(NL80211_STA_INFO_TX_FAILED) | |
| 1580 | BIT(NL80211_STA_INFO_TX_BITRATE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1581 | |
Leo Kim | 00c8dfc | 2015-10-29 12:05:30 +0900 | [diff] [blame] | 1582 | sinfo->signal = strStatistics.rssi; |
Leo Kim | 9b99274 | 2015-10-29 12:05:32 +0900 | [diff] [blame] | 1583 | sinfo->rx_packets = strStatistics.rx_cnt; |
Leo Kim | 5416037 | 2015-10-29 12:05:33 +0900 | [diff] [blame] | 1584 | sinfo->tx_packets = strStatistics.tx_cnt + strStatistics.tx_fail_cnt; |
| 1585 | sinfo->tx_failed = strStatistics.tx_fail_cnt; |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1586 | sinfo->txrate.legacy = strStatistics.link_speed * 10; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1587 | |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1588 | if ((strStatistics.link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && |
| 1589 | (strStatistics.link_speed != DEFAULT_LINK_SPEED)) |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1590 | wilc_enable_tcp_ack_filter(true); |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1591 | else if (strStatistics.link_speed != DEFAULT_LINK_SPEED) |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1592 | wilc_enable_tcp_ack_filter(false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1593 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1594 | PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets, |
| 1595 | sinfo->tx_failed, sinfo->txrate.legacy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1596 | } |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 1597 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1598 | } |
| 1599 | |
| 1600 | |
| 1601 | /** |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 1602 | * @brief change_bss |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1603 | * @details Modify parameters for a given BSS. |
| 1604 | * @param[in] |
| 1605 | * -use_cts_prot: Whether to use CTS protection |
| 1606 | * (0 = no, 1 = yes, -1 = do not change) |
| 1607 | * -use_short_preamble: Whether the use of short preambles is allowed |
| 1608 | * (0 = no, 1 = yes, -1 = do not change) |
| 1609 | * -use_short_slot_time: Whether the use of short slot time is allowed |
| 1610 | * (0 = no, 1 = yes, -1 = do not change) |
| 1611 | * -basic_rates: basic rates in IEEE 802.11 format |
| 1612 | * (or NULL for no change) |
| 1613 | * -basic_rates_len: number of basic rates |
| 1614 | * -ap_isolate: do not forward packets between connected stations |
| 1615 | * -ht_opmode: HT Operation mode |
| 1616 | * (u16 = opmode, -1 = do not change) |
| 1617 | * @return int : Return 0 on Success. |
| 1618 | * @author mdaftedar |
| 1619 | * @date 01 MAR 2012 |
| 1620 | * @version 1.0 |
| 1621 | */ |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 1622 | static int change_bss(struct wiphy *wiphy, struct net_device *dev, |
| 1623 | struct bss_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1624 | { |
| 1625 | PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n"); |
| 1626 | return 0; |
| 1627 | } |
| 1628 | |
| 1629 | /** |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 1630 | * @brief set_wiphy_params |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1631 | * @details Notify that wiphy parameters have changed; |
| 1632 | * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values |
| 1633 | * have changed. |
| 1634 | * @return int : Return 0 on Success |
| 1635 | * @author mdaftedar |
| 1636 | * @date 01 MAR 2012 |
| 1637 | * @version 1.0 |
| 1638 | */ |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 1639 | static int set_wiphy_params(struct wiphy *wiphy, u32 changed) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1640 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1641 | s32 s32Error = 0; |
Leo Kim | 9529650 | 2015-10-05 15:25:46 +0900 | [diff] [blame] | 1642 | struct cfg_param_val pstrCfgParamVal; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1643 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1644 | |
| 1645 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1646 | |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1647 | pstrCfgParamVal.flag = 0; |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 1648 | PRINT_D(CFG80211_DBG, "Setting Wiphy params\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1649 | |
| 1650 | if (changed & WIPHY_PARAM_RETRY_SHORT) { |
| 1651 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n", |
| 1652 | priv->dev->ieee80211_ptr->wiphy->retry_short); |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1653 | pstrCfgParamVal.flag |= RETRY_SHORT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1654 | pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short; |
| 1655 | } |
| 1656 | if (changed & WIPHY_PARAM_RETRY_LONG) { |
| 1657 | |
| 1658 | 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] | 1659 | pstrCfgParamVal.flag |= RETRY_LONG; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1660 | pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long; |
| 1661 | |
| 1662 | } |
| 1663 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { |
| 1664 | 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] | 1665 | pstrCfgParamVal.flag |= FRAG_THRESHOLD; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1666 | pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold; |
| 1667 | |
| 1668 | } |
| 1669 | |
| 1670 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { |
| 1671 | PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold); |
| 1672 | |
Tony Cho | 87c05b2 | 2015-10-12 16:56:07 +0900 | [diff] [blame] | 1673 | pstrCfgParamVal.flag |= RTS_THRESHOLD; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1674 | pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold; |
| 1675 | |
| 1676 | } |
| 1677 | |
| 1678 | PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1679 | s32Error = wilc_hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1680 | if (s32Error) |
| 1681 | PRINT_ER("Error in setting WIPHY PARAMS\n"); |
| 1682 | |
| 1683 | |
| 1684 | return s32Error; |
| 1685 | } |
Arnd Bergmann | e5af056 | 2015-05-29 22:52:12 +0200 | [diff] [blame] | 1686 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1687 | /** |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 1688 | * @brief set_pmksa |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1689 | * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac |
| 1690 | * devices running firmwares capable of generating the (re) association |
| 1691 | * RSN IE. It allows for faster roaming between WPA2 BSSIDs. |
| 1692 | * @param[in] |
| 1693 | * @return int : Return 0 on Success |
| 1694 | * @author mdaftedar |
| 1695 | * @date 01 MAR 2012 |
| 1696 | * @version 1.0 |
| 1697 | */ |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 1698 | static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, |
| 1699 | struct cfg80211_pmksa *pmksa) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1700 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1701 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1702 | s32 s32Error = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1703 | u8 flag = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1704 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1705 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1706 | |
| 1707 | PRINT_D(CFG80211_DBG, "Setting PMKSA\n"); |
| 1708 | |
| 1709 | |
| 1710 | for (i = 0; i < priv->pmkid_list.numpmkid; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1711 | if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1712 | ETH_ALEN)) { |
| 1713 | /*If bssid already exists and pmkid value needs to reset*/ |
| 1714 | flag = PMKID_FOUND; |
| 1715 | PRINT_D(CFG80211_DBG, "PMKID already exists\n"); |
| 1716 | break; |
| 1717 | } |
| 1718 | } |
| 1719 | if (i < WILC_MAX_NUM_PMKIDS) { |
| 1720 | PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n"); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1721 | memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1722 | ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1723 | memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1724 | PMKID_LEN); |
| 1725 | if (!(flag == PMKID_FOUND)) |
| 1726 | priv->pmkid_list.numpmkid++; |
| 1727 | } else { |
| 1728 | PRINT_ER("Invalid PMKID index\n"); |
| 1729 | s32Error = -EINVAL; |
| 1730 | } |
| 1731 | |
| 1732 | if (!s32Error) { |
| 1733 | PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1734 | s32Error = wilc_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1735 | } |
| 1736 | return s32Error; |
| 1737 | } |
| 1738 | |
| 1739 | /** |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 1740 | * @brief del_pmksa |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1741 | * @details Delete a cached PMKID. |
| 1742 | * @param[in] |
| 1743 | * @return int : Return 0 on Success |
| 1744 | * @author mdaftedar |
| 1745 | * @date 01 MAR 2012 |
| 1746 | * @version 1.0 |
| 1747 | */ |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 1748 | static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, |
| 1749 | struct cfg80211_pmksa *pmksa) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1750 | { |
| 1751 | |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1752 | u32 i; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1753 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1754 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1755 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1756 | |
| 1757 | PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n"); |
| 1758 | |
| 1759 | for (i = 0; i < priv->pmkid_list.numpmkid; i++) { |
Chaehyun Lim | 1a646e7 | 2015-08-07 09:02:03 +0900 | [diff] [blame] | 1760 | if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1761 | ETH_ALEN)) { |
| 1762 | /*If bssid is found, reset the values*/ |
| 1763 | PRINT_D(CFG80211_DBG, "Reseting PMKID values\n"); |
Leo Kim | cd1e6cb | 2015-10-05 15:25:45 +0900 | [diff] [blame] | 1764 | memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(struct host_if_pmkid)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1765 | break; |
| 1766 | } |
| 1767 | } |
| 1768 | |
| 1769 | if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) { |
| 1770 | for (; i < (priv->pmkid_list.numpmkid - 1); i++) { |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1771 | memcpy(priv->pmkid_list.pmkidlist[i].bssid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1772 | priv->pmkid_list.pmkidlist[i + 1].bssid, |
| 1773 | ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1774 | memcpy(priv->pmkid_list.pmkidlist[i].pmkid, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1775 | priv->pmkid_list.pmkidlist[i].pmkid, |
| 1776 | PMKID_LEN); |
| 1777 | } |
| 1778 | priv->pmkid_list.numpmkid--; |
| 1779 | } else { |
| 1780 | s32Error = -EINVAL; |
| 1781 | } |
| 1782 | |
| 1783 | return s32Error; |
| 1784 | } |
| 1785 | |
| 1786 | /** |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 1787 | * @brief flush_pmksa |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1788 | * @details Flush all cached PMKIDs. |
| 1789 | * @param[in] |
| 1790 | * @return int : Return 0 on Success |
| 1791 | * @author mdaftedar |
| 1792 | * @date 01 MAR 2012 |
| 1793 | * @version 1.0 |
| 1794 | */ |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 1795 | static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1796 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1797 | struct wilc_priv *priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1798 | |
| 1799 | PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n"); |
| 1800 | |
| 1801 | /*Get cashed Pmkids and set all with zeros*/ |
Leo Kim | a949f90 | 2015-10-05 15:25:44 +0900 | [diff] [blame] | 1802 | memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1803 | |
| 1804 | return 0; |
| 1805 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1806 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1807 | |
| 1808 | /** |
| 1809 | * @brief WILC_WFI_CfgParseRxAction |
| 1810 | * @details Function parses the received frames and modifies the following attributes: |
| 1811 | * -GO Intent |
| 1812 | * -Channel list |
| 1813 | * -Operating Channel |
| 1814 | * |
| 1815 | * @param[in] u8* Buffer, u32 length |
| 1816 | * @return NONE. |
| 1817 | * @author mdaftedar |
| 1818 | * @date 12 DEC 2012 |
| 1819 | * @version |
| 1820 | */ |
| 1821 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 1822 | static void WILC_WFI_CfgParseRxAction(u8 *buf, u32 len) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1823 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1824 | u32 index = 0; |
| 1825 | u32 i = 0, j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1826 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1827 | u8 op_channel_attr_index = 0; |
| 1828 | u8 channel_list_attr_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1829 | |
| 1830 | while (index < len) { |
| 1831 | if (buf[index] == GO_INTENT_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1832 | buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1833 | } |
| 1834 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1835 | if (buf[index] == CHANLIST_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1836 | channel_list_attr_index = index; |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1837 | else if (buf[index] == OPERCHAN_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1838 | op_channel_attr_index = index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1839 | index += buf[index + 1] + 3; /* ID,Length byte */ |
| 1840 | } |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1841 | if (wlan_channel != INVALID_CHANNEL) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1842 | /*Modify channel list attribute*/ |
| 1843 | if (channel_list_attr_index) { |
| 1844 | PRINT_D(GENERIC_DBG, "Modify channel list attribute\n"); |
| 1845 | for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { |
| 1846 | if (buf[i] == 0x51) { |
| 1847 | for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) { |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1848 | buf[j] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1849 | } |
| 1850 | break; |
| 1851 | } |
| 1852 | } |
| 1853 | } |
| 1854 | /*Modify operating channel attribute*/ |
| 1855 | if (op_channel_attr_index) { |
| 1856 | PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n"); |
| 1857 | buf[op_channel_attr_index + 6] = 0x51; |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1858 | buf[op_channel_attr_index + 7] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1859 | } |
| 1860 | } |
| 1861 | } |
| 1862 | |
| 1863 | /** |
| 1864 | * @brief WILC_WFI_CfgParseTxAction |
| 1865 | * @details Function parses the transmitted action frames and modifies the |
| 1866 | * GO Intent attribute |
| 1867 | * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype |
| 1868 | * @return NONE. |
| 1869 | * @author mdaftedar |
| 1870 | * @date 12 DEC 2012 |
| 1871 | * @version |
| 1872 | */ |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 1873 | 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] | 1874 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1875 | u32 index = 0; |
| 1876 | u32 i = 0, j = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1877 | |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1878 | u8 op_channel_attr_index = 0; |
| 1879 | u8 channel_list_attr_index = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1880 | |
| 1881 | while (index < len) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1882 | if (buf[index] == GO_INTENT_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1883 | buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1884 | |
| 1885 | break; |
| 1886 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1887 | |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1888 | if (buf[index] == CHANLIST_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1889 | channel_list_attr_index = index; |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1890 | else if (buf[index] == OPERCHAN_ATTR_ID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1891 | op_channel_attr_index = index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1892 | index += buf[index + 1] + 3; /* ID,Length byte */ |
| 1893 | } |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1894 | if (wlan_channel != INVALID_CHANNEL && bOperChan) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1895 | /*Modify channel list attribute*/ |
| 1896 | if (channel_list_attr_index) { |
| 1897 | PRINT_D(GENERIC_DBG, "Modify channel list attribute\n"); |
| 1898 | for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) { |
| 1899 | if (buf[i] == 0x51) { |
| 1900 | for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) { |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1901 | buf[j] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1902 | } |
| 1903 | break; |
| 1904 | } |
| 1905 | } |
| 1906 | } |
| 1907 | /*Modify operating channel attribute*/ |
| 1908 | if (op_channel_attr_index) { |
| 1909 | PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n"); |
| 1910 | buf[op_channel_attr_index + 6] = 0x51; |
Leo Kim | 0bd8274 | 2015-11-19 15:56:14 +0900 | [diff] [blame] | 1911 | buf[op_channel_attr_index + 7] = wlan_channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1912 | } |
| 1913 | } |
| 1914 | } |
| 1915 | |
| 1916 | /* @brief WILC_WFI_p2p_rx |
| 1917 | * @details |
| 1918 | * @param[in] |
| 1919 | * |
| 1920 | * @return None |
| 1921 | * @author Mai Daftedar |
| 1922 | * @date 2 JUN 2013 |
| 1923 | * @version 1.0 |
| 1924 | */ |
| 1925 | |
Chaehyun Lim | fbc2fe1 | 2015-09-15 14:06:16 +0900 | [diff] [blame] | 1926 | 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] | 1927 | { |
| 1928 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1929 | struct wilc_priv *priv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1930 | u32 header, pkt_offset; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1931 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1932 | u32 i = 0; |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 1933 | s32 s32Freq; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 1934 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1935 | priv = wiphy_priv(dev->ieee80211_ptr->wiphy); |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 1936 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1937 | |
| 1938 | /* Get WILC header */ |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1939 | memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1940 | |
| 1941 | /* The packet offset field conain info about what type of managment frame */ |
| 1942 | /* we are dealing with and ack status */ |
| 1943 | pkt_offset = GET_PKT_OFFSET(header); |
| 1944 | |
| 1945 | if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { |
| 1946 | if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) { |
| 1947 | PRINT_D(GENERIC_DBG, "Probe response ACK\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1948 | 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] | 1949 | return; |
| 1950 | } else { |
| 1951 | if (pkt_offset & IS_MGMT_STATUS_SUCCES) { |
| 1952 | 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], |
| 1953 | buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1954 | 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] | 1955 | } else { |
| 1956 | 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], |
| 1957 | buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1958 | 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] | 1959 | } |
| 1960 | return; |
| 1961 | } |
| 1962 | } else { |
| 1963 | |
| 1964 | PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]); |
| 1965 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1966 | /*Upper layer is informed that the frame is received on this freq*/ |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 1967 | s32Freq = ieee80211_channel_to_frequency(curr_channel, IEEE80211_BAND_2GHZ); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1968 | |
| 1969 | if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { |
| 1970 | PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]); |
| 1971 | |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1972 | if (priv->bCfgScanning && time_after_eq(jiffies, (unsigned long)pstrWFIDrv->p2p_timeout)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1973 | PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n"); |
| 1974 | return; |
| 1975 | } |
| 1976 | if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { |
| 1977 | |
| 1978 | switch (buff[ACTION_SUBTYPE_ID]) { |
| 1979 | case GAS_INTIAL_REQ: |
| 1980 | PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]); |
| 1981 | break; |
| 1982 | |
| 1983 | case GAS_INTIAL_RSP: |
| 1984 | PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]); |
| 1985 | break; |
| 1986 | |
| 1987 | case PUBLIC_ACT_VENDORSPEC: |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 1988 | if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1989 | 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] | 1990 | if (!wilc_ie) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1991 | for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 1992 | if (!memcmp(p2p_vendor_spec, &buff[i], 6)) { |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1993 | p2p_recv_random = buff[i + 6]; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 1994 | wilc_ie = true; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 1995 | 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] | 1996 | break; |
| 1997 | } |
| 1998 | } |
| 1999 | } |
| 2000 | } |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 2001 | if (p2p_local_random > p2p_recv_random) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2002 | if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP |
| 2003 | || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) { |
| 2004 | for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) { |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 2005 | 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] | 2006 | WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6)); |
| 2007 | break; |
| 2008 | } |
| 2009 | } |
| 2010 | } |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 2011 | } else { |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 2012 | 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] | 2013 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2014 | } |
| 2015 | |
| 2016 | |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 2017 | 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] | 2018 | PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n"); |
| 2019 | /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2020 | cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2021 | return; |
| 2022 | } |
| 2023 | break; |
| 2024 | |
| 2025 | default: |
| 2026 | PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]); |
| 2027 | break; |
| 2028 | } |
| 2029 | } |
| 2030 | } |
| 2031 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2032 | cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2033 | } |
| 2034 | } |
| 2035 | |
| 2036 | /** |
| 2037 | * @brief WILC_WFI_mgmt_tx_complete |
| 2038 | * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here) |
| 2039 | * @param[in] priv |
| 2040 | * transmitting status |
| 2041 | * @return None |
| 2042 | * @author Amr Abdelmoghny |
| 2043 | * @date 20 MAY 2013 |
| 2044 | * @version 1.0 |
| 2045 | */ |
| 2046 | static void WILC_WFI_mgmt_tx_complete(void *priv, int status) |
| 2047 | { |
| 2048 | struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv; |
| 2049 | |
| 2050 | |
| 2051 | kfree(pv_data->buff); |
| 2052 | kfree(pv_data); |
| 2053 | } |
| 2054 | |
| 2055 | /** |
| 2056 | * @brief WILC_WFI_RemainOnChannelReady |
| 2057 | * @details Callback function, called from handle_remain_on_channel on being ready on channel |
| 2058 | * @param |
| 2059 | * @return none |
| 2060 | * @author Amr abdelmoghny |
| 2061 | * @date 9 JUNE 2013 |
| 2062 | * @version |
| 2063 | */ |
| 2064 | |
| 2065 | static void WILC_WFI_RemainOnChannelReady(void *pUserVoid) |
| 2066 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2067 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2068 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2069 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2070 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 2071 | PRINT_D(HOSTINF_DBG, "Remain on channel ready\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2072 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2073 | priv->bInP2PlistenState = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2074 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2075 | cfg80211_ready_on_channel(priv->wdev, |
| 2076 | priv->strRemainOnChanParams.u64ListenCookie, |
| 2077 | priv->strRemainOnChanParams.pstrListenChan, |
| 2078 | priv->strRemainOnChanParams.u32ListenDuration, |
| 2079 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2080 | } |
| 2081 | |
| 2082 | /** |
| 2083 | * @brief WILC_WFI_RemainOnChannelExpired |
| 2084 | * @details Callback function, called on expiration of remain-on-channel duration |
| 2085 | * @param |
| 2086 | * @return none |
| 2087 | * @author Amr abdelmoghny |
| 2088 | * @date 15 MAY 2013 |
| 2089 | * @version |
| 2090 | */ |
| 2091 | |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 2092 | static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, u32 u32SessionID) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2093 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2094 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2095 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2096 | priv = (struct wilc_priv *)pUserVoid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2097 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2098 | if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 2099 | PRINT_D(GENERIC_DBG, "Remain on channel expired\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2100 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2101 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2102 | |
| 2103 | /*Inform wpas of remain-on-channel expiration*/ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2104 | cfg80211_remain_on_channel_expired(priv->wdev, |
| 2105 | priv->strRemainOnChanParams.u64ListenCookie, |
| 2106 | priv->strRemainOnChanParams.pstrListenChan, |
| 2107 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2108 | } else { |
| 2109 | PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID |
| 2110 | , priv->strRemainOnChanParams.u32ListenSessionID); |
| 2111 | } |
| 2112 | } |
| 2113 | |
| 2114 | |
| 2115 | /** |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 2116 | * @brief remain_on_channel |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2117 | * @details Request the driver to remain awake on the specified |
| 2118 | * channel for the specified duration to complete an off-channel |
| 2119 | * operation (e.g., public action frame exchange). When the driver is |
| 2120 | * ready on the requested channel, it must indicate this with an event |
| 2121 | * notification by calling cfg80211_ready_on_channel(). |
| 2122 | * @param[in] |
| 2123 | * @return int : Return 0 on Success |
| 2124 | * @author mdaftedar |
| 2125 | * @date 01 MAR 2012 |
| 2126 | * @version 1.0 |
| 2127 | */ |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 2128 | static int remain_on_channel(struct wiphy *wiphy, |
| 2129 | struct wireless_dev *wdev, |
| 2130 | struct ieee80211_channel *chan, |
| 2131 | unsigned int duration, u64 *cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2132 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2133 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2134 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2135 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2136 | priv = wiphy_priv(wiphy); |
| 2137 | |
| 2138 | PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value); |
| 2139 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2140 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2141 | if (wdev->iftype == NL80211_IFTYPE_AP) { |
| 2142 | PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode"); |
| 2143 | return s32Error; |
| 2144 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2145 | |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 2146 | curr_channel = chan->hw_value; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2147 | |
| 2148 | /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/ |
| 2149 | priv->strRemainOnChanParams.pstrListenChan = chan; |
| 2150 | priv->strRemainOnChanParams.u64ListenCookie = *cookie; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2151 | priv->strRemainOnChanParams.u32ListenDuration = duration; |
| 2152 | priv->strRemainOnChanParams.u32ListenSessionID++; |
| 2153 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2154 | s32Error = wilc_remain_on_channel(priv->hWILCWFIDrv |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2155 | , priv->strRemainOnChanParams.u32ListenSessionID |
| 2156 | , duration |
| 2157 | , chan->hw_value |
| 2158 | , WILC_WFI_RemainOnChannelExpired |
| 2159 | , WILC_WFI_RemainOnChannelReady |
| 2160 | , (void *)priv); |
| 2161 | |
| 2162 | return s32Error; |
| 2163 | } |
| 2164 | |
| 2165 | /** |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 2166 | * @brief cancel_remain_on_channel |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2167 | * @details Cancel an on-going remain-on-channel operation. |
| 2168 | * This allows the operation to be terminated prior to timeout based on |
| 2169 | * the duration value. |
| 2170 | * @param[in] struct wiphy *wiphy, |
| 2171 | * @param[in] struct net_device *dev |
| 2172 | * @param[in] u64 cookie, |
| 2173 | * @return int : Return 0 on Success |
| 2174 | * @author mdaftedar |
| 2175 | * @date 01 MAR 2012 |
| 2176 | * @version 1.0 |
| 2177 | */ |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 2178 | static int cancel_remain_on_channel(struct wiphy *wiphy, |
| 2179 | struct wireless_dev *wdev, |
| 2180 | u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2181 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2182 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2183 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2184 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2185 | priv = wiphy_priv(wiphy); |
| 2186 | |
| 2187 | PRINT_D(CFG80211_DBG, "Cancel remain on channel\n"); |
| 2188 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2189 | s32Error = wilc_listen_state_expired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2190 | return s32Error; |
| 2191 | } |
| 2192 | /** |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2193 | * @brief WILC_WFI_mgmt_tx_frame |
| 2194 | * @details |
| 2195 | * |
| 2196 | * @param[in] |
| 2197 | * @return NONE. |
| 2198 | * @author mdaftedar |
| 2199 | * @date 01 JUL 2012 |
| 2200 | * @version |
| 2201 | */ |
Chaehyun Lim | c156032 | 2015-09-22 18:34:51 +0900 | [diff] [blame] | 2202 | static int mgmt_tx(struct wiphy *wiphy, |
| 2203 | struct wireless_dev *wdev, |
| 2204 | struct cfg80211_mgmt_tx_params *params, |
| 2205 | u64 *cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2206 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2207 | struct ieee80211_channel *chan = params->chan; |
| 2208 | unsigned int wait = params->wait; |
| 2209 | const u8 *buf = params->buf; |
| 2210 | size_t len = params->len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2211 | const struct ieee80211_mgmt *mgmt; |
| 2212 | struct p2p_mgmt_data *mgmt_tx; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2213 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 2214 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 2215 | u32 i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2216 | perInterface_wlan_t *nic; |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 2217 | u32 buf_len = len + sizeof(p2p_vendor_spec) + sizeof(p2p_local_random); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2218 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2219 | nic = netdev_priv(wdev->netdev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2220 | priv = wiphy_priv(wiphy); |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 2221 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2222 | |
| 2223 | *cookie = (unsigned long)buf; |
| 2224 | priv->u64tx_cookie = *cookie; |
| 2225 | mgmt = (const struct ieee80211_mgmt *) buf; |
| 2226 | |
| 2227 | if (ieee80211_is_mgmt(mgmt->frame_control)) { |
| 2228 | |
| 2229 | /*mgmt frame allocation*/ |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 2230 | mgmt_tx = kmalloc(sizeof(struct p2p_mgmt_data), GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2231 | if (mgmt_tx == NULL) { |
| 2232 | PRINT_ER("Failed to allocate memory for mgmt_tx structure\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2233 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2234 | } |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 2235 | mgmt_tx->buff = kmalloc(buf_len, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2236 | if (mgmt_tx->buff == NULL) { |
| 2237 | PRINT_ER("Failed to allocate memory for mgmt_tx buff\n"); |
Tony Cho | f638dd3 | 2015-09-07 19:09:31 +0900 | [diff] [blame] | 2238 | kfree(mgmt_tx); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2239 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2240 | } |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 2241 | memcpy(mgmt_tx->buff, buf, len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2242 | mgmt_tx->size = len; |
| 2243 | |
| 2244 | |
| 2245 | if (ieee80211_is_probe_resp(mgmt->frame_control)) { |
| 2246 | PRINT_D(GENERIC_DBG, "TX: Probe Response\n"); |
| 2247 | PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2248 | wilc_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2249 | /*Save the current channel after we tune to it*/ |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 2250 | curr_channel = chan->hw_value; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2251 | } else if (ieee80211_is_action(mgmt->frame_control)) { |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 2252 | PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (u16)mgmt->frame_control); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2253 | |
| 2254 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2255 | if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2256 | /*Only set the channel, if not a negotiation confirmation frame |
| 2257 | * (If Negotiation confirmation frame, force it |
| 2258 | * to be transmitted on the same negotiation channel)*/ |
| 2259 | |
| 2260 | if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC || |
| 2261 | buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) { |
| 2262 | PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2263 | wilc_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2264 | /*Save the current channel after we tune to it*/ |
Chaehyun Lim | 866a2c2 | 2015-10-02 16:41:21 +0900 | [diff] [blame] | 2265 | curr_channel = chan->hw_value; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2266 | } |
| 2267 | switch (buf[ACTION_SUBTYPE_ID]) { |
| 2268 | case GAS_INTIAL_REQ: |
| 2269 | { |
| 2270 | PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]); |
| 2271 | break; |
| 2272 | } |
| 2273 | |
| 2274 | case GAS_INTIAL_RSP: |
| 2275 | { |
| 2276 | PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]); |
| 2277 | break; |
| 2278 | } |
| 2279 | |
| 2280 | case PUBLIC_ACT_VENDORSPEC: |
| 2281 | { |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 2282 | if (!memcmp(p2p_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2283 | /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/ |
| 2284 | 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] | 2285 | if (p2p_local_random == 1 && p2p_recv_random < p2p_local_random) { |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 2286 | get_random_bytes(&p2p_local_random, 1); |
| 2287 | p2p_local_random++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2288 | } |
| 2289 | } |
| 2290 | |
| 2291 | if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP |
| 2292 | || 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] | 2293 | if (p2p_local_random > p2p_recv_random) { |
| 2294 | 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] | 2295 | |
| 2296 | /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/ |
| 2297 | for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) { |
Leo Kim | 881eb5d | 2015-11-19 15:56:15 +0900 | [diff] [blame] | 2298 | 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] | 2299 | if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP) |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2300 | WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), true, nic->iftype); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2301 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2302 | /*If using supplicant go intent, no need at all*/ |
| 2303 | /*to parse transmitted negotiation frames*/ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2304 | else |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2305 | WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), false, nic->iftype); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2306 | break; |
| 2307 | } |
| 2308 | } |
| 2309 | |
| 2310 | if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) { |
Shivani Bhardwaj | d8060fc | 2015-10-29 00:30:01 +0530 | [diff] [blame] | 2311 | /* |
| 2312 | * Adding WILC information element to allow two WILC devices to |
| 2313 | * identify each other and connect |
| 2314 | */ |
Leo Kim | 8668594 | 2015-11-19 15:56:18 +0900 | [diff] [blame] | 2315 | memcpy(&mgmt_tx->buff[len], p2p_vendor_spec, sizeof(p2p_vendor_spec)); |
| 2316 | mgmt_tx->buff[len + sizeof(p2p_vendor_spec)] = p2p_local_random; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2317 | mgmt_tx->size = buf_len; |
| 2318 | } |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 2319 | } else { |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 2320 | 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] | 2321 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2322 | } |
| 2323 | |
| 2324 | } else { |
| 2325 | PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n"); |
| 2326 | } |
| 2327 | |
| 2328 | break; |
| 2329 | } |
| 2330 | |
| 2331 | default: |
| 2332 | { |
| 2333 | PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]); |
| 2334 | break; |
| 2335 | } |
| 2336 | } |
| 2337 | |
| 2338 | } |
| 2339 | |
| 2340 | 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] | 2341 | pstrWFIDrv->p2p_timeout = (jiffies + msecs_to_jiffies(wait)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2342 | |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 2343 | PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", |
| 2344 | jiffies, pstrWFIDrv->p2p_timeout); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2345 | } |
| 2346 | |
Glen Lee | 829c477 | 2015-10-29 12:18:44 +0900 | [diff] [blame] | 2347 | wilc_wlan_txq_add_mgmt_pkt(wdev->netdev, mgmt_tx, |
| 2348 | mgmt_tx->buff, mgmt_tx->size, |
Glen Lee | c9d4834 | 2015-10-01 16:03:43 +0900 | [diff] [blame] | 2349 | WILC_WFI_mgmt_tx_complete); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2350 | } else { |
| 2351 | PRINT_D(GENERIC_DBG, "This function transmits only management frames\n"); |
| 2352 | } |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 2353 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2354 | } |
| 2355 | |
Chaehyun Lim | 85c587a | 2015-09-22 18:34:50 +0900 | [diff] [blame] | 2356 | static int mgmt_tx_cancel_wait(struct wiphy *wiphy, |
| 2357 | struct wireless_dev *wdev, |
| 2358 | u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2359 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2360 | struct wilc_priv *priv; |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 2361 | struct host_if_drv *pstrWFIDrv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2362 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2363 | priv = wiphy_priv(wiphy); |
Leo Kim | 441dc60 | 2015-10-12 16:55:35 +0900 | [diff] [blame] | 2364 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2365 | |
| 2366 | |
| 2367 | PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies); |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 2368 | pstrWFIDrv->p2p_timeout = jiffies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2369 | |
Luis de Bethencourt | 7e4e87d | 2015-10-16 16:32:26 +0100 | [diff] [blame] | 2370 | if (!priv->bInP2PlistenState) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2371 | cfg80211_remain_on_channel_expired(priv->wdev, |
| 2372 | priv->strRemainOnChanParams.u64ListenCookie, |
| 2373 | priv->strRemainOnChanParams.pstrListenChan, |
| 2374 | GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2375 | } |
| 2376 | |
| 2377 | return 0; |
| 2378 | } |
| 2379 | |
| 2380 | /** |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 2381 | * @brief wilc_mgmt_frame_register |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2382 | * @details Notify driver that a management frame type was |
| 2383 | * registered. Note that this callback may not sleep, and cannot run |
| 2384 | * concurrently with itself. |
| 2385 | * @param[in] |
| 2386 | * @return NONE. |
| 2387 | * @author mdaftedar |
| 2388 | * @date 01 JUL 2012 |
| 2389 | * @version |
| 2390 | */ |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 2391 | void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, |
| 2392 | u16 frame_type, bool reg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2393 | { |
| 2394 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2395 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2396 | perInterface_wlan_t *nic; |
Glen Lee | 1b86935 | 2015-10-20 17:14:01 +0900 | [diff] [blame] | 2397 | struct wilc *wl; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2398 | |
| 2399 | priv = wiphy_priv(wiphy); |
| 2400 | nic = netdev_priv(priv->wdev->netdev); |
Glen Lee | 1b86935 | 2015-10-20 17:14:01 +0900 | [diff] [blame] | 2401 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2402 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2403 | if (!frame_type) |
| 2404 | return; |
| 2405 | |
| 2406 | PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg); |
| 2407 | switch (frame_type) { |
| 2408 | case PROBE_REQ: |
| 2409 | { |
| 2410 | nic->g_struct_frame_reg[0].frame_type = frame_type; |
| 2411 | nic->g_struct_frame_reg[0].reg = reg; |
| 2412 | } |
| 2413 | break; |
| 2414 | |
| 2415 | case ACTION: |
| 2416 | { |
| 2417 | nic->g_struct_frame_reg[1].frame_type = frame_type; |
| 2418 | nic->g_struct_frame_reg[1].reg = reg; |
| 2419 | } |
| 2420 | break; |
| 2421 | |
| 2422 | default: |
| 2423 | { |
| 2424 | break; |
| 2425 | } |
| 2426 | |
| 2427 | } |
| 2428 | /*If mac is closed, then return*/ |
Glen Lee | 1b86935 | 2015-10-20 17:14:01 +0900 | [diff] [blame] | 2429 | if (!wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2430 | PRINT_D(GENERIC_DBG, "Return since mac is closed\n"); |
| 2431 | return; |
| 2432 | } |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2433 | wilc_frame_register(priv->hWILCWFIDrv, frame_type, reg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2434 | |
| 2435 | |
| 2436 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2437 | |
| 2438 | /** |
Chaehyun Lim | a8047e2 | 2015-09-22 18:34:48 +0900 | [diff] [blame] | 2439 | * @brief set_cqm_rssi_config |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2440 | * @details Configure connection quality monitor RSSI threshold. |
| 2441 | * @param[in] struct wiphy *wiphy: |
| 2442 | * @param[in] struct net_device *dev: |
| 2443 | * @param[in] s32 rssi_thold: |
| 2444 | * @param[in] u32 rssi_hyst: |
| 2445 | * @return int : Return 0 on Success |
| 2446 | * @author mdaftedar |
| 2447 | * @date 01 MAR 2012 |
| 2448 | * @version 1.0 |
| 2449 | */ |
Chaehyun Lim | a8047e2 | 2015-09-22 18:34:48 +0900 | [diff] [blame] | 2450 | static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev, |
| 2451 | s32 rssi_thold, u32 rssi_hyst) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2452 | { |
| 2453 | PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n"); |
| 2454 | return 0; |
| 2455 | |
| 2456 | } |
| 2457 | /** |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 2458 | * @brief dump_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2459 | * @details Configure connection quality monitor RSSI threshold. |
| 2460 | * @param[in] struct wiphy *wiphy: |
| 2461 | * @param[in] struct net_device *dev |
| 2462 | * @param[in] int idx |
| 2463 | * @param[in] u8 *mac |
| 2464 | * @param[in] struct station_info *sinfo |
| 2465 | * @return int : Return 0 on Success |
| 2466 | * @author mdaftedar |
| 2467 | * @date 01 MAR 2012 |
| 2468 | * @version 1.0 |
| 2469 | */ |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 2470 | static int dump_station(struct wiphy *wiphy, struct net_device *dev, |
| 2471 | int idx, u8 *mac, struct station_info *sinfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2472 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2473 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2474 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2475 | PRINT_D(CFG80211_DBG, "Dumping station information\n"); |
| 2476 | |
| 2477 | if (idx != 0) |
| 2478 | return -ENOENT; |
| 2479 | |
| 2480 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2481 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2482 | sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2483 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2484 | wilc_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2485 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2486 | return 0; |
| 2487 | |
| 2488 | } |
| 2489 | |
| 2490 | |
| 2491 | /** |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 2492 | * @brief set_power_mgmt |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2493 | * @details |
| 2494 | * @param[in] |
| 2495 | * @return int : Return 0 on Success. |
| 2496 | * @author mdaftedar |
| 2497 | * @date 01 JUL 2012 |
Chaehyun Lim | cdc9cba | 2015-09-22 18:34:47 +0900 | [diff] [blame] | 2498 | * @version 1.0 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2499 | */ |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 2500 | static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, |
| 2501 | bool enabled, int timeout) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2502 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2503 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 2504 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2505 | PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout); |
| 2506 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 2507 | if (wiphy == NULL) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2508 | return -ENOENT; |
| 2509 | |
| 2510 | priv = wiphy_priv(wiphy); |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 2511 | if (priv->hWILCWFIDrv == NULL) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2512 | PRINT_ER("Driver is NULL\n"); |
| 2513 | return -EIO; |
| 2514 | } |
| 2515 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2516 | if (wilc_enable_ps) |
| 2517 | wilc_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2518 | |
| 2519 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2520 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2521 | |
| 2522 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 2523 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2524 | /** |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 2525 | * @brief change_virtual_intf |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2526 | * @details Change type/configuration of virtual interface, |
| 2527 | * keep the struct wireless_dev's iftype updated. |
| 2528 | * @param[in] NONE |
| 2529 | * @return int : Return 0 on Success. |
| 2530 | * @author mdaftedar |
| 2531 | * @date 01 MAR 2012 |
| 2532 | * @version 1.0 |
| 2533 | */ |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 2534 | static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, |
| 2535 | enum nl80211_iftype type, u32 *flags, struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2536 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2537 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2538 | perInterface_wlan_t *nic; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2539 | u8 interface_type; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 2540 | u16 TID = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2541 | u8 i; |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2542 | struct wilc *wl; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2543 | |
| 2544 | nic = netdev_priv(dev); |
| 2545 | priv = wiphy_priv(wiphy); |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2546 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2547 | |
| 2548 | PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n"); |
| 2549 | PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name); |
Leo Kim | 583d972 | 2015-11-19 15:56:16 +0900 | [diff] [blame] | 2550 | p2p_local_random = 0x01; |
Leo Kim | b84a3ac | 2015-11-19 15:56:17 +0900 | [diff] [blame] | 2551 | p2p_recv_random = 0x00; |
Leo Kim | a25d518 | 2015-11-19 15:56:19 +0900 | [diff] [blame] | 2552 | wilc_ie = false; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2553 | wilc_optaining_ip = false; |
| 2554 | del_timer(&wilc_during_ip_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2555 | PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2556 | /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/ |
| 2557 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2558 | wilc_set_machw_change_vir_if(dev, true); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2559 | } |
| 2560 | |
| 2561 | switch (type) { |
| 2562 | case NL80211_IFTYPE_STATION: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2563 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2564 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2565 | |
| 2566 | /* send delba over wlan interface */ |
| 2567 | |
| 2568 | |
| 2569 | dev->ieee80211_ptr->iftype = type; |
| 2570 | priv->wdev->iftype = type; |
| 2571 | nic->monitor_flag = 0; |
| 2572 | nic->iftype = STATION_MODE; |
| 2573 | |
| 2574 | /*Remove the enteries of the previously connected clients*/ |
| 2575 | memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2576 | interface_type = nic->iftype; |
| 2577 | nic->iftype = STATION_MODE; |
| 2578 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2579 | if (wl->initialized) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2580 | wilc_del_all_rx_ba_session(priv->hWILCWFIDrv, |
| 2581 | wl->vif[0].bssid, TID); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2582 | /* ensure that the message Q is empty */ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2583 | wilc_wait_msg_queue_idle(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2584 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2585 | /*Eliminate host interface blocking state*/ |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2586 | up(&wl->cfg_event); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2587 | |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 2588 | wilc1000_wlan_deinit(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2589 | wilc1000_wlan_init(dev, nic); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2590 | wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2591 | nic->iftype = interface_type; |
| 2592 | |
| 2593 | /*Setting interface 1 drv handler and mac address in newly downloaded FW*/ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2594 | wilc_set_wfi_drv_handler(wl->vif[0].hif_drv); |
| 2595 | wilc_set_mac_address(wl->vif[0].hif_drv, |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2596 | wl->vif[0].src_addr); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2597 | wilc_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2598 | |
| 2599 | /*Add saved WEP keys, if any*/ |
| 2600 | if (g_wep_keys_saved) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2601 | wilc_set_wep_default_keyid(wl->vif[0].hif_drv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2602 | g_key_wep_params.key_idx); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2603 | wilc_add_wep_key_bss_sta(wl->vif[0].hif_drv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2604 | g_key_wep_params.key, |
| 2605 | g_key_wep_params.key_len, |
| 2606 | g_key_wep_params.key_idx); |
| 2607 | } |
| 2608 | |
| 2609 | /*No matter the driver handler passed here, it will be overwriiten*/ |
| 2610 | /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2611 | wilc_flush_join_req(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2612 | |
| 2613 | /*Add saved PTK and GTK keys, if any*/ |
| 2614 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2615 | PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], |
| 2616 | g_key_ptk_params.key[1], |
| 2617 | g_key_ptk_params.key[2]); |
| 2618 | PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], |
| 2619 | g_key_gtk_params.key[1], |
| 2620 | g_key_gtk_params.key[2]); |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2621 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2622 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2623 | g_add_ptk_key_params.key_idx, |
| 2624 | g_add_ptk_key_params.pairwise, |
| 2625 | g_add_ptk_key_params.mac_addr, |
| 2626 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2627 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2628 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2629 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2630 | g_add_gtk_key_params.key_idx, |
| 2631 | g_add_gtk_key_params.pairwise, |
| 2632 | g_add_gtk_key_params.mac_addr, |
| 2633 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2634 | } |
| 2635 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2636 | if (wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2637 | for (i = 0; i < num_reg_frame; i++) { |
| 2638 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2639 | nic->g_struct_frame_reg[i].reg); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2640 | wilc_frame_register(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2641 | nic->g_struct_frame_reg[i].frame_type, |
| 2642 | nic->g_struct_frame_reg[i].reg); |
| 2643 | } |
| 2644 | } |
| 2645 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2646 | wilc_enable_ps = true; |
| 2647 | wilc_set_power_mgmt(priv->hWILCWFIDrv, 1, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2648 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2649 | break; |
| 2650 | |
| 2651 | case NL80211_IFTYPE_P2P_CLIENT: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2652 | wilc_enable_ps = false; |
| 2653 | wilc_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); |
| 2654 | wilc_connecting = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2655 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2656 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2657 | wilc_del_all_rx_ba_session(priv->hWILCWFIDrv, |
| 2658 | wl->vif[0].bssid, TID); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2659 | |
| 2660 | dev->ieee80211_ptr->iftype = type; |
| 2661 | priv->wdev->iftype = type; |
| 2662 | nic->monitor_flag = 0; |
| 2663 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2664 | PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); |
| 2665 | nic->iftype = CLIENT_MODE; |
| 2666 | |
| 2667 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2668 | if (wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2669 | /* ensure that the message Q is empty */ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2670 | wilc_wait_msg_queue_idle(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2671 | |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 2672 | wilc1000_wlan_deinit(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2673 | wilc1000_wlan_init(dev, nic); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2674 | wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2675 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2676 | wilc_set_wfi_drv_handler(wl->vif[0].hif_drv); |
| 2677 | wilc_set_mac_address(wl->vif[0].hif_drv, |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2678 | wl->vif[0].src_addr); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2679 | wilc_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2680 | |
| 2681 | /*Add saved WEP keys, if any*/ |
| 2682 | if (g_wep_keys_saved) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2683 | wilc_set_wep_default_keyid(wl->vif[0].hif_drv, |
| 2684 | g_key_wep_params.key_idx); |
| 2685 | wilc_add_wep_key_bss_sta(wl->vif[0].hif_drv, |
| 2686 | g_key_wep_params.key, |
| 2687 | g_key_wep_params.key_len, |
| 2688 | g_key_wep_params.key_idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2689 | } |
| 2690 | |
| 2691 | /*No matter the driver handler passed here, it will be overwriiten*/ |
| 2692 | /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2693 | wilc_flush_join_req(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2694 | |
| 2695 | /*Add saved PTK and GTK keys, if any*/ |
| 2696 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2697 | PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0], |
| 2698 | g_key_ptk_params.key[1], |
| 2699 | g_key_ptk_params.key[2]); |
| 2700 | PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0], |
| 2701 | g_key_gtk_params.key[1], |
| 2702 | g_key_gtk_params.key[2]); |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2703 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2704 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2705 | g_add_ptk_key_params.key_idx, |
| 2706 | g_add_ptk_key_params.pairwise, |
| 2707 | g_add_ptk_key_params.mac_addr, |
| 2708 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2709 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2710 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2711 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2712 | g_add_gtk_key_params.key_idx, |
| 2713 | g_add_gtk_key_params.pairwise, |
| 2714 | g_add_gtk_key_params.mac_addr, |
| 2715 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2716 | } |
| 2717 | |
| 2718 | /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/ |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2719 | refresh_scan(priv, 1, true); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2720 | wilc_set_machw_change_vir_if(dev, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2721 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2722 | if (wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2723 | for (i = 0; i < num_reg_frame; i++) { |
| 2724 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2725 | nic->g_struct_frame_reg[i].reg); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2726 | wilc_frame_register(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2727 | nic->g_struct_frame_reg[i].frame_type, |
| 2728 | nic->g_struct_frame_reg[i].reg); |
| 2729 | } |
| 2730 | } |
| 2731 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2732 | break; |
| 2733 | |
| 2734 | case NL80211_IFTYPE_AP: |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2735 | wilc_enable_ps = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2736 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2737 | dev->ieee80211_ptr->iftype = type; |
| 2738 | priv->wdev->iftype = type; |
| 2739 | nic->iftype = AP_MODE; |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 2740 | PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2741 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2742 | PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2743 | wilc_wlan_get_firmware(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2744 | /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/ |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2745 | if (wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2746 | nic->iftype = AP_MODE; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2747 | wilc_mac_close(dev); |
| 2748 | wilc_mac_open(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2749 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2750 | for (i = 0; i < num_reg_frame; i++) { |
| 2751 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2752 | nic->g_struct_frame_reg[i].reg); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2753 | wilc_frame_register(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2754 | nic->g_struct_frame_reg[i].frame_type, |
| 2755 | nic->g_struct_frame_reg[i].reg); |
| 2756 | } |
| 2757 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2758 | break; |
| 2759 | |
| 2760 | case NL80211_IFTYPE_P2P_GO: |
| 2761 | PRINT_D(GENERIC_DBG, "start duringIP timer\n"); |
| 2762 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2763 | wilc_optaining_ip = true; |
Leo Kim | 7e872df | 2015-11-19 15:56:20 +0900 | [diff] [blame] | 2764 | mod_timer(&wilc_during_ip_timer, |
| 2765 | jiffies + msecs_to_jiffies(during_ip_time)); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2766 | wilc_set_power_mgmt(priv->hWILCWFIDrv, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2767 | /*Delete block ack has to be the latest config packet*/ |
| 2768 | /*sent before downloading new FW. This is because it blocks on*/ |
| 2769 | /*hWaitResponse semaphore, which allows previous config*/ |
| 2770 | /*packets to actually take action on old FW*/ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2771 | wilc_del_all_rx_ba_session(priv->hWILCWFIDrv, |
| 2772 | wl->vif[0].bssid, TID); |
| 2773 | wilc_enable_ps = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2774 | PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2775 | dev->ieee80211_ptr->iftype = type; |
| 2776 | priv->wdev->iftype = type; |
| 2777 | |
Johnny Kim | 8a14330 | 2015-06-10 17:06:46 +0900 | [diff] [blame] | 2778 | PRINT_D(CORECONFIG_DBG, "priv->hWILCWFIDrv[%p]\n", priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2779 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2780 | PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n"); |
| 2781 | |
| 2782 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2783 | nic->iftype = GO_MODE; |
| 2784 | |
| 2785 | /* ensure that the message Q is empty */ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2786 | wilc_wait_msg_queue_idle(); |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 2787 | wilc1000_wlan_deinit(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2788 | wilc1000_wlan_init(dev, nic); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2789 | wilc_initialized = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2790 | |
| 2791 | |
| 2792 | /*Setting interface 1 drv handler and mac address in newly downloaded FW*/ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2793 | wilc_set_wfi_drv_handler(wl->vif[0].hif_drv); |
| 2794 | wilc_set_mac_address(wl->vif[0].hif_drv, |
| 2795 | wl->vif[0].src_addr); |
| 2796 | wilc_set_operation_mode(priv->hWILCWFIDrv, AP_MODE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2797 | |
| 2798 | /*Add saved WEP keys, if any*/ |
| 2799 | if (g_wep_keys_saved) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2800 | wilc_set_wep_default_keyid(wl->vif[0].hif_drv, |
| 2801 | g_key_wep_params.key_idx); |
| 2802 | wilc_add_wep_key_bss_sta(wl->vif[0].hif_drv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2803 | g_key_wep_params.key, |
| 2804 | g_key_wep_params.key_len, |
| 2805 | g_key_wep_params.key_idx); |
| 2806 | } |
| 2807 | |
| 2808 | /*No matter the driver handler passed here, it will be overwriiten*/ |
| 2809 | /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/ |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2810 | wilc_flush_join_req(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2811 | |
| 2812 | /*Add saved PTK and GTK keys, if any*/ |
| 2813 | if (g_ptk_keys_saved && g_gtk_keys_saved) { |
| 2814 | PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0], |
| 2815 | g_key_ptk_params.key[1], |
| 2816 | g_key_ptk_params.key[2], |
| 2817 | g_key_ptk_params.cipher); |
| 2818 | PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0], |
| 2819 | g_key_gtk_params.key[1], |
| 2820 | g_key_gtk_params.key[2], |
| 2821 | g_key_gtk_params.cipher); |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2822 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2823 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2824 | g_add_ptk_key_params.key_idx, |
| 2825 | g_add_ptk_key_params.pairwise, |
| 2826 | g_add_ptk_key_params.mac_addr, |
| 2827 | (struct key_params *)(&g_key_ptk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2828 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2829 | add_key(wl->vif[0].ndev->ieee80211_ptr->wiphy, |
| 2830 | wl->vif[0].ndev, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 2831 | g_add_gtk_key_params.key_idx, |
| 2832 | g_add_gtk_key_params.pairwise, |
| 2833 | g_add_gtk_key_params.mac_addr, |
| 2834 | (struct key_params *)(&g_key_gtk_params)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2835 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2836 | |
Glen Lee | 299382c | 2015-10-20 17:13:56 +0900 | [diff] [blame] | 2837 | if (wl->initialized) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2838 | for (i = 0; i < num_reg_frame; i++) { |
| 2839 | PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type, |
| 2840 | nic->g_struct_frame_reg[i].reg); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2841 | wilc_frame_register(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2842 | nic->g_struct_frame_reg[i].frame_type, |
| 2843 | nic->g_struct_frame_reg[i].reg); |
| 2844 | } |
| 2845 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2846 | break; |
| 2847 | |
| 2848 | default: |
| 2849 | PRINT_ER("Unknown interface type= %d\n", type); |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 2850 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2851 | } |
| 2852 | |
Leo Kim | aaed329 | 2015-10-12 16:55:38 +0900 | [diff] [blame] | 2853 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2854 | } |
| 2855 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2856 | /* (austin.2013-07-23) |
| 2857 | * |
| 2858 | * To support revised cfg80211_ops |
| 2859 | * |
| 2860 | * add_beacon --> start_ap |
| 2861 | * set_beacon --> change_beacon |
| 2862 | * del_beacon --> stop_ap |
| 2863 | * |
| 2864 | * beacon_parameters --> cfg80211_ap_settings |
| 2865 | * cfg80211_beacon_data |
| 2866 | * |
| 2867 | * applicable for linux kernel 3.4+ |
| 2868 | */ |
| 2869 | |
| 2870 | /** |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 2871 | * @brief start_ap |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2872 | * @details Add a beacon with given parameters, @head, @interval |
| 2873 | * and @dtim_period will be valid, @tail is optional. |
| 2874 | * @param[in] wiphy |
| 2875 | * @param[in] dev The net device structure |
| 2876 | * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added |
| 2877 | * @return int : Return 0 on Success. |
| 2878 | * @author austin |
| 2879 | * @date 23 JUL 2013 |
| 2880 | * @version 1.0 |
| 2881 | */ |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 2882 | static int start_ap(struct wiphy *wiphy, struct net_device *dev, |
| 2883 | struct cfg80211_ap_settings *settings) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2884 | { |
| 2885 | struct cfg80211_beacon_data *beacon = &(settings->beacon); |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2886 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2887 | s32 s32Error = 0; |
Glen Lee | 684dc18 | 2015-10-20 17:14:02 +0900 | [diff] [blame] | 2888 | struct wilc *wl; |
| 2889 | perInterface_wlan_t *nic; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2890 | |
| 2891 | priv = wiphy_priv(wiphy); |
Glen Lee | 684dc18 | 2015-10-20 17:14:02 +0900 | [diff] [blame] | 2892 | nic = netdev_priv(dev); |
| 2893 | wl = nic->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2894 | PRINT_D(HOSTAPD_DBG, "Starting ap\n"); |
| 2895 | |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 2896 | 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] | 2897 | settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len); |
| 2898 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 2899 | s32Error = set_channel(wiphy, &settings->chandef); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2900 | |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2901 | if (s32Error != 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2902 | PRINT_ER("Error in setting channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2903 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2904 | wilc_wlan_set_bssid(dev, wl->vif[0].src_addr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2905 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2906 | s32Error = wilc_add_beacon(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2907 | settings->beacon_interval, |
| 2908 | settings->dtim_period, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2909 | beacon->head_len, (u8 *)beacon->head, |
| 2910 | beacon->tail_len, (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2911 | |
| 2912 | return s32Error; |
| 2913 | } |
| 2914 | |
| 2915 | /** |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 2916 | * @brief change_beacon |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2917 | * @details Add a beacon with given parameters, @head, @interval |
| 2918 | * and @dtim_period will be valid, @tail is optional. |
| 2919 | * @param[in] wiphy |
| 2920 | * @param[in] dev The net device structure |
| 2921 | * @param[in] beacon cfg80211_beacon_data for the beacon to be changed |
| 2922 | * @return int : Return 0 on Success. |
| 2923 | * @author austin |
| 2924 | * @date 23 JUL 2013 |
| 2925 | * @version 1.0 |
| 2926 | */ |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 2927 | static int change_beacon(struct wiphy *wiphy, struct net_device *dev, |
| 2928 | struct cfg80211_beacon_data *beacon) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2929 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2930 | struct wilc_priv *priv; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2931 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2932 | |
| 2933 | priv = wiphy_priv(wiphy); |
| 2934 | PRINT_D(HOSTAPD_DBG, "Setting beacon\n"); |
| 2935 | |
| 2936 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2937 | s32Error = wilc_add_beacon(priv->hWILCWFIDrv, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2938 | 0, |
| 2939 | 0, |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2940 | beacon->head_len, (u8 *)beacon->head, |
| 2941 | beacon->tail_len, (u8 *)beacon->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2942 | |
| 2943 | return s32Error; |
| 2944 | } |
| 2945 | |
| 2946 | /** |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 2947 | * @brief stop_ap |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2948 | * @details Remove beacon configuration and stop sending the beacon. |
| 2949 | * @param[in] |
| 2950 | * @return int : Return 0 on Success. |
| 2951 | * @author austin |
| 2952 | * @date 23 JUL 2013 |
| 2953 | * @version 1.0 |
| 2954 | */ |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 2955 | static int stop_ap(struct wiphy *wiphy, struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2956 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2957 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2958 | struct wilc_priv *priv; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2959 | u8 NullBssid[ETH_ALEN] = {0}; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2960 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2961 | if (!wiphy) |
| 2962 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2963 | |
| 2964 | priv = wiphy_priv(wiphy); |
| 2965 | |
| 2966 | PRINT_D(HOSTAPD_DBG, "Deleting beacon\n"); |
| 2967 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2968 | wilc_wlan_set_bssid(dev, NullBssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2969 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2970 | s32Error = wilc_del_beacon(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2971 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 2972 | if (s32Error) |
| 2973 | PRINT_ER("Host delete beacon fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2974 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2975 | return s32Error; |
| 2976 | } |
| 2977 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2978 | /** |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 2979 | * @brief add_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2980 | * @details Add a new station. |
| 2981 | * @param[in] |
| 2982 | * @return int : Return 0 on Success. |
| 2983 | * @author mdaftedar |
| 2984 | * @date 01 MAR 2012 |
| 2985 | * @version 1.0 |
| 2986 | */ |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 2987 | static int add_station(struct wiphy *wiphy, struct net_device *dev, |
| 2988 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2989 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2990 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 2991 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 2992 | struct add_sta_param strStaParams = { {0} }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2993 | perInterface_wlan_t *nic; |
| 2994 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 2995 | if (!wiphy) |
| 2996 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2997 | |
| 2998 | priv = wiphy_priv(wiphy); |
| 2999 | nic = netdev_priv(dev); |
| 3000 | |
| 3001 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
Leo Kim | 2353c38 | 2015-10-29 12:05:41 +0900 | [diff] [blame] | 3002 | memcpy(strStaParams.bssid, mac, ETH_ALEN); |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 3003 | memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 3004 | strStaParams.aid = params->aid; |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 3005 | strStaParams.rates_len = params->supported_rates_len; |
Leo Kim | a622e01 | 2015-10-29 12:05:44 +0900 | [diff] [blame] | 3006 | strStaParams.rates = params->supported_rates; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3007 | |
| 3008 | PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid); |
| 3009 | |
| 3010 | 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], |
| 3011 | priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 3012 | PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.aid); |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 3013 | PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", |
| 3014 | strStaParams.rates_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3015 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3016 | if (params->ht_capa == NULL) { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 3017 | strStaParams.ht_supported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3018 | } else { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 3019 | strStaParams.ht_supported = true; |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 3020 | strStaParams.ht_capa_info = params->ht_capa->cap_info; |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 3021 | strStaParams.ht_ampdu_params = params->ht_capa->ampdu_params_info; |
Leo Kim | 5ebbf4f | 2015-10-29 12:05:48 +0900 | [diff] [blame] | 3022 | memcpy(strStaParams.ht_supp_mcs_set, |
| 3023 | ¶ms->ht_capa->mcs, |
| 3024 | WILC_SUPP_MCS_SET_SIZE); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 3025 | strStaParams.ht_ext_params = params->ht_capa->extended_ht_cap_info; |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 3026 | strStaParams.ht_tx_bf_cap = params->ht_capa->tx_BF_cap_info; |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 3027 | strStaParams.ht_ante_sel = params->ht_capa->antenna_selection_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3028 | } |
| 3029 | |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 3030 | strStaParams.flags_mask = params->sta_flags_mask; |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 3031 | strStaParams.flags_set = params->sta_flags_set; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3032 | |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 3033 | PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", |
| 3034 | strStaParams.ht_supported); |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 3035 | PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", |
| 3036 | strStaParams.ht_capa_info); |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 3037 | PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", |
| 3038 | strStaParams.ht_ampdu_params); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 3039 | PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", |
| 3040 | strStaParams.ht_ext_params); |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 3041 | PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", |
| 3042 | strStaParams.ht_tx_bf_cap); |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 3043 | PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", |
| 3044 | strStaParams.ht_ante_sel); |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 3045 | PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", |
| 3046 | strStaParams.flags_mask); |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 3047 | PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", |
| 3048 | strStaParams.flags_set); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3049 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 3050 | s32Error = wilc_add_station(priv->hWILCWFIDrv, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3051 | if (s32Error) |
| 3052 | PRINT_ER("Host add station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3053 | } |
| 3054 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3055 | return s32Error; |
| 3056 | } |
| 3057 | |
| 3058 | /** |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 3059 | * @brief del_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3060 | * @details Remove a station; @mac may be NULL to remove all stations. |
| 3061 | * @param[in] |
| 3062 | * @return int : Return 0 on Success. |
| 3063 | * @author mdaftedar |
| 3064 | * @date 01 MAR 2012 |
| 3065 | * @version 1.0 |
| 3066 | */ |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 3067 | static int del_station(struct wiphy *wiphy, struct net_device *dev, |
| 3068 | struct station_del_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3069 | { |
Arnd Bergmann | 057d1e9 | 2015-06-01 21:06:44 +0200 | [diff] [blame] | 3070 | const u8 *mac = params->mac; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3071 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3072 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3073 | perInterface_wlan_t *nic; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 3074 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3075 | if (!wiphy) |
| 3076 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3077 | |
| 3078 | priv = wiphy_priv(wiphy); |
| 3079 | nic = netdev_priv(dev); |
| 3080 | |
| 3081 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
| 3082 | PRINT_D(HOSTAPD_DBG, "Deleting station\n"); |
| 3083 | |
| 3084 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3085 | if (mac == NULL) { |
Chandra S Gorentla | 17aacd4 | 2015-08-08 17:41:35 +0530 | [diff] [blame] | 3086 | PRINT_D(HOSTAPD_DBG, "All associated stations\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 3087 | s32Error = wilc_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3088 | } else { |
| 3089 | 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]); |
| 3090 | } |
| 3091 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 3092 | s32Error = wilc_del_station(priv->hWILCWFIDrv, mac); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3093 | |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3094 | if (s32Error) |
| 3095 | PRINT_ER("Host delete station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3096 | } |
| 3097 | return s32Error; |
| 3098 | } |
| 3099 | |
| 3100 | /** |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 3101 | * @brief change_station |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3102 | * @details Modify a given station. |
| 3103 | * @param[in] |
| 3104 | * @return int : Return 0 on Success. |
| 3105 | * @author mdaftedar |
| 3106 | * @date 01 MAR 2012 |
| 3107 | * @version 1.0 |
| 3108 | */ |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 3109 | static int change_station(struct wiphy *wiphy, struct net_device *dev, |
| 3110 | const u8 *mac, struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3111 | { |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3112 | s32 s32Error = 0; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3113 | struct wilc_priv *priv; |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 3114 | struct add_sta_param strStaParams = { {0} }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3115 | perInterface_wlan_t *nic; |
| 3116 | |
| 3117 | |
| 3118 | PRINT_D(HOSTAPD_DBG, "Change station paramters\n"); |
| 3119 | |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3120 | if (!wiphy) |
| 3121 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3122 | |
| 3123 | priv = wiphy_priv(wiphy); |
| 3124 | nic = netdev_priv(dev); |
| 3125 | |
| 3126 | if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) { |
Leo Kim | 2353c38 | 2015-10-29 12:05:41 +0900 | [diff] [blame] | 3127 | memcpy(strStaParams.bssid, mac, ETH_ALEN); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 3128 | strStaParams.aid = params->aid; |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 3129 | strStaParams.rates_len = params->supported_rates_len; |
Leo Kim | a622e01 | 2015-10-29 12:05:44 +0900 | [diff] [blame] | 3130 | strStaParams.rates = params->supported_rates; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3131 | |
Leo Kim | 2353c38 | 2015-10-29 12:05:41 +0900 | [diff] [blame] | 3132 | PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n", |
| 3133 | strStaParams.bssid[0], strStaParams.bssid[1], |
| 3134 | strStaParams.bssid[2], strStaParams.bssid[3], |
| 3135 | strStaParams.bssid[4], strStaParams.bssid[5]); |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 3136 | PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.aid); |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 3137 | PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", |
| 3138 | strStaParams.rates_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3139 | |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3140 | if (params->ht_capa == NULL) { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 3141 | strStaParams.ht_supported = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3142 | } else { |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 3143 | strStaParams.ht_supported = true; |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 3144 | strStaParams.ht_capa_info = params->ht_capa->cap_info; |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 3145 | strStaParams.ht_ampdu_params = params->ht_capa->ampdu_params_info; |
Leo Kim | 5ebbf4f | 2015-10-29 12:05:48 +0900 | [diff] [blame] | 3146 | memcpy(strStaParams.ht_supp_mcs_set, |
| 3147 | ¶ms->ht_capa->mcs, |
| 3148 | WILC_SUPP_MCS_SET_SIZE); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 3149 | strStaParams.ht_ext_params = params->ht_capa->extended_ht_cap_info; |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 3150 | strStaParams.ht_tx_bf_cap = params->ht_capa->tx_BF_cap_info; |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 3151 | strStaParams.ht_ante_sel = params->ht_capa->antenna_selection_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3152 | } |
| 3153 | |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 3154 | strStaParams.flags_mask = params->sta_flags_mask; |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 3155 | strStaParams.flags_set = params->sta_flags_set; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3156 | |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 3157 | PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", |
| 3158 | strStaParams.ht_supported); |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 3159 | PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", |
| 3160 | strStaParams.ht_capa_info); |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 3161 | PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", |
| 3162 | strStaParams.ht_ampdu_params); |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 3163 | PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", |
| 3164 | strStaParams.ht_ext_params); |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 3165 | PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", |
| 3166 | strStaParams.ht_tx_bf_cap); |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 3167 | PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", |
| 3168 | strStaParams.ht_ante_sel); |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 3169 | PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", |
| 3170 | strStaParams.flags_mask); |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 3171 | PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", |
| 3172 | strStaParams.flags_set); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3173 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 3174 | s32Error = wilc_edit_station(priv->hWILCWFIDrv, &strStaParams); |
Leo Kim | 7dc1d0c | 2015-09-16 18:36:00 +0900 | [diff] [blame] | 3175 | if (s32Error) |
| 3176 | PRINT_ER("Host edit station fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3177 | } |
| 3178 | return s32Error; |
| 3179 | } |
| 3180 | |
| 3181 | |
| 3182 | /** |
Chaehyun Lim | 69deb4c | 2015-09-14 12:24:09 +0900 | [diff] [blame] | 3183 | * @brief add_virtual_intf |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3184 | * @details |
| 3185 | * @param[in] |
| 3186 | * @return int : Return 0 on Success. |
| 3187 | * @author mdaftedar |
| 3188 | * @date 01 JUL 2012 |
| 3189 | * @version 1.0 |
| 3190 | */ |
Chaehyun Lim | 37316e8 | 2015-09-22 18:34:52 +0900 | [diff] [blame] | 3191 | static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, |
| 3192 | const char *name, |
| 3193 | unsigned char name_assign_type, |
| 3194 | enum nl80211_iftype type, |
| 3195 | u32 *flags, |
| 3196 | struct vif_params *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3197 | { |
| 3198 | perInterface_wlan_t *nic; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3199 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3200 | struct net_device *new_ifc = NULL; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 3201 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3202 | priv = wiphy_priv(wiphy); |
| 3203 | |
| 3204 | |
| 3205 | |
| 3206 | PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev); |
| 3207 | |
| 3208 | nic = netdev_priv(priv->wdev->netdev); |
| 3209 | |
| 3210 | |
| 3211 | if (type == NL80211_IFTYPE_MONITOR) { |
| 3212 | PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n"); |
| 3213 | PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev); |
| 3214 | new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev); |
| 3215 | if (new_ifc != NULL) { |
| 3216 | PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3217 | nic = netdev_priv(priv->wdev->netdev); |
| 3218 | nic->monitor_flag = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3219 | } else |
| 3220 | PRINT_ER("Error in initializing monitor interface\n "); |
| 3221 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3222 | return priv->wdev; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3223 | } |
| 3224 | |
| 3225 | /** |
Chaehyun Lim | b4a7335 | 2015-09-14 12:24:10 +0900 | [diff] [blame] | 3226 | * @brief del_virtual_intf |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3227 | * @details |
| 3228 | * @param[in] |
| 3229 | * @return int : Return 0 on Success. |
| 3230 | * @author mdaftedar |
| 3231 | * @date 01 JUL 2012 |
| 3232 | * @version 1.0 |
| 3233 | */ |
Chaehyun Lim | 956d721 | 2015-09-22 18:34:49 +0900 | [diff] [blame] | 3234 | static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3235 | { |
| 3236 | PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3237 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3238 | } |
| 3239 | |
Chaehyun Lim | 0824192 | 2015-09-15 14:06:12 +0900 | [diff] [blame] | 3240 | static struct cfg80211_ops wilc_cfg80211_ops = { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3241 | |
Chaehyun Lim | 80785a9 | 2015-09-14 12:24:01 +0900 | [diff] [blame] | 3242 | .set_monitor_channel = set_channel, |
Chaehyun Lim | 0e30d06 | 2015-09-14 12:24:02 +0900 | [diff] [blame] | 3243 | .scan = scan, |
Chaehyun Lim | 4ffbcdb | 2015-09-14 12:24:03 +0900 | [diff] [blame] | 3244 | .connect = connect, |
Chaehyun Lim | b027cde | 2015-09-14 12:24:04 +0900 | [diff] [blame] | 3245 | .disconnect = disconnect, |
Chaehyun Lim | 953d417 | 2015-09-14 12:24:05 +0900 | [diff] [blame] | 3246 | .add_key = add_key, |
Chaehyun Lim | 3044ba7 | 2015-09-14 12:24:06 +0900 | [diff] [blame] | 3247 | .del_key = del_key, |
Chaehyun Lim | f4893df | 2015-09-14 12:24:07 +0900 | [diff] [blame] | 3248 | .get_key = get_key, |
Chaehyun Lim | 0f5b8ca | 2015-09-14 12:24:08 +0900 | [diff] [blame] | 3249 | .set_default_key = set_default_key, |
Chaehyun Lim | 69deb4c | 2015-09-14 12:24:09 +0900 | [diff] [blame] | 3250 | .add_virtual_intf = add_virtual_intf, |
Chaehyun Lim | b4a7335 | 2015-09-14 12:24:10 +0900 | [diff] [blame] | 3251 | .del_virtual_intf = del_virtual_intf, |
Chaehyun Lim | 3615e9a | 2015-09-14 12:24:11 +0900 | [diff] [blame] | 3252 | .change_virtual_intf = change_virtual_intf, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3253 | |
Chaehyun Lim | a13168d | 2015-09-14 12:24:12 +0900 | [diff] [blame] | 3254 | .start_ap = start_ap, |
Chaehyun Lim | 2a4c84d | 2015-09-14 12:24:13 +0900 | [diff] [blame] | 3255 | .change_beacon = change_beacon, |
Chaehyun Lim | c8cddd7 | 2015-09-14 12:24:14 +0900 | [diff] [blame] | 3256 | .stop_ap = stop_ap, |
Chaehyun Lim | ed26955 | 2015-09-14 12:24:15 +0900 | [diff] [blame] | 3257 | .add_station = add_station, |
Chaehyun Lim | a0a8be9 | 2015-09-14 12:24:16 +0900 | [diff] [blame] | 3258 | .del_station = del_station, |
Chaehyun Lim | 14b4208 | 2015-09-14 12:24:17 +0900 | [diff] [blame] | 3259 | .change_station = change_station, |
Chaehyun Lim | f06f562 | 2015-09-14 12:24:18 +0900 | [diff] [blame] | 3260 | .get_station = get_station, |
Chaehyun Lim | bdb6338 | 2015-09-14 12:24:19 +0900 | [diff] [blame] | 3261 | .dump_station = dump_station, |
Chaehyun Lim | a5f7db6 | 2015-09-14 12:24:20 +0900 | [diff] [blame] | 3262 | .change_bss = change_bss, |
Chaehyun Lim | a76b63e | 2015-09-14 12:24:21 +0900 | [diff] [blame] | 3263 | .set_wiphy_params = set_wiphy_params, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3264 | |
Chaehyun Lim | 4d46657 | 2015-09-14 12:24:22 +0900 | [diff] [blame] | 3265 | .set_pmksa = set_pmksa, |
Chaehyun Lim | 1ff86d9 | 2015-09-14 12:24:23 +0900 | [diff] [blame] | 3266 | .del_pmksa = del_pmksa, |
Chaehyun Lim | b33c39b | 2015-09-14 12:24:24 +0900 | [diff] [blame] | 3267 | .flush_pmksa = flush_pmksa, |
Chaehyun Lim | 6d19d69 | 2015-09-14 12:24:25 +0900 | [diff] [blame] | 3268 | .remain_on_channel = remain_on_channel, |
Chaehyun Lim | 1dd5440 | 2015-09-14 12:24:26 +0900 | [diff] [blame] | 3269 | .cancel_remain_on_channel = cancel_remain_on_channel, |
Chaehyun Lim | 4a2f9b3 | 2015-09-14 12:24:27 +0900 | [diff] [blame] | 3270 | .mgmt_tx_cancel_wait = mgmt_tx_cancel_wait, |
Chaehyun Lim | 12a26a3 | 2015-09-14 12:24:28 +0900 | [diff] [blame] | 3271 | .mgmt_tx = mgmt_tx, |
Chaehyun Lim | 8e0735c | 2015-09-20 15:51:16 +0900 | [diff] [blame] | 3272 | .mgmt_frame_register = wilc_mgmt_frame_register, |
Chaehyun Lim | 4653067 | 2015-09-22 18:34:46 +0900 | [diff] [blame] | 3273 | .set_power_mgmt = set_power_mgmt, |
Chaehyun Lim | a8047e2 | 2015-09-22 18:34:48 +0900 | [diff] [blame] | 3274 | .set_cqm_rssi_config = set_cqm_rssi_config, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3275 | |
| 3276 | }; |
| 3277 | |
| 3278 | |
| 3279 | |
| 3280 | |
| 3281 | |
| 3282 | /** |
| 3283 | * @brief WILC_WFI_update_stats |
| 3284 | * @details Modify parameters for a given BSS. |
| 3285 | * @param[in] |
| 3286 | * @return int : Return 0 on Success. |
| 3287 | * @author mdaftedar |
| 3288 | * @date 01 MAR 2012 |
Chaehyun Lim | cdc9cba | 2015-09-22 18:34:47 +0900 | [diff] [blame] | 3289 | * @version 1.0 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3290 | */ |
| 3291 | int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed) |
| 3292 | { |
| 3293 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3294 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3295 | |
| 3296 | priv = wiphy_priv(wiphy); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3297 | switch (changed) { |
| 3298 | |
| 3299 | case WILC_WFI_RX_PKT: |
| 3300 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3301 | priv->netstats.rx_packets++; |
| 3302 | priv->netstats.rx_bytes += pktlen; |
| 3303 | priv->netstats.rx_time = get_jiffies_64(); |
| 3304 | } |
| 3305 | break; |
| 3306 | |
| 3307 | case WILC_WFI_TX_PKT: |
| 3308 | { |
| 3309 | priv->netstats.tx_packets++; |
| 3310 | priv->netstats.tx_bytes += pktlen; |
| 3311 | priv->netstats.tx_time = get_jiffies_64(); |
| 3312 | |
| 3313 | } |
| 3314 | break; |
| 3315 | |
| 3316 | default: |
| 3317 | break; |
| 3318 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3319 | return 0; |
| 3320 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3321 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3322 | /** |
| 3323 | * @brief WILC_WFI_CfgAlloc |
| 3324 | * @details Allocation of the wireless device structure and assigning it |
| 3325 | * to the cfg80211 operations structure. |
| 3326 | * @param[in] NONE |
| 3327 | * @return wireless_dev : Returns pointer to wireless_dev structure. |
| 3328 | * @author mdaftedar |
| 3329 | * @date 01 MAR 2012 |
| 3330 | * @version 1.0 |
| 3331 | */ |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 3332 | static struct wireless_dev *WILC_WFI_CfgAlloc(void) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3333 | { |
| 3334 | |
| 3335 | struct wireless_dev *wdev; |
| 3336 | |
| 3337 | |
| 3338 | PRINT_D(CFG80211_DBG, "Allocating wireless device\n"); |
| 3339 | /*Allocating the wireless device structure*/ |
| 3340 | wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL); |
| 3341 | if (!wdev) { |
| 3342 | PRINT_ER("Cannot allocate wireless device\n"); |
| 3343 | goto _fail_; |
| 3344 | } |
| 3345 | |
| 3346 | /*Creating a new wiphy, linking wireless structure with the wiphy structure*/ |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3347 | wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3348 | if (!wdev->wiphy) { |
| 3349 | PRINT_ER("Cannot allocate wiphy\n"); |
| 3350 | goto _fail_mem_; |
| 3351 | |
| 3352 | } |
| 3353 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3354 | /* enable 802.11n HT */ |
| 3355 | WILC_WFI_band_2ghz.ht_cap.ht_supported = 1; |
| 3356 | WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); |
| 3357 | WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; |
| 3358 | WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; |
| 3359 | 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] | 3360 | |
| 3361 | /*wiphy bands*/ |
| 3362 | wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz; |
| 3363 | |
| 3364 | return wdev; |
| 3365 | |
| 3366 | _fail_mem_: |
| 3367 | kfree(wdev); |
| 3368 | _fail_: |
| 3369 | return NULL; |
| 3370 | |
| 3371 | } |
| 3372 | /** |
Chaehyun Lim | 8459fd5 | 2015-09-20 15:51:09 +0900 | [diff] [blame] | 3373 | * @brief wilc_create_wiphy |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3374 | * @details Registering of the wiphy structure and interface modes |
| 3375 | * @param[in] NONE |
| 3376 | * @return NONE |
| 3377 | * @author mdaftedar |
| 3378 | * @date 01 MAR 2012 |
| 3379 | * @version 1.0 |
| 3380 | */ |
Arnd Bergmann | 2e7d537 | 2015-11-16 15:05:03 +0100 | [diff] [blame] | 3381 | 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] | 3382 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3383 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3384 | struct wireless_dev *wdev; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3385 | s32 s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3386 | |
| 3387 | PRINT_D(CFG80211_DBG, "Registering wifi device\n"); |
| 3388 | |
| 3389 | wdev = WILC_WFI_CfgAlloc(); |
| 3390 | if (wdev == NULL) { |
| 3391 | PRINT_ER("CfgAlloc Failed\n"); |
| 3392 | return NULL; |
| 3393 | } |
| 3394 | |
| 3395 | |
| 3396 | /*Return hardware description structure (wiphy)'s priv*/ |
| 3397 | priv = wdev_priv(wdev); |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 3398 | sema_init(&(priv->SemHandleUpdateStats), 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3399 | |
| 3400 | /*Link the wiphy with wireless structure*/ |
| 3401 | priv->wdev = wdev; |
| 3402 | |
| 3403 | /*Maximum number of probed ssid to be added by user for the scan request*/ |
| 3404 | wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3405 | /*Maximum number of pmkids to be cashed*/ |
| 3406 | wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; |
| 3407 | 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] | 3408 | |
| 3409 | wdev->wiphy->max_scan_ie_len = 1000; |
| 3410 | |
| 3411 | /*signal strength in mBm (100*dBm) */ |
| 3412 | wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; |
| 3413 | |
| 3414 | /*Set the availaible cipher suites*/ |
| 3415 | wdev->wiphy->cipher_suites = cipher_suites; |
| 3416 | wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3417 | /*Setting default managment types: for register action frame: */ |
| 3418 | wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3419 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3420 | wdev->wiphy->max_remain_on_channel_duration = 500; |
| 3421 | /*Setting the wiphy interfcae mode and type before registering the wiphy*/ |
| 3422 | wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) | |
| 3423 | BIT(NL80211_IFTYPE_P2P_CLIENT); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3424 | wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3425 | wdev->iftype = NL80211_IFTYPE_STATION; |
| 3426 | |
| 3427 | |
| 3428 | |
| 3429 | PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n", |
| 3430 | wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type, |
| 3431 | wdev->wiphy->interface_modes, wdev->iftype); |
| 3432 | |
Arnd Bergmann | 2e7d537 | 2015-11-16 15:05:03 +0100 | [diff] [blame] | 3433 | set_wiphy_dev(wdev->wiphy, dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3434 | |
| 3435 | /*Register wiphy structure*/ |
| 3436 | s32Error = wiphy_register(wdev->wiphy); |
| 3437 | if (s32Error) { |
| 3438 | PRINT_ER("Cannot register wiphy device\n"); |
| 3439 | /*should define what action to be taken in such failure*/ |
| 3440 | } else { |
| 3441 | PRINT_D(CFG80211_DBG, "Successful Registering\n"); |
| 3442 | } |
| 3443 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3444 | priv->dev = net; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3445 | return wdev; |
| 3446 | |
| 3447 | |
| 3448 | } |
| 3449 | /** |
| 3450 | * @brief WILC_WFI_WiphyFree |
| 3451 | * @details Freeing allocation of the wireless device structure |
| 3452 | * @param[in] NONE |
| 3453 | * @return NONE |
| 3454 | * @author mdaftedar |
| 3455 | * @date 01 MAR 2012 |
| 3456 | * @version 1.0 |
| 3457 | */ |
Chaehyun Lim | dd4b6a8 | 2015-09-20 15:51:25 +0900 | [diff] [blame] | 3458 | int wilc_init_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3459 | { |
| 3460 | |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 3461 | int s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3462 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3463 | struct wilc_priv *priv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3464 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3465 | PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr); |
| 3466 | priv = wdev_priv(net->ieee80211_ptr); |
| 3467 | if (op_ifcs == 0) { |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 3468 | setup_timer(&hAgingTimer, remove_network_from_shadow, 0); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 3469 | setup_timer(&wilc_during_ip_timer, clear_duringIP, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3470 | } |
| 3471 | op_ifcs++; |
| 3472 | if (s32Error < 0) { |
| 3473 | PRINT_ER("Failed to creat refresh Timer\n"); |
| 3474 | return s32Error; |
| 3475 | } |
| 3476 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3477 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3478 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3479 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3480 | |
Arnd Bergmann | 83383ea | 2015-06-01 21:06:43 +0200 | [diff] [blame] | 3481 | sema_init(&(priv->hSemScanReq), 1); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 3482 | s32Error = wilc_init(net, &priv->hWILCWFIDrv); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3483 | if (s32Error) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3484 | PRINT_ER("Error while initializing hostinterface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3485 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3486 | return s32Error; |
| 3487 | } |
| 3488 | |
| 3489 | /** |
| 3490 | * @brief WILC_WFI_WiphyFree |
| 3491 | * @details Freeing allocation of the wireless device structure |
| 3492 | * @param[in] NONE |
| 3493 | * @return NONE |
| 3494 | * @author mdaftedar |
| 3495 | * @date 01 MAR 2012 |
| 3496 | * @version 1.0 |
| 3497 | */ |
Chaehyun Lim | a9a1682 | 2015-09-20 15:51:24 +0900 | [diff] [blame] | 3498 | int wilc_deinit_host_int(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3499 | { |
Chaehyun Lim | 1a8ccd8 | 2015-09-20 15:51:23 +0900 | [diff] [blame] | 3500 | int s32Error = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3501 | |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 3502 | struct wilc_priv *priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 3503 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3504 | priv = wdev_priv(net->ieee80211_ptr); |
| 3505 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3506 | priv->gbAutoRateAdjusted = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3507 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 3508 | priv->bInP2PlistenState = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3509 | |
| 3510 | op_ifcs--; |
| 3511 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 3512 | s32Error = wilc_deinit(priv->hWILCWFIDrv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3513 | |
| 3514 | /* Clear the Shadow scan */ |
Leo Kim | d14991a | 2015-11-19 15:56:22 +0900 | [diff] [blame] | 3515 | clear_shadow_scan(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3516 | if (op_ifcs == 0) { |
| 3517 | PRINT_D(CORECONFIG_DBG, "destroy during ip\n"); |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 3518 | del_timer_sync(&wilc_during_ip_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3519 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3520 | |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3521 | if (s32Error) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3522 | PRINT_ER("Error while deintializing host interface\n"); |
Chaehyun Lim | f1fe9c4 | 2015-09-20 15:51:22 +0900 | [diff] [blame] | 3523 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3524 | return s32Error; |
| 3525 | } |
| 3526 | |
| 3527 | |
| 3528 | /** |
| 3529 | * @brief WILC_WFI_WiphyFree |
| 3530 | * @details Freeing allocation of the wireless device structure |
| 3531 | * @param[in] NONE |
| 3532 | * @return NONE |
| 3533 | * @author mdaftedar |
| 3534 | * @date 01 MAR 2012 |
| 3535 | * @version 1.0 |
| 3536 | */ |
Chaehyun Lim | 96da20a | 2015-09-20 15:51:08 +0900 | [diff] [blame] | 3537 | void wilc_free_wiphy(struct net_device *net) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3538 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3539 | PRINT_D(CFG80211_DBG, "Unregistering wiphy\n"); |
| 3540 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 3541 | if (!net) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3542 | PRINT_D(INIT_DBG, "net_device is NULL\n"); |
| 3543 | return; |
| 3544 | } |
| 3545 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 3546 | if (!net->ieee80211_ptr) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3547 | PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n"); |
| 3548 | return; |
| 3549 | } |
| 3550 | |
Chaehyun Lim | 619837a | 2015-09-20 15:51:10 +0900 | [diff] [blame] | 3551 | if (!net->ieee80211_ptr->wiphy) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3552 | PRINT_D(INIT_DBG, "wiphy is NULL\n"); |
| 3553 | return; |
| 3554 | } |
| 3555 | |
| 3556 | wiphy_unregister(net->ieee80211_ptr->wiphy); |
| 3557 | |
| 3558 | PRINT_D(INIT_DBG, "Freeing wiphy\n"); |
| 3559 | wiphy_free(net->ieee80211_ptr->wiphy); |
| 3560 | kfree(net->ieee80211_ptr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3561 | } |