@@ -815,6 +815,22 @@ void mt76_free_device(struct mt76_dev *dev)
815
815
}
816
816
EXPORT_SYMBOL_GPL (mt76_free_device );
817
817
818
+ static struct mt76_phy *
819
+ mt76_vif_phy (struct ieee80211_hw * hw , struct ieee80211_vif * vif )
820
+ {
821
+ struct mt76_vif_link * mlink = (struct mt76_vif_link * )vif -> drv_priv ;
822
+ struct mt76_chanctx * ctx ;
823
+
824
+ if (!hw -> wiphy -> n_radio )
825
+ return hw -> priv ;
826
+
827
+ if (!mlink -> ctx )
828
+ return NULL ;
829
+
830
+ ctx = (struct mt76_chanctx * )mlink -> ctx -> drv_priv ;
831
+ return ctx -> phy ;
832
+ }
833
+
818
834
static void mt76_rx_release_amsdu (struct mt76_phy * phy , enum mt76_rxq_id q )
819
835
{
820
836
struct sk_buff * skb = phy -> rx_amsdu [q ].head ;
@@ -1023,33 +1039,53 @@ int mt76_update_channel(struct mt76_phy *phy)
1023
1039
}
1024
1040
EXPORT_SYMBOL_GPL (mt76_update_channel );
1025
1041
1042
+ static struct mt76_sband *
1043
+ mt76_get_survey_sband (struct mt76_phy * phy , int * idx )
1044
+ {
1045
+ if (* idx < phy -> sband_2g .sband .n_channels )
1046
+ return & phy -> sband_2g ;
1047
+
1048
+ * idx -= phy -> sband_2g .sband .n_channels ;
1049
+ if (* idx < phy -> sband_5g .sband .n_channels )
1050
+ return & phy -> sband_5g ;
1051
+
1052
+ * idx -= phy -> sband_5g .sband .n_channels ;
1053
+ if (* idx < phy -> sband_6g .sband .n_channels )
1054
+ return & phy -> sband_6g ;
1055
+
1056
+ * idx -= phy -> sband_6g .sband .n_channels ;
1057
+ return NULL ;
1058
+ }
1059
+
1026
1060
int mt76_get_survey (struct ieee80211_hw * hw , int idx ,
1027
1061
struct survey_info * survey )
1028
1062
{
1029
1063
struct mt76_phy * phy = hw -> priv ;
1030
1064
struct mt76_dev * dev = phy -> dev ;
1031
- struct mt76_sband * sband ;
1065
+ struct mt76_sband * sband = NULL ;
1032
1066
struct ieee80211_channel * chan ;
1033
1067
struct mt76_channel_state * state ;
1068
+ int phy_idx = 0 ;
1034
1069
int ret = 0 ;
1035
1070
1036
1071
mutex_lock (& dev -> mutex );
1037
- if (idx == 0 && dev -> drv -> update_survey )
1038
- mt76_update_survey (phy );
1039
-
1040
- if (idx >= phy -> sband_2g .sband .n_channels +
1041
- phy -> sband_5g .sband .n_channels ) {
1042
- idx -= (phy -> sband_2g .sband .n_channels +
1043
- phy -> sband_5g .sband .n_channels );
1044
- sband = & phy -> sband_6g ;
1045
- } else if (idx >= phy -> sband_2g .sband .n_channels ) {
1046
- idx -= phy -> sband_2g .sband .n_channels ;
1047
- sband = & phy -> sband_5g ;
1048
- } else {
1049
- sband = & phy -> sband_2g ;
1072
+
1073
+ for (phy_idx = 0 ; phy_idx < ARRAY_SIZE (dev -> phys ); phy_idx ++ ) {
1074
+ sband = NULL ;
1075
+ phy = dev -> phys [phy_idx ];
1076
+ if (!phy || phy -> hw != hw )
1077
+ continue ;
1078
+
1079
+ sband = mt76_get_survey_sband (phy , & idx );
1080
+
1081
+ if (idx == 0 && phy -> dev -> drv -> update_survey )
1082
+ mt76_update_survey (phy );
1083
+
1084
+ if (sband || !hw -> wiphy -> n_radio )
1085
+ break ;
1050
1086
}
1051
1087
1052
- if (idx >= sband -> sband . n_channels ) {
1088
+ if (! sband ) {
1053
1089
ret = - ENOENT ;
1054
1090
goto out ;
1055
1091
}
@@ -1555,6 +1591,10 @@ int mt76_sta_state(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1555
1591
struct mt76_dev * dev = phy -> dev ;
1556
1592
enum mt76_sta_event ev ;
1557
1593
1594
+ phy = mt76_vif_phy (hw , vif );
1595
+ if (!phy )
1596
+ return - EINVAL ;
1597
+
1558
1598
if (old_state == IEEE80211_STA_NOTEXIST &&
1559
1599
new_state == IEEE80211_STA_NONE )
1560
1600
return mt76_sta_add (phy , vif , sta );
@@ -1659,10 +1699,14 @@ EXPORT_SYMBOL_GPL(mt76_wcid_add_poll);
1659
1699
int mt76_get_txpower (struct ieee80211_hw * hw , struct ieee80211_vif * vif ,
1660
1700
unsigned int link_id , int * dbm )
1661
1701
{
1662
- struct mt76_phy * phy = hw -> priv ;
1663
- int n_chains = hweight16 (phy -> chainmask );
1664
- int delta = mt76_tx_power_nss_delta (n_chains );
1702
+ struct mt76_phy * phy = mt76_vif_phy (hw , vif );
1703
+ int n_chains , delta ;
1665
1704
1705
+ if (!phy )
1706
+ return - EINVAL ;
1707
+
1708
+ n_chains = hweight16 (phy -> chainmask );
1709
+ delta = mt76_tx_power_nss_delta (n_chains );
1666
1710
* dbm = DIV_ROUND_UP (phy -> txpower_cur + delta , 2 );
1667
1711
1668
1712
return 0 ;
@@ -1837,10 +1881,14 @@ int mt76_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
1837
1881
{
1838
1882
struct mt76_phy * phy = hw -> priv ;
1839
1883
struct mt76_dev * dev = phy -> dev ;
1884
+ int i ;
1840
1885
1841
1886
mutex_lock (& dev -> mutex );
1842
- * tx_ant = phy -> antenna_mask ;
1843
- * rx_ant = phy -> antenna_mask ;
1887
+ * tx_ant = 0 ;
1888
+ for (i = 0 ; i < ARRAY_SIZE (dev -> phys ); i ++ )
1889
+ if (dev -> phys [i ] && dev -> phys [i ]-> hw == hw )
1890
+ * tx_ant |= dev -> phys [i ]-> chainmask ;
1891
+ * rx_ant = * tx_ant ;
1844
1892
mutex_unlock (& dev -> mutex );
1845
1893
1846
1894
return 0 ;
0 commit comments