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