Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Ajay Singh | e61c7a1 | 2018-08-03 16:26:13 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. |
| 4 | * All rights reserved. |
| 5 | */ |
| 6 | |
Ajay Singh | 6cecbb2 | 2019-11-05 09:51:25 +0000 | [diff] [blame] | 7 | #include "netdev.h" |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 8 | |
Adham Abozaeid | f5a3cb9 | 2019-06-20 19:54:55 +0000 | [diff] [blame] | 9 | #define WILC_HIF_SCAN_TIMEOUT_MS 5000 |
Ajay Singh | b36b973 | 2019-02-02 19:17:05 +0000 | [diff] [blame] | 10 | #define WILC_HIF_CONNECT_TIMEOUT_MS 9500 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 11 | |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 12 | #define WILC_FALSE_FRMWR_CHANNEL 100 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 13 | |
Oscar Carter | a4338ed | 2020-05-04 17:09:11 +0200 | [diff] [blame] | 14 | #define WILC_SCAN_WID_LIST_SIZE 6 |
| 15 | |
Ajay Singh | 94bb6d3 | 2019-01-17 13:21:35 +0000 | [diff] [blame] | 16 | struct wilc_rcvd_mac_info { |
| 17 | u8 status; |
Tony Cho | f23a9ea | 2015-09-21 12:16:39 +0900 | [diff] [blame] | 18 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 19 | |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 20 | struct wilc_set_multicast { |
| 21 | u32 enabled; |
Leo Kim | adab2f7 | 2015-10-13 20:02:05 +0900 | [diff] [blame] | 22 | u32 cnt; |
Ajay Singh | e624c58 | 2018-09-04 12:09:26 +0530 | [diff] [blame] | 23 | u8 *mc_list; |
Tony Cho | 641210a | 2015-09-21 12:16:52 +0900 | [diff] [blame] | 24 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 25 | |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 26 | struct wilc_del_all_sta { |
Leo Kim | 8ba1803 | 2015-10-13 19:50:10 +0900 | [diff] [blame] | 27 | u8 assoc_sta; |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 28 | u8 mac[WILC_MAX_NUM_STA][ETH_ALEN]; |
Tony Cho | fb93a1e | 2015-09-21 12:16:57 +0900 | [diff] [blame] | 29 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 30 | |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 31 | union wilc_message_body { |
Ajay Singh | 6cd4fa5 | 2019-01-17 13:21:21 +0000 | [diff] [blame] | 32 | struct wilc_rcvd_net_info net_info; |
Ajay Singh | 94bb6d3 | 2019-01-17 13:21:35 +0000 | [diff] [blame] | 33 | struct wilc_rcvd_mac_info mac_info; |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 34 | struct wilc_set_multicast mc_info; |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 35 | struct wilc_remain_ch remain_on_ch; |
Tony Cho | e60831e | 2015-10-05 13:50:45 +0900 | [diff] [blame] | 36 | char *data; |
Tony Cho | dfc7663 | 2015-09-21 12:16:34 +0900 | [diff] [blame] | 37 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 38 | |
Tony Cho | 3a8c41b | 2015-09-18 18:11:04 +0900 | [diff] [blame] | 39 | struct host_if_msg { |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 40 | union wilc_message_body body; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 41 | struct wilc_vif *vif; |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 42 | struct work_struct work; |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 43 | void (*fn)(struct work_struct *ws); |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 44 | struct completion work_comp; |
| 45 | bool is_sync; |
Tony Cho | 3a8c41b | 2015-09-18 18:11:04 +0900 | [diff] [blame] | 46 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 47 | |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 48 | /* 'msg' should be free by the caller for syc */ |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 49 | static struct host_if_msg* |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 50 | wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *), |
| 51 | bool is_sync) |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 52 | { |
| 53 | struct host_if_msg *msg; |
| 54 | |
| 55 | if (!work_fun) |
| 56 | return ERR_PTR(-EINVAL); |
| 57 | |
| 58 | msg = kzalloc(sizeof(*msg), GFP_ATOMIC); |
| 59 | if (!msg) |
| 60 | return ERR_PTR(-ENOMEM); |
| 61 | msg->fn = work_fun; |
| 62 | msg->vif = vif; |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 63 | msg->is_sync = is_sync; |
| 64 | if (is_sync) |
| 65 | init_completion(&msg->work_comp); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 66 | |
| 67 | return msg; |
| 68 | } |
| 69 | |
Ajay Singh | c6a358d | 2018-06-26 11:37:08 +0530 | [diff] [blame] | 70 | static int wilc_enqueue_work(struct host_if_msg *msg) |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 71 | { |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 72 | INIT_WORK(&msg->work, msg->fn); |
Ajay Singh | 87de37f | 2018-09-04 12:09:27 +0530 | [diff] [blame] | 73 | |
| 74 | if (!msg->vif || !msg->vif->wilc || !msg->vif->wilc->hif_workqueue) |
| 75 | return -EINVAL; |
| 76 | |
| 77 | if (!queue_work(msg->vif->wilc->hif_workqueue, &msg->work)) |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 78 | return -EINVAL; |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 79 | |
Binoy Jayan | c6bb38a | 2016-06-23 11:11:50 +0530 | [diff] [blame] | 80 | return 0; |
| 81 | } |
| 82 | |
Ajay Singh | f131bbe | 2018-07-29 11:36:51 +0530 | [diff] [blame] | 83 | /* The idx starts from 0 to (NUM_CONCURRENT_IFC - 1), but 0 index used as |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 84 | * special purpose in wilc device, so we add 1 to the index to starts from 1. |
| 85 | * As a result, the returned index will be 1 to NUM_CONCURRENT_IFC. |
| 86 | */ |
Glen Lee | 31f0f69 | 2015-12-21 14:18:44 +0900 | [diff] [blame] | 87 | int wilc_get_vif_idx(struct wilc_vif *vif) |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 88 | { |
Leo Kim | 6750140 | 2016-02-04 18:15:39 +0900 | [diff] [blame] | 89 | return vif->idx + 1; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | /* We need to minus 1 from idx which is from wilc device to get real index |
| 93 | * of wilc->vif[], because we add 1 when pass to wilc device in the function |
| 94 | * wilc_get_vif_idx. |
Ajay Singh | f131bbe | 2018-07-29 11:36:51 +0530 | [diff] [blame] | 95 | * As a result, the index should be between 0 and (NUM_CONCURRENT_IFC - 1). |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 96 | */ |
| 97 | static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) |
| 98 | { |
| 99 | int index = idx - 1; |
Ajay Singh | 8399918 | 2019-09-26 15:14:59 +0000 | [diff] [blame] | 100 | struct wilc_vif *vif; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 101 | |
Ajay Singh | d0e41ef | 2018-11-12 05:45:29 +0000 | [diff] [blame] | 102 | if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC) |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 103 | return NULL; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 104 | |
Ajay Singh | 8399918 | 2019-09-26 15:14:59 +0000 | [diff] [blame] | 105 | list_for_each_entry_rcu(vif, &wilc->vif_list, list) { |
| 106 | if (vif->idx == index) |
| 107 | return vif; |
| 108 | } |
| 109 | |
| 110 | return NULL; |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 111 | } |
| 112 | |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 113 | static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) |
Ajay Singh | 2653aad | 2018-07-19 04:15:13 +0530 | [diff] [blame] | 114 | { |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 115 | int result = 0; |
Ajay Singh | 2653aad | 2018-07-19 04:15:13 +0530 | [diff] [blame] | 116 | u8 abort_running_scan; |
| 117 | struct wid wid; |
| 118 | struct host_if_drv *hif_drv = vif->hif_drv; |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 119 | struct wilc_user_scan_req *scan_req; |
Ajay Singh | 2653aad | 2018-07-19 04:15:13 +0530 | [diff] [blame] | 120 | |
| 121 | if (evt == SCAN_EVENT_ABORTED) { |
| 122 | abort_running_scan = 1; |
| 123 | wid.id = WID_ABORT_RUNNING_SCAN; |
| 124 | wid.type = WID_CHAR; |
| 125 | wid.val = (s8 *)&abort_running_scan; |
| 126 | wid.size = sizeof(char); |
| 127 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 128 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 2653aad | 2018-07-19 04:15:13 +0530 | [diff] [blame] | 129 | if (result) { |
| 130 | netdev_err(vif->ndev, "Failed to set abort running\n"); |
| 131 | result = -EFAULT; |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | if (!hif_drv) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 136 | netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); |
Ajay Singh | 2653aad | 2018-07-19 04:15:13 +0530 | [diff] [blame] | 137 | return result; |
| 138 | } |
| 139 | |
| 140 | scan_req = &hif_drv->usr_scan_req; |
| 141 | if (scan_req->scan_result) { |
Ajay Singh | 6c2cfb4 | 2019-01-17 13:21:18 +0000 | [diff] [blame] | 142 | scan_req->scan_result(evt, NULL, scan_req->arg); |
Ajay Singh | 2653aad | 2018-07-19 04:15:13 +0530 | [diff] [blame] | 143 | scan_req->scan_result = NULL; |
| 144 | } |
| 145 | |
| 146 | return result; |
| 147 | } |
| 148 | |
Ajay Singh | 8f1a0ac | 2018-12-02 18:03:38 +0000 | [diff] [blame] | 149 | int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, |
Adham Abozaeid | ac118d8 | 2019-03-25 22:27:26 +0000 | [diff] [blame] | 150 | u8 *ch_freq_list, u8 ch_list_len, |
Ajay Singh | 65af887 | 2019-01-17 13:21:44 +0000 | [diff] [blame] | 151 | void (*scan_result_fn)(enum scan_event, |
| 152 | struct wilc_rcvd_net_info *, void *), |
Adham Abozaeid | ac118d8 | 2019-03-25 22:27:26 +0000 | [diff] [blame] | 153 | void *user_arg, struct cfg80211_scan_request *request) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 154 | { |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 155 | int result = 0; |
Oscar Carter | a4338ed | 2020-05-04 17:09:11 +0200 | [diff] [blame] | 156 | struct wid wid_list[WILC_SCAN_WID_LIST_SIZE]; |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 157 | u32 index = 0; |
Adham Abozaeid | f5a3cb9 | 2019-06-20 19:54:55 +0000 | [diff] [blame] | 158 | u32 i, scan_timeout; |
Chaehyun Lim | 2f27ad1 | 2016-04-04 20:04:50 +0900 | [diff] [blame] | 159 | u8 *buffer; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 160 | u8 valuesize = 0; |
Ajay Singh | f47e59e | 2019-01-17 13:21:30 +0000 | [diff] [blame] | 161 | u8 *search_ssid_vals = NULL; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 162 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 163 | |
Ajay Singh | 7bf0242 | 2018-01-22 15:52:14 +0530 | [diff] [blame] | 164 | if (hif_drv->hif_state >= HOST_IF_SCANNING && |
| 165 | hif_drv->hif_state < HOST_IF_CONNECTED) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 166 | netdev_err(vif->ndev, "Already scan\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 167 | result = -EBUSY; |
Ajay Singh | 3e488a9 | 2018-03-07 07:43:52 +0530 | [diff] [blame] | 168 | goto error; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 169 | } |
| 170 | |
Adham Abozaeid | 5a28d3f | 2019-07-25 21:31:34 +0000 | [diff] [blame] | 171 | if (vif->connecting) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 172 | netdev_err(vif->ndev, "Don't do obss scan\n"); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 173 | result = -EBUSY; |
Ajay Singh | 3e488a9 | 2018-03-07 07:43:52 +0530 | [diff] [blame] | 174 | goto error; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 175 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 176 | |
Ajay Singh | 4932807 | 2018-07-29 11:36:55 +0530 | [diff] [blame] | 177 | hif_drv->usr_scan_req.ch_cnt = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 178 | |
Adham Abozaeid | ac118d8 | 2019-03-25 22:27:26 +0000 | [diff] [blame] | 179 | if (request->n_ssids) { |
| 180 | for (i = 0; i < request->n_ssids; i++) |
| 181 | valuesize += ((request->ssids[i].ssid_len) + 1); |
Ajay Singh | f47e59e | 2019-01-17 13:21:30 +0000 | [diff] [blame] | 182 | search_ssid_vals = kmalloc(valuesize + 1, GFP_KERNEL); |
| 183 | if (search_ssid_vals) { |
| 184 | wid_list[index].id = WID_SSID_PROBE_REQ; |
| 185 | wid_list[index].type = WID_STR; |
| 186 | wid_list[index].val = search_ssid_vals; |
Ajay Singh | 0b7b9b6 | 2018-12-15 02:32:29 +0000 | [diff] [blame] | 187 | buffer = wid_list[index].val; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 188 | |
Adham Abozaeid | ac118d8 | 2019-03-25 22:27:26 +0000 | [diff] [blame] | 189 | *buffer++ = request->n_ssids; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 190 | |
Adham Abozaeid | ac118d8 | 2019-03-25 22:27:26 +0000 | [diff] [blame] | 191 | for (i = 0; i < request->n_ssids; i++) { |
| 192 | *buffer++ = request->ssids[i].ssid_len; |
| 193 | memcpy(buffer, request->ssids[i].ssid, |
| 194 | request->ssids[i].ssid_len); |
| 195 | buffer += request->ssids[i].ssid_len; |
Ajay Singh | 0b7b9b6 | 2018-12-15 02:32:29 +0000 | [diff] [blame] | 196 | } |
Ajay Singh | 0b7b9b6 | 2018-12-15 02:32:29 +0000 | [diff] [blame] | 197 | wid_list[index].size = (s32)(valuesize + 1); |
| 198 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 199 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 200 | } |
| 201 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 202 | wid_list[index].id = WID_INFO_ELEMENT_PROBE; |
| 203 | wid_list[index].type = WID_BIN_DATA; |
Adham Abozaeid | ac118d8 | 2019-03-25 22:27:26 +0000 | [diff] [blame] | 204 | wid_list[index].val = (s8 *)request->ie; |
| 205 | wid_list[index].size = request->ie_len; |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 206 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 207 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 208 | wid_list[index].id = WID_SCAN_TYPE; |
| 209 | wid_list[index].type = WID_CHAR; |
| 210 | wid_list[index].size = sizeof(char); |
Ajay Singh | 8f1a0ac | 2018-12-02 18:03:38 +0000 | [diff] [blame] | 211 | wid_list[index].val = (s8 *)&scan_type; |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 212 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 213 | |
Adham Abozaeid | f5a3cb9 | 2019-06-20 19:54:55 +0000 | [diff] [blame] | 214 | if (scan_type == WILC_FW_PASSIVE_SCAN && request->duration) { |
| 215 | wid_list[index].id = WID_PASSIVE_SCAN_TIME; |
| 216 | wid_list[index].type = WID_SHORT; |
| 217 | wid_list[index].size = sizeof(u16); |
| 218 | wid_list[index].val = (s8 *)&request->duration; |
| 219 | index++; |
| 220 | |
| 221 | scan_timeout = (request->duration * ch_list_len) + 500; |
| 222 | } else { |
| 223 | scan_timeout = WILC_HIF_SCAN_TIMEOUT_MS; |
| 224 | } |
| 225 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 226 | wid_list[index].id = WID_SCAN_CHANNEL_LIST; |
| 227 | wid_list[index].type = WID_BIN_DATA; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 228 | |
Ajay Singh | 8f1a0ac | 2018-12-02 18:03:38 +0000 | [diff] [blame] | 229 | if (ch_freq_list && ch_list_len > 0) { |
| 230 | for (i = 0; i < ch_list_len; i++) { |
| 231 | if (ch_freq_list[i] > 0) |
| 232 | ch_freq_list[i] -= 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 233 | } |
| 234 | } |
| 235 | |
Ajay Singh | 8f1a0ac | 2018-12-02 18:03:38 +0000 | [diff] [blame] | 236 | wid_list[index].val = ch_freq_list; |
| 237 | wid_list[index].size = ch_list_len; |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 238 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 239 | |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 240 | wid_list[index].id = WID_START_SCAN_REQ; |
| 241 | wid_list[index].type = WID_CHAR; |
| 242 | wid_list[index].size = sizeof(char); |
Ajay Singh | 8f1a0ac | 2018-12-02 18:03:38 +0000 | [diff] [blame] | 243 | wid_list[index].val = (s8 *)&scan_source; |
Chaehyun Lim | 87b16cb | 2016-04-04 20:04:49 +0900 | [diff] [blame] | 244 | index++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 245 | |
Adham Abozaeid | eab0754 | 2019-03-27 20:28:34 +0000 | [diff] [blame] | 246 | hif_drv->usr_scan_req.scan_result = scan_result_fn; |
| 247 | hif_drv->usr_scan_req.arg = user_arg; |
| 248 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 249 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, index); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 250 | if (result) { |
Ajay Singh | 8f1a0ac | 2018-12-02 18:03:38 +0000 | [diff] [blame] | 251 | netdev_err(vif->ndev, "Failed to send scan parameters\n"); |
| 252 | goto error; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 253 | } |
| 254 | |
Ajay Singh | 8f1a0ac | 2018-12-02 18:03:38 +0000 | [diff] [blame] | 255 | hif_drv->scan_timer_vif = vif; |
| 256 | mod_timer(&hif_drv->scan_timer, |
Adham Abozaeid | f5a3cb9 | 2019-06-20 19:54:55 +0000 | [diff] [blame] | 257 | jiffies + msecs_to_jiffies(scan_timeout)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 258 | |
Ajay Singh | 8f1a0ac | 2018-12-02 18:03:38 +0000 | [diff] [blame] | 259 | error: |
Adham Abozaeid | ac118d8 | 2019-03-25 22:27:26 +0000 | [diff] [blame] | 260 | |
| 261 | kfree(search_ssid_vals); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 262 | |
Ajay Singh | 8f1a0ac | 2018-12-02 18:03:38 +0000 | [diff] [blame] | 263 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 264 | } |
| 265 | |
Ajay Singh | a343cf5 | 2018-12-02 18:03:34 +0000 | [diff] [blame] | 266 | static int wilc_send_connect_wid(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 267 | { |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 268 | int result = 0; |
Adham Abozaeid | 59fb805 | 2019-01-29 18:46:42 +0000 | [diff] [blame] | 269 | struct wid wid_list[4]; |
| 270 | u32 wid_cnt = 0; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 271 | struct host_if_drv *hif_drv = vif->hif_drv; |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 272 | struct wilc_conn_info *conn_attr = &hif_drv->conn_info; |
| 273 | struct wilc_join_bss_param *bss_param = conn_attr->param; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 274 | |
Ajay Singh | 54300bfb | 2018-03-07 07:43:54 +0530 | [diff] [blame] | 275 | wid_list[wid_cnt].id = WID_INFO_ELEMENT_ASSOCIATE; |
| 276 | wid_list[wid_cnt].type = WID_BIN_DATA; |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 277 | wid_list[wid_cnt].val = conn_attr->req_ies; |
| 278 | wid_list[wid_cnt].size = conn_attr->req_ies_len; |
Ajay Singh | 54300bfb | 2018-03-07 07:43:54 +0530 | [diff] [blame] | 279 | wid_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 280 | |
Ajay Singh | 674650f | 2018-07-19 04:15:12 +0530 | [diff] [blame] | 281 | wid_list[wid_cnt].id = WID_11I_MODE; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 282 | wid_list[wid_cnt].type = WID_CHAR; |
| 283 | wid_list[wid_cnt].size = sizeof(char); |
Ajay Singh | a343cf5 | 2018-12-02 18:03:34 +0000 | [diff] [blame] | 284 | wid_list[wid_cnt].val = (s8 *)&conn_attr->security; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 285 | wid_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 286 | |
Ajay Singh | 674650f | 2018-07-19 04:15:12 +0530 | [diff] [blame] | 287 | wid_list[wid_cnt].id = WID_AUTH_TYPE; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 288 | wid_list[wid_cnt].type = WID_CHAR; |
| 289 | wid_list[wid_cnt].size = sizeof(char); |
Ajay Singh | a343cf5 | 2018-12-02 18:03:34 +0000 | [diff] [blame] | 290 | wid_list[wid_cnt].val = (s8 *)&conn_attr->auth_type; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 291 | wid_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 292 | |
Ajay Singh | 674650f | 2018-07-19 04:15:12 +0530 | [diff] [blame] | 293 | wid_list[wid_cnt].id = WID_JOIN_REQ_EXTENDED; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 294 | wid_list[wid_cnt].type = WID_STR; |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 295 | wid_list[wid_cnt].size = sizeof(*bss_param); |
| 296 | wid_list[wid_cnt].val = (u8 *)bss_param; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 297 | wid_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 298 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 299 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, wid_cnt); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 300 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 301 | netdev_err(vif->ndev, "failed to send config packet\n"); |
Ajay Singh | 3e488a9 | 2018-03-07 07:43:52 +0530 | [diff] [blame] | 302 | goto error; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 303 | } else { |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 304 | hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 305 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 306 | |
Ajay Singh | a343cf5 | 2018-12-02 18:03:34 +0000 | [diff] [blame] | 307 | return 0; |
| 308 | |
Ajay Singh | 3e488a9 | 2018-03-07 07:43:52 +0530 | [diff] [blame] | 309 | error: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 310 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 311 | kfree(conn_attr->req_ies); |
| 312 | conn_attr->req_ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 313 | |
Ajay Singh | e559681 | 2018-12-02 18:03:31 +0000 | [diff] [blame] | 314 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 315 | } |
| 316 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 317 | static void handle_connect_timeout(struct work_struct *work) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 318 | { |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 319 | struct host_if_msg *msg = container_of(work, struct host_if_msg, work); |
| 320 | struct wilc_vif *vif = msg->vif; |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 321 | int result; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 322 | struct wid wid; |
Ajay Singh | 87ae3a5 | 2018-03-02 19:52:47 +0530 | [diff] [blame] | 323 | u16 dummy_reason_code = 0; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 324 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 325 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 326 | if (!hif_drv) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 327 | netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 328 | goto out; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 329 | } |
| 330 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 331 | hif_drv->hif_state = HOST_IF_IDLE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 332 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 333 | if (hif_drv->conn_info.conn_result) { |
| 334 | hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_CONN_RESP, |
| 335 | WILC_MAC_STATUS_DISCONNECTED, |
Ajay Singh | 03cf31c4 | 2019-01-17 13:21:38 +0000 | [diff] [blame] | 336 | hif_drv->conn_info.arg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 337 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 338 | } else { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 339 | netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 340 | } |
| 341 | |
Ajay Singh | 674650f | 2018-07-19 04:15:12 +0530 | [diff] [blame] | 342 | wid.id = WID_DISCONNECT; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 343 | wid.type = WID_CHAR; |
Ajay Singh | 87ae3a5 | 2018-03-02 19:52:47 +0530 | [diff] [blame] | 344 | wid.val = (s8 *)&dummy_reason_code; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 345 | wid.size = sizeof(char); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 346 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 347 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 348 | if (result) |
Colin Ian King | e171da0 | 2017-06-27 10:29:06 +0100 | [diff] [blame] | 349 | netdev_err(vif->ndev, "Failed to send disconnect\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 350 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 351 | hif_drv->conn_info.req_ies_len = 0; |
| 352 | kfree(hif_drv->conn_info.req_ies); |
| 353 | hif_drv->conn_info.req_ies = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 354 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 355 | out: |
| 356 | kfree(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 357 | } |
| 358 | |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 359 | void *wilc_parse_join_bss_param(struct cfg80211_bss *bss, |
| 360 | struct cfg80211_crypto_settings *crypto) |
Ajay Singh | 448d078 | 2018-07-19 04:15:15 +0530 | [diff] [blame] | 361 | { |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 362 | struct wilc_join_bss_param *param; |
| 363 | struct ieee80211_p2p_noa_attr noa_attr; |
| 364 | u8 rates_len = 0; |
| 365 | const u8 *tim_elm, *ssid_elm, *rates_ie, *supp_rates_ie; |
| 366 | const u8 *ht_ie, *wpa_ie, *wmm_ie, *rsn_ie; |
| 367 | int ret; |
Bo YU | c460495 | 2019-02-27 09:52:36 -0500 | [diff] [blame] | 368 | const struct cfg80211_bss_ies *ies = rcu_dereference(bss->ies); |
Ajay Singh | 448d078 | 2018-07-19 04:15:15 +0530 | [diff] [blame] | 369 | |
| 370 | param = kzalloc(sizeof(*param), GFP_KERNEL); |
| 371 | if (!param) |
| 372 | return NULL; |
| 373 | |
Bo YU | 1d4ccf2 | 2019-02-26 02:25:56 -0500 | [diff] [blame] | 374 | param->beacon_period = cpu_to_le16(bss->beacon_interval); |
| 375 | param->cap_info = cpu_to_le16(bss->capability); |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 376 | param->bss_type = WILC_FW_BSS_TYPE_INFRA; |
| 377 | param->ch = ieee80211_frequency_to_channel(bss->channel->center_freq); |
Ajay Singh | 6c2cfb4 | 2019-01-17 13:21:18 +0000 | [diff] [blame] | 378 | ether_addr_copy(param->bssid, bss->bssid); |
| 379 | |
| 380 | ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies->data, ies->len); |
| 381 | if (ssid_elm) { |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 382 | if (ssid_elm[1] <= IEEE80211_MAX_SSID_LEN) |
| 383 | memcpy(param->ssid, ssid_elm + 2, ssid_elm[1]); |
Ajay Singh | 6c2cfb4 | 2019-01-17 13:21:18 +0000 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies->data, ies->len); |
| 387 | if (tim_elm && tim_elm[1] >= 2) |
| 388 | param->dtim_period = tim_elm[3]; |
| 389 | |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 390 | memset(param->p_suites, 0xFF, 3); |
| 391 | memset(param->akm_suites, 0xFF, 3); |
Ajay Singh | 448d078 | 2018-07-19 04:15:15 +0530 | [diff] [blame] | 392 | |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 393 | rates_ie = cfg80211_find_ie(WLAN_EID_SUPP_RATES, ies->data, ies->len); |
| 394 | if (rates_ie) { |
| 395 | rates_len = rates_ie[1]; |
Dan Carpenter | d59dc92 | 2019-10-17 12:18:32 +0300 | [diff] [blame] | 396 | if (rates_len > WILC_MAX_RATES_SUPPORTED) |
| 397 | rates_len = WILC_MAX_RATES_SUPPORTED; |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 398 | param->supp_rates[0] = rates_len; |
| 399 | memcpy(¶m->supp_rates[1], rates_ie + 2, rates_len); |
| 400 | } |
| 401 | |
Ajay Singh | c7e621b | 2019-11-07 15:58:54 +0000 | [diff] [blame] | 402 | if (rates_len < WILC_MAX_RATES_SUPPORTED) { |
| 403 | supp_rates_ie = cfg80211_find_ie(WLAN_EID_EXT_SUPP_RATES, |
| 404 | ies->data, ies->len); |
| 405 | if (supp_rates_ie) { |
| 406 | u8 ext_rates = supp_rates_ie[1]; |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 407 | |
Ajay Singh | c7e621b | 2019-11-07 15:58:54 +0000 | [diff] [blame] | 408 | if (ext_rates > (WILC_MAX_RATES_SUPPORTED - rates_len)) |
| 409 | param->supp_rates[0] = WILC_MAX_RATES_SUPPORTED; |
| 410 | else |
| 411 | param->supp_rates[0] += ext_rates; |
| 412 | |
| 413 | memcpy(¶m->supp_rates[rates_len + 1], |
| 414 | supp_rates_ie + 2, |
| 415 | (param->supp_rates[0] - rates_len)); |
| 416 | } |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, ies->data, ies->len); |
| 420 | if (ht_ie) |
| 421 | param->ht_capable = true; |
| 422 | |
| 423 | ret = cfg80211_get_p2p_attr(ies->data, ies->len, |
| 424 | IEEE80211_P2P_ATTR_ABSENCE_NOTICE, |
| 425 | (u8 *)&noa_attr, sizeof(noa_attr)); |
| 426 | if (ret > 0) { |
| 427 | param->tsf_lo = cpu_to_le32(ies->tsf); |
| 428 | param->noa_enabled = 1; |
| 429 | param->idx = noa_attr.index; |
| 430 | if (noa_attr.oppps_ctwindow & IEEE80211_P2P_OPPPS_ENABLE_BIT) { |
| 431 | param->opp_enabled = 1; |
| 432 | param->opp_en.ct_window = noa_attr.oppps_ctwindow; |
| 433 | param->opp_en.cnt = noa_attr.desc[0].count; |
| 434 | param->opp_en.duration = noa_attr.desc[0].duration; |
| 435 | param->opp_en.interval = noa_attr.desc[0].interval; |
| 436 | param->opp_en.start_time = noa_attr.desc[0].start_time; |
| 437 | } else { |
| 438 | param->opp_enabled = 0; |
| 439 | param->opp_dis.cnt = noa_attr.desc[0].count; |
| 440 | param->opp_dis.duration = noa_attr.desc[0].duration; |
| 441 | param->opp_dis.interval = noa_attr.desc[0].interval; |
| 442 | param->opp_dis.start_time = noa_attr.desc[0].start_time; |
| 443 | } |
| 444 | } |
| 445 | wmm_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, |
| 446 | WLAN_OUI_TYPE_MICROSOFT_WMM, |
| 447 | ies->data, ies->len); |
| 448 | if (wmm_ie) { |
| 449 | struct ieee80211_wmm_param_ie *ie; |
| 450 | |
| 451 | ie = (struct ieee80211_wmm_param_ie *)wmm_ie; |
| 452 | if ((ie->oui_subtype == 0 || ie->oui_subtype == 1) && |
| 453 | ie->version == 1) { |
| 454 | param->wmm_cap = true; |
| 455 | if (ie->qos_info & BIT(7)) |
| 456 | param->uapsd_cap = true; |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | wpa_ie = cfg80211_find_vendor_ie(WLAN_OUI_MICROSOFT, |
| 461 | WLAN_OUI_TYPE_MICROSOFT_WPA, |
| 462 | ies->data, ies->len); |
| 463 | if (wpa_ie) { |
| 464 | param->mode_802_11i = 1; |
| 465 | param->rsn_found = true; |
| 466 | } |
| 467 | |
| 468 | rsn_ie = cfg80211_find_ie(WLAN_EID_RSN, ies->data, ies->len); |
| 469 | if (rsn_ie) { |
| 470 | int offset = 8; |
| 471 | |
| 472 | param->mode_802_11i = 2; |
| 473 | param->rsn_found = true; |
Ajay Singh | f1f2426 | 2019-11-05 09:51:30 +0000 | [diff] [blame] | 474 | /* extract RSN capabilities */ |
Ajay Singh | 4e0b0f4 | 2019-01-17 13:21:27 +0000 | [diff] [blame] | 475 | offset += (rsn_ie[offset] * 4) + 2; |
| 476 | offset += (rsn_ie[offset] * 4) + 2; |
| 477 | memcpy(param->rsn_cap, &rsn_ie[offset], 2); |
| 478 | } |
| 479 | |
| 480 | if (param->rsn_found) { |
| 481 | int i; |
| 482 | |
| 483 | param->rsn_grp_policy = crypto->cipher_group & 0xFF; |
| 484 | for (i = 0; i < crypto->n_ciphers_pairwise && i < 3; i++) |
| 485 | param->p_suites[i] = crypto->ciphers_pairwise[i] & 0xFF; |
| 486 | |
| 487 | for (i = 0; i < crypto->n_akm_suites && i < 3; i++) |
| 488 | param->akm_suites[i] = crypto->akm_suites[i] & 0xFF; |
| 489 | } |
Ajay Singh | 448d078 | 2018-07-19 04:15:15 +0530 | [diff] [blame] | 490 | |
| 491 | return (void *)param; |
| 492 | } |
| 493 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 494 | static void handle_rcvd_ntwrk_info(struct work_struct *work) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 495 | { |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 496 | struct host_if_msg *msg = container_of(work, struct host_if_msg, work); |
Ajay Singh | 6cd4fa5 | 2019-01-17 13:21:21 +0000 | [diff] [blame] | 497 | struct wilc_rcvd_net_info *rcvd_info = &msg->body.net_info; |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 498 | struct wilc_user_scan_req *scan_req = &msg->vif->hif_drv->usr_scan_req; |
Ajay Singh | 6cd4fa5 | 2019-01-17 13:21:21 +0000 | [diff] [blame] | 499 | const u8 *ch_elm; |
| 500 | u8 *ies; |
| 501 | int ies_len; |
| 502 | size_t offset; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 503 | |
Ajay Singh | 6cd4fa5 | 2019-01-17 13:21:21 +0000 | [diff] [blame] | 504 | if (ieee80211_is_probe_resp(rcvd_info->mgmt->frame_control)) |
| 505 | offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); |
| 506 | else if (ieee80211_is_beacon(rcvd_info->mgmt->frame_control)) |
| 507 | offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); |
| 508 | else |
Ajay Singh | 3b9ccd3 | 2018-03-02 19:52:48 +0530 | [diff] [blame] | 509 | goto done; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 510 | |
Ajay Singh | 6cd4fa5 | 2019-01-17 13:21:21 +0000 | [diff] [blame] | 511 | ies = rcvd_info->mgmt->u.beacon.variable; |
| 512 | ies_len = rcvd_info->frame_len - offset; |
| 513 | if (ies_len <= 0) |
Ajay Singh | 3b9ccd3 | 2018-03-02 19:52:48 +0530 | [diff] [blame] | 514 | goto done; |
Ajay Singh | 3b9ccd3 | 2018-03-02 19:52:48 +0530 | [diff] [blame] | 515 | |
Ajay Singh | 6cd4fa5 | 2019-01-17 13:21:21 +0000 | [diff] [blame] | 516 | ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len); |
| 517 | if (ch_elm && ch_elm[1] > 0) |
| 518 | rcvd_info->ch = ch_elm[2]; |
| 519 | |
| 520 | if (scan_req->scan_result) |
| 521 | scan_req->scan_result(SCAN_EVENT_NETWORK_FOUND, rcvd_info, |
| 522 | scan_req->arg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 523 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 524 | done: |
Ajay Singh | 6cd4fa5 | 2019-01-17 13:21:21 +0000 | [diff] [blame] | 525 | kfree(rcvd_info->mgmt); |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 526 | kfree(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 527 | } |
| 528 | |
Ajay Singh | abffb39 | 2018-09-25 11:53:21 +0530 | [diff] [blame] | 529 | static void host_int_get_assoc_res_info(struct wilc_vif *vif, |
| 530 | u8 *assoc_resp_info, |
| 531 | u32 max_assoc_resp_info_len, |
| 532 | u32 *rcvd_assoc_resp_info_len) |
Ajay Singh | 8bdc6bb | 2018-07-19 04:15:14 +0530 | [diff] [blame] | 533 | { |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 534 | int result; |
Ajay Singh | 8bdc6bb | 2018-07-19 04:15:14 +0530 | [diff] [blame] | 535 | struct wid wid; |
| 536 | |
| 537 | wid.id = WID_ASSOC_RES_INFO; |
| 538 | wid.type = WID_STR; |
| 539 | wid.val = assoc_resp_info; |
| 540 | wid.size = max_assoc_resp_info_len; |
| 541 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 542 | result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); |
Ajay Singh | 8bdc6bb | 2018-07-19 04:15:14 +0530 | [diff] [blame] | 543 | if (result) { |
| 544 | *rcvd_assoc_resp_info_len = 0; |
| 545 | netdev_err(vif->ndev, "Failed to send association response\n"); |
Ajay Singh | abffb39 | 2018-09-25 11:53:21 +0530 | [diff] [blame] | 546 | return; |
Ajay Singh | 8bdc6bb | 2018-07-19 04:15:14 +0530 | [diff] [blame] | 547 | } |
| 548 | |
| 549 | *rcvd_assoc_resp_info_len = wid.size; |
Ajay Singh | 8bdc6bb | 2018-07-19 04:15:14 +0530 | [diff] [blame] | 550 | } |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 551 | |
Ajay Singh | 1116468b | 2018-11-01 16:45:23 +0000 | [diff] [blame] | 552 | static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 553 | struct wilc_conn_info *ret_conn_info) |
Ajay Singh | 1116468b | 2018-11-01 16:45:23 +0000 | [diff] [blame] | 554 | { |
| 555 | u8 *ies; |
| 556 | u16 ies_len; |
Ajay Singh | 1d58fec | 2020-01-17 10:31:26 +0000 | [diff] [blame] | 557 | struct wilc_assoc_resp *res = (struct wilc_assoc_resp *)buffer; |
Ajay Singh | 1116468b | 2018-11-01 16:45:23 +0000 | [diff] [blame] | 558 | |
| 559 | ret_conn_info->status = le16_to_cpu(res->status_code); |
| 560 | if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { |
| 561 | ies = &buffer[sizeof(*res)]; |
| 562 | ies_len = buffer_len - sizeof(*res); |
| 563 | |
| 564 | ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL); |
| 565 | if (!ret_conn_info->resp_ies) |
| 566 | return -ENOMEM; |
| 567 | |
| 568 | ret_conn_info->resp_ies_len = ies_len; |
| 569 | } |
| 570 | |
| 571 | return 0; |
| 572 | } |
| 573 | |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 574 | static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, |
| 575 | u8 mac_status) |
| 576 | { |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 577 | struct host_if_drv *hif_drv = vif->hif_drv; |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 578 | struct wilc_conn_info *conn_info = &hif_drv->conn_info; |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 579 | |
Ajay Singh | 8c4574d | 2018-11-12 05:45:14 +0000 | [diff] [blame] | 580 | if (mac_status == WILC_MAC_STATUS_CONNECTED) { |
Ajay Singh | 9aef823 | 2018-05-11 13:43:08 +0530 | [diff] [blame] | 581 | u32 assoc_resp_info_len; |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 582 | |
Ajay Singh | d0e41ef | 2018-11-12 05:45:29 +0000 | [diff] [blame] | 583 | memset(hif_drv->assoc_resp, 0, WILC_MAX_ASSOC_RESP_FRAME_SIZE); |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 584 | |
Ajay Singh | 83a953e2 | 2018-09-04 12:09:30 +0530 | [diff] [blame] | 585 | host_int_get_assoc_res_info(vif, hif_drv->assoc_resp, |
Ajay Singh | d0e41ef | 2018-11-12 05:45:29 +0000 | [diff] [blame] | 586 | WILC_MAX_ASSOC_RESP_FRAME_SIZE, |
Ajay Singh | 9aef823 | 2018-05-11 13:43:08 +0530 | [diff] [blame] | 587 | &assoc_resp_info_len); |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 588 | |
Ajay Singh | 9aef823 | 2018-05-11 13:43:08 +0530 | [diff] [blame] | 589 | if (assoc_resp_info_len != 0) { |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 590 | s32 err = 0; |
| 591 | |
Ajay Singh | 83a953e2 | 2018-09-04 12:09:30 +0530 | [diff] [blame] | 592 | err = wilc_parse_assoc_resp_info(hif_drv->assoc_resp, |
Ajay Singh | 9aef823 | 2018-05-11 13:43:08 +0530 | [diff] [blame] | 593 | assoc_resp_info_len, |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 594 | conn_info); |
Ajay Singh | 49bf665 | 2018-05-11 13:43:31 +0530 | [diff] [blame] | 595 | if (err) |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 596 | netdev_err(vif->ndev, |
| 597 | "wilc_parse_assoc_resp_info() returned error %d\n", |
| 598 | err); |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 599 | } |
| 600 | } |
| 601 | |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 602 | del_timer(&hif_drv->connect_timer); |
Ajay Singh | 03cf31c4 | 2019-01-17 13:21:38 +0000 | [diff] [blame] | 603 | conn_info->conn_result(CONN_DISCONN_EVENT_CONN_RESP, mac_status, |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 604 | hif_drv->conn_info.arg); |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 605 | |
Ajay Singh | 8c4574d | 2018-11-12 05:45:14 +0000 | [diff] [blame] | 606 | if (mac_status == WILC_MAC_STATUS_CONNECTED && |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 607 | conn_info->status == WLAN_STATUS_SUCCESS) { |
| 608 | ether_addr_copy(hif_drv->assoc_bssid, conn_info->bssid); |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 609 | hif_drv->hif_state = HOST_IF_CONNECTED; |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 610 | } else { |
| 611 | hif_drv->hif_state = HOST_IF_IDLE; |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 612 | } |
| 613 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 614 | kfree(conn_info->resp_ies); |
| 615 | conn_info->resp_ies = NULL; |
| 616 | conn_info->resp_ies_len = 0; |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 617 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 618 | kfree(conn_info->req_ies); |
| 619 | conn_info->req_ies = NULL; |
| 620 | conn_info->req_ies_len = 0; |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | static inline void host_int_handle_disconnect(struct wilc_vif *vif) |
| 624 | { |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 625 | struct host_if_drv *hif_drv = vif->hif_drv; |
| 626 | |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 627 | if (hif_drv->usr_scan_req.scan_result) { |
| 628 | del_timer(&hif_drv->scan_timer); |
| 629 | handle_scan_done(vif, SCAN_EVENT_ABORTED); |
| 630 | } |
| 631 | |
Adham Abozaeid | ded11ab | 2019-07-25 21:31:35 +0000 | [diff] [blame] | 632 | if (hif_drv->conn_info.conn_result) |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 633 | hif_drv->conn_info.conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, |
Ajay Singh | 03cf31c4 | 2019-01-17 13:21:38 +0000 | [diff] [blame] | 634 | 0, hif_drv->conn_info.arg); |
Adham Abozaeid | ded11ab | 2019-07-25 21:31:35 +0000 | [diff] [blame] | 635 | else |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 636 | netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 637 | |
| 638 | eth_zero_addr(hif_drv->assoc_bssid); |
| 639 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 640 | hif_drv->conn_info.req_ies_len = 0; |
| 641 | kfree(hif_drv->conn_info.req_ies); |
| 642 | hif_drv->conn_info.req_ies = NULL; |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 643 | hif_drv->hif_state = HOST_IF_IDLE; |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 644 | } |
| 645 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 646 | static void handle_rcvd_gnrl_async_info(struct work_struct *work) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 647 | { |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 648 | struct host_if_msg *msg = container_of(work, struct host_if_msg, work); |
| 649 | struct wilc_vif *vif = msg->vif; |
Ajay Singh | 94bb6d3 | 2019-01-17 13:21:35 +0000 | [diff] [blame] | 650 | struct wilc_rcvd_mac_info *mac_info = &msg->body.mac_info; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 651 | struct host_if_drv *hif_drv = vif->hif_drv; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 652 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 653 | if (!hif_drv) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 654 | netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); |
Ajay Singh | 94bb6d3 | 2019-01-17 13:21:35 +0000 | [diff] [blame] | 655 | goto free_msg; |
Leo Kim | 234837d | 2015-09-22 14:34:43 +0900 | [diff] [blame] | 656 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 657 | |
Ajay Singh | 94bb6d3 | 2019-01-17 13:21:35 +0000 | [diff] [blame] | 658 | if (!hif_drv->conn_info.conn_result) { |
| 659 | netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); |
| 660 | goto free_msg; |
| 661 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 662 | |
Ajay Singh | 94bb6d3 | 2019-01-17 13:21:35 +0000 | [diff] [blame] | 663 | if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) { |
| 664 | host_int_parse_assoc_resp_info(vif, mac_info->status); |
| 665 | } else if (mac_info->status == WILC_MAC_STATUS_DISCONNECTED) { |
| 666 | if (hif_drv->hif_state == HOST_IF_CONNECTED) { |
Ajay Singh | 158152b | 2018-03-26 17:16:02 +0530 | [diff] [blame] | 667 | host_int_handle_disconnect(vif); |
Ajay Singh | 94bb6d3 | 2019-01-17 13:21:35 +0000 | [diff] [blame] | 668 | } else if (hif_drv->usr_scan_req.scan_result) { |
Leo Kim | 13b313e | 2015-10-29 11:58:34 +0900 | [diff] [blame] | 669 | del_timer(&hif_drv->scan_timer); |
Ajay Singh | 94bb6d3 | 2019-01-17 13:21:35 +0000 | [diff] [blame] | 670 | handle_scan_done(vif, SCAN_EVENT_ABORTED); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 671 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 672 | } |
| 673 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 674 | free_msg: |
| 675 | kfree(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 676 | } |
| 677 | |
Ajay Singh | 8e6d6cf | 2018-12-02 18:03:28 +0000 | [diff] [blame] | 678 | int wilc_disconnect(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 679 | { |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 680 | struct wid wid; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 681 | struct host_if_drv *hif_drv = vif->hif_drv; |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 682 | struct wilc_user_scan_req *scan_req; |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 683 | struct wilc_conn_info *conn_info; |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 684 | int result; |
Ajay Singh | e789367 | 2018-03-02 19:52:49 +0530 | [diff] [blame] | 685 | u16 dummy_reason_code = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 686 | |
Ajay Singh | 674650f | 2018-07-19 04:15:12 +0530 | [diff] [blame] | 687 | wid.id = WID_DISCONNECT; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 688 | wid.type = WID_CHAR; |
Ajay Singh | e789367 | 2018-03-02 19:52:49 +0530 | [diff] [blame] | 689 | wid.val = (s8 *)&dummy_reason_code; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 690 | wid.size = sizeof(char); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 691 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 692 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 693 | if (result) { |
Colin Ian King | e2e89d4 | 2019-04-15 17:33:30 +0100 | [diff] [blame] | 694 | netdev_err(vif->ndev, "Failed to send disconnect\n"); |
Ajay Singh | 8e6d6cf | 2018-12-02 18:03:28 +0000 | [diff] [blame] | 695 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 696 | } |
| 697 | |
Ajay Singh | 0e7ba8eb | 2018-03-07 07:43:55 +0530 | [diff] [blame] | 698 | scan_req = &hif_drv->usr_scan_req; |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 699 | conn_info = &hif_drv->conn_info; |
Ajay Singh | 0e7ba8eb | 2018-03-07 07:43:55 +0530 | [diff] [blame] | 700 | |
| 701 | if (scan_req->scan_result) { |
| 702 | del_timer(&hif_drv->scan_timer); |
Ajay Singh | 6c2cfb4 | 2019-01-17 13:21:18 +0000 | [diff] [blame] | 703 | scan_req->scan_result(SCAN_EVENT_ABORTED, NULL, scan_req->arg); |
Ajay Singh | 0e7ba8eb | 2018-03-07 07:43:55 +0530 | [diff] [blame] | 704 | scan_req->scan_result = NULL; |
| 705 | } |
| 706 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 707 | if (conn_info->conn_result) { |
Ajay Singh | 0e7ba8eb | 2018-03-07 07:43:55 +0530 | [diff] [blame] | 708 | if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) |
| 709 | del_timer(&hif_drv->connect_timer); |
| 710 | |
Ajay Singh | 03cf31c4 | 2019-01-17 13:21:38 +0000 | [diff] [blame] | 711 | conn_info->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, 0, |
| 712 | conn_info->arg); |
Ajay Singh | 0e7ba8eb | 2018-03-07 07:43:55 +0530 | [diff] [blame] | 713 | } else { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 714 | netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); |
Ajay Singh | 0e7ba8eb | 2018-03-07 07:43:55 +0530 | [diff] [blame] | 715 | } |
| 716 | |
Ajay Singh | 0e7ba8eb | 2018-03-07 07:43:55 +0530 | [diff] [blame] | 717 | hif_drv->hif_state = HOST_IF_IDLE; |
| 718 | |
| 719 | eth_zero_addr(hif_drv->assoc_bssid); |
| 720 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 721 | conn_info->req_ies_len = 0; |
| 722 | kfree(conn_info->req_ies); |
| 723 | conn_info->req_ies = NULL; |
Ajay Singh | 0e7ba8eb | 2018-03-07 07:43:55 +0530 | [diff] [blame] | 724 | |
Ajay Singh | 8e6d6cf | 2018-12-02 18:03:28 +0000 | [diff] [blame] | 725 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 726 | } |
| 727 | |
Ajay Singh | 19cb25e1 | 2018-12-02 18:03:25 +0000 | [diff] [blame] | 728 | int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 729 | { |
Ajay Singh | 173508b | 2018-01-30 22:20:29 +0530 | [diff] [blame] | 730 | struct wid wid_list[5]; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 731 | u32 wid_cnt = 0, result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 732 | |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 733 | wid_list[wid_cnt].id = WID_LINKSPEED; |
| 734 | wid_list[wid_cnt].type = WID_CHAR; |
| 735 | wid_list[wid_cnt].size = sizeof(char); |
Ajay Singh | fcc7010 | 2018-02-20 20:27:56 +0530 | [diff] [blame] | 736 | wid_list[wid_cnt].val = (s8 *)&stats->link_speed; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 737 | wid_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 738 | |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 739 | wid_list[wid_cnt].id = WID_RSSI; |
| 740 | wid_list[wid_cnt].type = WID_CHAR; |
| 741 | wid_list[wid_cnt].size = sizeof(char); |
Ajay Singh | fcc7010 | 2018-02-20 20:27:56 +0530 | [diff] [blame] | 742 | wid_list[wid_cnt].val = (s8 *)&stats->rssi; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 743 | wid_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 744 | |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 745 | wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT; |
| 746 | wid_list[wid_cnt].type = WID_INT; |
| 747 | wid_list[wid_cnt].size = sizeof(u32); |
Ajay Singh | fcc7010 | 2018-02-20 20:27:56 +0530 | [diff] [blame] | 748 | wid_list[wid_cnt].val = (s8 *)&stats->tx_cnt; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 749 | wid_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 750 | |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 751 | wid_list[wid_cnt].id = WID_RECEIVED_FRAGMENT_COUNT; |
| 752 | wid_list[wid_cnt].type = WID_INT; |
| 753 | wid_list[wid_cnt].size = sizeof(u32); |
Ajay Singh | fcc7010 | 2018-02-20 20:27:56 +0530 | [diff] [blame] | 754 | wid_list[wid_cnt].val = (s8 *)&stats->rx_cnt; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 755 | wid_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 756 | |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 757 | wid_list[wid_cnt].id = WID_FAILED_COUNT; |
| 758 | wid_list[wid_cnt].type = WID_INT; |
| 759 | wid_list[wid_cnt].size = sizeof(u32); |
Ajay Singh | fcc7010 | 2018-02-20 20:27:56 +0530 | [diff] [blame] | 760 | wid_list[wid_cnt].val = (s8 *)&stats->tx_fail_cnt; |
Ajay Singh | cdbdae1 | 2018-01-30 22:20:30 +0530 | [diff] [blame] | 761 | wid_cnt++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 762 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 763 | result = wilc_send_config_pkt(vif, WILC_GET_CFG, wid_list, wid_cnt); |
Ajay Singh | 19cb25e1 | 2018-12-02 18:03:25 +0000 | [diff] [blame] | 764 | if (result) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 765 | netdev_err(vif->ndev, "Failed to send scan parameters\n"); |
Ajay Singh | 19cb25e1 | 2018-12-02 18:03:25 +0000 | [diff] [blame] | 766 | return result; |
| 767 | } |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 768 | |
Ajay Singh | fcc7010 | 2018-02-20 20:27:56 +0530 | [diff] [blame] | 769 | if (stats->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH && |
| 770 | stats->link_speed != DEFAULT_LINK_SPEED) |
Ajay Singh | 95e05b4 | 2018-09-04 12:09:33 +0530 | [diff] [blame] | 771 | wilc_enable_tcp_ack_filter(vif, true); |
Ajay Singh | fcc7010 | 2018-02-20 20:27:56 +0530 | [diff] [blame] | 772 | else if (stats->link_speed != DEFAULT_LINK_SPEED) |
Ajay Singh | 95e05b4 | 2018-09-04 12:09:33 +0530 | [diff] [blame] | 773 | wilc_enable_tcp_ack_filter(vif, false); |
Glen Lee | 4fd6229 | 2016-02-04 18:15:24 +0900 | [diff] [blame] | 774 | |
Ajay Singh | 19cb25e1 | 2018-12-02 18:03:25 +0000 | [diff] [blame] | 775 | return result; |
| 776 | } |
| 777 | |
| 778 | static void handle_get_statistics(struct work_struct *work) |
| 779 | { |
| 780 | struct host_if_msg *msg = container_of(work, struct host_if_msg, work); |
| 781 | struct wilc_vif *vif = msg->vif; |
| 782 | struct rf_info *stats = (struct rf_info *)msg->body.data; |
| 783 | |
| 784 | wilc_get_statistics(vif, stats); |
| 785 | |
| 786 | kfree(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 787 | } |
| 788 | |
Ajay Singh | 6133ed9 | 2018-12-02 18:02:36 +0000 | [diff] [blame] | 789 | static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, |
| 790 | struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 791 | { |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 792 | ether_addr_copy(cur_byte, mac); |
| 793 | cur_byte += ETH_ALEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 794 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 795 | put_unaligned_le16(params->aid, cur_byte); |
| 796 | cur_byte += 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 797 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 798 | *cur_byte++ = params->supported_rates_len; |
| 799 | if (params->supported_rates_len > 0) |
| 800 | memcpy(cur_byte, params->supported_rates, |
| 801 | params->supported_rates_len); |
| 802 | cur_byte += params->supported_rates_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 803 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 804 | if (params->ht_capa) { |
| 805 | *cur_byte++ = true; |
Ajay Singh | efabc44 | 2020-03-02 16:22:35 +0000 | [diff] [blame] | 806 | memcpy(cur_byte, params->ht_capa, |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 807 | sizeof(struct ieee80211_ht_cap)); |
| 808 | } else { |
| 809 | *cur_byte++ = false; |
| 810 | } |
Ajay Singh | e33ff51 | 2018-01-30 22:20:31 +0530 | [diff] [blame] | 811 | cur_byte += sizeof(struct ieee80211_ht_cap); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 812 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 813 | put_unaligned_le16(params->sta_flags_mask, cur_byte); |
| 814 | cur_byte += 2; |
| 815 | put_unaligned_le16(params->sta_flags_set, cur_byte); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 816 | } |
| 817 | |
Ajay Singh | 3ccff33 | 2018-02-19 20:59:39 +0530 | [diff] [blame] | 818 | static int handle_remain_on_chan(struct wilc_vif *vif, |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 819 | struct wilc_remain_ch *hif_remain_ch) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 820 | { |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 821 | int result; |
Ajay Singh | d956839 | 2018-03-07 07:43:56 +0530 | [diff] [blame] | 822 | u8 remain_on_chan_flag; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 823 | struct wid wid; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 824 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 825 | |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 826 | if (hif_drv->usr_scan_req.scan_result) |
| 827 | return -EBUSY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 828 | |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 829 | if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) |
| 830 | return -EBUSY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 831 | |
Adham Abozaeid | 5a28d3f | 2019-07-25 21:31:34 +0000 | [diff] [blame] | 832 | if (vif->connecting) |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 833 | return -EBUSY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 834 | |
Ajay Singh | d956839 | 2018-03-07 07:43:56 +0530 | [diff] [blame] | 835 | remain_on_chan_flag = true; |
Ajay Singh | 674650f | 2018-07-19 04:15:12 +0530 | [diff] [blame] | 836 | wid.id = WID_REMAIN_ON_CHAN; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 837 | wid.type = WID_STR; |
| 838 | wid.size = 2; |
| 839 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 840 | if (!wid.val) |
| 841 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 842 | |
Ajay Singh | d956839 | 2018-03-07 07:43:56 +0530 | [diff] [blame] | 843 | wid.val[0] = remain_on_chan_flag; |
Ajay Singh | 9f24836 | 2018-02-19 20:59:34 +0530 | [diff] [blame] | 844 | wid.val[1] = (s8)hif_remain_ch->ch; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 845 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 846 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 8d5b5e6 | 2018-03-26 17:15:59 +0530 | [diff] [blame] | 847 | kfree(wid.val); |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 848 | if (result) |
| 849 | return -EBUSY; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 850 | |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 851 | hif_drv->remain_on_ch.arg = hif_remain_ch->arg; |
| 852 | hif_drv->remain_on_ch.expired = hif_remain_ch->expired; |
| 853 | hif_drv->remain_on_ch.ch = hif_remain_ch->ch; |
| 854 | hif_drv->remain_on_ch.cookie = hif_remain_ch->cookie; |
Ajay Singh | 198fd7e | 2018-04-25 22:48:24 +0530 | [diff] [blame] | 855 | hif_drv->remain_on_ch_timer_vif = vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 856 | |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 857 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 858 | } |
| 859 | |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 860 | static int wilc_handle_roc_expired(struct wilc_vif *vif, u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 861 | { |
Ajay Singh | d956839 | 2018-03-07 07:43:56 +0530 | [diff] [blame] | 862 | u8 remain_on_chan_flag; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 863 | struct wid wid; |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 864 | int result; |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 865 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 866 | |
Ajay Singh | 0f4f67b | 2020-02-11 09:57:09 +0000 | [diff] [blame] | 867 | if (vif->priv.p2p_listen_state) { |
Ajay Singh | d956839 | 2018-03-07 07:43:56 +0530 | [diff] [blame] | 868 | remain_on_chan_flag = false; |
Ajay Singh | 674650f | 2018-07-19 04:15:12 +0530 | [diff] [blame] | 869 | wid.id = WID_REMAIN_ON_CHAN; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 870 | wid.type = WID_STR; |
| 871 | wid.size = 2; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 872 | |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 873 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
Dilek Uzulmez | 98b6594 | 2016-10-09 22:27:53 +0300 | [diff] [blame] | 874 | if (!wid.val) |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 875 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 876 | |
Ajay Singh | d956839 | 2018-03-07 07:43:56 +0530 | [diff] [blame] | 877 | wid.val[0] = remain_on_chan_flag; |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 878 | wid.val[1] = WILC_FALSE_FRMWR_CHANNEL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 879 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 880 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 8d5b5e6 | 2018-03-26 17:15:59 +0530 | [diff] [blame] | 881 | kfree(wid.val); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 882 | if (result != 0) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 883 | netdev_err(vif->ndev, "Failed to set remain channel\n"); |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 884 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 885 | } |
| 886 | |
Leo Kim | bfb62ab | 2015-10-29 11:58:42 +0900 | [diff] [blame] | 887 | if (hif_drv->remain_on_ch.expired) { |
Leo Kim | c5cc4b1 | 2015-10-29 11:58:44 +0900 | [diff] [blame] | 888 | hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg, |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 889 | cookie); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 890 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 891 | } else { |
Chris Park | e3f1696 | 2016-02-04 18:24:30 +0900 | [diff] [blame] | 892 | netdev_dbg(vif->ndev, "Not in listen state\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 893 | } |
| 894 | |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 895 | return 0; |
| 896 | } |
| 897 | |
| 898 | static void wilc_handle_listen_state_expired(struct work_struct *work) |
| 899 | { |
| 900 | struct host_if_msg *msg = container_of(work, struct host_if_msg, work); |
| 901 | |
| 902 | wilc_handle_roc_expired(msg->vif, msg->body.remain_on_ch.cookie); |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 903 | kfree(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 904 | } |
| 905 | |
Ajay Singh | b44c386 | 2018-02-19 20:59:41 +0530 | [diff] [blame] | 906 | static void listen_timer_cb(struct timer_list *t) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 907 | { |
Kees Cook | 1f23319 | 2017-10-16 16:24:32 -0700 | [diff] [blame] | 908 | struct host_if_drv *hif_drv = from_timer(hif_drv, t, |
| 909 | remain_on_ch_timer); |
| 910 | struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif; |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 911 | int result; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 912 | struct host_if_msg *msg; |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 913 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 914 | del_timer(&vif->hif_drv->remain_on_ch_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 915 | |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 916 | msg = wilc_alloc_work(vif, wilc_handle_listen_state_expired, false); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 917 | if (IS_ERR(msg)) |
| 918 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 919 | |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 920 | msg->body.remain_on_ch.cookie = vif->hif_drv->remain_on_ch.cookie; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 921 | |
Ajay Singh | c6a358d | 2018-06-26 11:37:08 +0530 | [diff] [blame] | 922 | result = wilc_enqueue_work(msg); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 923 | if (result) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 924 | netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 925 | kfree(msg); |
| 926 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 927 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 928 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 929 | static void handle_set_mcast_filter(struct work_struct *work) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 930 | { |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 931 | struct host_if_msg *msg = container_of(work, struct host_if_msg, work); |
| 932 | struct wilc_vif *vif = msg->vif; |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 933 | struct wilc_set_multicast *set_mc = &msg->body.mc_info; |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 934 | int result; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 935 | struct wid wid; |
Ajay Singh | e33ff51 | 2018-01-30 22:20:31 +0530 | [diff] [blame] | 936 | u8 *cur_byte; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 937 | |
Ajay Singh | 674650f | 2018-07-19 04:15:12 +0530 | [diff] [blame] | 938 | wid.id = WID_SETUP_MULTICAST_FILTER; |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 939 | wid.type = WID_BIN; |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 940 | wid.size = sizeof(struct wilc_set_multicast) + (set_mc->cnt * ETH_ALEN); |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 941 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
| 942 | if (!wid.val) |
Ajay Singh | 3e488a9 | 2018-03-07 07:43:52 +0530 | [diff] [blame] | 943 | goto error; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 944 | |
Ajay Singh | e33ff51 | 2018-01-30 22:20:31 +0530 | [diff] [blame] | 945 | cur_byte = wid.val; |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 946 | put_unaligned_le32(set_mc->enabled, cur_byte); |
| 947 | cur_byte += 4; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 948 | |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 949 | put_unaligned_le32(set_mc->cnt, cur_byte); |
| 950 | cur_byte += 4; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 951 | |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 952 | if (set_mc->cnt > 0 && set_mc->mc_list) |
| 953 | memcpy(cur_byte, set_mc->mc_list, set_mc->cnt * ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 954 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 955 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 956 | if (result) |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 957 | netdev_err(vif->ndev, "Failed to send setup multicast\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 958 | |
Ajay Singh | 3e488a9 | 2018-03-07 07:43:52 +0530 | [diff] [blame] | 959 | error: |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 960 | kfree(set_mc->mc_list); |
Leo Kim | 45102f8 | 2015-10-28 15:59:28 +0900 | [diff] [blame] | 961 | kfree(wid.val); |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 962 | kfree(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 963 | } |
| 964 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 965 | static void handle_scan_timer(struct work_struct *work) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 966 | { |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 967 | struct host_if_msg *msg = container_of(work, struct host_if_msg, work); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 968 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 969 | handle_scan_done(msg->vif, SCAN_EVENT_ABORTED); |
| 970 | kfree(msg); |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 971 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 972 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 973 | static void handle_scan_complete(struct work_struct *work) |
| 974 | { |
| 975 | struct host_if_msg *msg = container_of(work, struct host_if_msg, work); |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 976 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 977 | del_timer(&msg->vif->hif_drv->scan_timer); |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 978 | |
Ajay Singh | 7233be3 | 2018-06-26 11:37:03 +0530 | [diff] [blame] | 979 | handle_scan_done(msg->vif, SCAN_EVENT_DONE); |
Binoy Jayan | a5c84b2 | 2016-06-23 11:11:52 +0530 | [diff] [blame] | 980 | |
Binoy Jayan | 2518ac5 | 2016-06-23 11:11:51 +0530 | [diff] [blame] | 981 | kfree(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 982 | } |
| 983 | |
Ajay Singh | 4189eb5 | 2018-02-19 20:59:40 +0530 | [diff] [blame] | 984 | static void timer_scan_cb(struct timer_list *t) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 985 | { |
Kees Cook | 1f23319 | 2017-10-16 16:24:32 -0700 | [diff] [blame] | 986 | struct host_if_drv *hif_drv = from_timer(hif_drv, t, scan_timer); |
| 987 | struct wilc_vif *vif = hif_drv->scan_timer_vif; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 988 | struct host_if_msg *msg; |
| 989 | int result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 990 | |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 991 | msg = wilc_alloc_work(vif, handle_scan_timer, false); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 992 | if (IS_ERR(msg)) |
| 993 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 994 | |
Ajay Singh | c6a358d | 2018-06-26 11:37:08 +0530 | [diff] [blame] | 995 | result = wilc_enqueue_work(msg); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 996 | if (result) |
| 997 | kfree(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 998 | } |
| 999 | |
Ajay Singh | 4189eb5 | 2018-02-19 20:59:40 +0530 | [diff] [blame] | 1000 | static void timer_connect_cb(struct timer_list *t) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1001 | { |
Kees Cook | 1f23319 | 2017-10-16 16:24:32 -0700 | [diff] [blame] | 1002 | struct host_if_drv *hif_drv = from_timer(hif_drv, t, |
| 1003 | connect_timer); |
| 1004 | struct wilc_vif *vif = hif_drv->connect_timer_vif; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1005 | struct host_if_msg *msg; |
| 1006 | int result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1007 | |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1008 | msg = wilc_alloc_work(vif, handle_connect_timeout, false); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1009 | if (IS_ERR(msg)) |
| 1010 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1011 | |
Ajay Singh | c6a358d | 2018-06-26 11:37:08 +0530 | [diff] [blame] | 1012 | result = wilc_enqueue_work(msg); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1013 | if (result) |
| 1014 | kfree(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1015 | } |
| 1016 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1017 | int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1018 | { |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1019 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1020 | int result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1021 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1022 | wid.id = WID_REMOVE_WEP_KEY; |
| 1023 | wid.type = WID_STR; |
| 1024 | wid.size = sizeof(char); |
| 1025 | wid.val = &index; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1026 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1027 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1028 | if (result) |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1029 | netdev_err(vif->ndev, |
| 1030 | "Failed to send remove wep key config packet\n"); |
Chaehyun Lim | 9e5e8b4 | 2015-10-05 19:35:00 +0900 | [diff] [blame] | 1031 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1032 | } |
| 1033 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1034 | int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1035 | { |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1036 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1037 | int result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1038 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1039 | wid.id = WID_KEY_ID; |
| 1040 | wid.type = WID_CHAR; |
| 1041 | wid.size = sizeof(char); |
| 1042 | wid.val = &index; |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1043 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1044 | if (result) |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1045 | netdev_err(vif->ndev, |
| 1046 | "Failed to send wep default key config packet\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1047 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1048 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1049 | } |
| 1050 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1051 | int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, |
| 1052 | u8 index) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1053 | { |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1054 | struct wid wid; |
Ajay Singh | c26bdea | 2018-03-26 17:15:58 +0530 | [diff] [blame] | 1055 | int result; |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1056 | struct wilc_wep_key *wep_key; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1057 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1058 | wid.id = WID_ADD_WEP_KEY; |
| 1059 | wid.type = WID_STR; |
| 1060 | wid.size = sizeof(*wep_key) + len; |
| 1061 | wep_key = kzalloc(wid.size, GFP_KERNEL); |
| 1062 | if (!wep_key) |
| 1063 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1064 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1065 | wid.val = (u8 *)wep_key; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1066 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1067 | wep_key->index = index; |
| 1068 | wep_key->key_len = len; |
| 1069 | memcpy(wep_key->key, key, len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1070 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1071 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1072 | if (result) |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1073 | netdev_err(vif->ndev, |
| 1074 | "Failed to add wep key config packet\n"); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1075 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1076 | kfree(wep_key); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1077 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1078 | } |
| 1079 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1080 | int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, |
Ajay Singh | ecba6b7 | 2018-07-19 04:15:04 +0530 | [diff] [blame] | 1081 | u8 index, u8 mode, enum authtype auth_type) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1082 | { |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1083 | struct wid wid_list[3]; |
Ajay Singh | c26bdea | 2018-03-26 17:15:58 +0530 | [diff] [blame] | 1084 | int result; |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1085 | struct wilc_wep_key *wep_key; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1086 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1087 | wid_list[0].id = WID_11I_MODE; |
| 1088 | wid_list[0].type = WID_CHAR; |
| 1089 | wid_list[0].size = sizeof(char); |
| 1090 | wid_list[0].val = &mode; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1091 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1092 | wid_list[1].id = WID_AUTH_TYPE; |
| 1093 | wid_list[1].type = WID_CHAR; |
| 1094 | wid_list[1].size = sizeof(char); |
| 1095 | wid_list[1].val = (s8 *)&auth_type; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1096 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1097 | wid_list[2].id = WID_WEP_KEY_VALUE; |
| 1098 | wid_list[2].type = WID_STR; |
| 1099 | wid_list[2].size = sizeof(*wep_key) + len; |
| 1100 | wep_key = kzalloc(wid_list[2].size, GFP_KERNEL); |
| 1101 | if (!wep_key) |
| 1102 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1103 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1104 | wid_list[2].val = (u8 *)wep_key; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1105 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1106 | wep_key->index = index; |
| 1107 | wep_key->key_len = len; |
| 1108 | memcpy(wep_key->key, key, len); |
| 1109 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1110 | ARRAY_SIZE(wid_list)); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1111 | if (result) |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1112 | netdev_err(vif->ndev, |
| 1113 | "Failed to add wep ap key config packet\n"); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1114 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1115 | kfree(wep_key); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1116 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1117 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 1118 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1119 | int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, |
| 1120 | const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, |
| 1121 | u8 mode, u8 cipher_mode, u8 index) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1122 | { |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1123 | int result = 0; |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1124 | u8 t_key_len = ptk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 1125 | |
Ajay Singh | d0e41ef | 2018-11-12 05:45:29 +0000 | [diff] [blame] | 1126 | if (mode == WILC_AP_MODE) { |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1127 | struct wid wid_list[2]; |
| 1128 | struct wilc_ap_wpa_ptk *key_buf; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1129 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1130 | wid_list[0].id = WID_11I_MODE; |
| 1131 | wid_list[0].type = WID_CHAR; |
| 1132 | wid_list[0].size = sizeof(char); |
| 1133 | wid_list[0].val = (s8 *)&cipher_mode; |
| 1134 | |
| 1135 | key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); |
| 1136 | if (!key_buf) |
| 1137 | return -ENOMEM; |
| 1138 | |
| 1139 | ether_addr_copy(key_buf->mac_addr, mac_addr); |
| 1140 | key_buf->index = index; |
| 1141 | key_buf->key_len = t_key_len; |
| 1142 | memcpy(&key_buf->key[0], ptk, ptk_key_len); |
| 1143 | |
| 1144 | if (rx_mic) |
| 1145 | memcpy(&key_buf->key[ptk_key_len], rx_mic, |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1146 | WILC_RX_MIC_KEY_LEN); |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1147 | |
| 1148 | if (tx_mic) |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1149 | memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN], |
| 1150 | tx_mic, WILC_TX_MIC_KEY_LEN); |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1151 | |
| 1152 | wid_list[1].id = WID_ADD_PTK; |
| 1153 | wid_list[1].type = WID_STR; |
| 1154 | wid_list[1].size = sizeof(*key_buf) + t_key_len; |
| 1155 | wid_list[1].val = (u8 *)key_buf; |
| 1156 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1157 | ARRAY_SIZE(wid_list)); |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1158 | kfree(key_buf); |
| 1159 | } else if (mode == WILC_STATION_MODE) { |
| 1160 | struct wid wid; |
| 1161 | struct wilc_sta_wpa_ptk *key_buf; |
| 1162 | |
| 1163 | key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); |
| 1164 | if (!key_buf) |
| 1165 | return -ENOMEM; |
| 1166 | |
| 1167 | ether_addr_copy(key_buf->mac_addr, mac_addr); |
| 1168 | key_buf->key_len = t_key_len; |
| 1169 | memcpy(&key_buf->key[0], ptk, ptk_key_len); |
| 1170 | |
| 1171 | if (rx_mic) |
| 1172 | memcpy(&key_buf->key[ptk_key_len], rx_mic, |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1173 | WILC_RX_MIC_KEY_LEN); |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1174 | |
| 1175 | if (tx_mic) |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1176 | memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN], |
| 1177 | tx_mic, WILC_TX_MIC_KEY_LEN); |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1178 | |
| 1179 | wid.id = WID_ADD_PTK; |
| 1180 | wid.type = WID_STR; |
| 1181 | wid.size = sizeof(*key_buf) + t_key_len; |
| 1182 | wid.val = (s8 *)key_buf; |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1183 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1184 | kfree(key_buf); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1185 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1186 | |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1187 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1188 | } |
| 1189 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1190 | int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, |
| 1191 | u8 index, u32 key_rsc_len, const u8 *key_rsc, |
| 1192 | const u8 *rx_mic, const u8 *tx_mic, u8 mode, |
| 1193 | u8 cipher_mode) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1194 | { |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1195 | int result = 0; |
| 1196 | struct wilc_gtk_key *gtk_key; |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1197 | int t_key_len = gtk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1198 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1199 | gtk_key = kzalloc(sizeof(*gtk_key) + t_key_len, GFP_KERNEL); |
| 1200 | if (!gtk_key) |
| 1201 | return -ENOMEM; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1202 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1203 | /* fill bssid value only in station mode */ |
| 1204 | if (mode == WILC_STATION_MODE && |
| 1205 | vif->hif_drv->hif_state == HOST_IF_CONNECTED) |
| 1206 | memcpy(gtk_key->mac_addr, vif->hif_drv->assoc_bssid, ETH_ALEN); |
| 1207 | |
| 1208 | if (key_rsc) |
| 1209 | memcpy(gtk_key->rsc, key_rsc, 8); |
| 1210 | gtk_key->index = index; |
| 1211 | gtk_key->key_len = t_key_len; |
| 1212 | memcpy(>k_key->key[0], rx_gtk, gtk_key_len); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1213 | |
Chaehyun Lim | 6d36c27 | 2015-11-08 16:49:12 +0900 | [diff] [blame] | 1214 | if (rx_mic) |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1215 | memcpy(>k_key->key[gtk_key_len], rx_mic, WILC_RX_MIC_KEY_LEN); |
Leo Kim | 91109e1 | 2015-10-19 18:26:13 +0900 | [diff] [blame] | 1216 | |
Chaehyun Lim | 2f79758 | 2015-11-08 16:49:13 +0900 | [diff] [blame] | 1217 | if (tx_mic) |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1218 | memcpy(>k_key->key[gtk_key_len + WILC_RX_MIC_KEY_LEN], |
| 1219 | tx_mic, WILC_TX_MIC_KEY_LEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1220 | |
Ajay Singh | d0e41ef | 2018-11-12 05:45:29 +0000 | [diff] [blame] | 1221 | if (mode == WILC_AP_MODE) { |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1222 | struct wid wid_list[2]; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1223 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1224 | wid_list[0].id = WID_11I_MODE; |
| 1225 | wid_list[0].type = WID_CHAR; |
| 1226 | wid_list[0].size = sizeof(char); |
| 1227 | wid_list[0].val = (s8 *)&cipher_mode; |
| 1228 | |
| 1229 | wid_list[1].id = WID_ADD_RX_GTK; |
| 1230 | wid_list[1].type = WID_STR; |
| 1231 | wid_list[1].size = sizeof(*gtk_key) + t_key_len; |
| 1232 | wid_list[1].val = (u8 *)gtk_key; |
| 1233 | |
| 1234 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1235 | ARRAY_SIZE(wid_list)); |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1236 | } else if (mode == WILC_STATION_MODE) { |
| 1237 | struct wid wid; |
| 1238 | |
| 1239 | wid.id = WID_ADD_RX_GTK; |
| 1240 | wid.type = WID_STR; |
| 1241 | wid.size = sizeof(*gtk_key) + t_key_len; |
| 1242 | wid.val = (u8 *)gtk_key; |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1243 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 3b5f10d | 2018-03-26 17:16:01 +0530 | [diff] [blame] | 1244 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1245 | |
Gustavo A. R. Silva | fe2570f | 2018-12-22 03:08:15 -0600 | [diff] [blame] | 1246 | kfree(gtk_key); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1247 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1248 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1249 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1250 | int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1251 | { |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1252 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1253 | |
Ajay Singh | b61c806 | 2018-12-02 18:03:11 +0000 | [diff] [blame] | 1254 | wid.id = WID_PMKID_INFO; |
| 1255 | wid.type = WID_STR; |
| 1256 | wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1; |
| 1257 | wid.val = (u8 *)pmkid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1258 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1259 | return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1260 | } |
| 1261 | |
Chaehyun Lim | 1eabfe3 | 2015-12-22 09:49:07 +0900 | [diff] [blame] | 1262 | int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1263 | { |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1264 | int result; |
Ajay Singh | 153068b | 2018-12-02 18:03:17 +0000 | [diff] [blame] | 1265 | struct wid wid; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1266 | |
Ajay Singh | 153068b | 2018-12-02 18:03:17 +0000 | [diff] [blame] | 1267 | wid.id = WID_MAC_ADDR; |
| 1268 | wid.type = WID_STR; |
| 1269 | wid.size = ETH_ALEN; |
| 1270 | wid.val = mac_addr; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1271 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1272 | result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1273 | if (result) |
Ajay Singh | 153068b | 2018-12-02 18:03:17 +0000 | [diff] [blame] | 1274 | netdev_err(vif->ndev, "Failed to get mac address\n"); |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1275 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1276 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1277 | } |
| 1278 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 1279 | int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies, |
| 1280 | size_t ies_len) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1281 | { |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1282 | int result; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1283 | struct host_if_drv *hif_drv = vif->hif_drv; |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 1284 | struct wilc_conn_info *conn_info = &hif_drv->conn_info; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1285 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 1286 | if (bssid) |
| 1287 | ether_addr_copy(conn_info->bssid, bssid); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1288 | |
Chaehyun Lim | 88c9421 | 2015-12-24 16:52:24 +0900 | [diff] [blame] | 1289 | if (ies) { |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 1290 | conn_info->req_ies_len = ies_len; |
| 1291 | conn_info->req_ies = kmemdup(ies, ies_len, GFP_KERNEL); |
Nishka Dasgupta | 95313752 | 2019-03-22 01:25:55 +0530 | [diff] [blame] | 1292 | if (!conn_info->req_ies) |
| 1293 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1294 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1295 | |
Ajay Singh | e559681 | 2018-12-02 18:03:31 +0000 | [diff] [blame] | 1296 | result = wilc_send_connect_wid(vif); |
| 1297 | if (result) |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1298 | goto free_ies; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1299 | |
Kees Cook | 1f23319 | 2017-10-16 16:24:32 -0700 | [diff] [blame] | 1300 | hif_drv->connect_timer_vif = vif; |
Leo Kim | 81a5950 | 2015-10-29 11:58:35 +0900 | [diff] [blame] | 1301 | mod_timer(&hif_drv->connect_timer, |
Ajay Singh | b36b973 | 2019-02-02 19:17:05 +0000 | [diff] [blame] | 1302 | jiffies + msecs_to_jiffies(WILC_HIF_CONNECT_TIMEOUT_MS)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1303 | |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1304 | return 0; |
| 1305 | |
| 1306 | free_ies: |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 1307 | kfree(conn_info->req_ies); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1308 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1309 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1310 | } |
| 1311 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1312 | int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1313 | { |
Ajay Singh | 77506d4 | 2018-12-02 18:02:54 +0000 | [diff] [blame] | 1314 | struct wid wid; |
Chaehyun Lim | 792fb25 | 2015-10-05 11:07:22 +0900 | [diff] [blame] | 1315 | int result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1316 | |
Ajay Singh | 77506d4 | 2018-12-02 18:02:54 +0000 | [diff] [blame] | 1317 | wid.id = WID_CURRENT_CHANNEL; |
| 1318 | wid.type = WID_CHAR; |
| 1319 | wid.size = sizeof(char); |
| 1320 | wid.val = &channel; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1321 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1322 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 77506d4 | 2018-12-02 18:02:54 +0000 | [diff] [blame] | 1323 | if (result) |
| 1324 | netdev_err(vif->ndev, "Failed to set channel\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1325 | |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1326 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1327 | } |
| 1328 | |
Adham Abozaeid | 4b1b8b0 | 2019-08-01 20:15:11 +0000 | [diff] [blame] | 1329 | int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode, |
| 1330 | u8 ifc_id) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1331 | { |
Ajay Singh | 04a61fb | 2018-12-02 18:03:05 +0000 | [diff] [blame] | 1332 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1333 | int result; |
Ajay Singh | 04a61fb | 2018-12-02 18:03:05 +0000 | [diff] [blame] | 1334 | struct wilc_drv_handler drv; |
Leo Kim | c09389a | 2015-10-28 15:59:24 +0900 | [diff] [blame] | 1335 | |
Adham Abozaeid | 4b1b8b0 | 2019-08-01 20:15:11 +0000 | [diff] [blame] | 1336 | wid.id = WID_SET_OPERATION_MODE; |
Ajay Singh | 04a61fb | 2018-12-02 18:03:05 +0000 | [diff] [blame] | 1337 | wid.type = WID_STR; |
| 1338 | wid.size = sizeof(drv); |
| 1339 | wid.val = (u8 *)&drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1340 | |
Ajay Singh | 04a61fb | 2018-12-02 18:03:05 +0000 | [diff] [blame] | 1341 | drv.handler = cpu_to_le32(index); |
| 1342 | drv.mode = (ifc_id | (mode << 1)); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1343 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1344 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 04a61fb | 2018-12-02 18:03:05 +0000 | [diff] [blame] | 1345 | if (result) |
| 1346 | netdev_err(vif->ndev, "Failed to set driver handler\n"); |
Ajay Singh | 3999681 | 2018-09-25 11:53:34 +0530 | [diff] [blame] | 1347 | |
Chaehyun Lim | a094101 | 2015-10-05 19:34:47 +0900 | [diff] [blame] | 1348 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1349 | } |
| 1350 | |
Ajay Singh | 98651ca | 2018-12-02 18:03:08 +0000 | [diff] [blame] | 1351 | s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1352 | { |
Ajay Singh | 98651ca | 2018-12-02 18:03:08 +0000 | [diff] [blame] | 1353 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1354 | s32 result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1355 | |
Ajay Singh | 98651ca | 2018-12-02 18:03:08 +0000 | [diff] [blame] | 1356 | wid.id = WID_SET_STA_MAC_INACTIVE_TIME; |
| 1357 | wid.type = WID_STR; |
| 1358 | wid.size = ETH_ALEN; |
| 1359 | wid.val = kzalloc(wid.size, GFP_KERNEL); |
| 1360 | if (!wid.val) |
| 1361 | return -ENOMEM; |
| 1362 | |
| 1363 | ether_addr_copy(wid.val, mac); |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1364 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 98651ca | 2018-12-02 18:03:08 +0000 | [diff] [blame] | 1365 | kfree(wid.val); |
| 1366 | if (result) { |
| 1367 | netdev_err(vif->ndev, "Failed to set inactive mac\n"); |
| 1368 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1369 | } |
| 1370 | |
Ajay Singh | 98651ca | 2018-12-02 18:03:08 +0000 | [diff] [blame] | 1371 | wid.id = WID_GET_INACTIVE_TIME; |
| 1372 | wid.type = WID_INT; |
| 1373 | wid.val = (s8 *)out_val; |
| 1374 | wid.size = sizeof(u32); |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1375 | result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1376 | if (result) |
Ajay Singh | 98651ca | 2018-12-02 18:03:08 +0000 | [diff] [blame] | 1377 | netdev_err(vif->ndev, "Failed to get inactive time\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1378 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1379 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1380 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 1381 | |
Chaehyun Lim | 652bb5e | 2015-12-24 16:52:37 +0900 | [diff] [blame] | 1382 | int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1383 | { |
Ajay Singh | daf0483 | 2018-12-02 18:02:59 +0000 | [diff] [blame] | 1384 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1385 | int result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1386 | |
Chaehyun Lim | 652bb5e | 2015-12-24 16:52:37 +0900 | [diff] [blame] | 1387 | if (!rssi_level) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1388 | netdev_err(vif->ndev, "%s: RSSI level is NULL\n", __func__); |
Leo Kim | e6e1266 | 2015-09-16 18:36:03 +0900 | [diff] [blame] | 1389 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1390 | } |
| 1391 | |
Ajay Singh | daf0483 | 2018-12-02 18:02:59 +0000 | [diff] [blame] | 1392 | wid.id = WID_RSSI; |
| 1393 | wid.type = WID_CHAR; |
| 1394 | wid.size = sizeof(char); |
| 1395 | wid.val = rssi_level; |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1396 | result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); |
Ajay Singh | daf0483 | 2018-12-02 18:02:59 +0000 | [diff] [blame] | 1397 | if (result) |
| 1398 | netdev_err(vif->ndev, "Failed to get RSSI value\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1399 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1400 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1401 | } |
| 1402 | |
Marko Stankovic | 2f6fa4c | 2018-12-25 23:35:31 +0100 | [diff] [blame] | 1403 | static int wilc_get_stats_async(struct wilc_vif *vif, struct rf_info *stats) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1404 | { |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1405 | int result; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1406 | struct host_if_msg *msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1407 | |
Ajay Singh | 19cb25e1 | 2018-12-02 18:03:25 +0000 | [diff] [blame] | 1408 | msg = wilc_alloc_work(vif, handle_get_statistics, false); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1409 | if (IS_ERR(msg)) |
| 1410 | return PTR_ERR(msg); |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 1411 | |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1412 | msg->body.data = (char *)stats; |
| 1413 | |
Ajay Singh | c6a358d | 2018-06-26 11:37:08 +0530 | [diff] [blame] | 1414 | result = wilc_enqueue_work(msg); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1415 | if (result) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1416 | netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1417 | kfree(msg); |
| 1418 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1419 | } |
| 1420 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1421 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1422 | } |
| 1423 | |
Ajay Singh | 5323917 | 2018-12-02 18:02:57 +0000 | [diff] [blame] | 1424 | int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1425 | { |
Ajay Singh | 5323917 | 2018-12-02 18:02:57 +0000 | [diff] [blame] | 1426 | struct wid wid_list[4]; |
| 1427 | int i = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1428 | |
Ajay Singh | 5323917 | 2018-12-02 18:02:57 +0000 | [diff] [blame] | 1429 | if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) { |
| 1430 | wid_list[i].id = WID_SHORT_RETRY_LIMIT; |
| 1431 | wid_list[i].val = (s8 *)¶m->short_retry_limit; |
| 1432 | wid_list[i].type = WID_SHORT; |
| 1433 | wid_list[i].size = sizeof(u16); |
| 1434 | i++; |
| 1435 | } |
| 1436 | if (param->flag & WILC_CFG_PARAM_RETRY_LONG) { |
| 1437 | wid_list[i].id = WID_LONG_RETRY_LIMIT; |
| 1438 | wid_list[i].val = (s8 *)¶m->long_retry_limit; |
| 1439 | wid_list[i].type = WID_SHORT; |
| 1440 | wid_list[i].size = sizeof(u16); |
| 1441 | i++; |
| 1442 | } |
| 1443 | if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) { |
| 1444 | wid_list[i].id = WID_FRAG_THRESHOLD; |
| 1445 | wid_list[i].val = (s8 *)¶m->frag_threshold; |
| 1446 | wid_list[i].type = WID_SHORT; |
| 1447 | wid_list[i].size = sizeof(u16); |
| 1448 | i++; |
| 1449 | } |
| 1450 | if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) { |
| 1451 | wid_list[i].id = WID_RTS_THRESHOLD; |
| 1452 | wid_list[i].val = (s8 *)¶m->rts_threshold; |
| 1453 | wid_list[i].type = WID_SHORT; |
| 1454 | wid_list[i].size = sizeof(u16); |
| 1455 | i++; |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1456 | } |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 1457 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1458 | return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, i); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1459 | } |
| 1460 | |
Ajay Singh | 5fefe58 | 2018-09-04 12:09:28 +0530 | [diff] [blame] | 1461 | static void get_periodic_rssi(struct timer_list *t) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1462 | { |
Ajay Singh | 5fefe58 | 2018-09-04 12:09:28 +0530 | [diff] [blame] | 1463 | struct wilc_vif *vif = from_timer(vif, t, periodic_rssi); |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 1464 | |
Glen Lee | 71130e8 | 2015-12-21 14:18:41 +0900 | [diff] [blame] | 1465 | if (!vif->hif_drv) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1466 | netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1467 | return; |
| 1468 | } |
| 1469 | |
Glen Lee | 4fd6229 | 2016-02-04 18:15:24 +0900 | [diff] [blame] | 1470 | if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) |
Ajay Singh | 19cb25e1 | 2018-12-02 18:03:25 +0000 | [diff] [blame] | 1471 | wilc_get_stats_async(vif, &vif->periodic_stat); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1472 | |
Ajay Singh | 5fefe58 | 2018-09-04 12:09:28 +0530 | [diff] [blame] | 1473 | mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1474 | } |
| 1475 | |
Chaehyun Lim | 1e995c1 | 2016-01-05 23:06:57 +0900 | [diff] [blame] | 1476 | 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] | 1477 | { |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 1478 | struct host_if_drv *hif_drv; |
Ajay Singh | 6bcba96 | 2018-07-19 04:15:19 +0530 | [diff] [blame] | 1479 | struct wilc_vif *vif = netdev_priv(dev); |
| 1480 | struct wilc *wilc = vif->wilc; |
Glen Lee | d5382219 | 2015-10-27 18:27:49 +0900 | [diff] [blame] | 1481 | |
sayli karnik | faa48ea | 2016-09-16 16:23:02 +0530 | [diff] [blame] | 1482 | hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL); |
Ajay Singh | 4b255c6 | 2018-04-23 22:03:31 +0530 | [diff] [blame] | 1483 | if (!hif_drv) |
| 1484 | return -ENOMEM; |
| 1485 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 1486 | *hif_drv_handler = hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1487 | |
Ajay Singh | 264a472 | 2019-06-26 12:40:58 +0000 | [diff] [blame] | 1488 | vif->hif_drv = hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1489 | |
Ajay Singh | 3999681 | 2018-09-25 11:53:34 +0530 | [diff] [blame] | 1490 | if (wilc->clients_count == 0) |
Ajay Singh | 98f83d3 | 2019-02-05 07:15:54 +0000 | [diff] [blame] | 1491 | mutex_init(&wilc->deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1492 | |
Ajay Singh | 5fefe58 | 2018-09-04 12:09:28 +0530 | [diff] [blame] | 1493 | timer_setup(&vif->periodic_rssi, get_periodic_rssi, 0); |
| 1494 | mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000)); |
| 1495 | |
Ajay Singh | 4189eb5 | 2018-02-19 20:59:40 +0530 | [diff] [blame] | 1496 | timer_setup(&hif_drv->scan_timer, timer_scan_cb, 0); |
| 1497 | timer_setup(&hif_drv->connect_timer, timer_connect_cb, 0); |
Ajay Singh | b44c386 | 2018-02-19 20:59:41 +0530 | [diff] [blame] | 1498 | timer_setup(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1499 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1500 | hif_drv->hif_state = HOST_IF_IDLE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1501 | |
Leo Kim | 1229b1a | 2015-10-29 12:05:39 +0900 | [diff] [blame] | 1502 | hif_drv->p2p_timeout = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1503 | |
Ajay Singh | 0b68334 | 2018-09-04 12:09:25 +0530 | [diff] [blame] | 1504 | wilc->clients_count++; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1505 | |
Ajay Singh | 4b255c6 | 2018-04-23 22:03:31 +0530 | [diff] [blame] | 1506 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1507 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1508 | |
Chaehyun Lim | 127a27c | 2016-02-05 10:35:13 +0900 | [diff] [blame] | 1509 | int wilc_deinit(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1510 | { |
Chaehyun Lim | 127a27c | 2016-02-05 10:35:13 +0900 | [diff] [blame] | 1511 | int result = 0; |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1512 | struct host_if_drv *hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1513 | |
Ajay Singh | 74cffaf | 2018-07-19 04:15:11 +0530 | [diff] [blame] | 1514 | if (!hif_drv) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1515 | netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); |
Chaehyun Lim | 8eb62f3 | 2016-02-05 10:35:14 +0900 | [diff] [blame] | 1516 | return -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1517 | } |
| 1518 | |
Ajay Singh | 98f83d3 | 2019-02-05 07:15:54 +0000 | [diff] [blame] | 1519 | mutex_lock(&vif->wilc->deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1520 | |
Chris Park | c4f9752 | 2016-02-04 18:24:04 +0900 | [diff] [blame] | 1521 | del_timer_sync(&hif_drv->scan_timer); |
| 1522 | del_timer_sync(&hif_drv->connect_timer); |
Ajay Singh | 5fefe58 | 2018-09-04 12:09:28 +0530 | [diff] [blame] | 1523 | del_timer_sync(&vif->periodic_rssi); |
Leo Kim | cc2d7e9 | 2015-10-29 11:58:36 +0900 | [diff] [blame] | 1524 | del_timer_sync(&hif_drv->remain_on_ch_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1525 | |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1526 | if (hif_drv->usr_scan_req.scan_result) { |
| 1527 | hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL, |
Ajay Singh | 6c2cfb4 | 2019-01-17 13:21:18 +0000 | [diff] [blame] | 1528 | hif_drv->usr_scan_req.arg); |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1529 | hif_drv->usr_scan_req.scan_result = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1530 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1531 | |
Leo Kim | b60005a | 2015-10-29 11:58:24 +0900 | [diff] [blame] | 1532 | hif_drv->hif_state = HOST_IF_IDLE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1533 | |
Tony Cho | a4ab1ad | 2015-10-12 16:56:05 +0900 | [diff] [blame] | 1534 | kfree(hif_drv); |
Ajay Singh | 3c55a24 | 2019-02-05 07:15:31 +0000 | [diff] [blame] | 1535 | vif->hif_drv = NULL; |
Ajay Singh | 0b68334 | 2018-09-04 12:09:25 +0530 | [diff] [blame] | 1536 | vif->wilc->clients_count--; |
Ajay Singh | 98f83d3 | 2019-02-05 07:15:54 +0000 | [diff] [blame] | 1537 | mutex_unlock(&vif->wilc->deinit_lock); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1538 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1539 | } |
| 1540 | |
Tahia Khan | bdb27e6 | 2017-03-07 19:26:41 -0500 | [diff] [blame] | 1541 | void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1542 | { |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 1543 | int result; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1544 | struct host_if_msg *msg; |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 1545 | int id; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1546 | struct host_if_drv *hif_drv; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 1547 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1548 | |
Ajay Singh | 92f6de4 | 2019-01-17 13:21:10 +0000 | [diff] [blame] | 1549 | id = get_unaligned_le32(&buffer[length - 4]); |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 1550 | vif = wilc_get_vif_from_idx(wilc, id); |
| 1551 | if (!vif) |
| 1552 | return; |
| 1553 | hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1554 | |
Ajay Singh | 3c55a24 | 2019-02-05 07:15:31 +0000 | [diff] [blame] | 1555 | if (!hif_drv) { |
Chris Park | b92f930 | 2016-02-22 13:12:02 +0900 | [diff] [blame] | 1556 | netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1557 | return; |
| 1558 | } |
| 1559 | |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1560 | msg = wilc_alloc_work(vif, handle_rcvd_ntwrk_info, false); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1561 | if (IS_ERR(msg)) |
Ajay Singh | 25b95133 | 2018-03-26 17:15:56 +0530 | [diff] [blame] | 1562 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1563 | |
Ajay Singh | 6cd4fa5 | 2019-01-17 13:21:21 +0000 | [diff] [blame] | 1564 | msg->body.net_info.frame_len = get_unaligned_le16(&buffer[6]) - 1; |
| 1565 | msg->body.net_info.rssi = buffer[8]; |
| 1566 | msg->body.net_info.mgmt = kmemdup(&buffer[9], |
| 1567 | msg->body.net_info.frame_len, |
| 1568 | GFP_KERNEL); |
| 1569 | if (!msg->body.net_info.mgmt) { |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1570 | kfree(msg); |
| 1571 | return; |
| 1572 | } |
| 1573 | |
Ajay Singh | c6a358d | 2018-06-26 11:37:08 +0530 | [diff] [blame] | 1574 | result = wilc_enqueue_work(msg); |
Ajay Singh | 25b95133 | 2018-03-26 17:15:56 +0530 | [diff] [blame] | 1575 | if (result) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1576 | netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); |
Ajay Singh | 6cd4fa5 | 2019-01-17 13:21:21 +0000 | [diff] [blame] | 1577 | kfree(msg->body.net_info.mgmt); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1578 | kfree(msg); |
Ajay Singh | 25b95133 | 2018-03-26 17:15:56 +0530 | [diff] [blame] | 1579 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1580 | } |
| 1581 | |
Tahia Khan | 28c8285 | 2017-03-07 19:26:44 -0500 | [diff] [blame] | 1582 | void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1583 | { |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 1584 | int result; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1585 | struct host_if_msg *msg; |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 1586 | int id; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1587 | struct host_if_drv *hif_drv; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 1588 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1589 | |
Ajay Singh | 98f83d3 | 2019-02-05 07:15:54 +0000 | [diff] [blame] | 1590 | mutex_lock(&wilc->deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1591 | |
Ajay Singh | 92f6de4 | 2019-01-17 13:21:10 +0000 | [diff] [blame] | 1592 | id = get_unaligned_le32(&buffer[length - 4]); |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 1593 | vif = wilc_get_vif_from_idx(wilc, id); |
| 1594 | if (!vif) { |
Ajay Singh | 98f83d3 | 2019-02-05 07:15:54 +0000 | [diff] [blame] | 1595 | mutex_unlock(&wilc->deinit_lock); |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 1596 | return; |
| 1597 | } |
| 1598 | |
| 1599 | hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1600 | |
Ajay Singh | 3c55a24 | 2019-02-05 07:15:31 +0000 | [diff] [blame] | 1601 | if (!hif_drv) { |
Ajay Singh | 98f83d3 | 2019-02-05 07:15:54 +0000 | [diff] [blame] | 1602 | mutex_unlock(&wilc->deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1603 | return; |
| 1604 | } |
| 1605 | |
Ajay Singh | 734c319 | 2019-01-17 13:21:32 +0000 | [diff] [blame] | 1606 | if (!hif_drv->conn_info.conn_result) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1607 | netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); |
Ajay Singh | 98f83d3 | 2019-02-05 07:15:54 +0000 | [diff] [blame] | 1608 | mutex_unlock(&wilc->deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1609 | return; |
| 1610 | } |
| 1611 | |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1612 | msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info, false); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1613 | if (IS_ERR(msg)) { |
Ajay Singh | 98f83d3 | 2019-02-05 07:15:54 +0000 | [diff] [blame] | 1614 | mutex_unlock(&wilc->deinit_lock); |
Ajay Singh | fe014d4 | 2018-03-26 17:16:03 +0530 | [diff] [blame] | 1615 | return; |
| 1616 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1617 | |
Ajay Singh | 94bb6d3 | 2019-01-17 13:21:35 +0000 | [diff] [blame] | 1618 | msg->body.mac_info.status = buffer[7]; |
Ajay Singh | c6a358d | 2018-06-26 11:37:08 +0530 | [diff] [blame] | 1619 | result = wilc_enqueue_work(msg); |
Ajay Singh | fe014d4 | 2018-03-26 17:16:03 +0530 | [diff] [blame] | 1620 | if (result) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1621 | netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1622 | kfree(msg); |
Ajay Singh | fe014d4 | 2018-03-26 17:16:03 +0530 | [diff] [blame] | 1623 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1624 | |
Ajay Singh | 98f83d3 | 2019-02-05 07:15:54 +0000 | [diff] [blame] | 1625 | mutex_unlock(&wilc->deinit_lock); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1626 | } |
| 1627 | |
Tahia Khan | dade3c6 | 2017-03-07 19:26:37 -0500 | [diff] [blame] | 1628 | void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1629 | { |
Ajay Singh | 82120ec | 2018-07-19 04:15:17 +0530 | [diff] [blame] | 1630 | int result; |
Johnny Kim | d42ab08 | 2015-08-20 16:32:52 +0900 | [diff] [blame] | 1631 | int id; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1632 | struct host_if_drv *hif_drv; |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 1633 | struct wilc_vif *vif; |
Luis de Bethencourt | 78c8759 | 2015-06-26 16:45:14 +0200 | [diff] [blame] | 1634 | |
Ajay Singh | 92f6de4 | 2019-01-17 13:21:10 +0000 | [diff] [blame] | 1635 | id = get_unaligned_le32(&buffer[length - 4]); |
Glen Lee | eb9939b | 2015-12-21 14:18:43 +0900 | [diff] [blame] | 1636 | vif = wilc_get_vif_from_idx(wilc, id); |
| 1637 | if (!vif) |
| 1638 | return; |
| 1639 | hif_drv = vif->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1640 | |
Ajay Singh | 3c55a24 | 2019-02-05 07:15:31 +0000 | [diff] [blame] | 1641 | if (!hif_drv) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1642 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1643 | |
Leo Kim | bc80185 | 2015-10-29 11:58:50 +0900 | [diff] [blame] | 1644 | if (hif_drv->usr_scan_req.scan_result) { |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1645 | struct host_if_msg *msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1646 | |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1647 | msg = wilc_alloc_work(vif, handle_scan_complete, false); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1648 | if (IS_ERR(msg)) |
| 1649 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1650 | |
Ajay Singh | c6a358d | 2018-06-26 11:37:08 +0530 | [diff] [blame] | 1651 | result = wilc_enqueue_work(msg); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1652 | if (result) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1653 | netdev_err(vif->ndev, "%s: enqueue work failed\n", |
| 1654 | __func__); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1655 | kfree(msg); |
| 1656 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1657 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1658 | } |
| 1659 | |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 1660 | int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, |
Chaehyun Lim | d44cd45 | 2016-01-03 17:35:36 +0900 | [diff] [blame] | 1661 | u32 duration, u16 chan, |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 1662 | void (*expired)(void *, u64), |
Chaehyun Lim | 482c433 | 2016-01-03 17:35:39 +0900 | [diff] [blame] | 1663 | void *user_arg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1664 | { |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1665 | struct wilc_remain_ch roc; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1666 | int result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1667 | |
Ajay Singh | 05d3bcb | 2018-12-02 18:03:22 +0000 | [diff] [blame] | 1668 | roc.ch = chan; |
| 1669 | roc.expired = expired; |
Ajay Singh | 05d3bcb | 2018-12-02 18:03:22 +0000 | [diff] [blame] | 1670 | roc.arg = user_arg; |
| 1671 | roc.duration = duration; |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 1672 | roc.cookie = cookie; |
Ajay Singh | 05d3bcb | 2018-12-02 18:03:22 +0000 | [diff] [blame] | 1673 | result = handle_remain_on_chan(vif, &roc); |
| 1674 | if (result) |
| 1675 | netdev_err(vif->ndev, "%s: failed to set remain on channel\n", |
| 1676 | __func__); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1677 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1678 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1679 | } |
| 1680 | |
Ajay Singh | b6c6cd1 | 2019-02-05 07:15:39 +0000 | [diff] [blame] | 1681 | int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1682 | { |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 1683 | if (!vif->hif_drv) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1684 | netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1685 | return -EFAULT; |
| 1686 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1687 | |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 1688 | del_timer(&vif->hif_drv->remain_on_ch_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1689 | |
Ajay Singh | 424a611 | 2019-06-26 12:40:45 +0000 | [diff] [blame] | 1690 | return wilc_handle_roc_expired(vif, cookie); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1691 | } |
| 1692 | |
Ajay Singh | e8de0ac | 2018-09-25 11:53:16 +0530 | [diff] [blame] | 1693 | void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1694 | { |
Ajay Singh | 147ccfd | 2018-12-02 18:02:51 +0000 | [diff] [blame] | 1695 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1696 | int result; |
Ajay Singh | 147ccfd | 2018-12-02 18:02:51 +0000 | [diff] [blame] | 1697 | struct wilc_reg_frame reg_frame; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1698 | |
Ajay Singh | 147ccfd | 2018-12-02 18:02:51 +0000 | [diff] [blame] | 1699 | wid.id = WID_REGISTER_FRAME; |
| 1700 | wid.type = WID_STR; |
| 1701 | wid.size = sizeof(reg_frame); |
| 1702 | wid.val = (u8 *)®_frame; |
| 1703 | |
| 1704 | memset(®_frame, 0x0, sizeof(reg_frame)); |
Ajay Singh | 5e3bafb | 2019-11-05 09:51:22 +0000 | [diff] [blame] | 1705 | |
| 1706 | if (reg) |
| 1707 | reg_frame.reg = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1708 | |
Chaehyun Lim | 2a8432f | 2015-12-30 21:15:26 +0900 | [diff] [blame] | 1709 | switch (frame_type) { |
Ajay Singh | 2bae293 | 2018-11-12 05:45:03 +0000 | [diff] [blame] | 1710 | case IEEE80211_STYPE_ACTION: |
Ajay Singh | 147ccfd | 2018-12-02 18:02:51 +0000 | [diff] [blame] | 1711 | reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1712 | break; |
| 1713 | |
Ajay Singh | 2bae293 | 2018-11-12 05:45:03 +0000 | [diff] [blame] | 1714 | case IEEE80211_STYPE_PROBE_REQ: |
Ajay Singh | 147ccfd | 2018-12-02 18:02:51 +0000 | [diff] [blame] | 1715 | reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1716 | break; |
| 1717 | |
| 1718 | default: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1719 | break; |
| 1720 | } |
Ajay Singh | 147ccfd | 2018-12-02 18:02:51 +0000 | [diff] [blame] | 1721 | reg_frame.frame_type = cpu_to_le16(frame_type); |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1722 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 147ccfd | 2018-12-02 18:02:51 +0000 | [diff] [blame] | 1723 | if (result) |
| 1724 | netdev_err(vif->ndev, "Failed to frame register\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1725 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1726 | |
Chaehyun Lim | 916935f | 2016-01-03 17:35:57 +0900 | [diff] [blame] | 1727 | int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, |
Ajay Singh | 976c89b | 2018-12-02 18:02:48 +0000 | [diff] [blame] | 1728 | struct cfg80211_beacon_data *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1729 | { |
Ajay Singh | 976c89b | 2018-12-02 18:02:48 +0000 | [diff] [blame] | 1730 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1731 | int result; |
Ajay Singh | 976c89b | 2018-12-02 18:02:48 +0000 | [diff] [blame] | 1732 | u8 *cur_byte; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1733 | |
Ajay Singh | 976c89b | 2018-12-02 18:02:48 +0000 | [diff] [blame] | 1734 | wid.id = WID_ADD_BEACON; |
| 1735 | wid.type = WID_BIN; |
| 1736 | wid.size = params->head_len + params->tail_len + 16; |
| 1737 | wid.val = kzalloc(wid.size, GFP_KERNEL); |
| 1738 | if (!wid.val) |
| 1739 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1740 | |
Ajay Singh | 976c89b | 2018-12-02 18:02:48 +0000 | [diff] [blame] | 1741 | cur_byte = wid.val; |
| 1742 | put_unaligned_le32(interval, cur_byte); |
| 1743 | cur_byte += 4; |
| 1744 | put_unaligned_le32(dtim_period, cur_byte); |
| 1745 | cur_byte += 4; |
| 1746 | put_unaligned_le32(params->head_len, cur_byte); |
| 1747 | cur_byte += 4; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1748 | |
Ajay Singh | 976c89b | 2018-12-02 18:02:48 +0000 | [diff] [blame] | 1749 | if (params->head_len > 0) |
| 1750 | memcpy(cur_byte, params->head, params->head_len); |
| 1751 | cur_byte += params->head_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1752 | |
Ajay Singh | 976c89b | 2018-12-02 18:02:48 +0000 | [diff] [blame] | 1753 | put_unaligned_le32(params->tail_len, cur_byte); |
| 1754 | cur_byte += 4; |
| 1755 | |
| 1756 | if (params->tail_len > 0) |
| 1757 | memcpy(cur_byte, params->tail, params->tail_len); |
| 1758 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1759 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1760 | if (result) |
Ajay Singh | 976c89b | 2018-12-02 18:02:48 +0000 | [diff] [blame] | 1761 | netdev_err(vif->ndev, "Failed to send add beacon\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1762 | |
Ajay Singh | 976c89b | 2018-12-02 18:02:48 +0000 | [diff] [blame] | 1763 | kfree(wid.val); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1764 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1765 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1766 | } |
| 1767 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1768 | int wilc_del_beacon(struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1769 | { |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1770 | int result; |
Ajay Singh | 38b3ffa | 2018-12-02 18:02:45 +0000 | [diff] [blame] | 1771 | struct wid wid; |
| 1772 | u8 del_beacon = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1773 | |
Ajay Singh | 38b3ffa | 2018-12-02 18:02:45 +0000 | [diff] [blame] | 1774 | wid.id = WID_DEL_BEACON; |
| 1775 | wid.type = WID_CHAR; |
| 1776 | wid.size = sizeof(char); |
| 1777 | wid.val = &del_beacon; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1778 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1779 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 38b3ffa | 2018-12-02 18:02:45 +0000 | [diff] [blame] | 1780 | if (result) |
| 1781 | netdev_err(vif->ndev, "Failed to send delete beacon\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1782 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1783 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1784 | } |
| 1785 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1786 | int wilc_add_station(struct wilc_vif *vif, const u8 *mac, |
| 1787 | struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1788 | { |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1789 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1790 | int result; |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1791 | u8 *cur_byte; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1792 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1793 | wid.id = WID_ADD_STA; |
| 1794 | wid.type = WID_BIN; |
| 1795 | wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len; |
| 1796 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
| 1797 | if (!wid.val) |
| 1798 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1799 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1800 | cur_byte = wid.val; |
Ajay Singh | 6133ed9 | 2018-12-02 18:02:36 +0000 | [diff] [blame] | 1801 | wilc_hif_pack_sta_param(cur_byte, mac, params); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1802 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1803 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1804 | if (result != 0) |
| 1805 | netdev_err(vif->ndev, "Failed to send add station\n"); |
| 1806 | |
| 1807 | kfree(wid.val); |
| 1808 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1809 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1810 | } |
| 1811 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1812 | int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1813 | { |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1814 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1815 | int result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1816 | |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1817 | wid.id = WID_REMOVE_STA; |
| 1818 | wid.type = WID_BIN; |
| 1819 | wid.size = ETH_ALEN; |
| 1820 | wid.val = kzalloc(wid.size, GFP_KERNEL); |
| 1821 | if (!wid.val) |
| 1822 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1823 | |
Chaehyun Lim | c9c4eb4 | 2015-11-06 19:11:14 +0900 | [diff] [blame] | 1824 | if (!mac_addr) |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1825 | eth_broadcast_addr(wid.val); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1826 | else |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1827 | ether_addr_copy(wid.val, mac_addr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1828 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1829 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1830 | if (result) |
| 1831 | netdev_err(vif->ndev, "Failed to del station\n"); |
| 1832 | |
| 1833 | kfree(wid.val); |
| 1834 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1835 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1836 | } |
Leo Kim | ae4dfa5 | 2015-10-13 19:49:26 +0900 | [diff] [blame] | 1837 | |
Chaehyun Lim | 2092374d | 2016-01-03 17:35:50 +0900 | [diff] [blame] | 1838 | 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] | 1839 | { |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1840 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1841 | int result; |
Chaehyun Lim | cc971ee | 2016-01-03 17:35:53 +0900 | [diff] [blame] | 1842 | int i; |
Chaehyun Lim | 9d6cec9 | 2016-01-03 17:35:54 +0900 | [diff] [blame] | 1843 | u8 assoc_sta = 0; |
Ajay Singh | f5436ed | 2019-02-07 11:29:01 +0000 | [diff] [blame] | 1844 | struct wilc_del_all_sta del_sta; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1845 | |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1846 | memset(&del_sta, 0x0, sizeof(del_sta)); |
Ajay Singh | d0e41ef | 2018-11-12 05:45:29 +0000 | [diff] [blame] | 1847 | for (i = 0; i < WILC_MAX_NUM_STA; i++) { |
Ajay Singh | 4c00f70 | 2018-12-02 18:02:43 +0000 | [diff] [blame] | 1848 | if (!is_zero_ether_addr(mac_addr[i])) { |
Chaehyun Lim | 9d6cec9 | 2016-01-03 17:35:54 +0900 | [diff] [blame] | 1849 | assoc_sta++; |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1850 | ether_addr_copy(del_sta.mac[i], mac_addr[i]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1851 | } |
| 1852 | } |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1853 | |
| 1854 | if (!assoc_sta) |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1855 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1856 | |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1857 | del_sta.assoc_sta = assoc_sta; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1858 | |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1859 | wid.id = WID_DEL_ALL_STA; |
| 1860 | wid.type = WID_STR; |
| 1861 | wid.size = (assoc_sta * ETH_ALEN) + 1; |
| 1862 | wid.val = (u8 *)&del_sta; |
| 1863 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1864 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1865 | if (result) |
Ajay Singh | 9f1bdb7 | 2018-12-02 18:02:40 +0000 | [diff] [blame] | 1866 | netdev_err(vif->ndev, "Failed to send delete all station\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1867 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1868 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1869 | } |
| 1870 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1871 | int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, |
| 1872 | struct station_parameters *params) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1873 | { |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1874 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1875 | int result; |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1876 | u8 *cur_byte; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1877 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1878 | wid.id = WID_EDIT_STA; |
| 1879 | wid.type = WID_BIN; |
| 1880 | wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len; |
| 1881 | wid.val = kmalloc(wid.size, GFP_KERNEL); |
| 1882 | if (!wid.val) |
| 1883 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1884 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1885 | cur_byte = wid.val; |
Ajay Singh | 6133ed9 | 2018-12-02 18:02:36 +0000 | [diff] [blame] | 1886 | wilc_hif_pack_sta_param(cur_byte, mac, params); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1887 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1888 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1889 | if (result) |
| 1890 | netdev_err(vif->ndev, "Failed to send edit station\n"); |
Leo Kim | 24db713 | 2015-09-16 18:36:01 +0900 | [diff] [blame] | 1891 | |
Ajay Singh | 78c0c4e | 2018-12-02 18:02:34 +0000 | [diff] [blame] | 1892 | kfree(wid.val); |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1893 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1894 | } |
Glen Lee | 108b343 | 2015-09-16 18:53:20 +0900 | [diff] [blame] | 1895 | |
Chaehyun Lim | ecd2750 | 2015-12-30 21:15:32 +0900 | [diff] [blame] | 1896 | 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] | 1897 | { |
Ajay Singh | cf6d060 | 2018-12-02 18:02:31 +0000 | [diff] [blame] | 1898 | struct wid wid; |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1899 | int result; |
Ajay Singh | cf6d060 | 2018-12-02 18:02:31 +0000 | [diff] [blame] | 1900 | s8 power_mode; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1901 | |
Ajay Singh | cf6d060 | 2018-12-02 18:02:31 +0000 | [diff] [blame] | 1902 | if (enabled) |
| 1903 | power_mode = WILC_FW_MIN_FAST_PS; |
| 1904 | else |
| 1905 | power_mode = WILC_FW_NO_POWERSAVE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1906 | |
Ajay Singh | cf6d060 | 2018-12-02 18:02:31 +0000 | [diff] [blame] | 1907 | wid.id = WID_POWER_MANAGEMENT; |
| 1908 | wid.val = &power_mode; |
| 1909 | wid.size = sizeof(char); |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1910 | result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Ajay Singh | cf6d060 | 2018-12-02 18:02:31 +0000 | [diff] [blame] | 1911 | if (result) |
| 1912 | netdev_err(vif->ndev, "Failed to send power management\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1913 | |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1914 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1915 | } |
| 1916 | |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 1917 | int wilc_setup_multicast_filter(struct wilc_vif *vif, u32 enabled, u32 count, |
Ajay Singh | e624c58 | 2018-09-04 12:09:26 +0530 | [diff] [blame] | 1918 | u8 *mc_list) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1919 | { |
Ajay Singh | d241877 | 2018-07-19 04:15:16 +0530 | [diff] [blame] | 1920 | int result; |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1921 | struct host_if_msg *msg; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1922 | |
Ajay Singh | 5e6f8a8 | 2018-06-26 11:37:06 +0530 | [diff] [blame] | 1923 | msg = wilc_alloc_work(vif, handle_set_mcast_filter, false); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1924 | if (IS_ERR(msg)) |
| 1925 | return PTR_ERR(msg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1926 | |
Ajay Singh | a0c6a32 | 2019-01-17 13:21:41 +0000 | [diff] [blame] | 1927 | msg->body.mc_info.enabled = enabled; |
| 1928 | msg->body.mc_info.cnt = count; |
| 1929 | msg->body.mc_info.mc_list = mc_list; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1930 | |
Ajay Singh | c6a358d | 2018-06-26 11:37:08 +0530 | [diff] [blame] | 1931 | result = wilc_enqueue_work(msg); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1932 | if (result) { |
Ajay Singh | a120adb8 | 2018-07-29 11:36:53 +0530 | [diff] [blame] | 1933 | netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); |
Ajay Singh | ff52a57 | 2018-06-26 11:37:05 +0530 | [diff] [blame] | 1934 | kfree(msg); |
| 1935 | } |
Leo Kim | 31390ee | 2015-10-19 18:26:08 +0900 | [diff] [blame] | 1936 | return result; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1937 | } |
| 1938 | |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 1939 | int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) |
| 1940 | { |
Ajay Singh | 430d0ec | 2018-12-02 18:02:28 +0000 | [diff] [blame] | 1941 | struct wid wid; |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 1942 | |
Ajay Singh | 430d0ec | 2018-12-02 18:02:28 +0000 | [diff] [blame] | 1943 | wid.id = WID_TX_POWER; |
| 1944 | wid.type = WID_CHAR; |
| 1945 | wid.val = &tx_power; |
| 1946 | wid.size = sizeof(char); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 1947 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1948 | return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 1949 | } |
| 1950 | |
| 1951 | int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) |
| 1952 | { |
Ajay Singh | 430d0ec | 2018-12-02 18:02:28 +0000 | [diff] [blame] | 1953 | struct wid wid; |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 1954 | |
Ajay Singh | 430d0ec | 2018-12-02 18:02:28 +0000 | [diff] [blame] | 1955 | wid.id = WID_TX_POWER; |
| 1956 | wid.type = WID_CHAR; |
| 1957 | wid.val = tx_power; |
| 1958 | wid.size = sizeof(char); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 1959 | |
Ajay Singh | 93592a6 | 2019-06-26 12:41:04 +0000 | [diff] [blame] | 1960 | return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); |
Glen Lee | 7041879 | 2016-02-04 18:15:27 +0900 | [diff] [blame] | 1961 | } |