3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 17:59:25 +01:00

test-runner: allow radio list subset to be configured

The radio_confs key was parsed in a way that required all radios
to be specified in the list. This isnt optimal, as you may want to
specially configure a certain radio, while keeping all the others
default.

This change reworks some logic and allows any radio to be specially
configured on its own.
This commit is contained in:
James Prestwood 2019-05-13 14:29:23 -07:00 committed by Denis Kenzior
parent 0e31b33631
commit 2d51622c0b

View File

@ -1091,9 +1091,8 @@ static bool configure_hw_radios(struct l_settings *hw_settings,
struct l_queue *wiphy_list) struct l_queue *wiphy_list)
{ {
char **radio_conf_list; char **radio_conf_list;
int num_radios_requested, num_radios_created; int i, num_radios_requested;
bool status = false; bool status = false;
bool has_hw_conf;
l_settings_get_int(hw_settings, HW_CONFIG_GROUP_SETUP, l_settings_get_int(hw_settings, HW_CONFIG_GROUP_SETUP,
HW_CONFIG_SETUP_NUM_RADIOS, HW_CONFIG_SETUP_NUM_RADIOS,
@ -1105,75 +1104,31 @@ static bool configure_hw_radios(struct l_settings *hw_settings,
return false; return false;
} }
has_hw_conf = l_settings_has_key(hw_settings, HW_CONFIG_GROUP_SETUP,
HW_CONFIG_SETUP_RADIO_CONFS);
radio_conf_list = radio_conf_list =
l_settings_get_string_list(hw_settings, HW_CONFIG_GROUP_SETUP, l_settings_get_string_list(hw_settings, HW_CONFIG_GROUP_SETUP,
HW_CONFIG_SETUP_RADIO_CONFS, HW_CONFIG_SETUP_RADIO_CONFS,
':'); ':');
if (has_hw_conf && !radio_conf_list) { for (i = 0; i < num_radios_requested; i++) {
l_error("%s doesn't parse", HW_CONFIG_SETUP_RADIO_CONFS);
return false;
}
if (has_hw_conf) {
int i;
for (i = 0; radio_conf_list[i]; i++) {
size_t len = strlen(radio_conf_list[i]);
if (len >= sizeof(((struct wiphy *) 0)->name)) {
l_error("Radio name: '%s' is too big",
radio_conf_list[i]);
goto exit;
}
if (len == 0) {
l_error("Radio name cannot be empty");
goto exit;
}
if (!l_settings_has_group(hw_settings,
radio_conf_list[i])) {
l_error("No radio configuration group [%s]"
" found in config file.",
radio_conf_list[i]);
goto exit;
}
}
if (i != num_radios_requested) {
l_error(HW_CONFIG_SETUP_RADIO_CONFS "should contain"
" %d radios", num_radios_requested);
goto exit;
}
}
num_radios_created = 0;
while (num_radios_requested > num_radios_created) {
struct wiphy *wiphy; struct wiphy *wiphy;
unsigned int channels; unsigned int channels;
bool p2p_device; bool p2p_device;
bool use_chanctx; bool use_chanctx;
wiphy = l_new(struct wiphy, 1); wiphy = l_new(struct wiphy, 1);
if (!has_hw_conf) { sprintf(wiphy->name, "rad%d", i);
/* radio not in radio_confs, use default parameters */
if (!l_strv_contains(radio_conf_list, wiphy->name)) {
channels = 1; channels = 1;
p2p_device = true; p2p_device = true;
use_chanctx = true; use_chanctx = true;
goto create;
sprintf(wiphy->name, "rad%d", num_radios_created);
goto configure;
} }
strcpy(wiphy->name, radio_conf_list[num_radios_created]);
if (!l_settings_get_uint(hw_settings, wiphy->name, if (!l_settings_get_uint(hw_settings, wiphy->name,
HW_CONFIG_PHY_CHANNELS, &channels)) HW_CONFIG_PHY_CHANNELS,
&channels))
channels = 1; channels = 1;
if (!l_settings_get_bool(hw_settings, wiphy->name, if (!l_settings_get_bool(hw_settings, wiphy->name,
@ -1181,10 +1136,11 @@ static bool configure_hw_radios(struct l_settings *hw_settings,
p2p_device = true; p2p_device = true;
if (!l_settings_get_bool(hw_settings, wiphy->name, if (!l_settings_get_bool(hw_settings, wiphy->name,
HW_CONFIG_PHY_CHANCTX, &use_chanctx)) HW_CONFIG_PHY_CHANCTX,
&use_chanctx))
use_chanctx = true; use_chanctx = true;
configure: create:
wiphy->id = create_hwsim_radio(wiphy->name, channels, wiphy->id = create_hwsim_radio(wiphy->name, channels,
p2p_device, use_chanctx); p2p_device, use_chanctx);
wiphy->can_ap = true; wiphy->can_ap = true;
@ -1195,7 +1151,6 @@ configure:
} }
l_queue_push_tail(wiphy_list, wiphy); l_queue_push_tail(wiphy_list, wiphy);
num_radios_created++;
} }
status = true; status = true;