Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004-2011 Atheros Communications Inc. |
| 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/ip.h> |
| 18 | #include "core.h" |
| 19 | #include "debug.h" |
Kalle Valo | 003353b0d | 2011-09-01 10:14:21 +0300 | [diff] [blame] | 20 | #include "testmode.h" |
Vivek Natarajan | 0603376 | 2011-09-06 13:01:36 +0530 | [diff] [blame] | 21 | #include "../regd.h" |
| 22 | #include "../regd_common.h" |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 23 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 24 | static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 25 | |
| 26 | static const s32 wmi_rate_tbl[][2] = { |
| 27 | /* {W/O SGI, with SGI} */ |
| 28 | {1000, 1000}, |
| 29 | {2000, 2000}, |
| 30 | {5500, 5500}, |
| 31 | {11000, 11000}, |
| 32 | {6000, 6000}, |
| 33 | {9000, 9000}, |
| 34 | {12000, 12000}, |
| 35 | {18000, 18000}, |
| 36 | {24000, 24000}, |
| 37 | {36000, 36000}, |
| 38 | {48000, 48000}, |
| 39 | {54000, 54000}, |
| 40 | {6500, 7200}, |
| 41 | {13000, 14400}, |
| 42 | {19500, 21700}, |
| 43 | {26000, 28900}, |
| 44 | {39000, 43300}, |
| 45 | {52000, 57800}, |
| 46 | {58500, 65000}, |
| 47 | {65000, 72200}, |
| 48 | {13500, 15000}, |
| 49 | {27000, 30000}, |
| 50 | {40500, 45000}, |
| 51 | {54000, 60000}, |
| 52 | {81000, 90000}, |
| 53 | {108000, 120000}, |
| 54 | {121500, 135000}, |
| 55 | {135000, 150000}, |
| 56 | {0, 0} |
| 57 | }; |
| 58 | |
| 59 | /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */ |
| 60 | static const u8 up_to_ac[] = { |
| 61 | WMM_AC_BE, |
| 62 | WMM_AC_BK, |
| 63 | WMM_AC_BK, |
| 64 | WMM_AC_BE, |
| 65 | WMM_AC_VI, |
| 66 | WMM_AC_VI, |
| 67 | WMM_AC_VO, |
| 68 | WMM_AC_VO, |
| 69 | }; |
| 70 | |
| 71 | void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id) |
| 72 | { |
| 73 | if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX)) |
| 74 | return; |
| 75 | |
| 76 | wmi->ep_id = ep_id; |
| 77 | } |
| 78 | |
| 79 | enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) |
| 80 | { |
| 81 | return wmi->ep_id; |
| 82 | } |
| 83 | |
Vasanthakumar Thiagarajan | 6765d0a | 2011-10-25 19:34:17 +0530 | [diff] [blame] | 84 | struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx) |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 85 | { |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 86 | struct ath6kl_vif *vif, *found = NULL; |
| 87 | |
Kalle Valo | 71f96ee | 2011-11-14 19:31:30 +0200 | [diff] [blame] | 88 | if (WARN_ON(if_idx > (ar->vif_max - 1))) |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 89 | return NULL; |
| 90 | |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 91 | /* FIXME: Locking */ |
Vasanthakumar Thiagarajan | 11f6e40 | 2011-11-01 16:38:50 +0530 | [diff] [blame] | 92 | spin_lock_bh(&ar->list_lock); |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 93 | list_for_each_entry(vif, &ar->vif_list, list) { |
| 94 | if (vif->fw_vif_idx == if_idx) { |
| 95 | found = vif; |
| 96 | break; |
| 97 | } |
| 98 | } |
Vasanthakumar Thiagarajan | 11f6e40 | 2011-11-01 16:38:50 +0530 | [diff] [blame] | 99 | spin_unlock_bh(&ar->list_lock); |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 100 | |
| 101 | return found; |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 102 | } |
| 103 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 104 | /* Performs DIX to 802.3 encapsulation for transmit packets. |
| 105 | * Assumes the entire DIX header is contigous and that there is |
| 106 | * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. |
| 107 | */ |
| 108 | int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) |
| 109 | { |
| 110 | struct ath6kl_llc_snap_hdr *llc_hdr; |
| 111 | struct ethhdr *eth_hdr; |
| 112 | size_t new_len; |
| 113 | __be16 type; |
| 114 | u8 *datap; |
| 115 | u16 size; |
| 116 | |
| 117 | if (WARN_ON(skb == NULL)) |
| 118 | return -EINVAL; |
| 119 | |
| 120 | size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr); |
| 121 | if (skb_headroom(skb) < size) |
| 122 | return -ENOMEM; |
| 123 | |
| 124 | eth_hdr = (struct ethhdr *) skb->data; |
| 125 | type = eth_hdr->h_proto; |
| 126 | |
| 127 | if (!is_ethertype(be16_to_cpu(type))) { |
| 128 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 129 | "%s: pkt is already in 802.3 format\n", __func__); |
| 130 | return 0; |
| 131 | } |
| 132 | |
| 133 | new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr); |
| 134 | |
| 135 | skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr)); |
| 136 | datap = skb->data; |
| 137 | |
| 138 | eth_hdr->h_proto = cpu_to_be16(new_len); |
| 139 | |
| 140 | memcpy(datap, eth_hdr, sizeof(*eth_hdr)); |
| 141 | |
| 142 | llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr)); |
| 143 | llc_hdr->dsap = 0xAA; |
| 144 | llc_hdr->ssap = 0xAA; |
| 145 | llc_hdr->cntl = 0x03; |
| 146 | llc_hdr->org_code[0] = 0x0; |
| 147 | llc_hdr->org_code[1] = 0x0; |
| 148 | llc_hdr->org_code[2] = 0x0; |
| 149 | llc_hdr->eth_type = type; |
| 150 | |
| 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, |
| 155 | u8 *version, void *tx_meta_info) |
| 156 | { |
| 157 | struct wmi_tx_meta_v1 *v1; |
| 158 | struct wmi_tx_meta_v2 *v2; |
| 159 | |
| 160 | if (WARN_ON(skb == NULL || version == NULL)) |
| 161 | return -EINVAL; |
| 162 | |
| 163 | switch (*version) { |
| 164 | case WMI_META_VERSION_1: |
| 165 | skb_push(skb, WMI_MAX_TX_META_SZ); |
| 166 | v1 = (struct wmi_tx_meta_v1 *) skb->data; |
| 167 | v1->pkt_id = 0; |
| 168 | v1->rate_plcy_id = 0; |
| 169 | *version = WMI_META_VERSION_1; |
| 170 | break; |
| 171 | case WMI_META_VERSION_2: |
| 172 | skb_push(skb, WMI_MAX_TX_META_SZ); |
| 173 | v2 = (struct wmi_tx_meta_v2 *) skb->data; |
| 174 | memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info, |
| 175 | sizeof(struct wmi_tx_meta_v2)); |
| 176 | break; |
| 177 | } |
| 178 | |
| 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, |
Thirumalai Pachamuthu | c1762a3 | 2012-01-12 18:21:39 +0530 | [diff] [blame^] | 183 | u8 msg_type, u32 flags, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 184 | enum wmi_data_hdr_data_type data_type, |
Vasanthakumar Thiagarajan | 6765d0a | 2011-10-25 19:34:17 +0530 | [diff] [blame] | 185 | u8 meta_ver, void *tx_meta_info, u8 if_idx) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 186 | { |
| 187 | struct wmi_data_hdr *data_hdr; |
| 188 | int ret; |
| 189 | |
Kalle Valo | 71f96ee | 2011-11-14 19:31:30 +0200 | [diff] [blame] | 190 | if (WARN_ON(skb == NULL || (if_idx > wmi->parent_dev->vif_max - 1))) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 191 | return -EINVAL; |
| 192 | |
Vasanthakumar Thiagarajan | 3ce6ff5 | 2011-08-22 20:40:21 +0530 | [diff] [blame] | 193 | if (tx_meta_info) { |
| 194 | ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info); |
| 195 | if (ret) |
| 196 | return ret; |
| 197 | } |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 198 | |
| 199 | skb_push(skb, sizeof(struct wmi_data_hdr)); |
| 200 | |
| 201 | data_hdr = (struct wmi_data_hdr *)skb->data; |
| 202 | memset(data_hdr, 0, sizeof(struct wmi_data_hdr)); |
| 203 | |
| 204 | data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; |
| 205 | data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; |
| 206 | |
Thirumalai Pachamuthu | c1762a3 | 2012-01-12 18:21:39 +0530 | [diff] [blame^] | 207 | if (flags & WMI_DATA_HDR_FLAGS_MORE) |
| 208 | data_hdr->info |= WMI_DATA_HDR_MORE; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 209 | |
Thirumalai Pachamuthu | c1762a3 | 2012-01-12 18:21:39 +0530 | [diff] [blame^] | 210 | if (flags & WMI_DATA_HDR_FLAGS_EOSP) |
| 211 | data_hdr->info3 |= cpu_to_le16(WMI_DATA_HDR_EOSP); |
| 212 | |
| 213 | data_hdr->info2 |= cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); |
| 214 | data_hdr->info3 |= cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 215 | |
| 216 | return 0; |
| 217 | } |
| 218 | |
Thirumalai Pachamuthu | c1762a3 | 2012-01-12 18:21:39 +0530 | [diff] [blame^] | 219 | u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 220 | { |
| 221 | struct iphdr *ip_hdr = (struct iphdr *) pkt; |
| 222 | u8 ip_pri; |
| 223 | |
| 224 | /* |
| 225 | * Determine IPTOS priority |
| 226 | * |
| 227 | * IP-TOS - 8bits |
| 228 | * : DSCP(6-bits) ECN(2-bits) |
| 229 | * : DSCP - P2 P1 P0 X X X |
| 230 | * where (P2 P1 P0) form 802.1D |
| 231 | */ |
| 232 | ip_pri = ip_hdr->tos >> 5; |
| 233 | ip_pri &= 0x7; |
| 234 | |
| 235 | if ((layer2_pri & 0x7) > ip_pri) |
| 236 | return (u8) layer2_pri & 0x7; |
| 237 | else |
| 238 | return ip_pri; |
| 239 | } |
| 240 | |
Thirumalai Pachamuthu | c1762a3 | 2012-01-12 18:21:39 +0530 | [diff] [blame^] | 241 | u8 ath6kl_wmi_get_traffic_class(u8 user_priority) |
| 242 | { |
| 243 | return up_to_ac[user_priority & 0x7]; |
| 244 | } |
| 245 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 246 | int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx, |
| 247 | struct sk_buff *skb, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 248 | u32 layer2_priority, bool wmm_enabled, |
| 249 | u8 *ac) |
| 250 | { |
| 251 | struct wmi_data_hdr *data_hdr; |
| 252 | struct ath6kl_llc_snap_hdr *llc_hdr; |
| 253 | struct wmi_create_pstream_cmd cmd; |
| 254 | u32 meta_size, hdr_size; |
| 255 | u16 ip_type = IP_ETHERTYPE; |
| 256 | u8 stream_exist, usr_pri; |
| 257 | u8 traffic_class = WMM_AC_BE; |
| 258 | u8 *datap; |
| 259 | |
| 260 | if (WARN_ON(skb == NULL)) |
| 261 | return -EINVAL; |
| 262 | |
| 263 | datap = skb->data; |
| 264 | data_hdr = (struct wmi_data_hdr *) datap; |
| 265 | |
| 266 | meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) & |
| 267 | WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0; |
| 268 | |
| 269 | if (!wmm_enabled) { |
| 270 | /* If WMM is disabled all traffic goes as BE traffic */ |
| 271 | usr_pri = 0; |
| 272 | } else { |
| 273 | hdr_size = sizeof(struct ethhdr); |
| 274 | |
| 275 | llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + |
| 276 | sizeof(struct |
| 277 | wmi_data_hdr) + |
| 278 | meta_size + hdr_size); |
| 279 | |
| 280 | if (llc_hdr->eth_type == htons(ip_type)) { |
| 281 | /* |
| 282 | * Extract the endpoint info from the TOS field |
| 283 | * in the IP header. |
| 284 | */ |
| 285 | usr_pri = |
| 286 | ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + |
| 287 | sizeof(struct ath6kl_llc_snap_hdr), |
| 288 | layer2_priority); |
| 289 | } else |
| 290 | usr_pri = layer2_priority & 0x7; |
| 291 | } |
| 292 | |
Kalle Valo | a7f0c58 | 2011-10-05 12:23:05 +0300 | [diff] [blame] | 293 | /* |
| 294 | * workaround for WMM S5 |
| 295 | * |
| 296 | * FIXME: wmi->traffic_class is always 100 so this test doesn't |
| 297 | * make sense |
| 298 | */ |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 299 | if ((wmi->traffic_class == WMM_AC_VI) && |
| 300 | ((usr_pri == 5) || (usr_pri == 4))) |
| 301 | usr_pri = 1; |
| 302 | |
| 303 | /* Convert user priority to traffic class */ |
| 304 | traffic_class = up_to_ac[usr_pri & 0x7]; |
| 305 | |
| 306 | wmi_data_hdr_set_up(data_hdr, usr_pri); |
| 307 | |
| 308 | spin_lock_bh(&wmi->lock); |
| 309 | stream_exist = wmi->fat_pipe_exist; |
| 310 | spin_unlock_bh(&wmi->lock); |
| 311 | |
| 312 | if (!(stream_exist & (1 << traffic_class))) { |
| 313 | memset(&cmd, 0, sizeof(cmd)); |
| 314 | cmd.traffic_class = traffic_class; |
| 315 | cmd.user_pri = usr_pri; |
| 316 | cmd.inactivity_int = |
| 317 | cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); |
| 318 | /* Implicit streams are created with TSID 0xFF */ |
| 319 | cmd.tsid = WMI_IMPLICIT_PSTREAM; |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 320 | ath6kl_wmi_create_pstream_cmd(wmi, if_idx, &cmd); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | *ac = traffic_class; |
| 324 | |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) |
| 329 | { |
| 330 | struct ieee80211_hdr_3addr *pwh, wh; |
| 331 | struct ath6kl_llc_snap_hdr *llc_hdr; |
| 332 | struct ethhdr eth_hdr; |
| 333 | u32 hdr_size; |
| 334 | u8 *datap; |
| 335 | __le16 sub_type; |
| 336 | |
| 337 | if (WARN_ON(skb == NULL)) |
| 338 | return -EINVAL; |
| 339 | |
| 340 | datap = skb->data; |
| 341 | pwh = (struct ieee80211_hdr_3addr *) datap; |
| 342 | |
| 343 | sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); |
| 344 | |
| 345 | memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); |
| 346 | |
| 347 | /* Strip off the 802.11 header */ |
| 348 | if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { |
| 349 | hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), |
| 350 | sizeof(u32)); |
| 351 | skb_pull(skb, hdr_size); |
| 352 | } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) |
| 353 | skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); |
| 354 | |
| 355 | datap = skb->data; |
| 356 | llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); |
| 357 | |
Raja Mani | c8790cba | 2011-07-19 19:27:32 +0530 | [diff] [blame] | 358 | memset(ð_hdr, 0, sizeof(eth_hdr)); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 359 | eth_hdr.h_proto = llc_hdr->eth_type; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 360 | |
| 361 | switch ((le16_to_cpu(wh.frame_control)) & |
| 362 | (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { |
| 363 | case 0: |
| 364 | memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); |
| 365 | memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); |
| 366 | break; |
| 367 | case IEEE80211_FCTL_TODS: |
| 368 | memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); |
| 369 | memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); |
| 370 | break; |
| 371 | case IEEE80211_FCTL_FROMDS: |
| 372 | memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); |
| 373 | memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); |
| 374 | break; |
| 375 | case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: |
| 376 | break; |
| 377 | } |
| 378 | |
| 379 | skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); |
| 380 | skb_push(skb, sizeof(eth_hdr)); |
| 381 | |
| 382 | datap = skb->data; |
| 383 | |
| 384 | memcpy(datap, ð_hdr, sizeof(eth_hdr)); |
| 385 | |
| 386 | return 0; |
| 387 | } |
| 388 | |
| 389 | /* |
| 390 | * Performs 802.3 to DIX encapsulation for received packets. |
| 391 | * Assumes the entire 802.3 header is contigous. |
| 392 | */ |
| 393 | int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) |
| 394 | { |
| 395 | struct ath6kl_llc_snap_hdr *llc_hdr; |
| 396 | struct ethhdr eth_hdr; |
| 397 | u8 *datap; |
| 398 | |
| 399 | if (WARN_ON(skb == NULL)) |
| 400 | return -EINVAL; |
| 401 | |
| 402 | datap = skb->data; |
| 403 | |
| 404 | memcpy(ð_hdr, datap, sizeof(eth_hdr)); |
| 405 | |
| 406 | llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); |
| 407 | eth_hdr.h_proto = llc_hdr->eth_type; |
| 408 | |
| 409 | skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); |
| 410 | datap = skb->data; |
| 411 | |
| 412 | memcpy(datap, ð_hdr, sizeof(eth_hdr)); |
| 413 | |
| 414 | return 0; |
| 415 | } |
| 416 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 417 | static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) |
| 418 | { |
| 419 | struct tx_complete_msg_v1 *msg_v1; |
| 420 | struct wmi_tx_complete_event *evt; |
| 421 | int index; |
| 422 | u16 size; |
| 423 | |
| 424 | evt = (struct wmi_tx_complete_event *) datap; |
| 425 | |
| 426 | ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", |
| 427 | evt->num_msg, evt->msg_len, evt->msg_type); |
| 428 | |
| 429 | if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI)) |
| 430 | return 0; |
| 431 | |
| 432 | for (index = 0; index < evt->num_msg; index++) { |
| 433 | size = sizeof(struct wmi_tx_complete_event) + |
| 434 | (index * sizeof(struct tx_complete_msg_v1)); |
| 435 | msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); |
| 436 | |
| 437 | ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", |
| 438 | msg_v1->status, msg_v1->pkt_id, |
| 439 | msg_v1->rate_idx, msg_v1->ack_failures); |
| 440 | } |
| 441 | |
| 442 | return 0; |
| 443 | } |
| 444 | |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 445 | static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 446 | int len, struct ath6kl_vif *vif) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 447 | { |
| 448 | struct wmi_remain_on_chnl_event *ev; |
| 449 | u32 freq; |
| 450 | u32 dur; |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 451 | struct ieee80211_channel *chan; |
| 452 | struct ath6kl *ar = wmi->parent_dev; |
Jouni Malinen | 1052261 | 2011-10-27 16:00:13 +0300 | [diff] [blame] | 453 | u32 id; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 454 | |
| 455 | if (len < sizeof(*ev)) |
| 456 | return -EINVAL; |
| 457 | |
| 458 | ev = (struct wmi_remain_on_chnl_event *) datap; |
| 459 | freq = le32_to_cpu(ev->freq); |
| 460 | dur = le32_to_cpu(ev->duration); |
| 461 | ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", |
| 462 | freq, dur); |
Vasanthakumar Thiagarajan | be98e3a | 2011-10-25 19:33:57 +0530 | [diff] [blame] | 463 | chan = ieee80211_get_channel(ar->wiphy, freq); |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 464 | if (!chan) { |
| 465 | ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " |
| 466 | "(freq=%u)\n", freq); |
| 467 | return -EINVAL; |
| 468 | } |
Jouni Malinen | 1052261 | 2011-10-27 16:00:13 +0300 | [diff] [blame] | 469 | id = vif->last_roc_id; |
| 470 | cfg80211_ready_on_channel(vif->ndev, id, chan, NL80211_CHAN_NO_HT, |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 471 | dur, GFP_ATOMIC); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 472 | |
| 473 | return 0; |
| 474 | } |
| 475 | |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 476 | static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 477 | u8 *datap, int len, |
| 478 | struct ath6kl_vif *vif) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 479 | { |
| 480 | struct wmi_cancel_remain_on_chnl_event *ev; |
| 481 | u32 freq; |
| 482 | u32 dur; |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 483 | struct ieee80211_channel *chan; |
| 484 | struct ath6kl *ar = wmi->parent_dev; |
Jouni Malinen | 1052261 | 2011-10-27 16:00:13 +0300 | [diff] [blame] | 485 | u32 id; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 486 | |
| 487 | if (len < sizeof(*ev)) |
| 488 | return -EINVAL; |
| 489 | |
| 490 | ev = (struct wmi_cancel_remain_on_chnl_event *) datap; |
| 491 | freq = le32_to_cpu(ev->freq); |
| 492 | dur = le32_to_cpu(ev->duration); |
| 493 | ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " |
| 494 | "status=%u\n", freq, dur, ev->status); |
Vasanthakumar Thiagarajan | be98e3a | 2011-10-25 19:33:57 +0530 | [diff] [blame] | 495 | chan = ieee80211_get_channel(ar->wiphy, freq); |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 496 | if (!chan) { |
| 497 | ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " |
| 498 | "channel (freq=%u)\n", freq); |
| 499 | return -EINVAL; |
| 500 | } |
Jouni Malinen | 1052261 | 2011-10-27 16:00:13 +0300 | [diff] [blame] | 501 | if (vif->last_cancel_roc_id && |
| 502 | vif->last_cancel_roc_id + 1 == vif->last_roc_id) |
| 503 | id = vif->last_cancel_roc_id; /* event for cancel command */ |
| 504 | else |
| 505 | id = vif->last_roc_id; /* timeout on uncanceled r-o-c */ |
| 506 | vif->last_cancel_roc_id = 0; |
| 507 | cfg80211_remain_on_channel_expired(vif->ndev, id, chan, |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 508 | NL80211_CHAN_NO_HT, GFP_ATOMIC); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 509 | |
| 510 | return 0; |
| 511 | } |
| 512 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 513 | static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 514 | struct ath6kl_vif *vif) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 515 | { |
| 516 | struct wmi_tx_status_event *ev; |
| 517 | u32 id; |
| 518 | |
| 519 | if (len < sizeof(*ev)) |
| 520 | return -EINVAL; |
| 521 | |
| 522 | ev = (struct wmi_tx_status_event *) datap; |
| 523 | id = le32_to_cpu(ev->id); |
| 524 | ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", |
| 525 | id, ev->ack_status); |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame] | 526 | if (wmi->last_mgmt_tx_frame) { |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 527 | cfg80211_mgmt_tx_status(vif->ndev, id, |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame] | 528 | wmi->last_mgmt_tx_frame, |
| 529 | wmi->last_mgmt_tx_frame_len, |
| 530 | !!ev->ack_status, GFP_ATOMIC); |
| 531 | kfree(wmi->last_mgmt_tx_frame); |
| 532 | wmi->last_mgmt_tx_frame = NULL; |
| 533 | wmi->last_mgmt_tx_frame_len = 0; |
| 534 | } |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 535 | |
| 536 | return 0; |
| 537 | } |
| 538 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 539 | static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 540 | struct ath6kl_vif *vif) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 541 | { |
| 542 | struct wmi_p2p_rx_probe_req_event *ev; |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 543 | u32 freq; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 544 | u16 dlen; |
| 545 | |
| 546 | if (len < sizeof(*ev)) |
| 547 | return -EINVAL; |
| 548 | |
| 549 | ev = (struct wmi_p2p_rx_probe_req_event *) datap; |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 550 | freq = le32_to_cpu(ev->freq); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 551 | dlen = le16_to_cpu(ev->len); |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 552 | if (datap + len < ev->data + dlen) { |
| 553 | ath6kl_err("invalid wmi_p2p_rx_probe_req_event: " |
| 554 | "len=%d dlen=%u\n", len, dlen); |
| 555 | return -EINVAL; |
| 556 | } |
| 557 | ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u " |
| 558 | "probe_req_report=%d\n", |
Vasanthakumar Thiagarajan | cf5333d | 2011-10-25 19:34:10 +0530 | [diff] [blame] | 559 | dlen, freq, vif->probe_req_report); |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 560 | |
Vasanthakumar Thiagarajan | cf5333d | 2011-10-25 19:34:10 +0530 | [diff] [blame] | 561 | if (vif->probe_req_report || vif->nw_type == AP_NETWORK) |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 562 | cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 563 | |
| 564 | return 0; |
| 565 | } |
| 566 | |
| 567 | static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) |
| 568 | { |
| 569 | struct wmi_p2p_capabilities_event *ev; |
| 570 | u16 dlen; |
| 571 | |
| 572 | if (len < sizeof(*ev)) |
| 573 | return -EINVAL; |
| 574 | |
| 575 | ev = (struct wmi_p2p_capabilities_event *) datap; |
| 576 | dlen = le16_to_cpu(ev->len); |
| 577 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); |
| 578 | |
| 579 | return 0; |
| 580 | } |
| 581 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 582 | static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 583 | struct ath6kl_vif *vif) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 584 | { |
| 585 | struct wmi_rx_action_event *ev; |
Jouni Malinen | 9809d8e | 2011-08-30 21:58:03 +0300 | [diff] [blame] | 586 | u32 freq; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 587 | u16 dlen; |
| 588 | |
| 589 | if (len < sizeof(*ev)) |
| 590 | return -EINVAL; |
| 591 | |
| 592 | ev = (struct wmi_rx_action_event *) datap; |
Jouni Malinen | 9809d8e | 2011-08-30 21:58:03 +0300 | [diff] [blame] | 593 | freq = le32_to_cpu(ev->freq); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 594 | dlen = le16_to_cpu(ev->len); |
Jouni Malinen | 9809d8e | 2011-08-30 21:58:03 +0300 | [diff] [blame] | 595 | if (datap + len < ev->data + dlen) { |
| 596 | ath6kl_err("invalid wmi_rx_action_event: " |
| 597 | "len=%d dlen=%u\n", len, dlen); |
| 598 | return -EINVAL; |
| 599 | } |
| 600 | ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 601 | cfg80211_rx_mgmt(vif->ndev, freq, ev->data, dlen, GFP_ATOMIC); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 602 | |
| 603 | return 0; |
| 604 | } |
| 605 | |
| 606 | static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) |
| 607 | { |
| 608 | struct wmi_p2p_info_event *ev; |
| 609 | u32 flags; |
| 610 | u16 dlen; |
| 611 | |
| 612 | if (len < sizeof(*ev)) |
| 613 | return -EINVAL; |
| 614 | |
| 615 | ev = (struct wmi_p2p_info_event *) datap; |
| 616 | flags = le32_to_cpu(ev->info_req_flags); |
| 617 | dlen = le16_to_cpu(ev->len); |
| 618 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); |
| 619 | |
| 620 | if (flags & P2P_FLAG_CAPABILITIES_REQ) { |
| 621 | struct wmi_p2p_capabilities *cap; |
| 622 | if (dlen < sizeof(*cap)) |
| 623 | return -EINVAL; |
| 624 | cap = (struct wmi_p2p_capabilities *) ev->data; |
| 625 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", |
| 626 | cap->go_power_save); |
| 627 | } |
| 628 | |
| 629 | if (flags & P2P_FLAG_MACADDR_REQ) { |
| 630 | struct wmi_p2p_macaddr *mac; |
| 631 | if (dlen < sizeof(*mac)) |
| 632 | return -EINVAL; |
| 633 | mac = (struct wmi_p2p_macaddr *) ev->data; |
| 634 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", |
| 635 | mac->mac_addr); |
| 636 | } |
| 637 | |
| 638 | if (flags & P2P_FLAG_HMODEL_REQ) { |
| 639 | struct wmi_p2p_hmodel *mod; |
| 640 | if (dlen < sizeof(*mod)) |
| 641 | return -EINVAL; |
| 642 | mod = (struct wmi_p2p_hmodel *) ev->data; |
| 643 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", |
| 644 | mod->p2p_model, |
| 645 | mod->p2p_model ? "host" : "firmware"); |
| 646 | } |
| 647 | return 0; |
| 648 | } |
| 649 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 650 | static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) |
| 651 | { |
| 652 | struct sk_buff *skb; |
| 653 | |
| 654 | skb = ath6kl_buf_alloc(size); |
| 655 | if (!skb) |
| 656 | return NULL; |
| 657 | |
| 658 | skb_put(skb, size); |
| 659 | if (size) |
| 660 | memset(skb->data, 0, size); |
| 661 | |
| 662 | return skb; |
| 663 | } |
| 664 | |
| 665 | /* Send a "simple" wmi command -- one with no arguments */ |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 666 | static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx, |
| 667 | enum wmi_cmd_id cmd_id) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 668 | { |
| 669 | struct sk_buff *skb; |
| 670 | int ret; |
| 671 | |
| 672 | skb = ath6kl_wmi_get_new_buf(0); |
| 673 | if (!skb) |
| 674 | return -ENOMEM; |
| 675 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 676 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 677 | |
| 678 | return ret; |
| 679 | } |
| 680 | |
| 681 | static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 682 | { |
| 683 | struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; |
| 684 | |
| 685 | if (len < sizeof(struct wmi_ready_event_2)) |
| 686 | return -EINVAL; |
| 687 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 688 | ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, |
| 689 | le32_to_cpu(ev->sw_version), |
| 690 | le32_to_cpu(ev->abi_version)); |
| 691 | |
| 692 | return 0; |
| 693 | } |
| 694 | |
Vivek Natarajan | e509044 | 2011-08-31 15:02:19 +0530 | [diff] [blame] | 695 | /* |
| 696 | * Mechanism to modify the roaming behavior in the firmware. The lower rssi |
| 697 | * at which the station has to roam can be passed with |
| 698 | * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level |
| 699 | * in dBm. |
| 700 | */ |
| 701 | int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi) |
| 702 | { |
| 703 | struct sk_buff *skb; |
| 704 | struct roam_ctrl_cmd *cmd; |
| 705 | |
| 706 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 707 | if (!skb) |
| 708 | return -ENOMEM; |
| 709 | |
| 710 | cmd = (struct roam_ctrl_cmd *) skb->data; |
| 711 | |
| 712 | cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD); |
| 713 | cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi + |
| 714 | DEF_SCAN_FOR_ROAM_INTVL); |
| 715 | cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi); |
| 716 | cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR; |
| 717 | cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS; |
| 718 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 719 | ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, |
| 720 | NO_SYNC_WMIFLAG); |
Vivek Natarajan | e509044 | 2011-08-31 15:02:19 +0530 | [diff] [blame] | 721 | |
| 722 | return 0; |
| 723 | } |
| 724 | |
Jouni Malinen | 1261875 | 2011-10-11 17:31:55 +0300 | [diff] [blame] | 725 | int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid) |
| 726 | { |
| 727 | struct sk_buff *skb; |
| 728 | struct roam_ctrl_cmd *cmd; |
| 729 | |
| 730 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 731 | if (!skb) |
| 732 | return -ENOMEM; |
| 733 | |
| 734 | cmd = (struct roam_ctrl_cmd *) skb->data; |
| 735 | memset(cmd, 0, sizeof(*cmd)); |
| 736 | |
| 737 | memcpy(cmd->info.bssid, bssid, ETH_ALEN); |
| 738 | cmd->roam_ctrl = WMI_FORCE_ROAM; |
| 739 | |
| 740 | ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 741 | return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, |
Jouni Malinen | 1261875 | 2011-10-11 17:31:55 +0300 | [diff] [blame] | 742 | NO_SYNC_WMIFLAG); |
| 743 | } |
| 744 | |
| 745 | int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode) |
| 746 | { |
| 747 | struct sk_buff *skb; |
| 748 | struct roam_ctrl_cmd *cmd; |
| 749 | |
| 750 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 751 | if (!skb) |
| 752 | return -ENOMEM; |
| 753 | |
| 754 | cmd = (struct roam_ctrl_cmd *) skb->data; |
| 755 | memset(cmd, 0, sizeof(*cmd)); |
| 756 | |
| 757 | cmd->info.roam_mode = mode; |
| 758 | cmd->roam_ctrl = WMI_SET_ROAM_MODE; |
| 759 | |
| 760 | ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 761 | return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID, |
Jouni Malinen | 1261875 | 2011-10-11 17:31:55 +0300 | [diff] [blame] | 762 | NO_SYNC_WMIFLAG); |
| 763 | } |
| 764 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 765 | static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 766 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 767 | { |
| 768 | struct wmi_connect_event *ev; |
| 769 | u8 *pie, *peie; |
| 770 | |
| 771 | if (len < sizeof(struct wmi_connect_event)) |
| 772 | return -EINVAL; |
| 773 | |
| 774 | ev = (struct wmi_connect_event *) datap; |
| 775 | |
Vasanthakumar Thiagarajan | f5938f2 | 2011-10-25 19:34:03 +0530 | [diff] [blame] | 776 | if (vif->nw_type == AP_NETWORK) { |
Jouni Malinen | 572e27c | 2011-09-05 17:38:45 +0300 | [diff] [blame] | 777 | /* AP mode start/STA connected event */ |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 778 | struct net_device *dev = vif->ndev; |
Jouni Malinen | 572e27c | 2011-09-05 17:38:45 +0300 | [diff] [blame] | 779 | if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) { |
| 780 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM " |
| 781 | "(AP started)\n", |
| 782 | __func__, le16_to_cpu(ev->u.ap_bss.ch), |
| 783 | ev->u.ap_bss.bssid); |
| 784 | ath6kl_connect_ap_mode_bss( |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 785 | vif, le16_to_cpu(ev->u.ap_bss.ch)); |
Jouni Malinen | 572e27c | 2011-09-05 17:38:45 +0300 | [diff] [blame] | 786 | } else { |
| 787 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: aid %u mac_addr %pM " |
| 788 | "auth=%u keymgmt=%u cipher=%u apsd_info=%u " |
| 789 | "(STA connected)\n", |
| 790 | __func__, ev->u.ap_sta.aid, |
| 791 | ev->u.ap_sta.mac_addr, |
| 792 | ev->u.ap_sta.auth, |
| 793 | ev->u.ap_sta.keymgmt, |
| 794 | le16_to_cpu(ev->u.ap_sta.cipher), |
| 795 | ev->u.ap_sta.apsd_info); |
Thirumalai Pachamuthu | c1762a3 | 2012-01-12 18:21:39 +0530 | [diff] [blame^] | 796 | |
Jouni Malinen | 572e27c | 2011-09-05 17:38:45 +0300 | [diff] [blame] | 797 | ath6kl_connect_ap_mode_sta( |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 798 | vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr, |
Jouni Malinen | 572e27c | 2011-09-05 17:38:45 +0300 | [diff] [blame] | 799 | ev->u.ap_sta.keymgmt, |
| 800 | le16_to_cpu(ev->u.ap_sta.cipher), |
| 801 | ev->u.ap_sta.auth, ev->assoc_req_len, |
Thirumalai Pachamuthu | c1762a3 | 2012-01-12 18:21:39 +0530 | [diff] [blame^] | 802 | ev->assoc_info + ev->beacon_ie_len, |
| 803 | ev->u.ap_sta.apsd_info); |
Jouni Malinen | 572e27c | 2011-09-05 17:38:45 +0300 | [diff] [blame] | 804 | } |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | /* STA/IBSS mode connection event */ |
| 809 | |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 810 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 811 | "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n", |
| 812 | le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid, |
| 813 | le16_to_cpu(ev->u.sta.listen_intvl), |
| 814 | le16_to_cpu(ev->u.sta.beacon_intvl), |
| 815 | le32_to_cpu(ev->u.sta.nw_type)); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 816 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 817 | /* Start of assoc rsp IEs */ |
| 818 | pie = ev->assoc_info + ev->beacon_ie_len + |
| 819 | ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ |
| 820 | |
| 821 | /* End of assoc rsp IEs */ |
| 822 | peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + |
| 823 | ev->assoc_resp_len; |
| 824 | |
| 825 | while (pie < peie) { |
| 826 | switch (*pie) { |
| 827 | case WLAN_EID_VENDOR_SPECIFIC: |
| 828 | if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && |
| 829 | pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { |
| 830 | /* WMM OUT (00:50:F2) */ |
| 831 | if (pie[1] > 5 |
| 832 | && pie[6] == WMM_PARAM_OUI_SUBTYPE) |
| 833 | wmi->is_wmm_enabled = true; |
| 834 | } |
| 835 | break; |
| 836 | } |
| 837 | |
| 838 | if (wmi->is_wmm_enabled) |
| 839 | break; |
| 840 | |
| 841 | pie += pie[1] + 2; |
| 842 | } |
| 843 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 844 | ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch), |
Jouni Malinen | 572e27c | 2011-09-05 17:38:45 +0300 | [diff] [blame] | 845 | ev->u.sta.bssid, |
| 846 | le16_to_cpu(ev->u.sta.listen_intvl), |
| 847 | le16_to_cpu(ev->u.sta.beacon_intvl), |
| 848 | le32_to_cpu(ev->u.sta.nw_type), |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 849 | ev->beacon_ie_len, ev->assoc_req_len, |
| 850 | ev->assoc_resp_len, ev->assoc_info); |
| 851 | |
| 852 | return 0; |
| 853 | } |
| 854 | |
Vivek Natarajan | 0603376 | 2011-09-06 13:01:36 +0530 | [diff] [blame] | 855 | static struct country_code_to_enum_rd * |
| 856 | ath6kl_regd_find_country(u16 countryCode) |
| 857 | { |
| 858 | int i; |
| 859 | |
| 860 | for (i = 0; i < ARRAY_SIZE(allCountries); i++) { |
| 861 | if (allCountries[i].countryCode == countryCode) |
| 862 | return &allCountries[i]; |
| 863 | } |
| 864 | |
| 865 | return NULL; |
| 866 | } |
| 867 | |
| 868 | static struct reg_dmn_pair_mapping * |
| 869 | ath6kl_get_regpair(u16 regdmn) |
| 870 | { |
| 871 | int i; |
| 872 | |
| 873 | if (regdmn == NO_ENUMRD) |
| 874 | return NULL; |
| 875 | |
| 876 | for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) { |
| 877 | if (regDomainPairs[i].regDmnEnum == regdmn) |
| 878 | return ®DomainPairs[i]; |
| 879 | } |
| 880 | |
| 881 | return NULL; |
| 882 | } |
| 883 | |
| 884 | static struct country_code_to_enum_rd * |
| 885 | ath6kl_regd_find_country_by_rd(u16 regdmn) |
| 886 | { |
| 887 | int i; |
| 888 | |
| 889 | for (i = 0; i < ARRAY_SIZE(allCountries); i++) { |
| 890 | if (allCountries[i].regDmnEnum == regdmn) |
| 891 | return &allCountries[i]; |
| 892 | } |
| 893 | |
| 894 | return NULL; |
| 895 | } |
| 896 | |
| 897 | static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len) |
| 898 | { |
| 899 | |
| 900 | struct ath6kl_wmi_regdomain *ev; |
| 901 | struct country_code_to_enum_rd *country = NULL; |
| 902 | struct reg_dmn_pair_mapping *regpair = NULL; |
| 903 | char alpha2[2]; |
| 904 | u32 reg_code; |
| 905 | |
| 906 | ev = (struct ath6kl_wmi_regdomain *) datap; |
| 907 | reg_code = le32_to_cpu(ev->reg_code); |
| 908 | |
| 909 | if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG) |
| 910 | country = ath6kl_regd_find_country((u16) reg_code); |
| 911 | else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) { |
| 912 | |
| 913 | regpair = ath6kl_get_regpair((u16) reg_code); |
| 914 | country = ath6kl_regd_find_country_by_rd((u16) reg_code); |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 915 | ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n", |
Vivek Natarajan | 0603376 | 2011-09-06 13:01:36 +0530 | [diff] [blame] | 916 | regpair->regDmnEnum); |
| 917 | } |
| 918 | |
| 919 | if (country) { |
| 920 | alpha2[0] = country->isoName[0]; |
| 921 | alpha2[1] = country->isoName[1]; |
| 922 | |
Vasanthakumar Thiagarajan | be98e3a | 2011-10-25 19:33:57 +0530 | [diff] [blame] | 923 | regulatory_hint(wmi->parent_dev->wiphy, alpha2); |
Vivek Natarajan | 0603376 | 2011-09-06 13:01:36 +0530 | [diff] [blame] | 924 | |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 925 | ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n", |
Vivek Natarajan | 0603376 | 2011-09-06 13:01:36 +0530 | [diff] [blame] | 926 | alpha2[0], alpha2[1]); |
| 927 | } |
| 928 | } |
| 929 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 930 | static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 931 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 932 | { |
| 933 | struct wmi_disconnect_event *ev; |
| 934 | wmi->traffic_class = 100; |
| 935 | |
| 936 | if (len < sizeof(struct wmi_disconnect_event)) |
| 937 | return -EINVAL; |
| 938 | |
| 939 | ev = (struct wmi_disconnect_event *) datap; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 940 | |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 941 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 942 | "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n", |
| 943 | le16_to_cpu(ev->proto_reason_status), ev->bssid, |
| 944 | ev->disconn_reason, ev->assoc_resp_len); |
| 945 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 946 | wmi->is_wmm_enabled = false; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 947 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 948 | ath6kl_disconnect_event(vif, ev->disconn_reason, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 949 | ev->bssid, ev->assoc_resp_len, ev->assoc_info, |
| 950 | le16_to_cpu(ev->proto_reason_status)); |
| 951 | |
| 952 | return 0; |
| 953 | } |
| 954 | |
| 955 | static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 956 | { |
| 957 | struct wmi_peer_node_event *ev; |
| 958 | |
| 959 | if (len < sizeof(struct wmi_peer_node_event)) |
| 960 | return -EINVAL; |
| 961 | |
| 962 | ev = (struct wmi_peer_node_event *) datap; |
| 963 | |
| 964 | if (ev->event_code == PEER_NODE_JOIN_EVENT) |
| 965 | ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", |
| 966 | ev->peer_mac_addr); |
| 967 | else if (ev->event_code == PEER_NODE_LEAVE_EVENT) |
| 968 | ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", |
| 969 | ev->peer_mac_addr); |
| 970 | |
| 971 | return 0; |
| 972 | } |
| 973 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 974 | static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 975 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 976 | { |
| 977 | struct wmi_tkip_micerr_event *ev; |
| 978 | |
| 979 | if (len < sizeof(struct wmi_tkip_micerr_event)) |
| 980 | return -EINVAL; |
| 981 | |
| 982 | ev = (struct wmi_tkip_micerr_event *) datap; |
| 983 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 984 | ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 985 | |
| 986 | return 0; |
| 987 | } |
| 988 | |
Kalle Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 989 | void ath6kl_wmi_sscan_timer(unsigned long ptr) |
| 990 | { |
| 991 | struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr; |
| 992 | |
| 993 | cfg80211_sched_scan_results(vif->ar->wiphy); |
| 994 | } |
| 995 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 996 | static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 997 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 998 | { |
Jouni Malinen | 82e14f5 | 2011-09-19 19:15:05 +0300 | [diff] [blame] | 999 | struct wmi_bss_info_hdr2 *bih; |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1000 | u8 *buf; |
| 1001 | struct ieee80211_channel *channel; |
| 1002 | struct ath6kl *ar = wmi->parent_dev; |
| 1003 | struct ieee80211_mgmt *mgmt; |
| 1004 | struct cfg80211_bss *bss; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1005 | |
Jouni Malinen | 82e14f5 | 2011-09-19 19:15:05 +0300 | [diff] [blame] | 1006 | if (len <= sizeof(struct wmi_bss_info_hdr2)) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1007 | return -EINVAL; |
| 1008 | |
Jouni Malinen | 82e14f5 | 2011-09-19 19:15:05 +0300 | [diff] [blame] | 1009 | bih = (struct wmi_bss_info_hdr2 *) datap; |
| 1010 | buf = datap + sizeof(struct wmi_bss_info_hdr2); |
| 1011 | len -= sizeof(struct wmi_bss_info_hdr2); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1012 | |
| 1013 | ath6kl_dbg(ATH6KL_DBG_WMI, |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1014 | "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" " |
| 1015 | "frame_type=%d\n", |
Jouni Malinen | 82e14f5 | 2011-09-19 19:15:05 +0300 | [diff] [blame] | 1016 | bih->ch, bih->snr, bih->snr - 95, bih->bssid, |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1017 | bih->frame_type); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1018 | |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1019 | if (bih->frame_type != BEACON_FTYPE && |
| 1020 | bih->frame_type != PROBERESP_FTYPE) |
| 1021 | return 0; /* Only update BSS table for now */ |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1022 | |
Jouni Malinen | 551185c | 2011-09-19 19:15:06 +0300 | [diff] [blame] | 1023 | if (bih->frame_type == BEACON_FTYPE && |
Vasanthakumar Thiagarajan | 59c9844 | 2011-10-25 19:34:01 +0530 | [diff] [blame] | 1024 | test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) { |
| 1025 | clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1026 | ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx, |
| 1027 | NONE_BSS_FILTER, 0); |
Jouni Malinen | 551185c | 2011-09-19 19:15:06 +0300 | [diff] [blame] | 1028 | } |
| 1029 | |
Vasanthakumar Thiagarajan | be98e3a | 2011-10-25 19:33:57 +0530 | [diff] [blame] | 1030 | channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch)); |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1031 | if (channel == NULL) |
| 1032 | return -EINVAL; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1033 | |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1034 | if (len < 8 + 2 + 2) |
| 1035 | return -EINVAL; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1036 | |
Vasanthakumar Thiagarajan | 59c9844 | 2011-10-25 19:34:01 +0530 | [diff] [blame] | 1037 | if (bih->frame_type == BEACON_FTYPE && test_bit(CONNECTED, &vif->flags) |
Vasanthakumar Thiagarajan | 8c8b65e | 2011-10-25 19:34:04 +0530 | [diff] [blame] | 1038 | && memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) { |
Jouni Malinen | 32c1087 | 2011-09-19 19:15:07 +0300 | [diff] [blame] | 1039 | const u8 *tim; |
| 1040 | tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2, |
| 1041 | len - 8 - 2 - 2); |
| 1042 | if (tim && tim[1] >= 2) { |
Vasanthakumar Thiagarajan | cf5333d | 2011-10-25 19:34:10 +0530 | [diff] [blame] | 1043 | vif->assoc_bss_dtim_period = tim[3]; |
Vasanthakumar Thiagarajan | 59c9844 | 2011-10-25 19:34:01 +0530 | [diff] [blame] | 1044 | set_bit(DTIM_PERIOD_AVAIL, &vif->flags); |
Jouni Malinen | 32c1087 | 2011-09-19 19:15:07 +0300 | [diff] [blame] | 1045 | } |
| 1046 | } |
| 1047 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1048 | /* |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1049 | * In theory, use of cfg80211_inform_bss() would be more natural here |
| 1050 | * since we do not have the full frame. However, at least for now, |
| 1051 | * cfg80211 can only distinguish Beacon and Probe Response frames from |
| 1052 | * each other when using cfg80211_inform_bss_frame(), so let's build a |
| 1053 | * fake IEEE 802.11 header to be able to take benefit of this. |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1054 | */ |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1055 | mgmt = kmalloc(24 + len, GFP_ATOMIC); |
| 1056 | if (mgmt == NULL) |
| 1057 | return -EINVAL; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1058 | |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1059 | if (bih->frame_type == BEACON_FTYPE) { |
| 1060 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 1061 | IEEE80211_STYPE_BEACON); |
| 1062 | memset(mgmt->da, 0xff, ETH_ALEN); |
| 1063 | } else { |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1064 | struct net_device *dev = vif->ndev; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1065 | |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1066 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 1067 | IEEE80211_STYPE_PROBE_RESP); |
| 1068 | memcpy(mgmt->da, dev->dev_addr, ETH_ALEN); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1069 | } |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1070 | mgmt->duration = cpu_to_le16(0); |
| 1071 | memcpy(mgmt->sa, bih->bssid, ETH_ALEN); |
| 1072 | memcpy(mgmt->bssid, bih->bssid, ETH_ALEN); |
| 1073 | mgmt->seq_ctrl = cpu_to_le16(0); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1074 | |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1075 | memcpy(&mgmt->u.beacon, buf, len); |
| 1076 | |
Vasanthakumar Thiagarajan | be98e3a | 2011-10-25 19:33:57 +0530 | [diff] [blame] | 1077 | bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt, |
Jouni Malinen | 82e14f5 | 2011-09-19 19:15:05 +0300 | [diff] [blame] | 1078 | 24 + len, (bih->snr - 95) * 100, |
| 1079 | GFP_ATOMIC); |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1080 | kfree(mgmt); |
| 1081 | if (bss == NULL) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1082 | return -ENOMEM; |
Jouni Malinen | 1aaa8c7 | 2011-09-19 19:15:03 +0300 | [diff] [blame] | 1083 | cfg80211_put_bss(bss); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1084 | |
Kalle Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 1085 | /* |
| 1086 | * Firmware doesn't return any event when scheduled scan has |
| 1087 | * finished, so we need to use a timer to find out when there are |
| 1088 | * no more results. |
| 1089 | * |
| 1090 | * The timer is started from the first bss info received, otherwise |
| 1091 | * the timer would not ever fire if the scan interval is short |
| 1092 | * enough. |
| 1093 | */ |
| 1094 | if (ar->state == ATH6KL_STATE_SCHED_SCAN && |
| 1095 | !timer_pending(&vif->sched_scan_timer)) { |
| 1096 | mod_timer(&vif->sched_scan_timer, jiffies + |
| 1097 | msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY)); |
| 1098 | } |
| 1099 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1100 | return 0; |
| 1101 | } |
| 1102 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1103 | /* Inactivity timeout of a fatpipe(pstream) at the target */ |
| 1104 | static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, |
| 1105 | int len) |
| 1106 | { |
| 1107 | struct wmi_pstream_timeout_event *ev; |
| 1108 | |
| 1109 | if (len < sizeof(struct wmi_pstream_timeout_event)) |
| 1110 | return -EINVAL; |
| 1111 | |
| 1112 | ev = (struct wmi_pstream_timeout_event *) datap; |
| 1113 | |
| 1114 | /* |
| 1115 | * When the pstream (fat pipe == AC) timesout, it means there were |
| 1116 | * no thinStreams within this pstream & it got implicitly created |
| 1117 | * due to data flow on this AC. We start the inactivity timer only |
| 1118 | * for implicitly created pstream. Just reset the host state. |
| 1119 | */ |
| 1120 | spin_lock_bh(&wmi->lock); |
| 1121 | wmi->stream_exist_for_ac[ev->traffic_class] = 0; |
| 1122 | wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); |
| 1123 | spin_unlock_bh(&wmi->lock); |
| 1124 | |
| 1125 | /* Indicate inactivity to driver layer for this fatpipe (pstream) */ |
| 1126 | ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); |
| 1127 | |
| 1128 | return 0; |
| 1129 | } |
| 1130 | |
| 1131 | static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1132 | { |
| 1133 | struct wmi_bit_rate_reply *reply; |
| 1134 | s32 rate; |
| 1135 | u32 sgi, index; |
| 1136 | |
| 1137 | if (len < sizeof(struct wmi_bit_rate_reply)) |
| 1138 | return -EINVAL; |
| 1139 | |
| 1140 | reply = (struct wmi_bit_rate_reply *) datap; |
| 1141 | |
| 1142 | ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); |
| 1143 | |
| 1144 | if (reply->rate_index == (s8) RATE_AUTO) { |
| 1145 | rate = RATE_AUTO; |
| 1146 | } else { |
| 1147 | index = reply->rate_index & 0x7f; |
| 1148 | sgi = (reply->rate_index & 0x80) ? 1 : 0; |
| 1149 | rate = wmi_rate_tbl[index][sgi]; |
| 1150 | } |
| 1151 | |
| 1152 | ath6kl_wakeup_event(wmi->parent_dev); |
| 1153 | |
| 1154 | return 0; |
| 1155 | } |
| 1156 | |
Thomas Pedersen | 4f34dac | 2011-12-30 01:57:00 -0800 | [diff] [blame] | 1157 | static int ath6kl_wmi_test_rx(struct wmi *wmi, u8 *datap, int len) |
Kalle Valo | 003353b0d | 2011-09-01 10:14:21 +0300 | [diff] [blame] | 1158 | { |
Thomas Pedersen | 4f34dac | 2011-12-30 01:57:00 -0800 | [diff] [blame] | 1159 | ath6kl_tm_rx_event(wmi->parent_dev, datap, len); |
Kalle Valo | 003353b0d | 2011-09-01 10:14:21 +0300 | [diff] [blame] | 1160 | |
| 1161 | return 0; |
| 1162 | } |
| 1163 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1164 | static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1165 | { |
| 1166 | if (len < sizeof(struct wmi_fix_rates_reply)) |
| 1167 | return -EINVAL; |
| 1168 | |
| 1169 | ath6kl_wakeup_event(wmi->parent_dev); |
| 1170 | |
| 1171 | return 0; |
| 1172 | } |
| 1173 | |
| 1174 | static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1175 | { |
| 1176 | if (len < sizeof(struct wmi_channel_list_reply)) |
| 1177 | return -EINVAL; |
| 1178 | |
| 1179 | ath6kl_wakeup_event(wmi->parent_dev); |
| 1180 | |
| 1181 | return 0; |
| 1182 | } |
| 1183 | |
| 1184 | static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1185 | { |
| 1186 | struct wmi_tx_pwr_reply *reply; |
| 1187 | |
| 1188 | if (len < sizeof(struct wmi_tx_pwr_reply)) |
| 1189 | return -EINVAL; |
| 1190 | |
| 1191 | reply = (struct wmi_tx_pwr_reply *) datap; |
| 1192 | ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); |
| 1193 | |
| 1194 | return 0; |
| 1195 | } |
| 1196 | |
| 1197 | static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1198 | { |
| 1199 | if (len < sizeof(struct wmi_get_keepalive_cmd)) |
| 1200 | return -EINVAL; |
| 1201 | |
| 1202 | ath6kl_wakeup_event(wmi->parent_dev); |
| 1203 | |
| 1204 | return 0; |
| 1205 | } |
| 1206 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1207 | static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len, |
| 1208 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1209 | { |
| 1210 | struct wmi_scan_complete_event *ev; |
| 1211 | |
| 1212 | ev = (struct wmi_scan_complete_event *) datap; |
| 1213 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1214 | ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status)); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1215 | wmi->is_probe_ssid = false; |
| 1216 | |
| 1217 | return 0; |
| 1218 | } |
| 1219 | |
Jouni Malinen | 8651213 | 2011-09-21 16:57:29 +0300 | [diff] [blame] | 1220 | static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap, |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1221 | int len, struct ath6kl_vif *vif) |
Jouni Malinen | 8651213 | 2011-09-21 16:57:29 +0300 | [diff] [blame] | 1222 | { |
| 1223 | struct wmi_neighbor_report_event *ev; |
| 1224 | u8 i; |
| 1225 | |
| 1226 | if (len < sizeof(*ev)) |
| 1227 | return -EINVAL; |
| 1228 | ev = (struct wmi_neighbor_report_event *) datap; |
| 1229 | if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info) |
| 1230 | > len) { |
| 1231 | ath6kl_dbg(ATH6KL_DBG_WMI, "truncated neighbor event " |
| 1232 | "(num=%d len=%d)\n", ev->num_neighbors, len); |
| 1233 | return -EINVAL; |
| 1234 | } |
| 1235 | for (i = 0; i < ev->num_neighbors; i++) { |
| 1236 | ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n", |
| 1237 | i + 1, ev->num_neighbors, ev->neighbor[i].bssid, |
| 1238 | ev->neighbor[i].bss_flags); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1239 | cfg80211_pmksa_candidate_notify(vif->ndev, i, |
Jouni Malinen | 8651213 | 2011-09-21 16:57:29 +0300 | [diff] [blame] | 1240 | ev->neighbor[i].bssid, |
| 1241 | !!(ev->neighbor[i].bss_flags & |
| 1242 | WMI_PREAUTH_CAPABLE_BSS), |
| 1243 | GFP_ATOMIC); |
| 1244 | } |
| 1245 | |
| 1246 | return 0; |
| 1247 | } |
| 1248 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1249 | /* |
| 1250 | * Target is reporting a programming error. This is for |
| 1251 | * developer aid only. Target only checks a few common violations |
| 1252 | * and it is responsibility of host to do all error checking. |
| 1253 | * Behavior of target after wmi error event is undefined. |
| 1254 | * A reset is recommended. |
| 1255 | */ |
| 1256 | static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1257 | { |
| 1258 | const char *type = "unknown error"; |
| 1259 | struct wmi_cmd_error_event *ev; |
| 1260 | ev = (struct wmi_cmd_error_event *) datap; |
| 1261 | |
| 1262 | switch (ev->err_code) { |
| 1263 | case INVALID_PARAM: |
| 1264 | type = "invalid parameter"; |
| 1265 | break; |
| 1266 | case ILLEGAL_STATE: |
| 1267 | type = "invalid state"; |
| 1268 | break; |
| 1269 | case INTERNAL_ERROR: |
| 1270 | type = "internal error"; |
| 1271 | break; |
| 1272 | } |
| 1273 | |
| 1274 | ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", |
| 1275 | ev->cmd_id, type); |
| 1276 | |
| 1277 | return 0; |
| 1278 | } |
| 1279 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1280 | static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 1281 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1282 | { |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1283 | ath6kl_tgt_stats_event(vif, datap, len); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1284 | |
| 1285 | return 0; |
| 1286 | } |
| 1287 | |
| 1288 | static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, |
| 1289 | struct sq_threshold_params *sq_thresh, |
| 1290 | u32 size) |
| 1291 | { |
| 1292 | u32 index; |
| 1293 | u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; |
| 1294 | |
| 1295 | /* The list is already in sorted order. Get the next lower value */ |
| 1296 | for (index = 0; index < size; index++) { |
| 1297 | if (rssi < sq_thresh->upper_threshold[index]) { |
| 1298 | threshold = (u8) sq_thresh->upper_threshold[index]; |
| 1299 | break; |
| 1300 | } |
| 1301 | } |
| 1302 | |
| 1303 | return threshold; |
| 1304 | } |
| 1305 | |
| 1306 | static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, |
| 1307 | struct sq_threshold_params *sq_thresh, |
| 1308 | u32 size) |
| 1309 | { |
| 1310 | u32 index; |
| 1311 | u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; |
| 1312 | |
| 1313 | /* The list is already in sorted order. Get the next lower value */ |
| 1314 | for (index = 0; index < size; index++) { |
| 1315 | if (rssi > sq_thresh->lower_threshold[index]) { |
| 1316 | threshold = (u8) sq_thresh->lower_threshold[index]; |
| 1317 | break; |
| 1318 | } |
| 1319 | } |
| 1320 | |
| 1321 | return threshold; |
| 1322 | } |
| 1323 | |
| 1324 | static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, |
| 1325 | struct wmi_rssi_threshold_params_cmd *rssi_cmd) |
| 1326 | { |
| 1327 | struct sk_buff *skb; |
| 1328 | struct wmi_rssi_threshold_params_cmd *cmd; |
| 1329 | |
| 1330 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1331 | if (!skb) |
| 1332 | return -ENOMEM; |
| 1333 | |
| 1334 | cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; |
| 1335 | memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); |
| 1336 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1337 | return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1338 | NO_SYNC_WMIFLAG); |
| 1339 | } |
| 1340 | |
| 1341 | static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, |
| 1342 | int len) |
| 1343 | { |
| 1344 | struct wmi_rssi_threshold_event *reply; |
| 1345 | struct wmi_rssi_threshold_params_cmd cmd; |
| 1346 | struct sq_threshold_params *sq_thresh; |
| 1347 | enum wmi_rssi_threshold_val new_threshold; |
| 1348 | u8 upper_rssi_threshold, lower_rssi_threshold; |
| 1349 | s16 rssi; |
| 1350 | int ret; |
| 1351 | |
| 1352 | if (len < sizeof(struct wmi_rssi_threshold_event)) |
| 1353 | return -EINVAL; |
| 1354 | |
| 1355 | reply = (struct wmi_rssi_threshold_event *) datap; |
| 1356 | new_threshold = (enum wmi_rssi_threshold_val) reply->range; |
| 1357 | rssi = a_sle16_to_cpu(reply->rssi); |
| 1358 | |
| 1359 | sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; |
| 1360 | |
| 1361 | /* |
| 1362 | * Identify the threshold breached and communicate that to the app. |
| 1363 | * After that install a new set of thresholds based on the signal |
| 1364 | * quality reported by the target |
| 1365 | */ |
| 1366 | if (new_threshold) { |
| 1367 | /* Upper threshold breached */ |
| 1368 | if (rssi < sq_thresh->upper_threshold[0]) { |
| 1369 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1370 | "spurious upper rssi threshold event: %d\n", |
| 1371 | rssi); |
| 1372 | } else if ((rssi < sq_thresh->upper_threshold[1]) && |
| 1373 | (rssi >= sq_thresh->upper_threshold[0])) { |
| 1374 | new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; |
| 1375 | } else if ((rssi < sq_thresh->upper_threshold[2]) && |
| 1376 | (rssi >= sq_thresh->upper_threshold[1])) { |
| 1377 | new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; |
| 1378 | } else if ((rssi < sq_thresh->upper_threshold[3]) && |
| 1379 | (rssi >= sq_thresh->upper_threshold[2])) { |
| 1380 | new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; |
| 1381 | } else if ((rssi < sq_thresh->upper_threshold[4]) && |
| 1382 | (rssi >= sq_thresh->upper_threshold[3])) { |
| 1383 | new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; |
| 1384 | } else if ((rssi < sq_thresh->upper_threshold[5]) && |
| 1385 | (rssi >= sq_thresh->upper_threshold[4])) { |
| 1386 | new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; |
| 1387 | } else if (rssi >= sq_thresh->upper_threshold[5]) { |
| 1388 | new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; |
| 1389 | } |
| 1390 | } else { |
| 1391 | /* Lower threshold breached */ |
| 1392 | if (rssi > sq_thresh->lower_threshold[0]) { |
| 1393 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1394 | "spurious lower rssi threshold event: %d %d\n", |
| 1395 | rssi, sq_thresh->lower_threshold[0]); |
| 1396 | } else if ((rssi > sq_thresh->lower_threshold[1]) && |
| 1397 | (rssi <= sq_thresh->lower_threshold[0])) { |
| 1398 | new_threshold = WMI_RSSI_THRESHOLD6_BELOW; |
| 1399 | } else if ((rssi > sq_thresh->lower_threshold[2]) && |
| 1400 | (rssi <= sq_thresh->lower_threshold[1])) { |
| 1401 | new_threshold = WMI_RSSI_THRESHOLD5_BELOW; |
| 1402 | } else if ((rssi > sq_thresh->lower_threshold[3]) && |
| 1403 | (rssi <= sq_thresh->lower_threshold[2])) { |
| 1404 | new_threshold = WMI_RSSI_THRESHOLD4_BELOW; |
| 1405 | } else if ((rssi > sq_thresh->lower_threshold[4]) && |
| 1406 | (rssi <= sq_thresh->lower_threshold[3])) { |
| 1407 | new_threshold = WMI_RSSI_THRESHOLD3_BELOW; |
| 1408 | } else if ((rssi > sq_thresh->lower_threshold[5]) && |
| 1409 | (rssi <= sq_thresh->lower_threshold[4])) { |
| 1410 | new_threshold = WMI_RSSI_THRESHOLD2_BELOW; |
| 1411 | } else if (rssi <= sq_thresh->lower_threshold[5]) { |
| 1412 | new_threshold = WMI_RSSI_THRESHOLD1_BELOW; |
| 1413 | } |
| 1414 | } |
| 1415 | |
| 1416 | /* Calculate and install the next set of thresholds */ |
| 1417 | lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, |
| 1418 | sq_thresh->lower_threshold_valid_count); |
| 1419 | upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, |
| 1420 | sq_thresh->upper_threshold_valid_count); |
| 1421 | |
| 1422 | /* Issue a wmi command to install the thresholds */ |
| 1423 | cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); |
| 1424 | cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); |
| 1425 | cmd.weight = sq_thresh->weight; |
| 1426 | cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); |
| 1427 | |
| 1428 | ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); |
| 1429 | if (ret) { |
| 1430 | ath6kl_err("unable to configure rssi thresholds\n"); |
| 1431 | return -EIO; |
| 1432 | } |
| 1433 | |
| 1434 | return 0; |
| 1435 | } |
| 1436 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1437 | static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 1438 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1439 | { |
| 1440 | struct wmi_cac_event *reply; |
| 1441 | struct ieee80211_tspec_ie *ts; |
| 1442 | u16 active_tsids, tsinfo; |
| 1443 | u8 tsid, index; |
| 1444 | u8 ts_id; |
| 1445 | |
| 1446 | if (len < sizeof(struct wmi_cac_event)) |
| 1447 | return -EINVAL; |
| 1448 | |
| 1449 | reply = (struct wmi_cac_event *) datap; |
| 1450 | |
| 1451 | if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && |
| 1452 | (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { |
| 1453 | |
| 1454 | ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); |
| 1455 | tsinfo = le16_to_cpu(ts->tsinfo); |
| 1456 | tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & |
| 1457 | IEEE80211_WMM_IE_TSPEC_TID_MASK; |
| 1458 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1459 | ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, |
| 1460 | reply->ac, tsid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1461 | } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { |
| 1462 | /* |
| 1463 | * Following assumes that there is only one outstanding |
| 1464 | * ADDTS request when this event is received |
| 1465 | */ |
| 1466 | spin_lock_bh(&wmi->lock); |
| 1467 | active_tsids = wmi->stream_exist_for_ac[reply->ac]; |
| 1468 | spin_unlock_bh(&wmi->lock); |
| 1469 | |
| 1470 | for (index = 0; index < sizeof(active_tsids) * 8; index++) { |
| 1471 | if ((active_tsids >> index) & 1) |
| 1472 | break; |
| 1473 | } |
| 1474 | if (index < (sizeof(active_tsids) * 8)) |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1475 | ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx, |
| 1476 | reply->ac, index); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1477 | } |
| 1478 | |
| 1479 | /* |
| 1480 | * Clear active tsids and Add missing handling |
| 1481 | * for delete qos stream from AP |
| 1482 | */ |
| 1483 | else if (reply->cac_indication == CAC_INDICATION_DELETE) { |
| 1484 | |
| 1485 | ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); |
| 1486 | tsinfo = le16_to_cpu(ts->tsinfo); |
| 1487 | ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & |
| 1488 | IEEE80211_WMM_IE_TSPEC_TID_MASK); |
| 1489 | |
| 1490 | spin_lock_bh(&wmi->lock); |
| 1491 | wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); |
| 1492 | active_tsids = wmi->stream_exist_for_ac[reply->ac]; |
| 1493 | spin_unlock_bh(&wmi->lock); |
| 1494 | |
| 1495 | /* Indicate stream inactivity to driver layer only if all tsids |
| 1496 | * within this AC are deleted. |
| 1497 | */ |
| 1498 | if (!active_tsids) { |
| 1499 | ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, |
| 1500 | false); |
| 1501 | wmi->fat_pipe_exist &= ~(1 << reply->ac); |
| 1502 | } |
| 1503 | } |
| 1504 | |
| 1505 | return 0; |
| 1506 | } |
| 1507 | |
| 1508 | static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, |
| 1509 | struct wmi_snr_threshold_params_cmd *snr_cmd) |
| 1510 | { |
| 1511 | struct sk_buff *skb; |
| 1512 | struct wmi_snr_threshold_params_cmd *cmd; |
| 1513 | |
| 1514 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1515 | if (!skb) |
| 1516 | return -ENOMEM; |
| 1517 | |
| 1518 | cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; |
| 1519 | memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); |
| 1520 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1521 | return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1522 | NO_SYNC_WMIFLAG); |
| 1523 | } |
| 1524 | |
| 1525 | static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, |
| 1526 | int len) |
| 1527 | { |
| 1528 | struct wmi_snr_threshold_event *reply; |
| 1529 | struct sq_threshold_params *sq_thresh; |
| 1530 | struct wmi_snr_threshold_params_cmd cmd; |
| 1531 | enum wmi_snr_threshold_val new_threshold; |
| 1532 | u8 upper_snr_threshold, lower_snr_threshold; |
| 1533 | s16 snr; |
| 1534 | int ret; |
| 1535 | |
| 1536 | if (len < sizeof(struct wmi_snr_threshold_event)) |
| 1537 | return -EINVAL; |
| 1538 | |
| 1539 | reply = (struct wmi_snr_threshold_event *) datap; |
| 1540 | |
| 1541 | new_threshold = (enum wmi_snr_threshold_val) reply->range; |
| 1542 | snr = reply->snr; |
| 1543 | |
| 1544 | sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; |
| 1545 | |
| 1546 | /* |
| 1547 | * Identify the threshold breached and communicate that to the app. |
| 1548 | * After that install a new set of thresholds based on the signal |
| 1549 | * quality reported by the target. |
| 1550 | */ |
| 1551 | if (new_threshold) { |
| 1552 | /* Upper threshold breached */ |
| 1553 | if (snr < sq_thresh->upper_threshold[0]) { |
| 1554 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1555 | "spurious upper snr threshold event: %d\n", |
| 1556 | snr); |
| 1557 | } else if ((snr < sq_thresh->upper_threshold[1]) && |
| 1558 | (snr >= sq_thresh->upper_threshold[0])) { |
| 1559 | new_threshold = WMI_SNR_THRESHOLD1_ABOVE; |
| 1560 | } else if ((snr < sq_thresh->upper_threshold[2]) && |
| 1561 | (snr >= sq_thresh->upper_threshold[1])) { |
| 1562 | new_threshold = WMI_SNR_THRESHOLD2_ABOVE; |
| 1563 | } else if ((snr < sq_thresh->upper_threshold[3]) && |
| 1564 | (snr >= sq_thresh->upper_threshold[2])) { |
| 1565 | new_threshold = WMI_SNR_THRESHOLD3_ABOVE; |
| 1566 | } else if (snr >= sq_thresh->upper_threshold[3]) { |
| 1567 | new_threshold = WMI_SNR_THRESHOLD4_ABOVE; |
| 1568 | } |
| 1569 | } else { |
| 1570 | /* Lower threshold breached */ |
| 1571 | if (snr > sq_thresh->lower_threshold[0]) { |
| 1572 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1573 | "spurious lower snr threshold event: %d\n", |
| 1574 | sq_thresh->lower_threshold[0]); |
| 1575 | } else if ((snr > sq_thresh->lower_threshold[1]) && |
| 1576 | (snr <= sq_thresh->lower_threshold[0])) { |
| 1577 | new_threshold = WMI_SNR_THRESHOLD4_BELOW; |
| 1578 | } else if ((snr > sq_thresh->lower_threshold[2]) && |
| 1579 | (snr <= sq_thresh->lower_threshold[1])) { |
| 1580 | new_threshold = WMI_SNR_THRESHOLD3_BELOW; |
| 1581 | } else if ((snr > sq_thresh->lower_threshold[3]) && |
| 1582 | (snr <= sq_thresh->lower_threshold[2])) { |
| 1583 | new_threshold = WMI_SNR_THRESHOLD2_BELOW; |
| 1584 | } else if (snr <= sq_thresh->lower_threshold[3]) { |
| 1585 | new_threshold = WMI_SNR_THRESHOLD1_BELOW; |
| 1586 | } |
| 1587 | } |
| 1588 | |
| 1589 | /* Calculate and install the next set of thresholds */ |
| 1590 | lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, |
| 1591 | sq_thresh->lower_threshold_valid_count); |
| 1592 | upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, |
| 1593 | sq_thresh->upper_threshold_valid_count); |
| 1594 | |
| 1595 | /* Issue a wmi command to install the thresholds */ |
| 1596 | cmd.thresh_above1_val = upper_snr_threshold; |
| 1597 | cmd.thresh_below1_val = lower_snr_threshold; |
| 1598 | cmd.weight = sq_thresh->weight; |
| 1599 | cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); |
| 1600 | |
| 1601 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1602 | "snr: %d, threshold: %d, lower: %d, upper: %d\n", |
| 1603 | snr, new_threshold, |
| 1604 | lower_snr_threshold, upper_snr_threshold); |
| 1605 | |
| 1606 | ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); |
| 1607 | if (ret) { |
| 1608 | ath6kl_err("unable to configure snr threshold\n"); |
| 1609 | return -EIO; |
| 1610 | } |
| 1611 | |
| 1612 | return 0; |
| 1613 | } |
| 1614 | |
| 1615 | static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1616 | { |
| 1617 | u16 ap_info_entry_size; |
| 1618 | struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; |
| 1619 | struct wmi_ap_info_v1 *ap_info_v1; |
| 1620 | u8 index; |
| 1621 | |
| 1622 | if (len < sizeof(struct wmi_aplist_event) || |
| 1623 | ev->ap_list_ver != APLIST_VER1) |
| 1624 | return -EINVAL; |
| 1625 | |
| 1626 | ap_info_entry_size = sizeof(struct wmi_ap_info_v1); |
| 1627 | ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; |
| 1628 | |
| 1629 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1630 | "number of APs in aplist event: %d\n", ev->num_ap); |
| 1631 | |
| 1632 | if (len < (int) (sizeof(struct wmi_aplist_event) + |
| 1633 | (ev->num_ap - 1) * ap_info_entry_size)) |
| 1634 | return -EINVAL; |
| 1635 | |
| 1636 | /* AP list version 1 contents */ |
| 1637 | for (index = 0; index < ev->num_ap; index++) { |
| 1638 | ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", |
| 1639 | index, ap_info_v1->bssid, ap_info_v1->channel); |
| 1640 | ap_info_v1++; |
| 1641 | } |
| 1642 | |
| 1643 | return 0; |
| 1644 | } |
| 1645 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1646 | int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1647 | enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) |
| 1648 | { |
| 1649 | struct wmi_cmd_hdr *cmd_hdr; |
| 1650 | enum htc_endpoint_id ep_id = wmi->ep_id; |
| 1651 | int ret; |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1652 | u16 info1; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1653 | |
Kalle Valo | 71f96ee | 2011-11-14 19:31:30 +0200 | [diff] [blame] | 1654 | if (WARN_ON(skb == NULL || (if_idx > (wmi->parent_dev->vif_max - 1)))) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1655 | return -EINVAL; |
| 1656 | |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 1657 | ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n", |
| 1658 | cmd_id, skb->len, sync_flag); |
| 1659 | ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ", |
| 1660 | skb->data, skb->len); |
| 1661 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1662 | if (sync_flag >= END_WMIFLAG) { |
| 1663 | dev_kfree_skb(skb); |
| 1664 | return -EINVAL; |
| 1665 | } |
| 1666 | |
| 1667 | if ((sync_flag == SYNC_BEFORE_WMIFLAG) || |
| 1668 | (sync_flag == SYNC_BOTH_WMIFLAG)) { |
| 1669 | /* |
| 1670 | * Make sure all data currently queued is transmitted before |
| 1671 | * the cmd execution. Establish a new sync point. |
| 1672 | */ |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1673 | ath6kl_wmi_sync_point(wmi, if_idx); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1674 | } |
| 1675 | |
| 1676 | skb_push(skb, sizeof(struct wmi_cmd_hdr)); |
| 1677 | |
| 1678 | cmd_hdr = (struct wmi_cmd_hdr *) skb->data; |
| 1679 | cmd_hdr->cmd_id = cpu_to_le16(cmd_id); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1680 | info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK; |
| 1681 | cmd_hdr->info1 = cpu_to_le16(info1); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1682 | |
| 1683 | /* Only for OPT_TX_CMD, use BE endpoint. */ |
| 1684 | if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { |
| 1685 | ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, |
Vasanthakumar Thiagarajan | 6765d0a | 2011-10-25 19:34:17 +0530 | [diff] [blame] | 1686 | false, false, 0, NULL, if_idx); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1687 | if (ret) { |
| 1688 | dev_kfree_skb(skb); |
| 1689 | return ret; |
| 1690 | } |
| 1691 | ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); |
| 1692 | } |
| 1693 | |
| 1694 | ath6kl_control_tx(wmi->parent_dev, skb, ep_id); |
| 1695 | |
| 1696 | if ((sync_flag == SYNC_AFTER_WMIFLAG) || |
| 1697 | (sync_flag == SYNC_BOTH_WMIFLAG)) { |
| 1698 | /* |
| 1699 | * Make sure all new data queued waits for the command to |
| 1700 | * execute. Establish a new sync point. |
| 1701 | */ |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1702 | ath6kl_wmi_sync_point(wmi, if_idx); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1703 | } |
| 1704 | |
| 1705 | return 0; |
| 1706 | } |
| 1707 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1708 | int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx, |
| 1709 | enum network_type nw_type, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1710 | enum dot11_auth_mode dot11_auth_mode, |
| 1711 | enum auth_mode auth_mode, |
| 1712 | enum crypto_type pairwise_crypto, |
| 1713 | u8 pairwise_crypto_len, |
| 1714 | enum crypto_type group_crypto, |
| 1715 | u8 group_crypto_len, int ssid_len, u8 *ssid, |
Aarthi Thiruvengadam | 3ca9d1f | 2011-12-13 13:32:12 -0800 | [diff] [blame] | 1716 | u8 *bssid, u16 channel, u32 ctrl_flags, |
| 1717 | u8 nw_subtype) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1718 | { |
| 1719 | struct sk_buff *skb; |
| 1720 | struct wmi_connect_cmd *cc; |
| 1721 | int ret; |
| 1722 | |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 1723 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1724 | "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d " |
| 1725 | "type %d dot11_auth %d auth %d pairwise %d group %d\n", |
| 1726 | bssid, channel, ctrl_flags, ssid_len, nw_type, |
| 1727 | dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto); |
| 1728 | ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len); |
| 1729 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1730 | wmi->traffic_class = 100; |
| 1731 | |
| 1732 | if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) |
| 1733 | return -EINVAL; |
| 1734 | |
| 1735 | if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) |
| 1736 | return -EINVAL; |
| 1737 | |
| 1738 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); |
| 1739 | if (!skb) |
| 1740 | return -ENOMEM; |
| 1741 | |
| 1742 | cc = (struct wmi_connect_cmd *) skb->data; |
| 1743 | |
| 1744 | if (ssid_len) |
| 1745 | memcpy(cc->ssid, ssid, ssid_len); |
| 1746 | |
| 1747 | cc->ssid_len = ssid_len; |
| 1748 | cc->nw_type = nw_type; |
| 1749 | cc->dot11_auth_mode = dot11_auth_mode; |
| 1750 | cc->auth_mode = auth_mode; |
| 1751 | cc->prwise_crypto_type = pairwise_crypto; |
| 1752 | cc->prwise_crypto_len = pairwise_crypto_len; |
| 1753 | cc->grp_crypto_type = group_crypto; |
| 1754 | cc->grp_crypto_len = group_crypto_len; |
| 1755 | cc->ch = cpu_to_le16(channel); |
| 1756 | cc->ctrl_flags = cpu_to_le32(ctrl_flags); |
Aarthi Thiruvengadam | 3ca9d1f | 2011-12-13 13:32:12 -0800 | [diff] [blame] | 1757 | cc->nw_subtype = nw_subtype; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1758 | |
| 1759 | if (bssid != NULL) |
| 1760 | memcpy(cc->bssid, bssid, ETH_ALEN); |
| 1761 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1762 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID, |
| 1763 | NO_SYNC_WMIFLAG); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1764 | |
| 1765 | return ret; |
| 1766 | } |
| 1767 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1768 | int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid, |
| 1769 | u16 channel) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1770 | { |
| 1771 | struct sk_buff *skb; |
| 1772 | struct wmi_reconnect_cmd *cc; |
| 1773 | int ret; |
| 1774 | |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 1775 | ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n", |
| 1776 | bssid, channel); |
| 1777 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1778 | wmi->traffic_class = 100; |
| 1779 | |
| 1780 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); |
| 1781 | if (!skb) |
| 1782 | return -ENOMEM; |
| 1783 | |
| 1784 | cc = (struct wmi_reconnect_cmd *) skb->data; |
| 1785 | cc->channel = cpu_to_le16(channel); |
| 1786 | |
| 1787 | if (bssid != NULL) |
| 1788 | memcpy(cc->bssid, bssid, ETH_ALEN); |
| 1789 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1790 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1791 | NO_SYNC_WMIFLAG); |
| 1792 | |
| 1793 | return ret; |
| 1794 | } |
| 1795 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1796 | int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1797 | { |
| 1798 | int ret; |
| 1799 | |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 1800 | ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n"); |
| 1801 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1802 | wmi->traffic_class = 100; |
| 1803 | |
| 1804 | /* Disconnect command does not need to do a SYNC before. */ |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1805 | ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1806 | |
| 1807 | return ret; |
| 1808 | } |
| 1809 | |
Aarthi Thiruvengadam | 3ca9d1f | 2011-12-13 13:32:12 -0800 | [diff] [blame] | 1810 | int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx, |
| 1811 | enum wmi_scan_type scan_type, |
| 1812 | u32 force_fgscan, u32 is_legacy, |
| 1813 | u32 home_dwell_time, u32 force_scan_interval, |
| 1814 | s8 num_chan, u16 *ch_list, u32 no_cck, u32 *rates) |
| 1815 | { |
| 1816 | struct sk_buff *skb; |
| 1817 | struct wmi_begin_scan_cmd *sc; |
| 1818 | s8 size; |
| 1819 | int i, band, ret; |
| 1820 | struct ath6kl *ar = wmi->parent_dev; |
| 1821 | int num_rates; |
| 1822 | |
| 1823 | size = sizeof(struct wmi_begin_scan_cmd); |
| 1824 | |
| 1825 | if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) |
| 1826 | return -EINVAL; |
| 1827 | |
| 1828 | if (num_chan > WMI_MAX_CHANNELS) |
| 1829 | return -EINVAL; |
| 1830 | |
| 1831 | if (num_chan) |
| 1832 | size += sizeof(u16) * (num_chan - 1); |
| 1833 | |
| 1834 | skb = ath6kl_wmi_get_new_buf(size); |
| 1835 | if (!skb) |
| 1836 | return -ENOMEM; |
| 1837 | |
| 1838 | sc = (struct wmi_begin_scan_cmd *) skb->data; |
| 1839 | sc->scan_type = scan_type; |
| 1840 | sc->force_fg_scan = cpu_to_le32(force_fgscan); |
| 1841 | sc->is_legacy = cpu_to_le32(is_legacy); |
| 1842 | sc->home_dwell_time = cpu_to_le32(home_dwell_time); |
| 1843 | sc->force_scan_intvl = cpu_to_le32(force_scan_interval); |
| 1844 | sc->no_cck = cpu_to_le32(no_cck); |
| 1845 | sc->num_ch = num_chan; |
| 1846 | |
| 1847 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { |
| 1848 | struct ieee80211_supported_band *sband = |
| 1849 | ar->wiphy->bands[band]; |
| 1850 | u32 ratemask = rates[band]; |
| 1851 | u8 *supp_rates = sc->supp_rates[band].rates; |
| 1852 | num_rates = 0; |
| 1853 | |
| 1854 | for (i = 0; i < sband->n_bitrates; i++) { |
| 1855 | if ((BIT(i) & ratemask) == 0) |
| 1856 | continue; /* skip rate */ |
| 1857 | supp_rates[num_rates++] = |
| 1858 | (u8) (sband->bitrates[i].bitrate / 5); |
| 1859 | } |
| 1860 | sc->supp_rates[band].nrates = num_rates; |
| 1861 | } |
| 1862 | |
| 1863 | for (i = 0; i < num_chan; i++) |
| 1864 | sc->ch_list[i] = cpu_to_le16(ch_list[i]); |
| 1865 | |
| 1866 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_BEGIN_SCAN_CMDID, |
| 1867 | NO_SYNC_WMIFLAG); |
| 1868 | |
| 1869 | return ret; |
| 1870 | } |
| 1871 | |
| 1872 | /* ath6kl_wmi_start_scan_cmd is to be deprecated. Use |
| 1873 | * ath6kl_wmi_begin_scan_cmd instead. The new function supports P2P |
| 1874 | * mgmt operations using station interface. |
| 1875 | */ |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1876 | int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx, |
| 1877 | enum wmi_scan_type scan_type, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1878 | u32 force_fgscan, u32 is_legacy, |
| 1879 | u32 home_dwell_time, u32 force_scan_interval, |
| 1880 | s8 num_chan, u16 *ch_list) |
| 1881 | { |
| 1882 | struct sk_buff *skb; |
| 1883 | struct wmi_start_scan_cmd *sc; |
| 1884 | s8 size; |
Edward Lu | 1276c9e | 2011-08-30 21:58:00 +0300 | [diff] [blame] | 1885 | int i, ret; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1886 | |
| 1887 | size = sizeof(struct wmi_start_scan_cmd); |
| 1888 | |
| 1889 | if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) |
| 1890 | return -EINVAL; |
| 1891 | |
| 1892 | if (num_chan > WMI_MAX_CHANNELS) |
| 1893 | return -EINVAL; |
| 1894 | |
| 1895 | if (num_chan) |
| 1896 | size += sizeof(u16) * (num_chan - 1); |
| 1897 | |
| 1898 | skb = ath6kl_wmi_get_new_buf(size); |
| 1899 | if (!skb) |
| 1900 | return -ENOMEM; |
| 1901 | |
| 1902 | sc = (struct wmi_start_scan_cmd *) skb->data; |
| 1903 | sc->scan_type = scan_type; |
| 1904 | sc->force_fg_scan = cpu_to_le32(force_fgscan); |
| 1905 | sc->is_legacy = cpu_to_le32(is_legacy); |
| 1906 | sc->home_dwell_time = cpu_to_le32(home_dwell_time); |
| 1907 | sc->force_scan_intvl = cpu_to_le32(force_scan_interval); |
| 1908 | sc->num_ch = num_chan; |
| 1909 | |
Edward Lu | 1276c9e | 2011-08-30 21:58:00 +0300 | [diff] [blame] | 1910 | for (i = 0; i < num_chan; i++) |
| 1911 | sc->ch_list[i] = cpu_to_le16(ch_list[i]); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1912 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1913 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1914 | NO_SYNC_WMIFLAG); |
| 1915 | |
| 1916 | return ret; |
| 1917 | } |
| 1918 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1919 | int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx, |
| 1920 | u16 fg_start_sec, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1921 | u16 fg_end_sec, u16 bg_sec, |
| 1922 | u16 minact_chdw_msec, u16 maxact_chdw_msec, |
| 1923 | u16 pas_chdw_msec, u8 short_scan_ratio, |
| 1924 | u8 scan_ctrl_flag, u32 max_dfsch_act_time, |
| 1925 | u16 maxact_scan_per_ssid) |
| 1926 | { |
| 1927 | struct sk_buff *skb; |
| 1928 | struct wmi_scan_params_cmd *sc; |
| 1929 | int ret; |
| 1930 | |
| 1931 | skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); |
| 1932 | if (!skb) |
| 1933 | return -ENOMEM; |
| 1934 | |
| 1935 | sc = (struct wmi_scan_params_cmd *) skb->data; |
| 1936 | sc->fg_start_period = cpu_to_le16(fg_start_sec); |
| 1937 | sc->fg_end_period = cpu_to_le16(fg_end_sec); |
| 1938 | sc->bg_period = cpu_to_le16(bg_sec); |
| 1939 | sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); |
| 1940 | sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); |
| 1941 | sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); |
| 1942 | sc->short_scan_ratio = short_scan_ratio; |
| 1943 | sc->scan_ctrl_flags = scan_ctrl_flag; |
| 1944 | sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); |
| 1945 | sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); |
| 1946 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1947 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1948 | NO_SYNC_WMIFLAG); |
| 1949 | return ret; |
| 1950 | } |
| 1951 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1952 | int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1953 | { |
| 1954 | struct sk_buff *skb; |
| 1955 | struct wmi_bss_filter_cmd *cmd; |
| 1956 | int ret; |
| 1957 | |
| 1958 | if (filter >= LAST_BSS_FILTER) |
| 1959 | return -EINVAL; |
| 1960 | |
| 1961 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1962 | if (!skb) |
| 1963 | return -ENOMEM; |
| 1964 | |
| 1965 | cmd = (struct wmi_bss_filter_cmd *) skb->data; |
| 1966 | cmd->bss_filter = filter; |
| 1967 | cmd->ie_mask = cpu_to_le32(ie_mask); |
| 1968 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 1969 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1970 | NO_SYNC_WMIFLAG); |
| 1971 | return ret; |
| 1972 | } |
| 1973 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 1974 | int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1975 | u8 ssid_len, u8 *ssid) |
| 1976 | { |
| 1977 | struct sk_buff *skb; |
| 1978 | struct wmi_probed_ssid_cmd *cmd; |
| 1979 | int ret; |
| 1980 | |
| 1981 | if (index > MAX_PROBED_SSID_INDEX) |
| 1982 | return -EINVAL; |
| 1983 | |
| 1984 | if (ssid_len > sizeof(cmd->ssid)) |
| 1985 | return -EINVAL; |
| 1986 | |
| 1987 | if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) |
| 1988 | return -EINVAL; |
| 1989 | |
| 1990 | if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) |
| 1991 | return -EINVAL; |
| 1992 | |
| 1993 | if (flag & SPECIFIC_SSID_FLAG) |
| 1994 | wmi->is_probe_ssid = true; |
| 1995 | |
| 1996 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1997 | if (!skb) |
| 1998 | return -ENOMEM; |
| 1999 | |
| 2000 | cmd = (struct wmi_probed_ssid_cmd *) skb->data; |
| 2001 | cmd->entry_index = index; |
| 2002 | cmd->flag = flag; |
| 2003 | cmd->ssid_len = ssid_len; |
| 2004 | memcpy(cmd->ssid, ssid, ssid_len); |
| 2005 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2006 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2007 | NO_SYNC_WMIFLAG); |
| 2008 | return ret; |
| 2009 | } |
| 2010 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2011 | int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx, |
| 2012 | u16 listen_interval, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2013 | u16 listen_beacons) |
| 2014 | { |
| 2015 | struct sk_buff *skb; |
| 2016 | struct wmi_listen_int_cmd *cmd; |
| 2017 | int ret; |
| 2018 | |
| 2019 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2020 | if (!skb) |
| 2021 | return -ENOMEM; |
| 2022 | |
| 2023 | cmd = (struct wmi_listen_int_cmd *) skb->data; |
| 2024 | cmd->listen_intvl = cpu_to_le16(listen_interval); |
| 2025 | cmd->num_beacons = cpu_to_le16(listen_beacons); |
| 2026 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2027 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2028 | NO_SYNC_WMIFLAG); |
| 2029 | return ret; |
| 2030 | } |
| 2031 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2032 | int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2033 | { |
| 2034 | struct sk_buff *skb; |
| 2035 | struct wmi_power_mode_cmd *cmd; |
| 2036 | int ret; |
| 2037 | |
| 2038 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2039 | if (!skb) |
| 2040 | return -ENOMEM; |
| 2041 | |
| 2042 | cmd = (struct wmi_power_mode_cmd *) skb->data; |
| 2043 | cmd->pwr_mode = pwr_mode; |
| 2044 | wmi->pwr_mode = pwr_mode; |
| 2045 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2046 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2047 | NO_SYNC_WMIFLAG); |
| 2048 | return ret; |
| 2049 | } |
| 2050 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2051 | int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2052 | u16 ps_poll_num, u16 dtim_policy, |
| 2053 | u16 tx_wakeup_policy, u16 num_tx_to_wakeup, |
| 2054 | u16 ps_fail_event_policy) |
| 2055 | { |
| 2056 | struct sk_buff *skb; |
| 2057 | struct wmi_power_params_cmd *pm; |
| 2058 | int ret; |
| 2059 | |
| 2060 | skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); |
| 2061 | if (!skb) |
| 2062 | return -ENOMEM; |
| 2063 | |
| 2064 | pm = (struct wmi_power_params_cmd *)skb->data; |
| 2065 | pm->idle_period = cpu_to_le16(idle_period); |
| 2066 | pm->pspoll_number = cpu_to_le16(ps_poll_num); |
| 2067 | pm->dtim_policy = cpu_to_le16(dtim_policy); |
| 2068 | pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); |
| 2069 | pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); |
| 2070 | pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); |
| 2071 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2072 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2073 | NO_SYNC_WMIFLAG); |
| 2074 | return ret; |
| 2075 | } |
| 2076 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2077 | int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2078 | { |
| 2079 | struct sk_buff *skb; |
| 2080 | struct wmi_disc_timeout_cmd *cmd; |
| 2081 | int ret; |
| 2082 | |
| 2083 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2084 | if (!skb) |
| 2085 | return -ENOMEM; |
| 2086 | |
| 2087 | cmd = (struct wmi_disc_timeout_cmd *) skb->data; |
| 2088 | cmd->discon_timeout = timeout; |
| 2089 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2090 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2091 | NO_SYNC_WMIFLAG); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2092 | |
Jouni Malinen | ff0b007 | 2011-10-11 17:31:56 +0300 | [diff] [blame] | 2093 | if (ret == 0) |
| 2094 | ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2095 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2096 | return ret; |
| 2097 | } |
| 2098 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2099 | int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2100 | enum crypto_type key_type, |
| 2101 | u8 key_usage, u8 key_len, |
Jouni Malinen | f4bb9a6 | 2011-11-02 23:45:55 +0200 | [diff] [blame] | 2102 | u8 *key_rsc, unsigned int key_rsc_len, |
| 2103 | u8 *key_material, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2104 | u8 key_op_ctrl, u8 *mac_addr, |
| 2105 | enum wmi_sync_flag sync_flag) |
| 2106 | { |
| 2107 | struct sk_buff *skb; |
| 2108 | struct wmi_add_cipher_key_cmd *cmd; |
| 2109 | int ret; |
| 2110 | |
Jouni Malinen | 9a5b131 | 2011-08-30 21:57:52 +0300 | [diff] [blame] | 2111 | ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " |
| 2112 | "key_usage=%d key_len=%d key_op_ctrl=%d\n", |
| 2113 | key_index, key_type, key_usage, key_len, key_op_ctrl); |
| 2114 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2115 | if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || |
Jouni Malinen | f4bb9a6 | 2011-11-02 23:45:55 +0200 | [diff] [blame] | 2116 | (key_material == NULL) || key_rsc_len > 8) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2117 | return -EINVAL; |
| 2118 | |
| 2119 | if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) |
| 2120 | return -EINVAL; |
| 2121 | |
| 2122 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2123 | if (!skb) |
| 2124 | return -ENOMEM; |
| 2125 | |
| 2126 | cmd = (struct wmi_add_cipher_key_cmd *) skb->data; |
| 2127 | cmd->key_index = key_index; |
| 2128 | cmd->key_type = key_type; |
| 2129 | cmd->key_usage = key_usage; |
| 2130 | cmd->key_len = key_len; |
| 2131 | memcpy(cmd->key, key_material, key_len); |
| 2132 | |
| 2133 | if (key_rsc != NULL) |
Jouni Malinen | f4bb9a6 | 2011-11-02 23:45:55 +0200 | [diff] [blame] | 2134 | memcpy(cmd->key_rsc, key_rsc, key_rsc_len); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2135 | |
| 2136 | cmd->key_op_ctrl = key_op_ctrl; |
| 2137 | |
| 2138 | if (mac_addr) |
| 2139 | memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); |
| 2140 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2141 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2142 | sync_flag); |
| 2143 | |
| 2144 | return ret; |
| 2145 | } |
| 2146 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2147 | int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2148 | { |
| 2149 | struct sk_buff *skb; |
| 2150 | struct wmi_add_krk_cmd *cmd; |
| 2151 | int ret; |
| 2152 | |
| 2153 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2154 | if (!skb) |
| 2155 | return -ENOMEM; |
| 2156 | |
| 2157 | cmd = (struct wmi_add_krk_cmd *) skb->data; |
| 2158 | memcpy(cmd->krk, krk, WMI_KRK_LEN); |
| 2159 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2160 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID, |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2161 | NO_SYNC_WMIFLAG); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2162 | |
| 2163 | return ret; |
| 2164 | } |
| 2165 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2166 | int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2167 | { |
| 2168 | struct sk_buff *skb; |
| 2169 | struct wmi_delete_cipher_key_cmd *cmd; |
| 2170 | int ret; |
| 2171 | |
| 2172 | if (key_index > WMI_MAX_KEY_INDEX) |
| 2173 | return -EINVAL; |
| 2174 | |
| 2175 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2176 | if (!skb) |
| 2177 | return -ENOMEM; |
| 2178 | |
| 2179 | cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; |
| 2180 | cmd->key_index = key_index; |
| 2181 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2182 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2183 | NO_SYNC_WMIFLAG); |
| 2184 | |
| 2185 | return ret; |
| 2186 | } |
| 2187 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2188 | int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2189 | const u8 *pmkid, bool set) |
| 2190 | { |
| 2191 | struct sk_buff *skb; |
| 2192 | struct wmi_setpmkid_cmd *cmd; |
| 2193 | int ret; |
| 2194 | |
| 2195 | if (bssid == NULL) |
| 2196 | return -EINVAL; |
| 2197 | |
| 2198 | if (set && pmkid == NULL) |
| 2199 | return -EINVAL; |
| 2200 | |
| 2201 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2202 | if (!skb) |
| 2203 | return -ENOMEM; |
| 2204 | |
| 2205 | cmd = (struct wmi_setpmkid_cmd *) skb->data; |
| 2206 | memcpy(cmd->bssid, bssid, ETH_ALEN); |
| 2207 | if (set) { |
| 2208 | memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); |
| 2209 | cmd->enable = PMKID_ENABLE; |
| 2210 | } else { |
| 2211 | memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); |
| 2212 | cmd->enable = PMKID_DISABLE; |
| 2213 | } |
| 2214 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2215 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2216 | NO_SYNC_WMIFLAG); |
| 2217 | |
| 2218 | return ret; |
| 2219 | } |
| 2220 | |
| 2221 | static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, |
Vasanthakumar Thiagarajan | 6765d0a | 2011-10-25 19:34:17 +0530 | [diff] [blame] | 2222 | enum htc_endpoint_id ep_id, u8 if_idx) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2223 | { |
| 2224 | struct wmi_data_hdr *data_hdr; |
| 2225 | int ret; |
| 2226 | |
| 2227 | if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) |
| 2228 | return -EINVAL; |
| 2229 | |
| 2230 | skb_push(skb, sizeof(struct wmi_data_hdr)); |
| 2231 | |
| 2232 | data_hdr = (struct wmi_data_hdr *) skb->data; |
| 2233 | data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; |
Vasanthakumar Thiagarajan | 6765d0a | 2011-10-25 19:34:17 +0530 | [diff] [blame] | 2234 | data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2235 | |
| 2236 | ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); |
| 2237 | |
| 2238 | return ret; |
| 2239 | } |
| 2240 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2241 | static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2242 | { |
| 2243 | struct sk_buff *skb; |
| 2244 | struct wmi_sync_cmd *cmd; |
| 2245 | struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; |
| 2246 | enum htc_endpoint_id ep_id; |
| 2247 | u8 index, num_pri_streams = 0; |
| 2248 | int ret = 0; |
| 2249 | |
| 2250 | memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); |
| 2251 | |
| 2252 | spin_lock_bh(&wmi->lock); |
| 2253 | |
| 2254 | for (index = 0; index < WMM_NUM_AC; index++) { |
| 2255 | if (wmi->fat_pipe_exist & (1 << index)) { |
| 2256 | num_pri_streams++; |
| 2257 | data_sync_bufs[num_pri_streams - 1].traffic_class = |
| 2258 | index; |
| 2259 | } |
| 2260 | } |
| 2261 | |
| 2262 | spin_unlock_bh(&wmi->lock); |
| 2263 | |
| 2264 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2265 | if (!skb) { |
| 2266 | ret = -ENOMEM; |
| 2267 | goto free_skb; |
| 2268 | } |
| 2269 | |
| 2270 | cmd = (struct wmi_sync_cmd *) skb->data; |
| 2271 | |
| 2272 | /* |
| 2273 | * In the SYNC cmd sent on the control Ep, send a bitmap |
| 2274 | * of the data eps on which the Data Sync will be sent |
| 2275 | */ |
| 2276 | cmd->data_sync_map = wmi->fat_pipe_exist; |
| 2277 | |
| 2278 | for (index = 0; index < num_pri_streams; index++) { |
| 2279 | data_sync_bufs[index].skb = ath6kl_buf_alloc(0); |
| 2280 | if (data_sync_bufs[index].skb == NULL) { |
| 2281 | ret = -ENOMEM; |
| 2282 | break; |
| 2283 | } |
| 2284 | } |
| 2285 | |
| 2286 | /* |
| 2287 | * If buffer allocation for any of the dataSync fails, |
| 2288 | * then do not send the Synchronize cmd on the control ep |
| 2289 | */ |
| 2290 | if (ret) |
| 2291 | goto free_skb; |
| 2292 | |
| 2293 | /* |
| 2294 | * Send sync cmd followed by sync data messages on all |
| 2295 | * endpoints being used |
| 2296 | */ |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2297 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2298 | NO_SYNC_WMIFLAG); |
| 2299 | |
| 2300 | if (ret) |
| 2301 | goto free_skb; |
| 2302 | |
| 2303 | /* cmd buffer sent, we no longer own it */ |
| 2304 | skb = NULL; |
| 2305 | |
| 2306 | for (index = 0; index < num_pri_streams; index++) { |
| 2307 | |
| 2308 | if (WARN_ON(!data_sync_bufs[index].skb)) |
| 2309 | break; |
| 2310 | |
| 2311 | ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, |
| 2312 | data_sync_bufs[index]. |
| 2313 | traffic_class); |
| 2314 | ret = |
| 2315 | ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, |
Vasanthakumar Thiagarajan | 6765d0a | 2011-10-25 19:34:17 +0530 | [diff] [blame] | 2316 | ep_id, if_idx); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2317 | |
| 2318 | if (ret) |
| 2319 | break; |
| 2320 | |
| 2321 | data_sync_bufs[index].skb = NULL; |
| 2322 | } |
| 2323 | |
| 2324 | free_skb: |
| 2325 | /* free up any resources left over (possibly due to an error) */ |
| 2326 | if (skb) |
| 2327 | dev_kfree_skb(skb); |
| 2328 | |
| 2329 | for (index = 0; index < num_pri_streams; index++) { |
| 2330 | if (data_sync_bufs[index].skb != NULL) { |
| 2331 | dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. |
| 2332 | skb); |
| 2333 | } |
| 2334 | } |
| 2335 | |
| 2336 | return ret; |
| 2337 | } |
| 2338 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2339 | int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2340 | struct wmi_create_pstream_cmd *params) |
| 2341 | { |
| 2342 | struct sk_buff *skb; |
| 2343 | struct wmi_create_pstream_cmd *cmd; |
| 2344 | u8 fatpipe_exist_for_ac = 0; |
| 2345 | s32 min_phy = 0; |
| 2346 | s32 nominal_phy = 0; |
| 2347 | int ret; |
| 2348 | |
| 2349 | if (!((params->user_pri < 8) && |
| 2350 | (params->user_pri <= 0x7) && |
| 2351 | (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && |
| 2352 | (params->traffic_direc == UPLINK_TRAFFIC || |
| 2353 | params->traffic_direc == DNLINK_TRAFFIC || |
| 2354 | params->traffic_direc == BIDIR_TRAFFIC) && |
| 2355 | (params->traffic_type == TRAFFIC_TYPE_APERIODIC || |
| 2356 | params->traffic_type == TRAFFIC_TYPE_PERIODIC) && |
| 2357 | (params->voice_psc_cap == DISABLE_FOR_THIS_AC || |
| 2358 | params->voice_psc_cap == ENABLE_FOR_THIS_AC || |
| 2359 | params->voice_psc_cap == ENABLE_FOR_ALL_AC) && |
| 2360 | (params->tsid == WMI_IMPLICIT_PSTREAM || |
| 2361 | params->tsid <= WMI_MAX_THINSTREAM))) { |
| 2362 | return -EINVAL; |
| 2363 | } |
| 2364 | |
| 2365 | /* |
| 2366 | * Check nominal PHY rate is >= minimalPHY, |
| 2367 | * so that DUT can allow TSRS IE |
| 2368 | */ |
| 2369 | |
| 2370 | /* Get the physical rate (units of bps) */ |
| 2371 | min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); |
| 2372 | |
| 2373 | /* Check minimal phy < nominal phy rate */ |
| 2374 | if (params->nominal_phy >= min_phy) { |
| 2375 | /* unit of 500 kbps */ |
| 2376 | nominal_phy = (params->nominal_phy * 1000) / 500; |
| 2377 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2378 | "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", |
| 2379 | min_phy, nominal_phy); |
| 2380 | |
| 2381 | params->nominal_phy = nominal_phy; |
| 2382 | } else { |
| 2383 | params->nominal_phy = 0; |
| 2384 | } |
| 2385 | |
| 2386 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2387 | if (!skb) |
| 2388 | return -ENOMEM; |
| 2389 | |
| 2390 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2391 | "sending create_pstream_cmd: ac=%d tsid:%d\n", |
| 2392 | params->traffic_class, params->tsid); |
| 2393 | |
| 2394 | cmd = (struct wmi_create_pstream_cmd *) skb->data; |
| 2395 | memcpy(cmd, params, sizeof(*cmd)); |
| 2396 | |
| 2397 | /* This is an implicitly created Fat pipe */ |
| 2398 | if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { |
| 2399 | spin_lock_bh(&wmi->lock); |
| 2400 | fatpipe_exist_for_ac = (wmi->fat_pipe_exist & |
| 2401 | (1 << params->traffic_class)); |
| 2402 | wmi->fat_pipe_exist |= (1 << params->traffic_class); |
| 2403 | spin_unlock_bh(&wmi->lock); |
| 2404 | } else { |
| 2405 | /* explicitly created thin stream within a fat pipe */ |
| 2406 | spin_lock_bh(&wmi->lock); |
| 2407 | fatpipe_exist_for_ac = (wmi->fat_pipe_exist & |
| 2408 | (1 << params->traffic_class)); |
| 2409 | wmi->stream_exist_for_ac[params->traffic_class] |= |
| 2410 | (1 << params->tsid); |
| 2411 | /* |
| 2412 | * If a thinstream becomes active, the fat pipe automatically |
| 2413 | * becomes active |
| 2414 | */ |
| 2415 | wmi->fat_pipe_exist |= (1 << params->traffic_class); |
| 2416 | spin_unlock_bh(&wmi->lock); |
| 2417 | } |
| 2418 | |
| 2419 | /* |
| 2420 | * Indicate activty change to driver layer only if this is the |
| 2421 | * first TSID to get created in this AC explicitly or an implicit |
| 2422 | * fat pipe is getting created. |
| 2423 | */ |
| 2424 | if (!fatpipe_exist_for_ac) |
| 2425 | ath6kl_indicate_tx_activity(wmi->parent_dev, |
| 2426 | params->traffic_class, true); |
| 2427 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2428 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2429 | NO_SYNC_WMIFLAG); |
| 2430 | return ret; |
| 2431 | } |
| 2432 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2433 | int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class, |
| 2434 | u8 tsid) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2435 | { |
| 2436 | struct sk_buff *skb; |
| 2437 | struct wmi_delete_pstream_cmd *cmd; |
| 2438 | u16 active_tsids = 0; |
| 2439 | int ret; |
| 2440 | |
| 2441 | if (traffic_class > 3) { |
| 2442 | ath6kl_err("invalid traffic class: %d\n", traffic_class); |
| 2443 | return -EINVAL; |
| 2444 | } |
| 2445 | |
| 2446 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2447 | if (!skb) |
| 2448 | return -ENOMEM; |
| 2449 | |
| 2450 | cmd = (struct wmi_delete_pstream_cmd *) skb->data; |
| 2451 | cmd->traffic_class = traffic_class; |
| 2452 | cmd->tsid = tsid; |
| 2453 | |
| 2454 | spin_lock_bh(&wmi->lock); |
| 2455 | active_tsids = wmi->stream_exist_for_ac[traffic_class]; |
| 2456 | spin_unlock_bh(&wmi->lock); |
| 2457 | |
| 2458 | if (!(active_tsids & (1 << tsid))) { |
| 2459 | dev_kfree_skb(skb); |
| 2460 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2461 | "TSID %d doesn't exist for traffic class: %d\n", |
| 2462 | tsid, traffic_class); |
| 2463 | return -ENODATA; |
| 2464 | } |
| 2465 | |
| 2466 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2467 | "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", |
| 2468 | traffic_class, tsid); |
| 2469 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2470 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2471 | SYNC_BEFORE_WMIFLAG); |
| 2472 | |
| 2473 | spin_lock_bh(&wmi->lock); |
| 2474 | wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); |
| 2475 | active_tsids = wmi->stream_exist_for_ac[traffic_class]; |
| 2476 | spin_unlock_bh(&wmi->lock); |
| 2477 | |
| 2478 | /* |
| 2479 | * Indicate stream inactivity to driver layer only if all tsids |
| 2480 | * within this AC are deleted. |
| 2481 | */ |
| 2482 | if (!active_tsids) { |
| 2483 | ath6kl_indicate_tx_activity(wmi->parent_dev, |
| 2484 | traffic_class, false); |
| 2485 | wmi->fat_pipe_exist &= ~(1 << traffic_class); |
| 2486 | } |
| 2487 | |
| 2488 | return ret; |
| 2489 | } |
| 2490 | |
Raja Mani | ca1d16a | 2011-12-16 14:24:23 +0530 | [diff] [blame] | 2491 | int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx, |
| 2492 | __be32 ips0, __be32 ips1) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2493 | { |
| 2494 | struct sk_buff *skb; |
| 2495 | struct wmi_set_ip_cmd *cmd; |
| 2496 | int ret; |
| 2497 | |
| 2498 | /* Multicast address are not valid */ |
Raja Mani | ca1d16a | 2011-12-16 14:24:23 +0530 | [diff] [blame] | 2499 | if (ipv4_is_multicast(ips0) || |
| 2500 | ipv4_is_multicast(ips1)) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2501 | return -EINVAL; |
| 2502 | |
| 2503 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); |
| 2504 | if (!skb) |
| 2505 | return -ENOMEM; |
| 2506 | |
| 2507 | cmd = (struct wmi_set_ip_cmd *) skb->data; |
Raja Mani | ca1d16a | 2011-12-16 14:24:23 +0530 | [diff] [blame] | 2508 | cmd->ips[0] = ips0; |
| 2509 | cmd->ips[1] = ips1; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2510 | |
Raja Mani | ca1d16a | 2011-12-16 14:24:23 +0530 | [diff] [blame] | 2511 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IP_CMDID, |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2512 | NO_SYNC_WMIFLAG); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2513 | return ret; |
| 2514 | } |
| 2515 | |
Raja Mani | 45cf110 | 2011-11-07 22:52:45 +0200 | [diff] [blame] | 2516 | static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi) |
| 2517 | { |
| 2518 | u16 active_tsids; |
| 2519 | u8 stream_exist; |
| 2520 | int i; |
| 2521 | |
| 2522 | /* |
| 2523 | * Relinquish credits from all implicitly created pstreams |
| 2524 | * since when we go to sleep. If user created explicit |
| 2525 | * thinstreams exists with in a fatpipe leave them intact |
| 2526 | * for the user to delete. |
| 2527 | */ |
| 2528 | spin_lock_bh(&wmi->lock); |
| 2529 | stream_exist = wmi->fat_pipe_exist; |
| 2530 | spin_unlock_bh(&wmi->lock); |
| 2531 | |
| 2532 | for (i = 0; i < WMM_NUM_AC; i++) { |
| 2533 | if (stream_exist & (1 << i)) { |
| 2534 | |
| 2535 | /* |
| 2536 | * FIXME: Is this lock & unlock inside |
| 2537 | * for loop correct? may need rework. |
| 2538 | */ |
| 2539 | spin_lock_bh(&wmi->lock); |
| 2540 | active_tsids = wmi->stream_exist_for_ac[i]; |
| 2541 | spin_unlock_bh(&wmi->lock); |
| 2542 | |
| 2543 | /* |
| 2544 | * If there are no user created thin streams |
| 2545 | * delete the fatpipe |
| 2546 | */ |
| 2547 | if (!active_tsids) { |
| 2548 | stream_exist &= ~(1 << i); |
| 2549 | /* |
| 2550 | * Indicate inactivity to driver layer for |
| 2551 | * this fatpipe (pstream) |
| 2552 | */ |
| 2553 | ath6kl_indicate_tx_activity(wmi->parent_dev, |
| 2554 | i, false); |
| 2555 | } |
| 2556 | } |
| 2557 | } |
| 2558 | |
| 2559 | /* FIXME: Can we do this assignment without locking ? */ |
| 2560 | spin_lock_bh(&wmi->lock); |
| 2561 | wmi->fat_pipe_exist = stream_exist; |
| 2562 | spin_unlock_bh(&wmi->lock); |
| 2563 | } |
| 2564 | |
| 2565 | int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx, |
| 2566 | enum ath6kl_host_mode host_mode) |
| 2567 | { |
| 2568 | struct sk_buff *skb; |
| 2569 | struct wmi_set_host_sleep_mode_cmd *cmd; |
| 2570 | int ret; |
| 2571 | |
| 2572 | if ((host_mode != ATH6KL_HOST_MODE_ASLEEP) && |
| 2573 | (host_mode != ATH6KL_HOST_MODE_AWAKE)) { |
| 2574 | ath6kl_err("invalid host sleep mode: %d\n", host_mode); |
| 2575 | return -EINVAL; |
| 2576 | } |
| 2577 | |
| 2578 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2579 | if (!skb) |
| 2580 | return -ENOMEM; |
| 2581 | |
| 2582 | cmd = (struct wmi_set_host_sleep_mode_cmd *) skb->data; |
| 2583 | |
| 2584 | if (host_mode == ATH6KL_HOST_MODE_ASLEEP) { |
| 2585 | ath6kl_wmi_relinquish_implicit_pstream_credits(wmi); |
| 2586 | cmd->asleep = cpu_to_le32(1); |
| 2587 | } else |
| 2588 | cmd->awake = cpu_to_le32(1); |
| 2589 | |
| 2590 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, |
| 2591 | WMI_SET_HOST_SLEEP_MODE_CMDID, |
| 2592 | NO_SYNC_WMIFLAG); |
| 2593 | return ret; |
| 2594 | } |
| 2595 | |
| 2596 | int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx, |
| 2597 | enum ath6kl_wow_mode wow_mode, |
| 2598 | u32 filter, u16 host_req_delay) |
| 2599 | { |
| 2600 | struct sk_buff *skb; |
| 2601 | struct wmi_set_wow_mode_cmd *cmd; |
| 2602 | int ret; |
| 2603 | |
| 2604 | if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) && |
| 2605 | wow_mode != ATH6KL_WOW_MODE_DISABLE) { |
| 2606 | ath6kl_err("invalid wow mode: %d\n", wow_mode); |
| 2607 | return -EINVAL; |
| 2608 | } |
| 2609 | |
| 2610 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2611 | if (!skb) |
| 2612 | return -ENOMEM; |
| 2613 | |
| 2614 | cmd = (struct wmi_set_wow_mode_cmd *) skb->data; |
| 2615 | cmd->enable_wow = cpu_to_le32(wow_mode); |
| 2616 | cmd->filter = cpu_to_le32(filter); |
| 2617 | cmd->host_req_delay = cpu_to_le16(host_req_delay); |
| 2618 | |
| 2619 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WOW_MODE_CMDID, |
| 2620 | NO_SYNC_WMIFLAG); |
| 2621 | return ret; |
| 2622 | } |
| 2623 | |
Raja Mani | 5c9b4fa | 2011-11-07 22:52:45 +0200 | [diff] [blame] | 2624 | int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, |
| 2625 | u8 list_id, u8 filter_size, |
| 2626 | u8 filter_offset, u8 *filter, u8 *mask) |
| 2627 | { |
| 2628 | struct sk_buff *skb; |
| 2629 | struct wmi_add_wow_pattern_cmd *cmd; |
| 2630 | u16 size; |
| 2631 | u8 *filter_mask; |
| 2632 | int ret; |
| 2633 | |
| 2634 | /* |
| 2635 | * Allocate additional memory in the buffer to hold |
| 2636 | * filter and mask value, which is twice of filter_size. |
| 2637 | */ |
| 2638 | size = sizeof(*cmd) + (2 * filter_size); |
| 2639 | |
| 2640 | skb = ath6kl_wmi_get_new_buf(size); |
| 2641 | if (!skb) |
| 2642 | return -ENOMEM; |
| 2643 | |
| 2644 | cmd = (struct wmi_add_wow_pattern_cmd *) skb->data; |
| 2645 | cmd->filter_list_id = list_id; |
| 2646 | cmd->filter_size = filter_size; |
| 2647 | cmd->filter_offset = filter_offset; |
| 2648 | |
| 2649 | memcpy(cmd->filter, filter, filter_size); |
| 2650 | |
| 2651 | filter_mask = (u8 *) (cmd->filter + filter_size); |
| 2652 | memcpy(filter_mask, mask, filter_size); |
| 2653 | |
| 2654 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_WOW_PATTERN_CMDID, |
| 2655 | NO_SYNC_WMIFLAG); |
| 2656 | |
| 2657 | return ret; |
| 2658 | } |
| 2659 | |
| 2660 | int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx, |
| 2661 | u16 list_id, u16 filter_id) |
| 2662 | { |
| 2663 | struct sk_buff *skb; |
| 2664 | struct wmi_del_wow_pattern_cmd *cmd; |
| 2665 | int ret; |
| 2666 | |
| 2667 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2668 | if (!skb) |
| 2669 | return -ENOMEM; |
| 2670 | |
| 2671 | cmd = (struct wmi_del_wow_pattern_cmd *) skb->data; |
| 2672 | cmd->filter_list_id = cpu_to_le16(list_id); |
| 2673 | cmd->filter_id = cpu_to_le16(filter_id); |
| 2674 | |
| 2675 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DEL_WOW_PATTERN_CMDID, |
| 2676 | NO_SYNC_WMIFLAG); |
| 2677 | return ret; |
| 2678 | } |
| 2679 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2680 | static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, |
| 2681 | enum wmix_command_id cmd_id, |
| 2682 | enum wmi_sync_flag sync_flag) |
| 2683 | { |
| 2684 | struct wmix_cmd_hdr *cmd_hdr; |
| 2685 | int ret; |
| 2686 | |
| 2687 | skb_push(skb, sizeof(struct wmix_cmd_hdr)); |
| 2688 | |
| 2689 | cmd_hdr = (struct wmix_cmd_hdr *) skb->data; |
| 2690 | cmd_hdr->cmd_id = cpu_to_le32(cmd_id); |
| 2691 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2692 | ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2693 | |
| 2694 | return ret; |
| 2695 | } |
| 2696 | |
| 2697 | int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) |
| 2698 | { |
| 2699 | struct sk_buff *skb; |
| 2700 | struct wmix_hb_challenge_resp_cmd *cmd; |
| 2701 | int ret; |
| 2702 | |
| 2703 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2704 | if (!skb) |
| 2705 | return -ENOMEM; |
| 2706 | |
| 2707 | cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; |
| 2708 | cmd->cookie = cpu_to_le32(cookie); |
| 2709 | cmd->source = cpu_to_le32(source); |
| 2710 | |
| 2711 | ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, |
| 2712 | NO_SYNC_WMIFLAG); |
| 2713 | return ret; |
| 2714 | } |
| 2715 | |
Kalle Valo | 939f1cc | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 2716 | int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config) |
| 2717 | { |
| 2718 | struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd; |
| 2719 | struct sk_buff *skb; |
| 2720 | int ret; |
| 2721 | |
| 2722 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2723 | if (!skb) |
| 2724 | return -ENOMEM; |
| 2725 | |
| 2726 | cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data; |
| 2727 | cmd->valid = cpu_to_le32(valid); |
| 2728 | cmd->config = cpu_to_le32(config); |
| 2729 | |
| 2730 | ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID, |
| 2731 | NO_SYNC_WMIFLAG); |
| 2732 | return ret; |
| 2733 | } |
| 2734 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2735 | int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2736 | { |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2737 | return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2738 | } |
| 2739 | |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 2740 | int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2741 | { |
| 2742 | struct sk_buff *skb; |
| 2743 | struct wmi_set_tx_pwr_cmd *cmd; |
| 2744 | int ret; |
| 2745 | |
| 2746 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); |
| 2747 | if (!skb) |
| 2748 | return -ENOMEM; |
| 2749 | |
| 2750 | cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; |
| 2751 | cmd->dbM = dbM; |
| 2752 | |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 2753 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2754 | NO_SYNC_WMIFLAG); |
| 2755 | |
| 2756 | return ret; |
| 2757 | } |
| 2758 | |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 2759 | int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2760 | { |
Vasanthakumar Thiagarajan | 990bd91 | 2011-10-25 19:34:20 +0530 | [diff] [blame] | 2761 | return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2762 | } |
| 2763 | |
Jouni Malinen | 4b28a80 | 2011-10-11 17:31:54 +0300 | [diff] [blame] | 2764 | int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi) |
| 2765 | { |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2766 | return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID); |
Jouni Malinen | 4b28a80 | 2011-10-11 17:31:54 +0300 | [diff] [blame] | 2767 | } |
| 2768 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2769 | int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status, |
| 2770 | u8 preamble_policy) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2771 | { |
| 2772 | struct sk_buff *skb; |
| 2773 | struct wmi_set_lpreamble_cmd *cmd; |
| 2774 | int ret; |
| 2775 | |
| 2776 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); |
| 2777 | if (!skb) |
| 2778 | return -ENOMEM; |
| 2779 | |
| 2780 | cmd = (struct wmi_set_lpreamble_cmd *) skb->data; |
| 2781 | cmd->status = status; |
| 2782 | cmd->preamble_policy = preamble_policy; |
| 2783 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2784 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2785 | NO_SYNC_WMIFLAG); |
| 2786 | return ret; |
| 2787 | } |
| 2788 | |
| 2789 | int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) |
| 2790 | { |
| 2791 | struct sk_buff *skb; |
| 2792 | struct wmi_set_rts_cmd *cmd; |
| 2793 | int ret; |
| 2794 | |
| 2795 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); |
| 2796 | if (!skb) |
| 2797 | return -ENOMEM; |
| 2798 | |
| 2799 | cmd = (struct wmi_set_rts_cmd *) skb->data; |
| 2800 | cmd->threshold = cpu_to_le16(threshold); |
| 2801 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2802 | ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID, |
| 2803 | NO_SYNC_WMIFLAG); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2804 | return ret; |
| 2805 | } |
| 2806 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2807 | int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2808 | { |
| 2809 | struct sk_buff *skb; |
| 2810 | struct wmi_set_wmm_txop_cmd *cmd; |
| 2811 | int ret; |
| 2812 | |
| 2813 | if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) |
| 2814 | return -EINVAL; |
| 2815 | |
| 2816 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); |
| 2817 | if (!skb) |
| 2818 | return -ENOMEM; |
| 2819 | |
| 2820 | cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; |
| 2821 | cmd->txop_enable = cfg; |
| 2822 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2823 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2824 | NO_SYNC_WMIFLAG); |
| 2825 | return ret; |
| 2826 | } |
| 2827 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2828 | int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx, |
| 2829 | u8 keep_alive_intvl) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2830 | { |
| 2831 | struct sk_buff *skb; |
| 2832 | struct wmi_set_keepalive_cmd *cmd; |
| 2833 | int ret; |
| 2834 | |
| 2835 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2836 | if (!skb) |
| 2837 | return -ENOMEM; |
| 2838 | |
| 2839 | cmd = (struct wmi_set_keepalive_cmd *) skb->data; |
| 2840 | cmd->keep_alive_intvl = keep_alive_intvl; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2841 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 2842 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2843 | NO_SYNC_WMIFLAG); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2844 | |
Jouni Malinen | ff0b007 | 2011-10-11 17:31:56 +0300 | [diff] [blame] | 2845 | if (ret == 0) |
| 2846 | ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2847 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2848 | return ret; |
| 2849 | } |
| 2850 | |
Kalle Valo | 003353b0d | 2011-09-01 10:14:21 +0300 | [diff] [blame] | 2851 | int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len) |
| 2852 | { |
| 2853 | struct sk_buff *skb; |
| 2854 | int ret; |
| 2855 | |
| 2856 | skb = ath6kl_wmi_get_new_buf(len); |
| 2857 | if (!skb) |
| 2858 | return -ENOMEM; |
| 2859 | |
| 2860 | memcpy(skb->data, buf, len); |
| 2861 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2862 | ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG); |
Kalle Valo | 003353b0d | 2011-09-01 10:14:21 +0300 | [diff] [blame] | 2863 | |
| 2864 | return ret; |
| 2865 | } |
| 2866 | |
Vasanthakumar Thiagarajan | 3f3c4ee | 2012-01-03 14:41:59 +0530 | [diff] [blame] | 2867 | int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on) |
| 2868 | { |
| 2869 | struct sk_buff *skb; |
| 2870 | struct wmi_mcast_filter_cmd *cmd; |
| 2871 | int ret; |
| 2872 | |
| 2873 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2874 | if (!skb) |
| 2875 | return -ENOMEM; |
| 2876 | |
| 2877 | cmd = (struct wmi_mcast_filter_cmd *) skb->data; |
| 2878 | cmd->mcast_all_enable = mc_all_on; |
| 2879 | |
| 2880 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_MCAST_FILTER_CMDID, |
| 2881 | NO_SYNC_WMIFLAG); |
| 2882 | return ret; |
| 2883 | } |
Kalle Valo | 003353b0d | 2011-09-01 10:14:21 +0300 | [diff] [blame] | 2884 | |
Vasanthakumar Thiagarajan | f914edd | 2012-01-03 14:42:00 +0530 | [diff] [blame] | 2885 | int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, |
| 2886 | u8 *filter, bool add_filter) |
| 2887 | { |
| 2888 | struct sk_buff *skb; |
| 2889 | struct wmi_mcast_filter_add_del_cmd *cmd; |
| 2890 | int ret; |
| 2891 | |
| 2892 | if ((filter[0] != 0x33 || filter[1] != 0x33) && |
| 2893 | (filter[0] != 0x01 || filter[1] != 0x00 || |
| 2894 | filter[2] != 0x5e || filter[3] > 0x7f)) { |
| 2895 | ath6kl_warn("invalid multicast filter address\n"); |
| 2896 | return -EINVAL; |
| 2897 | } |
| 2898 | |
| 2899 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2900 | if (!skb) |
| 2901 | return -ENOMEM; |
| 2902 | |
| 2903 | cmd = (struct wmi_mcast_filter_add_del_cmd *) skb->data; |
| 2904 | memcpy(cmd->mcast_mac, filter, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE); |
| 2905 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, |
| 2906 | add_filter ? WMI_SET_MCAST_FILTER_CMDID : |
| 2907 | WMI_DEL_MCAST_FILTER_CMDID, |
| 2908 | NO_SYNC_WMIFLAG); |
| 2909 | |
| 2910 | return ret; |
| 2911 | } |
| 2912 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2913 | s32 ath6kl_wmi_get_rate(s8 rate_index) |
| 2914 | { |
| 2915 | if (rate_index == RATE_AUTO) |
| 2916 | return 0; |
| 2917 | |
| 2918 | return wmi_rate_tbl[(u32) rate_index][0]; |
| 2919 | } |
| 2920 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2921 | static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, |
| 2922 | u32 len) |
| 2923 | { |
| 2924 | struct wmi_pmkid_list_reply *reply; |
| 2925 | u32 expected_len; |
| 2926 | |
| 2927 | if (len < sizeof(struct wmi_pmkid_list_reply)) |
| 2928 | return -EINVAL; |
| 2929 | |
| 2930 | reply = (struct wmi_pmkid_list_reply *)datap; |
| 2931 | expected_len = sizeof(reply->num_pmkid) + |
| 2932 | le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; |
| 2933 | |
| 2934 | if (len < expected_len) |
| 2935 | return -EINVAL; |
| 2936 | |
| 2937 | return 0; |
| 2938 | } |
| 2939 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2940 | static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 2941 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2942 | { |
| 2943 | struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; |
| 2944 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2945 | aggr_recv_addba_req_evt(vif, cmd->tid, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2946 | le16_to_cpu(cmd->st_seq_no), cmd->win_sz); |
| 2947 | |
| 2948 | return 0; |
| 2949 | } |
| 2950 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2951 | static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 2952 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2953 | { |
| 2954 | struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; |
| 2955 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 2956 | aggr_recv_delba_req_evt(vif, cmd->tid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2957 | |
| 2958 | return 0; |
| 2959 | } |
| 2960 | |
| 2961 | /* AP mode functions */ |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 2962 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2963 | int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx, |
| 2964 | struct wmi_connect_cmd *p) |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 2965 | { |
| 2966 | struct sk_buff *skb; |
| 2967 | struct wmi_connect_cmd *cm; |
| 2968 | int res; |
| 2969 | |
| 2970 | skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); |
| 2971 | if (!skb) |
| 2972 | return -ENOMEM; |
| 2973 | |
| 2974 | cm = (struct wmi_connect_cmd *) skb->data; |
| 2975 | memcpy(cm, p, sizeof(*cm)); |
| 2976 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2977 | res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID, |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 2978 | NO_SYNC_WMIFLAG); |
| 2979 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " |
| 2980 | "ctrl_flags=0x%x-> res=%d\n", |
| 2981 | __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), |
| 2982 | le32_to_cpu(p->ctrl_flags), res); |
| 2983 | return res; |
| 2984 | } |
| 2985 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 2986 | int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac, |
| 2987 | u16 reason) |
Jouni Malinen | 2387513 | 2011-08-30 21:57:53 +0300 | [diff] [blame] | 2988 | { |
| 2989 | struct sk_buff *skb; |
| 2990 | struct wmi_ap_set_mlme_cmd *cm; |
| 2991 | |
| 2992 | skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); |
| 2993 | if (!skb) |
| 2994 | return -ENOMEM; |
| 2995 | |
| 2996 | cm = (struct wmi_ap_set_mlme_cmd *) skb->data; |
| 2997 | memcpy(cm->mac, mac, ETH_ALEN); |
| 2998 | cm->reason = cpu_to_le16(reason); |
| 2999 | cm->cmd = cmd; |
| 3000 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3001 | return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID, |
Jouni Malinen | 2387513 | 2011-08-30 21:57:53 +0300 | [diff] [blame] | 3002 | NO_SYNC_WMIFLAG); |
| 3003 | } |
| 3004 | |
Thirumalai Pachamuthu | c1762a3 | 2012-01-12 18:21:39 +0530 | [diff] [blame^] | 3005 | /* This command will be used to enable/disable AP uAPSD feature */ |
| 3006 | int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable) |
| 3007 | { |
| 3008 | struct wmi_ap_set_apsd_cmd *cmd; |
| 3009 | struct sk_buff *skb; |
| 3010 | |
| 3011 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 3012 | if (!skb) |
| 3013 | return -ENOMEM; |
| 3014 | |
| 3015 | cmd = (struct wmi_ap_set_apsd_cmd *)skb->data; |
| 3016 | cmd->enable = enable; |
| 3017 | |
| 3018 | return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_APSD_CMDID, |
| 3019 | NO_SYNC_WMIFLAG); |
| 3020 | } |
| 3021 | |
| 3022 | int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, u8 if_idx, |
| 3023 | u16 aid, u16 bitmap, u32 flags) |
| 3024 | { |
| 3025 | struct wmi_ap_apsd_buffered_traffic_cmd *cmd; |
| 3026 | struct sk_buff *skb; |
| 3027 | |
| 3028 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 3029 | if (!skb) |
| 3030 | return -ENOMEM; |
| 3031 | |
| 3032 | cmd = (struct wmi_ap_apsd_buffered_traffic_cmd *)skb->data; |
| 3033 | cmd->aid = cpu_to_le16(aid); |
| 3034 | cmd->bitmap = cpu_to_le16(bitmap); |
| 3035 | cmd->flags = cpu_to_le32(flags); |
| 3036 | |
| 3037 | return ath6kl_wmi_cmd_send(wmi, if_idx, skb, |
| 3038 | WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID, |
| 3039 | NO_SYNC_WMIFLAG); |
| 3040 | } |
| 3041 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3042 | static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 3043 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3044 | { |
| 3045 | struct wmi_pspoll_event *ev; |
| 3046 | |
| 3047 | if (len < sizeof(struct wmi_pspoll_event)) |
| 3048 | return -EINVAL; |
| 3049 | |
| 3050 | ev = (struct wmi_pspoll_event *) datap; |
| 3051 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3052 | ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid)); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3053 | |
| 3054 | return 0; |
| 3055 | } |
| 3056 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3057 | static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len, |
| 3058 | struct ath6kl_vif *vif) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3059 | { |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3060 | ath6kl_dtimexpiry_event(vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3061 | |
| 3062 | return 0; |
| 3063 | } |
| 3064 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3065 | int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid, |
| 3066 | bool flag) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3067 | { |
| 3068 | struct sk_buff *skb; |
| 3069 | struct wmi_ap_set_pvb_cmd *cmd; |
| 3070 | int ret; |
| 3071 | |
| 3072 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); |
| 3073 | if (!skb) |
| 3074 | return -ENOMEM; |
| 3075 | |
| 3076 | cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; |
| 3077 | cmd->aid = cpu_to_le16(aid); |
Jouni Malinen | d6e51e6 | 2011-09-05 17:38:44 +0300 | [diff] [blame] | 3078 | cmd->rsvd = cpu_to_le16(0); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3079 | cmd->flag = cpu_to_le32(flag); |
| 3080 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3081 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3082 | NO_SYNC_WMIFLAG); |
| 3083 | |
| 3084 | return 0; |
| 3085 | } |
| 3086 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 3087 | int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx, |
| 3088 | u8 rx_meta_ver, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3089 | bool rx_dot11_hdr, bool defrag_on_host) |
| 3090 | { |
| 3091 | struct sk_buff *skb; |
| 3092 | struct wmi_rx_frame_format_cmd *cmd; |
| 3093 | int ret; |
| 3094 | |
| 3095 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 3096 | if (!skb) |
| 3097 | return -ENOMEM; |
| 3098 | |
| 3099 | cmd = (struct wmi_rx_frame_format_cmd *) skb->data; |
| 3100 | cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; |
| 3101 | cmd->defrag_on_host = defrag_on_host ? 1 : 0; |
| 3102 | cmd->meta_ver = rx_meta_ver; |
| 3103 | |
| 3104 | /* Delete the local aggr state, on host */ |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 3105 | ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3106 | NO_SYNC_WMIFLAG); |
| 3107 | |
| 3108 | return ret; |
| 3109 | } |
| 3110 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3111 | int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type, |
| 3112 | const u8 *ie, u8 ie_len) |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 3113 | { |
| 3114 | struct sk_buff *skb; |
| 3115 | struct wmi_set_appie_cmd *p; |
| 3116 | |
| 3117 | skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); |
| 3118 | if (!skb) |
| 3119 | return -ENOMEM; |
| 3120 | |
| 3121 | ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " |
| 3122 | "ie_len=%u\n", mgmt_frm_type, ie_len); |
| 3123 | p = (struct wmi_set_appie_cmd *) skb->data; |
| 3124 | p->mgmt_frm_type = mgmt_frm_type; |
| 3125 | p->ie_len = ie_len; |
Kalle Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 3126 | |
| 3127 | if (ie != NULL && ie_len > 0) |
| 3128 | memcpy(p->ie_info, ie, ie_len); |
| 3129 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3130 | return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID, |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 3131 | NO_SYNC_WMIFLAG); |
| 3132 | } |
| 3133 | |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3134 | int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) |
| 3135 | { |
| 3136 | struct sk_buff *skb; |
| 3137 | struct wmi_disable_11b_rates_cmd *cmd; |
| 3138 | |
| 3139 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 3140 | if (!skb) |
| 3141 | return -ENOMEM; |
| 3142 | |
| 3143 | ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", |
| 3144 | disable); |
| 3145 | cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; |
| 3146 | cmd->disable = disable ? 1 : 0; |
| 3147 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3148 | return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID, |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3149 | NO_SYNC_WMIFLAG); |
| 3150 | } |
| 3151 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3152 | int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3153 | { |
| 3154 | struct sk_buff *skb; |
| 3155 | struct wmi_remain_on_chnl_cmd *p; |
| 3156 | |
| 3157 | skb = ath6kl_wmi_get_new_buf(sizeof(*p)); |
| 3158 | if (!skb) |
| 3159 | return -ENOMEM; |
| 3160 | |
| 3161 | ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", |
| 3162 | freq, dur); |
| 3163 | p = (struct wmi_remain_on_chnl_cmd *) skb->data; |
| 3164 | p->freq = cpu_to_le32(freq); |
| 3165 | p->duration = cpu_to_le32(dur); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3166 | return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID, |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3167 | NO_SYNC_WMIFLAG); |
| 3168 | } |
| 3169 | |
Aarthi Thiruvengadam | 3ca9d1f | 2011-12-13 13:32:12 -0800 | [diff] [blame] | 3170 | /* ath6kl_wmi_send_action_cmd is to be deprecated. Use |
| 3171 | * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P |
| 3172 | * mgmt operations using station interface. |
| 3173 | */ |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3174 | int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, |
| 3175 | u32 wait, const u8 *data, u16 data_len) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3176 | { |
| 3177 | struct sk_buff *skb; |
| 3178 | struct wmi_send_action_cmd *p; |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame] | 3179 | u8 *buf; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3180 | |
| 3181 | if (wait) |
| 3182 | return -EINVAL; /* Offload for wait not supported */ |
| 3183 | |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame] | 3184 | buf = kmalloc(data_len, GFP_KERNEL); |
| 3185 | if (!buf) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3186 | return -ENOMEM; |
| 3187 | |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame] | 3188 | skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); |
| 3189 | if (!skb) { |
| 3190 | kfree(buf); |
| 3191 | return -ENOMEM; |
| 3192 | } |
| 3193 | |
| 3194 | kfree(wmi->last_mgmt_tx_frame); |
Aarthi Thiruvengadam | 3101ede | 2011-10-27 09:35:56 -0700 | [diff] [blame] | 3195 | memcpy(buf, data, data_len); |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame] | 3196 | wmi->last_mgmt_tx_frame = buf; |
| 3197 | wmi->last_mgmt_tx_frame_len = data_len; |
| 3198 | |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3199 | ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " |
| 3200 | "len=%u\n", id, freq, wait, data_len); |
| 3201 | p = (struct wmi_send_action_cmd *) skb->data; |
| 3202 | p->id = cpu_to_le32(id); |
| 3203 | p->freq = cpu_to_le32(freq); |
| 3204 | p->wait = cpu_to_le32(wait); |
| 3205 | p->len = cpu_to_le16(data_len); |
| 3206 | memcpy(p->data, data, data_len); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3207 | return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID, |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3208 | NO_SYNC_WMIFLAG); |
| 3209 | } |
| 3210 | |
Aarthi Thiruvengadam | 3ca9d1f | 2011-12-13 13:32:12 -0800 | [diff] [blame] | 3211 | int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq, |
| 3212 | u32 wait, const u8 *data, u16 data_len, |
| 3213 | u32 no_cck) |
| 3214 | { |
| 3215 | struct sk_buff *skb; |
| 3216 | struct wmi_send_mgmt_cmd *p; |
| 3217 | u8 *buf; |
| 3218 | |
| 3219 | if (wait) |
| 3220 | return -EINVAL; /* Offload for wait not supported */ |
| 3221 | |
| 3222 | buf = kmalloc(data_len, GFP_KERNEL); |
| 3223 | if (!buf) |
| 3224 | return -ENOMEM; |
| 3225 | |
| 3226 | skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); |
| 3227 | if (!skb) { |
| 3228 | kfree(buf); |
| 3229 | return -ENOMEM; |
| 3230 | } |
| 3231 | |
| 3232 | kfree(wmi->last_mgmt_tx_frame); |
| 3233 | memcpy(buf, data, data_len); |
| 3234 | wmi->last_mgmt_tx_frame = buf; |
| 3235 | wmi->last_mgmt_tx_frame_len = data_len; |
| 3236 | |
| 3237 | ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " |
| 3238 | "len=%u\n", id, freq, wait, data_len); |
| 3239 | p = (struct wmi_send_mgmt_cmd *) skb->data; |
| 3240 | p->id = cpu_to_le32(id); |
| 3241 | p->freq = cpu_to_le32(freq); |
| 3242 | p->wait = cpu_to_le32(wait); |
| 3243 | p->no_cck = cpu_to_le32(no_cck); |
| 3244 | p->len = cpu_to_le16(data_len); |
| 3245 | memcpy(p->data, data, data_len); |
| 3246 | return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_MGMT_CMDID, |
| 3247 | NO_SYNC_WMIFLAG); |
| 3248 | } |
| 3249 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3250 | int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq, |
| 3251 | const u8 *dst, const u8 *data, |
| 3252 | u16 data_len) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3253 | { |
| 3254 | struct sk_buff *skb; |
| 3255 | struct wmi_p2p_probe_response_cmd *p; |
Aarthi Thiruvengadam | bd24a50 | 2011-11-09 10:05:56 -0800 | [diff] [blame] | 3256 | size_t cmd_len = sizeof(*p) + data_len; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3257 | |
Aarthi Thiruvengadam | bd24a50 | 2011-11-09 10:05:56 -0800 | [diff] [blame] | 3258 | if (data_len == 0) |
| 3259 | cmd_len++; /* work around target minimum length requirement */ |
| 3260 | |
| 3261 | skb = ath6kl_wmi_get_new_buf(cmd_len); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3262 | if (!skb) |
| 3263 | return -ENOMEM; |
| 3264 | |
| 3265 | ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM " |
| 3266 | "len=%u\n", freq, dst, data_len); |
| 3267 | p = (struct wmi_p2p_probe_response_cmd *) skb->data; |
| 3268 | p->freq = cpu_to_le32(freq); |
| 3269 | memcpy(p->destination_addr, dst, ETH_ALEN); |
| 3270 | p->len = cpu_to_le16(data_len); |
| 3271 | memcpy(p->data, data, data_len); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3272 | return ath6kl_wmi_cmd_send(wmi, if_idx, skb, |
| 3273 | WMI_SEND_PROBE_RESPONSE_CMDID, |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3274 | NO_SYNC_WMIFLAG); |
| 3275 | } |
| 3276 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 3277 | int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3278 | { |
| 3279 | struct sk_buff *skb; |
| 3280 | struct wmi_probe_req_report_cmd *p; |
| 3281 | |
| 3282 | skb = ath6kl_wmi_get_new_buf(sizeof(*p)); |
| 3283 | if (!skb) |
| 3284 | return -ENOMEM; |
| 3285 | |
| 3286 | ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", |
| 3287 | enable); |
| 3288 | p = (struct wmi_probe_req_report_cmd *) skb->data; |
| 3289 | p->enable = enable ? 1 : 0; |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 3290 | return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID, |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3291 | NO_SYNC_WMIFLAG); |
| 3292 | } |
| 3293 | |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 3294 | int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3295 | { |
| 3296 | struct sk_buff *skb; |
| 3297 | struct wmi_get_p2p_info *p; |
| 3298 | |
| 3299 | skb = ath6kl_wmi_get_new_buf(sizeof(*p)); |
| 3300 | if (!skb) |
| 3301 | return -ENOMEM; |
| 3302 | |
| 3303 | ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", |
| 3304 | info_req_flags); |
| 3305 | p = (struct wmi_get_p2p_info *) skb->data; |
| 3306 | p->info_req_flags = cpu_to_le32(info_req_flags); |
Vasanthakumar Thiagarajan | 0ce5944 | 2011-10-25 19:34:25 +0530 | [diff] [blame] | 3307 | return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID, |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3308 | NO_SYNC_WMIFLAG); |
| 3309 | } |
| 3310 | |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3311 | int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3312 | { |
| 3313 | ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); |
Vasanthakumar Thiagarajan | 334234b | 2011-10-25 19:34:12 +0530 | [diff] [blame] | 3314 | return ath6kl_wmi_simple_cmd(wmi, if_idx, |
| 3315 | WMI_CANCEL_REMAIN_ON_CHNL_CMDID); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3316 | } |
| 3317 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3318 | static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) |
| 3319 | { |
| 3320 | struct wmix_cmd_hdr *cmd; |
| 3321 | u32 len; |
| 3322 | u16 id; |
| 3323 | u8 *datap; |
| 3324 | int ret = 0; |
| 3325 | |
| 3326 | if (skb->len < sizeof(struct wmix_cmd_hdr)) { |
| 3327 | ath6kl_err("bad packet 1\n"); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3328 | return -EINVAL; |
| 3329 | } |
| 3330 | |
| 3331 | cmd = (struct wmix_cmd_hdr *) skb->data; |
| 3332 | id = le32_to_cpu(cmd->cmd_id); |
| 3333 | |
| 3334 | skb_pull(skb, sizeof(struct wmix_cmd_hdr)); |
| 3335 | |
| 3336 | datap = skb->data; |
| 3337 | len = skb->len; |
| 3338 | |
| 3339 | switch (id) { |
| 3340 | case WMIX_HB_CHALLENGE_RESP_EVENTID: |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 3341 | ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n"); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3342 | break; |
| 3343 | case WMIX_DBGLOG_EVENTID: |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 3344 | ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len); |
Kalle Valo | bdf5396 | 2011-09-02 10:32:04 +0300 | [diff] [blame] | 3345 | ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3346 | break; |
| 3347 | default: |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 3348 | ath6kl_warn("unknown cmd id 0x%x\n", id); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3349 | ret = -EINVAL; |
| 3350 | break; |
| 3351 | } |
| 3352 | |
| 3353 | return ret; |
| 3354 | } |
| 3355 | |
Jouni Malinen | 4b28a80 | 2011-10-11 17:31:54 +0300 | [diff] [blame] | 3356 | static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 3357 | { |
| 3358 | return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len); |
| 3359 | } |
| 3360 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3361 | /* Control Path */ |
| 3362 | int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) |
| 3363 | { |
| 3364 | struct wmi_cmd_hdr *cmd; |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3365 | struct ath6kl_vif *vif; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3366 | u32 len; |
| 3367 | u16 id; |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3368 | u8 if_idx; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3369 | u8 *datap; |
| 3370 | int ret = 0; |
| 3371 | |
| 3372 | if (WARN_ON(skb == NULL)) |
| 3373 | return -EINVAL; |
| 3374 | |
| 3375 | if (skb->len < sizeof(struct wmi_cmd_hdr)) { |
| 3376 | ath6kl_err("bad packet 1\n"); |
| 3377 | dev_kfree_skb(skb); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3378 | return -EINVAL; |
| 3379 | } |
| 3380 | |
| 3381 | cmd = (struct wmi_cmd_hdr *) skb->data; |
| 3382 | id = le16_to_cpu(cmd->cmd_id); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3383 | if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3384 | |
| 3385 | skb_pull(skb, sizeof(struct wmi_cmd_hdr)); |
| 3386 | |
| 3387 | datap = skb->data; |
| 3388 | len = skb->len; |
| 3389 | |
Kalle Valo | b9b6ee6 | 2011-09-27 14:31:21 +0300 | [diff] [blame] | 3390 | ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len); |
| 3391 | ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ", |
Kalle Valo | ef09410 | 2011-09-27 14:30:45 +0300 | [diff] [blame] | 3392 | datap, len); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3393 | |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3394 | vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx); |
| 3395 | if (!vif) { |
| 3396 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 3397 | "Wmi event for unavailable vif, vif_index:%d\n", |
| 3398 | if_idx); |
| 3399 | dev_kfree_skb(skb); |
| 3400 | return -EINVAL; |
| 3401 | } |
| 3402 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3403 | switch (id) { |
| 3404 | case WMI_GET_BITRATE_CMDID: |
| 3405 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); |
| 3406 | ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); |
| 3407 | break; |
| 3408 | case WMI_GET_CHANNEL_LIST_CMDID: |
| 3409 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); |
| 3410 | ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); |
| 3411 | break; |
| 3412 | case WMI_GET_TX_PWR_CMDID: |
| 3413 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); |
| 3414 | ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); |
| 3415 | break; |
| 3416 | case WMI_READY_EVENTID: |
| 3417 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); |
| 3418 | ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); |
| 3419 | break; |
| 3420 | case WMI_CONNECT_EVENTID: |
| 3421 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3422 | ret = ath6kl_wmi_connect_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3423 | break; |
| 3424 | case WMI_DISCONNECT_EVENTID: |
| 3425 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3426 | ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3427 | break; |
| 3428 | case WMI_PEER_NODE_EVENTID: |
| 3429 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); |
| 3430 | ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); |
| 3431 | break; |
| 3432 | case WMI_TKIP_MICERR_EVENTID: |
| 3433 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3434 | ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3435 | break; |
| 3436 | case WMI_BSSINFO_EVENTID: |
| 3437 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3438 | ret = ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3439 | break; |
| 3440 | case WMI_REGDOMAIN_EVENTID: |
| 3441 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); |
Vivek Natarajan | 0603376 | 2011-09-06 13:01:36 +0530 | [diff] [blame] | 3442 | ath6kl_wmi_regdomain_event(wmi, datap, len); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3443 | break; |
| 3444 | case WMI_PSTREAM_TIMEOUT_EVENTID: |
| 3445 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); |
| 3446 | ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); |
| 3447 | break; |
| 3448 | case WMI_NEIGHBOR_REPORT_EVENTID: |
| 3449 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3450 | ret = ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len, |
| 3451 | vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3452 | break; |
| 3453 | case WMI_SCAN_COMPLETE_EVENTID: |
| 3454 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3455 | ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3456 | break; |
| 3457 | case WMI_CMDERROR_EVENTID: |
| 3458 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); |
| 3459 | ret = ath6kl_wmi_error_event_rx(wmi, datap, len); |
| 3460 | break; |
| 3461 | case WMI_REPORT_STATISTICS_EVENTID: |
| 3462 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3463 | ret = ath6kl_wmi_stats_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3464 | break; |
| 3465 | case WMI_RSSI_THRESHOLD_EVENTID: |
| 3466 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); |
| 3467 | ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); |
| 3468 | break; |
| 3469 | case WMI_ERROR_REPORT_EVENTID: |
| 3470 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); |
| 3471 | break; |
| 3472 | case WMI_OPT_RX_FRAME_EVENTID: |
| 3473 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); |
Jouni Malinen | f195d50 | 2011-09-19 19:15:00 +0300 | [diff] [blame] | 3474 | /* this event has been deprecated */ |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3475 | break; |
| 3476 | case WMI_REPORT_ROAM_TBL_EVENTID: |
| 3477 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); |
Jouni Malinen | 4b28a80 | 2011-10-11 17:31:54 +0300 | [diff] [blame] | 3478 | ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3479 | break; |
| 3480 | case WMI_EXTENSION_EVENTID: |
| 3481 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); |
| 3482 | ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); |
| 3483 | break; |
| 3484 | case WMI_CAC_EVENTID: |
| 3485 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3486 | ret = ath6kl_wmi_cac_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3487 | break; |
| 3488 | case WMI_CHANNEL_CHANGE_EVENTID: |
| 3489 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); |
| 3490 | break; |
| 3491 | case WMI_REPORT_ROAM_DATA_EVENTID: |
| 3492 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); |
| 3493 | break; |
Kalle Valo | 003353b0d | 2011-09-01 10:14:21 +0300 | [diff] [blame] | 3494 | case WMI_TEST_EVENTID: |
| 3495 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n"); |
Thomas Pedersen | 4f34dac | 2011-12-30 01:57:00 -0800 | [diff] [blame] | 3496 | ret = ath6kl_wmi_test_rx(wmi, datap, len); |
Kalle Valo | 003353b0d | 2011-09-01 10:14:21 +0300 | [diff] [blame] | 3497 | break; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3498 | case WMI_GET_FIXRATES_CMDID: |
| 3499 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); |
| 3500 | ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); |
| 3501 | break; |
| 3502 | case WMI_TX_RETRY_ERR_EVENTID: |
| 3503 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); |
| 3504 | break; |
| 3505 | case WMI_SNR_THRESHOLD_EVENTID: |
| 3506 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); |
| 3507 | ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); |
| 3508 | break; |
| 3509 | case WMI_LQ_THRESHOLD_EVENTID: |
| 3510 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); |
| 3511 | break; |
| 3512 | case WMI_APLIST_EVENTID: |
| 3513 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); |
| 3514 | ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); |
| 3515 | break; |
| 3516 | case WMI_GET_KEEPALIVE_CMDID: |
| 3517 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); |
| 3518 | ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); |
| 3519 | break; |
| 3520 | case WMI_GET_WOW_LIST_EVENTID: |
| 3521 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3522 | break; |
| 3523 | case WMI_GET_PMKID_LIST_EVENTID: |
| 3524 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); |
| 3525 | ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); |
| 3526 | break; |
| 3527 | case WMI_PSPOLL_EVENTID: |
| 3528 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3529 | ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3530 | break; |
| 3531 | case WMI_DTIMEXPIRY_EVENTID: |
| 3532 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3533 | ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3534 | break; |
| 3535 | case WMI_SET_PARAMS_REPLY_EVENTID: |
| 3536 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); |
| 3537 | break; |
| 3538 | case WMI_ADDBA_REQ_EVENTID: |
| 3539 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3540 | ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3541 | break; |
| 3542 | case WMI_ADDBA_RESP_EVENTID: |
| 3543 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); |
| 3544 | break; |
| 3545 | case WMI_DELBA_REQ_EVENTID: |
| 3546 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3547 | ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3548 | break; |
| 3549 | case WMI_REPORT_BTCOEX_CONFIG_EVENTID: |
| 3550 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 3551 | "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); |
| 3552 | break; |
| 3553 | case WMI_REPORT_BTCOEX_STATS_EVENTID: |
| 3554 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 3555 | "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); |
| 3556 | break; |
| 3557 | case WMI_TX_COMPLETE_EVENTID: |
| 3558 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); |
| 3559 | ret = ath6kl_wmi_tx_complete_event_rx(datap, len); |
| 3560 | break; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3561 | case WMI_REMAIN_ON_CHNL_EVENTID: |
| 3562 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3563 | ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3564 | break; |
| 3565 | case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: |
| 3566 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 3567 | "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 3568 | ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3569 | len, vif); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3570 | break; |
| 3571 | case WMI_TX_STATUS_EVENTID: |
| 3572 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3573 | ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3574 | break; |
| 3575 | case WMI_RX_PROBE_REQ_EVENTID: |
| 3576 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3577 | ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3578 | break; |
| 3579 | case WMI_P2P_CAPABILITIES_EVENTID: |
| 3580 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); |
| 3581 | ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); |
| 3582 | break; |
| 3583 | case WMI_RX_ACTION_EVENTID: |
| 3584 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); |
Vasanthakumar Thiagarajan | 240d279 | 2011-10-25 19:34:13 +0530 | [diff] [blame] | 3585 | ret = ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3586 | break; |
| 3587 | case WMI_P2P_INFO_EVENTID: |
| 3588 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); |
| 3589 | ret = ath6kl_wmi_p2p_info_event_rx(datap, len); |
| 3590 | break; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3591 | default: |
| 3592 | ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3593 | ret = -EINVAL; |
| 3594 | break; |
| 3595 | } |
| 3596 | |
| 3597 | dev_kfree_skb(skb); |
| 3598 | |
| 3599 | return ret; |
| 3600 | } |
| 3601 | |
Kalle Valo | c89c591 | 2011-10-27 18:48:00 +0300 | [diff] [blame] | 3602 | void ath6kl_wmi_reset(struct wmi *wmi) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3603 | { |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3604 | spin_lock_bh(&wmi->lock); |
| 3605 | |
| 3606 | wmi->fat_pipe_exist = 0; |
| 3607 | memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); |
| 3608 | |
| 3609 | spin_unlock_bh(&wmi->lock); |
| 3610 | } |
| 3611 | |
Vasanthakumar Thiagarajan | 2865785 | 2011-07-21 12:00:49 +0530 | [diff] [blame] | 3612 | void *ath6kl_wmi_init(struct ath6kl *dev) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3613 | { |
| 3614 | struct wmi *wmi; |
| 3615 | |
| 3616 | wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); |
| 3617 | if (!wmi) |
| 3618 | return NULL; |
| 3619 | |
| 3620 | spin_lock_init(&wmi->lock); |
| 3621 | |
| 3622 | wmi->parent_dev = dev; |
| 3623 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3624 | wmi->pwr_mode = REC_POWER; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3625 | |
Kalle Valo | c89c591 | 2011-10-27 18:48:00 +0300 | [diff] [blame] | 3626 | ath6kl_wmi_reset(wmi); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3627 | |
| 3628 | return wmi; |
| 3629 | } |
| 3630 | |
| 3631 | void ath6kl_wmi_shutdown(struct wmi *wmi) |
| 3632 | { |
| 3633 | if (!wmi) |
| 3634 | return; |
| 3635 | |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame] | 3636 | kfree(wmi->last_mgmt_tx_frame); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3637 | kfree(wmi); |
| 3638 | } |