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 24240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx); 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 846765d0aaSVasanthakumar Thiagarajan struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx) 85240d2799SVasanthakumar Thiagarajan { 86990bd915SVasanthakumar Thiagarajan struct ath6kl_vif *vif, *found = NULL; 87990bd915SVasanthakumar Thiagarajan 88240d2799SVasanthakumar Thiagarajan if (WARN_ON(if_idx > (MAX_NUM_VIF - 1))) 89240d2799SVasanthakumar Thiagarajan return NULL; 90240d2799SVasanthakumar Thiagarajan 91990bd915SVasanthakumar Thiagarajan /* FIXME: Locking */ 92990bd915SVasanthakumar Thiagarajan spin_lock(&ar->list_lock); 93990bd915SVasanthakumar Thiagarajan list_for_each_entry(vif, &ar->vif_list, list) { 94990bd915SVasanthakumar Thiagarajan if (vif->fw_vif_idx == if_idx) { 95990bd915SVasanthakumar Thiagarajan found = vif; 96990bd915SVasanthakumar Thiagarajan break; 97990bd915SVasanthakumar Thiagarajan } 98990bd915SVasanthakumar Thiagarajan } 99990bd915SVasanthakumar Thiagarajan spin_unlock(&ar->list_lock); 100990bd915SVasanthakumar Thiagarajan 101990bd915SVasanthakumar Thiagarajan return found; 102240d2799SVasanthakumar Thiagarajan } 103240d2799SVasanthakumar Thiagarajan 104bdcd8170SKalle Valo /* Performs DIX to 802.3 encapsulation for transmit packets. 105bdcd8170SKalle Valo * Assumes the entire DIX header is contigous and that there is 106bdcd8170SKalle Valo * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. 107bdcd8170SKalle Valo */ 108bdcd8170SKalle Valo int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) 109bdcd8170SKalle Valo { 110bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 111bdcd8170SKalle Valo struct ethhdr *eth_hdr; 112bdcd8170SKalle Valo size_t new_len; 113bdcd8170SKalle Valo __be16 type; 114bdcd8170SKalle Valo u8 *datap; 115bdcd8170SKalle Valo u16 size; 116bdcd8170SKalle Valo 117bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 118bdcd8170SKalle Valo return -EINVAL; 119bdcd8170SKalle Valo 120bdcd8170SKalle Valo size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr); 121bdcd8170SKalle Valo if (skb_headroom(skb) < size) 122bdcd8170SKalle Valo return -ENOMEM; 123bdcd8170SKalle Valo 124bdcd8170SKalle Valo eth_hdr = (struct ethhdr *) skb->data; 125bdcd8170SKalle Valo type = eth_hdr->h_proto; 126bdcd8170SKalle Valo 127bdcd8170SKalle Valo if (!is_ethertype(be16_to_cpu(type))) { 128bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 129bdcd8170SKalle Valo "%s: pkt is already in 802.3 format\n", __func__); 130bdcd8170SKalle Valo return 0; 131bdcd8170SKalle Valo } 132bdcd8170SKalle Valo 133bdcd8170SKalle Valo new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr); 134bdcd8170SKalle Valo 135bdcd8170SKalle Valo skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr)); 136bdcd8170SKalle Valo datap = skb->data; 137bdcd8170SKalle Valo 138bdcd8170SKalle Valo eth_hdr->h_proto = cpu_to_be16(new_len); 139bdcd8170SKalle Valo 140bdcd8170SKalle Valo memcpy(datap, eth_hdr, sizeof(*eth_hdr)); 141bdcd8170SKalle Valo 142bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr)); 143bdcd8170SKalle Valo llc_hdr->dsap = 0xAA; 144bdcd8170SKalle Valo llc_hdr->ssap = 0xAA; 145bdcd8170SKalle Valo llc_hdr->cntl = 0x03; 146bdcd8170SKalle Valo llc_hdr->org_code[0] = 0x0; 147bdcd8170SKalle Valo llc_hdr->org_code[1] = 0x0; 148bdcd8170SKalle Valo llc_hdr->org_code[2] = 0x0; 149bdcd8170SKalle Valo llc_hdr->eth_type = type; 150bdcd8170SKalle Valo 151bdcd8170SKalle Valo return 0; 152bdcd8170SKalle Valo } 153bdcd8170SKalle Valo 154bdcd8170SKalle Valo static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, 155bdcd8170SKalle Valo u8 *version, void *tx_meta_info) 156bdcd8170SKalle Valo { 157bdcd8170SKalle Valo struct wmi_tx_meta_v1 *v1; 158bdcd8170SKalle Valo struct wmi_tx_meta_v2 *v2; 159bdcd8170SKalle Valo 160bdcd8170SKalle Valo if (WARN_ON(skb == NULL || version == NULL)) 161bdcd8170SKalle Valo return -EINVAL; 162bdcd8170SKalle Valo 163bdcd8170SKalle Valo switch (*version) { 164bdcd8170SKalle Valo case WMI_META_VERSION_1: 165bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 166bdcd8170SKalle Valo v1 = (struct wmi_tx_meta_v1 *) skb->data; 167bdcd8170SKalle Valo v1->pkt_id = 0; 168bdcd8170SKalle Valo v1->rate_plcy_id = 0; 169bdcd8170SKalle Valo *version = WMI_META_VERSION_1; 170bdcd8170SKalle Valo break; 171bdcd8170SKalle Valo case WMI_META_VERSION_2: 172bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 173bdcd8170SKalle Valo v2 = (struct wmi_tx_meta_v2 *) skb->data; 174bdcd8170SKalle Valo memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info, 175bdcd8170SKalle Valo sizeof(struct wmi_tx_meta_v2)); 176bdcd8170SKalle Valo break; 177bdcd8170SKalle Valo } 178bdcd8170SKalle Valo 179bdcd8170SKalle Valo return 0; 180bdcd8170SKalle Valo } 181bdcd8170SKalle Valo 182bdcd8170SKalle Valo int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, 183bdcd8170SKalle Valo u8 msg_type, bool more_data, 184bdcd8170SKalle Valo enum wmi_data_hdr_data_type data_type, 1856765d0aaSVasanthakumar Thiagarajan u8 meta_ver, void *tx_meta_info, u8 if_idx) 186bdcd8170SKalle Valo { 187bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 188bdcd8170SKalle Valo int ret; 189bdcd8170SKalle Valo 1906765d0aaSVasanthakumar Thiagarajan if (WARN_ON(skb == NULL || (if_idx > MAX_NUM_VIF - 1))) 191bdcd8170SKalle Valo return -EINVAL; 192bdcd8170SKalle Valo 1933ce6ff50SVasanthakumar Thiagarajan if (tx_meta_info) { 194bdcd8170SKalle Valo ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info); 195bdcd8170SKalle Valo if (ret) 196bdcd8170SKalle Valo return ret; 1973ce6ff50SVasanthakumar Thiagarajan } 198bdcd8170SKalle Valo 199bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 200bdcd8170SKalle Valo 201bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *)skb->data; 202bdcd8170SKalle Valo memset(data_hdr, 0, sizeof(struct wmi_data_hdr)); 203bdcd8170SKalle Valo 204bdcd8170SKalle Valo data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; 205bdcd8170SKalle Valo data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; 206bdcd8170SKalle Valo 207bdcd8170SKalle Valo if (more_data) 208bdcd8170SKalle Valo data_hdr->info |= 209bdcd8170SKalle Valo WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT; 210bdcd8170SKalle Valo 211bdcd8170SKalle Valo data_hdr->info2 = cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); 2126765d0aaSVasanthakumar Thiagarajan data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); 213bdcd8170SKalle Valo 214bdcd8170SKalle Valo return 0; 215bdcd8170SKalle Valo } 216bdcd8170SKalle Valo 217bdcd8170SKalle Valo static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) 218bdcd8170SKalle Valo { 219bdcd8170SKalle Valo struct iphdr *ip_hdr = (struct iphdr *) pkt; 220bdcd8170SKalle Valo u8 ip_pri; 221bdcd8170SKalle Valo 222bdcd8170SKalle Valo /* 223bdcd8170SKalle Valo * Determine IPTOS priority 224bdcd8170SKalle Valo * 225bdcd8170SKalle Valo * IP-TOS - 8bits 226bdcd8170SKalle Valo * : DSCP(6-bits) ECN(2-bits) 227bdcd8170SKalle Valo * : DSCP - P2 P1 P0 X X X 228bdcd8170SKalle Valo * where (P2 P1 P0) form 802.1D 229bdcd8170SKalle Valo */ 230bdcd8170SKalle Valo ip_pri = ip_hdr->tos >> 5; 231bdcd8170SKalle Valo ip_pri &= 0x7; 232bdcd8170SKalle Valo 233bdcd8170SKalle Valo if ((layer2_pri & 0x7) > ip_pri) 234bdcd8170SKalle Valo return (u8) layer2_pri & 0x7; 235bdcd8170SKalle Valo else 236bdcd8170SKalle Valo return ip_pri; 237bdcd8170SKalle Valo } 238bdcd8170SKalle Valo 239240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx, 240240d2799SVasanthakumar Thiagarajan struct sk_buff *skb, 241bdcd8170SKalle Valo u32 layer2_priority, bool wmm_enabled, 242bdcd8170SKalle Valo u8 *ac) 243bdcd8170SKalle Valo { 244bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 245bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 246bdcd8170SKalle Valo struct wmi_create_pstream_cmd cmd; 247bdcd8170SKalle Valo u32 meta_size, hdr_size; 248bdcd8170SKalle Valo u16 ip_type = IP_ETHERTYPE; 249bdcd8170SKalle Valo u8 stream_exist, usr_pri; 250bdcd8170SKalle Valo u8 traffic_class = WMM_AC_BE; 251bdcd8170SKalle Valo u8 *datap; 252bdcd8170SKalle Valo 253bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 254bdcd8170SKalle Valo return -EINVAL; 255bdcd8170SKalle Valo 256bdcd8170SKalle Valo datap = skb->data; 257bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) datap; 258bdcd8170SKalle Valo 259bdcd8170SKalle Valo meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) & 260bdcd8170SKalle Valo WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0; 261bdcd8170SKalle Valo 262bdcd8170SKalle Valo if (!wmm_enabled) { 263bdcd8170SKalle Valo /* If WMM is disabled all traffic goes as BE traffic */ 264bdcd8170SKalle Valo usr_pri = 0; 265bdcd8170SKalle Valo } else { 266bdcd8170SKalle Valo hdr_size = sizeof(struct ethhdr); 267bdcd8170SKalle Valo 268bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + 269bdcd8170SKalle Valo sizeof(struct 270bdcd8170SKalle Valo wmi_data_hdr) + 271bdcd8170SKalle Valo meta_size + hdr_size); 272bdcd8170SKalle Valo 273bdcd8170SKalle Valo if (llc_hdr->eth_type == htons(ip_type)) { 274bdcd8170SKalle Valo /* 275bdcd8170SKalle Valo * Extract the endpoint info from the TOS field 276bdcd8170SKalle Valo * in the IP header. 277bdcd8170SKalle Valo */ 278bdcd8170SKalle Valo usr_pri = 279bdcd8170SKalle Valo ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + 280bdcd8170SKalle Valo sizeof(struct ath6kl_llc_snap_hdr), 281bdcd8170SKalle Valo layer2_priority); 282bdcd8170SKalle Valo } else 283bdcd8170SKalle Valo usr_pri = layer2_priority & 0x7; 284bdcd8170SKalle Valo } 285bdcd8170SKalle Valo 286a7f0c58bSKalle Valo /* 287a7f0c58bSKalle Valo * workaround for WMM S5 288a7f0c58bSKalle Valo * 289a7f0c58bSKalle Valo * FIXME: wmi->traffic_class is always 100 so this test doesn't 290a7f0c58bSKalle Valo * make sense 291a7f0c58bSKalle Valo */ 292bdcd8170SKalle Valo if ((wmi->traffic_class == WMM_AC_VI) && 293bdcd8170SKalle Valo ((usr_pri == 5) || (usr_pri == 4))) 294bdcd8170SKalle Valo usr_pri = 1; 295bdcd8170SKalle Valo 296bdcd8170SKalle Valo /* Convert user priority to traffic class */ 297bdcd8170SKalle Valo traffic_class = up_to_ac[usr_pri & 0x7]; 298bdcd8170SKalle Valo 299bdcd8170SKalle Valo wmi_data_hdr_set_up(data_hdr, usr_pri); 300bdcd8170SKalle Valo 301bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 302bdcd8170SKalle Valo stream_exist = wmi->fat_pipe_exist; 303bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 304bdcd8170SKalle Valo 305bdcd8170SKalle Valo if (!(stream_exist & (1 << traffic_class))) { 306bdcd8170SKalle Valo memset(&cmd, 0, sizeof(cmd)); 307bdcd8170SKalle Valo cmd.traffic_class = traffic_class; 308bdcd8170SKalle Valo cmd.user_pri = usr_pri; 309bdcd8170SKalle Valo cmd.inactivity_int = 310bdcd8170SKalle Valo cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); 311bdcd8170SKalle Valo /* Implicit streams are created with TSID 0xFF */ 312bdcd8170SKalle Valo cmd.tsid = WMI_IMPLICIT_PSTREAM; 313240d2799SVasanthakumar Thiagarajan ath6kl_wmi_create_pstream_cmd(wmi, if_idx, &cmd); 314bdcd8170SKalle Valo } 315bdcd8170SKalle Valo 316bdcd8170SKalle Valo *ac = traffic_class; 317bdcd8170SKalle Valo 318bdcd8170SKalle Valo return 0; 319bdcd8170SKalle Valo } 320bdcd8170SKalle Valo 321bdcd8170SKalle Valo int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) 322bdcd8170SKalle Valo { 323bdcd8170SKalle Valo struct ieee80211_hdr_3addr *pwh, wh; 324bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 325bdcd8170SKalle Valo struct ethhdr eth_hdr; 326bdcd8170SKalle Valo u32 hdr_size; 327bdcd8170SKalle Valo u8 *datap; 328bdcd8170SKalle Valo __le16 sub_type; 329bdcd8170SKalle Valo 330bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 331bdcd8170SKalle Valo return -EINVAL; 332bdcd8170SKalle Valo 333bdcd8170SKalle Valo datap = skb->data; 334bdcd8170SKalle Valo pwh = (struct ieee80211_hdr_3addr *) datap; 335bdcd8170SKalle Valo 336bdcd8170SKalle Valo sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); 337bdcd8170SKalle Valo 338bdcd8170SKalle Valo memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); 339bdcd8170SKalle Valo 340bdcd8170SKalle Valo /* Strip off the 802.11 header */ 341bdcd8170SKalle Valo if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { 342bdcd8170SKalle Valo hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), 343bdcd8170SKalle Valo sizeof(u32)); 344bdcd8170SKalle Valo skb_pull(skb, hdr_size); 345bdcd8170SKalle Valo } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) 346bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); 347bdcd8170SKalle Valo 348bdcd8170SKalle Valo datap = skb->data; 349bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); 350bdcd8170SKalle Valo 351c8790cbaSRaja Mani memset(ð_hdr, 0, sizeof(eth_hdr)); 352bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 353bdcd8170SKalle Valo 354bdcd8170SKalle Valo switch ((le16_to_cpu(wh.frame_control)) & 355bdcd8170SKalle Valo (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 356bdcd8170SKalle Valo case 0: 357bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 358bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 359bdcd8170SKalle Valo break; 360bdcd8170SKalle Valo case IEEE80211_FCTL_TODS: 361bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); 362bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 363bdcd8170SKalle Valo break; 364bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS: 365bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 366bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); 367bdcd8170SKalle Valo break; 368bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: 369bdcd8170SKalle Valo break; 370bdcd8170SKalle Valo } 371bdcd8170SKalle Valo 372bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 373bdcd8170SKalle Valo skb_push(skb, sizeof(eth_hdr)); 374bdcd8170SKalle Valo 375bdcd8170SKalle Valo datap = skb->data; 376bdcd8170SKalle Valo 377bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 378bdcd8170SKalle Valo 379bdcd8170SKalle Valo return 0; 380bdcd8170SKalle Valo } 381bdcd8170SKalle Valo 382bdcd8170SKalle Valo /* 383bdcd8170SKalle Valo * Performs 802.3 to DIX encapsulation for received packets. 384bdcd8170SKalle Valo * Assumes the entire 802.3 header is contigous. 385bdcd8170SKalle Valo */ 386bdcd8170SKalle Valo int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) 387bdcd8170SKalle Valo { 388bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 389bdcd8170SKalle Valo struct ethhdr eth_hdr; 390bdcd8170SKalle Valo u8 *datap; 391bdcd8170SKalle Valo 392bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 393bdcd8170SKalle Valo return -EINVAL; 394bdcd8170SKalle Valo 395bdcd8170SKalle Valo datap = skb->data; 396bdcd8170SKalle Valo 397bdcd8170SKalle Valo memcpy(ð_hdr, datap, sizeof(eth_hdr)); 398bdcd8170SKalle Valo 399bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); 400bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 401bdcd8170SKalle Valo 402bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 403bdcd8170SKalle Valo datap = skb->data; 404bdcd8170SKalle Valo 405bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 406bdcd8170SKalle Valo 407bdcd8170SKalle Valo return 0; 408bdcd8170SKalle Valo } 409bdcd8170SKalle Valo 410bdcd8170SKalle Valo static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) 411bdcd8170SKalle Valo { 412bdcd8170SKalle Valo struct tx_complete_msg_v1 *msg_v1; 413bdcd8170SKalle Valo struct wmi_tx_complete_event *evt; 414bdcd8170SKalle Valo int index; 415bdcd8170SKalle Valo u16 size; 416bdcd8170SKalle Valo 417bdcd8170SKalle Valo evt = (struct wmi_tx_complete_event *) datap; 418bdcd8170SKalle Valo 419bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", 420bdcd8170SKalle Valo evt->num_msg, evt->msg_len, evt->msg_type); 421bdcd8170SKalle Valo 422bdcd8170SKalle Valo if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI)) 423bdcd8170SKalle Valo return 0; 424bdcd8170SKalle Valo 425bdcd8170SKalle Valo for (index = 0; index < evt->num_msg; index++) { 426bdcd8170SKalle Valo size = sizeof(struct wmi_tx_complete_event) + 427bdcd8170SKalle Valo (index * sizeof(struct tx_complete_msg_v1)); 428bdcd8170SKalle Valo msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); 429bdcd8170SKalle Valo 430bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", 431bdcd8170SKalle Valo msg_v1->status, msg_v1->pkt_id, 432bdcd8170SKalle Valo msg_v1->rate_idx, msg_v1->ack_failures); 433bdcd8170SKalle Valo } 434bdcd8170SKalle Valo 435bdcd8170SKalle Valo return 0; 436bdcd8170SKalle Valo } 437bdcd8170SKalle Valo 438f9e5f05cSJouni Malinen static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, 439240d2799SVasanthakumar Thiagarajan int len, struct ath6kl_vif *vif) 4406465ddcfSJouni Malinen { 4416465ddcfSJouni Malinen struct wmi_remain_on_chnl_event *ev; 4426465ddcfSJouni Malinen u32 freq; 4436465ddcfSJouni Malinen u32 dur; 444f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 445f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4466465ddcfSJouni Malinen 4476465ddcfSJouni Malinen if (len < sizeof(*ev)) 4486465ddcfSJouni Malinen return -EINVAL; 4496465ddcfSJouni Malinen 4506465ddcfSJouni Malinen ev = (struct wmi_remain_on_chnl_event *) datap; 4516465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4526465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4536465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", 4546465ddcfSJouni Malinen freq, dur); 455be98e3a4SVasanthakumar Thiagarajan chan = ieee80211_get_channel(ar->wiphy, freq); 456f9e5f05cSJouni Malinen if (!chan) { 457f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " 458f9e5f05cSJouni Malinen "(freq=%u)\n", freq); 459f9e5f05cSJouni Malinen return -EINVAL; 460f9e5f05cSJouni Malinen } 461240d2799SVasanthakumar Thiagarajan cfg80211_ready_on_channel(vif->ndev, 1, chan, NL80211_CHAN_NO_HT, 462f9e5f05cSJouni Malinen dur, GFP_ATOMIC); 4636465ddcfSJouni Malinen 4646465ddcfSJouni Malinen return 0; 4656465ddcfSJouni Malinen } 4666465ddcfSJouni Malinen 467f9e5f05cSJouni Malinen static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, 468240d2799SVasanthakumar Thiagarajan u8 *datap, int len, 469240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 4706465ddcfSJouni Malinen { 4716465ddcfSJouni Malinen struct wmi_cancel_remain_on_chnl_event *ev; 4726465ddcfSJouni Malinen u32 freq; 4736465ddcfSJouni Malinen u32 dur; 474f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 475f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4766465ddcfSJouni Malinen 4776465ddcfSJouni Malinen if (len < sizeof(*ev)) 4786465ddcfSJouni Malinen return -EINVAL; 4796465ddcfSJouni Malinen 4806465ddcfSJouni Malinen ev = (struct wmi_cancel_remain_on_chnl_event *) datap; 4816465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4826465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4836465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " 4846465ddcfSJouni Malinen "status=%u\n", freq, dur, ev->status); 485be98e3a4SVasanthakumar Thiagarajan chan = ieee80211_get_channel(ar->wiphy, freq); 486f9e5f05cSJouni Malinen if (!chan) { 487f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " 488f9e5f05cSJouni Malinen "channel (freq=%u)\n", freq); 489f9e5f05cSJouni Malinen return -EINVAL; 490f9e5f05cSJouni Malinen } 491240d2799SVasanthakumar Thiagarajan cfg80211_remain_on_channel_expired(vif->ndev, 1, chan, 492f9e5f05cSJouni Malinen NL80211_CHAN_NO_HT, GFP_ATOMIC); 4936465ddcfSJouni Malinen 4946465ddcfSJouni Malinen return 0; 4956465ddcfSJouni Malinen } 4966465ddcfSJouni Malinen 497240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len, 498240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 4996465ddcfSJouni Malinen { 5006465ddcfSJouni Malinen struct wmi_tx_status_event *ev; 5016465ddcfSJouni Malinen u32 id; 5026465ddcfSJouni Malinen 5036465ddcfSJouni Malinen if (len < sizeof(*ev)) 5046465ddcfSJouni Malinen return -EINVAL; 5056465ddcfSJouni Malinen 5066465ddcfSJouni Malinen ev = (struct wmi_tx_status_event *) datap; 5076465ddcfSJouni Malinen id = le32_to_cpu(ev->id); 5086465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", 5096465ddcfSJouni Malinen id, ev->ack_status); 510a0df5db1SJouni Malinen if (wmi->last_mgmt_tx_frame) { 511240d2799SVasanthakumar Thiagarajan cfg80211_mgmt_tx_status(vif->ndev, id, 512a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame, 513a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len, 514a0df5db1SJouni Malinen !!ev->ack_status, GFP_ATOMIC); 515a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 516a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = NULL; 517a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = 0; 518a0df5db1SJouni Malinen } 5196465ddcfSJouni Malinen 5206465ddcfSJouni Malinen return 0; 5216465ddcfSJouni Malinen } 5226465ddcfSJouni Malinen 523240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len, 524240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 5256465ddcfSJouni Malinen { 5266465ddcfSJouni Malinen struct wmi_p2p_rx_probe_req_event *ev; 527ae32c30aSJouni Malinen u32 freq; 5286465ddcfSJouni Malinen u16 dlen; 5296465ddcfSJouni Malinen 5306465ddcfSJouni Malinen if (len < sizeof(*ev)) 5316465ddcfSJouni Malinen return -EINVAL; 5326465ddcfSJouni Malinen 5336465ddcfSJouni Malinen ev = (struct wmi_p2p_rx_probe_req_event *) datap; 534ae32c30aSJouni Malinen freq = le32_to_cpu(ev->freq); 5356465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 536ae32c30aSJouni Malinen if (datap + len < ev->data + dlen) { 537ae32c30aSJouni Malinen ath6kl_err("invalid wmi_p2p_rx_probe_req_event: " 538ae32c30aSJouni Malinen "len=%d dlen=%u\n", len, dlen); 539ae32c30aSJouni Malinen return -EINVAL; 540ae32c30aSJouni Malinen } 541ae32c30aSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u " 542ae32c30aSJouni Malinen "probe_req_report=%d\n", 543cf5333d7SVasanthakumar Thiagarajan dlen, freq, vif->probe_req_report); 544ae32c30aSJouni Malinen 545cf5333d7SVasanthakumar Thiagarajan if (vif->probe_req_report || vif->nw_type == AP_NETWORK) 546240d2799SVasanthakumar Thiagarajan cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC); 5476465ddcfSJouni Malinen 5486465ddcfSJouni Malinen return 0; 5496465ddcfSJouni Malinen } 5506465ddcfSJouni Malinen 5516465ddcfSJouni Malinen static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) 5526465ddcfSJouni Malinen { 5536465ddcfSJouni Malinen struct wmi_p2p_capabilities_event *ev; 5546465ddcfSJouni Malinen u16 dlen; 5556465ddcfSJouni Malinen 5566465ddcfSJouni Malinen if (len < sizeof(*ev)) 5576465ddcfSJouni Malinen return -EINVAL; 5586465ddcfSJouni Malinen 5596465ddcfSJouni Malinen ev = (struct wmi_p2p_capabilities_event *) datap; 5606465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5616465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); 5626465ddcfSJouni Malinen 5636465ddcfSJouni Malinen return 0; 5646465ddcfSJouni Malinen } 5656465ddcfSJouni Malinen 566240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len, 567240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 5686465ddcfSJouni Malinen { 5696465ddcfSJouni Malinen struct wmi_rx_action_event *ev; 5709809d8efSJouni Malinen u32 freq; 5716465ddcfSJouni Malinen u16 dlen; 5726465ddcfSJouni Malinen 5736465ddcfSJouni Malinen if (len < sizeof(*ev)) 5746465ddcfSJouni Malinen return -EINVAL; 5756465ddcfSJouni Malinen 5766465ddcfSJouni Malinen ev = (struct wmi_rx_action_event *) datap; 5779809d8efSJouni Malinen freq = le32_to_cpu(ev->freq); 5786465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5799809d8efSJouni Malinen if (datap + len < ev->data + dlen) { 5809809d8efSJouni Malinen ath6kl_err("invalid wmi_rx_action_event: " 5819809d8efSJouni Malinen "len=%d dlen=%u\n", len, dlen); 5829809d8efSJouni Malinen return -EINVAL; 5839809d8efSJouni Malinen } 5849809d8efSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); 585240d2799SVasanthakumar Thiagarajan cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC); 5866465ddcfSJouni Malinen 5876465ddcfSJouni Malinen return 0; 5886465ddcfSJouni Malinen } 5896465ddcfSJouni Malinen 5906465ddcfSJouni Malinen static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) 5916465ddcfSJouni Malinen { 5926465ddcfSJouni Malinen struct wmi_p2p_info_event *ev; 5936465ddcfSJouni Malinen u32 flags; 5946465ddcfSJouni Malinen u16 dlen; 5956465ddcfSJouni Malinen 5966465ddcfSJouni Malinen if (len < sizeof(*ev)) 5976465ddcfSJouni Malinen return -EINVAL; 5986465ddcfSJouni Malinen 5996465ddcfSJouni Malinen ev = (struct wmi_p2p_info_event *) datap; 6006465ddcfSJouni Malinen flags = le32_to_cpu(ev->info_req_flags); 6016465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 6026465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); 6036465ddcfSJouni Malinen 6046465ddcfSJouni Malinen if (flags & P2P_FLAG_CAPABILITIES_REQ) { 6056465ddcfSJouni Malinen struct wmi_p2p_capabilities *cap; 6066465ddcfSJouni Malinen if (dlen < sizeof(*cap)) 6076465ddcfSJouni Malinen return -EINVAL; 6086465ddcfSJouni Malinen cap = (struct wmi_p2p_capabilities *) ev->data; 6096465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", 6106465ddcfSJouni Malinen cap->go_power_save); 6116465ddcfSJouni Malinen } 6126465ddcfSJouni Malinen 6136465ddcfSJouni Malinen if (flags & P2P_FLAG_MACADDR_REQ) { 6146465ddcfSJouni Malinen struct wmi_p2p_macaddr *mac; 6156465ddcfSJouni Malinen if (dlen < sizeof(*mac)) 6166465ddcfSJouni Malinen return -EINVAL; 6176465ddcfSJouni Malinen mac = (struct wmi_p2p_macaddr *) ev->data; 6186465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", 6196465ddcfSJouni Malinen mac->mac_addr); 6206465ddcfSJouni Malinen } 6216465ddcfSJouni Malinen 6226465ddcfSJouni Malinen if (flags & P2P_FLAG_HMODEL_REQ) { 6236465ddcfSJouni Malinen struct wmi_p2p_hmodel *mod; 6246465ddcfSJouni Malinen if (dlen < sizeof(*mod)) 6256465ddcfSJouni Malinen return -EINVAL; 6266465ddcfSJouni Malinen mod = (struct wmi_p2p_hmodel *) ev->data; 6276465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", 6286465ddcfSJouni Malinen mod->p2p_model, 6296465ddcfSJouni Malinen mod->p2p_model ? "host" : "firmware"); 6306465ddcfSJouni Malinen } 6316465ddcfSJouni Malinen return 0; 6326465ddcfSJouni Malinen } 6336465ddcfSJouni Malinen 634bdcd8170SKalle Valo static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) 635bdcd8170SKalle Valo { 636bdcd8170SKalle Valo struct sk_buff *skb; 637bdcd8170SKalle Valo 638bdcd8170SKalle Valo skb = ath6kl_buf_alloc(size); 639bdcd8170SKalle Valo if (!skb) 640bdcd8170SKalle Valo return NULL; 641bdcd8170SKalle Valo 642bdcd8170SKalle Valo skb_put(skb, size); 643bdcd8170SKalle Valo if (size) 644bdcd8170SKalle Valo memset(skb->data, 0, size); 645bdcd8170SKalle Valo 646bdcd8170SKalle Valo return skb; 647bdcd8170SKalle Valo } 648bdcd8170SKalle Valo 649bdcd8170SKalle Valo /* Send a "simple" wmi command -- one with no arguments */ 650334234b5SVasanthakumar Thiagarajan static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx, 651334234b5SVasanthakumar Thiagarajan enum wmi_cmd_id cmd_id) 652bdcd8170SKalle Valo { 653bdcd8170SKalle Valo struct sk_buff *skb; 654bdcd8170SKalle Valo int ret; 655bdcd8170SKalle Valo 656bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(0); 657bdcd8170SKalle Valo if (!skb) 658bdcd8170SKalle Valo return -ENOMEM; 659bdcd8170SKalle Valo 660334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG); 661bdcd8170SKalle Valo 662bdcd8170SKalle Valo return ret; 663bdcd8170SKalle Valo } 664bdcd8170SKalle Valo 665bdcd8170SKalle Valo static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) 666bdcd8170SKalle Valo { 667bdcd8170SKalle Valo struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; 668bdcd8170SKalle Valo 669bdcd8170SKalle Valo if (len < sizeof(struct wmi_ready_event_2)) 670bdcd8170SKalle Valo return -EINVAL; 671bdcd8170SKalle Valo 672bdcd8170SKalle Valo ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, 673bdcd8170SKalle Valo le32_to_cpu(ev->sw_version), 674bdcd8170SKalle Valo le32_to_cpu(ev->abi_version)); 675bdcd8170SKalle Valo 676bdcd8170SKalle Valo return 0; 677bdcd8170SKalle Valo } 678bdcd8170SKalle Valo 679e5090444SVivek Natarajan /* 680e5090444SVivek Natarajan * Mechanism to modify the roaming behavior in the firmware. The lower rssi 681e5090444SVivek Natarajan * at which the station has to roam can be passed with 682e5090444SVivek Natarajan * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level 683e5090444SVivek Natarajan * in dBm. 684e5090444SVivek Natarajan */ 685e5090444SVivek Natarajan int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) 686e5090444SVivek Natarajan { 687e5090444SVivek Natarajan struct sk_buff *skb; 688e5090444SVivek Natarajan struct roam_ctrl_cmd *cmd; 689e5090444SVivek Natarajan 690e5090444SVivek Natarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 691e5090444SVivek Natarajan if (!skb) 692e5090444SVivek Natarajan return -ENOMEM; 693e5090444SVivek Natarajan 694e5090444SVivek Natarajan cmd = (struct roam_ctrl_cmd *) skb->data; 695e5090444SVivek Natarajan 696e5090444SVivek Natarajan cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD); 697e5090444SVivek Natarajan cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi + 698e5090444SVivek Natarajan DEF_SCAN_FOR_ROAM_INTVL); 699e5090444SVivek Natarajan cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi); 700e5090444SVivek Natarajan cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; 701e5090444SVivek Natarajan cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; 702e5090444SVivek Natarajan 703334234b5SVasanthakumar Thiagarajan ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, 704334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 705e5090444SVivek Natarajan 706e5090444SVivek Natarajan return 0; 707e5090444SVivek Natarajan } 708e5090444SVivek Natarajan 7091261875fSJouni Malinen int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid) 7101261875fSJouni Malinen { 7111261875fSJouni Malinen struct sk_buff *skb; 7121261875fSJouni Malinen struct roam_ctrl_cmd *cmd; 7131261875fSJouni Malinen 7141261875fSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 7151261875fSJouni Malinen if (!skb) 7161261875fSJouni Malinen return -ENOMEM; 7171261875fSJouni Malinen 7181261875fSJouni Malinen cmd = (struct roam_ctrl_cmd *) skb->data; 7191261875fSJouni Malinen memset(cmd, 0, sizeof(*cmd)); 7201261875fSJouni Malinen 7211261875fSJouni Malinen memcpy(cmd->info.bssid, bssid, ETH_ALEN); 7221261875fSJouni Malinen cmd->roam_ctrl = WMI_FORCE_ROAM; 7231261875fSJouni Malinen 7241261875fSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid); 725334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, 7261261875fSJouni Malinen NO_SYNC_WMIFLAG); 7271261875fSJouni Malinen } 7281261875fSJouni Malinen 7291261875fSJouni Malinen int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode) 7301261875fSJouni Malinen { 7311261875fSJouni Malinen struct sk_buff *skb; 7321261875fSJouni Malinen struct roam_ctrl_cmd *cmd; 7331261875fSJouni Malinen 7341261875fSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 7351261875fSJouni Malinen if (!skb) 7361261875fSJouni Malinen return -ENOMEM; 7371261875fSJouni Malinen 7381261875fSJouni Malinen cmd = (struct roam_ctrl_cmd *) skb->data; 7391261875fSJouni Malinen memset(cmd, 0, sizeof(*cmd)); 7401261875fSJouni Malinen 7411261875fSJouni Malinen cmd->info.roam_mode = mode; 7421261875fSJouni Malinen cmd->roam_ctrl = WMI_SET_ROAM_MODE; 7431261875fSJouni Malinen 7441261875fSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode); 745334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, 7461261875fSJouni Malinen NO_SYNC_WMIFLAG); 7471261875fSJouni Malinen } 7481261875fSJouni Malinen 749240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, 750240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 751bdcd8170SKalle Valo { 752bdcd8170SKalle Valo struct wmi_connect_event *ev; 753bdcd8170SKalle Valo u8 *pie, *peie; 754bdcd8170SKalle Valo 755bdcd8170SKalle Valo if (len < sizeof(struct wmi_connect_event)) 756bdcd8170SKalle Valo return -EINVAL; 757bdcd8170SKalle Valo 758bdcd8170SKalle Valo ev = (struct wmi_connect_event *) datap; 759bdcd8170SKalle Valo 760f5938f24SVasanthakumar Thiagarajan if (vif->nw_type == AP_NETWORK) { 761572e27c0SJouni Malinen /* AP mode start/STA connected event */ 762240d2799SVasanthakumar Thiagarajan struct net_device *dev = vif->ndev; 763572e27c0SJouni Malinen if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) { 764572e27c0SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM " 765572e27c0SJouni Malinen "(AP started)\n", 766572e27c0SJouni Malinen __func__, le16_to_cpu(ev->u.ap_bss.ch), 767572e27c0SJouni Malinen ev->u.ap_bss.bssid); 768572e27c0SJouni Malinen ath6kl_connect_ap_mode_bss( 769240d2799SVasanthakumar Thiagarajan vif, le16_to_cpu(ev->u.ap_bss.ch)); 770572e27c0SJouni Malinen } else { 771572e27c0SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM " 772572e27c0SJouni Malinen "auth=%u keymgmt=%u cipher=%u apsd_info=%u " 773572e27c0SJouni Malinen "(STA connected)\n", 774572e27c0SJouni Malinen __func__, ev->u.ap_sta.aid, 775572e27c0SJouni Malinen ev->u.ap_sta.mac_addr, 776572e27c0SJouni Malinen ev->u.ap_sta.auth, 777572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 778572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 779572e27c0SJouni Malinen ev->u.ap_sta.apsd_info); 780572e27c0SJouni Malinen ath6kl_connect_ap_mode_sta( 781240d2799SVasanthakumar Thiagarajan vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, 782572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 783572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 784572e27c0SJouni Malinen ev->u.ap_sta.auth, ev->assoc_req_len, 785572e27c0SJouni Malinen ev->assoc_info + ev->beacon_ie_len); 786572e27c0SJouni Malinen } 787572e27c0SJouni Malinen return 0; 788572e27c0SJouni Malinen } 789572e27c0SJouni Malinen 790572e27c0SJouni Malinen /* STA/IBSS mode connection event */ 791572e27c0SJouni Malinen 792b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 793b9b6ee60SKalle Valo "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n", 794b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid, 795b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.listen_intvl), 796b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.beacon_intvl), 797b9b6ee60SKalle Valo le32_to_cpu(ev->u.sta.nw_type)); 798bdcd8170SKalle Valo 799bdcd8170SKalle Valo /* Start of assoc rsp IEs */ 800bdcd8170SKalle Valo pie = ev->assoc_info + ev->beacon_ie_len + 801bdcd8170SKalle Valo ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ 802bdcd8170SKalle Valo 803bdcd8170SKalle Valo /* End of assoc rsp IEs */ 804bdcd8170SKalle Valo peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + 805bdcd8170SKalle Valo ev->assoc_resp_len; 806bdcd8170SKalle Valo 807bdcd8170SKalle Valo while (pie < peie) { 808bdcd8170SKalle Valo switch (*pie) { 809bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 810bdcd8170SKalle Valo if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && 811bdcd8170SKalle Valo pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { 812bdcd8170SKalle Valo /* WMM OUT (00:50:F2) */ 813bdcd8170SKalle Valo if (pie[1] > 5 814bdcd8170SKalle Valo && pie[6] == WMM_PARAM_OUI_SUBTYPE) 815bdcd8170SKalle Valo wmi->is_wmm_enabled = true; 816bdcd8170SKalle Valo } 817bdcd8170SKalle Valo break; 818bdcd8170SKalle Valo } 819bdcd8170SKalle Valo 820bdcd8170SKalle Valo if (wmi->is_wmm_enabled) 821bdcd8170SKalle Valo break; 822bdcd8170SKalle Valo 823bdcd8170SKalle Valo pie += pie[1] + 2; 824bdcd8170SKalle Valo } 825bdcd8170SKalle Valo 826240d2799SVasanthakumar Thiagarajan ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch), 827572e27c0SJouni Malinen ev->u.sta.bssid, 828572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.listen_intvl), 829572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.beacon_intvl), 830572e27c0SJouni Malinen le32_to_cpu(ev->u.sta.nw_type), 831bdcd8170SKalle Valo ev->beacon_ie_len, ev->assoc_req_len, 832bdcd8170SKalle Valo ev->assoc_resp_len, ev->assoc_info); 833bdcd8170SKalle Valo 834bdcd8170SKalle Valo return 0; 835bdcd8170SKalle Valo } 836bdcd8170SKalle Valo 83706033760SVivek Natarajan static struct country_code_to_enum_rd * 83806033760SVivek Natarajan ath6kl_regd_find_country(u16 countryCode) 83906033760SVivek Natarajan { 84006033760SVivek Natarajan int i; 84106033760SVivek Natarajan 84206033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 84306033760SVivek Natarajan if (allCountries[i].countryCode == countryCode) 84406033760SVivek Natarajan return &allCountries[i]; 84506033760SVivek Natarajan } 84606033760SVivek Natarajan 84706033760SVivek Natarajan return NULL; 84806033760SVivek Natarajan } 84906033760SVivek Natarajan 85006033760SVivek Natarajan static struct reg_dmn_pair_mapping * 85106033760SVivek Natarajan ath6kl_get_regpair(u16 regdmn) 85206033760SVivek Natarajan { 85306033760SVivek Natarajan int i; 85406033760SVivek Natarajan 85506033760SVivek Natarajan if (regdmn == NO_ENUMRD) 85606033760SVivek Natarajan return NULL; 85706033760SVivek Natarajan 85806033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) { 85906033760SVivek Natarajan if (regDomainPairs[i].regDmnEnum == regdmn) 86006033760SVivek Natarajan return ®DomainPairs[i]; 86106033760SVivek Natarajan } 86206033760SVivek Natarajan 86306033760SVivek Natarajan return NULL; 86406033760SVivek Natarajan } 86506033760SVivek Natarajan 86606033760SVivek Natarajan static struct country_code_to_enum_rd * 86706033760SVivek Natarajan ath6kl_regd_find_country_by_rd(u16 regdmn) 86806033760SVivek Natarajan { 86906033760SVivek Natarajan int i; 87006033760SVivek Natarajan 87106033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 87206033760SVivek Natarajan if (allCountries[i].regDmnEnum == regdmn) 87306033760SVivek Natarajan return &allCountries[i]; 87406033760SVivek Natarajan } 87506033760SVivek Natarajan 87606033760SVivek Natarajan return NULL; 87706033760SVivek Natarajan } 87806033760SVivek Natarajan 87906033760SVivek Natarajan static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) 88006033760SVivek Natarajan { 88106033760SVivek Natarajan 88206033760SVivek Natarajan struct ath6kl_wmi_regdomain *ev; 88306033760SVivek Natarajan struct country_code_to_enum_rd *country = NULL; 88406033760SVivek Natarajan struct reg_dmn_pair_mapping *regpair = NULL; 88506033760SVivek Natarajan char alpha2[2]; 88606033760SVivek Natarajan u32 reg_code; 88706033760SVivek Natarajan 88806033760SVivek Natarajan ev = (struct ath6kl_wmi_regdomain *) datap; 88906033760SVivek Natarajan reg_code = le32_to_cpu(ev->reg_code); 89006033760SVivek Natarajan 89106033760SVivek Natarajan if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) 89206033760SVivek Natarajan country = ath6kl_regd_find_country((u16) reg_code); 89306033760SVivek Natarajan else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) { 89406033760SVivek Natarajan 89506033760SVivek Natarajan regpair = ath6kl_get_regpair((u16) reg_code); 89606033760SVivek Natarajan country = ath6kl_regd_find_country_by_rd((u16) reg_code); 897b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n", 89806033760SVivek Natarajan regpair->regDmnEnum); 89906033760SVivek Natarajan } 90006033760SVivek Natarajan 90106033760SVivek Natarajan if (country) { 90206033760SVivek Natarajan alpha2[0] = country->isoName[0]; 90306033760SVivek Natarajan alpha2[1] = country->isoName[1]; 90406033760SVivek Natarajan 905be98e3a4SVasanthakumar Thiagarajan regulatory_hint(wmi->parent_dev->wiphy, alpha2); 90606033760SVivek Natarajan 907b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n", 90806033760SVivek Natarajan alpha2[0], alpha2[1]); 90906033760SVivek Natarajan } 91006033760SVivek Natarajan } 91106033760SVivek Natarajan 912240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len, 913240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 914bdcd8170SKalle Valo { 915bdcd8170SKalle Valo struct wmi_disconnect_event *ev; 916bdcd8170SKalle Valo wmi->traffic_class = 100; 917bdcd8170SKalle Valo 918bdcd8170SKalle Valo if (len < sizeof(struct wmi_disconnect_event)) 919bdcd8170SKalle Valo return -EINVAL; 920bdcd8170SKalle Valo 921bdcd8170SKalle Valo ev = (struct wmi_disconnect_event *) datap; 922bdcd8170SKalle Valo 923b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 924b9b6ee60SKalle Valo "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n", 925b9b6ee60SKalle Valo le16_to_cpu(ev->proto_reason_status), ev->bssid, 926b9b6ee60SKalle Valo ev->disconn_reason, ev->assoc_resp_len); 927b9b6ee60SKalle Valo 928bdcd8170SKalle Valo wmi->is_wmm_enabled = false; 929bdcd8170SKalle Valo 930240d2799SVasanthakumar Thiagarajan ath6kl_disconnect_event(vif, ev->disconn_reason, 931bdcd8170SKalle Valo ev->bssid, ev->assoc_resp_len, ev->assoc_info, 932bdcd8170SKalle Valo le16_to_cpu(ev->proto_reason_status)); 933bdcd8170SKalle Valo 934bdcd8170SKalle Valo return 0; 935bdcd8170SKalle Valo } 936bdcd8170SKalle Valo 937bdcd8170SKalle Valo static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) 938bdcd8170SKalle Valo { 939bdcd8170SKalle Valo struct wmi_peer_node_event *ev; 940bdcd8170SKalle Valo 941bdcd8170SKalle Valo if (len < sizeof(struct wmi_peer_node_event)) 942bdcd8170SKalle Valo return -EINVAL; 943bdcd8170SKalle Valo 944bdcd8170SKalle Valo ev = (struct wmi_peer_node_event *) datap; 945bdcd8170SKalle Valo 946bdcd8170SKalle Valo if (ev->event_code == PEER_NODE_JOIN_EVENT) 947bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", 948bdcd8170SKalle Valo ev->peer_mac_addr); 949bdcd8170SKalle Valo else if (ev->event_code == PEER_NODE_LEAVE_EVENT) 950bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", 951bdcd8170SKalle Valo ev->peer_mac_addr); 952bdcd8170SKalle Valo 953bdcd8170SKalle Valo return 0; 954bdcd8170SKalle Valo } 955bdcd8170SKalle Valo 956240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len, 957240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 958bdcd8170SKalle Valo { 959bdcd8170SKalle Valo struct wmi_tkip_micerr_event *ev; 960bdcd8170SKalle Valo 961bdcd8170SKalle Valo if (len < sizeof(struct wmi_tkip_micerr_event)) 962bdcd8170SKalle Valo return -EINVAL; 963bdcd8170SKalle Valo 964bdcd8170SKalle Valo ev = (struct wmi_tkip_micerr_event *) datap; 965bdcd8170SKalle Valo 966240d2799SVasanthakumar Thiagarajan ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast); 967bdcd8170SKalle Valo 968bdcd8170SKalle Valo return 0; 969bdcd8170SKalle Valo } 970bdcd8170SKalle Valo 971240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len, 972240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 973bdcd8170SKalle Valo { 97482e14f56SJouni Malinen struct wmi_bss_info_hdr2 *bih; 9751aaa8c74SJouni Malinen u8 *buf; 9761aaa8c74SJouni Malinen struct ieee80211_channel *channel; 9771aaa8c74SJouni Malinen struct ath6kl *ar = wmi->parent_dev; 9781aaa8c74SJouni Malinen struct ieee80211_mgmt *mgmt; 9791aaa8c74SJouni Malinen struct cfg80211_bss *bss; 980bdcd8170SKalle Valo 98182e14f56SJouni Malinen if (len <= sizeof(struct wmi_bss_info_hdr2)) 982bdcd8170SKalle Valo return -EINVAL; 983bdcd8170SKalle Valo 98482e14f56SJouni Malinen bih = (struct wmi_bss_info_hdr2 *) datap; 98582e14f56SJouni Malinen buf = datap + sizeof(struct wmi_bss_info_hdr2); 98682e14f56SJouni Malinen len -= sizeof(struct wmi_bss_info_hdr2); 987bdcd8170SKalle Valo 988bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 9891aaa8c74SJouni Malinen "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" " 9901aaa8c74SJouni Malinen "frame_type=%d\n", 99182e14f56SJouni Malinen bih->ch, bih->snr, bih->snr - 95, bih->bssid, 9921aaa8c74SJouni Malinen bih->frame_type); 993bdcd8170SKalle Valo 9941aaa8c74SJouni Malinen if (bih->frame_type != BEACON_FTYPE && 9951aaa8c74SJouni Malinen bih->frame_type != PROBERESP_FTYPE) 9961aaa8c74SJouni Malinen return 0; /* Only update BSS table for now */ 9971aaa8c74SJouni Malinen 998551185caSJouni Malinen if (bih->frame_type == BEACON_FTYPE && 99959c98449SVasanthakumar Thiagarajan test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) { 100059c98449SVasanthakumar Thiagarajan clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); 1001240d2799SVasanthakumar Thiagarajan ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, 1002240d2799SVasanthakumar Thiagarajan NONE_BSS_FILTER, 0); 1003551185caSJouni Malinen } 1004551185caSJouni Malinen 1005be98e3a4SVasanthakumar Thiagarajan channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch)); 10061aaa8c74SJouni Malinen if (channel == NULL) 10071aaa8c74SJouni Malinen return -EINVAL; 10081aaa8c74SJouni Malinen 10091aaa8c74SJouni Malinen if (len < 8 + 2 + 2) 10101aaa8c74SJouni Malinen return -EINVAL; 1011bdcd8170SKalle Valo 101259c98449SVasanthakumar Thiagarajan if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &vif->flags) 10138c8b65e3SVasanthakumar Thiagarajan && memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) { 101432c10874SJouni Malinen const u8 *tim; 101532c10874SJouni Malinen tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2, 101632c10874SJouni Malinen len - 8 - 2 - 2); 101732c10874SJouni Malinen if (tim && tim[1] >= 2) { 1018cf5333d7SVasanthakumar Thiagarajan vif->assoc_bss_dtim_period = tim[3]; 101959c98449SVasanthakumar Thiagarajan set_bit(DTIM_PERIOD_AVAIL, &vif->flags); 102032c10874SJouni Malinen } 102132c10874SJouni Malinen } 102232c10874SJouni Malinen 1023bdcd8170SKalle Valo /* 10241aaa8c74SJouni Malinen * In theory, use of cfg80211_inform_bss() would be more natural here 10251aaa8c74SJouni Malinen * since we do not have the full frame. However, at least for now, 10261aaa8c74SJouni Malinen * cfg80211 can only distinguish Beacon and Probe Response frames from 10271aaa8c74SJouni Malinen * each other when using cfg80211_inform_bss_frame(), so let's build a 10281aaa8c74SJouni Malinen * fake IEEE 802.11 header to be able to take benefit of this. 1029bdcd8170SKalle Valo */ 10301aaa8c74SJouni Malinen mgmt = kmalloc(24 + len, GFP_ATOMIC); 10311aaa8c74SJouni Malinen if (mgmt == NULL) 10321aaa8c74SJouni Malinen return -EINVAL; 10331aaa8c74SJouni Malinen 10341aaa8c74SJouni Malinen if (bih->frame_type == BEACON_FTYPE) { 10351aaa8c74SJouni Malinen mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 10361aaa8c74SJouni Malinen IEEE80211_STYPE_BEACON); 10371aaa8c74SJouni Malinen memset(mgmt->da, 0xff, ETH_ALEN); 10381aaa8c74SJouni Malinen } else { 1039240d2799SVasanthakumar Thiagarajan struct net_device *dev = vif->ndev; 10401aaa8c74SJouni Malinen 10411aaa8c74SJouni Malinen mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 10421aaa8c74SJouni Malinen IEEE80211_STYPE_PROBE_RESP); 10431aaa8c74SJouni Malinen memcpy(mgmt->da, dev->dev_addr, ETH_ALEN); 1044bdcd8170SKalle Valo } 10451aaa8c74SJouni Malinen mgmt->duration = cpu_to_le16(0); 10461aaa8c74SJouni Malinen memcpy(mgmt->sa, bih->bssid, ETH_ALEN); 10471aaa8c74SJouni Malinen memcpy(mgmt->bssid, bih->bssid, ETH_ALEN); 10481aaa8c74SJouni Malinen mgmt->seq_ctrl = cpu_to_le16(0); 1049bdcd8170SKalle Valo 10501aaa8c74SJouni Malinen memcpy(&mgmt->u.beacon, buf, len); 1051bdcd8170SKalle Valo 1052be98e3a4SVasanthakumar Thiagarajan bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt, 105382e14f56SJouni Malinen 24 + len, (bih->snr - 95) * 100, 105482e14f56SJouni Malinen GFP_ATOMIC); 10551aaa8c74SJouni Malinen kfree(mgmt); 10561aaa8c74SJouni Malinen if (bss == NULL) 1057bdcd8170SKalle Valo return -ENOMEM; 10581aaa8c74SJouni Malinen cfg80211_put_bss(bss); 1059bdcd8170SKalle Valo 1060bdcd8170SKalle Valo return 0; 1061bdcd8170SKalle Valo } 1062bdcd8170SKalle Valo 1063bdcd8170SKalle Valo /* Inactivity timeout of a fatpipe(pstream) at the target */ 1064bdcd8170SKalle Valo static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, 1065bdcd8170SKalle Valo int len) 1066bdcd8170SKalle Valo { 1067bdcd8170SKalle Valo struct wmi_pstream_timeout_event *ev; 1068bdcd8170SKalle Valo 1069bdcd8170SKalle Valo if (len < sizeof(struct wmi_pstream_timeout_event)) 1070bdcd8170SKalle Valo return -EINVAL; 1071bdcd8170SKalle Valo 1072bdcd8170SKalle Valo ev = (struct wmi_pstream_timeout_event *) datap; 1073bdcd8170SKalle Valo 1074bdcd8170SKalle Valo /* 1075bdcd8170SKalle Valo * When the pstream (fat pipe == AC) timesout, it means there were 1076bdcd8170SKalle Valo * no thinStreams within this pstream & it got implicitly created 1077bdcd8170SKalle Valo * due to data flow on this AC. We start the inactivity timer only 1078bdcd8170SKalle Valo * for implicitly created pstream. Just reset the host state. 1079bdcd8170SKalle Valo */ 1080bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1081bdcd8170SKalle Valo wmi->stream_exist_for_ac[ev->traffic_class] = 0; 1082bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); 1083bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1084bdcd8170SKalle Valo 1085bdcd8170SKalle Valo /* Indicate inactivity to driver layer for this fatpipe (pstream) */ 1086bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); 1087bdcd8170SKalle Valo 1088bdcd8170SKalle Valo return 0; 1089bdcd8170SKalle Valo } 1090bdcd8170SKalle Valo 1091bdcd8170SKalle Valo static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) 1092bdcd8170SKalle Valo { 1093bdcd8170SKalle Valo struct wmi_bit_rate_reply *reply; 1094bdcd8170SKalle Valo s32 rate; 1095bdcd8170SKalle Valo u32 sgi, index; 1096bdcd8170SKalle Valo 1097bdcd8170SKalle Valo if (len < sizeof(struct wmi_bit_rate_reply)) 1098bdcd8170SKalle Valo return -EINVAL; 1099bdcd8170SKalle Valo 1100bdcd8170SKalle Valo reply = (struct wmi_bit_rate_reply *) datap; 1101bdcd8170SKalle Valo 1102bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); 1103bdcd8170SKalle Valo 1104bdcd8170SKalle Valo if (reply->rate_index == (s8) RATE_AUTO) { 1105bdcd8170SKalle Valo rate = RATE_AUTO; 1106bdcd8170SKalle Valo } else { 1107bdcd8170SKalle Valo index = reply->rate_index & 0x7f; 1108bdcd8170SKalle Valo sgi = (reply->rate_index & 0x80) ? 1 : 0; 1109bdcd8170SKalle Valo rate = wmi_rate_tbl[index][sgi]; 1110bdcd8170SKalle Valo } 1111bdcd8170SKalle Valo 1112bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1113bdcd8170SKalle Valo 1114bdcd8170SKalle Valo return 0; 1115bdcd8170SKalle Valo } 1116bdcd8170SKalle Valo 1117003353b0SKalle Valo static int ath6kl_wmi_tcmd_test_report_rx(struct wmi *wmi, u8 *datap, int len) 1118003353b0SKalle Valo { 1119003353b0SKalle Valo ath6kl_tm_rx_report_event(wmi->parent_dev, datap, len); 1120003353b0SKalle Valo 1121003353b0SKalle Valo return 0; 1122003353b0SKalle Valo } 1123003353b0SKalle Valo 1124bdcd8170SKalle Valo static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) 1125bdcd8170SKalle Valo { 1126bdcd8170SKalle Valo if (len < sizeof(struct wmi_fix_rates_reply)) 1127bdcd8170SKalle Valo return -EINVAL; 1128bdcd8170SKalle Valo 1129bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1130bdcd8170SKalle Valo 1131bdcd8170SKalle Valo return 0; 1132bdcd8170SKalle Valo } 1133bdcd8170SKalle Valo 1134bdcd8170SKalle Valo static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) 1135bdcd8170SKalle Valo { 1136bdcd8170SKalle Valo if (len < sizeof(struct wmi_channel_list_reply)) 1137bdcd8170SKalle Valo return -EINVAL; 1138bdcd8170SKalle Valo 1139bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1140bdcd8170SKalle Valo 1141bdcd8170SKalle Valo return 0; 1142bdcd8170SKalle Valo } 1143bdcd8170SKalle Valo 1144bdcd8170SKalle Valo static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) 1145bdcd8170SKalle Valo { 1146bdcd8170SKalle Valo struct wmi_tx_pwr_reply *reply; 1147bdcd8170SKalle Valo 1148bdcd8170SKalle Valo if (len < sizeof(struct wmi_tx_pwr_reply)) 1149bdcd8170SKalle Valo return -EINVAL; 1150bdcd8170SKalle Valo 1151bdcd8170SKalle Valo reply = (struct wmi_tx_pwr_reply *) datap; 1152bdcd8170SKalle Valo ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); 1153bdcd8170SKalle Valo 1154bdcd8170SKalle Valo return 0; 1155bdcd8170SKalle Valo } 1156bdcd8170SKalle Valo 1157bdcd8170SKalle Valo static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) 1158bdcd8170SKalle Valo { 1159bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_keepalive_cmd)) 1160bdcd8170SKalle Valo return -EINVAL; 1161bdcd8170SKalle Valo 1162bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1163bdcd8170SKalle Valo 1164bdcd8170SKalle Valo return 0; 1165bdcd8170SKalle Valo } 1166bdcd8170SKalle Valo 1167240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len, 1168240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1169bdcd8170SKalle Valo { 1170bdcd8170SKalle Valo struct wmi_scan_complete_event *ev; 1171bdcd8170SKalle Valo 1172bdcd8170SKalle Valo ev = (struct wmi_scan_complete_event *) datap; 1173bdcd8170SKalle Valo 1174240d2799SVasanthakumar Thiagarajan ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status)); 1175bdcd8170SKalle Valo wmi->is_probe_ssid = false; 1176bdcd8170SKalle Valo 1177bdcd8170SKalle Valo return 0; 1178bdcd8170SKalle Valo } 1179bdcd8170SKalle Valo 118086512136SJouni Malinen static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap, 1181240d2799SVasanthakumar Thiagarajan int len, struct ath6kl_vif *vif) 118286512136SJouni Malinen { 118386512136SJouni Malinen struct wmi_neighbor_report_event *ev; 118486512136SJouni Malinen u8 i; 118586512136SJouni Malinen 118686512136SJouni Malinen if (len < sizeof(*ev)) 118786512136SJouni Malinen return -EINVAL; 118886512136SJouni Malinen ev = (struct wmi_neighbor_report_event *) datap; 118986512136SJouni Malinen if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info) 119086512136SJouni Malinen > len) { 119186512136SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "truncated neighbor event " 119286512136SJouni Malinen "(num=%d len=%d)\n", ev->num_neighbors, len); 119386512136SJouni Malinen return -EINVAL; 119486512136SJouni Malinen } 119586512136SJouni Malinen for (i = 0; i < ev->num_neighbors; i++) { 119686512136SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n", 119786512136SJouni Malinen i + 1, ev->num_neighbors, ev->neighbor[i].bssid, 119886512136SJouni Malinen ev->neighbor[i].bss_flags); 1199240d2799SVasanthakumar Thiagarajan cfg80211_pmksa_candidate_notify(vif->ndev, i, 120086512136SJouni Malinen ev->neighbor[i].bssid, 120186512136SJouni Malinen !!(ev->neighbor[i].bss_flags & 120286512136SJouni Malinen WMI_PREAUTH_CAPABLE_BSS), 120386512136SJouni Malinen GFP_ATOMIC); 120486512136SJouni Malinen } 120586512136SJouni Malinen 120686512136SJouni Malinen return 0; 120786512136SJouni Malinen } 120886512136SJouni Malinen 1209bdcd8170SKalle Valo /* 1210bdcd8170SKalle Valo * Target is reporting a programming error. This is for 1211bdcd8170SKalle Valo * developer aid only. Target only checks a few common violations 1212bdcd8170SKalle Valo * and it is responsibility of host to do all error checking. 1213bdcd8170SKalle Valo * Behavior of target after wmi error event is undefined. 1214bdcd8170SKalle Valo * A reset is recommended. 1215bdcd8170SKalle Valo */ 1216bdcd8170SKalle Valo static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) 1217bdcd8170SKalle Valo { 1218bdcd8170SKalle Valo const char *type = "unknown error"; 1219bdcd8170SKalle Valo struct wmi_cmd_error_event *ev; 1220bdcd8170SKalle Valo ev = (struct wmi_cmd_error_event *) datap; 1221bdcd8170SKalle Valo 1222bdcd8170SKalle Valo switch (ev->err_code) { 1223bdcd8170SKalle Valo case INVALID_PARAM: 1224bdcd8170SKalle Valo type = "invalid parameter"; 1225bdcd8170SKalle Valo break; 1226bdcd8170SKalle Valo case ILLEGAL_STATE: 1227bdcd8170SKalle Valo type = "invalid state"; 1228bdcd8170SKalle Valo break; 1229bdcd8170SKalle Valo case INTERNAL_ERROR: 1230bdcd8170SKalle Valo type = "internal error"; 1231bdcd8170SKalle Valo break; 1232bdcd8170SKalle Valo } 1233bdcd8170SKalle Valo 1234bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", 1235bdcd8170SKalle Valo ev->cmd_id, type); 1236bdcd8170SKalle Valo 1237bdcd8170SKalle Valo return 0; 1238bdcd8170SKalle Valo } 1239bdcd8170SKalle Valo 1240240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len, 1241240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1242bdcd8170SKalle Valo { 1243240d2799SVasanthakumar Thiagarajan ath6kl_tgt_stats_event(vif, datap, len); 1244bdcd8170SKalle Valo 1245bdcd8170SKalle Valo return 0; 1246bdcd8170SKalle Valo } 1247bdcd8170SKalle Valo 1248bdcd8170SKalle Valo static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, 1249bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1250bdcd8170SKalle Valo u32 size) 1251bdcd8170SKalle Valo { 1252bdcd8170SKalle Valo u32 index; 1253bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; 1254bdcd8170SKalle Valo 1255bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1256bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1257bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[index]) { 1258bdcd8170SKalle Valo threshold = (u8) sq_thresh->upper_threshold[index]; 1259bdcd8170SKalle Valo break; 1260bdcd8170SKalle Valo } 1261bdcd8170SKalle Valo } 1262bdcd8170SKalle Valo 1263bdcd8170SKalle Valo return threshold; 1264bdcd8170SKalle Valo } 1265bdcd8170SKalle Valo 1266bdcd8170SKalle Valo static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, 1267bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1268bdcd8170SKalle Valo u32 size) 1269bdcd8170SKalle Valo { 1270bdcd8170SKalle Valo u32 index; 1271bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; 1272bdcd8170SKalle Valo 1273bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1274bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1275bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[index]) { 1276bdcd8170SKalle Valo threshold = (u8) sq_thresh->lower_threshold[index]; 1277bdcd8170SKalle Valo break; 1278bdcd8170SKalle Valo } 1279bdcd8170SKalle Valo } 1280bdcd8170SKalle Valo 1281bdcd8170SKalle Valo return threshold; 1282bdcd8170SKalle Valo } 1283bdcd8170SKalle Valo 1284bdcd8170SKalle Valo static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, 1285bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *rssi_cmd) 1286bdcd8170SKalle Valo { 1287bdcd8170SKalle Valo struct sk_buff *skb; 1288bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *cmd; 1289bdcd8170SKalle Valo 1290bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1291bdcd8170SKalle Valo if (!skb) 1292bdcd8170SKalle Valo return -ENOMEM; 1293bdcd8170SKalle Valo 1294bdcd8170SKalle Valo cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; 1295bdcd8170SKalle Valo memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); 1296bdcd8170SKalle Valo 1297334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, 1298bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1299bdcd8170SKalle Valo } 1300bdcd8170SKalle Valo 1301bdcd8170SKalle Valo static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, 1302bdcd8170SKalle Valo int len) 1303bdcd8170SKalle Valo { 1304bdcd8170SKalle Valo struct wmi_rssi_threshold_event *reply; 1305bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd cmd; 1306bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1307bdcd8170SKalle Valo enum wmi_rssi_threshold_val new_threshold; 1308bdcd8170SKalle Valo u8 upper_rssi_threshold, lower_rssi_threshold; 1309bdcd8170SKalle Valo s16 rssi; 1310bdcd8170SKalle Valo int ret; 1311bdcd8170SKalle Valo 1312bdcd8170SKalle Valo if (len < sizeof(struct wmi_rssi_threshold_event)) 1313bdcd8170SKalle Valo return -EINVAL; 1314bdcd8170SKalle Valo 1315bdcd8170SKalle Valo reply = (struct wmi_rssi_threshold_event *) datap; 1316bdcd8170SKalle Valo new_threshold = (enum wmi_rssi_threshold_val) reply->range; 1317bdcd8170SKalle Valo rssi = a_sle16_to_cpu(reply->rssi); 1318bdcd8170SKalle Valo 1319bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; 1320bdcd8170SKalle Valo 1321bdcd8170SKalle Valo /* 1322bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1323bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1324bdcd8170SKalle Valo * quality reported by the target 1325bdcd8170SKalle Valo */ 1326bdcd8170SKalle Valo if (new_threshold) { 1327bdcd8170SKalle Valo /* Upper threshold breached */ 1328bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[0]) { 1329bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1330bdcd8170SKalle Valo "spurious upper rssi threshold event: %d\n", 1331bdcd8170SKalle Valo rssi); 1332bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[1]) && 1333bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[0])) { 1334bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; 1335bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[2]) && 1336bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[1])) { 1337bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; 1338bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[3]) && 1339bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[2])) { 1340bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; 1341bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[4]) && 1342bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[3])) { 1343bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; 1344bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[5]) && 1345bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[4])) { 1346bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; 1347bdcd8170SKalle Valo } else if (rssi >= sq_thresh->upper_threshold[5]) { 1348bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; 1349bdcd8170SKalle Valo } 1350bdcd8170SKalle Valo } else { 1351bdcd8170SKalle Valo /* Lower threshold breached */ 1352bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[0]) { 1353bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1354bdcd8170SKalle Valo "spurious lower rssi threshold event: %d %d\n", 1355bdcd8170SKalle Valo rssi, sq_thresh->lower_threshold[0]); 1356bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[1]) && 1357bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[0])) { 1358bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_BELOW; 1359bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[2]) && 1360bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[1])) { 1361bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_BELOW; 1362bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[3]) && 1363bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[2])) { 1364bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_BELOW; 1365bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[4]) && 1366bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[3])) { 1367bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_BELOW; 1368bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[5]) && 1369bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[4])) { 1370bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_BELOW; 1371bdcd8170SKalle Valo } else if (rssi <= sq_thresh->lower_threshold[5]) { 1372bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_BELOW; 1373bdcd8170SKalle Valo } 1374bdcd8170SKalle Valo } 1375bdcd8170SKalle Valo 1376bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1377bdcd8170SKalle Valo lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, 1378bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1379bdcd8170SKalle Valo upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, 1380bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1381bdcd8170SKalle Valo 1382bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1383bdcd8170SKalle Valo cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); 1384bdcd8170SKalle Valo cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); 1385bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1386bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1387bdcd8170SKalle Valo 1388bdcd8170SKalle Valo ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); 1389bdcd8170SKalle Valo if (ret) { 1390bdcd8170SKalle Valo ath6kl_err("unable to configure rssi thresholds\n"); 1391bdcd8170SKalle Valo return -EIO; 1392bdcd8170SKalle Valo } 1393bdcd8170SKalle Valo 1394bdcd8170SKalle Valo return 0; 1395bdcd8170SKalle Valo } 1396bdcd8170SKalle Valo 1397240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len, 1398240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1399bdcd8170SKalle Valo { 1400bdcd8170SKalle Valo struct wmi_cac_event *reply; 1401bdcd8170SKalle Valo struct ieee80211_tspec_ie *ts; 1402bdcd8170SKalle Valo u16 active_tsids, tsinfo; 1403bdcd8170SKalle Valo u8 tsid, index; 1404bdcd8170SKalle Valo u8 ts_id; 1405bdcd8170SKalle Valo 1406bdcd8170SKalle Valo if (len < sizeof(struct wmi_cac_event)) 1407bdcd8170SKalle Valo return -EINVAL; 1408bdcd8170SKalle Valo 1409bdcd8170SKalle Valo reply = (struct wmi_cac_event *) datap; 1410bdcd8170SKalle Valo 1411bdcd8170SKalle Valo if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && 1412bdcd8170SKalle Valo (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { 1413bdcd8170SKalle Valo 1414bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1415bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1416bdcd8170SKalle Valo tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1417bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK; 1418bdcd8170SKalle Valo 1419240d2799SVasanthakumar Thiagarajan ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, 1420240d2799SVasanthakumar Thiagarajan reply->ac, tsid); 1421bdcd8170SKalle Valo } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { 1422bdcd8170SKalle Valo /* 1423bdcd8170SKalle Valo * Following assumes that there is only one outstanding 1424bdcd8170SKalle Valo * ADDTS request when this event is received 1425bdcd8170SKalle Valo */ 1426bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1427bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1428bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1429bdcd8170SKalle Valo 1430bdcd8170SKalle Valo for (index = 0; index < sizeof(active_tsids) * 8; index++) { 1431bdcd8170SKalle Valo if ((active_tsids >> index) & 1) 1432bdcd8170SKalle Valo break; 1433bdcd8170SKalle Valo } 1434bdcd8170SKalle Valo if (index < (sizeof(active_tsids) * 8)) 1435240d2799SVasanthakumar Thiagarajan ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, 1436240d2799SVasanthakumar Thiagarajan reply->ac, index); 1437bdcd8170SKalle Valo } 1438bdcd8170SKalle Valo 1439bdcd8170SKalle Valo /* 1440bdcd8170SKalle Valo * Clear active tsids and Add missing handling 1441bdcd8170SKalle Valo * for delete qos stream from AP 1442bdcd8170SKalle Valo */ 1443bdcd8170SKalle Valo else if (reply->cac_indication == CAC_INDICATION_DELETE) { 1444bdcd8170SKalle Valo 1445bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1446bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1447bdcd8170SKalle Valo ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1448bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK); 1449bdcd8170SKalle Valo 1450bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1451bdcd8170SKalle Valo wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); 1452bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1453bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1454bdcd8170SKalle Valo 1455bdcd8170SKalle Valo /* Indicate stream inactivity to driver layer only if all tsids 1456bdcd8170SKalle Valo * within this AC are deleted. 1457bdcd8170SKalle Valo */ 1458bdcd8170SKalle Valo if (!active_tsids) { 1459bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, 1460bdcd8170SKalle Valo false); 1461bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << reply->ac); 1462bdcd8170SKalle Valo } 1463bdcd8170SKalle Valo } 1464bdcd8170SKalle Valo 1465bdcd8170SKalle Valo return 0; 1466bdcd8170SKalle Valo } 1467bdcd8170SKalle Valo 1468bdcd8170SKalle Valo static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, 1469bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *snr_cmd) 1470bdcd8170SKalle Valo { 1471bdcd8170SKalle Valo struct sk_buff *skb; 1472bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *cmd; 1473bdcd8170SKalle Valo 1474bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1475bdcd8170SKalle Valo if (!skb) 1476bdcd8170SKalle Valo return -ENOMEM; 1477bdcd8170SKalle Valo 1478bdcd8170SKalle Valo cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; 1479bdcd8170SKalle Valo memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); 1480bdcd8170SKalle Valo 1481334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, 1482bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1483bdcd8170SKalle Valo } 1484bdcd8170SKalle Valo 1485bdcd8170SKalle Valo static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, 1486bdcd8170SKalle Valo int len) 1487bdcd8170SKalle Valo { 1488bdcd8170SKalle Valo struct wmi_snr_threshold_event *reply; 1489bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1490bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd cmd; 1491bdcd8170SKalle Valo enum wmi_snr_threshold_val new_threshold; 1492bdcd8170SKalle Valo u8 upper_snr_threshold, lower_snr_threshold; 1493bdcd8170SKalle Valo s16 snr; 1494bdcd8170SKalle Valo int ret; 1495bdcd8170SKalle Valo 1496bdcd8170SKalle Valo if (len < sizeof(struct wmi_snr_threshold_event)) 1497bdcd8170SKalle Valo return -EINVAL; 1498bdcd8170SKalle Valo 1499bdcd8170SKalle Valo reply = (struct wmi_snr_threshold_event *) datap; 1500bdcd8170SKalle Valo 1501bdcd8170SKalle Valo new_threshold = (enum wmi_snr_threshold_val) reply->range; 1502bdcd8170SKalle Valo snr = reply->snr; 1503bdcd8170SKalle Valo 1504bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; 1505bdcd8170SKalle Valo 1506bdcd8170SKalle Valo /* 1507bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1508bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1509bdcd8170SKalle Valo * quality reported by the target. 1510bdcd8170SKalle Valo */ 1511bdcd8170SKalle Valo if (new_threshold) { 1512bdcd8170SKalle Valo /* Upper threshold breached */ 1513bdcd8170SKalle Valo if (snr < sq_thresh->upper_threshold[0]) { 1514bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1515bdcd8170SKalle Valo "spurious upper snr threshold event: %d\n", 1516bdcd8170SKalle Valo snr); 1517bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[1]) && 1518bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[0])) { 1519bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_ABOVE; 1520bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[2]) && 1521bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[1])) { 1522bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_ABOVE; 1523bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[3]) && 1524bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[2])) { 1525bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_ABOVE; 1526bdcd8170SKalle Valo } else if (snr >= sq_thresh->upper_threshold[3]) { 1527bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_ABOVE; 1528bdcd8170SKalle Valo } 1529bdcd8170SKalle Valo } else { 1530bdcd8170SKalle Valo /* Lower threshold breached */ 1531bdcd8170SKalle Valo if (snr > sq_thresh->lower_threshold[0]) { 1532bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1533bdcd8170SKalle Valo "spurious lower snr threshold event: %d\n", 1534bdcd8170SKalle Valo sq_thresh->lower_threshold[0]); 1535bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[1]) && 1536bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[0])) { 1537bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_BELOW; 1538bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[2]) && 1539bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[1])) { 1540bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_BELOW; 1541bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[3]) && 1542bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[2])) { 1543bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_BELOW; 1544bdcd8170SKalle Valo } else if (snr <= sq_thresh->lower_threshold[3]) { 1545bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_BELOW; 1546bdcd8170SKalle Valo } 1547bdcd8170SKalle Valo } 1548bdcd8170SKalle Valo 1549bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1550bdcd8170SKalle Valo lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, 1551bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1552bdcd8170SKalle Valo upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, 1553bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1554bdcd8170SKalle Valo 1555bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1556bdcd8170SKalle Valo cmd.thresh_above1_val = upper_snr_threshold; 1557bdcd8170SKalle Valo cmd.thresh_below1_val = lower_snr_threshold; 1558bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1559bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1560bdcd8170SKalle Valo 1561bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1562bdcd8170SKalle Valo "snr: %d, threshold: %d, lower: %d, upper: %d\n", 1563bdcd8170SKalle Valo snr, new_threshold, 1564bdcd8170SKalle Valo lower_snr_threshold, upper_snr_threshold); 1565bdcd8170SKalle Valo 1566bdcd8170SKalle Valo ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); 1567bdcd8170SKalle Valo if (ret) { 1568bdcd8170SKalle Valo ath6kl_err("unable to configure snr threshold\n"); 1569bdcd8170SKalle Valo return -EIO; 1570bdcd8170SKalle Valo } 1571bdcd8170SKalle Valo 1572bdcd8170SKalle Valo return 0; 1573bdcd8170SKalle Valo } 1574bdcd8170SKalle Valo 1575bdcd8170SKalle Valo static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) 1576bdcd8170SKalle Valo { 1577bdcd8170SKalle Valo u16 ap_info_entry_size; 1578bdcd8170SKalle Valo struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; 1579bdcd8170SKalle Valo struct wmi_ap_info_v1 *ap_info_v1; 1580bdcd8170SKalle Valo u8 index; 1581bdcd8170SKalle Valo 1582bdcd8170SKalle Valo if (len < sizeof(struct wmi_aplist_event) || 1583bdcd8170SKalle Valo ev->ap_list_ver != APLIST_VER1) 1584bdcd8170SKalle Valo return -EINVAL; 1585bdcd8170SKalle Valo 1586bdcd8170SKalle Valo ap_info_entry_size = sizeof(struct wmi_ap_info_v1); 1587bdcd8170SKalle Valo ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; 1588bdcd8170SKalle Valo 1589bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1590bdcd8170SKalle Valo "number of APs in aplist event: %d\n", ev->num_ap); 1591bdcd8170SKalle Valo 1592bdcd8170SKalle Valo if (len < (int) (sizeof(struct wmi_aplist_event) + 1593bdcd8170SKalle Valo (ev->num_ap - 1) * ap_info_entry_size)) 1594bdcd8170SKalle Valo return -EINVAL; 1595bdcd8170SKalle Valo 1596bdcd8170SKalle Valo /* AP list version 1 contents */ 1597bdcd8170SKalle Valo for (index = 0; index < ev->num_ap; index++) { 1598bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", 1599bdcd8170SKalle Valo index, ap_info_v1->bssid, ap_info_v1->channel); 1600bdcd8170SKalle Valo ap_info_v1++; 1601bdcd8170SKalle Valo } 1602bdcd8170SKalle Valo 1603bdcd8170SKalle Valo return 0; 1604bdcd8170SKalle Valo } 1605bdcd8170SKalle Valo 1606334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, 1607bdcd8170SKalle Valo enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) 1608bdcd8170SKalle Valo { 1609bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd_hdr; 1610bdcd8170SKalle Valo enum htc_endpoint_id ep_id = wmi->ep_id; 1611bdcd8170SKalle Valo int ret; 1612334234b5SVasanthakumar Thiagarajan u16 info1; 1613bdcd8170SKalle Valo 1614334234b5SVasanthakumar Thiagarajan if (WARN_ON(skb == NULL || (if_idx > (MAX_NUM_VIF - 1)))) 1615bdcd8170SKalle Valo return -EINVAL; 1616bdcd8170SKalle Valo 1617b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n", 1618b9b6ee60SKalle Valo cmd_id, skb->len, sync_flag); 1619b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ", 1620b9b6ee60SKalle Valo skb->data, skb->len); 1621b9b6ee60SKalle Valo 1622bdcd8170SKalle Valo if (sync_flag >= END_WMIFLAG) { 1623bdcd8170SKalle Valo dev_kfree_skb(skb); 1624bdcd8170SKalle Valo return -EINVAL; 1625bdcd8170SKalle Valo } 1626bdcd8170SKalle Valo 1627bdcd8170SKalle Valo if ((sync_flag == SYNC_BEFORE_WMIFLAG) || 1628bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1629bdcd8170SKalle Valo /* 1630bdcd8170SKalle Valo * Make sure all data currently queued is transmitted before 1631bdcd8170SKalle Valo * the cmd execution. Establish a new sync point. 1632bdcd8170SKalle Valo */ 1633240d2799SVasanthakumar Thiagarajan ath6kl_wmi_sync_point(wmi, if_idx); 1634bdcd8170SKalle Valo } 1635bdcd8170SKalle Valo 1636bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_cmd_hdr)); 1637bdcd8170SKalle Valo 1638bdcd8170SKalle Valo cmd_hdr = (struct wmi_cmd_hdr *) skb->data; 1639bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le16(cmd_id); 1640334234b5SVasanthakumar Thiagarajan info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK; 1641334234b5SVasanthakumar Thiagarajan cmd_hdr->info1 = cpu_to_le16(info1); 1642bdcd8170SKalle Valo 1643bdcd8170SKalle Valo /* Only for OPT_TX_CMD, use BE endpoint. */ 1644bdcd8170SKalle Valo if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { 1645bdcd8170SKalle Valo ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, 16466765d0aaSVasanthakumar Thiagarajan false, false, 0, NULL, if_idx); 1647bdcd8170SKalle Valo if (ret) { 1648bdcd8170SKalle Valo dev_kfree_skb(skb); 1649bdcd8170SKalle Valo return ret; 1650bdcd8170SKalle Valo } 1651bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); 1652bdcd8170SKalle Valo } 1653bdcd8170SKalle Valo 1654bdcd8170SKalle Valo ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 1655bdcd8170SKalle Valo 1656bdcd8170SKalle Valo if ((sync_flag == SYNC_AFTER_WMIFLAG) || 1657bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1658bdcd8170SKalle Valo /* 1659bdcd8170SKalle Valo * Make sure all new data queued waits for the command to 1660bdcd8170SKalle Valo * execute. Establish a new sync point. 1661bdcd8170SKalle Valo */ 1662240d2799SVasanthakumar Thiagarajan ath6kl_wmi_sync_point(wmi, if_idx); 1663bdcd8170SKalle Valo } 1664bdcd8170SKalle Valo 1665bdcd8170SKalle Valo return 0; 1666bdcd8170SKalle Valo } 1667bdcd8170SKalle Valo 1668334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx, 1669334234b5SVasanthakumar Thiagarajan enum network_type nw_type, 1670bdcd8170SKalle Valo enum dot11_auth_mode dot11_auth_mode, 1671bdcd8170SKalle Valo enum auth_mode auth_mode, 1672bdcd8170SKalle Valo enum crypto_type pairwise_crypto, 1673bdcd8170SKalle Valo u8 pairwise_crypto_len, 1674bdcd8170SKalle Valo enum crypto_type group_crypto, 1675bdcd8170SKalle Valo u8 group_crypto_len, int ssid_len, u8 *ssid, 1676bdcd8170SKalle Valo u8 *bssid, u16 channel, u32 ctrl_flags) 1677bdcd8170SKalle Valo { 1678bdcd8170SKalle Valo struct sk_buff *skb; 1679bdcd8170SKalle Valo struct wmi_connect_cmd *cc; 1680bdcd8170SKalle Valo int ret; 1681bdcd8170SKalle Valo 1682b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1683b9b6ee60SKalle Valo "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d " 1684b9b6ee60SKalle Valo "type %d dot11_auth %d auth %d pairwise %d group %d\n", 1685b9b6ee60SKalle Valo bssid, channel, ctrl_flags, ssid_len, nw_type, 1686b9b6ee60SKalle Valo dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto); 1687b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len); 1688b9b6ee60SKalle Valo 1689bdcd8170SKalle Valo wmi->traffic_class = 100; 1690bdcd8170SKalle Valo 1691bdcd8170SKalle Valo if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) 1692bdcd8170SKalle Valo return -EINVAL; 1693bdcd8170SKalle Valo 1694bdcd8170SKalle Valo if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) 1695bdcd8170SKalle Valo return -EINVAL; 1696bdcd8170SKalle Valo 1697bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); 1698bdcd8170SKalle Valo if (!skb) 1699bdcd8170SKalle Valo return -ENOMEM; 1700bdcd8170SKalle Valo 1701bdcd8170SKalle Valo cc = (struct wmi_connect_cmd *) skb->data; 1702bdcd8170SKalle Valo 1703bdcd8170SKalle Valo if (ssid_len) 1704bdcd8170SKalle Valo memcpy(cc->ssid, ssid, ssid_len); 1705bdcd8170SKalle Valo 1706bdcd8170SKalle Valo cc->ssid_len = ssid_len; 1707bdcd8170SKalle Valo cc->nw_type = nw_type; 1708bdcd8170SKalle Valo cc->dot11_auth_mode = dot11_auth_mode; 1709bdcd8170SKalle Valo cc->auth_mode = auth_mode; 1710bdcd8170SKalle Valo cc->prwise_crypto_type = pairwise_crypto; 1711bdcd8170SKalle Valo cc->prwise_crypto_len = pairwise_crypto_len; 1712bdcd8170SKalle Valo cc->grp_crypto_type = group_crypto; 1713bdcd8170SKalle Valo cc->grp_crypto_len = group_crypto_len; 1714bdcd8170SKalle Valo cc->ch = cpu_to_le16(channel); 1715bdcd8170SKalle Valo cc->ctrl_flags = cpu_to_le32(ctrl_flags); 1716bdcd8170SKalle Valo 1717bdcd8170SKalle Valo if (bssid != NULL) 1718bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1719bdcd8170SKalle Valo 1720334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID, 1721334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 1722bdcd8170SKalle Valo 1723bdcd8170SKalle Valo return ret; 1724bdcd8170SKalle Valo } 1725bdcd8170SKalle Valo 1726334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid, 1727334234b5SVasanthakumar Thiagarajan u16 channel) 1728bdcd8170SKalle Valo { 1729bdcd8170SKalle Valo struct sk_buff *skb; 1730bdcd8170SKalle Valo struct wmi_reconnect_cmd *cc; 1731bdcd8170SKalle Valo int ret; 1732bdcd8170SKalle Valo 1733b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n", 1734b9b6ee60SKalle Valo bssid, channel); 1735b9b6ee60SKalle Valo 1736bdcd8170SKalle Valo wmi->traffic_class = 100; 1737bdcd8170SKalle Valo 1738bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); 1739bdcd8170SKalle Valo if (!skb) 1740bdcd8170SKalle Valo return -ENOMEM; 1741bdcd8170SKalle Valo 1742bdcd8170SKalle Valo cc = (struct wmi_reconnect_cmd *) skb->data; 1743bdcd8170SKalle Valo cc->channel = cpu_to_le16(channel); 1744bdcd8170SKalle Valo 1745bdcd8170SKalle Valo if (bssid != NULL) 1746bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1747bdcd8170SKalle Valo 1748334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID, 1749bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1750bdcd8170SKalle Valo 1751bdcd8170SKalle Valo return ret; 1752bdcd8170SKalle Valo } 1753bdcd8170SKalle Valo 1754334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx) 1755bdcd8170SKalle Valo { 1756bdcd8170SKalle Valo int ret; 1757bdcd8170SKalle Valo 1758b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n"); 1759b9b6ee60SKalle Valo 1760bdcd8170SKalle Valo wmi->traffic_class = 100; 1761bdcd8170SKalle Valo 1762bdcd8170SKalle Valo /* Disconnect command does not need to do a SYNC before. */ 1763334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID); 1764bdcd8170SKalle Valo 1765bdcd8170SKalle Valo return ret; 1766bdcd8170SKalle Valo } 1767bdcd8170SKalle Valo 1768334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx, 1769334234b5SVasanthakumar Thiagarajan enum wmi_scan_type scan_type, 1770bdcd8170SKalle Valo u32 force_fgscan, u32 is_legacy, 1771bdcd8170SKalle Valo u32 home_dwell_time, u32 force_scan_interval, 1772bdcd8170SKalle Valo s8 num_chan, u16 *ch_list) 1773bdcd8170SKalle Valo { 1774bdcd8170SKalle Valo struct sk_buff *skb; 1775bdcd8170SKalle Valo struct wmi_start_scan_cmd *sc; 1776bdcd8170SKalle Valo s8 size; 17771276c9efSEdward Lu int i, ret; 1778bdcd8170SKalle Valo 1779bdcd8170SKalle Valo size = sizeof(struct wmi_start_scan_cmd); 1780bdcd8170SKalle Valo 1781bdcd8170SKalle Valo if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 1782bdcd8170SKalle Valo return -EINVAL; 1783bdcd8170SKalle Valo 1784bdcd8170SKalle Valo if (num_chan > WMI_MAX_CHANNELS) 1785bdcd8170SKalle Valo return -EINVAL; 1786bdcd8170SKalle Valo 1787bdcd8170SKalle Valo if (num_chan) 1788bdcd8170SKalle Valo size += sizeof(u16) * (num_chan - 1); 1789bdcd8170SKalle Valo 1790bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(size); 1791bdcd8170SKalle Valo if (!skb) 1792bdcd8170SKalle Valo return -ENOMEM; 1793bdcd8170SKalle Valo 1794bdcd8170SKalle Valo sc = (struct wmi_start_scan_cmd *) skb->data; 1795bdcd8170SKalle Valo sc->scan_type = scan_type; 1796bdcd8170SKalle Valo sc->force_fg_scan = cpu_to_le32(force_fgscan); 1797bdcd8170SKalle Valo sc->is_legacy = cpu_to_le32(is_legacy); 1798bdcd8170SKalle Valo sc->home_dwell_time = cpu_to_le32(home_dwell_time); 1799bdcd8170SKalle Valo sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 1800bdcd8170SKalle Valo sc->num_ch = num_chan; 1801bdcd8170SKalle Valo 18021276c9efSEdward Lu for (i = 0; i < num_chan; i++) 18031276c9efSEdward Lu sc->ch_list[i] = cpu_to_le16(ch_list[i]); 1804bdcd8170SKalle Valo 1805334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID, 1806bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1807bdcd8170SKalle Valo 1808bdcd8170SKalle Valo return ret; 1809bdcd8170SKalle Valo } 1810bdcd8170SKalle Valo 1811334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx, 1812334234b5SVasanthakumar Thiagarajan u16 fg_start_sec, 1813bdcd8170SKalle Valo u16 fg_end_sec, u16 bg_sec, 1814bdcd8170SKalle Valo u16 minact_chdw_msec, u16 maxact_chdw_msec, 1815bdcd8170SKalle Valo u16 pas_chdw_msec, u8 short_scan_ratio, 1816bdcd8170SKalle Valo u8 scan_ctrl_flag, u32 max_dfsch_act_time, 1817bdcd8170SKalle Valo u16 maxact_scan_per_ssid) 1818bdcd8170SKalle Valo { 1819bdcd8170SKalle Valo struct sk_buff *skb; 1820bdcd8170SKalle Valo struct wmi_scan_params_cmd *sc; 1821bdcd8170SKalle Valo int ret; 1822bdcd8170SKalle Valo 1823bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); 1824bdcd8170SKalle Valo if (!skb) 1825bdcd8170SKalle Valo return -ENOMEM; 1826bdcd8170SKalle Valo 1827bdcd8170SKalle Valo sc = (struct wmi_scan_params_cmd *) skb->data; 1828bdcd8170SKalle Valo sc->fg_start_period = cpu_to_le16(fg_start_sec); 1829bdcd8170SKalle Valo sc->fg_end_period = cpu_to_le16(fg_end_sec); 1830bdcd8170SKalle Valo sc->bg_period = cpu_to_le16(bg_sec); 1831bdcd8170SKalle Valo sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); 1832bdcd8170SKalle Valo sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); 1833bdcd8170SKalle Valo sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); 1834bdcd8170SKalle Valo sc->short_scan_ratio = short_scan_ratio; 1835bdcd8170SKalle Valo sc->scan_ctrl_flags = scan_ctrl_flag; 1836bdcd8170SKalle Valo sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); 1837bdcd8170SKalle Valo sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); 1838bdcd8170SKalle Valo 1839334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID, 1840bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1841bdcd8170SKalle Valo return ret; 1842bdcd8170SKalle Valo } 1843bdcd8170SKalle Valo 1844240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask) 1845bdcd8170SKalle Valo { 1846bdcd8170SKalle Valo struct sk_buff *skb; 1847bdcd8170SKalle Valo struct wmi_bss_filter_cmd *cmd; 1848bdcd8170SKalle Valo int ret; 1849bdcd8170SKalle Valo 1850bdcd8170SKalle Valo if (filter >= LAST_BSS_FILTER) 1851bdcd8170SKalle Valo return -EINVAL; 1852bdcd8170SKalle Valo 1853bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1854bdcd8170SKalle Valo if (!skb) 1855bdcd8170SKalle Valo return -ENOMEM; 1856bdcd8170SKalle Valo 1857bdcd8170SKalle Valo cmd = (struct wmi_bss_filter_cmd *) skb->data; 1858bdcd8170SKalle Valo cmd->bss_filter = filter; 1859bdcd8170SKalle Valo cmd->ie_mask = cpu_to_le32(ie_mask); 1860bdcd8170SKalle Valo 1861240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID, 1862bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1863bdcd8170SKalle Valo return ret; 1864bdcd8170SKalle Valo } 1865bdcd8170SKalle Valo 1866334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag, 1867bdcd8170SKalle Valo u8 ssid_len, u8 *ssid) 1868bdcd8170SKalle Valo { 1869bdcd8170SKalle Valo struct sk_buff *skb; 1870bdcd8170SKalle Valo struct wmi_probed_ssid_cmd *cmd; 1871bdcd8170SKalle Valo int ret; 1872bdcd8170SKalle Valo 1873bdcd8170SKalle Valo if (index > MAX_PROBED_SSID_INDEX) 1874bdcd8170SKalle Valo return -EINVAL; 1875bdcd8170SKalle Valo 1876bdcd8170SKalle Valo if (ssid_len > sizeof(cmd->ssid)) 1877bdcd8170SKalle Valo return -EINVAL; 1878bdcd8170SKalle Valo 1879bdcd8170SKalle Valo if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) 1880bdcd8170SKalle Valo return -EINVAL; 1881bdcd8170SKalle Valo 1882bdcd8170SKalle Valo if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) 1883bdcd8170SKalle Valo return -EINVAL; 1884bdcd8170SKalle Valo 1885bdcd8170SKalle Valo if (flag & SPECIFIC_SSID_FLAG) 1886bdcd8170SKalle Valo wmi->is_probe_ssid = true; 1887bdcd8170SKalle Valo 1888bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1889bdcd8170SKalle Valo if (!skb) 1890bdcd8170SKalle Valo return -ENOMEM; 1891bdcd8170SKalle Valo 1892bdcd8170SKalle Valo cmd = (struct wmi_probed_ssid_cmd *) skb->data; 1893bdcd8170SKalle Valo cmd->entry_index = index; 1894bdcd8170SKalle Valo cmd->flag = flag; 1895bdcd8170SKalle Valo cmd->ssid_len = ssid_len; 1896bdcd8170SKalle Valo memcpy(cmd->ssid, ssid, ssid_len); 1897bdcd8170SKalle Valo 1898334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID, 1899bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1900bdcd8170SKalle Valo return ret; 1901bdcd8170SKalle Valo } 1902bdcd8170SKalle Valo 1903334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, 1904334234b5SVasanthakumar Thiagarajan u16 listen_interval, 1905bdcd8170SKalle Valo u16 listen_beacons) 1906bdcd8170SKalle Valo { 1907bdcd8170SKalle Valo struct sk_buff *skb; 1908bdcd8170SKalle Valo struct wmi_listen_int_cmd *cmd; 1909bdcd8170SKalle Valo int ret; 1910bdcd8170SKalle Valo 1911bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1912bdcd8170SKalle Valo if (!skb) 1913bdcd8170SKalle Valo return -ENOMEM; 1914bdcd8170SKalle Valo 1915bdcd8170SKalle Valo cmd = (struct wmi_listen_int_cmd *) skb->data; 1916bdcd8170SKalle Valo cmd->listen_intvl = cpu_to_le16(listen_interval); 1917bdcd8170SKalle Valo cmd->num_beacons = cpu_to_le16(listen_beacons); 1918bdcd8170SKalle Valo 1919334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID, 1920bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1921bdcd8170SKalle Valo return ret; 1922bdcd8170SKalle Valo } 1923bdcd8170SKalle Valo 1924334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode) 1925bdcd8170SKalle Valo { 1926bdcd8170SKalle Valo struct sk_buff *skb; 1927bdcd8170SKalle Valo struct wmi_power_mode_cmd *cmd; 1928bdcd8170SKalle Valo int ret; 1929bdcd8170SKalle Valo 1930bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1931bdcd8170SKalle Valo if (!skb) 1932bdcd8170SKalle Valo return -ENOMEM; 1933bdcd8170SKalle Valo 1934bdcd8170SKalle Valo cmd = (struct wmi_power_mode_cmd *) skb->data; 1935bdcd8170SKalle Valo cmd->pwr_mode = pwr_mode; 1936bdcd8170SKalle Valo wmi->pwr_mode = pwr_mode; 1937bdcd8170SKalle Valo 1938334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID, 1939bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1940bdcd8170SKalle Valo return ret; 1941bdcd8170SKalle Valo } 1942bdcd8170SKalle Valo 1943*0ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period, 1944bdcd8170SKalle Valo u16 ps_poll_num, u16 dtim_policy, 1945bdcd8170SKalle Valo u16 tx_wakeup_policy, u16 num_tx_to_wakeup, 1946bdcd8170SKalle Valo u16 ps_fail_event_policy) 1947bdcd8170SKalle Valo { 1948bdcd8170SKalle Valo struct sk_buff *skb; 1949bdcd8170SKalle Valo struct wmi_power_params_cmd *pm; 1950bdcd8170SKalle Valo int ret; 1951bdcd8170SKalle Valo 1952bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); 1953bdcd8170SKalle Valo if (!skb) 1954bdcd8170SKalle Valo return -ENOMEM; 1955bdcd8170SKalle Valo 1956bdcd8170SKalle Valo pm = (struct wmi_power_params_cmd *)skb->data; 1957bdcd8170SKalle Valo pm->idle_period = cpu_to_le16(idle_period); 1958bdcd8170SKalle Valo pm->pspoll_number = cpu_to_le16(ps_poll_num); 1959bdcd8170SKalle Valo pm->dtim_policy = cpu_to_le16(dtim_policy); 1960bdcd8170SKalle Valo pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); 1961bdcd8170SKalle Valo pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); 1962bdcd8170SKalle Valo pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); 1963bdcd8170SKalle Valo 1964*0ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID, 1965bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1966bdcd8170SKalle Valo return ret; 1967bdcd8170SKalle Valo } 1968bdcd8170SKalle Valo 1969*0ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout) 1970bdcd8170SKalle Valo { 1971bdcd8170SKalle Valo struct sk_buff *skb; 1972bdcd8170SKalle Valo struct wmi_disc_timeout_cmd *cmd; 1973bdcd8170SKalle Valo int ret; 1974bdcd8170SKalle Valo 1975bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1976bdcd8170SKalle Valo if (!skb) 1977bdcd8170SKalle Valo return -ENOMEM; 1978bdcd8170SKalle Valo 1979bdcd8170SKalle Valo cmd = (struct wmi_disc_timeout_cmd *) skb->data; 1980bdcd8170SKalle Valo cmd->discon_timeout = timeout; 1981bdcd8170SKalle Valo 1982*0ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID, 1983bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1984334234b5SVasanthakumar Thiagarajan 1985ff0b0075SJouni Malinen if (ret == 0) 1986ff0b0075SJouni Malinen ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout); 1987334234b5SVasanthakumar Thiagarajan 1988bdcd8170SKalle Valo return ret; 1989bdcd8170SKalle Valo } 1990bdcd8170SKalle Valo 1991334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, 1992bdcd8170SKalle Valo enum crypto_type key_type, 1993bdcd8170SKalle Valo u8 key_usage, u8 key_len, 1994bdcd8170SKalle Valo u8 *key_rsc, u8 *key_material, 1995bdcd8170SKalle Valo u8 key_op_ctrl, u8 *mac_addr, 1996bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 1997bdcd8170SKalle Valo { 1998bdcd8170SKalle Valo struct sk_buff *skb; 1999bdcd8170SKalle Valo struct wmi_add_cipher_key_cmd *cmd; 2000bdcd8170SKalle Valo int ret; 2001bdcd8170SKalle Valo 20029a5b1318SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " 20039a5b1318SJouni Malinen "key_usage=%d key_len=%d key_op_ctrl=%d\n", 20049a5b1318SJouni Malinen key_index, key_type, key_usage, key_len, key_op_ctrl); 20059a5b1318SJouni Malinen 2006bdcd8170SKalle Valo if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || 2007bdcd8170SKalle Valo (key_material == NULL)) 2008bdcd8170SKalle Valo return -EINVAL; 2009bdcd8170SKalle Valo 2010bdcd8170SKalle Valo if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) 2011bdcd8170SKalle Valo return -EINVAL; 2012bdcd8170SKalle Valo 2013bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2014bdcd8170SKalle Valo if (!skb) 2015bdcd8170SKalle Valo return -ENOMEM; 2016bdcd8170SKalle Valo 2017bdcd8170SKalle Valo cmd = (struct wmi_add_cipher_key_cmd *) skb->data; 2018bdcd8170SKalle Valo cmd->key_index = key_index; 2019bdcd8170SKalle Valo cmd->key_type = key_type; 2020bdcd8170SKalle Valo cmd->key_usage = key_usage; 2021bdcd8170SKalle Valo cmd->key_len = key_len; 2022bdcd8170SKalle Valo memcpy(cmd->key, key_material, key_len); 2023bdcd8170SKalle Valo 2024bdcd8170SKalle Valo if (key_rsc != NULL) 2025bdcd8170SKalle Valo memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc)); 2026bdcd8170SKalle Valo 2027bdcd8170SKalle Valo cmd->key_op_ctrl = key_op_ctrl; 2028bdcd8170SKalle Valo 2029bdcd8170SKalle Valo if (mac_addr) 2030bdcd8170SKalle Valo memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); 2031bdcd8170SKalle Valo 2032334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID, 2033bdcd8170SKalle Valo sync_flag); 2034bdcd8170SKalle Valo 2035bdcd8170SKalle Valo return ret; 2036bdcd8170SKalle Valo } 2037bdcd8170SKalle Valo 2038240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk) 2039bdcd8170SKalle Valo { 2040bdcd8170SKalle Valo struct sk_buff *skb; 2041bdcd8170SKalle Valo struct wmi_add_krk_cmd *cmd; 2042bdcd8170SKalle Valo int ret; 2043bdcd8170SKalle Valo 2044bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2045bdcd8170SKalle Valo if (!skb) 2046bdcd8170SKalle Valo return -ENOMEM; 2047bdcd8170SKalle Valo 2048bdcd8170SKalle Valo cmd = (struct wmi_add_krk_cmd *) skb->data; 2049bdcd8170SKalle Valo memcpy(cmd->krk, krk, WMI_KRK_LEN); 2050bdcd8170SKalle Valo 2051240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID, 2052334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2053bdcd8170SKalle Valo 2054bdcd8170SKalle Valo return ret; 2055bdcd8170SKalle Valo } 2056bdcd8170SKalle Valo 2057334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index) 2058bdcd8170SKalle Valo { 2059bdcd8170SKalle Valo struct sk_buff *skb; 2060bdcd8170SKalle Valo struct wmi_delete_cipher_key_cmd *cmd; 2061bdcd8170SKalle Valo int ret; 2062bdcd8170SKalle Valo 2063bdcd8170SKalle Valo if (key_index > WMI_MAX_KEY_INDEX) 2064bdcd8170SKalle Valo return -EINVAL; 2065bdcd8170SKalle Valo 2066bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2067bdcd8170SKalle Valo if (!skb) 2068bdcd8170SKalle Valo return -ENOMEM; 2069bdcd8170SKalle Valo 2070bdcd8170SKalle Valo cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; 2071bdcd8170SKalle Valo cmd->key_index = key_index; 2072bdcd8170SKalle Valo 2073334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID, 2074bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2075bdcd8170SKalle Valo 2076bdcd8170SKalle Valo return ret; 2077bdcd8170SKalle Valo } 2078bdcd8170SKalle Valo 2079334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, 2080bdcd8170SKalle Valo const u8 *pmkid, bool set) 2081bdcd8170SKalle Valo { 2082bdcd8170SKalle Valo struct sk_buff *skb; 2083bdcd8170SKalle Valo struct wmi_setpmkid_cmd *cmd; 2084bdcd8170SKalle Valo int ret; 2085bdcd8170SKalle Valo 2086bdcd8170SKalle Valo if (bssid == NULL) 2087bdcd8170SKalle Valo return -EINVAL; 2088bdcd8170SKalle Valo 2089bdcd8170SKalle Valo if (set && pmkid == NULL) 2090bdcd8170SKalle Valo return -EINVAL; 2091bdcd8170SKalle Valo 2092bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2093bdcd8170SKalle Valo if (!skb) 2094bdcd8170SKalle Valo return -ENOMEM; 2095bdcd8170SKalle Valo 2096bdcd8170SKalle Valo cmd = (struct wmi_setpmkid_cmd *) skb->data; 2097bdcd8170SKalle Valo memcpy(cmd->bssid, bssid, ETH_ALEN); 2098bdcd8170SKalle Valo if (set) { 2099bdcd8170SKalle Valo memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); 2100bdcd8170SKalle Valo cmd->enable = PMKID_ENABLE; 2101bdcd8170SKalle Valo } else { 2102bdcd8170SKalle Valo memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); 2103bdcd8170SKalle Valo cmd->enable = PMKID_DISABLE; 2104bdcd8170SKalle Valo } 2105bdcd8170SKalle Valo 2106334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID, 2107bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2108bdcd8170SKalle Valo 2109bdcd8170SKalle Valo return ret; 2110bdcd8170SKalle Valo } 2111bdcd8170SKalle Valo 2112bdcd8170SKalle Valo static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, 21136765d0aaSVasanthakumar Thiagarajan enum htc_endpoint_id ep_id, u8 if_idx) 2114bdcd8170SKalle Valo { 2115bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 2116bdcd8170SKalle Valo int ret; 2117bdcd8170SKalle Valo 2118bdcd8170SKalle Valo if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) 2119bdcd8170SKalle Valo return -EINVAL; 2120bdcd8170SKalle Valo 2121bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 2122bdcd8170SKalle Valo 2123bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) skb->data; 2124bdcd8170SKalle Valo data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; 21256765d0aaSVasanthakumar Thiagarajan data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); 2126bdcd8170SKalle Valo 2127bdcd8170SKalle Valo ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 2128bdcd8170SKalle Valo 2129bdcd8170SKalle Valo return ret; 2130bdcd8170SKalle Valo } 2131bdcd8170SKalle Valo 2132240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx) 2133bdcd8170SKalle Valo { 2134bdcd8170SKalle Valo struct sk_buff *skb; 2135bdcd8170SKalle Valo struct wmi_sync_cmd *cmd; 2136bdcd8170SKalle Valo struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; 2137bdcd8170SKalle Valo enum htc_endpoint_id ep_id; 2138bdcd8170SKalle Valo u8 index, num_pri_streams = 0; 2139bdcd8170SKalle Valo int ret = 0; 2140bdcd8170SKalle Valo 2141bdcd8170SKalle Valo memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); 2142bdcd8170SKalle Valo 2143bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2144bdcd8170SKalle Valo 2145bdcd8170SKalle Valo for (index = 0; index < WMM_NUM_AC; index++) { 2146bdcd8170SKalle Valo if (wmi->fat_pipe_exist & (1 << index)) { 2147bdcd8170SKalle Valo num_pri_streams++; 2148bdcd8170SKalle Valo data_sync_bufs[num_pri_streams - 1].traffic_class = 2149bdcd8170SKalle Valo index; 2150bdcd8170SKalle Valo } 2151bdcd8170SKalle Valo } 2152bdcd8170SKalle Valo 2153bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2154bdcd8170SKalle Valo 2155bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2156bdcd8170SKalle Valo if (!skb) { 2157bdcd8170SKalle Valo ret = -ENOMEM; 2158bdcd8170SKalle Valo goto free_skb; 2159bdcd8170SKalle Valo } 2160bdcd8170SKalle Valo 2161bdcd8170SKalle Valo cmd = (struct wmi_sync_cmd *) skb->data; 2162bdcd8170SKalle Valo 2163bdcd8170SKalle Valo /* 2164bdcd8170SKalle Valo * In the SYNC cmd sent on the control Ep, send a bitmap 2165bdcd8170SKalle Valo * of the data eps on which the Data Sync will be sent 2166bdcd8170SKalle Valo */ 2167bdcd8170SKalle Valo cmd->data_sync_map = wmi->fat_pipe_exist; 2168bdcd8170SKalle Valo 2169bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2170bdcd8170SKalle Valo data_sync_bufs[index].skb = ath6kl_buf_alloc(0); 2171bdcd8170SKalle Valo if (data_sync_bufs[index].skb == NULL) { 2172bdcd8170SKalle Valo ret = -ENOMEM; 2173bdcd8170SKalle Valo break; 2174bdcd8170SKalle Valo } 2175bdcd8170SKalle Valo } 2176bdcd8170SKalle Valo 2177bdcd8170SKalle Valo /* 2178bdcd8170SKalle Valo * If buffer allocation for any of the dataSync fails, 2179bdcd8170SKalle Valo * then do not send the Synchronize cmd on the control ep 2180bdcd8170SKalle Valo */ 2181bdcd8170SKalle Valo if (ret) 2182bdcd8170SKalle Valo goto free_skb; 2183bdcd8170SKalle Valo 2184bdcd8170SKalle Valo /* 2185bdcd8170SKalle Valo * Send sync cmd followed by sync data messages on all 2186bdcd8170SKalle Valo * endpoints being used 2187bdcd8170SKalle Valo */ 2188240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID, 2189bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2190bdcd8170SKalle Valo 2191bdcd8170SKalle Valo if (ret) 2192bdcd8170SKalle Valo goto free_skb; 2193bdcd8170SKalle Valo 2194bdcd8170SKalle Valo /* cmd buffer sent, we no longer own it */ 2195bdcd8170SKalle Valo skb = NULL; 2196bdcd8170SKalle Valo 2197bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2198bdcd8170SKalle Valo 2199bdcd8170SKalle Valo if (WARN_ON(!data_sync_bufs[index].skb)) 2200bdcd8170SKalle Valo break; 2201bdcd8170SKalle Valo 2202bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, 2203bdcd8170SKalle Valo data_sync_bufs[index]. 2204bdcd8170SKalle Valo traffic_class); 2205bdcd8170SKalle Valo ret = 2206bdcd8170SKalle Valo ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, 22076765d0aaSVasanthakumar Thiagarajan ep_id, if_idx); 2208bdcd8170SKalle Valo 2209bdcd8170SKalle Valo if (ret) 2210bdcd8170SKalle Valo break; 2211bdcd8170SKalle Valo 2212bdcd8170SKalle Valo data_sync_bufs[index].skb = NULL; 2213bdcd8170SKalle Valo } 2214bdcd8170SKalle Valo 2215bdcd8170SKalle Valo free_skb: 2216bdcd8170SKalle Valo /* free up any resources left over (possibly due to an error) */ 2217bdcd8170SKalle Valo if (skb) 2218bdcd8170SKalle Valo dev_kfree_skb(skb); 2219bdcd8170SKalle Valo 2220bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2221bdcd8170SKalle Valo if (data_sync_bufs[index].skb != NULL) { 2222bdcd8170SKalle Valo dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. 2223bdcd8170SKalle Valo skb); 2224bdcd8170SKalle Valo } 2225bdcd8170SKalle Valo } 2226bdcd8170SKalle Valo 2227bdcd8170SKalle Valo return ret; 2228bdcd8170SKalle Valo } 2229bdcd8170SKalle Valo 2230240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx, 2231bdcd8170SKalle Valo struct wmi_create_pstream_cmd *params) 2232bdcd8170SKalle Valo { 2233bdcd8170SKalle Valo struct sk_buff *skb; 2234bdcd8170SKalle Valo struct wmi_create_pstream_cmd *cmd; 2235bdcd8170SKalle Valo u8 fatpipe_exist_for_ac = 0; 2236bdcd8170SKalle Valo s32 min_phy = 0; 2237bdcd8170SKalle Valo s32 nominal_phy = 0; 2238bdcd8170SKalle Valo int ret; 2239bdcd8170SKalle Valo 2240bdcd8170SKalle Valo if (!((params->user_pri < 8) && 2241bdcd8170SKalle Valo (params->user_pri <= 0x7) && 2242bdcd8170SKalle Valo (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && 2243bdcd8170SKalle Valo (params->traffic_direc == UPLINK_TRAFFIC || 2244bdcd8170SKalle Valo params->traffic_direc == DNLINK_TRAFFIC || 2245bdcd8170SKalle Valo params->traffic_direc == BIDIR_TRAFFIC) && 2246bdcd8170SKalle Valo (params->traffic_type == TRAFFIC_TYPE_APERIODIC || 2247bdcd8170SKalle Valo params->traffic_type == TRAFFIC_TYPE_PERIODIC) && 2248bdcd8170SKalle Valo (params->voice_psc_cap == DISABLE_FOR_THIS_AC || 2249bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_THIS_AC || 2250bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_ALL_AC) && 2251bdcd8170SKalle Valo (params->tsid == WMI_IMPLICIT_PSTREAM || 2252bdcd8170SKalle Valo params->tsid <= WMI_MAX_THINSTREAM))) { 2253bdcd8170SKalle Valo return -EINVAL; 2254bdcd8170SKalle Valo } 2255bdcd8170SKalle Valo 2256bdcd8170SKalle Valo /* 2257bdcd8170SKalle Valo * Check nominal PHY rate is >= minimalPHY, 2258bdcd8170SKalle Valo * so that DUT can allow TSRS IE 2259bdcd8170SKalle Valo */ 2260bdcd8170SKalle Valo 2261bdcd8170SKalle Valo /* Get the physical rate (units of bps) */ 2262bdcd8170SKalle Valo min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); 2263bdcd8170SKalle Valo 2264bdcd8170SKalle Valo /* Check minimal phy < nominal phy rate */ 2265bdcd8170SKalle Valo if (params->nominal_phy >= min_phy) { 2266bdcd8170SKalle Valo /* unit of 500 kbps */ 2267bdcd8170SKalle Valo nominal_phy = (params->nominal_phy * 1000) / 500; 2268bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2269bdcd8170SKalle Valo "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", 2270bdcd8170SKalle Valo min_phy, nominal_phy); 2271bdcd8170SKalle Valo 2272bdcd8170SKalle Valo params->nominal_phy = nominal_phy; 2273bdcd8170SKalle Valo } else { 2274bdcd8170SKalle Valo params->nominal_phy = 0; 2275bdcd8170SKalle Valo } 2276bdcd8170SKalle Valo 2277bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2278bdcd8170SKalle Valo if (!skb) 2279bdcd8170SKalle Valo return -ENOMEM; 2280bdcd8170SKalle Valo 2281bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2282bdcd8170SKalle Valo "sending create_pstream_cmd: ac=%d tsid:%d\n", 2283bdcd8170SKalle Valo params->traffic_class, params->tsid); 2284bdcd8170SKalle Valo 2285bdcd8170SKalle Valo cmd = (struct wmi_create_pstream_cmd *) skb->data; 2286bdcd8170SKalle Valo memcpy(cmd, params, sizeof(*cmd)); 2287bdcd8170SKalle Valo 2288bdcd8170SKalle Valo /* This is an implicitly created Fat pipe */ 2289bdcd8170SKalle Valo if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { 2290bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2291bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2292bdcd8170SKalle Valo (1 << params->traffic_class)); 2293bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2294bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2295bdcd8170SKalle Valo } else { 2296bdcd8170SKalle Valo /* explicitly created thin stream within a fat pipe */ 2297bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2298bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2299bdcd8170SKalle Valo (1 << params->traffic_class)); 2300bdcd8170SKalle Valo wmi->stream_exist_for_ac[params->traffic_class] |= 2301bdcd8170SKalle Valo (1 << params->tsid); 2302bdcd8170SKalle Valo /* 2303bdcd8170SKalle Valo * If a thinstream becomes active, the fat pipe automatically 2304bdcd8170SKalle Valo * becomes active 2305bdcd8170SKalle Valo */ 2306bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2307bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2308bdcd8170SKalle Valo } 2309bdcd8170SKalle Valo 2310bdcd8170SKalle Valo /* 2311bdcd8170SKalle Valo * Indicate activty change to driver layer only if this is the 2312bdcd8170SKalle Valo * first TSID to get created in this AC explicitly or an implicit 2313bdcd8170SKalle Valo * fat pipe is getting created. 2314bdcd8170SKalle Valo */ 2315bdcd8170SKalle Valo if (!fatpipe_exist_for_ac) 2316bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2317bdcd8170SKalle Valo params->traffic_class, true); 2318bdcd8170SKalle Valo 2319240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID, 2320bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2321bdcd8170SKalle Valo return ret; 2322bdcd8170SKalle Valo } 2323bdcd8170SKalle Valo 2324240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class, 2325240d2799SVasanthakumar Thiagarajan u8 tsid) 2326bdcd8170SKalle Valo { 2327bdcd8170SKalle Valo struct sk_buff *skb; 2328bdcd8170SKalle Valo struct wmi_delete_pstream_cmd *cmd; 2329bdcd8170SKalle Valo u16 active_tsids = 0; 2330bdcd8170SKalle Valo int ret; 2331bdcd8170SKalle Valo 2332bdcd8170SKalle Valo if (traffic_class > 3) { 2333bdcd8170SKalle Valo ath6kl_err("invalid traffic class: %d\n", traffic_class); 2334bdcd8170SKalle Valo return -EINVAL; 2335bdcd8170SKalle Valo } 2336bdcd8170SKalle Valo 2337bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2338bdcd8170SKalle Valo if (!skb) 2339bdcd8170SKalle Valo return -ENOMEM; 2340bdcd8170SKalle Valo 2341bdcd8170SKalle Valo cmd = (struct wmi_delete_pstream_cmd *) skb->data; 2342bdcd8170SKalle Valo cmd->traffic_class = traffic_class; 2343bdcd8170SKalle Valo cmd->tsid = tsid; 2344bdcd8170SKalle Valo 2345bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2346bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2347bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2348bdcd8170SKalle Valo 2349bdcd8170SKalle Valo if (!(active_tsids & (1 << tsid))) { 2350bdcd8170SKalle Valo dev_kfree_skb(skb); 2351bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2352bdcd8170SKalle Valo "TSID %d doesn't exist for traffic class: %d\n", 2353bdcd8170SKalle Valo tsid, traffic_class); 2354bdcd8170SKalle Valo return -ENODATA; 2355bdcd8170SKalle Valo } 2356bdcd8170SKalle Valo 2357bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2358bdcd8170SKalle Valo "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", 2359bdcd8170SKalle Valo traffic_class, tsid); 2360bdcd8170SKalle Valo 2361240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID, 2362bdcd8170SKalle Valo SYNC_BEFORE_WMIFLAG); 2363bdcd8170SKalle Valo 2364bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2365bdcd8170SKalle Valo wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); 2366bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2367bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2368bdcd8170SKalle Valo 2369bdcd8170SKalle Valo /* 2370bdcd8170SKalle Valo * Indicate stream inactivity to driver layer only if all tsids 2371bdcd8170SKalle Valo * within this AC are deleted. 2372bdcd8170SKalle Valo */ 2373bdcd8170SKalle Valo if (!active_tsids) { 2374bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2375bdcd8170SKalle Valo traffic_class, false); 2376bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << traffic_class); 2377bdcd8170SKalle Valo } 2378bdcd8170SKalle Valo 2379bdcd8170SKalle Valo return ret; 2380bdcd8170SKalle Valo } 2381bdcd8170SKalle Valo 2382bdcd8170SKalle Valo int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) 2383bdcd8170SKalle Valo { 2384bdcd8170SKalle Valo struct sk_buff *skb; 2385bdcd8170SKalle Valo struct wmi_set_ip_cmd *cmd; 2386bdcd8170SKalle Valo int ret; 2387bdcd8170SKalle Valo 2388bdcd8170SKalle Valo /* Multicast address are not valid */ 2389bdcd8170SKalle Valo if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) || 2390bdcd8170SKalle Valo (*((u8 *) &ip_cmd->ips[1]) >= 0xE0)) 2391bdcd8170SKalle Valo return -EINVAL; 2392bdcd8170SKalle Valo 2393bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); 2394bdcd8170SKalle Valo if (!skb) 2395bdcd8170SKalle Valo return -ENOMEM; 2396bdcd8170SKalle Valo 2397bdcd8170SKalle Valo cmd = (struct wmi_set_ip_cmd *) skb->data; 2398bdcd8170SKalle Valo memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); 2399bdcd8170SKalle Valo 2400334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_IP_CMDID, 2401334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2402bdcd8170SKalle Valo return ret; 2403bdcd8170SKalle Valo } 2404bdcd8170SKalle Valo 2405bdcd8170SKalle Valo static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, 2406bdcd8170SKalle Valo int len) 2407bdcd8170SKalle Valo { 2408bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_wow_list_reply)) 2409bdcd8170SKalle Valo return -EINVAL; 2410bdcd8170SKalle Valo 2411bdcd8170SKalle Valo return 0; 2412bdcd8170SKalle Valo } 2413bdcd8170SKalle Valo 2414bdcd8170SKalle Valo static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, 2415bdcd8170SKalle Valo enum wmix_command_id cmd_id, 2416bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2417bdcd8170SKalle Valo { 2418bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd_hdr; 2419bdcd8170SKalle Valo int ret; 2420bdcd8170SKalle Valo 2421bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmix_cmd_hdr)); 2422bdcd8170SKalle Valo 2423bdcd8170SKalle Valo cmd_hdr = (struct wmix_cmd_hdr *) skb->data; 2424bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le32(cmd_id); 2425bdcd8170SKalle Valo 2426334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag); 2427bdcd8170SKalle Valo 2428bdcd8170SKalle Valo return ret; 2429bdcd8170SKalle Valo } 2430bdcd8170SKalle Valo 2431bdcd8170SKalle Valo int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) 2432bdcd8170SKalle Valo { 2433bdcd8170SKalle Valo struct sk_buff *skb; 2434bdcd8170SKalle Valo struct wmix_hb_challenge_resp_cmd *cmd; 2435bdcd8170SKalle Valo int ret; 2436bdcd8170SKalle Valo 2437bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2438bdcd8170SKalle Valo if (!skb) 2439bdcd8170SKalle Valo return -ENOMEM; 2440bdcd8170SKalle Valo 2441bdcd8170SKalle Valo cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; 2442bdcd8170SKalle Valo cmd->cookie = cpu_to_le32(cookie); 2443bdcd8170SKalle Valo cmd->source = cpu_to_le32(source); 2444bdcd8170SKalle Valo 2445bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, 2446bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2447bdcd8170SKalle Valo return ret; 2448bdcd8170SKalle Valo } 2449bdcd8170SKalle Valo 2450939f1cceSKalle Valo int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config) 2451939f1cceSKalle Valo { 2452939f1cceSKalle Valo struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd; 2453939f1cceSKalle Valo struct sk_buff *skb; 2454939f1cceSKalle Valo int ret; 2455939f1cceSKalle Valo 2456939f1cceSKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2457939f1cceSKalle Valo if (!skb) 2458939f1cceSKalle Valo return -ENOMEM; 2459939f1cceSKalle Valo 2460939f1cceSKalle Valo cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data; 2461939f1cceSKalle Valo cmd->valid = cpu_to_le32(valid); 2462939f1cceSKalle Valo cmd->config = cpu_to_le32(config); 2463939f1cceSKalle Valo 2464939f1cceSKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID, 2465939f1cceSKalle Valo NO_SYNC_WMIFLAG); 2466939f1cceSKalle Valo return ret; 2467939f1cceSKalle Valo } 2468939f1cceSKalle Valo 2469334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx) 2470bdcd8170SKalle Valo { 2471334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID); 2472bdcd8170SKalle Valo } 2473bdcd8170SKalle Valo 2474990bd915SVasanthakumar Thiagarajan int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM) 2475bdcd8170SKalle Valo { 2476bdcd8170SKalle Valo struct sk_buff *skb; 2477bdcd8170SKalle Valo struct wmi_set_tx_pwr_cmd *cmd; 2478bdcd8170SKalle Valo int ret; 2479bdcd8170SKalle Valo 2480bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); 2481bdcd8170SKalle Valo if (!skb) 2482bdcd8170SKalle Valo return -ENOMEM; 2483bdcd8170SKalle Valo 2484bdcd8170SKalle Valo cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; 2485bdcd8170SKalle Valo cmd->dbM = dbM; 2486bdcd8170SKalle Valo 2487990bd915SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID, 2488bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2489bdcd8170SKalle Valo 2490bdcd8170SKalle Valo return ret; 2491bdcd8170SKalle Valo } 2492bdcd8170SKalle Valo 2493990bd915SVasanthakumar Thiagarajan int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx) 2494bdcd8170SKalle Valo { 2495990bd915SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID); 2496bdcd8170SKalle Valo } 2497bdcd8170SKalle Valo 24984b28a80dSJouni Malinen int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi) 24994b28a80dSJouni Malinen { 2500334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID); 25014b28a80dSJouni Malinen } 25024b28a80dSJouni Malinen 2503*0ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status, 2504*0ce59445SVasanthakumar Thiagarajan u8 preamble_policy) 2505bdcd8170SKalle Valo { 2506bdcd8170SKalle Valo struct sk_buff *skb; 2507bdcd8170SKalle Valo struct wmi_set_lpreamble_cmd *cmd; 2508bdcd8170SKalle Valo int ret; 2509bdcd8170SKalle Valo 2510bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); 2511bdcd8170SKalle Valo if (!skb) 2512bdcd8170SKalle Valo return -ENOMEM; 2513bdcd8170SKalle Valo 2514bdcd8170SKalle Valo cmd = (struct wmi_set_lpreamble_cmd *) skb->data; 2515bdcd8170SKalle Valo cmd->status = status; 2516bdcd8170SKalle Valo cmd->preamble_policy = preamble_policy; 2517bdcd8170SKalle Valo 2518*0ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID, 2519bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2520bdcd8170SKalle Valo return ret; 2521bdcd8170SKalle Valo } 2522bdcd8170SKalle Valo 2523bdcd8170SKalle Valo int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) 2524bdcd8170SKalle Valo { 2525bdcd8170SKalle Valo struct sk_buff *skb; 2526bdcd8170SKalle Valo struct wmi_set_rts_cmd *cmd; 2527bdcd8170SKalle Valo int ret; 2528bdcd8170SKalle Valo 2529bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); 2530bdcd8170SKalle Valo if (!skb) 2531bdcd8170SKalle Valo return -ENOMEM; 2532bdcd8170SKalle Valo 2533bdcd8170SKalle Valo cmd = (struct wmi_set_rts_cmd *) skb->data; 2534bdcd8170SKalle Valo cmd->threshold = cpu_to_le16(threshold); 2535bdcd8170SKalle Valo 2536334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID, 2537334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2538bdcd8170SKalle Valo return ret; 2539bdcd8170SKalle Valo } 2540bdcd8170SKalle Valo 2541*0ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg) 2542bdcd8170SKalle Valo { 2543bdcd8170SKalle Valo struct sk_buff *skb; 2544bdcd8170SKalle Valo struct wmi_set_wmm_txop_cmd *cmd; 2545bdcd8170SKalle Valo int ret; 2546bdcd8170SKalle Valo 2547bdcd8170SKalle Valo if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) 2548bdcd8170SKalle Valo return -EINVAL; 2549bdcd8170SKalle Valo 2550bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); 2551bdcd8170SKalle Valo if (!skb) 2552bdcd8170SKalle Valo return -ENOMEM; 2553bdcd8170SKalle Valo 2554bdcd8170SKalle Valo cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; 2555bdcd8170SKalle Valo cmd->txop_enable = cfg; 2556bdcd8170SKalle Valo 2557*0ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID, 2558bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2559bdcd8170SKalle Valo return ret; 2560bdcd8170SKalle Valo } 2561bdcd8170SKalle Valo 2562*0ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx, 2563*0ce59445SVasanthakumar Thiagarajan u8 keep_alive_intvl) 2564bdcd8170SKalle Valo { 2565bdcd8170SKalle Valo struct sk_buff *skb; 2566bdcd8170SKalle Valo struct wmi_set_keepalive_cmd *cmd; 2567bdcd8170SKalle Valo int ret; 2568bdcd8170SKalle Valo 2569bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2570bdcd8170SKalle Valo if (!skb) 2571bdcd8170SKalle Valo return -ENOMEM; 2572bdcd8170SKalle Valo 2573bdcd8170SKalle Valo cmd = (struct wmi_set_keepalive_cmd *) skb->data; 2574bdcd8170SKalle Valo cmd->keep_alive_intvl = keep_alive_intvl; 2575bdcd8170SKalle Valo 2576*0ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID, 2577bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2578334234b5SVasanthakumar Thiagarajan 2579ff0b0075SJouni Malinen if (ret == 0) 2580ff0b0075SJouni Malinen ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl); 2581334234b5SVasanthakumar Thiagarajan 2582bdcd8170SKalle Valo return ret; 2583bdcd8170SKalle Valo } 2584bdcd8170SKalle Valo 2585003353b0SKalle Valo int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) 2586003353b0SKalle Valo { 2587003353b0SKalle Valo struct sk_buff *skb; 2588003353b0SKalle Valo int ret; 2589003353b0SKalle Valo 2590003353b0SKalle Valo skb = ath6kl_wmi_get_new_buf(len); 2591003353b0SKalle Valo if (!skb) 2592003353b0SKalle Valo return -ENOMEM; 2593003353b0SKalle Valo 2594003353b0SKalle Valo memcpy(skb->data, buf, len); 2595003353b0SKalle Valo 2596334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); 2597003353b0SKalle Valo 2598003353b0SKalle Valo return ret; 2599003353b0SKalle Valo } 2600003353b0SKalle Valo 2601003353b0SKalle Valo 2602bdcd8170SKalle Valo s32 ath6kl_wmi_get_rate(s8 rate_index) 2603bdcd8170SKalle Valo { 2604bdcd8170SKalle Valo if (rate_index == RATE_AUTO) 2605bdcd8170SKalle Valo return 0; 2606bdcd8170SKalle Valo 2607bdcd8170SKalle Valo return wmi_rate_tbl[(u32) rate_index][0]; 2608bdcd8170SKalle Valo } 2609bdcd8170SKalle Valo 2610bdcd8170SKalle Valo static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, 2611bdcd8170SKalle Valo u32 len) 2612bdcd8170SKalle Valo { 2613bdcd8170SKalle Valo struct wmi_pmkid_list_reply *reply; 2614bdcd8170SKalle Valo u32 expected_len; 2615bdcd8170SKalle Valo 2616bdcd8170SKalle Valo if (len < sizeof(struct wmi_pmkid_list_reply)) 2617bdcd8170SKalle Valo return -EINVAL; 2618bdcd8170SKalle Valo 2619bdcd8170SKalle Valo reply = (struct wmi_pmkid_list_reply *)datap; 2620bdcd8170SKalle Valo expected_len = sizeof(reply->num_pmkid) + 2621bdcd8170SKalle Valo le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; 2622bdcd8170SKalle Valo 2623bdcd8170SKalle Valo if (len < expected_len) 2624bdcd8170SKalle Valo return -EINVAL; 2625bdcd8170SKalle Valo 2626bdcd8170SKalle Valo return 0; 2627bdcd8170SKalle Valo } 2628bdcd8170SKalle Valo 2629240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len, 2630240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 2631bdcd8170SKalle Valo { 2632bdcd8170SKalle Valo struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; 2633bdcd8170SKalle Valo 2634240d2799SVasanthakumar Thiagarajan aggr_recv_addba_req_evt(vif, cmd->tid, 2635bdcd8170SKalle Valo le16_to_cpu(cmd->st_seq_no), cmd->win_sz); 2636bdcd8170SKalle Valo 2637bdcd8170SKalle Valo return 0; 2638bdcd8170SKalle Valo } 2639bdcd8170SKalle Valo 2640240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len, 2641240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 2642bdcd8170SKalle Valo { 2643bdcd8170SKalle Valo struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; 2644bdcd8170SKalle Valo 2645240d2799SVasanthakumar Thiagarajan aggr_recv_delba_req_evt(vif, cmd->tid); 2646bdcd8170SKalle Valo 2647bdcd8170SKalle Valo return 0; 2648bdcd8170SKalle Valo } 2649bdcd8170SKalle Valo 2650bdcd8170SKalle Valo /* AP mode functions */ 26516a7c9badSJouni Malinen 2652334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, 2653334234b5SVasanthakumar Thiagarajan struct wmi_connect_cmd *p) 26546a7c9badSJouni Malinen { 26556a7c9badSJouni Malinen struct sk_buff *skb; 26566a7c9badSJouni Malinen struct wmi_connect_cmd *cm; 26576a7c9badSJouni Malinen int res; 26586a7c9badSJouni Malinen 26596a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 26606a7c9badSJouni Malinen if (!skb) 26616a7c9badSJouni Malinen return -ENOMEM; 26626a7c9badSJouni Malinen 26636a7c9badSJouni Malinen cm = (struct wmi_connect_cmd *) skb->data; 26646a7c9badSJouni Malinen memcpy(cm, p, sizeof(*cm)); 26656a7c9badSJouni Malinen 2666334234b5SVasanthakumar Thiagarajan res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID, 26676a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 26686a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " 26696a7c9badSJouni Malinen "ctrl_flags=0x%x-> res=%d\n", 26706a7c9badSJouni Malinen __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), 26716a7c9badSJouni Malinen le32_to_cpu(p->ctrl_flags), res); 26726a7c9badSJouni Malinen return res; 26736a7c9badSJouni Malinen } 26746a7c9badSJouni Malinen 2675334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac, 2676334234b5SVasanthakumar Thiagarajan u16 reason) 267723875136SJouni Malinen { 267823875136SJouni Malinen struct sk_buff *skb; 267923875136SJouni Malinen struct wmi_ap_set_mlme_cmd *cm; 268023875136SJouni Malinen 268123875136SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 268223875136SJouni Malinen if (!skb) 268323875136SJouni Malinen return -ENOMEM; 268423875136SJouni Malinen 268523875136SJouni Malinen cm = (struct wmi_ap_set_mlme_cmd *) skb->data; 268623875136SJouni Malinen memcpy(cm->mac, mac, ETH_ALEN); 268723875136SJouni Malinen cm->reason = cpu_to_le16(reason); 268823875136SJouni Malinen cm->cmd = cmd; 268923875136SJouni Malinen 2690334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID, 269123875136SJouni Malinen NO_SYNC_WMIFLAG); 269223875136SJouni Malinen } 269323875136SJouni Malinen 2694240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len, 2695240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 2696bdcd8170SKalle Valo { 2697bdcd8170SKalle Valo struct wmi_pspoll_event *ev; 2698bdcd8170SKalle Valo 2699bdcd8170SKalle Valo if (len < sizeof(struct wmi_pspoll_event)) 2700bdcd8170SKalle Valo return -EINVAL; 2701bdcd8170SKalle Valo 2702bdcd8170SKalle Valo ev = (struct wmi_pspoll_event *) datap; 2703bdcd8170SKalle Valo 2704240d2799SVasanthakumar Thiagarajan ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid)); 2705bdcd8170SKalle Valo 2706bdcd8170SKalle Valo return 0; 2707bdcd8170SKalle Valo } 2708bdcd8170SKalle Valo 2709240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len, 2710240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 2711bdcd8170SKalle Valo { 2712240d2799SVasanthakumar Thiagarajan ath6kl_dtimexpiry_event(vif); 2713bdcd8170SKalle Valo 2714bdcd8170SKalle Valo return 0; 2715bdcd8170SKalle Valo } 2716bdcd8170SKalle Valo 2717334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid, 2718334234b5SVasanthakumar Thiagarajan bool flag) 2719bdcd8170SKalle Valo { 2720bdcd8170SKalle Valo struct sk_buff *skb; 2721bdcd8170SKalle Valo struct wmi_ap_set_pvb_cmd *cmd; 2722bdcd8170SKalle Valo int ret; 2723bdcd8170SKalle Valo 2724bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); 2725bdcd8170SKalle Valo if (!skb) 2726bdcd8170SKalle Valo return -ENOMEM; 2727bdcd8170SKalle Valo 2728bdcd8170SKalle Valo cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; 2729bdcd8170SKalle Valo cmd->aid = cpu_to_le16(aid); 2730d6e51e6aSJouni Malinen cmd->rsvd = cpu_to_le16(0); 2731bdcd8170SKalle Valo cmd->flag = cpu_to_le32(flag); 2732bdcd8170SKalle Valo 2733334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID, 2734bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2735bdcd8170SKalle Valo 2736bdcd8170SKalle Valo return 0; 2737bdcd8170SKalle Valo } 2738bdcd8170SKalle Valo 2739*0ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx, 2740*0ce59445SVasanthakumar Thiagarajan u8 rx_meta_ver, 2741bdcd8170SKalle Valo bool rx_dot11_hdr, bool defrag_on_host) 2742bdcd8170SKalle Valo { 2743bdcd8170SKalle Valo struct sk_buff *skb; 2744bdcd8170SKalle Valo struct wmi_rx_frame_format_cmd *cmd; 2745bdcd8170SKalle Valo int ret; 2746bdcd8170SKalle Valo 2747bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2748bdcd8170SKalle Valo if (!skb) 2749bdcd8170SKalle Valo return -ENOMEM; 2750bdcd8170SKalle Valo 2751bdcd8170SKalle Valo cmd = (struct wmi_rx_frame_format_cmd *) skb->data; 2752bdcd8170SKalle Valo cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; 2753bdcd8170SKalle Valo cmd->defrag_on_host = defrag_on_host ? 1 : 0; 2754bdcd8170SKalle Valo cmd->meta_ver = rx_meta_ver; 2755bdcd8170SKalle Valo 2756bdcd8170SKalle Valo /* Delete the local aggr state, on host */ 2757*0ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID, 2758bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2759bdcd8170SKalle Valo 2760bdcd8170SKalle Valo return ret; 2761bdcd8170SKalle Valo } 2762bdcd8170SKalle Valo 2763334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, 2764334234b5SVasanthakumar Thiagarajan const u8 *ie, u8 ie_len) 27656a7c9badSJouni Malinen { 27666a7c9badSJouni Malinen struct sk_buff *skb; 27676a7c9badSJouni Malinen struct wmi_set_appie_cmd *p; 27686a7c9badSJouni Malinen 27696a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 27706a7c9badSJouni Malinen if (!skb) 27716a7c9badSJouni Malinen return -ENOMEM; 27726a7c9badSJouni Malinen 27736a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " 27746a7c9badSJouni Malinen "ie_len=%u\n", mgmt_frm_type, ie_len); 27756a7c9badSJouni Malinen p = (struct wmi_set_appie_cmd *) skb->data; 27766a7c9badSJouni Malinen p->mgmt_frm_type = mgmt_frm_type; 27776a7c9badSJouni Malinen p->ie_len = ie_len; 27786a7c9badSJouni Malinen memcpy(p->ie_info, ie, ie_len); 2779334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID, 27806a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 27816a7c9badSJouni Malinen } 27826a7c9badSJouni Malinen 27836465ddcfSJouni Malinen int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) 27846465ddcfSJouni Malinen { 27856465ddcfSJouni Malinen struct sk_buff *skb; 27866465ddcfSJouni Malinen struct wmi_disable_11b_rates_cmd *cmd; 27876465ddcfSJouni Malinen 27886465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 27896465ddcfSJouni Malinen if (!skb) 27906465ddcfSJouni Malinen return -ENOMEM; 27916465ddcfSJouni Malinen 27926465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", 27936465ddcfSJouni Malinen disable); 27946465ddcfSJouni Malinen cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; 27956465ddcfSJouni Malinen cmd->disable = disable ? 1 : 0; 27966465ddcfSJouni Malinen 2797334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID, 27986465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 27996465ddcfSJouni Malinen } 28006465ddcfSJouni Malinen 2801334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur) 28026465ddcfSJouni Malinen { 28036465ddcfSJouni Malinen struct sk_buff *skb; 28046465ddcfSJouni Malinen struct wmi_remain_on_chnl_cmd *p; 28056465ddcfSJouni Malinen 28066465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 28076465ddcfSJouni Malinen if (!skb) 28086465ddcfSJouni Malinen return -ENOMEM; 28096465ddcfSJouni Malinen 28106465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", 28116465ddcfSJouni Malinen freq, dur); 28126465ddcfSJouni Malinen p = (struct wmi_remain_on_chnl_cmd *) skb->data; 28136465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 28146465ddcfSJouni Malinen p->duration = cpu_to_le32(dur); 2815334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID, 28166465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28176465ddcfSJouni Malinen } 28186465ddcfSJouni Malinen 2819334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, 2820334234b5SVasanthakumar Thiagarajan u32 wait, const u8 *data, u16 data_len) 28216465ddcfSJouni Malinen { 28226465ddcfSJouni Malinen struct sk_buff *skb; 28236465ddcfSJouni Malinen struct wmi_send_action_cmd *p; 2824a0df5db1SJouni Malinen u8 *buf; 28256465ddcfSJouni Malinen 28266465ddcfSJouni Malinen if (wait) 28276465ddcfSJouni Malinen return -EINVAL; /* Offload for wait not supported */ 28286465ddcfSJouni Malinen 2829a0df5db1SJouni Malinen buf = kmalloc(data_len, GFP_KERNEL); 2830a0df5db1SJouni Malinen if (!buf) 28316465ddcfSJouni Malinen return -ENOMEM; 28326465ddcfSJouni Malinen 2833a0df5db1SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 2834a0df5db1SJouni Malinen if (!skb) { 2835a0df5db1SJouni Malinen kfree(buf); 2836a0df5db1SJouni Malinen return -ENOMEM; 2837a0df5db1SJouni Malinen } 2838a0df5db1SJouni Malinen 2839a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 2840a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = buf; 2841a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = data_len; 2842a0df5db1SJouni Malinen 28436465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " 28446465ddcfSJouni Malinen "len=%u\n", id, freq, wait, data_len); 28456465ddcfSJouni Malinen p = (struct wmi_send_action_cmd *) skb->data; 28466465ddcfSJouni Malinen p->id = cpu_to_le32(id); 28476465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 28486465ddcfSJouni Malinen p->wait = cpu_to_le32(wait); 28496465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 28506465ddcfSJouni Malinen memcpy(p->data, data, data_len); 2851334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID, 28526465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28536465ddcfSJouni Malinen } 28546465ddcfSJouni Malinen 2855334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, 2856334234b5SVasanthakumar Thiagarajan const u8 *dst, const u8 *data, 2857334234b5SVasanthakumar Thiagarajan u16 data_len) 28586465ddcfSJouni Malinen { 28596465ddcfSJouni Malinen struct sk_buff *skb; 28606465ddcfSJouni Malinen struct wmi_p2p_probe_response_cmd *p; 28616465ddcfSJouni Malinen 28626465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 28636465ddcfSJouni Malinen if (!skb) 28646465ddcfSJouni Malinen return -ENOMEM; 28656465ddcfSJouni Malinen 28666465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM " 28676465ddcfSJouni Malinen "len=%u\n", freq, dst, data_len); 28686465ddcfSJouni Malinen p = (struct wmi_p2p_probe_response_cmd *) skb->data; 28696465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 28706465ddcfSJouni Malinen memcpy(p->destination_addr, dst, ETH_ALEN); 28716465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 28726465ddcfSJouni Malinen memcpy(p->data, data, data_len); 2873334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, 2874334234b5SVasanthakumar Thiagarajan WMI_SEND_PROBE_RESPONSE_CMDID, 28756465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28766465ddcfSJouni Malinen } 28776465ddcfSJouni Malinen 2878*0ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable) 28796465ddcfSJouni Malinen { 28806465ddcfSJouni Malinen struct sk_buff *skb; 28816465ddcfSJouni Malinen struct wmi_probe_req_report_cmd *p; 28826465ddcfSJouni Malinen 28836465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 28846465ddcfSJouni Malinen if (!skb) 28856465ddcfSJouni Malinen return -ENOMEM; 28866465ddcfSJouni Malinen 28876465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", 28886465ddcfSJouni Malinen enable); 28896465ddcfSJouni Malinen p = (struct wmi_probe_req_report_cmd *) skb->data; 28906465ddcfSJouni Malinen p->enable = enable ? 1 : 0; 2891*0ce59445SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID, 28926465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 28936465ddcfSJouni Malinen } 28946465ddcfSJouni Malinen 2895*0ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags) 28966465ddcfSJouni Malinen { 28976465ddcfSJouni Malinen struct sk_buff *skb; 28986465ddcfSJouni Malinen struct wmi_get_p2p_info *p; 28996465ddcfSJouni Malinen 29006465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 29016465ddcfSJouni Malinen if (!skb) 29026465ddcfSJouni Malinen return -ENOMEM; 29036465ddcfSJouni Malinen 29046465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", 29056465ddcfSJouni Malinen info_req_flags); 29066465ddcfSJouni Malinen p = (struct wmi_get_p2p_info *) skb->data; 29076465ddcfSJouni Malinen p->info_req_flags = cpu_to_le32(info_req_flags); 2908*0ce59445SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID, 29096465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 29106465ddcfSJouni Malinen } 29116465ddcfSJouni Malinen 2912334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx) 29136465ddcfSJouni Malinen { 29146465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); 2915334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, if_idx, 2916334234b5SVasanthakumar Thiagarajan WMI_CANCEL_REMAIN_ON_CHNL_CMDID); 29176465ddcfSJouni Malinen } 29186465ddcfSJouni Malinen 2919bdcd8170SKalle Valo static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) 2920bdcd8170SKalle Valo { 2921bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd; 2922bdcd8170SKalle Valo u32 len; 2923bdcd8170SKalle Valo u16 id; 2924bdcd8170SKalle Valo u8 *datap; 2925bdcd8170SKalle Valo int ret = 0; 2926bdcd8170SKalle Valo 2927bdcd8170SKalle Valo if (skb->len < sizeof(struct wmix_cmd_hdr)) { 2928bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 2929bdcd8170SKalle Valo return -EINVAL; 2930bdcd8170SKalle Valo } 2931bdcd8170SKalle Valo 2932bdcd8170SKalle Valo cmd = (struct wmix_cmd_hdr *) skb->data; 2933bdcd8170SKalle Valo id = le32_to_cpu(cmd->cmd_id); 2934bdcd8170SKalle Valo 2935bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmix_cmd_hdr)); 2936bdcd8170SKalle Valo 2937bdcd8170SKalle Valo datap = skb->data; 2938bdcd8170SKalle Valo len = skb->len; 2939bdcd8170SKalle Valo 2940bdcd8170SKalle Valo switch (id) { 2941bdcd8170SKalle Valo case WMIX_HB_CHALLENGE_RESP_EVENTID: 2942b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n"); 2943bdcd8170SKalle Valo break; 2944bdcd8170SKalle Valo case WMIX_DBGLOG_EVENTID: 2945b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len); 2946bdf5396bSKalle Valo ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len); 2947bdcd8170SKalle Valo break; 2948bdcd8170SKalle Valo default: 2949b9b6ee60SKalle Valo ath6kl_warn("unknown cmd id 0x%x\n", id); 2950bdcd8170SKalle Valo ret = -EINVAL; 2951bdcd8170SKalle Valo break; 2952bdcd8170SKalle Valo } 2953bdcd8170SKalle Valo 2954bdcd8170SKalle Valo return ret; 2955bdcd8170SKalle Valo } 2956bdcd8170SKalle Valo 29574b28a80dSJouni Malinen static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len) 29584b28a80dSJouni Malinen { 29594b28a80dSJouni Malinen return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len); 29604b28a80dSJouni Malinen } 29614b28a80dSJouni Malinen 2962bdcd8170SKalle Valo /* Control Path */ 2963bdcd8170SKalle Valo int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) 2964bdcd8170SKalle Valo { 2965bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd; 2966240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif; 2967bdcd8170SKalle Valo u32 len; 2968bdcd8170SKalle Valo u16 id; 2969240d2799SVasanthakumar Thiagarajan u8 if_idx; 2970bdcd8170SKalle Valo u8 *datap; 2971bdcd8170SKalle Valo int ret = 0; 2972bdcd8170SKalle Valo 2973bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 2974bdcd8170SKalle Valo return -EINVAL; 2975bdcd8170SKalle Valo 2976bdcd8170SKalle Valo if (skb->len < sizeof(struct wmi_cmd_hdr)) { 2977bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 2978bdcd8170SKalle Valo dev_kfree_skb(skb); 2979bdcd8170SKalle Valo return -EINVAL; 2980bdcd8170SKalle Valo } 2981bdcd8170SKalle Valo 2982bdcd8170SKalle Valo cmd = (struct wmi_cmd_hdr *) skb->data; 2983bdcd8170SKalle Valo id = le16_to_cpu(cmd->cmd_id); 2984240d2799SVasanthakumar Thiagarajan if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK; 2985bdcd8170SKalle Valo 2986bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmi_cmd_hdr)); 2987bdcd8170SKalle Valo 2988bdcd8170SKalle Valo datap = skb->data; 2989bdcd8170SKalle Valo len = skb->len; 2990bdcd8170SKalle Valo 2991b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len); 2992b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ", 2993ef094103SKalle Valo datap, len); 2994bdcd8170SKalle Valo 2995240d2799SVasanthakumar Thiagarajan vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx); 2996240d2799SVasanthakumar Thiagarajan if (!vif) { 2997240d2799SVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, 2998240d2799SVasanthakumar Thiagarajan "Wmi event for unavailable vif, vif_index:%d\n", 2999240d2799SVasanthakumar Thiagarajan if_idx); 3000240d2799SVasanthakumar Thiagarajan dev_kfree_skb(skb); 3001240d2799SVasanthakumar Thiagarajan return -EINVAL; 3002240d2799SVasanthakumar Thiagarajan } 3003240d2799SVasanthakumar Thiagarajan 3004bdcd8170SKalle Valo switch (id) { 3005bdcd8170SKalle Valo case WMI_GET_BITRATE_CMDID: 3006bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); 3007bdcd8170SKalle Valo ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); 3008bdcd8170SKalle Valo break; 3009bdcd8170SKalle Valo case WMI_GET_CHANNEL_LIST_CMDID: 3010bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); 3011bdcd8170SKalle Valo ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); 3012bdcd8170SKalle Valo break; 3013bdcd8170SKalle Valo case WMI_GET_TX_PWR_CMDID: 3014bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); 3015bdcd8170SKalle Valo ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); 3016bdcd8170SKalle Valo break; 3017bdcd8170SKalle Valo case WMI_READY_EVENTID: 3018bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); 3019bdcd8170SKalle Valo ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); 3020bdcd8170SKalle Valo break; 3021bdcd8170SKalle Valo case WMI_CONNECT_EVENTID: 3022bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); 3023240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_connect_event_rx(wmi, datap, len, vif); 3024bdcd8170SKalle Valo break; 3025bdcd8170SKalle Valo case WMI_DISCONNECT_EVENTID: 3026bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); 3027240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif); 3028bdcd8170SKalle Valo break; 3029bdcd8170SKalle Valo case WMI_PEER_NODE_EVENTID: 3030bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); 3031bdcd8170SKalle Valo ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); 3032bdcd8170SKalle Valo break; 3033bdcd8170SKalle Valo case WMI_TKIP_MICERR_EVENTID: 3034bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); 3035240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif); 3036bdcd8170SKalle Valo break; 3037bdcd8170SKalle Valo case WMI_BSSINFO_EVENTID: 3038bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); 3039240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif); 3040bdcd8170SKalle Valo break; 3041bdcd8170SKalle Valo case WMI_REGDOMAIN_EVENTID: 3042bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); 304306033760SVivek Natarajan ath6kl_wmi_regdomain_event(wmi, datap, len); 3044bdcd8170SKalle Valo break; 3045bdcd8170SKalle Valo case WMI_PSTREAM_TIMEOUT_EVENTID: 3046bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); 3047bdcd8170SKalle Valo ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); 3048bdcd8170SKalle Valo break; 3049bdcd8170SKalle Valo case WMI_NEIGHBOR_REPORT_EVENTID: 3050bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); 3051240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len, 3052240d2799SVasanthakumar Thiagarajan vif); 3053bdcd8170SKalle Valo break; 3054bdcd8170SKalle Valo case WMI_SCAN_COMPLETE_EVENTID: 3055bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); 3056240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif); 3057bdcd8170SKalle Valo break; 3058bdcd8170SKalle Valo case WMI_CMDERROR_EVENTID: 3059bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); 3060bdcd8170SKalle Valo ret = ath6kl_wmi_error_event_rx(wmi, datap, len); 3061bdcd8170SKalle Valo break; 3062bdcd8170SKalle Valo case WMI_REPORT_STATISTICS_EVENTID: 3063bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); 3064240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_stats_event_rx(wmi, datap, len, vif); 3065bdcd8170SKalle Valo break; 3066bdcd8170SKalle Valo case WMI_RSSI_THRESHOLD_EVENTID: 3067bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); 3068bdcd8170SKalle Valo ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); 3069bdcd8170SKalle Valo break; 3070bdcd8170SKalle Valo case WMI_ERROR_REPORT_EVENTID: 3071bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); 3072bdcd8170SKalle Valo break; 3073bdcd8170SKalle Valo case WMI_OPT_RX_FRAME_EVENTID: 3074bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); 3075f195d507SJouni Malinen /* this event has been deprecated */ 3076bdcd8170SKalle Valo break; 3077bdcd8170SKalle Valo case WMI_REPORT_ROAM_TBL_EVENTID: 3078bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); 30794b28a80dSJouni Malinen ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len); 3080bdcd8170SKalle Valo break; 3081bdcd8170SKalle Valo case WMI_EXTENSION_EVENTID: 3082bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); 3083bdcd8170SKalle Valo ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); 3084bdcd8170SKalle Valo break; 3085bdcd8170SKalle Valo case WMI_CAC_EVENTID: 3086bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); 3087240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cac_event_rx(wmi, datap, len, vif); 3088bdcd8170SKalle Valo break; 3089bdcd8170SKalle Valo case WMI_CHANNEL_CHANGE_EVENTID: 3090bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); 3091bdcd8170SKalle Valo break; 3092bdcd8170SKalle Valo case WMI_REPORT_ROAM_DATA_EVENTID: 3093bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); 3094bdcd8170SKalle Valo break; 3095003353b0SKalle Valo case WMI_TEST_EVENTID: 3096003353b0SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n"); 3097003353b0SKalle Valo ret = ath6kl_wmi_tcmd_test_report_rx(wmi, datap, len); 3098003353b0SKalle Valo break; 3099bdcd8170SKalle Valo case WMI_GET_FIXRATES_CMDID: 3100bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); 3101bdcd8170SKalle Valo ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); 3102bdcd8170SKalle Valo break; 3103bdcd8170SKalle Valo case WMI_TX_RETRY_ERR_EVENTID: 3104bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); 3105bdcd8170SKalle Valo break; 3106bdcd8170SKalle Valo case WMI_SNR_THRESHOLD_EVENTID: 3107bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); 3108bdcd8170SKalle Valo ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); 3109bdcd8170SKalle Valo break; 3110bdcd8170SKalle Valo case WMI_LQ_THRESHOLD_EVENTID: 3111bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); 3112bdcd8170SKalle Valo break; 3113bdcd8170SKalle Valo case WMI_APLIST_EVENTID: 3114bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); 3115bdcd8170SKalle Valo ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); 3116bdcd8170SKalle Valo break; 3117bdcd8170SKalle Valo case WMI_GET_KEEPALIVE_CMDID: 3118bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); 3119bdcd8170SKalle Valo ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); 3120bdcd8170SKalle Valo break; 3121bdcd8170SKalle Valo case WMI_GET_WOW_LIST_EVENTID: 3122bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); 3123bdcd8170SKalle Valo ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len); 3124bdcd8170SKalle Valo break; 3125bdcd8170SKalle Valo case WMI_GET_PMKID_LIST_EVENTID: 3126bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); 3127bdcd8170SKalle Valo ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); 3128bdcd8170SKalle Valo break; 3129bdcd8170SKalle Valo case WMI_PSPOLL_EVENTID: 3130bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); 3131240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif); 3132bdcd8170SKalle Valo break; 3133bdcd8170SKalle Valo case WMI_DTIMEXPIRY_EVENTID: 3134bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); 3135240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif); 3136bdcd8170SKalle Valo break; 3137bdcd8170SKalle Valo case WMI_SET_PARAMS_REPLY_EVENTID: 3138bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); 3139bdcd8170SKalle Valo break; 3140bdcd8170SKalle Valo case WMI_ADDBA_REQ_EVENTID: 3141bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); 3142240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif); 3143bdcd8170SKalle Valo break; 3144bdcd8170SKalle Valo case WMI_ADDBA_RESP_EVENTID: 3145bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); 3146bdcd8170SKalle Valo break; 3147bdcd8170SKalle Valo case WMI_DELBA_REQ_EVENTID: 3148bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); 3149240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif); 3150bdcd8170SKalle Valo break; 3151bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_CONFIG_EVENTID: 3152bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3153bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); 3154bdcd8170SKalle Valo break; 3155bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_STATS_EVENTID: 3156bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3157bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); 3158bdcd8170SKalle Valo break; 3159bdcd8170SKalle Valo case WMI_TX_COMPLETE_EVENTID: 3160bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); 3161bdcd8170SKalle Valo ret = ath6kl_wmi_tx_complete_event_rx(datap, len); 3162bdcd8170SKalle Valo break; 31636465ddcfSJouni Malinen case WMI_REMAIN_ON_CHNL_EVENTID: 31646465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); 3165240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif); 31666465ddcfSJouni Malinen break; 31676465ddcfSJouni Malinen case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: 31686465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, 31696465ddcfSJouni Malinen "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); 3170f9e5f05cSJouni Malinen ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, 3171240d2799SVasanthakumar Thiagarajan len, vif); 31726465ddcfSJouni Malinen break; 31736465ddcfSJouni Malinen case WMI_TX_STATUS_EVENTID: 31746465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); 3175240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif); 31766465ddcfSJouni Malinen break; 31776465ddcfSJouni Malinen case WMI_RX_PROBE_REQ_EVENTID: 31786465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); 3179240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif); 31806465ddcfSJouni Malinen break; 31816465ddcfSJouni Malinen case WMI_P2P_CAPABILITIES_EVENTID: 31826465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); 31836465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); 31846465ddcfSJouni Malinen break; 31856465ddcfSJouni Malinen case WMI_RX_ACTION_EVENTID: 31866465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); 3187240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif); 31886465ddcfSJouni Malinen break; 31896465ddcfSJouni Malinen case WMI_P2P_INFO_EVENTID: 31906465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); 31916465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_info_event_rx(datap, len); 31926465ddcfSJouni Malinen break; 3193bdcd8170SKalle Valo default: 3194bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); 3195bdcd8170SKalle Valo ret = -EINVAL; 3196bdcd8170SKalle Valo break; 3197bdcd8170SKalle Valo } 3198bdcd8170SKalle Valo 3199bdcd8170SKalle Valo dev_kfree_skb(skb); 3200bdcd8170SKalle Valo 3201bdcd8170SKalle Valo return ret; 3202bdcd8170SKalle Valo } 3203bdcd8170SKalle Valo 3204bdcd8170SKalle Valo static void ath6kl_wmi_qos_state_init(struct wmi *wmi) 3205bdcd8170SKalle Valo { 3206bdcd8170SKalle Valo if (!wmi) 3207bdcd8170SKalle Valo return; 3208bdcd8170SKalle Valo 3209bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 3210bdcd8170SKalle Valo 3211bdcd8170SKalle Valo wmi->fat_pipe_exist = 0; 3212bdcd8170SKalle Valo memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); 3213bdcd8170SKalle Valo 3214bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 3215bdcd8170SKalle Valo } 3216bdcd8170SKalle Valo 32172865785eSVasanthakumar Thiagarajan void *ath6kl_wmi_init(struct ath6kl *dev) 3218bdcd8170SKalle Valo { 3219bdcd8170SKalle Valo struct wmi *wmi; 3220bdcd8170SKalle Valo 3221bdcd8170SKalle Valo wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); 3222bdcd8170SKalle Valo if (!wmi) 3223bdcd8170SKalle Valo return NULL; 3224bdcd8170SKalle Valo 3225bdcd8170SKalle Valo spin_lock_init(&wmi->lock); 3226bdcd8170SKalle Valo 3227bdcd8170SKalle Valo wmi->parent_dev = dev; 3228bdcd8170SKalle Valo 3229bdcd8170SKalle Valo wmi->pwr_mode = REC_POWER; 3230bdcd8170SKalle Valo 3231a7f0c58bSKalle Valo ath6kl_wmi_qos_state_init(wmi); 3232bdcd8170SKalle Valo 3233bdcd8170SKalle Valo return wmi; 3234bdcd8170SKalle Valo } 3235bdcd8170SKalle Valo 3236bdcd8170SKalle Valo void ath6kl_wmi_shutdown(struct wmi *wmi) 3237bdcd8170SKalle Valo { 3238bdcd8170SKalle Valo if (!wmi) 3239bdcd8170SKalle Valo return; 3240bdcd8170SKalle Valo 3241a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 3242bdcd8170SKalle Valo kfree(wmi); 3243bdcd8170SKalle Valo } 3244