Lines Matching defs:wlvif
44 static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif);
46 static int wl12xx_set_authorized(struct wl1271 *wl, struct wl12xx_vif *wlvif)
50 if (WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS))
53 if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
56 if (test_and_set_bit(WLVIF_FLAG_STA_STATE_SENT, &wlvif->flags))
59 ret = wl12xx_cmd_set_peer_state(wl, wlvif, wlvif->sta.hlid);
80 static int wl1271_set_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif,
86 ret = wl1271_acx_ps_rx_streaming(wl, wlvif, enable);
91 set_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags);
93 clear_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags);
102 int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif)
108 if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags))
113 test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) &&
116 ret = wl1271_set_rx_streaming(wl, wlvif, true);
118 ret = wl1271_set_rx_streaming(wl, wlvif, false);
120 timer_delete_sync(&wlvif->rx_streaming_timer);
129 struct wl12xx_vif *wlvif = container_of(work, struct wl12xx_vif,
131 struct wl1271 *wl = wlvif->wl;
135 if (test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags) ||
136 !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) ||
148 ret = wl1271_set_rx_streaming(wl, wlvif, true);
153 mod_timer(&wlvif->rx_streaming_timer,
166 struct wl12xx_vif *wlvif = container_of(work, struct wl12xx_vif,
168 struct wl1271 *wl = wlvif->wl;
172 if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags))
179 ret = wl1271_set_rx_streaming(wl, wlvif, false);
192 struct wl12xx_vif *wlvif = timer_container_of(wlvif, t,
194 struct wl1271 *wl = wlvif->wl;
195 ieee80211_queue_work(wl->hw, &wlvif->rx_streaming_disable_work);
213 struct wl12xx_vif *wlvif = container_of(work, struct wl12xx_vif,
215 struct wl1271 *wl = wlvif->wl;
216 struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
228 ret = wl1271_acx_set_ht_capabilities(wl, &wlvif->rc_ht_cap,
229 true, wlvif->sta.hlid);
233 wlcore_hw_sta_rc_update(wl, wlvif);
331 struct wl12xx_vif *wlvif,
343 wl12xx_ps_link_end(wl, wlvif, hlid);
356 wl12xx_ps_link_start(wl, wlvif, hlid, true);
360 struct wl12xx_vif *wlvif,
376 for_each_set_bit(hlid, wlvif->ap.sta_hlid_map, wl->num_links)
377 wl12xx_irq_ps_regulate_link(wl, wlvif, hlid,
385 struct wl12xx_vif *wlvif;
418 wl12xx_for_each_wlvif_sta(wl, wlvif) {
419 if (wlvif->sta.hlid != WL12XX_INVALID_LINK_ID &&
420 test_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags)) {
421 wlvifsta = wlvif;
428 wl12xx_for_each_wlvif(wl, wlvif) {
429 if (wlvif->bss_type == BSS_TYPE_AP_BSS &&
430 wlvif->inconn_count == 0 &&
431 test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) {
432 wlvifap = wlvif;
554 wl12xx_for_each_wlvif_ap(wl, wlvif) {
555 wl12xx_irq_update_links_status(wl, wlvif, status);
930 static void wlcore_save_freed_pkts(struct wl1271 *wl, struct wl12xx_vif *wlvif,
943 if (wlvif->encryption_type == KEY_GEM)
951 struct wl12xx_vif *wlvif,
955 struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
964 wlcore_save_freed_pkts(wl, wlvif, hlid, sta);
1001 struct wl12xx_vif *wlvif;
1036 wlvif = list_first_entry(&wl->wlvif_list,
1038 vif = wl12xx_wlvif_to_vif(wlvif);
1040 if (wlvif->bss_type == BSS_TYPE_STA_BSS &&
1041 test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) {
1042 wlcore_save_freed_pkts_addr(wl, wlvif, wlvif->sta.hlid,
1286 struct wl12xx_vif *wlvif = NULL;
1297 wlvif = wl12xx_vif_to_data(vif);
1301 hlid = wl12xx_tx_get_hlid(wl, wlvif, skb, control->sta);
1311 (!test_bit(hlid, wlvif->links_map)) ||
1312 (wlcore_is_queue_stopped_locked(wl, wlvif, q) &&
1313 !wlcore_is_queue_stopped_by_reason_locked(wl, wlvif, q,
1325 wlvif->tx_queue_count[q]++;
1331 if (wlvif->tx_queue_count[q] >= WL1271_TX_QUEUE_HIGH_WATERMARK &&
1332 !wlcore_is_queue_stopped_by_reason_locked(wl, wlvif, q,
1335 wlcore_stop_queue_locked(wl, wlvif, q,
1694 struct wl12xx_vif *wlvif,
1699 if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
1712 ret = wl1271_acx_wake_up_conditions(wl, wlvif,
1724 struct wl12xx_vif *wlvif,
1729 if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags))
1732 ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true);
1746 struct wl12xx_vif *wlvif,
1749 if (wlvif->bss_type == BSS_TYPE_STA_BSS)
1750 return wl1271_configure_suspend_sta(wl, wlvif, wow);
1751 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
1752 return wl1271_configure_suspend_ap(wl, wlvif, wow);
1756 static void wl1271_configure_resume(struct wl1271 *wl, struct wl12xx_vif *wlvif)
1759 bool is_ap = wlvif->bss_type == BSS_TYPE_AP_BSS;
1760 bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS;
1765 if ((is_sta && !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) ||
1766 (is_ap && !test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)))
1778 ret = wl1271_acx_wake_up_conditions(wl, wlvif,
1787 ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false);
1795 struct wl12xx_vif *wlvif;
1819 wl12xx_for_each_wlvif(wl, wlvif) {
1820 if (wlcore_is_p2p_mgmt(wlvif))
1823 ret = wl1271_configure_suspend(wl, wlvif, wow);
1874 struct wl12xx_vif *wlvif;
1929 wl12xx_for_each_wlvif(wl, wlvif) {
1930 if (wlcore_is_p2p_mgmt(wlvif))
1933 wl1271_configure_resume(wl, wlvif);
2107 struct wl12xx_vif *wlvif;
2111 wlvif = container_of(dwork, struct wl12xx_vif, channel_switch_work);
2112 wl = wlvif->wl;
2114 wl1271_info("channel switch failed (role_id: %d).", wlvif->role_id);
2122 if (!test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags))
2125 vif = wl12xx_wlvif_to_vif(wlvif);
2132 wl12xx_cmd_stop_channel_switch(wl, wlvif);
2145 struct wl12xx_vif *wlvif;
2148 wlvif = container_of(dwork, struct wl12xx_vif, connection_loss_work);
2149 wl = wlvif->wl;
2151 wl1271_info("Connection loss work (role_id: %d).", wlvif->role_id);
2159 if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
2162 vif = wl12xx_wlvif_to_vif(wlvif);
2172 struct wl12xx_vif *wlvif;
2177 wlvif = container_of(dwork, struct wl12xx_vif,
2179 wl = wlvif->wl;
2194 if (!time_after(time_spare, wlvif->pending_auth_reply_time))
2202 wlcore_update_inconn_sta(wl, wlvif, NULL, false);
2252 static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif)
2254 struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
2256 switch (wlvif->bss_type) {
2258 if (wlvif->p2p)
2266 if (wlvif->p2p)
2275 wl1271_error("invalid bss_type: %d", wlvif->bss_type);
2282 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2286 memset(wlvif, 0, offsetof(struct wl12xx_vif, persistent));
2290 wlvif->p2p = 1;
2294 wlvif->bss_type = BSS_TYPE_STA_BSS;
2297 wlvif->bss_type = BSS_TYPE_IBSS;
2300 wlvif->p2p = 1;
2304 wlvif->bss_type = BSS_TYPE_AP_BSS;
2307 wlvif->bss_type = MAX_BSS_TYPE;
2311 wlvif->role_id = WL12XX_INVALID_ROLE_ID;
2312 wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID;
2313 wlvif->dev_hlid = WL12XX_INVALID_LINK_ID;
2315 if (wlvif->bss_type == BSS_TYPE_STA_BSS ||
2316 wlvif->bss_type == BSS_TYPE_IBSS) {
2318 wlvif->sta.hlid = WL12XX_INVALID_LINK_ID;
2319 wl12xx_allocate_rate_policy(wl, &wlvif->sta.basic_rate_idx);
2320 wl12xx_allocate_rate_policy(wl, &wlvif->sta.ap_rate_idx);
2321 wl12xx_allocate_rate_policy(wl, &wlvif->sta.p2p_rate_idx);
2322 wlcore_allocate_klv_template(wl, &wlvif->sta.klv_template_id);
2323 wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC;
2324 wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC;
2325 wlvif->rate_set = CONF_TX_RATE_MASK_BASIC;
2328 wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID;
2329 wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID;
2330 wl12xx_allocate_rate_policy(wl, &wlvif->ap.mgmt_rate_idx);
2331 wl12xx_allocate_rate_policy(wl, &wlvif->ap.bcast_rate_idx);
2334 &wlvif->ap.ucast_rate_idx[i]);
2335 wlvif->basic_rate_set = CONF_TX_ENABLED_RATES;
2338 * wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
2341 wlvif->basic_rate = CONF_TX_ENABLED_RATES;
2343 wlvif->rate_set = CONF_TX_ENABLED_RATES;
2346 wlvif->bitrate_masks[NL80211_BAND_2GHZ] = wl->conf.tx.basic_rate;
2347 wlvif->bitrate_masks[NL80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5;
2348 wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT;
2354 wlvif->band = wl->band;
2355 wlvif->channel = wl->channel;
2356 wlvif->power_level = wl->power_level;
2357 wlvif->channel_type = wl->channel_type;
2359 INIT_WORK(&wlvif->rx_streaming_enable_work,
2361 INIT_WORK(&wlvif->rx_streaming_disable_work,
2363 INIT_WORK(&wlvif->rc_update_work, wlcore_rc_update_work);
2364 INIT_DELAYED_WORK(&wlvif->channel_switch_work,
2366 INIT_DELAYED_WORK(&wlvif->connection_loss_work,
2368 INIT_DELAYED_WORK(&wlvif->pending_auth_complete_work,
2370 INIT_LIST_HEAD(&wlvif->list);
2372 timer_setup(&wlvif->rx_streaming_timer, wl1271_rx_streaming_timer, 0);
2445 static bool wl12xx_dev_role_started(struct wl12xx_vif *wlvif)
2447 return wlvif->dev_hlid != WL12XX_INVALID_LINK_ID;
2495 struct wl12xx_vif *wlvif;
2497 wl12xx_for_each_wlvif_sta(wl, wlvif) {
2498 wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE);
2528 struct wl12xx_vif *wlvif)
2530 struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
2548 wlvif->hw_queue_base = vif->hw_queue[0];
2551 wlvif->hw_queue_base);
2562 wlvif->hw_queue_base = q_base * NUM_TX_QUEUES;
2564 wlvif->hw_queue_base);
2567 wl->queue_stop_reasons[wlvif->hw_queue_base + i] = 0;
2569 vif->hw_queue[i] = wlvif->hw_queue_base + i;
2574 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
2576 wlvif->hw_queue_base / NUM_TX_QUEUES;
2587 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2614 test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) {
2624 wlvif->wl = wl;
2625 role_type = wl12xx_get_role_type(wl, wlvif);
2631 ret = wlcore_allocate_hw_queue_base(wl, wlvif);
2667 if (!wlcore_is_p2p_mgmt(wlvif)) {
2669 role_type, &wlvif->role_id);
2679 &wlvif->dev_role_id);
2684 ret = wl1271_sta_hw_init(wl, wlvif);
2689 list_add(&wlvif->list, &wl->wlvif_list);
2690 set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags);
2692 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
2709 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2711 bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
2715 if (!test_and_clear_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))
2725 wl->scan_wlvif == wlvif) {
2743 if (wl->sched_vif == wlvif)
2757 if (wlvif->bss_type == BSS_TYPE_STA_BSS ||
2758 wlvif->bss_type == BSS_TYPE_IBSS) {
2759 if (wl12xx_dev_role_started(wlvif))
2760 wl12xx_stop_dev(wl, wlvif);
2763 if (!wlcore_is_p2p_mgmt(wlvif)) {
2764 ret = wl12xx_cmd_role_disable(wl, &wlvif->role_id);
2770 ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id);
2781 wl12xx_tx_reset_wlvif(wl, wlvif);
2784 wlvif->dev_hlid = WL12XX_INVALID_LINK_ID;
2786 if (wlvif->bss_type == BSS_TYPE_STA_BSS ||
2787 wlvif->bss_type == BSS_TYPE_IBSS) {
2788 wlvif->sta.hlid = WL12XX_INVALID_LINK_ID;
2789 wl12xx_free_rate_policy(wl, &wlvif->sta.basic_rate_idx);
2790 wl12xx_free_rate_policy(wl, &wlvif->sta.ap_rate_idx);
2791 wl12xx_free_rate_policy(wl, &wlvif->sta.p2p_rate_idx);
2792 wlcore_free_klv_template(wl, &wlvif->sta.klv_template_id);
2794 wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID;
2795 wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID;
2796 wl12xx_free_rate_policy(wl, &wlvif->ap.mgmt_rate_idx);
2797 wl12xx_free_rate_policy(wl, &wlvif->ap.bcast_rate_idx);
2800 &wlvif->ap.ucast_rate_idx[i]);
2801 wl1271_free_ap_keys(wl, wlvif);
2804 dev_kfree_skb(wlvif->probereq);
2805 wlvif->probereq = NULL;
2806 if (wl->last_wlvif == wlvif)
2808 list_del(&wlvif->list);
2809 memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map));
2810 wlvif->role_id = WL12XX_INVALID_ROLE_ID;
2811 wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID;
2845 timer_delete_sync(&wlvif->rx_streaming_timer);
2846 cancel_work_sync(&wlvif->rx_streaming_enable_work);
2847 cancel_work_sync(&wlvif->rx_streaming_disable_work);
2848 cancel_work_sync(&wlvif->rc_update_work);
2849 cancel_delayed_work_sync(&wlvif->connection_loss_work);
2850 cancel_delayed_work_sync(&wlvif->channel_switch_work);
2851 cancel_delayed_work_sync(&wlvif->pending_auth_complete_work);
2860 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2868 !test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))
2876 if (iter != wlvif)
2882 WARN_ON(iter != wlvif);
2910 static int wlcore_join(struct wl1271 *wl, struct wl12xx_vif *wlvif)
2913 bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS);
2924 if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
2928 wlvif->encryption_type = KEY_NONE;
2931 ret = wl12xx_cmd_role_start_ibss(wl, wlvif);
2933 ret = wl12xx_cmd_role_start_sta(wl, wlvif);
2938 static int wl1271_ssid_set(struct wl12xx_vif *wlvif, struct sk_buff *skb,
2956 wlvif->ssid_len = ssid_len;
2957 memcpy(wlvif->ssid, ptr+2, ssid_len);
2961 static int wlcore_set_ssid(struct wl1271 *wl, struct wl12xx_vif *wlvif)
2963 struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
2968 if (wlvif->bss_type != BSS_TYPE_STA_BSS)
2977 wl1271_ssid_set(wlvif, skb, ieoffset);
2983 static int wlcore_set_assoc(struct wl1271 *wl, struct wl12xx_vif *wlvif,
2992 wlvif->aid = vif->cfg.aid;
2993 wlvif->channel_type = cfg80211_get_chandef_type(&bss_conf->chanreq.oper);
2994 wlvif->beacon_int = bss_conf->beacon_int;
2995 wlvif->wmm_enabled = bss_conf->qos;
2997 set_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags);
3005 ret = wl1271_cmd_build_ps_poll(wl, wlvif, wlvif->aid);
3012 dev_kfree_skb(wlvif->probereq);
3013 wlvif->probereq = wl1271_cmd_build_ap_probe_req(wl,
3014 wlvif,
3018 wl1271_ssid_set(wlvif, wlvif->probereq, ieoffset);
3021 ret = wl1271_acx_conn_monit_params(wl, wlvif, true);
3031 ret = wl1271_acx_keep_alive_mode(wl, wlvif, true);
3035 ret = wl1271_acx_aid(wl, wlvif, wlvif->aid);
3039 ret = wl12xx_cmd_build_klv_null_data(wl, wlvif);
3043 ret = wl1271_acx_keep_alive_config(wl, wlvif,
3044 wlvif->sta.klv_template_id,
3053 ret = wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE);
3058 wlvif->rate_set =
3061 wlvif->band);
3062 ret = wl1271_acx_sta_rate_policies(wl, wlvif);
3070 static int wlcore_unset_assoc(struct wl1271 *wl, struct wl12xx_vif *wlvif)
3073 bool sta = wlvif->bss_type == BSS_TYPE_STA_BSS;
3077 !test_and_clear_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
3082 test_and_clear_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags))
3087 wlvif->aid = 0;
3090 dev_kfree_skb(wlvif->probereq);
3091 wlvif->probereq = NULL;
3094 ret = wl1271_acx_conn_monit_params(wl, wlvif, false);
3099 ret = wl1271_acx_keep_alive_mode(wl, wlvif, false);
3104 ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false);
3109 if (test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags)) {
3110 struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
3112 wl12xx_cmd_stop_channel_switch(wl, wlvif);
3114 cancel_delayed_work(&wlvif->channel_switch_work);
3118 wl1271_acx_keep_alive_config(wl, wlvif,
3119 wlvif->sta.klv_template_id,
3125 static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif)
3127 wlvif->basic_rate_set = wlvif->bitrate_masks[wlvif->band];
3128 wlvif->rate_set = wlvif->basic_rate_set;
3131 static void wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif,
3134 bool cur_idle = !test_bit(WLVIF_FLAG_ACTIVE, &wlvif->flags);
3140 clear_bit(WLVIF_FLAG_ACTIVE, &wlvif->flags);
3143 if (wl->sched_vif == wlvif)
3144 wl->ops->sched_scan_stop(wl, wlvif);
3146 set_bit(WLVIF_FLAG_ACTIVE, &wlvif->flags);
3150 static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif,
3155 if (wlcore_is_p2p_mgmt(wlvif))
3158 if (conf->power_level != wlvif->power_level) {
3159 ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level);
3163 wlvif->power_level = conf->power_level;
3172 struct wl12xx_vif *wlvif;
3196 wl12xx_for_each_wlvif(wl, wlvif) {
3197 ret = wl12xx_config_vif(wl, wlvif, conf, changed);
3258 struct wl12xx_vif *wlvif;
3277 wl12xx_for_each_wlvif(wl, wlvif) {
3278 if (wlcore_is_p2p_mgmt(wlvif))
3281 if (wlvif->bss_type != BSS_TYPE_AP_BSS) {
3283 ret = wl1271_acx_group_address_tbl(wl, wlvif,
3287 ret = wl1271_acx_group_address_tbl(wl, wlvif,
3300 if (wlvif->bss_type == BSS_TYPE_AP_BSS) {
3302 ret = wl1271_acx_group_address_tbl(wl, wlvif,
3326 static int wl1271_record_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif,
3344 if (wlvif->ap.recorded_keys[i] == NULL)
3347 if (wlvif->ap.recorded_keys[i]->id == id) {
3369 wlvif->ap.recorded_keys[i] = ap_key;
3373 static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif)
3378 kfree(wlvif->ap.recorded_keys[i]);
3379 wlvif->ap.recorded_keys[i] = NULL;
3383 static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif)
3391 if (wlvif->ap.recorded_keys[i] == NULL)
3394 key = wlvif->ap.recorded_keys[i];
3397 hlid = wlvif->ap.bcast_hlid;
3399 ret = wl1271_cmd_set_ap_key(wl, wlvif, KEY_ADD_OR_REPLACE,
3412 ret = wl12xx_cmd_set_default_wep_key(wl, wlvif->default_key,
3413 wlvif->ap.bcast_hlid);
3419 wl1271_free_ap_keys(wl, wlvif);
3423 static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif,
3430 bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
3440 hlid = wlvif->ap.bcast_hlid;
3443 if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) {
3451 ret = wl1271_record_ap_key(wl, wlvif, id,
3456 ret = wl1271_cmd_set_ap_key(wl, wlvif, action,
3486 wlvif->sta.hlid == WL12XX_INVALID_LINK_ID)
3489 ret = wl1271_cmd_set_sta_key(wl, wlvif, action,
3551 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3567 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
3572 hlid = wlvif->ap.bcast_hlid;
3575 hlid = wlvif->sta.hlid;
3611 ret = wl1271_set_key(wl, wlvif, KEY_ADD_OR_REPLACE,
3621 if (wlvif->bss_type == BSS_TYPE_AP_BSS)
3622 wlvif->encryption_type = key_type;
3628 if (wlvif->bss_type == BSS_TYPE_STA_BSS &&
3630 wlvif->encryption_type != key_type) {
3631 wlvif->encryption_type = key_type;
3632 ret = wl1271_cmd_build_arp_rsp(wl, wlvif);
3641 ret = wl1271_set_key(wl, wlvif, KEY_REMOVE,
3665 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3686 wlvif->default_key = key_idx;
3689 if (wlvif->encryption_type == KEY_WEP) {
3692 wlvif->sta.hlid);
3787 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3808 ret = wl->ops->scan_stop(wl, wlvif);
3840 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3856 ret = wl->ops->sched_scan_start(wl, wlvif, req, ies);
3860 wl->sched_vif = wlvif;
3874 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3888 wl->ops->sched_scan_stop(wl, wlvif);
3932 struct wl12xx_vif *wlvif;
3946 wl12xx_for_each_wlvif(wl, wlvif) {
3947 ret = wl1271_acx_rts_threshold(wl, wlvif, value);
3994 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4002 ret = wl1271_cmd_template_set(wl, wlvif->role_id,
4013 set_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, &wlvif->flags);
4025 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4031 if (wlvif->ssid_len > 0)
4032 return wl1271_cmd_template_set(wl, wlvif->role_id,
4069 return wl1271_cmd_template_set(wl, wlvif->role_id,
4081 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4086 ret = wl1271_acx_slot(wl, wlvif, SLOT_TIME_SHORT);
4088 ret = wl1271_acx_slot(wl, wlvif, SLOT_TIME_LONG);
4097 wl1271_acx_set_preamble(wl, wlvif, ACX_PREAMBLE_SHORT);
4099 wl1271_acx_set_preamble(wl, wlvif, ACX_PREAMBLE_LONG);
4104 ret = wl1271_acx_cts_protect(wl, wlvif,
4107 ret = wl1271_acx_cts_protect(wl, wlvif,
4123 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4138 ret = wl1271_ssid_set(wlvif, beacon, ieoffset);
4143 min_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
4146 ret = wl1271_cmd_template_set(wl, wlvif->role_id, tmpl_id,
4155 wlvif->wmm_enabled =
4165 if (test_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, &wlvif->flags))
4191 ret = wl1271_cmd_template_set(wl, wlvif->role_id,
4210 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4211 bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
4218 wlvif->beacon_int = bss_conf->beacon_int;
4222 u32 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
4233 &wlvif->flags)) {
4234 ret = wlcore_hw_dfs_master_restart(wl, wlvif);
4251 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4257 wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates,
4258 wlvif->band);
4259 wlvif->basic_rate = wl1271_tx_min_rate_get(wl,
4260 wlvif->basic_rate_set);
4262 ret = wl1271_init_ap_rates(wl, wlvif);
4275 wlvif->basic_rate,
4292 if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) {
4293 ret = wl12xx_cmd_role_start_ap(wl, wlvif);
4297 ret = wl1271_ap_init_hwenc(wl, wlvif);
4301 set_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags);
4305 if (test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) {
4310 if (test_bit(wlvif->role_id, wl->roc_map))
4311 wl12xx_croc(wl, wlvif->role_id);
4313 ret = wl12xx_cmd_role_stop_ap(wl, wlvif);
4317 clear_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags);
4319 &wlvif->flags);
4332 ret = wl1271_acx_set_ht_information(wl, wlvif,
4344 static int wlcore_set_bssid(struct wl1271 *wl, struct wl12xx_vif *wlvif,
4357 wlvif->beacon_int = bss_conf->beacon_int;
4359 wlvif->basic_rate_set =
4361 wlvif->band);
4362 wlvif->basic_rate =
4364 wlvif->basic_rate_set);
4367 wlvif->rate_set =
4370 wlvif->band);
4373 if (wl->sched_vif == wlvif)
4374 wl->ops->sched_scan_stop(wl, wlvif);
4376 ret = wl1271_acx_sta_rate_policies(wl, wlvif);
4380 ret = wl12xx_cmd_build_null_data(wl, wlvif);
4384 ret = wl1271_build_qos_null_data(wl, wl12xx_wlvif_to_vif(wlvif));
4388 wlcore_set_ssid(wl, wlvif);
4390 set_bit(WLVIF_FLAG_IN_USE, &wlvif->flags);
4395 static int wlcore_clear_bssid(struct wl1271 *wl, struct wl12xx_vif *wlvif)
4400 wl1271_set_band_rate(wl, wlvif);
4401 wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
4403 ret = wl1271_acx_sta_rate_policies(wl, wlvif);
4407 if (wlvif->bss_type == BSS_TYPE_STA_BSS &&
4408 test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags)) {
4409 ret = wl12xx_cmd_role_stop_sta(wl, wlvif);
4414 clear_bit(WLVIF_FLAG_IN_USE, &wlvif->flags);
4423 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4425 bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS);
4442 set_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags);
4445 wlcore_unset_assoc(wl, wlvif);
4446 wl12xx_cmd_role_stop_sta(wl, wlvif);
4465 wl1271_sta_handle_idle(wl, wlvif, vif->cfg.idle);
4471 ret = wl1271_acx_rssi_snr_trigger(wl, wlvif, enable,
4476 wlvif->rssi_thold = bss_conf->cqm_rssi_thold;
4487 sta_rate_set = sta->deflink.supp_rates[wlvif->band];
4501 ret = wlcore_set_bssid(wl, wlvif, vif,
4509 ret = wlcore_clear_bssid(wl, wlvif);
4521 wlvif->basic_rate_set =
4523 wlvif->band);
4524 wlvif->basic_rate =
4526 wlvif->basic_rate_set);
4529 wlvif->rate_set = CONF_TX_IBSS_DEFAULT_RATES;
4530 ret = wl1271_acx_sta_rate_policies(wl, wlvif);
4538 ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true);
4548 ret = wlcore_join(wl, wlvif);
4557 ret = wlcore_set_assoc(wl, wlvif, bss_conf,
4562 if (test_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags))
4563 wl12xx_set_authorized(wl, wlvif);
4565 wlcore_unset_assoc(wl, wlvif);
4571 test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) &&
4572 !test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags)) {
4586 ret = wl1271_ps_set_mode(wl, wlvif, ps_mode);
4591 test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags)) {
4594 ret = wl1271_ps_set_mode(wl, wlvif,
4609 wlvif->rate_set,
4610 wlvif->sta.hlid);
4618 ret = wl1271_acx_set_ht_information(wl, wlvif,
4632 wlvif->sta.qos = bss_conf->qos;
4633 WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS);
4636 wlvif->ip_addr = addr;
4643 ret = wl1271_cmd_build_arp_rsp(wl, wlvif);
4649 ret = wl1271_acx_arp_ip_filter(wl, wlvif,
4654 wlvif->ip_addr = 0;
4655 ret = wl1271_acx_arp_ip_filter(wl, wlvif, 0, addr);
4672 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4673 bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS);
4677 wlvif->role_id, (int)changed);
4684 cancel_delayed_work_sync(&wlvif->connection_loss_work);
4695 if (unlikely(!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)))
4703 bss_conf->txpower != wlvif->power_level) {
4705 ret = wl1271_acx_tx_power(wl, wlvif, bss_conf->txpower);
4709 wlvif->power_level = bss_conf->txpower;
4746 struct wl12xx_vif *wlvif;
4761 wl12xx_for_each_wlvif(wl, wlvif) {
4762 struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
4773 wlvif->bss_type == BSS_TYPE_AP_BSS &&
4774 ctx->radar_enabled && !wlvif->radar_enabled &&
4777 wlcore_hw_set_cac(wl, wlvif, true);
4778 wlvif->radar_enabled = true;
4794 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4801 wlvif->role_id, channel,
4810 if (unlikely(!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)))
4817 wlvif->band = ctx->def.chan->band;
4818 wlvif->channel = channel;
4819 wlvif->channel_type = cfg80211_get_chandef_type(&ctx->def);
4822 wl1271_set_band_rate(wl, wlvif);
4827 wlcore_hw_set_cac(wl, wlvif, true);
4828 wlvif->radar_enabled = true;
4845 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4850 wlvif->role_id,
4861 if (unlikely(!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)))
4868 if (wlvif->radar_enabled) {
4870 wlcore_hw_set_cac(wl, wlvif, false);
4871 wlvif->radar_enabled = false;
4881 struct wl12xx_vif *wlvif,
4889 wlvif->role_id, wlvif->channel, channel,
4892 if (WARN_ON_ONCE(wlvif->bss_type != BSS_TYPE_AP_BSS))
4895 WARN_ON(!test_bit(WLVIF_FLAG_BEACON_DISABLED, &wlvif->flags));
4897 if (wlvif->radar_enabled) {
4899 wlcore_hw_set_cac(wl, wlvif, false);
4900 wlvif->radar_enabled = false;
4903 wlvif->band = new_ctx->def.chan->band;
4904 wlvif->channel = channel;
4905 wlvif->channel_type = cfg80211_get_chandef_type(&new_ctx->def);
4910 wlcore_hw_set_cac(wl, wlvif, true);
4911 wlvif->radar_enabled = true;
4937 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vifs[i].vif);
4939 ret = __wlcore_switch_vif_chan(wl, wlvif, vifs[i].new_ctx);
4958 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
4962 if (wlcore_is_p2p_mgmt(wlvif))
4974 if (!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))
4985 ret = wl1271_acx_ac_cfg(wl, wlvif, wl1271_tx_get_queue(queue),
4991 ret = wl1271_acx_tid_cfg(wl, wlvif, wl1271_tx_get_queue(queue),
5012 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
5027 ret = wl12xx_acx_tsf_info(wl, wlvif, &mactime);
5054 struct wl12xx_vif *wlvif,
5067 ret = wl12xx_allocate_link(wl, wlvif, &wl_sta->hlid);
5076 set_bit(wl_sta->hlid, wlvif->ap.sta_hlid_map);
5082 void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid)
5084 if (!test_bit(hlid, wlvif->ap.sta_hlid_map))
5087 clear_bit(hlid, wlvif->ap.sta_hlid_map);
5095 wlcore_save_freed_pkts_addr(wl, wlvif, hlid, wl->links[hlid].addr);
5097 wl12xx_free_link(wl, wlvif, &hlid);
5109 struct wl12xx_vif *wlvif,
5118 ret = wl1271_allocate_sta(wl, wlvif, sta);
5125 ret = wl12xx_cmd_add_peer(wl, wlvif, sta, hlid);
5127 wl1271_free_sta(wl, wlvif, hlid);
5133 struct wl12xx_vif *wlvif,
5143 if (WARN_ON(!test_bit(id, wlvif->ap.sta_hlid_map)))
5146 ret = wl12xx_cmd_remove_peer(wl, wlvif, wl_sta->hlid);
5150 wl1271_free_sta(wl, wlvif, wl_sta->hlid);
5155 struct wl12xx_vif *wlvif)
5161 if (WARN_ON(wlvif->role_id == WL12XX_INVALID_ROLE_ID))
5164 wl12xx_roc(wl, wlvif, wlvif->role_id, wlvif->band, wlvif->channel);
5173 void wlcore_update_inconn_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif,
5180 if (!wlvif->ap_pending_auth_reply &&
5181 !wlvif->inconn_count)
5182 wlcore_roc_if_possible(wl, wlvif);
5186 wlvif->inconn_count++;
5188 wlvif->ap_pending_auth_reply = true;
5194 if (WARN_ON(!wl_sta && !wlvif->ap_pending_auth_reply))
5197 if (WARN_ON(wl_sta && !wlvif->inconn_count))
5202 wlvif->inconn_count--;
5204 wlvif->ap_pending_auth_reply = false;
5207 if (!wlvif->inconn_count && !wlvif->ap_pending_auth_reply &&
5208 test_bit(wlvif->role_id, wl->roc_map))
5209 wl12xx_croc(wl, wlvif->role_id);
5214 struct wl12xx_vif *wlvif,
5220 bool is_ap = wlvif->bss_type == BSS_TYPE_AP_BSS;
5221 bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS;
5230 ret = wl12xx_sta_add(wl, wlvif, sta);
5236 wlcore_update_inconn_sta(wl, wlvif, wl_sta, true);
5246 wl12xx_sta_remove(wl, wlvif, sta);
5248 wlcore_update_inconn_sta(wl, wlvif, wl_sta, false);
5254 ret = wl12xx_cmd_set_peer_state(wl, wlvif, wl_sta->hlid);
5264 wlcore_update_inconn_sta(wl, wlvif, wl_sta, false);
5270 set_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags);
5271 ret = wl12xx_set_authorized(wl, wlvif);
5279 clear_bit(WLVIF_FLAG_STA_AUTHORIZED, &wlvif->flags);
5280 clear_bit(WLVIF_FLAG_STA_STATE_SENT, &wlvif->flags);
5287 wlcore_save_freed_pkts(wl, wlvif, wlvif->sta.hlid, sta);
5288 wlvif->total_freed_pkts = 0;
5295 wlvif->total_freed_pkts = wl_sta->total_freed_pkts;
5302 if (test_bit(wlvif->role_id, wl->roc_map))
5303 wl12xx_croc(wl, wlvif->role_id);
5311 WARN_ON(wlvif->role_id == WL12XX_INVALID_ROLE_ID);
5312 wl12xx_roc(wl, wlvif, wlvif->role_id,
5313 wlvif->band, wlvif->channel);
5326 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
5343 ret = wl12xx_update_sta_state(wl, wlvif, sta, old_state, new_state);
5359 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
5381 if (wlvif->bss_type == BSS_TYPE_STA_BSS) {
5382 hlid = wlvif->sta.hlid;
5383 } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) {
5404 if (!wlvif->ba_support || !wlvif->ba_allowed) {
5483 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
5494 wlvif->bitrate_masks[i] =
5502 if (wlvif->bss_type == BSS_TYPE_STA_BSS &&
5503 !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) {
5509 wl1271_set_band_rate(wl, wlvif);
5510 wlvif->basic_rate =
5511 wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
5512 ret = wl1271_acx_sta_rate_policies(wl, wlvif);
5528 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
5538 if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags))
5551 if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) {
5554 ret = wl->ops->channel_switch(wl, wlvif, ch_switch);
5558 set_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags);
5561 delay_usec = ieee80211_tu_to_usec(wlvif->beacon_int) *
5563 ieee80211_queue_delayed_work(hw, &wlvif->channel_switch_work,
5577 struct wl12xx_vif *wlvif,
5582 ieee80211_beacon_get(wl->hw, wl12xx_wlvif_to_vif(wlvif), 0);
5592 static int wlcore_get_csa_count(struct wl1271 *wl, struct wl12xx_vif *wlvif,
5598 ie = wlcore_get_beacon_ie(wl, wlvif, WLAN_EID_CHANNEL_SWITCH);
5613 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
5622 wlvif->role_id);
5624 ret = wlcore_get_csa_count(wl, wlvif, &ch_switch.count);
5641 ret = wl->ops->channel_switch(wl, wlvif, &ch_switch);
5645 set_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags);
5668 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
5675 channel, wlvif->role_id);
5694 ret = wl12xx_start_dev(wl, wlvif, chan->band, channel);
5711 struct wl12xx_vif *wlvif;
5718 wlvif = wl12xx_vif_to_data(wl->roc_vif);
5720 if (!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))
5723 ret = wl12xx_stop_dev(wl, wlvif);
5799 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
5807 wlvif->rc_update_bw = sta->deflink.bandwidth;
5808 memcpy(&wlvif->rc_ht_cap, &sta->deflink.ht_cap,
5810 ieee80211_queue_work(hw, &wlvif->rc_update_work);
5819 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
5834 ret = wlcore_acx_average_rssi(wl, wlvif, &rssi_dbm);
6707 struct wl12xx_vif *wlvif;
6718 wl12xx_for_each_wlvif(wl, wlvif) {
6719 if (!test_bit(WLVIF_FLAG_IN_PS, &wlvif->flags) &&
6720 test_bit(WLVIF_FLAG_IN_USE, &wlvif->flags))