Lines Matching refs:priv

25 static void cw1200_do_join(struct cw1200_common *priv);
26 static void cw1200_do_unjoin(struct cw1200_common *priv);
28 static int cw1200_upload_beacon(struct cw1200_common *priv);
29 static int cw1200_upload_pspoll(struct cw1200_common *priv);
30 static int cw1200_upload_null(struct cw1200_common *priv);
31 static int cw1200_upload_qosnull(struct cw1200_common *priv);
32 static int cw1200_start_ap(struct cw1200_common *priv);
33 static int cw1200_update_beaconing(struct cw1200_common *priv);
34 static int cw1200_enable_beaconing(struct cw1200_common *priv,
40 static int __cw1200_flush(struct cw1200_common *priv, bool drop);
56 struct cw1200_common *priv = dev->priv; in cw1200_start() local
59 cw1200_pm_stay_awake(&priv->pm_state, HZ); in cw1200_start()
61 mutex_lock(&priv->conf_mutex); in cw1200_start()
64 WSM_EDCA_SET(&priv->edca, 0, 0x0002, 0x0003, 0x0007, 47, 0xc8, false); in cw1200_start()
65 WSM_EDCA_SET(&priv->edca, 1, 0x0002, 0x0007, 0x000f, 94, 0xc8, false); in cw1200_start()
66 WSM_EDCA_SET(&priv->edca, 2, 0x0003, 0x000f, 0x03ff, 0, 0xc8, false); in cw1200_start()
67 WSM_EDCA_SET(&priv->edca, 3, 0x0007, 0x000f, 0x03ff, 0, 0xc8, false); in cw1200_start()
68 ret = wsm_set_edca_params(priv, &priv->edca); in cw1200_start()
72 ret = cw1200_set_uapsd_param(priv, &priv->edca); in cw1200_start()
76 priv->setbssparams_done = false; in cw1200_start()
78 memcpy(priv->mac_addr, dev->wiphy->perm_addr, ETH_ALEN); in cw1200_start()
79 priv->mode = NL80211_IFTYPE_MONITOR; in cw1200_start()
80 priv->wep_default_key_id = -1; in cw1200_start()
82 priv->cqm_beacon_loss_count = 10; in cw1200_start()
84 ret = cw1200_setup_mac(priv); in cw1200_start()
89 mutex_unlock(&priv->conf_mutex); in cw1200_start()
95 struct cw1200_common *priv = dev->priv; in cw1200_stop() local
99 wsm_lock_tx(priv); in cw1200_stop()
101 while (down_trylock(&priv->scan.lock)) { in cw1200_stop()
103 priv->scan.req = NULL; in cw1200_stop()
106 up(&priv->scan.lock); in cw1200_stop()
108 cancel_delayed_work_sync(&priv->scan.probe_work); in cw1200_stop()
109 cancel_delayed_work_sync(&priv->scan.timeout); in cw1200_stop()
110 cancel_delayed_work_sync(&priv->clear_recent_scan_work); in cw1200_stop()
111 cancel_delayed_work_sync(&priv->join_timeout); in cw1200_stop()
112 cw1200_cqm_bssloss_sm(priv, 0, 0, 0); in cw1200_stop()
113 cancel_work_sync(&priv->unjoin_work); in cw1200_stop()
114 cancel_delayed_work_sync(&priv->link_id_gc_work); in cw1200_stop()
115 flush_workqueue(priv->workqueue); in cw1200_stop()
116 del_timer_sync(&priv->mcast_timeout); in cw1200_stop()
117 mutex_lock(&priv->conf_mutex); in cw1200_stop()
118 priv->mode = NL80211_IFTYPE_UNSPECIFIED; in cw1200_stop()
119 priv->listening = false; in cw1200_stop()
121 spin_lock(&priv->event_queue_lock); in cw1200_stop()
122 list_splice_init(&priv->event_queue, &list); in cw1200_stop()
123 spin_unlock(&priv->event_queue_lock); in cw1200_stop()
127 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_stop()
128 priv->join_pending = false; in cw1200_stop()
131 cw1200_queue_clear(&priv->tx_queue[i]); in cw1200_stop()
132 mutex_unlock(&priv->conf_mutex); in cw1200_stop()
133 tx_policy_clean(priv); in cw1200_stop()
136 if (atomic_xchg(&priv->tx_lock, 1) != 1) in cw1200_stop()
139 wsm_unlock_tx(priv); in cw1200_stop()
140 atomic_xchg(&priv->tx_lock, 0); /* for recovery to work */ in cw1200_stop()
148 void __cw1200_cqm_bssloss_sm(struct cw1200_common *priv, in __cw1200_cqm_bssloss_sm() argument
153 priv->delayed_link_loss = 0; in __cw1200_cqm_bssloss_sm()
154 cancel_work_sync(&priv->bss_params_work); in __cw1200_cqm_bssloss_sm()
157 priv->bss_loss_state, in __cw1200_cqm_bssloss_sm()
159 atomic_read(&priv->tx_lock), in __cw1200_cqm_bssloss_sm()
160 priv->delayed_unjoin); in __cw1200_cqm_bssloss_sm()
163 if (priv->delayed_unjoin) in __cw1200_cqm_bssloss_sm()
167 queue_delayed_work(priv->workqueue, in __cw1200_cqm_bssloss_sm()
168 &priv->bss_loss_work, in __cw1200_cqm_bssloss_sm()
170 priv->bss_loss_state = 0; in __cw1200_cqm_bssloss_sm()
173 if (!priv->vif->p2p && !atomic_read(&priv->tx_lock)) in __cw1200_cqm_bssloss_sm()
176 cancel_delayed_work_sync(&priv->bss_loss_work); in __cw1200_cqm_bssloss_sm()
177 priv->bss_loss_state = 0; in __cw1200_cqm_bssloss_sm()
178 queue_work(priv->workqueue, &priv->bss_params_work); in __cw1200_cqm_bssloss_sm()
181 if (priv->bss_loss_state < 3) in __cw1200_cqm_bssloss_sm()
184 cancel_delayed_work_sync(&priv->bss_loss_work); in __cw1200_cqm_bssloss_sm()
185 priv->bss_loss_state = 0; in __cw1200_cqm_bssloss_sm()
196 priv->bss_loss_state++; in __cw1200_cqm_bssloss_sm()
198 skb = ieee80211_nullfunc_get(priv->hw, priv->vif, false); in __cw1200_cqm_bssloss_sm()
201 cw1200_tx(priv->hw, NULL, skb); in __cw1200_cqm_bssloss_sm()
209 struct cw1200_common *priv = dev->priv; in cw1200_add_interface() local
216 mutex_lock(&priv->conf_mutex); in cw1200_add_interface()
218 if (priv->mode != NL80211_IFTYPE_MONITOR) { in cw1200_add_interface()
219 mutex_unlock(&priv->conf_mutex); in cw1200_add_interface()
228 priv->mode = vif->type; in cw1200_add_interface()
231 mutex_unlock(&priv->conf_mutex); in cw1200_add_interface()
235 priv->vif = vif; in cw1200_add_interface()
236 memcpy(priv->mac_addr, vif->addr, ETH_ALEN); in cw1200_add_interface()
237 ret = cw1200_setup_mac(priv); in cw1200_add_interface()
244 mutex_unlock(&priv->conf_mutex); in cw1200_add_interface()
251 struct cw1200_common *priv = dev->priv; in cw1200_remove_interface() local
257 mutex_lock(&priv->conf_mutex); in cw1200_remove_interface()
258 switch (priv->join_status) { in cw1200_remove_interface()
263 wsm_lock_tx(priv); in cw1200_remove_interface()
264 if (queue_work(priv->workqueue, &priv->unjoin_work) <= 0) in cw1200_remove_interface()
265 wsm_unlock_tx(priv); in cw1200_remove_interface()
268 for (i = 0; priv->link_id_map; ++i) { in cw1200_remove_interface()
269 if (priv->link_id_map & BIT(i)) { in cw1200_remove_interface()
271 wsm_reset(priv, &reset); in cw1200_remove_interface()
272 priv->link_id_map &= ~BIT(i); in cw1200_remove_interface()
275 memset(priv->link_id_db, 0, sizeof(priv->link_id_db)); in cw1200_remove_interface()
276 priv->sta_asleep_mask = 0; in cw1200_remove_interface()
277 priv->enable_beacon = false; in cw1200_remove_interface()
278 priv->tx_multicast = false; in cw1200_remove_interface()
279 priv->aid0_bit_set = false; in cw1200_remove_interface()
280 priv->buffered_multicasts = false; in cw1200_remove_interface()
281 priv->pspoll_mask = 0; in cw1200_remove_interface()
283 wsm_reset(priv, &reset); in cw1200_remove_interface()
286 cw1200_update_listening(priv, false); in cw1200_remove_interface()
291 priv->vif = NULL; in cw1200_remove_interface()
292 priv->mode = NL80211_IFTYPE_MONITOR; in cw1200_remove_interface()
293 eth_zero_addr(priv->mac_addr); in cw1200_remove_interface()
294 memset(&priv->p2p_ps_modeinfo, 0, sizeof(priv->p2p_ps_modeinfo)); in cw1200_remove_interface()
295 cw1200_free_keys(priv); in cw1200_remove_interface()
296 cw1200_setup_mac(priv); in cw1200_remove_interface()
297 priv->listening = false; in cw1200_remove_interface()
298 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_remove_interface()
299 if (!__cw1200_flush(priv, true)) in cw1200_remove_interface()
300 wsm_unlock_tx(priv); in cw1200_remove_interface()
302 mutex_unlock(&priv->conf_mutex); in cw1200_remove_interface()
327 struct cw1200_common *priv = dev->priv; in cw1200_config() local
332 down(&priv->scan.lock); in cw1200_config()
333 mutex_lock(&priv->conf_mutex); in cw1200_config()
338 priv->output_power = conf->power_level; in cw1200_config()
339 pr_debug("[STA] TX power: %d\n", priv->output_power); in cw1200_config()
340 wsm_set_output_power(priv, priv->output_power * 10); in cw1200_config()
344 (priv->channel != conf->chandef.chan)) { in cw1200_config()
353 if (!__cw1200_flush(priv, false)) { in cw1200_config()
354 if (!wsm_switch_channel(priv, &channel)) { in cw1200_config()
355 ret = wait_event_timeout(priv->channel_switch_done, in cw1200_config()
356 !priv->channel_switch_in_progress, in cw1200_config()
360 priv->channel = ch; in cw1200_config()
367 wsm_unlock_tx(priv); in cw1200_config()
374 priv->powersave_mode.mode = WSM_PSM_ACTIVE; in cw1200_config()
376 priv->powersave_mode.mode = WSM_PSM_PS; in cw1200_config()
378 priv->powersave_mode.mode = WSM_PSM_FAST_PS; in cw1200_config()
385 priv->powersave_mode.fast_psm_idle_period = 0xFF; in cw1200_config()
387 priv->powersave_mode.fast_psm_idle_period = in cw1200_config()
390 if (priv->join_status == CW1200_JOIN_STATUS_STA && in cw1200_config()
391 priv->bss_params.aid) in cw1200_config()
392 cw1200_set_pm(priv, &priv->powersave_mode); in cw1200_config()
410 wsm_lock_tx(priv); in cw1200_config()
412 if ((priv->join_status == CW1200_JOIN_STATUS_MONITOR) && in cw1200_config()
414 !priv->listening) { in cw1200_config()
415 cw1200_disable_listening(priv); in cw1200_config()
416 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_config()
418 wsm_set_operational_mode(priv, &mode); in cw1200_config()
419 wsm_unlock_tx(priv); in cw1200_config()
426 spin_lock_bh(&priv->tx_policy_cache.lock); in cw1200_config()
427 priv->long_frame_max_tx_count = conf->long_frame_max_tx_count; in cw1200_config()
428 priv->short_frame_max_tx_count = in cw1200_config()
431 priv->hw->max_rate_tries = priv->short_frame_max_tx_count; in cw1200_config()
432 spin_unlock_bh(&priv->tx_policy_cache.lock); in cw1200_config()
434 mutex_unlock(&priv->conf_mutex); in cw1200_config()
435 up(&priv->scan.lock); in cw1200_config()
439 void cw1200_update_filtering(struct cw1200_common *priv) in cw1200_update_filtering() argument
442 bool bssid_filtering = !priv->rx_filter.bssid; in cw1200_update_filtering()
443 bool is_p2p = priv->vif && priv->vif->p2p; in cw1200_update_filtering()
444 bool is_sta = priv->vif && NL80211_IFTYPE_STATION == priv->vif->type; in cw1200_update_filtering()
465 if (priv->join_status == CW1200_JOIN_STATUS_PASSIVE) in cw1200_update_filtering()
467 else if (priv->join_status == CW1200_JOIN_STATUS_MONITOR) in cw1200_update_filtering()
470 if (priv->disable_beacon_filter) { in cw1200_update_filtering()
496 ret = wsm_set_rx_filter(priv, &priv->rx_filter); in cw1200_update_filtering()
498 ret = wsm_set_beacon_filter_table(priv, &bf_tbl); in cw1200_update_filtering()
500 ret = wsm_beacon_filter_control(priv, &bf_ctrl); in cw1200_update_filtering()
502 ret = wsm_set_bssid_filtering(priv, bssid_filtering); in cw1200_update_filtering()
504 ret = wsm_set_multicast_filter(priv, &priv->multicast_filter); in cw1200_update_filtering()
506 wiphy_err(priv->hw->wiphy, in cw1200_update_filtering()
513 struct cw1200_common *priv = in cw1200_update_filtering_work() local
517 cw1200_update_filtering(priv); in cw1200_update_filtering_work()
522 struct cw1200_common *priv = in cw1200_set_beacon_wakeup_period_work() local
526 wsm_set_beacon_wakeup_period(priv, in cw1200_set_beacon_wakeup_period_work()
527 priv->beacon_int * priv->join_dtim_period > in cw1200_set_beacon_wakeup_period_work()
529 priv->join_dtim_period, 0); in cw1200_set_beacon_wakeup_period_work()
541 struct cw1200_common *priv = hw->priv; in cw1200_prepare_multicast() local
546 priv->has_multicast_subscription = false; in cw1200_prepare_multicast()
547 memset(&priv->multicast_filter, 0x00, sizeof(priv->multicast_filter)); in cw1200_prepare_multicast()
555 memcpy(&priv->multicast_filter.macaddrs[count], in cw1200_prepare_multicast()
559 priv->has_multicast_subscription = true; in cw1200_prepare_multicast()
564 priv->multicast_filter.enable = __cpu_to_le32(1); in cw1200_prepare_multicast()
565 priv->multicast_filter.num_addrs = __cpu_to_le32(count); in cw1200_prepare_multicast()
576 struct cw1200_common *priv = dev->priv; in cw1200_configure_filter() local
587 down(&priv->scan.lock); in cw1200_configure_filter()
588 mutex_lock(&priv->conf_mutex); in cw1200_configure_filter()
590 priv->rx_filter.promiscuous = 0; in cw1200_configure_filter()
591 priv->rx_filter.bssid = (*total_flags & (FIF_OTHER_BSS | in cw1200_configure_filter()
593 priv->rx_filter.fcs = (*total_flags & FIF_FCSFAIL) ? 1 : 0; in cw1200_configure_filter()
594 priv->disable_beacon_filter = !(*total_flags & in cw1200_configure_filter()
597 if (priv->listening != listening) { in cw1200_configure_filter()
598 priv->listening = listening; in cw1200_configure_filter()
599 wsm_lock_tx(priv); in cw1200_configure_filter()
600 cw1200_update_listening(priv, listening); in cw1200_configure_filter()
601 wsm_unlock_tx(priv); in cw1200_configure_filter()
603 cw1200_update_filtering(priv); in cw1200_configure_filter()
604 mutex_unlock(&priv->conf_mutex); in cw1200_configure_filter()
605 up(&priv->scan.lock); in cw1200_configure_filter()
611 struct cw1200_common *priv = dev->priv; in cw1200_conf_tx() local
616 mutex_lock(&priv->conf_mutex); in cw1200_conf_tx()
619 old_uapsd_flags = le16_to_cpu(priv->uapsd_info.uapsd_flags); in cw1200_conf_tx()
621 WSM_TX_QUEUE_SET(&priv->tx_queue_params, queue, 0, 0, 0); in cw1200_conf_tx()
622 ret = wsm_set_tx_queue_params(priv, in cw1200_conf_tx()
623 &priv->tx_queue_params.params[queue], queue); in cw1200_conf_tx()
629 WSM_EDCA_SET(&priv->edca, queue, params->aifs, in cw1200_conf_tx()
633 ret = wsm_set_edca_params(priv, &priv->edca); in cw1200_conf_tx()
639 if (priv->mode == NL80211_IFTYPE_STATION) { in cw1200_conf_tx()
640 ret = cw1200_set_uapsd_param(priv, &priv->edca); in cw1200_conf_tx()
641 if (!ret && priv->setbssparams_done && in cw1200_conf_tx()
642 (priv->join_status == CW1200_JOIN_STATUS_STA) && in cw1200_conf_tx()
643 (old_uapsd_flags != le16_to_cpu(priv->uapsd_info.uapsd_flags))) in cw1200_conf_tx()
644 ret = cw1200_set_pm(priv, &priv->powersave_mode); in cw1200_conf_tx()
651 mutex_unlock(&priv->conf_mutex); in cw1200_conf_tx()
658 struct cw1200_common *priv = dev->priv; in cw1200_get_stats() local
660 memcpy(stats, &priv->stats, sizeof(*stats)); in cw1200_get_stats()
664 int cw1200_set_pm(struct cw1200_common *priv, const struct wsm_set_pm *arg) in cw1200_set_pm() argument
668 if (priv->uapsd_info.uapsd_flags != 0) in cw1200_set_pm()
671 if (memcmp(&pm, &priv->firmware_ps_mode, in cw1200_set_pm()
673 priv->firmware_ps_mode = pm; in cw1200_set_pm()
674 return wsm_set_pm(priv, &pm); in cw1200_set_pm()
685 struct cw1200_common *priv = dev->priv; in cw1200_set_key() local
688 mutex_lock(&priv->conf_mutex); in cw1200_set_key()
694 int idx = cw1200_alloc_key(priv); in cw1200_set_key()
695 struct wsm_add_key *wsm_key = &priv->keys[idx]; in cw1200_set_key()
712 cw1200_free_key(priv, idx); in cw1200_set_key()
746 (priv->mode == NL80211_IFTYPE_AP) ? in cw1200_set_key()
811 cw1200_free_key(priv, idx); in cw1200_set_key()
815 ret = wsm_add_key(priv, wsm_key); in cw1200_set_key()
819 cw1200_free_key(priv, idx); in cw1200_set_key()
830 cw1200_free_key(priv, wsm_key.index); in cw1200_set_key()
831 ret = wsm_remove_key(priv, &wsm_key); in cw1200_set_key()
837 mutex_unlock(&priv->conf_mutex); in cw1200_set_key()
843 struct cw1200_common *priv = in cw1200_wep_key_work() local
845 u8 queue_id = cw1200_queue_get_queue_id(priv->pending_frame_id); in cw1200_wep_key_work()
846 struct cw1200_queue *queue = &priv->tx_queue[queue_id]; in cw1200_wep_key_work()
848 priv->wep_default_key_id); in cw1200_wep_key_work()
851 priv->wep_default_key_id); in cw1200_wep_key_work()
852 wsm_flush_tx(priv); in cw1200_wep_key_work()
853 wsm_write_mib(priv, WSM_MIB_ID_DOT11_WEP_DEFAULT_KEY_ID, in cw1200_wep_key_work()
855 cw1200_queue_requeue(queue, priv->pending_frame_id); in cw1200_wep_key_work()
856 wsm_unlock_tx(priv); in cw1200_wep_key_work()
863 struct cw1200_common *priv = hw->priv; in cw1200_set_rts_threshold() local
865 if (priv->mode == NL80211_IFTYPE_UNSPECIFIED) in cw1200_set_rts_threshold()
873 if (priv->rts_threshold == value) in cw1200_set_rts_threshold()
877 priv->rts_threshold); in cw1200_set_rts_threshold()
880 ret = wsm_write_mib(priv, WSM_MIB_ID_DOT11_RTS_THRESHOLD, in cw1200_set_rts_threshold()
883 priv->rts_threshold = value; in cw1200_set_rts_threshold()
891 static int __cw1200_flush(struct cw1200_common *priv, bool drop) in __cw1200_flush() argument
901 cw1200_queue_clear(&priv->tx_queue[i]); in __cw1200_flush()
904 priv->tx_queue_stats.wait_link_id_empty, in __cw1200_flush()
906 &priv->tx_queue_stats, -1), in __cw1200_flush()
917 wsm_lock_tx(priv); in __cw1200_flush()
918 if (!cw1200_queue_stats_is_empty(&priv->tx_queue_stats, -1)) { in __cw1200_flush()
920 wsm_unlock_tx(priv); in __cw1200_flush()
931 struct cw1200_common *priv = hw->priv; in cw1200_flush() local
933 switch (priv->mode) { in cw1200_flush()
938 if (!priv->enable_beacon) in cw1200_flush()
943 if (!__cw1200_flush(priv, drop)) in cw1200_flush()
944 wsm_unlock_tx(priv); in cw1200_flush()
952 void cw1200_free_event_queue(struct cw1200_common *priv) in cw1200_free_event_queue() argument
956 spin_lock(&priv->event_queue_lock); in cw1200_free_event_queue()
957 list_splice_init(&priv->event_queue, &list); in cw1200_free_event_queue()
958 spin_unlock(&priv->event_queue_lock); in cw1200_free_event_queue()
965 struct cw1200_common *priv = in cw1200_event_handler() local
970 spin_lock(&priv->event_queue_lock); in cw1200_event_handler()
971 list_splice_init(&priv->event_queue, &list); in cw1200_event_handler()
972 spin_unlock(&priv->event_queue_lock); in cw1200_event_handler()
981 cancel_work_sync(&priv->unjoin_work); in cw1200_event_handler()
982 if (!down_trylock(&priv->scan.lock)) { in cw1200_event_handler()
983 cw1200_cqm_bssloss_sm(priv, 1, 0, 0); in cw1200_event_handler()
984 up(&priv->scan.lock); in cw1200_event_handler()
989 priv->delayed_link_loss = 1; in cw1200_event_handler()
991 queue_delayed_work(priv->workqueue, in cw1200_event_handler()
992 &priv->bss_loss_work, 5*HZ); in cw1200_event_handler()
997 cw1200_cqm_bssloss_sm(priv, 0, 0, 0); in cw1200_event_handler()
998 cancel_work_sync(&priv->unjoin_work); in cw1200_event_handler()
1001 wiphy_info(priv->hw->wiphy, "radar pulse detected\n"); in cw1200_event_handler()
1010 if (priv->cqm_use_rssi) in cw1200_event_handler()
1015 cqm_evt = (rcpi_rssi <= priv->cqm_rssi_thold) ? in cw1200_event_handler()
1019 ieee80211_cqm_rssi_notify(priv->vif, cqm_evt, rcpi_rssi, in cw1200_event_handler()
1036 struct cw1200_common *priv = in cw1200_bss_loss_work() local
1040 wsm_lock_tx(priv); in cw1200_bss_loss_work()
1041 if (queue_work(priv->workqueue, &priv->unjoin_work) <= 0) in cw1200_bss_loss_work()
1042 wsm_unlock_tx(priv); in cw1200_bss_loss_work()
1047 struct cw1200_common *priv = in cw1200_bss_params_work() local
1049 mutex_lock(&priv->conf_mutex); in cw1200_bss_params_work()
1051 priv->bss_params.reset_beacon_loss = 1; in cw1200_bss_params_work()
1052 wsm_set_bss_params(priv, &priv->bss_params); in cw1200_bss_params_work()
1053 priv->bss_params.reset_beacon_loss = 0; in cw1200_bss_params_work()
1055 mutex_unlock(&priv->conf_mutex); in cw1200_bss_params_work()
1065 static int cw1200_parse_sdd_file(struct cw1200_common *priv) in cw1200_parse_sdd_file() argument
1067 const u8 *p = priv->sdd->data; in cw1200_parse_sdd_file()
1070 while (p + 2 <= priv->sdd->data + priv->sdd->size) { in cw1200_parse_sdd_file()
1071 if (p + p[1] + 2 > priv->sdd->data + priv->sdd->size) { in cw1200_parse_sdd_file()
1088 priv->conf_listen_interval = (v >> 7) & 0x1F; in cw1200_parse_sdd_file()
1090 priv->conf_listen_interval); in cw1200_parse_sdd_file()
1095 if (clk != priv->hw_refclk) in cw1200_parse_sdd_file()
1097 clk, priv->hw_refclk); in cw1200_parse_sdd_file()
1106 if (!priv->bt_present) { in cw1200_parse_sdd_file()
1108 priv->conf_listen_interval = 0; in cw1200_parse_sdd_file()
1113 int cw1200_setup_mac(struct cw1200_common *priv) in cw1200_setup_mac() argument
1133 .dot11StationId = &priv->mac_addr[0], in cw1200_setup_mac()
1140 priv->cqm_use_rssi = true; in cw1200_setup_mac()
1142 if (!priv->sdd) { in cw1200_setup_mac()
1143 ret = request_firmware(&priv->sdd, priv->sdd_path, priv->pdev); in cw1200_setup_mac()
1145 pr_err("Can't load sdd file %s.\n", priv->sdd_path); in cw1200_setup_mac()
1148 cw1200_parse_sdd_file(priv); in cw1200_setup_mac()
1151 cfg.dpdData = priv->sdd->data; in cw1200_setup_mac()
1152 cfg.dpdData_size = priv->sdd->size; in cw1200_setup_mac()
1153 ret = wsm_configuration(priv, &cfg); in cw1200_setup_mac()
1158 wsm_set_rcpi_rssi_threshold(priv, &threshold); in cw1200_setup_mac()
1163 static void cw1200_join_complete(struct cw1200_common *priv) in cw1200_join_complete() argument
1165 pr_debug("[STA] Join complete (%d)\n", priv->join_complete_status); in cw1200_join_complete()
1167 priv->join_pending = false; in cw1200_join_complete()
1168 if (priv->join_complete_status) { in cw1200_join_complete()
1169 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_join_complete()
1170 cw1200_update_listening(priv, priv->listening); in cw1200_join_complete()
1171 cw1200_do_unjoin(priv); in cw1200_join_complete()
1172 ieee80211_connection_loss(priv->vif); in cw1200_join_complete()
1174 if (priv->mode == NL80211_IFTYPE_ADHOC) in cw1200_join_complete()
1175 priv->join_status = CW1200_JOIN_STATUS_IBSS; in cw1200_join_complete()
1177 priv->join_status = CW1200_JOIN_STATUS_PRE_STA; in cw1200_join_complete()
1179 wsm_unlock_tx(priv); /* Clearing the lock held before do_join() */ in cw1200_join_complete()
1184 struct cw1200_common *priv = in cw1200_join_complete_work() local
1186 mutex_lock(&priv->conf_mutex); in cw1200_join_complete_work()
1187 cw1200_join_complete(priv); in cw1200_join_complete_work()
1188 mutex_unlock(&priv->conf_mutex); in cw1200_join_complete_work()
1191 void cw1200_join_complete_cb(struct cw1200_common *priv, in cw1200_join_complete_cb() argument
1197 if (cancel_delayed_work(&priv->join_timeout)) { in cw1200_join_complete_cb()
1198 priv->join_complete_status = arg->status; in cw1200_join_complete_cb()
1199 queue_work(priv->workqueue, &priv->join_complete_work); in cw1200_join_complete_cb()
1204 static void cw1200_do_join(struct cw1200_common *priv) in cw1200_do_join() argument
1207 struct ieee80211_bss_conf *conf = &priv->vif->bss_conf; in cw1200_do_join()
1216 .basic_rate_set = cw1200_rate_mask_to_wsm(priv, in cw1200_do_join()
1219 if (delayed_work_pending(&priv->join_timeout)) { in cw1200_do_join()
1221 wsm_unlock_tx(priv); in cw1200_do_join()
1225 if (priv->join_status) in cw1200_do_join()
1226 cw1200_do_unjoin(priv); in cw1200_do_join()
1228 bssid = priv->vif->bss_conf.bssid; in cw1200_do_join()
1230 bss = cfg80211_get_bss(priv->hw->wiphy, priv->channel, bssid, NULL, 0, in cw1200_do_join()
1234 wsm_unlock_tx(priv); in cw1200_do_join()
1238 mutex_lock(&priv->conf_mutex); in cw1200_do_join()
1243 if (atomic_read(&priv->scan.in_progress)) { in cw1200_do_join()
1244 wsm_unlock_tx(priv); in cw1200_do_join()
1248 priv->join_pending = true; in cw1200_do_join()
1255 if (!priv->beacon_int) in cw1200_do_join()
1256 priv->beacon_int = 1; in cw1200_do_join()
1258 join.beacon_interval = priv->beacon_int; in cw1200_do_join()
1261 if (priv->bt_present) { in cw1200_do_join()
1262 if (((priv->conf_listen_interval * 100) % in cw1200_do_join()
1263 priv->beacon_int) == 0) in cw1200_do_join()
1264 priv->listen_interval = in cw1200_do_join()
1265 ((priv->conf_listen_interval * 100) / in cw1200_do_join()
1266 priv->beacon_int); in cw1200_do_join()
1268 priv->listen_interval = in cw1200_do_join()
1269 ((priv->conf_listen_interval * 100) / in cw1200_do_join()
1270 priv->beacon_int + 1); in cw1200_do_join()
1273 if (priv->hw->conf.ps_dtim_period) in cw1200_do_join()
1274 priv->join_dtim_period = priv->hw->conf.ps_dtim_period; in cw1200_do_join()
1275 join.dtim_period = priv->join_dtim_period; in cw1200_do_join()
1277 join.channel_number = priv->channel->hw_value; in cw1200_do_join()
1278 join.band = (priv->channel->band == NL80211_BAND_5GHZ) ? in cw1200_do_join()
1285 join.dtim_period, priv->beacon_int); in cw1200_do_join()
1298 if (priv->vif->p2p) { in cw1200_do_join()
1301 cw1200_rate_mask_to_wsm(priv, 0xFF0); in cw1200_do_join()
1310 wsm_flush_tx(priv); in cw1200_do_join()
1313 cw1200_pm_stay_awake(&priv->pm_state, in cw1200_do_join()
1316 cw1200_update_listening(priv, false); in cw1200_do_join()
1319 wsm_set_block_ack_policy(priv, priv->ba_tx_tid_mask, in cw1200_do_join()
1320 priv->ba_rx_tid_mask); in cw1200_do_join()
1324 priv->join_status = CW1200_JOIN_STATUS_JOINING; in cw1200_do_join()
1325 queue_delayed_work(priv->workqueue, in cw1200_do_join()
1326 &priv->join_timeout, in cw1200_do_join()
1334 wsm_set_protected_mgmt_policy(priv, &mgmt_policy); in cw1200_do_join()
1337 if (wsm_join(priv, &join)) { in cw1200_do_join()
1339 cancel_delayed_work_sync(&priv->join_timeout); in cw1200_do_join()
1340 cw1200_update_listening(priv, priv->listening); in cw1200_do_join()
1342 if (queue_work(priv->workqueue, &priv->unjoin_work) <= 0) in cw1200_do_join()
1343 wsm_unlock_tx(priv); in cw1200_do_join()
1346 cw1200_join_complete(priv); /* Will clear tx_lock */ in cw1200_do_join()
1349 cw1200_upload_keys(priv); in cw1200_do_join()
1356 priv->disable_beacon_filter = true; in cw1200_do_join()
1358 cw1200_update_filtering(priv); in cw1200_do_join()
1361 mutex_unlock(&priv->conf_mutex); in cw1200_do_join()
1363 cfg80211_put_bss(priv->hw->wiphy, bss); in cw1200_do_join()
1368 struct cw1200_common *priv = in cw1200_join_timeout() local
1371 wsm_lock_tx(priv); in cw1200_join_timeout()
1372 if (queue_work(priv->workqueue, &priv->unjoin_work) <= 0) in cw1200_join_timeout()
1373 wsm_unlock_tx(priv); in cw1200_join_timeout()
1376 static void cw1200_do_unjoin(struct cw1200_common *priv) in cw1200_do_unjoin() argument
1382 cancel_delayed_work_sync(&priv->join_timeout); in cw1200_do_unjoin()
1384 mutex_lock(&priv->conf_mutex); in cw1200_do_unjoin()
1385 priv->join_pending = false; in cw1200_do_unjoin()
1387 if (atomic_read(&priv->scan.in_progress)) { in cw1200_do_unjoin()
1388 if (priv->delayed_unjoin) in cw1200_do_unjoin()
1389 wiphy_dbg(priv->hw->wiphy, "Delayed unjoin is already scheduled.\n"); in cw1200_do_unjoin()
1391 priv->delayed_unjoin = true; in cw1200_do_unjoin()
1395 priv->delayed_link_loss = false; in cw1200_do_unjoin()
1397 if (!priv->join_status) in cw1200_do_unjoin()
1400 if (priv->join_status == CW1200_JOIN_STATUS_AP) in cw1200_do_unjoin()
1403 cancel_work_sync(&priv->update_filtering_work); in cw1200_do_unjoin()
1404 cancel_work_sync(&priv->set_beacon_wakeup_period_work); in cw1200_do_unjoin()
1405 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_do_unjoin()
1408 wsm_flush_tx(priv); in cw1200_do_unjoin()
1409 wsm_keep_alive_period(priv, 0); in cw1200_do_unjoin()
1410 wsm_reset(priv, &reset); in cw1200_do_unjoin()
1411 wsm_set_output_power(priv, priv->output_power * 10); in cw1200_do_unjoin()
1412 priv->join_dtim_period = 0; in cw1200_do_unjoin()
1413 cw1200_setup_mac(priv); in cw1200_do_unjoin()
1414 cw1200_free_event_queue(priv); in cw1200_do_unjoin()
1415 cancel_work_sync(&priv->event_handler); in cw1200_do_unjoin()
1416 cw1200_update_listening(priv, priv->listening); in cw1200_do_unjoin()
1417 cw1200_cqm_bssloss_sm(priv, 0, 0, 0); in cw1200_do_unjoin()
1420 wsm_set_block_ack_policy(priv, 0, 0); in cw1200_do_unjoin()
1422 priv->disable_beacon_filter = false; in cw1200_do_unjoin()
1423 cw1200_update_filtering(priv); in cw1200_do_unjoin()
1424 memset(&priv->association_mode, 0, in cw1200_do_unjoin()
1425 sizeof(priv->association_mode)); in cw1200_do_unjoin()
1426 memset(&priv->bss_params, 0, sizeof(priv->bss_params)); in cw1200_do_unjoin()
1427 priv->setbssparams_done = false; in cw1200_do_unjoin()
1428 memset(&priv->firmware_ps_mode, 0, in cw1200_do_unjoin()
1429 sizeof(priv->firmware_ps_mode)); in cw1200_do_unjoin()
1434 mutex_unlock(&priv->conf_mutex); in cw1200_do_unjoin()
1439 struct cw1200_common *priv = in cw1200_unjoin_work() local
1442 cw1200_do_unjoin(priv); in cw1200_unjoin_work()
1445 ieee80211_connection_loss(priv->vif); in cw1200_unjoin_work()
1447 wsm_unlock_tx(priv); in cw1200_unjoin_work()
1450 int cw1200_enable_listening(struct cw1200_common *priv) in cw1200_enable_listening() argument
1461 if (priv->channel) { in cw1200_enable_listening()
1462 start.band = priv->channel->band == NL80211_BAND_5GHZ ? in cw1200_enable_listening()
1464 start.channel_number = priv->channel->hw_value; in cw1200_enable_listening()
1470 return wsm_start(priv, &start); in cw1200_enable_listening()
1473 int cw1200_disable_listening(struct cw1200_common *priv) in cw1200_disable_listening() argument
1479 ret = wsm_reset(priv, &reset); in cw1200_disable_listening()
1483 void cw1200_update_listening(struct cw1200_common *priv, bool enabled) in cw1200_update_listening() argument
1486 if (priv->join_status == CW1200_JOIN_STATUS_PASSIVE) { in cw1200_update_listening()
1487 if (!cw1200_enable_listening(priv)) in cw1200_update_listening()
1488 priv->join_status = CW1200_JOIN_STATUS_MONITOR; in cw1200_update_listening()
1489 wsm_set_probe_responder(priv, true); in cw1200_update_listening()
1492 if (priv->join_status == CW1200_JOIN_STATUS_MONITOR) { in cw1200_update_listening()
1493 if (!cw1200_disable_listening(priv)) in cw1200_update_listening()
1494 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_update_listening()
1495 wsm_set_probe_responder(priv, false); in cw1200_update_listening()
1500 int cw1200_set_uapsd_param(struct cw1200_common *priv, in cw1200_set_uapsd_param() argument
1527 priv->uapsd_info.uapsd_flags = cpu_to_le16(uapsd_flags); in cw1200_set_uapsd_param()
1528 priv->uapsd_info.min_auto_trigger_interval = 0; in cw1200_set_uapsd_param()
1529 priv->uapsd_info.max_auto_trigger_interval = 0; in cw1200_set_uapsd_param()
1530 priv->uapsd_info.auto_trigger_step = 0; in cw1200_set_uapsd_param()
1532 ret = wsm_set_uapsd_info(priv, &priv->uapsd_info); in cw1200_set_uapsd_param()
1542 struct cw1200_common *priv = hw->priv; in cw1200_sta_add() local
1548 if (priv->mode != NL80211_IFTYPE_AP) in cw1200_sta_add()
1551 sta_priv->link_id = cw1200_find_link_id(priv, sta->addr); in cw1200_sta_add()
1553 wiphy_info(priv->hw->wiphy, in cw1200_sta_add()
1558 entry = &priv->link_id_db[sta_priv->link_id - 1]; in cw1200_sta_add()
1559 spin_lock_bh(&priv->ps_state_lock); in cw1200_sta_add()
1562 priv->sta_asleep_mask |= BIT(sta_priv->link_id); in cw1200_sta_add()
1565 ieee80211_rx_irqsafe(priv->hw, skb); in cw1200_sta_add()
1566 spin_unlock_bh(&priv->ps_state_lock); in cw1200_sta_add()
1573 struct cw1200_common *priv = hw->priv; in cw1200_sta_remove() local
1578 if (priv->mode != NL80211_IFTYPE_AP || !sta_priv->link_id) in cw1200_sta_remove()
1581 entry = &priv->link_id_db[sta_priv->link_id - 1]; in cw1200_sta_remove()
1582 spin_lock_bh(&priv->ps_state_lock); in cw1200_sta_remove()
1585 wsm_lock_tx_async(priv); in cw1200_sta_remove()
1586 if (queue_work(priv->workqueue, &priv->link_id_work) <= 0) in cw1200_sta_remove()
1587 wsm_unlock_tx(priv); in cw1200_sta_remove()
1588 spin_unlock_bh(&priv->ps_state_lock); in cw1200_sta_remove()
1589 flush_workqueue(priv->workqueue); in cw1200_sta_remove()
1598 struct cw1200_common *priv = dev->priv; in __cw1200_sta_notify() local
1607 bit = priv->link_id_map; in __cw1200_sta_notify()
1608 prev = priv->sta_asleep_mask & bit; in __cw1200_sta_notify()
1613 if (priv->buffered_multicasts && in __cw1200_sta_notify()
1614 !priv->sta_asleep_mask) in __cw1200_sta_notify()
1615 queue_work(priv->workqueue, in __cw1200_sta_notify()
1616 &priv->multicast_start_work); in __cw1200_sta_notify()
1617 priv->sta_asleep_mask |= bit; in __cw1200_sta_notify()
1622 priv->sta_asleep_mask &= ~bit; in __cw1200_sta_notify()
1623 priv->pspoll_mask &= ~bit; in __cw1200_sta_notify()
1624 if (priv->tx_multicast && link_id && in __cw1200_sta_notify()
1625 !priv->sta_asleep_mask) in __cw1200_sta_notify()
1626 queue_work(priv->workqueue, in __cw1200_sta_notify()
1627 &priv->multicast_stop_work); in __cw1200_sta_notify()
1628 cw1200_bh_wakeup(priv); in __cw1200_sta_notify()
1639 struct cw1200_common *priv = dev->priv; in cw1200_sta_notify() local
1643 spin_lock_bh(&priv->ps_state_lock); in cw1200_sta_notify()
1645 spin_unlock_bh(&priv->ps_state_lock); in cw1200_sta_notify()
1648 static void cw1200_ps_notify(struct cw1200_common *priv, in cw1200_ps_notify() argument
1656 link_id, priv->sta_asleep_mask); in cw1200_ps_notify()
1658 __cw1200_sta_notify(priv->hw, priv->vif, in cw1200_ps_notify()
1662 static int cw1200_set_tim_impl(struct cw1200_common *priv, bool aid0_bit_set) in cw1200_set_tim_impl() argument
1673 skb = ieee80211_beacon_get_tim(priv->hw, priv->vif, in cw1200_set_tim_impl()
1676 if (!__cw1200_flush(priv, true)) in cw1200_set_tim_impl()
1677 wsm_unlock_tx(priv); in cw1200_set_tim_impl()
1696 wsm_update_ie(priv, &update_ie); in cw1200_set_tim_impl()
1705 struct cw1200_common *priv = in cw1200_set_tim_work() local
1707 (void)cw1200_set_tim_impl(priv, priv->aid0_bit_set); in cw1200_set_tim_work()
1713 struct cw1200_common *priv = dev->priv; in cw1200_set_tim() local
1714 queue_work(priv->workqueue, &priv->set_tim_work); in cw1200_set_tim()
1720 struct cw1200_common *priv = in cw1200_set_cts_work() local
1732 mutex_lock(&priv->conf_mutex); in cw1200_set_cts_work()
1733 erp_info = priv->erp_info; in cw1200_set_cts_work()
1734 mutex_unlock(&priv->conf_mutex); in cw1200_set_cts_work()
1743 wsm_write_mib(priv, WSM_MIB_ID_NON_ERP_PROTECTION, in cw1200_set_cts_work()
1745 wsm_update_ie(priv, &update_ie); in cw1200_set_cts_work()
1750 static int cw1200_set_btcoexinfo(struct cw1200_common *priv) in cw1200_set_btcoexinfo() argument
1755 if (priv->mode == NL80211_IFTYPE_STATION) { in cw1200_set_btcoexinfo()
1757 cw1200_upload_pspoll(priv); in cw1200_set_btcoexinfo()
1758 cw1200_upload_null(priv); in cw1200_set_btcoexinfo()
1759 cw1200_upload_qosnull(priv); in cw1200_set_btcoexinfo()
1766 if (!priv->vif->p2p) { in cw1200_set_btcoexinfo()
1768 if (priv->bss_params.operational_rate_set & ~0xF) { in cw1200_set_btcoexinfo()
1772 priv->bss_params.operational_rate_set & ~0xF)); in cw1200_set_btcoexinfo()
1776 arg.internalTxRate = (__ffs(le32_to_cpu(priv->association_mode.basic_rate_set))); in cw1200_set_btcoexinfo()
1778 arg.nonErpInternalTxRate = (__ffs(le32_to_cpu(priv->association_mode.basic_rate_set))); in cw1200_set_btcoexinfo()
1781 arg.internalTxRate = (__ffs(priv->bss_params.operational_rate_set & ~0xF)); in cw1200_set_btcoexinfo()
1782 arg.nonErpInternalTxRate = (__ffs(priv->bss_params.operational_rate_set & ~0xF)); in cw1200_set_btcoexinfo()
1786 priv->mode, in cw1200_set_btcoexinfo()
1790 ret = wsm_write_mib(priv, WSM_MIB_ID_OVERRIDE_INTERNAL_TX_RATE, in cw1200_set_btcoexinfo()
1801 struct cw1200_common *priv = dev->priv; in cw1200_bss_info_changed() local
1804 mutex_lock(&priv->conf_mutex); in cw1200_bss_info_changed()
1834 wsm_set_arp_ipv4_filter(priv, &filter); in cw1200_bss_info_changed()
1844 priv->beacon_int = info->beacon_int; in cw1200_bss_info_changed()
1845 cw1200_update_beaconing(priv); in cw1200_bss_info_changed()
1846 cw1200_upload_beacon(priv); in cw1200_bss_info_changed()
1852 if (priv->enable_beacon != info->enable_beacon) { in cw1200_bss_info_changed()
1853 cw1200_enable_beaconing(priv, info->enable_beacon); in cw1200_bss_info_changed()
1854 priv->enable_beacon = info->enable_beacon; in cw1200_bss_info_changed()
1862 else if (priv->join_status == CW1200_JOIN_STATUS_AP) in cw1200_bss_info_changed()
1863 cw1200_update_beaconing(priv); in cw1200_bss_info_changed()
1868 wsm_lock_tx(priv); in cw1200_bss_info_changed()
1869 priv->wep_default_key_id = -1; in cw1200_bss_info_changed()
1870 wsm_unlock_tx(priv); in cw1200_bss_info_changed()
1886 if (priv->join_status < CW1200_JOIN_STATUS_PRE_STA) { in cw1200_bss_info_changed()
1888 mutex_unlock(&priv->conf_mutex); in cw1200_bss_info_changed()
1890 } else if (priv->join_status == CW1200_JOIN_STATUS_PRE_STA) { in cw1200_bss_info_changed()
1891 priv->join_status = CW1200_JOIN_STATUS_STA; in cw1200_bss_info_changed()
1902 priv->join_dtim_period = info->dtim_period; in cw1200_bss_info_changed()
1903 priv->beacon_int = info->beacon_int; in cw1200_bss_info_changed()
1910 priv->ht_info.ht_cap = sta->ht_cap; in cw1200_bss_info_changed()
1911 priv->bss_params.operational_rate_set = in cw1200_bss_info_changed()
1912 cw1200_rate_mask_to_wsm(priv, in cw1200_bss_info_changed()
1913 sta->supp_rates[priv->channel->band]); in cw1200_bss_info_changed()
1914 priv->ht_info.channel_type = cfg80211_get_chandef_type(&dev->conf.chandef); in cw1200_bss_info_changed()
1915 priv->ht_info.operation_mode = info->ht_operation_mode; in cw1200_bss_info_changed()
1917 memset(&priv->ht_info, 0, in cw1200_bss_info_changed()
1918 sizeof(priv->ht_info)); in cw1200_bss_info_changed()
1919 priv->bss_params.operational_rate_set = -1; in cw1200_bss_info_changed()
1924 if (priv->ht_info.operation_mode & in cw1200_bss_info_changed()
1929 htprot |= cpu_to_le32((priv->ht_info.operation_mode & IEEE80211_HT_OP_MODE_PROTECTION) << 2); in cw1200_bss_info_changed()
1936 wsm_write_mib(priv, WSM_MIB_ID_SET_HT_PROTECTION, in cw1200_bss_info_changed()
1939 priv->association_mode.greenfield = in cw1200_bss_info_changed()
1940 cw1200_ht_greenfield(&priv->ht_info); in cw1200_bss_info_changed()
1941 priv->association_mode.flags = in cw1200_bss_info_changed()
1947 priv->association_mode.preamble = in cw1200_bss_info_changed()
1951 priv->association_mode.basic_rate_set = __cpu_to_le32( in cw1200_bss_info_changed()
1952 cw1200_rate_mask_to_wsm(priv, in cw1200_bss_info_changed()
1954 priv->association_mode.mpdu_start_spacing = in cw1200_bss_info_changed()
1955 cw1200_ht_ampdu_density(&priv->ht_info); in cw1200_bss_info_changed()
1957 cw1200_cqm_bssloss_sm(priv, 0, 0, 0); in cw1200_bss_info_changed()
1958 cancel_work_sync(&priv->unjoin_work); in cw1200_bss_info_changed()
1960 priv->bss_params.beacon_lost_count = priv->cqm_beacon_loss_count; in cw1200_bss_info_changed()
1961 priv->bss_params.aid = info->aid; in cw1200_bss_info_changed()
1963 if (priv->join_dtim_period < 1) in cw1200_bss_info_changed()
1964 priv->join_dtim_period = 1; in cw1200_bss_info_changed()
1967 priv->join_dtim_period, priv->beacon_int); in cw1200_bss_info_changed()
1969 priv->association_mode.preamble, in cw1200_bss_info_changed()
1970 priv->association_mode.greenfield, in cw1200_bss_info_changed()
1971 priv->bss_params.aid, in cw1200_bss_info_changed()
1972 priv->bss_params.operational_rate_set, in cw1200_bss_info_changed()
1973 priv->association_mode.basic_rate_set); in cw1200_bss_info_changed()
1974 wsm_set_association_mode(priv, &priv->association_mode); in cw1200_bss_info_changed()
1977 wsm_keep_alive_period(priv, 30 /* sec */); in cw1200_bss_info_changed()
1978 wsm_set_bss_params(priv, &priv->bss_params); in cw1200_bss_info_changed()
1979 priv->setbssparams_done = true; in cw1200_bss_info_changed()
1980 cw1200_set_beacon_wakeup_period_work(&priv->set_beacon_wakeup_period_work); in cw1200_bss_info_changed()
1981 cw1200_set_pm(priv, &priv->powersave_mode); in cw1200_bss_info_changed()
1983 if (priv->vif->p2p) { in cw1200_bss_info_changed()
1985 wsm_set_p2p_ps_modeinfo(priv, in cw1200_bss_info_changed()
1986 &priv->p2p_ps_modeinfo); in cw1200_bss_info_changed()
1988 if (priv->bt_present) in cw1200_bss_info_changed()
1989 cw1200_set_btcoexinfo(priv); in cw1200_bss_info_changed()
1991 memset(&priv->association_mode, 0, in cw1200_bss_info_changed()
1992 sizeof(priv->association_mode)); in cw1200_bss_info_changed()
1993 memset(&priv->bss_params, 0, sizeof(priv->bss_params)); in cw1200_bss_info_changed()
2001 u32 prev_erp_info = priv->erp_info; in cw1200_bss_info_changed()
2003 priv->erp_info |= WLAN_ERP_USE_PROTECTION; in cw1200_bss_info_changed()
2005 priv->erp_info &= ~WLAN_ERP_USE_PROTECTION; in cw1200_bss_info_changed()
2008 priv->erp_info |= WLAN_ERP_BARKER_PREAMBLE; in cw1200_bss_info_changed()
2010 priv->erp_info &= ~WLAN_ERP_BARKER_PREAMBLE; in cw1200_bss_info_changed()
2012 pr_debug("[STA] ERP Protection: %x\n", priv->erp_info); in cw1200_bss_info_changed()
2014 if (prev_erp_info != priv->erp_info) in cw1200_bss_info_changed()
2015 queue_work(priv->workqueue, &priv->set_cts_work); in cw1200_bss_info_changed()
2024 wsm_write_mib(priv, WSM_MIB_ID_DOT11_SLOT_TIME, in cw1200_bss_info_changed()
2034 priv->cqm_rssi_thold = info->cqm_rssi_thold; in cw1200_bss_info_changed()
2035 priv->cqm_rssi_hyst = info->cqm_rssi_hyst; in cw1200_bss_info_changed()
2048 if (priv->cqm_use_rssi) { in cw1200_bss_info_changed()
2067 if (priv->cqm_use_rssi) in cw1200_bss_info_changed()
2070 wsm_set_rcpi_rssi_threshold(priv, &threshold); in cw1200_bss_info_changed()
2072 mutex_unlock(&priv->conf_mutex); in cw1200_bss_info_changed()
2075 wsm_lock_tx(priv); in cw1200_bss_info_changed()
2076 cw1200_do_join(priv); /* Will unlock it for us */ in cw1200_bss_info_changed()
2082 struct cw1200_common *priv = in cw1200_multicast_start_work() local
2084 long tmo = priv->join_dtim_period * in cw1200_multicast_start_work()
2085 (priv->beacon_int + 20) * HZ / 1024; in cw1200_multicast_start_work()
2087 cancel_work_sync(&priv->multicast_stop_work); in cw1200_multicast_start_work()
2089 if (!priv->aid0_bit_set) { in cw1200_multicast_start_work()
2090 wsm_lock_tx(priv); in cw1200_multicast_start_work()
2091 cw1200_set_tim_impl(priv, true); in cw1200_multicast_start_work()
2092 priv->aid0_bit_set = true; in cw1200_multicast_start_work()
2093 mod_timer(&priv->mcast_timeout, jiffies + tmo); in cw1200_multicast_start_work()
2094 wsm_unlock_tx(priv); in cw1200_multicast_start_work()
2100 struct cw1200_common *priv = in cw1200_multicast_stop_work() local
2103 if (priv->aid0_bit_set) { in cw1200_multicast_stop_work()
2104 del_timer_sync(&priv->mcast_timeout); in cw1200_multicast_stop_work()
2105 wsm_lock_tx(priv); in cw1200_multicast_stop_work()
2106 priv->aid0_bit_set = false; in cw1200_multicast_stop_work()
2107 cw1200_set_tim_impl(priv, false); in cw1200_multicast_stop_work()
2108 wsm_unlock_tx(priv); in cw1200_multicast_stop_work()
2114 struct cw1200_common *priv = from_timer(priv, t, mcast_timeout); in cw1200_mcast_timeout() local
2116 wiphy_warn(priv->hw->wiphy, in cw1200_mcast_timeout()
2118 spin_lock_bh(&priv->ps_state_lock); in cw1200_mcast_timeout()
2119 priv->tx_multicast = priv->aid0_bit_set && in cw1200_mcast_timeout()
2120 priv->buffered_multicasts; in cw1200_mcast_timeout()
2121 if (priv->tx_multicast) in cw1200_mcast_timeout()
2122 cw1200_bh_wakeup(priv); in cw1200_mcast_timeout()
2123 spin_unlock_bh(&priv->ps_state_lock); in cw1200_mcast_timeout()
2142 void cw1200_suspend_resume(struct cw1200_common *priv, in cw1200_suspend_resume() argument
2151 spin_lock_bh(&priv->ps_state_lock); in cw1200_suspend_resume()
2153 priv->tx_multicast = false; in cw1200_suspend_resume()
2160 cw1200_pm_stay_awake(&priv->pm_state, in cw1200_suspend_resume()
2161 priv->join_dtim_period * in cw1200_suspend_resume()
2162 (priv->beacon_int + 20) * HZ / 1024); in cw1200_suspend_resume()
2163 priv->tx_multicast = (priv->aid0_bit_set && in cw1200_suspend_resume()
2164 priv->buffered_multicasts); in cw1200_suspend_resume()
2165 if (priv->tx_multicast) { in cw1200_suspend_resume()
2167 cw1200_bh_wakeup(priv); in cw1200_suspend_resume()
2170 spin_unlock_bh(&priv->ps_state_lock); in cw1200_suspend_resume()
2172 del_timer_sync(&priv->mcast_timeout); in cw1200_suspend_resume()
2174 spin_lock_bh(&priv->ps_state_lock); in cw1200_suspend_resume()
2175 cw1200_ps_notify(priv, arg->link_id, arg->stop); in cw1200_suspend_resume()
2176 spin_unlock_bh(&priv->ps_state_lock); in cw1200_suspend_resume()
2178 cw1200_bh_wakeup(priv); in cw1200_suspend_resume()
2186 static int cw1200_upload_beacon(struct cw1200_common *priv) in cw1200_upload_beacon() argument
2197 if (priv->mode == NL80211_IFTYPE_STATION || in cw1200_upload_beacon()
2198 priv->mode == NL80211_IFTYPE_MONITOR || in cw1200_upload_beacon()
2199 priv->mode == NL80211_IFTYPE_UNSPECIFIED) in cw1200_upload_beacon()
2202 if (priv->vif->p2p) in cw1200_upload_beacon()
2205 frame.skb = ieee80211_beacon_get_tim(priv->hw, priv->vif, in cw1200_upload_beacon()
2210 ret = wsm_set_template_frame(priv, &frame); in cw1200_upload_beacon()
2224 if (priv->vif->p2p) { in cw1200_upload_beacon()
2225 ret = wsm_set_probe_responder(priv, true); in cw1200_upload_beacon()
2227 ret = wsm_set_template_frame(priv, &frame); in cw1200_upload_beacon()
2228 wsm_set_probe_responder(priv, false); in cw1200_upload_beacon()
2237 static int cw1200_upload_pspoll(struct cw1200_common *priv) in cw1200_upload_pspoll() argument
2246 frame.skb = ieee80211_pspoll_get(priv->hw, priv->vif); in cw1200_upload_pspoll()
2250 ret = wsm_set_template_frame(priv, &frame); in cw1200_upload_pspoll()
2257 static int cw1200_upload_null(struct cw1200_common *priv) in cw1200_upload_null() argument
2265 frame.skb = ieee80211_nullfunc_get(priv->hw, priv->vif, false); in cw1200_upload_null()
2269 ret = wsm_set_template_frame(priv, &frame); in cw1200_upload_null()
2276 static int cw1200_upload_qosnull(struct cw1200_common *priv) in cw1200_upload_qosnull() argument
2297 static int cw1200_enable_beaconing(struct cw1200_common *priv, in cw1200_enable_beaconing() argument
2304 return wsm_beacon_transmit(priv, &transmit); in cw1200_enable_beaconing()
2307 static int cw1200_start_ap(struct cw1200_common *priv) in cw1200_start_ap() argument
2310 struct ieee80211_bss_conf *conf = &priv->vif->bss_conf; in cw1200_start_ap()
2312 .mode = priv->vif->p2p ? in cw1200_start_ap()
2314 .band = (priv->channel->band == NL80211_BAND_5GHZ) ? in cw1200_start_ap()
2316 .channel_number = priv->channel->hw_value, in cw1200_start_ap()
2323 .basic_rate_set = cw1200_rate_mask_to_wsm(priv, in cw1200_start_ap()
2337 priv->beacon_int = conf->beacon_int; in cw1200_start_ap()
2338 priv->join_dtim_period = conf->dtim_period; in cw1200_start_ap()
2340 memset(&priv->link_id_db, 0, sizeof(priv->link_id_db)); in cw1200_start_ap()
2347 ret = wsm_start(priv, &start); in cw1200_start_ap()
2349 ret = cw1200_upload_keys(priv); in cw1200_start_ap()
2350 if (!ret && priv->vif->p2p) { in cw1200_start_ap()
2352 wsm_set_p2p_ps_modeinfo(priv, &priv->p2p_ps_modeinfo); in cw1200_start_ap()
2355 wsm_set_block_ack_policy(priv, 0, 0); in cw1200_start_ap()
2356 priv->join_status = CW1200_JOIN_STATUS_AP; in cw1200_start_ap()
2357 cw1200_update_filtering(priv); in cw1200_start_ap()
2359 wsm_set_operational_mode(priv, &mode); in cw1200_start_ap()
2363 static int cw1200_update_beaconing(struct cw1200_common *priv) in cw1200_update_beaconing() argument
2365 struct ieee80211_bss_conf *conf = &priv->vif->bss_conf; in cw1200_update_beaconing()
2371 if (priv->mode == NL80211_IFTYPE_AP) { in cw1200_update_beaconing()
2373 if (priv->join_status != CW1200_JOIN_STATUS_AP || in cw1200_update_beaconing()
2374 priv->beacon_int != conf->beacon_int) { in cw1200_update_beaconing()
2376 wsm_lock_tx(priv); in cw1200_update_beaconing()
2377 if (priv->join_status != CW1200_JOIN_STATUS_PASSIVE) in cw1200_update_beaconing()
2378 wsm_reset(priv, &reset); in cw1200_update_beaconing()
2379 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_update_beaconing()
2380 cw1200_start_ap(priv); in cw1200_update_beaconing()
2381 wsm_unlock_tx(priv); in cw1200_update_beaconing()
2384 priv->join_status); in cw1200_update_beaconing()