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, -1, 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()
612 struct cw1200_common *priv = dev->priv; in cw1200_conf_tx() local
617 mutex_lock(&priv->conf_mutex); in cw1200_conf_tx()
620 old_uapsd_flags = le16_to_cpu(priv->uapsd_info.uapsd_flags); in cw1200_conf_tx()
622 WSM_TX_QUEUE_SET(&priv->tx_queue_params, queue, 0, 0, 0); in cw1200_conf_tx()
623 ret = wsm_set_tx_queue_params(priv, in cw1200_conf_tx()
624 &priv->tx_queue_params.params[queue], queue); in cw1200_conf_tx()
630 WSM_EDCA_SET(&priv->edca, queue, params->aifs, in cw1200_conf_tx()
634 ret = wsm_set_edca_params(priv, &priv->edca); in cw1200_conf_tx()
640 if (priv->mode == NL80211_IFTYPE_STATION) { in cw1200_conf_tx()
641 ret = cw1200_set_uapsd_param(priv, &priv->edca); in cw1200_conf_tx()
642 if (!ret && priv->setbssparams_done && in cw1200_conf_tx()
643 (priv->join_status == CW1200_JOIN_STATUS_STA) && in cw1200_conf_tx()
644 (old_uapsd_flags != le16_to_cpu(priv->uapsd_info.uapsd_flags))) in cw1200_conf_tx()
645 ret = cw1200_set_pm(priv, &priv->powersave_mode); in cw1200_conf_tx()
652 mutex_unlock(&priv->conf_mutex); in cw1200_conf_tx()
659 struct cw1200_common *priv = dev->priv; in cw1200_get_stats() local
661 memcpy(stats, &priv->stats, sizeof(*stats)); in cw1200_get_stats()
665 int cw1200_set_pm(struct cw1200_common *priv, const struct wsm_set_pm *arg) in cw1200_set_pm() argument
669 if (priv->uapsd_info.uapsd_flags != 0) in cw1200_set_pm()
672 if (memcmp(&pm, &priv->firmware_ps_mode, in cw1200_set_pm()
674 priv->firmware_ps_mode = pm; in cw1200_set_pm()
675 return wsm_set_pm(priv, &pm); in cw1200_set_pm()
686 struct cw1200_common *priv = dev->priv; in cw1200_set_key() local
689 mutex_lock(&priv->conf_mutex); in cw1200_set_key()
695 int idx = cw1200_alloc_key(priv); in cw1200_set_key()
696 struct wsm_add_key *wsm_key = &priv->keys[idx]; in cw1200_set_key()
713 cw1200_free_key(priv, idx); in cw1200_set_key()
747 (priv->mode == NL80211_IFTYPE_AP) ? in cw1200_set_key()
812 cw1200_free_key(priv, idx); in cw1200_set_key()
816 ret = wsm_add_key(priv, wsm_key); in cw1200_set_key()
820 cw1200_free_key(priv, idx); in cw1200_set_key()
831 cw1200_free_key(priv, wsm_key.index); in cw1200_set_key()
832 ret = wsm_remove_key(priv, &wsm_key); in cw1200_set_key()
838 mutex_unlock(&priv->conf_mutex); in cw1200_set_key()
844 struct cw1200_common *priv = in cw1200_wep_key_work() local
846 u8 queue_id = cw1200_queue_get_queue_id(priv->pending_frame_id); in cw1200_wep_key_work()
847 struct cw1200_queue *queue = &priv->tx_queue[queue_id]; in cw1200_wep_key_work()
849 priv->wep_default_key_id); in cw1200_wep_key_work()
852 priv->wep_default_key_id); in cw1200_wep_key_work()
853 wsm_flush_tx(priv); in cw1200_wep_key_work()
854 wsm_write_mib(priv, WSM_MIB_ID_DOT11_WEP_DEFAULT_KEY_ID, in cw1200_wep_key_work()
856 cw1200_queue_requeue(queue, priv->pending_frame_id); in cw1200_wep_key_work()
857 wsm_unlock_tx(priv); in cw1200_wep_key_work()
864 struct cw1200_common *priv = hw->priv; in cw1200_set_rts_threshold() local
866 if (priv->mode == NL80211_IFTYPE_UNSPECIFIED) in cw1200_set_rts_threshold()
874 if (priv->rts_threshold == value) in cw1200_set_rts_threshold()
878 priv->rts_threshold); in cw1200_set_rts_threshold()
881 ret = wsm_write_mib(priv, WSM_MIB_ID_DOT11_RTS_THRESHOLD, in cw1200_set_rts_threshold()
884 priv->rts_threshold = value; in cw1200_set_rts_threshold()
892 static int __cw1200_flush(struct cw1200_common *priv, bool drop) in __cw1200_flush() argument
902 cw1200_queue_clear(&priv->tx_queue[i]); in __cw1200_flush()
905 priv->tx_queue_stats.wait_link_id_empty, in __cw1200_flush()
907 &priv->tx_queue_stats, -1), in __cw1200_flush()
918 wsm_lock_tx(priv); in __cw1200_flush()
919 if (!cw1200_queue_stats_is_empty(&priv->tx_queue_stats, -1)) { in __cw1200_flush()
921 wsm_unlock_tx(priv); in __cw1200_flush()
932 struct cw1200_common *priv = hw->priv; in cw1200_flush() local
934 switch (priv->mode) { in cw1200_flush()
939 if (!priv->enable_beacon) in cw1200_flush()
944 if (!__cw1200_flush(priv, drop)) in cw1200_flush()
945 wsm_unlock_tx(priv); in cw1200_flush()
953 void cw1200_free_event_queue(struct cw1200_common *priv) in cw1200_free_event_queue() argument
957 spin_lock(&priv->event_queue_lock); in cw1200_free_event_queue()
958 list_splice_init(&priv->event_queue, &list); in cw1200_free_event_queue()
959 spin_unlock(&priv->event_queue_lock); in cw1200_free_event_queue()
966 struct cw1200_common *priv = in cw1200_event_handler() local
971 spin_lock(&priv->event_queue_lock); in cw1200_event_handler()
972 list_splice_init(&priv->event_queue, &list); in cw1200_event_handler()
973 spin_unlock(&priv->event_queue_lock); in cw1200_event_handler()
982 cancel_work_sync(&priv->unjoin_work); in cw1200_event_handler()
983 if (!down_trylock(&priv->scan.lock)) { in cw1200_event_handler()
984 cw1200_cqm_bssloss_sm(priv, 1, 0, 0); in cw1200_event_handler()
985 up(&priv->scan.lock); in cw1200_event_handler()
990 priv->delayed_link_loss = 1; in cw1200_event_handler()
992 queue_delayed_work(priv->workqueue, in cw1200_event_handler()
993 &priv->bss_loss_work, 5*HZ); in cw1200_event_handler()
998 cw1200_cqm_bssloss_sm(priv, 0, 0, 0); in cw1200_event_handler()
999 cancel_work_sync(&priv->unjoin_work); in cw1200_event_handler()
1002 wiphy_info(priv->hw->wiphy, "radar pulse detected\n"); in cw1200_event_handler()
1011 if (priv->cqm_use_rssi) in cw1200_event_handler()
1016 cqm_evt = (rcpi_rssi <= priv->cqm_rssi_thold) ? in cw1200_event_handler()
1020 ieee80211_cqm_rssi_notify(priv->vif, cqm_evt, rcpi_rssi, in cw1200_event_handler()
1037 struct cw1200_common *priv = in cw1200_bss_loss_work() local
1041 wsm_lock_tx(priv); in cw1200_bss_loss_work()
1042 if (queue_work(priv->workqueue, &priv->unjoin_work) <= 0) in cw1200_bss_loss_work()
1043 wsm_unlock_tx(priv); in cw1200_bss_loss_work()
1048 struct cw1200_common *priv = in cw1200_bss_params_work() local
1050 mutex_lock(&priv->conf_mutex); in cw1200_bss_params_work()
1052 priv->bss_params.reset_beacon_loss = 1; in cw1200_bss_params_work()
1053 wsm_set_bss_params(priv, &priv->bss_params); in cw1200_bss_params_work()
1054 priv->bss_params.reset_beacon_loss = 0; in cw1200_bss_params_work()
1056 mutex_unlock(&priv->conf_mutex); in cw1200_bss_params_work()
1066 static int cw1200_parse_sdd_file(struct cw1200_common *priv) in cw1200_parse_sdd_file() argument
1068 const u8 *p = priv->sdd->data; in cw1200_parse_sdd_file()
1071 while (p + 2 <= priv->sdd->data + priv->sdd->size) { in cw1200_parse_sdd_file()
1072 if (p + p[1] + 2 > priv->sdd->data + priv->sdd->size) { in cw1200_parse_sdd_file()
1089 priv->conf_listen_interval = (v >> 7) & 0x1F; in cw1200_parse_sdd_file()
1091 priv->conf_listen_interval); in cw1200_parse_sdd_file()
1096 if (clk != priv->hw_refclk) in cw1200_parse_sdd_file()
1098 clk, priv->hw_refclk); in cw1200_parse_sdd_file()
1107 if (!priv->bt_present) { in cw1200_parse_sdd_file()
1109 priv->conf_listen_interval = 0; in cw1200_parse_sdd_file()
1114 int cw1200_setup_mac(struct cw1200_common *priv) in cw1200_setup_mac() argument
1134 .dot11StationId = &priv->mac_addr[0], in cw1200_setup_mac()
1141 priv->cqm_use_rssi = true; in cw1200_setup_mac()
1143 if (!priv->sdd) { in cw1200_setup_mac()
1144 ret = request_firmware(&priv->sdd, priv->sdd_path, priv->pdev); in cw1200_setup_mac()
1146 pr_err("Can't load sdd file %s.\n", priv->sdd_path); in cw1200_setup_mac()
1149 cw1200_parse_sdd_file(priv); in cw1200_setup_mac()
1152 cfg.dpdData = priv->sdd->data; in cw1200_setup_mac()
1153 cfg.dpdData_size = priv->sdd->size; in cw1200_setup_mac()
1154 ret = wsm_configuration(priv, &cfg); in cw1200_setup_mac()
1159 wsm_set_rcpi_rssi_threshold(priv, &threshold); in cw1200_setup_mac()
1164 static void cw1200_join_complete(struct cw1200_common *priv) in cw1200_join_complete() argument
1166 pr_debug("[STA] Join complete (%d)\n", priv->join_complete_status); in cw1200_join_complete()
1168 priv->join_pending = false; in cw1200_join_complete()
1169 if (priv->join_complete_status) { in cw1200_join_complete()
1170 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_join_complete()
1171 cw1200_update_listening(priv, priv->listening); in cw1200_join_complete()
1172 cw1200_do_unjoin(priv); in cw1200_join_complete()
1173 ieee80211_connection_loss(priv->vif); in cw1200_join_complete()
1175 if (priv->mode == NL80211_IFTYPE_ADHOC) in cw1200_join_complete()
1176 priv->join_status = CW1200_JOIN_STATUS_IBSS; in cw1200_join_complete()
1178 priv->join_status = CW1200_JOIN_STATUS_PRE_STA; in cw1200_join_complete()
1180 wsm_unlock_tx(priv); /* Clearing the lock held before do_join() */ in cw1200_join_complete()
1185 struct cw1200_common *priv = in cw1200_join_complete_work() local
1187 mutex_lock(&priv->conf_mutex); in cw1200_join_complete_work()
1188 cw1200_join_complete(priv); in cw1200_join_complete_work()
1189 mutex_unlock(&priv->conf_mutex); in cw1200_join_complete_work()
1192 void cw1200_join_complete_cb(struct cw1200_common *priv, in cw1200_join_complete_cb() argument
1198 if (cancel_delayed_work(&priv->join_timeout)) { in cw1200_join_complete_cb()
1199 priv->join_complete_status = arg->status; in cw1200_join_complete_cb()
1200 queue_work(priv->workqueue, &priv->join_complete_work); in cw1200_join_complete_cb()
1205 static void cw1200_do_join(struct cw1200_common *priv) in cw1200_do_join() argument
1208 struct ieee80211_bss_conf *conf = &priv->vif->bss_conf; in cw1200_do_join()
1212 .mode = priv->vif->cfg.ibss_joined ? in cw1200_do_join()
1217 .basic_rate_set = cw1200_rate_mask_to_wsm(priv, in cw1200_do_join()
1220 if (delayed_work_pending(&priv->join_timeout)) { in cw1200_do_join()
1222 wsm_unlock_tx(priv); in cw1200_do_join()
1226 if (priv->join_status) in cw1200_do_join()
1227 cw1200_do_unjoin(priv); in cw1200_do_join()
1229 bssid = priv->vif->bss_conf.bssid; in cw1200_do_join()
1231 bss = cfg80211_get_bss(priv->hw->wiphy, priv->channel, bssid, NULL, 0, in cw1200_do_join()
1234 if (!bss && !priv->vif->cfg.ibss_joined) { in cw1200_do_join()
1235 wsm_unlock_tx(priv); in cw1200_do_join()
1239 mutex_lock(&priv->conf_mutex); in cw1200_do_join()
1244 if (atomic_read(&priv->scan.in_progress)) { in cw1200_do_join()
1245 wsm_unlock_tx(priv); in cw1200_do_join()
1249 priv->join_pending = true; in cw1200_do_join()
1256 if (!priv->beacon_int) in cw1200_do_join()
1257 priv->beacon_int = 1; in cw1200_do_join()
1259 join.beacon_interval = priv->beacon_int; in cw1200_do_join()
1262 if (priv->bt_present) { in cw1200_do_join()
1263 if (((priv->conf_listen_interval * 100) % in cw1200_do_join()
1264 priv->beacon_int) == 0) in cw1200_do_join()
1265 priv->listen_interval = in cw1200_do_join()
1266 ((priv->conf_listen_interval * 100) / in cw1200_do_join()
1267 priv->beacon_int); in cw1200_do_join()
1269 priv->listen_interval = in cw1200_do_join()
1270 ((priv->conf_listen_interval * 100) / in cw1200_do_join()
1271 priv->beacon_int + 1); in cw1200_do_join()
1274 if (priv->hw->conf.ps_dtim_period) in cw1200_do_join()
1275 priv->join_dtim_period = priv->hw->conf.ps_dtim_period; in cw1200_do_join()
1276 join.dtim_period = priv->join_dtim_period; in cw1200_do_join()
1278 join.channel_number = priv->channel->hw_value; in cw1200_do_join()
1279 join.band = (priv->channel->band == NL80211_BAND_5GHZ) ? in cw1200_do_join()
1286 join.dtim_period, priv->beacon_int); in cw1200_do_join()
1288 if (!priv->vif->cfg.ibss_joined) { in cw1200_do_join()
1299 if (priv->vif->p2p) { in cw1200_do_join()
1302 cw1200_rate_mask_to_wsm(priv, 0xFF0); in cw1200_do_join()
1306 if (!priv->vif->cfg.ibss_joined) { in cw1200_do_join()
1311 wsm_flush_tx(priv); in cw1200_do_join()
1314 cw1200_pm_stay_awake(&priv->pm_state, in cw1200_do_join()
1317 cw1200_update_listening(priv, false); in cw1200_do_join()
1320 wsm_set_block_ack_policy(priv, priv->ba_tx_tid_mask, in cw1200_do_join()
1321 priv->ba_rx_tid_mask); in cw1200_do_join()
1325 priv->join_status = CW1200_JOIN_STATUS_JOINING; in cw1200_do_join()
1326 queue_delayed_work(priv->workqueue, in cw1200_do_join()
1327 &priv->join_timeout, in cw1200_do_join()
1335 wsm_set_protected_mgmt_policy(priv, &mgmt_policy); in cw1200_do_join()
1338 if (wsm_join(priv, &join)) { in cw1200_do_join()
1340 cancel_delayed_work_sync(&priv->join_timeout); in cw1200_do_join()
1341 cw1200_update_listening(priv, priv->listening); in cw1200_do_join()
1343 if (queue_work(priv->workqueue, &priv->unjoin_work) <= 0) in cw1200_do_join()
1344 wsm_unlock_tx(priv); in cw1200_do_join()
1347 cw1200_join_complete(priv); /* Will clear tx_lock */ in cw1200_do_join()
1350 cw1200_upload_keys(priv); in cw1200_do_join()
1357 priv->disable_beacon_filter = true; in cw1200_do_join()
1359 cw1200_update_filtering(priv); in cw1200_do_join()
1362 mutex_unlock(&priv->conf_mutex); in cw1200_do_join()
1364 cfg80211_put_bss(priv->hw->wiphy, bss); in cw1200_do_join()
1369 struct cw1200_common *priv = in cw1200_join_timeout() local
1372 wsm_lock_tx(priv); in cw1200_join_timeout()
1373 if (queue_work(priv->workqueue, &priv->unjoin_work) <= 0) in cw1200_join_timeout()
1374 wsm_unlock_tx(priv); in cw1200_join_timeout()
1377 static void cw1200_do_unjoin(struct cw1200_common *priv) in cw1200_do_unjoin() argument
1383 cancel_delayed_work_sync(&priv->join_timeout); in cw1200_do_unjoin()
1385 mutex_lock(&priv->conf_mutex); in cw1200_do_unjoin()
1386 priv->join_pending = false; in cw1200_do_unjoin()
1388 if (atomic_read(&priv->scan.in_progress)) { in cw1200_do_unjoin()
1389 if (priv->delayed_unjoin) in cw1200_do_unjoin()
1390 wiphy_dbg(priv->hw->wiphy, "Delayed unjoin is already scheduled.\n"); in cw1200_do_unjoin()
1392 priv->delayed_unjoin = true; in cw1200_do_unjoin()
1396 priv->delayed_link_loss = false; in cw1200_do_unjoin()
1398 if (!priv->join_status) in cw1200_do_unjoin()
1401 if (priv->join_status == CW1200_JOIN_STATUS_AP) in cw1200_do_unjoin()
1404 cancel_work_sync(&priv->update_filtering_work); in cw1200_do_unjoin()
1405 cancel_work_sync(&priv->set_beacon_wakeup_period_work); in cw1200_do_unjoin()
1406 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_do_unjoin()
1409 wsm_flush_tx(priv); in cw1200_do_unjoin()
1410 wsm_keep_alive_period(priv, 0); in cw1200_do_unjoin()
1411 wsm_reset(priv, &reset); in cw1200_do_unjoin()
1412 wsm_set_output_power(priv, priv->output_power * 10); in cw1200_do_unjoin()
1413 priv->join_dtim_period = 0; in cw1200_do_unjoin()
1414 cw1200_setup_mac(priv); in cw1200_do_unjoin()
1415 cw1200_free_event_queue(priv); in cw1200_do_unjoin()
1416 cancel_work_sync(&priv->event_handler); in cw1200_do_unjoin()
1417 cw1200_update_listening(priv, priv->listening); in cw1200_do_unjoin()
1418 cw1200_cqm_bssloss_sm(priv, 0, 0, 0); in cw1200_do_unjoin()
1421 wsm_set_block_ack_policy(priv, 0, 0); in cw1200_do_unjoin()
1423 priv->disable_beacon_filter = false; in cw1200_do_unjoin()
1424 cw1200_update_filtering(priv); in cw1200_do_unjoin()
1425 memset(&priv->association_mode, 0, in cw1200_do_unjoin()
1426 sizeof(priv->association_mode)); in cw1200_do_unjoin()
1427 memset(&priv->bss_params, 0, sizeof(priv->bss_params)); in cw1200_do_unjoin()
1428 priv->setbssparams_done = false; in cw1200_do_unjoin()
1429 memset(&priv->firmware_ps_mode, 0, in cw1200_do_unjoin()
1430 sizeof(priv->firmware_ps_mode)); in cw1200_do_unjoin()
1435 mutex_unlock(&priv->conf_mutex); in cw1200_do_unjoin()
1440 struct cw1200_common *priv = in cw1200_unjoin_work() local
1443 cw1200_do_unjoin(priv); in cw1200_unjoin_work()
1446 ieee80211_connection_loss(priv->vif); in cw1200_unjoin_work()
1448 wsm_unlock_tx(priv); in cw1200_unjoin_work()
1451 int cw1200_enable_listening(struct cw1200_common *priv) in cw1200_enable_listening() argument
1462 if (priv->channel) { in cw1200_enable_listening()
1463 start.band = priv->channel->band == NL80211_BAND_5GHZ ? in cw1200_enable_listening()
1465 start.channel_number = priv->channel->hw_value; in cw1200_enable_listening()
1471 return wsm_start(priv, &start); in cw1200_enable_listening()
1474 int cw1200_disable_listening(struct cw1200_common *priv) in cw1200_disable_listening() argument
1480 ret = wsm_reset(priv, &reset); in cw1200_disable_listening()
1484 void cw1200_update_listening(struct cw1200_common *priv, bool enabled) in cw1200_update_listening() argument
1487 if (priv->join_status == CW1200_JOIN_STATUS_PASSIVE) { in cw1200_update_listening()
1488 if (!cw1200_enable_listening(priv)) in cw1200_update_listening()
1489 priv->join_status = CW1200_JOIN_STATUS_MONITOR; in cw1200_update_listening()
1490 wsm_set_probe_responder(priv, true); in cw1200_update_listening()
1493 if (priv->join_status == CW1200_JOIN_STATUS_MONITOR) { in cw1200_update_listening()
1494 if (!cw1200_disable_listening(priv)) in cw1200_update_listening()
1495 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_update_listening()
1496 wsm_set_probe_responder(priv, false); in cw1200_update_listening()
1501 int cw1200_set_uapsd_param(struct cw1200_common *priv, in cw1200_set_uapsd_param() argument
1528 priv->uapsd_info.uapsd_flags = cpu_to_le16(uapsd_flags); in cw1200_set_uapsd_param()
1529 priv->uapsd_info.min_auto_trigger_interval = 0; in cw1200_set_uapsd_param()
1530 priv->uapsd_info.max_auto_trigger_interval = 0; in cw1200_set_uapsd_param()
1531 priv->uapsd_info.auto_trigger_step = 0; in cw1200_set_uapsd_param()
1533 ret = wsm_set_uapsd_info(priv, &priv->uapsd_info); in cw1200_set_uapsd_param()
1543 struct cw1200_common *priv = hw->priv; in cw1200_sta_add() local
1549 if (priv->mode != NL80211_IFTYPE_AP) in cw1200_sta_add()
1552 sta_priv->link_id = cw1200_find_link_id(priv, sta->addr); in cw1200_sta_add()
1554 wiphy_info(priv->hw->wiphy, in cw1200_sta_add()
1559 entry = &priv->link_id_db[sta_priv->link_id - 1]; in cw1200_sta_add()
1560 spin_lock_bh(&priv->ps_state_lock); in cw1200_sta_add()
1563 priv->sta_asleep_mask |= BIT(sta_priv->link_id); in cw1200_sta_add()
1566 ieee80211_rx_irqsafe(priv->hw, skb); in cw1200_sta_add()
1567 spin_unlock_bh(&priv->ps_state_lock); in cw1200_sta_add()
1574 struct cw1200_common *priv = hw->priv; in cw1200_sta_remove() local
1579 if (priv->mode != NL80211_IFTYPE_AP || !sta_priv->link_id) in cw1200_sta_remove()
1582 entry = &priv->link_id_db[sta_priv->link_id - 1]; in cw1200_sta_remove()
1583 spin_lock_bh(&priv->ps_state_lock); in cw1200_sta_remove()
1586 wsm_lock_tx_async(priv); in cw1200_sta_remove()
1587 if (queue_work(priv->workqueue, &priv->link_id_work) <= 0) in cw1200_sta_remove()
1588 wsm_unlock_tx(priv); in cw1200_sta_remove()
1589 spin_unlock_bh(&priv->ps_state_lock); in cw1200_sta_remove()
1590 flush_workqueue(priv->workqueue); in cw1200_sta_remove()
1599 struct cw1200_common *priv = dev->priv; in __cw1200_sta_notify() local
1608 bit = priv->link_id_map; in __cw1200_sta_notify()
1609 prev = priv->sta_asleep_mask & bit; in __cw1200_sta_notify()
1614 if (priv->buffered_multicasts && in __cw1200_sta_notify()
1615 !priv->sta_asleep_mask) in __cw1200_sta_notify()
1616 queue_work(priv->workqueue, in __cw1200_sta_notify()
1617 &priv->multicast_start_work); in __cw1200_sta_notify()
1618 priv->sta_asleep_mask |= bit; in __cw1200_sta_notify()
1623 priv->sta_asleep_mask &= ~bit; in __cw1200_sta_notify()
1624 priv->pspoll_mask &= ~bit; in __cw1200_sta_notify()
1625 if (priv->tx_multicast && link_id && in __cw1200_sta_notify()
1626 !priv->sta_asleep_mask) in __cw1200_sta_notify()
1627 queue_work(priv->workqueue, in __cw1200_sta_notify()
1628 &priv->multicast_stop_work); in __cw1200_sta_notify()
1629 cw1200_bh_wakeup(priv); in __cw1200_sta_notify()
1640 struct cw1200_common *priv = dev->priv; in cw1200_sta_notify() local
1644 spin_lock_bh(&priv->ps_state_lock); in cw1200_sta_notify()
1646 spin_unlock_bh(&priv->ps_state_lock); in cw1200_sta_notify()
1649 static void cw1200_ps_notify(struct cw1200_common *priv, in cw1200_ps_notify() argument
1657 link_id, priv->sta_asleep_mask); in cw1200_ps_notify()
1659 __cw1200_sta_notify(priv->hw, priv->vif, in cw1200_ps_notify()
1663 static int cw1200_set_tim_impl(struct cw1200_common *priv, bool aid0_bit_set) in cw1200_set_tim_impl() argument
1674 skb = ieee80211_beacon_get_tim(priv->hw, priv->vif, in cw1200_set_tim_impl()
1677 if (!__cw1200_flush(priv, true)) in cw1200_set_tim_impl()
1678 wsm_unlock_tx(priv); in cw1200_set_tim_impl()
1697 wsm_update_ie(priv, &update_ie); in cw1200_set_tim_impl()
1706 struct cw1200_common *priv = in cw1200_set_tim_work() local
1708 (void)cw1200_set_tim_impl(priv, priv->aid0_bit_set); in cw1200_set_tim_work()
1714 struct cw1200_common *priv = dev->priv; in cw1200_set_tim() local
1715 queue_work(priv->workqueue, &priv->set_tim_work); in cw1200_set_tim()
1721 struct cw1200_common *priv = in cw1200_set_cts_work() local
1733 mutex_lock(&priv->conf_mutex); in cw1200_set_cts_work()
1734 erp_info = priv->erp_info; in cw1200_set_cts_work()
1735 mutex_unlock(&priv->conf_mutex); in cw1200_set_cts_work()
1744 wsm_write_mib(priv, WSM_MIB_ID_NON_ERP_PROTECTION, in cw1200_set_cts_work()
1746 wsm_update_ie(priv, &update_ie); in cw1200_set_cts_work()
1751 static int cw1200_set_btcoexinfo(struct cw1200_common *priv) in cw1200_set_btcoexinfo() argument
1756 if (priv->mode == NL80211_IFTYPE_STATION) { in cw1200_set_btcoexinfo()
1758 cw1200_upload_pspoll(priv); in cw1200_set_btcoexinfo()
1759 cw1200_upload_null(priv); in cw1200_set_btcoexinfo()
1760 cw1200_upload_qosnull(priv); in cw1200_set_btcoexinfo()
1767 if (!priv->vif->p2p) { in cw1200_set_btcoexinfo()
1769 if (priv->bss_params.operational_rate_set & ~0xF) { in cw1200_set_btcoexinfo()
1773 priv->bss_params.operational_rate_set & ~0xF)); in cw1200_set_btcoexinfo()
1777 arg.internalTxRate = (__ffs(le32_to_cpu(priv->association_mode.basic_rate_set))); in cw1200_set_btcoexinfo()
1779 arg.nonErpInternalTxRate = (__ffs(le32_to_cpu(priv->association_mode.basic_rate_set))); in cw1200_set_btcoexinfo()
1782 arg.internalTxRate = (__ffs(priv->bss_params.operational_rate_set & ~0xF)); in cw1200_set_btcoexinfo()
1783 arg.nonErpInternalTxRate = (__ffs(priv->bss_params.operational_rate_set & ~0xF)); in cw1200_set_btcoexinfo()
1787 priv->mode, in cw1200_set_btcoexinfo()
1791 ret = wsm_write_mib(priv, WSM_MIB_ID_OVERRIDE_INTERNAL_TX_RATE, in cw1200_set_btcoexinfo()
1802 struct cw1200_common *priv = dev->priv; in cw1200_bss_info_changed() local
1805 mutex_lock(&priv->conf_mutex); in cw1200_bss_info_changed()
1835 wsm_set_arp_ipv4_filter(priv, &filter); in cw1200_bss_info_changed()
1845 priv->beacon_int = info->beacon_int; in cw1200_bss_info_changed()
1846 cw1200_update_beaconing(priv); in cw1200_bss_info_changed()
1847 cw1200_upload_beacon(priv); in cw1200_bss_info_changed()
1853 if (priv->enable_beacon != info->enable_beacon) { in cw1200_bss_info_changed()
1854 cw1200_enable_beaconing(priv, info->enable_beacon); in cw1200_bss_info_changed()
1855 priv->enable_beacon = info->enable_beacon; in cw1200_bss_info_changed()
1863 else if (priv->join_status == CW1200_JOIN_STATUS_AP) in cw1200_bss_info_changed()
1864 cw1200_update_beaconing(priv); in cw1200_bss_info_changed()
1869 wsm_lock_tx(priv); in cw1200_bss_info_changed()
1870 priv->wep_default_key_id = -1; in cw1200_bss_info_changed()
1871 wsm_unlock_tx(priv); in cw1200_bss_info_changed()
1887 if (priv->join_status < CW1200_JOIN_STATUS_PRE_STA) { in cw1200_bss_info_changed()
1889 mutex_unlock(&priv->conf_mutex); in cw1200_bss_info_changed()
1891 } else if (priv->join_status == CW1200_JOIN_STATUS_PRE_STA) { in cw1200_bss_info_changed()
1892 priv->join_status = CW1200_JOIN_STATUS_STA; in cw1200_bss_info_changed()
1903 priv->join_dtim_period = info->dtim_period; in cw1200_bss_info_changed()
1904 priv->beacon_int = info->beacon_int; in cw1200_bss_info_changed()
1911 priv->ht_info.ht_cap = sta->deflink.ht_cap; in cw1200_bss_info_changed()
1912 priv->bss_params.operational_rate_set = in cw1200_bss_info_changed()
1913 cw1200_rate_mask_to_wsm(priv, in cw1200_bss_info_changed()
1914 sta->deflink.supp_rates[priv->channel->band]); in cw1200_bss_info_changed()
1915 priv->ht_info.channel_type = cfg80211_get_chandef_type(&dev->conf.chandef); in cw1200_bss_info_changed()
1916 priv->ht_info.operation_mode = info->ht_operation_mode; in cw1200_bss_info_changed()
1918 memset(&priv->ht_info, 0, in cw1200_bss_info_changed()
1919 sizeof(priv->ht_info)); in cw1200_bss_info_changed()
1920 priv->bss_params.operational_rate_set = -1; in cw1200_bss_info_changed()
1925 if (priv->ht_info.operation_mode & in cw1200_bss_info_changed()
1930 htprot |= cpu_to_le32((priv->ht_info.operation_mode & IEEE80211_HT_OP_MODE_PROTECTION) << 2); in cw1200_bss_info_changed()
1937 wsm_write_mib(priv, WSM_MIB_ID_SET_HT_PROTECTION, in cw1200_bss_info_changed()
1940 priv->association_mode.greenfield = in cw1200_bss_info_changed()
1941 cw1200_ht_greenfield(&priv->ht_info); in cw1200_bss_info_changed()
1942 priv->association_mode.flags = in cw1200_bss_info_changed()
1948 priv->association_mode.preamble = in cw1200_bss_info_changed()
1952 priv->association_mode.basic_rate_set = __cpu_to_le32( in cw1200_bss_info_changed()
1953 cw1200_rate_mask_to_wsm(priv, in cw1200_bss_info_changed()
1955 priv->association_mode.mpdu_start_spacing = in cw1200_bss_info_changed()
1956 cw1200_ht_ampdu_density(&priv->ht_info); in cw1200_bss_info_changed()
1958 cw1200_cqm_bssloss_sm(priv, 0, 0, 0); in cw1200_bss_info_changed()
1959 cancel_work_sync(&priv->unjoin_work); in cw1200_bss_info_changed()
1961 priv->bss_params.beacon_lost_count = priv->cqm_beacon_loss_count; in cw1200_bss_info_changed()
1962 priv->bss_params.aid = vif->cfg.aid; in cw1200_bss_info_changed()
1964 if (priv->join_dtim_period < 1) in cw1200_bss_info_changed()
1965 priv->join_dtim_period = 1; in cw1200_bss_info_changed()
1968 priv->join_dtim_period, priv->beacon_int); in cw1200_bss_info_changed()
1970 priv->association_mode.preamble, in cw1200_bss_info_changed()
1971 priv->association_mode.greenfield, in cw1200_bss_info_changed()
1972 priv->bss_params.aid, in cw1200_bss_info_changed()
1973 priv->bss_params.operational_rate_set, in cw1200_bss_info_changed()
1974 priv->association_mode.basic_rate_set); in cw1200_bss_info_changed()
1975 wsm_set_association_mode(priv, &priv->association_mode); in cw1200_bss_info_changed()
1978 wsm_keep_alive_period(priv, 30 /* sec */); in cw1200_bss_info_changed()
1979 wsm_set_bss_params(priv, &priv->bss_params); in cw1200_bss_info_changed()
1980 priv->setbssparams_done = true; in cw1200_bss_info_changed()
1981 cw1200_set_beacon_wakeup_period_work(&priv->set_beacon_wakeup_period_work); in cw1200_bss_info_changed()
1982 cw1200_set_pm(priv, &priv->powersave_mode); in cw1200_bss_info_changed()
1984 if (priv->vif->p2p) { in cw1200_bss_info_changed()
1986 wsm_set_p2p_ps_modeinfo(priv, in cw1200_bss_info_changed()
1987 &priv->p2p_ps_modeinfo); in cw1200_bss_info_changed()
1989 if (priv->bt_present) in cw1200_bss_info_changed()
1990 cw1200_set_btcoexinfo(priv); in cw1200_bss_info_changed()
1992 memset(&priv->association_mode, 0, in cw1200_bss_info_changed()
1993 sizeof(priv->association_mode)); in cw1200_bss_info_changed()
1994 memset(&priv->bss_params, 0, sizeof(priv->bss_params)); in cw1200_bss_info_changed()
2002 u32 prev_erp_info = priv->erp_info; in cw1200_bss_info_changed()
2004 priv->erp_info |= WLAN_ERP_USE_PROTECTION; in cw1200_bss_info_changed()
2006 priv->erp_info &= ~WLAN_ERP_USE_PROTECTION; in cw1200_bss_info_changed()
2009 priv->erp_info |= WLAN_ERP_BARKER_PREAMBLE; in cw1200_bss_info_changed()
2011 priv->erp_info &= ~WLAN_ERP_BARKER_PREAMBLE; in cw1200_bss_info_changed()
2013 pr_debug("[STA] ERP Protection: %x\n", priv->erp_info); in cw1200_bss_info_changed()
2015 if (prev_erp_info != priv->erp_info) in cw1200_bss_info_changed()
2016 queue_work(priv->workqueue, &priv->set_cts_work); in cw1200_bss_info_changed()
2025 wsm_write_mib(priv, WSM_MIB_ID_DOT11_SLOT_TIME, in cw1200_bss_info_changed()
2035 priv->cqm_rssi_thold = info->cqm_rssi_thold; in cw1200_bss_info_changed()
2036 priv->cqm_rssi_hyst = info->cqm_rssi_hyst; in cw1200_bss_info_changed()
2049 if (priv->cqm_use_rssi) { in cw1200_bss_info_changed()
2068 if (priv->cqm_use_rssi) in cw1200_bss_info_changed()
2071 wsm_set_rcpi_rssi_threshold(priv, &threshold); in cw1200_bss_info_changed()
2073 mutex_unlock(&priv->conf_mutex); in cw1200_bss_info_changed()
2076 wsm_lock_tx(priv); in cw1200_bss_info_changed()
2077 cw1200_do_join(priv); /* Will unlock it for us */ in cw1200_bss_info_changed()
2083 struct cw1200_common *priv = in cw1200_multicast_start_work() local
2085 long tmo = priv->join_dtim_period * in cw1200_multicast_start_work()
2086 (priv->beacon_int + 20) * HZ / 1024; in cw1200_multicast_start_work()
2088 cancel_work_sync(&priv->multicast_stop_work); in cw1200_multicast_start_work()
2090 if (!priv->aid0_bit_set) { in cw1200_multicast_start_work()
2091 wsm_lock_tx(priv); in cw1200_multicast_start_work()
2092 cw1200_set_tim_impl(priv, true); in cw1200_multicast_start_work()
2093 priv->aid0_bit_set = true; in cw1200_multicast_start_work()
2094 mod_timer(&priv->mcast_timeout, jiffies + tmo); in cw1200_multicast_start_work()
2095 wsm_unlock_tx(priv); in cw1200_multicast_start_work()
2101 struct cw1200_common *priv = in cw1200_multicast_stop_work() local
2104 if (priv->aid0_bit_set) { in cw1200_multicast_stop_work()
2105 del_timer_sync(&priv->mcast_timeout); in cw1200_multicast_stop_work()
2106 wsm_lock_tx(priv); in cw1200_multicast_stop_work()
2107 priv->aid0_bit_set = false; in cw1200_multicast_stop_work()
2108 cw1200_set_tim_impl(priv, false); in cw1200_multicast_stop_work()
2109 wsm_unlock_tx(priv); in cw1200_multicast_stop_work()
2115 struct cw1200_common *priv = from_timer(priv, t, mcast_timeout); in cw1200_mcast_timeout() local
2117 wiphy_warn(priv->hw->wiphy, in cw1200_mcast_timeout()
2119 spin_lock_bh(&priv->ps_state_lock); in cw1200_mcast_timeout()
2120 priv->tx_multicast = priv->aid0_bit_set && in cw1200_mcast_timeout()
2121 priv->buffered_multicasts; in cw1200_mcast_timeout()
2122 if (priv->tx_multicast) in cw1200_mcast_timeout()
2123 cw1200_bh_wakeup(priv); in cw1200_mcast_timeout()
2124 spin_unlock_bh(&priv->ps_state_lock); in cw1200_mcast_timeout()
2143 void cw1200_suspend_resume(struct cw1200_common *priv, in cw1200_suspend_resume() argument
2152 spin_lock_bh(&priv->ps_state_lock); in cw1200_suspend_resume()
2154 priv->tx_multicast = false; in cw1200_suspend_resume()
2161 cw1200_pm_stay_awake(&priv->pm_state, in cw1200_suspend_resume()
2162 priv->join_dtim_period * in cw1200_suspend_resume()
2163 (priv->beacon_int + 20) * HZ / 1024); in cw1200_suspend_resume()
2164 priv->tx_multicast = (priv->aid0_bit_set && in cw1200_suspend_resume()
2165 priv->buffered_multicasts); in cw1200_suspend_resume()
2166 if (priv->tx_multicast) { in cw1200_suspend_resume()
2168 cw1200_bh_wakeup(priv); in cw1200_suspend_resume()
2171 spin_unlock_bh(&priv->ps_state_lock); in cw1200_suspend_resume()
2173 del_timer_sync(&priv->mcast_timeout); in cw1200_suspend_resume()
2175 spin_lock_bh(&priv->ps_state_lock); in cw1200_suspend_resume()
2176 cw1200_ps_notify(priv, arg->link_id, arg->stop); in cw1200_suspend_resume()
2177 spin_unlock_bh(&priv->ps_state_lock); in cw1200_suspend_resume()
2179 cw1200_bh_wakeup(priv); in cw1200_suspend_resume()
2187 static int cw1200_upload_beacon(struct cw1200_common *priv) in cw1200_upload_beacon() argument
2198 if (priv->mode == NL80211_IFTYPE_STATION || in cw1200_upload_beacon()
2199 priv->mode == NL80211_IFTYPE_MONITOR || in cw1200_upload_beacon()
2200 priv->mode == NL80211_IFTYPE_UNSPECIFIED) in cw1200_upload_beacon()
2203 if (priv->vif->p2p) in cw1200_upload_beacon()
2206 frame.skb = ieee80211_beacon_get_tim(priv->hw, priv->vif, in cw1200_upload_beacon()
2211 ret = wsm_set_template_frame(priv, &frame); in cw1200_upload_beacon()
2225 if (priv->vif->p2p) { in cw1200_upload_beacon()
2226 ret = wsm_set_probe_responder(priv, true); in cw1200_upload_beacon()
2228 ret = wsm_set_template_frame(priv, &frame); in cw1200_upload_beacon()
2229 wsm_set_probe_responder(priv, false); in cw1200_upload_beacon()
2238 static int cw1200_upload_pspoll(struct cw1200_common *priv) in cw1200_upload_pspoll() argument
2247 frame.skb = ieee80211_pspoll_get(priv->hw, priv->vif); in cw1200_upload_pspoll()
2251 ret = wsm_set_template_frame(priv, &frame); in cw1200_upload_pspoll()
2258 static int cw1200_upload_null(struct cw1200_common *priv) in cw1200_upload_null() argument
2266 frame.skb = ieee80211_nullfunc_get(priv->hw, priv->vif,-1, false); in cw1200_upload_null()
2270 ret = wsm_set_template_frame(priv, &frame); in cw1200_upload_null()
2277 static int cw1200_upload_qosnull(struct cw1200_common *priv) in cw1200_upload_qosnull() argument
2298 static int cw1200_enable_beaconing(struct cw1200_common *priv, in cw1200_enable_beaconing() argument
2305 return wsm_beacon_transmit(priv, &transmit); in cw1200_enable_beaconing()
2308 static int cw1200_start_ap(struct cw1200_common *priv) in cw1200_start_ap() argument
2311 struct ieee80211_bss_conf *conf = &priv->vif->bss_conf; in cw1200_start_ap()
2313 .mode = priv->vif->p2p ? in cw1200_start_ap()
2315 .band = (priv->channel->band == NL80211_BAND_5GHZ) ? in cw1200_start_ap()
2317 .channel_number = priv->channel->hw_value, in cw1200_start_ap()
2324 .basic_rate_set = cw1200_rate_mask_to_wsm(priv, in cw1200_start_ap()
2334 start.ssid_len = priv->vif->cfg.ssid_len; in cw1200_start_ap()
2335 memcpy(start.ssid, priv->vif->cfg.ssid, start.ssid_len); in cw1200_start_ap()
2338 priv->beacon_int = conf->beacon_int; in cw1200_start_ap()
2339 priv->join_dtim_period = conf->dtim_period; in cw1200_start_ap()
2341 memset(&priv->link_id_db, 0, sizeof(priv->link_id_db)); in cw1200_start_ap()
2348 ret = wsm_start(priv, &start); in cw1200_start_ap()
2350 ret = cw1200_upload_keys(priv); in cw1200_start_ap()
2351 if (!ret && priv->vif->p2p) { in cw1200_start_ap()
2353 wsm_set_p2p_ps_modeinfo(priv, &priv->p2p_ps_modeinfo); in cw1200_start_ap()
2356 wsm_set_block_ack_policy(priv, 0, 0); in cw1200_start_ap()
2357 priv->join_status = CW1200_JOIN_STATUS_AP; in cw1200_start_ap()
2358 cw1200_update_filtering(priv); in cw1200_start_ap()
2360 wsm_set_operational_mode(priv, &mode); in cw1200_start_ap()
2364 static int cw1200_update_beaconing(struct cw1200_common *priv) in cw1200_update_beaconing() argument
2366 struct ieee80211_bss_conf *conf = &priv->vif->bss_conf; in cw1200_update_beaconing()
2372 if (priv->mode == NL80211_IFTYPE_AP) { in cw1200_update_beaconing()
2374 if (priv->join_status != CW1200_JOIN_STATUS_AP || in cw1200_update_beaconing()
2375 priv->beacon_int != conf->beacon_int) { in cw1200_update_beaconing()
2377 wsm_lock_tx(priv); in cw1200_update_beaconing()
2378 if (priv->join_status != CW1200_JOIN_STATUS_PASSIVE) in cw1200_update_beaconing()
2379 wsm_reset(priv, &reset); in cw1200_update_beaconing()
2380 priv->join_status = CW1200_JOIN_STATUS_PASSIVE; in cw1200_update_beaconing()
2381 cw1200_start_ap(priv); in cw1200_update_beaconing()
2382 wsm_unlock_tx(priv); in cw1200_update_beaconing()
2385 priv->join_status); in cw1200_update_beaconing()