@@ -69,6 +69,10 @@ static bool mlo;
69
69
module_param (mlo , bool , 0444 );
70
70
MODULE_PARM_DESC (mlo , "Support MLO" );
71
71
72
+ static bool multi_radio ;
73
+ module_param (multi_radio , bool , 0444 );
74
+ MODULE_PARM_DESC (mlo , "Support Multiple Radios per wiphy" );
75
+
72
76
/**
73
77
* enum hwsim_regtest - the type of regulatory tests we offer
74
78
*
@@ -669,6 +673,10 @@ struct mac80211_hwsim_data {
669
673
struct ieee80211_iface_limit if_limits [3 ];
670
674
int n_if_limits ;
671
675
676
+ struct ieee80211_iface_combination if_combination_radio ;
677
+ struct wiphy_radio_freq_range radio_range [NUM_NL80211_BANDS ];
678
+ struct wiphy_radio radio [NUM_NL80211_BANDS ];
679
+
672
680
u32 ciphers [ARRAY_SIZE (hwsim_ciphers )];
673
681
674
682
struct mac_address addresses [2 ];
@@ -917,6 +925,7 @@ static const struct nla_policy hwsim_genl_policy[HWSIM_ATTR_MAX + 1] = {
917
925
[HWSIM_ATTR_MLO_SUPPORT ] = { .type = NLA_FLAG },
918
926
[HWSIM_ATTR_PMSR_SUPPORT ] = NLA_POLICY_NESTED (hwsim_pmsr_capa_policy ),
919
927
[HWSIM_ATTR_PMSR_RESULT ] = NLA_POLICY_NESTED (hwsim_pmsr_peers_result_policy ),
928
+ [HWSIM_ATTR_MULTI_RADIO ] = { .type = NLA_FLAG },
920
929
};
921
930
922
931
#if IS_REACHABLE (CONFIG_VIRTIO )
@@ -4018,6 +4027,7 @@ struct hwsim_new_radio_params {
4018
4027
bool reg_strict ;
4019
4028
bool p2p_device ;
4020
4029
bool use_chanctx ;
4030
+ bool multi_radio ;
4021
4031
bool destroy_on_close ;
4022
4032
const char * hwname ;
4023
4033
bool no_vif ;
@@ -4094,6 +4104,12 @@ static int append_radio_msg(struct sk_buff *skb, int id,
4094
4104
return ret ;
4095
4105
}
4096
4106
4107
+ if (param -> multi_radio ) {
4108
+ ret = nla_put_flag (skb , HWSIM_ATTR_MULTI_RADIO );
4109
+ if (ret < 0 )
4110
+ return ret ;
4111
+ }
4112
+
4097
4113
if (param -> hwname ) {
4098
4114
ret = nla_put (skb , HWSIM_ATTR_RADIO_NAME ,
4099
4115
strlen (param -> hwname ), param -> hwname );
@@ -5114,6 +5130,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
5114
5130
struct net * net ;
5115
5131
int idx , i ;
5116
5132
int n_limits = 0 ;
5133
+ int n_bands = 0 ;
5117
5134
5118
5135
if (WARN_ON (param -> channels > 1 && !param -> use_chanctx ))
5119
5136
return - EINVAL ;
@@ -5217,22 +5234,22 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
5217
5234
n_limits ++ ;
5218
5235
}
5219
5236
5237
+ data -> if_combination .radar_detect_widths =
5238
+ BIT (NL80211_CHAN_WIDTH_5 ) |
5239
+ BIT (NL80211_CHAN_WIDTH_10 ) |
5240
+ BIT (NL80211_CHAN_WIDTH_20_NOHT ) |
5241
+ BIT (NL80211_CHAN_WIDTH_20 ) |
5242
+ BIT (NL80211_CHAN_WIDTH_40 ) |
5243
+ BIT (NL80211_CHAN_WIDTH_80 ) |
5244
+ BIT (NL80211_CHAN_WIDTH_160 );
5245
+
5220
5246
if (data -> use_chanctx ) {
5221
5247
hw -> wiphy -> max_scan_ssids = 255 ;
5222
5248
hw -> wiphy -> max_scan_ie_len = IEEE80211_MAX_DATA_LEN ;
5223
5249
hw -> wiphy -> max_remain_on_channel_duration = 1000 ;
5224
- data -> if_combination .radar_detect_widths = 0 ;
5225
5250
data -> if_combination .num_different_channels = data -> channels ;
5226
5251
} else {
5227
5252
data -> if_combination .num_different_channels = 1 ;
5228
- data -> if_combination .radar_detect_widths =
5229
- BIT (NL80211_CHAN_WIDTH_5 ) |
5230
- BIT (NL80211_CHAN_WIDTH_10 ) |
5231
- BIT (NL80211_CHAN_WIDTH_20_NOHT ) |
5232
- BIT (NL80211_CHAN_WIDTH_20 ) |
5233
- BIT (NL80211_CHAN_WIDTH_40 ) |
5234
- BIT (NL80211_CHAN_WIDTH_80 ) |
5235
- BIT (NL80211_CHAN_WIDTH_160 );
5236
5253
}
5237
5254
5238
5255
if (!n_limits ) {
@@ -5350,6 +5367,9 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
5350
5367
5351
5368
for (band = NL80211_BAND_2GHZ ; band < NUM_NL80211_BANDS ; band ++ ) {
5352
5369
struct ieee80211_supported_band * sband = & data -> bands [band ];
5370
+ struct wiphy_radio_freq_range * radio_range ;
5371
+ const struct ieee80211_channel * c ;
5372
+ struct wiphy_radio * radio ;
5353
5373
5354
5374
sband -> band = band ;
5355
5375
@@ -5423,8 +5443,36 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
5423
5443
mac80211_hwsim_sband_capab (sband );
5424
5444
5425
5445
hw -> wiphy -> bands [band ] = sband ;
5446
+
5447
+ if (!param -> multi_radio )
5448
+ continue ;
5449
+
5450
+ c = sband -> channels ;
5451
+ radio_range = & data -> radio_range [n_bands ];
5452
+ radio_range -> start_freq = ieee80211_channel_to_khz (c ) - 10000 ;
5453
+
5454
+ c += sband -> n_channels - 1 ;
5455
+ radio_range -> end_freq = ieee80211_channel_to_khz (c ) + 10000 ;
5456
+
5457
+ radio = & data -> radio [n_bands ++ ];
5458
+ radio -> freq_range = radio_range ;
5459
+ radio -> n_freq_range = 1 ;
5460
+ radio -> iface_combinations = & data -> if_combination_radio ;
5461
+ radio -> n_iface_combinations = 1 ;
5426
5462
}
5427
5463
5464
+ if (param -> multi_radio ) {
5465
+ hw -> wiphy -> radio = data -> radio ;
5466
+ hw -> wiphy -> n_radio = n_bands ;
5467
+
5468
+ memcpy (& data -> if_combination_radio , & data -> if_combination ,
5469
+ sizeof (data -> if_combination ));
5470
+ data -> if_combination .num_different_channels *= n_bands ;
5471
+ }
5472
+
5473
+ if (data -> use_chanctx )
5474
+ data -> if_combination .radar_detect_widths = 0 ;
5475
+
5428
5476
/* By default all radios belong to the first group */
5429
5477
data -> group = 1 ;
5430
5478
mutex_init (& data -> mutex );
@@ -6042,6 +6090,9 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
6042
6090
else
6043
6091
param .use_chanctx = (param .channels > 1 );
6044
6092
6093
+ if (info -> attrs [HWSIM_ATTR_MULTI_RADIO ])
6094
+ param .multi_radio = true;
6095
+
6045
6096
if (info -> attrs [HWSIM_ATTR_REG_HINT_ALPHA2 ])
6046
6097
param .reg_alpha2 =
6047
6098
nla_data (info -> attrs [HWSIM_ATTR_REG_HINT_ALPHA2 ]);
@@ -6122,7 +6173,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
6122
6173
6123
6174
param .mlo = info -> attrs [HWSIM_ATTR_MLO_SUPPORT ];
6124
6175
6125
- if (param .mlo )
6176
+ if (param .mlo || param . multi_radio )
6126
6177
param .use_chanctx = true;
6127
6178
6128
6179
if (info -> attrs [HWSIM_ATTR_RADIO_NAME ]) {
@@ -6815,7 +6866,8 @@ static int __init init_mac80211_hwsim(void)
6815
6866
6816
6867
param .p2p_device = support_p2p_device ;
6817
6868
param .mlo = mlo ;
6818
- param .use_chanctx = channels > 1 || mlo ;
6869
+ param .multi_radio = multi_radio ;
6870
+ param .use_chanctx = channels > 1 || mlo || multi_radio ;
6819
6871
param .iftypes = HWSIM_IFTYPE_SUPPORT_MASK ;
6820
6872
if (param .p2p_device )
6821
6873
param .iftypes |= BIT (NL80211_IFTYPE_P2P_DEVICE );
0 commit comments