2 * Copyright (c) 2004-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
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.
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.
25 #include "../regd_common.h"
27 static int ath6kl_wmi_sync_point(struct wmi
*wmi
, u8 if_idx
);
29 static const s32 wmi_rate_tbl
[][2] = {
30 /* {W/O SGI, with SGI} */
62 static const s32 wmi_rate_tbl_mcs15
[][2] = {
63 /* {W/O SGI, with SGI} */
76 {6500, 7200}, /* HT 20, MCS 0 */
84 {13000, 14400}, /* HT 20, MCS 8 */
91 {130000, 144400}, /* HT 20, MCS 15 */
92 {13500, 15000}, /*HT 40, MCS 0 */
100 {27000, 30000}, /*HT 40, MCS 8 */
107 {270000, 300000}, /*HT 40, MCS 15 */
111 /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
112 static const u8 up_to_ac
[] = {
123 void ath6kl_wmi_set_control_ep(struct wmi
*wmi
, enum htc_endpoint_id ep_id
)
125 if (WARN_ON(ep_id
== ENDPOINT_UNUSED
|| ep_id
>= ENDPOINT_MAX
))
131 enum htc_endpoint_id
ath6kl_wmi_get_control_ep(struct wmi
*wmi
)
136 struct ath6kl_vif
*ath6kl_get_vif_by_index(struct ath6kl
*ar
, u8 if_idx
)
138 struct ath6kl_vif
*vif
, *found
= NULL
;
140 if (WARN_ON(if_idx
> (ar
->vif_max
- 1)))
144 spin_lock_bh(&ar
->list_lock
);
145 list_for_each_entry(vif
, &ar
->vif_list
, list
) {
146 if (vif
->fw_vif_idx
== if_idx
) {
151 spin_unlock_bh(&ar
->list_lock
);
156 /* Performs DIX to 802.3 encapsulation for transmit packets.
157 * Assumes the entire DIX header is contiguous and that there is
158 * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers.
160 int ath6kl_wmi_dix_2_dot3(struct wmi
*wmi
, struct sk_buff
*skb
)
162 struct ath6kl_llc_snap_hdr
*llc_hdr
;
163 struct ethhdr
*eth_hdr
;
169 if (WARN_ON(skb
== NULL
))
172 size
= sizeof(struct ath6kl_llc_snap_hdr
) + sizeof(struct wmi_data_hdr
);
173 if (skb_headroom(skb
) < size
)
176 eth_hdr
= (struct ethhdr
*) skb
->data
;
177 type
= eth_hdr
->h_proto
;
179 if (!is_ethertype(be16_to_cpu(type
))) {
180 ath6kl_dbg(ATH6KL_DBG_WMI
,
181 "%s: pkt is already in 802.3 format\n", __func__
);
185 new_len
= skb
->len
- sizeof(*eth_hdr
) + sizeof(*llc_hdr
);
187 skb_push(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
190 eth_hdr
->h_proto
= cpu_to_be16(new_len
);
192 memcpy(datap
, eth_hdr
, sizeof(*eth_hdr
));
194 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
+ sizeof(*eth_hdr
));
195 llc_hdr
->dsap
= 0xAA;
196 llc_hdr
->ssap
= 0xAA;
197 llc_hdr
->cntl
= 0x03;
198 llc_hdr
->org_code
[0] = 0x0;
199 llc_hdr
->org_code
[1] = 0x0;
200 llc_hdr
->org_code
[2] = 0x0;
201 llc_hdr
->eth_type
= type
;
206 static int ath6kl_wmi_meta_add(struct wmi
*wmi
, struct sk_buff
*skb
,
207 u8
*version
, void *tx_meta_info
)
209 struct wmi_tx_meta_v1
*v1
;
210 struct wmi_tx_meta_v2
*v2
;
212 if (WARN_ON(skb
== NULL
|| version
== NULL
))
216 case WMI_META_VERSION_1
:
217 skb_push(skb
, WMI_MAX_TX_META_SZ
);
218 v1
= (struct wmi_tx_meta_v1
*) skb
->data
;
220 v1
->rate_plcy_id
= 0;
221 *version
= WMI_META_VERSION_1
;
223 case WMI_META_VERSION_2
:
224 skb_push(skb
, WMI_MAX_TX_META_SZ
);
225 v2
= (struct wmi_tx_meta_v2
*) skb
->data
;
226 memcpy(v2
, (struct wmi_tx_meta_v2
*) tx_meta_info
,
227 sizeof(struct wmi_tx_meta_v2
));
234 int ath6kl_wmi_data_hdr_add(struct wmi
*wmi
, struct sk_buff
*skb
,
235 u8 msg_type
, u32 flags
,
236 enum wmi_data_hdr_data_type data_type
,
237 u8 meta_ver
, void *tx_meta_info
, u8 if_idx
)
239 struct wmi_data_hdr
*data_hdr
;
242 if (WARN_ON(skb
== NULL
|| (if_idx
> wmi
->parent_dev
->vif_max
- 1)))
246 ret
= ath6kl_wmi_meta_add(wmi
, skb
, &meta_ver
, tx_meta_info
);
251 skb_push(skb
, sizeof(struct wmi_data_hdr
));
253 data_hdr
= (struct wmi_data_hdr
*)skb
->data
;
254 memset(data_hdr
, 0, sizeof(struct wmi_data_hdr
));
256 data_hdr
->info
= msg_type
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
257 data_hdr
->info
|= data_type
<< WMI_DATA_HDR_DATA_TYPE_SHIFT
;
259 if (flags
& WMI_DATA_HDR_FLAGS_MORE
)
260 data_hdr
->info
|= WMI_DATA_HDR_MORE
;
262 if (flags
& WMI_DATA_HDR_FLAGS_EOSP
)
263 data_hdr
->info3
|= cpu_to_le16(WMI_DATA_HDR_EOSP
);
265 data_hdr
->info2
|= cpu_to_le16(meta_ver
<< WMI_DATA_HDR_META_SHIFT
);
266 data_hdr
->info3
|= cpu_to_le16(if_idx
& WMI_DATA_HDR_IF_IDX_MASK
);
271 u8
ath6kl_wmi_determine_user_priority(u8
*pkt
, u32 layer2_pri
)
273 struct iphdr
*ip_hdr
= (struct iphdr
*) pkt
;
277 * Determine IPTOS priority
280 * : DSCP(6-bits) ECN(2-bits)
281 * : DSCP - P2 P1 P0 X X X
282 * where (P2 P1 P0) form 802.1D
284 ip_pri
= ip_hdr
->tos
>> 5;
287 if ((layer2_pri
& 0x7) > ip_pri
)
288 return (u8
) layer2_pri
& 0x7;
293 u8
ath6kl_wmi_get_traffic_class(u8 user_priority
)
295 return up_to_ac
[user_priority
& 0x7];
298 int ath6kl_wmi_implicit_create_pstream(struct wmi
*wmi
, u8 if_idx
,
300 u32 layer2_priority
, bool wmm_enabled
,
303 struct wmi_data_hdr
*data_hdr
;
304 struct ath6kl_llc_snap_hdr
*llc_hdr
;
305 struct wmi_create_pstream_cmd cmd
;
306 u32 meta_size
, hdr_size
;
307 u16 ip_type
= IP_ETHERTYPE
;
308 u8 stream_exist
, usr_pri
;
309 u8 traffic_class
= WMM_AC_BE
;
312 if (WARN_ON(skb
== NULL
))
316 data_hdr
= (struct wmi_data_hdr
*) datap
;
318 meta_size
= ((le16_to_cpu(data_hdr
->info2
) >> WMI_DATA_HDR_META_SHIFT
) &
319 WMI_DATA_HDR_META_MASK
) ? WMI_MAX_TX_META_SZ
: 0;
322 /* If WMM is disabled all traffic goes as BE traffic */
325 hdr_size
= sizeof(struct ethhdr
);
327 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
+
330 meta_size
+ hdr_size
);
332 if (llc_hdr
->eth_type
== htons(ip_type
)) {
334 * Extract the endpoint info from the TOS field
338 ath6kl_wmi_determine_user_priority(((u8
*) llc_hdr
) +
339 sizeof(struct ath6kl_llc_snap_hdr
),
342 usr_pri
= layer2_priority
& 0x7;
346 * Queue the EAPOL frames in the same WMM_AC_VO queue
347 * as that of management frames.
349 if (skb
->protocol
== cpu_to_be16(ETH_P_PAE
))
350 usr_pri
= WMI_VOICE_USER_PRIORITY
;
354 * workaround for WMM S5
356 * FIXME: wmi->traffic_class is always 100 so this test doesn't
359 if ((wmi
->traffic_class
== WMM_AC_VI
) &&
360 ((usr_pri
== 5) || (usr_pri
== 4)))
363 /* Convert user priority to traffic class */
364 traffic_class
= up_to_ac
[usr_pri
& 0x7];
366 wmi_data_hdr_set_up(data_hdr
, usr_pri
);
368 spin_lock_bh(&wmi
->lock
);
369 stream_exist
= wmi
->fat_pipe_exist
;
370 spin_unlock_bh(&wmi
->lock
);
372 if (!(stream_exist
& (1 << traffic_class
))) {
373 memset(&cmd
, 0, sizeof(cmd
));
374 cmd
.traffic_class
= traffic_class
;
375 cmd
.user_pri
= usr_pri
;
377 cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT
);
378 /* Implicit streams are created with TSID 0xFF */
379 cmd
.tsid
= WMI_IMPLICIT_PSTREAM
;
380 ath6kl_wmi_create_pstream_cmd(wmi
, if_idx
, &cmd
);
388 int ath6kl_wmi_dot11_hdr_remove(struct wmi
*wmi
, struct sk_buff
*skb
)
390 struct ieee80211_hdr_3addr
*pwh
, wh
;
391 struct ath6kl_llc_snap_hdr
*llc_hdr
;
392 struct ethhdr eth_hdr
;
397 if (WARN_ON(skb
== NULL
))
401 pwh
= (struct ieee80211_hdr_3addr
*) datap
;
403 sub_type
= pwh
->frame_control
& cpu_to_le16(IEEE80211_FCTL_STYPE
);
405 memcpy((u8
*) &wh
, datap
, sizeof(struct ieee80211_hdr_3addr
));
407 /* Strip off the 802.11 header */
408 if (sub_type
== cpu_to_le16(IEEE80211_STYPE_QOS_DATA
)) {
409 hdr_size
= roundup(sizeof(struct ieee80211_qos_hdr
),
411 skb_pull(skb
, hdr_size
);
412 } else if (sub_type
== cpu_to_le16(IEEE80211_STYPE_DATA
)) {
413 skb_pull(skb
, sizeof(struct ieee80211_hdr_3addr
));
417 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
);
419 memset(ð_hdr
, 0, sizeof(eth_hdr
));
420 eth_hdr
.h_proto
= llc_hdr
->eth_type
;
422 switch ((le16_to_cpu(wh
.frame_control
)) &
423 (IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
)) {
424 case IEEE80211_FCTL_TODS
:
425 memcpy(eth_hdr
.h_dest
, wh
.addr3
, ETH_ALEN
);
426 memcpy(eth_hdr
.h_source
, wh
.addr2
, ETH_ALEN
);
428 case IEEE80211_FCTL_FROMDS
:
429 memcpy(eth_hdr
.h_dest
, wh
.addr1
, ETH_ALEN
);
430 memcpy(eth_hdr
.h_source
, wh
.addr3
, ETH_ALEN
);
432 case IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
:
435 memcpy(eth_hdr
.h_dest
, wh
.addr1
, ETH_ALEN
);
436 memcpy(eth_hdr
.h_source
, wh
.addr2
, ETH_ALEN
);
440 skb_pull(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
441 skb_push(skb
, sizeof(eth_hdr
));
445 memcpy(datap
, ð_hdr
, sizeof(eth_hdr
));
451 * Performs 802.3 to DIX encapsulation for received packets.
452 * Assumes the entire 802.3 header is contiguous.
454 int ath6kl_wmi_dot3_2_dix(struct sk_buff
*skb
)
456 struct ath6kl_llc_snap_hdr
*llc_hdr
;
457 struct ethhdr eth_hdr
;
460 if (WARN_ON(skb
== NULL
))
465 memcpy(ð_hdr
, datap
, sizeof(eth_hdr
));
467 llc_hdr
= (struct ath6kl_llc_snap_hdr
*) (datap
+ sizeof(eth_hdr
));
468 eth_hdr
.h_proto
= llc_hdr
->eth_type
;
470 skb_pull(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
473 memcpy(datap
, ð_hdr
, sizeof(eth_hdr
));
478 static int ath6kl_wmi_tx_complete_event_rx(u8
*datap
, int len
)
480 struct tx_complete_msg_v1
*msg_v1
;
481 struct wmi_tx_complete_event
*evt
;
485 evt
= (struct wmi_tx_complete_event
*) datap
;
487 ath6kl_dbg(ATH6KL_DBG_WMI
, "comp: %d %d %d\n",
488 evt
->num_msg
, evt
->msg_len
, evt
->msg_type
);
490 for (index
= 0; index
< evt
->num_msg
; index
++) {
491 size
= sizeof(struct wmi_tx_complete_event
) +
492 (index
* sizeof(struct tx_complete_msg_v1
));
493 msg_v1
= (struct tx_complete_msg_v1
*)(datap
+ size
);
495 ath6kl_dbg(ATH6KL_DBG_WMI
, "msg: %d %d %d %d\n",
496 msg_v1
->status
, msg_v1
->pkt_id
,
497 msg_v1
->rate_idx
, msg_v1
->ack_failures
);
503 static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi
*wmi
, u8
*datap
,
504 int len
, struct ath6kl_vif
*vif
)
506 struct wmi_remain_on_chnl_event
*ev
;
509 struct ieee80211_channel
*chan
;
510 struct ath6kl
*ar
= wmi
->parent_dev
;
513 if (len
< sizeof(*ev
))
516 ev
= (struct wmi_remain_on_chnl_event
*) datap
;
517 freq
= le32_to_cpu(ev
->freq
);
518 dur
= le32_to_cpu(ev
->duration
);
519 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl: freq=%u dur=%u\n",
521 chan
= ieee80211_get_channel(ar
->wiphy
, freq
);
523 ath6kl_dbg(ATH6KL_DBG_WMI
,
524 "remain_on_chnl: Unknown channel (freq=%u)\n",
528 id
= vif
->last_roc_id
;
529 cfg80211_ready_on_channel(&vif
->wdev
, id
, chan
,
535 static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi
*wmi
,
537 struct ath6kl_vif
*vif
)
539 struct wmi_cancel_remain_on_chnl_event
*ev
;
542 struct ieee80211_channel
*chan
;
543 struct ath6kl
*ar
= wmi
->parent_dev
;
546 if (len
< sizeof(*ev
))
549 ev
= (struct wmi_cancel_remain_on_chnl_event
*) datap
;
550 freq
= le32_to_cpu(ev
->freq
);
551 dur
= le32_to_cpu(ev
->duration
);
552 ath6kl_dbg(ATH6KL_DBG_WMI
,
553 "cancel_remain_on_chnl: freq=%u dur=%u status=%u\n",
554 freq
, dur
, ev
->status
);
555 chan
= ieee80211_get_channel(ar
->wiphy
, freq
);
557 ath6kl_dbg(ATH6KL_DBG_WMI
,
558 "cancel_remain_on_chnl: Unknown channel (freq=%u)\n",
562 if (vif
->last_cancel_roc_id
&&
563 vif
->last_cancel_roc_id
+ 1 == vif
->last_roc_id
)
564 id
= vif
->last_cancel_roc_id
; /* event for cancel command */
566 id
= vif
->last_roc_id
; /* timeout on uncanceled r-o-c */
567 vif
->last_cancel_roc_id
= 0;
568 cfg80211_remain_on_channel_expired(&vif
->wdev
, id
, chan
, GFP_ATOMIC
);
573 static int ath6kl_wmi_tx_status_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
574 struct ath6kl_vif
*vif
)
576 struct wmi_tx_status_event
*ev
;
579 if (len
< sizeof(*ev
))
582 ev
= (struct wmi_tx_status_event
*) datap
;
583 id
= le32_to_cpu(ev
->id
);
584 ath6kl_dbg(ATH6KL_DBG_WMI
, "tx_status: id=%x ack_status=%u\n",
586 if (wmi
->last_mgmt_tx_frame
) {
587 cfg80211_mgmt_tx_status(&vif
->wdev
, id
,
588 wmi
->last_mgmt_tx_frame
,
589 wmi
->last_mgmt_tx_frame_len
,
590 !!ev
->ack_status
, GFP_ATOMIC
);
591 kfree(wmi
->last_mgmt_tx_frame
);
592 wmi
->last_mgmt_tx_frame
= NULL
;
593 wmi
->last_mgmt_tx_frame_len
= 0;
599 static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
600 struct ath6kl_vif
*vif
)
602 struct wmi_p2p_rx_probe_req_event
*ev
;
606 if (len
< sizeof(*ev
))
609 ev
= (struct wmi_p2p_rx_probe_req_event
*) datap
;
610 freq
= le32_to_cpu(ev
->freq
);
611 dlen
= le16_to_cpu(ev
->len
);
612 if (datap
+ len
< ev
->data
+ dlen
) {
613 ath6kl_err("invalid wmi_p2p_rx_probe_req_event: len=%d dlen=%u\n",
617 ath6kl_dbg(ATH6KL_DBG_WMI
,
618 "rx_probe_req: len=%u freq=%u probe_req_report=%d\n",
619 dlen
, freq
, vif
->probe_req_report
);
621 if (vif
->probe_req_report
|| vif
->nw_type
== AP_NETWORK
)
622 cfg80211_rx_mgmt(&vif
->wdev
, freq
, 0, ev
->data
, dlen
, 0);
627 static int ath6kl_wmi_p2p_capabilities_event_rx(u8
*datap
, int len
)
629 struct wmi_p2p_capabilities_event
*ev
;
632 if (len
< sizeof(*ev
))
635 ev
= (struct wmi_p2p_capabilities_event
*) datap
;
636 dlen
= le16_to_cpu(ev
->len
);
637 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_capab: len=%u\n", dlen
);
642 static int ath6kl_wmi_rx_action_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
643 struct ath6kl_vif
*vif
)
645 struct wmi_rx_action_event
*ev
;
649 if (len
< sizeof(*ev
))
652 ev
= (struct wmi_rx_action_event
*) datap
;
653 freq
= le32_to_cpu(ev
->freq
);
654 dlen
= le16_to_cpu(ev
->len
);
655 if (datap
+ len
< ev
->data
+ dlen
) {
656 ath6kl_err("invalid wmi_rx_action_event: len=%d dlen=%u\n",
660 ath6kl_dbg(ATH6KL_DBG_WMI
, "rx_action: len=%u freq=%u\n", dlen
, freq
);
661 cfg80211_rx_mgmt(&vif
->wdev
, freq
, 0, ev
->data
, dlen
, 0);
666 static int ath6kl_wmi_p2p_info_event_rx(u8
*datap
, int len
)
668 struct wmi_p2p_info_event
*ev
;
672 if (len
< sizeof(*ev
))
675 ev
= (struct wmi_p2p_info_event
*) datap
;
676 flags
= le32_to_cpu(ev
->info_req_flags
);
677 dlen
= le16_to_cpu(ev
->len
);
678 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: flags=%x len=%d\n", flags
, dlen
);
680 if (flags
& P2P_FLAG_CAPABILITIES_REQ
) {
681 struct wmi_p2p_capabilities
*cap
;
682 if (dlen
< sizeof(*cap
))
684 cap
= (struct wmi_p2p_capabilities
*) ev
->data
;
685 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: GO Power Save = %d\n",
689 if (flags
& P2P_FLAG_MACADDR_REQ
) {
690 struct wmi_p2p_macaddr
*mac
;
691 if (dlen
< sizeof(*mac
))
693 mac
= (struct wmi_p2p_macaddr
*) ev
->data
;
694 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: MAC Address = %pM\n",
698 if (flags
& P2P_FLAG_HMODEL_REQ
) {
699 struct wmi_p2p_hmodel
*mod
;
700 if (dlen
< sizeof(*mod
))
702 mod
= (struct wmi_p2p_hmodel
*) ev
->data
;
703 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: P2P Model = %d (%s)\n",
705 mod
->p2p_model
? "host" : "firmware");
710 static inline struct sk_buff
*ath6kl_wmi_get_new_buf(u32 size
)
714 skb
= ath6kl_buf_alloc(size
);
720 memset(skb
->data
, 0, size
);
725 /* Send a "simple" wmi command -- one with no arguments */
726 static int ath6kl_wmi_simple_cmd(struct wmi
*wmi
, u8 if_idx
,
727 enum wmi_cmd_id cmd_id
)
732 skb
= ath6kl_wmi_get_new_buf(0);
736 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, cmd_id
, NO_SYNC_WMIFLAG
);
741 static int ath6kl_wmi_ready_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
743 struct wmi_ready_event_2
*ev
= (struct wmi_ready_event_2
*) datap
;
745 if (len
< sizeof(struct wmi_ready_event_2
))
748 ath6kl_ready_event(wmi
->parent_dev
, ev
->mac_addr
,
749 le32_to_cpu(ev
->sw_version
),
750 le32_to_cpu(ev
->abi_version
), ev
->phy_cap
);
756 * Mechanism to modify the roaming behavior in the firmware. The lower rssi
757 * at which the station has to roam can be passed with
758 * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level
761 int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi
*wmi
, u8 lrssi
)
764 struct roam_ctrl_cmd
*cmd
;
766 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
770 cmd
= (struct roam_ctrl_cmd
*) skb
->data
;
772 cmd
->info
.params
.lrssi_scan_period
= cpu_to_le16(DEF_LRSSI_SCAN_PERIOD
);
773 cmd
->info
.params
.lrssi_scan_threshold
= a_cpu_to_sle16(lrssi
+
774 DEF_SCAN_FOR_ROAM_INTVL
);
775 cmd
->info
.params
.lrssi_roam_threshold
= a_cpu_to_sle16(lrssi
);
776 cmd
->info
.params
.roam_rssi_floor
= DEF_LRSSI_ROAM_FLOOR
;
777 cmd
->roam_ctrl
= WMI_SET_LRSSI_SCAN_PARAMS
;
779 ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SET_ROAM_CTRL_CMDID
,
785 int ath6kl_wmi_force_roam_cmd(struct wmi
*wmi
, const u8
*bssid
)
788 struct roam_ctrl_cmd
*cmd
;
790 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
794 cmd
= (struct roam_ctrl_cmd
*) skb
->data
;
796 memcpy(cmd
->info
.bssid
, bssid
, ETH_ALEN
);
797 cmd
->roam_ctrl
= WMI_FORCE_ROAM
;
799 ath6kl_dbg(ATH6KL_DBG_WMI
, "force roam to %pM\n", bssid
);
800 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SET_ROAM_CTRL_CMDID
,
804 int ath6kl_wmi_ap_set_beacon_intvl_cmd(struct wmi
*wmi
, u8 if_idx
,
808 struct set_beacon_int_cmd
*cmd
;
810 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
814 cmd
= (struct set_beacon_int_cmd
*) skb
->data
;
816 cmd
->beacon_intvl
= cpu_to_le32(beacon_intvl
);
817 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
818 WMI_SET_BEACON_INT_CMDID
, NO_SYNC_WMIFLAG
);
821 int ath6kl_wmi_ap_set_dtim_cmd(struct wmi
*wmi
, u8 if_idx
, u32 dtim_period
)
824 struct set_dtim_cmd
*cmd
;
826 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
830 cmd
= (struct set_dtim_cmd
*) skb
->data
;
832 cmd
->dtim_period
= cpu_to_le32(dtim_period
);
833 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
834 WMI_AP_SET_DTIM_CMDID
, NO_SYNC_WMIFLAG
);
837 int ath6kl_wmi_set_roam_mode_cmd(struct wmi
*wmi
, enum wmi_roam_mode mode
)
840 struct roam_ctrl_cmd
*cmd
;
842 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
846 cmd
= (struct roam_ctrl_cmd
*) skb
->data
;
848 cmd
->info
.roam_mode
= mode
;
849 cmd
->roam_ctrl
= WMI_SET_ROAM_MODE
;
851 ath6kl_dbg(ATH6KL_DBG_WMI
, "set roam mode %d\n", mode
);
852 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SET_ROAM_CTRL_CMDID
,
856 static int ath6kl_wmi_connect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
857 struct ath6kl_vif
*vif
)
859 struct wmi_connect_event
*ev
;
862 if (len
< sizeof(struct wmi_connect_event
))
865 ev
= (struct wmi_connect_event
*) datap
;
867 if (vif
->nw_type
== AP_NETWORK
) {
868 /* AP mode start/STA connected event */
869 struct net_device
*dev
= vif
->ndev
;
870 if (memcmp(dev
->dev_addr
, ev
->u
.ap_bss
.bssid
, ETH_ALEN
) == 0) {
871 ath6kl_dbg(ATH6KL_DBG_WMI
,
872 "%s: freq %d bssid %pM (AP started)\n",
873 __func__
, le16_to_cpu(ev
->u
.ap_bss
.ch
),
875 ath6kl_connect_ap_mode_bss(
876 vif
, le16_to_cpu(ev
->u
.ap_bss
.ch
));
878 ath6kl_dbg(ATH6KL_DBG_WMI
,
879 "%s: aid %u mac_addr %pM auth=%u keymgmt=%u cipher=%u apsd_info=%u (STA connected)\n",
880 __func__
, ev
->u
.ap_sta
.aid
,
881 ev
->u
.ap_sta
.mac_addr
,
883 ev
->u
.ap_sta
.keymgmt
,
884 le16_to_cpu(ev
->u
.ap_sta
.cipher
),
885 ev
->u
.ap_sta
.apsd_info
);
887 ath6kl_connect_ap_mode_sta(
888 vif
, ev
->u
.ap_sta
.aid
, ev
->u
.ap_sta
.mac_addr
,
889 ev
->u
.ap_sta
.keymgmt
,
890 le16_to_cpu(ev
->u
.ap_sta
.cipher
),
891 ev
->u
.ap_sta
.auth
, ev
->assoc_req_len
,
892 ev
->assoc_info
+ ev
->beacon_ie_len
,
893 ev
->u
.ap_sta
.apsd_info
);
898 /* STA/IBSS mode connection event */
900 ath6kl_dbg(ATH6KL_DBG_WMI
,
901 "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n",
902 le16_to_cpu(ev
->u
.sta
.ch
), ev
->u
.sta
.bssid
,
903 le16_to_cpu(ev
->u
.sta
.listen_intvl
),
904 le16_to_cpu(ev
->u
.sta
.beacon_intvl
),
905 le32_to_cpu(ev
->u
.sta
.nw_type
));
907 /* Start of assoc rsp IEs */
908 pie
= ev
->assoc_info
+ ev
->beacon_ie_len
+
909 ev
->assoc_req_len
+ (sizeof(u16
) * 3); /* capinfo, status, aid */
911 /* End of assoc rsp IEs */
912 peie
= ev
->assoc_info
+ ev
->beacon_ie_len
+ ev
->assoc_req_len
+
917 case WLAN_EID_VENDOR_SPECIFIC
:
918 if (pie
[1] > 3 && pie
[2] == 0x00 && pie
[3] == 0x50 &&
919 pie
[4] == 0xf2 && pie
[5] == WMM_OUI_TYPE
) {
920 /* WMM OUT (00:50:F2) */
922 pie
[6] == WMM_PARAM_OUI_SUBTYPE
)
923 wmi
->is_wmm_enabled
= true;
928 if (wmi
->is_wmm_enabled
)
934 ath6kl_connect_event(vif
, le16_to_cpu(ev
->u
.sta
.ch
),
936 le16_to_cpu(ev
->u
.sta
.listen_intvl
),
937 le16_to_cpu(ev
->u
.sta
.beacon_intvl
),
938 le32_to_cpu(ev
->u
.sta
.nw_type
),
939 ev
->beacon_ie_len
, ev
->assoc_req_len
,
940 ev
->assoc_resp_len
, ev
->assoc_info
);
945 static struct country_code_to_enum_rd
*
946 ath6kl_regd_find_country(u16 countryCode
)
950 for (i
= 0; i
< ARRAY_SIZE(allCountries
); i
++) {
951 if (allCountries
[i
].countryCode
== countryCode
)
952 return &allCountries
[i
];
958 static struct reg_dmn_pair_mapping
*
959 ath6kl_get_regpair(u16 regdmn
)
963 if (regdmn
== NO_ENUMRD
)
966 for (i
= 0; i
< ARRAY_SIZE(regDomainPairs
); i
++) {
967 if (regDomainPairs
[i
].reg_domain
== regdmn
)
968 return ®DomainPairs
[i
];
974 static struct country_code_to_enum_rd
*
975 ath6kl_regd_find_country_by_rd(u16 regdmn
)
979 for (i
= 0; i
< ARRAY_SIZE(allCountries
); i
++) {
980 if (allCountries
[i
].regDmnEnum
== regdmn
)
981 return &allCountries
[i
];
987 static void ath6kl_wmi_regdomain_event(struct wmi
*wmi
, u8
*datap
, int len
)
989 struct ath6kl_wmi_regdomain
*ev
;
990 struct country_code_to_enum_rd
*country
= NULL
;
991 struct reg_dmn_pair_mapping
*regpair
= NULL
;
995 ev
= (struct ath6kl_wmi_regdomain
*) datap
;
996 reg_code
= le32_to_cpu(ev
->reg_code
);
998 if ((reg_code
>> ATH6KL_COUNTRY_RD_SHIFT
) & COUNTRY_ERD_FLAG
) {
999 country
= ath6kl_regd_find_country((u16
) reg_code
);
1000 } else if (!(((u16
) reg_code
& WORLD_SKU_MASK
) == WORLD_SKU_PREFIX
)) {
1001 regpair
= ath6kl_get_regpair((u16
) reg_code
);
1002 country
= ath6kl_regd_find_country_by_rd((u16
) reg_code
);
1004 ath6kl_dbg(ATH6KL_DBG_WMI
, "Regpair used: 0x%0x\n",
1005 regpair
->reg_domain
);
1007 ath6kl_warn("Regpair not found reg_code 0x%0x\n",
1011 if (country
&& wmi
->parent_dev
->wiphy_registered
) {
1012 alpha2
[0] = country
->isoName
[0];
1013 alpha2
[1] = country
->isoName
[1];
1015 regulatory_hint(wmi
->parent_dev
->wiphy
, alpha2
);
1017 ath6kl_dbg(ATH6KL_DBG_WMI
, "Country alpha2 being used: %c%c\n",
1018 alpha2
[0], alpha2
[1]);
1022 static int ath6kl_wmi_disconnect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1023 struct ath6kl_vif
*vif
)
1025 struct wmi_disconnect_event
*ev
;
1026 wmi
->traffic_class
= 100;
1028 if (len
< sizeof(struct wmi_disconnect_event
))
1031 ev
= (struct wmi_disconnect_event
*) datap
;
1033 ath6kl_dbg(ATH6KL_DBG_WMI
,
1034 "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n",
1035 le16_to_cpu(ev
->proto_reason_status
), ev
->bssid
,
1036 ev
->disconn_reason
, ev
->assoc_resp_len
);
1038 wmi
->is_wmm_enabled
= false;
1040 ath6kl_disconnect_event(vif
, ev
->disconn_reason
,
1041 ev
->bssid
, ev
->assoc_resp_len
, ev
->assoc_info
,
1042 le16_to_cpu(ev
->proto_reason_status
));
1047 static int ath6kl_wmi_peer_node_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1049 struct wmi_peer_node_event
*ev
;
1051 if (len
< sizeof(struct wmi_peer_node_event
))
1054 ev
= (struct wmi_peer_node_event
*) datap
;
1056 if (ev
->event_code
== PEER_NODE_JOIN_EVENT
)
1057 ath6kl_dbg(ATH6KL_DBG_WMI
, "joined node with mac addr: %pM\n",
1059 else if (ev
->event_code
== PEER_NODE_LEAVE_EVENT
)
1060 ath6kl_dbg(ATH6KL_DBG_WMI
, "left node with mac addr: %pM\n",
1066 static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1067 struct ath6kl_vif
*vif
)
1069 struct wmi_tkip_micerr_event
*ev
;
1071 if (len
< sizeof(struct wmi_tkip_micerr_event
))
1074 ev
= (struct wmi_tkip_micerr_event
*) datap
;
1076 ath6kl_tkip_micerr_event(vif
, ev
->key_id
, ev
->is_mcast
);
1081 void ath6kl_wmi_sscan_timer(struct timer_list
*t
)
1083 struct ath6kl_vif
*vif
= from_timer(vif
, t
, sched_scan_timer
);
1085 cfg80211_sched_scan_results(vif
->ar
->wiphy
, 0);
1088 static int ath6kl_wmi_bssinfo_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1089 struct ath6kl_vif
*vif
)
1091 struct wmi_bss_info_hdr2
*bih
;
1093 struct ieee80211_channel
*channel
;
1094 struct ath6kl
*ar
= wmi
->parent_dev
;
1095 struct cfg80211_bss
*bss
;
1097 if (len
<= sizeof(struct wmi_bss_info_hdr2
))
1100 bih
= (struct wmi_bss_info_hdr2
*) datap
;
1101 buf
= datap
+ sizeof(struct wmi_bss_info_hdr2
);
1102 len
-= sizeof(struct wmi_bss_info_hdr2
);
1104 ath6kl_dbg(ATH6KL_DBG_WMI
,
1105 "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
1107 bih
->ch
, bih
->snr
, bih
->snr
- 95, bih
->bssid
,
1110 if (bih
->frame_type
!= BEACON_FTYPE
&&
1111 bih
->frame_type
!= PROBERESP_FTYPE
)
1112 return 0; /* Only update BSS table for now */
1114 if (bih
->frame_type
== BEACON_FTYPE
&&
1115 test_bit(CLEAR_BSSFILTER_ON_BEACON
, &vif
->flags
)) {
1116 clear_bit(CLEAR_BSSFILTER_ON_BEACON
, &vif
->flags
);
1117 ath6kl_wmi_bssfilter_cmd(ar
->wmi
, vif
->fw_vif_idx
,
1118 NONE_BSS_FILTER
, 0);
1121 channel
= ieee80211_get_channel(ar
->wiphy
, le16_to_cpu(bih
->ch
));
1122 if (channel
== NULL
)
1125 if (len
< 8 + 2 + 2)
1128 if (bih
->frame_type
== BEACON_FTYPE
&&
1129 test_bit(CONNECTED
, &vif
->flags
) &&
1130 memcmp(bih
->bssid
, vif
->bssid
, ETH_ALEN
) == 0) {
1132 tim
= cfg80211_find_ie(WLAN_EID_TIM
, buf
+ 8 + 2 + 2,
1134 if (tim
&& tim
[1] >= 2) {
1135 vif
->assoc_bss_dtim_period
= tim
[3];
1136 set_bit(DTIM_PERIOD_AVAIL
, &vif
->flags
);
1140 bss
= cfg80211_inform_bss(ar
->wiphy
, channel
,
1141 bih
->frame_type
== BEACON_FTYPE
?
1142 CFG80211_BSS_FTYPE_BEACON
:
1143 CFG80211_BSS_FTYPE_PRESP
,
1144 bih
->bssid
, get_unaligned_le64((__le64
*)buf
),
1145 get_unaligned_le16(((__le16
*)buf
) + 5),
1146 get_unaligned_le16(((__le16
*)buf
) + 4),
1147 buf
+ 8 + 2 + 2, len
- 8 - 2 - 2,
1148 (bih
->snr
- 95) * 100, GFP_ATOMIC
);
1151 cfg80211_put_bss(ar
->wiphy
, bss
);
1154 * Firmware doesn't return any event when scheduled scan has
1155 * finished, so we need to use a timer to find out when there are
1158 * The timer is started from the first bss info received, otherwise
1159 * the timer would not ever fire if the scan interval is short
1162 if (test_bit(SCHED_SCANNING
, &vif
->flags
) &&
1163 !timer_pending(&vif
->sched_scan_timer
)) {
1164 mod_timer(&vif
->sched_scan_timer
, jiffies
+
1165 msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY
));
1171 /* Inactivity timeout of a fatpipe(pstream) at the target */
1172 static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi
*wmi
, u8
*datap
,
1175 struct wmi_pstream_timeout_event
*ev
;
1177 if (len
< sizeof(struct wmi_pstream_timeout_event
))
1180 ev
= (struct wmi_pstream_timeout_event
*) datap
;
1183 * When the pstream (fat pipe == AC) timesout, it means there were
1184 * no thinStreams within this pstream & it got implicitly created
1185 * due to data flow on this AC. We start the inactivity timer only
1186 * for implicitly created pstream. Just reset the host state.
1188 spin_lock_bh(&wmi
->lock
);
1189 wmi
->stream_exist_for_ac
[ev
->traffic_class
] = 0;
1190 wmi
->fat_pipe_exist
&= ~(1 << ev
->traffic_class
);
1191 spin_unlock_bh(&wmi
->lock
);
1193 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1194 ath6kl_indicate_tx_activity(wmi
->parent_dev
, ev
->traffic_class
, false);
1199 static int ath6kl_wmi_bitrate_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1201 struct wmi_bit_rate_reply
*reply
;
1205 if (len
< sizeof(struct wmi_bit_rate_reply
))
1208 reply
= (struct wmi_bit_rate_reply
*) datap
;
1210 ath6kl_dbg(ATH6KL_DBG_WMI
, "rateindex %d\n", reply
->rate_index
);
1212 if (reply
->rate_index
== (s8
) RATE_AUTO
) {
1215 index
= reply
->rate_index
& 0x7f;
1216 if (WARN_ON_ONCE(index
> (RATE_MCS_7_40
+ 1)))
1219 sgi
= (reply
->rate_index
& 0x80) ? 1 : 0;
1220 rate
= wmi_rate_tbl
[index
][sgi
];
1223 ath6kl_wakeup_event(wmi
->parent_dev
);
1228 static int ath6kl_wmi_test_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1230 ath6kl_tm_rx_event(wmi
->parent_dev
, datap
, len
);
1235 static int ath6kl_wmi_ratemask_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1237 if (len
< sizeof(struct wmi_fix_rates_reply
))
1240 ath6kl_wakeup_event(wmi
->parent_dev
);
1245 static int ath6kl_wmi_ch_list_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1247 if (len
< sizeof(struct wmi_channel_list_reply
))
1250 ath6kl_wakeup_event(wmi
->parent_dev
);
1255 static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1257 struct wmi_tx_pwr_reply
*reply
;
1259 if (len
< sizeof(struct wmi_tx_pwr_reply
))
1262 reply
= (struct wmi_tx_pwr_reply
*) datap
;
1263 ath6kl_txpwr_rx_evt(wmi
->parent_dev
, reply
->dbM
);
1268 static int ath6kl_wmi_keepalive_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1270 if (len
< sizeof(struct wmi_get_keepalive_cmd
))
1273 ath6kl_wakeup_event(wmi
->parent_dev
);
1278 static int ath6kl_wmi_scan_complete_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1279 struct ath6kl_vif
*vif
)
1281 struct wmi_scan_complete_event
*ev
;
1283 ev
= (struct wmi_scan_complete_event
*) datap
;
1285 ath6kl_scan_complete_evt(vif
, a_sle32_to_cpu(ev
->status
));
1286 wmi
->is_probe_ssid
= false;
1291 static int ath6kl_wmi_neighbor_report_event_rx(struct wmi
*wmi
, u8
*datap
,
1292 int len
, struct ath6kl_vif
*vif
)
1294 struct wmi_neighbor_report_event
*ev
;
1297 if (len
< sizeof(*ev
))
1299 ev
= (struct wmi_neighbor_report_event
*) datap
;
1300 if (sizeof(*ev
) + ev
->num_neighbors
* sizeof(struct wmi_neighbor_info
)
1302 ath6kl_dbg(ATH6KL_DBG_WMI
,
1303 "truncated neighbor event (num=%d len=%d)\n",
1304 ev
->num_neighbors
, len
);
1307 for (i
= 0; i
< ev
->num_neighbors
; i
++) {
1308 ath6kl_dbg(ATH6KL_DBG_WMI
, "neighbor %d/%d - %pM 0x%x\n",
1309 i
+ 1, ev
->num_neighbors
, ev
->neighbor
[i
].bssid
,
1310 ev
->neighbor
[i
].bss_flags
);
1311 cfg80211_pmksa_candidate_notify(vif
->ndev
, i
,
1312 ev
->neighbor
[i
].bssid
,
1313 !!(ev
->neighbor
[i
].bss_flags
&
1314 WMI_PREAUTH_CAPABLE_BSS
),
1322 * Target is reporting a programming error. This is for
1323 * developer aid only. Target only checks a few common violations
1324 * and it is responsibility of host to do all error checking.
1325 * Behavior of target after wmi error event is undefined.
1326 * A reset is recommended.
1328 static int ath6kl_wmi_error_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1330 const char *type
= "unknown error";
1331 struct wmi_cmd_error_event
*ev
;
1332 ev
= (struct wmi_cmd_error_event
*) datap
;
1334 switch (ev
->err_code
) {
1336 type
= "invalid parameter";
1339 type
= "invalid state";
1341 case INTERNAL_ERROR
:
1342 type
= "internal error";
1346 ath6kl_dbg(ATH6KL_DBG_WMI
, "programming error, cmd=%d %s\n",
1352 static int ath6kl_wmi_stats_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1353 struct ath6kl_vif
*vif
)
1355 ath6kl_tgt_stats_event(vif
, datap
, len
);
1360 static u8
ath6kl_wmi_get_upper_threshold(s16 rssi
,
1361 struct sq_threshold_params
*sq_thresh
,
1365 u8 threshold
= (u8
) sq_thresh
->upper_threshold
[size
- 1];
1367 /* The list is already in sorted order. Get the next lower value */
1368 for (index
= 0; index
< size
; index
++) {
1369 if (rssi
< sq_thresh
->upper_threshold
[index
]) {
1370 threshold
= (u8
) sq_thresh
->upper_threshold
[index
];
1378 static u8
ath6kl_wmi_get_lower_threshold(s16 rssi
,
1379 struct sq_threshold_params
*sq_thresh
,
1383 u8 threshold
= (u8
) sq_thresh
->lower_threshold
[size
- 1];
1385 /* The list is already in sorted order. Get the next lower value */
1386 for (index
= 0; index
< size
; index
++) {
1387 if (rssi
> sq_thresh
->lower_threshold
[index
]) {
1388 threshold
= (u8
) sq_thresh
->lower_threshold
[index
];
1396 static int ath6kl_wmi_send_rssi_threshold_params(struct wmi
*wmi
,
1397 struct wmi_rssi_threshold_params_cmd
*rssi_cmd
)
1399 struct sk_buff
*skb
;
1400 struct wmi_rssi_threshold_params_cmd
*cmd
;
1402 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1406 cmd
= (struct wmi_rssi_threshold_params_cmd
*) skb
->data
;
1407 memcpy(cmd
, rssi_cmd
, sizeof(struct wmi_rssi_threshold_params_cmd
));
1409 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_RSSI_THRESHOLD_PARAMS_CMDID
,
1413 static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1416 struct wmi_rssi_threshold_event
*reply
;
1417 struct wmi_rssi_threshold_params_cmd cmd
;
1418 struct sq_threshold_params
*sq_thresh
;
1419 enum wmi_rssi_threshold_val new_threshold
;
1420 u8 upper_rssi_threshold
, lower_rssi_threshold
;
1424 if (len
< sizeof(struct wmi_rssi_threshold_event
))
1427 reply
= (struct wmi_rssi_threshold_event
*) datap
;
1428 new_threshold
= (enum wmi_rssi_threshold_val
) reply
->range
;
1429 rssi
= a_sle16_to_cpu(reply
->rssi
);
1431 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_RSSI
];
1434 * Identify the threshold breached and communicate that to the app.
1435 * After that install a new set of thresholds based on the signal
1436 * quality reported by the target
1438 if (new_threshold
) {
1439 /* Upper threshold breached */
1440 if (rssi
< sq_thresh
->upper_threshold
[0]) {
1441 ath6kl_dbg(ATH6KL_DBG_WMI
,
1442 "spurious upper rssi threshold event: %d\n",
1444 } else if ((rssi
< sq_thresh
->upper_threshold
[1]) &&
1445 (rssi
>= sq_thresh
->upper_threshold
[0])) {
1446 new_threshold
= WMI_RSSI_THRESHOLD1_ABOVE
;
1447 } else if ((rssi
< sq_thresh
->upper_threshold
[2]) &&
1448 (rssi
>= sq_thresh
->upper_threshold
[1])) {
1449 new_threshold
= WMI_RSSI_THRESHOLD2_ABOVE
;
1450 } else if ((rssi
< sq_thresh
->upper_threshold
[3]) &&
1451 (rssi
>= sq_thresh
->upper_threshold
[2])) {
1452 new_threshold
= WMI_RSSI_THRESHOLD3_ABOVE
;
1453 } else if ((rssi
< sq_thresh
->upper_threshold
[4]) &&
1454 (rssi
>= sq_thresh
->upper_threshold
[3])) {
1455 new_threshold
= WMI_RSSI_THRESHOLD4_ABOVE
;
1456 } else if ((rssi
< sq_thresh
->upper_threshold
[5]) &&
1457 (rssi
>= sq_thresh
->upper_threshold
[4])) {
1458 new_threshold
= WMI_RSSI_THRESHOLD5_ABOVE
;
1459 } else if (rssi
>= sq_thresh
->upper_threshold
[5]) {
1460 new_threshold
= WMI_RSSI_THRESHOLD6_ABOVE
;
1463 /* Lower threshold breached */
1464 if (rssi
> sq_thresh
->lower_threshold
[0]) {
1465 ath6kl_dbg(ATH6KL_DBG_WMI
,
1466 "spurious lower rssi threshold event: %d %d\n",
1467 rssi
, sq_thresh
->lower_threshold
[0]);
1468 } else if ((rssi
> sq_thresh
->lower_threshold
[1]) &&
1469 (rssi
<= sq_thresh
->lower_threshold
[0])) {
1470 new_threshold
= WMI_RSSI_THRESHOLD6_BELOW
;
1471 } else if ((rssi
> sq_thresh
->lower_threshold
[2]) &&
1472 (rssi
<= sq_thresh
->lower_threshold
[1])) {
1473 new_threshold
= WMI_RSSI_THRESHOLD5_BELOW
;
1474 } else if ((rssi
> sq_thresh
->lower_threshold
[3]) &&
1475 (rssi
<= sq_thresh
->lower_threshold
[2])) {
1476 new_threshold
= WMI_RSSI_THRESHOLD4_BELOW
;
1477 } else if ((rssi
> sq_thresh
->lower_threshold
[4]) &&
1478 (rssi
<= sq_thresh
->lower_threshold
[3])) {
1479 new_threshold
= WMI_RSSI_THRESHOLD3_BELOW
;
1480 } else if ((rssi
> sq_thresh
->lower_threshold
[5]) &&
1481 (rssi
<= sq_thresh
->lower_threshold
[4])) {
1482 new_threshold
= WMI_RSSI_THRESHOLD2_BELOW
;
1483 } else if (rssi
<= sq_thresh
->lower_threshold
[5]) {
1484 new_threshold
= WMI_RSSI_THRESHOLD1_BELOW
;
1488 /* Calculate and install the next set of thresholds */
1489 lower_rssi_threshold
= ath6kl_wmi_get_lower_threshold(rssi
, sq_thresh
,
1490 sq_thresh
->lower_threshold_valid_count
);
1491 upper_rssi_threshold
= ath6kl_wmi_get_upper_threshold(rssi
, sq_thresh
,
1492 sq_thresh
->upper_threshold_valid_count
);
1494 /* Issue a wmi command to install the thresholds */
1495 cmd
.thresh_above1_val
= a_cpu_to_sle16(upper_rssi_threshold
);
1496 cmd
.thresh_below1_val
= a_cpu_to_sle16(lower_rssi_threshold
);
1497 cmd
.weight
= sq_thresh
->weight
;
1498 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1500 ret
= ath6kl_wmi_send_rssi_threshold_params(wmi
, &cmd
);
1502 ath6kl_err("unable to configure rssi thresholds\n");
1509 static int ath6kl_wmi_cac_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1510 struct ath6kl_vif
*vif
)
1512 struct wmi_cac_event
*reply
;
1513 struct ieee80211_tspec_ie
*ts
;
1514 u16 active_tsids
, tsinfo
;
1518 if (len
< sizeof(struct wmi_cac_event
))
1521 reply
= (struct wmi_cac_event
*) datap
;
1523 if ((reply
->cac_indication
== CAC_INDICATION_ADMISSION_RESP
) &&
1524 (reply
->status_code
!= IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED
)) {
1525 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1526 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1527 tsid
= (tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1528 IEEE80211_WMM_IE_TSPEC_TID_MASK
;
1530 ath6kl_wmi_delete_pstream_cmd(wmi
, vif
->fw_vif_idx
,
1532 } else if (reply
->cac_indication
== CAC_INDICATION_NO_RESP
) {
1534 * Following assumes that there is only one outstanding
1535 * ADDTS request when this event is received
1537 spin_lock_bh(&wmi
->lock
);
1538 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1539 spin_unlock_bh(&wmi
->lock
);
1541 for (index
= 0; index
< sizeof(active_tsids
) * 8; index
++) {
1542 if ((active_tsids
>> index
) & 1)
1545 if (index
< (sizeof(active_tsids
) * 8))
1546 ath6kl_wmi_delete_pstream_cmd(wmi
, vif
->fw_vif_idx
,
1551 * Clear active tsids and Add missing handling
1552 * for delete qos stream from AP
1554 else if (reply
->cac_indication
== CAC_INDICATION_DELETE
) {
1555 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1556 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1557 ts_id
= ((tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1558 IEEE80211_WMM_IE_TSPEC_TID_MASK
);
1560 spin_lock_bh(&wmi
->lock
);
1561 wmi
->stream_exist_for_ac
[reply
->ac
] &= ~(1 << ts_id
);
1562 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1563 spin_unlock_bh(&wmi
->lock
);
1565 /* Indicate stream inactivity to driver layer only if all tsids
1566 * within this AC are deleted.
1568 if (!active_tsids
) {
1569 ath6kl_indicate_tx_activity(wmi
->parent_dev
, reply
->ac
,
1571 wmi
->fat_pipe_exist
&= ~(1 << reply
->ac
);
1578 static int ath6kl_wmi_txe_notify_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1579 struct ath6kl_vif
*vif
)
1581 struct wmi_txe_notify_event
*ev
;
1584 if (len
< sizeof(*ev
))
1587 if (vif
->nw_type
!= INFRA_NETWORK
||
1588 !test_bit(ATH6KL_FW_CAPABILITY_TX_ERR_NOTIFY
,
1589 vif
->ar
->fw_capabilities
))
1592 if (vif
->sme_state
!= SME_CONNECTED
)
1595 ev
= (struct wmi_txe_notify_event
*) datap
;
1596 rate
= le32_to_cpu(ev
->rate
);
1597 pkts
= le32_to_cpu(ev
->pkts
);
1599 ath6kl_dbg(ATH6KL_DBG_WMI
, "TXE notify event: peer %pM rate %d%% pkts %d intvl %ds\n",
1600 vif
->bssid
, rate
, pkts
, vif
->txe_intvl
);
1602 cfg80211_cqm_txe_notify(vif
->ndev
, vif
->bssid
, pkts
,
1603 rate
, vif
->txe_intvl
, GFP_KERNEL
);
1608 int ath6kl_wmi_set_txe_notify(struct wmi
*wmi
, u8 idx
,
1609 u32 rate
, u32 pkts
, u32 intvl
)
1611 struct sk_buff
*skb
;
1612 struct wmi_txe_notify_cmd
*cmd
;
1614 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1618 cmd
= (struct wmi_txe_notify_cmd
*) skb
->data
;
1619 cmd
->rate
= cpu_to_le32(rate
);
1620 cmd
->pkts
= cpu_to_le32(pkts
);
1621 cmd
->intvl
= cpu_to_le32(intvl
);
1623 return ath6kl_wmi_cmd_send(wmi
, idx
, skb
, WMI_SET_TXE_NOTIFY_CMDID
,
1627 int ath6kl_wmi_set_rssi_filter_cmd(struct wmi
*wmi
, u8 if_idx
, s8 rssi
)
1629 struct sk_buff
*skb
;
1630 struct wmi_set_rssi_filter_cmd
*cmd
;
1633 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1637 cmd
= (struct wmi_set_rssi_filter_cmd
*) skb
->data
;
1640 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_RSSI_FILTER_CMDID
,
1645 static int ath6kl_wmi_send_snr_threshold_params(struct wmi
*wmi
,
1646 struct wmi_snr_threshold_params_cmd
*snr_cmd
)
1648 struct sk_buff
*skb
;
1649 struct wmi_snr_threshold_params_cmd
*cmd
;
1651 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1655 cmd
= (struct wmi_snr_threshold_params_cmd
*) skb
->data
;
1656 memcpy(cmd
, snr_cmd
, sizeof(struct wmi_snr_threshold_params_cmd
));
1658 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SNR_THRESHOLD_PARAMS_CMDID
,
1662 static int ath6kl_wmi_snr_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1665 struct wmi_snr_threshold_event
*reply
;
1666 struct sq_threshold_params
*sq_thresh
;
1667 struct wmi_snr_threshold_params_cmd cmd
;
1668 enum wmi_snr_threshold_val new_threshold
;
1669 u8 upper_snr_threshold
, lower_snr_threshold
;
1673 if (len
< sizeof(struct wmi_snr_threshold_event
))
1676 reply
= (struct wmi_snr_threshold_event
*) datap
;
1678 new_threshold
= (enum wmi_snr_threshold_val
) reply
->range
;
1681 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_SNR
];
1684 * Identify the threshold breached and communicate that to the app.
1685 * After that install a new set of thresholds based on the signal
1686 * quality reported by the target.
1688 if (new_threshold
) {
1689 /* Upper threshold breached */
1690 if (snr
< sq_thresh
->upper_threshold
[0]) {
1691 ath6kl_dbg(ATH6KL_DBG_WMI
,
1692 "spurious upper snr threshold event: %d\n",
1694 } else if ((snr
< sq_thresh
->upper_threshold
[1]) &&
1695 (snr
>= sq_thresh
->upper_threshold
[0])) {
1696 new_threshold
= WMI_SNR_THRESHOLD1_ABOVE
;
1697 } else if ((snr
< sq_thresh
->upper_threshold
[2]) &&
1698 (snr
>= sq_thresh
->upper_threshold
[1])) {
1699 new_threshold
= WMI_SNR_THRESHOLD2_ABOVE
;
1700 } else if ((snr
< sq_thresh
->upper_threshold
[3]) &&
1701 (snr
>= sq_thresh
->upper_threshold
[2])) {
1702 new_threshold
= WMI_SNR_THRESHOLD3_ABOVE
;
1703 } else if (snr
>= sq_thresh
->upper_threshold
[3]) {
1704 new_threshold
= WMI_SNR_THRESHOLD4_ABOVE
;
1707 /* Lower threshold breached */
1708 if (snr
> sq_thresh
->lower_threshold
[0]) {
1709 ath6kl_dbg(ATH6KL_DBG_WMI
,
1710 "spurious lower snr threshold event: %d\n",
1711 sq_thresh
->lower_threshold
[0]);
1712 } else if ((snr
> sq_thresh
->lower_threshold
[1]) &&
1713 (snr
<= sq_thresh
->lower_threshold
[0])) {
1714 new_threshold
= WMI_SNR_THRESHOLD4_BELOW
;
1715 } else if ((snr
> sq_thresh
->lower_threshold
[2]) &&
1716 (snr
<= sq_thresh
->lower_threshold
[1])) {
1717 new_threshold
= WMI_SNR_THRESHOLD3_BELOW
;
1718 } else if ((snr
> sq_thresh
->lower_threshold
[3]) &&
1719 (snr
<= sq_thresh
->lower_threshold
[2])) {
1720 new_threshold
= WMI_SNR_THRESHOLD2_BELOW
;
1721 } else if (snr
<= sq_thresh
->lower_threshold
[3]) {
1722 new_threshold
= WMI_SNR_THRESHOLD1_BELOW
;
1726 /* Calculate and install the next set of thresholds */
1727 lower_snr_threshold
= ath6kl_wmi_get_lower_threshold(snr
, sq_thresh
,
1728 sq_thresh
->lower_threshold_valid_count
);
1729 upper_snr_threshold
= ath6kl_wmi_get_upper_threshold(snr
, sq_thresh
,
1730 sq_thresh
->upper_threshold_valid_count
);
1732 /* Issue a wmi command to install the thresholds */
1733 cmd
.thresh_above1_val
= upper_snr_threshold
;
1734 cmd
.thresh_below1_val
= lower_snr_threshold
;
1735 cmd
.weight
= sq_thresh
->weight
;
1736 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1738 ath6kl_dbg(ATH6KL_DBG_WMI
,
1739 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1741 lower_snr_threshold
, upper_snr_threshold
);
1743 ret
= ath6kl_wmi_send_snr_threshold_params(wmi
, &cmd
);
1745 ath6kl_err("unable to configure snr threshold\n");
1752 static int ath6kl_wmi_aplist_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1754 u16 ap_info_entry_size
;
1755 struct wmi_aplist_event
*ev
= (struct wmi_aplist_event
*) datap
;
1756 struct wmi_ap_info_v1
*ap_info_v1
;
1759 if (len
< sizeof(struct wmi_aplist_event
) ||
1760 ev
->ap_list_ver
!= APLIST_VER1
)
1763 ap_info_entry_size
= sizeof(struct wmi_ap_info_v1
);
1764 ap_info_v1
= (struct wmi_ap_info_v1
*) ev
->ap_list
;
1766 ath6kl_dbg(ATH6KL_DBG_WMI
,
1767 "number of APs in aplist event: %d\n", ev
->num_ap
);
1769 if (len
< (int) (sizeof(struct wmi_aplist_event
) +
1770 (ev
->num_ap
- 1) * ap_info_entry_size
))
1773 /* AP list version 1 contents */
1774 for (index
= 0; index
< ev
->num_ap
; index
++) {
1775 ath6kl_dbg(ATH6KL_DBG_WMI
, "AP#%d BSSID %pM Channel %d\n",
1776 index
, ap_info_v1
->bssid
, ap_info_v1
->channel
);
1783 int ath6kl_wmi_cmd_send(struct wmi
*wmi
, u8 if_idx
, struct sk_buff
*skb
,
1784 enum wmi_cmd_id cmd_id
, enum wmi_sync_flag sync_flag
)
1786 struct wmi_cmd_hdr
*cmd_hdr
;
1787 enum htc_endpoint_id ep_id
= wmi
->ep_id
;
1791 if (WARN_ON(skb
== NULL
||
1792 (if_idx
> (wmi
->parent_dev
->vif_max
- 1)))) {
1797 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi tx id %d len %d flag %d\n",
1798 cmd_id
, skb
->len
, sync_flag
);
1799 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP
, NULL
, "wmi tx ",
1800 skb
->data
, skb
->len
);
1802 if (sync_flag
>= END_WMIFLAG
) {
1807 if ((sync_flag
== SYNC_BEFORE_WMIFLAG
) ||
1808 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1810 * Make sure all data currently queued is transmitted before
1811 * the cmd execution. Establish a new sync point.
1813 ath6kl_wmi_sync_point(wmi
, if_idx
);
1816 skb_push(skb
, sizeof(struct wmi_cmd_hdr
));
1818 cmd_hdr
= (struct wmi_cmd_hdr
*) skb
->data
;
1819 cmd_hdr
->cmd_id
= cpu_to_le16(cmd_id
);
1820 info1
= if_idx
& WMI_CMD_HDR_IF_ID_MASK
;
1821 cmd_hdr
->info1
= cpu_to_le16(info1
);
1823 /* Only for OPT_TX_CMD, use BE endpoint. */
1824 if (cmd_id
== WMI_OPT_TX_FRAME_CMDID
) {
1825 ret
= ath6kl_wmi_data_hdr_add(wmi
, skb
, OPT_MSGTYPE
,
1826 false, false, 0, NULL
, if_idx
);
1831 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
, WMM_AC_BE
);
1834 ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
1836 if ((sync_flag
== SYNC_AFTER_WMIFLAG
) ||
1837 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1839 * Make sure all new data queued waits for the command to
1840 * execute. Establish a new sync point.
1842 ath6kl_wmi_sync_point(wmi
, if_idx
);
1848 int ath6kl_wmi_connect_cmd(struct wmi
*wmi
, u8 if_idx
,
1849 enum network_type nw_type
,
1850 enum dot11_auth_mode dot11_auth_mode
,
1851 enum auth_mode auth_mode
,
1852 enum crypto_type pairwise_crypto
,
1853 u8 pairwise_crypto_len
,
1854 enum crypto_type group_crypto
,
1855 u8 group_crypto_len
, int ssid_len
, u8
*ssid
,
1856 u8
*bssid
, u16 channel
, u32 ctrl_flags
,
1859 struct sk_buff
*skb
;
1860 struct wmi_connect_cmd
*cc
;
1863 ath6kl_dbg(ATH6KL_DBG_WMI
,
1864 "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d "
1865 "type %d dot11_auth %d auth %d pairwise %d group %d\n",
1866 bssid
, channel
, ctrl_flags
, ssid_len
, nw_type
,
1867 dot11_auth_mode
, auth_mode
, pairwise_crypto
, group_crypto
);
1868 ath6kl_dbg_dump(ATH6KL_DBG_WMI
, NULL
, "ssid ", ssid
, ssid_len
);
1870 wmi
->traffic_class
= 100;
1872 if ((pairwise_crypto
== NONE_CRYPT
) && (group_crypto
!= NONE_CRYPT
))
1875 if ((pairwise_crypto
!= NONE_CRYPT
) && (group_crypto
== NONE_CRYPT
))
1878 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd
));
1882 cc
= (struct wmi_connect_cmd
*) skb
->data
;
1885 memcpy(cc
->ssid
, ssid
, ssid_len
);
1887 cc
->ssid_len
= ssid_len
;
1888 cc
->nw_type
= nw_type
;
1889 cc
->dot11_auth_mode
= dot11_auth_mode
;
1890 cc
->auth_mode
= auth_mode
;
1891 cc
->prwise_crypto_type
= pairwise_crypto
;
1892 cc
->prwise_crypto_len
= pairwise_crypto_len
;
1893 cc
->grp_crypto_type
= group_crypto
;
1894 cc
->grp_crypto_len
= group_crypto_len
;
1895 cc
->ch
= cpu_to_le16(channel
);
1896 cc
->ctrl_flags
= cpu_to_le32(ctrl_flags
);
1897 cc
->nw_subtype
= nw_subtype
;
1900 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1902 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_CONNECT_CMDID
,
1908 int ath6kl_wmi_reconnect_cmd(struct wmi
*wmi
, u8 if_idx
, u8
*bssid
,
1911 struct sk_buff
*skb
;
1912 struct wmi_reconnect_cmd
*cc
;
1915 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi reconnect bssid %pM freq %d\n",
1918 wmi
->traffic_class
= 100;
1920 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd
));
1924 cc
= (struct wmi_reconnect_cmd
*) skb
->data
;
1925 cc
->channel
= cpu_to_le16(channel
);
1928 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1930 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_RECONNECT_CMDID
,
1936 int ath6kl_wmi_disconnect_cmd(struct wmi
*wmi
, u8 if_idx
)
1940 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi disconnect\n");
1942 wmi
->traffic_class
= 100;
1944 /* Disconnect command does not need to do a SYNC before. */
1945 ret
= ath6kl_wmi_simple_cmd(wmi
, if_idx
, WMI_DISCONNECT_CMDID
);
1950 /* ath6kl_wmi_start_scan_cmd is to be deprecated. Use
1951 * ath6kl_wmi_begin_scan_cmd instead. The new function supports P2P
1952 * mgmt operations using station interface.
1954 static int ath6kl_wmi_startscan_cmd(struct wmi
*wmi
, u8 if_idx
,
1955 enum wmi_scan_type scan_type
,
1956 u32 force_fgscan
, u32 is_legacy
,
1957 u32 home_dwell_time
,
1958 u32 force_scan_interval
,
1959 s8 num_chan
, u16
*ch_list
)
1961 struct sk_buff
*skb
;
1962 struct wmi_start_scan_cmd
*sc
;
1966 size
= sizeof(struct wmi_start_scan_cmd
);
1968 if ((scan_type
!= WMI_LONG_SCAN
) && (scan_type
!= WMI_SHORT_SCAN
))
1971 if (num_chan
> WMI_MAX_CHANNELS
)
1975 size
+= sizeof(u16
) * (num_chan
- 1);
1977 skb
= ath6kl_wmi_get_new_buf(size
);
1981 sc
= (struct wmi_start_scan_cmd
*) skb
->data
;
1982 sc
->scan_type
= scan_type
;
1983 sc
->force_fg_scan
= cpu_to_le32(force_fgscan
);
1984 sc
->is_legacy
= cpu_to_le32(is_legacy
);
1985 sc
->home_dwell_time
= cpu_to_le32(home_dwell_time
);
1986 sc
->force_scan_intvl
= cpu_to_le32(force_scan_interval
);
1987 sc
->num_ch
= num_chan
;
1989 for (i
= 0; i
< num_chan
; i
++)
1990 sc
->ch_list
[i
] = cpu_to_le16(ch_list
[i
]);
1992 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_START_SCAN_CMDID
,
1999 * beginscan supports (compared to old startscan) P2P mgmt operations using
2000 * station interface, send additional information like supported rates to
2001 * advertise and xmit rates for probe requests
2003 int ath6kl_wmi_beginscan_cmd(struct wmi
*wmi
, u8 if_idx
,
2004 enum wmi_scan_type scan_type
,
2005 u32 force_fgscan
, u32 is_legacy
,
2006 u32 home_dwell_time
, u32 force_scan_interval
,
2007 s8 num_chan
, u16
*ch_list
, u32 no_cck
, u32
*rates
)
2009 struct ieee80211_supported_band
*sband
;
2010 struct sk_buff
*skb
;
2011 struct wmi_begin_scan_cmd
*sc
;
2012 s8 size
, *supp_rates
;
2014 struct ath6kl
*ar
= wmi
->parent_dev
;
2018 if (!test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX
,
2019 ar
->fw_capabilities
)) {
2020 return ath6kl_wmi_startscan_cmd(wmi
, if_idx
,
2021 scan_type
, force_fgscan
,
2022 is_legacy
, home_dwell_time
,
2023 force_scan_interval
,
2027 size
= sizeof(struct wmi_begin_scan_cmd
);
2029 if ((scan_type
!= WMI_LONG_SCAN
) && (scan_type
!= WMI_SHORT_SCAN
))
2032 if (num_chan
> WMI_MAX_CHANNELS
)
2036 size
+= sizeof(u16
) * (num_chan
- 1);
2038 skb
= ath6kl_wmi_get_new_buf(size
);
2042 sc
= (struct wmi_begin_scan_cmd
*) skb
->data
;
2043 sc
->scan_type
= scan_type
;
2044 sc
->force_fg_scan
= cpu_to_le32(force_fgscan
);
2045 sc
->is_legacy
= cpu_to_le32(is_legacy
);
2046 sc
->home_dwell_time
= cpu_to_le32(home_dwell_time
);
2047 sc
->force_scan_intvl
= cpu_to_le32(force_scan_interval
);
2048 sc
->no_cck
= cpu_to_le32(no_cck
);
2049 sc
->num_ch
= num_chan
;
2051 for (band
= 0; band
< NUM_NL80211_BANDS
; band
++) {
2052 sband
= ar
->wiphy
->bands
[band
];
2057 if (WARN_ON(band
>= ATH6KL_NUM_BANDS
))
2060 ratemask
= rates
[band
];
2061 supp_rates
= sc
->supp_rates
[band
].rates
;
2064 for (i
= 0; i
< sband
->n_bitrates
; i
++) {
2065 if ((BIT(i
) & ratemask
) == 0)
2066 continue; /* skip rate */
2067 supp_rates
[num_rates
++] =
2068 (u8
) (sband
->bitrates
[i
].bitrate
/ 5);
2070 sc
->supp_rates
[band
].nrates
= num_rates
;
2073 for (i
= 0; i
< num_chan
; i
++)
2074 sc
->ch_list
[i
] = cpu_to_le16(ch_list
[i
]);
2076 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_BEGIN_SCAN_CMDID
,
2082 int ath6kl_wmi_enable_sched_scan_cmd(struct wmi
*wmi
, u8 if_idx
, bool enable
)
2084 struct sk_buff
*skb
;
2085 struct wmi_enable_sched_scan_cmd
*sc
;
2088 skb
= ath6kl_wmi_get_new_buf(sizeof(*sc
));
2092 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s scheduled scan on vif %d\n",
2093 enable
? "enabling" : "disabling", if_idx
);
2094 sc
= (struct wmi_enable_sched_scan_cmd
*) skb
->data
;
2095 sc
->enable
= enable
? 1 : 0;
2097 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
2098 WMI_ENABLE_SCHED_SCAN_CMDID
,
2103 int ath6kl_wmi_scanparams_cmd(struct wmi
*wmi
, u8 if_idx
,
2105 u16 fg_end_sec
, u16 bg_sec
,
2106 u16 minact_chdw_msec
, u16 maxact_chdw_msec
,
2107 u16 pas_chdw_msec
, u8 short_scan_ratio
,
2108 u8 scan_ctrl_flag
, u32 max_dfsch_act_time
,
2109 u16 maxact_scan_per_ssid
)
2111 struct sk_buff
*skb
;
2112 struct wmi_scan_params_cmd
*sc
;
2115 skb
= ath6kl_wmi_get_new_buf(sizeof(*sc
));
2119 sc
= (struct wmi_scan_params_cmd
*) skb
->data
;
2120 sc
->fg_start_period
= cpu_to_le16(fg_start_sec
);
2121 sc
->fg_end_period
= cpu_to_le16(fg_end_sec
);
2122 sc
->bg_period
= cpu_to_le16(bg_sec
);
2123 sc
->minact_chdwell_time
= cpu_to_le16(minact_chdw_msec
);
2124 sc
->maxact_chdwell_time
= cpu_to_le16(maxact_chdw_msec
);
2125 sc
->pas_chdwell_time
= cpu_to_le16(pas_chdw_msec
);
2126 sc
->short_scan_ratio
= short_scan_ratio
;
2127 sc
->scan_ctrl_flags
= scan_ctrl_flag
;
2128 sc
->max_dfsch_act_time
= cpu_to_le32(max_dfsch_act_time
);
2129 sc
->maxact_scan_per_ssid
= cpu_to_le16(maxact_scan_per_ssid
);
2131 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_SCAN_PARAMS_CMDID
,
2136 int ath6kl_wmi_bssfilter_cmd(struct wmi
*wmi
, u8 if_idx
, u8 filter
, u32 ie_mask
)
2138 struct sk_buff
*skb
;
2139 struct wmi_bss_filter_cmd
*cmd
;
2142 if (filter
>= LAST_BSS_FILTER
)
2145 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2149 cmd
= (struct wmi_bss_filter_cmd
*) skb
->data
;
2150 cmd
->bss_filter
= filter
;
2151 cmd
->ie_mask
= cpu_to_le32(ie_mask
);
2153 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_BSS_FILTER_CMDID
,
2158 int ath6kl_wmi_probedssid_cmd(struct wmi
*wmi
, u8 if_idx
, u8 index
, u8 flag
,
2159 u8 ssid_len
, u8
*ssid
)
2161 struct sk_buff
*skb
;
2162 struct wmi_probed_ssid_cmd
*cmd
;
2165 if (index
>= MAX_PROBED_SSIDS
)
2168 if (ssid_len
> sizeof(cmd
->ssid
))
2171 if ((flag
& (DISABLE_SSID_FLAG
| ANY_SSID_FLAG
)) && (ssid_len
> 0))
2174 if ((flag
& SPECIFIC_SSID_FLAG
) && !ssid_len
)
2177 if (flag
& SPECIFIC_SSID_FLAG
)
2178 wmi
->is_probe_ssid
= true;
2180 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2184 cmd
= (struct wmi_probed_ssid_cmd
*) skb
->data
;
2185 cmd
->entry_index
= index
;
2187 cmd
->ssid_len
= ssid_len
;
2188 memcpy(cmd
->ssid
, ssid
, ssid_len
);
2190 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_PROBED_SSID_CMDID
,
2195 int ath6kl_wmi_listeninterval_cmd(struct wmi
*wmi
, u8 if_idx
,
2196 u16 listen_interval
,
2199 struct sk_buff
*skb
;
2200 struct wmi_listen_int_cmd
*cmd
;
2203 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2207 cmd
= (struct wmi_listen_int_cmd
*) skb
->data
;
2208 cmd
->listen_intvl
= cpu_to_le16(listen_interval
);
2209 cmd
->num_beacons
= cpu_to_le16(listen_beacons
);
2211 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_LISTEN_INT_CMDID
,
2216 int ath6kl_wmi_bmisstime_cmd(struct wmi
*wmi
, u8 if_idx
,
2217 u16 bmiss_time
, u16 num_beacons
)
2219 struct sk_buff
*skb
;
2220 struct wmi_bmiss_time_cmd
*cmd
;
2223 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2227 cmd
= (struct wmi_bmiss_time_cmd
*) skb
->data
;
2228 cmd
->bmiss_time
= cpu_to_le16(bmiss_time
);
2229 cmd
->num_beacons
= cpu_to_le16(num_beacons
);
2231 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_BMISS_TIME_CMDID
,
2236 int ath6kl_wmi_powermode_cmd(struct wmi
*wmi
, u8 if_idx
, u8 pwr_mode
)
2238 struct sk_buff
*skb
;
2239 struct wmi_power_mode_cmd
*cmd
;
2242 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2246 cmd
= (struct wmi_power_mode_cmd
*) skb
->data
;
2247 cmd
->pwr_mode
= pwr_mode
;
2248 wmi
->pwr_mode
= pwr_mode
;
2250 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_POWER_MODE_CMDID
,
2255 int ath6kl_wmi_pmparams_cmd(struct wmi
*wmi
, u8 if_idx
, u16 idle_period
,
2256 u16 ps_poll_num
, u16 dtim_policy
,
2257 u16 tx_wakeup_policy
, u16 num_tx_to_wakeup
,
2258 u16 ps_fail_event_policy
)
2260 struct sk_buff
*skb
;
2261 struct wmi_power_params_cmd
*pm
;
2264 skb
= ath6kl_wmi_get_new_buf(sizeof(*pm
));
2268 pm
= (struct wmi_power_params_cmd
*)skb
->data
;
2269 pm
->idle_period
= cpu_to_le16(idle_period
);
2270 pm
->pspoll_number
= cpu_to_le16(ps_poll_num
);
2271 pm
->dtim_policy
= cpu_to_le16(dtim_policy
);
2272 pm
->tx_wakeup_policy
= cpu_to_le16(tx_wakeup_policy
);
2273 pm
->num_tx_to_wakeup
= cpu_to_le16(num_tx_to_wakeup
);
2274 pm
->ps_fail_event_policy
= cpu_to_le16(ps_fail_event_policy
);
2276 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_POWER_PARAMS_CMDID
,
2281 int ath6kl_wmi_disctimeout_cmd(struct wmi
*wmi
, u8 if_idx
, u8 timeout
)
2283 struct sk_buff
*skb
;
2284 struct wmi_disc_timeout_cmd
*cmd
;
2287 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2291 cmd
= (struct wmi_disc_timeout_cmd
*) skb
->data
;
2292 cmd
->discon_timeout
= timeout
;
2294 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_DISC_TIMEOUT_CMDID
,
2298 ath6kl_debug_set_disconnect_timeout(wmi
->parent_dev
, timeout
);
2303 int ath6kl_wmi_addkey_cmd(struct wmi
*wmi
, u8 if_idx
, u8 key_index
,
2304 enum crypto_type key_type
,
2305 u8 key_usage
, u8 key_len
,
2306 u8
*key_rsc
, unsigned int key_rsc_len
,
2308 u8 key_op_ctrl
, u8
*mac_addr
,
2309 enum wmi_sync_flag sync_flag
)
2311 struct sk_buff
*skb
;
2312 struct wmi_add_cipher_key_cmd
*cmd
;
2315 ath6kl_dbg(ATH6KL_DBG_WMI
,
2316 "addkey cmd: key_index=%u key_type=%d key_usage=%d key_len=%d key_op_ctrl=%d\n",
2317 key_index
, key_type
, key_usage
, key_len
, key_op_ctrl
);
2319 if ((key_index
> WMI_MAX_KEY_INDEX
) || (key_len
> WMI_MAX_KEY_LEN
) ||
2320 (key_material
== NULL
) || key_rsc_len
> 8)
2323 if ((WEP_CRYPT
!= key_type
) && (NULL
== key_rsc
))
2326 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2330 cmd
= (struct wmi_add_cipher_key_cmd
*) skb
->data
;
2331 cmd
->key_index
= key_index
;
2332 cmd
->key_type
= key_type
;
2333 cmd
->key_usage
= key_usage
;
2334 cmd
->key_len
= key_len
;
2335 memcpy(cmd
->key
, key_material
, key_len
);
2337 if (key_rsc
!= NULL
)
2338 memcpy(cmd
->key_rsc
, key_rsc
, key_rsc_len
);
2340 cmd
->key_op_ctrl
= key_op_ctrl
;
2343 memcpy(cmd
->key_mac_addr
, mac_addr
, ETH_ALEN
);
2345 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_ADD_CIPHER_KEY_CMDID
,
2351 int ath6kl_wmi_add_krk_cmd(struct wmi
*wmi
, u8 if_idx
, const u8
*krk
)
2353 struct sk_buff
*skb
;
2354 struct wmi_add_krk_cmd
*cmd
;
2357 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2361 cmd
= (struct wmi_add_krk_cmd
*) skb
->data
;
2362 memcpy(cmd
->krk
, krk
, WMI_KRK_LEN
);
2364 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_ADD_KRK_CMDID
,
2370 int ath6kl_wmi_deletekey_cmd(struct wmi
*wmi
, u8 if_idx
, u8 key_index
)
2372 struct sk_buff
*skb
;
2373 struct wmi_delete_cipher_key_cmd
*cmd
;
2376 if (key_index
> WMI_MAX_KEY_INDEX
)
2379 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2383 cmd
= (struct wmi_delete_cipher_key_cmd
*) skb
->data
;
2384 cmd
->key_index
= key_index
;
2386 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_DELETE_CIPHER_KEY_CMDID
,
2392 int ath6kl_wmi_setpmkid_cmd(struct wmi
*wmi
, u8 if_idx
, const u8
*bssid
,
2393 const u8
*pmkid
, bool set
)
2395 struct sk_buff
*skb
;
2396 struct wmi_setpmkid_cmd
*cmd
;
2402 if (set
&& pmkid
== NULL
)
2405 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2409 cmd
= (struct wmi_setpmkid_cmd
*) skb
->data
;
2410 memcpy(cmd
->bssid
, bssid
, ETH_ALEN
);
2412 memcpy(cmd
->pmkid
, pmkid
, sizeof(cmd
->pmkid
));
2413 cmd
->enable
= PMKID_ENABLE
;
2415 memset(cmd
->pmkid
, 0, sizeof(cmd
->pmkid
));
2416 cmd
->enable
= PMKID_DISABLE
;
2419 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_PMKID_CMDID
,
2425 static int ath6kl_wmi_data_sync_send(struct wmi
*wmi
, struct sk_buff
*skb
,
2426 enum htc_endpoint_id ep_id
, u8 if_idx
)
2428 struct wmi_data_hdr
*data_hdr
;
2431 if (WARN_ON(skb
== NULL
|| ep_id
== wmi
->ep_id
)) {
2436 skb_push(skb
, sizeof(struct wmi_data_hdr
));
2438 data_hdr
= (struct wmi_data_hdr
*) skb
->data
;
2439 data_hdr
->info
= SYNC_MSGTYPE
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
2440 data_hdr
->info3
= cpu_to_le16(if_idx
& WMI_DATA_HDR_IF_IDX_MASK
);
2442 ret
= ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
2447 static int ath6kl_wmi_sync_point(struct wmi
*wmi
, u8 if_idx
)
2449 struct sk_buff
*skb
;
2450 struct wmi_sync_cmd
*cmd
;
2451 struct wmi_data_sync_bufs data_sync_bufs
[WMM_NUM_AC
];
2452 enum htc_endpoint_id ep_id
;
2453 u8 index
, num_pri_streams
= 0;
2456 memset(data_sync_bufs
, 0, sizeof(data_sync_bufs
));
2458 spin_lock_bh(&wmi
->lock
);
2460 for (index
= 0; index
< WMM_NUM_AC
; index
++) {
2461 if (wmi
->fat_pipe_exist
& (1 << index
)) {
2463 data_sync_bufs
[num_pri_streams
- 1].traffic_class
=
2468 spin_unlock_bh(&wmi
->lock
);
2470 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2474 cmd
= (struct wmi_sync_cmd
*) skb
->data
;
2477 * In the SYNC cmd sent on the control Ep, send a bitmap
2478 * of the data eps on which the Data Sync will be sent
2480 cmd
->data_sync_map
= wmi
->fat_pipe_exist
;
2482 for (index
= 0; index
< num_pri_streams
; index
++) {
2483 data_sync_bufs
[index
].skb
= ath6kl_buf_alloc(0);
2484 if (data_sync_bufs
[index
].skb
== NULL
) {
2491 * If buffer allocation for any of the dataSync fails,
2492 * then do not send the Synchronize cmd on the control ep
2498 * Send sync cmd followed by sync data messages on all
2499 * endpoints being used
2501 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SYNCHRONIZE_CMDID
,
2507 for (index
= 0; index
< num_pri_streams
; index
++) {
2508 if (WARN_ON(!data_sync_bufs
[index
].skb
))
2511 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
,
2512 data_sync_bufs
[index
].
2515 ath6kl_wmi_data_sync_send(wmi
, data_sync_bufs
[index
].skb
,
2518 data_sync_bufs
[index
].skb
= NULL
;
2527 /* free up any resources left over (possibly due to an error) */
2531 for (index
= 0; index
< num_pri_streams
; index
++)
2532 dev_kfree_skb((struct sk_buff
*)data_sync_bufs
[index
].skb
);
2537 int ath6kl_wmi_create_pstream_cmd(struct wmi
*wmi
, u8 if_idx
,
2538 struct wmi_create_pstream_cmd
*params
)
2540 struct sk_buff
*skb
;
2541 struct wmi_create_pstream_cmd
*cmd
;
2542 u8 fatpipe_exist_for_ac
= 0;
2544 s32 nominal_phy
= 0;
2547 if (!((params
->user_pri
<= 0x7) &&
2548 (up_to_ac
[params
->user_pri
& 0x7] == params
->traffic_class
) &&
2549 (params
->traffic_direc
== UPLINK_TRAFFIC
||
2550 params
->traffic_direc
== DNLINK_TRAFFIC
||
2551 params
->traffic_direc
== BIDIR_TRAFFIC
) &&
2552 (params
->traffic_type
== TRAFFIC_TYPE_APERIODIC
||
2553 params
->traffic_type
== TRAFFIC_TYPE_PERIODIC
) &&
2554 (params
->voice_psc_cap
== DISABLE_FOR_THIS_AC
||
2555 params
->voice_psc_cap
== ENABLE_FOR_THIS_AC
||
2556 params
->voice_psc_cap
== ENABLE_FOR_ALL_AC
) &&
2557 (params
->tsid
== WMI_IMPLICIT_PSTREAM
||
2558 params
->tsid
<= WMI_MAX_THINSTREAM
))) {
2563 * Check nominal PHY rate is >= minimalPHY,
2564 * so that DUT can allow TSRS IE
2567 /* Get the physical rate (units of bps) */
2568 min_phy
= ((le32_to_cpu(params
->min_phy_rate
) / 1000) / 1000);
2570 /* Check minimal phy < nominal phy rate */
2571 if (params
->nominal_phy
>= min_phy
) {
2572 /* unit of 500 kbps */
2573 nominal_phy
= (params
->nominal_phy
* 1000) / 500;
2574 ath6kl_dbg(ATH6KL_DBG_WMI
,
2575 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2576 min_phy
, nominal_phy
);
2578 params
->nominal_phy
= nominal_phy
;
2580 params
->nominal_phy
= 0;
2583 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2587 ath6kl_dbg(ATH6KL_DBG_WMI
,
2588 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2589 params
->traffic_class
, params
->tsid
);
2591 cmd
= (struct wmi_create_pstream_cmd
*) skb
->data
;
2592 memcpy(cmd
, params
, sizeof(*cmd
));
2594 /* This is an implicitly created Fat pipe */
2595 if ((u32
) params
->tsid
== (u32
) WMI_IMPLICIT_PSTREAM
) {
2596 spin_lock_bh(&wmi
->lock
);
2597 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2598 (1 << params
->traffic_class
));
2599 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2600 spin_unlock_bh(&wmi
->lock
);
2602 /* explicitly created thin stream within a fat pipe */
2603 spin_lock_bh(&wmi
->lock
);
2604 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2605 (1 << params
->traffic_class
));
2606 wmi
->stream_exist_for_ac
[params
->traffic_class
] |=
2607 (1 << params
->tsid
);
2609 * If a thinstream becomes active, the fat pipe automatically
2612 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2613 spin_unlock_bh(&wmi
->lock
);
2617 * Indicate activty change to driver layer only if this is the
2618 * first TSID to get created in this AC explicitly or an implicit
2619 * fat pipe is getting created.
2621 if (!fatpipe_exist_for_ac
)
2622 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2623 params
->traffic_class
, true);
2625 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_CREATE_PSTREAM_CMDID
,
2630 int ath6kl_wmi_delete_pstream_cmd(struct wmi
*wmi
, u8 if_idx
, u8 traffic_class
,
2633 struct sk_buff
*skb
;
2634 struct wmi_delete_pstream_cmd
*cmd
;
2635 u16 active_tsids
= 0;
2638 if (traffic_class
> 3) {
2639 ath6kl_err("invalid traffic class: %d\n", traffic_class
);
2643 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2647 cmd
= (struct wmi_delete_pstream_cmd
*) skb
->data
;
2648 cmd
->traffic_class
= traffic_class
;
2651 spin_lock_bh(&wmi
->lock
);
2652 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2653 spin_unlock_bh(&wmi
->lock
);
2655 if (!(active_tsids
& (1 << tsid
))) {
2657 ath6kl_dbg(ATH6KL_DBG_WMI
,
2658 "TSID %d doesn't exist for traffic class: %d\n",
2659 tsid
, traffic_class
);
2663 ath6kl_dbg(ATH6KL_DBG_WMI
,
2664 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2665 traffic_class
, tsid
);
2667 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_DELETE_PSTREAM_CMDID
,
2668 SYNC_BEFORE_WMIFLAG
);
2670 spin_lock_bh(&wmi
->lock
);
2671 wmi
->stream_exist_for_ac
[traffic_class
] &= ~(1 << tsid
);
2672 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2673 spin_unlock_bh(&wmi
->lock
);
2676 * Indicate stream inactivity to driver layer only if all tsids
2677 * within this AC are deleted.
2679 if (!active_tsids
) {
2680 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2681 traffic_class
, false);
2682 wmi
->fat_pipe_exist
&= ~(1 << traffic_class
);
2688 int ath6kl_wmi_set_ip_cmd(struct wmi
*wmi
, u8 if_idx
,
2689 __be32 ips0
, __be32 ips1
)
2691 struct sk_buff
*skb
;
2692 struct wmi_set_ip_cmd
*cmd
;
2695 /* Multicast address are not valid */
2696 if (ipv4_is_multicast(ips0
) ||
2697 ipv4_is_multicast(ips1
))
2700 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd
));
2704 cmd
= (struct wmi_set_ip_cmd
*) skb
->data
;
2708 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_IP_CMDID
,
2713 static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi
*wmi
)
2720 * Relinquish credits from all implicitly created pstreams
2721 * since when we go to sleep. If user created explicit
2722 * thinstreams exists with in a fatpipe leave them intact
2723 * for the user to delete.
2725 spin_lock_bh(&wmi
->lock
);
2726 stream_exist
= wmi
->fat_pipe_exist
;
2727 spin_unlock_bh(&wmi
->lock
);
2729 for (i
= 0; i
< WMM_NUM_AC
; i
++) {
2730 if (stream_exist
& (1 << i
)) {
2732 * FIXME: Is this lock & unlock inside
2733 * for loop correct? may need rework.
2735 spin_lock_bh(&wmi
->lock
);
2736 active_tsids
= wmi
->stream_exist_for_ac
[i
];
2737 spin_unlock_bh(&wmi
->lock
);
2740 * If there are no user created thin streams
2741 * delete the fatpipe
2743 if (!active_tsids
) {
2744 stream_exist
&= ~(1 << i
);
2746 * Indicate inactivity to driver layer for
2747 * this fatpipe (pstream)
2749 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2755 /* FIXME: Can we do this assignment without locking ? */
2756 spin_lock_bh(&wmi
->lock
);
2757 wmi
->fat_pipe_exist
= stream_exist
;
2758 spin_unlock_bh(&wmi
->lock
);
2761 static int ath6kl_set_bitrate_mask64(struct wmi
*wmi
, u8 if_idx
,
2762 const struct cfg80211_bitrate_mask
*mask
)
2764 struct sk_buff
*skb
;
2765 int ret
, mode
, band
;
2766 u64 mcsrate
, ratemask
[ATH6KL_NUM_BANDS
];
2767 struct wmi_set_tx_select_rates64_cmd
*cmd
;
2769 memset(&ratemask
, 0, sizeof(ratemask
));
2771 /* only check 2.4 and 5 GHz bands, skip the rest */
2772 for (band
= 0; band
<= NL80211_BAND_5GHZ
; band
++) {
2773 /* copy legacy rate mask */
2774 ratemask
[band
] = mask
->control
[band
].legacy
;
2775 if (band
== NL80211_BAND_5GHZ
)
2777 mask
->control
[band
].legacy
<< 4;
2779 /* copy mcs rate mask */
2780 mcsrate
= mask
->control
[band
].ht_mcs
[1];
2782 mcsrate
|= mask
->control
[band
].ht_mcs
[0];
2783 ratemask
[band
] |= mcsrate
<< 12;
2784 ratemask
[band
] |= mcsrate
<< 28;
2787 ath6kl_dbg(ATH6KL_DBG_WMI
,
2788 "Ratemask 64 bit: 2.4:%llx 5:%llx\n",
2789 ratemask
[0], ratemask
[1]);
2791 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
) * WMI_RATES_MODE_MAX
);
2795 cmd
= (struct wmi_set_tx_select_rates64_cmd
*) skb
->data
;
2796 for (mode
= 0; mode
< WMI_RATES_MODE_MAX
; mode
++) {
2797 /* A mode operate in 5GHZ band */
2798 if (mode
== WMI_RATES_MODE_11A
||
2799 mode
== WMI_RATES_MODE_11A_HT20
||
2800 mode
== WMI_RATES_MODE_11A_HT40
)
2801 band
= NL80211_BAND_5GHZ
;
2803 band
= NL80211_BAND_2GHZ
;
2804 cmd
->ratemask
[mode
] = cpu_to_le64(ratemask
[band
]);
2807 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
2808 WMI_SET_TX_SELECT_RATES_CMDID
,
2813 static int ath6kl_set_bitrate_mask32(struct wmi
*wmi
, u8 if_idx
,
2814 const struct cfg80211_bitrate_mask
*mask
)
2816 struct sk_buff
*skb
;
2817 int ret
, mode
, band
;
2818 u32 mcsrate
, ratemask
[ATH6KL_NUM_BANDS
];
2819 struct wmi_set_tx_select_rates32_cmd
*cmd
;
2821 memset(&ratemask
, 0, sizeof(ratemask
));
2823 /* only check 2.4 and 5 GHz bands, skip the rest */
2824 for (band
= 0; band
<= NL80211_BAND_5GHZ
; band
++) {
2825 /* copy legacy rate mask */
2826 ratemask
[band
] = mask
->control
[band
].legacy
;
2827 if (band
== NL80211_BAND_5GHZ
)
2829 mask
->control
[band
].legacy
<< 4;
2831 /* copy mcs rate mask */
2832 mcsrate
= mask
->control
[band
].ht_mcs
[0];
2833 ratemask
[band
] |= mcsrate
<< 12;
2834 ratemask
[band
] |= mcsrate
<< 20;
2837 ath6kl_dbg(ATH6KL_DBG_WMI
,
2838 "Ratemask 32 bit: 2.4:%x 5:%x\n",
2839 ratemask
[0], ratemask
[1]);
2841 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
) * WMI_RATES_MODE_MAX
);
2845 cmd
= (struct wmi_set_tx_select_rates32_cmd
*) skb
->data
;
2846 for (mode
= 0; mode
< WMI_RATES_MODE_MAX
; mode
++) {
2847 /* A mode operate in 5GHZ band */
2848 if (mode
== WMI_RATES_MODE_11A
||
2849 mode
== WMI_RATES_MODE_11A_HT20
||
2850 mode
== WMI_RATES_MODE_11A_HT40
)
2851 band
= NL80211_BAND_5GHZ
;
2853 band
= NL80211_BAND_2GHZ
;
2854 cmd
->ratemask
[mode
] = cpu_to_le32(ratemask
[band
]);
2857 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
2858 WMI_SET_TX_SELECT_RATES_CMDID
,
2863 int ath6kl_wmi_set_bitrate_mask(struct wmi
*wmi
, u8 if_idx
,
2864 const struct cfg80211_bitrate_mask
*mask
)
2866 struct ath6kl
*ar
= wmi
->parent_dev
;
2868 if (test_bit(ATH6KL_FW_CAPABILITY_64BIT_RATES
,
2869 ar
->fw_capabilities
))
2870 return ath6kl_set_bitrate_mask64(wmi
, if_idx
, mask
);
2872 return ath6kl_set_bitrate_mask32(wmi
, if_idx
, mask
);
2875 int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi
*wmi
, u8 if_idx
,
2876 enum ath6kl_host_mode host_mode
)
2878 struct sk_buff
*skb
;
2879 struct wmi_set_host_sleep_mode_cmd
*cmd
;
2882 if ((host_mode
!= ATH6KL_HOST_MODE_ASLEEP
) &&
2883 (host_mode
!= ATH6KL_HOST_MODE_AWAKE
)) {
2884 ath6kl_err("invalid host sleep mode: %d\n", host_mode
);
2888 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2892 cmd
= (struct wmi_set_host_sleep_mode_cmd
*) skb
->data
;
2894 if (host_mode
== ATH6KL_HOST_MODE_ASLEEP
) {
2895 ath6kl_wmi_relinquish_implicit_pstream_credits(wmi
);
2896 cmd
->asleep
= cpu_to_le32(1);
2898 cmd
->awake
= cpu_to_le32(1);
2901 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
2902 WMI_SET_HOST_SLEEP_MODE_CMDID
,
2907 /* This command has zero length payload */
2908 static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi
*wmi
,
2909 struct ath6kl_vif
*vif
)
2911 struct ath6kl
*ar
= wmi
->parent_dev
;
2913 set_bit(HOST_SLEEP_MODE_CMD_PROCESSED
, &vif
->flags
);
2914 wake_up(&ar
->event_wq
);
2919 int ath6kl_wmi_set_wow_mode_cmd(struct wmi
*wmi
, u8 if_idx
,
2920 enum ath6kl_wow_mode wow_mode
,
2921 u32 filter
, u16 host_req_delay
)
2923 struct sk_buff
*skb
;
2924 struct wmi_set_wow_mode_cmd
*cmd
;
2927 if ((wow_mode
!= ATH6KL_WOW_MODE_ENABLE
) &&
2928 wow_mode
!= ATH6KL_WOW_MODE_DISABLE
) {
2929 ath6kl_err("invalid wow mode: %d\n", wow_mode
);
2933 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2937 cmd
= (struct wmi_set_wow_mode_cmd
*) skb
->data
;
2938 cmd
->enable_wow
= cpu_to_le32(wow_mode
);
2939 cmd
->filter
= cpu_to_le32(filter
);
2940 cmd
->host_req_delay
= cpu_to_le16(host_req_delay
);
2942 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_WOW_MODE_CMDID
,
2947 int ath6kl_wmi_add_wow_pattern_cmd(struct wmi
*wmi
, u8 if_idx
,
2948 u8 list_id
, u8 filter_size
,
2949 u8 filter_offset
, const u8
*filter
,
2952 struct sk_buff
*skb
;
2953 struct wmi_add_wow_pattern_cmd
*cmd
;
2959 * Allocate additional memory in the buffer to hold
2960 * filter and mask value, which is twice of filter_size.
2962 size
= sizeof(*cmd
) + (2 * filter_size
);
2964 skb
= ath6kl_wmi_get_new_buf(size
);
2968 cmd
= (struct wmi_add_wow_pattern_cmd
*) skb
->data
;
2969 cmd
->filter_list_id
= list_id
;
2970 cmd
->filter_size
= filter_size
;
2971 cmd
->filter_offset
= filter_offset
;
2973 memcpy(cmd
->filter
, filter
, filter_size
);
2975 filter_mask
= (u8
*) (cmd
->filter
+ filter_size
);
2976 memcpy(filter_mask
, mask
, filter_size
);
2978 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_ADD_WOW_PATTERN_CMDID
,
2984 int ath6kl_wmi_del_wow_pattern_cmd(struct wmi
*wmi
, u8 if_idx
,
2985 u16 list_id
, u16 filter_id
)
2987 struct sk_buff
*skb
;
2988 struct wmi_del_wow_pattern_cmd
*cmd
;
2991 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2995 cmd
= (struct wmi_del_wow_pattern_cmd
*) skb
->data
;
2996 cmd
->filter_list_id
= cpu_to_le16(list_id
);
2997 cmd
->filter_id
= cpu_to_le16(filter_id
);
2999 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_DEL_WOW_PATTERN_CMDID
,
3004 static int ath6kl_wmi_cmd_send_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
,
3005 enum wmix_command_id cmd_id
,
3006 enum wmi_sync_flag sync_flag
)
3008 struct wmix_cmd_hdr
*cmd_hdr
;
3011 skb_push(skb
, sizeof(struct wmix_cmd_hdr
));
3013 cmd_hdr
= (struct wmix_cmd_hdr
*) skb
->data
;
3014 cmd_hdr
->cmd_id
= cpu_to_le32(cmd_id
);
3016 ret
= ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_EXTENSION_CMDID
, sync_flag
);
3021 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi
*wmi
, u32 cookie
, u32 source
)
3023 struct sk_buff
*skb
;
3024 struct wmix_hb_challenge_resp_cmd
*cmd
;
3027 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3031 cmd
= (struct wmix_hb_challenge_resp_cmd
*) skb
->data
;
3032 cmd
->cookie
= cpu_to_le32(cookie
);
3033 cmd
->source
= cpu_to_le32(source
);
3035 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_HB_CHALLENGE_RESP_CMDID
,
3040 int ath6kl_wmi_config_debug_module_cmd(struct wmi
*wmi
, u32 valid
, u32 config
)
3042 struct ath6kl_wmix_dbglog_cfg_module_cmd
*cmd
;
3043 struct sk_buff
*skb
;
3046 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3050 cmd
= (struct ath6kl_wmix_dbglog_cfg_module_cmd
*) skb
->data
;
3051 cmd
->valid
= cpu_to_le32(valid
);
3052 cmd
->config
= cpu_to_le32(config
);
3054 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_DBGLOG_CFG_MODULE_CMDID
,
3059 int ath6kl_wmi_get_stats_cmd(struct wmi
*wmi
, u8 if_idx
)
3061 return ath6kl_wmi_simple_cmd(wmi
, if_idx
, WMI_GET_STATISTICS_CMDID
);
3064 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi
*wmi
, u8 if_idx
, u8 dbM
)
3066 struct sk_buff
*skb
;
3067 struct wmi_set_tx_pwr_cmd
*cmd
;
3070 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd
));
3074 cmd
= (struct wmi_set_tx_pwr_cmd
*) skb
->data
;
3077 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_TX_PWR_CMDID
,
3083 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi
*wmi
, u8 if_idx
)
3085 return ath6kl_wmi_simple_cmd(wmi
, if_idx
, WMI_GET_TX_PWR_CMDID
);
3088 int ath6kl_wmi_get_roam_tbl_cmd(struct wmi
*wmi
)
3090 return ath6kl_wmi_simple_cmd(wmi
, 0, WMI_GET_ROAM_TBL_CMDID
);
3093 int ath6kl_wmi_set_lpreamble_cmd(struct wmi
*wmi
, u8 if_idx
, u8 status
,
3096 struct sk_buff
*skb
;
3097 struct wmi_set_lpreamble_cmd
*cmd
;
3100 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd
));
3104 cmd
= (struct wmi_set_lpreamble_cmd
*) skb
->data
;
3105 cmd
->status
= status
;
3106 cmd
->preamble_policy
= preamble_policy
;
3108 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_LPREAMBLE_CMDID
,
3113 int ath6kl_wmi_set_rts_cmd(struct wmi
*wmi
, u16 threshold
)
3115 struct sk_buff
*skb
;
3116 struct wmi_set_rts_cmd
*cmd
;
3119 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd
));
3123 cmd
= (struct wmi_set_rts_cmd
*) skb
->data
;
3124 cmd
->threshold
= cpu_to_le16(threshold
);
3126 ret
= ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SET_RTS_CMDID
,
3131 int ath6kl_wmi_set_wmm_txop(struct wmi
*wmi
, u8 if_idx
, enum wmi_txop_cfg cfg
)
3133 struct sk_buff
*skb
;
3134 struct wmi_set_wmm_txop_cmd
*cmd
;
3137 if (!((cfg
== WMI_TXOP_DISABLED
) || (cfg
== WMI_TXOP_ENABLED
)))
3140 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd
));
3144 cmd
= (struct wmi_set_wmm_txop_cmd
*) skb
->data
;
3145 cmd
->txop_enable
= cfg
;
3147 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_WMM_TXOP_CMDID
,
3152 int ath6kl_wmi_set_keepalive_cmd(struct wmi
*wmi
, u8 if_idx
,
3153 u8 keep_alive_intvl
)
3155 struct sk_buff
*skb
;
3156 struct wmi_set_keepalive_cmd
*cmd
;
3159 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3163 cmd
= (struct wmi_set_keepalive_cmd
*) skb
->data
;
3164 cmd
->keep_alive_intvl
= keep_alive_intvl
;
3166 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_KEEPALIVE_CMDID
,
3170 ath6kl_debug_set_keepalive(wmi
->parent_dev
, keep_alive_intvl
);
3175 int ath6kl_wmi_set_htcap_cmd(struct wmi
*wmi
, u8 if_idx
,
3176 enum nl80211_band band
,
3177 struct ath6kl_htcap
*htcap
)
3179 struct sk_buff
*skb
;
3180 struct wmi_set_htcap_cmd
*cmd
;
3182 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3186 cmd
= (struct wmi_set_htcap_cmd
*) skb
->data
;
3189 * NOTE: Band in firmware matches enum nl80211_band, it is unlikely
3190 * this will be changed in firmware. If at all there is any change in
3191 * band value, the host needs to be fixed.
3194 cmd
->ht_enable
= !!htcap
->ht_enable
;
3195 cmd
->ht20_sgi
= !!(htcap
->cap_info
& IEEE80211_HT_CAP_SGI_20
);
3196 cmd
->ht40_supported
=
3197 !!(htcap
->cap_info
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
);
3198 cmd
->ht40_sgi
= !!(htcap
->cap_info
& IEEE80211_HT_CAP_SGI_40
);
3199 cmd
->intolerant_40mhz
=
3200 !!(htcap
->cap_info
& IEEE80211_HT_CAP_40MHZ_INTOLERANT
);
3201 cmd
->max_ampdu_len_exp
= htcap
->ampdu_factor
;
3203 ath6kl_dbg(ATH6KL_DBG_WMI
,
3204 "Set htcap: band:%d ht_enable:%d 40mhz:%d sgi_20mhz:%d sgi_40mhz:%d 40mhz_intolerant:%d ampdu_len_exp:%d\n",
3205 cmd
->band
, cmd
->ht_enable
, cmd
->ht40_supported
,
3206 cmd
->ht20_sgi
, cmd
->ht40_sgi
, cmd
->intolerant_40mhz
,
3207 cmd
->max_ampdu_len_exp
);
3208 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_HT_CAP_CMDID
,
3212 int ath6kl_wmi_test_cmd(struct wmi
*wmi
, void *buf
, size_t len
)
3214 struct sk_buff
*skb
;
3217 skb
= ath6kl_wmi_get_new_buf(len
);
3221 memcpy(skb
->data
, buf
, len
);
3223 ret
= ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_TEST_CMDID
, NO_SYNC_WMIFLAG
);
3228 int ath6kl_wmi_mcast_filter_cmd(struct wmi
*wmi
, u8 if_idx
, bool mc_all_on
)
3230 struct sk_buff
*skb
;
3231 struct wmi_mcast_filter_cmd
*cmd
;
3234 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3238 cmd
= (struct wmi_mcast_filter_cmd
*) skb
->data
;
3239 cmd
->mcast_all_enable
= mc_all_on
;
3241 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_MCAST_FILTER_CMDID
,
3246 int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi
*wmi
, u8 if_idx
,
3247 u8
*filter
, bool add_filter
)
3249 struct sk_buff
*skb
;
3250 struct wmi_mcast_filter_add_del_cmd
*cmd
;
3253 if ((filter
[0] != 0x33 || filter
[1] != 0x33) &&
3254 (filter
[0] != 0x01 || filter
[1] != 0x00 ||
3255 filter
[2] != 0x5e || filter
[3] > 0x7f)) {
3256 ath6kl_warn("invalid multicast filter address\n");
3260 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3264 cmd
= (struct wmi_mcast_filter_add_del_cmd
*) skb
->data
;
3265 memcpy(cmd
->mcast_mac
, filter
, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE
);
3266 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
3267 add_filter
? WMI_SET_MCAST_FILTER_CMDID
:
3268 WMI_DEL_MCAST_FILTER_CMDID
,
3274 int ath6kl_wmi_sta_bmiss_enhance_cmd(struct wmi
*wmi
, u8 if_idx
, bool enhance
)
3276 struct sk_buff
*skb
;
3277 struct wmi_sta_bmiss_enhance_cmd
*cmd
;
3280 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3284 cmd
= (struct wmi_sta_bmiss_enhance_cmd
*) skb
->data
;
3285 cmd
->enable
= enhance
? 1 : 0;
3287 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
3288 WMI_STA_BMISS_ENHANCE_CMDID
,
3293 int ath6kl_wmi_set_regdomain_cmd(struct wmi
*wmi
, const char *alpha2
)
3295 struct sk_buff
*skb
;
3296 struct wmi_set_regdomain_cmd
*cmd
;
3298 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3302 cmd
= (struct wmi_set_regdomain_cmd
*) skb
->data
;
3303 memcpy(cmd
->iso_name
, alpha2
, 2);
3305 return ath6kl_wmi_cmd_send(wmi
, 0, skb
,
3306 WMI_SET_REGDOMAIN_CMDID
,
3310 s32
ath6kl_wmi_get_rate(struct wmi
*wmi
, s8 rate_index
)
3312 struct ath6kl
*ar
= wmi
->parent_dev
;
3316 if (rate_index
== RATE_AUTO
)
3319 /* SGI is stored as the MSB of the rate_index */
3320 if (rate_index
& RATE_INDEX_MSB
) {
3321 rate_index
&= RATE_INDEX_WITHOUT_SGI_MASK
;
3325 if (test_bit(ATH6KL_FW_CAPABILITY_RATETABLE_MCS15
,
3326 ar
->fw_capabilities
)) {
3327 if (WARN_ON(rate_index
>= ARRAY_SIZE(wmi_rate_tbl_mcs15
)))
3330 ret
= wmi_rate_tbl_mcs15
[(u32
) rate_index
][sgi
];
3332 if (WARN_ON(rate_index
>= ARRAY_SIZE(wmi_rate_tbl
)))
3335 ret
= wmi_rate_tbl
[(u32
) rate_index
][sgi
];
3341 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi
*wmi
, u8
*datap
,
3344 struct wmi_pmkid_list_reply
*reply
;
3347 if (len
< sizeof(struct wmi_pmkid_list_reply
))
3350 reply
= (struct wmi_pmkid_list_reply
*)datap
;
3351 expected_len
= sizeof(reply
->num_pmkid
) +
3352 le32_to_cpu(reply
->num_pmkid
) * WMI_PMKID_LEN
;
3354 if (len
< expected_len
)
3360 static int ath6kl_wmi_addba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
3361 struct ath6kl_vif
*vif
)
3363 struct wmi_addba_req_event
*cmd
= (struct wmi_addba_req_event
*) datap
;
3365 aggr_recv_addba_req_evt(vif
, cmd
->tid
,
3366 le16_to_cpu(cmd
->st_seq_no
), cmd
->win_sz
);
3371 static int ath6kl_wmi_delba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
3372 struct ath6kl_vif
*vif
)
3374 struct wmi_delba_event
*cmd
= (struct wmi_delba_event
*) datap
;
3376 aggr_recv_delba_req_evt(vif
, cmd
->tid
);
3381 /* AP mode functions */
3383 int ath6kl_wmi_ap_profile_commit(struct wmi
*wmip
, u8 if_idx
,
3384 struct wmi_connect_cmd
*p
)
3386 struct sk_buff
*skb
;
3387 struct wmi_connect_cmd
*cm
;
3390 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
3394 cm
= (struct wmi_connect_cmd
*) skb
->data
;
3395 memcpy(cm
, p
, sizeof(*cm
));
3397 res
= ath6kl_wmi_cmd_send(wmip
, if_idx
, skb
, WMI_AP_CONFIG_COMMIT_CMDID
,
3399 ath6kl_dbg(ATH6KL_DBG_WMI
,
3400 "%s: nw_type=%u auth_mode=%u ch=%u ctrl_flags=0x%x-> res=%d\n",
3401 __func__
, p
->nw_type
, p
->auth_mode
, le16_to_cpu(p
->ch
),
3402 le32_to_cpu(p
->ctrl_flags
), res
);
3406 int ath6kl_wmi_ap_set_mlme(struct wmi
*wmip
, u8 if_idx
, u8 cmd
, const u8
*mac
,
3409 struct sk_buff
*skb
;
3410 struct wmi_ap_set_mlme_cmd
*cm
;
3412 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
3416 cm
= (struct wmi_ap_set_mlme_cmd
*) skb
->data
;
3417 memcpy(cm
->mac
, mac
, ETH_ALEN
);
3418 cm
->reason
= cpu_to_le16(reason
);
3421 ath6kl_dbg(ATH6KL_DBG_WMI
, "ap_set_mlme: cmd=%d reason=%d\n", cm
->cmd
,
3424 return ath6kl_wmi_cmd_send(wmip
, if_idx
, skb
, WMI_AP_SET_MLME_CMDID
,
3428 int ath6kl_wmi_ap_hidden_ssid(struct wmi
*wmi
, u8 if_idx
, bool enable
)
3430 struct sk_buff
*skb
;
3431 struct wmi_ap_hidden_ssid_cmd
*cmd
;
3433 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3437 cmd
= (struct wmi_ap_hidden_ssid_cmd
*) skb
->data
;
3438 cmd
->hidden_ssid
= enable
? 1 : 0;
3440 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_AP_HIDDEN_SSID_CMDID
,
3444 /* This command will be used to enable/disable AP uAPSD feature */
3445 int ath6kl_wmi_ap_set_apsd(struct wmi
*wmi
, u8 if_idx
, u8 enable
)
3447 struct wmi_ap_set_apsd_cmd
*cmd
;
3448 struct sk_buff
*skb
;
3450 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3454 cmd
= (struct wmi_ap_set_apsd_cmd
*)skb
->data
;
3455 cmd
->enable
= enable
;
3457 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_AP_SET_APSD_CMDID
,
3461 int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi
*wmi
, u8 if_idx
,
3462 u16 aid
, u16 bitmap
, u32 flags
)
3464 struct wmi_ap_apsd_buffered_traffic_cmd
*cmd
;
3465 struct sk_buff
*skb
;
3467 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3471 cmd
= (struct wmi_ap_apsd_buffered_traffic_cmd
*)skb
->data
;
3472 cmd
->aid
= cpu_to_le16(aid
);
3473 cmd
->bitmap
= cpu_to_le16(bitmap
);
3474 cmd
->flags
= cpu_to_le32(flags
);
3476 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
3477 WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID
,
3481 static int ath6kl_wmi_pspoll_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
3482 struct ath6kl_vif
*vif
)
3484 struct wmi_pspoll_event
*ev
;
3486 if (len
< sizeof(struct wmi_pspoll_event
))
3489 ev
= (struct wmi_pspoll_event
*) datap
;
3491 ath6kl_pspoll_event(vif
, le16_to_cpu(ev
->aid
));
3496 static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
3497 struct ath6kl_vif
*vif
)
3499 ath6kl_dtimexpiry_event(vif
);
3504 int ath6kl_wmi_set_pvb_cmd(struct wmi
*wmi
, u8 if_idx
, u16 aid
,
3507 struct sk_buff
*skb
;
3508 struct wmi_ap_set_pvb_cmd
*cmd
;
3511 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd
));
3515 cmd
= (struct wmi_ap_set_pvb_cmd
*) skb
->data
;
3516 cmd
->aid
= cpu_to_le16(aid
);
3517 cmd
->rsvd
= cpu_to_le16(0);
3518 cmd
->flag
= cpu_to_le32(flag
);
3520 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_AP_SET_PVB_CMDID
,
3526 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi
*wmi
, u8 if_idx
,
3528 bool rx_dot11_hdr
, bool defrag_on_host
)
3530 struct sk_buff
*skb
;
3531 struct wmi_rx_frame_format_cmd
*cmd
;
3534 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3538 cmd
= (struct wmi_rx_frame_format_cmd
*) skb
->data
;
3539 cmd
->dot11_hdr
= rx_dot11_hdr
? 1 : 0;
3540 cmd
->defrag_on_host
= defrag_on_host
? 1 : 0;
3541 cmd
->meta_ver
= rx_meta_ver
;
3543 /* Delete the local aggr state, on host */
3544 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_RX_FRAME_FORMAT_CMDID
,
3550 int ath6kl_wmi_set_appie_cmd(struct wmi
*wmi
, u8 if_idx
, u8 mgmt_frm_type
,
3551 const u8
*ie
, u8 ie_len
)
3553 struct sk_buff
*skb
;
3554 struct wmi_set_appie_cmd
*p
;
3556 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + ie_len
);
3560 ath6kl_dbg(ATH6KL_DBG_WMI
,
3561 "set_appie_cmd: mgmt_frm_type=%u ie_len=%u\n",
3562 mgmt_frm_type
, ie_len
);
3563 p
= (struct wmi_set_appie_cmd
*) skb
->data
;
3564 p
->mgmt_frm_type
= mgmt_frm_type
;
3567 if (ie
!= NULL
&& ie_len
> 0)
3568 memcpy(p
->ie_info
, ie
, ie_len
);
3570 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_APPIE_CMDID
,
3574 int ath6kl_wmi_set_ie_cmd(struct wmi
*wmi
, u8 if_idx
, u8 ie_id
, u8 ie_field
,
3575 const u8
*ie_info
, u8 ie_len
)
3577 struct sk_buff
*skb
;
3578 struct wmi_set_ie_cmd
*p
;
3580 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + ie_len
);
3584 ath6kl_dbg(ATH6KL_DBG_WMI
, "set_ie_cmd: ie_id=%u ie_ie_field=%u ie_len=%u\n",
3585 ie_id
, ie_field
, ie_len
);
3586 p
= (struct wmi_set_ie_cmd
*) skb
->data
;
3588 p
->ie_field
= ie_field
;
3590 if (ie_info
&& ie_len
> 0)
3591 memcpy(p
->ie_info
, ie_info
, ie_len
);
3593 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_IE_CMDID
,
3597 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi
*wmi
, bool disable
)
3599 struct sk_buff
*skb
;
3600 struct wmi_disable_11b_rates_cmd
*cmd
;
3602 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3606 ath6kl_dbg(ATH6KL_DBG_WMI
, "disable_11b_rates_cmd: disable=%u\n",
3608 cmd
= (struct wmi_disable_11b_rates_cmd
*) skb
->data
;
3609 cmd
->disable
= disable
? 1 : 0;
3611 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_DISABLE_11B_RATES_CMDID
,
3615 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi
*wmi
, u8 if_idx
, u32 freq
, u32 dur
)
3617 struct sk_buff
*skb
;
3618 struct wmi_remain_on_chnl_cmd
*p
;
3620 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
3624 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl_cmd: freq=%u dur=%u\n",
3626 p
= (struct wmi_remain_on_chnl_cmd
*) skb
->data
;
3627 p
->freq
= cpu_to_le32(freq
);
3628 p
->duration
= cpu_to_le32(dur
);
3629 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_REMAIN_ON_CHNL_CMDID
,
3633 /* ath6kl_wmi_send_action_cmd is to be deprecated. Use
3634 * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P
3635 * mgmt operations using station interface.
3637 static int ath6kl_wmi_send_action_cmd(struct wmi
*wmi
, u8 if_idx
, u32 id
,
3638 u32 freq
, u32 wait
, const u8
*data
,
3641 struct sk_buff
*skb
;
3642 struct wmi_send_action_cmd
*p
;
3646 return -EINVAL
; /* Offload for wait not supported */
3648 buf
= kmalloc(data_len
, GFP_KERNEL
);
3652 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
3658 kfree(wmi
->last_mgmt_tx_frame
);
3659 memcpy(buf
, data
, data_len
);
3660 wmi
->last_mgmt_tx_frame
= buf
;
3661 wmi
->last_mgmt_tx_frame_len
= data_len
;
3663 ath6kl_dbg(ATH6KL_DBG_WMI
,
3664 "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3665 id
, freq
, wait
, data_len
);
3666 p
= (struct wmi_send_action_cmd
*) skb
->data
;
3667 p
->id
= cpu_to_le32(id
);
3668 p
->freq
= cpu_to_le32(freq
);
3669 p
->wait
= cpu_to_le32(wait
);
3670 p
->len
= cpu_to_le16(data_len
);
3671 memcpy(p
->data
, data
, data_len
);
3672 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SEND_ACTION_CMDID
,
3676 static int __ath6kl_wmi_send_mgmt_cmd(struct wmi
*wmi
, u8 if_idx
, u32 id
,
3677 u32 freq
, u32 wait
, const u8
*data
,
3678 u16 data_len
, u32 no_cck
)
3680 struct sk_buff
*skb
;
3681 struct wmi_send_mgmt_cmd
*p
;
3685 return -EINVAL
; /* Offload for wait not supported */
3687 buf
= kmalloc(data_len
, GFP_KERNEL
);
3691 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
3697 kfree(wmi
->last_mgmt_tx_frame
);
3698 memcpy(buf
, data
, data_len
);
3699 wmi
->last_mgmt_tx_frame
= buf
;
3700 wmi
->last_mgmt_tx_frame_len
= data_len
;
3702 ath6kl_dbg(ATH6KL_DBG_WMI
,
3703 "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3704 id
, freq
, wait
, data_len
);
3705 p
= (struct wmi_send_mgmt_cmd
*) skb
->data
;
3706 p
->id
= cpu_to_le32(id
);
3707 p
->freq
= cpu_to_le32(freq
);
3708 p
->wait
= cpu_to_le32(wait
);
3709 p
->no_cck
= cpu_to_le32(no_cck
);
3710 p
->len
= cpu_to_le16(data_len
);
3711 memcpy(p
->data
, data
, data_len
);
3712 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SEND_MGMT_CMDID
,
3716 int ath6kl_wmi_send_mgmt_cmd(struct wmi
*wmi
, u8 if_idx
, u32 id
, u32 freq
,
3717 u32 wait
, const u8
*data
, u16 data_len
,
3721 struct ath6kl
*ar
= wmi
->parent_dev
;
3723 if (test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX
,
3724 ar
->fw_capabilities
)) {
3726 * If capable of doing P2P mgmt operations using
3727 * station interface, send additional information like
3728 * supported rates to advertise and xmit rates for
3731 status
= __ath6kl_wmi_send_mgmt_cmd(ar
->wmi
, if_idx
, id
, freq
,
3732 wait
, data
, data_len
,
3735 status
= ath6kl_wmi_send_action_cmd(ar
->wmi
, if_idx
, id
, freq
,
3736 wait
, data
, data_len
);
3742 int ath6kl_wmi_send_probe_response_cmd(struct wmi
*wmi
, u8 if_idx
, u32 freq
,
3743 const u8
*dst
, const u8
*data
,
3746 struct sk_buff
*skb
;
3747 struct wmi_p2p_probe_response_cmd
*p
;
3748 size_t cmd_len
= sizeof(*p
) + data_len
;
3751 cmd_len
++; /* work around target minimum length requirement */
3753 skb
= ath6kl_wmi_get_new_buf(cmd_len
);
3757 ath6kl_dbg(ATH6KL_DBG_WMI
,
3758 "send_probe_response_cmd: freq=%u dst=%pM len=%u\n",
3759 freq
, dst
, data_len
);
3760 p
= (struct wmi_p2p_probe_response_cmd
*) skb
->data
;
3761 p
->freq
= cpu_to_le32(freq
);
3762 memcpy(p
->destination_addr
, dst
, ETH_ALEN
);
3763 p
->len
= cpu_to_le16(data_len
);
3764 memcpy(p
->data
, data
, data_len
);
3765 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
3766 WMI_SEND_PROBE_RESPONSE_CMDID
,
3770 int ath6kl_wmi_probe_report_req_cmd(struct wmi
*wmi
, u8 if_idx
, bool enable
)
3772 struct sk_buff
*skb
;
3773 struct wmi_probe_req_report_cmd
*p
;
3775 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
3779 ath6kl_dbg(ATH6KL_DBG_WMI
, "probe_report_req_cmd: enable=%u\n",
3781 p
= (struct wmi_probe_req_report_cmd
*) skb
->data
;
3782 p
->enable
= enable
? 1 : 0;
3783 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_PROBE_REQ_REPORT_CMDID
,
3787 int ath6kl_wmi_info_req_cmd(struct wmi
*wmi
, u8 if_idx
, u32 info_req_flags
)
3789 struct sk_buff
*skb
;
3790 struct wmi_get_p2p_info
*p
;
3792 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
3796 ath6kl_dbg(ATH6KL_DBG_WMI
, "info_req_cmd: flags=%x\n",
3798 p
= (struct wmi_get_p2p_info
*) skb
->data
;
3799 p
->info_req_flags
= cpu_to_le32(info_req_flags
);
3800 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_GET_P2P_INFO_CMDID
,
3804 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi
*wmi
, u8 if_idx
)
3806 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl_cmd\n");
3807 return ath6kl_wmi_simple_cmd(wmi
, if_idx
,
3808 WMI_CANCEL_REMAIN_ON_CHNL_CMDID
);
3811 int ath6kl_wmi_set_inact_period(struct wmi
*wmi
, u8 if_idx
, int inact_timeout
)
3813 struct sk_buff
*skb
;
3814 struct wmi_set_inact_period_cmd
*cmd
;
3816 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3820 cmd
= (struct wmi_set_inact_period_cmd
*) skb
->data
;
3821 cmd
->inact_period
= cpu_to_le32(inact_timeout
);
3822 cmd
->num_null_func
= 0;
3824 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_AP_CONN_INACT_CMDID
,
3828 static void ath6kl_wmi_hb_challenge_resp_event(struct wmi
*wmi
, u8
*datap
,
3831 struct wmix_hb_challenge_resp_cmd
*cmd
;
3833 if (len
< sizeof(struct wmix_hb_challenge_resp_cmd
))
3836 cmd
= (struct wmix_hb_challenge_resp_cmd
*) datap
;
3837 ath6kl_recovery_hb_event(wmi
->parent_dev
,
3838 le32_to_cpu(cmd
->cookie
));
3841 static int ath6kl_wmi_control_rx_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
)
3843 struct wmix_cmd_hdr
*cmd
;
3849 if (skb
->len
< sizeof(struct wmix_cmd_hdr
)) {
3850 ath6kl_err("bad packet 1\n");
3854 cmd
= (struct wmix_cmd_hdr
*) skb
->data
;
3855 id
= le32_to_cpu(cmd
->cmd_id
);
3857 skb_pull(skb
, sizeof(struct wmix_cmd_hdr
));
3863 case WMIX_HB_CHALLENGE_RESP_EVENTID
:
3864 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi event hb challenge resp\n");
3865 ath6kl_wmi_hb_challenge_resp_event(wmi
, datap
, len
);
3867 case WMIX_DBGLOG_EVENTID
:
3868 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi event dbglog len %d\n", len
);
3869 ath6kl_debug_fwlog_event(wmi
->parent_dev
, datap
, len
);
3872 ath6kl_warn("unknown cmd id 0x%x\n", id
);
3880 static int ath6kl_wmi_roam_tbl_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
3882 return ath6kl_debug_roam_tbl_event(wmi
->parent_dev
, datap
, len
);
3885 /* Process interface specific wmi events, caller would free the datap */
3886 static int ath6kl_wmi_proc_events_vif(struct wmi
*wmi
, u16 if_idx
, u16 cmd_id
,
3889 struct ath6kl_vif
*vif
;
3891 vif
= ath6kl_get_vif_by_index(wmi
->parent_dev
, if_idx
);
3893 ath6kl_dbg(ATH6KL_DBG_WMI
,
3894 "Wmi event for unavailable vif, vif_index:%d\n",
3900 case WMI_CONNECT_EVENTID
:
3901 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CONNECT_EVENTID\n");
3902 return ath6kl_wmi_connect_event_rx(wmi
, datap
, len
, vif
);
3903 case WMI_DISCONNECT_EVENTID
:
3904 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DISCONNECT_EVENTID\n");
3905 return ath6kl_wmi_disconnect_event_rx(wmi
, datap
, len
, vif
);
3906 case WMI_TKIP_MICERR_EVENTID
:
3907 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TKIP_MICERR_EVENTID\n");
3908 return ath6kl_wmi_tkip_micerr_event_rx(wmi
, datap
, len
, vif
);
3909 case WMI_BSSINFO_EVENTID
:
3910 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_BSSINFO_EVENTID\n");
3911 return ath6kl_wmi_bssinfo_event_rx(wmi
, datap
, len
, vif
);
3912 case WMI_NEIGHBOR_REPORT_EVENTID
:
3913 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_NEIGHBOR_REPORT_EVENTID\n");
3914 return ath6kl_wmi_neighbor_report_event_rx(wmi
, datap
, len
,
3916 case WMI_SCAN_COMPLETE_EVENTID
:
3917 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SCAN_COMPLETE_EVENTID\n");
3918 return ath6kl_wmi_scan_complete_rx(wmi
, datap
, len
, vif
);
3919 case WMI_REPORT_STATISTICS_EVENTID
:
3920 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_STATISTICS_EVENTID\n");
3921 return ath6kl_wmi_stats_event_rx(wmi
, datap
, len
, vif
);
3922 case WMI_CAC_EVENTID
:
3923 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CAC_EVENTID\n");
3924 return ath6kl_wmi_cac_event_rx(wmi
, datap
, len
, vif
);
3925 case WMI_PSPOLL_EVENTID
:
3926 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSPOLL_EVENTID\n");
3927 return ath6kl_wmi_pspoll_event_rx(wmi
, datap
, len
, vif
);
3928 case WMI_DTIMEXPIRY_EVENTID
:
3929 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DTIMEXPIRY_EVENTID\n");
3930 return ath6kl_wmi_dtimexpiry_event_rx(wmi
, datap
, len
, vif
);
3931 case WMI_ADDBA_REQ_EVENTID
:
3932 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_REQ_EVENTID\n");
3933 return ath6kl_wmi_addba_req_event_rx(wmi
, datap
, len
, vif
);
3934 case WMI_DELBA_REQ_EVENTID
:
3935 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DELBA_REQ_EVENTID\n");
3936 return ath6kl_wmi_delba_req_event_rx(wmi
, datap
, len
, vif
);
3937 case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID
:
3938 ath6kl_dbg(ATH6KL_DBG_WMI
,
3939 "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID");
3940 return ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi
, vif
);
3941 case WMI_REMAIN_ON_CHNL_EVENTID
:
3942 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REMAIN_ON_CHNL_EVENTID\n");
3943 return ath6kl_wmi_remain_on_chnl_event_rx(wmi
, datap
, len
, vif
);
3944 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID
:
3945 ath6kl_dbg(ATH6KL_DBG_WMI
,
3946 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
3947 return ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi
, datap
,
3949 case WMI_TX_STATUS_EVENTID
:
3950 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_STATUS_EVENTID\n");
3951 return ath6kl_wmi_tx_status_event_rx(wmi
, datap
, len
, vif
);
3952 case WMI_RX_PROBE_REQ_EVENTID
:
3953 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_PROBE_REQ_EVENTID\n");
3954 return ath6kl_wmi_rx_probe_req_event_rx(wmi
, datap
, len
, vif
);
3955 case WMI_RX_ACTION_EVENTID
:
3956 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_ACTION_EVENTID\n");
3957 return ath6kl_wmi_rx_action_event_rx(wmi
, datap
, len
, vif
);
3958 case WMI_TXE_NOTIFY_EVENTID
:
3959 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TXE_NOTIFY_EVENTID\n");
3960 return ath6kl_wmi_txe_notify_event_rx(wmi
, datap
, len
, vif
);
3962 ath6kl_dbg(ATH6KL_DBG_WMI
, "unknown cmd id 0x%x\n", cmd_id
);
3969 static int ath6kl_wmi_proc_events(struct wmi
*wmi
, struct sk_buff
*skb
)
3971 struct wmi_cmd_hdr
*cmd
;
3978 cmd
= (struct wmi_cmd_hdr
*) skb
->data
;
3979 id
= le16_to_cpu(cmd
->cmd_id
);
3980 if_idx
= le16_to_cpu(cmd
->info1
) & WMI_CMD_HDR_IF_ID_MASK
;
3982 skb_pull(skb
, sizeof(struct wmi_cmd_hdr
));
3986 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi rx id %d len %d\n", id
, len
);
3987 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP
, NULL
, "wmi rx ",
3991 case WMI_GET_BITRATE_CMDID
:
3992 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_BITRATE_CMDID\n");
3993 ret
= ath6kl_wmi_bitrate_reply_rx(wmi
, datap
, len
);
3995 case WMI_GET_CHANNEL_LIST_CMDID
:
3996 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_CHANNEL_LIST_CMDID\n");
3997 ret
= ath6kl_wmi_ch_list_reply_rx(wmi
, datap
, len
);
3999 case WMI_GET_TX_PWR_CMDID
:
4000 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_TX_PWR_CMDID\n");
4001 ret
= ath6kl_wmi_tx_pwr_reply_rx(wmi
, datap
, len
);
4003 case WMI_READY_EVENTID
:
4004 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_READY_EVENTID\n");
4005 ret
= ath6kl_wmi_ready_event_rx(wmi
, datap
, len
);
4007 case WMI_PEER_NODE_EVENTID
:
4008 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PEER_NODE_EVENTID\n");
4009 ret
= ath6kl_wmi_peer_node_event_rx(wmi
, datap
, len
);
4011 case WMI_REGDOMAIN_EVENTID
:
4012 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REGDOMAIN_EVENTID\n");
4013 ath6kl_wmi_regdomain_event(wmi
, datap
, len
);
4015 case WMI_PSTREAM_TIMEOUT_EVENTID
:
4016 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
4017 ret
= ath6kl_wmi_pstream_timeout_event_rx(wmi
, datap
, len
);
4019 case WMI_CMDERROR_EVENTID
:
4020 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CMDERROR_EVENTID\n");
4021 ret
= ath6kl_wmi_error_event_rx(wmi
, datap
, len
);
4023 case WMI_RSSI_THRESHOLD_EVENTID
:
4024 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RSSI_THRESHOLD_EVENTID\n");
4025 ret
= ath6kl_wmi_rssi_threshold_event_rx(wmi
, datap
, len
);
4027 case WMI_ERROR_REPORT_EVENTID
:
4028 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ERROR_REPORT_EVENTID\n");
4030 case WMI_OPT_RX_FRAME_EVENTID
:
4031 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_OPT_RX_FRAME_EVENTID\n");
4032 /* this event has been deprecated */
4034 case WMI_REPORT_ROAM_TBL_EVENTID
:
4035 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_TBL_EVENTID\n");
4036 ret
= ath6kl_wmi_roam_tbl_event_rx(wmi
, datap
, len
);
4038 case WMI_EXTENSION_EVENTID
:
4039 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_EXTENSION_EVENTID\n");
4040 ret
= ath6kl_wmi_control_rx_xtnd(wmi
, skb
);
4042 case WMI_CHANNEL_CHANGE_EVENTID
:
4043 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CHANNEL_CHANGE_EVENTID\n");
4045 case WMI_REPORT_ROAM_DATA_EVENTID
:
4046 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_DATA_EVENTID\n");
4048 case WMI_TEST_EVENTID
:
4049 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TEST_EVENTID\n");
4050 ret
= ath6kl_wmi_test_rx(wmi
, datap
, len
);
4052 case WMI_GET_FIXRATES_CMDID
:
4053 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_FIXRATES_CMDID\n");
4054 ret
= ath6kl_wmi_ratemask_reply_rx(wmi
, datap
, len
);
4056 case WMI_TX_RETRY_ERR_EVENTID
:
4057 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_RETRY_ERR_EVENTID\n");
4059 case WMI_SNR_THRESHOLD_EVENTID
:
4060 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SNR_THRESHOLD_EVENTID\n");
4061 ret
= ath6kl_wmi_snr_threshold_event_rx(wmi
, datap
, len
);
4063 case WMI_LQ_THRESHOLD_EVENTID
:
4064 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_LQ_THRESHOLD_EVENTID\n");
4066 case WMI_APLIST_EVENTID
:
4067 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_APLIST_EVENTID\n");
4068 ret
= ath6kl_wmi_aplist_event_rx(wmi
, datap
, len
);
4070 case WMI_GET_KEEPALIVE_CMDID
:
4071 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_KEEPALIVE_CMDID\n");
4072 ret
= ath6kl_wmi_keepalive_reply_rx(wmi
, datap
, len
);
4074 case WMI_GET_WOW_LIST_EVENTID
:
4075 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_WOW_LIST_EVENTID\n");
4077 case WMI_GET_PMKID_LIST_EVENTID
:
4078 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_PMKID_LIST_EVENTID\n");
4079 ret
= ath6kl_wmi_get_pmkid_list_event_rx(wmi
, datap
, len
);
4081 case WMI_SET_PARAMS_REPLY_EVENTID
:
4082 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SET_PARAMS_REPLY_EVENTID\n");
4084 case WMI_ADDBA_RESP_EVENTID
:
4085 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_RESP_EVENTID\n");
4087 case WMI_REPORT_BTCOEX_CONFIG_EVENTID
:
4088 ath6kl_dbg(ATH6KL_DBG_WMI
,
4089 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
4091 case WMI_REPORT_BTCOEX_STATS_EVENTID
:
4092 ath6kl_dbg(ATH6KL_DBG_WMI
,
4093 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
4095 case WMI_TX_COMPLETE_EVENTID
:
4096 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_COMPLETE_EVENTID\n");
4097 ret
= ath6kl_wmi_tx_complete_event_rx(datap
, len
);
4099 case WMI_P2P_CAPABILITIES_EVENTID
:
4100 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_CAPABILITIES_EVENTID\n");
4101 ret
= ath6kl_wmi_p2p_capabilities_event_rx(datap
, len
);
4103 case WMI_P2P_INFO_EVENTID
:
4104 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_INFO_EVENTID\n");
4105 ret
= ath6kl_wmi_p2p_info_event_rx(datap
, len
);
4108 /* may be the event is interface specific */
4109 ret
= ath6kl_wmi_proc_events_vif(wmi
, if_idx
, id
, datap
, len
);
4118 int ath6kl_wmi_control_rx(struct wmi
*wmi
, struct sk_buff
*skb
)
4120 if (WARN_ON(skb
== NULL
))
4123 if (skb
->len
< sizeof(struct wmi_cmd_hdr
)) {
4124 ath6kl_err("bad packet 1\n");
4129 trace_ath6kl_wmi_event(skb
->data
, skb
->len
);
4131 return ath6kl_wmi_proc_events(wmi
, skb
);
4134 void ath6kl_wmi_reset(struct wmi
*wmi
)
4136 spin_lock_bh(&wmi
->lock
);
4138 wmi
->fat_pipe_exist
= 0;
4139 memset(wmi
->stream_exist_for_ac
, 0, sizeof(wmi
->stream_exist_for_ac
));
4141 spin_unlock_bh(&wmi
->lock
);
4144 void *ath6kl_wmi_init(struct ath6kl
*dev
)
4148 wmi
= kzalloc(sizeof(struct wmi
), GFP_KERNEL
);
4152 spin_lock_init(&wmi
->lock
);
4154 wmi
->parent_dev
= dev
;
4156 wmi
->pwr_mode
= REC_POWER
;
4158 ath6kl_wmi_reset(wmi
);
4163 void ath6kl_wmi_shutdown(struct wmi
*wmi
)
4168 kfree(wmi
->last_mgmt_tx_frame
);