1bdcd8170SKalle Valo /* 2bdcd8170SKalle Valo * Copyright (c) 2004-2011 Atheros Communications Inc. 3bdcd8170SKalle Valo * 4bdcd8170SKalle Valo * Permission to use, copy, modify, and/or distribute this software for any 5bdcd8170SKalle Valo * purpose with or without fee is hereby granted, provided that the above 6bdcd8170SKalle Valo * copyright notice and this permission notice appear in all copies. 7bdcd8170SKalle Valo * 8bdcd8170SKalle Valo * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9bdcd8170SKalle Valo * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10bdcd8170SKalle Valo * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11bdcd8170SKalle Valo * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12bdcd8170SKalle Valo * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13bdcd8170SKalle Valo * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14bdcd8170SKalle Valo * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15bdcd8170SKalle Valo */ 16bdcd8170SKalle Valo 17bdcd8170SKalle Valo #include <linux/ip.h> 18bdcd8170SKalle Valo #include "core.h" 19bdcd8170SKalle Valo #include "debug.h" 20bdcd8170SKalle Valo 21bdcd8170SKalle Valo static int ath6kl_wmi_sync_point(struct wmi *wmi); 22bdcd8170SKalle Valo 23bdcd8170SKalle Valo static const s32 wmi_rate_tbl[][2] = { 24bdcd8170SKalle Valo /* {W/O SGI, with SGI} */ 25bdcd8170SKalle Valo {1000, 1000}, 26bdcd8170SKalle Valo {2000, 2000}, 27bdcd8170SKalle Valo {5500, 5500}, 28bdcd8170SKalle Valo {11000, 11000}, 29bdcd8170SKalle Valo {6000, 6000}, 30bdcd8170SKalle Valo {9000, 9000}, 31bdcd8170SKalle Valo {12000, 12000}, 32bdcd8170SKalle Valo {18000, 18000}, 33bdcd8170SKalle Valo {24000, 24000}, 34bdcd8170SKalle Valo {36000, 36000}, 35bdcd8170SKalle Valo {48000, 48000}, 36bdcd8170SKalle Valo {54000, 54000}, 37bdcd8170SKalle Valo {6500, 7200}, 38bdcd8170SKalle Valo {13000, 14400}, 39bdcd8170SKalle Valo {19500, 21700}, 40bdcd8170SKalle Valo {26000, 28900}, 41bdcd8170SKalle Valo {39000, 43300}, 42bdcd8170SKalle Valo {52000, 57800}, 43bdcd8170SKalle Valo {58500, 65000}, 44bdcd8170SKalle Valo {65000, 72200}, 45bdcd8170SKalle Valo {13500, 15000}, 46bdcd8170SKalle Valo {27000, 30000}, 47bdcd8170SKalle Valo {40500, 45000}, 48bdcd8170SKalle Valo {54000, 60000}, 49bdcd8170SKalle Valo {81000, 90000}, 50bdcd8170SKalle Valo {108000, 120000}, 51bdcd8170SKalle Valo {121500, 135000}, 52bdcd8170SKalle Valo {135000, 150000}, 53bdcd8170SKalle Valo {0, 0} 54bdcd8170SKalle Valo }; 55bdcd8170SKalle Valo 56bdcd8170SKalle Valo /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */ 57bdcd8170SKalle Valo static const u8 up_to_ac[] = { 58bdcd8170SKalle Valo WMM_AC_BE, 59bdcd8170SKalle Valo WMM_AC_BK, 60bdcd8170SKalle Valo WMM_AC_BK, 61bdcd8170SKalle Valo WMM_AC_BE, 62bdcd8170SKalle Valo WMM_AC_VI, 63bdcd8170SKalle Valo WMM_AC_VI, 64bdcd8170SKalle Valo WMM_AC_VO, 65bdcd8170SKalle Valo WMM_AC_VO, 66bdcd8170SKalle Valo }; 67bdcd8170SKalle Valo 68bdcd8170SKalle Valo void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id) 69bdcd8170SKalle Valo { 70bdcd8170SKalle Valo if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX)) 71bdcd8170SKalle Valo return; 72bdcd8170SKalle Valo 73bdcd8170SKalle Valo wmi->ep_id = ep_id; 74bdcd8170SKalle Valo } 75bdcd8170SKalle Valo 76bdcd8170SKalle Valo enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) 77bdcd8170SKalle Valo { 78bdcd8170SKalle Valo return wmi->ep_id; 79bdcd8170SKalle Valo } 80bdcd8170SKalle Valo 81bdcd8170SKalle Valo /* Performs DIX to 802.3 encapsulation for transmit packets. 82bdcd8170SKalle Valo * Assumes the entire DIX header is contigous and that there is 83bdcd8170SKalle Valo * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. 84bdcd8170SKalle Valo */ 85bdcd8170SKalle Valo int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) 86bdcd8170SKalle Valo { 87bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 88bdcd8170SKalle Valo struct ethhdr *eth_hdr; 89bdcd8170SKalle Valo size_t new_len; 90bdcd8170SKalle Valo __be16 type; 91bdcd8170SKalle Valo u8 *datap; 92bdcd8170SKalle Valo u16 size; 93bdcd8170SKalle Valo 94bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 95bdcd8170SKalle Valo return -EINVAL; 96bdcd8170SKalle Valo 97bdcd8170SKalle Valo size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr); 98bdcd8170SKalle Valo if (skb_headroom(skb) < size) 99bdcd8170SKalle Valo return -ENOMEM; 100bdcd8170SKalle Valo 101bdcd8170SKalle Valo eth_hdr = (struct ethhdr *) skb->data; 102bdcd8170SKalle Valo type = eth_hdr->h_proto; 103bdcd8170SKalle Valo 104bdcd8170SKalle Valo if (!is_ethertype(be16_to_cpu(type))) { 105bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 106bdcd8170SKalle Valo "%s: pkt is already in 802.3 format\n", __func__); 107bdcd8170SKalle Valo return 0; 108bdcd8170SKalle Valo } 109bdcd8170SKalle Valo 110bdcd8170SKalle Valo new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr); 111bdcd8170SKalle Valo 112bdcd8170SKalle Valo skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr)); 113bdcd8170SKalle Valo datap = skb->data; 114bdcd8170SKalle Valo 115bdcd8170SKalle Valo eth_hdr->h_proto = cpu_to_be16(new_len); 116bdcd8170SKalle Valo 117bdcd8170SKalle Valo memcpy(datap, eth_hdr, sizeof(*eth_hdr)); 118bdcd8170SKalle Valo 119bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr)); 120bdcd8170SKalle Valo llc_hdr->dsap = 0xAA; 121bdcd8170SKalle Valo llc_hdr->ssap = 0xAA; 122bdcd8170SKalle Valo llc_hdr->cntl = 0x03; 123bdcd8170SKalle Valo llc_hdr->org_code[0] = 0x0; 124bdcd8170SKalle Valo llc_hdr->org_code[1] = 0x0; 125bdcd8170SKalle Valo llc_hdr->org_code[2] = 0x0; 126bdcd8170SKalle Valo llc_hdr->eth_type = type; 127bdcd8170SKalle Valo 128bdcd8170SKalle Valo return 0; 129bdcd8170SKalle Valo } 130bdcd8170SKalle Valo 131bdcd8170SKalle Valo static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, 132bdcd8170SKalle Valo u8 *version, void *tx_meta_info) 133bdcd8170SKalle Valo { 134bdcd8170SKalle Valo struct wmi_tx_meta_v1 *v1; 135bdcd8170SKalle Valo struct wmi_tx_meta_v2 *v2; 136bdcd8170SKalle Valo 137bdcd8170SKalle Valo if (WARN_ON(skb == NULL || version == NULL)) 138bdcd8170SKalle Valo return -EINVAL; 139bdcd8170SKalle Valo 140bdcd8170SKalle Valo switch (*version) { 141bdcd8170SKalle Valo case WMI_META_VERSION_1: 142bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 143bdcd8170SKalle Valo v1 = (struct wmi_tx_meta_v1 *) skb->data; 144bdcd8170SKalle Valo v1->pkt_id = 0; 145bdcd8170SKalle Valo v1->rate_plcy_id = 0; 146bdcd8170SKalle Valo *version = WMI_META_VERSION_1; 147bdcd8170SKalle Valo break; 148bdcd8170SKalle Valo case WMI_META_VERSION_2: 149bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 150bdcd8170SKalle Valo v2 = (struct wmi_tx_meta_v2 *) skb->data; 151bdcd8170SKalle Valo memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info, 152bdcd8170SKalle Valo sizeof(struct wmi_tx_meta_v2)); 153bdcd8170SKalle Valo break; 154bdcd8170SKalle Valo } 155bdcd8170SKalle Valo 156bdcd8170SKalle Valo return 0; 157bdcd8170SKalle Valo } 158bdcd8170SKalle Valo 159bdcd8170SKalle Valo int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, 160bdcd8170SKalle Valo u8 msg_type, bool more_data, 161bdcd8170SKalle Valo enum wmi_data_hdr_data_type data_type, 162bdcd8170SKalle Valo u8 meta_ver, void *tx_meta_info) 163bdcd8170SKalle Valo { 164bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 165bdcd8170SKalle Valo int ret; 166bdcd8170SKalle Valo 167bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 168bdcd8170SKalle Valo return -EINVAL; 169bdcd8170SKalle Valo 1703ce6ff50SVasanthakumar Thiagarajan if (tx_meta_info) { 171bdcd8170SKalle Valo ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info); 172bdcd8170SKalle Valo if (ret) 173bdcd8170SKalle Valo return ret; 1743ce6ff50SVasanthakumar Thiagarajan } 175bdcd8170SKalle Valo 176bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 177bdcd8170SKalle Valo 178bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *)skb->data; 179bdcd8170SKalle Valo memset(data_hdr, 0, sizeof(struct wmi_data_hdr)); 180bdcd8170SKalle Valo 181bdcd8170SKalle Valo data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; 182bdcd8170SKalle Valo data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; 183bdcd8170SKalle Valo 184bdcd8170SKalle Valo if (more_data) 185bdcd8170SKalle Valo data_hdr->info |= 186bdcd8170SKalle Valo WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT; 187bdcd8170SKalle Valo 188bdcd8170SKalle Valo data_hdr->info2 = cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); 189bdcd8170SKalle Valo data_hdr->info3 = 0; 190bdcd8170SKalle Valo 191bdcd8170SKalle Valo return 0; 192bdcd8170SKalle Valo } 193bdcd8170SKalle Valo 194bdcd8170SKalle Valo static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) 195bdcd8170SKalle Valo { 196bdcd8170SKalle Valo struct iphdr *ip_hdr = (struct iphdr *) pkt; 197bdcd8170SKalle Valo u8 ip_pri; 198bdcd8170SKalle Valo 199bdcd8170SKalle Valo /* 200bdcd8170SKalle Valo * Determine IPTOS priority 201bdcd8170SKalle Valo * 202bdcd8170SKalle Valo * IP-TOS - 8bits 203bdcd8170SKalle Valo * : DSCP(6-bits) ECN(2-bits) 204bdcd8170SKalle Valo * : DSCP - P2 P1 P0 X X X 205bdcd8170SKalle Valo * where (P2 P1 P0) form 802.1D 206bdcd8170SKalle Valo */ 207bdcd8170SKalle Valo ip_pri = ip_hdr->tos >> 5; 208bdcd8170SKalle Valo ip_pri &= 0x7; 209bdcd8170SKalle Valo 210bdcd8170SKalle Valo if ((layer2_pri & 0x7) > ip_pri) 211bdcd8170SKalle Valo return (u8) layer2_pri & 0x7; 212bdcd8170SKalle Valo else 213bdcd8170SKalle Valo return ip_pri; 214bdcd8170SKalle Valo } 215bdcd8170SKalle Valo 216bdcd8170SKalle Valo int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, 217bdcd8170SKalle Valo u32 layer2_priority, bool wmm_enabled, 218bdcd8170SKalle Valo u8 *ac) 219bdcd8170SKalle Valo { 220bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 221bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 222bdcd8170SKalle Valo struct wmi_create_pstream_cmd cmd; 223bdcd8170SKalle Valo u32 meta_size, hdr_size; 224bdcd8170SKalle Valo u16 ip_type = IP_ETHERTYPE; 225bdcd8170SKalle Valo u8 stream_exist, usr_pri; 226bdcd8170SKalle Valo u8 traffic_class = WMM_AC_BE; 227bdcd8170SKalle Valo u8 *datap; 228bdcd8170SKalle Valo 229bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 230bdcd8170SKalle Valo return -EINVAL; 231bdcd8170SKalle Valo 232bdcd8170SKalle Valo datap = skb->data; 233bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) datap; 234bdcd8170SKalle Valo 235bdcd8170SKalle Valo meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) & 236bdcd8170SKalle Valo WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0; 237bdcd8170SKalle Valo 238bdcd8170SKalle Valo if (!wmm_enabled) { 239bdcd8170SKalle Valo /* If WMM is disabled all traffic goes as BE traffic */ 240bdcd8170SKalle Valo usr_pri = 0; 241bdcd8170SKalle Valo } else { 242bdcd8170SKalle Valo hdr_size = sizeof(struct ethhdr); 243bdcd8170SKalle Valo 244bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + 245bdcd8170SKalle Valo sizeof(struct 246bdcd8170SKalle Valo wmi_data_hdr) + 247bdcd8170SKalle Valo meta_size + hdr_size); 248bdcd8170SKalle Valo 249bdcd8170SKalle Valo if (llc_hdr->eth_type == htons(ip_type)) { 250bdcd8170SKalle Valo /* 251bdcd8170SKalle Valo * Extract the endpoint info from the TOS field 252bdcd8170SKalle Valo * in the IP header. 253bdcd8170SKalle Valo */ 254bdcd8170SKalle Valo usr_pri = 255bdcd8170SKalle Valo ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + 256bdcd8170SKalle Valo sizeof(struct ath6kl_llc_snap_hdr), 257bdcd8170SKalle Valo layer2_priority); 258bdcd8170SKalle Valo } else 259bdcd8170SKalle Valo usr_pri = layer2_priority & 0x7; 260bdcd8170SKalle Valo } 261bdcd8170SKalle Valo 262bdcd8170SKalle Valo /* workaround for WMM S5 */ 263bdcd8170SKalle Valo if ((wmi->traffic_class == WMM_AC_VI) && 264bdcd8170SKalle Valo ((usr_pri == 5) || (usr_pri == 4))) 265bdcd8170SKalle Valo usr_pri = 1; 266bdcd8170SKalle Valo 267bdcd8170SKalle Valo /* Convert user priority to traffic class */ 268bdcd8170SKalle Valo traffic_class = up_to_ac[usr_pri & 0x7]; 269bdcd8170SKalle Valo 270bdcd8170SKalle Valo wmi_data_hdr_set_up(data_hdr, usr_pri); 271bdcd8170SKalle Valo 272bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 273bdcd8170SKalle Valo stream_exist = wmi->fat_pipe_exist; 274bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 275bdcd8170SKalle Valo 276bdcd8170SKalle Valo if (!(stream_exist & (1 << traffic_class))) { 277bdcd8170SKalle Valo memset(&cmd, 0, sizeof(cmd)); 278bdcd8170SKalle Valo cmd.traffic_class = traffic_class; 279bdcd8170SKalle Valo cmd.user_pri = usr_pri; 280bdcd8170SKalle Valo cmd.inactivity_int = 281bdcd8170SKalle Valo cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); 282bdcd8170SKalle Valo /* Implicit streams are created with TSID 0xFF */ 283bdcd8170SKalle Valo cmd.tsid = WMI_IMPLICIT_PSTREAM; 284bdcd8170SKalle Valo ath6kl_wmi_create_pstream_cmd(wmi, &cmd); 285bdcd8170SKalle Valo } 286bdcd8170SKalle Valo 287bdcd8170SKalle Valo *ac = traffic_class; 288bdcd8170SKalle Valo 289bdcd8170SKalle Valo return 0; 290bdcd8170SKalle Valo } 291bdcd8170SKalle Valo 292bdcd8170SKalle Valo int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) 293bdcd8170SKalle Valo { 294bdcd8170SKalle Valo struct ieee80211_hdr_3addr *pwh, wh; 295bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 296bdcd8170SKalle Valo struct ethhdr eth_hdr; 297bdcd8170SKalle Valo u32 hdr_size; 298bdcd8170SKalle Valo u8 *datap; 299bdcd8170SKalle Valo __le16 sub_type; 300bdcd8170SKalle Valo 301bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 302bdcd8170SKalle Valo return -EINVAL; 303bdcd8170SKalle Valo 304bdcd8170SKalle Valo datap = skb->data; 305bdcd8170SKalle Valo pwh = (struct ieee80211_hdr_3addr *) datap; 306bdcd8170SKalle Valo 307bdcd8170SKalle Valo sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); 308bdcd8170SKalle Valo 309bdcd8170SKalle Valo memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); 310bdcd8170SKalle Valo 311bdcd8170SKalle Valo /* Strip off the 802.11 header */ 312bdcd8170SKalle Valo if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { 313bdcd8170SKalle Valo hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), 314bdcd8170SKalle Valo sizeof(u32)); 315bdcd8170SKalle Valo skb_pull(skb, hdr_size); 316bdcd8170SKalle Valo } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) 317bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); 318bdcd8170SKalle Valo 319bdcd8170SKalle Valo datap = skb->data; 320bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); 321bdcd8170SKalle Valo 322c8790cbaSRaja Mani memset(ð_hdr, 0, sizeof(eth_hdr)); 323bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 324bdcd8170SKalle Valo 325bdcd8170SKalle Valo switch ((le16_to_cpu(wh.frame_control)) & 326bdcd8170SKalle Valo (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 327bdcd8170SKalle Valo case 0: 328bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 329bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 330bdcd8170SKalle Valo break; 331bdcd8170SKalle Valo case IEEE80211_FCTL_TODS: 332bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); 333bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 334bdcd8170SKalle Valo break; 335bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS: 336bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 337bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); 338bdcd8170SKalle Valo break; 339bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: 340bdcd8170SKalle Valo break; 341bdcd8170SKalle Valo } 342bdcd8170SKalle Valo 343bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 344bdcd8170SKalle Valo skb_push(skb, sizeof(eth_hdr)); 345bdcd8170SKalle Valo 346bdcd8170SKalle Valo datap = skb->data; 347bdcd8170SKalle Valo 348bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 349bdcd8170SKalle Valo 350bdcd8170SKalle Valo return 0; 351bdcd8170SKalle Valo } 352bdcd8170SKalle Valo 353bdcd8170SKalle Valo /* 354bdcd8170SKalle Valo * Performs 802.3 to DIX encapsulation for received packets. 355bdcd8170SKalle Valo * Assumes the entire 802.3 header is contigous. 356bdcd8170SKalle Valo */ 357bdcd8170SKalle Valo int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) 358bdcd8170SKalle Valo { 359bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 360bdcd8170SKalle Valo struct ethhdr eth_hdr; 361bdcd8170SKalle Valo u8 *datap; 362bdcd8170SKalle Valo 363bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 364bdcd8170SKalle Valo return -EINVAL; 365bdcd8170SKalle Valo 366bdcd8170SKalle Valo datap = skb->data; 367bdcd8170SKalle Valo 368bdcd8170SKalle Valo memcpy(ð_hdr, datap, sizeof(eth_hdr)); 369bdcd8170SKalle Valo 370bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); 371bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 372bdcd8170SKalle Valo 373bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 374bdcd8170SKalle Valo datap = skb->data; 375bdcd8170SKalle Valo 376bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 377bdcd8170SKalle Valo 378bdcd8170SKalle Valo return 0; 379bdcd8170SKalle Valo } 380bdcd8170SKalle Valo 381bdcd8170SKalle Valo static void ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(struct sk_buff *skb, 382bdcd8170SKalle Valo u8 *datap) 383bdcd8170SKalle Valo { 384bdcd8170SKalle Valo struct wmi_bss_info_hdr2 bih2; 385bdcd8170SKalle Valo struct wmi_bss_info_hdr *bih; 386bdcd8170SKalle Valo 387bdcd8170SKalle Valo memcpy(&bih2, datap, sizeof(struct wmi_bss_info_hdr2)); 388bdcd8170SKalle Valo 389bdcd8170SKalle Valo skb_push(skb, 4); 390bdcd8170SKalle Valo bih = (struct wmi_bss_info_hdr *) skb->data; 391bdcd8170SKalle Valo 392bdcd8170SKalle Valo bih->ch = bih2.ch; 393bdcd8170SKalle Valo bih->frame_type = bih2.frame_type; 394bdcd8170SKalle Valo bih->snr = bih2.snr; 395bdcd8170SKalle Valo bih->rssi = a_cpu_to_sle16(bih2.snr - 95); 396bdcd8170SKalle Valo bih->ie_mask = cpu_to_le32(le16_to_cpu(bih2.ie_mask)); 397bdcd8170SKalle Valo memcpy(bih->bssid, bih2.bssid, ETH_ALEN); 398bdcd8170SKalle Valo } 399bdcd8170SKalle Valo 400bdcd8170SKalle Valo static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) 401bdcd8170SKalle Valo { 402bdcd8170SKalle Valo struct tx_complete_msg_v1 *msg_v1; 403bdcd8170SKalle Valo struct wmi_tx_complete_event *evt; 404bdcd8170SKalle Valo int index; 405bdcd8170SKalle Valo u16 size; 406bdcd8170SKalle Valo 407bdcd8170SKalle Valo evt = (struct wmi_tx_complete_event *) datap; 408bdcd8170SKalle Valo 409bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", 410bdcd8170SKalle Valo evt->num_msg, evt->msg_len, evt->msg_type); 411bdcd8170SKalle Valo 412bdcd8170SKalle Valo if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI)) 413bdcd8170SKalle Valo return 0; 414bdcd8170SKalle Valo 415bdcd8170SKalle Valo for (index = 0; index < evt->num_msg; index++) { 416bdcd8170SKalle Valo size = sizeof(struct wmi_tx_complete_event) + 417bdcd8170SKalle Valo (index * sizeof(struct tx_complete_msg_v1)); 418bdcd8170SKalle Valo msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); 419bdcd8170SKalle Valo 420bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", 421bdcd8170SKalle Valo msg_v1->status, msg_v1->pkt_id, 422bdcd8170SKalle Valo msg_v1->rate_idx, msg_v1->ack_failures); 423bdcd8170SKalle Valo } 424bdcd8170SKalle Valo 425bdcd8170SKalle Valo return 0; 426bdcd8170SKalle Valo } 427bdcd8170SKalle Valo 428*f9e5f05cSJouni Malinen static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, 429*f9e5f05cSJouni Malinen int len) 4306465ddcfSJouni Malinen { 4316465ddcfSJouni Malinen struct wmi_remain_on_chnl_event *ev; 4326465ddcfSJouni Malinen u32 freq; 4336465ddcfSJouni Malinen u32 dur; 434*f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 435*f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4366465ddcfSJouni Malinen 4376465ddcfSJouni Malinen if (len < sizeof(*ev)) 4386465ddcfSJouni Malinen return -EINVAL; 4396465ddcfSJouni Malinen 4406465ddcfSJouni Malinen ev = (struct wmi_remain_on_chnl_event *) datap; 4416465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4426465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4436465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", 4446465ddcfSJouni Malinen freq, dur); 445*f9e5f05cSJouni Malinen chan = ieee80211_get_channel(ar->wdev->wiphy, freq); 446*f9e5f05cSJouni Malinen if (!chan) { 447*f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " 448*f9e5f05cSJouni Malinen "(freq=%u)\n", freq); 449*f9e5f05cSJouni Malinen return -EINVAL; 450*f9e5f05cSJouni Malinen } 451*f9e5f05cSJouni Malinen cfg80211_ready_on_channel(ar->net_dev, 1, chan, NL80211_CHAN_NO_HT, 452*f9e5f05cSJouni Malinen dur, GFP_ATOMIC); 4536465ddcfSJouni Malinen 4546465ddcfSJouni Malinen return 0; 4556465ddcfSJouni Malinen } 4566465ddcfSJouni Malinen 457*f9e5f05cSJouni Malinen static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, 458*f9e5f05cSJouni Malinen u8 *datap, int len) 4596465ddcfSJouni Malinen { 4606465ddcfSJouni Malinen struct wmi_cancel_remain_on_chnl_event *ev; 4616465ddcfSJouni Malinen u32 freq; 4626465ddcfSJouni Malinen u32 dur; 463*f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 464*f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4656465ddcfSJouni Malinen 4666465ddcfSJouni Malinen if (len < sizeof(*ev)) 4676465ddcfSJouni Malinen return -EINVAL; 4686465ddcfSJouni Malinen 4696465ddcfSJouni Malinen ev = (struct wmi_cancel_remain_on_chnl_event *) datap; 4706465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4716465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4726465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " 4736465ddcfSJouni Malinen "status=%u\n", freq, dur, ev->status); 474*f9e5f05cSJouni Malinen chan = ieee80211_get_channel(ar->wdev->wiphy, freq); 475*f9e5f05cSJouni Malinen if (!chan) { 476*f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " 477*f9e5f05cSJouni Malinen "channel (freq=%u)\n", freq); 478*f9e5f05cSJouni Malinen return -EINVAL; 479*f9e5f05cSJouni Malinen } 480*f9e5f05cSJouni Malinen cfg80211_remain_on_channel_expired(ar->net_dev, 1, chan, 481*f9e5f05cSJouni Malinen NL80211_CHAN_NO_HT, GFP_ATOMIC); 4826465ddcfSJouni Malinen 4836465ddcfSJouni Malinen return 0; 4846465ddcfSJouni Malinen } 4856465ddcfSJouni Malinen 4866465ddcfSJouni Malinen static int ath6kl_wmi_tx_status_event_rx(u8 *datap, int len) 4876465ddcfSJouni Malinen { 4886465ddcfSJouni Malinen struct wmi_tx_status_event *ev; 4896465ddcfSJouni Malinen u32 id; 4906465ddcfSJouni Malinen 4916465ddcfSJouni Malinen if (len < sizeof(*ev)) 4926465ddcfSJouni Malinen return -EINVAL; 4936465ddcfSJouni Malinen 4946465ddcfSJouni Malinen ev = (struct wmi_tx_status_event *) datap; 4956465ddcfSJouni Malinen id = le32_to_cpu(ev->id); 4966465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", 4976465ddcfSJouni Malinen id, ev->ack_status); 4986465ddcfSJouni Malinen 4996465ddcfSJouni Malinen return 0; 5006465ddcfSJouni Malinen } 5016465ddcfSJouni Malinen 5026465ddcfSJouni Malinen static int ath6kl_wmi_rx_probe_req_event_rx(u8 *datap, int len) 5036465ddcfSJouni Malinen { 5046465ddcfSJouni Malinen struct wmi_p2p_rx_probe_req_event *ev; 5056465ddcfSJouni Malinen u16 dlen; 5066465ddcfSJouni Malinen 5076465ddcfSJouni Malinen if (len < sizeof(*ev)) 5086465ddcfSJouni Malinen return -EINVAL; 5096465ddcfSJouni Malinen 5106465ddcfSJouni Malinen ev = (struct wmi_p2p_rx_probe_req_event *) datap; 5116465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5126465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u\n", 5136465ddcfSJouni Malinen dlen); 5146465ddcfSJouni Malinen 5156465ddcfSJouni Malinen return 0; 5166465ddcfSJouni Malinen } 5176465ddcfSJouni Malinen 5186465ddcfSJouni Malinen static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) 5196465ddcfSJouni Malinen { 5206465ddcfSJouni Malinen struct wmi_p2p_capabilities_event *ev; 5216465ddcfSJouni Malinen u16 dlen; 5226465ddcfSJouni Malinen 5236465ddcfSJouni Malinen if (len < sizeof(*ev)) 5246465ddcfSJouni Malinen return -EINVAL; 5256465ddcfSJouni Malinen 5266465ddcfSJouni Malinen ev = (struct wmi_p2p_capabilities_event *) datap; 5276465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5286465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); 5296465ddcfSJouni Malinen 5306465ddcfSJouni Malinen return 0; 5316465ddcfSJouni Malinen } 5326465ddcfSJouni Malinen 5336465ddcfSJouni Malinen static int ath6kl_wmi_rx_action_event_rx(u8 *datap, int len) 5346465ddcfSJouni Malinen { 5356465ddcfSJouni Malinen struct wmi_rx_action_event *ev; 5366465ddcfSJouni Malinen u16 dlen; 5376465ddcfSJouni Malinen 5386465ddcfSJouni Malinen if (len < sizeof(*ev)) 5396465ddcfSJouni Malinen return -EINVAL; 5406465ddcfSJouni Malinen 5416465ddcfSJouni Malinen ev = (struct wmi_rx_action_event *) datap; 5426465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5436465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u\n", dlen); 5446465ddcfSJouni Malinen 5456465ddcfSJouni Malinen return 0; 5466465ddcfSJouni Malinen } 5476465ddcfSJouni Malinen 5486465ddcfSJouni Malinen static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) 5496465ddcfSJouni Malinen { 5506465ddcfSJouni Malinen struct wmi_p2p_info_event *ev; 5516465ddcfSJouni Malinen u32 flags; 5526465ddcfSJouni Malinen u16 dlen; 5536465ddcfSJouni Malinen 5546465ddcfSJouni Malinen if (len < sizeof(*ev)) 5556465ddcfSJouni Malinen return -EINVAL; 5566465ddcfSJouni Malinen 5576465ddcfSJouni Malinen ev = (struct wmi_p2p_info_event *) datap; 5586465ddcfSJouni Malinen flags = le32_to_cpu(ev->info_req_flags); 5596465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5606465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); 5616465ddcfSJouni Malinen 5626465ddcfSJouni Malinen if (flags & P2P_FLAG_CAPABILITIES_REQ) { 5636465ddcfSJouni Malinen struct wmi_p2p_capabilities *cap; 5646465ddcfSJouni Malinen if (dlen < sizeof(*cap)) 5656465ddcfSJouni Malinen return -EINVAL; 5666465ddcfSJouni Malinen cap = (struct wmi_p2p_capabilities *) ev->data; 5676465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", 5686465ddcfSJouni Malinen cap->go_power_save); 5696465ddcfSJouni Malinen } 5706465ddcfSJouni Malinen 5716465ddcfSJouni Malinen if (flags & P2P_FLAG_MACADDR_REQ) { 5726465ddcfSJouni Malinen struct wmi_p2p_macaddr *mac; 5736465ddcfSJouni Malinen if (dlen < sizeof(*mac)) 5746465ddcfSJouni Malinen return -EINVAL; 5756465ddcfSJouni Malinen mac = (struct wmi_p2p_macaddr *) ev->data; 5766465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", 5776465ddcfSJouni Malinen mac->mac_addr); 5786465ddcfSJouni Malinen } 5796465ddcfSJouni Malinen 5806465ddcfSJouni Malinen if (flags & P2P_FLAG_HMODEL_REQ) { 5816465ddcfSJouni Malinen struct wmi_p2p_hmodel *mod; 5826465ddcfSJouni Malinen if (dlen < sizeof(*mod)) 5836465ddcfSJouni Malinen return -EINVAL; 5846465ddcfSJouni Malinen mod = (struct wmi_p2p_hmodel *) ev->data; 5856465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", 5866465ddcfSJouni Malinen mod->p2p_model, 5876465ddcfSJouni Malinen mod->p2p_model ? "host" : "firmware"); 5886465ddcfSJouni Malinen } 5896465ddcfSJouni Malinen return 0; 5906465ddcfSJouni Malinen } 5916465ddcfSJouni Malinen 592bdcd8170SKalle Valo static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) 593bdcd8170SKalle Valo { 594bdcd8170SKalle Valo struct sk_buff *skb; 595bdcd8170SKalle Valo 596bdcd8170SKalle Valo skb = ath6kl_buf_alloc(size); 597bdcd8170SKalle Valo if (!skb) 598bdcd8170SKalle Valo return NULL; 599bdcd8170SKalle Valo 600bdcd8170SKalle Valo skb_put(skb, size); 601bdcd8170SKalle Valo if (size) 602bdcd8170SKalle Valo memset(skb->data, 0, size); 603bdcd8170SKalle Valo 604bdcd8170SKalle Valo return skb; 605bdcd8170SKalle Valo } 606bdcd8170SKalle Valo 607bdcd8170SKalle Valo /* Send a "simple" wmi command -- one with no arguments */ 608bdcd8170SKalle Valo static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id) 609bdcd8170SKalle Valo { 610bdcd8170SKalle Valo struct sk_buff *skb; 611bdcd8170SKalle Valo int ret; 612bdcd8170SKalle Valo 613bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(0); 614bdcd8170SKalle Valo if (!skb) 615bdcd8170SKalle Valo return -ENOMEM; 616bdcd8170SKalle Valo 617bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG); 618bdcd8170SKalle Valo 619bdcd8170SKalle Valo return ret; 620bdcd8170SKalle Valo } 621bdcd8170SKalle Valo 622bdcd8170SKalle Valo static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) 623bdcd8170SKalle Valo { 624bdcd8170SKalle Valo struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; 625bdcd8170SKalle Valo 626bdcd8170SKalle Valo if (len < sizeof(struct wmi_ready_event_2)) 627bdcd8170SKalle Valo return -EINVAL; 628bdcd8170SKalle Valo 629bdcd8170SKalle Valo wmi->ready = true; 630bdcd8170SKalle Valo ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, 631bdcd8170SKalle Valo le32_to_cpu(ev->sw_version), 632bdcd8170SKalle Valo le32_to_cpu(ev->abi_version)); 633bdcd8170SKalle Valo 634bdcd8170SKalle Valo return 0; 635bdcd8170SKalle Valo } 636bdcd8170SKalle Valo 637bdcd8170SKalle Valo static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) 638bdcd8170SKalle Valo { 639bdcd8170SKalle Valo struct wmi_connect_event *ev; 640bdcd8170SKalle Valo u8 *pie, *peie; 641bdcd8170SKalle Valo 642bdcd8170SKalle Valo if (len < sizeof(struct wmi_connect_event)) 643bdcd8170SKalle Valo return -EINVAL; 644bdcd8170SKalle Valo 645bdcd8170SKalle Valo ev = (struct wmi_connect_event *) datap; 646bdcd8170SKalle Valo 647bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM\n", 648bdcd8170SKalle Valo __func__, ev->ch, ev->bssid); 649bdcd8170SKalle Valo 650bdcd8170SKalle Valo /* Start of assoc rsp IEs */ 651bdcd8170SKalle Valo pie = ev->assoc_info + ev->beacon_ie_len + 652bdcd8170SKalle Valo ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ 653bdcd8170SKalle Valo 654bdcd8170SKalle Valo /* End of assoc rsp IEs */ 655bdcd8170SKalle Valo peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + 656bdcd8170SKalle Valo ev->assoc_resp_len; 657bdcd8170SKalle Valo 658bdcd8170SKalle Valo while (pie < peie) { 659bdcd8170SKalle Valo switch (*pie) { 660bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 661bdcd8170SKalle Valo if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && 662bdcd8170SKalle Valo pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { 663bdcd8170SKalle Valo /* WMM OUT (00:50:F2) */ 664bdcd8170SKalle Valo if (pie[1] > 5 665bdcd8170SKalle Valo && pie[6] == WMM_PARAM_OUI_SUBTYPE) 666bdcd8170SKalle Valo wmi->is_wmm_enabled = true; 667bdcd8170SKalle Valo } 668bdcd8170SKalle Valo break; 669bdcd8170SKalle Valo } 670bdcd8170SKalle Valo 671bdcd8170SKalle Valo if (wmi->is_wmm_enabled) 672bdcd8170SKalle Valo break; 673bdcd8170SKalle Valo 674bdcd8170SKalle Valo pie += pie[1] + 2; 675bdcd8170SKalle Valo } 676bdcd8170SKalle Valo 677bdcd8170SKalle Valo ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->ch), ev->bssid, 678bdcd8170SKalle Valo le16_to_cpu(ev->listen_intvl), 679bdcd8170SKalle Valo le16_to_cpu(ev->beacon_intvl), 680bdcd8170SKalle Valo le32_to_cpu(ev->nw_type), 681bdcd8170SKalle Valo ev->beacon_ie_len, ev->assoc_req_len, 682bdcd8170SKalle Valo ev->assoc_resp_len, ev->assoc_info); 683bdcd8170SKalle Valo 684bdcd8170SKalle Valo return 0; 685bdcd8170SKalle Valo } 686bdcd8170SKalle Valo 687bdcd8170SKalle Valo static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) 688bdcd8170SKalle Valo { 689bdcd8170SKalle Valo struct wmi_disconnect_event *ev; 690bdcd8170SKalle Valo wmi->traffic_class = 100; 691bdcd8170SKalle Valo 692bdcd8170SKalle Valo if (len < sizeof(struct wmi_disconnect_event)) 693bdcd8170SKalle Valo return -EINVAL; 694bdcd8170SKalle Valo 695bdcd8170SKalle Valo ev = (struct wmi_disconnect_event *) datap; 696bdcd8170SKalle Valo 697bdcd8170SKalle Valo wmi->is_wmm_enabled = false; 698bdcd8170SKalle Valo wmi->pair_crypto_type = NONE_CRYPT; 699bdcd8170SKalle Valo wmi->grp_crypto_type = NONE_CRYPT; 700bdcd8170SKalle Valo 701bdcd8170SKalle Valo ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason, 702bdcd8170SKalle Valo ev->bssid, ev->assoc_resp_len, ev->assoc_info, 703bdcd8170SKalle Valo le16_to_cpu(ev->proto_reason_status)); 704bdcd8170SKalle Valo 705bdcd8170SKalle Valo return 0; 706bdcd8170SKalle Valo } 707bdcd8170SKalle Valo 708bdcd8170SKalle Valo static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) 709bdcd8170SKalle Valo { 710bdcd8170SKalle Valo struct wmi_peer_node_event *ev; 711bdcd8170SKalle Valo 712bdcd8170SKalle Valo if (len < sizeof(struct wmi_peer_node_event)) 713bdcd8170SKalle Valo return -EINVAL; 714bdcd8170SKalle Valo 715bdcd8170SKalle Valo ev = (struct wmi_peer_node_event *) datap; 716bdcd8170SKalle Valo 717bdcd8170SKalle Valo if (ev->event_code == PEER_NODE_JOIN_EVENT) 718bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", 719bdcd8170SKalle Valo ev->peer_mac_addr); 720bdcd8170SKalle Valo else if (ev->event_code == PEER_NODE_LEAVE_EVENT) 721bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", 722bdcd8170SKalle Valo ev->peer_mac_addr); 723bdcd8170SKalle Valo 724bdcd8170SKalle Valo return 0; 725bdcd8170SKalle Valo } 726bdcd8170SKalle Valo 727bdcd8170SKalle Valo static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len) 728bdcd8170SKalle Valo { 729bdcd8170SKalle Valo struct wmi_tkip_micerr_event *ev; 730bdcd8170SKalle Valo 731bdcd8170SKalle Valo if (len < sizeof(struct wmi_tkip_micerr_event)) 732bdcd8170SKalle Valo return -EINVAL; 733bdcd8170SKalle Valo 734bdcd8170SKalle Valo ev = (struct wmi_tkip_micerr_event *) datap; 735bdcd8170SKalle Valo 736bdcd8170SKalle Valo ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast); 737bdcd8170SKalle Valo 738bdcd8170SKalle Valo return 0; 739bdcd8170SKalle Valo } 740bdcd8170SKalle Valo 741bdcd8170SKalle Valo static int ath6kl_wlan_parse_beacon(u8 *buf, int frame_len, 742bdcd8170SKalle Valo struct ath6kl_common_ie *cie) 743bdcd8170SKalle Valo { 744bdcd8170SKalle Valo u8 *frm, *efrm; 745bdcd8170SKalle Valo u8 elemid_ssid = false; 746bdcd8170SKalle Valo 747bdcd8170SKalle Valo frm = buf; 748bdcd8170SKalle Valo efrm = (u8 *) (frm + frame_len); 749bdcd8170SKalle Valo 750bdcd8170SKalle Valo /* 751bdcd8170SKalle Valo * beacon/probe response frame format 752bdcd8170SKalle Valo * [8] time stamp 753bdcd8170SKalle Valo * [2] beacon interval 754bdcd8170SKalle Valo * [2] capability information 755bdcd8170SKalle Valo * [tlv] ssid 756bdcd8170SKalle Valo * [tlv] supported rates 757bdcd8170SKalle Valo * [tlv] country information 758bdcd8170SKalle Valo * [tlv] parameter set (FH/DS) 759bdcd8170SKalle Valo * [tlv] erp information 760bdcd8170SKalle Valo * [tlv] extended supported rates 761bdcd8170SKalle Valo * [tlv] WMM 762bdcd8170SKalle Valo * [tlv] WPA or RSN 763bdcd8170SKalle Valo * [tlv] Atheros Advanced Capabilities 764bdcd8170SKalle Valo */ 765bdcd8170SKalle Valo if ((efrm - frm) < 12) 766bdcd8170SKalle Valo return -EINVAL; 767bdcd8170SKalle Valo 768bdcd8170SKalle Valo memset(cie, 0, sizeof(*cie)); 769bdcd8170SKalle Valo 770bdcd8170SKalle Valo cie->ie_tstamp = frm; 771bdcd8170SKalle Valo frm += 8; 772bdcd8170SKalle Valo cie->ie_beaconInt = *(u16 *) frm; 773bdcd8170SKalle Valo frm += 2; 774bdcd8170SKalle Valo cie->ie_capInfo = *(u16 *) frm; 775bdcd8170SKalle Valo frm += 2; 776bdcd8170SKalle Valo cie->ie_chan = 0; 777bdcd8170SKalle Valo 778bdcd8170SKalle Valo while (frm < efrm) { 779bdcd8170SKalle Valo switch (*frm) { 780bdcd8170SKalle Valo case WLAN_EID_SSID: 781bdcd8170SKalle Valo if (!elemid_ssid) { 782bdcd8170SKalle Valo cie->ie_ssid = frm; 783bdcd8170SKalle Valo elemid_ssid = true; 784bdcd8170SKalle Valo } 785bdcd8170SKalle Valo break; 786bdcd8170SKalle Valo case WLAN_EID_SUPP_RATES: 787bdcd8170SKalle Valo cie->ie_rates = frm; 788bdcd8170SKalle Valo break; 789bdcd8170SKalle Valo case WLAN_EID_COUNTRY: 790bdcd8170SKalle Valo cie->ie_country = frm; 791bdcd8170SKalle Valo break; 792bdcd8170SKalle Valo case WLAN_EID_FH_PARAMS: 793bdcd8170SKalle Valo break; 794bdcd8170SKalle Valo case WLAN_EID_DS_PARAMS: 795bdcd8170SKalle Valo cie->ie_chan = frm[2]; 796bdcd8170SKalle Valo break; 797bdcd8170SKalle Valo case WLAN_EID_TIM: 798bdcd8170SKalle Valo cie->ie_tim = frm; 799bdcd8170SKalle Valo break; 800bdcd8170SKalle Valo case WLAN_EID_IBSS_PARAMS: 801bdcd8170SKalle Valo break; 802bdcd8170SKalle Valo case WLAN_EID_EXT_SUPP_RATES: 803bdcd8170SKalle Valo cie->ie_xrates = frm; 804bdcd8170SKalle Valo break; 805bdcd8170SKalle Valo case WLAN_EID_ERP_INFO: 806bdcd8170SKalle Valo if (frm[1] != 1) 807bdcd8170SKalle Valo return -EINVAL; 808bdcd8170SKalle Valo 809bdcd8170SKalle Valo cie->ie_erp = frm[2]; 810bdcd8170SKalle Valo break; 811bdcd8170SKalle Valo case WLAN_EID_RSN: 812bdcd8170SKalle Valo cie->ie_rsn = frm; 813bdcd8170SKalle Valo break; 814bdcd8170SKalle Valo case WLAN_EID_HT_CAPABILITY: 815bdcd8170SKalle Valo cie->ie_htcap = frm; 816bdcd8170SKalle Valo break; 817bdcd8170SKalle Valo case WLAN_EID_HT_INFORMATION: 818bdcd8170SKalle Valo cie->ie_htop = frm; 819bdcd8170SKalle Valo break; 820bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 821bdcd8170SKalle Valo if (frm[1] > 3 && frm[2] == 0x00 && frm[3] == 0x50 && 822bdcd8170SKalle Valo frm[4] == 0xf2) { 823bdcd8170SKalle Valo /* OUT Type (00:50:F2) */ 824bdcd8170SKalle Valo 825bdcd8170SKalle Valo if (frm[5] == WPA_OUI_TYPE) { 826bdcd8170SKalle Valo /* WPA OUT */ 827bdcd8170SKalle Valo cie->ie_wpa = frm; 828bdcd8170SKalle Valo } else if (frm[5] == WMM_OUI_TYPE) { 829bdcd8170SKalle Valo /* WMM OUT */ 830bdcd8170SKalle Valo cie->ie_wmm = frm; 831bdcd8170SKalle Valo } else if (frm[5] == WSC_OUT_TYPE) { 832bdcd8170SKalle Valo /* WSC OUT */ 833bdcd8170SKalle Valo cie->ie_wsc = frm; 834bdcd8170SKalle Valo } 835bdcd8170SKalle Valo 836bdcd8170SKalle Valo } else if (frm[1] > 3 && frm[2] == 0x00 837bdcd8170SKalle Valo && frm[3] == 0x03 && frm[4] == 0x7f 838bdcd8170SKalle Valo && frm[5] == ATH_OUI_TYPE) { 839bdcd8170SKalle Valo /* Atheros OUI (00:03:7f) */ 840bdcd8170SKalle Valo cie->ie_ath = frm; 841bdcd8170SKalle Valo } 842bdcd8170SKalle Valo break; 843bdcd8170SKalle Valo default: 844bdcd8170SKalle Valo break; 845bdcd8170SKalle Valo } 846bdcd8170SKalle Valo frm += frm[1] + 2; 847bdcd8170SKalle Valo } 848bdcd8170SKalle Valo 849bdcd8170SKalle Valo if ((cie->ie_rates == NULL) 850bdcd8170SKalle Valo || (cie->ie_rates[1] > ATH6KL_RATE_MAXSIZE)) 851bdcd8170SKalle Valo return -EINVAL; 852bdcd8170SKalle Valo 853bdcd8170SKalle Valo if ((cie->ie_ssid == NULL) 854bdcd8170SKalle Valo || (cie->ie_ssid[1] > IEEE80211_MAX_SSID_LEN)) 855bdcd8170SKalle Valo return -EINVAL; 856bdcd8170SKalle Valo 857bdcd8170SKalle Valo return 0; 858bdcd8170SKalle Valo } 859bdcd8170SKalle Valo 860bdcd8170SKalle Valo static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) 861bdcd8170SKalle Valo { 862bdcd8170SKalle Valo struct bss *bss = NULL; 863bdcd8170SKalle Valo struct wmi_bss_info_hdr *bih; 864bdcd8170SKalle Valo u8 cached_ssid_len = 0; 865bdcd8170SKalle Valo u8 cached_ssid[IEEE80211_MAX_SSID_LEN] = { 0 }; 866bdcd8170SKalle Valo u8 beacon_ssid_len = 0; 867bdcd8170SKalle Valo u8 *buf, *ie_ssid; 868bdcd8170SKalle Valo u8 *ni_buf; 869bdcd8170SKalle Valo int buf_len; 870bdcd8170SKalle Valo 871bdcd8170SKalle Valo int ret; 872bdcd8170SKalle Valo 873bdcd8170SKalle Valo if (len <= sizeof(struct wmi_bss_info_hdr)) 874bdcd8170SKalle Valo return -EINVAL; 875bdcd8170SKalle Valo 876bdcd8170SKalle Valo bih = (struct wmi_bss_info_hdr *) datap; 8777c3075e9SVasanthakumar Thiagarajan bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid); 878bdcd8170SKalle Valo 879bdcd8170SKalle Valo if (a_sle16_to_cpu(bih->rssi) > 0) { 880bdcd8170SKalle Valo if (bss == NULL) 881bdcd8170SKalle Valo return 0; 882bdcd8170SKalle Valo else 883bdcd8170SKalle Valo bih->rssi = a_cpu_to_sle16(bss->ni_rssi); 884bdcd8170SKalle Valo } 885bdcd8170SKalle Valo 886bdcd8170SKalle Valo buf = datap + sizeof(struct wmi_bss_info_hdr); 887bdcd8170SKalle Valo len -= sizeof(struct wmi_bss_info_hdr); 888bdcd8170SKalle Valo 889bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 890bdcd8170SKalle Valo "bss info evt - ch %u, rssi %02x, bssid \"%pM\"\n", 891bdcd8170SKalle Valo bih->ch, a_sle16_to_cpu(bih->rssi), bih->bssid); 892bdcd8170SKalle Valo 893bdcd8170SKalle Valo if (bss != NULL) { 894bdcd8170SKalle Valo /* 895bdcd8170SKalle Valo * Free up the node. We are about to allocate a new node. 896bdcd8170SKalle Valo * In case of hidden AP, beacon will not have ssid, 897bdcd8170SKalle Valo * but a directed probe response will have it, 898bdcd8170SKalle Valo * so cache the probe-resp-ssid if already present. 899bdcd8170SKalle Valo */ 900bdcd8170SKalle Valo if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE)) { 901bdcd8170SKalle Valo ie_ssid = bss->ni_cie.ie_ssid; 902bdcd8170SKalle Valo if (ie_ssid && (ie_ssid[1] <= IEEE80211_MAX_SSID_LEN) && 903bdcd8170SKalle Valo (ie_ssid[2] != 0)) { 904bdcd8170SKalle Valo cached_ssid_len = ie_ssid[1]; 905bdcd8170SKalle Valo memcpy(cached_ssid, ie_ssid + 2, 906bdcd8170SKalle Valo cached_ssid_len); 907bdcd8170SKalle Valo } 908bdcd8170SKalle Valo } 909bdcd8170SKalle Valo 910bdcd8170SKalle Valo /* 911bdcd8170SKalle Valo * Use the current average rssi of associated AP base on 912bdcd8170SKalle Valo * assumption 913bdcd8170SKalle Valo * 1. Most os with GUI will update RSSI by 914bdcd8170SKalle Valo * ath6kl_wmi_get_stats_cmd() periodically. 915bdcd8170SKalle Valo * 2. ath6kl_wmi_get_stats_cmd(..) will be called when calling 916bdcd8170SKalle Valo * ath6kl_wmi_startscan_cmd(...) 917bdcd8170SKalle Valo * The average value of RSSI give end-user better feeling for 918bdcd8170SKalle Valo * instance value of scan result. It also sync up RSSI info 919bdcd8170SKalle Valo * in GUI between scan result and RSSI signal icon. 920bdcd8170SKalle Valo */ 92170df0516SVasanthakumar Thiagarajan if (memcmp(wmi->parent_dev->bssid, bih->bssid, ETH_ALEN) == 0) { 922bdcd8170SKalle Valo bih->rssi = a_cpu_to_sle16(bss->ni_rssi); 923bdcd8170SKalle Valo bih->snr = bss->ni_snr; 924bdcd8170SKalle Valo } 925bdcd8170SKalle Valo 9267c3075e9SVasanthakumar Thiagarajan wlan_node_reclaim(&wmi->parent_dev->scan_table, bss); 927bdcd8170SKalle Valo } 928bdcd8170SKalle Valo 929bdcd8170SKalle Valo /* 930bdcd8170SKalle Valo * beacon/probe response frame format 931bdcd8170SKalle Valo * [8] time stamp 932bdcd8170SKalle Valo * [2] beacon interval 933bdcd8170SKalle Valo * [2] capability information 934bdcd8170SKalle Valo * [tlv] ssid 935bdcd8170SKalle Valo */ 936bdcd8170SKalle Valo beacon_ssid_len = buf[SSID_IE_LEN_INDEX]; 937bdcd8170SKalle Valo 938bdcd8170SKalle Valo /* 939bdcd8170SKalle Valo * If ssid is cached for this hidden AP, then change 940bdcd8170SKalle Valo * buffer len accordingly. 941bdcd8170SKalle Valo */ 942bdcd8170SKalle Valo if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && 943bdcd8170SKalle Valo (cached_ssid_len != 0) && 944bdcd8170SKalle Valo (beacon_ssid_len == 0 || (cached_ssid_len > beacon_ssid_len && 945bdcd8170SKalle Valo buf[SSID_IE_LEN_INDEX + 1] == 0))) { 946bdcd8170SKalle Valo 947bdcd8170SKalle Valo len += (cached_ssid_len - beacon_ssid_len); 948bdcd8170SKalle Valo } 949bdcd8170SKalle Valo 950bdcd8170SKalle Valo bss = wlan_node_alloc(len); 951bdcd8170SKalle Valo if (!bss) 952bdcd8170SKalle Valo return -ENOMEM; 953bdcd8170SKalle Valo 954bdcd8170SKalle Valo bss->ni_snr = bih->snr; 955bdcd8170SKalle Valo bss->ni_rssi = a_sle16_to_cpu(bih->rssi); 956bdcd8170SKalle Valo 957bdcd8170SKalle Valo if (WARN_ON(!bss->ni_buf)) 958bdcd8170SKalle Valo return -EINVAL; 959bdcd8170SKalle Valo 960bdcd8170SKalle Valo /* 961bdcd8170SKalle Valo * In case of hidden AP, beacon will not have ssid, 962bdcd8170SKalle Valo * but a directed probe response will have it, 963bdcd8170SKalle Valo * so place the cached-ssid(probe-resp) in the bss info. 964bdcd8170SKalle Valo */ 965bdcd8170SKalle Valo if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && 966bdcd8170SKalle Valo (cached_ssid_len != 0) && 967bdcd8170SKalle Valo (beacon_ssid_len == 0 || (beacon_ssid_len && 968bdcd8170SKalle Valo buf[SSID_IE_LEN_INDEX + 1] == 0))) { 969bdcd8170SKalle Valo ni_buf = bss->ni_buf; 970bdcd8170SKalle Valo buf_len = len; 971bdcd8170SKalle Valo 972bdcd8170SKalle Valo /* 973bdcd8170SKalle Valo * Copy the first 14 bytes: 974bdcd8170SKalle Valo * time-stamp(8), beacon-interval(2), 975bdcd8170SKalle Valo * cap-info(2), ssid-id(1), ssid-len(1). 976bdcd8170SKalle Valo */ 977bdcd8170SKalle Valo memcpy(ni_buf, buf, SSID_IE_LEN_INDEX + 1); 978bdcd8170SKalle Valo 979bdcd8170SKalle Valo ni_buf[SSID_IE_LEN_INDEX] = cached_ssid_len; 980bdcd8170SKalle Valo ni_buf += (SSID_IE_LEN_INDEX + 1); 981bdcd8170SKalle Valo 982bdcd8170SKalle Valo buf += (SSID_IE_LEN_INDEX + 1); 983bdcd8170SKalle Valo buf_len -= (SSID_IE_LEN_INDEX + 1); 984bdcd8170SKalle Valo 985bdcd8170SKalle Valo memcpy(ni_buf, cached_ssid, cached_ssid_len); 986bdcd8170SKalle Valo ni_buf += cached_ssid_len; 987bdcd8170SKalle Valo 988bdcd8170SKalle Valo buf += beacon_ssid_len; 989bdcd8170SKalle Valo buf_len -= beacon_ssid_len; 990bdcd8170SKalle Valo 991bdcd8170SKalle Valo if (cached_ssid_len > beacon_ssid_len) 992bdcd8170SKalle Valo buf_len -= (cached_ssid_len - beacon_ssid_len); 993bdcd8170SKalle Valo 994bdcd8170SKalle Valo memcpy(ni_buf, buf, buf_len); 995bdcd8170SKalle Valo } else 996bdcd8170SKalle Valo memcpy(bss->ni_buf, buf, len); 997bdcd8170SKalle Valo 998bdcd8170SKalle Valo bss->ni_framelen = len; 999bdcd8170SKalle Valo 1000bdcd8170SKalle Valo ret = ath6kl_wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie); 1001bdcd8170SKalle Valo if (ret) { 1002bdcd8170SKalle Valo wlan_node_free(bss); 1003bdcd8170SKalle Valo return -EINVAL; 1004bdcd8170SKalle Valo } 1005bdcd8170SKalle Valo 1006bdcd8170SKalle Valo /* 1007bdcd8170SKalle Valo * Update the frequency in ie_chan, overwriting of channel number 1008bdcd8170SKalle Valo * which is done in ath6kl_wlan_parse_beacon 1009bdcd8170SKalle Valo */ 1010bdcd8170SKalle Valo bss->ni_cie.ie_chan = le16_to_cpu(bih->ch); 10117c3075e9SVasanthakumar Thiagarajan wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid); 1012bdcd8170SKalle Valo 1013bdcd8170SKalle Valo return 0; 1014bdcd8170SKalle Valo } 1015bdcd8170SKalle Valo 1016bdcd8170SKalle Valo static int ath6kl_wmi_opt_frame_event_rx(struct wmi *wmi, u8 *datap, int len) 1017bdcd8170SKalle Valo { 1018bdcd8170SKalle Valo struct bss *bss; 1019bdcd8170SKalle Valo struct wmi_opt_rx_info_hdr *bih; 1020bdcd8170SKalle Valo u8 *buf; 1021bdcd8170SKalle Valo 1022bdcd8170SKalle Valo if (len <= sizeof(struct wmi_opt_rx_info_hdr)) 1023bdcd8170SKalle Valo return -EINVAL; 1024bdcd8170SKalle Valo 1025bdcd8170SKalle Valo bih = (struct wmi_opt_rx_info_hdr *) datap; 1026bdcd8170SKalle Valo buf = datap + sizeof(struct wmi_opt_rx_info_hdr); 1027bdcd8170SKalle Valo len -= sizeof(struct wmi_opt_rx_info_hdr); 1028bdcd8170SKalle Valo 1029bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "opt frame event %2.2x:%2.2x\n", 1030bdcd8170SKalle Valo bih->bssid[4], bih->bssid[5]); 1031bdcd8170SKalle Valo 10327c3075e9SVasanthakumar Thiagarajan bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid); 1033bdcd8170SKalle Valo if (bss != NULL) { 1034bdcd8170SKalle Valo /* Free up the node. We are about to allocate a new node. */ 10357c3075e9SVasanthakumar Thiagarajan wlan_node_reclaim(&wmi->parent_dev->scan_table, bss); 1036bdcd8170SKalle Valo } 1037bdcd8170SKalle Valo 1038bdcd8170SKalle Valo bss = wlan_node_alloc(len); 1039bdcd8170SKalle Valo if (!bss) 1040bdcd8170SKalle Valo return -ENOMEM; 1041bdcd8170SKalle Valo 1042bdcd8170SKalle Valo bss->ni_snr = bih->snr; 1043bdcd8170SKalle Valo bss->ni_cie.ie_chan = le16_to_cpu(bih->ch); 1044bdcd8170SKalle Valo 1045bdcd8170SKalle Valo if (WARN_ON(!bss->ni_buf)) 1046bdcd8170SKalle Valo return -EINVAL; 1047bdcd8170SKalle Valo 1048bdcd8170SKalle Valo memcpy(bss->ni_buf, buf, len); 10497c3075e9SVasanthakumar Thiagarajan wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid); 1050bdcd8170SKalle Valo 1051bdcd8170SKalle Valo return 0; 1052bdcd8170SKalle Valo } 1053bdcd8170SKalle Valo 1054bdcd8170SKalle Valo /* Inactivity timeout of a fatpipe(pstream) at the target */ 1055bdcd8170SKalle Valo static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, 1056bdcd8170SKalle Valo int len) 1057bdcd8170SKalle Valo { 1058bdcd8170SKalle Valo struct wmi_pstream_timeout_event *ev; 1059bdcd8170SKalle Valo 1060bdcd8170SKalle Valo if (len < sizeof(struct wmi_pstream_timeout_event)) 1061bdcd8170SKalle Valo return -EINVAL; 1062bdcd8170SKalle Valo 1063bdcd8170SKalle Valo ev = (struct wmi_pstream_timeout_event *) datap; 1064bdcd8170SKalle Valo 1065bdcd8170SKalle Valo /* 1066bdcd8170SKalle Valo * When the pstream (fat pipe == AC) timesout, it means there were 1067bdcd8170SKalle Valo * no thinStreams within this pstream & it got implicitly created 1068bdcd8170SKalle Valo * due to data flow on this AC. We start the inactivity timer only 1069bdcd8170SKalle Valo * for implicitly created pstream. Just reset the host state. 1070bdcd8170SKalle Valo */ 1071bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1072bdcd8170SKalle Valo wmi->stream_exist_for_ac[ev->traffic_class] = 0; 1073bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); 1074bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1075bdcd8170SKalle Valo 1076bdcd8170SKalle Valo /* Indicate inactivity to driver layer for this fatpipe (pstream) */ 1077bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); 1078bdcd8170SKalle Valo 1079bdcd8170SKalle Valo return 0; 1080bdcd8170SKalle Valo } 1081bdcd8170SKalle Valo 1082bdcd8170SKalle Valo static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) 1083bdcd8170SKalle Valo { 1084bdcd8170SKalle Valo struct wmi_bit_rate_reply *reply; 1085bdcd8170SKalle Valo s32 rate; 1086bdcd8170SKalle Valo u32 sgi, index; 1087bdcd8170SKalle Valo 1088bdcd8170SKalle Valo if (len < sizeof(struct wmi_bit_rate_reply)) 1089bdcd8170SKalle Valo return -EINVAL; 1090bdcd8170SKalle Valo 1091bdcd8170SKalle Valo reply = (struct wmi_bit_rate_reply *) datap; 1092bdcd8170SKalle Valo 1093bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); 1094bdcd8170SKalle Valo 1095bdcd8170SKalle Valo if (reply->rate_index == (s8) RATE_AUTO) { 1096bdcd8170SKalle Valo rate = RATE_AUTO; 1097bdcd8170SKalle Valo } else { 1098bdcd8170SKalle Valo index = reply->rate_index & 0x7f; 1099bdcd8170SKalle Valo sgi = (reply->rate_index & 0x80) ? 1 : 0; 1100bdcd8170SKalle Valo rate = wmi_rate_tbl[index][sgi]; 1101bdcd8170SKalle Valo } 1102bdcd8170SKalle Valo 1103bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1104bdcd8170SKalle Valo 1105bdcd8170SKalle Valo return 0; 1106bdcd8170SKalle Valo } 1107bdcd8170SKalle Valo 1108bdcd8170SKalle Valo static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) 1109bdcd8170SKalle Valo { 1110bdcd8170SKalle Valo if (len < sizeof(struct wmi_fix_rates_reply)) 1111bdcd8170SKalle Valo return -EINVAL; 1112bdcd8170SKalle Valo 1113bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1114bdcd8170SKalle Valo 1115bdcd8170SKalle Valo return 0; 1116bdcd8170SKalle Valo } 1117bdcd8170SKalle Valo 1118bdcd8170SKalle Valo static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) 1119bdcd8170SKalle Valo { 1120bdcd8170SKalle Valo if (len < sizeof(struct wmi_channel_list_reply)) 1121bdcd8170SKalle Valo return -EINVAL; 1122bdcd8170SKalle Valo 1123bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1124bdcd8170SKalle Valo 1125bdcd8170SKalle Valo return 0; 1126bdcd8170SKalle Valo } 1127bdcd8170SKalle Valo 1128bdcd8170SKalle Valo static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) 1129bdcd8170SKalle Valo { 1130bdcd8170SKalle Valo struct wmi_tx_pwr_reply *reply; 1131bdcd8170SKalle Valo 1132bdcd8170SKalle Valo if (len < sizeof(struct wmi_tx_pwr_reply)) 1133bdcd8170SKalle Valo return -EINVAL; 1134bdcd8170SKalle Valo 1135bdcd8170SKalle Valo reply = (struct wmi_tx_pwr_reply *) datap; 1136bdcd8170SKalle Valo ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); 1137bdcd8170SKalle Valo 1138bdcd8170SKalle Valo return 0; 1139bdcd8170SKalle Valo } 1140bdcd8170SKalle Valo 1141bdcd8170SKalle Valo static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) 1142bdcd8170SKalle Valo { 1143bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_keepalive_cmd)) 1144bdcd8170SKalle Valo return -EINVAL; 1145bdcd8170SKalle Valo 1146bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1147bdcd8170SKalle Valo 1148bdcd8170SKalle Valo return 0; 1149bdcd8170SKalle Valo } 1150bdcd8170SKalle Valo 1151bdcd8170SKalle Valo static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len) 1152bdcd8170SKalle Valo { 1153bdcd8170SKalle Valo struct wmi_scan_complete_event *ev; 1154bdcd8170SKalle Valo 1155bdcd8170SKalle Valo ev = (struct wmi_scan_complete_event *) datap; 1156bdcd8170SKalle Valo 1157bdcd8170SKalle Valo if (a_sle32_to_cpu(ev->status) == 0) 1158e4c7ffcbSVasanthakumar Thiagarajan wlan_refresh_inactive_nodes(wmi->parent_dev); 1159bdcd8170SKalle Valo 1160bdcd8170SKalle Valo ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status)); 1161bdcd8170SKalle Valo wmi->is_probe_ssid = false; 1162bdcd8170SKalle Valo 1163bdcd8170SKalle Valo return 0; 1164bdcd8170SKalle Valo } 1165bdcd8170SKalle Valo 1166bdcd8170SKalle Valo /* 1167bdcd8170SKalle Valo * Target is reporting a programming error. This is for 1168bdcd8170SKalle Valo * developer aid only. Target only checks a few common violations 1169bdcd8170SKalle Valo * and it is responsibility of host to do all error checking. 1170bdcd8170SKalle Valo * Behavior of target after wmi error event is undefined. 1171bdcd8170SKalle Valo * A reset is recommended. 1172bdcd8170SKalle Valo */ 1173bdcd8170SKalle Valo static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) 1174bdcd8170SKalle Valo { 1175bdcd8170SKalle Valo const char *type = "unknown error"; 1176bdcd8170SKalle Valo struct wmi_cmd_error_event *ev; 1177bdcd8170SKalle Valo ev = (struct wmi_cmd_error_event *) datap; 1178bdcd8170SKalle Valo 1179bdcd8170SKalle Valo switch (ev->err_code) { 1180bdcd8170SKalle Valo case INVALID_PARAM: 1181bdcd8170SKalle Valo type = "invalid parameter"; 1182bdcd8170SKalle Valo break; 1183bdcd8170SKalle Valo case ILLEGAL_STATE: 1184bdcd8170SKalle Valo type = "invalid state"; 1185bdcd8170SKalle Valo break; 1186bdcd8170SKalle Valo case INTERNAL_ERROR: 1187bdcd8170SKalle Valo type = "internal error"; 1188bdcd8170SKalle Valo break; 1189bdcd8170SKalle Valo } 1190bdcd8170SKalle Valo 1191bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", 1192bdcd8170SKalle Valo ev->cmd_id, type); 1193bdcd8170SKalle Valo 1194bdcd8170SKalle Valo return 0; 1195bdcd8170SKalle Valo } 1196bdcd8170SKalle Valo 1197bdcd8170SKalle Valo static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len) 1198bdcd8170SKalle Valo { 1199bdcd8170SKalle Valo ath6kl_tgt_stats_event(wmi->parent_dev, datap, len); 1200bdcd8170SKalle Valo 1201bdcd8170SKalle Valo return 0; 1202bdcd8170SKalle Valo } 1203bdcd8170SKalle Valo 1204bdcd8170SKalle Valo static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, 1205bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1206bdcd8170SKalle Valo u32 size) 1207bdcd8170SKalle Valo { 1208bdcd8170SKalle Valo u32 index; 1209bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; 1210bdcd8170SKalle Valo 1211bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1212bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1213bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[index]) { 1214bdcd8170SKalle Valo threshold = (u8) sq_thresh->upper_threshold[index]; 1215bdcd8170SKalle Valo break; 1216bdcd8170SKalle Valo } 1217bdcd8170SKalle Valo } 1218bdcd8170SKalle Valo 1219bdcd8170SKalle Valo return threshold; 1220bdcd8170SKalle Valo } 1221bdcd8170SKalle Valo 1222bdcd8170SKalle Valo static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, 1223bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1224bdcd8170SKalle Valo u32 size) 1225bdcd8170SKalle Valo { 1226bdcd8170SKalle Valo u32 index; 1227bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; 1228bdcd8170SKalle Valo 1229bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1230bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1231bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[index]) { 1232bdcd8170SKalle Valo threshold = (u8) sq_thresh->lower_threshold[index]; 1233bdcd8170SKalle Valo break; 1234bdcd8170SKalle Valo } 1235bdcd8170SKalle Valo } 1236bdcd8170SKalle Valo 1237bdcd8170SKalle Valo return threshold; 1238bdcd8170SKalle Valo } 1239bdcd8170SKalle Valo 1240bdcd8170SKalle Valo static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, 1241bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *rssi_cmd) 1242bdcd8170SKalle Valo { 1243bdcd8170SKalle Valo struct sk_buff *skb; 1244bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *cmd; 1245bdcd8170SKalle Valo 1246bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1247bdcd8170SKalle Valo if (!skb) 1248bdcd8170SKalle Valo return -ENOMEM; 1249bdcd8170SKalle Valo 1250bdcd8170SKalle Valo cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; 1251bdcd8170SKalle Valo memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); 1252bdcd8170SKalle Valo 1253bdcd8170SKalle Valo return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, 1254bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1255bdcd8170SKalle Valo } 1256bdcd8170SKalle Valo 1257bdcd8170SKalle Valo static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, 1258bdcd8170SKalle Valo int len) 1259bdcd8170SKalle Valo { 1260bdcd8170SKalle Valo struct wmi_rssi_threshold_event *reply; 1261bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd cmd; 1262bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1263bdcd8170SKalle Valo enum wmi_rssi_threshold_val new_threshold; 1264bdcd8170SKalle Valo u8 upper_rssi_threshold, lower_rssi_threshold; 1265bdcd8170SKalle Valo s16 rssi; 1266bdcd8170SKalle Valo int ret; 1267bdcd8170SKalle Valo 1268bdcd8170SKalle Valo if (len < sizeof(struct wmi_rssi_threshold_event)) 1269bdcd8170SKalle Valo return -EINVAL; 1270bdcd8170SKalle Valo 1271bdcd8170SKalle Valo reply = (struct wmi_rssi_threshold_event *) datap; 1272bdcd8170SKalle Valo new_threshold = (enum wmi_rssi_threshold_val) reply->range; 1273bdcd8170SKalle Valo rssi = a_sle16_to_cpu(reply->rssi); 1274bdcd8170SKalle Valo 1275bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; 1276bdcd8170SKalle Valo 1277bdcd8170SKalle Valo /* 1278bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1279bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1280bdcd8170SKalle Valo * quality reported by the target 1281bdcd8170SKalle Valo */ 1282bdcd8170SKalle Valo if (new_threshold) { 1283bdcd8170SKalle Valo /* Upper threshold breached */ 1284bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[0]) { 1285bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1286bdcd8170SKalle Valo "spurious upper rssi threshold event: %d\n", 1287bdcd8170SKalle Valo rssi); 1288bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[1]) && 1289bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[0])) { 1290bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; 1291bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[2]) && 1292bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[1])) { 1293bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; 1294bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[3]) && 1295bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[2])) { 1296bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; 1297bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[4]) && 1298bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[3])) { 1299bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; 1300bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[5]) && 1301bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[4])) { 1302bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; 1303bdcd8170SKalle Valo } else if (rssi >= sq_thresh->upper_threshold[5]) { 1304bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; 1305bdcd8170SKalle Valo } 1306bdcd8170SKalle Valo } else { 1307bdcd8170SKalle Valo /* Lower threshold breached */ 1308bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[0]) { 1309bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1310bdcd8170SKalle Valo "spurious lower rssi threshold event: %d %d\n", 1311bdcd8170SKalle Valo rssi, sq_thresh->lower_threshold[0]); 1312bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[1]) && 1313bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[0])) { 1314bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_BELOW; 1315bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[2]) && 1316bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[1])) { 1317bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_BELOW; 1318bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[3]) && 1319bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[2])) { 1320bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_BELOW; 1321bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[4]) && 1322bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[3])) { 1323bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_BELOW; 1324bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[5]) && 1325bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[4])) { 1326bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_BELOW; 1327bdcd8170SKalle Valo } else if (rssi <= sq_thresh->lower_threshold[5]) { 1328bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_BELOW; 1329bdcd8170SKalle Valo } 1330bdcd8170SKalle Valo } 1331bdcd8170SKalle Valo 1332bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1333bdcd8170SKalle Valo lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, 1334bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1335bdcd8170SKalle Valo upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, 1336bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1337bdcd8170SKalle Valo 1338bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1339bdcd8170SKalle Valo cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); 1340bdcd8170SKalle Valo cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); 1341bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1342bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1343bdcd8170SKalle Valo 1344bdcd8170SKalle Valo ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); 1345bdcd8170SKalle Valo if (ret) { 1346bdcd8170SKalle Valo ath6kl_err("unable to configure rssi thresholds\n"); 1347bdcd8170SKalle Valo return -EIO; 1348bdcd8170SKalle Valo } 1349bdcd8170SKalle Valo 1350bdcd8170SKalle Valo return 0; 1351bdcd8170SKalle Valo } 1352bdcd8170SKalle Valo 1353bdcd8170SKalle Valo static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) 1354bdcd8170SKalle Valo { 1355bdcd8170SKalle Valo struct wmi_cac_event *reply; 1356bdcd8170SKalle Valo struct ieee80211_tspec_ie *ts; 1357bdcd8170SKalle Valo u16 active_tsids, tsinfo; 1358bdcd8170SKalle Valo u8 tsid, index; 1359bdcd8170SKalle Valo u8 ts_id; 1360bdcd8170SKalle Valo 1361bdcd8170SKalle Valo if (len < sizeof(struct wmi_cac_event)) 1362bdcd8170SKalle Valo return -EINVAL; 1363bdcd8170SKalle Valo 1364bdcd8170SKalle Valo reply = (struct wmi_cac_event *) datap; 1365bdcd8170SKalle Valo 1366bdcd8170SKalle Valo if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && 1367bdcd8170SKalle Valo (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { 1368bdcd8170SKalle Valo 1369bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1370bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1371bdcd8170SKalle Valo tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1372bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK; 1373bdcd8170SKalle Valo 1374bdcd8170SKalle Valo ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid); 1375bdcd8170SKalle Valo } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { 1376bdcd8170SKalle Valo /* 1377bdcd8170SKalle Valo * Following assumes that there is only one outstanding 1378bdcd8170SKalle Valo * ADDTS request when this event is received 1379bdcd8170SKalle Valo */ 1380bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1381bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1382bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1383bdcd8170SKalle Valo 1384bdcd8170SKalle Valo for (index = 0; index < sizeof(active_tsids) * 8; index++) { 1385bdcd8170SKalle Valo if ((active_tsids >> index) & 1) 1386bdcd8170SKalle Valo break; 1387bdcd8170SKalle Valo } 1388bdcd8170SKalle Valo if (index < (sizeof(active_tsids) * 8)) 1389bdcd8170SKalle Valo ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index); 1390bdcd8170SKalle Valo } 1391bdcd8170SKalle Valo 1392bdcd8170SKalle Valo /* 1393bdcd8170SKalle Valo * Clear active tsids and Add missing handling 1394bdcd8170SKalle Valo * for delete qos stream from AP 1395bdcd8170SKalle Valo */ 1396bdcd8170SKalle Valo else if (reply->cac_indication == CAC_INDICATION_DELETE) { 1397bdcd8170SKalle Valo 1398bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1399bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1400bdcd8170SKalle Valo ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1401bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK); 1402bdcd8170SKalle Valo 1403bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1404bdcd8170SKalle Valo wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); 1405bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1406bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1407bdcd8170SKalle Valo 1408bdcd8170SKalle Valo /* Indicate stream inactivity to driver layer only if all tsids 1409bdcd8170SKalle Valo * within this AC are deleted. 1410bdcd8170SKalle Valo */ 1411bdcd8170SKalle Valo if (!active_tsids) { 1412bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, 1413bdcd8170SKalle Valo false); 1414bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << reply->ac); 1415bdcd8170SKalle Valo } 1416bdcd8170SKalle Valo } 1417bdcd8170SKalle Valo 1418bdcd8170SKalle Valo return 0; 1419bdcd8170SKalle Valo } 1420bdcd8170SKalle Valo 1421bdcd8170SKalle Valo static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, 1422bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *snr_cmd) 1423bdcd8170SKalle Valo { 1424bdcd8170SKalle Valo struct sk_buff *skb; 1425bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *cmd; 1426bdcd8170SKalle Valo 1427bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1428bdcd8170SKalle Valo if (!skb) 1429bdcd8170SKalle Valo return -ENOMEM; 1430bdcd8170SKalle Valo 1431bdcd8170SKalle Valo cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; 1432bdcd8170SKalle Valo memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); 1433bdcd8170SKalle Valo 1434bdcd8170SKalle Valo return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, 1435bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1436bdcd8170SKalle Valo } 1437bdcd8170SKalle Valo 1438bdcd8170SKalle Valo static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, 1439bdcd8170SKalle Valo int len) 1440bdcd8170SKalle Valo { 1441bdcd8170SKalle Valo struct wmi_snr_threshold_event *reply; 1442bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1443bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd cmd; 1444bdcd8170SKalle Valo enum wmi_snr_threshold_val new_threshold; 1445bdcd8170SKalle Valo u8 upper_snr_threshold, lower_snr_threshold; 1446bdcd8170SKalle Valo s16 snr; 1447bdcd8170SKalle Valo int ret; 1448bdcd8170SKalle Valo 1449bdcd8170SKalle Valo if (len < sizeof(struct wmi_snr_threshold_event)) 1450bdcd8170SKalle Valo return -EINVAL; 1451bdcd8170SKalle Valo 1452bdcd8170SKalle Valo reply = (struct wmi_snr_threshold_event *) datap; 1453bdcd8170SKalle Valo 1454bdcd8170SKalle Valo new_threshold = (enum wmi_snr_threshold_val) reply->range; 1455bdcd8170SKalle Valo snr = reply->snr; 1456bdcd8170SKalle Valo 1457bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; 1458bdcd8170SKalle Valo 1459bdcd8170SKalle Valo /* 1460bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1461bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1462bdcd8170SKalle Valo * quality reported by the target. 1463bdcd8170SKalle Valo */ 1464bdcd8170SKalle Valo if (new_threshold) { 1465bdcd8170SKalle Valo /* Upper threshold breached */ 1466bdcd8170SKalle Valo if (snr < sq_thresh->upper_threshold[0]) { 1467bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1468bdcd8170SKalle Valo "spurious upper snr threshold event: %d\n", 1469bdcd8170SKalle Valo snr); 1470bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[1]) && 1471bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[0])) { 1472bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_ABOVE; 1473bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[2]) && 1474bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[1])) { 1475bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_ABOVE; 1476bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[3]) && 1477bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[2])) { 1478bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_ABOVE; 1479bdcd8170SKalle Valo } else if (snr >= sq_thresh->upper_threshold[3]) { 1480bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_ABOVE; 1481bdcd8170SKalle Valo } 1482bdcd8170SKalle Valo } else { 1483bdcd8170SKalle Valo /* Lower threshold breached */ 1484bdcd8170SKalle Valo if (snr > sq_thresh->lower_threshold[0]) { 1485bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1486bdcd8170SKalle Valo "spurious lower snr threshold event: %d\n", 1487bdcd8170SKalle Valo sq_thresh->lower_threshold[0]); 1488bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[1]) && 1489bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[0])) { 1490bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_BELOW; 1491bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[2]) && 1492bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[1])) { 1493bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_BELOW; 1494bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[3]) && 1495bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[2])) { 1496bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_BELOW; 1497bdcd8170SKalle Valo } else if (snr <= sq_thresh->lower_threshold[3]) { 1498bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_BELOW; 1499bdcd8170SKalle Valo } 1500bdcd8170SKalle Valo } 1501bdcd8170SKalle Valo 1502bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1503bdcd8170SKalle Valo lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, 1504bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1505bdcd8170SKalle Valo upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, 1506bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1507bdcd8170SKalle Valo 1508bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1509bdcd8170SKalle Valo cmd.thresh_above1_val = upper_snr_threshold; 1510bdcd8170SKalle Valo cmd.thresh_below1_val = lower_snr_threshold; 1511bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1512bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1513bdcd8170SKalle Valo 1514bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1515bdcd8170SKalle Valo "snr: %d, threshold: %d, lower: %d, upper: %d\n", 1516bdcd8170SKalle Valo snr, new_threshold, 1517bdcd8170SKalle Valo lower_snr_threshold, upper_snr_threshold); 1518bdcd8170SKalle Valo 1519bdcd8170SKalle Valo ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); 1520bdcd8170SKalle Valo if (ret) { 1521bdcd8170SKalle Valo ath6kl_err("unable to configure snr threshold\n"); 1522bdcd8170SKalle Valo return -EIO; 1523bdcd8170SKalle Valo } 1524bdcd8170SKalle Valo 1525bdcd8170SKalle Valo return 0; 1526bdcd8170SKalle Valo } 1527bdcd8170SKalle Valo 1528bdcd8170SKalle Valo static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) 1529bdcd8170SKalle Valo { 1530bdcd8170SKalle Valo u16 ap_info_entry_size; 1531bdcd8170SKalle Valo struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; 1532bdcd8170SKalle Valo struct wmi_ap_info_v1 *ap_info_v1; 1533bdcd8170SKalle Valo u8 index; 1534bdcd8170SKalle Valo 1535bdcd8170SKalle Valo if (len < sizeof(struct wmi_aplist_event) || 1536bdcd8170SKalle Valo ev->ap_list_ver != APLIST_VER1) 1537bdcd8170SKalle Valo return -EINVAL; 1538bdcd8170SKalle Valo 1539bdcd8170SKalle Valo ap_info_entry_size = sizeof(struct wmi_ap_info_v1); 1540bdcd8170SKalle Valo ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; 1541bdcd8170SKalle Valo 1542bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1543bdcd8170SKalle Valo "number of APs in aplist event: %d\n", ev->num_ap); 1544bdcd8170SKalle Valo 1545bdcd8170SKalle Valo if (len < (int) (sizeof(struct wmi_aplist_event) + 1546bdcd8170SKalle Valo (ev->num_ap - 1) * ap_info_entry_size)) 1547bdcd8170SKalle Valo return -EINVAL; 1548bdcd8170SKalle Valo 1549bdcd8170SKalle Valo /* AP list version 1 contents */ 1550bdcd8170SKalle Valo for (index = 0; index < ev->num_ap; index++) { 1551bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", 1552bdcd8170SKalle Valo index, ap_info_v1->bssid, ap_info_v1->channel); 1553bdcd8170SKalle Valo ap_info_v1++; 1554bdcd8170SKalle Valo } 1555bdcd8170SKalle Valo 1556bdcd8170SKalle Valo return 0; 1557bdcd8170SKalle Valo } 1558bdcd8170SKalle Valo 1559bdcd8170SKalle Valo int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, 1560bdcd8170SKalle Valo enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) 1561bdcd8170SKalle Valo { 1562bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd_hdr; 1563bdcd8170SKalle Valo enum htc_endpoint_id ep_id = wmi->ep_id; 1564bdcd8170SKalle Valo int ret; 1565bdcd8170SKalle Valo 15666a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: cmd_id=%d\n", __func__, cmd_id); 15676a7c9badSJouni Malinen 1568bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 1569bdcd8170SKalle Valo return -EINVAL; 1570bdcd8170SKalle Valo 1571bdcd8170SKalle Valo if (sync_flag >= END_WMIFLAG) { 1572bdcd8170SKalle Valo dev_kfree_skb(skb); 1573bdcd8170SKalle Valo return -EINVAL; 1574bdcd8170SKalle Valo } 1575bdcd8170SKalle Valo 1576bdcd8170SKalle Valo if ((sync_flag == SYNC_BEFORE_WMIFLAG) || 1577bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1578bdcd8170SKalle Valo /* 1579bdcd8170SKalle Valo * Make sure all data currently queued is transmitted before 1580bdcd8170SKalle Valo * the cmd execution. Establish a new sync point. 1581bdcd8170SKalle Valo */ 1582bdcd8170SKalle Valo ath6kl_wmi_sync_point(wmi); 1583bdcd8170SKalle Valo } 1584bdcd8170SKalle Valo 1585bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_cmd_hdr)); 1586bdcd8170SKalle Valo 1587bdcd8170SKalle Valo cmd_hdr = (struct wmi_cmd_hdr *) skb->data; 1588bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le16(cmd_id); 1589bdcd8170SKalle Valo cmd_hdr->info1 = 0; /* added for virtual interface */ 1590bdcd8170SKalle Valo 1591bdcd8170SKalle Valo /* Only for OPT_TX_CMD, use BE endpoint. */ 1592bdcd8170SKalle Valo if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { 1593bdcd8170SKalle Valo ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, 1594bdcd8170SKalle Valo false, false, 0, NULL); 1595bdcd8170SKalle Valo if (ret) { 1596bdcd8170SKalle Valo dev_kfree_skb(skb); 1597bdcd8170SKalle Valo return ret; 1598bdcd8170SKalle Valo } 1599bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); 1600bdcd8170SKalle Valo } 1601bdcd8170SKalle Valo 1602bdcd8170SKalle Valo ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 1603bdcd8170SKalle Valo 1604bdcd8170SKalle Valo if ((sync_flag == SYNC_AFTER_WMIFLAG) || 1605bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1606bdcd8170SKalle Valo /* 1607bdcd8170SKalle Valo * Make sure all new data queued waits for the command to 1608bdcd8170SKalle Valo * execute. Establish a new sync point. 1609bdcd8170SKalle Valo */ 1610bdcd8170SKalle Valo ath6kl_wmi_sync_point(wmi); 1611bdcd8170SKalle Valo } 1612bdcd8170SKalle Valo 1613bdcd8170SKalle Valo return 0; 1614bdcd8170SKalle Valo } 1615bdcd8170SKalle Valo 1616bdcd8170SKalle Valo int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, 1617bdcd8170SKalle Valo enum dot11_auth_mode dot11_auth_mode, 1618bdcd8170SKalle Valo enum auth_mode auth_mode, 1619bdcd8170SKalle Valo enum crypto_type pairwise_crypto, 1620bdcd8170SKalle Valo u8 pairwise_crypto_len, 1621bdcd8170SKalle Valo enum crypto_type group_crypto, 1622bdcd8170SKalle Valo u8 group_crypto_len, int ssid_len, u8 *ssid, 1623bdcd8170SKalle Valo u8 *bssid, u16 channel, u32 ctrl_flags) 1624bdcd8170SKalle Valo { 1625bdcd8170SKalle Valo struct sk_buff *skb; 1626bdcd8170SKalle Valo struct wmi_connect_cmd *cc; 1627bdcd8170SKalle Valo int ret; 1628bdcd8170SKalle Valo 1629bdcd8170SKalle Valo wmi->traffic_class = 100; 1630bdcd8170SKalle Valo 1631bdcd8170SKalle Valo if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) 1632bdcd8170SKalle Valo return -EINVAL; 1633bdcd8170SKalle Valo 1634bdcd8170SKalle Valo if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) 1635bdcd8170SKalle Valo return -EINVAL; 1636bdcd8170SKalle Valo 1637bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); 1638bdcd8170SKalle Valo if (!skb) 1639bdcd8170SKalle Valo return -ENOMEM; 1640bdcd8170SKalle Valo 1641bdcd8170SKalle Valo cc = (struct wmi_connect_cmd *) skb->data; 1642bdcd8170SKalle Valo 1643bdcd8170SKalle Valo if (ssid_len) 1644bdcd8170SKalle Valo memcpy(cc->ssid, ssid, ssid_len); 1645bdcd8170SKalle Valo 1646bdcd8170SKalle Valo cc->ssid_len = ssid_len; 1647bdcd8170SKalle Valo cc->nw_type = nw_type; 1648bdcd8170SKalle Valo cc->dot11_auth_mode = dot11_auth_mode; 1649bdcd8170SKalle Valo cc->auth_mode = auth_mode; 1650bdcd8170SKalle Valo cc->prwise_crypto_type = pairwise_crypto; 1651bdcd8170SKalle Valo cc->prwise_crypto_len = pairwise_crypto_len; 1652bdcd8170SKalle Valo cc->grp_crypto_type = group_crypto; 1653bdcd8170SKalle Valo cc->grp_crypto_len = group_crypto_len; 1654bdcd8170SKalle Valo cc->ch = cpu_to_le16(channel); 1655bdcd8170SKalle Valo cc->ctrl_flags = cpu_to_le32(ctrl_flags); 1656bdcd8170SKalle Valo 1657bdcd8170SKalle Valo if (bssid != NULL) 1658bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1659bdcd8170SKalle Valo 1660bdcd8170SKalle Valo wmi->pair_crypto_type = pairwise_crypto; 1661bdcd8170SKalle Valo wmi->grp_crypto_type = group_crypto; 1662bdcd8170SKalle Valo 1663bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG); 1664bdcd8170SKalle Valo 1665bdcd8170SKalle Valo return ret; 1666bdcd8170SKalle Valo } 1667bdcd8170SKalle Valo 1668bdcd8170SKalle Valo int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel) 1669bdcd8170SKalle Valo { 1670bdcd8170SKalle Valo struct sk_buff *skb; 1671bdcd8170SKalle Valo struct wmi_reconnect_cmd *cc; 1672bdcd8170SKalle Valo int ret; 1673bdcd8170SKalle Valo 1674bdcd8170SKalle Valo wmi->traffic_class = 100; 1675bdcd8170SKalle Valo 1676bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); 1677bdcd8170SKalle Valo if (!skb) 1678bdcd8170SKalle Valo return -ENOMEM; 1679bdcd8170SKalle Valo 1680bdcd8170SKalle Valo cc = (struct wmi_reconnect_cmd *) skb->data; 1681bdcd8170SKalle Valo cc->channel = cpu_to_le16(channel); 1682bdcd8170SKalle Valo 1683bdcd8170SKalle Valo if (bssid != NULL) 1684bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1685bdcd8170SKalle Valo 1686bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID, 1687bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1688bdcd8170SKalle Valo 1689bdcd8170SKalle Valo return ret; 1690bdcd8170SKalle Valo } 1691bdcd8170SKalle Valo 1692bdcd8170SKalle Valo int ath6kl_wmi_disconnect_cmd(struct wmi *wmi) 1693bdcd8170SKalle Valo { 1694bdcd8170SKalle Valo int ret; 1695bdcd8170SKalle Valo 1696bdcd8170SKalle Valo wmi->traffic_class = 100; 1697bdcd8170SKalle Valo 1698bdcd8170SKalle Valo /* Disconnect command does not need to do a SYNC before. */ 1699bdcd8170SKalle Valo ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID); 1700bdcd8170SKalle Valo 1701bdcd8170SKalle Valo return ret; 1702bdcd8170SKalle Valo } 1703bdcd8170SKalle Valo 1704bdcd8170SKalle Valo int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, 1705bdcd8170SKalle Valo u32 force_fgscan, u32 is_legacy, 1706bdcd8170SKalle Valo u32 home_dwell_time, u32 force_scan_interval, 1707bdcd8170SKalle Valo s8 num_chan, u16 *ch_list) 1708bdcd8170SKalle Valo { 1709bdcd8170SKalle Valo struct sk_buff *skb; 1710bdcd8170SKalle Valo struct wmi_start_scan_cmd *sc; 1711bdcd8170SKalle Valo s8 size; 1712bdcd8170SKalle Valo int ret; 1713bdcd8170SKalle Valo 1714bdcd8170SKalle Valo size = sizeof(struct wmi_start_scan_cmd); 1715bdcd8170SKalle Valo 1716bdcd8170SKalle Valo if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 1717bdcd8170SKalle Valo return -EINVAL; 1718bdcd8170SKalle Valo 1719bdcd8170SKalle Valo if (num_chan > WMI_MAX_CHANNELS) 1720bdcd8170SKalle Valo return -EINVAL; 1721bdcd8170SKalle Valo 1722bdcd8170SKalle Valo if (num_chan) 1723bdcd8170SKalle Valo size += sizeof(u16) * (num_chan - 1); 1724bdcd8170SKalle Valo 1725bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(size); 1726bdcd8170SKalle Valo if (!skb) 1727bdcd8170SKalle Valo return -ENOMEM; 1728bdcd8170SKalle Valo 1729bdcd8170SKalle Valo sc = (struct wmi_start_scan_cmd *) skb->data; 1730bdcd8170SKalle Valo sc->scan_type = scan_type; 1731bdcd8170SKalle Valo sc->force_fg_scan = cpu_to_le32(force_fgscan); 1732bdcd8170SKalle Valo sc->is_legacy = cpu_to_le32(is_legacy); 1733bdcd8170SKalle Valo sc->home_dwell_time = cpu_to_le32(home_dwell_time); 1734bdcd8170SKalle Valo sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 1735bdcd8170SKalle Valo sc->num_ch = num_chan; 1736bdcd8170SKalle Valo 1737bdcd8170SKalle Valo if (num_chan) 1738bdcd8170SKalle Valo memcpy(sc->ch_list, ch_list, num_chan * sizeof(u16)); 1739bdcd8170SKalle Valo 1740bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID, 1741bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1742bdcd8170SKalle Valo 1743bdcd8170SKalle Valo return ret; 1744bdcd8170SKalle Valo } 1745bdcd8170SKalle Valo 1746bdcd8170SKalle Valo int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, 1747bdcd8170SKalle Valo u16 fg_end_sec, u16 bg_sec, 1748bdcd8170SKalle Valo u16 minact_chdw_msec, u16 maxact_chdw_msec, 1749bdcd8170SKalle Valo u16 pas_chdw_msec, u8 short_scan_ratio, 1750bdcd8170SKalle Valo u8 scan_ctrl_flag, u32 max_dfsch_act_time, 1751bdcd8170SKalle Valo u16 maxact_scan_per_ssid) 1752bdcd8170SKalle Valo { 1753bdcd8170SKalle Valo struct sk_buff *skb; 1754bdcd8170SKalle Valo struct wmi_scan_params_cmd *sc; 1755bdcd8170SKalle Valo int ret; 1756bdcd8170SKalle Valo 1757bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); 1758bdcd8170SKalle Valo if (!skb) 1759bdcd8170SKalle Valo return -ENOMEM; 1760bdcd8170SKalle Valo 1761bdcd8170SKalle Valo sc = (struct wmi_scan_params_cmd *) skb->data; 1762bdcd8170SKalle Valo sc->fg_start_period = cpu_to_le16(fg_start_sec); 1763bdcd8170SKalle Valo sc->fg_end_period = cpu_to_le16(fg_end_sec); 1764bdcd8170SKalle Valo sc->bg_period = cpu_to_le16(bg_sec); 1765bdcd8170SKalle Valo sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); 1766bdcd8170SKalle Valo sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); 1767bdcd8170SKalle Valo sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); 1768bdcd8170SKalle Valo sc->short_scan_ratio = short_scan_ratio; 1769bdcd8170SKalle Valo sc->scan_ctrl_flags = scan_ctrl_flag; 1770bdcd8170SKalle Valo sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); 1771bdcd8170SKalle Valo sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); 1772bdcd8170SKalle Valo 1773bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID, 1774bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1775bdcd8170SKalle Valo return ret; 1776bdcd8170SKalle Valo } 1777bdcd8170SKalle Valo 1778bdcd8170SKalle Valo int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) 1779bdcd8170SKalle Valo { 1780bdcd8170SKalle Valo struct sk_buff *skb; 1781bdcd8170SKalle Valo struct wmi_bss_filter_cmd *cmd; 1782bdcd8170SKalle Valo int ret; 1783bdcd8170SKalle Valo 1784bdcd8170SKalle Valo if (filter >= LAST_BSS_FILTER) 1785bdcd8170SKalle Valo return -EINVAL; 1786bdcd8170SKalle Valo 1787bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1788bdcd8170SKalle Valo if (!skb) 1789bdcd8170SKalle Valo return -ENOMEM; 1790bdcd8170SKalle Valo 1791bdcd8170SKalle Valo cmd = (struct wmi_bss_filter_cmd *) skb->data; 1792bdcd8170SKalle Valo cmd->bss_filter = filter; 1793bdcd8170SKalle Valo cmd->ie_mask = cpu_to_le32(ie_mask); 1794bdcd8170SKalle Valo 1795bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID, 1796bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1797bdcd8170SKalle Valo return ret; 1798bdcd8170SKalle Valo } 1799bdcd8170SKalle Valo 1800bdcd8170SKalle Valo int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, 1801bdcd8170SKalle Valo u8 ssid_len, u8 *ssid) 1802bdcd8170SKalle Valo { 1803bdcd8170SKalle Valo struct sk_buff *skb; 1804bdcd8170SKalle Valo struct wmi_probed_ssid_cmd *cmd; 1805bdcd8170SKalle Valo int ret; 1806bdcd8170SKalle Valo 1807bdcd8170SKalle Valo if (index > MAX_PROBED_SSID_INDEX) 1808bdcd8170SKalle Valo return -EINVAL; 1809bdcd8170SKalle Valo 1810bdcd8170SKalle Valo if (ssid_len > sizeof(cmd->ssid)) 1811bdcd8170SKalle Valo return -EINVAL; 1812bdcd8170SKalle Valo 1813bdcd8170SKalle Valo if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) 1814bdcd8170SKalle Valo return -EINVAL; 1815bdcd8170SKalle Valo 1816bdcd8170SKalle Valo if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) 1817bdcd8170SKalle Valo return -EINVAL; 1818bdcd8170SKalle Valo 1819bdcd8170SKalle Valo if (flag & SPECIFIC_SSID_FLAG) 1820bdcd8170SKalle Valo wmi->is_probe_ssid = true; 1821bdcd8170SKalle Valo 1822bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1823bdcd8170SKalle Valo if (!skb) 1824bdcd8170SKalle Valo return -ENOMEM; 1825bdcd8170SKalle Valo 1826bdcd8170SKalle Valo cmd = (struct wmi_probed_ssid_cmd *) skb->data; 1827bdcd8170SKalle Valo cmd->entry_index = index; 1828bdcd8170SKalle Valo cmd->flag = flag; 1829bdcd8170SKalle Valo cmd->ssid_len = ssid_len; 1830bdcd8170SKalle Valo memcpy(cmd->ssid, ssid, ssid_len); 1831bdcd8170SKalle Valo 1832bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID, 1833bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1834bdcd8170SKalle Valo return ret; 1835bdcd8170SKalle Valo } 1836bdcd8170SKalle Valo 1837bdcd8170SKalle Valo int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, 1838bdcd8170SKalle Valo u16 listen_beacons) 1839bdcd8170SKalle Valo { 1840bdcd8170SKalle Valo struct sk_buff *skb; 1841bdcd8170SKalle Valo struct wmi_listen_int_cmd *cmd; 1842bdcd8170SKalle Valo int ret; 1843bdcd8170SKalle Valo 1844bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1845bdcd8170SKalle Valo if (!skb) 1846bdcd8170SKalle Valo return -ENOMEM; 1847bdcd8170SKalle Valo 1848bdcd8170SKalle Valo cmd = (struct wmi_listen_int_cmd *) skb->data; 1849bdcd8170SKalle Valo cmd->listen_intvl = cpu_to_le16(listen_interval); 1850bdcd8170SKalle Valo cmd->num_beacons = cpu_to_le16(listen_beacons); 1851bdcd8170SKalle Valo 1852bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID, 1853bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1854bdcd8170SKalle Valo return ret; 1855bdcd8170SKalle Valo } 1856bdcd8170SKalle Valo 1857bdcd8170SKalle Valo int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode) 1858bdcd8170SKalle Valo { 1859bdcd8170SKalle Valo struct sk_buff *skb; 1860bdcd8170SKalle Valo struct wmi_power_mode_cmd *cmd; 1861bdcd8170SKalle Valo int ret; 1862bdcd8170SKalle Valo 1863bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1864bdcd8170SKalle Valo if (!skb) 1865bdcd8170SKalle Valo return -ENOMEM; 1866bdcd8170SKalle Valo 1867bdcd8170SKalle Valo cmd = (struct wmi_power_mode_cmd *) skb->data; 1868bdcd8170SKalle Valo cmd->pwr_mode = pwr_mode; 1869bdcd8170SKalle Valo wmi->pwr_mode = pwr_mode; 1870bdcd8170SKalle Valo 1871bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID, 1872bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1873bdcd8170SKalle Valo return ret; 1874bdcd8170SKalle Valo } 1875bdcd8170SKalle Valo 1876bdcd8170SKalle Valo int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, 1877bdcd8170SKalle Valo u16 ps_poll_num, u16 dtim_policy, 1878bdcd8170SKalle Valo u16 tx_wakeup_policy, u16 num_tx_to_wakeup, 1879bdcd8170SKalle Valo u16 ps_fail_event_policy) 1880bdcd8170SKalle Valo { 1881bdcd8170SKalle Valo struct sk_buff *skb; 1882bdcd8170SKalle Valo struct wmi_power_params_cmd *pm; 1883bdcd8170SKalle Valo int ret; 1884bdcd8170SKalle Valo 1885bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); 1886bdcd8170SKalle Valo if (!skb) 1887bdcd8170SKalle Valo return -ENOMEM; 1888bdcd8170SKalle Valo 1889bdcd8170SKalle Valo pm = (struct wmi_power_params_cmd *)skb->data; 1890bdcd8170SKalle Valo pm->idle_period = cpu_to_le16(idle_period); 1891bdcd8170SKalle Valo pm->pspoll_number = cpu_to_le16(ps_poll_num); 1892bdcd8170SKalle Valo pm->dtim_policy = cpu_to_le16(dtim_policy); 1893bdcd8170SKalle Valo pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); 1894bdcd8170SKalle Valo pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); 1895bdcd8170SKalle Valo pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); 1896bdcd8170SKalle Valo 1897bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID, 1898bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1899bdcd8170SKalle Valo return ret; 1900bdcd8170SKalle Valo } 1901bdcd8170SKalle Valo 1902bdcd8170SKalle Valo int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) 1903bdcd8170SKalle Valo { 1904bdcd8170SKalle Valo struct sk_buff *skb; 1905bdcd8170SKalle Valo struct wmi_disc_timeout_cmd *cmd; 1906bdcd8170SKalle Valo int ret; 1907bdcd8170SKalle Valo 1908bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1909bdcd8170SKalle Valo if (!skb) 1910bdcd8170SKalle Valo return -ENOMEM; 1911bdcd8170SKalle Valo 1912bdcd8170SKalle Valo cmd = (struct wmi_disc_timeout_cmd *) skb->data; 1913bdcd8170SKalle Valo cmd->discon_timeout = timeout; 1914bdcd8170SKalle Valo 1915bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID, 1916bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1917bdcd8170SKalle Valo return ret; 1918bdcd8170SKalle Valo } 1919bdcd8170SKalle Valo 1920bdcd8170SKalle Valo int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, 1921bdcd8170SKalle Valo enum crypto_type key_type, 1922bdcd8170SKalle Valo u8 key_usage, u8 key_len, 1923bdcd8170SKalle Valo u8 *key_rsc, u8 *key_material, 1924bdcd8170SKalle Valo u8 key_op_ctrl, u8 *mac_addr, 1925bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 1926bdcd8170SKalle Valo { 1927bdcd8170SKalle Valo struct sk_buff *skb; 1928bdcd8170SKalle Valo struct wmi_add_cipher_key_cmd *cmd; 1929bdcd8170SKalle Valo int ret; 1930bdcd8170SKalle Valo 19319a5b1318SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " 19329a5b1318SJouni Malinen "key_usage=%d key_len=%d key_op_ctrl=%d\n", 19339a5b1318SJouni Malinen key_index, key_type, key_usage, key_len, key_op_ctrl); 19349a5b1318SJouni Malinen 1935bdcd8170SKalle Valo if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || 1936bdcd8170SKalle Valo (key_material == NULL)) 1937bdcd8170SKalle Valo return -EINVAL; 1938bdcd8170SKalle Valo 1939bdcd8170SKalle Valo if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) 1940bdcd8170SKalle Valo return -EINVAL; 1941bdcd8170SKalle Valo 1942bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1943bdcd8170SKalle Valo if (!skb) 1944bdcd8170SKalle Valo return -ENOMEM; 1945bdcd8170SKalle Valo 1946bdcd8170SKalle Valo cmd = (struct wmi_add_cipher_key_cmd *) skb->data; 1947bdcd8170SKalle Valo cmd->key_index = key_index; 1948bdcd8170SKalle Valo cmd->key_type = key_type; 1949bdcd8170SKalle Valo cmd->key_usage = key_usage; 1950bdcd8170SKalle Valo cmd->key_len = key_len; 1951bdcd8170SKalle Valo memcpy(cmd->key, key_material, key_len); 1952bdcd8170SKalle Valo 1953bdcd8170SKalle Valo if (key_rsc != NULL) 1954bdcd8170SKalle Valo memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc)); 1955bdcd8170SKalle Valo 1956bdcd8170SKalle Valo cmd->key_op_ctrl = key_op_ctrl; 1957bdcd8170SKalle Valo 1958bdcd8170SKalle Valo if (mac_addr) 1959bdcd8170SKalle Valo memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); 1960bdcd8170SKalle Valo 1961bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID, 1962bdcd8170SKalle Valo sync_flag); 1963bdcd8170SKalle Valo 1964bdcd8170SKalle Valo return ret; 1965bdcd8170SKalle Valo } 1966bdcd8170SKalle Valo 1967bdcd8170SKalle Valo int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) 1968bdcd8170SKalle Valo { 1969bdcd8170SKalle Valo struct sk_buff *skb; 1970bdcd8170SKalle Valo struct wmi_add_krk_cmd *cmd; 1971bdcd8170SKalle Valo int ret; 1972bdcd8170SKalle Valo 1973bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1974bdcd8170SKalle Valo if (!skb) 1975bdcd8170SKalle Valo return -ENOMEM; 1976bdcd8170SKalle Valo 1977bdcd8170SKalle Valo cmd = (struct wmi_add_krk_cmd *) skb->data; 1978bdcd8170SKalle Valo memcpy(cmd->krk, krk, WMI_KRK_LEN); 1979bdcd8170SKalle Valo 1980bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG); 1981bdcd8170SKalle Valo 1982bdcd8170SKalle Valo return ret; 1983bdcd8170SKalle Valo } 1984bdcd8170SKalle Valo 1985bdcd8170SKalle Valo int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index) 1986bdcd8170SKalle Valo { 1987bdcd8170SKalle Valo struct sk_buff *skb; 1988bdcd8170SKalle Valo struct wmi_delete_cipher_key_cmd *cmd; 1989bdcd8170SKalle Valo int ret; 1990bdcd8170SKalle Valo 1991bdcd8170SKalle Valo if (key_index > WMI_MAX_KEY_INDEX) 1992bdcd8170SKalle Valo return -EINVAL; 1993bdcd8170SKalle Valo 1994bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1995bdcd8170SKalle Valo if (!skb) 1996bdcd8170SKalle Valo return -ENOMEM; 1997bdcd8170SKalle Valo 1998bdcd8170SKalle Valo cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; 1999bdcd8170SKalle Valo cmd->key_index = key_index; 2000bdcd8170SKalle Valo 2001bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID, 2002bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2003bdcd8170SKalle Valo 2004bdcd8170SKalle Valo return ret; 2005bdcd8170SKalle Valo } 2006bdcd8170SKalle Valo 2007bdcd8170SKalle Valo int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, 2008bdcd8170SKalle Valo const u8 *pmkid, bool set) 2009bdcd8170SKalle Valo { 2010bdcd8170SKalle Valo struct sk_buff *skb; 2011bdcd8170SKalle Valo struct wmi_setpmkid_cmd *cmd; 2012bdcd8170SKalle Valo int ret; 2013bdcd8170SKalle Valo 2014bdcd8170SKalle Valo if (bssid == NULL) 2015bdcd8170SKalle Valo return -EINVAL; 2016bdcd8170SKalle Valo 2017bdcd8170SKalle Valo if (set && pmkid == NULL) 2018bdcd8170SKalle Valo return -EINVAL; 2019bdcd8170SKalle Valo 2020bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2021bdcd8170SKalle Valo if (!skb) 2022bdcd8170SKalle Valo return -ENOMEM; 2023bdcd8170SKalle Valo 2024bdcd8170SKalle Valo cmd = (struct wmi_setpmkid_cmd *) skb->data; 2025bdcd8170SKalle Valo memcpy(cmd->bssid, bssid, ETH_ALEN); 2026bdcd8170SKalle Valo if (set) { 2027bdcd8170SKalle Valo memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); 2028bdcd8170SKalle Valo cmd->enable = PMKID_ENABLE; 2029bdcd8170SKalle Valo } else { 2030bdcd8170SKalle Valo memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); 2031bdcd8170SKalle Valo cmd->enable = PMKID_DISABLE; 2032bdcd8170SKalle Valo } 2033bdcd8170SKalle Valo 2034bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID, 2035bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2036bdcd8170SKalle Valo 2037bdcd8170SKalle Valo return ret; 2038bdcd8170SKalle Valo } 2039bdcd8170SKalle Valo 2040bdcd8170SKalle Valo static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, 2041bdcd8170SKalle Valo enum htc_endpoint_id ep_id) 2042bdcd8170SKalle Valo { 2043bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 2044bdcd8170SKalle Valo int ret; 2045bdcd8170SKalle Valo 2046bdcd8170SKalle Valo if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) 2047bdcd8170SKalle Valo return -EINVAL; 2048bdcd8170SKalle Valo 2049bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 2050bdcd8170SKalle Valo 2051bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) skb->data; 2052bdcd8170SKalle Valo data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; 2053bdcd8170SKalle Valo data_hdr->info3 = 0; 2054bdcd8170SKalle Valo 2055bdcd8170SKalle Valo ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 2056bdcd8170SKalle Valo 2057bdcd8170SKalle Valo return ret; 2058bdcd8170SKalle Valo } 2059bdcd8170SKalle Valo 2060bdcd8170SKalle Valo static int ath6kl_wmi_sync_point(struct wmi *wmi) 2061bdcd8170SKalle Valo { 2062bdcd8170SKalle Valo struct sk_buff *skb; 2063bdcd8170SKalle Valo struct wmi_sync_cmd *cmd; 2064bdcd8170SKalle Valo struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; 2065bdcd8170SKalle Valo enum htc_endpoint_id ep_id; 2066bdcd8170SKalle Valo u8 index, num_pri_streams = 0; 2067bdcd8170SKalle Valo int ret = 0; 2068bdcd8170SKalle Valo 2069bdcd8170SKalle Valo memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); 2070bdcd8170SKalle Valo 2071bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2072bdcd8170SKalle Valo 2073bdcd8170SKalle Valo for (index = 0; index < WMM_NUM_AC; index++) { 2074bdcd8170SKalle Valo if (wmi->fat_pipe_exist & (1 << index)) { 2075bdcd8170SKalle Valo num_pri_streams++; 2076bdcd8170SKalle Valo data_sync_bufs[num_pri_streams - 1].traffic_class = 2077bdcd8170SKalle Valo index; 2078bdcd8170SKalle Valo } 2079bdcd8170SKalle Valo } 2080bdcd8170SKalle Valo 2081bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2082bdcd8170SKalle Valo 2083bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2084bdcd8170SKalle Valo if (!skb) { 2085bdcd8170SKalle Valo ret = -ENOMEM; 2086bdcd8170SKalle Valo goto free_skb; 2087bdcd8170SKalle Valo } 2088bdcd8170SKalle Valo 2089bdcd8170SKalle Valo cmd = (struct wmi_sync_cmd *) skb->data; 2090bdcd8170SKalle Valo 2091bdcd8170SKalle Valo /* 2092bdcd8170SKalle Valo * In the SYNC cmd sent on the control Ep, send a bitmap 2093bdcd8170SKalle Valo * of the data eps on which the Data Sync will be sent 2094bdcd8170SKalle Valo */ 2095bdcd8170SKalle Valo cmd->data_sync_map = wmi->fat_pipe_exist; 2096bdcd8170SKalle Valo 2097bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2098bdcd8170SKalle Valo data_sync_bufs[index].skb = ath6kl_buf_alloc(0); 2099bdcd8170SKalle Valo if (data_sync_bufs[index].skb == NULL) { 2100bdcd8170SKalle Valo ret = -ENOMEM; 2101bdcd8170SKalle Valo break; 2102bdcd8170SKalle Valo } 2103bdcd8170SKalle Valo } 2104bdcd8170SKalle Valo 2105bdcd8170SKalle Valo /* 2106bdcd8170SKalle Valo * If buffer allocation for any of the dataSync fails, 2107bdcd8170SKalle Valo * then do not send the Synchronize cmd on the control ep 2108bdcd8170SKalle Valo */ 2109bdcd8170SKalle Valo if (ret) 2110bdcd8170SKalle Valo goto free_skb; 2111bdcd8170SKalle Valo 2112bdcd8170SKalle Valo /* 2113bdcd8170SKalle Valo * Send sync cmd followed by sync data messages on all 2114bdcd8170SKalle Valo * endpoints being used 2115bdcd8170SKalle Valo */ 2116bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID, 2117bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2118bdcd8170SKalle Valo 2119bdcd8170SKalle Valo if (ret) 2120bdcd8170SKalle Valo goto free_skb; 2121bdcd8170SKalle Valo 2122bdcd8170SKalle Valo /* cmd buffer sent, we no longer own it */ 2123bdcd8170SKalle Valo skb = NULL; 2124bdcd8170SKalle Valo 2125bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2126bdcd8170SKalle Valo 2127bdcd8170SKalle Valo if (WARN_ON(!data_sync_bufs[index].skb)) 2128bdcd8170SKalle Valo break; 2129bdcd8170SKalle Valo 2130bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, 2131bdcd8170SKalle Valo data_sync_bufs[index]. 2132bdcd8170SKalle Valo traffic_class); 2133bdcd8170SKalle Valo ret = 2134bdcd8170SKalle Valo ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, 2135bdcd8170SKalle Valo ep_id); 2136bdcd8170SKalle Valo 2137bdcd8170SKalle Valo if (ret) 2138bdcd8170SKalle Valo break; 2139bdcd8170SKalle Valo 2140bdcd8170SKalle Valo data_sync_bufs[index].skb = NULL; 2141bdcd8170SKalle Valo } 2142bdcd8170SKalle Valo 2143bdcd8170SKalle Valo free_skb: 2144bdcd8170SKalle Valo /* free up any resources left over (possibly due to an error) */ 2145bdcd8170SKalle Valo if (skb) 2146bdcd8170SKalle Valo dev_kfree_skb(skb); 2147bdcd8170SKalle Valo 2148bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2149bdcd8170SKalle Valo if (data_sync_bufs[index].skb != NULL) { 2150bdcd8170SKalle Valo dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. 2151bdcd8170SKalle Valo skb); 2152bdcd8170SKalle Valo } 2153bdcd8170SKalle Valo } 2154bdcd8170SKalle Valo 2155bdcd8170SKalle Valo return ret; 2156bdcd8170SKalle Valo } 2157bdcd8170SKalle Valo 2158bdcd8170SKalle Valo int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, 2159bdcd8170SKalle Valo struct wmi_create_pstream_cmd *params) 2160bdcd8170SKalle Valo { 2161bdcd8170SKalle Valo struct sk_buff *skb; 2162bdcd8170SKalle Valo struct wmi_create_pstream_cmd *cmd; 2163bdcd8170SKalle Valo u8 fatpipe_exist_for_ac = 0; 2164bdcd8170SKalle Valo s32 min_phy = 0; 2165bdcd8170SKalle Valo s32 nominal_phy = 0; 2166bdcd8170SKalle Valo int ret; 2167bdcd8170SKalle Valo 2168bdcd8170SKalle Valo if (!((params->user_pri < 8) && 2169bdcd8170SKalle Valo (params->user_pri <= 0x7) && 2170bdcd8170SKalle Valo (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && 2171bdcd8170SKalle Valo (params->traffic_direc == UPLINK_TRAFFIC || 2172bdcd8170SKalle Valo params->traffic_direc == DNLINK_TRAFFIC || 2173bdcd8170SKalle Valo params->traffic_direc == BIDIR_TRAFFIC) && 2174bdcd8170SKalle Valo (params->traffic_type == TRAFFIC_TYPE_APERIODIC || 2175bdcd8170SKalle Valo params->traffic_type == TRAFFIC_TYPE_PERIODIC) && 2176bdcd8170SKalle Valo (params->voice_psc_cap == DISABLE_FOR_THIS_AC || 2177bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_THIS_AC || 2178bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_ALL_AC) && 2179bdcd8170SKalle Valo (params->tsid == WMI_IMPLICIT_PSTREAM || 2180bdcd8170SKalle Valo params->tsid <= WMI_MAX_THINSTREAM))) { 2181bdcd8170SKalle Valo return -EINVAL; 2182bdcd8170SKalle Valo } 2183bdcd8170SKalle Valo 2184bdcd8170SKalle Valo /* 2185bdcd8170SKalle Valo * Check nominal PHY rate is >= minimalPHY, 2186bdcd8170SKalle Valo * so that DUT can allow TSRS IE 2187bdcd8170SKalle Valo */ 2188bdcd8170SKalle Valo 2189bdcd8170SKalle Valo /* Get the physical rate (units of bps) */ 2190bdcd8170SKalle Valo min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); 2191bdcd8170SKalle Valo 2192bdcd8170SKalle Valo /* Check minimal phy < nominal phy rate */ 2193bdcd8170SKalle Valo if (params->nominal_phy >= min_phy) { 2194bdcd8170SKalle Valo /* unit of 500 kbps */ 2195bdcd8170SKalle Valo nominal_phy = (params->nominal_phy * 1000) / 500; 2196bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2197bdcd8170SKalle Valo "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", 2198bdcd8170SKalle Valo min_phy, nominal_phy); 2199bdcd8170SKalle Valo 2200bdcd8170SKalle Valo params->nominal_phy = nominal_phy; 2201bdcd8170SKalle Valo } else { 2202bdcd8170SKalle Valo params->nominal_phy = 0; 2203bdcd8170SKalle Valo } 2204bdcd8170SKalle Valo 2205bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2206bdcd8170SKalle Valo if (!skb) 2207bdcd8170SKalle Valo return -ENOMEM; 2208bdcd8170SKalle Valo 2209bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2210bdcd8170SKalle Valo "sending create_pstream_cmd: ac=%d tsid:%d\n", 2211bdcd8170SKalle Valo params->traffic_class, params->tsid); 2212bdcd8170SKalle Valo 2213bdcd8170SKalle Valo cmd = (struct wmi_create_pstream_cmd *) skb->data; 2214bdcd8170SKalle Valo memcpy(cmd, params, sizeof(*cmd)); 2215bdcd8170SKalle Valo 2216bdcd8170SKalle Valo /* This is an implicitly created Fat pipe */ 2217bdcd8170SKalle Valo if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { 2218bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2219bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2220bdcd8170SKalle Valo (1 << params->traffic_class)); 2221bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2222bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2223bdcd8170SKalle Valo } else { 2224bdcd8170SKalle Valo /* explicitly created thin stream within a fat pipe */ 2225bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2226bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2227bdcd8170SKalle Valo (1 << params->traffic_class)); 2228bdcd8170SKalle Valo wmi->stream_exist_for_ac[params->traffic_class] |= 2229bdcd8170SKalle Valo (1 << params->tsid); 2230bdcd8170SKalle Valo /* 2231bdcd8170SKalle Valo * If a thinstream becomes active, the fat pipe automatically 2232bdcd8170SKalle Valo * becomes active 2233bdcd8170SKalle Valo */ 2234bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2235bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2236bdcd8170SKalle Valo } 2237bdcd8170SKalle Valo 2238bdcd8170SKalle Valo /* 2239bdcd8170SKalle Valo * Indicate activty change to driver layer only if this is the 2240bdcd8170SKalle Valo * first TSID to get created in this AC explicitly or an implicit 2241bdcd8170SKalle Valo * fat pipe is getting created. 2242bdcd8170SKalle Valo */ 2243bdcd8170SKalle Valo if (!fatpipe_exist_for_ac) 2244bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2245bdcd8170SKalle Valo params->traffic_class, true); 2246bdcd8170SKalle Valo 2247bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID, 2248bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2249bdcd8170SKalle Valo return ret; 2250bdcd8170SKalle Valo } 2251bdcd8170SKalle Valo 2252bdcd8170SKalle Valo int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) 2253bdcd8170SKalle Valo { 2254bdcd8170SKalle Valo struct sk_buff *skb; 2255bdcd8170SKalle Valo struct wmi_delete_pstream_cmd *cmd; 2256bdcd8170SKalle Valo u16 active_tsids = 0; 2257bdcd8170SKalle Valo int ret; 2258bdcd8170SKalle Valo 2259bdcd8170SKalle Valo if (traffic_class > 3) { 2260bdcd8170SKalle Valo ath6kl_err("invalid traffic class: %d\n", traffic_class); 2261bdcd8170SKalle Valo return -EINVAL; 2262bdcd8170SKalle Valo } 2263bdcd8170SKalle Valo 2264bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2265bdcd8170SKalle Valo if (!skb) 2266bdcd8170SKalle Valo return -ENOMEM; 2267bdcd8170SKalle Valo 2268bdcd8170SKalle Valo cmd = (struct wmi_delete_pstream_cmd *) skb->data; 2269bdcd8170SKalle Valo cmd->traffic_class = traffic_class; 2270bdcd8170SKalle Valo cmd->tsid = tsid; 2271bdcd8170SKalle Valo 2272bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2273bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2274bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2275bdcd8170SKalle Valo 2276bdcd8170SKalle Valo if (!(active_tsids & (1 << tsid))) { 2277bdcd8170SKalle Valo dev_kfree_skb(skb); 2278bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2279bdcd8170SKalle Valo "TSID %d doesn't exist for traffic class: %d\n", 2280bdcd8170SKalle Valo tsid, traffic_class); 2281bdcd8170SKalle Valo return -ENODATA; 2282bdcd8170SKalle Valo } 2283bdcd8170SKalle Valo 2284bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2285bdcd8170SKalle Valo "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", 2286bdcd8170SKalle Valo traffic_class, tsid); 2287bdcd8170SKalle Valo 2288bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID, 2289bdcd8170SKalle Valo SYNC_BEFORE_WMIFLAG); 2290bdcd8170SKalle Valo 2291bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2292bdcd8170SKalle Valo wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); 2293bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2294bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2295bdcd8170SKalle Valo 2296bdcd8170SKalle Valo /* 2297bdcd8170SKalle Valo * Indicate stream inactivity to driver layer only if all tsids 2298bdcd8170SKalle Valo * within this AC are deleted. 2299bdcd8170SKalle Valo */ 2300bdcd8170SKalle Valo if (!active_tsids) { 2301bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2302bdcd8170SKalle Valo traffic_class, false); 2303bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << traffic_class); 2304bdcd8170SKalle Valo } 2305bdcd8170SKalle Valo 2306bdcd8170SKalle Valo return ret; 2307bdcd8170SKalle Valo } 2308bdcd8170SKalle Valo 2309bdcd8170SKalle Valo int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) 2310bdcd8170SKalle Valo { 2311bdcd8170SKalle Valo struct sk_buff *skb; 2312bdcd8170SKalle Valo struct wmi_set_ip_cmd *cmd; 2313bdcd8170SKalle Valo int ret; 2314bdcd8170SKalle Valo 2315bdcd8170SKalle Valo /* Multicast address are not valid */ 2316bdcd8170SKalle Valo if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) || 2317bdcd8170SKalle Valo (*((u8 *) &ip_cmd->ips[1]) >= 0xE0)) 2318bdcd8170SKalle Valo return -EINVAL; 2319bdcd8170SKalle Valo 2320bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); 2321bdcd8170SKalle Valo if (!skb) 2322bdcd8170SKalle Valo return -ENOMEM; 2323bdcd8170SKalle Valo 2324bdcd8170SKalle Valo cmd = (struct wmi_set_ip_cmd *) skb->data; 2325bdcd8170SKalle Valo memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); 2326bdcd8170SKalle Valo 2327bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG); 2328bdcd8170SKalle Valo return ret; 2329bdcd8170SKalle Valo } 2330bdcd8170SKalle Valo 2331bdcd8170SKalle Valo static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, 2332bdcd8170SKalle Valo int len) 2333bdcd8170SKalle Valo { 2334bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_wow_list_reply)) 2335bdcd8170SKalle Valo return -EINVAL; 2336bdcd8170SKalle Valo 2337bdcd8170SKalle Valo return 0; 2338bdcd8170SKalle Valo } 2339bdcd8170SKalle Valo 2340bdcd8170SKalle Valo static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, 2341bdcd8170SKalle Valo enum wmix_command_id cmd_id, 2342bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2343bdcd8170SKalle Valo { 2344bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd_hdr; 2345bdcd8170SKalle Valo int ret; 2346bdcd8170SKalle Valo 2347bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmix_cmd_hdr)); 2348bdcd8170SKalle Valo 2349bdcd8170SKalle Valo cmd_hdr = (struct wmix_cmd_hdr *) skb->data; 2350bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le32(cmd_id); 2351bdcd8170SKalle Valo 2352bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag); 2353bdcd8170SKalle Valo 2354bdcd8170SKalle Valo return ret; 2355bdcd8170SKalle Valo } 2356bdcd8170SKalle Valo 2357bdcd8170SKalle Valo int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) 2358bdcd8170SKalle Valo { 2359bdcd8170SKalle Valo struct sk_buff *skb; 2360bdcd8170SKalle Valo struct wmix_hb_challenge_resp_cmd *cmd; 2361bdcd8170SKalle Valo int ret; 2362bdcd8170SKalle Valo 2363bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2364bdcd8170SKalle Valo if (!skb) 2365bdcd8170SKalle Valo return -ENOMEM; 2366bdcd8170SKalle Valo 2367bdcd8170SKalle Valo cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; 2368bdcd8170SKalle Valo cmd->cookie = cpu_to_le32(cookie); 2369bdcd8170SKalle Valo cmd->source = cpu_to_le32(source); 2370bdcd8170SKalle Valo 2371bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, 2372bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2373bdcd8170SKalle Valo return ret; 2374bdcd8170SKalle Valo } 2375bdcd8170SKalle Valo 2376bdcd8170SKalle Valo int ath6kl_wmi_get_stats_cmd(struct wmi *wmi) 2377bdcd8170SKalle Valo { 2378bdcd8170SKalle Valo return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID); 2379bdcd8170SKalle Valo } 2380bdcd8170SKalle Valo 2381bdcd8170SKalle Valo int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) 2382bdcd8170SKalle Valo { 2383bdcd8170SKalle Valo struct sk_buff *skb; 2384bdcd8170SKalle Valo struct wmi_set_tx_pwr_cmd *cmd; 2385bdcd8170SKalle Valo int ret; 2386bdcd8170SKalle Valo 2387bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); 2388bdcd8170SKalle Valo if (!skb) 2389bdcd8170SKalle Valo return -ENOMEM; 2390bdcd8170SKalle Valo 2391bdcd8170SKalle Valo cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; 2392bdcd8170SKalle Valo cmd->dbM = dbM; 2393bdcd8170SKalle Valo 2394bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID, 2395bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2396bdcd8170SKalle Valo 2397bdcd8170SKalle Valo return ret; 2398bdcd8170SKalle Valo } 2399bdcd8170SKalle Valo 2400bdcd8170SKalle Valo int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) 2401bdcd8170SKalle Valo { 2402bdcd8170SKalle Valo return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID); 2403bdcd8170SKalle Valo } 2404bdcd8170SKalle Valo 2405bdcd8170SKalle Valo int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) 2406bdcd8170SKalle Valo { 2407bdcd8170SKalle Valo struct sk_buff *skb; 2408bdcd8170SKalle Valo struct wmi_set_lpreamble_cmd *cmd; 2409bdcd8170SKalle Valo int ret; 2410bdcd8170SKalle Valo 2411bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); 2412bdcd8170SKalle Valo if (!skb) 2413bdcd8170SKalle Valo return -ENOMEM; 2414bdcd8170SKalle Valo 2415bdcd8170SKalle Valo cmd = (struct wmi_set_lpreamble_cmd *) skb->data; 2416bdcd8170SKalle Valo cmd->status = status; 2417bdcd8170SKalle Valo cmd->preamble_policy = preamble_policy; 2418bdcd8170SKalle Valo 2419bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID, 2420bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2421bdcd8170SKalle Valo return ret; 2422bdcd8170SKalle Valo } 2423bdcd8170SKalle Valo 2424bdcd8170SKalle Valo int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) 2425bdcd8170SKalle Valo { 2426bdcd8170SKalle Valo struct sk_buff *skb; 2427bdcd8170SKalle Valo struct wmi_set_rts_cmd *cmd; 2428bdcd8170SKalle Valo int ret; 2429bdcd8170SKalle Valo 2430bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); 2431bdcd8170SKalle Valo if (!skb) 2432bdcd8170SKalle Valo return -ENOMEM; 2433bdcd8170SKalle Valo 2434bdcd8170SKalle Valo cmd = (struct wmi_set_rts_cmd *) skb->data; 2435bdcd8170SKalle Valo cmd->threshold = cpu_to_le16(threshold); 2436bdcd8170SKalle Valo 2437bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG); 2438bdcd8170SKalle Valo return ret; 2439bdcd8170SKalle Valo } 2440bdcd8170SKalle Valo 2441bdcd8170SKalle Valo int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) 2442bdcd8170SKalle Valo { 2443bdcd8170SKalle Valo struct sk_buff *skb; 2444bdcd8170SKalle Valo struct wmi_set_wmm_txop_cmd *cmd; 2445bdcd8170SKalle Valo int ret; 2446bdcd8170SKalle Valo 2447bdcd8170SKalle Valo if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) 2448bdcd8170SKalle Valo return -EINVAL; 2449bdcd8170SKalle Valo 2450bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); 2451bdcd8170SKalle Valo if (!skb) 2452bdcd8170SKalle Valo return -ENOMEM; 2453bdcd8170SKalle Valo 2454bdcd8170SKalle Valo cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; 2455bdcd8170SKalle Valo cmd->txop_enable = cfg; 2456bdcd8170SKalle Valo 2457bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID, 2458bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2459bdcd8170SKalle Valo return ret; 2460bdcd8170SKalle Valo } 2461bdcd8170SKalle Valo 2462bdcd8170SKalle Valo int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) 2463bdcd8170SKalle Valo { 2464bdcd8170SKalle Valo struct sk_buff *skb; 2465bdcd8170SKalle Valo struct wmi_set_keepalive_cmd *cmd; 2466bdcd8170SKalle Valo int ret; 2467bdcd8170SKalle Valo 2468bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2469bdcd8170SKalle Valo if (!skb) 2470bdcd8170SKalle Valo return -ENOMEM; 2471bdcd8170SKalle Valo 2472bdcd8170SKalle Valo cmd = (struct wmi_set_keepalive_cmd *) skb->data; 2473bdcd8170SKalle Valo cmd->keep_alive_intvl = keep_alive_intvl; 2474bdcd8170SKalle Valo wmi->keep_alive_intvl = keep_alive_intvl; 2475bdcd8170SKalle Valo 2476bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, 2477bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2478bdcd8170SKalle Valo return ret; 2479bdcd8170SKalle Valo } 2480bdcd8170SKalle Valo 2481bdcd8170SKalle Valo s32 ath6kl_wmi_get_rate(s8 rate_index) 2482bdcd8170SKalle Valo { 2483bdcd8170SKalle Valo if (rate_index == RATE_AUTO) 2484bdcd8170SKalle Valo return 0; 2485bdcd8170SKalle Valo 2486bdcd8170SKalle Valo return wmi_rate_tbl[(u32) rate_index][0]; 2487bdcd8170SKalle Valo } 2488bdcd8170SKalle Valo 2489bdcd8170SKalle Valo void ath6kl_wmi_node_return(struct wmi *wmi, struct bss *bss) 2490bdcd8170SKalle Valo { 2491bdcd8170SKalle Valo if (bss) 24927c3075e9SVasanthakumar Thiagarajan wlan_node_return(&wmi->parent_dev->scan_table, bss); 2493bdcd8170SKalle Valo } 2494bdcd8170SKalle Valo 2495bdcd8170SKalle Valo struct bss *ath6kl_wmi_find_ssid_node(struct wmi *wmi, u8 * ssid, 2496bdcd8170SKalle Valo u32 ssid_len, bool is_wpa2, 2497bdcd8170SKalle Valo bool match_ssid) 2498bdcd8170SKalle Valo { 2499bdcd8170SKalle Valo struct bss *node = NULL; 2500bdcd8170SKalle Valo 25017c3075e9SVasanthakumar Thiagarajan node = wlan_find_ssid_node(&wmi->parent_dev->scan_table, ssid, 2502bdcd8170SKalle Valo ssid_len, is_wpa2, match_ssid); 2503bdcd8170SKalle Valo return node; 2504bdcd8170SKalle Valo } 2505bdcd8170SKalle Valo 2506bdcd8170SKalle Valo struct bss *ath6kl_wmi_find_node(struct wmi *wmi, const u8 * mac_addr) 2507bdcd8170SKalle Valo { 2508bdcd8170SKalle Valo struct bss *ni = NULL; 2509bdcd8170SKalle Valo 25107c3075e9SVasanthakumar Thiagarajan ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); 2511bdcd8170SKalle Valo 2512bdcd8170SKalle Valo return ni; 2513bdcd8170SKalle Valo } 2514bdcd8170SKalle Valo 2515bdcd8170SKalle Valo void ath6kl_wmi_node_free(struct wmi *wmi, const u8 * mac_addr) 2516bdcd8170SKalle Valo { 2517bdcd8170SKalle Valo struct bss *ni = NULL; 2518bdcd8170SKalle Valo 25197c3075e9SVasanthakumar Thiagarajan ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); 2520bdcd8170SKalle Valo if (ni != NULL) 25217c3075e9SVasanthakumar Thiagarajan wlan_node_reclaim(&wmi->parent_dev->scan_table, ni); 2522bdcd8170SKalle Valo 2523bdcd8170SKalle Valo return; 2524bdcd8170SKalle Valo } 2525bdcd8170SKalle Valo 2526bdcd8170SKalle Valo static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, 2527bdcd8170SKalle Valo u32 len) 2528bdcd8170SKalle Valo { 2529bdcd8170SKalle Valo struct wmi_pmkid_list_reply *reply; 2530bdcd8170SKalle Valo u32 expected_len; 2531bdcd8170SKalle Valo 2532bdcd8170SKalle Valo if (len < sizeof(struct wmi_pmkid_list_reply)) 2533bdcd8170SKalle Valo return -EINVAL; 2534bdcd8170SKalle Valo 2535bdcd8170SKalle Valo reply = (struct wmi_pmkid_list_reply *)datap; 2536bdcd8170SKalle Valo expected_len = sizeof(reply->num_pmkid) + 2537bdcd8170SKalle Valo le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; 2538bdcd8170SKalle Valo 2539bdcd8170SKalle Valo if (len < expected_len) 2540bdcd8170SKalle Valo return -EINVAL; 2541bdcd8170SKalle Valo 2542bdcd8170SKalle Valo return 0; 2543bdcd8170SKalle Valo } 2544bdcd8170SKalle Valo 2545bdcd8170SKalle Valo static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2546bdcd8170SKalle Valo { 2547bdcd8170SKalle Valo struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; 2548bdcd8170SKalle Valo 2549bdcd8170SKalle Valo aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid, 2550bdcd8170SKalle Valo le16_to_cpu(cmd->st_seq_no), cmd->win_sz); 2551bdcd8170SKalle Valo 2552bdcd8170SKalle Valo return 0; 2553bdcd8170SKalle Valo } 2554bdcd8170SKalle Valo 2555bdcd8170SKalle Valo static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2556bdcd8170SKalle Valo { 2557bdcd8170SKalle Valo struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; 2558bdcd8170SKalle Valo 2559bdcd8170SKalle Valo aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid); 2560bdcd8170SKalle Valo 2561bdcd8170SKalle Valo return 0; 2562bdcd8170SKalle Valo } 2563bdcd8170SKalle Valo 2564bdcd8170SKalle Valo /* AP mode functions */ 25656a7c9badSJouni Malinen 25666a7c9badSJouni Malinen int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) 25676a7c9badSJouni Malinen { 25686a7c9badSJouni Malinen struct sk_buff *skb; 25696a7c9badSJouni Malinen struct wmi_connect_cmd *cm; 25706a7c9badSJouni Malinen int res; 25716a7c9badSJouni Malinen 25726a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 25736a7c9badSJouni Malinen if (!skb) 25746a7c9badSJouni Malinen return -ENOMEM; 25756a7c9badSJouni Malinen 25766a7c9badSJouni Malinen cm = (struct wmi_connect_cmd *) skb->data; 25776a7c9badSJouni Malinen memcpy(cm, p, sizeof(*cm)); 25786a7c9badSJouni Malinen 25796a7c9badSJouni Malinen res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID, 25806a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 25816a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " 25826a7c9badSJouni Malinen "ctrl_flags=0x%x-> res=%d\n", 25836a7c9badSJouni Malinen __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), 25846a7c9badSJouni Malinen le32_to_cpu(p->ctrl_flags), res); 25856a7c9badSJouni Malinen return res; 25866a7c9badSJouni Malinen } 25876a7c9badSJouni Malinen 258823875136SJouni Malinen int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason) 258923875136SJouni Malinen { 259023875136SJouni Malinen struct sk_buff *skb; 259123875136SJouni Malinen struct wmi_ap_set_mlme_cmd *cm; 259223875136SJouni Malinen 259323875136SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 259423875136SJouni Malinen if (!skb) 259523875136SJouni Malinen return -ENOMEM; 259623875136SJouni Malinen 259723875136SJouni Malinen cm = (struct wmi_ap_set_mlme_cmd *) skb->data; 259823875136SJouni Malinen memcpy(cm->mac, mac, ETH_ALEN); 259923875136SJouni Malinen cm->reason = cpu_to_le16(reason); 260023875136SJouni Malinen cm->cmd = cmd; 260123875136SJouni Malinen 260223875136SJouni Malinen return ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_SET_MLME_CMDID, 260323875136SJouni Malinen NO_SYNC_WMIFLAG); 260423875136SJouni Malinen } 260523875136SJouni Malinen 2606bdcd8170SKalle Valo static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len) 2607bdcd8170SKalle Valo { 2608bdcd8170SKalle Valo struct wmi_pspoll_event *ev; 2609bdcd8170SKalle Valo 2610bdcd8170SKalle Valo if (len < sizeof(struct wmi_pspoll_event)) 2611bdcd8170SKalle Valo return -EINVAL; 2612bdcd8170SKalle Valo 2613bdcd8170SKalle Valo ev = (struct wmi_pspoll_event *) datap; 2614bdcd8170SKalle Valo 2615bdcd8170SKalle Valo ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid)); 2616bdcd8170SKalle Valo 2617bdcd8170SKalle Valo return 0; 2618bdcd8170SKalle Valo } 2619bdcd8170SKalle Valo 2620bdcd8170SKalle Valo static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len) 2621bdcd8170SKalle Valo { 2622bdcd8170SKalle Valo ath6kl_dtimexpiry_event(wmi->parent_dev); 2623bdcd8170SKalle Valo 2624bdcd8170SKalle Valo return 0; 2625bdcd8170SKalle Valo } 2626bdcd8170SKalle Valo 2627bdcd8170SKalle Valo int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag) 2628bdcd8170SKalle Valo { 2629bdcd8170SKalle Valo struct sk_buff *skb; 2630bdcd8170SKalle Valo struct wmi_ap_set_pvb_cmd *cmd; 2631bdcd8170SKalle Valo int ret; 2632bdcd8170SKalle Valo 2633bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); 2634bdcd8170SKalle Valo if (!skb) 2635bdcd8170SKalle Valo return -ENOMEM; 2636bdcd8170SKalle Valo 2637bdcd8170SKalle Valo cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; 2638bdcd8170SKalle Valo cmd->aid = cpu_to_le16(aid); 2639bdcd8170SKalle Valo cmd->flag = cpu_to_le32(flag); 2640bdcd8170SKalle Valo 2641bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID, 2642bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2643bdcd8170SKalle Valo 2644bdcd8170SKalle Valo return 0; 2645bdcd8170SKalle Valo } 2646bdcd8170SKalle Valo 2647bdcd8170SKalle Valo int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, 2648bdcd8170SKalle Valo bool rx_dot11_hdr, bool defrag_on_host) 2649bdcd8170SKalle Valo { 2650bdcd8170SKalle Valo struct sk_buff *skb; 2651bdcd8170SKalle Valo struct wmi_rx_frame_format_cmd *cmd; 2652bdcd8170SKalle Valo int ret; 2653bdcd8170SKalle Valo 2654bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2655bdcd8170SKalle Valo if (!skb) 2656bdcd8170SKalle Valo return -ENOMEM; 2657bdcd8170SKalle Valo 2658bdcd8170SKalle Valo cmd = (struct wmi_rx_frame_format_cmd *) skb->data; 2659bdcd8170SKalle Valo cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; 2660bdcd8170SKalle Valo cmd->defrag_on_host = defrag_on_host ? 1 : 0; 2661bdcd8170SKalle Valo cmd->meta_ver = rx_meta_ver; 2662bdcd8170SKalle Valo 2663bdcd8170SKalle Valo /* Delete the local aggr state, on host */ 2664bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID, 2665bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2666bdcd8170SKalle Valo 2667bdcd8170SKalle Valo return ret; 2668bdcd8170SKalle Valo } 2669bdcd8170SKalle Valo 26706a7c9badSJouni Malinen int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, 26716a7c9badSJouni Malinen u8 ie_len) 26726a7c9badSJouni Malinen { 26736a7c9badSJouni Malinen struct sk_buff *skb; 26746a7c9badSJouni Malinen struct wmi_set_appie_cmd *p; 26756a7c9badSJouni Malinen 26766a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 26776a7c9badSJouni Malinen if (!skb) 26786a7c9badSJouni Malinen return -ENOMEM; 26796a7c9badSJouni Malinen 26806a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " 26816a7c9badSJouni Malinen "ie_len=%u\n", mgmt_frm_type, ie_len); 26826a7c9badSJouni Malinen p = (struct wmi_set_appie_cmd *) skb->data; 26836a7c9badSJouni Malinen p->mgmt_frm_type = mgmt_frm_type; 26846a7c9badSJouni Malinen p->ie_len = ie_len; 26856a7c9badSJouni Malinen memcpy(p->ie_info, ie, ie_len); 26866a7c9badSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID, 26876a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 26886a7c9badSJouni Malinen } 26896a7c9badSJouni Malinen 26906465ddcfSJouni Malinen int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) 26916465ddcfSJouni Malinen { 26926465ddcfSJouni Malinen struct sk_buff *skb; 26936465ddcfSJouni Malinen struct wmi_disable_11b_rates_cmd *cmd; 26946465ddcfSJouni Malinen 26956465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 26966465ddcfSJouni Malinen if (!skb) 26976465ddcfSJouni Malinen return -ENOMEM; 26986465ddcfSJouni Malinen 26996465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", 27006465ddcfSJouni Malinen disable); 27016465ddcfSJouni Malinen cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; 27026465ddcfSJouni Malinen cmd->disable = disable ? 1 : 0; 27036465ddcfSJouni Malinen 27046465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_DISABLE_11B_RATES_CMDID, 27056465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 27066465ddcfSJouni Malinen } 27076465ddcfSJouni Malinen 27086465ddcfSJouni Malinen int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur) 27096465ddcfSJouni Malinen { 27106465ddcfSJouni Malinen struct sk_buff *skb; 27116465ddcfSJouni Malinen struct wmi_remain_on_chnl_cmd *p; 27126465ddcfSJouni Malinen 27136465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 27146465ddcfSJouni Malinen if (!skb) 27156465ddcfSJouni Malinen return -ENOMEM; 27166465ddcfSJouni Malinen 27176465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", 27186465ddcfSJouni Malinen freq, dur); 27196465ddcfSJouni Malinen p = (struct wmi_remain_on_chnl_cmd *) skb->data; 27206465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 27216465ddcfSJouni Malinen p->duration = cpu_to_le32(dur); 27226465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_REMAIN_ON_CHNL_CMDID, 27236465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 27246465ddcfSJouni Malinen } 27256465ddcfSJouni Malinen 27266465ddcfSJouni Malinen int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait, 27276465ddcfSJouni Malinen const u8 *data, u16 data_len) 27286465ddcfSJouni Malinen { 27296465ddcfSJouni Malinen struct sk_buff *skb; 27306465ddcfSJouni Malinen struct wmi_send_action_cmd *p; 27316465ddcfSJouni Malinen 27326465ddcfSJouni Malinen if (wait) 27336465ddcfSJouni Malinen return -EINVAL; /* Offload for wait not supported */ 27346465ddcfSJouni Malinen 27356465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 27366465ddcfSJouni Malinen if (!skb) 27376465ddcfSJouni Malinen return -ENOMEM; 27386465ddcfSJouni Malinen 27396465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " 27406465ddcfSJouni Malinen "len=%u\n", id, freq, wait, data_len); 27416465ddcfSJouni Malinen p = (struct wmi_send_action_cmd *) skb->data; 27426465ddcfSJouni Malinen p->id = cpu_to_le32(id); 27436465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 27446465ddcfSJouni Malinen p->wait = cpu_to_le32(wait); 27456465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 27466465ddcfSJouni Malinen memcpy(p->data, data, data_len); 27476465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_ACTION_CMDID, 27486465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 27496465ddcfSJouni Malinen } 27506465ddcfSJouni Malinen 27516465ddcfSJouni Malinen int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq, 27526465ddcfSJouni Malinen const u8 *dst, 27536465ddcfSJouni Malinen const u8 *data, u16 data_len) 27546465ddcfSJouni Malinen { 27556465ddcfSJouni Malinen struct sk_buff *skb; 27566465ddcfSJouni Malinen struct wmi_p2p_probe_response_cmd *p; 27576465ddcfSJouni Malinen 27586465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 27596465ddcfSJouni Malinen if (!skb) 27606465ddcfSJouni Malinen return -ENOMEM; 27616465ddcfSJouni Malinen 27626465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM " 27636465ddcfSJouni Malinen "len=%u\n", freq, dst, data_len); 27646465ddcfSJouni Malinen p = (struct wmi_p2p_probe_response_cmd *) skb->data; 27656465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 27666465ddcfSJouni Malinen memcpy(p->destination_addr, dst, ETH_ALEN); 27676465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 27686465ddcfSJouni Malinen memcpy(p->data, data, data_len); 27696465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_PROBE_RESPONSE_CMDID, 27706465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 27716465ddcfSJouni Malinen } 27726465ddcfSJouni Malinen 27736465ddcfSJouni Malinen int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable) 27746465ddcfSJouni Malinen { 27756465ddcfSJouni Malinen struct sk_buff *skb; 27766465ddcfSJouni Malinen struct wmi_probe_req_report_cmd *p; 27776465ddcfSJouni Malinen 27786465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 27796465ddcfSJouni Malinen if (!skb) 27806465ddcfSJouni Malinen return -ENOMEM; 27816465ddcfSJouni Malinen 27826465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", 27836465ddcfSJouni Malinen enable); 27846465ddcfSJouni Malinen p = (struct wmi_probe_req_report_cmd *) skb->data; 27856465ddcfSJouni Malinen p->enable = enable ? 1 : 0; 27866465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_PROBE_REQ_REPORT_CMDID, 27876465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 27886465ddcfSJouni Malinen } 27896465ddcfSJouni Malinen 27906465ddcfSJouni Malinen int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags) 27916465ddcfSJouni Malinen { 27926465ddcfSJouni Malinen struct sk_buff *skb; 27936465ddcfSJouni Malinen struct wmi_get_p2p_info *p; 27946465ddcfSJouni Malinen 27956465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 27966465ddcfSJouni Malinen if (!skb) 27976465ddcfSJouni Malinen return -ENOMEM; 27986465ddcfSJouni Malinen 27996465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", 28006465ddcfSJouni Malinen info_req_flags); 28016465ddcfSJouni Malinen p = (struct wmi_get_p2p_info *) skb->data; 28026465ddcfSJouni Malinen p->info_req_flags = cpu_to_le32(info_req_flags); 28036465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_GET_P2P_INFO_CMDID, 28046465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28056465ddcfSJouni Malinen } 28066465ddcfSJouni Malinen 28076465ddcfSJouni Malinen int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi) 28086465ddcfSJouni Malinen { 28096465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); 28106465ddcfSJouni Malinen return ath6kl_wmi_simple_cmd(wmi, WMI_CANCEL_REMAIN_ON_CHNL_CMDID); 28116465ddcfSJouni Malinen } 28126465ddcfSJouni Malinen 2813bdcd8170SKalle Valo static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) 2814bdcd8170SKalle Valo { 2815bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd; 2816bdcd8170SKalle Valo u32 len; 2817bdcd8170SKalle Valo u16 id; 2818bdcd8170SKalle Valo u8 *datap; 2819bdcd8170SKalle Valo int ret = 0; 2820bdcd8170SKalle Valo 2821bdcd8170SKalle Valo if (skb->len < sizeof(struct wmix_cmd_hdr)) { 2822bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 2823bdcd8170SKalle Valo wmi->stat.cmd_len_err++; 2824bdcd8170SKalle Valo return -EINVAL; 2825bdcd8170SKalle Valo } 2826bdcd8170SKalle Valo 2827bdcd8170SKalle Valo cmd = (struct wmix_cmd_hdr *) skb->data; 2828bdcd8170SKalle Valo id = le32_to_cpu(cmd->cmd_id); 2829bdcd8170SKalle Valo 2830bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmix_cmd_hdr)); 2831bdcd8170SKalle Valo 2832bdcd8170SKalle Valo datap = skb->data; 2833bdcd8170SKalle Valo len = skb->len; 2834bdcd8170SKalle Valo 2835bdcd8170SKalle Valo switch (id) { 2836bdcd8170SKalle Valo case WMIX_HB_CHALLENGE_RESP_EVENTID: 2837bdcd8170SKalle Valo break; 2838bdcd8170SKalle Valo case WMIX_DBGLOG_EVENTID: 2839bdcd8170SKalle Valo break; 2840bdcd8170SKalle Valo default: 2841bdcd8170SKalle Valo ath6kl_err("unknown cmd id 0x%x\n", id); 2842bdcd8170SKalle Valo wmi->stat.cmd_id_err++; 2843bdcd8170SKalle Valo ret = -EINVAL; 2844bdcd8170SKalle Valo break; 2845bdcd8170SKalle Valo } 2846bdcd8170SKalle Valo 2847bdcd8170SKalle Valo return ret; 2848bdcd8170SKalle Valo } 2849bdcd8170SKalle Valo 2850bdcd8170SKalle Valo /* Control Path */ 2851bdcd8170SKalle Valo int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) 2852bdcd8170SKalle Valo { 2853bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd; 2854bdcd8170SKalle Valo u32 len; 2855bdcd8170SKalle Valo u16 id; 2856bdcd8170SKalle Valo u8 *datap; 2857bdcd8170SKalle Valo int ret = 0; 2858bdcd8170SKalle Valo 2859bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 2860bdcd8170SKalle Valo return -EINVAL; 2861bdcd8170SKalle Valo 2862bdcd8170SKalle Valo if (skb->len < sizeof(struct wmi_cmd_hdr)) { 2863bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 2864bdcd8170SKalle Valo dev_kfree_skb(skb); 2865bdcd8170SKalle Valo wmi->stat.cmd_len_err++; 2866bdcd8170SKalle Valo return -EINVAL; 2867bdcd8170SKalle Valo } 2868bdcd8170SKalle Valo 2869bdcd8170SKalle Valo cmd = (struct wmi_cmd_hdr *) skb->data; 2870bdcd8170SKalle Valo id = le16_to_cpu(cmd->cmd_id); 2871bdcd8170SKalle Valo 2872bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmi_cmd_hdr)); 2873bdcd8170SKalle Valo 2874bdcd8170SKalle Valo datap = skb->data; 2875bdcd8170SKalle Valo len = skb->len; 2876bdcd8170SKalle Valo 2877bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "%s: wmi id: %d\n", __func__, id); 2878bdcd8170SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "msg payload ", datap, len); 2879bdcd8170SKalle Valo 2880bdcd8170SKalle Valo switch (id) { 2881bdcd8170SKalle Valo case WMI_GET_BITRATE_CMDID: 2882bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); 2883bdcd8170SKalle Valo ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); 2884bdcd8170SKalle Valo break; 2885bdcd8170SKalle Valo case WMI_GET_CHANNEL_LIST_CMDID: 2886bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); 2887bdcd8170SKalle Valo ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); 2888bdcd8170SKalle Valo break; 2889bdcd8170SKalle Valo case WMI_GET_TX_PWR_CMDID: 2890bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); 2891bdcd8170SKalle Valo ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); 2892bdcd8170SKalle Valo break; 2893bdcd8170SKalle Valo case WMI_READY_EVENTID: 2894bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); 2895bdcd8170SKalle Valo ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); 2896bdcd8170SKalle Valo break; 2897bdcd8170SKalle Valo case WMI_CONNECT_EVENTID: 2898bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); 2899bdcd8170SKalle Valo ret = ath6kl_wmi_connect_event_rx(wmi, datap, len); 2900bdcd8170SKalle Valo break; 2901bdcd8170SKalle Valo case WMI_DISCONNECT_EVENTID: 2902bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); 2903bdcd8170SKalle Valo ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len); 2904bdcd8170SKalle Valo break; 2905bdcd8170SKalle Valo case WMI_PEER_NODE_EVENTID: 2906bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); 2907bdcd8170SKalle Valo ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); 2908bdcd8170SKalle Valo break; 2909bdcd8170SKalle Valo case WMI_TKIP_MICERR_EVENTID: 2910bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); 2911bdcd8170SKalle Valo ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len); 2912bdcd8170SKalle Valo break; 2913bdcd8170SKalle Valo case WMI_BSSINFO_EVENTID: 2914bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); 2915bdcd8170SKalle Valo ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb, datap); 2916bdcd8170SKalle Valo ret = ath6kl_wmi_bssinfo_event_rx(wmi, skb->data, skb->len); 2917bdcd8170SKalle Valo break; 2918bdcd8170SKalle Valo case WMI_REGDOMAIN_EVENTID: 2919bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); 2920bdcd8170SKalle Valo break; 2921bdcd8170SKalle Valo case WMI_PSTREAM_TIMEOUT_EVENTID: 2922bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); 2923bdcd8170SKalle Valo ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); 2924bdcd8170SKalle Valo break; 2925bdcd8170SKalle Valo case WMI_NEIGHBOR_REPORT_EVENTID: 2926bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); 2927bdcd8170SKalle Valo break; 2928bdcd8170SKalle Valo case WMI_SCAN_COMPLETE_EVENTID: 2929bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); 2930bdcd8170SKalle Valo ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len); 2931bdcd8170SKalle Valo break; 2932bdcd8170SKalle Valo case WMI_CMDERROR_EVENTID: 2933bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); 2934bdcd8170SKalle Valo ret = ath6kl_wmi_error_event_rx(wmi, datap, len); 2935bdcd8170SKalle Valo break; 2936bdcd8170SKalle Valo case WMI_REPORT_STATISTICS_EVENTID: 2937bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); 2938bdcd8170SKalle Valo ret = ath6kl_wmi_stats_event_rx(wmi, datap, len); 2939bdcd8170SKalle Valo break; 2940bdcd8170SKalle Valo case WMI_RSSI_THRESHOLD_EVENTID: 2941bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); 2942bdcd8170SKalle Valo ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); 2943bdcd8170SKalle Valo break; 2944bdcd8170SKalle Valo case WMI_ERROR_REPORT_EVENTID: 2945bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); 2946bdcd8170SKalle Valo break; 2947bdcd8170SKalle Valo case WMI_OPT_RX_FRAME_EVENTID: 2948bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); 2949bdcd8170SKalle Valo ret = ath6kl_wmi_opt_frame_event_rx(wmi, datap, len); 2950bdcd8170SKalle Valo break; 2951bdcd8170SKalle Valo case WMI_REPORT_ROAM_TBL_EVENTID: 2952bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); 2953bdcd8170SKalle Valo break; 2954bdcd8170SKalle Valo case WMI_EXTENSION_EVENTID: 2955bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); 2956bdcd8170SKalle Valo ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); 2957bdcd8170SKalle Valo break; 2958bdcd8170SKalle Valo case WMI_CAC_EVENTID: 2959bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); 2960bdcd8170SKalle Valo ret = ath6kl_wmi_cac_event_rx(wmi, datap, len); 2961bdcd8170SKalle Valo break; 2962bdcd8170SKalle Valo case WMI_CHANNEL_CHANGE_EVENTID: 2963bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); 2964bdcd8170SKalle Valo break; 2965bdcd8170SKalle Valo case WMI_REPORT_ROAM_DATA_EVENTID: 2966bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); 2967bdcd8170SKalle Valo break; 2968bdcd8170SKalle Valo case WMI_GET_FIXRATES_CMDID: 2969bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); 2970bdcd8170SKalle Valo ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); 2971bdcd8170SKalle Valo break; 2972bdcd8170SKalle Valo case WMI_TX_RETRY_ERR_EVENTID: 2973bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); 2974bdcd8170SKalle Valo break; 2975bdcd8170SKalle Valo case WMI_SNR_THRESHOLD_EVENTID: 2976bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); 2977bdcd8170SKalle Valo ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); 2978bdcd8170SKalle Valo break; 2979bdcd8170SKalle Valo case WMI_LQ_THRESHOLD_EVENTID: 2980bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); 2981bdcd8170SKalle Valo break; 2982bdcd8170SKalle Valo case WMI_APLIST_EVENTID: 2983bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); 2984bdcd8170SKalle Valo ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); 2985bdcd8170SKalle Valo break; 2986bdcd8170SKalle Valo case WMI_GET_KEEPALIVE_CMDID: 2987bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); 2988bdcd8170SKalle Valo ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); 2989bdcd8170SKalle Valo break; 2990bdcd8170SKalle Valo case WMI_GET_WOW_LIST_EVENTID: 2991bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); 2992bdcd8170SKalle Valo ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len); 2993bdcd8170SKalle Valo break; 2994bdcd8170SKalle Valo case WMI_GET_PMKID_LIST_EVENTID: 2995bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); 2996bdcd8170SKalle Valo ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); 2997bdcd8170SKalle Valo break; 2998bdcd8170SKalle Valo case WMI_PSPOLL_EVENTID: 2999bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); 3000bdcd8170SKalle Valo ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len); 3001bdcd8170SKalle Valo break; 3002bdcd8170SKalle Valo case WMI_DTIMEXPIRY_EVENTID: 3003bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); 3004bdcd8170SKalle Valo ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len); 3005bdcd8170SKalle Valo break; 3006bdcd8170SKalle Valo case WMI_SET_PARAMS_REPLY_EVENTID: 3007bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); 3008bdcd8170SKalle Valo break; 3009bdcd8170SKalle Valo case WMI_ADDBA_REQ_EVENTID: 3010bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); 3011bdcd8170SKalle Valo ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len); 3012bdcd8170SKalle Valo break; 3013bdcd8170SKalle Valo case WMI_ADDBA_RESP_EVENTID: 3014bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); 3015bdcd8170SKalle Valo break; 3016bdcd8170SKalle Valo case WMI_DELBA_REQ_EVENTID: 3017bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); 3018bdcd8170SKalle Valo ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len); 3019bdcd8170SKalle Valo break; 3020bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_CONFIG_EVENTID: 3021bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3022bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); 3023bdcd8170SKalle Valo break; 3024bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_STATS_EVENTID: 3025bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3026bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); 3027bdcd8170SKalle Valo break; 3028bdcd8170SKalle Valo case WMI_TX_COMPLETE_EVENTID: 3029bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); 3030bdcd8170SKalle Valo ret = ath6kl_wmi_tx_complete_event_rx(datap, len); 3031bdcd8170SKalle Valo break; 30326465ddcfSJouni Malinen case WMI_REMAIN_ON_CHNL_EVENTID: 30336465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); 3034*f9e5f05cSJouni Malinen ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len); 30356465ddcfSJouni Malinen break; 30366465ddcfSJouni Malinen case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: 30376465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, 30386465ddcfSJouni Malinen "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); 3039*f9e5f05cSJouni Malinen ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, 3040*f9e5f05cSJouni Malinen len); 30416465ddcfSJouni Malinen break; 30426465ddcfSJouni Malinen case WMI_TX_STATUS_EVENTID: 30436465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); 30446465ddcfSJouni Malinen ret = ath6kl_wmi_tx_status_event_rx(datap, len); 30456465ddcfSJouni Malinen break; 30466465ddcfSJouni Malinen case WMI_RX_PROBE_REQ_EVENTID: 30476465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); 30486465ddcfSJouni Malinen ret = ath6kl_wmi_rx_probe_req_event_rx(datap, len); 30496465ddcfSJouni Malinen break; 30506465ddcfSJouni Malinen case WMI_P2P_CAPABILITIES_EVENTID: 30516465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); 30526465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); 30536465ddcfSJouni Malinen break; 30546465ddcfSJouni Malinen case WMI_RX_ACTION_EVENTID: 30556465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); 30566465ddcfSJouni Malinen ret = ath6kl_wmi_rx_action_event_rx(datap, len); 30576465ddcfSJouni Malinen break; 30586465ddcfSJouni Malinen case WMI_P2P_INFO_EVENTID: 30596465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); 30606465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_info_event_rx(datap, len); 30616465ddcfSJouni Malinen break; 3062bdcd8170SKalle Valo default: 3063bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); 3064bdcd8170SKalle Valo wmi->stat.cmd_id_err++; 3065bdcd8170SKalle Valo ret = -EINVAL; 3066bdcd8170SKalle Valo break; 3067bdcd8170SKalle Valo } 3068bdcd8170SKalle Valo 3069bdcd8170SKalle Valo dev_kfree_skb(skb); 3070bdcd8170SKalle Valo 3071bdcd8170SKalle Valo return ret; 3072bdcd8170SKalle Valo } 3073bdcd8170SKalle Valo 3074bdcd8170SKalle Valo static void ath6kl_wmi_qos_state_init(struct wmi *wmi) 3075bdcd8170SKalle Valo { 3076bdcd8170SKalle Valo if (!wmi) 3077bdcd8170SKalle Valo return; 3078bdcd8170SKalle Valo 3079bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 3080bdcd8170SKalle Valo 3081bdcd8170SKalle Valo wmi->fat_pipe_exist = 0; 3082bdcd8170SKalle Valo memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); 3083bdcd8170SKalle Valo 3084bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 3085bdcd8170SKalle Valo } 3086bdcd8170SKalle Valo 30872865785eSVasanthakumar Thiagarajan void *ath6kl_wmi_init(struct ath6kl *dev) 3088bdcd8170SKalle Valo { 3089bdcd8170SKalle Valo struct wmi *wmi; 3090bdcd8170SKalle Valo 3091bdcd8170SKalle Valo wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); 3092bdcd8170SKalle Valo if (!wmi) 3093bdcd8170SKalle Valo return NULL; 3094bdcd8170SKalle Valo 3095bdcd8170SKalle Valo spin_lock_init(&wmi->lock); 3096bdcd8170SKalle Valo 3097bdcd8170SKalle Valo wmi->parent_dev = dev; 3098bdcd8170SKalle Valo 3099bdcd8170SKalle Valo ath6kl_wmi_qos_state_init(wmi); 3100bdcd8170SKalle Valo 3101bdcd8170SKalle Valo wmi->pwr_mode = REC_POWER; 3102bdcd8170SKalle Valo wmi->phy_mode = WMI_11G_MODE; 3103bdcd8170SKalle Valo 3104bdcd8170SKalle Valo wmi->pair_crypto_type = NONE_CRYPT; 3105bdcd8170SKalle Valo wmi->grp_crypto_type = NONE_CRYPT; 3106bdcd8170SKalle Valo 3107bdcd8170SKalle Valo wmi->ht_allowed[A_BAND_24GHZ] = 1; 3108bdcd8170SKalle Valo wmi->ht_allowed[A_BAND_5GHZ] = 1; 3109bdcd8170SKalle Valo 3110bdcd8170SKalle Valo return wmi; 3111bdcd8170SKalle Valo } 3112bdcd8170SKalle Valo 3113bdcd8170SKalle Valo void ath6kl_wmi_shutdown(struct wmi *wmi) 3114bdcd8170SKalle Valo { 3115bdcd8170SKalle Valo if (!wmi) 3116bdcd8170SKalle Valo return; 3117bdcd8170SKalle Valo 3118bdcd8170SKalle Valo kfree(wmi); 3119bdcd8170SKalle Valo } 3120