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 265bdcd8170SKalle Valo /* workaround for WMM S5 */ 266bdcd8170SKalle Valo if ((wmi->traffic_class == WMM_AC_VI) && 267bdcd8170SKalle Valo ((usr_pri == 5) || (usr_pri == 4))) 268bdcd8170SKalle Valo usr_pri = 1; 269bdcd8170SKalle Valo 270bdcd8170SKalle Valo /* Convert user priority to traffic class */ 271bdcd8170SKalle Valo traffic_class = up_to_ac[usr_pri & 0x7]; 272bdcd8170SKalle Valo 273bdcd8170SKalle Valo wmi_data_hdr_set_up(data_hdr, usr_pri); 274bdcd8170SKalle Valo 275bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 276bdcd8170SKalle Valo stream_exist = wmi->fat_pipe_exist; 277bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 278bdcd8170SKalle Valo 279bdcd8170SKalle Valo if (!(stream_exist & (1 << traffic_class))) { 280bdcd8170SKalle Valo memset(&cmd, 0, sizeof(cmd)); 281bdcd8170SKalle Valo cmd.traffic_class = traffic_class; 282bdcd8170SKalle Valo cmd.user_pri = usr_pri; 283bdcd8170SKalle Valo cmd.inactivity_int = 284bdcd8170SKalle Valo cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); 285bdcd8170SKalle Valo /* Implicit streams are created with TSID 0xFF */ 286bdcd8170SKalle Valo cmd.tsid = WMI_IMPLICIT_PSTREAM; 287bdcd8170SKalle Valo ath6kl_wmi_create_pstream_cmd(wmi, &cmd); 288bdcd8170SKalle Valo } 289bdcd8170SKalle Valo 290bdcd8170SKalle Valo *ac = traffic_class; 291bdcd8170SKalle Valo 292bdcd8170SKalle Valo return 0; 293bdcd8170SKalle Valo } 294bdcd8170SKalle Valo 295bdcd8170SKalle Valo int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) 296bdcd8170SKalle Valo { 297bdcd8170SKalle Valo struct ieee80211_hdr_3addr *pwh, wh; 298bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 299bdcd8170SKalle Valo struct ethhdr eth_hdr; 300bdcd8170SKalle Valo u32 hdr_size; 301bdcd8170SKalle Valo u8 *datap; 302bdcd8170SKalle Valo __le16 sub_type; 303bdcd8170SKalle Valo 304bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 305bdcd8170SKalle Valo return -EINVAL; 306bdcd8170SKalle Valo 307bdcd8170SKalle Valo datap = skb->data; 308bdcd8170SKalle Valo pwh = (struct ieee80211_hdr_3addr *) datap; 309bdcd8170SKalle Valo 310bdcd8170SKalle Valo sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); 311bdcd8170SKalle Valo 312bdcd8170SKalle Valo memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); 313bdcd8170SKalle Valo 314bdcd8170SKalle Valo /* Strip off the 802.11 header */ 315bdcd8170SKalle Valo if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { 316bdcd8170SKalle Valo hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), 317bdcd8170SKalle Valo sizeof(u32)); 318bdcd8170SKalle Valo skb_pull(skb, hdr_size); 319bdcd8170SKalle Valo } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) 320bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); 321bdcd8170SKalle Valo 322bdcd8170SKalle Valo datap = skb->data; 323bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); 324bdcd8170SKalle Valo 325c8790cbaSRaja Mani memset(ð_hdr, 0, sizeof(eth_hdr)); 326bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 327bdcd8170SKalle Valo 328bdcd8170SKalle Valo switch ((le16_to_cpu(wh.frame_control)) & 329bdcd8170SKalle Valo (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 330bdcd8170SKalle Valo case 0: 331bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 332bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 333bdcd8170SKalle Valo break; 334bdcd8170SKalle Valo case IEEE80211_FCTL_TODS: 335bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); 336bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 337bdcd8170SKalle Valo break; 338bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS: 339bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 340bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); 341bdcd8170SKalle Valo break; 342bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: 343bdcd8170SKalle Valo break; 344bdcd8170SKalle Valo } 345bdcd8170SKalle Valo 346bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 347bdcd8170SKalle Valo skb_push(skb, sizeof(eth_hdr)); 348bdcd8170SKalle Valo 349bdcd8170SKalle Valo datap = skb->data; 350bdcd8170SKalle Valo 351bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 352bdcd8170SKalle Valo 353bdcd8170SKalle Valo return 0; 354bdcd8170SKalle Valo } 355bdcd8170SKalle Valo 356bdcd8170SKalle Valo /* 357bdcd8170SKalle Valo * Performs 802.3 to DIX encapsulation for received packets. 358bdcd8170SKalle Valo * Assumes the entire 802.3 header is contigous. 359bdcd8170SKalle Valo */ 360bdcd8170SKalle Valo int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) 361bdcd8170SKalle Valo { 362bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 363bdcd8170SKalle Valo struct ethhdr eth_hdr; 364bdcd8170SKalle Valo u8 *datap; 365bdcd8170SKalle Valo 366bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 367bdcd8170SKalle Valo return -EINVAL; 368bdcd8170SKalle Valo 369bdcd8170SKalle Valo datap = skb->data; 370bdcd8170SKalle Valo 371bdcd8170SKalle Valo memcpy(ð_hdr, datap, sizeof(eth_hdr)); 372bdcd8170SKalle Valo 373bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); 374bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 375bdcd8170SKalle Valo 376bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 377bdcd8170SKalle Valo datap = skb->data; 378bdcd8170SKalle Valo 379bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 380bdcd8170SKalle Valo 381bdcd8170SKalle Valo return 0; 382bdcd8170SKalle Valo } 383bdcd8170SKalle Valo 384bdcd8170SKalle Valo static void ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(struct sk_buff *skb, 385bdcd8170SKalle Valo u8 *datap) 386bdcd8170SKalle Valo { 387bdcd8170SKalle Valo struct wmi_bss_info_hdr2 bih2; 388bdcd8170SKalle Valo struct wmi_bss_info_hdr *bih; 389bdcd8170SKalle Valo 390bdcd8170SKalle Valo memcpy(&bih2, datap, sizeof(struct wmi_bss_info_hdr2)); 391bdcd8170SKalle Valo 392bdcd8170SKalle Valo skb_push(skb, 4); 393bdcd8170SKalle Valo bih = (struct wmi_bss_info_hdr *) skb->data; 394bdcd8170SKalle Valo 395bdcd8170SKalle Valo bih->ch = bih2.ch; 396bdcd8170SKalle Valo bih->frame_type = bih2.frame_type; 397bdcd8170SKalle Valo bih->snr = bih2.snr; 398bdcd8170SKalle Valo bih->rssi = a_cpu_to_sle16(bih2.snr - 95); 399bdcd8170SKalle Valo bih->ie_mask = cpu_to_le32(le16_to_cpu(bih2.ie_mask)); 400bdcd8170SKalle Valo memcpy(bih->bssid, bih2.bssid, ETH_ALEN); 401bdcd8170SKalle Valo } 402bdcd8170SKalle Valo 403bdcd8170SKalle Valo static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) 404bdcd8170SKalle Valo { 405bdcd8170SKalle Valo struct tx_complete_msg_v1 *msg_v1; 406bdcd8170SKalle Valo struct wmi_tx_complete_event *evt; 407bdcd8170SKalle Valo int index; 408bdcd8170SKalle Valo u16 size; 409bdcd8170SKalle Valo 410bdcd8170SKalle Valo evt = (struct wmi_tx_complete_event *) datap; 411bdcd8170SKalle Valo 412bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", 413bdcd8170SKalle Valo evt->num_msg, evt->msg_len, evt->msg_type); 414bdcd8170SKalle Valo 415bdcd8170SKalle Valo if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI)) 416bdcd8170SKalle Valo return 0; 417bdcd8170SKalle Valo 418bdcd8170SKalle Valo for (index = 0; index < evt->num_msg; index++) { 419bdcd8170SKalle Valo size = sizeof(struct wmi_tx_complete_event) + 420bdcd8170SKalle Valo (index * sizeof(struct tx_complete_msg_v1)); 421bdcd8170SKalle Valo msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); 422bdcd8170SKalle Valo 423bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", 424bdcd8170SKalle Valo msg_v1->status, msg_v1->pkt_id, 425bdcd8170SKalle Valo msg_v1->rate_idx, msg_v1->ack_failures); 426bdcd8170SKalle Valo } 427bdcd8170SKalle Valo 428bdcd8170SKalle Valo return 0; 429bdcd8170SKalle Valo } 430bdcd8170SKalle Valo 431f9e5f05cSJouni Malinen static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, 432f9e5f05cSJouni Malinen int len) 4336465ddcfSJouni Malinen { 4346465ddcfSJouni Malinen struct wmi_remain_on_chnl_event *ev; 4356465ddcfSJouni Malinen u32 freq; 4366465ddcfSJouni Malinen u32 dur; 437f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 438f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4396465ddcfSJouni Malinen 4406465ddcfSJouni Malinen if (len < sizeof(*ev)) 4416465ddcfSJouni Malinen return -EINVAL; 4426465ddcfSJouni Malinen 4436465ddcfSJouni Malinen ev = (struct wmi_remain_on_chnl_event *) datap; 4446465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4456465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4466465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", 4476465ddcfSJouni Malinen freq, dur); 448f9e5f05cSJouni Malinen chan = ieee80211_get_channel(ar->wdev->wiphy, freq); 449f9e5f05cSJouni Malinen if (!chan) { 450f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " 451f9e5f05cSJouni Malinen "(freq=%u)\n", freq); 452f9e5f05cSJouni Malinen return -EINVAL; 453f9e5f05cSJouni Malinen } 454f9e5f05cSJouni Malinen cfg80211_ready_on_channel(ar->net_dev, 1, chan, NL80211_CHAN_NO_HT, 455f9e5f05cSJouni Malinen dur, GFP_ATOMIC); 4566465ddcfSJouni Malinen 4576465ddcfSJouni Malinen return 0; 4586465ddcfSJouni Malinen } 4596465ddcfSJouni Malinen 460f9e5f05cSJouni Malinen static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, 461f9e5f05cSJouni Malinen u8 *datap, int len) 4626465ddcfSJouni Malinen { 4636465ddcfSJouni Malinen struct wmi_cancel_remain_on_chnl_event *ev; 4646465ddcfSJouni Malinen u32 freq; 4656465ddcfSJouni Malinen u32 dur; 466f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 467f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4686465ddcfSJouni Malinen 4696465ddcfSJouni Malinen if (len < sizeof(*ev)) 4706465ddcfSJouni Malinen return -EINVAL; 4716465ddcfSJouni Malinen 4726465ddcfSJouni Malinen ev = (struct wmi_cancel_remain_on_chnl_event *) datap; 4736465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4746465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4756465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " 4766465ddcfSJouni Malinen "status=%u\n", freq, dur, ev->status); 477f9e5f05cSJouni Malinen chan = ieee80211_get_channel(ar->wdev->wiphy, freq); 478f9e5f05cSJouni Malinen if (!chan) { 479f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " 480f9e5f05cSJouni Malinen "channel (freq=%u)\n", freq); 481f9e5f05cSJouni Malinen return -EINVAL; 482f9e5f05cSJouni Malinen } 483f9e5f05cSJouni Malinen cfg80211_remain_on_channel_expired(ar->net_dev, 1, chan, 484f9e5f05cSJouni Malinen NL80211_CHAN_NO_HT, GFP_ATOMIC); 4856465ddcfSJouni Malinen 4866465ddcfSJouni Malinen return 0; 4876465ddcfSJouni Malinen } 4886465ddcfSJouni Malinen 489a0df5db1SJouni Malinen static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len) 4906465ddcfSJouni Malinen { 4916465ddcfSJouni Malinen struct wmi_tx_status_event *ev; 4926465ddcfSJouni Malinen u32 id; 493a0df5db1SJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4946465ddcfSJouni Malinen 4956465ddcfSJouni Malinen if (len < sizeof(*ev)) 4966465ddcfSJouni Malinen return -EINVAL; 4976465ddcfSJouni Malinen 4986465ddcfSJouni Malinen ev = (struct wmi_tx_status_event *) datap; 4996465ddcfSJouni Malinen id = le32_to_cpu(ev->id); 5006465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", 5016465ddcfSJouni Malinen id, ev->ack_status); 502a0df5db1SJouni Malinen if (wmi->last_mgmt_tx_frame) { 503a0df5db1SJouni Malinen cfg80211_mgmt_tx_status(ar->net_dev, id, 504a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame, 505a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len, 506a0df5db1SJouni Malinen !!ev->ack_status, GFP_ATOMIC); 507a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 508a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = NULL; 509a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = 0; 510a0df5db1SJouni Malinen } 5116465ddcfSJouni Malinen 5126465ddcfSJouni Malinen return 0; 5136465ddcfSJouni Malinen } 5146465ddcfSJouni Malinen 515ae32c30aSJouni Malinen static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) 5166465ddcfSJouni Malinen { 5176465ddcfSJouni Malinen struct wmi_p2p_rx_probe_req_event *ev; 518ae32c30aSJouni Malinen u32 freq; 5196465ddcfSJouni Malinen u16 dlen; 520ae32c30aSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 5216465ddcfSJouni Malinen 5226465ddcfSJouni Malinen if (len < sizeof(*ev)) 5236465ddcfSJouni Malinen return -EINVAL; 5246465ddcfSJouni Malinen 5256465ddcfSJouni Malinen ev = (struct wmi_p2p_rx_probe_req_event *) datap; 526ae32c30aSJouni Malinen freq = le32_to_cpu(ev->freq); 5276465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 528ae32c30aSJouni Malinen if (datap + len < ev->data + dlen) { 529ae32c30aSJouni Malinen ath6kl_err("invalid wmi_p2p_rx_probe_req_event: " 530ae32c30aSJouni Malinen "len=%d dlen=%u\n", len, dlen); 531ae32c30aSJouni Malinen return -EINVAL; 532ae32c30aSJouni Malinen } 533ae32c30aSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u " 534ae32c30aSJouni Malinen "probe_req_report=%d\n", 535ae32c30aSJouni Malinen dlen, freq, ar->probe_req_report); 536ae32c30aSJouni Malinen 537ae32c30aSJouni Malinen if (ar->probe_req_report || ar->nw_type == AP_NETWORK) 538ae32c30aSJouni Malinen cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); 5396465ddcfSJouni Malinen 5406465ddcfSJouni Malinen return 0; 5416465ddcfSJouni Malinen } 5426465ddcfSJouni Malinen 5436465ddcfSJouni Malinen static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) 5446465ddcfSJouni Malinen { 5456465ddcfSJouni Malinen struct wmi_p2p_capabilities_event *ev; 5466465ddcfSJouni Malinen u16 dlen; 5476465ddcfSJouni Malinen 5486465ddcfSJouni Malinen if (len < sizeof(*ev)) 5496465ddcfSJouni Malinen return -EINVAL; 5506465ddcfSJouni Malinen 5516465ddcfSJouni Malinen ev = (struct wmi_p2p_capabilities_event *) datap; 5526465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5536465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); 5546465ddcfSJouni Malinen 5556465ddcfSJouni Malinen return 0; 5566465ddcfSJouni Malinen } 5576465ddcfSJouni Malinen 5589809d8efSJouni Malinen static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len) 5596465ddcfSJouni Malinen { 5606465ddcfSJouni Malinen struct wmi_rx_action_event *ev; 5619809d8efSJouni Malinen u32 freq; 5626465ddcfSJouni Malinen u16 dlen; 5639809d8efSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 5646465ddcfSJouni Malinen 5656465ddcfSJouni Malinen if (len < sizeof(*ev)) 5666465ddcfSJouni Malinen return -EINVAL; 5676465ddcfSJouni Malinen 5686465ddcfSJouni Malinen ev = (struct wmi_rx_action_event *) datap; 5699809d8efSJouni Malinen freq = le32_to_cpu(ev->freq); 5706465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5719809d8efSJouni Malinen if (datap + len < ev->data + dlen) { 5729809d8efSJouni Malinen ath6kl_err("invalid wmi_rx_action_event: " 5739809d8efSJouni Malinen "len=%d dlen=%u\n", len, dlen); 5749809d8efSJouni Malinen return -EINVAL; 5759809d8efSJouni Malinen } 5769809d8efSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); 5779809d8efSJouni Malinen cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); 5786465ddcfSJouni Malinen 5796465ddcfSJouni Malinen return 0; 5806465ddcfSJouni Malinen } 5816465ddcfSJouni Malinen 5826465ddcfSJouni Malinen static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) 5836465ddcfSJouni Malinen { 5846465ddcfSJouni Malinen struct wmi_p2p_info_event *ev; 5856465ddcfSJouni Malinen u32 flags; 5866465ddcfSJouni Malinen u16 dlen; 5876465ddcfSJouni Malinen 5886465ddcfSJouni Malinen if (len < sizeof(*ev)) 5896465ddcfSJouni Malinen return -EINVAL; 5906465ddcfSJouni Malinen 5916465ddcfSJouni Malinen ev = (struct wmi_p2p_info_event *) datap; 5926465ddcfSJouni Malinen flags = le32_to_cpu(ev->info_req_flags); 5936465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5946465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); 5956465ddcfSJouni Malinen 5966465ddcfSJouni Malinen if (flags & P2P_FLAG_CAPABILITIES_REQ) { 5976465ddcfSJouni Malinen struct wmi_p2p_capabilities *cap; 5986465ddcfSJouni Malinen if (dlen < sizeof(*cap)) 5996465ddcfSJouni Malinen return -EINVAL; 6006465ddcfSJouni Malinen cap = (struct wmi_p2p_capabilities *) ev->data; 6016465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", 6026465ddcfSJouni Malinen cap->go_power_save); 6036465ddcfSJouni Malinen } 6046465ddcfSJouni Malinen 6056465ddcfSJouni Malinen if (flags & P2P_FLAG_MACADDR_REQ) { 6066465ddcfSJouni Malinen struct wmi_p2p_macaddr *mac; 6076465ddcfSJouni Malinen if (dlen < sizeof(*mac)) 6086465ddcfSJouni Malinen return -EINVAL; 6096465ddcfSJouni Malinen mac = (struct wmi_p2p_macaddr *) ev->data; 6106465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", 6116465ddcfSJouni Malinen mac->mac_addr); 6126465ddcfSJouni Malinen } 6136465ddcfSJouni Malinen 6146465ddcfSJouni Malinen if (flags & P2P_FLAG_HMODEL_REQ) { 6156465ddcfSJouni Malinen struct wmi_p2p_hmodel *mod; 6166465ddcfSJouni Malinen if (dlen < sizeof(*mod)) 6176465ddcfSJouni Malinen return -EINVAL; 6186465ddcfSJouni Malinen mod = (struct wmi_p2p_hmodel *) ev->data; 6196465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", 6206465ddcfSJouni Malinen mod->p2p_model, 6216465ddcfSJouni Malinen mod->p2p_model ? "host" : "firmware"); 6226465ddcfSJouni Malinen } 6236465ddcfSJouni Malinen return 0; 6246465ddcfSJouni Malinen } 6256465ddcfSJouni Malinen 626bdcd8170SKalle Valo static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) 627bdcd8170SKalle Valo { 628bdcd8170SKalle Valo struct sk_buff *skb; 629bdcd8170SKalle Valo 630bdcd8170SKalle Valo skb = ath6kl_buf_alloc(size); 631bdcd8170SKalle Valo if (!skb) 632bdcd8170SKalle Valo return NULL; 633bdcd8170SKalle Valo 634bdcd8170SKalle Valo skb_put(skb, size); 635bdcd8170SKalle Valo if (size) 636bdcd8170SKalle Valo memset(skb->data, 0, size); 637bdcd8170SKalle Valo 638bdcd8170SKalle Valo return skb; 639bdcd8170SKalle Valo } 640bdcd8170SKalle Valo 641bdcd8170SKalle Valo /* Send a "simple" wmi command -- one with no arguments */ 642bdcd8170SKalle Valo static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id) 643bdcd8170SKalle Valo { 644bdcd8170SKalle Valo struct sk_buff *skb; 645bdcd8170SKalle Valo int ret; 646bdcd8170SKalle Valo 647bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(0); 648bdcd8170SKalle Valo if (!skb) 649bdcd8170SKalle Valo return -ENOMEM; 650bdcd8170SKalle Valo 651bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG); 652bdcd8170SKalle Valo 653bdcd8170SKalle Valo return ret; 654bdcd8170SKalle Valo } 655bdcd8170SKalle Valo 656bdcd8170SKalle Valo static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) 657bdcd8170SKalle Valo { 658bdcd8170SKalle Valo struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; 659bdcd8170SKalle Valo 660bdcd8170SKalle Valo if (len < sizeof(struct wmi_ready_event_2)) 661bdcd8170SKalle Valo return -EINVAL; 662bdcd8170SKalle Valo 663bdcd8170SKalle Valo wmi->ready = true; 664bdcd8170SKalle Valo ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, 665bdcd8170SKalle Valo le32_to_cpu(ev->sw_version), 666bdcd8170SKalle Valo le32_to_cpu(ev->abi_version)); 667bdcd8170SKalle Valo 668bdcd8170SKalle Valo return 0; 669bdcd8170SKalle Valo } 670bdcd8170SKalle Valo 671e5090444SVivek Natarajan /* 672e5090444SVivek Natarajan * Mechanism to modify the roaming behavior in the firmware. The lower rssi 673e5090444SVivek Natarajan * at which the station has to roam can be passed with 674e5090444SVivek Natarajan * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level 675e5090444SVivek Natarajan * in dBm. 676e5090444SVivek Natarajan */ 677e5090444SVivek Natarajan int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) 678e5090444SVivek Natarajan { 679e5090444SVivek Natarajan struct sk_buff *skb; 680e5090444SVivek Natarajan struct roam_ctrl_cmd *cmd; 681e5090444SVivek Natarajan 682e5090444SVivek Natarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 683e5090444SVivek Natarajan if (!skb) 684e5090444SVivek Natarajan return -ENOMEM; 685e5090444SVivek Natarajan 686e5090444SVivek Natarajan cmd = (struct roam_ctrl_cmd *) skb->data; 687e5090444SVivek Natarajan 688e5090444SVivek Natarajan cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD); 689e5090444SVivek Natarajan cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi + 690e5090444SVivek Natarajan DEF_SCAN_FOR_ROAM_INTVL); 691e5090444SVivek Natarajan cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi); 692e5090444SVivek Natarajan cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; 693e5090444SVivek Natarajan cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; 694e5090444SVivek Natarajan 695e5090444SVivek Natarajan ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_ROAM_CTRL_CMDID, NO_SYNC_WMIFLAG); 696e5090444SVivek Natarajan 697e5090444SVivek Natarajan return 0; 698e5090444SVivek Natarajan } 699e5090444SVivek Natarajan 700bdcd8170SKalle Valo static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) 701bdcd8170SKalle Valo { 702bdcd8170SKalle Valo struct wmi_connect_event *ev; 703bdcd8170SKalle Valo u8 *pie, *peie; 704572e27c0SJouni Malinen struct ath6kl *ar = wmi->parent_dev; 705bdcd8170SKalle Valo 706bdcd8170SKalle Valo if (len < sizeof(struct wmi_connect_event)) 707bdcd8170SKalle Valo return -EINVAL; 708bdcd8170SKalle Valo 709bdcd8170SKalle Valo ev = (struct wmi_connect_event *) datap; 710bdcd8170SKalle Valo 711572e27c0SJouni Malinen if (ar->nw_type == AP_NETWORK) { 712572e27c0SJouni Malinen /* AP mode start/STA connected event */ 713572e27c0SJouni Malinen struct net_device *dev = ar->net_dev; 714572e27c0SJouni Malinen if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) { 715572e27c0SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM " 716572e27c0SJouni Malinen "(AP started)\n", 717572e27c0SJouni Malinen __func__, le16_to_cpu(ev->u.ap_bss.ch), 718572e27c0SJouni Malinen ev->u.ap_bss.bssid); 719572e27c0SJouni Malinen ath6kl_connect_ap_mode_bss( 720572e27c0SJouni Malinen ar, le16_to_cpu(ev->u.ap_bss.ch)); 721572e27c0SJouni Malinen } else { 722572e27c0SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM " 723572e27c0SJouni Malinen "auth=%u keymgmt=%u cipher=%u apsd_info=%u " 724572e27c0SJouni Malinen "(STA connected)\n", 725572e27c0SJouni Malinen __func__, ev->u.ap_sta.aid, 726572e27c0SJouni Malinen ev->u.ap_sta.mac_addr, 727572e27c0SJouni Malinen ev->u.ap_sta.auth, 728572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 729572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 730572e27c0SJouni Malinen ev->u.ap_sta.apsd_info); 731572e27c0SJouni Malinen ath6kl_connect_ap_mode_sta( 732572e27c0SJouni Malinen ar, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, 733572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 734572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 735572e27c0SJouni Malinen ev->u.ap_sta.auth, ev->assoc_req_len, 736572e27c0SJouni Malinen ev->assoc_info + ev->beacon_ie_len); 737572e27c0SJouni Malinen } 738572e27c0SJouni Malinen return 0; 739572e27c0SJouni Malinen } 740572e27c0SJouni Malinen 741572e27c0SJouni Malinen /* STA/IBSS mode connection event */ 742572e27c0SJouni Malinen 743bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM\n", 744572e27c0SJouni Malinen __func__, le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid); 745bdcd8170SKalle Valo 746bdcd8170SKalle Valo /* Start of assoc rsp IEs */ 747bdcd8170SKalle Valo pie = ev->assoc_info + ev->beacon_ie_len + 748bdcd8170SKalle Valo ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ 749bdcd8170SKalle Valo 750bdcd8170SKalle Valo /* End of assoc rsp IEs */ 751bdcd8170SKalle Valo peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + 752bdcd8170SKalle Valo ev->assoc_resp_len; 753bdcd8170SKalle Valo 754bdcd8170SKalle Valo while (pie < peie) { 755bdcd8170SKalle Valo switch (*pie) { 756bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 757bdcd8170SKalle Valo if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && 758bdcd8170SKalle Valo pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { 759bdcd8170SKalle Valo /* WMM OUT (00:50:F2) */ 760bdcd8170SKalle Valo if (pie[1] > 5 761bdcd8170SKalle Valo && pie[6] == WMM_PARAM_OUI_SUBTYPE) 762bdcd8170SKalle Valo wmi->is_wmm_enabled = true; 763bdcd8170SKalle Valo } 764bdcd8170SKalle Valo break; 765bdcd8170SKalle Valo } 766bdcd8170SKalle Valo 767bdcd8170SKalle Valo if (wmi->is_wmm_enabled) 768bdcd8170SKalle Valo break; 769bdcd8170SKalle Valo 770bdcd8170SKalle Valo pie += pie[1] + 2; 771bdcd8170SKalle Valo } 772bdcd8170SKalle Valo 773572e27c0SJouni Malinen ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->u.sta.ch), 774572e27c0SJouni Malinen ev->u.sta.bssid, 775572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.listen_intvl), 776572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.beacon_intvl), 777572e27c0SJouni Malinen le32_to_cpu(ev->u.sta.nw_type), 778bdcd8170SKalle Valo ev->beacon_ie_len, ev->assoc_req_len, 779bdcd8170SKalle Valo ev->assoc_resp_len, ev->assoc_info); 780bdcd8170SKalle Valo 781bdcd8170SKalle Valo return 0; 782bdcd8170SKalle Valo } 783bdcd8170SKalle Valo 78406033760SVivek Natarajan static struct country_code_to_enum_rd * 78506033760SVivek Natarajan ath6kl_regd_find_country(u16 countryCode) 78606033760SVivek Natarajan { 78706033760SVivek Natarajan int i; 78806033760SVivek Natarajan 78906033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 79006033760SVivek Natarajan if (allCountries[i].countryCode == countryCode) 79106033760SVivek Natarajan return &allCountries[i]; 79206033760SVivek Natarajan } 79306033760SVivek Natarajan 79406033760SVivek Natarajan return NULL; 79506033760SVivek Natarajan } 79606033760SVivek Natarajan 79706033760SVivek Natarajan static struct reg_dmn_pair_mapping * 79806033760SVivek Natarajan ath6kl_get_regpair(u16 regdmn) 79906033760SVivek Natarajan { 80006033760SVivek Natarajan int i; 80106033760SVivek Natarajan 80206033760SVivek Natarajan if (regdmn == NO_ENUMRD) 80306033760SVivek Natarajan return NULL; 80406033760SVivek Natarajan 80506033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) { 80606033760SVivek Natarajan if (regDomainPairs[i].regDmnEnum == regdmn) 80706033760SVivek Natarajan return ®DomainPairs[i]; 80806033760SVivek Natarajan } 80906033760SVivek Natarajan 81006033760SVivek Natarajan return NULL; 81106033760SVivek Natarajan } 81206033760SVivek Natarajan 81306033760SVivek Natarajan static struct country_code_to_enum_rd * 81406033760SVivek Natarajan ath6kl_regd_find_country_by_rd(u16 regdmn) 81506033760SVivek Natarajan { 81606033760SVivek Natarajan int i; 81706033760SVivek Natarajan 81806033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 81906033760SVivek Natarajan if (allCountries[i].regDmnEnum == regdmn) 82006033760SVivek Natarajan return &allCountries[i]; 82106033760SVivek Natarajan } 82206033760SVivek Natarajan 82306033760SVivek Natarajan return NULL; 82406033760SVivek Natarajan } 82506033760SVivek Natarajan 82606033760SVivek Natarajan static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) 82706033760SVivek Natarajan { 82806033760SVivek Natarajan 82906033760SVivek Natarajan struct ath6kl_wmi_regdomain *ev; 83006033760SVivek Natarajan struct country_code_to_enum_rd *country = NULL; 83106033760SVivek Natarajan struct reg_dmn_pair_mapping *regpair = NULL; 83206033760SVivek Natarajan char alpha2[2]; 83306033760SVivek Natarajan u32 reg_code; 83406033760SVivek Natarajan 83506033760SVivek Natarajan ev = (struct ath6kl_wmi_regdomain *) datap; 83606033760SVivek Natarajan reg_code = le32_to_cpu(ev->reg_code); 83706033760SVivek Natarajan 83806033760SVivek Natarajan if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) 83906033760SVivek Natarajan country = ath6kl_regd_find_country((u16) reg_code); 84006033760SVivek Natarajan else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) { 84106033760SVivek Natarajan 84206033760SVivek Natarajan regpair = ath6kl_get_regpair((u16) reg_code); 84306033760SVivek Natarajan country = ath6kl_regd_find_country_by_rd((u16) reg_code); 84406033760SVivek Natarajan ath6kl_dbg(ATH6KL_DBG_WMI, "ath6kl: Regpair used: 0x%0x\n", 84506033760SVivek Natarajan regpair->regDmnEnum); 84606033760SVivek Natarajan } 84706033760SVivek Natarajan 84806033760SVivek Natarajan if (country) { 84906033760SVivek Natarajan alpha2[0] = country->isoName[0]; 85006033760SVivek Natarajan alpha2[1] = country->isoName[1]; 85106033760SVivek Natarajan 85206033760SVivek Natarajan regulatory_hint(wmi->parent_dev->wdev->wiphy, alpha2); 85306033760SVivek Natarajan 85406033760SVivek Natarajan ath6kl_dbg(ATH6KL_DBG_WMI, "ath6kl: Country alpha2 being used: %c%c\n", 85506033760SVivek Natarajan alpha2[0], alpha2[1]); 85606033760SVivek Natarajan } 85706033760SVivek Natarajan } 85806033760SVivek Natarajan 859bdcd8170SKalle Valo static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) 860bdcd8170SKalle Valo { 861bdcd8170SKalle Valo struct wmi_disconnect_event *ev; 862bdcd8170SKalle Valo wmi->traffic_class = 100; 863bdcd8170SKalle Valo 864bdcd8170SKalle Valo if (len < sizeof(struct wmi_disconnect_event)) 865bdcd8170SKalle Valo return -EINVAL; 866bdcd8170SKalle Valo 867bdcd8170SKalle Valo ev = (struct wmi_disconnect_event *) datap; 868bdcd8170SKalle Valo 869bdcd8170SKalle Valo wmi->is_wmm_enabled = false; 870bdcd8170SKalle Valo wmi->pair_crypto_type = NONE_CRYPT; 871bdcd8170SKalle Valo wmi->grp_crypto_type = NONE_CRYPT; 872bdcd8170SKalle Valo 873bdcd8170SKalle Valo ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason, 874bdcd8170SKalle Valo ev->bssid, ev->assoc_resp_len, ev->assoc_info, 875bdcd8170SKalle Valo le16_to_cpu(ev->proto_reason_status)); 876bdcd8170SKalle Valo 877bdcd8170SKalle Valo return 0; 878bdcd8170SKalle Valo } 879bdcd8170SKalle Valo 880bdcd8170SKalle Valo static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) 881bdcd8170SKalle Valo { 882bdcd8170SKalle Valo struct wmi_peer_node_event *ev; 883bdcd8170SKalle Valo 884bdcd8170SKalle Valo if (len < sizeof(struct wmi_peer_node_event)) 885bdcd8170SKalle Valo return -EINVAL; 886bdcd8170SKalle Valo 887bdcd8170SKalle Valo ev = (struct wmi_peer_node_event *) datap; 888bdcd8170SKalle Valo 889bdcd8170SKalle Valo if (ev->event_code == PEER_NODE_JOIN_EVENT) 890bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", 891bdcd8170SKalle Valo ev->peer_mac_addr); 892bdcd8170SKalle Valo else if (ev->event_code == PEER_NODE_LEAVE_EVENT) 893bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", 894bdcd8170SKalle Valo ev->peer_mac_addr); 895bdcd8170SKalle Valo 896bdcd8170SKalle Valo return 0; 897bdcd8170SKalle Valo } 898bdcd8170SKalle Valo 899bdcd8170SKalle Valo static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len) 900bdcd8170SKalle Valo { 901bdcd8170SKalle Valo struct wmi_tkip_micerr_event *ev; 902bdcd8170SKalle Valo 903bdcd8170SKalle Valo if (len < sizeof(struct wmi_tkip_micerr_event)) 904bdcd8170SKalle Valo return -EINVAL; 905bdcd8170SKalle Valo 906bdcd8170SKalle Valo ev = (struct wmi_tkip_micerr_event *) datap; 907bdcd8170SKalle Valo 908bdcd8170SKalle Valo ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast); 909bdcd8170SKalle Valo 910bdcd8170SKalle Valo return 0; 911bdcd8170SKalle Valo } 912bdcd8170SKalle Valo 913bdcd8170SKalle Valo static int ath6kl_wlan_parse_beacon(u8 *buf, int frame_len, 914bdcd8170SKalle Valo struct ath6kl_common_ie *cie) 915bdcd8170SKalle Valo { 916bdcd8170SKalle Valo u8 *frm, *efrm; 917bdcd8170SKalle Valo u8 elemid_ssid = false; 918bdcd8170SKalle Valo 919bdcd8170SKalle Valo frm = buf; 920bdcd8170SKalle Valo efrm = (u8 *) (frm + frame_len); 921bdcd8170SKalle Valo 922bdcd8170SKalle Valo /* 923bdcd8170SKalle Valo * beacon/probe response frame format 924bdcd8170SKalle Valo * [8] time stamp 925bdcd8170SKalle Valo * [2] beacon interval 926bdcd8170SKalle Valo * [2] capability information 927bdcd8170SKalle Valo * [tlv] ssid 928bdcd8170SKalle Valo * [tlv] supported rates 929bdcd8170SKalle Valo * [tlv] country information 930bdcd8170SKalle Valo * [tlv] parameter set (FH/DS) 931bdcd8170SKalle Valo * [tlv] erp information 932bdcd8170SKalle Valo * [tlv] extended supported rates 933bdcd8170SKalle Valo * [tlv] WMM 934bdcd8170SKalle Valo * [tlv] WPA or RSN 935bdcd8170SKalle Valo * [tlv] Atheros Advanced Capabilities 936bdcd8170SKalle Valo */ 937bdcd8170SKalle Valo if ((efrm - frm) < 12) 938bdcd8170SKalle Valo return -EINVAL; 939bdcd8170SKalle Valo 940bdcd8170SKalle Valo memset(cie, 0, sizeof(*cie)); 941bdcd8170SKalle Valo 942bdcd8170SKalle Valo cie->ie_tstamp = frm; 943bdcd8170SKalle Valo frm += 8; 944bdcd8170SKalle Valo cie->ie_beaconInt = *(u16 *) frm; 945bdcd8170SKalle Valo frm += 2; 946bdcd8170SKalle Valo cie->ie_capInfo = *(u16 *) frm; 947bdcd8170SKalle Valo frm += 2; 948bdcd8170SKalle Valo cie->ie_chan = 0; 949bdcd8170SKalle Valo 950bdcd8170SKalle Valo while (frm < efrm) { 951bdcd8170SKalle Valo switch (*frm) { 952bdcd8170SKalle Valo case WLAN_EID_SSID: 953bdcd8170SKalle Valo if (!elemid_ssid) { 954bdcd8170SKalle Valo cie->ie_ssid = frm; 955bdcd8170SKalle Valo elemid_ssid = true; 956bdcd8170SKalle Valo } 957bdcd8170SKalle Valo break; 958bdcd8170SKalle Valo case WLAN_EID_SUPP_RATES: 959bdcd8170SKalle Valo cie->ie_rates = frm; 960bdcd8170SKalle Valo break; 961bdcd8170SKalle Valo case WLAN_EID_COUNTRY: 962bdcd8170SKalle Valo cie->ie_country = frm; 963bdcd8170SKalle Valo break; 964bdcd8170SKalle Valo case WLAN_EID_FH_PARAMS: 965bdcd8170SKalle Valo break; 966bdcd8170SKalle Valo case WLAN_EID_DS_PARAMS: 967bdcd8170SKalle Valo cie->ie_chan = frm[2]; 968bdcd8170SKalle Valo break; 969bdcd8170SKalle Valo case WLAN_EID_TIM: 970bdcd8170SKalle Valo cie->ie_tim = frm; 971bdcd8170SKalle Valo break; 972bdcd8170SKalle Valo case WLAN_EID_IBSS_PARAMS: 973bdcd8170SKalle Valo break; 974bdcd8170SKalle Valo case WLAN_EID_EXT_SUPP_RATES: 975bdcd8170SKalle Valo cie->ie_xrates = frm; 976bdcd8170SKalle Valo break; 977bdcd8170SKalle Valo case WLAN_EID_ERP_INFO: 978bdcd8170SKalle Valo if (frm[1] != 1) 979bdcd8170SKalle Valo return -EINVAL; 980bdcd8170SKalle Valo 981bdcd8170SKalle Valo cie->ie_erp = frm[2]; 982bdcd8170SKalle Valo break; 983bdcd8170SKalle Valo case WLAN_EID_RSN: 984bdcd8170SKalle Valo cie->ie_rsn = frm; 985bdcd8170SKalle Valo break; 986bdcd8170SKalle Valo case WLAN_EID_HT_CAPABILITY: 987bdcd8170SKalle Valo cie->ie_htcap = frm; 988bdcd8170SKalle Valo break; 989bdcd8170SKalle Valo case WLAN_EID_HT_INFORMATION: 990bdcd8170SKalle Valo cie->ie_htop = frm; 991bdcd8170SKalle Valo break; 992bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 993bdcd8170SKalle Valo if (frm[1] > 3 && frm[2] == 0x00 && frm[3] == 0x50 && 994bdcd8170SKalle Valo frm[4] == 0xf2) { 995bdcd8170SKalle Valo /* OUT Type (00:50:F2) */ 996bdcd8170SKalle Valo 997bdcd8170SKalle Valo if (frm[5] == WPA_OUI_TYPE) { 998bdcd8170SKalle Valo /* WPA OUT */ 999bdcd8170SKalle Valo cie->ie_wpa = frm; 1000bdcd8170SKalle Valo } else if (frm[5] == WMM_OUI_TYPE) { 1001bdcd8170SKalle Valo /* WMM OUT */ 1002bdcd8170SKalle Valo cie->ie_wmm = frm; 1003bdcd8170SKalle Valo } else if (frm[5] == WSC_OUT_TYPE) { 1004bdcd8170SKalle Valo /* WSC OUT */ 1005bdcd8170SKalle Valo cie->ie_wsc = frm; 1006bdcd8170SKalle Valo } 1007bdcd8170SKalle Valo 1008bdcd8170SKalle Valo } else if (frm[1] > 3 && frm[2] == 0x00 1009bdcd8170SKalle Valo && frm[3] == 0x03 && frm[4] == 0x7f 1010bdcd8170SKalle Valo && frm[5] == ATH_OUI_TYPE) { 1011bdcd8170SKalle Valo /* Atheros OUI (00:03:7f) */ 1012bdcd8170SKalle Valo cie->ie_ath = frm; 1013bdcd8170SKalle Valo } 1014bdcd8170SKalle Valo break; 1015bdcd8170SKalle Valo default: 1016bdcd8170SKalle Valo break; 1017bdcd8170SKalle Valo } 1018bdcd8170SKalle Valo frm += frm[1] + 2; 1019bdcd8170SKalle Valo } 1020bdcd8170SKalle Valo 1021bdcd8170SKalle Valo if ((cie->ie_rates == NULL) 1022bdcd8170SKalle Valo || (cie->ie_rates[1] > ATH6KL_RATE_MAXSIZE)) 1023bdcd8170SKalle Valo return -EINVAL; 1024bdcd8170SKalle Valo 1025bdcd8170SKalle Valo if ((cie->ie_ssid == NULL) 1026bdcd8170SKalle Valo || (cie->ie_ssid[1] > IEEE80211_MAX_SSID_LEN)) 1027bdcd8170SKalle Valo return -EINVAL; 1028bdcd8170SKalle Valo 1029bdcd8170SKalle Valo return 0; 1030bdcd8170SKalle Valo } 1031bdcd8170SKalle Valo 1032bdcd8170SKalle Valo static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) 1033bdcd8170SKalle Valo { 1034bdcd8170SKalle Valo struct bss *bss = NULL; 1035bdcd8170SKalle Valo struct wmi_bss_info_hdr *bih; 1036bdcd8170SKalle Valo u8 cached_ssid_len = 0; 1037bdcd8170SKalle Valo u8 cached_ssid[IEEE80211_MAX_SSID_LEN] = { 0 }; 1038bdcd8170SKalle Valo u8 beacon_ssid_len = 0; 1039bdcd8170SKalle Valo u8 *buf, *ie_ssid; 1040bdcd8170SKalle Valo u8 *ni_buf; 1041bdcd8170SKalle Valo int buf_len; 1042bdcd8170SKalle Valo 1043bdcd8170SKalle Valo int ret; 1044bdcd8170SKalle Valo 1045bdcd8170SKalle Valo if (len <= sizeof(struct wmi_bss_info_hdr)) 1046bdcd8170SKalle Valo return -EINVAL; 1047bdcd8170SKalle Valo 1048bdcd8170SKalle Valo bih = (struct wmi_bss_info_hdr *) datap; 10497c3075e9SVasanthakumar Thiagarajan bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid); 1050bdcd8170SKalle Valo 1051bdcd8170SKalle Valo if (a_sle16_to_cpu(bih->rssi) > 0) { 1052bdcd8170SKalle Valo if (bss == NULL) 1053bdcd8170SKalle Valo return 0; 1054bdcd8170SKalle Valo else 1055bdcd8170SKalle Valo bih->rssi = a_cpu_to_sle16(bss->ni_rssi); 1056bdcd8170SKalle Valo } 1057bdcd8170SKalle Valo 1058bdcd8170SKalle Valo buf = datap + sizeof(struct wmi_bss_info_hdr); 1059bdcd8170SKalle Valo len -= sizeof(struct wmi_bss_info_hdr); 1060bdcd8170SKalle Valo 1061bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1062bdcd8170SKalle Valo "bss info evt - ch %u, rssi %02x, bssid \"%pM\"\n", 1063bdcd8170SKalle Valo bih->ch, a_sle16_to_cpu(bih->rssi), bih->bssid); 1064bdcd8170SKalle Valo 1065bdcd8170SKalle Valo if (bss != NULL) { 1066bdcd8170SKalle Valo /* 1067bdcd8170SKalle Valo * Free up the node. We are about to allocate a new node. 1068bdcd8170SKalle Valo * In case of hidden AP, beacon will not have ssid, 1069bdcd8170SKalle Valo * but a directed probe response will have it, 1070bdcd8170SKalle Valo * so cache the probe-resp-ssid if already present. 1071bdcd8170SKalle Valo */ 1072bdcd8170SKalle Valo if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE)) { 1073bdcd8170SKalle Valo ie_ssid = bss->ni_cie.ie_ssid; 1074bdcd8170SKalle Valo if (ie_ssid && (ie_ssid[1] <= IEEE80211_MAX_SSID_LEN) && 1075bdcd8170SKalle Valo (ie_ssid[2] != 0)) { 1076bdcd8170SKalle Valo cached_ssid_len = ie_ssid[1]; 1077bdcd8170SKalle Valo memcpy(cached_ssid, ie_ssid + 2, 1078bdcd8170SKalle Valo cached_ssid_len); 1079bdcd8170SKalle Valo } 1080bdcd8170SKalle Valo } 1081bdcd8170SKalle Valo 1082bdcd8170SKalle Valo /* 1083bdcd8170SKalle Valo * Use the current average rssi of associated AP base on 1084bdcd8170SKalle Valo * assumption 1085bdcd8170SKalle Valo * 1. Most os with GUI will update RSSI by 1086bdcd8170SKalle Valo * ath6kl_wmi_get_stats_cmd() periodically. 1087bdcd8170SKalle Valo * 2. ath6kl_wmi_get_stats_cmd(..) will be called when calling 1088bdcd8170SKalle Valo * ath6kl_wmi_startscan_cmd(...) 1089bdcd8170SKalle Valo * The average value of RSSI give end-user better feeling for 1090bdcd8170SKalle Valo * instance value of scan result. It also sync up RSSI info 1091bdcd8170SKalle Valo * in GUI between scan result and RSSI signal icon. 1092bdcd8170SKalle Valo */ 109370df0516SVasanthakumar Thiagarajan if (memcmp(wmi->parent_dev->bssid, bih->bssid, ETH_ALEN) == 0) { 1094bdcd8170SKalle Valo bih->rssi = a_cpu_to_sle16(bss->ni_rssi); 1095bdcd8170SKalle Valo bih->snr = bss->ni_snr; 1096bdcd8170SKalle Valo } 1097bdcd8170SKalle Valo 10987c3075e9SVasanthakumar Thiagarajan wlan_node_reclaim(&wmi->parent_dev->scan_table, bss); 1099bdcd8170SKalle Valo } 1100bdcd8170SKalle Valo 1101bdcd8170SKalle Valo /* 1102bdcd8170SKalle Valo * beacon/probe response frame format 1103bdcd8170SKalle Valo * [8] time stamp 1104bdcd8170SKalle Valo * [2] beacon interval 1105bdcd8170SKalle Valo * [2] capability information 1106bdcd8170SKalle Valo * [tlv] ssid 1107bdcd8170SKalle Valo */ 1108bdcd8170SKalle Valo beacon_ssid_len = buf[SSID_IE_LEN_INDEX]; 1109bdcd8170SKalle Valo 1110bdcd8170SKalle Valo /* 1111bdcd8170SKalle Valo * If ssid is cached for this hidden AP, then change 1112bdcd8170SKalle Valo * buffer len accordingly. 1113bdcd8170SKalle Valo */ 1114bdcd8170SKalle Valo if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && 1115bdcd8170SKalle Valo (cached_ssid_len != 0) && 1116bdcd8170SKalle Valo (beacon_ssid_len == 0 || (cached_ssid_len > beacon_ssid_len && 1117bdcd8170SKalle Valo buf[SSID_IE_LEN_INDEX + 1] == 0))) { 1118bdcd8170SKalle Valo 1119bdcd8170SKalle Valo len += (cached_ssid_len - beacon_ssid_len); 1120bdcd8170SKalle Valo } 1121bdcd8170SKalle Valo 1122bdcd8170SKalle Valo bss = wlan_node_alloc(len); 1123bdcd8170SKalle Valo if (!bss) 1124bdcd8170SKalle Valo return -ENOMEM; 1125bdcd8170SKalle Valo 1126bdcd8170SKalle Valo bss->ni_snr = bih->snr; 1127bdcd8170SKalle Valo bss->ni_rssi = a_sle16_to_cpu(bih->rssi); 1128bdcd8170SKalle Valo 1129bdcd8170SKalle Valo if (WARN_ON(!bss->ni_buf)) 1130bdcd8170SKalle Valo return -EINVAL; 1131bdcd8170SKalle Valo 1132bdcd8170SKalle Valo /* 1133bdcd8170SKalle Valo * In case of hidden AP, beacon will not have ssid, 1134bdcd8170SKalle Valo * but a directed probe response will have it, 1135bdcd8170SKalle Valo * so place the cached-ssid(probe-resp) in the bss info. 1136bdcd8170SKalle Valo */ 1137bdcd8170SKalle Valo if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && 1138bdcd8170SKalle Valo (cached_ssid_len != 0) && 1139bdcd8170SKalle Valo (beacon_ssid_len == 0 || (beacon_ssid_len && 1140bdcd8170SKalle Valo buf[SSID_IE_LEN_INDEX + 1] == 0))) { 1141bdcd8170SKalle Valo ni_buf = bss->ni_buf; 1142bdcd8170SKalle Valo buf_len = len; 1143bdcd8170SKalle Valo 1144bdcd8170SKalle Valo /* 1145bdcd8170SKalle Valo * Copy the first 14 bytes: 1146bdcd8170SKalle Valo * time-stamp(8), beacon-interval(2), 1147bdcd8170SKalle Valo * cap-info(2), ssid-id(1), ssid-len(1). 1148bdcd8170SKalle Valo */ 1149bdcd8170SKalle Valo memcpy(ni_buf, buf, SSID_IE_LEN_INDEX + 1); 1150bdcd8170SKalle Valo 1151bdcd8170SKalle Valo ni_buf[SSID_IE_LEN_INDEX] = cached_ssid_len; 1152bdcd8170SKalle Valo ni_buf += (SSID_IE_LEN_INDEX + 1); 1153bdcd8170SKalle Valo 1154bdcd8170SKalle Valo buf += (SSID_IE_LEN_INDEX + 1); 1155bdcd8170SKalle Valo buf_len -= (SSID_IE_LEN_INDEX + 1); 1156bdcd8170SKalle Valo 1157bdcd8170SKalle Valo memcpy(ni_buf, cached_ssid, cached_ssid_len); 1158bdcd8170SKalle Valo ni_buf += cached_ssid_len; 1159bdcd8170SKalle Valo 1160bdcd8170SKalle Valo buf += beacon_ssid_len; 1161bdcd8170SKalle Valo buf_len -= beacon_ssid_len; 1162bdcd8170SKalle Valo 1163bdcd8170SKalle Valo if (cached_ssid_len > beacon_ssid_len) 1164bdcd8170SKalle Valo buf_len -= (cached_ssid_len - beacon_ssid_len); 1165bdcd8170SKalle Valo 1166bdcd8170SKalle Valo memcpy(ni_buf, buf, buf_len); 1167bdcd8170SKalle Valo } else 1168bdcd8170SKalle Valo memcpy(bss->ni_buf, buf, len); 1169bdcd8170SKalle Valo 1170bdcd8170SKalle Valo bss->ni_framelen = len; 1171bdcd8170SKalle Valo 1172bdcd8170SKalle Valo ret = ath6kl_wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie); 1173bdcd8170SKalle Valo if (ret) { 1174bdcd8170SKalle Valo wlan_node_free(bss); 1175bdcd8170SKalle Valo return -EINVAL; 1176bdcd8170SKalle Valo } 1177bdcd8170SKalle Valo 1178bdcd8170SKalle Valo /* 1179bdcd8170SKalle Valo * Update the frequency in ie_chan, overwriting of channel number 1180bdcd8170SKalle Valo * which is done in ath6kl_wlan_parse_beacon 1181bdcd8170SKalle Valo */ 1182bdcd8170SKalle Valo bss->ni_cie.ie_chan = le16_to_cpu(bih->ch); 11837c3075e9SVasanthakumar Thiagarajan wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid); 1184bdcd8170SKalle Valo 1185bdcd8170SKalle Valo return 0; 1186bdcd8170SKalle Valo } 1187bdcd8170SKalle Valo 1188bdcd8170SKalle Valo /* Inactivity timeout of a fatpipe(pstream) at the target */ 1189bdcd8170SKalle Valo static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, 1190bdcd8170SKalle Valo int len) 1191bdcd8170SKalle Valo { 1192bdcd8170SKalle Valo struct wmi_pstream_timeout_event *ev; 1193bdcd8170SKalle Valo 1194bdcd8170SKalle Valo if (len < sizeof(struct wmi_pstream_timeout_event)) 1195bdcd8170SKalle Valo return -EINVAL; 1196bdcd8170SKalle Valo 1197bdcd8170SKalle Valo ev = (struct wmi_pstream_timeout_event *) datap; 1198bdcd8170SKalle Valo 1199bdcd8170SKalle Valo /* 1200bdcd8170SKalle Valo * When the pstream (fat pipe == AC) timesout, it means there were 1201bdcd8170SKalle Valo * no thinStreams within this pstream & it got implicitly created 1202bdcd8170SKalle Valo * due to data flow on this AC. We start the inactivity timer only 1203bdcd8170SKalle Valo * for implicitly created pstream. Just reset the host state. 1204bdcd8170SKalle Valo */ 1205bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1206bdcd8170SKalle Valo wmi->stream_exist_for_ac[ev->traffic_class] = 0; 1207bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); 1208bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1209bdcd8170SKalle Valo 1210bdcd8170SKalle Valo /* Indicate inactivity to driver layer for this fatpipe (pstream) */ 1211bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); 1212bdcd8170SKalle Valo 1213bdcd8170SKalle Valo return 0; 1214bdcd8170SKalle Valo } 1215bdcd8170SKalle Valo 1216bdcd8170SKalle Valo static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) 1217bdcd8170SKalle Valo { 1218bdcd8170SKalle Valo struct wmi_bit_rate_reply *reply; 1219bdcd8170SKalle Valo s32 rate; 1220bdcd8170SKalle Valo u32 sgi, index; 1221bdcd8170SKalle Valo 1222bdcd8170SKalle Valo if (len < sizeof(struct wmi_bit_rate_reply)) 1223bdcd8170SKalle Valo return -EINVAL; 1224bdcd8170SKalle Valo 1225bdcd8170SKalle Valo reply = (struct wmi_bit_rate_reply *) datap; 1226bdcd8170SKalle Valo 1227bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); 1228bdcd8170SKalle Valo 1229bdcd8170SKalle Valo if (reply->rate_index == (s8) RATE_AUTO) { 1230bdcd8170SKalle Valo rate = RATE_AUTO; 1231bdcd8170SKalle Valo } else { 1232bdcd8170SKalle Valo index = reply->rate_index & 0x7f; 1233bdcd8170SKalle Valo sgi = (reply->rate_index & 0x80) ? 1 : 0; 1234bdcd8170SKalle Valo rate = wmi_rate_tbl[index][sgi]; 1235bdcd8170SKalle Valo } 1236bdcd8170SKalle Valo 1237bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1238bdcd8170SKalle Valo 1239bdcd8170SKalle Valo return 0; 1240bdcd8170SKalle Valo } 1241bdcd8170SKalle Valo 1242003353b0SKalle Valo static int ath6kl_wmi_tcmd_test_report_rx(struct wmi *wmi, u8 *datap, int len) 1243003353b0SKalle Valo { 1244003353b0SKalle Valo ath6kl_tm_rx_report_event(wmi->parent_dev, datap, len); 1245003353b0SKalle Valo 1246003353b0SKalle Valo return 0; 1247003353b0SKalle Valo } 1248003353b0SKalle Valo 1249bdcd8170SKalle Valo static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) 1250bdcd8170SKalle Valo { 1251bdcd8170SKalle Valo if (len < sizeof(struct wmi_fix_rates_reply)) 1252bdcd8170SKalle Valo return -EINVAL; 1253bdcd8170SKalle Valo 1254bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1255bdcd8170SKalle Valo 1256bdcd8170SKalle Valo return 0; 1257bdcd8170SKalle Valo } 1258bdcd8170SKalle Valo 1259bdcd8170SKalle Valo static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) 1260bdcd8170SKalle Valo { 1261bdcd8170SKalle Valo if (len < sizeof(struct wmi_channel_list_reply)) 1262bdcd8170SKalle Valo return -EINVAL; 1263bdcd8170SKalle Valo 1264bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1265bdcd8170SKalle Valo 1266bdcd8170SKalle Valo return 0; 1267bdcd8170SKalle Valo } 1268bdcd8170SKalle Valo 1269bdcd8170SKalle Valo static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) 1270bdcd8170SKalle Valo { 1271bdcd8170SKalle Valo struct wmi_tx_pwr_reply *reply; 1272bdcd8170SKalle Valo 1273bdcd8170SKalle Valo if (len < sizeof(struct wmi_tx_pwr_reply)) 1274bdcd8170SKalle Valo return -EINVAL; 1275bdcd8170SKalle Valo 1276bdcd8170SKalle Valo reply = (struct wmi_tx_pwr_reply *) datap; 1277bdcd8170SKalle Valo ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); 1278bdcd8170SKalle Valo 1279bdcd8170SKalle Valo return 0; 1280bdcd8170SKalle Valo } 1281bdcd8170SKalle Valo 1282bdcd8170SKalle Valo static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) 1283bdcd8170SKalle Valo { 1284bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_keepalive_cmd)) 1285bdcd8170SKalle Valo return -EINVAL; 1286bdcd8170SKalle Valo 1287bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1288bdcd8170SKalle Valo 1289bdcd8170SKalle Valo return 0; 1290bdcd8170SKalle Valo } 1291bdcd8170SKalle Valo 1292bdcd8170SKalle Valo static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len) 1293bdcd8170SKalle Valo { 1294bdcd8170SKalle Valo struct wmi_scan_complete_event *ev; 1295bdcd8170SKalle Valo 1296bdcd8170SKalle Valo ev = (struct wmi_scan_complete_event *) datap; 1297bdcd8170SKalle Valo 1298bdcd8170SKalle Valo if (a_sle32_to_cpu(ev->status) == 0) 1299e4c7ffcbSVasanthakumar Thiagarajan wlan_refresh_inactive_nodes(wmi->parent_dev); 1300bdcd8170SKalle Valo 1301bdcd8170SKalle Valo ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status)); 1302bdcd8170SKalle Valo wmi->is_probe_ssid = false; 1303bdcd8170SKalle Valo 1304bdcd8170SKalle Valo return 0; 1305bdcd8170SKalle Valo } 1306bdcd8170SKalle Valo 1307bdcd8170SKalle Valo /* 1308bdcd8170SKalle Valo * Target is reporting a programming error. This is for 1309bdcd8170SKalle Valo * developer aid only. Target only checks a few common violations 1310bdcd8170SKalle Valo * and it is responsibility of host to do all error checking. 1311bdcd8170SKalle Valo * Behavior of target after wmi error event is undefined. 1312bdcd8170SKalle Valo * A reset is recommended. 1313bdcd8170SKalle Valo */ 1314bdcd8170SKalle Valo static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) 1315bdcd8170SKalle Valo { 1316bdcd8170SKalle Valo const char *type = "unknown error"; 1317bdcd8170SKalle Valo struct wmi_cmd_error_event *ev; 1318bdcd8170SKalle Valo ev = (struct wmi_cmd_error_event *) datap; 1319bdcd8170SKalle Valo 1320bdcd8170SKalle Valo switch (ev->err_code) { 1321bdcd8170SKalle Valo case INVALID_PARAM: 1322bdcd8170SKalle Valo type = "invalid parameter"; 1323bdcd8170SKalle Valo break; 1324bdcd8170SKalle Valo case ILLEGAL_STATE: 1325bdcd8170SKalle Valo type = "invalid state"; 1326bdcd8170SKalle Valo break; 1327bdcd8170SKalle Valo case INTERNAL_ERROR: 1328bdcd8170SKalle Valo type = "internal error"; 1329bdcd8170SKalle Valo break; 1330bdcd8170SKalle Valo } 1331bdcd8170SKalle Valo 1332bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", 1333bdcd8170SKalle Valo ev->cmd_id, type); 1334bdcd8170SKalle Valo 1335bdcd8170SKalle Valo return 0; 1336bdcd8170SKalle Valo } 1337bdcd8170SKalle Valo 1338bdcd8170SKalle Valo static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len) 1339bdcd8170SKalle Valo { 1340bdcd8170SKalle Valo ath6kl_tgt_stats_event(wmi->parent_dev, datap, len); 1341bdcd8170SKalle Valo 1342bdcd8170SKalle Valo return 0; 1343bdcd8170SKalle Valo } 1344bdcd8170SKalle Valo 1345bdcd8170SKalle Valo static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, 1346bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1347bdcd8170SKalle Valo u32 size) 1348bdcd8170SKalle Valo { 1349bdcd8170SKalle Valo u32 index; 1350bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; 1351bdcd8170SKalle Valo 1352bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1353bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1354bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[index]) { 1355bdcd8170SKalle Valo threshold = (u8) sq_thresh->upper_threshold[index]; 1356bdcd8170SKalle Valo break; 1357bdcd8170SKalle Valo } 1358bdcd8170SKalle Valo } 1359bdcd8170SKalle Valo 1360bdcd8170SKalle Valo return threshold; 1361bdcd8170SKalle Valo } 1362bdcd8170SKalle Valo 1363bdcd8170SKalle Valo static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, 1364bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1365bdcd8170SKalle Valo u32 size) 1366bdcd8170SKalle Valo { 1367bdcd8170SKalle Valo u32 index; 1368bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; 1369bdcd8170SKalle Valo 1370bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1371bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1372bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[index]) { 1373bdcd8170SKalle Valo threshold = (u8) sq_thresh->lower_threshold[index]; 1374bdcd8170SKalle Valo break; 1375bdcd8170SKalle Valo } 1376bdcd8170SKalle Valo } 1377bdcd8170SKalle Valo 1378bdcd8170SKalle Valo return threshold; 1379bdcd8170SKalle Valo } 1380bdcd8170SKalle Valo 1381bdcd8170SKalle Valo static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, 1382bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *rssi_cmd) 1383bdcd8170SKalle Valo { 1384bdcd8170SKalle Valo struct sk_buff *skb; 1385bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *cmd; 1386bdcd8170SKalle Valo 1387bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1388bdcd8170SKalle Valo if (!skb) 1389bdcd8170SKalle Valo return -ENOMEM; 1390bdcd8170SKalle Valo 1391bdcd8170SKalle Valo cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; 1392bdcd8170SKalle Valo memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); 1393bdcd8170SKalle Valo 1394bdcd8170SKalle Valo return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, 1395bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1396bdcd8170SKalle Valo } 1397bdcd8170SKalle Valo 1398bdcd8170SKalle Valo static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, 1399bdcd8170SKalle Valo int len) 1400bdcd8170SKalle Valo { 1401bdcd8170SKalle Valo struct wmi_rssi_threshold_event *reply; 1402bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd cmd; 1403bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1404bdcd8170SKalle Valo enum wmi_rssi_threshold_val new_threshold; 1405bdcd8170SKalle Valo u8 upper_rssi_threshold, lower_rssi_threshold; 1406bdcd8170SKalle Valo s16 rssi; 1407bdcd8170SKalle Valo int ret; 1408bdcd8170SKalle Valo 1409bdcd8170SKalle Valo if (len < sizeof(struct wmi_rssi_threshold_event)) 1410bdcd8170SKalle Valo return -EINVAL; 1411bdcd8170SKalle Valo 1412bdcd8170SKalle Valo reply = (struct wmi_rssi_threshold_event *) datap; 1413bdcd8170SKalle Valo new_threshold = (enum wmi_rssi_threshold_val) reply->range; 1414bdcd8170SKalle Valo rssi = a_sle16_to_cpu(reply->rssi); 1415bdcd8170SKalle Valo 1416bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; 1417bdcd8170SKalle Valo 1418bdcd8170SKalle Valo /* 1419bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1420bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1421bdcd8170SKalle Valo * quality reported by the target 1422bdcd8170SKalle Valo */ 1423bdcd8170SKalle Valo if (new_threshold) { 1424bdcd8170SKalle Valo /* Upper threshold breached */ 1425bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[0]) { 1426bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1427bdcd8170SKalle Valo "spurious upper rssi threshold event: %d\n", 1428bdcd8170SKalle Valo rssi); 1429bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[1]) && 1430bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[0])) { 1431bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; 1432bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[2]) && 1433bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[1])) { 1434bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; 1435bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[3]) && 1436bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[2])) { 1437bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; 1438bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[4]) && 1439bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[3])) { 1440bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; 1441bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[5]) && 1442bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[4])) { 1443bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; 1444bdcd8170SKalle Valo } else if (rssi >= sq_thresh->upper_threshold[5]) { 1445bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; 1446bdcd8170SKalle Valo } 1447bdcd8170SKalle Valo } else { 1448bdcd8170SKalle Valo /* Lower threshold breached */ 1449bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[0]) { 1450bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1451bdcd8170SKalle Valo "spurious lower rssi threshold event: %d %d\n", 1452bdcd8170SKalle Valo rssi, sq_thresh->lower_threshold[0]); 1453bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[1]) && 1454bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[0])) { 1455bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_BELOW; 1456bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[2]) && 1457bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[1])) { 1458bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_BELOW; 1459bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[3]) && 1460bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[2])) { 1461bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_BELOW; 1462bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[4]) && 1463bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[3])) { 1464bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_BELOW; 1465bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[5]) && 1466bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[4])) { 1467bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_BELOW; 1468bdcd8170SKalle Valo } else if (rssi <= sq_thresh->lower_threshold[5]) { 1469bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_BELOW; 1470bdcd8170SKalle Valo } 1471bdcd8170SKalle Valo } 1472bdcd8170SKalle Valo 1473bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1474bdcd8170SKalle Valo lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, 1475bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1476bdcd8170SKalle Valo upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, 1477bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1478bdcd8170SKalle Valo 1479bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1480bdcd8170SKalle Valo cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); 1481bdcd8170SKalle Valo cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); 1482bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1483bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1484bdcd8170SKalle Valo 1485bdcd8170SKalle Valo ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); 1486bdcd8170SKalle Valo if (ret) { 1487bdcd8170SKalle Valo ath6kl_err("unable to configure rssi thresholds\n"); 1488bdcd8170SKalle Valo return -EIO; 1489bdcd8170SKalle Valo } 1490bdcd8170SKalle Valo 1491bdcd8170SKalle Valo return 0; 1492bdcd8170SKalle Valo } 1493bdcd8170SKalle Valo 1494bdcd8170SKalle Valo static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) 1495bdcd8170SKalle Valo { 1496bdcd8170SKalle Valo struct wmi_cac_event *reply; 1497bdcd8170SKalle Valo struct ieee80211_tspec_ie *ts; 1498bdcd8170SKalle Valo u16 active_tsids, tsinfo; 1499bdcd8170SKalle Valo u8 tsid, index; 1500bdcd8170SKalle Valo u8 ts_id; 1501bdcd8170SKalle Valo 1502bdcd8170SKalle Valo if (len < sizeof(struct wmi_cac_event)) 1503bdcd8170SKalle Valo return -EINVAL; 1504bdcd8170SKalle Valo 1505bdcd8170SKalle Valo reply = (struct wmi_cac_event *) datap; 1506bdcd8170SKalle Valo 1507bdcd8170SKalle Valo if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && 1508bdcd8170SKalle Valo (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { 1509bdcd8170SKalle Valo 1510bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1511bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1512bdcd8170SKalle Valo tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1513bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK; 1514bdcd8170SKalle Valo 1515bdcd8170SKalle Valo ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid); 1516bdcd8170SKalle Valo } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { 1517bdcd8170SKalle Valo /* 1518bdcd8170SKalle Valo * Following assumes that there is only one outstanding 1519bdcd8170SKalle Valo * ADDTS request when this event is received 1520bdcd8170SKalle Valo */ 1521bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1522bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1523bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1524bdcd8170SKalle Valo 1525bdcd8170SKalle Valo for (index = 0; index < sizeof(active_tsids) * 8; index++) { 1526bdcd8170SKalle Valo if ((active_tsids >> index) & 1) 1527bdcd8170SKalle Valo break; 1528bdcd8170SKalle Valo } 1529bdcd8170SKalle Valo if (index < (sizeof(active_tsids) * 8)) 1530bdcd8170SKalle Valo ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index); 1531bdcd8170SKalle Valo } 1532bdcd8170SKalle Valo 1533bdcd8170SKalle Valo /* 1534bdcd8170SKalle Valo * Clear active tsids and Add missing handling 1535bdcd8170SKalle Valo * for delete qos stream from AP 1536bdcd8170SKalle Valo */ 1537bdcd8170SKalle Valo else if (reply->cac_indication == CAC_INDICATION_DELETE) { 1538bdcd8170SKalle Valo 1539bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1540bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1541bdcd8170SKalle Valo ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1542bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK); 1543bdcd8170SKalle Valo 1544bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1545bdcd8170SKalle Valo wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); 1546bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1547bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1548bdcd8170SKalle Valo 1549bdcd8170SKalle Valo /* Indicate stream inactivity to driver layer only if all tsids 1550bdcd8170SKalle Valo * within this AC are deleted. 1551bdcd8170SKalle Valo */ 1552bdcd8170SKalle Valo if (!active_tsids) { 1553bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, 1554bdcd8170SKalle Valo false); 1555bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << reply->ac); 1556bdcd8170SKalle Valo } 1557bdcd8170SKalle Valo } 1558bdcd8170SKalle Valo 1559bdcd8170SKalle Valo return 0; 1560bdcd8170SKalle Valo } 1561bdcd8170SKalle Valo 1562bdcd8170SKalle Valo static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, 1563bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *snr_cmd) 1564bdcd8170SKalle Valo { 1565bdcd8170SKalle Valo struct sk_buff *skb; 1566bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *cmd; 1567bdcd8170SKalle Valo 1568bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1569bdcd8170SKalle Valo if (!skb) 1570bdcd8170SKalle Valo return -ENOMEM; 1571bdcd8170SKalle Valo 1572bdcd8170SKalle Valo cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; 1573bdcd8170SKalle Valo memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); 1574bdcd8170SKalle Valo 1575bdcd8170SKalle Valo return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, 1576bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1577bdcd8170SKalle Valo } 1578bdcd8170SKalle Valo 1579bdcd8170SKalle Valo static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, 1580bdcd8170SKalle Valo int len) 1581bdcd8170SKalle Valo { 1582bdcd8170SKalle Valo struct wmi_snr_threshold_event *reply; 1583bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1584bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd cmd; 1585bdcd8170SKalle Valo enum wmi_snr_threshold_val new_threshold; 1586bdcd8170SKalle Valo u8 upper_snr_threshold, lower_snr_threshold; 1587bdcd8170SKalle Valo s16 snr; 1588bdcd8170SKalle Valo int ret; 1589bdcd8170SKalle Valo 1590bdcd8170SKalle Valo if (len < sizeof(struct wmi_snr_threshold_event)) 1591bdcd8170SKalle Valo return -EINVAL; 1592bdcd8170SKalle Valo 1593bdcd8170SKalle Valo reply = (struct wmi_snr_threshold_event *) datap; 1594bdcd8170SKalle Valo 1595bdcd8170SKalle Valo new_threshold = (enum wmi_snr_threshold_val) reply->range; 1596bdcd8170SKalle Valo snr = reply->snr; 1597bdcd8170SKalle Valo 1598bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; 1599bdcd8170SKalle Valo 1600bdcd8170SKalle Valo /* 1601bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1602bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1603bdcd8170SKalle Valo * quality reported by the target. 1604bdcd8170SKalle Valo */ 1605bdcd8170SKalle Valo if (new_threshold) { 1606bdcd8170SKalle Valo /* Upper threshold breached */ 1607bdcd8170SKalle Valo if (snr < sq_thresh->upper_threshold[0]) { 1608bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1609bdcd8170SKalle Valo "spurious upper snr threshold event: %d\n", 1610bdcd8170SKalle Valo snr); 1611bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[1]) && 1612bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[0])) { 1613bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_ABOVE; 1614bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[2]) && 1615bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[1])) { 1616bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_ABOVE; 1617bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[3]) && 1618bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[2])) { 1619bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_ABOVE; 1620bdcd8170SKalle Valo } else if (snr >= sq_thresh->upper_threshold[3]) { 1621bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_ABOVE; 1622bdcd8170SKalle Valo } 1623bdcd8170SKalle Valo } else { 1624bdcd8170SKalle Valo /* Lower threshold breached */ 1625bdcd8170SKalle Valo if (snr > sq_thresh->lower_threshold[0]) { 1626bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1627bdcd8170SKalle Valo "spurious lower snr threshold event: %d\n", 1628bdcd8170SKalle Valo sq_thresh->lower_threshold[0]); 1629bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[1]) && 1630bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[0])) { 1631bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_BELOW; 1632bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[2]) && 1633bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[1])) { 1634bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_BELOW; 1635bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[3]) && 1636bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[2])) { 1637bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_BELOW; 1638bdcd8170SKalle Valo } else if (snr <= sq_thresh->lower_threshold[3]) { 1639bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_BELOW; 1640bdcd8170SKalle Valo } 1641bdcd8170SKalle Valo } 1642bdcd8170SKalle Valo 1643bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1644bdcd8170SKalle Valo lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, 1645bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1646bdcd8170SKalle Valo upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, 1647bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1648bdcd8170SKalle Valo 1649bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1650bdcd8170SKalle Valo cmd.thresh_above1_val = upper_snr_threshold; 1651bdcd8170SKalle Valo cmd.thresh_below1_val = lower_snr_threshold; 1652bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1653bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1654bdcd8170SKalle Valo 1655bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1656bdcd8170SKalle Valo "snr: %d, threshold: %d, lower: %d, upper: %d\n", 1657bdcd8170SKalle Valo snr, new_threshold, 1658bdcd8170SKalle Valo lower_snr_threshold, upper_snr_threshold); 1659bdcd8170SKalle Valo 1660bdcd8170SKalle Valo ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); 1661bdcd8170SKalle Valo if (ret) { 1662bdcd8170SKalle Valo ath6kl_err("unable to configure snr threshold\n"); 1663bdcd8170SKalle Valo return -EIO; 1664bdcd8170SKalle Valo } 1665bdcd8170SKalle Valo 1666bdcd8170SKalle Valo return 0; 1667bdcd8170SKalle Valo } 1668bdcd8170SKalle Valo 1669bdcd8170SKalle Valo static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) 1670bdcd8170SKalle Valo { 1671bdcd8170SKalle Valo u16 ap_info_entry_size; 1672bdcd8170SKalle Valo struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; 1673bdcd8170SKalle Valo struct wmi_ap_info_v1 *ap_info_v1; 1674bdcd8170SKalle Valo u8 index; 1675bdcd8170SKalle Valo 1676bdcd8170SKalle Valo if (len < sizeof(struct wmi_aplist_event) || 1677bdcd8170SKalle Valo ev->ap_list_ver != APLIST_VER1) 1678bdcd8170SKalle Valo return -EINVAL; 1679bdcd8170SKalle Valo 1680bdcd8170SKalle Valo ap_info_entry_size = sizeof(struct wmi_ap_info_v1); 1681bdcd8170SKalle Valo ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; 1682bdcd8170SKalle Valo 1683bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1684bdcd8170SKalle Valo "number of APs in aplist event: %d\n", ev->num_ap); 1685bdcd8170SKalle Valo 1686bdcd8170SKalle Valo if (len < (int) (sizeof(struct wmi_aplist_event) + 1687bdcd8170SKalle Valo (ev->num_ap - 1) * ap_info_entry_size)) 1688bdcd8170SKalle Valo return -EINVAL; 1689bdcd8170SKalle Valo 1690bdcd8170SKalle Valo /* AP list version 1 contents */ 1691bdcd8170SKalle Valo for (index = 0; index < ev->num_ap; index++) { 1692bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", 1693bdcd8170SKalle Valo index, ap_info_v1->bssid, ap_info_v1->channel); 1694bdcd8170SKalle Valo ap_info_v1++; 1695bdcd8170SKalle Valo } 1696bdcd8170SKalle Valo 1697bdcd8170SKalle Valo return 0; 1698bdcd8170SKalle Valo } 1699bdcd8170SKalle Valo 1700bdcd8170SKalle Valo int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, 1701bdcd8170SKalle Valo enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) 1702bdcd8170SKalle Valo { 1703bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd_hdr; 1704bdcd8170SKalle Valo enum htc_endpoint_id ep_id = wmi->ep_id; 1705bdcd8170SKalle Valo int ret; 1706bdcd8170SKalle Valo 17076a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: cmd_id=%d\n", __func__, cmd_id); 17086a7c9badSJouni Malinen 1709bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 1710bdcd8170SKalle Valo return -EINVAL; 1711bdcd8170SKalle Valo 1712bdcd8170SKalle Valo if (sync_flag >= END_WMIFLAG) { 1713bdcd8170SKalle Valo dev_kfree_skb(skb); 1714bdcd8170SKalle Valo return -EINVAL; 1715bdcd8170SKalle Valo } 1716bdcd8170SKalle Valo 1717bdcd8170SKalle Valo if ((sync_flag == SYNC_BEFORE_WMIFLAG) || 1718bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1719bdcd8170SKalle Valo /* 1720bdcd8170SKalle Valo * Make sure all data currently queued is transmitted before 1721bdcd8170SKalle Valo * the cmd execution. Establish a new sync point. 1722bdcd8170SKalle Valo */ 1723bdcd8170SKalle Valo ath6kl_wmi_sync_point(wmi); 1724bdcd8170SKalle Valo } 1725bdcd8170SKalle Valo 1726bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_cmd_hdr)); 1727bdcd8170SKalle Valo 1728bdcd8170SKalle Valo cmd_hdr = (struct wmi_cmd_hdr *) skb->data; 1729bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le16(cmd_id); 1730bdcd8170SKalle Valo cmd_hdr->info1 = 0; /* added for virtual interface */ 1731bdcd8170SKalle Valo 1732bdcd8170SKalle Valo /* Only for OPT_TX_CMD, use BE endpoint. */ 1733bdcd8170SKalle Valo if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { 1734bdcd8170SKalle Valo ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, 1735bdcd8170SKalle Valo false, false, 0, NULL); 1736bdcd8170SKalle Valo if (ret) { 1737bdcd8170SKalle Valo dev_kfree_skb(skb); 1738bdcd8170SKalle Valo return ret; 1739bdcd8170SKalle Valo } 1740bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); 1741bdcd8170SKalle Valo } 1742bdcd8170SKalle Valo 1743bdcd8170SKalle Valo ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 1744bdcd8170SKalle Valo 1745bdcd8170SKalle Valo if ((sync_flag == SYNC_AFTER_WMIFLAG) || 1746bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1747bdcd8170SKalle Valo /* 1748bdcd8170SKalle Valo * Make sure all new data queued waits for the command to 1749bdcd8170SKalle Valo * execute. Establish a new sync point. 1750bdcd8170SKalle Valo */ 1751bdcd8170SKalle Valo ath6kl_wmi_sync_point(wmi); 1752bdcd8170SKalle Valo } 1753bdcd8170SKalle Valo 1754bdcd8170SKalle Valo return 0; 1755bdcd8170SKalle Valo } 1756bdcd8170SKalle Valo 1757bdcd8170SKalle Valo int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, 1758bdcd8170SKalle Valo enum dot11_auth_mode dot11_auth_mode, 1759bdcd8170SKalle Valo enum auth_mode auth_mode, 1760bdcd8170SKalle Valo enum crypto_type pairwise_crypto, 1761bdcd8170SKalle Valo u8 pairwise_crypto_len, 1762bdcd8170SKalle Valo enum crypto_type group_crypto, 1763bdcd8170SKalle Valo u8 group_crypto_len, int ssid_len, u8 *ssid, 1764bdcd8170SKalle Valo u8 *bssid, u16 channel, u32 ctrl_flags) 1765bdcd8170SKalle Valo { 1766bdcd8170SKalle Valo struct sk_buff *skb; 1767bdcd8170SKalle Valo struct wmi_connect_cmd *cc; 1768bdcd8170SKalle Valo int ret; 1769bdcd8170SKalle Valo 1770bdcd8170SKalle Valo wmi->traffic_class = 100; 1771bdcd8170SKalle Valo 1772bdcd8170SKalle Valo if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) 1773bdcd8170SKalle Valo return -EINVAL; 1774bdcd8170SKalle Valo 1775bdcd8170SKalle Valo if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) 1776bdcd8170SKalle Valo return -EINVAL; 1777bdcd8170SKalle Valo 1778bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); 1779bdcd8170SKalle Valo if (!skb) 1780bdcd8170SKalle Valo return -ENOMEM; 1781bdcd8170SKalle Valo 1782bdcd8170SKalle Valo cc = (struct wmi_connect_cmd *) skb->data; 1783bdcd8170SKalle Valo 1784bdcd8170SKalle Valo if (ssid_len) 1785bdcd8170SKalle Valo memcpy(cc->ssid, ssid, ssid_len); 1786bdcd8170SKalle Valo 1787bdcd8170SKalle Valo cc->ssid_len = ssid_len; 1788bdcd8170SKalle Valo cc->nw_type = nw_type; 1789bdcd8170SKalle Valo cc->dot11_auth_mode = dot11_auth_mode; 1790bdcd8170SKalle Valo cc->auth_mode = auth_mode; 1791bdcd8170SKalle Valo cc->prwise_crypto_type = pairwise_crypto; 1792bdcd8170SKalle Valo cc->prwise_crypto_len = pairwise_crypto_len; 1793bdcd8170SKalle Valo cc->grp_crypto_type = group_crypto; 1794bdcd8170SKalle Valo cc->grp_crypto_len = group_crypto_len; 1795bdcd8170SKalle Valo cc->ch = cpu_to_le16(channel); 1796bdcd8170SKalle Valo cc->ctrl_flags = cpu_to_le32(ctrl_flags); 1797bdcd8170SKalle Valo 1798bdcd8170SKalle Valo if (bssid != NULL) 1799bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1800bdcd8170SKalle Valo 1801bdcd8170SKalle Valo wmi->pair_crypto_type = pairwise_crypto; 1802bdcd8170SKalle Valo wmi->grp_crypto_type = group_crypto; 1803bdcd8170SKalle Valo 1804bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG); 1805bdcd8170SKalle Valo 1806bdcd8170SKalle Valo return ret; 1807bdcd8170SKalle Valo } 1808bdcd8170SKalle Valo 1809bdcd8170SKalle Valo int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel) 1810bdcd8170SKalle Valo { 1811bdcd8170SKalle Valo struct sk_buff *skb; 1812bdcd8170SKalle Valo struct wmi_reconnect_cmd *cc; 1813bdcd8170SKalle Valo int ret; 1814bdcd8170SKalle Valo 1815bdcd8170SKalle Valo wmi->traffic_class = 100; 1816bdcd8170SKalle Valo 1817bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); 1818bdcd8170SKalle Valo if (!skb) 1819bdcd8170SKalle Valo return -ENOMEM; 1820bdcd8170SKalle Valo 1821bdcd8170SKalle Valo cc = (struct wmi_reconnect_cmd *) skb->data; 1822bdcd8170SKalle Valo cc->channel = cpu_to_le16(channel); 1823bdcd8170SKalle Valo 1824bdcd8170SKalle Valo if (bssid != NULL) 1825bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1826bdcd8170SKalle Valo 1827bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID, 1828bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1829bdcd8170SKalle Valo 1830bdcd8170SKalle Valo return ret; 1831bdcd8170SKalle Valo } 1832bdcd8170SKalle Valo 1833bdcd8170SKalle Valo int ath6kl_wmi_disconnect_cmd(struct wmi *wmi) 1834bdcd8170SKalle Valo { 1835bdcd8170SKalle Valo int ret; 1836bdcd8170SKalle Valo 1837bdcd8170SKalle Valo wmi->traffic_class = 100; 1838bdcd8170SKalle Valo 1839bdcd8170SKalle Valo /* Disconnect command does not need to do a SYNC before. */ 1840bdcd8170SKalle Valo ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID); 1841bdcd8170SKalle Valo 1842bdcd8170SKalle Valo return ret; 1843bdcd8170SKalle Valo } 1844bdcd8170SKalle Valo 1845bdcd8170SKalle Valo int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, 1846bdcd8170SKalle Valo u32 force_fgscan, u32 is_legacy, 1847bdcd8170SKalle Valo u32 home_dwell_time, u32 force_scan_interval, 1848bdcd8170SKalle Valo s8 num_chan, u16 *ch_list) 1849bdcd8170SKalle Valo { 1850bdcd8170SKalle Valo struct sk_buff *skb; 1851bdcd8170SKalle Valo struct wmi_start_scan_cmd *sc; 1852bdcd8170SKalle Valo s8 size; 18531276c9efSEdward Lu int i, ret; 1854bdcd8170SKalle Valo 1855bdcd8170SKalle Valo size = sizeof(struct wmi_start_scan_cmd); 1856bdcd8170SKalle Valo 1857bdcd8170SKalle Valo if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 1858bdcd8170SKalle Valo return -EINVAL; 1859bdcd8170SKalle Valo 1860bdcd8170SKalle Valo if (num_chan > WMI_MAX_CHANNELS) 1861bdcd8170SKalle Valo return -EINVAL; 1862bdcd8170SKalle Valo 1863bdcd8170SKalle Valo if (num_chan) 1864bdcd8170SKalle Valo size += sizeof(u16) * (num_chan - 1); 1865bdcd8170SKalle Valo 1866bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(size); 1867bdcd8170SKalle Valo if (!skb) 1868bdcd8170SKalle Valo return -ENOMEM; 1869bdcd8170SKalle Valo 1870bdcd8170SKalle Valo sc = (struct wmi_start_scan_cmd *) skb->data; 1871bdcd8170SKalle Valo sc->scan_type = scan_type; 1872bdcd8170SKalle Valo sc->force_fg_scan = cpu_to_le32(force_fgscan); 1873bdcd8170SKalle Valo sc->is_legacy = cpu_to_le32(is_legacy); 1874bdcd8170SKalle Valo sc->home_dwell_time = cpu_to_le32(home_dwell_time); 1875bdcd8170SKalle Valo sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 1876bdcd8170SKalle Valo sc->num_ch = num_chan; 1877bdcd8170SKalle Valo 18781276c9efSEdward Lu for (i = 0; i < num_chan; i++) 18791276c9efSEdward Lu sc->ch_list[i] = cpu_to_le16(ch_list[i]); 1880bdcd8170SKalle Valo 1881bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID, 1882bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1883bdcd8170SKalle Valo 1884bdcd8170SKalle Valo return ret; 1885bdcd8170SKalle Valo } 1886bdcd8170SKalle Valo 1887bdcd8170SKalle Valo int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, 1888bdcd8170SKalle Valo u16 fg_end_sec, u16 bg_sec, 1889bdcd8170SKalle Valo u16 minact_chdw_msec, u16 maxact_chdw_msec, 1890bdcd8170SKalle Valo u16 pas_chdw_msec, u8 short_scan_ratio, 1891bdcd8170SKalle Valo u8 scan_ctrl_flag, u32 max_dfsch_act_time, 1892bdcd8170SKalle Valo u16 maxact_scan_per_ssid) 1893bdcd8170SKalle Valo { 1894bdcd8170SKalle Valo struct sk_buff *skb; 1895bdcd8170SKalle Valo struct wmi_scan_params_cmd *sc; 1896bdcd8170SKalle Valo int ret; 1897bdcd8170SKalle Valo 1898bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); 1899bdcd8170SKalle Valo if (!skb) 1900bdcd8170SKalle Valo return -ENOMEM; 1901bdcd8170SKalle Valo 1902bdcd8170SKalle Valo sc = (struct wmi_scan_params_cmd *) skb->data; 1903bdcd8170SKalle Valo sc->fg_start_period = cpu_to_le16(fg_start_sec); 1904bdcd8170SKalle Valo sc->fg_end_period = cpu_to_le16(fg_end_sec); 1905bdcd8170SKalle Valo sc->bg_period = cpu_to_le16(bg_sec); 1906bdcd8170SKalle Valo sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); 1907bdcd8170SKalle Valo sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); 1908bdcd8170SKalle Valo sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); 1909bdcd8170SKalle Valo sc->short_scan_ratio = short_scan_ratio; 1910bdcd8170SKalle Valo sc->scan_ctrl_flags = scan_ctrl_flag; 1911bdcd8170SKalle Valo sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); 1912bdcd8170SKalle Valo sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); 1913bdcd8170SKalle Valo 1914bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID, 1915bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1916bdcd8170SKalle Valo return ret; 1917bdcd8170SKalle Valo } 1918bdcd8170SKalle Valo 1919bdcd8170SKalle Valo int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) 1920bdcd8170SKalle Valo { 1921bdcd8170SKalle Valo struct sk_buff *skb; 1922bdcd8170SKalle Valo struct wmi_bss_filter_cmd *cmd; 1923bdcd8170SKalle Valo int ret; 1924bdcd8170SKalle Valo 1925bdcd8170SKalle Valo if (filter >= LAST_BSS_FILTER) 1926bdcd8170SKalle Valo return -EINVAL; 1927bdcd8170SKalle Valo 1928bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1929bdcd8170SKalle Valo if (!skb) 1930bdcd8170SKalle Valo return -ENOMEM; 1931bdcd8170SKalle Valo 1932bdcd8170SKalle Valo cmd = (struct wmi_bss_filter_cmd *) skb->data; 1933bdcd8170SKalle Valo cmd->bss_filter = filter; 1934bdcd8170SKalle Valo cmd->ie_mask = cpu_to_le32(ie_mask); 1935bdcd8170SKalle Valo 1936bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID, 1937bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1938bdcd8170SKalle Valo return ret; 1939bdcd8170SKalle Valo } 1940bdcd8170SKalle Valo 1941bdcd8170SKalle Valo int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, 1942bdcd8170SKalle Valo u8 ssid_len, u8 *ssid) 1943bdcd8170SKalle Valo { 1944bdcd8170SKalle Valo struct sk_buff *skb; 1945bdcd8170SKalle Valo struct wmi_probed_ssid_cmd *cmd; 1946bdcd8170SKalle Valo int ret; 1947bdcd8170SKalle Valo 1948bdcd8170SKalle Valo if (index > MAX_PROBED_SSID_INDEX) 1949bdcd8170SKalle Valo return -EINVAL; 1950bdcd8170SKalle Valo 1951bdcd8170SKalle Valo if (ssid_len > sizeof(cmd->ssid)) 1952bdcd8170SKalle Valo return -EINVAL; 1953bdcd8170SKalle Valo 1954bdcd8170SKalle Valo if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) 1955bdcd8170SKalle Valo return -EINVAL; 1956bdcd8170SKalle Valo 1957bdcd8170SKalle Valo if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) 1958bdcd8170SKalle Valo return -EINVAL; 1959bdcd8170SKalle Valo 1960bdcd8170SKalle Valo if (flag & SPECIFIC_SSID_FLAG) 1961bdcd8170SKalle Valo wmi->is_probe_ssid = true; 1962bdcd8170SKalle Valo 1963bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1964bdcd8170SKalle Valo if (!skb) 1965bdcd8170SKalle Valo return -ENOMEM; 1966bdcd8170SKalle Valo 1967bdcd8170SKalle Valo cmd = (struct wmi_probed_ssid_cmd *) skb->data; 1968bdcd8170SKalle Valo cmd->entry_index = index; 1969bdcd8170SKalle Valo cmd->flag = flag; 1970bdcd8170SKalle Valo cmd->ssid_len = ssid_len; 1971bdcd8170SKalle Valo memcpy(cmd->ssid, ssid, ssid_len); 1972bdcd8170SKalle Valo 1973bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID, 1974bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1975bdcd8170SKalle Valo return ret; 1976bdcd8170SKalle Valo } 1977bdcd8170SKalle Valo 1978bdcd8170SKalle Valo int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, 1979bdcd8170SKalle Valo u16 listen_beacons) 1980bdcd8170SKalle Valo { 1981bdcd8170SKalle Valo struct sk_buff *skb; 1982bdcd8170SKalle Valo struct wmi_listen_int_cmd *cmd; 1983bdcd8170SKalle Valo int ret; 1984bdcd8170SKalle Valo 1985bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1986bdcd8170SKalle Valo if (!skb) 1987bdcd8170SKalle Valo return -ENOMEM; 1988bdcd8170SKalle Valo 1989bdcd8170SKalle Valo cmd = (struct wmi_listen_int_cmd *) skb->data; 1990bdcd8170SKalle Valo cmd->listen_intvl = cpu_to_le16(listen_interval); 1991bdcd8170SKalle Valo cmd->num_beacons = cpu_to_le16(listen_beacons); 1992bdcd8170SKalle Valo 1993bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID, 1994bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1995bdcd8170SKalle Valo return ret; 1996bdcd8170SKalle Valo } 1997bdcd8170SKalle Valo 1998bdcd8170SKalle Valo int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode) 1999bdcd8170SKalle Valo { 2000bdcd8170SKalle Valo struct sk_buff *skb; 2001bdcd8170SKalle Valo struct wmi_power_mode_cmd *cmd; 2002bdcd8170SKalle Valo int ret; 2003bdcd8170SKalle Valo 2004bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2005bdcd8170SKalle Valo if (!skb) 2006bdcd8170SKalle Valo return -ENOMEM; 2007bdcd8170SKalle Valo 2008bdcd8170SKalle Valo cmd = (struct wmi_power_mode_cmd *) skb->data; 2009bdcd8170SKalle Valo cmd->pwr_mode = pwr_mode; 2010bdcd8170SKalle Valo wmi->pwr_mode = pwr_mode; 2011bdcd8170SKalle Valo 2012bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID, 2013bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2014bdcd8170SKalle Valo return ret; 2015bdcd8170SKalle Valo } 2016bdcd8170SKalle Valo 2017bdcd8170SKalle Valo int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, 2018bdcd8170SKalle Valo u16 ps_poll_num, u16 dtim_policy, 2019bdcd8170SKalle Valo u16 tx_wakeup_policy, u16 num_tx_to_wakeup, 2020bdcd8170SKalle Valo u16 ps_fail_event_policy) 2021bdcd8170SKalle Valo { 2022bdcd8170SKalle Valo struct sk_buff *skb; 2023bdcd8170SKalle Valo struct wmi_power_params_cmd *pm; 2024bdcd8170SKalle Valo int ret; 2025bdcd8170SKalle Valo 2026bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); 2027bdcd8170SKalle Valo if (!skb) 2028bdcd8170SKalle Valo return -ENOMEM; 2029bdcd8170SKalle Valo 2030bdcd8170SKalle Valo pm = (struct wmi_power_params_cmd *)skb->data; 2031bdcd8170SKalle Valo pm->idle_period = cpu_to_le16(idle_period); 2032bdcd8170SKalle Valo pm->pspoll_number = cpu_to_le16(ps_poll_num); 2033bdcd8170SKalle Valo pm->dtim_policy = cpu_to_le16(dtim_policy); 2034bdcd8170SKalle Valo pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); 2035bdcd8170SKalle Valo pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); 2036bdcd8170SKalle Valo pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); 2037bdcd8170SKalle Valo 2038bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID, 2039bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2040bdcd8170SKalle Valo return ret; 2041bdcd8170SKalle Valo } 2042bdcd8170SKalle Valo 2043bdcd8170SKalle Valo int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) 2044bdcd8170SKalle Valo { 2045bdcd8170SKalle Valo struct sk_buff *skb; 2046bdcd8170SKalle Valo struct wmi_disc_timeout_cmd *cmd; 2047bdcd8170SKalle Valo int ret; 2048bdcd8170SKalle Valo 2049bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2050bdcd8170SKalle Valo if (!skb) 2051bdcd8170SKalle Valo return -ENOMEM; 2052bdcd8170SKalle Valo 2053bdcd8170SKalle Valo cmd = (struct wmi_disc_timeout_cmd *) skb->data; 2054bdcd8170SKalle Valo cmd->discon_timeout = timeout; 2055bdcd8170SKalle Valo 2056bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID, 2057bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2058bdcd8170SKalle Valo return ret; 2059bdcd8170SKalle Valo } 2060bdcd8170SKalle Valo 2061bdcd8170SKalle Valo int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, 2062bdcd8170SKalle Valo enum crypto_type key_type, 2063bdcd8170SKalle Valo u8 key_usage, u8 key_len, 2064bdcd8170SKalle Valo u8 *key_rsc, u8 *key_material, 2065bdcd8170SKalle Valo u8 key_op_ctrl, u8 *mac_addr, 2066bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2067bdcd8170SKalle Valo { 2068bdcd8170SKalle Valo struct sk_buff *skb; 2069bdcd8170SKalle Valo struct wmi_add_cipher_key_cmd *cmd; 2070bdcd8170SKalle Valo int ret; 2071bdcd8170SKalle Valo 20729a5b1318SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " 20739a5b1318SJouni Malinen "key_usage=%d key_len=%d key_op_ctrl=%d\n", 20749a5b1318SJouni Malinen key_index, key_type, key_usage, key_len, key_op_ctrl); 20759a5b1318SJouni Malinen 2076bdcd8170SKalle Valo if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || 2077bdcd8170SKalle Valo (key_material == NULL)) 2078bdcd8170SKalle Valo return -EINVAL; 2079bdcd8170SKalle Valo 2080bdcd8170SKalle Valo if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) 2081bdcd8170SKalle Valo return -EINVAL; 2082bdcd8170SKalle Valo 2083bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2084bdcd8170SKalle Valo if (!skb) 2085bdcd8170SKalle Valo return -ENOMEM; 2086bdcd8170SKalle Valo 2087bdcd8170SKalle Valo cmd = (struct wmi_add_cipher_key_cmd *) skb->data; 2088bdcd8170SKalle Valo cmd->key_index = key_index; 2089bdcd8170SKalle Valo cmd->key_type = key_type; 2090bdcd8170SKalle Valo cmd->key_usage = key_usage; 2091bdcd8170SKalle Valo cmd->key_len = key_len; 2092bdcd8170SKalle Valo memcpy(cmd->key, key_material, key_len); 2093bdcd8170SKalle Valo 2094bdcd8170SKalle Valo if (key_rsc != NULL) 2095bdcd8170SKalle Valo memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc)); 2096bdcd8170SKalle Valo 2097bdcd8170SKalle Valo cmd->key_op_ctrl = key_op_ctrl; 2098bdcd8170SKalle Valo 2099bdcd8170SKalle Valo if (mac_addr) 2100bdcd8170SKalle Valo memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); 2101bdcd8170SKalle Valo 2102bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID, 2103bdcd8170SKalle Valo sync_flag); 2104bdcd8170SKalle Valo 2105bdcd8170SKalle Valo return ret; 2106bdcd8170SKalle Valo } 2107bdcd8170SKalle Valo 2108bdcd8170SKalle Valo int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) 2109bdcd8170SKalle Valo { 2110bdcd8170SKalle Valo struct sk_buff *skb; 2111bdcd8170SKalle Valo struct wmi_add_krk_cmd *cmd; 2112bdcd8170SKalle Valo int ret; 2113bdcd8170SKalle Valo 2114bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2115bdcd8170SKalle Valo if (!skb) 2116bdcd8170SKalle Valo return -ENOMEM; 2117bdcd8170SKalle Valo 2118bdcd8170SKalle Valo cmd = (struct wmi_add_krk_cmd *) skb->data; 2119bdcd8170SKalle Valo memcpy(cmd->krk, krk, WMI_KRK_LEN); 2120bdcd8170SKalle Valo 2121bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG); 2122bdcd8170SKalle Valo 2123bdcd8170SKalle Valo return ret; 2124bdcd8170SKalle Valo } 2125bdcd8170SKalle Valo 2126bdcd8170SKalle Valo int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index) 2127bdcd8170SKalle Valo { 2128bdcd8170SKalle Valo struct sk_buff *skb; 2129bdcd8170SKalle Valo struct wmi_delete_cipher_key_cmd *cmd; 2130bdcd8170SKalle Valo int ret; 2131bdcd8170SKalle Valo 2132bdcd8170SKalle Valo if (key_index > WMI_MAX_KEY_INDEX) 2133bdcd8170SKalle Valo return -EINVAL; 2134bdcd8170SKalle Valo 2135bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2136bdcd8170SKalle Valo if (!skb) 2137bdcd8170SKalle Valo return -ENOMEM; 2138bdcd8170SKalle Valo 2139bdcd8170SKalle Valo cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; 2140bdcd8170SKalle Valo cmd->key_index = key_index; 2141bdcd8170SKalle Valo 2142bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID, 2143bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2144bdcd8170SKalle Valo 2145bdcd8170SKalle Valo return ret; 2146bdcd8170SKalle Valo } 2147bdcd8170SKalle Valo 2148bdcd8170SKalle Valo int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, 2149bdcd8170SKalle Valo const u8 *pmkid, bool set) 2150bdcd8170SKalle Valo { 2151bdcd8170SKalle Valo struct sk_buff *skb; 2152bdcd8170SKalle Valo struct wmi_setpmkid_cmd *cmd; 2153bdcd8170SKalle Valo int ret; 2154bdcd8170SKalle Valo 2155bdcd8170SKalle Valo if (bssid == NULL) 2156bdcd8170SKalle Valo return -EINVAL; 2157bdcd8170SKalle Valo 2158bdcd8170SKalle Valo if (set && pmkid == NULL) 2159bdcd8170SKalle Valo return -EINVAL; 2160bdcd8170SKalle Valo 2161bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2162bdcd8170SKalle Valo if (!skb) 2163bdcd8170SKalle Valo return -ENOMEM; 2164bdcd8170SKalle Valo 2165bdcd8170SKalle Valo cmd = (struct wmi_setpmkid_cmd *) skb->data; 2166bdcd8170SKalle Valo memcpy(cmd->bssid, bssid, ETH_ALEN); 2167bdcd8170SKalle Valo if (set) { 2168bdcd8170SKalle Valo memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); 2169bdcd8170SKalle Valo cmd->enable = PMKID_ENABLE; 2170bdcd8170SKalle Valo } else { 2171bdcd8170SKalle Valo memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); 2172bdcd8170SKalle Valo cmd->enable = PMKID_DISABLE; 2173bdcd8170SKalle Valo } 2174bdcd8170SKalle Valo 2175bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID, 2176bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2177bdcd8170SKalle Valo 2178bdcd8170SKalle Valo return ret; 2179bdcd8170SKalle Valo } 2180bdcd8170SKalle Valo 2181bdcd8170SKalle Valo static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, 2182bdcd8170SKalle Valo enum htc_endpoint_id ep_id) 2183bdcd8170SKalle Valo { 2184bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 2185bdcd8170SKalle Valo int ret; 2186bdcd8170SKalle Valo 2187bdcd8170SKalle Valo if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) 2188bdcd8170SKalle Valo return -EINVAL; 2189bdcd8170SKalle Valo 2190bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 2191bdcd8170SKalle Valo 2192bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) skb->data; 2193bdcd8170SKalle Valo data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; 2194bdcd8170SKalle Valo data_hdr->info3 = 0; 2195bdcd8170SKalle Valo 2196bdcd8170SKalle Valo ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 2197bdcd8170SKalle Valo 2198bdcd8170SKalle Valo return ret; 2199bdcd8170SKalle Valo } 2200bdcd8170SKalle Valo 2201bdcd8170SKalle Valo static int ath6kl_wmi_sync_point(struct wmi *wmi) 2202bdcd8170SKalle Valo { 2203bdcd8170SKalle Valo struct sk_buff *skb; 2204bdcd8170SKalle Valo struct wmi_sync_cmd *cmd; 2205bdcd8170SKalle Valo struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; 2206bdcd8170SKalle Valo enum htc_endpoint_id ep_id; 2207bdcd8170SKalle Valo u8 index, num_pri_streams = 0; 2208bdcd8170SKalle Valo int ret = 0; 2209bdcd8170SKalle Valo 2210bdcd8170SKalle Valo memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); 2211bdcd8170SKalle Valo 2212bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2213bdcd8170SKalle Valo 2214bdcd8170SKalle Valo for (index = 0; index < WMM_NUM_AC; index++) { 2215bdcd8170SKalle Valo if (wmi->fat_pipe_exist & (1 << index)) { 2216bdcd8170SKalle Valo num_pri_streams++; 2217bdcd8170SKalle Valo data_sync_bufs[num_pri_streams - 1].traffic_class = 2218bdcd8170SKalle Valo index; 2219bdcd8170SKalle Valo } 2220bdcd8170SKalle Valo } 2221bdcd8170SKalle Valo 2222bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2223bdcd8170SKalle Valo 2224bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2225bdcd8170SKalle Valo if (!skb) { 2226bdcd8170SKalle Valo ret = -ENOMEM; 2227bdcd8170SKalle Valo goto free_skb; 2228bdcd8170SKalle Valo } 2229bdcd8170SKalle Valo 2230bdcd8170SKalle Valo cmd = (struct wmi_sync_cmd *) skb->data; 2231bdcd8170SKalle Valo 2232bdcd8170SKalle Valo /* 2233bdcd8170SKalle Valo * In the SYNC cmd sent on the control Ep, send a bitmap 2234bdcd8170SKalle Valo * of the data eps on which the Data Sync will be sent 2235bdcd8170SKalle Valo */ 2236bdcd8170SKalle Valo cmd->data_sync_map = wmi->fat_pipe_exist; 2237bdcd8170SKalle Valo 2238bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2239bdcd8170SKalle Valo data_sync_bufs[index].skb = ath6kl_buf_alloc(0); 2240bdcd8170SKalle Valo if (data_sync_bufs[index].skb == NULL) { 2241bdcd8170SKalle Valo ret = -ENOMEM; 2242bdcd8170SKalle Valo break; 2243bdcd8170SKalle Valo } 2244bdcd8170SKalle Valo } 2245bdcd8170SKalle Valo 2246bdcd8170SKalle Valo /* 2247bdcd8170SKalle Valo * If buffer allocation for any of the dataSync fails, 2248bdcd8170SKalle Valo * then do not send the Synchronize cmd on the control ep 2249bdcd8170SKalle Valo */ 2250bdcd8170SKalle Valo if (ret) 2251bdcd8170SKalle Valo goto free_skb; 2252bdcd8170SKalle Valo 2253bdcd8170SKalle Valo /* 2254bdcd8170SKalle Valo * Send sync cmd followed by sync data messages on all 2255bdcd8170SKalle Valo * endpoints being used 2256bdcd8170SKalle Valo */ 2257bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID, 2258bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2259bdcd8170SKalle Valo 2260bdcd8170SKalle Valo if (ret) 2261bdcd8170SKalle Valo goto free_skb; 2262bdcd8170SKalle Valo 2263bdcd8170SKalle Valo /* cmd buffer sent, we no longer own it */ 2264bdcd8170SKalle Valo skb = NULL; 2265bdcd8170SKalle Valo 2266bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2267bdcd8170SKalle Valo 2268bdcd8170SKalle Valo if (WARN_ON(!data_sync_bufs[index].skb)) 2269bdcd8170SKalle Valo break; 2270bdcd8170SKalle Valo 2271bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, 2272bdcd8170SKalle Valo data_sync_bufs[index]. 2273bdcd8170SKalle Valo traffic_class); 2274bdcd8170SKalle Valo ret = 2275bdcd8170SKalle Valo ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, 2276bdcd8170SKalle Valo ep_id); 2277bdcd8170SKalle Valo 2278bdcd8170SKalle Valo if (ret) 2279bdcd8170SKalle Valo break; 2280bdcd8170SKalle Valo 2281bdcd8170SKalle Valo data_sync_bufs[index].skb = NULL; 2282bdcd8170SKalle Valo } 2283bdcd8170SKalle Valo 2284bdcd8170SKalle Valo free_skb: 2285bdcd8170SKalle Valo /* free up any resources left over (possibly due to an error) */ 2286bdcd8170SKalle Valo if (skb) 2287bdcd8170SKalle Valo dev_kfree_skb(skb); 2288bdcd8170SKalle Valo 2289bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2290bdcd8170SKalle Valo if (data_sync_bufs[index].skb != NULL) { 2291bdcd8170SKalle Valo dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. 2292bdcd8170SKalle Valo skb); 2293bdcd8170SKalle Valo } 2294bdcd8170SKalle Valo } 2295bdcd8170SKalle Valo 2296bdcd8170SKalle Valo return ret; 2297bdcd8170SKalle Valo } 2298bdcd8170SKalle Valo 2299bdcd8170SKalle Valo int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, 2300bdcd8170SKalle Valo struct wmi_create_pstream_cmd *params) 2301bdcd8170SKalle Valo { 2302bdcd8170SKalle Valo struct sk_buff *skb; 2303bdcd8170SKalle Valo struct wmi_create_pstream_cmd *cmd; 2304bdcd8170SKalle Valo u8 fatpipe_exist_for_ac = 0; 2305bdcd8170SKalle Valo s32 min_phy = 0; 2306bdcd8170SKalle Valo s32 nominal_phy = 0; 2307bdcd8170SKalle Valo int ret; 2308bdcd8170SKalle Valo 2309bdcd8170SKalle Valo if (!((params->user_pri < 8) && 2310bdcd8170SKalle Valo (params->user_pri <= 0x7) && 2311bdcd8170SKalle Valo (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && 2312bdcd8170SKalle Valo (params->traffic_direc == UPLINK_TRAFFIC || 2313bdcd8170SKalle Valo params->traffic_direc == DNLINK_TRAFFIC || 2314bdcd8170SKalle Valo params->traffic_direc == BIDIR_TRAFFIC) && 2315bdcd8170SKalle Valo (params->traffic_type == TRAFFIC_TYPE_APERIODIC || 2316bdcd8170SKalle Valo params->traffic_type == TRAFFIC_TYPE_PERIODIC) && 2317bdcd8170SKalle Valo (params->voice_psc_cap == DISABLE_FOR_THIS_AC || 2318bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_THIS_AC || 2319bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_ALL_AC) && 2320bdcd8170SKalle Valo (params->tsid == WMI_IMPLICIT_PSTREAM || 2321bdcd8170SKalle Valo params->tsid <= WMI_MAX_THINSTREAM))) { 2322bdcd8170SKalle Valo return -EINVAL; 2323bdcd8170SKalle Valo } 2324bdcd8170SKalle Valo 2325bdcd8170SKalle Valo /* 2326bdcd8170SKalle Valo * Check nominal PHY rate is >= minimalPHY, 2327bdcd8170SKalle Valo * so that DUT can allow TSRS IE 2328bdcd8170SKalle Valo */ 2329bdcd8170SKalle Valo 2330bdcd8170SKalle Valo /* Get the physical rate (units of bps) */ 2331bdcd8170SKalle Valo min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); 2332bdcd8170SKalle Valo 2333bdcd8170SKalle Valo /* Check minimal phy < nominal phy rate */ 2334bdcd8170SKalle Valo if (params->nominal_phy >= min_phy) { 2335bdcd8170SKalle Valo /* unit of 500 kbps */ 2336bdcd8170SKalle Valo nominal_phy = (params->nominal_phy * 1000) / 500; 2337bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2338bdcd8170SKalle Valo "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", 2339bdcd8170SKalle Valo min_phy, nominal_phy); 2340bdcd8170SKalle Valo 2341bdcd8170SKalle Valo params->nominal_phy = nominal_phy; 2342bdcd8170SKalle Valo } else { 2343bdcd8170SKalle Valo params->nominal_phy = 0; 2344bdcd8170SKalle Valo } 2345bdcd8170SKalle Valo 2346bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2347bdcd8170SKalle Valo if (!skb) 2348bdcd8170SKalle Valo return -ENOMEM; 2349bdcd8170SKalle Valo 2350bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2351bdcd8170SKalle Valo "sending create_pstream_cmd: ac=%d tsid:%d\n", 2352bdcd8170SKalle Valo params->traffic_class, params->tsid); 2353bdcd8170SKalle Valo 2354bdcd8170SKalle Valo cmd = (struct wmi_create_pstream_cmd *) skb->data; 2355bdcd8170SKalle Valo memcpy(cmd, params, sizeof(*cmd)); 2356bdcd8170SKalle Valo 2357bdcd8170SKalle Valo /* This is an implicitly created Fat pipe */ 2358bdcd8170SKalle Valo if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { 2359bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2360bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2361bdcd8170SKalle Valo (1 << params->traffic_class)); 2362bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2363bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2364bdcd8170SKalle Valo } else { 2365bdcd8170SKalle Valo /* explicitly created thin stream within a fat pipe */ 2366bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2367bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2368bdcd8170SKalle Valo (1 << params->traffic_class)); 2369bdcd8170SKalle Valo wmi->stream_exist_for_ac[params->traffic_class] |= 2370bdcd8170SKalle Valo (1 << params->tsid); 2371bdcd8170SKalle Valo /* 2372bdcd8170SKalle Valo * If a thinstream becomes active, the fat pipe automatically 2373bdcd8170SKalle Valo * becomes active 2374bdcd8170SKalle Valo */ 2375bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2376bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2377bdcd8170SKalle Valo } 2378bdcd8170SKalle Valo 2379bdcd8170SKalle Valo /* 2380bdcd8170SKalle Valo * Indicate activty change to driver layer only if this is the 2381bdcd8170SKalle Valo * first TSID to get created in this AC explicitly or an implicit 2382bdcd8170SKalle Valo * fat pipe is getting created. 2383bdcd8170SKalle Valo */ 2384bdcd8170SKalle Valo if (!fatpipe_exist_for_ac) 2385bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2386bdcd8170SKalle Valo params->traffic_class, true); 2387bdcd8170SKalle Valo 2388bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID, 2389bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2390bdcd8170SKalle Valo return ret; 2391bdcd8170SKalle Valo } 2392bdcd8170SKalle Valo 2393bdcd8170SKalle Valo int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) 2394bdcd8170SKalle Valo { 2395bdcd8170SKalle Valo struct sk_buff *skb; 2396bdcd8170SKalle Valo struct wmi_delete_pstream_cmd *cmd; 2397bdcd8170SKalle Valo u16 active_tsids = 0; 2398bdcd8170SKalle Valo int ret; 2399bdcd8170SKalle Valo 2400bdcd8170SKalle Valo if (traffic_class > 3) { 2401bdcd8170SKalle Valo ath6kl_err("invalid traffic class: %d\n", traffic_class); 2402bdcd8170SKalle Valo return -EINVAL; 2403bdcd8170SKalle Valo } 2404bdcd8170SKalle Valo 2405bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2406bdcd8170SKalle Valo if (!skb) 2407bdcd8170SKalle Valo return -ENOMEM; 2408bdcd8170SKalle Valo 2409bdcd8170SKalle Valo cmd = (struct wmi_delete_pstream_cmd *) skb->data; 2410bdcd8170SKalle Valo cmd->traffic_class = traffic_class; 2411bdcd8170SKalle Valo cmd->tsid = tsid; 2412bdcd8170SKalle Valo 2413bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2414bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2415bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2416bdcd8170SKalle Valo 2417bdcd8170SKalle Valo if (!(active_tsids & (1 << tsid))) { 2418bdcd8170SKalle Valo dev_kfree_skb(skb); 2419bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2420bdcd8170SKalle Valo "TSID %d doesn't exist for traffic class: %d\n", 2421bdcd8170SKalle Valo tsid, traffic_class); 2422bdcd8170SKalle Valo return -ENODATA; 2423bdcd8170SKalle Valo } 2424bdcd8170SKalle Valo 2425bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2426bdcd8170SKalle Valo "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", 2427bdcd8170SKalle Valo traffic_class, tsid); 2428bdcd8170SKalle Valo 2429bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID, 2430bdcd8170SKalle Valo SYNC_BEFORE_WMIFLAG); 2431bdcd8170SKalle Valo 2432bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2433bdcd8170SKalle Valo wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); 2434bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2435bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2436bdcd8170SKalle Valo 2437bdcd8170SKalle Valo /* 2438bdcd8170SKalle Valo * Indicate stream inactivity to driver layer only if all tsids 2439bdcd8170SKalle Valo * within this AC are deleted. 2440bdcd8170SKalle Valo */ 2441bdcd8170SKalle Valo if (!active_tsids) { 2442bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2443bdcd8170SKalle Valo traffic_class, false); 2444bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << traffic_class); 2445bdcd8170SKalle Valo } 2446bdcd8170SKalle Valo 2447bdcd8170SKalle Valo return ret; 2448bdcd8170SKalle Valo } 2449bdcd8170SKalle Valo 2450bdcd8170SKalle Valo int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) 2451bdcd8170SKalle Valo { 2452bdcd8170SKalle Valo struct sk_buff *skb; 2453bdcd8170SKalle Valo struct wmi_set_ip_cmd *cmd; 2454bdcd8170SKalle Valo int ret; 2455bdcd8170SKalle Valo 2456bdcd8170SKalle Valo /* Multicast address are not valid */ 2457bdcd8170SKalle Valo if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) || 2458bdcd8170SKalle Valo (*((u8 *) &ip_cmd->ips[1]) >= 0xE0)) 2459bdcd8170SKalle Valo return -EINVAL; 2460bdcd8170SKalle Valo 2461bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); 2462bdcd8170SKalle Valo if (!skb) 2463bdcd8170SKalle Valo return -ENOMEM; 2464bdcd8170SKalle Valo 2465bdcd8170SKalle Valo cmd = (struct wmi_set_ip_cmd *) skb->data; 2466bdcd8170SKalle Valo memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); 2467bdcd8170SKalle Valo 2468bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG); 2469bdcd8170SKalle Valo return ret; 2470bdcd8170SKalle Valo } 2471bdcd8170SKalle Valo 2472bdcd8170SKalle Valo static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, 2473bdcd8170SKalle Valo int len) 2474bdcd8170SKalle Valo { 2475bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_wow_list_reply)) 2476bdcd8170SKalle Valo return -EINVAL; 2477bdcd8170SKalle Valo 2478bdcd8170SKalle Valo return 0; 2479bdcd8170SKalle Valo } 2480bdcd8170SKalle Valo 2481bdcd8170SKalle Valo static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, 2482bdcd8170SKalle Valo enum wmix_command_id cmd_id, 2483bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2484bdcd8170SKalle Valo { 2485bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd_hdr; 2486bdcd8170SKalle Valo int ret; 2487bdcd8170SKalle Valo 2488bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmix_cmd_hdr)); 2489bdcd8170SKalle Valo 2490bdcd8170SKalle Valo cmd_hdr = (struct wmix_cmd_hdr *) skb->data; 2491bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le32(cmd_id); 2492bdcd8170SKalle Valo 2493bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag); 2494bdcd8170SKalle Valo 2495bdcd8170SKalle Valo return ret; 2496bdcd8170SKalle Valo } 2497bdcd8170SKalle Valo 2498bdcd8170SKalle Valo int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) 2499bdcd8170SKalle Valo { 2500bdcd8170SKalle Valo struct sk_buff *skb; 2501bdcd8170SKalle Valo struct wmix_hb_challenge_resp_cmd *cmd; 2502bdcd8170SKalle Valo int ret; 2503bdcd8170SKalle Valo 2504bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2505bdcd8170SKalle Valo if (!skb) 2506bdcd8170SKalle Valo return -ENOMEM; 2507bdcd8170SKalle Valo 2508bdcd8170SKalle Valo cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; 2509bdcd8170SKalle Valo cmd->cookie = cpu_to_le32(cookie); 2510bdcd8170SKalle Valo cmd->source = cpu_to_le32(source); 2511bdcd8170SKalle Valo 2512bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, 2513bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2514bdcd8170SKalle Valo return ret; 2515bdcd8170SKalle Valo } 2516bdcd8170SKalle Valo 2517939f1cceSKalle Valo int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config) 2518939f1cceSKalle Valo { 2519939f1cceSKalle Valo struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd; 2520939f1cceSKalle Valo struct sk_buff *skb; 2521939f1cceSKalle Valo int ret; 2522939f1cceSKalle Valo 2523939f1cceSKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2524939f1cceSKalle Valo if (!skb) 2525939f1cceSKalle Valo return -ENOMEM; 2526939f1cceSKalle Valo 2527939f1cceSKalle Valo cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data; 2528939f1cceSKalle Valo cmd->valid = cpu_to_le32(valid); 2529939f1cceSKalle Valo cmd->config = cpu_to_le32(config); 2530939f1cceSKalle Valo 2531939f1cceSKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID, 2532939f1cceSKalle Valo NO_SYNC_WMIFLAG); 2533939f1cceSKalle Valo return ret; 2534939f1cceSKalle Valo } 2535939f1cceSKalle Valo 2536bdcd8170SKalle Valo int ath6kl_wmi_get_stats_cmd(struct wmi *wmi) 2537bdcd8170SKalle Valo { 2538bdcd8170SKalle Valo return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID); 2539bdcd8170SKalle Valo } 2540bdcd8170SKalle Valo 2541bdcd8170SKalle Valo int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) 2542bdcd8170SKalle Valo { 2543bdcd8170SKalle Valo struct sk_buff *skb; 2544bdcd8170SKalle Valo struct wmi_set_tx_pwr_cmd *cmd; 2545bdcd8170SKalle Valo int ret; 2546bdcd8170SKalle Valo 2547bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); 2548bdcd8170SKalle Valo if (!skb) 2549bdcd8170SKalle Valo return -ENOMEM; 2550bdcd8170SKalle Valo 2551bdcd8170SKalle Valo cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; 2552bdcd8170SKalle Valo cmd->dbM = dbM; 2553bdcd8170SKalle Valo 2554bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID, 2555bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2556bdcd8170SKalle Valo 2557bdcd8170SKalle Valo return ret; 2558bdcd8170SKalle Valo } 2559bdcd8170SKalle Valo 2560bdcd8170SKalle Valo int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) 2561bdcd8170SKalle Valo { 2562bdcd8170SKalle Valo return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID); 2563bdcd8170SKalle Valo } 2564bdcd8170SKalle Valo 2565bdcd8170SKalle Valo int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) 2566bdcd8170SKalle Valo { 2567bdcd8170SKalle Valo struct sk_buff *skb; 2568bdcd8170SKalle Valo struct wmi_set_lpreamble_cmd *cmd; 2569bdcd8170SKalle Valo int ret; 2570bdcd8170SKalle Valo 2571bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); 2572bdcd8170SKalle Valo if (!skb) 2573bdcd8170SKalle Valo return -ENOMEM; 2574bdcd8170SKalle Valo 2575bdcd8170SKalle Valo cmd = (struct wmi_set_lpreamble_cmd *) skb->data; 2576bdcd8170SKalle Valo cmd->status = status; 2577bdcd8170SKalle Valo cmd->preamble_policy = preamble_policy; 2578bdcd8170SKalle Valo 2579bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID, 2580bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2581bdcd8170SKalle Valo return ret; 2582bdcd8170SKalle Valo } 2583bdcd8170SKalle Valo 2584bdcd8170SKalle Valo int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) 2585bdcd8170SKalle Valo { 2586bdcd8170SKalle Valo struct sk_buff *skb; 2587bdcd8170SKalle Valo struct wmi_set_rts_cmd *cmd; 2588bdcd8170SKalle Valo int ret; 2589bdcd8170SKalle Valo 2590bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); 2591bdcd8170SKalle Valo if (!skb) 2592bdcd8170SKalle Valo return -ENOMEM; 2593bdcd8170SKalle Valo 2594bdcd8170SKalle Valo cmd = (struct wmi_set_rts_cmd *) skb->data; 2595bdcd8170SKalle Valo cmd->threshold = cpu_to_le16(threshold); 2596bdcd8170SKalle Valo 2597bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG); 2598bdcd8170SKalle Valo return ret; 2599bdcd8170SKalle Valo } 2600bdcd8170SKalle Valo 2601bdcd8170SKalle Valo int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) 2602bdcd8170SKalle Valo { 2603bdcd8170SKalle Valo struct sk_buff *skb; 2604bdcd8170SKalle Valo struct wmi_set_wmm_txop_cmd *cmd; 2605bdcd8170SKalle Valo int ret; 2606bdcd8170SKalle Valo 2607bdcd8170SKalle Valo if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) 2608bdcd8170SKalle Valo return -EINVAL; 2609bdcd8170SKalle Valo 2610bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); 2611bdcd8170SKalle Valo if (!skb) 2612bdcd8170SKalle Valo return -ENOMEM; 2613bdcd8170SKalle Valo 2614bdcd8170SKalle Valo cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; 2615bdcd8170SKalle Valo cmd->txop_enable = cfg; 2616bdcd8170SKalle Valo 2617bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID, 2618bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2619bdcd8170SKalle Valo return ret; 2620bdcd8170SKalle Valo } 2621bdcd8170SKalle Valo 2622bdcd8170SKalle Valo int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) 2623bdcd8170SKalle Valo { 2624bdcd8170SKalle Valo struct sk_buff *skb; 2625bdcd8170SKalle Valo struct wmi_set_keepalive_cmd *cmd; 2626bdcd8170SKalle Valo int ret; 2627bdcd8170SKalle Valo 2628bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2629bdcd8170SKalle Valo if (!skb) 2630bdcd8170SKalle Valo return -ENOMEM; 2631bdcd8170SKalle Valo 2632bdcd8170SKalle Valo cmd = (struct wmi_set_keepalive_cmd *) skb->data; 2633bdcd8170SKalle Valo cmd->keep_alive_intvl = keep_alive_intvl; 2634bdcd8170SKalle Valo wmi->keep_alive_intvl = keep_alive_intvl; 2635bdcd8170SKalle Valo 2636bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, 2637bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2638bdcd8170SKalle Valo return ret; 2639bdcd8170SKalle Valo } 2640bdcd8170SKalle Valo 2641003353b0SKalle Valo int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) 2642003353b0SKalle Valo { 2643003353b0SKalle Valo struct sk_buff *skb; 2644003353b0SKalle Valo int ret; 2645003353b0SKalle Valo 2646003353b0SKalle Valo skb = ath6kl_wmi_get_new_buf(len); 2647003353b0SKalle Valo if (!skb) 2648003353b0SKalle Valo return -ENOMEM; 2649003353b0SKalle Valo 2650003353b0SKalle Valo memcpy(skb->data, buf, len); 2651003353b0SKalle Valo 2652003353b0SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); 2653003353b0SKalle Valo 2654003353b0SKalle Valo return ret; 2655003353b0SKalle Valo } 2656003353b0SKalle Valo 2657003353b0SKalle Valo 2658bdcd8170SKalle Valo s32 ath6kl_wmi_get_rate(s8 rate_index) 2659bdcd8170SKalle Valo { 2660bdcd8170SKalle Valo if (rate_index == RATE_AUTO) 2661bdcd8170SKalle Valo return 0; 2662bdcd8170SKalle Valo 2663bdcd8170SKalle Valo return wmi_rate_tbl[(u32) rate_index][0]; 2664bdcd8170SKalle Valo } 2665bdcd8170SKalle Valo 2666bdcd8170SKalle Valo void ath6kl_wmi_node_return(struct wmi *wmi, struct bss *bss) 2667bdcd8170SKalle Valo { 2668bdcd8170SKalle Valo if (bss) 26697c3075e9SVasanthakumar Thiagarajan wlan_node_return(&wmi->parent_dev->scan_table, bss); 2670bdcd8170SKalle Valo } 2671bdcd8170SKalle Valo 2672bdcd8170SKalle Valo struct bss *ath6kl_wmi_find_ssid_node(struct wmi *wmi, u8 * ssid, 2673bdcd8170SKalle Valo u32 ssid_len, bool is_wpa2, 2674bdcd8170SKalle Valo bool match_ssid) 2675bdcd8170SKalle Valo { 2676bdcd8170SKalle Valo struct bss *node = NULL; 2677bdcd8170SKalle Valo 26787c3075e9SVasanthakumar Thiagarajan node = wlan_find_ssid_node(&wmi->parent_dev->scan_table, ssid, 2679bdcd8170SKalle Valo ssid_len, is_wpa2, match_ssid); 2680bdcd8170SKalle Valo return node; 2681bdcd8170SKalle Valo } 2682bdcd8170SKalle Valo 2683bdcd8170SKalle Valo struct bss *ath6kl_wmi_find_node(struct wmi *wmi, const u8 * mac_addr) 2684bdcd8170SKalle Valo { 2685bdcd8170SKalle Valo struct bss *ni = NULL; 2686bdcd8170SKalle Valo 26877c3075e9SVasanthakumar Thiagarajan ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); 2688bdcd8170SKalle Valo 2689bdcd8170SKalle Valo return ni; 2690bdcd8170SKalle Valo } 2691bdcd8170SKalle Valo 2692bdcd8170SKalle Valo void ath6kl_wmi_node_free(struct wmi *wmi, const u8 * mac_addr) 2693bdcd8170SKalle Valo { 2694bdcd8170SKalle Valo struct bss *ni = NULL; 2695bdcd8170SKalle Valo 26967c3075e9SVasanthakumar Thiagarajan ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); 2697bdcd8170SKalle Valo if (ni != NULL) 26987c3075e9SVasanthakumar Thiagarajan wlan_node_reclaim(&wmi->parent_dev->scan_table, ni); 2699bdcd8170SKalle Valo 2700bdcd8170SKalle Valo return; 2701bdcd8170SKalle Valo } 2702bdcd8170SKalle Valo 2703bdcd8170SKalle Valo static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, 2704bdcd8170SKalle Valo u32 len) 2705bdcd8170SKalle Valo { 2706bdcd8170SKalle Valo struct wmi_pmkid_list_reply *reply; 2707bdcd8170SKalle Valo u32 expected_len; 2708bdcd8170SKalle Valo 2709bdcd8170SKalle Valo if (len < sizeof(struct wmi_pmkid_list_reply)) 2710bdcd8170SKalle Valo return -EINVAL; 2711bdcd8170SKalle Valo 2712bdcd8170SKalle Valo reply = (struct wmi_pmkid_list_reply *)datap; 2713bdcd8170SKalle Valo expected_len = sizeof(reply->num_pmkid) + 2714bdcd8170SKalle Valo le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; 2715bdcd8170SKalle Valo 2716bdcd8170SKalle Valo if (len < expected_len) 2717bdcd8170SKalle Valo return -EINVAL; 2718bdcd8170SKalle Valo 2719bdcd8170SKalle Valo return 0; 2720bdcd8170SKalle Valo } 2721bdcd8170SKalle Valo 2722bdcd8170SKalle Valo static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2723bdcd8170SKalle Valo { 2724bdcd8170SKalle Valo struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; 2725bdcd8170SKalle Valo 2726bdcd8170SKalle Valo aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid, 2727bdcd8170SKalle Valo le16_to_cpu(cmd->st_seq_no), cmd->win_sz); 2728bdcd8170SKalle Valo 2729bdcd8170SKalle Valo return 0; 2730bdcd8170SKalle Valo } 2731bdcd8170SKalle Valo 2732bdcd8170SKalle Valo static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len) 2733bdcd8170SKalle Valo { 2734bdcd8170SKalle Valo struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; 2735bdcd8170SKalle Valo 2736bdcd8170SKalle Valo aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid); 2737bdcd8170SKalle Valo 2738bdcd8170SKalle Valo return 0; 2739bdcd8170SKalle Valo } 2740bdcd8170SKalle Valo 2741bdcd8170SKalle Valo /* AP mode functions */ 27426a7c9badSJouni Malinen 27436a7c9badSJouni Malinen int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) 27446a7c9badSJouni Malinen { 27456a7c9badSJouni Malinen struct sk_buff *skb; 27466a7c9badSJouni Malinen struct wmi_connect_cmd *cm; 27476a7c9badSJouni Malinen int res; 27486a7c9badSJouni Malinen 27496a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 27506a7c9badSJouni Malinen if (!skb) 27516a7c9badSJouni Malinen return -ENOMEM; 27526a7c9badSJouni Malinen 27536a7c9badSJouni Malinen cm = (struct wmi_connect_cmd *) skb->data; 27546a7c9badSJouni Malinen memcpy(cm, p, sizeof(*cm)); 27556a7c9badSJouni Malinen 27566a7c9badSJouni Malinen res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID, 27576a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 27586a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " 27596a7c9badSJouni Malinen "ctrl_flags=0x%x-> res=%d\n", 27606a7c9badSJouni Malinen __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), 27616a7c9badSJouni Malinen le32_to_cpu(p->ctrl_flags), res); 27626a7c9badSJouni Malinen return res; 27636a7c9badSJouni Malinen } 27646a7c9badSJouni Malinen 276523875136SJouni Malinen int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason) 276623875136SJouni Malinen { 276723875136SJouni Malinen struct sk_buff *skb; 276823875136SJouni Malinen struct wmi_ap_set_mlme_cmd *cm; 276923875136SJouni Malinen 277023875136SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 277123875136SJouni Malinen if (!skb) 277223875136SJouni Malinen return -ENOMEM; 277323875136SJouni Malinen 277423875136SJouni Malinen cm = (struct wmi_ap_set_mlme_cmd *) skb->data; 277523875136SJouni Malinen memcpy(cm->mac, mac, ETH_ALEN); 277623875136SJouni Malinen cm->reason = cpu_to_le16(reason); 277723875136SJouni Malinen cm->cmd = cmd; 277823875136SJouni Malinen 277923875136SJouni Malinen return ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_SET_MLME_CMDID, 278023875136SJouni Malinen NO_SYNC_WMIFLAG); 278123875136SJouni Malinen } 278223875136SJouni Malinen 2783bdcd8170SKalle Valo static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len) 2784bdcd8170SKalle Valo { 2785bdcd8170SKalle Valo struct wmi_pspoll_event *ev; 2786bdcd8170SKalle Valo 2787bdcd8170SKalle Valo if (len < sizeof(struct wmi_pspoll_event)) 2788bdcd8170SKalle Valo return -EINVAL; 2789bdcd8170SKalle Valo 2790bdcd8170SKalle Valo ev = (struct wmi_pspoll_event *) datap; 2791bdcd8170SKalle Valo 2792bdcd8170SKalle Valo ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid)); 2793bdcd8170SKalle Valo 2794bdcd8170SKalle Valo return 0; 2795bdcd8170SKalle Valo } 2796bdcd8170SKalle Valo 2797bdcd8170SKalle Valo static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len) 2798bdcd8170SKalle Valo { 2799bdcd8170SKalle Valo ath6kl_dtimexpiry_event(wmi->parent_dev); 2800bdcd8170SKalle Valo 2801bdcd8170SKalle Valo return 0; 2802bdcd8170SKalle Valo } 2803bdcd8170SKalle Valo 2804bdcd8170SKalle Valo int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag) 2805bdcd8170SKalle Valo { 2806bdcd8170SKalle Valo struct sk_buff *skb; 2807bdcd8170SKalle Valo struct wmi_ap_set_pvb_cmd *cmd; 2808bdcd8170SKalle Valo int ret; 2809bdcd8170SKalle Valo 2810bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); 2811bdcd8170SKalle Valo if (!skb) 2812bdcd8170SKalle Valo return -ENOMEM; 2813bdcd8170SKalle Valo 2814bdcd8170SKalle Valo cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; 2815bdcd8170SKalle Valo cmd->aid = cpu_to_le16(aid); 2816d6e51e6aSJouni Malinen cmd->rsvd = cpu_to_le16(0); 2817bdcd8170SKalle Valo cmd->flag = cpu_to_le32(flag); 2818bdcd8170SKalle Valo 2819bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID, 2820bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2821bdcd8170SKalle Valo 2822bdcd8170SKalle Valo return 0; 2823bdcd8170SKalle Valo } 2824bdcd8170SKalle Valo 2825bdcd8170SKalle Valo int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, 2826bdcd8170SKalle Valo bool rx_dot11_hdr, bool defrag_on_host) 2827bdcd8170SKalle Valo { 2828bdcd8170SKalle Valo struct sk_buff *skb; 2829bdcd8170SKalle Valo struct wmi_rx_frame_format_cmd *cmd; 2830bdcd8170SKalle Valo int ret; 2831bdcd8170SKalle Valo 2832bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2833bdcd8170SKalle Valo if (!skb) 2834bdcd8170SKalle Valo return -ENOMEM; 2835bdcd8170SKalle Valo 2836bdcd8170SKalle Valo cmd = (struct wmi_rx_frame_format_cmd *) skb->data; 2837bdcd8170SKalle Valo cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; 2838bdcd8170SKalle Valo cmd->defrag_on_host = defrag_on_host ? 1 : 0; 2839bdcd8170SKalle Valo cmd->meta_ver = rx_meta_ver; 2840bdcd8170SKalle Valo 2841bdcd8170SKalle Valo /* Delete the local aggr state, on host */ 2842bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID, 2843bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2844bdcd8170SKalle Valo 2845bdcd8170SKalle Valo return ret; 2846bdcd8170SKalle Valo } 2847bdcd8170SKalle Valo 28486a7c9badSJouni Malinen int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, 28496a7c9badSJouni Malinen u8 ie_len) 28506a7c9badSJouni Malinen { 28516a7c9badSJouni Malinen struct sk_buff *skb; 28526a7c9badSJouni Malinen struct wmi_set_appie_cmd *p; 28536a7c9badSJouni Malinen 28546a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 28556a7c9badSJouni Malinen if (!skb) 28566a7c9badSJouni Malinen return -ENOMEM; 28576a7c9badSJouni Malinen 28586a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " 28596a7c9badSJouni Malinen "ie_len=%u\n", mgmt_frm_type, ie_len); 28606a7c9badSJouni Malinen p = (struct wmi_set_appie_cmd *) skb->data; 28616a7c9badSJouni Malinen p->mgmt_frm_type = mgmt_frm_type; 28626a7c9badSJouni Malinen p->ie_len = ie_len; 28636a7c9badSJouni Malinen memcpy(p->ie_info, ie, ie_len); 28646a7c9badSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID, 28656a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 28666a7c9badSJouni Malinen } 28676a7c9badSJouni Malinen 28686465ddcfSJouni Malinen int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) 28696465ddcfSJouni Malinen { 28706465ddcfSJouni Malinen struct sk_buff *skb; 28716465ddcfSJouni Malinen struct wmi_disable_11b_rates_cmd *cmd; 28726465ddcfSJouni Malinen 28736465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 28746465ddcfSJouni Malinen if (!skb) 28756465ddcfSJouni Malinen return -ENOMEM; 28766465ddcfSJouni Malinen 28776465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", 28786465ddcfSJouni Malinen disable); 28796465ddcfSJouni Malinen cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; 28806465ddcfSJouni Malinen cmd->disable = disable ? 1 : 0; 28816465ddcfSJouni Malinen 28826465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_DISABLE_11B_RATES_CMDID, 28836465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28846465ddcfSJouni Malinen } 28856465ddcfSJouni Malinen 28866465ddcfSJouni Malinen int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur) 28876465ddcfSJouni Malinen { 28886465ddcfSJouni Malinen struct sk_buff *skb; 28896465ddcfSJouni Malinen struct wmi_remain_on_chnl_cmd *p; 28906465ddcfSJouni Malinen 28916465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 28926465ddcfSJouni Malinen if (!skb) 28936465ddcfSJouni Malinen return -ENOMEM; 28946465ddcfSJouni Malinen 28956465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", 28966465ddcfSJouni Malinen freq, dur); 28976465ddcfSJouni Malinen p = (struct wmi_remain_on_chnl_cmd *) skb->data; 28986465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 28996465ddcfSJouni Malinen p->duration = cpu_to_le32(dur); 29006465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_REMAIN_ON_CHNL_CMDID, 29016465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 29026465ddcfSJouni Malinen } 29036465ddcfSJouni Malinen 29046465ddcfSJouni Malinen int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait, 29056465ddcfSJouni Malinen const u8 *data, u16 data_len) 29066465ddcfSJouni Malinen { 29076465ddcfSJouni Malinen struct sk_buff *skb; 29086465ddcfSJouni Malinen struct wmi_send_action_cmd *p; 2909a0df5db1SJouni Malinen u8 *buf; 29106465ddcfSJouni Malinen 29116465ddcfSJouni Malinen if (wait) 29126465ddcfSJouni Malinen return -EINVAL; /* Offload for wait not supported */ 29136465ddcfSJouni Malinen 2914a0df5db1SJouni Malinen buf = kmalloc(data_len, GFP_KERNEL); 2915a0df5db1SJouni Malinen if (!buf) 29166465ddcfSJouni Malinen return -ENOMEM; 29176465ddcfSJouni Malinen 2918a0df5db1SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 2919a0df5db1SJouni Malinen if (!skb) { 2920a0df5db1SJouni Malinen kfree(buf); 2921a0df5db1SJouni Malinen return -ENOMEM; 2922a0df5db1SJouni Malinen } 2923a0df5db1SJouni Malinen 2924a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 2925a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = buf; 2926a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = data_len; 2927a0df5db1SJouni Malinen 29286465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " 29296465ddcfSJouni Malinen "len=%u\n", id, freq, wait, data_len); 29306465ddcfSJouni Malinen p = (struct wmi_send_action_cmd *) skb->data; 29316465ddcfSJouni Malinen p->id = cpu_to_le32(id); 29326465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 29336465ddcfSJouni Malinen p->wait = cpu_to_le32(wait); 29346465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 29356465ddcfSJouni Malinen memcpy(p->data, data, data_len); 29366465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_ACTION_CMDID, 29376465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 29386465ddcfSJouni Malinen } 29396465ddcfSJouni Malinen 29406465ddcfSJouni Malinen int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq, 29416465ddcfSJouni Malinen const u8 *dst, 29426465ddcfSJouni Malinen const u8 *data, u16 data_len) 29436465ddcfSJouni Malinen { 29446465ddcfSJouni Malinen struct sk_buff *skb; 29456465ddcfSJouni Malinen struct wmi_p2p_probe_response_cmd *p; 29466465ddcfSJouni Malinen 29476465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 29486465ddcfSJouni Malinen if (!skb) 29496465ddcfSJouni Malinen return -ENOMEM; 29506465ddcfSJouni Malinen 29516465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM " 29526465ddcfSJouni Malinen "len=%u\n", freq, dst, data_len); 29536465ddcfSJouni Malinen p = (struct wmi_p2p_probe_response_cmd *) skb->data; 29546465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 29556465ddcfSJouni Malinen memcpy(p->destination_addr, dst, ETH_ALEN); 29566465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 29576465ddcfSJouni Malinen memcpy(p->data, data, data_len); 29586465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_PROBE_RESPONSE_CMDID, 29596465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 29606465ddcfSJouni Malinen } 29616465ddcfSJouni Malinen 29626465ddcfSJouni Malinen int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable) 29636465ddcfSJouni Malinen { 29646465ddcfSJouni Malinen struct sk_buff *skb; 29656465ddcfSJouni Malinen struct wmi_probe_req_report_cmd *p; 29666465ddcfSJouni Malinen 29676465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 29686465ddcfSJouni Malinen if (!skb) 29696465ddcfSJouni Malinen return -ENOMEM; 29706465ddcfSJouni Malinen 29716465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", 29726465ddcfSJouni Malinen enable); 29736465ddcfSJouni Malinen p = (struct wmi_probe_req_report_cmd *) skb->data; 29746465ddcfSJouni Malinen p->enable = enable ? 1 : 0; 29756465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_PROBE_REQ_REPORT_CMDID, 29766465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 29776465ddcfSJouni Malinen } 29786465ddcfSJouni Malinen 29796465ddcfSJouni Malinen int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags) 29806465ddcfSJouni Malinen { 29816465ddcfSJouni Malinen struct sk_buff *skb; 29826465ddcfSJouni Malinen struct wmi_get_p2p_info *p; 29836465ddcfSJouni Malinen 29846465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 29856465ddcfSJouni Malinen if (!skb) 29866465ddcfSJouni Malinen return -ENOMEM; 29876465ddcfSJouni Malinen 29886465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", 29896465ddcfSJouni Malinen info_req_flags); 29906465ddcfSJouni Malinen p = (struct wmi_get_p2p_info *) skb->data; 29916465ddcfSJouni Malinen p->info_req_flags = cpu_to_le32(info_req_flags); 29926465ddcfSJouni Malinen return ath6kl_wmi_cmd_send(wmi, skb, WMI_GET_P2P_INFO_CMDID, 29936465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 29946465ddcfSJouni Malinen } 29956465ddcfSJouni Malinen 29966465ddcfSJouni Malinen int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi) 29976465ddcfSJouni Malinen { 29986465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); 29996465ddcfSJouni Malinen return ath6kl_wmi_simple_cmd(wmi, WMI_CANCEL_REMAIN_ON_CHNL_CMDID); 30006465ddcfSJouni Malinen } 30016465ddcfSJouni Malinen 3002bdcd8170SKalle Valo static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) 3003bdcd8170SKalle Valo { 3004bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd; 3005bdcd8170SKalle Valo u32 len; 3006bdcd8170SKalle Valo u16 id; 3007bdcd8170SKalle Valo u8 *datap; 3008bdcd8170SKalle Valo int ret = 0; 3009bdcd8170SKalle Valo 3010bdcd8170SKalle Valo if (skb->len < sizeof(struct wmix_cmd_hdr)) { 3011bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 3012bdcd8170SKalle Valo wmi->stat.cmd_len_err++; 3013bdcd8170SKalle Valo return -EINVAL; 3014bdcd8170SKalle Valo } 3015bdcd8170SKalle Valo 3016bdcd8170SKalle Valo cmd = (struct wmix_cmd_hdr *) skb->data; 3017bdcd8170SKalle Valo id = le32_to_cpu(cmd->cmd_id); 3018bdcd8170SKalle Valo 3019bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmix_cmd_hdr)); 3020bdcd8170SKalle Valo 3021bdcd8170SKalle Valo datap = skb->data; 3022bdcd8170SKalle Valo len = skb->len; 3023bdcd8170SKalle Valo 3024bdcd8170SKalle Valo switch (id) { 3025bdcd8170SKalle Valo case WMIX_HB_CHALLENGE_RESP_EVENTID: 3026bdcd8170SKalle Valo break; 3027bdcd8170SKalle Valo case WMIX_DBGLOG_EVENTID: 3028bdf5396bSKalle Valo ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len); 3029bdcd8170SKalle Valo break; 3030bdcd8170SKalle Valo default: 3031bdcd8170SKalle Valo ath6kl_err("unknown cmd id 0x%x\n", id); 3032bdcd8170SKalle Valo wmi->stat.cmd_id_err++; 3033bdcd8170SKalle Valo ret = -EINVAL; 3034bdcd8170SKalle Valo break; 3035bdcd8170SKalle Valo } 3036bdcd8170SKalle Valo 3037bdcd8170SKalle Valo return ret; 3038bdcd8170SKalle Valo } 3039bdcd8170SKalle Valo 3040bdcd8170SKalle Valo /* Control Path */ 3041bdcd8170SKalle Valo int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) 3042bdcd8170SKalle Valo { 3043bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd; 3044bdcd8170SKalle Valo u32 len; 3045bdcd8170SKalle Valo u16 id; 3046bdcd8170SKalle Valo u8 *datap; 3047bdcd8170SKalle Valo int ret = 0; 3048bdcd8170SKalle Valo 3049bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 3050bdcd8170SKalle Valo return -EINVAL; 3051bdcd8170SKalle Valo 3052bdcd8170SKalle Valo if (skb->len < sizeof(struct wmi_cmd_hdr)) { 3053bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 3054bdcd8170SKalle Valo dev_kfree_skb(skb); 3055bdcd8170SKalle Valo wmi->stat.cmd_len_err++; 3056bdcd8170SKalle Valo return -EINVAL; 3057bdcd8170SKalle Valo } 3058bdcd8170SKalle Valo 3059bdcd8170SKalle Valo cmd = (struct wmi_cmd_hdr *) skb->data; 3060bdcd8170SKalle Valo id = le16_to_cpu(cmd->cmd_id); 3061bdcd8170SKalle Valo 3062bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmi_cmd_hdr)); 3063bdcd8170SKalle Valo 3064bdcd8170SKalle Valo datap = skb->data; 3065bdcd8170SKalle Valo len = skb->len; 3066bdcd8170SKalle Valo 3067bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "%s: wmi id: %d\n", __func__, id); 3068bdcd8170SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "msg payload ", datap, len); 3069bdcd8170SKalle Valo 3070bdcd8170SKalle Valo switch (id) { 3071bdcd8170SKalle Valo case WMI_GET_BITRATE_CMDID: 3072bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); 3073bdcd8170SKalle Valo ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); 3074bdcd8170SKalle Valo break; 3075bdcd8170SKalle Valo case WMI_GET_CHANNEL_LIST_CMDID: 3076bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); 3077bdcd8170SKalle Valo ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); 3078bdcd8170SKalle Valo break; 3079bdcd8170SKalle Valo case WMI_GET_TX_PWR_CMDID: 3080bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); 3081bdcd8170SKalle Valo ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); 3082bdcd8170SKalle Valo break; 3083bdcd8170SKalle Valo case WMI_READY_EVENTID: 3084bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); 3085bdcd8170SKalle Valo ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); 3086bdcd8170SKalle Valo break; 3087bdcd8170SKalle Valo case WMI_CONNECT_EVENTID: 3088bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); 3089bdcd8170SKalle Valo ret = ath6kl_wmi_connect_event_rx(wmi, datap, len); 3090bdcd8170SKalle Valo break; 3091bdcd8170SKalle Valo case WMI_DISCONNECT_EVENTID: 3092bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); 3093bdcd8170SKalle Valo ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len); 3094bdcd8170SKalle Valo break; 3095bdcd8170SKalle Valo case WMI_PEER_NODE_EVENTID: 3096bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); 3097bdcd8170SKalle Valo ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); 3098bdcd8170SKalle Valo break; 3099bdcd8170SKalle Valo case WMI_TKIP_MICERR_EVENTID: 3100bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); 3101bdcd8170SKalle Valo ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len); 3102bdcd8170SKalle Valo break; 3103bdcd8170SKalle Valo case WMI_BSSINFO_EVENTID: 3104bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); 3105bdcd8170SKalle Valo ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb, datap); 3106bdcd8170SKalle Valo ret = ath6kl_wmi_bssinfo_event_rx(wmi, skb->data, skb->len); 3107bdcd8170SKalle Valo break; 3108bdcd8170SKalle Valo case WMI_REGDOMAIN_EVENTID: 3109bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); 311006033760SVivek Natarajan ath6kl_wmi_regdomain_event(wmi, datap, len); 3111bdcd8170SKalle Valo break; 3112bdcd8170SKalle Valo case WMI_PSTREAM_TIMEOUT_EVENTID: 3113bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); 3114bdcd8170SKalle Valo ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); 3115bdcd8170SKalle Valo break; 3116bdcd8170SKalle Valo case WMI_NEIGHBOR_REPORT_EVENTID: 3117bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); 3118bdcd8170SKalle Valo break; 3119bdcd8170SKalle Valo case WMI_SCAN_COMPLETE_EVENTID: 3120bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); 3121bdcd8170SKalle Valo ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len); 3122bdcd8170SKalle Valo break; 3123bdcd8170SKalle Valo case WMI_CMDERROR_EVENTID: 3124bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); 3125bdcd8170SKalle Valo ret = ath6kl_wmi_error_event_rx(wmi, datap, len); 3126bdcd8170SKalle Valo break; 3127bdcd8170SKalle Valo case WMI_REPORT_STATISTICS_EVENTID: 3128bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); 3129bdcd8170SKalle Valo ret = ath6kl_wmi_stats_event_rx(wmi, datap, len); 3130bdcd8170SKalle Valo break; 3131bdcd8170SKalle Valo case WMI_RSSI_THRESHOLD_EVENTID: 3132bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); 3133bdcd8170SKalle Valo ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); 3134bdcd8170SKalle Valo break; 3135bdcd8170SKalle Valo case WMI_ERROR_REPORT_EVENTID: 3136bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); 3137bdcd8170SKalle Valo break; 3138bdcd8170SKalle Valo case WMI_OPT_RX_FRAME_EVENTID: 3139bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); 3140*f195d507SJouni Malinen /* this event has been deprecated */ 3141bdcd8170SKalle Valo break; 3142bdcd8170SKalle Valo case WMI_REPORT_ROAM_TBL_EVENTID: 3143bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); 3144bdcd8170SKalle Valo break; 3145bdcd8170SKalle Valo case WMI_EXTENSION_EVENTID: 3146bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); 3147bdcd8170SKalle Valo ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); 3148bdcd8170SKalle Valo break; 3149bdcd8170SKalle Valo case WMI_CAC_EVENTID: 3150bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); 3151bdcd8170SKalle Valo ret = ath6kl_wmi_cac_event_rx(wmi, datap, len); 3152bdcd8170SKalle Valo break; 3153bdcd8170SKalle Valo case WMI_CHANNEL_CHANGE_EVENTID: 3154bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); 3155bdcd8170SKalle Valo break; 3156bdcd8170SKalle Valo case WMI_REPORT_ROAM_DATA_EVENTID: 3157bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); 3158bdcd8170SKalle Valo break; 3159003353b0SKalle Valo case WMI_TEST_EVENTID: 3160003353b0SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n"); 3161003353b0SKalle Valo ret = ath6kl_wmi_tcmd_test_report_rx(wmi, datap, len); 3162003353b0SKalle Valo break; 3163bdcd8170SKalle Valo case WMI_GET_FIXRATES_CMDID: 3164bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); 3165bdcd8170SKalle Valo ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); 3166bdcd8170SKalle Valo break; 3167bdcd8170SKalle Valo case WMI_TX_RETRY_ERR_EVENTID: 3168bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); 3169bdcd8170SKalle Valo break; 3170bdcd8170SKalle Valo case WMI_SNR_THRESHOLD_EVENTID: 3171bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); 3172bdcd8170SKalle Valo ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); 3173bdcd8170SKalle Valo break; 3174bdcd8170SKalle Valo case WMI_LQ_THRESHOLD_EVENTID: 3175bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); 3176bdcd8170SKalle Valo break; 3177bdcd8170SKalle Valo case WMI_APLIST_EVENTID: 3178bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); 3179bdcd8170SKalle Valo ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); 3180bdcd8170SKalle Valo break; 3181bdcd8170SKalle Valo case WMI_GET_KEEPALIVE_CMDID: 3182bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); 3183bdcd8170SKalle Valo ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); 3184bdcd8170SKalle Valo break; 3185bdcd8170SKalle Valo case WMI_GET_WOW_LIST_EVENTID: 3186bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); 3187bdcd8170SKalle Valo ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len); 3188bdcd8170SKalle Valo break; 3189bdcd8170SKalle Valo case WMI_GET_PMKID_LIST_EVENTID: 3190bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); 3191bdcd8170SKalle Valo ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); 3192bdcd8170SKalle Valo break; 3193bdcd8170SKalle Valo case WMI_PSPOLL_EVENTID: 3194bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); 3195bdcd8170SKalle Valo ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len); 3196bdcd8170SKalle Valo break; 3197bdcd8170SKalle Valo case WMI_DTIMEXPIRY_EVENTID: 3198bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); 3199bdcd8170SKalle Valo ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len); 3200bdcd8170SKalle Valo break; 3201bdcd8170SKalle Valo case WMI_SET_PARAMS_REPLY_EVENTID: 3202bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); 3203bdcd8170SKalle Valo break; 3204bdcd8170SKalle Valo case WMI_ADDBA_REQ_EVENTID: 3205bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); 3206bdcd8170SKalle Valo ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len); 3207bdcd8170SKalle Valo break; 3208bdcd8170SKalle Valo case WMI_ADDBA_RESP_EVENTID: 3209bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); 3210bdcd8170SKalle Valo break; 3211bdcd8170SKalle Valo case WMI_DELBA_REQ_EVENTID: 3212bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); 3213bdcd8170SKalle Valo ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len); 3214bdcd8170SKalle Valo break; 3215bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_CONFIG_EVENTID: 3216bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3217bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); 3218bdcd8170SKalle Valo break; 3219bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_STATS_EVENTID: 3220bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3221bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); 3222bdcd8170SKalle Valo break; 3223bdcd8170SKalle Valo case WMI_TX_COMPLETE_EVENTID: 3224bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); 3225bdcd8170SKalle Valo ret = ath6kl_wmi_tx_complete_event_rx(datap, len); 3226bdcd8170SKalle Valo break; 32276465ddcfSJouni Malinen case WMI_REMAIN_ON_CHNL_EVENTID: 32286465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); 3229f9e5f05cSJouni Malinen ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len); 32306465ddcfSJouni Malinen break; 32316465ddcfSJouni Malinen case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: 32326465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, 32336465ddcfSJouni Malinen "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); 3234f9e5f05cSJouni Malinen ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, 3235f9e5f05cSJouni Malinen len); 32366465ddcfSJouni Malinen break; 32376465ddcfSJouni Malinen case WMI_TX_STATUS_EVENTID: 32386465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); 3239a0df5db1SJouni Malinen ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len); 32406465ddcfSJouni Malinen break; 32416465ddcfSJouni Malinen case WMI_RX_PROBE_REQ_EVENTID: 32426465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); 3243ae32c30aSJouni Malinen ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len); 32446465ddcfSJouni Malinen break; 32456465ddcfSJouni Malinen case WMI_P2P_CAPABILITIES_EVENTID: 32466465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); 32476465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); 32486465ddcfSJouni Malinen break; 32496465ddcfSJouni Malinen case WMI_RX_ACTION_EVENTID: 32506465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); 32519809d8efSJouni Malinen ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len); 32526465ddcfSJouni Malinen break; 32536465ddcfSJouni Malinen case WMI_P2P_INFO_EVENTID: 32546465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); 32556465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_info_event_rx(datap, len); 32566465ddcfSJouni Malinen break; 3257bdcd8170SKalle Valo default: 3258bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); 3259bdcd8170SKalle Valo wmi->stat.cmd_id_err++; 3260bdcd8170SKalle Valo ret = -EINVAL; 3261bdcd8170SKalle Valo break; 3262bdcd8170SKalle Valo } 3263bdcd8170SKalle Valo 3264bdcd8170SKalle Valo dev_kfree_skb(skb); 3265bdcd8170SKalle Valo 3266bdcd8170SKalle Valo return ret; 3267bdcd8170SKalle Valo } 3268bdcd8170SKalle Valo 3269bdcd8170SKalle Valo static void ath6kl_wmi_qos_state_init(struct wmi *wmi) 3270bdcd8170SKalle Valo { 3271bdcd8170SKalle Valo if (!wmi) 3272bdcd8170SKalle Valo return; 3273bdcd8170SKalle Valo 3274bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 3275bdcd8170SKalle Valo 3276bdcd8170SKalle Valo wmi->fat_pipe_exist = 0; 3277bdcd8170SKalle Valo memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); 3278bdcd8170SKalle Valo 3279bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 3280bdcd8170SKalle Valo } 3281bdcd8170SKalle Valo 32822865785eSVasanthakumar Thiagarajan void *ath6kl_wmi_init(struct ath6kl *dev) 3283bdcd8170SKalle Valo { 3284bdcd8170SKalle Valo struct wmi *wmi; 3285bdcd8170SKalle Valo 3286bdcd8170SKalle Valo wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); 3287bdcd8170SKalle Valo if (!wmi) 3288bdcd8170SKalle Valo return NULL; 3289bdcd8170SKalle Valo 3290bdcd8170SKalle Valo spin_lock_init(&wmi->lock); 3291bdcd8170SKalle Valo 3292bdcd8170SKalle Valo wmi->parent_dev = dev; 3293bdcd8170SKalle Valo 3294bdcd8170SKalle Valo ath6kl_wmi_qos_state_init(wmi); 3295bdcd8170SKalle Valo 3296bdcd8170SKalle Valo wmi->pwr_mode = REC_POWER; 3297bdcd8170SKalle Valo wmi->phy_mode = WMI_11G_MODE; 3298bdcd8170SKalle Valo 3299bdcd8170SKalle Valo wmi->pair_crypto_type = NONE_CRYPT; 3300bdcd8170SKalle Valo wmi->grp_crypto_type = NONE_CRYPT; 3301bdcd8170SKalle Valo 3302bdcd8170SKalle Valo wmi->ht_allowed[A_BAND_24GHZ] = 1; 3303bdcd8170SKalle Valo wmi->ht_allowed[A_BAND_5GHZ] = 1; 3304bdcd8170SKalle Valo 3305bdcd8170SKalle Valo return wmi; 3306bdcd8170SKalle Valo } 3307bdcd8170SKalle Valo 3308bdcd8170SKalle Valo void ath6kl_wmi_shutdown(struct wmi *wmi) 3309bdcd8170SKalle Valo { 3310bdcd8170SKalle Valo if (!wmi) 3311bdcd8170SKalle Valo return; 3312bdcd8170SKalle Valo 3313a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 3314bdcd8170SKalle Valo kfree(wmi); 3315bdcd8170SKalle Valo } 3316