1 /* 2 * Copyright (c) 2004-2011 Atheros Communications Inc. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #include <linux/ip.h> 18 #include "core.h" 19 #include "debug.h" 20 #include "testmode.h" 21 #include "../regd.h" 22 #include "../regd_common.h" 23 24 static int ath6kl_wmi_sync_point(struct wmi *wmi); 25 26 static const s32 wmi_rate_tbl[][2] = { 27 /* {W/O SGI, with SGI} */ 28 {1000, 1000}, 29 {2000, 2000}, 30 {5500, 5500}, 31 {11000, 11000}, 32 {6000, 6000}, 33 {9000, 9000}, 34 {12000, 12000}, 35 {18000, 18000}, 36 {24000, 24000}, 37 {36000, 36000}, 38 {48000, 48000}, 39 {54000, 54000}, 40 {6500, 7200}, 41 {13000, 14400}, 42 {19500, 21700}, 43 {26000, 28900}, 44 {39000, 43300}, 45 {52000, 57800}, 46 {58500, 65000}, 47 {65000, 72200}, 48 {13500, 15000}, 49 {27000, 30000}, 50 {40500, 45000}, 51 {54000, 60000}, 52 {81000, 90000}, 53 {108000, 120000}, 54 {121500, 135000}, 55 {135000, 150000}, 56 {0, 0} 57 }; 58 59 /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */ 60 static const u8 up_to_ac[] = { 61 WMM_AC_BE, 62 WMM_AC_BK, 63 WMM_AC_BK, 64 WMM_AC_BE, 65 WMM_AC_VI, 66 WMM_AC_VI, 67 WMM_AC_VO, 68 WMM_AC_VO, 69 }; 70 71 void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id) 72 { 73 if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX)) 74 return; 75 76 wmi->ep_id = ep_id; 77 } 78 79 enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) 80 { 81 return wmi->ep_id; 82 } 83 84 /* Performs DIX to 802.3 encapsulation for transmit packets. 85 * Assumes the entire DIX header is contigous and that there is 86 * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. 87 */ 88 int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) 89 { 90 struct ath6kl_llc_snap_hdr *llc_hdr; 91 struct ethhdr *eth_hdr; 92 size_t new_len; 93 __be16 type; 94 u8 *datap; 95 u16 size; 96 97 if (WARN_ON(skb == NULL)) 98 return -EINVAL; 99 100 size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr); 101 if (skb_headroom(skb) < size) 102 return -ENOMEM; 103 104 eth_hdr = (struct ethhdr *) skb->data; 105 type = eth_hdr->h_proto; 106 107 if (!is_ethertype(be16_to_cpu(type))) { 108 ath6kl_dbg(ATH6KL_DBG_WMI, 109 "%s: pkt is already in 802.3 format\n", __func__); 110 return 0; 111 } 112 113 new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr); 114 115 skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr)); 116 datap = skb->data; 117 118 eth_hdr->h_proto = cpu_to_be16(new_len); 119 120 memcpy(datap, eth_hdr, sizeof(*eth_hdr)); 121 122 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr)); 123 llc_hdr->dsap = 0xAA; 124 llc_hdr->ssap = 0xAA; 125 llc_hdr->cntl = 0x03; 126 llc_hdr->org_code[0] = 0x0; 127 llc_hdr->org_code[1] = 0x0; 128 llc_hdr->org_code[2] = 0x0; 129 llc_hdr->eth_type = type; 130 131 return 0; 132 } 133 134 static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, 135 u8 *version, void *tx_meta_info) 136 { 137 struct wmi_tx_meta_v1 *v1; 138 struct wmi_tx_meta_v2 *v2; 139 140 if (WARN_ON(skb == NULL || version == NULL)) 141 return -EINVAL; 142 143 switch (*version) { 144 case WMI_META_VERSION_1: 145 skb_push(skb, WMI_MAX_TX_META_SZ); 146 v1 = (struct wmi_tx_meta_v1 *) skb->data; 147 v1->pkt_id = 0; 148 v1->rate_plcy_id = 0; 149 *version = WMI_META_VERSION_1; 150 break; 151 case WMI_META_VERSION_2: 152 skb_push(skb, WMI_MAX_TX_META_SZ); 153 v2 = (struct wmi_tx_meta_v2 *) skb->data; 154 memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info, 155 sizeof(struct wmi_tx_meta_v2)); 156 break; 157 } 158 159 return 0; 160 } 161 162 int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, 163 u8 msg_type, bool more_data, 164 enum wmi_data_hdr_data_type data_type, 165 u8 meta_ver, void *tx_meta_info) 166 { 167 struct wmi_data_hdr *data_hdr; 168 int ret; 169 170 if (WARN_ON(skb == NULL)) 171 return -EINVAL; 172 173 if (tx_meta_info) { 174 ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info); 175 if (ret) 176 return ret; 177 } 178 179 skb_push(skb, sizeof(struct wmi_data_hdr)); 180 181 data_hdr = (struct wmi_data_hdr *)skb->data; 182 memset(data_hdr, 0, sizeof(struct wmi_data_hdr)); 183 184 data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; 185 data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; 186 187 if (more_data) 188 data_hdr->info |= 189 WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT; 190 191 data_hdr->info2 = cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); 192 data_hdr->info3 = 0; 193 194 return 0; 195 } 196 197 static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) 198 { 199 struct iphdr *ip_hdr = (struct iphdr *) pkt; 200 u8 ip_pri; 201 202 /* 203 * Determine IPTOS priority 204 * 205 * IP-TOS - 8bits 206 * : DSCP(6-bits) ECN(2-bits) 207 * : DSCP - P2 P1 P0 X X X 208 * where (P2 P1 P0) form 802.1D 209 */ 210 ip_pri = ip_hdr->tos >> 5; 211 ip_pri &= 0x7; 212 213 if ((layer2_pri & 0x7) > ip_pri) 214 return (u8) layer2_pri & 0x7; 215 else 216 return ip_pri; 217 } 218 219 int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, 220 u32 layer2_priority, bool wmm_enabled, 221 u8 *ac) 222 { 223 struct wmi_data_hdr *data_hdr; 224 struct ath6kl_llc_snap_hdr *llc_hdr; 225 struct wmi_create_pstream_cmd cmd; 226 u32 meta_size, hdr_size; 227 u16 ip_type = IP_ETHERTYPE; 228 u8 stream_exist, usr_pri; 229 u8 traffic_class = WMM_AC_BE; 230 u8 *datap; 231 232 if (WARN_ON(skb == NULL)) 233 return -EINVAL; 234 235 datap = skb->data; 236 data_hdr = (struct wmi_data_hdr *) datap; 237 238 meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) & 239 WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0; 240 241 if (!wmm_enabled) { 242 /* If WMM is disabled all traffic goes as BE traffic */ 243 usr_pri = 0; 244 } else { 245 hdr_size = sizeof(struct ethhdr); 246 247 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + 248 sizeof(struct 249 wmi_data_hdr) + 250 meta_size + hdr_size); 251 252 if (llc_hdr->eth_type == htons(ip_type)) { 253 /* 254 * Extract the endpoint info from the TOS field 255 * in the IP header. 256 */ 257 usr_pri = 258 ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + 259 sizeof(struct ath6kl_llc_snap_hdr), 260 layer2_priority); 261 } else 262 usr_pri = layer2_priority & 0x7; 263 } 264 265 /* workaround for WMM S5 */ 266 if ((wmi->traffic_class == WMM_AC_VI) && 267 ((usr_pri == 5) || (usr_pri == 4))) 268 usr_pri = 1; 269 270 /* Convert user priority to traffic class */ 271 traffic_class = up_to_ac[usr_pri & 0x7]; 272 273 wmi_data_hdr_set_up(data_hdr, usr_pri); 274 275 spin_lock_bh(&wmi->lock); 276 stream_exist = wmi->fat_pipe_exist; 277 spin_unlock_bh(&wmi->lock); 278 279 if (!(stream_exist & (1 << traffic_class))) { 280 memset(&cmd, 0, sizeof(cmd)); 281 cmd.traffic_class = traffic_class; 282 cmd.user_pri = usr_pri; 283 cmd.inactivity_int = 284 cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); 285 /* Implicit streams are created with TSID 0xFF */ 286 cmd.tsid = WMI_IMPLICIT_PSTREAM; 287 ath6kl_wmi_create_pstream_cmd(wmi, &cmd); 288 } 289 290 *ac = traffic_class; 291 292 return 0; 293 } 294 295 int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) 296 { 297 struct ieee80211_hdr_3addr *pwh, wh; 298 struct ath6kl_llc_snap_hdr *llc_hdr; 299 struct ethhdr eth_hdr; 300 u32 hdr_size; 301 u8 *datap; 302 __le16 sub_type; 303 304 if (WARN_ON(skb == NULL)) 305 return -EINVAL; 306 307 datap = skb->data; 308 pwh = (struct ieee80211_hdr_3addr *) datap; 309 310 sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); 311 312 memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); 313 314 /* Strip off the 802.11 header */ 315 if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { 316 hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), 317 sizeof(u32)); 318 skb_pull(skb, hdr_size); 319 } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) 320 skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); 321 322 datap = skb->data; 323 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); 324 325 memset(ð_hdr, 0, sizeof(eth_hdr)); 326 eth_hdr.h_proto = llc_hdr->eth_type; 327 328 switch ((le16_to_cpu(wh.frame_control)) & 329 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 330 case 0: 331 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 332 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 333 break; 334 case IEEE80211_FCTL_TODS: 335 memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); 336 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 337 break; 338 case IEEE80211_FCTL_FROMDS: 339 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 340 memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); 341 break; 342 case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: 343 break; 344 } 345 346 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 347 skb_push(skb, sizeof(eth_hdr)); 348 349 datap = skb->data; 350 351 memcpy(datap, ð_hdr, sizeof(eth_hdr)); 352 353 return 0; 354 } 355 356 /* 357 * Performs 802.3 to DIX encapsulation for received packets. 358 * Assumes the entire 802.3 header is contigous. 359 */ 360 int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) 361 { 362 struct ath6kl_llc_snap_hdr *llc_hdr; 363 struct ethhdr eth_hdr; 364 u8 *datap; 365 366 if (WARN_ON(skb == NULL)) 367 return -EINVAL; 368 369 datap = skb->data; 370 371 memcpy(ð_hdr, datap, sizeof(eth_hdr)); 372 373 llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); 374 eth_hdr.h_proto = llc_hdr->eth_type; 375 376 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 377 datap = skb->data; 378 379 memcpy(datap, ð_hdr, sizeof(eth_hdr)); 380 381 return 0; 382 } 383 384 static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) 385 { 386 struct tx_complete_msg_v1 *msg_v1; 387 struct wmi_tx_complete_event *evt; 388 int index; 389 u16 size; 390 391 evt = (struct wmi_tx_complete_event *) datap; 392 393 ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", 394 evt->num_msg, evt->msg_len, evt->msg_type); 395 396 if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI)) 397 return 0; 398 399 for (index = 0; index < evt->num_msg; index++) { 400 size = sizeof(struct wmi_tx_complete_event) + 401 (index * sizeof(struct tx_complete_msg_v1)); 402 msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); 403 404 ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", 405 msg_v1->status, msg_v1->pkt_id, 406 msg_v1->rate_idx, msg_v1->ack_failures); 407 } 408 409 return 0; 410 } 411 412 static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, 413 int len) 414 { 415 struct wmi_remain_on_chnl_event *ev; 416 u32 freq; 417 u32 dur; 418 struct ieee80211_channel *chan; 419 struct ath6kl *ar = wmi->parent_dev; 420 421 if (len < sizeof(*ev)) 422 return -EINVAL; 423 424 ev = (struct wmi_remain_on_chnl_event *) datap; 425 freq = le32_to_cpu(ev->freq); 426 dur = le32_to_cpu(ev->duration); 427 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", 428 freq, dur); 429 chan = ieee80211_get_channel(ar->wdev->wiphy, freq); 430 if (!chan) { 431 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " 432 "(freq=%u)\n", freq); 433 return -EINVAL; 434 } 435 cfg80211_ready_on_channel(ar->net_dev, 1, chan, NL80211_CHAN_NO_HT, 436 dur, GFP_ATOMIC); 437 438 return 0; 439 } 440 441 static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, 442 u8 *datap, int len) 443 { 444 struct wmi_cancel_remain_on_chnl_event *ev; 445 u32 freq; 446 u32 dur; 447 struct ieee80211_channel *chan; 448 struct ath6kl *ar = wmi->parent_dev; 449 450 if (len < sizeof(*ev)) 451 return -EINVAL; 452 453 ev = (struct wmi_cancel_remain_on_chnl_event *) datap; 454 freq = le32_to_cpu(ev->freq); 455 dur = le32_to_cpu(ev->duration); 456 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " 457 "status=%u\n", freq, dur, ev->status); 458 chan = ieee80211_get_channel(ar->wdev->wiphy, freq); 459 if (!chan) { 460 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " 461 "channel (freq=%u)\n", freq); 462 return -EINVAL; 463 } 464 cfg80211_remain_on_channel_expired(ar->net_dev, 1, chan, 465 NL80211_CHAN_NO_HT, GFP_ATOMIC); 466 467 return 0; 468 } 469 470 static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len) 471 { 472 struct wmi_tx_status_event *ev; 473 u32 id; 474 struct ath6kl *ar = wmi->parent_dev; 475 476 if (len < sizeof(*ev)) 477 return -EINVAL; 478 479 ev = (struct wmi_tx_status_event *) datap; 480 id = le32_to_cpu(ev->id); 481 ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", 482 id, ev->ack_status); 483 if (wmi->last_mgmt_tx_frame) { 484 cfg80211_mgmt_tx_status(ar->net_dev, id, 485 wmi->last_mgmt_tx_frame, 486 wmi->last_mgmt_tx_frame_len, 487 !!ev->ack_status, GFP_ATOMIC); 488 kfree(wmi->last_mgmt_tx_frame); 489 wmi->last_mgmt_tx_frame = NULL; 490 wmi->last_mgmt_tx_frame_len = 0; 491 } 492 493 return 0; 494 } 495 496 static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) 497 { 498 struct wmi_p2p_rx_probe_req_event *ev; 499 u32 freq; 500 u16 dlen; 501 struct ath6kl *ar = wmi->parent_dev; 502 503 if (len < sizeof(*ev)) 504 return -EINVAL; 505 506 ev = (struct wmi_p2p_rx_probe_req_event *) datap; 507 freq = le32_to_cpu(ev->freq); 508 dlen = le16_to_cpu(ev->len); 509 if (datap + len < ev->data + dlen) { 510 ath6kl_err("invalid wmi_p2p_rx_probe_req_event: " 511 "len=%d dlen=%u\n", len, dlen); 512 return -EINVAL; 513 } 514 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u " 515 "probe_req_report=%d\n", 516 dlen, freq, ar->probe_req_report); 517 518 if (ar->probe_req_report || ar->nw_type == AP_NETWORK) 519 cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); 520 521 return 0; 522 } 523 524 static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) 525 { 526 struct wmi_p2p_capabilities_event *ev; 527 u16 dlen; 528 529 if (len < sizeof(*ev)) 530 return -EINVAL; 531 532 ev = (struct wmi_p2p_capabilities_event *) datap; 533 dlen = le16_to_cpu(ev->len); 534 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); 535 536 return 0; 537 } 538 539 static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len) 540 { 541 struct wmi_rx_action_event *ev; 542 u32 freq; 543 u16 dlen; 544 struct ath6kl *ar = wmi->parent_dev; 545 546 if (len < sizeof(*ev)) 547 return -EINVAL; 548 549 ev = (struct wmi_rx_action_event *) datap; 550 freq = le32_to_cpu(ev->freq); 551 dlen = le16_to_cpu(ev->len); 552 if (datap + len < ev->data + dlen) { 553 ath6kl_err("invalid wmi_rx_action_event: " 554 "len=%d dlen=%u\n", len, dlen); 555 return -EINVAL; 556 } 557 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); 558 cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); 559 560 return 0; 561 } 562 563 static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) 564 { 565 struct wmi_p2p_info_event *ev; 566 u32 flags; 567 u16 dlen; 568 569 if (len < sizeof(*ev)) 570 return -EINVAL; 571 572 ev = (struct wmi_p2p_info_event *) datap; 573 flags = le32_to_cpu(ev->info_req_flags); 574 dlen = le16_to_cpu(ev->len); 575 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); 576 577 if (flags & P2P_FLAG_CAPABILITIES_REQ) { 578 struct wmi_p2p_capabilities *cap; 579 if (dlen < sizeof(*cap)) 580 return -EINVAL; 581 cap = (struct wmi_p2p_capabilities *) ev->data; 582 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", 583 cap->go_power_save); 584 } 585 586 if (flags & P2P_FLAG_MACADDR_REQ) { 587 struct wmi_p2p_macaddr *mac; 588 if (dlen < sizeof(*mac)) 589 return -EINVAL; 590 mac = (struct wmi_p2p_macaddr *) ev->data; 591 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", 592 mac->mac_addr); 593 } 594 595 if (flags & P2P_FLAG_HMODEL_REQ) { 596 struct wmi_p2p_hmodel *mod; 597 if (dlen < sizeof(*mod)) 598 return -EINVAL; 599 mod = (struct wmi_p2p_hmodel *) ev->data; 600 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", 601 mod->p2p_model, 602 mod->p2p_model ? "host" : "firmware"); 603 } 604 return 0; 605 } 606 607 static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) 608 { 609 struct sk_buff *skb; 610 611 skb = ath6kl_buf_alloc(size); 612 if (!skb) 613 return NULL; 614 615 skb_put(skb, size); 616 if (size) 617 memset(skb->data, 0, size); 618 619 return skb; 620 } 621 622 /* Send a "simple" wmi command -- one with no arguments */ 623 static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id) 624 { 625 struct sk_buff *skb; 626 int ret; 627 628 skb = ath6kl_wmi_get_new_buf(0); 629 if (!skb) 630 return -ENOMEM; 631 632 ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG); 633 634 return ret; 635 } 636 637 static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) 638 { 639 struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; 640 641 if (len < sizeof(struct wmi_ready_event_2)) 642 return -EINVAL; 643 644 wmi->ready = true; 645 ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, 646 le32_to_cpu(ev->sw_version), 647 le32_to_cpu(ev->abi_version)); 648 649 return 0; 650 } 651 652 /* 653 * Mechanism to modify the roaming behavior in the firmware. The lower rssi 654 * at which the station has to roam can be passed with 655 * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level 656 * in dBm. 657 */ 658 int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) 659 { 660 struct sk_buff *skb; 661 struct roam_ctrl_cmd *cmd; 662 663 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 664 if (!skb) 665 return -ENOMEM; 666 667 cmd = (struct roam_ctrl_cmd *) skb->data; 668 669 cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD); 670 cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi + 671 DEF_SCAN_FOR_ROAM_INTVL); 672 cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi); 673 cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; 674 cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; 675 676 ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, NO_SYNC_WMIFLAG); 677 678 return 0; 679 } 680 681 static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) 682 { 683 struct wmi_connect_event *ev; 684 u8 *pie, *peie; 685 struct ath6kl *ar = wmi->parent_dev; 686 687 if (len < sizeof(struct wmi_connect_event)) 688 return -EINVAL; 689 690 ev = (struct wmi_connect_event *) datap; 691 692 if (ar->nw_type == AP_NETWORK) { 693 /* AP mode start/STA connected event */ 694 struct net_device *dev = ar->net_dev; 695 if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) { 696 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM " 697 "(AP started)\n", 698 __func__, le16_to_cpu(ev->u.ap_bss.ch), 699 ev->u.ap_bss.bssid); 700 ath6kl_connect_ap_mode_bss( 701 ar, le16_to_cpu(ev->u.ap_bss.ch)); 702 } else { 703 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM " 704 "auth=%u keymgmt=%u cipher=%u apsd_info=%u " 705 "(STA connected)\n", 706 __func__, ev->u.ap_sta.aid, 707 ev->u.ap_sta.mac_addr, 708 ev->u.ap_sta.auth, 709 ev->u.ap_sta.keymgmt, 710 le16_to_cpu(ev->u.ap_sta.cipher), 711 ev->u.ap_sta.apsd_info); 712 ath6kl_connect_ap_mode_sta( 713 ar, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, 714 ev->u.ap_sta.keymgmt, 715 le16_to_cpu(ev->u.ap_sta.cipher), 716 ev->u.ap_sta.auth, ev->assoc_req_len, 717 ev->assoc_info + ev->beacon_ie_len); 718 } 719 return 0; 720 } 721 722 /* STA/IBSS mode connection event */ 723 724 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM\n", 725 __func__, le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid); 726 727 /* Start of assoc rsp IEs */ 728 pie = ev->assoc_info + ev->beacon_ie_len + 729 ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ 730 731 /* End of assoc rsp IEs */ 732 peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + 733 ev->assoc_resp_len; 734 735 while (pie < peie) { 736 switch (*pie) { 737 case WLAN_EID_VENDOR_SPECIFIC: 738 if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && 739 pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { 740 /* WMM OUT (00:50:F2) */ 741 if (pie[1] > 5 742 && pie[6] == WMM_PARAM_OUI_SUBTYPE) 743 wmi->is_wmm_enabled = true; 744 } 745 break; 746 } 747 748 if (wmi->is_wmm_enabled) 749 break; 750 751 pie += pie[1] + 2; 752 } 753 754 ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->u.sta.ch), 755 ev->u.sta.bssid, 756 le16_to_cpu(ev->u.sta.listen_intvl), 757 le16_to_cpu(ev->u.sta.beacon_intvl), 758 le32_to_cpu(ev->u.sta.nw_type), 759 ev->beacon_ie_len, ev->assoc_req_len, 760 ev->assoc_resp_len, ev->assoc_info); 761 762 return 0; 763 } 764 765 static struct country_code_to_enum_rd * 766 ath6kl_regd_find_country(u16 countryCode) 767 { 768 int i; 769 770 for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 771 if (allCountries[i].countryCode == countryCode) 772 return &allCountries[i]; 773 } 774 775 return NULL; 776 } 777 778 static struct reg_dmn_pair_mapping * 779 ath6kl_get_regpair(u16 regdmn) 780 { 781 int i; 782 783 if (regdmn == NO_ENUMRD) 784 return NULL; 785 786 for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) { 787 if (regDomainPairs[i].regDmnEnum == regdmn) 788 return ®DomainPairs[i]; 789 } 790 791 return NULL; 792 } 793 794 static struct country_code_to_enum_rd * 795 ath6kl_regd_find_country_by_rd(u16 regdmn) 796 { 797 int i; 798 799 for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 800 if (allCountries[i].regDmnEnum == regdmn) 801 return &allCountries[i]; 802 } 803 804 return NULL; 805 } 806 807 static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) 808 { 809 810 struct ath6kl_wmi_regdomain *ev; 811 struct country_code_to_enum_rd *country = NULL; 812 struct reg_dmn_pair_mapping *regpair = NULL; 813 char alpha2[2]; 814 u32 reg_code; 815 816 ev = (struct ath6kl_wmi_regdomain *) datap; 817 reg_code = le32_to_cpu(ev->reg_code); 818 819 if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) 820 country = ath6kl_regd_find_country((u16) reg_code); 821 else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) { 822 823 regpair = ath6kl_get_regpair((u16) reg_code); 824 country = ath6kl_regd_find_country_by_rd((u16) reg_code); 825 ath6kl_dbg(ATH6KL_DBG_WMI, "ath6kl: Regpair used: 0x%0x\n", 826 regpair->regDmnEnum); 827 } 828 829 if (country) { 830 alpha2[0] = country->isoName[0]; 831 alpha2[1] = country->isoName[1]; 832 833 regulatory_hint(wmi->parent_dev->wdev->wiphy, alpha2); 834 835 ath6kl_dbg(ATH6KL_DBG_WMI, "ath6kl: Country alpha2 being used: %c%c\n", 836 alpha2[0], alpha2[1]); 837 } 838 } 839 840 static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) 841 { 842 struct wmi_disconnect_event *ev; 843 wmi->traffic_class = 100; 844 845 if (len < sizeof(struct wmi_disconnect_event)) 846 return -EINVAL; 847 848 ev = (struct wmi_disconnect_event *) datap; 849 850 wmi->is_wmm_enabled = false; 851 wmi->pair_crypto_type = NONE_CRYPT; 852 wmi->grp_crypto_type = NONE_CRYPT; 853 854 ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason, 855 ev->bssid, ev->assoc_resp_len, ev->assoc_info, 856 le16_to_cpu(ev->proto_reason_status)); 857 858 return 0; 859 } 860 861 static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) 862 { 863 struct wmi_peer_node_event *ev; 864 865 if (len < sizeof(struct wmi_peer_node_event)) 866 return -EINVAL; 867 868 ev = (struct wmi_peer_node_event *) datap; 869 870 if (ev->event_code == PEER_NODE_JOIN_EVENT) 871 ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", 872 ev->peer_mac_addr); 873 else if (ev->event_code == PEER_NODE_LEAVE_EVENT) 874 ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", 875 ev->peer_mac_addr); 876 877 return 0; 878 } 879 880 static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len) 881 { 882 struct wmi_tkip_micerr_event *ev; 883 884 if (len < sizeof(struct wmi_tkip_micerr_event)) 885 return -EINVAL; 886 887 ev = (struct wmi_tkip_micerr_event *) datap; 888 889 ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast); 890 891 return 0; 892 } 893 894 static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) 895 { 896 struct wmi_bss_info_hdr2 *bih; 897 u8 *buf; 898 struct ieee80211_channel *channel; 899 struct ath6kl *ar = wmi->parent_dev; 900 struct ieee80211_mgmt *mgmt; 901 struct cfg80211_bss *bss; 902 903 if (len <= sizeof(struct wmi_bss_info_hdr2)) 904 return -EINVAL; 905 906 bih = (struct wmi_bss_info_hdr2 *) datap; 907 buf = datap + sizeof(struct wmi_bss_info_hdr2); 908 len -= sizeof(struct wmi_bss_info_hdr2); 909 910 ath6kl_dbg(ATH6KL_DBG_WMI, 911 "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" " 912 "frame_type=%d\n", 913 bih->ch, bih->snr, bih->snr - 95, bih->bssid, 914 bih->frame_type); 915 916 if (bih->frame_type != BEACON_FTYPE && 917 bih->frame_type != PROBERESP_FTYPE) 918 return 0; /* Only update BSS table for now */ 919 920 if (bih->frame_type == BEACON_FTYPE && 921 test_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag)) { 922 clear_bit(CLEAR_BSSFILTER_ON_BEACON, &ar->flag); 923 ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); 924 } 925 926 channel = ieee80211_get_channel(ar->wdev->wiphy, le16_to_cpu(bih->ch)); 927 if (channel == NULL) 928 return -EINVAL; 929 930 if (len < 8 + 2 + 2) 931 return -EINVAL; 932 933 /* 934 * In theory, use of cfg80211_inform_bss() would be more natural here 935 * since we do not have the full frame. However, at least for now, 936 * cfg80211 can only distinguish Beacon and Probe Response frames from 937 * each other when using cfg80211_inform_bss_frame(), so let's build a 938 * fake IEEE 802.11 header to be able to take benefit of this. 939 */ 940 mgmt = kmalloc(24 + len, GFP_ATOMIC); 941 if (mgmt == NULL) 942 return -EINVAL; 943 944 if (bih->frame_type == BEACON_FTYPE) { 945 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 946 IEEE80211_STYPE_BEACON); 947 memset(mgmt->da, 0xff, ETH_ALEN); 948 } else { 949 struct net_device *dev = ar->net_dev; 950 951 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 952 IEEE80211_STYPE_PROBE_RESP); 953 memcpy(mgmt->da, dev->dev_addr, ETH_ALEN); 954 } 955 mgmt->duration = cpu_to_le16(0); 956 memcpy(mgmt->sa, bih->bssid, ETH_ALEN); 957 memcpy(mgmt->bssid, bih->bssid, ETH_ALEN); 958 mgmt->seq_ctrl = cpu_to_le16(0); 959 960 memcpy(&mgmt->u.beacon, buf, len); 961 962 bss = cfg80211_inform_bss_frame(ar->wdev->wiphy, channel, mgmt, 963 24 + len, (bih->snr - 95) * 100, 964 GFP_ATOMIC); 965 kfree(mgmt); 966 if (bss == NULL) 967 return -ENOMEM; 968 cfg80211_put_bss(bss); 969 970 return 0; 971 } 972 973 /* Inactivity timeout of a fatpipe(pstream) at the target */ 974 static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, 975 int len) 976 { 977 struct wmi_pstream_timeout_event *ev; 978 979 if (len < sizeof(struct wmi_pstream_timeout_event)) 980 return -EINVAL; 981 982 ev = (struct wmi_pstream_timeout_event *) datap; 983 984 /* 985 * When the pstream (fat pipe == AC) timesout, it means there were 986 * no thinStreams within this pstream & it got implicitly created 987 * due to data flow on this AC. We start the inactivity timer only 988 * for implicitly created pstream. Just reset the host state. 989 */ 990 spin_lock_bh(&wmi->lock); 991 wmi->stream_exist_for_ac[ev->traffic_class] = 0; 992 wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); 993 spin_unlock_bh(&wmi->lock); 994 995 /* Indicate inactivity to driver layer for this fatpipe (pstream) */ 996 ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); 997 998 return 0; 999 } 1000 1001 static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) 1002 { 1003 struct wmi_bit_rate_reply *reply; 1004 s32 rate; 1005 u32 sgi, index; 1006 1007 if (len < sizeof(struct wmi_bit_rate_reply)) 1008 return -EINVAL; 1009 1010 reply = (struct wmi_bit_rate_reply *) datap; 1011 1012 ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); 1013 1014 if (reply->rate_index == (s8) RATE_AUTO) { 1015 rate = RATE_AUTO; 1016 } else { 1017 index = reply->rate_index & 0x7f; 1018 sgi = (reply->rate_index & 0x80) ? 1 : 0; 1019 rate = wmi_rate_tbl[index][sgi]; 1020 } 1021 1022 ath6kl_wakeup_event(wmi->parent_dev); 1023 1024 return 0; 1025 } 1026 1027 static int ath6kl_wmi_tcmd_test_report_rx(struct wmi *wmi, u8 *datap, int len) 1028 { 1029 ath6kl_tm_rx_report_event(wmi->parent_dev, datap, len); 1030 1031 return 0; 1032 } 1033 1034 static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) 1035 { 1036 if (len < sizeof(struct wmi_fix_rates_reply)) 1037 return -EINVAL; 1038 1039 ath6kl_wakeup_event(wmi->parent_dev); 1040 1041 return 0; 1042 } 1043 1044 static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) 1045 { 1046 if (len < sizeof(struct wmi_channel_list_reply)) 1047 return -EINVAL; 1048 1049 ath6kl_wakeup_event(wmi->parent_dev); 1050 1051 return 0; 1052 } 1053 1054 static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) 1055 { 1056 struct wmi_tx_pwr_reply *reply; 1057 1058 if (len < sizeof(struct wmi_tx_pwr_reply)) 1059 return -EINVAL; 1060 1061 reply = (struct wmi_tx_pwr_reply *) datap; 1062 ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); 1063 1064 return 0; 1065 } 1066 1067 static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) 1068 { 1069 if (len < sizeof(struct wmi_get_keepalive_cmd)) 1070 return -EINVAL; 1071 1072 ath6kl_wakeup_event(wmi->parent_dev); 1073 1074 return 0; 1075 } 1076 1077 static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len) 1078 { 1079 struct wmi_scan_complete_event *ev; 1080 1081 ev = (struct wmi_scan_complete_event *) datap; 1082 1083 ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status)); 1084 wmi->is_probe_ssid = false; 1085 1086 return 0; 1087 } 1088 1089 /* 1090 * Target is reporting a programming error. This is for 1091 * developer aid only. Target only checks a few common violations 1092 * and it is responsibility of host to do all error checking. 1093 * Behavior of target after wmi error event is undefined. 1094 * A reset is recommended. 1095 */ 1096 static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) 1097 { 1098 const char *type = "unknown error"; 1099 struct wmi_cmd_error_event *ev; 1100 ev = (struct wmi_cmd_error_event *) datap; 1101 1102 switch (ev->err_code) { 1103 case INVALID_PARAM: 1104 type = "invalid parameter"; 1105 break; 1106 case ILLEGAL_STATE: 1107 type = "invalid state"; 1108 break; 1109 case INTERNAL_ERROR: 1110 type = "internal error"; 1111 break; 1112 } 1113 1114 ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", 1115 ev->cmd_id, type); 1116 1117 return 0; 1118 } 1119 1120 static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len) 1121 { 1122 ath6kl_tgt_stats_event(wmi->parent_dev, datap, len); 1123 1124 return 0; 1125 } 1126 1127 static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, 1128 struct sq_threshold_params *sq_thresh, 1129 u32 size) 1130 { 1131 u32 index; 1132 u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; 1133 1134 /* The list is already in sorted order. Get the next lower value */ 1135 for (index = 0; index < size; index++) { 1136 if (rssi < sq_thresh->upper_threshold[index]) { 1137 threshold = (u8) sq_thresh->upper_threshold[index]; 1138 break; 1139 } 1140 } 1141 1142 return threshold; 1143 } 1144 1145 static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, 1146 struct sq_threshold_params *sq_thresh, 1147 u32 size) 1148 { 1149 u32 index; 1150 u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; 1151 1152 /* The list is already in sorted order. Get the next lower value */ 1153 for (index = 0; index < size; index++) { 1154 if (rssi > sq_thresh->lower_threshold[index]) { 1155 threshold = (u8) sq_thresh->lower_threshold[index]; 1156 break; 1157 } 1158 } 1159 1160 return threshold; 1161 } 1162 1163 static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, 1164 struct wmi_rssi_threshold_params_cmd *rssi_cmd) 1165 { 1166 struct sk_buff *skb; 1167 struct wmi_rssi_threshold_params_cmd *cmd; 1168 1169 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1170 if (!skb) 1171 return -ENOMEM; 1172 1173 cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; 1174 memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); 1175 1176 return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, 1177 NO_SYNC_WMIFLAG); 1178 } 1179 1180 static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, 1181 int len) 1182 { 1183 struct wmi_rssi_threshold_event *reply; 1184 struct wmi_rssi_threshold_params_cmd cmd; 1185 struct sq_threshold_params *sq_thresh; 1186 enum wmi_rssi_threshold_val new_threshold; 1187 u8 upper_rssi_threshold, lower_rssi_threshold; 1188 s16 rssi; 1189 int ret; 1190 1191 if (len < sizeof(struct wmi_rssi_threshold_event)) 1192 return -EINVAL; 1193 1194 reply = (struct wmi_rssi_threshold_event *) datap; 1195 new_threshold = (enum wmi_rssi_threshold_val) reply->range; 1196 rssi = a_sle16_to_cpu(reply->rssi); 1197 1198 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; 1199 1200 /* 1201 * Identify the threshold breached and communicate that to the app. 1202 * After that install a new set of thresholds based on the signal 1203 * quality reported by the target 1204 */ 1205 if (new_threshold) { 1206 /* Upper threshold breached */ 1207 if (rssi < sq_thresh->upper_threshold[0]) { 1208 ath6kl_dbg(ATH6KL_DBG_WMI, 1209 "spurious upper rssi threshold event: %d\n", 1210 rssi); 1211 } else if ((rssi < sq_thresh->upper_threshold[1]) && 1212 (rssi >= sq_thresh->upper_threshold[0])) { 1213 new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; 1214 } else if ((rssi < sq_thresh->upper_threshold[2]) && 1215 (rssi >= sq_thresh->upper_threshold[1])) { 1216 new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; 1217 } else if ((rssi < sq_thresh->upper_threshold[3]) && 1218 (rssi >= sq_thresh->upper_threshold[2])) { 1219 new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; 1220 } else if ((rssi < sq_thresh->upper_threshold[4]) && 1221 (rssi >= sq_thresh->upper_threshold[3])) { 1222 new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; 1223 } else if ((rssi < sq_thresh->upper_threshold[5]) && 1224 (rssi >= sq_thresh->upper_threshold[4])) { 1225 new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; 1226 } else if (rssi >= sq_thresh->upper_threshold[5]) { 1227 new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; 1228 } 1229 } else { 1230 /* Lower threshold breached */ 1231 if (rssi > sq_thresh->lower_threshold[0]) { 1232 ath6kl_dbg(ATH6KL_DBG_WMI, 1233 "spurious lower rssi threshold event: %d %d\n", 1234 rssi, sq_thresh->lower_threshold[0]); 1235 } else if ((rssi > sq_thresh->lower_threshold[1]) && 1236 (rssi <= sq_thresh->lower_threshold[0])) { 1237 new_threshold = WMI_RSSI_THRESHOLD6_BELOW; 1238 } else if ((rssi > sq_thresh->lower_threshold[2]) && 1239 (rssi <= sq_thresh->lower_threshold[1])) { 1240 new_threshold = WMI_RSSI_THRESHOLD5_BELOW; 1241 } else if ((rssi > sq_thresh->lower_threshold[3]) && 1242 (rssi <= sq_thresh->lower_threshold[2])) { 1243 new_threshold = WMI_RSSI_THRESHOLD4_BELOW; 1244 } else if ((rssi > sq_thresh->lower_threshold[4]) && 1245 (rssi <= sq_thresh->lower_threshold[3])) { 1246 new_threshold = WMI_RSSI_THRESHOLD3_BELOW; 1247 } else if ((rssi > sq_thresh->lower_threshold[5]) && 1248 (rssi <= sq_thresh->lower_threshold[4])) { 1249 new_threshold = WMI_RSSI_THRESHOLD2_BELOW; 1250 } else if (rssi <= sq_thresh->lower_threshold[5]) { 1251 new_threshold = WMI_RSSI_THRESHOLD1_BELOW; 1252 } 1253 } 1254 1255 /* Calculate and install the next set of thresholds */ 1256 lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, 1257 sq_thresh->lower_threshold_valid_count); 1258 upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, 1259 sq_thresh->upper_threshold_valid_count); 1260 1261 /* Issue a wmi command to install the thresholds */ 1262 cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); 1263 cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); 1264 cmd.weight = sq_thresh->weight; 1265 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1266 1267 ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); 1268 if (ret) { 1269 ath6kl_err("unable to configure rssi thresholds\n"); 1270 return -EIO; 1271 } 1272 1273 return 0; 1274 } 1275 1276 static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) 1277 { 1278 struct wmi_cac_event *reply; 1279 struct ieee80211_tspec_ie *ts; 1280 u16 active_tsids, tsinfo; 1281 u8 tsid, index; 1282 u8 ts_id; 1283 1284 if (len < sizeof(struct wmi_cac_event)) 1285 return -EINVAL; 1286 1287 reply = (struct wmi_cac_event *) datap; 1288 1289 if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && 1290 (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { 1291 1292 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1293 tsinfo = le16_to_cpu(ts->tsinfo); 1294 tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1295 IEEE80211_WMM_IE_TSPEC_TID_MASK; 1296 1297 ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid); 1298 } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { 1299 /* 1300 * Following assumes that there is only one outstanding 1301 * ADDTS request when this event is received 1302 */ 1303 spin_lock_bh(&wmi->lock); 1304 active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1305 spin_unlock_bh(&wmi->lock); 1306 1307 for (index = 0; index < sizeof(active_tsids) * 8; index++) { 1308 if ((active_tsids >> index) & 1) 1309 break; 1310 } 1311 if (index < (sizeof(active_tsids) * 8)) 1312 ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index); 1313 } 1314 1315 /* 1316 * Clear active tsids and Add missing handling 1317 * for delete qos stream from AP 1318 */ 1319 else if (reply->cac_indication == CAC_INDICATION_DELETE) { 1320 1321 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1322 tsinfo = le16_to_cpu(ts->tsinfo); 1323 ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1324 IEEE80211_WMM_IE_TSPEC_TID_MASK); 1325 1326 spin_lock_bh(&wmi->lock); 1327 wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); 1328 active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1329 spin_unlock_bh(&wmi->lock); 1330 1331 /* Indicate stream inactivity to driver layer only if all tsids 1332 * within this AC are deleted. 1333 */ 1334 if (!active_tsids) { 1335 ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, 1336 false); 1337 wmi->fat_pipe_exist &= ~(1 << reply->ac); 1338 } 1339 } 1340 1341 return 0; 1342 } 1343 1344 static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, 1345 struct wmi_snr_threshold_params_cmd *snr_cmd) 1346 { 1347 struct sk_buff *skb; 1348 struct wmi_snr_threshold_params_cmd *cmd; 1349 1350 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1351 if (!skb) 1352 return -ENOMEM; 1353 1354 cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; 1355 memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); 1356 1357 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, 1358 NO_SYNC_WMIFLAG); 1359 } 1360 1361 static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, 1362 int len) 1363 { 1364 struct wmi_snr_threshold_event *reply; 1365 struct sq_threshold_params *sq_thresh; 1366 struct wmi_snr_threshold_params_cmd cmd; 1367 enum wmi_snr_threshold_val new_threshold; 1368 u8 upper_snr_threshold, lower_snr_threshold; 1369 s16 snr; 1370 int ret; 1371 1372 if (len < sizeof(struct wmi_snr_threshold_event)) 1373 return -EINVAL; 1374 1375 reply = (struct wmi_snr_threshold_event *) datap; 1376 1377 new_threshold = (enum wmi_snr_threshold_val) reply->range; 1378 snr = reply->snr; 1379 1380 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; 1381 1382 /* 1383 * Identify the threshold breached and communicate that to the app. 1384 * After that install a new set of thresholds based on the signal 1385 * quality reported by the target. 1386 */ 1387 if (new_threshold) { 1388 /* Upper threshold breached */ 1389 if (snr < sq_thresh->upper_threshold[0]) { 1390 ath6kl_dbg(ATH6KL_DBG_WMI, 1391 "spurious upper snr threshold event: %d\n", 1392 snr); 1393 } else if ((snr < sq_thresh->upper_threshold[1]) && 1394 (snr >= sq_thresh->upper_threshold[0])) { 1395 new_threshold = WMI_SNR_THRESHOLD1_ABOVE; 1396 } else if ((snr < sq_thresh->upper_threshold[2]) && 1397 (snr >= sq_thresh->upper_threshold[1])) { 1398 new_threshold = WMI_SNR_THRESHOLD2_ABOVE; 1399 } else if ((snr < sq_thresh->upper_threshold[3]) && 1400 (snr >= sq_thresh->upper_threshold[2])) { 1401 new_threshold = WMI_SNR_THRESHOLD3_ABOVE; 1402 } else if (snr >= sq_thresh->upper_threshold[3]) { 1403 new_threshold = WMI_SNR_THRESHOLD4_ABOVE; 1404 } 1405 } else { 1406 /* Lower threshold breached */ 1407 if (snr > sq_thresh->lower_threshold[0]) { 1408 ath6kl_dbg(ATH6KL_DBG_WMI, 1409 "spurious lower snr threshold event: %d\n", 1410 sq_thresh->lower_threshold[0]); 1411 } else if ((snr > sq_thresh->lower_threshold[1]) && 1412 (snr <= sq_thresh->lower_threshold[0])) { 1413 new_threshold = WMI_SNR_THRESHOLD4_BELOW; 1414 } else if ((snr > sq_thresh->lower_threshold[2]) && 1415 (snr <= sq_thresh->lower_threshold[1])) { 1416 new_threshold = WMI_SNR_THRESHOLD3_BELOW; 1417 } else if ((snr > sq_thresh->lower_threshold[3]) && 1418 (snr <= sq_thresh->lower_threshold[2])) { 1419 new_threshold = WMI_SNR_THRESHOLD2_BELOW; 1420 } else if (snr <= sq_thresh->lower_threshold[3]) { 1421 new_threshold = WMI_SNR_THRESHOLD1_BELOW; 1422 } 1423 } 1424 1425 /* Calculate and install the next set of thresholds */ 1426 lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, 1427 sq_thresh->lower_threshold_valid_count); 1428 upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, 1429 sq_thresh->upper_threshold_valid_count); 1430 1431 /* Issue a wmi command to install the thresholds */ 1432 cmd.thresh_above1_val = upper_snr_threshold; 1433 cmd.thresh_below1_val = lower_snr_threshold; 1434 cmd.weight = sq_thresh->weight; 1435 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1436 1437 ath6kl_dbg(ATH6KL_DBG_WMI, 1438 "snr: %d, threshold: %d, lower: %d, upper: %d\n", 1439 snr, new_threshold, 1440 lower_snr_threshold, upper_snr_threshold); 1441 1442 ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); 1443 if (ret) { 1444 ath6kl_err("unable to configure snr threshold\n"); 1445 return -EIO; 1446 } 1447 1448 return 0; 1449 } 1450 1451 static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) 1452 { 1453 u16 ap_info_entry_size; 1454 struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; 1455 struct wmi_ap_info_v1 *ap_info_v1; 1456 u8 index; 1457 1458 if (len < sizeof(struct wmi_aplist_event) || 1459 ev->ap_list_ver != APLIST_VER1) 1460 return -EINVAL; 1461 1462 ap_info_entry_size = sizeof(struct wmi_ap_info_v1); 1463 ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; 1464 1465 ath6kl_dbg(ATH6KL_DBG_WMI, 1466 "number of APs in aplist event: %d\n", ev->num_ap); 1467 1468 if (len < (int) (sizeof(struct wmi_aplist_event) + 1469 (ev->num_ap - 1) * ap_info_entry_size)) 1470 return -EINVAL; 1471 1472 /* AP list version 1 contents */ 1473 for (index = 0; index < ev->num_ap; index++) { 1474 ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", 1475 index, ap_info_v1->bssid, ap_info_v1->channel); 1476 ap_info_v1++; 1477 } 1478 1479 return 0; 1480 } 1481 1482 int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, 1483 enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) 1484 { 1485 struct wmi_cmd_hdr *cmd_hdr; 1486 enum htc_endpoint_id ep_id = wmi->ep_id; 1487 int ret; 1488 1489 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: cmd_id=%d\n", __func__, cmd_id); 1490 1491 if (WARN_ON(skb == NULL)) 1492 return -EINVAL; 1493 1494 if (sync_flag >= END_WMIFLAG) { 1495 dev_kfree_skb(skb); 1496 return -EINVAL; 1497 } 1498 1499 if ((sync_flag == SYNC_BEFORE_WMIFLAG) || 1500 (sync_flag == SYNC_BOTH_WMIFLAG)) { 1501 /* 1502 * Make sure all data currently queued is transmitted before 1503 * the cmd execution. Establish a new sync point. 1504 */ 1505 ath6kl_wmi_sync_point(wmi); 1506 } 1507 1508 skb_push(skb, sizeof(struct wmi_cmd_hdr)); 1509 1510 cmd_hdr = (struct wmi_cmd_hdr *) skb->data; 1511 cmd_hdr->cmd_id = cpu_to_le16(cmd_id); 1512 cmd_hdr->info1 = 0; /* added for virtual interface */ 1513 1514 /* Only for OPT_TX_CMD, use BE endpoint. */ 1515 if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { 1516 ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, 1517 false, false, 0, NULL); 1518 if (ret) { 1519 dev_kfree_skb(skb); 1520 return ret; 1521 } 1522 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); 1523 } 1524 1525 ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 1526 1527 if ((sync_flag == SYNC_AFTER_WMIFLAG) || 1528 (sync_flag == SYNC_BOTH_WMIFLAG)) { 1529 /* 1530 * Make sure all new data queued waits for the command to 1531 * execute. Establish a new sync point. 1532 */ 1533 ath6kl_wmi_sync_point(wmi); 1534 } 1535 1536 return 0; 1537 } 1538 1539 int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, 1540 enum dot11_auth_mode dot11_auth_mode, 1541 enum auth_mode auth_mode, 1542 enum crypto_type pairwise_crypto, 1543 u8 pairwise_crypto_len, 1544 enum crypto_type group_crypto, 1545 u8 group_crypto_len, int ssid_len, u8 *ssid, 1546 u8 *bssid, u16 channel, u32 ctrl_flags) 1547 { 1548 struct sk_buff *skb; 1549 struct wmi_connect_cmd *cc; 1550 int ret; 1551 1552 wmi->traffic_class = 100; 1553 1554 if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) 1555 return -EINVAL; 1556 1557 if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) 1558 return -EINVAL; 1559 1560 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); 1561 if (!skb) 1562 return -ENOMEM; 1563 1564 cc = (struct wmi_connect_cmd *) skb->data; 1565 1566 if (ssid_len) 1567 memcpy(cc->ssid, ssid, ssid_len); 1568 1569 cc->ssid_len = ssid_len; 1570 cc->nw_type = nw_type; 1571 cc->dot11_auth_mode = dot11_auth_mode; 1572 cc->auth_mode = auth_mode; 1573 cc->prwise_crypto_type = pairwise_crypto; 1574 cc->prwise_crypto_len = pairwise_crypto_len; 1575 cc->grp_crypto_type = group_crypto; 1576 cc->grp_crypto_len = group_crypto_len; 1577 cc->ch = cpu_to_le16(channel); 1578 cc->ctrl_flags = cpu_to_le32(ctrl_flags); 1579 1580 if (bssid != NULL) 1581 memcpy(cc->bssid, bssid, ETH_ALEN); 1582 1583 wmi->pair_crypto_type = pairwise_crypto; 1584 wmi->grp_crypto_type = group_crypto; 1585 1586 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG); 1587 1588 return ret; 1589 } 1590 1591 int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel) 1592 { 1593 struct sk_buff *skb; 1594 struct wmi_reconnect_cmd *cc; 1595 int ret; 1596 1597 wmi->traffic_class = 100; 1598 1599 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); 1600 if (!skb) 1601 return -ENOMEM; 1602 1603 cc = (struct wmi_reconnect_cmd *) skb->data; 1604 cc->channel = cpu_to_le16(channel); 1605 1606 if (bssid != NULL) 1607 memcpy(cc->bssid, bssid, ETH_ALEN); 1608 1609 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID, 1610 NO_SYNC_WMIFLAG); 1611 1612 return ret; 1613 } 1614 1615 int ath6kl_wmi_disconnect_cmd(struct wmi *wmi) 1616 { 1617 int ret; 1618 1619 wmi->traffic_class = 100; 1620 1621 /* Disconnect command does not need to do a SYNC before. */ 1622 ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID); 1623 1624 return ret; 1625 } 1626 1627 int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, 1628 u32 force_fgscan, u32 is_legacy, 1629 u32 home_dwell_time, u32 force_scan_interval, 1630 s8 num_chan, u16 *ch_list) 1631 { 1632 struct sk_buff *skb; 1633 struct wmi_start_scan_cmd *sc; 1634 s8 size; 1635 int i, ret; 1636 1637 size = sizeof(struct wmi_start_scan_cmd); 1638 1639 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 1640 return -EINVAL; 1641 1642 if (num_chan > WMI_MAX_CHANNELS) 1643 return -EINVAL; 1644 1645 if (num_chan) 1646 size += sizeof(u16) * (num_chan - 1); 1647 1648 skb = ath6kl_wmi_get_new_buf(size); 1649 if (!skb) 1650 return -ENOMEM; 1651 1652 sc = (struct wmi_start_scan_cmd *) skb->data; 1653 sc->scan_type = scan_type; 1654 sc->force_fg_scan = cpu_to_le32(force_fgscan); 1655 sc->is_legacy = cpu_to_le32(is_legacy); 1656 sc->home_dwell_time = cpu_to_le32(home_dwell_time); 1657 sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 1658 sc->num_ch = num_chan; 1659 1660 for (i = 0; i < num_chan; i++) 1661 sc->ch_list[i] = cpu_to_le16(ch_list[i]); 1662 1663 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID, 1664 NO_SYNC_WMIFLAG); 1665 1666 return ret; 1667 } 1668 1669 int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, 1670 u16 fg_end_sec, u16 bg_sec, 1671 u16 minact_chdw_msec, u16 maxact_chdw_msec, 1672 u16 pas_chdw_msec, u8 short_scan_ratio, 1673 u8 scan_ctrl_flag, u32 max_dfsch_act_time, 1674 u16 maxact_scan_per_ssid) 1675 { 1676 struct sk_buff *skb; 1677 struct wmi_scan_params_cmd *sc; 1678 int ret; 1679 1680 skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); 1681 if (!skb) 1682 return -ENOMEM; 1683 1684 sc = (struct wmi_scan_params_cmd *) skb->data; 1685 sc->fg_start_period = cpu_to_le16(fg_start_sec); 1686 sc->fg_end_period = cpu_to_le16(fg_end_sec); 1687 sc->bg_period = cpu_to_le16(bg_sec); 1688 sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); 1689 sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); 1690 sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); 1691 sc->short_scan_ratio = short_scan_ratio; 1692 sc->scan_ctrl_flags = scan_ctrl_flag; 1693 sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); 1694 sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); 1695 1696 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID, 1697 NO_SYNC_WMIFLAG); 1698 return ret; 1699 } 1700 1701 int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) 1702 { 1703 struct sk_buff *skb; 1704 struct wmi_bss_filter_cmd *cmd; 1705 int ret; 1706 1707 if (filter >= LAST_BSS_FILTER) 1708 return -EINVAL; 1709 1710 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1711 if (!skb) 1712 return -ENOMEM; 1713 1714 cmd = (struct wmi_bss_filter_cmd *) skb->data; 1715 cmd->bss_filter = filter; 1716 cmd->ie_mask = cpu_to_le32(ie_mask); 1717 1718 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID, 1719 NO_SYNC_WMIFLAG); 1720 return ret; 1721 } 1722 1723 int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, 1724 u8 ssid_len, u8 *ssid) 1725 { 1726 struct sk_buff *skb; 1727 struct wmi_probed_ssid_cmd *cmd; 1728 int ret; 1729 1730 if (index > MAX_PROBED_SSID_INDEX) 1731 return -EINVAL; 1732 1733 if (ssid_len > sizeof(cmd->ssid)) 1734 return -EINVAL; 1735 1736 if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) 1737 return -EINVAL; 1738 1739 if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) 1740 return -EINVAL; 1741 1742 if (flag & SPECIFIC_SSID_FLAG) 1743 wmi->is_probe_ssid = true; 1744 1745 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1746 if (!skb) 1747 return -ENOMEM; 1748 1749 cmd = (struct wmi_probed_ssid_cmd *) skb->data; 1750 cmd->entry_index = index; 1751 cmd->flag = flag; 1752 cmd->ssid_len = ssid_len; 1753 memcpy(cmd->ssid, ssid, ssid_len); 1754 1755 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID, 1756 NO_SYNC_WMIFLAG); 1757 return ret; 1758 } 1759 1760 int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, 1761 u16 listen_beacons) 1762 { 1763 struct sk_buff *skb; 1764 struct wmi_listen_int_cmd *cmd; 1765 int ret; 1766 1767 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1768 if (!skb) 1769 return -ENOMEM; 1770 1771 cmd = (struct wmi_listen_int_cmd *) skb->data; 1772 cmd->listen_intvl = cpu_to_le16(listen_interval); 1773 cmd->num_beacons = cpu_to_le16(listen_beacons); 1774 1775 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID, 1776 NO_SYNC_WMIFLAG); 1777 return ret; 1778 } 1779 1780 int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode) 1781 { 1782 struct sk_buff *skb; 1783 struct wmi_power_mode_cmd *cmd; 1784 int ret; 1785 1786 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1787 if (!skb) 1788 return -ENOMEM; 1789 1790 cmd = (struct wmi_power_mode_cmd *) skb->data; 1791 cmd->pwr_mode = pwr_mode; 1792 wmi->pwr_mode = pwr_mode; 1793 1794 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID, 1795 NO_SYNC_WMIFLAG); 1796 return ret; 1797 } 1798 1799 int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, 1800 u16 ps_poll_num, u16 dtim_policy, 1801 u16 tx_wakeup_policy, u16 num_tx_to_wakeup, 1802 u16 ps_fail_event_policy) 1803 { 1804 struct sk_buff *skb; 1805 struct wmi_power_params_cmd *pm; 1806 int ret; 1807 1808 skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); 1809 if (!skb) 1810 return -ENOMEM; 1811 1812 pm = (struct wmi_power_params_cmd *)skb->data; 1813 pm->idle_period = cpu_to_le16(idle_period); 1814 pm->pspoll_number = cpu_to_le16(ps_poll_num); 1815 pm->dtim_policy = cpu_to_le16(dtim_policy); 1816 pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); 1817 pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); 1818 pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); 1819 1820 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID, 1821 NO_SYNC_WMIFLAG); 1822 return ret; 1823 } 1824 1825 int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) 1826 { 1827 struct sk_buff *skb; 1828 struct wmi_disc_timeout_cmd *cmd; 1829 int ret; 1830 1831 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1832 if (!skb) 1833 return -ENOMEM; 1834 1835 cmd = (struct wmi_disc_timeout_cmd *) skb->data; 1836 cmd->discon_timeout = timeout; 1837 1838 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID, 1839 NO_SYNC_WMIFLAG); 1840 return ret; 1841 } 1842 1843 int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, 1844 enum crypto_type key_type, 1845 u8 key_usage, u8 key_len, 1846 u8 *key_rsc, u8 *key_material, 1847 u8 key_op_ctrl, u8 *mac_addr, 1848 enum wmi_sync_flag sync_flag) 1849 { 1850 struct sk_buff *skb; 1851 struct wmi_add_cipher_key_cmd *cmd; 1852 int ret; 1853 1854 ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " 1855 "key_usage=%d key_len=%d key_op_ctrl=%d\n", 1856 key_index, key_type, key_usage, key_len, key_op_ctrl); 1857 1858 if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || 1859 (key_material == NULL)) 1860 return -EINVAL; 1861 1862 if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) 1863 return -EINVAL; 1864 1865 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1866 if (!skb) 1867 return -ENOMEM; 1868 1869 cmd = (struct wmi_add_cipher_key_cmd *) skb->data; 1870 cmd->key_index = key_index; 1871 cmd->key_type = key_type; 1872 cmd->key_usage = key_usage; 1873 cmd->key_len = key_len; 1874 memcpy(cmd->key, key_material, key_len); 1875 1876 if (key_rsc != NULL) 1877 memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc)); 1878 1879 cmd->key_op_ctrl = key_op_ctrl; 1880 1881 if (mac_addr) 1882 memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); 1883 1884 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID, 1885 sync_flag); 1886 1887 return ret; 1888 } 1889 1890 int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) 1891 { 1892 struct sk_buff *skb; 1893 struct wmi_add_krk_cmd *cmd; 1894 int ret; 1895 1896 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1897 if (!skb) 1898 return -ENOMEM; 1899 1900 cmd = (struct wmi_add_krk_cmd *) skb->data; 1901 memcpy(cmd->krk, krk, WMI_KRK_LEN); 1902 1903 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG); 1904 1905 return ret; 1906 } 1907 1908 int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index) 1909 { 1910 struct sk_buff *skb; 1911 struct wmi_delete_cipher_key_cmd *cmd; 1912 int ret; 1913 1914 if (key_index > WMI_MAX_KEY_INDEX) 1915 return -EINVAL; 1916 1917 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1918 if (!skb) 1919 return -ENOMEM; 1920 1921 cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; 1922 cmd->key_index = key_index; 1923 1924 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID, 1925 NO_SYNC_WMIFLAG); 1926 1927 return ret; 1928 } 1929 1930 int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, 1931 const u8 *pmkid, bool set) 1932 { 1933 struct sk_buff *skb; 1934 struct wmi_setpmkid_cmd *cmd; 1935 int ret; 1936 1937 if (bssid == NULL) 1938 return -EINVAL; 1939 1940 if (set && pmkid == NULL) 1941 return -EINVAL; 1942 1943 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1944 if (!skb) 1945 return -ENOMEM; 1946 1947 cmd = (struct wmi_setpmkid_cmd *) skb->data; 1948 memcpy(cmd->bssid, bssid, ETH_ALEN); 1949 if (set) { 1950 memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); 1951 cmd->enable = PMKID_ENABLE; 1952 } else { 1953 memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); 1954 cmd->enable = PMKID_DISABLE; 1955 } 1956 1957 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID, 1958 NO_SYNC_WMIFLAG); 1959 1960 return ret; 1961 } 1962 1963 static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, 1964 enum htc_endpoint_id ep_id) 1965 { 1966 struct wmi_data_hdr *data_hdr; 1967 int ret; 1968 1969 if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) 1970 return -EINVAL; 1971 1972 skb_push(skb, sizeof(struct wmi_data_hdr)); 1973 1974 data_hdr = (struct wmi_data_hdr *) skb->data; 1975 data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; 1976 data_hdr->info3 = 0; 1977 1978 ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 1979 1980 return ret; 1981 } 1982 1983 static int ath6kl_wmi_sync_point(struct wmi *wmi) 1984 { 1985 struct sk_buff *skb; 1986 struct wmi_sync_cmd *cmd; 1987 struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; 1988 enum htc_endpoint_id ep_id; 1989 u8 index, num_pri_streams = 0; 1990 int ret = 0; 1991 1992 memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); 1993 1994 spin_lock_bh(&wmi->lock); 1995 1996 for (index = 0; index < WMM_NUM_AC; index++) { 1997 if (wmi->fat_pipe_exist & (1 << index)) { 1998 num_pri_streams++; 1999 data_sync_bufs[num_pri_streams - 1].traffic_class = 2000 index; 2001 } 2002 } 2003 2004 spin_unlock_bh(&wmi->lock); 2005 2006 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2007 if (!skb) { 2008 ret = -ENOMEM; 2009 goto free_skb; 2010 } 2011 2012 cmd = (struct wmi_sync_cmd *) skb->data; 2013 2014 /* 2015 * In the SYNC cmd sent on the control Ep, send a bitmap 2016 * of the data eps on which the Data Sync will be sent 2017 */ 2018 cmd->data_sync_map = wmi->fat_pipe_exist; 2019 2020 for (index = 0; index < num_pri_streams; index++) { 2021 data_sync_bufs[index].skb = ath6kl_buf_alloc(0); 2022 if (data_sync_bufs[index].skb == NULL) { 2023 ret = -ENOMEM; 2024 break; 2025 } 2026 } 2027 2028 /* 2029 * If buffer allocation for any of the dataSync fails, 2030 * then do not send the Synchronize cmd on the control ep 2031 */ 2032 if (ret) 2033 goto free_skb; 2034 2035 /* 2036 * Send sync cmd followed by sync data messages on all 2037 * endpoints being used 2038 */ 2039 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID, 2040 NO_SYNC_WMIFLAG); 2041 2042 if (ret) 2043 goto free_skb; 2044 2045 /* cmd buffer sent, we no longer own it */ 2046 skb = NULL; 2047 2048 for (index = 0; index < num_pri_streams; index++) { 2049 2050 if (WARN_ON(!data_sync_bufs[index].skb)) 2051 break; 2052 2053 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, 2054 data_sync_bufs[index]. 2055 traffic_class); 2056 ret = 2057 ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, 2058 ep_id); 2059 2060 if (ret) 2061 break; 2062 2063 data_sync_bufs[index].skb = NULL; 2064 } 2065 2066 free_skb: 2067 /* free up any resources left over (possibly due to an error) */ 2068 if (skb) 2069 dev_kfree_skb(skb); 2070 2071 for (index = 0; index < num_pri_streams; index++) { 2072 if (data_sync_bufs[index].skb != NULL) { 2073 dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. 2074 skb); 2075 } 2076 } 2077 2078 return ret; 2079 } 2080 2081 int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, 2082 struct wmi_create_pstream_cmd *params) 2083 { 2084 struct sk_buff *skb; 2085 struct wmi_create_pstream_cmd *cmd; 2086 u8 fatpipe_exist_for_ac = 0; 2087 s32 min_phy = 0; 2088 s32 nominal_phy = 0; 2089 int ret; 2090 2091 if (!((params->user_pri < 8) && 2092 (params->user_pri <= 0x7) && 2093 (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && 2094 (params->traffic_direc == UPLINK_TRAFFIC || 2095 params->traffic_direc == DNLINK_TRAFFIC || 2096 params->traffic_direc == BIDIR_TRAFFIC) && 2097 (params->traffic_type == TRAFFIC_TYPE_APERIODIC || 2098 params->traffic_type == TRAFFIC_TYPE_PERIODIC) && 2099 (params->voice_psc_cap == DISABLE_FOR_THIS_AC || 2100 params->voice_psc_cap == ENABLE_FOR_THIS_AC || 2101 params->voice_psc_cap == ENABLE_FOR_ALL_AC) && 2102 (params->tsid == WMI_IMPLICIT_PSTREAM || 2103 params->tsid <= WMI_MAX_THINSTREAM))) { 2104 return -EINVAL; 2105 } 2106 2107 /* 2108 * Check nominal PHY rate is >= minimalPHY, 2109 * so that DUT can allow TSRS IE 2110 */ 2111 2112 /* Get the physical rate (units of bps) */ 2113 min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); 2114 2115 /* Check minimal phy < nominal phy rate */ 2116 if (params->nominal_phy >= min_phy) { 2117 /* unit of 500 kbps */ 2118 nominal_phy = (params->nominal_phy * 1000) / 500; 2119 ath6kl_dbg(ATH6KL_DBG_WMI, 2120 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", 2121 min_phy, nominal_phy); 2122 2123 params->nominal_phy = nominal_phy; 2124 } else { 2125 params->nominal_phy = 0; 2126 } 2127 2128 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2129 if (!skb) 2130 return -ENOMEM; 2131 2132 ath6kl_dbg(ATH6KL_DBG_WMI, 2133 "sending create_pstream_cmd: ac=%d tsid:%d\n", 2134 params->traffic_class, params->tsid); 2135 2136 cmd = (struct wmi_create_pstream_cmd *) skb->data; 2137 memcpy(cmd, params, sizeof(*cmd)); 2138 2139 /* This is an implicitly created Fat pipe */ 2140 if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { 2141 spin_lock_bh(&wmi->lock); 2142 fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2143 (1 << params->traffic_class)); 2144 wmi->fat_pipe_exist |= (1 << params->traffic_class); 2145 spin_unlock_bh(&wmi->lock); 2146 } else { 2147 /* explicitly created thin stream within a fat pipe */ 2148 spin_lock_bh(&wmi->lock); 2149 fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2150 (1 << params->traffic_class)); 2151 wmi->stream_exist_for_ac[params->traffic_class] |= 2152 (1 << params->tsid); 2153 /* 2154 * If a thinstream becomes active, the fat pipe automatically 2155 * becomes active 2156 */ 2157 wmi->fat_pipe_exist |= (1 << params->traffic_class); 2158 spin_unlock_bh(&wmi->lock); 2159 } 2160 2161 /* 2162 * Indicate activty change to driver layer only if this is the 2163 * first TSID to get created in this AC explicitly or an implicit 2164 * fat pipe is getting created. 2165 */ 2166 if (!fatpipe_exist_for_ac) 2167 ath6kl_indicate_tx_activity(wmi->parent_dev, 2168 params->traffic_class, true); 2169 2170 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID, 2171 NO_SYNC_WMIFLAG); 2172 return ret; 2173 } 2174 2175 int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) 2176 { 2177 struct sk_buff *skb; 2178 struct wmi_delete_pstream_cmd *cmd; 2179 u16 active_tsids = 0; 2180 int ret; 2181 2182 if (traffic_class > 3) { 2183 ath6kl_err("invalid traffic class: %d\n", traffic_class); 2184 return -EINVAL; 2185 } 2186 2187 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2188 if (!skb) 2189 return -ENOMEM; 2190 2191 cmd = (struct wmi_delete_pstream_cmd *) skb->data; 2192 cmd->traffic_class = traffic_class; 2193 cmd->tsid = tsid; 2194 2195 spin_lock_bh(&wmi->lock); 2196 active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2197 spin_unlock_bh(&wmi->lock); 2198 2199 if (!(active_tsids & (1 << tsid))) { 2200 dev_kfree_skb(skb); 2201 ath6kl_dbg(ATH6KL_DBG_WMI, 2202 "TSID %d doesn't exist for traffic class: %d\n", 2203 tsid, traffic_class); 2204 return -ENODATA; 2205 } 2206 2207 ath6kl_dbg(ATH6KL_DBG_WMI, 2208 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", 2209 traffic_class, tsid); 2210 2211 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID, 2212 SYNC_BEFORE_WMIFLAG); 2213 2214 spin_lock_bh(&wmi->lock); 2215 wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); 2216 active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2217 spin_unlock_bh(&wmi->lock); 2218 2219 /* 2220 * Indicate stream inactivity to driver layer only if all tsids 2221 * within this AC are deleted. 2222 */ 2223 if (!active_tsids) { 2224 ath6kl_indicate_tx_activity(wmi->parent_dev, 2225 traffic_class, false); 2226 wmi->fat_pipe_exist &= ~(1 << traffic_class); 2227 } 2228 2229 return ret; 2230 } 2231 2232 int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) 2233 { 2234 struct sk_buff *skb; 2235 struct wmi_set_ip_cmd *cmd; 2236 int ret; 2237 2238 /* Multicast address are not valid */ 2239 if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) || 2240 (*((u8 *) &ip_cmd->ips[1]) >= 0xE0)) 2241 return -EINVAL; 2242 2243 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); 2244 if (!skb) 2245 return -ENOMEM; 2246 2247 cmd = (struct wmi_set_ip_cmd *) skb->data; 2248 memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); 2249 2250 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG); 2251 return ret; 2252 } 2253 2254 static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, 2255 int len) 2256 { 2257 if (len < sizeof(struct wmi_get_wow_list_reply)) 2258 return -EINVAL; 2259 2260 return 0; 2261 } 2262 2263 static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, 2264 enum wmix_command_id cmd_id, 2265 enum wmi_sync_flag sync_flag) 2266 { 2267 struct wmix_cmd_hdr *cmd_hdr; 2268 int ret; 2269 2270 skb_push(skb, sizeof(struct wmix_cmd_hdr)); 2271 2272 cmd_hdr = (struct wmix_cmd_hdr *) skb->data; 2273 cmd_hdr->cmd_id = cpu_to_le32(cmd_id); 2274 2275 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag); 2276 2277 return ret; 2278 } 2279 2280 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) 2281 { 2282 struct sk_buff *skb; 2283 struct wmix_hb_challenge_resp_cmd *cmd; 2284 int ret; 2285 2286 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2287 if (!skb) 2288 return -ENOMEM; 2289 2290 cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; 2291 cmd->cookie = cpu_to_le32(cookie); 2292 cmd->source = cpu_to_le32(source); 2293 2294 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, 2295 NO_SYNC_WMIFLAG); 2296 return ret; 2297 } 2298 2299 int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config) 2300 { 2301 struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd; 2302 struct sk_buff *skb; 2303 int ret; 2304 2305 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2306 if (!skb) 2307 return -ENOMEM; 2308 2309 cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data; 2310 cmd->valid = cpu_to_le32(valid); 2311 cmd->config = cpu_to_le32(config); 2312 2313 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID, 2314 NO_SYNC_WMIFLAG); 2315 return ret; 2316 } 2317 2318 int ath6kl_wmi_get_stats_cmd(struct wmi *wmi) 2319 { 2320 return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID); 2321 } 2322 2323 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) 2324 { 2325 struct sk_buff *skb; 2326 struct wmi_set_tx_pwr_cmd *cmd; 2327 int ret; 2328 2329 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); 2330 if (!skb) 2331 return -ENOMEM; 2332 2333 cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; 2334 cmd->dbM = dbM; 2335 2336 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID, 2337 NO_SYNC_WMIFLAG); 2338 2339 return ret; 2340 } 2341 2342 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) 2343 { 2344 return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID); 2345 } 2346 2347 int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) 2348 { 2349 struct sk_buff *skb; 2350 struct wmi_set_lpreamble_cmd *cmd; 2351 int ret; 2352 2353 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); 2354 if (!skb) 2355 return -ENOMEM; 2356 2357 cmd = (struct wmi_set_lpreamble_cmd *) skb->data; 2358 cmd->status = status; 2359 cmd->preamble_policy = preamble_policy; 2360 2361 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID, 2362 NO_SYNC_WMIFLAG); 2363 return ret; 2364 } 2365 2366 int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) 2367 { 2368 struct sk_buff *skb; 2369 struct wmi_set_rts_cmd *cmd; 2370 int ret; 2371 2372 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); 2373 if (!skb) 2374 return -ENOMEM; 2375 2376 cmd = (struct wmi_set_rts_cmd *) skb->data; 2377 cmd->threshold = cpu_to_le16(threshold); 2378 2379 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG); 2380 return ret; 2381 } 2382 2383 int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) 2384 { 2385 struct sk_buff *skb; 2386 struct wmi_set_wmm_txop_cmd *cmd; 2387 int ret; 2388 2389 if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) 2390 return -EINVAL; 2391 2392 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); 2393 if (!skb) 2394 return -ENOMEM; 2395 2396 cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; 2397 cmd->txop_enable = cfg; 2398 2399 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID, 2400 NO_SYNC_WMIFLAG); 2401 return ret; 2402 } 2403 2404 int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) 2405 { 2406 struct sk_buff *skb; 2407 struct wmi_set_keepalive_cmd *cmd; 2408 int ret; 2409 2410 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2411 if (!skb) 2412 return -ENOMEM; 2413 2414 cmd = (struct wmi_set_keepalive_cmd *) skb->data; 2415 cmd->keep_alive_intvl = keep_alive_intvl; 2416 wmi->keep_alive_intvl = keep_alive_intvl; 2417 2418 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, 2419 NO_SYNC_WMIFLAG); 2420 return ret; 2421 } 2422 2423 int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) 2424 { 2425 struct sk_buff *skb; 2426 int ret; 2427 2428 skb = ath6kl_wmi_get_new_buf(len); 2429 if (!skb) 2430 return -ENOMEM; 2431 2432 memcpy(skb->data, buf, len); 2433 2434 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); 2435 2436 return ret; 2437 } 2438 2439 2440 s32 ath6kl_wmi_get_rate(s8 rate_index) 2441 { 2442 if (rate_index == RATE_AUTO) 2443 return 0; 2444 2445 return wmi_rate_tbl[(u32) rate_index][0]; 2446 } 2447 2448 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, 2449 u32 len) 2450 { 2451 struct wmi_pmkid_list_reply *reply; 2452 u32 expected_len; 2453 2454 if (len < sizeof(struct wmi_pmkid_list_reply)) 2455 return -EINVAL; 2456 2457 reply = (struct wmi_pmkid_list_reply *)datap; 2458 expected_len = sizeof(reply->num_pmkid) + 2459 le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; 2460 2461 if (len < expected_len) 2462 return -EINVAL; 2463 2464 return 0; 2465 } 2466 2467 static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2468 { 2469 struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; 2470 2471 aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid, 2472 le16_to_cpu(cmd->st_seq_no), cmd->win_sz); 2473 2474 return 0; 2475 } 2476 2477 static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2478 { 2479 struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; 2480 2481 aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid); 2482 2483 return 0; 2484 } 2485 2486 /* AP mode functions */ 2487 2488 int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) 2489 { 2490 struct sk_buff *skb; 2491 struct wmi_connect_cmd *cm; 2492 int res; 2493 2494 skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 2495 if (!skb) 2496 return -ENOMEM; 2497 2498 cm = (struct wmi_connect_cmd *) skb->data; 2499 memcpy(cm, p, sizeof(*cm)); 2500 2501 res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID, 2502 NO_SYNC_WMIFLAG); 2503 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " 2504 "ctrl_flags=0x%x-> res=%d\n", 2505 __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), 2506 le32_to_cpu(p->ctrl_flags), res); 2507 return res; 2508 } 2509 2510 int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason) 2511 { 2512 struct sk_buff *skb; 2513 struct wmi_ap_set_mlme_cmd *cm; 2514 2515 skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 2516 if (!skb) 2517 return -ENOMEM; 2518 2519 cm = (struct wmi_ap_set_mlme_cmd *) skb->data; 2520 memcpy(cm->mac, mac, ETH_ALEN); 2521 cm->reason = cpu_to_le16(reason); 2522 cm->cmd = cmd; 2523 2524 return ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_SET_MLME_CMDID, 2525 NO_SYNC_WMIFLAG); 2526 } 2527 2528 static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len) 2529 { 2530 struct wmi_pspoll_event *ev; 2531 2532 if (len < sizeof(struct wmi_pspoll_event)) 2533 return -EINVAL; 2534 2535 ev = (struct wmi_pspoll_event *) datap; 2536 2537 ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid)); 2538 2539 return 0; 2540 } 2541 2542 static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len) 2543 { 2544 ath6kl_dtimexpiry_event(wmi->parent_dev); 2545 2546 return 0; 2547 } 2548 2549 int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag) 2550 { 2551 struct sk_buff *skb; 2552 struct wmi_ap_set_pvb_cmd *cmd; 2553 int ret; 2554 2555 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); 2556 if (!skb) 2557 return -ENOMEM; 2558 2559 cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; 2560 cmd->aid = cpu_to_le16(aid); 2561 cmd->rsvd = cpu_to_le16(0); 2562 cmd->flag = cpu_to_le32(flag); 2563 2564 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID, 2565 NO_SYNC_WMIFLAG); 2566 2567 return 0; 2568 } 2569 2570 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, 2571 bool rx_dot11_hdr, bool defrag_on_host) 2572 { 2573 struct sk_buff *skb; 2574 struct wmi_rx_frame_format_cmd *cmd; 2575 int ret; 2576 2577 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2578 if (!skb) 2579 return -ENOMEM; 2580 2581 cmd = (struct wmi_rx_frame_format_cmd *) skb->data; 2582 cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; 2583 cmd->defrag_on_host = defrag_on_host ? 1 : 0; 2584 cmd->meta_ver = rx_meta_ver; 2585 2586 /* Delete the local aggr state, on host */ 2587 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID, 2588 NO_SYNC_WMIFLAG); 2589 2590 return ret; 2591 } 2592 2593 int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, 2594 u8 ie_len) 2595 { 2596 struct sk_buff *skb; 2597 struct wmi_set_appie_cmd *p; 2598 2599 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 2600 if (!skb) 2601 return -ENOMEM; 2602 2603 ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " 2604 "ie_len=%u\n", mgmt_frm_type, ie_len); 2605 p = (struct wmi_set_appie_cmd *) skb->data; 2606 p->mgmt_frm_type = mgmt_frm_type; 2607 p->ie_len = ie_len; 2608 memcpy(p->ie_info, ie, ie_len); 2609 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID, 2610 NO_SYNC_WMIFLAG); 2611 } 2612 2613 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) 2614 { 2615 struct sk_buff *skb; 2616 struct wmi_disable_11b_rates_cmd *cmd; 2617 2618 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2619 if (!skb) 2620 return -ENOMEM; 2621 2622 ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", 2623 disable); 2624 cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; 2625 cmd->disable = disable ? 1 : 0; 2626 2627 return ath6kl_wmi_cmd_send(wmi, skb, WMI_DISABLE_11B_RATES_CMDID, 2628 NO_SYNC_WMIFLAG); 2629 } 2630 2631 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur) 2632 { 2633 struct sk_buff *skb; 2634 struct wmi_remain_on_chnl_cmd *p; 2635 2636 skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 2637 if (!skb) 2638 return -ENOMEM; 2639 2640 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", 2641 freq, dur); 2642 p = (struct wmi_remain_on_chnl_cmd *) skb->data; 2643 p->freq = cpu_to_le32(freq); 2644 p->duration = cpu_to_le32(dur); 2645 return ath6kl_wmi_cmd_send(wmi, skb, WMI_REMAIN_ON_CHNL_CMDID, 2646 NO_SYNC_WMIFLAG); 2647 } 2648 2649 int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait, 2650 const u8 *data, u16 data_len) 2651 { 2652 struct sk_buff *skb; 2653 struct wmi_send_action_cmd *p; 2654 u8 *buf; 2655 2656 if (wait) 2657 return -EINVAL; /* Offload for wait not supported */ 2658 2659 buf = kmalloc(data_len, GFP_KERNEL); 2660 if (!buf) 2661 return -ENOMEM; 2662 2663 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 2664 if (!skb) { 2665 kfree(buf); 2666 return -ENOMEM; 2667 } 2668 2669 kfree(wmi->last_mgmt_tx_frame); 2670 wmi->last_mgmt_tx_frame = buf; 2671 wmi->last_mgmt_tx_frame_len = data_len; 2672 2673 ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " 2674 "len=%u\n", id, freq, wait, data_len); 2675 p = (struct wmi_send_action_cmd *) skb->data; 2676 p->id = cpu_to_le32(id); 2677 p->freq = cpu_to_le32(freq); 2678 p->wait = cpu_to_le32(wait); 2679 p->len = cpu_to_le16(data_len); 2680 memcpy(p->data, data, data_len); 2681 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_ACTION_CMDID, 2682 NO_SYNC_WMIFLAG); 2683 } 2684 2685 int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq, 2686 const u8 *dst, 2687 const u8 *data, u16 data_len) 2688 { 2689 struct sk_buff *skb; 2690 struct wmi_p2p_probe_response_cmd *p; 2691 2692 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 2693 if (!skb) 2694 return -ENOMEM; 2695 2696 ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM " 2697 "len=%u\n", freq, dst, data_len); 2698 p = (struct wmi_p2p_probe_response_cmd *) skb->data; 2699 p->freq = cpu_to_le32(freq); 2700 memcpy(p->destination_addr, dst, ETH_ALEN); 2701 p->len = cpu_to_le16(data_len); 2702 memcpy(p->data, data, data_len); 2703 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_PROBE_RESPONSE_CMDID, 2704 NO_SYNC_WMIFLAG); 2705 } 2706 2707 int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable) 2708 { 2709 struct sk_buff *skb; 2710 struct wmi_probe_req_report_cmd *p; 2711 2712 skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 2713 if (!skb) 2714 return -ENOMEM; 2715 2716 ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", 2717 enable); 2718 p = (struct wmi_probe_req_report_cmd *) skb->data; 2719 p->enable = enable ? 1 : 0; 2720 return ath6kl_wmi_cmd_send(wmi, skb, WMI_PROBE_REQ_REPORT_CMDID, 2721 NO_SYNC_WMIFLAG); 2722 } 2723 2724 int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags) 2725 { 2726 struct sk_buff *skb; 2727 struct wmi_get_p2p_info *p; 2728 2729 skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 2730 if (!skb) 2731 return -ENOMEM; 2732 2733 ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", 2734 info_req_flags); 2735 p = (struct wmi_get_p2p_info *) skb->data; 2736 p->info_req_flags = cpu_to_le32(info_req_flags); 2737 return ath6kl_wmi_cmd_send(wmi, skb, WMI_GET_P2P_INFO_CMDID, 2738 NO_SYNC_WMIFLAG); 2739 } 2740 2741 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi) 2742 { 2743 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); 2744 return ath6kl_wmi_simple_cmd(wmi, WMI_CANCEL_REMAIN_ON_CHNL_CMDID); 2745 } 2746 2747 static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) 2748 { 2749 struct wmix_cmd_hdr *cmd; 2750 u32 len; 2751 u16 id; 2752 u8 *datap; 2753 int ret = 0; 2754 2755 if (skb->len < sizeof(struct wmix_cmd_hdr)) { 2756 ath6kl_err("bad packet 1\n"); 2757 wmi->stat.cmd_len_err++; 2758 return -EINVAL; 2759 } 2760 2761 cmd = (struct wmix_cmd_hdr *) skb->data; 2762 id = le32_to_cpu(cmd->cmd_id); 2763 2764 skb_pull(skb, sizeof(struct wmix_cmd_hdr)); 2765 2766 datap = skb->data; 2767 len = skb->len; 2768 2769 switch (id) { 2770 case WMIX_HB_CHALLENGE_RESP_EVENTID: 2771 break; 2772 case WMIX_DBGLOG_EVENTID: 2773 ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len); 2774 break; 2775 default: 2776 ath6kl_err("unknown cmd id 0x%x\n", id); 2777 wmi->stat.cmd_id_err++; 2778 ret = -EINVAL; 2779 break; 2780 } 2781 2782 return ret; 2783 } 2784 2785 /* Control Path */ 2786 int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) 2787 { 2788 struct wmi_cmd_hdr *cmd; 2789 u32 len; 2790 u16 id; 2791 u8 *datap; 2792 int ret = 0; 2793 2794 if (WARN_ON(skb == NULL)) 2795 return -EINVAL; 2796 2797 if (skb->len < sizeof(struct wmi_cmd_hdr)) { 2798 ath6kl_err("bad packet 1\n"); 2799 dev_kfree_skb(skb); 2800 wmi->stat.cmd_len_err++; 2801 return -EINVAL; 2802 } 2803 2804 cmd = (struct wmi_cmd_hdr *) skb->data; 2805 id = le16_to_cpu(cmd->cmd_id); 2806 2807 skb_pull(skb, sizeof(struct wmi_cmd_hdr)); 2808 2809 datap = skb->data; 2810 len = skb->len; 2811 2812 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: wmi id: %d\n", __func__, id); 2813 ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "msg payload ", datap, len); 2814 2815 switch (id) { 2816 case WMI_GET_BITRATE_CMDID: 2817 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); 2818 ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); 2819 break; 2820 case WMI_GET_CHANNEL_LIST_CMDID: 2821 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); 2822 ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); 2823 break; 2824 case WMI_GET_TX_PWR_CMDID: 2825 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); 2826 ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); 2827 break; 2828 case WMI_READY_EVENTID: 2829 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); 2830 ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); 2831 break; 2832 case WMI_CONNECT_EVENTID: 2833 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); 2834 ret = ath6kl_wmi_connect_event_rx(wmi, datap, len); 2835 break; 2836 case WMI_DISCONNECT_EVENTID: 2837 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); 2838 ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len); 2839 break; 2840 case WMI_PEER_NODE_EVENTID: 2841 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); 2842 ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); 2843 break; 2844 case WMI_TKIP_MICERR_EVENTID: 2845 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); 2846 ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len); 2847 break; 2848 case WMI_BSSINFO_EVENTID: 2849 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); 2850 ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len); 2851 break; 2852 case WMI_REGDOMAIN_EVENTID: 2853 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); 2854 ath6kl_wmi_regdomain_event(wmi, datap, len); 2855 break; 2856 case WMI_PSTREAM_TIMEOUT_EVENTID: 2857 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); 2858 ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); 2859 break; 2860 case WMI_NEIGHBOR_REPORT_EVENTID: 2861 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); 2862 break; 2863 case WMI_SCAN_COMPLETE_EVENTID: 2864 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); 2865 ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len); 2866 break; 2867 case WMI_CMDERROR_EVENTID: 2868 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); 2869 ret = ath6kl_wmi_error_event_rx(wmi, datap, len); 2870 break; 2871 case WMI_REPORT_STATISTICS_EVENTID: 2872 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); 2873 ret = ath6kl_wmi_stats_event_rx(wmi, datap, len); 2874 break; 2875 case WMI_RSSI_THRESHOLD_EVENTID: 2876 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); 2877 ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); 2878 break; 2879 case WMI_ERROR_REPORT_EVENTID: 2880 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); 2881 break; 2882 case WMI_OPT_RX_FRAME_EVENTID: 2883 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); 2884 /* this event has been deprecated */ 2885 break; 2886 case WMI_REPORT_ROAM_TBL_EVENTID: 2887 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); 2888 break; 2889 case WMI_EXTENSION_EVENTID: 2890 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); 2891 ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); 2892 break; 2893 case WMI_CAC_EVENTID: 2894 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); 2895 ret = ath6kl_wmi_cac_event_rx(wmi, datap, len); 2896 break; 2897 case WMI_CHANNEL_CHANGE_EVENTID: 2898 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); 2899 break; 2900 case WMI_REPORT_ROAM_DATA_EVENTID: 2901 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); 2902 break; 2903 case WMI_TEST_EVENTID: 2904 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n"); 2905 ret = ath6kl_wmi_tcmd_test_report_rx(wmi, datap, len); 2906 break; 2907 case WMI_GET_FIXRATES_CMDID: 2908 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); 2909 ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); 2910 break; 2911 case WMI_TX_RETRY_ERR_EVENTID: 2912 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); 2913 break; 2914 case WMI_SNR_THRESHOLD_EVENTID: 2915 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); 2916 ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); 2917 break; 2918 case WMI_LQ_THRESHOLD_EVENTID: 2919 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); 2920 break; 2921 case WMI_APLIST_EVENTID: 2922 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); 2923 ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); 2924 break; 2925 case WMI_GET_KEEPALIVE_CMDID: 2926 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); 2927 ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); 2928 break; 2929 case WMI_GET_WOW_LIST_EVENTID: 2930 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); 2931 ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len); 2932 break; 2933 case WMI_GET_PMKID_LIST_EVENTID: 2934 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); 2935 ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); 2936 break; 2937 case WMI_PSPOLL_EVENTID: 2938 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); 2939 ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len); 2940 break; 2941 case WMI_DTIMEXPIRY_EVENTID: 2942 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); 2943 ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len); 2944 break; 2945 case WMI_SET_PARAMS_REPLY_EVENTID: 2946 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); 2947 break; 2948 case WMI_ADDBA_REQ_EVENTID: 2949 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); 2950 ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len); 2951 break; 2952 case WMI_ADDBA_RESP_EVENTID: 2953 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); 2954 break; 2955 case WMI_DELBA_REQ_EVENTID: 2956 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); 2957 ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len); 2958 break; 2959 case WMI_REPORT_BTCOEX_CONFIG_EVENTID: 2960 ath6kl_dbg(ATH6KL_DBG_WMI, 2961 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); 2962 break; 2963 case WMI_REPORT_BTCOEX_STATS_EVENTID: 2964 ath6kl_dbg(ATH6KL_DBG_WMI, 2965 "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); 2966 break; 2967 case WMI_TX_COMPLETE_EVENTID: 2968 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); 2969 ret = ath6kl_wmi_tx_complete_event_rx(datap, len); 2970 break; 2971 case WMI_REMAIN_ON_CHNL_EVENTID: 2972 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); 2973 ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len); 2974 break; 2975 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: 2976 ath6kl_dbg(ATH6KL_DBG_WMI, 2977 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); 2978 ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, 2979 len); 2980 break; 2981 case WMI_TX_STATUS_EVENTID: 2982 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); 2983 ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len); 2984 break; 2985 case WMI_RX_PROBE_REQ_EVENTID: 2986 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); 2987 ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len); 2988 break; 2989 case WMI_P2P_CAPABILITIES_EVENTID: 2990 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); 2991 ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); 2992 break; 2993 case WMI_RX_ACTION_EVENTID: 2994 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); 2995 ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len); 2996 break; 2997 case WMI_P2P_INFO_EVENTID: 2998 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); 2999 ret = ath6kl_wmi_p2p_info_event_rx(datap, len); 3000 break; 3001 default: 3002 ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); 3003 wmi->stat.cmd_id_err++; 3004 ret = -EINVAL; 3005 break; 3006 } 3007 3008 dev_kfree_skb(skb); 3009 3010 return ret; 3011 } 3012 3013 static void ath6kl_wmi_qos_state_init(struct wmi *wmi) 3014 { 3015 if (!wmi) 3016 return; 3017 3018 spin_lock_bh(&wmi->lock); 3019 3020 wmi->fat_pipe_exist = 0; 3021 memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); 3022 3023 spin_unlock_bh(&wmi->lock); 3024 } 3025 3026 void *ath6kl_wmi_init(struct ath6kl *dev) 3027 { 3028 struct wmi *wmi; 3029 3030 wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); 3031 if (!wmi) 3032 return NULL; 3033 3034 spin_lock_init(&wmi->lock); 3035 3036 wmi->parent_dev = dev; 3037 3038 ath6kl_wmi_qos_state_init(wmi); 3039 3040 wmi->pwr_mode = REC_POWER; 3041 wmi->phy_mode = WMI_11G_MODE; 3042 3043 wmi->pair_crypto_type = NONE_CRYPT; 3044 wmi->grp_crypto_type = NONE_CRYPT; 3045 3046 wmi->ht_allowed[A_BAND_24GHZ] = 1; 3047 wmi->ht_allowed[A_BAND_5GHZ] = 1; 3048 3049 return wmi; 3050 } 3051 3052 void ath6kl_wmi_shutdown(struct wmi *wmi) 3053 { 3054 if (!wmi) 3055 return; 3056 3057 kfree(wmi->last_mgmt_tx_frame); 3058 kfree(wmi); 3059 } 3060