Lines Matching +full:rx +full:- +full:sched +full:- +full:sp
1 // SPDX-License-Identifier: GPL-2.0-only
4 * ST-Ericsson CW1200 mac80211 drivers.
6 * Copyright (c) 2010, ST-Ericsson
13 #include <linux/sched.h>
29 if ((buf)->data + size > (buf)->end) \
31 (buf)->data += size; \
36 if ((buf)->data + size > (buf)->end) \
38 memcpy(ptr, (buf)->data, size); \
39 (buf)->data += size; \
45 if ((buf)->data + sizeof(type) > (buf)->end) \
47 val = cvt(*(type2 *)(buf)->data); \
48 (buf)->data += sizeof(type); \
58 if ((buf)->data + size > (buf)->end) \
61 memcpy((buf)->data, ptr, size); \
62 (buf)->data += size; \
67 if ((buf)->data + sizeof(type) > (buf)->end) \
70 *(type2 *)(buf)->data = cvt(val); \
71 (buf)->data += sizeof(type); \
85 #define wsm_cmd_lock(__priv) mutex_lock(&((__priv)->wsm_cmd_mux))
86 #define wsm_cmd_unlock(__priv) mutex_unlock(&((__priv)->wsm_cmd_mux))
97 return -EINVAL; in wsm_generic_confirm()
102 return -EINVAL; in wsm_generic_confirm()
108 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_configuration()
112 WSM_PUT32(buf, arg->dot11MaxTransmitMsduLifeTime); in wsm_configuration()
113 WSM_PUT32(buf, arg->dot11MaxReceiveLifeTime); in wsm_configuration()
114 WSM_PUT32(buf, arg->dot11RtsThreshold); in wsm_configuration()
117 WSM_PUT16(buf, arg->dpdData_size + 12); in wsm_configuration()
119 WSM_PUT(buf, arg->dot11StationId, ETH_ALEN); in wsm_configuration()
121 WSM_PUT(buf, arg->dpdData, arg->dpdData_size); in wsm_configuration()
131 return -ENOMEM; in wsm_configuration()
143 return -EINVAL; in wsm_configuration_confirm()
145 WSM_GET(buf, arg->dot11StationId, ETH_ALEN); in wsm_configuration_confirm()
146 arg->dot11FrequencyBandsSupported = WSM_GET8(buf); in wsm_configuration_confirm()
148 arg->supportedRateMask = WSM_GET32(buf); in wsm_configuration_confirm()
150 arg->txPowerRange[i].min_power_level = WSM_GET32(buf); in wsm_configuration_confirm()
151 arg->txPowerRange[i].max_power_level = WSM_GET32(buf); in wsm_configuration_confirm()
152 arg->txPowerRange[i].stepping = WSM_GET32(buf); in wsm_configuration_confirm()
158 return -EINVAL; in wsm_configuration_confirm()
166 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_reset()
167 u16 cmd = WSM_RESET_REQ_ID | WSM_TX_LINK_ID(arg->link_id); in wsm_reset()
171 WSM_PUT32(buf, arg->reset_statistics ? 0 : 1); in wsm_reset()
178 return -ENOMEM; in wsm_reset()
193 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_read_mib()
211 return -ENOMEM; in wsm_read_mib()
220 return -EINVAL; in wsm_read_mib_confirm()
222 if (WARN_ON(WSM_GET16(buf) != arg->mib_id)) in wsm_read_mib_confirm()
223 return -EINVAL; in wsm_read_mib_confirm()
226 if (size > arg->buf_size) in wsm_read_mib_confirm()
227 size = arg->buf_size; in wsm_read_mib_confirm()
229 WSM_GET(buf, arg->buf, size); in wsm_read_mib_confirm()
230 arg->buf_size = size; in wsm_read_mib_confirm()
235 return -EINVAL; in wsm_read_mib_confirm()
244 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_write_mib()
264 return -ENOMEM; in wsm_write_mib()
277 if (arg->mib_id == WSM_MIB_ID_OPERATIONAL_POWER_MODE) { in wsm_write_mib_confirm()
279 const char *p = arg->buf; in wsm_write_mib_confirm()
291 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_scan()
293 if (arg->num_channels > 48) in wsm_scan()
294 return -EINVAL; in wsm_scan()
296 if (arg->num_ssids > 2) in wsm_scan()
297 return -EINVAL; in wsm_scan()
299 if (arg->band > 1) in wsm_scan()
300 return -EINVAL; in wsm_scan()
304 WSM_PUT8(buf, arg->band); in wsm_scan()
305 WSM_PUT8(buf, arg->type); in wsm_scan()
306 WSM_PUT8(buf, arg->flags); in wsm_scan()
307 WSM_PUT8(buf, arg->max_tx_rate); in wsm_scan()
308 WSM_PUT32(buf, arg->auto_scan_interval); in wsm_scan()
309 WSM_PUT8(buf, arg->num_probes); in wsm_scan()
310 WSM_PUT8(buf, arg->num_channels); in wsm_scan()
311 WSM_PUT8(buf, arg->num_ssids); in wsm_scan()
312 WSM_PUT8(buf, arg->probe_delay); in wsm_scan()
314 for (i = 0; i < arg->num_channels; ++i) { in wsm_scan()
315 WSM_PUT16(buf, arg->ch[i].number); in wsm_scan()
317 WSM_PUT32(buf, arg->ch[i].min_chan_time); in wsm_scan()
318 WSM_PUT32(buf, arg->ch[i].max_chan_time); in wsm_scan()
322 for (i = 0; i < arg->num_ssids; ++i) { in wsm_scan()
323 WSM_PUT32(buf, arg->ssids[i].length); in wsm_scan()
324 WSM_PUT(buf, &arg->ssids[i].ssid[0], in wsm_scan()
325 sizeof(arg->ssids[i].ssid)); in wsm_scan()
335 return -ENOMEM; in wsm_scan()
343 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_stop_scan()
371 return -EINVAL; in wsm_tx_confirm()
382 return -EINVAL; in wsm_multi_tx_confirm()
386 ret = wsm_release_tx_buffer(priv, count - 1); in wsm_multi_tx_confirm()
396 } while (!ret && --count); in wsm_multi_tx_confirm()
402 return -EINVAL; in wsm_multi_tx_confirm()
411 arg->status = WSM_GET32(buf); in wsm_join_confirm()
412 if (WARN_ON(arg->status) != WSM_STATUS_SUCCESS) in wsm_join_confirm()
413 return -EINVAL; in wsm_join_confirm()
415 arg->min_power_level = WSM_GET32(buf); in wsm_join_confirm()
416 arg->max_power_level = WSM_GET32(buf); in wsm_join_confirm()
422 return -EINVAL; in wsm_join_confirm()
428 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_join()
432 WSM_PUT8(buf, arg->mode); in wsm_join()
433 WSM_PUT8(buf, arg->band); in wsm_join()
434 WSM_PUT16(buf, arg->channel_number); in wsm_join()
435 WSM_PUT(buf, &arg->bssid[0], sizeof(arg->bssid)); in wsm_join()
436 WSM_PUT16(buf, arg->atim_window); in wsm_join()
437 WSM_PUT8(buf, arg->preamble_type); in wsm_join()
438 WSM_PUT8(buf, arg->probe_for_join); in wsm_join()
439 WSM_PUT8(buf, arg->dtim_period); in wsm_join()
440 WSM_PUT8(buf, arg->flags); in wsm_join()
441 WSM_PUT32(buf, arg->ssid_len); in wsm_join()
442 WSM_PUT(buf, &arg->ssid[0], sizeof(arg->ssid)); in wsm_join()
443 WSM_PUT32(buf, arg->beacon_interval); in wsm_join()
444 WSM_PUT32(buf, arg->basic_rate_set); in wsm_join()
446 priv->tx_burst_idx = -1; in wsm_join()
451 priv->join_complete_status = resp.status; in wsm_join()
458 return -ENOMEM; in wsm_join()
467 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_set_bss_params()
471 WSM_PUT8(buf, (arg->reset_beacon_loss ? 0x1 : 0)); in wsm_set_bss_params()
472 WSM_PUT8(buf, arg->beacon_lost_count); in wsm_set_bss_params()
473 WSM_PUT16(buf, arg->aid); in wsm_set_bss_params()
474 WSM_PUT32(buf, arg->operational_rate_set); in wsm_set_bss_params()
484 return -ENOMEM; in wsm_set_bss_params()
492 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_add_key()
506 return -ENOMEM; in wsm_add_key()
514 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_remove_key()
518 WSM_PUT8(buf, arg->index); in wsm_remove_key()
530 return -ENOMEM; in wsm_remove_key()
539 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_set_tx_queue_params()
546 WSM_PUT8(buf, arg->ackPolicy); in wsm_set_tx_queue_params()
548 WSM_PUT32(buf, arg->maxTransmitLifetime); in wsm_set_tx_queue_params()
549 WSM_PUT16(buf, arg->allowedMediumTime); in wsm_set_tx_queue_params()
559 return -ENOMEM; in wsm_set_tx_queue_params()
568 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_set_edca_params()
574 WSM_PUT16(buf, arg->params[3].cwmin); in wsm_set_edca_params()
575 WSM_PUT16(buf, arg->params[2].cwmin); in wsm_set_edca_params()
576 WSM_PUT16(buf, arg->params[1].cwmin); in wsm_set_edca_params()
577 WSM_PUT16(buf, arg->params[0].cwmin); in wsm_set_edca_params()
579 WSM_PUT16(buf, arg->params[3].cwmax); in wsm_set_edca_params()
580 WSM_PUT16(buf, arg->params[2].cwmax); in wsm_set_edca_params()
581 WSM_PUT16(buf, arg->params[1].cwmax); in wsm_set_edca_params()
582 WSM_PUT16(buf, arg->params[0].cwmax); in wsm_set_edca_params()
584 WSM_PUT8(buf, arg->params[3].aifns); in wsm_set_edca_params()
585 WSM_PUT8(buf, arg->params[2].aifns); in wsm_set_edca_params()
586 WSM_PUT8(buf, arg->params[1].aifns); in wsm_set_edca_params()
587 WSM_PUT8(buf, arg->params[0].aifns); in wsm_set_edca_params()
589 WSM_PUT16(buf, arg->params[3].txop_limit); in wsm_set_edca_params()
590 WSM_PUT16(buf, arg->params[2].txop_limit); in wsm_set_edca_params()
591 WSM_PUT16(buf, arg->params[1].txop_limit); in wsm_set_edca_params()
592 WSM_PUT16(buf, arg->params[0].txop_limit); in wsm_set_edca_params()
594 WSM_PUT32(buf, arg->params[3].max_rx_lifetime); in wsm_set_edca_params()
595 WSM_PUT32(buf, arg->params[2].max_rx_lifetime); in wsm_set_edca_params()
596 WSM_PUT32(buf, arg->params[1].max_rx_lifetime); in wsm_set_edca_params()
597 WSM_PUT32(buf, arg->params[0].max_rx_lifetime); in wsm_set_edca_params()
606 return -ENOMEM; in wsm_set_edca_params()
615 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_switch_channel()
619 WSM_PUT8(buf, arg->mode); in wsm_switch_channel()
620 WSM_PUT8(buf, arg->switch_count); in wsm_switch_channel()
621 WSM_PUT16(buf, arg->channel_number); in wsm_switch_channel()
623 priv->channel_switch_in_progress = 1; in wsm_switch_channel()
628 priv->channel_switch_in_progress = 0; in wsm_switch_channel()
635 return -ENOMEM; in wsm_switch_channel()
643 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_set_pm()
644 priv->ps_mode_switch_in_progress = 1; in wsm_set_pm()
648 WSM_PUT8(buf, arg->mode); in wsm_set_pm()
649 WSM_PUT8(buf, arg->fast_psm_idle_period); in wsm_set_pm()
650 WSM_PUT8(buf, arg->ap_psm_change_period); in wsm_set_pm()
651 WSM_PUT8(buf, arg->min_auto_pspoll_period); in wsm_set_pm()
661 return -ENOMEM; in wsm_set_pm()
669 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_start()
673 WSM_PUT8(buf, arg->mode); in wsm_start()
674 WSM_PUT8(buf, arg->band); in wsm_start()
675 WSM_PUT16(buf, arg->channel_number); in wsm_start()
676 WSM_PUT32(buf, arg->ct_window); in wsm_start()
677 WSM_PUT32(buf, arg->beacon_interval); in wsm_start()
678 WSM_PUT8(buf, arg->dtim_period); in wsm_start()
679 WSM_PUT8(buf, arg->preamble); in wsm_start()
680 WSM_PUT8(buf, arg->probe_delay); in wsm_start()
681 WSM_PUT8(buf, arg->ssid_len); in wsm_start()
682 WSM_PUT(buf, arg->ssid, sizeof(arg->ssid)); in wsm_start()
683 WSM_PUT32(buf, arg->basic_rate_set); in wsm_start()
685 priv->tx_burst_idx = -1; in wsm_start()
694 return -ENOMEM; in wsm_start()
703 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_beacon_transmit()
707 WSM_PUT32(buf, arg->enable_beaconing ? 1 : 0); in wsm_beacon_transmit()
717 return -ENOMEM; in wsm_beacon_transmit()
725 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_start_find()
738 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_stop_find()
751 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_map_link()
752 u16 cmd = 0x001C | WSM_TX_LINK_ID(arg->link_id); in wsm_map_link()
756 WSM_PUT(buf, &arg->mac_addr[0], sizeof(arg->mac_addr)); in wsm_map_link()
766 return -ENOMEM; in wsm_map_link()
775 struct wsm_buf *buf = &priv->wsm_cmd_buf; in wsm_update_ie()
779 WSM_PUT16(buf, arg->what); in wsm_update_ie()
780 WSM_PUT16(buf, arg->count); in wsm_update_ie()
781 WSM_PUT(buf, arg->ies, arg->length); in wsm_update_ie()
790 return -ENOMEM; in wsm_update_ie()
796 priv->rx_filter.probeResponder = enable; in wsm_set_probe_responder()
797 return wsm_set_rx_filter(priv, &priv->rx_filter); in wsm_set_probe_responder()
813 priv->wsm_caps.input_buffers = WSM_GET16(buf); in wsm_startup_indication()
814 priv->wsm_caps.input_buffer_size = WSM_GET16(buf); in wsm_startup_indication()
815 priv->wsm_caps.hw_id = WSM_GET16(buf); in wsm_startup_indication()
816 priv->wsm_caps.hw_subid = WSM_GET16(buf); in wsm_startup_indication()
817 priv->wsm_caps.status = WSM_GET16(buf); in wsm_startup_indication()
818 priv->wsm_caps.fw_cap = WSM_GET16(buf); in wsm_startup_indication()
819 priv->wsm_caps.fw_type = WSM_GET16(buf); in wsm_startup_indication()
820 priv->wsm_caps.fw_api = WSM_GET16(buf); in wsm_startup_indication()
821 priv->wsm_caps.fw_build = WSM_GET16(buf); in wsm_startup_indication()
822 priv->wsm_caps.fw_ver = WSM_GET16(buf); in wsm_startup_indication()
823 WSM_GET(buf, priv->wsm_caps.fw_label, sizeof(priv->wsm_caps.fw_label)); in wsm_startup_indication()
824 priv->wsm_caps.fw_label[sizeof(priv->wsm_caps.fw_label) - 1] = 0; /* Do not trust FW too much... */ in wsm_startup_indication()
826 if (WARN_ON(priv->wsm_caps.status)) in wsm_startup_indication()
827 return -EINVAL; in wsm_startup_indication()
829 if (WARN_ON(priv->wsm_caps.fw_type > 4)) in wsm_startup_indication()
830 return -EINVAL; in wsm_startup_indication()
837 priv->wsm_caps.input_buffers, in wsm_startup_indication()
838 priv->wsm_caps.input_buffer_size, in wsm_startup_indication()
839 priv->wsm_caps.hw_id, priv->wsm_caps.hw_subid, in wsm_startup_indication()
840 cw1200_fw_types[priv->wsm_caps.fw_type], in wsm_startup_indication()
841 priv->wsm_caps.fw_label, priv->wsm_caps.fw_ver, in wsm_startup_indication()
842 priv->wsm_caps.fw_build, in wsm_startup_indication()
843 priv->wsm_caps.fw_api, priv->wsm_caps.fw_cap); in wsm_startup_indication()
846 if (!(priv->wsm_caps.fw_cap & 0x1)) in wsm_startup_indication()
847 priv->hw->wiphy->bands[NL80211_BAND_2GHZ] = NULL; in wsm_startup_indication()
848 if (!(priv->wsm_caps.fw_cap & 0x2)) in wsm_startup_indication()
849 priv->hw->wiphy->bands[NL80211_BAND_5GHZ] = NULL; in wsm_startup_indication()
851 priv->firmware_ready = 1; in wsm_startup_indication()
852 wake_up(&priv->wsm_startup_done); in wsm_startup_indication()
857 return -EINVAL; in wsm_startup_indication()
865 struct wsm_rx rx; in wsm_receive_indication() local
870 rx.status = WSM_GET32(buf); in wsm_receive_indication()
871 rx.channel_number = WSM_GET16(buf); in wsm_receive_indication()
872 rx.rx_rate = WSM_GET8(buf); in wsm_receive_indication()
873 rx.rcpi_rssi = WSM_GET8(buf); in wsm_receive_indication()
874 rx.flags = WSM_GET32(buf); in wsm_receive_indication()
879 hdr = (struct ieee80211_hdr *)(*skb_p)->data; in wsm_receive_indication()
881 if (!rx.rcpi_rssi && in wsm_receive_indication()
882 (ieee80211_is_probe_resp(hdr->frame_control) || in wsm_receive_indication()
883 ieee80211_is_beacon(hdr->frame_control))) in wsm_receive_indication()
889 if (!priv->cqm_use_rssi) in wsm_receive_indication()
890 rx.rcpi_rssi = rx.rcpi_rssi / 2 - 110; in wsm_receive_indication()
892 fctl = *(__le16 *)buf->data; in wsm_receive_indication()
893 hdr_len = buf->data - buf->begin; in wsm_receive_indication()
895 if (!rx.status && ieee80211_is_deauth(fctl)) { in wsm_receive_indication()
896 if (priv->join_status == CW1200_JOIN_STATUS_STA) { in wsm_receive_indication()
898 pr_debug("[WSM] Issue unjoin command (RX).\n"); in wsm_receive_indication()
900 if (queue_work(priv->workqueue, in wsm_receive_indication()
901 &priv->unjoin_work) <= 0) in wsm_receive_indication()
905 cw1200_rx_cb(priv, &rx, link_id, skb_p); in wsm_receive_indication()
912 return -EINVAL; in wsm_receive_indication()
920 if (priv->mode == NL80211_IFTYPE_UNSPECIFIED) { in wsm_event_indication()
927 return -ENOMEM; in wsm_event_indication()
929 event->evt.id = WSM_GET32(buf); in wsm_event_indication()
930 event->evt.data = WSM_GET32(buf); in wsm_event_indication()
933 event->evt.id, event->evt.data); in wsm_event_indication()
935 spin_lock(&priv->event_queue_lock); in wsm_event_indication()
936 first = list_empty(&priv->event_queue); in wsm_event_indication()
937 list_add_tail(&event->link, &priv->event_queue); in wsm_event_indication()
938 spin_unlock(&priv->event_queue_lock); in wsm_event_indication()
941 queue_work(priv->workqueue, &priv->event_handler); in wsm_event_indication()
947 return -EINVAL; in wsm_event_indication()
955 priv->channel_switch_in_progress = 0; in wsm_channel_switch_indication()
956 wake_up(&priv->channel_switch_done); in wsm_channel_switch_indication()
963 return -EINVAL; in wsm_channel_switch_indication()
970 if (priv->ps_mode_switch_in_progress) { in wsm_set_pm_indication()
971 priv->ps_mode_switch_in_progress = 0; in wsm_set_pm_indication()
972 wake_up(&priv->ps_mode_switch_done); in wsm_set_pm_indication()
983 return -EINVAL; in wsm_scan_started()
989 return -EINVAL; in wsm_scan_started()
1004 return -EINVAL; in wsm_scan_complete_indication()
1018 return -EINVAL; in wsm_join_complete_indication()
1045 return -EINVAL; in wsm_ba_timeout_indication()
1065 return -EINVAL; in wsm_suspend_resume_indication()
1076 size_t buf_len = buf->data - buf->begin; in wsm_cmd_send()
1080 if (priv->bh_error) { in wsm_cmd_send()
1086 spin_lock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1087 while (!priv->wsm_cmd.done) { in wsm_cmd_send()
1088 spin_unlock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1089 spin_lock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1091 priv->wsm_cmd.done = 0; in wsm_cmd_send()
1092 spin_unlock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1097 cmd, __le16_to_cpu(((__le16 *)buf->begin)[2]), in wsm_cmd_send()
1110 ((__le16 *)buf->begin)[0] = __cpu_to_le16(buf_len); in wsm_cmd_send()
1111 ((__le16 *)buf->begin)[1] = __cpu_to_le16(cmd); in wsm_cmd_send()
1113 spin_lock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1114 BUG_ON(priv->wsm_cmd.ptr); in wsm_cmd_send()
1115 priv->wsm_cmd.ptr = buf->begin; in wsm_cmd_send()
1116 priv->wsm_cmd.len = buf_len; in wsm_cmd_send()
1117 priv->wsm_cmd.arg = arg; in wsm_cmd_send()
1118 priv->wsm_cmd.cmd = cmd; in wsm_cmd_send()
1119 spin_unlock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1124 ret = wait_event_timeout(priv->wsm_cmd_wq, in wsm_cmd_send()
1125 priv->wsm_cmd.done, tmo); in wsm_cmd_send()
1127 if (!ret && !priv->wsm_cmd.done) { in wsm_cmd_send()
1128 spin_lock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1129 priv->wsm_cmd.done = 1; in wsm_cmd_send()
1130 priv->wsm_cmd.ptr = NULL; in wsm_cmd_send()
1131 spin_unlock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1132 if (priv->bh_error) { in wsm_cmd_send()
1136 pr_err("CMD req (0x%04x) stuck in firmware, killing BH\n", priv->wsm_cmd.cmd); in wsm_cmd_send()
1138 buf->begin, buf_len); in wsm_cmd_send()
1139 pr_err("Outstanding outgoing frames: %d\n", priv->hw_bufs_used); in wsm_cmd_send()
1142 atomic_inc(&priv->bh_term); in wsm_cmd_send()
1143 wake_up(&priv->bh_wq); in wsm_cmd_send()
1144 ret = -ETIMEDOUT; in wsm_cmd_send()
1147 spin_lock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1148 BUG_ON(!priv->wsm_cmd.done); in wsm_cmd_send()
1149 ret = priv->wsm_cmd.ret; in wsm_cmd_send()
1150 spin_unlock(&priv->wsm_cmd.lock); in wsm_cmd_send()
1163 if (atomic_inc_return(&priv->tx_lock) == 1) { in wsm_lock_tx()
1172 if (atomic_inc_return(&priv->tx_lock) == 1) in wsm_lock_tx_async()
1184 BUG_ON(!atomic_read(&priv->tx_lock)); in wsm_flush_tx()
1190 if (!priv->hw_bufs_used) in wsm_flush_tx()
1193 if (priv->bh_error) { in wsm_flush_tx()
1201 &priv->tx_queue[i], in wsm_flush_tx()
1207 timeout = timestamp + WSM_CMD_LAST_CHANCE_TIMEOUT - jiffies; in wsm_flush_tx()
1208 if (timeout < 0 || wait_event_timeout(priv->bh_evt_wq, in wsm_flush_tx()
1209 !priv->hw_bufs_used, in wsm_flush_tx()
1212 priv->bh_error = 1; in wsm_flush_tx()
1213 …wiphy_err(priv->hw->wiphy, "[WSM] TX Frames (%d) stuck in firmware, killing BH\n", priv->hw_bufs_u… in wsm_flush_tx()
1214 wake_up(&priv->bh_wq); in wsm_flush_tx()
1226 tx_lock = atomic_dec_return(&priv->tx_lock); in wsm_unlock_tx()
1230 if (!priv->bh_error) in wsm_unlock_tx()
1237 /* WSM RX */
1263 wiphy_err(priv->hw->wiphy, in wsm_handle_exception()
1267 wiphy_err(priv->hw->wiphy, in wsm_handle_exception()
1272 wiphy_err(priv->hw->wiphy, in wsm_handle_exception()
1276 wiphy_err(priv->hw->wiphy, in wsm_handle_exception()
1277 "R12: 0x%.8X, SP: 0x%.8X, LR: 0x%.8X, PC: 0x%.8X,\n", in wsm_handle_exception()
1280 wiphy_err(priv->hw->wiphy, in wsm_handle_exception()
1289 wiphy_err(priv->hw->wiphy, "Firmware exception.\n"); in wsm_handle_exception()
1292 return -EINVAL; in wsm_handle_exception()
1307 wsm_buf.end = &wsm_buf.begin[__le16_to_cpu(wsm->len)]; in wsm_handle_rx()
1310 wsm_buf.end - wsm_buf.begin); in wsm_handle_rx()
1323 spin_lock(&priv->wsm_cmd.lock); in wsm_handle_rx()
1324 wsm_arg = priv->wsm_cmd.arg; in wsm_handle_rx()
1325 wsm_cmd = priv->wsm_cmd.cmd & in wsm_handle_rx()
1327 priv->wsm_cmd.cmd = 0xFFFF; in wsm_handle_rx()
1328 spin_unlock(&priv->wsm_cmd.lock); in wsm_handle_rx()
1331 /* Note that any non-zero is a fatal retcode. */ in wsm_handle_rx()
1332 ret = -EINVAL; in wsm_handle_rx()
1382 wiphy_warn(priv->hw->wiphy, in wsm_handle_rx()
1387 if (priv->join_status >= CW1200_JOIN_STATUS_JOINING) { in wsm_handle_rx()
1389 if (queue_work(priv->workqueue, &priv->unjoin_work) <= 0) in wsm_handle_rx()
1395 wiphy_warn(priv->hw->wiphy, in wsm_handle_rx()
1400 spin_lock(&priv->wsm_cmd.lock); in wsm_handle_rx()
1401 priv->wsm_cmd.ret = ret; in wsm_handle_rx()
1402 priv->wsm_cmd.done = 1; in wsm_handle_rx()
1403 spin_unlock(&priv->wsm_cmd.lock); in wsm_handle_rx()
1407 wake_up(&priv->wsm_cmd_wq); in wsm_handle_rx()
1447 ret = -EINVAL; in wsm_handle_rx()
1461 (struct ieee80211_hdr *)&((u8 *)wsm)[txpriv->offset]; in wsm_handle_tx_data()
1462 __le16 fctl = frame->frame_control; in wsm_handle_tx_data()
1470 switch (priv->mode) { in wsm_handle_tx_data()
1472 if (priv->join_status == CW1200_JOIN_STATUS_MONITOR) in wsm_handle_tx_data()
1474 else if (priv->join_status < CW1200_JOIN_STATUS_PRE_STA) in wsm_handle_tx_data()
1478 if (!priv->join_status) { in wsm_handle_tx_data()
1480 } else if (!(BIT(txpriv->raw_link_id) & in wsm_handle_tx_data()
1481 (BIT(0) | priv->link_id_map))) { in wsm_handle_tx_data()
1482 wiphy_warn(priv->hw->wiphy, in wsm_handle_tx_data()
1486 if (cw1200_queue_get_generation(wsm->packet_id) > in wsm_handle_tx_data()
1494 wiphy_warn(priv->hw->wiphy, in wsm_handle_tx_data()
1500 if (priv->join_status != CW1200_JOIN_STATUS_IBSS) in wsm_handle_tx_data()
1514 spin_lock(&priv->bss_loss_lock); in wsm_handle_tx_data()
1515 if (priv->bss_loss_state) { in wsm_handle_tx_data()
1516 priv->bss_loss_confirm_id = wsm->packet_id; in wsm_handle_tx_data()
1517 wsm->queue_id = WSM_QUEUE_VOICE; in wsm_handle_tx_data()
1519 spin_unlock(&priv->bss_loss_lock); in wsm_handle_tx_data()
1523 priv->mode != NL80211_IFTYPE_AP) { in wsm_handle_tx_data()
1526 if (queue_work(priv->workqueue, in wsm_handle_tx_data()
1527 &priv->unjoin_work) <= 0) in wsm_handle_tx_data()
1530 tx_info->control.hw_key && in wsm_handle_tx_data()
1531 tx_info->control.hw_key->keyidx != priv->wep_default_key_id && in wsm_handle_tx_data()
1532 (tx_info->control.hw_key->cipher == WLAN_CIPHER_SUITE_WEP40 || in wsm_handle_tx_data()
1533 tx_info->control.hw_key->cipher == WLAN_CIPHER_SUITE_WEP104)) { in wsm_handle_tx_data()
1546 priv->pending_frame_id = wsm->packet_id; in wsm_handle_tx_data()
1547 if (queue_delayed_work(priv->workqueue, in wsm_handle_tx_data()
1548 &priv->scan.probe_work, 0) <= 0) in wsm_handle_tx_data()
1554 BUG_ON(cw1200_queue_remove(queue, wsm->packet_id)); in wsm_handle_tx_data()
1560 priv->wep_default_key_id = tx_info->control.hw_key->keyidx; in wsm_handle_tx_data()
1561 priv->pending_frame_id = wsm->packet_id; in wsm_handle_tx_data()
1562 if (queue_work(priv->workqueue, &priv->wep_key_work) <= 0) in wsm_handle_tx_data()
1582 unsigned score, best = -1; in cw1200_get_prio_queue()
1583 int winner = -1; in cw1200_get_prio_queue()
1589 queued = cw1200_queue_get_num_queued(&priv->tx_queue[i], in cw1200_get_prio_queue()
1594 edca = &priv->edca.params[i]; in cw1200_get_prio_queue()
1595 score = ((edca->aifns + edca->cwmin) << 16) + in cw1200_get_prio_queue()
1596 ((edca->cwmax - edca->cwmin) * in cw1200_get_prio_queue()
1605 if (winner >= 0 && priv->tx_burst_idx >= 0 && in cw1200_get_prio_queue()
1606 winner != priv->tx_burst_idx && in cw1200_get_prio_queue()
1608 &priv->tx_queue[winner], in cw1200_get_prio_queue()
1611 &priv->tx_queue[priv->tx_burst_idx], in cw1200_get_prio_queue()
1613 winner = priv->tx_burst_idx; in cw1200_get_prio_queue()
1628 if (priv->tx_multicast) { in wsm_get_tx_queue_and_mask()
1639 tx_allowed_mask = ~priv->sta_asleep_mask; in wsm_get_tx_queue_and_mask()
1641 if (priv->sta_asleep_mask) { in wsm_get_tx_queue_and_mask()
1642 tx_allowed_mask |= priv->pspoll_mask; in wsm_get_tx_queue_and_mask()
1650 return -ENOENT; in wsm_get_tx_queue_and_mask()
1653 *queue_p = &priv->tx_queue[idx]; in wsm_get_tx_queue_and_mask()
1672 if (priv->wsm_cmd.ptr) { /* CMD request */ in wsm_get_tx()
1674 spin_lock(&priv->wsm_cmd.lock); in wsm_get_tx()
1675 BUG_ON(!priv->wsm_cmd.ptr); in wsm_get_tx()
1676 *data = priv->wsm_cmd.ptr; in wsm_get_tx()
1677 *tx_len = priv->wsm_cmd.len; in wsm_get_tx()
1679 spin_unlock(&priv->wsm_cmd.lock); in wsm_get_tx()
1684 if (atomic_add_return(0, &priv->tx_lock)) in wsm_get_tx()
1687 spin_lock_bh(&priv->ps_state_lock); in wsm_get_tx()
1691 queue_num = queue - priv->tx_queue; in wsm_get_tx()
1693 if (priv->buffered_multicasts && in wsm_get_tx()
1695 (priv->tx_multicast || !priv->sta_asleep_mask)) { in wsm_get_tx()
1696 priv->buffered_multicasts = false; in wsm_get_tx()
1697 if (priv->tx_multicast) { in wsm_get_tx()
1698 priv->tx_multicast = false; in wsm_get_tx()
1699 queue_work(priv->workqueue, in wsm_get_tx()
1700 &priv->multicast_stop_work); in wsm_get_tx()
1704 spin_unlock_bh(&priv->ps_state_lock); in wsm_get_tx()
1718 wsm->hdr.id &= __cpu_to_le16( in wsm_get_tx()
1720 wsm->hdr.id |= cpu_to_le16( in wsm_get_tx()
1721 WSM_TX_LINK_ID(txpriv->raw_link_id)); in wsm_get_tx()
1722 priv->pspoll_mask &= ~BIT(txpriv->raw_link_id); in wsm_get_tx()
1725 *tx_len = __le16_to_cpu(wsm->hdr.len); in wsm_get_tx()
1728 if (priv->edca.params[queue_num].txop_limit) in wsm_get_tx()
1736 priv->tx_burst_idx = queue_num; in wsm_get_tx()
1738 priv->tx_burst_idx = -1; in wsm_get_tx()
1743 &((u8 *)wsm)[txpriv->offset]; in wsm_get_tx()
1748 hdr->frame_control |= in wsm_get_tx()
1754 wsm->more ? 'M' : ' '); in wsm_get_tx()
1765 if (data == priv->wsm_cmd.ptr) { in wsm_txed()
1766 spin_lock(&priv->wsm_cmd.lock); in wsm_txed()
1767 priv->wsm_cmd.ptr = NULL; in wsm_txed()
1768 spin_unlock(&priv->wsm_cmd.lock); in wsm_txed()
1777 BUG_ON(buf->begin); in wsm_buf_init()
1778 buf->begin = kmalloc(FWLOAD_BLOCK_SIZE, GFP_KERNEL | GFP_DMA); in wsm_buf_init()
1779 buf->end = buf->begin ? &buf->begin[FWLOAD_BLOCK_SIZE] : buf->begin; in wsm_buf_init()
1785 kfree(buf->begin); in wsm_buf_deinit()
1786 buf->begin = buf->data = buf->end = NULL; in wsm_buf_deinit()
1791 if (buf->begin) { in wsm_buf_reset()
1792 buf->data = &buf->begin[4]; in wsm_buf_reset()
1793 *(u32 *)buf->begin = 0; in wsm_buf_reset()
1795 buf->data = buf->begin; in wsm_buf_reset()
1801 size_t pos = buf->data - buf->begin; in wsm_buf_reserve()
1807 tmp = krealloc(buf->begin, size, GFP_KERNEL | GFP_DMA); in wsm_buf_reserve()
1810 return -ENOMEM; in wsm_buf_reserve()
1813 buf->begin = tmp; in wsm_buf_reserve()
1814 buf->data = &buf->begin[pos]; in wsm_buf_reserve()
1815 buf->end = &buf->begin[size]; in wsm_buf_reserve()