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" |
| 20 | |
| 21 | static int ath6kl_wmi_sync_point(struct wmi *wmi); |
| 22 | |
| 23 | static const s32 wmi_rate_tbl[][2] = { |
| 24 | /* {W/O SGI, with SGI} */ |
| 25 | {1000, 1000}, |
| 26 | {2000, 2000}, |
| 27 | {5500, 5500}, |
| 28 | {11000, 11000}, |
| 29 | {6000, 6000}, |
| 30 | {9000, 9000}, |
| 31 | {12000, 12000}, |
| 32 | {18000, 18000}, |
| 33 | {24000, 24000}, |
| 34 | {36000, 36000}, |
| 35 | {48000, 48000}, |
| 36 | {54000, 54000}, |
| 37 | {6500, 7200}, |
| 38 | {13000, 14400}, |
| 39 | {19500, 21700}, |
| 40 | {26000, 28900}, |
| 41 | {39000, 43300}, |
| 42 | {52000, 57800}, |
| 43 | {58500, 65000}, |
| 44 | {65000, 72200}, |
| 45 | {13500, 15000}, |
| 46 | {27000, 30000}, |
| 47 | {40500, 45000}, |
| 48 | {54000, 60000}, |
| 49 | {81000, 90000}, |
| 50 | {108000, 120000}, |
| 51 | {121500, 135000}, |
| 52 | {135000, 150000}, |
| 53 | {0, 0} |
| 54 | }; |
| 55 | |
| 56 | /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */ |
| 57 | static const u8 up_to_ac[] = { |
| 58 | WMM_AC_BE, |
| 59 | WMM_AC_BK, |
| 60 | WMM_AC_BK, |
| 61 | WMM_AC_BE, |
| 62 | WMM_AC_VI, |
| 63 | WMM_AC_VI, |
| 64 | WMM_AC_VO, |
| 65 | WMM_AC_VO, |
| 66 | }; |
| 67 | |
| 68 | void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id) |
| 69 | { |
| 70 | if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX)) |
| 71 | return; |
| 72 | |
| 73 | wmi->ep_id = ep_id; |
| 74 | } |
| 75 | |
| 76 | enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi) |
| 77 | { |
| 78 | return wmi->ep_id; |
| 79 | } |
| 80 | |
| 81 | /* Performs DIX to 802.3 encapsulation for transmit packets. |
| 82 | * Assumes the entire DIX header is contigous and that there is |
| 83 | * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers. |
| 84 | */ |
| 85 | int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb) |
| 86 | { |
| 87 | struct ath6kl_llc_snap_hdr *llc_hdr; |
| 88 | struct ethhdr *eth_hdr; |
| 89 | size_t new_len; |
| 90 | __be16 type; |
| 91 | u8 *datap; |
| 92 | u16 size; |
| 93 | |
| 94 | if (WARN_ON(skb == NULL)) |
| 95 | return -EINVAL; |
| 96 | |
| 97 | size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr); |
| 98 | if (skb_headroom(skb) < size) |
| 99 | return -ENOMEM; |
| 100 | |
| 101 | eth_hdr = (struct ethhdr *) skb->data; |
| 102 | type = eth_hdr->h_proto; |
| 103 | |
| 104 | if (!is_ethertype(be16_to_cpu(type))) { |
| 105 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 106 | "%s: pkt is already in 802.3 format\n", __func__); |
| 107 | return 0; |
| 108 | } |
| 109 | |
| 110 | new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr); |
| 111 | |
| 112 | skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr)); |
| 113 | datap = skb->data; |
| 114 | |
| 115 | eth_hdr->h_proto = cpu_to_be16(new_len); |
| 116 | |
| 117 | memcpy(datap, eth_hdr, sizeof(*eth_hdr)); |
| 118 | |
| 119 | llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr)); |
| 120 | llc_hdr->dsap = 0xAA; |
| 121 | llc_hdr->ssap = 0xAA; |
| 122 | llc_hdr->cntl = 0x03; |
| 123 | llc_hdr->org_code[0] = 0x0; |
| 124 | llc_hdr->org_code[1] = 0x0; |
| 125 | llc_hdr->org_code[2] = 0x0; |
| 126 | llc_hdr->eth_type = type; |
| 127 | |
| 128 | return 0; |
| 129 | } |
| 130 | |
| 131 | static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb, |
| 132 | u8 *version, void *tx_meta_info) |
| 133 | { |
| 134 | struct wmi_tx_meta_v1 *v1; |
| 135 | struct wmi_tx_meta_v2 *v2; |
| 136 | |
| 137 | if (WARN_ON(skb == NULL || version == NULL)) |
| 138 | return -EINVAL; |
| 139 | |
| 140 | switch (*version) { |
| 141 | case WMI_META_VERSION_1: |
| 142 | skb_push(skb, WMI_MAX_TX_META_SZ); |
| 143 | v1 = (struct wmi_tx_meta_v1 *) skb->data; |
| 144 | v1->pkt_id = 0; |
| 145 | v1->rate_plcy_id = 0; |
| 146 | *version = WMI_META_VERSION_1; |
| 147 | break; |
| 148 | case WMI_META_VERSION_2: |
| 149 | skb_push(skb, WMI_MAX_TX_META_SZ); |
| 150 | v2 = (struct wmi_tx_meta_v2 *) skb->data; |
| 151 | memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info, |
| 152 | sizeof(struct wmi_tx_meta_v2)); |
| 153 | break; |
| 154 | } |
| 155 | |
| 156 | return 0; |
| 157 | } |
| 158 | |
| 159 | int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb, |
| 160 | u8 msg_type, bool more_data, |
| 161 | enum wmi_data_hdr_data_type data_type, |
| 162 | u8 meta_ver, void *tx_meta_info) |
| 163 | { |
| 164 | struct wmi_data_hdr *data_hdr; |
| 165 | int ret; |
| 166 | |
| 167 | if (WARN_ON(skb == NULL)) |
| 168 | return -EINVAL; |
| 169 | |
Vasanthakumar Thiagarajan | 3ce6ff5 | 2011-08-22 20:40:21 +0530 | [diff] [blame] | 170 | if (tx_meta_info) { |
| 171 | ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info); |
| 172 | if (ret) |
| 173 | return ret; |
| 174 | } |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 175 | |
| 176 | skb_push(skb, sizeof(struct wmi_data_hdr)); |
| 177 | |
| 178 | data_hdr = (struct wmi_data_hdr *)skb->data; |
| 179 | memset(data_hdr, 0, sizeof(struct wmi_data_hdr)); |
| 180 | |
| 181 | data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT; |
| 182 | data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT; |
| 183 | |
| 184 | if (more_data) |
| 185 | data_hdr->info |= |
| 186 | WMI_DATA_HDR_MORE_MASK << WMI_DATA_HDR_MORE_SHIFT; |
| 187 | |
| 188 | data_hdr->info2 = cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT); |
| 189 | data_hdr->info3 = 0; |
| 190 | |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | static u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri) |
| 195 | { |
| 196 | struct iphdr *ip_hdr = (struct iphdr *) pkt; |
| 197 | u8 ip_pri; |
| 198 | |
| 199 | /* |
| 200 | * Determine IPTOS priority |
| 201 | * |
| 202 | * IP-TOS - 8bits |
| 203 | * : DSCP(6-bits) ECN(2-bits) |
| 204 | * : DSCP - P2 P1 P0 X X X |
| 205 | * where (P2 P1 P0) form 802.1D |
| 206 | */ |
| 207 | ip_pri = ip_hdr->tos >> 5; |
| 208 | ip_pri &= 0x7; |
| 209 | |
| 210 | if ((layer2_pri & 0x7) > ip_pri) |
| 211 | return (u8) layer2_pri & 0x7; |
| 212 | else |
| 213 | return ip_pri; |
| 214 | } |
| 215 | |
| 216 | int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, struct sk_buff *skb, |
| 217 | u32 layer2_priority, bool wmm_enabled, |
| 218 | u8 *ac) |
| 219 | { |
| 220 | struct wmi_data_hdr *data_hdr; |
| 221 | struct ath6kl_llc_snap_hdr *llc_hdr; |
| 222 | struct wmi_create_pstream_cmd cmd; |
| 223 | u32 meta_size, hdr_size; |
| 224 | u16 ip_type = IP_ETHERTYPE; |
| 225 | u8 stream_exist, usr_pri; |
| 226 | u8 traffic_class = WMM_AC_BE; |
| 227 | u8 *datap; |
| 228 | |
| 229 | if (WARN_ON(skb == NULL)) |
| 230 | return -EINVAL; |
| 231 | |
| 232 | datap = skb->data; |
| 233 | data_hdr = (struct wmi_data_hdr *) datap; |
| 234 | |
| 235 | meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) & |
| 236 | WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0; |
| 237 | |
| 238 | if (!wmm_enabled) { |
| 239 | /* If WMM is disabled all traffic goes as BE traffic */ |
| 240 | usr_pri = 0; |
| 241 | } else { |
| 242 | hdr_size = sizeof(struct ethhdr); |
| 243 | |
| 244 | llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + |
| 245 | sizeof(struct |
| 246 | wmi_data_hdr) + |
| 247 | meta_size + hdr_size); |
| 248 | |
| 249 | if (llc_hdr->eth_type == htons(ip_type)) { |
| 250 | /* |
| 251 | * Extract the endpoint info from the TOS field |
| 252 | * in the IP header. |
| 253 | */ |
| 254 | usr_pri = |
| 255 | ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) + |
| 256 | sizeof(struct ath6kl_llc_snap_hdr), |
| 257 | layer2_priority); |
| 258 | } else |
| 259 | usr_pri = layer2_priority & 0x7; |
| 260 | } |
| 261 | |
| 262 | /* workaround for WMM S5 */ |
| 263 | if ((wmi->traffic_class == WMM_AC_VI) && |
| 264 | ((usr_pri == 5) || (usr_pri == 4))) |
| 265 | usr_pri = 1; |
| 266 | |
| 267 | /* Convert user priority to traffic class */ |
| 268 | traffic_class = up_to_ac[usr_pri & 0x7]; |
| 269 | |
| 270 | wmi_data_hdr_set_up(data_hdr, usr_pri); |
| 271 | |
| 272 | spin_lock_bh(&wmi->lock); |
| 273 | stream_exist = wmi->fat_pipe_exist; |
| 274 | spin_unlock_bh(&wmi->lock); |
| 275 | |
| 276 | if (!(stream_exist & (1 << traffic_class))) { |
| 277 | memset(&cmd, 0, sizeof(cmd)); |
| 278 | cmd.traffic_class = traffic_class; |
| 279 | cmd.user_pri = usr_pri; |
| 280 | cmd.inactivity_int = |
| 281 | cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT); |
| 282 | /* Implicit streams are created with TSID 0xFF */ |
| 283 | cmd.tsid = WMI_IMPLICIT_PSTREAM; |
| 284 | ath6kl_wmi_create_pstream_cmd(wmi, &cmd); |
| 285 | } |
| 286 | |
| 287 | *ac = traffic_class; |
| 288 | |
| 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb) |
| 293 | { |
| 294 | struct ieee80211_hdr_3addr *pwh, wh; |
| 295 | struct ath6kl_llc_snap_hdr *llc_hdr; |
| 296 | struct ethhdr eth_hdr; |
| 297 | u32 hdr_size; |
| 298 | u8 *datap; |
| 299 | __le16 sub_type; |
| 300 | |
| 301 | if (WARN_ON(skb == NULL)) |
| 302 | return -EINVAL; |
| 303 | |
| 304 | datap = skb->data; |
| 305 | pwh = (struct ieee80211_hdr_3addr *) datap; |
| 306 | |
| 307 | sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE); |
| 308 | |
| 309 | memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr)); |
| 310 | |
| 311 | /* Strip off the 802.11 header */ |
| 312 | if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) { |
| 313 | hdr_size = roundup(sizeof(struct ieee80211_qos_hdr), |
| 314 | sizeof(u32)); |
| 315 | skb_pull(skb, hdr_size); |
| 316 | } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA)) |
| 317 | skb_pull(skb, sizeof(struct ieee80211_hdr_3addr)); |
| 318 | |
| 319 | datap = skb->data; |
| 320 | llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap); |
| 321 | |
Raja Mani | c8790cb | 2011-07-19 19:27:32 +0530 | [diff] [blame] | 322 | memset(ð_hdr, 0, sizeof(eth_hdr)); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 323 | eth_hdr.h_proto = llc_hdr->eth_type; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 324 | |
| 325 | switch ((le16_to_cpu(wh.frame_control)) & |
| 326 | (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { |
| 327 | case 0: |
| 328 | memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); |
| 329 | memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); |
| 330 | break; |
| 331 | case IEEE80211_FCTL_TODS: |
| 332 | memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN); |
| 333 | memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN); |
| 334 | break; |
| 335 | case IEEE80211_FCTL_FROMDS: |
| 336 | memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN); |
| 337 | memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN); |
| 338 | break; |
| 339 | case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: |
| 340 | break; |
| 341 | } |
| 342 | |
| 343 | skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); |
| 344 | skb_push(skb, sizeof(eth_hdr)); |
| 345 | |
| 346 | datap = skb->data; |
| 347 | |
| 348 | memcpy(datap, ð_hdr, sizeof(eth_hdr)); |
| 349 | |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | /* |
| 354 | * Performs 802.3 to DIX encapsulation for received packets. |
| 355 | * Assumes the entire 802.3 header is contigous. |
| 356 | */ |
| 357 | int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb) |
| 358 | { |
| 359 | struct ath6kl_llc_snap_hdr *llc_hdr; |
| 360 | struct ethhdr eth_hdr; |
| 361 | u8 *datap; |
| 362 | |
| 363 | if (WARN_ON(skb == NULL)) |
| 364 | return -EINVAL; |
| 365 | |
| 366 | datap = skb->data; |
| 367 | |
| 368 | memcpy(ð_hdr, datap, sizeof(eth_hdr)); |
| 369 | |
| 370 | llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr)); |
| 371 | eth_hdr.h_proto = llc_hdr->eth_type; |
| 372 | |
| 373 | skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr)); |
| 374 | datap = skb->data; |
| 375 | |
| 376 | memcpy(datap, ð_hdr, sizeof(eth_hdr)); |
| 377 | |
| 378 | return 0; |
| 379 | } |
| 380 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 381 | static void ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(struct sk_buff *skb, |
| 382 | u8 *datap) |
| 383 | { |
| 384 | struct wmi_bss_info_hdr2 bih2; |
| 385 | struct wmi_bss_info_hdr *bih; |
| 386 | |
| 387 | memcpy(&bih2, datap, sizeof(struct wmi_bss_info_hdr2)); |
| 388 | |
| 389 | skb_push(skb, 4); |
| 390 | bih = (struct wmi_bss_info_hdr *) skb->data; |
| 391 | |
| 392 | bih->ch = bih2.ch; |
| 393 | bih->frame_type = bih2.frame_type; |
| 394 | bih->snr = bih2.snr; |
| 395 | bih->rssi = a_cpu_to_sle16(bih2.snr - 95); |
| 396 | bih->ie_mask = cpu_to_le32(le16_to_cpu(bih2.ie_mask)); |
| 397 | memcpy(bih->bssid, bih2.bssid, ETH_ALEN); |
| 398 | } |
| 399 | |
| 400 | static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len) |
| 401 | { |
| 402 | struct tx_complete_msg_v1 *msg_v1; |
| 403 | struct wmi_tx_complete_event *evt; |
| 404 | int index; |
| 405 | u16 size; |
| 406 | |
| 407 | evt = (struct wmi_tx_complete_event *) datap; |
| 408 | |
| 409 | ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n", |
| 410 | evt->num_msg, evt->msg_len, evt->msg_type); |
| 411 | |
| 412 | if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI)) |
| 413 | return 0; |
| 414 | |
| 415 | for (index = 0; index < evt->num_msg; index++) { |
| 416 | size = sizeof(struct wmi_tx_complete_event) + |
| 417 | (index * sizeof(struct tx_complete_msg_v1)); |
| 418 | msg_v1 = (struct tx_complete_msg_v1 *)(datap + size); |
| 419 | |
| 420 | ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n", |
| 421 | msg_v1->status, msg_v1->pkt_id, |
| 422 | msg_v1->rate_idx, msg_v1->ack_failures); |
| 423 | } |
| 424 | |
| 425 | return 0; |
| 426 | } |
| 427 | |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 428 | static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap, |
| 429 | int len) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 430 | { |
| 431 | struct wmi_remain_on_chnl_event *ev; |
| 432 | u32 freq; |
| 433 | u32 dur; |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 434 | struct ieee80211_channel *chan; |
| 435 | struct ath6kl *ar = wmi->parent_dev; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 436 | |
| 437 | if (len < sizeof(*ev)) |
| 438 | return -EINVAL; |
| 439 | |
| 440 | ev = (struct wmi_remain_on_chnl_event *) datap; |
| 441 | freq = le32_to_cpu(ev->freq); |
| 442 | dur = le32_to_cpu(ev->duration); |
| 443 | ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n", |
| 444 | freq, dur); |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 445 | chan = ieee80211_get_channel(ar->wdev->wiphy, freq); |
| 446 | if (!chan) { |
| 447 | ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel " |
| 448 | "(freq=%u)\n", freq); |
| 449 | return -EINVAL; |
| 450 | } |
| 451 | cfg80211_ready_on_channel(ar->net_dev, 1, chan, NL80211_CHAN_NO_HT, |
| 452 | dur, GFP_ATOMIC); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 453 | |
| 454 | return 0; |
| 455 | } |
| 456 | |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 457 | static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi, |
| 458 | u8 *datap, int len) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 459 | { |
| 460 | struct wmi_cancel_remain_on_chnl_event *ev; |
| 461 | u32 freq; |
| 462 | u32 dur; |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 463 | struct ieee80211_channel *chan; |
| 464 | struct ath6kl *ar = wmi->parent_dev; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 465 | |
| 466 | if (len < sizeof(*ev)) |
| 467 | return -EINVAL; |
| 468 | |
| 469 | ev = (struct wmi_cancel_remain_on_chnl_event *) datap; |
| 470 | freq = le32_to_cpu(ev->freq); |
| 471 | dur = le32_to_cpu(ev->duration); |
| 472 | ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u " |
| 473 | "status=%u\n", freq, dur, ev->status); |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 474 | chan = ieee80211_get_channel(ar->wdev->wiphy, freq); |
| 475 | if (!chan) { |
| 476 | ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown " |
| 477 | "channel (freq=%u)\n", freq); |
| 478 | return -EINVAL; |
| 479 | } |
| 480 | cfg80211_remain_on_channel_expired(ar->net_dev, 1, chan, |
| 481 | NL80211_CHAN_NO_HT, GFP_ATOMIC); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 482 | |
| 483 | return 0; |
| 484 | } |
| 485 | |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame^] | 486 | static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 487 | { |
| 488 | struct wmi_tx_status_event *ev; |
| 489 | u32 id; |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame^] | 490 | struct ath6kl *ar = wmi->parent_dev; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 491 | |
| 492 | if (len < sizeof(*ev)) |
| 493 | return -EINVAL; |
| 494 | |
| 495 | ev = (struct wmi_tx_status_event *) datap; |
| 496 | id = le32_to_cpu(ev->id); |
| 497 | ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n", |
| 498 | id, ev->ack_status); |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame^] | 499 | if (wmi->last_mgmt_tx_frame) { |
| 500 | cfg80211_mgmt_tx_status(ar->net_dev, id, |
| 501 | wmi->last_mgmt_tx_frame, |
| 502 | wmi->last_mgmt_tx_frame_len, |
| 503 | !!ev->ack_status, GFP_ATOMIC); |
| 504 | kfree(wmi->last_mgmt_tx_frame); |
| 505 | wmi->last_mgmt_tx_frame = NULL; |
| 506 | wmi->last_mgmt_tx_frame_len = 0; |
| 507 | } |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 508 | |
| 509 | return 0; |
| 510 | } |
| 511 | |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 512 | static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 513 | { |
| 514 | struct wmi_p2p_rx_probe_req_event *ev; |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 515 | u32 freq; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 516 | u16 dlen; |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 517 | struct ath6kl *ar = wmi->parent_dev; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 518 | |
| 519 | if (len < sizeof(*ev)) |
| 520 | return -EINVAL; |
| 521 | |
| 522 | ev = (struct wmi_p2p_rx_probe_req_event *) datap; |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 523 | freq = le32_to_cpu(ev->freq); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 524 | dlen = le16_to_cpu(ev->len); |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 525 | if (datap + len < ev->data + dlen) { |
| 526 | ath6kl_err("invalid wmi_p2p_rx_probe_req_event: " |
| 527 | "len=%d dlen=%u\n", len, dlen); |
| 528 | return -EINVAL; |
| 529 | } |
| 530 | ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u freq=%u " |
| 531 | "probe_req_report=%d\n", |
| 532 | dlen, freq, ar->probe_req_report); |
| 533 | |
| 534 | if (ar->probe_req_report || ar->nw_type == AP_NETWORK) |
| 535 | cfg80211_rx_mgmt(ar->net_dev, freq, ev->data, dlen, GFP_ATOMIC); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 536 | |
| 537 | return 0; |
| 538 | } |
| 539 | |
| 540 | static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len) |
| 541 | { |
| 542 | struct wmi_p2p_capabilities_event *ev; |
| 543 | u16 dlen; |
| 544 | |
| 545 | if (len < sizeof(*ev)) |
| 546 | return -EINVAL; |
| 547 | |
| 548 | ev = (struct wmi_p2p_capabilities_event *) datap; |
| 549 | dlen = le16_to_cpu(ev->len); |
| 550 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen); |
| 551 | |
| 552 | return 0; |
| 553 | } |
| 554 | |
| 555 | static int ath6kl_wmi_rx_action_event_rx(u8 *datap, int len) |
| 556 | { |
| 557 | struct wmi_rx_action_event *ev; |
| 558 | u16 dlen; |
| 559 | |
| 560 | if (len < sizeof(*ev)) |
| 561 | return -EINVAL; |
| 562 | |
| 563 | ev = (struct wmi_rx_action_event *) datap; |
| 564 | dlen = le16_to_cpu(ev->len); |
| 565 | ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u\n", dlen); |
| 566 | |
| 567 | return 0; |
| 568 | } |
| 569 | |
| 570 | static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len) |
| 571 | { |
| 572 | struct wmi_p2p_info_event *ev; |
| 573 | u32 flags; |
| 574 | u16 dlen; |
| 575 | |
| 576 | if (len < sizeof(*ev)) |
| 577 | return -EINVAL; |
| 578 | |
| 579 | ev = (struct wmi_p2p_info_event *) datap; |
| 580 | flags = le32_to_cpu(ev->info_req_flags); |
| 581 | dlen = le16_to_cpu(ev->len); |
| 582 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen); |
| 583 | |
| 584 | if (flags & P2P_FLAG_CAPABILITIES_REQ) { |
| 585 | struct wmi_p2p_capabilities *cap; |
| 586 | if (dlen < sizeof(*cap)) |
| 587 | return -EINVAL; |
| 588 | cap = (struct wmi_p2p_capabilities *) ev->data; |
| 589 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n", |
| 590 | cap->go_power_save); |
| 591 | } |
| 592 | |
| 593 | if (flags & P2P_FLAG_MACADDR_REQ) { |
| 594 | struct wmi_p2p_macaddr *mac; |
| 595 | if (dlen < sizeof(*mac)) |
| 596 | return -EINVAL; |
| 597 | mac = (struct wmi_p2p_macaddr *) ev->data; |
| 598 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n", |
| 599 | mac->mac_addr); |
| 600 | } |
| 601 | |
| 602 | if (flags & P2P_FLAG_HMODEL_REQ) { |
| 603 | struct wmi_p2p_hmodel *mod; |
| 604 | if (dlen < sizeof(*mod)) |
| 605 | return -EINVAL; |
| 606 | mod = (struct wmi_p2p_hmodel *) ev->data; |
| 607 | ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n", |
| 608 | mod->p2p_model, |
| 609 | mod->p2p_model ? "host" : "firmware"); |
| 610 | } |
| 611 | return 0; |
| 612 | } |
| 613 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 614 | static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) |
| 615 | { |
| 616 | struct sk_buff *skb; |
| 617 | |
| 618 | skb = ath6kl_buf_alloc(size); |
| 619 | if (!skb) |
| 620 | return NULL; |
| 621 | |
| 622 | skb_put(skb, size); |
| 623 | if (size) |
| 624 | memset(skb->data, 0, size); |
| 625 | |
| 626 | return skb; |
| 627 | } |
| 628 | |
| 629 | /* Send a "simple" wmi command -- one with no arguments */ |
| 630 | static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id) |
| 631 | { |
| 632 | struct sk_buff *skb; |
| 633 | int ret; |
| 634 | |
| 635 | skb = ath6kl_wmi_get_new_buf(0); |
| 636 | if (!skb) |
| 637 | return -ENOMEM; |
| 638 | |
| 639 | ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG); |
| 640 | |
| 641 | return ret; |
| 642 | } |
| 643 | |
| 644 | static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 645 | { |
| 646 | struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; |
| 647 | |
| 648 | if (len < sizeof(struct wmi_ready_event_2)) |
| 649 | return -EINVAL; |
| 650 | |
| 651 | wmi->ready = true; |
| 652 | ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, |
| 653 | le32_to_cpu(ev->sw_version), |
| 654 | le32_to_cpu(ev->abi_version)); |
| 655 | |
| 656 | return 0; |
| 657 | } |
| 658 | |
| 659 | static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 660 | { |
| 661 | struct wmi_connect_event *ev; |
| 662 | u8 *pie, *peie; |
| 663 | |
| 664 | if (len < sizeof(struct wmi_connect_event)) |
| 665 | return -EINVAL; |
| 666 | |
| 667 | ev = (struct wmi_connect_event *) datap; |
| 668 | |
| 669 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM\n", |
| 670 | __func__, ev->ch, ev->bssid); |
| 671 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 672 | /* Start of assoc rsp IEs */ |
| 673 | pie = ev->assoc_info + ev->beacon_ie_len + |
| 674 | ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ |
| 675 | |
| 676 | /* End of assoc rsp IEs */ |
| 677 | peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + |
| 678 | ev->assoc_resp_len; |
| 679 | |
| 680 | while (pie < peie) { |
| 681 | switch (*pie) { |
| 682 | case WLAN_EID_VENDOR_SPECIFIC: |
| 683 | if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && |
| 684 | pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { |
| 685 | /* WMM OUT (00:50:F2) */ |
| 686 | if (pie[1] > 5 |
| 687 | && pie[6] == WMM_PARAM_OUI_SUBTYPE) |
| 688 | wmi->is_wmm_enabled = true; |
| 689 | } |
| 690 | break; |
| 691 | } |
| 692 | |
| 693 | if (wmi->is_wmm_enabled) |
| 694 | break; |
| 695 | |
| 696 | pie += pie[1] + 2; |
| 697 | } |
| 698 | |
| 699 | ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->ch), ev->bssid, |
| 700 | le16_to_cpu(ev->listen_intvl), |
| 701 | le16_to_cpu(ev->beacon_intvl), |
| 702 | le32_to_cpu(ev->nw_type), |
| 703 | ev->beacon_ie_len, ev->assoc_req_len, |
| 704 | ev->assoc_resp_len, ev->assoc_info); |
| 705 | |
| 706 | return 0; |
| 707 | } |
| 708 | |
| 709 | static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 710 | { |
| 711 | struct wmi_disconnect_event *ev; |
| 712 | wmi->traffic_class = 100; |
| 713 | |
| 714 | if (len < sizeof(struct wmi_disconnect_event)) |
| 715 | return -EINVAL; |
| 716 | |
| 717 | ev = (struct wmi_disconnect_event *) datap; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 718 | |
| 719 | wmi->is_wmm_enabled = false; |
| 720 | wmi->pair_crypto_type = NONE_CRYPT; |
| 721 | wmi->grp_crypto_type = NONE_CRYPT; |
| 722 | |
| 723 | ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason, |
| 724 | ev->bssid, ev->assoc_resp_len, ev->assoc_info, |
| 725 | le16_to_cpu(ev->proto_reason_status)); |
| 726 | |
| 727 | return 0; |
| 728 | } |
| 729 | |
| 730 | static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 731 | { |
| 732 | struct wmi_peer_node_event *ev; |
| 733 | |
| 734 | if (len < sizeof(struct wmi_peer_node_event)) |
| 735 | return -EINVAL; |
| 736 | |
| 737 | ev = (struct wmi_peer_node_event *) datap; |
| 738 | |
| 739 | if (ev->event_code == PEER_NODE_JOIN_EVENT) |
| 740 | ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", |
| 741 | ev->peer_mac_addr); |
| 742 | else if (ev->event_code == PEER_NODE_LEAVE_EVENT) |
| 743 | ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", |
| 744 | ev->peer_mac_addr); |
| 745 | |
| 746 | return 0; |
| 747 | } |
| 748 | |
| 749 | static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 750 | { |
| 751 | struct wmi_tkip_micerr_event *ev; |
| 752 | |
| 753 | if (len < sizeof(struct wmi_tkip_micerr_event)) |
| 754 | return -EINVAL; |
| 755 | |
| 756 | ev = (struct wmi_tkip_micerr_event *) datap; |
| 757 | |
| 758 | ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast); |
| 759 | |
| 760 | return 0; |
| 761 | } |
| 762 | |
| 763 | static int ath6kl_wlan_parse_beacon(u8 *buf, int frame_len, |
| 764 | struct ath6kl_common_ie *cie) |
| 765 | { |
| 766 | u8 *frm, *efrm; |
| 767 | u8 elemid_ssid = false; |
| 768 | |
| 769 | frm = buf; |
| 770 | efrm = (u8 *) (frm + frame_len); |
| 771 | |
| 772 | /* |
| 773 | * beacon/probe response frame format |
| 774 | * [8] time stamp |
| 775 | * [2] beacon interval |
| 776 | * [2] capability information |
| 777 | * [tlv] ssid |
| 778 | * [tlv] supported rates |
| 779 | * [tlv] country information |
| 780 | * [tlv] parameter set (FH/DS) |
| 781 | * [tlv] erp information |
| 782 | * [tlv] extended supported rates |
| 783 | * [tlv] WMM |
| 784 | * [tlv] WPA or RSN |
| 785 | * [tlv] Atheros Advanced Capabilities |
| 786 | */ |
| 787 | if ((efrm - frm) < 12) |
| 788 | return -EINVAL; |
| 789 | |
| 790 | memset(cie, 0, sizeof(*cie)); |
| 791 | |
| 792 | cie->ie_tstamp = frm; |
| 793 | frm += 8; |
| 794 | cie->ie_beaconInt = *(u16 *) frm; |
| 795 | frm += 2; |
| 796 | cie->ie_capInfo = *(u16 *) frm; |
| 797 | frm += 2; |
| 798 | cie->ie_chan = 0; |
| 799 | |
| 800 | while (frm < efrm) { |
| 801 | switch (*frm) { |
| 802 | case WLAN_EID_SSID: |
| 803 | if (!elemid_ssid) { |
| 804 | cie->ie_ssid = frm; |
| 805 | elemid_ssid = true; |
| 806 | } |
| 807 | break; |
| 808 | case WLAN_EID_SUPP_RATES: |
| 809 | cie->ie_rates = frm; |
| 810 | break; |
| 811 | case WLAN_EID_COUNTRY: |
| 812 | cie->ie_country = frm; |
| 813 | break; |
| 814 | case WLAN_EID_FH_PARAMS: |
| 815 | break; |
| 816 | case WLAN_EID_DS_PARAMS: |
| 817 | cie->ie_chan = frm[2]; |
| 818 | break; |
| 819 | case WLAN_EID_TIM: |
| 820 | cie->ie_tim = frm; |
| 821 | break; |
| 822 | case WLAN_EID_IBSS_PARAMS: |
| 823 | break; |
| 824 | case WLAN_EID_EXT_SUPP_RATES: |
| 825 | cie->ie_xrates = frm; |
| 826 | break; |
| 827 | case WLAN_EID_ERP_INFO: |
| 828 | if (frm[1] != 1) |
| 829 | return -EINVAL; |
| 830 | |
| 831 | cie->ie_erp = frm[2]; |
| 832 | break; |
| 833 | case WLAN_EID_RSN: |
| 834 | cie->ie_rsn = frm; |
| 835 | break; |
| 836 | case WLAN_EID_HT_CAPABILITY: |
| 837 | cie->ie_htcap = frm; |
| 838 | break; |
| 839 | case WLAN_EID_HT_INFORMATION: |
| 840 | cie->ie_htop = frm; |
| 841 | break; |
| 842 | case WLAN_EID_VENDOR_SPECIFIC: |
| 843 | if (frm[1] > 3 && frm[2] == 0x00 && frm[3] == 0x50 && |
| 844 | frm[4] == 0xf2) { |
| 845 | /* OUT Type (00:50:F2) */ |
| 846 | |
| 847 | if (frm[5] == WPA_OUI_TYPE) { |
| 848 | /* WPA OUT */ |
| 849 | cie->ie_wpa = frm; |
| 850 | } else if (frm[5] == WMM_OUI_TYPE) { |
| 851 | /* WMM OUT */ |
| 852 | cie->ie_wmm = frm; |
| 853 | } else if (frm[5] == WSC_OUT_TYPE) { |
| 854 | /* WSC OUT */ |
| 855 | cie->ie_wsc = frm; |
| 856 | } |
| 857 | |
| 858 | } else if (frm[1] > 3 && frm[2] == 0x00 |
| 859 | && frm[3] == 0x03 && frm[4] == 0x7f |
| 860 | && frm[5] == ATH_OUI_TYPE) { |
| 861 | /* Atheros OUI (00:03:7f) */ |
| 862 | cie->ie_ath = frm; |
| 863 | } |
| 864 | break; |
| 865 | default: |
| 866 | break; |
| 867 | } |
| 868 | frm += frm[1] + 2; |
| 869 | } |
| 870 | |
| 871 | if ((cie->ie_rates == NULL) |
| 872 | || (cie->ie_rates[1] > ATH6KL_RATE_MAXSIZE)) |
| 873 | return -EINVAL; |
| 874 | |
| 875 | if ((cie->ie_ssid == NULL) |
| 876 | || (cie->ie_ssid[1] > IEEE80211_MAX_SSID_LEN)) |
| 877 | return -EINVAL; |
| 878 | |
| 879 | return 0; |
| 880 | } |
| 881 | |
| 882 | static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 883 | { |
| 884 | struct bss *bss = NULL; |
| 885 | struct wmi_bss_info_hdr *bih; |
| 886 | u8 cached_ssid_len = 0; |
| 887 | u8 cached_ssid[IEEE80211_MAX_SSID_LEN] = { 0 }; |
| 888 | u8 beacon_ssid_len = 0; |
| 889 | u8 *buf, *ie_ssid; |
| 890 | u8 *ni_buf; |
| 891 | int buf_len; |
| 892 | |
| 893 | int ret; |
| 894 | |
| 895 | if (len <= sizeof(struct wmi_bss_info_hdr)) |
| 896 | return -EINVAL; |
| 897 | |
| 898 | bih = (struct wmi_bss_info_hdr *) datap; |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 899 | bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 900 | |
| 901 | if (a_sle16_to_cpu(bih->rssi) > 0) { |
| 902 | if (bss == NULL) |
| 903 | return 0; |
| 904 | else |
| 905 | bih->rssi = a_cpu_to_sle16(bss->ni_rssi); |
| 906 | } |
| 907 | |
| 908 | buf = datap + sizeof(struct wmi_bss_info_hdr); |
| 909 | len -= sizeof(struct wmi_bss_info_hdr); |
| 910 | |
| 911 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 912 | "bss info evt - ch %u, rssi %02x, bssid \"%pM\"\n", |
| 913 | bih->ch, a_sle16_to_cpu(bih->rssi), bih->bssid); |
| 914 | |
| 915 | if (bss != NULL) { |
| 916 | /* |
| 917 | * Free up the node. We are about to allocate a new node. |
| 918 | * In case of hidden AP, beacon will not have ssid, |
| 919 | * but a directed probe response will have it, |
| 920 | * so cache the probe-resp-ssid if already present. |
| 921 | */ |
| 922 | if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE)) { |
| 923 | ie_ssid = bss->ni_cie.ie_ssid; |
| 924 | if (ie_ssid && (ie_ssid[1] <= IEEE80211_MAX_SSID_LEN) && |
| 925 | (ie_ssid[2] != 0)) { |
| 926 | cached_ssid_len = ie_ssid[1]; |
| 927 | memcpy(cached_ssid, ie_ssid + 2, |
| 928 | cached_ssid_len); |
| 929 | } |
| 930 | } |
| 931 | |
| 932 | /* |
| 933 | * Use the current average rssi of associated AP base on |
| 934 | * assumption |
| 935 | * 1. Most os with GUI will update RSSI by |
| 936 | * ath6kl_wmi_get_stats_cmd() periodically. |
| 937 | * 2. ath6kl_wmi_get_stats_cmd(..) will be called when calling |
| 938 | * ath6kl_wmi_startscan_cmd(...) |
| 939 | * The average value of RSSI give end-user better feeling for |
| 940 | * instance value of scan result. It also sync up RSSI info |
| 941 | * in GUI between scan result and RSSI signal icon. |
| 942 | */ |
Vasanthakumar Thiagarajan | 70df051 | 2011-07-21 14:09:07 +0530 | [diff] [blame] | 943 | if (memcmp(wmi->parent_dev->bssid, bih->bssid, ETH_ALEN) == 0) { |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 944 | bih->rssi = a_cpu_to_sle16(bss->ni_rssi); |
| 945 | bih->snr = bss->ni_snr; |
| 946 | } |
| 947 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 948 | wlan_node_reclaim(&wmi->parent_dev->scan_table, bss); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | /* |
| 952 | * beacon/probe response frame format |
| 953 | * [8] time stamp |
| 954 | * [2] beacon interval |
| 955 | * [2] capability information |
| 956 | * [tlv] ssid |
| 957 | */ |
| 958 | beacon_ssid_len = buf[SSID_IE_LEN_INDEX]; |
| 959 | |
| 960 | /* |
| 961 | * If ssid is cached for this hidden AP, then change |
| 962 | * buffer len accordingly. |
| 963 | */ |
| 964 | if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && |
| 965 | (cached_ssid_len != 0) && |
| 966 | (beacon_ssid_len == 0 || (cached_ssid_len > beacon_ssid_len && |
| 967 | buf[SSID_IE_LEN_INDEX + 1] == 0))) { |
| 968 | |
| 969 | len += (cached_ssid_len - beacon_ssid_len); |
| 970 | } |
| 971 | |
| 972 | bss = wlan_node_alloc(len); |
| 973 | if (!bss) |
| 974 | return -ENOMEM; |
| 975 | |
| 976 | bss->ni_snr = bih->snr; |
| 977 | bss->ni_rssi = a_sle16_to_cpu(bih->rssi); |
| 978 | |
| 979 | if (WARN_ON(!bss->ni_buf)) |
| 980 | return -EINVAL; |
| 981 | |
| 982 | /* |
| 983 | * In case of hidden AP, beacon will not have ssid, |
| 984 | * but a directed probe response will have it, |
| 985 | * so place the cached-ssid(probe-resp) in the bss info. |
| 986 | */ |
| 987 | if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && |
| 988 | (cached_ssid_len != 0) && |
| 989 | (beacon_ssid_len == 0 || (beacon_ssid_len && |
| 990 | buf[SSID_IE_LEN_INDEX + 1] == 0))) { |
| 991 | ni_buf = bss->ni_buf; |
| 992 | buf_len = len; |
| 993 | |
| 994 | /* |
| 995 | * Copy the first 14 bytes: |
| 996 | * time-stamp(8), beacon-interval(2), |
| 997 | * cap-info(2), ssid-id(1), ssid-len(1). |
| 998 | */ |
| 999 | memcpy(ni_buf, buf, SSID_IE_LEN_INDEX + 1); |
| 1000 | |
| 1001 | ni_buf[SSID_IE_LEN_INDEX] = cached_ssid_len; |
| 1002 | ni_buf += (SSID_IE_LEN_INDEX + 1); |
| 1003 | |
| 1004 | buf += (SSID_IE_LEN_INDEX + 1); |
| 1005 | buf_len -= (SSID_IE_LEN_INDEX + 1); |
| 1006 | |
| 1007 | memcpy(ni_buf, cached_ssid, cached_ssid_len); |
| 1008 | ni_buf += cached_ssid_len; |
| 1009 | |
| 1010 | buf += beacon_ssid_len; |
| 1011 | buf_len -= beacon_ssid_len; |
| 1012 | |
| 1013 | if (cached_ssid_len > beacon_ssid_len) |
| 1014 | buf_len -= (cached_ssid_len - beacon_ssid_len); |
| 1015 | |
| 1016 | memcpy(ni_buf, buf, buf_len); |
| 1017 | } else |
| 1018 | memcpy(bss->ni_buf, buf, len); |
| 1019 | |
| 1020 | bss->ni_framelen = len; |
| 1021 | |
| 1022 | ret = ath6kl_wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie); |
| 1023 | if (ret) { |
| 1024 | wlan_node_free(bss); |
| 1025 | return -EINVAL; |
| 1026 | } |
| 1027 | |
| 1028 | /* |
| 1029 | * Update the frequency in ie_chan, overwriting of channel number |
| 1030 | * which is done in ath6kl_wlan_parse_beacon |
| 1031 | */ |
| 1032 | bss->ni_cie.ie_chan = le16_to_cpu(bih->ch); |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 1033 | wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1034 | |
| 1035 | return 0; |
| 1036 | } |
| 1037 | |
| 1038 | static int ath6kl_wmi_opt_frame_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1039 | { |
| 1040 | struct bss *bss; |
| 1041 | struct wmi_opt_rx_info_hdr *bih; |
| 1042 | u8 *buf; |
| 1043 | |
| 1044 | if (len <= sizeof(struct wmi_opt_rx_info_hdr)) |
| 1045 | return -EINVAL; |
| 1046 | |
| 1047 | bih = (struct wmi_opt_rx_info_hdr *) datap; |
| 1048 | buf = datap + sizeof(struct wmi_opt_rx_info_hdr); |
| 1049 | len -= sizeof(struct wmi_opt_rx_info_hdr); |
| 1050 | |
| 1051 | ath6kl_dbg(ATH6KL_DBG_WMI, "opt frame event %2.2x:%2.2x\n", |
| 1052 | bih->bssid[4], bih->bssid[5]); |
| 1053 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 1054 | bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1055 | if (bss != NULL) { |
| 1056 | /* Free up the node. We are about to allocate a new node. */ |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 1057 | wlan_node_reclaim(&wmi->parent_dev->scan_table, bss); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1058 | } |
| 1059 | |
| 1060 | bss = wlan_node_alloc(len); |
| 1061 | if (!bss) |
| 1062 | return -ENOMEM; |
| 1063 | |
| 1064 | bss->ni_snr = bih->snr; |
| 1065 | bss->ni_cie.ie_chan = le16_to_cpu(bih->ch); |
| 1066 | |
| 1067 | if (WARN_ON(!bss->ni_buf)) |
| 1068 | return -EINVAL; |
| 1069 | |
| 1070 | memcpy(bss->ni_buf, buf, len); |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 1071 | wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1072 | |
| 1073 | return 0; |
| 1074 | } |
| 1075 | |
| 1076 | /* Inactivity timeout of a fatpipe(pstream) at the target */ |
| 1077 | static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, |
| 1078 | int len) |
| 1079 | { |
| 1080 | struct wmi_pstream_timeout_event *ev; |
| 1081 | |
| 1082 | if (len < sizeof(struct wmi_pstream_timeout_event)) |
| 1083 | return -EINVAL; |
| 1084 | |
| 1085 | ev = (struct wmi_pstream_timeout_event *) datap; |
| 1086 | |
| 1087 | /* |
| 1088 | * When the pstream (fat pipe == AC) timesout, it means there were |
| 1089 | * no thinStreams within this pstream & it got implicitly created |
| 1090 | * due to data flow on this AC. We start the inactivity timer only |
| 1091 | * for implicitly created pstream. Just reset the host state. |
| 1092 | */ |
| 1093 | spin_lock_bh(&wmi->lock); |
| 1094 | wmi->stream_exist_for_ac[ev->traffic_class] = 0; |
| 1095 | wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); |
| 1096 | spin_unlock_bh(&wmi->lock); |
| 1097 | |
| 1098 | /* Indicate inactivity to driver layer for this fatpipe (pstream) */ |
| 1099 | ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); |
| 1100 | |
| 1101 | return 0; |
| 1102 | } |
| 1103 | |
| 1104 | static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1105 | { |
| 1106 | struct wmi_bit_rate_reply *reply; |
| 1107 | s32 rate; |
| 1108 | u32 sgi, index; |
| 1109 | |
| 1110 | if (len < sizeof(struct wmi_bit_rate_reply)) |
| 1111 | return -EINVAL; |
| 1112 | |
| 1113 | reply = (struct wmi_bit_rate_reply *) datap; |
| 1114 | |
| 1115 | ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); |
| 1116 | |
| 1117 | if (reply->rate_index == (s8) RATE_AUTO) { |
| 1118 | rate = RATE_AUTO; |
| 1119 | } else { |
| 1120 | index = reply->rate_index & 0x7f; |
| 1121 | sgi = (reply->rate_index & 0x80) ? 1 : 0; |
| 1122 | rate = wmi_rate_tbl[index][sgi]; |
| 1123 | } |
| 1124 | |
| 1125 | ath6kl_wakeup_event(wmi->parent_dev); |
| 1126 | |
| 1127 | return 0; |
| 1128 | } |
| 1129 | |
| 1130 | static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1131 | { |
| 1132 | if (len < sizeof(struct wmi_fix_rates_reply)) |
| 1133 | return -EINVAL; |
| 1134 | |
| 1135 | ath6kl_wakeup_event(wmi->parent_dev); |
| 1136 | |
| 1137 | return 0; |
| 1138 | } |
| 1139 | |
| 1140 | static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1141 | { |
| 1142 | if (len < sizeof(struct wmi_channel_list_reply)) |
| 1143 | return -EINVAL; |
| 1144 | |
| 1145 | ath6kl_wakeup_event(wmi->parent_dev); |
| 1146 | |
| 1147 | return 0; |
| 1148 | } |
| 1149 | |
| 1150 | static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1151 | { |
| 1152 | struct wmi_tx_pwr_reply *reply; |
| 1153 | |
| 1154 | if (len < sizeof(struct wmi_tx_pwr_reply)) |
| 1155 | return -EINVAL; |
| 1156 | |
| 1157 | reply = (struct wmi_tx_pwr_reply *) datap; |
| 1158 | ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); |
| 1159 | |
| 1160 | return 0; |
| 1161 | } |
| 1162 | |
| 1163 | static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 1164 | { |
| 1165 | if (len < sizeof(struct wmi_get_keepalive_cmd)) |
| 1166 | return -EINVAL; |
| 1167 | |
| 1168 | ath6kl_wakeup_event(wmi->parent_dev); |
| 1169 | |
| 1170 | return 0; |
| 1171 | } |
| 1172 | |
| 1173 | static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len) |
| 1174 | { |
| 1175 | struct wmi_scan_complete_event *ev; |
| 1176 | |
| 1177 | ev = (struct wmi_scan_complete_event *) datap; |
| 1178 | |
| 1179 | if (a_sle32_to_cpu(ev->status) == 0) |
Vasanthakumar Thiagarajan | e4c7ffc | 2011-07-21 13:49:32 +0530 | [diff] [blame] | 1180 | wlan_refresh_inactive_nodes(wmi->parent_dev); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1181 | |
| 1182 | ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status)); |
| 1183 | wmi->is_probe_ssid = false; |
| 1184 | |
| 1185 | return 0; |
| 1186 | } |
| 1187 | |
| 1188 | /* |
| 1189 | * Target is reporting a programming error. This is for |
| 1190 | * developer aid only. Target only checks a few common violations |
| 1191 | * and it is responsibility of host to do all error checking. |
| 1192 | * Behavior of target after wmi error event is undefined. |
| 1193 | * A reset is recommended. |
| 1194 | */ |
| 1195 | static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1196 | { |
| 1197 | const char *type = "unknown error"; |
| 1198 | struct wmi_cmd_error_event *ev; |
| 1199 | ev = (struct wmi_cmd_error_event *) datap; |
| 1200 | |
| 1201 | switch (ev->err_code) { |
| 1202 | case INVALID_PARAM: |
| 1203 | type = "invalid parameter"; |
| 1204 | break; |
| 1205 | case ILLEGAL_STATE: |
| 1206 | type = "invalid state"; |
| 1207 | break; |
| 1208 | case INTERNAL_ERROR: |
| 1209 | type = "internal error"; |
| 1210 | break; |
| 1211 | } |
| 1212 | |
| 1213 | ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", |
| 1214 | ev->cmd_id, type); |
| 1215 | |
| 1216 | return 0; |
| 1217 | } |
| 1218 | |
| 1219 | static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1220 | { |
| 1221 | ath6kl_tgt_stats_event(wmi->parent_dev, datap, len); |
| 1222 | |
| 1223 | return 0; |
| 1224 | } |
| 1225 | |
| 1226 | static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, |
| 1227 | struct sq_threshold_params *sq_thresh, |
| 1228 | u32 size) |
| 1229 | { |
| 1230 | u32 index; |
| 1231 | u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; |
| 1232 | |
| 1233 | /* The list is already in sorted order. Get the next lower value */ |
| 1234 | for (index = 0; index < size; index++) { |
| 1235 | if (rssi < sq_thresh->upper_threshold[index]) { |
| 1236 | threshold = (u8) sq_thresh->upper_threshold[index]; |
| 1237 | break; |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | return threshold; |
| 1242 | } |
| 1243 | |
| 1244 | static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, |
| 1245 | struct sq_threshold_params *sq_thresh, |
| 1246 | u32 size) |
| 1247 | { |
| 1248 | u32 index; |
| 1249 | u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; |
| 1250 | |
| 1251 | /* The list is already in sorted order. Get the next lower value */ |
| 1252 | for (index = 0; index < size; index++) { |
| 1253 | if (rssi > sq_thresh->lower_threshold[index]) { |
| 1254 | threshold = (u8) sq_thresh->lower_threshold[index]; |
| 1255 | break; |
| 1256 | } |
| 1257 | } |
| 1258 | |
| 1259 | return threshold; |
| 1260 | } |
| 1261 | |
| 1262 | static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, |
| 1263 | struct wmi_rssi_threshold_params_cmd *rssi_cmd) |
| 1264 | { |
| 1265 | struct sk_buff *skb; |
| 1266 | struct wmi_rssi_threshold_params_cmd *cmd; |
| 1267 | |
| 1268 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1269 | if (!skb) |
| 1270 | return -ENOMEM; |
| 1271 | |
| 1272 | cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; |
| 1273 | memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); |
| 1274 | |
| 1275 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, |
| 1276 | NO_SYNC_WMIFLAG); |
| 1277 | } |
| 1278 | |
| 1279 | static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, |
| 1280 | int len) |
| 1281 | { |
| 1282 | struct wmi_rssi_threshold_event *reply; |
| 1283 | struct wmi_rssi_threshold_params_cmd cmd; |
| 1284 | struct sq_threshold_params *sq_thresh; |
| 1285 | enum wmi_rssi_threshold_val new_threshold; |
| 1286 | u8 upper_rssi_threshold, lower_rssi_threshold; |
| 1287 | s16 rssi; |
| 1288 | int ret; |
| 1289 | |
| 1290 | if (len < sizeof(struct wmi_rssi_threshold_event)) |
| 1291 | return -EINVAL; |
| 1292 | |
| 1293 | reply = (struct wmi_rssi_threshold_event *) datap; |
| 1294 | new_threshold = (enum wmi_rssi_threshold_val) reply->range; |
| 1295 | rssi = a_sle16_to_cpu(reply->rssi); |
| 1296 | |
| 1297 | sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; |
| 1298 | |
| 1299 | /* |
| 1300 | * Identify the threshold breached and communicate that to the app. |
| 1301 | * After that install a new set of thresholds based on the signal |
| 1302 | * quality reported by the target |
| 1303 | */ |
| 1304 | if (new_threshold) { |
| 1305 | /* Upper threshold breached */ |
| 1306 | if (rssi < sq_thresh->upper_threshold[0]) { |
| 1307 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1308 | "spurious upper rssi threshold event: %d\n", |
| 1309 | rssi); |
| 1310 | } else if ((rssi < sq_thresh->upper_threshold[1]) && |
| 1311 | (rssi >= sq_thresh->upper_threshold[0])) { |
| 1312 | new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; |
| 1313 | } else if ((rssi < sq_thresh->upper_threshold[2]) && |
| 1314 | (rssi >= sq_thresh->upper_threshold[1])) { |
| 1315 | new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; |
| 1316 | } else if ((rssi < sq_thresh->upper_threshold[3]) && |
| 1317 | (rssi >= sq_thresh->upper_threshold[2])) { |
| 1318 | new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; |
| 1319 | } else if ((rssi < sq_thresh->upper_threshold[4]) && |
| 1320 | (rssi >= sq_thresh->upper_threshold[3])) { |
| 1321 | new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; |
| 1322 | } else if ((rssi < sq_thresh->upper_threshold[5]) && |
| 1323 | (rssi >= sq_thresh->upper_threshold[4])) { |
| 1324 | new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; |
| 1325 | } else if (rssi >= sq_thresh->upper_threshold[5]) { |
| 1326 | new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; |
| 1327 | } |
| 1328 | } else { |
| 1329 | /* Lower threshold breached */ |
| 1330 | if (rssi > sq_thresh->lower_threshold[0]) { |
| 1331 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1332 | "spurious lower rssi threshold event: %d %d\n", |
| 1333 | rssi, sq_thresh->lower_threshold[0]); |
| 1334 | } else if ((rssi > sq_thresh->lower_threshold[1]) && |
| 1335 | (rssi <= sq_thresh->lower_threshold[0])) { |
| 1336 | new_threshold = WMI_RSSI_THRESHOLD6_BELOW; |
| 1337 | } else if ((rssi > sq_thresh->lower_threshold[2]) && |
| 1338 | (rssi <= sq_thresh->lower_threshold[1])) { |
| 1339 | new_threshold = WMI_RSSI_THRESHOLD5_BELOW; |
| 1340 | } else if ((rssi > sq_thresh->lower_threshold[3]) && |
| 1341 | (rssi <= sq_thresh->lower_threshold[2])) { |
| 1342 | new_threshold = WMI_RSSI_THRESHOLD4_BELOW; |
| 1343 | } else if ((rssi > sq_thresh->lower_threshold[4]) && |
| 1344 | (rssi <= sq_thresh->lower_threshold[3])) { |
| 1345 | new_threshold = WMI_RSSI_THRESHOLD3_BELOW; |
| 1346 | } else if ((rssi > sq_thresh->lower_threshold[5]) && |
| 1347 | (rssi <= sq_thresh->lower_threshold[4])) { |
| 1348 | new_threshold = WMI_RSSI_THRESHOLD2_BELOW; |
| 1349 | } else if (rssi <= sq_thresh->lower_threshold[5]) { |
| 1350 | new_threshold = WMI_RSSI_THRESHOLD1_BELOW; |
| 1351 | } |
| 1352 | } |
| 1353 | |
| 1354 | /* Calculate and install the next set of thresholds */ |
| 1355 | lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, |
| 1356 | sq_thresh->lower_threshold_valid_count); |
| 1357 | upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, |
| 1358 | sq_thresh->upper_threshold_valid_count); |
| 1359 | |
| 1360 | /* Issue a wmi command to install the thresholds */ |
| 1361 | cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); |
| 1362 | cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); |
| 1363 | cmd.weight = sq_thresh->weight; |
| 1364 | cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); |
| 1365 | |
| 1366 | ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); |
| 1367 | if (ret) { |
| 1368 | ath6kl_err("unable to configure rssi thresholds\n"); |
| 1369 | return -EIO; |
| 1370 | } |
| 1371 | |
| 1372 | return 0; |
| 1373 | } |
| 1374 | |
| 1375 | static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1376 | { |
| 1377 | struct wmi_cac_event *reply; |
| 1378 | struct ieee80211_tspec_ie *ts; |
| 1379 | u16 active_tsids, tsinfo; |
| 1380 | u8 tsid, index; |
| 1381 | u8 ts_id; |
| 1382 | |
| 1383 | if (len < sizeof(struct wmi_cac_event)) |
| 1384 | return -EINVAL; |
| 1385 | |
| 1386 | reply = (struct wmi_cac_event *) datap; |
| 1387 | |
| 1388 | if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && |
| 1389 | (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { |
| 1390 | |
| 1391 | ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); |
| 1392 | tsinfo = le16_to_cpu(ts->tsinfo); |
| 1393 | tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & |
| 1394 | IEEE80211_WMM_IE_TSPEC_TID_MASK; |
| 1395 | |
| 1396 | ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid); |
| 1397 | } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { |
| 1398 | /* |
| 1399 | * Following assumes that there is only one outstanding |
| 1400 | * ADDTS request when this event is received |
| 1401 | */ |
| 1402 | spin_lock_bh(&wmi->lock); |
| 1403 | active_tsids = wmi->stream_exist_for_ac[reply->ac]; |
| 1404 | spin_unlock_bh(&wmi->lock); |
| 1405 | |
| 1406 | for (index = 0; index < sizeof(active_tsids) * 8; index++) { |
| 1407 | if ((active_tsids >> index) & 1) |
| 1408 | break; |
| 1409 | } |
| 1410 | if (index < (sizeof(active_tsids) * 8)) |
| 1411 | ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index); |
| 1412 | } |
| 1413 | |
| 1414 | /* |
| 1415 | * Clear active tsids and Add missing handling |
| 1416 | * for delete qos stream from AP |
| 1417 | */ |
| 1418 | else if (reply->cac_indication == CAC_INDICATION_DELETE) { |
| 1419 | |
| 1420 | ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); |
| 1421 | tsinfo = le16_to_cpu(ts->tsinfo); |
| 1422 | ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & |
| 1423 | IEEE80211_WMM_IE_TSPEC_TID_MASK); |
| 1424 | |
| 1425 | spin_lock_bh(&wmi->lock); |
| 1426 | wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); |
| 1427 | active_tsids = wmi->stream_exist_for_ac[reply->ac]; |
| 1428 | spin_unlock_bh(&wmi->lock); |
| 1429 | |
| 1430 | /* Indicate stream inactivity to driver layer only if all tsids |
| 1431 | * within this AC are deleted. |
| 1432 | */ |
| 1433 | if (!active_tsids) { |
| 1434 | ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, |
| 1435 | false); |
| 1436 | wmi->fat_pipe_exist &= ~(1 << reply->ac); |
| 1437 | } |
| 1438 | } |
| 1439 | |
| 1440 | return 0; |
| 1441 | } |
| 1442 | |
| 1443 | static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, |
| 1444 | struct wmi_snr_threshold_params_cmd *snr_cmd) |
| 1445 | { |
| 1446 | struct sk_buff *skb; |
| 1447 | struct wmi_snr_threshold_params_cmd *cmd; |
| 1448 | |
| 1449 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1450 | if (!skb) |
| 1451 | return -ENOMEM; |
| 1452 | |
| 1453 | cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; |
| 1454 | memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); |
| 1455 | |
| 1456 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, |
| 1457 | NO_SYNC_WMIFLAG); |
| 1458 | } |
| 1459 | |
| 1460 | static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, |
| 1461 | int len) |
| 1462 | { |
| 1463 | struct wmi_snr_threshold_event *reply; |
| 1464 | struct sq_threshold_params *sq_thresh; |
| 1465 | struct wmi_snr_threshold_params_cmd cmd; |
| 1466 | enum wmi_snr_threshold_val new_threshold; |
| 1467 | u8 upper_snr_threshold, lower_snr_threshold; |
| 1468 | s16 snr; |
| 1469 | int ret; |
| 1470 | |
| 1471 | if (len < sizeof(struct wmi_snr_threshold_event)) |
| 1472 | return -EINVAL; |
| 1473 | |
| 1474 | reply = (struct wmi_snr_threshold_event *) datap; |
| 1475 | |
| 1476 | new_threshold = (enum wmi_snr_threshold_val) reply->range; |
| 1477 | snr = reply->snr; |
| 1478 | |
| 1479 | sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; |
| 1480 | |
| 1481 | /* |
| 1482 | * Identify the threshold breached and communicate that to the app. |
| 1483 | * After that install a new set of thresholds based on the signal |
| 1484 | * quality reported by the target. |
| 1485 | */ |
| 1486 | if (new_threshold) { |
| 1487 | /* Upper threshold breached */ |
| 1488 | if (snr < sq_thresh->upper_threshold[0]) { |
| 1489 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1490 | "spurious upper snr threshold event: %d\n", |
| 1491 | snr); |
| 1492 | } else if ((snr < sq_thresh->upper_threshold[1]) && |
| 1493 | (snr >= sq_thresh->upper_threshold[0])) { |
| 1494 | new_threshold = WMI_SNR_THRESHOLD1_ABOVE; |
| 1495 | } else if ((snr < sq_thresh->upper_threshold[2]) && |
| 1496 | (snr >= sq_thresh->upper_threshold[1])) { |
| 1497 | new_threshold = WMI_SNR_THRESHOLD2_ABOVE; |
| 1498 | } else if ((snr < sq_thresh->upper_threshold[3]) && |
| 1499 | (snr >= sq_thresh->upper_threshold[2])) { |
| 1500 | new_threshold = WMI_SNR_THRESHOLD3_ABOVE; |
| 1501 | } else if (snr >= sq_thresh->upper_threshold[3]) { |
| 1502 | new_threshold = WMI_SNR_THRESHOLD4_ABOVE; |
| 1503 | } |
| 1504 | } else { |
| 1505 | /* Lower threshold breached */ |
| 1506 | if (snr > sq_thresh->lower_threshold[0]) { |
| 1507 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1508 | "spurious lower snr threshold event: %d\n", |
| 1509 | sq_thresh->lower_threshold[0]); |
| 1510 | } else if ((snr > sq_thresh->lower_threshold[1]) && |
| 1511 | (snr <= sq_thresh->lower_threshold[0])) { |
| 1512 | new_threshold = WMI_SNR_THRESHOLD4_BELOW; |
| 1513 | } else if ((snr > sq_thresh->lower_threshold[2]) && |
| 1514 | (snr <= sq_thresh->lower_threshold[1])) { |
| 1515 | new_threshold = WMI_SNR_THRESHOLD3_BELOW; |
| 1516 | } else if ((snr > sq_thresh->lower_threshold[3]) && |
| 1517 | (snr <= sq_thresh->lower_threshold[2])) { |
| 1518 | new_threshold = WMI_SNR_THRESHOLD2_BELOW; |
| 1519 | } else if (snr <= sq_thresh->lower_threshold[3]) { |
| 1520 | new_threshold = WMI_SNR_THRESHOLD1_BELOW; |
| 1521 | } |
| 1522 | } |
| 1523 | |
| 1524 | /* Calculate and install the next set of thresholds */ |
| 1525 | lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, |
| 1526 | sq_thresh->lower_threshold_valid_count); |
| 1527 | upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, |
| 1528 | sq_thresh->upper_threshold_valid_count); |
| 1529 | |
| 1530 | /* Issue a wmi command to install the thresholds */ |
| 1531 | cmd.thresh_above1_val = upper_snr_threshold; |
| 1532 | cmd.thresh_below1_val = lower_snr_threshold; |
| 1533 | cmd.weight = sq_thresh->weight; |
| 1534 | cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); |
| 1535 | |
| 1536 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1537 | "snr: %d, threshold: %d, lower: %d, upper: %d\n", |
| 1538 | snr, new_threshold, |
| 1539 | lower_snr_threshold, upper_snr_threshold); |
| 1540 | |
| 1541 | ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); |
| 1542 | if (ret) { |
| 1543 | ath6kl_err("unable to configure snr threshold\n"); |
| 1544 | return -EIO; |
| 1545 | } |
| 1546 | |
| 1547 | return 0; |
| 1548 | } |
| 1549 | |
| 1550 | static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1551 | { |
| 1552 | u16 ap_info_entry_size; |
| 1553 | struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; |
| 1554 | struct wmi_ap_info_v1 *ap_info_v1; |
| 1555 | u8 index; |
| 1556 | |
| 1557 | if (len < sizeof(struct wmi_aplist_event) || |
| 1558 | ev->ap_list_ver != APLIST_VER1) |
| 1559 | return -EINVAL; |
| 1560 | |
| 1561 | ap_info_entry_size = sizeof(struct wmi_ap_info_v1); |
| 1562 | ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; |
| 1563 | |
| 1564 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1565 | "number of APs in aplist event: %d\n", ev->num_ap); |
| 1566 | |
| 1567 | if (len < (int) (sizeof(struct wmi_aplist_event) + |
| 1568 | (ev->num_ap - 1) * ap_info_entry_size)) |
| 1569 | return -EINVAL; |
| 1570 | |
| 1571 | /* AP list version 1 contents */ |
| 1572 | for (index = 0; index < ev->num_ap; index++) { |
| 1573 | ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", |
| 1574 | index, ap_info_v1->bssid, ap_info_v1->channel); |
| 1575 | ap_info_v1++; |
| 1576 | } |
| 1577 | |
| 1578 | return 0; |
| 1579 | } |
| 1580 | |
| 1581 | int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, |
| 1582 | enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) |
| 1583 | { |
| 1584 | struct wmi_cmd_hdr *cmd_hdr; |
| 1585 | enum htc_endpoint_id ep_id = wmi->ep_id; |
| 1586 | int ret; |
| 1587 | |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 1588 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: cmd_id=%d\n", __func__, cmd_id); |
| 1589 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1590 | if (WARN_ON(skb == NULL)) |
| 1591 | return -EINVAL; |
| 1592 | |
| 1593 | if (sync_flag >= END_WMIFLAG) { |
| 1594 | dev_kfree_skb(skb); |
| 1595 | return -EINVAL; |
| 1596 | } |
| 1597 | |
| 1598 | if ((sync_flag == SYNC_BEFORE_WMIFLAG) || |
| 1599 | (sync_flag == SYNC_BOTH_WMIFLAG)) { |
| 1600 | /* |
| 1601 | * Make sure all data currently queued is transmitted before |
| 1602 | * the cmd execution. Establish a new sync point. |
| 1603 | */ |
| 1604 | ath6kl_wmi_sync_point(wmi); |
| 1605 | } |
| 1606 | |
| 1607 | skb_push(skb, sizeof(struct wmi_cmd_hdr)); |
| 1608 | |
| 1609 | cmd_hdr = (struct wmi_cmd_hdr *) skb->data; |
| 1610 | cmd_hdr->cmd_id = cpu_to_le16(cmd_id); |
| 1611 | cmd_hdr->info1 = 0; /* added for virtual interface */ |
| 1612 | |
| 1613 | /* Only for OPT_TX_CMD, use BE endpoint. */ |
| 1614 | if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { |
| 1615 | ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, |
| 1616 | false, false, 0, NULL); |
| 1617 | if (ret) { |
| 1618 | dev_kfree_skb(skb); |
| 1619 | return ret; |
| 1620 | } |
| 1621 | ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); |
| 1622 | } |
| 1623 | |
| 1624 | ath6kl_control_tx(wmi->parent_dev, skb, ep_id); |
| 1625 | |
| 1626 | if ((sync_flag == SYNC_AFTER_WMIFLAG) || |
| 1627 | (sync_flag == SYNC_BOTH_WMIFLAG)) { |
| 1628 | /* |
| 1629 | * Make sure all new data queued waits for the command to |
| 1630 | * execute. Establish a new sync point. |
| 1631 | */ |
| 1632 | ath6kl_wmi_sync_point(wmi); |
| 1633 | } |
| 1634 | |
| 1635 | return 0; |
| 1636 | } |
| 1637 | |
| 1638 | int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, |
| 1639 | enum dot11_auth_mode dot11_auth_mode, |
| 1640 | enum auth_mode auth_mode, |
| 1641 | enum crypto_type pairwise_crypto, |
| 1642 | u8 pairwise_crypto_len, |
| 1643 | enum crypto_type group_crypto, |
| 1644 | u8 group_crypto_len, int ssid_len, u8 *ssid, |
| 1645 | u8 *bssid, u16 channel, u32 ctrl_flags) |
| 1646 | { |
| 1647 | struct sk_buff *skb; |
| 1648 | struct wmi_connect_cmd *cc; |
| 1649 | int ret; |
| 1650 | |
| 1651 | wmi->traffic_class = 100; |
| 1652 | |
| 1653 | if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) |
| 1654 | return -EINVAL; |
| 1655 | |
| 1656 | if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) |
| 1657 | return -EINVAL; |
| 1658 | |
| 1659 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); |
| 1660 | if (!skb) |
| 1661 | return -ENOMEM; |
| 1662 | |
| 1663 | cc = (struct wmi_connect_cmd *) skb->data; |
| 1664 | |
| 1665 | if (ssid_len) |
| 1666 | memcpy(cc->ssid, ssid, ssid_len); |
| 1667 | |
| 1668 | cc->ssid_len = ssid_len; |
| 1669 | cc->nw_type = nw_type; |
| 1670 | cc->dot11_auth_mode = dot11_auth_mode; |
| 1671 | cc->auth_mode = auth_mode; |
| 1672 | cc->prwise_crypto_type = pairwise_crypto; |
| 1673 | cc->prwise_crypto_len = pairwise_crypto_len; |
| 1674 | cc->grp_crypto_type = group_crypto; |
| 1675 | cc->grp_crypto_len = group_crypto_len; |
| 1676 | cc->ch = cpu_to_le16(channel); |
| 1677 | cc->ctrl_flags = cpu_to_le32(ctrl_flags); |
| 1678 | |
| 1679 | if (bssid != NULL) |
| 1680 | memcpy(cc->bssid, bssid, ETH_ALEN); |
| 1681 | |
| 1682 | wmi->pair_crypto_type = pairwise_crypto; |
| 1683 | wmi->grp_crypto_type = group_crypto; |
| 1684 | |
| 1685 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG); |
| 1686 | |
| 1687 | return ret; |
| 1688 | } |
| 1689 | |
| 1690 | int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel) |
| 1691 | { |
| 1692 | struct sk_buff *skb; |
| 1693 | struct wmi_reconnect_cmd *cc; |
| 1694 | int ret; |
| 1695 | |
| 1696 | wmi->traffic_class = 100; |
| 1697 | |
| 1698 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); |
| 1699 | if (!skb) |
| 1700 | return -ENOMEM; |
| 1701 | |
| 1702 | cc = (struct wmi_reconnect_cmd *) skb->data; |
| 1703 | cc->channel = cpu_to_le16(channel); |
| 1704 | |
| 1705 | if (bssid != NULL) |
| 1706 | memcpy(cc->bssid, bssid, ETH_ALEN); |
| 1707 | |
| 1708 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID, |
| 1709 | NO_SYNC_WMIFLAG); |
| 1710 | |
| 1711 | return ret; |
| 1712 | } |
| 1713 | |
| 1714 | int ath6kl_wmi_disconnect_cmd(struct wmi *wmi) |
| 1715 | { |
| 1716 | int ret; |
| 1717 | |
| 1718 | wmi->traffic_class = 100; |
| 1719 | |
| 1720 | /* Disconnect command does not need to do a SYNC before. */ |
| 1721 | ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID); |
| 1722 | |
| 1723 | return ret; |
| 1724 | } |
| 1725 | |
| 1726 | int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, |
| 1727 | u32 force_fgscan, u32 is_legacy, |
| 1728 | u32 home_dwell_time, u32 force_scan_interval, |
| 1729 | s8 num_chan, u16 *ch_list) |
| 1730 | { |
| 1731 | struct sk_buff *skb; |
| 1732 | struct wmi_start_scan_cmd *sc; |
| 1733 | s8 size; |
Edward Lu | 1276c9e | 2011-08-30 21:58:00 +0300 | [diff] [blame] | 1734 | int i, ret; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1735 | |
| 1736 | size = sizeof(struct wmi_start_scan_cmd); |
| 1737 | |
| 1738 | if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) |
| 1739 | return -EINVAL; |
| 1740 | |
| 1741 | if (num_chan > WMI_MAX_CHANNELS) |
| 1742 | return -EINVAL; |
| 1743 | |
| 1744 | if (num_chan) |
| 1745 | size += sizeof(u16) * (num_chan - 1); |
| 1746 | |
| 1747 | skb = ath6kl_wmi_get_new_buf(size); |
| 1748 | if (!skb) |
| 1749 | return -ENOMEM; |
| 1750 | |
| 1751 | sc = (struct wmi_start_scan_cmd *) skb->data; |
| 1752 | sc->scan_type = scan_type; |
| 1753 | sc->force_fg_scan = cpu_to_le32(force_fgscan); |
| 1754 | sc->is_legacy = cpu_to_le32(is_legacy); |
| 1755 | sc->home_dwell_time = cpu_to_le32(home_dwell_time); |
| 1756 | sc->force_scan_intvl = cpu_to_le32(force_scan_interval); |
| 1757 | sc->num_ch = num_chan; |
| 1758 | |
Edward Lu | 1276c9e | 2011-08-30 21:58:00 +0300 | [diff] [blame] | 1759 | for (i = 0; i < num_chan; i++) |
| 1760 | sc->ch_list[i] = cpu_to_le16(ch_list[i]); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1761 | |
| 1762 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID, |
| 1763 | NO_SYNC_WMIFLAG); |
| 1764 | |
| 1765 | return ret; |
| 1766 | } |
| 1767 | |
| 1768 | int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, |
| 1769 | u16 fg_end_sec, u16 bg_sec, |
| 1770 | u16 minact_chdw_msec, u16 maxact_chdw_msec, |
| 1771 | u16 pas_chdw_msec, u8 short_scan_ratio, |
| 1772 | u8 scan_ctrl_flag, u32 max_dfsch_act_time, |
| 1773 | u16 maxact_scan_per_ssid) |
| 1774 | { |
| 1775 | struct sk_buff *skb; |
| 1776 | struct wmi_scan_params_cmd *sc; |
| 1777 | int ret; |
| 1778 | |
| 1779 | skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); |
| 1780 | if (!skb) |
| 1781 | return -ENOMEM; |
| 1782 | |
| 1783 | sc = (struct wmi_scan_params_cmd *) skb->data; |
| 1784 | sc->fg_start_period = cpu_to_le16(fg_start_sec); |
| 1785 | sc->fg_end_period = cpu_to_le16(fg_end_sec); |
| 1786 | sc->bg_period = cpu_to_le16(bg_sec); |
| 1787 | sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); |
| 1788 | sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); |
| 1789 | sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); |
| 1790 | sc->short_scan_ratio = short_scan_ratio; |
| 1791 | sc->scan_ctrl_flags = scan_ctrl_flag; |
| 1792 | sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); |
| 1793 | sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); |
| 1794 | |
| 1795 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID, |
| 1796 | NO_SYNC_WMIFLAG); |
| 1797 | return ret; |
| 1798 | } |
| 1799 | |
| 1800 | int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) |
| 1801 | { |
| 1802 | struct sk_buff *skb; |
| 1803 | struct wmi_bss_filter_cmd *cmd; |
| 1804 | int ret; |
| 1805 | |
| 1806 | if (filter >= LAST_BSS_FILTER) |
| 1807 | return -EINVAL; |
| 1808 | |
| 1809 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1810 | if (!skb) |
| 1811 | return -ENOMEM; |
| 1812 | |
| 1813 | cmd = (struct wmi_bss_filter_cmd *) skb->data; |
| 1814 | cmd->bss_filter = filter; |
| 1815 | cmd->ie_mask = cpu_to_le32(ie_mask); |
| 1816 | |
| 1817 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID, |
| 1818 | NO_SYNC_WMIFLAG); |
| 1819 | return ret; |
| 1820 | } |
| 1821 | |
| 1822 | int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, |
| 1823 | u8 ssid_len, u8 *ssid) |
| 1824 | { |
| 1825 | struct sk_buff *skb; |
| 1826 | struct wmi_probed_ssid_cmd *cmd; |
| 1827 | int ret; |
| 1828 | |
| 1829 | if (index > MAX_PROBED_SSID_INDEX) |
| 1830 | return -EINVAL; |
| 1831 | |
| 1832 | if (ssid_len > sizeof(cmd->ssid)) |
| 1833 | return -EINVAL; |
| 1834 | |
| 1835 | if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) |
| 1836 | return -EINVAL; |
| 1837 | |
| 1838 | if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) |
| 1839 | return -EINVAL; |
| 1840 | |
| 1841 | if (flag & SPECIFIC_SSID_FLAG) |
| 1842 | wmi->is_probe_ssid = true; |
| 1843 | |
| 1844 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1845 | if (!skb) |
| 1846 | return -ENOMEM; |
| 1847 | |
| 1848 | cmd = (struct wmi_probed_ssid_cmd *) skb->data; |
| 1849 | cmd->entry_index = index; |
| 1850 | cmd->flag = flag; |
| 1851 | cmd->ssid_len = ssid_len; |
| 1852 | memcpy(cmd->ssid, ssid, ssid_len); |
| 1853 | |
| 1854 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID, |
| 1855 | NO_SYNC_WMIFLAG); |
| 1856 | return ret; |
| 1857 | } |
| 1858 | |
| 1859 | int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, |
| 1860 | u16 listen_beacons) |
| 1861 | { |
| 1862 | struct sk_buff *skb; |
| 1863 | struct wmi_listen_int_cmd *cmd; |
| 1864 | int ret; |
| 1865 | |
| 1866 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1867 | if (!skb) |
| 1868 | return -ENOMEM; |
| 1869 | |
| 1870 | cmd = (struct wmi_listen_int_cmd *) skb->data; |
| 1871 | cmd->listen_intvl = cpu_to_le16(listen_interval); |
| 1872 | cmd->num_beacons = cpu_to_le16(listen_beacons); |
| 1873 | |
| 1874 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID, |
| 1875 | NO_SYNC_WMIFLAG); |
| 1876 | return ret; |
| 1877 | } |
| 1878 | |
| 1879 | int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode) |
| 1880 | { |
| 1881 | struct sk_buff *skb; |
| 1882 | struct wmi_power_mode_cmd *cmd; |
| 1883 | int ret; |
| 1884 | |
| 1885 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1886 | if (!skb) |
| 1887 | return -ENOMEM; |
| 1888 | |
| 1889 | cmd = (struct wmi_power_mode_cmd *) skb->data; |
| 1890 | cmd->pwr_mode = pwr_mode; |
| 1891 | wmi->pwr_mode = pwr_mode; |
| 1892 | |
| 1893 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID, |
| 1894 | NO_SYNC_WMIFLAG); |
| 1895 | return ret; |
| 1896 | } |
| 1897 | |
| 1898 | int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, |
| 1899 | u16 ps_poll_num, u16 dtim_policy, |
| 1900 | u16 tx_wakeup_policy, u16 num_tx_to_wakeup, |
| 1901 | u16 ps_fail_event_policy) |
| 1902 | { |
| 1903 | struct sk_buff *skb; |
| 1904 | struct wmi_power_params_cmd *pm; |
| 1905 | int ret; |
| 1906 | |
| 1907 | skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); |
| 1908 | if (!skb) |
| 1909 | return -ENOMEM; |
| 1910 | |
| 1911 | pm = (struct wmi_power_params_cmd *)skb->data; |
| 1912 | pm->idle_period = cpu_to_le16(idle_period); |
| 1913 | pm->pspoll_number = cpu_to_le16(ps_poll_num); |
| 1914 | pm->dtim_policy = cpu_to_le16(dtim_policy); |
| 1915 | pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); |
| 1916 | pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); |
| 1917 | pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); |
| 1918 | |
| 1919 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID, |
| 1920 | NO_SYNC_WMIFLAG); |
| 1921 | return ret; |
| 1922 | } |
| 1923 | |
| 1924 | int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) |
| 1925 | { |
| 1926 | struct sk_buff *skb; |
| 1927 | struct wmi_disc_timeout_cmd *cmd; |
| 1928 | int ret; |
| 1929 | |
| 1930 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1931 | if (!skb) |
| 1932 | return -ENOMEM; |
| 1933 | |
| 1934 | cmd = (struct wmi_disc_timeout_cmd *) skb->data; |
| 1935 | cmd->discon_timeout = timeout; |
| 1936 | |
| 1937 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID, |
| 1938 | NO_SYNC_WMIFLAG); |
| 1939 | return ret; |
| 1940 | } |
| 1941 | |
| 1942 | int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, |
| 1943 | enum crypto_type key_type, |
| 1944 | u8 key_usage, u8 key_len, |
| 1945 | u8 *key_rsc, u8 *key_material, |
| 1946 | u8 key_op_ctrl, u8 *mac_addr, |
| 1947 | enum wmi_sync_flag sync_flag) |
| 1948 | { |
| 1949 | struct sk_buff *skb; |
| 1950 | struct wmi_add_cipher_key_cmd *cmd; |
| 1951 | int ret; |
| 1952 | |
Jouni Malinen | 9a5b131 | 2011-08-30 21:57:52 +0300 | [diff] [blame] | 1953 | ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " |
| 1954 | "key_usage=%d key_len=%d key_op_ctrl=%d\n", |
| 1955 | key_index, key_type, key_usage, key_len, key_op_ctrl); |
| 1956 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1957 | if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || |
| 1958 | (key_material == NULL)) |
| 1959 | return -EINVAL; |
| 1960 | |
| 1961 | if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) |
| 1962 | return -EINVAL; |
| 1963 | |
| 1964 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1965 | if (!skb) |
| 1966 | return -ENOMEM; |
| 1967 | |
| 1968 | cmd = (struct wmi_add_cipher_key_cmd *) skb->data; |
| 1969 | cmd->key_index = key_index; |
| 1970 | cmd->key_type = key_type; |
| 1971 | cmd->key_usage = key_usage; |
| 1972 | cmd->key_len = key_len; |
| 1973 | memcpy(cmd->key, key_material, key_len); |
| 1974 | |
| 1975 | if (key_rsc != NULL) |
| 1976 | memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc)); |
| 1977 | |
| 1978 | cmd->key_op_ctrl = key_op_ctrl; |
| 1979 | |
| 1980 | if (mac_addr) |
| 1981 | memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); |
| 1982 | |
| 1983 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID, |
| 1984 | sync_flag); |
| 1985 | |
| 1986 | return ret; |
| 1987 | } |
| 1988 | |
| 1989 | int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) |
| 1990 | { |
| 1991 | struct sk_buff *skb; |
| 1992 | struct wmi_add_krk_cmd *cmd; |
| 1993 | int ret; |
| 1994 | |
| 1995 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1996 | if (!skb) |
| 1997 | return -ENOMEM; |
| 1998 | |
| 1999 | cmd = (struct wmi_add_krk_cmd *) skb->data; |
| 2000 | memcpy(cmd->krk, krk, WMI_KRK_LEN); |
| 2001 | |
| 2002 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG); |
| 2003 | |
| 2004 | return ret; |
| 2005 | } |
| 2006 | |
| 2007 | int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index) |
| 2008 | { |
| 2009 | struct sk_buff *skb; |
| 2010 | struct wmi_delete_cipher_key_cmd *cmd; |
| 2011 | int ret; |
| 2012 | |
| 2013 | if (key_index > WMI_MAX_KEY_INDEX) |
| 2014 | return -EINVAL; |
| 2015 | |
| 2016 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2017 | if (!skb) |
| 2018 | return -ENOMEM; |
| 2019 | |
| 2020 | cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; |
| 2021 | cmd->key_index = key_index; |
| 2022 | |
| 2023 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID, |
| 2024 | NO_SYNC_WMIFLAG); |
| 2025 | |
| 2026 | return ret; |
| 2027 | } |
| 2028 | |
| 2029 | int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, |
| 2030 | const u8 *pmkid, bool set) |
| 2031 | { |
| 2032 | struct sk_buff *skb; |
| 2033 | struct wmi_setpmkid_cmd *cmd; |
| 2034 | int ret; |
| 2035 | |
| 2036 | if (bssid == NULL) |
| 2037 | return -EINVAL; |
| 2038 | |
| 2039 | if (set && pmkid == NULL) |
| 2040 | return -EINVAL; |
| 2041 | |
| 2042 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2043 | if (!skb) |
| 2044 | return -ENOMEM; |
| 2045 | |
| 2046 | cmd = (struct wmi_setpmkid_cmd *) skb->data; |
| 2047 | memcpy(cmd->bssid, bssid, ETH_ALEN); |
| 2048 | if (set) { |
| 2049 | memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); |
| 2050 | cmd->enable = PMKID_ENABLE; |
| 2051 | } else { |
| 2052 | memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); |
| 2053 | cmd->enable = PMKID_DISABLE; |
| 2054 | } |
| 2055 | |
| 2056 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID, |
| 2057 | NO_SYNC_WMIFLAG); |
| 2058 | |
| 2059 | return ret; |
| 2060 | } |
| 2061 | |
| 2062 | static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, |
| 2063 | enum htc_endpoint_id ep_id) |
| 2064 | { |
| 2065 | struct wmi_data_hdr *data_hdr; |
| 2066 | int ret; |
| 2067 | |
| 2068 | if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) |
| 2069 | return -EINVAL; |
| 2070 | |
| 2071 | skb_push(skb, sizeof(struct wmi_data_hdr)); |
| 2072 | |
| 2073 | data_hdr = (struct wmi_data_hdr *) skb->data; |
| 2074 | data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; |
| 2075 | data_hdr->info3 = 0; |
| 2076 | |
| 2077 | ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); |
| 2078 | |
| 2079 | return ret; |
| 2080 | } |
| 2081 | |
| 2082 | static int ath6kl_wmi_sync_point(struct wmi *wmi) |
| 2083 | { |
| 2084 | struct sk_buff *skb; |
| 2085 | struct wmi_sync_cmd *cmd; |
| 2086 | struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; |
| 2087 | enum htc_endpoint_id ep_id; |
| 2088 | u8 index, num_pri_streams = 0; |
| 2089 | int ret = 0; |
| 2090 | |
| 2091 | memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); |
| 2092 | |
| 2093 | spin_lock_bh(&wmi->lock); |
| 2094 | |
| 2095 | for (index = 0; index < WMM_NUM_AC; index++) { |
| 2096 | if (wmi->fat_pipe_exist & (1 << index)) { |
| 2097 | num_pri_streams++; |
| 2098 | data_sync_bufs[num_pri_streams - 1].traffic_class = |
| 2099 | index; |
| 2100 | } |
| 2101 | } |
| 2102 | |
| 2103 | spin_unlock_bh(&wmi->lock); |
| 2104 | |
| 2105 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2106 | if (!skb) { |
| 2107 | ret = -ENOMEM; |
| 2108 | goto free_skb; |
| 2109 | } |
| 2110 | |
| 2111 | cmd = (struct wmi_sync_cmd *) skb->data; |
| 2112 | |
| 2113 | /* |
| 2114 | * In the SYNC cmd sent on the control Ep, send a bitmap |
| 2115 | * of the data eps on which the Data Sync will be sent |
| 2116 | */ |
| 2117 | cmd->data_sync_map = wmi->fat_pipe_exist; |
| 2118 | |
| 2119 | for (index = 0; index < num_pri_streams; index++) { |
| 2120 | data_sync_bufs[index].skb = ath6kl_buf_alloc(0); |
| 2121 | if (data_sync_bufs[index].skb == NULL) { |
| 2122 | ret = -ENOMEM; |
| 2123 | break; |
| 2124 | } |
| 2125 | } |
| 2126 | |
| 2127 | /* |
| 2128 | * If buffer allocation for any of the dataSync fails, |
| 2129 | * then do not send the Synchronize cmd on the control ep |
| 2130 | */ |
| 2131 | if (ret) |
| 2132 | goto free_skb; |
| 2133 | |
| 2134 | /* |
| 2135 | * Send sync cmd followed by sync data messages on all |
| 2136 | * endpoints being used |
| 2137 | */ |
| 2138 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID, |
| 2139 | NO_SYNC_WMIFLAG); |
| 2140 | |
| 2141 | if (ret) |
| 2142 | goto free_skb; |
| 2143 | |
| 2144 | /* cmd buffer sent, we no longer own it */ |
| 2145 | skb = NULL; |
| 2146 | |
| 2147 | for (index = 0; index < num_pri_streams; index++) { |
| 2148 | |
| 2149 | if (WARN_ON(!data_sync_bufs[index].skb)) |
| 2150 | break; |
| 2151 | |
| 2152 | ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, |
| 2153 | data_sync_bufs[index]. |
| 2154 | traffic_class); |
| 2155 | ret = |
| 2156 | ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, |
| 2157 | ep_id); |
| 2158 | |
| 2159 | if (ret) |
| 2160 | break; |
| 2161 | |
| 2162 | data_sync_bufs[index].skb = NULL; |
| 2163 | } |
| 2164 | |
| 2165 | free_skb: |
| 2166 | /* free up any resources left over (possibly due to an error) */ |
| 2167 | if (skb) |
| 2168 | dev_kfree_skb(skb); |
| 2169 | |
| 2170 | for (index = 0; index < num_pri_streams; index++) { |
| 2171 | if (data_sync_bufs[index].skb != NULL) { |
| 2172 | dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. |
| 2173 | skb); |
| 2174 | } |
| 2175 | } |
| 2176 | |
| 2177 | return ret; |
| 2178 | } |
| 2179 | |
| 2180 | int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, |
| 2181 | struct wmi_create_pstream_cmd *params) |
| 2182 | { |
| 2183 | struct sk_buff *skb; |
| 2184 | struct wmi_create_pstream_cmd *cmd; |
| 2185 | u8 fatpipe_exist_for_ac = 0; |
| 2186 | s32 min_phy = 0; |
| 2187 | s32 nominal_phy = 0; |
| 2188 | int ret; |
| 2189 | |
| 2190 | if (!((params->user_pri < 8) && |
| 2191 | (params->user_pri <= 0x7) && |
| 2192 | (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && |
| 2193 | (params->traffic_direc == UPLINK_TRAFFIC || |
| 2194 | params->traffic_direc == DNLINK_TRAFFIC || |
| 2195 | params->traffic_direc == BIDIR_TRAFFIC) && |
| 2196 | (params->traffic_type == TRAFFIC_TYPE_APERIODIC || |
| 2197 | params->traffic_type == TRAFFIC_TYPE_PERIODIC) && |
| 2198 | (params->voice_psc_cap == DISABLE_FOR_THIS_AC || |
| 2199 | params->voice_psc_cap == ENABLE_FOR_THIS_AC || |
| 2200 | params->voice_psc_cap == ENABLE_FOR_ALL_AC) && |
| 2201 | (params->tsid == WMI_IMPLICIT_PSTREAM || |
| 2202 | params->tsid <= WMI_MAX_THINSTREAM))) { |
| 2203 | return -EINVAL; |
| 2204 | } |
| 2205 | |
| 2206 | /* |
| 2207 | * Check nominal PHY rate is >= minimalPHY, |
| 2208 | * so that DUT can allow TSRS IE |
| 2209 | */ |
| 2210 | |
| 2211 | /* Get the physical rate (units of bps) */ |
| 2212 | min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); |
| 2213 | |
| 2214 | /* Check minimal phy < nominal phy rate */ |
| 2215 | if (params->nominal_phy >= min_phy) { |
| 2216 | /* unit of 500 kbps */ |
| 2217 | nominal_phy = (params->nominal_phy * 1000) / 500; |
| 2218 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2219 | "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", |
| 2220 | min_phy, nominal_phy); |
| 2221 | |
| 2222 | params->nominal_phy = nominal_phy; |
| 2223 | } else { |
| 2224 | params->nominal_phy = 0; |
| 2225 | } |
| 2226 | |
| 2227 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2228 | if (!skb) |
| 2229 | return -ENOMEM; |
| 2230 | |
| 2231 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2232 | "sending create_pstream_cmd: ac=%d tsid:%d\n", |
| 2233 | params->traffic_class, params->tsid); |
| 2234 | |
| 2235 | cmd = (struct wmi_create_pstream_cmd *) skb->data; |
| 2236 | memcpy(cmd, params, sizeof(*cmd)); |
| 2237 | |
| 2238 | /* This is an implicitly created Fat pipe */ |
| 2239 | if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { |
| 2240 | spin_lock_bh(&wmi->lock); |
| 2241 | fatpipe_exist_for_ac = (wmi->fat_pipe_exist & |
| 2242 | (1 << params->traffic_class)); |
| 2243 | wmi->fat_pipe_exist |= (1 << params->traffic_class); |
| 2244 | spin_unlock_bh(&wmi->lock); |
| 2245 | } else { |
| 2246 | /* explicitly created thin stream within a fat pipe */ |
| 2247 | spin_lock_bh(&wmi->lock); |
| 2248 | fatpipe_exist_for_ac = (wmi->fat_pipe_exist & |
| 2249 | (1 << params->traffic_class)); |
| 2250 | wmi->stream_exist_for_ac[params->traffic_class] |= |
| 2251 | (1 << params->tsid); |
| 2252 | /* |
| 2253 | * If a thinstream becomes active, the fat pipe automatically |
| 2254 | * becomes active |
| 2255 | */ |
| 2256 | wmi->fat_pipe_exist |= (1 << params->traffic_class); |
| 2257 | spin_unlock_bh(&wmi->lock); |
| 2258 | } |
| 2259 | |
| 2260 | /* |
| 2261 | * Indicate activty change to driver layer only if this is the |
| 2262 | * first TSID to get created in this AC explicitly or an implicit |
| 2263 | * fat pipe is getting created. |
| 2264 | */ |
| 2265 | if (!fatpipe_exist_for_ac) |
| 2266 | ath6kl_indicate_tx_activity(wmi->parent_dev, |
| 2267 | params->traffic_class, true); |
| 2268 | |
| 2269 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID, |
| 2270 | NO_SYNC_WMIFLAG); |
| 2271 | return ret; |
| 2272 | } |
| 2273 | |
| 2274 | int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) |
| 2275 | { |
| 2276 | struct sk_buff *skb; |
| 2277 | struct wmi_delete_pstream_cmd *cmd; |
| 2278 | u16 active_tsids = 0; |
| 2279 | int ret; |
| 2280 | |
| 2281 | if (traffic_class > 3) { |
| 2282 | ath6kl_err("invalid traffic class: %d\n", traffic_class); |
| 2283 | return -EINVAL; |
| 2284 | } |
| 2285 | |
| 2286 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2287 | if (!skb) |
| 2288 | return -ENOMEM; |
| 2289 | |
| 2290 | cmd = (struct wmi_delete_pstream_cmd *) skb->data; |
| 2291 | cmd->traffic_class = traffic_class; |
| 2292 | cmd->tsid = tsid; |
| 2293 | |
| 2294 | spin_lock_bh(&wmi->lock); |
| 2295 | active_tsids = wmi->stream_exist_for_ac[traffic_class]; |
| 2296 | spin_unlock_bh(&wmi->lock); |
| 2297 | |
| 2298 | if (!(active_tsids & (1 << tsid))) { |
| 2299 | dev_kfree_skb(skb); |
| 2300 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2301 | "TSID %d doesn't exist for traffic class: %d\n", |
| 2302 | tsid, traffic_class); |
| 2303 | return -ENODATA; |
| 2304 | } |
| 2305 | |
| 2306 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2307 | "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", |
| 2308 | traffic_class, tsid); |
| 2309 | |
| 2310 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID, |
| 2311 | SYNC_BEFORE_WMIFLAG); |
| 2312 | |
| 2313 | spin_lock_bh(&wmi->lock); |
| 2314 | wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); |
| 2315 | active_tsids = wmi->stream_exist_for_ac[traffic_class]; |
| 2316 | spin_unlock_bh(&wmi->lock); |
| 2317 | |
| 2318 | /* |
| 2319 | * Indicate stream inactivity to driver layer only if all tsids |
| 2320 | * within this AC are deleted. |
| 2321 | */ |
| 2322 | if (!active_tsids) { |
| 2323 | ath6kl_indicate_tx_activity(wmi->parent_dev, |
| 2324 | traffic_class, false); |
| 2325 | wmi->fat_pipe_exist &= ~(1 << traffic_class); |
| 2326 | } |
| 2327 | |
| 2328 | return ret; |
| 2329 | } |
| 2330 | |
| 2331 | int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) |
| 2332 | { |
| 2333 | struct sk_buff *skb; |
| 2334 | struct wmi_set_ip_cmd *cmd; |
| 2335 | int ret; |
| 2336 | |
| 2337 | /* Multicast address are not valid */ |
| 2338 | if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) || |
| 2339 | (*((u8 *) &ip_cmd->ips[1]) >= 0xE0)) |
| 2340 | return -EINVAL; |
| 2341 | |
| 2342 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); |
| 2343 | if (!skb) |
| 2344 | return -ENOMEM; |
| 2345 | |
| 2346 | cmd = (struct wmi_set_ip_cmd *) skb->data; |
| 2347 | memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); |
| 2348 | |
| 2349 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG); |
| 2350 | return ret; |
| 2351 | } |
| 2352 | |
| 2353 | static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, |
| 2354 | int len) |
| 2355 | { |
| 2356 | if (len < sizeof(struct wmi_get_wow_list_reply)) |
| 2357 | return -EINVAL; |
| 2358 | |
| 2359 | return 0; |
| 2360 | } |
| 2361 | |
| 2362 | static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, |
| 2363 | enum wmix_command_id cmd_id, |
| 2364 | enum wmi_sync_flag sync_flag) |
| 2365 | { |
| 2366 | struct wmix_cmd_hdr *cmd_hdr; |
| 2367 | int ret; |
| 2368 | |
| 2369 | skb_push(skb, sizeof(struct wmix_cmd_hdr)); |
| 2370 | |
| 2371 | cmd_hdr = (struct wmix_cmd_hdr *) skb->data; |
| 2372 | cmd_hdr->cmd_id = cpu_to_le32(cmd_id); |
| 2373 | |
| 2374 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag); |
| 2375 | |
| 2376 | return ret; |
| 2377 | } |
| 2378 | |
| 2379 | int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) |
| 2380 | { |
| 2381 | struct sk_buff *skb; |
| 2382 | struct wmix_hb_challenge_resp_cmd *cmd; |
| 2383 | int ret; |
| 2384 | |
| 2385 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2386 | if (!skb) |
| 2387 | return -ENOMEM; |
| 2388 | |
| 2389 | cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; |
| 2390 | cmd->cookie = cpu_to_le32(cookie); |
| 2391 | cmd->source = cpu_to_le32(source); |
| 2392 | |
| 2393 | ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, |
| 2394 | NO_SYNC_WMIFLAG); |
| 2395 | return ret; |
| 2396 | } |
| 2397 | |
| 2398 | int ath6kl_wmi_get_stats_cmd(struct wmi *wmi) |
| 2399 | { |
| 2400 | return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID); |
| 2401 | } |
| 2402 | |
| 2403 | int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) |
| 2404 | { |
| 2405 | struct sk_buff *skb; |
| 2406 | struct wmi_set_tx_pwr_cmd *cmd; |
| 2407 | int ret; |
| 2408 | |
| 2409 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); |
| 2410 | if (!skb) |
| 2411 | return -ENOMEM; |
| 2412 | |
| 2413 | cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; |
| 2414 | cmd->dbM = dbM; |
| 2415 | |
| 2416 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID, |
| 2417 | NO_SYNC_WMIFLAG); |
| 2418 | |
| 2419 | return ret; |
| 2420 | } |
| 2421 | |
| 2422 | int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) |
| 2423 | { |
| 2424 | return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID); |
| 2425 | } |
| 2426 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2427 | int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) |
| 2428 | { |
| 2429 | struct sk_buff *skb; |
| 2430 | struct wmi_set_lpreamble_cmd *cmd; |
| 2431 | int ret; |
| 2432 | |
| 2433 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); |
| 2434 | if (!skb) |
| 2435 | return -ENOMEM; |
| 2436 | |
| 2437 | cmd = (struct wmi_set_lpreamble_cmd *) skb->data; |
| 2438 | cmd->status = status; |
| 2439 | cmd->preamble_policy = preamble_policy; |
| 2440 | |
| 2441 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID, |
| 2442 | NO_SYNC_WMIFLAG); |
| 2443 | return ret; |
| 2444 | } |
| 2445 | |
| 2446 | int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) |
| 2447 | { |
| 2448 | struct sk_buff *skb; |
| 2449 | struct wmi_set_rts_cmd *cmd; |
| 2450 | int ret; |
| 2451 | |
| 2452 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); |
| 2453 | if (!skb) |
| 2454 | return -ENOMEM; |
| 2455 | |
| 2456 | cmd = (struct wmi_set_rts_cmd *) skb->data; |
| 2457 | cmd->threshold = cpu_to_le16(threshold); |
| 2458 | |
| 2459 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG); |
| 2460 | return ret; |
| 2461 | } |
| 2462 | |
| 2463 | int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) |
| 2464 | { |
| 2465 | struct sk_buff *skb; |
| 2466 | struct wmi_set_wmm_txop_cmd *cmd; |
| 2467 | int ret; |
| 2468 | |
| 2469 | if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) |
| 2470 | return -EINVAL; |
| 2471 | |
| 2472 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); |
| 2473 | if (!skb) |
| 2474 | return -ENOMEM; |
| 2475 | |
| 2476 | cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; |
| 2477 | cmd->txop_enable = cfg; |
| 2478 | |
| 2479 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID, |
| 2480 | NO_SYNC_WMIFLAG); |
| 2481 | return ret; |
| 2482 | } |
| 2483 | |
| 2484 | int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) |
| 2485 | { |
| 2486 | struct sk_buff *skb; |
| 2487 | struct wmi_set_keepalive_cmd *cmd; |
| 2488 | int ret; |
| 2489 | |
| 2490 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2491 | if (!skb) |
| 2492 | return -ENOMEM; |
| 2493 | |
| 2494 | cmd = (struct wmi_set_keepalive_cmd *) skb->data; |
| 2495 | cmd->keep_alive_intvl = keep_alive_intvl; |
| 2496 | wmi->keep_alive_intvl = keep_alive_intvl; |
| 2497 | |
| 2498 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, |
| 2499 | NO_SYNC_WMIFLAG); |
| 2500 | return ret; |
| 2501 | } |
| 2502 | |
| 2503 | s32 ath6kl_wmi_get_rate(s8 rate_index) |
| 2504 | { |
| 2505 | if (rate_index == RATE_AUTO) |
| 2506 | return 0; |
| 2507 | |
| 2508 | return wmi_rate_tbl[(u32) rate_index][0]; |
| 2509 | } |
| 2510 | |
| 2511 | void ath6kl_wmi_node_return(struct wmi *wmi, struct bss *bss) |
| 2512 | { |
| 2513 | if (bss) |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2514 | wlan_node_return(&wmi->parent_dev->scan_table, bss); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2515 | } |
| 2516 | |
| 2517 | struct bss *ath6kl_wmi_find_ssid_node(struct wmi *wmi, u8 * ssid, |
| 2518 | u32 ssid_len, bool is_wpa2, |
| 2519 | bool match_ssid) |
| 2520 | { |
| 2521 | struct bss *node = NULL; |
| 2522 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2523 | node = wlan_find_ssid_node(&wmi->parent_dev->scan_table, ssid, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2524 | ssid_len, is_wpa2, match_ssid); |
| 2525 | return node; |
| 2526 | } |
| 2527 | |
| 2528 | struct bss *ath6kl_wmi_find_node(struct wmi *wmi, const u8 * mac_addr) |
| 2529 | { |
| 2530 | struct bss *ni = NULL; |
| 2531 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2532 | ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2533 | |
| 2534 | return ni; |
| 2535 | } |
| 2536 | |
| 2537 | void ath6kl_wmi_node_free(struct wmi *wmi, const u8 * mac_addr) |
| 2538 | { |
| 2539 | struct bss *ni = NULL; |
| 2540 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2541 | ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2542 | if (ni != NULL) |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2543 | wlan_node_reclaim(&wmi->parent_dev->scan_table, ni); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2544 | |
| 2545 | return; |
| 2546 | } |
| 2547 | |
| 2548 | static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, |
| 2549 | u32 len) |
| 2550 | { |
| 2551 | struct wmi_pmkid_list_reply *reply; |
| 2552 | u32 expected_len; |
| 2553 | |
| 2554 | if (len < sizeof(struct wmi_pmkid_list_reply)) |
| 2555 | return -EINVAL; |
| 2556 | |
| 2557 | reply = (struct wmi_pmkid_list_reply *)datap; |
| 2558 | expected_len = sizeof(reply->num_pmkid) + |
| 2559 | le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; |
| 2560 | |
| 2561 | if (len < expected_len) |
| 2562 | return -EINVAL; |
| 2563 | |
| 2564 | return 0; |
| 2565 | } |
| 2566 | |
| 2567 | static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 2568 | { |
| 2569 | struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; |
| 2570 | |
| 2571 | aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid, |
| 2572 | le16_to_cpu(cmd->st_seq_no), cmd->win_sz); |
| 2573 | |
| 2574 | return 0; |
| 2575 | } |
| 2576 | |
| 2577 | static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 2578 | { |
| 2579 | struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; |
| 2580 | |
| 2581 | aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid); |
| 2582 | |
| 2583 | return 0; |
| 2584 | } |
| 2585 | |
| 2586 | /* AP mode functions */ |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 2587 | |
| 2588 | int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) |
| 2589 | { |
| 2590 | struct sk_buff *skb; |
| 2591 | struct wmi_connect_cmd *cm; |
| 2592 | int res; |
| 2593 | |
| 2594 | skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); |
| 2595 | if (!skb) |
| 2596 | return -ENOMEM; |
| 2597 | |
| 2598 | cm = (struct wmi_connect_cmd *) skb->data; |
| 2599 | memcpy(cm, p, sizeof(*cm)); |
| 2600 | |
| 2601 | res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID, |
| 2602 | NO_SYNC_WMIFLAG); |
| 2603 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " |
| 2604 | "ctrl_flags=0x%x-> res=%d\n", |
| 2605 | __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), |
| 2606 | le32_to_cpu(p->ctrl_flags), res); |
| 2607 | return res; |
| 2608 | } |
| 2609 | |
Jouni Malinen | 2387513 | 2011-08-30 21:57:53 +0300 | [diff] [blame] | 2610 | int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason) |
| 2611 | { |
| 2612 | struct sk_buff *skb; |
| 2613 | struct wmi_ap_set_mlme_cmd *cm; |
| 2614 | |
| 2615 | skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); |
| 2616 | if (!skb) |
| 2617 | return -ENOMEM; |
| 2618 | |
| 2619 | cm = (struct wmi_ap_set_mlme_cmd *) skb->data; |
| 2620 | memcpy(cm->mac, mac, ETH_ALEN); |
| 2621 | cm->reason = cpu_to_le16(reason); |
| 2622 | cm->cmd = cmd; |
| 2623 | |
| 2624 | return ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_SET_MLME_CMDID, |
| 2625 | NO_SYNC_WMIFLAG); |
| 2626 | } |
| 2627 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2628 | static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 2629 | { |
| 2630 | struct wmi_pspoll_event *ev; |
| 2631 | |
| 2632 | if (len < sizeof(struct wmi_pspoll_event)) |
| 2633 | return -EINVAL; |
| 2634 | |
| 2635 | ev = (struct wmi_pspoll_event *) datap; |
| 2636 | |
| 2637 | ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid)); |
| 2638 | |
| 2639 | return 0; |
| 2640 | } |
| 2641 | |
| 2642 | static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 2643 | { |
| 2644 | ath6kl_dtimexpiry_event(wmi->parent_dev); |
| 2645 | |
| 2646 | return 0; |
| 2647 | } |
| 2648 | |
| 2649 | int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag) |
| 2650 | { |
| 2651 | struct sk_buff *skb; |
| 2652 | struct wmi_ap_set_pvb_cmd *cmd; |
| 2653 | int ret; |
| 2654 | |
| 2655 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); |
| 2656 | if (!skb) |
| 2657 | return -ENOMEM; |
| 2658 | |
| 2659 | cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; |
| 2660 | cmd->aid = cpu_to_le16(aid); |
| 2661 | cmd->flag = cpu_to_le32(flag); |
| 2662 | |
| 2663 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID, |
| 2664 | NO_SYNC_WMIFLAG); |
| 2665 | |
| 2666 | return 0; |
| 2667 | } |
| 2668 | |
| 2669 | int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, |
| 2670 | bool rx_dot11_hdr, bool defrag_on_host) |
| 2671 | { |
| 2672 | struct sk_buff *skb; |
| 2673 | struct wmi_rx_frame_format_cmd *cmd; |
| 2674 | int ret; |
| 2675 | |
| 2676 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2677 | if (!skb) |
| 2678 | return -ENOMEM; |
| 2679 | |
| 2680 | cmd = (struct wmi_rx_frame_format_cmd *) skb->data; |
| 2681 | cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; |
| 2682 | cmd->defrag_on_host = defrag_on_host ? 1 : 0; |
| 2683 | cmd->meta_ver = rx_meta_ver; |
| 2684 | |
| 2685 | /* Delete the local aggr state, on host */ |
| 2686 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID, |
| 2687 | NO_SYNC_WMIFLAG); |
| 2688 | |
| 2689 | return ret; |
| 2690 | } |
| 2691 | |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 2692 | int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, |
| 2693 | u8 ie_len) |
| 2694 | { |
| 2695 | struct sk_buff *skb; |
| 2696 | struct wmi_set_appie_cmd *p; |
| 2697 | |
| 2698 | skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); |
| 2699 | if (!skb) |
| 2700 | return -ENOMEM; |
| 2701 | |
| 2702 | ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " |
| 2703 | "ie_len=%u\n", mgmt_frm_type, ie_len); |
| 2704 | p = (struct wmi_set_appie_cmd *) skb->data; |
| 2705 | p->mgmt_frm_type = mgmt_frm_type; |
| 2706 | p->ie_len = ie_len; |
| 2707 | memcpy(p->ie_info, ie, ie_len); |
| 2708 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID, |
| 2709 | NO_SYNC_WMIFLAG); |
| 2710 | } |
| 2711 | |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 2712 | int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable) |
| 2713 | { |
| 2714 | struct sk_buff *skb; |
| 2715 | struct wmi_disable_11b_rates_cmd *cmd; |
| 2716 | |
| 2717 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2718 | if (!skb) |
| 2719 | return -ENOMEM; |
| 2720 | |
| 2721 | ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n", |
| 2722 | disable); |
| 2723 | cmd = (struct wmi_disable_11b_rates_cmd *) skb->data; |
| 2724 | cmd->disable = disable ? 1 : 0; |
| 2725 | |
| 2726 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_DISABLE_11B_RATES_CMDID, |
| 2727 | NO_SYNC_WMIFLAG); |
| 2728 | } |
| 2729 | |
| 2730 | int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur) |
| 2731 | { |
| 2732 | struct sk_buff *skb; |
| 2733 | struct wmi_remain_on_chnl_cmd *p; |
| 2734 | |
| 2735 | skb = ath6kl_wmi_get_new_buf(sizeof(*p)); |
| 2736 | if (!skb) |
| 2737 | return -ENOMEM; |
| 2738 | |
| 2739 | ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n", |
| 2740 | freq, dur); |
| 2741 | p = (struct wmi_remain_on_chnl_cmd *) skb->data; |
| 2742 | p->freq = cpu_to_le32(freq); |
| 2743 | p->duration = cpu_to_le32(dur); |
| 2744 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_REMAIN_ON_CHNL_CMDID, |
| 2745 | NO_SYNC_WMIFLAG); |
| 2746 | } |
| 2747 | |
| 2748 | int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait, |
| 2749 | const u8 *data, u16 data_len) |
| 2750 | { |
| 2751 | struct sk_buff *skb; |
| 2752 | struct wmi_send_action_cmd *p; |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame^] | 2753 | u8 *buf; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 2754 | |
| 2755 | if (wait) |
| 2756 | return -EINVAL; /* Offload for wait not supported */ |
| 2757 | |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame^] | 2758 | buf = kmalloc(data_len, GFP_KERNEL); |
| 2759 | if (!buf) |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 2760 | return -ENOMEM; |
| 2761 | |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame^] | 2762 | skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); |
| 2763 | if (!skb) { |
| 2764 | kfree(buf); |
| 2765 | return -ENOMEM; |
| 2766 | } |
| 2767 | |
| 2768 | kfree(wmi->last_mgmt_tx_frame); |
| 2769 | wmi->last_mgmt_tx_frame = buf; |
| 2770 | wmi->last_mgmt_tx_frame_len = data_len; |
| 2771 | |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 2772 | ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u " |
| 2773 | "len=%u\n", id, freq, wait, data_len); |
| 2774 | p = (struct wmi_send_action_cmd *) skb->data; |
| 2775 | p->id = cpu_to_le32(id); |
| 2776 | p->freq = cpu_to_le32(freq); |
| 2777 | p->wait = cpu_to_le32(wait); |
| 2778 | p->len = cpu_to_le16(data_len); |
| 2779 | memcpy(p->data, data, data_len); |
| 2780 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_ACTION_CMDID, |
| 2781 | NO_SYNC_WMIFLAG); |
| 2782 | } |
| 2783 | |
| 2784 | int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq, |
| 2785 | const u8 *dst, |
| 2786 | const u8 *data, u16 data_len) |
| 2787 | { |
| 2788 | struct sk_buff *skb; |
| 2789 | struct wmi_p2p_probe_response_cmd *p; |
| 2790 | |
| 2791 | skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len); |
| 2792 | if (!skb) |
| 2793 | return -ENOMEM; |
| 2794 | |
| 2795 | ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM " |
| 2796 | "len=%u\n", freq, dst, data_len); |
| 2797 | p = (struct wmi_p2p_probe_response_cmd *) skb->data; |
| 2798 | p->freq = cpu_to_le32(freq); |
| 2799 | memcpy(p->destination_addr, dst, ETH_ALEN); |
| 2800 | p->len = cpu_to_le16(data_len); |
| 2801 | memcpy(p->data, data, data_len); |
| 2802 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_PROBE_RESPONSE_CMDID, |
| 2803 | NO_SYNC_WMIFLAG); |
| 2804 | } |
| 2805 | |
| 2806 | int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable) |
| 2807 | { |
| 2808 | struct sk_buff *skb; |
| 2809 | struct wmi_probe_req_report_cmd *p; |
| 2810 | |
| 2811 | skb = ath6kl_wmi_get_new_buf(sizeof(*p)); |
| 2812 | if (!skb) |
| 2813 | return -ENOMEM; |
| 2814 | |
| 2815 | ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n", |
| 2816 | enable); |
| 2817 | p = (struct wmi_probe_req_report_cmd *) skb->data; |
| 2818 | p->enable = enable ? 1 : 0; |
| 2819 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_PROBE_REQ_REPORT_CMDID, |
| 2820 | NO_SYNC_WMIFLAG); |
| 2821 | } |
| 2822 | |
| 2823 | int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags) |
| 2824 | { |
| 2825 | struct sk_buff *skb; |
| 2826 | struct wmi_get_p2p_info *p; |
| 2827 | |
| 2828 | skb = ath6kl_wmi_get_new_buf(sizeof(*p)); |
| 2829 | if (!skb) |
| 2830 | return -ENOMEM; |
| 2831 | |
| 2832 | ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n", |
| 2833 | info_req_flags); |
| 2834 | p = (struct wmi_get_p2p_info *) skb->data; |
| 2835 | p->info_req_flags = cpu_to_le32(info_req_flags); |
| 2836 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_GET_P2P_INFO_CMDID, |
| 2837 | NO_SYNC_WMIFLAG); |
| 2838 | } |
| 2839 | |
| 2840 | int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi) |
| 2841 | { |
| 2842 | ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n"); |
| 2843 | return ath6kl_wmi_simple_cmd(wmi, WMI_CANCEL_REMAIN_ON_CHNL_CMDID); |
| 2844 | } |
| 2845 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2846 | static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) |
| 2847 | { |
| 2848 | struct wmix_cmd_hdr *cmd; |
| 2849 | u32 len; |
| 2850 | u16 id; |
| 2851 | u8 *datap; |
| 2852 | int ret = 0; |
| 2853 | |
| 2854 | if (skb->len < sizeof(struct wmix_cmd_hdr)) { |
| 2855 | ath6kl_err("bad packet 1\n"); |
| 2856 | wmi->stat.cmd_len_err++; |
| 2857 | return -EINVAL; |
| 2858 | } |
| 2859 | |
| 2860 | cmd = (struct wmix_cmd_hdr *) skb->data; |
| 2861 | id = le32_to_cpu(cmd->cmd_id); |
| 2862 | |
| 2863 | skb_pull(skb, sizeof(struct wmix_cmd_hdr)); |
| 2864 | |
| 2865 | datap = skb->data; |
| 2866 | len = skb->len; |
| 2867 | |
| 2868 | switch (id) { |
| 2869 | case WMIX_HB_CHALLENGE_RESP_EVENTID: |
| 2870 | break; |
| 2871 | case WMIX_DBGLOG_EVENTID: |
| 2872 | break; |
| 2873 | default: |
| 2874 | ath6kl_err("unknown cmd id 0x%x\n", id); |
| 2875 | wmi->stat.cmd_id_err++; |
| 2876 | ret = -EINVAL; |
| 2877 | break; |
| 2878 | } |
| 2879 | |
| 2880 | return ret; |
| 2881 | } |
| 2882 | |
| 2883 | /* Control Path */ |
| 2884 | int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) |
| 2885 | { |
| 2886 | struct wmi_cmd_hdr *cmd; |
| 2887 | u32 len; |
| 2888 | u16 id; |
| 2889 | u8 *datap; |
| 2890 | int ret = 0; |
| 2891 | |
| 2892 | if (WARN_ON(skb == NULL)) |
| 2893 | return -EINVAL; |
| 2894 | |
| 2895 | if (skb->len < sizeof(struct wmi_cmd_hdr)) { |
| 2896 | ath6kl_err("bad packet 1\n"); |
| 2897 | dev_kfree_skb(skb); |
| 2898 | wmi->stat.cmd_len_err++; |
| 2899 | return -EINVAL; |
| 2900 | } |
| 2901 | |
| 2902 | cmd = (struct wmi_cmd_hdr *) skb->data; |
| 2903 | id = le16_to_cpu(cmd->cmd_id); |
| 2904 | |
| 2905 | skb_pull(skb, sizeof(struct wmi_cmd_hdr)); |
| 2906 | |
| 2907 | datap = skb->data; |
| 2908 | len = skb->len; |
| 2909 | |
| 2910 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: wmi id: %d\n", __func__, id); |
| 2911 | ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "msg payload ", datap, len); |
| 2912 | |
| 2913 | switch (id) { |
| 2914 | case WMI_GET_BITRATE_CMDID: |
| 2915 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); |
| 2916 | ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); |
| 2917 | break; |
| 2918 | case WMI_GET_CHANNEL_LIST_CMDID: |
| 2919 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); |
| 2920 | ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); |
| 2921 | break; |
| 2922 | case WMI_GET_TX_PWR_CMDID: |
| 2923 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); |
| 2924 | ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); |
| 2925 | break; |
| 2926 | case WMI_READY_EVENTID: |
| 2927 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); |
| 2928 | ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); |
| 2929 | break; |
| 2930 | case WMI_CONNECT_EVENTID: |
| 2931 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); |
| 2932 | ret = ath6kl_wmi_connect_event_rx(wmi, datap, len); |
| 2933 | break; |
| 2934 | case WMI_DISCONNECT_EVENTID: |
| 2935 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); |
| 2936 | ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len); |
| 2937 | break; |
| 2938 | case WMI_PEER_NODE_EVENTID: |
| 2939 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); |
| 2940 | ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); |
| 2941 | break; |
| 2942 | case WMI_TKIP_MICERR_EVENTID: |
| 2943 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); |
| 2944 | ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len); |
| 2945 | break; |
| 2946 | case WMI_BSSINFO_EVENTID: |
| 2947 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); |
| 2948 | ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb, datap); |
| 2949 | ret = ath6kl_wmi_bssinfo_event_rx(wmi, skb->data, skb->len); |
| 2950 | break; |
| 2951 | case WMI_REGDOMAIN_EVENTID: |
| 2952 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); |
| 2953 | break; |
| 2954 | case WMI_PSTREAM_TIMEOUT_EVENTID: |
| 2955 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); |
| 2956 | ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); |
| 2957 | break; |
| 2958 | case WMI_NEIGHBOR_REPORT_EVENTID: |
| 2959 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); |
| 2960 | break; |
| 2961 | case WMI_SCAN_COMPLETE_EVENTID: |
| 2962 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); |
| 2963 | ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len); |
| 2964 | break; |
| 2965 | case WMI_CMDERROR_EVENTID: |
| 2966 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); |
| 2967 | ret = ath6kl_wmi_error_event_rx(wmi, datap, len); |
| 2968 | break; |
| 2969 | case WMI_REPORT_STATISTICS_EVENTID: |
| 2970 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); |
| 2971 | ret = ath6kl_wmi_stats_event_rx(wmi, datap, len); |
| 2972 | break; |
| 2973 | case WMI_RSSI_THRESHOLD_EVENTID: |
| 2974 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); |
| 2975 | ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); |
| 2976 | break; |
| 2977 | case WMI_ERROR_REPORT_EVENTID: |
| 2978 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); |
| 2979 | break; |
| 2980 | case WMI_OPT_RX_FRAME_EVENTID: |
| 2981 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); |
| 2982 | ret = ath6kl_wmi_opt_frame_event_rx(wmi, datap, len); |
| 2983 | break; |
| 2984 | case WMI_REPORT_ROAM_TBL_EVENTID: |
| 2985 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); |
| 2986 | break; |
| 2987 | case WMI_EXTENSION_EVENTID: |
| 2988 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); |
| 2989 | ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); |
| 2990 | break; |
| 2991 | case WMI_CAC_EVENTID: |
| 2992 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); |
| 2993 | ret = ath6kl_wmi_cac_event_rx(wmi, datap, len); |
| 2994 | break; |
| 2995 | case WMI_CHANNEL_CHANGE_EVENTID: |
| 2996 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); |
| 2997 | break; |
| 2998 | case WMI_REPORT_ROAM_DATA_EVENTID: |
| 2999 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); |
| 3000 | break; |
| 3001 | case WMI_GET_FIXRATES_CMDID: |
| 3002 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); |
| 3003 | ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); |
| 3004 | break; |
| 3005 | case WMI_TX_RETRY_ERR_EVENTID: |
| 3006 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); |
| 3007 | break; |
| 3008 | case WMI_SNR_THRESHOLD_EVENTID: |
| 3009 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); |
| 3010 | ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); |
| 3011 | break; |
| 3012 | case WMI_LQ_THRESHOLD_EVENTID: |
| 3013 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); |
| 3014 | break; |
| 3015 | case WMI_APLIST_EVENTID: |
| 3016 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); |
| 3017 | ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); |
| 3018 | break; |
| 3019 | case WMI_GET_KEEPALIVE_CMDID: |
| 3020 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); |
| 3021 | ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); |
| 3022 | break; |
| 3023 | case WMI_GET_WOW_LIST_EVENTID: |
| 3024 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); |
| 3025 | ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len); |
| 3026 | break; |
| 3027 | case WMI_GET_PMKID_LIST_EVENTID: |
| 3028 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); |
| 3029 | ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); |
| 3030 | break; |
| 3031 | case WMI_PSPOLL_EVENTID: |
| 3032 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); |
| 3033 | ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len); |
| 3034 | break; |
| 3035 | case WMI_DTIMEXPIRY_EVENTID: |
| 3036 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); |
| 3037 | ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len); |
| 3038 | break; |
| 3039 | case WMI_SET_PARAMS_REPLY_EVENTID: |
| 3040 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); |
| 3041 | break; |
| 3042 | case WMI_ADDBA_REQ_EVENTID: |
| 3043 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); |
| 3044 | ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len); |
| 3045 | break; |
| 3046 | case WMI_ADDBA_RESP_EVENTID: |
| 3047 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); |
| 3048 | break; |
| 3049 | case WMI_DELBA_REQ_EVENTID: |
| 3050 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); |
| 3051 | ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len); |
| 3052 | break; |
| 3053 | case WMI_REPORT_BTCOEX_CONFIG_EVENTID: |
| 3054 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 3055 | "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); |
| 3056 | break; |
| 3057 | case WMI_REPORT_BTCOEX_STATS_EVENTID: |
| 3058 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 3059 | "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); |
| 3060 | break; |
| 3061 | case WMI_TX_COMPLETE_EVENTID: |
| 3062 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); |
| 3063 | ret = ath6kl_wmi_tx_complete_event_rx(datap, len); |
| 3064 | break; |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3065 | case WMI_REMAIN_ON_CHNL_EVENTID: |
| 3066 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n"); |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 3067 | ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3068 | break; |
| 3069 | case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID: |
| 3070 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 3071 | "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n"); |
Jouni Malinen | f9e5f05 | 2011-08-30 21:57:58 +0300 | [diff] [blame] | 3072 | ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap, |
| 3073 | len); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3074 | break; |
| 3075 | case WMI_TX_STATUS_EVENTID: |
| 3076 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n"); |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame^] | 3077 | ret = ath6kl_wmi_tx_status_event_rx(wmi, datap, len); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3078 | break; |
| 3079 | case WMI_RX_PROBE_REQ_EVENTID: |
| 3080 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n"); |
Jouni Malinen | ae32c30 | 2011-08-30 21:58:01 +0300 | [diff] [blame] | 3081 | ret = ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len); |
Jouni Malinen | 6465ddc | 2011-08-30 21:57:54 +0300 | [diff] [blame] | 3082 | break; |
| 3083 | case WMI_P2P_CAPABILITIES_EVENTID: |
| 3084 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n"); |
| 3085 | ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len); |
| 3086 | break; |
| 3087 | case WMI_RX_ACTION_EVENTID: |
| 3088 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n"); |
| 3089 | ret = ath6kl_wmi_rx_action_event_rx(datap, len); |
| 3090 | break; |
| 3091 | case WMI_P2P_INFO_EVENTID: |
| 3092 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n"); |
| 3093 | ret = ath6kl_wmi_p2p_info_event_rx(datap, len); |
| 3094 | break; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3095 | default: |
| 3096 | ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); |
| 3097 | wmi->stat.cmd_id_err++; |
| 3098 | ret = -EINVAL; |
| 3099 | break; |
| 3100 | } |
| 3101 | |
| 3102 | dev_kfree_skb(skb); |
| 3103 | |
| 3104 | return ret; |
| 3105 | } |
| 3106 | |
| 3107 | static void ath6kl_wmi_qos_state_init(struct wmi *wmi) |
| 3108 | { |
| 3109 | if (!wmi) |
| 3110 | return; |
| 3111 | |
| 3112 | spin_lock_bh(&wmi->lock); |
| 3113 | |
| 3114 | wmi->fat_pipe_exist = 0; |
| 3115 | memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); |
| 3116 | |
| 3117 | spin_unlock_bh(&wmi->lock); |
| 3118 | } |
| 3119 | |
Vasanthakumar Thiagarajan | 2865785 | 2011-07-21 12:00:49 +0530 | [diff] [blame] | 3120 | void *ath6kl_wmi_init(struct ath6kl *dev) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3121 | { |
| 3122 | struct wmi *wmi; |
| 3123 | |
| 3124 | wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); |
| 3125 | if (!wmi) |
| 3126 | return NULL; |
| 3127 | |
| 3128 | spin_lock_init(&wmi->lock); |
| 3129 | |
| 3130 | wmi->parent_dev = dev; |
| 3131 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3132 | ath6kl_wmi_qos_state_init(wmi); |
| 3133 | |
| 3134 | wmi->pwr_mode = REC_POWER; |
| 3135 | wmi->phy_mode = WMI_11G_MODE; |
| 3136 | |
| 3137 | wmi->pair_crypto_type = NONE_CRYPT; |
| 3138 | wmi->grp_crypto_type = NONE_CRYPT; |
| 3139 | |
| 3140 | wmi->ht_allowed[A_BAND_24GHZ] = 1; |
| 3141 | wmi->ht_allowed[A_BAND_5GHZ] = 1; |
| 3142 | |
| 3143 | return wmi; |
| 3144 | } |
| 3145 | |
| 3146 | void ath6kl_wmi_shutdown(struct wmi *wmi) |
| 3147 | { |
| 3148 | if (!wmi) |
| 3149 | return; |
| 3150 | |
Jouni Malinen | a0df5db | 2011-08-30 21:58:02 +0300 | [diff] [blame^] | 3151 | kfree(wmi->last_mgmt_tx_frame); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 3152 | kfree(wmi); |
| 3153 | } |