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(struct wmi *wmi, u8 *datap,
431 struct wmi_remain_on_chnl_event *ev;
434 struct ieee80211_channel *chan;
435 struct ath6kl *ar = wmi->parent_dev;
437 if (len < sizeof(*ev))
440 ev = (struct wmi_remain_on_chnl_event *) datap;
441 freq = le32_to_cpu(ev->freq);
442 dur = le32_to_cpu(ev->duration);
443 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n",
445 chan = ieee80211_get_channel(ar->wdev->wiphy, freq);
447 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: Unknown channel "
448 "(freq=%u)\n", freq);
451 cfg80211_ready_on_channel(ar->net_dev, 1, chan, NL80211_CHAN_NO_HT,
457 static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi,
460 struct wmi_cancel_remain_on_chnl_event *ev;
463 struct ieee80211_channel *chan;
464 struct ath6kl *ar = wmi->parent_dev;
466 if (len < sizeof(*ev))
469 ev = (struct wmi_cancel_remain_on_chnl_event *) datap;
470 freq = le32_to_cpu(ev->freq);
471 dur = le32_to_cpu(ev->duration);
472 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: freq=%u dur=%u "
473 "status=%u\n", freq, dur, ev->status);
474 chan = ieee80211_get_channel(ar->wdev->wiphy, freq);
476 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl: Unknown "
477 "channel (freq=%u)\n", freq);
480 cfg80211_remain_on_channel_expired(ar->net_dev, 1, chan,
481 NL80211_CHAN_NO_HT, GFP_ATOMIC);
486 static int ath6kl_wmi_tx_status_event_rx(u8 *datap, int len)
488 struct wmi_tx_status_event *ev;
491 if (len < sizeof(*ev))
494 ev = (struct wmi_tx_status_event *) datap;
495 id = le32_to_cpu(ev->id);
496 ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n",
502 static int ath6kl_wmi_rx_probe_req_event_rx(u8 *datap, int len)
504 struct wmi_p2p_rx_probe_req_event *ev;
507 if (len < sizeof(*ev))
510 ev = (struct wmi_p2p_rx_probe_req_event *) datap;
511 dlen = le16_to_cpu(ev->len);
512 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_probe_req: len=%u\n",
518 static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len)
520 struct wmi_p2p_capabilities_event *ev;
523 if (len < sizeof(*ev))
526 ev = (struct wmi_p2p_capabilities_event *) datap;
527 dlen = le16_to_cpu(ev->len);
528 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen);
533 static int ath6kl_wmi_rx_action_event_rx(u8 *datap, int len)
535 struct wmi_rx_action_event *ev;
538 if (len < sizeof(*ev))
541 ev = (struct wmi_rx_action_event *) datap;
542 dlen = le16_to_cpu(ev->len);
543 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u\n", dlen);
548 static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len)
550 struct wmi_p2p_info_event *ev;
554 if (len < sizeof(*ev))
557 ev = (struct wmi_p2p_info_event *) datap;
558 flags = le32_to_cpu(ev->info_req_flags);
559 dlen = le16_to_cpu(ev->len);
560 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen);
562 if (flags & P2P_FLAG_CAPABILITIES_REQ) {
563 struct wmi_p2p_capabilities *cap;
564 if (dlen < sizeof(*cap))
566 cap = (struct wmi_p2p_capabilities *) ev->data;
567 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n",
571 if (flags & P2P_FLAG_MACADDR_REQ) {
572 struct wmi_p2p_macaddr *mac;
573 if (dlen < sizeof(*mac))
575 mac = (struct wmi_p2p_macaddr *) ev->data;
576 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n",
580 if (flags & P2P_FLAG_HMODEL_REQ) {
581 struct wmi_p2p_hmodel *mod;
582 if (dlen < sizeof(*mod))
584 mod = (struct wmi_p2p_hmodel *) ev->data;
585 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n",
587 mod->p2p_model ? "host" : "firmware");
592 static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size)
596 skb = ath6kl_buf_alloc(size);
602 memset(skb->data, 0, size);
607 /* Send a "simple" wmi command -- one with no arguments */
608 static int ath6kl_wmi_simple_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id)
613 skb = ath6kl_wmi_get_new_buf(0);
617 ret = ath6kl_wmi_cmd_send(wmi, skb, cmd_id, NO_SYNC_WMIFLAG);
622 static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len)
624 struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap;
626 if (len < sizeof(struct wmi_ready_event_2))
630 ath6kl_ready_event(wmi->parent_dev, ev->mac_addr,
631 le32_to_cpu(ev->sw_version),
632 le32_to_cpu(ev->abi_version));
637 static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len)
639 struct wmi_connect_event *ev;
642 if (len < sizeof(struct wmi_connect_event))
645 ev = (struct wmi_connect_event *) datap;
647 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: freq %d bssid %pM\n",
648 __func__, ev->ch, ev->bssid);
650 /* Start of assoc rsp IEs */
651 pie = ev->assoc_info + ev->beacon_ie_len +
652 ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */
654 /* End of assoc rsp IEs */
655 peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len +
660 case WLAN_EID_VENDOR_SPECIFIC:
661 if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 &&
662 pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) {
663 /* WMM OUT (00:50:F2) */
665 && pie[6] == WMM_PARAM_OUI_SUBTYPE)
666 wmi->is_wmm_enabled = true;
671 if (wmi->is_wmm_enabled)
677 ath6kl_connect_event(wmi->parent_dev, le16_to_cpu(ev->ch), ev->bssid,
678 le16_to_cpu(ev->listen_intvl),
679 le16_to_cpu(ev->beacon_intvl),
680 le32_to_cpu(ev->nw_type),
681 ev->beacon_ie_len, ev->assoc_req_len,
682 ev->assoc_resp_len, ev->assoc_info);
687 static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len)
689 struct wmi_disconnect_event *ev;
690 wmi->traffic_class = 100;
692 if (len < sizeof(struct wmi_disconnect_event))
695 ev = (struct wmi_disconnect_event *) datap;
697 wmi->is_wmm_enabled = false;
698 wmi->pair_crypto_type = NONE_CRYPT;
699 wmi->grp_crypto_type = NONE_CRYPT;
701 ath6kl_disconnect_event(wmi->parent_dev, ev->disconn_reason,
702 ev->bssid, ev->assoc_resp_len, ev->assoc_info,
703 le16_to_cpu(ev->proto_reason_status));
708 static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len)
710 struct wmi_peer_node_event *ev;
712 if (len < sizeof(struct wmi_peer_node_event))
715 ev = (struct wmi_peer_node_event *) datap;
717 if (ev->event_code == PEER_NODE_JOIN_EVENT)
718 ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n",
720 else if (ev->event_code == PEER_NODE_LEAVE_EVENT)
721 ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n",
727 static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len)
729 struct wmi_tkip_micerr_event *ev;
731 if (len < sizeof(struct wmi_tkip_micerr_event))
734 ev = (struct wmi_tkip_micerr_event *) datap;
736 ath6kl_tkip_micerr_event(wmi->parent_dev, ev->key_id, ev->is_mcast);
741 static int ath6kl_wlan_parse_beacon(u8 *buf, int frame_len,
742 struct ath6kl_common_ie *cie)
745 u8 elemid_ssid = false;
748 efrm = (u8 *) (frm + frame_len);
751 * beacon/probe response frame format
753 * [2] beacon interval
754 * [2] capability information
756 * [tlv] supported rates
757 * [tlv] country information
758 * [tlv] parameter set (FH/DS)
759 * [tlv] erp information
760 * [tlv] extended supported rates
763 * [tlv] Atheros Advanced Capabilities
765 if ((efrm - frm) < 12)
768 memset(cie, 0, sizeof(*cie));
770 cie->ie_tstamp = frm;
772 cie->ie_beaconInt = *(u16 *) frm;
774 cie->ie_capInfo = *(u16 *) frm;
786 case WLAN_EID_SUPP_RATES:
789 case WLAN_EID_COUNTRY:
790 cie->ie_country = frm;
792 case WLAN_EID_FH_PARAMS:
794 case WLAN_EID_DS_PARAMS:
795 cie->ie_chan = frm[2];
800 case WLAN_EID_IBSS_PARAMS:
802 case WLAN_EID_EXT_SUPP_RATES:
803 cie->ie_xrates = frm;
805 case WLAN_EID_ERP_INFO:
809 cie->ie_erp = frm[2];
814 case WLAN_EID_HT_CAPABILITY:
817 case WLAN_EID_HT_INFORMATION:
820 case WLAN_EID_VENDOR_SPECIFIC:
821 if (frm[1] > 3 && frm[2] == 0x00 && frm[3] == 0x50 &&
823 /* OUT Type (00:50:F2) */
825 if (frm[5] == WPA_OUI_TYPE) {
828 } else if (frm[5] == WMM_OUI_TYPE) {
831 } else if (frm[5] == WSC_OUT_TYPE) {
836 } else if (frm[1] > 3 && frm[2] == 0x00
837 && frm[3] == 0x03 && frm[4] == 0x7f
838 && frm[5] == ATH_OUI_TYPE) {
839 /* Atheros OUI (00:03:7f) */
849 if ((cie->ie_rates == NULL)
850 || (cie->ie_rates[1] > ATH6KL_RATE_MAXSIZE))
853 if ((cie->ie_ssid == NULL)
854 || (cie->ie_ssid[1] > IEEE80211_MAX_SSID_LEN))
860 static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len)
862 struct bss *bss = NULL;
863 struct wmi_bss_info_hdr *bih;
864 u8 cached_ssid_len = 0;
865 u8 cached_ssid[IEEE80211_MAX_SSID_LEN] = { 0 };
866 u8 beacon_ssid_len = 0;
873 if (len <= sizeof(struct wmi_bss_info_hdr))
876 bih = (struct wmi_bss_info_hdr *) datap;
877 bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid);
879 if (a_sle16_to_cpu(bih->rssi) > 0) {
883 bih->rssi = a_cpu_to_sle16(bss->ni_rssi);
886 buf = datap + sizeof(struct wmi_bss_info_hdr);
887 len -= sizeof(struct wmi_bss_info_hdr);
889 ath6kl_dbg(ATH6KL_DBG_WMI,
890 "bss info evt - ch %u, rssi %02x, bssid \"%pM\"\n",
891 bih->ch, a_sle16_to_cpu(bih->rssi), bih->bssid);
895 * Free up the node. We are about to allocate a new node.
896 * In case of hidden AP, beacon will not have ssid,
897 * but a directed probe response will have it,
898 * so cache the probe-resp-ssid if already present.
900 if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE)) {
901 ie_ssid = bss->ni_cie.ie_ssid;
902 if (ie_ssid && (ie_ssid[1] <= IEEE80211_MAX_SSID_LEN) &&
904 cached_ssid_len = ie_ssid[1];
905 memcpy(cached_ssid, ie_ssid + 2,
911 * Use the current average rssi of associated AP base on
913 * 1. Most os with GUI will update RSSI by
914 * ath6kl_wmi_get_stats_cmd() periodically.
915 * 2. ath6kl_wmi_get_stats_cmd(..) will be called when calling
916 * ath6kl_wmi_startscan_cmd(...)
917 * The average value of RSSI give end-user better feeling for
918 * instance value of scan result. It also sync up RSSI info
919 * in GUI between scan result and RSSI signal icon.
921 if (memcmp(wmi->parent_dev->bssid, bih->bssid, ETH_ALEN) == 0) {
922 bih->rssi = a_cpu_to_sle16(bss->ni_rssi);
923 bih->snr = bss->ni_snr;
926 wlan_node_reclaim(&wmi->parent_dev->scan_table, bss);
930 * beacon/probe response frame format
932 * [2] beacon interval
933 * [2] capability information
936 beacon_ssid_len = buf[SSID_IE_LEN_INDEX];
939 * If ssid is cached for this hidden AP, then change
940 * buffer len accordingly.
942 if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) &&
943 (cached_ssid_len != 0) &&
944 (beacon_ssid_len == 0 || (cached_ssid_len > beacon_ssid_len &&
945 buf[SSID_IE_LEN_INDEX + 1] == 0))) {
947 len += (cached_ssid_len - beacon_ssid_len);
950 bss = wlan_node_alloc(len);
954 bss->ni_snr = bih->snr;
955 bss->ni_rssi = a_sle16_to_cpu(bih->rssi);
957 if (WARN_ON(!bss->ni_buf))
961 * In case of hidden AP, beacon will not have ssid,
962 * but a directed probe response will have it,
963 * so place the cached-ssid(probe-resp) in the bss info.
965 if (wmi->is_probe_ssid && (bih->frame_type == BEACON_FTYPE) &&
966 (cached_ssid_len != 0) &&
967 (beacon_ssid_len == 0 || (beacon_ssid_len &&
968 buf[SSID_IE_LEN_INDEX + 1] == 0))) {
969 ni_buf = bss->ni_buf;
973 * Copy the first 14 bytes:
974 * time-stamp(8), beacon-interval(2),
975 * cap-info(2), ssid-id(1), ssid-len(1).
977 memcpy(ni_buf, buf, SSID_IE_LEN_INDEX + 1);
979 ni_buf[SSID_IE_LEN_INDEX] = cached_ssid_len;
980 ni_buf += (SSID_IE_LEN_INDEX + 1);
982 buf += (SSID_IE_LEN_INDEX + 1);
983 buf_len -= (SSID_IE_LEN_INDEX + 1);
985 memcpy(ni_buf, cached_ssid, cached_ssid_len);
986 ni_buf += cached_ssid_len;
988 buf += beacon_ssid_len;
989 buf_len -= beacon_ssid_len;
991 if (cached_ssid_len > beacon_ssid_len)
992 buf_len -= (cached_ssid_len - beacon_ssid_len);
994 memcpy(ni_buf, buf, buf_len);
996 memcpy(bss->ni_buf, buf, len);
998 bss->ni_framelen = len;
1000 ret = ath6kl_wlan_parse_beacon(bss->ni_buf, len, &bss->ni_cie);
1002 wlan_node_free(bss);
1007 * Update the frequency in ie_chan, overwriting of channel number
1008 * which is done in ath6kl_wlan_parse_beacon
1010 bss->ni_cie.ie_chan = le16_to_cpu(bih->ch);
1011 wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid);
1016 static int ath6kl_wmi_opt_frame_event_rx(struct wmi *wmi, u8 *datap, int len)
1019 struct wmi_opt_rx_info_hdr *bih;
1022 if (len <= sizeof(struct wmi_opt_rx_info_hdr))
1025 bih = (struct wmi_opt_rx_info_hdr *) datap;
1026 buf = datap + sizeof(struct wmi_opt_rx_info_hdr);
1027 len -= sizeof(struct wmi_opt_rx_info_hdr);
1029 ath6kl_dbg(ATH6KL_DBG_WMI, "opt frame event %2.2x:%2.2x\n",
1030 bih->bssid[4], bih->bssid[5]);
1032 bss = wlan_find_node(&wmi->parent_dev->scan_table, bih->bssid);
1034 /* Free up the node. We are about to allocate a new node. */
1035 wlan_node_reclaim(&wmi->parent_dev->scan_table, bss);
1038 bss = wlan_node_alloc(len);
1042 bss->ni_snr = bih->snr;
1043 bss->ni_cie.ie_chan = le16_to_cpu(bih->ch);
1045 if (WARN_ON(!bss->ni_buf))
1048 memcpy(bss->ni_buf, buf, len);
1049 wlan_setup_node(&wmi->parent_dev->scan_table, bss, bih->bssid);
1054 /* Inactivity timeout of a fatpipe(pstream) at the target */
1055 static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap,
1058 struct wmi_pstream_timeout_event *ev;
1060 if (len < sizeof(struct wmi_pstream_timeout_event))
1063 ev = (struct wmi_pstream_timeout_event *) datap;
1066 * When the pstream (fat pipe == AC) timesout, it means there were
1067 * no thinStreams within this pstream & it got implicitly created
1068 * due to data flow on this AC. We start the inactivity timer only
1069 * for implicitly created pstream. Just reset the host state.
1071 spin_lock_bh(&wmi->lock);
1072 wmi->stream_exist_for_ac[ev->traffic_class] = 0;
1073 wmi->fat_pipe_exist &= ~(1 << ev->traffic_class);
1074 spin_unlock_bh(&wmi->lock);
1076 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1077 ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false);
1082 static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len)
1084 struct wmi_bit_rate_reply *reply;
1088 if (len < sizeof(struct wmi_bit_rate_reply))
1091 reply = (struct wmi_bit_rate_reply *) datap;
1093 ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index);
1095 if (reply->rate_index == (s8) RATE_AUTO) {
1098 index = reply->rate_index & 0x7f;
1099 sgi = (reply->rate_index & 0x80) ? 1 : 0;
1100 rate = wmi_rate_tbl[index][sgi];
1103 ath6kl_wakeup_event(wmi->parent_dev);
1108 static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len)
1110 if (len < sizeof(struct wmi_fix_rates_reply))
1113 ath6kl_wakeup_event(wmi->parent_dev);
1118 static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len)
1120 if (len < sizeof(struct wmi_channel_list_reply))
1123 ath6kl_wakeup_event(wmi->parent_dev);
1128 static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len)
1130 struct wmi_tx_pwr_reply *reply;
1132 if (len < sizeof(struct wmi_tx_pwr_reply))
1135 reply = (struct wmi_tx_pwr_reply *) datap;
1136 ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM);
1141 static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len)
1143 if (len < sizeof(struct wmi_get_keepalive_cmd))
1146 ath6kl_wakeup_event(wmi->parent_dev);
1151 static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len)
1153 struct wmi_scan_complete_event *ev;
1155 ev = (struct wmi_scan_complete_event *) datap;
1157 if (a_sle32_to_cpu(ev->status) == 0)
1158 wlan_refresh_inactive_nodes(wmi->parent_dev);
1160 ath6kl_scan_complete_evt(wmi->parent_dev, a_sle32_to_cpu(ev->status));
1161 wmi->is_probe_ssid = false;
1167 * Target is reporting a programming error. This is for
1168 * developer aid only. Target only checks a few common violations
1169 * and it is responsibility of host to do all error checking.
1170 * Behavior of target after wmi error event is undefined.
1171 * A reset is recommended.
1173 static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len)
1175 const char *type = "unknown error";
1176 struct wmi_cmd_error_event *ev;
1177 ev = (struct wmi_cmd_error_event *) datap;
1179 switch (ev->err_code) {
1181 type = "invalid parameter";
1184 type = "invalid state";
1186 case INTERNAL_ERROR:
1187 type = "internal error";
1191 ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n",
1197 static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len)
1199 ath6kl_tgt_stats_event(wmi->parent_dev, datap, len);
1204 static u8 ath6kl_wmi_get_upper_threshold(s16 rssi,
1205 struct sq_threshold_params *sq_thresh,
1209 u8 threshold = (u8) sq_thresh->upper_threshold[size - 1];
1211 /* The list is already in sorted order. Get the next lower value */
1212 for (index = 0; index < size; index++) {
1213 if (rssi < sq_thresh->upper_threshold[index]) {
1214 threshold = (u8) sq_thresh->upper_threshold[index];
1222 static u8 ath6kl_wmi_get_lower_threshold(s16 rssi,
1223 struct sq_threshold_params *sq_thresh,
1227 u8 threshold = (u8) sq_thresh->lower_threshold[size - 1];
1229 /* The list is already in sorted order. Get the next lower value */
1230 for (index = 0; index < size; index++) {
1231 if (rssi > sq_thresh->lower_threshold[index]) {
1232 threshold = (u8) sq_thresh->lower_threshold[index];
1240 static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi,
1241 struct wmi_rssi_threshold_params_cmd *rssi_cmd)
1243 struct sk_buff *skb;
1244 struct wmi_rssi_threshold_params_cmd *cmd;
1246 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1250 cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data;
1251 memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd));
1253 return ath6kl_wmi_cmd_send(wmi, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID,
1257 static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap,
1260 struct wmi_rssi_threshold_event *reply;
1261 struct wmi_rssi_threshold_params_cmd cmd;
1262 struct sq_threshold_params *sq_thresh;
1263 enum wmi_rssi_threshold_val new_threshold;
1264 u8 upper_rssi_threshold, lower_rssi_threshold;
1268 if (len < sizeof(struct wmi_rssi_threshold_event))
1271 reply = (struct wmi_rssi_threshold_event *) datap;
1272 new_threshold = (enum wmi_rssi_threshold_val) reply->range;
1273 rssi = a_sle16_to_cpu(reply->rssi);
1275 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI];
1278 * Identify the threshold breached and communicate that to the app.
1279 * After that install a new set of thresholds based on the signal
1280 * quality reported by the target
1282 if (new_threshold) {
1283 /* Upper threshold breached */
1284 if (rssi < sq_thresh->upper_threshold[0]) {
1285 ath6kl_dbg(ATH6KL_DBG_WMI,
1286 "spurious upper rssi threshold event: %d\n",
1288 } else if ((rssi < sq_thresh->upper_threshold[1]) &&
1289 (rssi >= sq_thresh->upper_threshold[0])) {
1290 new_threshold = WMI_RSSI_THRESHOLD1_ABOVE;
1291 } else if ((rssi < sq_thresh->upper_threshold[2]) &&
1292 (rssi >= sq_thresh->upper_threshold[1])) {
1293 new_threshold = WMI_RSSI_THRESHOLD2_ABOVE;
1294 } else if ((rssi < sq_thresh->upper_threshold[3]) &&
1295 (rssi >= sq_thresh->upper_threshold[2])) {
1296 new_threshold = WMI_RSSI_THRESHOLD3_ABOVE;
1297 } else if ((rssi < sq_thresh->upper_threshold[4]) &&
1298 (rssi >= sq_thresh->upper_threshold[3])) {
1299 new_threshold = WMI_RSSI_THRESHOLD4_ABOVE;
1300 } else if ((rssi < sq_thresh->upper_threshold[5]) &&
1301 (rssi >= sq_thresh->upper_threshold[4])) {
1302 new_threshold = WMI_RSSI_THRESHOLD5_ABOVE;
1303 } else if (rssi >= sq_thresh->upper_threshold[5]) {
1304 new_threshold = WMI_RSSI_THRESHOLD6_ABOVE;
1307 /* Lower threshold breached */
1308 if (rssi > sq_thresh->lower_threshold[0]) {
1309 ath6kl_dbg(ATH6KL_DBG_WMI,
1310 "spurious lower rssi threshold event: %d %d\n",
1311 rssi, sq_thresh->lower_threshold[0]);
1312 } else if ((rssi > sq_thresh->lower_threshold[1]) &&
1313 (rssi <= sq_thresh->lower_threshold[0])) {
1314 new_threshold = WMI_RSSI_THRESHOLD6_BELOW;
1315 } else if ((rssi > sq_thresh->lower_threshold[2]) &&
1316 (rssi <= sq_thresh->lower_threshold[1])) {
1317 new_threshold = WMI_RSSI_THRESHOLD5_BELOW;
1318 } else if ((rssi > sq_thresh->lower_threshold[3]) &&
1319 (rssi <= sq_thresh->lower_threshold[2])) {
1320 new_threshold = WMI_RSSI_THRESHOLD4_BELOW;
1321 } else if ((rssi > sq_thresh->lower_threshold[4]) &&
1322 (rssi <= sq_thresh->lower_threshold[3])) {
1323 new_threshold = WMI_RSSI_THRESHOLD3_BELOW;
1324 } else if ((rssi > sq_thresh->lower_threshold[5]) &&
1325 (rssi <= sq_thresh->lower_threshold[4])) {
1326 new_threshold = WMI_RSSI_THRESHOLD2_BELOW;
1327 } else if (rssi <= sq_thresh->lower_threshold[5]) {
1328 new_threshold = WMI_RSSI_THRESHOLD1_BELOW;
1332 /* Calculate and install the next set of thresholds */
1333 lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh,
1334 sq_thresh->lower_threshold_valid_count);
1335 upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh,
1336 sq_thresh->upper_threshold_valid_count);
1338 /* Issue a wmi command to install the thresholds */
1339 cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold);
1340 cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold);
1341 cmd.weight = sq_thresh->weight;
1342 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1344 ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd);
1346 ath6kl_err("unable to configure rssi thresholds\n");
1353 static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len)
1355 struct wmi_cac_event *reply;
1356 struct ieee80211_tspec_ie *ts;
1357 u16 active_tsids, tsinfo;
1361 if (len < sizeof(struct wmi_cac_event))
1364 reply = (struct wmi_cac_event *) datap;
1366 if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) &&
1367 (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) {
1369 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1370 tsinfo = le16_to_cpu(ts->tsinfo);
1371 tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1372 IEEE80211_WMM_IE_TSPEC_TID_MASK;
1374 ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, tsid);
1375 } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) {
1377 * Following assumes that there is only one outstanding
1378 * ADDTS request when this event is received
1380 spin_lock_bh(&wmi->lock);
1381 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1382 spin_unlock_bh(&wmi->lock);
1384 for (index = 0; index < sizeof(active_tsids) * 8; index++) {
1385 if ((active_tsids >> index) & 1)
1388 if (index < (sizeof(active_tsids) * 8))
1389 ath6kl_wmi_delete_pstream_cmd(wmi, reply->ac, index);
1393 * Clear active tsids and Add missing handling
1394 * for delete qos stream from AP
1396 else if (reply->cac_indication == CAC_INDICATION_DELETE) {
1398 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1399 tsinfo = le16_to_cpu(ts->tsinfo);
1400 ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1401 IEEE80211_WMM_IE_TSPEC_TID_MASK);
1403 spin_lock_bh(&wmi->lock);
1404 wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id);
1405 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1406 spin_unlock_bh(&wmi->lock);
1408 /* Indicate stream inactivity to driver layer only if all tsids
1409 * within this AC are deleted.
1411 if (!active_tsids) {
1412 ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac,
1414 wmi->fat_pipe_exist &= ~(1 << reply->ac);
1421 static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi,
1422 struct wmi_snr_threshold_params_cmd *snr_cmd)
1424 struct sk_buff *skb;
1425 struct wmi_snr_threshold_params_cmd *cmd;
1427 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1431 cmd = (struct wmi_snr_threshold_params_cmd *) skb->data;
1432 memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd));
1434 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID,
1438 static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap,
1441 struct wmi_snr_threshold_event *reply;
1442 struct sq_threshold_params *sq_thresh;
1443 struct wmi_snr_threshold_params_cmd cmd;
1444 enum wmi_snr_threshold_val new_threshold;
1445 u8 upper_snr_threshold, lower_snr_threshold;
1449 if (len < sizeof(struct wmi_snr_threshold_event))
1452 reply = (struct wmi_snr_threshold_event *) datap;
1454 new_threshold = (enum wmi_snr_threshold_val) reply->range;
1457 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR];
1460 * Identify the threshold breached and communicate that to the app.
1461 * After that install a new set of thresholds based on the signal
1462 * quality reported by the target.
1464 if (new_threshold) {
1465 /* Upper threshold breached */
1466 if (snr < sq_thresh->upper_threshold[0]) {
1467 ath6kl_dbg(ATH6KL_DBG_WMI,
1468 "spurious upper snr threshold event: %d\n",
1470 } else if ((snr < sq_thresh->upper_threshold[1]) &&
1471 (snr >= sq_thresh->upper_threshold[0])) {
1472 new_threshold = WMI_SNR_THRESHOLD1_ABOVE;
1473 } else if ((snr < sq_thresh->upper_threshold[2]) &&
1474 (snr >= sq_thresh->upper_threshold[1])) {
1475 new_threshold = WMI_SNR_THRESHOLD2_ABOVE;
1476 } else if ((snr < sq_thresh->upper_threshold[3]) &&
1477 (snr >= sq_thresh->upper_threshold[2])) {
1478 new_threshold = WMI_SNR_THRESHOLD3_ABOVE;
1479 } else if (snr >= sq_thresh->upper_threshold[3]) {
1480 new_threshold = WMI_SNR_THRESHOLD4_ABOVE;
1483 /* Lower threshold breached */
1484 if (snr > sq_thresh->lower_threshold[0]) {
1485 ath6kl_dbg(ATH6KL_DBG_WMI,
1486 "spurious lower snr threshold event: %d\n",
1487 sq_thresh->lower_threshold[0]);
1488 } else if ((snr > sq_thresh->lower_threshold[1]) &&
1489 (snr <= sq_thresh->lower_threshold[0])) {
1490 new_threshold = WMI_SNR_THRESHOLD4_BELOW;
1491 } else if ((snr > sq_thresh->lower_threshold[2]) &&
1492 (snr <= sq_thresh->lower_threshold[1])) {
1493 new_threshold = WMI_SNR_THRESHOLD3_BELOW;
1494 } else if ((snr > sq_thresh->lower_threshold[3]) &&
1495 (snr <= sq_thresh->lower_threshold[2])) {
1496 new_threshold = WMI_SNR_THRESHOLD2_BELOW;
1497 } else if (snr <= sq_thresh->lower_threshold[3]) {
1498 new_threshold = WMI_SNR_THRESHOLD1_BELOW;
1502 /* Calculate and install the next set of thresholds */
1503 lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh,
1504 sq_thresh->lower_threshold_valid_count);
1505 upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh,
1506 sq_thresh->upper_threshold_valid_count);
1508 /* Issue a wmi command to install the thresholds */
1509 cmd.thresh_above1_val = upper_snr_threshold;
1510 cmd.thresh_below1_val = lower_snr_threshold;
1511 cmd.weight = sq_thresh->weight;
1512 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1514 ath6kl_dbg(ATH6KL_DBG_WMI,
1515 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1517 lower_snr_threshold, upper_snr_threshold);
1519 ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd);
1521 ath6kl_err("unable to configure snr threshold\n");
1528 static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len)
1530 u16 ap_info_entry_size;
1531 struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap;
1532 struct wmi_ap_info_v1 *ap_info_v1;
1535 if (len < sizeof(struct wmi_aplist_event) ||
1536 ev->ap_list_ver != APLIST_VER1)
1539 ap_info_entry_size = sizeof(struct wmi_ap_info_v1);
1540 ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list;
1542 ath6kl_dbg(ATH6KL_DBG_WMI,
1543 "number of APs in aplist event: %d\n", ev->num_ap);
1545 if (len < (int) (sizeof(struct wmi_aplist_event) +
1546 (ev->num_ap - 1) * ap_info_entry_size))
1549 /* AP list version 1 contents */
1550 for (index = 0; index < ev->num_ap; index++) {
1551 ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n",
1552 index, ap_info_v1->bssid, ap_info_v1->channel);
1559 int ath6kl_wmi_cmd_send(struct wmi *wmi, struct sk_buff *skb,
1560 enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag)
1562 struct wmi_cmd_hdr *cmd_hdr;
1563 enum htc_endpoint_id ep_id = wmi->ep_id;
1566 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: cmd_id=%d\n", __func__, cmd_id);
1568 if (WARN_ON(skb == NULL))
1571 if (sync_flag >= END_WMIFLAG) {
1576 if ((sync_flag == SYNC_BEFORE_WMIFLAG) ||
1577 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1579 * Make sure all data currently queued is transmitted before
1580 * the cmd execution. Establish a new sync point.
1582 ath6kl_wmi_sync_point(wmi);
1585 skb_push(skb, sizeof(struct wmi_cmd_hdr));
1587 cmd_hdr = (struct wmi_cmd_hdr *) skb->data;
1588 cmd_hdr->cmd_id = cpu_to_le16(cmd_id);
1589 cmd_hdr->info1 = 0; /* added for virtual interface */
1591 /* Only for OPT_TX_CMD, use BE endpoint. */
1592 if (cmd_id == WMI_OPT_TX_FRAME_CMDID) {
1593 ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE,
1594 false, false, 0, NULL);
1599 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE);
1602 ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
1604 if ((sync_flag == SYNC_AFTER_WMIFLAG) ||
1605 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1607 * Make sure all new data queued waits for the command to
1608 * execute. Establish a new sync point.
1610 ath6kl_wmi_sync_point(wmi);
1616 int ath6kl_wmi_connect_cmd(struct wmi *wmi, enum network_type nw_type,
1617 enum dot11_auth_mode dot11_auth_mode,
1618 enum auth_mode auth_mode,
1619 enum crypto_type pairwise_crypto,
1620 u8 pairwise_crypto_len,
1621 enum crypto_type group_crypto,
1622 u8 group_crypto_len, int ssid_len, u8 *ssid,
1623 u8 *bssid, u16 channel, u32 ctrl_flags)
1625 struct sk_buff *skb;
1626 struct wmi_connect_cmd *cc;
1629 wmi->traffic_class = 100;
1631 if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT))
1634 if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT))
1637 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd));
1641 cc = (struct wmi_connect_cmd *) skb->data;
1644 memcpy(cc->ssid, ssid, ssid_len);
1646 cc->ssid_len = ssid_len;
1647 cc->nw_type = nw_type;
1648 cc->dot11_auth_mode = dot11_auth_mode;
1649 cc->auth_mode = auth_mode;
1650 cc->prwise_crypto_type = pairwise_crypto;
1651 cc->prwise_crypto_len = pairwise_crypto_len;
1652 cc->grp_crypto_type = group_crypto;
1653 cc->grp_crypto_len = group_crypto_len;
1654 cc->ch = cpu_to_le16(channel);
1655 cc->ctrl_flags = cpu_to_le32(ctrl_flags);
1658 memcpy(cc->bssid, bssid, ETH_ALEN);
1660 wmi->pair_crypto_type = pairwise_crypto;
1661 wmi->grp_crypto_type = group_crypto;
1663 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CONNECT_CMDID, NO_SYNC_WMIFLAG);
1668 int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 *bssid, u16 channel)
1670 struct sk_buff *skb;
1671 struct wmi_reconnect_cmd *cc;
1674 wmi->traffic_class = 100;
1676 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd));
1680 cc = (struct wmi_reconnect_cmd *) skb->data;
1681 cc->channel = cpu_to_le16(channel);
1684 memcpy(cc->bssid, bssid, ETH_ALEN);
1686 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RECONNECT_CMDID,
1692 int ath6kl_wmi_disconnect_cmd(struct wmi *wmi)
1696 wmi->traffic_class = 100;
1698 /* Disconnect command does not need to do a SYNC before. */
1699 ret = ath6kl_wmi_simple_cmd(wmi, WMI_DISCONNECT_CMDID);
1704 int ath6kl_wmi_startscan_cmd(struct wmi *wmi, enum wmi_scan_type scan_type,
1705 u32 force_fgscan, u32 is_legacy,
1706 u32 home_dwell_time, u32 force_scan_interval,
1707 s8 num_chan, u16 *ch_list)
1709 struct sk_buff *skb;
1710 struct wmi_start_scan_cmd *sc;
1714 size = sizeof(struct wmi_start_scan_cmd);
1716 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
1719 if (num_chan > WMI_MAX_CHANNELS)
1723 size += sizeof(u16) * (num_chan - 1);
1725 skb = ath6kl_wmi_get_new_buf(size);
1729 sc = (struct wmi_start_scan_cmd *) skb->data;
1730 sc->scan_type = scan_type;
1731 sc->force_fg_scan = cpu_to_le32(force_fgscan);
1732 sc->is_legacy = cpu_to_le32(is_legacy);
1733 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
1734 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
1735 sc->num_ch = num_chan;
1738 memcpy(sc->ch_list, ch_list, num_chan * sizeof(u16));
1740 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_START_SCAN_CMDID,
1746 int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u16 fg_start_sec,
1747 u16 fg_end_sec, u16 bg_sec,
1748 u16 minact_chdw_msec, u16 maxact_chdw_msec,
1749 u16 pas_chdw_msec, u8 short_scan_ratio,
1750 u8 scan_ctrl_flag, u32 max_dfsch_act_time,
1751 u16 maxact_scan_per_ssid)
1753 struct sk_buff *skb;
1754 struct wmi_scan_params_cmd *sc;
1757 skb = ath6kl_wmi_get_new_buf(sizeof(*sc));
1761 sc = (struct wmi_scan_params_cmd *) skb->data;
1762 sc->fg_start_period = cpu_to_le16(fg_start_sec);
1763 sc->fg_end_period = cpu_to_le16(fg_end_sec);
1764 sc->bg_period = cpu_to_le16(bg_sec);
1765 sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec);
1766 sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec);
1767 sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec);
1768 sc->short_scan_ratio = short_scan_ratio;
1769 sc->scan_ctrl_flags = scan_ctrl_flag;
1770 sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time);
1771 sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid);
1773 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_SCAN_PARAMS_CMDID,
1778 int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 filter, u32 ie_mask)
1780 struct sk_buff *skb;
1781 struct wmi_bss_filter_cmd *cmd;
1784 if (filter >= LAST_BSS_FILTER)
1787 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1791 cmd = (struct wmi_bss_filter_cmd *) skb->data;
1792 cmd->bss_filter = filter;
1793 cmd->ie_mask = cpu_to_le32(ie_mask);
1795 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_BSS_FILTER_CMDID,
1800 int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 index, u8 flag,
1801 u8 ssid_len, u8 *ssid)
1803 struct sk_buff *skb;
1804 struct wmi_probed_ssid_cmd *cmd;
1807 if (index > MAX_PROBED_SSID_INDEX)
1810 if (ssid_len > sizeof(cmd->ssid))
1813 if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0))
1816 if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len)
1819 if (flag & SPECIFIC_SSID_FLAG)
1820 wmi->is_probe_ssid = true;
1822 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1826 cmd = (struct wmi_probed_ssid_cmd *) skb->data;
1827 cmd->entry_index = index;
1829 cmd->ssid_len = ssid_len;
1830 memcpy(cmd->ssid, ssid, ssid_len);
1832 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PROBED_SSID_CMDID,
1837 int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u16 listen_interval,
1840 struct sk_buff *skb;
1841 struct wmi_listen_int_cmd *cmd;
1844 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1848 cmd = (struct wmi_listen_int_cmd *) skb->data;
1849 cmd->listen_intvl = cpu_to_le16(listen_interval);
1850 cmd->num_beacons = cpu_to_le16(listen_beacons);
1852 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LISTEN_INT_CMDID,
1857 int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 pwr_mode)
1859 struct sk_buff *skb;
1860 struct wmi_power_mode_cmd *cmd;
1863 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1867 cmd = (struct wmi_power_mode_cmd *) skb->data;
1868 cmd->pwr_mode = pwr_mode;
1869 wmi->pwr_mode = pwr_mode;
1871 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_MODE_CMDID,
1876 int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u16 idle_period,
1877 u16 ps_poll_num, u16 dtim_policy,
1878 u16 tx_wakeup_policy, u16 num_tx_to_wakeup,
1879 u16 ps_fail_event_policy)
1881 struct sk_buff *skb;
1882 struct wmi_power_params_cmd *pm;
1885 skb = ath6kl_wmi_get_new_buf(sizeof(*pm));
1889 pm = (struct wmi_power_params_cmd *)skb->data;
1890 pm->idle_period = cpu_to_le16(idle_period);
1891 pm->pspoll_number = cpu_to_le16(ps_poll_num);
1892 pm->dtim_policy = cpu_to_le16(dtim_policy);
1893 pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy);
1894 pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup);
1895 pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy);
1897 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_POWER_PARAMS_CMDID,
1902 int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 timeout)
1904 struct sk_buff *skb;
1905 struct wmi_disc_timeout_cmd *cmd;
1908 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1912 cmd = (struct wmi_disc_timeout_cmd *) skb->data;
1913 cmd->discon_timeout = timeout;
1915 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_DISC_TIMEOUT_CMDID,
1920 int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 key_index,
1921 enum crypto_type key_type,
1922 u8 key_usage, u8 key_len,
1923 u8 *key_rsc, u8 *key_material,
1924 u8 key_op_ctrl, u8 *mac_addr,
1925 enum wmi_sync_flag sync_flag)
1927 struct sk_buff *skb;
1928 struct wmi_add_cipher_key_cmd *cmd;
1931 ath6kl_dbg(ATH6KL_DBG_WMI, "addkey cmd: key_index=%u key_type=%d "
1932 "key_usage=%d key_len=%d key_op_ctrl=%d\n",
1933 key_index, key_type, key_usage, key_len, key_op_ctrl);
1935 if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) ||
1936 (key_material == NULL))
1939 if ((WEP_CRYPT != key_type) && (NULL == key_rsc))
1942 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1946 cmd = (struct wmi_add_cipher_key_cmd *) skb->data;
1947 cmd->key_index = key_index;
1948 cmd->key_type = key_type;
1949 cmd->key_usage = key_usage;
1950 cmd->key_len = key_len;
1951 memcpy(cmd->key, key_material, key_len);
1953 if (key_rsc != NULL)
1954 memcpy(cmd->key_rsc, key_rsc, sizeof(cmd->key_rsc));
1956 cmd->key_op_ctrl = key_op_ctrl;
1959 memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN);
1961 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_CIPHER_KEY_CMDID,
1967 int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 *krk)
1969 struct sk_buff *skb;
1970 struct wmi_add_krk_cmd *cmd;
1973 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1977 cmd = (struct wmi_add_krk_cmd *) skb->data;
1978 memcpy(cmd->krk, krk, WMI_KRK_LEN);
1980 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_ADD_KRK_CMDID, NO_SYNC_WMIFLAG);
1985 int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 key_index)
1987 struct sk_buff *skb;
1988 struct wmi_delete_cipher_key_cmd *cmd;
1991 if (key_index > WMI_MAX_KEY_INDEX)
1994 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1998 cmd = (struct wmi_delete_cipher_key_cmd *) skb->data;
1999 cmd->key_index = key_index;
2001 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_CIPHER_KEY_CMDID,
2007 int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, const u8 *bssid,
2008 const u8 *pmkid, bool set)
2010 struct sk_buff *skb;
2011 struct wmi_setpmkid_cmd *cmd;
2017 if (set && pmkid == NULL)
2020 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2024 cmd = (struct wmi_setpmkid_cmd *) skb->data;
2025 memcpy(cmd->bssid, bssid, ETH_ALEN);
2027 memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid));
2028 cmd->enable = PMKID_ENABLE;
2030 memset(cmd->pmkid, 0, sizeof(cmd->pmkid));
2031 cmd->enable = PMKID_DISABLE;
2034 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_PMKID_CMDID,
2040 static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb,
2041 enum htc_endpoint_id ep_id)
2043 struct wmi_data_hdr *data_hdr;
2046 if (WARN_ON(skb == NULL || ep_id == wmi->ep_id))
2049 skb_push(skb, sizeof(struct wmi_data_hdr));
2051 data_hdr = (struct wmi_data_hdr *) skb->data;
2052 data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT;
2053 data_hdr->info3 = 0;
2055 ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
2060 static int ath6kl_wmi_sync_point(struct wmi *wmi)
2062 struct sk_buff *skb;
2063 struct wmi_sync_cmd *cmd;
2064 struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC];
2065 enum htc_endpoint_id ep_id;
2066 u8 index, num_pri_streams = 0;
2069 memset(data_sync_bufs, 0, sizeof(data_sync_bufs));
2071 spin_lock_bh(&wmi->lock);
2073 for (index = 0; index < WMM_NUM_AC; index++) {
2074 if (wmi->fat_pipe_exist & (1 << index)) {
2076 data_sync_bufs[num_pri_streams - 1].traffic_class =
2081 spin_unlock_bh(&wmi->lock);
2083 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2089 cmd = (struct wmi_sync_cmd *) skb->data;
2092 * In the SYNC cmd sent on the control Ep, send a bitmap
2093 * of the data eps on which the Data Sync will be sent
2095 cmd->data_sync_map = wmi->fat_pipe_exist;
2097 for (index = 0; index < num_pri_streams; index++) {
2098 data_sync_bufs[index].skb = ath6kl_buf_alloc(0);
2099 if (data_sync_bufs[index].skb == NULL) {
2106 * If buffer allocation for any of the dataSync fails,
2107 * then do not send the Synchronize cmd on the control ep
2113 * Send sync cmd followed by sync data messages on all
2114 * endpoints being used
2116 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SYNCHRONIZE_CMDID,
2122 /* cmd buffer sent, we no longer own it */
2125 for (index = 0; index < num_pri_streams; index++) {
2127 if (WARN_ON(!data_sync_bufs[index].skb))
2130 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev,
2131 data_sync_bufs[index].
2134 ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb,
2140 data_sync_bufs[index].skb = NULL;
2144 /* free up any resources left over (possibly due to an error) */
2148 for (index = 0; index < num_pri_streams; index++) {
2149 if (data_sync_bufs[index].skb != NULL) {
2150 dev_kfree_skb((struct sk_buff *)data_sync_bufs[index].
2158 int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi,
2159 struct wmi_create_pstream_cmd *params)
2161 struct sk_buff *skb;
2162 struct wmi_create_pstream_cmd *cmd;
2163 u8 fatpipe_exist_for_ac = 0;
2165 s32 nominal_phy = 0;
2168 if (!((params->user_pri < 8) &&
2169 (params->user_pri <= 0x7) &&
2170 (up_to_ac[params->user_pri & 0x7] == params->traffic_class) &&
2171 (params->traffic_direc == UPLINK_TRAFFIC ||
2172 params->traffic_direc == DNLINK_TRAFFIC ||
2173 params->traffic_direc == BIDIR_TRAFFIC) &&
2174 (params->traffic_type == TRAFFIC_TYPE_APERIODIC ||
2175 params->traffic_type == TRAFFIC_TYPE_PERIODIC) &&
2176 (params->voice_psc_cap == DISABLE_FOR_THIS_AC ||
2177 params->voice_psc_cap == ENABLE_FOR_THIS_AC ||
2178 params->voice_psc_cap == ENABLE_FOR_ALL_AC) &&
2179 (params->tsid == WMI_IMPLICIT_PSTREAM ||
2180 params->tsid <= WMI_MAX_THINSTREAM))) {
2185 * Check nominal PHY rate is >= minimalPHY,
2186 * so that DUT can allow TSRS IE
2189 /* Get the physical rate (units of bps) */
2190 min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000);
2192 /* Check minimal phy < nominal phy rate */
2193 if (params->nominal_phy >= min_phy) {
2194 /* unit of 500 kbps */
2195 nominal_phy = (params->nominal_phy * 1000) / 500;
2196 ath6kl_dbg(ATH6KL_DBG_WMI,
2197 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2198 min_phy, nominal_phy);
2200 params->nominal_phy = nominal_phy;
2202 params->nominal_phy = 0;
2205 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2209 ath6kl_dbg(ATH6KL_DBG_WMI,
2210 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2211 params->traffic_class, params->tsid);
2213 cmd = (struct wmi_create_pstream_cmd *) skb->data;
2214 memcpy(cmd, params, sizeof(*cmd));
2216 /* This is an implicitly created Fat pipe */
2217 if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) {
2218 spin_lock_bh(&wmi->lock);
2219 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2220 (1 << params->traffic_class));
2221 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2222 spin_unlock_bh(&wmi->lock);
2224 /* explicitly created thin stream within a fat pipe */
2225 spin_lock_bh(&wmi->lock);
2226 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2227 (1 << params->traffic_class));
2228 wmi->stream_exist_for_ac[params->traffic_class] |=
2229 (1 << params->tsid);
2231 * If a thinstream becomes active, the fat pipe automatically
2234 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2235 spin_unlock_bh(&wmi->lock);
2239 * Indicate activty change to driver layer only if this is the
2240 * first TSID to get created in this AC explicitly or an implicit
2241 * fat pipe is getting created.
2243 if (!fatpipe_exist_for_ac)
2244 ath6kl_indicate_tx_activity(wmi->parent_dev,
2245 params->traffic_class, true);
2247 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_CREATE_PSTREAM_CMDID,
2252 int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 traffic_class, u8 tsid)
2254 struct sk_buff *skb;
2255 struct wmi_delete_pstream_cmd *cmd;
2256 u16 active_tsids = 0;
2259 if (traffic_class > 3) {
2260 ath6kl_err("invalid traffic class: %d\n", traffic_class);
2264 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2268 cmd = (struct wmi_delete_pstream_cmd *) skb->data;
2269 cmd->traffic_class = traffic_class;
2272 spin_lock_bh(&wmi->lock);
2273 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2274 spin_unlock_bh(&wmi->lock);
2276 if (!(active_tsids & (1 << tsid))) {
2278 ath6kl_dbg(ATH6KL_DBG_WMI,
2279 "TSID %d doesn't exist for traffic class: %d\n",
2280 tsid, traffic_class);
2284 ath6kl_dbg(ATH6KL_DBG_WMI,
2285 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2286 traffic_class, tsid);
2288 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_DELETE_PSTREAM_CMDID,
2289 SYNC_BEFORE_WMIFLAG);
2291 spin_lock_bh(&wmi->lock);
2292 wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid);
2293 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2294 spin_unlock_bh(&wmi->lock);
2297 * Indicate stream inactivity to driver layer only if all tsids
2298 * within this AC are deleted.
2300 if (!active_tsids) {
2301 ath6kl_indicate_tx_activity(wmi->parent_dev,
2302 traffic_class, false);
2303 wmi->fat_pipe_exist &= ~(1 << traffic_class);
2309 int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, struct wmi_set_ip_cmd *ip_cmd)
2311 struct sk_buff *skb;
2312 struct wmi_set_ip_cmd *cmd;
2315 /* Multicast address are not valid */
2316 if ((*((u8 *) &ip_cmd->ips[0]) >= 0xE0) ||
2317 (*((u8 *) &ip_cmd->ips[1]) >= 0xE0))
2320 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd));
2324 cmd = (struct wmi_set_ip_cmd *) skb->data;
2325 memcpy(cmd, ip_cmd, sizeof(struct wmi_set_ip_cmd));
2327 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_IP_CMDID, NO_SYNC_WMIFLAG);
2331 static int ath6kl_wmi_get_wow_list_event_rx(struct wmi *wmi, u8 * datap,
2334 if (len < sizeof(struct wmi_get_wow_list_reply))
2340 static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb,
2341 enum wmix_command_id cmd_id,
2342 enum wmi_sync_flag sync_flag)
2344 struct wmix_cmd_hdr *cmd_hdr;
2347 skb_push(skb, sizeof(struct wmix_cmd_hdr));
2349 cmd_hdr = (struct wmix_cmd_hdr *) skb->data;
2350 cmd_hdr->cmd_id = cpu_to_le32(cmd_id);
2352 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_EXTENSION_CMDID, sync_flag);
2357 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source)
2359 struct sk_buff *skb;
2360 struct wmix_hb_challenge_resp_cmd *cmd;
2363 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2367 cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data;
2368 cmd->cookie = cpu_to_le32(cookie);
2369 cmd->source = cpu_to_le32(source);
2371 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID,
2376 int ath6kl_wmi_get_stats_cmd(struct wmi *wmi)
2378 return ath6kl_wmi_simple_cmd(wmi, WMI_GET_STATISTICS_CMDID);
2381 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 dbM)
2383 struct sk_buff *skb;
2384 struct wmi_set_tx_pwr_cmd *cmd;
2387 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd));
2391 cmd = (struct wmi_set_tx_pwr_cmd *) skb->data;
2394 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_TX_PWR_CMDID,
2400 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi)
2402 return ath6kl_wmi_simple_cmd(wmi, WMI_GET_TX_PWR_CMDID);
2405 int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 status, u8 preamble_policy)
2407 struct sk_buff *skb;
2408 struct wmi_set_lpreamble_cmd *cmd;
2411 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd));
2415 cmd = (struct wmi_set_lpreamble_cmd *) skb->data;
2416 cmd->status = status;
2417 cmd->preamble_policy = preamble_policy;
2419 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_LPREAMBLE_CMDID,
2424 int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold)
2426 struct sk_buff *skb;
2427 struct wmi_set_rts_cmd *cmd;
2430 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd));
2434 cmd = (struct wmi_set_rts_cmd *) skb->data;
2435 cmd->threshold = cpu_to_le16(threshold);
2437 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_RTS_CMDID, NO_SYNC_WMIFLAG);
2441 int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, enum wmi_txop_cfg cfg)
2443 struct sk_buff *skb;
2444 struct wmi_set_wmm_txop_cmd *cmd;
2447 if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)))
2450 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd));
2454 cmd = (struct wmi_set_wmm_txop_cmd *) skb->data;
2455 cmd->txop_enable = cfg;
2457 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_WMM_TXOP_CMDID,
2462 int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 keep_alive_intvl)
2464 struct sk_buff *skb;
2465 struct wmi_set_keepalive_cmd *cmd;
2468 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2472 cmd = (struct wmi_set_keepalive_cmd *) skb->data;
2473 cmd->keep_alive_intvl = keep_alive_intvl;
2474 wmi->keep_alive_intvl = keep_alive_intvl;
2476 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_KEEPALIVE_CMDID,
2481 s32 ath6kl_wmi_get_rate(s8 rate_index)
2483 if (rate_index == RATE_AUTO)
2486 return wmi_rate_tbl[(u32) rate_index][0];
2489 void ath6kl_wmi_node_return(struct wmi *wmi, struct bss *bss)
2492 wlan_node_return(&wmi->parent_dev->scan_table, bss);
2495 struct bss *ath6kl_wmi_find_ssid_node(struct wmi *wmi, u8 * ssid,
2496 u32 ssid_len, bool is_wpa2,
2499 struct bss *node = NULL;
2501 node = wlan_find_ssid_node(&wmi->parent_dev->scan_table, ssid,
2502 ssid_len, is_wpa2, match_ssid);
2506 struct bss *ath6kl_wmi_find_node(struct wmi *wmi, const u8 * mac_addr)
2508 struct bss *ni = NULL;
2510 ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr);
2515 void ath6kl_wmi_node_free(struct wmi *wmi, const u8 * mac_addr)
2517 struct bss *ni = NULL;
2519 ni = wlan_find_node(&wmi->parent_dev->scan_table, mac_addr);
2521 wlan_node_reclaim(&wmi->parent_dev->scan_table, ni);
2526 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,
2529 struct wmi_pmkid_list_reply *reply;
2532 if (len < sizeof(struct wmi_pmkid_list_reply))
2535 reply = (struct wmi_pmkid_list_reply *)datap;
2536 expected_len = sizeof(reply->num_pmkid) +
2537 le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN;
2539 if (len < expected_len)
2545 static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len)
2547 struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap;
2549 aggr_recv_addba_req_evt(wmi->parent_dev, cmd->tid,
2550 le16_to_cpu(cmd->st_seq_no), cmd->win_sz);
2555 static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len)
2557 struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap;
2559 aggr_recv_delba_req_evt(wmi->parent_dev, cmd->tid);
2564 /* AP mode functions */
2566 int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, struct wmi_connect_cmd *p)
2568 struct sk_buff *skb;
2569 struct wmi_connect_cmd *cm;
2572 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
2576 cm = (struct wmi_connect_cmd *) skb->data;
2577 memcpy(cm, p, sizeof(*cm));
2579 res = ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_CONFIG_COMMIT_CMDID,
2581 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: nw_type=%u auth_mode=%u ch=%u "
2582 "ctrl_flags=0x%x-> res=%d\n",
2583 __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch),
2584 le32_to_cpu(p->ctrl_flags), res);
2588 int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 cmd, const u8 *mac, u16 reason)
2590 struct sk_buff *skb;
2591 struct wmi_ap_set_mlme_cmd *cm;
2593 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
2597 cm = (struct wmi_ap_set_mlme_cmd *) skb->data;
2598 memcpy(cm->mac, mac, ETH_ALEN);
2599 cm->reason = cpu_to_le16(reason);
2602 return ath6kl_wmi_cmd_send(wmip, skb, WMI_AP_SET_MLME_CMDID,
2606 static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len)
2608 struct wmi_pspoll_event *ev;
2610 if (len < sizeof(struct wmi_pspoll_event))
2613 ev = (struct wmi_pspoll_event *) datap;
2615 ath6kl_pspoll_event(wmi->parent_dev, le16_to_cpu(ev->aid));
2620 static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len)
2622 ath6kl_dtimexpiry_event(wmi->parent_dev);
2627 int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u16 aid, bool flag)
2629 struct sk_buff *skb;
2630 struct wmi_ap_set_pvb_cmd *cmd;
2633 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd));
2637 cmd = (struct wmi_ap_set_pvb_cmd *) skb->data;
2638 cmd->aid = cpu_to_le16(aid);
2639 cmd->flag = cpu_to_le32(flag);
2641 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_AP_SET_PVB_CMDID,
2647 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 rx_meta_ver,
2648 bool rx_dot11_hdr, bool defrag_on_host)
2650 struct sk_buff *skb;
2651 struct wmi_rx_frame_format_cmd *cmd;
2654 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2658 cmd = (struct wmi_rx_frame_format_cmd *) skb->data;
2659 cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0;
2660 cmd->defrag_on_host = defrag_on_host ? 1 : 0;
2661 cmd->meta_ver = rx_meta_ver;
2663 /* Delete the local aggr state, on host */
2664 ret = ath6kl_wmi_cmd_send(wmi, skb, WMI_RX_FRAME_FORMAT_CMDID,
2670 int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 mgmt_frm_type, const u8 *ie,
2673 struct sk_buff *skb;
2674 struct wmi_set_appie_cmd *p;
2676 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len);
2680 ath6kl_dbg(ATH6KL_DBG_WMI, "set_appie_cmd: mgmt_frm_type=%u "
2681 "ie_len=%u\n", mgmt_frm_type, ie_len);
2682 p = (struct wmi_set_appie_cmd *) skb->data;
2683 p->mgmt_frm_type = mgmt_frm_type;
2685 memcpy(p->ie_info, ie, ie_len);
2686 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SET_APPIE_CMDID,
2690 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable)
2692 struct sk_buff *skb;
2693 struct wmi_disable_11b_rates_cmd *cmd;
2695 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2699 ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n",
2701 cmd = (struct wmi_disable_11b_rates_cmd *) skb->data;
2702 cmd->disable = disable ? 1 : 0;
2704 return ath6kl_wmi_cmd_send(wmi, skb, WMI_DISABLE_11B_RATES_CMDID,
2708 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u32 freq, u32 dur)
2710 struct sk_buff *skb;
2711 struct wmi_remain_on_chnl_cmd *p;
2713 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
2717 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n",
2719 p = (struct wmi_remain_on_chnl_cmd *) skb->data;
2720 p->freq = cpu_to_le32(freq);
2721 p->duration = cpu_to_le32(dur);
2722 return ath6kl_wmi_cmd_send(wmi, skb, WMI_REMAIN_ON_CHNL_CMDID,
2726 int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u32 id, u32 freq, u32 wait,
2727 const u8 *data, u16 data_len)
2729 struct sk_buff *skb;
2730 struct wmi_send_action_cmd *p;
2733 return -EINVAL; /* Offload for wait not supported */
2735 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
2739 ath6kl_dbg(ATH6KL_DBG_WMI, "send_action_cmd: id=%u freq=%u wait=%u "
2740 "len=%u\n", id, freq, wait, data_len);
2741 p = (struct wmi_send_action_cmd *) skb->data;
2742 p->id = cpu_to_le32(id);
2743 p->freq = cpu_to_le32(freq);
2744 p->wait = cpu_to_le32(wait);
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_ACTION_CMDID,
2751 int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u32 freq,
2753 const u8 *data, u16 data_len)
2755 struct sk_buff *skb;
2756 struct wmi_p2p_probe_response_cmd *p;
2758 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
2762 ath6kl_dbg(ATH6KL_DBG_WMI, "send_probe_response_cmd: freq=%u dst=%pM "
2763 "len=%u\n", freq, dst, data_len);
2764 p = (struct wmi_p2p_probe_response_cmd *) skb->data;
2765 p->freq = cpu_to_le32(freq);
2766 memcpy(p->destination_addr, dst, ETH_ALEN);
2767 p->len = cpu_to_le16(data_len);
2768 memcpy(p->data, data, data_len);
2769 return ath6kl_wmi_cmd_send(wmi, skb, WMI_SEND_PROBE_RESPONSE_CMDID,
2773 int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, bool enable)
2775 struct sk_buff *skb;
2776 struct wmi_probe_req_report_cmd *p;
2778 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
2782 ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n",
2784 p = (struct wmi_probe_req_report_cmd *) skb->data;
2785 p->enable = enable ? 1 : 0;
2786 return ath6kl_wmi_cmd_send(wmi, skb, WMI_PROBE_REQ_REPORT_CMDID,
2790 int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u32 info_req_flags)
2792 struct sk_buff *skb;
2793 struct wmi_get_p2p_info *p;
2795 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
2799 ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n",
2801 p = (struct wmi_get_p2p_info *) skb->data;
2802 p->info_req_flags = cpu_to_le32(info_req_flags);
2803 return ath6kl_wmi_cmd_send(wmi, skb, WMI_GET_P2P_INFO_CMDID,
2807 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi)
2809 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n");
2810 return ath6kl_wmi_simple_cmd(wmi, WMI_CANCEL_REMAIN_ON_CHNL_CMDID);
2813 static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb)
2815 struct wmix_cmd_hdr *cmd;
2821 if (skb->len < sizeof(struct wmix_cmd_hdr)) {
2822 ath6kl_err("bad packet 1\n");
2823 wmi->stat.cmd_len_err++;
2827 cmd = (struct wmix_cmd_hdr *) skb->data;
2828 id = le32_to_cpu(cmd->cmd_id);
2830 skb_pull(skb, sizeof(struct wmix_cmd_hdr));
2836 case WMIX_HB_CHALLENGE_RESP_EVENTID:
2838 case WMIX_DBGLOG_EVENTID:
2841 ath6kl_err("unknown cmd id 0x%x\n", id);
2842 wmi->stat.cmd_id_err++;
2851 int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
2853 struct wmi_cmd_hdr *cmd;
2859 if (WARN_ON(skb == NULL))
2862 if (skb->len < sizeof(struct wmi_cmd_hdr)) {
2863 ath6kl_err("bad packet 1\n");
2865 wmi->stat.cmd_len_err++;
2869 cmd = (struct wmi_cmd_hdr *) skb->data;
2870 id = le16_to_cpu(cmd->cmd_id);
2872 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
2877 ath6kl_dbg(ATH6KL_DBG_WMI, "%s: wmi id: %d\n", __func__, id);
2878 ath6kl_dbg_dump(ATH6KL_DBG_RAW_BYTES, "msg payload ", datap, len);
2881 case WMI_GET_BITRATE_CMDID:
2882 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n");
2883 ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len);
2885 case WMI_GET_CHANNEL_LIST_CMDID:
2886 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n");
2887 ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len);
2889 case WMI_GET_TX_PWR_CMDID:
2890 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n");
2891 ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len);
2893 case WMI_READY_EVENTID:
2894 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n");
2895 ret = ath6kl_wmi_ready_event_rx(wmi, datap, len);
2897 case WMI_CONNECT_EVENTID:
2898 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n");
2899 ret = ath6kl_wmi_connect_event_rx(wmi, datap, len);
2901 case WMI_DISCONNECT_EVENTID:
2902 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n");
2903 ret = ath6kl_wmi_disconnect_event_rx(wmi, datap, len);
2905 case WMI_PEER_NODE_EVENTID:
2906 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n");
2907 ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len);
2909 case WMI_TKIP_MICERR_EVENTID:
2910 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n");
2911 ret = ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len);
2913 case WMI_BSSINFO_EVENTID:
2914 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n");
2915 ath6kl_wmi_convert_bssinfo_hdr2_to_hdr(skb, datap);
2916 ret = ath6kl_wmi_bssinfo_event_rx(wmi, skb->data, skb->len);
2918 case WMI_REGDOMAIN_EVENTID:
2919 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n");
2921 case WMI_PSTREAM_TIMEOUT_EVENTID:
2922 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
2923 ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len);
2925 case WMI_NEIGHBOR_REPORT_EVENTID:
2926 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n");
2928 case WMI_SCAN_COMPLETE_EVENTID:
2929 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n");
2930 ret = ath6kl_wmi_scan_complete_rx(wmi, datap, len);
2932 case WMI_CMDERROR_EVENTID:
2933 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n");
2934 ret = ath6kl_wmi_error_event_rx(wmi, datap, len);
2936 case WMI_REPORT_STATISTICS_EVENTID:
2937 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n");
2938 ret = ath6kl_wmi_stats_event_rx(wmi, datap, len);
2940 case WMI_RSSI_THRESHOLD_EVENTID:
2941 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n");
2942 ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len);
2944 case WMI_ERROR_REPORT_EVENTID:
2945 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n");
2947 case WMI_OPT_RX_FRAME_EVENTID:
2948 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n");
2949 ret = ath6kl_wmi_opt_frame_event_rx(wmi, datap, len);
2951 case WMI_REPORT_ROAM_TBL_EVENTID:
2952 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n");
2954 case WMI_EXTENSION_EVENTID:
2955 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n");
2956 ret = ath6kl_wmi_control_rx_xtnd(wmi, skb);
2958 case WMI_CAC_EVENTID:
2959 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n");
2960 ret = ath6kl_wmi_cac_event_rx(wmi, datap, len);
2962 case WMI_CHANNEL_CHANGE_EVENTID:
2963 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n");
2965 case WMI_REPORT_ROAM_DATA_EVENTID:
2966 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n");
2968 case WMI_GET_FIXRATES_CMDID:
2969 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n");
2970 ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len);
2972 case WMI_TX_RETRY_ERR_EVENTID:
2973 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n");
2975 case WMI_SNR_THRESHOLD_EVENTID:
2976 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n");
2977 ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len);
2979 case WMI_LQ_THRESHOLD_EVENTID:
2980 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n");
2982 case WMI_APLIST_EVENTID:
2983 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n");
2984 ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len);
2986 case WMI_GET_KEEPALIVE_CMDID:
2987 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n");
2988 ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len);
2990 case WMI_GET_WOW_LIST_EVENTID:
2991 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n");
2992 ret = ath6kl_wmi_get_wow_list_event_rx(wmi, datap, len);
2994 case WMI_GET_PMKID_LIST_EVENTID:
2995 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n");
2996 ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len);
2998 case WMI_PSPOLL_EVENTID:
2999 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n");
3000 ret = ath6kl_wmi_pspoll_event_rx(wmi, datap, len);
3002 case WMI_DTIMEXPIRY_EVENTID:
3003 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n");
3004 ret = ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len);
3006 case WMI_SET_PARAMS_REPLY_EVENTID:
3007 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n");
3009 case WMI_ADDBA_REQ_EVENTID:
3010 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n");
3011 ret = ath6kl_wmi_addba_req_event_rx(wmi, datap, len);
3013 case WMI_ADDBA_RESP_EVENTID:
3014 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n");
3016 case WMI_DELBA_REQ_EVENTID:
3017 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n");
3018 ret = ath6kl_wmi_delba_req_event_rx(wmi, datap, len);
3020 case WMI_REPORT_BTCOEX_CONFIG_EVENTID:
3021 ath6kl_dbg(ATH6KL_DBG_WMI,
3022 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
3024 case WMI_REPORT_BTCOEX_STATS_EVENTID:
3025 ath6kl_dbg(ATH6KL_DBG_WMI,
3026 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
3028 case WMI_TX_COMPLETE_EVENTID:
3029 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n");
3030 ret = ath6kl_wmi_tx_complete_event_rx(datap, len);
3032 case WMI_REMAIN_ON_CHNL_EVENTID:
3033 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n");
3034 ret = ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len);
3036 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID:
3037 ath6kl_dbg(ATH6KL_DBG_WMI,
3038 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
3039 ret = ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap,
3042 case WMI_TX_STATUS_EVENTID:
3043 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n");
3044 ret = ath6kl_wmi_tx_status_event_rx(datap, len);
3046 case WMI_RX_PROBE_REQ_EVENTID:
3047 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n");
3048 ret = ath6kl_wmi_rx_probe_req_event_rx(datap, len);
3050 case WMI_P2P_CAPABILITIES_EVENTID:
3051 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n");
3052 ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len);
3054 case WMI_RX_ACTION_EVENTID:
3055 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n");
3056 ret = ath6kl_wmi_rx_action_event_rx(datap, len);
3058 case WMI_P2P_INFO_EVENTID:
3059 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n");
3060 ret = ath6kl_wmi_p2p_info_event_rx(datap, len);
3063 ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", id);
3064 wmi->stat.cmd_id_err++;
3074 static void ath6kl_wmi_qos_state_init(struct wmi *wmi)
3079 spin_lock_bh(&wmi->lock);
3081 wmi->fat_pipe_exist = 0;
3082 memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac));
3084 spin_unlock_bh(&wmi->lock);
3087 void *ath6kl_wmi_init(struct ath6kl *dev)
3091 wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL);
3095 spin_lock_init(&wmi->lock);
3097 wmi->parent_dev = dev;
3099 ath6kl_wmi_qos_state_init(wmi);
3101 wmi->pwr_mode = REC_POWER;
3102 wmi->phy_mode = WMI_11G_MODE;
3104 wmi->pair_crypto_type = NONE_CRYPT;
3105 wmi->grp_crypto_type = NONE_CRYPT;
3107 wmi->ht_allowed[A_BAND_24GHZ] = 1;
3108 wmi->ht_allowed[A_BAND_5GHZ] = 1;
3113 void ath6kl_wmi_shutdown(struct wmi *wmi)