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 static inline void host_int_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 else 651 netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); 652 653 eth_zero_addr(hif_drv->assoc_bssid); 654 655 hif_drv->conn_info.req_ies_len = 0; 656 kfree(hif_drv->conn_info.req_ies); 657 hif_drv->conn_info.req_ies = NULL; 658 hif_drv->hif_state = HOST_IF_IDLE; 659 } 660 661 static void handle_rcvd_gnrl_async_info(struct work_struct *work) 662 { 663 struct host_if_msg *msg = container_of(work, struct host_if_msg, work); 664 struct wilc_vif *vif = msg->vif; 665 struct wilc_rcvd_mac_info *mac_info = &msg->body.mac_info; 666 struct host_if_drv *hif_drv = vif->hif_drv; 667 668 if (!hif_drv) { 669 netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); 670 goto free_msg; 671 } 672 673 if (!hif_drv->conn_info.conn_result) { 674 netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); 675 goto free_msg; 676 } 677 678 679 if (hif_drv->hif_state == HOST_IF_EXTERNAL_AUTH) { 680 cfg80211_external_auth_request(vif->ndev, &vif->auth, 681 GFP_KERNEL); 682 hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP; 683 } else if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) { 684 host_int_parse_assoc_resp_info(vif, mac_info->status); 685 } else if (mac_info->status == WILC_MAC_STATUS_DISCONNECTED) { 686 if (hif_drv->hif_state == HOST_IF_CONNECTED) { 687 host_int_handle_disconnect(vif); 688 } else if (hif_drv->usr_scan_req.scan_result) { 689 del_timer(&hif_drv->scan_timer); 690 handle_scan_done(vif, SCAN_EVENT_ABORTED); 691 } 692 } 693 694 free_msg: 695 kfree(msg); 696 } 697 698 int wilc_disconnect(struct wilc_vif *vif) 699 { 700 struct wid wid; 701 struct host_if_drv *hif_drv = vif->hif_drv; 702 struct wilc_user_scan_req *scan_req; 703 struct wilc_conn_info *conn_info; 704 int result; 705 u16 dummy_reason_code = 0; 706 707 wid.id = WID_DISCONNECT; 708 wid.type = WID_CHAR; 709 wid.val = (s8 *)&dummy_reason_code; 710 wid.size = sizeof(char); 711 712 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 713 if (result) { 714 netdev_err(vif->ndev, "Failed to send disconnect\n"); 715 return result; 716 } 717 718 scan_req = &hif_drv->usr_scan_req; 719 conn_info = &hif_drv->conn_info; 720 721 if (scan_req->scan_result) { 722 del_timer(&hif_drv->scan_timer); 723 scan_req->scan_result(SCAN_EVENT_ABORTED, NULL, scan_req->arg); 724 scan_req->scan_result = NULL; 725 } 726 727 if (conn_info->conn_result) { 728 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP || 729 hif_drv->hif_state == HOST_IF_EXTERNAL_AUTH) 730 del_timer(&hif_drv->connect_timer); 731 732 conn_info->conn_result(CONN_DISCONN_EVENT_DISCONN_NOTIF, 0, 733 conn_info->arg); 734 } else { 735 netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); 736 } 737 738 hif_drv->hif_state = HOST_IF_IDLE; 739 740 eth_zero_addr(hif_drv->assoc_bssid); 741 742 conn_info->req_ies_len = 0; 743 kfree(conn_info->req_ies); 744 conn_info->req_ies = NULL; 745 746 return 0; 747 } 748 749 int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) 750 { 751 struct wid wid_list[5]; 752 u32 wid_cnt = 0, result; 753 754 wid_list[wid_cnt].id = WID_LINKSPEED; 755 wid_list[wid_cnt].type = WID_CHAR; 756 wid_list[wid_cnt].size = sizeof(char); 757 wid_list[wid_cnt].val = (s8 *)&stats->link_speed; 758 wid_cnt++; 759 760 wid_list[wid_cnt].id = WID_RSSI; 761 wid_list[wid_cnt].type = WID_CHAR; 762 wid_list[wid_cnt].size = sizeof(char); 763 wid_list[wid_cnt].val = (s8 *)&stats->rssi; 764 wid_cnt++; 765 766 wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT; 767 wid_list[wid_cnt].type = WID_INT; 768 wid_list[wid_cnt].size = sizeof(u32); 769 wid_list[wid_cnt].val = (s8 *)&stats->tx_cnt; 770 wid_cnt++; 771 772 wid_list[wid_cnt].id = WID_RECEIVED_FRAGMENT_COUNT; 773 wid_list[wid_cnt].type = WID_INT; 774 wid_list[wid_cnt].size = sizeof(u32); 775 wid_list[wid_cnt].val = (s8 *)&stats->rx_cnt; 776 wid_cnt++; 777 778 wid_list[wid_cnt].id = WID_FAILED_COUNT; 779 wid_list[wid_cnt].type = WID_INT; 780 wid_list[wid_cnt].size = sizeof(u32); 781 wid_list[wid_cnt].val = (s8 *)&stats->tx_fail_cnt; 782 wid_cnt++; 783 784 result = wilc_send_config_pkt(vif, WILC_GET_CFG, wid_list, wid_cnt); 785 if (result) { 786 netdev_err(vif->ndev, "Failed to send scan parameters\n"); 787 return result; 788 } 789 790 if (stats->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH && 791 stats->link_speed != DEFAULT_LINK_SPEED) 792 wilc_enable_tcp_ack_filter(vif, true); 793 else if (stats->link_speed != DEFAULT_LINK_SPEED) 794 wilc_enable_tcp_ack_filter(vif, false); 795 796 return result; 797 } 798 799 static void handle_get_statistics(struct work_struct *work) 800 { 801 struct host_if_msg *msg = container_of(work, struct host_if_msg, work); 802 struct wilc_vif *vif = msg->vif; 803 struct rf_info *stats = (struct rf_info *)msg->body.data; 804 805 wilc_get_statistics(vif, stats); 806 807 kfree(msg); 808 } 809 810 static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, 811 struct station_parameters *params) 812 { 813 ether_addr_copy(cur_byte, mac); 814 cur_byte += ETH_ALEN; 815 816 put_unaligned_le16(params->aid, cur_byte); 817 cur_byte += 2; 818 819 *cur_byte++ = params->supported_rates_len; 820 if (params->supported_rates_len > 0) 821 memcpy(cur_byte, params->supported_rates, 822 params->supported_rates_len); 823 cur_byte += params->supported_rates_len; 824 825 if (params->ht_capa) { 826 *cur_byte++ = true; 827 memcpy(cur_byte, params->ht_capa, 828 sizeof(struct ieee80211_ht_cap)); 829 } else { 830 *cur_byte++ = false; 831 } 832 cur_byte += sizeof(struct ieee80211_ht_cap); 833 834 put_unaligned_le16(params->sta_flags_mask, cur_byte); 835 cur_byte += 2; 836 put_unaligned_le16(params->sta_flags_set, cur_byte); 837 } 838 839 static int handle_remain_on_chan(struct wilc_vif *vif, 840 struct wilc_remain_ch *hif_remain_ch) 841 { 842 int result; 843 u8 remain_on_chan_flag; 844 struct wid wid; 845 struct host_if_drv *hif_drv = vif->hif_drv; 846 847 if (hif_drv->usr_scan_req.scan_result) 848 return -EBUSY; 849 850 if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) 851 return -EBUSY; 852 853 if (vif->connecting) 854 return -EBUSY; 855 856 remain_on_chan_flag = true; 857 wid.id = WID_REMAIN_ON_CHAN; 858 wid.type = WID_STR; 859 wid.size = 2; 860 wid.val = kmalloc(wid.size, GFP_KERNEL); 861 if (!wid.val) 862 return -ENOMEM; 863 864 wid.val[0] = remain_on_chan_flag; 865 wid.val[1] = (s8)hif_remain_ch->ch; 866 867 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 868 kfree(wid.val); 869 if (result) 870 return -EBUSY; 871 872 hif_drv->remain_on_ch.arg = hif_remain_ch->arg; 873 hif_drv->remain_on_ch.expired = hif_remain_ch->expired; 874 hif_drv->remain_on_ch.ch = hif_remain_ch->ch; 875 hif_drv->remain_on_ch.cookie = hif_remain_ch->cookie; 876 hif_drv->remain_on_ch_timer_vif = vif; 877 878 return 0; 879 } 880 881 static int wilc_handle_roc_expired(struct wilc_vif *vif, u64 cookie) 882 { 883 u8 remain_on_chan_flag; 884 struct wid wid; 885 int result; 886 struct host_if_drv *hif_drv = vif->hif_drv; 887 888 if (vif->priv.p2p_listen_state) { 889 remain_on_chan_flag = false; 890 wid.id = WID_REMAIN_ON_CHAN; 891 wid.type = WID_STR; 892 wid.size = 2; 893 894 wid.val = kmalloc(wid.size, GFP_KERNEL); 895 if (!wid.val) 896 return -ENOMEM; 897 898 wid.val[0] = remain_on_chan_flag; 899 wid.val[1] = WILC_FALSE_FRMWR_CHANNEL; 900 901 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 902 kfree(wid.val); 903 if (result != 0) { 904 netdev_err(vif->ndev, "Failed to set remain channel\n"); 905 return -EINVAL; 906 } 907 908 if (hif_drv->remain_on_ch.expired) { 909 hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg, 910 cookie); 911 } 912 } else { 913 netdev_dbg(vif->ndev, "Not in listen state\n"); 914 } 915 916 return 0; 917 } 918 919 static void wilc_handle_listen_state_expired(struct work_struct *work) 920 { 921 struct host_if_msg *msg = container_of(work, struct host_if_msg, work); 922 923 wilc_handle_roc_expired(msg->vif, msg->body.remain_on_ch.cookie); 924 kfree(msg); 925 } 926 927 static void listen_timer_cb(struct timer_list *t) 928 { 929 struct host_if_drv *hif_drv = from_timer(hif_drv, t, 930 remain_on_ch_timer); 931 struct wilc_vif *vif = hif_drv->remain_on_ch_timer_vif; 932 int result; 933 struct host_if_msg *msg; 934 935 del_timer(&vif->hif_drv->remain_on_ch_timer); 936 937 msg = wilc_alloc_work(vif, wilc_handle_listen_state_expired, false); 938 if (IS_ERR(msg)) 939 return; 940 941 msg->body.remain_on_ch.cookie = vif->hif_drv->remain_on_ch.cookie; 942 943 result = wilc_enqueue_work(msg); 944 if (result) { 945 netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); 946 kfree(msg); 947 } 948 } 949 950 static void handle_set_mcast_filter(struct work_struct *work) 951 { 952 struct host_if_msg *msg = container_of(work, struct host_if_msg, work); 953 struct wilc_vif *vif = msg->vif; 954 struct wilc_set_multicast *set_mc = &msg->body.mc_info; 955 int result; 956 struct wid wid; 957 u8 *cur_byte; 958 959 wid.id = WID_SETUP_MULTICAST_FILTER; 960 wid.type = WID_BIN; 961 wid.size = sizeof(struct wilc_set_multicast) + (set_mc->cnt * ETH_ALEN); 962 wid.val = kmalloc(wid.size, GFP_KERNEL); 963 if (!wid.val) 964 goto error; 965 966 cur_byte = wid.val; 967 put_unaligned_le32(set_mc->enabled, cur_byte); 968 cur_byte += 4; 969 970 put_unaligned_le32(set_mc->cnt, cur_byte); 971 cur_byte += 4; 972 973 if (set_mc->cnt > 0 && set_mc->mc_list) 974 memcpy(cur_byte, set_mc->mc_list, set_mc->cnt * ETH_ALEN); 975 976 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 977 if (result) 978 netdev_err(vif->ndev, "Failed to send setup multicast\n"); 979 980 error: 981 kfree(set_mc->mc_list); 982 kfree(wid.val); 983 kfree(msg); 984 } 985 986 void wilc_set_wowlan_trigger(struct wilc_vif *vif, bool enabled) 987 { 988 int ret; 989 struct wid wid; 990 u8 wowlan_trigger = 0; 991 992 if (enabled) 993 wowlan_trigger = 1; 994 995 wid.id = WID_WOWLAN_TRIGGER; 996 wid.type = WID_CHAR; 997 wid.val = &wowlan_trigger; 998 wid.size = sizeof(char); 999 1000 ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1001 if (ret) 1002 pr_err("Failed to send wowlan trigger config packet\n"); 1003 } 1004 1005 int wilc_set_external_auth_param(struct wilc_vif *vif, 1006 struct cfg80211_external_auth_params *auth) 1007 { 1008 int ret; 1009 struct wid wid; 1010 struct wilc_external_auth_param *param; 1011 1012 wid.id = WID_EXTERNAL_AUTH_PARAM; 1013 wid.type = WID_BIN_DATA; 1014 wid.size = sizeof(*param); 1015 param = kzalloc(sizeof(*param), GFP_KERNEL); 1016 if (!param) 1017 return -EINVAL; 1018 1019 wid.val = (u8 *)param; 1020 param->action = auth->action; 1021 ether_addr_copy(param->bssid, auth->bssid); 1022 memcpy(param->ssid, auth->ssid.ssid, auth->ssid.ssid_len); 1023 param->ssid_len = auth->ssid.ssid_len; 1024 ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1025 1026 kfree(param); 1027 return ret; 1028 } 1029 1030 static void handle_scan_timer(struct work_struct *work) 1031 { 1032 struct host_if_msg *msg = container_of(work, struct host_if_msg, work); 1033 1034 handle_scan_done(msg->vif, SCAN_EVENT_ABORTED); 1035 kfree(msg); 1036 } 1037 1038 static void handle_scan_complete(struct work_struct *work) 1039 { 1040 struct host_if_msg *msg = container_of(work, struct host_if_msg, work); 1041 1042 del_timer(&msg->vif->hif_drv->scan_timer); 1043 1044 handle_scan_done(msg->vif, SCAN_EVENT_DONE); 1045 1046 kfree(msg); 1047 } 1048 1049 static void timer_scan_cb(struct timer_list *t) 1050 { 1051 struct host_if_drv *hif_drv = from_timer(hif_drv, t, scan_timer); 1052 struct wilc_vif *vif = hif_drv->scan_timer_vif; 1053 struct host_if_msg *msg; 1054 int result; 1055 1056 msg = wilc_alloc_work(vif, handle_scan_timer, false); 1057 if (IS_ERR(msg)) 1058 return; 1059 1060 result = wilc_enqueue_work(msg); 1061 if (result) 1062 kfree(msg); 1063 } 1064 1065 static void timer_connect_cb(struct timer_list *t) 1066 { 1067 struct host_if_drv *hif_drv = from_timer(hif_drv, t, 1068 connect_timer); 1069 struct wilc_vif *vif = hif_drv->connect_timer_vif; 1070 struct host_if_msg *msg; 1071 int result; 1072 1073 msg = wilc_alloc_work(vif, handle_connect_timeout, false); 1074 if (IS_ERR(msg)) 1075 return; 1076 1077 result = wilc_enqueue_work(msg); 1078 if (result) 1079 kfree(msg); 1080 } 1081 1082 int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, 1083 const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, 1084 u8 mode, u8 cipher_mode, u8 index) 1085 { 1086 int result = 0; 1087 u8 t_key_len = ptk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN; 1088 1089 if (mode == WILC_AP_MODE) { 1090 struct wid wid_list[2]; 1091 struct wilc_ap_wpa_ptk *key_buf; 1092 1093 wid_list[0].id = WID_11I_MODE; 1094 wid_list[0].type = WID_CHAR; 1095 wid_list[0].size = sizeof(char); 1096 wid_list[0].val = (s8 *)&cipher_mode; 1097 1098 key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); 1099 if (!key_buf) 1100 return -ENOMEM; 1101 1102 ether_addr_copy(key_buf->mac_addr, mac_addr); 1103 key_buf->index = index; 1104 key_buf->key_len = t_key_len; 1105 memcpy(&key_buf->key[0], ptk, ptk_key_len); 1106 1107 if (rx_mic) 1108 memcpy(&key_buf->key[ptk_key_len], rx_mic, 1109 WILC_RX_MIC_KEY_LEN); 1110 1111 if (tx_mic) 1112 memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN], 1113 tx_mic, WILC_TX_MIC_KEY_LEN); 1114 1115 wid_list[1].id = WID_ADD_PTK; 1116 wid_list[1].type = WID_STR; 1117 wid_list[1].size = sizeof(*key_buf) + t_key_len; 1118 wid_list[1].val = (u8 *)key_buf; 1119 result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, 1120 ARRAY_SIZE(wid_list)); 1121 kfree(key_buf); 1122 } else if (mode == WILC_STATION_MODE) { 1123 struct wid wid; 1124 struct wilc_sta_wpa_ptk *key_buf; 1125 1126 key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); 1127 if (!key_buf) 1128 return -ENOMEM; 1129 1130 ether_addr_copy(key_buf->mac_addr, mac_addr); 1131 key_buf->key_len = t_key_len; 1132 memcpy(&key_buf->key[0], ptk, ptk_key_len); 1133 1134 if (rx_mic) 1135 memcpy(&key_buf->key[ptk_key_len], rx_mic, 1136 WILC_RX_MIC_KEY_LEN); 1137 1138 if (tx_mic) 1139 memcpy(&key_buf->key[ptk_key_len + WILC_RX_MIC_KEY_LEN], 1140 tx_mic, WILC_TX_MIC_KEY_LEN); 1141 1142 wid.id = WID_ADD_PTK; 1143 wid.type = WID_STR; 1144 wid.size = sizeof(*key_buf) + t_key_len; 1145 wid.val = (s8 *)key_buf; 1146 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1147 kfree(key_buf); 1148 } 1149 1150 return result; 1151 } 1152 1153 int wilc_add_igtk(struct wilc_vif *vif, const u8 *igtk, u8 igtk_key_len, 1154 const u8 *pn, u8 pn_len, const u8 *mac_addr, u8 mode, u8 index) 1155 { 1156 int result = 0; 1157 u8 t_key_len = igtk_key_len; 1158 struct wid wid; 1159 struct wilc_wpa_igtk *key_buf; 1160 1161 key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); 1162 if (!key_buf) 1163 return -ENOMEM; 1164 1165 key_buf->index = index; 1166 1167 memcpy(&key_buf->pn[0], pn, pn_len); 1168 key_buf->pn_len = pn_len; 1169 1170 memcpy(&key_buf->key[0], igtk, igtk_key_len); 1171 key_buf->key_len = t_key_len; 1172 1173 wid.id = WID_ADD_IGTK; 1174 wid.type = WID_STR; 1175 wid.size = sizeof(*key_buf) + t_key_len; 1176 wid.val = (s8 *)key_buf; 1177 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1178 kfree(key_buf); 1179 1180 return result; 1181 } 1182 1183 int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, 1184 u8 index, u32 key_rsc_len, const u8 *key_rsc, 1185 const u8 *rx_mic, const u8 *tx_mic, u8 mode, 1186 u8 cipher_mode) 1187 { 1188 int result = 0; 1189 struct wilc_gtk_key *gtk_key; 1190 int t_key_len = gtk_key_len + WILC_RX_MIC_KEY_LEN + WILC_TX_MIC_KEY_LEN; 1191 1192 gtk_key = kzalloc(sizeof(*gtk_key) + t_key_len, GFP_KERNEL); 1193 if (!gtk_key) 1194 return -ENOMEM; 1195 1196 /* fill bssid value only in station mode */ 1197 if (mode == WILC_STATION_MODE && 1198 vif->hif_drv->hif_state == HOST_IF_CONNECTED) 1199 memcpy(gtk_key->mac_addr, vif->hif_drv->assoc_bssid, ETH_ALEN); 1200 1201 if (key_rsc) 1202 memcpy(gtk_key->rsc, key_rsc, 8); 1203 gtk_key->index = index; 1204 gtk_key->key_len = t_key_len; 1205 memcpy(>k_key->key[0], rx_gtk, gtk_key_len); 1206 1207 if (rx_mic) 1208 memcpy(>k_key->key[gtk_key_len], rx_mic, WILC_RX_MIC_KEY_LEN); 1209 1210 if (tx_mic) 1211 memcpy(>k_key->key[gtk_key_len + WILC_RX_MIC_KEY_LEN], 1212 tx_mic, WILC_TX_MIC_KEY_LEN); 1213 1214 if (mode == WILC_AP_MODE) { 1215 struct wid wid_list[2]; 1216 1217 wid_list[0].id = WID_11I_MODE; 1218 wid_list[0].type = WID_CHAR; 1219 wid_list[0].size = sizeof(char); 1220 wid_list[0].val = (s8 *)&cipher_mode; 1221 1222 wid_list[1].id = WID_ADD_RX_GTK; 1223 wid_list[1].type = WID_STR; 1224 wid_list[1].size = sizeof(*gtk_key) + t_key_len; 1225 wid_list[1].val = (u8 *)gtk_key; 1226 1227 result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, 1228 ARRAY_SIZE(wid_list)); 1229 } else if (mode == WILC_STATION_MODE) { 1230 struct wid wid; 1231 1232 wid.id = WID_ADD_RX_GTK; 1233 wid.type = WID_STR; 1234 wid.size = sizeof(*gtk_key) + t_key_len; 1235 wid.val = (u8 *)gtk_key; 1236 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1237 } 1238 1239 kfree(gtk_key); 1240 return result; 1241 } 1242 1243 int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid) 1244 { 1245 struct wid wid; 1246 1247 wid.id = WID_PMKID_INFO; 1248 wid.type = WID_STR; 1249 wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1; 1250 wid.val = (u8 *)pmkid; 1251 1252 return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1253 } 1254 1255 int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) 1256 { 1257 int result; 1258 struct wid wid; 1259 1260 wid.id = WID_MAC_ADDR; 1261 wid.type = WID_STR; 1262 wid.size = ETH_ALEN; 1263 wid.val = mac_addr; 1264 1265 result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); 1266 if (result) 1267 netdev_err(vif->ndev, "Failed to get mac address\n"); 1268 1269 return result; 1270 } 1271 1272 int wilc_set_mac_address(struct wilc_vif *vif, u8 *mac_addr) 1273 { 1274 struct wid wid; 1275 int result; 1276 1277 wid.id = WID_MAC_ADDR; 1278 wid.type = WID_STR; 1279 wid.size = ETH_ALEN; 1280 wid.val = mac_addr; 1281 1282 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1283 if (result) 1284 netdev_err(vif->ndev, "Failed to set mac address\n"); 1285 1286 return result; 1287 } 1288 1289 int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ies, 1290 size_t ies_len) 1291 { 1292 int result; 1293 struct host_if_drv *hif_drv = vif->hif_drv; 1294 struct wilc_conn_info *conn_info = &hif_drv->conn_info; 1295 1296 if (bssid) 1297 ether_addr_copy(conn_info->bssid, bssid); 1298 1299 if (ies) { 1300 conn_info->req_ies_len = ies_len; 1301 conn_info->req_ies = kmemdup(ies, ies_len, GFP_KERNEL); 1302 if (!conn_info->req_ies) 1303 return -ENOMEM; 1304 } 1305 1306 result = wilc_send_connect_wid(vif); 1307 if (result) 1308 goto free_ies; 1309 1310 hif_drv->connect_timer_vif = vif; 1311 mod_timer(&hif_drv->connect_timer, 1312 jiffies + msecs_to_jiffies(WILC_HIF_CONNECT_TIMEOUT_MS)); 1313 1314 return 0; 1315 1316 free_ies: 1317 kfree(conn_info->req_ies); 1318 1319 return result; 1320 } 1321 1322 int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) 1323 { 1324 struct wid wid; 1325 int result; 1326 1327 wid.id = WID_CURRENT_CHANNEL; 1328 wid.type = WID_CHAR; 1329 wid.size = sizeof(char); 1330 wid.val = &channel; 1331 1332 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1333 if (result) 1334 netdev_err(vif->ndev, "Failed to set channel\n"); 1335 1336 return result; 1337 } 1338 1339 int wilc_set_operation_mode(struct wilc_vif *vif, int index, u8 mode, 1340 u8 ifc_id) 1341 { 1342 struct wid wid; 1343 int result; 1344 struct wilc_drv_handler drv; 1345 1346 wid.id = WID_SET_OPERATION_MODE; 1347 wid.type = WID_STR; 1348 wid.size = sizeof(drv); 1349 wid.val = (u8 *)&drv; 1350 1351 drv.handler = cpu_to_le32(index); 1352 drv.mode = (ifc_id | (mode << 1)); 1353 1354 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1355 if (result) 1356 netdev_err(vif->ndev, "Failed to set driver handler\n"); 1357 1358 return result; 1359 } 1360 1361 s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val) 1362 { 1363 struct wid wid; 1364 s32 result; 1365 1366 wid.id = WID_SET_STA_MAC_INACTIVE_TIME; 1367 wid.type = WID_STR; 1368 wid.size = ETH_ALEN; 1369 wid.val = kzalloc(wid.size, GFP_KERNEL); 1370 if (!wid.val) 1371 return -ENOMEM; 1372 1373 ether_addr_copy(wid.val, mac); 1374 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1375 kfree(wid.val); 1376 if (result) { 1377 netdev_err(vif->ndev, "Failed to set inactive mac\n"); 1378 return result; 1379 } 1380 1381 wid.id = WID_GET_INACTIVE_TIME; 1382 wid.type = WID_INT; 1383 wid.val = (s8 *)out_val; 1384 wid.size = sizeof(u32); 1385 result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); 1386 if (result) 1387 netdev_err(vif->ndev, "Failed to get inactive time\n"); 1388 1389 return result; 1390 } 1391 1392 int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) 1393 { 1394 struct wid wid; 1395 int result; 1396 1397 if (!rssi_level) { 1398 netdev_err(vif->ndev, "%s: RSSI level is NULL\n", __func__); 1399 return -EFAULT; 1400 } 1401 1402 wid.id = WID_RSSI; 1403 wid.type = WID_CHAR; 1404 wid.size = sizeof(char); 1405 wid.val = rssi_level; 1406 result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); 1407 if (result) 1408 netdev_err(vif->ndev, "Failed to get RSSI value\n"); 1409 1410 return result; 1411 } 1412 1413 static int wilc_get_stats_async(struct wilc_vif *vif, struct rf_info *stats) 1414 { 1415 int result; 1416 struct host_if_msg *msg; 1417 1418 msg = wilc_alloc_work(vif, handle_get_statistics, false); 1419 if (IS_ERR(msg)) 1420 return PTR_ERR(msg); 1421 1422 msg->body.data = (char *)stats; 1423 1424 result = wilc_enqueue_work(msg); 1425 if (result) { 1426 netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); 1427 kfree(msg); 1428 return result; 1429 } 1430 1431 return result; 1432 } 1433 1434 int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param) 1435 { 1436 struct wid wid_list[4]; 1437 int i = 0; 1438 1439 if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) { 1440 wid_list[i].id = WID_SHORT_RETRY_LIMIT; 1441 wid_list[i].val = (s8 *)¶m->short_retry_limit; 1442 wid_list[i].type = WID_SHORT; 1443 wid_list[i].size = sizeof(u16); 1444 i++; 1445 } 1446 if (param->flag & WILC_CFG_PARAM_RETRY_LONG) { 1447 wid_list[i].id = WID_LONG_RETRY_LIMIT; 1448 wid_list[i].val = (s8 *)¶m->long_retry_limit; 1449 wid_list[i].type = WID_SHORT; 1450 wid_list[i].size = sizeof(u16); 1451 i++; 1452 } 1453 if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) { 1454 wid_list[i].id = WID_FRAG_THRESHOLD; 1455 wid_list[i].val = (s8 *)¶m->frag_threshold; 1456 wid_list[i].type = WID_SHORT; 1457 wid_list[i].size = sizeof(u16); 1458 i++; 1459 } 1460 if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) { 1461 wid_list[i].id = WID_RTS_THRESHOLD; 1462 wid_list[i].val = (s8 *)¶m->rts_threshold; 1463 wid_list[i].type = WID_SHORT; 1464 wid_list[i].size = sizeof(u16); 1465 i++; 1466 } 1467 1468 return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, i); 1469 } 1470 1471 static void get_periodic_rssi(struct timer_list *t) 1472 { 1473 struct wilc_vif *vif = from_timer(vif, t, periodic_rssi); 1474 1475 if (!vif->hif_drv) { 1476 netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); 1477 return; 1478 } 1479 1480 if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) 1481 wilc_get_stats_async(vif, &vif->periodic_stat); 1482 1483 mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000)); 1484 } 1485 1486 int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) 1487 { 1488 struct host_if_drv *hif_drv; 1489 struct wilc_vif *vif = netdev_priv(dev); 1490 1491 hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL); 1492 if (!hif_drv) 1493 return -ENOMEM; 1494 1495 *hif_drv_handler = hif_drv; 1496 1497 vif->hif_drv = hif_drv; 1498 1499 timer_setup(&vif->periodic_rssi, get_periodic_rssi, 0); 1500 mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000)); 1501 1502 timer_setup(&hif_drv->scan_timer, timer_scan_cb, 0); 1503 timer_setup(&hif_drv->connect_timer, timer_connect_cb, 0); 1504 timer_setup(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0); 1505 1506 hif_drv->hif_state = HOST_IF_IDLE; 1507 1508 hif_drv->p2p_timeout = 0; 1509 1510 return 0; 1511 } 1512 1513 int wilc_deinit(struct wilc_vif *vif) 1514 { 1515 int result = 0; 1516 struct host_if_drv *hif_drv = vif->hif_drv; 1517 1518 if (!hif_drv) { 1519 netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); 1520 return -EFAULT; 1521 } 1522 1523 mutex_lock(&vif->wilc->deinit_lock); 1524 1525 del_timer_sync(&hif_drv->scan_timer); 1526 del_timer_sync(&hif_drv->connect_timer); 1527 del_timer_sync(&vif->periodic_rssi); 1528 del_timer_sync(&hif_drv->remain_on_ch_timer); 1529 1530 if (hif_drv->usr_scan_req.scan_result) { 1531 hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL, 1532 hif_drv->usr_scan_req.arg); 1533 hif_drv->usr_scan_req.scan_result = NULL; 1534 } 1535 1536 hif_drv->hif_state = HOST_IF_IDLE; 1537 1538 kfree(hif_drv); 1539 vif->hif_drv = NULL; 1540 mutex_unlock(&vif->wilc->deinit_lock); 1541 return result; 1542 } 1543 1544 void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) 1545 { 1546 int result; 1547 struct host_if_msg *msg; 1548 int id; 1549 struct host_if_drv *hif_drv; 1550 struct wilc_vif *vif; 1551 1552 id = get_unaligned_le32(&buffer[length - 4]); 1553 vif = wilc_get_vif_from_idx(wilc, id); 1554 if (!vif) 1555 return; 1556 hif_drv = vif->hif_drv; 1557 1558 if (!hif_drv) { 1559 netdev_err(vif->ndev, "driver not init[%p]\n", hif_drv); 1560 return; 1561 } 1562 1563 msg = wilc_alloc_work(vif, handle_rcvd_ntwrk_info, false); 1564 if (IS_ERR(msg)) 1565 return; 1566 1567 msg->body.net_info.frame_len = get_unaligned_le16(&buffer[6]) - 1; 1568 msg->body.net_info.rssi = buffer[8]; 1569 msg->body.net_info.mgmt = kmemdup(&buffer[9], 1570 msg->body.net_info.frame_len, 1571 GFP_KERNEL); 1572 if (!msg->body.net_info.mgmt) { 1573 kfree(msg); 1574 return; 1575 } 1576 1577 result = wilc_enqueue_work(msg); 1578 if (result) { 1579 netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); 1580 kfree(msg->body.net_info.mgmt); 1581 kfree(msg); 1582 } 1583 } 1584 1585 void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) 1586 { 1587 int result; 1588 struct host_if_msg *msg; 1589 int id; 1590 struct host_if_drv *hif_drv; 1591 struct wilc_vif *vif; 1592 1593 mutex_lock(&wilc->deinit_lock); 1594 1595 id = get_unaligned_le32(&buffer[length - 4]); 1596 vif = wilc_get_vif_from_idx(wilc, id); 1597 if (!vif) { 1598 mutex_unlock(&wilc->deinit_lock); 1599 return; 1600 } 1601 1602 hif_drv = vif->hif_drv; 1603 1604 if (!hif_drv) { 1605 mutex_unlock(&wilc->deinit_lock); 1606 return; 1607 } 1608 1609 if (!hif_drv->conn_info.conn_result) { 1610 netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__); 1611 mutex_unlock(&wilc->deinit_lock); 1612 return; 1613 } 1614 1615 msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info, false); 1616 if (IS_ERR(msg)) { 1617 mutex_unlock(&wilc->deinit_lock); 1618 return; 1619 } 1620 1621 msg->body.mac_info.status = buffer[7]; 1622 result = wilc_enqueue_work(msg); 1623 if (result) { 1624 netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); 1625 kfree(msg); 1626 } 1627 1628 mutex_unlock(&wilc->deinit_lock); 1629 } 1630 1631 void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length) 1632 { 1633 int result; 1634 int id; 1635 struct host_if_drv *hif_drv; 1636 struct wilc_vif *vif; 1637 1638 id = get_unaligned_le32(&buffer[length - 4]); 1639 vif = wilc_get_vif_from_idx(wilc, id); 1640 if (!vif) 1641 return; 1642 hif_drv = vif->hif_drv; 1643 1644 if (!hif_drv) 1645 return; 1646 1647 if (hif_drv->usr_scan_req.scan_result) { 1648 struct host_if_msg *msg; 1649 1650 msg = wilc_alloc_work(vif, handle_scan_complete, false); 1651 if (IS_ERR(msg)) 1652 return; 1653 1654 result = wilc_enqueue_work(msg); 1655 if (result) { 1656 netdev_err(vif->ndev, "%s: enqueue work failed\n", 1657 __func__); 1658 kfree(msg); 1659 } 1660 } 1661 } 1662 1663 int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, 1664 u32 duration, u16 chan, 1665 void (*expired)(void *, u64), 1666 void *user_arg) 1667 { 1668 struct wilc_remain_ch roc; 1669 int result; 1670 1671 roc.ch = chan; 1672 roc.expired = expired; 1673 roc.arg = user_arg; 1674 roc.duration = duration; 1675 roc.cookie = cookie; 1676 result = handle_remain_on_chan(vif, &roc); 1677 if (result) 1678 netdev_err(vif->ndev, "%s: failed to set remain on channel\n", 1679 __func__); 1680 1681 return result; 1682 } 1683 1684 int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie) 1685 { 1686 if (!vif->hif_drv) { 1687 netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); 1688 return -EFAULT; 1689 } 1690 1691 del_timer(&vif->hif_drv->remain_on_ch_timer); 1692 1693 return wilc_handle_roc_expired(vif, cookie); 1694 } 1695 1696 void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) 1697 { 1698 struct wid wid; 1699 int result; 1700 struct wilc_reg_frame reg_frame; 1701 1702 wid.id = WID_REGISTER_FRAME; 1703 wid.type = WID_STR; 1704 wid.size = sizeof(reg_frame); 1705 wid.val = (u8 *)®_frame; 1706 1707 memset(®_frame, 0x0, sizeof(reg_frame)); 1708 1709 if (reg) 1710 reg_frame.reg = 1; 1711 1712 switch (frame_type) { 1713 case IEEE80211_STYPE_ACTION: 1714 reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX; 1715 break; 1716 1717 case IEEE80211_STYPE_PROBE_REQ: 1718 reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX; 1719 break; 1720 1721 case IEEE80211_STYPE_AUTH: 1722 reg_frame.reg_id = WILC_FW_AUTH_REQ_IDX; 1723 break; 1724 1725 default: 1726 break; 1727 } 1728 reg_frame.frame_type = cpu_to_le16(frame_type); 1729 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1730 if (result) 1731 netdev_err(vif->ndev, "Failed to frame register\n"); 1732 } 1733 1734 int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, 1735 struct cfg80211_beacon_data *params) 1736 { 1737 struct wid wid; 1738 int result; 1739 u8 *cur_byte; 1740 1741 wid.id = WID_ADD_BEACON; 1742 wid.type = WID_BIN; 1743 wid.size = params->head_len + params->tail_len + 16; 1744 wid.val = kzalloc(wid.size, GFP_KERNEL); 1745 if (!wid.val) 1746 return -ENOMEM; 1747 1748 cur_byte = wid.val; 1749 put_unaligned_le32(interval, cur_byte); 1750 cur_byte += 4; 1751 put_unaligned_le32(dtim_period, cur_byte); 1752 cur_byte += 4; 1753 put_unaligned_le32(params->head_len, cur_byte); 1754 cur_byte += 4; 1755 1756 if (params->head_len > 0) 1757 memcpy(cur_byte, params->head, params->head_len); 1758 cur_byte += params->head_len; 1759 1760 put_unaligned_le32(params->tail_len, cur_byte); 1761 cur_byte += 4; 1762 1763 if (params->tail_len > 0) 1764 memcpy(cur_byte, params->tail, params->tail_len); 1765 1766 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1767 if (result) 1768 netdev_err(vif->ndev, "Failed to send add beacon\n"); 1769 1770 kfree(wid.val); 1771 1772 return result; 1773 } 1774 1775 int wilc_del_beacon(struct wilc_vif *vif) 1776 { 1777 int result; 1778 struct wid wid; 1779 u8 del_beacon = 0; 1780 1781 wid.id = WID_DEL_BEACON; 1782 wid.type = WID_CHAR; 1783 wid.size = sizeof(char); 1784 wid.val = &del_beacon; 1785 1786 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1787 if (result) 1788 netdev_err(vif->ndev, "Failed to send delete beacon\n"); 1789 1790 return result; 1791 } 1792 1793 int wilc_add_station(struct wilc_vif *vif, const u8 *mac, 1794 struct station_parameters *params) 1795 { 1796 struct wid wid; 1797 int result; 1798 u8 *cur_byte; 1799 1800 wid.id = WID_ADD_STA; 1801 wid.type = WID_BIN; 1802 wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len; 1803 wid.val = kmalloc(wid.size, GFP_KERNEL); 1804 if (!wid.val) 1805 return -ENOMEM; 1806 1807 cur_byte = wid.val; 1808 wilc_hif_pack_sta_param(cur_byte, mac, params); 1809 1810 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1811 if (result != 0) 1812 netdev_err(vif->ndev, "Failed to send add station\n"); 1813 1814 kfree(wid.val); 1815 1816 return result; 1817 } 1818 1819 int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) 1820 { 1821 struct wid wid; 1822 int result; 1823 1824 wid.id = WID_REMOVE_STA; 1825 wid.type = WID_BIN; 1826 wid.size = ETH_ALEN; 1827 wid.val = kzalloc(wid.size, GFP_KERNEL); 1828 if (!wid.val) 1829 return -ENOMEM; 1830 1831 if (!mac_addr) 1832 eth_broadcast_addr(wid.val); 1833 else 1834 ether_addr_copy(wid.val, mac_addr); 1835 1836 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1837 if (result) 1838 netdev_err(vif->ndev, "Failed to del station\n"); 1839 1840 kfree(wid.val); 1841 1842 return result; 1843 } 1844 1845 int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) 1846 { 1847 struct wid wid; 1848 int result; 1849 int i; 1850 u8 assoc_sta = 0; 1851 struct wilc_del_all_sta del_sta; 1852 1853 memset(&del_sta, 0x0, sizeof(del_sta)); 1854 for (i = 0; i < WILC_MAX_NUM_STA; i++) { 1855 if (!is_zero_ether_addr(mac_addr[i])) { 1856 assoc_sta++; 1857 ether_addr_copy(del_sta.mac[i], mac_addr[i]); 1858 } 1859 } 1860 1861 if (!assoc_sta) 1862 return 0; 1863 1864 del_sta.assoc_sta = assoc_sta; 1865 1866 wid.id = WID_DEL_ALL_STA; 1867 wid.type = WID_STR; 1868 wid.size = (assoc_sta * ETH_ALEN) + 1; 1869 wid.val = (u8 *)&del_sta; 1870 1871 result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); 1872 if (result) 1873 netdev_err(vif->ndev, "Failed to send delete all station\n"); 1874 1875 return result; 1876 } 1877 1878 int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, 1879 struct station_parameters *params) 1880 { 1881 struct wid wid; 1882 int result; 1883 u8 *cur_byte; 1884 1885 wid.id = WID_EDIT_STA; 1886 wid.type = WID_BIN; 1887 wid.size = WILC_ADD_STA_LENGTH + 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