2 * Copyright (c) 2004-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 #include "../regd_common.h"
26 static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx);
28 static const s32 wmi_rate_tbl[][2] = {
29 /* {W/O SGI, with SGI} */
61 /* 802.1d to AC mapping. Refer pg 57 of WMM-test-plan-v1.2 */
62 static const u8 up_to_ac[] = {
73 void ath6kl_wmi_set_control_ep(struct wmi *wmi, enum htc_endpoint_id ep_id)
75 if (WARN_ON(ep_id == ENDPOINT_UNUSED || ep_id >= ENDPOINT_MAX))
81 enum htc_endpoint_id ath6kl_wmi_get_control_ep(struct wmi *wmi)
86 struct ath6kl_vif *ath6kl_get_vif_by_index(struct ath6kl *ar, u8 if_idx)
88 struct ath6kl_vif *vif, *found = NULL;
90 if (WARN_ON(if_idx > (ar->vif_max - 1)))
94 spin_lock_bh(&ar->list_lock);
95 list_for_each_entry(vif, &ar->vif_list, list) {
96 if (vif->fw_vif_idx == if_idx) {
101 spin_unlock_bh(&ar->list_lock);
106 /* Performs DIX to 802.3 encapsulation for transmit packets.
107 * Assumes the entire DIX header is contigous and that there is
108 * enough room in the buffer for a 802.3 mac header and LLC+SNAP headers.
110 int ath6kl_wmi_dix_2_dot3(struct wmi *wmi, struct sk_buff *skb)
112 struct ath6kl_llc_snap_hdr *llc_hdr;
113 struct ethhdr *eth_hdr;
119 if (WARN_ON(skb == NULL))
122 size = sizeof(struct ath6kl_llc_snap_hdr) + sizeof(struct wmi_data_hdr);
123 if (skb_headroom(skb) < size)
126 eth_hdr = (struct ethhdr *) skb->data;
127 type = eth_hdr->h_proto;
129 if (!is_ethertype(be16_to_cpu(type))) {
130 ath6kl_dbg(ATH6KL_DBG_WMI,
131 "%s: pkt is already in 802.3 format\n", __func__);
135 new_len = skb->len - sizeof(*eth_hdr) + sizeof(*llc_hdr);
137 skb_push(skb, sizeof(struct ath6kl_llc_snap_hdr));
140 eth_hdr->h_proto = cpu_to_be16(new_len);
142 memcpy(datap, eth_hdr, sizeof(*eth_hdr));
144 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap + sizeof(*eth_hdr));
145 llc_hdr->dsap = 0xAA;
146 llc_hdr->ssap = 0xAA;
147 llc_hdr->cntl = 0x03;
148 llc_hdr->org_code[0] = 0x0;
149 llc_hdr->org_code[1] = 0x0;
150 llc_hdr->org_code[2] = 0x0;
151 llc_hdr->eth_type = type;
156 static int ath6kl_wmi_meta_add(struct wmi *wmi, struct sk_buff *skb,
157 u8 *version, void *tx_meta_info)
159 struct wmi_tx_meta_v1 *v1;
160 struct wmi_tx_meta_v2 *v2;
162 if (WARN_ON(skb == NULL || version == NULL))
166 case WMI_META_VERSION_1:
167 skb_push(skb, WMI_MAX_TX_META_SZ);
168 v1 = (struct wmi_tx_meta_v1 *) skb->data;
170 v1->rate_plcy_id = 0;
171 *version = WMI_META_VERSION_1;
173 case WMI_META_VERSION_2:
174 skb_push(skb, WMI_MAX_TX_META_SZ);
175 v2 = (struct wmi_tx_meta_v2 *) skb->data;
176 memcpy(v2, (struct wmi_tx_meta_v2 *) tx_meta_info,
177 sizeof(struct wmi_tx_meta_v2));
184 int ath6kl_wmi_data_hdr_add(struct wmi *wmi, struct sk_buff *skb,
185 u8 msg_type, u32 flags,
186 enum wmi_data_hdr_data_type data_type,
187 u8 meta_ver, void *tx_meta_info, u8 if_idx)
189 struct wmi_data_hdr *data_hdr;
192 if (WARN_ON(skb == NULL || (if_idx > wmi->parent_dev->vif_max - 1)))
196 ret = ath6kl_wmi_meta_add(wmi, skb, &meta_ver, tx_meta_info);
201 skb_push(skb, sizeof(struct wmi_data_hdr));
203 data_hdr = (struct wmi_data_hdr *)skb->data;
204 memset(data_hdr, 0, sizeof(struct wmi_data_hdr));
206 data_hdr->info = msg_type << WMI_DATA_HDR_MSG_TYPE_SHIFT;
207 data_hdr->info |= data_type << WMI_DATA_HDR_DATA_TYPE_SHIFT;
209 if (flags & WMI_DATA_HDR_FLAGS_MORE)
210 data_hdr->info |= WMI_DATA_HDR_MORE;
212 if (flags & WMI_DATA_HDR_FLAGS_EOSP)
213 data_hdr->info3 |= cpu_to_le16(WMI_DATA_HDR_EOSP);
215 data_hdr->info2 |= cpu_to_le16(meta_ver << WMI_DATA_HDR_META_SHIFT);
216 data_hdr->info3 |= cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK);
221 u8 ath6kl_wmi_determine_user_priority(u8 *pkt, u32 layer2_pri)
223 struct iphdr *ip_hdr = (struct iphdr *) pkt;
227 * Determine IPTOS priority
230 * : DSCP(6-bits) ECN(2-bits)
231 * : DSCP - P2 P1 P0 X X X
232 * where (P2 P1 P0) form 802.1D
234 ip_pri = ip_hdr->tos >> 5;
237 if ((layer2_pri & 0x7) > ip_pri)
238 return (u8) layer2_pri & 0x7;
243 u8 ath6kl_wmi_get_traffic_class(u8 user_priority)
245 return up_to_ac[user_priority & 0x7];
248 int ath6kl_wmi_implicit_create_pstream(struct wmi *wmi, u8 if_idx,
250 u32 layer2_priority, bool wmm_enabled,
253 struct wmi_data_hdr *data_hdr;
254 struct ath6kl_llc_snap_hdr *llc_hdr;
255 struct wmi_create_pstream_cmd cmd;
256 u32 meta_size, hdr_size;
257 u16 ip_type = IP_ETHERTYPE;
258 u8 stream_exist, usr_pri;
259 u8 traffic_class = WMM_AC_BE;
262 if (WARN_ON(skb == NULL))
266 data_hdr = (struct wmi_data_hdr *) datap;
268 meta_size = ((le16_to_cpu(data_hdr->info2) >> WMI_DATA_HDR_META_SHIFT) &
269 WMI_DATA_HDR_META_MASK) ? WMI_MAX_TX_META_SZ : 0;
272 /* If WMM is disabled all traffic goes as BE traffic */
275 hdr_size = sizeof(struct ethhdr);
277 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap +
280 meta_size + hdr_size);
282 if (llc_hdr->eth_type == htons(ip_type)) {
284 * Extract the endpoint info from the TOS field
288 ath6kl_wmi_determine_user_priority(((u8 *) llc_hdr) +
289 sizeof(struct ath6kl_llc_snap_hdr),
292 usr_pri = layer2_priority & 0x7;
295 * Queue the EAPOL frames in the same WMM_AC_VO queue
296 * as that of management frames.
298 if (skb->protocol == cpu_to_be16(ETH_P_PAE))
299 usr_pri = WMI_VOICE_USER_PRIORITY;
303 * workaround for WMM S5
305 * FIXME: wmi->traffic_class is always 100 so this test doesn't
308 if ((wmi->traffic_class == WMM_AC_VI) &&
309 ((usr_pri == 5) || (usr_pri == 4)))
312 /* Convert user priority to traffic class */
313 traffic_class = up_to_ac[usr_pri & 0x7];
315 wmi_data_hdr_set_up(data_hdr, usr_pri);
317 spin_lock_bh(&wmi->lock);
318 stream_exist = wmi->fat_pipe_exist;
319 spin_unlock_bh(&wmi->lock);
321 if (!(stream_exist & (1 << traffic_class))) {
322 memset(&cmd, 0, sizeof(cmd));
323 cmd.traffic_class = traffic_class;
324 cmd.user_pri = usr_pri;
326 cpu_to_le32(WMI_IMPLICIT_PSTREAM_INACTIVITY_INT);
327 /* Implicit streams are created with TSID 0xFF */
328 cmd.tsid = WMI_IMPLICIT_PSTREAM;
329 ath6kl_wmi_create_pstream_cmd(wmi, if_idx, &cmd);
337 int ath6kl_wmi_dot11_hdr_remove(struct wmi *wmi, struct sk_buff *skb)
339 struct ieee80211_hdr_3addr *pwh, wh;
340 struct ath6kl_llc_snap_hdr *llc_hdr;
341 struct ethhdr eth_hdr;
346 if (WARN_ON(skb == NULL))
350 pwh = (struct ieee80211_hdr_3addr *) datap;
352 sub_type = pwh->frame_control & cpu_to_le16(IEEE80211_FCTL_STYPE);
354 memcpy((u8 *) &wh, datap, sizeof(struct ieee80211_hdr_3addr));
356 /* Strip off the 802.11 header */
357 if (sub_type == cpu_to_le16(IEEE80211_STYPE_QOS_DATA)) {
358 hdr_size = roundup(sizeof(struct ieee80211_qos_hdr),
360 skb_pull(skb, hdr_size);
361 } else if (sub_type == cpu_to_le16(IEEE80211_STYPE_DATA))
362 skb_pull(skb, sizeof(struct ieee80211_hdr_3addr));
365 llc_hdr = (struct ath6kl_llc_snap_hdr *)(datap);
367 memset(ð_hdr, 0, sizeof(eth_hdr));
368 eth_hdr.h_proto = llc_hdr->eth_type;
370 switch ((le16_to_cpu(wh.frame_control)) &
371 (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
373 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
374 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
376 case IEEE80211_FCTL_TODS:
377 memcpy(eth_hdr.h_dest, wh.addr3, ETH_ALEN);
378 memcpy(eth_hdr.h_source, wh.addr2, ETH_ALEN);
380 case IEEE80211_FCTL_FROMDS:
381 memcpy(eth_hdr.h_dest, wh.addr1, ETH_ALEN);
382 memcpy(eth_hdr.h_source, wh.addr3, ETH_ALEN);
384 case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS:
388 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
389 skb_push(skb, sizeof(eth_hdr));
393 memcpy(datap, ð_hdr, sizeof(eth_hdr));
399 * Performs 802.3 to DIX encapsulation for received packets.
400 * Assumes the entire 802.3 header is contigous.
402 int ath6kl_wmi_dot3_2_dix(struct sk_buff *skb)
404 struct ath6kl_llc_snap_hdr *llc_hdr;
405 struct ethhdr eth_hdr;
408 if (WARN_ON(skb == NULL))
413 memcpy(ð_hdr, datap, sizeof(eth_hdr));
415 llc_hdr = (struct ath6kl_llc_snap_hdr *) (datap + sizeof(eth_hdr));
416 eth_hdr.h_proto = llc_hdr->eth_type;
418 skb_pull(skb, sizeof(struct ath6kl_llc_snap_hdr));
421 memcpy(datap, ð_hdr, sizeof(eth_hdr));
426 static int ath6kl_wmi_tx_complete_event_rx(u8 *datap, int len)
428 struct tx_complete_msg_v1 *msg_v1;
429 struct wmi_tx_complete_event *evt;
433 evt = (struct wmi_tx_complete_event *) datap;
435 ath6kl_dbg(ATH6KL_DBG_WMI, "comp: %d %d %d\n",
436 evt->num_msg, evt->msg_len, evt->msg_type);
438 for (index = 0; index < evt->num_msg; index++) {
439 size = sizeof(struct wmi_tx_complete_event) +
440 (index * sizeof(struct tx_complete_msg_v1));
441 msg_v1 = (struct tx_complete_msg_v1 *)(datap + size);
443 ath6kl_dbg(ATH6KL_DBG_WMI, "msg: %d %d %d %d\n",
444 msg_v1->status, msg_v1->pkt_id,
445 msg_v1->rate_idx, msg_v1->ack_failures);
451 static int ath6kl_wmi_remain_on_chnl_event_rx(struct wmi *wmi, u8 *datap,
452 int len, struct ath6kl_vif *vif)
454 struct wmi_remain_on_chnl_event *ev;
457 struct ieee80211_channel *chan;
458 struct ath6kl *ar = wmi->parent_dev;
461 if (len < sizeof(*ev))
464 ev = (struct wmi_remain_on_chnl_event *) datap;
465 freq = le32_to_cpu(ev->freq);
466 dur = le32_to_cpu(ev->duration);
467 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl: freq=%u dur=%u\n",
469 chan = ieee80211_get_channel(ar->wiphy, freq);
471 ath6kl_dbg(ATH6KL_DBG_WMI,
472 "remain_on_chnl: Unknown channel (freq=%u)\n",
476 id = vif->last_roc_id;
477 cfg80211_ready_on_channel(&vif->wdev, id, chan,
483 static int ath6kl_wmi_cancel_remain_on_chnl_event_rx(struct wmi *wmi,
485 struct ath6kl_vif *vif)
487 struct wmi_cancel_remain_on_chnl_event *ev;
490 struct ieee80211_channel *chan;
491 struct ath6kl *ar = wmi->parent_dev;
494 if (len < sizeof(*ev))
497 ev = (struct wmi_cancel_remain_on_chnl_event *) datap;
498 freq = le32_to_cpu(ev->freq);
499 dur = le32_to_cpu(ev->duration);
500 ath6kl_dbg(ATH6KL_DBG_WMI,
501 "cancel_remain_on_chnl: freq=%u dur=%u status=%u\n",
502 freq, dur, ev->status);
503 chan = ieee80211_get_channel(ar->wiphy, freq);
505 ath6kl_dbg(ATH6KL_DBG_WMI,
506 "cancel_remain_on_chnl: Unknown channel (freq=%u)\n",
510 if (vif->last_cancel_roc_id &&
511 vif->last_cancel_roc_id + 1 == vif->last_roc_id)
512 id = vif->last_cancel_roc_id; /* event for cancel command */
514 id = vif->last_roc_id; /* timeout on uncanceled r-o-c */
515 vif->last_cancel_roc_id = 0;
516 cfg80211_remain_on_channel_expired(&vif->wdev, id, chan, GFP_ATOMIC);
521 static int ath6kl_wmi_tx_status_event_rx(struct wmi *wmi, u8 *datap, int len,
522 struct ath6kl_vif *vif)
524 struct wmi_tx_status_event *ev;
527 if (len < sizeof(*ev))
530 ev = (struct wmi_tx_status_event *) datap;
531 id = le32_to_cpu(ev->id);
532 ath6kl_dbg(ATH6KL_DBG_WMI, "tx_status: id=%x ack_status=%u\n",
534 if (wmi->last_mgmt_tx_frame) {
535 cfg80211_mgmt_tx_status(&vif->wdev, id,
536 wmi->last_mgmt_tx_frame,
537 wmi->last_mgmt_tx_frame_len,
538 !!ev->ack_status, GFP_ATOMIC);
539 kfree(wmi->last_mgmt_tx_frame);
540 wmi->last_mgmt_tx_frame = NULL;
541 wmi->last_mgmt_tx_frame_len = 0;
547 static int ath6kl_wmi_rx_probe_req_event_rx(struct wmi *wmi, u8 *datap, int len,
548 struct ath6kl_vif *vif)
550 struct wmi_p2p_rx_probe_req_event *ev;
554 if (len < sizeof(*ev))
557 ev = (struct wmi_p2p_rx_probe_req_event *) datap;
558 freq = le32_to_cpu(ev->freq);
559 dlen = le16_to_cpu(ev->len);
560 if (datap + len < ev->data + dlen) {
561 ath6kl_err("invalid wmi_p2p_rx_probe_req_event: len=%d dlen=%u\n",
565 ath6kl_dbg(ATH6KL_DBG_WMI,
566 "rx_probe_req: len=%u freq=%u probe_req_report=%d\n",
567 dlen, freq, vif->probe_req_report);
569 if (vif->probe_req_report || vif->nw_type == AP_NETWORK)
570 cfg80211_rx_mgmt(&vif->wdev, freq, 0,
571 ev->data, dlen, GFP_ATOMIC);
576 static int ath6kl_wmi_p2p_capabilities_event_rx(u8 *datap, int len)
578 struct wmi_p2p_capabilities_event *ev;
581 if (len < sizeof(*ev))
584 ev = (struct wmi_p2p_capabilities_event *) datap;
585 dlen = le16_to_cpu(ev->len);
586 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_capab: len=%u\n", dlen);
591 static int ath6kl_wmi_rx_action_event_rx(struct wmi *wmi, u8 *datap, int len,
592 struct ath6kl_vif *vif)
594 struct wmi_rx_action_event *ev;
598 if (len < sizeof(*ev))
601 ev = (struct wmi_rx_action_event *) datap;
602 freq = le32_to_cpu(ev->freq);
603 dlen = le16_to_cpu(ev->len);
604 if (datap + len < ev->data + dlen) {
605 ath6kl_err("invalid wmi_rx_action_event: len=%d dlen=%u\n",
609 ath6kl_dbg(ATH6KL_DBG_WMI, "rx_action: len=%u freq=%u\n", dlen, freq);
610 cfg80211_rx_mgmt(&vif->wdev, freq, 0,
611 ev->data, dlen, GFP_ATOMIC);
616 static int ath6kl_wmi_p2p_info_event_rx(u8 *datap, int len)
618 struct wmi_p2p_info_event *ev;
622 if (len < sizeof(*ev))
625 ev = (struct wmi_p2p_info_event *) datap;
626 flags = le32_to_cpu(ev->info_req_flags);
627 dlen = le16_to_cpu(ev->len);
628 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: flags=%x len=%d\n", flags, dlen);
630 if (flags & P2P_FLAG_CAPABILITIES_REQ) {
631 struct wmi_p2p_capabilities *cap;
632 if (dlen < sizeof(*cap))
634 cap = (struct wmi_p2p_capabilities *) ev->data;
635 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: GO Power Save = %d\n",
639 if (flags & P2P_FLAG_MACADDR_REQ) {
640 struct wmi_p2p_macaddr *mac;
641 if (dlen < sizeof(*mac))
643 mac = (struct wmi_p2p_macaddr *) ev->data;
644 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: MAC Address = %pM\n",
648 if (flags & P2P_FLAG_HMODEL_REQ) {
649 struct wmi_p2p_hmodel *mod;
650 if (dlen < sizeof(*mod))
652 mod = (struct wmi_p2p_hmodel *) ev->data;
653 ath6kl_dbg(ATH6KL_DBG_WMI, "p2p_info: P2P Model = %d (%s)\n",
655 mod->p2p_model ? "host" : "firmware");
660 static inline struct sk_buff *ath6kl_wmi_get_new_buf(u32 size)
664 skb = ath6kl_buf_alloc(size);
670 memset(skb->data, 0, size);
675 /* Send a "simple" wmi command -- one with no arguments */
676 static int ath6kl_wmi_simple_cmd(struct wmi *wmi, u8 if_idx,
677 enum wmi_cmd_id cmd_id)
682 skb = ath6kl_wmi_get_new_buf(0);
686 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, cmd_id, NO_SYNC_WMIFLAG);
691 static int ath6kl_wmi_ready_event_rx(struct wmi *wmi, u8 *datap, int len)
693 struct wmi_ready_event_2 *ev = (struct wmi_ready_event_2 *) datap;
695 if (len < sizeof(struct wmi_ready_event_2))
698 ath6kl_ready_event(wmi->parent_dev, ev->mac_addr,
699 le32_to_cpu(ev->sw_version),
700 le32_to_cpu(ev->abi_version), ev->phy_cap);
706 * Mechanism to modify the roaming behavior in the firmware. The lower rssi
707 * at which the station has to roam can be passed with
708 * WMI_SET_LRSSI_SCAN_PARAMS. Subtract 96 from RSSI to get the signal level
711 int ath6kl_wmi_set_roam_lrssi_cmd(struct wmi *wmi, u8 lrssi)
714 struct roam_ctrl_cmd *cmd;
716 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
720 cmd = (struct roam_ctrl_cmd *) skb->data;
722 cmd->info.params.lrssi_scan_period = cpu_to_le16(DEF_LRSSI_SCAN_PERIOD);
723 cmd->info.params.lrssi_scan_threshold = a_cpu_to_sle16(lrssi +
724 DEF_SCAN_FOR_ROAM_INTVL);
725 cmd->info.params.lrssi_roam_threshold = a_cpu_to_sle16(lrssi);
726 cmd->info.params.roam_rssi_floor = DEF_LRSSI_ROAM_FLOOR;
727 cmd->roam_ctrl = WMI_SET_LRSSI_SCAN_PARAMS;
729 ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
735 int ath6kl_wmi_force_roam_cmd(struct wmi *wmi, const u8 *bssid)
738 struct roam_ctrl_cmd *cmd;
740 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
744 cmd = (struct roam_ctrl_cmd *) skb->data;
746 memcpy(cmd->info.bssid, bssid, ETH_ALEN);
747 cmd->roam_ctrl = WMI_FORCE_ROAM;
749 ath6kl_dbg(ATH6KL_DBG_WMI, "force roam to %pM\n", bssid);
750 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
754 int ath6kl_wmi_ap_set_beacon_intvl_cmd(struct wmi *wmi, u8 if_idx,
758 struct set_beacon_int_cmd *cmd;
760 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
764 cmd = (struct set_beacon_int_cmd *) skb->data;
766 cmd->beacon_intvl = cpu_to_le32(beacon_intvl);
767 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
768 WMI_SET_BEACON_INT_CMDID, NO_SYNC_WMIFLAG);
771 int ath6kl_wmi_ap_set_dtim_cmd(struct wmi *wmi, u8 if_idx, u32 dtim_period)
774 struct set_dtim_cmd *cmd;
776 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
780 cmd = (struct set_dtim_cmd *) skb->data;
782 cmd->dtim_period = cpu_to_le32(dtim_period);
783 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
784 WMI_AP_SET_DTIM_CMDID, NO_SYNC_WMIFLAG);
787 int ath6kl_wmi_set_roam_mode_cmd(struct wmi *wmi, enum wmi_roam_mode mode)
790 struct roam_ctrl_cmd *cmd;
792 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
796 cmd = (struct roam_ctrl_cmd *) skb->data;
798 cmd->info.roam_mode = mode;
799 cmd->roam_ctrl = WMI_SET_ROAM_MODE;
801 ath6kl_dbg(ATH6KL_DBG_WMI, "set roam mode %d\n", mode);
802 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_ROAM_CTRL_CMDID,
806 static int ath6kl_wmi_connect_event_rx(struct wmi *wmi, u8 *datap, int len,
807 struct ath6kl_vif *vif)
809 struct wmi_connect_event *ev;
812 if (len < sizeof(struct wmi_connect_event))
815 ev = (struct wmi_connect_event *) datap;
817 if (vif->nw_type == AP_NETWORK) {
818 /* AP mode start/STA connected event */
819 struct net_device *dev = vif->ndev;
820 if (memcmp(dev->dev_addr, ev->u.ap_bss.bssid, ETH_ALEN) == 0) {
821 ath6kl_dbg(ATH6KL_DBG_WMI,
822 "%s: freq %d bssid %pM (AP started)\n",
823 __func__, le16_to_cpu(ev->u.ap_bss.ch),
825 ath6kl_connect_ap_mode_bss(
826 vif, le16_to_cpu(ev->u.ap_bss.ch));
828 ath6kl_dbg(ATH6KL_DBG_WMI,
829 "%s: aid %u mac_addr %pM auth=%u keymgmt=%u cipher=%u apsd_info=%u (STA connected)\n",
830 __func__, ev->u.ap_sta.aid,
831 ev->u.ap_sta.mac_addr,
833 ev->u.ap_sta.keymgmt,
834 le16_to_cpu(ev->u.ap_sta.cipher),
835 ev->u.ap_sta.apsd_info);
837 ath6kl_connect_ap_mode_sta(
838 vif, ev->u.ap_sta.aid, ev->u.ap_sta.mac_addr,
839 ev->u.ap_sta.keymgmt,
840 le16_to_cpu(ev->u.ap_sta.cipher),
841 ev->u.ap_sta.auth, ev->assoc_req_len,
842 ev->assoc_info + ev->beacon_ie_len,
843 ev->u.ap_sta.apsd_info);
848 /* STA/IBSS mode connection event */
850 ath6kl_dbg(ATH6KL_DBG_WMI,
851 "wmi event connect freq %d bssid %pM listen_intvl %d beacon_intvl %d type %d\n",
852 le16_to_cpu(ev->u.sta.ch), ev->u.sta.bssid,
853 le16_to_cpu(ev->u.sta.listen_intvl),
854 le16_to_cpu(ev->u.sta.beacon_intvl),
855 le32_to_cpu(ev->u.sta.nw_type));
857 /* Start of assoc rsp IEs */
858 pie = ev->assoc_info + ev->beacon_ie_len +
859 ev->assoc_req_len + (sizeof(u16) * 3); /* capinfo, status, aid */
861 /* End of assoc rsp IEs */
862 peie = ev->assoc_info + ev->beacon_ie_len + ev->assoc_req_len +
867 case WLAN_EID_VENDOR_SPECIFIC:
868 if (pie[1] > 3 && pie[2] == 0x00 && pie[3] == 0x50 &&
869 pie[4] == 0xf2 && pie[5] == WMM_OUI_TYPE) {
870 /* WMM OUT (00:50:F2) */
872 pie[6] == WMM_PARAM_OUI_SUBTYPE)
873 wmi->is_wmm_enabled = true;
878 if (wmi->is_wmm_enabled)
884 ath6kl_connect_event(vif, le16_to_cpu(ev->u.sta.ch),
886 le16_to_cpu(ev->u.sta.listen_intvl),
887 le16_to_cpu(ev->u.sta.beacon_intvl),
888 le32_to_cpu(ev->u.sta.nw_type),
889 ev->beacon_ie_len, ev->assoc_req_len,
890 ev->assoc_resp_len, ev->assoc_info);
895 static struct country_code_to_enum_rd *
896 ath6kl_regd_find_country(u16 countryCode)
900 for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
901 if (allCountries[i].countryCode == countryCode)
902 return &allCountries[i];
908 static struct reg_dmn_pair_mapping *
909 ath6kl_get_regpair(u16 regdmn)
913 if (regdmn == NO_ENUMRD)
916 for (i = 0; i < ARRAY_SIZE(regDomainPairs); i++) {
917 if (regDomainPairs[i].regDmnEnum == regdmn)
918 return ®DomainPairs[i];
924 static struct country_code_to_enum_rd *
925 ath6kl_regd_find_country_by_rd(u16 regdmn)
929 for (i = 0; i < ARRAY_SIZE(allCountries); i++) {
930 if (allCountries[i].regDmnEnum == regdmn)
931 return &allCountries[i];
937 static void ath6kl_wmi_regdomain_event(struct wmi *wmi, u8 *datap, int len)
940 struct ath6kl_wmi_regdomain *ev;
941 struct country_code_to_enum_rd *country = NULL;
942 struct reg_dmn_pair_mapping *regpair = NULL;
946 ev = (struct ath6kl_wmi_regdomain *) datap;
947 reg_code = le32_to_cpu(ev->reg_code);
949 if ((reg_code >> ATH6KL_COUNTRY_RD_SHIFT) & COUNTRY_ERD_FLAG)
950 country = ath6kl_regd_find_country((u16) reg_code);
951 else if (!(((u16) reg_code & WORLD_SKU_MASK) == WORLD_SKU_PREFIX)) {
953 regpair = ath6kl_get_regpair((u16) reg_code);
954 country = ath6kl_regd_find_country_by_rd((u16) reg_code);
956 ath6kl_dbg(ATH6KL_DBG_WMI, "Regpair used: 0x%0x\n",
957 regpair->regDmnEnum);
959 ath6kl_warn("Regpair not found reg_code 0x%0x\n",
963 if (country && wmi->parent_dev->wiphy_registered) {
964 alpha2[0] = country->isoName[0];
965 alpha2[1] = country->isoName[1];
967 regulatory_hint(wmi->parent_dev->wiphy, alpha2);
969 ath6kl_dbg(ATH6KL_DBG_WMI, "Country alpha2 being used: %c%c\n",
970 alpha2[0], alpha2[1]);
974 static int ath6kl_wmi_disconnect_event_rx(struct wmi *wmi, u8 *datap, int len,
975 struct ath6kl_vif *vif)
977 struct wmi_disconnect_event *ev;
978 wmi->traffic_class = 100;
980 if (len < sizeof(struct wmi_disconnect_event))
983 ev = (struct wmi_disconnect_event *) datap;
985 ath6kl_dbg(ATH6KL_DBG_WMI,
986 "wmi event disconnect proto_reason %d bssid %pM wmi_reason %d assoc_resp_len %d\n",
987 le16_to_cpu(ev->proto_reason_status), ev->bssid,
988 ev->disconn_reason, ev->assoc_resp_len);
990 wmi->is_wmm_enabled = false;
992 ath6kl_disconnect_event(vif, ev->disconn_reason,
993 ev->bssid, ev->assoc_resp_len, ev->assoc_info,
994 le16_to_cpu(ev->proto_reason_status));
999 static int ath6kl_wmi_peer_node_event_rx(struct wmi *wmi, u8 *datap, int len)
1001 struct wmi_peer_node_event *ev;
1003 if (len < sizeof(struct wmi_peer_node_event))
1006 ev = (struct wmi_peer_node_event *) datap;
1008 if (ev->event_code == PEER_NODE_JOIN_EVENT)
1009 ath6kl_dbg(ATH6KL_DBG_WMI, "joined node with mac addr: %pM\n",
1011 else if (ev->event_code == PEER_NODE_LEAVE_EVENT)
1012 ath6kl_dbg(ATH6KL_DBG_WMI, "left node with mac addr: %pM\n",
1018 static int ath6kl_wmi_tkip_micerr_event_rx(struct wmi *wmi, u8 *datap, int len,
1019 struct ath6kl_vif *vif)
1021 struct wmi_tkip_micerr_event *ev;
1023 if (len < sizeof(struct wmi_tkip_micerr_event))
1026 ev = (struct wmi_tkip_micerr_event *) datap;
1028 ath6kl_tkip_micerr_event(vif, ev->key_id, ev->is_mcast);
1033 void ath6kl_wmi_sscan_timer(unsigned long ptr)
1035 struct ath6kl_vif *vif = (struct ath6kl_vif *) ptr;
1037 cfg80211_sched_scan_results(vif->ar->wiphy);
1040 static int ath6kl_wmi_bssinfo_event_rx(struct wmi *wmi, u8 *datap, int len,
1041 struct ath6kl_vif *vif)
1043 struct wmi_bss_info_hdr2 *bih;
1045 struct ieee80211_channel *channel;
1046 struct ath6kl *ar = wmi->parent_dev;
1047 struct ieee80211_mgmt *mgmt;
1048 struct cfg80211_bss *bss;
1050 if (len <= sizeof(struct wmi_bss_info_hdr2))
1053 bih = (struct wmi_bss_info_hdr2 *) datap;
1054 buf = datap + sizeof(struct wmi_bss_info_hdr2);
1055 len -= sizeof(struct wmi_bss_info_hdr2);
1057 ath6kl_dbg(ATH6KL_DBG_WMI,
1058 "bss info evt - ch %u, snr %d, rssi %d, bssid \"%pM\" "
1060 bih->ch, bih->snr, bih->snr - 95, bih->bssid,
1063 if (bih->frame_type != BEACON_FTYPE &&
1064 bih->frame_type != PROBERESP_FTYPE)
1065 return 0; /* Only update BSS table for now */
1067 if (bih->frame_type == BEACON_FTYPE &&
1068 test_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags)) {
1069 clear_bit(CLEAR_BSSFILTER_ON_BEACON, &vif->flags);
1070 ath6kl_wmi_bssfilter_cmd(ar->wmi, vif->fw_vif_idx,
1071 NONE_BSS_FILTER, 0);
1074 channel = ieee80211_get_channel(ar->wiphy, le16_to_cpu(bih->ch));
1075 if (channel == NULL)
1078 if (len < 8 + 2 + 2)
1081 if (bih->frame_type == BEACON_FTYPE &&
1082 test_bit(CONNECTED, &vif->flags) &&
1083 memcmp(bih->bssid, vif->bssid, ETH_ALEN) == 0) {
1085 tim = cfg80211_find_ie(WLAN_EID_TIM, buf + 8 + 2 + 2,
1087 if (tim && tim[1] >= 2) {
1088 vif->assoc_bss_dtim_period = tim[3];
1089 set_bit(DTIM_PERIOD_AVAIL, &vif->flags);
1094 * In theory, use of cfg80211_inform_bss() would be more natural here
1095 * since we do not have the full frame. However, at least for now,
1096 * cfg80211 can only distinguish Beacon and Probe Response frames from
1097 * each other when using cfg80211_inform_bss_frame(), so let's build a
1098 * fake IEEE 802.11 header to be able to take benefit of this.
1100 mgmt = kmalloc(24 + len, GFP_ATOMIC);
1104 if (bih->frame_type == BEACON_FTYPE) {
1105 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1106 IEEE80211_STYPE_BEACON);
1107 memset(mgmt->da, 0xff, ETH_ALEN);
1109 struct net_device *dev = vif->ndev;
1111 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
1112 IEEE80211_STYPE_PROBE_RESP);
1113 memcpy(mgmt->da, dev->dev_addr, ETH_ALEN);
1115 mgmt->duration = cpu_to_le16(0);
1116 memcpy(mgmt->sa, bih->bssid, ETH_ALEN);
1117 memcpy(mgmt->bssid, bih->bssid, ETH_ALEN);
1118 mgmt->seq_ctrl = cpu_to_le16(0);
1120 memcpy(&mgmt->u.beacon, buf, len);
1122 bss = cfg80211_inform_bss_frame(ar->wiphy, channel, mgmt,
1123 24 + len, (bih->snr - 95) * 100,
1128 cfg80211_put_bss(ar->wiphy, bss);
1131 * Firmware doesn't return any event when scheduled scan has
1132 * finished, so we need to use a timer to find out when there are
1135 * The timer is started from the first bss info received, otherwise
1136 * the timer would not ever fire if the scan interval is short
1139 if (test_bit(SCHED_SCANNING, &vif->flags) &&
1140 !timer_pending(&vif->sched_scan_timer)) {
1141 mod_timer(&vif->sched_scan_timer, jiffies +
1142 msecs_to_jiffies(ATH6KL_SCHED_SCAN_RESULT_DELAY));
1148 /* Inactivity timeout of a fatpipe(pstream) at the target */
1149 static int ath6kl_wmi_pstream_timeout_event_rx(struct wmi *wmi, u8 *datap,
1152 struct wmi_pstream_timeout_event *ev;
1154 if (len < sizeof(struct wmi_pstream_timeout_event))
1157 ev = (struct wmi_pstream_timeout_event *) datap;
1160 * When the pstream (fat pipe == AC) timesout, it means there were
1161 * no thinStreams within this pstream & it got implicitly created
1162 * due to data flow on this AC. We start the inactivity timer only
1163 * for implicitly created pstream. Just reset the host state.
1165 spin_lock_bh(&wmi->lock);
1166 wmi->stream_exist_for_ac[ev->traffic_class] = 0;
1167 wmi->fat_pipe_exist &= ~(1 << ev->traffic_class);
1168 spin_unlock_bh(&wmi->lock);
1170 /* Indicate inactivity to driver layer for this fatpipe (pstream) */
1171 ath6kl_indicate_tx_activity(wmi->parent_dev, ev->traffic_class, false);
1176 static int ath6kl_wmi_bitrate_reply_rx(struct wmi *wmi, u8 *datap, int len)
1178 struct wmi_bit_rate_reply *reply;
1182 if (len < sizeof(struct wmi_bit_rate_reply))
1185 reply = (struct wmi_bit_rate_reply *) datap;
1187 ath6kl_dbg(ATH6KL_DBG_WMI, "rateindex %d\n", reply->rate_index);
1189 if (reply->rate_index == (s8) RATE_AUTO) {
1192 index = reply->rate_index & 0x7f;
1193 if (WARN_ON_ONCE(index > (RATE_MCS_7_40 + 1)))
1196 sgi = (reply->rate_index & 0x80) ? 1 : 0;
1197 rate = wmi_rate_tbl[index][sgi];
1200 ath6kl_wakeup_event(wmi->parent_dev);
1205 static int ath6kl_wmi_test_rx(struct wmi *wmi, u8 *datap, int len)
1207 ath6kl_tm_rx_event(wmi->parent_dev, datap, len);
1212 static int ath6kl_wmi_ratemask_reply_rx(struct wmi *wmi, u8 *datap, int len)
1214 if (len < sizeof(struct wmi_fix_rates_reply))
1217 ath6kl_wakeup_event(wmi->parent_dev);
1222 static int ath6kl_wmi_ch_list_reply_rx(struct wmi *wmi, u8 *datap, int len)
1224 if (len < sizeof(struct wmi_channel_list_reply))
1227 ath6kl_wakeup_event(wmi->parent_dev);
1232 static int ath6kl_wmi_tx_pwr_reply_rx(struct wmi *wmi, u8 *datap, int len)
1234 struct wmi_tx_pwr_reply *reply;
1236 if (len < sizeof(struct wmi_tx_pwr_reply))
1239 reply = (struct wmi_tx_pwr_reply *) datap;
1240 ath6kl_txpwr_rx_evt(wmi->parent_dev, reply->dbM);
1245 static int ath6kl_wmi_keepalive_reply_rx(struct wmi *wmi, u8 *datap, int len)
1247 if (len < sizeof(struct wmi_get_keepalive_cmd))
1250 ath6kl_wakeup_event(wmi->parent_dev);
1255 static int ath6kl_wmi_scan_complete_rx(struct wmi *wmi, u8 *datap, int len,
1256 struct ath6kl_vif *vif)
1258 struct wmi_scan_complete_event *ev;
1260 ev = (struct wmi_scan_complete_event *) datap;
1262 ath6kl_scan_complete_evt(vif, a_sle32_to_cpu(ev->status));
1263 wmi->is_probe_ssid = false;
1268 static int ath6kl_wmi_neighbor_report_event_rx(struct wmi *wmi, u8 *datap,
1269 int len, struct ath6kl_vif *vif)
1271 struct wmi_neighbor_report_event *ev;
1274 if (len < sizeof(*ev))
1276 ev = (struct wmi_neighbor_report_event *) datap;
1277 if (sizeof(*ev) + ev->num_neighbors * sizeof(struct wmi_neighbor_info)
1279 ath6kl_dbg(ATH6KL_DBG_WMI,
1280 "truncated neighbor event (num=%d len=%d)\n",
1281 ev->num_neighbors, len);
1284 for (i = 0; i < ev->num_neighbors; i++) {
1285 ath6kl_dbg(ATH6KL_DBG_WMI, "neighbor %d/%d - %pM 0x%x\n",
1286 i + 1, ev->num_neighbors, ev->neighbor[i].bssid,
1287 ev->neighbor[i].bss_flags);
1288 cfg80211_pmksa_candidate_notify(vif->ndev, i,
1289 ev->neighbor[i].bssid,
1290 !!(ev->neighbor[i].bss_flags &
1291 WMI_PREAUTH_CAPABLE_BSS),
1299 * Target is reporting a programming error. This is for
1300 * developer aid only. Target only checks a few common violations
1301 * and it is responsibility of host to do all error checking.
1302 * Behavior of target after wmi error event is undefined.
1303 * A reset is recommended.
1305 static int ath6kl_wmi_error_event_rx(struct wmi *wmi, u8 *datap, int len)
1307 const char *type = "unknown error";
1308 struct wmi_cmd_error_event *ev;
1309 ev = (struct wmi_cmd_error_event *) datap;
1311 switch (ev->err_code) {
1313 type = "invalid parameter";
1316 type = "invalid state";
1318 case INTERNAL_ERROR:
1319 type = "internal error";
1323 ath6kl_dbg(ATH6KL_DBG_WMI, "programming error, cmd=%d %s\n",
1329 static int ath6kl_wmi_stats_event_rx(struct wmi *wmi, u8 *datap, int len,
1330 struct ath6kl_vif *vif)
1332 ath6kl_tgt_stats_event(vif, datap, len);
1337 static u8 ath6kl_wmi_get_upper_threshold(s16 rssi,
1338 struct sq_threshold_params *sq_thresh,
1342 u8 threshold = (u8) sq_thresh->upper_threshold[size - 1];
1344 /* The list is already in sorted order. Get the next lower value */
1345 for (index = 0; index < size; index++) {
1346 if (rssi < sq_thresh->upper_threshold[index]) {
1347 threshold = (u8) sq_thresh->upper_threshold[index];
1355 static u8 ath6kl_wmi_get_lower_threshold(s16 rssi,
1356 struct sq_threshold_params *sq_thresh,
1360 u8 threshold = (u8) sq_thresh->lower_threshold[size - 1];
1362 /* The list is already in sorted order. Get the next lower value */
1363 for (index = 0; index < size; index++) {
1364 if (rssi > sq_thresh->lower_threshold[index]) {
1365 threshold = (u8) sq_thresh->lower_threshold[index];
1373 static int ath6kl_wmi_send_rssi_threshold_params(struct wmi *wmi,
1374 struct wmi_rssi_threshold_params_cmd *rssi_cmd)
1376 struct sk_buff *skb;
1377 struct wmi_rssi_threshold_params_cmd *cmd;
1379 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1383 cmd = (struct wmi_rssi_threshold_params_cmd *) skb->data;
1384 memcpy(cmd, rssi_cmd, sizeof(struct wmi_rssi_threshold_params_cmd));
1386 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_RSSI_THRESHOLD_PARAMS_CMDID,
1390 static int ath6kl_wmi_rssi_threshold_event_rx(struct wmi *wmi, u8 *datap,
1393 struct wmi_rssi_threshold_event *reply;
1394 struct wmi_rssi_threshold_params_cmd cmd;
1395 struct sq_threshold_params *sq_thresh;
1396 enum wmi_rssi_threshold_val new_threshold;
1397 u8 upper_rssi_threshold, lower_rssi_threshold;
1401 if (len < sizeof(struct wmi_rssi_threshold_event))
1404 reply = (struct wmi_rssi_threshold_event *) datap;
1405 new_threshold = (enum wmi_rssi_threshold_val) reply->range;
1406 rssi = a_sle16_to_cpu(reply->rssi);
1408 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_RSSI];
1411 * Identify the threshold breached and communicate that to the app.
1412 * After that install a new set of thresholds based on the signal
1413 * quality reported by the target
1415 if (new_threshold) {
1416 /* Upper threshold breached */
1417 if (rssi < sq_thresh->upper_threshold[0]) {
1418 ath6kl_dbg(ATH6KL_DBG_WMI,
1419 "spurious upper rssi threshold event: %d\n",
1421 } else if ((rssi < sq_thresh->upper_threshold[1]) &&
1422 (rssi >= sq_thresh->upper_threshold[0])) {
1423 new_threshold = WMI_RSSI_THRESHOLD1_ABOVE;
1424 } else if ((rssi < sq_thresh->upper_threshold[2]) &&
1425 (rssi >= sq_thresh->upper_threshold[1])) {
1426 new_threshold = WMI_RSSI_THRESHOLD2_ABOVE;
1427 } else if ((rssi < sq_thresh->upper_threshold[3]) &&
1428 (rssi >= sq_thresh->upper_threshold[2])) {
1429 new_threshold = WMI_RSSI_THRESHOLD3_ABOVE;
1430 } else if ((rssi < sq_thresh->upper_threshold[4]) &&
1431 (rssi >= sq_thresh->upper_threshold[3])) {
1432 new_threshold = WMI_RSSI_THRESHOLD4_ABOVE;
1433 } else if ((rssi < sq_thresh->upper_threshold[5]) &&
1434 (rssi >= sq_thresh->upper_threshold[4])) {
1435 new_threshold = WMI_RSSI_THRESHOLD5_ABOVE;
1436 } else if (rssi >= sq_thresh->upper_threshold[5]) {
1437 new_threshold = WMI_RSSI_THRESHOLD6_ABOVE;
1440 /* Lower threshold breached */
1441 if (rssi > sq_thresh->lower_threshold[0]) {
1442 ath6kl_dbg(ATH6KL_DBG_WMI,
1443 "spurious lower rssi threshold event: %d %d\n",
1444 rssi, sq_thresh->lower_threshold[0]);
1445 } else if ((rssi > sq_thresh->lower_threshold[1]) &&
1446 (rssi <= sq_thresh->lower_threshold[0])) {
1447 new_threshold = WMI_RSSI_THRESHOLD6_BELOW;
1448 } else if ((rssi > sq_thresh->lower_threshold[2]) &&
1449 (rssi <= sq_thresh->lower_threshold[1])) {
1450 new_threshold = WMI_RSSI_THRESHOLD5_BELOW;
1451 } else if ((rssi > sq_thresh->lower_threshold[3]) &&
1452 (rssi <= sq_thresh->lower_threshold[2])) {
1453 new_threshold = WMI_RSSI_THRESHOLD4_BELOW;
1454 } else if ((rssi > sq_thresh->lower_threshold[4]) &&
1455 (rssi <= sq_thresh->lower_threshold[3])) {
1456 new_threshold = WMI_RSSI_THRESHOLD3_BELOW;
1457 } else if ((rssi > sq_thresh->lower_threshold[5]) &&
1458 (rssi <= sq_thresh->lower_threshold[4])) {
1459 new_threshold = WMI_RSSI_THRESHOLD2_BELOW;
1460 } else if (rssi <= sq_thresh->lower_threshold[5]) {
1461 new_threshold = WMI_RSSI_THRESHOLD1_BELOW;
1465 /* Calculate and install the next set of thresholds */
1466 lower_rssi_threshold = ath6kl_wmi_get_lower_threshold(rssi, sq_thresh,
1467 sq_thresh->lower_threshold_valid_count);
1468 upper_rssi_threshold = ath6kl_wmi_get_upper_threshold(rssi, sq_thresh,
1469 sq_thresh->upper_threshold_valid_count);
1471 /* Issue a wmi command to install the thresholds */
1472 cmd.thresh_above1_val = a_cpu_to_sle16(upper_rssi_threshold);
1473 cmd.thresh_below1_val = a_cpu_to_sle16(lower_rssi_threshold);
1474 cmd.weight = sq_thresh->weight;
1475 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1477 ret = ath6kl_wmi_send_rssi_threshold_params(wmi, &cmd);
1479 ath6kl_err("unable to configure rssi thresholds\n");
1486 static int ath6kl_wmi_cac_event_rx(struct wmi *wmi, u8 *datap, int len,
1487 struct ath6kl_vif *vif)
1489 struct wmi_cac_event *reply;
1490 struct ieee80211_tspec_ie *ts;
1491 u16 active_tsids, tsinfo;
1495 if (len < sizeof(struct wmi_cac_event))
1498 reply = (struct wmi_cac_event *) datap;
1500 if ((reply->cac_indication == CAC_INDICATION_ADMISSION_RESP) &&
1501 (reply->status_code != IEEE80211_TSPEC_STATUS_ADMISS_ACCEPTED)) {
1503 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1504 tsinfo = le16_to_cpu(ts->tsinfo);
1505 tsid = (tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1506 IEEE80211_WMM_IE_TSPEC_TID_MASK;
1508 ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
1510 } else if (reply->cac_indication == CAC_INDICATION_NO_RESP) {
1512 * Following assumes that there is only one outstanding
1513 * ADDTS request when this event is received
1515 spin_lock_bh(&wmi->lock);
1516 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1517 spin_unlock_bh(&wmi->lock);
1519 for (index = 0; index < sizeof(active_tsids) * 8; index++) {
1520 if ((active_tsids >> index) & 1)
1523 if (index < (sizeof(active_tsids) * 8))
1524 ath6kl_wmi_delete_pstream_cmd(wmi, vif->fw_vif_idx,
1529 * Clear active tsids and Add missing handling
1530 * for delete qos stream from AP
1532 else if (reply->cac_indication == CAC_INDICATION_DELETE) {
1534 ts = (struct ieee80211_tspec_ie *) &(reply->tspec_suggestion);
1535 tsinfo = le16_to_cpu(ts->tsinfo);
1536 ts_id = ((tsinfo >> IEEE80211_WMM_IE_TSPEC_TID_SHIFT) &
1537 IEEE80211_WMM_IE_TSPEC_TID_MASK);
1539 spin_lock_bh(&wmi->lock);
1540 wmi->stream_exist_for_ac[reply->ac] &= ~(1 << ts_id);
1541 active_tsids = wmi->stream_exist_for_ac[reply->ac];
1542 spin_unlock_bh(&wmi->lock);
1544 /* Indicate stream inactivity to driver layer only if all tsids
1545 * within this AC are deleted.
1547 if (!active_tsids) {
1548 ath6kl_indicate_tx_activity(wmi->parent_dev, reply->ac,
1550 wmi->fat_pipe_exist &= ~(1 << reply->ac);
1557 static int ath6kl_wmi_txe_notify_event_rx(struct wmi *wmi, u8 *datap, int len,
1558 struct ath6kl_vif *vif)
1560 struct wmi_txe_notify_event *ev;
1563 if (len < sizeof(*ev))
1566 if (vif->sme_state != SME_CONNECTED)
1569 ev = (struct wmi_txe_notify_event *) datap;
1570 rate = le32_to_cpu(ev->rate);
1571 pkts = le32_to_cpu(ev->pkts);
1573 ath6kl_dbg(ATH6KL_DBG_WMI, "TXE notify event: peer %pM rate %d% pkts %d intvl %ds\n",
1574 vif->bssid, rate, pkts, vif->txe_intvl);
1576 cfg80211_cqm_txe_notify(vif->ndev, vif->bssid, pkts,
1577 rate, vif->txe_intvl, GFP_KERNEL);
1582 int ath6kl_wmi_set_txe_notify(struct wmi *wmi, u8 idx,
1583 u32 rate, u32 pkts, u32 intvl)
1585 struct sk_buff *skb;
1586 struct wmi_txe_notify_cmd *cmd;
1588 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1592 cmd = (struct wmi_txe_notify_cmd *) skb->data;
1593 cmd->rate = cpu_to_le32(rate);
1594 cmd->pkts = cpu_to_le32(pkts);
1595 cmd->intvl = cpu_to_le32(intvl);
1597 return ath6kl_wmi_cmd_send(wmi, idx, skb, WMI_SET_TXE_NOTIFY_CMDID,
1601 int ath6kl_wmi_set_rssi_filter_cmd(struct wmi *wmi, u8 if_idx, s8 rssi)
1603 struct sk_buff *skb;
1604 struct wmi_set_rssi_filter_cmd *cmd;
1607 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1611 cmd = (struct wmi_set_rssi_filter_cmd *) skb->data;
1614 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_RSSI_FILTER_CMDID,
1619 static int ath6kl_wmi_send_snr_threshold_params(struct wmi *wmi,
1620 struct wmi_snr_threshold_params_cmd *snr_cmd)
1622 struct sk_buff *skb;
1623 struct wmi_snr_threshold_params_cmd *cmd;
1625 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
1629 cmd = (struct wmi_snr_threshold_params_cmd *) skb->data;
1630 memcpy(cmd, snr_cmd, sizeof(struct wmi_snr_threshold_params_cmd));
1632 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SNR_THRESHOLD_PARAMS_CMDID,
1636 static int ath6kl_wmi_snr_threshold_event_rx(struct wmi *wmi, u8 *datap,
1639 struct wmi_snr_threshold_event *reply;
1640 struct sq_threshold_params *sq_thresh;
1641 struct wmi_snr_threshold_params_cmd cmd;
1642 enum wmi_snr_threshold_val new_threshold;
1643 u8 upper_snr_threshold, lower_snr_threshold;
1647 if (len < sizeof(struct wmi_snr_threshold_event))
1650 reply = (struct wmi_snr_threshold_event *) datap;
1652 new_threshold = (enum wmi_snr_threshold_val) reply->range;
1655 sq_thresh = &wmi->sq_threshld[SIGNAL_QUALITY_METRICS_SNR];
1658 * Identify the threshold breached and communicate that to the app.
1659 * After that install a new set of thresholds based on the signal
1660 * quality reported by the target.
1662 if (new_threshold) {
1663 /* Upper threshold breached */
1664 if (snr < sq_thresh->upper_threshold[0]) {
1665 ath6kl_dbg(ATH6KL_DBG_WMI,
1666 "spurious upper snr threshold event: %d\n",
1668 } else if ((snr < sq_thresh->upper_threshold[1]) &&
1669 (snr >= sq_thresh->upper_threshold[0])) {
1670 new_threshold = WMI_SNR_THRESHOLD1_ABOVE;
1671 } else if ((snr < sq_thresh->upper_threshold[2]) &&
1672 (snr >= sq_thresh->upper_threshold[1])) {
1673 new_threshold = WMI_SNR_THRESHOLD2_ABOVE;
1674 } else if ((snr < sq_thresh->upper_threshold[3]) &&
1675 (snr >= sq_thresh->upper_threshold[2])) {
1676 new_threshold = WMI_SNR_THRESHOLD3_ABOVE;
1677 } else if (snr >= sq_thresh->upper_threshold[3]) {
1678 new_threshold = WMI_SNR_THRESHOLD4_ABOVE;
1681 /* Lower threshold breached */
1682 if (snr > sq_thresh->lower_threshold[0]) {
1683 ath6kl_dbg(ATH6KL_DBG_WMI,
1684 "spurious lower snr threshold event: %d\n",
1685 sq_thresh->lower_threshold[0]);
1686 } else if ((snr > sq_thresh->lower_threshold[1]) &&
1687 (snr <= sq_thresh->lower_threshold[0])) {
1688 new_threshold = WMI_SNR_THRESHOLD4_BELOW;
1689 } else if ((snr > sq_thresh->lower_threshold[2]) &&
1690 (snr <= sq_thresh->lower_threshold[1])) {
1691 new_threshold = WMI_SNR_THRESHOLD3_BELOW;
1692 } else if ((snr > sq_thresh->lower_threshold[3]) &&
1693 (snr <= sq_thresh->lower_threshold[2])) {
1694 new_threshold = WMI_SNR_THRESHOLD2_BELOW;
1695 } else if (snr <= sq_thresh->lower_threshold[3]) {
1696 new_threshold = WMI_SNR_THRESHOLD1_BELOW;
1700 /* Calculate and install the next set of thresholds */
1701 lower_snr_threshold = ath6kl_wmi_get_lower_threshold(snr, sq_thresh,
1702 sq_thresh->lower_threshold_valid_count);
1703 upper_snr_threshold = ath6kl_wmi_get_upper_threshold(snr, sq_thresh,
1704 sq_thresh->upper_threshold_valid_count);
1706 /* Issue a wmi command to install the thresholds */
1707 cmd.thresh_above1_val = upper_snr_threshold;
1708 cmd.thresh_below1_val = lower_snr_threshold;
1709 cmd.weight = sq_thresh->weight;
1710 cmd.poll_time = cpu_to_le32(sq_thresh->polling_interval);
1712 ath6kl_dbg(ATH6KL_DBG_WMI,
1713 "snr: %d, threshold: %d, lower: %d, upper: %d\n",
1715 lower_snr_threshold, upper_snr_threshold);
1717 ret = ath6kl_wmi_send_snr_threshold_params(wmi, &cmd);
1719 ath6kl_err("unable to configure snr threshold\n");
1726 static int ath6kl_wmi_aplist_event_rx(struct wmi *wmi, u8 *datap, int len)
1728 u16 ap_info_entry_size;
1729 struct wmi_aplist_event *ev = (struct wmi_aplist_event *) datap;
1730 struct wmi_ap_info_v1 *ap_info_v1;
1733 if (len < sizeof(struct wmi_aplist_event) ||
1734 ev->ap_list_ver != APLIST_VER1)
1737 ap_info_entry_size = sizeof(struct wmi_ap_info_v1);
1738 ap_info_v1 = (struct wmi_ap_info_v1 *) ev->ap_list;
1740 ath6kl_dbg(ATH6KL_DBG_WMI,
1741 "number of APs in aplist event: %d\n", ev->num_ap);
1743 if (len < (int) (sizeof(struct wmi_aplist_event) +
1744 (ev->num_ap - 1) * ap_info_entry_size))
1747 /* AP list version 1 contents */
1748 for (index = 0; index < ev->num_ap; index++) {
1749 ath6kl_dbg(ATH6KL_DBG_WMI, "AP#%d BSSID %pM Channel %d\n",
1750 index, ap_info_v1->bssid, ap_info_v1->channel);
1757 int ath6kl_wmi_cmd_send(struct wmi *wmi, u8 if_idx, struct sk_buff *skb,
1758 enum wmi_cmd_id cmd_id, enum wmi_sync_flag sync_flag)
1760 struct wmi_cmd_hdr *cmd_hdr;
1761 enum htc_endpoint_id ep_id = wmi->ep_id;
1765 if (WARN_ON(skb == NULL ||
1766 (if_idx > (wmi->parent_dev->vif_max - 1)))) {
1771 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi tx id %d len %d flag %d\n",
1772 cmd_id, skb->len, sync_flag);
1773 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi tx ",
1774 skb->data, skb->len);
1776 if (sync_flag >= END_WMIFLAG) {
1781 if ((sync_flag == SYNC_BEFORE_WMIFLAG) ||
1782 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1784 * Make sure all data currently queued is transmitted before
1785 * the cmd execution. Establish a new sync point.
1787 ath6kl_wmi_sync_point(wmi, if_idx);
1790 skb_push(skb, sizeof(struct wmi_cmd_hdr));
1792 cmd_hdr = (struct wmi_cmd_hdr *) skb->data;
1793 cmd_hdr->cmd_id = cpu_to_le16(cmd_id);
1794 info1 = if_idx & WMI_CMD_HDR_IF_ID_MASK;
1795 cmd_hdr->info1 = cpu_to_le16(info1);
1797 /* Only for OPT_TX_CMD, use BE endpoint. */
1798 if (cmd_id == WMI_OPT_TX_FRAME_CMDID) {
1799 ret = ath6kl_wmi_data_hdr_add(wmi, skb, OPT_MSGTYPE,
1800 false, false, 0, NULL, if_idx);
1805 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev, WMM_AC_BE);
1808 ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
1810 if ((sync_flag == SYNC_AFTER_WMIFLAG) ||
1811 (sync_flag == SYNC_BOTH_WMIFLAG)) {
1813 * Make sure all new data queued waits for the command to
1814 * execute. Establish a new sync point.
1816 ath6kl_wmi_sync_point(wmi, if_idx);
1822 int ath6kl_wmi_connect_cmd(struct wmi *wmi, u8 if_idx,
1823 enum network_type nw_type,
1824 enum dot11_auth_mode dot11_auth_mode,
1825 enum auth_mode auth_mode,
1826 enum crypto_type pairwise_crypto,
1827 u8 pairwise_crypto_len,
1828 enum crypto_type group_crypto,
1829 u8 group_crypto_len, int ssid_len, u8 *ssid,
1830 u8 *bssid, u16 channel, u32 ctrl_flags,
1833 struct sk_buff *skb;
1834 struct wmi_connect_cmd *cc;
1837 ath6kl_dbg(ATH6KL_DBG_WMI,
1838 "wmi connect bssid %pM freq %d flags 0x%x ssid_len %d "
1839 "type %d dot11_auth %d auth %d pairwise %d group %d\n",
1840 bssid, channel, ctrl_flags, ssid_len, nw_type,
1841 dot11_auth_mode, auth_mode, pairwise_crypto, group_crypto);
1842 ath6kl_dbg_dump(ATH6KL_DBG_WMI, NULL, "ssid ", ssid, ssid_len);
1844 wmi->traffic_class = 100;
1846 if ((pairwise_crypto == NONE_CRYPT) && (group_crypto != NONE_CRYPT))
1849 if ((pairwise_crypto != NONE_CRYPT) && (group_crypto == NONE_CRYPT))
1852 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_connect_cmd));
1856 cc = (struct wmi_connect_cmd *) skb->data;
1859 memcpy(cc->ssid, ssid, ssid_len);
1861 cc->ssid_len = ssid_len;
1862 cc->nw_type = nw_type;
1863 cc->dot11_auth_mode = dot11_auth_mode;
1864 cc->auth_mode = auth_mode;
1865 cc->prwise_crypto_type = pairwise_crypto;
1866 cc->prwise_crypto_len = pairwise_crypto_len;
1867 cc->grp_crypto_type = group_crypto;
1868 cc->grp_crypto_len = group_crypto_len;
1869 cc->ch = cpu_to_le16(channel);
1870 cc->ctrl_flags = cpu_to_le32(ctrl_flags);
1871 cc->nw_subtype = nw_subtype;
1874 memcpy(cc->bssid, bssid, ETH_ALEN);
1876 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CONNECT_CMDID,
1882 int ath6kl_wmi_reconnect_cmd(struct wmi *wmi, u8 if_idx, u8 *bssid,
1885 struct sk_buff *skb;
1886 struct wmi_reconnect_cmd *cc;
1889 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi reconnect bssid %pM freq %d\n",
1892 wmi->traffic_class = 100;
1894 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_reconnect_cmd));
1898 cc = (struct wmi_reconnect_cmd *) skb->data;
1899 cc->channel = cpu_to_le16(channel);
1902 memcpy(cc->bssid, bssid, ETH_ALEN);
1904 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RECONNECT_CMDID,
1910 int ath6kl_wmi_disconnect_cmd(struct wmi *wmi, u8 if_idx)
1914 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi disconnect\n");
1916 wmi->traffic_class = 100;
1918 /* Disconnect command does not need to do a SYNC before. */
1919 ret = ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_DISCONNECT_CMDID);
1924 /* ath6kl_wmi_start_scan_cmd is to be deprecated. Use
1925 * ath6kl_wmi_begin_scan_cmd instead. The new function supports P2P
1926 * mgmt operations using station interface.
1928 static int ath6kl_wmi_startscan_cmd(struct wmi *wmi, u8 if_idx,
1929 enum wmi_scan_type scan_type,
1930 u32 force_fgscan, u32 is_legacy,
1931 u32 home_dwell_time,
1932 u32 force_scan_interval,
1933 s8 num_chan, u16 *ch_list)
1935 struct sk_buff *skb;
1936 struct wmi_start_scan_cmd *sc;
1940 size = sizeof(struct wmi_start_scan_cmd);
1942 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
1945 if (num_chan > WMI_MAX_CHANNELS)
1949 size += sizeof(u16) * (num_chan - 1);
1951 skb = ath6kl_wmi_get_new_buf(size);
1955 sc = (struct wmi_start_scan_cmd *) skb->data;
1956 sc->scan_type = scan_type;
1957 sc->force_fg_scan = cpu_to_le32(force_fgscan);
1958 sc->is_legacy = cpu_to_le32(is_legacy);
1959 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
1960 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
1961 sc->num_ch = num_chan;
1963 for (i = 0; i < num_chan; i++)
1964 sc->ch_list[i] = cpu_to_le16(ch_list[i]);
1966 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_START_SCAN_CMDID,
1973 * beginscan supports (compared to old startscan) P2P mgmt operations using
1974 * station interface, send additional information like supported rates to
1975 * advertise and xmit rates for probe requests
1977 int ath6kl_wmi_beginscan_cmd(struct wmi *wmi, u8 if_idx,
1978 enum wmi_scan_type scan_type,
1979 u32 force_fgscan, u32 is_legacy,
1980 u32 home_dwell_time, u32 force_scan_interval,
1981 s8 num_chan, u16 *ch_list, u32 no_cck, u32 *rates)
1983 struct ieee80211_supported_band *sband;
1984 struct sk_buff *skb;
1985 struct wmi_begin_scan_cmd *sc;
1986 s8 size, *supp_rates;
1988 struct ath6kl *ar = wmi->parent_dev;
1992 if (!test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX,
1993 ar->fw_capabilities)) {
1994 return ath6kl_wmi_startscan_cmd(wmi, if_idx,
1995 scan_type, force_fgscan,
1996 is_legacy, home_dwell_time,
1997 force_scan_interval,
2001 size = sizeof(struct wmi_begin_scan_cmd);
2003 if ((scan_type != WMI_LONG_SCAN) && (scan_type != WMI_SHORT_SCAN))
2006 if (num_chan > WMI_MAX_CHANNELS)
2010 size += sizeof(u16) * (num_chan - 1);
2012 skb = ath6kl_wmi_get_new_buf(size);
2016 sc = (struct wmi_begin_scan_cmd *) skb->data;
2017 sc->scan_type = scan_type;
2018 sc->force_fg_scan = cpu_to_le32(force_fgscan);
2019 sc->is_legacy = cpu_to_le32(is_legacy);
2020 sc->home_dwell_time = cpu_to_le32(home_dwell_time);
2021 sc->force_scan_intvl = cpu_to_le32(force_scan_interval);
2022 sc->no_cck = cpu_to_le32(no_cck);
2023 sc->num_ch = num_chan;
2025 for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
2026 sband = ar->wiphy->bands[band];
2031 ratemask = rates[band];
2032 supp_rates = sc->supp_rates[band].rates;
2035 for (i = 0; i < sband->n_bitrates; i++) {
2036 if ((BIT(i) & ratemask) == 0)
2037 continue; /* skip rate */
2038 supp_rates[num_rates++] =
2039 (u8) (sband->bitrates[i].bitrate / 5);
2041 sc->supp_rates[band].nrates = num_rates;
2044 for (i = 0; i < num_chan; i++)
2045 sc->ch_list[i] = cpu_to_le16(ch_list[i]);
2047 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_BEGIN_SCAN_CMDID,
2053 int ath6kl_wmi_enable_sched_scan_cmd(struct wmi *wmi, u8 if_idx, bool enable)
2055 struct sk_buff *skb;
2056 struct wmi_enable_sched_scan_cmd *sc;
2059 skb = ath6kl_wmi_get_new_buf(sizeof(*sc));
2063 ath6kl_dbg(ATH6KL_DBG_WMI, "%s scheduled scan on vif %d\n",
2064 enable ? "enabling" : "disabling", if_idx);
2065 sc = (struct wmi_enable_sched_scan_cmd *) skb->data;
2066 sc->enable = enable ? 1 : 0;
2068 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2069 WMI_ENABLE_SCHED_SCAN_CMDID,
2074 int ath6kl_wmi_scanparams_cmd(struct wmi *wmi, u8 if_idx,
2076 u16 fg_end_sec, u16 bg_sec,
2077 u16 minact_chdw_msec, u16 maxact_chdw_msec,
2078 u16 pas_chdw_msec, u8 short_scan_ratio,
2079 u8 scan_ctrl_flag, u32 max_dfsch_act_time,
2080 u16 maxact_scan_per_ssid)
2082 struct sk_buff *skb;
2083 struct wmi_scan_params_cmd *sc;
2086 skb = ath6kl_wmi_get_new_buf(sizeof(*sc));
2090 sc = (struct wmi_scan_params_cmd *) skb->data;
2091 sc->fg_start_period = cpu_to_le16(fg_start_sec);
2092 sc->fg_end_period = cpu_to_le16(fg_end_sec);
2093 sc->bg_period = cpu_to_le16(bg_sec);
2094 sc->minact_chdwell_time = cpu_to_le16(minact_chdw_msec);
2095 sc->maxact_chdwell_time = cpu_to_le16(maxact_chdw_msec);
2096 sc->pas_chdwell_time = cpu_to_le16(pas_chdw_msec);
2097 sc->short_scan_ratio = short_scan_ratio;
2098 sc->scan_ctrl_flags = scan_ctrl_flag;
2099 sc->max_dfsch_act_time = cpu_to_le32(max_dfsch_act_time);
2100 sc->maxact_scan_per_ssid = cpu_to_le16(maxact_scan_per_ssid);
2102 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_SCAN_PARAMS_CMDID,
2107 int ath6kl_wmi_bssfilter_cmd(struct wmi *wmi, u8 if_idx, u8 filter, u32 ie_mask)
2109 struct sk_buff *skb;
2110 struct wmi_bss_filter_cmd *cmd;
2113 if (filter >= LAST_BSS_FILTER)
2116 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2120 cmd = (struct wmi_bss_filter_cmd *) skb->data;
2121 cmd->bss_filter = filter;
2122 cmd->ie_mask = cpu_to_le32(ie_mask);
2124 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BSS_FILTER_CMDID,
2129 int ath6kl_wmi_probedssid_cmd(struct wmi *wmi, u8 if_idx, u8 index, u8 flag,
2130 u8 ssid_len, u8 *ssid)
2132 struct sk_buff *skb;
2133 struct wmi_probed_ssid_cmd *cmd;
2136 if (index >= MAX_PROBED_SSIDS)
2139 if (ssid_len > sizeof(cmd->ssid))
2142 if ((flag & (DISABLE_SSID_FLAG | ANY_SSID_FLAG)) && (ssid_len > 0))
2145 if ((flag & SPECIFIC_SSID_FLAG) && !ssid_len)
2148 if (flag & SPECIFIC_SSID_FLAG)
2149 wmi->is_probe_ssid = true;
2151 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2155 cmd = (struct wmi_probed_ssid_cmd *) skb->data;
2156 cmd->entry_index = index;
2158 cmd->ssid_len = ssid_len;
2159 memcpy(cmd->ssid, ssid, ssid_len);
2161 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PROBED_SSID_CMDID,
2166 int ath6kl_wmi_listeninterval_cmd(struct wmi *wmi, u8 if_idx,
2167 u16 listen_interval,
2170 struct sk_buff *skb;
2171 struct wmi_listen_int_cmd *cmd;
2174 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2178 cmd = (struct wmi_listen_int_cmd *) skb->data;
2179 cmd->listen_intvl = cpu_to_le16(listen_interval);
2180 cmd->num_beacons = cpu_to_le16(listen_beacons);
2182 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LISTEN_INT_CMDID,
2187 int ath6kl_wmi_bmisstime_cmd(struct wmi *wmi, u8 if_idx,
2188 u16 bmiss_time, u16 num_beacons)
2190 struct sk_buff *skb;
2191 struct wmi_bmiss_time_cmd *cmd;
2194 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2198 cmd = (struct wmi_bmiss_time_cmd *) skb->data;
2199 cmd->bmiss_time = cpu_to_le16(bmiss_time);
2200 cmd->num_beacons = cpu_to_le16(num_beacons);
2202 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_BMISS_TIME_CMDID,
2207 int ath6kl_wmi_powermode_cmd(struct wmi *wmi, u8 if_idx, u8 pwr_mode)
2209 struct sk_buff *skb;
2210 struct wmi_power_mode_cmd *cmd;
2213 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2217 cmd = (struct wmi_power_mode_cmd *) skb->data;
2218 cmd->pwr_mode = pwr_mode;
2219 wmi->pwr_mode = pwr_mode;
2221 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_MODE_CMDID,
2226 int ath6kl_wmi_pmparams_cmd(struct wmi *wmi, u8 if_idx, u16 idle_period,
2227 u16 ps_poll_num, u16 dtim_policy,
2228 u16 tx_wakeup_policy, u16 num_tx_to_wakeup,
2229 u16 ps_fail_event_policy)
2231 struct sk_buff *skb;
2232 struct wmi_power_params_cmd *pm;
2235 skb = ath6kl_wmi_get_new_buf(sizeof(*pm));
2239 pm = (struct wmi_power_params_cmd *)skb->data;
2240 pm->idle_period = cpu_to_le16(idle_period);
2241 pm->pspoll_number = cpu_to_le16(ps_poll_num);
2242 pm->dtim_policy = cpu_to_le16(dtim_policy);
2243 pm->tx_wakeup_policy = cpu_to_le16(tx_wakeup_policy);
2244 pm->num_tx_to_wakeup = cpu_to_le16(num_tx_to_wakeup);
2245 pm->ps_fail_event_policy = cpu_to_le16(ps_fail_event_policy);
2247 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_POWER_PARAMS_CMDID,
2252 int ath6kl_wmi_disctimeout_cmd(struct wmi *wmi, u8 if_idx, u8 timeout)
2254 struct sk_buff *skb;
2255 struct wmi_disc_timeout_cmd *cmd;
2258 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2262 cmd = (struct wmi_disc_timeout_cmd *) skb->data;
2263 cmd->discon_timeout = timeout;
2265 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_DISC_TIMEOUT_CMDID,
2269 ath6kl_debug_set_disconnect_timeout(wmi->parent_dev, timeout);
2274 int ath6kl_wmi_addkey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index,
2275 enum crypto_type key_type,
2276 u8 key_usage, u8 key_len,
2277 u8 *key_rsc, unsigned int key_rsc_len,
2279 u8 key_op_ctrl, u8 *mac_addr,
2280 enum wmi_sync_flag sync_flag)
2282 struct sk_buff *skb;
2283 struct wmi_add_cipher_key_cmd *cmd;
2286 ath6kl_dbg(ATH6KL_DBG_WMI,
2287 "addkey cmd: key_index=%u key_type=%d key_usage=%d key_len=%d key_op_ctrl=%d\n",
2288 key_index, key_type, key_usage, key_len, key_op_ctrl);
2290 if ((key_index > WMI_MAX_KEY_INDEX) || (key_len > WMI_MAX_KEY_LEN) ||
2291 (key_material == NULL) || key_rsc_len > 8)
2294 if ((WEP_CRYPT != key_type) && (NULL == key_rsc))
2297 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2301 cmd = (struct wmi_add_cipher_key_cmd *) skb->data;
2302 cmd->key_index = key_index;
2303 cmd->key_type = key_type;
2304 cmd->key_usage = key_usage;
2305 cmd->key_len = key_len;
2306 memcpy(cmd->key, key_material, key_len);
2308 if (key_rsc != NULL)
2309 memcpy(cmd->key_rsc, key_rsc, key_rsc_len);
2311 cmd->key_op_ctrl = key_op_ctrl;
2314 memcpy(cmd->key_mac_addr, mac_addr, ETH_ALEN);
2316 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_CIPHER_KEY_CMDID,
2322 int ath6kl_wmi_add_krk_cmd(struct wmi *wmi, u8 if_idx, u8 *krk)
2324 struct sk_buff *skb;
2325 struct wmi_add_krk_cmd *cmd;
2328 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2332 cmd = (struct wmi_add_krk_cmd *) skb->data;
2333 memcpy(cmd->krk, krk, WMI_KRK_LEN);
2335 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_KRK_CMDID,
2341 int ath6kl_wmi_deletekey_cmd(struct wmi *wmi, u8 if_idx, u8 key_index)
2343 struct sk_buff *skb;
2344 struct wmi_delete_cipher_key_cmd *cmd;
2347 if (key_index > WMI_MAX_KEY_INDEX)
2350 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2354 cmd = (struct wmi_delete_cipher_key_cmd *) skb->data;
2355 cmd->key_index = key_index;
2357 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_CIPHER_KEY_CMDID,
2363 int ath6kl_wmi_setpmkid_cmd(struct wmi *wmi, u8 if_idx, const u8 *bssid,
2364 const u8 *pmkid, bool set)
2366 struct sk_buff *skb;
2367 struct wmi_setpmkid_cmd *cmd;
2373 if (set && pmkid == NULL)
2376 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2380 cmd = (struct wmi_setpmkid_cmd *) skb->data;
2381 memcpy(cmd->bssid, bssid, ETH_ALEN);
2383 memcpy(cmd->pmkid, pmkid, sizeof(cmd->pmkid));
2384 cmd->enable = PMKID_ENABLE;
2386 memset(cmd->pmkid, 0, sizeof(cmd->pmkid));
2387 cmd->enable = PMKID_DISABLE;
2390 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_PMKID_CMDID,
2396 static int ath6kl_wmi_data_sync_send(struct wmi *wmi, struct sk_buff *skb,
2397 enum htc_endpoint_id ep_id, u8 if_idx)
2399 struct wmi_data_hdr *data_hdr;
2402 if (WARN_ON(skb == NULL || ep_id == wmi->ep_id)) {
2407 skb_push(skb, sizeof(struct wmi_data_hdr));
2409 data_hdr = (struct wmi_data_hdr *) skb->data;
2410 data_hdr->info = SYNC_MSGTYPE << WMI_DATA_HDR_MSG_TYPE_SHIFT;
2411 data_hdr->info3 = cpu_to_le16(if_idx & WMI_DATA_HDR_IF_IDX_MASK);
2413 ret = ath6kl_control_tx(wmi->parent_dev, skb, ep_id);
2418 static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx)
2420 struct sk_buff *skb;
2421 struct wmi_sync_cmd *cmd;
2422 struct wmi_data_sync_bufs data_sync_bufs[WMM_NUM_AC];
2423 enum htc_endpoint_id ep_id;
2424 u8 index, num_pri_streams = 0;
2427 memset(data_sync_bufs, 0, sizeof(data_sync_bufs));
2429 spin_lock_bh(&wmi->lock);
2431 for (index = 0; index < WMM_NUM_AC; index++) {
2432 if (wmi->fat_pipe_exist & (1 << index)) {
2434 data_sync_bufs[num_pri_streams - 1].traffic_class =
2439 spin_unlock_bh(&wmi->lock);
2441 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2445 cmd = (struct wmi_sync_cmd *) skb->data;
2448 * In the SYNC cmd sent on the control Ep, send a bitmap
2449 * of the data eps on which the Data Sync will be sent
2451 cmd->data_sync_map = wmi->fat_pipe_exist;
2453 for (index = 0; index < num_pri_streams; index++) {
2454 data_sync_bufs[index].skb = ath6kl_buf_alloc(0);
2455 if (data_sync_bufs[index].skb == NULL) {
2462 * If buffer allocation for any of the dataSync fails,
2463 * then do not send the Synchronize cmd on the control ep
2469 * Send sync cmd followed by sync data messages on all
2470 * endpoints being used
2472 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SYNCHRONIZE_CMDID,
2478 for (index = 0; index < num_pri_streams; index++) {
2480 if (WARN_ON(!data_sync_bufs[index].skb))
2483 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev,
2484 data_sync_bufs[index].
2487 ath6kl_wmi_data_sync_send(wmi, data_sync_bufs[index].skb,
2490 data_sync_bufs[index].skb = NULL;
2499 /* free up any resources left over (possibly due to an error) */
2503 for (index = 0; index < num_pri_streams; index++)
2504 dev_kfree_skb((struct sk_buff *)data_sync_bufs[index].skb);
2509 int ath6kl_wmi_create_pstream_cmd(struct wmi *wmi, u8 if_idx,
2510 struct wmi_create_pstream_cmd *params)
2512 struct sk_buff *skb;
2513 struct wmi_create_pstream_cmd *cmd;
2514 u8 fatpipe_exist_for_ac = 0;
2516 s32 nominal_phy = 0;
2519 if (!((params->user_pri < 8) &&
2520 (params->user_pri <= 0x7) &&
2521 (up_to_ac[params->user_pri & 0x7] == params->traffic_class) &&
2522 (params->traffic_direc == UPLINK_TRAFFIC ||
2523 params->traffic_direc == DNLINK_TRAFFIC ||
2524 params->traffic_direc == BIDIR_TRAFFIC) &&
2525 (params->traffic_type == TRAFFIC_TYPE_APERIODIC ||
2526 params->traffic_type == TRAFFIC_TYPE_PERIODIC) &&
2527 (params->voice_psc_cap == DISABLE_FOR_THIS_AC ||
2528 params->voice_psc_cap == ENABLE_FOR_THIS_AC ||
2529 params->voice_psc_cap == ENABLE_FOR_ALL_AC) &&
2530 (params->tsid == WMI_IMPLICIT_PSTREAM ||
2531 params->tsid <= WMI_MAX_THINSTREAM))) {
2536 * Check nominal PHY rate is >= minimalPHY,
2537 * so that DUT can allow TSRS IE
2540 /* Get the physical rate (units of bps) */
2541 min_phy = ((le32_to_cpu(params->min_phy_rate) / 1000) / 1000);
2543 /* Check minimal phy < nominal phy rate */
2544 if (params->nominal_phy >= min_phy) {
2545 /* unit of 500 kbps */
2546 nominal_phy = (params->nominal_phy * 1000) / 500;
2547 ath6kl_dbg(ATH6KL_DBG_WMI,
2548 "TSRS IE enabled::MinPhy %x->NominalPhy ===> %x\n",
2549 min_phy, nominal_phy);
2551 params->nominal_phy = nominal_phy;
2553 params->nominal_phy = 0;
2556 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2560 ath6kl_dbg(ATH6KL_DBG_WMI,
2561 "sending create_pstream_cmd: ac=%d tsid:%d\n",
2562 params->traffic_class, params->tsid);
2564 cmd = (struct wmi_create_pstream_cmd *) skb->data;
2565 memcpy(cmd, params, sizeof(*cmd));
2567 /* This is an implicitly created Fat pipe */
2568 if ((u32) params->tsid == (u32) WMI_IMPLICIT_PSTREAM) {
2569 spin_lock_bh(&wmi->lock);
2570 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2571 (1 << params->traffic_class));
2572 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2573 spin_unlock_bh(&wmi->lock);
2575 /* explicitly created thin stream within a fat pipe */
2576 spin_lock_bh(&wmi->lock);
2577 fatpipe_exist_for_ac = (wmi->fat_pipe_exist &
2578 (1 << params->traffic_class));
2579 wmi->stream_exist_for_ac[params->traffic_class] |=
2580 (1 << params->tsid);
2582 * If a thinstream becomes active, the fat pipe automatically
2585 wmi->fat_pipe_exist |= (1 << params->traffic_class);
2586 spin_unlock_bh(&wmi->lock);
2590 * Indicate activty change to driver layer only if this is the
2591 * first TSID to get created in this AC explicitly or an implicit
2592 * fat pipe is getting created.
2594 if (!fatpipe_exist_for_ac)
2595 ath6kl_indicate_tx_activity(wmi->parent_dev,
2596 params->traffic_class, true);
2598 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_CREATE_PSTREAM_CMDID,
2603 int ath6kl_wmi_delete_pstream_cmd(struct wmi *wmi, u8 if_idx, u8 traffic_class,
2606 struct sk_buff *skb;
2607 struct wmi_delete_pstream_cmd *cmd;
2608 u16 active_tsids = 0;
2611 if (traffic_class > 3) {
2612 ath6kl_err("invalid traffic class: %d\n", traffic_class);
2616 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2620 cmd = (struct wmi_delete_pstream_cmd *) skb->data;
2621 cmd->traffic_class = traffic_class;
2624 spin_lock_bh(&wmi->lock);
2625 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2626 spin_unlock_bh(&wmi->lock);
2628 if (!(active_tsids & (1 << tsid))) {
2630 ath6kl_dbg(ATH6KL_DBG_WMI,
2631 "TSID %d doesn't exist for traffic class: %d\n",
2632 tsid, traffic_class);
2636 ath6kl_dbg(ATH6KL_DBG_WMI,
2637 "sending delete_pstream_cmd: traffic class: %d tsid=%d\n",
2638 traffic_class, tsid);
2640 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DELETE_PSTREAM_CMDID,
2641 SYNC_BEFORE_WMIFLAG);
2643 spin_lock_bh(&wmi->lock);
2644 wmi->stream_exist_for_ac[traffic_class] &= ~(1 << tsid);
2645 active_tsids = wmi->stream_exist_for_ac[traffic_class];
2646 spin_unlock_bh(&wmi->lock);
2649 * Indicate stream inactivity to driver layer only if all tsids
2650 * within this AC are deleted.
2652 if (!active_tsids) {
2653 ath6kl_indicate_tx_activity(wmi->parent_dev,
2654 traffic_class, false);
2655 wmi->fat_pipe_exist &= ~(1 << traffic_class);
2661 int ath6kl_wmi_set_ip_cmd(struct wmi *wmi, u8 if_idx,
2662 __be32 ips0, __be32 ips1)
2664 struct sk_buff *skb;
2665 struct wmi_set_ip_cmd *cmd;
2668 /* Multicast address are not valid */
2669 if (ipv4_is_multicast(ips0) ||
2670 ipv4_is_multicast(ips1))
2673 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_ip_cmd));
2677 cmd = (struct wmi_set_ip_cmd *) skb->data;
2681 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IP_CMDID,
2686 static void ath6kl_wmi_relinquish_implicit_pstream_credits(struct wmi *wmi)
2693 * Relinquish credits from all implicitly created pstreams
2694 * since when we go to sleep. If user created explicit
2695 * thinstreams exists with in a fatpipe leave them intact
2696 * for the user to delete.
2698 spin_lock_bh(&wmi->lock);
2699 stream_exist = wmi->fat_pipe_exist;
2700 spin_unlock_bh(&wmi->lock);
2702 for (i = 0; i < WMM_NUM_AC; i++) {
2703 if (stream_exist & (1 << i)) {
2706 * FIXME: Is this lock & unlock inside
2707 * for loop correct? may need rework.
2709 spin_lock_bh(&wmi->lock);
2710 active_tsids = wmi->stream_exist_for_ac[i];
2711 spin_unlock_bh(&wmi->lock);
2714 * If there are no user created thin streams
2715 * delete the fatpipe
2717 if (!active_tsids) {
2718 stream_exist &= ~(1 << i);
2720 * Indicate inactivity to driver layer for
2721 * this fatpipe (pstream)
2723 ath6kl_indicate_tx_activity(wmi->parent_dev,
2729 /* FIXME: Can we do this assignment without locking ? */
2730 spin_lock_bh(&wmi->lock);
2731 wmi->fat_pipe_exist = stream_exist;
2732 spin_unlock_bh(&wmi->lock);
2735 static int ath6kl_set_bitrate_mask64(struct wmi *wmi, u8 if_idx,
2736 const struct cfg80211_bitrate_mask *mask)
2738 struct sk_buff *skb;
2739 int ret, mode, band;
2740 u64 mcsrate, ratemask[ATH6KL_NUM_BANDS];
2741 struct wmi_set_tx_select_rates64_cmd *cmd;
2743 memset(&ratemask, 0, sizeof(ratemask));
2745 /* only check 2.4 and 5 GHz bands, skip the rest */
2746 for (band = 0; band <= IEEE80211_BAND_5GHZ; band++) {
2747 /* copy legacy rate mask */
2748 ratemask[band] = mask->control[band].legacy;
2749 if (band == IEEE80211_BAND_5GHZ)
2751 mask->control[band].legacy << 4;
2753 /* copy mcs rate mask */
2754 mcsrate = mask->control[band].mcs[1];
2756 mcsrate |= mask->control[band].mcs[0];
2757 ratemask[band] |= mcsrate << 12;
2758 ratemask[band] |= mcsrate << 28;
2761 ath6kl_dbg(ATH6KL_DBG_WMI,
2762 "Ratemask 64 bit: 2.4:%llx 5:%llx\n",
2763 ratemask[0], ratemask[1]);
2765 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd) * WMI_RATES_MODE_MAX);
2769 cmd = (struct wmi_set_tx_select_rates64_cmd *) skb->data;
2770 for (mode = 0; mode < WMI_RATES_MODE_MAX; mode++) {
2771 /* A mode operate in 5GHZ band */
2772 if (mode == WMI_RATES_MODE_11A ||
2773 mode == WMI_RATES_MODE_11A_HT20 ||
2774 mode == WMI_RATES_MODE_11A_HT40)
2775 band = IEEE80211_BAND_5GHZ;
2777 band = IEEE80211_BAND_2GHZ;
2778 cmd->ratemask[mode] = cpu_to_le64(ratemask[band]);
2781 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2782 WMI_SET_TX_SELECT_RATES_CMDID,
2787 static int ath6kl_set_bitrate_mask32(struct wmi *wmi, u8 if_idx,
2788 const struct cfg80211_bitrate_mask *mask)
2790 struct sk_buff *skb;
2791 int ret, mode, band;
2792 u32 mcsrate, ratemask[ATH6KL_NUM_BANDS];
2793 struct wmi_set_tx_select_rates32_cmd *cmd;
2795 memset(&ratemask, 0, sizeof(ratemask));
2797 /* only check 2.4 and 5 GHz bands, skip the rest */
2798 for (band = 0; band <= IEEE80211_BAND_5GHZ; band++) {
2799 /* copy legacy rate mask */
2800 ratemask[band] = mask->control[band].legacy;
2801 if (band == IEEE80211_BAND_5GHZ)
2803 mask->control[band].legacy << 4;
2805 /* copy mcs rate mask */
2806 mcsrate = mask->control[band].mcs[0];
2807 ratemask[band] |= mcsrate << 12;
2808 ratemask[band] |= mcsrate << 20;
2811 ath6kl_dbg(ATH6KL_DBG_WMI,
2812 "Ratemask 32 bit: 2.4:%x 5:%x\n",
2813 ratemask[0], ratemask[1]);
2815 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd) * WMI_RATES_MODE_MAX);
2819 cmd = (struct wmi_set_tx_select_rates32_cmd *) skb->data;
2820 for (mode = 0; mode < WMI_RATES_MODE_MAX; mode++) {
2821 /* A mode operate in 5GHZ band */
2822 if (mode == WMI_RATES_MODE_11A ||
2823 mode == WMI_RATES_MODE_11A_HT20 ||
2824 mode == WMI_RATES_MODE_11A_HT40)
2825 band = IEEE80211_BAND_5GHZ;
2827 band = IEEE80211_BAND_2GHZ;
2828 cmd->ratemask[mode] = cpu_to_le32(ratemask[band]);
2831 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2832 WMI_SET_TX_SELECT_RATES_CMDID,
2837 int ath6kl_wmi_set_bitrate_mask(struct wmi *wmi, u8 if_idx,
2838 const struct cfg80211_bitrate_mask *mask)
2840 struct ath6kl *ar = wmi->parent_dev;
2842 if (ar->hw.flags & ATH6KL_HW_64BIT_RATES)
2843 return ath6kl_set_bitrate_mask64(wmi, if_idx, mask);
2845 return ath6kl_set_bitrate_mask32(wmi, if_idx, mask);
2848 int ath6kl_wmi_set_host_sleep_mode_cmd(struct wmi *wmi, u8 if_idx,
2849 enum ath6kl_host_mode host_mode)
2851 struct sk_buff *skb;
2852 struct wmi_set_host_sleep_mode_cmd *cmd;
2855 if ((host_mode != ATH6KL_HOST_MODE_ASLEEP) &&
2856 (host_mode != ATH6KL_HOST_MODE_AWAKE)) {
2857 ath6kl_err("invalid host sleep mode: %d\n", host_mode);
2861 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2865 cmd = (struct wmi_set_host_sleep_mode_cmd *) skb->data;
2867 if (host_mode == ATH6KL_HOST_MODE_ASLEEP) {
2868 ath6kl_wmi_relinquish_implicit_pstream_credits(wmi);
2869 cmd->asleep = cpu_to_le32(1);
2871 cmd->awake = cpu_to_le32(1);
2873 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
2874 WMI_SET_HOST_SLEEP_MODE_CMDID,
2879 /* This command has zero length payload */
2880 static int ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(struct wmi *wmi,
2881 struct ath6kl_vif *vif)
2883 struct ath6kl *ar = wmi->parent_dev;
2885 set_bit(HOST_SLEEP_MODE_CMD_PROCESSED, &vif->flags);
2886 wake_up(&ar->event_wq);
2891 int ath6kl_wmi_set_wow_mode_cmd(struct wmi *wmi, u8 if_idx,
2892 enum ath6kl_wow_mode wow_mode,
2893 u32 filter, u16 host_req_delay)
2895 struct sk_buff *skb;
2896 struct wmi_set_wow_mode_cmd *cmd;
2899 if ((wow_mode != ATH6KL_WOW_MODE_ENABLE) &&
2900 wow_mode != ATH6KL_WOW_MODE_DISABLE) {
2901 ath6kl_err("invalid wow mode: %d\n", wow_mode);
2905 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2909 cmd = (struct wmi_set_wow_mode_cmd *) skb->data;
2910 cmd->enable_wow = cpu_to_le32(wow_mode);
2911 cmd->filter = cpu_to_le32(filter);
2912 cmd->host_req_delay = cpu_to_le16(host_req_delay);
2914 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WOW_MODE_CMDID,
2919 int ath6kl_wmi_add_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
2920 u8 list_id, u8 filter_size,
2921 u8 filter_offset, const u8 *filter,
2924 struct sk_buff *skb;
2925 struct wmi_add_wow_pattern_cmd *cmd;
2931 * Allocate additional memory in the buffer to hold
2932 * filter and mask value, which is twice of filter_size.
2934 size = sizeof(*cmd) + (2 * filter_size);
2936 skb = ath6kl_wmi_get_new_buf(size);
2940 cmd = (struct wmi_add_wow_pattern_cmd *) skb->data;
2941 cmd->filter_list_id = list_id;
2942 cmd->filter_size = filter_size;
2943 cmd->filter_offset = filter_offset;
2945 memcpy(cmd->filter, filter, filter_size);
2947 filter_mask = (u8 *) (cmd->filter + filter_size);
2948 memcpy(filter_mask, mask, filter_size);
2950 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_ADD_WOW_PATTERN_CMDID,
2956 int ath6kl_wmi_del_wow_pattern_cmd(struct wmi *wmi, u8 if_idx,
2957 u16 list_id, u16 filter_id)
2959 struct sk_buff *skb;
2960 struct wmi_del_wow_pattern_cmd *cmd;
2963 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
2967 cmd = (struct wmi_del_wow_pattern_cmd *) skb->data;
2968 cmd->filter_list_id = cpu_to_le16(list_id);
2969 cmd->filter_id = cpu_to_le16(filter_id);
2971 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_DEL_WOW_PATTERN_CMDID,
2976 static int ath6kl_wmi_cmd_send_xtnd(struct wmi *wmi, struct sk_buff *skb,
2977 enum wmix_command_id cmd_id,
2978 enum wmi_sync_flag sync_flag)
2980 struct wmix_cmd_hdr *cmd_hdr;
2983 skb_push(skb, sizeof(struct wmix_cmd_hdr));
2985 cmd_hdr = (struct wmix_cmd_hdr *) skb->data;
2986 cmd_hdr->cmd_id = cpu_to_le32(cmd_id);
2988 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_EXTENSION_CMDID, sync_flag);
2993 int ath6kl_wmi_get_challenge_resp_cmd(struct wmi *wmi, u32 cookie, u32 source)
2995 struct sk_buff *skb;
2996 struct wmix_hb_challenge_resp_cmd *cmd;
2999 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3003 cmd = (struct wmix_hb_challenge_resp_cmd *) skb->data;
3004 cmd->cookie = cpu_to_le32(cookie);
3005 cmd->source = cpu_to_le32(source);
3007 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_HB_CHALLENGE_RESP_CMDID,
3012 int ath6kl_wmi_config_debug_module_cmd(struct wmi *wmi, u32 valid, u32 config)
3014 struct ath6kl_wmix_dbglog_cfg_module_cmd *cmd;
3015 struct sk_buff *skb;
3018 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3022 cmd = (struct ath6kl_wmix_dbglog_cfg_module_cmd *) skb->data;
3023 cmd->valid = cpu_to_le32(valid);
3024 cmd->config = cpu_to_le32(config);
3026 ret = ath6kl_wmi_cmd_send_xtnd(wmi, skb, WMIX_DBGLOG_CFG_MODULE_CMDID,
3031 int ath6kl_wmi_get_stats_cmd(struct wmi *wmi, u8 if_idx)
3033 return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_STATISTICS_CMDID);
3036 int ath6kl_wmi_set_tx_pwr_cmd(struct wmi *wmi, u8 if_idx, u8 dbM)
3038 struct sk_buff *skb;
3039 struct wmi_set_tx_pwr_cmd *cmd;
3042 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_tx_pwr_cmd));
3046 cmd = (struct wmi_set_tx_pwr_cmd *) skb->data;
3049 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_TX_PWR_CMDID,
3055 int ath6kl_wmi_get_tx_pwr_cmd(struct wmi *wmi, u8 if_idx)
3057 return ath6kl_wmi_simple_cmd(wmi, if_idx, WMI_GET_TX_PWR_CMDID);
3060 int ath6kl_wmi_get_roam_tbl_cmd(struct wmi *wmi)
3062 return ath6kl_wmi_simple_cmd(wmi, 0, WMI_GET_ROAM_TBL_CMDID);
3065 int ath6kl_wmi_set_lpreamble_cmd(struct wmi *wmi, u8 if_idx, u8 status,
3068 struct sk_buff *skb;
3069 struct wmi_set_lpreamble_cmd *cmd;
3072 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_lpreamble_cmd));
3076 cmd = (struct wmi_set_lpreamble_cmd *) skb->data;
3077 cmd->status = status;
3078 cmd->preamble_policy = preamble_policy;
3080 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_LPREAMBLE_CMDID,
3085 int ath6kl_wmi_set_rts_cmd(struct wmi *wmi, u16 threshold)
3087 struct sk_buff *skb;
3088 struct wmi_set_rts_cmd *cmd;
3091 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_rts_cmd));
3095 cmd = (struct wmi_set_rts_cmd *) skb->data;
3096 cmd->threshold = cpu_to_le16(threshold);
3098 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_SET_RTS_CMDID,
3103 int ath6kl_wmi_set_wmm_txop(struct wmi *wmi, u8 if_idx, enum wmi_txop_cfg cfg)
3105 struct sk_buff *skb;
3106 struct wmi_set_wmm_txop_cmd *cmd;
3109 if (!((cfg == WMI_TXOP_DISABLED) || (cfg == WMI_TXOP_ENABLED)))
3112 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_set_wmm_txop_cmd));
3116 cmd = (struct wmi_set_wmm_txop_cmd *) skb->data;
3117 cmd->txop_enable = cfg;
3119 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_WMM_TXOP_CMDID,
3124 int ath6kl_wmi_set_keepalive_cmd(struct wmi *wmi, u8 if_idx,
3125 u8 keep_alive_intvl)
3127 struct sk_buff *skb;
3128 struct wmi_set_keepalive_cmd *cmd;
3131 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3135 cmd = (struct wmi_set_keepalive_cmd *) skb->data;
3136 cmd->keep_alive_intvl = keep_alive_intvl;
3138 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_KEEPALIVE_CMDID,
3142 ath6kl_debug_set_keepalive(wmi->parent_dev, keep_alive_intvl);
3147 int ath6kl_wmi_set_htcap_cmd(struct wmi *wmi, u8 if_idx,
3148 enum ieee80211_band band,
3149 struct ath6kl_htcap *htcap)
3151 struct sk_buff *skb;
3152 struct wmi_set_htcap_cmd *cmd;
3154 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3158 cmd = (struct wmi_set_htcap_cmd *) skb->data;
3161 * NOTE: Band in firmware matches enum ieee80211_band, it is unlikely
3162 * this will be changed in firmware. If at all there is any change in
3163 * band value, the host needs to be fixed.
3166 cmd->ht_enable = !!htcap->ht_enable;
3167 cmd->ht20_sgi = !!(htcap->cap_info & IEEE80211_HT_CAP_SGI_20);
3168 cmd->ht40_supported =
3169 !!(htcap->cap_info & IEEE80211_HT_CAP_SUP_WIDTH_20_40);
3170 cmd->ht40_sgi = !!(htcap->cap_info & IEEE80211_HT_CAP_SGI_40);
3171 cmd->intolerant_40mhz =
3172 !!(htcap->cap_info & IEEE80211_HT_CAP_40MHZ_INTOLERANT);
3173 cmd->max_ampdu_len_exp = htcap->ampdu_factor;
3175 ath6kl_dbg(ATH6KL_DBG_WMI,
3176 "Set htcap: band:%d ht_enable:%d 40mhz:%d sgi_20mhz:%d sgi_40mhz:%d 40mhz_intolerant:%d ampdu_len_exp:%d\n",
3177 cmd->band, cmd->ht_enable, cmd->ht40_supported,
3178 cmd->ht20_sgi, cmd->ht40_sgi, cmd->intolerant_40mhz,
3179 cmd->max_ampdu_len_exp);
3180 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_HT_CAP_CMDID,
3184 int ath6kl_wmi_test_cmd(struct wmi *wmi, void *buf, size_t len)
3186 struct sk_buff *skb;
3189 skb = ath6kl_wmi_get_new_buf(len);
3193 memcpy(skb->data, buf, len);
3195 ret = ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_TEST_CMDID, NO_SYNC_WMIFLAG);
3200 int ath6kl_wmi_mcast_filter_cmd(struct wmi *wmi, u8 if_idx, bool mc_all_on)
3202 struct sk_buff *skb;
3203 struct wmi_mcast_filter_cmd *cmd;
3206 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3210 cmd = (struct wmi_mcast_filter_cmd *) skb->data;
3211 cmd->mcast_all_enable = mc_all_on;
3213 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_MCAST_FILTER_CMDID,
3218 int ath6kl_wmi_add_del_mcast_filter_cmd(struct wmi *wmi, u8 if_idx,
3219 u8 *filter, bool add_filter)
3221 struct sk_buff *skb;
3222 struct wmi_mcast_filter_add_del_cmd *cmd;
3225 if ((filter[0] != 0x33 || filter[1] != 0x33) &&
3226 (filter[0] != 0x01 || filter[1] != 0x00 ||
3227 filter[2] != 0x5e || filter[3] > 0x7f)) {
3228 ath6kl_warn("invalid multicast filter address\n");
3232 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3236 cmd = (struct wmi_mcast_filter_add_del_cmd *) skb->data;
3237 memcpy(cmd->mcast_mac, filter, ATH6KL_MCAST_FILTER_MAC_ADDR_SIZE);
3238 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3239 add_filter ? WMI_SET_MCAST_FILTER_CMDID :
3240 WMI_DEL_MCAST_FILTER_CMDID,
3246 int ath6kl_wmi_sta_bmiss_enhance_cmd(struct wmi *wmi, u8 if_idx, bool enhance)
3248 struct sk_buff *skb;
3249 struct wmi_sta_bmiss_enhance_cmd *cmd;
3252 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3256 cmd = (struct wmi_sta_bmiss_enhance_cmd *) skb->data;
3257 cmd->enable = enhance ? 1 : 0;
3259 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3260 WMI_STA_BMISS_ENHANCE_CMDID,
3265 int ath6kl_wmi_set_regdomain_cmd(struct wmi *wmi, const char *alpha2)
3267 struct sk_buff *skb;
3268 struct wmi_set_regdomain_cmd *cmd;
3270 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3274 cmd = (struct wmi_set_regdomain_cmd *) skb->data;
3275 memcpy(cmd->iso_name, alpha2, 2);
3277 return ath6kl_wmi_cmd_send(wmi, 0, skb,
3278 WMI_SET_REGDOMAIN_CMDID,
3282 s32 ath6kl_wmi_get_rate(s8 rate_index)
3286 if (rate_index == RATE_AUTO)
3289 /* SGI is stored as the MSB of the rate_index */
3290 if (rate_index & RATE_INDEX_MSB) {
3291 rate_index &= RATE_INDEX_WITHOUT_SGI_MASK;
3295 if (WARN_ON(rate_index > RATE_MCS_7_40))
3296 rate_index = RATE_MCS_7_40;
3298 return wmi_rate_tbl[(u32) rate_index][sgi];
3301 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,
3304 struct wmi_pmkid_list_reply *reply;
3307 if (len < sizeof(struct wmi_pmkid_list_reply))
3310 reply = (struct wmi_pmkid_list_reply *)datap;
3311 expected_len = sizeof(reply->num_pmkid) +
3312 le32_to_cpu(reply->num_pmkid) * WMI_PMKID_LEN;
3314 if (len < expected_len)
3320 static int ath6kl_wmi_addba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
3321 struct ath6kl_vif *vif)
3323 struct wmi_addba_req_event *cmd = (struct wmi_addba_req_event *) datap;
3325 aggr_recv_addba_req_evt(vif, cmd->tid,
3326 le16_to_cpu(cmd->st_seq_no), cmd->win_sz);
3331 static int ath6kl_wmi_delba_req_event_rx(struct wmi *wmi, u8 *datap, int len,
3332 struct ath6kl_vif *vif)
3334 struct wmi_delba_event *cmd = (struct wmi_delba_event *) datap;
3336 aggr_recv_delba_req_evt(vif, cmd->tid);
3341 /* AP mode functions */
3343 int ath6kl_wmi_ap_profile_commit(struct wmi *wmip, u8 if_idx,
3344 struct wmi_connect_cmd *p)
3346 struct sk_buff *skb;
3347 struct wmi_connect_cmd *cm;
3350 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
3354 cm = (struct wmi_connect_cmd *) skb->data;
3355 memcpy(cm, p, sizeof(*cm));
3357 res = ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_CONFIG_COMMIT_CMDID,
3359 ath6kl_dbg(ATH6KL_DBG_WMI,
3360 "%s: nw_type=%u auth_mode=%u ch=%u ctrl_flags=0x%x-> res=%d\n",
3361 __func__, p->nw_type, p->auth_mode, le16_to_cpu(p->ch),
3362 le32_to_cpu(p->ctrl_flags), res);
3366 int ath6kl_wmi_ap_set_mlme(struct wmi *wmip, u8 if_idx, u8 cmd, const u8 *mac,
3369 struct sk_buff *skb;
3370 struct wmi_ap_set_mlme_cmd *cm;
3372 skb = ath6kl_wmi_get_new_buf(sizeof(*cm));
3376 cm = (struct wmi_ap_set_mlme_cmd *) skb->data;
3377 memcpy(cm->mac, mac, ETH_ALEN);
3378 cm->reason = cpu_to_le16(reason);
3381 ath6kl_dbg(ATH6KL_DBG_WMI, "ap_set_mlme: cmd=%d reason=%d\n", cm->cmd,
3384 return ath6kl_wmi_cmd_send(wmip, if_idx, skb, WMI_AP_SET_MLME_CMDID,
3388 int ath6kl_wmi_ap_hidden_ssid(struct wmi *wmi, u8 if_idx, bool enable)
3390 struct sk_buff *skb;
3391 struct wmi_ap_hidden_ssid_cmd *cmd;
3393 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3397 cmd = (struct wmi_ap_hidden_ssid_cmd *) skb->data;
3398 cmd->hidden_ssid = enable ? 1 : 0;
3400 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_HIDDEN_SSID_CMDID,
3404 /* This command will be used to enable/disable AP uAPSD feature */
3405 int ath6kl_wmi_ap_set_apsd(struct wmi *wmi, u8 if_idx, u8 enable)
3407 struct wmi_ap_set_apsd_cmd *cmd;
3408 struct sk_buff *skb;
3410 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3414 cmd = (struct wmi_ap_set_apsd_cmd *)skb->data;
3415 cmd->enable = enable;
3417 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_APSD_CMDID,
3421 int ath6kl_wmi_set_apsd_bfrd_traf(struct wmi *wmi, u8 if_idx,
3422 u16 aid, u16 bitmap, u32 flags)
3424 struct wmi_ap_apsd_buffered_traffic_cmd *cmd;
3425 struct sk_buff *skb;
3427 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3431 cmd = (struct wmi_ap_apsd_buffered_traffic_cmd *)skb->data;
3432 cmd->aid = cpu_to_le16(aid);
3433 cmd->bitmap = cpu_to_le16(bitmap);
3434 cmd->flags = cpu_to_le32(flags);
3436 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3437 WMI_AP_APSD_BUFFERED_TRAFFIC_CMDID,
3441 static int ath6kl_wmi_pspoll_event_rx(struct wmi *wmi, u8 *datap, int len,
3442 struct ath6kl_vif *vif)
3444 struct wmi_pspoll_event *ev;
3446 if (len < sizeof(struct wmi_pspoll_event))
3449 ev = (struct wmi_pspoll_event *) datap;
3451 ath6kl_pspoll_event(vif, le16_to_cpu(ev->aid));
3456 static int ath6kl_wmi_dtimexpiry_event_rx(struct wmi *wmi, u8 *datap, int len,
3457 struct ath6kl_vif *vif)
3459 ath6kl_dtimexpiry_event(vif);
3464 int ath6kl_wmi_set_pvb_cmd(struct wmi *wmi, u8 if_idx, u16 aid,
3467 struct sk_buff *skb;
3468 struct wmi_ap_set_pvb_cmd *cmd;
3471 skb = ath6kl_wmi_get_new_buf(sizeof(struct wmi_ap_set_pvb_cmd));
3475 cmd = (struct wmi_ap_set_pvb_cmd *) skb->data;
3476 cmd->aid = cpu_to_le16(aid);
3477 cmd->rsvd = cpu_to_le16(0);
3478 cmd->flag = cpu_to_le32(flag);
3480 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_SET_PVB_CMDID,
3486 int ath6kl_wmi_set_rx_frame_format_cmd(struct wmi *wmi, u8 if_idx,
3488 bool rx_dot11_hdr, bool defrag_on_host)
3490 struct sk_buff *skb;
3491 struct wmi_rx_frame_format_cmd *cmd;
3494 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3498 cmd = (struct wmi_rx_frame_format_cmd *) skb->data;
3499 cmd->dot11_hdr = rx_dot11_hdr ? 1 : 0;
3500 cmd->defrag_on_host = defrag_on_host ? 1 : 0;
3501 cmd->meta_ver = rx_meta_ver;
3503 /* Delete the local aggr state, on host */
3504 ret = ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_RX_FRAME_FORMAT_CMDID,
3510 int ath6kl_wmi_set_appie_cmd(struct wmi *wmi, u8 if_idx, u8 mgmt_frm_type,
3511 const u8 *ie, u8 ie_len)
3513 struct sk_buff *skb;
3514 struct wmi_set_appie_cmd *p;
3516 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len);
3520 ath6kl_dbg(ATH6KL_DBG_WMI,
3521 "set_appie_cmd: mgmt_frm_type=%u ie_len=%u\n",
3522 mgmt_frm_type, ie_len);
3523 p = (struct wmi_set_appie_cmd *) skb->data;
3524 p->mgmt_frm_type = mgmt_frm_type;
3527 if (ie != NULL && ie_len > 0)
3528 memcpy(p->ie_info, ie, ie_len);
3530 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_APPIE_CMDID,
3534 int ath6kl_wmi_set_ie_cmd(struct wmi *wmi, u8 if_idx, u8 ie_id, u8 ie_field,
3535 const u8 *ie_info, u8 ie_len)
3537 struct sk_buff *skb;
3538 struct wmi_set_ie_cmd *p;
3540 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + ie_len);
3544 ath6kl_dbg(ATH6KL_DBG_WMI, "set_ie_cmd: ie_id=%u ie_ie_field=%u ie_len=%u\n",
3545 ie_id, ie_field, ie_len);
3546 p = (struct wmi_set_ie_cmd *) skb->data;
3548 p->ie_field = ie_field;
3550 if (ie_info && ie_len > 0)
3551 memcpy(p->ie_info, ie_info, ie_len);
3553 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SET_IE_CMDID,
3557 int ath6kl_wmi_disable_11b_rates_cmd(struct wmi *wmi, bool disable)
3559 struct sk_buff *skb;
3560 struct wmi_disable_11b_rates_cmd *cmd;
3562 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3566 ath6kl_dbg(ATH6KL_DBG_WMI, "disable_11b_rates_cmd: disable=%u\n",
3568 cmd = (struct wmi_disable_11b_rates_cmd *) skb->data;
3569 cmd->disable = disable ? 1 : 0;
3571 return ath6kl_wmi_cmd_send(wmi, 0, skb, WMI_DISABLE_11B_RATES_CMDID,
3575 int ath6kl_wmi_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx, u32 freq, u32 dur)
3577 struct sk_buff *skb;
3578 struct wmi_remain_on_chnl_cmd *p;
3580 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3584 ath6kl_dbg(ATH6KL_DBG_WMI, "remain_on_chnl_cmd: freq=%u dur=%u\n",
3586 p = (struct wmi_remain_on_chnl_cmd *) skb->data;
3587 p->freq = cpu_to_le32(freq);
3588 p->duration = cpu_to_le32(dur);
3589 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_REMAIN_ON_CHNL_CMDID,
3593 /* ath6kl_wmi_send_action_cmd is to be deprecated. Use
3594 * ath6kl_wmi_send_mgmt_cmd instead. The new function supports P2P
3595 * mgmt operations using station interface.
3597 static int ath6kl_wmi_send_action_cmd(struct wmi *wmi, u8 if_idx, u32 id,
3598 u32 freq, u32 wait, const u8 *data,
3601 struct sk_buff *skb;
3602 struct wmi_send_action_cmd *p;
3606 return -EINVAL; /* Offload for wait not supported */
3608 buf = kmalloc(data_len, GFP_KERNEL);
3612 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
3618 kfree(wmi->last_mgmt_tx_frame);
3619 memcpy(buf, data, data_len);
3620 wmi->last_mgmt_tx_frame = buf;
3621 wmi->last_mgmt_tx_frame_len = data_len;
3623 ath6kl_dbg(ATH6KL_DBG_WMI,
3624 "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3625 id, freq, wait, data_len);
3626 p = (struct wmi_send_action_cmd *) skb->data;
3627 p->id = cpu_to_le32(id);
3628 p->freq = cpu_to_le32(freq);
3629 p->wait = cpu_to_le32(wait);
3630 p->len = cpu_to_le16(data_len);
3631 memcpy(p->data, data, data_len);
3632 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_ACTION_CMDID,
3636 static int __ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id,
3637 u32 freq, u32 wait, const u8 *data,
3638 u16 data_len, u32 no_cck)
3640 struct sk_buff *skb;
3641 struct wmi_send_mgmt_cmd *p;
3645 return -EINVAL; /* Offload for wait not supported */
3647 buf = kmalloc(data_len, GFP_KERNEL);
3651 skb = ath6kl_wmi_get_new_buf(sizeof(*p) + data_len);
3657 kfree(wmi->last_mgmt_tx_frame);
3658 memcpy(buf, data, data_len);
3659 wmi->last_mgmt_tx_frame = buf;
3660 wmi->last_mgmt_tx_frame_len = data_len;
3662 ath6kl_dbg(ATH6KL_DBG_WMI,
3663 "send_action_cmd: id=%u freq=%u wait=%u len=%u\n",
3664 id, freq, wait, data_len);
3665 p = (struct wmi_send_mgmt_cmd *) skb->data;
3666 p->id = cpu_to_le32(id);
3667 p->freq = cpu_to_le32(freq);
3668 p->wait = cpu_to_le32(wait);
3669 p->no_cck = cpu_to_le32(no_cck);
3670 p->len = cpu_to_le16(data_len);
3671 memcpy(p->data, data, data_len);
3672 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_SEND_MGMT_CMDID,
3676 int ath6kl_wmi_send_mgmt_cmd(struct wmi *wmi, u8 if_idx, u32 id, u32 freq,
3677 u32 wait, const u8 *data, u16 data_len,
3681 struct ath6kl *ar = wmi->parent_dev;
3683 if (test_bit(ATH6KL_FW_CAPABILITY_STA_P2PDEV_DUPLEX,
3684 ar->fw_capabilities)) {
3686 * If capable of doing P2P mgmt operations using
3687 * station interface, send additional information like
3688 * supported rates to advertise and xmit rates for
3691 status = __ath6kl_wmi_send_mgmt_cmd(ar->wmi, if_idx, id, freq,
3692 wait, data, data_len,
3695 status = ath6kl_wmi_send_action_cmd(ar->wmi, if_idx, id, freq,
3696 wait, data, data_len);
3702 int ath6kl_wmi_send_probe_response_cmd(struct wmi *wmi, u8 if_idx, u32 freq,
3703 const u8 *dst, const u8 *data,
3706 struct sk_buff *skb;
3707 struct wmi_p2p_probe_response_cmd *p;
3708 size_t cmd_len = sizeof(*p) + data_len;
3711 cmd_len++; /* work around target minimum length requirement */
3713 skb = ath6kl_wmi_get_new_buf(cmd_len);
3717 ath6kl_dbg(ATH6KL_DBG_WMI,
3718 "send_probe_response_cmd: freq=%u dst=%pM len=%u\n",
3719 freq, dst, data_len);
3720 p = (struct wmi_p2p_probe_response_cmd *) skb->data;
3721 p->freq = cpu_to_le32(freq);
3722 memcpy(p->destination_addr, dst, ETH_ALEN);
3723 p->len = cpu_to_le16(data_len);
3724 memcpy(p->data, data, data_len);
3725 return ath6kl_wmi_cmd_send(wmi, if_idx, skb,
3726 WMI_SEND_PROBE_RESPONSE_CMDID,
3730 int ath6kl_wmi_probe_report_req_cmd(struct wmi *wmi, u8 if_idx, bool enable)
3732 struct sk_buff *skb;
3733 struct wmi_probe_req_report_cmd *p;
3735 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3739 ath6kl_dbg(ATH6KL_DBG_WMI, "probe_report_req_cmd: enable=%u\n",
3741 p = (struct wmi_probe_req_report_cmd *) skb->data;
3742 p->enable = enable ? 1 : 0;
3743 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_PROBE_REQ_REPORT_CMDID,
3747 int ath6kl_wmi_info_req_cmd(struct wmi *wmi, u8 if_idx, u32 info_req_flags)
3749 struct sk_buff *skb;
3750 struct wmi_get_p2p_info *p;
3752 skb = ath6kl_wmi_get_new_buf(sizeof(*p));
3756 ath6kl_dbg(ATH6KL_DBG_WMI, "info_req_cmd: flags=%x\n",
3758 p = (struct wmi_get_p2p_info *) skb->data;
3759 p->info_req_flags = cpu_to_le32(info_req_flags);
3760 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_GET_P2P_INFO_CMDID,
3764 int ath6kl_wmi_cancel_remain_on_chnl_cmd(struct wmi *wmi, u8 if_idx)
3766 ath6kl_dbg(ATH6KL_DBG_WMI, "cancel_remain_on_chnl_cmd\n");
3767 return ath6kl_wmi_simple_cmd(wmi, if_idx,
3768 WMI_CANCEL_REMAIN_ON_CHNL_CMDID);
3771 int ath6kl_wmi_set_inact_period(struct wmi *wmi, u8 if_idx, int inact_timeout)
3773 struct sk_buff *skb;
3774 struct wmi_set_inact_period_cmd *cmd;
3776 skb = ath6kl_wmi_get_new_buf(sizeof(*cmd));
3780 cmd = (struct wmi_set_inact_period_cmd *) skb->data;
3781 cmd->inact_period = cpu_to_le32(inact_timeout);
3782 cmd->num_null_func = 0;
3784 return ath6kl_wmi_cmd_send(wmi, if_idx, skb, WMI_AP_CONN_INACT_CMDID,
3788 static void ath6kl_wmi_hb_challenge_resp_event(struct wmi *wmi, u8 *datap,
3791 struct wmix_hb_challenge_resp_cmd *cmd;
3793 if (len < sizeof(struct wmix_hb_challenge_resp_cmd))
3796 cmd = (struct wmix_hb_challenge_resp_cmd *) datap;
3797 ath6kl_recovery_hb_event(wmi->parent_dev,
3798 le32_to_cpu(cmd->cookie));
3801 static int ath6kl_wmi_control_rx_xtnd(struct wmi *wmi, struct sk_buff *skb)
3803 struct wmix_cmd_hdr *cmd;
3809 if (skb->len < sizeof(struct wmix_cmd_hdr)) {
3810 ath6kl_err("bad packet 1\n");
3814 cmd = (struct wmix_cmd_hdr *) skb->data;
3815 id = le32_to_cpu(cmd->cmd_id);
3817 skb_pull(skb, sizeof(struct wmix_cmd_hdr));
3823 case WMIX_HB_CHALLENGE_RESP_EVENTID:
3824 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event hb challenge resp\n");
3825 ath6kl_wmi_hb_challenge_resp_event(wmi, datap, len);
3827 case WMIX_DBGLOG_EVENTID:
3828 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi event dbglog len %d\n", len);
3829 ath6kl_debug_fwlog_event(wmi->parent_dev, datap, len);
3832 ath6kl_warn("unknown cmd id 0x%x\n", id);
3840 static int ath6kl_wmi_roam_tbl_event_rx(struct wmi *wmi, u8 *datap, int len)
3842 return ath6kl_debug_roam_tbl_event(wmi->parent_dev, datap, len);
3845 /* Process interface specific wmi events, caller would free the datap */
3846 static int ath6kl_wmi_proc_events_vif(struct wmi *wmi, u16 if_idx, u16 cmd_id,
3849 struct ath6kl_vif *vif;
3851 vif = ath6kl_get_vif_by_index(wmi->parent_dev, if_idx);
3853 ath6kl_dbg(ATH6KL_DBG_WMI,
3854 "Wmi event for unavailable vif, vif_index:%d\n",
3860 case WMI_CONNECT_EVENTID:
3861 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CONNECT_EVENTID\n");
3862 return ath6kl_wmi_connect_event_rx(wmi, datap, len, vif);
3863 case WMI_DISCONNECT_EVENTID:
3864 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DISCONNECT_EVENTID\n");
3865 return ath6kl_wmi_disconnect_event_rx(wmi, datap, len, vif);
3866 case WMI_TKIP_MICERR_EVENTID:
3867 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TKIP_MICERR_EVENTID\n");
3868 return ath6kl_wmi_tkip_micerr_event_rx(wmi, datap, len, vif);
3869 case WMI_BSSINFO_EVENTID:
3870 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_BSSINFO_EVENTID\n");
3871 return ath6kl_wmi_bssinfo_event_rx(wmi, datap, len, vif);
3872 case WMI_NEIGHBOR_REPORT_EVENTID:
3873 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_NEIGHBOR_REPORT_EVENTID\n");
3874 return ath6kl_wmi_neighbor_report_event_rx(wmi, datap, len,
3876 case WMI_SCAN_COMPLETE_EVENTID:
3877 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SCAN_COMPLETE_EVENTID\n");
3878 return ath6kl_wmi_scan_complete_rx(wmi, datap, len, vif);
3879 case WMI_REPORT_STATISTICS_EVENTID:
3880 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_STATISTICS_EVENTID\n");
3881 return ath6kl_wmi_stats_event_rx(wmi, datap, len, vif);
3882 case WMI_CAC_EVENTID:
3883 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CAC_EVENTID\n");
3884 return ath6kl_wmi_cac_event_rx(wmi, datap, len, vif);
3885 case WMI_PSPOLL_EVENTID:
3886 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSPOLL_EVENTID\n");
3887 return ath6kl_wmi_pspoll_event_rx(wmi, datap, len, vif);
3888 case WMI_DTIMEXPIRY_EVENTID:
3889 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DTIMEXPIRY_EVENTID\n");
3890 return ath6kl_wmi_dtimexpiry_event_rx(wmi, datap, len, vif);
3891 case WMI_ADDBA_REQ_EVENTID:
3892 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_REQ_EVENTID\n");
3893 return ath6kl_wmi_addba_req_event_rx(wmi, datap, len, vif);
3894 case WMI_DELBA_REQ_EVENTID:
3895 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_DELBA_REQ_EVENTID\n");
3896 return ath6kl_wmi_delba_req_event_rx(wmi, datap, len, vif);
3897 case WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID:
3898 ath6kl_dbg(ATH6KL_DBG_WMI,
3899 "WMI_SET_HOST_SLEEP_MODE_CMD_PROCESSED_EVENTID");
3900 return ath6kl_wmi_host_sleep_mode_cmd_prcd_evt_rx(wmi, vif);
3901 case WMI_REMAIN_ON_CHNL_EVENTID:
3902 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REMAIN_ON_CHNL_EVENTID\n");
3903 return ath6kl_wmi_remain_on_chnl_event_rx(wmi, datap, len, vif);
3904 case WMI_CANCEL_REMAIN_ON_CHNL_EVENTID:
3905 ath6kl_dbg(ATH6KL_DBG_WMI,
3906 "WMI_CANCEL_REMAIN_ON_CHNL_EVENTID\n");
3907 return ath6kl_wmi_cancel_remain_on_chnl_event_rx(wmi, datap,
3909 case WMI_TX_STATUS_EVENTID:
3910 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_STATUS_EVENTID\n");
3911 return ath6kl_wmi_tx_status_event_rx(wmi, datap, len, vif);
3912 case WMI_RX_PROBE_REQ_EVENTID:
3913 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_PROBE_REQ_EVENTID\n");
3914 return ath6kl_wmi_rx_probe_req_event_rx(wmi, datap, len, vif);
3915 case WMI_RX_ACTION_EVENTID:
3916 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RX_ACTION_EVENTID\n");
3917 return ath6kl_wmi_rx_action_event_rx(wmi, datap, len, vif);
3918 case WMI_TXE_NOTIFY_EVENTID:
3919 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TXE_NOTIFY_EVENTID\n");
3920 return ath6kl_wmi_txe_notify_event_rx(wmi, datap, len, vif);
3922 ath6kl_dbg(ATH6KL_DBG_WMI, "unknown cmd id 0x%x\n", cmd_id);
3929 static int ath6kl_wmi_proc_events(struct wmi *wmi, struct sk_buff *skb)
3931 struct wmi_cmd_hdr *cmd;
3938 cmd = (struct wmi_cmd_hdr *) skb->data;
3939 id = le16_to_cpu(cmd->cmd_id);
3940 if_idx = le16_to_cpu(cmd->info1) & WMI_CMD_HDR_IF_ID_MASK;
3942 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
3946 ath6kl_dbg(ATH6KL_DBG_WMI, "wmi rx id %d len %d\n", id, len);
3947 ath6kl_dbg_dump(ATH6KL_DBG_WMI_DUMP, NULL, "wmi rx ",
3951 case WMI_GET_BITRATE_CMDID:
3952 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_BITRATE_CMDID\n");
3953 ret = ath6kl_wmi_bitrate_reply_rx(wmi, datap, len);
3955 case WMI_GET_CHANNEL_LIST_CMDID:
3956 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_CHANNEL_LIST_CMDID\n");
3957 ret = ath6kl_wmi_ch_list_reply_rx(wmi, datap, len);
3959 case WMI_GET_TX_PWR_CMDID:
3960 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_TX_PWR_CMDID\n");
3961 ret = ath6kl_wmi_tx_pwr_reply_rx(wmi, datap, len);
3963 case WMI_READY_EVENTID:
3964 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_READY_EVENTID\n");
3965 ret = ath6kl_wmi_ready_event_rx(wmi, datap, len);
3967 case WMI_PEER_NODE_EVENTID:
3968 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PEER_NODE_EVENTID\n");
3969 ret = ath6kl_wmi_peer_node_event_rx(wmi, datap, len);
3971 case WMI_REGDOMAIN_EVENTID:
3972 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REGDOMAIN_EVENTID\n");
3973 ath6kl_wmi_regdomain_event(wmi, datap, len);
3975 case WMI_PSTREAM_TIMEOUT_EVENTID:
3976 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_PSTREAM_TIMEOUT_EVENTID\n");
3977 ret = ath6kl_wmi_pstream_timeout_event_rx(wmi, datap, len);
3979 case WMI_CMDERROR_EVENTID:
3980 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CMDERROR_EVENTID\n");
3981 ret = ath6kl_wmi_error_event_rx(wmi, datap, len);
3983 case WMI_RSSI_THRESHOLD_EVENTID:
3984 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_RSSI_THRESHOLD_EVENTID\n");
3985 ret = ath6kl_wmi_rssi_threshold_event_rx(wmi, datap, len);
3987 case WMI_ERROR_REPORT_EVENTID:
3988 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ERROR_REPORT_EVENTID\n");
3990 case WMI_OPT_RX_FRAME_EVENTID:
3991 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_OPT_RX_FRAME_EVENTID\n");
3992 /* this event has been deprecated */
3994 case WMI_REPORT_ROAM_TBL_EVENTID:
3995 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_TBL_EVENTID\n");
3996 ret = ath6kl_wmi_roam_tbl_event_rx(wmi, datap, len);
3998 case WMI_EXTENSION_EVENTID:
3999 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_EXTENSION_EVENTID\n");
4000 ret = ath6kl_wmi_control_rx_xtnd(wmi, skb);
4002 case WMI_CHANNEL_CHANGE_EVENTID:
4003 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_CHANNEL_CHANGE_EVENTID\n");
4005 case WMI_REPORT_ROAM_DATA_EVENTID:
4006 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_REPORT_ROAM_DATA_EVENTID\n");
4008 case WMI_TEST_EVENTID:
4009 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TEST_EVENTID\n");
4010 ret = ath6kl_wmi_test_rx(wmi, datap, len);
4012 case WMI_GET_FIXRATES_CMDID:
4013 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_FIXRATES_CMDID\n");
4014 ret = ath6kl_wmi_ratemask_reply_rx(wmi, datap, len);
4016 case WMI_TX_RETRY_ERR_EVENTID:
4017 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_RETRY_ERR_EVENTID\n");
4019 case WMI_SNR_THRESHOLD_EVENTID:
4020 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SNR_THRESHOLD_EVENTID\n");
4021 ret = ath6kl_wmi_snr_threshold_event_rx(wmi, datap, len);
4023 case WMI_LQ_THRESHOLD_EVENTID:
4024 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_LQ_THRESHOLD_EVENTID\n");
4026 case WMI_APLIST_EVENTID:
4027 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_APLIST_EVENTID\n");
4028 ret = ath6kl_wmi_aplist_event_rx(wmi, datap, len);
4030 case WMI_GET_KEEPALIVE_CMDID:
4031 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_KEEPALIVE_CMDID\n");
4032 ret = ath6kl_wmi_keepalive_reply_rx(wmi, datap, len);
4034 case WMI_GET_WOW_LIST_EVENTID:
4035 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_WOW_LIST_EVENTID\n");
4037 case WMI_GET_PMKID_LIST_EVENTID:
4038 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_GET_PMKID_LIST_EVENTID\n");
4039 ret = ath6kl_wmi_get_pmkid_list_event_rx(wmi, datap, len);
4041 case WMI_SET_PARAMS_REPLY_EVENTID:
4042 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_SET_PARAMS_REPLY_EVENTID\n");
4044 case WMI_ADDBA_RESP_EVENTID:
4045 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_ADDBA_RESP_EVENTID\n");
4047 case WMI_REPORT_BTCOEX_CONFIG_EVENTID:
4048 ath6kl_dbg(ATH6KL_DBG_WMI,
4049 "WMI_REPORT_BTCOEX_CONFIG_EVENTID\n");
4051 case WMI_REPORT_BTCOEX_STATS_EVENTID:
4052 ath6kl_dbg(ATH6KL_DBG_WMI,
4053 "WMI_REPORT_BTCOEX_STATS_EVENTID\n");
4055 case WMI_TX_COMPLETE_EVENTID:
4056 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_TX_COMPLETE_EVENTID\n");
4057 ret = ath6kl_wmi_tx_complete_event_rx(datap, len);
4059 case WMI_P2P_CAPABILITIES_EVENTID:
4060 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_CAPABILITIES_EVENTID\n");
4061 ret = ath6kl_wmi_p2p_capabilities_event_rx(datap, len);
4063 case WMI_P2P_INFO_EVENTID:
4064 ath6kl_dbg(ATH6KL_DBG_WMI, "WMI_P2P_INFO_EVENTID\n");
4065 ret = ath6kl_wmi_p2p_info_event_rx(datap, len);
4068 /* may be the event is interface specific */
4069 ret = ath6kl_wmi_proc_events_vif(wmi, if_idx, id, datap, len);
4078 int ath6kl_wmi_control_rx(struct wmi *wmi, struct sk_buff *skb)
4080 if (WARN_ON(skb == NULL))
4083 if (skb->len < sizeof(struct wmi_cmd_hdr)) {
4084 ath6kl_err("bad packet 1\n");
4089 return ath6kl_wmi_proc_events(wmi, skb);
4092 void ath6kl_wmi_reset(struct wmi *wmi)
4094 spin_lock_bh(&wmi->lock);
4096 wmi->fat_pipe_exist = 0;
4097 memset(wmi->stream_exist_for_ac, 0, sizeof(wmi->stream_exist_for_ac));
4099 spin_unlock_bh(&wmi->lock);
4102 void *ath6kl_wmi_init(struct ath6kl *dev)
4106 wmi = kzalloc(sizeof(struct wmi), GFP_KERNEL);
4110 spin_lock_init(&wmi->lock);
4112 wmi->parent_dev = dev;
4114 wmi->pwr_mode = REC_POWER;
4116 ath6kl_wmi_reset(wmi);
4121 void ath6kl_wmi_shutdown(struct wmi *wmi)
4126 kfree(wmi->last_mgmt_tx_frame);