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 | c8790cba | 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 | |
| 428 | static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size) |
| 429 | { |
| 430 | struct sk_buff *skb; |
| 431 | |
| 432 | skb = ath6kl_buf_alloc(size); |
| 433 | if (!skb) |
| 434 | return NULL; |
| 435 | |
| 436 | skb_put(skb, size); |
| 437 | if (size) |
| 438 | memset(skb->data, 0, size); |
| 439 | |
| 440 | return skb; |
| 441 | } |
| 442 | |
| 443 | /* Send a "simple" wmi command -- one with no arguments */ |
| 444 | static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id) |
| 445 | { |
| 446 | struct sk_buff *skb; |
| 447 | int ret; |
| 448 | |
| 449 | skb = ath6kl_wmi_get_new_buf(0); |
| 450 | if (!skb) |
| 451 | return -ENOMEM; |
| 452 | |
| 453 | ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG); |
| 454 | |
| 455 | return ret; |
| 456 | } |
| 457 | |
| 458 | static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 459 | { |
| 460 | struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap; |
| 461 | |
| 462 | if (len < sizeof(struct wmi_ready_event_2)) |
| 463 | return -EINVAL; |
| 464 | |
| 465 | wmi->ready = true; |
| 466 | ath6kl_ready_event(wmi->parent_dev, ev->mac_addr, |
| 467 | le32_to_cpu(ev->sw_version), |
| 468 | le32_to_cpu(ev->abi_version)); |
| 469 | |
| 470 | return 0; |
| 471 | } |
| 472 | |
| 473 | static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 474 | { |
| 475 | struct wmi_connect_event *ev; |
| 476 | u8 *pie, *peie; |
| 477 | |
| 478 | if (len < sizeof(struct wmi_connect_event)) |
| 479 | return -EINVAL; |
| 480 | |
| 481 | ev = (struct wmi_connect_event *) datap; |
| 482 | |
| 483 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM\n", |
| 484 | __func__, ev->ch, ev->bssid); |
| 485 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 486 | /* Start of assoc rsp IEs */ |
| 487 | pie = ev->assoc_info + ev->beacon_ie_len + |
| 488 | ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */ |
| 489 | |
| 490 | /* End of assoc rsp IEs */ |
| 491 | peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len + |
| 492 | ev->assoc_resp_len; |
| 493 | |
| 494 | while (pie < peie) { |
| 495 | switch (*pie) { |
| 496 | case WLAN_EID_VENDOR_SPECIFIC: |
| 497 | if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 && |
| 498 | pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) { |
| 499 | /* WMM OUT (00:50:F2) */ |
| 500 | if (pie[1] > 5 |
| 501 | && pie[6] == WMM_PARAM_OUI_SUBTYPE) |
| 502 | wmi->is_wmm_enabled = true; |
| 503 | } |
| 504 | break; |
| 505 | } |
| 506 | |
| 507 | if (wmi->is_wmm_enabled) |
| 508 | break; |
| 509 | |
| 510 | pie += pie[1] + 2; |
| 511 | } |
| 512 | |
| 513 | ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->ch), ev->bssid, |
| 514 | le16_to_cpu(ev->listen_intvl), |
| 515 | le16_to_cpu(ev->beacon_intvl), |
| 516 | le32_to_cpu(ev->nw_type), |
| 517 | ev->beacon_ie_len, ev->assoc_req_len, |
| 518 | ev->assoc_resp_len, ev->assoc_info); |
| 519 | |
| 520 | return 0; |
| 521 | } |
| 522 | |
| 523 | static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 524 | { |
| 525 | struct wmi_disconnect_event *ev; |
| 526 | wmi->traffic_class = 100; |
| 527 | |
| 528 | if (len < sizeof(struct wmi_disconnect_event)) |
| 529 | return -EINVAL; |
| 530 | |
| 531 | ev = (struct wmi_disconnect_event *) datap; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 532 | |
| 533 | wmi->is_wmm_enabled = false; |
| 534 | wmi->pair_crypto_type = NONE_CRYPT; |
| 535 | wmi->grp_crypto_type = NONE_CRYPT; |
| 536 | |
| 537 | ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason, |
| 538 | ev->bssid, ev->assoc_resp_len, ev->assoc_info, |
| 539 | le16_to_cpu(ev->proto_reason_status)); |
| 540 | |
| 541 | return 0; |
| 542 | } |
| 543 | |
| 544 | static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 545 | { |
| 546 | struct wmi_peer_node_event *ev; |
| 547 | |
| 548 | if (len < sizeof(struct wmi_peer_node_event)) |
| 549 | return -EINVAL; |
| 550 | |
| 551 | ev = (struct wmi_peer_node_event *) datap; |
| 552 | |
| 553 | if (ev->event_code == PEER_NODE_JOIN_EVENT) |
| 554 | ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n", |
| 555 | ev->peer_mac_addr); |
| 556 | else if (ev->event_code == PEER_NODE_LEAVE_EVENT) |
| 557 | ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n", |
| 558 | ev->peer_mac_addr); |
| 559 | |
| 560 | return 0; |
| 561 | } |
| 562 | |
| 563 | static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 564 | { |
| 565 | struct wmi_tkip_micerr_event *ev; |
| 566 | |
| 567 | if (len < sizeof(struct wmi_tkip_micerr_event)) |
| 568 | return -EINVAL; |
| 569 | |
| 570 | ev = (struct wmi_tkip_micerr_event *) datap; |
| 571 | |
| 572 | ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast); |
| 573 | |
| 574 | return 0; |
| 575 | } |
| 576 | |
| 577 | static int ath6kl_wlan_parse_beacon(u8 *buf, int frame_len, |
| 578 | struct ath6kl_common_ie *cie) |
| 579 | { |
| 580 | u8 *frm, *efrm; |
| 581 | u8 elemid_ssid = false; |
| 582 | |
| 583 | frm = buf; |
| 584 | efrm = (u8 *) (frm + frame_len); |
| 585 | |
| 586 | /* |
| 587 | * beacon/probe response frame format |
| 588 | * [8] time stamp |
| 589 | * [2] beacon interval |
| 590 | * [2] capability information |
| 591 | * [tlv] ssid |
| 592 | * [tlv] supported rates |
| 593 | * [tlv] country information |
| 594 | * [tlv] parameter set (FH/DS) |
| 595 | * [tlv] erp information |
| 596 | * [tlv] extended supported rates |
| 597 | * [tlv] WMM |
| 598 | * [tlv] WPA or RSN |
| 599 | * [tlv] Atheros Advanced Capabilities |
| 600 | */ |
| 601 | if ((efrm - frm) < 12) |
| 602 | return -EINVAL; |
| 603 | |
| 604 | memset(cie, 0, sizeof(*cie)); |
| 605 | |
| 606 | cie->ie_tstamp = frm; |
| 607 | frm += 8; |
| 608 | cie->ie_beaconInt = *(u16 *) frm; |
| 609 | frm += 2; |
| 610 | cie->ie_capInfo = *(u16 *) frm; |
| 611 | frm += 2; |
| 612 | cie->ie_chan = 0; |
| 613 | |
| 614 | while (frm < efrm) { |
| 615 | switch (*frm) { |
| 616 | case WLAN_EID_SSID: |
| 617 | if (!elemid_ssid) { |
| 618 | cie->ie_ssid = frm; |
| 619 | elemid_ssid = true; |
| 620 | } |
| 621 | break; |
| 622 | case WLAN_EID_SUPP_RATES: |
| 623 | cie->ie_rates = frm; |
| 624 | break; |
| 625 | case WLAN_EID_COUNTRY: |
| 626 | cie->ie_country = frm; |
| 627 | break; |
| 628 | case WLAN_EID_FH_PARAMS: |
| 629 | break; |
| 630 | case WLAN_EID_DS_PARAMS: |
| 631 | cie->ie_chan = frm[2]; |
| 632 | break; |
| 633 | case WLAN_EID_TIM: |
| 634 | cie->ie_tim = frm; |
| 635 | break; |
| 636 | case WLAN_EID_IBSS_PARAMS: |
| 637 | break; |
| 638 | case WLAN_EID_EXT_SUPP_RATES: |
| 639 | cie->ie_xrates = frm; |
| 640 | break; |
| 641 | case WLAN_EID_ERP_INFO: |
| 642 | if (frm[1] != 1) |
| 643 | return -EINVAL; |
| 644 | |
| 645 | cie->ie_erp = frm[2]; |
| 646 | break; |
| 647 | case WLAN_EID_RSN: |
| 648 | cie->ie_rsn = frm; |
| 649 | break; |
| 650 | case WLAN_EID_HT_CAPABILITY: |
| 651 | cie->ie_htcap = frm; |
| 652 | break; |
| 653 | case WLAN_EID_HT_INFORMATION: |
| 654 | cie->ie_htop = frm; |
| 655 | break; |
| 656 | case WLAN_EID_VENDOR_SPECIFIC: |
| 657 | if (frm[1] > 3 && frm[2] == 0x00 && frm[3] == 0x50 && |
| 658 | frm[4] == 0xf2) { |
| 659 | /* OUT Type (00:50:F2) */ |
| 660 | |
| 661 | if (frm[5] == WPA_OUI_TYPE) { |
| 662 | /* WPA OUT */ |
| 663 | cie->ie_wpa = frm; |
| 664 | } else if (frm[5] == WMM_OUI_TYPE) { |
| 665 | /* WMM OUT */ |
| 666 | cie->ie_wmm = frm; |
| 667 | } else if (frm[5] == WSC_OUT_TYPE) { |
| 668 | /* WSC OUT */ |
| 669 | cie->ie_wsc = frm; |
| 670 | } |
| 671 | |
| 672 | } else if (frm[1] > 3 && frm[2] == 0x00 |
| 673 | && frm[3] == 0x03 && frm[4] == 0x7f |
| 674 | && frm[5] == ATH_OUI_TYPE) { |
| 675 | /* Atheros OUI (00:03:7f) */ |
| 676 | cie->ie_ath = frm; |
| 677 | } |
| 678 | break; |
| 679 | default: |
| 680 | break; |
| 681 | } |
| 682 | frm += frm[1] + 2; |
| 683 | } |
| 684 | |
| 685 | if ((cie->ie_rates == NULL) |
| 686 | || (cie->ie_rates[1] > ATH6KL_RATE_MAXSIZE)) |
| 687 | return -EINVAL; |
| 688 | |
| 689 | if ((cie->ie_ssid == NULL) |
| 690 | || (cie->ie_ssid[1] > IEEE80211_MAX_SSID_LEN)) |
| 691 | return -EINVAL; |
| 692 | |
| 693 | return 0; |
| 694 | } |
| 695 | |
| 696 | static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 697 | { |
| 698 | struct bss *bss = NULL; |
| 699 | struct wmi_bss_info_hdr *bih; |
| 700 | u8 cached_ssid_len = 0; |
| 701 | u8 cached_ssid[IEEE80211_MAX_SSID_LEN] = { 0 }; |
| 702 | u8 beacon_ssid_len = 0; |
| 703 | u8 *buf, *ie_ssid; |
| 704 | u8 *ni_buf; |
| 705 | int buf_len; |
| 706 | |
| 707 | int ret; |
| 708 | |
| 709 | if (len <= sizeof(struct wmi_bss_info_hdr)) |
| 710 | return -EINVAL; |
| 711 | |
| 712 | bih = (struct wmi_bss_info_hdr *) datap; |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 713 | bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 714 | |
| 715 | if (a_sle16_to_cpu(bih->rssi) > 0) { |
| 716 | if (bss == NULL) |
| 717 | return 0; |
| 718 | else |
| 719 | bih->rssi = a_cpu_to_sle16(bss->ni_rssi); |
| 720 | } |
| 721 | |
| 722 | buf = datap + sizeof(struct wmi_bss_info_hdr); |
| 723 | len -= sizeof(struct wmi_bss_info_hdr); |
| 724 | |
| 725 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 726 | "bss info evt - ch %u, rssi %02x, bssid \"%pM\"\n", |
| 727 | bih->ch, a_sle16_to_cpu(bih->rssi), bih->bssid); |
| 728 | |
| 729 | if (bss != NULL) { |
| 730 | /* |
| 731 | * Free up the node. We are about to allocate a new node. |
| 732 | * In case of hidden AP, beacon will not have ssid, |
| 733 | * but a directed probe response will have it, |
| 734 | * so cache the probe-resp-ssid if already present. |
| 735 | */ |
| 736 | if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE)) { |
| 737 | ie_ssid = bss->ni_cie.ie_ssid; |
| 738 | if (ie_ssid && (ie_ssid[1] <= IEEE80211_MAX_SSID_LEN) && |
| 739 | (ie_ssid[2] != 0)) { |
| 740 | cached_ssid_len = ie_ssid[1]; |
| 741 | memcpy(cached_ssid, ie_ssid + 2, |
| 742 | cached_ssid_len); |
| 743 | } |
| 744 | } |
| 745 | |
| 746 | /* |
| 747 | * Use the current average rssi of associated AP base on |
| 748 | * assumption |
| 749 | * 1. Most os with GUI will update RSSI by |
| 750 | * ath6kl_wmi_get_stats_cmd() periodically. |
| 751 | * 2. ath6kl_wmi_get_stats_cmd(..) will be called when calling |
| 752 | * ath6kl_wmi_startscan_cmd(...) |
| 753 | * The average value of RSSI give end-user better feeling for |
| 754 | * instance value of scan result. It also sync up RSSI info |
| 755 | * in GUI between scan result and RSSI signal icon. |
| 756 | */ |
Vasanthakumar Thiagarajan | 70df051 | 2011-07-21 14:09:07 +0530 | [diff] [blame] | 757 | if (memcmp(wmi->parent_dev->bssid, bih->bssid, ETH_ALEN) == 0) { |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 758 | bih->rssi = a_cpu_to_sle16(bss->ni_rssi); |
| 759 | bih->snr = bss->ni_snr; |
| 760 | } |
| 761 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 762 | wlan_node_reclaim(&wmi->parent_dev->scan_table, bss); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 763 | } |
| 764 | |
| 765 | /* |
| 766 | * beacon/probe response frame format |
| 767 | * [8] time stamp |
| 768 | * [2] beacon interval |
| 769 | * [2] capability information |
| 770 | * [tlv] ssid |
| 771 | */ |
| 772 | beacon_ssid_len = buf[SSID_IE_LEN_INDEX]; |
| 773 | |
| 774 | /* |
| 775 | * If ssid is cached for this hidden AP, then change |
| 776 | * buffer len accordingly. |
| 777 | */ |
| 778 | if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && |
| 779 | (cached_ssid_len != 0) && |
| 780 | (beacon_ssid_len == 0 || (cached_ssid_len > beacon_ssid_len && |
| 781 | buf[SSID_IE_LEN_INDEX + 1] == 0))) { |
| 782 | |
| 783 | len += (cached_ssid_len - beacon_ssid_len); |
| 784 | } |
| 785 | |
| 786 | bss = wlan_node_alloc(len); |
| 787 | if (!bss) |
| 788 | return -ENOMEM; |
| 789 | |
| 790 | bss->ni_snr = bih->snr; |
| 791 | bss->ni_rssi = a_sle16_to_cpu(bih->rssi); |
| 792 | |
| 793 | if (WARN_ON(!bss->ni_buf)) |
| 794 | return -EINVAL; |
| 795 | |
| 796 | /* |
| 797 | * In case of hidden AP, beacon will not have ssid, |
| 798 | * but a directed probe response will have it, |
| 799 | * so place the cached-ssid(probe-resp) in the bss info. |
| 800 | */ |
| 801 | if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) && |
| 802 | (cached_ssid_len != 0) && |
| 803 | (beacon_ssid_len == 0 || (beacon_ssid_len && |
| 804 | buf[SSID_IE_LEN_INDEX + 1] == 0))) { |
| 805 | ni_buf = bss->ni_buf; |
| 806 | buf_len = len; |
| 807 | |
| 808 | /* |
| 809 | * Copy the first 14 bytes: |
| 810 | * time-stamp(8), beacon-interval(2), |
| 811 | * cap-info(2), ssid-id(1), ssid-len(1). |
| 812 | */ |
| 813 | memcpy(ni_buf, buf, SSID_IE_LEN_INDEX + 1); |
| 814 | |
| 815 | ni_buf[SSID_IE_LEN_INDEX] = cached_ssid_len; |
| 816 | ni_buf += (SSID_IE_LEN_INDEX + 1); |
| 817 | |
| 818 | buf += (SSID_IE_LEN_INDEX + 1); |
| 819 | buf_len -= (SSID_IE_LEN_INDEX + 1); |
| 820 | |
| 821 | memcpy(ni_buf, cached_ssid, cached_ssid_len); |
| 822 | ni_buf += cached_ssid_len; |
| 823 | |
| 824 | buf += beacon_ssid_len; |
| 825 | buf_len -= beacon_ssid_len; |
| 826 | |
| 827 | if (cached_ssid_len > beacon_ssid_len) |
| 828 | buf_len -= (cached_ssid_len - beacon_ssid_len); |
| 829 | |
| 830 | memcpy(ni_buf, buf, buf_len); |
| 831 | } else |
| 832 | memcpy(bss->ni_buf, buf, len); |
| 833 | |
| 834 | bss->ni_framelen = len; |
| 835 | |
| 836 | ret = ath6kl_wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie); |
| 837 | if (ret) { |
| 838 | wlan_node_free(bss); |
| 839 | return -EINVAL; |
| 840 | } |
| 841 | |
| 842 | /* |
| 843 | * Update the frequency in ie_chan, overwriting of channel number |
| 844 | * which is done in ath6kl_wlan_parse_beacon |
| 845 | */ |
| 846 | bss->ni_cie.ie_chan = le16_to_cpu(bih->ch); |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 847 | wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 848 | |
| 849 | return 0; |
| 850 | } |
| 851 | |
| 852 | static int ath6kl_wmi_opt_frame_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 853 | { |
| 854 | struct bss *bss; |
| 855 | struct wmi_opt_rx_info_hdr *bih; |
| 856 | u8 *buf; |
| 857 | |
| 858 | if (len <= sizeof(struct wmi_opt_rx_info_hdr)) |
| 859 | return -EINVAL; |
| 860 | |
| 861 | bih = (struct wmi_opt_rx_info_hdr *) datap; |
| 862 | buf = datap + sizeof(struct wmi_opt_rx_info_hdr); |
| 863 | len -= sizeof(struct wmi_opt_rx_info_hdr); |
| 864 | |
| 865 | ath6kl_dbg(ATH6KL_DBG_WMI, "opt frame event %2.2x:%2.2x\n", |
| 866 | bih->bssid[4], bih->bssid[5]); |
| 867 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 868 | bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 869 | if (bss != NULL) { |
| 870 | /* Free up the node. We are about to allocate a new node. */ |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 871 | wlan_node_reclaim(&wmi->parent_dev->scan_table, bss); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 872 | } |
| 873 | |
| 874 | bss = wlan_node_alloc(len); |
| 875 | if (!bss) |
| 876 | return -ENOMEM; |
| 877 | |
| 878 | bss->ni_snr = bih->snr; |
| 879 | bss->ni_cie.ie_chan = le16_to_cpu(bih->ch); |
| 880 | |
| 881 | if (WARN_ON(!bss->ni_buf)) |
| 882 | return -EINVAL; |
| 883 | |
| 884 | memcpy(bss->ni_buf, buf, len); |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 885 | wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 886 | |
| 887 | return 0; |
| 888 | } |
| 889 | |
| 890 | /* Inactivity timeout of a fatpipe(pstream) at the target */ |
| 891 | static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap, |
| 892 | int len) |
| 893 | { |
| 894 | struct wmi_pstream_timeout_event *ev; |
| 895 | |
| 896 | if (len < sizeof(struct wmi_pstream_timeout_event)) |
| 897 | return -EINVAL; |
| 898 | |
| 899 | ev = (struct wmi_pstream_timeout_event *) datap; |
| 900 | |
| 901 | /* |
| 902 | * When the pstream (fat pipe == AC) timesout, it means there were |
| 903 | * no thinStreams within this pstream & it got implicitly created |
| 904 | * due to data flow on this AC. We start the inactivity timer only |
| 905 | * for implicitly created pstream. Just reset the host state. |
| 906 | */ |
| 907 | spin_lock_bh(&wmi->lock); |
| 908 | wmi->stream_exist_for_ac[ev->traffic_class] = 0; |
| 909 | wmi->fat_pipe_exist &= ~(1 << ev->traffic_class); |
| 910 | spin_unlock_bh(&wmi->lock); |
| 911 | |
| 912 | /* Indicate inactivity to driver layer for this fatpipe (pstream) */ |
| 913 | ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false); |
| 914 | |
| 915 | return 0; |
| 916 | } |
| 917 | |
| 918 | static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 919 | { |
| 920 | struct wmi_bit_rate_reply *reply; |
| 921 | s32 rate; |
| 922 | u32 sgi, index; |
| 923 | |
| 924 | if (len < sizeof(struct wmi_bit_rate_reply)) |
| 925 | return -EINVAL; |
| 926 | |
| 927 | reply = (struct wmi_bit_rate_reply *) datap; |
| 928 | |
| 929 | ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index); |
| 930 | |
| 931 | if (reply->rate_index == (s8) RATE_AUTO) { |
| 932 | rate = RATE_AUTO; |
| 933 | } else { |
| 934 | index = reply->rate_index & 0x7f; |
| 935 | sgi = (reply->rate_index & 0x80) ? 1 : 0; |
| 936 | rate = wmi_rate_tbl[index][sgi]; |
| 937 | } |
| 938 | |
| 939 | ath6kl_wakeup_event(wmi->parent_dev); |
| 940 | |
| 941 | return 0; |
| 942 | } |
| 943 | |
| 944 | static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 945 | { |
| 946 | if (len < sizeof(struct wmi_fix_rates_reply)) |
| 947 | return -EINVAL; |
| 948 | |
| 949 | ath6kl_wakeup_event(wmi->parent_dev); |
| 950 | |
| 951 | return 0; |
| 952 | } |
| 953 | |
| 954 | static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 955 | { |
| 956 | if (len < sizeof(struct wmi_channel_list_reply)) |
| 957 | return -EINVAL; |
| 958 | |
| 959 | ath6kl_wakeup_event(wmi->parent_dev); |
| 960 | |
| 961 | return 0; |
| 962 | } |
| 963 | |
| 964 | static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 965 | { |
| 966 | struct wmi_tx_pwr_reply *reply; |
| 967 | |
| 968 | if (len < sizeof(struct wmi_tx_pwr_reply)) |
| 969 | return -EINVAL; |
| 970 | |
| 971 | reply = (struct wmi_tx_pwr_reply *) datap; |
| 972 | ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM); |
| 973 | |
| 974 | return 0; |
| 975 | } |
| 976 | |
| 977 | static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len) |
| 978 | { |
| 979 | if (len < sizeof(struct wmi_get_keepalive_cmd)) |
| 980 | return -EINVAL; |
| 981 | |
| 982 | ath6kl_wakeup_event(wmi->parent_dev); |
| 983 | |
| 984 | return 0; |
| 985 | } |
| 986 | |
| 987 | static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len) |
| 988 | { |
| 989 | struct wmi_scan_complete_event *ev; |
| 990 | |
| 991 | ev = (struct wmi_scan_complete_event *) datap; |
| 992 | |
| 993 | if (a_sle32_to_cpu(ev->status) == 0) |
Vasanthakumar Thiagarajan | e4c7ffc | 2011-07-21 13:49:32 +0530 | [diff] [blame] | 994 | wlan_refresh_inactive_nodes(wmi->parent_dev); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 995 | |
| 996 | ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status)); |
| 997 | wmi->is_probe_ssid = false; |
| 998 | |
| 999 | return 0; |
| 1000 | } |
| 1001 | |
| 1002 | /* |
| 1003 | * Target is reporting a programming error. This is for |
| 1004 | * developer aid only. Target only checks a few common violations |
| 1005 | * and it is responsibility of host to do all error checking. |
| 1006 | * Behavior of target after wmi error event is undefined. |
| 1007 | * A reset is recommended. |
| 1008 | */ |
| 1009 | static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1010 | { |
| 1011 | const char *type = "unknown error"; |
| 1012 | struct wmi_cmd_error_event *ev; |
| 1013 | ev = (struct wmi_cmd_error_event *) datap; |
| 1014 | |
| 1015 | switch (ev->err_code) { |
| 1016 | case INVALID_PARAM: |
| 1017 | type = "invalid parameter"; |
| 1018 | break; |
| 1019 | case ILLEGAL_STATE: |
| 1020 | type = "invalid state"; |
| 1021 | break; |
| 1022 | case INTERNAL_ERROR: |
| 1023 | type = "internal error"; |
| 1024 | break; |
| 1025 | } |
| 1026 | |
| 1027 | ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n", |
| 1028 | ev->cmd_id, type); |
| 1029 | |
| 1030 | return 0; |
| 1031 | } |
| 1032 | |
| 1033 | static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1034 | { |
| 1035 | ath6kl_tgt_stats_event(wmi->parent_dev, datap, len); |
| 1036 | |
| 1037 | return 0; |
| 1038 | } |
| 1039 | |
| 1040 | static u8 ath6kl_wmi_get_upper_threshold(s16 rssi, |
| 1041 | struct sq_threshold_params *sq_thresh, |
| 1042 | u32 size) |
| 1043 | { |
| 1044 | u32 index; |
| 1045 | u8 threshold = (u8) sq_thresh->upper_threshold[size - 1]; |
| 1046 | |
| 1047 | /* The list is already in sorted order. Get the next lower value */ |
| 1048 | for (index = 0; index < size; index++) { |
| 1049 | if (rssi < sq_thresh->upper_threshold[index]) { |
| 1050 | threshold = (u8) sq_thresh->upper_threshold[index]; |
| 1051 | break; |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | return threshold; |
| 1056 | } |
| 1057 | |
| 1058 | static u8 ath6kl_wmi_get_lower_threshold(s16 rssi, |
| 1059 | struct sq_threshold_params *sq_thresh, |
| 1060 | u32 size) |
| 1061 | { |
| 1062 | u32 index; |
| 1063 | u8 threshold = (u8) sq_thresh->lower_threshold[size - 1]; |
| 1064 | |
| 1065 | /* The list is already in sorted order. Get the next lower value */ |
| 1066 | for (index = 0; index < size; index++) { |
| 1067 | if (rssi > sq_thresh->lower_threshold[index]) { |
| 1068 | threshold = (u8) sq_thresh->lower_threshold[index]; |
| 1069 | break; |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | return threshold; |
| 1074 | } |
| 1075 | |
| 1076 | static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi, |
| 1077 | struct wmi_rssi_threshold_params_cmd *rssi_cmd) |
| 1078 | { |
| 1079 | struct sk_buff *skb; |
| 1080 | struct wmi_rssi_threshold_params_cmd *cmd; |
| 1081 | |
| 1082 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1083 | if (!skb) |
| 1084 | return -ENOMEM; |
| 1085 | |
| 1086 | cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data; |
| 1087 | memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd)); |
| 1088 | |
| 1089 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID, |
| 1090 | NO_SYNC_WMIFLAG); |
| 1091 | } |
| 1092 | |
| 1093 | static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap, |
| 1094 | int len) |
| 1095 | { |
| 1096 | struct wmi_rssi_threshold_event *reply; |
| 1097 | struct wmi_rssi_threshold_params_cmd cmd; |
| 1098 | struct sq_threshold_params *sq_thresh; |
| 1099 | enum wmi_rssi_threshold_val new_threshold; |
| 1100 | u8 upper_rssi_threshold, lower_rssi_threshold; |
| 1101 | s16 rssi; |
| 1102 | int ret; |
| 1103 | |
| 1104 | if (len < sizeof(struct wmi_rssi_threshold_event)) |
| 1105 | return -EINVAL; |
| 1106 | |
| 1107 | reply = (struct wmi_rssi_threshold_event *) datap; |
| 1108 | new_threshold = (enum wmi_rssi_threshold_val) reply->range; |
| 1109 | rssi = a_sle16_to_cpu(reply->rssi); |
| 1110 | |
| 1111 | sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI]; |
| 1112 | |
| 1113 | /* |
| 1114 | * Identify the threshold breached and communicate that to the app. |
| 1115 | * After that install a new set of thresholds based on the signal |
| 1116 | * quality reported by the target |
| 1117 | */ |
| 1118 | if (new_threshold) { |
| 1119 | /* Upper threshold breached */ |
| 1120 | if (rssi < sq_thresh->upper_threshold[0]) { |
| 1121 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1122 | "spurious upper rssi threshold event: %d\n", |
| 1123 | rssi); |
| 1124 | } else if ((rssi < sq_thresh->upper_threshold[1]) && |
| 1125 | (rssi >= sq_thresh->upper_threshold[0])) { |
| 1126 | new_threshold = WMI_RSSI_THRESHOLD1_ABOVE; |
| 1127 | } else if ((rssi < sq_thresh->upper_threshold[2]) && |
| 1128 | (rssi >= sq_thresh->upper_threshold[1])) { |
| 1129 | new_threshold = WMI_RSSI_THRESHOLD2_ABOVE; |
| 1130 | } else if ((rssi < sq_thresh->upper_threshold[3]) && |
| 1131 | (rssi >= sq_thresh->upper_threshold[2])) { |
| 1132 | new_threshold = WMI_RSSI_THRESHOLD3_ABOVE; |
| 1133 | } else if ((rssi < sq_thresh->upper_threshold[4]) && |
| 1134 | (rssi >= sq_thresh->upper_threshold[3])) { |
| 1135 | new_threshold = WMI_RSSI_THRESHOLD4_ABOVE; |
| 1136 | } else if ((rssi < sq_thresh->upper_threshold[5]) && |
| 1137 | (rssi >= sq_thresh->upper_threshold[4])) { |
| 1138 | new_threshold = WMI_RSSI_THRESHOLD5_ABOVE; |
| 1139 | } else if (rssi >= sq_thresh->upper_threshold[5]) { |
| 1140 | new_threshold = WMI_RSSI_THRESHOLD6_ABOVE; |
| 1141 | } |
| 1142 | } else { |
| 1143 | /* Lower threshold breached */ |
| 1144 | if (rssi > sq_thresh->lower_threshold[0]) { |
| 1145 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1146 | "spurious lower rssi threshold event: %d %d\n", |
| 1147 | rssi, sq_thresh->lower_threshold[0]); |
| 1148 | } else if ((rssi > sq_thresh->lower_threshold[1]) && |
| 1149 | (rssi <= sq_thresh->lower_threshold[0])) { |
| 1150 | new_threshold = WMI_RSSI_THRESHOLD6_BELOW; |
| 1151 | } else if ((rssi > sq_thresh->lower_threshold[2]) && |
| 1152 | (rssi <= sq_thresh->lower_threshold[1])) { |
| 1153 | new_threshold = WMI_RSSI_THRESHOLD5_BELOW; |
| 1154 | } else if ((rssi > sq_thresh->lower_threshold[3]) && |
| 1155 | (rssi <= sq_thresh->lower_threshold[2])) { |
| 1156 | new_threshold = WMI_RSSI_THRESHOLD4_BELOW; |
| 1157 | } else if ((rssi > sq_thresh->lower_threshold[4]) && |
| 1158 | (rssi <= sq_thresh->lower_threshold[3])) { |
| 1159 | new_threshold = WMI_RSSI_THRESHOLD3_BELOW; |
| 1160 | } else if ((rssi > sq_thresh->lower_threshold[5]) && |
| 1161 | (rssi <= sq_thresh->lower_threshold[4])) { |
| 1162 | new_threshold = WMI_RSSI_THRESHOLD2_BELOW; |
| 1163 | } else if (rssi <= sq_thresh->lower_threshold[5]) { |
| 1164 | new_threshold = WMI_RSSI_THRESHOLD1_BELOW; |
| 1165 | } |
| 1166 | } |
| 1167 | |
| 1168 | /* Calculate and install the next set of thresholds */ |
| 1169 | lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh, |
| 1170 | sq_thresh->lower_threshold_valid_count); |
| 1171 | upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh, |
| 1172 | sq_thresh->upper_threshold_valid_count); |
| 1173 | |
| 1174 | /* Issue a wmi command to install the thresholds */ |
| 1175 | cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold); |
| 1176 | cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold); |
| 1177 | cmd.weight = sq_thresh->weight; |
| 1178 | cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); |
| 1179 | |
| 1180 | ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd); |
| 1181 | if (ret) { |
| 1182 | ath6kl_err("unable to configure rssi thresholds\n"); |
| 1183 | return -EIO; |
| 1184 | } |
| 1185 | |
| 1186 | return 0; |
| 1187 | } |
| 1188 | |
| 1189 | static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1190 | { |
| 1191 | struct wmi_cac_event *reply; |
| 1192 | struct ieee80211_tspec_ie *ts; |
| 1193 | u16 active_tsids, tsinfo; |
| 1194 | u8 tsid, index; |
| 1195 | u8 ts_id; |
| 1196 | |
| 1197 | if (len < sizeof(struct wmi_cac_event)) |
| 1198 | return -EINVAL; |
| 1199 | |
| 1200 | reply = (struct wmi_cac_event *) datap; |
| 1201 | |
| 1202 | if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) && |
| 1203 | (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) { |
| 1204 | |
| 1205 | ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); |
| 1206 | tsinfo = le16_to_cpu(ts->tsinfo); |
| 1207 | tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & |
| 1208 | IEEE80211_WMM_IE_TSPEC_TID_MASK; |
| 1209 | |
| 1210 | ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid); |
| 1211 | } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) { |
| 1212 | /* |
| 1213 | * Following assumes that there is only one outstanding |
| 1214 | * ADDTS request when this event is received |
| 1215 | */ |
| 1216 | spin_lock_bh(&wmi->lock); |
| 1217 | active_tsids = wmi->stream_exist_for_ac[reply->ac]; |
| 1218 | spin_unlock_bh(&wmi->lock); |
| 1219 | |
| 1220 | for (index = 0; index < sizeof(active_tsids) * 8; index++) { |
| 1221 | if ((active_tsids >> index) & 1) |
| 1222 | break; |
| 1223 | } |
| 1224 | if (index < (sizeof(active_tsids) * 8)) |
| 1225 | ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index); |
| 1226 | } |
| 1227 | |
| 1228 | /* |
| 1229 | * Clear active tsids and Add missing handling |
| 1230 | * for delete qos stream from AP |
| 1231 | */ |
| 1232 | else if (reply->cac_indication == CAC_INDICATION_DELETE) { |
| 1233 | |
| 1234 | ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion); |
| 1235 | tsinfo = le16_to_cpu(ts->tsinfo); |
| 1236 | ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) & |
| 1237 | IEEE80211_WMM_IE_TSPEC_TID_MASK); |
| 1238 | |
| 1239 | spin_lock_bh(&wmi->lock); |
| 1240 | wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id); |
| 1241 | active_tsids = wmi->stream_exist_for_ac[reply->ac]; |
| 1242 | spin_unlock_bh(&wmi->lock); |
| 1243 | |
| 1244 | /* Indicate stream inactivity to driver layer only if all tsids |
| 1245 | * within this AC are deleted. |
| 1246 | */ |
| 1247 | if (!active_tsids) { |
| 1248 | ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac, |
| 1249 | false); |
| 1250 | wmi->fat_pipe_exist &= ~(1 << reply->ac); |
| 1251 | } |
| 1252 | } |
| 1253 | |
| 1254 | return 0; |
| 1255 | } |
| 1256 | |
| 1257 | static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi, |
| 1258 | struct wmi_snr_threshold_params_cmd *snr_cmd) |
| 1259 | { |
| 1260 | struct sk_buff *skb; |
| 1261 | struct wmi_snr_threshold_params_cmd *cmd; |
| 1262 | |
| 1263 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1264 | if (!skb) |
| 1265 | return -ENOMEM; |
| 1266 | |
| 1267 | cmd = (struct wmi_snr_threshold_params_cmd *) skb->data; |
| 1268 | memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd)); |
| 1269 | |
| 1270 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID, |
| 1271 | NO_SYNC_WMIFLAG); |
| 1272 | } |
| 1273 | |
| 1274 | static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap, |
| 1275 | int len) |
| 1276 | { |
| 1277 | struct wmi_snr_threshold_event *reply; |
| 1278 | struct sq_threshold_params *sq_thresh; |
| 1279 | struct wmi_snr_threshold_params_cmd cmd; |
| 1280 | enum wmi_snr_threshold_val new_threshold; |
| 1281 | u8 upper_snr_threshold, lower_snr_threshold; |
| 1282 | s16 snr; |
| 1283 | int ret; |
| 1284 | |
| 1285 | if (len < sizeof(struct wmi_snr_threshold_event)) |
| 1286 | return -EINVAL; |
| 1287 | |
| 1288 | reply = (struct wmi_snr_threshold_event *) datap; |
| 1289 | |
| 1290 | new_threshold = (enum wmi_snr_threshold_val) reply->range; |
| 1291 | snr = reply->snr; |
| 1292 | |
| 1293 | sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR]; |
| 1294 | |
| 1295 | /* |
| 1296 | * Identify the threshold breached and communicate that to the app. |
| 1297 | * After that install a new set of thresholds based on the signal |
| 1298 | * quality reported by the target. |
| 1299 | */ |
| 1300 | if (new_threshold) { |
| 1301 | /* Upper threshold breached */ |
| 1302 | if (snr < sq_thresh->upper_threshold[0]) { |
| 1303 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1304 | "spurious upper snr threshold event: %d\n", |
| 1305 | snr); |
| 1306 | } else if ((snr < sq_thresh->upper_threshold[1]) && |
| 1307 | (snr >= sq_thresh->upper_threshold[0])) { |
| 1308 | new_threshold = WMI_SNR_THRESHOLD1_ABOVE; |
| 1309 | } else if ((snr < sq_thresh->upper_threshold[2]) && |
| 1310 | (snr >= sq_thresh->upper_threshold[1])) { |
| 1311 | new_threshold = WMI_SNR_THRESHOLD2_ABOVE; |
| 1312 | } else if ((snr < sq_thresh->upper_threshold[3]) && |
| 1313 | (snr >= sq_thresh->upper_threshold[2])) { |
| 1314 | new_threshold = WMI_SNR_THRESHOLD3_ABOVE; |
| 1315 | } else if (snr >= sq_thresh->upper_threshold[3]) { |
| 1316 | new_threshold = WMI_SNR_THRESHOLD4_ABOVE; |
| 1317 | } |
| 1318 | } else { |
| 1319 | /* Lower threshold breached */ |
| 1320 | if (snr > sq_thresh->lower_threshold[0]) { |
| 1321 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1322 | "spurious lower snr threshold event: %d\n", |
| 1323 | sq_thresh->lower_threshold[0]); |
| 1324 | } else if ((snr > sq_thresh->lower_threshold[1]) && |
| 1325 | (snr <= sq_thresh->lower_threshold[0])) { |
| 1326 | new_threshold = WMI_SNR_THRESHOLD4_BELOW; |
| 1327 | } else if ((snr > sq_thresh->lower_threshold[2]) && |
| 1328 | (snr <= sq_thresh->lower_threshold[1])) { |
| 1329 | new_threshold = WMI_SNR_THRESHOLD3_BELOW; |
| 1330 | } else if ((snr > sq_thresh->lower_threshold[3]) && |
| 1331 | (snr <= sq_thresh->lower_threshold[2])) { |
| 1332 | new_threshold = WMI_SNR_THRESHOLD2_BELOW; |
| 1333 | } else if (snr <= sq_thresh->lower_threshold[3]) { |
| 1334 | new_threshold = WMI_SNR_THRESHOLD1_BELOW; |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | /* Calculate and install the next set of thresholds */ |
| 1339 | lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh, |
| 1340 | sq_thresh->lower_threshold_valid_count); |
| 1341 | upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh, |
| 1342 | sq_thresh->upper_threshold_valid_count); |
| 1343 | |
| 1344 | /* Issue a wmi command to install the thresholds */ |
| 1345 | cmd.thresh_above1_val = upper_snr_threshold; |
| 1346 | cmd.thresh_below1_val = lower_snr_threshold; |
| 1347 | cmd.weight = sq_thresh->weight; |
| 1348 | cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval); |
| 1349 | |
| 1350 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1351 | "snr: %d, threshold: %d, lower: %d, upper: %d\n", |
| 1352 | snr, new_threshold, |
| 1353 | lower_snr_threshold, upper_snr_threshold); |
| 1354 | |
| 1355 | ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd); |
| 1356 | if (ret) { |
| 1357 | ath6kl_err("unable to configure snr threshold\n"); |
| 1358 | return -EIO; |
| 1359 | } |
| 1360 | |
| 1361 | return 0; |
| 1362 | } |
| 1363 | |
| 1364 | static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 1365 | { |
| 1366 | u16 ap_info_entry_size; |
| 1367 | struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap; |
| 1368 | struct wmi_ap_info_v1 *ap_info_v1; |
| 1369 | u8 index; |
| 1370 | |
| 1371 | if (len < sizeof(struct wmi_aplist_event) || |
| 1372 | ev->ap_list_ver != APLIST_VER1) |
| 1373 | return -EINVAL; |
| 1374 | |
| 1375 | ap_info_entry_size = sizeof(struct wmi_ap_info_v1); |
| 1376 | ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list; |
| 1377 | |
| 1378 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 1379 | "number of APs in aplist event: %d\n", ev->num_ap); |
| 1380 | |
| 1381 | if (len < (int) (sizeof(struct wmi_aplist_event) + |
| 1382 | (ev->num_ap - 1) * ap_info_entry_size)) |
| 1383 | return -EINVAL; |
| 1384 | |
| 1385 | /* AP list version 1 contents */ |
| 1386 | for (index = 0; index < ev->num_ap; index++) { |
| 1387 | ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n", |
| 1388 | index, ap_info_v1->bssid, ap_info_v1->channel); |
| 1389 | ap_info_v1++; |
| 1390 | } |
| 1391 | |
| 1392 | return 0; |
| 1393 | } |
| 1394 | |
| 1395 | int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb, |
| 1396 | enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag) |
| 1397 | { |
| 1398 | struct wmi_cmd_hdr *cmd_hdr; |
| 1399 | enum htc_endpoint_id ep_id = wmi->ep_id; |
| 1400 | int ret; |
| 1401 | |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 1402 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: cmd_id=%d\n", __func__, cmd_id); |
| 1403 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1404 | if (WARN_ON(skb == NULL)) |
| 1405 | return -EINVAL; |
| 1406 | |
| 1407 | if (sync_flag >= END_WMIFLAG) { |
| 1408 | dev_kfree_skb(skb); |
| 1409 | return -EINVAL; |
| 1410 | } |
| 1411 | |
| 1412 | if ((sync_flag == SYNC_BEFORE_WMIFLAG) || |
| 1413 | (sync_flag == SYNC_BOTH_WMIFLAG)) { |
| 1414 | /* |
| 1415 | * Make sure all data currently queued is transmitted before |
| 1416 | * the cmd execution. Establish a new sync point. |
| 1417 | */ |
| 1418 | ath6kl_wmi_sync_point(wmi); |
| 1419 | } |
| 1420 | |
| 1421 | skb_push(skb, sizeof(struct wmi_cmd_hdr)); |
| 1422 | |
| 1423 | cmd_hdr = (struct wmi_cmd_hdr *) skb->data; |
| 1424 | cmd_hdr->cmd_id = cpu_to_le16(cmd_id); |
| 1425 | cmd_hdr->info1 = 0; /* added for virtual interface */ |
| 1426 | |
| 1427 | /* Only for OPT_TX_CMD, use BE endpoint. */ |
| 1428 | if (cmd_id == WMI_OPT_TX_FRAME_CMDID) { |
| 1429 | ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE, |
| 1430 | false, false, 0, NULL); |
| 1431 | if (ret) { |
| 1432 | dev_kfree_skb(skb); |
| 1433 | return ret; |
| 1434 | } |
| 1435 | ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE); |
| 1436 | } |
| 1437 | |
| 1438 | ath6kl_control_tx(wmi->parent_dev, skb, ep_id); |
| 1439 | |
| 1440 | if ((sync_flag == SYNC_AFTER_WMIFLAG) || |
| 1441 | (sync_flag == SYNC_BOTH_WMIFLAG)) { |
| 1442 | /* |
| 1443 | * Make sure all new data queued waits for the command to |
| 1444 | * execute. Establish a new sync point. |
| 1445 | */ |
| 1446 | ath6kl_wmi_sync_point(wmi); |
| 1447 | } |
| 1448 | |
| 1449 | return 0; |
| 1450 | } |
| 1451 | |
| 1452 | int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type, |
| 1453 | enum dot11_auth_mode dot11_auth_mode, |
| 1454 | enum auth_mode auth_mode, |
| 1455 | enum crypto_type pairwise_crypto, |
| 1456 | u8 pairwise_crypto_len, |
| 1457 | enum crypto_type group_crypto, |
| 1458 | u8 group_crypto_len, int ssid_len, u8 *ssid, |
| 1459 | u8 *bssid, u16 channel, u32 ctrl_flags) |
| 1460 | { |
| 1461 | struct sk_buff *skb; |
| 1462 | struct wmi_connect_cmd *cc; |
| 1463 | int ret; |
| 1464 | |
| 1465 | wmi->traffic_class = 100; |
| 1466 | |
| 1467 | if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT)) |
| 1468 | return -EINVAL; |
| 1469 | |
| 1470 | if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT)) |
| 1471 | return -EINVAL; |
| 1472 | |
| 1473 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd)); |
| 1474 | if (!skb) |
| 1475 | return -ENOMEM; |
| 1476 | |
| 1477 | cc = (struct wmi_connect_cmd *) skb->data; |
| 1478 | |
| 1479 | if (ssid_len) |
| 1480 | memcpy(cc->ssid, ssid, ssid_len); |
| 1481 | |
| 1482 | cc->ssid_len = ssid_len; |
| 1483 | cc->nw_type = nw_type; |
| 1484 | cc->dot11_auth_mode = dot11_auth_mode; |
| 1485 | cc->auth_mode = auth_mode; |
| 1486 | cc->prwise_crypto_type = pairwise_crypto; |
| 1487 | cc->prwise_crypto_len = pairwise_crypto_len; |
| 1488 | cc->grp_crypto_type = group_crypto; |
| 1489 | cc->grp_crypto_len = group_crypto_len; |
| 1490 | cc->ch = cpu_to_le16(channel); |
| 1491 | cc->ctrl_flags = cpu_to_le32(ctrl_flags); |
| 1492 | |
| 1493 | if (bssid != NULL) |
| 1494 | memcpy(cc->bssid, bssid, ETH_ALEN); |
| 1495 | |
| 1496 | wmi->pair_crypto_type = pairwise_crypto; |
| 1497 | wmi->grp_crypto_type = group_crypto; |
| 1498 | |
| 1499 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG); |
| 1500 | |
| 1501 | return ret; |
| 1502 | } |
| 1503 | |
| 1504 | int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel) |
| 1505 | { |
| 1506 | struct sk_buff *skb; |
| 1507 | struct wmi_reconnect_cmd *cc; |
| 1508 | int ret; |
| 1509 | |
| 1510 | wmi->traffic_class = 100; |
| 1511 | |
| 1512 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd)); |
| 1513 | if (!skb) |
| 1514 | return -ENOMEM; |
| 1515 | |
| 1516 | cc = (struct wmi_reconnect_cmd *) skb->data; |
| 1517 | cc->channel = cpu_to_le16(channel); |
| 1518 | |
| 1519 | if (bssid != NULL) |
| 1520 | memcpy(cc->bssid, bssid, ETH_ALEN); |
| 1521 | |
| 1522 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID, |
| 1523 | NO_SYNC_WMIFLAG); |
| 1524 | |
| 1525 | return ret; |
| 1526 | } |
| 1527 | |
| 1528 | int ath6kl_wmi_disconnect_cmd(struct wmi *wmi) |
| 1529 | { |
| 1530 | int ret; |
| 1531 | |
| 1532 | wmi->traffic_class = 100; |
| 1533 | |
| 1534 | /* Disconnect command does not need to do a SYNC before. */ |
| 1535 | ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID); |
| 1536 | |
| 1537 | return ret; |
| 1538 | } |
| 1539 | |
| 1540 | int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type, |
| 1541 | u32 force_fgscan, u32 is_legacy, |
| 1542 | u32 home_dwell_time, u32 force_scan_interval, |
| 1543 | s8 num_chan, u16 *ch_list) |
| 1544 | { |
| 1545 | struct sk_buff *skb; |
| 1546 | struct wmi_start_scan_cmd *sc; |
| 1547 | s8 size; |
| 1548 | int ret; |
| 1549 | |
| 1550 | size = sizeof(struct wmi_start_scan_cmd); |
| 1551 | |
| 1552 | if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN)) |
| 1553 | return -EINVAL; |
| 1554 | |
| 1555 | if (num_chan > WMI_MAX_CHANNELS) |
| 1556 | return -EINVAL; |
| 1557 | |
| 1558 | if (num_chan) |
| 1559 | size += sizeof(u16) * (num_chan - 1); |
| 1560 | |
| 1561 | skb = ath6kl_wmi_get_new_buf(size); |
| 1562 | if (!skb) |
| 1563 | return -ENOMEM; |
| 1564 | |
| 1565 | sc = (struct wmi_start_scan_cmd *) skb->data; |
| 1566 | sc->scan_type = scan_type; |
| 1567 | sc->force_fg_scan = cpu_to_le32(force_fgscan); |
| 1568 | sc->is_legacy = cpu_to_le32(is_legacy); |
| 1569 | sc->home_dwell_time = cpu_to_le32(home_dwell_time); |
| 1570 | sc->force_scan_intvl = cpu_to_le32(force_scan_interval); |
| 1571 | sc->num_ch = num_chan; |
| 1572 | |
| 1573 | if (num_chan) |
| 1574 | memcpy(sc->ch_list, ch_list, num_chan * sizeof(u16)); |
| 1575 | |
| 1576 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID, |
| 1577 | NO_SYNC_WMIFLAG); |
| 1578 | |
| 1579 | return ret; |
| 1580 | } |
| 1581 | |
| 1582 | int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec, |
| 1583 | u16 fg_end_sec, u16 bg_sec, |
| 1584 | u16 minact_chdw_msec, u16 maxact_chdw_msec, |
| 1585 | u16 pas_chdw_msec, u8 short_scan_ratio, |
| 1586 | u8 scan_ctrl_flag, u32 max_dfsch_act_time, |
| 1587 | u16 maxact_scan_per_ssid) |
| 1588 | { |
| 1589 | struct sk_buff *skb; |
| 1590 | struct wmi_scan_params_cmd *sc; |
| 1591 | int ret; |
| 1592 | |
| 1593 | skb = ath6kl_wmi_get_new_buf(sizeof(*sc)); |
| 1594 | if (!skb) |
| 1595 | return -ENOMEM; |
| 1596 | |
| 1597 | sc = (struct wmi_scan_params_cmd *) skb->data; |
| 1598 | sc->fg_start_period = cpu_to_le16(fg_start_sec); |
| 1599 | sc->fg_end_period = cpu_to_le16(fg_end_sec); |
| 1600 | sc->bg_period = cpu_to_le16(bg_sec); |
| 1601 | sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec); |
| 1602 | sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec); |
| 1603 | sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec); |
| 1604 | sc->short_scan_ratio = short_scan_ratio; |
| 1605 | sc->scan_ctrl_flags = scan_ctrl_flag; |
| 1606 | sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time); |
| 1607 | sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid); |
| 1608 | |
| 1609 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID, |
| 1610 | NO_SYNC_WMIFLAG); |
| 1611 | return ret; |
| 1612 | } |
| 1613 | |
| 1614 | int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask) |
| 1615 | { |
| 1616 | struct sk_buff *skb; |
| 1617 | struct wmi_bss_filter_cmd *cmd; |
| 1618 | int ret; |
| 1619 | |
| 1620 | if (filter >= LAST_BSS_FILTER) |
| 1621 | return -EINVAL; |
| 1622 | |
| 1623 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1624 | if (!skb) |
| 1625 | return -ENOMEM; |
| 1626 | |
| 1627 | cmd = (struct wmi_bss_filter_cmd *) skb->data; |
| 1628 | cmd->bss_filter = filter; |
| 1629 | cmd->ie_mask = cpu_to_le32(ie_mask); |
| 1630 | |
| 1631 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID, |
| 1632 | NO_SYNC_WMIFLAG); |
| 1633 | return ret; |
| 1634 | } |
| 1635 | |
| 1636 | int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag, |
| 1637 | u8 ssid_len, u8 *ssid) |
| 1638 | { |
| 1639 | struct sk_buff *skb; |
| 1640 | struct wmi_probed_ssid_cmd *cmd; |
| 1641 | int ret; |
| 1642 | |
| 1643 | if (index > MAX_PROBED_SSID_INDEX) |
| 1644 | return -EINVAL; |
| 1645 | |
| 1646 | if (ssid_len > sizeof(cmd->ssid)) |
| 1647 | return -EINVAL; |
| 1648 | |
| 1649 | if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0)) |
| 1650 | return -EINVAL; |
| 1651 | |
| 1652 | if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len) |
| 1653 | return -EINVAL; |
| 1654 | |
| 1655 | if (flag & SPECIFIC_SSID_FLAG) |
| 1656 | wmi->is_probe_ssid = true; |
| 1657 | |
| 1658 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1659 | if (!skb) |
| 1660 | return -ENOMEM; |
| 1661 | |
| 1662 | cmd = (struct wmi_probed_ssid_cmd *) skb->data; |
| 1663 | cmd->entry_index = index; |
| 1664 | cmd->flag = flag; |
| 1665 | cmd->ssid_len = ssid_len; |
| 1666 | memcpy(cmd->ssid, ssid, ssid_len); |
| 1667 | |
| 1668 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID, |
| 1669 | NO_SYNC_WMIFLAG); |
| 1670 | return ret; |
| 1671 | } |
| 1672 | |
| 1673 | int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval, |
| 1674 | u16 listen_beacons) |
| 1675 | { |
| 1676 | struct sk_buff *skb; |
| 1677 | struct wmi_listen_int_cmd *cmd; |
| 1678 | int ret; |
| 1679 | |
| 1680 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1681 | if (!skb) |
| 1682 | return -ENOMEM; |
| 1683 | |
| 1684 | cmd = (struct wmi_listen_int_cmd *) skb->data; |
| 1685 | cmd->listen_intvl = cpu_to_le16(listen_interval); |
| 1686 | cmd->num_beacons = cpu_to_le16(listen_beacons); |
| 1687 | |
| 1688 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID, |
| 1689 | NO_SYNC_WMIFLAG); |
| 1690 | return ret; |
| 1691 | } |
| 1692 | |
| 1693 | int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode) |
| 1694 | { |
| 1695 | struct sk_buff *skb; |
| 1696 | struct wmi_power_mode_cmd *cmd; |
| 1697 | int ret; |
| 1698 | |
| 1699 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1700 | if (!skb) |
| 1701 | return -ENOMEM; |
| 1702 | |
| 1703 | cmd = (struct wmi_power_mode_cmd *) skb->data; |
| 1704 | cmd->pwr_mode = pwr_mode; |
| 1705 | wmi->pwr_mode = pwr_mode; |
| 1706 | |
| 1707 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID, |
| 1708 | NO_SYNC_WMIFLAG); |
| 1709 | return ret; |
| 1710 | } |
| 1711 | |
| 1712 | int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period, |
| 1713 | u16 ps_poll_num, u16 dtim_policy, |
| 1714 | u16 tx_wakeup_policy, u16 num_tx_to_wakeup, |
| 1715 | u16 ps_fail_event_policy) |
| 1716 | { |
| 1717 | struct sk_buff *skb; |
| 1718 | struct wmi_power_params_cmd *pm; |
| 1719 | int ret; |
| 1720 | |
| 1721 | skb = ath6kl_wmi_get_new_buf(sizeof(*pm)); |
| 1722 | if (!skb) |
| 1723 | return -ENOMEM; |
| 1724 | |
| 1725 | pm = (struct wmi_power_params_cmd *)skb->data; |
| 1726 | pm->idle_period = cpu_to_le16(idle_period); |
| 1727 | pm->pspoll_number = cpu_to_le16(ps_poll_num); |
| 1728 | pm->dtim_policy = cpu_to_le16(dtim_policy); |
| 1729 | pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy); |
| 1730 | pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup); |
| 1731 | pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy); |
| 1732 | |
| 1733 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID, |
| 1734 | NO_SYNC_WMIFLAG); |
| 1735 | return ret; |
| 1736 | } |
| 1737 | |
| 1738 | int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout) |
| 1739 | { |
| 1740 | struct sk_buff *skb; |
| 1741 | struct wmi_disc_timeout_cmd *cmd; |
| 1742 | int ret; |
| 1743 | |
| 1744 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1745 | if (!skb) |
| 1746 | return -ENOMEM; |
| 1747 | |
| 1748 | cmd = (struct wmi_disc_timeout_cmd *) skb->data; |
| 1749 | cmd->discon_timeout = timeout; |
| 1750 | |
| 1751 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID, |
| 1752 | NO_SYNC_WMIFLAG); |
| 1753 | return ret; |
| 1754 | } |
| 1755 | |
| 1756 | int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index, |
| 1757 | enum crypto_type key_type, |
| 1758 | u8 key_usage, u8 key_len, |
| 1759 | u8 *key_rsc, u8 *key_material, |
| 1760 | u8 key_op_ctrl, u8 *mac_addr, |
| 1761 | enum wmi_sync_flag sync_flag) |
| 1762 | { |
| 1763 | struct sk_buff *skb; |
| 1764 | struct wmi_add_cipher_key_cmd *cmd; |
| 1765 | int ret; |
| 1766 | |
Jouni Malinen | 9a5b131 | 2011-08-30 21:57:52 +0300 | [diff] [blame^] | 1767 | ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d " |
| 1768 | "key_usage=%d key_len=%d key_op_ctrl=%d\n", |
| 1769 | key_index, key_type, key_usage, key_len, key_op_ctrl); |
| 1770 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1771 | if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) || |
| 1772 | (key_material == NULL)) |
| 1773 | return -EINVAL; |
| 1774 | |
| 1775 | if ((WEP_CRYPT != key_type) && (NULL == key_rsc)) |
| 1776 | return -EINVAL; |
| 1777 | |
| 1778 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1779 | if (!skb) |
| 1780 | return -ENOMEM; |
| 1781 | |
| 1782 | cmd = (struct wmi_add_cipher_key_cmd *) skb->data; |
| 1783 | cmd->key_index = key_index; |
| 1784 | cmd->key_type = key_type; |
| 1785 | cmd->key_usage = key_usage; |
| 1786 | cmd->key_len = key_len; |
| 1787 | memcpy(cmd->key, key_material, key_len); |
| 1788 | |
| 1789 | if (key_rsc != NULL) |
| 1790 | memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc)); |
| 1791 | |
| 1792 | cmd->key_op_ctrl = key_op_ctrl; |
| 1793 | |
| 1794 | if (mac_addr) |
| 1795 | memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN); |
| 1796 | |
| 1797 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID, |
| 1798 | sync_flag); |
| 1799 | |
| 1800 | return ret; |
| 1801 | } |
| 1802 | |
| 1803 | int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk) |
| 1804 | { |
| 1805 | struct sk_buff *skb; |
| 1806 | struct wmi_add_krk_cmd *cmd; |
| 1807 | int ret; |
| 1808 | |
| 1809 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1810 | if (!skb) |
| 1811 | return -ENOMEM; |
| 1812 | |
| 1813 | cmd = (struct wmi_add_krk_cmd *) skb->data; |
| 1814 | memcpy(cmd->krk, krk, WMI_KRK_LEN); |
| 1815 | |
| 1816 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG); |
| 1817 | |
| 1818 | return ret; |
| 1819 | } |
| 1820 | |
| 1821 | int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index) |
| 1822 | { |
| 1823 | struct sk_buff *skb; |
| 1824 | struct wmi_delete_cipher_key_cmd *cmd; |
| 1825 | int ret; |
| 1826 | |
| 1827 | if (key_index > WMI_MAX_KEY_INDEX) |
| 1828 | return -EINVAL; |
| 1829 | |
| 1830 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1831 | if (!skb) |
| 1832 | return -ENOMEM; |
| 1833 | |
| 1834 | cmd = (struct wmi_delete_cipher_key_cmd *) skb->data; |
| 1835 | cmd->key_index = key_index; |
| 1836 | |
| 1837 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID, |
| 1838 | NO_SYNC_WMIFLAG); |
| 1839 | |
| 1840 | return ret; |
| 1841 | } |
| 1842 | |
| 1843 | int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid, |
| 1844 | const u8 *pmkid, bool set) |
| 1845 | { |
| 1846 | struct sk_buff *skb; |
| 1847 | struct wmi_setpmkid_cmd *cmd; |
| 1848 | int ret; |
| 1849 | |
| 1850 | if (bssid == NULL) |
| 1851 | return -EINVAL; |
| 1852 | |
| 1853 | if (set && pmkid == NULL) |
| 1854 | return -EINVAL; |
| 1855 | |
| 1856 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1857 | if (!skb) |
| 1858 | return -ENOMEM; |
| 1859 | |
| 1860 | cmd = (struct wmi_setpmkid_cmd *) skb->data; |
| 1861 | memcpy(cmd->bssid, bssid, ETH_ALEN); |
| 1862 | if (set) { |
| 1863 | memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid)); |
| 1864 | cmd->enable = PMKID_ENABLE; |
| 1865 | } else { |
| 1866 | memset(cmd->pmkid, 0, sizeof(cmd->pmkid)); |
| 1867 | cmd->enable = PMKID_DISABLE; |
| 1868 | } |
| 1869 | |
| 1870 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID, |
| 1871 | NO_SYNC_WMIFLAG); |
| 1872 | |
| 1873 | return ret; |
| 1874 | } |
| 1875 | |
| 1876 | static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb, |
| 1877 | enum htc_endpoint_id ep_id) |
| 1878 | { |
| 1879 | struct wmi_data_hdr *data_hdr; |
| 1880 | int ret; |
| 1881 | |
| 1882 | if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) |
| 1883 | return -EINVAL; |
| 1884 | |
| 1885 | skb_push(skb, sizeof(struct wmi_data_hdr)); |
| 1886 | |
| 1887 | data_hdr = (struct wmi_data_hdr *) skb->data; |
| 1888 | data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT; |
| 1889 | data_hdr->info3 = 0; |
| 1890 | |
| 1891 | ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id); |
| 1892 | |
| 1893 | return ret; |
| 1894 | } |
| 1895 | |
| 1896 | static int ath6kl_wmi_sync_point(struct wmi *wmi) |
| 1897 | { |
| 1898 | struct sk_buff *skb; |
| 1899 | struct wmi_sync_cmd *cmd; |
| 1900 | struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC]; |
| 1901 | enum htc_endpoint_id ep_id; |
| 1902 | u8 index, num_pri_streams = 0; |
| 1903 | int ret = 0; |
| 1904 | |
| 1905 | memset(data_sync_bufs, 0, sizeof(data_sync_bufs)); |
| 1906 | |
| 1907 | spin_lock_bh(&wmi->lock); |
| 1908 | |
| 1909 | for (index = 0; index < WMM_NUM_AC; index++) { |
| 1910 | if (wmi->fat_pipe_exist & (1 << index)) { |
| 1911 | num_pri_streams++; |
| 1912 | data_sync_bufs[num_pri_streams - 1].traffic_class = |
| 1913 | index; |
| 1914 | } |
| 1915 | } |
| 1916 | |
| 1917 | spin_unlock_bh(&wmi->lock); |
| 1918 | |
| 1919 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 1920 | if (!skb) { |
| 1921 | ret = -ENOMEM; |
| 1922 | goto free_skb; |
| 1923 | } |
| 1924 | |
| 1925 | cmd = (struct wmi_sync_cmd *) skb->data; |
| 1926 | |
| 1927 | /* |
| 1928 | * In the SYNC cmd sent on the control Ep, send a bitmap |
| 1929 | * of the data eps on which the Data Sync will be sent |
| 1930 | */ |
| 1931 | cmd->data_sync_map = wmi->fat_pipe_exist; |
| 1932 | |
| 1933 | for (index = 0; index < num_pri_streams; index++) { |
| 1934 | data_sync_bufs[index].skb = ath6kl_buf_alloc(0); |
| 1935 | if (data_sync_bufs[index].skb == NULL) { |
| 1936 | ret = -ENOMEM; |
| 1937 | break; |
| 1938 | } |
| 1939 | } |
| 1940 | |
| 1941 | /* |
| 1942 | * If buffer allocation for any of the dataSync fails, |
| 1943 | * then do not send the Synchronize cmd on the control ep |
| 1944 | */ |
| 1945 | if (ret) |
| 1946 | goto free_skb; |
| 1947 | |
| 1948 | /* |
| 1949 | * Send sync cmd followed by sync data messages on all |
| 1950 | * endpoints being used |
| 1951 | */ |
| 1952 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID, |
| 1953 | NO_SYNC_WMIFLAG); |
| 1954 | |
| 1955 | if (ret) |
| 1956 | goto free_skb; |
| 1957 | |
| 1958 | /* cmd buffer sent, we no longer own it */ |
| 1959 | skb = NULL; |
| 1960 | |
| 1961 | for (index = 0; index < num_pri_streams; index++) { |
| 1962 | |
| 1963 | if (WARN_ON(!data_sync_bufs[index].skb)) |
| 1964 | break; |
| 1965 | |
| 1966 | ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, |
| 1967 | data_sync_bufs[index]. |
| 1968 | traffic_class); |
| 1969 | ret = |
| 1970 | ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb, |
| 1971 | ep_id); |
| 1972 | |
| 1973 | if (ret) |
| 1974 | break; |
| 1975 | |
| 1976 | data_sync_bufs[index].skb = NULL; |
| 1977 | } |
| 1978 | |
| 1979 | free_skb: |
| 1980 | /* free up any resources left over (possibly due to an error) */ |
| 1981 | if (skb) |
| 1982 | dev_kfree_skb(skb); |
| 1983 | |
| 1984 | for (index = 0; index < num_pri_streams; index++) { |
| 1985 | if (data_sync_bufs[index].skb != NULL) { |
| 1986 | dev_kfree_skb((struct sk_buff *)data_sync_bufs[index]. |
| 1987 | skb); |
| 1988 | } |
| 1989 | } |
| 1990 | |
| 1991 | return ret; |
| 1992 | } |
| 1993 | |
| 1994 | int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, |
| 1995 | struct wmi_create_pstream_cmd *params) |
| 1996 | { |
| 1997 | struct sk_buff *skb; |
| 1998 | struct wmi_create_pstream_cmd *cmd; |
| 1999 | u8 fatpipe_exist_for_ac = 0; |
| 2000 | s32 min_phy = 0; |
| 2001 | s32 nominal_phy = 0; |
| 2002 | int ret; |
| 2003 | |
| 2004 | if (!((params->user_pri < 8) && |
| 2005 | (params->user_pri <= 0x7) && |
| 2006 | (up_to_ac[params->user_pri & 0x7] == params->traffic_class) && |
| 2007 | (params->traffic_direc == UPLINK_TRAFFIC || |
| 2008 | params->traffic_direc == DNLINK_TRAFFIC || |
| 2009 | params->traffic_direc == BIDIR_TRAFFIC) && |
| 2010 | (params->traffic_type == TRAFFIC_TYPE_APERIODIC || |
| 2011 | params->traffic_type == TRAFFIC_TYPE_PERIODIC) && |
| 2012 | (params->voice_psc_cap == DISABLE_FOR_THIS_AC || |
| 2013 | params->voice_psc_cap == ENABLE_FOR_THIS_AC || |
| 2014 | params->voice_psc_cap == ENABLE_FOR_ALL_AC) && |
| 2015 | (params->tsid == WMI_IMPLICIT_PSTREAM || |
| 2016 | params->tsid <= WMI_MAX_THINSTREAM))) { |
| 2017 | return -EINVAL; |
| 2018 | } |
| 2019 | |
| 2020 | /* |
| 2021 | * Check nominal PHY rate is >= minimalPHY, |
| 2022 | * so that DUT can allow TSRS IE |
| 2023 | */ |
| 2024 | |
| 2025 | /* Get the physical rate (units of bps) */ |
| 2026 | min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000); |
| 2027 | |
| 2028 | /* Check minimal phy < nominal phy rate */ |
| 2029 | if (params->nominal_phy >= min_phy) { |
| 2030 | /* unit of 500 kbps */ |
| 2031 | nominal_phy = (params->nominal_phy * 1000) / 500; |
| 2032 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2033 | "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n", |
| 2034 | min_phy, nominal_phy); |
| 2035 | |
| 2036 | params->nominal_phy = nominal_phy; |
| 2037 | } else { |
| 2038 | params->nominal_phy = 0; |
| 2039 | } |
| 2040 | |
| 2041 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2042 | if (!skb) |
| 2043 | return -ENOMEM; |
| 2044 | |
| 2045 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2046 | "sending create_pstream_cmd: ac=%d tsid:%d\n", |
| 2047 | params->traffic_class, params->tsid); |
| 2048 | |
| 2049 | cmd = (struct wmi_create_pstream_cmd *) skb->data; |
| 2050 | memcpy(cmd, params, sizeof(*cmd)); |
| 2051 | |
| 2052 | /* This is an implicitly created Fat pipe */ |
| 2053 | if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) { |
| 2054 | spin_lock_bh(&wmi->lock); |
| 2055 | fatpipe_exist_for_ac = (wmi->fat_pipe_exist & |
| 2056 | (1 << params->traffic_class)); |
| 2057 | wmi->fat_pipe_exist |= (1 << params->traffic_class); |
| 2058 | spin_unlock_bh(&wmi->lock); |
| 2059 | } else { |
| 2060 | /* explicitly created thin stream within a fat pipe */ |
| 2061 | spin_lock_bh(&wmi->lock); |
| 2062 | fatpipe_exist_for_ac = (wmi->fat_pipe_exist & |
| 2063 | (1 << params->traffic_class)); |
| 2064 | wmi->stream_exist_for_ac[params->traffic_class] |= |
| 2065 | (1 << params->tsid); |
| 2066 | /* |
| 2067 | * If a thinstream becomes active, the fat pipe automatically |
| 2068 | * becomes active |
| 2069 | */ |
| 2070 | wmi->fat_pipe_exist |= (1 << params->traffic_class); |
| 2071 | spin_unlock_bh(&wmi->lock); |
| 2072 | } |
| 2073 | |
| 2074 | /* |
| 2075 | * Indicate activty change to driver layer only if this is the |
| 2076 | * first TSID to get created in this AC explicitly or an implicit |
| 2077 | * fat pipe is getting created. |
| 2078 | */ |
| 2079 | if (!fatpipe_exist_for_ac) |
| 2080 | ath6kl_indicate_tx_activity(wmi->parent_dev, |
| 2081 | params->traffic_class, true); |
| 2082 | |
| 2083 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID, |
| 2084 | NO_SYNC_WMIFLAG); |
| 2085 | return ret; |
| 2086 | } |
| 2087 | |
| 2088 | int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid) |
| 2089 | { |
| 2090 | struct sk_buff *skb; |
| 2091 | struct wmi_delete_pstream_cmd *cmd; |
| 2092 | u16 active_tsids = 0; |
| 2093 | int ret; |
| 2094 | |
| 2095 | if (traffic_class > 3) { |
| 2096 | ath6kl_err("invalid traffic class: %d\n", traffic_class); |
| 2097 | return -EINVAL; |
| 2098 | } |
| 2099 | |
| 2100 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2101 | if (!skb) |
| 2102 | return -ENOMEM; |
| 2103 | |
| 2104 | cmd = (struct wmi_delete_pstream_cmd *) skb->data; |
| 2105 | cmd->traffic_class = traffic_class; |
| 2106 | cmd->tsid = tsid; |
| 2107 | |
| 2108 | spin_lock_bh(&wmi->lock); |
| 2109 | active_tsids = wmi->stream_exist_for_ac[traffic_class]; |
| 2110 | spin_unlock_bh(&wmi->lock); |
| 2111 | |
| 2112 | if (!(active_tsids & (1 << tsid))) { |
| 2113 | dev_kfree_skb(skb); |
| 2114 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2115 | "TSID %d doesn't exist for traffic class: %d\n", |
| 2116 | tsid, traffic_class); |
| 2117 | return -ENODATA; |
| 2118 | } |
| 2119 | |
| 2120 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2121 | "sending delete_pstream_cmd: traffic class: %d tsid=%d\n", |
| 2122 | traffic_class, tsid); |
| 2123 | |
| 2124 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID, |
| 2125 | SYNC_BEFORE_WMIFLAG); |
| 2126 | |
| 2127 | spin_lock_bh(&wmi->lock); |
| 2128 | wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid); |
| 2129 | active_tsids = wmi->stream_exist_for_ac[traffic_class]; |
| 2130 | spin_unlock_bh(&wmi->lock); |
| 2131 | |
| 2132 | /* |
| 2133 | * Indicate stream inactivity to driver layer only if all tsids |
| 2134 | * within this AC are deleted. |
| 2135 | */ |
| 2136 | if (!active_tsids) { |
| 2137 | ath6kl_indicate_tx_activity(wmi->parent_dev, |
| 2138 | traffic_class, false); |
| 2139 | wmi->fat_pipe_exist &= ~(1 << traffic_class); |
| 2140 | } |
| 2141 | |
| 2142 | return ret; |
| 2143 | } |
| 2144 | |
| 2145 | int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd) |
| 2146 | { |
| 2147 | struct sk_buff *skb; |
| 2148 | struct wmi_set_ip_cmd *cmd; |
| 2149 | int ret; |
| 2150 | |
| 2151 | /* Multicast address are not valid */ |
| 2152 | if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) || |
| 2153 | (*((u8 *) &ip_cmd->ips[1]) >= 0xE0)) |
| 2154 | return -EINVAL; |
| 2155 | |
| 2156 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd)); |
| 2157 | if (!skb) |
| 2158 | return -ENOMEM; |
| 2159 | |
| 2160 | cmd = (struct wmi_set_ip_cmd *) skb->data; |
| 2161 | memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd)); |
| 2162 | |
| 2163 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG); |
| 2164 | return ret; |
| 2165 | } |
| 2166 | |
| 2167 | static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap, |
| 2168 | int len) |
| 2169 | { |
| 2170 | if (len < sizeof(struct wmi_get_wow_list_reply)) |
| 2171 | return -EINVAL; |
| 2172 | |
| 2173 | return 0; |
| 2174 | } |
| 2175 | |
| 2176 | static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb, |
| 2177 | enum wmix_command_id cmd_id, |
| 2178 | enum wmi_sync_flag sync_flag) |
| 2179 | { |
| 2180 | struct wmix_cmd_hdr *cmd_hdr; |
| 2181 | int ret; |
| 2182 | |
| 2183 | skb_push(skb, sizeof(struct wmix_cmd_hdr)); |
| 2184 | |
| 2185 | cmd_hdr = (struct wmix_cmd_hdr *) skb->data; |
| 2186 | cmd_hdr->cmd_id = cpu_to_le32(cmd_id); |
| 2187 | |
| 2188 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag); |
| 2189 | |
| 2190 | return ret; |
| 2191 | } |
| 2192 | |
| 2193 | int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source) |
| 2194 | { |
| 2195 | struct sk_buff *skb; |
| 2196 | struct wmix_hb_challenge_resp_cmd *cmd; |
| 2197 | int ret; |
| 2198 | |
| 2199 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2200 | if (!skb) |
| 2201 | return -ENOMEM; |
| 2202 | |
| 2203 | cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data; |
| 2204 | cmd->cookie = cpu_to_le32(cookie); |
| 2205 | cmd->source = cpu_to_le32(source); |
| 2206 | |
| 2207 | ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID, |
| 2208 | NO_SYNC_WMIFLAG); |
| 2209 | return ret; |
| 2210 | } |
| 2211 | |
| 2212 | int ath6kl_wmi_get_stats_cmd(struct wmi *wmi) |
| 2213 | { |
| 2214 | return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID); |
| 2215 | } |
| 2216 | |
| 2217 | int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM) |
| 2218 | { |
| 2219 | struct sk_buff *skb; |
| 2220 | struct wmi_set_tx_pwr_cmd *cmd; |
| 2221 | int ret; |
| 2222 | |
| 2223 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd)); |
| 2224 | if (!skb) |
| 2225 | return -ENOMEM; |
| 2226 | |
| 2227 | cmd = (struct wmi_set_tx_pwr_cmd *) skb->data; |
| 2228 | cmd->dbM = dbM; |
| 2229 | |
| 2230 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID, |
| 2231 | NO_SYNC_WMIFLAG); |
| 2232 | |
| 2233 | return ret; |
| 2234 | } |
| 2235 | |
| 2236 | int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi) |
| 2237 | { |
| 2238 | return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID); |
| 2239 | } |
| 2240 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2241 | int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy) |
| 2242 | { |
| 2243 | struct sk_buff *skb; |
| 2244 | struct wmi_set_lpreamble_cmd *cmd; |
| 2245 | int ret; |
| 2246 | |
| 2247 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd)); |
| 2248 | if (!skb) |
| 2249 | return -ENOMEM; |
| 2250 | |
| 2251 | cmd = (struct wmi_set_lpreamble_cmd *) skb->data; |
| 2252 | cmd->status = status; |
| 2253 | cmd->preamble_policy = preamble_policy; |
| 2254 | |
| 2255 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID, |
| 2256 | NO_SYNC_WMIFLAG); |
| 2257 | return ret; |
| 2258 | } |
| 2259 | |
| 2260 | int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold) |
| 2261 | { |
| 2262 | struct sk_buff *skb; |
| 2263 | struct wmi_set_rts_cmd *cmd; |
| 2264 | int ret; |
| 2265 | |
| 2266 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd)); |
| 2267 | if (!skb) |
| 2268 | return -ENOMEM; |
| 2269 | |
| 2270 | cmd = (struct wmi_set_rts_cmd *) skb->data; |
| 2271 | cmd->threshold = cpu_to_le16(threshold); |
| 2272 | |
| 2273 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG); |
| 2274 | return ret; |
| 2275 | } |
| 2276 | |
| 2277 | int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg) |
| 2278 | { |
| 2279 | struct sk_buff *skb; |
| 2280 | struct wmi_set_wmm_txop_cmd *cmd; |
| 2281 | int ret; |
| 2282 | |
| 2283 | if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED))) |
| 2284 | return -EINVAL; |
| 2285 | |
| 2286 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd)); |
| 2287 | if (!skb) |
| 2288 | return -ENOMEM; |
| 2289 | |
| 2290 | cmd = (struct wmi_set_wmm_txop_cmd *) skb->data; |
| 2291 | cmd->txop_enable = cfg; |
| 2292 | |
| 2293 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID, |
| 2294 | NO_SYNC_WMIFLAG); |
| 2295 | return ret; |
| 2296 | } |
| 2297 | |
| 2298 | int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl) |
| 2299 | { |
| 2300 | struct sk_buff *skb; |
| 2301 | struct wmi_set_keepalive_cmd *cmd; |
| 2302 | int ret; |
| 2303 | |
| 2304 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2305 | if (!skb) |
| 2306 | return -ENOMEM; |
| 2307 | |
| 2308 | cmd = (struct wmi_set_keepalive_cmd *) skb->data; |
| 2309 | cmd->keep_alive_intvl = keep_alive_intvl; |
| 2310 | wmi->keep_alive_intvl = keep_alive_intvl; |
| 2311 | |
| 2312 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID, |
| 2313 | NO_SYNC_WMIFLAG); |
| 2314 | return ret; |
| 2315 | } |
| 2316 | |
| 2317 | s32 ath6kl_wmi_get_rate(s8 rate_index) |
| 2318 | { |
| 2319 | if (rate_index == RATE_AUTO) |
| 2320 | return 0; |
| 2321 | |
| 2322 | return wmi_rate_tbl[(u32) rate_index][0]; |
| 2323 | } |
| 2324 | |
| 2325 | void ath6kl_wmi_node_return(struct wmi *wmi, struct bss *bss) |
| 2326 | { |
| 2327 | if (bss) |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2328 | wlan_node_return(&wmi->parent_dev->scan_table, bss); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2329 | } |
| 2330 | |
| 2331 | struct bss *ath6kl_wmi_find_ssid_node(struct wmi *wmi, u8 * ssid, |
| 2332 | u32 ssid_len, bool is_wpa2, |
| 2333 | bool match_ssid) |
| 2334 | { |
| 2335 | struct bss *node = NULL; |
| 2336 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2337 | node = wlan_find_ssid_node(&wmi->parent_dev->scan_table, ssid, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2338 | ssid_len, is_wpa2, match_ssid); |
| 2339 | return node; |
| 2340 | } |
| 2341 | |
| 2342 | struct bss *ath6kl_wmi_find_node(struct wmi *wmi, const u8 * mac_addr) |
| 2343 | { |
| 2344 | struct bss *ni = NULL; |
| 2345 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2346 | ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2347 | |
| 2348 | return ni; |
| 2349 | } |
| 2350 | |
| 2351 | void ath6kl_wmi_node_free(struct wmi *wmi, const u8 * mac_addr) |
| 2352 | { |
| 2353 | struct bss *ni = NULL; |
| 2354 | |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2355 | ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2356 | if (ni != NULL) |
Vasanthakumar Thiagarajan | 7c3075e | 2011-07-21 13:38:33 +0530 | [diff] [blame] | 2357 | wlan_node_reclaim(&wmi->parent_dev->scan_table, ni); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2358 | |
| 2359 | return; |
| 2360 | } |
| 2361 | |
| 2362 | static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap, |
| 2363 | u32 len) |
| 2364 | { |
| 2365 | struct wmi_pmkid_list_reply *reply; |
| 2366 | u32 expected_len; |
| 2367 | |
| 2368 | if (len < sizeof(struct wmi_pmkid_list_reply)) |
| 2369 | return -EINVAL; |
| 2370 | |
| 2371 | reply = (struct wmi_pmkid_list_reply *)datap; |
| 2372 | expected_len = sizeof(reply->num_pmkid) + |
| 2373 | le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN; |
| 2374 | |
| 2375 | if (len < expected_len) |
| 2376 | return -EINVAL; |
| 2377 | |
| 2378 | return 0; |
| 2379 | } |
| 2380 | |
| 2381 | static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 2382 | { |
| 2383 | struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap; |
| 2384 | |
| 2385 | aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid, |
| 2386 | le16_to_cpu(cmd->st_seq_no), cmd->win_sz); |
| 2387 | |
| 2388 | return 0; |
| 2389 | } |
| 2390 | |
| 2391 | static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 2392 | { |
| 2393 | struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap; |
| 2394 | |
| 2395 | aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid); |
| 2396 | |
| 2397 | return 0; |
| 2398 | } |
| 2399 | |
| 2400 | /* AP mode functions */ |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 2401 | |
| 2402 | int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p) |
| 2403 | { |
| 2404 | struct sk_buff *skb; |
| 2405 | struct wmi_connect_cmd *cm; |
| 2406 | int res; |
| 2407 | |
| 2408 | skb = ath6kl_wmi_get_new_buf(sizeof(*cm)); |
| 2409 | if (!skb) |
| 2410 | return -ENOMEM; |
| 2411 | |
| 2412 | cm = (struct wmi_connect_cmd *) skb->data; |
| 2413 | memcpy(cm, p, sizeof(*cm)); |
| 2414 | |
| 2415 | res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID, |
| 2416 | NO_SYNC_WMIFLAG); |
| 2417 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u " |
| 2418 | "ctrl_flags=0x%x-> res=%d\n", |
| 2419 | __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch), |
| 2420 | le32_to_cpu(p->ctrl_flags), res); |
| 2421 | return res; |
| 2422 | } |
| 2423 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2424 | static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 2425 | { |
| 2426 | struct wmi_pspoll_event *ev; |
| 2427 | |
| 2428 | if (len < sizeof(struct wmi_pspoll_event)) |
| 2429 | return -EINVAL; |
| 2430 | |
| 2431 | ev = (struct wmi_pspoll_event *) datap; |
| 2432 | |
| 2433 | ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid)); |
| 2434 | |
| 2435 | return 0; |
| 2436 | } |
| 2437 | |
| 2438 | static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len) |
| 2439 | { |
| 2440 | ath6kl_dtimexpiry_event(wmi->parent_dev); |
| 2441 | |
| 2442 | return 0; |
| 2443 | } |
| 2444 | |
| 2445 | int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag) |
| 2446 | { |
| 2447 | struct sk_buff *skb; |
| 2448 | struct wmi_ap_set_pvb_cmd *cmd; |
| 2449 | int ret; |
| 2450 | |
| 2451 | skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd)); |
| 2452 | if (!skb) |
| 2453 | return -ENOMEM; |
| 2454 | |
| 2455 | cmd = (struct wmi_ap_set_pvb_cmd *) skb->data; |
| 2456 | cmd->aid = cpu_to_le16(aid); |
| 2457 | cmd->flag = cpu_to_le32(flag); |
| 2458 | |
| 2459 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID, |
| 2460 | NO_SYNC_WMIFLAG); |
| 2461 | |
| 2462 | return 0; |
| 2463 | } |
| 2464 | |
| 2465 | int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver, |
| 2466 | bool rx_dot11_hdr, bool defrag_on_host) |
| 2467 | { |
| 2468 | struct sk_buff *skb; |
| 2469 | struct wmi_rx_frame_format_cmd *cmd; |
| 2470 | int ret; |
| 2471 | |
| 2472 | skb = ath6kl_wmi_get_new_buf(sizeof(*cmd)); |
| 2473 | if (!skb) |
| 2474 | return -ENOMEM; |
| 2475 | |
| 2476 | cmd = (struct wmi_rx_frame_format_cmd *) skb->data; |
| 2477 | cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0; |
| 2478 | cmd->defrag_on_host = defrag_on_host ? 1 : 0; |
| 2479 | cmd->meta_ver = rx_meta_ver; |
| 2480 | |
| 2481 | /* Delete the local aggr state, on host */ |
| 2482 | ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID, |
| 2483 | NO_SYNC_WMIFLAG); |
| 2484 | |
| 2485 | return ret; |
| 2486 | } |
| 2487 | |
Jouni Malinen | 6a7c9ba | 2011-08-30 21:57:50 +0300 | [diff] [blame] | 2488 | int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie, |
| 2489 | u8 ie_len) |
| 2490 | { |
| 2491 | struct sk_buff *skb; |
| 2492 | struct wmi_set_appie_cmd *p; |
| 2493 | |
| 2494 | skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len); |
| 2495 | if (!skb) |
| 2496 | return -ENOMEM; |
| 2497 | |
| 2498 | ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u " |
| 2499 | "ie_len=%u\n", mgmt_frm_type, ie_len); |
| 2500 | p = (struct wmi_set_appie_cmd *) skb->data; |
| 2501 | p->mgmt_frm_type = mgmt_frm_type; |
| 2502 | p->ie_len = ie_len; |
| 2503 | memcpy(p->ie_info, ie, ie_len); |
| 2504 | return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID, |
| 2505 | NO_SYNC_WMIFLAG); |
| 2506 | } |
| 2507 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2508 | static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb) |
| 2509 | { |
| 2510 | struct wmix_cmd_hdr *cmd; |
| 2511 | u32 len; |
| 2512 | u16 id; |
| 2513 | u8 *datap; |
| 2514 | int ret = 0; |
| 2515 | |
| 2516 | if (skb->len < sizeof(struct wmix_cmd_hdr)) { |
| 2517 | ath6kl_err("bad packet 1\n"); |
| 2518 | wmi->stat.cmd_len_err++; |
| 2519 | return -EINVAL; |
| 2520 | } |
| 2521 | |
| 2522 | cmd = (struct wmix_cmd_hdr *) skb->data; |
| 2523 | id = le32_to_cpu(cmd->cmd_id); |
| 2524 | |
| 2525 | skb_pull(skb, sizeof(struct wmix_cmd_hdr)); |
| 2526 | |
| 2527 | datap = skb->data; |
| 2528 | len = skb->len; |
| 2529 | |
| 2530 | switch (id) { |
| 2531 | case WMIX_HB_CHALLENGE_RESP_EVENTID: |
| 2532 | break; |
| 2533 | case WMIX_DBGLOG_EVENTID: |
| 2534 | break; |
| 2535 | default: |
| 2536 | ath6kl_err("unknown cmd id 0x%x\n", id); |
| 2537 | wmi->stat.cmd_id_err++; |
| 2538 | ret = -EINVAL; |
| 2539 | break; |
| 2540 | } |
| 2541 | |
| 2542 | return ret; |
| 2543 | } |
| 2544 | |
| 2545 | /* Control Path */ |
| 2546 | int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb) |
| 2547 | { |
| 2548 | struct wmi_cmd_hdr *cmd; |
| 2549 | u32 len; |
| 2550 | u16 id; |
| 2551 | u8 *datap; |
| 2552 | int ret = 0; |
| 2553 | |
| 2554 | if (WARN_ON(skb == NULL)) |
| 2555 | return -EINVAL; |
| 2556 | |
| 2557 | if (skb->len < sizeof(struct wmi_cmd_hdr)) { |
| 2558 | ath6kl_err("bad packet 1\n"); |
| 2559 | dev_kfree_skb(skb); |
| 2560 | wmi->stat.cmd_len_err++; |
| 2561 | return -EINVAL; |
| 2562 | } |
| 2563 | |
| 2564 | cmd = (struct wmi_cmd_hdr *) skb->data; |
| 2565 | id = le16_to_cpu(cmd->cmd_id); |
| 2566 | |
| 2567 | skb_pull(skb, sizeof(struct wmi_cmd_hdr)); |
| 2568 | |
| 2569 | datap = skb->data; |
| 2570 | len = skb->len; |
| 2571 | |
| 2572 | ath6kl_dbg(ATH6KL_DBG_WMI, "%s: wmi id: %d\n", __func__, id); |
| 2573 | ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "msg payload ", datap, len); |
| 2574 | |
| 2575 | switch (id) { |
| 2576 | case WMI_GET_BITRATE_CMDID: |
| 2577 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n"); |
| 2578 | ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len); |
| 2579 | break; |
| 2580 | case WMI_GET_CHANNEL_LIST_CMDID: |
| 2581 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n"); |
| 2582 | ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len); |
| 2583 | break; |
| 2584 | case WMI_GET_TX_PWR_CMDID: |
| 2585 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n"); |
| 2586 | ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len); |
| 2587 | break; |
| 2588 | case WMI_READY_EVENTID: |
| 2589 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n"); |
| 2590 | ret = ath6kl_wmi_ready_event_rx(wmi, datap, len); |
| 2591 | break; |
| 2592 | case WMI_CONNECT_EVENTID: |
| 2593 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n"); |
| 2594 | ret = ath6kl_wmi_connect_event_rx(wmi, datap, len); |
| 2595 | break; |
| 2596 | case WMI_DISCONNECT_EVENTID: |
| 2597 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n"); |
| 2598 | ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len); |
| 2599 | break; |
| 2600 | case WMI_PEER_NODE_EVENTID: |
| 2601 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n"); |
| 2602 | ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len); |
| 2603 | break; |
| 2604 | case WMI_TKIP_MICERR_EVENTID: |
| 2605 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n"); |
| 2606 | ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len); |
| 2607 | break; |
| 2608 | case WMI_BSSINFO_EVENTID: |
| 2609 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n"); |
| 2610 | ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb, datap); |
| 2611 | ret = ath6kl_wmi_bssinfo_event_rx(wmi, skb->data, skb->len); |
| 2612 | break; |
| 2613 | case WMI_REGDOMAIN_EVENTID: |
| 2614 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n"); |
| 2615 | break; |
| 2616 | case WMI_PSTREAM_TIMEOUT_EVENTID: |
| 2617 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n"); |
| 2618 | ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len); |
| 2619 | break; |
| 2620 | case WMI_NEIGHBOR_REPORT_EVENTID: |
| 2621 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n"); |
| 2622 | break; |
| 2623 | case WMI_SCAN_COMPLETE_EVENTID: |
| 2624 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n"); |
| 2625 | ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len); |
| 2626 | break; |
| 2627 | case WMI_CMDERROR_EVENTID: |
| 2628 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n"); |
| 2629 | ret = ath6kl_wmi_error_event_rx(wmi, datap, len); |
| 2630 | break; |
| 2631 | case WMI_REPORT_STATISTICS_EVENTID: |
| 2632 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n"); |
| 2633 | ret = ath6kl_wmi_stats_event_rx(wmi, datap, len); |
| 2634 | break; |
| 2635 | case WMI_RSSI_THRESHOLD_EVENTID: |
| 2636 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n"); |
| 2637 | ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len); |
| 2638 | break; |
| 2639 | case WMI_ERROR_REPORT_EVENTID: |
| 2640 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n"); |
| 2641 | break; |
| 2642 | case WMI_OPT_RX_FRAME_EVENTID: |
| 2643 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n"); |
| 2644 | ret = ath6kl_wmi_opt_frame_event_rx(wmi, datap, len); |
| 2645 | break; |
| 2646 | case WMI_REPORT_ROAM_TBL_EVENTID: |
| 2647 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n"); |
| 2648 | break; |
| 2649 | case WMI_EXTENSION_EVENTID: |
| 2650 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n"); |
| 2651 | ret = ath6kl_wmi_control_rx_xtnd(wmi, skb); |
| 2652 | break; |
| 2653 | case WMI_CAC_EVENTID: |
| 2654 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n"); |
| 2655 | ret = ath6kl_wmi_cac_event_rx(wmi, datap, len); |
| 2656 | break; |
| 2657 | case WMI_CHANNEL_CHANGE_EVENTID: |
| 2658 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n"); |
| 2659 | break; |
| 2660 | case WMI_REPORT_ROAM_DATA_EVENTID: |
| 2661 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n"); |
| 2662 | break; |
| 2663 | case WMI_GET_FIXRATES_CMDID: |
| 2664 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n"); |
| 2665 | ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len); |
| 2666 | break; |
| 2667 | case WMI_TX_RETRY_ERR_EVENTID: |
| 2668 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n"); |
| 2669 | break; |
| 2670 | case WMI_SNR_THRESHOLD_EVENTID: |
| 2671 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n"); |
| 2672 | ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len); |
| 2673 | break; |
| 2674 | case WMI_LQ_THRESHOLD_EVENTID: |
| 2675 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n"); |
| 2676 | break; |
| 2677 | case WMI_APLIST_EVENTID: |
| 2678 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n"); |
| 2679 | ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len); |
| 2680 | break; |
| 2681 | case WMI_GET_KEEPALIVE_CMDID: |
| 2682 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n"); |
| 2683 | ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len); |
| 2684 | break; |
| 2685 | case WMI_GET_WOW_LIST_EVENTID: |
| 2686 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n"); |
| 2687 | ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len); |
| 2688 | break; |
| 2689 | case WMI_GET_PMKID_LIST_EVENTID: |
| 2690 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n"); |
| 2691 | ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len); |
| 2692 | break; |
| 2693 | case WMI_PSPOLL_EVENTID: |
| 2694 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n"); |
| 2695 | ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len); |
| 2696 | break; |
| 2697 | case WMI_DTIMEXPIRY_EVENTID: |
| 2698 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n"); |
| 2699 | ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len); |
| 2700 | break; |
| 2701 | case WMI_SET_PARAMS_REPLY_EVENTID: |
| 2702 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n"); |
| 2703 | break; |
| 2704 | case WMI_ADDBA_REQ_EVENTID: |
| 2705 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n"); |
| 2706 | ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len); |
| 2707 | break; |
| 2708 | case WMI_ADDBA_RESP_EVENTID: |
| 2709 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n"); |
| 2710 | break; |
| 2711 | case WMI_DELBA_REQ_EVENTID: |
| 2712 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n"); |
| 2713 | ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len); |
| 2714 | break; |
| 2715 | case WMI_REPORT_BTCOEX_CONFIG_EVENTID: |
| 2716 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2717 | "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n"); |
| 2718 | break; |
| 2719 | case WMI_REPORT_BTCOEX_STATS_EVENTID: |
| 2720 | ath6kl_dbg(ATH6KL_DBG_WMI, |
| 2721 | "WMI_REPORT_BTCOEX_STATS_EVENTID\n"); |
| 2722 | break; |
| 2723 | case WMI_TX_COMPLETE_EVENTID: |
| 2724 | ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n"); |
| 2725 | ret = ath6kl_wmi_tx_complete_event_rx(datap, len); |
| 2726 | break; |
| 2727 | default: |
| 2728 | ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id); |
| 2729 | wmi->stat.cmd_id_err++; |
| 2730 | ret = -EINVAL; |
| 2731 | break; |
| 2732 | } |
| 2733 | |
| 2734 | dev_kfree_skb(skb); |
| 2735 | |
| 2736 | return ret; |
| 2737 | } |
| 2738 | |
| 2739 | static void ath6kl_wmi_qos_state_init(struct wmi *wmi) |
| 2740 | { |
| 2741 | if (!wmi) |
| 2742 | return; |
| 2743 | |
| 2744 | spin_lock_bh(&wmi->lock); |
| 2745 | |
| 2746 | wmi->fat_pipe_exist = 0; |
| 2747 | memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac)); |
| 2748 | |
| 2749 | spin_unlock_bh(&wmi->lock); |
| 2750 | } |
| 2751 | |
Vasanthakumar Thiagarajan | 2865785 | 2011-07-21 12:00:49 +0530 | [diff] [blame] | 2752 | void *ath6kl_wmi_init(struct ath6kl *dev) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2753 | { |
| 2754 | struct wmi *wmi; |
| 2755 | |
| 2756 | wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL); |
| 2757 | if (!wmi) |
| 2758 | return NULL; |
| 2759 | |
| 2760 | spin_lock_init(&wmi->lock); |
| 2761 | |
| 2762 | wmi->parent_dev = dev; |
| 2763 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2764 | ath6kl_wmi_qos_state_init(wmi); |
| 2765 | |
| 2766 | wmi->pwr_mode = REC_POWER; |
| 2767 | wmi->phy_mode = WMI_11G_MODE; |
| 2768 | |
| 2769 | wmi->pair_crypto_type = NONE_CRYPT; |
| 2770 | wmi->grp_crypto_type = NONE_CRYPT; |
| 2771 | |
| 2772 | wmi->ht_allowed[A_BAND_24GHZ] = 1; |
| 2773 | wmi->ht_allowed[A_BAND_5GHZ] = 1; |
| 2774 | |
| 2775 | return wmi; |
| 2776 | } |
| 2777 | |
| 2778 | void ath6kl_wmi_shutdown(struct wmi *wmi) |
| 2779 | { |
| 2780 | if (!wmi) |
| 2781 | return; |
| 2782 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 2783 | kfree(wmi); |
| 2784 | } |