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