2 * Copyright (c) 2004-2011 Atheros Communications Inc.
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include "../regd_common.h"
24 static int ath6kl_wmi_sync_point(struct wmi
*wmi
);
26 static const s32 wmi_rate_tbl
[][2] = {
27 /* {W/O SGI, with SGI} */
59 /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
60 static const u8 up_to_ac
[] = {
71 void ath6kl_wmi_set_control_ep(struct wmi
*wmi
, enum htc_endpoint_id ep_id
)
73 if (WARN_ON(ep_id
== ENDPOINT_UNUSED
|| ep_id
>= ENDPOINT_MAX
))
79 enum htc_endpoint_id
ath6kl_wmi_get_control_ep(struct wmi
*wmi
)
84 /* Performs DIX to 802.3 encapsulation for transmit packets.
85 * Assumes the entire DIX header is contigous and that there is
86 * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers.
88 int ath6kl_wmi_dix_2_dot3(struct wmi
*wmi
, struct sk_buff
*skb
)
90 struct ath6kl_llc_snap_hdr
*llc_hdr
;
91 struct ethhdr
*eth_hdr
;
97 if (WARN_ON(skb
== NULL
))
100 size
= sizeof(struct ath6kl_llc_snap_hdr
) + sizeof(struct wmi_data_hdr
);
101 if (skb_headroom(skb
) < size
)
104 eth_hdr
= (struct ethhdr
*) skb
->data
;
105 type
= eth_hdr
->h_proto
;
107 if (!is_ethertype(be16_to_cpu(type
))) {
108 ath6kl_dbg(ATH6KL_DBG_WMI
,
109 "%s: pkt is already in 802.3 format\n", __func__
);
113 new_len
= skb
->len
- sizeof(*eth_hdr
) + sizeof(*llc_hdr
);
115 skb_push(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
118 eth_hdr
->h_proto
= cpu_to_be16(new_len
);
120 memcpy(datap
, eth_hdr
, sizeof(*eth_hdr
));
122 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
+ sizeof(*eth_hdr
));
123 llc_hdr
->dsap
= 0xAA;
124 llc_hdr
->ssap
= 0xAA;
125 llc_hdr
->cntl
= 0x03;
126 llc_hdr
->org_code
[0] = 0x0;
127 llc_hdr
->org_code
[1] = 0x0;
128 llc_hdr
->org_code
[2] = 0x0;
129 llc_hdr
->eth_type
= type
;
134 static int ath6kl_wmi_meta_add(struct wmi
*wmi
, struct sk_buff
*skb
,
135 u8
*version
, void *tx_meta_info
)
137 struct wmi_tx_meta_v1
*v1
;
138 struct wmi_tx_meta_v2
*v2
;
140 if (WARN_ON(skb
== NULL
|| version
== NULL
))
144 case WMI_META_VERSION_1
:
145 skb_push(skb
, WMI_MAX_TX_META_SZ
);
146 v1
= (struct wmi_tx_meta_v1
*) skb
->data
;
148 v1
->rate_plcy_id
= 0;
149 *version
= WMI_META_VERSION_1
;
151 case WMI_META_VERSION_2
:
152 skb_push(skb
, WMI_MAX_TX_META_SZ
);
153 v2
= (struct wmi_tx_meta_v2
*) skb
->data
;
154 memcpy(v2
, (struct wmi_tx_meta_v2
*) tx_meta_info
,
155 sizeof(struct wmi_tx_meta_v2
));
162 int ath6kl_wmi_data_hdr_add(struct wmi
*wmi
, struct sk_buff
*skb
,
163 u8 msg_type
, bool more_data
,
164 enum wmi_data_hdr_data_type data_type
,
165 u8 meta_ver
, void *tx_meta_info
)
167 struct wmi_data_hdr
*data_hdr
;
170 if (WARN_ON(skb
== NULL
))
174 ret
= ath6kl_wmi_meta_add(wmi
, skb
, &meta_ver
, tx_meta_info
);
179 skb_push(skb
, sizeof(struct wmi_data_hdr
));
181 data_hdr
= (struct wmi_data_hdr
*)skb
->data
;
182 memset(data_hdr
, 0, sizeof(struct wmi_data_hdr
));
184 data_hdr
->info
= msg_type
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
185 data_hdr
->info
|= data_type
<< WMI_DATA_HDR_DATA_TYPE_SHIFT
;
189 WMI_DATA_HDR_MORE_MASK
<< WMI_DATA_HDR_MORE_SHIFT
;
191 data_hdr
->info2
= cpu_to_le16(meta_ver
<< WMI_DATA_HDR_META_SHIFT
);
197 static u8
ath6kl_wmi_determine_user_priority(u8
*pkt
, u32 layer2_pri
)
199 struct iphdr
*ip_hdr
= (struct iphdr
*) pkt
;
203 * Determine IPTOS priority
206 * : DSCP(6-bits) ECN(2-bits)
207 * : DSCP - P2 P1 P0 X X X
208 * where (P2 P1 P0) form 802.1D
210 ip_pri
= ip_hdr
->tos
>> 5;
213 if ((layer2_pri
& 0x7) > ip_pri
)
214 return (u8
) layer2_pri
& 0x7;
219 int ath6kl_wmi_implicit_create_pstream(struct wmi
*wmi
, struct sk_buff
*skb
,
220 u32 layer2_priority
, bool wmm_enabled
,
223 struct wmi_data_hdr
*data_hdr
;
224 struct ath6kl_llc_snap_hdr
*llc_hdr
;
225 struct wmi_create_pstream_cmd cmd
;
226 u32 meta_size
, hdr_size
;
227 u16 ip_type
= IP_ETHERTYPE
;
228 u8 stream_exist
, usr_pri
;
229 u8 traffic_class
= WMM_AC_BE
;
232 if (WARN_ON(skb
== NULL
))
236 data_hdr
= (struct wmi_data_hdr
*) datap
;
238 meta_size
= ((le16_to_cpu(data_hdr
->info2
) >> WMI_DATA_HDR_META_SHIFT
) &
239 WMI_DATA_HDR_META_MASK
) ? WMI_MAX_TX_META_SZ
: 0;
242 /* If WMM is disabled all traffic goes as BE traffic */
245 hdr_size
= sizeof(struct ethhdr
);
247 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
+
250 meta_size
+ hdr_size
);
252 if (llc_hdr
->eth_type
== htons(ip_type
)) {
254 * Extract the endpoint info from the TOS field
258 ath6kl_wmi_determine_user_priority(((u8
*) llc_hdr
) +
259 sizeof(struct ath6kl_llc_snap_hdr
),
262 usr_pri
= layer2_priority
& 0x7;
265 /* workaround for WMM S5 */
266 if ((wmi
->traffic_class
== WMM_AC_VI
) &&
267 ((usr_pri
== 5) || (usr_pri
== 4)))
270 /* Convert user priority to traffic class */
271 traffic_class
= up_to_ac
[usr_pri
& 0x7];
273 wmi_data_hdr_set_up(data_hdr
, usr_pri
);
275 spin_lock_bh(&wmi
->lock
);
276 stream_exist
= wmi
->fat_pipe_exist
;
277 spin_unlock_bh(&wmi
->lock
);
279 if (!(stream_exist
& (1 << traffic_class
))) {
280 memset(&cmd
, 0, sizeof(cmd
));
281 cmd
.traffic_class
= traffic_class
;
282 cmd
.user_pri
= usr_pri
;
284 cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT
);
285 /* Implicit streams are created with TSID 0xFF */
286 cmd
.tsid
= WMI_IMPLICIT_PSTREAM
;
287 ath6kl_wmi_create_pstream_cmd(wmi
, &cmd
);
295 int ath6kl_wmi_dot11_hdr_remove(struct wmi
*wmi
, struct sk_buff
*skb
)
297 struct ieee80211_hdr_3addr
*pwh
, wh
;
298 struct ath6kl_llc_snap_hdr
*llc_hdr
;
299 struct ethhdr eth_hdr
;
304 if (WARN_ON(skb
== NULL
))
308 pwh
= (struct ieee80211_hdr_3addr
*) datap
;
310 sub_type
= pwh
->frame_control
& cpu_to_le16(IEEE80211_FCTL_STYPE
);
312 memcpy((u8
*) &wh
, datap
, sizeof(struct ieee80211_hdr_3addr
));
314 /* Strip off the 802.11 header */
315 if (sub_type
== cpu_to_le16(IEEE80211_STYPE_QOS_DATA
)) {
316 hdr_size
= roundup(sizeof(struct ieee80211_qos_hdr
),
318 skb_pull(skb
, hdr_size
);
319 } else if (sub_type
== cpu_to_le16(IEEE80211_STYPE_DATA
))
320 skb_pull(skb
, sizeof(struct ieee80211_hdr_3addr
));
323 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
);
325 memset(ð_hdr
, 0, sizeof(eth_hdr
));
326 eth_hdr
.h_proto
= llc_hdr
->eth_type
;
328 switch ((le16_to_cpu(wh
.frame_control
)) &
329 (IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
)) {
331 memcpy(eth_hdr
.h_dest
, wh
.addr1
, ETH_ALEN
);
332 memcpy(eth_hdr
.h_source
, wh
.addr2
, ETH_ALEN
);
334 case IEEE80211_FCTL_TODS
:
335 memcpy(eth_hdr
.h_dest
, wh
.addr3
, ETH_ALEN
);
336 memcpy(eth_hdr
.h_source
, wh
.addr2
, ETH_ALEN
);
338 case IEEE80211_FCTL_FROMDS
:
339 memcpy(eth_hdr
.h_dest
, wh
.addr1
, ETH_ALEN
);
340 memcpy(eth_hdr
.h_source
, wh
.addr3
, ETH_ALEN
);
342 case IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
:
346 skb_pull(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
347 skb_push(skb
, sizeof(eth_hdr
));
351 memcpy(datap
, ð_hdr
, sizeof(eth_hdr
));
357 * Performs 802.3 to DIX encapsulation for received packets.
358 * Assumes the entire 802.3 header is contigous.
360 int ath6kl_wmi_dot3_2_dix(struct sk_buff
*skb
)
362 struct ath6kl_llc_snap_hdr
*llc_hdr
;
363 struct ethhdr eth_hdr
;
366 if (WARN_ON(skb
== NULL
))
371 memcpy(ð_hdr
, datap
, sizeof(eth_hdr
));
373 llc_hdr
= (struct ath6kl_llc_snap_hdr
*) (datap
+ sizeof(eth_hdr
));
374 eth_hdr
.h_proto
= llc_hdr
->eth_type
;
376 skb_pull(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
379 memcpy(datap
, ð_hdr
, sizeof(eth_hdr
));
384 static int ath6kl_wmi_tx_complete_event_rx(u8
*datap
, int len
)
386 struct tx_complete_msg_v1
*msg_v1
;
387 struct wmi_tx_complete_event
*evt
;
391 evt
= (struct wmi_tx_complete_event
*) datap
;
393 ath6kl_dbg(ATH6KL_DBG_WMI
, "comp: %d %d %d\n",
394 evt
->num_msg
, evt
->msg_len
, evt
->msg_type
);
396 if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI
))
399 for (index
= 0; index
< evt
->num_msg
; index
++) {
400 size
= sizeof(struct wmi_tx_complete_event
) +
401 (index
* sizeof(struct tx_complete_msg_v1
));
402 msg_v1
= (struct tx_complete_msg_v1
*)(datap
+ size
);
404 ath6kl_dbg(ATH6KL_DBG_WMI
, "msg: %d %d %d %d\n",
405 msg_v1
->status
, msg_v1
->pkt_id
,
406 msg_v1
->rate_idx
, msg_v1
->ack_failures
);
412 static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi
*wmi
, u8
*datap
,
415 struct wmi_remain_on_chnl_event
*ev
;
418 struct ieee80211_channel
*chan
;
419 struct ath6kl
*ar
= wmi
->parent_dev
;
421 if (len
< sizeof(*ev
))
424 ev
= (struct wmi_remain_on_chnl_event
*) datap
;
425 freq
= le32_to_cpu(ev
->freq
);
426 dur
= le32_to_cpu(ev
->duration
);
427 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl: freq=%u dur=%u\n",
429 chan
= ieee80211_get_channel(ar
->wdev
->wiphy
, freq
);
431 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl: Unknown channel "
432 "(freq=%u)\n", freq
);
435 cfg80211_ready_on_channel(ar
->net_dev
, 1, chan
, NL80211_CHAN_NO_HT
,
441 static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi
*wmi
,
444 struct wmi_cancel_remain_on_chnl_event
*ev
;
447 struct ieee80211_channel
*chan
;
448 struct ath6kl
*ar
= wmi
->parent_dev
;
450 if (len
< sizeof(*ev
))
453 ev
= (struct wmi_cancel_remain_on_chnl_event
*) datap
;
454 freq
= le32_to_cpu(ev
->freq
);
455 dur
= le32_to_cpu(ev
->duration
);
456 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl: freq=%u dur=%u "
457 "status=%u\n", freq
, dur
, ev
->status
);
458 chan
= ieee80211_get_channel(ar
->wdev
->wiphy
, freq
);
460 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl: Unknown "
461 "channel (freq=%u)\n", freq
);
464 cfg80211_remain_on_channel_expired(ar
->net_dev
, 1, chan
,
465 NL80211_CHAN_NO_HT
, GFP_ATOMIC
);
470 static int ath6kl_wmi_tx_status_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
472 struct wmi_tx_status_event
*ev
;
474 struct ath6kl
*ar
= wmi
->parent_dev
;
476 if (len
< sizeof(*ev
))
479 ev
= (struct wmi_tx_status_event
*) datap
;
480 id
= le32_to_cpu(ev
->id
);
481 ath6kl_dbg(ATH6KL_DBG_WMI
, "tx_status: id=%x ack_status=%u\n",
483 if (wmi
->last_mgmt_tx_frame
) {
484 cfg80211_mgmt_tx_status(ar
->net_dev
, id
,
485 wmi
->last_mgmt_tx_frame
,
486 wmi
->last_mgmt_tx_frame_len
,
487 !!ev
->ack_status
, GFP_ATOMIC
);
488 kfree(wmi
->last_mgmt_tx_frame
);
489 wmi
->last_mgmt_tx_frame
= NULL
;
490 wmi
->last_mgmt_tx_frame_len
= 0;
496 static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
498 struct wmi_p2p_rx_probe_req_event
*ev
;
501 struct ath6kl
*ar
= wmi
->parent_dev
;
503 if (len
< sizeof(*ev
))
506 ev
= (struct wmi_p2p_rx_probe_req_event
*) datap
;
507 freq
= le32_to_cpu(ev
->freq
);
508 dlen
= le16_to_cpu(ev
->len
);
509 if (datap
+ len
< ev
->data
+ dlen
) {
510 ath6kl_err("invalid wmi_p2p_rx_probe_req_event: "
511 "len=%d dlen=%u\n", len
, dlen
);
514 ath6kl_dbg(ATH6KL_DBG_WMI
, "rx_probe_req: len=%u freq=%u "
515 "probe_req_report=%d\n",
516 dlen
, freq
, ar
->probe_req_report
);
518 if (ar
->probe_req_report
|| ar
->nw_type
== AP_NETWORK
)
519 cfg80211_rx_mgmt(ar
->net_dev
, freq
, ev
->data
, dlen
, GFP_ATOMIC
);
524 static int ath6kl_wmi_p2p_capabilities_event_rx(u8
*datap
, int len
)
526 struct wmi_p2p_capabilities_event
*ev
;
529 if (len
< sizeof(*ev
))
532 ev
= (struct wmi_p2p_capabilities_event
*) datap
;
533 dlen
= le16_to_cpu(ev
->len
);
534 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_capab: len=%u\n", dlen
);
539 static int ath6kl_wmi_rx_action_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
541 struct wmi_rx_action_event
*ev
;
544 struct ath6kl
*ar
= wmi
->parent_dev
;
546 if (len
< sizeof(*ev
))
549 ev
= (struct wmi_rx_action_event
*) datap
;
550 freq
= le32_to_cpu(ev
->freq
);
551 dlen
= le16_to_cpu(ev
->len
);
552 if (datap
+ len
< ev
->data
+ dlen
) {
553 ath6kl_err("invalid wmi_rx_action_event: "
554 "len=%d dlen=%u\n", len
, dlen
);
557 ath6kl_dbg(ATH6KL_DBG_WMI
, "rx_action: len=%u freq=%u\n", dlen
, freq
);
558 cfg80211_rx_mgmt(ar
->net_dev
, freq
, ev
->data
, dlen
, GFP_ATOMIC
);
563 static int ath6kl_wmi_p2p_info_event_rx(u8
*datap
, int len
)
565 struct wmi_p2p_info_event
*ev
;
569 if (len
< sizeof(*ev
))
572 ev
= (struct wmi_p2p_info_event
*) datap
;
573 flags
= le32_to_cpu(ev
->info_req_flags
);
574 dlen
= le16_to_cpu(ev
->len
);
575 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: flags=%x len=%d\n", flags
, dlen
);
577 if (flags
& P2P_FLAG_CAPABILITIES_REQ
) {
578 struct wmi_p2p_capabilities
*cap
;
579 if (dlen
< sizeof(*cap
))
581 cap
= (struct wmi_p2p_capabilities
*) ev
->data
;
582 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: GO Power Save = %d\n",
586 if (flags
& P2P_FLAG_MACADDR_REQ
) {
587 struct wmi_p2p_macaddr
*mac
;
588 if (dlen
< sizeof(*mac
))
590 mac
= (struct wmi_p2p_macaddr
*) ev
->data
;
591 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: MAC Address = %pM\n",
595 if (flags
& P2P_FLAG_HMODEL_REQ
) {
596 struct wmi_p2p_hmodel
*mod
;
597 if (dlen
< sizeof(*mod
))
599 mod
= (struct wmi_p2p_hmodel
*) ev
->data
;
600 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: P2P Model = %d (%s)\n",
602 mod
->p2p_model
? "host" : "firmware");
607 static inline struct sk_buff
*ath6kl_wmi_get_new_buf(u32 size
)
611 skb
= ath6kl_buf_alloc(size
);
617 memset(skb
->data
, 0, size
);
622 /* Send a "simple" wmi command -- one with no arguments */
623 static int ath6kl_wmi_simple_cmd(struct wmi
*wmi
, enum wmi_cmd_id cmd_id
)
628 skb
= ath6kl_wmi_get_new_buf(0);
632 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, cmd_id
, NO_SYNC_WMIFLAG
);
637 static int ath6kl_wmi_ready_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
639 struct wmi_ready_event_2
*ev
= (struct wmi_ready_event_2
*) datap
;
641 if (len
< sizeof(struct wmi_ready_event_2
))
645 ath6kl_ready_event(wmi
->parent_dev
, ev
->mac_addr
,
646 le32_to_cpu(ev
->sw_version
),
647 le32_to_cpu(ev
->abi_version
));
653 * Mechanism to modify the roaming behavior in the firmware. The lower rssi
654 * at which the station has to roam can be passed with
655 * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level
658 int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi
*wmi
, u8 lrssi
)
661 struct roam_ctrl_cmd
*cmd
;
663 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
667 cmd
= (struct roam_ctrl_cmd
*) skb
->data
;
669 cmd
->info
.params
.lrssi_scan_period
= cpu_to_le16(DEF_LRSSI_SCAN_PERIOD
);
670 cmd
->info
.params
.lrssi_scan_threshold
= a_cpu_to_sle16(lrssi
+
671 DEF_SCAN_FOR_ROAM_INTVL
);
672 cmd
->info
.params
.lrssi_roam_threshold
= a_cpu_to_sle16(lrssi
);
673 cmd
->info
.params
.roam_rssi_floor
= DEF_LRSSI_ROAM_FLOOR
;
674 cmd
->roam_ctrl
= WMI_SET_LRSSI_SCAN_PARAMS
;
676 ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_ROAM_CTRL_CMDID
, NO_SYNC_WMIFLAG
);
681 static int ath6kl_wmi_connect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
683 struct wmi_connect_event
*ev
;
685 struct ath6kl
*ar
= wmi
->parent_dev
;
687 if (len
< sizeof(struct wmi_connect_event
))
690 ev
= (struct wmi_connect_event
*) datap
;
692 if (ar
->nw_type
== AP_NETWORK
) {
693 /* AP mode start/STA connected event */
694 struct net_device
*dev
= ar
->net_dev
;
695 if (memcmp(dev
->dev_addr
, ev
->u
.ap_bss
.bssid
, ETH_ALEN
) == 0) {
696 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: freq %d bssid %pM "
698 __func__
, le16_to_cpu(ev
->u
.ap_bss
.ch
),
700 ath6kl_connect_ap_mode_bss(
701 ar
, le16_to_cpu(ev
->u
.ap_bss
.ch
));
703 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: aid %u mac_addr %pM "
704 "auth=%u keymgmt=%u cipher=%u apsd_info=%u "
706 __func__
, ev
->u
.ap_sta
.aid
,
707 ev
->u
.ap_sta
.mac_addr
,
709 ev
->u
.ap_sta
.keymgmt
,
710 le16_to_cpu(ev
->u
.ap_sta
.cipher
),
711 ev
->u
.ap_sta
.apsd_info
);
712 ath6kl_connect_ap_mode_sta(
713 ar
, ev
->u
.ap_sta
.aid
, ev
->u
.ap_sta
.mac_addr
,
714 ev
->u
.ap_sta
.keymgmt
,
715 le16_to_cpu(ev
->u
.ap_sta
.cipher
),
716 ev
->u
.ap_sta
.auth
, ev
->assoc_req_len
,
717 ev
->assoc_info
+ ev
->beacon_ie_len
);
722 /* STA/IBSS mode connection event */
724 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: freq %d bssid %pM\n",
725 __func__
, le16_to_cpu(ev
->u
.sta
.ch
), ev
->u
.sta
.bssid
);
727 /* Start of assoc rsp IEs */
728 pie
= ev
->assoc_info
+ ev
->beacon_ie_len
+
729 ev
->assoc_req_len
+ (sizeof(u16
) * 3); /* capinfo, status, aid */
731 /* End of assoc rsp IEs */
732 peie
= ev
->assoc_info
+ ev
->beacon_ie_len
+ ev
->assoc_req_len
+
737 case WLAN_EID_VENDOR_SPECIFIC
:
738 if (pie
[1] > 3 && pie
[2] == 0x00 && pie
[3] == 0x50 &&
739 pie
[4] == 0xf2 && pie
[5] == WMM_OUI_TYPE
) {
740 /* WMM OUT (00:50:F2) */
742 && pie
[6] == WMM_PARAM_OUI_SUBTYPE
)
743 wmi
->is_wmm_enabled
= true;
748 if (wmi
->is_wmm_enabled
)
754 ath6kl_connect_event(wmi
->parent_dev
, le16_to_cpu(ev
->u
.sta
.ch
),
756 le16_to_cpu(ev
->u
.sta
.listen_intvl
),
757 le16_to_cpu(ev
->u
.sta
.beacon_intvl
),
758 le32_to_cpu(ev
->u
.sta
.nw_type
),
759 ev
->beacon_ie_len
, ev
->assoc_req_len
,
760 ev
->assoc_resp_len
, ev
->assoc_info
);
765 static struct country_code_to_enum_rd
*
766 ath6kl_regd_find_country(u16 countryCode
)
770 for (i
= 0; i
< ARRAY_SIZE(allCountries
); i
++) {
771 if (allCountries
[i
].countryCode
== countryCode
)
772 return &allCountries
[i
];
778 static struct reg_dmn_pair_mapping
*
779 ath6kl_get_regpair(u16 regdmn
)
783 if (regdmn
== NO_ENUMRD
)
786 for (i
= 0; i
< ARRAY_SIZE(regDomainPairs
); i
++) {
787 if (regDomainPairs
[i
].regDmnEnum
== regdmn
)
788 return ®DomainPairs
[i
];
794 static struct country_code_to_enum_rd
*
795 ath6kl_regd_find_country_by_rd(u16 regdmn
)
799 for (i
= 0; i
< ARRAY_SIZE(allCountries
); i
++) {
800 if (allCountries
[i
].regDmnEnum
== regdmn
)
801 return &allCountries
[i
];
807 static void ath6kl_wmi_regdomain_event(struct wmi
*wmi
, u8
*datap
, int len
)
810 struct ath6kl_wmi_regdomain
*ev
;
811 struct country_code_to_enum_rd
*country
= NULL
;
812 struct reg_dmn_pair_mapping
*regpair
= NULL
;
816 ev
= (struct ath6kl_wmi_regdomain
*) datap
;
817 reg_code
= le32_to_cpu(ev
->reg_code
);
819 if ((reg_code
>> ATH6KL_COUNTRY_RD_SHIFT
) & COUNTRY_ERD_FLAG
)
820 country
= ath6kl_regd_find_country((u16
) reg_code
);
821 else if (!(((u16
) reg_code
& WORLD_SKU_MASK
) == WORLD_SKU_PREFIX
)) {
823 regpair
= ath6kl_get_regpair((u16
) reg_code
);
824 country
= ath6kl_regd_find_country_by_rd((u16
) reg_code
);
825 ath6kl_dbg(ATH6KL_DBG_WMI
, "ath6kl: Regpair used: 0x%0x\n",
826 regpair
->regDmnEnum
);
830 alpha2
[0] = country
->isoName
[0];
831 alpha2
[1] = country
->isoName
[1];
833 regulatory_hint(wmi
->parent_dev
->wdev
->wiphy
, alpha2
);
835 ath6kl_dbg(ATH6KL_DBG_WMI
, "ath6kl: Country alpha2 being used: %c%c\n",
836 alpha2
[0], alpha2
[1]);
840 static int ath6kl_wmi_disconnect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
842 struct wmi_disconnect_event
*ev
;
843 wmi
->traffic_class
= 100;
845 if (len
< sizeof(struct wmi_disconnect_event
))
848 ev
= (struct wmi_disconnect_event
*) datap
;
850 wmi
->is_wmm_enabled
= false;
851 wmi
->pair_crypto_type
= NONE_CRYPT
;
852 wmi
->grp_crypto_type
= NONE_CRYPT
;
854 ath6kl_disconnect_event(wmi
->parent_dev
, ev
->disconn_reason
,
855 ev
->bssid
, ev
->assoc_resp_len
, ev
->assoc_info
,
856 le16_to_cpu(ev
->proto_reason_status
));
861 static int ath6kl_wmi_peer_node_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
863 struct wmi_peer_node_event
*ev
;
865 if (len
< sizeof(struct wmi_peer_node_event
))
868 ev
= (struct wmi_peer_node_event
*) datap
;
870 if (ev
->event_code
== PEER_NODE_JOIN_EVENT
)
871 ath6kl_dbg(ATH6KL_DBG_WMI
, "joined node with mac addr: %pM\n",
873 else if (ev
->event_code
== PEER_NODE_LEAVE_EVENT
)
874 ath6kl_dbg(ATH6KL_DBG_WMI
, "left node with mac addr: %pM\n",
880 static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
882 struct wmi_tkip_micerr_event
*ev
;
884 if (len
< sizeof(struct wmi_tkip_micerr_event
))
887 ev
= (struct wmi_tkip_micerr_event
*) datap
;
889 ath6kl_tkip_micerr_event(wmi
->parent_dev
, ev
->key_id
, ev
->is_mcast
);
894 static int ath6kl_wmi_bssinfo_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
896 struct wmi_bss_info_hdr2
*bih
;
898 struct ieee80211_channel
*channel
;
899 struct ath6kl
*ar
= wmi
->parent_dev
;
900 struct ieee80211_mgmt
*mgmt
;
901 struct cfg80211_bss
*bss
;
903 if (len
<= sizeof(struct wmi_bss_info_hdr2
))
906 bih
= (struct wmi_bss_info_hdr2
*) datap
;
907 buf
= datap
+ sizeof(struct wmi_bss_info_hdr2
);
908 len
-= sizeof(struct wmi_bss_info_hdr2
);
910 ath6kl_dbg(ATH6KL_DBG_WMI
,
911 "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
913 bih
->ch
, bih
->snr
, bih
->snr
- 95, bih
->bssid
,
916 if (bih
->frame_type
!= BEACON_FTYPE
&&
917 bih
->frame_type
!= PROBERESP_FTYPE
)
918 return 0; /* Only update BSS table for now */
920 if (bih
->frame_type
== BEACON_FTYPE
&&
921 test_bit(CLEAR_BSSFILTER_ON_BEACON
, &ar
->flag
)) {
922 clear_bit(CLEAR_BSSFILTER_ON_BEACON
, &ar
->flag
);
923 ath6kl_wmi_bssfilter_cmd(ar
->wmi
, NONE_BSS_FILTER
, 0);
926 channel
= ieee80211_get_channel(ar
->wdev
->wiphy
, le16_to_cpu(bih
->ch
));
933 if (bih
->frame_type
== BEACON_FTYPE
&& test_bit(CONNECTED
, &ar
->flag
) &&
934 memcmp(bih
->bssid
, ar
->bssid
, ETH_ALEN
) == 0) {
936 tim
= cfg80211_find_ie(WLAN_EID_TIM
, buf
+ 8 + 2 + 2,
938 if (tim
&& tim
[1] >= 2) {
939 ar
->assoc_bss_dtim_period
= tim
[3];
940 set_bit(DTIM_PERIOD_AVAIL
, &ar
->flag
);
945 * In theory, use of cfg80211_inform_bss() would be more natural here
946 * since we do not have the full frame. However, at least for now,
947 * cfg80211 can only distinguish Beacon and Probe Response frames from
948 * each other when using cfg80211_inform_bss_frame(), so let's build a
949 * fake IEEE 802.11 header to be able to take benefit of this.
951 mgmt
= kmalloc(24 + len
, GFP_ATOMIC
);
955 if (bih
->frame_type
== BEACON_FTYPE
) {
956 mgmt
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
957 IEEE80211_STYPE_BEACON
);
958 memset(mgmt
->da
, 0xff, ETH_ALEN
);
960 struct net_device
*dev
= ar
->net_dev
;
962 mgmt
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
963 IEEE80211_STYPE_PROBE_RESP
);
964 memcpy(mgmt
->da
, dev
->dev_addr
, ETH_ALEN
);
966 mgmt
->duration
= cpu_to_le16(0);
967 memcpy(mgmt
->sa
, bih
->bssid
, ETH_ALEN
);
968 memcpy(mgmt
->bssid
, bih
->bssid
, ETH_ALEN
);
969 mgmt
->seq_ctrl
= cpu_to_le16(0);
971 memcpy(&mgmt
->u
.beacon
, buf
, len
);
973 bss
= cfg80211_inform_bss_frame(ar
->wdev
->wiphy
, channel
, mgmt
,
974 24 + len
, (bih
->snr
- 95) * 100,
979 cfg80211_put_bss(bss
);
984 /* Inactivity timeout of a fatpipe(pstream) at the target */
985 static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi
*wmi
, u8
*datap
,
988 struct wmi_pstream_timeout_event
*ev
;
990 if (len
< sizeof(struct wmi_pstream_timeout_event
))
993 ev
= (struct wmi_pstream_timeout_event
*) datap
;
996 * When the pstream (fat pipe == AC) timesout, it means there were
997 * no thinStreams within this pstream & it got implicitly created
998 * due to data flow on this AC. We start the inactivity timer only
999 * for implicitly created pstream. Just reset the host state.
1001 spin_lock_bh(&wmi
->lock
);
1002 wmi
->stream_exist_for_ac
[ev
->traffic_class
] = 0;
1003 wmi
->fat_pipe_exist
&= ~(1 << ev
->traffic_class
);
1004 spin_unlock_bh(&wmi
->lock
);
1006 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1007 ath6kl_indicate_tx_activity(wmi
->parent_dev
, ev
->traffic_class
, false);
1012 static int ath6kl_wmi_bitrate_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1014 struct wmi_bit_rate_reply
*reply
;
1018 if (len
< sizeof(struct wmi_bit_rate_reply
))
1021 reply
= (struct wmi_bit_rate_reply
*) datap
;
1023 ath6kl_dbg(ATH6KL_DBG_WMI
, "rateindex %d\n", reply
->rate_index
);
1025 if (reply
->rate_index
== (s8
) RATE_AUTO
) {
1028 index
= reply
->rate_index
& 0x7f;
1029 sgi
= (reply
->rate_index
& 0x80) ? 1 : 0;
1030 rate
= wmi_rate_tbl
[index
][sgi
];
1033 ath6kl_wakeup_event(wmi
->parent_dev
);
1038 static int ath6kl_wmi_tcmd_test_report_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1040 ath6kl_tm_rx_report_event(wmi
->parent_dev
, datap
, len
);
1045 static int ath6kl_wmi_ratemask_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1047 if (len
< sizeof(struct wmi_fix_rates_reply
))
1050 ath6kl_wakeup_event(wmi
->parent_dev
);
1055 static int ath6kl_wmi_ch_list_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1057 if (len
< sizeof(struct wmi_channel_list_reply
))
1060 ath6kl_wakeup_event(wmi
->parent_dev
);
1065 static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1067 struct wmi_tx_pwr_reply
*reply
;
1069 if (len
< sizeof(struct wmi_tx_pwr_reply
))
1072 reply
= (struct wmi_tx_pwr_reply
*) datap
;
1073 ath6kl_txpwr_rx_evt(wmi
->parent_dev
, reply
->dbM
);
1078 static int ath6kl_wmi_keepalive_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1080 if (len
< sizeof(struct wmi_get_keepalive_cmd
))
1083 ath6kl_wakeup_event(wmi
->parent_dev
);
1088 static int ath6kl_wmi_scan_complete_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1090 struct wmi_scan_complete_event
*ev
;
1092 ev
= (struct wmi_scan_complete_event
*) datap
;
1094 ath6kl_scan_complete_evt(wmi
->parent_dev
, a_sle32_to_cpu(ev
->status
));
1095 wmi
->is_probe_ssid
= false;
1100 static int ath6kl_wmi_neighbor_report_event_rx(struct wmi
*wmi
, u8
*datap
,
1103 struct wmi_neighbor_report_event
*ev
;
1106 if (len
< sizeof(*ev
))
1108 ev
= (struct wmi_neighbor_report_event
*) datap
;
1109 if (sizeof(*ev
) + ev
->num_neighbors
* sizeof(struct wmi_neighbor_info
)
1111 ath6kl_dbg(ATH6KL_DBG_WMI
, "truncated neighbor event "
1112 "(num=%d len=%d)\n", ev
->num_neighbors
, len
);
1115 for (i
= 0; i
< ev
->num_neighbors
; i
++) {
1116 ath6kl_dbg(ATH6KL_DBG_WMI
, "neighbor %d/%d - %pM 0x%x\n",
1117 i
+ 1, ev
->num_neighbors
, ev
->neighbor
[i
].bssid
,
1118 ev
->neighbor
[i
].bss_flags
);
1119 cfg80211_pmksa_candidate_notify(wmi
->parent_dev
->net_dev
, i
,
1120 ev
->neighbor
[i
].bssid
,
1121 !!(ev
->neighbor
[i
].bss_flags
&
1122 WMI_PREAUTH_CAPABLE_BSS
),
1130 * Target is reporting a programming error. This is for
1131 * developer aid only. Target only checks a few common violations
1132 * and it is responsibility of host to do all error checking.
1133 * Behavior of target after wmi error event is undefined.
1134 * A reset is recommended.
1136 static int ath6kl_wmi_error_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1138 const char *type
= "unknown error";
1139 struct wmi_cmd_error_event
*ev
;
1140 ev
= (struct wmi_cmd_error_event
*) datap
;
1142 switch (ev
->err_code
) {
1144 type
= "invalid parameter";
1147 type
= "invalid state";
1149 case INTERNAL_ERROR
:
1150 type
= "internal error";
1154 ath6kl_dbg(ATH6KL_DBG_WMI
, "programming error, cmd=%d %s\n",
1160 static int ath6kl_wmi_stats_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1162 ath6kl_tgt_stats_event(wmi
->parent_dev
, datap
, len
);
1167 static u8
ath6kl_wmi_get_upper_threshold(s16 rssi
,
1168 struct sq_threshold_params
*sq_thresh
,
1172 u8 threshold
= (u8
) sq_thresh
->upper_threshold
[size
- 1];
1174 /* The list is already in sorted order. Get the next lower value */
1175 for (index
= 0; index
< size
; index
++) {
1176 if (rssi
< sq_thresh
->upper_threshold
[index
]) {
1177 threshold
= (u8
) sq_thresh
->upper_threshold
[index
];
1185 static u8
ath6kl_wmi_get_lower_threshold(s16 rssi
,
1186 struct sq_threshold_params
*sq_thresh
,
1190 u8 threshold
= (u8
) sq_thresh
->lower_threshold
[size
- 1];
1192 /* The list is already in sorted order. Get the next lower value */
1193 for (index
= 0; index
< size
; index
++) {
1194 if (rssi
> sq_thresh
->lower_threshold
[index
]) {
1195 threshold
= (u8
) sq_thresh
->lower_threshold
[index
];
1203 static int ath6kl_wmi_send_rssi_threshold_params(struct wmi
*wmi
,
1204 struct wmi_rssi_threshold_params_cmd
*rssi_cmd
)
1206 struct sk_buff
*skb
;
1207 struct wmi_rssi_threshold_params_cmd
*cmd
;
1209 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1213 cmd
= (struct wmi_rssi_threshold_params_cmd
*) skb
->data
;
1214 memcpy(cmd
, rssi_cmd
, sizeof(struct wmi_rssi_threshold_params_cmd
));
1216 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RSSI_THRESHOLD_PARAMS_CMDID
,
1220 static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1223 struct wmi_rssi_threshold_event
*reply
;
1224 struct wmi_rssi_threshold_params_cmd cmd
;
1225 struct sq_threshold_params
*sq_thresh
;
1226 enum wmi_rssi_threshold_val new_threshold
;
1227 u8 upper_rssi_threshold
, lower_rssi_threshold
;
1231 if (len
< sizeof(struct wmi_rssi_threshold_event
))
1234 reply
= (struct wmi_rssi_threshold_event
*) datap
;
1235 new_threshold
= (enum wmi_rssi_threshold_val
) reply
->range
;
1236 rssi
= a_sle16_to_cpu(reply
->rssi
);
1238 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_RSSI
];
1241 * Identify the threshold breached and communicate that to the app.
1242 * After that install a new set of thresholds based on the signal
1243 * quality reported by the target
1245 if (new_threshold
) {
1246 /* Upper threshold breached */
1247 if (rssi
< sq_thresh
->upper_threshold
[0]) {
1248 ath6kl_dbg(ATH6KL_DBG_WMI
,
1249 "spurious upper rssi threshold event: %d\n",
1251 } else if ((rssi
< sq_thresh
->upper_threshold
[1]) &&
1252 (rssi
>= sq_thresh
->upper_threshold
[0])) {
1253 new_threshold
= WMI_RSSI_THRESHOLD1_ABOVE
;
1254 } else if ((rssi
< sq_thresh
->upper_threshold
[2]) &&
1255 (rssi
>= sq_thresh
->upper_threshold
[1])) {
1256 new_threshold
= WMI_RSSI_THRESHOLD2_ABOVE
;
1257 } else if ((rssi
< sq_thresh
->upper_threshold
[3]) &&
1258 (rssi
>= sq_thresh
->upper_threshold
[2])) {
1259 new_threshold
= WMI_RSSI_THRESHOLD3_ABOVE
;
1260 } else if ((rssi
< sq_thresh
->upper_threshold
[4]) &&
1261 (rssi
>= sq_thresh
->upper_threshold
[3])) {
1262 new_threshold
= WMI_RSSI_THRESHOLD4_ABOVE
;
1263 } else if ((rssi
< sq_thresh
->upper_threshold
[5]) &&
1264 (rssi
>= sq_thresh
->upper_threshold
[4])) {
1265 new_threshold
= WMI_RSSI_THRESHOLD5_ABOVE
;
1266 } else if (rssi
>= sq_thresh
->upper_threshold
[5]) {
1267 new_threshold
= WMI_RSSI_THRESHOLD6_ABOVE
;
1270 /* Lower threshold breached */
1271 if (rssi
> sq_thresh
->lower_threshold
[0]) {
1272 ath6kl_dbg(ATH6KL_DBG_WMI
,
1273 "spurious lower rssi threshold event: %d %d\n",
1274 rssi
, sq_thresh
->lower_threshold
[0]);
1275 } else if ((rssi
> sq_thresh
->lower_threshold
[1]) &&
1276 (rssi
<= sq_thresh
->lower_threshold
[0])) {
1277 new_threshold
= WMI_RSSI_THRESHOLD6_BELOW
;
1278 } else if ((rssi
> sq_thresh
->lower_threshold
[2]) &&
1279 (rssi
<= sq_thresh
->lower_threshold
[1])) {
1280 new_threshold
= WMI_RSSI_THRESHOLD5_BELOW
;
1281 } else if ((rssi
> sq_thresh
->lower_threshold
[3]) &&
1282 (rssi
<= sq_thresh
->lower_threshold
[2])) {
1283 new_threshold
= WMI_RSSI_THRESHOLD4_BELOW
;
1284 } else if ((rssi
> sq_thresh
->lower_threshold
[4]) &&
1285 (rssi
<= sq_thresh
->lower_threshold
[3])) {
1286 new_threshold
= WMI_RSSI_THRESHOLD3_BELOW
;
1287 } else if ((rssi
> sq_thresh
->lower_threshold
[5]) &&
1288 (rssi
<= sq_thresh
->lower_threshold
[4])) {
1289 new_threshold
= WMI_RSSI_THRESHOLD2_BELOW
;
1290 } else if (rssi
<= sq_thresh
->lower_threshold
[5]) {
1291 new_threshold
= WMI_RSSI_THRESHOLD1_BELOW
;
1295 /* Calculate and install the next set of thresholds */
1296 lower_rssi_threshold
= ath6kl_wmi_get_lower_threshold(rssi
, sq_thresh
,
1297 sq_thresh
->lower_threshold_valid_count
);
1298 upper_rssi_threshold
= ath6kl_wmi_get_upper_threshold(rssi
, sq_thresh
,
1299 sq_thresh
->upper_threshold_valid_count
);
1301 /* Issue a wmi command to install the thresholds */
1302 cmd
.thresh_above1_val
= a_cpu_to_sle16(upper_rssi_threshold
);
1303 cmd
.thresh_below1_val
= a_cpu_to_sle16(lower_rssi_threshold
);
1304 cmd
.weight
= sq_thresh
->weight
;
1305 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1307 ret
= ath6kl_wmi_send_rssi_threshold_params(wmi
, &cmd
);
1309 ath6kl_err("unable to configure rssi thresholds\n");
1316 static int ath6kl_wmi_cac_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1318 struct wmi_cac_event
*reply
;
1319 struct ieee80211_tspec_ie
*ts
;
1320 u16 active_tsids
, tsinfo
;
1324 if (len
< sizeof(struct wmi_cac_event
))
1327 reply
= (struct wmi_cac_event
*) datap
;
1329 if ((reply
->cac_indication
== CAC_INDICATION_ADMISSION_RESP
) &&
1330 (reply
->status_code
!= IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED
)) {
1332 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1333 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1334 tsid
= (tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1335 IEEE80211_WMM_IE_TSPEC_TID_MASK
;
1337 ath6kl_wmi_delete_pstream_cmd(wmi
, reply
->ac
, tsid
);
1338 } else if (reply
->cac_indication
== CAC_INDICATION_NO_RESP
) {
1340 * Following assumes that there is only one outstanding
1341 * ADDTS request when this event is received
1343 spin_lock_bh(&wmi
->lock
);
1344 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1345 spin_unlock_bh(&wmi
->lock
);
1347 for (index
= 0; index
< sizeof(active_tsids
) * 8; index
++) {
1348 if ((active_tsids
>> index
) & 1)
1351 if (index
< (sizeof(active_tsids
) * 8))
1352 ath6kl_wmi_delete_pstream_cmd(wmi
, reply
->ac
, index
);
1356 * Clear active tsids and Add missing handling
1357 * for delete qos stream from AP
1359 else if (reply
->cac_indication
== CAC_INDICATION_DELETE
) {
1361 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1362 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1363 ts_id
= ((tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1364 IEEE80211_WMM_IE_TSPEC_TID_MASK
);
1366 spin_lock_bh(&wmi
->lock
);
1367 wmi
->stream_exist_for_ac
[reply
->ac
] &= ~(1 << ts_id
);
1368 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1369 spin_unlock_bh(&wmi
->lock
);
1371 /* Indicate stream inactivity to driver layer only if all tsids
1372 * within this AC are deleted.
1374 if (!active_tsids
) {
1375 ath6kl_indicate_tx_activity(wmi
->parent_dev
, reply
->ac
,
1377 wmi
->fat_pipe_exist
&= ~(1 << reply
->ac
);
1384 static int ath6kl_wmi_send_snr_threshold_params(struct wmi
*wmi
,
1385 struct wmi_snr_threshold_params_cmd
*snr_cmd
)
1387 struct sk_buff
*skb
;
1388 struct wmi_snr_threshold_params_cmd
*cmd
;
1390 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1394 cmd
= (struct wmi_snr_threshold_params_cmd
*) skb
->data
;
1395 memcpy(cmd
, snr_cmd
, sizeof(struct wmi_snr_threshold_params_cmd
));
1397 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SNR_THRESHOLD_PARAMS_CMDID
,
1401 static int ath6kl_wmi_snr_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1404 struct wmi_snr_threshold_event
*reply
;
1405 struct sq_threshold_params
*sq_thresh
;
1406 struct wmi_snr_threshold_params_cmd cmd
;
1407 enum wmi_snr_threshold_val new_threshold
;
1408 u8 upper_snr_threshold
, lower_snr_threshold
;
1412 if (len
< sizeof(struct wmi_snr_threshold_event
))
1415 reply
= (struct wmi_snr_threshold_event
*) datap
;
1417 new_threshold
= (enum wmi_snr_threshold_val
) reply
->range
;
1420 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_SNR
];
1423 * Identify the threshold breached and communicate that to the app.
1424 * After that install a new set of thresholds based on the signal
1425 * quality reported by the target.
1427 if (new_threshold
) {
1428 /* Upper threshold breached */
1429 if (snr
< sq_thresh
->upper_threshold
[0]) {
1430 ath6kl_dbg(ATH6KL_DBG_WMI
,
1431 "spurious upper snr threshold event: %d\n",
1433 } else if ((snr
< sq_thresh
->upper_threshold
[1]) &&
1434 (snr
>= sq_thresh
->upper_threshold
[0])) {
1435 new_threshold
= WMI_SNR_THRESHOLD1_ABOVE
;
1436 } else if ((snr
< sq_thresh
->upper_threshold
[2]) &&
1437 (snr
>= sq_thresh
->upper_threshold
[1])) {
1438 new_threshold
= WMI_SNR_THRESHOLD2_ABOVE
;
1439 } else if ((snr
< sq_thresh
->upper_threshold
[3]) &&
1440 (snr
>= sq_thresh
->upper_threshold
[2])) {
1441 new_threshold
= WMI_SNR_THRESHOLD3_ABOVE
;
1442 } else if (snr
>= sq_thresh
->upper_threshold
[3]) {
1443 new_threshold
= WMI_SNR_THRESHOLD4_ABOVE
;
1446 /* Lower threshold breached */
1447 if (snr
> sq_thresh
->lower_threshold
[0]) {
1448 ath6kl_dbg(ATH6KL_DBG_WMI
,
1449 "spurious lower snr threshold event: %d\n",
1450 sq_thresh
->lower_threshold
[0]);
1451 } else if ((snr
> sq_thresh
->lower_threshold
[1]) &&
1452 (snr
<= sq_thresh
->lower_threshold
[0])) {
1453 new_threshold
= WMI_SNR_THRESHOLD4_BELOW
;
1454 } else if ((snr
> sq_thresh
->lower_threshold
[2]) &&
1455 (snr
<= sq_thresh
->lower_threshold
[1])) {
1456 new_threshold
= WMI_SNR_THRESHOLD3_BELOW
;
1457 } else if ((snr
> sq_thresh
->lower_threshold
[3]) &&
1458 (snr
<= sq_thresh
->lower_threshold
[2])) {
1459 new_threshold
= WMI_SNR_THRESHOLD2_BELOW
;
1460 } else if (snr
<= sq_thresh
->lower_threshold
[3]) {
1461 new_threshold
= WMI_SNR_THRESHOLD1_BELOW
;
1465 /* Calculate and install the next set of thresholds */
1466 lower_snr_threshold
= ath6kl_wmi_get_lower_threshold(snr
, sq_thresh
,
1467 sq_thresh
->lower_threshold_valid_count
);
1468 upper_snr_threshold
= ath6kl_wmi_get_upper_threshold(snr
, sq_thresh
,
1469 sq_thresh
->upper_threshold_valid_count
);
1471 /* Issue a wmi command to install the thresholds */
1472 cmd
.thresh_above1_val
= upper_snr_threshold
;
1473 cmd
.thresh_below1_val
= lower_snr_threshold
;
1474 cmd
.weight
= sq_thresh
->weight
;
1475 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1477 ath6kl_dbg(ATH6KL_DBG_WMI
,
1478 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1480 lower_snr_threshold
, upper_snr_threshold
);
1482 ret
= ath6kl_wmi_send_snr_threshold_params(wmi
, &cmd
);
1484 ath6kl_err("unable to configure snr threshold\n");
1491 static int ath6kl_wmi_aplist_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1493 u16 ap_info_entry_size
;
1494 struct wmi_aplist_event
*ev
= (struct wmi_aplist_event
*) datap
;
1495 struct wmi_ap_info_v1
*ap_info_v1
;
1498 if (len
< sizeof(struct wmi_aplist_event
) ||
1499 ev
->ap_list_ver
!= APLIST_VER1
)
1502 ap_info_entry_size
= sizeof(struct wmi_ap_info_v1
);
1503 ap_info_v1
= (struct wmi_ap_info_v1
*) ev
->ap_list
;
1505 ath6kl_dbg(ATH6KL_DBG_WMI
,
1506 "number of APs in aplist event: %d\n", ev
->num_ap
);
1508 if (len
< (int) (sizeof(struct wmi_aplist_event
) +
1509 (ev
->num_ap
- 1) * ap_info_entry_size
))
1512 /* AP list version 1 contents */
1513 for (index
= 0; index
< ev
->num_ap
; index
++) {
1514 ath6kl_dbg(ATH6KL_DBG_WMI
, "AP#%d BSSID %pM Channel %d\n",
1515 index
, ap_info_v1
->bssid
, ap_info_v1
->channel
);
1522 int ath6kl_wmi_cmd_send(struct wmi
*wmi
, struct sk_buff
*skb
,
1523 enum wmi_cmd_id cmd_id
, enum wmi_sync_flag sync_flag
)
1525 struct wmi_cmd_hdr
*cmd_hdr
;
1526 enum htc_endpoint_id ep_id
= wmi
->ep_id
;
1529 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: cmd_id=%d\n", __func__
, cmd_id
);
1531 if (WARN_ON(skb
== NULL
))
1534 if (sync_flag
>= END_WMIFLAG
) {
1539 if ((sync_flag
== SYNC_BEFORE_WMIFLAG
) ||
1540 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1542 * Make sure all data currently queued is transmitted before
1543 * the cmd execution. Establish a new sync point.
1545 ath6kl_wmi_sync_point(wmi
);
1548 skb_push(skb
, sizeof(struct wmi_cmd_hdr
));
1550 cmd_hdr
= (struct wmi_cmd_hdr
*) skb
->data
;
1551 cmd_hdr
->cmd_id
= cpu_to_le16(cmd_id
);
1552 cmd_hdr
->info1
= 0; /* added for virtual interface */
1554 /* Only for OPT_TX_CMD, use BE endpoint. */
1555 if (cmd_id
== WMI_OPT_TX_FRAME_CMDID
) {
1556 ret
= ath6kl_wmi_data_hdr_add(wmi
, skb
, OPT_MSGTYPE
,
1557 false, false, 0, NULL
);
1562 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
, WMM_AC_BE
);
1565 ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
1567 if ((sync_flag
== SYNC_AFTER_WMIFLAG
) ||
1568 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1570 * Make sure all new data queued waits for the command to
1571 * execute. Establish a new sync point.
1573 ath6kl_wmi_sync_point(wmi
);
1579 int ath6kl_wmi_connect_cmd(struct wmi
*wmi
, enum network_type nw_type
,
1580 enum dot11_auth_mode dot11_auth_mode
,
1581 enum auth_mode auth_mode
,
1582 enum crypto_type pairwise_crypto
,
1583 u8 pairwise_crypto_len
,
1584 enum crypto_type group_crypto
,
1585 u8 group_crypto_len
, int ssid_len
, u8
*ssid
,
1586 u8
*bssid
, u16 channel
, u32 ctrl_flags
)
1588 struct sk_buff
*skb
;
1589 struct wmi_connect_cmd
*cc
;
1592 wmi
->traffic_class
= 100;
1594 if ((pairwise_crypto
== NONE_CRYPT
) && (group_crypto
!= NONE_CRYPT
))
1597 if ((pairwise_crypto
!= NONE_CRYPT
) && (group_crypto
== NONE_CRYPT
))
1600 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd
));
1604 cc
= (struct wmi_connect_cmd
*) skb
->data
;
1607 memcpy(cc
->ssid
, ssid
, ssid_len
);
1609 cc
->ssid_len
= ssid_len
;
1610 cc
->nw_type
= nw_type
;
1611 cc
->dot11_auth_mode
= dot11_auth_mode
;
1612 cc
->auth_mode
= auth_mode
;
1613 cc
->prwise_crypto_type
= pairwise_crypto
;
1614 cc
->prwise_crypto_len
= pairwise_crypto_len
;
1615 cc
->grp_crypto_type
= group_crypto
;
1616 cc
->grp_crypto_len
= group_crypto_len
;
1617 cc
->ch
= cpu_to_le16(channel
);
1618 cc
->ctrl_flags
= cpu_to_le32(ctrl_flags
);
1621 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1623 wmi
->pair_crypto_type
= pairwise_crypto
;
1624 wmi
->grp_crypto_type
= group_crypto
;
1626 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_CONNECT_CMDID
, NO_SYNC_WMIFLAG
);
1631 int ath6kl_wmi_reconnect_cmd(struct wmi
*wmi
, u8
*bssid
, u16 channel
)
1633 struct sk_buff
*skb
;
1634 struct wmi_reconnect_cmd
*cc
;
1637 wmi
->traffic_class
= 100;
1639 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd
));
1643 cc
= (struct wmi_reconnect_cmd
*) skb
->data
;
1644 cc
->channel
= cpu_to_le16(channel
);
1647 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1649 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RECONNECT_CMDID
,
1655 int ath6kl_wmi_disconnect_cmd(struct wmi
*wmi
)
1659 wmi
->traffic_class
= 100;
1661 /* Disconnect command does not need to do a SYNC before. */
1662 ret
= ath6kl_wmi_simple_cmd(wmi
, WMI_DISCONNECT_CMDID
);
1667 int ath6kl_wmi_startscan_cmd(struct wmi
*wmi
, enum wmi_scan_type scan_type
,
1668 u32 force_fgscan
, u32 is_legacy
,
1669 u32 home_dwell_time
, u32 force_scan_interval
,
1670 s8 num_chan
, u16
*ch_list
)
1672 struct sk_buff
*skb
;
1673 struct wmi_start_scan_cmd
*sc
;
1677 size
= sizeof(struct wmi_start_scan_cmd
);
1679 if ((scan_type
!= WMI_LONG_SCAN
) && (scan_type
!= WMI_SHORT_SCAN
))
1682 if (num_chan
> WMI_MAX_CHANNELS
)
1686 size
+= sizeof(u16
) * (num_chan
- 1);
1688 skb
= ath6kl_wmi_get_new_buf(size
);
1692 sc
= (struct wmi_start_scan_cmd
*) skb
->data
;
1693 sc
->scan_type
= scan_type
;
1694 sc
->force_fg_scan
= cpu_to_le32(force_fgscan
);
1695 sc
->is_legacy
= cpu_to_le32(is_legacy
);
1696 sc
->home_dwell_time
= cpu_to_le32(home_dwell_time
);
1697 sc
->force_scan_intvl
= cpu_to_le32(force_scan_interval
);
1698 sc
->num_ch
= num_chan
;
1700 for (i
= 0; i
< num_chan
; i
++)
1701 sc
->ch_list
[i
] = cpu_to_le16(ch_list
[i
]);
1703 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_START_SCAN_CMDID
,
1709 int ath6kl_wmi_scanparams_cmd(struct wmi
*wmi
, u16 fg_start_sec
,
1710 u16 fg_end_sec
, u16 bg_sec
,
1711 u16 minact_chdw_msec
, u16 maxact_chdw_msec
,
1712 u16 pas_chdw_msec
, u8 short_scan_ratio
,
1713 u8 scan_ctrl_flag
, u32 max_dfsch_act_time
,
1714 u16 maxact_scan_per_ssid
)
1716 struct sk_buff
*skb
;
1717 struct wmi_scan_params_cmd
*sc
;
1720 skb
= ath6kl_wmi_get_new_buf(sizeof(*sc
));
1724 sc
= (struct wmi_scan_params_cmd
*) skb
->data
;
1725 sc
->fg_start_period
= cpu_to_le16(fg_start_sec
);
1726 sc
->fg_end_period
= cpu_to_le16(fg_end_sec
);
1727 sc
->bg_period
= cpu_to_le16(bg_sec
);
1728 sc
->minact_chdwell_time
= cpu_to_le16(minact_chdw_msec
);
1729 sc
->maxact_chdwell_time
= cpu_to_le16(maxact_chdw_msec
);
1730 sc
->pas_chdwell_time
= cpu_to_le16(pas_chdw_msec
);
1731 sc
->short_scan_ratio
= short_scan_ratio
;
1732 sc
->scan_ctrl_flags
= scan_ctrl_flag
;
1733 sc
->max_dfsch_act_time
= cpu_to_le32(max_dfsch_act_time
);
1734 sc
->maxact_scan_per_ssid
= cpu_to_le16(maxact_scan_per_ssid
);
1736 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_SCAN_PARAMS_CMDID
,
1741 int ath6kl_wmi_bssfilter_cmd(struct wmi
*wmi
, u8 filter
, u32 ie_mask
)
1743 struct sk_buff
*skb
;
1744 struct wmi_bss_filter_cmd
*cmd
;
1747 if (filter
>= LAST_BSS_FILTER
)
1750 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1754 cmd
= (struct wmi_bss_filter_cmd
*) skb
->data
;
1755 cmd
->bss_filter
= filter
;
1756 cmd
->ie_mask
= cpu_to_le32(ie_mask
);
1758 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_BSS_FILTER_CMDID
,
1763 int ath6kl_wmi_probedssid_cmd(struct wmi
*wmi
, u8 index
, u8 flag
,
1764 u8 ssid_len
, u8
*ssid
)
1766 struct sk_buff
*skb
;
1767 struct wmi_probed_ssid_cmd
*cmd
;
1770 if (index
> MAX_PROBED_SSID_INDEX
)
1773 if (ssid_len
> sizeof(cmd
->ssid
))
1776 if ((flag
& (DISABLE_SSID_FLAG
| ANY_SSID_FLAG
)) && (ssid_len
> 0))
1779 if ((flag
& SPECIFIC_SSID_FLAG
) && !ssid_len
)
1782 if (flag
& SPECIFIC_SSID_FLAG
)
1783 wmi
->is_probe_ssid
= true;
1785 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1789 cmd
= (struct wmi_probed_ssid_cmd
*) skb
->data
;
1790 cmd
->entry_index
= index
;
1792 cmd
->ssid_len
= ssid_len
;
1793 memcpy(cmd
->ssid
, ssid
, ssid_len
);
1795 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_PROBED_SSID_CMDID
,
1800 int ath6kl_wmi_listeninterval_cmd(struct wmi
*wmi
, u16 listen_interval
,
1803 struct sk_buff
*skb
;
1804 struct wmi_listen_int_cmd
*cmd
;
1807 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1811 cmd
= (struct wmi_listen_int_cmd
*) skb
->data
;
1812 cmd
->listen_intvl
= cpu_to_le16(listen_interval
);
1813 cmd
->num_beacons
= cpu_to_le16(listen_beacons
);
1815 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_LISTEN_INT_CMDID
,
1820 int ath6kl_wmi_powermode_cmd(struct wmi
*wmi
, u8 pwr_mode
)
1822 struct sk_buff
*skb
;
1823 struct wmi_power_mode_cmd
*cmd
;
1826 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1830 cmd
= (struct wmi_power_mode_cmd
*) skb
->data
;
1831 cmd
->pwr_mode
= pwr_mode
;
1832 wmi
->pwr_mode
= pwr_mode
;
1834 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_POWER_MODE_CMDID
,
1839 int ath6kl_wmi_pmparams_cmd(struct wmi
*wmi
, u16 idle_period
,
1840 u16 ps_poll_num
, u16 dtim_policy
,
1841 u16 tx_wakeup_policy
, u16 num_tx_to_wakeup
,
1842 u16 ps_fail_event_policy
)
1844 struct sk_buff
*skb
;
1845 struct wmi_power_params_cmd
*pm
;
1848 skb
= ath6kl_wmi_get_new_buf(sizeof(*pm
));
1852 pm
= (struct wmi_power_params_cmd
*)skb
->data
;
1853 pm
->idle_period
= cpu_to_le16(idle_period
);
1854 pm
->pspoll_number
= cpu_to_le16(ps_poll_num
);
1855 pm
->dtim_policy
= cpu_to_le16(dtim_policy
);
1856 pm
->tx_wakeup_policy
= cpu_to_le16(tx_wakeup_policy
);
1857 pm
->num_tx_to_wakeup
= cpu_to_le16(num_tx_to_wakeup
);
1858 pm
->ps_fail_event_policy
= cpu_to_le16(ps_fail_event_policy
);
1860 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_POWER_PARAMS_CMDID
,
1865 int ath6kl_wmi_disctimeout_cmd(struct wmi
*wmi
, u8 timeout
)
1867 struct sk_buff
*skb
;
1868 struct wmi_disc_timeout_cmd
*cmd
;
1871 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1875 cmd
= (struct wmi_disc_timeout_cmd
*) skb
->data
;
1876 cmd
->discon_timeout
= timeout
;
1878 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_DISC_TIMEOUT_CMDID
,
1883 int ath6kl_wmi_addkey_cmd(struct wmi
*wmi
, u8 key_index
,
1884 enum crypto_type key_type
,
1885 u8 key_usage
, u8 key_len
,
1886 u8
*key_rsc
, u8
*key_material
,
1887 u8 key_op_ctrl
, u8
*mac_addr
,
1888 enum wmi_sync_flag sync_flag
)
1890 struct sk_buff
*skb
;
1891 struct wmi_add_cipher_key_cmd
*cmd
;
1894 ath6kl_dbg(ATH6KL_DBG_WMI
, "addkey cmd: key_index=%u key_type=%d "
1895 "key_usage=%d key_len=%d key_op_ctrl=%d\n",
1896 key_index
, key_type
, key_usage
, key_len
, key_op_ctrl
);
1898 if ((key_index
> WMI_MAX_KEY_INDEX
) || (key_len
> WMI_MAX_KEY_LEN
) ||
1899 (key_material
== NULL
))
1902 if ((WEP_CRYPT
!= key_type
) && (NULL
== key_rsc
))
1905 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1909 cmd
= (struct wmi_add_cipher_key_cmd
*) skb
->data
;
1910 cmd
->key_index
= key_index
;
1911 cmd
->key_type
= key_type
;
1912 cmd
->key_usage
= key_usage
;
1913 cmd
->key_len
= key_len
;
1914 memcpy(cmd
->key
, key_material
, key_len
);
1916 if (key_rsc
!= NULL
)
1917 memcpy(cmd
->key_rsc
, key_rsc
, sizeof(cmd
->key_rsc
));
1919 cmd
->key_op_ctrl
= key_op_ctrl
;
1922 memcpy(cmd
->key_mac_addr
, mac_addr
, ETH_ALEN
);
1924 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_ADD_CIPHER_KEY_CMDID
,
1930 int ath6kl_wmi_add_krk_cmd(struct wmi
*wmi
, u8
*krk
)
1932 struct sk_buff
*skb
;
1933 struct wmi_add_krk_cmd
*cmd
;
1936 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1940 cmd
= (struct wmi_add_krk_cmd
*) skb
->data
;
1941 memcpy(cmd
->krk
, krk
, WMI_KRK_LEN
);
1943 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_ADD_KRK_CMDID
, NO_SYNC_WMIFLAG
);
1948 int ath6kl_wmi_deletekey_cmd(struct wmi
*wmi
, u8 key_index
)
1950 struct sk_buff
*skb
;
1951 struct wmi_delete_cipher_key_cmd
*cmd
;
1954 if (key_index
> WMI_MAX_KEY_INDEX
)
1957 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1961 cmd
= (struct wmi_delete_cipher_key_cmd
*) skb
->data
;
1962 cmd
->key_index
= key_index
;
1964 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DELETE_CIPHER_KEY_CMDID
,
1970 int ath6kl_wmi_setpmkid_cmd(struct wmi
*wmi
, const u8
*bssid
,
1971 const u8
*pmkid
, bool set
)
1973 struct sk_buff
*skb
;
1974 struct wmi_setpmkid_cmd
*cmd
;
1980 if (set
&& pmkid
== NULL
)
1983 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1987 cmd
= (struct wmi_setpmkid_cmd
*) skb
->data
;
1988 memcpy(cmd
->bssid
, bssid
, ETH_ALEN
);
1990 memcpy(cmd
->pmkid
, pmkid
, sizeof(cmd
->pmkid
));
1991 cmd
->enable
= PMKID_ENABLE
;
1993 memset(cmd
->pmkid
, 0, sizeof(cmd
->pmkid
));
1994 cmd
->enable
= PMKID_DISABLE
;
1997 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_PMKID_CMDID
,
2003 static int ath6kl_wmi_data_sync_send(struct wmi
*wmi
, struct sk_buff
*skb
,
2004 enum htc_endpoint_id ep_id
)
2006 struct wmi_data_hdr
*data_hdr
;
2009 if (WARN_ON(skb
== NULL
|| ep_id
== wmi
->ep_id
))
2012 skb_push(skb
, sizeof(struct wmi_data_hdr
));
2014 data_hdr
= (struct wmi_data_hdr
*) skb
->data
;
2015 data_hdr
->info
= SYNC_MSGTYPE
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
2016 data_hdr
->info3
= 0;
2018 ret
= ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
2023 static int ath6kl_wmi_sync_point(struct wmi
*wmi
)
2025 struct sk_buff
*skb
;
2026 struct wmi_sync_cmd
*cmd
;
2027 struct wmi_data_sync_bufs data_sync_bufs
[WMM_NUM_AC
];
2028 enum htc_endpoint_id ep_id
;
2029 u8 index
, num_pri_streams
= 0;
2032 memset(data_sync_bufs
, 0, sizeof(data_sync_bufs
));
2034 spin_lock_bh(&wmi
->lock
);
2036 for (index
= 0; index
< WMM_NUM_AC
; index
++) {
2037 if (wmi
->fat_pipe_exist
& (1 << index
)) {
2039 data_sync_bufs
[num_pri_streams
- 1].traffic_class
=
2044 spin_unlock_bh(&wmi
->lock
);
2046 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2052 cmd
= (struct wmi_sync_cmd
*) skb
->data
;
2055 * In the SYNC cmd sent on the control Ep, send a bitmap
2056 * of the data eps on which the Data Sync will be sent
2058 cmd
->data_sync_map
= wmi
->fat_pipe_exist
;
2060 for (index
= 0; index
< num_pri_streams
; index
++) {
2061 data_sync_bufs
[index
].skb
= ath6kl_buf_alloc(0);
2062 if (data_sync_bufs
[index
].skb
== NULL
) {
2069 * If buffer allocation for any of the dataSync fails,
2070 * then do not send the Synchronize cmd on the control ep
2076 * Send sync cmd followed by sync data messages on all
2077 * endpoints being used
2079 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SYNCHRONIZE_CMDID
,
2085 /* cmd buffer sent, we no longer own it */
2088 for (index
= 0; index
< num_pri_streams
; index
++) {
2090 if (WARN_ON(!data_sync_bufs
[index
].skb
))
2093 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
,
2094 data_sync_bufs
[index
].
2097 ath6kl_wmi_data_sync_send(wmi
, data_sync_bufs
[index
].skb
,
2103 data_sync_bufs
[index
].skb
= NULL
;
2107 /* free up any resources left over (possibly due to an error) */
2111 for (index
= 0; index
< num_pri_streams
; index
++) {
2112 if (data_sync_bufs
[index
].skb
!= NULL
) {
2113 dev_kfree_skb((struct sk_buff
*)data_sync_bufs
[index
].
2121 int ath6kl_wmi_create_pstream_cmd(struct wmi
*wmi
,
2122 struct wmi_create_pstream_cmd
*params
)
2124 struct sk_buff
*skb
;
2125 struct wmi_create_pstream_cmd
*cmd
;
2126 u8 fatpipe_exist_for_ac
= 0;
2128 s32 nominal_phy
= 0;
2131 if (!((params
->user_pri
< 8) &&
2132 (params
->user_pri
<= 0x7) &&
2133 (up_to_ac
[params
->user_pri
& 0x7] == params
->traffic_class
) &&
2134 (params
->traffic_direc
== UPLINK_TRAFFIC
||
2135 params
->traffic_direc
== DNLINK_TRAFFIC
||
2136 params
->traffic_direc
== BIDIR_TRAFFIC
) &&
2137 (params
->traffic_type
== TRAFFIC_TYPE_APERIODIC
||
2138 params
->traffic_type
== TRAFFIC_TYPE_PERIODIC
) &&
2139 (params
->voice_psc_cap
== DISABLE_FOR_THIS_AC
||
2140 params
->voice_psc_cap
== ENABLE_FOR_THIS_AC
||
2141 params
->voice_psc_cap
== ENABLE_FOR_ALL_AC
) &&
2142 (params
->tsid
== WMI_IMPLICIT_PSTREAM
||
2143 params
->tsid
<= WMI_MAX_THINSTREAM
))) {
2148 * Check nominal PHY rate is >= minimalPHY,
2149 * so that DUT can allow TSRS IE
2152 /* Get the physical rate (units of bps) */
2153 min_phy
= ((le32_to_cpu(params
->min_phy_rate
) / 1000) / 1000);
2155 /* Check minimal phy < nominal phy rate */
2156 if (params
->nominal_phy
>= min_phy
) {
2157 /* unit of 500 kbps */
2158 nominal_phy
= (params
->nominal_phy
* 1000) / 500;
2159 ath6kl_dbg(ATH6KL_DBG_WMI
,
2160 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2161 min_phy
, nominal_phy
);
2163 params
->nominal_phy
= nominal_phy
;
2165 params
->nominal_phy
= 0;
2168 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2172 ath6kl_dbg(ATH6KL_DBG_WMI
,
2173 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2174 params
->traffic_class
, params
->tsid
);
2176 cmd
= (struct wmi_create_pstream_cmd
*) skb
->data
;
2177 memcpy(cmd
, params
, sizeof(*cmd
));
2179 /* This is an implicitly created Fat pipe */
2180 if ((u32
) params
->tsid
== (u32
) WMI_IMPLICIT_PSTREAM
) {
2181 spin_lock_bh(&wmi
->lock
);
2182 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2183 (1 << params
->traffic_class
));
2184 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2185 spin_unlock_bh(&wmi
->lock
);
2187 /* explicitly created thin stream within a fat pipe */
2188 spin_lock_bh(&wmi
->lock
);
2189 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2190 (1 << params
->traffic_class
));
2191 wmi
->stream_exist_for_ac
[params
->traffic_class
] |=
2192 (1 << params
->tsid
);
2194 * If a thinstream becomes active, the fat pipe automatically
2197 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2198 spin_unlock_bh(&wmi
->lock
);
2202 * Indicate activty change to driver layer only if this is the
2203 * first TSID to get created in this AC explicitly or an implicit
2204 * fat pipe is getting created.
2206 if (!fatpipe_exist_for_ac
)
2207 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2208 params
->traffic_class
, true);
2210 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_CREATE_PSTREAM_CMDID
,
2215 int ath6kl_wmi_delete_pstream_cmd(struct wmi
*wmi
, u8 traffic_class
, u8 tsid
)
2217 struct sk_buff
*skb
;
2218 struct wmi_delete_pstream_cmd
*cmd
;
2219 u16 active_tsids
= 0;
2222 if (traffic_class
> 3) {
2223 ath6kl_err("invalid traffic class: %d\n", traffic_class
);
2227 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2231 cmd
= (struct wmi_delete_pstream_cmd
*) skb
->data
;
2232 cmd
->traffic_class
= traffic_class
;
2235 spin_lock_bh(&wmi
->lock
);
2236 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2237 spin_unlock_bh(&wmi
->lock
);
2239 if (!(active_tsids
& (1 << tsid
))) {
2241 ath6kl_dbg(ATH6KL_DBG_WMI
,
2242 "TSID %d doesn't exist for traffic class: %d\n",
2243 tsid
, traffic_class
);
2247 ath6kl_dbg(ATH6KL_DBG_WMI
,
2248 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2249 traffic_class
, tsid
);
2251 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DELETE_PSTREAM_CMDID
,
2252 SYNC_BEFORE_WMIFLAG
);
2254 spin_lock_bh(&wmi
->lock
);
2255 wmi
->stream_exist_for_ac
[traffic_class
] &= ~(1 << tsid
);
2256 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2257 spin_unlock_bh(&wmi
->lock
);
2260 * Indicate stream inactivity to driver layer only if all tsids
2261 * within this AC are deleted.
2263 if (!active_tsids
) {
2264 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2265 traffic_class
, false);
2266 wmi
->fat_pipe_exist
&= ~(1 << traffic_class
);
2272 int ath6kl_wmi_set_ip_cmd(struct wmi
*wmi
, struct wmi_set_ip_cmd
*ip_cmd
)
2274 struct sk_buff
*skb
;
2275 struct wmi_set_ip_cmd
*cmd
;
2278 /* Multicast address are not valid */
2279 if ((*((u8
*) &ip_cmd
->ips
[0]) >= 0xE0) ||
2280 (*((u8
*) &ip_cmd
->ips
[1]) >= 0xE0))
2283 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd
));
2287 cmd
= (struct wmi_set_ip_cmd
*) skb
->data
;
2288 memcpy(cmd
, ip_cmd
, sizeof(struct wmi_set_ip_cmd
));
2290 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_IP_CMDID
, NO_SYNC_WMIFLAG
);
2294 static int ath6kl_wmi_get_wow_list_event_rx(struct wmi
*wmi
, u8
* datap
,
2297 if (len
< sizeof(struct wmi_get_wow_list_reply
))
2303 static int ath6kl_wmi_cmd_send_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
,
2304 enum wmix_command_id cmd_id
,
2305 enum wmi_sync_flag sync_flag
)
2307 struct wmix_cmd_hdr
*cmd_hdr
;
2310 skb_push(skb
, sizeof(struct wmix_cmd_hdr
));
2312 cmd_hdr
= (struct wmix_cmd_hdr
*) skb
->data
;
2313 cmd_hdr
->cmd_id
= cpu_to_le32(cmd_id
);
2315 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_EXTENSION_CMDID
, sync_flag
);
2320 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi
*wmi
, u32 cookie
, u32 source
)
2322 struct sk_buff
*skb
;
2323 struct wmix_hb_challenge_resp_cmd
*cmd
;
2326 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2330 cmd
= (struct wmix_hb_challenge_resp_cmd
*) skb
->data
;
2331 cmd
->cookie
= cpu_to_le32(cookie
);
2332 cmd
->source
= cpu_to_le32(source
);
2334 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_HB_CHALLENGE_RESP_CMDID
,
2339 int ath6kl_wmi_config_debug_module_cmd(struct wmi
*wmi
, u32 valid
, u32 config
)
2341 struct ath6kl_wmix_dbglog_cfg_module_cmd
*cmd
;
2342 struct sk_buff
*skb
;
2345 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2349 cmd
= (struct ath6kl_wmix_dbglog_cfg_module_cmd
*) skb
->data
;
2350 cmd
->valid
= cpu_to_le32(valid
);
2351 cmd
->config
= cpu_to_le32(config
);
2353 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_DBGLOG_CFG_MODULE_CMDID
,
2358 int ath6kl_wmi_get_stats_cmd(struct wmi
*wmi
)
2360 return ath6kl_wmi_simple_cmd(wmi
, WMI_GET_STATISTICS_CMDID
);
2363 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi
*wmi
, u8 dbM
)
2365 struct sk_buff
*skb
;
2366 struct wmi_set_tx_pwr_cmd
*cmd
;
2369 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd
));
2373 cmd
= (struct wmi_set_tx_pwr_cmd
*) skb
->data
;
2376 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_TX_PWR_CMDID
,
2382 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi
*wmi
)
2384 return ath6kl_wmi_simple_cmd(wmi
, WMI_GET_TX_PWR_CMDID
);
2387 int ath6kl_wmi_set_lpreamble_cmd(struct wmi
*wmi
, u8 status
, u8 preamble_policy
)
2389 struct sk_buff
*skb
;
2390 struct wmi_set_lpreamble_cmd
*cmd
;
2393 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd
));
2397 cmd
= (struct wmi_set_lpreamble_cmd
*) skb
->data
;
2398 cmd
->status
= status
;
2399 cmd
->preamble_policy
= preamble_policy
;
2401 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_LPREAMBLE_CMDID
,
2406 int ath6kl_wmi_set_rts_cmd(struct wmi
*wmi
, u16 threshold
)
2408 struct sk_buff
*skb
;
2409 struct wmi_set_rts_cmd
*cmd
;
2412 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd
));
2416 cmd
= (struct wmi_set_rts_cmd
*) skb
->data
;
2417 cmd
->threshold
= cpu_to_le16(threshold
);
2419 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_RTS_CMDID
, NO_SYNC_WMIFLAG
);
2423 int ath6kl_wmi_set_wmm_txop(struct wmi
*wmi
, enum wmi_txop_cfg cfg
)
2425 struct sk_buff
*skb
;
2426 struct wmi_set_wmm_txop_cmd
*cmd
;
2429 if (!((cfg
== WMI_TXOP_DISABLED
) || (cfg
== WMI_TXOP_ENABLED
)))
2432 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd
));
2436 cmd
= (struct wmi_set_wmm_txop_cmd
*) skb
->data
;
2437 cmd
->txop_enable
= cfg
;
2439 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_WMM_TXOP_CMDID
,
2444 int ath6kl_wmi_set_keepalive_cmd(struct wmi
*wmi
, u8 keep_alive_intvl
)
2446 struct sk_buff
*skb
;
2447 struct wmi_set_keepalive_cmd
*cmd
;
2450 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2454 cmd
= (struct wmi_set_keepalive_cmd
*) skb
->data
;
2455 cmd
->keep_alive_intvl
= keep_alive_intvl
;
2456 wmi
->keep_alive_intvl
= keep_alive_intvl
;
2458 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_KEEPALIVE_CMDID
,
2463 int ath6kl_wmi_test_cmd(struct wmi
*wmi
, void *buf
, size_t len
)
2465 struct sk_buff
*skb
;
2468 skb
= ath6kl_wmi_get_new_buf(len
);
2472 memcpy(skb
->data
, buf
, len
);
2474 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_TEST_CMDID
, NO_SYNC_WMIFLAG
);
2480 s32
ath6kl_wmi_get_rate(s8 rate_index
)
2482 if (rate_index
== RATE_AUTO
)
2485 return wmi_rate_tbl
[(u32
) rate_index
][0];
2488 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi
*wmi
, u8
*datap
,
2491 struct wmi_pmkid_list_reply
*reply
;
2494 if (len
< sizeof(struct wmi_pmkid_list_reply
))
2497 reply
= (struct wmi_pmkid_list_reply
*)datap
;
2498 expected_len
= sizeof(reply
->num_pmkid
) +
2499 le32_to_cpu(reply
->num_pmkid
) * WMI_PMKID_LEN
;
2501 if (len
< expected_len
)
2507 static int ath6kl_wmi_addba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2509 struct wmi_addba_req_event
*cmd
= (struct wmi_addba_req_event
*) datap
;
2511 aggr_recv_addba_req_evt(wmi
->parent_dev
, cmd
->tid
,
2512 le16_to_cpu(cmd
->st_seq_no
), cmd
->win_sz
);
2517 static int ath6kl_wmi_delba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2519 struct wmi_delba_event
*cmd
= (struct wmi_delba_event
*) datap
;
2521 aggr_recv_delba_req_evt(wmi
->parent_dev
, cmd
->tid
);
2526 /* AP mode functions */
2528 int ath6kl_wmi_ap_profile_commit(struct wmi
*wmip
, struct wmi_connect_cmd
*p
)
2530 struct sk_buff
*skb
;
2531 struct wmi_connect_cmd
*cm
;
2534 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
2538 cm
= (struct wmi_connect_cmd
*) skb
->data
;
2539 memcpy(cm
, p
, sizeof(*cm
));
2541 res
= ath6kl_wmi_cmd_send(wmip
, skb
, WMI_AP_CONFIG_COMMIT_CMDID
,
2543 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: nw_type=%u auth_mode=%u ch=%u "
2544 "ctrl_flags=0x%x-> res=%d\n",
2545 __func__
, p
->nw_type
, p
->auth_mode
, le16_to_cpu(p
->ch
),
2546 le32_to_cpu(p
->ctrl_flags
), res
);
2550 int ath6kl_wmi_ap_set_mlme(struct wmi
*wmip
, u8 cmd
, const u8
*mac
, u16 reason
)
2552 struct sk_buff
*skb
;
2553 struct wmi_ap_set_mlme_cmd
*cm
;
2555 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
2559 cm
= (struct wmi_ap_set_mlme_cmd
*) skb
->data
;
2560 memcpy(cm
->mac
, mac
, ETH_ALEN
);
2561 cm
->reason
= cpu_to_le16(reason
);
2564 return ath6kl_wmi_cmd_send(wmip
, skb
, WMI_AP_SET_MLME_CMDID
,
2568 static int ath6kl_wmi_pspoll_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2570 struct wmi_pspoll_event
*ev
;
2572 if (len
< sizeof(struct wmi_pspoll_event
))
2575 ev
= (struct wmi_pspoll_event
*) datap
;
2577 ath6kl_pspoll_event(wmi
->parent_dev
, le16_to_cpu(ev
->aid
));
2582 static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2584 ath6kl_dtimexpiry_event(wmi
->parent_dev
);
2589 int ath6kl_wmi_set_pvb_cmd(struct wmi
*wmi
, u16 aid
, bool flag
)
2591 struct sk_buff
*skb
;
2592 struct wmi_ap_set_pvb_cmd
*cmd
;
2595 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd
));
2599 cmd
= (struct wmi_ap_set_pvb_cmd
*) skb
->data
;
2600 cmd
->aid
= cpu_to_le16(aid
);
2601 cmd
->rsvd
= cpu_to_le16(0);
2602 cmd
->flag
= cpu_to_le32(flag
);
2604 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_AP_SET_PVB_CMDID
,
2610 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi
*wmi
, u8 rx_meta_ver
,
2611 bool rx_dot11_hdr
, bool defrag_on_host
)
2613 struct sk_buff
*skb
;
2614 struct wmi_rx_frame_format_cmd
*cmd
;
2617 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2621 cmd
= (struct wmi_rx_frame_format_cmd
*) skb
->data
;
2622 cmd
->dot11_hdr
= rx_dot11_hdr
? 1 : 0;
2623 cmd
->defrag_on_host
= defrag_on_host
? 1 : 0;
2624 cmd
->meta_ver
= rx_meta_ver
;
2626 /* Delete the local aggr state, on host */
2627 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RX_FRAME_FORMAT_CMDID
,
2633 int ath6kl_wmi_set_appie_cmd(struct wmi
*wmi
, u8 mgmt_frm_type
, const u8
*ie
,
2636 struct sk_buff
*skb
;
2637 struct wmi_set_appie_cmd
*p
;
2639 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + ie_len
);
2643 ath6kl_dbg(ATH6KL_DBG_WMI
, "set_appie_cmd: mgmt_frm_type=%u "
2644 "ie_len=%u\n", mgmt_frm_type
, ie_len
);
2645 p
= (struct wmi_set_appie_cmd
*) skb
->data
;
2646 p
->mgmt_frm_type
= mgmt_frm_type
;
2648 memcpy(p
->ie_info
, ie
, ie_len
);
2649 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_APPIE_CMDID
,
2653 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi
*wmi
, bool disable
)
2655 struct sk_buff
*skb
;
2656 struct wmi_disable_11b_rates_cmd
*cmd
;
2658 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2662 ath6kl_dbg(ATH6KL_DBG_WMI
, "disable_11b_rates_cmd: disable=%u\n",
2664 cmd
= (struct wmi_disable_11b_rates_cmd
*) skb
->data
;
2665 cmd
->disable
= disable
? 1 : 0;
2667 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DISABLE_11B_RATES_CMDID
,
2671 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi
*wmi
, u32 freq
, u32 dur
)
2673 struct sk_buff
*skb
;
2674 struct wmi_remain_on_chnl_cmd
*p
;
2676 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2680 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl_cmd: freq=%u dur=%u\n",
2682 p
= (struct wmi_remain_on_chnl_cmd
*) skb
->data
;
2683 p
->freq
= cpu_to_le32(freq
);
2684 p
->duration
= cpu_to_le32(dur
);
2685 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_REMAIN_ON_CHNL_CMDID
,
2689 int ath6kl_wmi_send_action_cmd(struct wmi
*wmi
, u32 id
, u32 freq
, u32 wait
,
2690 const u8
*data
, u16 data_len
)
2692 struct sk_buff
*skb
;
2693 struct wmi_send_action_cmd
*p
;
2697 return -EINVAL
; /* Offload for wait not supported */
2699 buf
= kmalloc(data_len
, GFP_KERNEL
);
2703 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
2709 kfree(wmi
->last_mgmt_tx_frame
);
2710 wmi
->last_mgmt_tx_frame
= buf
;
2711 wmi
->last_mgmt_tx_frame_len
= data_len
;
2713 ath6kl_dbg(ATH6KL_DBG_WMI
, "send_action_cmd: id=%u freq=%u wait=%u "
2714 "len=%u\n", id
, freq
, wait
, data_len
);
2715 p
= (struct wmi_send_action_cmd
*) skb
->data
;
2716 p
->id
= cpu_to_le32(id
);
2717 p
->freq
= cpu_to_le32(freq
);
2718 p
->wait
= cpu_to_le32(wait
);
2719 p
->len
= cpu_to_le16(data_len
);
2720 memcpy(p
->data
, data
, data_len
);
2721 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SEND_ACTION_CMDID
,
2725 int ath6kl_wmi_send_probe_response_cmd(struct wmi
*wmi
, u32 freq
,
2727 const u8
*data
, u16 data_len
)
2729 struct sk_buff
*skb
;
2730 struct wmi_p2p_probe_response_cmd
*p
;
2732 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
2736 ath6kl_dbg(ATH6KL_DBG_WMI
, "send_probe_response_cmd: freq=%u dst=%pM "
2737 "len=%u\n", freq
, dst
, data_len
);
2738 p
= (struct wmi_p2p_probe_response_cmd
*) skb
->data
;
2739 p
->freq
= cpu_to_le32(freq
);
2740 memcpy(p
->destination_addr
, dst
, ETH_ALEN
);
2741 p
->len
= cpu_to_le16(data_len
);
2742 memcpy(p
->data
, data
, data_len
);
2743 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SEND_PROBE_RESPONSE_CMDID
,
2747 int ath6kl_wmi_probe_report_req_cmd(struct wmi
*wmi
, bool enable
)
2749 struct sk_buff
*skb
;
2750 struct wmi_probe_req_report_cmd
*p
;
2752 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2756 ath6kl_dbg(ATH6KL_DBG_WMI
, "probe_report_req_cmd: enable=%u\n",
2758 p
= (struct wmi_probe_req_report_cmd
*) skb
->data
;
2759 p
->enable
= enable
? 1 : 0;
2760 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_PROBE_REQ_REPORT_CMDID
,
2764 int ath6kl_wmi_info_req_cmd(struct wmi
*wmi
, u32 info_req_flags
)
2766 struct sk_buff
*skb
;
2767 struct wmi_get_p2p_info
*p
;
2769 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2773 ath6kl_dbg(ATH6KL_DBG_WMI
, "info_req_cmd: flags=%x\n",
2775 p
= (struct wmi_get_p2p_info
*) skb
->data
;
2776 p
->info_req_flags
= cpu_to_le32(info_req_flags
);
2777 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_GET_P2P_INFO_CMDID
,
2781 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi
*wmi
)
2783 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl_cmd\n");
2784 return ath6kl_wmi_simple_cmd(wmi
, WMI_CANCEL_REMAIN_ON_CHNL_CMDID
);
2787 static int ath6kl_wmi_control_rx_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
)
2789 struct wmix_cmd_hdr
*cmd
;
2795 if (skb
->len
< sizeof(struct wmix_cmd_hdr
)) {
2796 ath6kl_err("bad packet 1\n");
2797 wmi
->stat
.cmd_len_err
++;
2801 cmd
= (struct wmix_cmd_hdr
*) skb
->data
;
2802 id
= le32_to_cpu(cmd
->cmd_id
);
2804 skb_pull(skb
, sizeof(struct wmix_cmd_hdr
));
2810 case WMIX_HB_CHALLENGE_RESP_EVENTID
:
2812 case WMIX_DBGLOG_EVENTID
:
2813 ath6kl_debug_fwlog_event(wmi
->parent_dev
, datap
, len
);
2816 ath6kl_err("unknown cmd id 0x%x\n", id
);
2817 wmi
->stat
.cmd_id_err
++;
2826 int ath6kl_wmi_control_rx(struct wmi
*wmi
, struct sk_buff
*skb
)
2828 struct wmi_cmd_hdr
*cmd
;
2834 if (WARN_ON(skb
== NULL
))
2837 if (skb
->len
< sizeof(struct wmi_cmd_hdr
)) {
2838 ath6kl_err("bad packet 1\n");
2840 wmi
->stat
.cmd_len_err
++;
2844 cmd
= (struct wmi_cmd_hdr
*) skb
->data
;
2845 id
= le16_to_cpu(cmd
->cmd_id
);
2847 skb_pull(skb
, sizeof(struct wmi_cmd_hdr
));
2852 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: wmi id: %d\n", __func__
, id
);
2853 ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES
, "msg payload ", datap
, len
);
2856 case WMI_GET_BITRATE_CMDID
:
2857 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_BITRATE_CMDID\n");
2858 ret
= ath6kl_wmi_bitrate_reply_rx(wmi
, datap
, len
);
2860 case WMI_GET_CHANNEL_LIST_CMDID
:
2861 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_CHANNEL_LIST_CMDID\n");
2862 ret
= ath6kl_wmi_ch_list_reply_rx(wmi
, datap
, len
);
2864 case WMI_GET_TX_PWR_CMDID
:
2865 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_TX_PWR_CMDID\n");
2866 ret
= ath6kl_wmi_tx_pwr_reply_rx(wmi
, datap
, len
);
2868 case WMI_READY_EVENTID
:
2869 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_READY_EVENTID\n");
2870 ret
= ath6kl_wmi_ready_event_rx(wmi
, datap
, len
);
2872 case WMI_CONNECT_EVENTID
:
2873 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CONNECT_EVENTID\n");
2874 ret
= ath6kl_wmi_connect_event_rx(wmi
, datap
, len
);
2876 case WMI_DISCONNECT_EVENTID
:
2877 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DISCONNECT_EVENTID\n");
2878 ret
= ath6kl_wmi_disconnect_event_rx(wmi
, datap
, len
);
2880 case WMI_PEER_NODE_EVENTID
:
2881 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PEER_NODE_EVENTID\n");
2882 ret
= ath6kl_wmi_peer_node_event_rx(wmi
, datap
, len
);
2884 case WMI_TKIP_MICERR_EVENTID
:
2885 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TKIP_MICERR_EVENTID\n");
2886 ret
= ath6kl_wmi_tkip_micerr_event_rx(wmi
, datap
, len
);
2888 case WMI_BSSINFO_EVENTID
:
2889 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_BSSINFO_EVENTID\n");
2890 ret
= ath6kl_wmi_bssinfo_event_rx(wmi
, datap
, len
);
2892 case WMI_REGDOMAIN_EVENTID
:
2893 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REGDOMAIN_EVENTID\n");
2894 ath6kl_wmi_regdomain_event(wmi
, datap
, len
);
2896 case WMI_PSTREAM_TIMEOUT_EVENTID
:
2897 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
2898 ret
= ath6kl_wmi_pstream_timeout_event_rx(wmi
, datap
, len
);
2900 case WMI_NEIGHBOR_REPORT_EVENTID
:
2901 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_NEIGHBOR_REPORT_EVENTID\n");
2902 ret
= ath6kl_wmi_neighbor_report_event_rx(wmi
, datap
, len
);
2904 case WMI_SCAN_COMPLETE_EVENTID
:
2905 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SCAN_COMPLETE_EVENTID\n");
2906 ret
= ath6kl_wmi_scan_complete_rx(wmi
, datap
, len
);
2908 case WMI_CMDERROR_EVENTID
:
2909 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CMDERROR_EVENTID\n");
2910 ret
= ath6kl_wmi_error_event_rx(wmi
, datap
, len
);
2912 case WMI_REPORT_STATISTICS_EVENTID
:
2913 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_STATISTICS_EVENTID\n");
2914 ret
= ath6kl_wmi_stats_event_rx(wmi
, datap
, len
);
2916 case WMI_RSSI_THRESHOLD_EVENTID
:
2917 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RSSI_THRESHOLD_EVENTID\n");
2918 ret
= ath6kl_wmi_rssi_threshold_event_rx(wmi
, datap
, len
);
2920 case WMI_ERROR_REPORT_EVENTID
:
2921 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ERROR_REPORT_EVENTID\n");
2923 case WMI_OPT_RX_FRAME_EVENTID
:
2924 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_OPT_RX_FRAME_EVENTID\n");
2925 /* this event has been deprecated */
2927 case WMI_REPORT_ROAM_TBL_EVENTID
:
2928 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_TBL_EVENTID\n");
2930 case WMI_EXTENSION_EVENTID
:
2931 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_EXTENSION_EVENTID\n");
2932 ret
= ath6kl_wmi_control_rx_xtnd(wmi
, skb
);
2934 case WMI_CAC_EVENTID
:
2935 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CAC_EVENTID\n");
2936 ret
= ath6kl_wmi_cac_event_rx(wmi
, datap
, len
);
2938 case WMI_CHANNEL_CHANGE_EVENTID
:
2939 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CHANNEL_CHANGE_EVENTID\n");
2941 case WMI_REPORT_ROAM_DATA_EVENTID
:
2942 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_DATA_EVENTID\n");
2944 case WMI_TEST_EVENTID
:
2945 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TEST_EVENTID\n");
2946 ret
= ath6kl_wmi_tcmd_test_report_rx(wmi
, datap
, len
);
2948 case WMI_GET_FIXRATES_CMDID
:
2949 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_FIXRATES_CMDID\n");
2950 ret
= ath6kl_wmi_ratemask_reply_rx(wmi
, datap
, len
);
2952 case WMI_TX_RETRY_ERR_EVENTID
:
2953 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_RETRY_ERR_EVENTID\n");
2955 case WMI_SNR_THRESHOLD_EVENTID
:
2956 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SNR_THRESHOLD_EVENTID\n");
2957 ret
= ath6kl_wmi_snr_threshold_event_rx(wmi
, datap
, len
);
2959 case WMI_LQ_THRESHOLD_EVENTID
:
2960 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_LQ_THRESHOLD_EVENTID\n");
2962 case WMI_APLIST_EVENTID
:
2963 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_APLIST_EVENTID\n");
2964 ret
= ath6kl_wmi_aplist_event_rx(wmi
, datap
, len
);
2966 case WMI_GET_KEEPALIVE_CMDID
:
2967 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_KEEPALIVE_CMDID\n");
2968 ret
= ath6kl_wmi_keepalive_reply_rx(wmi
, datap
, len
);
2970 case WMI_GET_WOW_LIST_EVENTID
:
2971 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_WOW_LIST_EVENTID\n");
2972 ret
= ath6kl_wmi_get_wow_list_event_rx(wmi
, datap
, len
);
2974 case WMI_GET_PMKID_LIST_EVENTID
:
2975 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_PMKID_LIST_EVENTID\n");
2976 ret
= ath6kl_wmi_get_pmkid_list_event_rx(wmi
, datap
, len
);
2978 case WMI_PSPOLL_EVENTID
:
2979 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSPOLL_EVENTID\n");
2980 ret
= ath6kl_wmi_pspoll_event_rx(wmi
, datap
, len
);
2982 case WMI_DTIMEXPIRY_EVENTID
:
2983 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DTIMEXPIRY_EVENTID\n");
2984 ret
= ath6kl_wmi_dtimexpiry_event_rx(wmi
, datap
, len
);
2986 case WMI_SET_PARAMS_REPLY_EVENTID
:
2987 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SET_PARAMS_REPLY_EVENTID\n");
2989 case WMI_ADDBA_REQ_EVENTID
:
2990 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_REQ_EVENTID\n");
2991 ret
= ath6kl_wmi_addba_req_event_rx(wmi
, datap
, len
);
2993 case WMI_ADDBA_RESP_EVENTID
:
2994 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_RESP_EVENTID\n");
2996 case WMI_DELBA_REQ_EVENTID
:
2997 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DELBA_REQ_EVENTID\n");
2998 ret
= ath6kl_wmi_delba_req_event_rx(wmi
, datap
, len
);
3000 case WMI_REPORT_BTCOEX_CONFIG_EVENTID
:
3001 ath6kl_dbg(ATH6KL_DBG_WMI
,
3002 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
3004 case WMI_REPORT_BTCOEX_STATS_EVENTID
:
3005 ath6kl_dbg(ATH6KL_DBG_WMI
,
3006 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
3008 case WMI_TX_COMPLETE_EVENTID
:
3009 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_COMPLETE_EVENTID\n");
3010 ret
= ath6kl_wmi_tx_complete_event_rx(datap
, len
);
3012 case WMI_REMAIN_ON_CHNL_EVENTID
:
3013 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REMAIN_ON_CHNL_EVENTID\n");
3014 ret
= ath6kl_wmi_remain_on_chnl_event_rx(wmi
, datap
, len
);
3016 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID
:
3017 ath6kl_dbg(ATH6KL_DBG_WMI
,
3018 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
3019 ret
= ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi
, datap
,
3022 case WMI_TX_STATUS_EVENTID
:
3023 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_STATUS_EVENTID\n");
3024 ret
= ath6kl_wmi_tx_status_event_rx(wmi
, datap
, len
);
3026 case WMI_RX_PROBE_REQ_EVENTID
:
3027 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_PROBE_REQ_EVENTID\n");
3028 ret
= ath6kl_wmi_rx_probe_req_event_rx(wmi
, datap
, len
);
3030 case WMI_P2P_CAPABILITIES_EVENTID
:
3031 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_CAPABILITIES_EVENTID\n");
3032 ret
= ath6kl_wmi_p2p_capabilities_event_rx(datap
, len
);
3034 case WMI_RX_ACTION_EVENTID
:
3035 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_ACTION_EVENTID\n");
3036 ret
= ath6kl_wmi_rx_action_event_rx(wmi
, datap
, len
);
3038 case WMI_P2P_INFO_EVENTID
:
3039 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_INFO_EVENTID\n");
3040 ret
= ath6kl_wmi_p2p_info_event_rx(datap
, len
);
3043 ath6kl_dbg(ATH6KL_DBG_WMI
, "unknown cmd id 0x%x\n", id
);
3044 wmi
->stat
.cmd_id_err
++;
3054 static void ath6kl_wmi_qos_state_init(struct wmi
*wmi
)
3059 spin_lock_bh(&wmi
->lock
);
3061 wmi
->fat_pipe_exist
= 0;
3062 memset(wmi
->stream_exist_for_ac
, 0, sizeof(wmi
->stream_exist_for_ac
));
3064 spin_unlock_bh(&wmi
->lock
);
3067 void *ath6kl_wmi_init(struct ath6kl
*dev
)
3071 wmi
= kzalloc(sizeof(struct wmi
), GFP_KERNEL
);
3075 spin_lock_init(&wmi
->lock
);
3077 wmi
->parent_dev
= dev
;
3079 ath6kl_wmi_qos_state_init(wmi
);
3081 wmi
->pwr_mode
= REC_POWER
;
3082 wmi
->phy_mode
= WMI_11G_MODE
;
3084 wmi
->pair_crypto_type
= NONE_CRYPT
;
3085 wmi
->grp_crypto_type
= NONE_CRYPT
;
3087 wmi
->ht_allowed
[A_BAND_24GHZ
] = 1;
3088 wmi
->ht_allowed
[A_BAND_5GHZ
] = 1;
3093 void ath6kl_wmi_shutdown(struct wmi
*wmi
)
3098 kfree(wmi
->last_mgmt_tx_frame
);