Chaehyun Lim | e215a87 | 2015-09-30 08:15:41 +0900 | [diff] [blame] | 1 | #include <linux/slab.h> |
| 2 | #include <linux/time.h> |
| 3 | #include <linux/kthread.h> |
| 4 | #include <linux/delay.h> |
Alison Schofield | e0c1496 | 2016-03-14 10:34:14 -0700 | [diff] [blame] | 5 | #include <linux/completion.h> |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 6 | #include <linux/list.h> |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 7 | #include <linux/workqueue.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 8 | #include "host_interface.h" |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 9 | #include <linux/spinlock.h> |
| 10 | #include <linux/errno.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 11 | #include "coreconfigurator.h" |
Arnd Bergmann | 491880e | 2015-11-16 15:04:55 +0100 | [diff] [blame] | 12 | #include "wilc_wlan.h" |
Chaehyun Lim | 5366012 | 2015-09-17 16:48:49 +0900 | [diff] [blame] | 13 | #include "wilc_wlan_if.h" |
Shraddha Barke | 281dd5a | 2015-10-05 17:00:33 +0530 | [diff] [blame] | 14 | #include <linux/etherdevice.h> |
Glen Lee | d5382219 | 2015-10-27 18:27:49 +0900 | [diff] [blame] | 15 | #include "wilc_wfi_netdevice.h" |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 16 | |
Chaehyun Lim | 9eac3a1 | 2015-06-18 22:08:51 +0900 | [diff] [blame] | 17 | #define HOST_IF_MSG_SCAN 0 |
| 18 | #define HOST_IF_MSG_CONNECT 1 |
| 19 | #define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO 2 |
| 20 | #define HOST_IF_MSG_KEY 3 |
| 21 | #define HOST_IF_MSG_RCVD_NTWRK_INFO 4 |
| 22 | #define HOST_IF_MSG_RCVD_SCAN_COMPLETE 5 |
| 23 | #define HOST_IF_MSG_CFG_PARAMS 6 |
| 24 | #define HOST_IF_MSG_SET_CHANNEL 7 |
| 25 | #define HOST_IF_MSG_DISCONNECT 8 |
| 26 | #define HOST_IF_MSG_GET_RSSI 9 |
Chaehyun Lim | 9eac3a1 | 2015-06-18 22:08:51 +0900 | [diff] [blame] | 27 | #define HOST_IF_MSG_ADD_BEACON 11 |
| 28 | #define HOST_IF_MSG_DEL_BEACON 12 |
| 29 | #define HOST_IF_MSG_ADD_STATION 13 |
| 30 | #define HOST_IF_MSG_DEL_STATION 14 |
| 31 | #define HOST_IF_MSG_EDIT_STATION 15 |
| 32 | #define HOST_IF_MSG_SCAN_TIMER_FIRED 16 |
| 33 | #define HOST_IF_MSG_CONNECT_TIMER_FIRED 17 |
| 34 | #define HOST_IF_MSG_POWER_MGMT 18 |
| 35 | #define HOST_IF_MSG_GET_INACTIVETIME 19 |
| 36 | #define HOST_IF_MSG_REMAIN_ON_CHAN 20 |
| 37 | #define HOST_IF_MSG_REGISTER_FRAME 21 |
| 38 | #define HOST_IF_MSG_LISTEN_TIMER_FIRED 22 |
Chaehyun Lim | 9eac3a1 | 2015-06-18 22:08:51 +0900 | [diff] [blame] | 39 | #define HOST_IF_MSG_SET_WFIDRV_HANDLER 24 |
Chaehyun Lim | 9eac3a1 | 2015-06-18 22:08:51 +0900 | [diff] [blame] | 40 | #define HOST_IF_MSG_GET_MAC_ADDRESS 26 |
| 41 | #define HOST_IF_MSG_SET_OPERATION_MODE 27 |
| 42 | #define HOST_IF_MSG_SET_IPADDRESS 28 |
| 43 | #define HOST_IF_MSG_GET_IPADDRESS 29 |
Chaehyun Lim | 9eac3a1 | 2015-06-18 22:08:51 +0900 | [diff] [blame] | 44 | #define HOST_IF_MSG_GET_STATISTICS 31 |
| 45 | #define HOST_IF_MSG_SET_MULTICAST_FILTER 32 |
Chaehyun Lim | 9eac3a1 | 2015-06-18 22:08:51 +0900 | [diff] [blame] | 46 | #define HOST_IF_MSG_DEL_BA_SESSION 34 |
Chaehyun Lim | 9eac3a1 | 2015-06-18 22:08:51 +0900 | [diff] [blame] | 47 | #define HOST_IF_MSG_DEL_ALL_STA 36 |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 48 | #define HOST_IF_MSG_SET_TX_POWER 38 |
| 49 | #define HOST_IF_MSG_GET_TX_POWER 39 |
Chaehyun Lim | 9eac3a1 | 2015-06-18 22:08:51 +0900 | [diff] [blame] | 50 | #define HOST_IF_MSG_EXIT 100 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 51 | |
Chaehyun Lim | e54d5b7 | 2015-06-18 22:08:50 +0900 | [diff] [blame] | 52 | #define HOST_IF_SCAN_TIMEOUT 4000 |
| 53 | #define HOST_IF_CONNECT_TIMEOUT 9500 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 54 | |
Chaehyun Lim | e54d5b7 | 2015-06-18 22:08:50 +0900 | [diff] [blame] | 55 | #define BA_SESSION_DEFAULT_BUFFER_SIZE 16 |
| 56 | #define BA_SESSION_DEFAULT_TIMEOUT 1000 |
| 57 | #define BLOCK_ACK_REQ_SIZE 0x14 |
Leo Kim | 9f3295a | 2015-10-19 18:26:10 +0900 | [diff] [blame] | 58 | #define FALSE_FRMWR_CHANNEL 100 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 59 | |
Glen Lee | 4fd6229 | 2016-02-04 18:15:24 +0900 | [diff] [blame] | 60 | #define TCP_ACK_FILTER_LINK_SPEED_THRESH 54 |
| 61 | #define DEFAULT_LINK_SPEED 72 |
| 62 | |
Leo Kim | 4372d3d | 2015-10-05 15:25:43 +0900 | [diff] [blame] | 63 | struct host_if_wpa_attr { |
Leo Kim | 124968fc | 2015-10-13 19:49:30 +0900 | [diff] [blame] | 64 | u8 *key; |
Leo Kim | 248080a | 2015-10-13 19:49:31 +0900 | [diff] [blame] | 65 | const u8 *mac_addr; |
Leo Kim | 0e74c00 | 2015-10-13 19:49:32 +0900 | [diff] [blame] | 66 | u8 *seq; |
Leo Kim | dacc594 | 2015-10-13 19:49:33 +0900 | [diff] [blame] | 67 | u8 seq_len; |
Leo Kim | e2dfbac | 2015-10-13 19:49:34 +0900 | [diff] [blame] | 68 | u8 index; |
Leo Kim | 6acf291 | 2015-10-13 19:49:35 +0900 | [diff] [blame] | 69 | u8 key_len; |
Leo Kim | 7b2ebb2 | 2015-10-13 19:49:36 +0900 | [diff] [blame] | 70 | u8 mode; |
Leo Kim | 4372d3d | 2015-10-05 15:25:43 +0900 | [diff] [blame] | 71 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 72 | |
Leo Kim | c276c44 | 2015-10-05 15:25:42 +0900 | [diff] [blame] | 73 | struct host_if_wep_attr { |
Tony Cho | e5538d3 | 2015-10-12 16:56:11 +0900 | [diff] [blame] | 74 | u8 *key; |
Tony Cho | d520e35 | 2015-10-12 16:56:12 +0900 | [diff] [blame] | 75 | u8 key_len; |
Tony Cho | 259b3aa | 2015-10-12 16:56:13 +0900 | [diff] [blame] | 76 | u8 index; |
Tony Cho | b5eaff1 | 2015-10-12 16:56:14 +0900 | [diff] [blame] | 77 | u8 mode; |
Tony Cho | 7fa252e | 2015-10-12 16:56:15 +0900 | [diff] [blame] | 78 | enum AUTHTYPE auth_type; |
Leo Kim | c276c44 | 2015-10-05 15:25:42 +0900 | [diff] [blame] | 79 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 80 | |
Leo Kim | 40cc2c9 | 2015-10-05 15:25:41 +0900 | [diff] [blame] | 81 | union host_if_key_attr { |
Tony Cho | 2ed7a2f | 2015-10-12 16:56:08 +0900 | [diff] [blame] | 82 | struct host_if_wep_attr wep; |
Tony Cho | e3501a4 | 2015-10-12 16:56:09 +0900 | [diff] [blame] | 83 | struct host_if_wpa_attr wpa; |
Tony Cho | 610e386 | 2015-10-12 16:56:10 +0900 | [diff] [blame] | 84 | struct host_if_pmkid_attr pmkid; |
Leo Kim | 40cc2c9 | 2015-10-05 15:25:41 +0900 | [diff] [blame] | 85 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 86 | |
Tony Cho | c98387a | 2015-09-21 12:16:40 +0900 | [diff] [blame] | 87 | struct key_attr { |
Leo Kim | 8e9f427 | 2015-10-13 19:49:27 +0900 | [diff] [blame] | 88 | enum KEY_TYPE type; |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 89 | u8 action; |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 90 | union host_if_key_attr attr; |
Tony Cho | c98387a | 2015-09-21 12:16:40 +0900 | [diff] [blame] | 91 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 92 | |
Tony Cho | c476feb | 2015-09-21 12:16:36 +0900 | [diff] [blame] | 93 | struct scan_attr { |
Leo Kim | 4256889 | 2015-10-13 19:49:37 +0900 | [diff] [blame] | 94 | u8 src; |
Leo Kim | 1e276c8 | 2015-10-13 19:49:38 +0900 | [diff] [blame] | 95 | u8 type; |
Leo Kim | 82eeb0a | 2015-10-13 19:49:40 +0900 | [diff] [blame] | 96 | u8 *ch_freq_list; |
Leo Kim | f97bd9c | 2015-10-13 19:49:41 +0900 | [diff] [blame] | 97 | u8 ch_list_len; |
Leo Kim | d6f19aa | 2015-10-13 19:49:42 +0900 | [diff] [blame] | 98 | u8 *ies; |
Leo Kim | 7b1f76c | 2015-10-13 19:49:43 +0900 | [diff] [blame] | 99 | size_t ies_len; |
Leo Kim | c17c6da | 2015-10-13 19:49:44 +0900 | [diff] [blame] | 100 | wilc_scan_result result; |
Leo Kim | 5f2b50c | 2015-10-13 19:49:45 +0900 | [diff] [blame] | 101 | void *arg; |
Leo Kim | 629b9ca | 2015-10-13 19:49:46 +0900 | [diff] [blame] | 102 | struct hidden_network hidden_network; |
Tony Cho | c476feb | 2015-09-21 12:16:36 +0900 | [diff] [blame] | 103 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 104 | |
Tony Cho | 120ae59 | 2015-09-21 12:16:37 +0900 | [diff] [blame] | 105 | struct connect_attr { |
Leo Kim | 9254db0 | 2015-10-13 19:49:49 +0900 | [diff] [blame] | 106 | u8 *bssid; |
Leo Kim | f7bbd9c | 2015-10-13 19:49:50 +0900 | [diff] [blame] | 107 | u8 *ssid; |
Leo Kim | 8b3c9fa | 2015-10-13 19:49:51 +0900 | [diff] [blame] | 108 | size_t ssid_len; |
Leo Kim | 2ea158c | 2015-10-13 19:49:52 +0900 | [diff] [blame] | 109 | u8 *ies; |
Leo Kim | b59d5c5 | 2015-10-13 19:49:53 +0900 | [diff] [blame] | 110 | size_t ies_len; |
Leo Kim | a64fd67 | 2015-10-13 19:49:54 +0900 | [diff] [blame] | 111 | u8 security; |
Leo Kim | 6abcc11 | 2015-10-13 19:49:55 +0900 | [diff] [blame] | 112 | wilc_connect_result result; |
Leo Kim | 8f38db8 | 2015-10-13 19:49:56 +0900 | [diff] [blame] | 113 | void *arg; |
Leo Kim | 61b4fd0 | 2015-10-13 19:49:57 +0900 | [diff] [blame] | 114 | enum AUTHTYPE auth_type; |
Leo Kim | 0d1527e | 2015-10-13 19:49:58 +0900 | [diff] [blame] | 115 | u8 ch; |
Leo Kim | f2bed2c | 2015-10-13 19:49:59 +0900 | [diff] [blame] | 116 | void *params; |
Tony Cho | 120ae59 | 2015-09-21 12:16:37 +0900 | [diff] [blame] | 117 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 118 | |
Tony Cho | f23a9ea | 2015-09-21 12:16:39 +0900 | [diff] [blame] | 119 | struct rcvd_async_info { |
Leo Kim | 33722ac7 | 2015-10-13 19:50:00 +0900 | [diff] [blame] | 120 | u8 *buffer; |
Leo Kim | f94f488 | 2015-10-13 19:50:01 +0900 | [diff] [blame] | 121 | u32 len; |
Tony Cho | f23a9ea | 2015-09-21 12:16:39 +0900 | [diff] [blame] | 122 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 123 | |
Tony Cho | 94bdfe4 | 2015-09-30 18:44:27 +0900 | [diff] [blame] | 124 | struct channel_attr { |
Leo Kim | 730ee05 | 2015-10-13 19:50:02 +0900 | [diff] [blame] | 125 | u8 set_ch; |
Tony Cho | 326b323 | 2015-09-21 12:16:42 +0900 | [diff] [blame] | 126 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 127 | |
Tony Cho | 7f33fec | 2015-09-30 18:44:30 +0900 | [diff] [blame] | 128 | struct beacon_attr { |
Leo Kim | 12262dd | 2015-10-13 19:50:03 +0900 | [diff] [blame] | 129 | u32 interval; |
Leo Kim | e76ab77 | 2015-10-13 19:50:04 +0900 | [diff] [blame] | 130 | u32 dtim_period; |
Leo Kim | 51c6618 | 2015-10-13 19:50:05 +0900 | [diff] [blame] | 131 | u32 head_len; |
Leo Kim | 8ce528b | 2015-10-13 19:50:06 +0900 | [diff] [blame] | 132 | u8 *head; |
Leo Kim | 030c57e | 2015-10-13 19:50:07 +0900 | [diff] [blame] | 133 | u32 tail_len; |
Leo Kim | 7dbcb6d3 | 2015-10-13 19:50:08 +0900 | [diff] [blame] | 134 | u8 *tail; |
Tony Cho | 902362b | 2015-09-21 12:16:44 +0900 | [diff] [blame] | 135 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 136 | |
Tony Cho | 641210a | 2015-09-21 12:16:52 +0900 | [diff] [blame] | 137 | struct set_multicast { |
Leo Kim | bae636eb | 2015-10-13 20:02:04 +0900 | [diff] [blame] | 138 | bool enabled; |
Leo Kim | adab2f7 | 2015-10-13 20:02:05 +0900 | [diff] [blame] | 139 | u32 cnt; |
Tony Cho | 641210a | 2015-09-21 12:16:52 +0900 | [diff] [blame] | 140 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 141 | |
Tony Cho | b4e644e | 2015-09-21 12:17:00 +0900 | [diff] [blame] | 142 | struct del_all_sta { |
Leo Kim | e51b921 | 2015-10-13 19:50:09 +0900 | [diff] [blame] | 143 | u8 del_all_sta[MAX_NUM_STA][ETH_ALEN]; |
Leo Kim | 8ba1803 | 2015-10-13 19:50:10 +0900 | [diff] [blame] | 144 | u8 assoc_sta; |
Tony Cho | b4e644e | 2015-09-21 12:17:00 +0900 | [diff] [blame] | 145 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 146 | |
Tony Cho | fb93a1e | 2015-09-21 12:16:57 +0900 | [diff] [blame] | 147 | struct del_sta { |
Leo Kim | e4839d3 | 2015-10-13 20:02:06 +0900 | [diff] [blame] | 148 | u8 mac_addr[ETH_ALEN]; |
Tony Cho | fb93a1e | 2015-09-21 12:16:57 +0900 | [diff] [blame] | 149 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 150 | |
Tony Cho | 5a008f1 | 2015-09-21 12:16:48 +0900 | [diff] [blame] | 151 | struct power_mgmt_param { |
Leo Kim | 33c70c1 | 2015-10-13 20:02:07 +0900 | [diff] [blame] | 152 | bool enabled; |
Leo Kim | 937918f | 2015-10-13 20:02:08 +0900 | [diff] [blame] | 153 | u32 timeout; |
Tony Cho | 5a008f1 | 2015-09-21 12:16:48 +0900 | [diff] [blame] | 154 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 155 | |
Tony Cho | 15191ea | 2015-09-21 12:16:50 +0900 | [diff] [blame] | 156 | struct set_ip_addr { |
Leo Kim | 78675be | 2015-10-13 20:02:09 +0900 | [diff] [blame] | 157 | u8 *ip_addr; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 158 | u8 idx; |
Tony Cho | 15191ea | 2015-09-21 12:16:50 +0900 | [diff] [blame] | 159 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 160 | |
Tony Cho | 3d1eac0 | 2015-09-21 12:16:49 +0900 | [diff] [blame] | 161 | struct sta_inactive_t { |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 162 | u8 mac[6]; |
Tony Cho | 3d1eac0 | 2015-09-21 12:16:49 +0900 | [diff] [blame] | 163 | }; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 164 | |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 165 | struct tx_power { |
| 166 | u8 tx_pwr; |
| 167 | }; |
| 168 | |
Tony Cho | dfc7663 | 2015-09-21 12:16:34 +0900 | [diff] [blame] | 169 | union message_body { |
Tony Cho | 4528bdb | 2015-09-30 18:44:20 +0900 | [diff] [blame] | 170 | struct scan_attr scan_info; |
Tony Cho | 3f50197 | 2015-09-30 18:44:21 +0900 | [diff] [blame] | 171 | struct connect_attr con_info; |
Tony Cho | 02d1946 | 2015-09-30 18:44:22 +0900 | [diff] [blame] | 172 | struct rcvd_net_info net_info; |
Tony Cho | 66add62 | 2015-09-30 18:44:23 +0900 | [diff] [blame] | 173 | struct rcvd_async_info async_info; |
Tony Cho | 18990bf | 2015-09-30 18:44:24 +0900 | [diff] [blame] | 174 | struct key_attr key_info; |
Tony Cho | a2340c3 | 2015-09-30 18:44:25 +0900 | [diff] [blame] | 175 | struct cfg_param_attr cfg_info; |
Tony Cho | ffd6dbc | 2015-09-30 18:44:28 +0900 | [diff] [blame] | 176 | struct channel_attr channel_info; |
Tony Cho | a98491e | 2015-09-30 18:44:31 +0900 | [diff] [blame] | 177 | struct beacon_attr beacon_info; |
Tony Cho | ca8f47f | 2015-09-30 18:44:32 +0900 | [diff] [blame] | 178 | struct add_sta_param add_sta_info; |
Tony Cho | 889c25b | 2015-09-30 18:44:33 +0900 | [diff] [blame] | 179 | struct del_sta del_sta_info; |
Tony Cho | 4a93096 | 2015-09-30 18:44:34 +0900 | [diff] [blame] | 180 | struct add_sta_param edit_sta_info; |
Tony Cho | 49e1f81 | 2015-09-30 18:44:36 +0900 | [diff] [blame] | 181 | struct power_mgmt_param pwr_mgmt_info; |
Tony Cho | 66bac7f | 2015-09-30 18:44:37 +0900 | [diff] [blame] | 182 | struct sta_inactive_t mac_info; |
Tony Cho | fb2d65e | 2015-09-30 18:44:39 +0900 | [diff] [blame] | 183 | struct set_ip_addr ip_info; |
Tony Cho | 5e4377e | 2015-09-30 18:44:38 +0900 | [diff] [blame] | 184 | struct drv_handler drv; |
Tony Cho | a079cf4d | 2015-09-30 18:55:05 +0900 | [diff] [blame] | 185 | struct set_multicast multicast_info; |
Tony Cho | 00c4630 | 2015-09-30 18:55:06 +0900 | [diff] [blame] | 186 | struct op_mode mode; |
Tony Cho | a584869 | 2015-09-30 18:55:08 +0900 | [diff] [blame] | 187 | struct get_mac_addr get_mac_info; |
Tony Cho | c833b47 | 2015-09-30 18:55:09 +0900 | [diff] [blame] | 188 | struct ba_session_info session_info; |
Tony Cho | 070d365 | 2015-09-30 18:55:10 +0900 | [diff] [blame] | 189 | struct remain_ch remain_on_ch; |
Tony Cho | 5c4008d | 2015-10-05 13:50:44 +0900 | [diff] [blame] | 190 | struct reg_frame reg_frame; |
Tony Cho | e60831e | 2015-10-05 13:50:45 +0900 | [diff] [blame] | 191 | char *data; |
Tony Cho | b0c1e80 | 2015-10-05 13:50:46 +0900 | [diff] [blame] | 192 | struct del_all_sta del_all_sta_info; |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 193 | struct tx_power tx_power; |
Tony Cho | dfc7663 | 2015-09-21 12:16:34 +0900 | [diff] [blame] | 194 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 195 | |
Tony Cho | 3a8c41b | 2015-09-18 18:11:04 +0900 | [diff] [blame] | 196 | struct host_if_msg { |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 197 | u16 id; |
| 198 | union message_body body; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 199 | struct wilc_vif *vif; |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 200 | struct work_struct work; |
Tony Cho | 3a8c41b | 2015-09-18 18:11:04 +0900 | [diff] [blame] | 201 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 202 | |
Leo Kim | e0a1221 | 2015-10-12 16:55:49 +0900 | [diff] [blame] | 203 | struct join_bss_param { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 204 | BSSTYPE_T bss_type; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 205 | u8 dtim_period; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 206 | u16 beacon_period; |
| 207 | u16 cap_info; |
Chaehyun Lim | f176429 | 2016-02-12 23:04:37 +0900 | [diff] [blame] | 208 | u8 bssid[6]; |
Dean Lee | 576917a | 2015-06-15 11:58:57 +0900 | [diff] [blame] | 209 | char ssid[MAX_SSID_LEN]; |
Leo Kim | 619d27b | 2015-10-15 13:24:42 +0900 | [diff] [blame] | 210 | u8 ssid_len; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 211 | u8 supp_rates[MAX_RATES_SUPPORTED + 1]; |
| 212 | u8 ht_capable; |
| 213 | u8 wmm_cap; |
| 214 | u8 uapsd_cap; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 215 | bool rsn_found; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 216 | u8 rsn_grp_policy; |
| 217 | u8 mode_802_11i; |
| 218 | u8 rsn_pcip_policy[3]; |
| 219 | u8 rsn_auth_policy[3]; |
| 220 | u8 rsn_cap[2]; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 221 | u32 tsf; |
Leo Kim | 7a8d51d | 2015-10-15 13:24:43 +0900 | [diff] [blame] | 222 | u8 noa_enabled; |
Leo Kim | d72b33c | 2015-10-15 13:24:44 +0900 | [diff] [blame] | 223 | u8 opp_enabled; |
Leo Kim | 99b6694 | 2015-10-15 13:24:45 +0900 | [diff] [blame] | 224 | u8 ct_window; |
Leo Kim | c21047e | 2015-10-15 13:24:46 +0900 | [diff] [blame] | 225 | u8 cnt; |
Leo Kim | cc17900 | 2015-10-15 13:24:47 +0900 | [diff] [blame] | 226 | u8 idx; |
Leo Kim | 109e6ca | 2015-10-15 13:24:48 +0900 | [diff] [blame] | 227 | u8 duration[4]; |
Leo Kim | 1d8b76b | 2015-10-15 13:24:49 +0900 | [diff] [blame] | 228 | u8 interval[4]; |
Leo Kim | 4be55e2 | 2015-10-28 15:59:27 +0900 | [diff] [blame] | 229 | u8 start_time[4]; |
Leo Kim | e0a1221 | 2015-10-12 16:55:49 +0900 | [diff] [blame] | 230 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 231 | |
Hugo Camboulive | d27afda | 2016-01-04 22:02:23 +0000 | [diff] [blame] | 232 | static struct host_if_drv *terminated_handle; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 233 | bool wilc_optaining_ip; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 234 | static u8 P2P_LISTEN_STATE; |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 235 | static struct workqueue_struct *hif_workqueue; |
Chaehyun Lim | 04dd9a4 | 2016-03-23 21:28:33 +0900 | [diff] [blame] | 236 | static struct completion hif_thread_comp; |
Chaehyun Lim | 2bb0258 | 2016-03-23 21:28:34 +0900 | [diff] [blame] | 237 | static struct completion hif_driver_comp; |
Chaehyun Lim | 613eaa3 | 2016-03-14 09:40:27 +0900 | [diff] [blame] | 238 | static struct completion hif_wait_response; |
Chaehyun Lim | 896802a | 2016-03-22 08:39:24 +0900 | [diff] [blame] | 239 | static struct mutex hif_deinit_lock; |
kbuild test robot | 24aadb8 | 2015-10-15 14:32:40 +0800 | [diff] [blame] | 240 | static struct timer_list periodic_rssi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 241 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 242 | u8 wilc_multicast_mac_addr_list[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 243 | |
Leo Kim | a633c0b | 2015-10-15 13:24:59 +0900 | [diff] [blame] | 244 | static u8 rcv_assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 245 | |
kbuild test robot | f64321c | 2015-10-15 14:46:26 +0800 | [diff] [blame] | 246 | static bool scan_while_connected; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 247 | |
Leo Kim | 144b7b2 | 2015-10-15 13:25:01 +0900 | [diff] [blame] | 248 | static s8 rssi; |
Leo Kim | 078b1e9 | 2015-10-15 13:25:04 +0900 | [diff] [blame] | 249 | static u8 set_ip[2][4]; |
Leo Kim | 1e75d01 | 2015-10-15 13:25:05 +0900 | [diff] [blame] | 250 | static u8 get_ip[2][4]; |
Leo Kim | ad26906 | 2015-10-15 13:25:06 +0900 | [diff] [blame] | 251 | static u32 inactive_time; |
Leo Kim | a74c7bf | 2015-10-15 13:25:07 +0900 | [diff] [blame] | 252 | static u8 del_beacon; |
Leo Kim | 7178aed | 2015-10-19 18:26:09 +0900 | [diff] [blame] | 253 | static u32 clients_count; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 254 | |
kbuild test robot | ef59919 | 2015-10-15 15:04:15 +0800 | [diff] [blame] | 255 | static u8 *join_req; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 256 | static u8 *info_element; |
kbuild test robot | 23047d5 | 2015-10-15 15:18:34 +0800 | [diff] [blame] | 257 | static u8 mode_11i; |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 258 | static u8 auth_type; |
| 259 | static u32 join_req_size; |
kbuild test robot | 5e0e7c2 | 2015-10-15 15:47:44 +0800 | [diff] [blame] | 260 | static u32 info_element_size; |
Glen Lee | 7036c62 | 2015-12-21 14:18:45 +0900 | [diff] [blame] | 261 | static struct wilc_vif *join_req_vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 262 | #define REAL_JOIN_REQ 0 |
| 263 | #define FLUSHED_JOIN_REQ 1 |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 264 | #define FLUSHED_BYTE_POS 79 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 265 | |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 266 | static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo); |
Chaehyun Lim | 4ad878b | 2015-12-30 21:15:44 +0900 | [diff] [blame] | 267 | static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx); |
Chaehyun Lim | 4aa3387 | 2016-04-04 20:04:44 +0900 | [diff] [blame] | 268 | static s32 Handle_ScanDone(struct wilc_vif *vif, enum scan_event enuEvent); |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 269 | static void host_if_work(struct work_struct *work); |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 270 | |
| 271 | /*! |
| 272 | * @author syounan |
| 273 | * @date 1 Sep 2010 |
| 274 | * @note copied from FLO glue implementatuion |
| 275 | * @version 1.0 |
| 276 | */ |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 277 | static int wilc_enqueue_cmd(struct host_if_msg *msg) |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 278 | { |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 279 | struct host_if_msg *new_msg; |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 280 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 281 | new_msg = kmemdup(msg, sizeof(*new_msg), GFP_ATOMIC); |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 282 | if (!new_msg) |
| 283 | return -ENOMEM; |
| 284 | |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 285 | INIT_WORK(&new_msg->work, host_if_work); |
| 286 | queue_work(hif_workqueue, &new_msg->work); |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 287 | return 0; |
| 288 | } |
| 289 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 290 | |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 291 | /* The u8IfIdx starts from 0 to NUM_CONCURRENT_IFC -1, but 0 index used as |
| 292 | * special purpose in wilc device, so we add 1 to the index to starts from 1. |
| 293 | * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC. |
| 294 | */ |
Glen Lee | 31f0f69 | 2015-12-21 14:18:44 +0900 | [diff] [blame] | 295 | int wilc_get_vif_idx(struct wilc_vif *vif) |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 296 | { |
Leo Kim | 6750140 | 2016-02-04 18:15:39 +0900 | [diff] [blame] | 297 | return vif->idx + 1; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | /* We need to minus 1 from idx which is from wilc device to get real index |
| 301 | * of wilc->vif[], because we add 1 when pass to wilc device in the function |
| 302 | * wilc_get_vif_idx. |
| 303 | * As a result, the index should be between 0 and NUM_CONCURRENT_IFC -1. |
| 304 | */ |
| 305 | static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) |
| 306 | { |
| 307 | int index = idx - 1; |
| 308 | |
| 309 | if (index < 0 || index >= NUM_CONCURRENT_IFC) |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 310 | return NULL; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 311 | |
| 312 | return wilc->vif[index]; |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 313 | } |
| 314 | |
Chaehyun Lim | c43f5f9 | 2016-02-12 23:04:44 +0900 | [diff] [blame] | 315 | static void handle_set_channel(struct wilc_vif *vif, |
| 316 | struct channel_attr *hif_set_ch) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 317 | { |
Chaehyun Lim | 5349f6d | 2016-02-12 23:04:46 +0900 | [diff] [blame] | 318 | int ret = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 319 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 320 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 321 | wid.id = (u16)WID_CURRENT_CHANNEL; |
| 322 | wid.type = WID_CHAR; |
Leo Kim | 9cf7878 | 2015-10-29 12:05:54 +0900 | [diff] [blame] | 323 | wid.val = (char *)&hif_set_ch->set_ch; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 324 | wid.size = sizeof(char); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 325 | |
Chaehyun Lim | 5349f6d | 2016-02-12 23:04:46 +0900 | [diff] [blame] | 326 | ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
| 327 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 328 | |
Chaehyun Lim | 5349f6d | 2016-02-12 23:04:46 +0900 | [diff] [blame] | 329 | if (ret) |
Chaehyun Lim | ecdd5c7 | 2016-02-12 23:04:47 +0900 | [diff] [blame] | 330 | netdev_err(vif->ndev, "Failed to set channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 331 | } |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 332 | |
Chaehyun Lim | 62a0d45 | 2016-04-07 08:10:38 +0900 | [diff] [blame] | 333 | static void handle_set_wfi_drv_handler(struct wilc_vif *vif, |
| 334 | struct drv_handler *hif_drv_handler) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 335 | { |
Chaehyun Lim | fdcc285 | 2016-04-07 08:10:40 +0900 | [diff] [blame] | 336 | int ret = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 337 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 338 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 339 | wid.id = (u16)WID_SET_DRV_HANDLER; |
Glen Lee | b330686 | 2016-02-04 18:15:18 +0900 | [diff] [blame] | 340 | wid.type = WID_STR; |
| 341 | wid.val = (s8 *)hif_drv_handler; |
| 342 | wid.size = sizeof(*hif_drv_handler); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 343 | |
Chaehyun Lim | fdcc285 | 2016-04-07 08:10:40 +0900 | [diff] [blame] | 344 | ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
| 345 | hif_drv_handler->handler); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 346 | |
Glen Lee | 31f0f69 | 2015-12-21 14:18:44 +0900 | [diff] [blame] | 347 | if (!hif_drv_handler->handler) |
Chaehyun Lim | 2bb0258 | 2016-03-23 21:28:34 +0900 | [diff] [blame] | 348 | complete(&hif_driver_comp); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 349 | |
Chaehyun Lim | fdcc285 | 2016-04-07 08:10:40 +0900 | [diff] [blame] | 350 | if (ret) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 351 | netdev_err(vif->ndev, "Failed to set driver handler\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 352 | } |
| 353 | |
Chaehyun Lim | b093d4f | 2016-04-07 08:10:41 +0900 | [diff] [blame] | 354 | static void handle_set_operation_mode(struct wilc_vif *vif, |
| 355 | struct op_mode *hif_op_mode) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 356 | { |
Chaehyun Lim | 14f3b08 | 2016-04-07 08:10:43 +0900 | [diff] [blame] | 357 | int ret = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 358 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 359 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 360 | wid.id = (u16)WID_SET_OPERATION_MODE; |
| 361 | wid.type = WID_INT; |
Leo Kim | acff1d7 | 2015-10-29 12:05:56 +0900 | [diff] [blame] | 362 | wid.val = (s8 *)&hif_op_mode->mode; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 363 | wid.size = sizeof(u32); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 364 | |
Chaehyun Lim | 14f3b08 | 2016-04-07 08:10:43 +0900 | [diff] [blame] | 365 | ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
| 366 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 367 | |
Leo Kim | acff1d7 | 2015-10-29 12:05:56 +0900 | [diff] [blame] | 368 | if ((hif_op_mode->mode) == IDLE_MODE) |
Chaehyun Lim | 2bb0258 | 2016-03-23 21:28:34 +0900 | [diff] [blame] | 369 | complete(&hif_driver_comp); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 370 | |
Chaehyun Lim | 14f3b08 | 2016-04-07 08:10:43 +0900 | [diff] [blame] | 371 | if (ret) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 372 | netdev_err(vif->ndev, "Failed to set driver handler\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 373 | } |
| 374 | |
Chaehyun Lim | fc6138b | 2016-04-19 09:35:29 +0900 | [diff] [blame] | 375 | static void handle_set_ip_address(struct wilc_vif *vif, u8 *ip_addr, u8 idx) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 376 | { |
Chaehyun Lim | 8958f58 | 2016-04-19 09:35:31 +0900 | [diff] [blame] | 377 | int ret = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 378 | struct wid wid; |
Leo Kim | ebc57d1 | 2015-11-05 14:36:03 +0900 | [diff] [blame] | 379 | char firmware_ip_addr[4] = {0}; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 380 | |
Leo Kim | a6527c3 | 2015-11-05 14:36:02 +0900 | [diff] [blame] | 381 | if (ip_addr[0] < 192) |
| 382 | ip_addr[0] = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 383 | |
Leo Kim | a6527c3 | 2015-11-05 14:36:02 +0900 | [diff] [blame] | 384 | memcpy(set_ip[idx], ip_addr, IP_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 385 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 386 | wid.id = (u16)WID_IP_ADDRESS; |
| 387 | wid.type = WID_STR; |
Leo Kim | a6527c3 | 2015-11-05 14:36:02 +0900 | [diff] [blame] | 388 | wid.val = (u8 *)ip_addr; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 389 | wid.size = IP_ALEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 390 | |
Chaehyun Lim | 8958f58 | 2016-04-19 09:35:31 +0900 | [diff] [blame] | 391 | ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
| 392 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 393 | |
Chaehyun Lim | f8813d3 | 2015-12-30 21:15:42 +0900 | [diff] [blame] | 394 | host_int_get_ipaddress(vif, firmware_ip_addr, idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 395 | |
Chaehyun Lim | 8958f58 | 2016-04-19 09:35:31 +0900 | [diff] [blame] | 396 | if (ret) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 397 | netdev_err(vif->ndev, "Failed to set IP address\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 398 | } |
| 399 | |
Chaehyun Lim | 8f9d9e0 | 2016-05-02 19:47:49 +0900 | [diff] [blame] | 400 | static void handle_get_ip_address(struct wilc_vif *vif, u8 idx) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 401 | { |
Chaehyun Lim | 6f2f5d5 | 2016-05-02 19:47:51 +0900 | [diff] [blame] | 402 | int ret = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 403 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 404 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 405 | wid.id = (u16)WID_IP_ADDRESS; |
| 406 | wid.type = WID_STR; |
| 407 | wid.val = kmalloc(IP_ALEN, GFP_KERNEL); |
| 408 | wid.size = IP_ALEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 409 | |
Chaehyun Lim | 6f2f5d5 | 2016-05-02 19:47:51 +0900 | [diff] [blame] | 410 | ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, |
| 411 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 412 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 413 | memcpy(get_ip[idx], wid.val, IP_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 414 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 415 | kfree(wid.val); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 416 | |
Leo Kim | 1e75d01 | 2015-10-15 13:25:05 +0900 | [diff] [blame] | 417 | if (memcmp(get_ip[idx], set_ip[idx], IP_ALEN) != 0) |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 418 | wilc_setup_ipaddress(vif, set_ip[idx], idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 419 | |
Chaehyun Lim | abfaf5f | 2016-05-02 19:47:52 +0900 | [diff] [blame] | 420 | if (ret) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 421 | netdev_err(vif->ndev, "Failed to get IP address\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 422 | } |
| 423 | |
Chaehyun Lim | 93dc5d5 | 2016-05-02 19:47:53 +0900 | [diff] [blame] | 424 | static void handle_get_mac_address(struct wilc_vif *vif, |
| 425 | struct get_mac_addr *get_mac_addr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 426 | { |
Chaehyun Lim | beba2ab | 2016-05-02 19:47:55 +0900 | [diff] [blame] | 427 | int ret = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 428 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 429 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 430 | wid.id = (u16)WID_MAC_ADDR; |
| 431 | wid.type = WID_STR; |
Leo Kim | 7f0ee9a | 2015-11-05 14:36:06 +0900 | [diff] [blame] | 432 | wid.val = get_mac_addr->mac_addr; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 433 | wid.size = ETH_ALEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 434 | |
Chaehyun Lim | beba2ab | 2016-05-02 19:47:55 +0900 | [diff] [blame] | 435 | ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, |
| 436 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 437 | |
Chaehyun Lim | beba2ab | 2016-05-02 19:47:55 +0900 | [diff] [blame] | 438 | if (ret) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 439 | netdev_err(vif->ndev, "Failed to get mac address\n"); |
Chaehyun Lim | 613eaa3 | 2016-03-14 09:40:27 +0900 | [diff] [blame] | 440 | complete(&hif_wait_response); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 441 | } |
| 442 | |
Chaehyun Lim | fbc976c | 2016-06-13 08:28:10 +0900 | [diff] [blame] | 443 | static void handle_cfg_param(struct wilc_vif *vif, |
| 444 | struct cfg_param_attr *cfg_param_attr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 445 | { |
Chaehyun Lim | a1e7df4 | 2016-06-13 08:28:12 +0900 | [diff] [blame] | 446 | int ret = 0; |
Leo Kim | 13ca52a | 2015-11-06 11:20:11 +0900 | [diff] [blame] | 447 | struct wid wid_list[32]; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 448 | struct host_if_drv *hif_drv = vif->hif_drv; |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 449 | int i = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 450 | |
Chaehyun Lim | 1f12f14 | 2016-03-08 10:04:32 +0900 | [diff] [blame] | 451 | mutex_lock(&hif_drv->cfg_values_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 452 | |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 453 | if (cfg_param_attr->flag & BSS_TYPE) { |
Chaehyun Lim | 0cb7a574 | 2016-06-13 08:28:14 +0900 | [diff] [blame] | 454 | u8 bss_type = cfg_param_attr->bss_type; |
| 455 | |
| 456 | if (bss_type < 6) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 457 | wid_list[i].id = WID_BSS_TYPE; |
Chaehyun Lim | 0cb7a574 | 2016-06-13 08:28:14 +0900 | [diff] [blame] | 458 | wid_list[i].val = (s8 *)&bss_type; |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 459 | wid_list[i].type = WID_CHAR; |
| 460 | wid_list[i].size = sizeof(char); |
Chaehyun Lim | 2938f20 | 2016-06-13 08:28:15 +0900 | [diff] [blame] | 461 | hif_drv->cfg_values.bss_type = bss_type; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 462 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 463 | netdev_err(vif->ndev, "check value 6 over\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 464 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 465 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 466 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 467 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 468 | if (cfg_param_attr->flag & AUTH_TYPE) { |
| 469 | if (cfg_param_attr->auth_type == 1 || |
| 470 | cfg_param_attr->auth_type == 2 || |
| 471 | cfg_param_attr->auth_type == 5) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 472 | wid_list[i].id = WID_AUTH_TYPE; |
| 473 | wid_list[i].val = (s8 *)&cfg_param_attr->auth_type; |
| 474 | wid_list[i].type = WID_CHAR; |
| 475 | wid_list[i].size = sizeof(char); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 476 | hif_drv->cfg_values.auth_type = (u8)cfg_param_attr->auth_type; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 477 | } else { |
Chaehyun Lim | cdc6cd2 | 2016-02-23 15:38:03 +0900 | [diff] [blame] | 478 | netdev_err(vif->ndev, "Impossible value\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 479 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 480 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 481 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 482 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 483 | if (cfg_param_attr->flag & AUTHEN_TIMEOUT) { |
| 484 | if (cfg_param_attr->auth_timeout > 0 && |
| 485 | cfg_param_attr->auth_timeout < 65536) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 486 | wid_list[i].id = WID_AUTH_TIMEOUT; |
| 487 | wid_list[i].val = (s8 *)&cfg_param_attr->auth_timeout; |
| 488 | wid_list[i].type = WID_SHORT; |
| 489 | wid_list[i].size = sizeof(u16); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 490 | hif_drv->cfg_values.auth_timeout = cfg_param_attr->auth_timeout; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 491 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 492 | netdev_err(vif->ndev, "Range(1 ~ 65535) over\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 493 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 494 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 495 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 496 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 497 | if (cfg_param_attr->flag & POWER_MANAGEMENT) { |
| 498 | if (cfg_param_attr->power_mgmt_mode < 5) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 499 | wid_list[i].id = WID_POWER_MANAGEMENT; |
| 500 | wid_list[i].val = (s8 *)&cfg_param_attr->power_mgmt_mode; |
| 501 | wid_list[i].type = WID_CHAR; |
| 502 | wid_list[i].size = sizeof(char); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 503 | hif_drv->cfg_values.power_mgmt_mode = (u8)cfg_param_attr->power_mgmt_mode; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 504 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 505 | netdev_err(vif->ndev, "Invalid power mode\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 506 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 507 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 508 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 509 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 510 | if (cfg_param_attr->flag & RETRY_SHORT) { |
| 511 | if (cfg_param_attr->short_retry_limit > 0 && |
| 512 | cfg_param_attr->short_retry_limit < 256) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 513 | wid_list[i].id = WID_SHORT_RETRY_LIMIT; |
| 514 | wid_list[i].val = (s8 *)&cfg_param_attr->short_retry_limit; |
| 515 | wid_list[i].type = WID_SHORT; |
| 516 | wid_list[i].size = sizeof(u16); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 517 | hif_drv->cfg_values.short_retry_limit = cfg_param_attr->short_retry_limit; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 518 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 519 | netdev_err(vif->ndev, "Range(1~256) over\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 520 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 521 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 522 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 523 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 524 | if (cfg_param_attr->flag & RETRY_LONG) { |
| 525 | if (cfg_param_attr->long_retry_limit > 0 && |
| 526 | cfg_param_attr->long_retry_limit < 256) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 527 | wid_list[i].id = WID_LONG_RETRY_LIMIT; |
| 528 | wid_list[i].val = (s8 *)&cfg_param_attr->long_retry_limit; |
| 529 | wid_list[i].type = WID_SHORT; |
| 530 | wid_list[i].size = sizeof(u16); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 531 | hif_drv->cfg_values.long_retry_limit = cfg_param_attr->long_retry_limit; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 532 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 533 | netdev_err(vif->ndev, "Range(1~256) over\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 534 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 535 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 536 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 537 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 538 | if (cfg_param_attr->flag & FRAG_THRESHOLD) { |
| 539 | if (cfg_param_attr->frag_threshold > 255 && |
| 540 | cfg_param_attr->frag_threshold < 7937) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 541 | wid_list[i].id = WID_FRAG_THRESHOLD; |
| 542 | wid_list[i].val = (s8 *)&cfg_param_attr->frag_threshold; |
| 543 | wid_list[i].type = WID_SHORT; |
| 544 | wid_list[i].size = sizeof(u16); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 545 | hif_drv->cfg_values.frag_threshold = cfg_param_attr->frag_threshold; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 546 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 547 | netdev_err(vif->ndev, "Threshold Range fail\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 548 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 549 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 550 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 551 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 552 | if (cfg_param_attr->flag & RTS_THRESHOLD) { |
| 553 | if (cfg_param_attr->rts_threshold > 255 && |
| 554 | cfg_param_attr->rts_threshold < 65536) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 555 | wid_list[i].id = WID_RTS_THRESHOLD; |
| 556 | wid_list[i].val = (s8 *)&cfg_param_attr->rts_threshold; |
| 557 | wid_list[i].type = WID_SHORT; |
| 558 | wid_list[i].size = sizeof(u16); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 559 | hif_drv->cfg_values.rts_threshold = cfg_param_attr->rts_threshold; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 560 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 561 | netdev_err(vif->ndev, "Threshold Range fail\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 562 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 563 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 564 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 565 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 566 | if (cfg_param_attr->flag & PREAMBLE) { |
| 567 | if (cfg_param_attr->preamble_type < 3) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 568 | wid_list[i].id = WID_PREAMBLE; |
| 569 | wid_list[i].val = (s8 *)&cfg_param_attr->preamble_type; |
| 570 | wid_list[i].type = WID_CHAR; |
| 571 | wid_list[i].size = sizeof(char); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 572 | hif_drv->cfg_values.preamble_type = cfg_param_attr->preamble_type; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 573 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 574 | netdev_err(vif->ndev, "Preamle Range(0~2) over\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 575 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 576 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 577 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 578 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 579 | if (cfg_param_attr->flag & SHORT_SLOT_ALLOWED) { |
| 580 | if (cfg_param_attr->short_slot_allowed < 2) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 581 | wid_list[i].id = WID_SHORT_SLOT_ALLOWED; |
| 582 | wid_list[i].val = (s8 *)&cfg_param_attr->short_slot_allowed; |
| 583 | wid_list[i].type = WID_CHAR; |
| 584 | wid_list[i].size = sizeof(char); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 585 | hif_drv->cfg_values.short_slot_allowed = (u8)cfg_param_attr->short_slot_allowed; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 586 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 587 | netdev_err(vif->ndev, "Short slot(2) over\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 588 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 589 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 590 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 591 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 592 | if (cfg_param_attr->flag & TXOP_PROT_DISABLE) { |
| 593 | if (cfg_param_attr->txop_prot_disabled < 2) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 594 | wid_list[i].id = WID_11N_TXOP_PROT_DISABLE; |
| 595 | wid_list[i].val = (s8 *)&cfg_param_attr->txop_prot_disabled; |
| 596 | wid_list[i].type = WID_CHAR; |
| 597 | wid_list[i].size = sizeof(char); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 598 | hif_drv->cfg_values.txop_prot_disabled = (u8)cfg_param_attr->txop_prot_disabled; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 599 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 600 | netdev_err(vif->ndev, "TXOP prot disable\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 601 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 602 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 603 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 604 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 605 | if (cfg_param_attr->flag & BEACON_INTERVAL) { |
| 606 | if (cfg_param_attr->beacon_interval > 0 && |
| 607 | cfg_param_attr->beacon_interval < 65536) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 608 | wid_list[i].id = WID_BEACON_INTERVAL; |
| 609 | wid_list[i].val = (s8 *)&cfg_param_attr->beacon_interval; |
| 610 | wid_list[i].type = WID_SHORT; |
| 611 | wid_list[i].size = sizeof(u16); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 612 | hif_drv->cfg_values.beacon_interval = cfg_param_attr->beacon_interval; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 613 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 614 | netdev_err(vif->ndev, "Beacon interval(1~65535)fail\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 615 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 616 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 617 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 618 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 619 | if (cfg_param_attr->flag & DTIM_PERIOD) { |
| 620 | if (cfg_param_attr->dtim_period > 0 && |
| 621 | cfg_param_attr->dtim_period < 256) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 622 | wid_list[i].id = WID_DTIM_PERIOD; |
| 623 | wid_list[i].val = (s8 *)&cfg_param_attr->dtim_period; |
| 624 | wid_list[i].type = WID_CHAR; |
| 625 | wid_list[i].size = sizeof(char); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 626 | hif_drv->cfg_values.dtim_period = cfg_param_attr->dtim_period; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 627 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 628 | netdev_err(vif->ndev, "DTIM range(1~255) fail\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 629 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 630 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 631 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 632 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 633 | if (cfg_param_attr->flag & SITE_SURVEY) { |
| 634 | if (cfg_param_attr->site_survey_enabled < 3) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 635 | wid_list[i].id = WID_SITE_SURVEY; |
| 636 | wid_list[i].val = (s8 *)&cfg_param_attr->site_survey_enabled; |
| 637 | wid_list[i].type = WID_CHAR; |
| 638 | wid_list[i].size = sizeof(char); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 639 | hif_drv->cfg_values.site_survey_enabled = (u8)cfg_param_attr->site_survey_enabled; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 640 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 641 | netdev_err(vif->ndev, "Site survey disable\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 642 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 643 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 644 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 645 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 646 | if (cfg_param_attr->flag & SITE_SURVEY_SCAN_TIME) { |
| 647 | if (cfg_param_attr->site_survey_scan_time > 0 && |
| 648 | cfg_param_attr->site_survey_scan_time < 65536) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 649 | wid_list[i].id = WID_SITE_SURVEY_SCAN_TIME; |
| 650 | wid_list[i].val = (s8 *)&cfg_param_attr->site_survey_scan_time; |
| 651 | wid_list[i].type = WID_SHORT; |
| 652 | wid_list[i].size = sizeof(u16); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 653 | hif_drv->cfg_values.site_survey_scan_time = cfg_param_attr->site_survey_scan_time; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 654 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 655 | netdev_err(vif->ndev, "Site scan time(1~65535) over\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 656 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 657 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 658 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 659 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 660 | if (cfg_param_attr->flag & ACTIVE_SCANTIME) { |
| 661 | if (cfg_param_attr->active_scan_time > 0 && |
| 662 | cfg_param_attr->active_scan_time < 65536) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 663 | wid_list[i].id = WID_ACTIVE_SCAN_TIME; |
| 664 | wid_list[i].val = (s8 *)&cfg_param_attr->active_scan_time; |
| 665 | wid_list[i].type = WID_SHORT; |
| 666 | wid_list[i].size = sizeof(u16); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 667 | hif_drv->cfg_values.active_scan_time = cfg_param_attr->active_scan_time; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 668 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 669 | netdev_err(vif->ndev, "Active time(1~65535) over\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 670 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 671 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 672 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 673 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 674 | if (cfg_param_attr->flag & PASSIVE_SCANTIME) { |
| 675 | if (cfg_param_attr->passive_scan_time > 0 && |
| 676 | cfg_param_attr->passive_scan_time < 65536) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 677 | wid_list[i].id = WID_PASSIVE_SCAN_TIME; |
| 678 | wid_list[i].val = (s8 *)&cfg_param_attr->passive_scan_time; |
| 679 | wid_list[i].type = WID_SHORT; |
| 680 | wid_list[i].size = sizeof(u16); |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 681 | hif_drv->cfg_values.passive_scan_time = cfg_param_attr->passive_scan_time; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 682 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 683 | netdev_err(vif->ndev, "Passive time(1~65535) over\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 684 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 685 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 686 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 687 | } |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 688 | if (cfg_param_attr->flag & CURRENT_TX_RATE) { |
| 689 | enum CURRENT_TXRATE curr_tx_rate = cfg_param_attr->curr_tx_rate; |
Leo Kim | c09389a | 2015-10-28 15:59:24 +0900 | [diff] [blame] | 690 | |
Chaehyun Lim | ae9106a | 2016-02-23 15:38:01 +0900 | [diff] [blame] | 691 | if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 || |
| 692 | curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 || |
| 693 | curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6 || |
| 694 | curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12 || |
| 695 | curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 || |
Chaehyun Lim | 940d43d | 2016-02-23 15:38:02 +0900 | [diff] [blame] | 696 | curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || |
| 697 | curr_tx_rate == MBPS_54) { |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 698 | wid_list[i].id = WID_CURRENT_TX_RATE; |
| 699 | wid_list[i].val = (s8 *)&curr_tx_rate; |
| 700 | wid_list[i].type = WID_SHORT; |
| 701 | wid_list[i].size = sizeof(u16); |
Leo Kim | ace303f | 2015-10-29 11:58:26 +0900 | [diff] [blame] | 702 | hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 703 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 704 | netdev_err(vif->ndev, "out of TX rate\n"); |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 705 | goto unlock; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 706 | } |
Chaehyun Lim | 44a4db1 | 2016-02-23 15:38:00 +0900 | [diff] [blame] | 707 | i++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 708 | } |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 709 | |
Chaehyun Lim | a1e7df4 | 2016-06-13 08:28:12 +0900 | [diff] [blame] | 710 | ret = wilc_send_config_pkt(vif, SET_CFG, wid_list, |
| 711 | i, wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 712 | |
Chaehyun Lim | a1e7df4 | 2016-06-13 08:28:12 +0900 | [diff] [blame] | 713 | if (ret) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 714 | netdev_err(vif->ndev, "Error in setting CFG params\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 715 | |
Chaehyun Lim | 960efe0 | 2016-04-04 20:04:43 +0900 | [diff] [blame] | 716 | unlock: |
Chaehyun Lim | 1f12f14 | 2016-03-08 10:04:32 +0900 | [diff] [blame] | 717 | mutex_unlock(&hif_drv->cfg_values_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 718 | } |
| 719 | |
Chaehyun Lim | 34b107e | 2016-04-04 20:04:47 +0900 | [diff] [blame] | 720 | static s32 handle_scan(struct wilc_vif *vif, struct scan_attr *scan_info) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 721 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 722 | s32 result = 0; |
Chaehyun Lim | bbff83d | 2016-04-04 20:04:48 +0900 | [diff] [blame] | 723 | struct wid wid_list[5]; |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 724 | u32 index = 0; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 725 | u32 i; |
Chaehyun Lim | 2f27ad1 | 2016-04-04 20:04:50 +0900 | [diff] [blame] | 726 | u8 *buffer; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 727 | u8 valuesize = 0; |
| 728 | u8 *pu8HdnNtwrksWidVal = NULL; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 729 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 730 | |
Chaehyun Lim | 34b107e | 2016-04-04 20:04:47 +0900 | [diff] [blame] | 731 | hif_drv->usr_scan_req.scan_result = scan_info->result; |
| 732 | hif_drv->usr_scan_req.arg = scan_info->arg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 733 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 734 | if ((hif_drv->hif_state >= HOST_IF_SCANNING) && |
| 735 | (hif_drv->hif_state < HOST_IF_CONNECTED)) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 736 | netdev_err(vif->ndev, "Already scan\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 737 | result = -EBUSY; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 738 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 739 | } |
| 740 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 741 | if (wilc_optaining_ip || wilc_connecting) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 742 | netdev_err(vif->ndev, "Don't do obss scan\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 743 | result = -EBUSY; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 744 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 745 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 746 | |
Leo Kim | f79756e | 2015-10-29 12:05:36 +0900 | [diff] [blame] | 747 | hif_drv->usr_scan_req.rcvd_ch_cnt = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 748 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 749 | wid_list[index].id = (u16)WID_SSID_PROBE_REQ; |
| 750 | wid_list[index].type = WID_STR; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 751 | |
Chaehyun Lim | 34b107e | 2016-04-04 20:04:47 +0900 | [diff] [blame] | 752 | for (i = 0; i < scan_info->hidden_network.n_ssids; i++) |
| 753 | valuesize += ((scan_info->hidden_network.net_info[i].ssid_len) + 1); |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 754 | pu8HdnNtwrksWidVal = kmalloc(valuesize + 1, GFP_KERNEL); |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 755 | wid_list[index].val = pu8HdnNtwrksWidVal; |
| 756 | if (wid_list[index].val) { |
Chaehyun Lim | 2f27ad1 | 2016-04-04 20:04:50 +0900 | [diff] [blame] | 757 | buffer = wid_list[index].val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 758 | |
Chaehyun Lim | 2f27ad1 | 2016-04-04 20:04:50 +0900 | [diff] [blame] | 759 | *buffer++ = scan_info->hidden_network.n_ssids; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 760 | |
Chaehyun Lim | 34b107e | 2016-04-04 20:04:47 +0900 | [diff] [blame] | 761 | for (i = 0; i < scan_info->hidden_network.n_ssids; i++) { |
Chaehyun Lim | 2f27ad1 | 2016-04-04 20:04:50 +0900 | [diff] [blame] | 762 | *buffer++ = scan_info->hidden_network.net_info[i].ssid_len; |
| 763 | memcpy(buffer, scan_info->hidden_network.net_info[i].ssid, scan_info->hidden_network.net_info[i].ssid_len); |
| 764 | buffer += scan_info->hidden_network.net_info[i].ssid_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 765 | } |
| 766 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 767 | wid_list[index].size = (s32)(valuesize + 1); |
| 768 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 769 | } |
| 770 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 771 | wid_list[index].id = WID_INFO_ELEMENT_PROBE; |
| 772 | wid_list[index].type = WID_BIN_DATA; |
| 773 | wid_list[index].val = scan_info->ies; |
| 774 | wid_list[index].size = scan_info->ies_len; |
| 775 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 776 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 777 | wid_list[index].id = WID_SCAN_TYPE; |
| 778 | wid_list[index].type = WID_CHAR; |
| 779 | wid_list[index].size = sizeof(char); |
| 780 | wid_list[index].val = (s8 *)&scan_info->type; |
| 781 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 782 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 783 | wid_list[index].id = WID_SCAN_CHANNEL_LIST; |
| 784 | wid_list[index].type = WID_BIN_DATA; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 785 | |
Chaehyun Lim | 34b107e | 2016-04-04 20:04:47 +0900 | [diff] [blame] | 786 | if (scan_info->ch_freq_list && |
| 787 | scan_info->ch_list_len > 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 788 | int i; |
| 789 | |
Chaehyun Lim | 34b107e | 2016-04-04 20:04:47 +0900 | [diff] [blame] | 790 | for (i = 0; i < scan_info->ch_list_len; i++) { |
| 791 | if (scan_info->ch_freq_list[i] > 0) |
| 792 | scan_info->ch_freq_list[i] = scan_info->ch_freq_list[i] - 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 793 | } |
| 794 | } |
| 795 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 796 | wid_list[index].val = scan_info->ch_freq_list; |
| 797 | wid_list[index].size = scan_info->ch_list_len; |
| 798 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 799 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 800 | wid_list[index].id = WID_START_SCAN_REQ; |
| 801 | wid_list[index].type = WID_CHAR; |
| 802 | wid_list[index].size = sizeof(char); |
| 803 | wid_list[index].val = (s8 *)&scan_info->src; |
| 804 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 805 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 806 | if (hif_drv->hif_state == HOST_IF_CONNECTED) |
Leo Kim | ca8540e4 | 2015-10-15 13:25:00 +0900 | [diff] [blame] | 807 | scan_while_connected = true; |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 808 | else if (hif_drv->hif_state == HOST_IF_IDLE) |
Leo Kim | ca8540e4 | 2015-10-15 13:25:00 +0900 | [diff] [blame] | 809 | scan_while_connected = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 810 | |
Chaehyun Lim | bbff83d | 2016-04-04 20:04:48 +0900 | [diff] [blame] | 811 | result = wilc_send_config_pkt(vif, SET_CFG, wid_list, |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 812 | index, |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 813 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 814 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 815 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 816 | netdev_err(vif->ndev, "Failed to send scan parameters\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 817 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 818 | ERRORHANDLER: |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 819 | if (result) { |
Leo Kim | 13b313e | 2015-10-29 11:58:34 +0900 | [diff] [blame] | 820 | del_timer(&hif_drv->scan_timer); |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 821 | Handle_ScanDone(vif, SCAN_EVENT_ABORTED); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 822 | } |
| 823 | |
Chaehyun Lim | 34b107e | 2016-04-04 20:04:47 +0900 | [diff] [blame] | 824 | kfree(scan_info->ch_freq_list); |
| 825 | scan_info->ch_freq_list = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 826 | |
Chaehyun Lim | 34b107e | 2016-04-04 20:04:47 +0900 | [diff] [blame] | 827 | kfree(scan_info->ies); |
| 828 | scan_info->ies = NULL; |
| 829 | kfree(scan_info->hidden_network.net_info); |
| 830 | scan_info->hidden_network.net_info = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 831 | |
Shraddha Barke | 95f840f | 2015-10-14 07:29:19 +0530 | [diff] [blame] | 832 | kfree(pu8HdnNtwrksWidVal); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 833 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 834 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 835 | } |
| 836 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 837 | static s32 Handle_ScanDone(struct wilc_vif *vif, |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 838 | enum scan_event enuEvent) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 839 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 840 | s32 result = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 841 | u8 u8abort_running_scan; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 842 | struct wid wid; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 843 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 844 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 845 | if (enuEvent == SCAN_EVENT_ABORTED) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 846 | u8abort_running_scan = 1; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 847 | wid.id = (u16)WID_ABORT_RUNNING_SCAN; |
| 848 | wid.type = WID_CHAR; |
| 849 | wid.val = (s8 *)&u8abort_running_scan; |
| 850 | wid.size = sizeof(char); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 851 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 852 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 853 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 854 | |
| 855 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 856 | netdev_err(vif->ndev, "Failed to set abort running\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 857 | result = -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 858 | } |
| 859 | } |
| 860 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 861 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 862 | netdev_err(vif->ndev, "Driver handler is NULL\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 863 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 864 | } |
| 865 | |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 866 | if (hif_drv->usr_scan_req.scan_result) { |
| 867 | hif_drv->usr_scan_req.scan_result(enuEvent, NULL, |
Leo Kim | 66eaea3 | 2015-10-29 11:58:51 +0900 | [diff] [blame] | 868 | hif_drv->usr_scan_req.arg, NULL); |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 869 | hif_drv->usr_scan_req.scan_result = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 870 | } |
| 871 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 872 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 873 | } |
| 874 | |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 875 | u8 wilc_connected_ssid[6] = {0}; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 876 | static s32 Handle_Connect(struct wilc_vif *vif, |
Tony Cho | 120ae59 | 2015-09-21 12:16:37 +0900 | [diff] [blame] | 877 | struct connect_attr *pstrHostIFconnectAttr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 878 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 879 | s32 result = 0; |
Leo Kim | e9e0c26 | 2015-10-12 16:55:41 +0900 | [diff] [blame] | 880 | struct wid strWIDList[8]; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 881 | u32 u32WidsCount = 0, dummyval = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 882 | u8 *pu8CurrByte = NULL; |
Leo Kim | e0a1221 | 2015-10-12 16:55:49 +0900 | [diff] [blame] | 883 | struct join_bss_param *ptstrJoinBssParam; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 884 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 885 | |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 886 | if (memcmp(pstrHostIFconnectAttr->bssid, wilc_connected_ssid, ETH_ALEN) == 0) { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 887 | result = 0; |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 888 | netdev_err(vif->ndev, "Discard connect request\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 889 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 890 | } |
| 891 | |
Alison Schofield | 59b97b3 | 2016-02-12 22:51:04 -0800 | [diff] [blame] | 892 | ptstrJoinBssParam = pstrHostIFconnectAttr->params; |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 893 | if (!ptstrJoinBssParam) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 894 | netdev_err(vif->ndev, "Required BSSID not found\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 895 | result = -ENOENT; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 896 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 897 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 898 | |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 899 | if (pstrHostIFconnectAttr->bssid) { |
Chaehyun Lim | 788f6fc | 2016-02-12 23:04:40 +0900 | [diff] [blame] | 900 | hif_drv->usr_conn_req.bssid = kmalloc(6, GFP_KERNEL); |
| 901 | memcpy(hif_drv->usr_conn_req.bssid, pstrHostIFconnectAttr->bssid, 6); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 902 | } |
| 903 | |
Leo Kim | 74ab5e4 | 2015-10-29 11:58:53 +0900 | [diff] [blame] | 904 | hif_drv->usr_conn_req.ssid_len = pstrHostIFconnectAttr->ssid_len; |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 905 | if (pstrHostIFconnectAttr->ssid) { |
Chaehyun Lim | 7221641 | 2016-02-12 23:04:41 +0900 | [diff] [blame] | 906 | hif_drv->usr_conn_req.ssid = kmalloc(pstrHostIFconnectAttr->ssid_len + 1, GFP_KERNEL); |
| 907 | memcpy(hif_drv->usr_conn_req.ssid, |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 908 | pstrHostIFconnectAttr->ssid, |
| 909 | pstrHostIFconnectAttr->ssid_len); |
Chaehyun Lim | 7221641 | 2016-02-12 23:04:41 +0900 | [diff] [blame] | 910 | hif_drv->usr_conn_req.ssid[pstrHostIFconnectAttr->ssid_len] = '\0'; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 911 | } |
| 912 | |
Leo Kim | 331ed08 | 2015-10-29 11:58:55 +0900 | [diff] [blame] | 913 | hif_drv->usr_conn_req.ies_len = pstrHostIFconnectAttr->ies_len; |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 914 | if (pstrHostIFconnectAttr->ies) { |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 915 | hif_drv->usr_conn_req.ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL); |
| 916 | memcpy(hif_drv->usr_conn_req.ies, |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 917 | pstrHostIFconnectAttr->ies, |
| 918 | pstrHostIFconnectAttr->ies_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 919 | } |
| 920 | |
Chaehyun Lim | a0942c5 | 2016-02-12 23:04:42 +0900 | [diff] [blame] | 921 | hif_drv->usr_conn_req.security = pstrHostIFconnectAttr->security; |
Leo Kim | 7d06972 | 2015-10-29 12:05:37 +0900 | [diff] [blame] | 922 | hif_drv->usr_conn_req.auth_type = pstrHostIFconnectAttr->auth_type; |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 923 | hif_drv->usr_conn_req.conn_result = pstrHostIFconnectAttr->result; |
Leo Kim | 73abaa4 | 2015-10-29 12:05:27 +0900 | [diff] [blame] | 924 | hif_drv->usr_conn_req.arg = pstrHostIFconnectAttr->arg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 925 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 926 | strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 927 | strWIDList[u32WidsCount].type = WID_INT; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 928 | strWIDList[u32WidsCount].size = sizeof(u32); |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 929 | strWIDList[u32WidsCount].val = (s8 *)(&(dummyval)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 930 | u32WidsCount++; |
| 931 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 932 | strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 933 | strWIDList[u32WidsCount].type = WID_INT; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 934 | strWIDList[u32WidsCount].size = sizeof(u32); |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 935 | strWIDList[u32WidsCount].val = (s8 *)(&(dummyval)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 936 | u32WidsCount++; |
| 937 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 938 | strWIDList[u32WidsCount].id = WID_FAILED_COUNT; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 939 | strWIDList[u32WidsCount].type = WID_INT; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 940 | strWIDList[u32WidsCount].size = sizeof(u32); |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 941 | strWIDList[u32WidsCount].val = (s8 *)(&(dummyval)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 942 | u32WidsCount++; |
| 943 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 944 | { |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 945 | strWIDList[u32WidsCount].id = WID_INFO_ELEMENT_ASSOCIATE; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 946 | strWIDList[u32WidsCount].type = WID_BIN_DATA; |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 947 | strWIDList[u32WidsCount].val = hif_drv->usr_conn_req.ies; |
Leo Kim | 331ed08 | 2015-10-29 11:58:55 +0900 | [diff] [blame] | 948 | strWIDList[u32WidsCount].size = hif_drv->usr_conn_req.ies_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 949 | u32WidsCount++; |
| 950 | |
Leo Kim | f7bbd9c | 2015-10-13 19:49:50 +0900 | [diff] [blame] | 951 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) { |
Leo Kim | 331ed08 | 2015-10-29 11:58:55 +0900 | [diff] [blame] | 952 | info_element_size = hif_drv->usr_conn_req.ies_len; |
Leo Kim | dfef7b8 | 2015-10-15 13:25:14 +0900 | [diff] [blame] | 953 | info_element = kmalloc(info_element_size, GFP_KERNEL); |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 954 | memcpy(info_element, hif_drv->usr_conn_req.ies, |
Leo Kim | dfef7b8 | 2015-10-15 13:25:14 +0900 | [diff] [blame] | 955 | info_element_size); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 956 | } |
| 957 | } |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 958 | strWIDList[u32WidsCount].id = (u16)WID_11I_MODE; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 959 | strWIDList[u32WidsCount].type = WID_CHAR; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 960 | strWIDList[u32WidsCount].size = sizeof(char); |
Chaehyun Lim | a0942c5 | 2016-02-12 23:04:42 +0900 | [diff] [blame] | 961 | strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.security; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 962 | u32WidsCount++; |
| 963 | |
Leo Kim | f7bbd9c | 2015-10-13 19:49:50 +0900 | [diff] [blame] | 964 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) |
Chaehyun Lim | a0942c5 | 2016-02-12 23:04:42 +0900 | [diff] [blame] | 965 | mode_11i = hif_drv->usr_conn_req.security; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 966 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 967 | strWIDList[u32WidsCount].id = (u16)WID_AUTH_TYPE; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 968 | strWIDList[u32WidsCount].type = WID_CHAR; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 969 | strWIDList[u32WidsCount].size = sizeof(char); |
Leo Kim | 7d06972 | 2015-10-29 12:05:37 +0900 | [diff] [blame] | 970 | strWIDList[u32WidsCount].val = (s8 *)&hif_drv->usr_conn_req.auth_type; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 971 | u32WidsCount++; |
| 972 | |
Leo Kim | f7bbd9c | 2015-10-13 19:49:50 +0900 | [diff] [blame] | 973 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) |
Leo Kim | 7d06972 | 2015-10-29 12:05:37 +0900 | [diff] [blame] | 974 | auth_type = (u8)hif_drv->usr_conn_req.auth_type; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 975 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 976 | strWIDList[u32WidsCount].id = (u16)WID_JOIN_REQ_EXTENDED; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 977 | strWIDList[u32WidsCount].type = WID_STR; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 978 | strWIDList[u32WidsCount].size = 112; |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 979 | strWIDList[u32WidsCount].val = kmalloc(strWIDList[u32WidsCount].size, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 980 | |
Leo Kim | f7bbd9c | 2015-10-13 19:49:50 +0900 | [diff] [blame] | 981 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) { |
Leo Kim | 0626baa | 2015-10-15 13:25:13 +0900 | [diff] [blame] | 982 | join_req_size = strWIDList[u32WidsCount].size; |
| 983 | join_req = kmalloc(join_req_size, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 984 | } |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 985 | if (!strWIDList[u32WidsCount].val) { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 986 | result = -EFAULT; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 987 | goto ERRORHANDLER; |
| 988 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 989 | |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 990 | pu8CurrByte = strWIDList[u32WidsCount].val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 991 | |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 992 | if (pstrHostIFconnectAttr->ssid) { |
Leo Kim | 8b3c9fa | 2015-10-13 19:49:51 +0900 | [diff] [blame] | 993 | memcpy(pu8CurrByte, pstrHostIFconnectAttr->ssid, pstrHostIFconnectAttr->ssid_len); |
| 994 | pu8CurrByte[pstrHostIFconnectAttr->ssid_len] = '\0'; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 995 | } |
| 996 | pu8CurrByte += MAX_SSID_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 997 | *(pu8CurrByte++) = INFRASTRUCTURE; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 998 | |
Leo Kim | 0d1527e | 2015-10-13 19:49:58 +0900 | [diff] [blame] | 999 | if ((pstrHostIFconnectAttr->ch >= 1) && (pstrHostIFconnectAttr->ch <= 14)) { |
| 1000 | *(pu8CurrByte++) = pstrHostIFconnectAttr->ch; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1001 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1002 | netdev_err(vif->ndev, "Channel out of range\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1003 | *(pu8CurrByte++) = 0xFF; |
| 1004 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1005 | *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF; |
| 1006 | *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1007 | |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1008 | if (pstrHostIFconnectAttr->bssid) |
Leo Kim | 9254db0 | 2015-10-13 19:49:49 +0900 | [diff] [blame] | 1009 | memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1010 | pu8CurrByte += 6; |
| 1011 | |
Tony Cho | c0f52fb | 2015-10-20 17:10:46 +0900 | [diff] [blame] | 1012 | if (pstrHostIFconnectAttr->bssid) |
| 1013 | memcpy(pu8CurrByte, pstrHostIFconnectAttr->bssid, 6); |
| 1014 | pu8CurrByte += 6; |
| 1015 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1016 | *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF; |
| 1017 | *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1018 | *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 1019 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1020 | memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1021 | pu8CurrByte += (MAX_RATES_SUPPORTED + 1); |
| 1022 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1023 | *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1024 | *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap; |
| 1025 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1026 | *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable; |
Leo Kim | ff06982 | 2015-10-29 12:05:26 +0900 | [diff] [blame] | 1027 | hif_drv->usr_conn_req.ht_capable = ptstrJoinBssParam->ht_capable; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1028 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1029 | *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1030 | *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1031 | *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 1032 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1033 | memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1034 | pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy); |
| 1035 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1036 | memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1037 | pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy); |
| 1038 | |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1039 | memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1040 | pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap); |
| 1041 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1042 | *(pu8CurrByte++) = REAL_JOIN_REQ; |
Leo Kim | 7a8d51d | 2015-10-15 13:24:43 +0900 | [diff] [blame] | 1043 | *(pu8CurrByte++) = ptstrJoinBssParam->noa_enabled; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1044 | |
Leo Kim | 7a8d51d | 2015-10-15 13:24:43 +0900 | [diff] [blame] | 1045 | if (ptstrJoinBssParam->noa_enabled) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1046 | *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF; |
| 1047 | *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF; |
| 1048 | *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF; |
| 1049 | *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF; |
| 1050 | |
Leo Kim | d72b33c | 2015-10-15 13:24:44 +0900 | [diff] [blame] | 1051 | *(pu8CurrByte++) = ptstrJoinBssParam->opp_enabled; |
Leo Kim | cc17900 | 2015-10-15 13:24:47 +0900 | [diff] [blame] | 1052 | *(pu8CurrByte++) = ptstrJoinBssParam->idx; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1053 | |
Leo Kim | d72b33c | 2015-10-15 13:24:44 +0900 | [diff] [blame] | 1054 | if (ptstrJoinBssParam->opp_enabled) |
Leo Kim | 99b6694 | 2015-10-15 13:24:45 +0900 | [diff] [blame] | 1055 | *(pu8CurrByte++) = ptstrJoinBssParam->ct_window; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1056 | |
Leo Kim | c21047e | 2015-10-15 13:24:46 +0900 | [diff] [blame] | 1057 | *(pu8CurrByte++) = ptstrJoinBssParam->cnt; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1058 | |
Leo Kim | 109e6ca | 2015-10-15 13:24:48 +0900 | [diff] [blame] | 1059 | memcpy(pu8CurrByte, ptstrJoinBssParam->duration, sizeof(ptstrJoinBssParam->duration)); |
| 1060 | pu8CurrByte += sizeof(ptstrJoinBssParam->duration); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1061 | |
Leo Kim | 1d8b76b | 2015-10-15 13:24:49 +0900 | [diff] [blame] | 1062 | memcpy(pu8CurrByte, ptstrJoinBssParam->interval, sizeof(ptstrJoinBssParam->interval)); |
| 1063 | pu8CurrByte += sizeof(ptstrJoinBssParam->interval); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1064 | |
Leo Kim | 4be55e2 | 2015-10-28 15:59:27 +0900 | [diff] [blame] | 1065 | memcpy(pu8CurrByte, ptstrJoinBssParam->start_time, sizeof(ptstrJoinBssParam->start_time)); |
| 1066 | pu8CurrByte += sizeof(ptstrJoinBssParam->start_time); |
Chris Park | c4f9752 | 2016-02-04 18:24:04 +0900 | [diff] [blame] | 1067 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1068 | |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 1069 | pu8CurrByte = strWIDList[u32WidsCount].val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1070 | u32WidsCount++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1071 | |
Leo Kim | f7bbd9c | 2015-10-13 19:49:50 +0900 | [diff] [blame] | 1072 | if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) { |
Leo Kim | 0626baa | 2015-10-15 13:25:13 +0900 | [diff] [blame] | 1073 | memcpy(join_req, pu8CurrByte, join_req_size); |
Glen Lee | 7036c62 | 2015-12-21 14:18:45 +0900 | [diff] [blame] | 1074 | join_req_vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1075 | } |
| 1076 | |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 1077 | if (pstrHostIFconnectAttr->bssid) |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 1078 | memcpy(wilc_connected_ssid, |
| 1079 | pstrHostIFconnectAttr->bssid, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1080 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1081 | result = wilc_send_config_pkt(vif, SET_CFG, strWIDList, |
Glen Lee | ec62e6d | 2015-11-18 15:11:33 +0900 | [diff] [blame] | 1082 | u32WidsCount, |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 1083 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1084 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1085 | netdev_err(vif->ndev, "failed to send config packet\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1086 | result = -EFAULT; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1087 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1088 | } else { |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1089 | hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1090 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1091 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1092 | ERRORHANDLER: |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1093 | if (result) { |
Chaehyun Lim | 3b0437e | 2016-02-25 09:15:42 +0900 | [diff] [blame] | 1094 | struct connect_info strConnectInfo; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1095 | |
Leo Kim | 81a5950 | 2015-10-29 11:58:35 +0900 | [diff] [blame] | 1096 | del_timer(&hif_drv->connect_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1097 | |
Chaehyun Lim | 3b0437e | 2016-02-25 09:15:42 +0900 | [diff] [blame] | 1098 | memset(&strConnectInfo, 0, sizeof(struct connect_info)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1099 | |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1100 | if (pstrHostIFconnectAttr->result) { |
| 1101 | if (pstrHostIFconnectAttr->bssid) |
Chaehyun Lim | d4a24e0 | 2016-02-25 09:15:43 +0900 | [diff] [blame] | 1102 | memcpy(strConnectInfo.bssid, pstrHostIFconnectAttr->bssid, 6); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1103 | |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1104 | if (pstrHostIFconnectAttr->ies) { |
Chaehyun Lim | 4607f9c | 2016-02-25 09:15:45 +0900 | [diff] [blame] | 1105 | strConnectInfo.req_ies_len = pstrHostIFconnectAttr->ies_len; |
Chaehyun Lim | 4ff4857 | 2016-02-25 09:15:44 +0900 | [diff] [blame] | 1106 | strConnectInfo.req_ies = kmalloc(pstrHostIFconnectAttr->ies_len, GFP_KERNEL); |
| 1107 | memcpy(strConnectInfo.req_ies, |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 1108 | pstrHostIFconnectAttr->ies, |
| 1109 | pstrHostIFconnectAttr->ies_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1110 | } |
| 1111 | |
Leo Kim | 6abcc11 | 2015-10-13 19:49:55 +0900 | [diff] [blame] | 1112 | pstrHostIFconnectAttr->result(CONN_DISCONN_EVENT_CONN_RESP, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1113 | &strConnectInfo, |
| 1114 | MAC_DISCONNECTED, |
| 1115 | NULL, |
Leo Kim | 8f38db8 | 2015-10-13 19:49:56 +0900 | [diff] [blame] | 1116 | pstrHostIFconnectAttr->arg); |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1117 | hif_drv->hif_state = HOST_IF_IDLE; |
Chaehyun Lim | 4ff4857 | 2016-02-25 09:15:44 +0900 | [diff] [blame] | 1118 | kfree(strConnectInfo.req_ies); |
| 1119 | strConnectInfo.req_ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1120 | |
| 1121 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1122 | netdev_err(vif->ndev, "Connect callback is NULL\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1123 | } |
| 1124 | } |
| 1125 | |
Shraddha Barke | 95f840f | 2015-10-14 07:29:19 +0530 | [diff] [blame] | 1126 | kfree(pstrHostIFconnectAttr->bssid); |
| 1127 | pstrHostIFconnectAttr->bssid = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1128 | |
Shraddha Barke | 95f840f | 2015-10-14 07:29:19 +0530 | [diff] [blame] | 1129 | kfree(pstrHostIFconnectAttr->ssid); |
| 1130 | pstrHostIFconnectAttr->ssid = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1131 | |
Shraddha Barke | 95f840f | 2015-10-14 07:29:19 +0530 | [diff] [blame] | 1132 | kfree(pstrHostIFconnectAttr->ies); |
| 1133 | pstrHostIFconnectAttr->ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1134 | |
Shraddha Barke | 95f840f | 2015-10-14 07:29:19 +0530 | [diff] [blame] | 1135 | kfree(pu8CurrByte); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1136 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1137 | } |
| 1138 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1139 | static s32 Handle_ConnectTimeout(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1140 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1141 | s32 result = 0; |
Chaehyun Lim | 3b0437e | 2016-02-25 09:15:42 +0900 | [diff] [blame] | 1142 | struct connect_info strConnectInfo; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1143 | struct wid wid; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 1144 | u16 u16DummyReasonCode = 0; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1145 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1146 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 1147 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1148 | netdev_err(vif->ndev, "Driver handler is NULL\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1149 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1150 | } |
| 1151 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1152 | hif_drv->hif_state = HOST_IF_IDLE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1153 | |
Leo Kim | ca8540e4 | 2015-10-15 13:25:00 +0900 | [diff] [blame] | 1154 | scan_while_connected = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1155 | |
Chaehyun Lim | 3b0437e | 2016-02-25 09:15:42 +0900 | [diff] [blame] | 1156 | memset(&strConnectInfo, 0, sizeof(struct connect_info)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1157 | |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 1158 | if (hif_drv->usr_conn_req.conn_result) { |
Chaehyun Lim | 788f6fc | 2016-02-12 23:04:40 +0900 | [diff] [blame] | 1159 | if (hif_drv->usr_conn_req.bssid) { |
Chaehyun Lim | d4a24e0 | 2016-02-25 09:15:43 +0900 | [diff] [blame] | 1160 | memcpy(strConnectInfo.bssid, |
Chaehyun Lim | 788f6fc | 2016-02-12 23:04:40 +0900 | [diff] [blame] | 1161 | hif_drv->usr_conn_req.bssid, 6); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1162 | } |
| 1163 | |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 1164 | if (hif_drv->usr_conn_req.ies) { |
Chaehyun Lim | 4607f9c | 2016-02-25 09:15:45 +0900 | [diff] [blame] | 1165 | strConnectInfo.req_ies_len = hif_drv->usr_conn_req.ies_len; |
Chaehyun Lim | 4ff4857 | 2016-02-25 09:15:44 +0900 | [diff] [blame] | 1166 | strConnectInfo.req_ies = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL); |
| 1167 | memcpy(strConnectInfo.req_ies, |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 1168 | hif_drv->usr_conn_req.ies, |
Leo Kim | 331ed08 | 2015-10-29 11:58:55 +0900 | [diff] [blame] | 1169 | hif_drv->usr_conn_req.ies_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1170 | } |
| 1171 | |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 1172 | hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP, |
| 1173 | &strConnectInfo, |
| 1174 | MAC_DISCONNECTED, |
| 1175 | NULL, |
Leo Kim | 73abaa4 | 2015-10-29 12:05:27 +0900 | [diff] [blame] | 1176 | hif_drv->usr_conn_req.arg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1177 | |
Chaehyun Lim | 4ff4857 | 2016-02-25 09:15:44 +0900 | [diff] [blame] | 1178 | kfree(strConnectInfo.req_ies); |
| 1179 | strConnectInfo.req_ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1180 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1181 | netdev_err(vif->ndev, "Connect callback is NULL\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1182 | } |
| 1183 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1184 | wid.id = (u16)WID_DISCONNECT; |
| 1185 | wid.type = WID_CHAR; |
| 1186 | wid.val = (s8 *)&u16DummyReasonCode; |
| 1187 | wid.size = sizeof(char); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1188 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1189 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1190 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1191 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1192 | netdev_err(vif->ndev, "Failed to send dissconect\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1193 | |
Leo Kim | 74ab5e4 | 2015-10-29 11:58:53 +0900 | [diff] [blame] | 1194 | hif_drv->usr_conn_req.ssid_len = 0; |
Chaehyun Lim | 7221641 | 2016-02-12 23:04:41 +0900 | [diff] [blame] | 1195 | kfree(hif_drv->usr_conn_req.ssid); |
| 1196 | hif_drv->usr_conn_req.ssid = NULL; |
Chaehyun Lim | 788f6fc | 2016-02-12 23:04:40 +0900 | [diff] [blame] | 1197 | kfree(hif_drv->usr_conn_req.bssid); |
| 1198 | hif_drv->usr_conn_req.bssid = NULL; |
Leo Kim | 331ed08 | 2015-10-29 11:58:55 +0900 | [diff] [blame] | 1199 | hif_drv->usr_conn_req.ies_len = 0; |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 1200 | kfree(hif_drv->usr_conn_req.ies); |
Glen Lee | cc28e4b | 2015-12-18 18:26:02 +0900 | [diff] [blame] | 1201 | hif_drv->usr_conn_req.ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1202 | |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 1203 | eth_zero_addr(wilc_connected_ssid); |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 1204 | |
Glen Lee | 7036c62 | 2015-12-21 14:18:45 +0900 | [diff] [blame] | 1205 | if (join_req && join_req_vif == vif) { |
Leo Kim | 044a6410 | 2015-10-15 13:25:09 +0900 | [diff] [blame] | 1206 | kfree(join_req); |
| 1207 | join_req = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1208 | } |
Leo Kim | 48ce246 | 2015-10-15 13:25:10 +0900 | [diff] [blame] | 1209 | |
Glen Lee | 7036c62 | 2015-12-21 14:18:45 +0900 | [diff] [blame] | 1210 | if (info_element && join_req_vif == vif) { |
Leo Kim | 48ce246 | 2015-10-15 13:25:10 +0900 | [diff] [blame] | 1211 | kfree(info_element); |
| 1212 | info_element = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1213 | } |
| 1214 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1215 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1216 | } |
| 1217 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1218 | static s32 Handle_RcvdNtwrkInfo(struct wilc_vif *vif, |
Tony Cho | 3bbd59f | 2015-09-21 12:16:38 +0900 | [diff] [blame] | 1219 | struct rcvd_net_info *pstrRcvdNetworkInfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1220 | { |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1221 | u32 i; |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1222 | bool bNewNtwrkFound; |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1223 | s32 result = 0; |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 1224 | struct network_info *pstrNetworkInfo = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1225 | void *pJoinParams = NULL; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1226 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1227 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 1228 | bNewNtwrkFound = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1229 | |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1230 | if (hif_drv->usr_scan_req.scan_result) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1231 | wilc_parse_network_info(pstrRcvdNetworkInfo->buffer, &pstrNetworkInfo); |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1232 | if ((!pstrNetworkInfo) || |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1233 | (!hif_drv->usr_scan_req.scan_result)) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1234 | netdev_err(vif->ndev, "driver is null\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1235 | result = -EINVAL; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1236 | goto done; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1237 | } |
| 1238 | |
Leo Kim | f79756e | 2015-10-29 12:05:36 +0900 | [diff] [blame] | 1239 | for (i = 0; i < hif_drv->usr_scan_req.rcvd_ch_cnt; i++) { |
Luis de Bethencourt | 4562d22 | 2016-06-23 18:57:09 +0100 | [diff] [blame] | 1240 | if (memcmp(hif_drv->usr_scan_req.net_info[i].bssid, |
| 1241 | pstrNetworkInfo->bssid, 6) == 0) { |
| 1242 | if (pstrNetworkInfo->rssi <= hif_drv->usr_scan_req.net_info[i].rssi) { |
| 1243 | goto done; |
| 1244 | } else { |
| 1245 | hif_drv->usr_scan_req.net_info[i].rssi = pstrNetworkInfo->rssi; |
| 1246 | bNewNtwrkFound = false; |
| 1247 | break; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1248 | } |
| 1249 | } |
| 1250 | } |
| 1251 | |
Punit Vara | 047e664 | 2015-10-25 04:01:25 +0530 | [diff] [blame] | 1252 | if (bNewNtwrkFound) { |
Leo Kim | f79756e | 2015-10-29 12:05:36 +0900 | [diff] [blame] | 1253 | if (hif_drv->usr_scan_req.rcvd_ch_cnt < MAX_NUM_SCANNED_NETWORKS) { |
Chaehyun Lim | 5cfbbf1 | 2016-02-12 23:04:39 +0900 | [diff] [blame] | 1254 | hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].rssi = pstrNetworkInfo->rssi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1255 | |
Luis de Bethencourt | 4562d22 | 2016-06-23 18:57:09 +0100 | [diff] [blame] | 1256 | memcpy(hif_drv->usr_scan_req.net_info[hif_drv->usr_scan_req.rcvd_ch_cnt].bssid, |
| 1257 | pstrNetworkInfo->bssid, 6); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1258 | |
Luis de Bethencourt | 4562d22 | 2016-06-23 18:57:09 +0100 | [diff] [blame] | 1259 | hif_drv->usr_scan_req.rcvd_ch_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1260 | |
Luis de Bethencourt | 4562d22 | 2016-06-23 18:57:09 +0100 | [diff] [blame] | 1261 | pstrNetworkInfo->new_network = true; |
| 1262 | pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1263 | |
Luis de Bethencourt | 4562d22 | 2016-06-23 18:57:09 +0100 | [diff] [blame] | 1264 | hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, |
| 1265 | hif_drv->usr_scan_req.arg, |
| 1266 | pJoinParams); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1267 | } |
| 1268 | } else { |
Leo Kim | d402076 | 2016-02-04 18:24:20 +0900 | [diff] [blame] | 1269 | pstrNetworkInfo->new_network = false; |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1270 | hif_drv->usr_scan_req.scan_result(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo, |
Leo Kim | 66eaea3 | 2015-10-29 11:58:51 +0900 | [diff] [blame] | 1271 | hif_drv->usr_scan_req.arg, NULL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1272 | } |
| 1273 | } |
| 1274 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1275 | done: |
Shraddha Barke | 95f840f | 2015-10-14 07:29:19 +0530 | [diff] [blame] | 1276 | kfree(pstrRcvdNetworkInfo->buffer); |
| 1277 | pstrRcvdNetworkInfo->buffer = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1278 | |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1279 | if (pstrNetworkInfo) { |
Leo Kim | 390b6db | 2016-02-04 18:24:23 +0900 | [diff] [blame] | 1280 | kfree(pstrNetworkInfo->ies); |
Leo Kim | d9fb23d | 2016-02-04 18:24:06 +0900 | [diff] [blame] | 1281 | kfree(pstrNetworkInfo); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1282 | } |
| 1283 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1284 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1285 | } |
| 1286 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1287 | static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 1288 | u8 *pu8AssocRespInfo, |
| 1289 | u32 u32MaxAssocRespInfoLen, |
| 1290 | u32 *pu32RcvdAssocRespInfoLen); |
| 1291 | |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 1292 | static s32 Handle_RcvdGnrlAsyncInfo(struct wilc_vif *vif, |
Tony Cho | f23a9ea | 2015-09-21 12:16:39 +0900 | [diff] [blame] | 1293 | struct rcvd_async_info *pstrRcvdGnrlAsyncInfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1294 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1295 | s32 result = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1296 | u8 u8MsgType = 0; |
| 1297 | u8 u8MsgID = 0; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 1298 | u16 u16MsgLen = 0; |
| 1299 | u16 u16WidID = (u16)WID_NIL; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1300 | u8 u8WidLen = 0; |
| 1301 | u8 u8MacStatus; |
| 1302 | u8 u8MacStatusReasonCode; |
| 1303 | u8 u8MacStatusAdditionalInfo; |
Chaehyun Lim | 3b0437e | 2016-02-25 09:15:42 +0900 | [diff] [blame] | 1304 | struct connect_info strConnectInfo; |
Chaehyun Lim | bb76df5 | 2016-02-25 09:15:49 +0900 | [diff] [blame] | 1305 | struct disconnect_info strDisconnectNotifInfo; |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1306 | s32 s32Err = 0; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1307 | struct host_if_drv *hif_drv = vif->hif_drv; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 1308 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 1309 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1310 | netdev_err(vif->ndev, "Driver handler is NULL\n"); |
Leo Kim | 234837d | 2015-09-22 14:34:43 +0900 | [diff] [blame] | 1311 | return -ENODEV; |
| 1312 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1313 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1314 | if ((hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) || |
| 1315 | (hif_drv->hif_state == HOST_IF_CONNECTED) || |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1316 | hif_drv->usr_scan_req.scan_result) { |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1317 | if (!pstrRcvdGnrlAsyncInfo->buffer || |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 1318 | !hif_drv->usr_conn_req.conn_result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1319 | netdev_err(vif->ndev, "driver is null\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1320 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1321 | } |
| 1322 | |
Leo Kim | 33722ac7 | 2015-10-13 19:50:00 +0900 | [diff] [blame] | 1323 | u8MsgType = pstrRcvdGnrlAsyncInfo->buffer[0]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1324 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1325 | if ('I' != u8MsgType) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1326 | netdev_err(vif->ndev, "Received Message incorrect.\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1327 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1328 | } |
| 1329 | |
Leo Kim | 33722ac7 | 2015-10-13 19:50:00 +0900 | [diff] [blame] | 1330 | u8MsgID = pstrRcvdGnrlAsyncInfo->buffer[1]; |
| 1331 | u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[2], pstrRcvdGnrlAsyncInfo->buffer[3]); |
| 1332 | u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->buffer[4], pstrRcvdGnrlAsyncInfo->buffer[5]); |
| 1333 | u8WidLen = pstrRcvdGnrlAsyncInfo->buffer[6]; |
| 1334 | u8MacStatus = pstrRcvdGnrlAsyncInfo->buffer[7]; |
| 1335 | u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->buffer[8]; |
| 1336 | u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->buffer[9]; |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1337 | if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) { |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1338 | u32 u32RcvdAssocRespInfoLen = 0; |
Leo Kim | 40d96e1 | 2016-02-04 18:24:08 +0900 | [diff] [blame] | 1339 | struct connect_resp_info *pstrConnectRespInfo = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1340 | |
Chaehyun Lim | 3b0437e | 2016-02-25 09:15:42 +0900 | [diff] [blame] | 1341 | memset(&strConnectInfo, 0, sizeof(struct connect_info)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1342 | |
| 1343 | if (u8MacStatus == MAC_CONNECTED) { |
Leo Kim | a633c0b | 2015-10-15 13:24:59 +0900 | [diff] [blame] | 1344 | memset(rcv_assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1345 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1346 | host_int_get_assoc_res_info(vif, |
Leo Kim | a633c0b | 2015-10-15 13:24:59 +0900 | [diff] [blame] | 1347 | rcv_assoc_resp, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1348 | MAX_ASSOC_RESP_FRAME_SIZE, |
| 1349 | &u32RcvdAssocRespInfoLen); |
| 1350 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1351 | if (u32RcvdAssocRespInfoLen != 0) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1352 | s32Err = wilc_parse_assoc_resp_info(rcv_assoc_resp, u32RcvdAssocRespInfoLen, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1353 | &pstrConnectRespInfo); |
| 1354 | if (s32Err) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1355 | netdev_err(vif->ndev, "wilc_parse_assoc_resp_info() returned error %d\n", s32Err); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1356 | } else { |
Chaehyun Lim | 134b4cf | 2016-02-25 09:15:48 +0900 | [diff] [blame] | 1357 | strConnectInfo.status = pstrConnectRespInfo->status; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1358 | |
Chaehyun Lim | 134b4cf | 2016-02-25 09:15:48 +0900 | [diff] [blame] | 1359 | if (strConnectInfo.status == SUCCESSFUL_STATUSCODE) { |
Leo Kim | ba7b6ff | 2016-02-04 18:24:09 +0900 | [diff] [blame] | 1360 | if (pstrConnectRespInfo->ies) { |
Chaehyun Lim | 3e7477c | 2016-02-25 09:15:47 +0900 | [diff] [blame] | 1361 | strConnectInfo.resp_ies_len = pstrConnectRespInfo->ies_len; |
Chaehyun Lim | 61e1326 | 2016-02-25 09:15:46 +0900 | [diff] [blame] | 1362 | strConnectInfo.resp_ies = kmalloc(pstrConnectRespInfo->ies_len, GFP_KERNEL); |
| 1363 | memcpy(strConnectInfo.resp_ies, pstrConnectRespInfo->ies, |
Leo Kim | ba7b6ff | 2016-02-04 18:24:09 +0900 | [diff] [blame] | 1364 | pstrConnectRespInfo->ies_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1365 | } |
| 1366 | } |
| 1367 | |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1368 | if (pstrConnectRespInfo) { |
Leo Kim | ba7b6ff | 2016-02-04 18:24:09 +0900 | [diff] [blame] | 1369 | kfree(pstrConnectRespInfo->ies); |
Leo Kim | 5f79c2a | 2016-02-04 18:24:07 +0900 | [diff] [blame] | 1370 | kfree(pstrConnectRespInfo); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1371 | } |
| 1372 | } |
| 1373 | } |
| 1374 | } |
| 1375 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1376 | if ((u8MacStatus == MAC_CONNECTED) && |
Chaehyun Lim | 134b4cf | 2016-02-25 09:15:48 +0900 | [diff] [blame] | 1377 | (strConnectInfo.status != SUCCESSFUL_STATUSCODE)) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1378 | netdev_err(vif->ndev, "Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE\n"); |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 1379 | eth_zero_addr(wilc_connected_ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1380 | } else if (u8MacStatus == MAC_DISCONNECTED) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1381 | netdev_err(vif->ndev, "Received MAC status is MAC_DISCONNECTED\n"); |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 1382 | eth_zero_addr(wilc_connected_ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1383 | } |
| 1384 | |
Chaehyun Lim | 788f6fc | 2016-02-12 23:04:40 +0900 | [diff] [blame] | 1385 | if (hif_drv->usr_conn_req.bssid) { |
Chaehyun Lim | d4a24e0 | 2016-02-25 09:15:43 +0900 | [diff] [blame] | 1386 | memcpy(strConnectInfo.bssid, hif_drv->usr_conn_req.bssid, 6); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1387 | |
| 1388 | if ((u8MacStatus == MAC_CONNECTED) && |
Chaehyun Lim | 134b4cf | 2016-02-25 09:15:48 +0900 | [diff] [blame] | 1389 | (strConnectInfo.status == SUCCESSFUL_STATUSCODE)) { |
Leo Kim | 2a4eded | 2015-10-29 11:58:25 +0900 | [diff] [blame] | 1390 | memcpy(hif_drv->assoc_bssid, |
Chaehyun Lim | 788f6fc | 2016-02-12 23:04:40 +0900 | [diff] [blame] | 1391 | hif_drv->usr_conn_req.bssid, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1392 | } |
| 1393 | } |
| 1394 | |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 1395 | if (hif_drv->usr_conn_req.ies) { |
Chaehyun Lim | 4607f9c | 2016-02-25 09:15:45 +0900 | [diff] [blame] | 1396 | strConnectInfo.req_ies_len = hif_drv->usr_conn_req.ies_len; |
Chaehyun Lim | 4ff4857 | 2016-02-25 09:15:44 +0900 | [diff] [blame] | 1397 | strConnectInfo.req_ies = kmalloc(hif_drv->usr_conn_req.ies_len, GFP_KERNEL); |
| 1398 | memcpy(strConnectInfo.req_ies, |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 1399 | hif_drv->usr_conn_req.ies, |
Leo Kim | 331ed08 | 2015-10-29 11:58:55 +0900 | [diff] [blame] | 1400 | hif_drv->usr_conn_req.ies_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1401 | } |
| 1402 | |
Leo Kim | 81a5950 | 2015-10-29 11:58:35 +0900 | [diff] [blame] | 1403 | del_timer(&hif_drv->connect_timer); |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 1404 | hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP, |
| 1405 | &strConnectInfo, |
| 1406 | u8MacStatus, |
| 1407 | NULL, |
Leo Kim | 73abaa4 | 2015-10-29 12:05:27 +0900 | [diff] [blame] | 1408 | hif_drv->usr_conn_req.arg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1409 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1410 | if ((u8MacStatus == MAC_CONNECTED) && |
Chaehyun Lim | 134b4cf | 2016-02-25 09:15:48 +0900 | [diff] [blame] | 1411 | (strConnectInfo.status == SUCCESSFUL_STATUSCODE)) { |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1412 | wilc_set_power_mgmt(vif, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1413 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1414 | hif_drv->hif_state = HOST_IF_CONNECTED; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1415 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1416 | wilc_optaining_ip = true; |
| 1417 | mod_timer(&wilc_during_ip_timer, |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 1418 | jiffies + msecs_to_jiffies(10000)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1419 | } else { |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1420 | hif_drv->hif_state = HOST_IF_IDLE; |
Leo Kim | ca8540e4 | 2015-10-15 13:25:00 +0900 | [diff] [blame] | 1421 | scan_while_connected = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1422 | } |
| 1423 | |
Chaehyun Lim | 61e1326 | 2016-02-25 09:15:46 +0900 | [diff] [blame] | 1424 | kfree(strConnectInfo.resp_ies); |
| 1425 | strConnectInfo.resp_ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1426 | |
Chaehyun Lim | 4ff4857 | 2016-02-25 09:15:44 +0900 | [diff] [blame] | 1427 | kfree(strConnectInfo.req_ies); |
| 1428 | strConnectInfo.req_ies = NULL; |
Leo Kim | 74ab5e4 | 2015-10-29 11:58:53 +0900 | [diff] [blame] | 1429 | hif_drv->usr_conn_req.ssid_len = 0; |
Chaehyun Lim | 7221641 | 2016-02-12 23:04:41 +0900 | [diff] [blame] | 1430 | kfree(hif_drv->usr_conn_req.ssid); |
| 1431 | hif_drv->usr_conn_req.ssid = NULL; |
Chaehyun Lim | 788f6fc | 2016-02-12 23:04:40 +0900 | [diff] [blame] | 1432 | kfree(hif_drv->usr_conn_req.bssid); |
| 1433 | hif_drv->usr_conn_req.bssid = NULL; |
Leo Kim | 331ed08 | 2015-10-29 11:58:55 +0900 | [diff] [blame] | 1434 | hif_drv->usr_conn_req.ies_len = 0; |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 1435 | kfree(hif_drv->usr_conn_req.ies); |
Glen Lee | cc28e4b | 2015-12-18 18:26:02 +0900 | [diff] [blame] | 1436 | hif_drv->usr_conn_req.ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1437 | } else if ((u8MacStatus == MAC_DISCONNECTED) && |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1438 | (hif_drv->hif_state == HOST_IF_CONNECTED)) { |
Chaehyun Lim | bb76df5 | 2016-02-25 09:15:49 +0900 | [diff] [blame] | 1439 | memset(&strDisconnectNotifInfo, 0, sizeof(struct disconnect_info)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1440 | |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1441 | if (hif_drv->usr_scan_req.scan_result) { |
Leo Kim | 13b313e | 2015-10-29 11:58:34 +0900 | [diff] [blame] | 1442 | del_timer(&hif_drv->scan_timer); |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1443 | Handle_ScanDone(vif, SCAN_EVENT_ABORTED); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1444 | } |
| 1445 | |
Chaehyun Lim | 90f209d | 2016-02-25 09:15:50 +0900 | [diff] [blame] | 1446 | strDisconnectNotifInfo.reason = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1447 | strDisconnectNotifInfo.ie = NULL; |
| 1448 | strDisconnectNotifInfo.ie_len = 0; |
| 1449 | |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 1450 | if (hif_drv->usr_conn_req.conn_result) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1451 | wilc_optaining_ip = false; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1452 | wilc_set_power_mgmt(vif, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1453 | |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 1454 | hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, |
| 1455 | NULL, |
| 1456 | 0, |
| 1457 | &strDisconnectNotifInfo, |
Leo Kim | 73abaa4 | 2015-10-29 12:05:27 +0900 | [diff] [blame] | 1458 | hif_drv->usr_conn_req.arg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1459 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1460 | netdev_err(vif->ndev, "Connect result NULL\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1461 | } |
| 1462 | |
Leo Kim | 2a4eded | 2015-10-29 11:58:25 +0900 | [diff] [blame] | 1463 | eth_zero_addr(hif_drv->assoc_bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1464 | |
Leo Kim | 74ab5e4 | 2015-10-29 11:58:53 +0900 | [diff] [blame] | 1465 | hif_drv->usr_conn_req.ssid_len = 0; |
Chaehyun Lim | 7221641 | 2016-02-12 23:04:41 +0900 | [diff] [blame] | 1466 | kfree(hif_drv->usr_conn_req.ssid); |
| 1467 | hif_drv->usr_conn_req.ssid = NULL; |
Chaehyun Lim | 788f6fc | 2016-02-12 23:04:40 +0900 | [diff] [blame] | 1468 | kfree(hif_drv->usr_conn_req.bssid); |
| 1469 | hif_drv->usr_conn_req.bssid = NULL; |
Leo Kim | 331ed08 | 2015-10-29 11:58:55 +0900 | [diff] [blame] | 1470 | hif_drv->usr_conn_req.ies_len = 0; |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 1471 | kfree(hif_drv->usr_conn_req.ies); |
Glen Lee | cc28e4b | 2015-12-18 18:26:02 +0900 | [diff] [blame] | 1472 | hif_drv->usr_conn_req.ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1473 | |
Glen Lee | 7036c62 | 2015-12-21 14:18:45 +0900 | [diff] [blame] | 1474 | if (join_req && join_req_vif == vif) { |
Leo Kim | 044a6410 | 2015-10-15 13:25:09 +0900 | [diff] [blame] | 1475 | kfree(join_req); |
| 1476 | join_req = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1477 | } |
Leo Kim | 48ce246 | 2015-10-15 13:25:10 +0900 | [diff] [blame] | 1478 | |
Glen Lee | 7036c62 | 2015-12-21 14:18:45 +0900 | [diff] [blame] | 1479 | if (info_element && join_req_vif == vif) { |
Leo Kim | 48ce246 | 2015-10-15 13:25:10 +0900 | [diff] [blame] | 1480 | kfree(info_element); |
| 1481 | info_element = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1482 | } |
| 1483 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1484 | hif_drv->hif_state = HOST_IF_IDLE; |
Leo Kim | ca8540e4 | 2015-10-15 13:25:00 +0900 | [diff] [blame] | 1485 | scan_while_connected = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1486 | |
| 1487 | } else if ((u8MacStatus == MAC_DISCONNECTED) && |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1488 | (hif_drv->usr_scan_req.scan_result)) { |
Leo Kim | 13b313e | 2015-10-29 11:58:34 +0900 | [diff] [blame] | 1489 | del_timer(&hif_drv->scan_timer); |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1490 | if (hif_drv->usr_scan_req.scan_result) |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1491 | Handle_ScanDone(vif, SCAN_EVENT_ABORTED); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1492 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1493 | } |
| 1494 | |
Shraddha Barke | 95f840f | 2015-10-14 07:29:19 +0530 | [diff] [blame] | 1495 | kfree(pstrRcvdGnrlAsyncInfo->buffer); |
| 1496 | pstrRcvdGnrlAsyncInfo->buffer = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1497 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1498 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1499 | } |
| 1500 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1501 | static int Handle_Key(struct wilc_vif *vif, |
Tony Cho | c98387a | 2015-09-21 12:16:40 +0900 | [diff] [blame] | 1502 | struct key_attr *pstrHostIFkeyAttr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1503 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1504 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1505 | struct wid wid; |
Leo Kim | e9e0c26 | 2015-10-12 16:55:41 +0900 | [diff] [blame] | 1506 | struct wid strWIDList[5]; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1507 | u8 i; |
| 1508 | u8 *pu8keybuf; |
Chaehyun Lim | ca356ad | 2015-06-11 14:35:57 +0900 | [diff] [blame] | 1509 | s8 s8idxarray[1]; |
| 1510 | s8 ret = 0; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1511 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1512 | |
Leo Kim | 8e9f427 | 2015-10-13 19:49:27 +0900 | [diff] [blame] | 1513 | switch (pstrHostIFkeyAttr->type) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1514 | case WEP: |
| 1515 | |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 1516 | if (pstrHostIFkeyAttr->action & ADDKEY_AP) { |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1517 | strWIDList[0].id = (u16)WID_11I_MODE; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1518 | strWIDList[0].type = WID_CHAR; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1519 | strWIDList[0].size = sizeof(char); |
Leo Kim | bafaa69 | 2015-10-28 15:59:21 +0900 | [diff] [blame] | 1520 | strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.mode; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1521 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1522 | strWIDList[1].id = WID_AUTH_TYPE; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1523 | strWIDList[1].type = WID_CHAR; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1524 | strWIDList[1].size = sizeof(char); |
Leo Kim | bafaa69 | 2015-10-28 15:59:21 +0900 | [diff] [blame] | 1525 | strWIDList[1].val = (s8 *)&pstrHostIFkeyAttr->attr.wep.auth_type; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1526 | |
Glen Lee | ec45048 | 2016-02-04 18:15:28 +0900 | [diff] [blame] | 1527 | pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, |
Shraddha Barke | 543f5b1 | 2015-10-16 10:47:11 +0530 | [diff] [blame] | 1528 | GFP_KERNEL); |
Chris Park | 77f3a71 | 2016-02-22 13:12:01 +0900 | [diff] [blame] | 1529 | if (!pu8keybuf) |
Luis de Bethencourt | 9081987 | 2015-10-26 05:52:50 +0000 | [diff] [blame] | 1530 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1531 | |
Glen Lee | ec45048 | 2016-02-04 18:15:28 +0900 | [diff] [blame] | 1532 | pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index; |
| 1533 | pu8keybuf[1] = pstrHostIFkeyAttr->attr.wep.key_len; |
| 1534 | |
| 1535 | memcpy(&pu8keybuf[2], pstrHostIFkeyAttr->attr.wep.key, |
| 1536 | pstrHostIFkeyAttr->attr.wep.key_len); |
| 1537 | |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 1538 | kfree(pstrHostIFkeyAttr->attr.wep.key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1539 | |
Glen Lee | ec45048 | 2016-02-04 18:15:28 +0900 | [diff] [blame] | 1540 | strWIDList[2].id = (u16)WID_WEP_KEY_VALUE; |
| 1541 | strWIDList[2].type = WID_STR; |
| 1542 | strWIDList[2].size = pstrHostIFkeyAttr->attr.wep.key_len + 2; |
| 1543 | strWIDList[2].val = (s8 *)pu8keybuf; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1544 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1545 | result = wilc_send_config_pkt(vif, SET_CFG, |
Glen Lee | ec45048 | 2016-02-04 18:15:28 +0900 | [diff] [blame] | 1546 | strWIDList, 3, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1547 | wilc_get_vif_idx(vif)); |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1548 | kfree(pu8keybuf); |
Leo Kim | 9edaa5f | 2015-11-25 11:59:48 +0900 | [diff] [blame] | 1549 | } else if (pstrHostIFkeyAttr->action & ADDKEY) { |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 1550 | pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len + 2, GFP_KERNEL); |
Chris Park | 77f3a71 | 2016-02-22 13:12:01 +0900 | [diff] [blame] | 1551 | if (!pu8keybuf) |
Luis de Bethencourt | 9081987 | 2015-10-26 05:52:50 +0000 | [diff] [blame] | 1552 | return -ENOMEM; |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 1553 | pu8keybuf[0] = pstrHostIFkeyAttr->attr.wep.index; |
| 1554 | memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->attr.wep.key_len, 1); |
| 1555 | memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->attr.wep.key, |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 1556 | pstrHostIFkeyAttr->attr.wep.key_len); |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 1557 | kfree(pstrHostIFkeyAttr->attr.wep.key); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1558 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1559 | wid.id = (u16)WID_ADD_WEP_KEY; |
| 1560 | wid.type = WID_STR; |
| 1561 | wid.val = (s8 *)pu8keybuf; |
| 1562 | wid.size = pstrHostIFkeyAttr->attr.wep.key_len + 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1563 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1564 | result = wilc_send_config_pkt(vif, SET_CFG, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1565 | &wid, 1, |
| 1566 | wilc_get_vif_idx(vif)); |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1567 | kfree(pu8keybuf); |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 1568 | } else if (pstrHostIFkeyAttr->action & REMOVEKEY) { |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1569 | wid.id = (u16)WID_REMOVE_WEP_KEY; |
| 1570 | wid.type = WID_STR; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1571 | |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 1572 | s8idxarray[0] = (s8)pstrHostIFkeyAttr->attr.wep.index; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1573 | wid.val = s8idxarray; |
| 1574 | wid.size = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1575 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1576 | result = wilc_send_config_pkt(vif, SET_CFG, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1577 | &wid, 1, |
| 1578 | wilc_get_vif_idx(vif)); |
Glen Lee | ec45048 | 2016-02-04 18:15:28 +0900 | [diff] [blame] | 1579 | } else if (pstrHostIFkeyAttr->action & DEFAULTKEY) { |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1580 | wid.id = (u16)WID_KEY_ID; |
| 1581 | wid.type = WID_CHAR; |
| 1582 | wid.val = (s8 *)&pstrHostIFkeyAttr->attr.wep.index; |
| 1583 | wid.size = sizeof(char); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1584 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1585 | result = wilc_send_config_pkt(vif, SET_CFG, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1586 | &wid, 1, |
| 1587 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1588 | } |
Alison Schofield | 702962f | 2016-03-14 10:35:41 -0700 | [diff] [blame] | 1589 | complete(&hif_drv->comp_test_key_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1590 | break; |
| 1591 | |
Leo Kim | 5cd8f7a | 2015-10-29 12:05:34 +0900 | [diff] [blame] | 1592 | case WPA_RX_GTK: |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 1593 | if (pstrHostIFkeyAttr->action & ADDKEY_AP) { |
Shraddha Barke | b156f1e | 2015-10-13 23:07:00 +0530 | [diff] [blame] | 1594 | pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1595 | if (!pu8keybuf) { |
Luis de Bethencourt | 9081987 | 2015-10-26 05:52:50 +0000 | [diff] [blame] | 1596 | ret = -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1597 | goto _WPARxGtk_end_case_; |
| 1598 | } |
| 1599 | |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1600 | if (pstrHostIFkeyAttr->attr.wpa.seq) |
Leo Kim | 0e74c00 | 2015-10-13 19:49:32 +0900 | [diff] [blame] | 1601 | memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1602 | |
Leo Kim | e2dfbac | 2015-10-13 19:49:34 +0900 | [diff] [blame] | 1603 | memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1); |
Leo Kim | 6acf291 | 2015-10-13 19:49:35 +0900 | [diff] [blame] | 1604 | memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1); |
Leo Kim | 124968fc | 2015-10-13 19:49:30 +0900 | [diff] [blame] | 1605 | memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key, |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 1606 | pstrHostIFkeyAttr->attr.wpa.key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1607 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1608 | strWIDList[0].id = (u16)WID_11I_MODE; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1609 | strWIDList[0].type = WID_CHAR; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1610 | strWIDList[0].size = sizeof(char); |
Leo Kim | bafaa69 | 2015-10-28 15:59:21 +0900 | [diff] [blame] | 1611 | strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1612 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1613 | strWIDList[1].id = (u16)WID_ADD_RX_GTK; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1614 | strWIDList[1].type = WID_STR; |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 1615 | strWIDList[1].val = (s8 *)pu8keybuf; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1616 | strWIDList[1].size = RX_MIC_KEY_MSG_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1617 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1618 | result = wilc_send_config_pkt(vif, SET_CFG, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1619 | strWIDList, 2, |
| 1620 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1621 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1622 | kfree(pu8keybuf); |
Alison Schofield | 702962f | 2016-03-14 10:35:41 -0700 | [diff] [blame] | 1623 | complete(&hif_drv->comp_test_key_block); |
Leo Kim | 9edaa5f | 2015-11-25 11:59:48 +0900 | [diff] [blame] | 1624 | } else if (pstrHostIFkeyAttr->action & ADDKEY) { |
Shraddha Barke | b156f1e | 2015-10-13 23:07:00 +0530 | [diff] [blame] | 1625 | pu8keybuf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); |
Roger H. Newell | b59958e | 2016-03-19 12:50:52 -0230 | [diff] [blame] | 1626 | if (!pu8keybuf) { |
Luis de Bethencourt | 9081987 | 2015-10-26 05:52:50 +0000 | [diff] [blame] | 1627 | ret = -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1628 | goto _WPARxGtk_end_case_; |
| 1629 | } |
| 1630 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1631 | if (hif_drv->hif_state == HOST_IF_CONNECTED) |
Leo Kim | 2a4eded | 2015-10-29 11:58:25 +0900 | [diff] [blame] | 1632 | memcpy(pu8keybuf, hif_drv->assoc_bssid, ETH_ALEN); |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 1633 | else |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1634 | netdev_err(vif->ndev, "Couldn't handle\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1635 | |
Leo Kim | 0e74c00 | 2015-10-13 19:49:32 +0900 | [diff] [blame] | 1636 | memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->attr.wpa.seq, 8); |
Leo Kim | e2dfbac | 2015-10-13 19:49:34 +0900 | [diff] [blame] | 1637 | memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->attr.wpa.index, 1); |
Leo Kim | 6acf291 | 2015-10-13 19:49:35 +0900 | [diff] [blame] | 1638 | memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->attr.wpa.key_len, 1); |
Leo Kim | 124968fc | 2015-10-13 19:49:30 +0900 | [diff] [blame] | 1639 | memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->attr.wpa.key, |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 1640 | pstrHostIFkeyAttr->attr.wpa.key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1641 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1642 | wid.id = (u16)WID_ADD_RX_GTK; |
| 1643 | wid.type = WID_STR; |
| 1644 | wid.val = (s8 *)pu8keybuf; |
| 1645 | wid.size = RX_MIC_KEY_MSG_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1646 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1647 | result = wilc_send_config_pkt(vif, SET_CFG, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1648 | &wid, 1, |
| 1649 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1650 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1651 | kfree(pu8keybuf); |
Alison Schofield | 702962f | 2016-03-14 10:35:41 -0700 | [diff] [blame] | 1652 | complete(&hif_drv->comp_test_key_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1653 | } |
| 1654 | _WPARxGtk_end_case_: |
Leo Kim | 124968fc | 2015-10-13 19:49:30 +0900 | [diff] [blame] | 1655 | kfree(pstrHostIFkeyAttr->attr.wpa.key); |
Leo Kim | 0e74c00 | 2015-10-13 19:49:32 +0900 | [diff] [blame] | 1656 | kfree(pstrHostIFkeyAttr->attr.wpa.seq); |
Luis de Bethencourt | 9081987 | 2015-10-26 05:52:50 +0000 | [diff] [blame] | 1657 | if (ret) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1658 | return ret; |
| 1659 | |
| 1660 | break; |
| 1661 | |
Leo Kim | 2141fe3 | 2015-10-29 12:05:35 +0900 | [diff] [blame] | 1662 | case WPA_PTK: |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 1663 | if (pstrHostIFkeyAttr->action & ADDKEY_AP) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1664 | pu8keybuf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL); |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1665 | if (!pu8keybuf) { |
Luis de Bethencourt | 9081987 | 2015-10-26 05:52:50 +0000 | [diff] [blame] | 1666 | ret = -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1667 | goto _WPAPtk_end_case_; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1668 | } |
| 1669 | |
Leo Kim | 248080a | 2015-10-13 19:49:31 +0900 | [diff] [blame] | 1670 | memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6); |
Leo Kim | e2dfbac | 2015-10-13 19:49:34 +0900 | [diff] [blame] | 1671 | memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.index, 1); |
Leo Kim | 6acf291 | 2015-10-13 19:49:35 +0900 | [diff] [blame] | 1672 | memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->attr.wpa.key_len, 1); |
Leo Kim | 124968fc | 2015-10-13 19:49:30 +0900 | [diff] [blame] | 1673 | memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->attr.wpa.key, |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 1674 | pstrHostIFkeyAttr->attr.wpa.key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1675 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1676 | strWIDList[0].id = (u16)WID_11I_MODE; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1677 | strWIDList[0].type = WID_CHAR; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1678 | strWIDList[0].size = sizeof(char); |
Leo Kim | bafaa69 | 2015-10-28 15:59:21 +0900 | [diff] [blame] | 1679 | strWIDList[0].val = (s8 *)&pstrHostIFkeyAttr->attr.wpa.mode; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1680 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1681 | strWIDList[1].id = (u16)WID_ADD_PTK; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1682 | strWIDList[1].type = WID_STR; |
Leo Kim | 900bb4a | 2015-10-12 16:55:46 +0900 | [diff] [blame] | 1683 | strWIDList[1].val = (s8 *)pu8keybuf; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1684 | strWIDList[1].size = PTK_KEY_MSG_LEN + 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1685 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1686 | result = wilc_send_config_pkt(vif, SET_CFG, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1687 | strWIDList, 2, |
| 1688 | wilc_get_vif_idx(vif)); |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1689 | kfree(pu8keybuf); |
Alison Schofield | 702962f | 2016-03-14 10:35:41 -0700 | [diff] [blame] | 1690 | complete(&hif_drv->comp_test_key_block); |
Leo Kim | 9edaa5f | 2015-11-25 11:59:48 +0900 | [diff] [blame] | 1691 | } else if (pstrHostIFkeyAttr->action & ADDKEY) { |
Glen Lee | f305258 | 2015-09-10 12:03:04 +0900 | [diff] [blame] | 1692 | pu8keybuf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL); |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1693 | if (!pu8keybuf) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1694 | netdev_err(vif->ndev, "No buffer send PTK\n"); |
Luis de Bethencourt | 9081987 | 2015-10-26 05:52:50 +0000 | [diff] [blame] | 1695 | ret = -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1696 | goto _WPAPtk_end_case_; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1697 | } |
| 1698 | |
Leo Kim | 248080a | 2015-10-13 19:49:31 +0900 | [diff] [blame] | 1699 | memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wpa.mac_addr, 6); |
Leo Kim | 6acf291 | 2015-10-13 19:49:35 +0900 | [diff] [blame] | 1700 | memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->attr.wpa.key_len, 1); |
Leo Kim | 124968fc | 2015-10-13 19:49:30 +0900 | [diff] [blame] | 1701 | memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->attr.wpa.key, |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 1702 | pstrHostIFkeyAttr->attr.wpa.key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1703 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1704 | wid.id = (u16)WID_ADD_PTK; |
| 1705 | wid.type = WID_STR; |
| 1706 | wid.val = (s8 *)pu8keybuf; |
| 1707 | wid.size = PTK_KEY_MSG_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1708 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1709 | result = wilc_send_config_pkt(vif, SET_CFG, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1710 | &wid, 1, |
| 1711 | wilc_get_vif_idx(vif)); |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1712 | kfree(pu8keybuf); |
Alison Schofield | 702962f | 2016-03-14 10:35:41 -0700 | [diff] [blame] | 1713 | complete(&hif_drv->comp_test_key_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1714 | } |
| 1715 | |
| 1716 | _WPAPtk_end_case_: |
Leo Kim | 124968fc | 2015-10-13 19:49:30 +0900 | [diff] [blame] | 1717 | kfree(pstrHostIFkeyAttr->attr.wpa.key); |
Luis de Bethencourt | 9081987 | 2015-10-26 05:52:50 +0000 | [diff] [blame] | 1718 | if (ret) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1719 | return ret; |
| 1720 | |
| 1721 | break; |
| 1722 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1723 | case PMKSA: |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 1724 | pu8keybuf = kmalloc((pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, GFP_KERNEL); |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1725 | if (!pu8keybuf) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1726 | netdev_err(vif->ndev, "No buffer to send PMKSA Key\n"); |
Luis de Bethencourt | 9081987 | 2015-10-26 05:52:50 +0000 | [diff] [blame] | 1727 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1728 | } |
| 1729 | |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 1730 | pu8keybuf[0] = pstrHostIFkeyAttr->attr.pmkid.numpmkid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1731 | |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 1732 | for (i = 0; i < pstrHostIFkeyAttr->attr.pmkid.numpmkid; i++) { |
| 1733 | memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN); |
| 1734 | memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1735 | } |
| 1736 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1737 | wid.id = (u16)WID_PMKID_INFO; |
| 1738 | wid.type = WID_STR; |
| 1739 | wid.val = (s8 *)pu8keybuf; |
| 1740 | wid.size = (pstrHostIFkeyAttr->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1741 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1742 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1743 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1744 | |
Chaehyun Lim | 49188af | 2015-08-11 10:32:41 +0900 | [diff] [blame] | 1745 | kfree(pu8keybuf); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1746 | break; |
| 1747 | } |
| 1748 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1749 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1750 | netdev_err(vif->ndev, "Failed to send key config packet\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1751 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1752 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1753 | } |
| 1754 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1755 | static void Handle_Disconnect(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1756 | { |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1757 | struct wid wid; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1758 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1759 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1760 | s32 result = 0; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 1761 | u16 u16DummyReasonCode = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1762 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1763 | wid.id = (u16)WID_DISCONNECT; |
| 1764 | wid.type = WID_CHAR; |
| 1765 | wid.val = (s8 *)&u16DummyReasonCode; |
| 1766 | wid.size = sizeof(char); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1767 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1768 | wilc_optaining_ip = false; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1769 | wilc_set_power_mgmt(vif, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1770 | |
Leo Kim | e554a30 | 2015-11-19 15:56:21 +0900 | [diff] [blame] | 1771 | eth_zero_addr(wilc_connected_ssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1772 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1773 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1774 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1775 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1776 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1777 | netdev_err(vif->ndev, "Failed to send dissconect\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1778 | } else { |
Chaehyun Lim | bb76df5 | 2016-02-25 09:15:49 +0900 | [diff] [blame] | 1779 | struct disconnect_info strDisconnectNotifInfo; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1780 | |
Chaehyun Lim | bb76df5 | 2016-02-25 09:15:49 +0900 | [diff] [blame] | 1781 | memset(&strDisconnectNotifInfo, 0, sizeof(struct disconnect_info)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1782 | |
Chaehyun Lim | 90f209d | 2016-02-25 09:15:50 +0900 | [diff] [blame] | 1783 | strDisconnectNotifInfo.reason = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1784 | strDisconnectNotifInfo.ie = NULL; |
| 1785 | strDisconnectNotifInfo.ie_len = 0; |
| 1786 | |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1787 | if (hif_drv->usr_scan_req.scan_result) { |
Leo Kim | 13b313e | 2015-10-29 11:58:34 +0900 | [diff] [blame] | 1788 | del_timer(&hif_drv->scan_timer); |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 1789 | hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, |
| 1790 | NULL, |
| 1791 | hif_drv->usr_scan_req.arg, |
| 1792 | NULL); |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1793 | hif_drv->usr_scan_req.scan_result = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1794 | } |
| 1795 | |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 1796 | if (hif_drv->usr_conn_req.conn_result) { |
Chris Park | c4f9752 | 2016-02-04 18:24:04 +0900 | [diff] [blame] | 1797 | if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) |
Leo Kim | 81a5950 | 2015-10-29 11:58:35 +0900 | [diff] [blame] | 1798 | del_timer(&hif_drv->connect_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1799 | |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 1800 | hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, |
| 1801 | NULL, |
| 1802 | 0, |
| 1803 | &strDisconnectNotifInfo, |
Leo Kim | 73abaa4 | 2015-10-29 12:05:27 +0900 | [diff] [blame] | 1804 | hif_drv->usr_conn_req.arg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1805 | } else { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1806 | netdev_err(vif->ndev, "conn_result = NULL\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1807 | } |
| 1808 | |
Leo Kim | ca8540e4 | 2015-10-15 13:25:00 +0900 | [diff] [blame] | 1809 | scan_while_connected = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1810 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1811 | hif_drv->hif_state = HOST_IF_IDLE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1812 | |
Leo Kim | 2a4eded | 2015-10-29 11:58:25 +0900 | [diff] [blame] | 1813 | eth_zero_addr(hif_drv->assoc_bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1814 | |
Leo Kim | 74ab5e4 | 2015-10-29 11:58:53 +0900 | [diff] [blame] | 1815 | hif_drv->usr_conn_req.ssid_len = 0; |
Chaehyun Lim | 7221641 | 2016-02-12 23:04:41 +0900 | [diff] [blame] | 1816 | kfree(hif_drv->usr_conn_req.ssid); |
| 1817 | hif_drv->usr_conn_req.ssid = NULL; |
Chaehyun Lim | 788f6fc | 2016-02-12 23:04:40 +0900 | [diff] [blame] | 1818 | kfree(hif_drv->usr_conn_req.bssid); |
| 1819 | hif_drv->usr_conn_req.bssid = NULL; |
Leo Kim | 331ed08 | 2015-10-29 11:58:55 +0900 | [diff] [blame] | 1820 | hif_drv->usr_conn_req.ies_len = 0; |
Leo Kim | a3b2f4b | 2015-10-29 11:58:54 +0900 | [diff] [blame] | 1821 | kfree(hif_drv->usr_conn_req.ies); |
Glen Lee | cc28e4b | 2015-12-18 18:26:02 +0900 | [diff] [blame] | 1822 | hif_drv->usr_conn_req.ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1823 | |
Glen Lee | 7036c62 | 2015-12-21 14:18:45 +0900 | [diff] [blame] | 1824 | if (join_req && join_req_vif == vif) { |
Leo Kim | 044a6410 | 2015-10-15 13:25:09 +0900 | [diff] [blame] | 1825 | kfree(join_req); |
| 1826 | join_req = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1827 | } |
Leo Kim | 48ce246 | 2015-10-15 13:25:10 +0900 | [diff] [blame] | 1828 | |
Glen Lee | 7036c62 | 2015-12-21 14:18:45 +0900 | [diff] [blame] | 1829 | if (info_element && join_req_vif == vif) { |
Leo Kim | 48ce246 | 2015-10-15 13:25:10 +0900 | [diff] [blame] | 1830 | kfree(info_element); |
| 1831 | info_element = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1832 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1833 | } |
| 1834 | |
Alison Schofield | 96adbd2 | 2016-03-14 10:35:05 -0700 | [diff] [blame] | 1835 | complete(&hif_drv->comp_test_disconn_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1836 | } |
| 1837 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1838 | void wilc_resolve_disconnect_aberration(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1839 | { |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1840 | if (!vif->hif_drv) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1841 | return; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1842 | if ((vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) || |
Chris Park | c4f9752 | 2016-02-04 18:24:04 +0900 | [diff] [blame] | 1843 | (vif->hif_drv->hif_state == HOST_IF_CONNECTING)) |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1844 | wilc_disconnect(vif, 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1845 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1846 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1847 | static void Handle_GetRssi(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1848 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1849 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1850 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1851 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1852 | wid.id = (u16)WID_RSSI; |
| 1853 | wid.type = WID_CHAR; |
| 1854 | wid.val = &rssi; |
| 1855 | wid.size = sizeof(char); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1856 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1857 | result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1858 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1859 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1860 | netdev_err(vif->ndev, "Failed to get RSSI value\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1861 | result = -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1862 | } |
| 1863 | |
Alison Schofield | 7c8a3dc | 2016-03-14 10:34:39 -0700 | [diff] [blame] | 1864 | complete(&vif->hif_drv->comp_get_rssi); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1865 | } |
| 1866 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1867 | static s32 Handle_GetStatistics(struct wilc_vif *vif, |
| 1868 | struct rf_info *pstrStatistics) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1869 | { |
Leo Kim | e9e0c26 | 2015-10-12 16:55:41 +0900 | [diff] [blame] | 1870 | struct wid strWIDList[5]; |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1871 | u32 u32WidsCount = 0, result = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1872 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1873 | strWIDList[u32WidsCount].id = WID_LINKSPEED; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1874 | strWIDList[u32WidsCount].type = WID_CHAR; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1875 | strWIDList[u32WidsCount].size = sizeof(char); |
Leo Kim | 5babeec | 2015-10-29 12:05:29 +0900 | [diff] [blame] | 1876 | strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->link_speed; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1877 | u32WidsCount++; |
| 1878 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1879 | strWIDList[u32WidsCount].id = WID_RSSI; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1880 | strWIDList[u32WidsCount].type = WID_CHAR; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1881 | strWIDList[u32WidsCount].size = sizeof(char); |
Leo Kim | 00c8dfc | 2015-10-29 12:05:30 +0900 | [diff] [blame] | 1882 | strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rssi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1883 | u32WidsCount++; |
| 1884 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1885 | strWIDList[u32WidsCount].id = WID_SUCCESS_FRAME_COUNT; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1886 | strWIDList[u32WidsCount].type = WID_INT; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1887 | strWIDList[u32WidsCount].size = sizeof(u32); |
Leo Kim | 7e84ff4 | 2015-10-29 12:05:31 +0900 | [diff] [blame] | 1888 | strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_cnt; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1889 | u32WidsCount++; |
| 1890 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1891 | strWIDList[u32WidsCount].id = WID_RECEIVED_FRAGMENT_COUNT; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1892 | strWIDList[u32WidsCount].type = WID_INT; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1893 | strWIDList[u32WidsCount].size = sizeof(u32); |
Leo Kim | 9b99274 | 2015-10-29 12:05:32 +0900 | [diff] [blame] | 1894 | strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->rx_cnt; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1895 | u32WidsCount++; |
| 1896 | |
Leo Kim | daaf16b | 2015-10-12 16:55:44 +0900 | [diff] [blame] | 1897 | strWIDList[u32WidsCount].id = WID_FAILED_COUNT; |
Leo Kim | 416d832 | 2015-10-12 16:55:43 +0900 | [diff] [blame] | 1898 | strWIDList[u32WidsCount].type = WID_INT; |
Leo Kim | 2fd3e44 | 2015-10-12 16:55:45 +0900 | [diff] [blame] | 1899 | strWIDList[u32WidsCount].size = sizeof(u32); |
Leo Kim | 5416037 | 2015-10-29 12:05:33 +0900 | [diff] [blame] | 1900 | strWIDList[u32WidsCount].val = (s8 *)&pstrStatistics->tx_fail_cnt; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1901 | u32WidsCount++; |
| 1902 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1903 | result = wilc_send_config_pkt(vif, GET_CFG, strWIDList, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1904 | u32WidsCount, |
| 1905 | wilc_get_vif_idx(vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1906 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1907 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1908 | netdev_err(vif->ndev, "Failed to send scan parameters\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1909 | |
Glen Lee | 4fd6229 | 2016-02-04 18:15:24 +0900 | [diff] [blame] | 1910 | if (pstrStatistics->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH && |
| 1911 | pstrStatistics->link_speed != DEFAULT_LINK_SPEED) |
| 1912 | wilc_enable_tcp_ack_filter(true); |
| 1913 | else if (pstrStatistics->link_speed != DEFAULT_LINK_SPEED) |
| 1914 | wilc_enable_tcp_ack_filter(false); |
| 1915 | |
| 1916 | if (pstrStatistics != &vif->wilc->dummy_statistics) |
Chaehyun Lim | 613eaa3 | 2016-03-14 09:40:27 +0900 | [diff] [blame] | 1917 | complete(&hif_wait_response); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1918 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1919 | } |
| 1920 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1921 | static s32 Handle_Get_InActiveTime(struct wilc_vif *vif, |
Tony Cho | 3d1eac0 | 2015-09-21 12:16:49 +0900 | [diff] [blame] | 1922 | struct sta_inactive_t *strHostIfStaInactiveT) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1923 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1924 | s32 result = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1925 | u8 *stamac; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1926 | struct wid wid; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1927 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1928 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1929 | wid.id = (u16)WID_SET_STA_MAC_INACTIVE_TIME; |
| 1930 | wid.type = WID_STR; |
| 1931 | wid.size = ETH_ALEN; |
| 1932 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1933 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1934 | stamac = wid.val; |
Chaehyun Lim | d00d2ba | 2015-08-10 11:33:19 +0900 | [diff] [blame] | 1935 | memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1936 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1937 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1938 | wilc_get_vif_idx(vif)); |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 1939 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1940 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1941 | netdev_err(vif->ndev, "Failed to SET incative time\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1942 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1943 | } |
| 1944 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1945 | wid.id = (u16)WID_GET_INACTIVE_TIME; |
| 1946 | wid.type = WID_INT; |
| 1947 | wid.val = (s8 *)&inactive_time; |
| 1948 | wid.size = sizeof(u32); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1949 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 1950 | result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 1951 | wilc_get_vif_idx(vif)); |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 1952 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1953 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1954 | netdev_err(vif->ndev, "Failed to get incative time\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1955 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1956 | } |
| 1957 | |
Alison Schofield | e0c1496 | 2016-03-14 10:34:14 -0700 | [diff] [blame] | 1958 | complete(&hif_drv->comp_inactive_time); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1959 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1960 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1961 | } |
| 1962 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1963 | static void Handle_AddBeacon(struct wilc_vif *vif, |
Tony Cho | 7f33fec | 2015-09-30 18:44:30 +0900 | [diff] [blame] | 1964 | struct beacon_attr *pstrSetBeaconParam) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1965 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1966 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1967 | struct wid wid; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1968 | u8 *pu8CurrByte; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 1969 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1970 | wid.id = (u16)WID_ADD_BEACON; |
| 1971 | wid.type = WID_BIN; |
| 1972 | wid.size = pstrSetBeaconParam->head_len + pstrSetBeaconParam->tail_len + 16; |
| 1973 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
| 1974 | if (!wid.val) |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1975 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1976 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 1977 | pu8CurrByte = wid.val; |
Leo Kim | 12262dd | 2015-10-13 19:50:03 +0900 | [diff] [blame] | 1978 | *pu8CurrByte++ = (pstrSetBeaconParam->interval & 0xFF); |
| 1979 | *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 8) & 0xFF); |
| 1980 | *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 16) & 0xFF); |
| 1981 | *pu8CurrByte++ = ((pstrSetBeaconParam->interval >> 24) & 0xFF); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1982 | |
Leo Kim | e76ab77 | 2015-10-13 19:50:04 +0900 | [diff] [blame] | 1983 | *pu8CurrByte++ = (pstrSetBeaconParam->dtim_period & 0xFF); |
| 1984 | *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 8) & 0xFF); |
| 1985 | *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 16) & 0xFF); |
| 1986 | *pu8CurrByte++ = ((pstrSetBeaconParam->dtim_period >> 24) & 0xFF); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1987 | |
Leo Kim | 51c6618 | 2015-10-13 19:50:05 +0900 | [diff] [blame] | 1988 | *pu8CurrByte++ = (pstrSetBeaconParam->head_len & 0xFF); |
| 1989 | *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 8) & 0xFF); |
| 1990 | *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 16) & 0xFF); |
| 1991 | *pu8CurrByte++ = ((pstrSetBeaconParam->head_len >> 24) & 0xFF); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1992 | |
Leo Kim | 8ce528b | 2015-10-13 19:50:06 +0900 | [diff] [blame] | 1993 | memcpy(pu8CurrByte, pstrSetBeaconParam->head, pstrSetBeaconParam->head_len); |
Leo Kim | 51c6618 | 2015-10-13 19:50:05 +0900 | [diff] [blame] | 1994 | pu8CurrByte += pstrSetBeaconParam->head_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1995 | |
Leo Kim | 030c57e | 2015-10-13 19:50:07 +0900 | [diff] [blame] | 1996 | *pu8CurrByte++ = (pstrSetBeaconParam->tail_len & 0xFF); |
| 1997 | *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 8) & 0xFF); |
| 1998 | *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 16) & 0xFF); |
| 1999 | *pu8CurrByte++ = ((pstrSetBeaconParam->tail_len >> 24) & 0xFF); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2000 | |
Mario J. Rugiero | 7cf8e59 | 2015-12-03 13:24:05 -0300 | [diff] [blame] | 2001 | if (pstrSetBeaconParam->tail) |
Leo Kim | 7dbcb6d3 | 2015-10-13 19:50:08 +0900 | [diff] [blame] | 2002 | memcpy(pu8CurrByte, pstrSetBeaconParam->tail, pstrSetBeaconParam->tail_len); |
Leo Kim | 030c57e | 2015-10-13 19:50:07 +0900 | [diff] [blame] | 2003 | pu8CurrByte += pstrSetBeaconParam->tail_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2004 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2005 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
| 2006 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2007 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2008 | netdev_err(vif->ndev, "Failed to send add beacon\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2009 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2010 | ERRORHANDLER: |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2011 | kfree(wid.val); |
Leo Kim | 8ce528b | 2015-10-13 19:50:06 +0900 | [diff] [blame] | 2012 | kfree(pstrSetBeaconParam->head); |
Leo Kim | 7dbcb6d3 | 2015-10-13 19:50:08 +0900 | [diff] [blame] | 2013 | kfree(pstrSetBeaconParam->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2014 | } |
| 2015 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2016 | static void Handle_DelBeacon(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2017 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2018 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2019 | struct wid wid; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2020 | u8 *pu8CurrByte; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 2021 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2022 | wid.id = (u16)WID_DEL_BEACON; |
| 2023 | wid.type = WID_CHAR; |
| 2024 | wid.size = sizeof(char); |
| 2025 | wid.val = &del_beacon; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2026 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2027 | if (!wid.val) |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2028 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2029 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2030 | pu8CurrByte = wid.val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2031 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2032 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2033 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2034 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2035 | netdev_err(vif->ndev, "Failed to send delete beacon\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2036 | } |
| 2037 | |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 2038 | static u32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, |
| 2039 | struct add_sta_param *pstrStationParam) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2040 | { |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2041 | u8 *pu8CurrByte; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2042 | |
| 2043 | pu8CurrByte = pu8Buffer; |
| 2044 | |
Leo Kim | 2353c38 | 2015-10-29 12:05:41 +0900 | [diff] [blame] | 2045 | memcpy(pu8CurrByte, pstrStationParam->bssid, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2046 | pu8CurrByte += ETH_ALEN; |
| 2047 | |
Leo Kim | 4101eb8 | 2015-10-29 12:05:42 +0900 | [diff] [blame] | 2048 | *pu8CurrByte++ = pstrStationParam->aid & 0xFF; |
| 2049 | *pu8CurrByte++ = (pstrStationParam->aid >> 8) & 0xFF; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2050 | |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2051 | *pu8CurrByte++ = pstrStationParam->rates_len; |
| 2052 | if (pstrStationParam->rates_len > 0) |
Leo Kim | a622e01 | 2015-10-29 12:05:44 +0900 | [diff] [blame] | 2053 | memcpy(pu8CurrByte, pstrStationParam->rates, |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2054 | pstrStationParam->rates_len); |
| 2055 | pu8CurrByte += pstrStationParam->rates_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2056 | |
Leo Kim | 2252012 | 2015-10-29 12:05:45 +0900 | [diff] [blame] | 2057 | *pu8CurrByte++ = pstrStationParam->ht_supported; |
Leo Kim | 0d073f6 | 2015-10-29 12:05:46 +0900 | [diff] [blame] | 2058 | *pu8CurrByte++ = pstrStationParam->ht_capa_info & 0xFF; |
| 2059 | *pu8CurrByte++ = (pstrStationParam->ht_capa_info >> 8) & 0xFF; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2060 | |
Leo Kim | fba1f2d | 2015-10-29 12:05:47 +0900 | [diff] [blame] | 2061 | *pu8CurrByte++ = pstrStationParam->ht_ampdu_params; |
Leo Kim | 5ebbf4f | 2015-10-29 12:05:48 +0900 | [diff] [blame] | 2062 | memcpy(pu8CurrByte, pstrStationParam->ht_supp_mcs_set, |
| 2063 | WILC_SUPP_MCS_SET_SIZE); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2064 | pu8CurrByte += WILC_SUPP_MCS_SET_SIZE; |
| 2065 | |
Leo Kim | 223741d | 2015-10-29 12:05:49 +0900 | [diff] [blame] | 2066 | *pu8CurrByte++ = pstrStationParam->ht_ext_params & 0xFF; |
| 2067 | *pu8CurrByte++ = (pstrStationParam->ht_ext_params >> 8) & 0xFF; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2068 | |
Leo Kim | 74fe73c | 2015-10-29 12:05:50 +0900 | [diff] [blame] | 2069 | *pu8CurrByte++ = pstrStationParam->ht_tx_bf_cap & 0xFF; |
| 2070 | *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 8) & 0xFF; |
| 2071 | *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 16) & 0xFF; |
| 2072 | *pu8CurrByte++ = (pstrStationParam->ht_tx_bf_cap >> 24) & 0xFF; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2073 | |
Leo Kim | a486baf | 2015-10-29 12:05:51 +0900 | [diff] [blame] | 2074 | *pu8CurrByte++ = pstrStationParam->ht_ante_sel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2075 | |
Leo Kim | f676e17 | 2015-10-29 12:05:52 +0900 | [diff] [blame] | 2076 | *pu8CurrByte++ = pstrStationParam->flags_mask & 0xFF; |
| 2077 | *pu8CurrByte++ = (pstrStationParam->flags_mask >> 8) & 0xFF; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2078 | |
Leo Kim | 67ab64e | 2015-10-29 12:05:53 +0900 | [diff] [blame] | 2079 | *pu8CurrByte++ = pstrStationParam->flags_set & 0xFF; |
| 2080 | *pu8CurrByte++ = (pstrStationParam->flags_set >> 8) & 0xFF; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2081 | |
| 2082 | return pu8CurrByte - pu8Buffer; |
| 2083 | } |
| 2084 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2085 | static void Handle_AddStation(struct wilc_vif *vif, |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 2086 | struct add_sta_param *pstrStationParam) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2087 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2088 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2089 | struct wid wid; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2090 | u8 *pu8CurrByte; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 2091 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2092 | wid.id = (u16)WID_ADD_STA; |
| 2093 | wid.type = WID_BIN; |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2094 | wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2095 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2096 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
| 2097 | if (!wid.val) |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2098 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2099 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2100 | pu8CurrByte = wid.val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2101 | pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); |
| 2102 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2103 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2104 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2105 | if (result != 0) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2106 | netdev_err(vif->ndev, "Failed to send add station\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2107 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2108 | ERRORHANDLER: |
Leo Kim | a622e01 | 2015-10-29 12:05:44 +0900 | [diff] [blame] | 2109 | kfree(pstrStationParam->rates); |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2110 | kfree(wid.val); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2111 | } |
| 2112 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2113 | static void Handle_DelAllSta(struct wilc_vif *vif, |
Tony Cho | b4e644e | 2015-09-21 12:17:00 +0900 | [diff] [blame] | 2114 | struct del_all_sta *pstrDelAllStaParam) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2115 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2116 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2117 | struct wid wid; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2118 | u8 *pu8CurrByte; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2119 | u8 i; |
Chaehyun Lim | 3703480 | 2015-06-11 14:34:32 +0900 | [diff] [blame] | 2120 | u8 au8Zero_Buff[6] = {0}; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 2121 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2122 | wid.id = (u16)WID_DEL_ALL_STA; |
| 2123 | wid.type = WID_STR; |
| 2124 | wid.size = (pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2125 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2126 | wid.val = kmalloc((pstrDelAllStaParam->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL); |
| 2127 | if (!wid.val) |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2128 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2129 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2130 | pu8CurrByte = wid.val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2131 | |
Leo Kim | 8ba1803 | 2015-10-13 19:50:10 +0900 | [diff] [blame] | 2132 | *(pu8CurrByte++) = pstrDelAllStaParam->assoc_sta; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2133 | |
| 2134 | for (i = 0; i < MAX_NUM_STA; i++) { |
Leo Kim | e51b921 | 2015-10-13 19:50:09 +0900 | [diff] [blame] | 2135 | if (memcmp(pstrDelAllStaParam->del_all_sta[i], au8Zero_Buff, ETH_ALEN)) |
| 2136 | memcpy(pu8CurrByte, pstrDelAllStaParam->del_all_sta[i], ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2137 | else |
| 2138 | continue; |
| 2139 | |
| 2140 | pu8CurrByte += ETH_ALEN; |
| 2141 | } |
| 2142 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2143 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2144 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2145 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2146 | netdev_err(vif->ndev, "Failed to send add station\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2147 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2148 | ERRORHANDLER: |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2149 | kfree(wid.val); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2150 | |
Chaehyun Lim | 613eaa3 | 2016-03-14 09:40:27 +0900 | [diff] [blame] | 2151 | complete(&hif_wait_response); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2152 | } |
| 2153 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2154 | static void Handle_DelStation(struct wilc_vif *vif, |
Tony Cho | fb93a1e | 2015-09-21 12:16:57 +0900 | [diff] [blame] | 2155 | struct del_sta *pstrDelStaParam) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2156 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2157 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2158 | struct wid wid; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2159 | u8 *pu8CurrByte; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2160 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2161 | wid.id = (u16)WID_REMOVE_STA; |
| 2162 | wid.type = WID_BIN; |
| 2163 | wid.size = ETH_ALEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2164 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2165 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
| 2166 | if (!wid.val) |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2167 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2168 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2169 | pu8CurrByte = wid.val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2170 | |
Leo Kim | e4839d3 | 2015-10-13 20:02:06 +0900 | [diff] [blame] | 2171 | memcpy(pu8CurrByte, pstrDelStaParam->mac_addr, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2172 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2173 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2174 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2175 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2176 | netdev_err(vif->ndev, "Failed to send add station\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2177 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2178 | ERRORHANDLER: |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2179 | kfree(wid.val); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2180 | } |
| 2181 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2182 | static void Handle_EditStation(struct wilc_vif *vif, |
Tony Cho | 6a89ba9 | 2015-09-21 12:16:46 +0900 | [diff] [blame] | 2183 | struct add_sta_param *pstrStationParam) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2184 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2185 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2186 | struct wid wid; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2187 | u8 *pu8CurrByte; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2188 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2189 | wid.id = (u16)WID_EDIT_STA; |
| 2190 | wid.type = WID_BIN; |
Leo Kim | e734223 | 2015-10-29 12:05:43 +0900 | [diff] [blame] | 2191 | wid.size = WILC_ADD_STA_LENGTH + pstrStationParam->rates_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2192 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2193 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
| 2194 | if (!wid.val) |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2195 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2196 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2197 | pu8CurrByte = wid.val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2198 | pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam); |
| 2199 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2200 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2201 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2202 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2203 | netdev_err(vif->ndev, "Failed to send edit station\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2204 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2205 | ERRORHANDLER: |
Leo Kim | a622e01 | 2015-10-29 12:05:44 +0900 | [diff] [blame] | 2206 | kfree(pstrStationParam->rates); |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2207 | kfree(wid.val); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2208 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2209 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2210 | static int Handle_RemainOnChan(struct wilc_vif *vif, |
Tony Cho | 2f9c03f | 2015-09-21 12:16:58 +0900 | [diff] [blame] | 2211 | struct remain_ch *pstrHostIfRemainOnChan) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2212 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2213 | s32 result = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2214 | u8 u8remain_on_chan_flag; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2215 | struct wid wid; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2216 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2217 | |
Leo Kim | 5beef2c | 2015-10-28 15:59:36 +0900 | [diff] [blame] | 2218 | if (!hif_drv->remain_on_ch_pending) { |
Leo Kim | c5cc4b1 | 2015-10-29 11:58:44 +0900 | [diff] [blame] | 2219 | hif_drv->remain_on_ch.arg = pstrHostIfRemainOnChan->arg; |
Leo Kim | bfb62ab | 2015-10-29 11:58:42 +0900 | [diff] [blame] | 2220 | hif_drv->remain_on_ch.expired = pstrHostIfRemainOnChan->expired; |
Leo Kim | 5e5f791 | 2015-10-29 11:58:43 +0900 | [diff] [blame] | 2221 | hif_drv->remain_on_ch.ready = pstrHostIfRemainOnChan->ready; |
Leo Kim | 839ab70 | 2015-10-29 11:58:41 +0900 | [diff] [blame] | 2222 | hif_drv->remain_on_ch.ch = pstrHostIfRemainOnChan->ch; |
Leo Kim | 9d764e3 | 2015-10-29 12:05:38 +0900 | [diff] [blame] | 2223 | hif_drv->remain_on_ch.id = pstrHostIfRemainOnChan->id; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2224 | } else { |
Leo Kim | 839ab70 | 2015-10-29 11:58:41 +0900 | [diff] [blame] | 2225 | pstrHostIfRemainOnChan->ch = hif_drv->remain_on_ch.ch; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2226 | } |
| 2227 | |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 2228 | if (hif_drv->usr_scan_req.scan_result) { |
Leo Kim | 5beef2c | 2015-10-28 15:59:36 +0900 | [diff] [blame] | 2229 | hif_drv->remain_on_ch_pending = 1; |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2230 | result = -EBUSY; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2231 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2232 | } |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 2233 | if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2234 | result = -EBUSY; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2235 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2236 | } |
| 2237 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2238 | if (wilc_optaining_ip || wilc_connecting) { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2239 | result = -EBUSY; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2240 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2241 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2242 | |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2243 | u8remain_on_chan_flag = true; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2244 | wid.id = (u16)WID_REMAIN_ON_CHAN; |
| 2245 | wid.type = WID_STR; |
| 2246 | wid.size = 2; |
| 2247 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
| 2248 | if (!wid.val) { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2249 | result = -ENOMEM; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2250 | goto ERRORHANDLER; |
| 2251 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2252 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2253 | wid.val[0] = u8remain_on_chan_flag; |
Leo Kim | 839ab70 | 2015-10-29 11:58:41 +0900 | [diff] [blame] | 2254 | wid.val[1] = (s8)pstrHostIfRemainOnChan->ch; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2255 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2256 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2257 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2258 | if (result != 0) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2259 | netdev_err(vif->ndev, "Failed to set remain on channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2260 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2261 | ERRORHANDLER: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2262 | { |
| 2263 | P2P_LISTEN_STATE = 1; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2264 | hif_drv->remain_on_ch_timer.data = (unsigned long)vif; |
Leo Kim | cc2d7e9 | 2015-10-29 11:58:36 +0900 | [diff] [blame] | 2265 | mod_timer(&hif_drv->remain_on_ch_timer, |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 2266 | jiffies + |
Chaehyun Lim | fb6e068 | 2016-01-03 17:35:33 +0900 | [diff] [blame] | 2267 | msecs_to_jiffies(pstrHostIfRemainOnChan->duration)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2268 | |
Leo Kim | 5e5f791 | 2015-10-29 11:58:43 +0900 | [diff] [blame] | 2269 | if (hif_drv->remain_on_ch.ready) |
Leo Kim | c5cc4b1 | 2015-10-29 11:58:44 +0900 | [diff] [blame] | 2270 | hif_drv->remain_on_ch.ready(hif_drv->remain_on_ch.arg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2271 | |
Leo Kim | 5beef2c | 2015-10-28 15:59:36 +0900 | [diff] [blame] | 2272 | if (hif_drv->remain_on_ch_pending) |
| 2273 | hif_drv->remain_on_ch_pending = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2274 | } |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2275 | |
| 2276 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2277 | } |
| 2278 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2279 | static int Handle_RegisterFrame(struct wilc_vif *vif, |
Tony Cho | bc37c5d | 2015-09-21 12:16:59 +0900 | [diff] [blame] | 2280 | struct reg_frame *pstrHostIfRegisterFrame) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2281 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2282 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2283 | struct wid wid; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2284 | u8 *pu8CurrByte; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2285 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2286 | wid.id = (u16)WID_REGISTER_FRAME; |
| 2287 | wid.type = WID_STR; |
| 2288 | wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL); |
| 2289 | if (!wid.val) |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2290 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2291 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2292 | pu8CurrByte = wid.val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2293 | |
Leo Kim | 6abf868 | 2015-10-29 11:58:38 +0900 | [diff] [blame] | 2294 | *pu8CurrByte++ = pstrHostIfRegisterFrame->reg; |
Leo Kim | bcb410b | 2015-10-29 11:58:40 +0900 | [diff] [blame] | 2295 | *pu8CurrByte++ = pstrHostIfRegisterFrame->reg_id; |
Leo Kim | d5f654c | 2015-10-29 11:58:39 +0900 | [diff] [blame] | 2296 | memcpy(pu8CurrByte, &pstrHostIfRegisterFrame->frame_type, sizeof(u16)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2297 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2298 | wid.size = sizeof(u16) + 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2299 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2300 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2301 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2302 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2303 | netdev_err(vif->ndev, "Failed to frame register\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2304 | result = -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2305 | } |
| 2306 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2307 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2308 | } |
| 2309 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2310 | static u32 Handle_ListenStateExpired(struct wilc_vif *vif, |
Tony Cho | 2f9c03f | 2015-09-21 12:16:58 +0900 | [diff] [blame] | 2311 | struct remain_ch *pstrHostIfRemainOnChan) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2312 | { |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2313 | u8 u8remain_on_chan_flag; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2314 | struct wid wid; |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2315 | s32 result = 0; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2316 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2317 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2318 | if (P2P_LISTEN_STATE) { |
Dean Lee | 72ed4dc | 2015-06-12 14:11:44 +0900 | [diff] [blame] | 2319 | u8remain_on_chan_flag = false; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2320 | wid.id = (u16)WID_REMAIN_ON_CHAN; |
| 2321 | wid.type = WID_STR; |
| 2322 | wid.size = 2; |
| 2323 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2324 | |
Leo Kim | 653bb46 | 2015-12-21 14:18:24 +0900 | [diff] [blame] | 2325 | if (!wid.val) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2326 | netdev_err(vif->ndev, "Failed to allocate memory\n"); |
Leo Kim | 653bb46 | 2015-12-21 14:18:24 +0900 | [diff] [blame] | 2327 | return -ENOMEM; |
| 2328 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2329 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2330 | wid.val[0] = u8remain_on_chan_flag; |
| 2331 | wid.val[1] = FALSE_FRMWR_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2332 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2333 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2334 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2335 | if (result != 0) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2336 | netdev_err(vif->ndev, "Failed to set remain channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2337 | goto _done_; |
| 2338 | } |
| 2339 | |
Leo Kim | bfb62ab | 2015-10-29 11:58:42 +0900 | [diff] [blame] | 2340 | if (hif_drv->remain_on_ch.expired) { |
Leo Kim | c5cc4b1 | 2015-10-29 11:58:44 +0900 | [diff] [blame] | 2341 | hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg, |
Leo Kim | 9d764e3 | 2015-10-29 12:05:38 +0900 | [diff] [blame] | 2342 | pstrHostIfRemainOnChan->id); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2343 | } |
| 2344 | P2P_LISTEN_STATE = 0; |
| 2345 | } else { |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 2346 | netdev_dbg(vif->ndev, "Not in listen state\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2347 | result = -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2348 | } |
| 2349 | |
| 2350 | _done_: |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2351 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2352 | } |
| 2353 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 2354 | static void ListenTimerCB(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2355 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2356 | s32 result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2357 | struct host_if_msg msg; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2358 | struct wilc_vif *vif = (struct wilc_vif *)arg; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 2359 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2360 | del_timer(&vif->hif_drv->remain_on_ch_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2361 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2362 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2363 | msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2364 | msg.vif = vif; |
| 2365 | msg.body.remain_on_ch.id = vif->hif_drv->remain_on_ch.id; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2366 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2367 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2368 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2369 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2370 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2371 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2372 | static void Handle_PowerManagement(struct wilc_vif *vif, |
Tony Cho | 5a008f1 | 2015-09-21 12:16:48 +0900 | [diff] [blame] | 2373 | struct power_mgmt_param *strPowerMgmtParam) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2374 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2375 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2376 | struct wid wid; |
Chaehyun Lim | ca356ad | 2015-06-11 14:35:57 +0900 | [diff] [blame] | 2377 | s8 s8PowerMode; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 2378 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2379 | wid.id = (u16)WID_POWER_MANAGEMENT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2380 | |
Punit Vara | 047e664 | 2015-10-25 04:01:25 +0530 | [diff] [blame] | 2381 | if (strPowerMgmtParam->enabled) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2382 | s8PowerMode = MIN_FAST_PS; |
Chandra S Gorentla | 78174ad | 2015-08-08 17:41:36 +0530 | [diff] [blame] | 2383 | else |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2384 | s8PowerMode = NO_POWERSAVE; |
Chris Park | c4f9752 | 2016-02-04 18:24:04 +0900 | [diff] [blame] | 2385 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2386 | wid.val = &s8PowerMode; |
| 2387 | wid.size = sizeof(char); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2388 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2389 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2390 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2391 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2392 | netdev_err(vif->ndev, "Failed to send power management\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2393 | } |
| 2394 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2395 | static void Handle_SetMulticastFilter(struct wilc_vif *vif, |
Tony Cho | 641210a | 2015-09-21 12:16:52 +0900 | [diff] [blame] | 2396 | struct set_multicast *strHostIfSetMulti) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2397 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2398 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2399 | struct wid wid; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 2400 | u8 *pu8CurrByte; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2401 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2402 | wid.id = (u16)WID_SETUP_MULTICAST_FILTER; |
| 2403 | wid.type = WID_BIN; |
| 2404 | wid.size = sizeof(struct set_multicast) + ((strHostIfSetMulti->cnt) * ETH_ALEN); |
| 2405 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
| 2406 | if (!wid.val) |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2407 | goto ERRORHANDLER; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2408 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2409 | pu8CurrByte = wid.val; |
Leo Kim | bae636eb | 2015-10-13 20:02:04 +0900 | [diff] [blame] | 2410 | *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF); |
Leo Kim | c8751ad | 2015-11-25 11:59:49 +0900 | [diff] [blame] | 2411 | *pu8CurrByte++ = 0; |
| 2412 | *pu8CurrByte++ = 0; |
| 2413 | *pu8CurrByte++ = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2414 | |
Leo Kim | adab2f7 | 2015-10-13 20:02:05 +0900 | [diff] [blame] | 2415 | *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF); |
| 2416 | *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF); |
| 2417 | *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 16) & 0xFF); |
| 2418 | *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 24) & 0xFF); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2419 | |
Leo Kim | adab2f7 | 2015-10-13 20:02:05 +0900 | [diff] [blame] | 2420 | if ((strHostIfSetMulti->cnt) > 0) |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2421 | memcpy(pu8CurrByte, wilc_multicast_mac_addr_list, |
Leo Kim | fb70e9f | 2015-11-05 14:36:09 +0900 | [diff] [blame] | 2422 | ((strHostIfSetMulti->cnt) * ETH_ALEN)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2423 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2424 | result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 2425 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2426 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2427 | netdev_err(vif->ndev, "Failed to send setup multicast\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2428 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2429 | ERRORHANDLER: |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2430 | kfree(wid.val); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2431 | } |
| 2432 | |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 2433 | static void handle_set_tx_pwr(struct wilc_vif *vif, u8 tx_pwr) |
| 2434 | { |
| 2435 | int ret; |
| 2436 | struct wid wid; |
| 2437 | |
| 2438 | wid.id = (u16)WID_TX_POWER; |
| 2439 | wid.type = WID_CHAR; |
| 2440 | wid.val = &tx_pwr; |
| 2441 | wid.size = sizeof(char); |
| 2442 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2443 | ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, |
| 2444 | wilc_get_vif_idx(vif)); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 2445 | if (ret) |
| 2446 | netdev_err(vif->ndev, "Failed to set TX PWR\n"); |
| 2447 | } |
| 2448 | |
| 2449 | static void handle_get_tx_pwr(struct wilc_vif *vif, u8 *tx_pwr) |
| 2450 | { |
Chaehyun Lim | 12915c5 | 2016-04-07 08:10:37 +0900 | [diff] [blame] | 2451 | int ret = 0; |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 2452 | struct wid wid; |
| 2453 | |
| 2454 | wid.id = (u16)WID_TX_POWER; |
| 2455 | wid.type = WID_CHAR; |
| 2456 | wid.val = (s8 *)tx_pwr; |
| 2457 | wid.size = sizeof(char); |
| 2458 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 2459 | ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, |
| 2460 | wilc_get_vif_idx(vif)); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 2461 | if (ret) |
| 2462 | netdev_err(vif->ndev, "Failed to get TX PWR\n"); |
| 2463 | |
Chaehyun Lim | 613eaa3 | 2016-03-14 09:40:27 +0900 | [diff] [blame] | 2464 | complete(&hif_wait_response); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 2465 | } |
| 2466 | |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 2467 | static void host_if_work(struct work_struct *work) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2468 | { |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 2469 | struct host_if_msg *msg; |
| 2470 | struct wilc *wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2471 | |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 2472 | msg = container_of(work, struct host_if_msg, work); |
| 2473 | wilc = msg->vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2474 | |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 2475 | if (msg->id == HOST_IF_MSG_CONNECT && |
| 2476 | msg->vif->hif_drv->usr_scan_req.scan_result) { |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2477 | wilc_enqueue_cmd(msg); |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 2478 | usleep_range(2 * 1000, 2 * 1000); |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2479 | goto free_msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2480 | } |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2481 | switch (msg->id) { |
| 2482 | case HOST_IF_MSG_SCAN: |
| 2483 | handle_scan(msg->vif, &msg->body.scan_info); |
| 2484 | break; |
| 2485 | |
| 2486 | case HOST_IF_MSG_CONNECT: |
| 2487 | Handle_Connect(msg->vif, &msg->body.con_info); |
| 2488 | break; |
| 2489 | |
| 2490 | case HOST_IF_MSG_RCVD_NTWRK_INFO: |
| 2491 | Handle_RcvdNtwrkInfo(msg->vif, &msg->body.net_info); |
| 2492 | break; |
| 2493 | |
| 2494 | case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO: |
| 2495 | Handle_RcvdGnrlAsyncInfo(msg->vif, |
| 2496 | &msg->body.async_info); |
| 2497 | break; |
| 2498 | |
| 2499 | case HOST_IF_MSG_KEY: |
| 2500 | Handle_Key(msg->vif, &msg->body.key_info); |
| 2501 | break; |
| 2502 | |
| 2503 | case HOST_IF_MSG_CFG_PARAMS: |
| 2504 | handle_cfg_param(msg->vif, &msg->body.cfg_info); |
| 2505 | break; |
| 2506 | |
| 2507 | case HOST_IF_MSG_SET_CHANNEL: |
| 2508 | handle_set_channel(msg->vif, &msg->body.channel_info); |
| 2509 | break; |
| 2510 | |
| 2511 | case HOST_IF_MSG_DISCONNECT: |
| 2512 | Handle_Disconnect(msg->vif); |
| 2513 | break; |
| 2514 | |
| 2515 | case HOST_IF_MSG_RCVD_SCAN_COMPLETE: |
| 2516 | del_timer(&msg->vif->hif_drv->scan_timer); |
| 2517 | |
| 2518 | if (!wilc_wlan_get_num_conn_ifcs(wilc)) |
| 2519 | wilc_chip_sleep_manually(wilc); |
| 2520 | |
| 2521 | Handle_ScanDone(msg->vif, SCAN_EVENT_DONE); |
| 2522 | |
| 2523 | if (msg->vif->hif_drv->remain_on_ch_pending) |
| 2524 | Handle_RemainOnChan(msg->vif, |
| 2525 | &msg->body.remain_on_ch); |
| 2526 | |
| 2527 | break; |
| 2528 | |
| 2529 | case HOST_IF_MSG_GET_RSSI: |
| 2530 | Handle_GetRssi(msg->vif); |
| 2531 | break; |
| 2532 | |
| 2533 | case HOST_IF_MSG_GET_STATISTICS: |
| 2534 | Handle_GetStatistics(msg->vif, |
| 2535 | (struct rf_info *)msg->body.data); |
| 2536 | break; |
| 2537 | |
| 2538 | case HOST_IF_MSG_ADD_BEACON: |
| 2539 | Handle_AddBeacon(msg->vif, &msg->body.beacon_info); |
| 2540 | break; |
| 2541 | |
| 2542 | case HOST_IF_MSG_DEL_BEACON: |
| 2543 | Handle_DelBeacon(msg->vif); |
| 2544 | break; |
| 2545 | |
| 2546 | case HOST_IF_MSG_ADD_STATION: |
| 2547 | Handle_AddStation(msg->vif, &msg->body.add_sta_info); |
| 2548 | break; |
| 2549 | |
| 2550 | case HOST_IF_MSG_DEL_STATION: |
| 2551 | Handle_DelStation(msg->vif, &msg->body.del_sta_info); |
| 2552 | break; |
| 2553 | |
| 2554 | case HOST_IF_MSG_EDIT_STATION: |
| 2555 | Handle_EditStation(msg->vif, &msg->body.edit_sta_info); |
| 2556 | break; |
| 2557 | |
| 2558 | case HOST_IF_MSG_GET_INACTIVETIME: |
| 2559 | Handle_Get_InActiveTime(msg->vif, &msg->body.mac_info); |
| 2560 | break; |
| 2561 | |
| 2562 | case HOST_IF_MSG_SCAN_TIMER_FIRED: |
| 2563 | Handle_ScanDone(msg->vif, SCAN_EVENT_ABORTED); |
| 2564 | break; |
| 2565 | |
| 2566 | case HOST_IF_MSG_CONNECT_TIMER_FIRED: |
| 2567 | Handle_ConnectTimeout(msg->vif); |
| 2568 | break; |
| 2569 | |
| 2570 | case HOST_IF_MSG_POWER_MGMT: |
| 2571 | Handle_PowerManagement(msg->vif, |
| 2572 | &msg->body.pwr_mgmt_info); |
| 2573 | break; |
| 2574 | |
| 2575 | case HOST_IF_MSG_SET_WFIDRV_HANDLER: |
| 2576 | handle_set_wfi_drv_handler(msg->vif, &msg->body.drv); |
| 2577 | break; |
| 2578 | |
| 2579 | case HOST_IF_MSG_SET_OPERATION_MODE: |
| 2580 | handle_set_operation_mode(msg->vif, &msg->body.mode); |
| 2581 | break; |
| 2582 | |
| 2583 | case HOST_IF_MSG_SET_IPADDRESS: |
| 2584 | handle_set_ip_address(msg->vif, |
| 2585 | msg->body.ip_info.ip_addr, |
| 2586 | msg->body.ip_info.idx); |
| 2587 | break; |
| 2588 | |
| 2589 | case HOST_IF_MSG_GET_IPADDRESS: |
| 2590 | handle_get_ip_address(msg->vif, msg->body.ip_info.idx); |
| 2591 | break; |
| 2592 | |
| 2593 | case HOST_IF_MSG_GET_MAC_ADDRESS: |
| 2594 | handle_get_mac_address(msg->vif, |
| 2595 | &msg->body.get_mac_info); |
| 2596 | break; |
| 2597 | |
| 2598 | case HOST_IF_MSG_REMAIN_ON_CHAN: |
| 2599 | Handle_RemainOnChan(msg->vif, &msg->body.remain_on_ch); |
| 2600 | break; |
| 2601 | |
| 2602 | case HOST_IF_MSG_REGISTER_FRAME: |
| 2603 | Handle_RegisterFrame(msg->vif, &msg->body.reg_frame); |
| 2604 | break; |
| 2605 | |
| 2606 | case HOST_IF_MSG_LISTEN_TIMER_FIRED: |
| 2607 | Handle_ListenStateExpired(msg->vif, &msg->body.remain_on_ch); |
| 2608 | break; |
| 2609 | |
| 2610 | case HOST_IF_MSG_SET_MULTICAST_FILTER: |
| 2611 | Handle_SetMulticastFilter(msg->vif, &msg->body.multicast_info); |
| 2612 | break; |
| 2613 | |
| 2614 | case HOST_IF_MSG_DEL_ALL_STA: |
| 2615 | Handle_DelAllSta(msg->vif, &msg->body.del_all_sta_info); |
| 2616 | break; |
| 2617 | |
| 2618 | case HOST_IF_MSG_SET_TX_POWER: |
| 2619 | handle_set_tx_pwr(msg->vif, msg->body.tx_power.tx_pwr); |
| 2620 | break; |
| 2621 | |
| 2622 | case HOST_IF_MSG_GET_TX_POWER: |
| 2623 | handle_get_tx_pwr(msg->vif, &msg->body.tx_power.tx_pwr); |
| 2624 | break; |
| 2625 | default: |
| 2626 | netdev_err(msg->vif->ndev, "[Host Interface] undefined\n"); |
| 2627 | break; |
| 2628 | } |
| 2629 | free_msg: |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 2630 | kfree(msg); |
Chaehyun Lim | 04dd9a4 | 2016-03-23 21:28:33 +0900 | [diff] [blame] | 2631 | complete(&hif_thread_comp); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2632 | } |
| 2633 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 2634 | static void TimerCB_Scan(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2635 | { |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2636 | struct wilc_vif *vif = (struct wilc_vif *)arg; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2637 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2638 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2639 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2640 | msg.vif = vif; |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2641 | msg.id = HOST_IF_MSG_SCAN_TIMER_FIRED; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2642 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2643 | wilc_enqueue_cmd(&msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2644 | } |
| 2645 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 2646 | static void TimerCB_Connect(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2647 | { |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2648 | struct wilc_vif *vif = (struct wilc_vif *)arg; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2649 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2650 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2651 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 2652 | msg.vif = vif; |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2653 | msg.id = HOST_IF_MSG_CONNECT_TIMER_FIRED; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2654 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2655 | wilc_enqueue_cmd(&msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2656 | } |
| 2657 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 2658 | s32 wilc_remove_key(struct host_if_drv *hif_drv, const u8 *pu8StaAddress) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2659 | { |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2660 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2661 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 2662 | wid.id = (u16)WID_REMOVE_KEY; |
| 2663 | wid.type = WID_STR; |
| 2664 | wid.val = (s8 *)pu8StaAddress; |
| 2665 | wid.size = 6; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2666 | |
Leo Kim | b68d820b | 2015-10-12 16:55:37 +0900 | [diff] [blame] | 2667 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2668 | } |
| 2669 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2670 | int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2671 | { |
Chaehyun Lim | 9e5e8b4 | 2015-10-05 19:35:00 +0900 | [diff] [blame] | 2672 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2673 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2674 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2675 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 2676 | if (!hif_drv) { |
Chaehyun Lim | 9e5e8b4 | 2015-10-05 19:35:00 +0900 | [diff] [blame] | 2677 | result = -EFAULT; |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2678 | netdev_err(vif->ndev, "Failed to send setup multicast\n"); |
Chaehyun Lim | 9e5e8b4 | 2015-10-05 19:35:00 +0900 | [diff] [blame] | 2679 | return result; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2680 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2681 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2682 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2683 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2684 | msg.id = HOST_IF_MSG_KEY; |
Leo Kim | 8e9f427 | 2015-10-13 19:49:27 +0900 | [diff] [blame] | 2685 | msg.body.key_info.type = WEP; |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 2686 | msg.body.key_info.action = REMOVEKEY; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2687 | msg.vif = vif; |
Leo Kim | 73b2e38 | 2015-10-13 19:49:29 +0900 | [diff] [blame] | 2688 | msg.body.key_info.attr.wep.index = index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2689 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2690 | result = wilc_enqueue_cmd(&msg); |
Chaehyun Lim | 9e5e8b4 | 2015-10-05 19:35:00 +0900 | [diff] [blame] | 2691 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2692 | netdev_err(vif->ndev, "Request to remove WEP key\n"); |
Leo Kim | 27e1f13 | 2016-04-01 17:44:13 +0900 | [diff] [blame] | 2693 | else |
| 2694 | wait_for_completion(&hif_drv->comp_test_key_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2695 | |
Chaehyun Lim | 9e5e8b4 | 2015-10-05 19:35:00 +0900 | [diff] [blame] | 2696 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2697 | } |
| 2698 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2699 | int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2700 | { |
Chaehyun Lim | 5b41c7c | 2015-10-26 09:44:42 +0900 | [diff] [blame] | 2701 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2702 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2703 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2704 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 2705 | if (!hif_drv) { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2706 | result = -EFAULT; |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2707 | netdev_err(vif->ndev, "driver is null\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2708 | return result; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2709 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2710 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2711 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2712 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2713 | msg.id = HOST_IF_MSG_KEY; |
Leo Kim | 8e9f427 | 2015-10-13 19:49:27 +0900 | [diff] [blame] | 2714 | msg.body.key_info.type = WEP; |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 2715 | msg.body.key_info.action = DEFAULTKEY; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2716 | msg.vif = vif; |
Chaehyun Lim | e91d034 | 2015-10-26 09:44:44 +0900 | [diff] [blame] | 2717 | msg.body.key_info.attr.wep.index = index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2718 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2719 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2720 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2721 | netdev_err(vif->ndev, "Default key index\n"); |
Leo Kim | 27e1f13 | 2016-04-01 17:44:13 +0900 | [diff] [blame] | 2722 | else |
| 2723 | wait_for_completion(&hif_drv->comp_test_key_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2724 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2725 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2726 | } |
| 2727 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2728 | int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, |
| 2729 | u8 index) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2730 | { |
Chaehyun Lim | 66b8cb8 | 2015-10-27 20:40:32 +0900 | [diff] [blame] | 2731 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2732 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2733 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2734 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 2735 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2736 | netdev_err(vif->ndev, "driver is null\n"); |
Leo Kim | 771788078 | 2015-10-19 18:26:11 +0900 | [diff] [blame] | 2737 | return -EFAULT; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2738 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2739 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2740 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2741 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2742 | msg.id = HOST_IF_MSG_KEY; |
Leo Kim | 8e9f427 | 2015-10-13 19:49:27 +0900 | [diff] [blame] | 2743 | msg.body.key_info.type = WEP; |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 2744 | msg.body.key_info.action = ADDKEY; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2745 | msg.vif = vif; |
Chaehyun Lim | 1cc0c32 | 2015-10-27 20:40:37 +0900 | [diff] [blame] | 2746 | msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); |
| 2747 | if (!msg.body.key_info.attr.wep.key) |
| 2748 | return -ENOMEM; |
| 2749 | |
Chaehyun Lim | dbc5319 | 2015-10-27 20:40:35 +0900 | [diff] [blame] | 2750 | msg.body.key_info.attr.wep.key_len = len; |
Chaehyun Lim | 0b2cc3e | 2015-10-27 20:40:36 +0900 | [diff] [blame] | 2751 | msg.body.key_info.attr.wep.index = index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2752 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2753 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2754 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2755 | netdev_err(vif->ndev, "STA - WEP Key\n"); |
Alison Schofield | 702962f | 2016-03-14 10:35:41 -0700 | [diff] [blame] | 2756 | wait_for_completion(&hif_drv->comp_test_key_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2757 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2758 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2759 | } |
| 2760 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2761 | int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, |
| 2762 | u8 index, u8 mode, enum AUTHTYPE auth_type) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2763 | { |
Chaehyun Lim | 641c20a | 2015-10-28 08:19:19 +0900 | [diff] [blame] | 2764 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2765 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2766 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2767 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 2768 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2769 | netdev_err(vif->ndev, "driver is null\n"); |
Leo Kim | 771788078 | 2015-10-19 18:26:11 +0900 | [diff] [blame] | 2770 | return -EFAULT; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2771 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2772 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2773 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2774 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2775 | msg.id = HOST_IF_MSG_KEY; |
Leo Kim | 8e9f427 | 2015-10-13 19:49:27 +0900 | [diff] [blame] | 2776 | msg.body.key_info.type = WEP; |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 2777 | msg.body.key_info.action = ADDKEY_AP; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2778 | msg.vif = vif; |
Chaehyun Lim | 58eabd6 | 2015-10-28 08:19:27 +0900 | [diff] [blame] | 2779 | msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); |
| 2780 | if (!msg.body.key_info.attr.wep.key) |
| 2781 | return -ENOMEM; |
| 2782 | |
Chaehyun Lim | a5389b0 | 2015-10-28 08:19:23 +0900 | [diff] [blame] | 2783 | msg.body.key_info.attr.wep.key_len = len; |
Chaehyun Lim | a76dc95 | 2015-10-28 08:19:24 +0900 | [diff] [blame] | 2784 | msg.body.key_info.attr.wep.index = index; |
Chaehyun Lim | 730a28d | 2015-10-28 08:19:25 +0900 | [diff] [blame] | 2785 | msg.body.key_info.attr.wep.mode = mode; |
Chaehyun Lim | ff3bce2 | 2015-10-28 08:19:26 +0900 | [diff] [blame] | 2786 | msg.body.key_info.attr.wep.auth_type = auth_type; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 2787 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2788 | result = wilc_enqueue_cmd(&msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2789 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2790 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2791 | netdev_err(vif->ndev, "AP - WEP Key\n"); |
Leo Kim | 27e1f13 | 2016-04-01 17:44:13 +0900 | [diff] [blame] | 2792 | else |
| 2793 | wait_for_completion(&hif_drv->comp_test_key_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2794 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2795 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2796 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 2797 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2798 | int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, |
| 2799 | const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, |
| 2800 | u8 mode, u8 cipher_mode, u8 index) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2801 | { |
Chaehyun Lim | 706ab42 | 2015-11-08 16:48:54 +0900 | [diff] [blame] | 2802 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2803 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2804 | struct host_if_drv *hif_drv = vif->hif_drv; |
Chaehyun Lim | 53bbbb5 | 2015-11-08 16:49:03 +0900 | [diff] [blame] | 2805 | u8 key_len = ptk_key_len; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 2806 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 2807 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2808 | netdev_err(vif->ndev, "driver is null\n"); |
Leo Kim | 771788078 | 2015-10-19 18:26:11 +0900 | [diff] [blame] | 2809 | return -EFAULT; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2810 | } |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 2811 | |
Chaehyun Lim | 38f6629 | 2015-11-08 16:48:58 +0900 | [diff] [blame] | 2812 | if (rx_mic) |
Chaehyun Lim | 53bbbb5 | 2015-11-08 16:49:03 +0900 | [diff] [blame] | 2813 | key_len += RX_MIC_KEY_LEN; |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 2814 | |
Chaehyun Lim | d7c0242 | 2015-11-08 16:48:59 +0900 | [diff] [blame] | 2815 | if (tx_mic) |
Chaehyun Lim | 53bbbb5 | 2015-11-08 16:49:03 +0900 | [diff] [blame] | 2816 | key_len += TX_MIC_KEY_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2817 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2818 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2819 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2820 | msg.id = HOST_IF_MSG_KEY; |
Leo Kim | 2141fe3 | 2015-10-29 12:05:35 +0900 | [diff] [blame] | 2821 | msg.body.key_info.type = WPA_PTK; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2822 | if (mode == AP_MODE) { |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 2823 | msg.body.key_info.action = ADDKEY_AP; |
Chaehyun Lim | 3e5c4ab | 2015-11-08 16:49:01 +0900 | [diff] [blame] | 2824 | msg.body.key_info.attr.wpa.index = index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2825 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2826 | if (mode == STATION_MODE) |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 2827 | msg.body.key_info.action = ADDKEY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2828 | |
Chaehyun Lim | 8ab8c59 | 2015-11-08 16:49:04 +0900 | [diff] [blame] | 2829 | msg.body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL); |
| 2830 | if (!msg.body.key_info.attr.wpa.key) |
| 2831 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2832 | |
Chris Park | 9ac0c05 | 2016-02-22 13:11:56 +0900 | [diff] [blame] | 2833 | if (rx_mic) |
Chaehyun Lim | 38f6629 | 2015-11-08 16:48:58 +0900 | [diff] [blame] | 2834 | memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, RX_MIC_KEY_LEN); |
Chris Park | 9ac0c05 | 2016-02-22 13:11:56 +0900 | [diff] [blame] | 2835 | |
| 2836 | if (tx_mic) |
Chaehyun Lim | d7c0242 | 2015-11-08 16:48:59 +0900 | [diff] [blame] | 2837 | memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, TX_MIC_KEY_LEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2838 | |
Chaehyun Lim | 53bbbb5 | 2015-11-08 16:49:03 +0900 | [diff] [blame] | 2839 | msg.body.key_info.attr.wpa.key_len = key_len; |
Leo Kim | 248080a | 2015-10-13 19:49:31 +0900 | [diff] [blame] | 2840 | msg.body.key_info.attr.wpa.mac_addr = mac_addr; |
Chaehyun Lim | f0c8257 | 2015-11-08 16:49:00 +0900 | [diff] [blame] | 2841 | msg.body.key_info.attr.wpa.mode = cipher_mode; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2842 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2843 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2844 | result = wilc_enqueue_cmd(&msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2845 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2846 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2847 | netdev_err(vif->ndev, "PTK Key\n"); |
Leo Kim | 27e1f13 | 2016-04-01 17:44:13 +0900 | [diff] [blame] | 2848 | else |
| 2849 | wait_for_completion(&hif_drv->comp_test_key_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2850 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2851 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2852 | } |
| 2853 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2854 | int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, |
| 2855 | u8 index, u32 key_rsc_len, const u8 *key_rsc, |
| 2856 | const u8 *rx_mic, const u8 *tx_mic, u8 mode, |
| 2857 | u8 cipher_mode) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2858 | { |
Chaehyun Lim | 1503457 | 2015-11-08 16:49:05 +0900 | [diff] [blame] | 2859 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2860 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2861 | struct host_if_drv *hif_drv = vif->hif_drv; |
Chaehyun Lim | d002fcc | 2015-11-08 16:49:15 +0900 | [diff] [blame] | 2862 | u8 key_len = gtk_key_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2863 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 2864 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2865 | netdev_err(vif->ndev, "driver is null\n"); |
Leo Kim | 771788078 | 2015-10-19 18:26:11 +0900 | [diff] [blame] | 2866 | return -EFAULT; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2867 | } |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2868 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2869 | |
Chaehyun Lim | 6d36c27 | 2015-11-08 16:49:12 +0900 | [diff] [blame] | 2870 | if (rx_mic) |
Chaehyun Lim | d002fcc | 2015-11-08 16:49:15 +0900 | [diff] [blame] | 2871 | key_len += RX_MIC_KEY_LEN; |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 2872 | |
Chaehyun Lim | 2f79758 | 2015-11-08 16:49:13 +0900 | [diff] [blame] | 2873 | if (tx_mic) |
Chaehyun Lim | d002fcc | 2015-11-08 16:49:15 +0900 | [diff] [blame] | 2874 | key_len += TX_MIC_KEY_LEN; |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 2875 | |
Chaehyun Lim | 982859c | 2015-11-08 16:49:11 +0900 | [diff] [blame] | 2876 | if (key_rsc) { |
Chaehyun Lim | 9bfda38 | 2015-11-08 16:49:16 +0900 | [diff] [blame] | 2877 | msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc, |
| 2878 | key_rsc_len, |
| 2879 | GFP_KERNEL); |
| 2880 | if (!msg.body.key_info.attr.wpa.seq) |
| 2881 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2882 | } |
| 2883 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2884 | msg.id = HOST_IF_MSG_KEY; |
Leo Kim | 5cd8f7a | 2015-10-29 12:05:34 +0900 | [diff] [blame] | 2885 | msg.body.key_info.type = WPA_RX_GTK; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2886 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2887 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2888 | if (mode == AP_MODE) { |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 2889 | msg.body.key_info.action = ADDKEY_AP; |
Chaehyun Lim | 57bfcbc | 2015-11-08 16:49:14 +0900 | [diff] [blame] | 2890 | msg.body.key_info.attr.wpa.mode = cipher_mode; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2891 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2892 | if (mode == STATION_MODE) |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 2893 | msg.body.key_info.action = ADDKEY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2894 | |
Chaehyun Lim | 9bfda38 | 2015-11-08 16:49:16 +0900 | [diff] [blame] | 2895 | msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk, |
| 2896 | key_len, |
| 2897 | GFP_KERNEL); |
| 2898 | if (!msg.body.key_info.attr.wpa.key) |
| 2899 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2900 | |
Chaehyun Lim | 6d36c27 | 2015-11-08 16:49:12 +0900 | [diff] [blame] | 2901 | if (rx_mic) |
| 2902 | memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 2903 | RX_MIC_KEY_LEN); |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 2904 | |
Chaehyun Lim | 2f79758 | 2015-11-08 16:49:13 +0900 | [diff] [blame] | 2905 | if (tx_mic) |
| 2906 | memcpy(msg.body.key_info.attr.wpa.key + 24, tx_mic, |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 2907 | TX_MIC_KEY_LEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2908 | |
Chaehyun Lim | 9a5e5736 | 2015-11-08 16:49:09 +0900 | [diff] [blame] | 2909 | msg.body.key_info.attr.wpa.index = index; |
Chaehyun Lim | d002fcc | 2015-11-08 16:49:15 +0900 | [diff] [blame] | 2910 | msg.body.key_info.attr.wpa.key_len = key_len; |
Chaehyun Lim | 18bef99 | 2015-11-08 16:49:10 +0900 | [diff] [blame] | 2911 | msg.body.key_info.attr.wpa.seq_len = key_rsc_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2912 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2913 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2914 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2915 | netdev_err(vif->ndev, "RX GTK\n"); |
Leo Kim | 27e1f13 | 2016-04-01 17:44:13 +0900 | [diff] [blame] | 2916 | else |
| 2917 | wait_for_completion(&hif_drv->comp_test_key_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2918 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2919 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2920 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2921 | |
Chaehyun Lim | 1ab5870 | 2015-12-22 09:49:03 +0900 | [diff] [blame] | 2922 | int wilc_set_pmkid_info(struct wilc_vif *vif, |
Chaehyun Lim | 16c0cba | 2015-12-22 09:49:05 +0900 | [diff] [blame] | 2923 | struct host_if_pmkid_attr *pmkid) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2924 | { |
Chaehyun Lim | 1ab5870 | 2015-12-22 09:49:03 +0900 | [diff] [blame] | 2925 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2926 | struct host_if_msg msg; |
Chaehyun Lim | 89dec13 | 2015-12-22 09:49:04 +0900 | [diff] [blame] | 2927 | int i; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2928 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2929 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2930 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2931 | msg.id = HOST_IF_MSG_KEY; |
Leo Kim | 8e9f427 | 2015-10-13 19:49:27 +0900 | [diff] [blame] | 2932 | msg.body.key_info.type = PMKSA; |
Leo Kim | 0d17e38 | 2015-10-13 19:49:28 +0900 | [diff] [blame] | 2933 | msg.body.key_info.action = ADDKEY; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2934 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2935 | |
Chaehyun Lim | 16c0cba | 2015-12-22 09:49:05 +0900 | [diff] [blame] | 2936 | for (i = 0; i < pmkid->numpmkid; i++) { |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 2937 | memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].bssid, |
Chaehyun Lim | 16c0cba | 2015-12-22 09:49:05 +0900 | [diff] [blame] | 2938 | &pmkid->pmkidlist[i].bssid, ETH_ALEN); |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 2939 | memcpy(msg.body.key_info.attr.pmkid.pmkidlist[i].pmkid, |
Chaehyun Lim | 16c0cba | 2015-12-22 09:49:05 +0900 | [diff] [blame] | 2940 | &pmkid->pmkidlist[i].pmkid, PMKID_LEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2941 | } |
| 2942 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2943 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2944 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2945 | netdev_err(vif->ndev, "PMKID Info\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2946 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2947 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2948 | } |
| 2949 | |
Chaehyun Lim | 1eabfe3 | 2015-12-22 09:49:07 +0900 | [diff] [blame] | 2950 | int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2951 | { |
Chaehyun Lim | dcb15a0 | 2015-12-22 09:49:06 +0900 | [diff] [blame] | 2952 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2953 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2954 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2955 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2956 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2957 | msg.id = HOST_IF_MSG_GET_MAC_ADDRESS; |
Chaehyun Lim | 1eabfe3 | 2015-12-22 09:49:07 +0900 | [diff] [blame] | 2958 | msg.body.get_mac_info.mac_addr = mac_addr; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 2959 | msg.vif = vif; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 2960 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 2961 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2962 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2963 | netdev_err(vif->ndev, "Failed to send get mac address\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 2964 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2965 | } |
| 2966 | |
Chaehyun Lim | 613eaa3 | 2016-03-14 09:40:27 +0900 | [diff] [blame] | 2967 | wait_for_completion(&hif_wait_response); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 2968 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2969 | } |
| 2970 | |
Chaehyun Lim | f2cb5f3 | 2015-12-24 16:52:22 +0900 | [diff] [blame] | 2971 | int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, |
Chaehyun Lim | 8c38d96 | 2015-12-24 16:52:25 +0900 | [diff] [blame] | 2972 | size_t ssid_len, const u8 *ies, size_t ies_len, |
Chaehyun Lim | 2ef2983 | 2015-12-24 16:52:27 +0900 | [diff] [blame] | 2973 | wilc_connect_result connect_result, void *user_arg, |
Chaehyun Lim | 12a3b8b | 2015-12-24 16:52:29 +0900 | [diff] [blame] | 2974 | u8 security, enum AUTHTYPE auth_type, |
Chaehyun Lim | f382b37 | 2015-12-24 16:52:31 +0900 | [diff] [blame] | 2975 | u8 channel, void *join_params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2976 | { |
Chaehyun Lim | 0a285b2 | 2015-12-24 16:52:20 +0900 | [diff] [blame] | 2977 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2978 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 2979 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2980 | |
Chaehyun Lim | 81c23a7 | 2015-12-24 16:52:26 +0900 | [diff] [blame] | 2981 | if (!hif_drv || !connect_result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2982 | netdev_err(vif->ndev, "Driver is null\n"); |
Leo Kim | 771788078 | 2015-10-19 18:26:11 +0900 | [diff] [blame] | 2983 | return -EFAULT; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2984 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2985 | |
Chaehyun Lim | f382b37 | 2015-12-24 16:52:31 +0900 | [diff] [blame] | 2986 | if (!join_params) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 2987 | netdev_err(vif->ndev, "Unable to Join - JoinParams is NULL\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2988 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2989 | } |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 2990 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 2991 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2992 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 2993 | msg.id = HOST_IF_MSG_CONNECT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2994 | |
Chaehyun Lim | e0c54a8 | 2015-12-24 16:52:28 +0900 | [diff] [blame] | 2995 | msg.body.con_info.security = security; |
Chaehyun Lim | 12a3b8b | 2015-12-24 16:52:29 +0900 | [diff] [blame] | 2996 | msg.body.con_info.auth_type = auth_type; |
Chaehyun Lim | 0ea1ece | 2015-12-24 16:52:30 +0900 | [diff] [blame] | 2997 | msg.body.con_info.ch = channel; |
Chaehyun Lim | 81c23a7 | 2015-12-24 16:52:26 +0900 | [diff] [blame] | 2998 | msg.body.con_info.result = connect_result; |
Chaehyun Lim | 2ef2983 | 2015-12-24 16:52:27 +0900 | [diff] [blame] | 2999 | msg.body.con_info.arg = user_arg; |
Chaehyun Lim | f382b37 | 2015-12-24 16:52:31 +0900 | [diff] [blame] | 3000 | msg.body.con_info.params = join_params; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3001 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3002 | |
Chaehyun Lim | 16a537c | 2015-12-24 16:52:21 +0900 | [diff] [blame] | 3003 | if (bssid) { |
Chaehyun Lim | 1162313 | 2015-12-24 16:52:32 +0900 | [diff] [blame] | 3004 | msg.body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL); |
| 3005 | if (!msg.body.con_info.bssid) |
| 3006 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3007 | } |
| 3008 | |
Chaehyun Lim | f2cb5f3 | 2015-12-24 16:52:22 +0900 | [diff] [blame] | 3009 | if (ssid) { |
Chaehyun Lim | dee39b1 | 2015-12-24 16:52:23 +0900 | [diff] [blame] | 3010 | msg.body.con_info.ssid_len = ssid_len; |
Chaehyun Lim | 1162313 | 2015-12-24 16:52:32 +0900 | [diff] [blame] | 3011 | msg.body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL); |
| 3012 | if (!msg.body.con_info.ssid) |
| 3013 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3014 | } |
| 3015 | |
Chaehyun Lim | 88c9421 | 2015-12-24 16:52:24 +0900 | [diff] [blame] | 3016 | if (ies) { |
Chaehyun Lim | 8c38d96 | 2015-12-24 16:52:25 +0900 | [diff] [blame] | 3017 | msg.body.con_info.ies_len = ies_len; |
Chaehyun Lim | 1162313 | 2015-12-24 16:52:32 +0900 | [diff] [blame] | 3018 | msg.body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL); |
| 3019 | if (!msg.body.con_info.ies) |
| 3020 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3021 | } |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 3022 | if (hif_drv->hif_state < HOST_IF_CONNECTING) |
| 3023 | hif_drv->hif_state = HOST_IF_CONNECTING; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3024 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3025 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3026 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3027 | netdev_err(vif->ndev, "send message: Set join request\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3028 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3029 | } |
| 3030 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 3031 | hif_drv->connect_timer.data = (unsigned long)vif; |
Leo Kim | 81a5950 | 2015-10-29 11:58:35 +0900 | [diff] [blame] | 3032 | mod_timer(&hif_drv->connect_timer, |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 3033 | jiffies + msecs_to_jiffies(HOST_IF_CONNECT_TIMEOUT)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3034 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3035 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3036 | } |
| 3037 | |
Chaehyun Lim | 9f723fd | 2015-12-24 16:52:34 +0900 | [diff] [blame] | 3038 | int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3039 | { |
Chaehyun Lim | 5350251 | 2015-12-24 16:52:33 +0900 | [diff] [blame] | 3040 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3041 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3042 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3043 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3044 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3045 | netdev_err(vif->ndev, "Driver is null\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3046 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3047 | } |
| 3048 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3049 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3050 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3051 | msg.id = HOST_IF_MSG_DISCONNECT; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3052 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3053 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3054 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3055 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3056 | netdev_err(vif->ndev, "Failed to send message: disconnect\n"); |
Leo Kim | 27e1f13 | 2016-04-01 17:44:13 +0900 | [diff] [blame] | 3057 | else |
| 3058 | wait_for_completion(&hif_drv->comp_test_disconn_block); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3059 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3060 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3061 | } |
| 3062 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 3063 | static s32 host_int_get_assoc_res_info(struct wilc_vif *vif, |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 3064 | u8 *pu8AssocRespInfo, |
| 3065 | u32 u32MaxAssocRespInfoLen, |
| 3066 | u32 *pu32RcvdAssocRespInfoLen) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3067 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3068 | s32 result = 0; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 3069 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3070 | |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 3071 | wid.id = (u16)WID_ASSOC_RES_INFO; |
| 3072 | wid.type = WID_STR; |
| 3073 | wid.val = pu8AssocRespInfo; |
| 3074 | wid.size = u32MaxAssocRespInfoLen; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3075 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 3076 | result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, |
Chaehyun Lim | 4cf93d7 | 2016-01-26 18:50:00 +0900 | [diff] [blame] | 3077 | wilc_get_vif_idx(vif)); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3078 | if (result) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3079 | *pu32RcvdAssocRespInfoLen = 0; |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3080 | netdev_err(vif->ndev, "Failed to send association response\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3081 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3082 | } |
Eva Rachel Retuya | c22177d | 2016-02-16 16:24:44 +0800 | [diff] [blame] | 3083 | |
Janani Ravichandran | 24c6c29 | 2016-02-14 00:09:33 -0500 | [diff] [blame] | 3084 | *pu32RcvdAssocRespInfoLen = wid.size; |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3085 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3086 | } |
| 3087 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3088 | int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3089 | { |
Chaehyun Lim | 792fb25 | 2015-10-05 11:07:22 +0900 | [diff] [blame] | 3090 | int result; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3091 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3092 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3093 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3094 | msg.id = HOST_IF_MSG_SET_CHANNEL; |
Leo Kim | 730ee05 | 2015-10-13 19:50:02 +0900 | [diff] [blame] | 3095 | msg.body.channel_info.set_ch = channel; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3096 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3097 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3098 | result = wilc_enqueue_cmd(&msg); |
Chaehyun Lim | 1ef58e4 | 2015-10-02 21:44:49 +0900 | [diff] [blame] | 3099 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3100 | netdev_err(vif->ndev, "wilc mq send fail\n"); |
Chaehyun Lim | 792fb25 | 2015-10-05 11:07:22 +0900 | [diff] [blame] | 3101 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3102 | } |
| 3103 | |
Chaehyun Lim | 792fb25 | 2015-10-05 11:07:22 +0900 | [diff] [blame] | 3104 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3105 | } |
| 3106 | |
Glen Lee | b330686 | 2016-02-04 18:15:18 +0900 | [diff] [blame] | 3107 | int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mac_idx) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3108 | { |
Chaehyun Lim | a094101 | 2015-10-05 19:34:47 +0900 | [diff] [blame] | 3109 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3110 | struct host_if_msg msg; |
Leo Kim | c09389a | 2015-10-28 15:59:24 +0900 | [diff] [blame] | 3111 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3112 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3113 | msg.id = HOST_IF_MSG_SET_WFIDRV_HANDLER; |
Glen Lee | 31f0f69 | 2015-12-21 14:18:44 +0900 | [diff] [blame] | 3114 | msg.body.drv.handler = index; |
Glen Lee | b330686 | 2016-02-04 18:15:18 +0900 | [diff] [blame] | 3115 | msg.body.drv.mac_idx = mac_idx; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3116 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3117 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3118 | result = wilc_enqueue_cmd(&msg); |
Chaehyun Lim | a094101 | 2015-10-05 19:34:47 +0900 | [diff] [blame] | 3119 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3120 | netdev_err(vif->ndev, "wilc mq send fail\n"); |
Chaehyun Lim | a094101 | 2015-10-05 19:34:47 +0900 | [diff] [blame] | 3121 | result = -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3122 | } |
| 3123 | |
Chaehyun Lim | a094101 | 2015-10-05 19:34:47 +0900 | [diff] [blame] | 3124 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3125 | } |
| 3126 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3127 | int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3128 | { |
Chaehyun Lim | a0c1ee0 | 2015-10-05 19:34:50 +0900 | [diff] [blame] | 3129 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3130 | struct host_if_msg msg; |
Leo Kim | c09389a | 2015-10-28 15:59:24 +0900 | [diff] [blame] | 3131 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3132 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3133 | msg.id = HOST_IF_MSG_SET_OPERATION_MODE; |
Leo Kim | c96debf | 2015-10-28 15:59:30 +0900 | [diff] [blame] | 3134 | msg.body.mode.mode = mode; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3135 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3136 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3137 | result = wilc_enqueue_cmd(&msg); |
Chaehyun Lim | a0c1ee0 | 2015-10-05 19:34:50 +0900 | [diff] [blame] | 3138 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3139 | netdev_err(vif->ndev, "wilc mq send fail\n"); |
Chaehyun Lim | a0c1ee0 | 2015-10-05 19:34:50 +0900 | [diff] [blame] | 3140 | result = -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3141 | } |
| 3142 | |
Chaehyun Lim | a0c1ee0 | 2015-10-05 19:34:50 +0900 | [diff] [blame] | 3143 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3144 | } |
| 3145 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3146 | s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, |
| 3147 | u32 *pu32InactiveTime) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3148 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3149 | s32 result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3150 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3151 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3152 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3153 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3154 | netdev_err(vif->ndev, "driver is null\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3155 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3156 | } |
| 3157 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3158 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Leo Kim | 8c8360b | 2015-10-19 18:26:12 +0900 | [diff] [blame] | 3159 | memcpy(msg.body.mac_info.mac, mac, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3160 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3161 | msg.id = HOST_IF_MSG_GET_INACTIVETIME; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3162 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3163 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3164 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3165 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3166 | netdev_err(vif->ndev, "Failed to send get host ch param\n"); |
Leo Kim | 27e1f13 | 2016-04-01 17:44:13 +0900 | [diff] [blame] | 3167 | else |
| 3168 | wait_for_completion(&hif_drv->comp_inactive_time); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3169 | |
Leo Kim | ad26906 | 2015-10-15 13:25:06 +0900 | [diff] [blame] | 3170 | *pu32InactiveTime = inactive_time; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3171 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3172 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3173 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 3174 | |
Chaehyun Lim | 652bb5e | 2015-12-24 16:52:37 +0900 | [diff] [blame] | 3175 | int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3176 | { |
Chaehyun Lim | e16aed6 | 2015-12-24 16:52:36 +0900 | [diff] [blame] | 3177 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3178 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3179 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3180 | |
Leo Kim | c09389a | 2015-10-28 15:59:24 +0900 | [diff] [blame] | 3181 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3182 | msg.id = HOST_IF_MSG_GET_RSSI; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3183 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3184 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3185 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3186 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3187 | netdev_err(vif->ndev, "Failed to send get host ch param\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3188 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3189 | } |
| 3190 | |
Alison Schofield | 7c8a3dc | 2016-03-14 10:34:39 -0700 | [diff] [blame] | 3191 | wait_for_completion(&hif_drv->comp_get_rssi); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3192 | |
Chaehyun Lim | 652bb5e | 2015-12-24 16:52:37 +0900 | [diff] [blame] | 3193 | if (!rssi_level) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3194 | netdev_err(vif->ndev, "RSS pointer value is null\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3195 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3196 | } |
| 3197 | |
Chaehyun Lim | 652bb5e | 2015-12-24 16:52:37 +0900 | [diff] [blame] | 3198 | *rssi_level = rssi; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3199 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3200 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3201 | } |
| 3202 | |
Chaehyun Lim | f70b25f | 2015-12-24 16:52:39 +0900 | [diff] [blame] | 3203 | int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3204 | { |
Chaehyun Lim | cd163d3 | 2015-12-24 16:52:38 +0900 | [diff] [blame] | 3205 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3206 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3207 | |
Leo Kim | c09389a | 2015-10-28 15:59:24 +0900 | [diff] [blame] | 3208 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3209 | msg.id = HOST_IF_MSG_GET_STATISTICS; |
Chaehyun Lim | f70b25f | 2015-12-24 16:52:39 +0900 | [diff] [blame] | 3210 | msg.body.data = (char *)stats; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3211 | msg.vif = vif; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3212 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3213 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3214 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3215 | netdev_err(vif->ndev, "Failed to send get host channel\n"); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 3216 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3217 | } |
| 3218 | |
Glen Lee | 4fd6229 | 2016-02-04 18:15:24 +0900 | [diff] [blame] | 3219 | if (stats != &vif->wilc->dummy_statistics) |
Chaehyun Lim | 613eaa3 | 2016-03-14 09:40:27 +0900 | [diff] [blame] | 3220 | wait_for_completion(&hif_wait_response); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3221 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3222 | } |
| 3223 | |
Chaehyun Lim | c0734df | 2016-01-05 23:06:47 +0900 | [diff] [blame] | 3224 | int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, |
Chaehyun Lim | ce2d023 | 2016-01-05 23:06:50 +0900 | [diff] [blame] | 3225 | u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, |
Chaehyun Lim | 2c97f2d | 2016-01-05 23:06:53 +0900 | [diff] [blame] | 3226 | size_t ies_len, wilc_scan_result scan_result, void *user_arg, |
Chaehyun Lim | d317818 | 2016-01-05 23:06:54 +0900 | [diff] [blame] | 3227 | struct hidden_network *hidden_network) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3228 | { |
Chaehyun Lim | 03a5d8c | 2016-01-05 23:06:45 +0900 | [diff] [blame] | 3229 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3230 | struct host_if_msg msg; |
Chaehyun Lim | b41dfdb | 2016-02-12 23:04:43 +0900 | [diff] [blame] | 3231 | struct scan_attr *scan_info = &msg.body.scan_info; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3232 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3233 | |
Chaehyun Lim | c8fb0bf | 2016-01-05 23:06:52 +0900 | [diff] [blame] | 3234 | if (!hif_drv || !scan_result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3235 | netdev_err(vif->ndev, "hif_drv or scan_result = NULL\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3236 | return -EFAULT; |
| 3237 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3238 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3239 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3240 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3241 | msg.id = HOST_IF_MSG_SCAN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3242 | |
Chaehyun Lim | d317818 | 2016-01-05 23:06:54 +0900 | [diff] [blame] | 3243 | if (hidden_network) { |
Chaehyun Lim | b41dfdb | 2016-02-12 23:04:43 +0900 | [diff] [blame] | 3244 | scan_info->hidden_network.net_info = hidden_network->net_info; |
| 3245 | scan_info->hidden_network.n_ssids = hidden_network->n_ssids; |
Chris Park | c4f9752 | 2016-02-04 18:24:04 +0900 | [diff] [blame] | 3246 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3247 | |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3248 | msg.vif = vif; |
Chaehyun Lim | b41dfdb | 2016-02-12 23:04:43 +0900 | [diff] [blame] | 3249 | scan_info->src = scan_source; |
| 3250 | scan_info->type = scan_type; |
| 3251 | scan_info->result = scan_result; |
| 3252 | scan_info->arg = user_arg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3253 | |
Chaehyun Lim | b41dfdb | 2016-02-12 23:04:43 +0900 | [diff] [blame] | 3254 | scan_info->ch_list_len = ch_list_len; |
| 3255 | scan_info->ch_freq_list = kmemdup(ch_freq_list, |
| 3256 | ch_list_len, |
| 3257 | GFP_KERNEL); |
| 3258 | if (!scan_info->ch_freq_list) |
Chaehyun Lim | 1a271d9 | 2016-01-05 23:06:55 +0900 | [diff] [blame] | 3259 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3260 | |
Chaehyun Lim | b41dfdb | 2016-02-12 23:04:43 +0900 | [diff] [blame] | 3261 | scan_info->ies_len = ies_len; |
| 3262 | scan_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); |
| 3263 | if (!scan_info->ies) |
Chaehyun Lim | 1a271d9 | 2016-01-05 23:06:55 +0900 | [diff] [blame] | 3264 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3265 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3266 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3267 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3268 | netdev_err(vif->ndev, "Error in sending message queue\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3269 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3270 | } |
| 3271 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 3272 | hif_drv->scan_timer.data = (unsigned long)vif; |
Leo Kim | 13b313e | 2015-10-29 11:58:34 +0900 | [diff] [blame] | 3273 | mod_timer(&hif_drv->scan_timer, |
Greg Kroah-Hartman | 9eb0664 | 2015-08-17 11:10:55 -0700 | [diff] [blame] | 3274 | jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3275 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3276 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3277 | } |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3278 | |
Chaehyun Lim | 4168da7 | 2016-02-05 10:35:11 +0900 | [diff] [blame] | 3279 | int wilc_hif_set_cfg(struct wilc_vif *vif, |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 3280 | struct cfg_param_attr *cfg_param) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3281 | { |
Chaehyun Lim | 4168da7 | 2016-02-05 10:35:11 +0900 | [diff] [blame] | 3282 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3283 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3284 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3285 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3286 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3287 | netdev_err(vif->ndev, "hif_drv NULL\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3288 | return -EFAULT; |
| 3289 | } |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3290 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3291 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3292 | msg.id = HOST_IF_MSG_CFG_PARAMS; |
Chaehyun Lim | a5f0fb5 | 2016-02-23 15:37:58 +0900 | [diff] [blame] | 3293 | msg.body.cfg_info = *cfg_param; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3294 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3295 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3296 | result = wilc_enqueue_cmd(&msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3297 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3298 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3299 | } |
| 3300 | |
Greg Kroah-Hartman | 93dee8e | 2015-08-14 20:28:32 -0700 | [diff] [blame] | 3301 | static void GetPeriodicRSSI(unsigned long arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3302 | { |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 3303 | struct wilc_vif *vif = (struct wilc_vif *)arg; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 3304 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 3305 | if (!vif->hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3306 | netdev_err(vif->ndev, "Driver handler is NULL\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3307 | return; |
| 3308 | } |
| 3309 | |
Glen Lee | 4fd6229 | 2016-02-04 18:15:24 +0900 | [diff] [blame] | 3310 | if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) |
| 3311 | wilc_get_statistics(vif, &vif->wilc->dummy_statistics); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3312 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 3313 | periodic_rssi.data = (unsigned long)vif; |
Leo Kim | 262f55e | 2015-10-15 13:24:58 +0900 | [diff] [blame] | 3314 | mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3315 | } |
| 3316 | |
Chaehyun Lim | 1e995c1 | 2016-01-05 23:06:57 +0900 | [diff] [blame] | 3317 | int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3318 | { |
Chaehyun Lim | 1e995c1 | 2016-01-05 23:06:57 +0900 | [diff] [blame] | 3319 | int result = 0; |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3320 | struct host_if_drv *hif_drv; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 3321 | struct wilc_vif *vif; |
Glen Lee | d5382219 | 2015-10-27 18:27:49 +0900 | [diff] [blame] | 3322 | struct wilc *wilc; |
Glen Lee | 03efae3 | 2015-12-21 14:18:49 +0900 | [diff] [blame] | 3323 | int i; |
Glen Lee | d5382219 | 2015-10-27 18:27:49 +0900 | [diff] [blame] | 3324 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 3325 | vif = netdev_priv(dev); |
| 3326 | wilc = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3327 | |
Leo Kim | ca8540e4 | 2015-10-15 13:25:00 +0900 | [diff] [blame] | 3328 | scan_while_connected = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3329 | |
Chaehyun Lim | 613eaa3 | 2016-03-14 09:40:27 +0900 | [diff] [blame] | 3330 | init_completion(&hif_wait_response); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3331 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3332 | hif_drv = kzalloc(sizeof(struct host_if_drv), GFP_KERNEL); |
| 3333 | if (!hif_drv) { |
Chaehyun Lim | 5b09bd3 | 2015-09-22 18:34:59 +0900 | [diff] [blame] | 3334 | result = -ENOMEM; |
Vincent Stehlé | 17db84e | 2015-10-07 07:08:25 +0200 | [diff] [blame] | 3335 | goto _fail_; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3336 | } |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3337 | *hif_drv_handler = hif_drv; |
Glen Lee | 03efae3 | 2015-12-21 14:18:49 +0900 | [diff] [blame] | 3338 | for (i = 0; i < wilc->vif_num; i++) |
| 3339 | if (dev == wilc->vif[i]->ndev) { |
| 3340 | wilc->vif[i]->hif_drv = hif_drv; |
| 3341 | break; |
| 3342 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3343 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 3344 | wilc_optaining_ip = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3345 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3346 | if (clients_count == 0) { |
Chaehyun Lim | 04dd9a4 | 2016-03-23 21:28:33 +0900 | [diff] [blame] | 3347 | init_completion(&hif_thread_comp); |
Chaehyun Lim | 2bb0258 | 2016-03-23 21:28:34 +0900 | [diff] [blame] | 3348 | init_completion(&hif_driver_comp); |
Chaehyun Lim | 896802a | 2016-03-22 08:39:24 +0900 | [diff] [blame] | 3349 | mutex_init(&hif_deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3350 | } |
| 3351 | |
Alison Schofield | 702962f | 2016-03-14 10:35:41 -0700 | [diff] [blame] | 3352 | init_completion(&hif_drv->comp_test_key_block); |
Alison Schofield | 96adbd2 | 2016-03-14 10:35:05 -0700 | [diff] [blame] | 3353 | init_completion(&hif_drv->comp_test_disconn_block); |
Alison Schofield | 7c8a3dc | 2016-03-14 10:34:39 -0700 | [diff] [blame] | 3354 | init_completion(&hif_drv->comp_get_rssi); |
Alison Schofield | e0c1496 | 2016-03-14 10:34:14 -0700 | [diff] [blame] | 3355 | init_completion(&hif_drv->comp_inactive_time); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3356 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3357 | if (clients_count == 0) { |
Chaehyun Lim | 5b09bd3 | 2015-09-22 18:34:59 +0900 | [diff] [blame] | 3358 | if (result < 0) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3359 | netdev_err(vif->ndev, "Failed to creat MQ\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3360 | goto _fail_; |
| 3361 | } |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 3362 | hif_workqueue = create_singlethread_workqueue("WILC_wq"); |
| 3363 | if (!hif_workqueue) { |
| 3364 | netdev_err(vif->ndev, "Failed to create workqueue\n"); |
| 3365 | result = -ENOMEM; |
Dan Carpenter | 2343682 | 2016-07-16 13:07:55 +0300 | [diff] [blame] | 3366 | goto _fail_; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3367 | } |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 3368 | |
Leo Kim | 262f55e | 2015-10-15 13:24:58 +0900 | [diff] [blame] | 3369 | setup_timer(&periodic_rssi, GetPeriodicRSSI, |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 3370 | (unsigned long)vif); |
Leo Kim | 262f55e | 2015-10-15 13:24:58 +0900 | [diff] [blame] | 3371 | mod_timer(&periodic_rssi, jiffies + msecs_to_jiffies(5000)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3372 | } |
| 3373 | |
Leo Kim | 13b313e | 2015-10-29 11:58:34 +0900 | [diff] [blame] | 3374 | setup_timer(&hif_drv->scan_timer, TimerCB_Scan, 0); |
Leo Kim | 81a5950 | 2015-10-29 11:58:35 +0900 | [diff] [blame] | 3375 | setup_timer(&hif_drv->connect_timer, TimerCB_Connect, 0); |
Leo Kim | cc2d7e9 | 2015-10-29 11:58:36 +0900 | [diff] [blame] | 3376 | setup_timer(&hif_drv->remain_on_ch_timer, ListenTimerCB, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3377 | |
Chaehyun Lim | 1f12f14 | 2016-03-08 10:04:32 +0900 | [diff] [blame] | 3378 | mutex_init(&hif_drv->cfg_values_lock); |
| 3379 | mutex_lock(&hif_drv->cfg_values_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3380 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 3381 | hif_drv->hif_state = HOST_IF_IDLE; |
Leo Kim | ace303f | 2015-10-29 11:58:26 +0900 | [diff] [blame] | 3382 | hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF; |
| 3383 | hif_drv->cfg_values.scan_source = DEFAULT_SCAN; |
| 3384 | hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME; |
| 3385 | hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME; |
| 3386 | hif_drv->cfg_values.curr_tx_rate = AUTORATE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3387 | |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 3388 | hif_drv->p2p_timeout = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3389 | |
Chaehyun Lim | 1f12f14 | 2016-03-08 10:04:32 +0900 | [diff] [blame] | 3390 | mutex_unlock(&hif_drv->cfg_values_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3391 | |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3392 | clients_count++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3393 | |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 3394 | destroy_workqueue(hif_workqueue); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3395 | _fail_: |
Chaehyun Lim | 5b09bd3 | 2015-09-22 18:34:59 +0900 | [diff] [blame] | 3396 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3397 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3398 | |
Chaehyun Lim | 127a27c | 2016-02-05 10:35:13 +0900 | [diff] [blame] | 3399 | int wilc_deinit(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3400 | { |
Chaehyun Lim | 127a27c | 2016-02-05 10:35:13 +0900 | [diff] [blame] | 3401 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3402 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3403 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3404 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3405 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3406 | netdev_err(vif->ndev, "hif_drv = NULL\n"); |
Chaehyun Lim | 8eb62f3 | 2016-02-05 10:35:14 +0900 | [diff] [blame] | 3407 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3408 | } |
| 3409 | |
Chaehyun Lim | 896802a | 2016-03-22 08:39:24 +0900 | [diff] [blame] | 3410 | mutex_lock(&hif_deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3411 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3412 | terminated_handle = hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3413 | |
Chris Park | c4f9752 | 2016-02-04 18:24:04 +0900 | [diff] [blame] | 3414 | del_timer_sync(&hif_drv->scan_timer); |
| 3415 | del_timer_sync(&hif_drv->connect_timer); |
| 3416 | del_timer_sync(&periodic_rssi); |
Leo Kim | cc2d7e9 | 2015-10-29 11:58:36 +0900 | [diff] [blame] | 3417 | del_timer_sync(&hif_drv->remain_on_ch_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3418 | |
Glen Lee | b330686 | 2016-02-04 18:15:18 +0900 | [diff] [blame] | 3419 | wilc_set_wfi_drv_handler(vif, 0, 0); |
Chaehyun Lim | 2bb0258 | 2016-03-23 21:28:34 +0900 | [diff] [blame] | 3420 | wait_for_completion(&hif_driver_comp); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3421 | |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 3422 | if (hif_drv->usr_scan_req.scan_result) { |
| 3423 | hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL, |
Leo Kim | 66eaea3 | 2015-10-29 11:58:51 +0900 | [diff] [blame] | 3424 | hif_drv->usr_scan_req.arg, NULL); |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 3425 | hif_drv->usr_scan_req.scan_result = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3426 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3427 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 3428 | hif_drv->hif_state = HOST_IF_IDLE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3429 | |
Leo Kim | ca8540e4 | 2015-10-15 13:25:00 +0900 | [diff] [blame] | 3430 | scan_while_connected = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3431 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3432 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3433 | |
| 3434 | if (clients_count == 1) { |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3435 | msg.id = HOST_IF_MSG_EXIT; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3436 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3437 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3438 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3439 | if (result != 0) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3440 | netdev_err(vif->ndev, "deinit : Error(%d)\n", result); |
Leo Kim | 27e1f13 | 2016-04-01 17:44:13 +0900 | [diff] [blame] | 3441 | else |
| 3442 | wait_for_completion(&hif_thread_comp); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3443 | |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 3444 | destroy_workqueue(hif_workqueue); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3445 | } |
| 3446 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3447 | kfree(hif_drv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3448 | |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3449 | clients_count--; |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 3450 | terminated_handle = NULL; |
Chaehyun Lim | 896802a | 2016-03-22 08:39:24 +0900 | [diff] [blame] | 3451 | mutex_unlock(&hif_deinit_lock); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3452 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3453 | } |
| 3454 | |
Glen Lee | cd04d22 | 2015-12-21 14:18:42 +0900 | [diff] [blame] | 3455 | void wilc_network_info_received(struct wilc *wilc, u8 *pu8Buffer, |
| 3456 | u32 u32Length) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3457 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3458 | s32 result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3459 | struct host_if_msg msg; |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 3460 | int id; |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3461 | struct host_if_drv *hif_drv = NULL; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3462 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3463 | |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 3464 | id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3465 | vif = wilc_get_vif_from_idx(wilc, id); |
| 3466 | if (!vif) |
| 3467 | return; |
| 3468 | hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3469 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3470 | if (!hif_drv || hif_drv == terminated_handle) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3471 | netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3472 | return; |
| 3473 | } |
| 3474 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3475 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3476 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3477 | msg.id = HOST_IF_MSG_RCVD_NTWRK_INFO; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3478 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3479 | |
Leo Kim | 3bffac6 | 2015-10-13 20:02:11 +0900 | [diff] [blame] | 3480 | msg.body.net_info.len = u32Length; |
Leo Kim | b021b80 | 2015-10-13 20:02:10 +0900 | [diff] [blame] | 3481 | msg.body.net_info.buffer = kmalloc(u32Length, GFP_KERNEL); |
| 3482 | memcpy(msg.body.net_info.buffer, pu8Buffer, u32Length); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3483 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3484 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3485 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3486 | netdev_err(vif->ndev, "message parameters (%d)\n", result); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3487 | } |
| 3488 | |
Glen Lee | cd04d22 | 2015-12-21 14:18:42 +0900 | [diff] [blame] | 3489 | void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *pu8Buffer, |
| 3490 | u32 u32Length) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3491 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3492 | s32 result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3493 | struct host_if_msg msg; |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 3494 | int id; |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3495 | struct host_if_drv *hif_drv = NULL; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3496 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3497 | |
Chaehyun Lim | 896802a | 2016-03-22 08:39:24 +0900 | [diff] [blame] | 3498 | mutex_lock(&hif_deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3499 | |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 3500 | id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3501 | vif = wilc_get_vif_from_idx(wilc, id); |
| 3502 | if (!vif) { |
Chaehyun Lim | 896802a | 2016-03-22 08:39:24 +0900 | [diff] [blame] | 3503 | mutex_unlock(&hif_deinit_lock); |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3504 | return; |
| 3505 | } |
| 3506 | |
| 3507 | hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3508 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3509 | if (!hif_drv || hif_drv == terminated_handle) { |
Chaehyun Lim | 896802a | 2016-03-22 08:39:24 +0900 | [diff] [blame] | 3510 | mutex_unlock(&hif_deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3511 | return; |
| 3512 | } |
| 3513 | |
Leo Kim | 33bfb19 | 2015-10-29 11:58:56 +0900 | [diff] [blame] | 3514 | if (!hif_drv->usr_conn_req.conn_result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3515 | netdev_err(vif->ndev, "there is no current Connect Request\n"); |
Chaehyun Lim | 896802a | 2016-03-22 08:39:24 +0900 | [diff] [blame] | 3516 | mutex_unlock(&hif_deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3517 | return; |
| 3518 | } |
| 3519 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3520 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3521 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3522 | msg.id = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3523 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3524 | |
Leo Kim | f94f488 | 2015-10-13 19:50:01 +0900 | [diff] [blame] | 3525 | msg.body.async_info.len = u32Length; |
Leo Kim | 33722ac7 | 2015-10-13 19:50:00 +0900 | [diff] [blame] | 3526 | msg.body.async_info.buffer = kmalloc(u32Length, GFP_KERNEL); |
| 3527 | memcpy(msg.body.async_info.buffer, pu8Buffer, u32Length); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3528 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3529 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3530 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3531 | netdev_err(vif->ndev, "synchronous info (%d)\n", result); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3532 | |
Chaehyun Lim | 896802a | 2016-03-22 08:39:24 +0900 | [diff] [blame] | 3533 | mutex_unlock(&hif_deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3534 | } |
| 3535 | |
Glen Lee | cd04d22 | 2015-12-21 14:18:42 +0900 | [diff] [blame] | 3536 | void wilc_scan_complete_received(struct wilc *wilc, u8 *pu8Buffer, |
| 3537 | u32 u32Length) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3538 | { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3539 | s32 result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3540 | struct host_if_msg msg; |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 3541 | int id; |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3542 | struct host_if_drv *hif_drv = NULL; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3543 | struct wilc_vif *vif; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 3544 | |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 3545 | id = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24)); |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3546 | vif = wilc_get_vif_from_idx(wilc, id); |
| 3547 | if (!vif) |
| 3548 | return; |
| 3549 | hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3550 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3551 | if (!hif_drv || hif_drv == terminated_handle) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3552 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3553 | |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 3554 | if (hif_drv->usr_scan_req.scan_result) { |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3555 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3556 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3557 | msg.id = HOST_IF_MSG_RCVD_SCAN_COMPLETE; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 3558 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3559 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3560 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3561 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3562 | netdev_err(vif->ndev, "complete param (%d)\n", result); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3563 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3564 | } |
| 3565 | |
Chaehyun Lim | 6f7584b | 2016-01-03 17:35:35 +0900 | [diff] [blame] | 3566 | int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, |
Chaehyun Lim | d44cd45 | 2016-01-03 17:35:36 +0900 | [diff] [blame] | 3567 | u32 duration, u16 chan, |
Chaehyun Lim | 95bfdd5 | 2016-01-03 17:35:37 +0900 | [diff] [blame] | 3568 | wilc_remain_on_chan_expired expired, |
Chaehyun Lim | 1aae939 | 2016-01-03 17:35:38 +0900 | [diff] [blame] | 3569 | wilc_remain_on_chan_ready ready, |
Chaehyun Lim | 482c433 | 2016-01-03 17:35:39 +0900 | [diff] [blame] | 3570 | void *user_arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3571 | { |
Chaehyun Lim | 6d6bc40 | 2016-01-03 17:35:34 +0900 | [diff] [blame] | 3572 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3573 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3574 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3575 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3576 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3577 | msg.id = HOST_IF_MSG_REMAIN_ON_CHAN; |
Leo Kim | 839ab70 | 2015-10-29 11:58:41 +0900 | [diff] [blame] | 3578 | msg.body.remain_on_ch.ch = chan; |
Chaehyun Lim | 95bfdd5 | 2016-01-03 17:35:37 +0900 | [diff] [blame] | 3579 | msg.body.remain_on_ch.expired = expired; |
Chaehyun Lim | 1aae939 | 2016-01-03 17:35:38 +0900 | [diff] [blame] | 3580 | msg.body.remain_on_ch.ready = ready; |
Chaehyun Lim | 482c433 | 2016-01-03 17:35:39 +0900 | [diff] [blame] | 3581 | msg.body.remain_on_ch.arg = user_arg; |
Chaehyun Lim | d44cd45 | 2016-01-03 17:35:36 +0900 | [diff] [blame] | 3582 | msg.body.remain_on_ch.duration = duration; |
Chaehyun Lim | 6f7584b | 2016-01-03 17:35:35 +0900 | [diff] [blame] | 3583 | msg.body.remain_on_ch.id = session_id; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3584 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3585 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3586 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3587 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3588 | netdev_err(vif->ndev, "wilc mq send fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3589 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3590 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3591 | } |
| 3592 | |
Chaehyun Lim | 6b0f7cd | 2015-12-30 21:15:29 +0900 | [diff] [blame] | 3593 | int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3594 | { |
Chaehyun Lim | 5ca581e | 2015-12-30 21:15:28 +0900 | [diff] [blame] | 3595 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3596 | struct host_if_msg msg; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3597 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3598 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 3599 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3600 | netdev_err(vif->ndev, "driver is null\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3601 | return -EFAULT; |
| 3602 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3603 | |
Leo Kim | cc2d7e9 | 2015-10-29 11:58:36 +0900 | [diff] [blame] | 3604 | del_timer(&hif_drv->remain_on_ch_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3605 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3606 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3607 | msg.id = HOST_IF_MSG_LISTEN_TIMER_FIRED; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3608 | msg.vif = vif; |
Chaehyun Lim | 6b0f7cd | 2015-12-30 21:15:29 +0900 | [diff] [blame] | 3609 | msg.body.remain_on_ch.id = session_id; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3610 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3611 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3612 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3613 | netdev_err(vif->ndev, "wilc mq send fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3614 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3615 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3616 | } |
| 3617 | |
Chaehyun Lim | 8859fc2 | 2015-12-30 21:15:27 +0900 | [diff] [blame] | 3618 | int wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3619 | { |
Chaehyun Lim | de61db9 | 2015-12-30 21:15:25 +0900 | [diff] [blame] | 3620 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3621 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3622 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3623 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3624 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3625 | msg.id = HOST_IF_MSG_REGISTER_FRAME; |
Chaehyun Lim | 2a8432f | 2015-12-30 21:15:26 +0900 | [diff] [blame] | 3626 | switch (frame_type) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3627 | case ACTION: |
Leo Kim | bcb410b | 2015-10-29 11:58:40 +0900 | [diff] [blame] | 3628 | msg.body.reg_frame.reg_id = ACTION_FRM_IDX; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3629 | break; |
| 3630 | |
| 3631 | case PROBE_REQ: |
Leo Kim | bcb410b | 2015-10-29 11:58:40 +0900 | [diff] [blame] | 3632 | msg.body.reg_frame.reg_id = PROBE_REQ_IDX; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3633 | break; |
| 3634 | |
| 3635 | default: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3636 | break; |
| 3637 | } |
Chaehyun Lim | 2a8432f | 2015-12-30 21:15:26 +0900 | [diff] [blame] | 3638 | msg.body.reg_frame.frame_type = frame_type; |
Chaehyun Lim | 8859fc2 | 2015-12-30 21:15:27 +0900 | [diff] [blame] | 3639 | msg.body.reg_frame.reg = reg; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3640 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3641 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3642 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3643 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3644 | netdev_err(vif->ndev, "wilc mq send fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3645 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3646 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3647 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3648 | |
Chaehyun Lim | 916935f | 2016-01-03 17:35:57 +0900 | [diff] [blame] | 3649 | int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, |
Chaehyun Lim | 733d103 | 2016-01-03 17:36:01 +0900 | [diff] [blame] | 3650 | u32 head_len, u8 *head, u32 tail_len, u8 *tail) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3651 | { |
Chaehyun Lim | 4d84dbe | 2016-01-03 17:35:55 +0900 | [diff] [blame] | 3652 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3653 | struct host_if_msg msg; |
Chaehyun Lim | 75bf22c | 2016-01-03 17:36:02 +0900 | [diff] [blame] | 3654 | struct beacon_attr *beacon_info = &msg.body.beacon_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3655 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3656 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3657 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3658 | msg.id = HOST_IF_MSG_ADD_BEACON; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3659 | msg.vif = vif; |
Chaehyun Lim | 75bf22c | 2016-01-03 17:36:02 +0900 | [diff] [blame] | 3660 | beacon_info->interval = interval; |
| 3661 | beacon_info->dtim_period = dtim_period; |
| 3662 | beacon_info->head_len = head_len; |
| 3663 | beacon_info->head = kmemdup(head, head_len, GFP_KERNEL); |
| 3664 | if (!beacon_info->head) { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3665 | result = -ENOMEM; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3666 | goto ERRORHANDLER; |
| 3667 | } |
Chaehyun Lim | 75bf22c | 2016-01-03 17:36:02 +0900 | [diff] [blame] | 3668 | beacon_info->tail_len = tail_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3669 | |
Chaehyun Lim | 2df3585 | 2016-01-03 17:36:00 +0900 | [diff] [blame] | 3670 | if (tail_len > 0) { |
Chaehyun Lim | 75bf22c | 2016-01-03 17:36:02 +0900 | [diff] [blame] | 3671 | beacon_info->tail = kmemdup(tail, tail_len, GFP_KERNEL); |
| 3672 | if (!beacon_info->tail) { |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3673 | result = -ENOMEM; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3674 | goto ERRORHANDLER; |
| 3675 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3676 | } else { |
Chaehyun Lim | 75bf22c | 2016-01-03 17:36:02 +0900 | [diff] [blame] | 3677 | beacon_info->tail = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3678 | } |
| 3679 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3680 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3681 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3682 | netdev_err(vif->ndev, "wilc mq send fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3683 | |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3684 | ERRORHANDLER: |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3685 | if (result) { |
Chaehyun Lim | 75bf22c | 2016-01-03 17:36:02 +0900 | [diff] [blame] | 3686 | kfree(beacon_info->head); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3687 | |
Chaehyun Lim | 75bf22c | 2016-01-03 17:36:02 +0900 | [diff] [blame] | 3688 | kfree(beacon_info->tail); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3689 | } |
| 3690 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3691 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3692 | } |
| 3693 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3694 | int wilc_del_beacon(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3695 | { |
Chaehyun Lim | 0a5298c | 2015-11-06 19:11:10 +0900 | [diff] [blame] | 3696 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3697 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3698 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3699 | msg.id = HOST_IF_MSG_DEL_BEACON; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3700 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3701 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3702 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3703 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3704 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3705 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3706 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3707 | } |
| 3708 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3709 | int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3710 | { |
Chaehyun Lim | 18cfbd3 | 2015-11-06 19:11:16 +0900 | [diff] [blame] | 3711 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3712 | struct host_if_msg msg; |
Chaehyun Lim | 773e02e | 2015-11-06 19:11:19 +0900 | [diff] [blame] | 3713 | struct add_sta_param *add_sta_info = &msg.body.add_sta_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3714 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3715 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3716 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3717 | msg.id = HOST_IF_MSG_ADD_STATION; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3718 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3719 | |
Chaehyun Lim | 773e02e | 2015-11-06 19:11:19 +0900 | [diff] [blame] | 3720 | memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param)); |
| 3721 | if (add_sta_info->rates_len > 0) { |
Chaehyun Lim | 9062305 | 2015-11-06 19:11:21 +0900 | [diff] [blame] | 3722 | add_sta_info->rates = kmemdup(sta_param->rates, |
| 3723 | add_sta_info->rates_len, |
| 3724 | GFP_KERNEL); |
| 3725 | if (!add_sta_info->rates) |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3726 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3727 | } |
| 3728 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3729 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3730 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3731 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3732 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3733 | } |
| 3734 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 3735 | int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3736 | { |
Chaehyun Lim | 79a0c0a | 2015-11-06 19:11:12 +0900 | [diff] [blame] | 3737 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3738 | struct host_if_msg msg; |
Chaehyun Lim | c87fbed | 2015-11-06 19:11:15 +0900 | [diff] [blame] | 3739 | struct del_sta *del_sta_info = &msg.body.del_sta_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3740 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3741 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3742 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3743 | msg.id = HOST_IF_MSG_DEL_STATION; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3744 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3745 | |
Chaehyun Lim | c9c4eb4 | 2015-11-06 19:11:14 +0900 | [diff] [blame] | 3746 | if (!mac_addr) |
Chaehyun Lim | c87fbed | 2015-11-06 19:11:15 +0900 | [diff] [blame] | 3747 | eth_broadcast_addr(del_sta_info->mac_addr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3748 | else |
Chaehyun Lim | c87fbed | 2015-11-06 19:11:15 +0900 | [diff] [blame] | 3749 | memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3750 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3751 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3752 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3753 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3754 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3755 | } |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3756 | |
Chaehyun Lim | 2092374d | 2016-01-03 17:35:50 +0900 | [diff] [blame] | 3757 | int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3758 | { |
Chaehyun Lim | 253eb92 | 2016-01-03 17:35:49 +0900 | [diff] [blame] | 3759 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3760 | struct host_if_msg msg; |
Chaehyun Lim | 55d44a6 | 2016-01-03 17:35:51 +0900 | [diff] [blame] | 3761 | struct del_all_sta *del_all_sta_info = &msg.body.del_all_sta_info; |
Chaehyun Lim | 06e682b | 2016-01-03 17:35:52 +0900 | [diff] [blame] | 3762 | u8 zero_addr[ETH_ALEN] = {0}; |
Chaehyun Lim | cc971ee | 2016-01-03 17:35:53 +0900 | [diff] [blame] | 3763 | int i; |
Chaehyun Lim | 9d6cec9 | 2016-01-03 17:35:54 +0900 | [diff] [blame] | 3764 | u8 assoc_sta = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3765 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3766 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3767 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3768 | msg.id = HOST_IF_MSG_DEL_ALL_STA; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3769 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3770 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3771 | for (i = 0; i < MAX_NUM_STA; i++) { |
Chaehyun Lim | 06e682b | 2016-01-03 17:35:52 +0900 | [diff] [blame] | 3772 | if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) { |
Chaehyun Lim | 55d44a6 | 2016-01-03 17:35:51 +0900 | [diff] [blame] | 3773 | memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN); |
Chaehyun Lim | 9d6cec9 | 2016-01-03 17:35:54 +0900 | [diff] [blame] | 3774 | assoc_sta++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3775 | } |
| 3776 | } |
Chris Park | 9ac0c05 | 2016-02-22 13:11:56 +0900 | [diff] [blame] | 3777 | if (!assoc_sta) |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3778 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3779 | |
Chaehyun Lim | 9d6cec9 | 2016-01-03 17:35:54 +0900 | [diff] [blame] | 3780 | del_all_sta_info->assoc_sta = assoc_sta; |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3781 | result = wilc_enqueue_cmd(&msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3782 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3783 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3784 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Leo Kim | 27e1f13 | 2016-04-01 17:44:13 +0900 | [diff] [blame] | 3785 | else |
| 3786 | wait_for_completion(&hif_wait_response); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3787 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3788 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3789 | } |
| 3790 | |
Chaehyun Lim | 4208e66 | 2016-01-03 17:35:44 +0900 | [diff] [blame] | 3791 | int wilc_edit_station(struct wilc_vif *vif, |
Chaehyun Lim | 4c7abe1 | 2016-01-03 17:35:45 +0900 | [diff] [blame] | 3792 | struct add_sta_param *sta_param) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3793 | { |
Chaehyun Lim | 4208e66 | 2016-01-03 17:35:44 +0900 | [diff] [blame] | 3794 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3795 | struct host_if_msg msg; |
Chaehyun Lim | 785c071 | 2016-01-03 17:35:46 +0900 | [diff] [blame] | 3796 | struct add_sta_param *add_sta_info = &msg.body.add_sta_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3797 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3798 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3799 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3800 | msg.id = HOST_IF_MSG_EDIT_STATION; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3801 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3802 | |
Chaehyun Lim | 785c071 | 2016-01-03 17:35:46 +0900 | [diff] [blame] | 3803 | memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param)); |
| 3804 | if (add_sta_info->rates_len > 0) { |
Chaehyun Lim | e38d850 | 2016-01-03 17:35:48 +0900 | [diff] [blame] | 3805 | add_sta_info->rates = kmemdup(sta_param->rates, |
| 3806 | add_sta_info->rates_len, |
| 3807 | GFP_KERNEL); |
| 3808 | if (!add_sta_info->rates) |
Leo Kim | 7ae4336 | 2015-09-16 18:35:59 +0900 | [diff] [blame] | 3809 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3810 | } |
| 3811 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3812 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3813 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3814 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 3815 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3816 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3817 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 3818 | |
Chaehyun Lim | ecd2750 | 2015-12-30 21:15:32 +0900 | [diff] [blame] | 3819 | int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3820 | { |
Chaehyun Lim | 5d48f12 | 2015-12-30 21:15:30 +0900 | [diff] [blame] | 3821 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3822 | struct host_if_msg msg; |
Chaehyun Lim | 568640e | 2015-12-30 21:15:33 +0900 | [diff] [blame] | 3823 | struct power_mgmt_param *pwr_mgmt_info = &msg.body.pwr_mgmt_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3824 | |
Glen Lee | ff9d65a | 2016-02-04 18:15:20 +0900 | [diff] [blame] | 3825 | if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled) |
| 3826 | return 0; |
| 3827 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3828 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3829 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3830 | msg.id = HOST_IF_MSG_POWER_MGMT; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3831 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3832 | |
Chaehyun Lim | 568640e | 2015-12-30 21:15:33 +0900 | [diff] [blame] | 3833 | pwr_mgmt_info->enabled = enabled; |
| 3834 | pwr_mgmt_info->timeout = timeout; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3835 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3836 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3837 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3838 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3839 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3840 | } |
| 3841 | |
Chaehyun Lim | b80c094 | 2015-12-30 21:15:35 +0900 | [diff] [blame] | 3842 | int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, |
Chaehyun Lim | 2dff2d4 | 2015-12-30 21:15:36 +0900 | [diff] [blame] | 3843 | u32 count) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3844 | { |
Chaehyun Lim | 14d9526 | 2015-12-30 21:15:34 +0900 | [diff] [blame] | 3845 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3846 | struct host_if_msg msg; |
Chaehyun Lim | 40ecd38 | 2015-12-30 21:15:37 +0900 | [diff] [blame] | 3847 | struct set_multicast *multicast_filter_param = &msg.body.multicast_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3848 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 3849 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3850 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 3851 | msg.id = HOST_IF_MSG_SET_MULTICAST_FILTER; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 3852 | msg.vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3853 | |
Chaehyun Lim | 40ecd38 | 2015-12-30 21:15:37 +0900 | [diff] [blame] | 3854 | multicast_filter_param->enabled = enabled; |
| 3855 | multicast_filter_param->cnt = count; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3856 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 3857 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3858 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 3859 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 3860 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3861 | } |
| 3862 | |
Leo Kim | 6b5180a | 2016-02-04 18:24:10 +0900 | [diff] [blame] | 3863 | static void *host_int_ParseJoinBssParam(struct network_info *ptstrNetworkInfo) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3864 | { |
Leo Kim | e0a1221 | 2015-10-12 16:55:49 +0900 | [diff] [blame] | 3865 | struct join_bss_param *pNewJoinBssParam = NULL; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 3866 | u8 *pu8IEs; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 3867 | u16 u16IEsLen; |
| 3868 | u16 index = 0; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 3869 | u8 suppRatesNo = 0; |
| 3870 | u8 extSuppRatesNo; |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 3871 | u16 jumpOffset; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 3872 | u8 pcipherCount; |
| 3873 | u8 authCount; |
| 3874 | u8 pcipherTotalCount = 0; |
| 3875 | u8 authTotalCount = 0; |
| 3876 | u8 i, j; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3877 | |
Leo Kim | 390b6db | 2016-02-04 18:24:23 +0900 | [diff] [blame] | 3878 | pu8IEs = ptstrNetworkInfo->ies; |
| 3879 | u16IEsLen = ptstrNetworkInfo->ies_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3880 | |
Shraddha Barke | b156f1e | 2015-10-13 23:07:00 +0530 | [diff] [blame] | 3881 | pNewJoinBssParam = kzalloc(sizeof(struct join_bss_param), GFP_KERNEL); |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 3882 | if (pNewJoinBssParam) { |
Leo Kim | df340fd | 2016-02-04 18:24:17 +0900 | [diff] [blame] | 3883 | pNewJoinBssParam->dtim_period = ptstrNetworkInfo->dtim_period; |
Leo Kim | 4b313e9 | 2016-02-04 18:24:16 +0900 | [diff] [blame] | 3884 | pNewJoinBssParam->beacon_period = ptstrNetworkInfo->beacon_period; |
Leo Kim | fa5e2d1 | 2016-02-04 18:24:12 +0900 | [diff] [blame] | 3885 | pNewJoinBssParam->cap_info = ptstrNetworkInfo->cap_info; |
Chaehyun Lim | f176429 | 2016-02-12 23:04:37 +0900 | [diff] [blame] | 3886 | memcpy(pNewJoinBssParam->bssid, ptstrNetworkInfo->bssid, 6); |
Leo Kim | 2a3ff58 | 2016-02-04 18:24:13 +0900 | [diff] [blame] | 3887 | memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->ssid, |
Leo Kim | a36e89e | 2016-02-04 18:24:14 +0900 | [diff] [blame] | 3888 | ptstrNetworkInfo->ssid_len + 1); |
| 3889 | pNewJoinBssParam->ssid_len = ptstrNetworkInfo->ssid_len; |
Chaehyun Lim | 2cc4683 | 2015-08-07 09:02:01 +0900 | [diff] [blame] | 3890 | memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3); |
| 3891 | memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3892 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3893 | while (index < u16IEsLen) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3894 | if (pu8IEs[index] == SUPP_RATES_IE) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3895 | suppRatesNo = pu8IEs[index + 1]; |
| 3896 | pNewJoinBssParam->supp_rates[0] = suppRatesNo; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3897 | index += 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3898 | |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 3899 | for (i = 0; i < suppRatesNo; i++) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3900 | pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i]; |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 3901 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3902 | index += suppRatesNo; |
| 3903 | continue; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3904 | } else if (pu8IEs[index] == EXT_SUPP_RATES_IE) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3905 | extSuppRatesNo = pu8IEs[index + 1]; |
| 3906 | if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo)) |
| 3907 | pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED; |
| 3908 | else |
| 3909 | pNewJoinBssParam->supp_rates[0] += extSuppRatesNo; |
| 3910 | index += 2; |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 3911 | for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3912 | pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i]; |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 3913 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3914 | index += extSuppRatesNo; |
| 3915 | continue; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3916 | } else if (pu8IEs[index] == HT_CAPABILITY_IE) { |
Chaehyun Lim | 0be1eb7 | 2015-06-13 15:41:18 +0900 | [diff] [blame] | 3917 | pNewJoinBssParam->ht_capable = true; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3918 | index += pu8IEs[index + 1] + 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3919 | continue; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3920 | } else if ((pu8IEs[index] == WMM_IE) && |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3921 | (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) && |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3922 | (pu8IEs[index + 4] == 0xF2) && |
| 3923 | (pu8IEs[index + 5] == 0x02) && |
| 3924 | ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3925 | (pu8IEs[index + 7] == 0x01)) { |
Chaehyun Lim | 0be1eb7 | 2015-06-13 15:41:18 +0900 | [diff] [blame] | 3926 | pNewJoinBssParam->wmm_cap = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3927 | |
Anish Bhatt | ffda203 | 2015-09-29 12:15:49 -0700 | [diff] [blame] | 3928 | if (pu8IEs[index + 8] & BIT(7)) |
Chaehyun Lim | 0be1eb7 | 2015-06-13 15:41:18 +0900 | [diff] [blame] | 3929 | pNewJoinBssParam->uapsd_cap = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3930 | index += pu8IEs[index + 1] + 2; |
| 3931 | continue; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3932 | } else if ((pu8IEs[index] == P2P_IE) && |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3933 | (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) && |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3934 | (pu8IEs[index + 4] == 0x9a) && |
| 3935 | (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 3936 | u16 u16P2P_count; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 3937 | |
Leo Kim | afb7065 | 2016-02-04 18:24:22 +0900 | [diff] [blame] | 3938 | pNewJoinBssParam->tsf = ptstrNetworkInfo->tsf_lo; |
Leo Kim | 7a8d51d | 2015-10-15 13:24:43 +0900 | [diff] [blame] | 3939 | pNewJoinBssParam->noa_enabled = 1; |
Leo Kim | cc17900 | 2015-10-15 13:24:47 +0900 | [diff] [blame] | 3940 | pNewJoinBssParam->idx = pu8IEs[index + 9]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3941 | |
Anish Bhatt | ffda203 | 2015-09-29 12:15:49 -0700 | [diff] [blame] | 3942 | if (pu8IEs[index + 10] & BIT(7)) { |
Leo Kim | d72b33c | 2015-10-15 13:24:44 +0900 | [diff] [blame] | 3943 | pNewJoinBssParam->opp_enabled = 1; |
Leo Kim | 99b6694 | 2015-10-15 13:24:45 +0900 | [diff] [blame] | 3944 | pNewJoinBssParam->ct_window = pu8IEs[index + 10]; |
Leo Kim | d72b33c | 2015-10-15 13:24:44 +0900 | [diff] [blame] | 3945 | } else { |
| 3946 | pNewJoinBssParam->opp_enabled = 0; |
| 3947 | } |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3948 | |
Leo Kim | c21047e | 2015-10-15 13:24:46 +0900 | [diff] [blame] | 3949 | pNewJoinBssParam->cnt = pu8IEs[index + 11]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3950 | u16P2P_count = index + 12; |
| 3951 | |
Leo Kim | 109e6ca | 2015-10-15 13:24:48 +0900 | [diff] [blame] | 3952 | memcpy(pNewJoinBssParam->duration, pu8IEs + u16P2P_count, 4); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3953 | u16P2P_count += 4; |
| 3954 | |
Leo Kim | 1d8b76b | 2015-10-15 13:24:49 +0900 | [diff] [blame] | 3955 | memcpy(pNewJoinBssParam->interval, pu8IEs + u16P2P_count, 4); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3956 | u16P2P_count += 4; |
| 3957 | |
Leo Kim | 4be55e2 | 2015-10-28 15:59:27 +0900 | [diff] [blame] | 3958 | memcpy(pNewJoinBssParam->start_time, pu8IEs + u16P2P_count, 4); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3959 | |
| 3960 | index += pu8IEs[index + 1] + 2; |
| 3961 | continue; |
| 3962 | |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3963 | } else if ((pu8IEs[index] == RSN_IE) || |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3964 | ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) && |
| 3965 | (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) && |
| 3966 | (pu8IEs[index + 5] == 0x01))) { |
Chaehyun Lim | d85f532 | 2015-06-11 14:35:54 +0900 | [diff] [blame] | 3967 | u16 rsnIndex = index; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3968 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3969 | if (pu8IEs[rsnIndex] == RSN_IE) { |
| 3970 | pNewJoinBssParam->mode_802_11i = 2; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3971 | } else { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3972 | if (pNewJoinBssParam->mode_802_11i == 0) |
| 3973 | pNewJoinBssParam->mode_802_11i = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3974 | rsnIndex += 4; |
| 3975 | } |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3976 | |
| 3977 | rsnIndex += 7; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3978 | pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex]; |
| 3979 | rsnIndex++; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3980 | jumpOffset = pu8IEs[rsnIndex] * 4; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3981 | pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex]; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3982 | rsnIndex += 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3983 | |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 3984 | for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3985 | pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1]; |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 3986 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3987 | pcipherTotalCount += pcipherCount; |
| 3988 | rsnIndex += jumpOffset; |
| 3989 | |
| 3990 | jumpOffset = pu8IEs[rsnIndex] * 4; |
| 3991 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3992 | authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex]; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 3993 | rsnIndex += 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3994 | |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 3995 | for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3996 | pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1]; |
Leo Kim | d1666e2 | 2015-10-28 15:59:22 +0900 | [diff] [blame] | 3997 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 3998 | authTotalCount += authCount; |
| 3999 | rsnIndex += jumpOffset; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 4000 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4001 | if (pu8IEs[index] == RSN_IE) { |
| 4002 | pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex]; |
| 4003 | pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1]; |
| 4004 | rsnIndex += 2; |
| 4005 | } |
Abdul Hussain | f717c0eb | 2015-06-16 09:49:49 +0000 | [diff] [blame] | 4006 | pNewJoinBssParam->rsn_found = true; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 4007 | index += pu8IEs[index + 1] + 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4008 | continue; |
| 4009 | } else |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 4010 | index += pu8IEs[index + 1] + 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4011 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4012 | } |
| 4013 | |
| 4014 | return (void *)pNewJoinBssParam; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4015 | } |
| 4016 | |
Chaehyun Lim | 6964f08 | 2015-12-30 21:15:39 +0900 | [diff] [blame] | 4017 | int wilc_setup_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4018 | { |
Chaehyun Lim | 3d2a0bf | 2015-12-30 21:15:38 +0900 | [diff] [blame] | 4019 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 4020 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4021 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 4022 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4023 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 4024 | msg.id = HOST_IF_MSG_SET_IPADDRESS; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4025 | |
Chaehyun Lim | 6964f08 | 2015-12-30 21:15:39 +0900 | [diff] [blame] | 4026 | msg.body.ip_info.ip_addr = ip_addr; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 4027 | msg.vif = vif; |
Tony Cho | fb2d65e | 2015-09-30 18:44:39 +0900 | [diff] [blame] | 4028 | msg.body.ip_info.idx = idx; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4029 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 4030 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 4031 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 4032 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4033 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 4034 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4035 | } |
| 4036 | |
Chaehyun Lim | 3b4276d | 2015-12-30 21:15:43 +0900 | [diff] [blame] | 4037 | static int host_int_get_ipaddress(struct wilc_vif *vif, u8 *ip_addr, u8 idx) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4038 | { |
Chaehyun Lim | cb8f4e0 | 2015-12-30 21:15:41 +0900 | [diff] [blame] | 4039 | int result = 0; |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 4040 | struct host_if_msg msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4041 | |
Tony Cho | 143eb95 | 2015-09-21 12:16:32 +0900 | [diff] [blame] | 4042 | memset(&msg, 0, sizeof(struct host_if_msg)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4043 | |
Tony Cho | a9f812a | 2015-09-21 12:16:33 +0900 | [diff] [blame] | 4044 | msg.id = HOST_IF_MSG_GET_IPADDRESS; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4045 | |
Chaehyun Lim | 3b4276d | 2015-12-30 21:15:43 +0900 | [diff] [blame] | 4046 | msg.body.ip_info.ip_addr = ip_addr; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 4047 | msg.vif = vif; |
Tony Cho | fb2d65e | 2015-09-30 18:44:39 +0900 | [diff] [blame] | 4048 | msg.body.ip_info.idx = idx; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4049 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 4050 | result = wilc_enqueue_cmd(&msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 4051 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 4052 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4053 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 4054 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4055 | } |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 4056 | |
| 4057 | int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) |
| 4058 | { |
| 4059 | int ret = 0; |
| 4060 | struct host_if_msg msg; |
| 4061 | |
| 4062 | memset(&msg, 0, sizeof(struct host_if_msg)); |
| 4063 | |
| 4064 | msg.id = HOST_IF_MSG_SET_TX_POWER; |
| 4065 | msg.body.tx_power.tx_pwr = tx_power; |
| 4066 | msg.vif = vif; |
| 4067 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 4068 | ret = wilc_enqueue_cmd(&msg); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 4069 | if (ret) |
| 4070 | netdev_err(vif->ndev, "wilc_mq_send fail\n"); |
| 4071 | |
| 4072 | return ret; |
| 4073 | } |
| 4074 | |
| 4075 | int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) |
| 4076 | { |
| 4077 | int ret = 0; |
| 4078 | struct host_if_msg msg; |
| 4079 | |
| 4080 | memset(&msg, 0, sizeof(struct host_if_msg)); |
| 4081 | |
| 4082 | msg.id = HOST_IF_MSG_GET_TX_POWER; |
| 4083 | msg.vif = vif; |
| 4084 | |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 4085 | ret = wilc_enqueue_cmd(&msg); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 4086 | if (ret) |
| 4087 | netdev_err(vif->ndev, "Failed to get TX PWR\n"); |
| 4088 | |
Chaehyun Lim | 613eaa3 | 2016-03-14 09:40:27 +0900 | [diff] [blame] | 4089 | wait_for_completion(&hif_wait_response); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 4090 | *tx_power = msg.body.tx_power.tx_pwr; |
| 4091 | |
| 4092 | return ret; |
| 4093 | } |