Skip to content

Commit ae4c1bb

Browse files
gomordlucacoelho
authored andcommitted
iwlwifi: rs: add support for TLC config command ver 4
The new version enables support for EHT mode configurations. The name of IWL_TLC_HT_BW_NONE_160 change to IWL_TLC_MCS_PER_BW_80 to make the difference from 80 bandwidth (non 160), and the new bandwidth 320 which is also non 160. Signed-off-by: Mordechay Goodstein <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Link: https://lore.kernel.org/r/iwlwifi.20211210090244.7d1a57f3df1b.Ibc01dde2b064329ad5f5bcefa83d1998d557cbdb@changeid Signed-off-by: Luca Coelho <[email protected]>
1 parent 5c3310c commit ae4c1bb

File tree

2 files changed

+99
-29
lines changed

2 files changed

+99
-29
lines changed

drivers/net/wireless/intel/iwlwifi/fw/api/rs.h

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,20 @@ enum IWL_TLC_MNG_NSS {
116116
IWL_TLC_NSS_MAX
117117
};
118118

119-
enum IWL_TLC_HT_BW_RATES {
120-
IWL_TLC_HT_BW_NONE_160,
121-
IWL_TLC_HT_BW_160,
119+
/**
120+
* enum IWL_TLC_MCS_PER_BW - mcs index per BW
121+
* @IWL_TLC_MCS_PER_BW_80: mcs for bw - 20Hhz, 40Hhz, 80Hhz
122+
* @IWL_TLC_MCS_PER_BW_160: mcs for bw - 160Mhz
123+
* @IWL_TLC_MCS_PER_BW_320: mcs for bw - 320Mhz
124+
* @IWL_TLC_MCS_PER_BW_NUM_V3: number of entries up to version 3
125+
* @IWL_TLC_MCS_PER_BW_NUM_V4: number of entries from version 4
126+
*/
127+
enum IWL_TLC_MCS_PER_BW {
128+
IWL_TLC_MCS_PER_BW_80,
129+
IWL_TLC_MCS_PER_BW_160,
130+
IWL_TLC_MCS_PER_BW_320,
131+
IWL_TLC_MCS_PER_BW_NUM_V3 = IWL_TLC_MCS_PER_BW_160 + 1,
132+
IWL_TLC_MCS_PER_BW_NUM_V4 = IWL_TLC_MCS_PER_BW_320 + 1,
122133
};
123134

124135
/**
@@ -131,16 +142,16 @@ enum IWL_TLC_HT_BW_RATES {
131142
* @amsdu: TX amsdu is supported
132143
* @flags: bitmask of &enum iwl_tlc_mng_cfg_flags
133144
* @non_ht_rates: bitmap of supported legacy rates
134-
* @ht_rates: bitmap of &enum iwl_tlc_mng_ht_rates, per <nss, channel-width>
135-
* pair (0 - 80mhz width and below, 1 - 160mhz).
145+
* @ht_rates: bitmap of &enum iwl_tlc_mng_ht_rates, per &enum IWL_TLC_MCS_PER_BW
146+
* <nss, channel-width> pair (0 - 80mhz width and below, 1 - 160mhz).
136147
* @max_mpdu_len: max MPDU length, in bytes
137148
* @sgi_ch_width_supp: bitmap of SGI support per channel width
138149
* use BIT(@enum iwl_tlc_mng_cfg_cw)
139150
* @reserved2: reserved
140151
* @max_tx_op: max TXOP in uSecs for all AC (BK, BE, VO, VI),
141152
* set zero for no limit.
142153
*/
143-
struct iwl_tlc_config_cmd {
154+
struct iwl_tlc_config_cmd_v3 {
144155
u8 sta_id;
145156
u8 reserved1[3];
146157
u8 max_ch_width;
@@ -149,13 +160,44 @@ struct iwl_tlc_config_cmd {
149160
u8 amsdu;
150161
__le16 flags;
151162
__le16 non_ht_rates;
152-
__le16 ht_rates[IWL_TLC_NSS_MAX][2];
163+
__le16 ht_rates[IWL_TLC_NSS_MAX][IWL_TLC_MCS_PER_BW_NUM_V3];
153164
__le16 max_mpdu_len;
154165
u8 sgi_ch_width_supp;
155166
u8 reserved2;
156167
__le32 max_tx_op;
157168
} __packed; /* TLC_MNG_CONFIG_CMD_API_S_VER_3 */
158169

170+
/**
171+
* struct tlc_config_cmd - TLC configuration
172+
* @sta_id: station id
173+
* @reserved1: reserved
174+
* @max_ch_width: max supported channel width from &enum iwl_tlc_mng_cfg_cw
175+
* @mode: &enum iwl_tlc_mng_cfg_mode
176+
* @chains: bitmask of &enum iwl_tlc_mng_cfg_chains
177+
* @sgi_ch_width_supp: bitmap of SGI support per channel width
178+
* use BIT(&enum iwl_tlc_mng_cfg_cw)
179+
* @flags: bitmask of &enum iwl_tlc_mng_cfg_flags
180+
* @non_ht_rates: bitmap of supported legacy rates
181+
* @ht_rates: bitmap of &enum iwl_tlc_mng_ht_rates, per <nss, channel-width>
182+
* pair (0 - 80mhz width and below, 1 - 160mhz, 2 - 320mhz).
183+
* @max_mpdu_len: max MPDU length, in bytes
184+
* @max_tx_op: max TXOP in uSecs for all AC (BK, BE, VO, VI),
185+
* set zero for no limit.
186+
*/
187+
struct iwl_tlc_config_cmd_v4 {
188+
u8 sta_id;
189+
u8 reserved1[3];
190+
u8 max_ch_width;
191+
u8 mode;
192+
u8 chains;
193+
u8 sgi_ch_width_supp;
194+
__le16 flags;
195+
__le16 non_ht_rates;
196+
__le16 ht_rates[IWL_TLC_NSS_MAX][IWL_TLC_MCS_PER_BW_NUM_V4];
197+
__le16 max_mpdu_len;
198+
__le16 max_tx_op;
199+
} __packed; /* TLC_MNG_CONFIG_CMD_API_S_VER_4 */
200+
159201
/**
160202
* enum iwl_tlc_update_flags - updated fields
161203
* @IWL_TLC_NOTIF_FLAG_RATE: last initial rate update

drivers/net/wireless/intel/iwlwifi/mvm/rs-fw.c

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ int rs_fw_vht_highest_rx_mcs_index(const struct ieee80211_sta_vht_cap *vht_cap,
129129
static void
130130
rs_fw_vht_set_enabled_rates(const struct ieee80211_sta *sta,
131131
const struct ieee80211_sta_vht_cap *vht_cap,
132-
struct iwl_tlc_config_cmd *cmd)
132+
struct iwl_tlc_config_cmd_v4 *cmd)
133133
{
134134
u16 supp;
135135
int i, highest_mcs;
@@ -154,7 +154,7 @@ rs_fw_vht_set_enabled_rates(const struct ieee80211_sta *sta,
154154
if (sta->bandwidth == IEEE80211_STA_RX_BW_20)
155155
supp &= ~BIT(IWL_TLC_MNG_HT_RATE_MCS9);
156156

157-
cmd->ht_rates[i][IWL_TLC_HT_BW_NONE_160] = cpu_to_le16(supp);
157+
cmd->ht_rates[i][IWL_TLC_MCS_PER_BW_80] = cpu_to_le16(supp);
158158
/*
159159
* Check if VHT extended NSS indicates that the bandwidth/NSS
160160
* configuration is supported - only for MCS 0 since we already
@@ -164,8 +164,8 @@ rs_fw_vht_set_enabled_rates(const struct ieee80211_sta *sta,
164164
ieee80211_get_vht_max_nss(&ieee_vht_cap,
165165
IEEE80211_VHT_CHANWIDTH_160MHZ,
166166
0, true, nss) >= nss)
167-
cmd->ht_rates[i][IWL_TLC_HT_BW_160] =
168-
cmd->ht_rates[i][IWL_TLC_HT_BW_NONE_160];
167+
cmd->ht_rates[i][IWL_TLC_MCS_PER_BW_160] =
168+
cmd->ht_rates[i][IWL_TLC_MCS_PER_BW_80];
169169
}
170170
}
171171

@@ -189,7 +189,7 @@ static u16 rs_fw_he_ieee80211_mcs_to_rs_mcs(u16 mcs)
189189
static void
190190
rs_fw_he_set_enabled_rates(const struct ieee80211_sta *sta,
191191
struct ieee80211_supported_band *sband,
192-
struct iwl_tlc_config_cmd *cmd)
192+
struct iwl_tlc_config_cmd_v4 *cmd)
193193
{
194194
const struct ieee80211_sta_he_cap *he_cap = &sta->he_cap;
195195
u16 mcs_160 = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_160);
@@ -219,7 +219,7 @@ rs_fw_he_set_enabled_rates(const struct ieee80211_sta *sta,
219219
}
220220
if (_mcs_80 > _tx_mcs_80)
221221
_mcs_80 = _tx_mcs_80;
222-
cmd->ht_rates[i][IWL_TLC_HT_BW_NONE_160] =
222+
cmd->ht_rates[i][IWL_TLC_MCS_PER_BW_80] =
223223
cpu_to_le16(rs_fw_he_ieee80211_mcs_to_rs_mcs(_mcs_80));
224224

225225
/* If one side doesn't support - mark both as not supporting */
@@ -230,14 +230,14 @@ rs_fw_he_set_enabled_rates(const struct ieee80211_sta *sta,
230230
}
231231
if (_mcs_160 > _tx_mcs_160)
232232
_mcs_160 = _tx_mcs_160;
233-
cmd->ht_rates[i][IWL_TLC_HT_BW_160] =
233+
cmd->ht_rates[i][IWL_TLC_MCS_PER_BW_160] =
234234
cpu_to_le16(rs_fw_he_ieee80211_mcs_to_rs_mcs(_mcs_160));
235235
}
236236
}
237237

238238
static void rs_fw_set_supp_rates(struct ieee80211_sta *sta,
239239
struct ieee80211_supported_band *sband,
240-
struct iwl_tlc_config_cmd *cmd)
240+
struct iwl_tlc_config_cmd_v4 *cmd)
241241
{
242242
int i;
243243
u16 supp = 0;
@@ -263,15 +263,15 @@ static void rs_fw_set_supp_rates(struct ieee80211_sta *sta,
263263
rs_fw_vht_set_enabled_rates(sta, vht_cap, cmd);
264264
} else if (ht_cap->ht_supported) {
265265
cmd->mode = IWL_TLC_MNG_MODE_HT;
266-
cmd->ht_rates[IWL_TLC_NSS_1][IWL_TLC_HT_BW_NONE_160] =
266+
cmd->ht_rates[IWL_TLC_NSS_1][IWL_TLC_MCS_PER_BW_80] =
267267
cpu_to_le16(ht_cap->mcs.rx_mask[0]);
268268

269269
/* the station support only a single receive chain */
270270
if (sta->smps_mode == IEEE80211_SMPS_STATIC)
271-
cmd->ht_rates[IWL_TLC_NSS_2][IWL_TLC_HT_BW_NONE_160] =
271+
cmd->ht_rates[IWL_TLC_NSS_2][IWL_TLC_MCS_PER_BW_80] =
272272
0;
273273
else
274-
cmd->ht_rates[IWL_TLC_NSS_2][IWL_TLC_HT_BW_NONE_160] =
274+
cmd->ht_rates[IWL_TLC_NSS_2][IWL_TLC_MCS_PER_BW_80] =
275275
cpu_to_le16(ht_cap->mcs.rx_mask[1]);
276276
}
277277
}
@@ -423,23 +423,18 @@ void rs_fw_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
423423
u32 cmd_id = iwl_cmd_id(TLC_MNG_CONFIG_CMD, DATA_PATH_GROUP, 0);
424424
struct ieee80211_supported_band *sband = hw->wiphy->bands[band];
425425
u16 max_amsdu_len = rs_fw_get_max_amsdu_len(sta);
426-
struct iwl_tlc_config_cmd cfg_cmd = {
426+
struct iwl_tlc_config_cmd_v4 cfg_cmd = {
427427
.sta_id = mvmsta->sta_id,
428428
.max_ch_width = update ?
429429
rs_fw_bw_from_sta_bw(sta) : RATE_MCS_CHAN_WIDTH_20,
430430
.flags = cpu_to_le16(rs_fw_get_config_flags(mvm, sta, sband)),
431431
.chains = rs_fw_set_active_chains(iwl_mvm_get_valid_tx_ant(mvm)),
432432
.sgi_ch_width_supp = rs_fw_sgi_cw_support(sta),
433-
.max_mpdu_len = cpu_to_le16(max_amsdu_len),
434-
.amsdu = iwl_mvm_is_csum_supported(mvm),
433+
.max_mpdu_len = iwl_mvm_is_csum_supported(mvm) ?
434+
cpu_to_le16(max_amsdu_len) : 0,
435435
};
436436
int ret;
437-
u16 cmd_size = sizeof(cfg_cmd);
438-
439-
/* In old versions of the API the struct is 4 bytes smaller */
440-
if (iwl_fw_lookup_cmd_ver(mvm->fw, DATA_PATH_GROUP,
441-
TLC_MNG_CONFIG_CMD, 0) < 3)
442-
cmd_size -= 4;
437+
int cmd_ver;
443438

444439
memset(lq_sta, 0, offsetof(typeof(*lq_sta), pers));
445440

@@ -454,8 +449,41 @@ void rs_fw_rate_init(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
454449
*/
455450
sta->max_amsdu_len = max_amsdu_len;
456451

457-
ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, CMD_ASYNC, cmd_size,
458-
&cfg_cmd);
452+
cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, DATA_PATH_GROUP,
453+
TLC_MNG_CONFIG_CMD, 0);
454+
if (cmd_ver == 4) {
455+
ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, CMD_ASYNC,
456+
sizeof(cfg_cmd), &cfg_cmd);
457+
} else if (cmd_ver < 4) {
458+
struct iwl_tlc_config_cmd_v3 cfg_cmd_v3 = {
459+
.sta_id = cfg_cmd.sta_id,
460+
.max_ch_width = cfg_cmd.max_ch_width,
461+
.mode = cfg_cmd.mode,
462+
.chains = cfg_cmd.chains,
463+
.amsdu = !!cfg_cmd.max_mpdu_len,
464+
.flags = cfg_cmd.flags,
465+
.non_ht_rates = cfg_cmd.non_ht_rates,
466+
.ht_rates[0][0] = cfg_cmd.ht_rates[0][0],
467+
.ht_rates[0][1] = cfg_cmd.ht_rates[0][1],
468+
.ht_rates[1][0] = cfg_cmd.ht_rates[1][0],
469+
.ht_rates[1][1] = cfg_cmd.ht_rates[1][1],
470+
.sgi_ch_width_supp = cfg_cmd.sgi_ch_width_supp,
471+
.max_mpdu_len = cfg_cmd.max_mpdu_len,
472+
};
473+
474+
u16 cmd_size = sizeof(cfg_cmd_v3);
475+
476+
/* In old versions of the API the struct is 4 bytes smaller */
477+
if (iwl_fw_lookup_cmd_ver(mvm->fw, DATA_PATH_GROUP,
478+
TLC_MNG_CONFIG_CMD, 0) < 3)
479+
cmd_size -= 4;
480+
481+
ret = iwl_mvm_send_cmd_pdu(mvm, cmd_id, CMD_ASYNC, cmd_size,
482+
&cfg_cmd_v3);
483+
} else {
484+
ret = -EINVAL;
485+
}
486+
459487
if (ret)
460488
IWL_ERR(mvm, "Failed to send rate scale config (%d)\n", ret);
461489
}

0 commit comments

Comments
 (0)