Linux Audio

Check our new training course

Loading...
v6.8
  1// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
  2/*
  3 * Copyright (C) 2013-2014, 2018-2019, 2022-2023 Intel Corporation
  4 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
  5 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  6#include "mvm.h"
  7
  8/* For counting bound interfaces */
  9struct iwl_mvm_active_iface_iterator_data {
 10	struct ieee80211_vif *ignore_vif;
 11	struct ieee80211_sta *sta_vif_ap_sta;
 12	enum iwl_sf_state sta_vif_state;
 13	u32 num_active_macs;
 14};
 15
 16/*
 17 * Count bound interfaces which are not p2p, besides data->ignore_vif.
 18 * data->station_vif will point to one bound vif of type station, if exists.
 19 */
 20static void iwl_mvm_bound_iface_iterator(void *_data, u8 *mac,
 21					 struct ieee80211_vif *vif)
 22{
 23	struct iwl_mvm_active_iface_iterator_data *data = _data;
 24	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 25
 26	if (vif == data->ignore_vif || !mvmvif->deflink.phy_ctxt ||
 27	    vif->type == NL80211_IFTYPE_P2P_DEVICE)
 28		return;
 29
 30	data->num_active_macs++;
 31
 32	if (vif->type == NL80211_IFTYPE_STATION) {
 33		data->sta_vif_ap_sta = mvmvif->ap_sta;
 34		if (vif->cfg.assoc)
 35			data->sta_vif_state = SF_FULL_ON;
 36		else
 37			data->sta_vif_state = SF_INIT_OFF;
 38	}
 39}
 40
 41/*
 42 * Aging and idle timeouts for the different possible scenarios
 43 * in default configuration
 44 */
 45static const
 46__le32 sf_full_timeout_def[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES] = {
 47	{
 48		cpu_to_le32(SF_SINGLE_UNICAST_AGING_TIMER_DEF),
 49		cpu_to_le32(SF_SINGLE_UNICAST_IDLE_TIMER_DEF)
 50	},
 51	{
 52		cpu_to_le32(SF_AGG_UNICAST_AGING_TIMER_DEF),
 53		cpu_to_le32(SF_AGG_UNICAST_IDLE_TIMER_DEF)
 54	},
 55	{
 56		cpu_to_le32(SF_MCAST_AGING_TIMER_DEF),
 57		cpu_to_le32(SF_MCAST_IDLE_TIMER_DEF)
 58	},
 59	{
 60		cpu_to_le32(SF_BA_AGING_TIMER_DEF),
 61		cpu_to_le32(SF_BA_IDLE_TIMER_DEF)
 62	},
 63	{
 64		cpu_to_le32(SF_TX_RE_AGING_TIMER_DEF),
 65		cpu_to_le32(SF_TX_RE_IDLE_TIMER_DEF)
 66	},
 67};
 68
 69/*
 70 * Aging and idle timeouts for the different possible scenarios
 71 * in single BSS MAC configuration.
 72 */
 73static const __le32 sf_full_timeout[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES] = {
 74	{
 75		cpu_to_le32(SF_SINGLE_UNICAST_AGING_TIMER),
 76		cpu_to_le32(SF_SINGLE_UNICAST_IDLE_TIMER)
 77	},
 78	{
 79		cpu_to_le32(SF_AGG_UNICAST_AGING_TIMER),
 80		cpu_to_le32(SF_AGG_UNICAST_IDLE_TIMER)
 81	},
 82	{
 83		cpu_to_le32(SF_MCAST_AGING_TIMER),
 84		cpu_to_le32(SF_MCAST_IDLE_TIMER)
 85	},
 86	{
 87		cpu_to_le32(SF_BA_AGING_TIMER),
 88		cpu_to_le32(SF_BA_IDLE_TIMER)
 89	},
 90	{
 91		cpu_to_le32(SF_TX_RE_AGING_TIMER),
 92		cpu_to_le32(SF_TX_RE_IDLE_TIMER)
 93	},
 94};
 95
 96static void iwl_mvm_fill_sf_command(struct iwl_mvm *mvm,
 97				    struct iwl_sf_cfg_cmd *sf_cmd,
 98				    struct ieee80211_sta *sta)
 99{
100	int i, j, watermark;
101	u8 max_rx_nss = 0;
102	bool is_legacy = true;
103	struct ieee80211_link_sta *link_sta;
104	unsigned int link_id;
105
106	sf_cmd->watermark[SF_LONG_DELAY_ON] = cpu_to_le32(SF_W_MARK_SCAN);
107
108	/*
109	 * If we are in association flow - check antenna configuration
110	 * capabilities of the AP station, and choose the watermark accordingly.
111	 */
112	if (sta) {
113		/* find the maximal NSS number among all links (if relevant) */
114		rcu_read_lock();
115		for (link_id = 0; link_id < ARRAY_SIZE(sta->link); link_id++) {
116			link_sta = rcu_dereference(sta->link[link_id]);
117			if (!link_sta)
118				continue;
119
120			if (link_sta->ht_cap.ht_supported ||
121			    link_sta->vht_cap.vht_supported ||
122			    link_sta->eht_cap.has_eht ||
123			    link_sta->he_cap.has_he) {
124				is_legacy = false;
125				max_rx_nss = max(max_rx_nss, link_sta->rx_nss);
126			}
127		}
128		rcu_read_unlock();
129
130		if (!is_legacy) {
131			switch (max_rx_nss) {
132			case 1:
133				watermark = SF_W_MARK_SISO;
134				break;
135			case 2:
136				watermark = SF_W_MARK_MIMO2;
137				break;
138			default:
139				watermark = SF_W_MARK_MIMO3;
140				break;
141			}
142		} else {
143			watermark = SF_W_MARK_LEGACY;
144		}
145	/* default watermark value for unassociated mode. */
146	} else {
147		watermark = SF_W_MARK_MIMO2;
148	}
149	sf_cmd->watermark[SF_FULL_ON] = cpu_to_le32(watermark);
150
151	for (i = 0; i < SF_NUM_SCENARIO; i++) {
152		for (j = 0; j < SF_NUM_TIMEOUT_TYPES; j++) {
153			sf_cmd->long_delay_timeouts[i][j] =
154					cpu_to_le32(SF_LONG_DELAY_AGING_TIMER);
155		}
156	}
157
158	if (sta) {
159		BUILD_BUG_ON(sizeof(sf_full_timeout) !=
160			     sizeof(__le32) * SF_NUM_SCENARIO *
161			     SF_NUM_TIMEOUT_TYPES);
162
163		memcpy(sf_cmd->full_on_timeouts, sf_full_timeout,
164		       sizeof(sf_full_timeout));
165	} else {
166		BUILD_BUG_ON(sizeof(sf_full_timeout_def) !=
167			     sizeof(__le32) * SF_NUM_SCENARIO *
168			     SF_NUM_TIMEOUT_TYPES);
169
170		memcpy(sf_cmd->full_on_timeouts, sf_full_timeout_def,
171		       sizeof(sf_full_timeout_def));
172	}
 
173}
174
175static int iwl_mvm_sf_config(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
176			     enum iwl_sf_state new_state)
177{
178	struct iwl_sf_cfg_cmd sf_cmd = {
179		.state = cpu_to_le32(new_state),
180	};
 
181	int ret = 0;
182
 
 
 
183	/*
184	 * If an associated AP sta changed its antenna configuration, the state
185	 * will remain FULL_ON but SF parameters need to be reconsidered.
186	 */
187	if (new_state != SF_FULL_ON && mvm->sf_state == new_state)
188		return 0;
189
190	switch (new_state) {
191	case SF_UNINIT:
192		iwl_mvm_fill_sf_command(mvm, &sf_cmd, NULL);
193		break;
194	case SF_FULL_ON:
195		if (!sta) {
196			IWL_ERR(mvm,
197				"No station: Cannot switch SF to FULL_ON\n");
198			return -EINVAL;
199		}
 
 
 
 
 
 
 
200		iwl_mvm_fill_sf_command(mvm, &sf_cmd, sta);
 
201		break;
202	case SF_INIT_OFF:
203		iwl_mvm_fill_sf_command(mvm, &sf_cmd, NULL);
204		break;
205	default:
206		WARN_ONCE(1, "Invalid state: %d. not sending Smart Fifo cmd\n",
207			  new_state);
208		return -EINVAL;
209	}
210
211	ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_SF_CFG_CMD, CMD_ASYNC,
212				   sizeof(sf_cmd), &sf_cmd);
213	if (!ret)
214		mvm->sf_state = new_state;
215
216	return ret;
217}
218
219/*
220 * Update Smart fifo:
221 * Count bound interfaces that are not to be removed, ignoring p2p devices,
222 * and set new state accordingly.
223 */
224int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *changed_vif,
225		      bool remove_vif)
226{
227	enum iwl_sf_state new_state;
 
228	struct iwl_mvm_vif *mvmvif = NULL;
229	struct iwl_mvm_active_iface_iterator_data data = {
230		.ignore_vif = changed_vif,
231		.sta_vif_state = SF_UNINIT,
 
232	};
233	struct ieee80211_sta *sta = NULL;
234
235	/*
236	 * Ignore the call if we are in HW Restart flow, or if the handled
237	 * vif is a p2p device.
238	 */
239	if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) ||
240	    (changed_vif && changed_vif->type == NL80211_IFTYPE_P2P_DEVICE))
241		return 0;
242
243	ieee80211_iterate_active_interfaces_atomic(mvm->hw,
244						   IEEE80211_IFACE_ITER_NORMAL,
245						   iwl_mvm_bound_iface_iterator,
246						   &data);
247
248	/* If changed_vif exists and is not to be removed, add to the count */
249	if (changed_vif && !remove_vif)
250		data.num_active_macs++;
251
252	switch (data.num_active_macs) {
253	case 0:
254		/* If there are no active macs - change state to SF_INIT_OFF */
255		new_state = SF_INIT_OFF;
256		break;
257	case 1:
258		if (remove_vif) {
259			/* The one active mac left is of type station
260			 * and we filled the relevant data during iteration
261			 */
262			new_state = data.sta_vif_state;
263			sta = data.sta_vif_ap_sta;
264		} else {
265			if (WARN_ON(!changed_vif))
266				return -EINVAL;
267			if (changed_vif->type != NL80211_IFTYPE_STATION) {
268				new_state = SF_UNINIT;
269			} else if (changed_vif->cfg.assoc &&
270				   changed_vif->bss_conf.dtim_period) {
271				mvmvif = iwl_mvm_vif_from_mac80211(changed_vif);
272				sta = mvmvif->ap_sta;
273				new_state = SF_FULL_ON;
274			} else {
275				new_state = SF_INIT_OFF;
276			}
277		}
278		break;
279	default:
280		/* If there are multiple active macs - change to SF_UNINIT */
281		new_state = SF_UNINIT;
282	}
283
284	return iwl_mvm_sf_config(mvm, sta, new_state);
285}
v5.4
  1/******************************************************************************
  2 *
  3 * This file is provided under a dual BSD/GPLv2 license.  When using or
  4 * redistributing this file, you may do so under either license.
  5 *
  6 * GPL LICENSE SUMMARY
  7 *
  8 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
  9 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
 10 * Copyright (C) 2018 Intel Corporation
 11 *
 12 * This program is free software; you can redistribute it and/or modify
 13 * it under the terms of version 2 of the GNU General Public License as
 14 * published by the Free Software Foundation.
 15 *
 16 * This program is distributed in the hope that it will be useful, but
 17 * WITHOUT ANY WARRANTY; without even the implied warranty of
 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 19 * General Public License for more details.
 20 *
 21 * The full GNU General Public License is included in this distribution
 22 * in the file called COPYING.
 23 *
 24 * Contact Information:
 25 *  Intel Linux Wireless <linuxwifi@intel.com>
 26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 27 *
 28 * BSD LICENSE
 29 *
 30 * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
 31 * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
 32 * Copyright (C) 2018 Intel Corporation
 33 * All rights reserved.
 34 *
 35 * Redistribution and use in source and binary forms, with or without
 36 * modification, are permitted provided that the following conditions
 37 * are met:
 38 *
 39 *  * Redistributions of source code must retain the above copyright
 40 *    notice, this list of conditions and the following disclaimer.
 41 *  * Redistributions in binary form must reproduce the above copyright
 42 *    notice, this list of conditions and the following disclaimer in
 43 *    the documentation and/or other materials provided with the
 44 *    distribution.
 45 *  * Neither the name Intel Corporation nor the names of its
 46 *    contributors may be used to endorse or promote products derived
 47 *    from this software without specific prior written permission.
 48 *
 49 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 50 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 51 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 52 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 53 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 54 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 55 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 56 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 57 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 58 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 59 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 60 *
 61 *****************************************************************************/
 62#include "mvm.h"
 63
 64/* For counting bound interfaces */
 65struct iwl_mvm_active_iface_iterator_data {
 66	struct ieee80211_vif *ignore_vif;
 67	u8 sta_vif_ap_sta_id;
 68	enum iwl_sf_state sta_vif_state;
 69	u32 num_active_macs;
 70};
 71
 72/*
 73 * Count bound interfaces which are not p2p, besides data->ignore_vif.
 74 * data->station_vif will point to one bound vif of type station, if exists.
 75 */
 76static void iwl_mvm_bound_iface_iterator(void *_data, u8 *mac,
 77					 struct ieee80211_vif *vif)
 78{
 79	struct iwl_mvm_active_iface_iterator_data *data = _data;
 80	struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
 81
 82	if (vif == data->ignore_vif || !mvmvif->phy_ctxt ||
 83	    vif->type == NL80211_IFTYPE_P2P_DEVICE)
 84		return;
 85
 86	data->num_active_macs++;
 87
 88	if (vif->type == NL80211_IFTYPE_STATION) {
 89		data->sta_vif_ap_sta_id = mvmvif->ap_sta_id;
 90		if (vif->bss_conf.assoc)
 91			data->sta_vif_state = SF_FULL_ON;
 92		else
 93			data->sta_vif_state = SF_INIT_OFF;
 94	}
 95}
 96
 97/*
 98 * Aging and idle timeouts for the different possible scenarios
 99 * in default configuration
100 */
101static const
102__le32 sf_full_timeout_def[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES] = {
103	{
104		cpu_to_le32(SF_SINGLE_UNICAST_AGING_TIMER_DEF),
105		cpu_to_le32(SF_SINGLE_UNICAST_IDLE_TIMER_DEF)
106	},
107	{
108		cpu_to_le32(SF_AGG_UNICAST_AGING_TIMER_DEF),
109		cpu_to_le32(SF_AGG_UNICAST_IDLE_TIMER_DEF)
110	},
111	{
112		cpu_to_le32(SF_MCAST_AGING_TIMER_DEF),
113		cpu_to_le32(SF_MCAST_IDLE_TIMER_DEF)
114	},
115	{
116		cpu_to_le32(SF_BA_AGING_TIMER_DEF),
117		cpu_to_le32(SF_BA_IDLE_TIMER_DEF)
118	},
119	{
120		cpu_to_le32(SF_TX_RE_AGING_TIMER_DEF),
121		cpu_to_le32(SF_TX_RE_IDLE_TIMER_DEF)
122	},
123};
124
125/*
126 * Aging and idle timeouts for the different possible scenarios
127 * in single BSS MAC configuration.
128 */
129static const __le32 sf_full_timeout[SF_NUM_SCENARIO][SF_NUM_TIMEOUT_TYPES] = {
130	{
131		cpu_to_le32(SF_SINGLE_UNICAST_AGING_TIMER),
132		cpu_to_le32(SF_SINGLE_UNICAST_IDLE_TIMER)
133	},
134	{
135		cpu_to_le32(SF_AGG_UNICAST_AGING_TIMER),
136		cpu_to_le32(SF_AGG_UNICAST_IDLE_TIMER)
137	},
138	{
139		cpu_to_le32(SF_MCAST_AGING_TIMER),
140		cpu_to_le32(SF_MCAST_IDLE_TIMER)
141	},
142	{
143		cpu_to_le32(SF_BA_AGING_TIMER),
144		cpu_to_le32(SF_BA_IDLE_TIMER)
145	},
146	{
147		cpu_to_le32(SF_TX_RE_AGING_TIMER),
148		cpu_to_le32(SF_TX_RE_IDLE_TIMER)
149	},
150};
151
152static void iwl_mvm_fill_sf_command(struct iwl_mvm *mvm,
153				    struct iwl_sf_cfg_cmd *sf_cmd,
154				    struct ieee80211_sta *sta)
155{
156	int i, j, watermark;
 
 
 
 
157
158	sf_cmd->watermark[SF_LONG_DELAY_ON] = cpu_to_le32(SF_W_MARK_SCAN);
159
160	/*
161	 * If we are in association flow - check antenna configuration
162	 * capabilities of the AP station, and choose the watermark accordingly.
163	 */
164	if (sta) {
165		if (sta->ht_cap.ht_supported || sta->vht_cap.vht_supported) {
166			switch (sta->rx_nss) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167			case 1:
168				watermark = SF_W_MARK_SISO;
169				break;
170			case 2:
171				watermark = SF_W_MARK_MIMO2;
172				break;
173			default:
174				watermark = SF_W_MARK_MIMO3;
175				break;
176			}
177		} else {
178			watermark = SF_W_MARK_LEGACY;
179		}
180	/* default watermark value for unassociated mode. */
181	} else {
182		watermark = SF_W_MARK_MIMO2;
183	}
184	sf_cmd->watermark[SF_FULL_ON] = cpu_to_le32(watermark);
185
186	for (i = 0; i < SF_NUM_SCENARIO; i++) {
187		for (j = 0; j < SF_NUM_TIMEOUT_TYPES; j++) {
188			sf_cmd->long_delay_timeouts[i][j] =
189					cpu_to_le32(SF_LONG_DELAY_AGING_TIMER);
190		}
191	}
192
193	if (sta) {
194		BUILD_BUG_ON(sizeof(sf_full_timeout) !=
195			     sizeof(__le32) * SF_NUM_SCENARIO *
196			     SF_NUM_TIMEOUT_TYPES);
197
198		memcpy(sf_cmd->full_on_timeouts, sf_full_timeout,
199		       sizeof(sf_full_timeout));
200	} else {
201		BUILD_BUG_ON(sizeof(sf_full_timeout_def) !=
202			     sizeof(__le32) * SF_NUM_SCENARIO *
203			     SF_NUM_TIMEOUT_TYPES);
204
205		memcpy(sf_cmd->full_on_timeouts, sf_full_timeout_def,
206		       sizeof(sf_full_timeout_def));
207	}
208
209}
210
211static int iwl_mvm_sf_config(struct iwl_mvm *mvm, u8 sta_id,
212			     enum iwl_sf_state new_state)
213{
214	struct iwl_sf_cfg_cmd sf_cmd = {
215		.state = cpu_to_le32(new_state),
216	};
217	struct ieee80211_sta *sta;
218	int ret = 0;
219
220	if (mvm->cfg->disable_dummy_notification)
221		sf_cmd.state |= cpu_to_le32(SF_CFG_DUMMY_NOTIF_OFF);
222
223	/*
224	 * If an associated AP sta changed its antenna configuration, the state
225	 * will remain FULL_ON but SF parameters need to be reconsidered.
226	 */
227	if (new_state != SF_FULL_ON && mvm->sf_state == new_state)
228		return 0;
229
230	switch (new_state) {
231	case SF_UNINIT:
232		iwl_mvm_fill_sf_command(mvm, &sf_cmd, NULL);
233		break;
234	case SF_FULL_ON:
235		if (sta_id == IWL_MVM_INVALID_STA) {
236			IWL_ERR(mvm,
237				"No station: Cannot switch SF to FULL_ON\n");
238			return -EINVAL;
239		}
240		rcu_read_lock();
241		sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
242		if (IS_ERR_OR_NULL(sta)) {
243			IWL_ERR(mvm, "Invalid station id\n");
244			rcu_read_unlock();
245			return -EINVAL;
246		}
247		iwl_mvm_fill_sf_command(mvm, &sf_cmd, sta);
248		rcu_read_unlock();
249		break;
250	case SF_INIT_OFF:
251		iwl_mvm_fill_sf_command(mvm, &sf_cmd, NULL);
252		break;
253	default:
254		WARN_ONCE(1, "Invalid state: %d. not sending Smart Fifo cmd\n",
255			  new_state);
256		return -EINVAL;
257	}
258
259	ret = iwl_mvm_send_cmd_pdu(mvm, REPLY_SF_CFG_CMD, CMD_ASYNC,
260				   sizeof(sf_cmd), &sf_cmd);
261	if (!ret)
262		mvm->sf_state = new_state;
263
264	return ret;
265}
266
267/*
268 * Update Smart fifo:
269 * Count bound interfaces that are not to be removed, ignoring p2p devices,
270 * and set new state accordingly.
271 */
272int iwl_mvm_sf_update(struct iwl_mvm *mvm, struct ieee80211_vif *changed_vif,
273		      bool remove_vif)
274{
275	enum iwl_sf_state new_state;
276	u8 sta_id = IWL_MVM_INVALID_STA;
277	struct iwl_mvm_vif *mvmvif = NULL;
278	struct iwl_mvm_active_iface_iterator_data data = {
279		.ignore_vif = changed_vif,
280		.sta_vif_state = SF_UNINIT,
281		.sta_vif_ap_sta_id = IWL_MVM_INVALID_STA,
282	};
 
283
284	/*
285	 * Ignore the call if we are in HW Restart flow, or if the handled
286	 * vif is a p2p device.
287	 */
288	if (test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status) ||
289	    (changed_vif && changed_vif->type == NL80211_IFTYPE_P2P_DEVICE))
290		return 0;
291
292	ieee80211_iterate_active_interfaces_atomic(mvm->hw,
293						   IEEE80211_IFACE_ITER_NORMAL,
294						   iwl_mvm_bound_iface_iterator,
295						   &data);
296
297	/* If changed_vif exists and is not to be removed, add to the count */
298	if (changed_vif && !remove_vif)
299		data.num_active_macs++;
300
301	switch (data.num_active_macs) {
302	case 0:
303		/* If there are no active macs - change state to SF_INIT_OFF */
304		new_state = SF_INIT_OFF;
305		break;
306	case 1:
307		if (remove_vif) {
308			/* The one active mac left is of type station
309			 * and we filled the relevant data during iteration
310			 */
311			new_state = data.sta_vif_state;
312			sta_id = data.sta_vif_ap_sta_id;
313		} else {
314			if (WARN_ON(!changed_vif))
315				return -EINVAL;
316			if (changed_vif->type != NL80211_IFTYPE_STATION) {
317				new_state = SF_UNINIT;
318			} else if (changed_vif->bss_conf.assoc &&
319				   changed_vif->bss_conf.dtim_period) {
320				mvmvif = iwl_mvm_vif_from_mac80211(changed_vif);
321				sta_id = mvmvif->ap_sta_id;
322				new_state = SF_FULL_ON;
323			} else {
324				new_state = SF_INIT_OFF;
325			}
326		}
327		break;
328	default:
329		/* If there are multiple active macs - change to SF_UNINIT */
330		new_state = SF_UNINIT;
331	}
332	return iwl_mvm_sf_config(mvm, sta_id, new_state);
 
333}