1bdcd8170SKalle Valo /* 2bdcd8170SKalle Valo * Copyright (c) 2004-2011 Atheros Communications Inc. 3bdcd8170SKalle Valo * 4bdcd8170SKalle Valo * Permission to use, copy, modify, and/or distribute this software for any 5bdcd8170SKalle Valo * purpose with or without fee is hereby granted, provided that the above 6bdcd8170SKalle Valo * copyright notice and this permission notice appear in all copies. 7bdcd8170SKalle Valo * 8bdcd8170SKalle Valo * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9bdcd8170SKalle Valo * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10bdcd8170SKalle Valo * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11bdcd8170SKalle Valo * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12bdcd8170SKalle Valo * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13bdcd8170SKalle Valo * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14bdcd8170SKalle Valo * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15bdcd8170SKalle Valo */ 16bdcd8170SKalle Valo 17bdcd8170SKalle Valo #include <linux/ip.h> 18bdcd8170SKalle Valo #include "core.h" 19bdcd8170SKalle Valo #include "debug.h" 20003353b0SKalle Valo #include "testmode.h" 2106033760SVivek Natarajan #include "../regd.h" 2206033760SVivek Natarajan #include "../regd_common.h" 23bdcd8170SKalle Valo 24bdcd8170SKalle Valo static int ath6kl_wmi_sync_point(struct wmi *wmi); 25bdcd8170SKalle Valo 26bdcd8170SKalle Valo static const s32 wmi_rate_tbl[][2] = { 27bdcd8170SKalle Valo /* {W/O SGI, with SGI} */ 28bdcd8170SKalle Valo {1000, 1000}, 29bdcd8170SKalle Valo {2000, 2000}, 30bdcd8170SKalle Valo {5500, 5500}, 31bdcd8170SKalle Valo {11000, 11000}, 32bdcd8170SKalle Valo {6000, 6000}, 33bdcd8170SKalle Valo {9000, 9000}, 34bdcd8170SKalle Valo {12000, 12000}, 35bdcd8170SKalle Valo {18000, 18000}, 36bdcd8170SKalle Valo {24000, 24000}, 37bdcd8170SKalle Valo {36000, 36000}, 38bdcd8170SKalle Valo {48000, 48000}, 39bdcd8170SKalle Valo {54000, 54000}, 40bdcd8170SKalle Valo {6500, 7200}, 41bdcd8170SKalle Valo {13000, 14400}, 42bdcd8170SKalle Valo {19500, 21700}, 43bdcd8170SKalle Valo {26000, 28900}, 44bdcd8170SKalle Valo {39000, 43300}, 45bdcd8170SKalle Valo {52000, 57800}, 46bdcd8170SKalle Valo {58500, 65000}, 47bdcd8170SKalle Valo {65000, 72200}, 48bdcd8170SKalle Valo {13500, 15000}, 49bdcd8170SKalle Valo {27000, 30000}, 50bdcd8170SKalle Valo {40500, 45000}, 51bdcd8170SKalle Valo {54000, 60000}, 52bdcd8170SKalle Valo {81000, 90000}, 53bdcd8170SKalle Valo {108000, 120000}, 54bdcd8170SKalle Valo {121500, 135000}, 55bdcd8170SKalle Valo {135000, 150000}, 56bdcd8170SKalle Valo {0, 0} 57bdcd8170SKalle Valo }; 58bdcd8170SKalle Valo 59bdcd8170SKalle Valo /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */ 60bdcd8170SKalle Valo static const u8 up_to_ac[] = { 61bdcd8170SKalle Valo WMM_AC_BE, 62bdcd8170SKalle Valo WMM_AC_BK, 63bdcd8170SKalle Valo WMM_AC_BK, 64bdcd8170SKalle Valo WMM_AC_BE, 65bdcd8170SKalle Valo WMM_AC_VI, 66bdcd8170SKalle Valo WMM_AC_VI, 67bdcd8170SKalle Valo WMM_AC_VO, 68bdcd8170SKalle Valo WMM_AC_VO, 69bdcd8170SKalle Valo }; 70bdcd8170SKalle Valo 71bdcd8170SKalle Valo void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id) 72bdcd8170SKalle Valo { 73bdcd8170SKalle Valo if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX)) 74bdcd8170SKalle Valo return; 75bdcd8170SKalle Valo 76bdcd8170SKalle Valo wmi->ep_id = ep_id; 77bdcd8170SKalle Valo } 78bdcd8170SKalle Valo 79bdcd8170SKalle Valo enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) 80bdcd8170SKalle Valo { 81bdcd8170SKalle Valo return wmi->ep_id; 82bdcd8170SKalle Valo } 83bdcd8170SKalle Valo 84bdcd8170SKalle Valo /* Performs DIX to 802.3 encapsulation for transmit packets. 85bdcd8170SKalle Valo * Assumes the entire DIX header is contigous and that there is 86bdcd8170SKalle Valo * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. 87bdcd8170SKalle Valo */ 88bdcd8170SKalle Valo int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) 89bdcd8170SKalle Valo { 90bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 91bdcd8170SKalle Valo struct ethhdr *eth_hdr; 92bdcd8170SKalle Valo size_t new_len; 93bdcd8170SKalle Valo __be16 type; 94bdcd8170SKalle Valo u8 *datap; 95bdcd8170SKalle Valo u16 size; 96bdcd8170SKalle Valo 97bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 98bdcd8170SKalle Valo return -EINVAL; 99bdcd8170SKalle Valo 100bdcd8170SKalle Valo size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr); 101bdcd8170SKalle Valo if (skb_headroom(skb) < size) 102bdcd8170SKalle Valo return -ENOMEM; 103bdcd8170SKalle Valo 104bdcd8170SKalle Valo eth_hdr = (struct ethhdr *) skb->data; 105bdcd8170SKalle Valo type = eth_hdr->h_proto; 106bdcd8170SKalle Valo 107bdcd8170SKalle Valo if (!is_ethertype(be16_to_cpu(type))) { 108bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 109bdcd8170SKalle Valo "%s: pkt is already in 802.3 format\n", __func__); 110bdcd8170SKalle Valo return 0; 111bdcd8170SKalle Valo } 112bdcd8170SKalle Valo 113bdcd8170SKalle Valo new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr); 114bdcd8170SKalle Valo 115bdcd8170SKalle Valo skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr)); 116bdcd8170SKalle Valo datap = skb->data; 117bdcd8170SKalle Valo 118bdcd8170SKalle Valo eth_hdr->h_proto = cpu_to_be16(new_len); 119bdcd8170SKalle Valo 120bdcd8170SKalle Valo memcpy(datap, eth_hdr, sizeof(*eth_hdr)); 121bdcd8170SKalle Valo 122bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr)); 123bdcd8170SKalle Valo llc_hdr->dsap = 0xAA; 124bdcd8170SKalle Valo llc_hdr->ssap = 0xAA; 125bdcd8170SKalle Valo llc_hdr->cntl = 0x03; 126bdcd8170SKalle Valo llc_hdr->org_code[0] = 0x0; 127bdcd8170SKalle Valo llc_hdr->org_code[1] = 0x0; 128bdcd8170SKalle Valo llc_hdr->org_code[2] = 0x0; 129bdcd8170SKalle Valo llc_hdr->eth_type = type; 130bdcd8170SKalle Valo 131bdcd8170SKalle Valo return 0; 132bdcd8170SKalle Valo } 133bdcd8170SKalle Valo 134bdcd8170SKalle Valo static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, 135bdcd8170SKalle Valo u8 *version, void *tx_meta_info) 136bdcd8170SKalle Valo { 137bdcd8170SKalle Valo struct wmi_tx_meta_v1 *v1; 138bdcd8170SKalle Valo struct wmi_tx_meta_v2 *v2; 139bdcd8170SKalle Valo 140bdcd8170SKalle Valo if (WARN_ON(skb == NULL || version == NULL)) 141bdcd8170SKalle Valo return -EINVAL; 142bdcd8170SKalle Valo 143bdcd8170SKalle Valo switch (*version) { 144bdcd8170SKalle Valo case WMI_META_VERSION_1: 145bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 146bdcd8170SKalle Valo v1 = (struct wmi_tx_meta_v1 *) skb->data; 147bdcd8170SKalle Valo v1->pkt_id = 0; 148bdcd8170SKalle Valo v1->rate_plcy_id = 0; 149bdcd8170SKalle Valo *version = WMI_META_VERSION_1; 150bdcd8170SKalle Valo break; 151bdcd8170SKalle Valo case WMI_META_VERSION_2: 152bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 153bdcd8170SKalle Valo v2 = (struct wmi_tx_meta_v2 *) skb->data; 154bdcd8170SKalle Valo memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info, 155bdcd8170SKalle Valo sizeof(struct wmi_tx_meta_v2)); 156bdcd8170SKalle Valo break; 157bdcd8170SKalle Valo } 158bdcd8170SKalle Valo 159bdcd8170SKalle Valo return 0; 160bdcd8170SKalle Valo } 161bdcd8170SKalle Valo 162bdcd8170SKalle Valo int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, 163bdcd8170SKalle Valo u8 msg_type, bool more_data, 164bdcd8170SKalle Valo enum wmi_data_hdr_data_type data_type, 165bdcd8170SKalle Valo u8 meta_ver, void *tx_meta_info) 166bdcd8170SKalle Valo { 167bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 168bdcd8170SKalle Valo int ret; 169bdcd8170SKalle Valo 170bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 171bdcd8170SKalle Valo return -EINVAL; 172bdcd8170SKalle Valo 1733ce6ff50SVasanthakumar Thiagarajan if (tx_meta_info) { 174bdcd8170SKalle Valo ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info); 175bdcd8170SKalle Valo if (ret) 176bdcd8170SKalle Valo return ret; 1773ce6ff50SVasanthakumar Thiagarajan } 178bdcd8170SKalle Valo 179bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 180bdcd8170SKalle Valo 181bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *)skb->data; 182bdcd8170SKalle Valo memset(data_hdr, 0, sizeof(struct wmi_data_hdr)); 183bdcd8170SKalle Valo 184bdcd8170SKalle Valo data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; 185bdcd8170SKalle Valo data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; 186bdcd8170SKalle Valo 187bdcd8170SKalle Valo if (more_data) 188bdcd8170SKalle Valo data_hdr->info |= 189bdcd8170SKalle Valo WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT; 190bdcd8170SKalle Valo 191bdcd8170SKalle Valo data_hdr->info2 = cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); 192bdcd8170SKalle Valo data_hdr->info3 = 0; 193bdcd8170SKalle Valo 194bdcd8170SKalle Valo return 0; 195bdcd8170SKalle Valo } 196bdcd8170SKalle Valo 197bdcd8170SKalle Valo static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) 198bdcd8170SKalle Valo { 199bdcd8170SKalle Valo struct iphdr *ip_hdr = (struct iphdr *) pkt; 200bdcd8170SKalle Valo u8 ip_pri; 201bdcd8170SKalle Valo 202bdcd8170SKalle Valo /* 203bdcd8170SKalle Valo * Determine IPTOS priority 204bdcd8170SKalle Valo * 205bdcd8170SKalle Valo * IP-TOS - 8bits 206bdcd8170SKalle Valo * : DSCP(6-bits) ECN(2-bits) 207bdcd8170SKalle Valo * : DSCP - P2 P1 P0 X X X 208bdcd8170SKalle Valo * where (P2 P1 P0) form 802.1D 209bdcd8170SKalle Valo */ 210bdcd8170SKalle Valo ip_pri = ip_hdr->tos >> 5; 211bdcd8170SKalle Valo ip_pri &= 0x7; 212bdcd8170SKalle Valo 213bdcd8170SKalle Valo if ((layer2_pri & 0x7) > ip_pri) 214bdcd8170SKalle Valo return (u8) layer2_pri & 0x7; 215bdcd8170SKalle Valo else 216bdcd8170SKalle Valo return ip_pri; 217bdcd8170SKalle Valo } 218bdcd8170SKalle Valo 219bdcd8170SKalle Valo int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, 220bdcd8170SKalle Valo u32 layer2_priority, bool wmm_enabled, 221bdcd8170SKalle Valo u8 *ac) 222bdcd8170SKalle Valo { 223bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 224bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 225bdcd8170SKalle Valo struct wmi_create_pstream_cmd cmd; 226bdcd8170SKalle Valo u32 meta_size, hdr_size; 227bdcd8170SKalle Valo u16 ip_type = IP_ETHERTYPE; 228bdcd8170SKalle Valo u8 stream_exist, usr_pri; 229bdcd8170SKalle Valo u8 traffic_class = WMM_AC_BE; 230bdcd8170SKalle Valo u8 *datap; 231bdcd8170SKalle Valo 232bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 233bdcd8170SKalle Valo return -EINVAL; 234bdcd8170SKalle Valo 235bdcd8170SKalle Valo datap = skb->data; 236bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) datap; 237bdcd8170SKalle Valo 238bdcd8170SKalle Valo meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) & 239bdcd8170SKalle Valo WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0; 240bdcd8170SKalle Valo 241bdcd8170SKalle Valo if (!wmm_enabled) { 242bdcd8170SKalle Valo /* If WMM is disabled all traffic goes as BE traffic */ 243bdcd8170SKalle Valo usr_pri = 0; 244bdcd8170SKalle Valo } else { 245bdcd8170SKalle Valo hdr_size = sizeof(struct ethhdr); 246bdcd8170SKalle Valo 247bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + 248bdcd8170SKalle Valo sizeof(struct 249bdcd8170SKalle Valo wmi_data_hdr) + 250bdcd8170SKalle Valo meta_size + hdr_size); 251bdcd8170SKalle Valo 252bdcd8170SKalle Valo if (llc_hdr->eth_type == htons(ip_type)) { 253bdcd8170SKalle Valo /* 254bdcd8170SKalle Valo * Extract the endpoint info from the TOS field 255bdcd8170SKalle Valo * in the IP header. 256bdcd8170SKalle Valo */ 257bdcd8170SKalle Valo usr_pri = 258bdcd8170SKalle Valo ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + 259bdcd8170SKalle Valo sizeof(struct ath6kl_llc_snap_hdr), 260bdcd8170SKalle Valo layer2_priority); 261bdcd8170SKalle Valo } else 262bdcd8170SKalle Valo usr_pri = layer2_priority & 0x7; 263bdcd8170SKalle Valo } 264bdcd8170SKalle Valo 265a7f0c58bSKalle Valo /* 266a7f0c58bSKalle Valo * workaround for WMM S5 267a7f0c58bSKalle Valo * 268a7f0c58bSKalle Valo * FIXME: wmi->traffic_class is always 100 so this test doesn't 269a7f0c58bSKalle Valo * make sense 270a7f0c58bSKalle Valo */ 271bdcd8170SKalle Valo if ((wmi->traffic_class == WMM_AC_VI) && 272bdcd8170SKalle Valo ((usr_pri == 5) || (usr_pri == 4))) 273bdcd8170SKalle Valo usr_pri = 1; 274bdcd8170SKalle Valo 275bdcd8170SKalle Valo /* Convert user priority to traffic class */ 276bdcd8170SKalle Valo traffic_class = up_to_ac[usr_pri & 0x7]; 277bdcd8170SKalle Valo 278bdcd8170SKalle Valo wmi_data_hdr_set_up(data_hdr, usr_pri); 279bdcd8170SKalle Valo 280bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 281bdcd8170SKalle Valo stream_exist = wmi->fat_pipe_exist; 282bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 283bdcd8170SKalle Valo 284bdcd8170SKalle Valo if (!(stream_exist & (1 << traffic_class))) { 285bdcd8170SKalle Valo memset(&cmd, 0, sizeof(cmd)); 286bdcd8170SKalle Valo cmd.traffic_class = traffic_class; 287bdcd8170SKalle Valo cmd.user_pri = usr_pri; 288bdcd8170SKalle Valo cmd.inactivity_int = 289bdcd8170SKalle Valo cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); 290bdcd8170SKalle Valo /* Implicit streams are created with TSID 0xFF */ 291bdcd8170SKalle Valo cmd.tsid = WMI_IMPLICIT_PSTREAM; 292bdcd8170SKalle Valo ath6kl_wmi_create_pstream_cmd(wmi, &cmd); 293bdcd8170SKalle Valo } 294bdcd8170SKalle Valo 295bdcd8170SKalle Valo *ac = traffic_class; 296bdcd8170SKalle Valo 297bdcd8170SKalle Valo return 0; 298bdcd8170SKalle Valo } 299bdcd8170SKalle Valo 300bdcd8170SKalle Valo int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) 301bdcd8170SKalle Valo { 302bdcd8170SKalle Valo struct ieee80211_hdr_3addr *pwh, wh; 303bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 304bdcd8170SKalle Valo struct ethhdr eth_hdr; 305bdcd8170SKalle Valo u32 hdr_size; 306bdcd8170SKalle Valo u8 *datap; 307bdcd8170SKalle Valo __le16 sub_type; 308bdcd8170SKalle Valo 309bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 310bdcd8170SKalle Valo return -EINVAL; 311bdcd8170SKalle Valo 312bdcd8170SKalle Valo datap = skb->data; 313bdcd8170SKalle Valo pwh = (struct ieee80211_hdr_3addr *) datap; 314bdcd8170SKalle Valo 315bdcd8170SKalle Valo sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); 316bdcd8170SKalle Valo 317bdcd8170SKalle Valo memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); 318bdcd8170SKalle Valo 319bdcd8170SKalle Valo /* Strip off the 802.11 header */ 320bdcd8170SKalle Valo if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { 321bdcd8170SKalle Valo hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), 322bdcd8170SKalle Valo sizeof(u32)); 323bdcd8170SKalle Valo skb_pull(skb, hdr_size); 324bdcd8170SKalle Valo } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) 325bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); 326bdcd8170SKalle Valo 327bdcd8170SKalle Valo datap = skb->data; 328bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); 329bdcd8170SKalle Valo 330c8790cbaSRaja Mani memset(ð_hdr, 0, sizeof(eth_hdr)); 331bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 332bdcd8170SKalle Valo 333bdcd8170SKalle Valo switch ((le16_to_cpu(wh.frame_control)) & 334bdcd8170SKalle Valo (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 335bdcd8170SKalle Valo case 0: 336bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 337bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 338bdcd8170SKalle Valo break; 339bdcd8170SKalle Valo case IEEE80211_FCTL_TODS: 340bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); 341bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 342bdcd8170SKalle Valo break; 343bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS: 344bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 345bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); 346bdcd8170SKalle Valo break; 347bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: 348bdcd8170SKalle Valo break; 349bdcd8170SKalle Valo } 350bdcd8170SKalle Valo 351bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 352bdcd8170SKalle Valo skb_push(skb, sizeof(eth_hdr)); 353bdcd8170SKalle Valo 354bdcd8170SKalle Valo datap = skb->data; 355bdcd8170SKalle Valo 356bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 357bdcd8170SKalle Valo 358bdcd8170SKalle Valo return 0; 359bdcd8170SKalle Valo } 360bdcd8170SKalle Valo 361bdcd8170SKalle Valo /* 362bdcd8170SKalle Valo * Performs 802.3 to DIX encapsulation for received packets. 363bdcd8170SKalle Valo * Assumes the entire 802.3 header is contigous. 364bdcd8170SKalle Valo */ 365bdcd8170SKalle Valo int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) 366bdcd8170SKalle Valo { 367bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 368bdcd8170SKalle Valo struct ethhdr eth_hdr; 369bdcd8170SKalle Valo u8 *datap; 370bdcd8170SKalle Valo 371bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 372bdcd8170SKalle Valo return -EINVAL; 373bdcd8170SKalle Valo 374bdcd8170SKalle Valo datap = skb->data; 375bdcd8170SKalle Valo 376bdcd8170SKalle Valo memcpy(ð_hdr, datap, sizeof(eth_hdr)); 377bdcd8170SKalle Valo 378bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); 379bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 380bdcd8170SKalle Valo 381bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 382bdcd8170SKalle Valo datap = skb->data; 383bdcd8170SKalle Valo 384bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 385bdcd8170SKalle Valo 386bdcd8170SKalle Valo return 0; 387bdcd8170SKalle Valo } 388bdcd8170SKalle Valo 389bdcd8170SKalle Valo static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) 390bdcd8170SKalle Valo { 391bdcd8170SKalle Valo struct tx_complete_msg_v1 *msg_v1; 392bdcd8170SKalle Valo struct wmi_tx_complete_event *evt; 393bdcd8170SKalle Valo int index; 394bdcd8170SKalle Valo u16 size; 395bdcd8170SKalle Valo 396bdcd8170SKalle Valo evt = (struct wmi_tx_complete_event *) datap; 397bdcd8170SKalle Valo 398bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", 399bdcd8170SKalle Valo evt->num_msg, evt->msg_len, evt->msg_type); 400bdcd8170SKalle Valo 401bdcd8170SKalle Valo if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI)) 402bdcd8170SKalle Valo return 0; 403bdcd8170SKalle Valo 404bdcd8170SKalle Valo for (index = 0; index < evt->num_msg; index++) { 405bdcd8170SKalle Valo size = sizeof(struct wmi_tx_complete_event) + 406bdcd8170SKalle Valo (index * sizeof(struct tx_complete_msg_v1)); 407bdcd8170SKalle Valo msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); 408bdcd8170SKalle Valo 409bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", 410bdcd8170SKalle Valo msg_v1->status, msg_v1->pkt_id, 411bdcd8170SKalle Valo msg_v1->rate_idx, msg_v1->ack_failures); 412bdcd8170SKalle Valo } 413bdcd8170SKalle Valo 414bdcd8170SKalle Valo return 0; 415bdcd8170SKalle Valo } 416bdcd8170SKalle Valo 417f9e5f05cSJouni Malinen static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, 418f9e5f05cSJouni Malinen int len) 4196465ddcfSJouni Malinen { 4206465ddcfSJouni Malinen struct wmi_remain_on_chnl_event *ev; 4216465ddcfSJouni Malinen u32 freq; 4226465ddcfSJouni Malinen u32 dur; 423f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 424f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4256465ddcfSJouni Malinen 4266465ddcfSJouni Malinen if (len < sizeof(*ev)) 4276465ddcfSJouni Malinen return -EINVAL; 4286465ddcfSJouni Malinen 4296465ddcfSJouni Malinen ev = (struct wmi_remain_on_chnl_event *) datap; 4306465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4316465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4326465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", 4336465ddcfSJouni Malinen freq, dur); 434be98e3a4SVasanthakumar Thiagarajan chan = ieee80211_get_channel(ar->wiphy, freq); 435f9e5f05cSJouni Malinen if (!chan) { 436f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " 437f9e5f05cSJouni Malinen "(freq=%u)\n", freq); 438f9e5f05cSJouni Malinen return -EINVAL; 439f9e5f05cSJouni Malinen } 440f9e5f05cSJouni Malinen cfg80211_ready_on_channel(ar->net_dev, 1, chan, NL80211_CHAN_NO_HT, 441f9e5f05cSJouni Malinen dur, GFP_ATOMIC); 4426465ddcfSJouni Malinen 4436465ddcfSJouni Malinen return 0; 4446465ddcfSJouni Malinen } 4456465ddcfSJouni Malinen 446f9e5f05cSJouni Malinen static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, 447f9e5f05cSJouni Malinen u8 *datap, int len) 4486465ddcfSJouni Malinen { 4496465ddcfSJouni Malinen struct wmi_cancel_remain_on_chnl_event *ev; 4506465ddcfSJouni Malinen u32 freq; 4516465ddcfSJouni Malinen u32 dur; 452f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 453f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4546465ddcfSJouni Malinen 4556465ddcfSJouni Malinen if (len < sizeof(*ev)) 4566465ddcfSJouni Malinen return -EINVAL; 4576465ddcfSJouni Malinen 4586465ddcfSJouni Malinen ev = (struct wmi_cancel_remain_on_chnl_event *) datap; 4596465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4606465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4616465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " 4626465ddcfSJouni Malinen "status=%u\n", freq, dur, ev->status); 463be98e3a4SVasanthakumar Thiagarajan chan = ieee80211_get_channel(ar->wiphy, freq); 464f9e5f05cSJouni Malinen if (!chan) { 465f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " 466f9e5f05cSJouni Malinen "channel (freq=%u)\n", freq); 467f9e5f05cSJouni Malinen return -EINVAL; 468f9e5f05cSJouni Malinen } 469f9e5f05cSJouni Malinen cfg80211_remain_on_channel_expired(ar->net_dev, 1, chan, 470f9e5f05cSJouni Malinen NL80211_CHAN_NO_HT, GFP_ATOMIC); 4716465ddcfSJouni Malinen 4726465ddcfSJouni Malinen return 0; 4736465ddcfSJouni Malinen } 4746465ddcfSJouni Malinen 475a0df5db1SJouni Malinen static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len) 4766465ddcfSJouni Malinen { 4776465ddcfSJouni Malinen struct wmi_tx_status_event *ev; 4786465ddcfSJouni Malinen u32 id; 479a0df5db1SJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4806465ddcfSJouni Malinen 4816465ddcfSJouni Malinen if (len < sizeof(*ev)) 4826465ddcfSJouni Malinen return -EINVAL; 4836465ddcfSJouni Malinen 4846465ddcfSJouni Malinen ev = (struct wmi_tx_status_event *) datap; 4856465ddcfSJouni Malinen id = le32_to_cpu(ev->id); 4866465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", 4876465ddcfSJouni Malinen id, ev->ack_status); 488a0df5db1SJouni Malinen if (wmi->last_mgmt_tx_frame) { 489a0df5db1SJouni Malinen cfg80211_mgmt_tx_status(ar->net_dev, id, 490a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame, 491a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len, 492a0df5db1SJouni Malinen !!ev->ack_status, GFP_ATOMIC); 493a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 494a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = NULL; 495a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = 0; 496a0df5db1SJouni Malinen } 4976465ddcfSJouni Malinen 4986465ddcfSJouni Malinen return 0; 4996465ddcfSJouni Malinen } 5006465ddcfSJouni Malinen 501ae32c30aSJouni Malinen static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) 5026465ddcfSJouni Malinen { 5036465ddcfSJouni Malinen struct wmi_p2p_rx_probe_req_event *ev; 504ae32c30aSJouni Malinen u32 freq; 5056465ddcfSJouni Malinen u16 dlen; 506ae32c30aSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 507f5938f24SVasanthakumar Thiagarajan /* TODO: Findout vif */ 508f5938f24SVasanthakumar Thiagarajan struct ath6kl_vif *vif = ar->vif; 5096465ddcfSJouni Malinen 5106465ddcfSJouni Malinen if (len < sizeof(*ev)) 5116465ddcfSJouni Malinen return -EINVAL; 5126465ddcfSJouni Malinen 5136465ddcfSJouni Malinen ev = (struct wmi_p2p_rx_probe_req_event *) datap; 514ae32c30aSJouni Malinen freq = le32_to_cpu(ev->freq); 5156465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 516ae32c30aSJouni Malinen if (datap + len < ev->data + dlen) { 517ae32c30aSJouni Malinen ath6kl_err("invalid wmi_p2p_rx_probe_req_event: " 518ae32c30aSJouni Malinen "len=%d dlen=%u\n", len, dlen); 519ae32c30aSJouni Malinen return -EINVAL; 520ae32c30aSJouni Malinen } 521ae32c30aSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u " 522ae32c30aSJouni Malinen "probe_req_report=%d\n", 523*cf5333d7SVasanthakumar Thiagarajan dlen, freq, vif->probe_req_report); 524ae32c30aSJouni Malinen 525*cf5333d7SVasanthakumar Thiagarajan if (vif->probe_req_report || vif->nw_type == AP_NETWORK) 526ae32c30aSJouni Malinen cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); 5276465ddcfSJouni Malinen 5286465ddcfSJouni Malinen return 0; 5296465ddcfSJouni Malinen } 5306465ddcfSJouni Malinen 5316465ddcfSJouni Malinen static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) 5326465ddcfSJouni Malinen { 5336465ddcfSJouni Malinen struct wmi_p2p_capabilities_event *ev; 5346465ddcfSJouni Malinen u16 dlen; 5356465ddcfSJouni Malinen 5366465ddcfSJouni Malinen if (len < sizeof(*ev)) 5376465ddcfSJouni Malinen return -EINVAL; 5386465ddcfSJouni Malinen 5396465ddcfSJouni Malinen ev = (struct wmi_p2p_capabilities_event *) datap; 5406465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5416465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); 5426465ddcfSJouni Malinen 5436465ddcfSJouni Malinen return 0; 5446465ddcfSJouni Malinen } 5456465ddcfSJouni Malinen 5469809d8efSJouni Malinen static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len) 5476465ddcfSJouni Malinen { 5486465ddcfSJouni Malinen struct wmi_rx_action_event *ev; 5499809d8efSJouni Malinen u32 freq; 5506465ddcfSJouni Malinen u16 dlen; 5519809d8efSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 5526465ddcfSJouni Malinen 5536465ddcfSJouni Malinen if (len < sizeof(*ev)) 5546465ddcfSJouni Malinen return -EINVAL; 5556465ddcfSJouni Malinen 5566465ddcfSJouni Malinen ev = (struct wmi_rx_action_event *) datap; 5579809d8efSJouni Malinen freq = le32_to_cpu(ev->freq); 5586465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5599809d8efSJouni Malinen if (datap + len < ev->data + dlen) { 5609809d8efSJouni Malinen ath6kl_err("invalid wmi_rx_action_event: " 5619809d8efSJouni Malinen "len=%d dlen=%u\n", len, dlen); 5629809d8efSJouni Malinen return -EINVAL; 5639809d8efSJouni Malinen } 5649809d8efSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); 5659809d8efSJouni Malinen cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); 5666465ddcfSJouni Malinen 5676465ddcfSJouni Malinen return 0; 5686465ddcfSJouni Malinen } 5696465ddcfSJouni Malinen 5706465ddcfSJouni Malinen static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) 5716465ddcfSJouni Malinen { 5726465ddcfSJouni Malinen struct wmi_p2p_info_event *ev; 5736465ddcfSJouni Malinen u32 flags; 5746465ddcfSJouni Malinen u16 dlen; 5756465ddcfSJouni Malinen 5766465ddcfSJouni Malinen if (len < sizeof(*ev)) 5776465ddcfSJouni Malinen return -EINVAL; 5786465ddcfSJouni Malinen 5796465ddcfSJouni Malinen ev = (struct wmi_p2p_info_event *) datap; 5806465ddcfSJouni Malinen flags = le32_to_cpu(ev->info_req_flags); 5816465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5826465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); 5836465ddcfSJouni Malinen 5846465ddcfSJouni Malinen if (flags & P2P_FLAG_CAPABILITIES_REQ) { 5856465ddcfSJouni Malinen struct wmi_p2p_capabilities *cap; 5866465ddcfSJouni Malinen if (dlen < sizeof(*cap)) 5876465ddcfSJouni Malinen return -EINVAL; 5886465ddcfSJouni Malinen cap = (struct wmi_p2p_capabilities *) ev->data; 5896465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", 5906465ddcfSJouni Malinen cap->go_power_save); 5916465ddcfSJouni Malinen } 5926465ddcfSJouni Malinen 5936465ddcfSJouni Malinen if (flags & P2P_FLAG_MACADDR_REQ) { 5946465ddcfSJouni Malinen struct wmi_p2p_macaddr *mac; 5956465ddcfSJouni Malinen if (dlen < sizeof(*mac)) 5966465ddcfSJouni Malinen return -EINVAL; 5976465ddcfSJouni Malinen mac = (struct wmi_p2p_macaddr *) ev->data; 5986465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", 5996465ddcfSJouni Malinen mac->mac_addr); 6006465ddcfSJouni Malinen } 6016465ddcfSJouni Malinen 6026465ddcfSJouni Malinen if (flags & P2P_FLAG_HMODEL_REQ) { 6036465ddcfSJouni Malinen struct wmi_p2p_hmodel *mod; 6046465ddcfSJouni Malinen if (dlen < sizeof(*mod)) 6056465ddcfSJouni Malinen return -EINVAL; 6066465ddcfSJouni Malinen mod = (struct wmi_p2p_hmodel *) ev->data; 6076465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", 6086465ddcfSJouni Malinen mod->p2p_model, 6096465ddcfSJouni Malinen mod->p2p_model ? "host" : "firmware"); 6106465ddcfSJouni Malinen } 6116465ddcfSJouni Malinen return 0; 6126465ddcfSJouni Malinen } 6136465ddcfSJouni Malinen 614bdcd8170SKalle Valo static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) 615bdcd8170SKalle Valo { 616bdcd8170SKalle Valo struct sk_buff *skb; 617bdcd8170SKalle Valo 618bdcd8170SKalle Valo skb = ath6kl_buf_alloc(size); 619bdcd8170SKalle Valo if (!skb) 620bdcd8170SKalle Valo return NULL; 621bdcd8170SKalle Valo 622bdcd8170SKalle Valo skb_put(skb, size); 623bdcd8170SKalle Valo if (size) 624bdcd8170SKalle Valo memset(skb->data, 0, size); 625bdcd8170SKalle Valo 626bdcd8170SKalle Valo return skb; 627bdcd8170SKalle Valo } 628bdcd8170SKalle Valo 629bdcd8170SKalle Valo /* Send a "simple" wmi command -- one with no arguments */ 630bdcd8170SKalle Valo static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id) 631bdcd8170SKalle Valo { 632bdcd8170SKalle Valo struct sk_buff *skb; 633bdcd8170SKalle Valo int ret; 634bdcd8170SKalle Valo 635bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(0); 636bdcd8170SKalle Valo if (!skb) 637bdcd8170SKalle Valo return -ENOMEM; 638bdcd8170SKalle Valo 639bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG); 640bdcd8170SKalle Valo 641bdcd8170SKalle Valo return ret; 642bdcd8170SKalle Valo } 643bdcd8170SKalle Valo 644bdcd8170SKalle Valo static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) 645bdcd8170SKalle Valo { 646bdcd8170SKalle Valo struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; 647bdcd8170SKalle Valo 648bdcd8170SKalle Valo if (len < sizeof(struct wmi_ready_event_2)) 649bdcd8170SKalle Valo return -EINVAL; 650bdcd8170SKalle Valo 651bdcd8170SKalle Valo ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, 652bdcd8170SKalle Valo le32_to_cpu(ev->sw_version), 653bdcd8170SKalle Valo le32_to_cpu(ev->abi_version)); 654bdcd8170SKalle Valo 655bdcd8170SKalle Valo return 0; 656bdcd8170SKalle Valo } 657bdcd8170SKalle Valo 658e5090444SVivek Natarajan /* 659e5090444SVivek Natarajan * Mechanism to modify the roaming behavior in the firmware. The lower rssi 660e5090444SVivek Natarajan * at which the station has to roam can be passed with 661e5090444SVivek Natarajan * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level 662e5090444SVivek Natarajan * in dBm. 663e5090444SVivek Natarajan */ 664e5090444SVivek Natarajan int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) 665e5090444SVivek Natarajan { 666e5090444SVivek Natarajan struct sk_buff *skb; 667e5090444SVivek Natarajan struct roam_ctrl_cmd *cmd; 668e5090444SVivek Natarajan 669e5090444SVivek Natarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 670e5090444SVivek Natarajan if (!skb) 671e5090444SVivek Natarajan return -ENOMEM; 672e5090444SVivek Natarajan 673e5090444SVivek Natarajan cmd = (struct roam_ctrl_cmd *) skb->data; 674e5090444SVivek Natarajan 675e5090444SVivek Natarajan cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD); 676e5090444SVivek Natarajan cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi + 677e5090444SVivek Natarajan DEF_SCAN_FOR_ROAM_INTVL); 678e5090444SVivek Natarajan cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi); 679e5090444SVivek Natarajan cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; 680e5090444SVivek Natarajan cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; 681e5090444SVivek Natarajan 682e5090444SVivek Natarajan ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, NO_SYNC_WMIFLAG); 683e5090444SVivek Natarajan 684e5090444SVivek Natarajan return 0; 685e5090444SVivek Natarajan } 686e5090444SVivek Natarajan 6871261875fSJouni Malinen int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid) 6881261875fSJouni Malinen { 6891261875fSJouni Malinen struct sk_buff *skb; 6901261875fSJouni Malinen struct roam_ctrl_cmd *cmd; 6911261875fSJouni Malinen 6921261875fSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 6931261875fSJouni Malinen if (!skb) 6941261875fSJouni Malinen return -ENOMEM; 6951261875fSJouni Malinen 6961261875fSJouni Malinen cmd = (struct roam_ctrl_cmd *) skb->data; 6971261875fSJouni Malinen memset(cmd, 0, sizeof(*cmd)); 6981261875fSJouni Malinen 6991261875fSJouni Malinen memcpy(cmd->info.bssid, bssid, ETH_ALEN); 7001261875fSJouni Malinen cmd->roam_ctrl = WMI_FORCE_ROAM; 7011261875fSJouni Malinen 7021261875fSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid); 7031261875fSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, 7041261875fSJouni Malinen NO_SYNC_WMIFLAG); 7051261875fSJouni Malinen } 7061261875fSJouni Malinen 7071261875fSJouni Malinen int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode) 7081261875fSJouni Malinen { 7091261875fSJouni Malinen struct sk_buff *skb; 7101261875fSJouni Malinen struct roam_ctrl_cmd *cmd; 7111261875fSJouni Malinen 7121261875fSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 7131261875fSJouni Malinen if (!skb) 7141261875fSJouni Malinen return -ENOMEM; 7151261875fSJouni Malinen 7161261875fSJouni Malinen cmd = (struct roam_ctrl_cmd *) skb->data; 7171261875fSJouni Malinen memset(cmd, 0, sizeof(*cmd)); 7181261875fSJouni Malinen 7191261875fSJouni Malinen cmd->info.roam_mode = mode; 7201261875fSJouni Malinen cmd->roam_ctrl = WMI_SET_ROAM_MODE; 7211261875fSJouni Malinen 7221261875fSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode); 7231261875fSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, 7241261875fSJouni Malinen NO_SYNC_WMIFLAG); 7251261875fSJouni Malinen } 7261261875fSJouni Malinen 727bdcd8170SKalle Valo static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) 728bdcd8170SKalle Valo { 729bdcd8170SKalle Valo struct wmi_connect_event *ev; 730bdcd8170SKalle Valo u8 *pie, *peie; 731572e27c0SJouni Malinen struct ath6kl *ar = wmi->parent_dev; 732f5938f24SVasanthakumar Thiagarajan /* TODO: Findout vif */ 733f5938f24SVasanthakumar Thiagarajan struct ath6kl_vif *vif = ar->vif; 734bdcd8170SKalle Valo 735bdcd8170SKalle Valo if (len < sizeof(struct wmi_connect_event)) 736bdcd8170SKalle Valo return -EINVAL; 737bdcd8170SKalle Valo 738bdcd8170SKalle Valo ev = (struct wmi_connect_event *) datap; 739bdcd8170SKalle Valo 740f5938f24SVasanthakumar Thiagarajan if (vif->nw_type == AP_NETWORK) { 741572e27c0SJouni Malinen /* AP mode start/STA connected event */ 742572e27c0SJouni Malinen struct net_device *dev = ar->net_dev; 743572e27c0SJouni Malinen if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) { 744572e27c0SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM " 745572e27c0SJouni Malinen "(AP started)\n", 746572e27c0SJouni Malinen __func__, le16_to_cpu(ev->u.ap_bss.ch), 747572e27c0SJouni Malinen ev->u.ap_bss.bssid); 748572e27c0SJouni Malinen ath6kl_connect_ap_mode_bss( 749572e27c0SJouni Malinen ar, le16_to_cpu(ev->u.ap_bss.ch)); 750572e27c0SJouni Malinen } else { 751572e27c0SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM " 752572e27c0SJouni Malinen "auth=%u keymgmt=%u cipher=%u apsd_info=%u " 753572e27c0SJouni Malinen "(STA connected)\n", 754572e27c0SJouni Malinen __func__, ev->u.ap_sta.aid, 755572e27c0SJouni Malinen ev->u.ap_sta.mac_addr, 756572e27c0SJouni Malinen ev->u.ap_sta.auth, 757572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 758572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 759572e27c0SJouni Malinen ev->u.ap_sta.apsd_info); 760572e27c0SJouni Malinen ath6kl_connect_ap_mode_sta( 761572e27c0SJouni Malinen ar, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, 762572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 763572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 764572e27c0SJouni Malinen ev->u.ap_sta.auth, ev->assoc_req_len, 765572e27c0SJouni Malinen ev->assoc_info + ev->beacon_ie_len); 766572e27c0SJouni Malinen } 767572e27c0SJouni Malinen return 0; 768572e27c0SJouni Malinen } 769572e27c0SJouni Malinen 770572e27c0SJouni Malinen /* STA/IBSS mode connection event */ 771572e27c0SJouni Malinen 772b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 773b9b6ee60SKalle Valo "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n", 774b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid, 775b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.listen_intvl), 776b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.beacon_intvl), 777b9b6ee60SKalle Valo le32_to_cpu(ev->u.sta.nw_type)); 778bdcd8170SKalle Valo 779bdcd8170SKalle Valo /* Start of assoc rsp IEs */ 780bdcd8170SKalle Valo pie = ev->assoc_info + ev->beacon_ie_len + 781bdcd8170SKalle Valo ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ 782bdcd8170SKalle Valo 783bdcd8170SKalle Valo /* End of assoc rsp IEs */ 784bdcd8170SKalle Valo peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + 785bdcd8170SKalle Valo ev->assoc_resp_len; 786bdcd8170SKalle Valo 787bdcd8170SKalle Valo while (pie < peie) { 788bdcd8170SKalle Valo switch (*pie) { 789bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 790bdcd8170SKalle Valo if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && 791bdcd8170SKalle Valo pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { 792bdcd8170SKalle Valo /* WMM OUT (00:50:F2) */ 793bdcd8170SKalle Valo if (pie[1] > 5 794bdcd8170SKalle Valo && pie[6] == WMM_PARAM_OUI_SUBTYPE) 795bdcd8170SKalle Valo wmi->is_wmm_enabled = true; 796bdcd8170SKalle Valo } 797bdcd8170SKalle Valo break; 798bdcd8170SKalle Valo } 799bdcd8170SKalle Valo 800bdcd8170SKalle Valo if (wmi->is_wmm_enabled) 801bdcd8170SKalle Valo break; 802bdcd8170SKalle Valo 803bdcd8170SKalle Valo pie += pie[1] + 2; 804bdcd8170SKalle Valo } 805bdcd8170SKalle Valo 806572e27c0SJouni Malinen ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->u.sta.ch), 807572e27c0SJouni Malinen ev->u.sta.bssid, 808572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.listen_intvl), 809572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.beacon_intvl), 810572e27c0SJouni Malinen le32_to_cpu(ev->u.sta.nw_type), 811bdcd8170SKalle Valo ev->beacon_ie_len, ev->assoc_req_len, 812bdcd8170SKalle Valo ev->assoc_resp_len, ev->assoc_info); 813bdcd8170SKalle Valo 814bdcd8170SKalle Valo return 0; 815bdcd8170SKalle Valo } 816bdcd8170SKalle Valo 81706033760SVivek Natarajan static struct country_code_to_enum_rd * 81806033760SVivek Natarajan ath6kl_regd_find_country(u16 countryCode) 81906033760SVivek Natarajan { 82006033760SVivek Natarajan int i; 82106033760SVivek Natarajan 82206033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 82306033760SVivek Natarajan if (allCountries[i].countryCode == countryCode) 82406033760SVivek Natarajan return &allCountries[i]; 82506033760SVivek Natarajan } 82606033760SVivek Natarajan 82706033760SVivek Natarajan return NULL; 82806033760SVivek Natarajan } 82906033760SVivek Natarajan 83006033760SVivek Natarajan static struct reg_dmn_pair_mapping * 83106033760SVivek Natarajan ath6kl_get_regpair(u16 regdmn) 83206033760SVivek Natarajan { 83306033760SVivek Natarajan int i; 83406033760SVivek Natarajan 83506033760SVivek Natarajan if (regdmn == NO_ENUMRD) 83606033760SVivek Natarajan return NULL; 83706033760SVivek Natarajan 83806033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) { 83906033760SVivek Natarajan if (regDomainPairs[i].regDmnEnum == regdmn) 84006033760SVivek Natarajan return ®DomainPairs[i]; 84106033760SVivek Natarajan } 84206033760SVivek Natarajan 84306033760SVivek Natarajan return NULL; 84406033760SVivek Natarajan } 84506033760SVivek Natarajan 84606033760SVivek Natarajan static struct country_code_to_enum_rd * 84706033760SVivek Natarajan ath6kl_regd_find_country_by_rd(u16 regdmn) 84806033760SVivek Natarajan { 84906033760SVivek Natarajan int i; 85006033760SVivek Natarajan 85106033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 85206033760SVivek Natarajan if (allCountries[i].regDmnEnum == regdmn) 85306033760SVivek Natarajan return &allCountries[i]; 85406033760SVivek Natarajan } 85506033760SVivek Natarajan 85606033760SVivek Natarajan return NULL; 85706033760SVivek Natarajan } 85806033760SVivek Natarajan 85906033760SVivek Natarajan static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) 86006033760SVivek Natarajan { 86106033760SVivek Natarajan 86206033760SVivek Natarajan struct ath6kl_wmi_regdomain *ev; 86306033760SVivek Natarajan struct country_code_to_enum_rd *country = NULL; 86406033760SVivek Natarajan struct reg_dmn_pair_mapping *regpair = NULL; 86506033760SVivek Natarajan char alpha2[2]; 86606033760SVivek Natarajan u32 reg_code; 86706033760SVivek Natarajan 86806033760SVivek Natarajan ev = (struct ath6kl_wmi_regdomain *) datap; 86906033760SVivek Natarajan reg_code = le32_to_cpu(ev->reg_code); 87006033760SVivek Natarajan 87106033760SVivek Natarajan if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) 87206033760SVivek Natarajan country = ath6kl_regd_find_country((u16) reg_code); 87306033760SVivek Natarajan else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) { 87406033760SVivek Natarajan 87506033760SVivek Natarajan regpair = ath6kl_get_regpair((u16) reg_code); 87606033760SVivek Natarajan country = ath6kl_regd_find_country_by_rd((u16) reg_code); 877b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n", 87806033760SVivek Natarajan regpair->regDmnEnum); 87906033760SVivek Natarajan } 88006033760SVivek Natarajan 88106033760SVivek Natarajan if (country) { 88206033760SVivek Natarajan alpha2[0] = country->isoName[0]; 88306033760SVivek Natarajan alpha2[1] = country->isoName[1]; 88406033760SVivek Natarajan 885be98e3a4SVasanthakumar Thiagarajan regulatory_hint(wmi->parent_dev->wiphy, alpha2); 88606033760SVivek Natarajan 887b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n", 88806033760SVivek Natarajan alpha2[0], alpha2[1]); 88906033760SVivek Natarajan } 89006033760SVivek Natarajan } 89106033760SVivek Natarajan 892bdcd8170SKalle Valo static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) 893bdcd8170SKalle Valo { 894bdcd8170SKalle Valo struct wmi_disconnect_event *ev; 895bdcd8170SKalle Valo wmi->traffic_class = 100; 896bdcd8170SKalle Valo 897bdcd8170SKalle Valo if (len < sizeof(struct wmi_disconnect_event)) 898bdcd8170SKalle Valo return -EINVAL; 899bdcd8170SKalle Valo 900bdcd8170SKalle Valo ev = (struct wmi_disconnect_event *) datap; 901bdcd8170SKalle Valo 902b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 903b9b6ee60SKalle Valo "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n", 904b9b6ee60SKalle Valo le16_to_cpu(ev->proto_reason_status), ev->bssid, 905b9b6ee60SKalle Valo ev->disconn_reason, ev->assoc_resp_len); 906b9b6ee60SKalle Valo 907bdcd8170SKalle Valo wmi->is_wmm_enabled = false; 908bdcd8170SKalle Valo 909bdcd8170SKalle Valo ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason, 910bdcd8170SKalle Valo ev->bssid, ev->assoc_resp_len, ev->assoc_info, 911bdcd8170SKalle Valo le16_to_cpu(ev->proto_reason_status)); 912bdcd8170SKalle Valo 913bdcd8170SKalle Valo return 0; 914bdcd8170SKalle Valo } 915bdcd8170SKalle Valo 916bdcd8170SKalle Valo static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) 917bdcd8170SKalle Valo { 918bdcd8170SKalle Valo struct wmi_peer_node_event *ev; 919bdcd8170SKalle Valo 920bdcd8170SKalle Valo if (len < sizeof(struct wmi_peer_node_event)) 921bdcd8170SKalle Valo return -EINVAL; 922bdcd8170SKalle Valo 923bdcd8170SKalle Valo ev = (struct wmi_peer_node_event *) datap; 924bdcd8170SKalle Valo 925bdcd8170SKalle Valo if (ev->event_code == PEER_NODE_JOIN_EVENT) 926bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", 927bdcd8170SKalle Valo ev->peer_mac_addr); 928bdcd8170SKalle Valo else if (ev->event_code == PEER_NODE_LEAVE_EVENT) 929bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", 930bdcd8170SKalle Valo ev->peer_mac_addr); 931bdcd8170SKalle Valo 932bdcd8170SKalle Valo return 0; 933bdcd8170SKalle Valo } 934bdcd8170SKalle Valo 935bdcd8170SKalle Valo static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len) 936bdcd8170SKalle Valo { 937bdcd8170SKalle Valo struct wmi_tkip_micerr_event *ev; 938bdcd8170SKalle Valo 939bdcd8170SKalle Valo if (len < sizeof(struct wmi_tkip_micerr_event)) 940bdcd8170SKalle Valo return -EINVAL; 941bdcd8170SKalle Valo 942bdcd8170SKalle Valo ev = (struct wmi_tkip_micerr_event *) datap; 943bdcd8170SKalle Valo 944bdcd8170SKalle Valo ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast); 945bdcd8170SKalle Valo 946bdcd8170SKalle Valo return 0; 947bdcd8170SKalle Valo } 948bdcd8170SKalle Valo 949bdcd8170SKalle Valo static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) 950bdcd8170SKalle Valo { 95182e14f56SJouni Malinen struct wmi_bss_info_hdr2 *bih; 9521aaa8c74SJouni Malinen u8 *buf; 9531aaa8c74SJouni Malinen struct ieee80211_channel *channel; 9541aaa8c74SJouni Malinen struct ath6kl *ar = wmi->parent_dev; 9551aaa8c74SJouni Malinen struct ieee80211_mgmt *mgmt; 9561aaa8c74SJouni Malinen struct cfg80211_bss *bss; 95759c98449SVasanthakumar Thiagarajan /*TODO: Findout vif properly */ 95859c98449SVasanthakumar Thiagarajan struct ath6kl_vif *vif = ar->vif; 959bdcd8170SKalle Valo 96082e14f56SJouni Malinen if (len <= sizeof(struct wmi_bss_info_hdr2)) 961bdcd8170SKalle Valo return -EINVAL; 962bdcd8170SKalle Valo 96382e14f56SJouni Malinen bih = (struct wmi_bss_info_hdr2 *) datap; 96482e14f56SJouni Malinen buf = datap + sizeof(struct wmi_bss_info_hdr2); 96582e14f56SJouni Malinen len -= sizeof(struct wmi_bss_info_hdr2); 966bdcd8170SKalle Valo 967bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 9681aaa8c74SJouni Malinen "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" " 9691aaa8c74SJouni Malinen "frame_type=%d\n", 97082e14f56SJouni Malinen bih->ch, bih->snr, bih->snr - 95, bih->bssid, 9711aaa8c74SJouni Malinen bih->frame_type); 972bdcd8170SKalle Valo 9731aaa8c74SJouni Malinen if (bih->frame_type != BEACON_FTYPE && 9741aaa8c74SJouni Malinen bih->frame_type != PROBERESP_FTYPE) 9751aaa8c74SJouni Malinen return 0; /* Only update BSS table for now */ 9761aaa8c74SJouni Malinen 977551185caSJouni Malinen if (bih->frame_type == BEACON_FTYPE && 97859c98449SVasanthakumar Thiagarajan test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) { 97959c98449SVasanthakumar Thiagarajan clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); 980551185caSJouni Malinen ath6kl_wmi_bssfilter_cmd(ar->wmi, NONE_BSS_FILTER, 0); 981551185caSJouni Malinen } 982551185caSJouni Malinen 983be98e3a4SVasanthakumar Thiagarajan channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch)); 9841aaa8c74SJouni Malinen if (channel == NULL) 9851aaa8c74SJouni Malinen return -EINVAL; 9861aaa8c74SJouni Malinen 9871aaa8c74SJouni Malinen if (len < 8 + 2 + 2) 9881aaa8c74SJouni Malinen return -EINVAL; 989bdcd8170SKalle Valo 99059c98449SVasanthakumar Thiagarajan if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &vif->flags) 9918c8b65e3SVasanthakumar Thiagarajan && memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) { 99232c10874SJouni Malinen const u8 *tim; 99332c10874SJouni Malinen tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2, 99432c10874SJouni Malinen len - 8 - 2 - 2); 99532c10874SJouni Malinen if (tim && tim[1] >= 2) { 996*cf5333d7SVasanthakumar Thiagarajan vif->assoc_bss_dtim_period = tim[3]; 99759c98449SVasanthakumar Thiagarajan set_bit(DTIM_PERIOD_AVAIL, &vif->flags); 99832c10874SJouni Malinen } 99932c10874SJouni Malinen } 100032c10874SJouni Malinen 1001bdcd8170SKalle Valo /* 10021aaa8c74SJouni Malinen * In theory, use of cfg80211_inform_bss() would be more natural here 10031aaa8c74SJouni Malinen * since we do not have the full frame. However, at least for now, 10041aaa8c74SJouni Malinen * cfg80211 can only distinguish Beacon and Probe Response frames from 10051aaa8c74SJouni Malinen * each other when using cfg80211_inform_bss_frame(), so let's build a 10061aaa8c74SJouni Malinen * fake IEEE 802.11 header to be able to take benefit of this. 1007bdcd8170SKalle Valo */ 10081aaa8c74SJouni Malinen mgmt = kmalloc(24 + len, GFP_ATOMIC); 10091aaa8c74SJouni Malinen if (mgmt == NULL) 10101aaa8c74SJouni Malinen return -EINVAL; 10111aaa8c74SJouni Malinen 10121aaa8c74SJouni Malinen if (bih->frame_type == BEACON_FTYPE) { 10131aaa8c74SJouni Malinen mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 10141aaa8c74SJouni Malinen IEEE80211_STYPE_BEACON); 10151aaa8c74SJouni Malinen memset(mgmt->da, 0xff, ETH_ALEN); 10161aaa8c74SJouni Malinen } else { 10171aaa8c74SJouni Malinen struct net_device *dev = ar->net_dev; 10181aaa8c74SJouni Malinen 10191aaa8c74SJouni Malinen mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 10201aaa8c74SJouni Malinen IEEE80211_STYPE_PROBE_RESP); 10211aaa8c74SJouni Malinen memcpy(mgmt->da, dev->dev_addr, ETH_ALEN); 1022bdcd8170SKalle Valo } 10231aaa8c74SJouni Malinen mgmt->duration = cpu_to_le16(0); 10241aaa8c74SJouni Malinen memcpy(mgmt->sa, bih->bssid, ETH_ALEN); 10251aaa8c74SJouni Malinen memcpy(mgmt->bssid, bih->bssid, ETH_ALEN); 10261aaa8c74SJouni Malinen mgmt->seq_ctrl = cpu_to_le16(0); 1027bdcd8170SKalle Valo 10281aaa8c74SJouni Malinen memcpy(&mgmt->u.beacon, buf, len); 1029bdcd8170SKalle Valo 1030be98e3a4SVasanthakumar Thiagarajan bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt, 103182e14f56SJouni Malinen 24 + len, (bih->snr - 95) * 100, 103282e14f56SJouni Malinen GFP_ATOMIC); 10331aaa8c74SJouni Malinen kfree(mgmt); 10341aaa8c74SJouni Malinen if (bss == NULL) 1035bdcd8170SKalle Valo return -ENOMEM; 10361aaa8c74SJouni Malinen cfg80211_put_bss(bss); 1037bdcd8170SKalle Valo 1038bdcd8170SKalle Valo return 0; 1039bdcd8170SKalle Valo } 1040bdcd8170SKalle Valo 1041bdcd8170SKalle Valo /* Inactivity timeout of a fatpipe(pstream) at the target */ 1042bdcd8170SKalle Valo static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, 1043bdcd8170SKalle Valo int len) 1044bdcd8170SKalle Valo { 1045bdcd8170SKalle Valo struct wmi_pstream_timeout_event *ev; 1046bdcd8170SKalle Valo 1047bdcd8170SKalle Valo if (len < sizeof(struct wmi_pstream_timeout_event)) 1048bdcd8170SKalle Valo return -EINVAL; 1049bdcd8170SKalle Valo 1050bdcd8170SKalle Valo ev = (struct wmi_pstream_timeout_event *) datap; 1051bdcd8170SKalle Valo 1052bdcd8170SKalle Valo /* 1053bdcd8170SKalle Valo * When the pstream (fat pipe == AC) timesout, it means there were 1054bdcd8170SKalle Valo * no thinStreams within this pstream & it got implicitly created 1055bdcd8170SKalle Valo * due to data flow on this AC. We start the inactivity timer only 1056bdcd8170SKalle Valo * for implicitly created pstream. Just reset the host state. 1057bdcd8170SKalle Valo */ 1058bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1059bdcd8170SKalle Valo wmi->stream_exist_for_ac[ev->traffic_class] = 0; 1060bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); 1061bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1062bdcd8170SKalle Valo 1063bdcd8170SKalle Valo /* Indicate inactivity to driver layer for this fatpipe (pstream) */ 1064bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); 1065bdcd8170SKalle Valo 1066bdcd8170SKalle Valo return 0; 1067bdcd8170SKalle Valo } 1068bdcd8170SKalle Valo 1069bdcd8170SKalle Valo static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) 1070bdcd8170SKalle Valo { 1071bdcd8170SKalle Valo struct wmi_bit_rate_reply *reply; 1072bdcd8170SKalle Valo s32 rate; 1073bdcd8170SKalle Valo u32 sgi, index; 1074bdcd8170SKalle Valo 1075bdcd8170SKalle Valo if (len < sizeof(struct wmi_bit_rate_reply)) 1076bdcd8170SKalle Valo return -EINVAL; 1077bdcd8170SKalle Valo 1078bdcd8170SKalle Valo reply = (struct wmi_bit_rate_reply *) datap; 1079bdcd8170SKalle Valo 1080bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); 1081bdcd8170SKalle Valo 1082bdcd8170SKalle Valo if (reply->rate_index == (s8) RATE_AUTO) { 1083bdcd8170SKalle Valo rate = RATE_AUTO; 1084bdcd8170SKalle Valo } else { 1085bdcd8170SKalle Valo index = reply->rate_index & 0x7f; 1086bdcd8170SKalle Valo sgi = (reply->rate_index & 0x80) ? 1 : 0; 1087bdcd8170SKalle Valo rate = wmi_rate_tbl[index][sgi]; 1088bdcd8170SKalle Valo } 1089bdcd8170SKalle Valo 1090bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1091bdcd8170SKalle Valo 1092bdcd8170SKalle Valo return 0; 1093bdcd8170SKalle Valo } 1094bdcd8170SKalle Valo 1095003353b0SKalle Valo static int ath6kl_wmi_tcmd_test_report_rx(struct wmi *wmi, u8 *datap, int len) 1096003353b0SKalle Valo { 1097003353b0SKalle Valo ath6kl_tm_rx_report_event(wmi->parent_dev, datap, len); 1098003353b0SKalle Valo 1099003353b0SKalle Valo return 0; 1100003353b0SKalle Valo } 1101003353b0SKalle Valo 1102bdcd8170SKalle Valo static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) 1103bdcd8170SKalle Valo { 1104bdcd8170SKalle Valo if (len < sizeof(struct wmi_fix_rates_reply)) 1105bdcd8170SKalle Valo return -EINVAL; 1106bdcd8170SKalle Valo 1107bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1108bdcd8170SKalle Valo 1109bdcd8170SKalle Valo return 0; 1110bdcd8170SKalle Valo } 1111bdcd8170SKalle Valo 1112bdcd8170SKalle Valo static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) 1113bdcd8170SKalle Valo { 1114bdcd8170SKalle Valo if (len < sizeof(struct wmi_channel_list_reply)) 1115bdcd8170SKalle Valo return -EINVAL; 1116bdcd8170SKalle Valo 1117bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1118bdcd8170SKalle Valo 1119bdcd8170SKalle Valo return 0; 1120bdcd8170SKalle Valo } 1121bdcd8170SKalle Valo 1122bdcd8170SKalle Valo static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) 1123bdcd8170SKalle Valo { 1124bdcd8170SKalle Valo struct wmi_tx_pwr_reply *reply; 1125bdcd8170SKalle Valo 1126bdcd8170SKalle Valo if (len < sizeof(struct wmi_tx_pwr_reply)) 1127bdcd8170SKalle Valo return -EINVAL; 1128bdcd8170SKalle Valo 1129bdcd8170SKalle Valo reply = (struct wmi_tx_pwr_reply *) datap; 1130bdcd8170SKalle Valo ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); 1131bdcd8170SKalle Valo 1132bdcd8170SKalle Valo return 0; 1133bdcd8170SKalle Valo } 1134bdcd8170SKalle Valo 1135bdcd8170SKalle Valo static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) 1136bdcd8170SKalle Valo { 1137bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_keepalive_cmd)) 1138bdcd8170SKalle Valo return -EINVAL; 1139bdcd8170SKalle Valo 1140bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1141bdcd8170SKalle Valo 1142bdcd8170SKalle Valo return 0; 1143bdcd8170SKalle Valo } 1144bdcd8170SKalle Valo 1145bdcd8170SKalle Valo static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len) 1146bdcd8170SKalle Valo { 1147bdcd8170SKalle Valo struct wmi_scan_complete_event *ev; 1148bdcd8170SKalle Valo 1149bdcd8170SKalle Valo ev = (struct wmi_scan_complete_event *) datap; 1150bdcd8170SKalle Valo 1151bdcd8170SKalle Valo ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status)); 1152bdcd8170SKalle Valo wmi->is_probe_ssid = false; 1153bdcd8170SKalle Valo 1154bdcd8170SKalle Valo return 0; 1155bdcd8170SKalle Valo } 1156bdcd8170SKalle Valo 115786512136SJouni Malinen static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap, 115886512136SJouni Malinen int len) 115986512136SJouni Malinen { 116086512136SJouni Malinen struct wmi_neighbor_report_event *ev; 116186512136SJouni Malinen u8 i; 116286512136SJouni Malinen 116386512136SJouni Malinen if (len < sizeof(*ev)) 116486512136SJouni Malinen return -EINVAL; 116586512136SJouni Malinen ev = (struct wmi_neighbor_report_event *) datap; 116686512136SJouni Malinen if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info) 116786512136SJouni Malinen > len) { 116886512136SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "truncated neighbor event " 116986512136SJouni Malinen "(num=%d len=%d)\n", ev->num_neighbors, len); 117086512136SJouni Malinen return -EINVAL; 117186512136SJouni Malinen } 117286512136SJouni Malinen for (i = 0; i < ev->num_neighbors; i++) { 117386512136SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n", 117486512136SJouni Malinen i + 1, ev->num_neighbors, ev->neighbor[i].bssid, 117586512136SJouni Malinen ev->neighbor[i].bss_flags); 117686512136SJouni Malinen cfg80211_pmksa_candidate_notify(wmi->parent_dev->net_dev, i, 117786512136SJouni Malinen ev->neighbor[i].bssid, 117886512136SJouni Malinen !!(ev->neighbor[i].bss_flags & 117986512136SJouni Malinen WMI_PREAUTH_CAPABLE_BSS), 118086512136SJouni Malinen GFP_ATOMIC); 118186512136SJouni Malinen } 118286512136SJouni Malinen 118386512136SJouni Malinen return 0; 118486512136SJouni Malinen } 118586512136SJouni Malinen 1186bdcd8170SKalle Valo /* 1187bdcd8170SKalle Valo * Target is reporting a programming error. This is for 1188bdcd8170SKalle Valo * developer aid only. Target only checks a few common violations 1189bdcd8170SKalle Valo * and it is responsibility of host to do all error checking. 1190bdcd8170SKalle Valo * Behavior of target after wmi error event is undefined. 1191bdcd8170SKalle Valo * A reset is recommended. 1192bdcd8170SKalle Valo */ 1193bdcd8170SKalle Valo static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) 1194bdcd8170SKalle Valo { 1195bdcd8170SKalle Valo const char *type = "unknown error"; 1196bdcd8170SKalle Valo struct wmi_cmd_error_event *ev; 1197bdcd8170SKalle Valo ev = (struct wmi_cmd_error_event *) datap; 1198bdcd8170SKalle Valo 1199bdcd8170SKalle Valo switch (ev->err_code) { 1200bdcd8170SKalle Valo case INVALID_PARAM: 1201bdcd8170SKalle Valo type = "invalid parameter"; 1202bdcd8170SKalle Valo break; 1203bdcd8170SKalle Valo case ILLEGAL_STATE: 1204bdcd8170SKalle Valo type = "invalid state"; 1205bdcd8170SKalle Valo break; 1206bdcd8170SKalle Valo case INTERNAL_ERROR: 1207bdcd8170SKalle Valo type = "internal error"; 1208bdcd8170SKalle Valo break; 1209bdcd8170SKalle Valo } 1210bdcd8170SKalle Valo 1211bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", 1212bdcd8170SKalle Valo ev->cmd_id, type); 1213bdcd8170SKalle Valo 1214bdcd8170SKalle Valo return 0; 1215bdcd8170SKalle Valo } 1216bdcd8170SKalle Valo 1217bdcd8170SKalle Valo static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len) 1218bdcd8170SKalle Valo { 1219bdcd8170SKalle Valo ath6kl_tgt_stats_event(wmi->parent_dev, datap, len); 1220bdcd8170SKalle Valo 1221bdcd8170SKalle Valo return 0; 1222bdcd8170SKalle Valo } 1223bdcd8170SKalle Valo 1224bdcd8170SKalle Valo static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, 1225bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1226bdcd8170SKalle Valo u32 size) 1227bdcd8170SKalle Valo { 1228bdcd8170SKalle Valo u32 index; 1229bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; 1230bdcd8170SKalle Valo 1231bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1232bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1233bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[index]) { 1234bdcd8170SKalle Valo threshold = (u8) sq_thresh->upper_threshold[index]; 1235bdcd8170SKalle Valo break; 1236bdcd8170SKalle Valo } 1237bdcd8170SKalle Valo } 1238bdcd8170SKalle Valo 1239bdcd8170SKalle Valo return threshold; 1240bdcd8170SKalle Valo } 1241bdcd8170SKalle Valo 1242bdcd8170SKalle Valo static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, 1243bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1244bdcd8170SKalle Valo u32 size) 1245bdcd8170SKalle Valo { 1246bdcd8170SKalle Valo u32 index; 1247bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; 1248bdcd8170SKalle Valo 1249bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1250bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1251bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[index]) { 1252bdcd8170SKalle Valo threshold = (u8) sq_thresh->lower_threshold[index]; 1253bdcd8170SKalle Valo break; 1254bdcd8170SKalle Valo } 1255bdcd8170SKalle Valo } 1256bdcd8170SKalle Valo 1257bdcd8170SKalle Valo return threshold; 1258bdcd8170SKalle Valo } 1259bdcd8170SKalle Valo 1260bdcd8170SKalle Valo static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, 1261bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *rssi_cmd) 1262bdcd8170SKalle Valo { 1263bdcd8170SKalle Valo struct sk_buff *skb; 1264bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *cmd; 1265bdcd8170SKalle Valo 1266bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1267bdcd8170SKalle Valo if (!skb) 1268bdcd8170SKalle Valo return -ENOMEM; 1269bdcd8170SKalle Valo 1270bdcd8170SKalle Valo cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; 1271bdcd8170SKalle Valo memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); 1272bdcd8170SKalle Valo 1273bdcd8170SKalle Valo return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, 1274bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1275bdcd8170SKalle Valo } 1276bdcd8170SKalle Valo 1277bdcd8170SKalle Valo static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, 1278bdcd8170SKalle Valo int len) 1279bdcd8170SKalle Valo { 1280bdcd8170SKalle Valo struct wmi_rssi_threshold_event *reply; 1281bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd cmd; 1282bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1283bdcd8170SKalle Valo enum wmi_rssi_threshold_val new_threshold; 1284bdcd8170SKalle Valo u8 upper_rssi_threshold, lower_rssi_threshold; 1285bdcd8170SKalle Valo s16 rssi; 1286bdcd8170SKalle Valo int ret; 1287bdcd8170SKalle Valo 1288bdcd8170SKalle Valo if (len < sizeof(struct wmi_rssi_threshold_event)) 1289bdcd8170SKalle Valo return -EINVAL; 1290bdcd8170SKalle Valo 1291bdcd8170SKalle Valo reply = (struct wmi_rssi_threshold_event *) datap; 1292bdcd8170SKalle Valo new_threshold = (enum wmi_rssi_threshold_val) reply->range; 1293bdcd8170SKalle Valo rssi = a_sle16_to_cpu(reply->rssi); 1294bdcd8170SKalle Valo 1295bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; 1296bdcd8170SKalle Valo 1297bdcd8170SKalle Valo /* 1298bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1299bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1300bdcd8170SKalle Valo * quality reported by the target 1301bdcd8170SKalle Valo */ 1302bdcd8170SKalle Valo if (new_threshold) { 1303bdcd8170SKalle Valo /* Upper threshold breached */ 1304bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[0]) { 1305bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1306bdcd8170SKalle Valo "spurious upper rssi threshold event: %d\n", 1307bdcd8170SKalle Valo rssi); 1308bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[1]) && 1309bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[0])) { 1310bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; 1311bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[2]) && 1312bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[1])) { 1313bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; 1314bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[3]) && 1315bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[2])) { 1316bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; 1317bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[4]) && 1318bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[3])) { 1319bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; 1320bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[5]) && 1321bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[4])) { 1322bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; 1323bdcd8170SKalle Valo } else if (rssi >= sq_thresh->upper_threshold[5]) { 1324bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; 1325bdcd8170SKalle Valo } 1326bdcd8170SKalle Valo } else { 1327bdcd8170SKalle Valo /* Lower threshold breached */ 1328bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[0]) { 1329bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1330bdcd8170SKalle Valo "spurious lower rssi threshold event: %d %d\n", 1331bdcd8170SKalle Valo rssi, sq_thresh->lower_threshold[0]); 1332bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[1]) && 1333bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[0])) { 1334bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_BELOW; 1335bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[2]) && 1336bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[1])) { 1337bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_BELOW; 1338bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[3]) && 1339bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[2])) { 1340bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_BELOW; 1341bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[4]) && 1342bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[3])) { 1343bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_BELOW; 1344bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[5]) && 1345bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[4])) { 1346bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_BELOW; 1347bdcd8170SKalle Valo } else if (rssi <= sq_thresh->lower_threshold[5]) { 1348bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_BELOW; 1349bdcd8170SKalle Valo } 1350bdcd8170SKalle Valo } 1351bdcd8170SKalle Valo 1352bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1353bdcd8170SKalle Valo lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, 1354bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1355bdcd8170SKalle Valo upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, 1356bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1357bdcd8170SKalle Valo 1358bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1359bdcd8170SKalle Valo cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); 1360bdcd8170SKalle Valo cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); 1361bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1362bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1363bdcd8170SKalle Valo 1364bdcd8170SKalle Valo ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); 1365bdcd8170SKalle Valo if (ret) { 1366bdcd8170SKalle Valo ath6kl_err("unable to configure rssi thresholds\n"); 1367bdcd8170SKalle Valo return -EIO; 1368bdcd8170SKalle Valo } 1369bdcd8170SKalle Valo 1370bdcd8170SKalle Valo return 0; 1371bdcd8170SKalle Valo } 1372bdcd8170SKalle Valo 1373bdcd8170SKalle Valo static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) 1374bdcd8170SKalle Valo { 1375bdcd8170SKalle Valo struct wmi_cac_event *reply; 1376bdcd8170SKalle Valo struct ieee80211_tspec_ie *ts; 1377bdcd8170SKalle Valo u16 active_tsids, tsinfo; 1378bdcd8170SKalle Valo u8 tsid, index; 1379bdcd8170SKalle Valo u8 ts_id; 1380bdcd8170SKalle Valo 1381bdcd8170SKalle Valo if (len < sizeof(struct wmi_cac_event)) 1382bdcd8170SKalle Valo return -EINVAL; 1383bdcd8170SKalle Valo 1384bdcd8170SKalle Valo reply = (struct wmi_cac_event *) datap; 1385bdcd8170SKalle Valo 1386bdcd8170SKalle Valo if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && 1387bdcd8170SKalle Valo (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { 1388bdcd8170SKalle Valo 1389bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1390bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1391bdcd8170SKalle Valo tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1392bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK; 1393bdcd8170SKalle Valo 1394bdcd8170SKalle Valo ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid); 1395bdcd8170SKalle Valo } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { 1396bdcd8170SKalle Valo /* 1397bdcd8170SKalle Valo * Following assumes that there is only one outstanding 1398bdcd8170SKalle Valo * ADDTS request when this event is received 1399bdcd8170SKalle Valo */ 1400bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1401bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1402bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1403bdcd8170SKalle Valo 1404bdcd8170SKalle Valo for (index = 0; index < sizeof(active_tsids) * 8; index++) { 1405bdcd8170SKalle Valo if ((active_tsids >> index) & 1) 1406bdcd8170SKalle Valo break; 1407bdcd8170SKalle Valo } 1408bdcd8170SKalle Valo if (index < (sizeof(active_tsids) * 8)) 1409bdcd8170SKalle Valo ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index); 1410bdcd8170SKalle Valo } 1411bdcd8170SKalle Valo 1412bdcd8170SKalle Valo /* 1413bdcd8170SKalle Valo * Clear active tsids and Add missing handling 1414bdcd8170SKalle Valo * for delete qos stream from AP 1415bdcd8170SKalle Valo */ 1416bdcd8170SKalle Valo else if (reply->cac_indication == CAC_INDICATION_DELETE) { 1417bdcd8170SKalle Valo 1418bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1419bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1420bdcd8170SKalle Valo ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1421bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK); 1422bdcd8170SKalle Valo 1423bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1424bdcd8170SKalle Valo wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); 1425bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1426bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1427bdcd8170SKalle Valo 1428bdcd8170SKalle Valo /* Indicate stream inactivity to driver layer only if all tsids 1429bdcd8170SKalle Valo * within this AC are deleted. 1430bdcd8170SKalle Valo */ 1431bdcd8170SKalle Valo if (!active_tsids) { 1432bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, 1433bdcd8170SKalle Valo false); 1434bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << reply->ac); 1435bdcd8170SKalle Valo } 1436bdcd8170SKalle Valo } 1437bdcd8170SKalle Valo 1438bdcd8170SKalle Valo return 0; 1439bdcd8170SKalle Valo } 1440bdcd8170SKalle Valo 1441bdcd8170SKalle Valo static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, 1442bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *snr_cmd) 1443bdcd8170SKalle Valo { 1444bdcd8170SKalle Valo struct sk_buff *skb; 1445bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *cmd; 1446bdcd8170SKalle Valo 1447bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1448bdcd8170SKalle Valo if (!skb) 1449bdcd8170SKalle Valo return -ENOMEM; 1450bdcd8170SKalle Valo 1451bdcd8170SKalle Valo cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; 1452bdcd8170SKalle Valo memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); 1453bdcd8170SKalle Valo 1454bdcd8170SKalle Valo return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, 1455bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1456bdcd8170SKalle Valo } 1457bdcd8170SKalle Valo 1458bdcd8170SKalle Valo static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, 1459bdcd8170SKalle Valo int len) 1460bdcd8170SKalle Valo { 1461bdcd8170SKalle Valo struct wmi_snr_threshold_event *reply; 1462bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1463bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd cmd; 1464bdcd8170SKalle Valo enum wmi_snr_threshold_val new_threshold; 1465bdcd8170SKalle Valo u8 upper_snr_threshold, lower_snr_threshold; 1466bdcd8170SKalle Valo s16 snr; 1467bdcd8170SKalle Valo int ret; 1468bdcd8170SKalle Valo 1469bdcd8170SKalle Valo if (len < sizeof(struct wmi_snr_threshold_event)) 1470bdcd8170SKalle Valo return -EINVAL; 1471bdcd8170SKalle Valo 1472bdcd8170SKalle Valo reply = (struct wmi_snr_threshold_event *) datap; 1473bdcd8170SKalle Valo 1474bdcd8170SKalle Valo new_threshold = (enum wmi_snr_threshold_val) reply->range; 1475bdcd8170SKalle Valo snr = reply->snr; 1476bdcd8170SKalle Valo 1477bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; 1478bdcd8170SKalle Valo 1479bdcd8170SKalle Valo /* 1480bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1481bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1482bdcd8170SKalle Valo * quality reported by the target. 1483bdcd8170SKalle Valo */ 1484bdcd8170SKalle Valo if (new_threshold) { 1485bdcd8170SKalle Valo /* Upper threshold breached */ 1486bdcd8170SKalle Valo if (snr < sq_thresh->upper_threshold[0]) { 1487bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1488bdcd8170SKalle Valo "spurious upper snr threshold event: %d\n", 1489bdcd8170SKalle Valo snr); 1490bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[1]) && 1491bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[0])) { 1492bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_ABOVE; 1493bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[2]) && 1494bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[1])) { 1495bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_ABOVE; 1496bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[3]) && 1497bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[2])) { 1498bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_ABOVE; 1499bdcd8170SKalle Valo } else if (snr >= sq_thresh->upper_threshold[3]) { 1500bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_ABOVE; 1501bdcd8170SKalle Valo } 1502bdcd8170SKalle Valo } else { 1503bdcd8170SKalle Valo /* Lower threshold breached */ 1504bdcd8170SKalle Valo if (snr > sq_thresh->lower_threshold[0]) { 1505bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1506bdcd8170SKalle Valo "spurious lower snr threshold event: %d\n", 1507bdcd8170SKalle Valo sq_thresh->lower_threshold[0]); 1508bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[1]) && 1509bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[0])) { 1510bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_BELOW; 1511bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[2]) && 1512bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[1])) { 1513bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_BELOW; 1514bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[3]) && 1515bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[2])) { 1516bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_BELOW; 1517bdcd8170SKalle Valo } else if (snr <= sq_thresh->lower_threshold[3]) { 1518bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_BELOW; 1519bdcd8170SKalle Valo } 1520bdcd8170SKalle Valo } 1521bdcd8170SKalle Valo 1522bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1523bdcd8170SKalle Valo lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, 1524bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1525bdcd8170SKalle Valo upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, 1526bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1527bdcd8170SKalle Valo 1528bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1529bdcd8170SKalle Valo cmd.thresh_above1_val = upper_snr_threshold; 1530bdcd8170SKalle Valo cmd.thresh_below1_val = lower_snr_threshold; 1531bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1532bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1533bdcd8170SKalle Valo 1534bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1535bdcd8170SKalle Valo "snr: %d, threshold: %d, lower: %d, upper: %d\n", 1536bdcd8170SKalle Valo snr, new_threshold, 1537bdcd8170SKalle Valo lower_snr_threshold, upper_snr_threshold); 1538bdcd8170SKalle Valo 1539bdcd8170SKalle Valo ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); 1540bdcd8170SKalle Valo if (ret) { 1541bdcd8170SKalle Valo ath6kl_err("unable to configure snr threshold\n"); 1542bdcd8170SKalle Valo return -EIO; 1543bdcd8170SKalle Valo } 1544bdcd8170SKalle Valo 1545bdcd8170SKalle Valo return 0; 1546bdcd8170SKalle Valo } 1547bdcd8170SKalle Valo 1548bdcd8170SKalle Valo static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) 1549bdcd8170SKalle Valo { 1550bdcd8170SKalle Valo u16 ap_info_entry_size; 1551bdcd8170SKalle Valo struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; 1552bdcd8170SKalle Valo struct wmi_ap_info_v1 *ap_info_v1; 1553bdcd8170SKalle Valo u8 index; 1554bdcd8170SKalle Valo 1555bdcd8170SKalle Valo if (len < sizeof(struct wmi_aplist_event) || 1556bdcd8170SKalle Valo ev->ap_list_ver != APLIST_VER1) 1557bdcd8170SKalle Valo return -EINVAL; 1558bdcd8170SKalle Valo 1559bdcd8170SKalle Valo ap_info_entry_size = sizeof(struct wmi_ap_info_v1); 1560bdcd8170SKalle Valo ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; 1561bdcd8170SKalle Valo 1562bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1563bdcd8170SKalle Valo "number of APs in aplist event: %d\n", ev->num_ap); 1564bdcd8170SKalle Valo 1565bdcd8170SKalle Valo if (len < (int) (sizeof(struct wmi_aplist_event) + 1566bdcd8170SKalle Valo (ev->num_ap - 1) * ap_info_entry_size)) 1567bdcd8170SKalle Valo return -EINVAL; 1568bdcd8170SKalle Valo 1569bdcd8170SKalle Valo /* AP list version 1 contents */ 1570bdcd8170SKalle Valo for (index = 0; index < ev->num_ap; index++) { 1571bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", 1572bdcd8170SKalle Valo index, ap_info_v1->bssid, ap_info_v1->channel); 1573bdcd8170SKalle Valo ap_info_v1++; 1574bdcd8170SKalle Valo } 1575bdcd8170SKalle Valo 1576bdcd8170SKalle Valo return 0; 1577bdcd8170SKalle Valo } 1578bdcd8170SKalle Valo 1579bdcd8170SKalle Valo int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, 1580bdcd8170SKalle Valo enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) 1581bdcd8170SKalle Valo { 1582bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd_hdr; 1583bdcd8170SKalle Valo enum htc_endpoint_id ep_id = wmi->ep_id; 1584bdcd8170SKalle Valo int ret; 1585bdcd8170SKalle Valo 1586bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 1587bdcd8170SKalle Valo return -EINVAL; 1588bdcd8170SKalle Valo 1589b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n", 1590b9b6ee60SKalle Valo cmd_id, skb->len, sync_flag); 1591b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ", 1592b9b6ee60SKalle Valo skb->data, skb->len); 1593b9b6ee60SKalle Valo 1594bdcd8170SKalle Valo if (sync_flag >= END_WMIFLAG) { 1595bdcd8170SKalle Valo dev_kfree_skb(skb); 1596bdcd8170SKalle Valo return -EINVAL; 1597bdcd8170SKalle Valo } 1598bdcd8170SKalle Valo 1599bdcd8170SKalle Valo if ((sync_flag == SYNC_BEFORE_WMIFLAG) || 1600bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1601bdcd8170SKalle Valo /* 1602bdcd8170SKalle Valo * Make sure all data currently queued is transmitted before 1603bdcd8170SKalle Valo * the cmd execution. Establish a new sync point. 1604bdcd8170SKalle Valo */ 1605bdcd8170SKalle Valo ath6kl_wmi_sync_point(wmi); 1606bdcd8170SKalle Valo } 1607bdcd8170SKalle Valo 1608bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_cmd_hdr)); 1609bdcd8170SKalle Valo 1610bdcd8170SKalle Valo cmd_hdr = (struct wmi_cmd_hdr *) skb->data; 1611bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le16(cmd_id); 1612bdcd8170SKalle Valo cmd_hdr->info1 = 0; /* added for virtual interface */ 1613bdcd8170SKalle Valo 1614bdcd8170SKalle Valo /* Only for OPT_TX_CMD, use BE endpoint. */ 1615bdcd8170SKalle Valo if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { 1616bdcd8170SKalle Valo ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, 1617bdcd8170SKalle Valo false, false, 0, NULL); 1618bdcd8170SKalle Valo if (ret) { 1619bdcd8170SKalle Valo dev_kfree_skb(skb); 1620bdcd8170SKalle Valo return ret; 1621bdcd8170SKalle Valo } 1622bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); 1623bdcd8170SKalle Valo } 1624bdcd8170SKalle Valo 1625bdcd8170SKalle Valo ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 1626bdcd8170SKalle Valo 1627bdcd8170SKalle Valo if ((sync_flag == SYNC_AFTER_WMIFLAG) || 1628bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1629bdcd8170SKalle Valo /* 1630bdcd8170SKalle Valo * Make sure all new data queued waits for the command to 1631bdcd8170SKalle Valo * execute. Establish a new sync point. 1632bdcd8170SKalle Valo */ 1633bdcd8170SKalle Valo ath6kl_wmi_sync_point(wmi); 1634bdcd8170SKalle Valo } 1635bdcd8170SKalle Valo 1636bdcd8170SKalle Valo return 0; 1637bdcd8170SKalle Valo } 1638bdcd8170SKalle Valo 1639bdcd8170SKalle Valo int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, 1640bdcd8170SKalle Valo enum dot11_auth_mode dot11_auth_mode, 1641bdcd8170SKalle Valo enum auth_mode auth_mode, 1642bdcd8170SKalle Valo enum crypto_type pairwise_crypto, 1643bdcd8170SKalle Valo u8 pairwise_crypto_len, 1644bdcd8170SKalle Valo enum crypto_type group_crypto, 1645bdcd8170SKalle Valo u8 group_crypto_len, int ssid_len, u8 *ssid, 1646bdcd8170SKalle Valo u8 *bssid, u16 channel, u32 ctrl_flags) 1647bdcd8170SKalle Valo { 1648bdcd8170SKalle Valo struct sk_buff *skb; 1649bdcd8170SKalle Valo struct wmi_connect_cmd *cc; 1650bdcd8170SKalle Valo int ret; 1651bdcd8170SKalle Valo 1652b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1653b9b6ee60SKalle Valo "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d " 1654b9b6ee60SKalle Valo "type %d dot11_auth %d auth %d pairwise %d group %d\n", 1655b9b6ee60SKalle Valo bssid, channel, ctrl_flags, ssid_len, nw_type, 1656b9b6ee60SKalle Valo dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto); 1657b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len); 1658b9b6ee60SKalle Valo 1659bdcd8170SKalle Valo wmi->traffic_class = 100; 1660bdcd8170SKalle Valo 1661bdcd8170SKalle Valo if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) 1662bdcd8170SKalle Valo return -EINVAL; 1663bdcd8170SKalle Valo 1664bdcd8170SKalle Valo if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) 1665bdcd8170SKalle Valo return -EINVAL; 1666bdcd8170SKalle Valo 1667bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); 1668bdcd8170SKalle Valo if (!skb) 1669bdcd8170SKalle Valo return -ENOMEM; 1670bdcd8170SKalle Valo 1671bdcd8170SKalle Valo cc = (struct wmi_connect_cmd *) skb->data; 1672bdcd8170SKalle Valo 1673bdcd8170SKalle Valo if (ssid_len) 1674bdcd8170SKalle Valo memcpy(cc->ssid, ssid, ssid_len); 1675bdcd8170SKalle Valo 1676bdcd8170SKalle Valo cc->ssid_len = ssid_len; 1677bdcd8170SKalle Valo cc->nw_type = nw_type; 1678bdcd8170SKalle Valo cc->dot11_auth_mode = dot11_auth_mode; 1679bdcd8170SKalle Valo cc->auth_mode = auth_mode; 1680bdcd8170SKalle Valo cc->prwise_crypto_type = pairwise_crypto; 1681bdcd8170SKalle Valo cc->prwise_crypto_len = pairwise_crypto_len; 1682bdcd8170SKalle Valo cc->grp_crypto_type = group_crypto; 1683bdcd8170SKalle Valo cc->grp_crypto_len = group_crypto_len; 1684bdcd8170SKalle Valo cc->ch = cpu_to_le16(channel); 1685bdcd8170SKalle Valo cc->ctrl_flags = cpu_to_le32(ctrl_flags); 1686bdcd8170SKalle Valo 1687bdcd8170SKalle Valo if (bssid != NULL) 1688bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1689bdcd8170SKalle Valo 1690bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG); 1691bdcd8170SKalle Valo 1692bdcd8170SKalle Valo return ret; 1693bdcd8170SKalle Valo } 1694bdcd8170SKalle Valo 1695bdcd8170SKalle Valo int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel) 1696bdcd8170SKalle Valo { 1697bdcd8170SKalle Valo struct sk_buff *skb; 1698bdcd8170SKalle Valo struct wmi_reconnect_cmd *cc; 1699bdcd8170SKalle Valo int ret; 1700bdcd8170SKalle Valo 1701b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n", 1702b9b6ee60SKalle Valo bssid, channel); 1703b9b6ee60SKalle Valo 1704bdcd8170SKalle Valo wmi->traffic_class = 100; 1705bdcd8170SKalle Valo 1706bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); 1707bdcd8170SKalle Valo if (!skb) 1708bdcd8170SKalle Valo return -ENOMEM; 1709bdcd8170SKalle Valo 1710bdcd8170SKalle Valo cc = (struct wmi_reconnect_cmd *) skb->data; 1711bdcd8170SKalle Valo cc->channel = cpu_to_le16(channel); 1712bdcd8170SKalle Valo 1713bdcd8170SKalle Valo if (bssid != NULL) 1714bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1715bdcd8170SKalle Valo 1716bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID, 1717bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1718bdcd8170SKalle Valo 1719bdcd8170SKalle Valo return ret; 1720bdcd8170SKalle Valo } 1721bdcd8170SKalle Valo 1722bdcd8170SKalle Valo int ath6kl_wmi_disconnect_cmd(struct wmi *wmi) 1723bdcd8170SKalle Valo { 1724bdcd8170SKalle Valo int ret; 1725bdcd8170SKalle Valo 1726b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n"); 1727b9b6ee60SKalle Valo 1728bdcd8170SKalle Valo wmi->traffic_class = 100; 1729bdcd8170SKalle Valo 1730bdcd8170SKalle Valo /* Disconnect command does not need to do a SYNC before. */ 1731bdcd8170SKalle Valo ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID); 1732bdcd8170SKalle Valo 1733bdcd8170SKalle Valo return ret; 1734bdcd8170SKalle Valo } 1735bdcd8170SKalle Valo 1736bdcd8170SKalle Valo int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, 1737bdcd8170SKalle Valo u32 force_fgscan, u32 is_legacy, 1738bdcd8170SKalle Valo u32 home_dwell_time, u32 force_scan_interval, 1739bdcd8170SKalle Valo s8 num_chan, u16 *ch_list) 1740bdcd8170SKalle Valo { 1741bdcd8170SKalle Valo struct sk_buff *skb; 1742bdcd8170SKalle Valo struct wmi_start_scan_cmd *sc; 1743bdcd8170SKalle Valo s8 size; 17441276c9efSEdward Lu int i, ret; 1745bdcd8170SKalle Valo 1746bdcd8170SKalle Valo size = sizeof(struct wmi_start_scan_cmd); 1747bdcd8170SKalle Valo 1748bdcd8170SKalle Valo if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 1749bdcd8170SKalle Valo return -EINVAL; 1750bdcd8170SKalle Valo 1751bdcd8170SKalle Valo if (num_chan > WMI_MAX_CHANNELS) 1752bdcd8170SKalle Valo return -EINVAL; 1753bdcd8170SKalle Valo 1754bdcd8170SKalle Valo if (num_chan) 1755bdcd8170SKalle Valo size += sizeof(u16) * (num_chan - 1); 1756bdcd8170SKalle Valo 1757bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(size); 1758bdcd8170SKalle Valo if (!skb) 1759bdcd8170SKalle Valo return -ENOMEM; 1760bdcd8170SKalle Valo 1761bdcd8170SKalle Valo sc = (struct wmi_start_scan_cmd *) skb->data; 1762bdcd8170SKalle Valo sc->scan_type = scan_type; 1763bdcd8170SKalle Valo sc->force_fg_scan = cpu_to_le32(force_fgscan); 1764bdcd8170SKalle Valo sc->is_legacy = cpu_to_le32(is_legacy); 1765bdcd8170SKalle Valo sc->home_dwell_time = cpu_to_le32(home_dwell_time); 1766bdcd8170SKalle Valo sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 1767bdcd8170SKalle Valo sc->num_ch = num_chan; 1768bdcd8170SKalle Valo 17691276c9efSEdward Lu for (i = 0; i < num_chan; i++) 17701276c9efSEdward Lu sc->ch_list[i] = cpu_to_le16(ch_list[i]); 1771bdcd8170SKalle Valo 1772bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID, 1773bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1774bdcd8170SKalle Valo 1775bdcd8170SKalle Valo return ret; 1776bdcd8170SKalle Valo } 1777bdcd8170SKalle Valo 1778bdcd8170SKalle Valo int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, 1779bdcd8170SKalle Valo u16 fg_end_sec, u16 bg_sec, 1780bdcd8170SKalle Valo u16 minact_chdw_msec, u16 maxact_chdw_msec, 1781bdcd8170SKalle Valo u16 pas_chdw_msec, u8 short_scan_ratio, 1782bdcd8170SKalle Valo u8 scan_ctrl_flag, u32 max_dfsch_act_time, 1783bdcd8170SKalle Valo u16 maxact_scan_per_ssid) 1784bdcd8170SKalle Valo { 1785bdcd8170SKalle Valo struct sk_buff *skb; 1786bdcd8170SKalle Valo struct wmi_scan_params_cmd *sc; 1787bdcd8170SKalle Valo int ret; 1788bdcd8170SKalle Valo 1789bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); 1790bdcd8170SKalle Valo if (!skb) 1791bdcd8170SKalle Valo return -ENOMEM; 1792bdcd8170SKalle Valo 1793bdcd8170SKalle Valo sc = (struct wmi_scan_params_cmd *) skb->data; 1794bdcd8170SKalle Valo sc->fg_start_period = cpu_to_le16(fg_start_sec); 1795bdcd8170SKalle Valo sc->fg_end_period = cpu_to_le16(fg_end_sec); 1796bdcd8170SKalle Valo sc->bg_period = cpu_to_le16(bg_sec); 1797bdcd8170SKalle Valo sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); 1798bdcd8170SKalle Valo sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); 1799bdcd8170SKalle Valo sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); 1800bdcd8170SKalle Valo sc->short_scan_ratio = short_scan_ratio; 1801bdcd8170SKalle Valo sc->scan_ctrl_flags = scan_ctrl_flag; 1802bdcd8170SKalle Valo sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); 1803bdcd8170SKalle Valo sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); 1804bdcd8170SKalle Valo 1805bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID, 1806bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1807bdcd8170SKalle Valo return ret; 1808bdcd8170SKalle Valo } 1809bdcd8170SKalle Valo 1810bdcd8170SKalle Valo int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) 1811bdcd8170SKalle Valo { 1812bdcd8170SKalle Valo struct sk_buff *skb; 1813bdcd8170SKalle Valo struct wmi_bss_filter_cmd *cmd; 1814bdcd8170SKalle Valo int ret; 1815bdcd8170SKalle Valo 1816bdcd8170SKalle Valo if (filter >= LAST_BSS_FILTER) 1817bdcd8170SKalle Valo return -EINVAL; 1818bdcd8170SKalle Valo 1819bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1820bdcd8170SKalle Valo if (!skb) 1821bdcd8170SKalle Valo return -ENOMEM; 1822bdcd8170SKalle Valo 1823bdcd8170SKalle Valo cmd = (struct wmi_bss_filter_cmd *) skb->data; 1824bdcd8170SKalle Valo cmd->bss_filter = filter; 1825bdcd8170SKalle Valo cmd->ie_mask = cpu_to_le32(ie_mask); 1826bdcd8170SKalle Valo 1827bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID, 1828bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1829bdcd8170SKalle Valo return ret; 1830bdcd8170SKalle Valo } 1831bdcd8170SKalle Valo 1832bdcd8170SKalle Valo int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, 1833bdcd8170SKalle Valo u8 ssid_len, u8 *ssid) 1834bdcd8170SKalle Valo { 1835bdcd8170SKalle Valo struct sk_buff *skb; 1836bdcd8170SKalle Valo struct wmi_probed_ssid_cmd *cmd; 1837bdcd8170SKalle Valo int ret; 1838bdcd8170SKalle Valo 1839bdcd8170SKalle Valo if (index > MAX_PROBED_SSID_INDEX) 1840bdcd8170SKalle Valo return -EINVAL; 1841bdcd8170SKalle Valo 1842bdcd8170SKalle Valo if (ssid_len > sizeof(cmd->ssid)) 1843bdcd8170SKalle Valo return -EINVAL; 1844bdcd8170SKalle Valo 1845bdcd8170SKalle Valo if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) 1846bdcd8170SKalle Valo return -EINVAL; 1847bdcd8170SKalle Valo 1848bdcd8170SKalle Valo if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) 1849bdcd8170SKalle Valo return -EINVAL; 1850bdcd8170SKalle Valo 1851bdcd8170SKalle Valo if (flag & SPECIFIC_SSID_FLAG) 1852bdcd8170SKalle Valo wmi->is_probe_ssid = true; 1853bdcd8170SKalle Valo 1854bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1855bdcd8170SKalle Valo if (!skb) 1856bdcd8170SKalle Valo return -ENOMEM; 1857bdcd8170SKalle Valo 1858bdcd8170SKalle Valo cmd = (struct wmi_probed_ssid_cmd *) skb->data; 1859bdcd8170SKalle Valo cmd->entry_index = index; 1860bdcd8170SKalle Valo cmd->flag = flag; 1861bdcd8170SKalle Valo cmd->ssid_len = ssid_len; 1862bdcd8170SKalle Valo memcpy(cmd->ssid, ssid, ssid_len); 1863bdcd8170SKalle Valo 1864bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID, 1865bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1866bdcd8170SKalle Valo return ret; 1867bdcd8170SKalle Valo } 1868bdcd8170SKalle Valo 1869bdcd8170SKalle Valo int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, 1870bdcd8170SKalle Valo u16 listen_beacons) 1871bdcd8170SKalle Valo { 1872bdcd8170SKalle Valo struct sk_buff *skb; 1873bdcd8170SKalle Valo struct wmi_listen_int_cmd *cmd; 1874bdcd8170SKalle Valo int ret; 1875bdcd8170SKalle Valo 1876bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1877bdcd8170SKalle Valo if (!skb) 1878bdcd8170SKalle Valo return -ENOMEM; 1879bdcd8170SKalle Valo 1880bdcd8170SKalle Valo cmd = (struct wmi_listen_int_cmd *) skb->data; 1881bdcd8170SKalle Valo cmd->listen_intvl = cpu_to_le16(listen_interval); 1882bdcd8170SKalle Valo cmd->num_beacons = cpu_to_le16(listen_beacons); 1883bdcd8170SKalle Valo 1884bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID, 1885bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1886bdcd8170SKalle Valo return ret; 1887bdcd8170SKalle Valo } 1888bdcd8170SKalle Valo 1889bdcd8170SKalle Valo int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode) 1890bdcd8170SKalle Valo { 1891bdcd8170SKalle Valo struct sk_buff *skb; 1892bdcd8170SKalle Valo struct wmi_power_mode_cmd *cmd; 1893bdcd8170SKalle Valo int ret; 1894bdcd8170SKalle Valo 1895bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1896bdcd8170SKalle Valo if (!skb) 1897bdcd8170SKalle Valo return -ENOMEM; 1898bdcd8170SKalle Valo 1899bdcd8170SKalle Valo cmd = (struct wmi_power_mode_cmd *) skb->data; 1900bdcd8170SKalle Valo cmd->pwr_mode = pwr_mode; 1901bdcd8170SKalle Valo wmi->pwr_mode = pwr_mode; 1902bdcd8170SKalle Valo 1903bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID, 1904bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1905bdcd8170SKalle Valo return ret; 1906bdcd8170SKalle Valo } 1907bdcd8170SKalle Valo 1908bdcd8170SKalle Valo int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, 1909bdcd8170SKalle Valo u16 ps_poll_num, u16 dtim_policy, 1910bdcd8170SKalle Valo u16 tx_wakeup_policy, u16 num_tx_to_wakeup, 1911bdcd8170SKalle Valo u16 ps_fail_event_policy) 1912bdcd8170SKalle Valo { 1913bdcd8170SKalle Valo struct sk_buff *skb; 1914bdcd8170SKalle Valo struct wmi_power_params_cmd *pm; 1915bdcd8170SKalle Valo int ret; 1916bdcd8170SKalle Valo 1917bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); 1918bdcd8170SKalle Valo if (!skb) 1919bdcd8170SKalle Valo return -ENOMEM; 1920bdcd8170SKalle Valo 1921bdcd8170SKalle Valo pm = (struct wmi_power_params_cmd *)skb->data; 1922bdcd8170SKalle Valo pm->idle_period = cpu_to_le16(idle_period); 1923bdcd8170SKalle Valo pm->pspoll_number = cpu_to_le16(ps_poll_num); 1924bdcd8170SKalle Valo pm->dtim_policy = cpu_to_le16(dtim_policy); 1925bdcd8170SKalle Valo pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); 1926bdcd8170SKalle Valo pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); 1927bdcd8170SKalle Valo pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); 1928bdcd8170SKalle Valo 1929bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID, 1930bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1931bdcd8170SKalle Valo return ret; 1932bdcd8170SKalle Valo } 1933bdcd8170SKalle Valo 1934bdcd8170SKalle Valo int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) 1935bdcd8170SKalle Valo { 1936bdcd8170SKalle Valo struct sk_buff *skb; 1937bdcd8170SKalle Valo struct wmi_disc_timeout_cmd *cmd; 1938bdcd8170SKalle Valo int ret; 1939bdcd8170SKalle Valo 1940bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1941bdcd8170SKalle Valo if (!skb) 1942bdcd8170SKalle Valo return -ENOMEM; 1943bdcd8170SKalle Valo 1944bdcd8170SKalle Valo cmd = (struct wmi_disc_timeout_cmd *) skb->data; 1945bdcd8170SKalle Valo cmd->discon_timeout = timeout; 1946bdcd8170SKalle Valo 1947bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID, 1948bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1949ff0b0075SJouni Malinen if (ret == 0) 1950ff0b0075SJouni Malinen ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout); 1951bdcd8170SKalle Valo return ret; 1952bdcd8170SKalle Valo } 1953bdcd8170SKalle Valo 1954bdcd8170SKalle Valo int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, 1955bdcd8170SKalle Valo enum crypto_type key_type, 1956bdcd8170SKalle Valo u8 key_usage, u8 key_len, 1957bdcd8170SKalle Valo u8 *key_rsc, u8 *key_material, 1958bdcd8170SKalle Valo u8 key_op_ctrl, u8 *mac_addr, 1959bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 1960bdcd8170SKalle Valo { 1961bdcd8170SKalle Valo struct sk_buff *skb; 1962bdcd8170SKalle Valo struct wmi_add_cipher_key_cmd *cmd; 1963bdcd8170SKalle Valo int ret; 1964bdcd8170SKalle Valo 19659a5b1318SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " 19669a5b1318SJouni Malinen "key_usage=%d key_len=%d key_op_ctrl=%d\n", 19679a5b1318SJouni Malinen key_index, key_type, key_usage, key_len, key_op_ctrl); 19689a5b1318SJouni Malinen 1969bdcd8170SKalle Valo if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || 1970bdcd8170SKalle Valo (key_material == NULL)) 1971bdcd8170SKalle Valo return -EINVAL; 1972bdcd8170SKalle Valo 1973bdcd8170SKalle Valo if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) 1974bdcd8170SKalle Valo return -EINVAL; 1975bdcd8170SKalle Valo 1976bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1977bdcd8170SKalle Valo if (!skb) 1978bdcd8170SKalle Valo return -ENOMEM; 1979bdcd8170SKalle Valo 1980bdcd8170SKalle Valo cmd = (struct wmi_add_cipher_key_cmd *) skb->data; 1981bdcd8170SKalle Valo cmd->key_index = key_index; 1982bdcd8170SKalle Valo cmd->key_type = key_type; 1983bdcd8170SKalle Valo cmd->key_usage = key_usage; 1984bdcd8170SKalle Valo cmd->key_len = key_len; 1985bdcd8170SKalle Valo memcpy(cmd->key, key_material, key_len); 1986bdcd8170SKalle Valo 1987bdcd8170SKalle Valo if (key_rsc != NULL) 1988bdcd8170SKalle Valo memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc)); 1989bdcd8170SKalle Valo 1990bdcd8170SKalle Valo cmd->key_op_ctrl = key_op_ctrl; 1991bdcd8170SKalle Valo 1992bdcd8170SKalle Valo if (mac_addr) 1993bdcd8170SKalle Valo memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); 1994bdcd8170SKalle Valo 1995bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID, 1996bdcd8170SKalle Valo sync_flag); 1997bdcd8170SKalle Valo 1998bdcd8170SKalle Valo return ret; 1999bdcd8170SKalle Valo } 2000bdcd8170SKalle Valo 2001bdcd8170SKalle Valo int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) 2002bdcd8170SKalle Valo { 2003bdcd8170SKalle Valo struct sk_buff *skb; 2004bdcd8170SKalle Valo struct wmi_add_krk_cmd *cmd; 2005bdcd8170SKalle Valo int ret; 2006bdcd8170SKalle Valo 2007bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2008bdcd8170SKalle Valo if (!skb) 2009bdcd8170SKalle Valo return -ENOMEM; 2010bdcd8170SKalle Valo 2011bdcd8170SKalle Valo cmd = (struct wmi_add_krk_cmd *) skb->data; 2012bdcd8170SKalle Valo memcpy(cmd->krk, krk, WMI_KRK_LEN); 2013bdcd8170SKalle Valo 2014bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG); 2015bdcd8170SKalle Valo 2016bdcd8170SKalle Valo return ret; 2017bdcd8170SKalle Valo } 2018bdcd8170SKalle Valo 2019bdcd8170SKalle Valo int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index) 2020bdcd8170SKalle Valo { 2021bdcd8170SKalle Valo struct sk_buff *skb; 2022bdcd8170SKalle Valo struct wmi_delete_cipher_key_cmd *cmd; 2023bdcd8170SKalle Valo int ret; 2024bdcd8170SKalle Valo 2025bdcd8170SKalle Valo if (key_index > WMI_MAX_KEY_INDEX) 2026bdcd8170SKalle Valo return -EINVAL; 2027bdcd8170SKalle Valo 2028bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2029bdcd8170SKalle Valo if (!skb) 2030bdcd8170SKalle Valo return -ENOMEM; 2031bdcd8170SKalle Valo 2032bdcd8170SKalle Valo cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; 2033bdcd8170SKalle Valo cmd->key_index = key_index; 2034bdcd8170SKalle Valo 2035bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID, 2036bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2037bdcd8170SKalle Valo 2038bdcd8170SKalle Valo return ret; 2039bdcd8170SKalle Valo } 2040bdcd8170SKalle Valo 2041bdcd8170SKalle Valo int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, 2042bdcd8170SKalle Valo const u8 *pmkid, bool set) 2043bdcd8170SKalle Valo { 2044bdcd8170SKalle Valo struct sk_buff *skb; 2045bdcd8170SKalle Valo struct wmi_setpmkid_cmd *cmd; 2046bdcd8170SKalle Valo int ret; 2047bdcd8170SKalle Valo 2048bdcd8170SKalle Valo if (bssid == NULL) 2049bdcd8170SKalle Valo return -EINVAL; 2050bdcd8170SKalle Valo 2051bdcd8170SKalle Valo if (set && pmkid == NULL) 2052bdcd8170SKalle Valo return -EINVAL; 2053bdcd8170SKalle Valo 2054bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2055bdcd8170SKalle Valo if (!skb) 2056bdcd8170SKalle Valo return -ENOMEM; 2057bdcd8170SKalle Valo 2058bdcd8170SKalle Valo cmd = (struct wmi_setpmkid_cmd *) skb->data; 2059bdcd8170SKalle Valo memcpy(cmd->bssid, bssid, ETH_ALEN); 2060bdcd8170SKalle Valo if (set) { 2061bdcd8170SKalle Valo memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); 2062bdcd8170SKalle Valo cmd->enable = PMKID_ENABLE; 2063bdcd8170SKalle Valo } else { 2064bdcd8170SKalle Valo memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); 2065bdcd8170SKalle Valo cmd->enable = PMKID_DISABLE; 2066bdcd8170SKalle Valo } 2067bdcd8170SKalle Valo 2068bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID, 2069bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2070bdcd8170SKalle Valo 2071bdcd8170SKalle Valo return ret; 2072bdcd8170SKalle Valo } 2073bdcd8170SKalle Valo 2074bdcd8170SKalle Valo static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, 2075bdcd8170SKalle Valo enum htc_endpoint_id ep_id) 2076bdcd8170SKalle Valo { 2077bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 2078bdcd8170SKalle Valo int ret; 2079bdcd8170SKalle Valo 2080bdcd8170SKalle Valo if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) 2081bdcd8170SKalle Valo return -EINVAL; 2082bdcd8170SKalle Valo 2083bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 2084bdcd8170SKalle Valo 2085bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) skb->data; 2086bdcd8170SKalle Valo data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; 2087bdcd8170SKalle Valo data_hdr->info3 = 0; 2088bdcd8170SKalle Valo 2089bdcd8170SKalle Valo ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 2090bdcd8170SKalle Valo 2091bdcd8170SKalle Valo return ret; 2092bdcd8170SKalle Valo } 2093bdcd8170SKalle Valo 2094bdcd8170SKalle Valo static int ath6kl_wmi_sync_point(struct wmi *wmi) 2095bdcd8170SKalle Valo { 2096bdcd8170SKalle Valo struct sk_buff *skb; 2097bdcd8170SKalle Valo struct wmi_sync_cmd *cmd; 2098bdcd8170SKalle Valo struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; 2099bdcd8170SKalle Valo enum htc_endpoint_id ep_id; 2100bdcd8170SKalle Valo u8 index, num_pri_streams = 0; 2101bdcd8170SKalle Valo int ret = 0; 2102bdcd8170SKalle Valo 2103bdcd8170SKalle Valo memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); 2104bdcd8170SKalle Valo 2105bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2106bdcd8170SKalle Valo 2107bdcd8170SKalle Valo for (index = 0; index < WMM_NUM_AC; index++) { 2108bdcd8170SKalle Valo if (wmi->fat_pipe_exist & (1 << index)) { 2109bdcd8170SKalle Valo num_pri_streams++; 2110bdcd8170SKalle Valo data_sync_bufs[num_pri_streams - 1].traffic_class = 2111bdcd8170SKalle Valo index; 2112bdcd8170SKalle Valo } 2113bdcd8170SKalle Valo } 2114bdcd8170SKalle Valo 2115bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2116bdcd8170SKalle Valo 2117bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2118bdcd8170SKalle Valo if (!skb) { 2119bdcd8170SKalle Valo ret = -ENOMEM; 2120bdcd8170SKalle Valo goto free_skb; 2121bdcd8170SKalle Valo } 2122bdcd8170SKalle Valo 2123bdcd8170SKalle Valo cmd = (struct wmi_sync_cmd *) skb->data; 2124bdcd8170SKalle Valo 2125bdcd8170SKalle Valo /* 2126bdcd8170SKalle Valo * In the SYNC cmd sent on the control Ep, send a bitmap 2127bdcd8170SKalle Valo * of the data eps on which the Data Sync will be sent 2128bdcd8170SKalle Valo */ 2129bdcd8170SKalle Valo cmd->data_sync_map = wmi->fat_pipe_exist; 2130bdcd8170SKalle Valo 2131bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2132bdcd8170SKalle Valo data_sync_bufs[index].skb = ath6kl_buf_alloc(0); 2133bdcd8170SKalle Valo if (data_sync_bufs[index].skb == NULL) { 2134bdcd8170SKalle Valo ret = -ENOMEM; 2135bdcd8170SKalle Valo break; 2136bdcd8170SKalle Valo } 2137bdcd8170SKalle Valo } 2138bdcd8170SKalle Valo 2139bdcd8170SKalle Valo /* 2140bdcd8170SKalle Valo * If buffer allocation for any of the dataSync fails, 2141bdcd8170SKalle Valo * then do not send the Synchronize cmd on the control ep 2142bdcd8170SKalle Valo */ 2143bdcd8170SKalle Valo if (ret) 2144bdcd8170SKalle Valo goto free_skb; 2145bdcd8170SKalle Valo 2146bdcd8170SKalle Valo /* 2147bdcd8170SKalle Valo * Send sync cmd followed by sync data messages on all 2148bdcd8170SKalle Valo * endpoints being used 2149bdcd8170SKalle Valo */ 2150bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID, 2151bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2152bdcd8170SKalle Valo 2153bdcd8170SKalle Valo if (ret) 2154bdcd8170SKalle Valo goto free_skb; 2155bdcd8170SKalle Valo 2156bdcd8170SKalle Valo /* cmd buffer sent, we no longer own it */ 2157bdcd8170SKalle Valo skb = NULL; 2158bdcd8170SKalle Valo 2159bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2160bdcd8170SKalle Valo 2161bdcd8170SKalle Valo if (WARN_ON(!data_sync_bufs[index].skb)) 2162bdcd8170SKalle Valo break; 2163bdcd8170SKalle Valo 2164bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, 2165bdcd8170SKalle Valo data_sync_bufs[index]. 2166bdcd8170SKalle Valo traffic_class); 2167bdcd8170SKalle Valo ret = 2168bdcd8170SKalle Valo ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, 2169bdcd8170SKalle Valo ep_id); 2170bdcd8170SKalle Valo 2171bdcd8170SKalle Valo if (ret) 2172bdcd8170SKalle Valo break; 2173bdcd8170SKalle Valo 2174bdcd8170SKalle Valo data_sync_bufs[index].skb = NULL; 2175bdcd8170SKalle Valo } 2176bdcd8170SKalle Valo 2177bdcd8170SKalle Valo free_skb: 2178bdcd8170SKalle Valo /* free up any resources left over (possibly due to an error) */ 2179bdcd8170SKalle Valo if (skb) 2180bdcd8170SKalle Valo dev_kfree_skb(skb); 2181bdcd8170SKalle Valo 2182bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2183bdcd8170SKalle Valo if (data_sync_bufs[index].skb != NULL) { 2184bdcd8170SKalle Valo dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. 2185bdcd8170SKalle Valo skb); 2186bdcd8170SKalle Valo } 2187bdcd8170SKalle Valo } 2188bdcd8170SKalle Valo 2189bdcd8170SKalle Valo return ret; 2190bdcd8170SKalle Valo } 2191bdcd8170SKalle Valo 2192bdcd8170SKalle Valo int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, 2193bdcd8170SKalle Valo struct wmi_create_pstream_cmd *params) 2194bdcd8170SKalle Valo { 2195bdcd8170SKalle Valo struct sk_buff *skb; 2196bdcd8170SKalle Valo struct wmi_create_pstream_cmd *cmd; 2197bdcd8170SKalle Valo u8 fatpipe_exist_for_ac = 0; 2198bdcd8170SKalle Valo s32 min_phy = 0; 2199bdcd8170SKalle Valo s32 nominal_phy = 0; 2200bdcd8170SKalle Valo int ret; 2201bdcd8170SKalle Valo 2202bdcd8170SKalle Valo if (!((params->user_pri < 8) && 2203bdcd8170SKalle Valo (params->user_pri <= 0x7) && 2204bdcd8170SKalle Valo (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && 2205bdcd8170SKalle Valo (params->traffic_direc == UPLINK_TRAFFIC || 2206bdcd8170SKalle Valo params->traffic_direc == DNLINK_TRAFFIC || 2207bdcd8170SKalle Valo params->traffic_direc == BIDIR_TRAFFIC) && 2208bdcd8170SKalle Valo (params->traffic_type == TRAFFIC_TYPE_APERIODIC || 2209bdcd8170SKalle Valo params->traffic_type == TRAFFIC_TYPE_PERIODIC) && 2210bdcd8170SKalle Valo (params->voice_psc_cap == DISABLE_FOR_THIS_AC || 2211bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_THIS_AC || 2212bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_ALL_AC) && 2213bdcd8170SKalle Valo (params->tsid == WMI_IMPLICIT_PSTREAM || 2214bdcd8170SKalle Valo params->tsid <= WMI_MAX_THINSTREAM))) { 2215bdcd8170SKalle Valo return -EINVAL; 2216bdcd8170SKalle Valo } 2217bdcd8170SKalle Valo 2218bdcd8170SKalle Valo /* 2219bdcd8170SKalle Valo * Check nominal PHY rate is >= minimalPHY, 2220bdcd8170SKalle Valo * so that DUT can allow TSRS IE 2221bdcd8170SKalle Valo */ 2222bdcd8170SKalle Valo 2223bdcd8170SKalle Valo /* Get the physical rate (units of bps) */ 2224bdcd8170SKalle Valo min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); 2225bdcd8170SKalle Valo 2226bdcd8170SKalle Valo /* Check minimal phy < nominal phy rate */ 2227bdcd8170SKalle Valo if (params->nominal_phy >= min_phy) { 2228bdcd8170SKalle Valo /* unit of 500 kbps */ 2229bdcd8170SKalle Valo nominal_phy = (params->nominal_phy * 1000) / 500; 2230bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2231bdcd8170SKalle Valo "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", 2232bdcd8170SKalle Valo min_phy, nominal_phy); 2233bdcd8170SKalle Valo 2234bdcd8170SKalle Valo params->nominal_phy = nominal_phy; 2235bdcd8170SKalle Valo } else { 2236bdcd8170SKalle Valo params->nominal_phy = 0; 2237bdcd8170SKalle Valo } 2238bdcd8170SKalle Valo 2239bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2240bdcd8170SKalle Valo if (!skb) 2241bdcd8170SKalle Valo return -ENOMEM; 2242bdcd8170SKalle Valo 2243bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2244bdcd8170SKalle Valo "sending create_pstream_cmd: ac=%d tsid:%d\n", 2245bdcd8170SKalle Valo params->traffic_class, params->tsid); 2246bdcd8170SKalle Valo 2247bdcd8170SKalle Valo cmd = (struct wmi_create_pstream_cmd *) skb->data; 2248bdcd8170SKalle Valo memcpy(cmd, params, sizeof(*cmd)); 2249bdcd8170SKalle Valo 2250bdcd8170SKalle Valo /* This is an implicitly created Fat pipe */ 2251bdcd8170SKalle Valo if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { 2252bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2253bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2254bdcd8170SKalle Valo (1 << params->traffic_class)); 2255bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2256bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2257bdcd8170SKalle Valo } else { 2258bdcd8170SKalle Valo /* explicitly created thin stream within a fat pipe */ 2259bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2260bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2261bdcd8170SKalle Valo (1 << params->traffic_class)); 2262bdcd8170SKalle Valo wmi->stream_exist_for_ac[params->traffic_class] |= 2263bdcd8170SKalle Valo (1 << params->tsid); 2264bdcd8170SKalle Valo /* 2265bdcd8170SKalle Valo * If a thinstream becomes active, the fat pipe automatically 2266bdcd8170SKalle Valo * becomes active 2267bdcd8170SKalle Valo */ 2268bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2269bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2270bdcd8170SKalle Valo } 2271bdcd8170SKalle Valo 2272bdcd8170SKalle Valo /* 2273bdcd8170SKalle Valo * Indicate activty change to driver layer only if this is the 2274bdcd8170SKalle Valo * first TSID to get created in this AC explicitly or an implicit 2275bdcd8170SKalle Valo * fat pipe is getting created. 2276bdcd8170SKalle Valo */ 2277bdcd8170SKalle Valo if (!fatpipe_exist_for_ac) 2278bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2279bdcd8170SKalle Valo params->traffic_class, true); 2280bdcd8170SKalle Valo 2281bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID, 2282bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2283bdcd8170SKalle Valo return ret; 2284bdcd8170SKalle Valo } 2285bdcd8170SKalle Valo 2286bdcd8170SKalle Valo int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) 2287bdcd8170SKalle Valo { 2288bdcd8170SKalle Valo struct sk_buff *skb; 2289bdcd8170SKalle Valo struct wmi_delete_pstream_cmd *cmd; 2290bdcd8170SKalle Valo u16 active_tsids = 0; 2291bdcd8170SKalle Valo int ret; 2292bdcd8170SKalle Valo 2293bdcd8170SKalle Valo if (traffic_class > 3) { 2294bdcd8170SKalle Valo ath6kl_err("invalid traffic class: %d\n", traffic_class); 2295bdcd8170SKalle Valo return -EINVAL; 2296bdcd8170SKalle Valo } 2297bdcd8170SKalle Valo 2298bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2299bdcd8170SKalle Valo if (!skb) 2300bdcd8170SKalle Valo return -ENOMEM; 2301bdcd8170SKalle Valo 2302bdcd8170SKalle Valo cmd = (struct wmi_delete_pstream_cmd *) skb->data; 2303bdcd8170SKalle Valo cmd->traffic_class = traffic_class; 2304bdcd8170SKalle Valo cmd->tsid = tsid; 2305bdcd8170SKalle Valo 2306bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2307bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2308bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2309bdcd8170SKalle Valo 2310bdcd8170SKalle Valo if (!(active_tsids & (1 << tsid))) { 2311bdcd8170SKalle Valo dev_kfree_skb(skb); 2312bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2313bdcd8170SKalle Valo "TSID %d doesn't exist for traffic class: %d\n", 2314bdcd8170SKalle Valo tsid, traffic_class); 2315bdcd8170SKalle Valo return -ENODATA; 2316bdcd8170SKalle Valo } 2317bdcd8170SKalle Valo 2318bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2319bdcd8170SKalle Valo "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", 2320bdcd8170SKalle Valo traffic_class, tsid); 2321bdcd8170SKalle Valo 2322bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID, 2323bdcd8170SKalle Valo SYNC_BEFORE_WMIFLAG); 2324bdcd8170SKalle Valo 2325bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2326bdcd8170SKalle Valo wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); 2327bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2328bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2329bdcd8170SKalle Valo 2330bdcd8170SKalle Valo /* 2331bdcd8170SKalle Valo * Indicate stream inactivity to driver layer only if all tsids 2332bdcd8170SKalle Valo * within this AC are deleted. 2333bdcd8170SKalle Valo */ 2334bdcd8170SKalle Valo if (!active_tsids) { 2335bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2336bdcd8170SKalle Valo traffic_class, false); 2337bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << traffic_class); 2338bdcd8170SKalle Valo } 2339bdcd8170SKalle Valo 2340bdcd8170SKalle Valo return ret; 2341bdcd8170SKalle Valo } 2342bdcd8170SKalle Valo 2343bdcd8170SKalle Valo int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) 2344bdcd8170SKalle Valo { 2345bdcd8170SKalle Valo struct sk_buff *skb; 2346bdcd8170SKalle Valo struct wmi_set_ip_cmd *cmd; 2347bdcd8170SKalle Valo int ret; 2348bdcd8170SKalle Valo 2349bdcd8170SKalle Valo /* Multicast address are not valid */ 2350bdcd8170SKalle Valo if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) || 2351bdcd8170SKalle Valo (*((u8 *) &ip_cmd->ips[1]) >= 0xE0)) 2352bdcd8170SKalle Valo return -EINVAL; 2353bdcd8170SKalle Valo 2354bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); 2355bdcd8170SKalle Valo if (!skb) 2356bdcd8170SKalle Valo return -ENOMEM; 2357bdcd8170SKalle Valo 2358bdcd8170SKalle Valo cmd = (struct wmi_set_ip_cmd *) skb->data; 2359bdcd8170SKalle Valo memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); 2360bdcd8170SKalle Valo 2361bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG); 2362bdcd8170SKalle Valo return ret; 2363bdcd8170SKalle Valo } 2364bdcd8170SKalle Valo 2365bdcd8170SKalle Valo static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, 2366bdcd8170SKalle Valo int len) 2367bdcd8170SKalle Valo { 2368bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_wow_list_reply)) 2369bdcd8170SKalle Valo return -EINVAL; 2370bdcd8170SKalle Valo 2371bdcd8170SKalle Valo return 0; 2372bdcd8170SKalle Valo } 2373bdcd8170SKalle Valo 2374bdcd8170SKalle Valo static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, 2375bdcd8170SKalle Valo enum wmix_command_id cmd_id, 2376bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2377bdcd8170SKalle Valo { 2378bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd_hdr; 2379bdcd8170SKalle Valo int ret; 2380bdcd8170SKalle Valo 2381bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmix_cmd_hdr)); 2382bdcd8170SKalle Valo 2383bdcd8170SKalle Valo cmd_hdr = (struct wmix_cmd_hdr *) skb->data; 2384bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le32(cmd_id); 2385bdcd8170SKalle Valo 2386bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag); 2387bdcd8170SKalle Valo 2388bdcd8170SKalle Valo return ret; 2389bdcd8170SKalle Valo } 2390bdcd8170SKalle Valo 2391bdcd8170SKalle Valo int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) 2392bdcd8170SKalle Valo { 2393bdcd8170SKalle Valo struct sk_buff *skb; 2394bdcd8170SKalle Valo struct wmix_hb_challenge_resp_cmd *cmd; 2395bdcd8170SKalle Valo int ret; 2396bdcd8170SKalle Valo 2397bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2398bdcd8170SKalle Valo if (!skb) 2399bdcd8170SKalle Valo return -ENOMEM; 2400bdcd8170SKalle Valo 2401bdcd8170SKalle Valo cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; 2402bdcd8170SKalle Valo cmd->cookie = cpu_to_le32(cookie); 2403bdcd8170SKalle Valo cmd->source = cpu_to_le32(source); 2404bdcd8170SKalle Valo 2405bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, 2406bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2407bdcd8170SKalle Valo return ret; 2408bdcd8170SKalle Valo } 2409bdcd8170SKalle Valo 2410939f1cceSKalle Valo int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config) 2411939f1cceSKalle Valo { 2412939f1cceSKalle Valo struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd; 2413939f1cceSKalle Valo struct sk_buff *skb; 2414939f1cceSKalle Valo int ret; 2415939f1cceSKalle Valo 2416939f1cceSKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2417939f1cceSKalle Valo if (!skb) 2418939f1cceSKalle Valo return -ENOMEM; 2419939f1cceSKalle Valo 2420939f1cceSKalle Valo cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data; 2421939f1cceSKalle Valo cmd->valid = cpu_to_le32(valid); 2422939f1cceSKalle Valo cmd->config = cpu_to_le32(config); 2423939f1cceSKalle Valo 2424939f1cceSKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID, 2425939f1cceSKalle Valo NO_SYNC_WMIFLAG); 2426939f1cceSKalle Valo return ret; 2427939f1cceSKalle Valo } 2428939f1cceSKalle Valo 2429bdcd8170SKalle Valo int ath6kl_wmi_get_stats_cmd(struct wmi *wmi) 2430bdcd8170SKalle Valo { 2431bdcd8170SKalle Valo return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID); 2432bdcd8170SKalle Valo } 2433bdcd8170SKalle Valo 2434bdcd8170SKalle Valo int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) 2435bdcd8170SKalle Valo { 2436bdcd8170SKalle Valo struct sk_buff *skb; 2437bdcd8170SKalle Valo struct wmi_set_tx_pwr_cmd *cmd; 2438bdcd8170SKalle Valo int ret; 2439bdcd8170SKalle Valo 2440bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); 2441bdcd8170SKalle Valo if (!skb) 2442bdcd8170SKalle Valo return -ENOMEM; 2443bdcd8170SKalle Valo 2444bdcd8170SKalle Valo cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; 2445bdcd8170SKalle Valo cmd->dbM = dbM; 2446bdcd8170SKalle Valo 2447bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID, 2448bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2449bdcd8170SKalle Valo 2450bdcd8170SKalle Valo return ret; 2451bdcd8170SKalle Valo } 2452bdcd8170SKalle Valo 2453bdcd8170SKalle Valo int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) 2454bdcd8170SKalle Valo { 2455bdcd8170SKalle Valo return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID); 2456bdcd8170SKalle Valo } 2457bdcd8170SKalle Valo 24584b28a80dSJouni Malinen int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi) 24594b28a80dSJouni Malinen { 24604b28a80dSJouni Malinen return ath6kl_wmi_simple_cmd(wmi, WMI_GET_ROAM_TBL_CMDID); 24614b28a80dSJouni Malinen } 24624b28a80dSJouni Malinen 2463bdcd8170SKalle Valo int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) 2464bdcd8170SKalle Valo { 2465bdcd8170SKalle Valo struct sk_buff *skb; 2466bdcd8170SKalle Valo struct wmi_set_lpreamble_cmd *cmd; 2467bdcd8170SKalle Valo int ret; 2468bdcd8170SKalle Valo 2469bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); 2470bdcd8170SKalle Valo if (!skb) 2471bdcd8170SKalle Valo return -ENOMEM; 2472bdcd8170SKalle Valo 2473bdcd8170SKalle Valo cmd = (struct wmi_set_lpreamble_cmd *) skb->data; 2474bdcd8170SKalle Valo cmd->status = status; 2475bdcd8170SKalle Valo cmd->preamble_policy = preamble_policy; 2476bdcd8170SKalle Valo 2477bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID, 2478bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2479bdcd8170SKalle Valo return ret; 2480bdcd8170SKalle Valo } 2481bdcd8170SKalle Valo 2482bdcd8170SKalle Valo int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) 2483bdcd8170SKalle Valo { 2484bdcd8170SKalle Valo struct sk_buff *skb; 2485bdcd8170SKalle Valo struct wmi_set_rts_cmd *cmd; 2486bdcd8170SKalle Valo int ret; 2487bdcd8170SKalle Valo 2488bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); 2489bdcd8170SKalle Valo if (!skb) 2490bdcd8170SKalle Valo return -ENOMEM; 2491bdcd8170SKalle Valo 2492bdcd8170SKalle Valo cmd = (struct wmi_set_rts_cmd *) skb->data; 2493bdcd8170SKalle Valo cmd->threshold = cpu_to_le16(threshold); 2494bdcd8170SKalle Valo 2495bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG); 2496bdcd8170SKalle Valo return ret; 2497bdcd8170SKalle Valo } 2498bdcd8170SKalle Valo 2499bdcd8170SKalle Valo int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) 2500bdcd8170SKalle Valo { 2501bdcd8170SKalle Valo struct sk_buff *skb; 2502bdcd8170SKalle Valo struct wmi_set_wmm_txop_cmd *cmd; 2503bdcd8170SKalle Valo int ret; 2504bdcd8170SKalle Valo 2505bdcd8170SKalle Valo if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) 2506bdcd8170SKalle Valo return -EINVAL; 2507bdcd8170SKalle Valo 2508bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); 2509bdcd8170SKalle Valo if (!skb) 2510bdcd8170SKalle Valo return -ENOMEM; 2511bdcd8170SKalle Valo 2512bdcd8170SKalle Valo cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; 2513bdcd8170SKalle Valo cmd->txop_enable = cfg; 2514bdcd8170SKalle Valo 2515bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID, 2516bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2517bdcd8170SKalle Valo return ret; 2518bdcd8170SKalle Valo } 2519bdcd8170SKalle Valo 2520bdcd8170SKalle Valo int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) 2521bdcd8170SKalle Valo { 2522bdcd8170SKalle Valo struct sk_buff *skb; 2523bdcd8170SKalle Valo struct wmi_set_keepalive_cmd *cmd; 2524bdcd8170SKalle Valo int ret; 2525bdcd8170SKalle Valo 2526bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2527bdcd8170SKalle Valo if (!skb) 2528bdcd8170SKalle Valo return -ENOMEM; 2529bdcd8170SKalle Valo 2530bdcd8170SKalle Valo cmd = (struct wmi_set_keepalive_cmd *) skb->data; 2531bdcd8170SKalle Valo cmd->keep_alive_intvl = keep_alive_intvl; 2532bdcd8170SKalle Valo 2533bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, 2534bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2535ff0b0075SJouni Malinen if (ret == 0) 2536ff0b0075SJouni Malinen ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl); 2537bdcd8170SKalle Valo return ret; 2538bdcd8170SKalle Valo } 2539bdcd8170SKalle Valo 2540003353b0SKalle Valo int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) 2541003353b0SKalle Valo { 2542003353b0SKalle Valo struct sk_buff *skb; 2543003353b0SKalle Valo int ret; 2544003353b0SKalle Valo 2545003353b0SKalle Valo skb = ath6kl_wmi_get_new_buf(len); 2546003353b0SKalle Valo if (!skb) 2547003353b0SKalle Valo return -ENOMEM; 2548003353b0SKalle Valo 2549003353b0SKalle Valo memcpy(skb->data, buf, len); 2550003353b0SKalle Valo 2551003353b0SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); 2552003353b0SKalle Valo 2553003353b0SKalle Valo return ret; 2554003353b0SKalle Valo } 2555003353b0SKalle Valo 2556003353b0SKalle Valo 2557bdcd8170SKalle Valo s32 ath6kl_wmi_get_rate(s8 rate_index) 2558bdcd8170SKalle Valo { 2559bdcd8170SKalle Valo if (rate_index == RATE_AUTO) 2560bdcd8170SKalle Valo return 0; 2561bdcd8170SKalle Valo 2562bdcd8170SKalle Valo return wmi_rate_tbl[(u32) rate_index][0]; 2563bdcd8170SKalle Valo } 2564bdcd8170SKalle Valo 2565bdcd8170SKalle Valo static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, 2566bdcd8170SKalle Valo u32 len) 2567bdcd8170SKalle Valo { 2568bdcd8170SKalle Valo struct wmi_pmkid_list_reply *reply; 2569bdcd8170SKalle Valo u32 expected_len; 2570bdcd8170SKalle Valo 2571bdcd8170SKalle Valo if (len < sizeof(struct wmi_pmkid_list_reply)) 2572bdcd8170SKalle Valo return -EINVAL; 2573bdcd8170SKalle Valo 2574bdcd8170SKalle Valo reply = (struct wmi_pmkid_list_reply *)datap; 2575bdcd8170SKalle Valo expected_len = sizeof(reply->num_pmkid) + 2576bdcd8170SKalle Valo le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; 2577bdcd8170SKalle Valo 2578bdcd8170SKalle Valo if (len < expected_len) 2579bdcd8170SKalle Valo return -EINVAL; 2580bdcd8170SKalle Valo 2581bdcd8170SKalle Valo return 0; 2582bdcd8170SKalle Valo } 2583bdcd8170SKalle Valo 2584bdcd8170SKalle Valo static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2585bdcd8170SKalle Valo { 2586bdcd8170SKalle Valo struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; 2587bdcd8170SKalle Valo 2588bdcd8170SKalle Valo aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid, 2589bdcd8170SKalle Valo le16_to_cpu(cmd->st_seq_no), cmd->win_sz); 2590bdcd8170SKalle Valo 2591bdcd8170SKalle Valo return 0; 2592bdcd8170SKalle Valo } 2593bdcd8170SKalle Valo 2594bdcd8170SKalle Valo static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2595bdcd8170SKalle Valo { 2596bdcd8170SKalle Valo struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; 2597bdcd8170SKalle Valo 2598bdcd8170SKalle Valo aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid); 2599bdcd8170SKalle Valo 2600bdcd8170SKalle Valo return 0; 2601bdcd8170SKalle Valo } 2602bdcd8170SKalle Valo 2603bdcd8170SKalle Valo /* AP mode functions */ 26046a7c9badSJouni Malinen 26056a7c9badSJouni Malinen int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) 26066a7c9badSJouni Malinen { 26076a7c9badSJouni Malinen struct sk_buff *skb; 26086a7c9badSJouni Malinen struct wmi_connect_cmd *cm; 26096a7c9badSJouni Malinen int res; 26106a7c9badSJouni Malinen 26116a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 26126a7c9badSJouni Malinen if (!skb) 26136a7c9badSJouni Malinen return -ENOMEM; 26146a7c9badSJouni Malinen 26156a7c9badSJouni Malinen cm = (struct wmi_connect_cmd *) skb->data; 26166a7c9badSJouni Malinen memcpy(cm, p, sizeof(*cm)); 26176a7c9badSJouni Malinen 26186a7c9badSJouni Malinen res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID, 26196a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 26206a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " 26216a7c9badSJouni Malinen "ctrl_flags=0x%x-> res=%d\n", 26226a7c9badSJouni Malinen __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), 26236a7c9badSJouni Malinen le32_to_cpu(p->ctrl_flags), res); 26246a7c9badSJouni Malinen return res; 26256a7c9badSJouni Malinen } 26266a7c9badSJouni Malinen 262723875136SJouni Malinen int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason) 262823875136SJouni Malinen { 262923875136SJouni Malinen struct sk_buff *skb; 263023875136SJouni Malinen struct wmi_ap_set_mlme_cmd *cm; 263123875136SJouni Malinen 263223875136SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 263323875136SJouni Malinen if (!skb) 263423875136SJouni Malinen return -ENOMEM; 263523875136SJouni Malinen 263623875136SJouni Malinen cm = (struct wmi_ap_set_mlme_cmd *) skb->data; 263723875136SJouni Malinen memcpy(cm->mac, mac, ETH_ALEN); 263823875136SJouni Malinen cm->reason = cpu_to_le16(reason); 263923875136SJouni Malinen cm->cmd = cmd; 264023875136SJouni Malinen 264123875136SJouni Malinen return ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_SET_MLME_CMDID, 264223875136SJouni Malinen NO_SYNC_WMIFLAG); 264323875136SJouni Malinen } 264423875136SJouni Malinen 2645bdcd8170SKalle Valo static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len) 2646bdcd8170SKalle Valo { 2647bdcd8170SKalle Valo struct wmi_pspoll_event *ev; 2648bdcd8170SKalle Valo 2649bdcd8170SKalle Valo if (len < sizeof(struct wmi_pspoll_event)) 2650bdcd8170SKalle Valo return -EINVAL; 2651bdcd8170SKalle Valo 2652bdcd8170SKalle Valo ev = (struct wmi_pspoll_event *) datap; 2653bdcd8170SKalle Valo 2654bdcd8170SKalle Valo ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid)); 2655bdcd8170SKalle Valo 2656bdcd8170SKalle Valo return 0; 2657bdcd8170SKalle Valo } 2658bdcd8170SKalle Valo 2659bdcd8170SKalle Valo static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len) 2660bdcd8170SKalle Valo { 2661bdcd8170SKalle Valo ath6kl_dtimexpiry_event(wmi->parent_dev); 2662bdcd8170SKalle Valo 2663bdcd8170SKalle Valo return 0; 2664bdcd8170SKalle Valo } 2665bdcd8170SKalle Valo 2666bdcd8170SKalle Valo int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag) 2667bdcd8170SKalle Valo { 2668bdcd8170SKalle Valo struct sk_buff *skb; 2669bdcd8170SKalle Valo struct wmi_ap_set_pvb_cmd *cmd; 2670bdcd8170SKalle Valo int ret; 2671bdcd8170SKalle Valo 2672bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); 2673bdcd8170SKalle Valo if (!skb) 2674bdcd8170SKalle Valo return -ENOMEM; 2675bdcd8170SKalle Valo 2676bdcd8170SKalle Valo cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; 2677bdcd8170SKalle Valo cmd->aid = cpu_to_le16(aid); 2678d6e51e6aSJouni Malinen cmd->rsvd = cpu_to_le16(0); 2679bdcd8170SKalle Valo cmd->flag = cpu_to_le32(flag); 2680bdcd8170SKalle Valo 2681bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID, 2682bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2683bdcd8170SKalle Valo 2684bdcd8170SKalle Valo return 0; 2685bdcd8170SKalle Valo } 2686bdcd8170SKalle Valo 2687bdcd8170SKalle Valo int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, 2688bdcd8170SKalle Valo bool rx_dot11_hdr, bool defrag_on_host) 2689bdcd8170SKalle Valo { 2690bdcd8170SKalle Valo struct sk_buff *skb; 2691bdcd8170SKalle Valo struct wmi_rx_frame_format_cmd *cmd; 2692bdcd8170SKalle Valo int ret; 2693bdcd8170SKalle Valo 2694bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2695bdcd8170SKalle Valo if (!skb) 2696bdcd8170SKalle Valo return -ENOMEM; 2697bdcd8170SKalle Valo 2698bdcd8170SKalle Valo cmd = (struct wmi_rx_frame_format_cmd *) skb->data; 2699bdcd8170SKalle Valo cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; 2700bdcd8170SKalle Valo cmd->defrag_on_host = defrag_on_host ? 1 : 0; 2701bdcd8170SKalle Valo cmd->meta_ver = rx_meta_ver; 2702bdcd8170SKalle Valo 2703bdcd8170SKalle Valo /* Delete the local aggr state, on host */ 2704bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID, 2705bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2706bdcd8170SKalle Valo 2707bdcd8170SKalle Valo return ret; 2708bdcd8170SKalle Valo } 2709bdcd8170SKalle Valo 27106a7c9badSJouni Malinen int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, 27116a7c9badSJouni Malinen u8 ie_len) 27126a7c9badSJouni Malinen { 27136a7c9badSJouni Malinen struct sk_buff *skb; 27146a7c9badSJouni Malinen struct wmi_set_appie_cmd *p; 27156a7c9badSJouni Malinen 27166a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 27176a7c9badSJouni Malinen if (!skb) 27186a7c9badSJouni Malinen return -ENOMEM; 27196a7c9badSJouni Malinen 27206a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " 27216a7c9badSJouni Malinen "ie_len=%u\n", mgmt_frm_type, ie_len); 27226a7c9badSJouni Malinen p = (struct wmi_set_appie_cmd *) skb->data; 27236a7c9badSJouni Malinen p->mgmt_frm_type = mgmt_frm_type; 27246a7c9badSJouni Malinen p->ie_len = ie_len; 27256a7c9badSJouni Malinen memcpy(p->ie_info, ie, ie_len); 27266a7c9badSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID, 27276a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 27286a7c9badSJouni Malinen } 27296a7c9badSJouni Malinen 27306465ddcfSJouni Malinen int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) 27316465ddcfSJouni Malinen { 27326465ddcfSJouni Malinen struct sk_buff *skb; 27336465ddcfSJouni Malinen struct wmi_disable_11b_rates_cmd *cmd; 27346465ddcfSJouni Malinen 27356465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 27366465ddcfSJouni Malinen if (!skb) 27376465ddcfSJouni Malinen return -ENOMEM; 27386465ddcfSJouni Malinen 27396465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", 27406465ddcfSJouni Malinen disable); 27416465ddcfSJouni Malinen cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; 27426465ddcfSJouni Malinen cmd->disable = disable ? 1 : 0; 27436465ddcfSJouni Malinen 27446465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_DISABLE_11B_RATES_CMDID, 27456465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 27466465ddcfSJouni Malinen } 27476465ddcfSJouni Malinen 27486465ddcfSJouni Malinen int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur) 27496465ddcfSJouni Malinen { 27506465ddcfSJouni Malinen struct sk_buff *skb; 27516465ddcfSJouni Malinen struct wmi_remain_on_chnl_cmd *p; 27526465ddcfSJouni Malinen 27536465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 27546465ddcfSJouni Malinen if (!skb) 27556465ddcfSJouni Malinen return -ENOMEM; 27566465ddcfSJouni Malinen 27576465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", 27586465ddcfSJouni Malinen freq, dur); 27596465ddcfSJouni Malinen p = (struct wmi_remain_on_chnl_cmd *) skb->data; 27606465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 27616465ddcfSJouni Malinen p->duration = cpu_to_le32(dur); 27626465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_REMAIN_ON_CHNL_CMDID, 27636465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 27646465ddcfSJouni Malinen } 27656465ddcfSJouni Malinen 27666465ddcfSJouni Malinen int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait, 27676465ddcfSJouni Malinen const u8 *data, u16 data_len) 27686465ddcfSJouni Malinen { 27696465ddcfSJouni Malinen struct sk_buff *skb; 27706465ddcfSJouni Malinen struct wmi_send_action_cmd *p; 2771a0df5db1SJouni Malinen u8 *buf; 27726465ddcfSJouni Malinen 27736465ddcfSJouni Malinen if (wait) 27746465ddcfSJouni Malinen return -EINVAL; /* Offload for wait not supported */ 27756465ddcfSJouni Malinen 2776a0df5db1SJouni Malinen buf = kmalloc(data_len, GFP_KERNEL); 2777a0df5db1SJouni Malinen if (!buf) 27786465ddcfSJouni Malinen return -ENOMEM; 27796465ddcfSJouni Malinen 2780a0df5db1SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 2781a0df5db1SJouni Malinen if (!skb) { 2782a0df5db1SJouni Malinen kfree(buf); 2783a0df5db1SJouni Malinen return -ENOMEM; 2784a0df5db1SJouni Malinen } 2785a0df5db1SJouni Malinen 2786a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 2787a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = buf; 2788a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = data_len; 2789a0df5db1SJouni Malinen 27906465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " 27916465ddcfSJouni Malinen "len=%u\n", id, freq, wait, data_len); 27926465ddcfSJouni Malinen p = (struct wmi_send_action_cmd *) skb->data; 27936465ddcfSJouni Malinen p->id = cpu_to_le32(id); 27946465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 27956465ddcfSJouni Malinen p->wait = cpu_to_le32(wait); 27966465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 27976465ddcfSJouni Malinen memcpy(p->data, data, data_len); 27986465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_ACTION_CMDID, 27996465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28006465ddcfSJouni Malinen } 28016465ddcfSJouni Malinen 28026465ddcfSJouni Malinen int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq, 28036465ddcfSJouni Malinen const u8 *dst, 28046465ddcfSJouni Malinen const u8 *data, u16 data_len) 28056465ddcfSJouni Malinen { 28066465ddcfSJouni Malinen struct sk_buff *skb; 28076465ddcfSJouni Malinen struct wmi_p2p_probe_response_cmd *p; 28086465ddcfSJouni Malinen 28096465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 28106465ddcfSJouni Malinen if (!skb) 28116465ddcfSJouni Malinen return -ENOMEM; 28126465ddcfSJouni Malinen 28136465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM " 28146465ddcfSJouni Malinen "len=%u\n", freq, dst, data_len); 28156465ddcfSJouni Malinen p = (struct wmi_p2p_probe_response_cmd *) skb->data; 28166465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 28176465ddcfSJouni Malinen memcpy(p->destination_addr, dst, ETH_ALEN); 28186465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 28196465ddcfSJouni Malinen memcpy(p->data, data, data_len); 28206465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_PROBE_RESPONSE_CMDID, 28216465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28226465ddcfSJouni Malinen } 28236465ddcfSJouni Malinen 28246465ddcfSJouni Malinen int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable) 28256465ddcfSJouni Malinen { 28266465ddcfSJouni Malinen struct sk_buff *skb; 28276465ddcfSJouni Malinen struct wmi_probe_req_report_cmd *p; 28286465ddcfSJouni Malinen 28296465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 28306465ddcfSJouni Malinen if (!skb) 28316465ddcfSJouni Malinen return -ENOMEM; 28326465ddcfSJouni Malinen 28336465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", 28346465ddcfSJouni Malinen enable); 28356465ddcfSJouni Malinen p = (struct wmi_probe_req_report_cmd *) skb->data; 28366465ddcfSJouni Malinen p->enable = enable ? 1 : 0; 28376465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_PROBE_REQ_REPORT_CMDID, 28386465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28396465ddcfSJouni Malinen } 28406465ddcfSJouni Malinen 28416465ddcfSJouni Malinen int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags) 28426465ddcfSJouni Malinen { 28436465ddcfSJouni Malinen struct sk_buff *skb; 28446465ddcfSJouni Malinen struct wmi_get_p2p_info *p; 28456465ddcfSJouni Malinen 28466465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 28476465ddcfSJouni Malinen if (!skb) 28486465ddcfSJouni Malinen return -ENOMEM; 28496465ddcfSJouni Malinen 28506465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", 28516465ddcfSJouni Malinen info_req_flags); 28526465ddcfSJouni Malinen p = (struct wmi_get_p2p_info *) skb->data; 28536465ddcfSJouni Malinen p->info_req_flags = cpu_to_le32(info_req_flags); 28546465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_GET_P2P_INFO_CMDID, 28556465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28566465ddcfSJouni Malinen } 28576465ddcfSJouni Malinen 28586465ddcfSJouni Malinen int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi) 28596465ddcfSJouni Malinen { 28606465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); 28616465ddcfSJouni Malinen return ath6kl_wmi_simple_cmd(wmi, WMI_CANCEL_REMAIN_ON_CHNL_CMDID); 28626465ddcfSJouni Malinen } 28636465ddcfSJouni Malinen 2864bdcd8170SKalle Valo static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) 2865bdcd8170SKalle Valo { 2866bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd; 2867bdcd8170SKalle Valo u32 len; 2868bdcd8170SKalle Valo u16 id; 2869bdcd8170SKalle Valo u8 *datap; 2870bdcd8170SKalle Valo int ret = 0; 2871bdcd8170SKalle Valo 2872bdcd8170SKalle Valo if (skb->len < sizeof(struct wmix_cmd_hdr)) { 2873bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 2874bdcd8170SKalle Valo return -EINVAL; 2875bdcd8170SKalle Valo } 2876bdcd8170SKalle Valo 2877bdcd8170SKalle Valo cmd = (struct wmix_cmd_hdr *) skb->data; 2878bdcd8170SKalle Valo id = le32_to_cpu(cmd->cmd_id); 2879bdcd8170SKalle Valo 2880bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmix_cmd_hdr)); 2881bdcd8170SKalle Valo 2882bdcd8170SKalle Valo datap = skb->data; 2883bdcd8170SKalle Valo len = skb->len; 2884bdcd8170SKalle Valo 2885bdcd8170SKalle Valo switch (id) { 2886bdcd8170SKalle Valo case WMIX_HB_CHALLENGE_RESP_EVENTID: 2887b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n"); 2888bdcd8170SKalle Valo break; 2889bdcd8170SKalle Valo case WMIX_DBGLOG_EVENTID: 2890b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len); 2891bdf5396bSKalle Valo ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len); 2892bdcd8170SKalle Valo break; 2893bdcd8170SKalle Valo default: 2894b9b6ee60SKalle Valo ath6kl_warn("unknown cmd id 0x%x\n", id); 2895bdcd8170SKalle Valo ret = -EINVAL; 2896bdcd8170SKalle Valo break; 2897bdcd8170SKalle Valo } 2898bdcd8170SKalle Valo 2899bdcd8170SKalle Valo return ret; 2900bdcd8170SKalle Valo } 2901bdcd8170SKalle Valo 29024b28a80dSJouni Malinen static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len) 29034b28a80dSJouni Malinen { 29044b28a80dSJouni Malinen return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len); 29054b28a80dSJouni Malinen } 29064b28a80dSJouni Malinen 2907bdcd8170SKalle Valo /* Control Path */ 2908bdcd8170SKalle Valo int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) 2909bdcd8170SKalle Valo { 2910bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd; 2911bdcd8170SKalle Valo u32 len; 2912bdcd8170SKalle Valo u16 id; 2913bdcd8170SKalle Valo u8 *datap; 2914bdcd8170SKalle Valo int ret = 0; 2915bdcd8170SKalle Valo 2916bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 2917bdcd8170SKalle Valo return -EINVAL; 2918bdcd8170SKalle Valo 2919bdcd8170SKalle Valo if (skb->len < sizeof(struct wmi_cmd_hdr)) { 2920bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 2921bdcd8170SKalle Valo dev_kfree_skb(skb); 2922bdcd8170SKalle Valo return -EINVAL; 2923bdcd8170SKalle Valo } 2924bdcd8170SKalle Valo 2925bdcd8170SKalle Valo cmd = (struct wmi_cmd_hdr *) skb->data; 2926bdcd8170SKalle Valo id = le16_to_cpu(cmd->cmd_id); 2927bdcd8170SKalle Valo 2928bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmi_cmd_hdr)); 2929bdcd8170SKalle Valo 2930bdcd8170SKalle Valo datap = skb->data; 2931bdcd8170SKalle Valo len = skb->len; 2932bdcd8170SKalle Valo 2933b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len); 2934b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ", 2935ef094103SKalle Valo datap, len); 2936bdcd8170SKalle Valo 2937bdcd8170SKalle Valo switch (id) { 2938bdcd8170SKalle Valo case WMI_GET_BITRATE_CMDID: 2939bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); 2940bdcd8170SKalle Valo ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); 2941bdcd8170SKalle Valo break; 2942bdcd8170SKalle Valo case WMI_GET_CHANNEL_LIST_CMDID: 2943bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); 2944bdcd8170SKalle Valo ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); 2945bdcd8170SKalle Valo break; 2946bdcd8170SKalle Valo case WMI_GET_TX_PWR_CMDID: 2947bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); 2948bdcd8170SKalle Valo ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); 2949bdcd8170SKalle Valo break; 2950bdcd8170SKalle Valo case WMI_READY_EVENTID: 2951bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); 2952bdcd8170SKalle Valo ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); 2953bdcd8170SKalle Valo break; 2954bdcd8170SKalle Valo case WMI_CONNECT_EVENTID: 2955bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); 2956bdcd8170SKalle Valo ret = ath6kl_wmi_connect_event_rx(wmi, datap, len); 2957bdcd8170SKalle Valo break; 2958bdcd8170SKalle Valo case WMI_DISCONNECT_EVENTID: 2959bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); 2960bdcd8170SKalle Valo ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len); 2961bdcd8170SKalle Valo break; 2962bdcd8170SKalle Valo case WMI_PEER_NODE_EVENTID: 2963bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); 2964bdcd8170SKalle Valo ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); 2965bdcd8170SKalle Valo break; 2966bdcd8170SKalle Valo case WMI_TKIP_MICERR_EVENTID: 2967bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); 2968bdcd8170SKalle Valo ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len); 2969bdcd8170SKalle Valo break; 2970bdcd8170SKalle Valo case WMI_BSSINFO_EVENTID: 2971bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); 297282e14f56SJouni Malinen ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len); 2973bdcd8170SKalle Valo break; 2974bdcd8170SKalle Valo case WMI_REGDOMAIN_EVENTID: 2975bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); 297606033760SVivek Natarajan ath6kl_wmi_regdomain_event(wmi, datap, len); 2977bdcd8170SKalle Valo break; 2978bdcd8170SKalle Valo case WMI_PSTREAM_TIMEOUT_EVENTID: 2979bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); 2980bdcd8170SKalle Valo ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); 2981bdcd8170SKalle Valo break; 2982bdcd8170SKalle Valo case WMI_NEIGHBOR_REPORT_EVENTID: 2983bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); 298486512136SJouni Malinen ret = ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len); 2985bdcd8170SKalle Valo break; 2986bdcd8170SKalle Valo case WMI_SCAN_COMPLETE_EVENTID: 2987bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); 2988bdcd8170SKalle Valo ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len); 2989bdcd8170SKalle Valo break; 2990bdcd8170SKalle Valo case WMI_CMDERROR_EVENTID: 2991bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); 2992bdcd8170SKalle Valo ret = ath6kl_wmi_error_event_rx(wmi, datap, len); 2993bdcd8170SKalle Valo break; 2994bdcd8170SKalle Valo case WMI_REPORT_STATISTICS_EVENTID: 2995bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); 2996bdcd8170SKalle Valo ret = ath6kl_wmi_stats_event_rx(wmi, datap, len); 2997bdcd8170SKalle Valo break; 2998bdcd8170SKalle Valo case WMI_RSSI_THRESHOLD_EVENTID: 2999bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); 3000bdcd8170SKalle Valo ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); 3001bdcd8170SKalle Valo break; 3002bdcd8170SKalle Valo case WMI_ERROR_REPORT_EVENTID: 3003bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); 3004bdcd8170SKalle Valo break; 3005bdcd8170SKalle Valo case WMI_OPT_RX_FRAME_EVENTID: 3006bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); 3007f195d507SJouni Malinen /* this event has been deprecated */ 3008bdcd8170SKalle Valo break; 3009bdcd8170SKalle Valo case WMI_REPORT_ROAM_TBL_EVENTID: 3010bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); 30114b28a80dSJouni Malinen ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len); 3012bdcd8170SKalle Valo break; 3013bdcd8170SKalle Valo case WMI_EXTENSION_EVENTID: 3014bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); 3015bdcd8170SKalle Valo ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); 3016bdcd8170SKalle Valo break; 3017bdcd8170SKalle Valo case WMI_CAC_EVENTID: 3018bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); 3019bdcd8170SKalle Valo ret = ath6kl_wmi_cac_event_rx(wmi, datap, len); 3020bdcd8170SKalle Valo break; 3021bdcd8170SKalle Valo case WMI_CHANNEL_CHANGE_EVENTID: 3022bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); 3023bdcd8170SKalle Valo break; 3024bdcd8170SKalle Valo case WMI_REPORT_ROAM_DATA_EVENTID: 3025bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); 3026bdcd8170SKalle Valo break; 3027003353b0SKalle Valo case WMI_TEST_EVENTID: 3028003353b0SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n"); 3029003353b0SKalle Valo ret = ath6kl_wmi_tcmd_test_report_rx(wmi, datap, len); 3030003353b0SKalle Valo break; 3031bdcd8170SKalle Valo case WMI_GET_FIXRATES_CMDID: 3032bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); 3033bdcd8170SKalle Valo ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); 3034bdcd8170SKalle Valo break; 3035bdcd8170SKalle Valo case WMI_TX_RETRY_ERR_EVENTID: 3036bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); 3037bdcd8170SKalle Valo break; 3038bdcd8170SKalle Valo case WMI_SNR_THRESHOLD_EVENTID: 3039bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); 3040bdcd8170SKalle Valo ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); 3041bdcd8170SKalle Valo break; 3042bdcd8170SKalle Valo case WMI_LQ_THRESHOLD_EVENTID: 3043bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); 3044bdcd8170SKalle Valo break; 3045bdcd8170SKalle Valo case WMI_APLIST_EVENTID: 3046bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); 3047bdcd8170SKalle Valo ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); 3048bdcd8170SKalle Valo break; 3049bdcd8170SKalle Valo case WMI_GET_KEEPALIVE_CMDID: 3050bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); 3051bdcd8170SKalle Valo ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); 3052bdcd8170SKalle Valo break; 3053bdcd8170SKalle Valo case WMI_GET_WOW_LIST_EVENTID: 3054bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); 3055bdcd8170SKalle Valo ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len); 3056bdcd8170SKalle Valo break; 3057bdcd8170SKalle Valo case WMI_GET_PMKID_LIST_EVENTID: 3058bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); 3059bdcd8170SKalle Valo ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); 3060bdcd8170SKalle Valo break; 3061bdcd8170SKalle Valo case WMI_PSPOLL_EVENTID: 3062bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); 3063bdcd8170SKalle Valo ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len); 3064bdcd8170SKalle Valo break; 3065bdcd8170SKalle Valo case WMI_DTIMEXPIRY_EVENTID: 3066bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); 3067bdcd8170SKalle Valo ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len); 3068bdcd8170SKalle Valo break; 3069bdcd8170SKalle Valo case WMI_SET_PARAMS_REPLY_EVENTID: 3070bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); 3071bdcd8170SKalle Valo break; 3072bdcd8170SKalle Valo case WMI_ADDBA_REQ_EVENTID: 3073bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); 3074bdcd8170SKalle Valo ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len); 3075bdcd8170SKalle Valo break; 3076bdcd8170SKalle Valo case WMI_ADDBA_RESP_EVENTID: 3077bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); 3078bdcd8170SKalle Valo break; 3079bdcd8170SKalle Valo case WMI_DELBA_REQ_EVENTID: 3080bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); 3081bdcd8170SKalle Valo ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len); 3082bdcd8170SKalle Valo break; 3083bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_CONFIG_EVENTID: 3084bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3085bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); 3086bdcd8170SKalle Valo break; 3087bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_STATS_EVENTID: 3088bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3089bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); 3090bdcd8170SKalle Valo break; 3091bdcd8170SKalle Valo case WMI_TX_COMPLETE_EVENTID: 3092bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); 3093bdcd8170SKalle Valo ret = ath6kl_wmi_tx_complete_event_rx(datap, len); 3094bdcd8170SKalle Valo break; 30956465ddcfSJouni Malinen case WMI_REMAIN_ON_CHNL_EVENTID: 30966465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); 3097f9e5f05cSJouni Malinen ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len); 30986465ddcfSJouni Malinen break; 30996465ddcfSJouni Malinen case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: 31006465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, 31016465ddcfSJouni Malinen "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); 3102f9e5f05cSJouni Malinen ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, 3103f9e5f05cSJouni Malinen len); 31046465ddcfSJouni Malinen break; 31056465ddcfSJouni Malinen case WMI_TX_STATUS_EVENTID: 31066465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); 3107a0df5db1SJouni Malinen ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len); 31086465ddcfSJouni Malinen break; 31096465ddcfSJouni Malinen case WMI_RX_PROBE_REQ_EVENTID: 31106465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); 3111ae32c30aSJouni Malinen ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len); 31126465ddcfSJouni Malinen break; 31136465ddcfSJouni Malinen case WMI_P2P_CAPABILITIES_EVENTID: 31146465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); 31156465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); 31166465ddcfSJouni Malinen break; 31176465ddcfSJouni Malinen case WMI_RX_ACTION_EVENTID: 31186465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); 31199809d8efSJouni Malinen ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len); 31206465ddcfSJouni Malinen break; 31216465ddcfSJouni Malinen case WMI_P2P_INFO_EVENTID: 31226465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); 31236465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_info_event_rx(datap, len); 31246465ddcfSJouni Malinen break; 3125bdcd8170SKalle Valo default: 3126bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); 3127bdcd8170SKalle Valo ret = -EINVAL; 3128bdcd8170SKalle Valo break; 3129bdcd8170SKalle Valo } 3130bdcd8170SKalle Valo 3131bdcd8170SKalle Valo dev_kfree_skb(skb); 3132bdcd8170SKalle Valo 3133bdcd8170SKalle Valo return ret; 3134bdcd8170SKalle Valo } 3135bdcd8170SKalle Valo 3136bdcd8170SKalle Valo static void ath6kl_wmi_qos_state_init(struct wmi *wmi) 3137bdcd8170SKalle Valo { 3138bdcd8170SKalle Valo if (!wmi) 3139bdcd8170SKalle Valo return; 3140bdcd8170SKalle Valo 3141bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 3142bdcd8170SKalle Valo 3143bdcd8170SKalle Valo wmi->fat_pipe_exist = 0; 3144bdcd8170SKalle Valo memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); 3145bdcd8170SKalle Valo 3146bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 3147bdcd8170SKalle Valo } 3148bdcd8170SKalle Valo 31492865785eSVasanthakumar Thiagarajan void *ath6kl_wmi_init(struct ath6kl *dev) 3150bdcd8170SKalle Valo { 3151bdcd8170SKalle Valo struct wmi *wmi; 3152bdcd8170SKalle Valo 3153bdcd8170SKalle Valo wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); 3154bdcd8170SKalle Valo if (!wmi) 3155bdcd8170SKalle Valo return NULL; 3156bdcd8170SKalle Valo 3157bdcd8170SKalle Valo spin_lock_init(&wmi->lock); 3158bdcd8170SKalle Valo 3159bdcd8170SKalle Valo wmi->parent_dev = dev; 3160bdcd8170SKalle Valo 3161bdcd8170SKalle Valo wmi->pwr_mode = REC_POWER; 3162bdcd8170SKalle Valo 3163a7f0c58bSKalle Valo ath6kl_wmi_qos_state_init(wmi); 3164bdcd8170SKalle Valo 3165bdcd8170SKalle Valo return wmi; 3166bdcd8170SKalle Valo } 3167bdcd8170SKalle Valo 3168bdcd8170SKalle Valo void ath6kl_wmi_shutdown(struct wmi *wmi) 3169bdcd8170SKalle Valo { 3170bdcd8170SKalle Valo if (!wmi) 3171bdcd8170SKalle Valo return; 3172bdcd8170SKalle Valo 3173a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 3174bdcd8170SKalle Valo kfree(wmi); 3175bdcd8170SKalle Valo } 3176