1bdcd8170SKalle Valo /* 2bdcd8170SKalle Valo * Copyright (c) 2004-2011 Atheros Communications Inc. 31b2df407SVasanthakumar Thiagarajan * Copyright (c) 2011-2012 Qualcomm Atheros, Inc. 4bdcd8170SKalle Valo * 5bdcd8170SKalle Valo * Permission to use, copy, modify, and/or distribute this software for any 6bdcd8170SKalle Valo * purpose with or without fee is hereby granted, provided that the above 7bdcd8170SKalle Valo * copyright notice and this permission notice appear in all copies. 8bdcd8170SKalle Valo * 9bdcd8170SKalle Valo * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10bdcd8170SKalle Valo * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11bdcd8170SKalle Valo * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12bdcd8170SKalle Valo * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13bdcd8170SKalle Valo * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14bdcd8170SKalle Valo * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15bdcd8170SKalle Valo * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16bdcd8170SKalle Valo */ 17bdcd8170SKalle Valo 18bdcd8170SKalle Valo #include <linux/ip.h> 191560ac7dSLuis R. Rodriguez #include <linux/in.h> 20bdcd8170SKalle Valo #include "core.h" 21bdcd8170SKalle Valo #include "debug.h" 22003353b0SKalle Valo #include "testmode.h" 2306033760SVivek Natarajan #include "../regd.h" 2406033760SVivek Natarajan #include "../regd_common.h" 25bdcd8170SKalle Valo 26240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx); 27bdcd8170SKalle Valo 28bdcd8170SKalle Valo static const s32 wmi_rate_tbl[][2] = { 29bdcd8170SKalle Valo /* {W/O SGI, with SGI} */ 30bdcd8170SKalle Valo {1000, 1000}, 31bdcd8170SKalle Valo {2000, 2000}, 32bdcd8170SKalle Valo {5500, 5500}, 33bdcd8170SKalle Valo {11000, 11000}, 34bdcd8170SKalle Valo {6000, 6000}, 35bdcd8170SKalle Valo {9000, 9000}, 36bdcd8170SKalle Valo {12000, 12000}, 37bdcd8170SKalle Valo {18000, 18000}, 38bdcd8170SKalle Valo {24000, 24000}, 39bdcd8170SKalle Valo {36000, 36000}, 40bdcd8170SKalle Valo {48000, 48000}, 41bdcd8170SKalle Valo {54000, 54000}, 42bdcd8170SKalle Valo {6500, 7200}, 43bdcd8170SKalle Valo {13000, 14400}, 44bdcd8170SKalle Valo {19500, 21700}, 45bdcd8170SKalle Valo {26000, 28900}, 46bdcd8170SKalle Valo {39000, 43300}, 47bdcd8170SKalle Valo {52000, 57800}, 48bdcd8170SKalle Valo {58500, 65000}, 49bdcd8170SKalle Valo {65000, 72200}, 50bdcd8170SKalle Valo {13500, 15000}, 51bdcd8170SKalle Valo {27000, 30000}, 52bdcd8170SKalle Valo {40500, 45000}, 53bdcd8170SKalle Valo {54000, 60000}, 54bdcd8170SKalle Valo {81000, 90000}, 55bdcd8170SKalle Valo {108000, 120000}, 56bdcd8170SKalle Valo {121500, 135000}, 57bdcd8170SKalle Valo {135000, 150000}, 58bdcd8170SKalle Valo {0, 0} 59bdcd8170SKalle Valo }; 60bdcd8170SKalle Valo 61bdcd8170SKalle Valo /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */ 62bdcd8170SKalle Valo static const u8 up_to_ac[] = { 63bdcd8170SKalle Valo WMM_AC_BE, 64bdcd8170SKalle Valo WMM_AC_BK, 65bdcd8170SKalle Valo WMM_AC_BK, 66bdcd8170SKalle Valo WMM_AC_BE, 67bdcd8170SKalle Valo WMM_AC_VI, 68bdcd8170SKalle Valo WMM_AC_VI, 69bdcd8170SKalle Valo WMM_AC_VO, 70bdcd8170SKalle Valo WMM_AC_VO, 71bdcd8170SKalle Valo }; 72bdcd8170SKalle Valo 73bdcd8170SKalle Valo void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id) 74bdcd8170SKalle Valo { 75bdcd8170SKalle Valo if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX)) 76bdcd8170SKalle Valo return; 77bdcd8170SKalle Valo 78bdcd8170SKalle Valo wmi->ep_id = ep_id; 79bdcd8170SKalle Valo } 80bdcd8170SKalle Valo 81bdcd8170SKalle Valo enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) 82bdcd8170SKalle Valo { 83bdcd8170SKalle Valo return wmi->ep_id; 84bdcd8170SKalle Valo } 85bdcd8170SKalle Valo 866765d0aaSVasanthakumar Thiagarajan struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx) 87240d2799SVasanthakumar Thiagarajan { 88990bd915SVasanthakumar Thiagarajan struct ath6kl_vif *vif, *found = NULL; 89990bd915SVasanthakumar Thiagarajan 9071f96ee6SKalle Valo if (WARN_ON(if_idx > (ar->vif_max - 1))) 91240d2799SVasanthakumar Thiagarajan return NULL; 92240d2799SVasanthakumar Thiagarajan 93990bd915SVasanthakumar Thiagarajan /* FIXME: Locking */ 9411f6e40dSVasanthakumar Thiagarajan spin_lock_bh(&ar->list_lock); 95990bd915SVasanthakumar Thiagarajan list_for_each_entry(vif, &ar->vif_list, list) { 96990bd915SVasanthakumar Thiagarajan if (vif->fw_vif_idx == if_idx) { 97990bd915SVasanthakumar Thiagarajan found = vif; 98990bd915SVasanthakumar Thiagarajan break; 99990bd915SVasanthakumar Thiagarajan } 100990bd915SVasanthakumar Thiagarajan } 10111f6e40dSVasanthakumar Thiagarajan spin_unlock_bh(&ar->list_lock); 102990bd915SVasanthakumar Thiagarajan 103990bd915SVasanthakumar Thiagarajan return found; 104240d2799SVasanthakumar Thiagarajan } 105240d2799SVasanthakumar Thiagarajan 106bdcd8170SKalle Valo /* Performs DIX to 802.3 encapsulation for transmit packets. 107bdcd8170SKalle Valo * Assumes the entire DIX header is contigous and that there is 108bdcd8170SKalle Valo * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. 109bdcd8170SKalle Valo */ 110bdcd8170SKalle Valo int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) 111bdcd8170SKalle Valo { 112bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 113bdcd8170SKalle Valo struct ethhdr *eth_hdr; 114bdcd8170SKalle Valo size_t new_len; 115bdcd8170SKalle Valo __be16 type; 116bdcd8170SKalle Valo u8 *datap; 117bdcd8170SKalle Valo u16 size; 118bdcd8170SKalle Valo 119bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 120bdcd8170SKalle Valo return -EINVAL; 121bdcd8170SKalle Valo 122bdcd8170SKalle Valo size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr); 123bdcd8170SKalle Valo if (skb_headroom(skb) < size) 124bdcd8170SKalle Valo return -ENOMEM; 125bdcd8170SKalle Valo 126bdcd8170SKalle Valo eth_hdr = (struct ethhdr *) skb->data; 127bdcd8170SKalle Valo type = eth_hdr->h_proto; 128bdcd8170SKalle Valo 129bdcd8170SKalle Valo if (!is_ethertype(be16_to_cpu(type))) { 130bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 131bdcd8170SKalle Valo "%s: pkt is already in 802.3 format\n", __func__); 132bdcd8170SKalle Valo return 0; 133bdcd8170SKalle Valo } 134bdcd8170SKalle Valo 135bdcd8170SKalle Valo new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr); 136bdcd8170SKalle Valo 137bdcd8170SKalle Valo skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr)); 138bdcd8170SKalle Valo datap = skb->data; 139bdcd8170SKalle Valo 140bdcd8170SKalle Valo eth_hdr->h_proto = cpu_to_be16(new_len); 141bdcd8170SKalle Valo 142bdcd8170SKalle Valo memcpy(datap, eth_hdr, sizeof(*eth_hdr)); 143bdcd8170SKalle Valo 144bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr)); 145bdcd8170SKalle Valo llc_hdr->dsap = 0xAA; 146bdcd8170SKalle Valo llc_hdr->ssap = 0xAA; 147bdcd8170SKalle Valo llc_hdr->cntl = 0x03; 148bdcd8170SKalle Valo llc_hdr->org_code[0] = 0x0; 149bdcd8170SKalle Valo llc_hdr->org_code[1] = 0x0; 150bdcd8170SKalle Valo llc_hdr->org_code[2] = 0x0; 151bdcd8170SKalle Valo llc_hdr->eth_type = type; 152bdcd8170SKalle Valo 153bdcd8170SKalle Valo return 0; 154bdcd8170SKalle Valo } 155bdcd8170SKalle Valo 156bdcd8170SKalle Valo static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, 157bdcd8170SKalle Valo u8 *version, void *tx_meta_info) 158bdcd8170SKalle Valo { 159bdcd8170SKalle Valo struct wmi_tx_meta_v1 *v1; 160bdcd8170SKalle Valo struct wmi_tx_meta_v2 *v2; 161bdcd8170SKalle Valo 162bdcd8170SKalle Valo if (WARN_ON(skb == NULL || version == NULL)) 163bdcd8170SKalle Valo return -EINVAL; 164bdcd8170SKalle Valo 165bdcd8170SKalle Valo switch (*version) { 166bdcd8170SKalle Valo case WMI_META_VERSION_1: 167bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 168bdcd8170SKalle Valo v1 = (struct wmi_tx_meta_v1 *) skb->data; 169bdcd8170SKalle Valo v1->pkt_id = 0; 170bdcd8170SKalle Valo v1->rate_plcy_id = 0; 171bdcd8170SKalle Valo *version = WMI_META_VERSION_1; 172bdcd8170SKalle Valo break; 173bdcd8170SKalle Valo case WMI_META_VERSION_2: 174bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 175bdcd8170SKalle Valo v2 = (struct wmi_tx_meta_v2 *) skb->data; 176bdcd8170SKalle Valo memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info, 177bdcd8170SKalle Valo sizeof(struct wmi_tx_meta_v2)); 178bdcd8170SKalle Valo break; 179bdcd8170SKalle Valo } 180bdcd8170SKalle Valo 181bdcd8170SKalle Valo return 0; 182bdcd8170SKalle Valo } 183bdcd8170SKalle Valo 184bdcd8170SKalle Valo int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, 185c1762a3fSThirumalai Pachamuthu u8 msg_type, u32 flags, 186bdcd8170SKalle Valo enum wmi_data_hdr_data_type data_type, 1876765d0aaSVasanthakumar Thiagarajan u8 meta_ver, void *tx_meta_info, u8 if_idx) 188bdcd8170SKalle Valo { 189bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 190bdcd8170SKalle Valo int ret; 191bdcd8170SKalle Valo 19271f96ee6SKalle Valo if (WARN_ON(skb == NULL || (if_idx > wmi->parent_dev->vif_max - 1))) 193bdcd8170SKalle Valo return -EINVAL; 194bdcd8170SKalle Valo 1953ce6ff50SVasanthakumar Thiagarajan if (tx_meta_info) { 196bdcd8170SKalle Valo ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info); 197bdcd8170SKalle Valo if (ret) 198bdcd8170SKalle Valo return ret; 1993ce6ff50SVasanthakumar Thiagarajan } 200bdcd8170SKalle Valo 201bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 202bdcd8170SKalle Valo 203bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *)skb->data; 204bdcd8170SKalle Valo memset(data_hdr, 0, sizeof(struct wmi_data_hdr)); 205bdcd8170SKalle Valo 206bdcd8170SKalle Valo data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; 207bdcd8170SKalle Valo data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; 208bdcd8170SKalle Valo 209c1762a3fSThirumalai Pachamuthu if (flags & WMI_DATA_HDR_FLAGS_MORE) 210c1762a3fSThirumalai Pachamuthu data_hdr->info |= WMI_DATA_HDR_MORE; 211bdcd8170SKalle Valo 212c1762a3fSThirumalai Pachamuthu if (flags & WMI_DATA_HDR_FLAGS_EOSP) 213c1762a3fSThirumalai Pachamuthu data_hdr->info3 |= cpu_to_le16(WMI_DATA_HDR_EOSP); 214c1762a3fSThirumalai Pachamuthu 215c1762a3fSThirumalai Pachamuthu data_hdr->info2 |= cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); 216c1762a3fSThirumalai Pachamuthu data_hdr->info3 |= cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); 217bdcd8170SKalle Valo 218bdcd8170SKalle Valo return 0; 219bdcd8170SKalle Valo } 220bdcd8170SKalle Valo 221c1762a3fSThirumalai Pachamuthu u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) 222bdcd8170SKalle Valo { 223bdcd8170SKalle Valo struct iphdr *ip_hdr = (struct iphdr *) pkt; 224bdcd8170SKalle Valo u8 ip_pri; 225bdcd8170SKalle Valo 226bdcd8170SKalle Valo /* 227bdcd8170SKalle Valo * Determine IPTOS priority 228bdcd8170SKalle Valo * 229bdcd8170SKalle Valo * IP-TOS - 8bits 230bdcd8170SKalle Valo * : DSCP(6-bits) ECN(2-bits) 231bdcd8170SKalle Valo * : DSCP - P2 P1 P0 X X X 232bdcd8170SKalle Valo * where (P2 P1 P0) form 802.1D 233bdcd8170SKalle Valo */ 234bdcd8170SKalle Valo ip_pri = ip_hdr->tos >> 5; 235bdcd8170SKalle Valo ip_pri &= 0x7; 236bdcd8170SKalle Valo 237bdcd8170SKalle Valo if ((layer2_pri & 0x7) > ip_pri) 238bdcd8170SKalle Valo return (u8) layer2_pri & 0x7; 239bdcd8170SKalle Valo else 240bdcd8170SKalle Valo return ip_pri; 241bdcd8170SKalle Valo } 242bdcd8170SKalle Valo 243c1762a3fSThirumalai Pachamuthu u8 ath6kl_wmi_get_traffic_class(u8 user_priority) 244c1762a3fSThirumalai Pachamuthu { 245c1762a3fSThirumalai Pachamuthu return up_to_ac[user_priority & 0x7]; 246c1762a3fSThirumalai Pachamuthu } 247c1762a3fSThirumalai Pachamuthu 248240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx, 249240d2799SVasanthakumar Thiagarajan struct sk_buff *skb, 250bdcd8170SKalle Valo u32 layer2_priority, bool wmm_enabled, 251bdcd8170SKalle Valo u8 *ac) 252bdcd8170SKalle Valo { 253bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 254bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 255bdcd8170SKalle Valo struct wmi_create_pstream_cmd cmd; 256bdcd8170SKalle Valo u32 meta_size, hdr_size; 257bdcd8170SKalle Valo u16 ip_type = IP_ETHERTYPE; 258bdcd8170SKalle Valo u8 stream_exist, usr_pri; 259bdcd8170SKalle Valo u8 traffic_class = WMM_AC_BE; 260bdcd8170SKalle Valo u8 *datap; 261bdcd8170SKalle Valo 262bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 263bdcd8170SKalle Valo return -EINVAL; 264bdcd8170SKalle Valo 265bdcd8170SKalle Valo datap = skb->data; 266bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) datap; 267bdcd8170SKalle Valo 268bdcd8170SKalle Valo meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) & 269bdcd8170SKalle Valo WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0; 270bdcd8170SKalle Valo 271bdcd8170SKalle Valo if (!wmm_enabled) { 272bdcd8170SKalle Valo /* If WMM is disabled all traffic goes as BE traffic */ 273bdcd8170SKalle Valo usr_pri = 0; 274bdcd8170SKalle Valo } else { 275bdcd8170SKalle Valo hdr_size = sizeof(struct ethhdr); 276bdcd8170SKalle Valo 277bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + 278bdcd8170SKalle Valo sizeof(struct 279bdcd8170SKalle Valo wmi_data_hdr) + 280bdcd8170SKalle Valo meta_size + hdr_size); 281bdcd8170SKalle Valo 282bdcd8170SKalle Valo if (llc_hdr->eth_type == htons(ip_type)) { 283bdcd8170SKalle Valo /* 284bdcd8170SKalle Valo * Extract the endpoint info from the TOS field 285bdcd8170SKalle Valo * in the IP header. 286bdcd8170SKalle Valo */ 287bdcd8170SKalle Valo usr_pri = 288bdcd8170SKalle Valo ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + 289bdcd8170SKalle Valo sizeof(struct ath6kl_llc_snap_hdr), 290bdcd8170SKalle Valo layer2_priority); 291bdcd8170SKalle Valo } else 292bdcd8170SKalle Valo usr_pri = layer2_priority & 0x7; 293f3740572SVivek Natarajan 294f3740572SVivek Natarajan /* 295f3740572SVivek Natarajan * Queue the EAPOL frames in the same WMM_AC_VO queue 296f3740572SVivek Natarajan * as that of management frames. 297f3740572SVivek Natarajan */ 298f3740572SVivek Natarajan if (skb->protocol == cpu_to_be16(ETH_P_PAE)) 299f3740572SVivek Natarajan usr_pri = WMI_VOICE_USER_PRIORITY; 300bdcd8170SKalle Valo } 301bdcd8170SKalle Valo 302a7f0c58bSKalle Valo /* 303a7f0c58bSKalle Valo * workaround for WMM S5 304a7f0c58bSKalle Valo * 305a7f0c58bSKalle Valo * FIXME: wmi->traffic_class is always 100 so this test doesn't 306a7f0c58bSKalle Valo * make sense 307a7f0c58bSKalle Valo */ 308bdcd8170SKalle Valo if ((wmi->traffic_class == WMM_AC_VI) && 309bdcd8170SKalle Valo ((usr_pri == 5) || (usr_pri == 4))) 310bdcd8170SKalle Valo usr_pri = 1; 311bdcd8170SKalle Valo 312bdcd8170SKalle Valo /* Convert user priority to traffic class */ 313bdcd8170SKalle Valo traffic_class = up_to_ac[usr_pri & 0x7]; 314bdcd8170SKalle Valo 315bdcd8170SKalle Valo wmi_data_hdr_set_up(data_hdr, usr_pri); 316bdcd8170SKalle Valo 317bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 318bdcd8170SKalle Valo stream_exist = wmi->fat_pipe_exist; 319bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 320bdcd8170SKalle Valo 321bdcd8170SKalle Valo if (!(stream_exist & (1 << traffic_class))) { 322bdcd8170SKalle Valo memset(&cmd, 0, sizeof(cmd)); 323bdcd8170SKalle Valo cmd.traffic_class = traffic_class; 324bdcd8170SKalle Valo cmd.user_pri = usr_pri; 325bdcd8170SKalle Valo cmd.inactivity_int = 326bdcd8170SKalle Valo cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); 327bdcd8170SKalle Valo /* Implicit streams are created with TSID 0xFF */ 328bdcd8170SKalle Valo cmd.tsid = WMI_IMPLICIT_PSTREAM; 329240d2799SVasanthakumar Thiagarajan ath6kl_wmi_create_pstream_cmd(wmi, if_idx, &cmd); 330bdcd8170SKalle Valo } 331bdcd8170SKalle Valo 332bdcd8170SKalle Valo *ac = traffic_class; 333bdcd8170SKalle Valo 334bdcd8170SKalle Valo return 0; 335bdcd8170SKalle Valo } 336bdcd8170SKalle Valo 337bdcd8170SKalle Valo int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) 338bdcd8170SKalle Valo { 339bdcd8170SKalle Valo struct ieee80211_hdr_3addr *pwh, wh; 340bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 341bdcd8170SKalle Valo struct ethhdr eth_hdr; 342bdcd8170SKalle Valo u32 hdr_size; 343bdcd8170SKalle Valo u8 *datap; 344bdcd8170SKalle Valo __le16 sub_type; 345bdcd8170SKalle Valo 346bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 347bdcd8170SKalle Valo return -EINVAL; 348bdcd8170SKalle Valo 349bdcd8170SKalle Valo datap = skb->data; 350bdcd8170SKalle Valo pwh = (struct ieee80211_hdr_3addr *) datap; 351bdcd8170SKalle Valo 352bdcd8170SKalle Valo sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); 353bdcd8170SKalle Valo 354bdcd8170SKalle Valo memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); 355bdcd8170SKalle Valo 356bdcd8170SKalle Valo /* Strip off the 802.11 header */ 357bdcd8170SKalle Valo if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { 358bdcd8170SKalle Valo hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), 359bdcd8170SKalle Valo sizeof(u32)); 360bdcd8170SKalle Valo skb_pull(skb, hdr_size); 361bdcd8170SKalle Valo } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) 362bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); 363bdcd8170SKalle Valo 364bdcd8170SKalle Valo datap = skb->data; 365bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); 366bdcd8170SKalle Valo 367c8790cbaSRaja Mani memset(ð_hdr, 0, sizeof(eth_hdr)); 368bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 369bdcd8170SKalle Valo 370bdcd8170SKalle Valo switch ((le16_to_cpu(wh.frame_control)) & 371bdcd8170SKalle Valo (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 372bdcd8170SKalle Valo case 0: 373bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 374bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 375bdcd8170SKalle Valo break; 376bdcd8170SKalle Valo case IEEE80211_FCTL_TODS: 377bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); 378bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 379bdcd8170SKalle Valo break; 380bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS: 381bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 382bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); 383bdcd8170SKalle Valo break; 384bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: 385bdcd8170SKalle Valo break; 386bdcd8170SKalle Valo } 387bdcd8170SKalle Valo 388bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 389bdcd8170SKalle Valo skb_push(skb, sizeof(eth_hdr)); 390bdcd8170SKalle Valo 391bdcd8170SKalle Valo datap = skb->data; 392bdcd8170SKalle Valo 393bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 394bdcd8170SKalle Valo 395bdcd8170SKalle Valo return 0; 396bdcd8170SKalle Valo } 397bdcd8170SKalle Valo 398bdcd8170SKalle Valo /* 399bdcd8170SKalle Valo * Performs 802.3 to DIX encapsulation for received packets. 400bdcd8170SKalle Valo * Assumes the entire 802.3 header is contigous. 401bdcd8170SKalle Valo */ 402bdcd8170SKalle Valo int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) 403bdcd8170SKalle Valo { 404bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 405bdcd8170SKalle Valo struct ethhdr eth_hdr; 406bdcd8170SKalle Valo u8 *datap; 407bdcd8170SKalle Valo 408bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 409bdcd8170SKalle Valo return -EINVAL; 410bdcd8170SKalle Valo 411bdcd8170SKalle Valo datap = skb->data; 412bdcd8170SKalle Valo 413bdcd8170SKalle Valo memcpy(ð_hdr, datap, sizeof(eth_hdr)); 414bdcd8170SKalle Valo 415bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); 416bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 417bdcd8170SKalle Valo 418bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 419bdcd8170SKalle Valo datap = skb->data; 420bdcd8170SKalle Valo 421bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 422bdcd8170SKalle Valo 423bdcd8170SKalle Valo return 0; 424bdcd8170SKalle Valo } 425bdcd8170SKalle Valo 426bdcd8170SKalle Valo static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) 427bdcd8170SKalle Valo { 428bdcd8170SKalle Valo struct tx_complete_msg_v1 *msg_v1; 429bdcd8170SKalle Valo struct wmi_tx_complete_event *evt; 430bdcd8170SKalle Valo int index; 431bdcd8170SKalle Valo u16 size; 432bdcd8170SKalle Valo 433bdcd8170SKalle Valo evt = (struct wmi_tx_complete_event *) datap; 434bdcd8170SKalle Valo 435bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", 436bdcd8170SKalle Valo evt->num_msg, evt->msg_len, evt->msg_type); 437bdcd8170SKalle Valo 438bdcd8170SKalle Valo for (index = 0; index < evt->num_msg; index++) { 439bdcd8170SKalle Valo size = sizeof(struct wmi_tx_complete_event) + 440bdcd8170SKalle Valo (index * sizeof(struct tx_complete_msg_v1)); 441bdcd8170SKalle Valo msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); 442bdcd8170SKalle Valo 443bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", 444bdcd8170SKalle Valo msg_v1->status, msg_v1->pkt_id, 445bdcd8170SKalle Valo msg_v1->rate_idx, msg_v1->ack_failures); 446bdcd8170SKalle Valo } 447bdcd8170SKalle Valo 448bdcd8170SKalle Valo return 0; 449bdcd8170SKalle Valo } 450bdcd8170SKalle Valo 451f9e5f05cSJouni Malinen static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, 452240d2799SVasanthakumar Thiagarajan int len, struct ath6kl_vif *vif) 4536465ddcfSJouni Malinen { 4546465ddcfSJouni Malinen struct wmi_remain_on_chnl_event *ev; 4556465ddcfSJouni Malinen u32 freq; 4566465ddcfSJouni Malinen u32 dur; 457f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 458f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4591052261eSJouni Malinen u32 id; 4606465ddcfSJouni Malinen 4616465ddcfSJouni Malinen if (len < sizeof(*ev)) 4626465ddcfSJouni Malinen return -EINVAL; 4636465ddcfSJouni Malinen 4646465ddcfSJouni Malinen ev = (struct wmi_remain_on_chnl_event *) datap; 4656465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4666465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4676465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", 4686465ddcfSJouni Malinen freq, dur); 469be98e3a4SVasanthakumar Thiagarajan chan = ieee80211_get_channel(ar->wiphy, freq); 470f9e5f05cSJouni Malinen if (!chan) { 471cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 472cdeb8602SKalle Valo "remain_on_chnl: Unknown channel (freq=%u)\n", 473cdeb8602SKalle Valo freq); 474f9e5f05cSJouni Malinen return -EINVAL; 475f9e5f05cSJouni Malinen } 4761052261eSJouni Malinen id = vif->last_roc_id; 47771bbc994SJohannes Berg cfg80211_ready_on_channel(&vif->wdev, id, chan, NL80211_CHAN_NO_HT, 478f9e5f05cSJouni Malinen dur, GFP_ATOMIC); 4796465ddcfSJouni Malinen 4806465ddcfSJouni Malinen return 0; 4816465ddcfSJouni Malinen } 4826465ddcfSJouni Malinen 483f9e5f05cSJouni Malinen static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, 484240d2799SVasanthakumar Thiagarajan u8 *datap, int len, 485240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 4866465ddcfSJouni Malinen { 4876465ddcfSJouni Malinen struct wmi_cancel_remain_on_chnl_event *ev; 4886465ddcfSJouni Malinen u32 freq; 4896465ddcfSJouni Malinen u32 dur; 490f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 491f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4921052261eSJouni Malinen u32 id; 4936465ddcfSJouni Malinen 4946465ddcfSJouni Malinen if (len < sizeof(*ev)) 4956465ddcfSJouni Malinen return -EINVAL; 4966465ddcfSJouni Malinen 4976465ddcfSJouni Malinen ev = (struct wmi_cancel_remain_on_chnl_event *) datap; 4986465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4996465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 500cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 501cdeb8602SKalle Valo "cancel_remain_on_chnl: freq=%u dur=%u status=%u\n", 502cdeb8602SKalle Valo freq, dur, ev->status); 503be98e3a4SVasanthakumar Thiagarajan chan = ieee80211_get_channel(ar->wiphy, freq); 504f9e5f05cSJouni Malinen if (!chan) { 505cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 506cdeb8602SKalle Valo "cancel_remain_on_chnl: Unknown channel (freq=%u)\n", 507cdeb8602SKalle Valo freq); 508f9e5f05cSJouni Malinen return -EINVAL; 509f9e5f05cSJouni Malinen } 5101052261eSJouni Malinen if (vif->last_cancel_roc_id && 5111052261eSJouni Malinen vif->last_cancel_roc_id + 1 == vif->last_roc_id) 5121052261eSJouni Malinen id = vif->last_cancel_roc_id; /* event for cancel command */ 5131052261eSJouni Malinen else 5141052261eSJouni Malinen id = vif->last_roc_id; /* timeout on uncanceled r-o-c */ 5151052261eSJouni Malinen vif->last_cancel_roc_id = 0; 51671bbc994SJohannes Berg cfg80211_remain_on_channel_expired(&vif->wdev, id, chan, 517f9e5f05cSJouni Malinen NL80211_CHAN_NO_HT, GFP_ATOMIC); 5186465ddcfSJouni Malinen 5196465ddcfSJouni Malinen return 0; 5206465ddcfSJouni Malinen } 5216465ddcfSJouni Malinen 522240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len, 523240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 5246465ddcfSJouni Malinen { 5256465ddcfSJouni Malinen struct wmi_tx_status_event *ev; 5266465ddcfSJouni Malinen u32 id; 5276465ddcfSJouni Malinen 5286465ddcfSJouni Malinen if (len < sizeof(*ev)) 5296465ddcfSJouni Malinen return -EINVAL; 5306465ddcfSJouni Malinen 5316465ddcfSJouni Malinen ev = (struct wmi_tx_status_event *) datap; 5326465ddcfSJouni Malinen id = le32_to_cpu(ev->id); 5336465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", 5346465ddcfSJouni Malinen id, ev->ack_status); 535a0df5db1SJouni Malinen if (wmi->last_mgmt_tx_frame) { 53671bbc994SJohannes Berg cfg80211_mgmt_tx_status(&vif->wdev, id, 537a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame, 538a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len, 539a0df5db1SJouni Malinen !!ev->ack_status, GFP_ATOMIC); 540a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 541a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = NULL; 542a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = 0; 543a0df5db1SJouni Malinen } 5446465ddcfSJouni Malinen 5456465ddcfSJouni Malinen return 0; 5466465ddcfSJouni Malinen } 5476465ddcfSJouni Malinen 548240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len, 549240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 5506465ddcfSJouni Malinen { 5516465ddcfSJouni Malinen struct wmi_p2p_rx_probe_req_event *ev; 552ae32c30aSJouni Malinen u32 freq; 5536465ddcfSJouni Malinen u16 dlen; 5546465ddcfSJouni Malinen 5556465ddcfSJouni Malinen if (len < sizeof(*ev)) 5566465ddcfSJouni Malinen return -EINVAL; 5576465ddcfSJouni Malinen 5586465ddcfSJouni Malinen ev = (struct wmi_p2p_rx_probe_req_event *) datap; 559ae32c30aSJouni Malinen freq = le32_to_cpu(ev->freq); 5606465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 561ae32c30aSJouni Malinen if (datap + len < ev->data + dlen) { 562cdeb8602SKalle Valo ath6kl_err("invalid wmi_p2p_rx_probe_req_event: len=%d dlen=%u\n", 563cdeb8602SKalle Valo len, dlen); 564ae32c30aSJouni Malinen return -EINVAL; 565ae32c30aSJouni Malinen } 566cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 567cdeb8602SKalle Valo "rx_probe_req: len=%u freq=%u probe_req_report=%d\n", 568cf5333d7SVasanthakumar Thiagarajan dlen, freq, vif->probe_req_report); 569ae32c30aSJouni Malinen 570cf5333d7SVasanthakumar Thiagarajan if (vif->probe_req_report || vif->nw_type == AP_NETWORK) 57171bbc994SJohannes Berg cfg80211_rx_mgmt(&vif->wdev, freq, 0, 572804483e9SJohannes Berg ev->data, dlen, GFP_ATOMIC); 5736465ddcfSJouni Malinen 5746465ddcfSJouni Malinen return 0; 5756465ddcfSJouni Malinen } 5766465ddcfSJouni Malinen 5776465ddcfSJouni Malinen static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) 5786465ddcfSJouni Malinen { 5796465ddcfSJouni Malinen struct wmi_p2p_capabilities_event *ev; 5806465ddcfSJouni Malinen u16 dlen; 5816465ddcfSJouni Malinen 5826465ddcfSJouni Malinen if (len < sizeof(*ev)) 5836465ddcfSJouni Malinen return -EINVAL; 5846465ddcfSJouni Malinen 5856465ddcfSJouni Malinen ev = (struct wmi_p2p_capabilities_event *) datap; 5866465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5876465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); 5886465ddcfSJouni Malinen 5896465ddcfSJouni Malinen return 0; 5906465ddcfSJouni Malinen } 5916465ddcfSJouni Malinen 592240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len, 593240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 5946465ddcfSJouni Malinen { 5956465ddcfSJouni Malinen struct wmi_rx_action_event *ev; 5969809d8efSJouni Malinen u32 freq; 5976465ddcfSJouni Malinen u16 dlen; 5986465ddcfSJouni Malinen 5996465ddcfSJouni Malinen if (len < sizeof(*ev)) 6006465ddcfSJouni Malinen return -EINVAL; 6016465ddcfSJouni Malinen 6026465ddcfSJouni Malinen ev = (struct wmi_rx_action_event *) datap; 6039809d8efSJouni Malinen freq = le32_to_cpu(ev->freq); 6046465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 6059809d8efSJouni Malinen if (datap + len < ev->data + dlen) { 606cdeb8602SKalle Valo ath6kl_err("invalid wmi_rx_action_event: len=%d dlen=%u\n", 607cdeb8602SKalle Valo len, dlen); 6089809d8efSJouni Malinen return -EINVAL; 6099809d8efSJouni Malinen } 6109809d8efSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); 61171bbc994SJohannes Berg cfg80211_rx_mgmt(&vif->wdev, freq, 0, 612804483e9SJohannes Berg ev->data, dlen, GFP_ATOMIC); 6136465ddcfSJouni Malinen 6146465ddcfSJouni Malinen return 0; 6156465ddcfSJouni Malinen } 6166465ddcfSJouni Malinen 6176465ddcfSJouni Malinen static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) 6186465ddcfSJouni Malinen { 6196465ddcfSJouni Malinen struct wmi_p2p_info_event *ev; 6206465ddcfSJouni Malinen u32 flags; 6216465ddcfSJouni Malinen u16 dlen; 6226465ddcfSJouni Malinen 6236465ddcfSJouni Malinen if (len < sizeof(*ev)) 6246465ddcfSJouni Malinen return -EINVAL; 6256465ddcfSJouni Malinen 6266465ddcfSJouni Malinen ev = (struct wmi_p2p_info_event *) datap; 6276465ddcfSJouni Malinen flags = le32_to_cpu(ev->info_req_flags); 6286465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 6296465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); 6306465ddcfSJouni Malinen 6316465ddcfSJouni Malinen if (flags & P2P_FLAG_CAPABILITIES_REQ) { 6326465ddcfSJouni Malinen struct wmi_p2p_capabilities *cap; 6336465ddcfSJouni Malinen if (dlen < sizeof(*cap)) 6346465ddcfSJouni Malinen return -EINVAL; 6356465ddcfSJouni Malinen cap = (struct wmi_p2p_capabilities *) ev->data; 6366465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", 6376465ddcfSJouni Malinen cap->go_power_save); 6386465ddcfSJouni Malinen } 6396465ddcfSJouni Malinen 6406465ddcfSJouni Malinen if (flags & P2P_FLAG_MACADDR_REQ) { 6416465ddcfSJouni Malinen struct wmi_p2p_macaddr *mac; 6426465ddcfSJouni Malinen if (dlen < sizeof(*mac)) 6436465ddcfSJouni Malinen return -EINVAL; 6446465ddcfSJouni Malinen mac = (struct wmi_p2p_macaddr *) ev->data; 6456465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", 6466465ddcfSJouni Malinen mac->mac_addr); 6476465ddcfSJouni Malinen } 6486465ddcfSJouni Malinen 6496465ddcfSJouni Malinen if (flags & P2P_FLAG_HMODEL_REQ) { 6506465ddcfSJouni Malinen struct wmi_p2p_hmodel *mod; 6516465ddcfSJouni Malinen if (dlen < sizeof(*mod)) 6526465ddcfSJouni Malinen return -EINVAL; 6536465ddcfSJouni Malinen mod = (struct wmi_p2p_hmodel *) ev->data; 6546465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", 6556465ddcfSJouni Malinen mod->p2p_model, 6566465ddcfSJouni Malinen mod->p2p_model ? "host" : "firmware"); 6576465ddcfSJouni Malinen } 6586465ddcfSJouni Malinen return 0; 6596465ddcfSJouni Malinen } 6606465ddcfSJouni Malinen 661bdcd8170SKalle Valo static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) 662bdcd8170SKalle Valo { 663bdcd8170SKalle Valo struct sk_buff *skb; 664bdcd8170SKalle Valo 665bdcd8170SKalle Valo skb = ath6kl_buf_alloc(size); 666bdcd8170SKalle Valo if (!skb) 667bdcd8170SKalle Valo return NULL; 668bdcd8170SKalle Valo 669bdcd8170SKalle Valo skb_put(skb, size); 670bdcd8170SKalle Valo if (size) 671bdcd8170SKalle Valo memset(skb->data, 0, size); 672bdcd8170SKalle Valo 673bdcd8170SKalle Valo return skb; 674bdcd8170SKalle Valo } 675bdcd8170SKalle Valo 676bdcd8170SKalle Valo /* Send a "simple" wmi command -- one with no arguments */ 677334234b5SVasanthakumar Thiagarajan static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx, 678334234b5SVasanthakumar Thiagarajan enum wmi_cmd_id cmd_id) 679bdcd8170SKalle Valo { 680bdcd8170SKalle Valo struct sk_buff *skb; 681bdcd8170SKalle Valo int ret; 682bdcd8170SKalle Valo 683bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(0); 684bdcd8170SKalle Valo if (!skb) 685bdcd8170SKalle Valo return -ENOMEM; 686bdcd8170SKalle Valo 687334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG); 688bdcd8170SKalle Valo 689bdcd8170SKalle Valo return ret; 690bdcd8170SKalle Valo } 691bdcd8170SKalle Valo 692bdcd8170SKalle Valo static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) 693bdcd8170SKalle Valo { 694bdcd8170SKalle Valo struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; 695bdcd8170SKalle Valo 696bdcd8170SKalle Valo if (len < sizeof(struct wmi_ready_event_2)) 697bdcd8170SKalle Valo return -EINVAL; 698bdcd8170SKalle Valo 699bdcd8170SKalle Valo ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, 700bdcd8170SKalle Valo le32_to_cpu(ev->sw_version), 701d92917e4SThomas Pedersen le32_to_cpu(ev->abi_version), ev->phy_cap); 702bdcd8170SKalle Valo 703bdcd8170SKalle Valo return 0; 704bdcd8170SKalle Valo } 705bdcd8170SKalle Valo 706e5090444SVivek Natarajan /* 707e5090444SVivek Natarajan * Mechanism to modify the roaming behavior in the firmware. The lower rssi 708e5090444SVivek Natarajan * at which the station has to roam can be passed with 709e5090444SVivek Natarajan * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level 710e5090444SVivek Natarajan * in dBm. 711e5090444SVivek Natarajan */ 712e5090444SVivek Natarajan int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) 713e5090444SVivek Natarajan { 714e5090444SVivek Natarajan struct sk_buff *skb; 715e5090444SVivek Natarajan struct roam_ctrl_cmd *cmd; 716e5090444SVivek Natarajan 717e5090444SVivek Natarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 718e5090444SVivek Natarajan if (!skb) 719e5090444SVivek Natarajan return -ENOMEM; 720e5090444SVivek Natarajan 721e5090444SVivek Natarajan cmd = (struct roam_ctrl_cmd *) skb->data; 722e5090444SVivek Natarajan 723e5090444SVivek Natarajan cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD); 724e5090444SVivek Natarajan cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi + 725e5090444SVivek Natarajan DEF_SCAN_FOR_ROAM_INTVL); 726e5090444SVivek Natarajan cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi); 727e5090444SVivek Natarajan cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; 728e5090444SVivek Natarajan cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; 729e5090444SVivek Natarajan 730334234b5SVasanthakumar Thiagarajan ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, 731334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 732e5090444SVivek Natarajan 733e5090444SVivek Natarajan return 0; 734e5090444SVivek Natarajan } 735e5090444SVivek Natarajan 7361261875fSJouni Malinen int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid) 7371261875fSJouni Malinen { 7381261875fSJouni Malinen struct sk_buff *skb; 7391261875fSJouni Malinen struct roam_ctrl_cmd *cmd; 7401261875fSJouni Malinen 7411261875fSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 7421261875fSJouni Malinen if (!skb) 7431261875fSJouni Malinen return -ENOMEM; 7441261875fSJouni Malinen 7451261875fSJouni Malinen cmd = (struct roam_ctrl_cmd *) skb->data; 7461261875fSJouni Malinen 7471261875fSJouni Malinen memcpy(cmd->info.bssid, bssid, ETH_ALEN); 7481261875fSJouni Malinen cmd->roam_ctrl = WMI_FORCE_ROAM; 7491261875fSJouni Malinen 7501261875fSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid); 751334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, 7521261875fSJouni Malinen NO_SYNC_WMIFLAG); 7531261875fSJouni Malinen } 7541261875fSJouni Malinen 755d154f32eSEtay Luz int ath6kl_wmi_ap_set_dtim_cmd(struct wmi *wmi, u8 if_idx, u32 dtim_period) 756d154f32eSEtay Luz { 757d154f32eSEtay Luz struct sk_buff *skb; 758d154f32eSEtay Luz struct set_dtim_cmd *cmd; 759d154f32eSEtay Luz 760d154f32eSEtay Luz skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 761d154f32eSEtay Luz if (!skb) 762d154f32eSEtay Luz return -ENOMEM; 763d154f32eSEtay Luz 764d154f32eSEtay Luz cmd = (struct set_dtim_cmd *) skb->data; 765d154f32eSEtay Luz 766d154f32eSEtay Luz cmd->dtim_period = cpu_to_le32(dtim_period); 767d154f32eSEtay Luz return ath6kl_wmi_cmd_send(wmi, if_idx, skb, 768d154f32eSEtay Luz WMI_AP_SET_DTIM_CMDID, NO_SYNC_WMIFLAG); 769d154f32eSEtay Luz } 770d154f32eSEtay Luz 7711261875fSJouni Malinen int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode) 7721261875fSJouni Malinen { 7731261875fSJouni Malinen struct sk_buff *skb; 7741261875fSJouni Malinen struct roam_ctrl_cmd *cmd; 7751261875fSJouni Malinen 7761261875fSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 7771261875fSJouni Malinen if (!skb) 7781261875fSJouni Malinen return -ENOMEM; 7791261875fSJouni Malinen 7801261875fSJouni Malinen cmd = (struct roam_ctrl_cmd *) skb->data; 7811261875fSJouni Malinen 7821261875fSJouni Malinen cmd->info.roam_mode = mode; 7831261875fSJouni Malinen cmd->roam_ctrl = WMI_SET_ROAM_MODE; 7841261875fSJouni Malinen 7851261875fSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode); 786334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, 7871261875fSJouni Malinen NO_SYNC_WMIFLAG); 7881261875fSJouni Malinen } 7891261875fSJouni Malinen 790240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, 791240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 792bdcd8170SKalle Valo { 793bdcd8170SKalle Valo struct wmi_connect_event *ev; 794bdcd8170SKalle Valo u8 *pie, *peie; 795bdcd8170SKalle Valo 796bdcd8170SKalle Valo if (len < sizeof(struct wmi_connect_event)) 797bdcd8170SKalle Valo return -EINVAL; 798bdcd8170SKalle Valo 799bdcd8170SKalle Valo ev = (struct wmi_connect_event *) datap; 800bdcd8170SKalle Valo 801f5938f24SVasanthakumar Thiagarajan if (vif->nw_type == AP_NETWORK) { 802572e27c0SJouni Malinen /* AP mode start/STA connected event */ 803240d2799SVasanthakumar Thiagarajan struct net_device *dev = vif->ndev; 804572e27c0SJouni Malinen if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) { 805cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 806cdeb8602SKalle Valo "%s: freq %d bssid %pM (AP started)\n", 807572e27c0SJouni Malinen __func__, le16_to_cpu(ev->u.ap_bss.ch), 808572e27c0SJouni Malinen ev->u.ap_bss.bssid); 809572e27c0SJouni Malinen ath6kl_connect_ap_mode_bss( 810240d2799SVasanthakumar Thiagarajan vif, le16_to_cpu(ev->u.ap_bss.ch)); 811572e27c0SJouni Malinen } else { 812cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 813cdeb8602SKalle Valo "%s: aid %u mac_addr %pM auth=%u keymgmt=%u cipher=%u apsd_info=%u (STA connected)\n", 814572e27c0SJouni Malinen __func__, ev->u.ap_sta.aid, 815572e27c0SJouni Malinen ev->u.ap_sta.mac_addr, 816572e27c0SJouni Malinen ev->u.ap_sta.auth, 817572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 818572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 819572e27c0SJouni Malinen ev->u.ap_sta.apsd_info); 820c1762a3fSThirumalai Pachamuthu 821572e27c0SJouni Malinen ath6kl_connect_ap_mode_sta( 822240d2799SVasanthakumar Thiagarajan vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, 823572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 824572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 825572e27c0SJouni Malinen ev->u.ap_sta.auth, ev->assoc_req_len, 826c1762a3fSThirumalai Pachamuthu ev->assoc_info + ev->beacon_ie_len, 827c1762a3fSThirumalai Pachamuthu ev->u.ap_sta.apsd_info); 828572e27c0SJouni Malinen } 829572e27c0SJouni Malinen return 0; 830572e27c0SJouni Malinen } 831572e27c0SJouni Malinen 832572e27c0SJouni Malinen /* STA/IBSS mode connection event */ 833572e27c0SJouni Malinen 834b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 835b9b6ee60SKalle Valo "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n", 836b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid, 837b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.listen_intvl), 838b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.beacon_intvl), 839b9b6ee60SKalle Valo le32_to_cpu(ev->u.sta.nw_type)); 840bdcd8170SKalle Valo 841bdcd8170SKalle Valo /* Start of assoc rsp IEs */ 842bdcd8170SKalle Valo pie = ev->assoc_info + ev->beacon_ie_len + 843bdcd8170SKalle Valo ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ 844bdcd8170SKalle Valo 845bdcd8170SKalle Valo /* End of assoc rsp IEs */ 846bdcd8170SKalle Valo peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + 847bdcd8170SKalle Valo ev->assoc_resp_len; 848bdcd8170SKalle Valo 849bdcd8170SKalle Valo while (pie < peie) { 850bdcd8170SKalle Valo switch (*pie) { 851bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 852bdcd8170SKalle Valo if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && 853bdcd8170SKalle Valo pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { 854bdcd8170SKalle Valo /* WMM OUT (00:50:F2) */ 855ddc3d77cSKalle Valo if (pie[1] > 5 && 856ddc3d77cSKalle Valo pie[6] == WMM_PARAM_OUI_SUBTYPE) 857bdcd8170SKalle Valo wmi->is_wmm_enabled = true; 858bdcd8170SKalle Valo } 859bdcd8170SKalle Valo break; 860bdcd8170SKalle Valo } 861bdcd8170SKalle Valo 862bdcd8170SKalle Valo if (wmi->is_wmm_enabled) 863bdcd8170SKalle Valo break; 864bdcd8170SKalle Valo 865bdcd8170SKalle Valo pie += pie[1] + 2; 866bdcd8170SKalle Valo } 867bdcd8170SKalle Valo 868240d2799SVasanthakumar Thiagarajan ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch), 869572e27c0SJouni Malinen ev->u.sta.bssid, 870572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.listen_intvl), 871572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.beacon_intvl), 872572e27c0SJouni Malinen le32_to_cpu(ev->u.sta.nw_type), 873bdcd8170SKalle Valo ev->beacon_ie_len, ev->assoc_req_len, 874bdcd8170SKalle Valo ev->assoc_resp_len, ev->assoc_info); 875bdcd8170SKalle Valo 876bdcd8170SKalle Valo return 0; 877bdcd8170SKalle Valo } 878bdcd8170SKalle Valo 87906033760SVivek Natarajan static struct country_code_to_enum_rd * 88006033760SVivek Natarajan ath6kl_regd_find_country(u16 countryCode) 88106033760SVivek Natarajan { 88206033760SVivek Natarajan int i; 88306033760SVivek Natarajan 88406033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 88506033760SVivek Natarajan if (allCountries[i].countryCode == countryCode) 88606033760SVivek Natarajan return &allCountries[i]; 88706033760SVivek Natarajan } 88806033760SVivek Natarajan 88906033760SVivek Natarajan return NULL; 89006033760SVivek Natarajan } 89106033760SVivek Natarajan 89206033760SVivek Natarajan static struct reg_dmn_pair_mapping * 89306033760SVivek Natarajan ath6kl_get_regpair(u16 regdmn) 89406033760SVivek Natarajan { 89506033760SVivek Natarajan int i; 89606033760SVivek Natarajan 89706033760SVivek Natarajan if (regdmn == NO_ENUMRD) 89806033760SVivek Natarajan return NULL; 89906033760SVivek Natarajan 90006033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) { 90106033760SVivek Natarajan if (regDomainPairs[i].regDmnEnum == regdmn) 90206033760SVivek Natarajan return ®DomainPairs[i]; 90306033760SVivek Natarajan } 90406033760SVivek Natarajan 90506033760SVivek Natarajan return NULL; 90606033760SVivek Natarajan } 90706033760SVivek Natarajan 90806033760SVivek Natarajan static struct country_code_to_enum_rd * 90906033760SVivek Natarajan ath6kl_regd_find_country_by_rd(u16 regdmn) 91006033760SVivek Natarajan { 91106033760SVivek Natarajan int i; 91206033760SVivek Natarajan 91306033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 91406033760SVivek Natarajan if (allCountries[i].regDmnEnum == regdmn) 91506033760SVivek Natarajan return &allCountries[i]; 91606033760SVivek Natarajan } 91706033760SVivek Natarajan 91806033760SVivek Natarajan return NULL; 91906033760SVivek Natarajan } 92006033760SVivek Natarajan 92106033760SVivek Natarajan static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) 92206033760SVivek Natarajan { 92306033760SVivek Natarajan 92406033760SVivek Natarajan struct ath6kl_wmi_regdomain *ev; 92506033760SVivek Natarajan struct country_code_to_enum_rd *country = NULL; 92606033760SVivek Natarajan struct reg_dmn_pair_mapping *regpair = NULL; 92706033760SVivek Natarajan char alpha2[2]; 92806033760SVivek Natarajan u32 reg_code; 92906033760SVivek Natarajan 93006033760SVivek Natarajan ev = (struct ath6kl_wmi_regdomain *) datap; 93106033760SVivek Natarajan reg_code = le32_to_cpu(ev->reg_code); 93206033760SVivek Natarajan 93306033760SVivek Natarajan if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) 93406033760SVivek Natarajan country = ath6kl_regd_find_country((u16) reg_code); 93506033760SVivek Natarajan else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) { 93606033760SVivek Natarajan 93706033760SVivek Natarajan regpair = ath6kl_get_regpair((u16) reg_code); 93806033760SVivek Natarajan country = ath6kl_regd_find_country_by_rd((u16) reg_code); 93943a06b34SRaja Mani if (regpair) 940b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n", 94106033760SVivek Natarajan regpair->regDmnEnum); 94243a06b34SRaja Mani else 94343a06b34SRaja Mani ath6kl_warn("Regpair not found reg_code 0x%0x\n", 94443a06b34SRaja Mani reg_code); 94506033760SVivek Natarajan } 94606033760SVivek Natarajan 947e5348a1eSVasanthakumar Thiagarajan if (country && wmi->parent_dev->wiphy_registered) { 94806033760SVivek Natarajan alpha2[0] = country->isoName[0]; 94906033760SVivek Natarajan alpha2[1] = country->isoName[1]; 95006033760SVivek Natarajan 951be98e3a4SVasanthakumar Thiagarajan regulatory_hint(wmi->parent_dev->wiphy, alpha2); 95206033760SVivek Natarajan 953b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n", 95406033760SVivek Natarajan alpha2[0], alpha2[1]); 95506033760SVivek Natarajan } 95606033760SVivek Natarajan } 95706033760SVivek Natarajan 958240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len, 959240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 960bdcd8170SKalle Valo { 961bdcd8170SKalle Valo struct wmi_disconnect_event *ev; 962bdcd8170SKalle Valo wmi->traffic_class = 100; 963bdcd8170SKalle Valo 964bdcd8170SKalle Valo if (len < sizeof(struct wmi_disconnect_event)) 965bdcd8170SKalle Valo return -EINVAL; 966bdcd8170SKalle Valo 967bdcd8170SKalle Valo ev = (struct wmi_disconnect_event *) datap; 968bdcd8170SKalle Valo 969b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 970b9b6ee60SKalle Valo "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n", 971b9b6ee60SKalle Valo le16_to_cpu(ev->proto_reason_status), ev->bssid, 972b9b6ee60SKalle Valo ev->disconn_reason, ev->assoc_resp_len); 973b9b6ee60SKalle Valo 974bdcd8170SKalle Valo wmi->is_wmm_enabled = false; 975bdcd8170SKalle Valo 976240d2799SVasanthakumar Thiagarajan ath6kl_disconnect_event(vif, ev->disconn_reason, 977bdcd8170SKalle Valo ev->bssid, ev->assoc_resp_len, ev->assoc_info, 978bdcd8170SKalle Valo le16_to_cpu(ev->proto_reason_status)); 979bdcd8170SKalle Valo 980bdcd8170SKalle Valo return 0; 981bdcd8170SKalle Valo } 982bdcd8170SKalle Valo 983bdcd8170SKalle Valo static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) 984bdcd8170SKalle Valo { 985bdcd8170SKalle Valo struct wmi_peer_node_event *ev; 986bdcd8170SKalle Valo 987bdcd8170SKalle Valo if (len < sizeof(struct wmi_peer_node_event)) 988bdcd8170SKalle Valo return -EINVAL; 989bdcd8170SKalle Valo 990bdcd8170SKalle Valo ev = (struct wmi_peer_node_event *) datap; 991bdcd8170SKalle Valo 992bdcd8170SKalle Valo if (ev->event_code == PEER_NODE_JOIN_EVENT) 993bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", 994bdcd8170SKalle Valo ev->peer_mac_addr); 995bdcd8170SKalle Valo else if (ev->event_code == PEER_NODE_LEAVE_EVENT) 996bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", 997bdcd8170SKalle Valo ev->peer_mac_addr); 998bdcd8170SKalle Valo 999bdcd8170SKalle Valo return 0; 1000bdcd8170SKalle Valo } 1001bdcd8170SKalle Valo 1002240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len, 1003240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1004bdcd8170SKalle Valo { 1005bdcd8170SKalle Valo struct wmi_tkip_micerr_event *ev; 1006bdcd8170SKalle Valo 1007bdcd8170SKalle Valo if (len < sizeof(struct wmi_tkip_micerr_event)) 1008bdcd8170SKalle Valo return -EINVAL; 1009bdcd8170SKalle Valo 1010bdcd8170SKalle Valo ev = (struct wmi_tkip_micerr_event *) datap; 1011bdcd8170SKalle Valo 1012240d2799SVasanthakumar Thiagarajan ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast); 1013bdcd8170SKalle Valo 1014bdcd8170SKalle Valo return 0; 1015bdcd8170SKalle Valo } 1016bdcd8170SKalle Valo 101710509f90SKalle Valo void ath6kl_wmi_sscan_timer(unsigned long ptr) 101810509f90SKalle Valo { 101910509f90SKalle Valo struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr; 102010509f90SKalle Valo 102110509f90SKalle Valo cfg80211_sched_scan_results(vif->ar->wiphy); 102210509f90SKalle Valo } 102310509f90SKalle Valo 1024240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len, 1025240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1026bdcd8170SKalle Valo { 102782e14f56SJouni Malinen struct wmi_bss_info_hdr2 *bih; 10281aaa8c74SJouni Malinen u8 *buf; 10291aaa8c74SJouni Malinen struct ieee80211_channel *channel; 10301aaa8c74SJouni Malinen struct ath6kl *ar = wmi->parent_dev; 10311aaa8c74SJouni Malinen struct ieee80211_mgmt *mgmt; 10321aaa8c74SJouni Malinen struct cfg80211_bss *bss; 1033bdcd8170SKalle Valo 103482e14f56SJouni Malinen if (len <= sizeof(struct wmi_bss_info_hdr2)) 1035bdcd8170SKalle Valo return -EINVAL; 1036bdcd8170SKalle Valo 103782e14f56SJouni Malinen bih = (struct wmi_bss_info_hdr2 *) datap; 103882e14f56SJouni Malinen buf = datap + sizeof(struct wmi_bss_info_hdr2); 103982e14f56SJouni Malinen len -= sizeof(struct wmi_bss_info_hdr2); 1040bdcd8170SKalle Valo 1041bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 10421aaa8c74SJouni Malinen "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" " 10431aaa8c74SJouni Malinen "frame_type=%d\n", 104482e14f56SJouni Malinen bih->ch, bih->snr, bih->snr - 95, bih->bssid, 10451aaa8c74SJouni Malinen bih->frame_type); 1046bdcd8170SKalle Valo 10471aaa8c74SJouni Malinen if (bih->frame_type != BEACON_FTYPE && 10481aaa8c74SJouni Malinen bih->frame_type != PROBERESP_FTYPE) 10491aaa8c74SJouni Malinen return 0; /* Only update BSS table for now */ 10501aaa8c74SJouni Malinen 1051551185caSJouni Malinen if (bih->frame_type == BEACON_FTYPE && 105259c98449SVasanthakumar Thiagarajan test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) { 105359c98449SVasanthakumar Thiagarajan clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); 1054240d2799SVasanthakumar Thiagarajan ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, 1055240d2799SVasanthakumar Thiagarajan NONE_BSS_FILTER, 0); 1056551185caSJouni Malinen } 1057551185caSJouni Malinen 1058be98e3a4SVasanthakumar Thiagarajan channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch)); 10591aaa8c74SJouni Malinen if (channel == NULL) 10601aaa8c74SJouni Malinen return -EINVAL; 10611aaa8c74SJouni Malinen 10621aaa8c74SJouni Malinen if (len < 8 + 2 + 2) 10631aaa8c74SJouni Malinen return -EINVAL; 1064bdcd8170SKalle Valo 1065ddc3d77cSKalle Valo if (bih->frame_type == BEACON_FTYPE && 1066ddc3d77cSKalle Valo test_bit(CONNECTED, &vif->flags) && 1067ddc3d77cSKalle Valo memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) { 106832c10874SJouni Malinen const u8 *tim; 106932c10874SJouni Malinen tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2, 107032c10874SJouni Malinen len - 8 - 2 - 2); 107132c10874SJouni Malinen if (tim && tim[1] >= 2) { 1072cf5333d7SVasanthakumar Thiagarajan vif->assoc_bss_dtim_period = tim[3]; 107359c98449SVasanthakumar Thiagarajan set_bit(DTIM_PERIOD_AVAIL, &vif->flags); 107432c10874SJouni Malinen } 107532c10874SJouni Malinen } 107632c10874SJouni Malinen 1077bdcd8170SKalle Valo /* 10781aaa8c74SJouni Malinen * In theory, use of cfg80211_inform_bss() would be more natural here 10791aaa8c74SJouni Malinen * since we do not have the full frame. However, at least for now, 10801aaa8c74SJouni Malinen * cfg80211 can only distinguish Beacon and Probe Response frames from 10811aaa8c74SJouni Malinen * each other when using cfg80211_inform_bss_frame(), so let's build a 10821aaa8c74SJouni Malinen * fake IEEE 802.11 header to be able to take benefit of this. 1083bdcd8170SKalle Valo */ 10841aaa8c74SJouni Malinen mgmt = kmalloc(24 + len, GFP_ATOMIC); 10851aaa8c74SJouni Malinen if (mgmt == NULL) 10861aaa8c74SJouni Malinen return -EINVAL; 10871aaa8c74SJouni Malinen 10881aaa8c74SJouni Malinen if (bih->frame_type == BEACON_FTYPE) { 10891aaa8c74SJouni Malinen mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 10901aaa8c74SJouni Malinen IEEE80211_STYPE_BEACON); 10911aaa8c74SJouni Malinen memset(mgmt->da, 0xff, ETH_ALEN); 10921aaa8c74SJouni Malinen } else { 1093240d2799SVasanthakumar Thiagarajan struct net_device *dev = vif->ndev; 10941aaa8c74SJouni Malinen 10951aaa8c74SJouni Malinen mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 10961aaa8c74SJouni Malinen IEEE80211_STYPE_PROBE_RESP); 10971aaa8c74SJouni Malinen memcpy(mgmt->da, dev->dev_addr, ETH_ALEN); 1098bdcd8170SKalle Valo } 10991aaa8c74SJouni Malinen mgmt->duration = cpu_to_le16(0); 11001aaa8c74SJouni Malinen memcpy(mgmt->sa, bih->bssid, ETH_ALEN); 11011aaa8c74SJouni Malinen memcpy(mgmt->bssid, bih->bssid, ETH_ALEN); 11021aaa8c74SJouni Malinen mgmt->seq_ctrl = cpu_to_le16(0); 1103bdcd8170SKalle Valo 11041aaa8c74SJouni Malinen memcpy(&mgmt->u.beacon, buf, len); 1105bdcd8170SKalle Valo 1106be98e3a4SVasanthakumar Thiagarajan bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt, 110782e14f56SJouni Malinen 24 + len, (bih->snr - 95) * 100, 110882e14f56SJouni Malinen GFP_ATOMIC); 11091aaa8c74SJouni Malinen kfree(mgmt); 11101aaa8c74SJouni Malinen if (bss == NULL) 1111bdcd8170SKalle Valo return -ENOMEM; 11121aaa8c74SJouni Malinen cfg80211_put_bss(bss); 1113bdcd8170SKalle Valo 111410509f90SKalle Valo /* 111510509f90SKalle Valo * Firmware doesn't return any event when scheduled scan has 111610509f90SKalle Valo * finished, so we need to use a timer to find out when there are 111710509f90SKalle Valo * no more results. 111810509f90SKalle Valo * 111910509f90SKalle Valo * The timer is started from the first bss info received, otherwise 112010509f90SKalle Valo * the timer would not ever fire if the scan interval is short 112110509f90SKalle Valo * enough. 112210509f90SKalle Valo */ 1123b1f47e3aSThomas Pedersen if (test_bit(SCHED_SCANNING, &vif->flags) && 112410509f90SKalle Valo !timer_pending(&vif->sched_scan_timer)) { 112510509f90SKalle Valo mod_timer(&vif->sched_scan_timer, jiffies + 112610509f90SKalle Valo msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY)); 112710509f90SKalle Valo } 112810509f90SKalle Valo 1129bdcd8170SKalle Valo return 0; 1130bdcd8170SKalle Valo } 1131bdcd8170SKalle Valo 1132bdcd8170SKalle Valo /* Inactivity timeout of a fatpipe(pstream) at the target */ 1133bdcd8170SKalle Valo static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, 1134bdcd8170SKalle Valo int len) 1135bdcd8170SKalle Valo { 1136bdcd8170SKalle Valo struct wmi_pstream_timeout_event *ev; 1137bdcd8170SKalle Valo 1138bdcd8170SKalle Valo if (len < sizeof(struct wmi_pstream_timeout_event)) 1139bdcd8170SKalle Valo return -EINVAL; 1140bdcd8170SKalle Valo 1141bdcd8170SKalle Valo ev = (struct wmi_pstream_timeout_event *) datap; 1142bdcd8170SKalle Valo 1143bdcd8170SKalle Valo /* 1144bdcd8170SKalle Valo * When the pstream (fat pipe == AC) timesout, it means there were 1145bdcd8170SKalle Valo * no thinStreams within this pstream & it got implicitly created 1146bdcd8170SKalle Valo * due to data flow on this AC. We start the inactivity timer only 1147bdcd8170SKalle Valo * for implicitly created pstream. Just reset the host state. 1148bdcd8170SKalle Valo */ 1149bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1150bdcd8170SKalle Valo wmi->stream_exist_for_ac[ev->traffic_class] = 0; 1151bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); 1152bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1153bdcd8170SKalle Valo 1154bdcd8170SKalle Valo /* Indicate inactivity to driver layer for this fatpipe (pstream) */ 1155bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); 1156bdcd8170SKalle Valo 1157bdcd8170SKalle Valo return 0; 1158bdcd8170SKalle Valo } 1159bdcd8170SKalle Valo 1160bdcd8170SKalle Valo static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) 1161bdcd8170SKalle Valo { 1162bdcd8170SKalle Valo struct wmi_bit_rate_reply *reply; 1163bdcd8170SKalle Valo s32 rate; 1164bdcd8170SKalle Valo u32 sgi, index; 1165bdcd8170SKalle Valo 1166bdcd8170SKalle Valo if (len < sizeof(struct wmi_bit_rate_reply)) 1167bdcd8170SKalle Valo return -EINVAL; 1168bdcd8170SKalle Valo 1169bdcd8170SKalle Valo reply = (struct wmi_bit_rate_reply *) datap; 1170bdcd8170SKalle Valo 1171bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); 1172bdcd8170SKalle Valo 1173bdcd8170SKalle Valo if (reply->rate_index == (s8) RATE_AUTO) { 1174bdcd8170SKalle Valo rate = RATE_AUTO; 1175bdcd8170SKalle Valo } else { 1176bdcd8170SKalle Valo index = reply->rate_index & 0x7f; 1177*d54601b9SRaja Mani if (WARN_ON_ONCE(index > (RATE_MCS_7_40 + 1))) 1178*d54601b9SRaja Mani return -EINVAL; 1179*d54601b9SRaja Mani 1180bdcd8170SKalle Valo sgi = (reply->rate_index & 0x80) ? 1 : 0; 1181bdcd8170SKalle Valo rate = wmi_rate_tbl[index][sgi]; 1182bdcd8170SKalle Valo } 1183bdcd8170SKalle Valo 1184bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1185bdcd8170SKalle Valo 1186bdcd8170SKalle Valo return 0; 1187bdcd8170SKalle Valo } 1188bdcd8170SKalle Valo 11894f34daceSThomas Pedersen static int ath6kl_wmi_test_rx(struct wmi *wmi, u8 *datap, int len) 1190003353b0SKalle Valo { 11914f34daceSThomas Pedersen ath6kl_tm_rx_event(wmi->parent_dev, datap, len); 1192003353b0SKalle Valo 1193003353b0SKalle Valo return 0; 1194003353b0SKalle Valo } 1195003353b0SKalle Valo 1196bdcd8170SKalle Valo static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) 1197bdcd8170SKalle Valo { 1198bdcd8170SKalle Valo if (len < sizeof(struct wmi_fix_rates_reply)) 1199bdcd8170SKalle Valo return -EINVAL; 1200bdcd8170SKalle Valo 1201bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1202bdcd8170SKalle Valo 1203bdcd8170SKalle Valo return 0; 1204bdcd8170SKalle Valo } 1205bdcd8170SKalle Valo 1206bdcd8170SKalle Valo static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) 1207bdcd8170SKalle Valo { 1208bdcd8170SKalle Valo if (len < sizeof(struct wmi_channel_list_reply)) 1209bdcd8170SKalle Valo return -EINVAL; 1210bdcd8170SKalle Valo 1211bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1212bdcd8170SKalle Valo 1213bdcd8170SKalle Valo return 0; 1214bdcd8170SKalle Valo } 1215bdcd8170SKalle Valo 1216bdcd8170SKalle Valo static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) 1217bdcd8170SKalle Valo { 1218bdcd8170SKalle Valo struct wmi_tx_pwr_reply *reply; 1219bdcd8170SKalle Valo 1220bdcd8170SKalle Valo if (len < sizeof(struct wmi_tx_pwr_reply)) 1221bdcd8170SKalle Valo return -EINVAL; 1222bdcd8170SKalle Valo 1223bdcd8170SKalle Valo reply = (struct wmi_tx_pwr_reply *) datap; 1224bdcd8170SKalle Valo ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); 1225bdcd8170SKalle Valo 1226bdcd8170SKalle Valo return 0; 1227bdcd8170SKalle Valo } 1228bdcd8170SKalle Valo 1229bdcd8170SKalle Valo static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) 1230bdcd8170SKalle Valo { 1231bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_keepalive_cmd)) 1232bdcd8170SKalle Valo return -EINVAL; 1233bdcd8170SKalle Valo 1234bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1235bdcd8170SKalle Valo 1236bdcd8170SKalle Valo return 0; 1237bdcd8170SKalle Valo } 1238bdcd8170SKalle Valo 1239240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len, 1240240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1241bdcd8170SKalle Valo { 1242bdcd8170SKalle Valo struct wmi_scan_complete_event *ev; 1243bdcd8170SKalle Valo 1244bdcd8170SKalle Valo ev = (struct wmi_scan_complete_event *) datap; 1245bdcd8170SKalle Valo 1246240d2799SVasanthakumar Thiagarajan ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status)); 1247bdcd8170SKalle Valo wmi->is_probe_ssid = false; 1248bdcd8170SKalle Valo 1249bdcd8170SKalle Valo return 0; 1250bdcd8170SKalle Valo } 1251bdcd8170SKalle Valo 125286512136SJouni Malinen static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap, 1253240d2799SVasanthakumar Thiagarajan int len, struct ath6kl_vif *vif) 125486512136SJouni Malinen { 125586512136SJouni Malinen struct wmi_neighbor_report_event *ev; 125686512136SJouni Malinen u8 i; 125786512136SJouni Malinen 125886512136SJouni Malinen if (len < sizeof(*ev)) 125986512136SJouni Malinen return -EINVAL; 126086512136SJouni Malinen ev = (struct wmi_neighbor_report_event *) datap; 126186512136SJouni Malinen if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info) 126286512136SJouni Malinen > len) { 1263cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1264cdeb8602SKalle Valo "truncated neighbor event (num=%d len=%d)\n", 1265cdeb8602SKalle Valo ev->num_neighbors, len); 126686512136SJouni Malinen return -EINVAL; 126786512136SJouni Malinen } 126886512136SJouni Malinen for (i = 0; i < ev->num_neighbors; i++) { 126986512136SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n", 127086512136SJouni Malinen i + 1, ev->num_neighbors, ev->neighbor[i].bssid, 127186512136SJouni Malinen ev->neighbor[i].bss_flags); 1272240d2799SVasanthakumar Thiagarajan cfg80211_pmksa_candidate_notify(vif->ndev, i, 127386512136SJouni Malinen ev->neighbor[i].bssid, 127486512136SJouni Malinen !!(ev->neighbor[i].bss_flags & 127586512136SJouni Malinen WMI_PREAUTH_CAPABLE_BSS), 127686512136SJouni Malinen GFP_ATOMIC); 127786512136SJouni Malinen } 127886512136SJouni Malinen 127986512136SJouni Malinen return 0; 128086512136SJouni Malinen } 128186512136SJouni Malinen 1282bdcd8170SKalle Valo /* 1283bdcd8170SKalle Valo * Target is reporting a programming error. This is for 1284bdcd8170SKalle Valo * developer aid only. Target only checks a few common violations 1285bdcd8170SKalle Valo * and it is responsibility of host to do all error checking. 1286bdcd8170SKalle Valo * Behavior of target after wmi error event is undefined. 1287bdcd8170SKalle Valo * A reset is recommended. 1288bdcd8170SKalle Valo */ 1289bdcd8170SKalle Valo static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) 1290bdcd8170SKalle Valo { 1291bdcd8170SKalle Valo const char *type = "unknown error"; 1292bdcd8170SKalle Valo struct wmi_cmd_error_event *ev; 1293bdcd8170SKalle Valo ev = (struct wmi_cmd_error_event *) datap; 1294bdcd8170SKalle Valo 1295bdcd8170SKalle Valo switch (ev->err_code) { 1296bdcd8170SKalle Valo case INVALID_PARAM: 1297bdcd8170SKalle Valo type = "invalid parameter"; 1298bdcd8170SKalle Valo break; 1299bdcd8170SKalle Valo case ILLEGAL_STATE: 1300bdcd8170SKalle Valo type = "invalid state"; 1301bdcd8170SKalle Valo break; 1302bdcd8170SKalle Valo case INTERNAL_ERROR: 1303bdcd8170SKalle Valo type = "internal error"; 1304bdcd8170SKalle Valo break; 1305bdcd8170SKalle Valo } 1306bdcd8170SKalle Valo 1307bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", 1308bdcd8170SKalle Valo ev->cmd_id, type); 1309bdcd8170SKalle Valo 1310bdcd8170SKalle Valo return 0; 1311bdcd8170SKalle Valo } 1312bdcd8170SKalle Valo 1313240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len, 1314240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1315bdcd8170SKalle Valo { 1316240d2799SVasanthakumar Thiagarajan ath6kl_tgt_stats_event(vif, datap, len); 1317bdcd8170SKalle Valo 1318bdcd8170SKalle Valo return 0; 1319bdcd8170SKalle Valo } 1320bdcd8170SKalle Valo 1321bdcd8170SKalle Valo static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, 1322bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1323bdcd8170SKalle Valo u32 size) 1324bdcd8170SKalle Valo { 1325bdcd8170SKalle Valo u32 index; 1326bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; 1327bdcd8170SKalle Valo 1328bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1329bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1330bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[index]) { 1331bdcd8170SKalle Valo threshold = (u8) sq_thresh->upper_threshold[index]; 1332bdcd8170SKalle Valo break; 1333bdcd8170SKalle Valo } 1334bdcd8170SKalle Valo } 1335bdcd8170SKalle Valo 1336bdcd8170SKalle Valo return threshold; 1337bdcd8170SKalle Valo } 1338bdcd8170SKalle Valo 1339bdcd8170SKalle Valo static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, 1340bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1341bdcd8170SKalle Valo u32 size) 1342bdcd8170SKalle Valo { 1343bdcd8170SKalle Valo u32 index; 1344bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; 1345bdcd8170SKalle Valo 1346bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1347bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1348bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[index]) { 1349bdcd8170SKalle Valo threshold = (u8) sq_thresh->lower_threshold[index]; 1350bdcd8170SKalle Valo break; 1351bdcd8170SKalle Valo } 1352bdcd8170SKalle Valo } 1353bdcd8170SKalle Valo 1354bdcd8170SKalle Valo return threshold; 1355bdcd8170SKalle Valo } 1356bdcd8170SKalle Valo 1357bdcd8170SKalle Valo static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, 1358bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *rssi_cmd) 1359bdcd8170SKalle Valo { 1360bdcd8170SKalle Valo struct sk_buff *skb; 1361bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *cmd; 1362bdcd8170SKalle Valo 1363bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1364bdcd8170SKalle Valo if (!skb) 1365bdcd8170SKalle Valo return -ENOMEM; 1366bdcd8170SKalle Valo 1367bdcd8170SKalle Valo cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; 1368bdcd8170SKalle Valo memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); 1369bdcd8170SKalle Valo 1370334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, 1371bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1372bdcd8170SKalle Valo } 1373bdcd8170SKalle Valo 1374bdcd8170SKalle Valo static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, 1375bdcd8170SKalle Valo int len) 1376bdcd8170SKalle Valo { 1377bdcd8170SKalle Valo struct wmi_rssi_threshold_event *reply; 1378bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd cmd; 1379bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1380bdcd8170SKalle Valo enum wmi_rssi_threshold_val new_threshold; 1381bdcd8170SKalle Valo u8 upper_rssi_threshold, lower_rssi_threshold; 1382bdcd8170SKalle Valo s16 rssi; 1383bdcd8170SKalle Valo int ret; 1384bdcd8170SKalle Valo 1385bdcd8170SKalle Valo if (len < sizeof(struct wmi_rssi_threshold_event)) 1386bdcd8170SKalle Valo return -EINVAL; 1387bdcd8170SKalle Valo 1388bdcd8170SKalle Valo reply = (struct wmi_rssi_threshold_event *) datap; 1389bdcd8170SKalle Valo new_threshold = (enum wmi_rssi_threshold_val) reply->range; 1390bdcd8170SKalle Valo rssi = a_sle16_to_cpu(reply->rssi); 1391bdcd8170SKalle Valo 1392bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; 1393bdcd8170SKalle Valo 1394bdcd8170SKalle Valo /* 1395bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1396bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1397bdcd8170SKalle Valo * quality reported by the target 1398bdcd8170SKalle Valo */ 1399bdcd8170SKalle Valo if (new_threshold) { 1400bdcd8170SKalle Valo /* Upper threshold breached */ 1401bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[0]) { 1402bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1403bdcd8170SKalle Valo "spurious upper rssi threshold event: %d\n", 1404bdcd8170SKalle Valo rssi); 1405bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[1]) && 1406bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[0])) { 1407bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; 1408bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[2]) && 1409bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[1])) { 1410bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; 1411bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[3]) && 1412bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[2])) { 1413bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; 1414bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[4]) && 1415bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[3])) { 1416bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; 1417bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[5]) && 1418bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[4])) { 1419bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; 1420bdcd8170SKalle Valo } else if (rssi >= sq_thresh->upper_threshold[5]) { 1421bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; 1422bdcd8170SKalle Valo } 1423bdcd8170SKalle Valo } else { 1424bdcd8170SKalle Valo /* Lower threshold breached */ 1425bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[0]) { 1426bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1427bdcd8170SKalle Valo "spurious lower rssi threshold event: %d %d\n", 1428bdcd8170SKalle Valo rssi, sq_thresh->lower_threshold[0]); 1429bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[1]) && 1430bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[0])) { 1431bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_BELOW; 1432bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[2]) && 1433bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[1])) { 1434bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_BELOW; 1435bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[3]) && 1436bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[2])) { 1437bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_BELOW; 1438bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[4]) && 1439bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[3])) { 1440bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_BELOW; 1441bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[5]) && 1442bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[4])) { 1443bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_BELOW; 1444bdcd8170SKalle Valo } else if (rssi <= sq_thresh->lower_threshold[5]) { 1445bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_BELOW; 1446bdcd8170SKalle Valo } 1447bdcd8170SKalle Valo } 1448bdcd8170SKalle Valo 1449bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1450bdcd8170SKalle Valo lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, 1451bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1452bdcd8170SKalle Valo upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, 1453bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1454bdcd8170SKalle Valo 1455bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1456bdcd8170SKalle Valo cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); 1457bdcd8170SKalle Valo cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); 1458bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1459bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1460bdcd8170SKalle Valo 1461bdcd8170SKalle Valo ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); 1462bdcd8170SKalle Valo if (ret) { 1463bdcd8170SKalle Valo ath6kl_err("unable to configure rssi thresholds\n"); 1464bdcd8170SKalle Valo return -EIO; 1465bdcd8170SKalle Valo } 1466bdcd8170SKalle Valo 1467bdcd8170SKalle Valo return 0; 1468bdcd8170SKalle Valo } 1469bdcd8170SKalle Valo 1470240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len, 1471240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1472bdcd8170SKalle Valo { 1473bdcd8170SKalle Valo struct wmi_cac_event *reply; 1474bdcd8170SKalle Valo struct ieee80211_tspec_ie *ts; 1475bdcd8170SKalle Valo u16 active_tsids, tsinfo; 1476bdcd8170SKalle Valo u8 tsid, index; 1477bdcd8170SKalle Valo u8 ts_id; 1478bdcd8170SKalle Valo 1479bdcd8170SKalle Valo if (len < sizeof(struct wmi_cac_event)) 1480bdcd8170SKalle Valo return -EINVAL; 1481bdcd8170SKalle Valo 1482bdcd8170SKalle Valo reply = (struct wmi_cac_event *) datap; 1483bdcd8170SKalle Valo 1484bdcd8170SKalle Valo if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && 1485bdcd8170SKalle Valo (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { 1486bdcd8170SKalle Valo 1487bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1488bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1489bdcd8170SKalle Valo tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1490bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK; 1491bdcd8170SKalle Valo 1492240d2799SVasanthakumar Thiagarajan ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, 1493240d2799SVasanthakumar Thiagarajan reply->ac, tsid); 1494bdcd8170SKalle Valo } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { 1495bdcd8170SKalle Valo /* 1496bdcd8170SKalle Valo * Following assumes that there is only one outstanding 1497bdcd8170SKalle Valo * ADDTS request when this event is received 1498bdcd8170SKalle Valo */ 1499bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1500bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1501bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1502bdcd8170SKalle Valo 1503bdcd8170SKalle Valo for (index = 0; index < sizeof(active_tsids) * 8; index++) { 1504bdcd8170SKalle Valo if ((active_tsids >> index) & 1) 1505bdcd8170SKalle Valo break; 1506bdcd8170SKalle Valo } 1507bdcd8170SKalle Valo if (index < (sizeof(active_tsids) * 8)) 1508240d2799SVasanthakumar Thiagarajan ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, 1509240d2799SVasanthakumar Thiagarajan reply->ac, index); 1510bdcd8170SKalle Valo } 1511bdcd8170SKalle Valo 1512bdcd8170SKalle Valo /* 1513bdcd8170SKalle Valo * Clear active tsids and Add missing handling 1514bdcd8170SKalle Valo * for delete qos stream from AP 1515bdcd8170SKalle Valo */ 1516bdcd8170SKalle Valo else if (reply->cac_indication == CAC_INDICATION_DELETE) { 1517bdcd8170SKalle Valo 1518bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1519bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1520bdcd8170SKalle Valo ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1521bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK); 1522bdcd8170SKalle Valo 1523bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1524bdcd8170SKalle Valo wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); 1525bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1526bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1527bdcd8170SKalle Valo 1528bdcd8170SKalle Valo /* Indicate stream inactivity to driver layer only if all tsids 1529bdcd8170SKalle Valo * within this AC are deleted. 1530bdcd8170SKalle Valo */ 1531bdcd8170SKalle Valo if (!active_tsids) { 1532bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, 1533bdcd8170SKalle Valo false); 1534bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << reply->ac); 1535bdcd8170SKalle Valo } 1536bdcd8170SKalle Valo } 1537bdcd8170SKalle Valo 1538bdcd8170SKalle Valo return 0; 1539bdcd8170SKalle Valo } 1540bdcd8170SKalle Valo 1541279b2862SThomas Pedersen static int ath6kl_wmi_txe_notify_event_rx(struct wmi *wmi, u8 *datap, int len, 1542279b2862SThomas Pedersen struct ath6kl_vif *vif) 1543279b2862SThomas Pedersen { 1544279b2862SThomas Pedersen struct wmi_txe_notify_event *ev; 1545279b2862SThomas Pedersen u32 rate, pkts; 1546279b2862SThomas Pedersen 1547279b2862SThomas Pedersen if (len < sizeof(*ev)) 1548279b2862SThomas Pedersen return -EINVAL; 1549279b2862SThomas Pedersen 1550279b2862SThomas Pedersen if (vif->sme_state != SME_CONNECTED) 1551279b2862SThomas Pedersen return -ENOTCONN; 1552279b2862SThomas Pedersen 1553279b2862SThomas Pedersen ev = (struct wmi_txe_notify_event *) datap; 1554279b2862SThomas Pedersen rate = le32_to_cpu(ev->rate); 1555279b2862SThomas Pedersen pkts = le32_to_cpu(ev->pkts); 1556279b2862SThomas Pedersen 1557279b2862SThomas Pedersen ath6kl_dbg(ATH6KL_DBG_WMI, "TXE notify event: peer %pM rate %d% pkts %d intvl %ds\n", 1558279b2862SThomas Pedersen vif->bssid, rate, pkts, vif->txe_intvl); 1559279b2862SThomas Pedersen 1560279b2862SThomas Pedersen cfg80211_cqm_txe_notify(vif->ndev, vif->bssid, pkts, 1561279b2862SThomas Pedersen rate, vif->txe_intvl, GFP_KERNEL); 1562279b2862SThomas Pedersen 1563279b2862SThomas Pedersen return 0; 1564279b2862SThomas Pedersen } 1565279b2862SThomas Pedersen 1566279b2862SThomas Pedersen int ath6kl_wmi_set_txe_notify(struct wmi *wmi, u8 idx, 1567279b2862SThomas Pedersen u32 rate, u32 pkts, u32 intvl) 1568279b2862SThomas Pedersen { 1569279b2862SThomas Pedersen struct sk_buff *skb; 1570279b2862SThomas Pedersen struct wmi_txe_notify_cmd *cmd; 1571279b2862SThomas Pedersen 1572279b2862SThomas Pedersen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1573279b2862SThomas Pedersen if (!skb) 1574279b2862SThomas Pedersen return -ENOMEM; 1575279b2862SThomas Pedersen 1576279b2862SThomas Pedersen cmd = (struct wmi_txe_notify_cmd *) skb->data; 1577279b2862SThomas Pedersen cmd->rate = cpu_to_le32(rate); 1578279b2862SThomas Pedersen cmd->pkts = cpu_to_le32(pkts); 1579279b2862SThomas Pedersen cmd->intvl = cpu_to_le32(intvl); 1580279b2862SThomas Pedersen 1581279b2862SThomas Pedersen return ath6kl_wmi_cmd_send(wmi, idx, skb, WMI_SET_TXE_NOTIFY_CMDID, 1582279b2862SThomas Pedersen NO_SYNC_WMIFLAG); 1583279b2862SThomas Pedersen } 1584279b2862SThomas Pedersen 158585b20fc2SThomas Pedersen int ath6kl_wmi_set_rssi_filter_cmd(struct wmi *wmi, u8 if_idx, s8 rssi) 158685b20fc2SThomas Pedersen { 158785b20fc2SThomas Pedersen struct sk_buff *skb; 158885b20fc2SThomas Pedersen struct wmi_set_rssi_filter_cmd *cmd; 158985b20fc2SThomas Pedersen int ret; 159085b20fc2SThomas Pedersen 159185b20fc2SThomas Pedersen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 159285b20fc2SThomas Pedersen if (!skb) 159385b20fc2SThomas Pedersen return -ENOMEM; 159485b20fc2SThomas Pedersen 159585b20fc2SThomas Pedersen cmd = (struct wmi_set_rssi_filter_cmd *) skb->data; 159685b20fc2SThomas Pedersen cmd->rssi = rssi; 159785b20fc2SThomas Pedersen 159885b20fc2SThomas Pedersen ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_RSSI_FILTER_CMDID, 159985b20fc2SThomas Pedersen NO_SYNC_WMIFLAG); 160085b20fc2SThomas Pedersen return ret; 160185b20fc2SThomas Pedersen } 160285b20fc2SThomas Pedersen 1603bdcd8170SKalle Valo static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, 1604bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *snr_cmd) 1605bdcd8170SKalle Valo { 1606bdcd8170SKalle Valo struct sk_buff *skb; 1607bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *cmd; 1608bdcd8170SKalle Valo 1609bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1610bdcd8170SKalle Valo if (!skb) 1611bdcd8170SKalle Valo return -ENOMEM; 1612bdcd8170SKalle Valo 1613bdcd8170SKalle Valo cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; 1614bdcd8170SKalle Valo memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); 1615bdcd8170SKalle Valo 1616334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, 1617bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1618bdcd8170SKalle Valo } 1619bdcd8170SKalle Valo 1620bdcd8170SKalle Valo static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, 1621bdcd8170SKalle Valo int len) 1622bdcd8170SKalle Valo { 1623bdcd8170SKalle Valo struct wmi_snr_threshold_event *reply; 1624bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1625bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd cmd; 1626bdcd8170SKalle Valo enum wmi_snr_threshold_val new_threshold; 1627bdcd8170SKalle Valo u8 upper_snr_threshold, lower_snr_threshold; 1628bdcd8170SKalle Valo s16 snr; 1629bdcd8170SKalle Valo int ret; 1630bdcd8170SKalle Valo 1631bdcd8170SKalle Valo if (len < sizeof(struct wmi_snr_threshold_event)) 1632bdcd8170SKalle Valo return -EINVAL; 1633bdcd8170SKalle Valo 1634bdcd8170SKalle Valo reply = (struct wmi_snr_threshold_event *) datap; 1635bdcd8170SKalle Valo 1636bdcd8170SKalle Valo new_threshold = (enum wmi_snr_threshold_val) reply->range; 1637bdcd8170SKalle Valo snr = reply->snr; 1638bdcd8170SKalle Valo 1639bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; 1640bdcd8170SKalle Valo 1641bdcd8170SKalle Valo /* 1642bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1643bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1644bdcd8170SKalle Valo * quality reported by the target. 1645bdcd8170SKalle Valo */ 1646bdcd8170SKalle Valo if (new_threshold) { 1647bdcd8170SKalle Valo /* Upper threshold breached */ 1648bdcd8170SKalle Valo if (snr < sq_thresh->upper_threshold[0]) { 1649bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1650bdcd8170SKalle Valo "spurious upper snr threshold event: %d\n", 1651bdcd8170SKalle Valo snr); 1652bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[1]) && 1653bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[0])) { 1654bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_ABOVE; 1655bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[2]) && 1656bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[1])) { 1657bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_ABOVE; 1658bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[3]) && 1659bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[2])) { 1660bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_ABOVE; 1661bdcd8170SKalle Valo } else if (snr >= sq_thresh->upper_threshold[3]) { 1662bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_ABOVE; 1663bdcd8170SKalle Valo } 1664bdcd8170SKalle Valo } else { 1665bdcd8170SKalle Valo /* Lower threshold breached */ 1666bdcd8170SKalle Valo if (snr > sq_thresh->lower_threshold[0]) { 1667bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1668bdcd8170SKalle Valo "spurious lower snr threshold event: %d\n", 1669bdcd8170SKalle Valo sq_thresh->lower_threshold[0]); 1670bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[1]) && 1671bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[0])) { 1672bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_BELOW; 1673bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[2]) && 1674bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[1])) { 1675bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_BELOW; 1676bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[3]) && 1677bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[2])) { 1678bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_BELOW; 1679bdcd8170SKalle Valo } else if (snr <= sq_thresh->lower_threshold[3]) { 1680bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_BELOW; 1681bdcd8170SKalle Valo } 1682bdcd8170SKalle Valo } 1683bdcd8170SKalle Valo 1684bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1685bdcd8170SKalle Valo lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, 1686bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1687bdcd8170SKalle Valo upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, 1688bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1689bdcd8170SKalle Valo 1690bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1691bdcd8170SKalle Valo cmd.thresh_above1_val = upper_snr_threshold; 1692bdcd8170SKalle Valo cmd.thresh_below1_val = lower_snr_threshold; 1693bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1694bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1695bdcd8170SKalle Valo 1696bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1697bdcd8170SKalle Valo "snr: %d, threshold: %d, lower: %d, upper: %d\n", 1698bdcd8170SKalle Valo snr, new_threshold, 1699bdcd8170SKalle Valo lower_snr_threshold, upper_snr_threshold); 1700bdcd8170SKalle Valo 1701bdcd8170SKalle Valo ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); 1702bdcd8170SKalle Valo if (ret) { 1703bdcd8170SKalle Valo ath6kl_err("unable to configure snr threshold\n"); 1704bdcd8170SKalle Valo return -EIO; 1705bdcd8170SKalle Valo } 1706bdcd8170SKalle Valo 1707bdcd8170SKalle Valo return 0; 1708bdcd8170SKalle Valo } 1709bdcd8170SKalle Valo 1710bdcd8170SKalle Valo static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) 1711bdcd8170SKalle Valo { 1712bdcd8170SKalle Valo u16 ap_info_entry_size; 1713bdcd8170SKalle Valo struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; 1714bdcd8170SKalle Valo struct wmi_ap_info_v1 *ap_info_v1; 1715bdcd8170SKalle Valo u8 index; 1716bdcd8170SKalle Valo 1717bdcd8170SKalle Valo if (len < sizeof(struct wmi_aplist_event) || 1718bdcd8170SKalle Valo ev->ap_list_ver != APLIST_VER1) 1719bdcd8170SKalle Valo return -EINVAL; 1720bdcd8170SKalle Valo 1721bdcd8170SKalle Valo ap_info_entry_size = sizeof(struct wmi_ap_info_v1); 1722bdcd8170SKalle Valo ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; 1723bdcd8170SKalle Valo 1724bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1725bdcd8170SKalle Valo "number of APs in aplist event: %d\n", ev->num_ap); 1726bdcd8170SKalle Valo 1727bdcd8170SKalle Valo if (len < (int) (sizeof(struct wmi_aplist_event) + 1728bdcd8170SKalle Valo (ev->num_ap - 1) * ap_info_entry_size)) 1729bdcd8170SKalle Valo return -EINVAL; 1730bdcd8170SKalle Valo 1731bdcd8170SKalle Valo /* AP list version 1 contents */ 1732bdcd8170SKalle Valo for (index = 0; index < ev->num_ap; index++) { 1733bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", 1734bdcd8170SKalle Valo index, ap_info_v1->bssid, ap_info_v1->channel); 1735bdcd8170SKalle Valo ap_info_v1++; 1736bdcd8170SKalle Valo } 1737bdcd8170SKalle Valo 1738bdcd8170SKalle Valo return 0; 1739bdcd8170SKalle Valo } 1740bdcd8170SKalle Valo 1741334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, 1742bdcd8170SKalle Valo enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) 1743bdcd8170SKalle Valo { 1744bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd_hdr; 1745bdcd8170SKalle Valo enum htc_endpoint_id ep_id = wmi->ep_id; 1746bdcd8170SKalle Valo int ret; 1747334234b5SVasanthakumar Thiagarajan u16 info1; 1748bdcd8170SKalle Valo 17490616dc1fSVasanthakumar Thiagarajan if (WARN_ON(skb == NULL || 17500616dc1fSVasanthakumar Thiagarajan (if_idx > (wmi->parent_dev->vif_max - 1)))) { 17510616dc1fSVasanthakumar Thiagarajan dev_kfree_skb(skb); 1752bdcd8170SKalle Valo return -EINVAL; 17530616dc1fSVasanthakumar Thiagarajan } 1754bdcd8170SKalle Valo 1755b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n", 1756b9b6ee60SKalle Valo cmd_id, skb->len, sync_flag); 1757b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ", 1758b9b6ee60SKalle Valo skb->data, skb->len); 1759b9b6ee60SKalle Valo 1760bdcd8170SKalle Valo if (sync_flag >= END_WMIFLAG) { 1761bdcd8170SKalle Valo dev_kfree_skb(skb); 1762bdcd8170SKalle Valo return -EINVAL; 1763bdcd8170SKalle Valo } 1764bdcd8170SKalle Valo 1765bdcd8170SKalle Valo if ((sync_flag == SYNC_BEFORE_WMIFLAG) || 1766bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1767bdcd8170SKalle Valo /* 1768bdcd8170SKalle Valo * Make sure all data currently queued is transmitted before 1769bdcd8170SKalle Valo * the cmd execution. Establish a new sync point. 1770bdcd8170SKalle Valo */ 1771240d2799SVasanthakumar Thiagarajan ath6kl_wmi_sync_point(wmi, if_idx); 1772bdcd8170SKalle Valo } 1773bdcd8170SKalle Valo 1774bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_cmd_hdr)); 1775bdcd8170SKalle Valo 1776bdcd8170SKalle Valo cmd_hdr = (struct wmi_cmd_hdr *) skb->data; 1777bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le16(cmd_id); 1778334234b5SVasanthakumar Thiagarajan info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK; 1779334234b5SVasanthakumar Thiagarajan cmd_hdr->info1 = cpu_to_le16(info1); 1780bdcd8170SKalle Valo 1781bdcd8170SKalle Valo /* Only for OPT_TX_CMD, use BE endpoint. */ 1782bdcd8170SKalle Valo if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { 1783bdcd8170SKalle Valo ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, 17846765d0aaSVasanthakumar Thiagarajan false, false, 0, NULL, if_idx); 1785bdcd8170SKalle Valo if (ret) { 1786bdcd8170SKalle Valo dev_kfree_skb(skb); 1787bdcd8170SKalle Valo return ret; 1788bdcd8170SKalle Valo } 1789bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); 1790bdcd8170SKalle Valo } 1791bdcd8170SKalle Valo 1792bdcd8170SKalle Valo ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 1793bdcd8170SKalle Valo 1794bdcd8170SKalle Valo if ((sync_flag == SYNC_AFTER_WMIFLAG) || 1795bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1796bdcd8170SKalle Valo /* 1797bdcd8170SKalle Valo * Make sure all new data queued waits for the command to 1798bdcd8170SKalle Valo * execute. Establish a new sync point. 1799bdcd8170SKalle Valo */ 1800240d2799SVasanthakumar Thiagarajan ath6kl_wmi_sync_point(wmi, if_idx); 1801bdcd8170SKalle Valo } 1802bdcd8170SKalle Valo 1803bdcd8170SKalle Valo return 0; 1804bdcd8170SKalle Valo } 1805bdcd8170SKalle Valo 1806334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx, 1807334234b5SVasanthakumar Thiagarajan enum network_type nw_type, 1808bdcd8170SKalle Valo enum dot11_auth_mode dot11_auth_mode, 1809bdcd8170SKalle Valo enum auth_mode auth_mode, 1810bdcd8170SKalle Valo enum crypto_type pairwise_crypto, 1811bdcd8170SKalle Valo u8 pairwise_crypto_len, 1812bdcd8170SKalle Valo enum crypto_type group_crypto, 1813bdcd8170SKalle Valo u8 group_crypto_len, int ssid_len, u8 *ssid, 18143ca9d1fcSAarthi Thiruvengadam u8 *bssid, u16 channel, u32 ctrl_flags, 18153ca9d1fcSAarthi Thiruvengadam u8 nw_subtype) 1816bdcd8170SKalle Valo { 1817bdcd8170SKalle Valo struct sk_buff *skb; 1818bdcd8170SKalle Valo struct wmi_connect_cmd *cc; 1819bdcd8170SKalle Valo int ret; 1820bdcd8170SKalle Valo 1821b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1822b9b6ee60SKalle Valo "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d " 1823b9b6ee60SKalle Valo "type %d dot11_auth %d auth %d pairwise %d group %d\n", 1824b9b6ee60SKalle Valo bssid, channel, ctrl_flags, ssid_len, nw_type, 1825b9b6ee60SKalle Valo dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto); 1826b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len); 1827b9b6ee60SKalle Valo 1828bdcd8170SKalle Valo wmi->traffic_class = 100; 1829bdcd8170SKalle Valo 1830bdcd8170SKalle Valo if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) 1831bdcd8170SKalle Valo return -EINVAL; 1832bdcd8170SKalle Valo 1833bdcd8170SKalle Valo if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) 1834bdcd8170SKalle Valo return -EINVAL; 1835bdcd8170SKalle Valo 1836bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); 1837bdcd8170SKalle Valo if (!skb) 1838bdcd8170SKalle Valo return -ENOMEM; 1839bdcd8170SKalle Valo 1840bdcd8170SKalle Valo cc = (struct wmi_connect_cmd *) skb->data; 1841bdcd8170SKalle Valo 1842bdcd8170SKalle Valo if (ssid_len) 1843bdcd8170SKalle Valo memcpy(cc->ssid, ssid, ssid_len); 1844bdcd8170SKalle Valo 1845bdcd8170SKalle Valo cc->ssid_len = ssid_len; 1846bdcd8170SKalle Valo cc->nw_type = nw_type; 1847bdcd8170SKalle Valo cc->dot11_auth_mode = dot11_auth_mode; 1848bdcd8170SKalle Valo cc->auth_mode = auth_mode; 1849bdcd8170SKalle Valo cc->prwise_crypto_type = pairwise_crypto; 1850bdcd8170SKalle Valo cc->prwise_crypto_len = pairwise_crypto_len; 1851bdcd8170SKalle Valo cc->grp_crypto_type = group_crypto; 1852bdcd8170SKalle Valo cc->grp_crypto_len = group_crypto_len; 1853bdcd8170SKalle Valo cc->ch = cpu_to_le16(channel); 1854bdcd8170SKalle Valo cc->ctrl_flags = cpu_to_le32(ctrl_flags); 18553ca9d1fcSAarthi Thiruvengadam cc->nw_subtype = nw_subtype; 1856bdcd8170SKalle Valo 1857bdcd8170SKalle Valo if (bssid != NULL) 1858bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1859bdcd8170SKalle Valo 1860334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID, 1861334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 1862bdcd8170SKalle Valo 1863bdcd8170SKalle Valo return ret; 1864bdcd8170SKalle Valo } 1865bdcd8170SKalle Valo 1866334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid, 1867334234b5SVasanthakumar Thiagarajan u16 channel) 1868bdcd8170SKalle Valo { 1869bdcd8170SKalle Valo struct sk_buff *skb; 1870bdcd8170SKalle Valo struct wmi_reconnect_cmd *cc; 1871bdcd8170SKalle Valo int ret; 1872bdcd8170SKalle Valo 1873b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n", 1874b9b6ee60SKalle Valo bssid, channel); 1875b9b6ee60SKalle Valo 1876bdcd8170SKalle Valo wmi->traffic_class = 100; 1877bdcd8170SKalle Valo 1878bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); 1879bdcd8170SKalle Valo if (!skb) 1880bdcd8170SKalle Valo return -ENOMEM; 1881bdcd8170SKalle Valo 1882bdcd8170SKalle Valo cc = (struct wmi_reconnect_cmd *) skb->data; 1883bdcd8170SKalle Valo cc->channel = cpu_to_le16(channel); 1884bdcd8170SKalle Valo 1885bdcd8170SKalle Valo if (bssid != NULL) 1886bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1887bdcd8170SKalle Valo 1888334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID, 1889bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1890bdcd8170SKalle Valo 1891bdcd8170SKalle Valo return ret; 1892bdcd8170SKalle Valo } 1893bdcd8170SKalle Valo 1894334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx) 1895bdcd8170SKalle Valo { 1896bdcd8170SKalle Valo int ret; 1897bdcd8170SKalle Valo 1898b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n"); 1899b9b6ee60SKalle Valo 1900bdcd8170SKalle Valo wmi->traffic_class = 100; 1901bdcd8170SKalle Valo 1902bdcd8170SKalle Valo /* Disconnect command does not need to do a SYNC before. */ 1903334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID); 1904bdcd8170SKalle Valo 1905bdcd8170SKalle Valo return ret; 1906bdcd8170SKalle Valo } 1907bdcd8170SKalle Valo 1908c8c72b74SKalle Valo /* ath6kl_wmi_start_scan_cmd is to be deprecated. Use 1909c8c72b74SKalle Valo * ath6kl_wmi_begin_scan_cmd instead. The new function supports P2P 1910c8c72b74SKalle Valo * mgmt operations using station interface. 1911c8c72b74SKalle Valo */ 191211f0bfcfSKalle Valo static int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx, 1913c8c72b74SKalle Valo enum wmi_scan_type scan_type, 1914c8c72b74SKalle Valo u32 force_fgscan, u32 is_legacy, 191511f0bfcfSKalle Valo u32 home_dwell_time, 191611f0bfcfSKalle Valo u32 force_scan_interval, 1917c8c72b74SKalle Valo s8 num_chan, u16 *ch_list) 1918c8c72b74SKalle Valo { 1919c8c72b74SKalle Valo struct sk_buff *skb; 1920c8c72b74SKalle Valo struct wmi_start_scan_cmd *sc; 1921c8c72b74SKalle Valo s8 size; 1922c8c72b74SKalle Valo int i, ret; 1923c8c72b74SKalle Valo 1924c8c72b74SKalle Valo size = sizeof(struct wmi_start_scan_cmd); 1925c8c72b74SKalle Valo 1926c8c72b74SKalle Valo if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 1927c8c72b74SKalle Valo return -EINVAL; 1928c8c72b74SKalle Valo 1929c8c72b74SKalle Valo if (num_chan > WMI_MAX_CHANNELS) 1930c8c72b74SKalle Valo return -EINVAL; 1931c8c72b74SKalle Valo 1932c8c72b74SKalle Valo if (num_chan) 1933c8c72b74SKalle Valo size += sizeof(u16) * (num_chan - 1); 1934c8c72b74SKalle Valo 1935c8c72b74SKalle Valo skb = ath6kl_wmi_get_new_buf(size); 1936c8c72b74SKalle Valo if (!skb) 1937c8c72b74SKalle Valo return -ENOMEM; 1938c8c72b74SKalle Valo 1939c8c72b74SKalle Valo sc = (struct wmi_start_scan_cmd *) skb->data; 1940c8c72b74SKalle Valo sc->scan_type = scan_type; 1941c8c72b74SKalle Valo sc->force_fg_scan = cpu_to_le32(force_fgscan); 1942c8c72b74SKalle Valo sc->is_legacy = cpu_to_le32(is_legacy); 1943c8c72b74SKalle Valo sc->home_dwell_time = cpu_to_le32(home_dwell_time); 1944c8c72b74SKalle Valo sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 1945c8c72b74SKalle Valo sc->num_ch = num_chan; 1946c8c72b74SKalle Valo 1947c8c72b74SKalle Valo for (i = 0; i < num_chan; i++) 1948c8c72b74SKalle Valo sc->ch_list[i] = cpu_to_le16(ch_list[i]); 1949c8c72b74SKalle Valo 1950c8c72b74SKalle Valo ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID, 1951c8c72b74SKalle Valo NO_SYNC_WMIFLAG); 1952c8c72b74SKalle Valo 1953c8c72b74SKalle Valo return ret; 1954c8c72b74SKalle Valo } 1955c8c72b74SKalle Valo 195611f0bfcfSKalle Valo /* 195711f0bfcfSKalle Valo * beginscan supports (compared to old startscan) P2P mgmt operations using 195811f0bfcfSKalle Valo * station interface, send additional information like supported rates to 195911f0bfcfSKalle Valo * advertise and xmit rates for probe requests 196011f0bfcfSKalle Valo */ 19613ca9d1fcSAarthi Thiruvengadam int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx, 19623ca9d1fcSAarthi Thiruvengadam enum wmi_scan_type scan_type, 19633ca9d1fcSAarthi Thiruvengadam u32 force_fgscan, u32 is_legacy, 19643ca9d1fcSAarthi Thiruvengadam u32 home_dwell_time, u32 force_scan_interval, 19653ca9d1fcSAarthi Thiruvengadam s8 num_chan, u16 *ch_list, u32 no_cck, u32 *rates) 19663ca9d1fcSAarthi Thiruvengadam { 196703e2084aSThomas Pedersen struct ieee80211_supported_band *sband; 19683ca9d1fcSAarthi Thiruvengadam struct sk_buff *skb; 19693ca9d1fcSAarthi Thiruvengadam struct wmi_begin_scan_cmd *sc; 197003e2084aSThomas Pedersen s8 size, *supp_rates; 19713ca9d1fcSAarthi Thiruvengadam int i, band, ret; 19723ca9d1fcSAarthi Thiruvengadam struct ath6kl *ar = wmi->parent_dev; 19733ca9d1fcSAarthi Thiruvengadam int num_rates; 197403e2084aSThomas Pedersen u32 ratemask; 19753ca9d1fcSAarthi Thiruvengadam 197611f0bfcfSKalle Valo if (!test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX, 197711f0bfcfSKalle Valo ar->fw_capabilities)) { 197811f0bfcfSKalle Valo return ath6kl_wmi_startscan_cmd(wmi, if_idx, 197911f0bfcfSKalle Valo scan_type, force_fgscan, 198011f0bfcfSKalle Valo is_legacy, home_dwell_time, 198111f0bfcfSKalle Valo force_scan_interval, 198211f0bfcfSKalle Valo num_chan, ch_list); 198311f0bfcfSKalle Valo } 198411f0bfcfSKalle Valo 19853ca9d1fcSAarthi Thiruvengadam size = sizeof(struct wmi_begin_scan_cmd); 19863ca9d1fcSAarthi Thiruvengadam 19873ca9d1fcSAarthi Thiruvengadam if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 19883ca9d1fcSAarthi Thiruvengadam return -EINVAL; 19893ca9d1fcSAarthi Thiruvengadam 19903ca9d1fcSAarthi Thiruvengadam if (num_chan > WMI_MAX_CHANNELS) 19913ca9d1fcSAarthi Thiruvengadam return -EINVAL; 19923ca9d1fcSAarthi Thiruvengadam 19933ca9d1fcSAarthi Thiruvengadam if (num_chan) 19943ca9d1fcSAarthi Thiruvengadam size += sizeof(u16) * (num_chan - 1); 19953ca9d1fcSAarthi Thiruvengadam 19963ca9d1fcSAarthi Thiruvengadam skb = ath6kl_wmi_get_new_buf(size); 19973ca9d1fcSAarthi Thiruvengadam if (!skb) 19983ca9d1fcSAarthi Thiruvengadam return -ENOMEM; 19993ca9d1fcSAarthi Thiruvengadam 20003ca9d1fcSAarthi Thiruvengadam sc = (struct wmi_begin_scan_cmd *) skb->data; 20013ca9d1fcSAarthi Thiruvengadam sc->scan_type = scan_type; 20023ca9d1fcSAarthi Thiruvengadam sc->force_fg_scan = cpu_to_le32(force_fgscan); 20033ca9d1fcSAarthi Thiruvengadam sc->is_legacy = cpu_to_le32(is_legacy); 20043ca9d1fcSAarthi Thiruvengadam sc->home_dwell_time = cpu_to_le32(home_dwell_time); 20053ca9d1fcSAarthi Thiruvengadam sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 20063ca9d1fcSAarthi Thiruvengadam sc->no_cck = cpu_to_le32(no_cck); 20073ca9d1fcSAarthi Thiruvengadam sc->num_ch = num_chan; 20083ca9d1fcSAarthi Thiruvengadam 20093ca9d1fcSAarthi Thiruvengadam for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 201003e2084aSThomas Pedersen sband = ar->wiphy->bands[band]; 201103e2084aSThomas Pedersen 201203e2084aSThomas Pedersen if (!sband) 201303e2084aSThomas Pedersen continue; 201403e2084aSThomas Pedersen 201503e2084aSThomas Pedersen ratemask = rates[band]; 201603e2084aSThomas Pedersen supp_rates = sc->supp_rates[band].rates; 20173ca9d1fcSAarthi Thiruvengadam num_rates = 0; 20183ca9d1fcSAarthi Thiruvengadam 20193ca9d1fcSAarthi Thiruvengadam for (i = 0; i < sband->n_bitrates; i++) { 20203ca9d1fcSAarthi Thiruvengadam if ((BIT(i) & ratemask) == 0) 20213ca9d1fcSAarthi Thiruvengadam continue; /* skip rate */ 20223ca9d1fcSAarthi Thiruvengadam supp_rates[num_rates++] = 20233ca9d1fcSAarthi Thiruvengadam (u8) (sband->bitrates[i].bitrate / 5); 20243ca9d1fcSAarthi Thiruvengadam } 20253ca9d1fcSAarthi Thiruvengadam sc->supp_rates[band].nrates = num_rates; 20263ca9d1fcSAarthi Thiruvengadam } 20273ca9d1fcSAarthi Thiruvengadam 20283ca9d1fcSAarthi Thiruvengadam for (i = 0; i < num_chan; i++) 20293ca9d1fcSAarthi Thiruvengadam sc->ch_list[i] = cpu_to_le16(ch_list[i]); 20303ca9d1fcSAarthi Thiruvengadam 20313ca9d1fcSAarthi Thiruvengadam ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_BEGIN_SCAN_CMDID, 20323ca9d1fcSAarthi Thiruvengadam NO_SYNC_WMIFLAG); 20333ca9d1fcSAarthi Thiruvengadam 20343ca9d1fcSAarthi Thiruvengadam return ret; 20353ca9d1fcSAarthi Thiruvengadam } 20363ca9d1fcSAarthi Thiruvengadam 2037b1f47e3aSThomas Pedersen int ath6kl_wmi_enable_sched_scan_cmd(struct wmi *wmi, u8 if_idx, bool enable) 2038b1f47e3aSThomas Pedersen { 2039b1f47e3aSThomas Pedersen struct sk_buff *skb; 2040b1f47e3aSThomas Pedersen struct wmi_enable_sched_scan_cmd *sc; 2041b1f47e3aSThomas Pedersen int ret; 2042b1f47e3aSThomas Pedersen 2043b1f47e3aSThomas Pedersen skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); 2044b1f47e3aSThomas Pedersen if (!skb) 2045b1f47e3aSThomas Pedersen return -ENOMEM; 2046b1f47e3aSThomas Pedersen 2047b1f47e3aSThomas Pedersen ath6kl_dbg(ATH6KL_DBG_WMI, "%s scheduled scan on vif %d\n", 2048b1f47e3aSThomas Pedersen enable ? "enabling" : "disabling", if_idx); 2049b1f47e3aSThomas Pedersen sc = (struct wmi_enable_sched_scan_cmd *) skb->data; 2050b1f47e3aSThomas Pedersen sc->enable = enable ? 1 : 0; 2051b1f47e3aSThomas Pedersen 2052b1f47e3aSThomas Pedersen ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, 2053b1f47e3aSThomas Pedersen WMI_ENABLE_SCHED_SCAN_CMDID, 2054b1f47e3aSThomas Pedersen NO_SYNC_WMIFLAG); 2055b1f47e3aSThomas Pedersen return ret; 2056b1f47e3aSThomas Pedersen } 2057b1f47e3aSThomas Pedersen 2058334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx, 2059334234b5SVasanthakumar Thiagarajan u16 fg_start_sec, 2060bdcd8170SKalle Valo u16 fg_end_sec, u16 bg_sec, 2061bdcd8170SKalle Valo u16 minact_chdw_msec, u16 maxact_chdw_msec, 2062bdcd8170SKalle Valo u16 pas_chdw_msec, u8 short_scan_ratio, 2063bdcd8170SKalle Valo u8 scan_ctrl_flag, u32 max_dfsch_act_time, 2064bdcd8170SKalle Valo u16 maxact_scan_per_ssid) 2065bdcd8170SKalle Valo { 2066bdcd8170SKalle Valo struct sk_buff *skb; 2067bdcd8170SKalle Valo struct wmi_scan_params_cmd *sc; 2068bdcd8170SKalle Valo int ret; 2069bdcd8170SKalle Valo 2070bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); 2071bdcd8170SKalle Valo if (!skb) 2072bdcd8170SKalle Valo return -ENOMEM; 2073bdcd8170SKalle Valo 2074bdcd8170SKalle Valo sc = (struct wmi_scan_params_cmd *) skb->data; 2075bdcd8170SKalle Valo sc->fg_start_period = cpu_to_le16(fg_start_sec); 2076bdcd8170SKalle Valo sc->fg_end_period = cpu_to_le16(fg_end_sec); 2077bdcd8170SKalle Valo sc->bg_period = cpu_to_le16(bg_sec); 2078bdcd8170SKalle Valo sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); 2079bdcd8170SKalle Valo sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); 2080bdcd8170SKalle Valo sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); 2081bdcd8170SKalle Valo sc->short_scan_ratio = short_scan_ratio; 2082bdcd8170SKalle Valo sc->scan_ctrl_flags = scan_ctrl_flag; 2083bdcd8170SKalle Valo sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); 2084bdcd8170SKalle Valo sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); 2085bdcd8170SKalle Valo 2086334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID, 2087bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2088bdcd8170SKalle Valo return ret; 2089bdcd8170SKalle Valo } 2090bdcd8170SKalle Valo 2091240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask) 2092bdcd8170SKalle Valo { 2093bdcd8170SKalle Valo struct sk_buff *skb; 2094bdcd8170SKalle Valo struct wmi_bss_filter_cmd *cmd; 2095bdcd8170SKalle Valo int ret; 2096bdcd8170SKalle Valo 2097bdcd8170SKalle Valo if (filter >= LAST_BSS_FILTER) 2098bdcd8170SKalle Valo return -EINVAL; 2099bdcd8170SKalle Valo 2100bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2101bdcd8170SKalle Valo if (!skb) 2102bdcd8170SKalle Valo return -ENOMEM; 2103bdcd8170SKalle Valo 2104bdcd8170SKalle Valo cmd = (struct wmi_bss_filter_cmd *) skb->data; 2105bdcd8170SKalle Valo cmd->bss_filter = filter; 2106bdcd8170SKalle Valo cmd->ie_mask = cpu_to_le32(ie_mask); 2107bdcd8170SKalle Valo 2108240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID, 2109bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2110bdcd8170SKalle Valo return ret; 2111bdcd8170SKalle Valo } 2112bdcd8170SKalle Valo 2113334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag, 2114bdcd8170SKalle Valo u8 ssid_len, u8 *ssid) 2115bdcd8170SKalle Valo { 2116bdcd8170SKalle Valo struct sk_buff *skb; 2117bdcd8170SKalle Valo struct wmi_probed_ssid_cmd *cmd; 2118bdcd8170SKalle Valo int ret; 2119bdcd8170SKalle Valo 21208ab5415dSJouni Malinen if (index >= MAX_PROBED_SSIDS) 2121bdcd8170SKalle Valo return -EINVAL; 2122bdcd8170SKalle Valo 2123bdcd8170SKalle Valo if (ssid_len > sizeof(cmd->ssid)) 2124bdcd8170SKalle Valo return -EINVAL; 2125bdcd8170SKalle Valo 2126bdcd8170SKalle Valo if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) 2127bdcd8170SKalle Valo return -EINVAL; 2128bdcd8170SKalle Valo 2129bdcd8170SKalle Valo if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) 2130bdcd8170SKalle Valo return -EINVAL; 2131bdcd8170SKalle Valo 2132bdcd8170SKalle Valo if (flag & SPECIFIC_SSID_FLAG) 2133bdcd8170SKalle Valo wmi->is_probe_ssid = true; 2134bdcd8170SKalle Valo 2135bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2136bdcd8170SKalle Valo if (!skb) 2137bdcd8170SKalle Valo return -ENOMEM; 2138bdcd8170SKalle Valo 2139bdcd8170SKalle Valo cmd = (struct wmi_probed_ssid_cmd *) skb->data; 2140bdcd8170SKalle Valo cmd->entry_index = index; 2141bdcd8170SKalle Valo cmd->flag = flag; 2142bdcd8170SKalle Valo cmd->ssid_len = ssid_len; 2143bdcd8170SKalle Valo memcpy(cmd->ssid, ssid, ssid_len); 2144bdcd8170SKalle Valo 2145334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID, 2146bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2147bdcd8170SKalle Valo return ret; 2148bdcd8170SKalle Valo } 2149bdcd8170SKalle Valo 2150334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, 2151334234b5SVasanthakumar Thiagarajan u16 listen_interval, 2152bdcd8170SKalle Valo u16 listen_beacons) 2153bdcd8170SKalle Valo { 2154bdcd8170SKalle Valo struct sk_buff *skb; 2155bdcd8170SKalle Valo struct wmi_listen_int_cmd *cmd; 2156bdcd8170SKalle Valo int ret; 2157bdcd8170SKalle Valo 2158bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2159bdcd8170SKalle Valo if (!skb) 2160bdcd8170SKalle Valo return -ENOMEM; 2161bdcd8170SKalle Valo 2162bdcd8170SKalle Valo cmd = (struct wmi_listen_int_cmd *) skb->data; 2163bdcd8170SKalle Valo cmd->listen_intvl = cpu_to_le16(listen_interval); 2164bdcd8170SKalle Valo cmd->num_beacons = cpu_to_le16(listen_beacons); 2165bdcd8170SKalle Valo 2166334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID, 2167bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2168bdcd8170SKalle Valo return ret; 2169bdcd8170SKalle Valo } 2170bdcd8170SKalle Valo 2171ce0dc0cfSRaja Mani int ath6kl_wmi_bmisstime_cmd(struct wmi *wmi, u8 if_idx, 2172ce0dc0cfSRaja Mani u16 bmiss_time, u16 num_beacons) 2173ce0dc0cfSRaja Mani { 2174ce0dc0cfSRaja Mani struct sk_buff *skb; 2175ce0dc0cfSRaja Mani struct wmi_bmiss_time_cmd *cmd; 2176ce0dc0cfSRaja Mani int ret; 2177ce0dc0cfSRaja Mani 2178ce0dc0cfSRaja Mani skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2179ce0dc0cfSRaja Mani if (!skb) 2180ce0dc0cfSRaja Mani return -ENOMEM; 2181ce0dc0cfSRaja Mani 2182ce0dc0cfSRaja Mani cmd = (struct wmi_bmiss_time_cmd *) skb->data; 2183ce0dc0cfSRaja Mani cmd->bmiss_time = cpu_to_le16(bmiss_time); 2184ce0dc0cfSRaja Mani cmd->num_beacons = cpu_to_le16(num_beacons); 2185ce0dc0cfSRaja Mani 2186ce0dc0cfSRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BMISS_TIME_CMDID, 2187ce0dc0cfSRaja Mani NO_SYNC_WMIFLAG); 2188ce0dc0cfSRaja Mani return ret; 2189ce0dc0cfSRaja Mani } 2190ce0dc0cfSRaja Mani 2191334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode) 2192bdcd8170SKalle Valo { 2193bdcd8170SKalle Valo struct sk_buff *skb; 2194bdcd8170SKalle Valo struct wmi_power_mode_cmd *cmd; 2195bdcd8170SKalle Valo int ret; 2196bdcd8170SKalle Valo 2197bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2198bdcd8170SKalle Valo if (!skb) 2199bdcd8170SKalle Valo return -ENOMEM; 2200bdcd8170SKalle Valo 2201bdcd8170SKalle Valo cmd = (struct wmi_power_mode_cmd *) skb->data; 2202bdcd8170SKalle Valo cmd->pwr_mode = pwr_mode; 2203bdcd8170SKalle Valo wmi->pwr_mode = pwr_mode; 2204bdcd8170SKalle Valo 2205334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID, 2206bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2207bdcd8170SKalle Valo return ret; 2208bdcd8170SKalle Valo } 2209bdcd8170SKalle Valo 22100ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period, 2211bdcd8170SKalle Valo u16 ps_poll_num, u16 dtim_policy, 2212bdcd8170SKalle Valo u16 tx_wakeup_policy, u16 num_tx_to_wakeup, 2213bdcd8170SKalle Valo u16 ps_fail_event_policy) 2214bdcd8170SKalle Valo { 2215bdcd8170SKalle Valo struct sk_buff *skb; 2216bdcd8170SKalle Valo struct wmi_power_params_cmd *pm; 2217bdcd8170SKalle Valo int ret; 2218bdcd8170SKalle Valo 2219bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); 2220bdcd8170SKalle Valo if (!skb) 2221bdcd8170SKalle Valo return -ENOMEM; 2222bdcd8170SKalle Valo 2223bdcd8170SKalle Valo pm = (struct wmi_power_params_cmd *)skb->data; 2224bdcd8170SKalle Valo pm->idle_period = cpu_to_le16(idle_period); 2225bdcd8170SKalle Valo pm->pspoll_number = cpu_to_le16(ps_poll_num); 2226bdcd8170SKalle Valo pm->dtim_policy = cpu_to_le16(dtim_policy); 2227bdcd8170SKalle Valo pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); 2228bdcd8170SKalle Valo pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); 2229bdcd8170SKalle Valo pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); 2230bdcd8170SKalle Valo 22310ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID, 2232bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2233bdcd8170SKalle Valo return ret; 2234bdcd8170SKalle Valo } 2235bdcd8170SKalle Valo 22360ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout) 2237bdcd8170SKalle Valo { 2238bdcd8170SKalle Valo struct sk_buff *skb; 2239bdcd8170SKalle Valo struct wmi_disc_timeout_cmd *cmd; 2240bdcd8170SKalle Valo int ret; 2241bdcd8170SKalle Valo 2242bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2243bdcd8170SKalle Valo if (!skb) 2244bdcd8170SKalle Valo return -ENOMEM; 2245bdcd8170SKalle Valo 2246bdcd8170SKalle Valo cmd = (struct wmi_disc_timeout_cmd *) skb->data; 2247bdcd8170SKalle Valo cmd->discon_timeout = timeout; 2248bdcd8170SKalle Valo 22490ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID, 2250bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2251334234b5SVasanthakumar Thiagarajan 2252ff0b0075SJouni Malinen if (ret == 0) 2253ff0b0075SJouni Malinen ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout); 2254334234b5SVasanthakumar Thiagarajan 2255bdcd8170SKalle Valo return ret; 2256bdcd8170SKalle Valo } 2257bdcd8170SKalle Valo 2258334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, 2259bdcd8170SKalle Valo enum crypto_type key_type, 2260bdcd8170SKalle Valo u8 key_usage, u8 key_len, 2261f4bb9a6fSJouni Malinen u8 *key_rsc, unsigned int key_rsc_len, 2262f4bb9a6fSJouni Malinen u8 *key_material, 2263bdcd8170SKalle Valo u8 key_op_ctrl, u8 *mac_addr, 2264bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2265bdcd8170SKalle Valo { 2266bdcd8170SKalle Valo struct sk_buff *skb; 2267bdcd8170SKalle Valo struct wmi_add_cipher_key_cmd *cmd; 2268bdcd8170SKalle Valo int ret; 2269bdcd8170SKalle Valo 2270cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2271cdeb8602SKalle Valo "addkey cmd: key_index=%u key_type=%d key_usage=%d key_len=%d key_op_ctrl=%d\n", 22729a5b1318SJouni Malinen key_index, key_type, key_usage, key_len, key_op_ctrl); 22739a5b1318SJouni Malinen 2274bdcd8170SKalle Valo if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || 2275f4bb9a6fSJouni Malinen (key_material == NULL) || key_rsc_len > 8) 2276bdcd8170SKalle Valo return -EINVAL; 2277bdcd8170SKalle Valo 2278bdcd8170SKalle Valo if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) 2279bdcd8170SKalle Valo return -EINVAL; 2280bdcd8170SKalle Valo 2281bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2282bdcd8170SKalle Valo if (!skb) 2283bdcd8170SKalle Valo return -ENOMEM; 2284bdcd8170SKalle Valo 2285bdcd8170SKalle Valo cmd = (struct wmi_add_cipher_key_cmd *) skb->data; 2286bdcd8170SKalle Valo cmd->key_index = key_index; 2287bdcd8170SKalle Valo cmd->key_type = key_type; 2288bdcd8170SKalle Valo cmd->key_usage = key_usage; 2289bdcd8170SKalle Valo cmd->key_len = key_len; 2290bdcd8170SKalle Valo memcpy(cmd->key, key_material, key_len); 2291bdcd8170SKalle Valo 2292bdcd8170SKalle Valo if (key_rsc != NULL) 2293f4bb9a6fSJouni Malinen memcpy(cmd->key_rsc, key_rsc, key_rsc_len); 2294bdcd8170SKalle Valo 2295bdcd8170SKalle Valo cmd->key_op_ctrl = key_op_ctrl; 2296bdcd8170SKalle Valo 2297bdcd8170SKalle Valo if (mac_addr) 2298bdcd8170SKalle Valo memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); 2299bdcd8170SKalle Valo 2300334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID, 2301bdcd8170SKalle Valo sync_flag); 2302bdcd8170SKalle Valo 2303bdcd8170SKalle Valo return ret; 2304bdcd8170SKalle Valo } 2305bdcd8170SKalle Valo 2306240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk) 2307bdcd8170SKalle Valo { 2308bdcd8170SKalle Valo struct sk_buff *skb; 2309bdcd8170SKalle Valo struct wmi_add_krk_cmd *cmd; 2310bdcd8170SKalle Valo int ret; 2311bdcd8170SKalle Valo 2312bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2313bdcd8170SKalle Valo if (!skb) 2314bdcd8170SKalle Valo return -ENOMEM; 2315bdcd8170SKalle Valo 2316bdcd8170SKalle Valo cmd = (struct wmi_add_krk_cmd *) skb->data; 2317bdcd8170SKalle Valo memcpy(cmd->krk, krk, WMI_KRK_LEN); 2318bdcd8170SKalle Valo 2319240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID, 2320334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2321bdcd8170SKalle Valo 2322bdcd8170SKalle Valo return ret; 2323bdcd8170SKalle Valo } 2324bdcd8170SKalle Valo 2325334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index) 2326bdcd8170SKalle Valo { 2327bdcd8170SKalle Valo struct sk_buff *skb; 2328bdcd8170SKalle Valo struct wmi_delete_cipher_key_cmd *cmd; 2329bdcd8170SKalle Valo int ret; 2330bdcd8170SKalle Valo 2331bdcd8170SKalle Valo if (key_index > WMI_MAX_KEY_INDEX) 2332bdcd8170SKalle Valo return -EINVAL; 2333bdcd8170SKalle Valo 2334bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2335bdcd8170SKalle Valo if (!skb) 2336bdcd8170SKalle Valo return -ENOMEM; 2337bdcd8170SKalle Valo 2338bdcd8170SKalle Valo cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; 2339bdcd8170SKalle Valo cmd->key_index = key_index; 2340bdcd8170SKalle Valo 2341334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID, 2342bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2343bdcd8170SKalle Valo 2344bdcd8170SKalle Valo return ret; 2345bdcd8170SKalle Valo } 2346bdcd8170SKalle Valo 2347334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, 2348bdcd8170SKalle Valo const u8 *pmkid, bool set) 2349bdcd8170SKalle Valo { 2350bdcd8170SKalle Valo struct sk_buff *skb; 2351bdcd8170SKalle Valo struct wmi_setpmkid_cmd *cmd; 2352bdcd8170SKalle Valo int ret; 2353bdcd8170SKalle Valo 2354bdcd8170SKalle Valo if (bssid == NULL) 2355bdcd8170SKalle Valo return -EINVAL; 2356bdcd8170SKalle Valo 2357bdcd8170SKalle Valo if (set && pmkid == NULL) 2358bdcd8170SKalle Valo return -EINVAL; 2359bdcd8170SKalle Valo 2360bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2361bdcd8170SKalle Valo if (!skb) 2362bdcd8170SKalle Valo return -ENOMEM; 2363bdcd8170SKalle Valo 2364bdcd8170SKalle Valo cmd = (struct wmi_setpmkid_cmd *) skb->data; 2365bdcd8170SKalle Valo memcpy(cmd->bssid, bssid, ETH_ALEN); 2366bdcd8170SKalle Valo if (set) { 2367bdcd8170SKalle Valo memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); 2368bdcd8170SKalle Valo cmd->enable = PMKID_ENABLE; 2369bdcd8170SKalle Valo } else { 2370bdcd8170SKalle Valo memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); 2371bdcd8170SKalle Valo cmd->enable = PMKID_DISABLE; 2372bdcd8170SKalle Valo } 2373bdcd8170SKalle Valo 2374334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID, 2375bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2376bdcd8170SKalle Valo 2377bdcd8170SKalle Valo return ret; 2378bdcd8170SKalle Valo } 2379bdcd8170SKalle Valo 2380bdcd8170SKalle Valo static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, 23816765d0aaSVasanthakumar Thiagarajan enum htc_endpoint_id ep_id, u8 if_idx) 2382bdcd8170SKalle Valo { 2383bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 2384bdcd8170SKalle Valo int ret; 2385bdcd8170SKalle Valo 23860616dc1fSVasanthakumar Thiagarajan if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) { 23870616dc1fSVasanthakumar Thiagarajan dev_kfree_skb(skb); 2388bdcd8170SKalle Valo return -EINVAL; 23890616dc1fSVasanthakumar Thiagarajan } 2390bdcd8170SKalle Valo 2391bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 2392bdcd8170SKalle Valo 2393bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) skb->data; 2394bdcd8170SKalle Valo data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; 23956765d0aaSVasanthakumar Thiagarajan data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); 2396bdcd8170SKalle Valo 2397bdcd8170SKalle Valo ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 2398bdcd8170SKalle Valo 2399bdcd8170SKalle Valo return ret; 2400bdcd8170SKalle Valo } 2401bdcd8170SKalle Valo 2402240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx) 2403bdcd8170SKalle Valo { 2404bdcd8170SKalle Valo struct sk_buff *skb; 2405bdcd8170SKalle Valo struct wmi_sync_cmd *cmd; 2406bdcd8170SKalle Valo struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; 2407bdcd8170SKalle Valo enum htc_endpoint_id ep_id; 2408bdcd8170SKalle Valo u8 index, num_pri_streams = 0; 2409bdcd8170SKalle Valo int ret = 0; 2410bdcd8170SKalle Valo 2411bdcd8170SKalle Valo memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); 2412bdcd8170SKalle Valo 2413bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2414bdcd8170SKalle Valo 2415bdcd8170SKalle Valo for (index = 0; index < WMM_NUM_AC; index++) { 2416bdcd8170SKalle Valo if (wmi->fat_pipe_exist & (1 << index)) { 2417bdcd8170SKalle Valo num_pri_streams++; 2418bdcd8170SKalle Valo data_sync_bufs[num_pri_streams - 1].traffic_class = 2419bdcd8170SKalle Valo index; 2420bdcd8170SKalle Valo } 2421bdcd8170SKalle Valo } 2422bdcd8170SKalle Valo 2423bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2424bdcd8170SKalle Valo 2425bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 24260616dc1fSVasanthakumar Thiagarajan if (!skb) 24270616dc1fSVasanthakumar Thiagarajan return -ENOMEM; 2428bdcd8170SKalle Valo 2429bdcd8170SKalle Valo cmd = (struct wmi_sync_cmd *) skb->data; 2430bdcd8170SKalle Valo 2431bdcd8170SKalle Valo /* 2432bdcd8170SKalle Valo * In the SYNC cmd sent on the control Ep, send a bitmap 2433bdcd8170SKalle Valo * of the data eps on which the Data Sync will be sent 2434bdcd8170SKalle Valo */ 2435bdcd8170SKalle Valo cmd->data_sync_map = wmi->fat_pipe_exist; 2436bdcd8170SKalle Valo 2437bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2438bdcd8170SKalle Valo data_sync_bufs[index].skb = ath6kl_buf_alloc(0); 2439bdcd8170SKalle Valo if (data_sync_bufs[index].skb == NULL) { 2440bdcd8170SKalle Valo ret = -ENOMEM; 2441bdcd8170SKalle Valo break; 2442bdcd8170SKalle Valo } 2443bdcd8170SKalle Valo } 2444bdcd8170SKalle Valo 2445bdcd8170SKalle Valo /* 2446bdcd8170SKalle Valo * If buffer allocation for any of the dataSync fails, 2447bdcd8170SKalle Valo * then do not send the Synchronize cmd on the control ep 2448bdcd8170SKalle Valo */ 2449bdcd8170SKalle Valo if (ret) 24500616dc1fSVasanthakumar Thiagarajan goto free_cmd_skb; 2451bdcd8170SKalle Valo 2452bdcd8170SKalle Valo /* 2453bdcd8170SKalle Valo * Send sync cmd followed by sync data messages on all 2454bdcd8170SKalle Valo * endpoints being used 2455bdcd8170SKalle Valo */ 2456240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID, 2457bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2458bdcd8170SKalle Valo 2459bdcd8170SKalle Valo if (ret) 24600616dc1fSVasanthakumar Thiagarajan goto free_data_skb; 2461bdcd8170SKalle Valo 2462bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2463bdcd8170SKalle Valo 2464bdcd8170SKalle Valo if (WARN_ON(!data_sync_bufs[index].skb)) 24650616dc1fSVasanthakumar Thiagarajan goto free_data_skb; 2466bdcd8170SKalle Valo 2467bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, 2468bdcd8170SKalle Valo data_sync_bufs[index]. 2469bdcd8170SKalle Valo traffic_class); 2470bdcd8170SKalle Valo ret = 2471bdcd8170SKalle Valo ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, 24726765d0aaSVasanthakumar Thiagarajan ep_id, if_idx); 2473bdcd8170SKalle Valo 2474bdcd8170SKalle Valo data_sync_bufs[index].skb = NULL; 24750616dc1fSVasanthakumar Thiagarajan 24760616dc1fSVasanthakumar Thiagarajan if (ret) 24770616dc1fSVasanthakumar Thiagarajan goto free_data_skb; 2478bdcd8170SKalle Valo } 2479bdcd8170SKalle Valo 24800616dc1fSVasanthakumar Thiagarajan return 0; 24810616dc1fSVasanthakumar Thiagarajan 24820616dc1fSVasanthakumar Thiagarajan free_cmd_skb: 2483bdcd8170SKalle Valo /* free up any resources left over (possibly due to an error) */ 2484bdcd8170SKalle Valo if (skb) 2485bdcd8170SKalle Valo dev_kfree_skb(skb); 2486bdcd8170SKalle Valo 24870616dc1fSVasanthakumar Thiagarajan free_data_skb: 2488bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2489bdcd8170SKalle Valo if (data_sync_bufs[index].skb != NULL) { 2490bdcd8170SKalle Valo dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. 2491bdcd8170SKalle Valo skb); 2492bdcd8170SKalle Valo } 2493bdcd8170SKalle Valo } 2494bdcd8170SKalle Valo 2495bdcd8170SKalle Valo return ret; 2496bdcd8170SKalle Valo } 2497bdcd8170SKalle Valo 2498240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx, 2499bdcd8170SKalle Valo struct wmi_create_pstream_cmd *params) 2500bdcd8170SKalle Valo { 2501bdcd8170SKalle Valo struct sk_buff *skb; 2502bdcd8170SKalle Valo struct wmi_create_pstream_cmd *cmd; 2503bdcd8170SKalle Valo u8 fatpipe_exist_for_ac = 0; 2504bdcd8170SKalle Valo s32 min_phy = 0; 2505bdcd8170SKalle Valo s32 nominal_phy = 0; 2506bdcd8170SKalle Valo int ret; 2507bdcd8170SKalle Valo 2508bdcd8170SKalle Valo if (!((params->user_pri < 8) && 2509bdcd8170SKalle Valo (params->user_pri <= 0x7) && 2510bdcd8170SKalle Valo (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && 2511bdcd8170SKalle Valo (params->traffic_direc == UPLINK_TRAFFIC || 2512bdcd8170SKalle Valo params->traffic_direc == DNLINK_TRAFFIC || 2513bdcd8170SKalle Valo params->traffic_direc == BIDIR_TRAFFIC) && 2514bdcd8170SKalle Valo (params->traffic_type == TRAFFIC_TYPE_APERIODIC || 2515bdcd8170SKalle Valo params->traffic_type == TRAFFIC_TYPE_PERIODIC) && 2516bdcd8170SKalle Valo (params->voice_psc_cap == DISABLE_FOR_THIS_AC || 2517bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_THIS_AC || 2518bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_ALL_AC) && 2519bdcd8170SKalle Valo (params->tsid == WMI_IMPLICIT_PSTREAM || 2520bdcd8170SKalle Valo params->tsid <= WMI_MAX_THINSTREAM))) { 2521bdcd8170SKalle Valo return -EINVAL; 2522bdcd8170SKalle Valo } 2523bdcd8170SKalle Valo 2524bdcd8170SKalle Valo /* 2525bdcd8170SKalle Valo * Check nominal PHY rate is >= minimalPHY, 2526bdcd8170SKalle Valo * so that DUT can allow TSRS IE 2527bdcd8170SKalle Valo */ 2528bdcd8170SKalle Valo 2529bdcd8170SKalle Valo /* Get the physical rate (units of bps) */ 2530bdcd8170SKalle Valo min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); 2531bdcd8170SKalle Valo 2532bdcd8170SKalle Valo /* Check minimal phy < nominal phy rate */ 2533bdcd8170SKalle Valo if (params->nominal_phy >= min_phy) { 2534bdcd8170SKalle Valo /* unit of 500 kbps */ 2535bdcd8170SKalle Valo nominal_phy = (params->nominal_phy * 1000) / 500; 2536bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2537bdcd8170SKalle Valo "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", 2538bdcd8170SKalle Valo min_phy, nominal_phy); 2539bdcd8170SKalle Valo 2540bdcd8170SKalle Valo params->nominal_phy = nominal_phy; 2541bdcd8170SKalle Valo } else { 2542bdcd8170SKalle Valo params->nominal_phy = 0; 2543bdcd8170SKalle Valo } 2544bdcd8170SKalle Valo 2545bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2546bdcd8170SKalle Valo if (!skb) 2547bdcd8170SKalle Valo return -ENOMEM; 2548bdcd8170SKalle Valo 2549bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2550bdcd8170SKalle Valo "sending create_pstream_cmd: ac=%d tsid:%d\n", 2551bdcd8170SKalle Valo params->traffic_class, params->tsid); 2552bdcd8170SKalle Valo 2553bdcd8170SKalle Valo cmd = (struct wmi_create_pstream_cmd *) skb->data; 2554bdcd8170SKalle Valo memcpy(cmd, params, sizeof(*cmd)); 2555bdcd8170SKalle Valo 2556bdcd8170SKalle Valo /* This is an implicitly created Fat pipe */ 2557bdcd8170SKalle Valo if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { 2558bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2559bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2560bdcd8170SKalle Valo (1 << params->traffic_class)); 2561bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2562bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2563bdcd8170SKalle Valo } else { 2564bdcd8170SKalle Valo /* explicitly created thin stream within a fat pipe */ 2565bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2566bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2567bdcd8170SKalle Valo (1 << params->traffic_class)); 2568bdcd8170SKalle Valo wmi->stream_exist_for_ac[params->traffic_class] |= 2569bdcd8170SKalle Valo (1 << params->tsid); 2570bdcd8170SKalle Valo /* 2571bdcd8170SKalle Valo * If a thinstream becomes active, the fat pipe automatically 2572bdcd8170SKalle Valo * becomes active 2573bdcd8170SKalle Valo */ 2574bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2575bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2576bdcd8170SKalle Valo } 2577bdcd8170SKalle Valo 2578bdcd8170SKalle Valo /* 2579bdcd8170SKalle Valo * Indicate activty change to driver layer only if this is the 2580bdcd8170SKalle Valo * first TSID to get created in this AC explicitly or an implicit 2581bdcd8170SKalle Valo * fat pipe is getting created. 2582bdcd8170SKalle Valo */ 2583bdcd8170SKalle Valo if (!fatpipe_exist_for_ac) 2584bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2585bdcd8170SKalle Valo params->traffic_class, true); 2586bdcd8170SKalle Valo 2587240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID, 2588bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2589bdcd8170SKalle Valo return ret; 2590bdcd8170SKalle Valo } 2591bdcd8170SKalle Valo 2592240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class, 2593240d2799SVasanthakumar Thiagarajan u8 tsid) 2594bdcd8170SKalle Valo { 2595bdcd8170SKalle Valo struct sk_buff *skb; 2596bdcd8170SKalle Valo struct wmi_delete_pstream_cmd *cmd; 2597bdcd8170SKalle Valo u16 active_tsids = 0; 2598bdcd8170SKalle Valo int ret; 2599bdcd8170SKalle Valo 2600bdcd8170SKalle Valo if (traffic_class > 3) { 2601bdcd8170SKalle Valo ath6kl_err("invalid traffic class: %d\n", traffic_class); 2602bdcd8170SKalle Valo return -EINVAL; 2603bdcd8170SKalle Valo } 2604bdcd8170SKalle Valo 2605bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2606bdcd8170SKalle Valo if (!skb) 2607bdcd8170SKalle Valo return -ENOMEM; 2608bdcd8170SKalle Valo 2609bdcd8170SKalle Valo cmd = (struct wmi_delete_pstream_cmd *) skb->data; 2610bdcd8170SKalle Valo cmd->traffic_class = traffic_class; 2611bdcd8170SKalle Valo cmd->tsid = tsid; 2612bdcd8170SKalle Valo 2613bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2614bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2615bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2616bdcd8170SKalle Valo 2617bdcd8170SKalle Valo if (!(active_tsids & (1 << tsid))) { 2618bdcd8170SKalle Valo dev_kfree_skb(skb); 2619bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2620bdcd8170SKalle Valo "TSID %d doesn't exist for traffic class: %d\n", 2621bdcd8170SKalle Valo tsid, traffic_class); 2622bdcd8170SKalle Valo return -ENODATA; 2623bdcd8170SKalle Valo } 2624bdcd8170SKalle Valo 2625bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2626bdcd8170SKalle Valo "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", 2627bdcd8170SKalle Valo traffic_class, tsid); 2628bdcd8170SKalle Valo 2629240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID, 2630bdcd8170SKalle Valo SYNC_BEFORE_WMIFLAG); 2631bdcd8170SKalle Valo 2632bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2633bdcd8170SKalle Valo wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); 2634bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2635bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2636bdcd8170SKalle Valo 2637bdcd8170SKalle Valo /* 2638bdcd8170SKalle Valo * Indicate stream inactivity to driver layer only if all tsids 2639bdcd8170SKalle Valo * within this AC are deleted. 2640bdcd8170SKalle Valo */ 2641bdcd8170SKalle Valo if (!active_tsids) { 2642bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2643bdcd8170SKalle Valo traffic_class, false); 2644bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << traffic_class); 2645bdcd8170SKalle Valo } 2646bdcd8170SKalle Valo 2647bdcd8170SKalle Valo return ret; 2648bdcd8170SKalle Valo } 2649bdcd8170SKalle Valo 2650ca1d16a0SRaja Mani int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx, 2651ca1d16a0SRaja Mani __be32 ips0, __be32 ips1) 2652bdcd8170SKalle Valo { 2653bdcd8170SKalle Valo struct sk_buff *skb; 2654bdcd8170SKalle Valo struct wmi_set_ip_cmd *cmd; 2655bdcd8170SKalle Valo int ret; 2656bdcd8170SKalle Valo 2657bdcd8170SKalle Valo /* Multicast address are not valid */ 2658ca1d16a0SRaja Mani if (ipv4_is_multicast(ips0) || 2659ca1d16a0SRaja Mani ipv4_is_multicast(ips1)) 2660bdcd8170SKalle Valo return -EINVAL; 2661bdcd8170SKalle Valo 2662bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); 2663bdcd8170SKalle Valo if (!skb) 2664bdcd8170SKalle Valo return -ENOMEM; 2665bdcd8170SKalle Valo 2666bdcd8170SKalle Valo cmd = (struct wmi_set_ip_cmd *) skb->data; 2667ca1d16a0SRaja Mani cmd->ips[0] = ips0; 2668ca1d16a0SRaja Mani cmd->ips[1] = ips1; 2669bdcd8170SKalle Valo 2670ca1d16a0SRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IP_CMDID, 2671334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2672bdcd8170SKalle Valo return ret; 2673bdcd8170SKalle Valo } 2674bdcd8170SKalle Valo 267545cf110bSRaja Mani static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi) 267645cf110bSRaja Mani { 267745cf110bSRaja Mani u16 active_tsids; 267845cf110bSRaja Mani u8 stream_exist; 267945cf110bSRaja Mani int i; 268045cf110bSRaja Mani 268145cf110bSRaja Mani /* 268245cf110bSRaja Mani * Relinquish credits from all implicitly created pstreams 268345cf110bSRaja Mani * since when we go to sleep. If user created explicit 268445cf110bSRaja Mani * thinstreams exists with in a fatpipe leave them intact 268545cf110bSRaja Mani * for the user to delete. 268645cf110bSRaja Mani */ 268745cf110bSRaja Mani spin_lock_bh(&wmi->lock); 268845cf110bSRaja Mani stream_exist = wmi->fat_pipe_exist; 268945cf110bSRaja Mani spin_unlock_bh(&wmi->lock); 269045cf110bSRaja Mani 269145cf110bSRaja Mani for (i = 0; i < WMM_NUM_AC; i++) { 269245cf110bSRaja Mani if (stream_exist & (1 << i)) { 269345cf110bSRaja Mani 269445cf110bSRaja Mani /* 269545cf110bSRaja Mani * FIXME: Is this lock & unlock inside 269645cf110bSRaja Mani * for loop correct? may need rework. 269745cf110bSRaja Mani */ 269845cf110bSRaja Mani spin_lock_bh(&wmi->lock); 269945cf110bSRaja Mani active_tsids = wmi->stream_exist_for_ac[i]; 270045cf110bSRaja Mani spin_unlock_bh(&wmi->lock); 270145cf110bSRaja Mani 270245cf110bSRaja Mani /* 270345cf110bSRaja Mani * If there are no user created thin streams 270445cf110bSRaja Mani * delete the fatpipe 270545cf110bSRaja Mani */ 270645cf110bSRaja Mani if (!active_tsids) { 270745cf110bSRaja Mani stream_exist &= ~(1 << i); 270845cf110bSRaja Mani /* 270945cf110bSRaja Mani * Indicate inactivity to driver layer for 271045cf110bSRaja Mani * this fatpipe (pstream) 271145cf110bSRaja Mani */ 271245cf110bSRaja Mani ath6kl_indicate_tx_activity(wmi->parent_dev, 271345cf110bSRaja Mani i, false); 271445cf110bSRaja Mani } 271545cf110bSRaja Mani } 271645cf110bSRaja Mani } 271745cf110bSRaja Mani 271845cf110bSRaja Mani /* FIXME: Can we do this assignment without locking ? */ 271945cf110bSRaja Mani spin_lock_bh(&wmi->lock); 272045cf110bSRaja Mani wmi->fat_pipe_exist = stream_exist; 272145cf110bSRaja Mani spin_unlock_bh(&wmi->lock); 272245cf110bSRaja Mani } 272345cf110bSRaja Mani 272406e360acSBala Shanmugam static int ath6kl_set_bitrate_mask64(struct wmi *wmi, u8 if_idx, 272506e360acSBala Shanmugam const struct cfg80211_bitrate_mask *mask) 272606e360acSBala Shanmugam { 272706e360acSBala Shanmugam struct sk_buff *skb; 272806e360acSBala Shanmugam int ret, mode, band; 2729f8c03053SKalle Valo u64 mcsrate, ratemask[ATH6KL_NUM_BANDS]; 273006e360acSBala Shanmugam struct wmi_set_tx_select_rates64_cmd *cmd; 273106e360acSBala Shanmugam 273206e360acSBala Shanmugam memset(&ratemask, 0, sizeof(ratemask)); 2733f8c03053SKalle Valo 2734f8c03053SKalle Valo /* only check 2.4 and 5 GHz bands, skip the rest */ 2735f8c03053SKalle Valo for (band = 0; band <= IEEE80211_BAND_5GHZ; band++) { 273606e360acSBala Shanmugam /* copy legacy rate mask */ 273706e360acSBala Shanmugam ratemask[band] = mask->control[band].legacy; 273806e360acSBala Shanmugam if (band == IEEE80211_BAND_5GHZ) 273906e360acSBala Shanmugam ratemask[band] = 274006e360acSBala Shanmugam mask->control[band].legacy << 4; 274106e360acSBala Shanmugam 274206e360acSBala Shanmugam /* copy mcs rate mask */ 274306e360acSBala Shanmugam mcsrate = mask->control[band].mcs[1]; 274406e360acSBala Shanmugam mcsrate <<= 8; 274506e360acSBala Shanmugam mcsrate |= mask->control[band].mcs[0]; 274606e360acSBala Shanmugam ratemask[band] |= mcsrate << 12; 274706e360acSBala Shanmugam ratemask[band] |= mcsrate << 28; 274806e360acSBala Shanmugam } 274906e360acSBala Shanmugam 275006e360acSBala Shanmugam ath6kl_dbg(ATH6KL_DBG_WMI, 275106e360acSBala Shanmugam "Ratemask 64 bit: 2.4:%llx 5:%llx\n", 275206e360acSBala Shanmugam ratemask[0], ratemask[1]); 275306e360acSBala Shanmugam 275406e360acSBala Shanmugam skb = ath6kl_wmi_get_new_buf(sizeof(*cmd) * WMI_RATES_MODE_MAX); 275506e360acSBala Shanmugam if (!skb) 275606e360acSBala Shanmugam return -ENOMEM; 275706e360acSBala Shanmugam 275806e360acSBala Shanmugam cmd = (struct wmi_set_tx_select_rates64_cmd *) skb->data; 275906e360acSBala Shanmugam for (mode = 0; mode < WMI_RATES_MODE_MAX; mode++) { 276006e360acSBala Shanmugam /* A mode operate in 5GHZ band */ 276106e360acSBala Shanmugam if (mode == WMI_RATES_MODE_11A || 276206e360acSBala Shanmugam mode == WMI_RATES_MODE_11A_HT20 || 276306e360acSBala Shanmugam mode == WMI_RATES_MODE_11A_HT40) 276406e360acSBala Shanmugam band = IEEE80211_BAND_5GHZ; 276506e360acSBala Shanmugam else 276606e360acSBala Shanmugam band = IEEE80211_BAND_2GHZ; 276706e360acSBala Shanmugam cmd->ratemask[mode] = cpu_to_le64(ratemask[band]); 276806e360acSBala Shanmugam } 276906e360acSBala Shanmugam 277006e360acSBala Shanmugam ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, 277106e360acSBala Shanmugam WMI_SET_TX_SELECT_RATES_CMDID, 277206e360acSBala Shanmugam NO_SYNC_WMIFLAG); 277306e360acSBala Shanmugam return ret; 277406e360acSBala Shanmugam } 277506e360acSBala Shanmugam 277606e360acSBala Shanmugam static int ath6kl_set_bitrate_mask32(struct wmi *wmi, u8 if_idx, 277706e360acSBala Shanmugam const struct cfg80211_bitrate_mask *mask) 277806e360acSBala Shanmugam { 277906e360acSBala Shanmugam struct sk_buff *skb; 278006e360acSBala Shanmugam int ret, mode, band; 2781f8c03053SKalle Valo u32 mcsrate, ratemask[ATH6KL_NUM_BANDS]; 278206e360acSBala Shanmugam struct wmi_set_tx_select_rates32_cmd *cmd; 278306e360acSBala Shanmugam 278406e360acSBala Shanmugam memset(&ratemask, 0, sizeof(ratemask)); 2785f8c03053SKalle Valo 2786f8c03053SKalle Valo /* only check 2.4 and 5 GHz bands, skip the rest */ 2787f8c03053SKalle Valo for (band = 0; band <= IEEE80211_BAND_5GHZ; band++) { 278806e360acSBala Shanmugam /* copy legacy rate mask */ 278906e360acSBala Shanmugam ratemask[band] = mask->control[band].legacy; 279006e360acSBala Shanmugam if (band == IEEE80211_BAND_5GHZ) 279106e360acSBala Shanmugam ratemask[band] = 279206e360acSBala Shanmugam mask->control[band].legacy << 4; 279306e360acSBala Shanmugam 279406e360acSBala Shanmugam /* copy mcs rate mask */ 279506e360acSBala Shanmugam mcsrate = mask->control[band].mcs[0]; 279606e360acSBala Shanmugam ratemask[band] |= mcsrate << 12; 279706e360acSBala Shanmugam ratemask[band] |= mcsrate << 20; 279806e360acSBala Shanmugam } 279906e360acSBala Shanmugam 280006e360acSBala Shanmugam ath6kl_dbg(ATH6KL_DBG_WMI, 280106e360acSBala Shanmugam "Ratemask 32 bit: 2.4:%x 5:%x\n", 280206e360acSBala Shanmugam ratemask[0], ratemask[1]); 280306e360acSBala Shanmugam 280406e360acSBala Shanmugam skb = ath6kl_wmi_get_new_buf(sizeof(*cmd) * WMI_RATES_MODE_MAX); 280506e360acSBala Shanmugam if (!skb) 280606e360acSBala Shanmugam return -ENOMEM; 280706e360acSBala Shanmugam 280806e360acSBala Shanmugam cmd = (struct wmi_set_tx_select_rates32_cmd *) skb->data; 280906e360acSBala Shanmugam for (mode = 0; mode < WMI_RATES_MODE_MAX; mode++) { 281006e360acSBala Shanmugam /* A mode operate in 5GHZ band */ 281106e360acSBala Shanmugam if (mode == WMI_RATES_MODE_11A || 281206e360acSBala Shanmugam mode == WMI_RATES_MODE_11A_HT20 || 281306e360acSBala Shanmugam mode == WMI_RATES_MODE_11A_HT40) 281406e360acSBala Shanmugam band = IEEE80211_BAND_5GHZ; 281506e360acSBala Shanmugam else 281606e360acSBala Shanmugam band = IEEE80211_BAND_2GHZ; 281706e360acSBala Shanmugam cmd->ratemask[mode] = cpu_to_le32(ratemask[band]); 281806e360acSBala Shanmugam } 281906e360acSBala Shanmugam 282006e360acSBala Shanmugam ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, 282106e360acSBala Shanmugam WMI_SET_TX_SELECT_RATES_CMDID, 282206e360acSBala Shanmugam NO_SYNC_WMIFLAG); 282306e360acSBala Shanmugam return ret; 282406e360acSBala Shanmugam } 282506e360acSBala Shanmugam 282606e360acSBala Shanmugam int ath6kl_wmi_set_bitrate_mask(struct wmi *wmi, u8 if_idx, 282706e360acSBala Shanmugam const struct cfg80211_bitrate_mask *mask) 282806e360acSBala Shanmugam { 282906e360acSBala Shanmugam struct ath6kl *ar = wmi->parent_dev; 283006e360acSBala Shanmugam 283106e360acSBala Shanmugam if (ar->hw.flags & ATH6KL_HW_FLAG_64BIT_RATES) 283206e360acSBala Shanmugam return ath6kl_set_bitrate_mask64(wmi, if_idx, mask); 283306e360acSBala Shanmugam else 283406e360acSBala Shanmugam return ath6kl_set_bitrate_mask32(wmi, if_idx, mask); 283506e360acSBala Shanmugam } 283606e360acSBala Shanmugam 283745cf110bSRaja Mani int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx, 283845cf110bSRaja Mani enum ath6kl_host_mode host_mode) 283945cf110bSRaja Mani { 284045cf110bSRaja Mani struct sk_buff *skb; 284145cf110bSRaja Mani struct wmi_set_host_sleep_mode_cmd *cmd; 284245cf110bSRaja Mani int ret; 284345cf110bSRaja Mani 284445cf110bSRaja Mani if ((host_mode != ATH6KL_HOST_MODE_ASLEEP) && 284545cf110bSRaja Mani (host_mode != ATH6KL_HOST_MODE_AWAKE)) { 284645cf110bSRaja Mani ath6kl_err("invalid host sleep mode: %d\n", host_mode); 284745cf110bSRaja Mani return -EINVAL; 284845cf110bSRaja Mani } 284945cf110bSRaja Mani 285045cf110bSRaja Mani skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 285145cf110bSRaja Mani if (!skb) 285245cf110bSRaja Mani return -ENOMEM; 285345cf110bSRaja Mani 285445cf110bSRaja Mani cmd = (struct wmi_set_host_sleep_mode_cmd *) skb->data; 285545cf110bSRaja Mani 285645cf110bSRaja Mani if (host_mode == ATH6KL_HOST_MODE_ASLEEP) { 285745cf110bSRaja Mani ath6kl_wmi_relinquish_implicit_pstream_credits(wmi); 285845cf110bSRaja Mani cmd->asleep = cpu_to_le32(1); 285945cf110bSRaja Mani } else 286045cf110bSRaja Mani cmd->awake = cpu_to_le32(1); 286145cf110bSRaja Mani 286245cf110bSRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, 286345cf110bSRaja Mani WMI_SET_HOST_SLEEP_MODE_CMDID, 286445cf110bSRaja Mani NO_SYNC_WMIFLAG); 286545cf110bSRaja Mani return ret; 286645cf110bSRaja Mani } 286745cf110bSRaja Mani 2868081c7a84SRaja Mani /* This command has zero length payload */ 2869081c7a84SRaja Mani static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi *wmi, 2870081c7a84SRaja Mani struct ath6kl_vif *vif) 2871081c7a84SRaja Mani { 2872081c7a84SRaja Mani struct ath6kl *ar = wmi->parent_dev; 2873081c7a84SRaja Mani 2874081c7a84SRaja Mani set_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags); 2875081c7a84SRaja Mani wake_up(&ar->event_wq); 2876081c7a84SRaja Mani 2877081c7a84SRaja Mani return 0; 2878081c7a84SRaja Mani } 2879081c7a84SRaja Mani 288045cf110bSRaja Mani int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, 288145cf110bSRaja Mani enum ath6kl_wow_mode wow_mode, 288245cf110bSRaja Mani u32 filter, u16 host_req_delay) 288345cf110bSRaja Mani { 288445cf110bSRaja Mani struct sk_buff *skb; 288545cf110bSRaja Mani struct wmi_set_wow_mode_cmd *cmd; 288645cf110bSRaja Mani int ret; 288745cf110bSRaja Mani 288845cf110bSRaja Mani if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) && 288945cf110bSRaja Mani wow_mode != ATH6KL_WOW_MODE_DISABLE) { 289045cf110bSRaja Mani ath6kl_err("invalid wow mode: %d\n", wow_mode); 289145cf110bSRaja Mani return -EINVAL; 289245cf110bSRaja Mani } 289345cf110bSRaja Mani 289445cf110bSRaja Mani skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 289545cf110bSRaja Mani if (!skb) 289645cf110bSRaja Mani return -ENOMEM; 289745cf110bSRaja Mani 289845cf110bSRaja Mani cmd = (struct wmi_set_wow_mode_cmd *) skb->data; 289945cf110bSRaja Mani cmd->enable_wow = cpu_to_le32(wow_mode); 290045cf110bSRaja Mani cmd->filter = cpu_to_le32(filter); 290145cf110bSRaja Mani cmd->host_req_delay = cpu_to_le16(host_req_delay); 290245cf110bSRaja Mani 290345cf110bSRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WOW_MODE_CMDID, 290445cf110bSRaja Mani NO_SYNC_WMIFLAG); 290545cf110bSRaja Mani return ret; 290645cf110bSRaja Mani } 290745cf110bSRaja Mani 29085c9b4fa1SRaja Mani int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, 29095c9b4fa1SRaja Mani u8 list_id, u8 filter_size, 2910d91e8eeeSRaja Mani u8 filter_offset, const u8 *filter, 2911d91e8eeeSRaja Mani const u8 *mask) 29125c9b4fa1SRaja Mani { 29135c9b4fa1SRaja Mani struct sk_buff *skb; 29145c9b4fa1SRaja Mani struct wmi_add_wow_pattern_cmd *cmd; 29155c9b4fa1SRaja Mani u16 size; 29165c9b4fa1SRaja Mani u8 *filter_mask; 29175c9b4fa1SRaja Mani int ret; 29185c9b4fa1SRaja Mani 29195c9b4fa1SRaja Mani /* 29205c9b4fa1SRaja Mani * Allocate additional memory in the buffer to hold 29215c9b4fa1SRaja Mani * filter and mask value, which is twice of filter_size. 29225c9b4fa1SRaja Mani */ 29235c9b4fa1SRaja Mani size = sizeof(*cmd) + (2 * filter_size); 29245c9b4fa1SRaja Mani 29255c9b4fa1SRaja Mani skb = ath6kl_wmi_get_new_buf(size); 29265c9b4fa1SRaja Mani if (!skb) 29275c9b4fa1SRaja Mani return -ENOMEM; 29285c9b4fa1SRaja Mani 29295c9b4fa1SRaja Mani cmd = (struct wmi_add_wow_pattern_cmd *) skb->data; 29305c9b4fa1SRaja Mani cmd->filter_list_id = list_id; 29315c9b4fa1SRaja Mani cmd->filter_size = filter_size; 29325c9b4fa1SRaja Mani cmd->filter_offset = filter_offset; 29335c9b4fa1SRaja Mani 29345c9b4fa1SRaja Mani memcpy(cmd->filter, filter, filter_size); 29355c9b4fa1SRaja Mani 29365c9b4fa1SRaja Mani filter_mask = (u8 *) (cmd->filter + filter_size); 29375c9b4fa1SRaja Mani memcpy(filter_mask, mask, filter_size); 29385c9b4fa1SRaja Mani 29395c9b4fa1SRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_WOW_PATTERN_CMDID, 29405c9b4fa1SRaja Mani NO_SYNC_WMIFLAG); 29415c9b4fa1SRaja Mani 29425c9b4fa1SRaja Mani return ret; 29435c9b4fa1SRaja Mani } 29445c9b4fa1SRaja Mani 29455c9b4fa1SRaja Mani int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, 29465c9b4fa1SRaja Mani u16 list_id, u16 filter_id) 29475c9b4fa1SRaja Mani { 29485c9b4fa1SRaja Mani struct sk_buff *skb; 29495c9b4fa1SRaja Mani struct wmi_del_wow_pattern_cmd *cmd; 29505c9b4fa1SRaja Mani int ret; 29515c9b4fa1SRaja Mani 29525c9b4fa1SRaja Mani skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 29535c9b4fa1SRaja Mani if (!skb) 29545c9b4fa1SRaja Mani return -ENOMEM; 29555c9b4fa1SRaja Mani 29565c9b4fa1SRaja Mani cmd = (struct wmi_del_wow_pattern_cmd *) skb->data; 29575c9b4fa1SRaja Mani cmd->filter_list_id = cpu_to_le16(list_id); 29585c9b4fa1SRaja Mani cmd->filter_id = cpu_to_le16(filter_id); 29595c9b4fa1SRaja Mani 29605c9b4fa1SRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DEL_WOW_PATTERN_CMDID, 29615c9b4fa1SRaja Mani NO_SYNC_WMIFLAG); 29625c9b4fa1SRaja Mani return ret; 29635c9b4fa1SRaja Mani } 29645c9b4fa1SRaja Mani 2965bdcd8170SKalle Valo static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, 2966bdcd8170SKalle Valo enum wmix_command_id cmd_id, 2967bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2968bdcd8170SKalle Valo { 2969bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd_hdr; 2970bdcd8170SKalle Valo int ret; 2971bdcd8170SKalle Valo 2972bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmix_cmd_hdr)); 2973bdcd8170SKalle Valo 2974bdcd8170SKalle Valo cmd_hdr = (struct wmix_cmd_hdr *) skb->data; 2975bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le32(cmd_id); 2976bdcd8170SKalle Valo 2977334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag); 2978bdcd8170SKalle Valo 2979bdcd8170SKalle Valo return ret; 2980bdcd8170SKalle Valo } 2981bdcd8170SKalle Valo 2982bdcd8170SKalle Valo int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) 2983bdcd8170SKalle Valo { 2984bdcd8170SKalle Valo struct sk_buff *skb; 2985bdcd8170SKalle Valo struct wmix_hb_challenge_resp_cmd *cmd; 2986bdcd8170SKalle Valo int ret; 2987bdcd8170SKalle Valo 2988bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2989bdcd8170SKalle Valo if (!skb) 2990bdcd8170SKalle Valo return -ENOMEM; 2991bdcd8170SKalle Valo 2992bdcd8170SKalle Valo cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; 2993bdcd8170SKalle Valo cmd->cookie = cpu_to_le32(cookie); 2994bdcd8170SKalle Valo cmd->source = cpu_to_le32(source); 2995bdcd8170SKalle Valo 2996bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, 2997bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2998bdcd8170SKalle Valo return ret; 2999bdcd8170SKalle Valo } 3000bdcd8170SKalle Valo 3001939f1cceSKalle Valo int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config) 3002939f1cceSKalle Valo { 3003939f1cceSKalle Valo struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd; 3004939f1cceSKalle Valo struct sk_buff *skb; 3005939f1cceSKalle Valo int ret; 3006939f1cceSKalle Valo 3007939f1cceSKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3008939f1cceSKalle Valo if (!skb) 3009939f1cceSKalle Valo return -ENOMEM; 3010939f1cceSKalle Valo 3011939f1cceSKalle Valo cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data; 3012939f1cceSKalle Valo cmd->valid = cpu_to_le32(valid); 3013939f1cceSKalle Valo cmd->config = cpu_to_le32(config); 3014939f1cceSKalle Valo 3015939f1cceSKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID, 3016939f1cceSKalle Valo NO_SYNC_WMIFLAG); 3017939f1cceSKalle Valo return ret; 3018939f1cceSKalle Valo } 3019939f1cceSKalle Valo 3020334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx) 3021bdcd8170SKalle Valo { 3022334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID); 3023bdcd8170SKalle Valo } 3024bdcd8170SKalle Valo 3025990bd915SVasanthakumar Thiagarajan int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM) 3026bdcd8170SKalle Valo { 3027bdcd8170SKalle Valo struct sk_buff *skb; 3028bdcd8170SKalle Valo struct wmi_set_tx_pwr_cmd *cmd; 3029bdcd8170SKalle Valo int ret; 3030bdcd8170SKalle Valo 3031bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); 3032bdcd8170SKalle Valo if (!skb) 3033bdcd8170SKalle Valo return -ENOMEM; 3034bdcd8170SKalle Valo 3035bdcd8170SKalle Valo cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; 3036bdcd8170SKalle Valo cmd->dbM = dbM; 3037bdcd8170SKalle Valo 3038990bd915SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID, 3039bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 3040bdcd8170SKalle Valo 3041bdcd8170SKalle Valo return ret; 3042bdcd8170SKalle Valo } 3043bdcd8170SKalle Valo 3044990bd915SVasanthakumar Thiagarajan int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx) 3045bdcd8170SKalle Valo { 3046990bd915SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID); 3047bdcd8170SKalle Valo } 3048bdcd8170SKalle Valo 30494b28a80dSJouni Malinen int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi) 30504b28a80dSJouni Malinen { 3051334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID); 30524b28a80dSJouni Malinen } 30534b28a80dSJouni Malinen 30540ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status, 30550ce59445SVasanthakumar Thiagarajan u8 preamble_policy) 3056bdcd8170SKalle Valo { 3057bdcd8170SKalle Valo struct sk_buff *skb; 3058bdcd8170SKalle Valo struct wmi_set_lpreamble_cmd *cmd; 3059bdcd8170SKalle Valo int ret; 3060bdcd8170SKalle Valo 3061bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); 3062bdcd8170SKalle Valo if (!skb) 3063bdcd8170SKalle Valo return -ENOMEM; 3064bdcd8170SKalle Valo 3065bdcd8170SKalle Valo cmd = (struct wmi_set_lpreamble_cmd *) skb->data; 3066bdcd8170SKalle Valo cmd->status = status; 3067bdcd8170SKalle Valo cmd->preamble_policy = preamble_policy; 3068bdcd8170SKalle Valo 30690ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID, 3070bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 3071bdcd8170SKalle Valo return ret; 3072bdcd8170SKalle Valo } 3073bdcd8170SKalle Valo 3074bdcd8170SKalle Valo int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) 3075bdcd8170SKalle Valo { 3076bdcd8170SKalle Valo struct sk_buff *skb; 3077bdcd8170SKalle Valo struct wmi_set_rts_cmd *cmd; 3078bdcd8170SKalle Valo int ret; 3079bdcd8170SKalle Valo 3080bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); 3081bdcd8170SKalle Valo if (!skb) 3082bdcd8170SKalle Valo return -ENOMEM; 3083bdcd8170SKalle Valo 3084bdcd8170SKalle Valo cmd = (struct wmi_set_rts_cmd *) skb->data; 3085bdcd8170SKalle Valo cmd->threshold = cpu_to_le16(threshold); 3086bdcd8170SKalle Valo 3087334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID, 3088334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 3089bdcd8170SKalle Valo return ret; 3090bdcd8170SKalle Valo } 3091bdcd8170SKalle Valo 30920ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg) 3093bdcd8170SKalle Valo { 3094bdcd8170SKalle Valo struct sk_buff *skb; 3095bdcd8170SKalle Valo struct wmi_set_wmm_txop_cmd *cmd; 3096bdcd8170SKalle Valo int ret; 3097bdcd8170SKalle Valo 3098bdcd8170SKalle Valo if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) 3099bdcd8170SKalle Valo return -EINVAL; 3100bdcd8170SKalle Valo 3101bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); 3102bdcd8170SKalle Valo if (!skb) 3103bdcd8170SKalle Valo return -ENOMEM; 3104bdcd8170SKalle Valo 3105bdcd8170SKalle Valo cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; 3106bdcd8170SKalle Valo cmd->txop_enable = cfg; 3107bdcd8170SKalle Valo 31080ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID, 3109bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 3110bdcd8170SKalle Valo return ret; 3111bdcd8170SKalle Valo } 3112bdcd8170SKalle Valo 31130ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx, 31140ce59445SVasanthakumar Thiagarajan u8 keep_alive_intvl) 3115bdcd8170SKalle Valo { 3116bdcd8170SKalle Valo struct sk_buff *skb; 3117bdcd8170SKalle Valo struct wmi_set_keepalive_cmd *cmd; 3118bdcd8170SKalle Valo int ret; 3119bdcd8170SKalle Valo 3120bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3121bdcd8170SKalle Valo if (!skb) 3122bdcd8170SKalle Valo return -ENOMEM; 3123bdcd8170SKalle Valo 3124bdcd8170SKalle Valo cmd = (struct wmi_set_keepalive_cmd *) skb->data; 3125bdcd8170SKalle Valo cmd->keep_alive_intvl = keep_alive_intvl; 3126bdcd8170SKalle Valo 31270ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID, 3128bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 3129334234b5SVasanthakumar Thiagarajan 3130ff0b0075SJouni Malinen if (ret == 0) 3131ff0b0075SJouni Malinen ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl); 3132334234b5SVasanthakumar Thiagarajan 3133bdcd8170SKalle Valo return ret; 3134bdcd8170SKalle Valo } 3135bdcd8170SKalle Valo 3136df90b369SVasanthakumar Thiagarajan int ath6kl_wmi_set_htcap_cmd(struct wmi *wmi, u8 if_idx, 3137df90b369SVasanthakumar Thiagarajan enum ieee80211_band band, 3138df90b369SVasanthakumar Thiagarajan struct ath6kl_htcap *htcap) 3139df90b369SVasanthakumar Thiagarajan { 3140df90b369SVasanthakumar Thiagarajan struct sk_buff *skb; 3141df90b369SVasanthakumar Thiagarajan struct wmi_set_htcap_cmd *cmd; 3142df90b369SVasanthakumar Thiagarajan 3143df90b369SVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3144df90b369SVasanthakumar Thiagarajan if (!skb) 3145df90b369SVasanthakumar Thiagarajan return -ENOMEM; 3146df90b369SVasanthakumar Thiagarajan 3147df90b369SVasanthakumar Thiagarajan cmd = (struct wmi_set_htcap_cmd *) skb->data; 3148df90b369SVasanthakumar Thiagarajan 3149df90b369SVasanthakumar Thiagarajan /* 3150df90b369SVasanthakumar Thiagarajan * NOTE: Band in firmware matches enum ieee80211_band, it is unlikely 3151df90b369SVasanthakumar Thiagarajan * this will be changed in firmware. If at all there is any change in 3152df90b369SVasanthakumar Thiagarajan * band value, the host needs to be fixed. 3153df90b369SVasanthakumar Thiagarajan */ 3154df90b369SVasanthakumar Thiagarajan cmd->band = band; 3155df90b369SVasanthakumar Thiagarajan cmd->ht_enable = !!htcap->ht_enable; 3156df90b369SVasanthakumar Thiagarajan cmd->ht20_sgi = !!(htcap->cap_info & IEEE80211_HT_CAP_SGI_20); 3157df90b369SVasanthakumar Thiagarajan cmd->ht40_supported = 3158df90b369SVasanthakumar Thiagarajan !!(htcap->cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40); 3159df90b369SVasanthakumar Thiagarajan cmd->ht40_sgi = !!(htcap->cap_info & IEEE80211_HT_CAP_SGI_40); 3160df90b369SVasanthakumar Thiagarajan cmd->intolerant_40mhz = 3161df90b369SVasanthakumar Thiagarajan !!(htcap->cap_info & IEEE80211_HT_CAP_40MHZ_INTOLERANT); 3162df90b369SVasanthakumar Thiagarajan cmd->max_ampdu_len_exp = htcap->ampdu_factor; 3163df90b369SVasanthakumar Thiagarajan 3164df90b369SVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, 3165df90b369SVasanthakumar Thiagarajan "Set htcap: band:%d ht_enable:%d 40mhz:%d sgi_20mhz:%d sgi_40mhz:%d 40mhz_intolerant:%d ampdu_len_exp:%d\n", 3166df90b369SVasanthakumar Thiagarajan cmd->band, cmd->ht_enable, cmd->ht40_supported, 3167df90b369SVasanthakumar Thiagarajan cmd->ht20_sgi, cmd->ht40_sgi, cmd->intolerant_40mhz, 3168df90b369SVasanthakumar Thiagarajan cmd->max_ampdu_len_exp); 3169df90b369SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_HT_CAP_CMDID, 3170df90b369SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 3171df90b369SVasanthakumar Thiagarajan } 3172df90b369SVasanthakumar Thiagarajan 3173003353b0SKalle Valo int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) 3174003353b0SKalle Valo { 3175003353b0SKalle Valo struct sk_buff *skb; 3176003353b0SKalle Valo int ret; 3177003353b0SKalle Valo 3178003353b0SKalle Valo skb = ath6kl_wmi_get_new_buf(len); 3179003353b0SKalle Valo if (!skb) 3180003353b0SKalle Valo return -ENOMEM; 3181003353b0SKalle Valo 3182003353b0SKalle Valo memcpy(skb->data, buf, len); 3183003353b0SKalle Valo 3184334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); 3185003353b0SKalle Valo 3186003353b0SKalle Valo return ret; 3187003353b0SKalle Valo } 3188003353b0SKalle Valo 31893f3c4ee7SVasanthakumar Thiagarajan int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on) 31903f3c4ee7SVasanthakumar Thiagarajan { 31913f3c4ee7SVasanthakumar Thiagarajan struct sk_buff *skb; 31923f3c4ee7SVasanthakumar Thiagarajan struct wmi_mcast_filter_cmd *cmd; 31933f3c4ee7SVasanthakumar Thiagarajan int ret; 31943f3c4ee7SVasanthakumar Thiagarajan 31953f3c4ee7SVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 31963f3c4ee7SVasanthakumar Thiagarajan if (!skb) 31973f3c4ee7SVasanthakumar Thiagarajan return -ENOMEM; 31983f3c4ee7SVasanthakumar Thiagarajan 31993f3c4ee7SVasanthakumar Thiagarajan cmd = (struct wmi_mcast_filter_cmd *) skb->data; 32003f3c4ee7SVasanthakumar Thiagarajan cmd->mcast_all_enable = mc_all_on; 32013f3c4ee7SVasanthakumar Thiagarajan 32023f3c4ee7SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_MCAST_FILTER_CMDID, 32033f3c4ee7SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 32043f3c4ee7SVasanthakumar Thiagarajan return ret; 32053f3c4ee7SVasanthakumar Thiagarajan } 3206003353b0SKalle Valo 3207f914edd3SVasanthakumar Thiagarajan int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, 3208f914edd3SVasanthakumar Thiagarajan u8 *filter, bool add_filter) 3209f914edd3SVasanthakumar Thiagarajan { 3210f914edd3SVasanthakumar Thiagarajan struct sk_buff *skb; 3211f914edd3SVasanthakumar Thiagarajan struct wmi_mcast_filter_add_del_cmd *cmd; 3212f914edd3SVasanthakumar Thiagarajan int ret; 3213f914edd3SVasanthakumar Thiagarajan 3214f914edd3SVasanthakumar Thiagarajan if ((filter[0] != 0x33 || filter[1] != 0x33) && 3215f914edd3SVasanthakumar Thiagarajan (filter[0] != 0x01 || filter[1] != 0x00 || 3216f914edd3SVasanthakumar Thiagarajan filter[2] != 0x5e || filter[3] > 0x7f)) { 3217f914edd3SVasanthakumar Thiagarajan ath6kl_warn("invalid multicast filter address\n"); 3218f914edd3SVasanthakumar Thiagarajan return -EINVAL; 3219f914edd3SVasanthakumar Thiagarajan } 3220f914edd3SVasanthakumar Thiagarajan 3221f914edd3SVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3222f914edd3SVasanthakumar Thiagarajan if (!skb) 3223f914edd3SVasanthakumar Thiagarajan return -ENOMEM; 3224f914edd3SVasanthakumar Thiagarajan 3225f914edd3SVasanthakumar Thiagarajan cmd = (struct wmi_mcast_filter_add_del_cmd *) skb->data; 3226f914edd3SVasanthakumar Thiagarajan memcpy(cmd->mcast_mac, filter, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE); 3227f914edd3SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, 3228f914edd3SVasanthakumar Thiagarajan add_filter ? WMI_SET_MCAST_FILTER_CMDID : 3229f914edd3SVasanthakumar Thiagarajan WMI_DEL_MCAST_FILTER_CMDID, 3230f914edd3SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 3231f914edd3SVasanthakumar Thiagarajan 3232f914edd3SVasanthakumar Thiagarajan return ret; 3233f914edd3SVasanthakumar Thiagarajan } 3234f914edd3SVasanthakumar Thiagarajan 3235c422d52dSThomas Pedersen int ath6kl_wmi_sta_bmiss_enhance_cmd(struct wmi *wmi, u8 if_idx, bool enhance) 3236c422d52dSThomas Pedersen { 3237c422d52dSThomas Pedersen struct sk_buff *skb; 3238c422d52dSThomas Pedersen struct wmi_sta_bmiss_enhance_cmd *cmd; 3239c422d52dSThomas Pedersen int ret; 3240c422d52dSThomas Pedersen 3241c422d52dSThomas Pedersen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3242c422d52dSThomas Pedersen if (!skb) 3243c422d52dSThomas Pedersen return -ENOMEM; 3244c422d52dSThomas Pedersen 3245c422d52dSThomas Pedersen cmd = (struct wmi_sta_bmiss_enhance_cmd *) skb->data; 3246c422d52dSThomas Pedersen cmd->enable = enhance ? 1 : 0; 3247c422d52dSThomas Pedersen 3248c422d52dSThomas Pedersen ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, 3249c422d52dSThomas Pedersen WMI_STA_BMISS_ENHANCE_CMDID, 3250c422d52dSThomas Pedersen NO_SYNC_WMIFLAG); 3251c422d52dSThomas Pedersen return ret; 3252c422d52dSThomas Pedersen } 3253c422d52dSThomas Pedersen 325484841ba2SKalle Valo int ath6kl_wmi_set_regdomain_cmd(struct wmi *wmi, const char *alpha2) 325584841ba2SKalle Valo { 325684841ba2SKalle Valo struct sk_buff *skb; 325784841ba2SKalle Valo struct wmi_set_regdomain_cmd *cmd; 325884841ba2SKalle Valo 325984841ba2SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 326084841ba2SKalle Valo if (!skb) 326184841ba2SKalle Valo return -ENOMEM; 326284841ba2SKalle Valo 326384841ba2SKalle Valo cmd = (struct wmi_set_regdomain_cmd *) skb->data; 326484841ba2SKalle Valo memcpy(cmd->iso_name, alpha2, 2); 326584841ba2SKalle Valo 326684841ba2SKalle Valo return ath6kl_wmi_cmd_send(wmi, 0, skb, 326784841ba2SKalle Valo WMI_SET_REGDOMAIN_CMDID, 326884841ba2SKalle Valo NO_SYNC_WMIFLAG); 326984841ba2SKalle Valo } 327084841ba2SKalle Valo 3271bdcd8170SKalle Valo s32 ath6kl_wmi_get_rate(s8 rate_index) 3272bdcd8170SKalle Valo { 327383685091SDengke Qiu u8 sgi = 0; 327483685091SDengke Qiu 3275bdcd8170SKalle Valo if (rate_index == RATE_AUTO) 3276bdcd8170SKalle Valo return 0; 3277bdcd8170SKalle Valo 327883685091SDengke Qiu /* SGI is stored as the MSB of the rate_index */ 327983685091SDengke Qiu if (rate_index & RATE_INDEX_MSB) { 328083685091SDengke Qiu rate_index &= RATE_INDEX_WITHOUT_SGI_MASK; 328183685091SDengke Qiu sgi = 1; 328283685091SDengke Qiu } 328383685091SDengke Qiu 328483685091SDengke Qiu if (WARN_ON(rate_index > RATE_MCS_7_40)) 328583685091SDengke Qiu rate_index = RATE_MCS_7_40; 328683685091SDengke Qiu 328783685091SDengke Qiu return wmi_rate_tbl[(u32) rate_index][sgi]; 3288bdcd8170SKalle Valo } 3289bdcd8170SKalle Valo 3290bdcd8170SKalle Valo static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, 3291bdcd8170SKalle Valo u32 len) 3292bdcd8170SKalle Valo { 3293bdcd8170SKalle Valo struct wmi_pmkid_list_reply *reply; 3294bdcd8170SKalle Valo u32 expected_len; 3295bdcd8170SKalle Valo 3296bdcd8170SKalle Valo if (len < sizeof(struct wmi_pmkid_list_reply)) 3297bdcd8170SKalle Valo return -EINVAL; 3298bdcd8170SKalle Valo 3299bdcd8170SKalle Valo reply = (struct wmi_pmkid_list_reply *)datap; 3300bdcd8170SKalle Valo expected_len = sizeof(reply->num_pmkid) + 3301bdcd8170SKalle Valo le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; 3302bdcd8170SKalle Valo 3303bdcd8170SKalle Valo if (len < expected_len) 3304bdcd8170SKalle Valo return -EINVAL; 3305bdcd8170SKalle Valo 3306bdcd8170SKalle Valo return 0; 3307bdcd8170SKalle Valo } 3308bdcd8170SKalle Valo 3309240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len, 3310240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 3311bdcd8170SKalle Valo { 3312bdcd8170SKalle Valo struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; 3313bdcd8170SKalle Valo 3314240d2799SVasanthakumar Thiagarajan aggr_recv_addba_req_evt(vif, cmd->tid, 3315bdcd8170SKalle Valo le16_to_cpu(cmd->st_seq_no), cmd->win_sz); 3316bdcd8170SKalle Valo 3317bdcd8170SKalle Valo return 0; 3318bdcd8170SKalle Valo } 3319bdcd8170SKalle Valo 3320240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len, 3321240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 3322bdcd8170SKalle Valo { 3323bdcd8170SKalle Valo struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; 3324bdcd8170SKalle Valo 3325240d2799SVasanthakumar Thiagarajan aggr_recv_delba_req_evt(vif, cmd->tid); 3326bdcd8170SKalle Valo 3327bdcd8170SKalle Valo return 0; 3328bdcd8170SKalle Valo } 3329bdcd8170SKalle Valo 3330bdcd8170SKalle Valo /* AP mode functions */ 33316a7c9badSJouni Malinen 3332334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, 3333334234b5SVasanthakumar Thiagarajan struct wmi_connect_cmd *p) 33346a7c9badSJouni Malinen { 33356a7c9badSJouni Malinen struct sk_buff *skb; 33366a7c9badSJouni Malinen struct wmi_connect_cmd *cm; 33376a7c9badSJouni Malinen int res; 33386a7c9badSJouni Malinen 33396a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 33406a7c9badSJouni Malinen if (!skb) 33416a7c9badSJouni Malinen return -ENOMEM; 33426a7c9badSJouni Malinen 33436a7c9badSJouni Malinen cm = (struct wmi_connect_cmd *) skb->data; 33446a7c9badSJouni Malinen memcpy(cm, p, sizeof(*cm)); 33456a7c9badSJouni Malinen 3346334234b5SVasanthakumar Thiagarajan res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID, 33476a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 3348cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3349cdeb8602SKalle Valo "%s: nw_type=%u auth_mode=%u ch=%u ctrl_flags=0x%x-> res=%d\n", 33506a7c9badSJouni Malinen __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), 33516a7c9badSJouni Malinen le32_to_cpu(p->ctrl_flags), res); 33526a7c9badSJouni Malinen return res; 33536a7c9badSJouni Malinen } 33546a7c9badSJouni Malinen 3355334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac, 3356334234b5SVasanthakumar Thiagarajan u16 reason) 335723875136SJouni Malinen { 335823875136SJouni Malinen struct sk_buff *skb; 335923875136SJouni Malinen struct wmi_ap_set_mlme_cmd *cm; 336023875136SJouni Malinen 336123875136SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 336223875136SJouni Malinen if (!skb) 336323875136SJouni Malinen return -ENOMEM; 336423875136SJouni Malinen 336523875136SJouni Malinen cm = (struct wmi_ap_set_mlme_cmd *) skb->data; 336623875136SJouni Malinen memcpy(cm->mac, mac, ETH_ALEN); 336723875136SJouni Malinen cm->reason = cpu_to_le16(reason); 336823875136SJouni Malinen cm->cmd = cmd; 336923875136SJouni Malinen 33707397ddebSAarthi Thiruvengadam ath6kl_dbg(ATH6KL_DBG_WMI, "ap_set_mlme: cmd=%d reason=%d\n", cm->cmd, 33717397ddebSAarthi Thiruvengadam cm->reason); 33727397ddebSAarthi Thiruvengadam 3373334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID, 337423875136SJouni Malinen NO_SYNC_WMIFLAG); 337523875136SJouni Malinen } 337623875136SJouni Malinen 337767cd22e4SThomas Pedersen int ath6kl_wmi_ap_hidden_ssid(struct wmi *wmi, u8 if_idx, bool enable) 337867cd22e4SThomas Pedersen { 337967cd22e4SThomas Pedersen struct sk_buff *skb; 338067cd22e4SThomas Pedersen struct wmi_ap_hidden_ssid_cmd *cmd; 338167cd22e4SThomas Pedersen 338267cd22e4SThomas Pedersen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 338367cd22e4SThomas Pedersen if (!skb) 338467cd22e4SThomas Pedersen return -ENOMEM; 338567cd22e4SThomas Pedersen 338667cd22e4SThomas Pedersen cmd = (struct wmi_ap_hidden_ssid_cmd *) skb->data; 338767cd22e4SThomas Pedersen cmd->hidden_ssid = enable ? 1 : 0; 338867cd22e4SThomas Pedersen 338967cd22e4SThomas Pedersen return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_HIDDEN_SSID_CMDID, 339067cd22e4SThomas Pedersen NO_SYNC_WMIFLAG); 339167cd22e4SThomas Pedersen } 339267cd22e4SThomas Pedersen 3393c1762a3fSThirumalai Pachamuthu /* This command will be used to enable/disable AP uAPSD feature */ 3394c1762a3fSThirumalai Pachamuthu int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable) 3395c1762a3fSThirumalai Pachamuthu { 3396c1762a3fSThirumalai Pachamuthu struct wmi_ap_set_apsd_cmd *cmd; 3397c1762a3fSThirumalai Pachamuthu struct sk_buff *skb; 3398c1762a3fSThirumalai Pachamuthu 3399c1762a3fSThirumalai Pachamuthu skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3400c1762a3fSThirumalai Pachamuthu if (!skb) 3401c1762a3fSThirumalai Pachamuthu return -ENOMEM; 3402c1762a3fSThirumalai Pachamuthu 3403c1762a3fSThirumalai Pachamuthu cmd = (struct wmi_ap_set_apsd_cmd *)skb->data; 3404c1762a3fSThirumalai Pachamuthu cmd->enable = enable; 3405c1762a3fSThirumalai Pachamuthu 3406c1762a3fSThirumalai Pachamuthu return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_APSD_CMDID, 3407c1762a3fSThirumalai Pachamuthu NO_SYNC_WMIFLAG); 3408c1762a3fSThirumalai Pachamuthu } 3409c1762a3fSThirumalai Pachamuthu 3410c1762a3fSThirumalai Pachamuthu int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, u8 if_idx, 3411c1762a3fSThirumalai Pachamuthu u16 aid, u16 bitmap, u32 flags) 3412c1762a3fSThirumalai Pachamuthu { 3413c1762a3fSThirumalai Pachamuthu struct wmi_ap_apsd_buffered_traffic_cmd *cmd; 3414c1762a3fSThirumalai Pachamuthu struct sk_buff *skb; 3415c1762a3fSThirumalai Pachamuthu 3416c1762a3fSThirumalai Pachamuthu skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3417c1762a3fSThirumalai Pachamuthu if (!skb) 3418c1762a3fSThirumalai Pachamuthu return -ENOMEM; 3419c1762a3fSThirumalai Pachamuthu 3420c1762a3fSThirumalai Pachamuthu cmd = (struct wmi_ap_apsd_buffered_traffic_cmd *)skb->data; 3421c1762a3fSThirumalai Pachamuthu cmd->aid = cpu_to_le16(aid); 3422c1762a3fSThirumalai Pachamuthu cmd->bitmap = cpu_to_le16(bitmap); 3423c1762a3fSThirumalai Pachamuthu cmd->flags = cpu_to_le32(flags); 3424c1762a3fSThirumalai Pachamuthu 3425c1762a3fSThirumalai Pachamuthu return ath6kl_wmi_cmd_send(wmi, if_idx, skb, 3426c1762a3fSThirumalai Pachamuthu WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID, 3427c1762a3fSThirumalai Pachamuthu NO_SYNC_WMIFLAG); 3428c1762a3fSThirumalai Pachamuthu } 3429c1762a3fSThirumalai Pachamuthu 3430240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len, 3431240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 3432bdcd8170SKalle Valo { 3433bdcd8170SKalle Valo struct wmi_pspoll_event *ev; 3434bdcd8170SKalle Valo 3435bdcd8170SKalle Valo if (len < sizeof(struct wmi_pspoll_event)) 3436bdcd8170SKalle Valo return -EINVAL; 3437bdcd8170SKalle Valo 3438bdcd8170SKalle Valo ev = (struct wmi_pspoll_event *) datap; 3439bdcd8170SKalle Valo 3440240d2799SVasanthakumar Thiagarajan ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid)); 3441bdcd8170SKalle Valo 3442bdcd8170SKalle Valo return 0; 3443bdcd8170SKalle Valo } 3444bdcd8170SKalle Valo 3445240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len, 3446240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 3447bdcd8170SKalle Valo { 3448240d2799SVasanthakumar Thiagarajan ath6kl_dtimexpiry_event(vif); 3449bdcd8170SKalle Valo 3450bdcd8170SKalle Valo return 0; 3451bdcd8170SKalle Valo } 3452bdcd8170SKalle Valo 3453334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid, 3454334234b5SVasanthakumar Thiagarajan bool flag) 3455bdcd8170SKalle Valo { 3456bdcd8170SKalle Valo struct sk_buff *skb; 3457bdcd8170SKalle Valo struct wmi_ap_set_pvb_cmd *cmd; 3458bdcd8170SKalle Valo int ret; 3459bdcd8170SKalle Valo 3460bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); 3461bdcd8170SKalle Valo if (!skb) 3462bdcd8170SKalle Valo return -ENOMEM; 3463bdcd8170SKalle Valo 3464bdcd8170SKalle Valo cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; 3465bdcd8170SKalle Valo cmd->aid = cpu_to_le16(aid); 3466d6e51e6aSJouni Malinen cmd->rsvd = cpu_to_le16(0); 3467bdcd8170SKalle Valo cmd->flag = cpu_to_le32(flag); 3468bdcd8170SKalle Valo 3469334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID, 3470bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 3471bdcd8170SKalle Valo 3472bdcd8170SKalle Valo return 0; 3473bdcd8170SKalle Valo } 3474bdcd8170SKalle Valo 34750ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx, 34760ce59445SVasanthakumar Thiagarajan u8 rx_meta_ver, 3477bdcd8170SKalle Valo bool rx_dot11_hdr, bool defrag_on_host) 3478bdcd8170SKalle Valo { 3479bdcd8170SKalle Valo struct sk_buff *skb; 3480bdcd8170SKalle Valo struct wmi_rx_frame_format_cmd *cmd; 3481bdcd8170SKalle Valo int ret; 3482bdcd8170SKalle Valo 3483bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3484bdcd8170SKalle Valo if (!skb) 3485bdcd8170SKalle Valo return -ENOMEM; 3486bdcd8170SKalle Valo 3487bdcd8170SKalle Valo cmd = (struct wmi_rx_frame_format_cmd *) skb->data; 3488bdcd8170SKalle Valo cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; 3489bdcd8170SKalle Valo cmd->defrag_on_host = defrag_on_host ? 1 : 0; 3490bdcd8170SKalle Valo cmd->meta_ver = rx_meta_ver; 3491bdcd8170SKalle Valo 3492bdcd8170SKalle Valo /* Delete the local aggr state, on host */ 34930ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID, 3494bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 3495bdcd8170SKalle Valo 3496bdcd8170SKalle Valo return ret; 3497bdcd8170SKalle Valo } 3498bdcd8170SKalle Valo 3499334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, 3500334234b5SVasanthakumar Thiagarajan const u8 *ie, u8 ie_len) 35016a7c9badSJouni Malinen { 35026a7c9badSJouni Malinen struct sk_buff *skb; 35036a7c9badSJouni Malinen struct wmi_set_appie_cmd *p; 35046a7c9badSJouni Malinen 35056a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 35066a7c9badSJouni Malinen if (!skb) 35076a7c9badSJouni Malinen return -ENOMEM; 35086a7c9badSJouni Malinen 3509cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3510cdeb8602SKalle Valo "set_appie_cmd: mgmt_frm_type=%u ie_len=%u\n", 3511cdeb8602SKalle Valo mgmt_frm_type, ie_len); 35126a7c9badSJouni Malinen p = (struct wmi_set_appie_cmd *) skb->data; 35136a7c9badSJouni Malinen p->mgmt_frm_type = mgmt_frm_type; 35146a7c9badSJouni Malinen p->ie_len = ie_len; 351510509f90SKalle Valo 351610509f90SKalle Valo if (ie != NULL && ie_len > 0) 35176a7c9badSJouni Malinen memcpy(p->ie_info, ie, ie_len); 351810509f90SKalle Valo 3519334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID, 35206a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 35216a7c9badSJouni Malinen } 35226a7c9badSJouni Malinen 3523d97c121bSVasanthakumar Thiagarajan int ath6kl_wmi_set_ie_cmd(struct wmi *wmi, u8 if_idx, u8 ie_id, u8 ie_field, 3524d97c121bSVasanthakumar Thiagarajan const u8 *ie_info, u8 ie_len) 3525d97c121bSVasanthakumar Thiagarajan { 3526d97c121bSVasanthakumar Thiagarajan struct sk_buff *skb; 3527d97c121bSVasanthakumar Thiagarajan struct wmi_set_ie_cmd *p; 3528d97c121bSVasanthakumar Thiagarajan 3529d97c121bSVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 3530d97c121bSVasanthakumar Thiagarajan if (!skb) 3531d97c121bSVasanthakumar Thiagarajan return -ENOMEM; 3532d97c121bSVasanthakumar Thiagarajan 3533d97c121bSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "set_ie_cmd: ie_id=%u ie_ie_field=%u ie_len=%u\n", 3534d97c121bSVasanthakumar Thiagarajan ie_id, ie_field, ie_len); 3535d97c121bSVasanthakumar Thiagarajan p = (struct wmi_set_ie_cmd *) skb->data; 3536d97c121bSVasanthakumar Thiagarajan p->ie_id = ie_id; 3537d97c121bSVasanthakumar Thiagarajan p->ie_field = ie_field; 3538d97c121bSVasanthakumar Thiagarajan p->ie_len = ie_len; 3539d97c121bSVasanthakumar Thiagarajan if (ie_info && ie_len > 0) 3540d97c121bSVasanthakumar Thiagarajan memcpy(p->ie_info, ie_info, ie_len); 3541d97c121bSVasanthakumar Thiagarajan 3542d97c121bSVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IE_CMDID, 3543d97c121bSVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 3544d97c121bSVasanthakumar Thiagarajan } 3545d97c121bSVasanthakumar Thiagarajan 35466465ddcfSJouni Malinen int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) 35476465ddcfSJouni Malinen { 35486465ddcfSJouni Malinen struct sk_buff *skb; 35496465ddcfSJouni Malinen struct wmi_disable_11b_rates_cmd *cmd; 35506465ddcfSJouni Malinen 35516465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 35526465ddcfSJouni Malinen if (!skb) 35536465ddcfSJouni Malinen return -ENOMEM; 35546465ddcfSJouni Malinen 35556465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", 35566465ddcfSJouni Malinen disable); 35576465ddcfSJouni Malinen cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; 35586465ddcfSJouni Malinen cmd->disable = disable ? 1 : 0; 35596465ddcfSJouni Malinen 3560334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID, 35616465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 35626465ddcfSJouni Malinen } 35636465ddcfSJouni Malinen 3564334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur) 35656465ddcfSJouni Malinen { 35666465ddcfSJouni Malinen struct sk_buff *skb; 35676465ddcfSJouni Malinen struct wmi_remain_on_chnl_cmd *p; 35686465ddcfSJouni Malinen 35696465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 35706465ddcfSJouni Malinen if (!skb) 35716465ddcfSJouni Malinen return -ENOMEM; 35726465ddcfSJouni Malinen 35736465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", 35746465ddcfSJouni Malinen freq, dur); 35756465ddcfSJouni Malinen p = (struct wmi_remain_on_chnl_cmd *) skb->data; 35766465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 35776465ddcfSJouni Malinen p->duration = cpu_to_le32(dur); 3578334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID, 35796465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 35806465ddcfSJouni Malinen } 35816465ddcfSJouni Malinen 35823ca9d1fcSAarthi Thiruvengadam /* ath6kl_wmi_send_action_cmd is to be deprecated. Use 35833ca9d1fcSAarthi Thiruvengadam * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P 35843ca9d1fcSAarthi Thiruvengadam * mgmt operations using station interface. 35853ca9d1fcSAarthi Thiruvengadam */ 3586d0ff7383SNaveen Gangadharan static int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, 3587d0ff7383SNaveen Gangadharan u32 freq, u32 wait, const u8 *data, 3588d0ff7383SNaveen Gangadharan u16 data_len) 35896465ddcfSJouni Malinen { 35906465ddcfSJouni Malinen struct sk_buff *skb; 35916465ddcfSJouni Malinen struct wmi_send_action_cmd *p; 3592a0df5db1SJouni Malinen u8 *buf; 35936465ddcfSJouni Malinen 35946465ddcfSJouni Malinen if (wait) 35956465ddcfSJouni Malinen return -EINVAL; /* Offload for wait not supported */ 35966465ddcfSJouni Malinen 3597a0df5db1SJouni Malinen buf = kmalloc(data_len, GFP_KERNEL); 3598a0df5db1SJouni Malinen if (!buf) 35996465ddcfSJouni Malinen return -ENOMEM; 36006465ddcfSJouni Malinen 3601a0df5db1SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 3602a0df5db1SJouni Malinen if (!skb) { 3603a0df5db1SJouni Malinen kfree(buf); 3604a0df5db1SJouni Malinen return -ENOMEM; 3605a0df5db1SJouni Malinen } 3606a0df5db1SJouni Malinen 3607a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 36083101edefSAarthi Thiruvengadam memcpy(buf, data, data_len); 3609a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = buf; 3610a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = data_len; 3611a0df5db1SJouni Malinen 3612cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3613cdeb8602SKalle Valo "send_action_cmd: id=%u freq=%u wait=%u len=%u\n", 3614cdeb8602SKalle Valo id, freq, wait, data_len); 36156465ddcfSJouni Malinen p = (struct wmi_send_action_cmd *) skb->data; 36166465ddcfSJouni Malinen p->id = cpu_to_le32(id); 36176465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 36186465ddcfSJouni Malinen p->wait = cpu_to_le32(wait); 36196465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 36206465ddcfSJouni Malinen memcpy(p->data, data, data_len); 3621334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID, 36226465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 36236465ddcfSJouni Malinen } 36246465ddcfSJouni Malinen 3625d0ff7383SNaveen Gangadharan static int __ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, 3626d0ff7383SNaveen Gangadharan u32 freq, u32 wait, const u8 *data, 3627d0ff7383SNaveen Gangadharan u16 data_len, u32 no_cck) 36283ca9d1fcSAarthi Thiruvengadam { 36293ca9d1fcSAarthi Thiruvengadam struct sk_buff *skb; 36303ca9d1fcSAarthi Thiruvengadam struct wmi_send_mgmt_cmd *p; 36313ca9d1fcSAarthi Thiruvengadam u8 *buf; 36323ca9d1fcSAarthi Thiruvengadam 36333ca9d1fcSAarthi Thiruvengadam if (wait) 36343ca9d1fcSAarthi Thiruvengadam return -EINVAL; /* Offload for wait not supported */ 36353ca9d1fcSAarthi Thiruvengadam 36363ca9d1fcSAarthi Thiruvengadam buf = kmalloc(data_len, GFP_KERNEL); 36373ca9d1fcSAarthi Thiruvengadam if (!buf) 36383ca9d1fcSAarthi Thiruvengadam return -ENOMEM; 36393ca9d1fcSAarthi Thiruvengadam 36403ca9d1fcSAarthi Thiruvengadam skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 36413ca9d1fcSAarthi Thiruvengadam if (!skb) { 36423ca9d1fcSAarthi Thiruvengadam kfree(buf); 36433ca9d1fcSAarthi Thiruvengadam return -ENOMEM; 36443ca9d1fcSAarthi Thiruvengadam } 36453ca9d1fcSAarthi Thiruvengadam 36463ca9d1fcSAarthi Thiruvengadam kfree(wmi->last_mgmt_tx_frame); 36473ca9d1fcSAarthi Thiruvengadam memcpy(buf, data, data_len); 36483ca9d1fcSAarthi Thiruvengadam wmi->last_mgmt_tx_frame = buf; 36493ca9d1fcSAarthi Thiruvengadam wmi->last_mgmt_tx_frame_len = data_len; 36503ca9d1fcSAarthi Thiruvengadam 3651cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3652cdeb8602SKalle Valo "send_action_cmd: id=%u freq=%u wait=%u len=%u\n", 3653cdeb8602SKalle Valo id, freq, wait, data_len); 36543ca9d1fcSAarthi Thiruvengadam p = (struct wmi_send_mgmt_cmd *) skb->data; 36553ca9d1fcSAarthi Thiruvengadam p->id = cpu_to_le32(id); 36563ca9d1fcSAarthi Thiruvengadam p->freq = cpu_to_le32(freq); 36573ca9d1fcSAarthi Thiruvengadam p->wait = cpu_to_le32(wait); 36583ca9d1fcSAarthi Thiruvengadam p->no_cck = cpu_to_le32(no_cck); 36593ca9d1fcSAarthi Thiruvengadam p->len = cpu_to_le16(data_len); 36603ca9d1fcSAarthi Thiruvengadam memcpy(p->data, data, data_len); 36613ca9d1fcSAarthi Thiruvengadam return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_MGMT_CMDID, 36623ca9d1fcSAarthi Thiruvengadam NO_SYNC_WMIFLAG); 36633ca9d1fcSAarthi Thiruvengadam } 36643ca9d1fcSAarthi Thiruvengadam 3665d0ff7383SNaveen Gangadharan int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, 3666d0ff7383SNaveen Gangadharan u32 wait, const u8 *data, u16 data_len, 3667d0ff7383SNaveen Gangadharan u32 no_cck) 3668d0ff7383SNaveen Gangadharan { 3669d0ff7383SNaveen Gangadharan int status; 3670d0ff7383SNaveen Gangadharan struct ath6kl *ar = wmi->parent_dev; 3671d0ff7383SNaveen Gangadharan 3672d0ff7383SNaveen Gangadharan if (test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX, 3673d0ff7383SNaveen Gangadharan ar->fw_capabilities)) { 3674d0ff7383SNaveen Gangadharan /* 3675d0ff7383SNaveen Gangadharan * If capable of doing P2P mgmt operations using 3676d0ff7383SNaveen Gangadharan * station interface, send additional information like 3677d0ff7383SNaveen Gangadharan * supported rates to advertise and xmit rates for 3678d0ff7383SNaveen Gangadharan * probe requests 3679d0ff7383SNaveen Gangadharan */ 3680d0ff7383SNaveen Gangadharan status = __ath6kl_wmi_send_mgmt_cmd(ar->wmi, if_idx, id, freq, 3681d0ff7383SNaveen Gangadharan wait, data, data_len, 3682d0ff7383SNaveen Gangadharan no_cck); 3683d0ff7383SNaveen Gangadharan } else { 3684d0ff7383SNaveen Gangadharan status = ath6kl_wmi_send_action_cmd(ar->wmi, if_idx, id, freq, 3685d0ff7383SNaveen Gangadharan wait, data, data_len); 3686d0ff7383SNaveen Gangadharan } 3687d0ff7383SNaveen Gangadharan 3688d0ff7383SNaveen Gangadharan return status; 3689d0ff7383SNaveen Gangadharan } 3690d0ff7383SNaveen Gangadharan 3691334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, 3692334234b5SVasanthakumar Thiagarajan const u8 *dst, const u8 *data, 3693334234b5SVasanthakumar Thiagarajan u16 data_len) 36946465ddcfSJouni Malinen { 36956465ddcfSJouni Malinen struct sk_buff *skb; 36966465ddcfSJouni Malinen struct wmi_p2p_probe_response_cmd *p; 3697bd24a50fSAarthi Thiruvengadam size_t cmd_len = sizeof(*p) + data_len; 36986465ddcfSJouni Malinen 3699bd24a50fSAarthi Thiruvengadam if (data_len == 0) 3700bd24a50fSAarthi Thiruvengadam cmd_len++; /* work around target minimum length requirement */ 3701bd24a50fSAarthi Thiruvengadam 3702bd24a50fSAarthi Thiruvengadam skb = ath6kl_wmi_get_new_buf(cmd_len); 37036465ddcfSJouni Malinen if (!skb) 37046465ddcfSJouni Malinen return -ENOMEM; 37056465ddcfSJouni Malinen 3706cdeb8602SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3707cdeb8602SKalle Valo "send_probe_response_cmd: freq=%u dst=%pM len=%u\n", 3708cdeb8602SKalle Valo freq, dst, data_len); 37096465ddcfSJouni Malinen p = (struct wmi_p2p_probe_response_cmd *) skb->data; 37106465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 37116465ddcfSJouni Malinen memcpy(p->destination_addr, dst, ETH_ALEN); 37126465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 37136465ddcfSJouni Malinen memcpy(p->data, data, data_len); 3714334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, 3715334234b5SVasanthakumar Thiagarajan WMI_SEND_PROBE_RESPONSE_CMDID, 37166465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 37176465ddcfSJouni Malinen } 37186465ddcfSJouni Malinen 37190ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable) 37206465ddcfSJouni Malinen { 37216465ddcfSJouni Malinen struct sk_buff *skb; 37226465ddcfSJouni Malinen struct wmi_probe_req_report_cmd *p; 37236465ddcfSJouni Malinen 37246465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 37256465ddcfSJouni Malinen if (!skb) 37266465ddcfSJouni Malinen return -ENOMEM; 37276465ddcfSJouni Malinen 37286465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", 37296465ddcfSJouni Malinen enable); 37306465ddcfSJouni Malinen p = (struct wmi_probe_req_report_cmd *) skb->data; 37316465ddcfSJouni Malinen p->enable = enable ? 1 : 0; 37320ce59445SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID, 37336465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 37346465ddcfSJouni Malinen } 37356465ddcfSJouni Malinen 37360ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags) 37376465ddcfSJouni Malinen { 37386465ddcfSJouni Malinen struct sk_buff *skb; 37396465ddcfSJouni Malinen struct wmi_get_p2p_info *p; 37406465ddcfSJouni Malinen 37416465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 37426465ddcfSJouni Malinen if (!skb) 37436465ddcfSJouni Malinen return -ENOMEM; 37446465ddcfSJouni Malinen 37456465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", 37466465ddcfSJouni Malinen info_req_flags); 37476465ddcfSJouni Malinen p = (struct wmi_get_p2p_info *) skb->data; 37486465ddcfSJouni Malinen p->info_req_flags = cpu_to_le32(info_req_flags); 37490ce59445SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID, 37506465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 37516465ddcfSJouni Malinen } 37526465ddcfSJouni Malinen 3753334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx) 37546465ddcfSJouni Malinen { 37556465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); 3756334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, if_idx, 3757334234b5SVasanthakumar Thiagarajan WMI_CANCEL_REMAIN_ON_CHNL_CMDID); 37586465ddcfSJouni Malinen } 37596465ddcfSJouni Malinen 376003bdeb0dSVasanthakumar Thiagarajan int ath6kl_wmi_set_inact_period(struct wmi *wmi, u8 if_idx, int inact_timeout) 376103bdeb0dSVasanthakumar Thiagarajan { 376203bdeb0dSVasanthakumar Thiagarajan struct sk_buff *skb; 376303bdeb0dSVasanthakumar Thiagarajan struct wmi_set_inact_period_cmd *cmd; 376403bdeb0dSVasanthakumar Thiagarajan 376503bdeb0dSVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 376603bdeb0dSVasanthakumar Thiagarajan if (!skb) 376703bdeb0dSVasanthakumar Thiagarajan return -ENOMEM; 376803bdeb0dSVasanthakumar Thiagarajan 376903bdeb0dSVasanthakumar Thiagarajan cmd = (struct wmi_set_inact_period_cmd *) skb->data; 377003bdeb0dSVasanthakumar Thiagarajan cmd->inact_period = cpu_to_le32(inact_timeout); 377103bdeb0dSVasanthakumar Thiagarajan cmd->num_null_func = 0; 377203bdeb0dSVasanthakumar Thiagarajan 377303bdeb0dSVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_CONN_INACT_CMDID, 377403bdeb0dSVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 377503bdeb0dSVasanthakumar Thiagarajan } 377603bdeb0dSVasanthakumar Thiagarajan 377792332993SVasanthakumar Thiagarajan static void ath6kl_wmi_hb_challenge_resp_event(struct wmi *wmi, u8 *datap, 377892332993SVasanthakumar Thiagarajan int len) 377992332993SVasanthakumar Thiagarajan { 378092332993SVasanthakumar Thiagarajan struct wmix_hb_challenge_resp_cmd *cmd; 378192332993SVasanthakumar Thiagarajan 378292332993SVasanthakumar Thiagarajan if (len < sizeof(struct wmix_hb_challenge_resp_cmd)) 378392332993SVasanthakumar Thiagarajan return; 378492332993SVasanthakumar Thiagarajan 378592332993SVasanthakumar Thiagarajan cmd = (struct wmix_hb_challenge_resp_cmd *) datap; 378692332993SVasanthakumar Thiagarajan ath6kl_recovery_hb_event(wmi->parent_dev, 378792332993SVasanthakumar Thiagarajan le32_to_cpu(cmd->cookie)); 378892332993SVasanthakumar Thiagarajan } 378992332993SVasanthakumar Thiagarajan 3790bdcd8170SKalle Valo static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) 3791bdcd8170SKalle Valo { 3792bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd; 3793bdcd8170SKalle Valo u32 len; 3794bdcd8170SKalle Valo u16 id; 3795bdcd8170SKalle Valo u8 *datap; 3796bdcd8170SKalle Valo int ret = 0; 3797bdcd8170SKalle Valo 3798bdcd8170SKalle Valo if (skb->len < sizeof(struct wmix_cmd_hdr)) { 3799bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 3800bdcd8170SKalle Valo return -EINVAL; 3801bdcd8170SKalle Valo } 3802bdcd8170SKalle Valo 3803bdcd8170SKalle Valo cmd = (struct wmix_cmd_hdr *) skb->data; 3804bdcd8170SKalle Valo id = le32_to_cpu(cmd->cmd_id); 3805bdcd8170SKalle Valo 3806bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmix_cmd_hdr)); 3807bdcd8170SKalle Valo 3808bdcd8170SKalle Valo datap = skb->data; 3809bdcd8170SKalle Valo len = skb->len; 3810bdcd8170SKalle Valo 3811bdcd8170SKalle Valo switch (id) { 3812bdcd8170SKalle Valo case WMIX_HB_CHALLENGE_RESP_EVENTID: 3813b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n"); 381492332993SVasanthakumar Thiagarajan ath6kl_wmi_hb_challenge_resp_event(wmi, datap, len); 3815bdcd8170SKalle Valo break; 3816bdcd8170SKalle Valo case WMIX_DBGLOG_EVENTID: 3817b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len); 3818bdf5396bSKalle Valo ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len); 3819bdcd8170SKalle Valo break; 3820bdcd8170SKalle Valo default: 3821b9b6ee60SKalle Valo ath6kl_warn("unknown cmd id 0x%x\n", id); 3822bdcd8170SKalle Valo ret = -EINVAL; 3823bdcd8170SKalle Valo break; 3824bdcd8170SKalle Valo } 3825bdcd8170SKalle Valo 3826bdcd8170SKalle Valo return ret; 3827bdcd8170SKalle Valo } 3828bdcd8170SKalle Valo 38294b28a80dSJouni Malinen static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len) 38304b28a80dSJouni Malinen { 38314b28a80dSJouni Malinen return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len); 38324b28a80dSJouni Malinen } 38334b28a80dSJouni Malinen 38345dbc811fSVasanthakumar Thiagarajan /* Process interface specific wmi events, caller would free the datap */ 38355dbc811fSVasanthakumar Thiagarajan static int ath6kl_wmi_proc_events_vif(struct wmi *wmi, u16 if_idx, u16 cmd_id, 38365dbc811fSVasanthakumar Thiagarajan u8 *datap, u32 len) 3837bdcd8170SKalle Valo { 3838240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif; 3839bdcd8170SKalle Valo 3840240d2799SVasanthakumar Thiagarajan vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx); 3841240d2799SVasanthakumar Thiagarajan if (!vif) { 3842240d2799SVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, 3843240d2799SVasanthakumar Thiagarajan "Wmi event for unavailable vif, vif_index:%d\n", 3844240d2799SVasanthakumar Thiagarajan if_idx); 3845240d2799SVasanthakumar Thiagarajan return -EINVAL; 3846240d2799SVasanthakumar Thiagarajan } 3847240d2799SVasanthakumar Thiagarajan 38485dbc811fSVasanthakumar Thiagarajan switch (cmd_id) { 38495dbc811fSVasanthakumar Thiagarajan case WMI_CONNECT_EVENTID: 38505dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); 38515dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_connect_event_rx(wmi, datap, len, vif); 38525dbc811fSVasanthakumar Thiagarajan case WMI_DISCONNECT_EVENTID: 38535dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); 38545dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif); 38555dbc811fSVasanthakumar Thiagarajan case WMI_TKIP_MICERR_EVENTID: 38565dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); 38575dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif); 38585dbc811fSVasanthakumar Thiagarajan case WMI_BSSINFO_EVENTID: 38595dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); 38605dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif); 38615dbc811fSVasanthakumar Thiagarajan case WMI_NEIGHBOR_REPORT_EVENTID: 38625dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); 38635dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len, 38645dbc811fSVasanthakumar Thiagarajan vif); 38655dbc811fSVasanthakumar Thiagarajan case WMI_SCAN_COMPLETE_EVENTID: 38665dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); 38675dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif); 38685dbc811fSVasanthakumar Thiagarajan case WMI_REPORT_STATISTICS_EVENTID: 38695dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); 38705dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_stats_event_rx(wmi, datap, len, vif); 38715dbc811fSVasanthakumar Thiagarajan case WMI_CAC_EVENTID: 38725dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); 38735dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_cac_event_rx(wmi, datap, len, vif); 38745dbc811fSVasanthakumar Thiagarajan case WMI_PSPOLL_EVENTID: 38755dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); 38765dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif); 38775dbc811fSVasanthakumar Thiagarajan case WMI_DTIMEXPIRY_EVENTID: 38785dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); 38795dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif); 38805dbc811fSVasanthakumar Thiagarajan case WMI_ADDBA_REQ_EVENTID: 38815dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); 38825dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif); 38835dbc811fSVasanthakumar Thiagarajan case WMI_DELBA_REQ_EVENTID: 38845dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); 38855dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif); 38865dbc811fSVasanthakumar Thiagarajan case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID: 38875dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, 38885dbc811fSVasanthakumar Thiagarajan "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID"); 38895dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif); 38905dbc811fSVasanthakumar Thiagarajan case WMI_REMAIN_ON_CHNL_EVENTID: 38915dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); 38925dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif); 38935dbc811fSVasanthakumar Thiagarajan case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: 38945dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, 38955dbc811fSVasanthakumar Thiagarajan "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); 38965dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, 38975dbc811fSVasanthakumar Thiagarajan len, vif); 38985dbc811fSVasanthakumar Thiagarajan case WMI_TX_STATUS_EVENTID: 38995dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); 39005dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif); 39015dbc811fSVasanthakumar Thiagarajan case WMI_RX_PROBE_REQ_EVENTID: 39025dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); 39035dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif); 39045dbc811fSVasanthakumar Thiagarajan case WMI_RX_ACTION_EVENTID: 39055dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); 39065dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif); 3907279b2862SThomas Pedersen case WMI_TXE_NOTIFY_EVENTID: 3908279b2862SThomas Pedersen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TXE_NOTIFY_EVENTID\n"); 3909279b2862SThomas Pedersen return ath6kl_wmi_txe_notify_event_rx(wmi, datap, len, vif); 39105dbc811fSVasanthakumar Thiagarajan default: 39115dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", cmd_id); 39125dbc811fSVasanthakumar Thiagarajan return -EINVAL; 39135dbc811fSVasanthakumar Thiagarajan } 39145dbc811fSVasanthakumar Thiagarajan 39155dbc811fSVasanthakumar Thiagarajan return 0; 39165dbc811fSVasanthakumar Thiagarajan } 39175dbc811fSVasanthakumar Thiagarajan 39185dbc811fSVasanthakumar Thiagarajan static int ath6kl_wmi_proc_events(struct wmi *wmi, struct sk_buff *skb) 39195dbc811fSVasanthakumar Thiagarajan { 39205dbc811fSVasanthakumar Thiagarajan struct wmi_cmd_hdr *cmd; 39215dbc811fSVasanthakumar Thiagarajan int ret = 0; 39225dbc811fSVasanthakumar Thiagarajan u32 len; 39235dbc811fSVasanthakumar Thiagarajan u16 id; 39245dbc811fSVasanthakumar Thiagarajan u8 if_idx; 39255dbc811fSVasanthakumar Thiagarajan u8 *datap; 39265dbc811fSVasanthakumar Thiagarajan 39275dbc811fSVasanthakumar Thiagarajan cmd = (struct wmi_cmd_hdr *) skb->data; 39285dbc811fSVasanthakumar Thiagarajan id = le16_to_cpu(cmd->cmd_id); 39295dbc811fSVasanthakumar Thiagarajan if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK; 39305dbc811fSVasanthakumar Thiagarajan 39315dbc811fSVasanthakumar Thiagarajan skb_pull(skb, sizeof(struct wmi_cmd_hdr)); 39325dbc811fSVasanthakumar Thiagarajan datap = skb->data; 39335dbc811fSVasanthakumar Thiagarajan len = skb->len; 39345dbc811fSVasanthakumar Thiagarajan 39355dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len); 39365dbc811fSVasanthakumar Thiagarajan ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ", 39375dbc811fSVasanthakumar Thiagarajan datap, len); 39385dbc811fSVasanthakumar Thiagarajan 3939bdcd8170SKalle Valo switch (id) { 3940bdcd8170SKalle Valo case WMI_GET_BITRATE_CMDID: 3941bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); 3942bdcd8170SKalle Valo ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); 3943bdcd8170SKalle Valo break; 3944bdcd8170SKalle Valo case WMI_GET_CHANNEL_LIST_CMDID: 3945bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); 3946bdcd8170SKalle Valo ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); 3947bdcd8170SKalle Valo break; 3948bdcd8170SKalle Valo case WMI_GET_TX_PWR_CMDID: 3949bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); 3950bdcd8170SKalle Valo ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); 3951bdcd8170SKalle Valo break; 3952bdcd8170SKalle Valo case WMI_READY_EVENTID: 3953bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); 3954bdcd8170SKalle Valo ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); 3955bdcd8170SKalle Valo break; 3956bdcd8170SKalle Valo case WMI_PEER_NODE_EVENTID: 3957bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); 3958bdcd8170SKalle Valo ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); 3959bdcd8170SKalle Valo break; 3960bdcd8170SKalle Valo case WMI_REGDOMAIN_EVENTID: 3961bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); 396206033760SVivek Natarajan ath6kl_wmi_regdomain_event(wmi, datap, len); 3963bdcd8170SKalle Valo break; 3964bdcd8170SKalle Valo case WMI_PSTREAM_TIMEOUT_EVENTID: 3965bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); 3966bdcd8170SKalle Valo ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); 3967bdcd8170SKalle Valo break; 3968bdcd8170SKalle Valo case WMI_CMDERROR_EVENTID: 3969bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); 3970bdcd8170SKalle Valo ret = ath6kl_wmi_error_event_rx(wmi, datap, len); 3971bdcd8170SKalle Valo break; 3972bdcd8170SKalle Valo case WMI_RSSI_THRESHOLD_EVENTID: 3973bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); 3974bdcd8170SKalle Valo ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); 3975bdcd8170SKalle Valo break; 3976bdcd8170SKalle Valo case WMI_ERROR_REPORT_EVENTID: 3977bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); 3978bdcd8170SKalle Valo break; 3979bdcd8170SKalle Valo case WMI_OPT_RX_FRAME_EVENTID: 3980bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); 3981f195d507SJouni Malinen /* this event has been deprecated */ 3982bdcd8170SKalle Valo break; 3983bdcd8170SKalle Valo case WMI_REPORT_ROAM_TBL_EVENTID: 3984bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); 39854b28a80dSJouni Malinen ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len); 3986bdcd8170SKalle Valo break; 3987bdcd8170SKalle Valo case WMI_EXTENSION_EVENTID: 3988bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); 3989bdcd8170SKalle Valo ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); 3990bdcd8170SKalle Valo break; 3991bdcd8170SKalle Valo case WMI_CHANNEL_CHANGE_EVENTID: 3992bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); 3993bdcd8170SKalle Valo break; 3994bdcd8170SKalle Valo case WMI_REPORT_ROAM_DATA_EVENTID: 3995bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); 3996bdcd8170SKalle Valo break; 3997003353b0SKalle Valo case WMI_TEST_EVENTID: 3998003353b0SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n"); 39994f34daceSThomas Pedersen ret = ath6kl_wmi_test_rx(wmi, datap, len); 4000003353b0SKalle Valo break; 4001bdcd8170SKalle Valo case WMI_GET_FIXRATES_CMDID: 4002bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); 4003bdcd8170SKalle Valo ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); 4004bdcd8170SKalle Valo break; 4005bdcd8170SKalle Valo case WMI_TX_RETRY_ERR_EVENTID: 4006bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); 4007bdcd8170SKalle Valo break; 4008bdcd8170SKalle Valo case WMI_SNR_THRESHOLD_EVENTID: 4009bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); 4010bdcd8170SKalle Valo ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); 4011bdcd8170SKalle Valo break; 4012bdcd8170SKalle Valo case WMI_LQ_THRESHOLD_EVENTID: 4013bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); 4014bdcd8170SKalle Valo break; 4015bdcd8170SKalle Valo case WMI_APLIST_EVENTID: 4016bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); 4017bdcd8170SKalle Valo ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); 4018bdcd8170SKalle Valo break; 4019bdcd8170SKalle Valo case WMI_GET_KEEPALIVE_CMDID: 4020bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); 4021bdcd8170SKalle Valo ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); 4022bdcd8170SKalle Valo break; 4023bdcd8170SKalle Valo case WMI_GET_WOW_LIST_EVENTID: 4024bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); 4025bdcd8170SKalle Valo break; 4026bdcd8170SKalle Valo case WMI_GET_PMKID_LIST_EVENTID: 4027bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); 4028bdcd8170SKalle Valo ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); 4029bdcd8170SKalle Valo break; 4030bdcd8170SKalle Valo case WMI_SET_PARAMS_REPLY_EVENTID: 4031bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); 4032bdcd8170SKalle Valo break; 4033bdcd8170SKalle Valo case WMI_ADDBA_RESP_EVENTID: 4034bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); 4035bdcd8170SKalle Valo break; 4036bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_CONFIG_EVENTID: 4037bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 4038bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); 4039bdcd8170SKalle Valo break; 4040bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_STATS_EVENTID: 4041bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 4042bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); 4043bdcd8170SKalle Valo break; 4044bdcd8170SKalle Valo case WMI_TX_COMPLETE_EVENTID: 4045bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); 4046bdcd8170SKalle Valo ret = ath6kl_wmi_tx_complete_event_rx(datap, len); 4047bdcd8170SKalle Valo break; 40486465ddcfSJouni Malinen case WMI_P2P_CAPABILITIES_EVENTID: 40496465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); 40506465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); 40516465ddcfSJouni Malinen break; 40526465ddcfSJouni Malinen case WMI_P2P_INFO_EVENTID: 40536465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); 40546465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_info_event_rx(datap, len); 40556465ddcfSJouni Malinen break; 4056bdcd8170SKalle Valo default: 40575dbc811fSVasanthakumar Thiagarajan /* may be the event is interface specific */ 40585dbc811fSVasanthakumar Thiagarajan ret = ath6kl_wmi_proc_events_vif(wmi, if_idx, id, datap, len); 4059bdcd8170SKalle Valo break; 4060bdcd8170SKalle Valo } 4061bdcd8170SKalle Valo 4062bdcd8170SKalle Valo dev_kfree_skb(skb); 4063bdcd8170SKalle Valo return ret; 4064bdcd8170SKalle Valo } 4065bdcd8170SKalle Valo 40665dbc811fSVasanthakumar Thiagarajan /* Control Path */ 40675dbc811fSVasanthakumar Thiagarajan int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) 40685dbc811fSVasanthakumar Thiagarajan { 40695dbc811fSVasanthakumar Thiagarajan if (WARN_ON(skb == NULL)) 40705dbc811fSVasanthakumar Thiagarajan return -EINVAL; 40715dbc811fSVasanthakumar Thiagarajan 40725dbc811fSVasanthakumar Thiagarajan if (skb->len < sizeof(struct wmi_cmd_hdr)) { 40735dbc811fSVasanthakumar Thiagarajan ath6kl_err("bad packet 1\n"); 40745dbc811fSVasanthakumar Thiagarajan dev_kfree_skb(skb); 40755dbc811fSVasanthakumar Thiagarajan return -EINVAL; 40765dbc811fSVasanthakumar Thiagarajan } 40775dbc811fSVasanthakumar Thiagarajan 40785dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_proc_events(wmi, skb); 40795dbc811fSVasanthakumar Thiagarajan } 40805dbc811fSVasanthakumar Thiagarajan 4081c89c591dSKalle Valo void ath6kl_wmi_reset(struct wmi *wmi) 4082bdcd8170SKalle Valo { 4083bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 4084bdcd8170SKalle Valo 4085bdcd8170SKalle Valo wmi->fat_pipe_exist = 0; 4086bdcd8170SKalle Valo memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); 4087bdcd8170SKalle Valo 4088bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 4089bdcd8170SKalle Valo } 4090bdcd8170SKalle Valo 40912865785eSVasanthakumar Thiagarajan void *ath6kl_wmi_init(struct ath6kl *dev) 4092bdcd8170SKalle Valo { 4093bdcd8170SKalle Valo struct wmi *wmi; 4094bdcd8170SKalle Valo 4095bdcd8170SKalle Valo wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); 4096bdcd8170SKalle Valo if (!wmi) 4097bdcd8170SKalle Valo return NULL; 4098bdcd8170SKalle Valo 4099bdcd8170SKalle Valo spin_lock_init(&wmi->lock); 4100bdcd8170SKalle Valo 4101bdcd8170SKalle Valo wmi->parent_dev = dev; 4102bdcd8170SKalle Valo 4103bdcd8170SKalle Valo wmi->pwr_mode = REC_POWER; 4104bdcd8170SKalle Valo 4105c89c591dSKalle Valo ath6kl_wmi_reset(wmi); 4106bdcd8170SKalle Valo 4107bdcd8170SKalle Valo return wmi; 4108bdcd8170SKalle Valo } 4109bdcd8170SKalle Valo 4110bdcd8170SKalle Valo void ath6kl_wmi_shutdown(struct wmi *wmi) 4111bdcd8170SKalle Valo { 4112bdcd8170SKalle Valo if (!wmi) 4113bdcd8170SKalle Valo return; 4114bdcd8170SKalle Valo 4115a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 4116bdcd8170SKalle Valo kfree(wmi); 4117bdcd8170SKalle Valo } 4118