1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /*
3  * Copyright (C) 2017 Intel Deutschland GmbH
4  * Copyright (C) 2018-2021 Intel Corporation
5  */
6 #include "rs.h"
7 #include "fw-api.h"
8 #include "sta.h"
9 #include "iwl-op-mode.h"
10 #include "mvm.h"
11 
rs_fw_bw_from_sta_bw(struct ieee80211_sta * sta)12 static u8 rs_fw_bw_from_sta_bw(struct ieee80211_sta *sta)
13 {
14 	switch (sta->bandwidth) {
15 	case IEEE80211_STA_RX_BW_160:
16 		return IWL_TLC_MNG_CH_WIDTH_160MHZ;
17 	case IEEE80211_STA_RX_BW_80:
18 		return IWL_TLC_MNG_CH_WIDTH_80MHZ;
19 	case IEEE80211_STA_RX_BW_40:
20 		return IWL_TLC_MNG_CH_WIDTH_40MHZ;
21 	case IEEE80211_STA_RX_BW_20:
22 	default:
23 		return IWL_TLC_MNG_CH_WIDTH_20MHZ;
24 	}
25 }
26 
rs_fw_set_active_chains(u8 chains)27 static u8 rs_fw_set_active_chains(u8 chains)
28 {
29 	u8 fw_chains = 0;
30 
31 	if (chains & ANT_A)
32 		fw_chains |= IWL_TLC_MNG_CHAIN_A_MSK;
33 	if (chains & ANT_B)
34 		fw_chains |= IWL_TLC_MNG_CHAIN_B_MSK;
35 	if (chains & ANT_C)
36 		WARN(false,
37 		     "tlc offload doesn't support antenna C. chains: 0x%x\n",
38 		     chains);
39 
40 	return fw_chains;
41 }
42 
rs_fw_sgi_cw_support(struct ieee80211_sta * sta)43 static u8 rs_fw_sgi_cw_support(struct ieee80211_sta *sta)
44 {
45 	struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
46 	struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
47 	struct ieee80211_sta_he_cap *he_cap = &sta->he_cap;
48 	u8 supp = 0;
49 
50 	if (he_cap->has_he)
51 		return 0;
52 
53 	if (ht_cap->cap & IEEE80211_HT_CAP_SGI_20)
54 		supp |= BIT(IWL_TLC_MNG_CH_WIDTH_20MHZ);
55 	if (ht_cap->cap & IEEE80211_HT_CAP_SGI_40)
56 		supp |= BIT(IWL_TLC_MNG_CH_WIDTH_40MHZ);
57 	if (vht_cap->cap & IEEE80211_VHT_CAP_SHORT_GI_80)
58 		supp |= BIT(IWL_TLC_MNG_CH_WIDTH_80MHZ);
59 	if (vht_cap->cap & IEEE80211_VHT_CAP_SHORT_GI_160)
60 		supp |= BIT(IWL_TLC_MNG_CH_WIDTH_160MHZ);
61 
62 	return supp;
63 }
64 
rs_fw_get_config_flags(struct iwl_mvm * mvm,struct ieee80211_sta * sta,struct ieee80211_supported_band * sband)65 static u16 rs_fw_get_config_flags(struct iwl_mvm *mvm,
66 				  struct ieee80211_sta *sta,
67 				  struct ieee80211_supported_band *sband)
68 {
69 	struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
70 	struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
71 	struct ieee80211_sta_he_cap *he_cap = &sta->he_cap;
72 	bool vht_ena = vht_cap->vht_supported;
73 	u16 flags = 0;
74 
75 	/* get STBC flags */
76 	if (mvm->cfg->ht_params->stbc &&
77 	    (num_of_ant(iwl_mvm_get_valid_tx_ant(mvm)) > 1)) {
78 		if (he_cap->has_he && he_cap->he_cap_elem.phy_cap_info[2] &
79 				      IEEE80211_HE_PHY_CAP2_STBC_RX_UNDER_80MHZ)
80 			flags |= IWL_TLC_MNG_CFG_FLAGS_STBC_MSK;
81 		else if (vht_cap->cap & IEEE80211_VHT_CAP_RXSTBC_MASK)
82 			flags |= IWL_TLC_MNG_CFG_FLAGS_STBC_MSK;
83 		else if (ht_cap->cap & IEEE80211_HT_CAP_RX_STBC)
84 			flags |= IWL_TLC_MNG_CFG_FLAGS_STBC_MSK;
85 	}
86 
87 	if (mvm->cfg->ht_params->ldpc &&
88 	    ((ht_cap->cap & IEEE80211_HT_CAP_LDPC_CODING) ||
89 	     (vht_ena && (vht_cap->cap & IEEE80211_VHT_CAP_RXLDPC))))
90 		flags |= IWL_TLC_MNG_CFG_FLAGS_LDPC_MSK;
91 
92 	/* consider LDPC support in case of HE */
93 	if (he_cap->has_he && (he_cap->he_cap_elem.phy_cap_info[1] &
94 	    IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD))
95 		flags |= IWL_TLC_MNG_CFG_FLAGS_LDPC_MSK;
96 
97 	if (sband->iftype_data && sband->iftype_data->he_cap.has_he &&
98 	    !(sband->iftype_data->he_cap.he_cap_elem.phy_cap_info[1] &
99 	     IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD))
100 		flags &= ~IWL_TLC_MNG_CFG_FLAGS_LDPC_MSK;
101 
102 	if (he_cap->has_he &&
103 	    (he_cap->he_cap_elem.phy_cap_info[3] &
104 	     IEEE80211_HE_PHY_CAP3_DCM_MAX_CONST_RX_MASK))
105 		flags |= IWL_TLC_MNG_CFG_FLAGS_HE_DCM_NSS_1_MSK;
106 
107 	return flags;
108 }
109 
110 static
rs_fw_vht_highest_rx_mcs_index(const struct ieee80211_sta_vht_cap * vht_cap,int nss)111 int rs_fw_vht_highest_rx_mcs_index(const struct ieee80211_sta_vht_cap *vht_cap,
112 				   int nss)
113 {
114 	u16 rx_mcs = le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map) &
115 		(0x3 << (2 * (nss - 1)));
116 	rx_mcs >>= (2 * (nss - 1));
117 
118 	switch (rx_mcs) {
119 	case IEEE80211_VHT_MCS_SUPPORT_0_7:
120 		return IWL_TLC_MNG_HT_RATE_MCS7;
121 	case IEEE80211_VHT_MCS_SUPPORT_0_8:
122 		return IWL_TLC_MNG_HT_RATE_MCS8;
123 	case IEEE80211_VHT_MCS_SUPPORT_0_9:
124 		return IWL_TLC_MNG_HT_RATE_MCS9;
125 	default:
126 		WARN_ON_ONCE(1);
127 		break;
128 	}
129 
130 	return 0;
131 }
132 
133 static void
rs_fw_vht_set_enabled_rates(const struct ieee80211_sta * sta,const struct ieee80211_sta_vht_cap * vht_cap,struct iwl_tlc_config_cmd * cmd)134 rs_fw_vht_set_enabled_rates(const struct ieee80211_sta *sta,
135 			    const struct ieee80211_sta_vht_cap *vht_cap,
136 			    struct iwl_tlc_config_cmd *cmd)
137 {
138 	u16 supp;
139 	int i, highest_mcs;
140 	u8 max_nss = sta->rx_nss;
141 	struct ieee80211_vht_cap ieee_vht_cap = {
142 		.vht_cap_info = cpu_to_le32(vht_cap->cap),
143 		.supp_mcs = vht_cap->vht_mcs,
144 	};
145 
146 	/* the station support only a single receive chain */
147 	if (sta->smps_mode == IEEE80211_SMPS_STATIC)
148 		max_nss = 1;
149 
150 	for (i = 0; i < max_nss && i < IWL_TLC_NSS_MAX; i++) {
151 		int nss = i + 1;
152 
153 		highest_mcs = rs_fw_vht_highest_rx_mcs_index(vht_cap, nss);
154 		if (!highest_mcs)
155 			continue;
156 
157 		supp = BIT(highest_mcs + 1) - 1;
158 		if (sta->bandwidth == IEEE80211_STA_RX_BW_20)
159 			supp &= ~BIT(IWL_TLC_MNG_HT_RATE_MCS9);
160 
161 		cmd->ht_rates[i][IWL_TLC_HT_BW_NONE_160] = cpu_to_le16(supp);
162 		/*
163 		 * Check if VHT extended NSS indicates that the bandwidth/NSS
164 		 * configuration is supported - only for MCS 0 since we already
165 		 * decoded the MCS bits anyway ourselves.
166 		 */
167 		if (sta->bandwidth == IEEE80211_STA_RX_BW_160 &&
168 		    ieee80211_get_vht_max_nss(&ieee_vht_cap,
169 					      IEEE80211_VHT_CHANWIDTH_160MHZ,
170 					      0, true, nss) >= nss)
171 			cmd->ht_rates[i][IWL_TLC_HT_BW_160] =
172 				cmd->ht_rates[i][IWL_TLC_HT_BW_NONE_160];
173 	}
174 }
175 
rs_fw_he_ieee80211_mcs_to_rs_mcs(u16 mcs)176 static u16 rs_fw_he_ieee80211_mcs_to_rs_mcs(u16 mcs)
177 {
178 	switch (mcs) {
179 	case IEEE80211_HE_MCS_SUPPORT_0_7:
180 		return BIT(IWL_TLC_MNG_HT_RATE_MCS7 + 1) - 1;
181 	case IEEE80211_HE_MCS_SUPPORT_0_9:
182 		return BIT(IWL_TLC_MNG_HT_RATE_MCS9 + 1) - 1;
183 	case IEEE80211_HE_MCS_SUPPORT_0_11:
184 		return BIT(IWL_TLC_MNG_HT_RATE_MCS11 + 1) - 1;
185 	case IEEE80211_HE_MCS_NOT_SUPPORTED:
186 		return 0;
187 	}
188 
189 	WARN(1, "invalid HE MCS %d\n", mcs);
190 	return 0;
191 }
192 
193 static void
rs_fw_he_set_enabled_rates(const struct ieee80211_sta * sta,struct ieee80211_supported_band * sband,struct iwl_tlc_config_cmd * cmd)194 rs_fw_he_set_enabled_rates(const struct ieee80211_sta *sta,
195 			   struct ieee80211_supported_band *sband,
196 			   struct iwl_tlc_config_cmd *cmd)
197 {
198 	const struct ieee80211_sta_he_cap *he_cap = &sta->he_cap;
199 	u16 mcs_160 = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_160);
200 	u16 mcs_80 = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80);
201 	u16 tx_mcs_80 =
202 		le16_to_cpu(sband->iftype_data->he_cap.he_mcs_nss_supp.tx_mcs_80);
203 	u16 tx_mcs_160 =
204 		le16_to_cpu(sband->iftype_data->he_cap.he_mcs_nss_supp.tx_mcs_160);
205 	int i;
206 	u8 nss = sta->rx_nss;
207 
208 	/* the station support only a single receive chain */
209 	if (sta->smps_mode == IEEE80211_SMPS_STATIC)
210 		nss = 1;
211 
212 	for (i = 0; i < nss && i < IWL_TLC_NSS_MAX; i++) {
213 		u16 _mcs_160 = (mcs_160 >> (2 * i)) & 0x3;
214 		u16 _mcs_80 = (mcs_80 >> (2 * i)) & 0x3;
215 		u16 _tx_mcs_160 = (tx_mcs_160 >> (2 * i)) & 0x3;
216 		u16 _tx_mcs_80 = (tx_mcs_80 >> (2 * i)) & 0x3;
217 
218 		/* If one side doesn't support - mark both as not supporting */
219 		if (_mcs_80 == IEEE80211_HE_MCS_NOT_SUPPORTED ||
220 		    _tx_mcs_80 == IEEE80211_HE_MCS_NOT_SUPPORTED) {
221 			_mcs_80 = IEEE80211_HE_MCS_NOT_SUPPORTED;
222 			_tx_mcs_80 = IEEE80211_HE_MCS_NOT_SUPPORTED;
223 		}
224 		if (_mcs_80 > _tx_mcs_80)
225 			_mcs_80 = _tx_mcs_80;
226 		cmd->ht_rates[i][IWL_TLC_HT_BW_NONE_160] =
227 			cpu_to_le16(rs_fw_he_ieee80211_mcs_to_rs_mcs(_mcs_80));
228 
229 		/* If one side doesn't support - mark both as not supporting */
230 		if (_mcs_160 == IEEE80211_HE_MCS_NOT_SUPPORTED ||
231 		    _tx_mcs_160 == IEEE80211_HE_MCS_NOT_SUPPORTED) {
232 			_mcs_160 = IEEE80211_HE_MCS_NOT_SUPPORTED;
233 			_tx_mcs_160 = IEEE80211_HE_MCS_NOT_SUPPORTED;
234 		}
235 		if (_mcs_160 > _tx_mcs_160)
236 			_mcs_160 = _tx_mcs_160;
237 		cmd->ht_rates[i][IWL_TLC_HT_BW_160] =
238 			cpu_to_le16(rs_fw_he_ieee80211_mcs_to_rs_mcs(_mcs_160));
239 	}
240 }
241 
rs_fw_set_supp_rates(struct ieee80211_sta * sta,struct ieee80211_supported_band * sband,struct iwl_tlc_config_cmd * cmd)242 static void rs_fw_set_supp_rates(struct ieee80211_sta *sta,
243 				 struct ieee80211_supported_band *sband,
244 				 struct iwl_tlc_config_cmd *cmd)
245 {
246 	int i;
247 	u16 supp = 0;
248 	unsigned long tmp; /* must be unsigned long for for_each_set_bit */
249 	const struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
250 	const struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
251 	const struct ieee80211_sta_he_cap *he_cap = &sta->he_cap;
252 
253 	/* non HT rates */
254 	tmp = sta->supp_rates[sband->band];
255 	for_each_set_bit(i, &tmp, BITS_PER_LONG)
256 		supp |= BIT(sband->bitrates[i].hw_value);
257 
258 	cmd->non_ht_rates = cpu_to_le16(supp);
259 	cmd->mode = IWL_TLC_MNG_MODE_NON_HT;
260 
261 	/* HT/VHT rates */
262 	if (he_cap->has_he) {
263 		cmd->mode = IWL_TLC_MNG_MODE_HE;
264 		rs_fw_he_set_enabled_rates(sta, sband, cmd);
265 	} else if (vht_cap->vht_supported) {
266 		cmd->mode = IWL_TLC_MNG_MODE_VHT;
267 		rs_fw_vht_set_enabled_rates(sta, vht_cap, cmd);
268 	} else if (ht_cap->ht_supported) {
269 		cmd->mode = IWL_TLC_MNG_MODE_HT;
270 		cmd->ht_rates[IWL_TLC_NSS_1][IWL_TLC_HT_BW_NONE_160] =
271 			cpu_to_le16(ht_cap->mcs.rx_mask[0]);
272 
273 		/* the station support only a single receive chain */
274 		if (sta->smps_mode == IEEE80211_SMPS_STATIC)
275 			cmd->ht_rates[IWL_TLC_NSS_2][IWL_TLC_HT_BW_NONE_160] =
276 				0;
277 		else
278 			cmd->ht_rates[IWL_TLC_NSS_2][IWL_TLC_HT_BW_NONE_160] =
279 				cpu_to_le16(ht_cap->mcs.rx_mask[1]);
280 	}
281 }
282 
iwl_mvm_tlc_update_notif(struct iwl_mvm * mvm,struct iwl_rx_cmd_buffer * rxb)283 void iwl_mvm_tlc_update_notif(struct iwl_mvm *mvm,
284 			      struct iwl_rx_cmd_buffer *rxb)
285 {
286 	struct iwl_rx_packet *pkt = rxb_addr(rxb);
287 	struct iwl_tlc_update_notif *notif;
288 	struct ieee80211_sta *sta;
289 	struct iwl_mvm_sta *mvmsta;
290 	struct iwl_lq_sta_rs_fw *lq_sta;
291 	u32 flags;
292 
293 	rcu_read_lock();
294 
295 	notif = (void *)pkt->data;
296 	sta = rcu_dereference(mvm->fw_id_to_mac_id[notif->sta_id]);
297 	if (IS_ERR_OR_NULL(sta)) {
298 		IWL_ERR(mvm, "Invalid sta id (%d) in FW TLC notification\n",
299 			notif->sta_id);
300 		goto out;
301 	}
302 
303 	mvmsta = iwl_mvm_sta_from_mac80211(sta);
304 
305 	if (!mvmsta) {
306 		IWL_ERR(mvm, "Invalid sta id (%d) in FW TLC notification\n",
307 			notif->sta_id);
308 		goto out;
309 	}
310 
311 	flags = le32_to_cpu(notif->flags);
312 
313 	lq_sta = &mvmsta->lq_sta.rs_fw;
314 
315 	if (flags & IWL_TLC_NOTIF_FLAG_RATE) {
316 		char pretty_rate[100];
317 		lq_sta->last_rate_n_flags = le32_to_cpu(notif->rate);
318 		rs_pretty_print_rate(pretty_rate, sizeof(pretty_rate),
319 				     lq_sta->last_rate_n_flags);
320 		IWL_DEBUG_RATE(mvm, "new rate: %s\n", pretty_rate);
321 	}
322 
323 	if (flags & IWL_TLC_NOTIF_FLAG_AMSDU && !mvmsta->orig_amsdu_len) {
324 		u16 size = le32_to_cpu(notif->amsdu_size);
325 		int i;
326 
327 		if (sta->max_amsdu_len < size) {
328 			/*
329 			 * In debug sta->max_amsdu_len < size
330 			 * so also check with orig_amsdu_len which holds the
331 			 * original data before debugfs changed the value
332 			 */
333 			WARN_ON(mvmsta->orig_amsdu_len < size);
334 			goto out;
335 		}
336 
337 		mvmsta->amsdu_enabled = le32_to_cpu(notif->amsdu_enabled);
338 		mvmsta->max_amsdu_len = size;
339 		sta->max_rc_amsdu_len = mvmsta->max_amsdu_len;
340 
341 		for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
342 			if (mvmsta->amsdu_enabled & BIT(i))
343 				sta->max_tid_amsdu_len[i] =
344 					iwl_mvm_max_amsdu_size(mvm, sta, i);
345 			else
346 				/*
347 				 * Not so elegant, but this will effectively
348 				 * prevent AMSDU on this TID
349 				 */
350 				sta->max_tid_amsdu_len[i] = 1;
351 		}
352 
353 		IWL_DEBUG_RATE(mvm,
354 			       "AMSDU update. AMSDU size: %d, AMSDU selected size: %d, AMSDU TID bitmap 0x%X\n",
355 			       le32_to_cpu(notif->amsdu_size), size,
356 			       mvmsta->amsdu_enabled);
357 	}
358 out:
359 	rcu_read_unlock();
360 }
361 
rs_fw_get_max_amsdu_len(struct ieee80211_sta * sta)362 u16 rs_fw_get_max_amsdu_len(struct ieee80211_sta *sta)
363 {
364 	struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
365 	const struct ieee80211_sta_vht_cap *vht_cap = &sta->vht_cap;
366 	const struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap;
367 
368 	if (mvmsta->vif->bss_conf.chandef.chan->band == NL80211_BAND_6GHZ) {
369 		switch (le16_get_bits(sta->he_6ghz_capa.capa,
370 				      IEEE80211_HE_6GHZ_CAP_MAX_MPDU_LEN)) {
371 		case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454:
372 			return IEEE80211_MAX_MPDU_LEN_VHT_11454;
373 		case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991:
374 			return IEEE80211_MAX_MPDU_LEN_VHT_7991;
375 		default:
376 			return IEEE80211_MAX_MPDU_LEN_VHT_3895;
377 		}
378 	} else
379 	if (vht_cap->vht_supported) {
380 		switch (vht_cap->cap & IEEE80211_VHT_CAP_MAX_MPDU_MASK) {
381 		case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454:
382 			return IEEE80211_MAX_MPDU_LEN_VHT_11454;
383 		case IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991:
384 			return IEEE80211_MAX_MPDU_LEN_VHT_7991;
385 		default:
386 			return IEEE80211_MAX_MPDU_LEN_VHT_3895;
387 		}
388 	} else if (ht_cap->ht_supported) {
389 		if (ht_cap->cap & IEEE80211_HT_CAP_MAX_AMSDU)
390 			/*
391 			 * agg is offloaded so we need to assume that agg
392 			 * are enabled and max mpdu in ampdu is 4095
393 			 * (spec 802.11-2016 9.3.2.1)
394 			 */
395 			return IEEE80211_MAX_MPDU_LEN_HT_BA;
396 		else
397 			return IEEE80211_MAX_MPDU_LEN_HT_3839;
398 	}
399 
400 	/* in legacy mode no amsdu is enabled so return zero */
401 	return 0;
402 }
403 
rs_fw_rate_init(struct iwl_mvm * mvm,struct ieee80211_sta * sta,enum nl80211_band band,bool update)404 void rs_fw_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
405 		     enum nl80211_band band, bool update)
406 {
407 	struct ieee80211_hw *hw = mvm->hw;
408 	struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
409 	struct iwl_lq_sta_rs_fw *lq_sta = &mvmsta->lq_sta.rs_fw;
410 	u32 cmd_id = iwl_cmd_id(TLC_MNG_CONFIG_CMD, DATA_PATH_GROUP, 0);
411 	struct ieee80211_supported_band *sband = hw->wiphy->bands[band];
412 	u16 max_amsdu_len = rs_fw_get_max_amsdu_len(sta);
413 	struct iwl_tlc_config_cmd cfg_cmd = {
414 		.sta_id = mvmsta->sta_id,
415 		.max_ch_width = update ?
416 			rs_fw_bw_from_sta_bw(sta) : RATE_MCS_CHAN_WIDTH_20,
417 		.flags = cpu_to_le16(rs_fw_get_config_flags(mvm, sta, sband)),
418 		.chains = rs_fw_set_active_chains(iwl_mvm_get_valid_tx_ant(mvm)),
419 		.sgi_ch_width_supp = rs_fw_sgi_cw_support(sta),
420 		.max_mpdu_len = cpu_to_le16(max_amsdu_len),
421 		.amsdu = iwl_mvm_is_csum_supported(mvm),
422 	};
423 	int ret;
424 	u16 cmd_size = sizeof(cfg_cmd);
425 
426 	/* In old versions of the API the struct is 4 bytes smaller */
427 	if (iwl_fw_lookup_cmd_ver(mvm->fw, DATA_PATH_GROUP,
428 				  TLC_MNG_CONFIG_CMD, 0) < 3)
429 		cmd_size -= 4;
430 
431 	memset(lq_sta, 0, offsetof(typeof(*lq_sta), pers));
432 
433 #ifdef CONFIG_IWLWIFI_DEBUGFS
434 	iwl_mvm_reset_frame_stats(mvm);
435 #endif
436 	rs_fw_set_supp_rates(sta, sband, &cfg_cmd);
437 
438 	/*
439 	 * since TLC offload works with one mode we can assume
440 	 * that only vht/ht is used and also set it as station max amsdu
441 	 */
442 	sta->max_amsdu_len = max_amsdu_len;
443 
444 	ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, CMD_ASYNC, cmd_size,
445 				   &cfg_cmd);
446 	if (ret)
447 		IWL_ERR(mvm, "Failed to send rate scale config (%d)\n", ret);
448 }
449 
rs_fw_tx_protection(struct iwl_mvm * mvm,struct iwl_mvm_sta * mvmsta,bool enable)450 int rs_fw_tx_protection(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta,
451 			bool enable)
452 {
453 	/* TODO: need to introduce a new FW cmd since LQ cmd is not relevant */
454 	IWL_DEBUG_RATE(mvm, "tx protection - not implemented yet.\n");
455 	return 0;
456 }
457 
iwl_mvm_rs_add_sta(struct iwl_mvm * mvm,struct iwl_mvm_sta * mvmsta)458 void iwl_mvm_rs_add_sta(struct iwl_mvm *mvm, struct iwl_mvm_sta *mvmsta)
459 {
460 	struct iwl_lq_sta_rs_fw *lq_sta = &mvmsta->lq_sta.rs_fw;
461 
462 	IWL_DEBUG_RATE(mvm, "create station rate scale window\n");
463 
464 	lq_sta->pers.drv = mvm;
465 	lq_sta->pers.sta_id = mvmsta->sta_id;
466 	lq_sta->pers.chains = 0;
467 	memset(lq_sta->pers.chain_signal, 0, sizeof(lq_sta->pers.chain_signal));
468 	lq_sta->pers.last_rssi = S8_MIN;
469 	lq_sta->last_rate_n_flags = 0;
470 
471 #ifdef CONFIG_MAC80211_DEBUGFS
472 	lq_sta->pers.dbg_fixed_rate = 0;
473 #endif
474 }
475