diff options
author | Luis R. Rodriguez <lrodriguez@atheros.com> | 2009-03-06 00:13:06 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-03-16 18:09:29 -0400 |
commit | 22cad73587ac85e2e9d1f52aae62023aec093654 (patch) | |
tree | 6d56469173780de009d3d2ef96f6f5fc80075b58 /drivers/net/wireless/mac80211_hwsim.c | |
parent | 94041b294094bbd9fbbe11aa71278fdc70d29d6d (diff) |
mac80211_hwsim: add support for 5 GHz
ACME Inc. is now selling a dual band radio.
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.c | 138 |
1 files changed, 102 insertions, 36 deletions
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index fce49ba061d5..d8716bed5e46 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
@@ -10,7 +10,6 @@ | |||
10 | /* | 10 | /* |
11 | * TODO: | 11 | * TODO: |
12 | * - IBSS mode simulation (Beacon transmission with competition for "air time") | 12 | * - IBSS mode simulation (Beacon transmission with competition for "air time") |
13 | * - IEEE 802.11a and 802.11n modes | ||
14 | * - RX filtering based on filter configuration (data->rx_filter) | 13 | * - RX filtering based on filter configuration (data->rx_filter) |
15 | */ | 14 | */ |
16 | 15 | ||
@@ -86,22 +85,65 @@ static struct class *hwsim_class; | |||
86 | 85 | ||
87 | static struct net_device *hwsim_mon; /* global monitor netdev */ | 86 | static struct net_device *hwsim_mon; /* global monitor netdev */ |
88 | 87 | ||
88 | #define CHAN2G(_freq) { \ | ||
89 | .band = IEEE80211_BAND_2GHZ, \ | ||
90 | .center_freq = (_freq), \ | ||
91 | .hw_value = (_freq), \ | ||
92 | .max_power = 20, \ | ||
93 | } | ||
94 | |||
95 | #define CHAN5G(_freq) { \ | ||
96 | .band = IEEE80211_BAND_5GHZ, \ | ||
97 | .center_freq = (_freq), \ | ||
98 | .hw_value = (_freq), \ | ||
99 | .max_power = 20, \ | ||
100 | } | ||
101 | |||
102 | static const struct ieee80211_channel hwsim_channels_2ghz[] = { | ||
103 | CHAN2G(2412), /* Channel 1 */ | ||
104 | CHAN2G(2417), /* Channel 2 */ | ||
105 | CHAN2G(2422), /* Channel 3 */ | ||
106 | CHAN2G(2427), /* Channel 4 */ | ||
107 | CHAN2G(2432), /* Channel 5 */ | ||
108 | CHAN2G(2437), /* Channel 6 */ | ||
109 | CHAN2G(2442), /* Channel 7 */ | ||
110 | CHAN2G(2447), /* Channel 8 */ | ||
111 | CHAN2G(2452), /* Channel 9 */ | ||
112 | CHAN2G(2457), /* Channel 10 */ | ||
113 | CHAN2G(2462), /* Channel 11 */ | ||
114 | CHAN2G(2467), /* Channel 12 */ | ||
115 | CHAN2G(2472), /* Channel 13 */ | ||
116 | CHAN2G(2484), /* Channel 14 */ | ||
117 | }; | ||
89 | 118 | ||
90 | static const struct ieee80211_channel hwsim_channels[] = { | 119 | static const struct ieee80211_channel hwsim_channels_5ghz[] = { |
91 | { .center_freq = 2412 }, | 120 | CHAN5G(5180), /* Channel 36 */ |
92 | { .center_freq = 2417 }, | 121 | CHAN5G(5200), /* Channel 40 */ |
93 | { .center_freq = 2422 }, | 122 | CHAN5G(5220), /* Channel 44 */ |
94 | { .center_freq = 2427 }, | 123 | CHAN5G(5240), /* Channel 48 */ |
95 | { .center_freq = 2432 }, | 124 | |
96 | { .center_freq = 2437 }, | 125 | CHAN5G(5260), /* Channel 52 */ |
97 | { .center_freq = 2442 }, | 126 | CHAN5G(5280), /* Channel 56 */ |
98 | { .center_freq = 2447 }, | 127 | CHAN5G(5300), /* Channel 60 */ |
99 | { .center_freq = 2452 }, | 128 | CHAN5G(5320), /* Channel 64 */ |
100 | { .center_freq = 2457 }, | 129 | |
101 | { .center_freq = 2462 }, | 130 | CHAN5G(5500), /* Channel 100 */ |
102 | { .center_freq = 2467 }, | 131 | CHAN5G(5520), /* Channel 104 */ |
103 | { .center_freq = 2472 }, | 132 | CHAN5G(5540), /* Channel 108 */ |
104 | { .center_freq = 2484 }, | 133 | CHAN5G(5560), /* Channel 112 */ |
134 | CHAN5G(5580), /* Channel 116 */ | ||
135 | CHAN5G(5600), /* Channel 120 */ | ||
136 | CHAN5G(5620), /* Channel 124 */ | ||
137 | CHAN5G(5640), /* Channel 128 */ | ||
138 | CHAN5G(5660), /* Channel 132 */ | ||
139 | CHAN5G(5680), /* Channel 136 */ | ||
140 | CHAN5G(5700), /* Channel 140 */ | ||
141 | |||
142 | CHAN5G(5745), /* Channel 149 */ | ||
143 | CHAN5G(5765), /* Channel 153 */ | ||
144 | CHAN5G(5785), /* Channel 157 */ | ||
145 | CHAN5G(5805), /* Channel 161 */ | ||
146 | CHAN5G(5825), /* Channel 165 */ | ||
105 | }; | 147 | }; |
106 | 148 | ||
107 | static const struct ieee80211_rate hwsim_rates[] = { | 149 | static const struct ieee80211_rate hwsim_rates[] = { |
@@ -126,8 +168,9 @@ struct mac80211_hwsim_data { | |||
126 | struct list_head list; | 168 | struct list_head list; |
127 | struct ieee80211_hw *hw; | 169 | struct ieee80211_hw *hw; |
128 | struct device *dev; | 170 | struct device *dev; |
129 | struct ieee80211_supported_band band; | 171 | struct ieee80211_supported_band bands[2]; |
130 | struct ieee80211_channel channels[ARRAY_SIZE(hwsim_channels)]; | 172 | struct ieee80211_channel channels_2ghz[ARRAY_SIZE(hwsim_channels_2ghz)]; |
173 | struct ieee80211_channel channels_5ghz[ARRAY_SIZE(hwsim_channels_5ghz)]; | ||
131 | struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)]; | 174 | struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)]; |
132 | 175 | ||
133 | struct ieee80211_channel *channel; | 176 | struct ieee80211_channel *channel; |
@@ -728,6 +771,7 @@ static int __init init_mac80211_hwsim(void) | |||
728 | u8 addr[ETH_ALEN]; | 771 | u8 addr[ETH_ALEN]; |
729 | struct mac80211_hwsim_data *data; | 772 | struct mac80211_hwsim_data *data; |
730 | struct ieee80211_hw *hw; | 773 | struct ieee80211_hw *hw; |
774 | enum ieee80211_band band; | ||
731 | 775 | ||
732 | if (radios < 1 || radios > 100) | 776 | if (radios < 1 || radios > 100) |
733 | return -EINVAL; | 777 | return -EINVAL; |
@@ -785,25 +829,47 @@ static int __init init_mac80211_hwsim(void) | |||
785 | hw->vif_data_size = sizeof(struct hwsim_vif_priv); | 829 | hw->vif_data_size = sizeof(struct hwsim_vif_priv); |
786 | hw->sta_data_size = sizeof(struct hwsim_sta_priv); | 830 | hw->sta_data_size = sizeof(struct hwsim_sta_priv); |
787 | 831 | ||
788 | memcpy(data->channels, hwsim_channels, sizeof(hwsim_channels)); | 832 | memcpy(data->channels_2ghz, hwsim_channels_2ghz, |
833 | sizeof(hwsim_channels_2ghz)); | ||
834 | memcpy(data->channels_5ghz, hwsim_channels_5ghz, | ||
835 | sizeof(hwsim_channels_5ghz)); | ||
789 | memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); | 836 | memcpy(data->rates, hwsim_rates, sizeof(hwsim_rates)); |
790 | data->band.channels = data->channels; | 837 | |
791 | data->band.n_channels = ARRAY_SIZE(hwsim_channels); | 838 | for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) { |
792 | data->band.bitrates = data->rates; | 839 | struct ieee80211_supported_band *sband = &data->bands[band]; |
793 | data->band.n_bitrates = ARRAY_SIZE(hwsim_rates); | 840 | switch (band) { |
794 | data->band.ht_cap.ht_supported = true; | 841 | case IEEE80211_BAND_2GHZ: |
795 | data->band.ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | | 842 | sband->channels = data->channels_2ghz; |
796 | IEEE80211_HT_CAP_GRN_FLD | | 843 | sband->n_channels = |
797 | IEEE80211_HT_CAP_SGI_40 | | 844 | ARRAY_SIZE(hwsim_channels_2ghz); |
798 | IEEE80211_HT_CAP_DSSSCCK40; | 845 | break; |
799 | data->band.ht_cap.ampdu_factor = 0x3; | 846 | case IEEE80211_BAND_5GHZ: |
800 | data->band.ht_cap.ampdu_density = 0x6; | 847 | sband->channels = data->channels_5ghz; |
801 | memset(&data->band.ht_cap.mcs, 0, | 848 | sband->n_channels = |
802 | sizeof(data->band.ht_cap.mcs)); | 849 | ARRAY_SIZE(hwsim_channels_5ghz); |
803 | data->band.ht_cap.mcs.rx_mask[0] = 0xff; | 850 | break; |
804 | data->band.ht_cap.mcs.rx_mask[1] = 0xff; | 851 | default: |
805 | data->band.ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; | 852 | break; |
806 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &data->band; | 853 | } |
854 | |||
855 | sband->bitrates = data->rates; | ||
856 | sband->n_bitrates = ARRAY_SIZE(hwsim_rates); | ||
857 | |||
858 | sband->ht_cap.ht_supported = true; | ||
859 | sband->ht_cap.cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | | ||
860 | IEEE80211_HT_CAP_GRN_FLD | | ||
861 | IEEE80211_HT_CAP_SGI_40 | | ||
862 | IEEE80211_HT_CAP_DSSSCCK40; | ||
863 | sband->ht_cap.ampdu_factor = 0x3; | ||
864 | sband->ht_cap.ampdu_density = 0x6; | ||
865 | memset(&sband->ht_cap.mcs, 0, | ||
866 | sizeof(sband->ht_cap.mcs)); | ||
867 | sband->ht_cap.mcs.rx_mask[0] = 0xff; | ||
868 | sband->ht_cap.mcs.rx_mask[1] = 0xff; | ||
869 | sband->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; | ||
870 | |||
871 | hw->wiphy->bands[band] = sband; | ||
872 | } | ||
807 | 873 | ||
808 | err = ieee80211_register_hw(hw); | 874 | err = ieee80211_register_hw(hw); |
809 | if (err < 0) { | 875 | if (err < 0) { |