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