2 * Copyright (c) 2004-2011 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 static int ath6kl_wmi_sync_point(struct wmi
*wmi
);
24 static const s32 wmi_rate_tbl
[][2] = {
25 /* {W/O SGI, with SGI} */
57 /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
58 static const u8 up_to_ac
[] = {
69 void ath6kl_wmi_set_control_ep(struct wmi
*wmi
, enum htc_endpoint_id ep_id
)
71 if (WARN_ON(ep_id
== ENDPOINT_UNUSED
|| ep_id
>= ENDPOINT_MAX
))
77 enum htc_endpoint_id
ath6kl_wmi_get_control_ep(struct wmi
*wmi
)
82 /* Performs DIX to 802.3 encapsulation for transmit packets.
83 * Assumes the entire DIX header is contigous and that there is
84 * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers.
86 int ath6kl_wmi_dix_2_dot3(struct wmi
*wmi
, struct sk_buff
*skb
)
88 struct ath6kl_llc_snap_hdr
*llc_hdr
;
89 struct ethhdr
*eth_hdr
;
95 if (WARN_ON(skb
== NULL
))
98 size
= sizeof(struct ath6kl_llc_snap_hdr
) + sizeof(struct wmi_data_hdr
);
99 if (skb_headroom(skb
) < size
)
102 eth_hdr
= (struct ethhdr
*) skb
->data
;
103 type
= eth_hdr
->h_proto
;
105 if (!is_ethertype(be16_to_cpu(type
))) {
106 ath6kl_dbg(ATH6KL_DBG_WMI
,
107 "%s: pkt is already in 802.3 format\n", __func__
);
111 new_len
= skb
->len
- sizeof(*eth_hdr
) + sizeof(*llc_hdr
);
113 skb_push(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
116 eth_hdr
->h_proto
= cpu_to_be16(new_len
);
118 memcpy(datap
, eth_hdr
, sizeof(*eth_hdr
));
120 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
+ sizeof(*eth_hdr
));
121 llc_hdr
->dsap
= 0xAA;
122 llc_hdr
->ssap
= 0xAA;
123 llc_hdr
->cntl
= 0x03;
124 llc_hdr
->org_code
[0] = 0x0;
125 llc_hdr
->org_code
[1] = 0x0;
126 llc_hdr
->org_code
[2] = 0x0;
127 llc_hdr
->eth_type
= type
;
132 static int ath6kl_wmi_meta_add(struct wmi
*wmi
, struct sk_buff
*skb
,
133 u8
*version
, void *tx_meta_info
)
135 struct wmi_tx_meta_v1
*v1
;
136 struct wmi_tx_meta_v2
*v2
;
138 if (WARN_ON(skb
== NULL
|| version
== NULL
))
142 case WMI_META_VERSION_1
:
143 skb_push(skb
, WMI_MAX_TX_META_SZ
);
144 v1
= (struct wmi_tx_meta_v1
*) skb
->data
;
146 v1
->rate_plcy_id
= 0;
147 *version
= WMI_META_VERSION_1
;
149 case WMI_META_VERSION_2
:
150 skb_push(skb
, WMI_MAX_TX_META_SZ
);
151 v2
= (struct wmi_tx_meta_v2
*) skb
->data
;
152 memcpy(v2
, (struct wmi_tx_meta_v2
*) tx_meta_info
,
153 sizeof(struct wmi_tx_meta_v2
));
160 int ath6kl_wmi_data_hdr_add(struct wmi
*wmi
, struct sk_buff
*skb
,
161 u8 msg_type
, bool more_data
,
162 enum wmi_data_hdr_data_type data_type
,
163 u8 meta_ver
, void *tx_meta_info
)
165 struct wmi_data_hdr
*data_hdr
;
168 if (WARN_ON(skb
== NULL
))
172 ret
= ath6kl_wmi_meta_add(wmi
, skb
, &meta_ver
, tx_meta_info
);
177 skb_push(skb
, sizeof(struct wmi_data_hdr
));
179 data_hdr
= (struct wmi_data_hdr
*)skb
->data
;
180 memset(data_hdr
, 0, sizeof(struct wmi_data_hdr
));
182 data_hdr
->info
= msg_type
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
183 data_hdr
->info
|= data_type
<< WMI_DATA_HDR_DATA_TYPE_SHIFT
;
187 WMI_DATA_HDR_MORE_MASK
<< WMI_DATA_HDR_MORE_SHIFT
;
189 data_hdr
->info2
= cpu_to_le16(meta_ver
<< WMI_DATA_HDR_META_SHIFT
);
195 static u8
ath6kl_wmi_determine_user_priority(u8
*pkt
, u32 layer2_pri
)
197 struct iphdr
*ip_hdr
= (struct iphdr
*) pkt
;
201 * Determine IPTOS priority
204 * : DSCP(6-bits) ECN(2-bits)
205 * : DSCP - P2 P1 P0 X X X
206 * where (P2 P1 P0) form 802.1D
208 ip_pri
= ip_hdr
->tos
>> 5;
211 if ((layer2_pri
& 0x7) > ip_pri
)
212 return (u8
) layer2_pri
& 0x7;
217 int ath6kl_wmi_implicit_create_pstream(struct wmi
*wmi
, struct sk_buff
*skb
,
218 u32 layer2_priority
, bool wmm_enabled
,
221 struct wmi_data_hdr
*data_hdr
;
222 struct ath6kl_llc_snap_hdr
*llc_hdr
;
223 struct wmi_create_pstream_cmd cmd
;
224 u32 meta_size
, hdr_size
;
225 u16 ip_type
= IP_ETHERTYPE
;
226 u8 stream_exist
, usr_pri
;
227 u8 traffic_class
= WMM_AC_BE
;
230 if (WARN_ON(skb
== NULL
))
234 data_hdr
= (struct wmi_data_hdr
*) datap
;
236 meta_size
= ((le16_to_cpu(data_hdr
->info2
) >> WMI_DATA_HDR_META_SHIFT
) &
237 WMI_DATA_HDR_META_MASK
) ? WMI_MAX_TX_META_SZ
: 0;
240 /* If WMM is disabled all traffic goes as BE traffic */
243 hdr_size
= sizeof(struct ethhdr
);
245 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
+
248 meta_size
+ hdr_size
);
250 if (llc_hdr
->eth_type
== htons(ip_type
)) {
252 * Extract the endpoint info from the TOS field
256 ath6kl_wmi_determine_user_priority(((u8
*) llc_hdr
) +
257 sizeof(struct ath6kl_llc_snap_hdr
),
260 usr_pri
= layer2_priority
& 0x7;
263 /* workaround for WMM S5 */
264 if ((wmi
->traffic_class
== WMM_AC_VI
) &&
265 ((usr_pri
== 5) || (usr_pri
== 4)))
268 /* Convert user priority to traffic class */
269 traffic_class
= up_to_ac
[usr_pri
& 0x7];
271 wmi_data_hdr_set_up(data_hdr
, usr_pri
);
273 spin_lock_bh(&wmi
->lock
);
274 stream_exist
= wmi
->fat_pipe_exist
;
275 spin_unlock_bh(&wmi
->lock
);
277 if (!(stream_exist
& (1 << traffic_class
))) {
278 memset(&cmd
, 0, sizeof(cmd
));
279 cmd
.traffic_class
= traffic_class
;
280 cmd
.user_pri
= usr_pri
;
282 cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT
);
283 /* Implicit streams are created with TSID 0xFF */
284 cmd
.tsid
= WMI_IMPLICIT_PSTREAM
;
285 ath6kl_wmi_create_pstream_cmd(wmi
, &cmd
);
293 int ath6kl_wmi_dot11_hdr_remove(struct wmi
*wmi
, struct sk_buff
*skb
)
295 struct ieee80211_hdr_3addr
*pwh
, wh
;
296 struct ath6kl_llc_snap_hdr
*llc_hdr
;
297 struct ethhdr eth_hdr
;
302 if (WARN_ON(skb
== NULL
))
306 pwh
= (struct ieee80211_hdr_3addr
*) datap
;
308 sub_type
= pwh
->frame_control
& cpu_to_le16(IEEE80211_FCTL_STYPE
);
310 memcpy((u8
*) &wh
, datap
, sizeof(struct ieee80211_hdr_3addr
));
312 /* Strip off the 802.11 header */
313 if (sub_type
== cpu_to_le16(IEEE80211_STYPE_QOS_DATA
)) {
314 hdr_size
= roundup(sizeof(struct ieee80211_qos_hdr
),
316 skb_pull(skb
, hdr_size
);
317 } else if (sub_type
== cpu_to_le16(IEEE80211_STYPE_DATA
))
318 skb_pull(skb
, sizeof(struct ieee80211_hdr_3addr
));
321 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
);
323 memset(ð_hdr
, 0, sizeof(eth_hdr
));
324 eth_hdr
.h_proto
= llc_hdr
->eth_type
;
326 switch ((le16_to_cpu(wh
.frame_control
)) &
327 (IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
)) {
329 memcpy(eth_hdr
.h_dest
, wh
.addr1
, ETH_ALEN
);
330 memcpy(eth_hdr
.h_source
, wh
.addr2
, ETH_ALEN
);
332 case IEEE80211_FCTL_TODS
:
333 memcpy(eth_hdr
.h_dest
, wh
.addr3
, ETH_ALEN
);
334 memcpy(eth_hdr
.h_source
, wh
.addr2
, ETH_ALEN
);
336 case IEEE80211_FCTL_FROMDS
:
337 memcpy(eth_hdr
.h_dest
, wh
.addr1
, ETH_ALEN
);
338 memcpy(eth_hdr
.h_source
, wh
.addr3
, ETH_ALEN
);
340 case IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
:
344 skb_pull(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
345 skb_push(skb
, sizeof(eth_hdr
));
349 memcpy(datap
, ð_hdr
, sizeof(eth_hdr
));
355 * Performs 802.3 to DIX encapsulation for received packets.
356 * Assumes the entire 802.3 header is contigous.
358 int ath6kl_wmi_dot3_2_dix(struct sk_buff
*skb
)
360 struct ath6kl_llc_snap_hdr
*llc_hdr
;
361 struct ethhdr eth_hdr
;
364 if (WARN_ON(skb
== NULL
))
369 memcpy(ð_hdr
, datap
, sizeof(eth_hdr
));
371 llc_hdr
= (struct ath6kl_llc_snap_hdr
*) (datap
+ sizeof(eth_hdr
));
372 eth_hdr
.h_proto
= llc_hdr
->eth_type
;
374 skb_pull(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
377 memcpy(datap
, ð_hdr
, sizeof(eth_hdr
));
382 static void ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(struct sk_buff
*skb
,
385 struct wmi_bss_info_hdr2 bih2
;
386 struct wmi_bss_info_hdr
*bih
;
388 memcpy(&bih2
, datap
, sizeof(struct wmi_bss_info_hdr2
));
391 bih
= (struct wmi_bss_info_hdr
*) skb
->data
;
394 bih
->frame_type
= bih2
.frame_type
;
396 bih
->rssi
= a_cpu_to_sle16(bih2
.snr
- 95);
397 bih
->ie_mask
= cpu_to_le32(le16_to_cpu(bih2
.ie_mask
));
398 memcpy(bih
->bssid
, bih2
.bssid
, ETH_ALEN
);
401 static int ath6kl_wmi_tx_complete_event_rx(u8
*datap
, int len
)
403 struct tx_complete_msg_v1
*msg_v1
;
404 struct wmi_tx_complete_event
*evt
;
408 evt
= (struct wmi_tx_complete_event
*) datap
;
410 ath6kl_dbg(ATH6KL_DBG_WMI
, "comp: %d %d %d\n",
411 evt
->num_msg
, evt
->msg_len
, evt
->msg_type
);
413 if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI
))
416 for (index
= 0; index
< evt
->num_msg
; index
++) {
417 size
= sizeof(struct wmi_tx_complete_event
) +
418 (index
* sizeof(struct tx_complete_msg_v1
));
419 msg_v1
= (struct tx_complete_msg_v1
*)(datap
+ size
);
421 ath6kl_dbg(ATH6KL_DBG_WMI
, "msg: %d %d %d %d\n",
422 msg_v1
->status
, msg_v1
->pkt_id
,
423 msg_v1
->rate_idx
, msg_v1
->ack_failures
);
429 static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi
*wmi
, u8
*datap
,
432 struct wmi_remain_on_chnl_event
*ev
;
435 struct ieee80211_channel
*chan
;
436 struct ath6kl
*ar
= wmi
->parent_dev
;
438 if (len
< sizeof(*ev
))
441 ev
= (struct wmi_remain_on_chnl_event
*) datap
;
442 freq
= le32_to_cpu(ev
->freq
);
443 dur
= le32_to_cpu(ev
->duration
);
444 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl: freq=%u dur=%u\n",
446 chan
= ieee80211_get_channel(ar
->wdev
->wiphy
, freq
);
448 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl: Unknown channel "
449 "(freq=%u)\n", freq
);
452 cfg80211_ready_on_channel(ar
->net_dev
, 1, chan
, NL80211_CHAN_NO_HT
,
458 static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi
*wmi
,
461 struct wmi_cancel_remain_on_chnl_event
*ev
;
464 struct ieee80211_channel
*chan
;
465 struct ath6kl
*ar
= wmi
->parent_dev
;
467 if (len
< sizeof(*ev
))
470 ev
= (struct wmi_cancel_remain_on_chnl_event
*) datap
;
471 freq
= le32_to_cpu(ev
->freq
);
472 dur
= le32_to_cpu(ev
->duration
);
473 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl: freq=%u dur=%u "
474 "status=%u\n", freq
, dur
, ev
->status
);
475 chan
= ieee80211_get_channel(ar
->wdev
->wiphy
, freq
);
477 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl: Unknown "
478 "channel (freq=%u)\n", freq
);
481 cfg80211_remain_on_channel_expired(ar
->net_dev
, 1, chan
,
482 NL80211_CHAN_NO_HT
, GFP_ATOMIC
);
487 static int ath6kl_wmi_tx_status_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
489 struct wmi_tx_status_event
*ev
;
491 struct ath6kl
*ar
= wmi
->parent_dev
;
493 if (len
< sizeof(*ev
))
496 ev
= (struct wmi_tx_status_event
*) datap
;
497 id
= le32_to_cpu(ev
->id
);
498 ath6kl_dbg(ATH6KL_DBG_WMI
, "tx_status: id=%x ack_status=%u\n",
500 if (wmi
->last_mgmt_tx_frame
) {
501 cfg80211_mgmt_tx_status(ar
->net_dev
, id
,
502 wmi
->last_mgmt_tx_frame
,
503 wmi
->last_mgmt_tx_frame_len
,
504 !!ev
->ack_status
, GFP_ATOMIC
);
505 kfree(wmi
->last_mgmt_tx_frame
);
506 wmi
->last_mgmt_tx_frame
= NULL
;
507 wmi
->last_mgmt_tx_frame_len
= 0;
513 static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
515 struct wmi_p2p_rx_probe_req_event
*ev
;
518 struct ath6kl
*ar
= wmi
->parent_dev
;
520 if (len
< sizeof(*ev
))
523 ev
= (struct wmi_p2p_rx_probe_req_event
*) datap
;
524 freq
= le32_to_cpu(ev
->freq
);
525 dlen
= le16_to_cpu(ev
->len
);
526 if (datap
+ len
< ev
->data
+ dlen
) {
527 ath6kl_err("invalid wmi_p2p_rx_probe_req_event: "
528 "len=%d dlen=%u\n", len
, dlen
);
531 ath6kl_dbg(ATH6KL_DBG_WMI
, "rx_probe_req: len=%u freq=%u "
532 "probe_req_report=%d\n",
533 dlen
, freq
, ar
->probe_req_report
);
535 if (ar
->probe_req_report
|| ar
->nw_type
== AP_NETWORK
)
536 cfg80211_rx_mgmt(ar
->net_dev
, freq
, ev
->data
, dlen
, GFP_ATOMIC
);
541 static int ath6kl_wmi_p2p_capabilities_event_rx(u8
*datap
, int len
)
543 struct wmi_p2p_capabilities_event
*ev
;
546 if (len
< sizeof(*ev
))
549 ev
= (struct wmi_p2p_capabilities_event
*) datap
;
550 dlen
= le16_to_cpu(ev
->len
);
551 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_capab: len=%u\n", dlen
);
556 static int ath6kl_wmi_rx_action_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
558 struct wmi_rx_action_event
*ev
;
561 struct ath6kl
*ar
= wmi
->parent_dev
;
563 if (len
< sizeof(*ev
))
566 ev
= (struct wmi_rx_action_event
*) datap
;
567 freq
= le32_to_cpu(ev
->freq
);
568 dlen
= le16_to_cpu(ev
->len
);
569 if (datap
+ len
< ev
->data
+ dlen
) {
570 ath6kl_err("invalid wmi_rx_action_event: "
571 "len=%d dlen=%u\n", len
, dlen
);
574 ath6kl_dbg(ATH6KL_DBG_WMI
, "rx_action: len=%u freq=%u\n", dlen
, freq
);
575 cfg80211_rx_mgmt(ar
->net_dev
, freq
, ev
->data
, dlen
, GFP_ATOMIC
);
580 static int ath6kl_wmi_p2p_info_event_rx(u8
*datap
, int len
)
582 struct wmi_p2p_info_event
*ev
;
586 if (len
< sizeof(*ev
))
589 ev
= (struct wmi_p2p_info_event
*) datap
;
590 flags
= le32_to_cpu(ev
->info_req_flags
);
591 dlen
= le16_to_cpu(ev
->len
);
592 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: flags=%x len=%d\n", flags
, dlen
);
594 if (flags
& P2P_FLAG_CAPABILITIES_REQ
) {
595 struct wmi_p2p_capabilities
*cap
;
596 if (dlen
< sizeof(*cap
))
598 cap
= (struct wmi_p2p_capabilities
*) ev
->data
;
599 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: GO Power Save = %d\n",
603 if (flags
& P2P_FLAG_MACADDR_REQ
) {
604 struct wmi_p2p_macaddr
*mac
;
605 if (dlen
< sizeof(*mac
))
607 mac
= (struct wmi_p2p_macaddr
*) ev
->data
;
608 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: MAC Address = %pM\n",
612 if (flags
& P2P_FLAG_HMODEL_REQ
) {
613 struct wmi_p2p_hmodel
*mod
;
614 if (dlen
< sizeof(*mod
))
616 mod
= (struct wmi_p2p_hmodel
*) ev
->data
;
617 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: P2P Model = %d (%s)\n",
619 mod
->p2p_model
? "host" : "firmware");
624 static inline struct sk_buff
*ath6kl_wmi_get_new_buf(u32 size
)
628 skb
= ath6kl_buf_alloc(size
);
634 memset(skb
->data
, 0, size
);
639 /* Send a "simple" wmi command -- one with no arguments */
640 static int ath6kl_wmi_simple_cmd(struct wmi
*wmi
, enum wmi_cmd_id cmd_id
)
645 skb
= ath6kl_wmi_get_new_buf(0);
649 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, cmd_id
, NO_SYNC_WMIFLAG
);
654 static int ath6kl_wmi_ready_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
656 struct wmi_ready_event_2
*ev
= (struct wmi_ready_event_2
*) datap
;
658 if (len
< sizeof(struct wmi_ready_event_2
))
662 ath6kl_ready_event(wmi
->parent_dev
, ev
->mac_addr
,
663 le32_to_cpu(ev
->sw_version
),
664 le32_to_cpu(ev
->abi_version
));
669 static int ath6kl_wmi_connect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
671 struct wmi_connect_event
*ev
;
674 if (len
< sizeof(struct wmi_connect_event
))
677 ev
= (struct wmi_connect_event
*) datap
;
679 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: freq %d bssid %pM\n",
680 __func__
, ev
->ch
, ev
->bssid
);
682 /* Start of assoc rsp IEs */
683 pie
= ev
->assoc_info
+ ev
->beacon_ie_len
+
684 ev
->assoc_req_len
+ (sizeof(u16
) * 3); /* capinfo, status, aid */
686 /* End of assoc rsp IEs */
687 peie
= ev
->assoc_info
+ ev
->beacon_ie_len
+ ev
->assoc_req_len
+
692 case WLAN_EID_VENDOR_SPECIFIC
:
693 if (pie
[1] > 3 && pie
[2] == 0x00 && pie
[3] == 0x50 &&
694 pie
[4] == 0xf2 && pie
[5] == WMM_OUI_TYPE
) {
695 /* WMM OUT (00:50:F2) */
697 && pie
[6] == WMM_PARAM_OUI_SUBTYPE
)
698 wmi
->is_wmm_enabled
= true;
703 if (wmi
->is_wmm_enabled
)
709 ath6kl_connect_event(wmi
->parent_dev
, le16_to_cpu(ev
->ch
), ev
->bssid
,
710 le16_to_cpu(ev
->listen_intvl
),
711 le16_to_cpu(ev
->beacon_intvl
),
712 le32_to_cpu(ev
->nw_type
),
713 ev
->beacon_ie_len
, ev
->assoc_req_len
,
714 ev
->assoc_resp_len
, ev
->assoc_info
);
719 static int ath6kl_wmi_disconnect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
721 struct wmi_disconnect_event
*ev
;
722 wmi
->traffic_class
= 100;
724 if (len
< sizeof(struct wmi_disconnect_event
))
727 ev
= (struct wmi_disconnect_event
*) datap
;
729 wmi
->is_wmm_enabled
= false;
730 wmi
->pair_crypto_type
= NONE_CRYPT
;
731 wmi
->grp_crypto_type
= NONE_CRYPT
;
733 ath6kl_disconnect_event(wmi
->parent_dev
, ev
->disconn_reason
,
734 ev
->bssid
, ev
->assoc_resp_len
, ev
->assoc_info
,
735 le16_to_cpu(ev
->proto_reason_status
));
740 static int ath6kl_wmi_peer_node_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
742 struct wmi_peer_node_event
*ev
;
744 if (len
< sizeof(struct wmi_peer_node_event
))
747 ev
= (struct wmi_peer_node_event
*) datap
;
749 if (ev
->event_code
== PEER_NODE_JOIN_EVENT
)
750 ath6kl_dbg(ATH6KL_DBG_WMI
, "joined node with mac addr: %pM\n",
752 else if (ev
->event_code
== PEER_NODE_LEAVE_EVENT
)
753 ath6kl_dbg(ATH6KL_DBG_WMI
, "left node with mac addr: %pM\n",
759 static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
761 struct wmi_tkip_micerr_event
*ev
;
763 if (len
< sizeof(struct wmi_tkip_micerr_event
))
766 ev
= (struct wmi_tkip_micerr_event
*) datap
;
768 ath6kl_tkip_micerr_event(wmi
->parent_dev
, ev
->key_id
, ev
->is_mcast
);
773 static int ath6kl_wlan_parse_beacon(u8
*buf
, int frame_len
,
774 struct ath6kl_common_ie
*cie
)
777 u8 elemid_ssid
= false;
780 efrm
= (u8
*) (frm
+ frame_len
);
783 * beacon/probe response frame format
785 * [2] beacon interval
786 * [2] capability information
788 * [tlv] supported rates
789 * [tlv] country information
790 * [tlv] parameter set (FH/DS)
791 * [tlv] erp information
792 * [tlv] extended supported rates
795 * [tlv] Atheros Advanced Capabilities
797 if ((efrm
- frm
) < 12)
800 memset(cie
, 0, sizeof(*cie
));
802 cie
->ie_tstamp
= frm
;
804 cie
->ie_beaconInt
= *(u16
*) frm
;
806 cie
->ie_capInfo
= *(u16
*) frm
;
818 case WLAN_EID_SUPP_RATES
:
821 case WLAN_EID_COUNTRY
:
822 cie
->ie_country
= frm
;
824 case WLAN_EID_FH_PARAMS
:
826 case WLAN_EID_DS_PARAMS
:
827 cie
->ie_chan
= frm
[2];
832 case WLAN_EID_IBSS_PARAMS
:
834 case WLAN_EID_EXT_SUPP_RATES
:
835 cie
->ie_xrates
= frm
;
837 case WLAN_EID_ERP_INFO
:
841 cie
->ie_erp
= frm
[2];
846 case WLAN_EID_HT_CAPABILITY
:
849 case WLAN_EID_HT_INFORMATION
:
852 case WLAN_EID_VENDOR_SPECIFIC
:
853 if (frm
[1] > 3 && frm
[2] == 0x00 && frm
[3] == 0x50 &&
855 /* OUT Type (00:50:F2) */
857 if (frm
[5] == WPA_OUI_TYPE
) {
860 } else if (frm
[5] == WMM_OUI_TYPE
) {
863 } else if (frm
[5] == WSC_OUT_TYPE
) {
868 } else if (frm
[1] > 3 && frm
[2] == 0x00
869 && frm
[3] == 0x03 && frm
[4] == 0x7f
870 && frm
[5] == ATH_OUI_TYPE
) {
871 /* Atheros OUI (00:03:7f) */
881 if ((cie
->ie_rates
== NULL
)
882 || (cie
->ie_rates
[1] > ATH6KL_RATE_MAXSIZE
))
885 if ((cie
->ie_ssid
== NULL
)
886 || (cie
->ie_ssid
[1] > IEEE80211_MAX_SSID_LEN
))
892 static int ath6kl_wmi_bssinfo_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
894 struct bss
*bss
= NULL
;
895 struct wmi_bss_info_hdr
*bih
;
896 u8 cached_ssid_len
= 0;
897 u8 cached_ssid
[IEEE80211_MAX_SSID_LEN
] = { 0 };
898 u8 beacon_ssid_len
= 0;
905 if (len
<= sizeof(struct wmi_bss_info_hdr
))
908 bih
= (struct wmi_bss_info_hdr
*) datap
;
909 bss
= wlan_find_node(&wmi
->parent_dev
->scan_table
, bih
->bssid
);
911 if (a_sle16_to_cpu(bih
->rssi
) > 0) {
915 bih
->rssi
= a_cpu_to_sle16(bss
->ni_rssi
);
918 buf
= datap
+ sizeof(struct wmi_bss_info_hdr
);
919 len
-= sizeof(struct wmi_bss_info_hdr
);
921 ath6kl_dbg(ATH6KL_DBG_WMI
,
922 "bss info evt - ch %u, rssi %02x, bssid \"%pM\"\n",
923 bih
->ch
, a_sle16_to_cpu(bih
->rssi
), bih
->bssid
);
927 * Free up the node. We are about to allocate a new node.
928 * In case of hidden AP, beacon will not have ssid,
929 * but a directed probe response will have it,
930 * so cache the probe-resp-ssid if already present.
932 if (wmi
->is_probe_ssid
&& (bih
->frame_type
== BEACON_FTYPE
)) {
933 ie_ssid
= bss
->ni_cie
.ie_ssid
;
934 if (ie_ssid
&& (ie_ssid
[1] <= IEEE80211_MAX_SSID_LEN
) &&
936 cached_ssid_len
= ie_ssid
[1];
937 memcpy(cached_ssid
, ie_ssid
+ 2,
943 * Use the current average rssi of associated AP base on
945 * 1. Most os with GUI will update RSSI by
946 * ath6kl_wmi_get_stats_cmd() periodically.
947 * 2. ath6kl_wmi_get_stats_cmd(..) will be called when calling
948 * ath6kl_wmi_startscan_cmd(...)
949 * The average value of RSSI give end-user better feeling for
950 * instance value of scan result. It also sync up RSSI info
951 * in GUI between scan result and RSSI signal icon.
953 if (memcmp(wmi
->parent_dev
->bssid
, bih
->bssid
, ETH_ALEN
) == 0) {
954 bih
->rssi
= a_cpu_to_sle16(bss
->ni_rssi
);
955 bih
->snr
= bss
->ni_snr
;
958 wlan_node_reclaim(&wmi
->parent_dev
->scan_table
, bss
);
962 * beacon/probe response frame format
964 * [2] beacon interval
965 * [2] capability information
968 beacon_ssid_len
= buf
[SSID_IE_LEN_INDEX
];
971 * If ssid is cached for this hidden AP, then change
972 * buffer len accordingly.
974 if (wmi
->is_probe_ssid
&& (bih
->frame_type
== BEACON_FTYPE
) &&
975 (cached_ssid_len
!= 0) &&
976 (beacon_ssid_len
== 0 || (cached_ssid_len
> beacon_ssid_len
&&
977 buf
[SSID_IE_LEN_INDEX
+ 1] == 0))) {
979 len
+= (cached_ssid_len
- beacon_ssid_len
);
982 bss
= wlan_node_alloc(len
);
986 bss
->ni_snr
= bih
->snr
;
987 bss
->ni_rssi
= a_sle16_to_cpu(bih
->rssi
);
989 if (WARN_ON(!bss
->ni_buf
))
993 * In case of hidden AP, beacon will not have ssid,
994 * but a directed probe response will have it,
995 * so place the cached-ssid(probe-resp) in the bss info.
997 if (wmi
->is_probe_ssid
&& (bih
->frame_type
== BEACON_FTYPE
) &&
998 (cached_ssid_len
!= 0) &&
999 (beacon_ssid_len
== 0 || (beacon_ssid_len
&&
1000 buf
[SSID_IE_LEN_INDEX
+ 1] == 0))) {
1001 ni_buf
= bss
->ni_buf
;
1005 * Copy the first 14 bytes:
1006 * time-stamp(8), beacon-interval(2),
1007 * cap-info(2), ssid-id(1), ssid-len(1).
1009 memcpy(ni_buf
, buf
, SSID_IE_LEN_INDEX
+ 1);
1011 ni_buf
[SSID_IE_LEN_INDEX
] = cached_ssid_len
;
1012 ni_buf
+= (SSID_IE_LEN_INDEX
+ 1);
1014 buf
+= (SSID_IE_LEN_INDEX
+ 1);
1015 buf_len
-= (SSID_IE_LEN_INDEX
+ 1);
1017 memcpy(ni_buf
, cached_ssid
, cached_ssid_len
);
1018 ni_buf
+= cached_ssid_len
;
1020 buf
+= beacon_ssid_len
;
1021 buf_len
-= beacon_ssid_len
;
1023 if (cached_ssid_len
> beacon_ssid_len
)
1024 buf_len
-= (cached_ssid_len
- beacon_ssid_len
);
1026 memcpy(ni_buf
, buf
, buf_len
);
1028 memcpy(bss
->ni_buf
, buf
, len
);
1030 bss
->ni_framelen
= len
;
1032 ret
= ath6kl_wlan_parse_beacon(bss
->ni_buf
, len
, &bss
->ni_cie
);
1034 wlan_node_free(bss
);
1039 * Update the frequency in ie_chan, overwriting of channel number
1040 * which is done in ath6kl_wlan_parse_beacon
1042 bss
->ni_cie
.ie_chan
= le16_to_cpu(bih
->ch
);
1043 wlan_setup_node(&wmi
->parent_dev
->scan_table
, bss
, bih
->bssid
);
1048 static int ath6kl_wmi_opt_frame_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1051 struct wmi_opt_rx_info_hdr
*bih
;
1054 if (len
<= sizeof(struct wmi_opt_rx_info_hdr
))
1057 bih
= (struct wmi_opt_rx_info_hdr
*) datap
;
1058 buf
= datap
+ sizeof(struct wmi_opt_rx_info_hdr
);
1059 len
-= sizeof(struct wmi_opt_rx_info_hdr
);
1061 ath6kl_dbg(ATH6KL_DBG_WMI
, "opt frame event %2.2x:%2.2x\n",
1062 bih
->bssid
[4], bih
->bssid
[5]);
1064 bss
= wlan_find_node(&wmi
->parent_dev
->scan_table
, bih
->bssid
);
1066 /* Free up the node. We are about to allocate a new node. */
1067 wlan_node_reclaim(&wmi
->parent_dev
->scan_table
, bss
);
1070 bss
= wlan_node_alloc(len
);
1074 bss
->ni_snr
= bih
->snr
;
1075 bss
->ni_cie
.ie_chan
= le16_to_cpu(bih
->ch
);
1077 if (WARN_ON(!bss
->ni_buf
))
1080 memcpy(bss
->ni_buf
, buf
, len
);
1081 wlan_setup_node(&wmi
->parent_dev
->scan_table
, bss
, bih
->bssid
);
1086 /* Inactivity timeout of a fatpipe(pstream) at the target */
1087 static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi
*wmi
, u8
*datap
,
1090 struct wmi_pstream_timeout_event
*ev
;
1092 if (len
< sizeof(struct wmi_pstream_timeout_event
))
1095 ev
= (struct wmi_pstream_timeout_event
*) datap
;
1098 * When the pstream (fat pipe == AC) timesout, it means there were
1099 * no thinStreams within this pstream & it got implicitly created
1100 * due to data flow on this AC. We start the inactivity timer only
1101 * for implicitly created pstream. Just reset the host state.
1103 spin_lock_bh(&wmi
->lock
);
1104 wmi
->stream_exist_for_ac
[ev
->traffic_class
] = 0;
1105 wmi
->fat_pipe_exist
&= ~(1 << ev
->traffic_class
);
1106 spin_unlock_bh(&wmi
->lock
);
1108 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1109 ath6kl_indicate_tx_activity(wmi
->parent_dev
, ev
->traffic_class
, false);
1114 static int ath6kl_wmi_bitrate_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1116 struct wmi_bit_rate_reply
*reply
;
1120 if (len
< sizeof(struct wmi_bit_rate_reply
))
1123 reply
= (struct wmi_bit_rate_reply
*) datap
;
1125 ath6kl_dbg(ATH6KL_DBG_WMI
, "rateindex %d\n", reply
->rate_index
);
1127 if (reply
->rate_index
== (s8
) RATE_AUTO
) {
1130 index
= reply
->rate_index
& 0x7f;
1131 sgi
= (reply
->rate_index
& 0x80) ? 1 : 0;
1132 rate
= wmi_rate_tbl
[index
][sgi
];
1135 ath6kl_wakeup_event(wmi
->parent_dev
);
1140 static int ath6kl_wmi_tcmd_test_report_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1142 ath6kl_tm_rx_report_event(wmi
->parent_dev
, datap
, len
);
1147 static int ath6kl_wmi_ratemask_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1149 if (len
< sizeof(struct wmi_fix_rates_reply
))
1152 ath6kl_wakeup_event(wmi
->parent_dev
);
1157 static int ath6kl_wmi_ch_list_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1159 if (len
< sizeof(struct wmi_channel_list_reply
))
1162 ath6kl_wakeup_event(wmi
->parent_dev
);
1167 static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1169 struct wmi_tx_pwr_reply
*reply
;
1171 if (len
< sizeof(struct wmi_tx_pwr_reply
))
1174 reply
= (struct wmi_tx_pwr_reply
*) datap
;
1175 ath6kl_txpwr_rx_evt(wmi
->parent_dev
, reply
->dbM
);
1180 static int ath6kl_wmi_keepalive_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1182 if (len
< sizeof(struct wmi_get_keepalive_cmd
))
1185 ath6kl_wakeup_event(wmi
->parent_dev
);
1190 static int ath6kl_wmi_scan_complete_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1192 struct wmi_scan_complete_event
*ev
;
1194 ev
= (struct wmi_scan_complete_event
*) datap
;
1196 if (a_sle32_to_cpu(ev
->status
) == 0)
1197 wlan_refresh_inactive_nodes(wmi
->parent_dev
);
1199 ath6kl_scan_complete_evt(wmi
->parent_dev
, a_sle32_to_cpu(ev
->status
));
1200 wmi
->is_probe_ssid
= false;
1206 * Target is reporting a programming error. This is for
1207 * developer aid only. Target only checks a few common violations
1208 * and it is responsibility of host to do all error checking.
1209 * Behavior of target after wmi error event is undefined.
1210 * A reset is recommended.
1212 static int ath6kl_wmi_error_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1214 const char *type
= "unknown error";
1215 struct wmi_cmd_error_event
*ev
;
1216 ev
= (struct wmi_cmd_error_event
*) datap
;
1218 switch (ev
->err_code
) {
1220 type
= "invalid parameter";
1223 type
= "invalid state";
1225 case INTERNAL_ERROR
:
1226 type
= "internal error";
1230 ath6kl_dbg(ATH6KL_DBG_WMI
, "programming error, cmd=%d %s\n",
1236 static int ath6kl_wmi_stats_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1238 ath6kl_tgt_stats_event(wmi
->parent_dev
, datap
, len
);
1243 static u8
ath6kl_wmi_get_upper_threshold(s16 rssi
,
1244 struct sq_threshold_params
*sq_thresh
,
1248 u8 threshold
= (u8
) sq_thresh
->upper_threshold
[size
- 1];
1250 /* The list is already in sorted order. Get the next lower value */
1251 for (index
= 0; index
< size
; index
++) {
1252 if (rssi
< sq_thresh
->upper_threshold
[index
]) {
1253 threshold
= (u8
) sq_thresh
->upper_threshold
[index
];
1261 static u8
ath6kl_wmi_get_lower_threshold(s16 rssi
,
1262 struct sq_threshold_params
*sq_thresh
,
1266 u8 threshold
= (u8
) sq_thresh
->lower_threshold
[size
- 1];
1268 /* The list is already in sorted order. Get the next lower value */
1269 for (index
= 0; index
< size
; index
++) {
1270 if (rssi
> sq_thresh
->lower_threshold
[index
]) {
1271 threshold
= (u8
) sq_thresh
->lower_threshold
[index
];
1279 static int ath6kl_wmi_send_rssi_threshold_params(struct wmi
*wmi
,
1280 struct wmi_rssi_threshold_params_cmd
*rssi_cmd
)
1282 struct sk_buff
*skb
;
1283 struct wmi_rssi_threshold_params_cmd
*cmd
;
1285 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1289 cmd
= (struct wmi_rssi_threshold_params_cmd
*) skb
->data
;
1290 memcpy(cmd
, rssi_cmd
, sizeof(struct wmi_rssi_threshold_params_cmd
));
1292 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RSSI_THRESHOLD_PARAMS_CMDID
,
1296 static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1299 struct wmi_rssi_threshold_event
*reply
;
1300 struct wmi_rssi_threshold_params_cmd cmd
;
1301 struct sq_threshold_params
*sq_thresh
;
1302 enum wmi_rssi_threshold_val new_threshold
;
1303 u8 upper_rssi_threshold
, lower_rssi_threshold
;
1307 if (len
< sizeof(struct wmi_rssi_threshold_event
))
1310 reply
= (struct wmi_rssi_threshold_event
*) datap
;
1311 new_threshold
= (enum wmi_rssi_threshold_val
) reply
->range
;
1312 rssi
= a_sle16_to_cpu(reply
->rssi
);
1314 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_RSSI
];
1317 * Identify the threshold breached and communicate that to the app.
1318 * After that install a new set of thresholds based on the signal
1319 * quality reported by the target
1321 if (new_threshold
) {
1322 /* Upper threshold breached */
1323 if (rssi
< sq_thresh
->upper_threshold
[0]) {
1324 ath6kl_dbg(ATH6KL_DBG_WMI
,
1325 "spurious upper rssi threshold event: %d\n",
1327 } else if ((rssi
< sq_thresh
->upper_threshold
[1]) &&
1328 (rssi
>= sq_thresh
->upper_threshold
[0])) {
1329 new_threshold
= WMI_RSSI_THRESHOLD1_ABOVE
;
1330 } else if ((rssi
< sq_thresh
->upper_threshold
[2]) &&
1331 (rssi
>= sq_thresh
->upper_threshold
[1])) {
1332 new_threshold
= WMI_RSSI_THRESHOLD2_ABOVE
;
1333 } else if ((rssi
< sq_thresh
->upper_threshold
[3]) &&
1334 (rssi
>= sq_thresh
->upper_threshold
[2])) {
1335 new_threshold
= WMI_RSSI_THRESHOLD3_ABOVE
;
1336 } else if ((rssi
< sq_thresh
->upper_threshold
[4]) &&
1337 (rssi
>= sq_thresh
->upper_threshold
[3])) {
1338 new_threshold
= WMI_RSSI_THRESHOLD4_ABOVE
;
1339 } else if ((rssi
< sq_thresh
->upper_threshold
[5]) &&
1340 (rssi
>= sq_thresh
->upper_threshold
[4])) {
1341 new_threshold
= WMI_RSSI_THRESHOLD5_ABOVE
;
1342 } else if (rssi
>= sq_thresh
->upper_threshold
[5]) {
1343 new_threshold
= WMI_RSSI_THRESHOLD6_ABOVE
;
1346 /* Lower threshold breached */
1347 if (rssi
> sq_thresh
->lower_threshold
[0]) {
1348 ath6kl_dbg(ATH6KL_DBG_WMI
,
1349 "spurious lower rssi threshold event: %d %d\n",
1350 rssi
, sq_thresh
->lower_threshold
[0]);
1351 } else if ((rssi
> sq_thresh
->lower_threshold
[1]) &&
1352 (rssi
<= sq_thresh
->lower_threshold
[0])) {
1353 new_threshold
= WMI_RSSI_THRESHOLD6_BELOW
;
1354 } else if ((rssi
> sq_thresh
->lower_threshold
[2]) &&
1355 (rssi
<= sq_thresh
->lower_threshold
[1])) {
1356 new_threshold
= WMI_RSSI_THRESHOLD5_BELOW
;
1357 } else if ((rssi
> sq_thresh
->lower_threshold
[3]) &&
1358 (rssi
<= sq_thresh
->lower_threshold
[2])) {
1359 new_threshold
= WMI_RSSI_THRESHOLD4_BELOW
;
1360 } else if ((rssi
> sq_thresh
->lower_threshold
[4]) &&
1361 (rssi
<= sq_thresh
->lower_threshold
[3])) {
1362 new_threshold
= WMI_RSSI_THRESHOLD3_BELOW
;
1363 } else if ((rssi
> sq_thresh
->lower_threshold
[5]) &&
1364 (rssi
<= sq_thresh
->lower_threshold
[4])) {
1365 new_threshold
= WMI_RSSI_THRESHOLD2_BELOW
;
1366 } else if (rssi
<= sq_thresh
->lower_threshold
[5]) {
1367 new_threshold
= WMI_RSSI_THRESHOLD1_BELOW
;
1371 /* Calculate and install the next set of thresholds */
1372 lower_rssi_threshold
= ath6kl_wmi_get_lower_threshold(rssi
, sq_thresh
,
1373 sq_thresh
->lower_threshold_valid_count
);
1374 upper_rssi_threshold
= ath6kl_wmi_get_upper_threshold(rssi
, sq_thresh
,
1375 sq_thresh
->upper_threshold_valid_count
);
1377 /* Issue a wmi command to install the thresholds */
1378 cmd
.thresh_above1_val
= a_cpu_to_sle16(upper_rssi_threshold
);
1379 cmd
.thresh_below1_val
= a_cpu_to_sle16(lower_rssi_threshold
);
1380 cmd
.weight
= sq_thresh
->weight
;
1381 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1383 ret
= ath6kl_wmi_send_rssi_threshold_params(wmi
, &cmd
);
1385 ath6kl_err("unable to configure rssi thresholds\n");
1392 static int ath6kl_wmi_cac_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1394 struct wmi_cac_event
*reply
;
1395 struct ieee80211_tspec_ie
*ts
;
1396 u16 active_tsids
, tsinfo
;
1400 if (len
< sizeof(struct wmi_cac_event
))
1403 reply
= (struct wmi_cac_event
*) datap
;
1405 if ((reply
->cac_indication
== CAC_INDICATION_ADMISSION_RESP
) &&
1406 (reply
->status_code
!= IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED
)) {
1408 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1409 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1410 tsid
= (tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1411 IEEE80211_WMM_IE_TSPEC_TID_MASK
;
1413 ath6kl_wmi_delete_pstream_cmd(wmi
, reply
->ac
, tsid
);
1414 } else if (reply
->cac_indication
== CAC_INDICATION_NO_RESP
) {
1416 * Following assumes that there is only one outstanding
1417 * ADDTS request when this event is received
1419 spin_lock_bh(&wmi
->lock
);
1420 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1421 spin_unlock_bh(&wmi
->lock
);
1423 for (index
= 0; index
< sizeof(active_tsids
) * 8; index
++) {
1424 if ((active_tsids
>> index
) & 1)
1427 if (index
< (sizeof(active_tsids
) * 8))
1428 ath6kl_wmi_delete_pstream_cmd(wmi
, reply
->ac
, index
);
1432 * Clear active tsids and Add missing handling
1433 * for delete qos stream from AP
1435 else if (reply
->cac_indication
== CAC_INDICATION_DELETE
) {
1437 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1438 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1439 ts_id
= ((tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1440 IEEE80211_WMM_IE_TSPEC_TID_MASK
);
1442 spin_lock_bh(&wmi
->lock
);
1443 wmi
->stream_exist_for_ac
[reply
->ac
] &= ~(1 << ts_id
);
1444 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1445 spin_unlock_bh(&wmi
->lock
);
1447 /* Indicate stream inactivity to driver layer only if all tsids
1448 * within this AC are deleted.
1450 if (!active_tsids
) {
1451 ath6kl_indicate_tx_activity(wmi
->parent_dev
, reply
->ac
,
1453 wmi
->fat_pipe_exist
&= ~(1 << reply
->ac
);
1460 static int ath6kl_wmi_send_snr_threshold_params(struct wmi
*wmi
,
1461 struct wmi_snr_threshold_params_cmd
*snr_cmd
)
1463 struct sk_buff
*skb
;
1464 struct wmi_snr_threshold_params_cmd
*cmd
;
1466 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1470 cmd
= (struct wmi_snr_threshold_params_cmd
*) skb
->data
;
1471 memcpy(cmd
, snr_cmd
, sizeof(struct wmi_snr_threshold_params_cmd
));
1473 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SNR_THRESHOLD_PARAMS_CMDID
,
1477 static int ath6kl_wmi_snr_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1480 struct wmi_snr_threshold_event
*reply
;
1481 struct sq_threshold_params
*sq_thresh
;
1482 struct wmi_snr_threshold_params_cmd cmd
;
1483 enum wmi_snr_threshold_val new_threshold
;
1484 u8 upper_snr_threshold
, lower_snr_threshold
;
1488 if (len
< sizeof(struct wmi_snr_threshold_event
))
1491 reply
= (struct wmi_snr_threshold_event
*) datap
;
1493 new_threshold
= (enum wmi_snr_threshold_val
) reply
->range
;
1496 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_SNR
];
1499 * Identify the threshold breached and communicate that to the app.
1500 * After that install a new set of thresholds based on the signal
1501 * quality reported by the target.
1503 if (new_threshold
) {
1504 /* Upper threshold breached */
1505 if (snr
< sq_thresh
->upper_threshold
[0]) {
1506 ath6kl_dbg(ATH6KL_DBG_WMI
,
1507 "spurious upper snr threshold event: %d\n",
1509 } else if ((snr
< sq_thresh
->upper_threshold
[1]) &&
1510 (snr
>= sq_thresh
->upper_threshold
[0])) {
1511 new_threshold
= WMI_SNR_THRESHOLD1_ABOVE
;
1512 } else if ((snr
< sq_thresh
->upper_threshold
[2]) &&
1513 (snr
>= sq_thresh
->upper_threshold
[1])) {
1514 new_threshold
= WMI_SNR_THRESHOLD2_ABOVE
;
1515 } else if ((snr
< sq_thresh
->upper_threshold
[3]) &&
1516 (snr
>= sq_thresh
->upper_threshold
[2])) {
1517 new_threshold
= WMI_SNR_THRESHOLD3_ABOVE
;
1518 } else if (snr
>= sq_thresh
->upper_threshold
[3]) {
1519 new_threshold
= WMI_SNR_THRESHOLD4_ABOVE
;
1522 /* Lower threshold breached */
1523 if (snr
> sq_thresh
->lower_threshold
[0]) {
1524 ath6kl_dbg(ATH6KL_DBG_WMI
,
1525 "spurious lower snr threshold event: %d\n",
1526 sq_thresh
->lower_threshold
[0]);
1527 } else if ((snr
> sq_thresh
->lower_threshold
[1]) &&
1528 (snr
<= sq_thresh
->lower_threshold
[0])) {
1529 new_threshold
= WMI_SNR_THRESHOLD4_BELOW
;
1530 } else if ((snr
> sq_thresh
->lower_threshold
[2]) &&
1531 (snr
<= sq_thresh
->lower_threshold
[1])) {
1532 new_threshold
= WMI_SNR_THRESHOLD3_BELOW
;
1533 } else if ((snr
> sq_thresh
->lower_threshold
[3]) &&
1534 (snr
<= sq_thresh
->lower_threshold
[2])) {
1535 new_threshold
= WMI_SNR_THRESHOLD2_BELOW
;
1536 } else if (snr
<= sq_thresh
->lower_threshold
[3]) {
1537 new_threshold
= WMI_SNR_THRESHOLD1_BELOW
;
1541 /* Calculate and install the next set of thresholds */
1542 lower_snr_threshold
= ath6kl_wmi_get_lower_threshold(snr
, sq_thresh
,
1543 sq_thresh
->lower_threshold_valid_count
);
1544 upper_snr_threshold
= ath6kl_wmi_get_upper_threshold(snr
, sq_thresh
,
1545 sq_thresh
->upper_threshold_valid_count
);
1547 /* Issue a wmi command to install the thresholds */
1548 cmd
.thresh_above1_val
= upper_snr_threshold
;
1549 cmd
.thresh_below1_val
= lower_snr_threshold
;
1550 cmd
.weight
= sq_thresh
->weight
;
1551 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1553 ath6kl_dbg(ATH6KL_DBG_WMI
,
1554 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1556 lower_snr_threshold
, upper_snr_threshold
);
1558 ret
= ath6kl_wmi_send_snr_threshold_params(wmi
, &cmd
);
1560 ath6kl_err("unable to configure snr threshold\n");
1567 static int ath6kl_wmi_aplist_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1569 u16 ap_info_entry_size
;
1570 struct wmi_aplist_event
*ev
= (struct wmi_aplist_event
*) datap
;
1571 struct wmi_ap_info_v1
*ap_info_v1
;
1574 if (len
< sizeof(struct wmi_aplist_event
) ||
1575 ev
->ap_list_ver
!= APLIST_VER1
)
1578 ap_info_entry_size
= sizeof(struct wmi_ap_info_v1
);
1579 ap_info_v1
= (struct wmi_ap_info_v1
*) ev
->ap_list
;
1581 ath6kl_dbg(ATH6KL_DBG_WMI
,
1582 "number of APs in aplist event: %d\n", ev
->num_ap
);
1584 if (len
< (int) (sizeof(struct wmi_aplist_event
) +
1585 (ev
->num_ap
- 1) * ap_info_entry_size
))
1588 /* AP list version 1 contents */
1589 for (index
= 0; index
< ev
->num_ap
; index
++) {
1590 ath6kl_dbg(ATH6KL_DBG_WMI
, "AP#%d BSSID %pM Channel %d\n",
1591 index
, ap_info_v1
->bssid
, ap_info_v1
->channel
);
1598 int ath6kl_wmi_cmd_send(struct wmi
*wmi
, struct sk_buff
*skb
,
1599 enum wmi_cmd_id cmd_id
, enum wmi_sync_flag sync_flag
)
1601 struct wmi_cmd_hdr
*cmd_hdr
;
1602 enum htc_endpoint_id ep_id
= wmi
->ep_id
;
1605 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: cmd_id=%d\n", __func__
, cmd_id
);
1607 if (WARN_ON(skb
== NULL
))
1610 if (sync_flag
>= END_WMIFLAG
) {
1615 if ((sync_flag
== SYNC_BEFORE_WMIFLAG
) ||
1616 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1618 * Make sure all data currently queued is transmitted before
1619 * the cmd execution. Establish a new sync point.
1621 ath6kl_wmi_sync_point(wmi
);
1624 skb_push(skb
, sizeof(struct wmi_cmd_hdr
));
1626 cmd_hdr
= (struct wmi_cmd_hdr
*) skb
->data
;
1627 cmd_hdr
->cmd_id
= cpu_to_le16(cmd_id
);
1628 cmd_hdr
->info1
= 0; /* added for virtual interface */
1630 /* Only for OPT_TX_CMD, use BE endpoint. */
1631 if (cmd_id
== WMI_OPT_TX_FRAME_CMDID
) {
1632 ret
= ath6kl_wmi_data_hdr_add(wmi
, skb
, OPT_MSGTYPE
,
1633 false, false, 0, NULL
);
1638 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
, WMM_AC_BE
);
1641 ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
1643 if ((sync_flag
== SYNC_AFTER_WMIFLAG
) ||
1644 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1646 * Make sure all new data queued waits for the command to
1647 * execute. Establish a new sync point.
1649 ath6kl_wmi_sync_point(wmi
);
1655 int ath6kl_wmi_connect_cmd(struct wmi
*wmi
, enum network_type nw_type
,
1656 enum dot11_auth_mode dot11_auth_mode
,
1657 enum auth_mode auth_mode
,
1658 enum crypto_type pairwise_crypto
,
1659 u8 pairwise_crypto_len
,
1660 enum crypto_type group_crypto
,
1661 u8 group_crypto_len
, int ssid_len
, u8
*ssid
,
1662 u8
*bssid
, u16 channel
, u32 ctrl_flags
)
1664 struct sk_buff
*skb
;
1665 struct wmi_connect_cmd
*cc
;
1668 wmi
->traffic_class
= 100;
1670 if ((pairwise_crypto
== NONE_CRYPT
) && (group_crypto
!= NONE_CRYPT
))
1673 if ((pairwise_crypto
!= NONE_CRYPT
) && (group_crypto
== NONE_CRYPT
))
1676 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd
));
1680 cc
= (struct wmi_connect_cmd
*) skb
->data
;
1683 memcpy(cc
->ssid
, ssid
, ssid_len
);
1685 cc
->ssid_len
= ssid_len
;
1686 cc
->nw_type
= nw_type
;
1687 cc
->dot11_auth_mode
= dot11_auth_mode
;
1688 cc
->auth_mode
= auth_mode
;
1689 cc
->prwise_crypto_type
= pairwise_crypto
;
1690 cc
->prwise_crypto_len
= pairwise_crypto_len
;
1691 cc
->grp_crypto_type
= group_crypto
;
1692 cc
->grp_crypto_len
= group_crypto_len
;
1693 cc
->ch
= cpu_to_le16(channel
);
1694 cc
->ctrl_flags
= cpu_to_le32(ctrl_flags
);
1697 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1699 wmi
->pair_crypto_type
= pairwise_crypto
;
1700 wmi
->grp_crypto_type
= group_crypto
;
1702 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_CONNECT_CMDID
, NO_SYNC_WMIFLAG
);
1707 int ath6kl_wmi_reconnect_cmd(struct wmi
*wmi
, u8
*bssid
, u16 channel
)
1709 struct sk_buff
*skb
;
1710 struct wmi_reconnect_cmd
*cc
;
1713 wmi
->traffic_class
= 100;
1715 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd
));
1719 cc
= (struct wmi_reconnect_cmd
*) skb
->data
;
1720 cc
->channel
= cpu_to_le16(channel
);
1723 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1725 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RECONNECT_CMDID
,
1731 int ath6kl_wmi_disconnect_cmd(struct wmi
*wmi
)
1735 wmi
->traffic_class
= 100;
1737 /* Disconnect command does not need to do a SYNC before. */
1738 ret
= ath6kl_wmi_simple_cmd(wmi
, WMI_DISCONNECT_CMDID
);
1743 int ath6kl_wmi_startscan_cmd(struct wmi
*wmi
, enum wmi_scan_type scan_type
,
1744 u32 force_fgscan
, u32 is_legacy
,
1745 u32 home_dwell_time
, u32 force_scan_interval
,
1746 s8 num_chan
, u16
*ch_list
)
1748 struct sk_buff
*skb
;
1749 struct wmi_start_scan_cmd
*sc
;
1753 size
= sizeof(struct wmi_start_scan_cmd
);
1755 if ((scan_type
!= WMI_LONG_SCAN
) && (scan_type
!= WMI_SHORT_SCAN
))
1758 if (num_chan
> WMI_MAX_CHANNELS
)
1762 size
+= sizeof(u16
) * (num_chan
- 1);
1764 skb
= ath6kl_wmi_get_new_buf(size
);
1768 sc
= (struct wmi_start_scan_cmd
*) skb
->data
;
1769 sc
->scan_type
= scan_type
;
1770 sc
->force_fg_scan
= cpu_to_le32(force_fgscan
);
1771 sc
->is_legacy
= cpu_to_le32(is_legacy
);
1772 sc
->home_dwell_time
= cpu_to_le32(home_dwell_time
);
1773 sc
->force_scan_intvl
= cpu_to_le32(force_scan_interval
);
1774 sc
->num_ch
= num_chan
;
1776 for (i
= 0; i
< num_chan
; i
++)
1777 sc
->ch_list
[i
] = cpu_to_le16(ch_list
[i
]);
1779 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_START_SCAN_CMDID
,
1785 int ath6kl_wmi_scanparams_cmd(struct wmi
*wmi
, u16 fg_start_sec
,
1786 u16 fg_end_sec
, u16 bg_sec
,
1787 u16 minact_chdw_msec
, u16 maxact_chdw_msec
,
1788 u16 pas_chdw_msec
, u8 short_scan_ratio
,
1789 u8 scan_ctrl_flag
, u32 max_dfsch_act_time
,
1790 u16 maxact_scan_per_ssid
)
1792 struct sk_buff
*skb
;
1793 struct wmi_scan_params_cmd
*sc
;
1796 skb
= ath6kl_wmi_get_new_buf(sizeof(*sc
));
1800 sc
= (struct wmi_scan_params_cmd
*) skb
->data
;
1801 sc
->fg_start_period
= cpu_to_le16(fg_start_sec
);
1802 sc
->fg_end_period
= cpu_to_le16(fg_end_sec
);
1803 sc
->bg_period
= cpu_to_le16(bg_sec
);
1804 sc
->minact_chdwell_time
= cpu_to_le16(minact_chdw_msec
);
1805 sc
->maxact_chdwell_time
= cpu_to_le16(maxact_chdw_msec
);
1806 sc
->pas_chdwell_time
= cpu_to_le16(pas_chdw_msec
);
1807 sc
->short_scan_ratio
= short_scan_ratio
;
1808 sc
->scan_ctrl_flags
= scan_ctrl_flag
;
1809 sc
->max_dfsch_act_time
= cpu_to_le32(max_dfsch_act_time
);
1810 sc
->maxact_scan_per_ssid
= cpu_to_le16(maxact_scan_per_ssid
);
1812 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_SCAN_PARAMS_CMDID
,
1817 int ath6kl_wmi_bssfilter_cmd(struct wmi
*wmi
, u8 filter
, u32 ie_mask
)
1819 struct sk_buff
*skb
;
1820 struct wmi_bss_filter_cmd
*cmd
;
1823 if (filter
>= LAST_BSS_FILTER
)
1826 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1830 cmd
= (struct wmi_bss_filter_cmd
*) skb
->data
;
1831 cmd
->bss_filter
= filter
;
1832 cmd
->ie_mask
= cpu_to_le32(ie_mask
);
1834 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_BSS_FILTER_CMDID
,
1839 int ath6kl_wmi_probedssid_cmd(struct wmi
*wmi
, u8 index
, u8 flag
,
1840 u8 ssid_len
, u8
*ssid
)
1842 struct sk_buff
*skb
;
1843 struct wmi_probed_ssid_cmd
*cmd
;
1846 if (index
> MAX_PROBED_SSID_INDEX
)
1849 if (ssid_len
> sizeof(cmd
->ssid
))
1852 if ((flag
& (DISABLE_SSID_FLAG
| ANY_SSID_FLAG
)) && (ssid_len
> 0))
1855 if ((flag
& SPECIFIC_SSID_FLAG
) && !ssid_len
)
1858 if (flag
& SPECIFIC_SSID_FLAG
)
1859 wmi
->is_probe_ssid
= true;
1861 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1865 cmd
= (struct wmi_probed_ssid_cmd
*) skb
->data
;
1866 cmd
->entry_index
= index
;
1868 cmd
->ssid_len
= ssid_len
;
1869 memcpy(cmd
->ssid
, ssid
, ssid_len
);
1871 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_PROBED_SSID_CMDID
,
1876 int ath6kl_wmi_listeninterval_cmd(struct wmi
*wmi
, u16 listen_interval
,
1879 struct sk_buff
*skb
;
1880 struct wmi_listen_int_cmd
*cmd
;
1883 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1887 cmd
= (struct wmi_listen_int_cmd
*) skb
->data
;
1888 cmd
->listen_intvl
= cpu_to_le16(listen_interval
);
1889 cmd
->num_beacons
= cpu_to_le16(listen_beacons
);
1891 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_LISTEN_INT_CMDID
,
1896 int ath6kl_wmi_powermode_cmd(struct wmi
*wmi
, u8 pwr_mode
)
1898 struct sk_buff
*skb
;
1899 struct wmi_power_mode_cmd
*cmd
;
1902 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1906 cmd
= (struct wmi_power_mode_cmd
*) skb
->data
;
1907 cmd
->pwr_mode
= pwr_mode
;
1908 wmi
->pwr_mode
= pwr_mode
;
1910 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_POWER_MODE_CMDID
,
1915 int ath6kl_wmi_pmparams_cmd(struct wmi
*wmi
, u16 idle_period
,
1916 u16 ps_poll_num
, u16 dtim_policy
,
1917 u16 tx_wakeup_policy
, u16 num_tx_to_wakeup
,
1918 u16 ps_fail_event_policy
)
1920 struct sk_buff
*skb
;
1921 struct wmi_power_params_cmd
*pm
;
1924 skb
= ath6kl_wmi_get_new_buf(sizeof(*pm
));
1928 pm
= (struct wmi_power_params_cmd
*)skb
->data
;
1929 pm
->idle_period
= cpu_to_le16(idle_period
);
1930 pm
->pspoll_number
= cpu_to_le16(ps_poll_num
);
1931 pm
->dtim_policy
= cpu_to_le16(dtim_policy
);
1932 pm
->tx_wakeup_policy
= cpu_to_le16(tx_wakeup_policy
);
1933 pm
->num_tx_to_wakeup
= cpu_to_le16(num_tx_to_wakeup
);
1934 pm
->ps_fail_event_policy
= cpu_to_le16(ps_fail_event_policy
);
1936 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_POWER_PARAMS_CMDID
,
1941 int ath6kl_wmi_disctimeout_cmd(struct wmi
*wmi
, u8 timeout
)
1943 struct sk_buff
*skb
;
1944 struct wmi_disc_timeout_cmd
*cmd
;
1947 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1951 cmd
= (struct wmi_disc_timeout_cmd
*) skb
->data
;
1952 cmd
->discon_timeout
= timeout
;
1954 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_DISC_TIMEOUT_CMDID
,
1959 int ath6kl_wmi_addkey_cmd(struct wmi
*wmi
, u8 key_index
,
1960 enum crypto_type key_type
,
1961 u8 key_usage
, u8 key_len
,
1962 u8
*key_rsc
, u8
*key_material
,
1963 u8 key_op_ctrl
, u8
*mac_addr
,
1964 enum wmi_sync_flag sync_flag
)
1966 struct sk_buff
*skb
;
1967 struct wmi_add_cipher_key_cmd
*cmd
;
1970 ath6kl_dbg(ATH6KL_DBG_WMI
, "addkey cmd: key_index=%u key_type=%d "
1971 "key_usage=%d key_len=%d key_op_ctrl=%d\n",
1972 key_index
, key_type
, key_usage
, key_len
, key_op_ctrl
);
1974 if ((key_index
> WMI_MAX_KEY_INDEX
) || (key_len
> WMI_MAX_KEY_LEN
) ||
1975 (key_material
== NULL
))
1978 if ((WEP_CRYPT
!= key_type
) && (NULL
== key_rsc
))
1981 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1985 cmd
= (struct wmi_add_cipher_key_cmd
*) skb
->data
;
1986 cmd
->key_index
= key_index
;
1987 cmd
->key_type
= key_type
;
1988 cmd
->key_usage
= key_usage
;
1989 cmd
->key_len
= key_len
;
1990 memcpy(cmd
->key
, key_material
, key_len
);
1992 if (key_rsc
!= NULL
)
1993 memcpy(cmd
->key_rsc
, key_rsc
, sizeof(cmd
->key_rsc
));
1995 cmd
->key_op_ctrl
= key_op_ctrl
;
1998 memcpy(cmd
->key_mac_addr
, mac_addr
, ETH_ALEN
);
2000 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_ADD_CIPHER_KEY_CMDID
,
2006 int ath6kl_wmi_add_krk_cmd(struct wmi
*wmi
, u8
*krk
)
2008 struct sk_buff
*skb
;
2009 struct wmi_add_krk_cmd
*cmd
;
2012 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2016 cmd
= (struct wmi_add_krk_cmd
*) skb
->data
;
2017 memcpy(cmd
->krk
, krk
, WMI_KRK_LEN
);
2019 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_ADD_KRK_CMDID
, NO_SYNC_WMIFLAG
);
2024 int ath6kl_wmi_deletekey_cmd(struct wmi
*wmi
, u8 key_index
)
2026 struct sk_buff
*skb
;
2027 struct wmi_delete_cipher_key_cmd
*cmd
;
2030 if (key_index
> WMI_MAX_KEY_INDEX
)
2033 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2037 cmd
= (struct wmi_delete_cipher_key_cmd
*) skb
->data
;
2038 cmd
->key_index
= key_index
;
2040 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DELETE_CIPHER_KEY_CMDID
,
2046 int ath6kl_wmi_setpmkid_cmd(struct wmi
*wmi
, const u8
*bssid
,
2047 const u8
*pmkid
, bool set
)
2049 struct sk_buff
*skb
;
2050 struct wmi_setpmkid_cmd
*cmd
;
2056 if (set
&& pmkid
== NULL
)
2059 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2063 cmd
= (struct wmi_setpmkid_cmd
*) skb
->data
;
2064 memcpy(cmd
->bssid
, bssid
, ETH_ALEN
);
2066 memcpy(cmd
->pmkid
, pmkid
, sizeof(cmd
->pmkid
));
2067 cmd
->enable
= PMKID_ENABLE
;
2069 memset(cmd
->pmkid
, 0, sizeof(cmd
->pmkid
));
2070 cmd
->enable
= PMKID_DISABLE
;
2073 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_PMKID_CMDID
,
2079 static int ath6kl_wmi_data_sync_send(struct wmi
*wmi
, struct sk_buff
*skb
,
2080 enum htc_endpoint_id ep_id
)
2082 struct wmi_data_hdr
*data_hdr
;
2085 if (WARN_ON(skb
== NULL
|| ep_id
== wmi
->ep_id
))
2088 skb_push(skb
, sizeof(struct wmi_data_hdr
));
2090 data_hdr
= (struct wmi_data_hdr
*) skb
->data
;
2091 data_hdr
->info
= SYNC_MSGTYPE
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
2092 data_hdr
->info3
= 0;
2094 ret
= ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
2099 static int ath6kl_wmi_sync_point(struct wmi
*wmi
)
2101 struct sk_buff
*skb
;
2102 struct wmi_sync_cmd
*cmd
;
2103 struct wmi_data_sync_bufs data_sync_bufs
[WMM_NUM_AC
];
2104 enum htc_endpoint_id ep_id
;
2105 u8 index
, num_pri_streams
= 0;
2108 memset(data_sync_bufs
, 0, sizeof(data_sync_bufs
));
2110 spin_lock_bh(&wmi
->lock
);
2112 for (index
= 0; index
< WMM_NUM_AC
; index
++) {
2113 if (wmi
->fat_pipe_exist
& (1 << index
)) {
2115 data_sync_bufs
[num_pri_streams
- 1].traffic_class
=
2120 spin_unlock_bh(&wmi
->lock
);
2122 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2128 cmd
= (struct wmi_sync_cmd
*) skb
->data
;
2131 * In the SYNC cmd sent on the control Ep, send a bitmap
2132 * of the data eps on which the Data Sync will be sent
2134 cmd
->data_sync_map
= wmi
->fat_pipe_exist
;
2136 for (index
= 0; index
< num_pri_streams
; index
++) {
2137 data_sync_bufs
[index
].skb
= ath6kl_buf_alloc(0);
2138 if (data_sync_bufs
[index
].skb
== NULL
) {
2145 * If buffer allocation for any of the dataSync fails,
2146 * then do not send the Synchronize cmd on the control ep
2152 * Send sync cmd followed by sync data messages on all
2153 * endpoints being used
2155 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SYNCHRONIZE_CMDID
,
2161 /* cmd buffer sent, we no longer own it */
2164 for (index
= 0; index
< num_pri_streams
; index
++) {
2166 if (WARN_ON(!data_sync_bufs
[index
].skb
))
2169 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
,
2170 data_sync_bufs
[index
].
2173 ath6kl_wmi_data_sync_send(wmi
, data_sync_bufs
[index
].skb
,
2179 data_sync_bufs
[index
].skb
= NULL
;
2183 /* free up any resources left over (possibly due to an error) */
2187 for (index
= 0; index
< num_pri_streams
; index
++) {
2188 if (data_sync_bufs
[index
].skb
!= NULL
) {
2189 dev_kfree_skb((struct sk_buff
*)data_sync_bufs
[index
].
2197 int ath6kl_wmi_create_pstream_cmd(struct wmi
*wmi
,
2198 struct wmi_create_pstream_cmd
*params
)
2200 struct sk_buff
*skb
;
2201 struct wmi_create_pstream_cmd
*cmd
;
2202 u8 fatpipe_exist_for_ac
= 0;
2204 s32 nominal_phy
= 0;
2207 if (!((params
->user_pri
< 8) &&
2208 (params
->user_pri
<= 0x7) &&
2209 (up_to_ac
[params
->user_pri
& 0x7] == params
->traffic_class
) &&
2210 (params
->traffic_direc
== UPLINK_TRAFFIC
||
2211 params
->traffic_direc
== DNLINK_TRAFFIC
||
2212 params
->traffic_direc
== BIDIR_TRAFFIC
) &&
2213 (params
->traffic_type
== TRAFFIC_TYPE_APERIODIC
||
2214 params
->traffic_type
== TRAFFIC_TYPE_PERIODIC
) &&
2215 (params
->voice_psc_cap
== DISABLE_FOR_THIS_AC
||
2216 params
->voice_psc_cap
== ENABLE_FOR_THIS_AC
||
2217 params
->voice_psc_cap
== ENABLE_FOR_ALL_AC
) &&
2218 (params
->tsid
== WMI_IMPLICIT_PSTREAM
||
2219 params
->tsid
<= WMI_MAX_THINSTREAM
))) {
2224 * Check nominal PHY rate is >= minimalPHY,
2225 * so that DUT can allow TSRS IE
2228 /* Get the physical rate (units of bps) */
2229 min_phy
= ((le32_to_cpu(params
->min_phy_rate
) / 1000) / 1000);
2231 /* Check minimal phy < nominal phy rate */
2232 if (params
->nominal_phy
>= min_phy
) {
2233 /* unit of 500 kbps */
2234 nominal_phy
= (params
->nominal_phy
* 1000) / 500;
2235 ath6kl_dbg(ATH6KL_DBG_WMI
,
2236 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2237 min_phy
, nominal_phy
);
2239 params
->nominal_phy
= nominal_phy
;
2241 params
->nominal_phy
= 0;
2244 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2248 ath6kl_dbg(ATH6KL_DBG_WMI
,
2249 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2250 params
->traffic_class
, params
->tsid
);
2252 cmd
= (struct wmi_create_pstream_cmd
*) skb
->data
;
2253 memcpy(cmd
, params
, sizeof(*cmd
));
2255 /* This is an implicitly created Fat pipe */
2256 if ((u32
) params
->tsid
== (u32
) WMI_IMPLICIT_PSTREAM
) {
2257 spin_lock_bh(&wmi
->lock
);
2258 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2259 (1 << params
->traffic_class
));
2260 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2261 spin_unlock_bh(&wmi
->lock
);
2263 /* explicitly created thin stream within a fat pipe */
2264 spin_lock_bh(&wmi
->lock
);
2265 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2266 (1 << params
->traffic_class
));
2267 wmi
->stream_exist_for_ac
[params
->traffic_class
] |=
2268 (1 << params
->tsid
);
2270 * If a thinstream becomes active, the fat pipe automatically
2273 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2274 spin_unlock_bh(&wmi
->lock
);
2278 * Indicate activty change to driver layer only if this is the
2279 * first TSID to get created in this AC explicitly or an implicit
2280 * fat pipe is getting created.
2282 if (!fatpipe_exist_for_ac
)
2283 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2284 params
->traffic_class
, true);
2286 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_CREATE_PSTREAM_CMDID
,
2291 int ath6kl_wmi_delete_pstream_cmd(struct wmi
*wmi
, u8 traffic_class
, u8 tsid
)
2293 struct sk_buff
*skb
;
2294 struct wmi_delete_pstream_cmd
*cmd
;
2295 u16 active_tsids
= 0;
2298 if (traffic_class
> 3) {
2299 ath6kl_err("invalid traffic class: %d\n", traffic_class
);
2303 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2307 cmd
= (struct wmi_delete_pstream_cmd
*) skb
->data
;
2308 cmd
->traffic_class
= traffic_class
;
2311 spin_lock_bh(&wmi
->lock
);
2312 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2313 spin_unlock_bh(&wmi
->lock
);
2315 if (!(active_tsids
& (1 << tsid
))) {
2317 ath6kl_dbg(ATH6KL_DBG_WMI
,
2318 "TSID %d doesn't exist for traffic class: %d\n",
2319 tsid
, traffic_class
);
2323 ath6kl_dbg(ATH6KL_DBG_WMI
,
2324 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2325 traffic_class
, tsid
);
2327 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DELETE_PSTREAM_CMDID
,
2328 SYNC_BEFORE_WMIFLAG
);
2330 spin_lock_bh(&wmi
->lock
);
2331 wmi
->stream_exist_for_ac
[traffic_class
] &= ~(1 << tsid
);
2332 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2333 spin_unlock_bh(&wmi
->lock
);
2336 * Indicate stream inactivity to driver layer only if all tsids
2337 * within this AC are deleted.
2339 if (!active_tsids
) {
2340 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2341 traffic_class
, false);
2342 wmi
->fat_pipe_exist
&= ~(1 << traffic_class
);
2348 int ath6kl_wmi_set_ip_cmd(struct wmi
*wmi
, struct wmi_set_ip_cmd
*ip_cmd
)
2350 struct sk_buff
*skb
;
2351 struct wmi_set_ip_cmd
*cmd
;
2354 /* Multicast address are not valid */
2355 if ((*((u8
*) &ip_cmd
->ips
[0]) >= 0xE0) ||
2356 (*((u8
*) &ip_cmd
->ips
[1]) >= 0xE0))
2359 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd
));
2363 cmd
= (struct wmi_set_ip_cmd
*) skb
->data
;
2364 memcpy(cmd
, ip_cmd
, sizeof(struct wmi_set_ip_cmd
));
2366 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_IP_CMDID
, NO_SYNC_WMIFLAG
);
2370 static int ath6kl_wmi_get_wow_list_event_rx(struct wmi
*wmi
, u8
* datap
,
2373 if (len
< sizeof(struct wmi_get_wow_list_reply
))
2379 static int ath6kl_wmi_cmd_send_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
,
2380 enum wmix_command_id cmd_id
,
2381 enum wmi_sync_flag sync_flag
)
2383 struct wmix_cmd_hdr
*cmd_hdr
;
2386 skb_push(skb
, sizeof(struct wmix_cmd_hdr
));
2388 cmd_hdr
= (struct wmix_cmd_hdr
*) skb
->data
;
2389 cmd_hdr
->cmd_id
= cpu_to_le32(cmd_id
);
2391 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_EXTENSION_CMDID
, sync_flag
);
2396 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi
*wmi
, u32 cookie
, u32 source
)
2398 struct sk_buff
*skb
;
2399 struct wmix_hb_challenge_resp_cmd
*cmd
;
2402 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2406 cmd
= (struct wmix_hb_challenge_resp_cmd
*) skb
->data
;
2407 cmd
->cookie
= cpu_to_le32(cookie
);
2408 cmd
->source
= cpu_to_le32(source
);
2410 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_HB_CHALLENGE_RESP_CMDID
,
2415 int ath6kl_wmi_config_debug_module_cmd(struct wmi
*wmi
, u32 valid
, u32 config
)
2417 struct ath6kl_wmix_dbglog_cfg_module_cmd
*cmd
;
2418 struct sk_buff
*skb
;
2421 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2425 cmd
= (struct ath6kl_wmix_dbglog_cfg_module_cmd
*) skb
->data
;
2426 cmd
->valid
= cpu_to_le32(valid
);
2427 cmd
->config
= cpu_to_le32(config
);
2429 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_DBGLOG_CFG_MODULE_CMDID
,
2434 int ath6kl_wmi_get_stats_cmd(struct wmi
*wmi
)
2436 return ath6kl_wmi_simple_cmd(wmi
, WMI_GET_STATISTICS_CMDID
);
2439 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi
*wmi
, u8 dbM
)
2441 struct sk_buff
*skb
;
2442 struct wmi_set_tx_pwr_cmd
*cmd
;
2445 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd
));
2449 cmd
= (struct wmi_set_tx_pwr_cmd
*) skb
->data
;
2452 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_TX_PWR_CMDID
,
2458 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi
*wmi
)
2460 return ath6kl_wmi_simple_cmd(wmi
, WMI_GET_TX_PWR_CMDID
);
2463 int ath6kl_wmi_set_lpreamble_cmd(struct wmi
*wmi
, u8 status
, u8 preamble_policy
)
2465 struct sk_buff
*skb
;
2466 struct wmi_set_lpreamble_cmd
*cmd
;
2469 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd
));
2473 cmd
= (struct wmi_set_lpreamble_cmd
*) skb
->data
;
2474 cmd
->status
= status
;
2475 cmd
->preamble_policy
= preamble_policy
;
2477 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_LPREAMBLE_CMDID
,
2482 int ath6kl_wmi_set_rts_cmd(struct wmi
*wmi
, u16 threshold
)
2484 struct sk_buff
*skb
;
2485 struct wmi_set_rts_cmd
*cmd
;
2488 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd
));
2492 cmd
= (struct wmi_set_rts_cmd
*) skb
->data
;
2493 cmd
->threshold
= cpu_to_le16(threshold
);
2495 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_RTS_CMDID
, NO_SYNC_WMIFLAG
);
2499 int ath6kl_wmi_set_wmm_txop(struct wmi
*wmi
, enum wmi_txop_cfg cfg
)
2501 struct sk_buff
*skb
;
2502 struct wmi_set_wmm_txop_cmd
*cmd
;
2505 if (!((cfg
== WMI_TXOP_DISABLED
) || (cfg
== WMI_TXOP_ENABLED
)))
2508 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd
));
2512 cmd
= (struct wmi_set_wmm_txop_cmd
*) skb
->data
;
2513 cmd
->txop_enable
= cfg
;
2515 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_WMM_TXOP_CMDID
,
2520 int ath6kl_wmi_set_keepalive_cmd(struct wmi
*wmi
, u8 keep_alive_intvl
)
2522 struct sk_buff
*skb
;
2523 struct wmi_set_keepalive_cmd
*cmd
;
2526 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2530 cmd
= (struct wmi_set_keepalive_cmd
*) skb
->data
;
2531 cmd
->keep_alive_intvl
= keep_alive_intvl
;
2532 wmi
->keep_alive_intvl
= keep_alive_intvl
;
2534 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_KEEPALIVE_CMDID
,
2539 int ath6kl_wmi_test_cmd(struct wmi
*wmi
, void *buf
, size_t len
)
2541 struct sk_buff
*skb
;
2544 skb
= ath6kl_wmi_get_new_buf(len
);
2548 memcpy(skb
->data
, buf
, len
);
2550 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_TEST_CMDID
, NO_SYNC_WMIFLAG
);
2556 s32
ath6kl_wmi_get_rate(s8 rate_index
)
2558 if (rate_index
== RATE_AUTO
)
2561 return wmi_rate_tbl
[(u32
) rate_index
][0];
2564 void ath6kl_wmi_node_return(struct wmi
*wmi
, struct bss
*bss
)
2567 wlan_node_return(&wmi
->parent_dev
->scan_table
, bss
);
2570 struct bss
*ath6kl_wmi_find_ssid_node(struct wmi
*wmi
, u8
* ssid
,
2571 u32 ssid_len
, bool is_wpa2
,
2574 struct bss
*node
= NULL
;
2576 node
= wlan_find_ssid_node(&wmi
->parent_dev
->scan_table
, ssid
,
2577 ssid_len
, is_wpa2
, match_ssid
);
2581 struct bss
*ath6kl_wmi_find_node(struct wmi
*wmi
, const u8
* mac_addr
)
2583 struct bss
*ni
= NULL
;
2585 ni
= wlan_find_node(&wmi
->parent_dev
->scan_table
, mac_addr
);
2590 void ath6kl_wmi_node_free(struct wmi
*wmi
, const u8
* mac_addr
)
2592 struct bss
*ni
= NULL
;
2594 ni
= wlan_find_node(&wmi
->parent_dev
->scan_table
, mac_addr
);
2596 wlan_node_reclaim(&wmi
->parent_dev
->scan_table
, ni
);
2601 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi
*wmi
, u8
*datap
,
2604 struct wmi_pmkid_list_reply
*reply
;
2607 if (len
< sizeof(struct wmi_pmkid_list_reply
))
2610 reply
= (struct wmi_pmkid_list_reply
*)datap
;
2611 expected_len
= sizeof(reply
->num_pmkid
) +
2612 le32_to_cpu(reply
->num_pmkid
) * WMI_PMKID_LEN
;
2614 if (len
< expected_len
)
2620 static int ath6kl_wmi_addba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2622 struct wmi_addba_req_event
*cmd
= (struct wmi_addba_req_event
*) datap
;
2624 aggr_recv_addba_req_evt(wmi
->parent_dev
, cmd
->tid
,
2625 le16_to_cpu(cmd
->st_seq_no
), cmd
->win_sz
);
2630 static int ath6kl_wmi_delba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2632 struct wmi_delba_event
*cmd
= (struct wmi_delba_event
*) datap
;
2634 aggr_recv_delba_req_evt(wmi
->parent_dev
, cmd
->tid
);
2639 /* AP mode functions */
2641 int ath6kl_wmi_ap_profile_commit(struct wmi
*wmip
, struct wmi_connect_cmd
*p
)
2643 struct sk_buff
*skb
;
2644 struct wmi_connect_cmd
*cm
;
2647 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
2651 cm
= (struct wmi_connect_cmd
*) skb
->data
;
2652 memcpy(cm
, p
, sizeof(*cm
));
2654 res
= ath6kl_wmi_cmd_send(wmip
, skb
, WMI_AP_CONFIG_COMMIT_CMDID
,
2656 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: nw_type=%u auth_mode=%u ch=%u "
2657 "ctrl_flags=0x%x-> res=%d\n",
2658 __func__
, p
->nw_type
, p
->auth_mode
, le16_to_cpu(p
->ch
),
2659 le32_to_cpu(p
->ctrl_flags
), res
);
2663 int ath6kl_wmi_ap_set_mlme(struct wmi
*wmip
, u8 cmd
, const u8
*mac
, u16 reason
)
2665 struct sk_buff
*skb
;
2666 struct wmi_ap_set_mlme_cmd
*cm
;
2668 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
2672 cm
= (struct wmi_ap_set_mlme_cmd
*) skb
->data
;
2673 memcpy(cm
->mac
, mac
, ETH_ALEN
);
2674 cm
->reason
= cpu_to_le16(reason
);
2677 return ath6kl_wmi_cmd_send(wmip
, skb
, WMI_AP_SET_MLME_CMDID
,
2681 static int ath6kl_wmi_pspoll_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2683 struct wmi_pspoll_event
*ev
;
2685 if (len
< sizeof(struct wmi_pspoll_event
))
2688 ev
= (struct wmi_pspoll_event
*) datap
;
2690 ath6kl_pspoll_event(wmi
->parent_dev
, le16_to_cpu(ev
->aid
));
2695 static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2697 ath6kl_dtimexpiry_event(wmi
->parent_dev
);
2702 int ath6kl_wmi_set_pvb_cmd(struct wmi
*wmi
, u16 aid
, bool flag
)
2704 struct sk_buff
*skb
;
2705 struct wmi_ap_set_pvb_cmd
*cmd
;
2708 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd
));
2712 cmd
= (struct wmi_ap_set_pvb_cmd
*) skb
->data
;
2713 cmd
->aid
= cpu_to_le16(aid
);
2714 cmd
->flag
= cpu_to_le32(flag
);
2716 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_AP_SET_PVB_CMDID
,
2722 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi
*wmi
, u8 rx_meta_ver
,
2723 bool rx_dot11_hdr
, bool defrag_on_host
)
2725 struct sk_buff
*skb
;
2726 struct wmi_rx_frame_format_cmd
*cmd
;
2729 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2733 cmd
= (struct wmi_rx_frame_format_cmd
*) skb
->data
;
2734 cmd
->dot11_hdr
= rx_dot11_hdr
? 1 : 0;
2735 cmd
->defrag_on_host
= defrag_on_host
? 1 : 0;
2736 cmd
->meta_ver
= rx_meta_ver
;
2738 /* Delete the local aggr state, on host */
2739 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RX_FRAME_FORMAT_CMDID
,
2745 int ath6kl_wmi_set_appie_cmd(struct wmi
*wmi
, u8 mgmt_frm_type
, const u8
*ie
,
2748 struct sk_buff
*skb
;
2749 struct wmi_set_appie_cmd
*p
;
2751 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + ie_len
);
2755 ath6kl_dbg(ATH6KL_DBG_WMI
, "set_appie_cmd: mgmt_frm_type=%u "
2756 "ie_len=%u\n", mgmt_frm_type
, ie_len
);
2757 p
= (struct wmi_set_appie_cmd
*) skb
->data
;
2758 p
->mgmt_frm_type
= mgmt_frm_type
;
2760 memcpy(p
->ie_info
, ie
, ie_len
);
2761 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_APPIE_CMDID
,
2765 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi
*wmi
, bool disable
)
2767 struct sk_buff
*skb
;
2768 struct wmi_disable_11b_rates_cmd
*cmd
;
2770 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2774 ath6kl_dbg(ATH6KL_DBG_WMI
, "disable_11b_rates_cmd: disable=%u\n",
2776 cmd
= (struct wmi_disable_11b_rates_cmd
*) skb
->data
;
2777 cmd
->disable
= disable
? 1 : 0;
2779 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DISABLE_11B_RATES_CMDID
,
2783 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi
*wmi
, u32 freq
, u32 dur
)
2785 struct sk_buff
*skb
;
2786 struct wmi_remain_on_chnl_cmd
*p
;
2788 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2792 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl_cmd: freq=%u dur=%u\n",
2794 p
= (struct wmi_remain_on_chnl_cmd
*) skb
->data
;
2795 p
->freq
= cpu_to_le32(freq
);
2796 p
->duration
= cpu_to_le32(dur
);
2797 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_REMAIN_ON_CHNL_CMDID
,
2801 int ath6kl_wmi_send_action_cmd(struct wmi
*wmi
, u32 id
, u32 freq
, u32 wait
,
2802 const u8
*data
, u16 data_len
)
2804 struct sk_buff
*skb
;
2805 struct wmi_send_action_cmd
*p
;
2809 return -EINVAL
; /* Offload for wait not supported */
2811 buf
= kmalloc(data_len
, GFP_KERNEL
);
2815 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
2821 kfree(wmi
->last_mgmt_tx_frame
);
2822 wmi
->last_mgmt_tx_frame
= buf
;
2823 wmi
->last_mgmt_tx_frame_len
= data_len
;
2825 ath6kl_dbg(ATH6KL_DBG_WMI
, "send_action_cmd: id=%u freq=%u wait=%u "
2826 "len=%u\n", id
, freq
, wait
, data_len
);
2827 p
= (struct wmi_send_action_cmd
*) skb
->data
;
2828 p
->id
= cpu_to_le32(id
);
2829 p
->freq
= cpu_to_le32(freq
);
2830 p
->wait
= cpu_to_le32(wait
);
2831 p
->len
= cpu_to_le16(data_len
);
2832 memcpy(p
->data
, data
, data_len
);
2833 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SEND_ACTION_CMDID
,
2837 int ath6kl_wmi_send_probe_response_cmd(struct wmi
*wmi
, u32 freq
,
2839 const u8
*data
, u16 data_len
)
2841 struct sk_buff
*skb
;
2842 struct wmi_p2p_probe_response_cmd
*p
;
2844 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
2848 ath6kl_dbg(ATH6KL_DBG_WMI
, "send_probe_response_cmd: freq=%u dst=%pM "
2849 "len=%u\n", freq
, dst
, data_len
);
2850 p
= (struct wmi_p2p_probe_response_cmd
*) skb
->data
;
2851 p
->freq
= cpu_to_le32(freq
);
2852 memcpy(p
->destination_addr
, dst
, ETH_ALEN
);
2853 p
->len
= cpu_to_le16(data_len
);
2854 memcpy(p
->data
, data
, data_len
);
2855 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SEND_PROBE_RESPONSE_CMDID
,
2859 int ath6kl_wmi_probe_report_req_cmd(struct wmi
*wmi
, bool enable
)
2861 struct sk_buff
*skb
;
2862 struct wmi_probe_req_report_cmd
*p
;
2864 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2868 ath6kl_dbg(ATH6KL_DBG_WMI
, "probe_report_req_cmd: enable=%u\n",
2870 p
= (struct wmi_probe_req_report_cmd
*) skb
->data
;
2871 p
->enable
= enable
? 1 : 0;
2872 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_PROBE_REQ_REPORT_CMDID
,
2876 int ath6kl_wmi_info_req_cmd(struct wmi
*wmi
, u32 info_req_flags
)
2878 struct sk_buff
*skb
;
2879 struct wmi_get_p2p_info
*p
;
2881 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2885 ath6kl_dbg(ATH6KL_DBG_WMI
, "info_req_cmd: flags=%x\n",
2887 p
= (struct wmi_get_p2p_info
*) skb
->data
;
2888 p
->info_req_flags
= cpu_to_le32(info_req_flags
);
2889 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_GET_P2P_INFO_CMDID
,
2893 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi
*wmi
)
2895 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl_cmd\n");
2896 return ath6kl_wmi_simple_cmd(wmi
, WMI_CANCEL_REMAIN_ON_CHNL_CMDID
);
2899 static int ath6kl_wmi_control_rx_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
)
2901 struct wmix_cmd_hdr
*cmd
;
2907 if (skb
->len
< sizeof(struct wmix_cmd_hdr
)) {
2908 ath6kl_err("bad packet 1\n");
2909 wmi
->stat
.cmd_len_err
++;
2913 cmd
= (struct wmix_cmd_hdr
*) skb
->data
;
2914 id
= le32_to_cpu(cmd
->cmd_id
);
2916 skb_pull(skb
, sizeof(struct wmix_cmd_hdr
));
2922 case WMIX_HB_CHALLENGE_RESP_EVENTID
:
2924 case WMIX_DBGLOG_EVENTID
:
2925 ath6kl_debug_fwlog_event(wmi
->parent_dev
, datap
, len
);
2928 ath6kl_err("unknown cmd id 0x%x\n", id
);
2929 wmi
->stat
.cmd_id_err
++;
2938 int ath6kl_wmi_control_rx(struct wmi
*wmi
, struct sk_buff
*skb
)
2940 struct wmi_cmd_hdr
*cmd
;
2946 if (WARN_ON(skb
== NULL
))
2949 if (skb
->len
< sizeof(struct wmi_cmd_hdr
)) {
2950 ath6kl_err("bad packet 1\n");
2952 wmi
->stat
.cmd_len_err
++;
2956 cmd
= (struct wmi_cmd_hdr
*) skb
->data
;
2957 id
= le16_to_cpu(cmd
->cmd_id
);
2959 skb_pull(skb
, sizeof(struct wmi_cmd_hdr
));
2964 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: wmi id: %d\n", __func__
, id
);
2965 ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES
, "msg payload ", datap
, len
);
2968 case WMI_GET_BITRATE_CMDID
:
2969 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_BITRATE_CMDID\n");
2970 ret
= ath6kl_wmi_bitrate_reply_rx(wmi
, datap
, len
);
2972 case WMI_GET_CHANNEL_LIST_CMDID
:
2973 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_CHANNEL_LIST_CMDID\n");
2974 ret
= ath6kl_wmi_ch_list_reply_rx(wmi
, datap
, len
);
2976 case WMI_GET_TX_PWR_CMDID
:
2977 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_TX_PWR_CMDID\n");
2978 ret
= ath6kl_wmi_tx_pwr_reply_rx(wmi
, datap
, len
);
2980 case WMI_READY_EVENTID
:
2981 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_READY_EVENTID\n");
2982 ret
= ath6kl_wmi_ready_event_rx(wmi
, datap
, len
);
2984 case WMI_CONNECT_EVENTID
:
2985 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CONNECT_EVENTID\n");
2986 ret
= ath6kl_wmi_connect_event_rx(wmi
, datap
, len
);
2988 case WMI_DISCONNECT_EVENTID
:
2989 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DISCONNECT_EVENTID\n");
2990 ret
= ath6kl_wmi_disconnect_event_rx(wmi
, datap
, len
);
2992 case WMI_PEER_NODE_EVENTID
:
2993 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PEER_NODE_EVENTID\n");
2994 ret
= ath6kl_wmi_peer_node_event_rx(wmi
, datap
, len
);
2996 case WMI_TKIP_MICERR_EVENTID
:
2997 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TKIP_MICERR_EVENTID\n");
2998 ret
= ath6kl_wmi_tkip_micerr_event_rx(wmi
, datap
, len
);
3000 case WMI_BSSINFO_EVENTID
:
3001 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_BSSINFO_EVENTID\n");
3002 ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb
, datap
);
3003 ret
= ath6kl_wmi_bssinfo_event_rx(wmi
, skb
->data
, skb
->len
);
3005 case WMI_REGDOMAIN_EVENTID
:
3006 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REGDOMAIN_EVENTID\n");
3008 case WMI_PSTREAM_TIMEOUT_EVENTID
:
3009 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
3010 ret
= ath6kl_wmi_pstream_timeout_event_rx(wmi
, datap
, len
);
3012 case WMI_NEIGHBOR_REPORT_EVENTID
:
3013 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_NEIGHBOR_REPORT_EVENTID\n");
3015 case WMI_SCAN_COMPLETE_EVENTID
:
3016 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SCAN_COMPLETE_EVENTID\n");
3017 ret
= ath6kl_wmi_scan_complete_rx(wmi
, datap
, len
);
3019 case WMI_CMDERROR_EVENTID
:
3020 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CMDERROR_EVENTID\n");
3021 ret
= ath6kl_wmi_error_event_rx(wmi
, datap
, len
);
3023 case WMI_REPORT_STATISTICS_EVENTID
:
3024 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_STATISTICS_EVENTID\n");
3025 ret
= ath6kl_wmi_stats_event_rx(wmi
, datap
, len
);
3027 case WMI_RSSI_THRESHOLD_EVENTID
:
3028 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RSSI_THRESHOLD_EVENTID\n");
3029 ret
= ath6kl_wmi_rssi_threshold_event_rx(wmi
, datap
, len
);
3031 case WMI_ERROR_REPORT_EVENTID
:
3032 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ERROR_REPORT_EVENTID\n");
3034 case WMI_OPT_RX_FRAME_EVENTID
:
3035 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_OPT_RX_FRAME_EVENTID\n");
3036 ret
= ath6kl_wmi_opt_frame_event_rx(wmi
, datap
, len
);
3038 case WMI_REPORT_ROAM_TBL_EVENTID
:
3039 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_TBL_EVENTID\n");
3041 case WMI_EXTENSION_EVENTID
:
3042 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_EXTENSION_EVENTID\n");
3043 ret
= ath6kl_wmi_control_rx_xtnd(wmi
, skb
);
3045 case WMI_CAC_EVENTID
:
3046 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CAC_EVENTID\n");
3047 ret
= ath6kl_wmi_cac_event_rx(wmi
, datap
, len
);
3049 case WMI_CHANNEL_CHANGE_EVENTID
:
3050 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CHANNEL_CHANGE_EVENTID\n");
3052 case WMI_REPORT_ROAM_DATA_EVENTID
:
3053 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_DATA_EVENTID\n");
3055 case WMI_TEST_EVENTID
:
3056 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TEST_EVENTID\n");
3057 ret
= ath6kl_wmi_tcmd_test_report_rx(wmi
, datap
, len
);
3059 case WMI_GET_FIXRATES_CMDID
:
3060 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_FIXRATES_CMDID\n");
3061 ret
= ath6kl_wmi_ratemask_reply_rx(wmi
, datap
, len
);
3063 case WMI_TX_RETRY_ERR_EVENTID
:
3064 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_RETRY_ERR_EVENTID\n");
3066 case WMI_SNR_THRESHOLD_EVENTID
:
3067 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SNR_THRESHOLD_EVENTID\n");
3068 ret
= ath6kl_wmi_snr_threshold_event_rx(wmi
, datap
, len
);
3070 case WMI_LQ_THRESHOLD_EVENTID
:
3071 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_LQ_THRESHOLD_EVENTID\n");
3073 case WMI_APLIST_EVENTID
:
3074 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_APLIST_EVENTID\n");
3075 ret
= ath6kl_wmi_aplist_event_rx(wmi
, datap
, len
);
3077 case WMI_GET_KEEPALIVE_CMDID
:
3078 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_KEEPALIVE_CMDID\n");
3079 ret
= ath6kl_wmi_keepalive_reply_rx(wmi
, datap
, len
);
3081 case WMI_GET_WOW_LIST_EVENTID
:
3082 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_WOW_LIST_EVENTID\n");
3083 ret
= ath6kl_wmi_get_wow_list_event_rx(wmi
, datap
, len
);
3085 case WMI_GET_PMKID_LIST_EVENTID
:
3086 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_PMKID_LIST_EVENTID\n");
3087 ret
= ath6kl_wmi_get_pmkid_list_event_rx(wmi
, datap
, len
);
3089 case WMI_PSPOLL_EVENTID
:
3090 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSPOLL_EVENTID\n");
3091 ret
= ath6kl_wmi_pspoll_event_rx(wmi
, datap
, len
);
3093 case WMI_DTIMEXPIRY_EVENTID
:
3094 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DTIMEXPIRY_EVENTID\n");
3095 ret
= ath6kl_wmi_dtimexpiry_event_rx(wmi
, datap
, len
);
3097 case WMI_SET_PARAMS_REPLY_EVENTID
:
3098 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SET_PARAMS_REPLY_EVENTID\n");
3100 case WMI_ADDBA_REQ_EVENTID
:
3101 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_REQ_EVENTID\n");
3102 ret
= ath6kl_wmi_addba_req_event_rx(wmi
, datap
, len
);
3104 case WMI_ADDBA_RESP_EVENTID
:
3105 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_RESP_EVENTID\n");
3107 case WMI_DELBA_REQ_EVENTID
:
3108 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DELBA_REQ_EVENTID\n");
3109 ret
= ath6kl_wmi_delba_req_event_rx(wmi
, datap
, len
);
3111 case WMI_REPORT_BTCOEX_CONFIG_EVENTID
:
3112 ath6kl_dbg(ATH6KL_DBG_WMI
,
3113 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
3115 case WMI_REPORT_BTCOEX_STATS_EVENTID
:
3116 ath6kl_dbg(ATH6KL_DBG_WMI
,
3117 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
3119 case WMI_TX_COMPLETE_EVENTID
:
3120 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_COMPLETE_EVENTID\n");
3121 ret
= ath6kl_wmi_tx_complete_event_rx(datap
, len
);
3123 case WMI_REMAIN_ON_CHNL_EVENTID
:
3124 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REMAIN_ON_CHNL_EVENTID\n");
3125 ret
= ath6kl_wmi_remain_on_chnl_event_rx(wmi
, datap
, len
);
3127 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID
:
3128 ath6kl_dbg(ATH6KL_DBG_WMI
,
3129 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
3130 ret
= ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi
, datap
,
3133 case WMI_TX_STATUS_EVENTID
:
3134 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_STATUS_EVENTID\n");
3135 ret
= ath6kl_wmi_tx_status_event_rx(wmi
, datap
, len
);
3137 case WMI_RX_PROBE_REQ_EVENTID
:
3138 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_PROBE_REQ_EVENTID\n");
3139 ret
= ath6kl_wmi_rx_probe_req_event_rx(wmi
, datap
, len
);
3141 case WMI_P2P_CAPABILITIES_EVENTID
:
3142 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_CAPABILITIES_EVENTID\n");
3143 ret
= ath6kl_wmi_p2p_capabilities_event_rx(datap
, len
);
3145 case WMI_RX_ACTION_EVENTID
:
3146 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_ACTION_EVENTID\n");
3147 ret
= ath6kl_wmi_rx_action_event_rx(wmi
, datap
, len
);
3149 case WMI_P2P_INFO_EVENTID
:
3150 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_INFO_EVENTID\n");
3151 ret
= ath6kl_wmi_p2p_info_event_rx(datap
, len
);
3154 ath6kl_dbg(ATH6KL_DBG_WMI
, "unknown cmd id 0x%x\n", id
);
3155 wmi
->stat
.cmd_id_err
++;
3165 static void ath6kl_wmi_qos_state_init(struct wmi
*wmi
)
3170 spin_lock_bh(&wmi
->lock
);
3172 wmi
->fat_pipe_exist
= 0;
3173 memset(wmi
->stream_exist_for_ac
, 0, sizeof(wmi
->stream_exist_for_ac
));
3175 spin_unlock_bh(&wmi
->lock
);
3178 void *ath6kl_wmi_init(struct ath6kl
*dev
)
3182 wmi
= kzalloc(sizeof(struct wmi
), GFP_KERNEL
);
3186 spin_lock_init(&wmi
->lock
);
3188 wmi
->parent_dev
= dev
;
3190 ath6kl_wmi_qos_state_init(wmi
);
3192 wmi
->pwr_mode
= REC_POWER
;
3193 wmi
->phy_mode
= WMI_11G_MODE
;
3195 wmi
->pair_crypto_type
= NONE_CRYPT
;
3196 wmi
->grp_crypto_type
= NONE_CRYPT
;
3198 wmi
->ht_allowed
[A_BAND_24GHZ
] = 1;
3199 wmi
->ht_allowed
[A_BAND_5GHZ
] = 1;
3204 void ath6kl_wmi_shutdown(struct wmi
*wmi
)
3209 kfree(wmi
->last_mgmt_tx_frame
);