aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wagner <wagi@monom.org>2009-05-18 13:49:25 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-05-20 14:46:29 -0400
commit73606d00360cb93963aeb7bfbf8bfdbc51cfab9f (patch)
treef64c63650fa78641c9438e859778c45d915cc8d8
parent1071db863b129847cedb65339d1e87ecf5952a8b (diff)
mac80211_hwsim: Group radios
Currently all radios receive all traffic on the simulated air if they are tuned to the same channel. This patch introduces the concept of grouping, which allows to assign a radio to certain group. Only radios in the same group can 'see' each other. Each bit in /debug/ieee80211/phy*/hwsim/group represents one group. By default all radios belong to the same group "1", e.g. bit 1 is set. Additionally a radio can belong to several groups. Signed-off-by: Daniel Wagner <wagi@monom.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index 61a4ad7cc1c2..574b8bb121e1 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -291,6 +291,14 @@ struct mac80211_hwsim_data {
291 bool ps_poll_pending; 291 bool ps_poll_pending;
292 struct dentry *debugfs; 292 struct dentry *debugfs;
293 struct dentry *debugfs_ps; 293 struct dentry *debugfs_ps;
294
295 /*
296 * Only radios in the same group can communicate together (the
297 * channel has to match too). Each bit represents a group. A
298 * radio can be in more then one group.
299 */
300 u64 group;
301 struct dentry *debugfs_group;
294}; 302};
295 303
296 304
@@ -412,7 +420,8 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
412 420
413 if (!data2->started || !data2->radio_enabled || 421 if (!data2->started || !data2->radio_enabled ||
414 !hwsim_ps_rx_ok(data2, skb) || 422 !hwsim_ps_rx_ok(data2, skb) ||
415 data->channel->center_freq != data2->channel->center_freq) 423 data->channel->center_freq != data2->channel->center_freq ||
424 !(data->group & data2->group))
416 continue; 425 continue;
417 426
418 nskb = skb_copy(skb, GFP_ATOMIC); 427 nskb = skb_copy(skb, GFP_ATOMIC);
@@ -720,6 +729,7 @@ static void mac80211_hwsim_free(void)
720 spin_unlock_bh(&hwsim_radio_lock); 729 spin_unlock_bh(&hwsim_radio_lock);
721 730
722 list_for_each_entry(data, &tmplist, list) { 731 list_for_each_entry(data, &tmplist, list) {
732 debugfs_remove(data->debugfs_group);
723 debugfs_remove(data->debugfs_ps); 733 debugfs_remove(data->debugfs_ps);
724 debugfs_remove(data->debugfs); 734 debugfs_remove(data->debugfs);
725 ieee80211_unregister_hw(data->hw); 735 ieee80211_unregister_hw(data->hw);
@@ -872,6 +882,24 @@ DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_ps, hwsim_fops_ps_read, hwsim_fops_ps_write,
872 "%llu\n"); 882 "%llu\n");
873 883
874 884
885static int hwsim_fops_group_read(void *dat, u64 *val)
886{
887 struct mac80211_hwsim_data *data = dat;
888 *val = data->group;
889 return 0;
890}
891
892static int hwsim_fops_group_write(void *dat, u64 val)
893{
894 struct mac80211_hwsim_data *data = dat;
895 data->group = val;
896 return 0;
897}
898
899DEFINE_SIMPLE_ATTRIBUTE(hwsim_fops_group,
900 hwsim_fops_group_read, hwsim_fops_group_write,
901 "%llx\n");
902
875static int __init init_mac80211_hwsim(void) 903static int __init init_mac80211_hwsim(void)
876{ 904{
877 int i, err = 0; 905 int i, err = 0;
@@ -976,6 +1004,8 @@ static int __init init_mac80211_hwsim(void)
976 1004
977 hw->wiphy->bands[band] = sband; 1005 hw->wiphy->bands[band] = sband;
978 } 1006 }
1007 /* By default all radios are belonging to the first group */
1008 data->group = 1;
979 1009
980 /* Work to be done prior to ieee80211_register_hw() */ 1010 /* Work to be done prior to ieee80211_register_hw() */
981 switch (regtest) { 1011 switch (regtest) {
@@ -1100,6 +1130,9 @@ static int __init init_mac80211_hwsim(void)
1100 data->debugfs_ps = debugfs_create_file("ps", 0666, 1130 data->debugfs_ps = debugfs_create_file("ps", 0666,
1101 data->debugfs, data, 1131 data->debugfs, data,
1102 &hwsim_fops_ps); 1132 &hwsim_fops_ps);
1133 data->debugfs_group = debugfs_create_file("group", 0666,
1134 data->debugfs, data,
1135 &hwsim_fops_group);
1103 1136
1104 setup_timer(&data->beacon_timer, mac80211_hwsim_beacon, 1137 setup_timer(&data->beacon_timer, mac80211_hwsim_beacon,
1105 (unsigned long) hw); 1138 (unsigned long) hw);