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> 19bdcd8170SKalle Valo #include "core.h" 20bdcd8170SKalle Valo #include "debug.h" 21003353b0SKalle Valo #include "testmode.h" 2206033760SVivek Natarajan #include "../regd.h" 2306033760SVivek Natarajan #include "../regd_common.h" 24bdcd8170SKalle Valo 25240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx); 26bdcd8170SKalle Valo 27bdcd8170SKalle Valo static const s32 wmi_rate_tbl[][2] = { 28bdcd8170SKalle Valo /* {W/O SGI, with SGI} */ 29bdcd8170SKalle Valo {1000, 1000}, 30bdcd8170SKalle Valo {2000, 2000}, 31bdcd8170SKalle Valo {5500, 5500}, 32bdcd8170SKalle Valo {11000, 11000}, 33bdcd8170SKalle Valo {6000, 6000}, 34bdcd8170SKalle Valo {9000, 9000}, 35bdcd8170SKalle Valo {12000, 12000}, 36bdcd8170SKalle Valo {18000, 18000}, 37bdcd8170SKalle Valo {24000, 24000}, 38bdcd8170SKalle Valo {36000, 36000}, 39bdcd8170SKalle Valo {48000, 48000}, 40bdcd8170SKalle Valo {54000, 54000}, 41bdcd8170SKalle Valo {6500, 7200}, 42bdcd8170SKalle Valo {13000, 14400}, 43bdcd8170SKalle Valo {19500, 21700}, 44bdcd8170SKalle Valo {26000, 28900}, 45bdcd8170SKalle Valo {39000, 43300}, 46bdcd8170SKalle Valo {52000, 57800}, 47bdcd8170SKalle Valo {58500, 65000}, 48bdcd8170SKalle Valo {65000, 72200}, 49bdcd8170SKalle Valo {13500, 15000}, 50bdcd8170SKalle Valo {27000, 30000}, 51bdcd8170SKalle Valo {40500, 45000}, 52bdcd8170SKalle Valo {54000, 60000}, 53bdcd8170SKalle Valo {81000, 90000}, 54bdcd8170SKalle Valo {108000, 120000}, 55bdcd8170SKalle Valo {121500, 135000}, 56bdcd8170SKalle Valo {135000, 150000}, 57bdcd8170SKalle Valo {0, 0} 58bdcd8170SKalle Valo }; 59bdcd8170SKalle Valo 60bdcd8170SKalle Valo /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */ 61bdcd8170SKalle Valo static const u8 up_to_ac[] = { 62bdcd8170SKalle Valo WMM_AC_BE, 63bdcd8170SKalle Valo WMM_AC_BK, 64bdcd8170SKalle Valo WMM_AC_BK, 65bdcd8170SKalle Valo WMM_AC_BE, 66bdcd8170SKalle Valo WMM_AC_VI, 67bdcd8170SKalle Valo WMM_AC_VI, 68bdcd8170SKalle Valo WMM_AC_VO, 69bdcd8170SKalle Valo WMM_AC_VO, 70bdcd8170SKalle Valo }; 71bdcd8170SKalle Valo 72bdcd8170SKalle Valo void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id) 73bdcd8170SKalle Valo { 74bdcd8170SKalle Valo if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX)) 75bdcd8170SKalle Valo return; 76bdcd8170SKalle Valo 77bdcd8170SKalle Valo wmi->ep_id = ep_id; 78bdcd8170SKalle Valo } 79bdcd8170SKalle Valo 80bdcd8170SKalle Valo enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) 81bdcd8170SKalle Valo { 82bdcd8170SKalle Valo return wmi->ep_id; 83bdcd8170SKalle Valo } 84bdcd8170SKalle Valo 856765d0aaSVasanthakumar Thiagarajan struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx) 86240d2799SVasanthakumar Thiagarajan { 87990bd915SVasanthakumar Thiagarajan struct ath6kl_vif *vif, *found = NULL; 88990bd915SVasanthakumar Thiagarajan 8971f96ee6SKalle Valo if (WARN_ON(if_idx > (ar->vif_max - 1))) 90240d2799SVasanthakumar Thiagarajan return NULL; 91240d2799SVasanthakumar Thiagarajan 92990bd915SVasanthakumar Thiagarajan /* FIXME: Locking */ 9311f6e40dSVasanthakumar Thiagarajan spin_lock_bh(&ar->list_lock); 94990bd915SVasanthakumar Thiagarajan list_for_each_entry(vif, &ar->vif_list, list) { 95990bd915SVasanthakumar Thiagarajan if (vif->fw_vif_idx == if_idx) { 96990bd915SVasanthakumar Thiagarajan found = vif; 97990bd915SVasanthakumar Thiagarajan break; 98990bd915SVasanthakumar Thiagarajan } 99990bd915SVasanthakumar Thiagarajan } 10011f6e40dSVasanthakumar Thiagarajan spin_unlock_bh(&ar->list_lock); 101990bd915SVasanthakumar Thiagarajan 102990bd915SVasanthakumar Thiagarajan return found; 103240d2799SVasanthakumar Thiagarajan } 104240d2799SVasanthakumar Thiagarajan 105bdcd8170SKalle Valo /* Performs DIX to 802.3 encapsulation for transmit packets. 106bdcd8170SKalle Valo * Assumes the entire DIX header is contigous and that there is 107bdcd8170SKalle Valo * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. 108bdcd8170SKalle Valo */ 109bdcd8170SKalle Valo int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) 110bdcd8170SKalle Valo { 111bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 112bdcd8170SKalle Valo struct ethhdr *eth_hdr; 113bdcd8170SKalle Valo size_t new_len; 114bdcd8170SKalle Valo __be16 type; 115bdcd8170SKalle Valo u8 *datap; 116bdcd8170SKalle Valo u16 size; 117bdcd8170SKalle Valo 118bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 119bdcd8170SKalle Valo return -EINVAL; 120bdcd8170SKalle Valo 121bdcd8170SKalle Valo size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr); 122bdcd8170SKalle Valo if (skb_headroom(skb) < size) 123bdcd8170SKalle Valo return -ENOMEM; 124bdcd8170SKalle Valo 125bdcd8170SKalle Valo eth_hdr = (struct ethhdr *) skb->data; 126bdcd8170SKalle Valo type = eth_hdr->h_proto; 127bdcd8170SKalle Valo 128bdcd8170SKalle Valo if (!is_ethertype(be16_to_cpu(type))) { 129bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 130bdcd8170SKalle Valo "%s: pkt is already in 802.3 format\n", __func__); 131bdcd8170SKalle Valo return 0; 132bdcd8170SKalle Valo } 133bdcd8170SKalle Valo 134bdcd8170SKalle Valo new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr); 135bdcd8170SKalle Valo 136bdcd8170SKalle Valo skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr)); 137bdcd8170SKalle Valo datap = skb->data; 138bdcd8170SKalle Valo 139bdcd8170SKalle Valo eth_hdr->h_proto = cpu_to_be16(new_len); 140bdcd8170SKalle Valo 141bdcd8170SKalle Valo memcpy(datap, eth_hdr, sizeof(*eth_hdr)); 142bdcd8170SKalle Valo 143bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr)); 144bdcd8170SKalle Valo llc_hdr->dsap = 0xAA; 145bdcd8170SKalle Valo llc_hdr->ssap = 0xAA; 146bdcd8170SKalle Valo llc_hdr->cntl = 0x03; 147bdcd8170SKalle Valo llc_hdr->org_code[0] = 0x0; 148bdcd8170SKalle Valo llc_hdr->org_code[1] = 0x0; 149bdcd8170SKalle Valo llc_hdr->org_code[2] = 0x0; 150bdcd8170SKalle Valo llc_hdr->eth_type = type; 151bdcd8170SKalle Valo 152bdcd8170SKalle Valo return 0; 153bdcd8170SKalle Valo } 154bdcd8170SKalle Valo 155bdcd8170SKalle Valo static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, 156bdcd8170SKalle Valo u8 *version, void *tx_meta_info) 157bdcd8170SKalle Valo { 158bdcd8170SKalle Valo struct wmi_tx_meta_v1 *v1; 159bdcd8170SKalle Valo struct wmi_tx_meta_v2 *v2; 160bdcd8170SKalle Valo 161bdcd8170SKalle Valo if (WARN_ON(skb == NULL || version == NULL)) 162bdcd8170SKalle Valo return -EINVAL; 163bdcd8170SKalle Valo 164bdcd8170SKalle Valo switch (*version) { 165bdcd8170SKalle Valo case WMI_META_VERSION_1: 166bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 167bdcd8170SKalle Valo v1 = (struct wmi_tx_meta_v1 *) skb->data; 168bdcd8170SKalle Valo v1->pkt_id = 0; 169bdcd8170SKalle Valo v1->rate_plcy_id = 0; 170bdcd8170SKalle Valo *version = WMI_META_VERSION_1; 171bdcd8170SKalle Valo break; 172bdcd8170SKalle Valo case WMI_META_VERSION_2: 173bdcd8170SKalle Valo skb_push(skb, WMI_MAX_TX_META_SZ); 174bdcd8170SKalle Valo v2 = (struct wmi_tx_meta_v2 *) skb->data; 175bdcd8170SKalle Valo memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info, 176bdcd8170SKalle Valo sizeof(struct wmi_tx_meta_v2)); 177bdcd8170SKalle Valo break; 178bdcd8170SKalle Valo } 179bdcd8170SKalle Valo 180bdcd8170SKalle Valo return 0; 181bdcd8170SKalle Valo } 182bdcd8170SKalle Valo 183bdcd8170SKalle Valo int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, 184c1762a3fSThirumalai Pachamuthu u8 msg_type, u32 flags, 185bdcd8170SKalle Valo enum wmi_data_hdr_data_type data_type, 1866765d0aaSVasanthakumar Thiagarajan u8 meta_ver, void *tx_meta_info, u8 if_idx) 187bdcd8170SKalle Valo { 188bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 189bdcd8170SKalle Valo int ret; 190bdcd8170SKalle Valo 19171f96ee6SKalle Valo if (WARN_ON(skb == NULL || (if_idx > wmi->parent_dev->vif_max - 1))) 192bdcd8170SKalle Valo return -EINVAL; 193bdcd8170SKalle Valo 1943ce6ff50SVasanthakumar Thiagarajan if (tx_meta_info) { 195bdcd8170SKalle Valo ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info); 196bdcd8170SKalle Valo if (ret) 197bdcd8170SKalle Valo return ret; 1983ce6ff50SVasanthakumar Thiagarajan } 199bdcd8170SKalle Valo 200bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 201bdcd8170SKalle Valo 202bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *)skb->data; 203bdcd8170SKalle Valo memset(data_hdr, 0, sizeof(struct wmi_data_hdr)); 204bdcd8170SKalle Valo 205bdcd8170SKalle Valo data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; 206bdcd8170SKalle Valo data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; 207bdcd8170SKalle Valo 208c1762a3fSThirumalai Pachamuthu if (flags & WMI_DATA_HDR_FLAGS_MORE) 209c1762a3fSThirumalai Pachamuthu data_hdr->info |= WMI_DATA_HDR_MORE; 210bdcd8170SKalle Valo 211c1762a3fSThirumalai Pachamuthu if (flags & WMI_DATA_HDR_FLAGS_EOSP) 212c1762a3fSThirumalai Pachamuthu data_hdr->info3 |= cpu_to_le16(WMI_DATA_HDR_EOSP); 213c1762a3fSThirumalai Pachamuthu 214c1762a3fSThirumalai Pachamuthu data_hdr->info2 |= cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); 215c1762a3fSThirumalai Pachamuthu data_hdr->info3 |= cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); 216bdcd8170SKalle Valo 217bdcd8170SKalle Valo return 0; 218bdcd8170SKalle Valo } 219bdcd8170SKalle Valo 220c1762a3fSThirumalai Pachamuthu u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) 221bdcd8170SKalle Valo { 222bdcd8170SKalle Valo struct iphdr *ip_hdr = (struct iphdr *) pkt; 223bdcd8170SKalle Valo u8 ip_pri; 224bdcd8170SKalle Valo 225bdcd8170SKalle Valo /* 226bdcd8170SKalle Valo * Determine IPTOS priority 227bdcd8170SKalle Valo * 228bdcd8170SKalle Valo * IP-TOS - 8bits 229bdcd8170SKalle Valo * : DSCP(6-bits) ECN(2-bits) 230bdcd8170SKalle Valo * : DSCP - P2 P1 P0 X X X 231bdcd8170SKalle Valo * where (P2 P1 P0) form 802.1D 232bdcd8170SKalle Valo */ 233bdcd8170SKalle Valo ip_pri = ip_hdr->tos >> 5; 234bdcd8170SKalle Valo ip_pri &= 0x7; 235bdcd8170SKalle Valo 236bdcd8170SKalle Valo if ((layer2_pri & 0x7) > ip_pri) 237bdcd8170SKalle Valo return (u8) layer2_pri & 0x7; 238bdcd8170SKalle Valo else 239bdcd8170SKalle Valo return ip_pri; 240bdcd8170SKalle Valo } 241bdcd8170SKalle Valo 242c1762a3fSThirumalai Pachamuthu u8 ath6kl_wmi_get_traffic_class(u8 user_priority) 243c1762a3fSThirumalai Pachamuthu { 244c1762a3fSThirumalai Pachamuthu return up_to_ac[user_priority & 0x7]; 245c1762a3fSThirumalai Pachamuthu } 246c1762a3fSThirumalai Pachamuthu 247240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx, 248240d2799SVasanthakumar Thiagarajan struct sk_buff *skb, 249bdcd8170SKalle Valo u32 layer2_priority, bool wmm_enabled, 250bdcd8170SKalle Valo u8 *ac) 251bdcd8170SKalle Valo { 252bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 253bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 254bdcd8170SKalle Valo struct wmi_create_pstream_cmd cmd; 255bdcd8170SKalle Valo u32 meta_size, hdr_size; 256bdcd8170SKalle Valo u16 ip_type = IP_ETHERTYPE; 257bdcd8170SKalle Valo u8 stream_exist, usr_pri; 258bdcd8170SKalle Valo u8 traffic_class = WMM_AC_BE; 259bdcd8170SKalle Valo u8 *datap; 260bdcd8170SKalle Valo 261bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 262bdcd8170SKalle Valo return -EINVAL; 263bdcd8170SKalle Valo 264bdcd8170SKalle Valo datap = skb->data; 265bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) datap; 266bdcd8170SKalle Valo 267bdcd8170SKalle Valo meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) & 268bdcd8170SKalle Valo WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0; 269bdcd8170SKalle Valo 270bdcd8170SKalle Valo if (!wmm_enabled) { 271bdcd8170SKalle Valo /* If WMM is disabled all traffic goes as BE traffic */ 272bdcd8170SKalle Valo usr_pri = 0; 273bdcd8170SKalle Valo } else { 274bdcd8170SKalle Valo hdr_size = sizeof(struct ethhdr); 275bdcd8170SKalle Valo 276bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + 277bdcd8170SKalle Valo sizeof(struct 278bdcd8170SKalle Valo wmi_data_hdr) + 279bdcd8170SKalle Valo meta_size + hdr_size); 280bdcd8170SKalle Valo 281bdcd8170SKalle Valo if (llc_hdr->eth_type == htons(ip_type)) { 282bdcd8170SKalle Valo /* 283bdcd8170SKalle Valo * Extract the endpoint info from the TOS field 284bdcd8170SKalle Valo * in the IP header. 285bdcd8170SKalle Valo */ 286bdcd8170SKalle Valo usr_pri = 287bdcd8170SKalle Valo ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + 288bdcd8170SKalle Valo sizeof(struct ath6kl_llc_snap_hdr), 289bdcd8170SKalle Valo layer2_priority); 290bdcd8170SKalle Valo } else 291bdcd8170SKalle Valo usr_pri = layer2_priority & 0x7; 292bdcd8170SKalle Valo } 293bdcd8170SKalle Valo 294a7f0c58bSKalle Valo /* 295a7f0c58bSKalle Valo * workaround for WMM S5 296a7f0c58bSKalle Valo * 297a7f0c58bSKalle Valo * FIXME: wmi->traffic_class is always 100 so this test doesn't 298a7f0c58bSKalle Valo * make sense 299a7f0c58bSKalle Valo */ 300bdcd8170SKalle Valo if ((wmi->traffic_class == WMM_AC_VI) && 301bdcd8170SKalle Valo ((usr_pri == 5) || (usr_pri == 4))) 302bdcd8170SKalle Valo usr_pri = 1; 303bdcd8170SKalle Valo 304bdcd8170SKalle Valo /* Convert user priority to traffic class */ 305bdcd8170SKalle Valo traffic_class = up_to_ac[usr_pri & 0x7]; 306bdcd8170SKalle Valo 307bdcd8170SKalle Valo wmi_data_hdr_set_up(data_hdr, usr_pri); 308bdcd8170SKalle Valo 309bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 310bdcd8170SKalle Valo stream_exist = wmi->fat_pipe_exist; 311bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 312bdcd8170SKalle Valo 313bdcd8170SKalle Valo if (!(stream_exist & (1 << traffic_class))) { 314bdcd8170SKalle Valo memset(&cmd, 0, sizeof(cmd)); 315bdcd8170SKalle Valo cmd.traffic_class = traffic_class; 316bdcd8170SKalle Valo cmd.user_pri = usr_pri; 317bdcd8170SKalle Valo cmd.inactivity_int = 318bdcd8170SKalle Valo cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); 319bdcd8170SKalle Valo /* Implicit streams are created with TSID 0xFF */ 320bdcd8170SKalle Valo cmd.tsid = WMI_IMPLICIT_PSTREAM; 321240d2799SVasanthakumar Thiagarajan ath6kl_wmi_create_pstream_cmd(wmi, if_idx, &cmd); 322bdcd8170SKalle Valo } 323bdcd8170SKalle Valo 324bdcd8170SKalle Valo *ac = traffic_class; 325bdcd8170SKalle Valo 326bdcd8170SKalle Valo return 0; 327bdcd8170SKalle Valo } 328bdcd8170SKalle Valo 329bdcd8170SKalle Valo int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) 330bdcd8170SKalle Valo { 331bdcd8170SKalle Valo struct ieee80211_hdr_3addr *pwh, wh; 332bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 333bdcd8170SKalle Valo struct ethhdr eth_hdr; 334bdcd8170SKalle Valo u32 hdr_size; 335bdcd8170SKalle Valo u8 *datap; 336bdcd8170SKalle Valo __le16 sub_type; 337bdcd8170SKalle Valo 338bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 339bdcd8170SKalle Valo return -EINVAL; 340bdcd8170SKalle Valo 341bdcd8170SKalle Valo datap = skb->data; 342bdcd8170SKalle Valo pwh = (struct ieee80211_hdr_3addr *) datap; 343bdcd8170SKalle Valo 344bdcd8170SKalle Valo sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); 345bdcd8170SKalle Valo 346bdcd8170SKalle Valo memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); 347bdcd8170SKalle Valo 348bdcd8170SKalle Valo /* Strip off the 802.11 header */ 349bdcd8170SKalle Valo if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { 350bdcd8170SKalle Valo hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), 351bdcd8170SKalle Valo sizeof(u32)); 352bdcd8170SKalle Valo skb_pull(skb, hdr_size); 353bdcd8170SKalle Valo } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) 354bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); 355bdcd8170SKalle Valo 356bdcd8170SKalle Valo datap = skb->data; 357bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); 358bdcd8170SKalle Valo 359c8790cbaSRaja Mani memset(ð_hdr, 0, sizeof(eth_hdr)); 360bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 361bdcd8170SKalle Valo 362bdcd8170SKalle Valo switch ((le16_to_cpu(wh.frame_control)) & 363bdcd8170SKalle Valo (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { 364bdcd8170SKalle Valo case 0: 365bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 366bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 367bdcd8170SKalle Valo break; 368bdcd8170SKalle Valo case IEEE80211_FCTL_TODS: 369bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); 370bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); 371bdcd8170SKalle Valo break; 372bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS: 373bdcd8170SKalle Valo memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); 374bdcd8170SKalle Valo memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); 375bdcd8170SKalle Valo break; 376bdcd8170SKalle Valo case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: 377bdcd8170SKalle Valo break; 378bdcd8170SKalle Valo } 379bdcd8170SKalle Valo 380bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 381bdcd8170SKalle Valo skb_push(skb, sizeof(eth_hdr)); 382bdcd8170SKalle Valo 383bdcd8170SKalle Valo datap = skb->data; 384bdcd8170SKalle Valo 385bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 386bdcd8170SKalle Valo 387bdcd8170SKalle Valo return 0; 388bdcd8170SKalle Valo } 389bdcd8170SKalle Valo 390bdcd8170SKalle Valo /* 391bdcd8170SKalle Valo * Performs 802.3 to DIX encapsulation for received packets. 392bdcd8170SKalle Valo * Assumes the entire 802.3 header is contigous. 393bdcd8170SKalle Valo */ 394bdcd8170SKalle Valo int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) 395bdcd8170SKalle Valo { 396bdcd8170SKalle Valo struct ath6kl_llc_snap_hdr *llc_hdr; 397bdcd8170SKalle Valo struct ethhdr eth_hdr; 398bdcd8170SKalle Valo u8 *datap; 399bdcd8170SKalle Valo 400bdcd8170SKalle Valo if (WARN_ON(skb == NULL)) 401bdcd8170SKalle Valo return -EINVAL; 402bdcd8170SKalle Valo 403bdcd8170SKalle Valo datap = skb->data; 404bdcd8170SKalle Valo 405bdcd8170SKalle Valo memcpy(ð_hdr, datap, sizeof(eth_hdr)); 406bdcd8170SKalle Valo 407bdcd8170SKalle Valo llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); 408bdcd8170SKalle Valo eth_hdr.h_proto = llc_hdr->eth_type; 409bdcd8170SKalle Valo 410bdcd8170SKalle Valo skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); 411bdcd8170SKalle Valo datap = skb->data; 412bdcd8170SKalle Valo 413bdcd8170SKalle Valo memcpy(datap, ð_hdr, sizeof(eth_hdr)); 414bdcd8170SKalle Valo 415bdcd8170SKalle Valo return 0; 416bdcd8170SKalle Valo } 417bdcd8170SKalle Valo 418bdcd8170SKalle Valo static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) 419bdcd8170SKalle Valo { 420bdcd8170SKalle Valo struct tx_complete_msg_v1 *msg_v1; 421bdcd8170SKalle Valo struct wmi_tx_complete_event *evt; 422bdcd8170SKalle Valo int index; 423bdcd8170SKalle Valo u16 size; 424bdcd8170SKalle Valo 425bdcd8170SKalle Valo evt = (struct wmi_tx_complete_event *) datap; 426bdcd8170SKalle Valo 427bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", 428bdcd8170SKalle Valo evt->num_msg, evt->msg_len, evt->msg_type); 429bdcd8170SKalle Valo 430bdcd8170SKalle Valo for (index = 0; index < evt->num_msg; index++) { 431bdcd8170SKalle Valo size = sizeof(struct wmi_tx_complete_event) + 432bdcd8170SKalle Valo (index * sizeof(struct tx_complete_msg_v1)); 433bdcd8170SKalle Valo msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); 434bdcd8170SKalle Valo 435bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", 436bdcd8170SKalle Valo msg_v1->status, msg_v1->pkt_id, 437bdcd8170SKalle Valo msg_v1->rate_idx, msg_v1->ack_failures); 438bdcd8170SKalle Valo } 439bdcd8170SKalle Valo 440bdcd8170SKalle Valo return 0; 441bdcd8170SKalle Valo } 442bdcd8170SKalle Valo 443f9e5f05cSJouni Malinen static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, 444240d2799SVasanthakumar Thiagarajan int len, struct ath6kl_vif *vif) 4456465ddcfSJouni Malinen { 4466465ddcfSJouni Malinen struct wmi_remain_on_chnl_event *ev; 4476465ddcfSJouni Malinen u32 freq; 4486465ddcfSJouni Malinen u32 dur; 449f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 450f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4511052261eSJouni Malinen u32 id; 4526465ddcfSJouni Malinen 4536465ddcfSJouni Malinen if (len < sizeof(*ev)) 4546465ddcfSJouni Malinen return -EINVAL; 4556465ddcfSJouni Malinen 4566465ddcfSJouni Malinen ev = (struct wmi_remain_on_chnl_event *) datap; 4576465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4586465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4596465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", 4606465ddcfSJouni Malinen freq, dur); 461be98e3a4SVasanthakumar Thiagarajan chan = ieee80211_get_channel(ar->wiphy, freq); 462f9e5f05cSJouni Malinen if (!chan) { 463f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " 464f9e5f05cSJouni Malinen "(freq=%u)\n", freq); 465f9e5f05cSJouni Malinen return -EINVAL; 466f9e5f05cSJouni Malinen } 4671052261eSJouni Malinen id = vif->last_roc_id; 4681052261eSJouni Malinen cfg80211_ready_on_channel(vif->ndev, id, chan, NL80211_CHAN_NO_HT, 469f9e5f05cSJouni Malinen dur, GFP_ATOMIC); 4706465ddcfSJouni Malinen 4716465ddcfSJouni Malinen return 0; 4726465ddcfSJouni Malinen } 4736465ddcfSJouni Malinen 474f9e5f05cSJouni Malinen static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, 475240d2799SVasanthakumar Thiagarajan u8 *datap, int len, 476240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 4776465ddcfSJouni Malinen { 4786465ddcfSJouni Malinen struct wmi_cancel_remain_on_chnl_event *ev; 4796465ddcfSJouni Malinen u32 freq; 4806465ddcfSJouni Malinen u32 dur; 481f9e5f05cSJouni Malinen struct ieee80211_channel *chan; 482f9e5f05cSJouni Malinen struct ath6kl *ar = wmi->parent_dev; 4831052261eSJouni Malinen u32 id; 4846465ddcfSJouni Malinen 4856465ddcfSJouni Malinen if (len < sizeof(*ev)) 4866465ddcfSJouni Malinen return -EINVAL; 4876465ddcfSJouni Malinen 4886465ddcfSJouni Malinen ev = (struct wmi_cancel_remain_on_chnl_event *) datap; 4896465ddcfSJouni Malinen freq = le32_to_cpu(ev->freq); 4906465ddcfSJouni Malinen dur = le32_to_cpu(ev->duration); 4916465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " 4926465ddcfSJouni Malinen "status=%u\n", freq, dur, ev->status); 493be98e3a4SVasanthakumar Thiagarajan chan = ieee80211_get_channel(ar->wiphy, freq); 494f9e5f05cSJouni Malinen if (!chan) { 495f9e5f05cSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " 496f9e5f05cSJouni Malinen "channel (freq=%u)\n", freq); 497f9e5f05cSJouni Malinen return -EINVAL; 498f9e5f05cSJouni Malinen } 4991052261eSJouni Malinen if (vif->last_cancel_roc_id && 5001052261eSJouni Malinen vif->last_cancel_roc_id + 1 == vif->last_roc_id) 5011052261eSJouni Malinen id = vif->last_cancel_roc_id; /* event for cancel command */ 5021052261eSJouni Malinen else 5031052261eSJouni Malinen id = vif->last_roc_id; /* timeout on uncanceled r-o-c */ 5041052261eSJouni Malinen vif->last_cancel_roc_id = 0; 5051052261eSJouni Malinen cfg80211_remain_on_channel_expired(vif->ndev, id, chan, 506f9e5f05cSJouni Malinen NL80211_CHAN_NO_HT, GFP_ATOMIC); 5076465ddcfSJouni Malinen 5086465ddcfSJouni Malinen return 0; 5096465ddcfSJouni Malinen } 5106465ddcfSJouni Malinen 511240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len, 512240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 5136465ddcfSJouni Malinen { 5146465ddcfSJouni Malinen struct wmi_tx_status_event *ev; 5156465ddcfSJouni Malinen u32 id; 5166465ddcfSJouni Malinen 5176465ddcfSJouni Malinen if (len < sizeof(*ev)) 5186465ddcfSJouni Malinen return -EINVAL; 5196465ddcfSJouni Malinen 5206465ddcfSJouni Malinen ev = (struct wmi_tx_status_event *) datap; 5216465ddcfSJouni Malinen id = le32_to_cpu(ev->id); 5226465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", 5236465ddcfSJouni Malinen id, ev->ack_status); 524a0df5db1SJouni Malinen if (wmi->last_mgmt_tx_frame) { 525240d2799SVasanthakumar Thiagarajan cfg80211_mgmt_tx_status(vif->ndev, id, 526a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame, 527a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len, 528a0df5db1SJouni Malinen !!ev->ack_status, GFP_ATOMIC); 529a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 530a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = NULL; 531a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = 0; 532a0df5db1SJouni Malinen } 5336465ddcfSJouni Malinen 5346465ddcfSJouni Malinen return 0; 5356465ddcfSJouni Malinen } 5366465ddcfSJouni Malinen 537240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len, 538240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 5396465ddcfSJouni Malinen { 5406465ddcfSJouni Malinen struct wmi_p2p_rx_probe_req_event *ev; 541ae32c30aSJouni Malinen u32 freq; 5426465ddcfSJouni Malinen u16 dlen; 5436465ddcfSJouni Malinen 5446465ddcfSJouni Malinen if (len < sizeof(*ev)) 5456465ddcfSJouni Malinen return -EINVAL; 5466465ddcfSJouni Malinen 5476465ddcfSJouni Malinen ev = (struct wmi_p2p_rx_probe_req_event *) datap; 548ae32c30aSJouni Malinen freq = le32_to_cpu(ev->freq); 5496465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 550ae32c30aSJouni Malinen if (datap + len < ev->data + dlen) { 551ae32c30aSJouni Malinen ath6kl_err("invalid wmi_p2p_rx_probe_req_event: " 552ae32c30aSJouni Malinen "len=%d dlen=%u\n", len, dlen); 553ae32c30aSJouni Malinen return -EINVAL; 554ae32c30aSJouni Malinen } 555ae32c30aSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u " 556ae32c30aSJouni Malinen "probe_req_report=%d\n", 557cf5333d7SVasanthakumar Thiagarajan dlen, freq, vif->probe_req_report); 558ae32c30aSJouni Malinen 559cf5333d7SVasanthakumar Thiagarajan if (vif->probe_req_report || vif->nw_type == AP_NETWORK) 560804483e9SJohannes Berg cfg80211_rx_mgmt(vif->ndev, freq, 0, 561804483e9SJohannes Berg ev->data, dlen, GFP_ATOMIC); 5626465ddcfSJouni Malinen 5636465ddcfSJouni Malinen return 0; 5646465ddcfSJouni Malinen } 5656465ddcfSJouni Malinen 5666465ddcfSJouni Malinen static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) 5676465ddcfSJouni Malinen { 5686465ddcfSJouni Malinen struct wmi_p2p_capabilities_event *ev; 5696465ddcfSJouni Malinen u16 dlen; 5706465ddcfSJouni Malinen 5716465ddcfSJouni Malinen if (len < sizeof(*ev)) 5726465ddcfSJouni Malinen return -EINVAL; 5736465ddcfSJouni Malinen 5746465ddcfSJouni Malinen ev = (struct wmi_p2p_capabilities_event *) datap; 5756465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5766465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); 5776465ddcfSJouni Malinen 5786465ddcfSJouni Malinen return 0; 5796465ddcfSJouni Malinen } 5806465ddcfSJouni Malinen 581240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len, 582240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 5836465ddcfSJouni Malinen { 5846465ddcfSJouni Malinen struct wmi_rx_action_event *ev; 5859809d8efSJouni Malinen u32 freq; 5866465ddcfSJouni Malinen u16 dlen; 5876465ddcfSJouni Malinen 5886465ddcfSJouni Malinen if (len < sizeof(*ev)) 5896465ddcfSJouni Malinen return -EINVAL; 5906465ddcfSJouni Malinen 5916465ddcfSJouni Malinen ev = (struct wmi_rx_action_event *) datap; 5929809d8efSJouni Malinen freq = le32_to_cpu(ev->freq); 5936465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 5949809d8efSJouni Malinen if (datap + len < ev->data + dlen) { 5959809d8efSJouni Malinen ath6kl_err("invalid wmi_rx_action_event: " 5969809d8efSJouni Malinen "len=%d dlen=%u\n", len, dlen); 5979809d8efSJouni Malinen return -EINVAL; 5989809d8efSJouni Malinen } 5999809d8efSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); 600804483e9SJohannes Berg cfg80211_rx_mgmt(vif->ndev, freq, 0, 601804483e9SJohannes Berg ev->data, dlen, GFP_ATOMIC); 6026465ddcfSJouni Malinen 6036465ddcfSJouni Malinen return 0; 6046465ddcfSJouni Malinen } 6056465ddcfSJouni Malinen 6066465ddcfSJouni Malinen static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) 6076465ddcfSJouni Malinen { 6086465ddcfSJouni Malinen struct wmi_p2p_info_event *ev; 6096465ddcfSJouni Malinen u32 flags; 6106465ddcfSJouni Malinen u16 dlen; 6116465ddcfSJouni Malinen 6126465ddcfSJouni Malinen if (len < sizeof(*ev)) 6136465ddcfSJouni Malinen return -EINVAL; 6146465ddcfSJouni Malinen 6156465ddcfSJouni Malinen ev = (struct wmi_p2p_info_event *) datap; 6166465ddcfSJouni Malinen flags = le32_to_cpu(ev->info_req_flags); 6176465ddcfSJouni Malinen dlen = le16_to_cpu(ev->len); 6186465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); 6196465ddcfSJouni Malinen 6206465ddcfSJouni Malinen if (flags & P2P_FLAG_CAPABILITIES_REQ) { 6216465ddcfSJouni Malinen struct wmi_p2p_capabilities *cap; 6226465ddcfSJouni Malinen if (dlen < sizeof(*cap)) 6236465ddcfSJouni Malinen return -EINVAL; 6246465ddcfSJouni Malinen cap = (struct wmi_p2p_capabilities *) ev->data; 6256465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", 6266465ddcfSJouni Malinen cap->go_power_save); 6276465ddcfSJouni Malinen } 6286465ddcfSJouni Malinen 6296465ddcfSJouni Malinen if (flags & P2P_FLAG_MACADDR_REQ) { 6306465ddcfSJouni Malinen struct wmi_p2p_macaddr *mac; 6316465ddcfSJouni Malinen if (dlen < sizeof(*mac)) 6326465ddcfSJouni Malinen return -EINVAL; 6336465ddcfSJouni Malinen mac = (struct wmi_p2p_macaddr *) ev->data; 6346465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", 6356465ddcfSJouni Malinen mac->mac_addr); 6366465ddcfSJouni Malinen } 6376465ddcfSJouni Malinen 6386465ddcfSJouni Malinen if (flags & P2P_FLAG_HMODEL_REQ) { 6396465ddcfSJouni Malinen struct wmi_p2p_hmodel *mod; 6406465ddcfSJouni Malinen if (dlen < sizeof(*mod)) 6416465ddcfSJouni Malinen return -EINVAL; 6426465ddcfSJouni Malinen mod = (struct wmi_p2p_hmodel *) ev->data; 6436465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", 6446465ddcfSJouni Malinen mod->p2p_model, 6456465ddcfSJouni Malinen mod->p2p_model ? "host" : "firmware"); 6466465ddcfSJouni Malinen } 6476465ddcfSJouni Malinen return 0; 6486465ddcfSJouni Malinen } 6496465ddcfSJouni Malinen 650bdcd8170SKalle Valo static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) 651bdcd8170SKalle Valo { 652bdcd8170SKalle Valo struct sk_buff *skb; 653bdcd8170SKalle Valo 654bdcd8170SKalle Valo skb = ath6kl_buf_alloc(size); 655bdcd8170SKalle Valo if (!skb) 656bdcd8170SKalle Valo return NULL; 657bdcd8170SKalle Valo 658bdcd8170SKalle Valo skb_put(skb, size); 659bdcd8170SKalle Valo if (size) 660bdcd8170SKalle Valo memset(skb->data, 0, size); 661bdcd8170SKalle Valo 662bdcd8170SKalle Valo return skb; 663bdcd8170SKalle Valo } 664bdcd8170SKalle Valo 665bdcd8170SKalle Valo /* Send a "simple" wmi command -- one with no arguments */ 666334234b5SVasanthakumar Thiagarajan static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx, 667334234b5SVasanthakumar Thiagarajan enum wmi_cmd_id cmd_id) 668bdcd8170SKalle Valo { 669bdcd8170SKalle Valo struct sk_buff *skb; 670bdcd8170SKalle Valo int ret; 671bdcd8170SKalle Valo 672bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(0); 673bdcd8170SKalle Valo if (!skb) 674bdcd8170SKalle Valo return -ENOMEM; 675bdcd8170SKalle Valo 676334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG); 677bdcd8170SKalle Valo 678bdcd8170SKalle Valo return ret; 679bdcd8170SKalle Valo } 680bdcd8170SKalle Valo 681bdcd8170SKalle Valo static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) 682bdcd8170SKalle Valo { 683bdcd8170SKalle Valo struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; 684bdcd8170SKalle Valo 685bdcd8170SKalle Valo if (len < sizeof(struct wmi_ready_event_2)) 686bdcd8170SKalle Valo return -EINVAL; 687bdcd8170SKalle Valo 688bdcd8170SKalle Valo ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, 689bdcd8170SKalle Valo le32_to_cpu(ev->sw_version), 690bdcd8170SKalle Valo le32_to_cpu(ev->abi_version)); 691bdcd8170SKalle Valo 692bdcd8170SKalle Valo return 0; 693bdcd8170SKalle Valo } 694bdcd8170SKalle Valo 695e5090444SVivek Natarajan /* 696e5090444SVivek Natarajan * Mechanism to modify the roaming behavior in the firmware. The lower rssi 697e5090444SVivek Natarajan * at which the station has to roam can be passed with 698e5090444SVivek Natarajan * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level 699e5090444SVivek Natarajan * in dBm. 700e5090444SVivek Natarajan */ 701e5090444SVivek Natarajan int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) 702e5090444SVivek Natarajan { 703e5090444SVivek Natarajan struct sk_buff *skb; 704e5090444SVivek Natarajan struct roam_ctrl_cmd *cmd; 705e5090444SVivek Natarajan 706e5090444SVivek Natarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 707e5090444SVivek Natarajan if (!skb) 708e5090444SVivek Natarajan return -ENOMEM; 709e5090444SVivek Natarajan 710e5090444SVivek Natarajan cmd = (struct roam_ctrl_cmd *) skb->data; 711e5090444SVivek Natarajan 712e5090444SVivek Natarajan cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD); 713e5090444SVivek Natarajan cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi + 714e5090444SVivek Natarajan DEF_SCAN_FOR_ROAM_INTVL); 715e5090444SVivek Natarajan cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi); 716e5090444SVivek Natarajan cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; 717e5090444SVivek Natarajan cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; 718e5090444SVivek Natarajan 719334234b5SVasanthakumar Thiagarajan ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, 720334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 721e5090444SVivek Natarajan 722e5090444SVivek Natarajan return 0; 723e5090444SVivek Natarajan } 724e5090444SVivek Natarajan 7251261875fSJouni Malinen int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid) 7261261875fSJouni Malinen { 7271261875fSJouni Malinen struct sk_buff *skb; 7281261875fSJouni Malinen struct roam_ctrl_cmd *cmd; 7291261875fSJouni Malinen 7301261875fSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 7311261875fSJouni Malinen if (!skb) 7321261875fSJouni Malinen return -ENOMEM; 7331261875fSJouni Malinen 7341261875fSJouni Malinen cmd = (struct roam_ctrl_cmd *) skb->data; 7351261875fSJouni Malinen memset(cmd, 0, sizeof(*cmd)); 7361261875fSJouni Malinen 7371261875fSJouni Malinen memcpy(cmd->info.bssid, bssid, ETH_ALEN); 7381261875fSJouni Malinen cmd->roam_ctrl = WMI_FORCE_ROAM; 7391261875fSJouni Malinen 7401261875fSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid); 741334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, 7421261875fSJouni Malinen NO_SYNC_WMIFLAG); 7431261875fSJouni Malinen } 7441261875fSJouni Malinen 7451261875fSJouni Malinen int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode) 7461261875fSJouni Malinen { 7471261875fSJouni Malinen struct sk_buff *skb; 7481261875fSJouni Malinen struct roam_ctrl_cmd *cmd; 7491261875fSJouni Malinen 7501261875fSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 7511261875fSJouni Malinen if (!skb) 7521261875fSJouni Malinen return -ENOMEM; 7531261875fSJouni Malinen 7541261875fSJouni Malinen cmd = (struct roam_ctrl_cmd *) skb->data; 7551261875fSJouni Malinen memset(cmd, 0, sizeof(*cmd)); 7561261875fSJouni Malinen 7571261875fSJouni Malinen cmd->info.roam_mode = mode; 7581261875fSJouni Malinen cmd->roam_ctrl = WMI_SET_ROAM_MODE; 7591261875fSJouni Malinen 7601261875fSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode); 761334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, 7621261875fSJouni Malinen NO_SYNC_WMIFLAG); 7631261875fSJouni Malinen } 7641261875fSJouni Malinen 765240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, 766240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 767bdcd8170SKalle Valo { 768bdcd8170SKalle Valo struct wmi_connect_event *ev; 769bdcd8170SKalle Valo u8 *pie, *peie; 770bdcd8170SKalle Valo 771bdcd8170SKalle Valo if (len < sizeof(struct wmi_connect_event)) 772bdcd8170SKalle Valo return -EINVAL; 773bdcd8170SKalle Valo 774bdcd8170SKalle Valo ev = (struct wmi_connect_event *) datap; 775bdcd8170SKalle Valo 776f5938f24SVasanthakumar Thiagarajan if (vif->nw_type == AP_NETWORK) { 777572e27c0SJouni Malinen /* AP mode start/STA connected event */ 778240d2799SVasanthakumar Thiagarajan struct net_device *dev = vif->ndev; 779572e27c0SJouni Malinen if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) { 780572e27c0SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM " 781572e27c0SJouni Malinen "(AP started)\n", 782572e27c0SJouni Malinen __func__, le16_to_cpu(ev->u.ap_bss.ch), 783572e27c0SJouni Malinen ev->u.ap_bss.bssid); 784572e27c0SJouni Malinen ath6kl_connect_ap_mode_bss( 785240d2799SVasanthakumar Thiagarajan vif, le16_to_cpu(ev->u.ap_bss.ch)); 786572e27c0SJouni Malinen } else { 787572e27c0SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM " 788572e27c0SJouni Malinen "auth=%u keymgmt=%u cipher=%u apsd_info=%u " 789572e27c0SJouni Malinen "(STA connected)\n", 790572e27c0SJouni Malinen __func__, ev->u.ap_sta.aid, 791572e27c0SJouni Malinen ev->u.ap_sta.mac_addr, 792572e27c0SJouni Malinen ev->u.ap_sta.auth, 793572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 794572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 795572e27c0SJouni Malinen ev->u.ap_sta.apsd_info); 796c1762a3fSThirumalai Pachamuthu 797572e27c0SJouni Malinen ath6kl_connect_ap_mode_sta( 798240d2799SVasanthakumar Thiagarajan vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, 799572e27c0SJouni Malinen ev->u.ap_sta.keymgmt, 800572e27c0SJouni Malinen le16_to_cpu(ev->u.ap_sta.cipher), 801572e27c0SJouni Malinen ev->u.ap_sta.auth, ev->assoc_req_len, 802c1762a3fSThirumalai Pachamuthu ev->assoc_info + ev->beacon_ie_len, 803c1762a3fSThirumalai Pachamuthu ev->u.ap_sta.apsd_info); 804572e27c0SJouni Malinen } 805572e27c0SJouni Malinen return 0; 806572e27c0SJouni Malinen } 807572e27c0SJouni Malinen 808572e27c0SJouni Malinen /* STA/IBSS mode connection event */ 809572e27c0SJouni Malinen 810b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 811b9b6ee60SKalle Valo "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n", 812b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid, 813b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.listen_intvl), 814b9b6ee60SKalle Valo le16_to_cpu(ev->u.sta.beacon_intvl), 815b9b6ee60SKalle Valo le32_to_cpu(ev->u.sta.nw_type)); 816bdcd8170SKalle Valo 817bdcd8170SKalle Valo /* Start of assoc rsp IEs */ 818bdcd8170SKalle Valo pie = ev->assoc_info + ev->beacon_ie_len + 819bdcd8170SKalle Valo ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ 820bdcd8170SKalle Valo 821bdcd8170SKalle Valo /* End of assoc rsp IEs */ 822bdcd8170SKalle Valo peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + 823bdcd8170SKalle Valo ev->assoc_resp_len; 824bdcd8170SKalle Valo 825bdcd8170SKalle Valo while (pie < peie) { 826bdcd8170SKalle Valo switch (*pie) { 827bdcd8170SKalle Valo case WLAN_EID_VENDOR_SPECIFIC: 828bdcd8170SKalle Valo if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && 829bdcd8170SKalle Valo pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { 830bdcd8170SKalle Valo /* WMM OUT (00:50:F2) */ 831ddc3d77cSKalle Valo if (pie[1] > 5 && 832ddc3d77cSKalle Valo pie[6] == WMM_PARAM_OUI_SUBTYPE) 833bdcd8170SKalle Valo wmi->is_wmm_enabled = true; 834bdcd8170SKalle Valo } 835bdcd8170SKalle Valo break; 836bdcd8170SKalle Valo } 837bdcd8170SKalle Valo 838bdcd8170SKalle Valo if (wmi->is_wmm_enabled) 839bdcd8170SKalle Valo break; 840bdcd8170SKalle Valo 841bdcd8170SKalle Valo pie += pie[1] + 2; 842bdcd8170SKalle Valo } 843bdcd8170SKalle Valo 844240d2799SVasanthakumar Thiagarajan ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch), 845572e27c0SJouni Malinen ev->u.sta.bssid, 846572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.listen_intvl), 847572e27c0SJouni Malinen le16_to_cpu(ev->u.sta.beacon_intvl), 848572e27c0SJouni Malinen le32_to_cpu(ev->u.sta.nw_type), 849bdcd8170SKalle Valo ev->beacon_ie_len, ev->assoc_req_len, 850bdcd8170SKalle Valo ev->assoc_resp_len, ev->assoc_info); 851bdcd8170SKalle Valo 852bdcd8170SKalle Valo return 0; 853bdcd8170SKalle Valo } 854bdcd8170SKalle Valo 85506033760SVivek Natarajan static struct country_code_to_enum_rd * 85606033760SVivek Natarajan ath6kl_regd_find_country(u16 countryCode) 85706033760SVivek Natarajan { 85806033760SVivek Natarajan int i; 85906033760SVivek Natarajan 86006033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 86106033760SVivek Natarajan if (allCountries[i].countryCode == countryCode) 86206033760SVivek Natarajan return &allCountries[i]; 86306033760SVivek Natarajan } 86406033760SVivek Natarajan 86506033760SVivek Natarajan return NULL; 86606033760SVivek Natarajan } 86706033760SVivek Natarajan 86806033760SVivek Natarajan static struct reg_dmn_pair_mapping * 86906033760SVivek Natarajan ath6kl_get_regpair(u16 regdmn) 87006033760SVivek Natarajan { 87106033760SVivek Natarajan int i; 87206033760SVivek Natarajan 87306033760SVivek Natarajan if (regdmn == NO_ENUMRD) 87406033760SVivek Natarajan return NULL; 87506033760SVivek Natarajan 87606033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) { 87706033760SVivek Natarajan if (regDomainPairs[i].regDmnEnum == regdmn) 87806033760SVivek Natarajan return ®DomainPairs[i]; 87906033760SVivek Natarajan } 88006033760SVivek Natarajan 88106033760SVivek Natarajan return NULL; 88206033760SVivek Natarajan } 88306033760SVivek Natarajan 88406033760SVivek Natarajan static struct country_code_to_enum_rd * 88506033760SVivek Natarajan ath6kl_regd_find_country_by_rd(u16 regdmn) 88606033760SVivek Natarajan { 88706033760SVivek Natarajan int i; 88806033760SVivek Natarajan 88906033760SVivek Natarajan for (i = 0; i < ARRAY_SIZE(allCountries); i++) { 89006033760SVivek Natarajan if (allCountries[i].regDmnEnum == regdmn) 89106033760SVivek Natarajan return &allCountries[i]; 89206033760SVivek Natarajan } 89306033760SVivek Natarajan 89406033760SVivek Natarajan return NULL; 89506033760SVivek Natarajan } 89606033760SVivek Natarajan 89706033760SVivek Natarajan static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) 89806033760SVivek Natarajan { 89906033760SVivek Natarajan 90006033760SVivek Natarajan struct ath6kl_wmi_regdomain *ev; 90106033760SVivek Natarajan struct country_code_to_enum_rd *country = NULL; 90206033760SVivek Natarajan struct reg_dmn_pair_mapping *regpair = NULL; 90306033760SVivek Natarajan char alpha2[2]; 90406033760SVivek Natarajan u32 reg_code; 90506033760SVivek Natarajan 90606033760SVivek Natarajan ev = (struct ath6kl_wmi_regdomain *) datap; 90706033760SVivek Natarajan reg_code = le32_to_cpu(ev->reg_code); 90806033760SVivek Natarajan 90906033760SVivek Natarajan if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) 91006033760SVivek Natarajan country = ath6kl_regd_find_country((u16) reg_code); 91106033760SVivek Natarajan else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) { 91206033760SVivek Natarajan 91306033760SVivek Natarajan regpair = ath6kl_get_regpair((u16) reg_code); 91406033760SVivek Natarajan country = ath6kl_regd_find_country_by_rd((u16) reg_code); 915b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n", 91606033760SVivek Natarajan regpair->regDmnEnum); 91706033760SVivek Natarajan } 91806033760SVivek Natarajan 919e5348a1eSVasanthakumar Thiagarajan if (country && wmi->parent_dev->wiphy_registered) { 92006033760SVivek Natarajan alpha2[0] = country->isoName[0]; 92106033760SVivek Natarajan alpha2[1] = country->isoName[1]; 92206033760SVivek Natarajan 923be98e3a4SVasanthakumar Thiagarajan regulatory_hint(wmi->parent_dev->wiphy, alpha2); 92406033760SVivek Natarajan 925b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n", 92606033760SVivek Natarajan alpha2[0], alpha2[1]); 92706033760SVivek Natarajan } 92806033760SVivek Natarajan } 92906033760SVivek Natarajan 930240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len, 931240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 932bdcd8170SKalle Valo { 933bdcd8170SKalle Valo struct wmi_disconnect_event *ev; 934bdcd8170SKalle Valo wmi->traffic_class = 100; 935bdcd8170SKalle Valo 936bdcd8170SKalle Valo if (len < sizeof(struct wmi_disconnect_event)) 937bdcd8170SKalle Valo return -EINVAL; 938bdcd8170SKalle Valo 939bdcd8170SKalle Valo ev = (struct wmi_disconnect_event *) datap; 940bdcd8170SKalle Valo 941b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 942b9b6ee60SKalle Valo "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n", 943b9b6ee60SKalle Valo le16_to_cpu(ev->proto_reason_status), ev->bssid, 944b9b6ee60SKalle Valo ev->disconn_reason, ev->assoc_resp_len); 945b9b6ee60SKalle Valo 946bdcd8170SKalle Valo wmi->is_wmm_enabled = false; 947bdcd8170SKalle Valo 948240d2799SVasanthakumar Thiagarajan ath6kl_disconnect_event(vif, ev->disconn_reason, 949bdcd8170SKalle Valo ev->bssid, ev->assoc_resp_len, ev->assoc_info, 950bdcd8170SKalle Valo le16_to_cpu(ev->proto_reason_status)); 951bdcd8170SKalle Valo 952bdcd8170SKalle Valo return 0; 953bdcd8170SKalle Valo } 954bdcd8170SKalle Valo 955bdcd8170SKalle Valo static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) 956bdcd8170SKalle Valo { 957bdcd8170SKalle Valo struct wmi_peer_node_event *ev; 958bdcd8170SKalle Valo 959bdcd8170SKalle Valo if (len < sizeof(struct wmi_peer_node_event)) 960bdcd8170SKalle Valo return -EINVAL; 961bdcd8170SKalle Valo 962bdcd8170SKalle Valo ev = (struct wmi_peer_node_event *) datap; 963bdcd8170SKalle Valo 964bdcd8170SKalle Valo if (ev->event_code == PEER_NODE_JOIN_EVENT) 965bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", 966bdcd8170SKalle Valo ev->peer_mac_addr); 967bdcd8170SKalle Valo else if (ev->event_code == PEER_NODE_LEAVE_EVENT) 968bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", 969bdcd8170SKalle Valo ev->peer_mac_addr); 970bdcd8170SKalle Valo 971bdcd8170SKalle Valo return 0; 972bdcd8170SKalle Valo } 973bdcd8170SKalle Valo 974240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len, 975240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 976bdcd8170SKalle Valo { 977bdcd8170SKalle Valo struct wmi_tkip_micerr_event *ev; 978bdcd8170SKalle Valo 979bdcd8170SKalle Valo if (len < sizeof(struct wmi_tkip_micerr_event)) 980bdcd8170SKalle Valo return -EINVAL; 981bdcd8170SKalle Valo 982bdcd8170SKalle Valo ev = (struct wmi_tkip_micerr_event *) datap; 983bdcd8170SKalle Valo 984240d2799SVasanthakumar Thiagarajan ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast); 985bdcd8170SKalle Valo 986bdcd8170SKalle Valo return 0; 987bdcd8170SKalle Valo } 988bdcd8170SKalle Valo 98910509f90SKalle Valo void ath6kl_wmi_sscan_timer(unsigned long ptr) 99010509f90SKalle Valo { 99110509f90SKalle Valo struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr; 99210509f90SKalle Valo 99310509f90SKalle Valo cfg80211_sched_scan_results(vif->ar->wiphy); 99410509f90SKalle Valo } 99510509f90SKalle Valo 996240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len, 997240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 998bdcd8170SKalle Valo { 99982e14f56SJouni Malinen struct wmi_bss_info_hdr2 *bih; 10001aaa8c74SJouni Malinen u8 *buf; 10011aaa8c74SJouni Malinen struct ieee80211_channel *channel; 10021aaa8c74SJouni Malinen struct ath6kl *ar = wmi->parent_dev; 10031aaa8c74SJouni Malinen struct ieee80211_mgmt *mgmt; 10041aaa8c74SJouni Malinen struct cfg80211_bss *bss; 1005bdcd8170SKalle Valo 100682e14f56SJouni Malinen if (len <= sizeof(struct wmi_bss_info_hdr2)) 1007bdcd8170SKalle Valo return -EINVAL; 1008bdcd8170SKalle Valo 100982e14f56SJouni Malinen bih = (struct wmi_bss_info_hdr2 *) datap; 101082e14f56SJouni Malinen buf = datap + sizeof(struct wmi_bss_info_hdr2); 101182e14f56SJouni Malinen len -= sizeof(struct wmi_bss_info_hdr2); 1012bdcd8170SKalle Valo 1013bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 10141aaa8c74SJouni Malinen "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" " 10151aaa8c74SJouni Malinen "frame_type=%d\n", 101682e14f56SJouni Malinen bih->ch, bih->snr, bih->snr - 95, bih->bssid, 10171aaa8c74SJouni Malinen bih->frame_type); 1018bdcd8170SKalle Valo 10191aaa8c74SJouni Malinen if (bih->frame_type != BEACON_FTYPE && 10201aaa8c74SJouni Malinen bih->frame_type != PROBERESP_FTYPE) 10211aaa8c74SJouni Malinen return 0; /* Only update BSS table for now */ 10221aaa8c74SJouni Malinen 1023551185caSJouni Malinen if (bih->frame_type == BEACON_FTYPE && 102459c98449SVasanthakumar Thiagarajan test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) { 102559c98449SVasanthakumar Thiagarajan clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); 1026240d2799SVasanthakumar Thiagarajan ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, 1027240d2799SVasanthakumar Thiagarajan NONE_BSS_FILTER, 0); 1028551185caSJouni Malinen } 1029551185caSJouni Malinen 1030be98e3a4SVasanthakumar Thiagarajan channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch)); 10311aaa8c74SJouni Malinen if (channel == NULL) 10321aaa8c74SJouni Malinen return -EINVAL; 10331aaa8c74SJouni Malinen 10341aaa8c74SJouni Malinen if (len < 8 + 2 + 2) 10351aaa8c74SJouni Malinen return -EINVAL; 1036bdcd8170SKalle Valo 1037ddc3d77cSKalle Valo if (bih->frame_type == BEACON_FTYPE && 1038ddc3d77cSKalle Valo test_bit(CONNECTED, &vif->flags) && 1039ddc3d77cSKalle Valo memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) { 104032c10874SJouni Malinen const u8 *tim; 104132c10874SJouni Malinen tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2, 104232c10874SJouni Malinen len - 8 - 2 - 2); 104332c10874SJouni Malinen if (tim && tim[1] >= 2) { 1044cf5333d7SVasanthakumar Thiagarajan vif->assoc_bss_dtim_period = tim[3]; 104559c98449SVasanthakumar Thiagarajan set_bit(DTIM_PERIOD_AVAIL, &vif->flags); 104632c10874SJouni Malinen } 104732c10874SJouni Malinen } 104832c10874SJouni Malinen 1049bdcd8170SKalle Valo /* 10501aaa8c74SJouni Malinen * In theory, use of cfg80211_inform_bss() would be more natural here 10511aaa8c74SJouni Malinen * since we do not have the full frame. However, at least for now, 10521aaa8c74SJouni Malinen * cfg80211 can only distinguish Beacon and Probe Response frames from 10531aaa8c74SJouni Malinen * each other when using cfg80211_inform_bss_frame(), so let's build a 10541aaa8c74SJouni Malinen * fake IEEE 802.11 header to be able to take benefit of this. 1055bdcd8170SKalle Valo */ 10561aaa8c74SJouni Malinen mgmt = kmalloc(24 + len, GFP_ATOMIC); 10571aaa8c74SJouni Malinen if (mgmt == NULL) 10581aaa8c74SJouni Malinen return -EINVAL; 10591aaa8c74SJouni Malinen 10601aaa8c74SJouni Malinen if (bih->frame_type == BEACON_FTYPE) { 10611aaa8c74SJouni Malinen mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 10621aaa8c74SJouni Malinen IEEE80211_STYPE_BEACON); 10631aaa8c74SJouni Malinen memset(mgmt->da, 0xff, ETH_ALEN); 10641aaa8c74SJouni Malinen } else { 1065240d2799SVasanthakumar Thiagarajan struct net_device *dev = vif->ndev; 10661aaa8c74SJouni Malinen 10671aaa8c74SJouni Malinen mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 10681aaa8c74SJouni Malinen IEEE80211_STYPE_PROBE_RESP); 10691aaa8c74SJouni Malinen memcpy(mgmt->da, dev->dev_addr, ETH_ALEN); 1070bdcd8170SKalle Valo } 10711aaa8c74SJouni Malinen mgmt->duration = cpu_to_le16(0); 10721aaa8c74SJouni Malinen memcpy(mgmt->sa, bih->bssid, ETH_ALEN); 10731aaa8c74SJouni Malinen memcpy(mgmt->bssid, bih->bssid, ETH_ALEN); 10741aaa8c74SJouni Malinen mgmt->seq_ctrl = cpu_to_le16(0); 1075bdcd8170SKalle Valo 10761aaa8c74SJouni Malinen memcpy(&mgmt->u.beacon, buf, len); 1077bdcd8170SKalle Valo 1078be98e3a4SVasanthakumar Thiagarajan bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt, 107982e14f56SJouni Malinen 24 + len, (bih->snr - 95) * 100, 108082e14f56SJouni Malinen GFP_ATOMIC); 10811aaa8c74SJouni Malinen kfree(mgmt); 10821aaa8c74SJouni Malinen if (bss == NULL) 1083bdcd8170SKalle Valo return -ENOMEM; 10841aaa8c74SJouni Malinen cfg80211_put_bss(bss); 1085bdcd8170SKalle Valo 108610509f90SKalle Valo /* 108710509f90SKalle Valo * Firmware doesn't return any event when scheduled scan has 108810509f90SKalle Valo * finished, so we need to use a timer to find out when there are 108910509f90SKalle Valo * no more results. 109010509f90SKalle Valo * 109110509f90SKalle Valo * The timer is started from the first bss info received, otherwise 109210509f90SKalle Valo * the timer would not ever fire if the scan interval is short 109310509f90SKalle Valo * enough. 109410509f90SKalle Valo */ 109510509f90SKalle Valo if (ar->state == ATH6KL_STATE_SCHED_SCAN && 109610509f90SKalle Valo !timer_pending(&vif->sched_scan_timer)) { 109710509f90SKalle Valo mod_timer(&vif->sched_scan_timer, jiffies + 109810509f90SKalle Valo msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY)); 109910509f90SKalle Valo } 110010509f90SKalle Valo 1101bdcd8170SKalle Valo return 0; 1102bdcd8170SKalle Valo } 1103bdcd8170SKalle Valo 1104bdcd8170SKalle Valo /* Inactivity timeout of a fatpipe(pstream) at the target */ 1105bdcd8170SKalle Valo static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, 1106bdcd8170SKalle Valo int len) 1107bdcd8170SKalle Valo { 1108bdcd8170SKalle Valo struct wmi_pstream_timeout_event *ev; 1109bdcd8170SKalle Valo 1110bdcd8170SKalle Valo if (len < sizeof(struct wmi_pstream_timeout_event)) 1111bdcd8170SKalle Valo return -EINVAL; 1112bdcd8170SKalle Valo 1113bdcd8170SKalle Valo ev = (struct wmi_pstream_timeout_event *) datap; 1114bdcd8170SKalle Valo 1115bdcd8170SKalle Valo /* 1116bdcd8170SKalle Valo * When the pstream (fat pipe == AC) timesout, it means there were 1117bdcd8170SKalle Valo * no thinStreams within this pstream & it got implicitly created 1118bdcd8170SKalle Valo * due to data flow on this AC. We start the inactivity timer only 1119bdcd8170SKalle Valo * for implicitly created pstream. Just reset the host state. 1120bdcd8170SKalle Valo */ 1121bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1122bdcd8170SKalle Valo wmi->stream_exist_for_ac[ev->traffic_class] = 0; 1123bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); 1124bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1125bdcd8170SKalle Valo 1126bdcd8170SKalle Valo /* Indicate inactivity to driver layer for this fatpipe (pstream) */ 1127bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); 1128bdcd8170SKalle Valo 1129bdcd8170SKalle Valo return 0; 1130bdcd8170SKalle Valo } 1131bdcd8170SKalle Valo 1132bdcd8170SKalle Valo static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) 1133bdcd8170SKalle Valo { 1134bdcd8170SKalle Valo struct wmi_bit_rate_reply *reply; 1135bdcd8170SKalle Valo s32 rate; 1136bdcd8170SKalle Valo u32 sgi, index; 1137bdcd8170SKalle Valo 1138bdcd8170SKalle Valo if (len < sizeof(struct wmi_bit_rate_reply)) 1139bdcd8170SKalle Valo return -EINVAL; 1140bdcd8170SKalle Valo 1141bdcd8170SKalle Valo reply = (struct wmi_bit_rate_reply *) datap; 1142bdcd8170SKalle Valo 1143bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); 1144bdcd8170SKalle Valo 1145bdcd8170SKalle Valo if (reply->rate_index == (s8) RATE_AUTO) { 1146bdcd8170SKalle Valo rate = RATE_AUTO; 1147bdcd8170SKalle Valo } else { 1148bdcd8170SKalle Valo index = reply->rate_index & 0x7f; 1149bdcd8170SKalle Valo sgi = (reply->rate_index & 0x80) ? 1 : 0; 1150bdcd8170SKalle Valo rate = wmi_rate_tbl[index][sgi]; 1151bdcd8170SKalle Valo } 1152bdcd8170SKalle Valo 1153bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1154bdcd8170SKalle Valo 1155bdcd8170SKalle Valo return 0; 1156bdcd8170SKalle Valo } 1157bdcd8170SKalle Valo 11584f34daceSThomas Pedersen static int ath6kl_wmi_test_rx(struct wmi *wmi, u8 *datap, int len) 1159003353b0SKalle Valo { 11604f34daceSThomas Pedersen ath6kl_tm_rx_event(wmi->parent_dev, datap, len); 1161003353b0SKalle Valo 1162003353b0SKalle Valo return 0; 1163003353b0SKalle Valo } 1164003353b0SKalle Valo 1165bdcd8170SKalle Valo static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) 1166bdcd8170SKalle Valo { 1167bdcd8170SKalle Valo if (len < sizeof(struct wmi_fix_rates_reply)) 1168bdcd8170SKalle Valo return -EINVAL; 1169bdcd8170SKalle Valo 1170bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1171bdcd8170SKalle Valo 1172bdcd8170SKalle Valo return 0; 1173bdcd8170SKalle Valo } 1174bdcd8170SKalle Valo 1175bdcd8170SKalle Valo static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) 1176bdcd8170SKalle Valo { 1177bdcd8170SKalle Valo if (len < sizeof(struct wmi_channel_list_reply)) 1178bdcd8170SKalle Valo return -EINVAL; 1179bdcd8170SKalle Valo 1180bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1181bdcd8170SKalle Valo 1182bdcd8170SKalle Valo return 0; 1183bdcd8170SKalle Valo } 1184bdcd8170SKalle Valo 1185bdcd8170SKalle Valo static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) 1186bdcd8170SKalle Valo { 1187bdcd8170SKalle Valo struct wmi_tx_pwr_reply *reply; 1188bdcd8170SKalle Valo 1189bdcd8170SKalle Valo if (len < sizeof(struct wmi_tx_pwr_reply)) 1190bdcd8170SKalle Valo return -EINVAL; 1191bdcd8170SKalle Valo 1192bdcd8170SKalle Valo reply = (struct wmi_tx_pwr_reply *) datap; 1193bdcd8170SKalle Valo ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); 1194bdcd8170SKalle Valo 1195bdcd8170SKalle Valo return 0; 1196bdcd8170SKalle Valo } 1197bdcd8170SKalle Valo 1198bdcd8170SKalle Valo static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) 1199bdcd8170SKalle Valo { 1200bdcd8170SKalle Valo if (len < sizeof(struct wmi_get_keepalive_cmd)) 1201bdcd8170SKalle Valo return -EINVAL; 1202bdcd8170SKalle Valo 1203bdcd8170SKalle Valo ath6kl_wakeup_event(wmi->parent_dev); 1204bdcd8170SKalle Valo 1205bdcd8170SKalle Valo return 0; 1206bdcd8170SKalle Valo } 1207bdcd8170SKalle Valo 1208240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len, 1209240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1210bdcd8170SKalle Valo { 1211bdcd8170SKalle Valo struct wmi_scan_complete_event *ev; 1212bdcd8170SKalle Valo 1213bdcd8170SKalle Valo ev = (struct wmi_scan_complete_event *) datap; 1214bdcd8170SKalle Valo 1215240d2799SVasanthakumar Thiagarajan ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status)); 1216bdcd8170SKalle Valo wmi->is_probe_ssid = false; 1217bdcd8170SKalle Valo 1218bdcd8170SKalle Valo return 0; 1219bdcd8170SKalle Valo } 1220bdcd8170SKalle Valo 122186512136SJouni Malinen static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap, 1222240d2799SVasanthakumar Thiagarajan int len, struct ath6kl_vif *vif) 122386512136SJouni Malinen { 122486512136SJouni Malinen struct wmi_neighbor_report_event *ev; 122586512136SJouni Malinen u8 i; 122686512136SJouni Malinen 122786512136SJouni Malinen if (len < sizeof(*ev)) 122886512136SJouni Malinen return -EINVAL; 122986512136SJouni Malinen ev = (struct wmi_neighbor_report_event *) datap; 123086512136SJouni Malinen if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info) 123186512136SJouni Malinen > len) { 123286512136SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "truncated neighbor event " 123386512136SJouni Malinen "(num=%d len=%d)\n", ev->num_neighbors, len); 123486512136SJouni Malinen return -EINVAL; 123586512136SJouni Malinen } 123686512136SJouni Malinen for (i = 0; i < ev->num_neighbors; i++) { 123786512136SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n", 123886512136SJouni Malinen i + 1, ev->num_neighbors, ev->neighbor[i].bssid, 123986512136SJouni Malinen ev->neighbor[i].bss_flags); 1240240d2799SVasanthakumar Thiagarajan cfg80211_pmksa_candidate_notify(vif->ndev, i, 124186512136SJouni Malinen ev->neighbor[i].bssid, 124286512136SJouni Malinen !!(ev->neighbor[i].bss_flags & 124386512136SJouni Malinen WMI_PREAUTH_CAPABLE_BSS), 124486512136SJouni Malinen GFP_ATOMIC); 124586512136SJouni Malinen } 124686512136SJouni Malinen 124786512136SJouni Malinen return 0; 124886512136SJouni Malinen } 124986512136SJouni Malinen 1250bdcd8170SKalle Valo /* 1251bdcd8170SKalle Valo * Target is reporting a programming error. This is for 1252bdcd8170SKalle Valo * developer aid only. Target only checks a few common violations 1253bdcd8170SKalle Valo * and it is responsibility of host to do all error checking. 1254bdcd8170SKalle Valo * Behavior of target after wmi error event is undefined. 1255bdcd8170SKalle Valo * A reset is recommended. 1256bdcd8170SKalle Valo */ 1257bdcd8170SKalle Valo static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) 1258bdcd8170SKalle Valo { 1259bdcd8170SKalle Valo const char *type = "unknown error"; 1260bdcd8170SKalle Valo struct wmi_cmd_error_event *ev; 1261bdcd8170SKalle Valo ev = (struct wmi_cmd_error_event *) datap; 1262bdcd8170SKalle Valo 1263bdcd8170SKalle Valo switch (ev->err_code) { 1264bdcd8170SKalle Valo case INVALID_PARAM: 1265bdcd8170SKalle Valo type = "invalid parameter"; 1266bdcd8170SKalle Valo break; 1267bdcd8170SKalle Valo case ILLEGAL_STATE: 1268bdcd8170SKalle Valo type = "invalid state"; 1269bdcd8170SKalle Valo break; 1270bdcd8170SKalle Valo case INTERNAL_ERROR: 1271bdcd8170SKalle Valo type = "internal error"; 1272bdcd8170SKalle Valo break; 1273bdcd8170SKalle Valo } 1274bdcd8170SKalle Valo 1275bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", 1276bdcd8170SKalle Valo ev->cmd_id, type); 1277bdcd8170SKalle Valo 1278bdcd8170SKalle Valo return 0; 1279bdcd8170SKalle Valo } 1280bdcd8170SKalle Valo 1281240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len, 1282240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1283bdcd8170SKalle Valo { 1284240d2799SVasanthakumar Thiagarajan ath6kl_tgt_stats_event(vif, datap, len); 1285bdcd8170SKalle Valo 1286bdcd8170SKalle Valo return 0; 1287bdcd8170SKalle Valo } 1288bdcd8170SKalle Valo 1289bdcd8170SKalle Valo static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, 1290bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1291bdcd8170SKalle Valo u32 size) 1292bdcd8170SKalle Valo { 1293bdcd8170SKalle Valo u32 index; 1294bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; 1295bdcd8170SKalle Valo 1296bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1297bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1298bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[index]) { 1299bdcd8170SKalle Valo threshold = (u8) sq_thresh->upper_threshold[index]; 1300bdcd8170SKalle Valo break; 1301bdcd8170SKalle Valo } 1302bdcd8170SKalle Valo } 1303bdcd8170SKalle Valo 1304bdcd8170SKalle Valo return threshold; 1305bdcd8170SKalle Valo } 1306bdcd8170SKalle Valo 1307bdcd8170SKalle Valo static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, 1308bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh, 1309bdcd8170SKalle Valo u32 size) 1310bdcd8170SKalle Valo { 1311bdcd8170SKalle Valo u32 index; 1312bdcd8170SKalle Valo u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; 1313bdcd8170SKalle Valo 1314bdcd8170SKalle Valo /* The list is already in sorted order. Get the next lower value */ 1315bdcd8170SKalle Valo for (index = 0; index < size; index++) { 1316bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[index]) { 1317bdcd8170SKalle Valo threshold = (u8) sq_thresh->lower_threshold[index]; 1318bdcd8170SKalle Valo break; 1319bdcd8170SKalle Valo } 1320bdcd8170SKalle Valo } 1321bdcd8170SKalle Valo 1322bdcd8170SKalle Valo return threshold; 1323bdcd8170SKalle Valo } 1324bdcd8170SKalle Valo 1325bdcd8170SKalle Valo static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, 1326bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *rssi_cmd) 1327bdcd8170SKalle Valo { 1328bdcd8170SKalle Valo struct sk_buff *skb; 1329bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd *cmd; 1330bdcd8170SKalle Valo 1331bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1332bdcd8170SKalle Valo if (!skb) 1333bdcd8170SKalle Valo return -ENOMEM; 1334bdcd8170SKalle Valo 1335bdcd8170SKalle Valo cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; 1336bdcd8170SKalle Valo memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); 1337bdcd8170SKalle Valo 1338334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, 1339bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1340bdcd8170SKalle Valo } 1341bdcd8170SKalle Valo 1342bdcd8170SKalle Valo static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, 1343bdcd8170SKalle Valo int len) 1344bdcd8170SKalle Valo { 1345bdcd8170SKalle Valo struct wmi_rssi_threshold_event *reply; 1346bdcd8170SKalle Valo struct wmi_rssi_threshold_params_cmd cmd; 1347bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1348bdcd8170SKalle Valo enum wmi_rssi_threshold_val new_threshold; 1349bdcd8170SKalle Valo u8 upper_rssi_threshold, lower_rssi_threshold; 1350bdcd8170SKalle Valo s16 rssi; 1351bdcd8170SKalle Valo int ret; 1352bdcd8170SKalle Valo 1353bdcd8170SKalle Valo if (len < sizeof(struct wmi_rssi_threshold_event)) 1354bdcd8170SKalle Valo return -EINVAL; 1355bdcd8170SKalle Valo 1356bdcd8170SKalle Valo reply = (struct wmi_rssi_threshold_event *) datap; 1357bdcd8170SKalle Valo new_threshold = (enum wmi_rssi_threshold_val) reply->range; 1358bdcd8170SKalle Valo rssi = a_sle16_to_cpu(reply->rssi); 1359bdcd8170SKalle Valo 1360bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; 1361bdcd8170SKalle Valo 1362bdcd8170SKalle Valo /* 1363bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1364bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1365bdcd8170SKalle Valo * quality reported by the target 1366bdcd8170SKalle Valo */ 1367bdcd8170SKalle Valo if (new_threshold) { 1368bdcd8170SKalle Valo /* Upper threshold breached */ 1369bdcd8170SKalle Valo if (rssi < sq_thresh->upper_threshold[0]) { 1370bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1371bdcd8170SKalle Valo "spurious upper rssi threshold event: %d\n", 1372bdcd8170SKalle Valo rssi); 1373bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[1]) && 1374bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[0])) { 1375bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; 1376bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[2]) && 1377bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[1])) { 1378bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; 1379bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[3]) && 1380bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[2])) { 1381bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; 1382bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[4]) && 1383bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[3])) { 1384bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; 1385bdcd8170SKalle Valo } else if ((rssi < sq_thresh->upper_threshold[5]) && 1386bdcd8170SKalle Valo (rssi >= sq_thresh->upper_threshold[4])) { 1387bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; 1388bdcd8170SKalle Valo } else if (rssi >= sq_thresh->upper_threshold[5]) { 1389bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; 1390bdcd8170SKalle Valo } 1391bdcd8170SKalle Valo } else { 1392bdcd8170SKalle Valo /* Lower threshold breached */ 1393bdcd8170SKalle Valo if (rssi > sq_thresh->lower_threshold[0]) { 1394bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1395bdcd8170SKalle Valo "spurious lower rssi threshold event: %d %d\n", 1396bdcd8170SKalle Valo rssi, sq_thresh->lower_threshold[0]); 1397bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[1]) && 1398bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[0])) { 1399bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD6_BELOW; 1400bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[2]) && 1401bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[1])) { 1402bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD5_BELOW; 1403bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[3]) && 1404bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[2])) { 1405bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD4_BELOW; 1406bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[4]) && 1407bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[3])) { 1408bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD3_BELOW; 1409bdcd8170SKalle Valo } else if ((rssi > sq_thresh->lower_threshold[5]) && 1410bdcd8170SKalle Valo (rssi <= sq_thresh->lower_threshold[4])) { 1411bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD2_BELOW; 1412bdcd8170SKalle Valo } else if (rssi <= sq_thresh->lower_threshold[5]) { 1413bdcd8170SKalle Valo new_threshold = WMI_RSSI_THRESHOLD1_BELOW; 1414bdcd8170SKalle Valo } 1415bdcd8170SKalle Valo } 1416bdcd8170SKalle Valo 1417bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1418bdcd8170SKalle Valo lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, 1419bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1420bdcd8170SKalle Valo upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, 1421bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1422bdcd8170SKalle Valo 1423bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1424bdcd8170SKalle Valo cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); 1425bdcd8170SKalle Valo cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); 1426bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1427bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1428bdcd8170SKalle Valo 1429bdcd8170SKalle Valo ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); 1430bdcd8170SKalle Valo if (ret) { 1431bdcd8170SKalle Valo ath6kl_err("unable to configure rssi thresholds\n"); 1432bdcd8170SKalle Valo return -EIO; 1433bdcd8170SKalle Valo } 1434bdcd8170SKalle Valo 1435bdcd8170SKalle Valo return 0; 1436bdcd8170SKalle Valo } 1437bdcd8170SKalle Valo 1438240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len, 1439240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 1440bdcd8170SKalle Valo { 1441bdcd8170SKalle Valo struct wmi_cac_event *reply; 1442bdcd8170SKalle Valo struct ieee80211_tspec_ie *ts; 1443bdcd8170SKalle Valo u16 active_tsids, tsinfo; 1444bdcd8170SKalle Valo u8 tsid, index; 1445bdcd8170SKalle Valo u8 ts_id; 1446bdcd8170SKalle Valo 1447bdcd8170SKalle Valo if (len < sizeof(struct wmi_cac_event)) 1448bdcd8170SKalle Valo return -EINVAL; 1449bdcd8170SKalle Valo 1450bdcd8170SKalle Valo reply = (struct wmi_cac_event *) datap; 1451bdcd8170SKalle Valo 1452bdcd8170SKalle Valo if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && 1453bdcd8170SKalle Valo (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { 1454bdcd8170SKalle Valo 1455bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1456bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1457bdcd8170SKalle Valo tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1458bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK; 1459bdcd8170SKalle Valo 1460240d2799SVasanthakumar Thiagarajan ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, 1461240d2799SVasanthakumar Thiagarajan reply->ac, tsid); 1462bdcd8170SKalle Valo } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { 1463bdcd8170SKalle Valo /* 1464bdcd8170SKalle Valo * Following assumes that there is only one outstanding 1465bdcd8170SKalle Valo * ADDTS request when this event is received 1466bdcd8170SKalle Valo */ 1467bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1468bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1469bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1470bdcd8170SKalle Valo 1471bdcd8170SKalle Valo for (index = 0; index < sizeof(active_tsids) * 8; index++) { 1472bdcd8170SKalle Valo if ((active_tsids >> index) & 1) 1473bdcd8170SKalle Valo break; 1474bdcd8170SKalle Valo } 1475bdcd8170SKalle Valo if (index < (sizeof(active_tsids) * 8)) 1476240d2799SVasanthakumar Thiagarajan ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, 1477240d2799SVasanthakumar Thiagarajan reply->ac, index); 1478bdcd8170SKalle Valo } 1479bdcd8170SKalle Valo 1480bdcd8170SKalle Valo /* 1481bdcd8170SKalle Valo * Clear active tsids and Add missing handling 1482bdcd8170SKalle Valo * for delete qos stream from AP 1483bdcd8170SKalle Valo */ 1484bdcd8170SKalle Valo else if (reply->cac_indication == CAC_INDICATION_DELETE) { 1485bdcd8170SKalle Valo 1486bdcd8170SKalle Valo ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); 1487bdcd8170SKalle Valo tsinfo = le16_to_cpu(ts->tsinfo); 1488bdcd8170SKalle Valo ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & 1489bdcd8170SKalle Valo IEEE80211_WMM_IE_TSPEC_TID_MASK); 1490bdcd8170SKalle Valo 1491bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 1492bdcd8170SKalle Valo wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); 1493bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[reply->ac]; 1494bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 1495bdcd8170SKalle Valo 1496bdcd8170SKalle Valo /* Indicate stream inactivity to driver layer only if all tsids 1497bdcd8170SKalle Valo * within this AC are deleted. 1498bdcd8170SKalle Valo */ 1499bdcd8170SKalle Valo if (!active_tsids) { 1500bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, 1501bdcd8170SKalle Valo false); 1502bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << reply->ac); 1503bdcd8170SKalle Valo } 1504bdcd8170SKalle Valo } 1505bdcd8170SKalle Valo 1506bdcd8170SKalle Valo return 0; 1507bdcd8170SKalle Valo } 1508bdcd8170SKalle Valo 1509bdcd8170SKalle Valo static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, 1510bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *snr_cmd) 1511bdcd8170SKalle Valo { 1512bdcd8170SKalle Valo struct sk_buff *skb; 1513bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd *cmd; 1514bdcd8170SKalle Valo 1515bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1516bdcd8170SKalle Valo if (!skb) 1517bdcd8170SKalle Valo return -ENOMEM; 1518bdcd8170SKalle Valo 1519bdcd8170SKalle Valo cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; 1520bdcd8170SKalle Valo memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); 1521bdcd8170SKalle Valo 1522334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, 1523bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1524bdcd8170SKalle Valo } 1525bdcd8170SKalle Valo 1526bdcd8170SKalle Valo static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, 1527bdcd8170SKalle Valo int len) 1528bdcd8170SKalle Valo { 1529bdcd8170SKalle Valo struct wmi_snr_threshold_event *reply; 1530bdcd8170SKalle Valo struct sq_threshold_params *sq_thresh; 1531bdcd8170SKalle Valo struct wmi_snr_threshold_params_cmd cmd; 1532bdcd8170SKalle Valo enum wmi_snr_threshold_val new_threshold; 1533bdcd8170SKalle Valo u8 upper_snr_threshold, lower_snr_threshold; 1534bdcd8170SKalle Valo s16 snr; 1535bdcd8170SKalle Valo int ret; 1536bdcd8170SKalle Valo 1537bdcd8170SKalle Valo if (len < sizeof(struct wmi_snr_threshold_event)) 1538bdcd8170SKalle Valo return -EINVAL; 1539bdcd8170SKalle Valo 1540bdcd8170SKalle Valo reply = (struct wmi_snr_threshold_event *) datap; 1541bdcd8170SKalle Valo 1542bdcd8170SKalle Valo new_threshold = (enum wmi_snr_threshold_val) reply->range; 1543bdcd8170SKalle Valo snr = reply->snr; 1544bdcd8170SKalle Valo 1545bdcd8170SKalle Valo sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; 1546bdcd8170SKalle Valo 1547bdcd8170SKalle Valo /* 1548bdcd8170SKalle Valo * Identify the threshold breached and communicate that to the app. 1549bdcd8170SKalle Valo * After that install a new set of thresholds based on the signal 1550bdcd8170SKalle Valo * quality reported by the target. 1551bdcd8170SKalle Valo */ 1552bdcd8170SKalle Valo if (new_threshold) { 1553bdcd8170SKalle Valo /* Upper threshold breached */ 1554bdcd8170SKalle Valo if (snr < sq_thresh->upper_threshold[0]) { 1555bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1556bdcd8170SKalle Valo "spurious upper snr threshold event: %d\n", 1557bdcd8170SKalle Valo snr); 1558bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[1]) && 1559bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[0])) { 1560bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_ABOVE; 1561bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[2]) && 1562bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[1])) { 1563bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_ABOVE; 1564bdcd8170SKalle Valo } else if ((snr < sq_thresh->upper_threshold[3]) && 1565bdcd8170SKalle Valo (snr >= sq_thresh->upper_threshold[2])) { 1566bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_ABOVE; 1567bdcd8170SKalle Valo } else if (snr >= sq_thresh->upper_threshold[3]) { 1568bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_ABOVE; 1569bdcd8170SKalle Valo } 1570bdcd8170SKalle Valo } else { 1571bdcd8170SKalle Valo /* Lower threshold breached */ 1572bdcd8170SKalle Valo if (snr > sq_thresh->lower_threshold[0]) { 1573bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1574bdcd8170SKalle Valo "spurious lower snr threshold event: %d\n", 1575bdcd8170SKalle Valo sq_thresh->lower_threshold[0]); 1576bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[1]) && 1577bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[0])) { 1578bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD4_BELOW; 1579bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[2]) && 1580bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[1])) { 1581bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD3_BELOW; 1582bdcd8170SKalle Valo } else if ((snr > sq_thresh->lower_threshold[3]) && 1583bdcd8170SKalle Valo (snr <= sq_thresh->lower_threshold[2])) { 1584bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD2_BELOW; 1585bdcd8170SKalle Valo } else if (snr <= sq_thresh->lower_threshold[3]) { 1586bdcd8170SKalle Valo new_threshold = WMI_SNR_THRESHOLD1_BELOW; 1587bdcd8170SKalle Valo } 1588bdcd8170SKalle Valo } 1589bdcd8170SKalle Valo 1590bdcd8170SKalle Valo /* Calculate and install the next set of thresholds */ 1591bdcd8170SKalle Valo lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, 1592bdcd8170SKalle Valo sq_thresh->lower_threshold_valid_count); 1593bdcd8170SKalle Valo upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, 1594bdcd8170SKalle Valo sq_thresh->upper_threshold_valid_count); 1595bdcd8170SKalle Valo 1596bdcd8170SKalle Valo /* Issue a wmi command to install the thresholds */ 1597bdcd8170SKalle Valo cmd.thresh_above1_val = upper_snr_threshold; 1598bdcd8170SKalle Valo cmd.thresh_below1_val = lower_snr_threshold; 1599bdcd8170SKalle Valo cmd.weight = sq_thresh->weight; 1600bdcd8170SKalle Valo cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); 1601bdcd8170SKalle Valo 1602bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1603bdcd8170SKalle Valo "snr: %d, threshold: %d, lower: %d, upper: %d\n", 1604bdcd8170SKalle Valo snr, new_threshold, 1605bdcd8170SKalle Valo lower_snr_threshold, upper_snr_threshold); 1606bdcd8170SKalle Valo 1607bdcd8170SKalle Valo ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); 1608bdcd8170SKalle Valo if (ret) { 1609bdcd8170SKalle Valo ath6kl_err("unable to configure snr threshold\n"); 1610bdcd8170SKalle Valo return -EIO; 1611bdcd8170SKalle Valo } 1612bdcd8170SKalle Valo 1613bdcd8170SKalle Valo return 0; 1614bdcd8170SKalle Valo } 1615bdcd8170SKalle Valo 1616bdcd8170SKalle Valo static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) 1617bdcd8170SKalle Valo { 1618bdcd8170SKalle Valo u16 ap_info_entry_size; 1619bdcd8170SKalle Valo struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; 1620bdcd8170SKalle Valo struct wmi_ap_info_v1 *ap_info_v1; 1621bdcd8170SKalle Valo u8 index; 1622bdcd8170SKalle Valo 1623bdcd8170SKalle Valo if (len < sizeof(struct wmi_aplist_event) || 1624bdcd8170SKalle Valo ev->ap_list_ver != APLIST_VER1) 1625bdcd8170SKalle Valo return -EINVAL; 1626bdcd8170SKalle Valo 1627bdcd8170SKalle Valo ap_info_entry_size = sizeof(struct wmi_ap_info_v1); 1628bdcd8170SKalle Valo ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; 1629bdcd8170SKalle Valo 1630bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1631bdcd8170SKalle Valo "number of APs in aplist event: %d\n", ev->num_ap); 1632bdcd8170SKalle Valo 1633bdcd8170SKalle Valo if (len < (int) (sizeof(struct wmi_aplist_event) + 1634bdcd8170SKalle Valo (ev->num_ap - 1) * ap_info_entry_size)) 1635bdcd8170SKalle Valo return -EINVAL; 1636bdcd8170SKalle Valo 1637bdcd8170SKalle Valo /* AP list version 1 contents */ 1638bdcd8170SKalle Valo for (index = 0; index < ev->num_ap; index++) { 1639bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", 1640bdcd8170SKalle Valo index, ap_info_v1->bssid, ap_info_v1->channel); 1641bdcd8170SKalle Valo ap_info_v1++; 1642bdcd8170SKalle Valo } 1643bdcd8170SKalle Valo 1644bdcd8170SKalle Valo return 0; 1645bdcd8170SKalle Valo } 1646bdcd8170SKalle Valo 1647334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, 1648bdcd8170SKalle Valo enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) 1649bdcd8170SKalle Valo { 1650bdcd8170SKalle Valo struct wmi_cmd_hdr *cmd_hdr; 1651bdcd8170SKalle Valo enum htc_endpoint_id ep_id = wmi->ep_id; 1652bdcd8170SKalle Valo int ret; 1653334234b5SVasanthakumar Thiagarajan u16 info1; 1654bdcd8170SKalle Valo 165571f96ee6SKalle Valo if (WARN_ON(skb == NULL || (if_idx > (wmi->parent_dev->vif_max - 1)))) 1656bdcd8170SKalle Valo return -EINVAL; 1657bdcd8170SKalle Valo 1658b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n", 1659b9b6ee60SKalle Valo cmd_id, skb->len, sync_flag); 1660b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ", 1661b9b6ee60SKalle Valo skb->data, skb->len); 1662b9b6ee60SKalle Valo 1663bdcd8170SKalle Valo if (sync_flag >= END_WMIFLAG) { 1664bdcd8170SKalle Valo dev_kfree_skb(skb); 1665bdcd8170SKalle Valo return -EINVAL; 1666bdcd8170SKalle Valo } 1667bdcd8170SKalle Valo 1668bdcd8170SKalle Valo if ((sync_flag == SYNC_BEFORE_WMIFLAG) || 1669bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1670bdcd8170SKalle Valo /* 1671bdcd8170SKalle Valo * Make sure all data currently queued is transmitted before 1672bdcd8170SKalle Valo * the cmd execution. Establish a new sync point. 1673bdcd8170SKalle Valo */ 1674240d2799SVasanthakumar Thiagarajan ath6kl_wmi_sync_point(wmi, if_idx); 1675bdcd8170SKalle Valo } 1676bdcd8170SKalle Valo 1677bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_cmd_hdr)); 1678bdcd8170SKalle Valo 1679bdcd8170SKalle Valo cmd_hdr = (struct wmi_cmd_hdr *) skb->data; 1680bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le16(cmd_id); 1681334234b5SVasanthakumar Thiagarajan info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK; 1682334234b5SVasanthakumar Thiagarajan cmd_hdr->info1 = cpu_to_le16(info1); 1683bdcd8170SKalle Valo 1684bdcd8170SKalle Valo /* Only for OPT_TX_CMD, use BE endpoint. */ 1685bdcd8170SKalle Valo if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { 1686bdcd8170SKalle Valo ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, 16876765d0aaSVasanthakumar Thiagarajan false, false, 0, NULL, if_idx); 1688bdcd8170SKalle Valo if (ret) { 1689bdcd8170SKalle Valo dev_kfree_skb(skb); 1690bdcd8170SKalle Valo return ret; 1691bdcd8170SKalle Valo } 1692bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); 1693bdcd8170SKalle Valo } 1694bdcd8170SKalle Valo 1695bdcd8170SKalle Valo ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 1696bdcd8170SKalle Valo 1697bdcd8170SKalle Valo if ((sync_flag == SYNC_AFTER_WMIFLAG) || 1698bdcd8170SKalle Valo (sync_flag == SYNC_BOTH_WMIFLAG)) { 1699bdcd8170SKalle Valo /* 1700bdcd8170SKalle Valo * Make sure all new data queued waits for the command to 1701bdcd8170SKalle Valo * execute. Establish a new sync point. 1702bdcd8170SKalle Valo */ 1703240d2799SVasanthakumar Thiagarajan ath6kl_wmi_sync_point(wmi, if_idx); 1704bdcd8170SKalle Valo } 1705bdcd8170SKalle Valo 1706bdcd8170SKalle Valo return 0; 1707bdcd8170SKalle Valo } 1708bdcd8170SKalle Valo 1709334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx, 1710334234b5SVasanthakumar Thiagarajan enum network_type nw_type, 1711bdcd8170SKalle Valo enum dot11_auth_mode dot11_auth_mode, 1712bdcd8170SKalle Valo enum auth_mode auth_mode, 1713bdcd8170SKalle Valo enum crypto_type pairwise_crypto, 1714bdcd8170SKalle Valo u8 pairwise_crypto_len, 1715bdcd8170SKalle Valo enum crypto_type group_crypto, 1716bdcd8170SKalle Valo u8 group_crypto_len, int ssid_len, u8 *ssid, 17173ca9d1fcSAarthi Thiruvengadam u8 *bssid, u16 channel, u32 ctrl_flags, 17183ca9d1fcSAarthi Thiruvengadam u8 nw_subtype) 1719bdcd8170SKalle Valo { 1720bdcd8170SKalle Valo struct sk_buff *skb; 1721bdcd8170SKalle Valo struct wmi_connect_cmd *cc; 1722bdcd8170SKalle Valo int ret; 1723bdcd8170SKalle Valo 1724b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 1725b9b6ee60SKalle Valo "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d " 1726b9b6ee60SKalle Valo "type %d dot11_auth %d auth %d pairwise %d group %d\n", 1727b9b6ee60SKalle Valo bssid, channel, ctrl_flags, ssid_len, nw_type, 1728b9b6ee60SKalle Valo dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto); 1729b9b6ee60SKalle Valo ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len); 1730b9b6ee60SKalle Valo 1731bdcd8170SKalle Valo wmi->traffic_class = 100; 1732bdcd8170SKalle Valo 1733bdcd8170SKalle Valo if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) 1734bdcd8170SKalle Valo return -EINVAL; 1735bdcd8170SKalle Valo 1736bdcd8170SKalle Valo if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) 1737bdcd8170SKalle Valo return -EINVAL; 1738bdcd8170SKalle Valo 1739bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); 1740bdcd8170SKalle Valo if (!skb) 1741bdcd8170SKalle Valo return -ENOMEM; 1742bdcd8170SKalle Valo 1743bdcd8170SKalle Valo cc = (struct wmi_connect_cmd *) skb->data; 1744bdcd8170SKalle Valo 1745bdcd8170SKalle Valo if (ssid_len) 1746bdcd8170SKalle Valo memcpy(cc->ssid, ssid, ssid_len); 1747bdcd8170SKalle Valo 1748bdcd8170SKalle Valo cc->ssid_len = ssid_len; 1749bdcd8170SKalle Valo cc->nw_type = nw_type; 1750bdcd8170SKalle Valo cc->dot11_auth_mode = dot11_auth_mode; 1751bdcd8170SKalle Valo cc->auth_mode = auth_mode; 1752bdcd8170SKalle Valo cc->prwise_crypto_type = pairwise_crypto; 1753bdcd8170SKalle Valo cc->prwise_crypto_len = pairwise_crypto_len; 1754bdcd8170SKalle Valo cc->grp_crypto_type = group_crypto; 1755bdcd8170SKalle Valo cc->grp_crypto_len = group_crypto_len; 1756bdcd8170SKalle Valo cc->ch = cpu_to_le16(channel); 1757bdcd8170SKalle Valo cc->ctrl_flags = cpu_to_le32(ctrl_flags); 17583ca9d1fcSAarthi Thiruvengadam cc->nw_subtype = nw_subtype; 1759bdcd8170SKalle Valo 1760bdcd8170SKalle Valo if (bssid != NULL) 1761bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1762bdcd8170SKalle Valo 1763334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID, 1764334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 1765bdcd8170SKalle Valo 1766bdcd8170SKalle Valo return ret; 1767bdcd8170SKalle Valo } 1768bdcd8170SKalle Valo 1769334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid, 1770334234b5SVasanthakumar Thiagarajan u16 channel) 1771bdcd8170SKalle Valo { 1772bdcd8170SKalle Valo struct sk_buff *skb; 1773bdcd8170SKalle Valo struct wmi_reconnect_cmd *cc; 1774bdcd8170SKalle Valo int ret; 1775bdcd8170SKalle Valo 1776b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n", 1777b9b6ee60SKalle Valo bssid, channel); 1778b9b6ee60SKalle Valo 1779bdcd8170SKalle Valo wmi->traffic_class = 100; 1780bdcd8170SKalle Valo 1781bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); 1782bdcd8170SKalle Valo if (!skb) 1783bdcd8170SKalle Valo return -ENOMEM; 1784bdcd8170SKalle Valo 1785bdcd8170SKalle Valo cc = (struct wmi_reconnect_cmd *) skb->data; 1786bdcd8170SKalle Valo cc->channel = cpu_to_le16(channel); 1787bdcd8170SKalle Valo 1788bdcd8170SKalle Valo if (bssid != NULL) 1789bdcd8170SKalle Valo memcpy(cc->bssid, bssid, ETH_ALEN); 1790bdcd8170SKalle Valo 1791334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID, 1792bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1793bdcd8170SKalle Valo 1794bdcd8170SKalle Valo return ret; 1795bdcd8170SKalle Valo } 1796bdcd8170SKalle Valo 1797334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx) 1798bdcd8170SKalle Valo { 1799bdcd8170SKalle Valo int ret; 1800bdcd8170SKalle Valo 1801b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n"); 1802b9b6ee60SKalle Valo 1803bdcd8170SKalle Valo wmi->traffic_class = 100; 1804bdcd8170SKalle Valo 1805bdcd8170SKalle Valo /* Disconnect command does not need to do a SYNC before. */ 1806334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID); 1807bdcd8170SKalle Valo 1808bdcd8170SKalle Valo return ret; 1809bdcd8170SKalle Valo } 1810bdcd8170SKalle Valo 18113ca9d1fcSAarthi Thiruvengadam int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx, 18123ca9d1fcSAarthi Thiruvengadam enum wmi_scan_type scan_type, 18133ca9d1fcSAarthi Thiruvengadam u32 force_fgscan, u32 is_legacy, 18143ca9d1fcSAarthi Thiruvengadam u32 home_dwell_time, u32 force_scan_interval, 18153ca9d1fcSAarthi Thiruvengadam s8 num_chan, u16 *ch_list, u32 no_cck, u32 *rates) 18163ca9d1fcSAarthi Thiruvengadam { 18173ca9d1fcSAarthi Thiruvengadam struct sk_buff *skb; 18183ca9d1fcSAarthi Thiruvengadam struct wmi_begin_scan_cmd *sc; 18193ca9d1fcSAarthi Thiruvengadam s8 size; 18203ca9d1fcSAarthi Thiruvengadam int i, band, ret; 18213ca9d1fcSAarthi Thiruvengadam struct ath6kl *ar = wmi->parent_dev; 18223ca9d1fcSAarthi Thiruvengadam int num_rates; 18233ca9d1fcSAarthi Thiruvengadam 18243ca9d1fcSAarthi Thiruvengadam size = sizeof(struct wmi_begin_scan_cmd); 18253ca9d1fcSAarthi Thiruvengadam 18263ca9d1fcSAarthi Thiruvengadam if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 18273ca9d1fcSAarthi Thiruvengadam return -EINVAL; 18283ca9d1fcSAarthi Thiruvengadam 18293ca9d1fcSAarthi Thiruvengadam if (num_chan > WMI_MAX_CHANNELS) 18303ca9d1fcSAarthi Thiruvengadam return -EINVAL; 18313ca9d1fcSAarthi Thiruvengadam 18323ca9d1fcSAarthi Thiruvengadam if (num_chan) 18333ca9d1fcSAarthi Thiruvengadam size += sizeof(u16) * (num_chan - 1); 18343ca9d1fcSAarthi Thiruvengadam 18353ca9d1fcSAarthi Thiruvengadam skb = ath6kl_wmi_get_new_buf(size); 18363ca9d1fcSAarthi Thiruvengadam if (!skb) 18373ca9d1fcSAarthi Thiruvengadam return -ENOMEM; 18383ca9d1fcSAarthi Thiruvengadam 18393ca9d1fcSAarthi Thiruvengadam sc = (struct wmi_begin_scan_cmd *) skb->data; 18403ca9d1fcSAarthi Thiruvengadam sc->scan_type = scan_type; 18413ca9d1fcSAarthi Thiruvengadam sc->force_fg_scan = cpu_to_le32(force_fgscan); 18423ca9d1fcSAarthi Thiruvengadam sc->is_legacy = cpu_to_le32(is_legacy); 18433ca9d1fcSAarthi Thiruvengadam sc->home_dwell_time = cpu_to_le32(home_dwell_time); 18443ca9d1fcSAarthi Thiruvengadam sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 18453ca9d1fcSAarthi Thiruvengadam sc->no_cck = cpu_to_le32(no_cck); 18463ca9d1fcSAarthi Thiruvengadam sc->num_ch = num_chan; 18473ca9d1fcSAarthi Thiruvengadam 18483ca9d1fcSAarthi Thiruvengadam for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 18493ca9d1fcSAarthi Thiruvengadam struct ieee80211_supported_band *sband = 18503ca9d1fcSAarthi Thiruvengadam ar->wiphy->bands[band]; 18513ca9d1fcSAarthi Thiruvengadam u32 ratemask = rates[band]; 18523ca9d1fcSAarthi Thiruvengadam u8 *supp_rates = sc->supp_rates[band].rates; 18533ca9d1fcSAarthi Thiruvengadam num_rates = 0; 18543ca9d1fcSAarthi Thiruvengadam 18553ca9d1fcSAarthi Thiruvengadam for (i = 0; i < sband->n_bitrates; i++) { 18563ca9d1fcSAarthi Thiruvengadam if ((BIT(i) & ratemask) == 0) 18573ca9d1fcSAarthi Thiruvengadam continue; /* skip rate */ 18583ca9d1fcSAarthi Thiruvengadam supp_rates[num_rates++] = 18593ca9d1fcSAarthi Thiruvengadam (u8) (sband->bitrates[i].bitrate / 5); 18603ca9d1fcSAarthi Thiruvengadam } 18613ca9d1fcSAarthi Thiruvengadam sc->supp_rates[band].nrates = num_rates; 18623ca9d1fcSAarthi Thiruvengadam } 18633ca9d1fcSAarthi Thiruvengadam 18643ca9d1fcSAarthi Thiruvengadam for (i = 0; i < num_chan; i++) 18653ca9d1fcSAarthi Thiruvengadam sc->ch_list[i] = cpu_to_le16(ch_list[i]); 18663ca9d1fcSAarthi Thiruvengadam 18673ca9d1fcSAarthi Thiruvengadam ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_BEGIN_SCAN_CMDID, 18683ca9d1fcSAarthi Thiruvengadam NO_SYNC_WMIFLAG); 18693ca9d1fcSAarthi Thiruvengadam 18703ca9d1fcSAarthi Thiruvengadam return ret; 18713ca9d1fcSAarthi Thiruvengadam } 18723ca9d1fcSAarthi Thiruvengadam 18733ca9d1fcSAarthi Thiruvengadam /* ath6kl_wmi_start_scan_cmd is to be deprecated. Use 18743ca9d1fcSAarthi Thiruvengadam * ath6kl_wmi_begin_scan_cmd instead. The new function supports P2P 18753ca9d1fcSAarthi Thiruvengadam * mgmt operations using station interface. 18763ca9d1fcSAarthi Thiruvengadam */ 1877334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx, 1878334234b5SVasanthakumar Thiagarajan enum wmi_scan_type scan_type, 1879bdcd8170SKalle Valo u32 force_fgscan, u32 is_legacy, 1880bdcd8170SKalle Valo u32 home_dwell_time, u32 force_scan_interval, 1881bdcd8170SKalle Valo s8 num_chan, u16 *ch_list) 1882bdcd8170SKalle Valo { 1883bdcd8170SKalle Valo struct sk_buff *skb; 1884bdcd8170SKalle Valo struct wmi_start_scan_cmd *sc; 1885bdcd8170SKalle Valo s8 size; 18861276c9efSEdward Lu int i, ret; 1887bdcd8170SKalle Valo 1888bdcd8170SKalle Valo size = sizeof(struct wmi_start_scan_cmd); 1889bdcd8170SKalle Valo 1890bdcd8170SKalle Valo if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) 1891bdcd8170SKalle Valo return -EINVAL; 1892bdcd8170SKalle Valo 1893bdcd8170SKalle Valo if (num_chan > WMI_MAX_CHANNELS) 1894bdcd8170SKalle Valo return -EINVAL; 1895bdcd8170SKalle Valo 1896bdcd8170SKalle Valo if (num_chan) 1897bdcd8170SKalle Valo size += sizeof(u16) * (num_chan - 1); 1898bdcd8170SKalle Valo 1899bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(size); 1900bdcd8170SKalle Valo if (!skb) 1901bdcd8170SKalle Valo return -ENOMEM; 1902bdcd8170SKalle Valo 1903bdcd8170SKalle Valo sc = (struct wmi_start_scan_cmd *) skb->data; 1904bdcd8170SKalle Valo sc->scan_type = scan_type; 1905bdcd8170SKalle Valo sc->force_fg_scan = cpu_to_le32(force_fgscan); 1906bdcd8170SKalle Valo sc->is_legacy = cpu_to_le32(is_legacy); 1907bdcd8170SKalle Valo sc->home_dwell_time = cpu_to_le32(home_dwell_time); 1908bdcd8170SKalle Valo sc->force_scan_intvl = cpu_to_le32(force_scan_interval); 1909bdcd8170SKalle Valo sc->num_ch = num_chan; 1910bdcd8170SKalle Valo 19111276c9efSEdward Lu for (i = 0; i < num_chan; i++) 19121276c9efSEdward Lu sc->ch_list[i] = cpu_to_le16(ch_list[i]); 1913bdcd8170SKalle Valo 1914334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID, 1915bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1916bdcd8170SKalle Valo 1917bdcd8170SKalle Valo return ret; 1918bdcd8170SKalle Valo } 1919bdcd8170SKalle Valo 1920334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx, 1921334234b5SVasanthakumar Thiagarajan u16 fg_start_sec, 1922bdcd8170SKalle Valo u16 fg_end_sec, u16 bg_sec, 1923bdcd8170SKalle Valo u16 minact_chdw_msec, u16 maxact_chdw_msec, 1924bdcd8170SKalle Valo u16 pas_chdw_msec, u8 short_scan_ratio, 1925bdcd8170SKalle Valo u8 scan_ctrl_flag, u32 max_dfsch_act_time, 1926bdcd8170SKalle Valo u16 maxact_scan_per_ssid) 1927bdcd8170SKalle Valo { 1928bdcd8170SKalle Valo struct sk_buff *skb; 1929bdcd8170SKalle Valo struct wmi_scan_params_cmd *sc; 1930bdcd8170SKalle Valo int ret; 1931bdcd8170SKalle Valo 1932bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); 1933bdcd8170SKalle Valo if (!skb) 1934bdcd8170SKalle Valo return -ENOMEM; 1935bdcd8170SKalle Valo 1936bdcd8170SKalle Valo sc = (struct wmi_scan_params_cmd *) skb->data; 1937bdcd8170SKalle Valo sc->fg_start_period = cpu_to_le16(fg_start_sec); 1938bdcd8170SKalle Valo sc->fg_end_period = cpu_to_le16(fg_end_sec); 1939bdcd8170SKalle Valo sc->bg_period = cpu_to_le16(bg_sec); 1940bdcd8170SKalle Valo sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); 1941bdcd8170SKalle Valo sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); 1942bdcd8170SKalle Valo sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); 1943bdcd8170SKalle Valo sc->short_scan_ratio = short_scan_ratio; 1944bdcd8170SKalle Valo sc->scan_ctrl_flags = scan_ctrl_flag; 1945bdcd8170SKalle Valo sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); 1946bdcd8170SKalle Valo sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); 1947bdcd8170SKalle Valo 1948334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID, 1949bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1950bdcd8170SKalle Valo return ret; 1951bdcd8170SKalle Valo } 1952bdcd8170SKalle Valo 1953240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask) 1954bdcd8170SKalle Valo { 1955bdcd8170SKalle Valo struct sk_buff *skb; 1956bdcd8170SKalle Valo struct wmi_bss_filter_cmd *cmd; 1957bdcd8170SKalle Valo int ret; 1958bdcd8170SKalle Valo 1959bdcd8170SKalle Valo if (filter >= LAST_BSS_FILTER) 1960bdcd8170SKalle Valo return -EINVAL; 1961bdcd8170SKalle Valo 1962bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1963bdcd8170SKalle Valo if (!skb) 1964bdcd8170SKalle Valo return -ENOMEM; 1965bdcd8170SKalle Valo 1966bdcd8170SKalle Valo cmd = (struct wmi_bss_filter_cmd *) skb->data; 1967bdcd8170SKalle Valo cmd->bss_filter = filter; 1968bdcd8170SKalle Valo cmd->ie_mask = cpu_to_le32(ie_mask); 1969bdcd8170SKalle Valo 1970240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID, 1971bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 1972bdcd8170SKalle Valo return ret; 1973bdcd8170SKalle Valo } 1974bdcd8170SKalle Valo 1975334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag, 1976bdcd8170SKalle Valo u8 ssid_len, u8 *ssid) 1977bdcd8170SKalle Valo { 1978bdcd8170SKalle Valo struct sk_buff *skb; 1979bdcd8170SKalle Valo struct wmi_probed_ssid_cmd *cmd; 1980bdcd8170SKalle Valo int ret; 1981bdcd8170SKalle Valo 1982bdcd8170SKalle Valo if (index > MAX_PROBED_SSID_INDEX) 1983bdcd8170SKalle Valo return -EINVAL; 1984bdcd8170SKalle Valo 1985bdcd8170SKalle Valo if (ssid_len > sizeof(cmd->ssid)) 1986bdcd8170SKalle Valo return -EINVAL; 1987bdcd8170SKalle Valo 1988bdcd8170SKalle Valo if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) 1989bdcd8170SKalle Valo return -EINVAL; 1990bdcd8170SKalle Valo 1991bdcd8170SKalle Valo if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) 1992bdcd8170SKalle Valo return -EINVAL; 1993bdcd8170SKalle Valo 1994bdcd8170SKalle Valo if (flag & SPECIFIC_SSID_FLAG) 1995bdcd8170SKalle Valo wmi->is_probe_ssid = true; 1996bdcd8170SKalle Valo 1997bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 1998bdcd8170SKalle Valo if (!skb) 1999bdcd8170SKalle Valo return -ENOMEM; 2000bdcd8170SKalle Valo 2001bdcd8170SKalle Valo cmd = (struct wmi_probed_ssid_cmd *) skb->data; 2002bdcd8170SKalle Valo cmd->entry_index = index; 2003bdcd8170SKalle Valo cmd->flag = flag; 2004bdcd8170SKalle Valo cmd->ssid_len = ssid_len; 2005bdcd8170SKalle Valo memcpy(cmd->ssid, ssid, ssid_len); 2006bdcd8170SKalle Valo 2007334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID, 2008bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2009bdcd8170SKalle Valo return ret; 2010bdcd8170SKalle Valo } 2011bdcd8170SKalle Valo 2012334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, 2013334234b5SVasanthakumar Thiagarajan u16 listen_interval, 2014bdcd8170SKalle Valo u16 listen_beacons) 2015bdcd8170SKalle Valo { 2016bdcd8170SKalle Valo struct sk_buff *skb; 2017bdcd8170SKalle Valo struct wmi_listen_int_cmd *cmd; 2018bdcd8170SKalle Valo int ret; 2019bdcd8170SKalle Valo 2020bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2021bdcd8170SKalle Valo if (!skb) 2022bdcd8170SKalle Valo return -ENOMEM; 2023bdcd8170SKalle Valo 2024bdcd8170SKalle Valo cmd = (struct wmi_listen_int_cmd *) skb->data; 2025bdcd8170SKalle Valo cmd->listen_intvl = cpu_to_le16(listen_interval); 2026bdcd8170SKalle Valo cmd->num_beacons = cpu_to_le16(listen_beacons); 2027bdcd8170SKalle Valo 2028334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID, 2029bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2030bdcd8170SKalle Valo return ret; 2031bdcd8170SKalle Valo } 2032bdcd8170SKalle Valo 2033ce0dc0cfSRaja Mani int ath6kl_wmi_bmisstime_cmd(struct wmi *wmi, u8 if_idx, 2034ce0dc0cfSRaja Mani u16 bmiss_time, u16 num_beacons) 2035ce0dc0cfSRaja Mani { 2036ce0dc0cfSRaja Mani struct sk_buff *skb; 2037ce0dc0cfSRaja Mani struct wmi_bmiss_time_cmd *cmd; 2038ce0dc0cfSRaja Mani int ret; 2039ce0dc0cfSRaja Mani 2040ce0dc0cfSRaja Mani skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2041ce0dc0cfSRaja Mani if (!skb) 2042ce0dc0cfSRaja Mani return -ENOMEM; 2043ce0dc0cfSRaja Mani 2044ce0dc0cfSRaja Mani cmd = (struct wmi_bmiss_time_cmd *) skb->data; 2045ce0dc0cfSRaja Mani cmd->bmiss_time = cpu_to_le16(bmiss_time); 2046ce0dc0cfSRaja Mani cmd->num_beacons = cpu_to_le16(num_beacons); 2047ce0dc0cfSRaja Mani 2048ce0dc0cfSRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BMISS_TIME_CMDID, 2049ce0dc0cfSRaja Mani NO_SYNC_WMIFLAG); 2050ce0dc0cfSRaja Mani return ret; 2051ce0dc0cfSRaja Mani } 2052ce0dc0cfSRaja Mani 2053334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode) 2054bdcd8170SKalle Valo { 2055bdcd8170SKalle Valo struct sk_buff *skb; 2056bdcd8170SKalle Valo struct wmi_power_mode_cmd *cmd; 2057bdcd8170SKalle Valo int ret; 2058bdcd8170SKalle Valo 2059bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2060bdcd8170SKalle Valo if (!skb) 2061bdcd8170SKalle Valo return -ENOMEM; 2062bdcd8170SKalle Valo 2063bdcd8170SKalle Valo cmd = (struct wmi_power_mode_cmd *) skb->data; 2064bdcd8170SKalle Valo cmd->pwr_mode = pwr_mode; 2065bdcd8170SKalle Valo wmi->pwr_mode = pwr_mode; 2066bdcd8170SKalle Valo 2067334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID, 2068bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2069bdcd8170SKalle Valo return ret; 2070bdcd8170SKalle Valo } 2071bdcd8170SKalle Valo 20720ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period, 2073bdcd8170SKalle Valo u16 ps_poll_num, u16 dtim_policy, 2074bdcd8170SKalle Valo u16 tx_wakeup_policy, u16 num_tx_to_wakeup, 2075bdcd8170SKalle Valo u16 ps_fail_event_policy) 2076bdcd8170SKalle Valo { 2077bdcd8170SKalle Valo struct sk_buff *skb; 2078bdcd8170SKalle Valo struct wmi_power_params_cmd *pm; 2079bdcd8170SKalle Valo int ret; 2080bdcd8170SKalle Valo 2081bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); 2082bdcd8170SKalle Valo if (!skb) 2083bdcd8170SKalle Valo return -ENOMEM; 2084bdcd8170SKalle Valo 2085bdcd8170SKalle Valo pm = (struct wmi_power_params_cmd *)skb->data; 2086bdcd8170SKalle Valo pm->idle_period = cpu_to_le16(idle_period); 2087bdcd8170SKalle Valo pm->pspoll_number = cpu_to_le16(ps_poll_num); 2088bdcd8170SKalle Valo pm->dtim_policy = cpu_to_le16(dtim_policy); 2089bdcd8170SKalle Valo pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); 2090bdcd8170SKalle Valo pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); 2091bdcd8170SKalle Valo pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); 2092bdcd8170SKalle Valo 20930ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID, 2094bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2095bdcd8170SKalle Valo return ret; 2096bdcd8170SKalle Valo } 2097bdcd8170SKalle Valo 20980ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout) 2099bdcd8170SKalle Valo { 2100bdcd8170SKalle Valo struct sk_buff *skb; 2101bdcd8170SKalle Valo struct wmi_disc_timeout_cmd *cmd; 2102bdcd8170SKalle Valo int ret; 2103bdcd8170SKalle Valo 2104bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2105bdcd8170SKalle Valo if (!skb) 2106bdcd8170SKalle Valo return -ENOMEM; 2107bdcd8170SKalle Valo 2108bdcd8170SKalle Valo cmd = (struct wmi_disc_timeout_cmd *) skb->data; 2109bdcd8170SKalle Valo cmd->discon_timeout = timeout; 2110bdcd8170SKalle Valo 21110ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID, 2112bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2113334234b5SVasanthakumar Thiagarajan 2114ff0b0075SJouni Malinen if (ret == 0) 2115ff0b0075SJouni Malinen ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout); 2116334234b5SVasanthakumar Thiagarajan 2117bdcd8170SKalle Valo return ret; 2118bdcd8170SKalle Valo } 2119bdcd8170SKalle Valo 2120334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, 2121bdcd8170SKalle Valo enum crypto_type key_type, 2122bdcd8170SKalle Valo u8 key_usage, u8 key_len, 2123f4bb9a6fSJouni Malinen u8 *key_rsc, unsigned int key_rsc_len, 2124f4bb9a6fSJouni Malinen u8 *key_material, 2125bdcd8170SKalle Valo u8 key_op_ctrl, u8 *mac_addr, 2126bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2127bdcd8170SKalle Valo { 2128bdcd8170SKalle Valo struct sk_buff *skb; 2129bdcd8170SKalle Valo struct wmi_add_cipher_key_cmd *cmd; 2130bdcd8170SKalle Valo int ret; 2131bdcd8170SKalle Valo 21329a5b1318SJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " 21339a5b1318SJouni Malinen "key_usage=%d key_len=%d key_op_ctrl=%d\n", 21349a5b1318SJouni Malinen key_index, key_type, key_usage, key_len, key_op_ctrl); 21359a5b1318SJouni Malinen 2136bdcd8170SKalle Valo if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || 2137f4bb9a6fSJouni Malinen (key_material == NULL) || key_rsc_len > 8) 2138bdcd8170SKalle Valo return -EINVAL; 2139bdcd8170SKalle Valo 2140bdcd8170SKalle Valo if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) 2141bdcd8170SKalle Valo return -EINVAL; 2142bdcd8170SKalle Valo 2143bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2144bdcd8170SKalle Valo if (!skb) 2145bdcd8170SKalle Valo return -ENOMEM; 2146bdcd8170SKalle Valo 2147bdcd8170SKalle Valo cmd = (struct wmi_add_cipher_key_cmd *) skb->data; 2148bdcd8170SKalle Valo cmd->key_index = key_index; 2149bdcd8170SKalle Valo cmd->key_type = key_type; 2150bdcd8170SKalle Valo cmd->key_usage = key_usage; 2151bdcd8170SKalle Valo cmd->key_len = key_len; 2152bdcd8170SKalle Valo memcpy(cmd->key, key_material, key_len); 2153bdcd8170SKalle Valo 2154bdcd8170SKalle Valo if (key_rsc != NULL) 2155f4bb9a6fSJouni Malinen memcpy(cmd->key_rsc, key_rsc, key_rsc_len); 2156bdcd8170SKalle Valo 2157bdcd8170SKalle Valo cmd->key_op_ctrl = key_op_ctrl; 2158bdcd8170SKalle Valo 2159bdcd8170SKalle Valo if (mac_addr) 2160bdcd8170SKalle Valo memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); 2161bdcd8170SKalle Valo 2162334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID, 2163bdcd8170SKalle Valo sync_flag); 2164bdcd8170SKalle Valo 2165bdcd8170SKalle Valo return ret; 2166bdcd8170SKalle Valo } 2167bdcd8170SKalle Valo 2168240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk) 2169bdcd8170SKalle Valo { 2170bdcd8170SKalle Valo struct sk_buff *skb; 2171bdcd8170SKalle Valo struct wmi_add_krk_cmd *cmd; 2172bdcd8170SKalle Valo int ret; 2173bdcd8170SKalle Valo 2174bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2175bdcd8170SKalle Valo if (!skb) 2176bdcd8170SKalle Valo return -ENOMEM; 2177bdcd8170SKalle Valo 2178bdcd8170SKalle Valo cmd = (struct wmi_add_krk_cmd *) skb->data; 2179bdcd8170SKalle Valo memcpy(cmd->krk, krk, WMI_KRK_LEN); 2180bdcd8170SKalle Valo 2181240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID, 2182334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2183bdcd8170SKalle Valo 2184bdcd8170SKalle Valo return ret; 2185bdcd8170SKalle Valo } 2186bdcd8170SKalle Valo 2187334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index) 2188bdcd8170SKalle Valo { 2189bdcd8170SKalle Valo struct sk_buff *skb; 2190bdcd8170SKalle Valo struct wmi_delete_cipher_key_cmd *cmd; 2191bdcd8170SKalle Valo int ret; 2192bdcd8170SKalle Valo 2193bdcd8170SKalle Valo if (key_index > WMI_MAX_KEY_INDEX) 2194bdcd8170SKalle Valo return -EINVAL; 2195bdcd8170SKalle Valo 2196bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2197bdcd8170SKalle Valo if (!skb) 2198bdcd8170SKalle Valo return -ENOMEM; 2199bdcd8170SKalle Valo 2200bdcd8170SKalle Valo cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; 2201bdcd8170SKalle Valo cmd->key_index = key_index; 2202bdcd8170SKalle Valo 2203334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID, 2204bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2205bdcd8170SKalle Valo 2206bdcd8170SKalle Valo return ret; 2207bdcd8170SKalle Valo } 2208bdcd8170SKalle Valo 2209334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, 2210bdcd8170SKalle Valo const u8 *pmkid, bool set) 2211bdcd8170SKalle Valo { 2212bdcd8170SKalle Valo struct sk_buff *skb; 2213bdcd8170SKalle Valo struct wmi_setpmkid_cmd *cmd; 2214bdcd8170SKalle Valo int ret; 2215bdcd8170SKalle Valo 2216bdcd8170SKalle Valo if (bssid == NULL) 2217bdcd8170SKalle Valo return -EINVAL; 2218bdcd8170SKalle Valo 2219bdcd8170SKalle Valo if (set && pmkid == NULL) 2220bdcd8170SKalle Valo return -EINVAL; 2221bdcd8170SKalle Valo 2222bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2223bdcd8170SKalle Valo if (!skb) 2224bdcd8170SKalle Valo return -ENOMEM; 2225bdcd8170SKalle Valo 2226bdcd8170SKalle Valo cmd = (struct wmi_setpmkid_cmd *) skb->data; 2227bdcd8170SKalle Valo memcpy(cmd->bssid, bssid, ETH_ALEN); 2228bdcd8170SKalle Valo if (set) { 2229bdcd8170SKalle Valo memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); 2230bdcd8170SKalle Valo cmd->enable = PMKID_ENABLE; 2231bdcd8170SKalle Valo } else { 2232bdcd8170SKalle Valo memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); 2233bdcd8170SKalle Valo cmd->enable = PMKID_DISABLE; 2234bdcd8170SKalle Valo } 2235bdcd8170SKalle Valo 2236334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID, 2237bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2238bdcd8170SKalle Valo 2239bdcd8170SKalle Valo return ret; 2240bdcd8170SKalle Valo } 2241bdcd8170SKalle Valo 2242bdcd8170SKalle Valo static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, 22436765d0aaSVasanthakumar Thiagarajan enum htc_endpoint_id ep_id, u8 if_idx) 2244bdcd8170SKalle Valo { 2245bdcd8170SKalle Valo struct wmi_data_hdr *data_hdr; 2246bdcd8170SKalle Valo int ret; 2247bdcd8170SKalle Valo 2248bdcd8170SKalle Valo if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) 2249bdcd8170SKalle Valo return -EINVAL; 2250bdcd8170SKalle Valo 2251bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmi_data_hdr)); 2252bdcd8170SKalle Valo 2253bdcd8170SKalle Valo data_hdr = (struct wmi_data_hdr *) skb->data; 2254bdcd8170SKalle Valo data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; 22556765d0aaSVasanthakumar Thiagarajan data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); 2256bdcd8170SKalle Valo 2257bdcd8170SKalle Valo ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); 2258bdcd8170SKalle Valo 2259bdcd8170SKalle Valo return ret; 2260bdcd8170SKalle Valo } 2261bdcd8170SKalle Valo 2262240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx) 2263bdcd8170SKalle Valo { 2264bdcd8170SKalle Valo struct sk_buff *skb; 2265bdcd8170SKalle Valo struct wmi_sync_cmd *cmd; 2266bdcd8170SKalle Valo struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; 2267bdcd8170SKalle Valo enum htc_endpoint_id ep_id; 2268bdcd8170SKalle Valo u8 index, num_pri_streams = 0; 2269bdcd8170SKalle Valo int ret = 0; 2270bdcd8170SKalle Valo 2271bdcd8170SKalle Valo memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); 2272bdcd8170SKalle Valo 2273bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2274bdcd8170SKalle Valo 2275bdcd8170SKalle Valo for (index = 0; index < WMM_NUM_AC; index++) { 2276bdcd8170SKalle Valo if (wmi->fat_pipe_exist & (1 << index)) { 2277bdcd8170SKalle Valo num_pri_streams++; 2278bdcd8170SKalle Valo data_sync_bufs[num_pri_streams - 1].traffic_class = 2279bdcd8170SKalle Valo index; 2280bdcd8170SKalle Valo } 2281bdcd8170SKalle Valo } 2282bdcd8170SKalle Valo 2283bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2284bdcd8170SKalle Valo 2285bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2286bdcd8170SKalle Valo if (!skb) { 2287bdcd8170SKalle Valo ret = -ENOMEM; 2288bdcd8170SKalle Valo goto free_skb; 2289bdcd8170SKalle Valo } 2290bdcd8170SKalle Valo 2291bdcd8170SKalle Valo cmd = (struct wmi_sync_cmd *) skb->data; 2292bdcd8170SKalle Valo 2293bdcd8170SKalle Valo /* 2294bdcd8170SKalle Valo * In the SYNC cmd sent on the control Ep, send a bitmap 2295bdcd8170SKalle Valo * of the data eps on which the Data Sync will be sent 2296bdcd8170SKalle Valo */ 2297bdcd8170SKalle Valo cmd->data_sync_map = wmi->fat_pipe_exist; 2298bdcd8170SKalle Valo 2299bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2300bdcd8170SKalle Valo data_sync_bufs[index].skb = ath6kl_buf_alloc(0); 2301bdcd8170SKalle Valo if (data_sync_bufs[index].skb == NULL) { 2302bdcd8170SKalle Valo ret = -ENOMEM; 2303bdcd8170SKalle Valo break; 2304bdcd8170SKalle Valo } 2305bdcd8170SKalle Valo } 2306bdcd8170SKalle Valo 2307bdcd8170SKalle Valo /* 2308bdcd8170SKalle Valo * If buffer allocation for any of the dataSync fails, 2309bdcd8170SKalle Valo * then do not send the Synchronize cmd on the control ep 2310bdcd8170SKalle Valo */ 2311bdcd8170SKalle Valo if (ret) 2312bdcd8170SKalle Valo goto free_skb; 2313bdcd8170SKalle Valo 2314bdcd8170SKalle Valo /* 2315bdcd8170SKalle Valo * Send sync cmd followed by sync data messages on all 2316bdcd8170SKalle Valo * endpoints being used 2317bdcd8170SKalle Valo */ 2318240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID, 2319bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2320bdcd8170SKalle Valo 2321bdcd8170SKalle Valo if (ret) 2322bdcd8170SKalle Valo goto free_skb; 2323bdcd8170SKalle Valo 2324bdcd8170SKalle Valo /* cmd buffer sent, we no longer own it */ 2325bdcd8170SKalle Valo skb = NULL; 2326bdcd8170SKalle Valo 2327bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2328bdcd8170SKalle Valo 2329bdcd8170SKalle Valo if (WARN_ON(!data_sync_bufs[index].skb)) 2330bdcd8170SKalle Valo break; 2331bdcd8170SKalle Valo 2332bdcd8170SKalle Valo ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, 2333bdcd8170SKalle Valo data_sync_bufs[index]. 2334bdcd8170SKalle Valo traffic_class); 2335bdcd8170SKalle Valo ret = 2336bdcd8170SKalle Valo ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, 23376765d0aaSVasanthakumar Thiagarajan ep_id, if_idx); 2338bdcd8170SKalle Valo 2339bdcd8170SKalle Valo if (ret) 2340bdcd8170SKalle Valo break; 2341bdcd8170SKalle Valo 2342bdcd8170SKalle Valo data_sync_bufs[index].skb = NULL; 2343bdcd8170SKalle Valo } 2344bdcd8170SKalle Valo 2345bdcd8170SKalle Valo free_skb: 2346bdcd8170SKalle Valo /* free up any resources left over (possibly due to an error) */ 2347bdcd8170SKalle Valo if (skb) 2348bdcd8170SKalle Valo dev_kfree_skb(skb); 2349bdcd8170SKalle Valo 2350bdcd8170SKalle Valo for (index = 0; index < num_pri_streams; index++) { 2351bdcd8170SKalle Valo if (data_sync_bufs[index].skb != NULL) { 2352bdcd8170SKalle Valo dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. 2353bdcd8170SKalle Valo skb); 2354bdcd8170SKalle Valo } 2355bdcd8170SKalle Valo } 2356bdcd8170SKalle Valo 2357bdcd8170SKalle Valo return ret; 2358bdcd8170SKalle Valo } 2359bdcd8170SKalle Valo 2360240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx, 2361bdcd8170SKalle Valo struct wmi_create_pstream_cmd *params) 2362bdcd8170SKalle Valo { 2363bdcd8170SKalle Valo struct sk_buff *skb; 2364bdcd8170SKalle Valo struct wmi_create_pstream_cmd *cmd; 2365bdcd8170SKalle Valo u8 fatpipe_exist_for_ac = 0; 2366bdcd8170SKalle Valo s32 min_phy = 0; 2367bdcd8170SKalle Valo s32 nominal_phy = 0; 2368bdcd8170SKalle Valo int ret; 2369bdcd8170SKalle Valo 2370bdcd8170SKalle Valo if (!((params->user_pri < 8) && 2371bdcd8170SKalle Valo (params->user_pri <= 0x7) && 2372bdcd8170SKalle Valo (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && 2373bdcd8170SKalle Valo (params->traffic_direc == UPLINK_TRAFFIC || 2374bdcd8170SKalle Valo params->traffic_direc == DNLINK_TRAFFIC || 2375bdcd8170SKalle Valo params->traffic_direc == BIDIR_TRAFFIC) && 2376bdcd8170SKalle Valo (params->traffic_type == TRAFFIC_TYPE_APERIODIC || 2377bdcd8170SKalle Valo params->traffic_type == TRAFFIC_TYPE_PERIODIC) && 2378bdcd8170SKalle Valo (params->voice_psc_cap == DISABLE_FOR_THIS_AC || 2379bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_THIS_AC || 2380bdcd8170SKalle Valo params->voice_psc_cap == ENABLE_FOR_ALL_AC) && 2381bdcd8170SKalle Valo (params->tsid == WMI_IMPLICIT_PSTREAM || 2382bdcd8170SKalle Valo params->tsid <= WMI_MAX_THINSTREAM))) { 2383bdcd8170SKalle Valo return -EINVAL; 2384bdcd8170SKalle Valo } 2385bdcd8170SKalle Valo 2386bdcd8170SKalle Valo /* 2387bdcd8170SKalle Valo * Check nominal PHY rate is >= minimalPHY, 2388bdcd8170SKalle Valo * so that DUT can allow TSRS IE 2389bdcd8170SKalle Valo */ 2390bdcd8170SKalle Valo 2391bdcd8170SKalle Valo /* Get the physical rate (units of bps) */ 2392bdcd8170SKalle Valo min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); 2393bdcd8170SKalle Valo 2394bdcd8170SKalle Valo /* Check minimal phy < nominal phy rate */ 2395bdcd8170SKalle Valo if (params->nominal_phy >= min_phy) { 2396bdcd8170SKalle Valo /* unit of 500 kbps */ 2397bdcd8170SKalle Valo nominal_phy = (params->nominal_phy * 1000) / 500; 2398bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2399bdcd8170SKalle Valo "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", 2400bdcd8170SKalle Valo min_phy, nominal_phy); 2401bdcd8170SKalle Valo 2402bdcd8170SKalle Valo params->nominal_phy = nominal_phy; 2403bdcd8170SKalle Valo } else { 2404bdcd8170SKalle Valo params->nominal_phy = 0; 2405bdcd8170SKalle Valo } 2406bdcd8170SKalle Valo 2407bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2408bdcd8170SKalle Valo if (!skb) 2409bdcd8170SKalle Valo return -ENOMEM; 2410bdcd8170SKalle Valo 2411bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2412bdcd8170SKalle Valo "sending create_pstream_cmd: ac=%d tsid:%d\n", 2413bdcd8170SKalle Valo params->traffic_class, params->tsid); 2414bdcd8170SKalle Valo 2415bdcd8170SKalle Valo cmd = (struct wmi_create_pstream_cmd *) skb->data; 2416bdcd8170SKalle Valo memcpy(cmd, params, sizeof(*cmd)); 2417bdcd8170SKalle Valo 2418bdcd8170SKalle Valo /* This is an implicitly created Fat pipe */ 2419bdcd8170SKalle Valo if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { 2420bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2421bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2422bdcd8170SKalle Valo (1 << params->traffic_class)); 2423bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2424bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2425bdcd8170SKalle Valo } else { 2426bdcd8170SKalle Valo /* explicitly created thin stream within a fat pipe */ 2427bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2428bdcd8170SKalle Valo fatpipe_exist_for_ac = (wmi->fat_pipe_exist & 2429bdcd8170SKalle Valo (1 << params->traffic_class)); 2430bdcd8170SKalle Valo wmi->stream_exist_for_ac[params->traffic_class] |= 2431bdcd8170SKalle Valo (1 << params->tsid); 2432bdcd8170SKalle Valo /* 2433bdcd8170SKalle Valo * If a thinstream becomes active, the fat pipe automatically 2434bdcd8170SKalle Valo * becomes active 2435bdcd8170SKalle Valo */ 2436bdcd8170SKalle Valo wmi->fat_pipe_exist |= (1 << params->traffic_class); 2437bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2438bdcd8170SKalle Valo } 2439bdcd8170SKalle Valo 2440bdcd8170SKalle Valo /* 2441bdcd8170SKalle Valo * Indicate activty change to driver layer only if this is the 2442bdcd8170SKalle Valo * first TSID to get created in this AC explicitly or an implicit 2443bdcd8170SKalle Valo * fat pipe is getting created. 2444bdcd8170SKalle Valo */ 2445bdcd8170SKalle Valo if (!fatpipe_exist_for_ac) 2446bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2447bdcd8170SKalle Valo params->traffic_class, true); 2448bdcd8170SKalle Valo 2449240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID, 2450bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2451bdcd8170SKalle Valo return ret; 2452bdcd8170SKalle Valo } 2453bdcd8170SKalle Valo 2454240d2799SVasanthakumar Thiagarajan int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class, 2455240d2799SVasanthakumar Thiagarajan u8 tsid) 2456bdcd8170SKalle Valo { 2457bdcd8170SKalle Valo struct sk_buff *skb; 2458bdcd8170SKalle Valo struct wmi_delete_pstream_cmd *cmd; 2459bdcd8170SKalle Valo u16 active_tsids = 0; 2460bdcd8170SKalle Valo int ret; 2461bdcd8170SKalle Valo 2462bdcd8170SKalle Valo if (traffic_class > 3) { 2463bdcd8170SKalle Valo ath6kl_err("invalid traffic class: %d\n", traffic_class); 2464bdcd8170SKalle Valo return -EINVAL; 2465bdcd8170SKalle Valo } 2466bdcd8170SKalle Valo 2467bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2468bdcd8170SKalle Valo if (!skb) 2469bdcd8170SKalle Valo return -ENOMEM; 2470bdcd8170SKalle Valo 2471bdcd8170SKalle Valo cmd = (struct wmi_delete_pstream_cmd *) skb->data; 2472bdcd8170SKalle Valo cmd->traffic_class = traffic_class; 2473bdcd8170SKalle Valo cmd->tsid = tsid; 2474bdcd8170SKalle Valo 2475bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2476bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2477bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2478bdcd8170SKalle Valo 2479bdcd8170SKalle Valo if (!(active_tsids & (1 << tsid))) { 2480bdcd8170SKalle Valo dev_kfree_skb(skb); 2481bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2482bdcd8170SKalle Valo "TSID %d doesn't exist for traffic class: %d\n", 2483bdcd8170SKalle Valo tsid, traffic_class); 2484bdcd8170SKalle Valo return -ENODATA; 2485bdcd8170SKalle Valo } 2486bdcd8170SKalle Valo 2487bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 2488bdcd8170SKalle Valo "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", 2489bdcd8170SKalle Valo traffic_class, tsid); 2490bdcd8170SKalle Valo 2491240d2799SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID, 2492bdcd8170SKalle Valo SYNC_BEFORE_WMIFLAG); 2493bdcd8170SKalle Valo 2494bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 2495bdcd8170SKalle Valo wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); 2496bdcd8170SKalle Valo active_tsids = wmi->stream_exist_for_ac[traffic_class]; 2497bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 2498bdcd8170SKalle Valo 2499bdcd8170SKalle Valo /* 2500bdcd8170SKalle Valo * Indicate stream inactivity to driver layer only if all tsids 2501bdcd8170SKalle Valo * within this AC are deleted. 2502bdcd8170SKalle Valo */ 2503bdcd8170SKalle Valo if (!active_tsids) { 2504bdcd8170SKalle Valo ath6kl_indicate_tx_activity(wmi->parent_dev, 2505bdcd8170SKalle Valo traffic_class, false); 2506bdcd8170SKalle Valo wmi->fat_pipe_exist &= ~(1 << traffic_class); 2507bdcd8170SKalle Valo } 2508bdcd8170SKalle Valo 2509bdcd8170SKalle Valo return ret; 2510bdcd8170SKalle Valo } 2511bdcd8170SKalle Valo 2512ca1d16a0SRaja Mani int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx, 2513ca1d16a0SRaja Mani __be32 ips0, __be32 ips1) 2514bdcd8170SKalle Valo { 2515bdcd8170SKalle Valo struct sk_buff *skb; 2516bdcd8170SKalle Valo struct wmi_set_ip_cmd *cmd; 2517bdcd8170SKalle Valo int ret; 2518bdcd8170SKalle Valo 2519bdcd8170SKalle Valo /* Multicast address are not valid */ 2520ca1d16a0SRaja Mani if (ipv4_is_multicast(ips0) || 2521ca1d16a0SRaja Mani ipv4_is_multicast(ips1)) 2522bdcd8170SKalle Valo return -EINVAL; 2523bdcd8170SKalle Valo 2524bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); 2525bdcd8170SKalle Valo if (!skb) 2526bdcd8170SKalle Valo return -ENOMEM; 2527bdcd8170SKalle Valo 2528bdcd8170SKalle Valo cmd = (struct wmi_set_ip_cmd *) skb->data; 2529ca1d16a0SRaja Mani cmd->ips[0] = ips0; 2530ca1d16a0SRaja Mani cmd->ips[1] = ips1; 2531bdcd8170SKalle Valo 2532ca1d16a0SRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IP_CMDID, 2533334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2534bdcd8170SKalle Valo return ret; 2535bdcd8170SKalle Valo } 2536bdcd8170SKalle Valo 253745cf110bSRaja Mani static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi) 253845cf110bSRaja Mani { 253945cf110bSRaja Mani u16 active_tsids; 254045cf110bSRaja Mani u8 stream_exist; 254145cf110bSRaja Mani int i; 254245cf110bSRaja Mani 254345cf110bSRaja Mani /* 254445cf110bSRaja Mani * Relinquish credits from all implicitly created pstreams 254545cf110bSRaja Mani * since when we go to sleep. If user created explicit 254645cf110bSRaja Mani * thinstreams exists with in a fatpipe leave them intact 254745cf110bSRaja Mani * for the user to delete. 254845cf110bSRaja Mani */ 254945cf110bSRaja Mani spin_lock_bh(&wmi->lock); 255045cf110bSRaja Mani stream_exist = wmi->fat_pipe_exist; 255145cf110bSRaja Mani spin_unlock_bh(&wmi->lock); 255245cf110bSRaja Mani 255345cf110bSRaja Mani for (i = 0; i < WMM_NUM_AC; i++) { 255445cf110bSRaja Mani if (stream_exist & (1 << i)) { 255545cf110bSRaja Mani 255645cf110bSRaja Mani /* 255745cf110bSRaja Mani * FIXME: Is this lock & unlock inside 255845cf110bSRaja Mani * for loop correct? may need rework. 255945cf110bSRaja Mani */ 256045cf110bSRaja Mani spin_lock_bh(&wmi->lock); 256145cf110bSRaja Mani active_tsids = wmi->stream_exist_for_ac[i]; 256245cf110bSRaja Mani spin_unlock_bh(&wmi->lock); 256345cf110bSRaja Mani 256445cf110bSRaja Mani /* 256545cf110bSRaja Mani * If there are no user created thin streams 256645cf110bSRaja Mani * delete the fatpipe 256745cf110bSRaja Mani */ 256845cf110bSRaja Mani if (!active_tsids) { 256945cf110bSRaja Mani stream_exist &= ~(1 << i); 257045cf110bSRaja Mani /* 257145cf110bSRaja Mani * Indicate inactivity to driver layer for 257245cf110bSRaja Mani * this fatpipe (pstream) 257345cf110bSRaja Mani */ 257445cf110bSRaja Mani ath6kl_indicate_tx_activity(wmi->parent_dev, 257545cf110bSRaja Mani i, false); 257645cf110bSRaja Mani } 257745cf110bSRaja Mani } 257845cf110bSRaja Mani } 257945cf110bSRaja Mani 258045cf110bSRaja Mani /* FIXME: Can we do this assignment without locking ? */ 258145cf110bSRaja Mani spin_lock_bh(&wmi->lock); 258245cf110bSRaja Mani wmi->fat_pipe_exist = stream_exist; 258345cf110bSRaja Mani spin_unlock_bh(&wmi->lock); 258445cf110bSRaja Mani } 258545cf110bSRaja Mani 258645cf110bSRaja Mani int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx, 258745cf110bSRaja Mani enum ath6kl_host_mode host_mode) 258845cf110bSRaja Mani { 258945cf110bSRaja Mani struct sk_buff *skb; 259045cf110bSRaja Mani struct wmi_set_host_sleep_mode_cmd *cmd; 259145cf110bSRaja Mani int ret; 259245cf110bSRaja Mani 259345cf110bSRaja Mani if ((host_mode != ATH6KL_HOST_MODE_ASLEEP) && 259445cf110bSRaja Mani (host_mode != ATH6KL_HOST_MODE_AWAKE)) { 259545cf110bSRaja Mani ath6kl_err("invalid host sleep mode: %d\n", host_mode); 259645cf110bSRaja Mani return -EINVAL; 259745cf110bSRaja Mani } 259845cf110bSRaja Mani 259945cf110bSRaja Mani skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 260045cf110bSRaja Mani if (!skb) 260145cf110bSRaja Mani return -ENOMEM; 260245cf110bSRaja Mani 260345cf110bSRaja Mani cmd = (struct wmi_set_host_sleep_mode_cmd *) skb->data; 260445cf110bSRaja Mani 260545cf110bSRaja Mani if (host_mode == ATH6KL_HOST_MODE_ASLEEP) { 260645cf110bSRaja Mani ath6kl_wmi_relinquish_implicit_pstream_credits(wmi); 260745cf110bSRaja Mani cmd->asleep = cpu_to_le32(1); 260845cf110bSRaja Mani } else 260945cf110bSRaja Mani cmd->awake = cpu_to_le32(1); 261045cf110bSRaja Mani 261145cf110bSRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, 261245cf110bSRaja Mani WMI_SET_HOST_SLEEP_MODE_CMDID, 261345cf110bSRaja Mani NO_SYNC_WMIFLAG); 261445cf110bSRaja Mani return ret; 261545cf110bSRaja Mani } 261645cf110bSRaja Mani 2617081c7a84SRaja Mani /* This command has zero length payload */ 2618081c7a84SRaja Mani static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi *wmi, 2619081c7a84SRaja Mani struct ath6kl_vif *vif) 2620081c7a84SRaja Mani { 2621081c7a84SRaja Mani struct ath6kl *ar = wmi->parent_dev; 2622081c7a84SRaja Mani 2623081c7a84SRaja Mani set_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags); 2624081c7a84SRaja Mani wake_up(&ar->event_wq); 2625081c7a84SRaja Mani 2626081c7a84SRaja Mani return 0; 2627081c7a84SRaja Mani } 2628081c7a84SRaja Mani 262945cf110bSRaja Mani int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, 263045cf110bSRaja Mani enum ath6kl_wow_mode wow_mode, 263145cf110bSRaja Mani u32 filter, u16 host_req_delay) 263245cf110bSRaja Mani { 263345cf110bSRaja Mani struct sk_buff *skb; 263445cf110bSRaja Mani struct wmi_set_wow_mode_cmd *cmd; 263545cf110bSRaja Mani int ret; 263645cf110bSRaja Mani 263745cf110bSRaja Mani if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) && 263845cf110bSRaja Mani wow_mode != ATH6KL_WOW_MODE_DISABLE) { 263945cf110bSRaja Mani ath6kl_err("invalid wow mode: %d\n", wow_mode); 264045cf110bSRaja Mani return -EINVAL; 264145cf110bSRaja Mani } 264245cf110bSRaja Mani 264345cf110bSRaja Mani skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 264445cf110bSRaja Mani if (!skb) 264545cf110bSRaja Mani return -ENOMEM; 264645cf110bSRaja Mani 264745cf110bSRaja Mani cmd = (struct wmi_set_wow_mode_cmd *) skb->data; 264845cf110bSRaja Mani cmd->enable_wow = cpu_to_le32(wow_mode); 264945cf110bSRaja Mani cmd->filter = cpu_to_le32(filter); 265045cf110bSRaja Mani cmd->host_req_delay = cpu_to_le16(host_req_delay); 265145cf110bSRaja Mani 265245cf110bSRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WOW_MODE_CMDID, 265345cf110bSRaja Mani NO_SYNC_WMIFLAG); 265445cf110bSRaja Mani return ret; 265545cf110bSRaja Mani } 265645cf110bSRaja Mani 26575c9b4fa1SRaja Mani int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, 26585c9b4fa1SRaja Mani u8 list_id, u8 filter_size, 2659d91e8eeeSRaja Mani u8 filter_offset, const u8 *filter, 2660d91e8eeeSRaja Mani const u8 *mask) 26615c9b4fa1SRaja Mani { 26625c9b4fa1SRaja Mani struct sk_buff *skb; 26635c9b4fa1SRaja Mani struct wmi_add_wow_pattern_cmd *cmd; 26645c9b4fa1SRaja Mani u16 size; 26655c9b4fa1SRaja Mani u8 *filter_mask; 26665c9b4fa1SRaja Mani int ret; 26675c9b4fa1SRaja Mani 26685c9b4fa1SRaja Mani /* 26695c9b4fa1SRaja Mani * Allocate additional memory in the buffer to hold 26705c9b4fa1SRaja Mani * filter and mask value, which is twice of filter_size. 26715c9b4fa1SRaja Mani */ 26725c9b4fa1SRaja Mani size = sizeof(*cmd) + (2 * filter_size); 26735c9b4fa1SRaja Mani 26745c9b4fa1SRaja Mani skb = ath6kl_wmi_get_new_buf(size); 26755c9b4fa1SRaja Mani if (!skb) 26765c9b4fa1SRaja Mani return -ENOMEM; 26775c9b4fa1SRaja Mani 26785c9b4fa1SRaja Mani cmd = (struct wmi_add_wow_pattern_cmd *) skb->data; 26795c9b4fa1SRaja Mani cmd->filter_list_id = list_id; 26805c9b4fa1SRaja Mani cmd->filter_size = filter_size; 26815c9b4fa1SRaja Mani cmd->filter_offset = filter_offset; 26825c9b4fa1SRaja Mani 26835c9b4fa1SRaja Mani memcpy(cmd->filter, filter, filter_size); 26845c9b4fa1SRaja Mani 26855c9b4fa1SRaja Mani filter_mask = (u8 *) (cmd->filter + filter_size); 26865c9b4fa1SRaja Mani memcpy(filter_mask, mask, filter_size); 26875c9b4fa1SRaja Mani 26885c9b4fa1SRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_WOW_PATTERN_CMDID, 26895c9b4fa1SRaja Mani NO_SYNC_WMIFLAG); 26905c9b4fa1SRaja Mani 26915c9b4fa1SRaja Mani return ret; 26925c9b4fa1SRaja Mani } 26935c9b4fa1SRaja Mani 26945c9b4fa1SRaja Mani int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, 26955c9b4fa1SRaja Mani u16 list_id, u16 filter_id) 26965c9b4fa1SRaja Mani { 26975c9b4fa1SRaja Mani struct sk_buff *skb; 26985c9b4fa1SRaja Mani struct wmi_del_wow_pattern_cmd *cmd; 26995c9b4fa1SRaja Mani int ret; 27005c9b4fa1SRaja Mani 27015c9b4fa1SRaja Mani skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 27025c9b4fa1SRaja Mani if (!skb) 27035c9b4fa1SRaja Mani return -ENOMEM; 27045c9b4fa1SRaja Mani 27055c9b4fa1SRaja Mani cmd = (struct wmi_del_wow_pattern_cmd *) skb->data; 27065c9b4fa1SRaja Mani cmd->filter_list_id = cpu_to_le16(list_id); 27075c9b4fa1SRaja Mani cmd->filter_id = cpu_to_le16(filter_id); 27085c9b4fa1SRaja Mani 27095c9b4fa1SRaja Mani ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DEL_WOW_PATTERN_CMDID, 27105c9b4fa1SRaja Mani NO_SYNC_WMIFLAG); 27115c9b4fa1SRaja Mani return ret; 27125c9b4fa1SRaja Mani } 27135c9b4fa1SRaja Mani 2714bdcd8170SKalle Valo static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, 2715bdcd8170SKalle Valo enum wmix_command_id cmd_id, 2716bdcd8170SKalle Valo enum wmi_sync_flag sync_flag) 2717bdcd8170SKalle Valo { 2718bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd_hdr; 2719bdcd8170SKalle Valo int ret; 2720bdcd8170SKalle Valo 2721bdcd8170SKalle Valo skb_push(skb, sizeof(struct wmix_cmd_hdr)); 2722bdcd8170SKalle Valo 2723bdcd8170SKalle Valo cmd_hdr = (struct wmix_cmd_hdr *) skb->data; 2724bdcd8170SKalle Valo cmd_hdr->cmd_id = cpu_to_le32(cmd_id); 2725bdcd8170SKalle Valo 2726334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag); 2727bdcd8170SKalle Valo 2728bdcd8170SKalle Valo return ret; 2729bdcd8170SKalle Valo } 2730bdcd8170SKalle Valo 2731bdcd8170SKalle Valo int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) 2732bdcd8170SKalle Valo { 2733bdcd8170SKalle Valo struct sk_buff *skb; 2734bdcd8170SKalle Valo struct wmix_hb_challenge_resp_cmd *cmd; 2735bdcd8170SKalle Valo int ret; 2736bdcd8170SKalle Valo 2737bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2738bdcd8170SKalle Valo if (!skb) 2739bdcd8170SKalle Valo return -ENOMEM; 2740bdcd8170SKalle Valo 2741bdcd8170SKalle Valo cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; 2742bdcd8170SKalle Valo cmd->cookie = cpu_to_le32(cookie); 2743bdcd8170SKalle Valo cmd->source = cpu_to_le32(source); 2744bdcd8170SKalle Valo 2745bdcd8170SKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, 2746bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2747bdcd8170SKalle Valo return ret; 2748bdcd8170SKalle Valo } 2749bdcd8170SKalle Valo 2750939f1cceSKalle Valo int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config) 2751939f1cceSKalle Valo { 2752939f1cceSKalle Valo struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd; 2753939f1cceSKalle Valo struct sk_buff *skb; 2754939f1cceSKalle Valo int ret; 2755939f1cceSKalle Valo 2756939f1cceSKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2757939f1cceSKalle Valo if (!skb) 2758939f1cceSKalle Valo return -ENOMEM; 2759939f1cceSKalle Valo 2760939f1cceSKalle Valo cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data; 2761939f1cceSKalle Valo cmd->valid = cpu_to_le32(valid); 2762939f1cceSKalle Valo cmd->config = cpu_to_le32(config); 2763939f1cceSKalle Valo 2764939f1cceSKalle Valo ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID, 2765939f1cceSKalle Valo NO_SYNC_WMIFLAG); 2766939f1cceSKalle Valo return ret; 2767939f1cceSKalle Valo } 2768939f1cceSKalle Valo 2769334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx) 2770bdcd8170SKalle Valo { 2771334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID); 2772bdcd8170SKalle Valo } 2773bdcd8170SKalle Valo 2774990bd915SVasanthakumar Thiagarajan int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM) 2775bdcd8170SKalle Valo { 2776bdcd8170SKalle Valo struct sk_buff *skb; 2777bdcd8170SKalle Valo struct wmi_set_tx_pwr_cmd *cmd; 2778bdcd8170SKalle Valo int ret; 2779bdcd8170SKalle Valo 2780bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); 2781bdcd8170SKalle Valo if (!skb) 2782bdcd8170SKalle Valo return -ENOMEM; 2783bdcd8170SKalle Valo 2784bdcd8170SKalle Valo cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; 2785bdcd8170SKalle Valo cmd->dbM = dbM; 2786bdcd8170SKalle Valo 2787990bd915SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID, 2788bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2789bdcd8170SKalle Valo 2790bdcd8170SKalle Valo return ret; 2791bdcd8170SKalle Valo } 2792bdcd8170SKalle Valo 2793990bd915SVasanthakumar Thiagarajan int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx) 2794bdcd8170SKalle Valo { 2795990bd915SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID); 2796bdcd8170SKalle Valo } 2797bdcd8170SKalle Valo 27984b28a80dSJouni Malinen int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi) 27994b28a80dSJouni Malinen { 2800334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID); 28014b28a80dSJouni Malinen } 28024b28a80dSJouni Malinen 28030ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status, 28040ce59445SVasanthakumar Thiagarajan u8 preamble_policy) 2805bdcd8170SKalle Valo { 2806bdcd8170SKalle Valo struct sk_buff *skb; 2807bdcd8170SKalle Valo struct wmi_set_lpreamble_cmd *cmd; 2808bdcd8170SKalle Valo int ret; 2809bdcd8170SKalle Valo 2810bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); 2811bdcd8170SKalle Valo if (!skb) 2812bdcd8170SKalle Valo return -ENOMEM; 2813bdcd8170SKalle Valo 2814bdcd8170SKalle Valo cmd = (struct wmi_set_lpreamble_cmd *) skb->data; 2815bdcd8170SKalle Valo cmd->status = status; 2816bdcd8170SKalle Valo cmd->preamble_policy = preamble_policy; 2817bdcd8170SKalle Valo 28180ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID, 2819bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2820bdcd8170SKalle Valo return ret; 2821bdcd8170SKalle Valo } 2822bdcd8170SKalle Valo 2823bdcd8170SKalle Valo int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) 2824bdcd8170SKalle Valo { 2825bdcd8170SKalle Valo struct sk_buff *skb; 2826bdcd8170SKalle Valo struct wmi_set_rts_cmd *cmd; 2827bdcd8170SKalle Valo int ret; 2828bdcd8170SKalle Valo 2829bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); 2830bdcd8170SKalle Valo if (!skb) 2831bdcd8170SKalle Valo return -ENOMEM; 2832bdcd8170SKalle Valo 2833bdcd8170SKalle Valo cmd = (struct wmi_set_rts_cmd *) skb->data; 2834bdcd8170SKalle Valo cmd->threshold = cpu_to_le16(threshold); 2835bdcd8170SKalle Valo 2836334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID, 2837334234b5SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2838bdcd8170SKalle Valo return ret; 2839bdcd8170SKalle Valo } 2840bdcd8170SKalle Valo 28410ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg) 2842bdcd8170SKalle Valo { 2843bdcd8170SKalle Valo struct sk_buff *skb; 2844bdcd8170SKalle Valo struct wmi_set_wmm_txop_cmd *cmd; 2845bdcd8170SKalle Valo int ret; 2846bdcd8170SKalle Valo 2847bdcd8170SKalle Valo if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) 2848bdcd8170SKalle Valo return -EINVAL; 2849bdcd8170SKalle Valo 2850bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); 2851bdcd8170SKalle Valo if (!skb) 2852bdcd8170SKalle Valo return -ENOMEM; 2853bdcd8170SKalle Valo 2854bdcd8170SKalle Valo cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; 2855bdcd8170SKalle Valo cmd->txop_enable = cfg; 2856bdcd8170SKalle Valo 28570ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID, 2858bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2859bdcd8170SKalle Valo return ret; 2860bdcd8170SKalle Valo } 2861bdcd8170SKalle Valo 28620ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx, 28630ce59445SVasanthakumar Thiagarajan u8 keep_alive_intvl) 2864bdcd8170SKalle Valo { 2865bdcd8170SKalle Valo struct sk_buff *skb; 2866bdcd8170SKalle Valo struct wmi_set_keepalive_cmd *cmd; 2867bdcd8170SKalle Valo int ret; 2868bdcd8170SKalle Valo 2869bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2870bdcd8170SKalle Valo if (!skb) 2871bdcd8170SKalle Valo return -ENOMEM; 2872bdcd8170SKalle Valo 2873bdcd8170SKalle Valo cmd = (struct wmi_set_keepalive_cmd *) skb->data; 2874bdcd8170SKalle Valo cmd->keep_alive_intvl = keep_alive_intvl; 2875bdcd8170SKalle Valo 28760ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID, 2877bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 2878334234b5SVasanthakumar Thiagarajan 2879ff0b0075SJouni Malinen if (ret == 0) 2880ff0b0075SJouni Malinen ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl); 2881334234b5SVasanthakumar Thiagarajan 2882bdcd8170SKalle Valo return ret; 2883bdcd8170SKalle Valo } 2884bdcd8170SKalle Valo 2885df90b369SVasanthakumar Thiagarajan int ath6kl_wmi_set_htcap_cmd(struct wmi *wmi, u8 if_idx, 2886df90b369SVasanthakumar Thiagarajan enum ieee80211_band band, 2887df90b369SVasanthakumar Thiagarajan struct ath6kl_htcap *htcap) 2888df90b369SVasanthakumar Thiagarajan { 2889df90b369SVasanthakumar Thiagarajan struct sk_buff *skb; 2890df90b369SVasanthakumar Thiagarajan struct wmi_set_htcap_cmd *cmd; 2891df90b369SVasanthakumar Thiagarajan 2892df90b369SVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2893df90b369SVasanthakumar Thiagarajan if (!skb) 2894df90b369SVasanthakumar Thiagarajan return -ENOMEM; 2895df90b369SVasanthakumar Thiagarajan 2896df90b369SVasanthakumar Thiagarajan cmd = (struct wmi_set_htcap_cmd *) skb->data; 2897df90b369SVasanthakumar Thiagarajan 2898df90b369SVasanthakumar Thiagarajan /* 2899df90b369SVasanthakumar Thiagarajan * NOTE: Band in firmware matches enum ieee80211_band, it is unlikely 2900df90b369SVasanthakumar Thiagarajan * this will be changed in firmware. If at all there is any change in 2901df90b369SVasanthakumar Thiagarajan * band value, the host needs to be fixed. 2902df90b369SVasanthakumar Thiagarajan */ 2903df90b369SVasanthakumar Thiagarajan cmd->band = band; 2904df90b369SVasanthakumar Thiagarajan cmd->ht_enable = !!htcap->ht_enable; 2905df90b369SVasanthakumar Thiagarajan cmd->ht20_sgi = !!(htcap->cap_info & IEEE80211_HT_CAP_SGI_20); 2906df90b369SVasanthakumar Thiagarajan cmd->ht40_supported = 2907df90b369SVasanthakumar Thiagarajan !!(htcap->cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40); 2908df90b369SVasanthakumar Thiagarajan cmd->ht40_sgi = !!(htcap->cap_info & IEEE80211_HT_CAP_SGI_40); 2909df90b369SVasanthakumar Thiagarajan cmd->intolerant_40mhz = 2910df90b369SVasanthakumar Thiagarajan !!(htcap->cap_info & IEEE80211_HT_CAP_40MHZ_INTOLERANT); 2911df90b369SVasanthakumar Thiagarajan cmd->max_ampdu_len_exp = htcap->ampdu_factor; 2912df90b369SVasanthakumar Thiagarajan 2913df90b369SVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, 2914df90b369SVasanthakumar Thiagarajan "Set htcap: band:%d ht_enable:%d 40mhz:%d sgi_20mhz:%d sgi_40mhz:%d 40mhz_intolerant:%d ampdu_len_exp:%d\n", 2915df90b369SVasanthakumar Thiagarajan cmd->band, cmd->ht_enable, cmd->ht40_supported, 2916df90b369SVasanthakumar Thiagarajan cmd->ht20_sgi, cmd->ht40_sgi, cmd->intolerant_40mhz, 2917df90b369SVasanthakumar Thiagarajan cmd->max_ampdu_len_exp); 2918df90b369SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_HT_CAP_CMDID, 2919df90b369SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2920df90b369SVasanthakumar Thiagarajan } 2921df90b369SVasanthakumar Thiagarajan 2922003353b0SKalle Valo int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) 2923003353b0SKalle Valo { 2924003353b0SKalle Valo struct sk_buff *skb; 2925003353b0SKalle Valo int ret; 2926003353b0SKalle Valo 2927003353b0SKalle Valo skb = ath6kl_wmi_get_new_buf(len); 2928003353b0SKalle Valo if (!skb) 2929003353b0SKalle Valo return -ENOMEM; 2930003353b0SKalle Valo 2931003353b0SKalle Valo memcpy(skb->data, buf, len); 2932003353b0SKalle Valo 2933334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); 2934003353b0SKalle Valo 2935003353b0SKalle Valo return ret; 2936003353b0SKalle Valo } 2937003353b0SKalle Valo 29383f3c4ee7SVasanthakumar Thiagarajan int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on) 29393f3c4ee7SVasanthakumar Thiagarajan { 29403f3c4ee7SVasanthakumar Thiagarajan struct sk_buff *skb; 29413f3c4ee7SVasanthakumar Thiagarajan struct wmi_mcast_filter_cmd *cmd; 29423f3c4ee7SVasanthakumar Thiagarajan int ret; 29433f3c4ee7SVasanthakumar Thiagarajan 29443f3c4ee7SVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 29453f3c4ee7SVasanthakumar Thiagarajan if (!skb) 29463f3c4ee7SVasanthakumar Thiagarajan return -ENOMEM; 29473f3c4ee7SVasanthakumar Thiagarajan 29483f3c4ee7SVasanthakumar Thiagarajan cmd = (struct wmi_mcast_filter_cmd *) skb->data; 29493f3c4ee7SVasanthakumar Thiagarajan cmd->mcast_all_enable = mc_all_on; 29503f3c4ee7SVasanthakumar Thiagarajan 29513f3c4ee7SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_MCAST_FILTER_CMDID, 29523f3c4ee7SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 29533f3c4ee7SVasanthakumar Thiagarajan return ret; 29543f3c4ee7SVasanthakumar Thiagarajan } 2955003353b0SKalle Valo 2956f914edd3SVasanthakumar Thiagarajan int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, 2957f914edd3SVasanthakumar Thiagarajan u8 *filter, bool add_filter) 2958f914edd3SVasanthakumar Thiagarajan { 2959f914edd3SVasanthakumar Thiagarajan struct sk_buff *skb; 2960f914edd3SVasanthakumar Thiagarajan struct wmi_mcast_filter_add_del_cmd *cmd; 2961f914edd3SVasanthakumar Thiagarajan int ret; 2962f914edd3SVasanthakumar Thiagarajan 2963f914edd3SVasanthakumar Thiagarajan if ((filter[0] != 0x33 || filter[1] != 0x33) && 2964f914edd3SVasanthakumar Thiagarajan (filter[0] != 0x01 || filter[1] != 0x00 || 2965f914edd3SVasanthakumar Thiagarajan filter[2] != 0x5e || filter[3] > 0x7f)) { 2966f914edd3SVasanthakumar Thiagarajan ath6kl_warn("invalid multicast filter address\n"); 2967f914edd3SVasanthakumar Thiagarajan return -EINVAL; 2968f914edd3SVasanthakumar Thiagarajan } 2969f914edd3SVasanthakumar Thiagarajan 2970f914edd3SVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 2971f914edd3SVasanthakumar Thiagarajan if (!skb) 2972f914edd3SVasanthakumar Thiagarajan return -ENOMEM; 2973f914edd3SVasanthakumar Thiagarajan 2974f914edd3SVasanthakumar Thiagarajan cmd = (struct wmi_mcast_filter_add_del_cmd *) skb->data; 2975f914edd3SVasanthakumar Thiagarajan memcpy(cmd->mcast_mac, filter, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE); 2976f914edd3SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, 2977f914edd3SVasanthakumar Thiagarajan add_filter ? WMI_SET_MCAST_FILTER_CMDID : 2978f914edd3SVasanthakumar Thiagarajan WMI_DEL_MCAST_FILTER_CMDID, 2979f914edd3SVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 2980f914edd3SVasanthakumar Thiagarajan 2981f914edd3SVasanthakumar Thiagarajan return ret; 2982f914edd3SVasanthakumar Thiagarajan } 2983f914edd3SVasanthakumar Thiagarajan 2984bdcd8170SKalle Valo s32 ath6kl_wmi_get_rate(s8 rate_index) 2985bdcd8170SKalle Valo { 2986bdcd8170SKalle Valo if (rate_index == RATE_AUTO) 2987bdcd8170SKalle Valo return 0; 2988bdcd8170SKalle Valo 2989bdcd8170SKalle Valo return wmi_rate_tbl[(u32) rate_index][0]; 2990bdcd8170SKalle Valo } 2991bdcd8170SKalle Valo 2992bdcd8170SKalle Valo static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, 2993bdcd8170SKalle Valo u32 len) 2994bdcd8170SKalle Valo { 2995bdcd8170SKalle Valo struct wmi_pmkid_list_reply *reply; 2996bdcd8170SKalle Valo u32 expected_len; 2997bdcd8170SKalle Valo 2998bdcd8170SKalle Valo if (len < sizeof(struct wmi_pmkid_list_reply)) 2999bdcd8170SKalle Valo return -EINVAL; 3000bdcd8170SKalle Valo 3001bdcd8170SKalle Valo reply = (struct wmi_pmkid_list_reply *)datap; 3002bdcd8170SKalle Valo expected_len = sizeof(reply->num_pmkid) + 3003bdcd8170SKalle Valo le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; 3004bdcd8170SKalle Valo 3005bdcd8170SKalle Valo if (len < expected_len) 3006bdcd8170SKalle Valo return -EINVAL; 3007bdcd8170SKalle Valo 3008bdcd8170SKalle Valo return 0; 3009bdcd8170SKalle Valo } 3010bdcd8170SKalle Valo 3011240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len, 3012240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 3013bdcd8170SKalle Valo { 3014bdcd8170SKalle Valo struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; 3015bdcd8170SKalle Valo 3016240d2799SVasanthakumar Thiagarajan aggr_recv_addba_req_evt(vif, cmd->tid, 3017bdcd8170SKalle Valo le16_to_cpu(cmd->st_seq_no), cmd->win_sz); 3018bdcd8170SKalle Valo 3019bdcd8170SKalle Valo return 0; 3020bdcd8170SKalle Valo } 3021bdcd8170SKalle Valo 3022240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len, 3023240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 3024bdcd8170SKalle Valo { 3025bdcd8170SKalle Valo struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; 3026bdcd8170SKalle Valo 3027240d2799SVasanthakumar Thiagarajan aggr_recv_delba_req_evt(vif, cmd->tid); 3028bdcd8170SKalle Valo 3029bdcd8170SKalle Valo return 0; 3030bdcd8170SKalle Valo } 3031bdcd8170SKalle Valo 3032bdcd8170SKalle Valo /* AP mode functions */ 30336a7c9badSJouni Malinen 3034334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, 3035334234b5SVasanthakumar Thiagarajan struct wmi_connect_cmd *p) 30366a7c9badSJouni Malinen { 30376a7c9badSJouni Malinen struct sk_buff *skb; 30386a7c9badSJouni Malinen struct wmi_connect_cmd *cm; 30396a7c9badSJouni Malinen int res; 30406a7c9badSJouni Malinen 30416a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 30426a7c9badSJouni Malinen if (!skb) 30436a7c9badSJouni Malinen return -ENOMEM; 30446a7c9badSJouni Malinen 30456a7c9badSJouni Malinen cm = (struct wmi_connect_cmd *) skb->data; 30466a7c9badSJouni Malinen memcpy(cm, p, sizeof(*cm)); 30476a7c9badSJouni Malinen 3048334234b5SVasanthakumar Thiagarajan res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID, 30496a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 30506a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " 30516a7c9badSJouni Malinen "ctrl_flags=0x%x-> res=%d\n", 30526a7c9badSJouni Malinen __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), 30536a7c9badSJouni Malinen le32_to_cpu(p->ctrl_flags), res); 30546a7c9badSJouni Malinen return res; 30556a7c9badSJouni Malinen } 30566a7c9badSJouni Malinen 3057334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac, 3058334234b5SVasanthakumar Thiagarajan u16 reason) 305923875136SJouni Malinen { 306023875136SJouni Malinen struct sk_buff *skb; 306123875136SJouni Malinen struct wmi_ap_set_mlme_cmd *cm; 306223875136SJouni Malinen 306323875136SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); 306423875136SJouni Malinen if (!skb) 306523875136SJouni Malinen return -ENOMEM; 306623875136SJouni Malinen 306723875136SJouni Malinen cm = (struct wmi_ap_set_mlme_cmd *) skb->data; 306823875136SJouni Malinen memcpy(cm->mac, mac, ETH_ALEN); 306923875136SJouni Malinen cm->reason = cpu_to_le16(reason); 307023875136SJouni Malinen cm->cmd = cmd; 307123875136SJouni Malinen 30727397ddebSAarthi Thiruvengadam ath6kl_dbg(ATH6KL_DBG_WMI, "ap_set_mlme: cmd=%d reason=%d\n", cm->cmd, 30737397ddebSAarthi Thiruvengadam cm->reason); 30747397ddebSAarthi Thiruvengadam 3075334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID, 307623875136SJouni Malinen NO_SYNC_WMIFLAG); 307723875136SJouni Malinen } 307823875136SJouni Malinen 307967cd22e4SThomas Pedersen int ath6kl_wmi_ap_hidden_ssid(struct wmi *wmi, u8 if_idx, bool enable) 308067cd22e4SThomas Pedersen { 308167cd22e4SThomas Pedersen struct sk_buff *skb; 308267cd22e4SThomas Pedersen struct wmi_ap_hidden_ssid_cmd *cmd; 308367cd22e4SThomas Pedersen 308467cd22e4SThomas Pedersen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 308567cd22e4SThomas Pedersen if (!skb) 308667cd22e4SThomas Pedersen return -ENOMEM; 308767cd22e4SThomas Pedersen 308867cd22e4SThomas Pedersen cmd = (struct wmi_ap_hidden_ssid_cmd *) skb->data; 308967cd22e4SThomas Pedersen cmd->hidden_ssid = enable ? 1 : 0; 309067cd22e4SThomas Pedersen 309167cd22e4SThomas Pedersen return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_HIDDEN_SSID_CMDID, 309267cd22e4SThomas Pedersen NO_SYNC_WMIFLAG); 309367cd22e4SThomas Pedersen } 309467cd22e4SThomas Pedersen 3095c1762a3fSThirumalai Pachamuthu /* This command will be used to enable/disable AP uAPSD feature */ 3096c1762a3fSThirumalai Pachamuthu int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable) 3097c1762a3fSThirumalai Pachamuthu { 3098c1762a3fSThirumalai Pachamuthu struct wmi_ap_set_apsd_cmd *cmd; 3099c1762a3fSThirumalai Pachamuthu struct sk_buff *skb; 3100c1762a3fSThirumalai Pachamuthu 3101c1762a3fSThirumalai Pachamuthu skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3102c1762a3fSThirumalai Pachamuthu if (!skb) 3103c1762a3fSThirumalai Pachamuthu return -ENOMEM; 3104c1762a3fSThirumalai Pachamuthu 3105c1762a3fSThirumalai Pachamuthu cmd = (struct wmi_ap_set_apsd_cmd *)skb->data; 3106c1762a3fSThirumalai Pachamuthu cmd->enable = enable; 3107c1762a3fSThirumalai Pachamuthu 3108c1762a3fSThirumalai Pachamuthu return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_APSD_CMDID, 3109c1762a3fSThirumalai Pachamuthu NO_SYNC_WMIFLAG); 3110c1762a3fSThirumalai Pachamuthu } 3111c1762a3fSThirumalai Pachamuthu 3112c1762a3fSThirumalai Pachamuthu int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, u8 if_idx, 3113c1762a3fSThirumalai Pachamuthu u16 aid, u16 bitmap, u32 flags) 3114c1762a3fSThirumalai Pachamuthu { 3115c1762a3fSThirumalai Pachamuthu struct wmi_ap_apsd_buffered_traffic_cmd *cmd; 3116c1762a3fSThirumalai Pachamuthu struct sk_buff *skb; 3117c1762a3fSThirumalai Pachamuthu 3118c1762a3fSThirumalai Pachamuthu skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3119c1762a3fSThirumalai Pachamuthu if (!skb) 3120c1762a3fSThirumalai Pachamuthu return -ENOMEM; 3121c1762a3fSThirumalai Pachamuthu 3122c1762a3fSThirumalai Pachamuthu cmd = (struct wmi_ap_apsd_buffered_traffic_cmd *)skb->data; 3123c1762a3fSThirumalai Pachamuthu cmd->aid = cpu_to_le16(aid); 3124c1762a3fSThirumalai Pachamuthu cmd->bitmap = cpu_to_le16(bitmap); 3125c1762a3fSThirumalai Pachamuthu cmd->flags = cpu_to_le32(flags); 3126c1762a3fSThirumalai Pachamuthu 3127c1762a3fSThirumalai Pachamuthu return ath6kl_wmi_cmd_send(wmi, if_idx, skb, 3128c1762a3fSThirumalai Pachamuthu WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID, 3129c1762a3fSThirumalai Pachamuthu NO_SYNC_WMIFLAG); 3130c1762a3fSThirumalai Pachamuthu } 3131c1762a3fSThirumalai Pachamuthu 3132240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len, 3133240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 3134bdcd8170SKalle Valo { 3135bdcd8170SKalle Valo struct wmi_pspoll_event *ev; 3136bdcd8170SKalle Valo 3137bdcd8170SKalle Valo if (len < sizeof(struct wmi_pspoll_event)) 3138bdcd8170SKalle Valo return -EINVAL; 3139bdcd8170SKalle Valo 3140bdcd8170SKalle Valo ev = (struct wmi_pspoll_event *) datap; 3141bdcd8170SKalle Valo 3142240d2799SVasanthakumar Thiagarajan ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid)); 3143bdcd8170SKalle Valo 3144bdcd8170SKalle Valo return 0; 3145bdcd8170SKalle Valo } 3146bdcd8170SKalle Valo 3147240d2799SVasanthakumar Thiagarajan static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len, 3148240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif) 3149bdcd8170SKalle Valo { 3150240d2799SVasanthakumar Thiagarajan ath6kl_dtimexpiry_event(vif); 3151bdcd8170SKalle Valo 3152bdcd8170SKalle Valo return 0; 3153bdcd8170SKalle Valo } 3154bdcd8170SKalle Valo 3155334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid, 3156334234b5SVasanthakumar Thiagarajan bool flag) 3157bdcd8170SKalle Valo { 3158bdcd8170SKalle Valo struct sk_buff *skb; 3159bdcd8170SKalle Valo struct wmi_ap_set_pvb_cmd *cmd; 3160bdcd8170SKalle Valo int ret; 3161bdcd8170SKalle Valo 3162bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); 3163bdcd8170SKalle Valo if (!skb) 3164bdcd8170SKalle Valo return -ENOMEM; 3165bdcd8170SKalle Valo 3166bdcd8170SKalle Valo cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; 3167bdcd8170SKalle Valo cmd->aid = cpu_to_le16(aid); 3168d6e51e6aSJouni Malinen cmd->rsvd = cpu_to_le16(0); 3169bdcd8170SKalle Valo cmd->flag = cpu_to_le32(flag); 3170bdcd8170SKalle Valo 3171334234b5SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID, 3172bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 3173bdcd8170SKalle Valo 3174bdcd8170SKalle Valo return 0; 3175bdcd8170SKalle Valo } 3176bdcd8170SKalle Valo 31770ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx, 31780ce59445SVasanthakumar Thiagarajan u8 rx_meta_ver, 3179bdcd8170SKalle Valo bool rx_dot11_hdr, bool defrag_on_host) 3180bdcd8170SKalle Valo { 3181bdcd8170SKalle Valo struct sk_buff *skb; 3182bdcd8170SKalle Valo struct wmi_rx_frame_format_cmd *cmd; 3183bdcd8170SKalle Valo int ret; 3184bdcd8170SKalle Valo 3185bdcd8170SKalle Valo skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 3186bdcd8170SKalle Valo if (!skb) 3187bdcd8170SKalle Valo return -ENOMEM; 3188bdcd8170SKalle Valo 3189bdcd8170SKalle Valo cmd = (struct wmi_rx_frame_format_cmd *) skb->data; 3190bdcd8170SKalle Valo cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; 3191bdcd8170SKalle Valo cmd->defrag_on_host = defrag_on_host ? 1 : 0; 3192bdcd8170SKalle Valo cmd->meta_ver = rx_meta_ver; 3193bdcd8170SKalle Valo 3194bdcd8170SKalle Valo /* Delete the local aggr state, on host */ 31950ce59445SVasanthakumar Thiagarajan ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID, 3196bdcd8170SKalle Valo NO_SYNC_WMIFLAG); 3197bdcd8170SKalle Valo 3198bdcd8170SKalle Valo return ret; 3199bdcd8170SKalle Valo } 3200bdcd8170SKalle Valo 3201334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, 3202334234b5SVasanthakumar Thiagarajan const u8 *ie, u8 ie_len) 32036a7c9badSJouni Malinen { 32046a7c9badSJouni Malinen struct sk_buff *skb; 32056a7c9badSJouni Malinen struct wmi_set_appie_cmd *p; 32066a7c9badSJouni Malinen 32076a7c9badSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 32086a7c9badSJouni Malinen if (!skb) 32096a7c9badSJouni Malinen return -ENOMEM; 32106a7c9badSJouni Malinen 32116a7c9badSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " 32126a7c9badSJouni Malinen "ie_len=%u\n", mgmt_frm_type, ie_len); 32136a7c9badSJouni Malinen p = (struct wmi_set_appie_cmd *) skb->data; 32146a7c9badSJouni Malinen p->mgmt_frm_type = mgmt_frm_type; 32156a7c9badSJouni Malinen p->ie_len = ie_len; 321610509f90SKalle Valo 321710509f90SKalle Valo if (ie != NULL && ie_len > 0) 32186a7c9badSJouni Malinen memcpy(p->ie_info, ie, ie_len); 321910509f90SKalle Valo 3220334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID, 32216a7c9badSJouni Malinen NO_SYNC_WMIFLAG); 32226a7c9badSJouni Malinen } 32236a7c9badSJouni Malinen 3224*d97c121bSVasanthakumar Thiagarajan int ath6kl_wmi_set_ie_cmd(struct wmi *wmi, u8 if_idx, u8 ie_id, u8 ie_field, 3225*d97c121bSVasanthakumar Thiagarajan const u8 *ie_info, u8 ie_len) 3226*d97c121bSVasanthakumar Thiagarajan { 3227*d97c121bSVasanthakumar Thiagarajan struct sk_buff *skb; 3228*d97c121bSVasanthakumar Thiagarajan struct wmi_set_ie_cmd *p; 3229*d97c121bSVasanthakumar Thiagarajan 3230*d97c121bSVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); 3231*d97c121bSVasanthakumar Thiagarajan if (!skb) 3232*d97c121bSVasanthakumar Thiagarajan return -ENOMEM; 3233*d97c121bSVasanthakumar Thiagarajan 3234*d97c121bSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "set_ie_cmd: ie_id=%u ie_ie_field=%u ie_len=%u\n", 3235*d97c121bSVasanthakumar Thiagarajan ie_id, ie_field, ie_len); 3236*d97c121bSVasanthakumar Thiagarajan p = (struct wmi_set_ie_cmd *) skb->data; 3237*d97c121bSVasanthakumar Thiagarajan p->ie_id = ie_id; 3238*d97c121bSVasanthakumar Thiagarajan p->ie_field = ie_field; 3239*d97c121bSVasanthakumar Thiagarajan p->ie_len = ie_len; 3240*d97c121bSVasanthakumar Thiagarajan if (ie_info && ie_len > 0) 3241*d97c121bSVasanthakumar Thiagarajan memcpy(p->ie_info, ie_info, ie_len); 3242*d97c121bSVasanthakumar Thiagarajan 3243*d97c121bSVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IE_CMDID, 3244*d97c121bSVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 3245*d97c121bSVasanthakumar Thiagarajan } 3246*d97c121bSVasanthakumar Thiagarajan 32476465ddcfSJouni Malinen int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) 32486465ddcfSJouni Malinen { 32496465ddcfSJouni Malinen struct sk_buff *skb; 32506465ddcfSJouni Malinen struct wmi_disable_11b_rates_cmd *cmd; 32516465ddcfSJouni Malinen 32526465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 32536465ddcfSJouni Malinen if (!skb) 32546465ddcfSJouni Malinen return -ENOMEM; 32556465ddcfSJouni Malinen 32566465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", 32576465ddcfSJouni Malinen disable); 32586465ddcfSJouni Malinen cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; 32596465ddcfSJouni Malinen cmd->disable = disable ? 1 : 0; 32606465ddcfSJouni Malinen 3261334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID, 32626465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 32636465ddcfSJouni Malinen } 32646465ddcfSJouni Malinen 3265334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur) 32666465ddcfSJouni Malinen { 32676465ddcfSJouni Malinen struct sk_buff *skb; 32686465ddcfSJouni Malinen struct wmi_remain_on_chnl_cmd *p; 32696465ddcfSJouni Malinen 32706465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 32716465ddcfSJouni Malinen if (!skb) 32726465ddcfSJouni Malinen return -ENOMEM; 32736465ddcfSJouni Malinen 32746465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", 32756465ddcfSJouni Malinen freq, dur); 32766465ddcfSJouni Malinen p = (struct wmi_remain_on_chnl_cmd *) skb->data; 32776465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 32786465ddcfSJouni Malinen p->duration = cpu_to_le32(dur); 3279334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID, 32806465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 32816465ddcfSJouni Malinen } 32826465ddcfSJouni Malinen 32833ca9d1fcSAarthi Thiruvengadam /* ath6kl_wmi_send_action_cmd is to be deprecated. Use 32843ca9d1fcSAarthi Thiruvengadam * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P 32853ca9d1fcSAarthi Thiruvengadam * mgmt operations using station interface. 32863ca9d1fcSAarthi Thiruvengadam */ 3287d0ff7383SNaveen Gangadharan static int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, 3288d0ff7383SNaveen Gangadharan u32 freq, u32 wait, const u8 *data, 3289d0ff7383SNaveen Gangadharan u16 data_len) 32906465ddcfSJouni Malinen { 32916465ddcfSJouni Malinen struct sk_buff *skb; 32926465ddcfSJouni Malinen struct wmi_send_action_cmd *p; 3293a0df5db1SJouni Malinen u8 *buf; 32946465ddcfSJouni Malinen 32956465ddcfSJouni Malinen if (wait) 32966465ddcfSJouni Malinen return -EINVAL; /* Offload for wait not supported */ 32976465ddcfSJouni Malinen 3298a0df5db1SJouni Malinen buf = kmalloc(data_len, GFP_KERNEL); 3299a0df5db1SJouni Malinen if (!buf) 33006465ddcfSJouni Malinen return -ENOMEM; 33016465ddcfSJouni Malinen 3302a0df5db1SJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 3303a0df5db1SJouni Malinen if (!skb) { 3304a0df5db1SJouni Malinen kfree(buf); 3305a0df5db1SJouni Malinen return -ENOMEM; 3306a0df5db1SJouni Malinen } 3307a0df5db1SJouni Malinen 3308a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 33093101edefSAarthi Thiruvengadam memcpy(buf, data, data_len); 3310a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame = buf; 3311a0df5db1SJouni Malinen wmi->last_mgmt_tx_frame_len = data_len; 3312a0df5db1SJouni Malinen 33136465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " 33146465ddcfSJouni Malinen "len=%u\n", id, freq, wait, data_len); 33156465ddcfSJouni Malinen p = (struct wmi_send_action_cmd *) skb->data; 33166465ddcfSJouni Malinen p->id = cpu_to_le32(id); 33176465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 33186465ddcfSJouni Malinen p->wait = cpu_to_le32(wait); 33196465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 33206465ddcfSJouni Malinen memcpy(p->data, data, data_len); 3321334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID, 33226465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 33236465ddcfSJouni Malinen } 33246465ddcfSJouni Malinen 3325d0ff7383SNaveen Gangadharan static int __ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, 3326d0ff7383SNaveen Gangadharan u32 freq, u32 wait, const u8 *data, 3327d0ff7383SNaveen Gangadharan u16 data_len, u32 no_cck) 33283ca9d1fcSAarthi Thiruvengadam { 33293ca9d1fcSAarthi Thiruvengadam struct sk_buff *skb; 33303ca9d1fcSAarthi Thiruvengadam struct wmi_send_mgmt_cmd *p; 33313ca9d1fcSAarthi Thiruvengadam u8 *buf; 33323ca9d1fcSAarthi Thiruvengadam 33333ca9d1fcSAarthi Thiruvengadam if (wait) 33343ca9d1fcSAarthi Thiruvengadam return -EINVAL; /* Offload for wait not supported */ 33353ca9d1fcSAarthi Thiruvengadam 33363ca9d1fcSAarthi Thiruvengadam buf = kmalloc(data_len, GFP_KERNEL); 33373ca9d1fcSAarthi Thiruvengadam if (!buf) 33383ca9d1fcSAarthi Thiruvengadam return -ENOMEM; 33393ca9d1fcSAarthi Thiruvengadam 33403ca9d1fcSAarthi Thiruvengadam skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); 33413ca9d1fcSAarthi Thiruvengadam if (!skb) { 33423ca9d1fcSAarthi Thiruvengadam kfree(buf); 33433ca9d1fcSAarthi Thiruvengadam return -ENOMEM; 33443ca9d1fcSAarthi Thiruvengadam } 33453ca9d1fcSAarthi Thiruvengadam 33463ca9d1fcSAarthi Thiruvengadam kfree(wmi->last_mgmt_tx_frame); 33473ca9d1fcSAarthi Thiruvengadam memcpy(buf, data, data_len); 33483ca9d1fcSAarthi Thiruvengadam wmi->last_mgmt_tx_frame = buf; 33493ca9d1fcSAarthi Thiruvengadam wmi->last_mgmt_tx_frame_len = data_len; 33503ca9d1fcSAarthi Thiruvengadam 33513ca9d1fcSAarthi Thiruvengadam ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " 33523ca9d1fcSAarthi Thiruvengadam "len=%u\n", id, freq, wait, data_len); 33533ca9d1fcSAarthi Thiruvengadam p = (struct wmi_send_mgmt_cmd *) skb->data; 33543ca9d1fcSAarthi Thiruvengadam p->id = cpu_to_le32(id); 33553ca9d1fcSAarthi Thiruvengadam p->freq = cpu_to_le32(freq); 33563ca9d1fcSAarthi Thiruvengadam p->wait = cpu_to_le32(wait); 33573ca9d1fcSAarthi Thiruvengadam p->no_cck = cpu_to_le32(no_cck); 33583ca9d1fcSAarthi Thiruvengadam p->len = cpu_to_le16(data_len); 33593ca9d1fcSAarthi Thiruvengadam memcpy(p->data, data, data_len); 33603ca9d1fcSAarthi Thiruvengadam return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_MGMT_CMDID, 33613ca9d1fcSAarthi Thiruvengadam NO_SYNC_WMIFLAG); 33623ca9d1fcSAarthi Thiruvengadam } 33633ca9d1fcSAarthi Thiruvengadam 3364d0ff7383SNaveen Gangadharan int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, 3365d0ff7383SNaveen Gangadharan u32 wait, const u8 *data, u16 data_len, 3366d0ff7383SNaveen Gangadharan u32 no_cck) 3367d0ff7383SNaveen Gangadharan { 3368d0ff7383SNaveen Gangadharan int status; 3369d0ff7383SNaveen Gangadharan struct ath6kl *ar = wmi->parent_dev; 3370d0ff7383SNaveen Gangadharan 3371d0ff7383SNaveen Gangadharan if (test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX, 3372d0ff7383SNaveen Gangadharan ar->fw_capabilities)) { 3373d0ff7383SNaveen Gangadharan /* 3374d0ff7383SNaveen Gangadharan * If capable of doing P2P mgmt operations using 3375d0ff7383SNaveen Gangadharan * station interface, send additional information like 3376d0ff7383SNaveen Gangadharan * supported rates to advertise and xmit rates for 3377d0ff7383SNaveen Gangadharan * probe requests 3378d0ff7383SNaveen Gangadharan */ 3379d0ff7383SNaveen Gangadharan status = __ath6kl_wmi_send_mgmt_cmd(ar->wmi, if_idx, id, freq, 3380d0ff7383SNaveen Gangadharan wait, data, data_len, 3381d0ff7383SNaveen Gangadharan no_cck); 3382d0ff7383SNaveen Gangadharan } else { 3383d0ff7383SNaveen Gangadharan status = ath6kl_wmi_send_action_cmd(ar->wmi, if_idx, id, freq, 3384d0ff7383SNaveen Gangadharan wait, data, data_len); 3385d0ff7383SNaveen Gangadharan } 3386d0ff7383SNaveen Gangadharan 3387d0ff7383SNaveen Gangadharan return status; 3388d0ff7383SNaveen Gangadharan } 3389d0ff7383SNaveen Gangadharan 3390334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, 3391334234b5SVasanthakumar Thiagarajan const u8 *dst, const u8 *data, 3392334234b5SVasanthakumar Thiagarajan u16 data_len) 33936465ddcfSJouni Malinen { 33946465ddcfSJouni Malinen struct sk_buff *skb; 33956465ddcfSJouni Malinen struct wmi_p2p_probe_response_cmd *p; 3396bd24a50fSAarthi Thiruvengadam size_t cmd_len = sizeof(*p) + data_len; 33976465ddcfSJouni Malinen 3398bd24a50fSAarthi Thiruvengadam if (data_len == 0) 3399bd24a50fSAarthi Thiruvengadam cmd_len++; /* work around target minimum length requirement */ 3400bd24a50fSAarthi Thiruvengadam 3401bd24a50fSAarthi Thiruvengadam skb = ath6kl_wmi_get_new_buf(cmd_len); 34026465ddcfSJouni Malinen if (!skb) 34036465ddcfSJouni Malinen return -ENOMEM; 34046465ddcfSJouni Malinen 34056465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM " 34066465ddcfSJouni Malinen "len=%u\n", freq, dst, data_len); 34076465ddcfSJouni Malinen p = (struct wmi_p2p_probe_response_cmd *) skb->data; 34086465ddcfSJouni Malinen p->freq = cpu_to_le32(freq); 34096465ddcfSJouni Malinen memcpy(p->destination_addr, dst, ETH_ALEN); 34106465ddcfSJouni Malinen p->len = cpu_to_le16(data_len); 34116465ddcfSJouni Malinen memcpy(p->data, data, data_len); 3412334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, 3413334234b5SVasanthakumar Thiagarajan WMI_SEND_PROBE_RESPONSE_CMDID, 34146465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 34156465ddcfSJouni Malinen } 34166465ddcfSJouni Malinen 34170ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable) 34186465ddcfSJouni Malinen { 34196465ddcfSJouni Malinen struct sk_buff *skb; 34206465ddcfSJouni Malinen struct wmi_probe_req_report_cmd *p; 34216465ddcfSJouni Malinen 34226465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 34236465ddcfSJouni Malinen if (!skb) 34246465ddcfSJouni Malinen return -ENOMEM; 34256465ddcfSJouni Malinen 34266465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", 34276465ddcfSJouni Malinen enable); 34286465ddcfSJouni Malinen p = (struct wmi_probe_req_report_cmd *) skb->data; 34296465ddcfSJouni Malinen p->enable = enable ? 1 : 0; 34300ce59445SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID, 34316465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 34326465ddcfSJouni Malinen } 34336465ddcfSJouni Malinen 34340ce59445SVasanthakumar Thiagarajan int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags) 34356465ddcfSJouni Malinen { 34366465ddcfSJouni Malinen struct sk_buff *skb; 34376465ddcfSJouni Malinen struct wmi_get_p2p_info *p; 34386465ddcfSJouni Malinen 34396465ddcfSJouni Malinen skb = ath6kl_wmi_get_new_buf(sizeof(*p)); 34406465ddcfSJouni Malinen if (!skb) 34416465ddcfSJouni Malinen return -ENOMEM; 34426465ddcfSJouni Malinen 34436465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", 34446465ddcfSJouni Malinen info_req_flags); 34456465ddcfSJouni Malinen p = (struct wmi_get_p2p_info *) skb->data; 34466465ddcfSJouni Malinen p->info_req_flags = cpu_to_le32(info_req_flags); 34470ce59445SVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID, 34486465ddcfSJouni Malinen NO_SYNC_WMIFLAG); 34496465ddcfSJouni Malinen } 34506465ddcfSJouni Malinen 3451334234b5SVasanthakumar Thiagarajan int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx) 34526465ddcfSJouni Malinen { 34536465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); 3454334234b5SVasanthakumar Thiagarajan return ath6kl_wmi_simple_cmd(wmi, if_idx, 3455334234b5SVasanthakumar Thiagarajan WMI_CANCEL_REMAIN_ON_CHNL_CMDID); 34566465ddcfSJouni Malinen } 34576465ddcfSJouni Malinen 345803bdeb0dSVasanthakumar Thiagarajan int ath6kl_wmi_set_inact_period(struct wmi *wmi, u8 if_idx, int inact_timeout) 345903bdeb0dSVasanthakumar Thiagarajan { 346003bdeb0dSVasanthakumar Thiagarajan struct sk_buff *skb; 346103bdeb0dSVasanthakumar Thiagarajan struct wmi_set_inact_period_cmd *cmd; 346203bdeb0dSVasanthakumar Thiagarajan 346303bdeb0dSVasanthakumar Thiagarajan skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); 346403bdeb0dSVasanthakumar Thiagarajan if (!skb) 346503bdeb0dSVasanthakumar Thiagarajan return -ENOMEM; 346603bdeb0dSVasanthakumar Thiagarajan 346703bdeb0dSVasanthakumar Thiagarajan cmd = (struct wmi_set_inact_period_cmd *) skb->data; 346803bdeb0dSVasanthakumar Thiagarajan cmd->inact_period = cpu_to_le32(inact_timeout); 346903bdeb0dSVasanthakumar Thiagarajan cmd->num_null_func = 0; 347003bdeb0dSVasanthakumar Thiagarajan 347103bdeb0dSVasanthakumar Thiagarajan return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_CONN_INACT_CMDID, 347203bdeb0dSVasanthakumar Thiagarajan NO_SYNC_WMIFLAG); 347303bdeb0dSVasanthakumar Thiagarajan } 347403bdeb0dSVasanthakumar Thiagarajan 3475bdcd8170SKalle Valo static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) 3476bdcd8170SKalle Valo { 3477bdcd8170SKalle Valo struct wmix_cmd_hdr *cmd; 3478bdcd8170SKalle Valo u32 len; 3479bdcd8170SKalle Valo u16 id; 3480bdcd8170SKalle Valo u8 *datap; 3481bdcd8170SKalle Valo int ret = 0; 3482bdcd8170SKalle Valo 3483bdcd8170SKalle Valo if (skb->len < sizeof(struct wmix_cmd_hdr)) { 3484bdcd8170SKalle Valo ath6kl_err("bad packet 1\n"); 3485bdcd8170SKalle Valo return -EINVAL; 3486bdcd8170SKalle Valo } 3487bdcd8170SKalle Valo 3488bdcd8170SKalle Valo cmd = (struct wmix_cmd_hdr *) skb->data; 3489bdcd8170SKalle Valo id = le32_to_cpu(cmd->cmd_id); 3490bdcd8170SKalle Valo 3491bdcd8170SKalle Valo skb_pull(skb, sizeof(struct wmix_cmd_hdr)); 3492bdcd8170SKalle Valo 3493bdcd8170SKalle Valo datap = skb->data; 3494bdcd8170SKalle Valo len = skb->len; 3495bdcd8170SKalle Valo 3496bdcd8170SKalle Valo switch (id) { 3497bdcd8170SKalle Valo case WMIX_HB_CHALLENGE_RESP_EVENTID: 3498b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n"); 3499bdcd8170SKalle Valo break; 3500bdcd8170SKalle Valo case WMIX_DBGLOG_EVENTID: 3501b9b6ee60SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len); 3502bdf5396bSKalle Valo ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len); 3503bdcd8170SKalle Valo break; 3504bdcd8170SKalle Valo default: 3505b9b6ee60SKalle Valo ath6kl_warn("unknown cmd id 0x%x\n", id); 3506bdcd8170SKalle Valo ret = -EINVAL; 3507bdcd8170SKalle Valo break; 3508bdcd8170SKalle Valo } 3509bdcd8170SKalle Valo 3510bdcd8170SKalle Valo return ret; 3511bdcd8170SKalle Valo } 3512bdcd8170SKalle Valo 35134b28a80dSJouni Malinen static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len) 35144b28a80dSJouni Malinen { 35154b28a80dSJouni Malinen return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len); 35164b28a80dSJouni Malinen } 35174b28a80dSJouni Malinen 35185dbc811fSVasanthakumar Thiagarajan /* Process interface specific wmi events, caller would free the datap */ 35195dbc811fSVasanthakumar Thiagarajan static int ath6kl_wmi_proc_events_vif(struct wmi *wmi, u16 if_idx, u16 cmd_id, 35205dbc811fSVasanthakumar Thiagarajan u8 *datap, u32 len) 3521bdcd8170SKalle Valo { 3522240d2799SVasanthakumar Thiagarajan struct ath6kl_vif *vif; 3523bdcd8170SKalle Valo 3524240d2799SVasanthakumar Thiagarajan vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx); 3525240d2799SVasanthakumar Thiagarajan if (!vif) { 3526240d2799SVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, 3527240d2799SVasanthakumar Thiagarajan "Wmi event for unavailable vif, vif_index:%d\n", 3528240d2799SVasanthakumar Thiagarajan if_idx); 3529240d2799SVasanthakumar Thiagarajan return -EINVAL; 3530240d2799SVasanthakumar Thiagarajan } 3531240d2799SVasanthakumar Thiagarajan 35325dbc811fSVasanthakumar Thiagarajan switch (cmd_id) { 35335dbc811fSVasanthakumar Thiagarajan case WMI_CONNECT_EVENTID: 35345dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); 35355dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_connect_event_rx(wmi, datap, len, vif); 35365dbc811fSVasanthakumar Thiagarajan case WMI_DISCONNECT_EVENTID: 35375dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); 35385dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif); 35395dbc811fSVasanthakumar Thiagarajan case WMI_TKIP_MICERR_EVENTID: 35405dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); 35415dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif); 35425dbc811fSVasanthakumar Thiagarajan case WMI_BSSINFO_EVENTID: 35435dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); 35445dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif); 35455dbc811fSVasanthakumar Thiagarajan case WMI_NEIGHBOR_REPORT_EVENTID: 35465dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); 35475dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len, 35485dbc811fSVasanthakumar Thiagarajan vif); 35495dbc811fSVasanthakumar Thiagarajan case WMI_SCAN_COMPLETE_EVENTID: 35505dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); 35515dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif); 35525dbc811fSVasanthakumar Thiagarajan case WMI_REPORT_STATISTICS_EVENTID: 35535dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); 35545dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_stats_event_rx(wmi, datap, len, vif); 35555dbc811fSVasanthakumar Thiagarajan case WMI_CAC_EVENTID: 35565dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); 35575dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_cac_event_rx(wmi, datap, len, vif); 35585dbc811fSVasanthakumar Thiagarajan case WMI_PSPOLL_EVENTID: 35595dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); 35605dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif); 35615dbc811fSVasanthakumar Thiagarajan case WMI_DTIMEXPIRY_EVENTID: 35625dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); 35635dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif); 35645dbc811fSVasanthakumar Thiagarajan case WMI_ADDBA_REQ_EVENTID: 35655dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); 35665dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif); 35675dbc811fSVasanthakumar Thiagarajan case WMI_DELBA_REQ_EVENTID: 35685dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); 35695dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif); 35705dbc811fSVasanthakumar Thiagarajan case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID: 35715dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, 35725dbc811fSVasanthakumar Thiagarajan "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID"); 35735dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif); 35745dbc811fSVasanthakumar Thiagarajan case WMI_REMAIN_ON_CHNL_EVENTID: 35755dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); 35765dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif); 35775dbc811fSVasanthakumar Thiagarajan case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: 35785dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, 35795dbc811fSVasanthakumar Thiagarajan "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); 35805dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, 35815dbc811fSVasanthakumar Thiagarajan len, vif); 35825dbc811fSVasanthakumar Thiagarajan case WMI_TX_STATUS_EVENTID: 35835dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); 35845dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif); 35855dbc811fSVasanthakumar Thiagarajan case WMI_RX_PROBE_REQ_EVENTID: 35865dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); 35875dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif); 35885dbc811fSVasanthakumar Thiagarajan case WMI_RX_ACTION_EVENTID: 35895dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); 35905dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif); 35915dbc811fSVasanthakumar Thiagarajan default: 35925dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", cmd_id); 35935dbc811fSVasanthakumar Thiagarajan return -EINVAL; 35945dbc811fSVasanthakumar Thiagarajan } 35955dbc811fSVasanthakumar Thiagarajan 35965dbc811fSVasanthakumar Thiagarajan return 0; 35975dbc811fSVasanthakumar Thiagarajan } 35985dbc811fSVasanthakumar Thiagarajan 35995dbc811fSVasanthakumar Thiagarajan static int ath6kl_wmi_proc_events(struct wmi *wmi, struct sk_buff *skb) 36005dbc811fSVasanthakumar Thiagarajan { 36015dbc811fSVasanthakumar Thiagarajan struct wmi_cmd_hdr *cmd; 36025dbc811fSVasanthakumar Thiagarajan int ret = 0; 36035dbc811fSVasanthakumar Thiagarajan u32 len; 36045dbc811fSVasanthakumar Thiagarajan u16 id; 36055dbc811fSVasanthakumar Thiagarajan u8 if_idx; 36065dbc811fSVasanthakumar Thiagarajan u8 *datap; 36075dbc811fSVasanthakumar Thiagarajan 36085dbc811fSVasanthakumar Thiagarajan cmd = (struct wmi_cmd_hdr *) skb->data; 36095dbc811fSVasanthakumar Thiagarajan id = le16_to_cpu(cmd->cmd_id); 36105dbc811fSVasanthakumar Thiagarajan if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK; 36115dbc811fSVasanthakumar Thiagarajan 36125dbc811fSVasanthakumar Thiagarajan skb_pull(skb, sizeof(struct wmi_cmd_hdr)); 36135dbc811fSVasanthakumar Thiagarajan datap = skb->data; 36145dbc811fSVasanthakumar Thiagarajan len = skb->len; 36155dbc811fSVasanthakumar Thiagarajan 36165dbc811fSVasanthakumar Thiagarajan ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len); 36175dbc811fSVasanthakumar Thiagarajan ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ", 36185dbc811fSVasanthakumar Thiagarajan datap, len); 36195dbc811fSVasanthakumar Thiagarajan 3620bdcd8170SKalle Valo switch (id) { 3621bdcd8170SKalle Valo case WMI_GET_BITRATE_CMDID: 3622bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); 3623bdcd8170SKalle Valo ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); 3624bdcd8170SKalle Valo break; 3625bdcd8170SKalle Valo case WMI_GET_CHANNEL_LIST_CMDID: 3626bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); 3627bdcd8170SKalle Valo ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); 3628bdcd8170SKalle Valo break; 3629bdcd8170SKalle Valo case WMI_GET_TX_PWR_CMDID: 3630bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); 3631bdcd8170SKalle Valo ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); 3632bdcd8170SKalle Valo break; 3633bdcd8170SKalle Valo case WMI_READY_EVENTID: 3634bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); 3635bdcd8170SKalle Valo ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); 3636bdcd8170SKalle Valo break; 3637bdcd8170SKalle Valo case WMI_PEER_NODE_EVENTID: 3638bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); 3639bdcd8170SKalle Valo ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); 3640bdcd8170SKalle Valo break; 3641bdcd8170SKalle Valo case WMI_REGDOMAIN_EVENTID: 3642bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); 364306033760SVivek Natarajan ath6kl_wmi_regdomain_event(wmi, datap, len); 3644bdcd8170SKalle Valo break; 3645bdcd8170SKalle Valo case WMI_PSTREAM_TIMEOUT_EVENTID: 3646bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); 3647bdcd8170SKalle Valo ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); 3648bdcd8170SKalle Valo break; 3649bdcd8170SKalle Valo case WMI_CMDERROR_EVENTID: 3650bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); 3651bdcd8170SKalle Valo ret = ath6kl_wmi_error_event_rx(wmi, datap, len); 3652bdcd8170SKalle Valo break; 3653bdcd8170SKalle Valo case WMI_RSSI_THRESHOLD_EVENTID: 3654bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); 3655bdcd8170SKalle Valo ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); 3656bdcd8170SKalle Valo break; 3657bdcd8170SKalle Valo case WMI_ERROR_REPORT_EVENTID: 3658bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); 3659bdcd8170SKalle Valo break; 3660bdcd8170SKalle Valo case WMI_OPT_RX_FRAME_EVENTID: 3661bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); 3662f195d507SJouni Malinen /* this event has been deprecated */ 3663bdcd8170SKalle Valo break; 3664bdcd8170SKalle Valo case WMI_REPORT_ROAM_TBL_EVENTID: 3665bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); 36664b28a80dSJouni Malinen ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len); 3667bdcd8170SKalle Valo break; 3668bdcd8170SKalle Valo case WMI_EXTENSION_EVENTID: 3669bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); 3670bdcd8170SKalle Valo ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); 3671bdcd8170SKalle Valo break; 3672bdcd8170SKalle Valo case WMI_CHANNEL_CHANGE_EVENTID: 3673bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); 3674bdcd8170SKalle Valo break; 3675bdcd8170SKalle Valo case WMI_REPORT_ROAM_DATA_EVENTID: 3676bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); 3677bdcd8170SKalle Valo break; 3678003353b0SKalle Valo case WMI_TEST_EVENTID: 3679003353b0SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n"); 36804f34daceSThomas Pedersen ret = ath6kl_wmi_test_rx(wmi, datap, len); 3681003353b0SKalle Valo break; 3682bdcd8170SKalle Valo case WMI_GET_FIXRATES_CMDID: 3683bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); 3684bdcd8170SKalle Valo ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); 3685bdcd8170SKalle Valo break; 3686bdcd8170SKalle Valo case WMI_TX_RETRY_ERR_EVENTID: 3687bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); 3688bdcd8170SKalle Valo break; 3689bdcd8170SKalle Valo case WMI_SNR_THRESHOLD_EVENTID: 3690bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); 3691bdcd8170SKalle Valo ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); 3692bdcd8170SKalle Valo break; 3693bdcd8170SKalle Valo case WMI_LQ_THRESHOLD_EVENTID: 3694bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); 3695bdcd8170SKalle Valo break; 3696bdcd8170SKalle Valo case WMI_APLIST_EVENTID: 3697bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); 3698bdcd8170SKalle Valo ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); 3699bdcd8170SKalle Valo break; 3700bdcd8170SKalle Valo case WMI_GET_KEEPALIVE_CMDID: 3701bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); 3702bdcd8170SKalle Valo ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); 3703bdcd8170SKalle Valo break; 3704bdcd8170SKalle Valo case WMI_GET_WOW_LIST_EVENTID: 3705bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); 3706bdcd8170SKalle Valo break; 3707bdcd8170SKalle Valo case WMI_GET_PMKID_LIST_EVENTID: 3708bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); 3709bdcd8170SKalle Valo ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); 3710bdcd8170SKalle Valo break; 3711bdcd8170SKalle Valo case WMI_SET_PARAMS_REPLY_EVENTID: 3712bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); 3713bdcd8170SKalle Valo break; 3714bdcd8170SKalle Valo case WMI_ADDBA_RESP_EVENTID: 3715bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); 3716bdcd8170SKalle Valo break; 3717bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_CONFIG_EVENTID: 3718bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3719bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); 3720bdcd8170SKalle Valo break; 3721bdcd8170SKalle Valo case WMI_REPORT_BTCOEX_STATS_EVENTID: 3722bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, 3723bdcd8170SKalle Valo "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); 3724bdcd8170SKalle Valo break; 3725bdcd8170SKalle Valo case WMI_TX_COMPLETE_EVENTID: 3726bdcd8170SKalle Valo ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); 3727bdcd8170SKalle Valo ret = ath6kl_wmi_tx_complete_event_rx(datap, len); 3728bdcd8170SKalle Valo break; 37296465ddcfSJouni Malinen case WMI_P2P_CAPABILITIES_EVENTID: 37306465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); 37316465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); 37326465ddcfSJouni Malinen break; 37336465ddcfSJouni Malinen case WMI_P2P_INFO_EVENTID: 37346465ddcfSJouni Malinen ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); 37356465ddcfSJouni Malinen ret = ath6kl_wmi_p2p_info_event_rx(datap, len); 37366465ddcfSJouni Malinen break; 3737bdcd8170SKalle Valo default: 37385dbc811fSVasanthakumar Thiagarajan /* may be the event is interface specific */ 37395dbc811fSVasanthakumar Thiagarajan ret = ath6kl_wmi_proc_events_vif(wmi, if_idx, id, datap, len); 3740bdcd8170SKalle Valo break; 3741bdcd8170SKalle Valo } 3742bdcd8170SKalle Valo 3743bdcd8170SKalle Valo dev_kfree_skb(skb); 3744bdcd8170SKalle Valo return ret; 3745bdcd8170SKalle Valo } 3746bdcd8170SKalle Valo 37475dbc811fSVasanthakumar Thiagarajan /* Control Path */ 37485dbc811fSVasanthakumar Thiagarajan int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) 37495dbc811fSVasanthakumar Thiagarajan { 37505dbc811fSVasanthakumar Thiagarajan if (WARN_ON(skb == NULL)) 37515dbc811fSVasanthakumar Thiagarajan return -EINVAL; 37525dbc811fSVasanthakumar Thiagarajan 37535dbc811fSVasanthakumar Thiagarajan if (skb->len < sizeof(struct wmi_cmd_hdr)) { 37545dbc811fSVasanthakumar Thiagarajan ath6kl_err("bad packet 1\n"); 37555dbc811fSVasanthakumar Thiagarajan dev_kfree_skb(skb); 37565dbc811fSVasanthakumar Thiagarajan return -EINVAL; 37575dbc811fSVasanthakumar Thiagarajan } 37585dbc811fSVasanthakumar Thiagarajan 37595dbc811fSVasanthakumar Thiagarajan return ath6kl_wmi_proc_events(wmi, skb); 37605dbc811fSVasanthakumar Thiagarajan } 37615dbc811fSVasanthakumar Thiagarajan 3762c89c591dSKalle Valo void ath6kl_wmi_reset(struct wmi *wmi) 3763bdcd8170SKalle Valo { 3764bdcd8170SKalle Valo spin_lock_bh(&wmi->lock); 3765bdcd8170SKalle Valo 3766bdcd8170SKalle Valo wmi->fat_pipe_exist = 0; 3767bdcd8170SKalle Valo memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); 3768bdcd8170SKalle Valo 3769bdcd8170SKalle Valo spin_unlock_bh(&wmi->lock); 3770bdcd8170SKalle Valo } 3771bdcd8170SKalle Valo 37722865785eSVasanthakumar Thiagarajan void *ath6kl_wmi_init(struct ath6kl *dev) 3773bdcd8170SKalle Valo { 3774bdcd8170SKalle Valo struct wmi *wmi; 3775bdcd8170SKalle Valo 3776bdcd8170SKalle Valo wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); 3777bdcd8170SKalle Valo if (!wmi) 3778bdcd8170SKalle Valo return NULL; 3779bdcd8170SKalle Valo 3780bdcd8170SKalle Valo spin_lock_init(&wmi->lock); 3781bdcd8170SKalle Valo 3782bdcd8170SKalle Valo wmi->parent_dev = dev; 3783bdcd8170SKalle Valo 3784bdcd8170SKalle Valo wmi->pwr_mode = REC_POWER; 3785bdcd8170SKalle Valo 3786c89c591dSKalle Valo ath6kl_wmi_reset(wmi); 3787bdcd8170SKalle Valo 3788bdcd8170SKalle Valo return wmi; 3789bdcd8170SKalle Valo } 3790bdcd8170SKalle Valo 3791bdcd8170SKalle Valo void ath6kl_wmi_shutdown(struct wmi *wmi) 3792bdcd8170SKalle Valo { 3793bdcd8170SKalle Valo if (!wmi) 3794bdcd8170SKalle Valo return; 3795bdcd8170SKalle Valo 3796a0df5db1SJouni Malinen kfree(wmi->last_mgmt_tx_frame); 3797bdcd8170SKalle Valo kfree(wmi); 3798bdcd8170SKalle Valo } 3799