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 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SET_ROAM_CTRL_CMDID
,
783 int ath6kl_wmi_force_roam_cmd(struct wmi
*wmi
, const u8
*bssid
)
786 struct roam_ctrl_cmd
*cmd
;
788 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
792 cmd
= (struct roam_ctrl_cmd
*) skb
->data
;
794 memcpy(cmd
->info
.bssid
, bssid
, ETH_ALEN
);
795 cmd
->roam_ctrl
= WMI_FORCE_ROAM
;
797 ath6kl_dbg(ATH6KL_DBG_WMI
, "force roam to %pM\n", bssid
);
798 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SET_ROAM_CTRL_CMDID
,
802 int ath6kl_wmi_ap_set_beacon_intvl_cmd(struct wmi
*wmi
, u8 if_idx
,
806 struct set_beacon_int_cmd
*cmd
;
808 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
812 cmd
= (struct set_beacon_int_cmd
*) skb
->data
;
814 cmd
->beacon_intvl
= cpu_to_le32(beacon_intvl
);
815 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
816 WMI_SET_BEACON_INT_CMDID
, NO_SYNC_WMIFLAG
);
819 int ath6kl_wmi_ap_set_dtim_cmd(struct wmi
*wmi
, u8 if_idx
, u32 dtim_period
)
822 struct set_dtim_cmd
*cmd
;
824 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
828 cmd
= (struct set_dtim_cmd
*) skb
->data
;
830 cmd
->dtim_period
= cpu_to_le32(dtim_period
);
831 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
832 WMI_AP_SET_DTIM_CMDID
, NO_SYNC_WMIFLAG
);
835 int ath6kl_wmi_set_roam_mode_cmd(struct wmi
*wmi
, enum wmi_roam_mode mode
)
838 struct roam_ctrl_cmd
*cmd
;
840 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
844 cmd
= (struct roam_ctrl_cmd
*) skb
->data
;
846 cmd
->info
.roam_mode
= mode
;
847 cmd
->roam_ctrl
= WMI_SET_ROAM_MODE
;
849 ath6kl_dbg(ATH6KL_DBG_WMI
, "set roam mode %d\n", mode
);
850 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SET_ROAM_CTRL_CMDID
,
854 static int ath6kl_wmi_connect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
855 struct ath6kl_vif
*vif
)
857 struct wmi_connect_event
*ev
;
860 if (len
< sizeof(struct wmi_connect_event
))
863 ev
= (struct wmi_connect_event
*) datap
;
865 if (vif
->nw_type
== AP_NETWORK
) {
866 /* AP mode start/STA connected event */
867 struct net_device
*dev
= vif
->ndev
;
868 if (memcmp(dev
->dev_addr
, ev
->u
.ap_bss
.bssid
, ETH_ALEN
) == 0) {
869 ath6kl_dbg(ATH6KL_DBG_WMI
,
870 "%s: freq %d bssid %pM (AP started)\n",
871 __func__
, le16_to_cpu(ev
->u
.ap_bss
.ch
),
873 ath6kl_connect_ap_mode_bss(
874 vif
, le16_to_cpu(ev
->u
.ap_bss
.ch
));
876 ath6kl_dbg(ATH6KL_DBG_WMI
,
877 "%s: aid %u mac_addr %pM auth=%u keymgmt=%u cipher=%u apsd_info=%u (STA connected)\n",
878 __func__
, ev
->u
.ap_sta
.aid
,
879 ev
->u
.ap_sta
.mac_addr
,
881 ev
->u
.ap_sta
.keymgmt
,
882 le16_to_cpu(ev
->u
.ap_sta
.cipher
),
883 ev
->u
.ap_sta
.apsd_info
);
885 ath6kl_connect_ap_mode_sta(
886 vif
, ev
->u
.ap_sta
.aid
, ev
->u
.ap_sta
.mac_addr
,
887 ev
->u
.ap_sta
.keymgmt
,
888 le16_to_cpu(ev
->u
.ap_sta
.cipher
),
889 ev
->u
.ap_sta
.auth
, ev
->assoc_req_len
,
890 ev
->assoc_info
+ ev
->beacon_ie_len
,
891 ev
->u
.ap_sta
.apsd_info
);
896 /* STA/IBSS mode connection event */
898 ath6kl_dbg(ATH6KL_DBG_WMI
,
899 "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n",
900 le16_to_cpu(ev
->u
.sta
.ch
), ev
->u
.sta
.bssid
,
901 le16_to_cpu(ev
->u
.sta
.listen_intvl
),
902 le16_to_cpu(ev
->u
.sta
.beacon_intvl
),
903 le32_to_cpu(ev
->u
.sta
.nw_type
));
905 /* Start of assoc rsp IEs */
906 pie
= ev
->assoc_info
+ ev
->beacon_ie_len
+
907 ev
->assoc_req_len
+ (sizeof(u16
) * 3); /* capinfo, status, aid */
909 /* End of assoc rsp IEs */
910 peie
= ev
->assoc_info
+ ev
->beacon_ie_len
+ ev
->assoc_req_len
+
915 case WLAN_EID_VENDOR_SPECIFIC
:
916 if (pie
[1] > 3 && pie
[2] == 0x00 && pie
[3] == 0x50 &&
917 pie
[4] == 0xf2 && pie
[5] == WMM_OUI_TYPE
) {
918 /* WMM OUT (00:50:F2) */
920 pie
[6] == WMM_PARAM_OUI_SUBTYPE
)
921 wmi
->is_wmm_enabled
= true;
926 if (wmi
->is_wmm_enabled
)
932 ath6kl_connect_event(vif
, le16_to_cpu(ev
->u
.sta
.ch
),
934 le16_to_cpu(ev
->u
.sta
.listen_intvl
),
935 le16_to_cpu(ev
->u
.sta
.beacon_intvl
),
936 le32_to_cpu(ev
->u
.sta
.nw_type
),
937 ev
->beacon_ie_len
, ev
->assoc_req_len
,
938 ev
->assoc_resp_len
, ev
->assoc_info
);
943 static struct country_code_to_enum_rd
*
944 ath6kl_regd_find_country(u16 countryCode
)
948 for (i
= 0; i
< ARRAY_SIZE(allCountries
); i
++) {
949 if (allCountries
[i
].countryCode
== countryCode
)
950 return &allCountries
[i
];
956 static struct reg_dmn_pair_mapping
*
957 ath6kl_get_regpair(u16 regdmn
)
961 if (regdmn
== NO_ENUMRD
)
964 for (i
= 0; i
< ARRAY_SIZE(regDomainPairs
); i
++) {
965 if (regDomainPairs
[i
].reg_domain
== regdmn
)
966 return ®DomainPairs
[i
];
972 static struct country_code_to_enum_rd
*
973 ath6kl_regd_find_country_by_rd(u16 regdmn
)
977 for (i
= 0; i
< ARRAY_SIZE(allCountries
); i
++) {
978 if (allCountries
[i
].regDmnEnum
== regdmn
)
979 return &allCountries
[i
];
985 static void ath6kl_wmi_regdomain_event(struct wmi
*wmi
, u8
*datap
, int len
)
987 struct ath6kl_wmi_regdomain
*ev
;
988 struct country_code_to_enum_rd
*country
= NULL
;
989 struct reg_dmn_pair_mapping
*regpair
= NULL
;
993 ev
= (struct ath6kl_wmi_regdomain
*) datap
;
994 reg_code
= le32_to_cpu(ev
->reg_code
);
996 if ((reg_code
>> ATH6KL_COUNTRY_RD_SHIFT
) & COUNTRY_ERD_FLAG
) {
997 country
= ath6kl_regd_find_country((u16
) reg_code
);
998 } else if (!(((u16
) reg_code
& WORLD_SKU_MASK
) == WORLD_SKU_PREFIX
)) {
999 regpair
= ath6kl_get_regpair((u16
) reg_code
);
1000 country
= ath6kl_regd_find_country_by_rd((u16
) reg_code
);
1002 ath6kl_dbg(ATH6KL_DBG_WMI
, "Regpair used: 0x%0x\n",
1003 regpair
->reg_domain
);
1005 ath6kl_warn("Regpair not found reg_code 0x%0x\n",
1009 if (country
&& wmi
->parent_dev
->wiphy_registered
) {
1010 alpha2
[0] = country
->isoName
[0];
1011 alpha2
[1] = country
->isoName
[1];
1013 regulatory_hint(wmi
->parent_dev
->wiphy
, alpha2
);
1015 ath6kl_dbg(ATH6KL_DBG_WMI
, "Country alpha2 being used: %c%c\n",
1016 alpha2
[0], alpha2
[1]);
1020 static int ath6kl_wmi_disconnect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1021 struct ath6kl_vif
*vif
)
1023 struct wmi_disconnect_event
*ev
;
1024 wmi
->traffic_class
= 100;
1026 if (len
< sizeof(struct wmi_disconnect_event
))
1029 ev
= (struct wmi_disconnect_event
*) datap
;
1031 ath6kl_dbg(ATH6KL_DBG_WMI
,
1032 "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n",
1033 le16_to_cpu(ev
->proto_reason_status
), ev
->bssid
,
1034 ev
->disconn_reason
, ev
->assoc_resp_len
);
1036 wmi
->is_wmm_enabled
= false;
1038 ath6kl_disconnect_event(vif
, ev
->disconn_reason
,
1039 ev
->bssid
, ev
->assoc_resp_len
, ev
->assoc_info
,
1040 le16_to_cpu(ev
->proto_reason_status
));
1045 static int ath6kl_wmi_peer_node_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1047 struct wmi_peer_node_event
*ev
;
1049 if (len
< sizeof(struct wmi_peer_node_event
))
1052 ev
= (struct wmi_peer_node_event
*) datap
;
1054 if (ev
->event_code
== PEER_NODE_JOIN_EVENT
)
1055 ath6kl_dbg(ATH6KL_DBG_WMI
, "joined node with mac addr: %pM\n",
1057 else if (ev
->event_code
== PEER_NODE_LEAVE_EVENT
)
1058 ath6kl_dbg(ATH6KL_DBG_WMI
, "left node with mac addr: %pM\n",
1064 static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1065 struct ath6kl_vif
*vif
)
1067 struct wmi_tkip_micerr_event
*ev
;
1069 if (len
< sizeof(struct wmi_tkip_micerr_event
))
1072 ev
= (struct wmi_tkip_micerr_event
*) datap
;
1074 ath6kl_tkip_micerr_event(vif
, ev
->key_id
, ev
->is_mcast
);
1079 void ath6kl_wmi_sscan_timer(struct timer_list
*t
)
1081 struct ath6kl_vif
*vif
= from_timer(vif
, t
, sched_scan_timer
);
1083 cfg80211_sched_scan_results(vif
->ar
->wiphy
, 0);
1086 static int ath6kl_wmi_bssinfo_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1087 struct ath6kl_vif
*vif
)
1089 struct wmi_bss_info_hdr2
*bih
;
1091 struct ieee80211_channel
*channel
;
1092 struct ath6kl
*ar
= wmi
->parent_dev
;
1093 struct cfg80211_bss
*bss
;
1095 if (len
<= sizeof(struct wmi_bss_info_hdr2
))
1098 bih
= (struct wmi_bss_info_hdr2
*) datap
;
1099 buf
= datap
+ sizeof(struct wmi_bss_info_hdr2
);
1100 len
-= sizeof(struct wmi_bss_info_hdr2
);
1102 ath6kl_dbg(ATH6KL_DBG_WMI
,
1103 "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
1105 bih
->ch
, bih
->snr
, bih
->snr
- 95, bih
->bssid
,
1108 if (bih
->frame_type
!= BEACON_FTYPE
&&
1109 bih
->frame_type
!= PROBERESP_FTYPE
)
1110 return 0; /* Only update BSS table for now */
1112 if (bih
->frame_type
== BEACON_FTYPE
&&
1113 test_bit(CLEAR_BSSFILTER_ON_BEACON
, &vif
->flags
)) {
1114 clear_bit(CLEAR_BSSFILTER_ON_BEACON
, &vif
->flags
);
1115 ath6kl_wmi_bssfilter_cmd(ar
->wmi
, vif
->fw_vif_idx
,
1116 NONE_BSS_FILTER
, 0);
1119 channel
= ieee80211_get_channel(ar
->wiphy
, le16_to_cpu(bih
->ch
));
1120 if (channel
== NULL
)
1123 if (len
< 8 + 2 + 2)
1126 if (bih
->frame_type
== BEACON_FTYPE
&&
1127 test_bit(CONNECTED
, &vif
->flags
) &&
1128 memcmp(bih
->bssid
, vif
->bssid
, ETH_ALEN
) == 0) {
1130 tim
= cfg80211_find_ie(WLAN_EID_TIM
, buf
+ 8 + 2 + 2,
1132 if (tim
&& tim
[1] >= 2) {
1133 vif
->assoc_bss_dtim_period
= tim
[3];
1134 set_bit(DTIM_PERIOD_AVAIL
, &vif
->flags
);
1138 bss
= cfg80211_inform_bss(ar
->wiphy
, channel
,
1139 bih
->frame_type
== BEACON_FTYPE
?
1140 CFG80211_BSS_FTYPE_BEACON
:
1141 CFG80211_BSS_FTYPE_PRESP
,
1142 bih
->bssid
, get_unaligned_le64((__le64
*)buf
),
1143 get_unaligned_le16(((__le16
*)buf
) + 5),
1144 get_unaligned_le16(((__le16
*)buf
) + 4),
1145 buf
+ 8 + 2 + 2, len
- 8 - 2 - 2,
1146 (bih
->snr
- 95) * 100, GFP_ATOMIC
);
1149 cfg80211_put_bss(ar
->wiphy
, bss
);
1152 * Firmware doesn't return any event when scheduled scan has
1153 * finished, so we need to use a timer to find out when there are
1156 * The timer is started from the first bss info received, otherwise
1157 * the timer would not ever fire if the scan interval is short
1160 if (test_bit(SCHED_SCANNING
, &vif
->flags
) &&
1161 !timer_pending(&vif
->sched_scan_timer
)) {
1162 mod_timer(&vif
->sched_scan_timer
, jiffies
+
1163 msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY
));
1169 /* Inactivity timeout of a fatpipe(pstream) at the target */
1170 static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi
*wmi
, u8
*datap
,
1173 struct wmi_pstream_timeout_event
*ev
;
1175 if (len
< sizeof(struct wmi_pstream_timeout_event
))
1178 ev
= (struct wmi_pstream_timeout_event
*) datap
;
1179 if (ev
->traffic_class
>= WMM_NUM_AC
) {
1180 ath6kl_err("invalid traffic class: %d\n", ev
->traffic_class
);
1185 * When the pstream (fat pipe == AC) timesout, it means there were
1186 * no thinStreams within this pstream & it got implicitly created
1187 * due to data flow on this AC. We start the inactivity timer only
1188 * for implicitly created pstream. Just reset the host state.
1190 spin_lock_bh(&wmi
->lock
);
1191 wmi
->stream_exist_for_ac
[ev
->traffic_class
] = 0;
1192 wmi
->fat_pipe_exist
&= ~(1 << ev
->traffic_class
);
1193 spin_unlock_bh(&wmi
->lock
);
1195 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1196 ath6kl_indicate_tx_activity(wmi
->parent_dev
, ev
->traffic_class
, false);
1201 static int ath6kl_wmi_bitrate_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1203 struct wmi_bit_rate_reply
*reply
;
1206 if (len
< sizeof(struct wmi_bit_rate_reply
))
1209 reply
= (struct wmi_bit_rate_reply
*) datap
;
1211 ath6kl_dbg(ATH6KL_DBG_WMI
, "rateindex %d\n", reply
->rate_index
);
1213 if (reply
->rate_index
!= (s8
) RATE_AUTO
) {
1214 index
= reply
->rate_index
& 0x7f;
1215 if (WARN_ON_ONCE(index
> (RATE_MCS_7_40
+ 1)))
1219 ath6kl_wakeup_event(wmi
->parent_dev
);
1224 static int ath6kl_wmi_test_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1226 ath6kl_tm_rx_event(wmi
->parent_dev
, datap
, len
);
1231 static int ath6kl_wmi_ratemask_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1233 if (len
< sizeof(struct wmi_fix_rates_reply
))
1236 ath6kl_wakeup_event(wmi
->parent_dev
);
1241 static int ath6kl_wmi_ch_list_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1243 if (len
< sizeof(struct wmi_channel_list_reply
))
1246 ath6kl_wakeup_event(wmi
->parent_dev
);
1251 static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1253 struct wmi_tx_pwr_reply
*reply
;
1255 if (len
< sizeof(struct wmi_tx_pwr_reply
))
1258 reply
= (struct wmi_tx_pwr_reply
*) datap
;
1259 ath6kl_txpwr_rx_evt(wmi
->parent_dev
, reply
->dbM
);
1264 static int ath6kl_wmi_keepalive_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1266 if (len
< sizeof(struct wmi_get_keepalive_cmd
))
1269 ath6kl_wakeup_event(wmi
->parent_dev
);
1274 static int ath6kl_wmi_scan_complete_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1275 struct ath6kl_vif
*vif
)
1277 struct wmi_scan_complete_event
*ev
;
1279 ev
= (struct wmi_scan_complete_event
*) datap
;
1281 ath6kl_scan_complete_evt(vif
, a_sle32_to_cpu(ev
->status
));
1282 wmi
->is_probe_ssid
= false;
1287 static int ath6kl_wmi_neighbor_report_event_rx(struct wmi
*wmi
, u8
*datap
,
1288 int len
, struct ath6kl_vif
*vif
)
1290 struct wmi_neighbor_report_event
*ev
;
1293 if (len
< sizeof(*ev
))
1295 ev
= (struct wmi_neighbor_report_event
*) datap
;
1296 if (struct_size(ev
, neighbor
, ev
->num_neighbors
) > len
) {
1297 ath6kl_dbg(ATH6KL_DBG_WMI
,
1298 "truncated neighbor event (num=%d len=%d)\n",
1299 ev
->num_neighbors
, len
);
1302 for (i
= 0; i
< ev
->num_neighbors
; i
++) {
1303 ath6kl_dbg(ATH6KL_DBG_WMI
, "neighbor %d/%d - %pM 0x%x\n",
1304 i
+ 1, ev
->num_neighbors
, ev
->neighbor
[i
].bssid
,
1305 ev
->neighbor
[i
].bss_flags
);
1306 cfg80211_pmksa_candidate_notify(vif
->ndev
, i
,
1307 ev
->neighbor
[i
].bssid
,
1308 !!(ev
->neighbor
[i
].bss_flags
&
1309 WMI_PREAUTH_CAPABLE_BSS
),
1317 * Target is reporting a programming error. This is for
1318 * developer aid only. Target only checks a few common violations
1319 * and it is responsibility of host to do all error checking.
1320 * Behavior of target after wmi error event is undefined.
1321 * A reset is recommended.
1323 static int ath6kl_wmi_error_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1325 const char *type
= "unknown error";
1326 struct wmi_cmd_error_event
*ev
;
1327 ev
= (struct wmi_cmd_error_event
*) datap
;
1329 switch (ev
->err_code
) {
1331 type
= "invalid parameter";
1334 type
= "invalid state";
1336 case INTERNAL_ERROR
:
1337 type
= "internal error";
1341 ath6kl_dbg(ATH6KL_DBG_WMI
, "programming error, cmd=%d %s\n",
1347 static int ath6kl_wmi_stats_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1348 struct ath6kl_vif
*vif
)
1350 ath6kl_tgt_stats_event(vif
, datap
, len
);
1355 static u8
ath6kl_wmi_get_upper_threshold(s16 rssi
,
1356 struct sq_threshold_params
*sq_thresh
,
1360 u8 threshold
= (u8
) sq_thresh
->upper_threshold
[size
- 1];
1362 /* The list is already in sorted order. Get the next lower value */
1363 for (index
= 0; index
< size
; index
++) {
1364 if (rssi
< sq_thresh
->upper_threshold
[index
]) {
1365 threshold
= (u8
) sq_thresh
->upper_threshold
[index
];
1373 static u8
ath6kl_wmi_get_lower_threshold(s16 rssi
,
1374 struct sq_threshold_params
*sq_thresh
,
1378 u8 threshold
= (u8
) sq_thresh
->lower_threshold
[size
- 1];
1380 /* The list is already in sorted order. Get the next lower value */
1381 for (index
= 0; index
< size
; index
++) {
1382 if (rssi
> sq_thresh
->lower_threshold
[index
]) {
1383 threshold
= (u8
) sq_thresh
->lower_threshold
[index
];
1391 static int ath6kl_wmi_send_rssi_threshold_params(struct wmi
*wmi
,
1392 struct wmi_rssi_threshold_params_cmd
*rssi_cmd
)
1394 struct sk_buff
*skb
;
1395 struct wmi_rssi_threshold_params_cmd
*cmd
;
1397 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1401 cmd
= (struct wmi_rssi_threshold_params_cmd
*) skb
->data
;
1402 memcpy(cmd
, rssi_cmd
, sizeof(struct wmi_rssi_threshold_params_cmd
));
1404 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_RSSI_THRESHOLD_PARAMS_CMDID
,
1408 static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1411 struct wmi_rssi_threshold_event
*reply
;
1412 struct wmi_rssi_threshold_params_cmd cmd
;
1413 struct sq_threshold_params
*sq_thresh
;
1414 enum wmi_rssi_threshold_val new_threshold
;
1415 u8 upper_rssi_threshold
, lower_rssi_threshold
;
1419 if (len
< sizeof(struct wmi_rssi_threshold_event
))
1422 reply
= (struct wmi_rssi_threshold_event
*) datap
;
1423 new_threshold
= (enum wmi_rssi_threshold_val
) reply
->range
;
1424 rssi
= a_sle16_to_cpu(reply
->rssi
);
1426 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_RSSI
];
1429 * Identify the threshold breached and communicate that to the app.
1430 * After that install a new set of thresholds based on the signal
1431 * quality reported by the target
1433 if (new_threshold
) {
1434 /* Upper threshold breached */
1435 if (rssi
< sq_thresh
->upper_threshold
[0]) {
1436 ath6kl_dbg(ATH6KL_DBG_WMI
,
1437 "spurious upper rssi threshold event: %d\n",
1439 } else if ((rssi
< sq_thresh
->upper_threshold
[1]) &&
1440 (rssi
>= sq_thresh
->upper_threshold
[0])) {
1441 new_threshold
= WMI_RSSI_THRESHOLD1_ABOVE
;
1442 } else if ((rssi
< sq_thresh
->upper_threshold
[2]) &&
1443 (rssi
>= sq_thresh
->upper_threshold
[1])) {
1444 new_threshold
= WMI_RSSI_THRESHOLD2_ABOVE
;
1445 } else if ((rssi
< sq_thresh
->upper_threshold
[3]) &&
1446 (rssi
>= sq_thresh
->upper_threshold
[2])) {
1447 new_threshold
= WMI_RSSI_THRESHOLD3_ABOVE
;
1448 } else if ((rssi
< sq_thresh
->upper_threshold
[4]) &&
1449 (rssi
>= sq_thresh
->upper_threshold
[3])) {
1450 new_threshold
= WMI_RSSI_THRESHOLD4_ABOVE
;
1451 } else if ((rssi
< sq_thresh
->upper_threshold
[5]) &&
1452 (rssi
>= sq_thresh
->upper_threshold
[4])) {
1453 new_threshold
= WMI_RSSI_THRESHOLD5_ABOVE
;
1454 } else if (rssi
>= sq_thresh
->upper_threshold
[5]) {
1455 new_threshold
= WMI_RSSI_THRESHOLD6_ABOVE
;
1458 /* Lower threshold breached */
1459 if (rssi
> sq_thresh
->lower_threshold
[0]) {
1460 ath6kl_dbg(ATH6KL_DBG_WMI
,
1461 "spurious lower rssi threshold event: %d %d\n",
1462 rssi
, sq_thresh
->lower_threshold
[0]);
1463 } else if ((rssi
> sq_thresh
->lower_threshold
[1]) &&
1464 (rssi
<= sq_thresh
->lower_threshold
[0])) {
1465 new_threshold
= WMI_RSSI_THRESHOLD6_BELOW
;
1466 } else if ((rssi
> sq_thresh
->lower_threshold
[2]) &&
1467 (rssi
<= sq_thresh
->lower_threshold
[1])) {
1468 new_threshold
= WMI_RSSI_THRESHOLD5_BELOW
;
1469 } else if ((rssi
> sq_thresh
->lower_threshold
[3]) &&
1470 (rssi
<= sq_thresh
->lower_threshold
[2])) {
1471 new_threshold
= WMI_RSSI_THRESHOLD4_BELOW
;
1472 } else if ((rssi
> sq_thresh
->lower_threshold
[4]) &&
1473 (rssi
<= sq_thresh
->lower_threshold
[3])) {
1474 new_threshold
= WMI_RSSI_THRESHOLD3_BELOW
;
1475 } else if ((rssi
> sq_thresh
->lower_threshold
[5]) &&
1476 (rssi
<= sq_thresh
->lower_threshold
[4])) {
1477 new_threshold
= WMI_RSSI_THRESHOLD2_BELOW
;
1478 } else if (rssi
<= sq_thresh
->lower_threshold
[5]) {
1479 new_threshold
= WMI_RSSI_THRESHOLD1_BELOW
;
1483 /* Calculate and install the next set of thresholds */
1484 lower_rssi_threshold
= ath6kl_wmi_get_lower_threshold(rssi
, sq_thresh
,
1485 sq_thresh
->lower_threshold_valid_count
);
1486 upper_rssi_threshold
= ath6kl_wmi_get_upper_threshold(rssi
, sq_thresh
,
1487 sq_thresh
->upper_threshold_valid_count
);
1489 /* Issue a wmi command to install the thresholds */
1490 cmd
.thresh_above1_val
= a_cpu_to_sle16(upper_rssi_threshold
);
1491 cmd
.thresh_below1_val
= a_cpu_to_sle16(lower_rssi_threshold
);
1492 cmd
.weight
= sq_thresh
->weight
;
1493 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1495 ret
= ath6kl_wmi_send_rssi_threshold_params(wmi
, &cmd
);
1497 ath6kl_err("unable to configure rssi thresholds\n");
1504 static int ath6kl_wmi_cac_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1505 struct ath6kl_vif
*vif
)
1507 struct wmi_cac_event
*reply
;
1508 struct ieee80211_tspec_ie
*ts
;
1509 u16 active_tsids
, tsinfo
;
1513 if (len
< sizeof(struct wmi_cac_event
))
1516 reply
= (struct wmi_cac_event
*) datap
;
1517 if (reply
->ac
>= WMM_NUM_AC
) {
1518 ath6kl_err("invalid AC: %d\n", reply
->ac
);
1522 if ((reply
->cac_indication
== CAC_INDICATION_ADMISSION_RESP
) &&
1523 (reply
->status_code
!= IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED
)) {
1524 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1525 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1526 tsid
= (tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1527 IEEE80211_WMM_IE_TSPEC_TID_MASK
;
1529 ath6kl_wmi_delete_pstream_cmd(wmi
, vif
->fw_vif_idx
,
1531 } else if (reply
->cac_indication
== CAC_INDICATION_NO_RESP
) {
1533 * Following assumes that there is only one outstanding
1534 * ADDTS request when this event is received
1536 spin_lock_bh(&wmi
->lock
);
1537 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1538 spin_unlock_bh(&wmi
->lock
);
1540 for (index
= 0; index
< sizeof(active_tsids
) * 8; index
++) {
1541 if ((active_tsids
>> index
) & 1)
1544 if (index
< (sizeof(active_tsids
) * 8))
1545 ath6kl_wmi_delete_pstream_cmd(wmi
, vif
->fw_vif_idx
,
1550 * Clear active tsids and Add missing handling
1551 * for delete qos stream from AP
1553 else if (reply
->cac_indication
== CAC_INDICATION_DELETE
) {
1554 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1555 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1556 ts_id
= ((tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1557 IEEE80211_WMM_IE_TSPEC_TID_MASK
);
1559 spin_lock_bh(&wmi
->lock
);
1560 wmi
->stream_exist_for_ac
[reply
->ac
] &= ~(1 << ts_id
);
1561 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1562 spin_unlock_bh(&wmi
->lock
);
1564 /* Indicate stream inactivity to driver layer only if all tsids
1565 * within this AC are deleted.
1567 if (!active_tsids
) {
1568 ath6kl_indicate_tx_activity(wmi
->parent_dev
, reply
->ac
,
1570 wmi
->fat_pipe_exist
&= ~(1 << reply
->ac
);
1577 static int ath6kl_wmi_txe_notify_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
1578 struct ath6kl_vif
*vif
)
1580 struct wmi_txe_notify_event
*ev
;
1583 if (len
< sizeof(*ev
))
1586 if (vif
->nw_type
!= INFRA_NETWORK
||
1587 !test_bit(ATH6KL_FW_CAPABILITY_TX_ERR_NOTIFY
,
1588 vif
->ar
->fw_capabilities
))
1591 if (vif
->sme_state
!= SME_CONNECTED
)
1594 ev
= (struct wmi_txe_notify_event
*) datap
;
1595 rate
= le32_to_cpu(ev
->rate
);
1596 pkts
= le32_to_cpu(ev
->pkts
);
1598 ath6kl_dbg(ATH6KL_DBG_WMI
, "TXE notify event: peer %pM rate %d%% pkts %d intvl %ds\n",
1599 vif
->bssid
, rate
, pkts
, vif
->txe_intvl
);
1601 cfg80211_cqm_txe_notify(vif
->ndev
, vif
->bssid
, pkts
,
1602 rate
, vif
->txe_intvl
, GFP_KERNEL
);
1607 int ath6kl_wmi_set_txe_notify(struct wmi
*wmi
, u8 idx
,
1608 u32 rate
, u32 pkts
, u32 intvl
)
1610 struct sk_buff
*skb
;
1611 struct wmi_txe_notify_cmd
*cmd
;
1613 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1617 cmd
= (struct wmi_txe_notify_cmd
*) skb
->data
;
1618 cmd
->rate
= cpu_to_le32(rate
);
1619 cmd
->pkts
= cpu_to_le32(pkts
);
1620 cmd
->intvl
= cpu_to_le32(intvl
);
1622 return ath6kl_wmi_cmd_send(wmi
, idx
, skb
, WMI_SET_TXE_NOTIFY_CMDID
,
1626 int ath6kl_wmi_set_rssi_filter_cmd(struct wmi
*wmi
, u8 if_idx
, s8 rssi
)
1628 struct sk_buff
*skb
;
1629 struct wmi_set_rssi_filter_cmd
*cmd
;
1632 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1636 cmd
= (struct wmi_set_rssi_filter_cmd
*) skb
->data
;
1639 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_RSSI_FILTER_CMDID
,
1644 static int ath6kl_wmi_send_snr_threshold_params(struct wmi
*wmi
,
1645 struct wmi_snr_threshold_params_cmd
*snr_cmd
)
1647 struct sk_buff
*skb
;
1648 struct wmi_snr_threshold_params_cmd
*cmd
;
1650 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1654 cmd
= (struct wmi_snr_threshold_params_cmd
*) skb
->data
;
1655 memcpy(cmd
, snr_cmd
, sizeof(struct wmi_snr_threshold_params_cmd
));
1657 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SNR_THRESHOLD_PARAMS_CMDID
,
1661 static int ath6kl_wmi_snr_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1664 struct wmi_snr_threshold_event
*reply
;
1665 struct sq_threshold_params
*sq_thresh
;
1666 struct wmi_snr_threshold_params_cmd cmd
;
1667 enum wmi_snr_threshold_val new_threshold
;
1668 u8 upper_snr_threshold
, lower_snr_threshold
;
1672 if (len
< sizeof(struct wmi_snr_threshold_event
))
1675 reply
= (struct wmi_snr_threshold_event
*) datap
;
1677 new_threshold
= (enum wmi_snr_threshold_val
) reply
->range
;
1680 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_SNR
];
1683 * Identify the threshold breached and communicate that to the app.
1684 * After that install a new set of thresholds based on the signal
1685 * quality reported by the target.
1687 if (new_threshold
) {
1688 /* Upper threshold breached */
1689 if (snr
< sq_thresh
->upper_threshold
[0]) {
1690 ath6kl_dbg(ATH6KL_DBG_WMI
,
1691 "spurious upper snr threshold event: %d\n",
1693 } else if ((snr
< sq_thresh
->upper_threshold
[1]) &&
1694 (snr
>= sq_thresh
->upper_threshold
[0])) {
1695 new_threshold
= WMI_SNR_THRESHOLD1_ABOVE
;
1696 } else if ((snr
< sq_thresh
->upper_threshold
[2]) &&
1697 (snr
>= sq_thresh
->upper_threshold
[1])) {
1698 new_threshold
= WMI_SNR_THRESHOLD2_ABOVE
;
1699 } else if ((snr
< sq_thresh
->upper_threshold
[3]) &&
1700 (snr
>= sq_thresh
->upper_threshold
[2])) {
1701 new_threshold
= WMI_SNR_THRESHOLD3_ABOVE
;
1702 } else if (snr
>= sq_thresh
->upper_threshold
[3]) {
1703 new_threshold
= WMI_SNR_THRESHOLD4_ABOVE
;
1706 /* Lower threshold breached */
1707 if (snr
> sq_thresh
->lower_threshold
[0]) {
1708 ath6kl_dbg(ATH6KL_DBG_WMI
,
1709 "spurious lower snr threshold event: %d\n",
1710 sq_thresh
->lower_threshold
[0]);
1711 } else if ((snr
> sq_thresh
->lower_threshold
[1]) &&
1712 (snr
<= sq_thresh
->lower_threshold
[0])) {
1713 new_threshold
= WMI_SNR_THRESHOLD4_BELOW
;
1714 } else if ((snr
> sq_thresh
->lower_threshold
[2]) &&
1715 (snr
<= sq_thresh
->lower_threshold
[1])) {
1716 new_threshold
= WMI_SNR_THRESHOLD3_BELOW
;
1717 } else if ((snr
> sq_thresh
->lower_threshold
[3]) &&
1718 (snr
<= sq_thresh
->lower_threshold
[2])) {
1719 new_threshold
= WMI_SNR_THRESHOLD2_BELOW
;
1720 } else if (snr
<= sq_thresh
->lower_threshold
[3]) {
1721 new_threshold
= WMI_SNR_THRESHOLD1_BELOW
;
1725 /* Calculate and install the next set of thresholds */
1726 lower_snr_threshold
= ath6kl_wmi_get_lower_threshold(snr
, sq_thresh
,
1727 sq_thresh
->lower_threshold_valid_count
);
1728 upper_snr_threshold
= ath6kl_wmi_get_upper_threshold(snr
, sq_thresh
,
1729 sq_thresh
->upper_threshold_valid_count
);
1731 /* Issue a wmi command to install the thresholds */
1732 cmd
.thresh_above1_val
= upper_snr_threshold
;
1733 cmd
.thresh_below1_val
= lower_snr_threshold
;
1734 cmd
.weight
= sq_thresh
->weight
;
1735 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1737 ath6kl_dbg(ATH6KL_DBG_WMI
,
1738 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1740 lower_snr_threshold
, upper_snr_threshold
);
1742 ret
= ath6kl_wmi_send_snr_threshold_params(wmi
, &cmd
);
1744 ath6kl_err("unable to configure snr threshold\n");
1751 static int ath6kl_wmi_aplist_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1753 struct wmi_aplist_event
*ev
= (struct wmi_aplist_event
*) datap
;
1754 struct wmi_ap_info_v1
*ap_info_v1
;
1757 if (len
< sizeof(struct wmi_aplist_event
) ||
1758 ev
->ap_list_ver
!= APLIST_VER1
)
1761 ap_info_v1
= (struct wmi_ap_info_v1
*) ev
->ap_list
;
1763 ath6kl_dbg(ATH6KL_DBG_WMI
,
1764 "number of APs in aplist event: %d\n", ev
->num_ap
);
1766 if (len
< struct_size(ev
, ap_list
, ev
->num_ap
))
1769 /* AP list version 1 contents */
1770 for (index
= 0; index
< ev
->num_ap
; index
++) {
1771 ath6kl_dbg(ATH6KL_DBG_WMI
, "AP#%d BSSID %pM Channel %d\n",
1772 index
, ap_info_v1
->bssid
, ap_info_v1
->channel
);
1779 int ath6kl_wmi_cmd_send(struct wmi
*wmi
, u8 if_idx
, struct sk_buff
*skb
,
1780 enum wmi_cmd_id cmd_id
, enum wmi_sync_flag sync_flag
)
1782 struct wmi_cmd_hdr
*cmd_hdr
;
1783 enum htc_endpoint_id ep_id
= wmi
->ep_id
;
1787 if (WARN_ON(skb
== NULL
||
1788 (if_idx
> (wmi
->parent_dev
->vif_max
- 1)))) {
1793 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi tx id %d len %d flag %d\n",
1794 cmd_id
, skb
->len
, sync_flag
);
1795 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP
, NULL
, "wmi tx ",
1796 skb
->data
, skb
->len
);
1798 if (sync_flag
>= END_WMIFLAG
) {
1803 if ((sync_flag
== SYNC_BEFORE_WMIFLAG
) ||
1804 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1806 * Make sure all data currently queued is transmitted before
1807 * the cmd execution. Establish a new sync point.
1809 ath6kl_wmi_sync_point(wmi
, if_idx
);
1812 skb_push(skb
, sizeof(struct wmi_cmd_hdr
));
1814 cmd_hdr
= (struct wmi_cmd_hdr
*) skb
->data
;
1815 cmd_hdr
->cmd_id
= cpu_to_le16(cmd_id
);
1816 info1
= if_idx
& WMI_CMD_HDR_IF_ID_MASK
;
1817 cmd_hdr
->info1
= cpu_to_le16(info1
);
1819 /* Only for OPT_TX_CMD, use BE endpoint. */
1820 if (cmd_id
== WMI_OPT_TX_FRAME_CMDID
) {
1821 ret
= ath6kl_wmi_data_hdr_add(wmi
, skb
, OPT_MSGTYPE
, false,
1822 WMI_DATA_HDR_DATA_TYPE_802_3
, 0, NULL
, if_idx
);
1827 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
, WMM_AC_BE
);
1830 ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
1832 if ((sync_flag
== SYNC_AFTER_WMIFLAG
) ||
1833 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1835 * Make sure all new data queued waits for the command to
1836 * execute. Establish a new sync point.
1838 ath6kl_wmi_sync_point(wmi
, if_idx
);
1844 int ath6kl_wmi_connect_cmd(struct wmi
*wmi
, u8 if_idx
,
1845 enum network_type nw_type
,
1846 enum dot11_auth_mode dot11_auth_mode
,
1847 enum auth_mode auth_mode
,
1848 enum ath6kl_crypto_type pairwise_crypto
,
1849 u8 pairwise_crypto_len
,
1850 enum ath6kl_crypto_type group_crypto
,
1851 u8 group_crypto_len
, int ssid_len
, u8
*ssid
,
1852 u8
*bssid
, u16 channel
, u32 ctrl_flags
,
1855 struct sk_buff
*skb
;
1856 struct wmi_connect_cmd
*cc
;
1859 ath6kl_dbg(ATH6KL_DBG_WMI
,
1860 "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d "
1861 "type %d dot11_auth %d auth %d pairwise %d group %d\n",
1862 bssid
, channel
, ctrl_flags
, ssid_len
, nw_type
,
1863 dot11_auth_mode
, auth_mode
, pairwise_crypto
, group_crypto
);
1864 ath6kl_dbg_dump(ATH6KL_DBG_WMI
, NULL
, "ssid ", ssid
, ssid_len
);
1866 wmi
->traffic_class
= 100;
1868 if ((pairwise_crypto
== NONE_CRYPT
) && (group_crypto
!= NONE_CRYPT
))
1871 if ((pairwise_crypto
!= NONE_CRYPT
) && (group_crypto
== NONE_CRYPT
))
1874 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd
));
1878 cc
= (struct wmi_connect_cmd
*) skb
->data
;
1881 memcpy(cc
->ssid
, ssid
, ssid_len
);
1883 cc
->ssid_len
= ssid_len
;
1884 cc
->nw_type
= nw_type
;
1885 cc
->dot11_auth_mode
= dot11_auth_mode
;
1886 cc
->auth_mode
= auth_mode
;
1887 cc
->prwise_crypto_type
= pairwise_crypto
;
1888 cc
->prwise_crypto_len
= pairwise_crypto_len
;
1889 cc
->grp_crypto_type
= group_crypto
;
1890 cc
->grp_crypto_len
= group_crypto_len
;
1891 cc
->ch
= cpu_to_le16(channel
);
1892 cc
->ctrl_flags
= cpu_to_le32(ctrl_flags
);
1893 cc
->nw_subtype
= nw_subtype
;
1896 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1898 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_CONNECT_CMDID
,
1904 int ath6kl_wmi_reconnect_cmd(struct wmi
*wmi
, u8 if_idx
, u8
*bssid
,
1907 struct sk_buff
*skb
;
1908 struct wmi_reconnect_cmd
*cc
;
1911 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi reconnect bssid %pM freq %d\n",
1914 wmi
->traffic_class
= 100;
1916 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd
));
1920 cc
= (struct wmi_reconnect_cmd
*) skb
->data
;
1921 cc
->channel
= cpu_to_le16(channel
);
1924 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1926 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_RECONNECT_CMDID
,
1932 int ath6kl_wmi_disconnect_cmd(struct wmi
*wmi
, u8 if_idx
)
1936 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi disconnect\n");
1938 wmi
->traffic_class
= 100;
1940 /* Disconnect command does not need to do a SYNC before. */
1941 ret
= ath6kl_wmi_simple_cmd(wmi
, if_idx
, WMI_DISCONNECT_CMDID
);
1946 /* ath6kl_wmi_start_scan_cmd is to be deprecated. Use
1947 * ath6kl_wmi_begin_scan_cmd instead. The new function supports P2P
1948 * mgmt operations using station interface.
1950 static int ath6kl_wmi_startscan_cmd(struct wmi
*wmi
, u8 if_idx
,
1951 enum wmi_scan_type scan_type
,
1952 u32 force_fgscan
, u32 is_legacy
,
1953 u32 home_dwell_time
,
1954 u32 force_scan_interval
,
1955 s8 num_chan
, u16
*ch_list
)
1957 struct sk_buff
*skb
;
1958 struct wmi_start_scan_cmd
*sc
;
1961 if ((scan_type
!= WMI_LONG_SCAN
) && (scan_type
!= WMI_SHORT_SCAN
))
1964 if (num_chan
> WMI_MAX_CHANNELS
)
1967 skb
= ath6kl_wmi_get_new_buf(struct_size(sc
, ch_list
, num_chan
));
1971 sc
= (struct wmi_start_scan_cmd
*) skb
->data
;
1972 sc
->scan_type
= scan_type
;
1973 sc
->force_fg_scan
= cpu_to_le32(force_fgscan
);
1974 sc
->is_legacy
= cpu_to_le32(is_legacy
);
1975 sc
->home_dwell_time
= cpu_to_le32(home_dwell_time
);
1976 sc
->force_scan_intvl
= cpu_to_le32(force_scan_interval
);
1977 sc
->num_ch
= num_chan
;
1979 for (i
= 0; i
< num_chan
; i
++)
1980 sc
->ch_list
[i
] = cpu_to_le16(ch_list
[i
]);
1982 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_START_SCAN_CMDID
,
1989 * beginscan supports (compared to old startscan) P2P mgmt operations using
1990 * station interface, send additional information like supported rates to
1991 * advertise and xmit rates for probe requests
1993 int ath6kl_wmi_beginscan_cmd(struct wmi
*wmi
, u8 if_idx
,
1994 enum wmi_scan_type scan_type
,
1995 u32 force_fgscan
, u32 is_legacy
,
1996 u32 home_dwell_time
, u32 force_scan_interval
,
1997 s8 num_chan
, u16
*ch_list
, u32 no_cck
, u32
*rates
)
1999 struct ieee80211_supported_band
*sband
;
2000 struct sk_buff
*skb
;
2001 struct wmi_begin_scan_cmd
*sc
;
2004 struct ath6kl
*ar
= wmi
->parent_dev
;
2008 if (!test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX
,
2009 ar
->fw_capabilities
)) {
2010 return ath6kl_wmi_startscan_cmd(wmi
, if_idx
,
2011 scan_type
, force_fgscan
,
2012 is_legacy
, home_dwell_time
,
2013 force_scan_interval
,
2017 if ((scan_type
!= WMI_LONG_SCAN
) && (scan_type
!= WMI_SHORT_SCAN
))
2020 if (num_chan
> WMI_MAX_CHANNELS
)
2023 skb
= ath6kl_wmi_get_new_buf(struct_size(sc
, ch_list
, num_chan
));
2027 sc
= (struct wmi_begin_scan_cmd
*) skb
->data
;
2028 sc
->scan_type
= scan_type
;
2029 sc
->force_fg_scan
= cpu_to_le32(force_fgscan
);
2030 sc
->is_legacy
= cpu_to_le32(is_legacy
);
2031 sc
->home_dwell_time
= cpu_to_le32(home_dwell_time
);
2032 sc
->force_scan_intvl
= cpu_to_le32(force_scan_interval
);
2033 sc
->no_cck
= cpu_to_le32(no_cck
);
2034 sc
->num_ch
= num_chan
;
2036 for (band
= 0; band
< NUM_NL80211_BANDS
; band
++) {
2037 sband
= ar
->wiphy
->bands
[band
];
2042 if (WARN_ON(band
>= ATH6KL_NUM_BANDS
))
2045 ratemask
= rates
[band
];
2046 supp_rates
= sc
->supp_rates
[band
].rates
;
2049 for (i
= 0; i
< sband
->n_bitrates
; i
++) {
2050 if ((BIT(i
) & ratemask
) == 0)
2051 continue; /* skip rate */
2052 supp_rates
[num_rates
++] =
2053 (u8
) (sband
->bitrates
[i
].bitrate
/ 5);
2055 sc
->supp_rates
[band
].nrates
= num_rates
;
2058 for (i
= 0; i
< num_chan
; i
++)
2059 sc
->ch_list
[i
] = cpu_to_le16(ch_list
[i
]);
2061 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_BEGIN_SCAN_CMDID
,
2067 int ath6kl_wmi_enable_sched_scan_cmd(struct wmi
*wmi
, u8 if_idx
, bool enable
)
2069 struct sk_buff
*skb
;
2070 struct wmi_enable_sched_scan_cmd
*sc
;
2073 skb
= ath6kl_wmi_get_new_buf(sizeof(*sc
));
2077 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s scheduled scan on vif %d\n",
2078 enable
? "enabling" : "disabling", if_idx
);
2079 sc
= (struct wmi_enable_sched_scan_cmd
*) skb
->data
;
2080 sc
->enable
= enable
? 1 : 0;
2082 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
2083 WMI_ENABLE_SCHED_SCAN_CMDID
,
2088 int ath6kl_wmi_scanparams_cmd(struct wmi
*wmi
, u8 if_idx
,
2090 u16 fg_end_sec
, u16 bg_sec
,
2091 u16 minact_chdw_msec
, u16 maxact_chdw_msec
,
2092 u16 pas_chdw_msec
, u8 short_scan_ratio
,
2093 u8 scan_ctrl_flag
, u32 max_dfsch_act_time
,
2094 u16 maxact_scan_per_ssid
)
2096 struct sk_buff
*skb
;
2097 struct wmi_scan_params_cmd
*sc
;
2100 skb
= ath6kl_wmi_get_new_buf(sizeof(*sc
));
2104 sc
= (struct wmi_scan_params_cmd
*) skb
->data
;
2105 sc
->fg_start_period
= cpu_to_le16(fg_start_sec
);
2106 sc
->fg_end_period
= cpu_to_le16(fg_end_sec
);
2107 sc
->bg_period
= cpu_to_le16(bg_sec
);
2108 sc
->minact_chdwell_time
= cpu_to_le16(minact_chdw_msec
);
2109 sc
->maxact_chdwell_time
= cpu_to_le16(maxact_chdw_msec
);
2110 sc
->pas_chdwell_time
= cpu_to_le16(pas_chdw_msec
);
2111 sc
->short_scan_ratio
= short_scan_ratio
;
2112 sc
->scan_ctrl_flags
= scan_ctrl_flag
;
2113 sc
->max_dfsch_act_time
= cpu_to_le32(max_dfsch_act_time
);
2114 sc
->maxact_scan_per_ssid
= cpu_to_le16(maxact_scan_per_ssid
);
2116 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_SCAN_PARAMS_CMDID
,
2121 int ath6kl_wmi_bssfilter_cmd(struct wmi
*wmi
, u8 if_idx
, u8 filter
, u32 ie_mask
)
2123 struct sk_buff
*skb
;
2124 struct wmi_bss_filter_cmd
*cmd
;
2127 if (filter
>= LAST_BSS_FILTER
)
2130 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2134 cmd
= (struct wmi_bss_filter_cmd
*) skb
->data
;
2135 cmd
->bss_filter
= filter
;
2136 cmd
->ie_mask
= cpu_to_le32(ie_mask
);
2138 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_BSS_FILTER_CMDID
,
2143 int ath6kl_wmi_probedssid_cmd(struct wmi
*wmi
, u8 if_idx
, u8 index
, u8 flag
,
2144 u8 ssid_len
, u8
*ssid
)
2146 struct sk_buff
*skb
;
2147 struct wmi_probed_ssid_cmd
*cmd
;
2150 if (index
>= MAX_PROBED_SSIDS
)
2153 if (ssid_len
> sizeof(cmd
->ssid
))
2156 if ((flag
& (DISABLE_SSID_FLAG
| ANY_SSID_FLAG
)) && (ssid_len
> 0))
2159 if ((flag
& SPECIFIC_SSID_FLAG
) && !ssid_len
)
2162 if (flag
& SPECIFIC_SSID_FLAG
)
2163 wmi
->is_probe_ssid
= true;
2165 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2169 cmd
= (struct wmi_probed_ssid_cmd
*) skb
->data
;
2170 cmd
->entry_index
= index
;
2172 cmd
->ssid_len
= ssid_len
;
2173 memcpy(cmd
->ssid
, ssid
, ssid_len
);
2175 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_PROBED_SSID_CMDID
,
2180 int ath6kl_wmi_listeninterval_cmd(struct wmi
*wmi
, u8 if_idx
,
2181 u16 listen_interval
,
2184 struct sk_buff
*skb
;
2185 struct wmi_listen_int_cmd
*cmd
;
2188 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2192 cmd
= (struct wmi_listen_int_cmd
*) skb
->data
;
2193 cmd
->listen_intvl
= cpu_to_le16(listen_interval
);
2194 cmd
->num_beacons
= cpu_to_le16(listen_beacons
);
2196 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_LISTEN_INT_CMDID
,
2201 int ath6kl_wmi_bmisstime_cmd(struct wmi
*wmi
, u8 if_idx
,
2202 u16 bmiss_time
, u16 num_beacons
)
2204 struct sk_buff
*skb
;
2205 struct wmi_bmiss_time_cmd
*cmd
;
2208 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2212 cmd
= (struct wmi_bmiss_time_cmd
*) skb
->data
;
2213 cmd
->bmiss_time
= cpu_to_le16(bmiss_time
);
2214 cmd
->num_beacons
= cpu_to_le16(num_beacons
);
2216 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_BMISS_TIME_CMDID
,
2221 int ath6kl_wmi_powermode_cmd(struct wmi
*wmi
, u8 if_idx
, u8 pwr_mode
)
2223 struct sk_buff
*skb
;
2224 struct wmi_power_mode_cmd
*cmd
;
2227 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2231 cmd
= (struct wmi_power_mode_cmd
*) skb
->data
;
2232 cmd
->pwr_mode
= pwr_mode
;
2233 wmi
->pwr_mode
= pwr_mode
;
2235 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_POWER_MODE_CMDID
,
2240 int ath6kl_wmi_pmparams_cmd(struct wmi
*wmi
, u8 if_idx
, u16 idle_period
,
2241 u16 ps_poll_num
, u16 dtim_policy
,
2242 u16 tx_wakeup_policy
, u16 num_tx_to_wakeup
,
2243 u16 ps_fail_event_policy
)
2245 struct sk_buff
*skb
;
2246 struct wmi_power_params_cmd
*pm
;
2249 skb
= ath6kl_wmi_get_new_buf(sizeof(*pm
));
2253 pm
= (struct wmi_power_params_cmd
*)skb
->data
;
2254 pm
->idle_period
= cpu_to_le16(idle_period
);
2255 pm
->pspoll_number
= cpu_to_le16(ps_poll_num
);
2256 pm
->dtim_policy
= cpu_to_le16(dtim_policy
);
2257 pm
->tx_wakeup_policy
= cpu_to_le16(tx_wakeup_policy
);
2258 pm
->num_tx_to_wakeup
= cpu_to_le16(num_tx_to_wakeup
);
2259 pm
->ps_fail_event_policy
= cpu_to_le16(ps_fail_event_policy
);
2261 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_POWER_PARAMS_CMDID
,
2266 int ath6kl_wmi_disctimeout_cmd(struct wmi
*wmi
, u8 if_idx
, u8 timeout
)
2268 struct sk_buff
*skb
;
2269 struct wmi_disc_timeout_cmd
*cmd
;
2272 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2276 cmd
= (struct wmi_disc_timeout_cmd
*) skb
->data
;
2277 cmd
->discon_timeout
= timeout
;
2279 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_DISC_TIMEOUT_CMDID
,
2283 ath6kl_debug_set_disconnect_timeout(wmi
->parent_dev
, timeout
);
2288 int ath6kl_wmi_addkey_cmd(struct wmi
*wmi
, u8 if_idx
, u8 key_index
,
2289 enum ath6kl_crypto_type key_type
,
2290 u8 key_usage
, u8 key_len
,
2291 u8
*key_rsc
, unsigned int key_rsc_len
,
2293 u8 key_op_ctrl
, u8
*mac_addr
,
2294 enum wmi_sync_flag sync_flag
)
2296 struct sk_buff
*skb
;
2297 struct wmi_add_cipher_key_cmd
*cmd
;
2300 ath6kl_dbg(ATH6KL_DBG_WMI
,
2301 "addkey cmd: key_index=%u key_type=%d key_usage=%d key_len=%d key_op_ctrl=%d\n",
2302 key_index
, key_type
, key_usage
, key_len
, key_op_ctrl
);
2304 if ((key_index
> WMI_MAX_KEY_INDEX
) || (key_len
> WMI_MAX_KEY_LEN
) ||
2305 (key_material
== NULL
) || key_rsc_len
> 8)
2308 if ((WEP_CRYPT
!= key_type
) && (NULL
== key_rsc
))
2311 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2315 cmd
= (struct wmi_add_cipher_key_cmd
*) skb
->data
;
2316 cmd
->key_index
= key_index
;
2317 cmd
->key_type
= key_type
;
2318 cmd
->key_usage
= key_usage
;
2319 cmd
->key_len
= key_len
;
2320 memcpy(cmd
->key
, key_material
, key_len
);
2322 if (key_rsc
!= NULL
)
2323 memcpy(cmd
->key_rsc
, key_rsc
, key_rsc_len
);
2325 cmd
->key_op_ctrl
= key_op_ctrl
;
2328 memcpy(cmd
->key_mac_addr
, mac_addr
, ETH_ALEN
);
2330 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_ADD_CIPHER_KEY_CMDID
,
2336 int ath6kl_wmi_add_krk_cmd(struct wmi
*wmi
, u8 if_idx
, const u8
*krk
)
2338 struct sk_buff
*skb
;
2339 struct wmi_add_krk_cmd
*cmd
;
2342 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2346 cmd
= (struct wmi_add_krk_cmd
*) skb
->data
;
2347 memcpy(cmd
->krk
, krk
, WMI_KRK_LEN
);
2349 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_ADD_KRK_CMDID
,
2355 int ath6kl_wmi_deletekey_cmd(struct wmi
*wmi
, u8 if_idx
, u8 key_index
)
2357 struct sk_buff
*skb
;
2358 struct wmi_delete_cipher_key_cmd
*cmd
;
2361 if (key_index
> WMI_MAX_KEY_INDEX
)
2364 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2368 cmd
= (struct wmi_delete_cipher_key_cmd
*) skb
->data
;
2369 cmd
->key_index
= key_index
;
2371 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_DELETE_CIPHER_KEY_CMDID
,
2377 int ath6kl_wmi_setpmkid_cmd(struct wmi
*wmi
, u8 if_idx
, const u8
*bssid
,
2378 const u8
*pmkid
, bool set
)
2380 struct sk_buff
*skb
;
2381 struct wmi_setpmkid_cmd
*cmd
;
2387 if (set
&& pmkid
== NULL
)
2390 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2394 cmd
= (struct wmi_setpmkid_cmd
*) skb
->data
;
2395 memcpy(cmd
->bssid
, bssid
, ETH_ALEN
);
2397 memcpy(cmd
->pmkid
, pmkid
, sizeof(cmd
->pmkid
));
2398 cmd
->enable
= PMKID_ENABLE
;
2400 memset(cmd
->pmkid
, 0, sizeof(cmd
->pmkid
));
2401 cmd
->enable
= PMKID_DISABLE
;
2404 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_PMKID_CMDID
,
2410 static int ath6kl_wmi_data_sync_send(struct wmi
*wmi
, struct sk_buff
*skb
,
2411 enum htc_endpoint_id ep_id
, u8 if_idx
)
2413 struct wmi_data_hdr
*data_hdr
;
2416 if (WARN_ON(skb
== NULL
|| ep_id
== wmi
->ep_id
)) {
2421 skb_push(skb
, sizeof(struct wmi_data_hdr
));
2423 data_hdr
= (struct wmi_data_hdr
*) skb
->data
;
2424 data_hdr
->info
= SYNC_MSGTYPE
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
2425 data_hdr
->info3
= cpu_to_le16(if_idx
& WMI_DATA_HDR_IF_IDX_MASK
);
2427 ret
= ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
2432 static int ath6kl_wmi_sync_point(struct wmi
*wmi
, u8 if_idx
)
2434 struct sk_buff
*skb
;
2435 struct wmi_sync_cmd
*cmd
;
2436 struct wmi_data_sync_bufs data_sync_bufs
[WMM_NUM_AC
];
2437 enum htc_endpoint_id ep_id
;
2438 u8 index
, num_pri_streams
= 0;
2441 memset(data_sync_bufs
, 0, sizeof(data_sync_bufs
));
2443 spin_lock_bh(&wmi
->lock
);
2445 for (index
= 0; index
< WMM_NUM_AC
; index
++) {
2446 if (wmi
->fat_pipe_exist
& (1 << index
)) {
2448 data_sync_bufs
[num_pri_streams
- 1].traffic_class
=
2453 spin_unlock_bh(&wmi
->lock
);
2455 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2459 cmd
= (struct wmi_sync_cmd
*) skb
->data
;
2462 * In the SYNC cmd sent on the control Ep, send a bitmap
2463 * of the data eps on which the Data Sync will be sent
2465 cmd
->data_sync_map
= wmi
->fat_pipe_exist
;
2467 for (index
= 0; index
< num_pri_streams
; index
++) {
2468 data_sync_bufs
[index
].skb
= ath6kl_buf_alloc(0);
2469 if (data_sync_bufs
[index
].skb
== NULL
) {
2476 * If buffer allocation for any of the dataSync fails,
2477 * then do not send the Synchronize cmd on the control ep
2483 * Send sync cmd followed by sync data messages on all
2484 * endpoints being used
2486 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SYNCHRONIZE_CMDID
,
2492 for (index
= 0; index
< num_pri_streams
; index
++) {
2493 if (WARN_ON(!data_sync_bufs
[index
].skb
)) {
2498 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
,
2499 data_sync_bufs
[index
].
2502 ath6kl_wmi_data_sync_send(wmi
, data_sync_bufs
[index
].skb
,
2505 data_sync_bufs
[index
].skb
= NULL
;
2514 /* free up any resources left over (possibly due to an error) */
2518 for (index
= 0; index
< num_pri_streams
; index
++)
2519 dev_kfree_skb((struct sk_buff
*)data_sync_bufs
[index
].skb
);
2524 int ath6kl_wmi_create_pstream_cmd(struct wmi
*wmi
, u8 if_idx
,
2525 struct wmi_create_pstream_cmd
*params
)
2527 struct sk_buff
*skb
;
2528 struct wmi_create_pstream_cmd
*cmd
;
2529 u8 fatpipe_exist_for_ac
= 0;
2531 s32 nominal_phy
= 0;
2534 if (!((params
->user_pri
<= 0x7) &&
2535 (up_to_ac
[params
->user_pri
& 0x7] == params
->traffic_class
) &&
2536 (params
->traffic_direc
== UPLINK_TRAFFIC
||
2537 params
->traffic_direc
== DNLINK_TRAFFIC
||
2538 params
->traffic_direc
== BIDIR_TRAFFIC
) &&
2539 (params
->traffic_type
== TRAFFIC_TYPE_APERIODIC
||
2540 params
->traffic_type
== TRAFFIC_TYPE_PERIODIC
) &&
2541 (params
->voice_psc_cap
== DISABLE_FOR_THIS_AC
||
2542 params
->voice_psc_cap
== ENABLE_FOR_THIS_AC
||
2543 params
->voice_psc_cap
== ENABLE_FOR_ALL_AC
) &&
2544 (params
->tsid
== WMI_IMPLICIT_PSTREAM
||
2545 params
->tsid
<= WMI_MAX_THINSTREAM
))) {
2550 * Check nominal PHY rate is >= minimalPHY,
2551 * so that DUT can allow TSRS IE
2554 /* Get the physical rate (units of bps) */
2555 min_phy
= ((le32_to_cpu(params
->min_phy_rate
) / 1000) / 1000);
2557 /* Check minimal phy < nominal phy rate */
2558 if (params
->nominal_phy
>= min_phy
) {
2559 /* unit of 500 kbps */
2560 nominal_phy
= (params
->nominal_phy
* 1000) / 500;
2561 ath6kl_dbg(ATH6KL_DBG_WMI
,
2562 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2563 min_phy
, nominal_phy
);
2565 params
->nominal_phy
= nominal_phy
;
2567 params
->nominal_phy
= 0;
2570 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2574 ath6kl_dbg(ATH6KL_DBG_WMI
,
2575 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2576 params
->traffic_class
, params
->tsid
);
2578 cmd
= (struct wmi_create_pstream_cmd
*) skb
->data
;
2579 memcpy(cmd
, params
, sizeof(*cmd
));
2581 /* This is an implicitly created Fat pipe */
2582 if ((u32
) params
->tsid
== (u32
) WMI_IMPLICIT_PSTREAM
) {
2583 spin_lock_bh(&wmi
->lock
);
2584 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2585 (1 << params
->traffic_class
));
2586 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2587 spin_unlock_bh(&wmi
->lock
);
2589 /* explicitly created thin stream within a fat pipe */
2590 spin_lock_bh(&wmi
->lock
);
2591 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2592 (1 << params
->traffic_class
));
2593 wmi
->stream_exist_for_ac
[params
->traffic_class
] |=
2594 (1 << params
->tsid
);
2596 * If a thinstream becomes active, the fat pipe automatically
2599 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2600 spin_unlock_bh(&wmi
->lock
);
2604 * Indicate activty change to driver layer only if this is the
2605 * first TSID to get created in this AC explicitly or an implicit
2606 * fat pipe is getting created.
2608 if (!fatpipe_exist_for_ac
)
2609 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2610 params
->traffic_class
, true);
2612 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_CREATE_PSTREAM_CMDID
,
2617 int ath6kl_wmi_delete_pstream_cmd(struct wmi
*wmi
, u8 if_idx
, u8 traffic_class
,
2620 struct sk_buff
*skb
;
2621 struct wmi_delete_pstream_cmd
*cmd
;
2622 u16 active_tsids
= 0;
2625 if (traffic_class
>= WMM_NUM_AC
) {
2626 ath6kl_err("invalid traffic class: %d\n", traffic_class
);
2631 ath6kl_err("invalid tsid: %d\n", tsid
);
2635 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2639 cmd
= (struct wmi_delete_pstream_cmd
*) skb
->data
;
2640 cmd
->traffic_class
= traffic_class
;
2643 spin_lock_bh(&wmi
->lock
);
2644 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2645 spin_unlock_bh(&wmi
->lock
);
2647 if (!(active_tsids
& (1 << tsid
))) {
2649 ath6kl_dbg(ATH6KL_DBG_WMI
,
2650 "TSID %d doesn't exist for traffic class: %d\n",
2651 tsid
, traffic_class
);
2655 ath6kl_dbg(ATH6KL_DBG_WMI
,
2656 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2657 traffic_class
, tsid
);
2659 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_DELETE_PSTREAM_CMDID
,
2660 SYNC_BEFORE_WMIFLAG
);
2662 spin_lock_bh(&wmi
->lock
);
2663 wmi
->stream_exist_for_ac
[traffic_class
] &= ~(1 << tsid
);
2664 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2665 spin_unlock_bh(&wmi
->lock
);
2668 * Indicate stream inactivity to driver layer only if all tsids
2669 * within this AC are deleted.
2671 if (!active_tsids
) {
2672 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2673 traffic_class
, false);
2674 wmi
->fat_pipe_exist
&= ~(1 << traffic_class
);
2680 int ath6kl_wmi_set_ip_cmd(struct wmi
*wmi
, u8 if_idx
,
2681 __be32 ips0
, __be32 ips1
)
2683 struct sk_buff
*skb
;
2684 struct wmi_set_ip_cmd
*cmd
;
2687 /* Multicast address are not valid */
2688 if (ipv4_is_multicast(ips0
) ||
2689 ipv4_is_multicast(ips1
))
2692 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd
));
2696 cmd
= (struct wmi_set_ip_cmd
*) skb
->data
;
2700 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_IP_CMDID
,
2705 static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi
*wmi
)
2712 * Relinquish credits from all implicitly created pstreams
2713 * since when we go to sleep. If user created explicit
2714 * thinstreams exists with in a fatpipe leave them intact
2715 * for the user to delete.
2717 spin_lock_bh(&wmi
->lock
);
2718 stream_exist
= wmi
->fat_pipe_exist
;
2719 spin_unlock_bh(&wmi
->lock
);
2721 for (i
= 0; i
< WMM_NUM_AC
; i
++) {
2722 if (stream_exist
& (1 << i
)) {
2724 * FIXME: Is this lock & unlock inside
2725 * for loop correct? may need rework.
2727 spin_lock_bh(&wmi
->lock
);
2728 active_tsids
= wmi
->stream_exist_for_ac
[i
];
2729 spin_unlock_bh(&wmi
->lock
);
2732 * If there are no user created thin streams
2733 * delete the fatpipe
2735 if (!active_tsids
) {
2736 stream_exist
&= ~(1 << i
);
2738 * Indicate inactivity to driver layer for
2739 * this fatpipe (pstream)
2741 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2747 /* FIXME: Can we do this assignment without locking ? */
2748 spin_lock_bh(&wmi
->lock
);
2749 wmi
->fat_pipe_exist
= stream_exist
;
2750 spin_unlock_bh(&wmi
->lock
);
2753 static int ath6kl_set_bitrate_mask64(struct wmi
*wmi
, u8 if_idx
,
2754 const struct cfg80211_bitrate_mask
*mask
)
2756 struct sk_buff
*skb
;
2757 int ret
, mode
, band
;
2758 u64 mcsrate
, ratemask
[ATH6KL_NUM_BANDS
];
2759 struct wmi_set_tx_select_rates64_cmd
*cmd
;
2761 memset(&ratemask
, 0, sizeof(ratemask
));
2763 /* only check 2.4 and 5 GHz bands, skip the rest */
2764 for (band
= 0; band
<= NL80211_BAND_5GHZ
; band
++) {
2765 /* copy legacy rate mask */
2766 ratemask
[band
] = mask
->control
[band
].legacy
;
2767 if (band
== NL80211_BAND_5GHZ
)
2769 mask
->control
[band
].legacy
<< 4;
2771 /* copy mcs rate mask */
2772 mcsrate
= mask
->control
[band
].ht_mcs
[1];
2774 mcsrate
|= mask
->control
[band
].ht_mcs
[0];
2775 ratemask
[band
] |= mcsrate
<< 12;
2776 ratemask
[band
] |= mcsrate
<< 28;
2779 ath6kl_dbg(ATH6KL_DBG_WMI
,
2780 "Ratemask 64 bit: 2.4:%llx 5:%llx\n",
2781 ratemask
[0], ratemask
[1]);
2783 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
) * WMI_RATES_MODE_MAX
);
2787 cmd
= (struct wmi_set_tx_select_rates64_cmd
*) skb
->data
;
2788 for (mode
= 0; mode
< WMI_RATES_MODE_MAX
; mode
++) {
2789 /* A mode operate in 5GHZ band */
2790 if (mode
== WMI_RATES_MODE_11A
||
2791 mode
== WMI_RATES_MODE_11A_HT20
||
2792 mode
== WMI_RATES_MODE_11A_HT40
)
2793 band
= NL80211_BAND_5GHZ
;
2795 band
= NL80211_BAND_2GHZ
;
2796 cmd
->ratemask
[mode
] = cpu_to_le64(ratemask
[band
]);
2799 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
2800 WMI_SET_TX_SELECT_RATES_CMDID
,
2805 static int ath6kl_set_bitrate_mask32(struct wmi
*wmi
, u8 if_idx
,
2806 const struct cfg80211_bitrate_mask
*mask
)
2808 struct sk_buff
*skb
;
2809 int ret
, mode
, band
;
2810 u32 mcsrate
, ratemask
[ATH6KL_NUM_BANDS
];
2811 struct wmi_set_tx_select_rates32_cmd
*cmd
;
2813 memset(&ratemask
, 0, sizeof(ratemask
));
2815 /* only check 2.4 and 5 GHz bands, skip the rest */
2816 for (band
= 0; band
<= NL80211_BAND_5GHZ
; band
++) {
2817 /* copy legacy rate mask */
2818 ratemask
[band
] = mask
->control
[band
].legacy
;
2819 if (band
== NL80211_BAND_5GHZ
)
2821 mask
->control
[band
].legacy
<< 4;
2823 /* copy mcs rate mask */
2824 mcsrate
= mask
->control
[band
].ht_mcs
[0];
2825 ratemask
[band
] |= mcsrate
<< 12;
2826 ratemask
[band
] |= mcsrate
<< 20;
2829 ath6kl_dbg(ATH6KL_DBG_WMI
,
2830 "Ratemask 32 bit: 2.4:%x 5:%x\n",
2831 ratemask
[0], ratemask
[1]);
2833 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
) * WMI_RATES_MODE_MAX
);
2837 cmd
= (struct wmi_set_tx_select_rates32_cmd
*) skb
->data
;
2838 for (mode
= 0; mode
< WMI_RATES_MODE_MAX
; mode
++) {
2839 /* A mode operate in 5GHZ band */
2840 if (mode
== WMI_RATES_MODE_11A
||
2841 mode
== WMI_RATES_MODE_11A_HT20
||
2842 mode
== WMI_RATES_MODE_11A_HT40
)
2843 band
= NL80211_BAND_5GHZ
;
2845 band
= NL80211_BAND_2GHZ
;
2846 cmd
->ratemask
[mode
] = cpu_to_le32(ratemask
[band
]);
2849 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
2850 WMI_SET_TX_SELECT_RATES_CMDID
,
2855 int ath6kl_wmi_set_bitrate_mask(struct wmi
*wmi
, u8 if_idx
,
2856 const struct cfg80211_bitrate_mask
*mask
)
2858 struct ath6kl
*ar
= wmi
->parent_dev
;
2860 if (test_bit(ATH6KL_FW_CAPABILITY_64BIT_RATES
,
2861 ar
->fw_capabilities
))
2862 return ath6kl_set_bitrate_mask64(wmi
, if_idx
, mask
);
2864 return ath6kl_set_bitrate_mask32(wmi
, if_idx
, mask
);
2867 int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi
*wmi
, u8 if_idx
,
2868 enum ath6kl_host_mode host_mode
)
2870 struct sk_buff
*skb
;
2871 struct wmi_set_host_sleep_mode_cmd
*cmd
;
2874 if ((host_mode
!= ATH6KL_HOST_MODE_ASLEEP
) &&
2875 (host_mode
!= ATH6KL_HOST_MODE_AWAKE
)) {
2876 ath6kl_err("invalid host sleep mode: %d\n", host_mode
);
2880 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2884 cmd
= (struct wmi_set_host_sleep_mode_cmd
*) skb
->data
;
2886 if (host_mode
== ATH6KL_HOST_MODE_ASLEEP
) {
2887 ath6kl_wmi_relinquish_implicit_pstream_credits(wmi
);
2888 cmd
->asleep
= cpu_to_le32(1);
2890 cmd
->awake
= cpu_to_le32(1);
2893 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
2894 WMI_SET_HOST_SLEEP_MODE_CMDID
,
2899 /* This command has zero length payload */
2900 static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi
*wmi
,
2901 struct ath6kl_vif
*vif
)
2903 struct ath6kl
*ar
= wmi
->parent_dev
;
2905 set_bit(HOST_SLEEP_MODE_CMD_PROCESSED
, &vif
->flags
);
2906 wake_up(&ar
->event_wq
);
2911 int ath6kl_wmi_set_wow_mode_cmd(struct wmi
*wmi
, u8 if_idx
,
2912 enum ath6kl_wow_mode wow_mode
,
2913 u32 filter
, u16 host_req_delay
)
2915 struct sk_buff
*skb
;
2916 struct wmi_set_wow_mode_cmd
*cmd
;
2919 if ((wow_mode
!= ATH6KL_WOW_MODE_ENABLE
) &&
2920 wow_mode
!= ATH6KL_WOW_MODE_DISABLE
) {
2921 ath6kl_err("invalid wow mode: %d\n", wow_mode
);
2925 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2929 cmd
= (struct wmi_set_wow_mode_cmd
*) skb
->data
;
2930 cmd
->enable_wow
= cpu_to_le32(wow_mode
);
2931 cmd
->filter
= cpu_to_le32(filter
);
2932 cmd
->host_req_delay
= cpu_to_le16(host_req_delay
);
2934 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_WOW_MODE_CMDID
,
2939 int ath6kl_wmi_add_wow_pattern_cmd(struct wmi
*wmi
, u8 if_idx
,
2940 u8 list_id
, u8 filter_size
,
2941 u8 filter_offset
, const u8
*filter
,
2944 struct sk_buff
*skb
;
2945 struct wmi_add_wow_pattern_cmd
*cmd
;
2951 * Allocate additional memory in the buffer to hold
2952 * filter and mask value, which is twice of filter_size.
2954 size
= sizeof(*cmd
) + (2 * filter_size
);
2956 skb
= ath6kl_wmi_get_new_buf(size
);
2960 cmd
= (struct wmi_add_wow_pattern_cmd
*) skb
->data
;
2961 cmd
->filter_list_id
= list_id
;
2962 cmd
->filter_size
= filter_size
;
2963 cmd
->filter_offset
= filter_offset
;
2965 memcpy(cmd
->filter
, filter
, filter_size
);
2967 filter_mask
= (u8
*) (cmd
->filter
+ filter_size
);
2968 memcpy(filter_mask
, mask
, filter_size
);
2970 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_ADD_WOW_PATTERN_CMDID
,
2976 int ath6kl_wmi_del_wow_pattern_cmd(struct wmi
*wmi
, u8 if_idx
,
2977 u16 list_id
, u16 filter_id
)
2979 struct sk_buff
*skb
;
2980 struct wmi_del_wow_pattern_cmd
*cmd
;
2983 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2987 cmd
= (struct wmi_del_wow_pattern_cmd
*) skb
->data
;
2988 cmd
->filter_list_id
= cpu_to_le16(list_id
);
2989 cmd
->filter_id
= cpu_to_le16(filter_id
);
2991 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_DEL_WOW_PATTERN_CMDID
,
2996 static int ath6kl_wmi_cmd_send_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
,
2997 enum wmix_command_id cmd_id
,
2998 enum wmi_sync_flag sync_flag
)
3000 struct wmix_cmd_hdr
*cmd_hdr
;
3003 skb_push(skb
, sizeof(struct wmix_cmd_hdr
));
3005 cmd_hdr
= (struct wmix_cmd_hdr
*) skb
->data
;
3006 cmd_hdr
->cmd_id
= cpu_to_le32(cmd_id
);
3008 ret
= ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_EXTENSION_CMDID
, sync_flag
);
3013 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi
*wmi
, u32 cookie
, u32 source
)
3015 struct sk_buff
*skb
;
3016 struct wmix_hb_challenge_resp_cmd
*cmd
;
3019 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3023 cmd
= (struct wmix_hb_challenge_resp_cmd
*) skb
->data
;
3024 cmd
->cookie
= cpu_to_le32(cookie
);
3025 cmd
->source
= cpu_to_le32(source
);
3027 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_HB_CHALLENGE_RESP_CMDID
,
3032 int ath6kl_wmi_config_debug_module_cmd(struct wmi
*wmi
, u32 valid
, u32 config
)
3034 struct ath6kl_wmix_dbglog_cfg_module_cmd
*cmd
;
3035 struct sk_buff
*skb
;
3038 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3042 cmd
= (struct ath6kl_wmix_dbglog_cfg_module_cmd
*) skb
->data
;
3043 cmd
->valid
= cpu_to_le32(valid
);
3044 cmd
->config
= cpu_to_le32(config
);
3046 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_DBGLOG_CFG_MODULE_CMDID
,
3051 int ath6kl_wmi_get_stats_cmd(struct wmi
*wmi
, u8 if_idx
)
3053 return ath6kl_wmi_simple_cmd(wmi
, if_idx
, WMI_GET_STATISTICS_CMDID
);
3056 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi
*wmi
, u8 if_idx
, u8 dbM
)
3058 struct sk_buff
*skb
;
3059 struct wmi_set_tx_pwr_cmd
*cmd
;
3062 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd
));
3066 cmd
= (struct wmi_set_tx_pwr_cmd
*) skb
->data
;
3069 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_TX_PWR_CMDID
,
3075 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi
*wmi
, u8 if_idx
)
3077 return ath6kl_wmi_simple_cmd(wmi
, if_idx
, WMI_GET_TX_PWR_CMDID
);
3080 int ath6kl_wmi_get_roam_tbl_cmd(struct wmi
*wmi
)
3082 return ath6kl_wmi_simple_cmd(wmi
, 0, WMI_GET_ROAM_TBL_CMDID
);
3085 int ath6kl_wmi_set_lpreamble_cmd(struct wmi
*wmi
, u8 if_idx
, u8 status
,
3088 struct sk_buff
*skb
;
3089 struct wmi_set_lpreamble_cmd
*cmd
;
3092 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd
));
3096 cmd
= (struct wmi_set_lpreamble_cmd
*) skb
->data
;
3097 cmd
->status
= status
;
3098 cmd
->preamble_policy
= preamble_policy
;
3100 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_LPREAMBLE_CMDID
,
3105 int ath6kl_wmi_set_rts_cmd(struct wmi
*wmi
, u16 threshold
)
3107 struct sk_buff
*skb
;
3108 struct wmi_set_rts_cmd
*cmd
;
3111 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd
));
3115 cmd
= (struct wmi_set_rts_cmd
*) skb
->data
;
3116 cmd
->threshold
= cpu_to_le16(threshold
);
3118 ret
= ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_SET_RTS_CMDID
,
3123 int ath6kl_wmi_set_wmm_txop(struct wmi
*wmi
, u8 if_idx
, enum wmi_txop_cfg cfg
)
3125 struct sk_buff
*skb
;
3126 struct wmi_set_wmm_txop_cmd
*cmd
;
3129 if (!((cfg
== WMI_TXOP_DISABLED
) || (cfg
== WMI_TXOP_ENABLED
)))
3132 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd
));
3136 cmd
= (struct wmi_set_wmm_txop_cmd
*) skb
->data
;
3137 cmd
->txop_enable
= cfg
;
3139 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_WMM_TXOP_CMDID
,
3144 int ath6kl_wmi_set_keepalive_cmd(struct wmi
*wmi
, u8 if_idx
,
3145 u8 keep_alive_intvl
)
3147 struct sk_buff
*skb
;
3148 struct wmi_set_keepalive_cmd
*cmd
;
3151 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3155 cmd
= (struct wmi_set_keepalive_cmd
*) skb
->data
;
3156 cmd
->keep_alive_intvl
= keep_alive_intvl
;
3158 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_KEEPALIVE_CMDID
,
3162 ath6kl_debug_set_keepalive(wmi
->parent_dev
, keep_alive_intvl
);
3167 int ath6kl_wmi_set_htcap_cmd(struct wmi
*wmi
, u8 if_idx
,
3168 enum nl80211_band band
,
3169 struct ath6kl_htcap
*htcap
)
3171 struct sk_buff
*skb
;
3172 struct wmi_set_htcap_cmd
*cmd
;
3174 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3178 cmd
= (struct wmi_set_htcap_cmd
*) skb
->data
;
3181 * NOTE: Band in firmware matches enum nl80211_band, it is unlikely
3182 * this will be changed in firmware. If at all there is any change in
3183 * band value, the host needs to be fixed.
3186 cmd
->ht_enable
= !!htcap
->ht_enable
;
3187 cmd
->ht20_sgi
= !!(htcap
->cap_info
& IEEE80211_HT_CAP_SGI_20
);
3188 cmd
->ht40_supported
=
3189 !!(htcap
->cap_info
& IEEE80211_HT_CAP_SUP_WIDTH_20_40
);
3190 cmd
->ht40_sgi
= !!(htcap
->cap_info
& IEEE80211_HT_CAP_SGI_40
);
3191 cmd
->intolerant_40mhz
=
3192 !!(htcap
->cap_info
& IEEE80211_HT_CAP_40MHZ_INTOLERANT
);
3193 cmd
->max_ampdu_len_exp
= htcap
->ampdu_factor
;
3195 ath6kl_dbg(ATH6KL_DBG_WMI
,
3196 "Set htcap: band:%d ht_enable:%d 40mhz:%d sgi_20mhz:%d sgi_40mhz:%d 40mhz_intolerant:%d ampdu_len_exp:%d\n",
3197 cmd
->band
, cmd
->ht_enable
, cmd
->ht40_supported
,
3198 cmd
->ht20_sgi
, cmd
->ht40_sgi
, cmd
->intolerant_40mhz
,
3199 cmd
->max_ampdu_len_exp
);
3200 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_HT_CAP_CMDID
,
3204 int ath6kl_wmi_test_cmd(struct wmi
*wmi
, void *buf
, size_t len
)
3206 struct sk_buff
*skb
;
3209 skb
= ath6kl_wmi_get_new_buf(len
);
3213 memcpy(skb
->data
, buf
, len
);
3215 ret
= ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_TEST_CMDID
, NO_SYNC_WMIFLAG
);
3220 int ath6kl_wmi_mcast_filter_cmd(struct wmi
*wmi
, u8 if_idx
, bool mc_all_on
)
3222 struct sk_buff
*skb
;
3223 struct wmi_mcast_filter_cmd
*cmd
;
3226 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3230 cmd
= (struct wmi_mcast_filter_cmd
*) skb
->data
;
3231 cmd
->mcast_all_enable
= mc_all_on
;
3233 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_MCAST_FILTER_CMDID
,
3238 int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi
*wmi
, u8 if_idx
,
3239 u8
*filter
, bool add_filter
)
3241 struct sk_buff
*skb
;
3242 struct wmi_mcast_filter_add_del_cmd
*cmd
;
3245 if ((filter
[0] != 0x33 || filter
[1] != 0x33) &&
3246 (filter
[0] != 0x01 || filter
[1] != 0x00 ||
3247 filter
[2] != 0x5e || filter
[3] > 0x7f)) {
3248 ath6kl_warn("invalid multicast filter address\n");
3252 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3256 cmd
= (struct wmi_mcast_filter_add_del_cmd
*) skb
->data
;
3257 memcpy(cmd
->mcast_mac
, filter
, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE
);
3258 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
3259 add_filter
? WMI_SET_MCAST_FILTER_CMDID
:
3260 WMI_DEL_MCAST_FILTER_CMDID
,
3266 int ath6kl_wmi_sta_bmiss_enhance_cmd(struct wmi
*wmi
, u8 if_idx
, bool enhance
)
3268 struct sk_buff
*skb
;
3269 struct wmi_sta_bmiss_enhance_cmd
*cmd
;
3272 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3276 cmd
= (struct wmi_sta_bmiss_enhance_cmd
*) skb
->data
;
3277 cmd
->enable
= enhance
? 1 : 0;
3279 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
3280 WMI_STA_BMISS_ENHANCE_CMDID
,
3285 int ath6kl_wmi_set_regdomain_cmd(struct wmi
*wmi
, const char *alpha2
)
3287 struct sk_buff
*skb
;
3288 struct wmi_set_regdomain_cmd
*cmd
;
3290 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3294 cmd
= (struct wmi_set_regdomain_cmd
*) skb
->data
;
3295 memcpy(cmd
->iso_name
, alpha2
, 2);
3297 return ath6kl_wmi_cmd_send(wmi
, 0, skb
,
3298 WMI_SET_REGDOMAIN_CMDID
,
3302 s32
ath6kl_wmi_get_rate(struct wmi
*wmi
, s8 rate_index
)
3304 struct ath6kl
*ar
= wmi
->parent_dev
;
3308 if (rate_index
== RATE_AUTO
)
3311 /* SGI is stored as the MSB of the rate_index */
3312 if (rate_index
& RATE_INDEX_MSB
) {
3313 rate_index
&= RATE_INDEX_WITHOUT_SGI_MASK
;
3317 if (test_bit(ATH6KL_FW_CAPABILITY_RATETABLE_MCS15
,
3318 ar
->fw_capabilities
)) {
3319 if (WARN_ON(rate_index
>= ARRAY_SIZE(wmi_rate_tbl_mcs15
)))
3322 ret
= wmi_rate_tbl_mcs15
[(u32
) rate_index
][sgi
];
3324 if (WARN_ON(rate_index
>= ARRAY_SIZE(wmi_rate_tbl
)))
3327 ret
= wmi_rate_tbl
[(u32
) rate_index
][sgi
];
3333 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi
*wmi
, u8
*datap
,
3336 struct wmi_pmkid_list_reply
*reply
;
3339 if (len
< sizeof(struct wmi_pmkid_list_reply
))
3342 reply
= (struct wmi_pmkid_list_reply
*)datap
;
3343 expected_len
= sizeof(reply
->num_pmkid
) +
3344 le32_to_cpu(reply
->num_pmkid
) * WMI_PMKID_LEN
;
3346 if (len
< expected_len
)
3352 static int ath6kl_wmi_addba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
3353 struct ath6kl_vif
*vif
)
3355 struct wmi_addba_req_event
*cmd
= (struct wmi_addba_req_event
*) datap
;
3357 aggr_recv_addba_req_evt(vif
, cmd
->tid
,
3358 le16_to_cpu(cmd
->st_seq_no
), cmd
->win_sz
);
3363 static int ath6kl_wmi_delba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
3364 struct ath6kl_vif
*vif
)
3366 struct wmi_delba_event
*cmd
= (struct wmi_delba_event
*) datap
;
3368 aggr_recv_delba_req_evt(vif
, cmd
->tid
);
3373 /* AP mode functions */
3375 int ath6kl_wmi_ap_profile_commit(struct wmi
*wmip
, u8 if_idx
,
3376 struct wmi_connect_cmd
*p
)
3378 struct sk_buff
*skb
;
3379 struct wmi_connect_cmd
*cm
;
3382 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
3386 cm
= (struct wmi_connect_cmd
*) skb
->data
;
3387 memcpy(cm
, p
, sizeof(*cm
));
3389 res
= ath6kl_wmi_cmd_send(wmip
, if_idx
, skb
, WMI_AP_CONFIG_COMMIT_CMDID
,
3391 ath6kl_dbg(ATH6KL_DBG_WMI
,
3392 "%s: nw_type=%u auth_mode=%u ch=%u ctrl_flags=0x%x-> res=%d\n",
3393 __func__
, p
->nw_type
, p
->auth_mode
, le16_to_cpu(p
->ch
),
3394 le32_to_cpu(p
->ctrl_flags
), res
);
3398 int ath6kl_wmi_ap_set_mlme(struct wmi
*wmip
, u8 if_idx
, u8 cmd
, const u8
*mac
,
3401 struct sk_buff
*skb
;
3402 struct wmi_ap_set_mlme_cmd
*cm
;
3404 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
3408 cm
= (struct wmi_ap_set_mlme_cmd
*) skb
->data
;
3409 memcpy(cm
->mac
, mac
, ETH_ALEN
);
3410 cm
->reason
= cpu_to_le16(reason
);
3413 ath6kl_dbg(ATH6KL_DBG_WMI
, "ap_set_mlme: cmd=%d reason=%d\n", cm
->cmd
,
3416 return ath6kl_wmi_cmd_send(wmip
, if_idx
, skb
, WMI_AP_SET_MLME_CMDID
,
3420 int ath6kl_wmi_ap_hidden_ssid(struct wmi
*wmi
, u8 if_idx
, bool enable
)
3422 struct sk_buff
*skb
;
3423 struct wmi_ap_hidden_ssid_cmd
*cmd
;
3425 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3429 cmd
= (struct wmi_ap_hidden_ssid_cmd
*) skb
->data
;
3430 cmd
->hidden_ssid
= enable
? 1 : 0;
3432 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_AP_HIDDEN_SSID_CMDID
,
3436 /* This command will be used to enable/disable AP uAPSD feature */
3437 int ath6kl_wmi_ap_set_apsd(struct wmi
*wmi
, u8 if_idx
, u8 enable
)
3439 struct wmi_ap_set_apsd_cmd
*cmd
;
3440 struct sk_buff
*skb
;
3442 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3446 cmd
= (struct wmi_ap_set_apsd_cmd
*)skb
->data
;
3447 cmd
->enable
= enable
;
3449 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_AP_SET_APSD_CMDID
,
3453 int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi
*wmi
, u8 if_idx
,
3454 u16 aid
, u16 bitmap
, u32 flags
)
3456 struct wmi_ap_apsd_buffered_traffic_cmd
*cmd
;
3457 struct sk_buff
*skb
;
3459 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3463 cmd
= (struct wmi_ap_apsd_buffered_traffic_cmd
*)skb
->data
;
3464 cmd
->aid
= cpu_to_le16(aid
);
3465 cmd
->bitmap
= cpu_to_le16(bitmap
);
3466 cmd
->flags
= cpu_to_le32(flags
);
3468 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
3469 WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID
,
3473 static int ath6kl_wmi_pspoll_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
3474 struct ath6kl_vif
*vif
)
3476 struct wmi_pspoll_event
*ev
;
3478 if (len
< sizeof(struct wmi_pspoll_event
))
3481 ev
= (struct wmi_pspoll_event
*) datap
;
3483 ath6kl_pspoll_event(vif
, le16_to_cpu(ev
->aid
));
3488 static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi
*wmi
, u8
*datap
, int len
,
3489 struct ath6kl_vif
*vif
)
3491 ath6kl_dtimexpiry_event(vif
);
3496 int ath6kl_wmi_set_pvb_cmd(struct wmi
*wmi
, u8 if_idx
, u16 aid
,
3499 struct sk_buff
*skb
;
3500 struct wmi_ap_set_pvb_cmd
*cmd
;
3503 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd
));
3507 cmd
= (struct wmi_ap_set_pvb_cmd
*) skb
->data
;
3508 cmd
->aid
= cpu_to_le16(aid
);
3509 cmd
->rsvd
= cpu_to_le16(0);
3510 cmd
->flag
= cpu_to_le32(flag
);
3512 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_AP_SET_PVB_CMDID
,
3518 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi
*wmi
, u8 if_idx
,
3520 bool rx_dot11_hdr
, bool defrag_on_host
)
3522 struct sk_buff
*skb
;
3523 struct wmi_rx_frame_format_cmd
*cmd
;
3526 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3530 cmd
= (struct wmi_rx_frame_format_cmd
*) skb
->data
;
3531 cmd
->dot11_hdr
= rx_dot11_hdr
? 1 : 0;
3532 cmd
->defrag_on_host
= defrag_on_host
? 1 : 0;
3533 cmd
->meta_ver
= rx_meta_ver
;
3535 /* Delete the local aggr state, on host */
3536 ret
= ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_RX_FRAME_FORMAT_CMDID
,
3542 int ath6kl_wmi_set_appie_cmd(struct wmi
*wmi
, u8 if_idx
, u8 mgmt_frm_type
,
3543 const u8
*ie
, u8 ie_len
)
3545 struct sk_buff
*skb
;
3546 struct wmi_set_appie_cmd
*p
;
3548 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + ie_len
);
3552 ath6kl_dbg(ATH6KL_DBG_WMI
,
3553 "set_appie_cmd: mgmt_frm_type=%u ie_len=%u\n",
3554 mgmt_frm_type
, ie_len
);
3555 p
= (struct wmi_set_appie_cmd
*) skb
->data
;
3556 p
->mgmt_frm_type
= mgmt_frm_type
;
3559 if (ie
!= NULL
&& ie_len
> 0)
3560 memcpy(p
->ie_info
, ie
, ie_len
);
3562 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_APPIE_CMDID
,
3566 int ath6kl_wmi_set_ie_cmd(struct wmi
*wmi
, u8 if_idx
, u8 ie_id
, u8 ie_field
,
3567 const u8
*ie_info
, u8 ie_len
)
3569 struct sk_buff
*skb
;
3570 struct wmi_set_ie_cmd
*p
;
3572 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + ie_len
);
3576 ath6kl_dbg(ATH6KL_DBG_WMI
, "set_ie_cmd: ie_id=%u ie_ie_field=%u ie_len=%u\n",
3577 ie_id
, ie_field
, ie_len
);
3578 p
= (struct wmi_set_ie_cmd
*) skb
->data
;
3580 p
->ie_field
= ie_field
;
3582 if (ie_info
&& ie_len
> 0)
3583 memcpy(p
->ie_info
, ie_info
, ie_len
);
3585 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SET_IE_CMDID
,
3589 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi
*wmi
, bool disable
)
3591 struct sk_buff
*skb
;
3592 struct wmi_disable_11b_rates_cmd
*cmd
;
3594 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3598 ath6kl_dbg(ATH6KL_DBG_WMI
, "disable_11b_rates_cmd: disable=%u\n",
3600 cmd
= (struct wmi_disable_11b_rates_cmd
*) skb
->data
;
3601 cmd
->disable
= disable
? 1 : 0;
3603 return ath6kl_wmi_cmd_send(wmi
, 0, skb
, WMI_DISABLE_11B_RATES_CMDID
,
3607 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi
*wmi
, u8 if_idx
, u32 freq
, u32 dur
)
3609 struct sk_buff
*skb
;
3610 struct wmi_remain_on_chnl_cmd
*p
;
3612 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
3616 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl_cmd: freq=%u dur=%u\n",
3618 p
= (struct wmi_remain_on_chnl_cmd
*) skb
->data
;
3619 p
->freq
= cpu_to_le32(freq
);
3620 p
->duration
= cpu_to_le32(dur
);
3621 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_REMAIN_ON_CHNL_CMDID
,
3625 /* ath6kl_wmi_send_action_cmd is to be deprecated. Use
3626 * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P
3627 * mgmt operations using station interface.
3629 static int ath6kl_wmi_send_action_cmd(struct wmi
*wmi
, u8 if_idx
, u32 id
,
3630 u32 freq
, u32 wait
, const u8
*data
,
3633 struct sk_buff
*skb
;
3634 struct wmi_send_action_cmd
*p
;
3638 return -EINVAL
; /* Offload for wait not supported */
3640 buf
= kmemdup(data
, data_len
, GFP_KERNEL
);
3644 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
3650 kfree(wmi
->last_mgmt_tx_frame
);
3651 wmi
->last_mgmt_tx_frame
= buf
;
3652 wmi
->last_mgmt_tx_frame_len
= data_len
;
3654 ath6kl_dbg(ATH6KL_DBG_WMI
,
3655 "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3656 id
, freq
, wait
, data_len
);
3657 p
= (struct wmi_send_action_cmd
*) skb
->data
;
3658 p
->id
= cpu_to_le32(id
);
3659 p
->freq
= cpu_to_le32(freq
);
3660 p
->wait
= cpu_to_le32(wait
);
3661 p
->len
= cpu_to_le16(data_len
);
3662 memcpy(p
->data
, data
, data_len
);
3663 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SEND_ACTION_CMDID
,
3667 static int __ath6kl_wmi_send_mgmt_cmd(struct wmi
*wmi
, u8 if_idx
, u32 id
,
3668 u32 freq
, u32 wait
, const u8
*data
,
3669 u16 data_len
, u32 no_cck
)
3671 struct sk_buff
*skb
;
3672 struct wmi_send_mgmt_cmd
*p
;
3676 return -EINVAL
; /* Offload for wait not supported */
3678 buf
= kmemdup(data
, data_len
, GFP_KERNEL
);
3682 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
3688 kfree(wmi
->last_mgmt_tx_frame
);
3689 wmi
->last_mgmt_tx_frame
= buf
;
3690 wmi
->last_mgmt_tx_frame_len
= data_len
;
3692 ath6kl_dbg(ATH6KL_DBG_WMI
,
3693 "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3694 id
, freq
, wait
, data_len
);
3695 p
= (struct wmi_send_mgmt_cmd
*) skb
->data
;
3696 p
->id
= cpu_to_le32(id
);
3697 p
->freq
= cpu_to_le32(freq
);
3698 p
->wait
= cpu_to_le32(wait
);
3699 p
->no_cck
= cpu_to_le32(no_cck
);
3700 p
->len
= cpu_to_le16(data_len
);
3701 memcpy(p
->data
, data
, data_len
);
3702 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_SEND_MGMT_CMDID
,
3706 int ath6kl_wmi_send_mgmt_cmd(struct wmi
*wmi
, u8 if_idx
, u32 id
, u32 freq
,
3707 u32 wait
, const u8
*data
, u16 data_len
,
3711 struct ath6kl
*ar
= wmi
->parent_dev
;
3713 if (test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX
,
3714 ar
->fw_capabilities
)) {
3716 * If capable of doing P2P mgmt operations using
3717 * station interface, send additional information like
3718 * supported rates to advertise and xmit rates for
3721 status
= __ath6kl_wmi_send_mgmt_cmd(ar
->wmi
, if_idx
, id
, freq
,
3722 wait
, data
, data_len
,
3725 status
= ath6kl_wmi_send_action_cmd(ar
->wmi
, if_idx
, id
, freq
,
3726 wait
, data
, data_len
);
3732 int ath6kl_wmi_send_probe_response_cmd(struct wmi
*wmi
, u8 if_idx
, u32 freq
,
3733 const u8
*dst
, const u8
*data
,
3736 struct sk_buff
*skb
;
3737 struct wmi_p2p_probe_response_cmd
*p
;
3738 size_t cmd_len
= sizeof(*p
) + data_len
;
3741 cmd_len
++; /* work around target minimum length requirement */
3743 skb
= ath6kl_wmi_get_new_buf(cmd_len
);
3747 ath6kl_dbg(ATH6KL_DBG_WMI
,
3748 "send_probe_response_cmd: freq=%u dst=%pM len=%u\n",
3749 freq
, dst
, data_len
);
3750 p
= (struct wmi_p2p_probe_response_cmd
*) skb
->data
;
3751 p
->freq
= cpu_to_le32(freq
);
3752 memcpy(p
->destination_addr
, dst
, ETH_ALEN
);
3753 p
->len
= cpu_to_le16(data_len
);
3754 memcpy(p
->data
, data
, data_len
);
3755 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
,
3756 WMI_SEND_PROBE_RESPONSE_CMDID
,
3760 int ath6kl_wmi_probe_report_req_cmd(struct wmi
*wmi
, u8 if_idx
, bool enable
)
3762 struct sk_buff
*skb
;
3763 struct wmi_probe_req_report_cmd
*p
;
3765 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
3769 ath6kl_dbg(ATH6KL_DBG_WMI
, "probe_report_req_cmd: enable=%u\n",
3771 p
= (struct wmi_probe_req_report_cmd
*) skb
->data
;
3772 p
->enable
= enable
? 1 : 0;
3773 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_PROBE_REQ_REPORT_CMDID
,
3777 int ath6kl_wmi_info_req_cmd(struct wmi
*wmi
, u8 if_idx
, u32 info_req_flags
)
3779 struct sk_buff
*skb
;
3780 struct wmi_get_p2p_info
*p
;
3782 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
3786 ath6kl_dbg(ATH6KL_DBG_WMI
, "info_req_cmd: flags=%x\n",
3788 p
= (struct wmi_get_p2p_info
*) skb
->data
;
3789 p
->info_req_flags
= cpu_to_le32(info_req_flags
);
3790 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_GET_P2P_INFO_CMDID
,
3794 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi
*wmi
, u8 if_idx
)
3796 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl_cmd\n");
3797 return ath6kl_wmi_simple_cmd(wmi
, if_idx
,
3798 WMI_CANCEL_REMAIN_ON_CHNL_CMDID
);
3801 int ath6kl_wmi_set_inact_period(struct wmi
*wmi
, u8 if_idx
, int inact_timeout
)
3803 struct sk_buff
*skb
;
3804 struct wmi_set_inact_period_cmd
*cmd
;
3806 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
3810 cmd
= (struct wmi_set_inact_period_cmd
*) skb
->data
;
3811 cmd
->inact_period
= cpu_to_le32(inact_timeout
);
3812 cmd
->num_null_func
= 0;
3814 return ath6kl_wmi_cmd_send(wmi
, if_idx
, skb
, WMI_AP_CONN_INACT_CMDID
,
3818 static void ath6kl_wmi_hb_challenge_resp_event(struct wmi
*wmi
, u8
*datap
,
3821 struct wmix_hb_challenge_resp_cmd
*cmd
;
3823 if (len
< sizeof(struct wmix_hb_challenge_resp_cmd
))
3826 cmd
= (struct wmix_hb_challenge_resp_cmd
*) datap
;
3827 ath6kl_recovery_hb_event(wmi
->parent_dev
,
3828 le32_to_cpu(cmd
->cookie
));
3831 static int ath6kl_wmi_control_rx_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
)
3833 struct wmix_cmd_hdr
*cmd
;
3839 if (skb
->len
< sizeof(struct wmix_cmd_hdr
)) {
3840 ath6kl_err("bad packet 1\n");
3844 cmd
= (struct wmix_cmd_hdr
*) skb
->data
;
3845 id
= le32_to_cpu(cmd
->cmd_id
);
3847 skb_pull(skb
, sizeof(struct wmix_cmd_hdr
));
3853 case WMIX_HB_CHALLENGE_RESP_EVENTID
:
3854 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi event hb challenge resp\n");
3855 ath6kl_wmi_hb_challenge_resp_event(wmi
, datap
, len
);
3857 case WMIX_DBGLOG_EVENTID
:
3858 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi event dbglog len %d\n", len
);
3859 ath6kl_debug_fwlog_event(wmi
->parent_dev
, datap
, len
);
3862 ath6kl_warn("unknown cmd id 0x%x\n", id
);
3870 static int ath6kl_wmi_roam_tbl_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
3872 return ath6kl_debug_roam_tbl_event(wmi
->parent_dev
, datap
, len
);
3875 /* Process interface specific wmi events, caller would free the datap */
3876 static int ath6kl_wmi_proc_events_vif(struct wmi
*wmi
, u16 if_idx
, u16 cmd_id
,
3879 struct ath6kl_vif
*vif
;
3881 vif
= ath6kl_get_vif_by_index(wmi
->parent_dev
, if_idx
);
3883 ath6kl_dbg(ATH6KL_DBG_WMI
,
3884 "Wmi event for unavailable vif, vif_index:%d\n",
3890 case WMI_CONNECT_EVENTID
:
3891 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CONNECT_EVENTID\n");
3892 return ath6kl_wmi_connect_event_rx(wmi
, datap
, len
, vif
);
3893 case WMI_DISCONNECT_EVENTID
:
3894 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DISCONNECT_EVENTID\n");
3895 return ath6kl_wmi_disconnect_event_rx(wmi
, datap
, len
, vif
);
3896 case WMI_TKIP_MICERR_EVENTID
:
3897 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TKIP_MICERR_EVENTID\n");
3898 return ath6kl_wmi_tkip_micerr_event_rx(wmi
, datap
, len
, vif
);
3899 case WMI_BSSINFO_EVENTID
:
3900 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_BSSINFO_EVENTID\n");
3901 return ath6kl_wmi_bssinfo_event_rx(wmi
, datap
, len
, vif
);
3902 case WMI_NEIGHBOR_REPORT_EVENTID
:
3903 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_NEIGHBOR_REPORT_EVENTID\n");
3904 return ath6kl_wmi_neighbor_report_event_rx(wmi
, datap
, len
,
3906 case WMI_SCAN_COMPLETE_EVENTID
:
3907 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SCAN_COMPLETE_EVENTID\n");
3908 return ath6kl_wmi_scan_complete_rx(wmi
, datap
, len
, vif
);
3909 case WMI_REPORT_STATISTICS_EVENTID
:
3910 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_STATISTICS_EVENTID\n");
3911 return ath6kl_wmi_stats_event_rx(wmi
, datap
, len
, vif
);
3912 case WMI_CAC_EVENTID
:
3913 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CAC_EVENTID\n");
3914 return ath6kl_wmi_cac_event_rx(wmi
, datap
, len
, vif
);
3915 case WMI_PSPOLL_EVENTID
:
3916 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSPOLL_EVENTID\n");
3917 return ath6kl_wmi_pspoll_event_rx(wmi
, datap
, len
, vif
);
3918 case WMI_DTIMEXPIRY_EVENTID
:
3919 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DTIMEXPIRY_EVENTID\n");
3920 return ath6kl_wmi_dtimexpiry_event_rx(wmi
, datap
, len
, vif
);
3921 case WMI_ADDBA_REQ_EVENTID
:
3922 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_REQ_EVENTID\n");
3923 return ath6kl_wmi_addba_req_event_rx(wmi
, datap
, len
, vif
);
3924 case WMI_DELBA_REQ_EVENTID
:
3925 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DELBA_REQ_EVENTID\n");
3926 return ath6kl_wmi_delba_req_event_rx(wmi
, datap
, len
, vif
);
3927 case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID
:
3928 ath6kl_dbg(ATH6KL_DBG_WMI
,
3929 "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID");
3930 return ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi
, vif
);
3931 case WMI_REMAIN_ON_CHNL_EVENTID
:
3932 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REMAIN_ON_CHNL_EVENTID\n");
3933 return ath6kl_wmi_remain_on_chnl_event_rx(wmi
, datap
, len
, vif
);
3934 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID
:
3935 ath6kl_dbg(ATH6KL_DBG_WMI
,
3936 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
3937 return ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi
, datap
,
3939 case WMI_TX_STATUS_EVENTID
:
3940 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_STATUS_EVENTID\n");
3941 return ath6kl_wmi_tx_status_event_rx(wmi
, datap
, len
, vif
);
3942 case WMI_RX_PROBE_REQ_EVENTID
:
3943 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_PROBE_REQ_EVENTID\n");
3944 return ath6kl_wmi_rx_probe_req_event_rx(wmi
, datap
, len
, vif
);
3945 case WMI_RX_ACTION_EVENTID
:
3946 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_ACTION_EVENTID\n");
3947 return ath6kl_wmi_rx_action_event_rx(wmi
, datap
, len
, vif
);
3948 case WMI_TXE_NOTIFY_EVENTID
:
3949 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TXE_NOTIFY_EVENTID\n");
3950 return ath6kl_wmi_txe_notify_event_rx(wmi
, datap
, len
, vif
);
3952 ath6kl_dbg(ATH6KL_DBG_WMI
, "unknown cmd id 0x%x\n", cmd_id
);
3959 static int ath6kl_wmi_proc_events(struct wmi
*wmi
, struct sk_buff
*skb
)
3961 struct wmi_cmd_hdr
*cmd
;
3968 cmd
= (struct wmi_cmd_hdr
*) skb
->data
;
3969 id
= le16_to_cpu(cmd
->cmd_id
);
3970 if_idx
= le16_to_cpu(cmd
->info1
) & WMI_CMD_HDR_IF_ID_MASK
;
3972 skb_pull(skb
, sizeof(struct wmi_cmd_hdr
));
3976 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi rx id %d len %d\n", id
, len
);
3977 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP
, NULL
, "wmi rx ",
3981 case WMI_GET_BITRATE_CMDID
:
3982 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_BITRATE_CMDID\n");
3983 ret
= ath6kl_wmi_bitrate_reply_rx(wmi
, datap
, len
);
3985 case WMI_GET_CHANNEL_LIST_CMDID
:
3986 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_CHANNEL_LIST_CMDID\n");
3987 ret
= ath6kl_wmi_ch_list_reply_rx(wmi
, datap
, len
);
3989 case WMI_GET_TX_PWR_CMDID
:
3990 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_TX_PWR_CMDID\n");
3991 ret
= ath6kl_wmi_tx_pwr_reply_rx(wmi
, datap
, len
);
3993 case WMI_READY_EVENTID
:
3994 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_READY_EVENTID\n");
3995 ret
= ath6kl_wmi_ready_event_rx(wmi
, datap
, len
);
3997 case WMI_PEER_NODE_EVENTID
:
3998 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PEER_NODE_EVENTID\n");
3999 ret
= ath6kl_wmi_peer_node_event_rx(wmi
, datap
, len
);
4001 case WMI_REGDOMAIN_EVENTID
:
4002 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REGDOMAIN_EVENTID\n");
4003 ath6kl_wmi_regdomain_event(wmi
, datap
, len
);
4005 case WMI_PSTREAM_TIMEOUT_EVENTID
:
4006 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
4007 ret
= ath6kl_wmi_pstream_timeout_event_rx(wmi
, datap
, len
);
4009 case WMI_CMDERROR_EVENTID
:
4010 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CMDERROR_EVENTID\n");
4011 ret
= ath6kl_wmi_error_event_rx(wmi
, datap
, len
);
4013 case WMI_RSSI_THRESHOLD_EVENTID
:
4014 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RSSI_THRESHOLD_EVENTID\n");
4015 ret
= ath6kl_wmi_rssi_threshold_event_rx(wmi
, datap
, len
);
4017 case WMI_ERROR_REPORT_EVENTID
:
4018 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ERROR_REPORT_EVENTID\n");
4020 case WMI_OPT_RX_FRAME_EVENTID
:
4021 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_OPT_RX_FRAME_EVENTID\n");
4022 /* this event has been deprecated */
4024 case WMI_REPORT_ROAM_TBL_EVENTID
:
4025 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_TBL_EVENTID\n");
4026 ret
= ath6kl_wmi_roam_tbl_event_rx(wmi
, datap
, len
);
4028 case WMI_EXTENSION_EVENTID
:
4029 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_EXTENSION_EVENTID\n");
4030 ret
= ath6kl_wmi_control_rx_xtnd(wmi
, skb
);
4032 case WMI_CHANNEL_CHANGE_EVENTID
:
4033 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CHANNEL_CHANGE_EVENTID\n");
4035 case WMI_REPORT_ROAM_DATA_EVENTID
:
4036 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_DATA_EVENTID\n");
4038 case WMI_TEST_EVENTID
:
4039 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TEST_EVENTID\n");
4040 ret
= ath6kl_wmi_test_rx(wmi
, datap
, len
);
4042 case WMI_GET_FIXRATES_CMDID
:
4043 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_FIXRATES_CMDID\n");
4044 ret
= ath6kl_wmi_ratemask_reply_rx(wmi
, datap
, len
);
4046 case WMI_TX_RETRY_ERR_EVENTID
:
4047 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_RETRY_ERR_EVENTID\n");
4049 case WMI_SNR_THRESHOLD_EVENTID
:
4050 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SNR_THRESHOLD_EVENTID\n");
4051 ret
= ath6kl_wmi_snr_threshold_event_rx(wmi
, datap
, len
);
4053 case WMI_LQ_THRESHOLD_EVENTID
:
4054 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_LQ_THRESHOLD_EVENTID\n");
4056 case WMI_APLIST_EVENTID
:
4057 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_APLIST_EVENTID\n");
4058 ret
= ath6kl_wmi_aplist_event_rx(wmi
, datap
, len
);
4060 case WMI_GET_KEEPALIVE_CMDID
:
4061 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_KEEPALIVE_CMDID\n");
4062 ret
= ath6kl_wmi_keepalive_reply_rx(wmi
, datap
, len
);
4064 case WMI_GET_WOW_LIST_EVENTID
:
4065 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_WOW_LIST_EVENTID\n");
4067 case WMI_GET_PMKID_LIST_EVENTID
:
4068 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_PMKID_LIST_EVENTID\n");
4069 ret
= ath6kl_wmi_get_pmkid_list_event_rx(wmi
, datap
, len
);
4071 case WMI_SET_PARAMS_REPLY_EVENTID
:
4072 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SET_PARAMS_REPLY_EVENTID\n");
4074 case WMI_ADDBA_RESP_EVENTID
:
4075 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_RESP_EVENTID\n");
4077 case WMI_REPORT_BTCOEX_CONFIG_EVENTID
:
4078 ath6kl_dbg(ATH6KL_DBG_WMI
,
4079 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
4081 case WMI_REPORT_BTCOEX_STATS_EVENTID
:
4082 ath6kl_dbg(ATH6KL_DBG_WMI
,
4083 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
4085 case WMI_TX_COMPLETE_EVENTID
:
4086 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_COMPLETE_EVENTID\n");
4087 ret
= ath6kl_wmi_tx_complete_event_rx(datap
, len
);
4089 case WMI_P2P_CAPABILITIES_EVENTID
:
4090 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_CAPABILITIES_EVENTID\n");
4091 ret
= ath6kl_wmi_p2p_capabilities_event_rx(datap
, len
);
4093 case WMI_P2P_INFO_EVENTID
:
4094 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_INFO_EVENTID\n");
4095 ret
= ath6kl_wmi_p2p_info_event_rx(datap
, len
);
4098 /* may be the event is interface specific */
4099 ret
= ath6kl_wmi_proc_events_vif(wmi
, if_idx
, id
, datap
, len
);
4108 int ath6kl_wmi_control_rx(struct wmi
*wmi
, struct sk_buff
*skb
)
4110 if (WARN_ON(skb
== NULL
))
4113 if (skb
->len
< sizeof(struct wmi_cmd_hdr
)) {
4114 ath6kl_err("bad packet 1\n");
4119 trace_ath6kl_wmi_event(skb
->data
, skb
->len
);
4121 return ath6kl_wmi_proc_events(wmi
, skb
);
4124 void ath6kl_wmi_reset(struct wmi
*wmi
)
4126 spin_lock_bh(&wmi
->lock
);
4128 wmi
->fat_pipe_exist
= 0;
4129 memset(wmi
->stream_exist_for_ac
, 0, sizeof(wmi
->stream_exist_for_ac
));
4131 spin_unlock_bh(&wmi
->lock
);
4134 void *ath6kl_wmi_init(struct ath6kl
*dev
)
4138 wmi
= kzalloc(sizeof(struct wmi
), GFP_KERNEL
);
4142 spin_lock_init(&wmi
->lock
);
4144 wmi
->parent_dev
= dev
;
4146 wmi
->pwr_mode
= REC_POWER
;
4148 ath6kl_wmi_reset(wmi
);
4153 void ath6kl_wmi_shutdown(struct wmi
*wmi
)
4158 kfree(wmi
->last_mgmt_tx_frame
);