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