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
,
725 "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n",
726 le16_to_cpu(ev
->u
.sta
.ch
), ev
->u
.sta
.bssid
,
727 le16_to_cpu(ev
->u
.sta
.listen_intvl
),
728 le16_to_cpu(ev
->u
.sta
.beacon_intvl
),
729 le32_to_cpu(ev
->u
.sta
.nw_type
));
731 /* Start of assoc rsp IEs */
732 pie
= ev
->assoc_info
+ ev
->beacon_ie_len
+
733 ev
->assoc_req_len
+ (sizeof(u16
) * 3); /* capinfo, status, aid */
735 /* End of assoc rsp IEs */
736 peie
= ev
->assoc_info
+ ev
->beacon_ie_len
+ ev
->assoc_req_len
+
741 case WLAN_EID_VENDOR_SPECIFIC
:
742 if (pie
[1] > 3 && pie
[2] == 0x00 && pie
[3] == 0x50 &&
743 pie
[4] == 0xf2 && pie
[5] == WMM_OUI_TYPE
) {
744 /* WMM OUT (00:50:F2) */
746 && pie
[6] == WMM_PARAM_OUI_SUBTYPE
)
747 wmi
->is_wmm_enabled
= true;
752 if (wmi
->is_wmm_enabled
)
758 ath6kl_connect_event(wmi
->parent_dev
, le16_to_cpu(ev
->u
.sta
.ch
),
760 le16_to_cpu(ev
->u
.sta
.listen_intvl
),
761 le16_to_cpu(ev
->u
.sta
.beacon_intvl
),
762 le32_to_cpu(ev
->u
.sta
.nw_type
),
763 ev
->beacon_ie_len
, ev
->assoc_req_len
,
764 ev
->assoc_resp_len
, ev
->assoc_info
);
769 static struct country_code_to_enum_rd
*
770 ath6kl_regd_find_country(u16 countryCode
)
774 for (i
= 0; i
< ARRAY_SIZE(allCountries
); i
++) {
775 if (allCountries
[i
].countryCode
== countryCode
)
776 return &allCountries
[i
];
782 static struct reg_dmn_pair_mapping
*
783 ath6kl_get_regpair(u16 regdmn
)
787 if (regdmn
== NO_ENUMRD
)
790 for (i
= 0; i
< ARRAY_SIZE(regDomainPairs
); i
++) {
791 if (regDomainPairs
[i
].regDmnEnum
== regdmn
)
792 return ®DomainPairs
[i
];
798 static struct country_code_to_enum_rd
*
799 ath6kl_regd_find_country_by_rd(u16 regdmn
)
803 for (i
= 0; i
< ARRAY_SIZE(allCountries
); i
++) {
804 if (allCountries
[i
].regDmnEnum
== regdmn
)
805 return &allCountries
[i
];
811 static void ath6kl_wmi_regdomain_event(struct wmi
*wmi
, u8
*datap
, int len
)
814 struct ath6kl_wmi_regdomain
*ev
;
815 struct country_code_to_enum_rd
*country
= NULL
;
816 struct reg_dmn_pair_mapping
*regpair
= NULL
;
820 ev
= (struct ath6kl_wmi_regdomain
*) datap
;
821 reg_code
= le32_to_cpu(ev
->reg_code
);
823 if ((reg_code
>> ATH6KL_COUNTRY_RD_SHIFT
) & COUNTRY_ERD_FLAG
)
824 country
= ath6kl_regd_find_country((u16
) reg_code
);
825 else if (!(((u16
) reg_code
& WORLD_SKU_MASK
) == WORLD_SKU_PREFIX
)) {
827 regpair
= ath6kl_get_regpair((u16
) reg_code
);
828 country
= ath6kl_regd_find_country_by_rd((u16
) reg_code
);
829 ath6kl_dbg(ATH6KL_DBG_WMI
, "Regpair used: 0x%0x\n",
830 regpair
->regDmnEnum
);
834 alpha2
[0] = country
->isoName
[0];
835 alpha2
[1] = country
->isoName
[1];
837 regulatory_hint(wmi
->parent_dev
->wdev
->wiphy
, alpha2
);
839 ath6kl_dbg(ATH6KL_DBG_WMI
, "Country alpha2 being used: %c%c\n",
840 alpha2
[0], alpha2
[1]);
844 static int ath6kl_wmi_disconnect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
846 struct wmi_disconnect_event
*ev
;
847 wmi
->traffic_class
= 100;
849 if (len
< sizeof(struct wmi_disconnect_event
))
852 ev
= (struct wmi_disconnect_event
*) datap
;
854 ath6kl_dbg(ATH6KL_DBG_WMI
,
855 "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n",
856 le16_to_cpu(ev
->proto_reason_status
), ev
->bssid
,
857 ev
->disconn_reason
, ev
->assoc_resp_len
);
859 wmi
->is_wmm_enabled
= false;
860 wmi
->pair_crypto_type
= NONE_CRYPT
;
861 wmi
->grp_crypto_type
= NONE_CRYPT
;
863 ath6kl_disconnect_event(wmi
->parent_dev
, ev
->disconn_reason
,
864 ev
->bssid
, ev
->assoc_resp_len
, ev
->assoc_info
,
865 le16_to_cpu(ev
->proto_reason_status
));
870 static int ath6kl_wmi_peer_node_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
872 struct wmi_peer_node_event
*ev
;
874 if (len
< sizeof(struct wmi_peer_node_event
))
877 ev
= (struct wmi_peer_node_event
*) datap
;
879 if (ev
->event_code
== PEER_NODE_JOIN_EVENT
)
880 ath6kl_dbg(ATH6KL_DBG_WMI
, "joined node with mac addr: %pM\n",
882 else if (ev
->event_code
== PEER_NODE_LEAVE_EVENT
)
883 ath6kl_dbg(ATH6KL_DBG_WMI
, "left node with mac addr: %pM\n",
889 static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
891 struct wmi_tkip_micerr_event
*ev
;
893 if (len
< sizeof(struct wmi_tkip_micerr_event
))
896 ev
= (struct wmi_tkip_micerr_event
*) datap
;
898 ath6kl_tkip_micerr_event(wmi
->parent_dev
, ev
->key_id
, ev
->is_mcast
);
903 static int ath6kl_wmi_bssinfo_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
905 struct wmi_bss_info_hdr2
*bih
;
907 struct ieee80211_channel
*channel
;
908 struct ath6kl
*ar
= wmi
->parent_dev
;
909 struct ieee80211_mgmt
*mgmt
;
910 struct cfg80211_bss
*bss
;
912 if (len
<= sizeof(struct wmi_bss_info_hdr2
))
915 bih
= (struct wmi_bss_info_hdr2
*) datap
;
916 buf
= datap
+ sizeof(struct wmi_bss_info_hdr2
);
917 len
-= sizeof(struct wmi_bss_info_hdr2
);
919 ath6kl_dbg(ATH6KL_DBG_WMI
,
920 "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
922 bih
->ch
, bih
->snr
, bih
->snr
- 95, bih
->bssid
,
925 if (bih
->frame_type
!= BEACON_FTYPE
&&
926 bih
->frame_type
!= PROBERESP_FTYPE
)
927 return 0; /* Only update BSS table for now */
929 if (bih
->frame_type
== BEACON_FTYPE
&&
930 test_bit(CLEAR_BSSFILTER_ON_BEACON
, &ar
->flag
)) {
931 clear_bit(CLEAR_BSSFILTER_ON_BEACON
, &ar
->flag
);
932 ath6kl_wmi_bssfilter_cmd(ar
->wmi
, NONE_BSS_FILTER
, 0);
935 channel
= ieee80211_get_channel(ar
->wdev
->wiphy
, le16_to_cpu(bih
->ch
));
942 if (bih
->frame_type
== BEACON_FTYPE
&& test_bit(CONNECTED
, &ar
->flag
) &&
943 memcmp(bih
->bssid
, ar
->bssid
, ETH_ALEN
) == 0) {
945 tim
= cfg80211_find_ie(WLAN_EID_TIM
, buf
+ 8 + 2 + 2,
947 if (tim
&& tim
[1] >= 2) {
948 ar
->assoc_bss_dtim_period
= tim
[3];
949 set_bit(DTIM_PERIOD_AVAIL
, &ar
->flag
);
954 * In theory, use of cfg80211_inform_bss() would be more natural here
955 * since we do not have the full frame. However, at least for now,
956 * cfg80211 can only distinguish Beacon and Probe Response frames from
957 * each other when using cfg80211_inform_bss_frame(), so let's build a
958 * fake IEEE 802.11 header to be able to take benefit of this.
960 mgmt
= kmalloc(24 + len
, GFP_ATOMIC
);
964 if (bih
->frame_type
== BEACON_FTYPE
) {
965 mgmt
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
966 IEEE80211_STYPE_BEACON
);
967 memset(mgmt
->da
, 0xff, ETH_ALEN
);
969 struct net_device
*dev
= ar
->net_dev
;
971 mgmt
->frame_control
= cpu_to_le16(IEEE80211_FTYPE_MGMT
|
972 IEEE80211_STYPE_PROBE_RESP
);
973 memcpy(mgmt
->da
, dev
->dev_addr
, ETH_ALEN
);
975 mgmt
->duration
= cpu_to_le16(0);
976 memcpy(mgmt
->sa
, bih
->bssid
, ETH_ALEN
);
977 memcpy(mgmt
->bssid
, bih
->bssid
, ETH_ALEN
);
978 mgmt
->seq_ctrl
= cpu_to_le16(0);
980 memcpy(&mgmt
->u
.beacon
, buf
, len
);
982 bss
= cfg80211_inform_bss_frame(ar
->wdev
->wiphy
, channel
, mgmt
,
983 24 + len
, (bih
->snr
- 95) * 100,
988 cfg80211_put_bss(bss
);
993 /* Inactivity timeout of a fatpipe(pstream) at the target */
994 static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi
*wmi
, u8
*datap
,
997 struct wmi_pstream_timeout_event
*ev
;
999 if (len
< sizeof(struct wmi_pstream_timeout_event
))
1002 ev
= (struct wmi_pstream_timeout_event
*) datap
;
1005 * When the pstream (fat pipe == AC) timesout, it means there were
1006 * no thinStreams within this pstream & it got implicitly created
1007 * due to data flow on this AC. We start the inactivity timer only
1008 * for implicitly created pstream. Just reset the host state.
1010 spin_lock_bh(&wmi
->lock
);
1011 wmi
->stream_exist_for_ac
[ev
->traffic_class
] = 0;
1012 wmi
->fat_pipe_exist
&= ~(1 << ev
->traffic_class
);
1013 spin_unlock_bh(&wmi
->lock
);
1015 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1016 ath6kl_indicate_tx_activity(wmi
->parent_dev
, ev
->traffic_class
, false);
1021 static int ath6kl_wmi_bitrate_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1023 struct wmi_bit_rate_reply
*reply
;
1027 if (len
< sizeof(struct wmi_bit_rate_reply
))
1030 reply
= (struct wmi_bit_rate_reply
*) datap
;
1032 ath6kl_dbg(ATH6KL_DBG_WMI
, "rateindex %d\n", reply
->rate_index
);
1034 if (reply
->rate_index
== (s8
) RATE_AUTO
) {
1037 index
= reply
->rate_index
& 0x7f;
1038 sgi
= (reply
->rate_index
& 0x80) ? 1 : 0;
1039 rate
= wmi_rate_tbl
[index
][sgi
];
1042 ath6kl_wakeup_event(wmi
->parent_dev
);
1047 static int ath6kl_wmi_tcmd_test_report_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1049 ath6kl_tm_rx_report_event(wmi
->parent_dev
, datap
, len
);
1054 static int ath6kl_wmi_ratemask_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1056 if (len
< sizeof(struct wmi_fix_rates_reply
))
1059 ath6kl_wakeup_event(wmi
->parent_dev
);
1064 static int ath6kl_wmi_ch_list_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1066 if (len
< sizeof(struct wmi_channel_list_reply
))
1069 ath6kl_wakeup_event(wmi
->parent_dev
);
1074 static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1076 struct wmi_tx_pwr_reply
*reply
;
1078 if (len
< sizeof(struct wmi_tx_pwr_reply
))
1081 reply
= (struct wmi_tx_pwr_reply
*) datap
;
1082 ath6kl_txpwr_rx_evt(wmi
->parent_dev
, reply
->dbM
);
1087 static int ath6kl_wmi_keepalive_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1089 if (len
< sizeof(struct wmi_get_keepalive_cmd
))
1092 ath6kl_wakeup_event(wmi
->parent_dev
);
1097 static int ath6kl_wmi_scan_complete_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1099 struct wmi_scan_complete_event
*ev
;
1101 ev
= (struct wmi_scan_complete_event
*) datap
;
1103 ath6kl_scan_complete_evt(wmi
->parent_dev
, a_sle32_to_cpu(ev
->status
));
1104 wmi
->is_probe_ssid
= false;
1109 static int ath6kl_wmi_neighbor_report_event_rx(struct wmi
*wmi
, u8
*datap
,
1112 struct wmi_neighbor_report_event
*ev
;
1115 if (len
< sizeof(*ev
))
1117 ev
= (struct wmi_neighbor_report_event
*) datap
;
1118 if (sizeof(*ev
) + ev
->num_neighbors
* sizeof(struct wmi_neighbor_info
)
1120 ath6kl_dbg(ATH6KL_DBG_WMI
, "truncated neighbor event "
1121 "(num=%d len=%d)\n", ev
->num_neighbors
, len
);
1124 for (i
= 0; i
< ev
->num_neighbors
; i
++) {
1125 ath6kl_dbg(ATH6KL_DBG_WMI
, "neighbor %d/%d - %pM 0x%x\n",
1126 i
+ 1, ev
->num_neighbors
, ev
->neighbor
[i
].bssid
,
1127 ev
->neighbor
[i
].bss_flags
);
1128 cfg80211_pmksa_candidate_notify(wmi
->parent_dev
->net_dev
, i
,
1129 ev
->neighbor
[i
].bssid
,
1130 !!(ev
->neighbor
[i
].bss_flags
&
1131 WMI_PREAUTH_CAPABLE_BSS
),
1139 * Target is reporting a programming error. This is for
1140 * developer aid only. Target only checks a few common violations
1141 * and it is responsibility of host to do all error checking.
1142 * Behavior of target after wmi error event is undefined.
1143 * A reset is recommended.
1145 static int ath6kl_wmi_error_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1147 const char *type
= "unknown error";
1148 struct wmi_cmd_error_event
*ev
;
1149 ev
= (struct wmi_cmd_error_event
*) datap
;
1151 switch (ev
->err_code
) {
1153 type
= "invalid parameter";
1156 type
= "invalid state";
1158 case INTERNAL_ERROR
:
1159 type
= "internal error";
1163 ath6kl_dbg(ATH6KL_DBG_WMI
, "programming error, cmd=%d %s\n",
1169 static int ath6kl_wmi_stats_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1171 ath6kl_tgt_stats_event(wmi
->parent_dev
, datap
, len
);
1176 static u8
ath6kl_wmi_get_upper_threshold(s16 rssi
,
1177 struct sq_threshold_params
*sq_thresh
,
1181 u8 threshold
= (u8
) sq_thresh
->upper_threshold
[size
- 1];
1183 /* The list is already in sorted order. Get the next lower value */
1184 for (index
= 0; index
< size
; index
++) {
1185 if (rssi
< sq_thresh
->upper_threshold
[index
]) {
1186 threshold
= (u8
) sq_thresh
->upper_threshold
[index
];
1194 static u8
ath6kl_wmi_get_lower_threshold(s16 rssi
,
1195 struct sq_threshold_params
*sq_thresh
,
1199 u8 threshold
= (u8
) sq_thresh
->lower_threshold
[size
- 1];
1201 /* The list is already in sorted order. Get the next lower value */
1202 for (index
= 0; index
< size
; index
++) {
1203 if (rssi
> sq_thresh
->lower_threshold
[index
]) {
1204 threshold
= (u8
) sq_thresh
->lower_threshold
[index
];
1212 static int ath6kl_wmi_send_rssi_threshold_params(struct wmi
*wmi
,
1213 struct wmi_rssi_threshold_params_cmd
*rssi_cmd
)
1215 struct sk_buff
*skb
;
1216 struct wmi_rssi_threshold_params_cmd
*cmd
;
1218 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1222 cmd
= (struct wmi_rssi_threshold_params_cmd
*) skb
->data
;
1223 memcpy(cmd
, rssi_cmd
, sizeof(struct wmi_rssi_threshold_params_cmd
));
1225 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RSSI_THRESHOLD_PARAMS_CMDID
,
1229 static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1232 struct wmi_rssi_threshold_event
*reply
;
1233 struct wmi_rssi_threshold_params_cmd cmd
;
1234 struct sq_threshold_params
*sq_thresh
;
1235 enum wmi_rssi_threshold_val new_threshold
;
1236 u8 upper_rssi_threshold
, lower_rssi_threshold
;
1240 if (len
< sizeof(struct wmi_rssi_threshold_event
))
1243 reply
= (struct wmi_rssi_threshold_event
*) datap
;
1244 new_threshold
= (enum wmi_rssi_threshold_val
) reply
->range
;
1245 rssi
= a_sle16_to_cpu(reply
->rssi
);
1247 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_RSSI
];
1250 * Identify the threshold breached and communicate that to the app.
1251 * After that install a new set of thresholds based on the signal
1252 * quality reported by the target
1254 if (new_threshold
) {
1255 /* Upper threshold breached */
1256 if (rssi
< sq_thresh
->upper_threshold
[0]) {
1257 ath6kl_dbg(ATH6KL_DBG_WMI
,
1258 "spurious upper rssi threshold event: %d\n",
1260 } else if ((rssi
< sq_thresh
->upper_threshold
[1]) &&
1261 (rssi
>= sq_thresh
->upper_threshold
[0])) {
1262 new_threshold
= WMI_RSSI_THRESHOLD1_ABOVE
;
1263 } else if ((rssi
< sq_thresh
->upper_threshold
[2]) &&
1264 (rssi
>= sq_thresh
->upper_threshold
[1])) {
1265 new_threshold
= WMI_RSSI_THRESHOLD2_ABOVE
;
1266 } else if ((rssi
< sq_thresh
->upper_threshold
[3]) &&
1267 (rssi
>= sq_thresh
->upper_threshold
[2])) {
1268 new_threshold
= WMI_RSSI_THRESHOLD3_ABOVE
;
1269 } else if ((rssi
< sq_thresh
->upper_threshold
[4]) &&
1270 (rssi
>= sq_thresh
->upper_threshold
[3])) {
1271 new_threshold
= WMI_RSSI_THRESHOLD4_ABOVE
;
1272 } else if ((rssi
< sq_thresh
->upper_threshold
[5]) &&
1273 (rssi
>= sq_thresh
->upper_threshold
[4])) {
1274 new_threshold
= WMI_RSSI_THRESHOLD5_ABOVE
;
1275 } else if (rssi
>= sq_thresh
->upper_threshold
[5]) {
1276 new_threshold
= WMI_RSSI_THRESHOLD6_ABOVE
;
1279 /* Lower threshold breached */
1280 if (rssi
> sq_thresh
->lower_threshold
[0]) {
1281 ath6kl_dbg(ATH6KL_DBG_WMI
,
1282 "spurious lower rssi threshold event: %d %d\n",
1283 rssi
, sq_thresh
->lower_threshold
[0]);
1284 } else if ((rssi
> sq_thresh
->lower_threshold
[1]) &&
1285 (rssi
<= sq_thresh
->lower_threshold
[0])) {
1286 new_threshold
= WMI_RSSI_THRESHOLD6_BELOW
;
1287 } else if ((rssi
> sq_thresh
->lower_threshold
[2]) &&
1288 (rssi
<= sq_thresh
->lower_threshold
[1])) {
1289 new_threshold
= WMI_RSSI_THRESHOLD5_BELOW
;
1290 } else if ((rssi
> sq_thresh
->lower_threshold
[3]) &&
1291 (rssi
<= sq_thresh
->lower_threshold
[2])) {
1292 new_threshold
= WMI_RSSI_THRESHOLD4_BELOW
;
1293 } else if ((rssi
> sq_thresh
->lower_threshold
[4]) &&
1294 (rssi
<= sq_thresh
->lower_threshold
[3])) {
1295 new_threshold
= WMI_RSSI_THRESHOLD3_BELOW
;
1296 } else if ((rssi
> sq_thresh
->lower_threshold
[5]) &&
1297 (rssi
<= sq_thresh
->lower_threshold
[4])) {
1298 new_threshold
= WMI_RSSI_THRESHOLD2_BELOW
;
1299 } else if (rssi
<= sq_thresh
->lower_threshold
[5]) {
1300 new_threshold
= WMI_RSSI_THRESHOLD1_BELOW
;
1304 /* Calculate and install the next set of thresholds */
1305 lower_rssi_threshold
= ath6kl_wmi_get_lower_threshold(rssi
, sq_thresh
,
1306 sq_thresh
->lower_threshold_valid_count
);
1307 upper_rssi_threshold
= ath6kl_wmi_get_upper_threshold(rssi
, sq_thresh
,
1308 sq_thresh
->upper_threshold_valid_count
);
1310 /* Issue a wmi command to install the thresholds */
1311 cmd
.thresh_above1_val
= a_cpu_to_sle16(upper_rssi_threshold
);
1312 cmd
.thresh_below1_val
= a_cpu_to_sle16(lower_rssi_threshold
);
1313 cmd
.weight
= sq_thresh
->weight
;
1314 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1316 ret
= ath6kl_wmi_send_rssi_threshold_params(wmi
, &cmd
);
1318 ath6kl_err("unable to configure rssi thresholds\n");
1325 static int ath6kl_wmi_cac_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1327 struct wmi_cac_event
*reply
;
1328 struct ieee80211_tspec_ie
*ts
;
1329 u16 active_tsids
, tsinfo
;
1333 if (len
< sizeof(struct wmi_cac_event
))
1336 reply
= (struct wmi_cac_event
*) datap
;
1338 if ((reply
->cac_indication
== CAC_INDICATION_ADMISSION_RESP
) &&
1339 (reply
->status_code
!= IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED
)) {
1341 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1342 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1343 tsid
= (tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1344 IEEE80211_WMM_IE_TSPEC_TID_MASK
;
1346 ath6kl_wmi_delete_pstream_cmd(wmi
, reply
->ac
, tsid
);
1347 } else if (reply
->cac_indication
== CAC_INDICATION_NO_RESP
) {
1349 * Following assumes that there is only one outstanding
1350 * ADDTS request when this event is received
1352 spin_lock_bh(&wmi
->lock
);
1353 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1354 spin_unlock_bh(&wmi
->lock
);
1356 for (index
= 0; index
< sizeof(active_tsids
) * 8; index
++) {
1357 if ((active_tsids
>> index
) & 1)
1360 if (index
< (sizeof(active_tsids
) * 8))
1361 ath6kl_wmi_delete_pstream_cmd(wmi
, reply
->ac
, index
);
1365 * Clear active tsids and Add missing handling
1366 * for delete qos stream from AP
1368 else if (reply
->cac_indication
== CAC_INDICATION_DELETE
) {
1370 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1371 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1372 ts_id
= ((tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1373 IEEE80211_WMM_IE_TSPEC_TID_MASK
);
1375 spin_lock_bh(&wmi
->lock
);
1376 wmi
->stream_exist_for_ac
[reply
->ac
] &= ~(1 << ts_id
);
1377 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1378 spin_unlock_bh(&wmi
->lock
);
1380 /* Indicate stream inactivity to driver layer only if all tsids
1381 * within this AC are deleted.
1383 if (!active_tsids
) {
1384 ath6kl_indicate_tx_activity(wmi
->parent_dev
, reply
->ac
,
1386 wmi
->fat_pipe_exist
&= ~(1 << reply
->ac
);
1393 static int ath6kl_wmi_send_snr_threshold_params(struct wmi
*wmi
,
1394 struct wmi_snr_threshold_params_cmd
*snr_cmd
)
1396 struct sk_buff
*skb
;
1397 struct wmi_snr_threshold_params_cmd
*cmd
;
1399 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1403 cmd
= (struct wmi_snr_threshold_params_cmd
*) skb
->data
;
1404 memcpy(cmd
, snr_cmd
, sizeof(struct wmi_snr_threshold_params_cmd
));
1406 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SNR_THRESHOLD_PARAMS_CMDID
,
1410 static int ath6kl_wmi_snr_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1413 struct wmi_snr_threshold_event
*reply
;
1414 struct sq_threshold_params
*sq_thresh
;
1415 struct wmi_snr_threshold_params_cmd cmd
;
1416 enum wmi_snr_threshold_val new_threshold
;
1417 u8 upper_snr_threshold
, lower_snr_threshold
;
1421 if (len
< sizeof(struct wmi_snr_threshold_event
))
1424 reply
= (struct wmi_snr_threshold_event
*) datap
;
1426 new_threshold
= (enum wmi_snr_threshold_val
) reply
->range
;
1429 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_SNR
];
1432 * Identify the threshold breached and communicate that to the app.
1433 * After that install a new set of thresholds based on the signal
1434 * quality reported by the target.
1436 if (new_threshold
) {
1437 /* Upper threshold breached */
1438 if (snr
< sq_thresh
->upper_threshold
[0]) {
1439 ath6kl_dbg(ATH6KL_DBG_WMI
,
1440 "spurious upper snr threshold event: %d\n",
1442 } else if ((snr
< sq_thresh
->upper_threshold
[1]) &&
1443 (snr
>= sq_thresh
->upper_threshold
[0])) {
1444 new_threshold
= WMI_SNR_THRESHOLD1_ABOVE
;
1445 } else if ((snr
< sq_thresh
->upper_threshold
[2]) &&
1446 (snr
>= sq_thresh
->upper_threshold
[1])) {
1447 new_threshold
= WMI_SNR_THRESHOLD2_ABOVE
;
1448 } else if ((snr
< sq_thresh
->upper_threshold
[3]) &&
1449 (snr
>= sq_thresh
->upper_threshold
[2])) {
1450 new_threshold
= WMI_SNR_THRESHOLD3_ABOVE
;
1451 } else if (snr
>= sq_thresh
->upper_threshold
[3]) {
1452 new_threshold
= WMI_SNR_THRESHOLD4_ABOVE
;
1455 /* Lower threshold breached */
1456 if (snr
> sq_thresh
->lower_threshold
[0]) {
1457 ath6kl_dbg(ATH6KL_DBG_WMI
,
1458 "spurious lower snr threshold event: %d\n",
1459 sq_thresh
->lower_threshold
[0]);
1460 } else if ((snr
> sq_thresh
->lower_threshold
[1]) &&
1461 (snr
<= sq_thresh
->lower_threshold
[0])) {
1462 new_threshold
= WMI_SNR_THRESHOLD4_BELOW
;
1463 } else if ((snr
> sq_thresh
->lower_threshold
[2]) &&
1464 (snr
<= sq_thresh
->lower_threshold
[1])) {
1465 new_threshold
= WMI_SNR_THRESHOLD3_BELOW
;
1466 } else if ((snr
> sq_thresh
->lower_threshold
[3]) &&
1467 (snr
<= sq_thresh
->lower_threshold
[2])) {
1468 new_threshold
= WMI_SNR_THRESHOLD2_BELOW
;
1469 } else if (snr
<= sq_thresh
->lower_threshold
[3]) {
1470 new_threshold
= WMI_SNR_THRESHOLD1_BELOW
;
1474 /* Calculate and install the next set of thresholds */
1475 lower_snr_threshold
= ath6kl_wmi_get_lower_threshold(snr
, sq_thresh
,
1476 sq_thresh
->lower_threshold_valid_count
);
1477 upper_snr_threshold
= ath6kl_wmi_get_upper_threshold(snr
, sq_thresh
,
1478 sq_thresh
->upper_threshold_valid_count
);
1480 /* Issue a wmi command to install the thresholds */
1481 cmd
.thresh_above1_val
= upper_snr_threshold
;
1482 cmd
.thresh_below1_val
= lower_snr_threshold
;
1483 cmd
.weight
= sq_thresh
->weight
;
1484 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1486 ath6kl_dbg(ATH6KL_DBG_WMI
,
1487 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1489 lower_snr_threshold
, upper_snr_threshold
);
1491 ret
= ath6kl_wmi_send_snr_threshold_params(wmi
, &cmd
);
1493 ath6kl_err("unable to configure snr threshold\n");
1500 static int ath6kl_wmi_aplist_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1502 u16 ap_info_entry_size
;
1503 struct wmi_aplist_event
*ev
= (struct wmi_aplist_event
*) datap
;
1504 struct wmi_ap_info_v1
*ap_info_v1
;
1507 if (len
< sizeof(struct wmi_aplist_event
) ||
1508 ev
->ap_list_ver
!= APLIST_VER1
)
1511 ap_info_entry_size
= sizeof(struct wmi_ap_info_v1
);
1512 ap_info_v1
= (struct wmi_ap_info_v1
*) ev
->ap_list
;
1514 ath6kl_dbg(ATH6KL_DBG_WMI
,
1515 "number of APs in aplist event: %d\n", ev
->num_ap
);
1517 if (len
< (int) (sizeof(struct wmi_aplist_event
) +
1518 (ev
->num_ap
- 1) * ap_info_entry_size
))
1521 /* AP list version 1 contents */
1522 for (index
= 0; index
< ev
->num_ap
; index
++) {
1523 ath6kl_dbg(ATH6KL_DBG_WMI
, "AP#%d BSSID %pM Channel %d\n",
1524 index
, ap_info_v1
->bssid
, ap_info_v1
->channel
);
1531 int ath6kl_wmi_cmd_send(struct wmi
*wmi
, struct sk_buff
*skb
,
1532 enum wmi_cmd_id cmd_id
, enum wmi_sync_flag sync_flag
)
1534 struct wmi_cmd_hdr
*cmd_hdr
;
1535 enum htc_endpoint_id ep_id
= wmi
->ep_id
;
1538 if (WARN_ON(skb
== NULL
))
1541 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi tx id %d len %d flag %d\n",
1542 cmd_id
, skb
->len
, sync_flag
);
1543 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP
, NULL
, "wmi tx ",
1544 skb
->data
, skb
->len
);
1546 if (sync_flag
>= END_WMIFLAG
) {
1551 if ((sync_flag
== SYNC_BEFORE_WMIFLAG
) ||
1552 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1554 * Make sure all data currently queued is transmitted before
1555 * the cmd execution. Establish a new sync point.
1557 ath6kl_wmi_sync_point(wmi
);
1560 skb_push(skb
, sizeof(struct wmi_cmd_hdr
));
1562 cmd_hdr
= (struct wmi_cmd_hdr
*) skb
->data
;
1563 cmd_hdr
->cmd_id
= cpu_to_le16(cmd_id
);
1564 cmd_hdr
->info1
= 0; /* added for virtual interface */
1566 /* Only for OPT_TX_CMD, use BE endpoint. */
1567 if (cmd_id
== WMI_OPT_TX_FRAME_CMDID
) {
1568 ret
= ath6kl_wmi_data_hdr_add(wmi
, skb
, OPT_MSGTYPE
,
1569 false, false, 0, NULL
);
1574 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
, WMM_AC_BE
);
1577 ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
1579 if ((sync_flag
== SYNC_AFTER_WMIFLAG
) ||
1580 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1582 * Make sure all new data queued waits for the command to
1583 * execute. Establish a new sync point.
1585 ath6kl_wmi_sync_point(wmi
);
1591 int ath6kl_wmi_connect_cmd(struct wmi
*wmi
, enum network_type nw_type
,
1592 enum dot11_auth_mode dot11_auth_mode
,
1593 enum auth_mode auth_mode
,
1594 enum crypto_type pairwise_crypto
,
1595 u8 pairwise_crypto_len
,
1596 enum crypto_type group_crypto
,
1597 u8 group_crypto_len
, int ssid_len
, u8
*ssid
,
1598 u8
*bssid
, u16 channel
, u32 ctrl_flags
)
1600 struct sk_buff
*skb
;
1601 struct wmi_connect_cmd
*cc
;
1604 ath6kl_dbg(ATH6KL_DBG_WMI
,
1605 "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d "
1606 "type %d dot11_auth %d auth %d pairwise %d group %d\n",
1607 bssid
, channel
, ctrl_flags
, ssid_len
, nw_type
,
1608 dot11_auth_mode
, auth_mode
, pairwise_crypto
, group_crypto
);
1609 ath6kl_dbg_dump(ATH6KL_DBG_WMI
, NULL
, "ssid ", ssid
, ssid_len
);
1611 wmi
->traffic_class
= 100;
1613 if ((pairwise_crypto
== NONE_CRYPT
) && (group_crypto
!= NONE_CRYPT
))
1616 if ((pairwise_crypto
!= NONE_CRYPT
) && (group_crypto
== NONE_CRYPT
))
1619 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd
));
1623 cc
= (struct wmi_connect_cmd
*) skb
->data
;
1626 memcpy(cc
->ssid
, ssid
, ssid_len
);
1628 cc
->ssid_len
= ssid_len
;
1629 cc
->nw_type
= nw_type
;
1630 cc
->dot11_auth_mode
= dot11_auth_mode
;
1631 cc
->auth_mode
= auth_mode
;
1632 cc
->prwise_crypto_type
= pairwise_crypto
;
1633 cc
->prwise_crypto_len
= pairwise_crypto_len
;
1634 cc
->grp_crypto_type
= group_crypto
;
1635 cc
->grp_crypto_len
= group_crypto_len
;
1636 cc
->ch
= cpu_to_le16(channel
);
1637 cc
->ctrl_flags
= cpu_to_le32(ctrl_flags
);
1640 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1642 wmi
->pair_crypto_type
= pairwise_crypto
;
1643 wmi
->grp_crypto_type
= group_crypto
;
1645 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_CONNECT_CMDID
, NO_SYNC_WMIFLAG
);
1650 int ath6kl_wmi_reconnect_cmd(struct wmi
*wmi
, u8
*bssid
, u16 channel
)
1652 struct sk_buff
*skb
;
1653 struct wmi_reconnect_cmd
*cc
;
1656 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi reconnect bssid %pM freq %d\n",
1659 wmi
->traffic_class
= 100;
1661 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd
));
1665 cc
= (struct wmi_reconnect_cmd
*) skb
->data
;
1666 cc
->channel
= cpu_to_le16(channel
);
1669 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1671 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RECONNECT_CMDID
,
1677 int ath6kl_wmi_disconnect_cmd(struct wmi
*wmi
)
1681 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi disconnect\n");
1683 wmi
->traffic_class
= 100;
1685 /* Disconnect command does not need to do a SYNC before. */
1686 ret
= ath6kl_wmi_simple_cmd(wmi
, WMI_DISCONNECT_CMDID
);
1691 int ath6kl_wmi_startscan_cmd(struct wmi
*wmi
, enum wmi_scan_type scan_type
,
1692 u32 force_fgscan
, u32 is_legacy
,
1693 u32 home_dwell_time
, u32 force_scan_interval
,
1694 s8 num_chan
, u16
*ch_list
)
1696 struct sk_buff
*skb
;
1697 struct wmi_start_scan_cmd
*sc
;
1701 size
= sizeof(struct wmi_start_scan_cmd
);
1703 if ((scan_type
!= WMI_LONG_SCAN
) && (scan_type
!= WMI_SHORT_SCAN
))
1706 if (num_chan
> WMI_MAX_CHANNELS
)
1710 size
+= sizeof(u16
) * (num_chan
- 1);
1712 skb
= ath6kl_wmi_get_new_buf(size
);
1716 sc
= (struct wmi_start_scan_cmd
*) skb
->data
;
1717 sc
->scan_type
= scan_type
;
1718 sc
->force_fg_scan
= cpu_to_le32(force_fgscan
);
1719 sc
->is_legacy
= cpu_to_le32(is_legacy
);
1720 sc
->home_dwell_time
= cpu_to_le32(home_dwell_time
);
1721 sc
->force_scan_intvl
= cpu_to_le32(force_scan_interval
);
1722 sc
->num_ch
= num_chan
;
1724 for (i
= 0; i
< num_chan
; i
++)
1725 sc
->ch_list
[i
] = cpu_to_le16(ch_list
[i
]);
1727 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_START_SCAN_CMDID
,
1733 int ath6kl_wmi_scanparams_cmd(struct wmi
*wmi
, u16 fg_start_sec
,
1734 u16 fg_end_sec
, u16 bg_sec
,
1735 u16 minact_chdw_msec
, u16 maxact_chdw_msec
,
1736 u16 pas_chdw_msec
, u8 short_scan_ratio
,
1737 u8 scan_ctrl_flag
, u32 max_dfsch_act_time
,
1738 u16 maxact_scan_per_ssid
)
1740 struct sk_buff
*skb
;
1741 struct wmi_scan_params_cmd
*sc
;
1744 skb
= ath6kl_wmi_get_new_buf(sizeof(*sc
));
1748 sc
= (struct wmi_scan_params_cmd
*) skb
->data
;
1749 sc
->fg_start_period
= cpu_to_le16(fg_start_sec
);
1750 sc
->fg_end_period
= cpu_to_le16(fg_end_sec
);
1751 sc
->bg_period
= cpu_to_le16(bg_sec
);
1752 sc
->minact_chdwell_time
= cpu_to_le16(minact_chdw_msec
);
1753 sc
->maxact_chdwell_time
= cpu_to_le16(maxact_chdw_msec
);
1754 sc
->pas_chdwell_time
= cpu_to_le16(pas_chdw_msec
);
1755 sc
->short_scan_ratio
= short_scan_ratio
;
1756 sc
->scan_ctrl_flags
= scan_ctrl_flag
;
1757 sc
->max_dfsch_act_time
= cpu_to_le32(max_dfsch_act_time
);
1758 sc
->maxact_scan_per_ssid
= cpu_to_le16(maxact_scan_per_ssid
);
1760 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_SCAN_PARAMS_CMDID
,
1765 int ath6kl_wmi_bssfilter_cmd(struct wmi
*wmi
, u8 filter
, u32 ie_mask
)
1767 struct sk_buff
*skb
;
1768 struct wmi_bss_filter_cmd
*cmd
;
1771 if (filter
>= LAST_BSS_FILTER
)
1774 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1778 cmd
= (struct wmi_bss_filter_cmd
*) skb
->data
;
1779 cmd
->bss_filter
= filter
;
1780 cmd
->ie_mask
= cpu_to_le32(ie_mask
);
1782 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_BSS_FILTER_CMDID
,
1787 int ath6kl_wmi_probedssid_cmd(struct wmi
*wmi
, u8 index
, u8 flag
,
1788 u8 ssid_len
, u8
*ssid
)
1790 struct sk_buff
*skb
;
1791 struct wmi_probed_ssid_cmd
*cmd
;
1794 if (index
> MAX_PROBED_SSID_INDEX
)
1797 if (ssid_len
> sizeof(cmd
->ssid
))
1800 if ((flag
& (DISABLE_SSID_FLAG
| ANY_SSID_FLAG
)) && (ssid_len
> 0))
1803 if ((flag
& SPECIFIC_SSID_FLAG
) && !ssid_len
)
1806 if (flag
& SPECIFIC_SSID_FLAG
)
1807 wmi
->is_probe_ssid
= true;
1809 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1813 cmd
= (struct wmi_probed_ssid_cmd
*) skb
->data
;
1814 cmd
->entry_index
= index
;
1816 cmd
->ssid_len
= ssid_len
;
1817 memcpy(cmd
->ssid
, ssid
, ssid_len
);
1819 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_PROBED_SSID_CMDID
,
1824 int ath6kl_wmi_listeninterval_cmd(struct wmi
*wmi
, u16 listen_interval
,
1827 struct sk_buff
*skb
;
1828 struct wmi_listen_int_cmd
*cmd
;
1831 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1835 cmd
= (struct wmi_listen_int_cmd
*) skb
->data
;
1836 cmd
->listen_intvl
= cpu_to_le16(listen_interval
);
1837 cmd
->num_beacons
= cpu_to_le16(listen_beacons
);
1839 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_LISTEN_INT_CMDID
,
1844 int ath6kl_wmi_powermode_cmd(struct wmi
*wmi
, u8 pwr_mode
)
1846 struct sk_buff
*skb
;
1847 struct wmi_power_mode_cmd
*cmd
;
1850 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1854 cmd
= (struct wmi_power_mode_cmd
*) skb
->data
;
1855 cmd
->pwr_mode
= pwr_mode
;
1856 wmi
->pwr_mode
= pwr_mode
;
1858 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_POWER_MODE_CMDID
,
1863 int ath6kl_wmi_pmparams_cmd(struct wmi
*wmi
, u16 idle_period
,
1864 u16 ps_poll_num
, u16 dtim_policy
,
1865 u16 tx_wakeup_policy
, u16 num_tx_to_wakeup
,
1866 u16 ps_fail_event_policy
)
1868 struct sk_buff
*skb
;
1869 struct wmi_power_params_cmd
*pm
;
1872 skb
= ath6kl_wmi_get_new_buf(sizeof(*pm
));
1876 pm
= (struct wmi_power_params_cmd
*)skb
->data
;
1877 pm
->idle_period
= cpu_to_le16(idle_period
);
1878 pm
->pspoll_number
= cpu_to_le16(ps_poll_num
);
1879 pm
->dtim_policy
= cpu_to_le16(dtim_policy
);
1880 pm
->tx_wakeup_policy
= cpu_to_le16(tx_wakeup_policy
);
1881 pm
->num_tx_to_wakeup
= cpu_to_le16(num_tx_to_wakeup
);
1882 pm
->ps_fail_event_policy
= cpu_to_le16(ps_fail_event_policy
);
1884 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_POWER_PARAMS_CMDID
,
1889 int ath6kl_wmi_disctimeout_cmd(struct wmi
*wmi
, u8 timeout
)
1891 struct sk_buff
*skb
;
1892 struct wmi_disc_timeout_cmd
*cmd
;
1895 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1899 cmd
= (struct wmi_disc_timeout_cmd
*) skb
->data
;
1900 cmd
->discon_timeout
= timeout
;
1902 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_DISC_TIMEOUT_CMDID
,
1907 int ath6kl_wmi_addkey_cmd(struct wmi
*wmi
, u8 key_index
,
1908 enum crypto_type key_type
,
1909 u8 key_usage
, u8 key_len
,
1910 u8
*key_rsc
, u8
*key_material
,
1911 u8 key_op_ctrl
, u8
*mac_addr
,
1912 enum wmi_sync_flag sync_flag
)
1914 struct sk_buff
*skb
;
1915 struct wmi_add_cipher_key_cmd
*cmd
;
1918 ath6kl_dbg(ATH6KL_DBG_WMI
, "addkey cmd: key_index=%u key_type=%d "
1919 "key_usage=%d key_len=%d key_op_ctrl=%d\n",
1920 key_index
, key_type
, key_usage
, key_len
, key_op_ctrl
);
1922 if ((key_index
> WMI_MAX_KEY_INDEX
) || (key_len
> WMI_MAX_KEY_LEN
) ||
1923 (key_material
== NULL
))
1926 if ((WEP_CRYPT
!= key_type
) && (NULL
== key_rsc
))
1929 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1933 cmd
= (struct wmi_add_cipher_key_cmd
*) skb
->data
;
1934 cmd
->key_index
= key_index
;
1935 cmd
->key_type
= key_type
;
1936 cmd
->key_usage
= key_usage
;
1937 cmd
->key_len
= key_len
;
1938 memcpy(cmd
->key
, key_material
, key_len
);
1940 if (key_rsc
!= NULL
)
1941 memcpy(cmd
->key_rsc
, key_rsc
, sizeof(cmd
->key_rsc
));
1943 cmd
->key_op_ctrl
= key_op_ctrl
;
1946 memcpy(cmd
->key_mac_addr
, mac_addr
, ETH_ALEN
);
1948 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_ADD_CIPHER_KEY_CMDID
,
1954 int ath6kl_wmi_add_krk_cmd(struct wmi
*wmi
, u8
*krk
)
1956 struct sk_buff
*skb
;
1957 struct wmi_add_krk_cmd
*cmd
;
1960 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1964 cmd
= (struct wmi_add_krk_cmd
*) skb
->data
;
1965 memcpy(cmd
->krk
, krk
, WMI_KRK_LEN
);
1967 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_ADD_KRK_CMDID
, NO_SYNC_WMIFLAG
);
1972 int ath6kl_wmi_deletekey_cmd(struct wmi
*wmi
, u8 key_index
)
1974 struct sk_buff
*skb
;
1975 struct wmi_delete_cipher_key_cmd
*cmd
;
1978 if (key_index
> WMI_MAX_KEY_INDEX
)
1981 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1985 cmd
= (struct wmi_delete_cipher_key_cmd
*) skb
->data
;
1986 cmd
->key_index
= key_index
;
1988 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DELETE_CIPHER_KEY_CMDID
,
1994 int ath6kl_wmi_setpmkid_cmd(struct wmi
*wmi
, const u8
*bssid
,
1995 const u8
*pmkid
, bool set
)
1997 struct sk_buff
*skb
;
1998 struct wmi_setpmkid_cmd
*cmd
;
2004 if (set
&& pmkid
== NULL
)
2007 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2011 cmd
= (struct wmi_setpmkid_cmd
*) skb
->data
;
2012 memcpy(cmd
->bssid
, bssid
, ETH_ALEN
);
2014 memcpy(cmd
->pmkid
, pmkid
, sizeof(cmd
->pmkid
));
2015 cmd
->enable
= PMKID_ENABLE
;
2017 memset(cmd
->pmkid
, 0, sizeof(cmd
->pmkid
));
2018 cmd
->enable
= PMKID_DISABLE
;
2021 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_PMKID_CMDID
,
2027 static int ath6kl_wmi_data_sync_send(struct wmi
*wmi
, struct sk_buff
*skb
,
2028 enum htc_endpoint_id ep_id
)
2030 struct wmi_data_hdr
*data_hdr
;
2033 if (WARN_ON(skb
== NULL
|| ep_id
== wmi
->ep_id
))
2036 skb_push(skb
, sizeof(struct wmi_data_hdr
));
2038 data_hdr
= (struct wmi_data_hdr
*) skb
->data
;
2039 data_hdr
->info
= SYNC_MSGTYPE
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
2040 data_hdr
->info3
= 0;
2042 ret
= ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
2047 static int ath6kl_wmi_sync_point(struct wmi
*wmi
)
2049 struct sk_buff
*skb
;
2050 struct wmi_sync_cmd
*cmd
;
2051 struct wmi_data_sync_bufs data_sync_bufs
[WMM_NUM_AC
];
2052 enum htc_endpoint_id ep_id
;
2053 u8 index
, num_pri_streams
= 0;
2056 memset(data_sync_bufs
, 0, sizeof(data_sync_bufs
));
2058 spin_lock_bh(&wmi
->lock
);
2060 for (index
= 0; index
< WMM_NUM_AC
; index
++) {
2061 if (wmi
->fat_pipe_exist
& (1 << index
)) {
2063 data_sync_bufs
[num_pri_streams
- 1].traffic_class
=
2068 spin_unlock_bh(&wmi
->lock
);
2070 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2076 cmd
= (struct wmi_sync_cmd
*) skb
->data
;
2079 * In the SYNC cmd sent on the control Ep, send a bitmap
2080 * of the data eps on which the Data Sync will be sent
2082 cmd
->data_sync_map
= wmi
->fat_pipe_exist
;
2084 for (index
= 0; index
< num_pri_streams
; index
++) {
2085 data_sync_bufs
[index
].skb
= ath6kl_buf_alloc(0);
2086 if (data_sync_bufs
[index
].skb
== NULL
) {
2093 * If buffer allocation for any of the dataSync fails,
2094 * then do not send the Synchronize cmd on the control ep
2100 * Send sync cmd followed by sync data messages on all
2101 * endpoints being used
2103 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SYNCHRONIZE_CMDID
,
2109 /* cmd buffer sent, we no longer own it */
2112 for (index
= 0; index
< num_pri_streams
; index
++) {
2114 if (WARN_ON(!data_sync_bufs
[index
].skb
))
2117 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
,
2118 data_sync_bufs
[index
].
2121 ath6kl_wmi_data_sync_send(wmi
, data_sync_bufs
[index
].skb
,
2127 data_sync_bufs
[index
].skb
= NULL
;
2131 /* free up any resources left over (possibly due to an error) */
2135 for (index
= 0; index
< num_pri_streams
; index
++) {
2136 if (data_sync_bufs
[index
].skb
!= NULL
) {
2137 dev_kfree_skb((struct sk_buff
*)data_sync_bufs
[index
].
2145 int ath6kl_wmi_create_pstream_cmd(struct wmi
*wmi
,
2146 struct wmi_create_pstream_cmd
*params
)
2148 struct sk_buff
*skb
;
2149 struct wmi_create_pstream_cmd
*cmd
;
2150 u8 fatpipe_exist_for_ac
= 0;
2152 s32 nominal_phy
= 0;
2155 if (!((params
->user_pri
< 8) &&
2156 (params
->user_pri
<= 0x7) &&
2157 (up_to_ac
[params
->user_pri
& 0x7] == params
->traffic_class
) &&
2158 (params
->traffic_direc
== UPLINK_TRAFFIC
||
2159 params
->traffic_direc
== DNLINK_TRAFFIC
||
2160 params
->traffic_direc
== BIDIR_TRAFFIC
) &&
2161 (params
->traffic_type
== TRAFFIC_TYPE_APERIODIC
||
2162 params
->traffic_type
== TRAFFIC_TYPE_PERIODIC
) &&
2163 (params
->voice_psc_cap
== DISABLE_FOR_THIS_AC
||
2164 params
->voice_psc_cap
== ENABLE_FOR_THIS_AC
||
2165 params
->voice_psc_cap
== ENABLE_FOR_ALL_AC
) &&
2166 (params
->tsid
== WMI_IMPLICIT_PSTREAM
||
2167 params
->tsid
<= WMI_MAX_THINSTREAM
))) {
2172 * Check nominal PHY rate is >= minimalPHY,
2173 * so that DUT can allow TSRS IE
2176 /* Get the physical rate (units of bps) */
2177 min_phy
= ((le32_to_cpu(params
->min_phy_rate
) / 1000) / 1000);
2179 /* Check minimal phy < nominal phy rate */
2180 if (params
->nominal_phy
>= min_phy
) {
2181 /* unit of 500 kbps */
2182 nominal_phy
= (params
->nominal_phy
* 1000) / 500;
2183 ath6kl_dbg(ATH6KL_DBG_WMI
,
2184 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2185 min_phy
, nominal_phy
);
2187 params
->nominal_phy
= nominal_phy
;
2189 params
->nominal_phy
= 0;
2192 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2196 ath6kl_dbg(ATH6KL_DBG_WMI
,
2197 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2198 params
->traffic_class
, params
->tsid
);
2200 cmd
= (struct wmi_create_pstream_cmd
*) skb
->data
;
2201 memcpy(cmd
, params
, sizeof(*cmd
));
2203 /* This is an implicitly created Fat pipe */
2204 if ((u32
) params
->tsid
== (u32
) WMI_IMPLICIT_PSTREAM
) {
2205 spin_lock_bh(&wmi
->lock
);
2206 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2207 (1 << params
->traffic_class
));
2208 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2209 spin_unlock_bh(&wmi
->lock
);
2211 /* explicitly created thin stream within a fat pipe */
2212 spin_lock_bh(&wmi
->lock
);
2213 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2214 (1 << params
->traffic_class
));
2215 wmi
->stream_exist_for_ac
[params
->traffic_class
] |=
2216 (1 << params
->tsid
);
2218 * If a thinstream becomes active, the fat pipe automatically
2221 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2222 spin_unlock_bh(&wmi
->lock
);
2226 * Indicate activty change to driver layer only if this is the
2227 * first TSID to get created in this AC explicitly or an implicit
2228 * fat pipe is getting created.
2230 if (!fatpipe_exist_for_ac
)
2231 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2232 params
->traffic_class
, true);
2234 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_CREATE_PSTREAM_CMDID
,
2239 int ath6kl_wmi_delete_pstream_cmd(struct wmi
*wmi
, u8 traffic_class
, u8 tsid
)
2241 struct sk_buff
*skb
;
2242 struct wmi_delete_pstream_cmd
*cmd
;
2243 u16 active_tsids
= 0;
2246 if (traffic_class
> 3) {
2247 ath6kl_err("invalid traffic class: %d\n", traffic_class
);
2251 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2255 cmd
= (struct wmi_delete_pstream_cmd
*) skb
->data
;
2256 cmd
->traffic_class
= traffic_class
;
2259 spin_lock_bh(&wmi
->lock
);
2260 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2261 spin_unlock_bh(&wmi
->lock
);
2263 if (!(active_tsids
& (1 << tsid
))) {
2265 ath6kl_dbg(ATH6KL_DBG_WMI
,
2266 "TSID %d doesn't exist for traffic class: %d\n",
2267 tsid
, traffic_class
);
2271 ath6kl_dbg(ATH6KL_DBG_WMI
,
2272 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2273 traffic_class
, tsid
);
2275 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DELETE_PSTREAM_CMDID
,
2276 SYNC_BEFORE_WMIFLAG
);
2278 spin_lock_bh(&wmi
->lock
);
2279 wmi
->stream_exist_for_ac
[traffic_class
] &= ~(1 << tsid
);
2280 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2281 spin_unlock_bh(&wmi
->lock
);
2284 * Indicate stream inactivity to driver layer only if all tsids
2285 * within this AC are deleted.
2287 if (!active_tsids
) {
2288 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2289 traffic_class
, false);
2290 wmi
->fat_pipe_exist
&= ~(1 << traffic_class
);
2296 int ath6kl_wmi_set_ip_cmd(struct wmi
*wmi
, struct wmi_set_ip_cmd
*ip_cmd
)
2298 struct sk_buff
*skb
;
2299 struct wmi_set_ip_cmd
*cmd
;
2302 /* Multicast address are not valid */
2303 if ((*((u8
*) &ip_cmd
->ips
[0]) >= 0xE0) ||
2304 (*((u8
*) &ip_cmd
->ips
[1]) >= 0xE0))
2307 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd
));
2311 cmd
= (struct wmi_set_ip_cmd
*) skb
->data
;
2312 memcpy(cmd
, ip_cmd
, sizeof(struct wmi_set_ip_cmd
));
2314 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_IP_CMDID
, NO_SYNC_WMIFLAG
);
2318 static int ath6kl_wmi_get_wow_list_event_rx(struct wmi
*wmi
, u8
* datap
,
2321 if (len
< sizeof(struct wmi_get_wow_list_reply
))
2327 static int ath6kl_wmi_cmd_send_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
,
2328 enum wmix_command_id cmd_id
,
2329 enum wmi_sync_flag sync_flag
)
2331 struct wmix_cmd_hdr
*cmd_hdr
;
2334 skb_push(skb
, sizeof(struct wmix_cmd_hdr
));
2336 cmd_hdr
= (struct wmix_cmd_hdr
*) skb
->data
;
2337 cmd_hdr
->cmd_id
= cpu_to_le32(cmd_id
);
2339 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_EXTENSION_CMDID
, sync_flag
);
2344 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi
*wmi
, u32 cookie
, u32 source
)
2346 struct sk_buff
*skb
;
2347 struct wmix_hb_challenge_resp_cmd
*cmd
;
2350 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2354 cmd
= (struct wmix_hb_challenge_resp_cmd
*) skb
->data
;
2355 cmd
->cookie
= cpu_to_le32(cookie
);
2356 cmd
->source
= cpu_to_le32(source
);
2358 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_HB_CHALLENGE_RESP_CMDID
,
2363 int ath6kl_wmi_config_debug_module_cmd(struct wmi
*wmi
, u32 valid
, u32 config
)
2365 struct ath6kl_wmix_dbglog_cfg_module_cmd
*cmd
;
2366 struct sk_buff
*skb
;
2369 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2373 cmd
= (struct ath6kl_wmix_dbglog_cfg_module_cmd
*) skb
->data
;
2374 cmd
->valid
= cpu_to_le32(valid
);
2375 cmd
->config
= cpu_to_le32(config
);
2377 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_DBGLOG_CFG_MODULE_CMDID
,
2382 int ath6kl_wmi_get_stats_cmd(struct wmi
*wmi
)
2384 return ath6kl_wmi_simple_cmd(wmi
, WMI_GET_STATISTICS_CMDID
);
2387 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi
*wmi
, u8 dbM
)
2389 struct sk_buff
*skb
;
2390 struct wmi_set_tx_pwr_cmd
*cmd
;
2393 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd
));
2397 cmd
= (struct wmi_set_tx_pwr_cmd
*) skb
->data
;
2400 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_TX_PWR_CMDID
,
2406 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi
*wmi
)
2408 return ath6kl_wmi_simple_cmd(wmi
, WMI_GET_TX_PWR_CMDID
);
2411 int ath6kl_wmi_set_lpreamble_cmd(struct wmi
*wmi
, u8 status
, u8 preamble_policy
)
2413 struct sk_buff
*skb
;
2414 struct wmi_set_lpreamble_cmd
*cmd
;
2417 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd
));
2421 cmd
= (struct wmi_set_lpreamble_cmd
*) skb
->data
;
2422 cmd
->status
= status
;
2423 cmd
->preamble_policy
= preamble_policy
;
2425 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_LPREAMBLE_CMDID
,
2430 int ath6kl_wmi_set_rts_cmd(struct wmi
*wmi
, u16 threshold
)
2432 struct sk_buff
*skb
;
2433 struct wmi_set_rts_cmd
*cmd
;
2436 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd
));
2440 cmd
= (struct wmi_set_rts_cmd
*) skb
->data
;
2441 cmd
->threshold
= cpu_to_le16(threshold
);
2443 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_RTS_CMDID
, NO_SYNC_WMIFLAG
);
2447 int ath6kl_wmi_set_wmm_txop(struct wmi
*wmi
, enum wmi_txop_cfg cfg
)
2449 struct sk_buff
*skb
;
2450 struct wmi_set_wmm_txop_cmd
*cmd
;
2453 if (!((cfg
== WMI_TXOP_DISABLED
) || (cfg
== WMI_TXOP_ENABLED
)))
2456 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd
));
2460 cmd
= (struct wmi_set_wmm_txop_cmd
*) skb
->data
;
2461 cmd
->txop_enable
= cfg
;
2463 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_WMM_TXOP_CMDID
,
2468 int ath6kl_wmi_set_keepalive_cmd(struct wmi
*wmi
, u8 keep_alive_intvl
)
2470 struct sk_buff
*skb
;
2471 struct wmi_set_keepalive_cmd
*cmd
;
2474 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2478 cmd
= (struct wmi_set_keepalive_cmd
*) skb
->data
;
2479 cmd
->keep_alive_intvl
= keep_alive_intvl
;
2480 wmi
->keep_alive_intvl
= keep_alive_intvl
;
2482 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_KEEPALIVE_CMDID
,
2487 int ath6kl_wmi_test_cmd(struct wmi
*wmi
, void *buf
, size_t len
)
2489 struct sk_buff
*skb
;
2492 skb
= ath6kl_wmi_get_new_buf(len
);
2496 memcpy(skb
->data
, buf
, len
);
2498 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_TEST_CMDID
, NO_SYNC_WMIFLAG
);
2504 s32
ath6kl_wmi_get_rate(s8 rate_index
)
2506 if (rate_index
== RATE_AUTO
)
2509 return wmi_rate_tbl
[(u32
) rate_index
][0];
2512 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi
*wmi
, u8
*datap
,
2515 struct wmi_pmkid_list_reply
*reply
;
2518 if (len
< sizeof(struct wmi_pmkid_list_reply
))
2521 reply
= (struct wmi_pmkid_list_reply
*)datap
;
2522 expected_len
= sizeof(reply
->num_pmkid
) +
2523 le32_to_cpu(reply
->num_pmkid
) * WMI_PMKID_LEN
;
2525 if (len
< expected_len
)
2531 static int ath6kl_wmi_addba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2533 struct wmi_addba_req_event
*cmd
= (struct wmi_addba_req_event
*) datap
;
2535 aggr_recv_addba_req_evt(wmi
->parent_dev
, cmd
->tid
,
2536 le16_to_cpu(cmd
->st_seq_no
), cmd
->win_sz
);
2541 static int ath6kl_wmi_delba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2543 struct wmi_delba_event
*cmd
= (struct wmi_delba_event
*) datap
;
2545 aggr_recv_delba_req_evt(wmi
->parent_dev
, cmd
->tid
);
2550 /* AP mode functions */
2552 int ath6kl_wmi_ap_profile_commit(struct wmi
*wmip
, struct wmi_connect_cmd
*p
)
2554 struct sk_buff
*skb
;
2555 struct wmi_connect_cmd
*cm
;
2558 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
2562 cm
= (struct wmi_connect_cmd
*) skb
->data
;
2563 memcpy(cm
, p
, sizeof(*cm
));
2565 res
= ath6kl_wmi_cmd_send(wmip
, skb
, WMI_AP_CONFIG_COMMIT_CMDID
,
2567 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: nw_type=%u auth_mode=%u ch=%u "
2568 "ctrl_flags=0x%x-> res=%d\n",
2569 __func__
, p
->nw_type
, p
->auth_mode
, le16_to_cpu(p
->ch
),
2570 le32_to_cpu(p
->ctrl_flags
), res
);
2574 int ath6kl_wmi_ap_set_mlme(struct wmi
*wmip
, u8 cmd
, const u8
*mac
, u16 reason
)
2576 struct sk_buff
*skb
;
2577 struct wmi_ap_set_mlme_cmd
*cm
;
2579 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
2583 cm
= (struct wmi_ap_set_mlme_cmd
*) skb
->data
;
2584 memcpy(cm
->mac
, mac
, ETH_ALEN
);
2585 cm
->reason
= cpu_to_le16(reason
);
2588 return ath6kl_wmi_cmd_send(wmip
, skb
, WMI_AP_SET_MLME_CMDID
,
2592 static int ath6kl_wmi_pspoll_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2594 struct wmi_pspoll_event
*ev
;
2596 if (len
< sizeof(struct wmi_pspoll_event
))
2599 ev
= (struct wmi_pspoll_event
*) datap
;
2601 ath6kl_pspoll_event(wmi
->parent_dev
, le16_to_cpu(ev
->aid
));
2606 static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2608 ath6kl_dtimexpiry_event(wmi
->parent_dev
);
2613 int ath6kl_wmi_set_pvb_cmd(struct wmi
*wmi
, u16 aid
, bool flag
)
2615 struct sk_buff
*skb
;
2616 struct wmi_ap_set_pvb_cmd
*cmd
;
2619 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd
));
2623 cmd
= (struct wmi_ap_set_pvb_cmd
*) skb
->data
;
2624 cmd
->aid
= cpu_to_le16(aid
);
2625 cmd
->rsvd
= cpu_to_le16(0);
2626 cmd
->flag
= cpu_to_le32(flag
);
2628 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_AP_SET_PVB_CMDID
,
2634 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi
*wmi
, u8 rx_meta_ver
,
2635 bool rx_dot11_hdr
, bool defrag_on_host
)
2637 struct sk_buff
*skb
;
2638 struct wmi_rx_frame_format_cmd
*cmd
;
2641 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2645 cmd
= (struct wmi_rx_frame_format_cmd
*) skb
->data
;
2646 cmd
->dot11_hdr
= rx_dot11_hdr
? 1 : 0;
2647 cmd
->defrag_on_host
= defrag_on_host
? 1 : 0;
2648 cmd
->meta_ver
= rx_meta_ver
;
2650 /* Delete the local aggr state, on host */
2651 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RX_FRAME_FORMAT_CMDID
,
2657 int ath6kl_wmi_set_appie_cmd(struct wmi
*wmi
, u8 mgmt_frm_type
, const u8
*ie
,
2660 struct sk_buff
*skb
;
2661 struct wmi_set_appie_cmd
*p
;
2663 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + ie_len
);
2667 ath6kl_dbg(ATH6KL_DBG_WMI
, "set_appie_cmd: mgmt_frm_type=%u "
2668 "ie_len=%u\n", mgmt_frm_type
, ie_len
);
2669 p
= (struct wmi_set_appie_cmd
*) skb
->data
;
2670 p
->mgmt_frm_type
= mgmt_frm_type
;
2672 memcpy(p
->ie_info
, ie
, ie_len
);
2673 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_APPIE_CMDID
,
2677 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi
*wmi
, bool disable
)
2679 struct sk_buff
*skb
;
2680 struct wmi_disable_11b_rates_cmd
*cmd
;
2682 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2686 ath6kl_dbg(ATH6KL_DBG_WMI
, "disable_11b_rates_cmd: disable=%u\n",
2688 cmd
= (struct wmi_disable_11b_rates_cmd
*) skb
->data
;
2689 cmd
->disable
= disable
? 1 : 0;
2691 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DISABLE_11B_RATES_CMDID
,
2695 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi
*wmi
, u32 freq
, u32 dur
)
2697 struct sk_buff
*skb
;
2698 struct wmi_remain_on_chnl_cmd
*p
;
2700 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2704 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl_cmd: freq=%u dur=%u\n",
2706 p
= (struct wmi_remain_on_chnl_cmd
*) skb
->data
;
2707 p
->freq
= cpu_to_le32(freq
);
2708 p
->duration
= cpu_to_le32(dur
);
2709 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_REMAIN_ON_CHNL_CMDID
,
2713 int ath6kl_wmi_send_action_cmd(struct wmi
*wmi
, u32 id
, u32 freq
, u32 wait
,
2714 const u8
*data
, u16 data_len
)
2716 struct sk_buff
*skb
;
2717 struct wmi_send_action_cmd
*p
;
2721 return -EINVAL
; /* Offload for wait not supported */
2723 buf
= kmalloc(data_len
, GFP_KERNEL
);
2727 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
2733 kfree(wmi
->last_mgmt_tx_frame
);
2734 wmi
->last_mgmt_tx_frame
= buf
;
2735 wmi
->last_mgmt_tx_frame_len
= data_len
;
2737 ath6kl_dbg(ATH6KL_DBG_WMI
, "send_action_cmd: id=%u freq=%u wait=%u "
2738 "len=%u\n", id
, freq
, wait
, data_len
);
2739 p
= (struct wmi_send_action_cmd
*) skb
->data
;
2740 p
->id
= cpu_to_le32(id
);
2741 p
->freq
= cpu_to_le32(freq
);
2742 p
->wait
= cpu_to_le32(wait
);
2743 p
->len
= cpu_to_le16(data_len
);
2744 memcpy(p
->data
, data
, data_len
);
2745 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SEND_ACTION_CMDID
,
2749 int ath6kl_wmi_send_probe_response_cmd(struct wmi
*wmi
, u32 freq
,
2751 const u8
*data
, u16 data_len
)
2753 struct sk_buff
*skb
;
2754 struct wmi_p2p_probe_response_cmd
*p
;
2756 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
2760 ath6kl_dbg(ATH6KL_DBG_WMI
, "send_probe_response_cmd: freq=%u dst=%pM "
2761 "len=%u\n", freq
, dst
, data_len
);
2762 p
= (struct wmi_p2p_probe_response_cmd
*) skb
->data
;
2763 p
->freq
= cpu_to_le32(freq
);
2764 memcpy(p
->destination_addr
, dst
, ETH_ALEN
);
2765 p
->len
= cpu_to_le16(data_len
);
2766 memcpy(p
->data
, data
, data_len
);
2767 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SEND_PROBE_RESPONSE_CMDID
,
2771 int ath6kl_wmi_probe_report_req_cmd(struct wmi
*wmi
, bool enable
)
2773 struct sk_buff
*skb
;
2774 struct wmi_probe_req_report_cmd
*p
;
2776 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2780 ath6kl_dbg(ATH6KL_DBG_WMI
, "probe_report_req_cmd: enable=%u\n",
2782 p
= (struct wmi_probe_req_report_cmd
*) skb
->data
;
2783 p
->enable
= enable
? 1 : 0;
2784 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_PROBE_REQ_REPORT_CMDID
,
2788 int ath6kl_wmi_info_req_cmd(struct wmi
*wmi
, u32 info_req_flags
)
2790 struct sk_buff
*skb
;
2791 struct wmi_get_p2p_info
*p
;
2793 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2797 ath6kl_dbg(ATH6KL_DBG_WMI
, "info_req_cmd: flags=%x\n",
2799 p
= (struct wmi_get_p2p_info
*) skb
->data
;
2800 p
->info_req_flags
= cpu_to_le32(info_req_flags
);
2801 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_GET_P2P_INFO_CMDID
,
2805 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi
*wmi
)
2807 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl_cmd\n");
2808 return ath6kl_wmi_simple_cmd(wmi
, WMI_CANCEL_REMAIN_ON_CHNL_CMDID
);
2811 static int ath6kl_wmi_control_rx_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
)
2813 struct wmix_cmd_hdr
*cmd
;
2819 if (skb
->len
< sizeof(struct wmix_cmd_hdr
)) {
2820 ath6kl_err("bad packet 1\n");
2821 wmi
->stat
.cmd_len_err
++;
2825 cmd
= (struct wmix_cmd_hdr
*) skb
->data
;
2826 id
= le32_to_cpu(cmd
->cmd_id
);
2828 skb_pull(skb
, sizeof(struct wmix_cmd_hdr
));
2834 case WMIX_HB_CHALLENGE_RESP_EVENTID
:
2835 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi event hb challenge resp\n");
2837 case WMIX_DBGLOG_EVENTID
:
2838 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi event dbglog len %d\n", len
);
2839 ath6kl_debug_fwlog_event(wmi
->parent_dev
, datap
, len
);
2842 ath6kl_warn("unknown cmd id 0x%x\n", id
);
2843 wmi
->stat
.cmd_id_err
++;
2852 int ath6kl_wmi_control_rx(struct wmi
*wmi
, struct sk_buff
*skb
)
2854 struct wmi_cmd_hdr
*cmd
;
2860 if (WARN_ON(skb
== NULL
))
2863 if (skb
->len
< sizeof(struct wmi_cmd_hdr
)) {
2864 ath6kl_err("bad packet 1\n");
2866 wmi
->stat
.cmd_len_err
++;
2870 cmd
= (struct wmi_cmd_hdr
*) skb
->data
;
2871 id
= le16_to_cpu(cmd
->cmd_id
);
2873 skb_pull(skb
, sizeof(struct wmi_cmd_hdr
));
2878 ath6kl_dbg(ATH6KL_DBG_WMI
, "wmi rx id %d len %d\n", id
, len
);
2879 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP
, NULL
, "wmi rx ",
2883 case WMI_GET_BITRATE_CMDID
:
2884 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_BITRATE_CMDID\n");
2885 ret
= ath6kl_wmi_bitrate_reply_rx(wmi
, datap
, len
);
2887 case WMI_GET_CHANNEL_LIST_CMDID
:
2888 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_CHANNEL_LIST_CMDID\n");
2889 ret
= ath6kl_wmi_ch_list_reply_rx(wmi
, datap
, len
);
2891 case WMI_GET_TX_PWR_CMDID
:
2892 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_TX_PWR_CMDID\n");
2893 ret
= ath6kl_wmi_tx_pwr_reply_rx(wmi
, datap
, len
);
2895 case WMI_READY_EVENTID
:
2896 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_READY_EVENTID\n");
2897 ret
= ath6kl_wmi_ready_event_rx(wmi
, datap
, len
);
2899 case WMI_CONNECT_EVENTID
:
2900 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CONNECT_EVENTID\n");
2901 ret
= ath6kl_wmi_connect_event_rx(wmi
, datap
, len
);
2903 case WMI_DISCONNECT_EVENTID
:
2904 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DISCONNECT_EVENTID\n");
2905 ret
= ath6kl_wmi_disconnect_event_rx(wmi
, datap
, len
);
2907 case WMI_PEER_NODE_EVENTID
:
2908 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PEER_NODE_EVENTID\n");
2909 ret
= ath6kl_wmi_peer_node_event_rx(wmi
, datap
, len
);
2911 case WMI_TKIP_MICERR_EVENTID
:
2912 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TKIP_MICERR_EVENTID\n");
2913 ret
= ath6kl_wmi_tkip_micerr_event_rx(wmi
, datap
, len
);
2915 case WMI_BSSINFO_EVENTID
:
2916 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_BSSINFO_EVENTID\n");
2917 ret
= ath6kl_wmi_bssinfo_event_rx(wmi
, datap
, len
);
2919 case WMI_REGDOMAIN_EVENTID
:
2920 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REGDOMAIN_EVENTID\n");
2921 ath6kl_wmi_regdomain_event(wmi
, datap
, len
);
2923 case WMI_PSTREAM_TIMEOUT_EVENTID
:
2924 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
2925 ret
= ath6kl_wmi_pstream_timeout_event_rx(wmi
, datap
, len
);
2927 case WMI_NEIGHBOR_REPORT_EVENTID
:
2928 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_NEIGHBOR_REPORT_EVENTID\n");
2929 ret
= ath6kl_wmi_neighbor_report_event_rx(wmi
, datap
, len
);
2931 case WMI_SCAN_COMPLETE_EVENTID
:
2932 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SCAN_COMPLETE_EVENTID\n");
2933 ret
= ath6kl_wmi_scan_complete_rx(wmi
, datap
, len
);
2935 case WMI_CMDERROR_EVENTID
:
2936 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CMDERROR_EVENTID\n");
2937 ret
= ath6kl_wmi_error_event_rx(wmi
, datap
, len
);
2939 case WMI_REPORT_STATISTICS_EVENTID
:
2940 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_STATISTICS_EVENTID\n");
2941 ret
= ath6kl_wmi_stats_event_rx(wmi
, datap
, len
);
2943 case WMI_RSSI_THRESHOLD_EVENTID
:
2944 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RSSI_THRESHOLD_EVENTID\n");
2945 ret
= ath6kl_wmi_rssi_threshold_event_rx(wmi
, datap
, len
);
2947 case WMI_ERROR_REPORT_EVENTID
:
2948 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ERROR_REPORT_EVENTID\n");
2950 case WMI_OPT_RX_FRAME_EVENTID
:
2951 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_OPT_RX_FRAME_EVENTID\n");
2952 /* this event has been deprecated */
2954 case WMI_REPORT_ROAM_TBL_EVENTID
:
2955 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_TBL_EVENTID\n");
2957 case WMI_EXTENSION_EVENTID
:
2958 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_EXTENSION_EVENTID\n");
2959 ret
= ath6kl_wmi_control_rx_xtnd(wmi
, skb
);
2961 case WMI_CAC_EVENTID
:
2962 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CAC_EVENTID\n");
2963 ret
= ath6kl_wmi_cac_event_rx(wmi
, datap
, len
);
2965 case WMI_CHANNEL_CHANGE_EVENTID
:
2966 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CHANNEL_CHANGE_EVENTID\n");
2968 case WMI_REPORT_ROAM_DATA_EVENTID
:
2969 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_DATA_EVENTID\n");
2971 case WMI_TEST_EVENTID
:
2972 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TEST_EVENTID\n");
2973 ret
= ath6kl_wmi_tcmd_test_report_rx(wmi
, datap
, len
);
2975 case WMI_GET_FIXRATES_CMDID
:
2976 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_FIXRATES_CMDID\n");
2977 ret
= ath6kl_wmi_ratemask_reply_rx(wmi
, datap
, len
);
2979 case WMI_TX_RETRY_ERR_EVENTID
:
2980 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_RETRY_ERR_EVENTID\n");
2982 case WMI_SNR_THRESHOLD_EVENTID
:
2983 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SNR_THRESHOLD_EVENTID\n");
2984 ret
= ath6kl_wmi_snr_threshold_event_rx(wmi
, datap
, len
);
2986 case WMI_LQ_THRESHOLD_EVENTID
:
2987 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_LQ_THRESHOLD_EVENTID\n");
2989 case WMI_APLIST_EVENTID
:
2990 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_APLIST_EVENTID\n");
2991 ret
= ath6kl_wmi_aplist_event_rx(wmi
, datap
, len
);
2993 case WMI_GET_KEEPALIVE_CMDID
:
2994 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_KEEPALIVE_CMDID\n");
2995 ret
= ath6kl_wmi_keepalive_reply_rx(wmi
, datap
, len
);
2997 case WMI_GET_WOW_LIST_EVENTID
:
2998 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_WOW_LIST_EVENTID\n");
2999 ret
= ath6kl_wmi_get_wow_list_event_rx(wmi
, datap
, len
);
3001 case WMI_GET_PMKID_LIST_EVENTID
:
3002 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_PMKID_LIST_EVENTID\n");
3003 ret
= ath6kl_wmi_get_pmkid_list_event_rx(wmi
, datap
, len
);
3005 case WMI_PSPOLL_EVENTID
:
3006 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSPOLL_EVENTID\n");
3007 ret
= ath6kl_wmi_pspoll_event_rx(wmi
, datap
, len
);
3009 case WMI_DTIMEXPIRY_EVENTID
:
3010 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DTIMEXPIRY_EVENTID\n");
3011 ret
= ath6kl_wmi_dtimexpiry_event_rx(wmi
, datap
, len
);
3013 case WMI_SET_PARAMS_REPLY_EVENTID
:
3014 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SET_PARAMS_REPLY_EVENTID\n");
3016 case WMI_ADDBA_REQ_EVENTID
:
3017 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_REQ_EVENTID\n");
3018 ret
= ath6kl_wmi_addba_req_event_rx(wmi
, datap
, len
);
3020 case WMI_ADDBA_RESP_EVENTID
:
3021 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_RESP_EVENTID\n");
3023 case WMI_DELBA_REQ_EVENTID
:
3024 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DELBA_REQ_EVENTID\n");
3025 ret
= ath6kl_wmi_delba_req_event_rx(wmi
, datap
, len
);
3027 case WMI_REPORT_BTCOEX_CONFIG_EVENTID
:
3028 ath6kl_dbg(ATH6KL_DBG_WMI
,
3029 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
3031 case WMI_REPORT_BTCOEX_STATS_EVENTID
:
3032 ath6kl_dbg(ATH6KL_DBG_WMI
,
3033 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
3035 case WMI_TX_COMPLETE_EVENTID
:
3036 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_COMPLETE_EVENTID\n");
3037 ret
= ath6kl_wmi_tx_complete_event_rx(datap
, len
);
3039 case WMI_REMAIN_ON_CHNL_EVENTID
:
3040 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REMAIN_ON_CHNL_EVENTID\n");
3041 ret
= ath6kl_wmi_remain_on_chnl_event_rx(wmi
, datap
, len
);
3043 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID
:
3044 ath6kl_dbg(ATH6KL_DBG_WMI
,
3045 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
3046 ret
= ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi
, datap
,
3049 case WMI_TX_STATUS_EVENTID
:
3050 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_STATUS_EVENTID\n");
3051 ret
= ath6kl_wmi_tx_status_event_rx(wmi
, datap
, len
);
3053 case WMI_RX_PROBE_REQ_EVENTID
:
3054 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_PROBE_REQ_EVENTID\n");
3055 ret
= ath6kl_wmi_rx_probe_req_event_rx(wmi
, datap
, len
);
3057 case WMI_P2P_CAPABILITIES_EVENTID
:
3058 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_CAPABILITIES_EVENTID\n");
3059 ret
= ath6kl_wmi_p2p_capabilities_event_rx(datap
, len
);
3061 case WMI_RX_ACTION_EVENTID
:
3062 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_ACTION_EVENTID\n");
3063 ret
= ath6kl_wmi_rx_action_event_rx(wmi
, datap
, len
);
3065 case WMI_P2P_INFO_EVENTID
:
3066 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_INFO_EVENTID\n");
3067 ret
= ath6kl_wmi_p2p_info_event_rx(datap
, len
);
3070 ath6kl_dbg(ATH6KL_DBG_WMI
, "unknown cmd id 0x%x\n", id
);
3071 wmi
->stat
.cmd_id_err
++;
3081 static void ath6kl_wmi_qos_state_init(struct wmi
*wmi
)
3086 spin_lock_bh(&wmi
->lock
);
3088 wmi
->fat_pipe_exist
= 0;
3089 memset(wmi
->stream_exist_for_ac
, 0, sizeof(wmi
->stream_exist_for_ac
));
3091 spin_unlock_bh(&wmi
->lock
);
3094 void *ath6kl_wmi_init(struct ath6kl
*dev
)
3098 wmi
= kzalloc(sizeof(struct wmi
), GFP_KERNEL
);
3102 spin_lock_init(&wmi
->lock
);
3104 wmi
->parent_dev
= dev
;
3106 ath6kl_wmi_qos_state_init(wmi
);
3108 wmi
->pwr_mode
= REC_POWER
;
3109 wmi
->phy_mode
= WMI_11G_MODE
;
3111 wmi
->pair_crypto_type
= NONE_CRYPT
;
3112 wmi
->grp_crypto_type
= NONE_CRYPT
;
3114 wmi
->ht_allowed
[A_BAND_24GHZ
] = 1;
3115 wmi
->ht_allowed
[A_BAND_5GHZ
] = 1;
3120 void ath6kl_wmi_shutdown(struct wmi
*wmi
)
3125 kfree(wmi
->last_mgmt_tx_frame
);