Hi Vladimir, The below commit triggers a warning. tree: git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git for-john head: ba0afa2f22e1e3f332e45460f99328025d44564e commit: 3a0c52a6d82cc41da965284412608c74aece34e4 [648/651] cfg80211: add 802.11ad (60gHz band) support 647: b d9b3b28 2012-07-02 14:47:44 +0200 mac80211: allow calling ieee80211_ap_probereq_get() during auth/assoc 648: B 3a0c52a [ 72.865235] WARNING: at /c/kernel-tests/net/net/wireless/core.c:471 wiphy_register+0x401/0x451() 649: B 90cdc6d [ 64.868502] WARNING: at /c/kernel-tests/net/net/wireless/core.c:471 wiphy_register+0x401/0x451() 650: B b188148 [ 30.024352] WARNING: at /c/kernel-tests/net/net/wireless/core.c:471 wiphy_register+0x401/0x451() 651: B ba0afa2 [ 77.237955] WARNING: at /c/kernel-tests/net/net/wireless/core.c:471 wiphy_register+0x401/0x451() [b] boot OK [B] kernel boots with some problem [ 72.862898] mac80211_hwsim: Initializing radio 0 [ 72.864155] ------------[ cut here ]------------ [ 72.865235] WARNING: at /c/kernel-tests/net/net/wireless/core.c:471 wiphy_register+0x401/0x451() [ 72.867261] Hardware name: Bochs [ 72.868096] Modules linked in: [ 72.868885] Pid: 1, comm: swapper/0 Not tainted 3.5.0-rc1+ #4 [ 72.870152] Call Trace: [ 72.870885] [] warn_slowpath_common+0x83/0x9c [ 72.872241] [] warn_slowpath_null+0x1a/0x1c [ 72.873542] [] wiphy_register+0x401/0x451 [ 72.874835] [] ? __kmalloc+0x128/0x13a [ 72.876069] [] ? ieee80211_register_hw+0x113/0x5dc [ 72.877473] [] ieee80211_register_hw+0x3a4/0x5dc [ 72.878944] [] init_mac80211_hwsim+0x423/0x6a0 [ 72.880294] [] ? carl9170_driver_init+0x1b/0x1b [ 72.881671] [] do_one_initcall+0x7f/0x13a [ 72.882985] [] kernel_init+0x170/0x1f8 [ 72.884215] [] ? do_early_param+0x8c/0x8c [ 72.885483] [] kernel_thread_helper+0x4/0x10 [ 72.886787] [] ? retint_restore_args+0x13/0x13 [ 72.888244] [] ? start_kernel+0x3e7/0x3e7 [ 72.889506] [] ? gs_change+0x13/0x13 [ 72.890695] ---[ end trace bd81035d49db0c0f ]--- [ 72.891797] mac80211_hwsim: ieee80211_register_hw failed (-22) commit 3a0c52a6d82cc41da965284412608c74aece34e4 Author: Vladimir Kondratiev Date: Mon Jul 2 09:32:32 2012 +0300 cfg80211: add 802.11ad (60gHz band) support Add enumerations for both cfg80211 and nl80211. This expands wiphy.bands etc. arrays. Extend channel <-> frequency translation to cover 60g band and modify the rate check logic since there are no legacy mandatory rates (only MCS is used.) Signed-off-by: Vladimir Kondratiev Signed-off-by: Johannes Berg diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index 4b10157..d4fd29a 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -946,7 +946,7 @@ il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) case IEEE80211_BAND_5GHZ: rs_sta->expected_tpt = il3945_expected_tpt_a; break; - case IEEE80211_NUM_BANDS: + default: BUG(); break; } diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h index 2300327..74cc55c 100644 --- a/include/linux/nl80211.h +++ b/include/linux/nl80211.h @@ -2545,10 +2545,12 @@ enum nl80211_tx_rate_attributes { * enum nl80211_band - Frequency band * @NL80211_BAND_2GHZ: 2.4 GHz ISM band * @NL80211_BAND_5GHZ: around 5 GHz band (4.9 - 5.7 GHz) + * @NL80211_BAND_60GHZ: around 60 GHz band (58.32 - 64.80 GHz) */ enum nl80211_band { NL80211_BAND_2GHZ, NL80211_BAND_5GHZ, + NL80211_BAND_60GHZ, }; /** diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index fa26934..0b564e8 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -70,11 +70,13 @@ * * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7) + * @IEEE80211_BAND_60GHZ: around 60 GHz band (58.32 - 64.80 GHz) * @IEEE80211_NUM_BANDS: number of defined bands */ enum ieee80211_band { IEEE80211_BAND_2GHZ = NL80211_BAND_2GHZ, IEEE80211_BAND_5GHZ = NL80211_BAND_5GHZ, + IEEE80211_BAND_60GHZ = NL80211_BAND_60GHZ, /* keep last */ IEEE80211_NUM_BANDS diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 4e75303..4990f4f 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -140,6 +140,8 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx, if (r->flags & IEEE80211_RATE_MANDATORY_A) mrate = r->bitrate; break; + case IEEE80211_BAND_60GHZ: + /* TODO, for now fall through */ case IEEE80211_NUM_BANDS: WARN_ON(1); break; diff --git a/net/wireless/core.c b/net/wireless/core.c index ca2b95f..e13365f 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c @@ -468,8 +468,14 @@ int wiphy_register(struct wiphy *wiphy) continue; sband->band = band; - - if (WARN_ON(!sband->n_channels || !sband->n_bitrates)) + if (WARN_ON(!sband->n_channels)) + return -EINVAL; + /* + * on 60gHz band, there are no legacy rates, so + * n_bitrates is 0 + */ + if (WARN_ON(band != IEEE80211_BAND_60GHZ && + !sband->n_bitrates)) return -EINVAL; /* diff --git a/net/wireless/util.c b/net/wireless/util.c index a9260ac..0228c64 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -35,19 +35,29 @@ int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band) { /* see 802.11 17.3.8.3.2 and Annex J * there are overlapping channel numbers in 5GHz and 2GHz bands */ - if (band == IEEE80211_BAND_5GHZ) { - if (chan >= 182 && chan <= 196) - return 4000 + chan * 5; - else - return 5000 + chan * 5; - } else { /* IEEE80211_BAND_2GHZ */ + if (chan <= 0) + return 0; /* not supported */ + switch (band) { + case IEEE80211_BAND_2GHZ: if (chan == 14) return 2484; else if (chan < 14) return 2407 + chan * 5; + break; + case IEEE80211_BAND_5GHZ: + if (chan >= 182 && chan <= 196) + return 4000 + chan * 5; else - return 0; /* not supported */ + return 5000 + chan * 5; + break; + case IEEE80211_BAND_60GHZ: + if (chan < 5) + return 56160 + chan * 2160; + break; + default: + ; } + return 0; /* not supported */ } EXPORT_SYMBOL(ieee80211_channel_to_frequency); @@ -60,8 +70,12 @@ int ieee80211_frequency_to_channel(int freq) return (freq - 2407) / 5; else if (freq >= 4910 && freq <= 4980) return (freq - 4000) / 5; - else + else if (freq <= 45000) /* DMG band lower limit */ return (freq - 5000) / 5; + else if (freq >= 58320 && freq <= 64800) + return (freq - 56160) / 2160; + else + return 0; } EXPORT_SYMBOL(ieee80211_frequency_to_channel); @@ -137,6 +151,11 @@ static void set_mandatory_flags_band(struct ieee80211_supported_band *sband, } WARN_ON(want != 0 && want != 3 && want != 6); break; + case IEEE80211_BAND_60GHZ: + /* check for mandatory HT MCS 1..4 */ + WARN_ON(!sband->ht_cap.ht_supported); + WARN_ON((sband->ht_cap.mcs.rx_mask[0] & 0x1e) != 0x1e); + break; case IEEE80211_NUM_BANDS: WARN_ON(1); break;