Skip to content

Commit cacc1d4

Browse files
ggreenmajmberg-intel
authored andcommitted
wifi: iwlwifi: mvm: add link_conf parameter for add/remove/change link
Add link_conf parameter and change all the relevant calls accordingly. Signed-off-by: Gregory Greenman <[email protected]> Link: https://lore.kernel.org/r/20230328104949.374015eed2e3.Icbf15a18e2599b53f4fa1c92fe3db64b551b84b1@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent ac251da commit cacc1d4

File tree

5 files changed

+118
-74
lines changed

5 files changed

+118
-74
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/link.c

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,94 +20,111 @@ static int iwl_mvm_link_cmd_send(struct iwl_mvm *mvm,
2020
return ret;
2121
}
2222

23-
int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
23+
int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
24+
struct ieee80211_bss_conf *link_conf)
2425
{
2526
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
26-
struct iwl_mvm_phy_ctxt *phyctxt = mvmvif->deflink.phy_ctxt;
27+
unsigned int link_id = link_conf->link_id;
2728
struct iwl_link_config_cmd cmd = {};
29+
struct iwl_mvm_phy_ctxt *phyctxt;
30+
31+
if (WARN_ON_ONCE(!mvmvif->link[link_id]))
32+
return -EINVAL;
2833

2934
/* Update SF - Disable if needed. if this fails, SF might still be on
3035
* while many macs are bound, which is forbidden - so fail the binding.
3136
*/
3237
if (iwl_mvm_sf_update(mvm, vif, false))
3338
return -EINVAL;
3439

40+
/* FIXME: add proper link id allocation */
3541
cmd.link_id = cpu_to_le32(mvmvif->id);
3642
cmd.mac_id = cpu_to_le32(mvmvif->id);
3743
/* P2P-Device already has a valid PHY context during add */
44+
phyctxt = mvmvif->link[link_id]->phy_ctxt;
3845
if (phyctxt)
3946
cmd.phy_id = cpu_to_le32(phyctxt->id);
4047
else
4148
cmd.phy_id = cpu_to_le32(FW_CTXT_INVALID);
4249

43-
memcpy(cmd.local_link_addr, vif->addr, ETH_ALEN);
50+
memcpy(cmd.local_link_addr, link_conf->addr, ETH_ALEN);
4451

45-
if (vif->type == NL80211_IFTYPE_ADHOC && vif->bss_conf.bssid)
46-
memcpy(cmd.ibss_bssid_addr, vif->bss_conf.bssid, ETH_ALEN);
52+
if (vif->type == NL80211_IFTYPE_ADHOC && link_conf->bssid)
53+
memcpy(cmd.ibss_bssid_addr, link_conf->bssid, ETH_ALEN);
4754

4855
return iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_ADD);
4956
}
5057

5158
int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
59+
struct ieee80211_bss_conf *link_conf,
5260
u32 changes, bool active)
5361
{
5462
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
55-
struct iwl_mvm_phy_ctxt *phyctxt = mvmvif->deflink.phy_ctxt;
63+
unsigned int link_id = link_conf->link_id;
64+
struct iwl_mvm_phy_ctxt *phyctxt;
5665
struct iwl_link_config_cmd cmd = {};
5766
u32 ht_flag, flags = 0, flags_mask = 0;
5867

68+
if (WARN_ON_ONCE(!mvmvif->link[link_id]))
69+
return -EINVAL;
70+
71+
/* FIXME: add proper link id allocation */
5972
cmd.link_id = cpu_to_le32(mvmvif->id);
6073

6174
/* The phy_id, link address and listen_lmac can be modified only until
6275
* the link becomes active, otherwise they will be ignored.
6376
*/
77+
phyctxt = mvmvif->link[link_id]->phy_ctxt;
6478
if (phyctxt)
6579
cmd.phy_id = cpu_to_le32(phyctxt->id);
6680
else
6781
cmd.phy_id = cpu_to_le32(FW_CTXT_INVALID);
6882
cmd.mac_id = cpu_to_le32(mvmvif->id);
6983

70-
memcpy(cmd.local_link_addr, vif->addr, ETH_ALEN);
84+
memcpy(cmd.local_link_addr, link_conf->addr, ETH_ALEN);
7185

7286
cmd.active = cpu_to_le32(active);
7387

74-
if (vif->type == NL80211_IFTYPE_ADHOC && vif->bss_conf.bssid)
75-
memcpy(cmd.ibss_bssid_addr, vif->bss_conf.bssid, ETH_ALEN);
88+
if (vif->type == NL80211_IFTYPE_ADHOC && link_conf->bssid)
89+
memcpy(cmd.ibss_bssid_addr, link_conf->bssid, ETH_ALEN);
7690

7791
/* TODO: set a value to cmd.listen_lmac when system requiremens
7892
* will define it
7993
*/
8094

81-
iwl_mvm_set_fw_basic_rates(mvm, vif, &cmd.cck_rates, &cmd.ofdm_rates);
95+
iwl_mvm_set_fw_basic_rates(mvm, vif, link_conf,
96+
&cmd.cck_rates, &cmd.ofdm_rates);
8297

83-
cmd.cck_short_preamble = cpu_to_le32(vif->bss_conf.use_short_preamble);
84-
cmd.short_slot = cpu_to_le32(vif->bss_conf.use_short_slot);
98+
cmd.cck_short_preamble = cpu_to_le32(link_conf->use_short_preamble);
99+
cmd.short_slot = cpu_to_le32(link_conf->use_short_slot);
85100

86101
/* The fw does not distinguish between ht and fat */
87102
ht_flag = LINK_PROT_FLG_HT_PROT | LINK_PROT_FLG_FAT_PROT;
88-
iwl_mvm_set_fw_protection_flags(mvm, vif, &cmd.protection_flags,
103+
iwl_mvm_set_fw_protection_flags(mvm, vif, link_conf,
104+
&cmd.protection_flags,
89105
ht_flag, LINK_PROT_FLG_TGG_PROTECT);
90106

91-
iwl_mvm_set_fw_qos_params(mvm, vif, &cmd.ac[0], &cmd.qos_flags);
107+
iwl_mvm_set_fw_qos_params(mvm, vif, link_conf, &cmd.ac[0],
108+
&cmd.qos_flags);
92109

93110

94-
cmd.bi = cpu_to_le32(vif->bss_conf.beacon_int);
95-
cmd.dtim_interval = cpu_to_le32(vif->bss_conf.beacon_int *
96-
vif->bss_conf.dtim_period);
111+
cmd.bi = cpu_to_le32(link_conf->beacon_int);
112+
cmd.dtim_interval = cpu_to_le32(link_conf->beacon_int *
113+
link_conf->dtim_period);
97114

98-
if (!vif->bss_conf.he_support || iwlwifi_mod_params.disable_11ax ||
115+
if (!link_conf->he_support || iwlwifi_mod_params.disable_11ax ||
99116
!vif->cfg.assoc) {
100117
changes &= ~LINK_CONTEXT_MODIFY_HE_PARAMS;
101118
goto send_cmd;
102119
}
103120

104-
cmd.htc_trig_based_pkt_ext = vif->bss_conf.htc_trig_based_pkt_ext;
121+
cmd.htc_trig_based_pkt_ext = link_conf->htc_trig_based_pkt_ext;
105122

106-
if (vif->bss_conf.uora_exists) {
123+
if (link_conf->uora_exists) {
107124
cmd.rand_alloc_ecwmin =
108-
vif->bss_conf.uora_ocw_range & 0x7;
125+
link_conf->uora_ocw_range & 0x7;
109126
cmd.rand_alloc_ecwmax =
110-
(vif->bss_conf.uora_ocw_range >> 3) & 0x7;
127+
(link_conf->uora_ocw_range >> 3) & 0x7;
111128
}
112129

113130
/* TODO how to set ndp_fdbk_buff_th_exp? */
@@ -118,31 +135,31 @@ int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
118135
flags_mask |= LINK_FLG_MU_EDCA_CW;
119136
}
120137

121-
if (vif->bss_conf.eht_puncturing && !iwlwifi_mod_params.disable_11be)
122-
cmd.puncture_mask = cpu_to_le16(vif->bss_conf.eht_puncturing);
138+
if (link_conf->eht_puncturing && !iwlwifi_mod_params.disable_11be)
139+
cmd.puncture_mask = cpu_to_le16(link_conf->eht_puncturing);
123140
else
124141
/* This flag can be set only if the MAC has eht support */
125142
changes &= ~LINK_CONTEXT_MODIFY_EHT_PARAMS;
126143

127-
cmd.bss_color = vif->bss_conf.he_bss_color.color;
144+
cmd.bss_color = link_conf->he_bss_color.color;
128145

129-
if (!vif->bss_conf.he_bss_color.enabled) {
146+
if (!link_conf->he_bss_color.enabled) {
130147
flags |= LINK_FLG_BSS_COLOR_DIS;
131148
flags_mask |= LINK_FLG_BSS_COLOR_DIS;
132149
}
133150

134-
cmd.frame_time_rts_th = cpu_to_le16(vif->bss_conf.frame_time_rts_th);
151+
cmd.frame_time_rts_th = cpu_to_le16(link_conf->frame_time_rts_th);
135152

136153
/* Block 26-tone RU OFDMA transmissions */
137154
if (mvmvif->deflink.he_ru_2mhz_block) {
138155
flags |= LINK_FLG_RU_2MHZ_BLOCK;
139156
flags_mask |= LINK_FLG_RU_2MHZ_BLOCK;
140157
}
141158

142-
if (vif->bss_conf.nontransmitted) {
159+
if (link_conf->nontransmitted) {
143160
ether_addr_copy(cmd.ref_bssid_addr,
144-
vif->bss_conf.transmitter_bssid);
145-
cmd.bssid_index = vif->bss_conf.bssid_index;
161+
link_conf->transmitter_bssid);
162+
cmd.bssid_index = link_conf->bssid_index;
146163
}
147164

148165
send_cmd:
@@ -153,12 +170,14 @@ int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
153170
return iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_MODIFY);
154171
}
155172

156-
int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif)
173+
int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
174+
struct ieee80211_bss_conf *link_conf)
157175
{
158176
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
159177
struct iwl_link_config_cmd cmd = {};
160178
int ret;
161179

180+
/* FIXME: add proper link id allocation */
162181
cmd.link_id = cpu_to_le32(mvmvif->id);
163182
ret = iwl_mvm_link_cmd_send(mvm, &cmd, FW_CTXT_ACTION_REMOVE);
164183

drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -397,16 +397,18 @@ static void iwl_mvm_ack_rates(struct iwl_mvm *mvm,
397397
}
398398

399399
void iwl_mvm_set_fw_basic_rates(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
400+
struct ieee80211_bss_conf *link_conf,
400401
__le32 *cck_rates, __le32 *ofdm_rates)
401402
{
402403
struct ieee80211_chanctx_conf *chanctx;
403-
u8 cck_ack_rates, ofdm_ack_rates;
404+
u8 cck_ack_rates = 0, ofdm_ack_rates = 0;
404405

405406
rcu_read_lock();
406-
chanctx = rcu_dereference(vif->bss_conf.chanctx_conf);
407+
chanctx = rcu_dereference(link_conf->chanctx_conf);
407408
iwl_mvm_ack_rates(mvm, vif, chanctx ? chanctx->def.chan->band
408409
: NL80211_BAND_2GHZ,
409410
&cck_ack_rates, &ofdm_ack_rates);
411+
410412
rcu_read_unlock();
411413

412414
*cck_rates = cpu_to_le32((u32)cck_ack_rates);
@@ -415,21 +417,22 @@ void iwl_mvm_set_fw_basic_rates(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
415417

416418
void iwl_mvm_set_fw_protection_flags(struct iwl_mvm *mvm,
417419
struct ieee80211_vif *vif,
420+
struct ieee80211_bss_conf *link_conf,
418421
__le32 *protection_flags, u32 ht_flag,
419422
u32 tgg_flag)
420423
{
421424
/* for both sta and ap, ht_operation_mode hold the protection_mode */
422-
u8 protection_mode = vif->bss_conf.ht_operation_mode &
425+
u8 protection_mode = link_conf->ht_operation_mode &
423426
IEEE80211_HT_OP_MODE_PROTECTION;
424-
bool ht_enabled = !!(vif->bss_conf.ht_operation_mode &
427+
bool ht_enabled = !!(link_conf->ht_operation_mode &
425428
IEEE80211_HT_OP_MODE_PROTECTION);
426429

427-
if (vif->bss_conf.use_cts_prot)
430+
if (link_conf->use_cts_prot)
428431
*protection_flags |= cpu_to_le32(tgg_flag);
429432

430433
IWL_DEBUG_RATE(mvm, "use_cts_prot %d, ht_operation_mode %d\n",
431-
vif->bss_conf.use_cts_prot,
432-
vif->bss_conf.ht_operation_mode);
434+
link_conf->use_cts_prot,
435+
link_conf->ht_operation_mode);
433436

434437
if (!ht_enabled)
435438
return;
@@ -448,7 +451,7 @@ void iwl_mvm_set_fw_protection_flags(struct iwl_mvm *mvm,
448451
break;
449452
case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
450453
/* Protect when channel wider than 20MHz */
451-
if (vif->bss_conf.chandef.width > NL80211_CHAN_WIDTH_20)
454+
if (link_conf->chandef.width > NL80211_CHAN_WIDTH_20)
452455
*protection_flags |= cpu_to_le32(ht_flag);
453456
break;
454457
default:
@@ -459,6 +462,7 @@ void iwl_mvm_set_fw_protection_flags(struct iwl_mvm *mvm,
459462
}
460463

461464
void iwl_mvm_set_fw_qos_params(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
465+
struct ieee80211_bss_conf *link_conf,
462466
struct iwl_ac_qos *ac, __le32 *qos_flags)
463467
{
464468
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
@@ -478,10 +482,10 @@ void iwl_mvm_set_fw_qos_params(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
478482
ac[ucode_ac].fifos_mask = BIT(txf);
479483
}
480484

481-
if (vif->bss_conf.qos)
485+
if (link_conf->qos)
482486
*qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA);
483487

484-
if (vif->bss_conf.chandef.width != NL80211_CHAN_WIDTH_20_NOHT)
488+
if (link_conf->chandef.width != NL80211_CHAN_WIDTH_20_NOHT)
485489
*qos_flags |= cpu_to_le32(MAC_QOS_FLG_TGN);
486490
}
487491

@@ -538,7 +542,7 @@ static void iwl_mvm_mac_ctxt_cmd_common(struct iwl_mvm *mvm,
538542
else
539543
eth_broadcast_addr(cmd->bssid_addr);
540544

541-
iwl_mvm_set_fw_basic_rates(mvm, vif, &cmd->cck_rates,
545+
iwl_mvm_set_fw_basic_rates(mvm, vif, &vif->bss_conf, &cmd->cck_rates,
542546
&cmd->ofdm_rates);
543547

544548
cmd->cck_short_preamble =
@@ -550,11 +554,13 @@ static void iwl_mvm_mac_ctxt_cmd_common(struct iwl_mvm *mvm,
550554

551555
cmd->filter_flags = 0;
552556

553-
iwl_mvm_set_fw_qos_params(mvm, vif, &cmd->ac[0], &cmd->qos_flags);
557+
iwl_mvm_set_fw_qos_params(mvm, vif, &vif->bss_conf, &cmd->ac[0],
558+
&cmd->qos_flags);
554559

555560
/* The fw does not distinguish between ht and fat */
556561
ht_flag = MAC_PROT_FLG_HT_PROT | MAC_PROT_FLG_FAT_PROT;
557-
iwl_mvm_set_fw_protection_flags(mvm, vif, &cmd->protection_flags,
562+
iwl_mvm_set_fw_protection_flags(mvm, vif, &vif->bss_conf,
563+
&cmd->protection_flags,
558564
ht_flag, MAC_PROT_FLG_TGG_PROTECT);
559565
}
560566

@@ -570,6 +576,7 @@ static int iwl_mvm_mac_ctxt_send_cmd(struct iwl_mvm *mvm,
570576
}
571577

572578
void iwl_mvm_set_fw_dtim_tbtt(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
579+
struct ieee80211_bss_conf *link_conf,
573580
__le64 *dtim_tsf, __le32 *dtim_time,
574581
__le32 *assoc_beacon_arrive_time)
575582
{
@@ -590,17 +597,17 @@ void iwl_mvm_set_fw_dtim_tbtt(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
590597
* 384us in the longest case), this is currently not relevant
591598
* as the firmware wakes up around 2ms before the TBTT.
592599
*/
593-
dtim_offs = vif->bss_conf.sync_dtim_count *
594-
vif->bss_conf.beacon_int;
600+
dtim_offs = link_conf->sync_dtim_count *
601+
link_conf->beacon_int;
595602
/* convert TU to usecs */
596603
dtim_offs *= 1024;
597604

598605
*dtim_tsf =
599-
cpu_to_le64(vif->bss_conf.sync_tsf + dtim_offs);
606+
cpu_to_le64(link_conf->sync_tsf + dtim_offs);
600607
*dtim_time =
601-
cpu_to_le32(vif->bss_conf.sync_device_ts + dtim_offs);
608+
cpu_to_le32(link_conf->sync_device_ts + dtim_offs);
602609
*assoc_beacon_arrive_time =
603-
cpu_to_le32(vif->bss_conf.sync_device_ts);
610+
cpu_to_le32(link_conf->sync_device_ts);
604611

605612
IWL_DEBUG_INFO(mvm, "DTIM TBTT is 0x%llx/0x%x, offset %d\n",
606613
le64_to_cpu(*dtim_tsf),
@@ -666,7 +673,8 @@ static int iwl_mvm_mac_ctxt_cmd_sta(struct iwl_mvm *mvm,
666673
!force_assoc_off) {
667674
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
668675

669-
iwl_mvm_set_fw_dtim_tbtt(mvm, vif, &ctxt_sta->dtim_tsf,
676+
iwl_mvm_set_fw_dtim_tbtt(mvm, vif, &vif->bss_conf,
677+
&ctxt_sta->dtim_tsf,
670678
&ctxt_sta->dtim_time,
671679
&ctxt_sta->assoc_beacon_arrive_time);
672680

drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3619,7 +3619,7 @@ int iwl_mvm_mac_sta_state_common(struct ieee80211_hw *hw,
36193619
callbacks->mac_ctxt_changed(mvm, vif, false);
36203620

36213621
if (mvm->mld_api_is_used)
3622-
iwl_mvm_link_changed(mvm, vif,
3622+
iwl_mvm_link_changed(mvm, vif, &vif->bss_conf,
36233623
LINK_CONTEXT_MODIFY_ALL &
36243624
~LINK_CONTEXT_MODIFY_ACTIVE,
36253625
true);

0 commit comments

Comments
 (0)