@@ -293,7 +293,8 @@ int mt7996_vif_link_add(struct mt76_phy *mphy, struct ieee80211_vif *vif,
293293 * interface, since firmware only records BSSID when the entry is new
294294 */
295295 if (vif -> type != NL80211_IFTYPE_STATION )
296- mt7996_mcu_add_sta (dev , vif , mlink , NULL , CONN_STATE_PORT_SECURE , true);
296+ mt7996_mcu_add_sta (dev , link_conf , NULL , link , NULL ,
297+ CONN_STATE_PORT_SECURE , true);
297298 rcu_assign_pointer (dev -> mt76 .wcid [idx ], & msta_link -> wcid );
298299
299300 ieee80211_iter_keys (mphy -> hw , vif , mt7996_key_iter , link );
@@ -311,7 +312,8 @@ void mt7996_vif_link_remove(struct mt76_phy *mphy, struct ieee80211_vif *vif,
311312 struct mt7996_dev * dev = phy -> dev ;
312313 int idx = msta_link -> wcid .idx ;
313314
314- mt7996_mcu_add_sta (dev , vif , mlink , NULL , CONN_STATE_DISCONNECT , false);
315+ mt7996_mcu_add_sta (dev , link_conf , NULL , link , NULL ,
316+ CONN_STATE_DISCONNECT , false);
315317 mt7996_mcu_add_bss_info (phy , vif , link_conf , mlink , false);
316318
317319 mt7996_mcu_add_dev_info (phy , vif , link_conf , mlink , false);
@@ -703,7 +705,7 @@ mt7996_vif_cfg_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
703705
704706 mt7996_mcu_add_bss_info (link -> phy , vif , link_conf ,
705707 & link -> mt76 , true);
706- mt7996_mcu_add_sta (dev , vif , & link -> mt76 , NULL ,
708+ mt7996_mcu_add_sta (dev , link_conf , NULL , link , NULL ,
707709 CONN_STATE_PORT_SECURE ,
708710 !!(changed & BSS_CHANGED_BSSID ));
709711 }
@@ -717,17 +719,17 @@ mt7996_link_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
717719 struct ieee80211_bss_conf * info , u64 changed )
718720{
719721 struct mt7996_dev * dev = mt7996_hw_dev (hw );
720- struct mt76_vif_link * mvif ;
722+ struct mt7996_vif_link * link ;
721723 struct mt7996_phy * phy ;
722724 struct mt76_phy * mphy ;
723725
724726 mutex_lock (& dev -> mt76 .mutex );
725727
726- mvif = mt76_vif_conf_link ( & dev -> mt76 , vif , info );
727- if (!mvif )
728+ link = mt7996_vif_conf_link ( dev , vif , info );
729+ if (!link )
728730 goto out ;
729731
730- mphy = mt76_vif_link_phy (mvif );
732+ mphy = mt76_vif_link_phy (& link -> mt76 );
731733 if (!mphy )
732734 goto out ;
733735
@@ -738,8 +740,9 @@ mt7996_link_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
738740 */
739741 if ((changed & BSS_CHANGED_BSSID && !is_zero_ether_addr (info -> bssid )) ||
740742 (changed & BSS_CHANGED_BEACON_ENABLED && info -> enable_beacon )) {
741- mt7996_mcu_add_bss_info (phy , vif , info , mvif , true);
742- mt7996_mcu_add_sta (dev , vif , mvif , NULL , CONN_STATE_PORT_SECURE ,
743+ mt7996_mcu_add_bss_info (phy , vif , info , & link -> mt76 , true);
744+ mt7996_mcu_add_sta (dev , info , NULL , link , NULL ,
745+ CONN_STATE_PORT_SECURE ,
743746 !!(changed & BSS_CHANGED_BSSID ));
744747 }
745748
@@ -756,11 +759,11 @@ mt7996_link_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
756759 }
757760
758761 if (changed & BSS_CHANGED_MCAST_RATE )
759- mvif -> mcast_rates_idx =
762+ link -> mt76 . mcast_rates_idx =
760763 mt7996_get_rates_table (phy , info , false, true);
761764
762765 if (changed & BSS_CHANGED_BASIC_RATES )
763- mvif -> basic_rates_idx =
766+ link -> mt76 . basic_rates_idx =
764767 mt7996_get_rates_table (phy , info , false, false);
765768
766769 /* ensure that enable txcmd_mode after bss_info */
@@ -772,15 +775,15 @@ mt7996_link_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
772775
773776 if (changed & BSS_CHANGED_HE_BSS_COLOR ) {
774777 if ((vif -> type == NL80211_IFTYPE_AP &&
775- mvif -> omac_idx <= HW_BSSID_MAX ) ||
778+ link -> mt76 . omac_idx <= HW_BSSID_MAX ) ||
776779 vif -> type == NL80211_IFTYPE_STATION )
777- mt7996_mcu_update_bss_color (dev , mvif ,
780+ mt7996_mcu_update_bss_color (dev , & link -> mt76 ,
778781 & info -> he_bss_color );
779782 }
780783
781784 if (changed & (BSS_CHANGED_BEACON |
782785 BSS_CHANGED_BEACON_ENABLED )) {
783- mvif -> beacon_rates_idx =
786+ link -> mt76 . beacon_rates_idx =
784787 mt7996_get_rates_table (phy , info , true, false);
785788
786789 mt7996_mcu_add_beacon (hw , vif , info );
@@ -816,10 +819,12 @@ mt7996_channel_switch_beacon(struct ieee80211_hw *hw,
816819}
817820
818821static int
819- mt7996_mac_sta_init_link (struct mt7996_dev * dev , struct ieee80211_vif * vif ,
820- struct mt7996_vif_link * link ,
821- struct ieee80211_sta * sta , unsigned int link_id )
822+ mt7996_mac_sta_init_link (struct mt7996_dev * dev ,
823+ struct ieee80211_bss_conf * link_conf ,
824+ struct ieee80211_link_sta * link_sta ,
825+ struct mt7996_vif_link * link , unsigned int link_id )
822826{
827+ struct ieee80211_sta * sta = link_sta -> sta ;
823828 struct mt7996_sta * msta = (struct mt7996_sta * )sta -> drv_priv ;
824829 struct mt7996_phy * phy = link -> phy ;
825830 struct mt7996_sta_link * msta_link ;
@@ -863,8 +868,8 @@ mt7996_mac_sta_init_link(struct mt7996_dev *dev, struct ieee80211_vif *vif,
863868 rcu_assign_pointer (msta -> link [link_id ], msta_link );
864869
865870 mt7996_mac_wtbl_update (dev , idx , MT_WTBL_UPDATE_ADM_COUNT_CLEAR );
866- mt7996_mcu_add_sta (dev , vif , & link -> mt76 , sta , CONN_STATE_DISCONNECT ,
867- true);
871+ mt7996_mcu_add_sta (dev , link_conf , link_sta , link , msta_link ,
872+ CONN_STATE_DISCONNECT , true);
868873
869874 rcu_assign_pointer (dev -> mt76 .wcid [idx ], & msta_link -> wcid );
870875 mt76_wcid_init (& msta_link -> wcid , phy -> mt76 -> band_idx );
@@ -930,16 +935,27 @@ mt7996_mac_sta_add_links(struct mt7996_dev *dev, struct ieee80211_vif *vif,
930935 int err ;
931936
932937 for_each_set_bit (link_id , & new_links , IEEE80211_MLD_MAX_NUM_LINKS ) {
938+ struct ieee80211_bss_conf * link_conf ;
939+ struct ieee80211_link_sta * link_sta ;
933940 struct mt7996_vif_link * link ;
934941
935942 if (rcu_access_pointer (msta -> link [link_id ]))
936943 continue ;
937944
945+ link_conf = link_conf_dereference_protected (vif , link_id );
946+ if (!link_conf )
947+ goto error_unlink ;
948+
938949 link = mt7996_vif_link (dev , vif , link_id );
939950 if (!link )
940951 goto error_unlink ;
941952
942- err = mt7996_mac_sta_init_link (dev , vif , link , sta , link_id );
953+ link_sta = link_sta_dereference_protected (sta , link_id );
954+ if (!link_sta )
955+ goto error_unlink ;
956+
957+ err = mt7996_mac_sta_init_link (dev , link_conf , link_sta , link ,
958+ link_id );
943959 if (err )
944960 goto error_unlink ;
945961 }
@@ -1005,10 +1021,15 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
10051021 unsigned int link_id ;
10061022
10071023 for_each_sta_active_link (vif , sta , link_sta , link_id ) {
1024+ struct ieee80211_bss_conf * link_conf ;
10081025 struct mt7996_sta_link * msta_link ;
10091026 struct mt7996_vif_link * link ;
10101027 int i , err ;
10111028
1029+ link_conf = link_conf_dereference_protected (vif , link_id );
1030+ if (!link_conf )
1031+ continue ;
1032+
10121033 link = mt7996_vif_link (dev , vif , link_id );
10131034 if (!link )
10141035 continue ;
@@ -1019,7 +1040,8 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
10191040
10201041 switch (ev ) {
10211042 case MT76_STA_EVENT_ASSOC :
1022- err = mt7996_mcu_add_sta (dev , vif , & link -> mt76 , sta ,
1043+ err = mt7996_mcu_add_sta (dev , link_conf , link_sta ,
1044+ link , msta_link ,
10231045 CONN_STATE_CONNECT , true);
10241046 if (err )
10251047 return err ;
@@ -1032,7 +1054,8 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
10321054 msta_link -> wcid .sta = 1 ;
10331055 break ;
10341056 case MT76_STA_EVENT_AUTHORIZE :
1035- err = mt7996_mcu_add_sta (dev , vif , & link -> mt76 , sta ,
1057+ err = mt7996_mcu_add_sta (dev , link_conf , link_sta ,
1058+ link , msta_link ,
10361059 CONN_STATE_PORT_SECURE , false);
10371060 if (err )
10381061 return err ;
@@ -1041,8 +1064,9 @@ mt7996_mac_sta_event(struct mt7996_dev *dev, struct ieee80211_vif *vif,
10411064 for (i = 0 ; i < ARRAY_SIZE (msta_link -> twt .flow ); i ++ )
10421065 mt7996_mac_twt_teardown_flow (dev , msta , i );
10431066
1044- mt7996_mcu_add_sta (dev , vif , & link -> mt76 , sta ,
1045- CONN_STATE_DISCONNECT , false);
1067+ mt7996_mcu_add_sta (dev , link_conf , link_sta , link ,
1068+ msta_link , CONN_STATE_DISCONNECT ,
1069+ false);
10461070 msta_link -> wcid .sta_disabled = 1 ;
10471071 msta_link -> wcid .sta = 0 ;
10481072 break ;
0 commit comments