aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mac80211_hwsim.c
diff options
context:
space:
mode:
authorLuis R. Rodriguez <lrodriguez@atheros.com>2009-03-09 22:08:27 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-03-16 18:09:41 -0400
commit4a5af9c2923b6d8ce31a7fe84d7dc5431cd844a0 (patch)
tree615003b6b42c137180ba4e2bc8cc50ddef8b00e5 /drivers/net/wireless/mac80211_hwsim.c
parent73d54c9e74c4d8ee8a41bc516f481f0f754eca32 (diff)
mac80211_hwsim: add regulatory testing options
This adds a module parameter for mac80211_hwsim regulatory testing. This module parameter is designed specifically to help test the different possible types of driver specific regulatory requests and also helps to test world roaming, all without any hardware. If you want to just simply test different alpha2s just use the userspace regulatory request as this won't buy you anything new. Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mac80211_hwsim.c')
-rw-r--r--drivers/net/wireless/mac80211_hwsim.c210
1 files changed, 210 insertions, 0 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
index d8716bed5e46..a15078bcad73 100644
--- a/drivers/net/wireless/mac80211_hwsim.c
+++ b/drivers/net/wireless/mac80211_hwsim.c
@@ -30,6 +30,112 @@ static int radios = 2;
30module_param(radios, int, 0444); 30module_param(radios, int, 0444);
31MODULE_PARM_DESC(radios, "Number of simulated radios"); 31MODULE_PARM_DESC(radios, "Number of simulated radios");
32 32
33/**
34 * enum hwsim_regtest - the type of regulatory tests we offer
35 *
36 * These are the different values you can use for the regtest
37 * module parameter. This is useful to help test world roaming
38 * and the driver regulatory_hint() call and combinations of these.
39 * If you want to do specific alpha2 regulatory domain tests simply
40 * use the userspace regulatory request as that will be respected as
41 * well without the need of this module parameter. This is designed
42 * only for testing the driver regulatory request, world roaming
43 * and all possible combinations.
44 *
45 * @HWSIM_REGTEST_DISABLED: No regulatory tests are performed,
46 * this is the default value.
47 * @HWSIM_REGTEST_DRIVER_REG_FOLLOW: Used for testing the driver regulatory
48 * hint, only one driver regulatory hint will be sent as such the
49 * secondary radios are expected to follow.
50 * @HWSIM_REGTEST_DRIVER_REG_ALL: Used for testing the driver regulatory
51 * request with all radios reporting the same regulatory domain.
52 * @HWSIM_REGTEST_DIFF_COUNTRY: Used for testing the drivers calling
53 * different regulatory domains requests. Expected behaviour is for
54 * an intersection to occur but each device will still use their
55 * respective regulatory requested domains. Subsequent radios will
56 * use the resulting intersection.
57 * @HWSIM_REGTEST_WORLD_ROAM: Used for testing the world roaming. We acomplish
58 * this by using a custom beacon-capable regulatory domain for the first
59 * radio. All other device world roam.
60 * @HWSIM_REGTEST_CUSTOM_WORLD: Used for testing the custom world regulatory
61 * domain requests. All radios will adhere to this custom world regulatory
62 * domain.
63 * @HWSIM_REGTEST_CUSTOM_WORLD_2: Used for testing 2 custom world regulatory
64 * domain requests. The first radio will adhere to the first custom world
65 * regulatory domain, the second one to the second custom world regulatory
66 * domain. All other devices will world roam.
67 * @HWSIM_REGTEST_STRICT_FOLLOW_: Used for testing strict regulatory domain
68 * settings, only the first radio will send a regulatory domain request
69 * and use strict settings. The rest of the radios are expected to follow.
70 * @HWSIM_REGTEST_STRICT_ALL: Used for testing strict regulatory domain
71 * settings. All radios will adhere to this.
72 * @HWSIM_REGTEST_STRICT_AND_DRIVER_REG: Used for testing strict regulatory
73 * domain settings, combined with secondary driver regulatory domain
74 * settings. The first radio will get a strict regulatory domain setting
75 * using the first driver regulatory request and the second radio will use
76 * non-strict settings using the second driver regulatory request. All
77 * other devices should follow the intersection created between the
78 * first two.
79 * @HWSIM_REGTEST_ALL: Used for testing every possible mix. You will need
80 * at least 6 radios for a complete test. We will test in this order:
81 * 1 - driver custom world regulatory domain
82 * 2 - second custom world regulatory domain
83 * 3 - first driver regulatory domain request
84 * 4 - second driver regulatory domain request
85 * 5 - strict regulatory domain settings using the third driver regulatory
86 * domain request
87 * 6 and on - should follow the intersection of the 3rd, 4rth and 5th radio
88 * regulatory requests.
89 */
90enum hwsim_regtest {
91 HWSIM_REGTEST_DISABLED = 0,
92 HWSIM_REGTEST_DRIVER_REG_FOLLOW = 1,
93 HWSIM_REGTEST_DRIVER_REG_ALL = 2,
94 HWSIM_REGTEST_DIFF_COUNTRY = 3,
95 HWSIM_REGTEST_WORLD_ROAM = 4,
96 HWSIM_REGTEST_CUSTOM_WORLD = 5,
97 HWSIM_REGTEST_CUSTOM_WORLD_2 = 6,
98 HWSIM_REGTEST_STRICT_FOLLOW = 7,
99 HWSIM_REGTEST_STRICT_ALL = 8,
100 HWSIM_REGTEST_STRICT_AND_DRIVER_REG = 9,
101 HWSIM_REGTEST_ALL = 10,
102};
103
104/* Set to one of the HWSIM_REGTEST_* values above */
105static int regtest = HWSIM_REGTEST_DISABLED;
106module_param(regtest, int, 0444);
107MODULE_PARM_DESC(regtest, "The type of regulatory test we want to run");
108
109static const char *hwsim_alpha2s[] = {
110 "FI",
111 "AL",
112 "US",
113 "DE",
114 "JP",
115 "AL",
116};
117
118static const struct ieee80211_regdomain hwsim_world_regdom_custom_01 = {
119 .n_reg_rules = 4,
120 .alpha2 = "99",
121 .reg_rules = {
122 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0),
123 REG_RULE(2484-10, 2484+10, 40, 0, 20, 0),
124 REG_RULE(5150-10, 5240+10, 40, 0, 30, 0),
125 REG_RULE(5745-10, 5825+10, 40, 0, 30, 0),
126 }
127};
128
129static const struct ieee80211_regdomain hwsim_world_regdom_custom_02 = {
130 .n_reg_rules = 2,
131 .alpha2 = "99",
132 .reg_rules = {
133 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0),
134 REG_RULE(5725-10, 5850+10, 40, 0, 30,
135 NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
136 }
137};
138
33struct hwsim_vif_priv { 139struct hwsim_vif_priv {
34 u32 magic; 140 u32 magic;
35 u8 bssid[ETH_ALEN]; 141 u8 bssid[ETH_ALEN];
@@ -871,6 +977,64 @@ static int __init init_mac80211_hwsim(void)
871 hw->wiphy->bands[band] = sband; 977 hw->wiphy->bands[band] = sband;
872 } 978 }
873 979
980 /* Work to be done prior to ieee80211_register_hw() */
981 switch (regtest) {
982 case HWSIM_REGTEST_DISABLED:
983 case HWSIM_REGTEST_DRIVER_REG_FOLLOW:
984 case HWSIM_REGTEST_DRIVER_REG_ALL:
985 case HWSIM_REGTEST_DIFF_COUNTRY:
986 /*
987 * Nothing to be done for driver regulatory domain
988 * hints prior to ieee80211_register_hw()
989 */
990 break;
991 case HWSIM_REGTEST_WORLD_ROAM:
992 if (i == 0) {
993 hw->wiphy->custom_regulatory = true;
994 wiphy_apply_custom_regulatory(hw->wiphy,
995 &hwsim_world_regdom_custom_01);
996 }
997 break;
998 case HWSIM_REGTEST_CUSTOM_WORLD:
999 hw->wiphy->custom_regulatory = true;
1000 wiphy_apply_custom_regulatory(hw->wiphy,
1001 &hwsim_world_regdom_custom_01);
1002 break;
1003 case HWSIM_REGTEST_CUSTOM_WORLD_2:
1004 if (i == 0) {
1005 hw->wiphy->custom_regulatory = true;
1006 wiphy_apply_custom_regulatory(hw->wiphy,
1007 &hwsim_world_regdom_custom_01);
1008 } else if (i == 1) {
1009 hw->wiphy->custom_regulatory = true;
1010 wiphy_apply_custom_regulatory(hw->wiphy,
1011 &hwsim_world_regdom_custom_02);
1012 }
1013 break;
1014 case HWSIM_REGTEST_STRICT_ALL:
1015 hw->wiphy->strict_regulatory = true;
1016 break;
1017 case HWSIM_REGTEST_STRICT_FOLLOW:
1018 case HWSIM_REGTEST_STRICT_AND_DRIVER_REG:
1019 if (i == 0)
1020 hw->wiphy->strict_regulatory = true;
1021 break;
1022 case HWSIM_REGTEST_ALL:
1023 if (i == 0) {
1024 hw->wiphy->custom_regulatory = true;
1025 wiphy_apply_custom_regulatory(hw->wiphy,
1026 &hwsim_world_regdom_custom_01);
1027 } else if (i == 1) {
1028 hw->wiphy->custom_regulatory = true;
1029 wiphy_apply_custom_regulatory(hw->wiphy,
1030 &hwsim_world_regdom_custom_02);
1031 } else if (i == 4)
1032 hw->wiphy->strict_regulatory = true;
1033 break;
1034 default:
1035 break;
1036 }
1037
874 err = ieee80211_register_hw(hw); 1038 err = ieee80211_register_hw(hw);
875 if (err < 0) { 1039 if (err < 0) {
876 printk(KERN_DEBUG "mac80211_hwsim: " 1040 printk(KERN_DEBUG "mac80211_hwsim: "
@@ -878,6 +1042,52 @@ static int __init init_mac80211_hwsim(void)
878 goto failed_hw; 1042 goto failed_hw;
879 } 1043 }
880 1044
1045 /* Work to be done after to ieee80211_register_hw() */
1046 switch (regtest) {
1047 case HWSIM_REGTEST_WORLD_ROAM:
1048 case HWSIM_REGTEST_DISABLED:
1049 break;
1050 case HWSIM_REGTEST_DRIVER_REG_FOLLOW:
1051 if (!i)
1052 regulatory_hint(hw->wiphy, hwsim_alpha2s[0]);
1053 break;
1054 case HWSIM_REGTEST_DRIVER_REG_ALL:
1055 case HWSIM_REGTEST_STRICT_ALL:
1056 regulatory_hint(hw->wiphy, hwsim_alpha2s[0]);
1057 break;
1058 case HWSIM_REGTEST_DIFF_COUNTRY:
1059 if (i < ARRAY_SIZE(hwsim_alpha2s))
1060 regulatory_hint(hw->wiphy, hwsim_alpha2s[i]);
1061 break;
1062 case HWSIM_REGTEST_CUSTOM_WORLD:
1063 case HWSIM_REGTEST_CUSTOM_WORLD_2:
1064 /*
1065 * Nothing to be done for custom world regulatory
1066 * domains after to ieee80211_register_hw
1067 */
1068 break;
1069 case HWSIM_REGTEST_STRICT_FOLLOW:
1070 if (i == 0)
1071 regulatory_hint(hw->wiphy, hwsim_alpha2s[0]);
1072 break;
1073 case HWSIM_REGTEST_STRICT_AND_DRIVER_REG:
1074 if (i == 0)
1075 regulatory_hint(hw->wiphy, hwsim_alpha2s[0]);
1076 else if (i == 1)
1077 regulatory_hint(hw->wiphy, hwsim_alpha2s[1]);
1078 break;
1079 case HWSIM_REGTEST_ALL:
1080 if (i == 2)
1081 regulatory_hint(hw->wiphy, hwsim_alpha2s[0]);
1082 else if (i == 3)
1083 regulatory_hint(hw->wiphy, hwsim_alpha2s[1]);
1084 else if (i == 4)
1085 regulatory_hint(hw->wiphy, hwsim_alpha2s[2]);
1086 break;
1087 default:
1088 break;
1089 }
1090
881 printk(KERN_DEBUG "%s: hwaddr %pM registered\n", 1091 printk(KERN_DEBUG "%s: hwaddr %pM registered\n",
882 wiphy_name(hw->wiphy), 1092 wiphy_name(hw->wiphy),
883 hw->wiphy->perm_addr); 1093 hw->wiphy->perm_addr);