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" 20003353b0SKalle Valo #include "testmode.h" 21bdcd8170SKalle Valo 22bdcd8170SKalle Valo static int ath6kl_wmi_sync_point(struct wmi *wmi); 23bdcd8170SKalle Valo 24bdcd8170SKalle Valo static const s32 wmi_rate_tbl[][2] = { 25bdcd8170SKalle Valo /* {W/O SGI, with SGI} */ 26bdcd8170SKalle Valo {1000, 1000}, 27bdcd8170SKalle Valo {2000, 2000}, 28bdcd8170SKalle Valo {5500, 5500}, 29bdcd8170SKalle Valo {11000, 11000}, 30bdcd8170SKalle Valo {6000, 6000}, 31bdcd8170SKalle Valo {9000, 9000}, 32bdcd8170SKalle Valo {12000, 12000}, 33bdcd8170SKalle Valo {18000, 18000}, 34bdcd8170SKalle Valo {24000, 24000}, 35bdcd8170SKalle Valo {36000, 36000}, 36bdcd8170SKalle Valo {48000, 48000}, 37bdcd8170SKalle Valo {54000, 54000}, 38bdcd8170SKalle Valo {6500, 7200}, 39bdcd8170SKalle Valo {13000, 14400}, 40bdcd8170SKalle Valo {19500, 21700}, 41bdcd8170SKalle Valo {26000, 28900}, 42bdcd8170SKalle Valo {39000, 43300}, 43bdcd8170SKalle Valo {52000, 57800}, 44bdcd8170SKalle Valo {58500, 65000}, 45bdcd8170SKalle Valo {65000, 72200}, 46bdcd8170SKalle Valo {13500, 15000}, 47bdcd8170SKalle Valo {27000, 30000}, 48bdcd8170SKalle Valo {40500, 45000}, 49bdcd8170SKalle Valo {54000, 60000}, 50bdcd8170SKalle Valo {81000, 90000}, 51bdcd8170SKalle Valo {108000, 120000}, 52bdcd8170SKalle Valo {121500, 135000}, 53bdcd8170SKalle Valo {135000, 150000}, 54bdcd8170SKalle Valo {0, 0} 55bdcd8170SKalle Valo }; 56bdcd8170SKalle Valo 57bdcd8170SKalle Valo /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */ 58bdcd8170SKalle Valo static const u8 up_to_ac[] = { 59bdcd8170SKalle Valo WMM_AC_BE, 60bdcd8170SKalle Valo WMM_AC_BK, 61bdcd8170SKalle Valo WMM_AC_BK, 62bdcd8170SKalle Valo WMM_AC_BE, 63bdcd8170SKalle Valo WMM_AC_VI, 64bdcd8170SKalle Valo WMM_AC_VI, 65bdcd8170SKalle Valo WMM_AC_VO, 66bdcd8170SKalle Valo WMM_AC_VO, 67bdcd8170SKalle Valo }; 68bdcd8170SKalle Valo 69bdcd8170SKalle Valo void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id) 70bdcd8170SKalle Valo { 71bdcd8170SKalle Valo if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX)) 72bdcd8170SKalle Valo return; 73bdcd8170SKalle Valo 74bdcd8170SKalle Valo wmi->ep_id = ep_id; 75bdcd8170SKalle Valo } 76bdcd8170SKalle Valo 77bdcd8170SKalle Valo enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) 78bdcd8170SKalle Valo { 79bdcd8170SKalle Valo return wmi->ep_id; 80bdcd8170SKalle Valo } 81bdcd8170SKalle Valo 82bdcd8170SKalle Valo /* Performs DIX to 802.3 encapsulation for transmit packets. 83bdcd8170SKalle Valo * Assumes the entire DIX header is contigous and that there is 84bdcd8170SKalle Valo * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. 85bdcd8170SKalle Valo */ 86bdcd8170SKalle Valo int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) 87bdcd8170SKalle Valo { 88bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 89bdcd8170SKalle Valo struct ethhdr *eth_hdr; 90bdcd8170SKalle Valo size_t new_len; 91bdcd8170SKalle Valo __be16 type; 92bdcd8170SKalle Valo u8 *datap; 93bdcd8170SKalle Valo u16 size; 94bdcd8170SKalle Valo 95bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 96bdcd8170SKalle Valo return -EINVAL; 97bdcd8170SKalle Valo 98bdcd8170SKalle Valo size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr); 99bdcd8170SKalle Valo if (skb_headroom(skb) < size) 100bdcd8170SKalle Valo return -ENOMEM; 101bdcd8170SKalle Valo 102bdcd8170SKalle Valo eth_hdr = (struct ethhdr *) skb->data; 103bdcd8170SKalle Valo type = eth_hdr->h_proto; 104bdcd8170SKalle Valo 105bdcd8170SKalle Valo if (!is_ethertype(be16_to_cpu(type))) { 106bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 107bdcd8170SKalle Valo "%s: pkt is already in 802.3 format\n", __func__); 108bdcd8170SKalle Valo return 0; 109bdcd8170SKalle Valo } 110bdcd8170SKalle Valo 111bdcd8170SKalle Valo new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr); 112bdcd8170SKalle Valo 113bdcd8170SKalle Valo skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr)); 114bdcd8170SKalle Valo datap = skb->data; 115bdcd8170SKalle Valo 116bdcd8170SKalle Valo eth_hdr->h_proto = cpu_to_be16(new_len); 117bdcd8170SKalle Valo 118bdcd8170SKalle Valo memcpy(datap, eth_hdr, sizeof(*eth_hdr)); 119bdcd8170SKalle Valo 120bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr)); 121bdcd8170SKalle Valo llc_hdr->dsap = 0xAA; 122bdcd8170SKalle Valo llc_hdr->ssap = 0xAA; 123bdcd8170SKalle Valo llc_hdr->cntl = 0x03; 124bdcd8170SKalle Valo llc_hdr->org_code[0] = 0x0; 125bdcd8170SKalle Valo llc_hdr->org_code[1] = 0x0; 126bdcd8170SKalle Valo llc_hdr->org_code[2] = 0x0; 127bdcd8170SKalle Valo llc_hdr->eth_type = type; 128bdcd8170SKalle Valo 129bdcd8170SKalle Valo return 0; 130bdcd8170SKalle Valo } 131bdcd8170SKalle Valo 132bdcd8170SKalle Valo static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, 133bdcd8170SKalle Valo u8 *version, void *tx_meta_info) 134bdcd8170SKalle Valo { 135bdcd8170SKalle Valo struct wmi_tx_meta_v1 *v1; 136bdcd8170SKalle Valo struct wmi_tx_meta_v2 *v2; 137bdcd8170SKalle Valo 138bdcd8170SKalle Valo if (WARN_ON(skb == NULL || version == NULL)) 139bdcd8170SKalle Valo return -EINVAL; 140bdcd8170SKalle Valo 141bdcd8170SKalle Valo switch (*version) { 142bdcd8170SKalle Valo case WMI_META_VERSION_1: 143bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 144bdcd8170SKalle Valo v1 = (struct wmi_tx_meta_v1 *) skb->data; 145bdcd8170SKalle Valo v1->pkt_id = 0; 146bdcd8170SKalle Valo v1->rate_plcy_id = 0; 147bdcd8170SKalle Valo *version = WMI_META_VERSION_1; 148bdcd8170SKalle Valo break; 149bdcd8170SKalle Valo case WMI_META_VERSION_2: 150bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 151bdcd8170SKalle Valo v2 = (struct wmi_tx_meta_v2 *) skb->data; 152bdcd8170SKalle Valo memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info, 153bdcd8170SKalle Valo sizeof(struct wmi_tx_meta_v2)); 154bdcd8170SKalle Valo break; 155bdcd8170SKalle Valo } 156bdcd8170SKalle Valo 157bdcd8170SKalle Valo return 0; 158bdcd8170SKalle Valo } 159bdcd8170SKalle Valo 160bdcd8170SKalle Valo int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, 161bdcd8170SKalle Valo u8 msg_type, bool more_data, 162bdcd8170SKalle Valo enum wmi_data_hdr_data_type data_type, 163bdcd8170SKalle Valo u8 meta_ver, void *tx_meta_info) 164bdcd8170SKalle Valo { 165bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 166bdcd8170SKalle Valo int ret; 167bdcd8170SKalle Valo 168bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 169bdcd8170SKalle Valo return -EINVAL; 170bdcd8170SKalle Valo 1713ce6ff50SVasanthakumar Thiagarajan if (tx_meta_info) { 172bdcd8170SKalle Valo ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info); 173bdcd8170SKalle Valo if (ret) 174bdcd8170SKalle Valo return ret; 1753ce6ff50SVasanthakumar Thiagarajan } 176bdcd8170SKalle Valo 177bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 178bdcd8170SKalle Valo 179bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *)skb->data; 180bdcd8170SKalle Valo memset(data_hdr, 0, sizeof(struct wmi_data_hdr)); 181bdcd8170SKalle Valo 182bdcd8170SKalle Valo data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; 183bdcd8170SKalle Valo data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; 184bdcd8170SKalle Valo 185bdcd8170SKalle Valo if (more_data) 186bdcd8170SKalle Valo data_hdr->info |= 187bdcd8170SKalle Valo WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT; 188bdcd8170SKalle Valo 189bdcd8170SKalle Valo data_hdr->info2 = cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); 190bdcd8170SKalle Valo data_hdr->info3 = 0; 191bdcd8170SKalle Valo 192bdcd8170SKalle Valo return 0; 193bdcd8170SKalle Valo } 194bdcd8170SKalle Valo 195bdcd8170SKalle Valo static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) 196bdcd8170SKalle Valo { 197bdcd8170SKalle Valo struct iphdr *ip_hdr = (struct iphdr *) pkt; 198bdcd8170SKalle Valo u8 ip_pri; 199bdcd8170SKalle Valo 200bdcd8170SKalle Valo /* 201bdcd8170SKalle Valo * Determine IPTOS priority 202bdcd8170SKalle Valo * 203bdcd8170SKalle Valo * IP-TOS - 8bits 204bdcd8170SKalle Valo * : DSCP(6-bits) ECN(2-bits) 205bdcd8170SKalle Valo * : DSCP - P2 P1 P0 X X X 206bdcd8170SKalle Valo * where (P2 P1 P0) form 802.1D 207bdcd8170SKalle Valo */ 208bdcd8170SKalle Valo ip_pri = ip_hdr->tos >> 5; 209bdcd8170SKalle Valo ip_pri &= 0x7; 210bdcd8170SKalle Valo 211bdcd8170SKalle Valo if ((layer2_pri & 0x7) > ip_pri) 212bdcd8170SKalle Valo return (u8) layer2_pri & 0x7; 213bdcd8170SKalle Valo else 214bdcd8170SKalle Valo return ip_pri; 215bdcd8170SKalle Valo } 216bdcd8170SKalle Valo 217bdcd8170SKalle Valo int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, 218bdcd8170SKalle Valo u32 layer2_priority, bool wmm_enabled, 219bdcd8170SKalle Valo u8 *ac) 220bdcd8170SKalle Valo { 221bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 222bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 223bdcd8170SKalle Valo struct wmi_create_pstream_cmd cmd; 224bdcd8170SKalle Valo u32 meta_size, hdr_size; 225bdcd8170SKalle Valo u16 ip_type = IP_ETHERTYPE; 226bdcd8170SKalle Valo u8 stream_exist, usr_pri; 227bdcd8170SKalle Valo u8 traffic_class = WMM_AC_BE; 228bdcd8170SKalle Valo u8 *datap; 229bdcd8170SKalle Valo 230bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 231bdcd8170SKalle Valo return -EINVAL; 232bdcd8170SKalle Valo 233bdcd8170SKalle Valo datap = skb->data; 234bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) datap; 235bdcd8170SKalle Valo 236bdcd8170SKalle Valo meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) & 237bdcd8170SKalle Valo WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0; 238bdcd8170SKalle Valo 239bdcd8170SKalle Valo if (!wmm_enabled) { 240bdcd8170SKalle Valo /* If WMM is disabled all traffic goes as BE traffic */ 241bdcd8170SKalle Valo usr_pri = 0; 242bdcd8170SKalle Valo } else { 243bdcd8170SKalle Valo hdr_size = sizeof(struct ethhdr); 244bdcd8170SKalle Valo 245bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + 246bdcd8170SKalle Valo sizeof(struct 247bdcd8170SKalle Valo wmi_data_hdr) + 248bdcd8170SKalle Valo meta_size + hdr_size); 249bdcd8170SKalle Valo 250bdcd8170SKalle Valo if (llc_hdr->eth_type == htons(ip_type)) { 251bdcd8170SKalle Valo /* 252bdcd8170SKalle Valo * Extract the endpoint info from the TOS field 253bdcd8170SKalle Valo * in the IP header. 254bdcd8170SKalle Valo */ 255bdcd8170SKalle Valo usr_pri = 256bdcd8170SKalle Valo ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + 257bdcd8170SKalle Valo sizeof(struct ath6kl_llc_snap_hdr), 258bdcd8170SKalle Valo layer2_priority); 259bdcd8170SKalle Valo } else 260bdcd8170SKalle Valo usr_pri = layer2_priority & 0x7; 261bdcd8170SKalle Valo } 262bdcd8170SKalle Valo 263bdcd8170SKalle Valo /* workaround for WMM S5 */ 264bdcd8170SKalle Valo if ((wmi->traffic_class == WMM_AC_VI) && 265bdcd8170SKalle Valo ((usr_pri == 5) || (usr_pri == 4))) 266bdcd8170SKalle Valo usr_pri = 1; 267bdcd8170SKalle Valo 268bdcd8170SKalle Valo /* Convert user priority to traffic class */ 269bdcd8170SKalle Valo traffic_class = up_to_ac[usr_pri & 0x7]; 270bdcd8170SKalle Valo 271bdcd8170SKalle Valo wmi_data_hdr_set_up(data_hdr, usr_pri); 272bdcd8170SKalle Valo 273bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 274bdcd8170SKalle Valo stream_exist = wmi->fat_pipe_exist; 275bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 276bdcd8170SKalle Valo 277bdcd8170SKalle Valo if (!(stream_exist & (1 << traffic_class))) { 278bdcd8170SKalle Valo memset(&cmd, 0, sizeof(cmd)); 279bdcd8170SKalle Valo cmd.traffic_class = traffic_class; 280bdcd8170SKalle Valo cmd.user_pri = usr_pri; 281bdcd8170SKalle Valo cmd.inactivity_int = 282bdcd8170SKalle Valo cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); 283bdcd8170SKalle Valo /* Implicit streams are created with TSID 0xFF */ 284bdcd8170SKalle Valo cmd.tsid = WMI_IMPLICIT_PSTREAM; 285bdcd8170SKalle Valo ath6kl_wmi_create_pstream_cmd(wmi, &cmd); 286bdcd8170SKalle Valo } 287bdcd8170SKalle Valo 288bdcd8170SKalle Valo *ac = traffic_class; 289bdcd8170SKalle Valo 290bdcd8170SKalle Valo return 0; 291bdcd8170SKalle Valo } 292bdcd8170SKalle Valo 293bdcd8170SKalle Valo int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) 294bdcd8170SKalle Valo { 295bdcd8170SKalle Valo struct ieee80211_hdr_3addr *pwh, wh; 296bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 297bdcd8170SKalle Valo struct ethhdr eth_hdr; 298bdcd8170SKalle Valo u32 hdr_size; 299bdcd8170SKalle Valo u8 *datap; 300bdcd8170SKalle Valo __le16 sub_type; 301bdcd8170SKalle Valo 302bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 303bdcd8170SKalle Valo return -EINVAL; 304bdcd8170SKalle Valo 305bdcd8170SKalle Valo datap = skb->data; 306bdcd8170SKalle Valo pwh = (struct ieee80211_hdr_3addr *) datap; 307bdcd8170SKalle Valo 308bdcd8170SKalle Valo sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); 309bdcd8170SKalle Valo 310bdcd8170SKalle Valo memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); 311bdcd8170SKalle Valo 312bdcd8170SKalle Valo /* Strip off the 802.11 header */ 313bdcd8170SKalle Valo if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { 314bdcd8170SKalle Valo hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), 315bdcd8170SKalle Valo sizeof(u32)); 316bdcd8170SKalle Valo skb_pull(skb, hdr_size); 317bdcd8170SKalle Valo } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) 318bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); 319bdcd8170SKalle Valo 320bdcd8170SKalle Valo datap = skb->data; 321bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); 322bdcd8170SKalle Valo 323c8790cbaSRaja Mani memset(ð_hdr, 0, sizeof(eth_hdr)); 324bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 325bdcd8170SKalle Valo 326bdcd8170SKalle Valo switch ((le16_to_cpu(wh.frame_control)) & 327bdcd8170SKalle Valo (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 328bdcd8170SKalle Valo case 0: 329bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 330bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 331bdcd8170SKalle Valo break; 332bdcd8170SKalle Valo case IEEE80211_FCTL_TODS: 333bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); 334bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 335bdcd8170SKalle Valo break; 336bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS: 337bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 338bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); 339bdcd8170SKalle Valo break; 340bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: 341bdcd8170SKalle Valo break; 342bdcd8170SKalle Valo } 343bdcd8170SKalle Valo 344bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 345bdcd8170SKalle Valo skb_push(skb, sizeof(eth_hdr)); 346bdcd8170SKalle Valo 347bdcd8170SKalle Valo datap = skb->data; 348bdcd8170SKalle Valo 349bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 350bdcd8170SKalle Valo 351bdcd8170SKalle Valo return 0; 352bdcd8170SKalle Valo } 353bdcd8170SKalle Valo 354bdcd8170SKalle Valo /* 355bdcd8170SKalle Valo * Performs 802.3 to DIX encapsulation for received packets. 356bdcd8170SKalle Valo * Assumes the entire 802.3 header is contigous. 357bdcd8170SKalle Valo */ 358bdcd8170SKalle Valo int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) 359bdcd8170SKalle Valo { 360bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 361bdcd8170SKalle Valo struct ethhdr eth_hdr; 362bdcd8170SKalle Valo u8 *datap; 363bdcd8170SKalle Valo 364bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 365bdcd8170SKalle Valo return -EINVAL; 366bdcd8170SKalle Valo 367bdcd8170SKalle Valo datap = skb->data; 368bdcd8170SKalle Valo 369bdcd8170SKalle Valo memcpy(ð_hdr, datap, sizeof(eth_hdr)); 370bdcd8170SKalle Valo 371bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); 372bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 373bdcd8170SKalle Valo 374bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 375bdcd8170SKalle Valo datap = skb->data; 376bdcd8170SKalle Valo 377bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 378bdcd8170SKalle Valo 379bdcd8170SKalle Valo return 0; 380bdcd8170SKalle Valo } 381bdcd8170SKalle Valo 382bdcd8170SKalle Valo static void ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(struct sk_buff *skb, 383bdcd8170SKalle Valo u8 *datap) 384bdcd8170SKalle Valo { 385bdcd8170SKalle Valo struct wmi_bss_info_hdr2 bih2; 386bdcd8170SKalle Valo struct wmi_bss_info_hdr *bih; 387bdcd8170SKalle Valo 388bdcd8170SKalle Valo memcpy(&bih2, datap, sizeof(struct wmi_bss_info_hdr2)); 389bdcd8170SKalle Valo 390bdcd8170SKalle Valo skb_push(skb, 4); 391bdcd8170SKalle Valo bih = (struct wmi_bss_info_hdr *) skb->data; 392bdcd8170SKalle Valo 393bdcd8170SKalle Valo bih->ch = bih2.ch; 394bdcd8170SKalle Valo bih->frame_type = bih2.frame_type; 395bdcd8170SKalle Valo bih->snr = bih2.snr; 396bdcd8170SKalle Valo bih->rssi = a_cpu_to_sle16(bih2.snr - 95); 397bdcd8170SKalle Valo bih->ie_mask = cpu_to_le32(le16_to_cpu(bih2.ie_mask)); 398bdcd8170SKalle Valo memcpy(bih->bssid, bih2.bssid, ETH_ALEN); 399bdcd8170SKalle Valo } 400bdcd8170SKalle Valo 401bdcd8170SKalle Valo static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) 402bdcd8170SKalle Valo { 403bdcd8170SKalle Valo struct tx_complete_msg_v1 *msg_v1; 404bdcd8170SKalle Valo struct wmi_tx_complete_event *evt; 405bdcd8170SKalle Valo int index; 406bdcd8170SKalle Valo u16 size; 407bdcd8170SKalle Valo 408bdcd8170SKalle Valo evt = (struct wmi_tx_complete_event *) datap; 409bdcd8170SKalle Valo 410bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", 411bdcd8170SKalle Valo evt->num_msg, evt->msg_len, evt->msg_type); 412bdcd8170SKalle Valo 413bdcd8170SKalle Valo if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI)) 414bdcd8170SKalle Valo return 0; 415bdcd8170SKalle Valo 416bdcd8170SKalle Valo for (index = 0; index < evt->num_msg; index++) { 417bdcd8170SKalle Valo size = sizeof(struct wmi_tx_complete_event) + 418bdcd8170SKalle Valo (index * sizeof(struct tx_complete_msg_v1)); 419bdcd8170SKalle Valo msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); 420bdcd8170SKalle Valo 421bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", 422bdcd8170SKalle Valo msg_v1->status, msg_v1->pkt_id, 423bdcd8170SKalle Valo msg_v1->rate_idx, msg_v1->ack_failures); 424bdcd8170SKalle Valo } 425bdcd8170SKalle Valo 426bdcd8170SKalle Valo return 0; 427bdcd8170SKalle Valo } 428bdcd8170SKalle Valo 429f9e5f05cSJouni Malinen static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, 430f9e5f05cSJouni Malinen int len) 4316465ddcfSJouni Malinen { 4326465ddcfSJouni Malinen struct wmi_remain_on_chnl_event *ev; 4336465ddcfSJouni Malinen u32 freq; 4346465ddcfSJouni Malinen u32 dur; 435f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 436f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4376465ddcfSJouni Malinen 4386465ddcfSJouni Malinen if (len < sizeof(*ev)) 4396465ddcfSJouni Malinen return -EINVAL; 4406465ddcfSJouni Malinen 4416465ddcfSJouni Malinen ev = (struct wmi_remain_on_chnl_event *) datap; 4426465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4436465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4446465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", 4456465ddcfSJouni Malinen freq, dur); 446f9e5f05cSJouni Malinen chan = ieee80211_get_channel(ar->wdev->wiphy, freq); 447f9e5f05cSJouni Malinen if (!chan) { 448f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " 449f9e5f05cSJouni Malinen "(freq=%u)\n", freq); 450f9e5f05cSJouni Malinen return -EINVAL; 451f9e5f05cSJouni Malinen } 452f9e5f05cSJouni Malinen cfg80211_ready_on_channel(ar->net_dev, 1, chan, NL80211_CHAN_NO_HT, 453f9e5f05cSJouni Malinen dur, GFP_ATOMIC); 4546465ddcfSJouni Malinen 4556465ddcfSJouni Malinen return 0; 4566465ddcfSJouni Malinen } 4576465ddcfSJouni Malinen 458f9e5f05cSJouni Malinen static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, 459f9e5f05cSJouni Malinen u8 *datap, int len) 4606465ddcfSJouni Malinen { 4616465ddcfSJouni Malinen struct wmi_cancel_remain_on_chnl_event *ev; 4626465ddcfSJouni Malinen u32 freq; 4636465ddcfSJouni Malinen u32 dur; 464f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 465f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4666465ddcfSJouni Malinen 4676465ddcfSJouni Malinen if (len < sizeof(*ev)) 4686465ddcfSJouni Malinen return -EINVAL; 4696465ddcfSJouni Malinen 4706465ddcfSJouni Malinen ev = (struct wmi_cancel_remain_on_chnl_event *) datap; 4716465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4726465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4736465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " 4746465ddcfSJouni Malinen "status=%u\n", freq, dur, ev->status); 475f9e5f05cSJouni Malinen chan = ieee80211_get_channel(ar->wdev->wiphy, freq); 476f9e5f05cSJouni Malinen if (!chan) { 477f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " 478f9e5f05cSJouni Malinen "channel (freq=%u)\n", freq); 479f9e5f05cSJouni Malinen return -EINVAL; 480f9e5f05cSJouni Malinen } 481f9e5f05cSJouni Malinen cfg80211_remain_on_channel_expired(ar->net_dev, 1, chan, 482f9e5f05cSJouni Malinen NL80211_CHAN_NO_HT, GFP_ATOMIC); 4836465ddcfSJouni Malinen 4846465ddcfSJouni Malinen return 0; 4856465ddcfSJouni Malinen } 4866465ddcfSJouni Malinen 487a0df5db1SJouni Malinen static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len) 4886465ddcfSJouni Malinen { 4896465ddcfSJouni Malinen struct wmi_tx_status_event *ev; 4906465ddcfSJouni Malinen u32 id; 491a0df5db1SJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4926465ddcfSJouni Malinen 4936465ddcfSJouni Malinen if (len < sizeof(*ev)) 4946465ddcfSJouni Malinen return -EINVAL; 4956465ddcfSJouni Malinen 4966465ddcfSJouni Malinen ev = (struct wmi_tx_status_event *) datap; 4976465ddcfSJouni Malinen id = le32_to_cpu(ev->id); 4986465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", 4996465ddcfSJouni Malinen id, ev->ack_status); 500a0df5db1SJouni Malinen if (wmi->last_mgmt_tx_frame) { 501a0df5db1SJouni Malinen cfg80211_mgmt_tx_status(ar->net_dev, id, 502a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame, 503a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len, 504a0df5db1SJouni Malinen !!ev->ack_status, GFP_ATOMIC); 505a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 506a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = NULL; 507a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = 0; 508a0df5db1SJouni Malinen } 5096465ddcfSJouni Malinen 5106465ddcfSJouni Malinen return 0; 5116465ddcfSJouni Malinen } 5126465ddcfSJouni Malinen 513ae32c30aSJouni Malinen static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) 5146465ddcfSJouni Malinen { 5156465ddcfSJouni Malinen struct wmi_p2p_rx_probe_req_event *ev; 516ae32c30aSJouni Malinen u32 freq; 5176465ddcfSJouni Malinen u16 dlen; 518ae32c30aSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 5196465ddcfSJouni Malinen 5206465ddcfSJouni Malinen if (len < sizeof(*ev)) 5216465ddcfSJouni Malinen return -EINVAL; 5226465ddcfSJouni Malinen 5236465ddcfSJouni Malinen ev = (struct wmi_p2p_rx_probe_req_event *) datap; 524ae32c30aSJouni Malinen freq = le32_to_cpu(ev->freq); 5256465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 526ae32c30aSJouni Malinen if (datap + len < ev->data + dlen) { 527ae32c30aSJouni Malinen ath6kl_err("invalid wmi_p2p_rx_probe_req_event: " 528ae32c30aSJouni Malinen "len=%d dlen=%u\n", len, dlen); 529ae32c30aSJouni Malinen return -EINVAL; 530ae32c30aSJouni Malinen } 531ae32c30aSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u " 532ae32c30aSJouni Malinen "probe_req_report=%d\n", 533ae32c30aSJouni Malinen dlen, freq, ar->probe_req_report); 534ae32c30aSJouni Malinen 535ae32c30aSJouni Malinen if (ar->probe_req_report || ar->nw_type == AP_NETWORK) 536ae32c30aSJouni Malinen cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); 5376465ddcfSJouni Malinen 5386465ddcfSJouni Malinen return 0; 5396465ddcfSJouni Malinen } 5406465ddcfSJouni Malinen 5416465ddcfSJouni Malinen static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) 5426465ddcfSJouni Malinen { 5436465ddcfSJouni Malinen struct wmi_p2p_capabilities_event *ev; 5446465ddcfSJouni Malinen u16 dlen; 5456465ddcfSJouni Malinen 5466465ddcfSJouni Malinen if (len < sizeof(*ev)) 5476465ddcfSJouni Malinen return -EINVAL; 5486465ddcfSJouni Malinen 5496465ddcfSJouni Malinen ev = (struct wmi_p2p_capabilities_event *) datap; 5506465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5516465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); 5526465ddcfSJouni Malinen 5536465ddcfSJouni Malinen return 0; 5546465ddcfSJouni Malinen } 5556465ddcfSJouni Malinen 5569809d8efSJouni Malinen static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len) 5576465ddcfSJouni Malinen { 5586465ddcfSJouni Malinen struct wmi_rx_action_event *ev; 5599809d8efSJouni Malinen u32 freq; 5606465ddcfSJouni Malinen u16 dlen; 5619809d8efSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 5626465ddcfSJouni Malinen 5636465ddcfSJouni Malinen if (len < sizeof(*ev)) 5646465ddcfSJouni Malinen return -EINVAL; 5656465ddcfSJouni Malinen 5666465ddcfSJouni Malinen ev = (struct wmi_rx_action_event *) datap; 5679809d8efSJouni Malinen freq = le32_to_cpu(ev->freq); 5686465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5699809d8efSJouni Malinen if (datap + len < ev->data + dlen) { 5709809d8efSJouni Malinen ath6kl_err("invalid wmi_rx_action_event: " 5719809d8efSJouni Malinen "len=%d dlen=%u\n", len, dlen); 5729809d8efSJouni Malinen return -EINVAL; 5739809d8efSJouni Malinen } 5749809d8efSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); 5759809d8efSJouni Malinen cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); 5766465ddcfSJouni Malinen 5776465ddcfSJouni Malinen return 0; 5786465ddcfSJouni Malinen } 5796465ddcfSJouni Malinen 5806465ddcfSJouni Malinen static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) 5816465ddcfSJouni Malinen { 5826465ddcfSJouni Malinen struct wmi_p2p_info_event *ev; 5836465ddcfSJouni Malinen u32 flags; 5846465ddcfSJouni Malinen u16 dlen; 5856465ddcfSJouni Malinen 5866465ddcfSJouni Malinen if (len < sizeof(*ev)) 5876465ddcfSJouni Malinen return -EINVAL; 5886465ddcfSJouni Malinen 5896465ddcfSJouni Malinen ev = (struct wmi_p2p_info_event *) datap; 5906465ddcfSJouni Malinen flags = le32_to_cpu(ev->info_req_flags); 5916465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5926465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); 5936465ddcfSJouni Malinen 5946465ddcfSJouni Malinen if (flags & P2P_FLAG_CAPABILITIES_REQ) { 5956465ddcfSJouni Malinen struct wmi_p2p_capabilities *cap; 5966465ddcfSJouni Malinen if (dlen < sizeof(*cap)) 5976465ddcfSJouni Malinen return -EINVAL; 5986465ddcfSJouni Malinen cap = (struct wmi_p2p_capabilities *) ev->data; 5996465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", 6006465ddcfSJouni Malinen cap->go_power_save); 6016465ddcfSJouni Malinen } 6026465ddcfSJouni Malinen 6036465ddcfSJouni Malinen if (flags & P2P_FLAG_MACADDR_REQ) { 6046465ddcfSJouni Malinen struct wmi_p2p_macaddr *mac; 6056465ddcfSJouni Malinen if (dlen < sizeof(*mac)) 6066465ddcfSJouni Malinen return -EINVAL; 6076465ddcfSJouni Malinen mac = (struct wmi_p2p_macaddr *) ev->data; 6086465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", 6096465ddcfSJouni Malinen mac->mac_addr); 6106465ddcfSJouni Malinen } 6116465ddcfSJouni Malinen 6126465ddcfSJouni Malinen if (flags & P2P_FLAG_HMODEL_REQ) { 6136465ddcfSJouni Malinen struct wmi_p2p_hmodel *mod; 6146465ddcfSJouni Malinen if (dlen < sizeof(*mod)) 6156465ddcfSJouni Malinen return -EINVAL; 6166465ddcfSJouni Malinen mod = (struct wmi_p2p_hmodel *) ev->data; 6176465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", 6186465ddcfSJouni Malinen mod->p2p_model, 6196465ddcfSJouni Malinen mod->p2p_model ? "host" : "firmware"); 6206465ddcfSJouni Malinen } 6216465ddcfSJouni Malinen return 0; 6226465ddcfSJouni Malinen } 6236465ddcfSJouni Malinen 624bdcd8170SKalle Valo static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) 625bdcd8170SKalle Valo { 626bdcd8170SKalle Valo struct sk_buff *skb; 627bdcd8170SKalle Valo 628bdcd8170SKalle Valo skb = ath6kl_buf_alloc(size); 629bdcd8170SKalle Valo if (!skb) 630bdcd8170SKalle Valo return NULL; 631bdcd8170SKalle Valo 632bdcd8170SKalle Valo skb_put(skb, size); 633bdcd8170SKalle Valo if (size) 634bdcd8170SKalle Valo memset(skb->data, 0, size); 635bdcd8170SKalle Valo 636bdcd8170SKalle Valo return skb; 637bdcd8170SKalle Valo } 638bdcd8170SKalle Valo 639bdcd8170SKalle Valo /* Send a "simple" wmi command -- one with no arguments */ 640bdcd8170SKalle Valo static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id) 641bdcd8170SKalle Valo { 642bdcd8170SKalle Valo struct sk_buff *skb; 643bdcd8170SKalle Valo int ret; 644bdcd8170SKalle Valo 645bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(0); 646bdcd8170SKalle Valo if (!skb) 647bdcd8170SKalle Valo return -ENOMEM; 648bdcd8170SKalle Valo 649bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG); 650bdcd8170SKalle Valo 651bdcd8170SKalle Valo return ret; 652bdcd8170SKalle Valo } 653bdcd8170SKalle Valo 654bdcd8170SKalle Valo static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) 655bdcd8170SKalle Valo { 656bdcd8170SKalle Valo struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; 657bdcd8170SKalle Valo 658bdcd8170SKalle Valo if (len < sizeof(struct wmi_ready_event_2)) 659bdcd8170SKalle Valo return -EINVAL; 660bdcd8170SKalle Valo 661bdcd8170SKalle Valo wmi->ready = true; 662bdcd8170SKalle Valo ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, 663bdcd8170SKalle Valo le32_to_cpu(ev->sw_version), 664bdcd8170SKalle Valo le32_to_cpu(ev->abi_version)); 665bdcd8170SKalle Valo 666bdcd8170SKalle Valo return 0; 667bdcd8170SKalle Valo } 668bdcd8170SKalle Valo 669*e5090444SVivek Natarajan /* 670*e5090444SVivek Natarajan * Mechanism to modify the roaming behavior in the firmware. The lower rssi 671*e5090444SVivek Natarajan * at which the station has to roam can be passed with 672*e5090444SVivek Natarajan * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level 673*e5090444SVivek Natarajan * in dBm. 674*e5090444SVivek Natarajan */ 675*e5090444SVivek Natarajan int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) 676*e5090444SVivek Natarajan { 677*e5090444SVivek Natarajan struct sk_buff *skb; 678*e5090444SVivek Natarajan struct roam_ctrl_cmd *cmd; 679*e5090444SVivek Natarajan 680*e5090444SVivek Natarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 681*e5090444SVivek Natarajan if (!skb) 682*e5090444SVivek Natarajan return -ENOMEM; 683*e5090444SVivek Natarajan 684*e5090444SVivek Natarajan cmd = (struct roam_ctrl_cmd *) skb->data; 685*e5090444SVivek Natarajan 686*e5090444SVivek Natarajan cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD); 687*e5090444SVivek Natarajan cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi + 688*e5090444SVivek Natarajan DEF_SCAN_FOR_ROAM_INTVL); 689*e5090444SVivek Natarajan cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi); 690*e5090444SVivek Natarajan cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; 691*e5090444SVivek Natarajan cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; 692*e5090444SVivek Natarajan 693*e5090444SVivek Natarajan ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, NO_SYNC_WMIFLAG); 694*e5090444SVivek Natarajan 695*e5090444SVivek Natarajan return 0; 696*e5090444SVivek Natarajan } 697*e5090444SVivek Natarajan 698bdcd8170SKalle Valo static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) 699bdcd8170SKalle Valo { 700bdcd8170SKalle Valo struct wmi_connect_event *ev; 701bdcd8170SKalle Valo u8 *pie, *peie; 702bdcd8170SKalle Valo 703bdcd8170SKalle Valo if (len < sizeof(struct wmi_connect_event)) 704bdcd8170SKalle Valo return -EINVAL; 705bdcd8170SKalle Valo 706bdcd8170SKalle Valo ev = (struct wmi_connect_event *) datap; 707bdcd8170SKalle Valo 708bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM\n", 709bdcd8170SKalle Valo __func__, ev->ch, ev->bssid); 710bdcd8170SKalle Valo 711bdcd8170SKalle Valo /* Start of assoc rsp IEs */ 712bdcd8170SKalle Valo pie = ev->assoc_info + ev->beacon_ie_len + 713bdcd8170SKalle Valo ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ 714bdcd8170SKalle Valo 715bdcd8170SKalle Valo /* End of assoc rsp IEs */ 716bdcd8170SKalle Valo peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + 717bdcd8170SKalle Valo ev->assoc_resp_len; 718bdcd8170SKalle Valo 719bdcd8170SKalle Valo while (pie < peie) { 720bdcd8170SKalle Valo switch (*pie) { 721bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 722bdcd8170SKalle Valo if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && 723bdcd8170SKalle Valo pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { 724bdcd8170SKalle Valo /* WMM OUT (00:50:F2) */ 725bdcd8170SKalle Valo if (pie[1] > 5 726bdcd8170SKalle Valo && pie[6] == WMM_PARAM_OUI_SUBTYPE) 727bdcd8170SKalle Valo wmi->is_wmm_enabled = true; 728bdcd8170SKalle Valo } 729bdcd8170SKalle Valo break; 730bdcd8170SKalle Valo } 731bdcd8170SKalle Valo 732bdcd8170SKalle Valo if (wmi->is_wmm_enabled) 733bdcd8170SKalle Valo break; 734bdcd8170SKalle Valo 735bdcd8170SKalle Valo pie += pie[1] + 2; 736bdcd8170SKalle Valo } 737bdcd8170SKalle Valo 738bdcd8170SKalle Valo ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->ch), ev->bssid, 739bdcd8170SKalle Valo le16_to_cpu(ev->listen_intvl), 740bdcd8170SKalle Valo le16_to_cpu(ev->beacon_intvl), 741bdcd8170SKalle Valo le32_to_cpu(ev->nw_type), 742bdcd8170SKalle Valo ev->beacon_ie_len, ev->assoc_req_len, 743bdcd8170SKalle Valo ev->assoc_resp_len, ev->assoc_info); 744bdcd8170SKalle Valo 745bdcd8170SKalle Valo return 0; 746bdcd8170SKalle Valo } 747bdcd8170SKalle Valo 748bdcd8170SKalle Valo static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) 749bdcd8170SKalle Valo { 750bdcd8170SKalle Valo struct wmi_disconnect_event *ev; 751bdcd8170SKalle Valo wmi->traffic_class = 100; 752bdcd8170SKalle Valo 753bdcd8170SKalle Valo if (len < sizeof(struct wmi_disconnect_event)) 754bdcd8170SKalle Valo return -EINVAL; 755bdcd8170SKalle Valo 756bdcd8170SKalle Valo ev = (struct wmi_disconnect_event *) datap; 757bdcd8170SKalle Valo 758bdcd8170SKalle Valo wmi->is_wmm_enabled = false; 759bdcd8170SKalle Valo wmi->pair_crypto_type = NONE_CRYPT; 760bdcd8170SKalle Valo wmi->grp_crypto_type = NONE_CRYPT; 761bdcd8170SKalle Valo 762bdcd8170SKalle Valo ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason, 763bdcd8170SKalle Valo ev->bssid, ev->assoc_resp_len, ev->assoc_info, 764bdcd8170SKalle Valo le16_to_cpu(ev->proto_reason_status)); 765bdcd8170SKalle Valo 766bdcd8170SKalle Valo return 0; 767bdcd8170SKalle Valo } 768bdcd8170SKalle Valo 769bdcd8170SKalle Valo static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) 770bdcd8170SKalle Valo { 771bdcd8170SKalle Valo struct wmi_peer_node_event *ev; 772bdcd8170SKalle Valo 773bdcd8170SKalle Valo if (len < sizeof(struct wmi_peer_node_event)) 774bdcd8170SKalle Valo return -EINVAL; 775bdcd8170SKalle Valo 776bdcd8170SKalle Valo ev = (struct wmi_peer_node_event *) datap; 777bdcd8170SKalle Valo 778bdcd8170SKalle Valo if (ev->event_code == PEER_NODE_JOIN_EVENT) 779bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", 780bdcd8170SKalle Valo ev->peer_mac_addr); 781bdcd8170SKalle Valo else if (ev->event_code == PEER_NODE_LEAVE_EVENT) 782bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", 783bdcd8170SKalle Valo ev->peer_mac_addr); 784bdcd8170SKalle Valo 785bdcd8170SKalle Valo return 0; 786bdcd8170SKalle Valo } 787bdcd8170SKalle Valo 788bdcd8170SKalle Valo static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len) 789bdcd8170SKalle Valo { 790bdcd8170SKalle Valo struct wmi_tkip_micerr_event *ev; 791bdcd8170SKalle Valo 792bdcd8170SKalle Valo if (len < sizeof(struct wmi_tkip_micerr_event)) 793bdcd8170SKalle Valo return -EINVAL; 794bdcd8170SKalle Valo 795bdcd8170SKalle Valo ev = (struct wmi_tkip_micerr_event *) datap; 796bdcd8170SKalle Valo 797bdcd8170SKalle Valo ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast); 798bdcd8170SKalle Valo 799bdcd8170SKalle Valo return 0; 800bdcd8170SKalle Valo } 801bdcd8170SKalle Valo 802bdcd8170SKalle Valo static int ath6kl_wlan_parse_beacon(u8 *buf, int frame_len, 803bdcd8170SKalle Valo struct ath6kl_common_ie *cie) 804bdcd8170SKalle Valo { 805bdcd8170SKalle Valo u8 *frm, *efrm; 806bdcd8170SKalle Valo u8 elemid_ssid = false; 807bdcd8170SKalle Valo 808bdcd8170SKalle Valo frm = buf; 809bdcd8170SKalle Valo efrm = (u8 *) (frm + frame_len); 810bdcd8170SKalle Valo 811bdcd8170SKalle Valo /* 812bdcd8170SKalle Valo * beacon/probe response frame format 813bdcd8170SKalle Valo * [8] time stamp 814bdcd8170SKalle Valo * [2] beacon interval 815bdcd8170SKalle Valo * [2] capability information 816bdcd8170SKalle Valo * [tlv] ssid 817bdcd8170SKalle Valo * [tlv] supported rates 818bdcd8170SKalle Valo * [tlv] country information 819bdcd8170SKalle Valo * [tlv] parameter set (FH/DS) 820bdcd8170SKalle Valo * [tlv] erp information 821bdcd8170SKalle Valo * [tlv] extended supported rates 822bdcd8170SKalle Valo * [tlv] WMM 823bdcd8170SKalle Valo * [tlv] WPA or RSN 824bdcd8170SKalle Valo * [tlv] Atheros Advanced Capabilities 825bdcd8170SKalle Valo */ 826bdcd8170SKalle Valo if ((efrm - frm) < 12) 827bdcd8170SKalle Valo return -EINVAL; 828bdcd8170SKalle Valo 829bdcd8170SKalle Valo memset(cie, 0, sizeof(*cie)); 830bdcd8170SKalle Valo 831bdcd8170SKalle Valo cie->ie_tstamp = frm; 832bdcd8170SKalle Valo frm += 8; 833bdcd8170SKalle Valo cie->ie_beaconInt = *(u16 *) frm; 834bdcd8170SKalle Valo frm += 2; 835bdcd8170SKalle Valo cie->ie_capInfo = *(u16 *) frm; 836bdcd8170SKalle Valo frm += 2; 837bdcd8170SKalle Valo cie->ie_chan = 0; 838bdcd8170SKalle Valo 839bdcd8170SKalle Valo while (frm < efrm) { 840bdcd8170SKalle Valo switch (*frm) { 841bdcd8170SKalle Valo case WLAN_EID_SSID: 842bdcd8170SKalle Valo if (!elemid_ssid) { 843bdcd8170SKalle Valo cie->ie_ssid = frm; 844bdcd8170SKalle Valo elemid_ssid = true; 845bdcd8170SKalle Valo } 846bdcd8170SKalle Valo break; 847bdcd8170SKalle Valo case WLAN_EID_SUPP_RATES: 848bdcd8170SKalle Valo cie->ie_rates = frm; 849bdcd8170SKalle Valo break; 850bdcd8170SKalle Valo case WLAN_EID_COUNTRY: 851bdcd8170SKalle Valo cie->ie_country = frm; 852bdcd8170SKalle Valo break; 853bdcd8170SKalle Valo case WLAN_EID_FH_PARAMS: 854bdcd8170SKalle Valo break; 855bdcd8170SKalle Valo case WLAN_EID_DS_PARAMS: 856bdcd8170SKalle Valo cie->ie_chan = frm[2]; 857bdcd8170SKalle Valo break; 858bdcd8170SKalle Valo case WLAN_EID_TIM: 859bdcd8170SKalle Valo cie->ie_tim = frm; 860bdcd8170SKalle Valo break; 861bdcd8170SKalle Valo case WLAN_EID_IBSS_PARAMS: 862bdcd8170SKalle Valo break; 863bdcd8170SKalle Valo case WLAN_EID_EXT_SUPP_RATES: 864bdcd8170SKalle Valo cie->ie_xrates = frm; 865bdcd8170SKalle Valo break; 866bdcd8170SKalle Valo case WLAN_EID_ERP_INFO: 867bdcd8170SKalle Valo if (frm[1] != 1) 868bdcd8170SKalle Valo return -EINVAL; 869bdcd8170SKalle Valo 870bdcd8170SKalle Valo cie->ie_erp = frm[2]; 871bdcd8170SKalle Valo break; 872bdcd8170SKalle Valo case WLAN_EID_RSN: 873bdcd8170SKalle Valo cie->ie_rsn = frm; 874bdcd8170SKalle Valo break; 875bdcd8170SKalle Valo case WLAN_EID_HT_CAPABILITY: 876bdcd8170SKalle Valo cie->ie_htcap = frm; 877bdcd8170SKalle Valo break; 878bdcd8170SKalle Valo case WLAN_EID_HT_INFORMATION: 879bdcd8170SKalle Valo cie->ie_htop = frm; 880bdcd8170SKalle Valo break; 881bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 882bdcd8170SKalle Valo if (frm[1] > 3 && frm[2] == 0x00 && frm[3] == 0x50 && 883bdcd8170SKalle Valo frm[4] == 0xf2) { 884bdcd8170SKalle Valo /* OUT Type (00:50:F2) */ 885bdcd8170SKalle Valo 886bdcd8170SKalle Valo if (frm[5] == WPA_OUI_TYPE) { 887bdcd8170SKalle Valo /* WPA OUT */ 888bdcd8170SKalle Valo cie->ie_wpa = frm; 889bdcd8170SKalle Valo } else if (frm[5] == WMM_OUI_TYPE) { 890bdcd8170SKalle Valo /* WMM OUT */ 891bdcd8170SKalle Valo cie->ie_wmm = frm; 892bdcd8170SKalle Valo } else if (frm[5] == WSC_OUT_TYPE) { 893bdcd8170SKalle Valo /* WSC OUT */ 894bdcd8170SKalle Valo cie->ie_wsc = frm; 895bdcd8170SKalle Valo } 896bdcd8170SKalle Valo 897bdcd8170SKalle Valo } else if (frm[1] > 3 && frm[2] == 0x00 898bdcd8170SKalle Valo && frm[3] == 0x03 && frm[4] == 0x7f 899bdcd8170SKalle Valo && frm[5] == ATH_OUI_TYPE) { 900bdcd8170SKalle Valo /* Atheros OUI (00:03:7f) */ 901bdcd8170SKalle Valo cie->ie_ath = frm; 902bdcd8170SKalle Valo } 903bdcd8170SKalle Valo break; 904bdcd8170SKalle Valo default: 905bdcd8170SKalle Valo break; 906bdcd8170SKalle Valo } 907bdcd8170SKalle Valo frm += frm[1] + 2; 908bdcd8170SKalle Valo } 909bdcd8170SKalle Valo 910bdcd8170SKalle Valo if ((cie->ie_rates == NULL) 911bdcd8170SKalle Valo || (cie->ie_rates[1] > ATH6KL_RATE_MAXSIZE)) 912bdcd8170SKalle Valo return -EINVAL; 913bdcd8170SKalle Valo 914bdcd8170SKalle Valo if ((cie->ie_ssid == NULL) 915bdcd8170SKalle Valo || (cie->ie_ssid[1] > IEEE80211_MAX_SSID_LEN)) 916bdcd8170SKalle Valo return -EINVAL; 917bdcd8170SKalle Valo 918bdcd8170SKalle Valo return 0; 919bdcd8170SKalle Valo } 920bdcd8170SKalle Valo 921bdcd8170SKalle Valo static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) 922bdcd8170SKalle Valo { 923bdcd8170SKalle Valo struct bss *bss = NULL; 924bdcd8170SKalle Valo struct wmi_bss_info_hdr *bih; 925bdcd8170SKalle Valo u8 cached_ssid_len = 0; 926bdcd8170SKalle Valo u8 cached_ssid[IEEE80211_MAX_SSID_LEN] = { 0 }; 927bdcd8170SKalle Valo u8 beacon_ssid_len = 0; 928bdcd8170SKalle Valo u8 *buf, *ie_ssid; 929bdcd8170SKalle Valo u8 *ni_buf; 930bdcd8170SKalle Valo int buf_len; 931bdcd8170SKalle Valo 932bdcd8170SKalle Valo int ret; 933bdcd8170SKalle Valo 934bdcd8170SKalle Valo if (len <= sizeof(struct wmi_bss_info_hdr)) 935bdcd8170SKalle Valo return -EINVAL; 936bdcd8170SKalle Valo 937bdcd8170SKalle Valo bih = (struct wmi_bss_info_hdr *) datap; 9387c3075e9SVasanthakumar Thiagarajan bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid); 939bdcd8170SKalle Valo 940bdcd8170SKalle Valo if (a_sle16_to_cpu(bih->rssi) > 0) { 941bdcd8170SKalle Valo if (bss == NULL) 942bdcd8170SKalle Valo return 0; 943bdcd8170SKalle Valo else 944bdcd8170SKalle Valo bih->rssi = a_cpu_to_sle16(bss->ni_rssi); 945bdcd8170SKalle Valo } 946bdcd8170SKalle Valo 947bdcd8170SKalle Valo buf = datap + sizeof(struct wmi_bss_info_hdr); 948bdcd8170SKalle Valo len -= sizeof(struct wmi_bss_info_hdr); 949bdcd8170SKalle Valo 950bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 951bdcd8170SKalle Valo "bss info evt - ch %u, rssi %02x, bssid \"%pM\"\n", 952bdcd8170SKalle Valo bih->ch, a_sle16_to_cpu(bih->rssi), bih->bssid); 953bdcd8170SKalle Valo 954bdcd8170SKalle Valo if (bss != NULL) { 955bdcd8170SKalle Valo /* 956bdcd8170SKalle Valo * Free up the node. We are about to allocate a new node. 957bdcd8170SKalle Valo * In case of hidden AP, beacon will not have ssid, 958bdcd8170SKalle Valo * but a directed probe response will have it, 959bdcd8170SKalle Valo * so cache the probe-resp-ssid if already present. 960bdcd8170SKalle Valo */ 961bdcd8170SKalle Valo if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE)) { 962bdcd8170SKalle Valo ie_ssid = bss->ni_cie.ie_ssid; 963bdcd8170SKalle Valo if (ie_ssid && (ie_ssid[1] <= IEEE80211_MAX_SSID_LEN) && 964bdcd8170SKalle Valo (ie_ssid[2] != 0)) { 965bdcd8170SKalle Valo cached_ssid_len = ie_ssid[1]; 966bdcd8170SKalle Valo memcpy(cached_ssid, ie_ssid + 2, 967bdcd8170SKalle Valo cached_ssid_len); 968bdcd8170SKalle Valo } 969bdcd8170SKalle Valo } 970bdcd8170SKalle Valo 971bdcd8170SKalle Valo /* 972bdcd8170SKalle Valo * Use the current average rssi of associated AP base on 973bdcd8170SKalle Valo * assumption 974bdcd8170SKalle Valo * 1. Most os with GUI will update RSSI by 975bdcd8170SKalle Valo * ath6kl_wmi_get_stats_cmd() periodically. 976bdcd8170SKalle Valo * 2. ath6kl_wmi_get_stats_cmd(..) will be called when calling 977bdcd8170SKalle Valo * ath6kl_wmi_startscan_cmd(...) 978bdcd8170SKalle Valo * The average value of RSSI give end-user better feeling for 979bdcd8170SKalle Valo * instance value of scan result. It also sync up RSSI info 980bdcd8170SKalle Valo * in GUI between scan result and RSSI signal icon. 981bdcd8170SKalle Valo */ 98270df0516SVasanthakumar Thiagarajan if (memcmp(wmi->parent_dev->bssid, bih->bssid, ETH_ALEN) == 0) { 983bdcd8170SKalle Valo bih->rssi = a_cpu_to_sle16(bss->ni_rssi); 984bdcd8170SKalle Valo bih->snr = bss->ni_snr; 985bdcd8170SKalle Valo } 986bdcd8170SKalle Valo 9877c3075e9SVasanthakumar Thiagarajan wlan_node_reclaim(&wmi->parent_dev->scan_table, bss); 988bdcd8170SKalle Valo } 989bdcd8170SKalle Valo 990bdcd8170SKalle Valo /* 991bdcd8170SKalle Valo * beacon/probe response frame format 992bdcd8170SKalle Valo * [8] time stamp 993bdcd8170SKalle Valo * [2] beacon interval 994bdcd8170SKalle Valo * [2] capability information 995bdcd8170SKalle Valo * [tlv] ssid 996bdcd8170SKalle Valo */ 997bdcd8170SKalle Valo beacon_ssid_len = buf[SSID_IE_LEN_INDEX]; 998bdcd8170SKalle Valo 999bdcd8170SKalle Valo /* 1000bdcd8170SKalle Valo * If ssid is cached for this hidden AP, then change 1001bdcd8170SKalle Valo * buffer len accordingly. 1002bdcd8170SKalle Valo */ 1003bdcd8170SKalle Valo if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && 1004bdcd8170SKalle Valo (cached_ssid_len != 0) && 1005bdcd8170SKalle Valo (beacon_ssid_len == 0 || (cached_ssid_len > beacon_ssid_len && 1006bdcd8170SKalle Valo buf[SSID_IE_LEN_INDEX + 1] == 0))) { 1007bdcd8170SKalle Valo 1008bdcd8170SKalle Valo len += (cached_ssid_len - beacon_ssid_len); 1009bdcd8170SKalle Valo } 1010bdcd8170SKalle Valo 1011bdcd8170SKalle Valo bss = wlan_node_alloc(len); 1012bdcd8170SKalle Valo if (!bss) 1013bdcd8170SKalle Valo return -ENOMEM; 1014bdcd8170SKalle Valo 1015bdcd8170SKalle Valo bss->ni_snr = bih->snr; 1016bdcd8170SKalle Valo bss->ni_rssi = a_sle16_to_cpu(bih->rssi); 1017bdcd8170SKalle Valo 1018bdcd8170SKalle Valo if (WARN_ON(!bss->ni_buf)) 1019bdcd8170SKalle Valo return -EINVAL; 1020bdcd8170SKalle Valo 1021bdcd8170SKalle Valo /* 1022bdcd8170SKalle Valo * In case of hidden AP, beacon will not have ssid, 1023bdcd8170SKalle Valo * but a directed probe response will have it, 1024bdcd8170SKalle Valo * so place the cached-ssid(probe-resp) in the bss info. 1025bdcd8170SKalle Valo */ 1026bdcd8170SKalle Valo if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && 1027bdcd8170SKalle Valo (cached_ssid_len != 0) && 1028bdcd8170SKalle Valo (beacon_ssid_len == 0 || (beacon_ssid_len && 1029bdcd8170SKalle Valo buf[SSID_IE_LEN_INDEX + 1] == 0))) { 1030bdcd8170SKalle Valo ni_buf = bss->ni_buf; 1031bdcd8170SKalle Valo buf_len = len; 1032bdcd8170SKalle Valo 1033bdcd8170SKalle Valo /* 1034bdcd8170SKalle Valo * Copy the first 14 bytes: 1035bdcd8170SKalle Valo * time-stamp(8), beacon-interval(2), 1036bdcd8170SKalle Valo * cap-info(2), ssid-id(1), ssid-len(1). 1037bdcd8170SKalle Valo */ 1038bdcd8170SKalle Valo memcpy(ni_buf, buf, SSID_IE_LEN_INDEX + 1); 1039bdcd8170SKalle Valo 1040bdcd8170SKalle Valo ni_buf[SSID_IE_LEN_INDEX] = cached_ssid_len; 1041bdcd8170SKalle Valo ni_buf += (SSID_IE_LEN_INDEX + 1); 1042bdcd8170SKalle Valo 1043bdcd8170SKalle Valo buf += (SSID_IE_LEN_INDEX + 1); 1044bdcd8170SKalle Valo buf_len -= (SSID_IE_LEN_INDEX + 1); 1045bdcd8170SKalle Valo 1046bdcd8170SKalle Valo memcpy(ni_buf, cached_ssid, cached_ssid_len); 1047bdcd8170SKalle Valo ni_buf += cached_ssid_len; 1048bdcd8170SKalle Valo 1049bdcd8170SKalle Valo buf += beacon_ssid_len; 1050bdcd8170SKalle Valo buf_len -= beacon_ssid_len; 1051bdcd8170SKalle Valo 1052bdcd8170SKalle Valo if (cached_ssid_len > beacon_ssid_len) 1053bdcd8170SKalle Valo buf_len -= (cached_ssid_len - beacon_ssid_len); 1054bdcd8170SKalle Valo 1055bdcd8170SKalle Valo memcpy(ni_buf, buf, buf_len); 1056bdcd8170SKalle Valo } else 1057bdcd8170SKalle Valo memcpy(bss->ni_buf, buf, len); 1058bdcd8170SKalle Valo 1059bdcd8170SKalle Valo bss->ni_framelen = len; 1060bdcd8170SKalle Valo 1061bdcd8170SKalle Valo ret = ath6kl_wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie); 1062bdcd8170SKalle Valo if (ret) { 1063bdcd8170SKalle Valo wlan_node_free(bss); 1064bdcd8170SKalle Valo return -EINVAL; 1065bdcd8170SKalle Valo } 1066bdcd8170SKalle Valo 1067bdcd8170SKalle Valo /* 1068bdcd8170SKalle Valo * Update the frequency in ie_chan, overwriting of channel number 1069bdcd8170SKalle Valo * which is done in ath6kl_wlan_parse_beacon 1070bdcd8170SKalle Valo */ 1071bdcd8170SKalle Valo bss->ni_cie.ie_chan = le16_to_cpu(bih->ch); 10727c3075e9SVasanthakumar Thiagarajan wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid); 1073bdcd8170SKalle Valo 1074bdcd8170SKalle Valo return 0; 1075bdcd8170SKalle Valo } 1076bdcd8170SKalle Valo 1077bdcd8170SKalle Valo static int ath6kl_wmi_opt_frame_event_rx(struct wmi *wmi, u8 *datap, int len) 1078bdcd8170SKalle Valo { 1079bdcd8170SKalle Valo struct bss *bss; 1080bdcd8170SKalle Valo struct wmi_opt_rx_info_hdr *bih; 1081bdcd8170SKalle Valo u8 *buf; 1082bdcd8170SKalle Valo 1083bdcd8170SKalle Valo if (len <= sizeof(struct wmi_opt_rx_info_hdr)) 1084bdcd8170SKalle Valo return -EINVAL; 1085bdcd8170SKalle Valo 1086bdcd8170SKalle Valo bih = (struct wmi_opt_rx_info_hdr *) datap; 1087bdcd8170SKalle Valo buf = datap + sizeof(struct wmi_opt_rx_info_hdr); 1088bdcd8170SKalle Valo len -= sizeof(struct wmi_opt_rx_info_hdr); 1089bdcd8170SKalle Valo 1090bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "opt frame event %2.2x:%2.2x\n", 1091bdcd8170SKalle Valo bih->bssid[4], bih->bssid[5]); 1092bdcd8170SKalle Valo 10937c3075e9SVasanthakumar Thiagarajan bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid); 1094bdcd8170SKalle Valo if (bss != NULL) { 1095bdcd8170SKalle Valo /* Free up the node. We are about to allocate a new node. */ 10967c3075e9SVasanthakumar Thiagarajan wlan_node_reclaim(&wmi->parent_dev->scan_table, bss); 1097bdcd8170SKalle Valo } 1098bdcd8170SKalle Valo 1099bdcd8170SKalle Valo bss = wlan_node_alloc(len); 1100bdcd8170SKalle Valo if (!bss) 1101bdcd8170SKalle Valo return -ENOMEM; 1102bdcd8170SKalle Valo 1103bdcd8170SKalle Valo bss->ni_snr = bih->snr; 1104bdcd8170SKalle Valo bss->ni_cie.ie_chan = le16_to_cpu(bih->ch); 1105bdcd8170SKalle Valo 1106bdcd8170SKalle Valo if (WARN_ON(!bss->ni_buf)) 1107bdcd8170SKalle Valo return -EINVAL; 1108bdcd8170SKalle Valo 1109bdcd8170SKalle Valo memcpy(bss->ni_buf, buf, len); 11107c3075e9SVasanthakumar Thiagarajan wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid); 1111bdcd8170SKalle Valo 1112bdcd8170SKalle Valo return 0; 1113bdcd8170SKalle Valo } 1114bdcd8170SKalle Valo 1115bdcd8170SKalle Valo /* Inactivity timeout of a fatpipe(pstream) at the target */ 1116bdcd8170SKalle Valo static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, 1117bdcd8170SKalle Valo int len) 1118bdcd8170SKalle Valo { 1119bdcd8170SKalle Valo struct wmi_pstream_timeout_event *ev; 1120bdcd8170SKalle Valo 1121bdcd8170SKalle Valo if (len < sizeof(struct wmi_pstream_timeout_event)) 1122bdcd8170SKalle Valo return -EINVAL; 1123bdcd8170SKalle Valo 1124bdcd8170SKalle Valo ev = (struct wmi_pstream_timeout_event *) datap; 1125bdcd8170SKalle Valo 1126bdcd8170SKalle Valo /* 1127bdcd8170SKalle Valo * When the pstream (fat pipe == AC) timesout, it means there were 1128bdcd8170SKalle Valo * no thinStreams within this pstream & it got implicitly created 1129bdcd8170SKalle Valo * due to data flow on this AC. We start the inactivity timer only 1130bdcd8170SKalle Valo * for implicitly created pstream. Just reset the host state. 1131bdcd8170SKalle Valo */ 1132bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1133bdcd8170SKalle Valo wmi->stream_exist_for_ac[ev->traffic_class] = 0; 1134bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); 1135bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1136bdcd8170SKalle Valo 1137bdcd8170SKalle Valo /* Indicate inactivity to driver layer for this fatpipe (pstream) */ 1138bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); 1139bdcd8170SKalle Valo 1140bdcd8170SKalle Valo return 0; 1141bdcd8170SKalle Valo } 1142bdcd8170SKalle Valo 1143bdcd8170SKalle Valo static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) 1144bdcd8170SKalle Valo { 1145bdcd8170SKalle Valo struct wmi_bit_rate_reply *reply; 1146bdcd8170SKalle Valo s32 rate; 1147bdcd8170SKalle Valo u32 sgi, index; 1148bdcd8170SKalle Valo 1149bdcd8170SKalle Valo if (len < sizeof(struct wmi_bit_rate_reply)) 1150bdcd8170SKalle Valo return -EINVAL; 1151bdcd8170SKalle Valo 1152bdcd8170SKalle Valo reply = (struct wmi_bit_rate_reply *) datap; 1153bdcd8170SKalle Valo 1154bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); 1155bdcd8170SKalle Valo 1156bdcd8170SKalle Valo if (reply->rate_index == (s8) RATE_AUTO) { 1157bdcd8170SKalle Valo rate = RATE_AUTO; 1158bdcd8170SKalle Valo } else { 1159bdcd8170SKalle Valo index = reply->rate_index & 0x7f; 1160bdcd8170SKalle Valo sgi = (reply->rate_index & 0x80) ? 1 : 0; 1161bdcd8170SKalle Valo rate = wmi_rate_tbl[index][sgi]; 1162bdcd8170SKalle Valo } 1163bdcd8170SKalle Valo 1164bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1165bdcd8170SKalle Valo 1166bdcd8170SKalle Valo return 0; 1167bdcd8170SKalle Valo } 1168bdcd8170SKalle Valo 1169003353b0SKalle Valo static int ath6kl_wmi_tcmd_test_report_rx(struct wmi *wmi, u8 *datap, int len) 1170003353b0SKalle Valo { 1171003353b0SKalle Valo ath6kl_tm_rx_report_event(wmi->parent_dev, datap, len); 1172003353b0SKalle Valo 1173003353b0SKalle Valo return 0; 1174003353b0SKalle Valo } 1175003353b0SKalle Valo 1176bdcd8170SKalle Valo static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) 1177bdcd8170SKalle Valo { 1178bdcd8170SKalle Valo if (len < sizeof(struct wmi_fix_rates_reply)) 1179bdcd8170SKalle Valo return -EINVAL; 1180bdcd8170SKalle Valo 1181bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1182bdcd8170SKalle Valo 1183bdcd8170SKalle Valo return 0; 1184bdcd8170SKalle Valo } 1185bdcd8170SKalle Valo 1186bdcd8170SKalle Valo static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) 1187bdcd8170SKalle Valo { 1188bdcd8170SKalle Valo if (len < sizeof(struct wmi_channel_list_reply)) 1189bdcd8170SKalle Valo return -EINVAL; 1190bdcd8170SKalle Valo 1191bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1192bdcd8170SKalle Valo 1193bdcd8170SKalle Valo return 0; 1194bdcd8170SKalle Valo } 1195bdcd8170SKalle Valo 1196bdcd8170SKalle Valo static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) 1197bdcd8170SKalle Valo { 1198bdcd8170SKalle Valo struct wmi_tx_pwr_reply *reply; 1199bdcd8170SKalle Valo 1200bdcd8170SKalle Valo if (len < sizeof(struct wmi_tx_pwr_reply)) 1201bdcd8170SKalle Valo return -EINVAL; 1202bdcd8170SKalle Valo 1203bdcd8170SKalle Valo reply = (struct wmi_tx_pwr_reply *) datap; 1204bdcd8170SKalle Valo ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); 1205bdcd8170SKalle Valo 1206bdcd8170SKalle Valo return 0; 1207bdcd8170SKalle Valo } 1208bdcd8170SKalle Valo 1209bdcd8170SKalle Valo static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) 1210bdcd8170SKalle Valo { 1211bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_keepalive_cmd)) 1212bdcd8170SKalle Valo return -EINVAL; 1213bdcd8170SKalle Valo 1214bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1215bdcd8170SKalle Valo 1216bdcd8170SKalle Valo return 0; 1217bdcd8170SKalle Valo } 1218bdcd8170SKalle Valo 1219bdcd8170SKalle Valo static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len) 1220bdcd8170SKalle Valo { 1221bdcd8170SKalle Valo struct wmi_scan_complete_event *ev; 1222bdcd8170SKalle Valo 1223bdcd8170SKalle Valo ev = (struct wmi_scan_complete_event *) datap; 1224bdcd8170SKalle Valo 1225bdcd8170SKalle Valo if (a_sle32_to_cpu(ev->status) == 0) 1226e4c7ffcbSVasanthakumar Thiagarajan wlan_refresh_inactive_nodes(wmi->parent_dev); 1227bdcd8170SKalle Valo 1228bdcd8170SKalle Valo ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status)); 1229bdcd8170SKalle Valo wmi->is_probe_ssid = false; 1230bdcd8170SKalle Valo 1231bdcd8170SKalle Valo return 0; 1232bdcd8170SKalle Valo } 1233bdcd8170SKalle Valo 1234bdcd8170SKalle Valo /* 1235bdcd8170SKalle Valo * Target is reporting a programming error. This is for 1236bdcd8170SKalle Valo * developer aid only. Target only checks a few common violations 1237bdcd8170SKalle Valo * and it is responsibility of host to do all error checking. 1238bdcd8170SKalle Valo * Behavior of target after wmi error event is undefined. 1239bdcd8170SKalle Valo * A reset is recommended. 1240bdcd8170SKalle Valo */ 1241bdcd8170SKalle Valo static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) 1242bdcd8170SKalle Valo { 1243bdcd8170SKalle Valo const char *type = "unknown error"; 1244bdcd8170SKalle Valo struct wmi_cmd_error_event *ev; 1245bdcd8170SKalle Valo ev = (struct wmi_cmd_error_event *) datap; 1246bdcd8170SKalle Valo 1247bdcd8170SKalle Valo switch (ev->err_code) { 1248bdcd8170SKalle Valo case INVALID_PARAM: 1249bdcd8170SKalle Valo type = "invalid parameter"; 1250bdcd8170SKalle Valo break; 1251bdcd8170SKalle Valo case ILLEGAL_STATE: 1252bdcd8170SKalle Valo type = "invalid state"; 1253bdcd8170SKalle Valo break; 1254bdcd8170SKalle Valo case INTERNAL_ERROR: 1255bdcd8170SKalle Valo type = "internal error"; 1256bdcd8170SKalle Valo break; 1257bdcd8170SKalle Valo } 1258bdcd8170SKalle Valo 1259bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", 1260bdcd8170SKalle Valo ev->cmd_id, type); 1261bdcd8170SKalle Valo 1262bdcd8170SKalle Valo return 0; 1263bdcd8170SKalle Valo } 1264bdcd8170SKalle Valo 1265bdcd8170SKalle Valo static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len) 1266bdcd8170SKalle Valo { 1267bdcd8170SKalle Valo ath6kl_tgt_stats_event(wmi->parent_dev, datap, len); 1268bdcd8170SKalle Valo 1269bdcd8170SKalle Valo return 0; 1270bdcd8170SKalle Valo } 1271bdcd8170SKalle Valo 1272bdcd8170SKalle Valo static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, 1273bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1274bdcd8170SKalle Valo u32 size) 1275bdcd8170SKalle Valo { 1276bdcd8170SKalle Valo u32 index; 1277bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; 1278bdcd8170SKalle Valo 1279bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1280bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1281bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[index]) { 1282bdcd8170SKalle Valo threshold = (u8) sq_thresh->upper_threshold[index]; 1283bdcd8170SKalle Valo break; 1284bdcd8170SKalle Valo } 1285bdcd8170SKalle Valo } 1286bdcd8170SKalle Valo 1287bdcd8170SKalle Valo return threshold; 1288bdcd8170SKalle Valo } 1289bdcd8170SKalle Valo 1290bdcd8170SKalle Valo static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, 1291bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1292bdcd8170SKalle Valo u32 size) 1293bdcd8170SKalle Valo { 1294bdcd8170SKalle Valo u32 index; 1295bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; 1296bdcd8170SKalle Valo 1297bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1298bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1299bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[index]) { 1300bdcd8170SKalle Valo threshold = (u8) sq_thresh->lower_threshold[index]; 1301bdcd8170SKalle Valo break; 1302bdcd8170SKalle Valo } 1303bdcd8170SKalle Valo } 1304bdcd8170SKalle Valo 1305bdcd8170SKalle Valo return threshold; 1306bdcd8170SKalle Valo } 1307bdcd8170SKalle Valo 1308bdcd8170SKalle Valo static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, 1309bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *rssi_cmd) 1310bdcd8170SKalle Valo { 1311bdcd8170SKalle Valo struct sk_buff *skb; 1312bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *cmd; 1313bdcd8170SKalle Valo 1314bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1315bdcd8170SKalle Valo if (!skb) 1316bdcd8170SKalle Valo return -ENOMEM; 1317bdcd8170SKalle Valo 1318bdcd8170SKalle Valo cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; 1319bdcd8170SKalle Valo memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); 1320bdcd8170SKalle Valo 1321bdcd8170SKalle Valo return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, 1322bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1323bdcd8170SKalle Valo } 1324bdcd8170SKalle Valo 1325bdcd8170SKalle Valo static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, 1326bdcd8170SKalle Valo int len) 1327bdcd8170SKalle Valo { 1328bdcd8170SKalle Valo struct wmi_rssi_threshold_event *reply; 1329bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd cmd; 1330bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1331bdcd8170SKalle Valo enum wmi_rssi_threshold_val new_threshold; 1332bdcd8170SKalle Valo u8 upper_rssi_threshold, lower_rssi_threshold; 1333bdcd8170SKalle Valo s16 rssi; 1334bdcd8170SKalle Valo int ret; 1335bdcd8170SKalle Valo 1336bdcd8170SKalle Valo if (len < sizeof(struct wmi_rssi_threshold_event)) 1337bdcd8170SKalle Valo return -EINVAL; 1338bdcd8170SKalle Valo 1339bdcd8170SKalle Valo reply = (struct wmi_rssi_threshold_event *) datap; 1340bdcd8170SKalle Valo new_threshold = (enum wmi_rssi_threshold_val) reply->range; 1341bdcd8170SKalle Valo rssi = a_sle16_to_cpu(reply->rssi); 1342bdcd8170SKalle Valo 1343bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; 1344bdcd8170SKalle Valo 1345bdcd8170SKalle Valo /* 1346bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1347bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1348bdcd8170SKalle Valo * quality reported by the target 1349bdcd8170SKalle Valo */ 1350bdcd8170SKalle Valo if (new_threshold) { 1351bdcd8170SKalle Valo /* Upper threshold breached */ 1352bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[0]) { 1353bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1354bdcd8170SKalle Valo "spurious upper rssi threshold event: %d\n", 1355bdcd8170SKalle Valo rssi); 1356bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[1]) && 1357bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[0])) { 1358bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; 1359bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[2]) && 1360bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[1])) { 1361bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; 1362bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[3]) && 1363bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[2])) { 1364bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; 1365bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[4]) && 1366bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[3])) { 1367bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; 1368bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[5]) && 1369bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[4])) { 1370bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; 1371bdcd8170SKalle Valo } else if (rssi >= sq_thresh->upper_threshold[5]) { 1372bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; 1373bdcd8170SKalle Valo } 1374bdcd8170SKalle Valo } else { 1375bdcd8170SKalle Valo /* Lower threshold breached */ 1376bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[0]) { 1377bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1378bdcd8170SKalle Valo "spurious lower rssi threshold event: %d %d\n", 1379bdcd8170SKalle Valo rssi, sq_thresh->lower_threshold[0]); 1380bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[1]) && 1381bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[0])) { 1382bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_BELOW; 1383bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[2]) && 1384bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[1])) { 1385bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_BELOW; 1386bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[3]) && 1387bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[2])) { 1388bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_BELOW; 1389bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[4]) && 1390bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[3])) { 1391bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_BELOW; 1392bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[5]) && 1393bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[4])) { 1394bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_BELOW; 1395bdcd8170SKalle Valo } else if (rssi <= sq_thresh->lower_threshold[5]) { 1396bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_BELOW; 1397bdcd8170SKalle Valo } 1398bdcd8170SKalle Valo } 1399bdcd8170SKalle Valo 1400bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1401bdcd8170SKalle Valo lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, 1402bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1403bdcd8170SKalle Valo upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, 1404bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1405bdcd8170SKalle Valo 1406bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1407bdcd8170SKalle Valo cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); 1408bdcd8170SKalle Valo cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); 1409bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1410bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1411bdcd8170SKalle Valo 1412bdcd8170SKalle Valo ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); 1413bdcd8170SKalle Valo if (ret) { 1414bdcd8170SKalle Valo ath6kl_err("unable to configure rssi thresholds\n"); 1415bdcd8170SKalle Valo return -EIO; 1416bdcd8170SKalle Valo } 1417bdcd8170SKalle Valo 1418bdcd8170SKalle Valo return 0; 1419bdcd8170SKalle Valo } 1420bdcd8170SKalle Valo 1421bdcd8170SKalle Valo static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) 1422bdcd8170SKalle Valo { 1423bdcd8170SKalle Valo struct wmi_cac_event *reply; 1424bdcd8170SKalle Valo struct ieee80211_tspec_ie *ts; 1425bdcd8170SKalle Valo u16 active_tsids, tsinfo; 1426bdcd8170SKalle Valo u8 tsid, index; 1427bdcd8170SKalle Valo u8 ts_id; 1428bdcd8170SKalle Valo 1429bdcd8170SKalle Valo if (len < sizeof(struct wmi_cac_event)) 1430bdcd8170SKalle Valo return -EINVAL; 1431bdcd8170SKalle Valo 1432bdcd8170SKalle Valo reply = (struct wmi_cac_event *) datap; 1433bdcd8170SKalle Valo 1434bdcd8170SKalle Valo if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && 1435bdcd8170SKalle Valo (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { 1436bdcd8170SKalle Valo 1437bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1438bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1439bdcd8170SKalle Valo tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1440bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK; 1441bdcd8170SKalle Valo 1442bdcd8170SKalle Valo ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid); 1443bdcd8170SKalle Valo } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { 1444bdcd8170SKalle Valo /* 1445bdcd8170SKalle Valo * Following assumes that there is only one outstanding 1446bdcd8170SKalle Valo * ADDTS request when this event is received 1447bdcd8170SKalle Valo */ 1448bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1449bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1450bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1451bdcd8170SKalle Valo 1452bdcd8170SKalle Valo for (index = 0; index < sizeof(active_tsids) * 8; index++) { 1453bdcd8170SKalle Valo if ((active_tsids >> index) & 1) 1454bdcd8170SKalle Valo break; 1455bdcd8170SKalle Valo } 1456bdcd8170SKalle Valo if (index < (sizeof(active_tsids) * 8)) 1457bdcd8170SKalle Valo ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index); 1458bdcd8170SKalle Valo } 1459bdcd8170SKalle Valo 1460bdcd8170SKalle Valo /* 1461bdcd8170SKalle Valo * Clear active tsids and Add missing handling 1462bdcd8170SKalle Valo * for delete qos stream from AP 1463bdcd8170SKalle Valo */ 1464bdcd8170SKalle Valo else if (reply->cac_indication == CAC_INDICATION_DELETE) { 1465bdcd8170SKalle Valo 1466bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1467bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1468bdcd8170SKalle Valo ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1469bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK); 1470bdcd8170SKalle Valo 1471bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1472bdcd8170SKalle Valo wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); 1473bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1474bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1475bdcd8170SKalle Valo 1476bdcd8170SKalle Valo /* Indicate stream inactivity to driver layer only if all tsids 1477bdcd8170SKalle Valo * within this AC are deleted. 1478bdcd8170SKalle Valo */ 1479bdcd8170SKalle Valo if (!active_tsids) { 1480bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, 1481bdcd8170SKalle Valo false); 1482bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << reply->ac); 1483bdcd8170SKalle Valo } 1484bdcd8170SKalle Valo } 1485bdcd8170SKalle Valo 1486bdcd8170SKalle Valo return 0; 1487bdcd8170SKalle Valo } 1488bdcd8170SKalle Valo 1489bdcd8170SKalle Valo static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, 1490bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *snr_cmd) 1491bdcd8170SKalle Valo { 1492bdcd8170SKalle Valo struct sk_buff *skb; 1493bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *cmd; 1494bdcd8170SKalle Valo 1495bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1496bdcd8170SKalle Valo if (!skb) 1497bdcd8170SKalle Valo return -ENOMEM; 1498bdcd8170SKalle Valo 1499bdcd8170SKalle Valo cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; 1500bdcd8170SKalle Valo memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); 1501bdcd8170SKalle Valo 1502bdcd8170SKalle Valo return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, 1503bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1504bdcd8170SKalle Valo } 1505bdcd8170SKalle Valo 1506bdcd8170SKalle Valo static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, 1507bdcd8170SKalle Valo int len) 1508bdcd8170SKalle Valo { 1509bdcd8170SKalle Valo struct wmi_snr_threshold_event *reply; 1510bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1511bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd cmd; 1512bdcd8170SKalle Valo enum wmi_snr_threshold_val new_threshold; 1513bdcd8170SKalle Valo u8 upper_snr_threshold, lower_snr_threshold; 1514bdcd8170SKalle Valo s16 snr; 1515bdcd8170SKalle Valo int ret; 1516bdcd8170SKalle Valo 1517bdcd8170SKalle Valo if (len < sizeof(struct wmi_snr_threshold_event)) 1518bdcd8170SKalle Valo return -EINVAL; 1519bdcd8170SKalle Valo 1520bdcd8170SKalle Valo reply = (struct wmi_snr_threshold_event *) datap; 1521bdcd8170SKalle Valo 1522bdcd8170SKalle Valo new_threshold = (enum wmi_snr_threshold_val) reply->range; 1523bdcd8170SKalle Valo snr = reply->snr; 1524bdcd8170SKalle Valo 1525bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; 1526bdcd8170SKalle Valo 1527bdcd8170SKalle Valo /* 1528bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1529bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1530bdcd8170SKalle Valo * quality reported by the target. 1531bdcd8170SKalle Valo */ 1532bdcd8170SKalle Valo if (new_threshold) { 1533bdcd8170SKalle Valo /* Upper threshold breached */ 1534bdcd8170SKalle Valo if (snr < sq_thresh->upper_threshold[0]) { 1535bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1536bdcd8170SKalle Valo "spurious upper snr threshold event: %d\n", 1537bdcd8170SKalle Valo snr); 1538bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[1]) && 1539bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[0])) { 1540bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_ABOVE; 1541bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[2]) && 1542bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[1])) { 1543bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_ABOVE; 1544bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[3]) && 1545bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[2])) { 1546bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_ABOVE; 1547bdcd8170SKalle Valo } else if (snr >= sq_thresh->upper_threshold[3]) { 1548bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_ABOVE; 1549bdcd8170SKalle Valo } 1550bdcd8170SKalle Valo } else { 1551bdcd8170SKalle Valo /* Lower threshold breached */ 1552bdcd8170SKalle Valo if (snr > sq_thresh->lower_threshold[0]) { 1553bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1554bdcd8170SKalle Valo "spurious lower snr threshold event: %d\n", 1555bdcd8170SKalle Valo sq_thresh->lower_threshold[0]); 1556bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[1]) && 1557bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[0])) { 1558bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_BELOW; 1559bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[2]) && 1560bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[1])) { 1561bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_BELOW; 1562bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[3]) && 1563bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[2])) { 1564bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_BELOW; 1565bdcd8170SKalle Valo } else if (snr <= sq_thresh->lower_threshold[3]) { 1566bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_BELOW; 1567bdcd8170SKalle Valo } 1568bdcd8170SKalle Valo } 1569bdcd8170SKalle Valo 1570bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1571bdcd8170SKalle Valo lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, 1572bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1573bdcd8170SKalle Valo upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, 1574bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1575bdcd8170SKalle Valo 1576bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1577bdcd8170SKalle Valo cmd.thresh_above1_val = upper_snr_threshold; 1578bdcd8170SKalle Valo cmd.thresh_below1_val = lower_snr_threshold; 1579bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1580bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1581bdcd8170SKalle Valo 1582bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1583bdcd8170SKalle Valo "snr: %d, threshold: %d, lower: %d, upper: %d\n", 1584bdcd8170SKalle Valo snr, new_threshold, 1585bdcd8170SKalle Valo lower_snr_threshold, upper_snr_threshold); 1586bdcd8170SKalle Valo 1587bdcd8170SKalle Valo ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); 1588bdcd8170SKalle Valo if (ret) { 1589bdcd8170SKalle Valo ath6kl_err("unable to configure snr threshold\n"); 1590bdcd8170SKalle Valo return -EIO; 1591bdcd8170SKalle Valo } 1592bdcd8170SKalle Valo 1593bdcd8170SKalle Valo return 0; 1594bdcd8170SKalle Valo } 1595bdcd8170SKalle Valo 1596bdcd8170SKalle Valo static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) 1597bdcd8170SKalle Valo { 1598bdcd8170SKalle Valo u16 ap_info_entry_size; 1599bdcd8170SKalle Valo struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; 1600bdcd8170SKalle Valo struct wmi_ap_info_v1 *ap_info_v1; 1601bdcd8170SKalle Valo u8 index; 1602bdcd8170SKalle Valo 1603bdcd8170SKalle Valo if (len < sizeof(struct wmi_aplist_event) || 1604bdcd8170SKalle Valo ev->ap_list_ver != APLIST_VER1) 1605bdcd8170SKalle Valo return -EINVAL; 1606bdcd8170SKalle Valo 1607bdcd8170SKalle Valo ap_info_entry_size = sizeof(struct wmi_ap_info_v1); 1608bdcd8170SKalle Valo ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; 1609bdcd8170SKalle Valo 1610bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1611bdcd8170SKalle Valo "number of APs in aplist event: %d\n", ev->num_ap); 1612bdcd8170SKalle Valo 1613bdcd8170SKalle Valo if (len < (int) (sizeof(struct wmi_aplist_event) + 1614bdcd8170SKalle Valo (ev->num_ap - 1) * ap_info_entry_size)) 1615bdcd8170SKalle Valo return -EINVAL; 1616bdcd8170SKalle Valo 1617bdcd8170SKalle Valo /* AP list version 1 contents */ 1618bdcd8170SKalle Valo for (index = 0; index < ev->num_ap; index++) { 1619bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", 1620bdcd8170SKalle Valo index, ap_info_v1->bssid, ap_info_v1->channel); 1621bdcd8170SKalle Valo ap_info_v1++; 1622bdcd8170SKalle Valo } 1623bdcd8170SKalle Valo 1624bdcd8170SKalle Valo return 0; 1625bdcd8170SKalle Valo } 1626bdcd8170SKalle Valo 1627bdcd8170SKalle Valo int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, 1628bdcd8170SKalle Valo enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) 1629bdcd8170SKalle Valo { 1630bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd_hdr; 1631bdcd8170SKalle Valo enum htc_endpoint_id ep_id = wmi->ep_id; 1632bdcd8170SKalle Valo int ret; 1633bdcd8170SKalle Valo 16346a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: cmd_id=%d\n", __func__, cmd_id); 16356a7c9badSJouni Malinen 1636bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 1637bdcd8170SKalle Valo return -EINVAL; 1638bdcd8170SKalle Valo 1639bdcd8170SKalle Valo if (sync_flag >= END_WMIFLAG) { 1640bdcd8170SKalle Valo dev_kfree_skb(skb); 1641bdcd8170SKalle Valo return -EINVAL; 1642bdcd8170SKalle Valo } 1643bdcd8170SKalle Valo 1644bdcd8170SKalle Valo if ((sync_flag == SYNC_BEFORE_WMIFLAG) || 1645bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1646bdcd8170SKalle Valo /* 1647bdcd8170SKalle Valo * Make sure all data currently queued is transmitted before 1648bdcd8170SKalle Valo * the cmd execution. Establish a new sync point. 1649bdcd8170SKalle Valo */ 1650bdcd8170SKalle Valo ath6kl_wmi_sync_point(wmi); 1651bdcd8170SKalle Valo } 1652bdcd8170SKalle Valo 1653bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_cmd_hdr)); 1654bdcd8170SKalle Valo 1655bdcd8170SKalle Valo cmd_hdr = (struct wmi_cmd_hdr *) skb->data; 1656bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le16(cmd_id); 1657bdcd8170SKalle Valo cmd_hdr->info1 = 0; /* added for virtual interface */ 1658bdcd8170SKalle Valo 1659bdcd8170SKalle Valo /* Only for OPT_TX_CMD, use BE endpoint. */ 1660bdcd8170SKalle Valo if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { 1661bdcd8170SKalle Valo ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, 1662bdcd8170SKalle Valo false, false, 0, NULL); 1663bdcd8170SKalle Valo if (ret) { 1664bdcd8170SKalle Valo dev_kfree_skb(skb); 1665bdcd8170SKalle Valo return ret; 1666bdcd8170SKalle Valo } 1667bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); 1668bdcd8170SKalle Valo } 1669bdcd8170SKalle Valo 1670bdcd8170SKalle Valo ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 1671bdcd8170SKalle Valo 1672bdcd8170SKalle Valo if ((sync_flag == SYNC_AFTER_WMIFLAG) || 1673bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1674bdcd8170SKalle Valo /* 1675bdcd8170SKalle Valo * Make sure all new data queued waits for the command to 1676bdcd8170SKalle Valo * execute. Establish a new sync point. 1677bdcd8170SKalle Valo */ 1678bdcd8170SKalle Valo ath6kl_wmi_sync_point(wmi); 1679bdcd8170SKalle Valo } 1680bdcd8170SKalle Valo 1681bdcd8170SKalle Valo return 0; 1682bdcd8170SKalle Valo } 1683bdcd8170SKalle Valo 1684bdcd8170SKalle Valo int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, 1685bdcd8170SKalle Valo enum dot11_auth_mode dot11_auth_mode, 1686bdcd8170SKalle Valo enum auth_mode auth_mode, 1687bdcd8170SKalle Valo enum crypto_type pairwise_crypto, 1688bdcd8170SKalle Valo u8 pairwise_crypto_len, 1689bdcd8170SKalle Valo enum crypto_type group_crypto, 1690bdcd8170SKalle Valo u8 group_crypto_len, int ssid_len, u8 *ssid, 1691bdcd8170SKalle Valo u8 *bssid, u16 channel, u32 ctrl_flags) 1692bdcd8170SKalle Valo { 1693bdcd8170SKalle Valo struct sk_buff *skb; 1694bdcd8170SKalle Valo struct wmi_connect_cmd *cc; 1695bdcd8170SKalle Valo int ret; 1696bdcd8170SKalle Valo 1697bdcd8170SKalle Valo wmi->traffic_class = 100; 1698bdcd8170SKalle Valo 1699bdcd8170SKalle Valo if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) 1700bdcd8170SKalle Valo return -EINVAL; 1701bdcd8170SKalle Valo 1702bdcd8170SKalle Valo if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) 1703bdcd8170SKalle Valo return -EINVAL; 1704bdcd8170SKalle Valo 1705bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); 1706bdcd8170SKalle Valo if (!skb) 1707bdcd8170SKalle Valo return -ENOMEM; 1708bdcd8170SKalle Valo 1709bdcd8170SKalle Valo cc = (struct wmi_connect_cmd *) skb->data; 1710bdcd8170SKalle Valo 1711bdcd8170SKalle Valo if (ssid_len) 1712bdcd8170SKalle Valo memcpy(cc->ssid, ssid, ssid_len); 1713bdcd8170SKalle Valo 1714bdcd8170SKalle Valo cc->ssid_len = ssid_len; 1715bdcd8170SKalle Valo cc->nw_type = nw_type; 1716bdcd8170SKalle Valo cc->dot11_auth_mode = dot11_auth_mode; 1717bdcd8170SKalle Valo cc->auth_mode = auth_mode; 1718bdcd8170SKalle Valo cc->prwise_crypto_type = pairwise_crypto; 1719bdcd8170SKalle Valo cc->prwise_crypto_len = pairwise_crypto_len; 1720bdcd8170SKalle Valo cc->grp_crypto_type = group_crypto; 1721bdcd8170SKalle Valo cc->grp_crypto_len = group_crypto_len; 1722bdcd8170SKalle Valo cc->ch = cpu_to_le16(channel); 1723bdcd8170SKalle Valo cc->ctrl_flags = cpu_to_le32(ctrl_flags); 1724bdcd8170SKalle Valo 1725bdcd8170SKalle Valo if (bssid != NULL) 1726bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1727bdcd8170SKalle Valo 1728bdcd8170SKalle Valo wmi->pair_crypto_type = pairwise_crypto; 1729bdcd8170SKalle Valo wmi->grp_crypto_type = group_crypto; 1730bdcd8170SKalle Valo 1731bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG); 1732bdcd8170SKalle Valo 1733bdcd8170SKalle Valo return ret; 1734bdcd8170SKalle Valo } 1735bdcd8170SKalle Valo 1736bdcd8170SKalle Valo int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel) 1737bdcd8170SKalle Valo { 1738bdcd8170SKalle Valo struct sk_buff *skb; 1739bdcd8170SKalle Valo struct wmi_reconnect_cmd *cc; 1740bdcd8170SKalle Valo int ret; 1741bdcd8170SKalle Valo 1742bdcd8170SKalle Valo wmi->traffic_class = 100; 1743bdcd8170SKalle Valo 1744bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); 1745bdcd8170SKalle Valo if (!skb) 1746bdcd8170SKalle Valo return -ENOMEM; 1747bdcd8170SKalle Valo 1748bdcd8170SKalle Valo cc = (struct wmi_reconnect_cmd *) skb->data; 1749bdcd8170SKalle Valo cc->channel = cpu_to_le16(channel); 1750bdcd8170SKalle Valo 1751bdcd8170SKalle Valo if (bssid != NULL) 1752bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1753bdcd8170SKalle Valo 1754bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID, 1755bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1756bdcd8170SKalle Valo 1757bdcd8170SKalle Valo return ret; 1758bdcd8170SKalle Valo } 1759bdcd8170SKalle Valo 1760bdcd8170SKalle Valo int ath6kl_wmi_disconnect_cmd(struct wmi *wmi) 1761bdcd8170SKalle Valo { 1762bdcd8170SKalle Valo int ret; 1763bdcd8170SKalle Valo 1764bdcd8170SKalle Valo wmi->traffic_class = 100; 1765bdcd8170SKalle Valo 1766bdcd8170SKalle Valo /* Disconnect command does not need to do a SYNC before. */ 1767bdcd8170SKalle Valo ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID); 1768bdcd8170SKalle Valo 1769bdcd8170SKalle Valo return ret; 1770bdcd8170SKalle Valo } 1771bdcd8170SKalle Valo 1772bdcd8170SKalle Valo int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, 1773bdcd8170SKalle Valo u32 force_fgscan, u32 is_legacy, 1774bdcd8170SKalle Valo u32 home_dwell_time, u32 force_scan_interval, 1775bdcd8170SKalle Valo s8 num_chan, u16 *ch_list) 1776bdcd8170SKalle Valo { 1777bdcd8170SKalle Valo struct sk_buff *skb; 1778bdcd8170SKalle Valo struct wmi_start_scan_cmd *sc; 1779bdcd8170SKalle Valo s8 size; 17801276c9efSEdward Lu int i, ret; 1781bdcd8170SKalle Valo 1782bdcd8170SKalle Valo size = sizeof(struct wmi_start_scan_cmd); 1783bdcd8170SKalle Valo 1784bdcd8170SKalle Valo if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 1785bdcd8170SKalle Valo return -EINVAL; 1786bdcd8170SKalle Valo 1787bdcd8170SKalle Valo if (num_chan > WMI_MAX_CHANNELS) 1788bdcd8170SKalle Valo return -EINVAL; 1789bdcd8170SKalle Valo 1790bdcd8170SKalle Valo if (num_chan) 1791bdcd8170SKalle Valo size += sizeof(u16) * (num_chan - 1); 1792bdcd8170SKalle Valo 1793bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(size); 1794bdcd8170SKalle Valo if (!skb) 1795bdcd8170SKalle Valo return -ENOMEM; 1796bdcd8170SKalle Valo 1797bdcd8170SKalle Valo sc = (struct wmi_start_scan_cmd *) skb->data; 1798bdcd8170SKalle Valo sc->scan_type = scan_type; 1799bdcd8170SKalle Valo sc->force_fg_scan = cpu_to_le32(force_fgscan); 1800bdcd8170SKalle Valo sc->is_legacy = cpu_to_le32(is_legacy); 1801bdcd8170SKalle Valo sc->home_dwell_time = cpu_to_le32(home_dwell_time); 1802bdcd8170SKalle Valo sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 1803bdcd8170SKalle Valo sc->num_ch = num_chan; 1804bdcd8170SKalle Valo 18051276c9efSEdward Lu for (i = 0; i < num_chan; i++) 18061276c9efSEdward Lu sc->ch_list[i] = cpu_to_le16(ch_list[i]); 1807bdcd8170SKalle Valo 1808bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID, 1809bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1810bdcd8170SKalle Valo 1811bdcd8170SKalle Valo return ret; 1812bdcd8170SKalle Valo } 1813bdcd8170SKalle Valo 1814bdcd8170SKalle Valo int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, 1815bdcd8170SKalle Valo u16 fg_end_sec, u16 bg_sec, 1816bdcd8170SKalle Valo u16 minact_chdw_msec, u16 maxact_chdw_msec, 1817bdcd8170SKalle Valo u16 pas_chdw_msec, u8 short_scan_ratio, 1818bdcd8170SKalle Valo u8 scan_ctrl_flag, u32 max_dfsch_act_time, 1819bdcd8170SKalle Valo u16 maxact_scan_per_ssid) 1820bdcd8170SKalle Valo { 1821bdcd8170SKalle Valo struct sk_buff *skb; 1822bdcd8170SKalle Valo struct wmi_scan_params_cmd *sc; 1823bdcd8170SKalle Valo int ret; 1824bdcd8170SKalle Valo 1825bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); 1826bdcd8170SKalle Valo if (!skb) 1827bdcd8170SKalle Valo return -ENOMEM; 1828bdcd8170SKalle Valo 1829bdcd8170SKalle Valo sc = (struct wmi_scan_params_cmd *) skb->data; 1830bdcd8170SKalle Valo sc->fg_start_period = cpu_to_le16(fg_start_sec); 1831bdcd8170SKalle Valo sc->fg_end_period = cpu_to_le16(fg_end_sec); 1832bdcd8170SKalle Valo sc->bg_period = cpu_to_le16(bg_sec); 1833bdcd8170SKalle Valo sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); 1834bdcd8170SKalle Valo sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); 1835bdcd8170SKalle Valo sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); 1836bdcd8170SKalle Valo sc->short_scan_ratio = short_scan_ratio; 1837bdcd8170SKalle Valo sc->scan_ctrl_flags = scan_ctrl_flag; 1838bdcd8170SKalle Valo sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); 1839bdcd8170SKalle Valo sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); 1840bdcd8170SKalle Valo 1841bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID, 1842bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1843bdcd8170SKalle Valo return ret; 1844bdcd8170SKalle Valo } 1845bdcd8170SKalle Valo 1846bdcd8170SKalle Valo int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) 1847bdcd8170SKalle Valo { 1848bdcd8170SKalle Valo struct sk_buff *skb; 1849bdcd8170SKalle Valo struct wmi_bss_filter_cmd *cmd; 1850bdcd8170SKalle Valo int ret; 1851bdcd8170SKalle Valo 1852bdcd8170SKalle Valo if (filter >= LAST_BSS_FILTER) 1853bdcd8170SKalle Valo return -EINVAL; 1854bdcd8170SKalle Valo 1855bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1856bdcd8170SKalle Valo if (!skb) 1857bdcd8170SKalle Valo return -ENOMEM; 1858bdcd8170SKalle Valo 1859bdcd8170SKalle Valo cmd = (struct wmi_bss_filter_cmd *) skb->data; 1860bdcd8170SKalle Valo cmd->bss_filter = filter; 1861bdcd8170SKalle Valo cmd->ie_mask = cpu_to_le32(ie_mask); 1862bdcd8170SKalle Valo 1863bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID, 1864bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1865bdcd8170SKalle Valo return ret; 1866bdcd8170SKalle Valo } 1867bdcd8170SKalle Valo 1868bdcd8170SKalle Valo int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, 1869bdcd8170SKalle Valo u8 ssid_len, u8 *ssid) 1870bdcd8170SKalle Valo { 1871bdcd8170SKalle Valo struct sk_buff *skb; 1872bdcd8170SKalle Valo struct wmi_probed_ssid_cmd *cmd; 1873bdcd8170SKalle Valo int ret; 1874bdcd8170SKalle Valo 1875bdcd8170SKalle Valo if (index > MAX_PROBED_SSID_INDEX) 1876bdcd8170SKalle Valo return -EINVAL; 1877bdcd8170SKalle Valo 1878bdcd8170SKalle Valo if (ssid_len > sizeof(cmd->ssid)) 1879bdcd8170SKalle Valo return -EINVAL; 1880bdcd8170SKalle Valo 1881bdcd8170SKalle Valo if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) 1882bdcd8170SKalle Valo return -EINVAL; 1883bdcd8170SKalle Valo 1884bdcd8170SKalle Valo if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) 1885bdcd8170SKalle Valo return -EINVAL; 1886bdcd8170SKalle Valo 1887bdcd8170SKalle Valo if (flag & SPECIFIC_SSID_FLAG) 1888bdcd8170SKalle Valo wmi->is_probe_ssid = true; 1889bdcd8170SKalle Valo 1890bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1891bdcd8170SKalle Valo if (!skb) 1892bdcd8170SKalle Valo return -ENOMEM; 1893bdcd8170SKalle Valo 1894bdcd8170SKalle Valo cmd = (struct wmi_probed_ssid_cmd *) skb->data; 1895bdcd8170SKalle Valo cmd->entry_index = index; 1896bdcd8170SKalle Valo cmd->flag = flag; 1897bdcd8170SKalle Valo cmd->ssid_len = ssid_len; 1898bdcd8170SKalle Valo memcpy(cmd->ssid, ssid, ssid_len); 1899bdcd8170SKalle Valo 1900bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID, 1901bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1902bdcd8170SKalle Valo return ret; 1903bdcd8170SKalle Valo } 1904bdcd8170SKalle Valo 1905bdcd8170SKalle Valo int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, 1906bdcd8170SKalle Valo u16 listen_beacons) 1907bdcd8170SKalle Valo { 1908bdcd8170SKalle Valo struct sk_buff *skb; 1909bdcd8170SKalle Valo struct wmi_listen_int_cmd *cmd; 1910bdcd8170SKalle Valo int ret; 1911bdcd8170SKalle Valo 1912bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1913bdcd8170SKalle Valo if (!skb) 1914bdcd8170SKalle Valo return -ENOMEM; 1915bdcd8170SKalle Valo 1916bdcd8170SKalle Valo cmd = (struct wmi_listen_int_cmd *) skb->data; 1917bdcd8170SKalle Valo cmd->listen_intvl = cpu_to_le16(listen_interval); 1918bdcd8170SKalle Valo cmd->num_beacons = cpu_to_le16(listen_beacons); 1919bdcd8170SKalle Valo 1920bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID, 1921bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1922bdcd8170SKalle Valo return ret; 1923bdcd8170SKalle Valo } 1924bdcd8170SKalle Valo 1925bdcd8170SKalle Valo int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode) 1926bdcd8170SKalle Valo { 1927bdcd8170SKalle Valo struct sk_buff *skb; 1928bdcd8170SKalle Valo struct wmi_power_mode_cmd *cmd; 1929bdcd8170SKalle Valo int ret; 1930bdcd8170SKalle Valo 1931bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1932bdcd8170SKalle Valo if (!skb) 1933bdcd8170SKalle Valo return -ENOMEM; 1934bdcd8170SKalle Valo 1935bdcd8170SKalle Valo cmd = (struct wmi_power_mode_cmd *) skb->data; 1936bdcd8170SKalle Valo cmd->pwr_mode = pwr_mode; 1937bdcd8170SKalle Valo wmi->pwr_mode = pwr_mode; 1938bdcd8170SKalle Valo 1939bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID, 1940bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1941bdcd8170SKalle Valo return ret; 1942bdcd8170SKalle Valo } 1943bdcd8170SKalle Valo 1944bdcd8170SKalle Valo int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, 1945bdcd8170SKalle Valo u16 ps_poll_num, u16 dtim_policy, 1946bdcd8170SKalle Valo u16 tx_wakeup_policy, u16 num_tx_to_wakeup, 1947bdcd8170SKalle Valo u16 ps_fail_event_policy) 1948bdcd8170SKalle Valo { 1949bdcd8170SKalle Valo struct sk_buff *skb; 1950bdcd8170SKalle Valo struct wmi_power_params_cmd *pm; 1951bdcd8170SKalle Valo int ret; 1952bdcd8170SKalle Valo 1953bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); 1954bdcd8170SKalle Valo if (!skb) 1955bdcd8170SKalle Valo return -ENOMEM; 1956bdcd8170SKalle Valo 1957bdcd8170SKalle Valo pm = (struct wmi_power_params_cmd *)skb->data; 1958bdcd8170SKalle Valo pm->idle_period = cpu_to_le16(idle_period); 1959bdcd8170SKalle Valo pm->pspoll_number = cpu_to_le16(ps_poll_num); 1960bdcd8170SKalle Valo pm->dtim_policy = cpu_to_le16(dtim_policy); 1961bdcd8170SKalle Valo pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); 1962bdcd8170SKalle Valo pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); 1963bdcd8170SKalle Valo pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); 1964bdcd8170SKalle Valo 1965bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID, 1966bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1967bdcd8170SKalle Valo return ret; 1968bdcd8170SKalle Valo } 1969bdcd8170SKalle Valo 1970bdcd8170SKalle Valo int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) 1971bdcd8170SKalle Valo { 1972bdcd8170SKalle Valo struct sk_buff *skb; 1973bdcd8170SKalle Valo struct wmi_disc_timeout_cmd *cmd; 1974bdcd8170SKalle Valo int ret; 1975bdcd8170SKalle Valo 1976bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1977bdcd8170SKalle Valo if (!skb) 1978bdcd8170SKalle Valo return -ENOMEM; 1979bdcd8170SKalle Valo 1980bdcd8170SKalle Valo cmd = (struct wmi_disc_timeout_cmd *) skb->data; 1981bdcd8170SKalle Valo cmd->discon_timeout = timeout; 1982bdcd8170SKalle Valo 1983bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID, 1984bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1985bdcd8170SKalle Valo return ret; 1986bdcd8170SKalle Valo } 1987bdcd8170SKalle Valo 1988bdcd8170SKalle Valo int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, 1989bdcd8170SKalle Valo enum crypto_type key_type, 1990bdcd8170SKalle Valo u8 key_usage, u8 key_len, 1991bdcd8170SKalle Valo u8 *key_rsc, u8 *key_material, 1992bdcd8170SKalle Valo u8 key_op_ctrl, u8 *mac_addr, 1993bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 1994bdcd8170SKalle Valo { 1995bdcd8170SKalle Valo struct sk_buff *skb; 1996bdcd8170SKalle Valo struct wmi_add_cipher_key_cmd *cmd; 1997bdcd8170SKalle Valo int ret; 1998bdcd8170SKalle Valo 19999a5b1318SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " 20009a5b1318SJouni Malinen "key_usage=%d key_len=%d key_op_ctrl=%d\n", 20019a5b1318SJouni Malinen key_index, key_type, key_usage, key_len, key_op_ctrl); 20029a5b1318SJouni Malinen 2003bdcd8170SKalle Valo if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || 2004bdcd8170SKalle Valo (key_material == NULL)) 2005bdcd8170SKalle Valo return -EINVAL; 2006bdcd8170SKalle Valo 2007bdcd8170SKalle Valo if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) 2008bdcd8170SKalle Valo return -EINVAL; 2009bdcd8170SKalle Valo 2010bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2011bdcd8170SKalle Valo if (!skb) 2012bdcd8170SKalle Valo return -ENOMEM; 2013bdcd8170SKalle Valo 2014bdcd8170SKalle Valo cmd = (struct wmi_add_cipher_key_cmd *) skb->data; 2015bdcd8170SKalle Valo cmd->key_index = key_index; 2016bdcd8170SKalle Valo cmd->key_type = key_type; 2017bdcd8170SKalle Valo cmd->key_usage = key_usage; 2018bdcd8170SKalle Valo cmd->key_len = key_len; 2019bdcd8170SKalle Valo memcpy(cmd->key, key_material, key_len); 2020bdcd8170SKalle Valo 2021bdcd8170SKalle Valo if (key_rsc != NULL) 2022bdcd8170SKalle Valo memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc)); 2023bdcd8170SKalle Valo 2024bdcd8170SKalle Valo cmd->key_op_ctrl = key_op_ctrl; 2025bdcd8170SKalle Valo 2026bdcd8170SKalle Valo if (mac_addr) 2027bdcd8170SKalle Valo memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); 2028bdcd8170SKalle Valo 2029bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID, 2030bdcd8170SKalle Valo sync_flag); 2031bdcd8170SKalle Valo 2032bdcd8170SKalle Valo return ret; 2033bdcd8170SKalle Valo } 2034bdcd8170SKalle Valo 2035bdcd8170SKalle Valo int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) 2036bdcd8170SKalle Valo { 2037bdcd8170SKalle Valo struct sk_buff *skb; 2038bdcd8170SKalle Valo struct wmi_add_krk_cmd *cmd; 2039bdcd8170SKalle Valo int ret; 2040bdcd8170SKalle Valo 2041bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2042bdcd8170SKalle Valo if (!skb) 2043bdcd8170SKalle Valo return -ENOMEM; 2044bdcd8170SKalle Valo 2045bdcd8170SKalle Valo cmd = (struct wmi_add_krk_cmd *) skb->data; 2046bdcd8170SKalle Valo memcpy(cmd->krk, krk, WMI_KRK_LEN); 2047bdcd8170SKalle Valo 2048bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG); 2049bdcd8170SKalle Valo 2050bdcd8170SKalle Valo return ret; 2051bdcd8170SKalle Valo } 2052bdcd8170SKalle Valo 2053bdcd8170SKalle Valo int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index) 2054bdcd8170SKalle Valo { 2055bdcd8170SKalle Valo struct sk_buff *skb; 2056bdcd8170SKalle Valo struct wmi_delete_cipher_key_cmd *cmd; 2057bdcd8170SKalle Valo int ret; 2058bdcd8170SKalle Valo 2059bdcd8170SKalle Valo if (key_index > WMI_MAX_KEY_INDEX) 2060bdcd8170SKalle Valo return -EINVAL; 2061bdcd8170SKalle Valo 2062bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2063bdcd8170SKalle Valo if (!skb) 2064bdcd8170SKalle Valo return -ENOMEM; 2065bdcd8170SKalle Valo 2066bdcd8170SKalle Valo cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; 2067bdcd8170SKalle Valo cmd->key_index = key_index; 2068bdcd8170SKalle Valo 2069bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID, 2070bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2071bdcd8170SKalle Valo 2072bdcd8170SKalle Valo return ret; 2073bdcd8170SKalle Valo } 2074bdcd8170SKalle Valo 2075bdcd8170SKalle Valo int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, 2076bdcd8170SKalle Valo const u8 *pmkid, bool set) 2077bdcd8170SKalle Valo { 2078bdcd8170SKalle Valo struct sk_buff *skb; 2079bdcd8170SKalle Valo struct wmi_setpmkid_cmd *cmd; 2080bdcd8170SKalle Valo int ret; 2081bdcd8170SKalle Valo 2082bdcd8170SKalle Valo if (bssid == NULL) 2083bdcd8170SKalle Valo return -EINVAL; 2084bdcd8170SKalle Valo 2085bdcd8170SKalle Valo if (set && pmkid == NULL) 2086bdcd8170SKalle Valo return -EINVAL; 2087bdcd8170SKalle Valo 2088bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2089bdcd8170SKalle Valo if (!skb) 2090bdcd8170SKalle Valo return -ENOMEM; 2091bdcd8170SKalle Valo 2092bdcd8170SKalle Valo cmd = (struct wmi_setpmkid_cmd *) skb->data; 2093bdcd8170SKalle Valo memcpy(cmd->bssid, bssid, ETH_ALEN); 2094bdcd8170SKalle Valo if (set) { 2095bdcd8170SKalle Valo memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); 2096bdcd8170SKalle Valo cmd->enable = PMKID_ENABLE; 2097bdcd8170SKalle Valo } else { 2098bdcd8170SKalle Valo memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); 2099bdcd8170SKalle Valo cmd->enable = PMKID_DISABLE; 2100bdcd8170SKalle Valo } 2101bdcd8170SKalle Valo 2102bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID, 2103bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2104bdcd8170SKalle Valo 2105bdcd8170SKalle Valo return ret; 2106bdcd8170SKalle Valo } 2107bdcd8170SKalle Valo 2108bdcd8170SKalle Valo static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, 2109bdcd8170SKalle Valo enum htc_endpoint_id ep_id) 2110bdcd8170SKalle Valo { 2111bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 2112bdcd8170SKalle Valo int ret; 2113bdcd8170SKalle Valo 2114bdcd8170SKalle Valo if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) 2115bdcd8170SKalle Valo return -EINVAL; 2116bdcd8170SKalle Valo 2117bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 2118bdcd8170SKalle Valo 2119bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) skb->data; 2120bdcd8170SKalle Valo data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; 2121bdcd8170SKalle Valo data_hdr->info3 = 0; 2122bdcd8170SKalle Valo 2123bdcd8170SKalle Valo ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 2124bdcd8170SKalle Valo 2125bdcd8170SKalle Valo return ret; 2126bdcd8170SKalle Valo } 2127bdcd8170SKalle Valo 2128bdcd8170SKalle Valo static int ath6kl_wmi_sync_point(struct wmi *wmi) 2129bdcd8170SKalle Valo { 2130bdcd8170SKalle Valo struct sk_buff *skb; 2131bdcd8170SKalle Valo struct wmi_sync_cmd *cmd; 2132bdcd8170SKalle Valo struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; 2133bdcd8170SKalle Valo enum htc_endpoint_id ep_id; 2134bdcd8170SKalle Valo u8 index, num_pri_streams = 0; 2135bdcd8170SKalle Valo int ret = 0; 2136bdcd8170SKalle Valo 2137bdcd8170SKalle Valo memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); 2138bdcd8170SKalle Valo 2139bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2140bdcd8170SKalle Valo 2141bdcd8170SKalle Valo for (index = 0; index < WMM_NUM_AC; index++) { 2142bdcd8170SKalle Valo if (wmi->fat_pipe_exist & (1 << index)) { 2143bdcd8170SKalle Valo num_pri_streams++; 2144bdcd8170SKalle Valo data_sync_bufs[num_pri_streams - 1].traffic_class = 2145bdcd8170SKalle Valo index; 2146bdcd8170SKalle Valo } 2147bdcd8170SKalle Valo } 2148bdcd8170SKalle Valo 2149bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2150bdcd8170SKalle Valo 2151bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2152bdcd8170SKalle Valo if (!skb) { 2153bdcd8170SKalle Valo ret = -ENOMEM; 2154bdcd8170SKalle Valo goto free_skb; 2155bdcd8170SKalle Valo } 2156bdcd8170SKalle Valo 2157bdcd8170SKalle Valo cmd = (struct wmi_sync_cmd *) skb->data; 2158bdcd8170SKalle Valo 2159bdcd8170SKalle Valo /* 2160bdcd8170SKalle Valo * In the SYNC cmd sent on the control Ep, send a bitmap 2161bdcd8170SKalle Valo * of the data eps on which the Data Sync will be sent 2162bdcd8170SKalle Valo */ 2163bdcd8170SKalle Valo cmd->data_sync_map = wmi->fat_pipe_exist; 2164bdcd8170SKalle Valo 2165bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2166bdcd8170SKalle Valo data_sync_bufs[index].skb = ath6kl_buf_alloc(0); 2167bdcd8170SKalle Valo if (data_sync_bufs[index].skb == NULL) { 2168bdcd8170SKalle Valo ret = -ENOMEM; 2169bdcd8170SKalle Valo break; 2170bdcd8170SKalle Valo } 2171bdcd8170SKalle Valo } 2172bdcd8170SKalle Valo 2173bdcd8170SKalle Valo /* 2174bdcd8170SKalle Valo * If buffer allocation for any of the dataSync fails, 2175bdcd8170SKalle Valo * then do not send the Synchronize cmd on the control ep 2176bdcd8170SKalle Valo */ 2177bdcd8170SKalle Valo if (ret) 2178bdcd8170SKalle Valo goto free_skb; 2179bdcd8170SKalle Valo 2180bdcd8170SKalle Valo /* 2181bdcd8170SKalle Valo * Send sync cmd followed by sync data messages on all 2182bdcd8170SKalle Valo * endpoints being used 2183bdcd8170SKalle Valo */ 2184bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID, 2185bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2186bdcd8170SKalle Valo 2187bdcd8170SKalle Valo if (ret) 2188bdcd8170SKalle Valo goto free_skb; 2189bdcd8170SKalle Valo 2190bdcd8170SKalle Valo /* cmd buffer sent, we no longer own it */ 2191bdcd8170SKalle Valo skb = NULL; 2192bdcd8170SKalle Valo 2193bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2194bdcd8170SKalle Valo 2195bdcd8170SKalle Valo if (WARN_ON(!data_sync_bufs[index].skb)) 2196bdcd8170SKalle Valo break; 2197bdcd8170SKalle Valo 2198bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, 2199bdcd8170SKalle Valo data_sync_bufs[index]. 2200bdcd8170SKalle Valo traffic_class); 2201bdcd8170SKalle Valo ret = 2202bdcd8170SKalle Valo ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, 2203bdcd8170SKalle Valo ep_id); 2204bdcd8170SKalle Valo 2205bdcd8170SKalle Valo if (ret) 2206bdcd8170SKalle Valo break; 2207bdcd8170SKalle Valo 2208bdcd8170SKalle Valo data_sync_bufs[index].skb = NULL; 2209bdcd8170SKalle Valo } 2210bdcd8170SKalle Valo 2211bdcd8170SKalle Valo free_skb: 2212bdcd8170SKalle Valo /* free up any resources left over (possibly due to an error) */ 2213bdcd8170SKalle Valo if (skb) 2214bdcd8170SKalle Valo dev_kfree_skb(skb); 2215bdcd8170SKalle Valo 2216bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2217bdcd8170SKalle Valo if (data_sync_bufs[index].skb != NULL) { 2218bdcd8170SKalle Valo dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. 2219bdcd8170SKalle Valo skb); 2220bdcd8170SKalle Valo } 2221bdcd8170SKalle Valo } 2222bdcd8170SKalle Valo 2223bdcd8170SKalle Valo return ret; 2224bdcd8170SKalle Valo } 2225bdcd8170SKalle Valo 2226bdcd8170SKalle Valo int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, 2227bdcd8170SKalle Valo struct wmi_create_pstream_cmd *params) 2228bdcd8170SKalle Valo { 2229bdcd8170SKalle Valo struct sk_buff *skb; 2230bdcd8170SKalle Valo struct wmi_create_pstream_cmd *cmd; 2231bdcd8170SKalle Valo u8 fatpipe_exist_for_ac = 0; 2232bdcd8170SKalle Valo s32 min_phy = 0; 2233bdcd8170SKalle Valo s32 nominal_phy = 0; 2234bdcd8170SKalle Valo int ret; 2235bdcd8170SKalle Valo 2236bdcd8170SKalle Valo if (!((params->user_pri < 8) && 2237bdcd8170SKalle Valo (params->user_pri <= 0x7) && 2238bdcd8170SKalle Valo (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && 2239bdcd8170SKalle Valo (params->traffic_direc == UPLINK_TRAFFIC || 2240bdcd8170SKalle Valo params->traffic_direc == DNLINK_TRAFFIC || 2241bdcd8170SKalle Valo params->traffic_direc == BIDIR_TRAFFIC) && 2242bdcd8170SKalle Valo (params->traffic_type == TRAFFIC_TYPE_APERIODIC || 2243bdcd8170SKalle Valo params->traffic_type == TRAFFIC_TYPE_PERIODIC) && 2244bdcd8170SKalle Valo (params->voice_psc_cap == DISABLE_FOR_THIS_AC || 2245bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_THIS_AC || 2246bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_ALL_AC) && 2247bdcd8170SKalle Valo (params->tsid == WMI_IMPLICIT_PSTREAM || 2248bdcd8170SKalle Valo params->tsid <= WMI_MAX_THINSTREAM))) { 2249bdcd8170SKalle Valo return -EINVAL; 2250bdcd8170SKalle Valo } 2251bdcd8170SKalle Valo 2252bdcd8170SKalle Valo /* 2253bdcd8170SKalle Valo * Check nominal PHY rate is >= minimalPHY, 2254bdcd8170SKalle Valo * so that DUT can allow TSRS IE 2255bdcd8170SKalle Valo */ 2256bdcd8170SKalle Valo 2257bdcd8170SKalle Valo /* Get the physical rate (units of bps) */ 2258bdcd8170SKalle Valo min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); 2259bdcd8170SKalle Valo 2260bdcd8170SKalle Valo /* Check minimal phy < nominal phy rate */ 2261bdcd8170SKalle Valo if (params->nominal_phy >= min_phy) { 2262bdcd8170SKalle Valo /* unit of 500 kbps */ 2263bdcd8170SKalle Valo nominal_phy = (params->nominal_phy * 1000) / 500; 2264bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2265bdcd8170SKalle Valo "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", 2266bdcd8170SKalle Valo min_phy, nominal_phy); 2267bdcd8170SKalle Valo 2268bdcd8170SKalle Valo params->nominal_phy = nominal_phy; 2269bdcd8170SKalle Valo } else { 2270bdcd8170SKalle Valo params->nominal_phy = 0; 2271bdcd8170SKalle Valo } 2272bdcd8170SKalle Valo 2273bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2274bdcd8170SKalle Valo if (!skb) 2275bdcd8170SKalle Valo return -ENOMEM; 2276bdcd8170SKalle Valo 2277bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2278bdcd8170SKalle Valo "sending create_pstream_cmd: ac=%d tsid:%d\n", 2279bdcd8170SKalle Valo params->traffic_class, params->tsid); 2280bdcd8170SKalle Valo 2281bdcd8170SKalle Valo cmd = (struct wmi_create_pstream_cmd *) skb->data; 2282bdcd8170SKalle Valo memcpy(cmd, params, sizeof(*cmd)); 2283bdcd8170SKalle Valo 2284bdcd8170SKalle Valo /* This is an implicitly created Fat pipe */ 2285bdcd8170SKalle Valo if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { 2286bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2287bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2288bdcd8170SKalle Valo (1 << params->traffic_class)); 2289bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2290bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2291bdcd8170SKalle Valo } else { 2292bdcd8170SKalle Valo /* explicitly created thin stream within a fat pipe */ 2293bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2294bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2295bdcd8170SKalle Valo (1 << params->traffic_class)); 2296bdcd8170SKalle Valo wmi->stream_exist_for_ac[params->traffic_class] |= 2297bdcd8170SKalle Valo (1 << params->tsid); 2298bdcd8170SKalle Valo /* 2299bdcd8170SKalle Valo * If a thinstream becomes active, the fat pipe automatically 2300bdcd8170SKalle Valo * becomes active 2301bdcd8170SKalle Valo */ 2302bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2303bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2304bdcd8170SKalle Valo } 2305bdcd8170SKalle Valo 2306bdcd8170SKalle Valo /* 2307bdcd8170SKalle Valo * Indicate activty change to driver layer only if this is the 2308bdcd8170SKalle Valo * first TSID to get created in this AC explicitly or an implicit 2309bdcd8170SKalle Valo * fat pipe is getting created. 2310bdcd8170SKalle Valo */ 2311bdcd8170SKalle Valo if (!fatpipe_exist_for_ac) 2312bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2313bdcd8170SKalle Valo params->traffic_class, true); 2314bdcd8170SKalle Valo 2315bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID, 2316bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2317bdcd8170SKalle Valo return ret; 2318bdcd8170SKalle Valo } 2319bdcd8170SKalle Valo 2320bdcd8170SKalle Valo int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) 2321bdcd8170SKalle Valo { 2322bdcd8170SKalle Valo struct sk_buff *skb; 2323bdcd8170SKalle Valo struct wmi_delete_pstream_cmd *cmd; 2324bdcd8170SKalle Valo u16 active_tsids = 0; 2325bdcd8170SKalle Valo int ret; 2326bdcd8170SKalle Valo 2327bdcd8170SKalle Valo if (traffic_class > 3) { 2328bdcd8170SKalle Valo ath6kl_err("invalid traffic class: %d\n", traffic_class); 2329bdcd8170SKalle Valo return -EINVAL; 2330bdcd8170SKalle Valo } 2331bdcd8170SKalle Valo 2332bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2333bdcd8170SKalle Valo if (!skb) 2334bdcd8170SKalle Valo return -ENOMEM; 2335bdcd8170SKalle Valo 2336bdcd8170SKalle Valo cmd = (struct wmi_delete_pstream_cmd *) skb->data; 2337bdcd8170SKalle Valo cmd->traffic_class = traffic_class; 2338bdcd8170SKalle Valo cmd->tsid = tsid; 2339bdcd8170SKalle Valo 2340bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2341bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2342bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2343bdcd8170SKalle Valo 2344bdcd8170SKalle Valo if (!(active_tsids & (1 << tsid))) { 2345bdcd8170SKalle Valo dev_kfree_skb(skb); 2346bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2347bdcd8170SKalle Valo "TSID %d doesn't exist for traffic class: %d\n", 2348bdcd8170SKalle Valo tsid, traffic_class); 2349bdcd8170SKalle Valo return -ENODATA; 2350bdcd8170SKalle Valo } 2351bdcd8170SKalle Valo 2352bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2353bdcd8170SKalle Valo "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", 2354bdcd8170SKalle Valo traffic_class, tsid); 2355bdcd8170SKalle Valo 2356bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID, 2357bdcd8170SKalle Valo SYNC_BEFORE_WMIFLAG); 2358bdcd8170SKalle Valo 2359bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2360bdcd8170SKalle Valo wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); 2361bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2362bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2363bdcd8170SKalle Valo 2364bdcd8170SKalle Valo /* 2365bdcd8170SKalle Valo * Indicate stream inactivity to driver layer only if all tsids 2366bdcd8170SKalle Valo * within this AC are deleted. 2367bdcd8170SKalle Valo */ 2368bdcd8170SKalle Valo if (!active_tsids) { 2369bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2370bdcd8170SKalle Valo traffic_class, false); 2371bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << traffic_class); 2372bdcd8170SKalle Valo } 2373bdcd8170SKalle Valo 2374bdcd8170SKalle Valo return ret; 2375bdcd8170SKalle Valo } 2376bdcd8170SKalle Valo 2377bdcd8170SKalle Valo int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) 2378bdcd8170SKalle Valo { 2379bdcd8170SKalle Valo struct sk_buff *skb; 2380bdcd8170SKalle Valo struct wmi_set_ip_cmd *cmd; 2381bdcd8170SKalle Valo int ret; 2382bdcd8170SKalle Valo 2383bdcd8170SKalle Valo /* Multicast address are not valid */ 2384bdcd8170SKalle Valo if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) || 2385bdcd8170SKalle Valo (*((u8 *) &ip_cmd->ips[1]) >= 0xE0)) 2386bdcd8170SKalle Valo return -EINVAL; 2387bdcd8170SKalle Valo 2388bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); 2389bdcd8170SKalle Valo if (!skb) 2390bdcd8170SKalle Valo return -ENOMEM; 2391bdcd8170SKalle Valo 2392bdcd8170SKalle Valo cmd = (struct wmi_set_ip_cmd *) skb->data; 2393bdcd8170SKalle Valo memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); 2394bdcd8170SKalle Valo 2395bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG); 2396bdcd8170SKalle Valo return ret; 2397bdcd8170SKalle Valo } 2398bdcd8170SKalle Valo 2399bdcd8170SKalle Valo static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, 2400bdcd8170SKalle Valo int len) 2401bdcd8170SKalle Valo { 2402bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_wow_list_reply)) 2403bdcd8170SKalle Valo return -EINVAL; 2404bdcd8170SKalle Valo 2405bdcd8170SKalle Valo return 0; 2406bdcd8170SKalle Valo } 2407bdcd8170SKalle Valo 2408bdcd8170SKalle Valo static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, 2409bdcd8170SKalle Valo enum wmix_command_id cmd_id, 2410bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2411bdcd8170SKalle Valo { 2412bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd_hdr; 2413bdcd8170SKalle Valo int ret; 2414bdcd8170SKalle Valo 2415bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmix_cmd_hdr)); 2416bdcd8170SKalle Valo 2417bdcd8170SKalle Valo cmd_hdr = (struct wmix_cmd_hdr *) skb->data; 2418bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le32(cmd_id); 2419bdcd8170SKalle Valo 2420bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag); 2421bdcd8170SKalle Valo 2422bdcd8170SKalle Valo return ret; 2423bdcd8170SKalle Valo } 2424bdcd8170SKalle Valo 2425bdcd8170SKalle Valo int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) 2426bdcd8170SKalle Valo { 2427bdcd8170SKalle Valo struct sk_buff *skb; 2428bdcd8170SKalle Valo struct wmix_hb_challenge_resp_cmd *cmd; 2429bdcd8170SKalle Valo int ret; 2430bdcd8170SKalle Valo 2431bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2432bdcd8170SKalle Valo if (!skb) 2433bdcd8170SKalle Valo return -ENOMEM; 2434bdcd8170SKalle Valo 2435bdcd8170SKalle Valo cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; 2436bdcd8170SKalle Valo cmd->cookie = cpu_to_le32(cookie); 2437bdcd8170SKalle Valo cmd->source = cpu_to_le32(source); 2438bdcd8170SKalle Valo 2439bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, 2440bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2441bdcd8170SKalle Valo return ret; 2442bdcd8170SKalle Valo } 2443bdcd8170SKalle Valo 2444939f1cceSKalle Valo int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config) 2445939f1cceSKalle Valo { 2446939f1cceSKalle Valo struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd; 2447939f1cceSKalle Valo struct sk_buff *skb; 2448939f1cceSKalle Valo int ret; 2449939f1cceSKalle Valo 2450939f1cceSKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2451939f1cceSKalle Valo if (!skb) 2452939f1cceSKalle Valo return -ENOMEM; 2453939f1cceSKalle Valo 2454939f1cceSKalle Valo cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data; 2455939f1cceSKalle Valo cmd->valid = cpu_to_le32(valid); 2456939f1cceSKalle Valo cmd->config = cpu_to_le32(config); 2457939f1cceSKalle Valo 2458939f1cceSKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID, 2459939f1cceSKalle Valo NO_SYNC_WMIFLAG); 2460939f1cceSKalle Valo return ret; 2461939f1cceSKalle Valo } 2462939f1cceSKalle Valo 2463bdcd8170SKalle Valo int ath6kl_wmi_get_stats_cmd(struct wmi *wmi) 2464bdcd8170SKalle Valo { 2465bdcd8170SKalle Valo return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID); 2466bdcd8170SKalle Valo } 2467bdcd8170SKalle Valo 2468bdcd8170SKalle Valo int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) 2469bdcd8170SKalle Valo { 2470bdcd8170SKalle Valo struct sk_buff *skb; 2471bdcd8170SKalle Valo struct wmi_set_tx_pwr_cmd *cmd; 2472bdcd8170SKalle Valo int ret; 2473bdcd8170SKalle Valo 2474bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); 2475bdcd8170SKalle Valo if (!skb) 2476bdcd8170SKalle Valo return -ENOMEM; 2477bdcd8170SKalle Valo 2478bdcd8170SKalle Valo cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; 2479bdcd8170SKalle Valo cmd->dbM = dbM; 2480bdcd8170SKalle Valo 2481bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID, 2482bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2483bdcd8170SKalle Valo 2484bdcd8170SKalle Valo return ret; 2485bdcd8170SKalle Valo } 2486bdcd8170SKalle Valo 2487bdcd8170SKalle Valo int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) 2488bdcd8170SKalle Valo { 2489bdcd8170SKalle Valo return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID); 2490bdcd8170SKalle Valo } 2491bdcd8170SKalle Valo 2492bdcd8170SKalle Valo int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) 2493bdcd8170SKalle Valo { 2494bdcd8170SKalle Valo struct sk_buff *skb; 2495bdcd8170SKalle Valo struct wmi_set_lpreamble_cmd *cmd; 2496bdcd8170SKalle Valo int ret; 2497bdcd8170SKalle Valo 2498bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); 2499bdcd8170SKalle Valo if (!skb) 2500bdcd8170SKalle Valo return -ENOMEM; 2501bdcd8170SKalle Valo 2502bdcd8170SKalle Valo cmd = (struct wmi_set_lpreamble_cmd *) skb->data; 2503bdcd8170SKalle Valo cmd->status = status; 2504bdcd8170SKalle Valo cmd->preamble_policy = preamble_policy; 2505bdcd8170SKalle Valo 2506bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID, 2507bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2508bdcd8170SKalle Valo return ret; 2509bdcd8170SKalle Valo } 2510bdcd8170SKalle Valo 2511bdcd8170SKalle Valo int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) 2512bdcd8170SKalle Valo { 2513bdcd8170SKalle Valo struct sk_buff *skb; 2514bdcd8170SKalle Valo struct wmi_set_rts_cmd *cmd; 2515bdcd8170SKalle Valo int ret; 2516bdcd8170SKalle Valo 2517bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); 2518bdcd8170SKalle Valo if (!skb) 2519bdcd8170SKalle Valo return -ENOMEM; 2520bdcd8170SKalle Valo 2521bdcd8170SKalle Valo cmd = (struct wmi_set_rts_cmd *) skb->data; 2522bdcd8170SKalle Valo cmd->threshold = cpu_to_le16(threshold); 2523bdcd8170SKalle Valo 2524bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG); 2525bdcd8170SKalle Valo return ret; 2526bdcd8170SKalle Valo } 2527bdcd8170SKalle Valo 2528bdcd8170SKalle Valo int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) 2529bdcd8170SKalle Valo { 2530bdcd8170SKalle Valo struct sk_buff *skb; 2531bdcd8170SKalle Valo struct wmi_set_wmm_txop_cmd *cmd; 2532bdcd8170SKalle Valo int ret; 2533bdcd8170SKalle Valo 2534bdcd8170SKalle Valo if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) 2535bdcd8170SKalle Valo return -EINVAL; 2536bdcd8170SKalle Valo 2537bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); 2538bdcd8170SKalle Valo if (!skb) 2539bdcd8170SKalle Valo return -ENOMEM; 2540bdcd8170SKalle Valo 2541bdcd8170SKalle Valo cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; 2542bdcd8170SKalle Valo cmd->txop_enable = cfg; 2543bdcd8170SKalle Valo 2544bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID, 2545bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2546bdcd8170SKalle Valo return ret; 2547bdcd8170SKalle Valo } 2548bdcd8170SKalle Valo 2549bdcd8170SKalle Valo int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) 2550bdcd8170SKalle Valo { 2551bdcd8170SKalle Valo struct sk_buff *skb; 2552bdcd8170SKalle Valo struct wmi_set_keepalive_cmd *cmd; 2553bdcd8170SKalle Valo int ret; 2554bdcd8170SKalle Valo 2555bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2556bdcd8170SKalle Valo if (!skb) 2557bdcd8170SKalle Valo return -ENOMEM; 2558bdcd8170SKalle Valo 2559bdcd8170SKalle Valo cmd = (struct wmi_set_keepalive_cmd *) skb->data; 2560bdcd8170SKalle Valo cmd->keep_alive_intvl = keep_alive_intvl; 2561bdcd8170SKalle Valo wmi->keep_alive_intvl = keep_alive_intvl; 2562bdcd8170SKalle Valo 2563bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, 2564bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2565bdcd8170SKalle Valo return ret; 2566bdcd8170SKalle Valo } 2567bdcd8170SKalle Valo 2568003353b0SKalle Valo int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) 2569003353b0SKalle Valo { 2570003353b0SKalle Valo struct sk_buff *skb; 2571003353b0SKalle Valo int ret; 2572003353b0SKalle Valo 2573003353b0SKalle Valo skb = ath6kl_wmi_get_new_buf(len); 2574003353b0SKalle Valo if (!skb) 2575003353b0SKalle Valo return -ENOMEM; 2576003353b0SKalle Valo 2577003353b0SKalle Valo memcpy(skb->data, buf, len); 2578003353b0SKalle Valo 2579003353b0SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); 2580003353b0SKalle Valo 2581003353b0SKalle Valo return ret; 2582003353b0SKalle Valo } 2583003353b0SKalle Valo 2584003353b0SKalle Valo 2585bdcd8170SKalle Valo s32 ath6kl_wmi_get_rate(s8 rate_index) 2586bdcd8170SKalle Valo { 2587bdcd8170SKalle Valo if (rate_index == RATE_AUTO) 2588bdcd8170SKalle Valo return 0; 2589bdcd8170SKalle Valo 2590bdcd8170SKalle Valo return wmi_rate_tbl[(u32) rate_index][0]; 2591bdcd8170SKalle Valo } 2592bdcd8170SKalle Valo 2593bdcd8170SKalle Valo void ath6kl_wmi_node_return(struct wmi *wmi, struct bss *bss) 2594bdcd8170SKalle Valo { 2595bdcd8170SKalle Valo if (bss) 25967c3075e9SVasanthakumar Thiagarajan wlan_node_return(&wmi->parent_dev->scan_table, bss); 2597bdcd8170SKalle Valo } 2598bdcd8170SKalle Valo 2599bdcd8170SKalle Valo struct bss *ath6kl_wmi_find_ssid_node(struct wmi *wmi, u8 * ssid, 2600bdcd8170SKalle Valo u32 ssid_len, bool is_wpa2, 2601bdcd8170SKalle Valo bool match_ssid) 2602bdcd8170SKalle Valo { 2603bdcd8170SKalle Valo struct bss *node = NULL; 2604bdcd8170SKalle Valo 26057c3075e9SVasanthakumar Thiagarajan node = wlan_find_ssid_node(&wmi->parent_dev->scan_table, ssid, 2606bdcd8170SKalle Valo ssid_len, is_wpa2, match_ssid); 2607bdcd8170SKalle Valo return node; 2608bdcd8170SKalle Valo } 2609bdcd8170SKalle Valo 2610bdcd8170SKalle Valo struct bss *ath6kl_wmi_find_node(struct wmi *wmi, const u8 * mac_addr) 2611bdcd8170SKalle Valo { 2612bdcd8170SKalle Valo struct bss *ni = NULL; 2613bdcd8170SKalle Valo 26147c3075e9SVasanthakumar Thiagarajan ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); 2615bdcd8170SKalle Valo 2616bdcd8170SKalle Valo return ni; 2617bdcd8170SKalle Valo } 2618bdcd8170SKalle Valo 2619bdcd8170SKalle Valo void ath6kl_wmi_node_free(struct wmi *wmi, const u8 * mac_addr) 2620bdcd8170SKalle Valo { 2621bdcd8170SKalle Valo struct bss *ni = NULL; 2622bdcd8170SKalle Valo 26237c3075e9SVasanthakumar Thiagarajan ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); 2624bdcd8170SKalle Valo if (ni != NULL) 26257c3075e9SVasanthakumar Thiagarajan wlan_node_reclaim(&wmi->parent_dev->scan_table, ni); 2626bdcd8170SKalle Valo 2627bdcd8170SKalle Valo return; 2628bdcd8170SKalle Valo } 2629bdcd8170SKalle Valo 2630bdcd8170SKalle Valo static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, 2631bdcd8170SKalle Valo u32 len) 2632bdcd8170SKalle Valo { 2633bdcd8170SKalle Valo struct wmi_pmkid_list_reply *reply; 2634bdcd8170SKalle Valo u32 expected_len; 2635bdcd8170SKalle Valo 2636bdcd8170SKalle Valo if (len < sizeof(struct wmi_pmkid_list_reply)) 2637bdcd8170SKalle Valo return -EINVAL; 2638bdcd8170SKalle Valo 2639bdcd8170SKalle Valo reply = (struct wmi_pmkid_list_reply *)datap; 2640bdcd8170SKalle Valo expected_len = sizeof(reply->num_pmkid) + 2641bdcd8170SKalle Valo le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; 2642bdcd8170SKalle Valo 2643bdcd8170SKalle Valo if (len < expected_len) 2644bdcd8170SKalle Valo return -EINVAL; 2645bdcd8170SKalle Valo 2646bdcd8170SKalle Valo return 0; 2647bdcd8170SKalle Valo } 2648bdcd8170SKalle Valo 2649bdcd8170SKalle Valo static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2650bdcd8170SKalle Valo { 2651bdcd8170SKalle Valo struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; 2652bdcd8170SKalle Valo 2653bdcd8170SKalle Valo aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid, 2654bdcd8170SKalle Valo le16_to_cpu(cmd->st_seq_no), cmd->win_sz); 2655bdcd8170SKalle Valo 2656bdcd8170SKalle Valo return 0; 2657bdcd8170SKalle Valo } 2658bdcd8170SKalle Valo 2659bdcd8170SKalle Valo static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2660bdcd8170SKalle Valo { 2661bdcd8170SKalle Valo struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; 2662bdcd8170SKalle Valo 2663bdcd8170SKalle Valo aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid); 2664bdcd8170SKalle Valo 2665bdcd8170SKalle Valo return 0; 2666bdcd8170SKalle Valo } 2667bdcd8170SKalle Valo 2668bdcd8170SKalle Valo /* AP mode functions */ 26696a7c9badSJouni Malinen 26706a7c9badSJouni Malinen int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) 26716a7c9badSJouni Malinen { 26726a7c9badSJouni Malinen struct sk_buff *skb; 26736a7c9badSJouni Malinen struct wmi_connect_cmd *cm; 26746a7c9badSJouni Malinen int res; 26756a7c9badSJouni Malinen 26766a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 26776a7c9badSJouni Malinen if (!skb) 26786a7c9badSJouni Malinen return -ENOMEM; 26796a7c9badSJouni Malinen 26806a7c9badSJouni Malinen cm = (struct wmi_connect_cmd *) skb->data; 26816a7c9badSJouni Malinen memcpy(cm, p, sizeof(*cm)); 26826a7c9badSJouni Malinen 26836a7c9badSJouni Malinen res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID, 26846a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 26856a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " 26866a7c9badSJouni Malinen "ctrl_flags=0x%x-> res=%d\n", 26876a7c9badSJouni Malinen __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), 26886a7c9badSJouni Malinen le32_to_cpu(p->ctrl_flags), res); 26896a7c9badSJouni Malinen return res; 26906a7c9badSJouni Malinen } 26916a7c9badSJouni Malinen 269223875136SJouni Malinen int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason) 269323875136SJouni Malinen { 269423875136SJouni Malinen struct sk_buff *skb; 269523875136SJouni Malinen struct wmi_ap_set_mlme_cmd *cm; 269623875136SJouni Malinen 269723875136SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 269823875136SJouni Malinen if (!skb) 269923875136SJouni Malinen return -ENOMEM; 270023875136SJouni Malinen 270123875136SJouni Malinen cm = (struct wmi_ap_set_mlme_cmd *) skb->data; 270223875136SJouni Malinen memcpy(cm->mac, mac, ETH_ALEN); 270323875136SJouni Malinen cm->reason = cpu_to_le16(reason); 270423875136SJouni Malinen cm->cmd = cmd; 270523875136SJouni Malinen 270623875136SJouni Malinen return ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_SET_MLME_CMDID, 270723875136SJouni Malinen NO_SYNC_WMIFLAG); 270823875136SJouni Malinen } 270923875136SJouni Malinen 2710bdcd8170SKalle Valo static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len) 2711bdcd8170SKalle Valo { 2712bdcd8170SKalle Valo struct wmi_pspoll_event *ev; 2713bdcd8170SKalle Valo 2714bdcd8170SKalle Valo if (len < sizeof(struct wmi_pspoll_event)) 2715bdcd8170SKalle Valo return -EINVAL; 2716bdcd8170SKalle Valo 2717bdcd8170SKalle Valo ev = (struct wmi_pspoll_event *) datap; 2718bdcd8170SKalle Valo 2719bdcd8170SKalle Valo ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid)); 2720bdcd8170SKalle Valo 2721bdcd8170SKalle Valo return 0; 2722bdcd8170SKalle Valo } 2723bdcd8170SKalle Valo 2724bdcd8170SKalle Valo static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len) 2725bdcd8170SKalle Valo { 2726bdcd8170SKalle Valo ath6kl_dtimexpiry_event(wmi->parent_dev); 2727bdcd8170SKalle Valo 2728bdcd8170SKalle Valo return 0; 2729bdcd8170SKalle Valo } 2730bdcd8170SKalle Valo 2731bdcd8170SKalle Valo int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag) 2732bdcd8170SKalle Valo { 2733bdcd8170SKalle Valo struct sk_buff *skb; 2734bdcd8170SKalle Valo struct wmi_ap_set_pvb_cmd *cmd; 2735bdcd8170SKalle Valo int ret; 2736bdcd8170SKalle Valo 2737bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); 2738bdcd8170SKalle Valo if (!skb) 2739bdcd8170SKalle Valo return -ENOMEM; 2740bdcd8170SKalle Valo 2741bdcd8170SKalle Valo cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; 2742bdcd8170SKalle Valo cmd->aid = cpu_to_le16(aid); 2743bdcd8170SKalle Valo cmd->flag = cpu_to_le32(flag); 2744bdcd8170SKalle Valo 2745bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID, 2746bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2747bdcd8170SKalle Valo 2748bdcd8170SKalle Valo return 0; 2749bdcd8170SKalle Valo } 2750bdcd8170SKalle Valo 2751bdcd8170SKalle Valo int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, 2752bdcd8170SKalle Valo bool rx_dot11_hdr, bool defrag_on_host) 2753bdcd8170SKalle Valo { 2754bdcd8170SKalle Valo struct sk_buff *skb; 2755bdcd8170SKalle Valo struct wmi_rx_frame_format_cmd *cmd; 2756bdcd8170SKalle Valo int ret; 2757bdcd8170SKalle Valo 2758bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2759bdcd8170SKalle Valo if (!skb) 2760bdcd8170SKalle Valo return -ENOMEM; 2761bdcd8170SKalle Valo 2762bdcd8170SKalle Valo cmd = (struct wmi_rx_frame_format_cmd *) skb->data; 2763bdcd8170SKalle Valo cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; 2764bdcd8170SKalle Valo cmd->defrag_on_host = defrag_on_host ? 1 : 0; 2765bdcd8170SKalle Valo cmd->meta_ver = rx_meta_ver; 2766bdcd8170SKalle Valo 2767bdcd8170SKalle Valo /* Delete the local aggr state, on host */ 2768bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID, 2769bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2770bdcd8170SKalle Valo 2771bdcd8170SKalle Valo return ret; 2772bdcd8170SKalle Valo } 2773bdcd8170SKalle Valo 27746a7c9badSJouni Malinen int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, 27756a7c9badSJouni Malinen u8 ie_len) 27766a7c9badSJouni Malinen { 27776a7c9badSJouni Malinen struct sk_buff *skb; 27786a7c9badSJouni Malinen struct wmi_set_appie_cmd *p; 27796a7c9badSJouni Malinen 27806a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 27816a7c9badSJouni Malinen if (!skb) 27826a7c9badSJouni Malinen return -ENOMEM; 27836a7c9badSJouni Malinen 27846a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " 27856a7c9badSJouni Malinen "ie_len=%u\n", mgmt_frm_type, ie_len); 27866a7c9badSJouni Malinen p = (struct wmi_set_appie_cmd *) skb->data; 27876a7c9badSJouni Malinen p->mgmt_frm_type = mgmt_frm_type; 27886a7c9badSJouni Malinen p->ie_len = ie_len; 27896a7c9badSJouni Malinen memcpy(p->ie_info, ie, ie_len); 27906a7c9badSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID, 27916a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 27926a7c9badSJouni Malinen } 27936a7c9badSJouni Malinen 27946465ddcfSJouni Malinen int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) 27956465ddcfSJouni Malinen { 27966465ddcfSJouni Malinen struct sk_buff *skb; 27976465ddcfSJouni Malinen struct wmi_disable_11b_rates_cmd *cmd; 27986465ddcfSJouni Malinen 27996465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 28006465ddcfSJouni Malinen if (!skb) 28016465ddcfSJouni Malinen return -ENOMEM; 28026465ddcfSJouni Malinen 28036465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", 28046465ddcfSJouni Malinen disable); 28056465ddcfSJouni Malinen cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; 28066465ddcfSJouni Malinen cmd->disable = disable ? 1 : 0; 28076465ddcfSJouni Malinen 28086465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_DISABLE_11B_RATES_CMDID, 28096465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28106465ddcfSJouni Malinen } 28116465ddcfSJouni Malinen 28126465ddcfSJouni Malinen int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur) 28136465ddcfSJouni Malinen { 28146465ddcfSJouni Malinen struct sk_buff *skb; 28156465ddcfSJouni Malinen struct wmi_remain_on_chnl_cmd *p; 28166465ddcfSJouni Malinen 28176465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 28186465ddcfSJouni Malinen if (!skb) 28196465ddcfSJouni Malinen return -ENOMEM; 28206465ddcfSJouni Malinen 28216465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", 28226465ddcfSJouni Malinen freq, dur); 28236465ddcfSJouni Malinen p = (struct wmi_remain_on_chnl_cmd *) skb->data; 28246465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 28256465ddcfSJouni Malinen p->duration = cpu_to_le32(dur); 28266465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_REMAIN_ON_CHNL_CMDID, 28276465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28286465ddcfSJouni Malinen } 28296465ddcfSJouni Malinen 28306465ddcfSJouni Malinen int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait, 28316465ddcfSJouni Malinen const u8 *data, u16 data_len) 28326465ddcfSJouni Malinen { 28336465ddcfSJouni Malinen struct sk_buff *skb; 28346465ddcfSJouni Malinen struct wmi_send_action_cmd *p; 2835a0df5db1SJouni Malinen u8 *buf; 28366465ddcfSJouni Malinen 28376465ddcfSJouni Malinen if (wait) 28386465ddcfSJouni Malinen return -EINVAL; /* Offload for wait not supported */ 28396465ddcfSJouni Malinen 2840a0df5db1SJouni Malinen buf = kmalloc(data_len, GFP_KERNEL); 2841a0df5db1SJouni Malinen if (!buf) 28426465ddcfSJouni Malinen return -ENOMEM; 28436465ddcfSJouni Malinen 2844a0df5db1SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 2845a0df5db1SJouni Malinen if (!skb) { 2846a0df5db1SJouni Malinen kfree(buf); 2847a0df5db1SJouni Malinen return -ENOMEM; 2848a0df5db1SJouni Malinen } 2849a0df5db1SJouni Malinen 2850a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 2851a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = buf; 2852a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = data_len; 2853a0df5db1SJouni Malinen 28546465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " 28556465ddcfSJouni Malinen "len=%u\n", id, freq, wait, data_len); 28566465ddcfSJouni Malinen p = (struct wmi_send_action_cmd *) skb->data; 28576465ddcfSJouni Malinen p->id = cpu_to_le32(id); 28586465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 28596465ddcfSJouni Malinen p->wait = cpu_to_le32(wait); 28606465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 28616465ddcfSJouni Malinen memcpy(p->data, data, data_len); 28626465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_ACTION_CMDID, 28636465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28646465ddcfSJouni Malinen } 28656465ddcfSJouni Malinen 28666465ddcfSJouni Malinen int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq, 28676465ddcfSJouni Malinen const u8 *dst, 28686465ddcfSJouni Malinen const u8 *data, u16 data_len) 28696465ddcfSJouni Malinen { 28706465ddcfSJouni Malinen struct sk_buff *skb; 28716465ddcfSJouni Malinen struct wmi_p2p_probe_response_cmd *p; 28726465ddcfSJouni Malinen 28736465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 28746465ddcfSJouni Malinen if (!skb) 28756465ddcfSJouni Malinen return -ENOMEM; 28766465ddcfSJouni Malinen 28776465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM " 28786465ddcfSJouni Malinen "len=%u\n", freq, dst, data_len); 28796465ddcfSJouni Malinen p = (struct wmi_p2p_probe_response_cmd *) skb->data; 28806465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 28816465ddcfSJouni Malinen memcpy(p->destination_addr, dst, ETH_ALEN); 28826465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 28836465ddcfSJouni Malinen memcpy(p->data, data, data_len); 28846465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_PROBE_RESPONSE_CMDID, 28856465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28866465ddcfSJouni Malinen } 28876465ddcfSJouni Malinen 28886465ddcfSJouni Malinen int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable) 28896465ddcfSJouni Malinen { 28906465ddcfSJouni Malinen struct sk_buff *skb; 28916465ddcfSJouni Malinen struct wmi_probe_req_report_cmd *p; 28926465ddcfSJouni Malinen 28936465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 28946465ddcfSJouni Malinen if (!skb) 28956465ddcfSJouni Malinen return -ENOMEM; 28966465ddcfSJouni Malinen 28976465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", 28986465ddcfSJouni Malinen enable); 28996465ddcfSJouni Malinen p = (struct wmi_probe_req_report_cmd *) skb->data; 29006465ddcfSJouni Malinen p->enable = enable ? 1 : 0; 29016465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_PROBE_REQ_REPORT_CMDID, 29026465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 29036465ddcfSJouni Malinen } 29046465ddcfSJouni Malinen 29056465ddcfSJouni Malinen int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags) 29066465ddcfSJouni Malinen { 29076465ddcfSJouni Malinen struct sk_buff *skb; 29086465ddcfSJouni Malinen struct wmi_get_p2p_info *p; 29096465ddcfSJouni Malinen 29106465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 29116465ddcfSJouni Malinen if (!skb) 29126465ddcfSJouni Malinen return -ENOMEM; 29136465ddcfSJouni Malinen 29146465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", 29156465ddcfSJouni Malinen info_req_flags); 29166465ddcfSJouni Malinen p = (struct wmi_get_p2p_info *) skb->data; 29176465ddcfSJouni Malinen p->info_req_flags = cpu_to_le32(info_req_flags); 29186465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_GET_P2P_INFO_CMDID, 29196465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 29206465ddcfSJouni Malinen } 29216465ddcfSJouni Malinen 29226465ddcfSJouni Malinen int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi) 29236465ddcfSJouni Malinen { 29246465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); 29256465ddcfSJouni Malinen return ath6kl_wmi_simple_cmd(wmi, WMI_CANCEL_REMAIN_ON_CHNL_CMDID); 29266465ddcfSJouni Malinen } 29276465ddcfSJouni Malinen 2928bdcd8170SKalle Valo static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) 2929bdcd8170SKalle Valo { 2930bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd; 2931bdcd8170SKalle Valo u32 len; 2932bdcd8170SKalle Valo u16 id; 2933bdcd8170SKalle Valo u8 *datap; 2934bdcd8170SKalle Valo int ret = 0; 2935bdcd8170SKalle Valo 2936bdcd8170SKalle Valo if (skb->len < sizeof(struct wmix_cmd_hdr)) { 2937bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 2938bdcd8170SKalle Valo wmi->stat.cmd_len_err++; 2939bdcd8170SKalle Valo return -EINVAL; 2940bdcd8170SKalle Valo } 2941bdcd8170SKalle Valo 2942bdcd8170SKalle Valo cmd = (struct wmix_cmd_hdr *) skb->data; 2943bdcd8170SKalle Valo id = le32_to_cpu(cmd->cmd_id); 2944bdcd8170SKalle Valo 2945bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmix_cmd_hdr)); 2946bdcd8170SKalle Valo 2947bdcd8170SKalle Valo datap = skb->data; 2948bdcd8170SKalle Valo len = skb->len; 2949bdcd8170SKalle Valo 2950bdcd8170SKalle Valo switch (id) { 2951bdcd8170SKalle Valo case WMIX_HB_CHALLENGE_RESP_EVENTID: 2952bdcd8170SKalle Valo break; 2953bdcd8170SKalle Valo case WMIX_DBGLOG_EVENTID: 2954bdf5396bSKalle Valo ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len); 2955bdcd8170SKalle Valo break; 2956bdcd8170SKalle Valo default: 2957bdcd8170SKalle Valo ath6kl_err("unknown cmd id 0x%x\n", id); 2958bdcd8170SKalle Valo wmi->stat.cmd_id_err++; 2959bdcd8170SKalle Valo ret = -EINVAL; 2960bdcd8170SKalle Valo break; 2961bdcd8170SKalle Valo } 2962bdcd8170SKalle Valo 2963bdcd8170SKalle Valo return ret; 2964bdcd8170SKalle Valo } 2965bdcd8170SKalle Valo 2966bdcd8170SKalle Valo /* Control Path */ 2967bdcd8170SKalle Valo int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) 2968bdcd8170SKalle Valo { 2969bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd; 2970bdcd8170SKalle Valo u32 len; 2971bdcd8170SKalle Valo u16 id; 2972bdcd8170SKalle Valo u8 *datap; 2973bdcd8170SKalle Valo int ret = 0; 2974bdcd8170SKalle Valo 2975bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 2976bdcd8170SKalle Valo return -EINVAL; 2977bdcd8170SKalle Valo 2978bdcd8170SKalle Valo if (skb->len < sizeof(struct wmi_cmd_hdr)) { 2979bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 2980bdcd8170SKalle Valo dev_kfree_skb(skb); 2981bdcd8170SKalle Valo wmi->stat.cmd_len_err++; 2982bdcd8170SKalle Valo return -EINVAL; 2983bdcd8170SKalle Valo } 2984bdcd8170SKalle Valo 2985bdcd8170SKalle Valo cmd = (struct wmi_cmd_hdr *) skb->data; 2986bdcd8170SKalle Valo id = le16_to_cpu(cmd->cmd_id); 2987bdcd8170SKalle Valo 2988bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmi_cmd_hdr)); 2989bdcd8170SKalle Valo 2990bdcd8170SKalle Valo datap = skb->data; 2991bdcd8170SKalle Valo len = skb->len; 2992bdcd8170SKalle Valo 2993bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "%s: wmi id: %d\n", __func__, id); 2994bdcd8170SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "msg payload ", datap, len); 2995bdcd8170SKalle Valo 2996bdcd8170SKalle Valo switch (id) { 2997bdcd8170SKalle Valo case WMI_GET_BITRATE_CMDID: 2998bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); 2999bdcd8170SKalle Valo ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); 3000bdcd8170SKalle Valo break; 3001bdcd8170SKalle Valo case WMI_GET_CHANNEL_LIST_CMDID: 3002bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); 3003bdcd8170SKalle Valo ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); 3004bdcd8170SKalle Valo break; 3005bdcd8170SKalle Valo case WMI_GET_TX_PWR_CMDID: 3006bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); 3007bdcd8170SKalle Valo ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); 3008bdcd8170SKalle Valo break; 3009bdcd8170SKalle Valo case WMI_READY_EVENTID: 3010bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); 3011bdcd8170SKalle Valo ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); 3012bdcd8170SKalle Valo break; 3013bdcd8170SKalle Valo case WMI_CONNECT_EVENTID: 3014bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); 3015bdcd8170SKalle Valo ret = ath6kl_wmi_connect_event_rx(wmi, datap, len); 3016bdcd8170SKalle Valo break; 3017bdcd8170SKalle Valo case WMI_DISCONNECT_EVENTID: 3018bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); 3019bdcd8170SKalle Valo ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len); 3020bdcd8170SKalle Valo break; 3021bdcd8170SKalle Valo case WMI_PEER_NODE_EVENTID: 3022bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); 3023bdcd8170SKalle Valo ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); 3024bdcd8170SKalle Valo break; 3025bdcd8170SKalle Valo case WMI_TKIP_MICERR_EVENTID: 3026bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); 3027bdcd8170SKalle Valo ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len); 3028bdcd8170SKalle Valo break; 3029bdcd8170SKalle Valo case WMI_BSSINFO_EVENTID: 3030bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); 3031bdcd8170SKalle Valo ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb, datap); 3032bdcd8170SKalle Valo ret = ath6kl_wmi_bssinfo_event_rx(wmi, skb->data, skb->len); 3033bdcd8170SKalle Valo break; 3034bdcd8170SKalle Valo case WMI_REGDOMAIN_EVENTID: 3035bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); 3036bdcd8170SKalle Valo break; 3037bdcd8170SKalle Valo case WMI_PSTREAM_TIMEOUT_EVENTID: 3038bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); 3039bdcd8170SKalle Valo ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); 3040bdcd8170SKalle Valo break; 3041bdcd8170SKalle Valo case WMI_NEIGHBOR_REPORT_EVENTID: 3042bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); 3043bdcd8170SKalle Valo break; 3044bdcd8170SKalle Valo case WMI_SCAN_COMPLETE_EVENTID: 3045bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); 3046bdcd8170SKalle Valo ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len); 3047bdcd8170SKalle Valo break; 3048bdcd8170SKalle Valo case WMI_CMDERROR_EVENTID: 3049bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); 3050bdcd8170SKalle Valo ret = ath6kl_wmi_error_event_rx(wmi, datap, len); 3051bdcd8170SKalle Valo break; 3052bdcd8170SKalle Valo case WMI_REPORT_STATISTICS_EVENTID: 3053bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); 3054bdcd8170SKalle Valo ret = ath6kl_wmi_stats_event_rx(wmi, datap, len); 3055bdcd8170SKalle Valo break; 3056bdcd8170SKalle Valo case WMI_RSSI_THRESHOLD_EVENTID: 3057bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); 3058bdcd8170SKalle Valo ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); 3059bdcd8170SKalle Valo break; 3060bdcd8170SKalle Valo case WMI_ERROR_REPORT_EVENTID: 3061bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); 3062bdcd8170SKalle Valo break; 3063bdcd8170SKalle Valo case WMI_OPT_RX_FRAME_EVENTID: 3064bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); 3065bdcd8170SKalle Valo ret = ath6kl_wmi_opt_frame_event_rx(wmi, datap, len); 3066bdcd8170SKalle Valo break; 3067bdcd8170SKalle Valo case WMI_REPORT_ROAM_TBL_EVENTID: 3068bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); 3069bdcd8170SKalle Valo break; 3070bdcd8170SKalle Valo case WMI_EXTENSION_EVENTID: 3071bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); 3072bdcd8170SKalle Valo ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); 3073bdcd8170SKalle Valo break; 3074bdcd8170SKalle Valo case WMI_CAC_EVENTID: 3075bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); 3076bdcd8170SKalle Valo ret = ath6kl_wmi_cac_event_rx(wmi, datap, len); 3077bdcd8170SKalle Valo break; 3078bdcd8170SKalle Valo case WMI_CHANNEL_CHANGE_EVENTID: 3079bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); 3080bdcd8170SKalle Valo break; 3081bdcd8170SKalle Valo case WMI_REPORT_ROAM_DATA_EVENTID: 3082bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); 3083bdcd8170SKalle Valo break; 3084003353b0SKalle Valo case WMI_TEST_EVENTID: 3085003353b0SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n"); 3086003353b0SKalle Valo ret = ath6kl_wmi_tcmd_test_report_rx(wmi, datap, len); 3087003353b0SKalle Valo break; 3088bdcd8170SKalle Valo case WMI_GET_FIXRATES_CMDID: 3089bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); 3090bdcd8170SKalle Valo ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); 3091bdcd8170SKalle Valo break; 3092bdcd8170SKalle Valo case WMI_TX_RETRY_ERR_EVENTID: 3093bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); 3094bdcd8170SKalle Valo break; 3095bdcd8170SKalle Valo case WMI_SNR_THRESHOLD_EVENTID: 3096bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); 3097bdcd8170SKalle Valo ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); 3098bdcd8170SKalle Valo break; 3099bdcd8170SKalle Valo case WMI_LQ_THRESHOLD_EVENTID: 3100bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); 3101bdcd8170SKalle Valo break; 3102bdcd8170SKalle Valo case WMI_APLIST_EVENTID: 3103bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); 3104bdcd8170SKalle Valo ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); 3105bdcd8170SKalle Valo break; 3106bdcd8170SKalle Valo case WMI_GET_KEEPALIVE_CMDID: 3107bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); 3108bdcd8170SKalle Valo ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); 3109bdcd8170SKalle Valo break; 3110bdcd8170SKalle Valo case WMI_GET_WOW_LIST_EVENTID: 3111bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); 3112bdcd8170SKalle Valo ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len); 3113bdcd8170SKalle Valo break; 3114bdcd8170SKalle Valo case WMI_GET_PMKID_LIST_EVENTID: 3115bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); 3116bdcd8170SKalle Valo ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); 3117bdcd8170SKalle Valo break; 3118bdcd8170SKalle Valo case WMI_PSPOLL_EVENTID: 3119bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); 3120bdcd8170SKalle Valo ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len); 3121bdcd8170SKalle Valo break; 3122bdcd8170SKalle Valo case WMI_DTIMEXPIRY_EVENTID: 3123bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); 3124bdcd8170SKalle Valo ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len); 3125bdcd8170SKalle Valo break; 3126bdcd8170SKalle Valo case WMI_SET_PARAMS_REPLY_EVENTID: 3127bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); 3128bdcd8170SKalle Valo break; 3129bdcd8170SKalle Valo case WMI_ADDBA_REQ_EVENTID: 3130bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); 3131bdcd8170SKalle Valo ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len); 3132bdcd8170SKalle Valo break; 3133bdcd8170SKalle Valo case WMI_ADDBA_RESP_EVENTID: 3134bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); 3135bdcd8170SKalle Valo break; 3136bdcd8170SKalle Valo case WMI_DELBA_REQ_EVENTID: 3137bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); 3138bdcd8170SKalle Valo ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len); 3139bdcd8170SKalle Valo break; 3140bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_CONFIG_EVENTID: 3141bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3142bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); 3143bdcd8170SKalle Valo break; 3144bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_STATS_EVENTID: 3145bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3146bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); 3147bdcd8170SKalle Valo break; 3148bdcd8170SKalle Valo case WMI_TX_COMPLETE_EVENTID: 3149bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); 3150bdcd8170SKalle Valo ret = ath6kl_wmi_tx_complete_event_rx(datap, len); 3151bdcd8170SKalle Valo break; 31526465ddcfSJouni Malinen case WMI_REMAIN_ON_CHNL_EVENTID: 31536465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); 3154f9e5f05cSJouni Malinen ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len); 31556465ddcfSJouni Malinen break; 31566465ddcfSJouni Malinen case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: 31576465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, 31586465ddcfSJouni Malinen "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); 3159f9e5f05cSJouni Malinen ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, 3160f9e5f05cSJouni Malinen len); 31616465ddcfSJouni Malinen break; 31626465ddcfSJouni Malinen case WMI_TX_STATUS_EVENTID: 31636465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); 3164a0df5db1SJouni Malinen ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len); 31656465ddcfSJouni Malinen break; 31666465ddcfSJouni Malinen case WMI_RX_PROBE_REQ_EVENTID: 31676465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); 3168ae32c30aSJouni Malinen ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len); 31696465ddcfSJouni Malinen break; 31706465ddcfSJouni Malinen case WMI_P2P_CAPABILITIES_EVENTID: 31716465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); 31726465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); 31736465ddcfSJouni Malinen break; 31746465ddcfSJouni Malinen case WMI_RX_ACTION_EVENTID: 31756465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); 31769809d8efSJouni Malinen ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len); 31776465ddcfSJouni Malinen break; 31786465ddcfSJouni Malinen case WMI_P2P_INFO_EVENTID: 31796465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); 31806465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_info_event_rx(datap, len); 31816465ddcfSJouni Malinen break; 3182bdcd8170SKalle Valo default: 3183bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); 3184bdcd8170SKalle Valo wmi->stat.cmd_id_err++; 3185bdcd8170SKalle Valo ret = -EINVAL; 3186bdcd8170SKalle Valo break; 3187bdcd8170SKalle Valo } 3188bdcd8170SKalle Valo 3189bdcd8170SKalle Valo dev_kfree_skb(skb); 3190bdcd8170SKalle Valo 3191bdcd8170SKalle Valo return ret; 3192bdcd8170SKalle Valo } 3193bdcd8170SKalle Valo 3194bdcd8170SKalle Valo static void ath6kl_wmi_qos_state_init(struct wmi *wmi) 3195bdcd8170SKalle Valo { 3196bdcd8170SKalle Valo if (!wmi) 3197bdcd8170SKalle Valo return; 3198bdcd8170SKalle Valo 3199bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 3200bdcd8170SKalle Valo 3201bdcd8170SKalle Valo wmi->fat_pipe_exist = 0; 3202bdcd8170SKalle Valo memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); 3203bdcd8170SKalle Valo 3204bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 3205bdcd8170SKalle Valo } 3206bdcd8170SKalle Valo 32072865785eSVasanthakumar Thiagarajan void *ath6kl_wmi_init(struct ath6kl *dev) 3208bdcd8170SKalle Valo { 3209bdcd8170SKalle Valo struct wmi *wmi; 3210bdcd8170SKalle Valo 3211bdcd8170SKalle Valo wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); 3212bdcd8170SKalle Valo if (!wmi) 3213bdcd8170SKalle Valo return NULL; 3214bdcd8170SKalle Valo 3215bdcd8170SKalle Valo spin_lock_init(&wmi->lock); 3216bdcd8170SKalle Valo 3217bdcd8170SKalle Valo wmi->parent_dev = dev; 3218bdcd8170SKalle Valo 3219bdcd8170SKalle Valo ath6kl_wmi_qos_state_init(wmi); 3220bdcd8170SKalle Valo 3221bdcd8170SKalle Valo wmi->pwr_mode = REC_POWER; 3222bdcd8170SKalle Valo wmi->phy_mode = WMI_11G_MODE; 3223bdcd8170SKalle Valo 3224bdcd8170SKalle Valo wmi->pair_crypto_type = NONE_CRYPT; 3225bdcd8170SKalle Valo wmi->grp_crypto_type = NONE_CRYPT; 3226bdcd8170SKalle Valo 3227bdcd8170SKalle Valo wmi->ht_allowed[A_BAND_24GHZ] = 1; 3228bdcd8170SKalle Valo wmi->ht_allowed[A_BAND_5GHZ] = 1; 3229bdcd8170SKalle Valo 3230bdcd8170SKalle Valo return wmi; 3231bdcd8170SKalle Valo } 3232bdcd8170SKalle Valo 3233bdcd8170SKalle Valo void ath6kl_wmi_shutdown(struct wmi *wmi) 3234bdcd8170SKalle Valo { 3235bdcd8170SKalle Valo if (!wmi) 3236bdcd8170SKalle Valo return; 3237bdcd8170SKalle Valo 3238a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 3239bdcd8170SKalle Valo kfree(wmi); 3240bdcd8170SKalle Valo } 3241