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.
21 static int ath6kl_wmi_sync_point(struct wmi
*wmi
);
23 static const s32 wmi_rate_tbl
[][2] = {
24 /* {W/O SGI, with SGI} */
56 /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
57 static const u8 up_to_ac
[] = {
68 void ath6kl_wmi_set_control_ep(struct wmi
*wmi
, enum htc_endpoint_id ep_id
)
70 if (WARN_ON(ep_id
== ENDPOINT_UNUSED
|| ep_id
>= ENDPOINT_MAX
))
76 enum htc_endpoint_id
ath6kl_wmi_get_control_ep(struct wmi
*wmi
)
81 /* Performs DIX to 802.3 encapsulation for transmit packets.
82 * Assumes the entire DIX header is contigous and that there is
83 * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers.
85 int ath6kl_wmi_dix_2_dot3(struct wmi
*wmi
, struct sk_buff
*skb
)
87 struct ath6kl_llc_snap_hdr
*llc_hdr
;
88 struct ethhdr
*eth_hdr
;
94 if (WARN_ON(skb
== NULL
))
97 size
= sizeof(struct ath6kl_llc_snap_hdr
) + sizeof(struct wmi_data_hdr
);
98 if (skb_headroom(skb
) < size
)
101 eth_hdr
= (struct ethhdr
*) skb
->data
;
102 type
= eth_hdr
->h_proto
;
104 if (!is_ethertype(be16_to_cpu(type
))) {
105 ath6kl_dbg(ATH6KL_DBG_WMI
,
106 "%s: pkt is already in 802.3 format\n", __func__
);
110 new_len
= skb
->len
- sizeof(*eth_hdr
) + sizeof(*llc_hdr
);
112 skb_push(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
115 eth_hdr
->h_proto
= cpu_to_be16(new_len
);
117 memcpy(datap
, eth_hdr
, sizeof(*eth_hdr
));
119 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
+ sizeof(*eth_hdr
));
120 llc_hdr
->dsap
= 0xAA;
121 llc_hdr
->ssap
= 0xAA;
122 llc_hdr
->cntl
= 0x03;
123 llc_hdr
->org_code
[0] = 0x0;
124 llc_hdr
->org_code
[1] = 0x0;
125 llc_hdr
->org_code
[2] = 0x0;
126 llc_hdr
->eth_type
= type
;
131 static int ath6kl_wmi_meta_add(struct wmi
*wmi
, struct sk_buff
*skb
,
132 u8
*version
, void *tx_meta_info
)
134 struct wmi_tx_meta_v1
*v1
;
135 struct wmi_tx_meta_v2
*v2
;
137 if (WARN_ON(skb
== NULL
|| version
== NULL
))
141 case WMI_META_VERSION_1
:
142 skb_push(skb
, WMI_MAX_TX_META_SZ
);
143 v1
= (struct wmi_tx_meta_v1
*) skb
->data
;
145 v1
->rate_plcy_id
= 0;
146 *version
= WMI_META_VERSION_1
;
148 case WMI_META_VERSION_2
:
149 skb_push(skb
, WMI_MAX_TX_META_SZ
);
150 v2
= (struct wmi_tx_meta_v2
*) skb
->data
;
151 memcpy(v2
, (struct wmi_tx_meta_v2
*) tx_meta_info
,
152 sizeof(struct wmi_tx_meta_v2
));
159 int ath6kl_wmi_data_hdr_add(struct wmi
*wmi
, struct sk_buff
*skb
,
160 u8 msg_type
, bool more_data
,
161 enum wmi_data_hdr_data_type data_type
,
162 u8 meta_ver
, void *tx_meta_info
)
164 struct wmi_data_hdr
*data_hdr
;
167 if (WARN_ON(skb
== NULL
))
171 ret
= ath6kl_wmi_meta_add(wmi
, skb
, &meta_ver
, tx_meta_info
);
176 skb_push(skb
, sizeof(struct wmi_data_hdr
));
178 data_hdr
= (struct wmi_data_hdr
*)skb
->data
;
179 memset(data_hdr
, 0, sizeof(struct wmi_data_hdr
));
181 data_hdr
->info
= msg_type
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
182 data_hdr
->info
|= data_type
<< WMI_DATA_HDR_DATA_TYPE_SHIFT
;
186 WMI_DATA_HDR_MORE_MASK
<< WMI_DATA_HDR_MORE_SHIFT
;
188 data_hdr
->info2
= cpu_to_le16(meta_ver
<< WMI_DATA_HDR_META_SHIFT
);
194 static u8
ath6kl_wmi_determine_user_priority(u8
*pkt
, u32 layer2_pri
)
196 struct iphdr
*ip_hdr
= (struct iphdr
*) pkt
;
200 * Determine IPTOS priority
203 * : DSCP(6-bits) ECN(2-bits)
204 * : DSCP - P2 P1 P0 X X X
205 * where (P2 P1 P0) form 802.1D
207 ip_pri
= ip_hdr
->tos
>> 5;
210 if ((layer2_pri
& 0x7) > ip_pri
)
211 return (u8
) layer2_pri
& 0x7;
216 int ath6kl_wmi_implicit_create_pstream(struct wmi
*wmi
, struct sk_buff
*skb
,
217 u32 layer2_priority
, bool wmm_enabled
,
220 struct wmi_data_hdr
*data_hdr
;
221 struct ath6kl_llc_snap_hdr
*llc_hdr
;
222 struct wmi_create_pstream_cmd cmd
;
223 u32 meta_size
, hdr_size
;
224 u16 ip_type
= IP_ETHERTYPE
;
225 u8 stream_exist
, usr_pri
;
226 u8 traffic_class
= WMM_AC_BE
;
229 if (WARN_ON(skb
== NULL
))
233 data_hdr
= (struct wmi_data_hdr
*) datap
;
235 meta_size
= ((le16_to_cpu(data_hdr
->info2
) >> WMI_DATA_HDR_META_SHIFT
) &
236 WMI_DATA_HDR_META_MASK
) ? WMI_MAX_TX_META_SZ
: 0;
239 /* If WMM is disabled all traffic goes as BE traffic */
242 hdr_size
= sizeof(struct ethhdr
);
244 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
+
247 meta_size
+ hdr_size
);
249 if (llc_hdr
->eth_type
== htons(ip_type
)) {
251 * Extract the endpoint info from the TOS field
255 ath6kl_wmi_determine_user_priority(((u8
*) llc_hdr
) +
256 sizeof(struct ath6kl_llc_snap_hdr
),
259 usr_pri
= layer2_priority
& 0x7;
262 /* workaround for WMM S5 */
263 if ((wmi
->traffic_class
== WMM_AC_VI
) &&
264 ((usr_pri
== 5) || (usr_pri
== 4)))
267 /* Convert user priority to traffic class */
268 traffic_class
= up_to_ac
[usr_pri
& 0x7];
270 wmi_data_hdr_set_up(data_hdr
, usr_pri
);
272 spin_lock_bh(&wmi
->lock
);
273 stream_exist
= wmi
->fat_pipe_exist
;
274 spin_unlock_bh(&wmi
->lock
);
276 if (!(stream_exist
& (1 << traffic_class
))) {
277 memset(&cmd
, 0, sizeof(cmd
));
278 cmd
.traffic_class
= traffic_class
;
279 cmd
.user_pri
= usr_pri
;
281 cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT
);
282 /* Implicit streams are created with TSID 0xFF */
283 cmd
.tsid
= WMI_IMPLICIT_PSTREAM
;
284 ath6kl_wmi_create_pstream_cmd(wmi
, &cmd
);
292 int ath6kl_wmi_dot11_hdr_remove(struct wmi
*wmi
, struct sk_buff
*skb
)
294 struct ieee80211_hdr_3addr
*pwh
, wh
;
295 struct ath6kl_llc_snap_hdr
*llc_hdr
;
296 struct ethhdr eth_hdr
;
301 if (WARN_ON(skb
== NULL
))
305 pwh
= (struct ieee80211_hdr_3addr
*) datap
;
307 sub_type
= pwh
->frame_control
& cpu_to_le16(IEEE80211_FCTL_STYPE
);
309 memcpy((u8
*) &wh
, datap
, sizeof(struct ieee80211_hdr_3addr
));
311 /* Strip off the 802.11 header */
312 if (sub_type
== cpu_to_le16(IEEE80211_STYPE_QOS_DATA
)) {
313 hdr_size
= roundup(sizeof(struct ieee80211_qos_hdr
),
315 skb_pull(skb
, hdr_size
);
316 } else if (sub_type
== cpu_to_le16(IEEE80211_STYPE_DATA
))
317 skb_pull(skb
, sizeof(struct ieee80211_hdr_3addr
));
320 llc_hdr
= (struct ath6kl_llc_snap_hdr
*)(datap
);
322 memset(ð_hdr
, 0, sizeof(eth_hdr
));
323 eth_hdr
.h_proto
= llc_hdr
->eth_type
;
325 switch ((le16_to_cpu(wh
.frame_control
)) &
326 (IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
)) {
328 memcpy(eth_hdr
.h_dest
, wh
.addr1
, ETH_ALEN
);
329 memcpy(eth_hdr
.h_source
, wh
.addr2
, ETH_ALEN
);
331 case IEEE80211_FCTL_TODS
:
332 memcpy(eth_hdr
.h_dest
, wh
.addr3
, ETH_ALEN
);
333 memcpy(eth_hdr
.h_source
, wh
.addr2
, ETH_ALEN
);
335 case IEEE80211_FCTL_FROMDS
:
336 memcpy(eth_hdr
.h_dest
, wh
.addr1
, ETH_ALEN
);
337 memcpy(eth_hdr
.h_source
, wh
.addr3
, ETH_ALEN
);
339 case IEEE80211_FCTL_FROMDS
| IEEE80211_FCTL_TODS
:
343 skb_pull(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
344 skb_push(skb
, sizeof(eth_hdr
));
348 memcpy(datap
, ð_hdr
, sizeof(eth_hdr
));
354 * Performs 802.3 to DIX encapsulation for received packets.
355 * Assumes the entire 802.3 header is contigous.
357 int ath6kl_wmi_dot3_2_dix(struct sk_buff
*skb
)
359 struct ath6kl_llc_snap_hdr
*llc_hdr
;
360 struct ethhdr eth_hdr
;
363 if (WARN_ON(skb
== NULL
))
368 memcpy(ð_hdr
, datap
, sizeof(eth_hdr
));
370 llc_hdr
= (struct ath6kl_llc_snap_hdr
*) (datap
+ sizeof(eth_hdr
));
371 eth_hdr
.h_proto
= llc_hdr
->eth_type
;
373 skb_pull(skb
, sizeof(struct ath6kl_llc_snap_hdr
));
376 memcpy(datap
, ð_hdr
, sizeof(eth_hdr
));
381 static void ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(struct sk_buff
*skb
,
384 struct wmi_bss_info_hdr2 bih2
;
385 struct wmi_bss_info_hdr
*bih
;
387 memcpy(&bih2
, datap
, sizeof(struct wmi_bss_info_hdr2
));
390 bih
= (struct wmi_bss_info_hdr
*) skb
->data
;
393 bih
->frame_type
= bih2
.frame_type
;
395 bih
->rssi
= a_cpu_to_sle16(bih2
.snr
- 95);
396 bih
->ie_mask
= cpu_to_le32(le16_to_cpu(bih2
.ie_mask
));
397 memcpy(bih
->bssid
, bih2
.bssid
, ETH_ALEN
);
400 static int ath6kl_wmi_tx_complete_event_rx(u8
*datap
, int len
)
402 struct tx_complete_msg_v1
*msg_v1
;
403 struct wmi_tx_complete_event
*evt
;
407 evt
= (struct wmi_tx_complete_event
*) datap
;
409 ath6kl_dbg(ATH6KL_DBG_WMI
, "comp: %d %d %d\n",
410 evt
->num_msg
, evt
->msg_len
, evt
->msg_type
);
412 if (!AR_DBG_LVL_CHECK(ATH6KL_DBG_WMI
))
415 for (index
= 0; index
< evt
->num_msg
; index
++) {
416 size
= sizeof(struct wmi_tx_complete_event
) +
417 (index
* sizeof(struct tx_complete_msg_v1
));
418 msg_v1
= (struct tx_complete_msg_v1
*)(datap
+ size
);
420 ath6kl_dbg(ATH6KL_DBG_WMI
, "msg: %d %d %d %d\n",
421 msg_v1
->status
, msg_v1
->pkt_id
,
422 msg_v1
->rate_idx
, msg_v1
->ack_failures
);
428 static int ath6kl_wmi_remain_on_chnl_event_rx(u8
*datap
, int len
)
430 struct wmi_remain_on_chnl_event
*ev
;
434 if (len
< sizeof(*ev
))
437 ev
= (struct wmi_remain_on_chnl_event
*) datap
;
438 freq
= le32_to_cpu(ev
->freq
);
439 dur
= le32_to_cpu(ev
->duration
);
440 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl: freq=%u dur=%u\n",
446 static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(u8
*datap
, int len
)
448 struct wmi_cancel_remain_on_chnl_event
*ev
;
452 if (len
< sizeof(*ev
))
455 ev
= (struct wmi_cancel_remain_on_chnl_event
*) datap
;
456 freq
= le32_to_cpu(ev
->freq
);
457 dur
= le32_to_cpu(ev
->duration
);
458 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl: freq=%u dur=%u "
459 "status=%u\n", freq
, dur
, ev
->status
);
464 static int ath6kl_wmi_tx_status_event_rx(u8
*datap
, int len
)
466 struct wmi_tx_status_event
*ev
;
469 if (len
< sizeof(*ev
))
472 ev
= (struct wmi_tx_status_event
*) datap
;
473 id
= le32_to_cpu(ev
->id
);
474 ath6kl_dbg(ATH6KL_DBG_WMI
, "tx_status: id=%x ack_status=%u\n",
480 static int ath6kl_wmi_rx_probe_req_event_rx(u8
*datap
, int len
)
482 struct wmi_p2p_rx_probe_req_event
*ev
;
485 if (len
< sizeof(*ev
))
488 ev
= (struct wmi_p2p_rx_probe_req_event
*) datap
;
489 dlen
= le16_to_cpu(ev
->len
);
490 ath6kl_dbg(ATH6KL_DBG_WMI
, "rx_probe_req: len=%u\n",
496 static int ath6kl_wmi_p2p_capabilities_event_rx(u8
*datap
, int len
)
498 struct wmi_p2p_capabilities_event
*ev
;
501 if (len
< sizeof(*ev
))
504 ev
= (struct wmi_p2p_capabilities_event
*) datap
;
505 dlen
= le16_to_cpu(ev
->len
);
506 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_capab: len=%u\n", dlen
);
511 static int ath6kl_wmi_rx_action_event_rx(u8
*datap
, int len
)
513 struct wmi_rx_action_event
*ev
;
516 if (len
< sizeof(*ev
))
519 ev
= (struct wmi_rx_action_event
*) datap
;
520 dlen
= le16_to_cpu(ev
->len
);
521 ath6kl_dbg(ATH6KL_DBG_WMI
, "rx_action: len=%u\n", dlen
);
526 static int ath6kl_wmi_p2p_info_event_rx(u8
*datap
, int len
)
528 struct wmi_p2p_info_event
*ev
;
532 if (len
< sizeof(*ev
))
535 ev
= (struct wmi_p2p_info_event
*) datap
;
536 flags
= le32_to_cpu(ev
->info_req_flags
);
537 dlen
= le16_to_cpu(ev
->len
);
538 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: flags=%x len=%d\n", flags
, dlen
);
540 if (flags
& P2P_FLAG_CAPABILITIES_REQ
) {
541 struct wmi_p2p_capabilities
*cap
;
542 if (dlen
< sizeof(*cap
))
544 cap
= (struct wmi_p2p_capabilities
*) ev
->data
;
545 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: GO Power Save = %d\n",
549 if (flags
& P2P_FLAG_MACADDR_REQ
) {
550 struct wmi_p2p_macaddr
*mac
;
551 if (dlen
< sizeof(*mac
))
553 mac
= (struct wmi_p2p_macaddr
*) ev
->data
;
554 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: MAC Address = %pM\n",
558 if (flags
& P2P_FLAG_HMODEL_REQ
) {
559 struct wmi_p2p_hmodel
*mod
;
560 if (dlen
< sizeof(*mod
))
562 mod
= (struct wmi_p2p_hmodel
*) ev
->data
;
563 ath6kl_dbg(ATH6KL_DBG_WMI
, "p2p_info: P2P Model = %d (%s)\n",
565 mod
->p2p_model
? "host" : "firmware");
570 static inline struct sk_buff
*ath6kl_wmi_get_new_buf(u32 size
)
574 skb
= ath6kl_buf_alloc(size
);
580 memset(skb
->data
, 0, size
);
585 /* Send a "simple" wmi command -- one with no arguments */
586 static int ath6kl_wmi_simple_cmd(struct wmi
*wmi
, enum wmi_cmd_id cmd_id
)
591 skb
= ath6kl_wmi_get_new_buf(0);
595 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, cmd_id
, NO_SYNC_WMIFLAG
);
600 static int ath6kl_wmi_ready_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
602 struct wmi_ready_event_2
*ev
= (struct wmi_ready_event_2
*) datap
;
604 if (len
< sizeof(struct wmi_ready_event_2
))
608 ath6kl_ready_event(wmi
->parent_dev
, ev
->mac_addr
,
609 le32_to_cpu(ev
->sw_version
),
610 le32_to_cpu(ev
->abi_version
));
615 static int ath6kl_wmi_connect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
617 struct wmi_connect_event
*ev
;
620 if (len
< sizeof(struct wmi_connect_event
))
623 ev
= (struct wmi_connect_event
*) datap
;
625 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: freq %d bssid %pM\n",
626 __func__
, ev
->ch
, ev
->bssid
);
628 /* Start of assoc rsp IEs */
629 pie
= ev
->assoc_info
+ ev
->beacon_ie_len
+
630 ev
->assoc_req_len
+ (sizeof(u16
) * 3); /* capinfo, status, aid */
632 /* End of assoc rsp IEs */
633 peie
= ev
->assoc_info
+ ev
->beacon_ie_len
+ ev
->assoc_req_len
+
638 case WLAN_EID_VENDOR_SPECIFIC
:
639 if (pie
[1] > 3 && pie
[2] == 0x00 && pie
[3] == 0x50 &&
640 pie
[4] == 0xf2 && pie
[5] == WMM_OUI_TYPE
) {
641 /* WMM OUT (00:50:F2) */
643 && pie
[6] == WMM_PARAM_OUI_SUBTYPE
)
644 wmi
->is_wmm_enabled
= true;
649 if (wmi
->is_wmm_enabled
)
655 ath6kl_connect_event(wmi
->parent_dev
, le16_to_cpu(ev
->ch
), ev
->bssid
,
656 le16_to_cpu(ev
->listen_intvl
),
657 le16_to_cpu(ev
->beacon_intvl
),
658 le32_to_cpu(ev
->nw_type
),
659 ev
->beacon_ie_len
, ev
->assoc_req_len
,
660 ev
->assoc_resp_len
, ev
->assoc_info
);
665 static int ath6kl_wmi_disconnect_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
667 struct wmi_disconnect_event
*ev
;
668 wmi
->traffic_class
= 100;
670 if (len
< sizeof(struct wmi_disconnect_event
))
673 ev
= (struct wmi_disconnect_event
*) datap
;
675 wmi
->is_wmm_enabled
= false;
676 wmi
->pair_crypto_type
= NONE_CRYPT
;
677 wmi
->grp_crypto_type
= NONE_CRYPT
;
679 ath6kl_disconnect_event(wmi
->parent_dev
, ev
->disconn_reason
,
680 ev
->bssid
, ev
->assoc_resp_len
, ev
->assoc_info
,
681 le16_to_cpu(ev
->proto_reason_status
));
686 static int ath6kl_wmi_peer_node_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
688 struct wmi_peer_node_event
*ev
;
690 if (len
< sizeof(struct wmi_peer_node_event
))
693 ev
= (struct wmi_peer_node_event
*) datap
;
695 if (ev
->event_code
== PEER_NODE_JOIN_EVENT
)
696 ath6kl_dbg(ATH6KL_DBG_WMI
, "joined node with mac addr: %pM\n",
698 else if (ev
->event_code
== PEER_NODE_LEAVE_EVENT
)
699 ath6kl_dbg(ATH6KL_DBG_WMI
, "left node with mac addr: %pM\n",
705 static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
707 struct wmi_tkip_micerr_event
*ev
;
709 if (len
< sizeof(struct wmi_tkip_micerr_event
))
712 ev
= (struct wmi_tkip_micerr_event
*) datap
;
714 ath6kl_tkip_micerr_event(wmi
->parent_dev
, ev
->key_id
, ev
->is_mcast
);
719 static int ath6kl_wlan_parse_beacon(u8
*buf
, int frame_len
,
720 struct ath6kl_common_ie
*cie
)
723 u8 elemid_ssid
= false;
726 efrm
= (u8
*) (frm
+ frame_len
);
729 * beacon/probe response frame format
731 * [2] beacon interval
732 * [2] capability information
734 * [tlv] supported rates
735 * [tlv] country information
736 * [tlv] parameter set (FH/DS)
737 * [tlv] erp information
738 * [tlv] extended supported rates
741 * [tlv] Atheros Advanced Capabilities
743 if ((efrm
- frm
) < 12)
746 memset(cie
, 0, sizeof(*cie
));
748 cie
->ie_tstamp
= frm
;
750 cie
->ie_beaconInt
= *(u16
*) frm
;
752 cie
->ie_capInfo
= *(u16
*) frm
;
764 case WLAN_EID_SUPP_RATES
:
767 case WLAN_EID_COUNTRY
:
768 cie
->ie_country
= frm
;
770 case WLAN_EID_FH_PARAMS
:
772 case WLAN_EID_DS_PARAMS
:
773 cie
->ie_chan
= frm
[2];
778 case WLAN_EID_IBSS_PARAMS
:
780 case WLAN_EID_EXT_SUPP_RATES
:
781 cie
->ie_xrates
= frm
;
783 case WLAN_EID_ERP_INFO
:
787 cie
->ie_erp
= frm
[2];
792 case WLAN_EID_HT_CAPABILITY
:
795 case WLAN_EID_HT_INFORMATION
:
798 case WLAN_EID_VENDOR_SPECIFIC
:
799 if (frm
[1] > 3 && frm
[2] == 0x00 && frm
[3] == 0x50 &&
801 /* OUT Type (00:50:F2) */
803 if (frm
[5] == WPA_OUI_TYPE
) {
806 } else if (frm
[5] == WMM_OUI_TYPE
) {
809 } else if (frm
[5] == WSC_OUT_TYPE
) {
814 } else if (frm
[1] > 3 && frm
[2] == 0x00
815 && frm
[3] == 0x03 && frm
[4] == 0x7f
816 && frm
[5] == ATH_OUI_TYPE
) {
817 /* Atheros OUI (00:03:7f) */
827 if ((cie
->ie_rates
== NULL
)
828 || (cie
->ie_rates
[1] > ATH6KL_RATE_MAXSIZE
))
831 if ((cie
->ie_ssid
== NULL
)
832 || (cie
->ie_ssid
[1] > IEEE80211_MAX_SSID_LEN
))
838 static int ath6kl_wmi_bssinfo_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
840 struct bss
*bss
= NULL
;
841 struct wmi_bss_info_hdr
*bih
;
842 u8 cached_ssid_len
= 0;
843 u8 cached_ssid
[IEEE80211_MAX_SSID_LEN
] = { 0 };
844 u8 beacon_ssid_len
= 0;
851 if (len
<= sizeof(struct wmi_bss_info_hdr
))
854 bih
= (struct wmi_bss_info_hdr
*) datap
;
855 bss
= wlan_find_node(&wmi
->parent_dev
->scan_table
, bih
->bssid
);
857 if (a_sle16_to_cpu(bih
->rssi
) > 0) {
861 bih
->rssi
= a_cpu_to_sle16(bss
->ni_rssi
);
864 buf
= datap
+ sizeof(struct wmi_bss_info_hdr
);
865 len
-= sizeof(struct wmi_bss_info_hdr
);
867 ath6kl_dbg(ATH6KL_DBG_WMI
,
868 "bss info evt - ch %u, rssi %02x, bssid \"%pM\"\n",
869 bih
->ch
, a_sle16_to_cpu(bih
->rssi
), bih
->bssid
);
873 * Free up the node. We are about to allocate a new node.
874 * In case of hidden AP, beacon will not have ssid,
875 * but a directed probe response will have it,
876 * so cache the probe-resp-ssid if already present.
878 if (wmi
->is_probe_ssid
&& (bih
->frame_type
== BEACON_FTYPE
)) {
879 ie_ssid
= bss
->ni_cie
.ie_ssid
;
880 if (ie_ssid
&& (ie_ssid
[1] <= IEEE80211_MAX_SSID_LEN
) &&
882 cached_ssid_len
= ie_ssid
[1];
883 memcpy(cached_ssid
, ie_ssid
+ 2,
889 * Use the current average rssi of associated AP base on
891 * 1. Most os with GUI will update RSSI by
892 * ath6kl_wmi_get_stats_cmd() periodically.
893 * 2. ath6kl_wmi_get_stats_cmd(..) will be called when calling
894 * ath6kl_wmi_startscan_cmd(...)
895 * The average value of RSSI give end-user better feeling for
896 * instance value of scan result. It also sync up RSSI info
897 * in GUI between scan result and RSSI signal icon.
899 if (memcmp(wmi
->parent_dev
->bssid
, bih
->bssid
, ETH_ALEN
) == 0) {
900 bih
->rssi
= a_cpu_to_sle16(bss
->ni_rssi
);
901 bih
->snr
= bss
->ni_snr
;
904 wlan_node_reclaim(&wmi
->parent_dev
->scan_table
, bss
);
908 * beacon/probe response frame format
910 * [2] beacon interval
911 * [2] capability information
914 beacon_ssid_len
= buf
[SSID_IE_LEN_INDEX
];
917 * If ssid is cached for this hidden AP, then change
918 * buffer len accordingly.
920 if (wmi
->is_probe_ssid
&& (bih
->frame_type
== BEACON_FTYPE
) &&
921 (cached_ssid_len
!= 0) &&
922 (beacon_ssid_len
== 0 || (cached_ssid_len
> beacon_ssid_len
&&
923 buf
[SSID_IE_LEN_INDEX
+ 1] == 0))) {
925 len
+= (cached_ssid_len
- beacon_ssid_len
);
928 bss
= wlan_node_alloc(len
);
932 bss
->ni_snr
= bih
->snr
;
933 bss
->ni_rssi
= a_sle16_to_cpu(bih
->rssi
);
935 if (WARN_ON(!bss
->ni_buf
))
939 * In case of hidden AP, beacon will not have ssid,
940 * but a directed probe response will have it,
941 * so place the cached-ssid(probe-resp) in the bss info.
943 if (wmi
->is_probe_ssid
&& (bih
->frame_type
== BEACON_FTYPE
) &&
944 (cached_ssid_len
!= 0) &&
945 (beacon_ssid_len
== 0 || (beacon_ssid_len
&&
946 buf
[SSID_IE_LEN_INDEX
+ 1] == 0))) {
947 ni_buf
= bss
->ni_buf
;
951 * Copy the first 14 bytes:
952 * time-stamp(8), beacon-interval(2),
953 * cap-info(2), ssid-id(1), ssid-len(1).
955 memcpy(ni_buf
, buf
, SSID_IE_LEN_INDEX
+ 1);
957 ni_buf
[SSID_IE_LEN_INDEX
] = cached_ssid_len
;
958 ni_buf
+= (SSID_IE_LEN_INDEX
+ 1);
960 buf
+= (SSID_IE_LEN_INDEX
+ 1);
961 buf_len
-= (SSID_IE_LEN_INDEX
+ 1);
963 memcpy(ni_buf
, cached_ssid
, cached_ssid_len
);
964 ni_buf
+= cached_ssid_len
;
966 buf
+= beacon_ssid_len
;
967 buf_len
-= beacon_ssid_len
;
969 if (cached_ssid_len
> beacon_ssid_len
)
970 buf_len
-= (cached_ssid_len
- beacon_ssid_len
);
972 memcpy(ni_buf
, buf
, buf_len
);
974 memcpy(bss
->ni_buf
, buf
, len
);
976 bss
->ni_framelen
= len
;
978 ret
= ath6kl_wlan_parse_beacon(bss
->ni_buf
, len
, &bss
->ni_cie
);
985 * Update the frequency in ie_chan, overwriting of channel number
986 * which is done in ath6kl_wlan_parse_beacon
988 bss
->ni_cie
.ie_chan
= le16_to_cpu(bih
->ch
);
989 wlan_setup_node(&wmi
->parent_dev
->scan_table
, bss
, bih
->bssid
);
994 static int ath6kl_wmi_opt_frame_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
997 struct wmi_opt_rx_info_hdr
*bih
;
1000 if (len
<= sizeof(struct wmi_opt_rx_info_hdr
))
1003 bih
= (struct wmi_opt_rx_info_hdr
*) datap
;
1004 buf
= datap
+ sizeof(struct wmi_opt_rx_info_hdr
);
1005 len
-= sizeof(struct wmi_opt_rx_info_hdr
);
1007 ath6kl_dbg(ATH6KL_DBG_WMI
, "opt frame event %2.2x:%2.2x\n",
1008 bih
->bssid
[4], bih
->bssid
[5]);
1010 bss
= wlan_find_node(&wmi
->parent_dev
->scan_table
, bih
->bssid
);
1012 /* Free up the node. We are about to allocate a new node. */
1013 wlan_node_reclaim(&wmi
->parent_dev
->scan_table
, bss
);
1016 bss
= wlan_node_alloc(len
);
1020 bss
->ni_snr
= bih
->snr
;
1021 bss
->ni_cie
.ie_chan
= le16_to_cpu(bih
->ch
);
1023 if (WARN_ON(!bss
->ni_buf
))
1026 memcpy(bss
->ni_buf
, buf
, len
);
1027 wlan_setup_node(&wmi
->parent_dev
->scan_table
, bss
, bih
->bssid
);
1032 /* Inactivity timeout of a fatpipe(pstream) at the target */
1033 static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi
*wmi
, u8
*datap
,
1036 struct wmi_pstream_timeout_event
*ev
;
1038 if (len
< sizeof(struct wmi_pstream_timeout_event
))
1041 ev
= (struct wmi_pstream_timeout_event
*) datap
;
1044 * When the pstream (fat pipe == AC) timesout, it means there were
1045 * no thinStreams within this pstream & it got implicitly created
1046 * due to data flow on this AC. We start the inactivity timer only
1047 * for implicitly created pstream. Just reset the host state.
1049 spin_lock_bh(&wmi
->lock
);
1050 wmi
->stream_exist_for_ac
[ev
->traffic_class
] = 0;
1051 wmi
->fat_pipe_exist
&= ~(1 << ev
->traffic_class
);
1052 spin_unlock_bh(&wmi
->lock
);
1054 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1055 ath6kl_indicate_tx_activity(wmi
->parent_dev
, ev
->traffic_class
, false);
1060 static int ath6kl_wmi_bitrate_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1062 struct wmi_bit_rate_reply
*reply
;
1066 if (len
< sizeof(struct wmi_bit_rate_reply
))
1069 reply
= (struct wmi_bit_rate_reply
*) datap
;
1071 ath6kl_dbg(ATH6KL_DBG_WMI
, "rateindex %d\n", reply
->rate_index
);
1073 if (reply
->rate_index
== (s8
) RATE_AUTO
) {
1076 index
= reply
->rate_index
& 0x7f;
1077 sgi
= (reply
->rate_index
& 0x80) ? 1 : 0;
1078 rate
= wmi_rate_tbl
[index
][sgi
];
1081 ath6kl_wakeup_event(wmi
->parent_dev
);
1086 static int ath6kl_wmi_ratemask_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1088 if (len
< sizeof(struct wmi_fix_rates_reply
))
1091 ath6kl_wakeup_event(wmi
->parent_dev
);
1096 static int ath6kl_wmi_ch_list_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1098 if (len
< sizeof(struct wmi_channel_list_reply
))
1101 ath6kl_wakeup_event(wmi
->parent_dev
);
1106 static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1108 struct wmi_tx_pwr_reply
*reply
;
1110 if (len
< sizeof(struct wmi_tx_pwr_reply
))
1113 reply
= (struct wmi_tx_pwr_reply
*) datap
;
1114 ath6kl_txpwr_rx_evt(wmi
->parent_dev
, reply
->dbM
);
1119 static int ath6kl_wmi_keepalive_reply_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1121 if (len
< sizeof(struct wmi_get_keepalive_cmd
))
1124 ath6kl_wakeup_event(wmi
->parent_dev
);
1129 static int ath6kl_wmi_scan_complete_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1131 struct wmi_scan_complete_event
*ev
;
1133 ev
= (struct wmi_scan_complete_event
*) datap
;
1135 if (a_sle32_to_cpu(ev
->status
) == 0)
1136 wlan_refresh_inactive_nodes(wmi
->parent_dev
);
1138 ath6kl_scan_complete_evt(wmi
->parent_dev
, a_sle32_to_cpu(ev
->status
));
1139 wmi
->is_probe_ssid
= false;
1145 * Target is reporting a programming error. This is for
1146 * developer aid only. Target only checks a few common violations
1147 * and it is responsibility of host to do all error checking.
1148 * Behavior of target after wmi error event is undefined.
1149 * A reset is recommended.
1151 static int ath6kl_wmi_error_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1153 const char *type
= "unknown error";
1154 struct wmi_cmd_error_event
*ev
;
1155 ev
= (struct wmi_cmd_error_event
*) datap
;
1157 switch (ev
->err_code
) {
1159 type
= "invalid parameter";
1162 type
= "invalid state";
1164 case INTERNAL_ERROR
:
1165 type
= "internal error";
1169 ath6kl_dbg(ATH6KL_DBG_WMI
, "programming error, cmd=%d %s\n",
1175 static int ath6kl_wmi_stats_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1177 ath6kl_tgt_stats_event(wmi
->parent_dev
, datap
, len
);
1182 static u8
ath6kl_wmi_get_upper_threshold(s16 rssi
,
1183 struct sq_threshold_params
*sq_thresh
,
1187 u8 threshold
= (u8
) sq_thresh
->upper_threshold
[size
- 1];
1189 /* The list is already in sorted order. Get the next lower value */
1190 for (index
= 0; index
< size
; index
++) {
1191 if (rssi
< sq_thresh
->upper_threshold
[index
]) {
1192 threshold
= (u8
) sq_thresh
->upper_threshold
[index
];
1200 static u8
ath6kl_wmi_get_lower_threshold(s16 rssi
,
1201 struct sq_threshold_params
*sq_thresh
,
1205 u8 threshold
= (u8
) sq_thresh
->lower_threshold
[size
- 1];
1207 /* The list is already in sorted order. Get the next lower value */
1208 for (index
= 0; index
< size
; index
++) {
1209 if (rssi
> sq_thresh
->lower_threshold
[index
]) {
1210 threshold
= (u8
) sq_thresh
->lower_threshold
[index
];
1218 static int ath6kl_wmi_send_rssi_threshold_params(struct wmi
*wmi
,
1219 struct wmi_rssi_threshold_params_cmd
*rssi_cmd
)
1221 struct sk_buff
*skb
;
1222 struct wmi_rssi_threshold_params_cmd
*cmd
;
1224 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1228 cmd
= (struct wmi_rssi_threshold_params_cmd
*) skb
->data
;
1229 memcpy(cmd
, rssi_cmd
, sizeof(struct wmi_rssi_threshold_params_cmd
));
1231 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RSSI_THRESHOLD_PARAMS_CMDID
,
1235 static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1238 struct wmi_rssi_threshold_event
*reply
;
1239 struct wmi_rssi_threshold_params_cmd cmd
;
1240 struct sq_threshold_params
*sq_thresh
;
1241 enum wmi_rssi_threshold_val new_threshold
;
1242 u8 upper_rssi_threshold
, lower_rssi_threshold
;
1246 if (len
< sizeof(struct wmi_rssi_threshold_event
))
1249 reply
= (struct wmi_rssi_threshold_event
*) datap
;
1250 new_threshold
= (enum wmi_rssi_threshold_val
) reply
->range
;
1251 rssi
= a_sle16_to_cpu(reply
->rssi
);
1253 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_RSSI
];
1256 * Identify the threshold breached and communicate that to the app.
1257 * After that install a new set of thresholds based on the signal
1258 * quality reported by the target
1260 if (new_threshold
) {
1261 /* Upper threshold breached */
1262 if (rssi
< sq_thresh
->upper_threshold
[0]) {
1263 ath6kl_dbg(ATH6KL_DBG_WMI
,
1264 "spurious upper rssi threshold event: %d\n",
1266 } else if ((rssi
< sq_thresh
->upper_threshold
[1]) &&
1267 (rssi
>= sq_thresh
->upper_threshold
[0])) {
1268 new_threshold
= WMI_RSSI_THRESHOLD1_ABOVE
;
1269 } else if ((rssi
< sq_thresh
->upper_threshold
[2]) &&
1270 (rssi
>= sq_thresh
->upper_threshold
[1])) {
1271 new_threshold
= WMI_RSSI_THRESHOLD2_ABOVE
;
1272 } else if ((rssi
< sq_thresh
->upper_threshold
[3]) &&
1273 (rssi
>= sq_thresh
->upper_threshold
[2])) {
1274 new_threshold
= WMI_RSSI_THRESHOLD3_ABOVE
;
1275 } else if ((rssi
< sq_thresh
->upper_threshold
[4]) &&
1276 (rssi
>= sq_thresh
->upper_threshold
[3])) {
1277 new_threshold
= WMI_RSSI_THRESHOLD4_ABOVE
;
1278 } else if ((rssi
< sq_thresh
->upper_threshold
[5]) &&
1279 (rssi
>= sq_thresh
->upper_threshold
[4])) {
1280 new_threshold
= WMI_RSSI_THRESHOLD5_ABOVE
;
1281 } else if (rssi
>= sq_thresh
->upper_threshold
[5]) {
1282 new_threshold
= WMI_RSSI_THRESHOLD6_ABOVE
;
1285 /* Lower threshold breached */
1286 if (rssi
> sq_thresh
->lower_threshold
[0]) {
1287 ath6kl_dbg(ATH6KL_DBG_WMI
,
1288 "spurious lower rssi threshold event: %d %d\n",
1289 rssi
, sq_thresh
->lower_threshold
[0]);
1290 } else if ((rssi
> sq_thresh
->lower_threshold
[1]) &&
1291 (rssi
<= sq_thresh
->lower_threshold
[0])) {
1292 new_threshold
= WMI_RSSI_THRESHOLD6_BELOW
;
1293 } else if ((rssi
> sq_thresh
->lower_threshold
[2]) &&
1294 (rssi
<= sq_thresh
->lower_threshold
[1])) {
1295 new_threshold
= WMI_RSSI_THRESHOLD5_BELOW
;
1296 } else if ((rssi
> sq_thresh
->lower_threshold
[3]) &&
1297 (rssi
<= sq_thresh
->lower_threshold
[2])) {
1298 new_threshold
= WMI_RSSI_THRESHOLD4_BELOW
;
1299 } else if ((rssi
> sq_thresh
->lower_threshold
[4]) &&
1300 (rssi
<= sq_thresh
->lower_threshold
[3])) {
1301 new_threshold
= WMI_RSSI_THRESHOLD3_BELOW
;
1302 } else if ((rssi
> sq_thresh
->lower_threshold
[5]) &&
1303 (rssi
<= sq_thresh
->lower_threshold
[4])) {
1304 new_threshold
= WMI_RSSI_THRESHOLD2_BELOW
;
1305 } else if (rssi
<= sq_thresh
->lower_threshold
[5]) {
1306 new_threshold
= WMI_RSSI_THRESHOLD1_BELOW
;
1310 /* Calculate and install the next set of thresholds */
1311 lower_rssi_threshold
= ath6kl_wmi_get_lower_threshold(rssi
, sq_thresh
,
1312 sq_thresh
->lower_threshold_valid_count
);
1313 upper_rssi_threshold
= ath6kl_wmi_get_upper_threshold(rssi
, sq_thresh
,
1314 sq_thresh
->upper_threshold_valid_count
);
1316 /* Issue a wmi command to install the thresholds */
1317 cmd
.thresh_above1_val
= a_cpu_to_sle16(upper_rssi_threshold
);
1318 cmd
.thresh_below1_val
= a_cpu_to_sle16(lower_rssi_threshold
);
1319 cmd
.weight
= sq_thresh
->weight
;
1320 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1322 ret
= ath6kl_wmi_send_rssi_threshold_params(wmi
, &cmd
);
1324 ath6kl_err("unable to configure rssi thresholds\n");
1331 static int ath6kl_wmi_cac_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1333 struct wmi_cac_event
*reply
;
1334 struct ieee80211_tspec_ie
*ts
;
1335 u16 active_tsids
, tsinfo
;
1339 if (len
< sizeof(struct wmi_cac_event
))
1342 reply
= (struct wmi_cac_event
*) datap
;
1344 if ((reply
->cac_indication
== CAC_INDICATION_ADMISSION_RESP
) &&
1345 (reply
->status_code
!= IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED
)) {
1347 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1348 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1349 tsid
= (tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1350 IEEE80211_WMM_IE_TSPEC_TID_MASK
;
1352 ath6kl_wmi_delete_pstream_cmd(wmi
, reply
->ac
, tsid
);
1353 } else if (reply
->cac_indication
== CAC_INDICATION_NO_RESP
) {
1355 * Following assumes that there is only one outstanding
1356 * ADDTS request when this event is received
1358 spin_lock_bh(&wmi
->lock
);
1359 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1360 spin_unlock_bh(&wmi
->lock
);
1362 for (index
= 0; index
< sizeof(active_tsids
) * 8; index
++) {
1363 if ((active_tsids
>> index
) & 1)
1366 if (index
< (sizeof(active_tsids
) * 8))
1367 ath6kl_wmi_delete_pstream_cmd(wmi
, reply
->ac
, index
);
1371 * Clear active tsids and Add missing handling
1372 * for delete qos stream from AP
1374 else if (reply
->cac_indication
== CAC_INDICATION_DELETE
) {
1376 ts
= (struct ieee80211_tspec_ie
*) &(reply
->tspec_suggestion
);
1377 tsinfo
= le16_to_cpu(ts
->tsinfo
);
1378 ts_id
= ((tsinfo
>> IEEE80211_WMM_IE_TSPEC_TID_SHIFT
) &
1379 IEEE80211_WMM_IE_TSPEC_TID_MASK
);
1381 spin_lock_bh(&wmi
->lock
);
1382 wmi
->stream_exist_for_ac
[reply
->ac
] &= ~(1 << ts_id
);
1383 active_tsids
= wmi
->stream_exist_for_ac
[reply
->ac
];
1384 spin_unlock_bh(&wmi
->lock
);
1386 /* Indicate stream inactivity to driver layer only if all tsids
1387 * within this AC are deleted.
1389 if (!active_tsids
) {
1390 ath6kl_indicate_tx_activity(wmi
->parent_dev
, reply
->ac
,
1392 wmi
->fat_pipe_exist
&= ~(1 << reply
->ac
);
1399 static int ath6kl_wmi_send_snr_threshold_params(struct wmi
*wmi
,
1400 struct wmi_snr_threshold_params_cmd
*snr_cmd
)
1402 struct sk_buff
*skb
;
1403 struct wmi_snr_threshold_params_cmd
*cmd
;
1405 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1409 cmd
= (struct wmi_snr_threshold_params_cmd
*) skb
->data
;
1410 memcpy(cmd
, snr_cmd
, sizeof(struct wmi_snr_threshold_params_cmd
));
1412 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SNR_THRESHOLD_PARAMS_CMDID
,
1416 static int ath6kl_wmi_snr_threshold_event_rx(struct wmi
*wmi
, u8
*datap
,
1419 struct wmi_snr_threshold_event
*reply
;
1420 struct sq_threshold_params
*sq_thresh
;
1421 struct wmi_snr_threshold_params_cmd cmd
;
1422 enum wmi_snr_threshold_val new_threshold
;
1423 u8 upper_snr_threshold
, lower_snr_threshold
;
1427 if (len
< sizeof(struct wmi_snr_threshold_event
))
1430 reply
= (struct wmi_snr_threshold_event
*) datap
;
1432 new_threshold
= (enum wmi_snr_threshold_val
) reply
->range
;
1435 sq_thresh
= &wmi
->sq_threshld
[SIGNAL_QUALITY_METRICS_SNR
];
1438 * Identify the threshold breached and communicate that to the app.
1439 * After that install a new set of thresholds based on the signal
1440 * quality reported by the target.
1442 if (new_threshold
) {
1443 /* Upper threshold breached */
1444 if (snr
< sq_thresh
->upper_threshold
[0]) {
1445 ath6kl_dbg(ATH6KL_DBG_WMI
,
1446 "spurious upper snr threshold event: %d\n",
1448 } else if ((snr
< sq_thresh
->upper_threshold
[1]) &&
1449 (snr
>= sq_thresh
->upper_threshold
[0])) {
1450 new_threshold
= WMI_SNR_THRESHOLD1_ABOVE
;
1451 } else if ((snr
< sq_thresh
->upper_threshold
[2]) &&
1452 (snr
>= sq_thresh
->upper_threshold
[1])) {
1453 new_threshold
= WMI_SNR_THRESHOLD2_ABOVE
;
1454 } else if ((snr
< sq_thresh
->upper_threshold
[3]) &&
1455 (snr
>= sq_thresh
->upper_threshold
[2])) {
1456 new_threshold
= WMI_SNR_THRESHOLD3_ABOVE
;
1457 } else if (snr
>= sq_thresh
->upper_threshold
[3]) {
1458 new_threshold
= WMI_SNR_THRESHOLD4_ABOVE
;
1461 /* Lower threshold breached */
1462 if (snr
> sq_thresh
->lower_threshold
[0]) {
1463 ath6kl_dbg(ATH6KL_DBG_WMI
,
1464 "spurious lower snr threshold event: %d\n",
1465 sq_thresh
->lower_threshold
[0]);
1466 } else if ((snr
> sq_thresh
->lower_threshold
[1]) &&
1467 (snr
<= sq_thresh
->lower_threshold
[0])) {
1468 new_threshold
= WMI_SNR_THRESHOLD4_BELOW
;
1469 } else if ((snr
> sq_thresh
->lower_threshold
[2]) &&
1470 (snr
<= sq_thresh
->lower_threshold
[1])) {
1471 new_threshold
= WMI_SNR_THRESHOLD3_BELOW
;
1472 } else if ((snr
> sq_thresh
->lower_threshold
[3]) &&
1473 (snr
<= sq_thresh
->lower_threshold
[2])) {
1474 new_threshold
= WMI_SNR_THRESHOLD2_BELOW
;
1475 } else if (snr
<= sq_thresh
->lower_threshold
[3]) {
1476 new_threshold
= WMI_SNR_THRESHOLD1_BELOW
;
1480 /* Calculate and install the next set of thresholds */
1481 lower_snr_threshold
= ath6kl_wmi_get_lower_threshold(snr
, sq_thresh
,
1482 sq_thresh
->lower_threshold_valid_count
);
1483 upper_snr_threshold
= ath6kl_wmi_get_upper_threshold(snr
, sq_thresh
,
1484 sq_thresh
->upper_threshold_valid_count
);
1486 /* Issue a wmi command to install the thresholds */
1487 cmd
.thresh_above1_val
= upper_snr_threshold
;
1488 cmd
.thresh_below1_val
= lower_snr_threshold
;
1489 cmd
.weight
= sq_thresh
->weight
;
1490 cmd
.poll_time
= cpu_to_le32(sq_thresh
->polling_interval
);
1492 ath6kl_dbg(ATH6KL_DBG_WMI
,
1493 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1495 lower_snr_threshold
, upper_snr_threshold
);
1497 ret
= ath6kl_wmi_send_snr_threshold_params(wmi
, &cmd
);
1499 ath6kl_err("unable to configure snr threshold\n");
1506 static int ath6kl_wmi_aplist_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
1508 u16 ap_info_entry_size
;
1509 struct wmi_aplist_event
*ev
= (struct wmi_aplist_event
*) datap
;
1510 struct wmi_ap_info_v1
*ap_info_v1
;
1513 if (len
< sizeof(struct wmi_aplist_event
) ||
1514 ev
->ap_list_ver
!= APLIST_VER1
)
1517 ap_info_entry_size
= sizeof(struct wmi_ap_info_v1
);
1518 ap_info_v1
= (struct wmi_ap_info_v1
*) ev
->ap_list
;
1520 ath6kl_dbg(ATH6KL_DBG_WMI
,
1521 "number of APs in aplist event: %d\n", ev
->num_ap
);
1523 if (len
< (int) (sizeof(struct wmi_aplist_event
) +
1524 (ev
->num_ap
- 1) * ap_info_entry_size
))
1527 /* AP list version 1 contents */
1528 for (index
= 0; index
< ev
->num_ap
; index
++) {
1529 ath6kl_dbg(ATH6KL_DBG_WMI
, "AP#%d BSSID %pM Channel %d\n",
1530 index
, ap_info_v1
->bssid
, ap_info_v1
->channel
);
1537 int ath6kl_wmi_cmd_send(struct wmi
*wmi
, struct sk_buff
*skb
,
1538 enum wmi_cmd_id cmd_id
, enum wmi_sync_flag sync_flag
)
1540 struct wmi_cmd_hdr
*cmd_hdr
;
1541 enum htc_endpoint_id ep_id
= wmi
->ep_id
;
1544 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: cmd_id=%d\n", __func__
, cmd_id
);
1546 if (WARN_ON(skb
== NULL
))
1549 if (sync_flag
>= END_WMIFLAG
) {
1554 if ((sync_flag
== SYNC_BEFORE_WMIFLAG
) ||
1555 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1557 * Make sure all data currently queued is transmitted before
1558 * the cmd execution. Establish a new sync point.
1560 ath6kl_wmi_sync_point(wmi
);
1563 skb_push(skb
, sizeof(struct wmi_cmd_hdr
));
1565 cmd_hdr
= (struct wmi_cmd_hdr
*) skb
->data
;
1566 cmd_hdr
->cmd_id
= cpu_to_le16(cmd_id
);
1567 cmd_hdr
->info1
= 0; /* added for virtual interface */
1569 /* Only for OPT_TX_CMD, use BE endpoint. */
1570 if (cmd_id
== WMI_OPT_TX_FRAME_CMDID
) {
1571 ret
= ath6kl_wmi_data_hdr_add(wmi
, skb
, OPT_MSGTYPE
,
1572 false, false, 0, NULL
);
1577 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
, WMM_AC_BE
);
1580 ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
1582 if ((sync_flag
== SYNC_AFTER_WMIFLAG
) ||
1583 (sync_flag
== SYNC_BOTH_WMIFLAG
)) {
1585 * Make sure all new data queued waits for the command to
1586 * execute. Establish a new sync point.
1588 ath6kl_wmi_sync_point(wmi
);
1594 int ath6kl_wmi_connect_cmd(struct wmi
*wmi
, enum network_type nw_type
,
1595 enum dot11_auth_mode dot11_auth_mode
,
1596 enum auth_mode auth_mode
,
1597 enum crypto_type pairwise_crypto
,
1598 u8 pairwise_crypto_len
,
1599 enum crypto_type group_crypto
,
1600 u8 group_crypto_len
, int ssid_len
, u8
*ssid
,
1601 u8
*bssid
, u16 channel
, u32 ctrl_flags
)
1603 struct sk_buff
*skb
;
1604 struct wmi_connect_cmd
*cc
;
1607 wmi
->traffic_class
= 100;
1609 if ((pairwise_crypto
== NONE_CRYPT
) && (group_crypto
!= NONE_CRYPT
))
1612 if ((pairwise_crypto
!= NONE_CRYPT
) && (group_crypto
== NONE_CRYPT
))
1615 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd
));
1619 cc
= (struct wmi_connect_cmd
*) skb
->data
;
1622 memcpy(cc
->ssid
, ssid
, ssid_len
);
1624 cc
->ssid_len
= ssid_len
;
1625 cc
->nw_type
= nw_type
;
1626 cc
->dot11_auth_mode
= dot11_auth_mode
;
1627 cc
->auth_mode
= auth_mode
;
1628 cc
->prwise_crypto_type
= pairwise_crypto
;
1629 cc
->prwise_crypto_len
= pairwise_crypto_len
;
1630 cc
->grp_crypto_type
= group_crypto
;
1631 cc
->grp_crypto_len
= group_crypto_len
;
1632 cc
->ch
= cpu_to_le16(channel
);
1633 cc
->ctrl_flags
= cpu_to_le32(ctrl_flags
);
1636 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1638 wmi
->pair_crypto_type
= pairwise_crypto
;
1639 wmi
->grp_crypto_type
= group_crypto
;
1641 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_CONNECT_CMDID
, NO_SYNC_WMIFLAG
);
1646 int ath6kl_wmi_reconnect_cmd(struct wmi
*wmi
, u8
*bssid
, u16 channel
)
1648 struct sk_buff
*skb
;
1649 struct wmi_reconnect_cmd
*cc
;
1652 wmi
->traffic_class
= 100;
1654 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd
));
1658 cc
= (struct wmi_reconnect_cmd
*) skb
->data
;
1659 cc
->channel
= cpu_to_le16(channel
);
1662 memcpy(cc
->bssid
, bssid
, ETH_ALEN
);
1664 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RECONNECT_CMDID
,
1670 int ath6kl_wmi_disconnect_cmd(struct wmi
*wmi
)
1674 wmi
->traffic_class
= 100;
1676 /* Disconnect command does not need to do a SYNC before. */
1677 ret
= ath6kl_wmi_simple_cmd(wmi
, WMI_DISCONNECT_CMDID
);
1682 int ath6kl_wmi_startscan_cmd(struct wmi
*wmi
, enum wmi_scan_type scan_type
,
1683 u32 force_fgscan
, u32 is_legacy
,
1684 u32 home_dwell_time
, u32 force_scan_interval
,
1685 s8 num_chan
, u16
*ch_list
)
1687 struct sk_buff
*skb
;
1688 struct wmi_start_scan_cmd
*sc
;
1692 size
= sizeof(struct wmi_start_scan_cmd
);
1694 if ((scan_type
!= WMI_LONG_SCAN
) && (scan_type
!= WMI_SHORT_SCAN
))
1697 if (num_chan
> WMI_MAX_CHANNELS
)
1701 size
+= sizeof(u16
) * (num_chan
- 1);
1703 skb
= ath6kl_wmi_get_new_buf(size
);
1707 sc
= (struct wmi_start_scan_cmd
*) skb
->data
;
1708 sc
->scan_type
= scan_type
;
1709 sc
->force_fg_scan
= cpu_to_le32(force_fgscan
);
1710 sc
->is_legacy
= cpu_to_le32(is_legacy
);
1711 sc
->home_dwell_time
= cpu_to_le32(home_dwell_time
);
1712 sc
->force_scan_intvl
= cpu_to_le32(force_scan_interval
);
1713 sc
->num_ch
= num_chan
;
1716 memcpy(sc
->ch_list
, ch_list
, num_chan
* sizeof(u16
));
1718 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_START_SCAN_CMDID
,
1724 int ath6kl_wmi_scanparams_cmd(struct wmi
*wmi
, u16 fg_start_sec
,
1725 u16 fg_end_sec
, u16 bg_sec
,
1726 u16 minact_chdw_msec
, u16 maxact_chdw_msec
,
1727 u16 pas_chdw_msec
, u8 short_scan_ratio
,
1728 u8 scan_ctrl_flag
, u32 max_dfsch_act_time
,
1729 u16 maxact_scan_per_ssid
)
1731 struct sk_buff
*skb
;
1732 struct wmi_scan_params_cmd
*sc
;
1735 skb
= ath6kl_wmi_get_new_buf(sizeof(*sc
));
1739 sc
= (struct wmi_scan_params_cmd
*) skb
->data
;
1740 sc
->fg_start_period
= cpu_to_le16(fg_start_sec
);
1741 sc
->fg_end_period
= cpu_to_le16(fg_end_sec
);
1742 sc
->bg_period
= cpu_to_le16(bg_sec
);
1743 sc
->minact_chdwell_time
= cpu_to_le16(minact_chdw_msec
);
1744 sc
->maxact_chdwell_time
= cpu_to_le16(maxact_chdw_msec
);
1745 sc
->pas_chdwell_time
= cpu_to_le16(pas_chdw_msec
);
1746 sc
->short_scan_ratio
= short_scan_ratio
;
1747 sc
->scan_ctrl_flags
= scan_ctrl_flag
;
1748 sc
->max_dfsch_act_time
= cpu_to_le32(max_dfsch_act_time
);
1749 sc
->maxact_scan_per_ssid
= cpu_to_le16(maxact_scan_per_ssid
);
1751 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_SCAN_PARAMS_CMDID
,
1756 int ath6kl_wmi_bssfilter_cmd(struct wmi
*wmi
, u8 filter
, u32 ie_mask
)
1758 struct sk_buff
*skb
;
1759 struct wmi_bss_filter_cmd
*cmd
;
1762 if (filter
>= LAST_BSS_FILTER
)
1765 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1769 cmd
= (struct wmi_bss_filter_cmd
*) skb
->data
;
1770 cmd
->bss_filter
= filter
;
1771 cmd
->ie_mask
= cpu_to_le32(ie_mask
);
1773 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_BSS_FILTER_CMDID
,
1778 int ath6kl_wmi_probedssid_cmd(struct wmi
*wmi
, u8 index
, u8 flag
,
1779 u8 ssid_len
, u8
*ssid
)
1781 struct sk_buff
*skb
;
1782 struct wmi_probed_ssid_cmd
*cmd
;
1785 if (index
> MAX_PROBED_SSID_INDEX
)
1788 if (ssid_len
> sizeof(cmd
->ssid
))
1791 if ((flag
& (DISABLE_SSID_FLAG
| ANY_SSID_FLAG
)) && (ssid_len
> 0))
1794 if ((flag
& SPECIFIC_SSID_FLAG
) && !ssid_len
)
1797 if (flag
& SPECIFIC_SSID_FLAG
)
1798 wmi
->is_probe_ssid
= true;
1800 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1804 cmd
= (struct wmi_probed_ssid_cmd
*) skb
->data
;
1805 cmd
->entry_index
= index
;
1807 cmd
->ssid_len
= ssid_len
;
1808 memcpy(cmd
->ssid
, ssid
, ssid_len
);
1810 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_PROBED_SSID_CMDID
,
1815 int ath6kl_wmi_listeninterval_cmd(struct wmi
*wmi
, u16 listen_interval
,
1818 struct sk_buff
*skb
;
1819 struct wmi_listen_int_cmd
*cmd
;
1822 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1826 cmd
= (struct wmi_listen_int_cmd
*) skb
->data
;
1827 cmd
->listen_intvl
= cpu_to_le16(listen_interval
);
1828 cmd
->num_beacons
= cpu_to_le16(listen_beacons
);
1830 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_LISTEN_INT_CMDID
,
1835 int ath6kl_wmi_powermode_cmd(struct wmi
*wmi
, u8 pwr_mode
)
1837 struct sk_buff
*skb
;
1838 struct wmi_power_mode_cmd
*cmd
;
1841 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1845 cmd
= (struct wmi_power_mode_cmd
*) skb
->data
;
1846 cmd
->pwr_mode
= pwr_mode
;
1847 wmi
->pwr_mode
= pwr_mode
;
1849 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_POWER_MODE_CMDID
,
1854 int ath6kl_wmi_pmparams_cmd(struct wmi
*wmi
, u16 idle_period
,
1855 u16 ps_poll_num
, u16 dtim_policy
,
1856 u16 tx_wakeup_policy
, u16 num_tx_to_wakeup
,
1857 u16 ps_fail_event_policy
)
1859 struct sk_buff
*skb
;
1860 struct wmi_power_params_cmd
*pm
;
1863 skb
= ath6kl_wmi_get_new_buf(sizeof(*pm
));
1867 pm
= (struct wmi_power_params_cmd
*)skb
->data
;
1868 pm
->idle_period
= cpu_to_le16(idle_period
);
1869 pm
->pspoll_number
= cpu_to_le16(ps_poll_num
);
1870 pm
->dtim_policy
= cpu_to_le16(dtim_policy
);
1871 pm
->tx_wakeup_policy
= cpu_to_le16(tx_wakeup_policy
);
1872 pm
->num_tx_to_wakeup
= cpu_to_le16(num_tx_to_wakeup
);
1873 pm
->ps_fail_event_policy
= cpu_to_le16(ps_fail_event_policy
);
1875 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_POWER_PARAMS_CMDID
,
1880 int ath6kl_wmi_disctimeout_cmd(struct wmi
*wmi
, u8 timeout
)
1882 struct sk_buff
*skb
;
1883 struct wmi_disc_timeout_cmd
*cmd
;
1886 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1890 cmd
= (struct wmi_disc_timeout_cmd
*) skb
->data
;
1891 cmd
->discon_timeout
= timeout
;
1893 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_DISC_TIMEOUT_CMDID
,
1898 int ath6kl_wmi_addkey_cmd(struct wmi
*wmi
, u8 key_index
,
1899 enum crypto_type key_type
,
1900 u8 key_usage
, u8 key_len
,
1901 u8
*key_rsc
, u8
*key_material
,
1902 u8 key_op_ctrl
, u8
*mac_addr
,
1903 enum wmi_sync_flag sync_flag
)
1905 struct sk_buff
*skb
;
1906 struct wmi_add_cipher_key_cmd
*cmd
;
1909 ath6kl_dbg(ATH6KL_DBG_WMI
, "addkey cmd: key_index=%u key_type=%d "
1910 "key_usage=%d key_len=%d key_op_ctrl=%d\n",
1911 key_index
, key_type
, key_usage
, key_len
, key_op_ctrl
);
1913 if ((key_index
> WMI_MAX_KEY_INDEX
) || (key_len
> WMI_MAX_KEY_LEN
) ||
1914 (key_material
== NULL
))
1917 if ((WEP_CRYPT
!= key_type
) && (NULL
== key_rsc
))
1920 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1924 cmd
= (struct wmi_add_cipher_key_cmd
*) skb
->data
;
1925 cmd
->key_index
= key_index
;
1926 cmd
->key_type
= key_type
;
1927 cmd
->key_usage
= key_usage
;
1928 cmd
->key_len
= key_len
;
1929 memcpy(cmd
->key
, key_material
, key_len
);
1931 if (key_rsc
!= NULL
)
1932 memcpy(cmd
->key_rsc
, key_rsc
, sizeof(cmd
->key_rsc
));
1934 cmd
->key_op_ctrl
= key_op_ctrl
;
1937 memcpy(cmd
->key_mac_addr
, mac_addr
, ETH_ALEN
);
1939 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_ADD_CIPHER_KEY_CMDID
,
1945 int ath6kl_wmi_add_krk_cmd(struct wmi
*wmi
, u8
*krk
)
1947 struct sk_buff
*skb
;
1948 struct wmi_add_krk_cmd
*cmd
;
1951 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1955 cmd
= (struct wmi_add_krk_cmd
*) skb
->data
;
1956 memcpy(cmd
->krk
, krk
, WMI_KRK_LEN
);
1958 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_ADD_KRK_CMDID
, NO_SYNC_WMIFLAG
);
1963 int ath6kl_wmi_deletekey_cmd(struct wmi
*wmi
, u8 key_index
)
1965 struct sk_buff
*skb
;
1966 struct wmi_delete_cipher_key_cmd
*cmd
;
1969 if (key_index
> WMI_MAX_KEY_INDEX
)
1972 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
1976 cmd
= (struct wmi_delete_cipher_key_cmd
*) skb
->data
;
1977 cmd
->key_index
= key_index
;
1979 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DELETE_CIPHER_KEY_CMDID
,
1985 int ath6kl_wmi_setpmkid_cmd(struct wmi
*wmi
, const u8
*bssid
,
1986 const u8
*pmkid
, bool set
)
1988 struct sk_buff
*skb
;
1989 struct wmi_setpmkid_cmd
*cmd
;
1995 if (set
&& pmkid
== NULL
)
1998 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2002 cmd
= (struct wmi_setpmkid_cmd
*) skb
->data
;
2003 memcpy(cmd
->bssid
, bssid
, ETH_ALEN
);
2005 memcpy(cmd
->pmkid
, pmkid
, sizeof(cmd
->pmkid
));
2006 cmd
->enable
= PMKID_ENABLE
;
2008 memset(cmd
->pmkid
, 0, sizeof(cmd
->pmkid
));
2009 cmd
->enable
= PMKID_DISABLE
;
2012 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_PMKID_CMDID
,
2018 static int ath6kl_wmi_data_sync_send(struct wmi
*wmi
, struct sk_buff
*skb
,
2019 enum htc_endpoint_id ep_id
)
2021 struct wmi_data_hdr
*data_hdr
;
2024 if (WARN_ON(skb
== NULL
|| ep_id
== wmi
->ep_id
))
2027 skb_push(skb
, sizeof(struct wmi_data_hdr
));
2029 data_hdr
= (struct wmi_data_hdr
*) skb
->data
;
2030 data_hdr
->info
= SYNC_MSGTYPE
<< WMI_DATA_HDR_MSG_TYPE_SHIFT
;
2031 data_hdr
->info3
= 0;
2033 ret
= ath6kl_control_tx(wmi
->parent_dev
, skb
, ep_id
);
2038 static int ath6kl_wmi_sync_point(struct wmi
*wmi
)
2040 struct sk_buff
*skb
;
2041 struct wmi_sync_cmd
*cmd
;
2042 struct wmi_data_sync_bufs data_sync_bufs
[WMM_NUM_AC
];
2043 enum htc_endpoint_id ep_id
;
2044 u8 index
, num_pri_streams
= 0;
2047 memset(data_sync_bufs
, 0, sizeof(data_sync_bufs
));
2049 spin_lock_bh(&wmi
->lock
);
2051 for (index
= 0; index
< WMM_NUM_AC
; index
++) {
2052 if (wmi
->fat_pipe_exist
& (1 << index
)) {
2054 data_sync_bufs
[num_pri_streams
- 1].traffic_class
=
2059 spin_unlock_bh(&wmi
->lock
);
2061 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2067 cmd
= (struct wmi_sync_cmd
*) skb
->data
;
2070 * In the SYNC cmd sent on the control Ep, send a bitmap
2071 * of the data eps on which the Data Sync will be sent
2073 cmd
->data_sync_map
= wmi
->fat_pipe_exist
;
2075 for (index
= 0; index
< num_pri_streams
; index
++) {
2076 data_sync_bufs
[index
].skb
= ath6kl_buf_alloc(0);
2077 if (data_sync_bufs
[index
].skb
== NULL
) {
2084 * If buffer allocation for any of the dataSync fails,
2085 * then do not send the Synchronize cmd on the control ep
2091 * Send sync cmd followed by sync data messages on all
2092 * endpoints being used
2094 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SYNCHRONIZE_CMDID
,
2100 /* cmd buffer sent, we no longer own it */
2103 for (index
= 0; index
< num_pri_streams
; index
++) {
2105 if (WARN_ON(!data_sync_bufs
[index
].skb
))
2108 ep_id
= ath6kl_ac2_endpoint_id(wmi
->parent_dev
,
2109 data_sync_bufs
[index
].
2112 ath6kl_wmi_data_sync_send(wmi
, data_sync_bufs
[index
].skb
,
2118 data_sync_bufs
[index
].skb
= NULL
;
2122 /* free up any resources left over (possibly due to an error) */
2126 for (index
= 0; index
< num_pri_streams
; index
++) {
2127 if (data_sync_bufs
[index
].skb
!= NULL
) {
2128 dev_kfree_skb((struct sk_buff
*)data_sync_bufs
[index
].
2136 int ath6kl_wmi_create_pstream_cmd(struct wmi
*wmi
,
2137 struct wmi_create_pstream_cmd
*params
)
2139 struct sk_buff
*skb
;
2140 struct wmi_create_pstream_cmd
*cmd
;
2141 u8 fatpipe_exist_for_ac
= 0;
2143 s32 nominal_phy
= 0;
2146 if (!((params
->user_pri
< 8) &&
2147 (params
->user_pri
<= 0x7) &&
2148 (up_to_ac
[params
->user_pri
& 0x7] == params
->traffic_class
) &&
2149 (params
->traffic_direc
== UPLINK_TRAFFIC
||
2150 params
->traffic_direc
== DNLINK_TRAFFIC
||
2151 params
->traffic_direc
== BIDIR_TRAFFIC
) &&
2152 (params
->traffic_type
== TRAFFIC_TYPE_APERIODIC
||
2153 params
->traffic_type
== TRAFFIC_TYPE_PERIODIC
) &&
2154 (params
->voice_psc_cap
== DISABLE_FOR_THIS_AC
||
2155 params
->voice_psc_cap
== ENABLE_FOR_THIS_AC
||
2156 params
->voice_psc_cap
== ENABLE_FOR_ALL_AC
) &&
2157 (params
->tsid
== WMI_IMPLICIT_PSTREAM
||
2158 params
->tsid
<= WMI_MAX_THINSTREAM
))) {
2163 * Check nominal PHY rate is >= minimalPHY,
2164 * so that DUT can allow TSRS IE
2167 /* Get the physical rate (units of bps) */
2168 min_phy
= ((le32_to_cpu(params
->min_phy_rate
) / 1000) / 1000);
2170 /* Check minimal phy < nominal phy rate */
2171 if (params
->nominal_phy
>= min_phy
) {
2172 /* unit of 500 kbps */
2173 nominal_phy
= (params
->nominal_phy
* 1000) / 500;
2174 ath6kl_dbg(ATH6KL_DBG_WMI
,
2175 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2176 min_phy
, nominal_phy
);
2178 params
->nominal_phy
= nominal_phy
;
2180 params
->nominal_phy
= 0;
2183 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2187 ath6kl_dbg(ATH6KL_DBG_WMI
,
2188 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2189 params
->traffic_class
, params
->tsid
);
2191 cmd
= (struct wmi_create_pstream_cmd
*) skb
->data
;
2192 memcpy(cmd
, params
, sizeof(*cmd
));
2194 /* This is an implicitly created Fat pipe */
2195 if ((u32
) params
->tsid
== (u32
) WMI_IMPLICIT_PSTREAM
) {
2196 spin_lock_bh(&wmi
->lock
);
2197 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2198 (1 << params
->traffic_class
));
2199 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2200 spin_unlock_bh(&wmi
->lock
);
2202 /* explicitly created thin stream within a fat pipe */
2203 spin_lock_bh(&wmi
->lock
);
2204 fatpipe_exist_for_ac
= (wmi
->fat_pipe_exist
&
2205 (1 << params
->traffic_class
));
2206 wmi
->stream_exist_for_ac
[params
->traffic_class
] |=
2207 (1 << params
->tsid
);
2209 * If a thinstream becomes active, the fat pipe automatically
2212 wmi
->fat_pipe_exist
|= (1 << params
->traffic_class
);
2213 spin_unlock_bh(&wmi
->lock
);
2217 * Indicate activty change to driver layer only if this is the
2218 * first TSID to get created in this AC explicitly or an implicit
2219 * fat pipe is getting created.
2221 if (!fatpipe_exist_for_ac
)
2222 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2223 params
->traffic_class
, true);
2225 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_CREATE_PSTREAM_CMDID
,
2230 int ath6kl_wmi_delete_pstream_cmd(struct wmi
*wmi
, u8 traffic_class
, u8 tsid
)
2232 struct sk_buff
*skb
;
2233 struct wmi_delete_pstream_cmd
*cmd
;
2234 u16 active_tsids
= 0;
2237 if (traffic_class
> 3) {
2238 ath6kl_err("invalid traffic class: %d\n", traffic_class
);
2242 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2246 cmd
= (struct wmi_delete_pstream_cmd
*) skb
->data
;
2247 cmd
->traffic_class
= traffic_class
;
2250 spin_lock_bh(&wmi
->lock
);
2251 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2252 spin_unlock_bh(&wmi
->lock
);
2254 if (!(active_tsids
& (1 << tsid
))) {
2256 ath6kl_dbg(ATH6KL_DBG_WMI
,
2257 "TSID %d doesn't exist for traffic class: %d\n",
2258 tsid
, traffic_class
);
2262 ath6kl_dbg(ATH6KL_DBG_WMI
,
2263 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2264 traffic_class
, tsid
);
2266 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DELETE_PSTREAM_CMDID
,
2267 SYNC_BEFORE_WMIFLAG
);
2269 spin_lock_bh(&wmi
->lock
);
2270 wmi
->stream_exist_for_ac
[traffic_class
] &= ~(1 << tsid
);
2271 active_tsids
= wmi
->stream_exist_for_ac
[traffic_class
];
2272 spin_unlock_bh(&wmi
->lock
);
2275 * Indicate stream inactivity to driver layer only if all tsids
2276 * within this AC are deleted.
2278 if (!active_tsids
) {
2279 ath6kl_indicate_tx_activity(wmi
->parent_dev
,
2280 traffic_class
, false);
2281 wmi
->fat_pipe_exist
&= ~(1 << traffic_class
);
2287 int ath6kl_wmi_set_ip_cmd(struct wmi
*wmi
, struct wmi_set_ip_cmd
*ip_cmd
)
2289 struct sk_buff
*skb
;
2290 struct wmi_set_ip_cmd
*cmd
;
2293 /* Multicast address are not valid */
2294 if ((*((u8
*) &ip_cmd
->ips
[0]) >= 0xE0) ||
2295 (*((u8
*) &ip_cmd
->ips
[1]) >= 0xE0))
2298 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd
));
2302 cmd
= (struct wmi_set_ip_cmd
*) skb
->data
;
2303 memcpy(cmd
, ip_cmd
, sizeof(struct wmi_set_ip_cmd
));
2305 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_IP_CMDID
, NO_SYNC_WMIFLAG
);
2309 static int ath6kl_wmi_get_wow_list_event_rx(struct wmi
*wmi
, u8
* datap
,
2312 if (len
< sizeof(struct wmi_get_wow_list_reply
))
2318 static int ath6kl_wmi_cmd_send_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
,
2319 enum wmix_command_id cmd_id
,
2320 enum wmi_sync_flag sync_flag
)
2322 struct wmix_cmd_hdr
*cmd_hdr
;
2325 skb_push(skb
, sizeof(struct wmix_cmd_hdr
));
2327 cmd_hdr
= (struct wmix_cmd_hdr
*) skb
->data
;
2328 cmd_hdr
->cmd_id
= cpu_to_le32(cmd_id
);
2330 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_EXTENSION_CMDID
, sync_flag
);
2335 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi
*wmi
, u32 cookie
, u32 source
)
2337 struct sk_buff
*skb
;
2338 struct wmix_hb_challenge_resp_cmd
*cmd
;
2341 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2345 cmd
= (struct wmix_hb_challenge_resp_cmd
*) skb
->data
;
2346 cmd
->cookie
= cpu_to_le32(cookie
);
2347 cmd
->source
= cpu_to_le32(source
);
2349 ret
= ath6kl_wmi_cmd_send_xtnd(wmi
, skb
, WMIX_HB_CHALLENGE_RESP_CMDID
,
2354 int ath6kl_wmi_get_stats_cmd(struct wmi
*wmi
)
2356 return ath6kl_wmi_simple_cmd(wmi
, WMI_GET_STATISTICS_CMDID
);
2359 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi
*wmi
, u8 dbM
)
2361 struct sk_buff
*skb
;
2362 struct wmi_set_tx_pwr_cmd
*cmd
;
2365 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd
));
2369 cmd
= (struct wmi_set_tx_pwr_cmd
*) skb
->data
;
2372 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_TX_PWR_CMDID
,
2378 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi
*wmi
)
2380 return ath6kl_wmi_simple_cmd(wmi
, WMI_GET_TX_PWR_CMDID
);
2383 int ath6kl_wmi_set_lpreamble_cmd(struct wmi
*wmi
, u8 status
, u8 preamble_policy
)
2385 struct sk_buff
*skb
;
2386 struct wmi_set_lpreamble_cmd
*cmd
;
2389 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd
));
2393 cmd
= (struct wmi_set_lpreamble_cmd
*) skb
->data
;
2394 cmd
->status
= status
;
2395 cmd
->preamble_policy
= preamble_policy
;
2397 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_LPREAMBLE_CMDID
,
2402 int ath6kl_wmi_set_rts_cmd(struct wmi
*wmi
, u16 threshold
)
2404 struct sk_buff
*skb
;
2405 struct wmi_set_rts_cmd
*cmd
;
2408 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd
));
2412 cmd
= (struct wmi_set_rts_cmd
*) skb
->data
;
2413 cmd
->threshold
= cpu_to_le16(threshold
);
2415 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_RTS_CMDID
, NO_SYNC_WMIFLAG
);
2419 int ath6kl_wmi_set_wmm_txop(struct wmi
*wmi
, enum wmi_txop_cfg cfg
)
2421 struct sk_buff
*skb
;
2422 struct wmi_set_wmm_txop_cmd
*cmd
;
2425 if (!((cfg
== WMI_TXOP_DISABLED
) || (cfg
== WMI_TXOP_ENABLED
)))
2428 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd
));
2432 cmd
= (struct wmi_set_wmm_txop_cmd
*) skb
->data
;
2433 cmd
->txop_enable
= cfg
;
2435 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_WMM_TXOP_CMDID
,
2440 int ath6kl_wmi_set_keepalive_cmd(struct wmi
*wmi
, u8 keep_alive_intvl
)
2442 struct sk_buff
*skb
;
2443 struct wmi_set_keepalive_cmd
*cmd
;
2446 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2450 cmd
= (struct wmi_set_keepalive_cmd
*) skb
->data
;
2451 cmd
->keep_alive_intvl
= keep_alive_intvl
;
2452 wmi
->keep_alive_intvl
= keep_alive_intvl
;
2454 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_KEEPALIVE_CMDID
,
2459 s32
ath6kl_wmi_get_rate(s8 rate_index
)
2461 if (rate_index
== RATE_AUTO
)
2464 return wmi_rate_tbl
[(u32
) rate_index
][0];
2467 void ath6kl_wmi_node_return(struct wmi
*wmi
, struct bss
*bss
)
2470 wlan_node_return(&wmi
->parent_dev
->scan_table
, bss
);
2473 struct bss
*ath6kl_wmi_find_ssid_node(struct wmi
*wmi
, u8
* ssid
,
2474 u32 ssid_len
, bool is_wpa2
,
2477 struct bss
*node
= NULL
;
2479 node
= wlan_find_ssid_node(&wmi
->parent_dev
->scan_table
, ssid
,
2480 ssid_len
, is_wpa2
, match_ssid
);
2484 struct bss
*ath6kl_wmi_find_node(struct wmi
*wmi
, const u8
* mac_addr
)
2486 struct bss
*ni
= NULL
;
2488 ni
= wlan_find_node(&wmi
->parent_dev
->scan_table
, mac_addr
);
2493 void ath6kl_wmi_node_free(struct wmi
*wmi
, const u8
* mac_addr
)
2495 struct bss
*ni
= NULL
;
2497 ni
= wlan_find_node(&wmi
->parent_dev
->scan_table
, mac_addr
);
2499 wlan_node_reclaim(&wmi
->parent_dev
->scan_table
, ni
);
2504 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi
*wmi
, u8
*datap
,
2507 struct wmi_pmkid_list_reply
*reply
;
2510 if (len
< sizeof(struct wmi_pmkid_list_reply
))
2513 reply
= (struct wmi_pmkid_list_reply
*)datap
;
2514 expected_len
= sizeof(reply
->num_pmkid
) +
2515 le32_to_cpu(reply
->num_pmkid
) * WMI_PMKID_LEN
;
2517 if (len
< expected_len
)
2523 static int ath6kl_wmi_addba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2525 struct wmi_addba_req_event
*cmd
= (struct wmi_addba_req_event
*) datap
;
2527 aggr_recv_addba_req_evt(wmi
->parent_dev
, cmd
->tid
,
2528 le16_to_cpu(cmd
->st_seq_no
), cmd
->win_sz
);
2533 static int ath6kl_wmi_delba_req_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2535 struct wmi_delba_event
*cmd
= (struct wmi_delba_event
*) datap
;
2537 aggr_recv_delba_req_evt(wmi
->parent_dev
, cmd
->tid
);
2542 /* AP mode functions */
2544 int ath6kl_wmi_ap_profile_commit(struct wmi
*wmip
, struct wmi_connect_cmd
*p
)
2546 struct sk_buff
*skb
;
2547 struct wmi_connect_cmd
*cm
;
2550 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
2554 cm
= (struct wmi_connect_cmd
*) skb
->data
;
2555 memcpy(cm
, p
, sizeof(*cm
));
2557 res
= ath6kl_wmi_cmd_send(wmip
, skb
, WMI_AP_CONFIG_COMMIT_CMDID
,
2559 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: nw_type=%u auth_mode=%u ch=%u "
2560 "ctrl_flags=0x%x-> res=%d\n",
2561 __func__
, p
->nw_type
, p
->auth_mode
, le16_to_cpu(p
->ch
),
2562 le32_to_cpu(p
->ctrl_flags
), res
);
2566 int ath6kl_wmi_ap_set_mlme(struct wmi
*wmip
, u8 cmd
, const u8
*mac
, u16 reason
)
2568 struct sk_buff
*skb
;
2569 struct wmi_ap_set_mlme_cmd
*cm
;
2571 skb
= ath6kl_wmi_get_new_buf(sizeof(*cm
));
2575 cm
= (struct wmi_ap_set_mlme_cmd
*) skb
->data
;
2576 memcpy(cm
->mac
, mac
, ETH_ALEN
);
2577 cm
->reason
= cpu_to_le16(reason
);
2580 return ath6kl_wmi_cmd_send(wmip
, skb
, WMI_AP_SET_MLME_CMDID
,
2584 static int ath6kl_wmi_pspoll_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2586 struct wmi_pspoll_event
*ev
;
2588 if (len
< sizeof(struct wmi_pspoll_event
))
2591 ev
= (struct wmi_pspoll_event
*) datap
;
2593 ath6kl_pspoll_event(wmi
->parent_dev
, le16_to_cpu(ev
->aid
));
2598 static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi
*wmi
, u8
*datap
, int len
)
2600 ath6kl_dtimexpiry_event(wmi
->parent_dev
);
2605 int ath6kl_wmi_set_pvb_cmd(struct wmi
*wmi
, u16 aid
, bool flag
)
2607 struct sk_buff
*skb
;
2608 struct wmi_ap_set_pvb_cmd
*cmd
;
2611 skb
= ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd
));
2615 cmd
= (struct wmi_ap_set_pvb_cmd
*) skb
->data
;
2616 cmd
->aid
= cpu_to_le16(aid
);
2617 cmd
->flag
= cpu_to_le32(flag
);
2619 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_AP_SET_PVB_CMDID
,
2625 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi
*wmi
, u8 rx_meta_ver
,
2626 bool rx_dot11_hdr
, bool defrag_on_host
)
2628 struct sk_buff
*skb
;
2629 struct wmi_rx_frame_format_cmd
*cmd
;
2632 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2636 cmd
= (struct wmi_rx_frame_format_cmd
*) skb
->data
;
2637 cmd
->dot11_hdr
= rx_dot11_hdr
? 1 : 0;
2638 cmd
->defrag_on_host
= defrag_on_host
? 1 : 0;
2639 cmd
->meta_ver
= rx_meta_ver
;
2641 /* Delete the local aggr state, on host */
2642 ret
= ath6kl_wmi_cmd_send(wmi
, skb
, WMI_RX_FRAME_FORMAT_CMDID
,
2648 int ath6kl_wmi_set_appie_cmd(struct wmi
*wmi
, u8 mgmt_frm_type
, const u8
*ie
,
2651 struct sk_buff
*skb
;
2652 struct wmi_set_appie_cmd
*p
;
2654 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + ie_len
);
2658 ath6kl_dbg(ATH6KL_DBG_WMI
, "set_appie_cmd: mgmt_frm_type=%u "
2659 "ie_len=%u\n", mgmt_frm_type
, ie_len
);
2660 p
= (struct wmi_set_appie_cmd
*) skb
->data
;
2661 p
->mgmt_frm_type
= mgmt_frm_type
;
2663 memcpy(p
->ie_info
, ie
, ie_len
);
2664 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SET_APPIE_CMDID
,
2668 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi
*wmi
, bool disable
)
2670 struct sk_buff
*skb
;
2671 struct wmi_disable_11b_rates_cmd
*cmd
;
2673 skb
= ath6kl_wmi_get_new_buf(sizeof(*cmd
));
2677 ath6kl_dbg(ATH6KL_DBG_WMI
, "disable_11b_rates_cmd: disable=%u\n",
2679 cmd
= (struct wmi_disable_11b_rates_cmd
*) skb
->data
;
2680 cmd
->disable
= disable
? 1 : 0;
2682 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_DISABLE_11B_RATES_CMDID
,
2686 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi
*wmi
, u32 freq
, u32 dur
)
2688 struct sk_buff
*skb
;
2689 struct wmi_remain_on_chnl_cmd
*p
;
2691 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2695 ath6kl_dbg(ATH6KL_DBG_WMI
, "remain_on_chnl_cmd: freq=%u dur=%u\n",
2697 p
= (struct wmi_remain_on_chnl_cmd
*) skb
->data
;
2698 p
->freq
= cpu_to_le32(freq
);
2699 p
->duration
= cpu_to_le32(dur
);
2700 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_REMAIN_ON_CHNL_CMDID
,
2704 int ath6kl_wmi_send_action_cmd(struct wmi
*wmi
, u32 id
, u32 freq
, u32 wait
,
2705 const u8
*data
, u16 data_len
)
2707 struct sk_buff
*skb
;
2708 struct wmi_send_action_cmd
*p
;
2711 return -EINVAL
; /* Offload for wait not supported */
2713 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
2717 ath6kl_dbg(ATH6KL_DBG_WMI
, "send_action_cmd: id=%u freq=%u wait=%u "
2718 "len=%u\n", id
, freq
, wait
, data_len
);
2719 p
= (struct wmi_send_action_cmd
*) skb
->data
;
2720 p
->id
= cpu_to_le32(id
);
2721 p
->freq
= cpu_to_le32(freq
);
2722 p
->wait
= cpu_to_le32(wait
);
2723 p
->len
= cpu_to_le16(data_len
);
2724 memcpy(p
->data
, data
, data_len
);
2725 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SEND_ACTION_CMDID
,
2729 int ath6kl_wmi_send_probe_response_cmd(struct wmi
*wmi
, u32 freq
,
2731 const u8
*data
, u16 data_len
)
2733 struct sk_buff
*skb
;
2734 struct wmi_p2p_probe_response_cmd
*p
;
2736 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
) + data_len
);
2740 ath6kl_dbg(ATH6KL_DBG_WMI
, "send_probe_response_cmd: freq=%u dst=%pM "
2741 "len=%u\n", freq
, dst
, data_len
);
2742 p
= (struct wmi_p2p_probe_response_cmd
*) skb
->data
;
2743 p
->freq
= cpu_to_le32(freq
);
2744 memcpy(p
->destination_addr
, dst
, ETH_ALEN
);
2745 p
->len
= cpu_to_le16(data_len
);
2746 memcpy(p
->data
, data
, data_len
);
2747 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_SEND_PROBE_RESPONSE_CMDID
,
2751 int ath6kl_wmi_probe_report_req_cmd(struct wmi
*wmi
, bool enable
)
2753 struct sk_buff
*skb
;
2754 struct wmi_probe_req_report_cmd
*p
;
2756 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2760 ath6kl_dbg(ATH6KL_DBG_WMI
, "probe_report_req_cmd: enable=%u\n",
2762 p
= (struct wmi_probe_req_report_cmd
*) skb
->data
;
2763 p
->enable
= enable
? 1 : 0;
2764 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_PROBE_REQ_REPORT_CMDID
,
2768 int ath6kl_wmi_info_req_cmd(struct wmi
*wmi
, u32 info_req_flags
)
2770 struct sk_buff
*skb
;
2771 struct wmi_get_p2p_info
*p
;
2773 skb
= ath6kl_wmi_get_new_buf(sizeof(*p
));
2777 ath6kl_dbg(ATH6KL_DBG_WMI
, "info_req_cmd: flags=%x\n",
2779 p
= (struct wmi_get_p2p_info
*) skb
->data
;
2780 p
->info_req_flags
= cpu_to_le32(info_req_flags
);
2781 return ath6kl_wmi_cmd_send(wmi
, skb
, WMI_GET_P2P_INFO_CMDID
,
2785 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi
*wmi
)
2787 ath6kl_dbg(ATH6KL_DBG_WMI
, "cancel_remain_on_chnl_cmd\n");
2788 return ath6kl_wmi_simple_cmd(wmi
, WMI_CANCEL_REMAIN_ON_CHNL_CMDID
);
2791 static int ath6kl_wmi_control_rx_xtnd(struct wmi
*wmi
, struct sk_buff
*skb
)
2793 struct wmix_cmd_hdr
*cmd
;
2799 if (skb
->len
< sizeof(struct wmix_cmd_hdr
)) {
2800 ath6kl_err("bad packet 1\n");
2801 wmi
->stat
.cmd_len_err
++;
2805 cmd
= (struct wmix_cmd_hdr
*) skb
->data
;
2806 id
= le32_to_cpu(cmd
->cmd_id
);
2808 skb_pull(skb
, sizeof(struct wmix_cmd_hdr
));
2814 case WMIX_HB_CHALLENGE_RESP_EVENTID
:
2816 case WMIX_DBGLOG_EVENTID
:
2819 ath6kl_err("unknown cmd id 0x%x\n", id
);
2820 wmi
->stat
.cmd_id_err
++;
2829 int ath6kl_wmi_control_rx(struct wmi
*wmi
, struct sk_buff
*skb
)
2831 struct wmi_cmd_hdr
*cmd
;
2837 if (WARN_ON(skb
== NULL
))
2840 if (skb
->len
< sizeof(struct wmi_cmd_hdr
)) {
2841 ath6kl_err("bad packet 1\n");
2843 wmi
->stat
.cmd_len_err
++;
2847 cmd
= (struct wmi_cmd_hdr
*) skb
->data
;
2848 id
= le16_to_cpu(cmd
->cmd_id
);
2850 skb_pull(skb
, sizeof(struct wmi_cmd_hdr
));
2855 ath6kl_dbg(ATH6KL_DBG_WMI
, "%s: wmi id: %d\n", __func__
, id
);
2856 ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES
, "msg payload ", datap
, len
);
2859 case WMI_GET_BITRATE_CMDID
:
2860 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_BITRATE_CMDID\n");
2861 ret
= ath6kl_wmi_bitrate_reply_rx(wmi
, datap
, len
);
2863 case WMI_GET_CHANNEL_LIST_CMDID
:
2864 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_CHANNEL_LIST_CMDID\n");
2865 ret
= ath6kl_wmi_ch_list_reply_rx(wmi
, datap
, len
);
2867 case WMI_GET_TX_PWR_CMDID
:
2868 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_TX_PWR_CMDID\n");
2869 ret
= ath6kl_wmi_tx_pwr_reply_rx(wmi
, datap
, len
);
2871 case WMI_READY_EVENTID
:
2872 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_READY_EVENTID\n");
2873 ret
= ath6kl_wmi_ready_event_rx(wmi
, datap
, len
);
2875 case WMI_CONNECT_EVENTID
:
2876 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CONNECT_EVENTID\n");
2877 ret
= ath6kl_wmi_connect_event_rx(wmi
, datap
, len
);
2879 case WMI_DISCONNECT_EVENTID
:
2880 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DISCONNECT_EVENTID\n");
2881 ret
= ath6kl_wmi_disconnect_event_rx(wmi
, datap
, len
);
2883 case WMI_PEER_NODE_EVENTID
:
2884 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PEER_NODE_EVENTID\n");
2885 ret
= ath6kl_wmi_peer_node_event_rx(wmi
, datap
, len
);
2887 case WMI_TKIP_MICERR_EVENTID
:
2888 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TKIP_MICERR_EVENTID\n");
2889 ret
= ath6kl_wmi_tkip_micerr_event_rx(wmi
, datap
, len
);
2891 case WMI_BSSINFO_EVENTID
:
2892 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_BSSINFO_EVENTID\n");
2893 ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb
, datap
);
2894 ret
= ath6kl_wmi_bssinfo_event_rx(wmi
, skb
->data
, skb
->len
);
2896 case WMI_REGDOMAIN_EVENTID
:
2897 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REGDOMAIN_EVENTID\n");
2899 case WMI_PSTREAM_TIMEOUT_EVENTID
:
2900 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
2901 ret
= ath6kl_wmi_pstream_timeout_event_rx(wmi
, datap
, len
);
2903 case WMI_NEIGHBOR_REPORT_EVENTID
:
2904 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_NEIGHBOR_REPORT_EVENTID\n");
2906 case WMI_SCAN_COMPLETE_EVENTID
:
2907 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SCAN_COMPLETE_EVENTID\n");
2908 ret
= ath6kl_wmi_scan_complete_rx(wmi
, datap
, len
);
2910 case WMI_CMDERROR_EVENTID
:
2911 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CMDERROR_EVENTID\n");
2912 ret
= ath6kl_wmi_error_event_rx(wmi
, datap
, len
);
2914 case WMI_REPORT_STATISTICS_EVENTID
:
2915 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_STATISTICS_EVENTID\n");
2916 ret
= ath6kl_wmi_stats_event_rx(wmi
, datap
, len
);
2918 case WMI_RSSI_THRESHOLD_EVENTID
:
2919 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RSSI_THRESHOLD_EVENTID\n");
2920 ret
= ath6kl_wmi_rssi_threshold_event_rx(wmi
, datap
, len
);
2922 case WMI_ERROR_REPORT_EVENTID
:
2923 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ERROR_REPORT_EVENTID\n");
2925 case WMI_OPT_RX_FRAME_EVENTID
:
2926 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_OPT_RX_FRAME_EVENTID\n");
2927 ret
= ath6kl_wmi_opt_frame_event_rx(wmi
, datap
, len
);
2929 case WMI_REPORT_ROAM_TBL_EVENTID
:
2930 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_TBL_EVENTID\n");
2932 case WMI_EXTENSION_EVENTID
:
2933 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_EXTENSION_EVENTID\n");
2934 ret
= ath6kl_wmi_control_rx_xtnd(wmi
, skb
);
2936 case WMI_CAC_EVENTID
:
2937 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CAC_EVENTID\n");
2938 ret
= ath6kl_wmi_cac_event_rx(wmi
, datap
, len
);
2940 case WMI_CHANNEL_CHANGE_EVENTID
:
2941 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_CHANNEL_CHANGE_EVENTID\n");
2943 case WMI_REPORT_ROAM_DATA_EVENTID
:
2944 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REPORT_ROAM_DATA_EVENTID\n");
2946 case WMI_GET_FIXRATES_CMDID
:
2947 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_FIXRATES_CMDID\n");
2948 ret
= ath6kl_wmi_ratemask_reply_rx(wmi
, datap
, len
);
2950 case WMI_TX_RETRY_ERR_EVENTID
:
2951 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_RETRY_ERR_EVENTID\n");
2953 case WMI_SNR_THRESHOLD_EVENTID
:
2954 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SNR_THRESHOLD_EVENTID\n");
2955 ret
= ath6kl_wmi_snr_threshold_event_rx(wmi
, datap
, len
);
2957 case WMI_LQ_THRESHOLD_EVENTID
:
2958 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_LQ_THRESHOLD_EVENTID\n");
2960 case WMI_APLIST_EVENTID
:
2961 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_APLIST_EVENTID\n");
2962 ret
= ath6kl_wmi_aplist_event_rx(wmi
, datap
, len
);
2964 case WMI_GET_KEEPALIVE_CMDID
:
2965 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_KEEPALIVE_CMDID\n");
2966 ret
= ath6kl_wmi_keepalive_reply_rx(wmi
, datap
, len
);
2968 case WMI_GET_WOW_LIST_EVENTID
:
2969 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_WOW_LIST_EVENTID\n");
2970 ret
= ath6kl_wmi_get_wow_list_event_rx(wmi
, datap
, len
);
2972 case WMI_GET_PMKID_LIST_EVENTID
:
2973 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_GET_PMKID_LIST_EVENTID\n");
2974 ret
= ath6kl_wmi_get_pmkid_list_event_rx(wmi
, datap
, len
);
2976 case WMI_PSPOLL_EVENTID
:
2977 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_PSPOLL_EVENTID\n");
2978 ret
= ath6kl_wmi_pspoll_event_rx(wmi
, datap
, len
);
2980 case WMI_DTIMEXPIRY_EVENTID
:
2981 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DTIMEXPIRY_EVENTID\n");
2982 ret
= ath6kl_wmi_dtimexpiry_event_rx(wmi
, datap
, len
);
2984 case WMI_SET_PARAMS_REPLY_EVENTID
:
2985 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_SET_PARAMS_REPLY_EVENTID\n");
2987 case WMI_ADDBA_REQ_EVENTID
:
2988 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_REQ_EVENTID\n");
2989 ret
= ath6kl_wmi_addba_req_event_rx(wmi
, datap
, len
);
2991 case WMI_ADDBA_RESP_EVENTID
:
2992 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_ADDBA_RESP_EVENTID\n");
2994 case WMI_DELBA_REQ_EVENTID
:
2995 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_DELBA_REQ_EVENTID\n");
2996 ret
= ath6kl_wmi_delba_req_event_rx(wmi
, datap
, len
);
2998 case WMI_REPORT_BTCOEX_CONFIG_EVENTID
:
2999 ath6kl_dbg(ATH6KL_DBG_WMI
,
3000 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
3002 case WMI_REPORT_BTCOEX_STATS_EVENTID
:
3003 ath6kl_dbg(ATH6KL_DBG_WMI
,
3004 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
3006 case WMI_TX_COMPLETE_EVENTID
:
3007 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_COMPLETE_EVENTID\n");
3008 ret
= ath6kl_wmi_tx_complete_event_rx(datap
, len
);
3010 case WMI_REMAIN_ON_CHNL_EVENTID
:
3011 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_REMAIN_ON_CHNL_EVENTID\n");
3012 ret
= ath6kl_wmi_remain_on_chnl_event_rx(datap
, len
);
3014 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID
:
3015 ath6kl_dbg(ATH6KL_DBG_WMI
,
3016 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
3017 ret
= ath6kl_wmi_cancel_remain_on_chnl_event_rx(datap
, len
);
3019 case WMI_TX_STATUS_EVENTID
:
3020 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_TX_STATUS_EVENTID\n");
3021 ret
= ath6kl_wmi_tx_status_event_rx(datap
, len
);
3023 case WMI_RX_PROBE_REQ_EVENTID
:
3024 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_PROBE_REQ_EVENTID\n");
3025 ret
= ath6kl_wmi_rx_probe_req_event_rx(datap
, len
);
3027 case WMI_P2P_CAPABILITIES_EVENTID
:
3028 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_CAPABILITIES_EVENTID\n");
3029 ret
= ath6kl_wmi_p2p_capabilities_event_rx(datap
, len
);
3031 case WMI_RX_ACTION_EVENTID
:
3032 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_RX_ACTION_EVENTID\n");
3033 ret
= ath6kl_wmi_rx_action_event_rx(datap
, len
);
3035 case WMI_P2P_INFO_EVENTID
:
3036 ath6kl_dbg(ATH6KL_DBG_WMI
, "WMI_P2P_INFO_EVENTID\n");
3037 ret
= ath6kl_wmi_p2p_info_event_rx(datap
, len
);
3040 ath6kl_dbg(ATH6KL_DBG_WMI
, "unknown cmd id 0x%x\n", id
);
3041 wmi
->stat
.cmd_id_err
++;
3051 static void ath6kl_wmi_qos_state_init(struct wmi
*wmi
)
3056 spin_lock_bh(&wmi
->lock
);
3058 wmi
->fat_pipe_exist
= 0;
3059 memset(wmi
->stream_exist_for_ac
, 0, sizeof(wmi
->stream_exist_for_ac
));
3061 spin_unlock_bh(&wmi
->lock
);
3064 void *ath6kl_wmi_init(struct ath6kl
*dev
)
3068 wmi
= kzalloc(sizeof(struct wmi
), GFP_KERNEL
);
3072 spin_lock_init(&wmi
->lock
);
3074 wmi
->parent_dev
= dev
;
3076 ath6kl_wmi_qos_state_init(wmi
);
3078 wmi
->pwr_mode
= REC_POWER
;
3079 wmi
->phy_mode
= WMI_11G_MODE
;
3081 wmi
->pair_crypto_type
= NONE_CRYPT
;
3082 wmi
->grp_crypto_type
= NONE_CRYPT
;
3084 wmi
->ht_allowed
[A_BAND_24GHZ
] = 1;
3085 wmi
->ht_allowed
[A_BAND_5GHZ
] = 1;
3090 void ath6kl_wmi_shutdown(struct wmi
*wmi
)