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