OpenWrt Forum Archive

Topic: Hostapd on 5 ghz

The content of this topic has been archived on 27 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I'm trying to test the ath9k driver on a RB433 equipped with a ubiquiti SR71A mini pci card. On the 2.4 ghz, I could connect to the AP in G mode but no N. My client is a intel 4965 agn card running on debian with the 2.6.28-1 snapshot kernel. I also installed the last version of compat-wireless dated 11 of february. Under windows XP (also running the last version of the proset utility and drivers) i also can connect in G mode but no N. The log reports a odd error "security mismatch with 11n", which really looks like something they use in general when something goes wrong because it appears also when no encryption is selected (open AP). On the support page, they say that one can expect performance better than 56 mbits only when using wpa2 personal AES or no encryption, and it's strongly adviced to use the 5 ghz channels for an effective channel bonding.
Following this advice, i got a set of 3 dual band antennas and I started testing such a configuration. By the way, I'm stuck on configuring the interface because hostapd refuse to set up the interface on the 5 ghz channels.

This is my wireless configuration

root@OpenWrt:/lib/wifi# cat /etc/config/wireless

config 'wifi-device' 'wlan0'
        option 'type' 'mac80211'
        option 'disabled' '0'
        option 'channel' '44'


config 'wifi-iface'
        option 'device' 'wlan0'
        option 'network' 'wifi'
        option 'mode' 'ap'
        option 'ssid' 'OpenWRT-N'
        option 'encryption' 'psk2'
        option 'key' 'secretpassword1'

this is the hostapd.sh script

root@OpenWrt:/lib/wifi# cat hostapd.sh
hostapd_setup_vif() {
        local vif="$1"
        local driver="$2"
        local hostapd_cfg=

        # Examples:
        # psk-mixed/tkip        => WPA1+2 PSK, TKIP
        # wpa-psk2/tkip+aes     => WPA2 PSK, CCMP+TKIP
        # wpa2/tkip+aes         => WPA2 RADIUS, CCMP+TKIP
        # ...

        # TODO: move this parsing function somewhere generic, so that
        # later it can be reused by drivers that don't use hostapd

        # crypto defaults: WPA2 vs WPA1
        case "$enc" in
                wpa2*|WPA2*|*PSK2*|*psk2*)
                        wpa=2
                        crypto="CCMP"
                ;;
                *mixed*)
                        wpa=3
                        crypto="CCMP TKIP"
                ;;
                *)
                        wpa=1
                        crypto="TKIP"
                ;;
        esac

        # explicit override for crypto setting
        case "$enc" in
                *tkip+aes|*TKIP+AES|*tkip+ccmp|*TKIP+CCMP) crypto="CCMP TKIP";;
                *tkip|*TKIP) crypto="TKIP";;
                *aes|*AES|*ccmp|*CCMP) crypto="CCMP";;
        esac

        # use crypto/auth settings for building the hostapd config
        case "$enc" in
                *psk*|*PSK*)
                        config_get psk "$vif" key
                        if [ ${#psk} -eq 64 ]; then
                                append hostapd_cfg "wpa_psk=$psk" "$N"
                        else
                                append hostapd_cfg "wpa_passphrase=$psk" "$N"
                        fi
                ;;
                *wpa*|*WPA*)
                        # required fields? formats?
                        # hostapd is particular, maybe a default configuration for failures
                        config_get server "$vif" server
                        append hostapd_cfg "auth_server_addr=$server" "$N"
                        config_get port "$vif" port
                        port=${port:-1812}
                        append hostapd_cfg "auth_server_port=$port" "$N"
                        config_get secret "$vif" key
                        append hostapd_cfg "auth_server_shared_secret=$secret" "$N"
                        config_get nasid "$vif" nasid
                        append hostapd_cfg "nas_identifier=$nasid" "$N"
                        append hostapd_cfg "eapol_key_index_workaround=1" "$N"
                        append hostapd_cfg "radius_acct_interim_interval=300" "$N"
                        append hostapd_cfg "ieee8021x=1" "$N"
                        append hostapd_cfg "auth_algs=1" "$N"
                        append hostapd_cfg "wpa_key_mgmt=WPA-EAP" "$N"
                        append hostapd_cfg "wpa_group_rekey=300" "$N"
                        append hostapd_cfg "wpa_gmk_rekey=640" "$N"
                ;;
                *)
                        wpa=0
                        crypto=
                ;;
        esac
        config_get ifname "$vif" ifname
        config_get bridge "$vif" bridge
        config_get ssid "$vif" ssid
        config_get device "$vif" device
        config_get channel "$device" channel
        config_get hwmode "$device" hwmode
        case "$hwmode" in
                11a) hwmode=a;;
                11b) hwmode=b;;
                11g) hwmode=g;;
                *)
                        hwmode=
                        [ "$channel" -gt 14 ] && hwmode=a
                ;;
        esac
        cat > /var/run/hostapd-$ifname.conf <<EOF
ctrl_interface=/var/run/hostapd-$ifname
driver=$driver
interface=$ifname
hw_mode=${hwmode:-g}
channel=$channel
${bridge:+bridge=$bridge}
ssid=$ssid
debug=4
wpa=$wpa
${crypto:+wpa_pairwise=$crypto}

ieee80211n=1
ht_capab=[RX-STBC123][SHORT-GI-40][DSSS_CCK-40][HT40-]
$hostapd_cfg
EOF
        hostapd -dd -P /var/run/wifi-$ifname.pid -B /var/run/hostapd-$ifname.conf
}

The debug output of hostapd is the following

root@OpenWrt:/lib/wifi# wifi up
Configuration file: /var/run/hostapd-wlan0.conf
Line 8: DEPRECATED: 'debug' configuration variable is not used anymore
Opening raw packet socket for ifindex 0
BSS count 1, BSSID mask ff:ff:ff:ff:ff:ff (0 bits)
SIOCGIWRANGE: WE(compiled)=22 WE(source)=21 enc_capa=0xf
nl80211: Added 802.11b mode based on 802.11g information
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=20 dBm
wlan0: IEEE 802.11 Configured channel (44) not found from the channel list of current mode (2) IEEE 802.11a
wlan0: IEEE 802.11 Hardware does not support configured channel
Could not select hw_mode and channel. (-1)
wlan0: Unable to setup interface.
rmdir[ctrl_interface]: No such file or directory
enable_mac80211(wlan0): Failed to set up wpa for interface wlan0

As you can see, it is making a check on the 2.4 ghz, which suggest me that it is hardcoded somewhere in the source on hostapd or it does not decode correctly the information got from the system.

(Last edited by simone78 on 13 Feb 2009, 23:08)

I having exactly the same thing with my  (AR5416) in AP mode. I use it with ubuntu sever x86,  I  also have a CF card with OpenWrt on it, but just tested that a coulpe of times.

I could enable AP mode in the 5 Ghz band until a couple of weeks ago (wireless-testing git) then the ath9k regulatory code was changed (about 20.jan ->) and since then I'm not allowed to use any 5Ghz channels in AP mode. So it is not hardcoded, its in the ath9k driver. iw list for me now shows that all channels in 5ghz has passive scanning/no-ibss.

Atheros have a regdomain value and a contry code value stored in their cards eeprom. If they are not "right" you will get a world domain that is restrictive on what channels/modes that are allowed.
Try to contact them you bought the card from, maybe they can change the eeprom?

After days of googling around, I could understand that this was an issue related to regulatory stuff. I also posted in the hostapd mailing list, an a nice soul answered (even if I can't really understand at this stage what type of operating mode can be enabled on 5 ghz).
I doubt the ubiquiti will listen to a request like that, because they push their airos, like mikrotik does with its RouterOS. By the way, all this looking around for informations is really stessing, as everyone talks only to literate and never take time to introduce concepts to freshers.
For example, we know that hostapd is supporting 802.11n from 0.6.7 version. Should I understand that similar steps should also be taken on the client side? When using wpa_supplicant, what I'm supposed to do? SHould I pre-configure the interface with the iw utility, or should I assume a certain level of automatic configuration?

linuxb wrote:

I could enable AP mode in the 5 Ghz band until a couple of weeks ago (wireless-testing git) then the ath9k regulatory code was changed (about 20.jan ->) and since then I'm not allowed to use any 5Ghz channels in AP mode. So it is not hardcoded, its in the ath9k driver. iw list for me now shows that all channels in 5ghz has passive scanning/no-ibss.

I would encourage you to narrow it down the specific date of the compat-wireless change, the old ones are here: http://www.orbit-lab.org/kernel/compat- … -2.6/2009/  Or even better, the specific git checkin.

Then post to ath9k-devel the before/after results.  I think if everyone understands clearly that the rewrite broke something - it will be revisited by the author.

Im using wireless-testing git kernel, I think it was applyed the 23.jan
http://git.kernel.org/?p=linux/kernel/g … 2009-01-23

But I dont belive it broke something (for me it sure did), it was intentional changes to the regulatory code. I still has active scanning in 2.4 Ghz and can use it with hostapd.
I think the reason I lost active scanning in 5 Ghz is because my wifi card has no country code in the eeprom (returns 00), and somehow thats the reason it dont follow my countrys CRDA 100%. (should have allowed active scanning on some 5Ghz channels)   

I wonder if you guys with OpenWrt flashed on dual band routers allso getting troubles with restrictive regulatory/CRDA ?

(Last edited by linuxb on 16 Feb 2009, 23:53)

I have been searching around for this terminology, if I understood well, passive scanning referes to a type of association protocol which is taken on by station machines and does not refer directly to AP mode. I can't explain to myself why it should avoid the equipment to be set as AP. Moreover, assuming that AP can't be configured, the output of "iw list" makes me understand that neither ad-hoc mode is avaliable (no ibss). So, should we assume that 5 ghz can't be used at all? Maybe every manufacturer which relies on atheros chips is hardcoding a personal country code and regdomain value in this eeprom which is later correctly decoded by their proprietary os and drivers?
I found on various mailing lists some examples on how to change the regulatory domains, as for example

iw reg set US

but countries other than US are never accepted. Personally, I think that the reason for such a behaviour is maybe related to legal questions (or even economics) and not to technical ones. I found here something interesting about the subject.

(Last edited by simone78 on 17 Feb 2009, 00:35)

I dont think you have iw or CRDA installed in OpenWRT?
If not you are using the old regulatroy rules, you have add a module parameter to cfg80211 to change the regdomain.
For europe use parameter: ieee80211_regdom=EU

If you have CRDA but not iw, you can use hostapd to change regdomain.
(I think you allso need ieee80211d=1)
like:
country_code=IT
ieee80211d=1

Setting ieee80211_regdom=EU produces a segmentation fault, as reported also form other users in various mailing list. The other option is to use JP as value, but it's not accepted and US is set back.

I don't know why, but now I could set up a 5 ghz AP on channel 40. I suppose it's because I installed the crda package and built again the system today. I see that now we're using kernel 2.6.28-5. By the way, no N speed under linux.

Thats good news, so it seem you have the right card (eeprom).
I comiled OpenWrt (x86) today and installed it. I thought for a moment that I could use 5Ghz channels in AP mode since It was avalible in Luci. But no, iw list confirmed that I had only passive scanning, no-ibss.

The file transfere speed I got (2.4Ghz) was between 5 and 7 MBytes/sek. I was quite close, about 2 Meters from my AP.

I had the same problem with 5 GHz band disabled. I've fixed it by removing ath9k default regdomain restrictions and now all channels are usable.

But switching to 5 Ghz band didn't help my win xp clients with Intel Wifi 5100 and 5300 to connect in N mode, while Broadcom client works in N mode in both 2.4 and 5 GHz bands. More details here: http://forum.openwrt.org/viewtopic.php?pid=82969#p82969


Here is the patch:

--- a/drivers/net/wireless/ath9k/regd.c    2009-02-25 07:14:45.000000000 +0200
+++ b/drivers/net/wireless/ath9k/regd.c    2009-03-01 14:08:15.000000000 +0200
@@ -27,21 +27,16 @@
  */
 
 /* Only these channels all allow active scan on all world regulatory domains */
-#define ATH9K_2GHZ_CH01_11    REG_RULE(2412-10, 2462+10, 40, 0, 20, 0)
+#define ATH9K_2GHZ_CH01_11    REG_RULE(2412-10, 2462+10, 40, 0, 30, 0)
 
 /* We enable active scan on these a case by case basis by regulatory domain */
-#define ATH9K_2GHZ_CH12_13    REG_RULE(2467-10, 2472+10, 40, 0, 20,\
-                    NL80211_RRF_PASSIVE_SCAN)
-#define ATH9K_2GHZ_CH14        REG_RULE(2484-10, 2484+10, 40, 0, 20,\
-                NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM)
+#define ATH9K_2GHZ_CH12_13    REG_RULE(2467-10, 2472+10, 40, 0, 30, 0)
+#define ATH9K_2GHZ_CH14        REG_RULE(2484-10, 2484+10, 40, 0, 30, 0)
 
 /* We allow IBSS on these on a case by case basis by regulatory domain */
-#define ATH9K_5GHZ_5150_5350    REG_RULE(5150-10, 5350+10, 40, 0, 30,\
-                NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
-#define ATH9K_5GHZ_5470_5850    REG_RULE(5470-10, 5850+10, 40, 0, 30,\
-                NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
-#define ATH9K_5GHZ_5725_5850    REG_RULE(5725-10, 5850+10, 40, 0, 30,\
-                NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
+#define ATH9K_5GHZ_5150_5350    REG_RULE(5150-10, 5350+10, 40, 0, 30, 0)
+#define ATH9K_5GHZ_5470_5850    REG_RULE(5470-10, 5850+10, 40, 0, 30, 0)
+#define ATH9K_5GHZ_5725_5850    REG_RULE(5725-10, 5850+10, 40, 0, 30, 0)
 
 #define ATH9K_2GHZ_ALL        ATH9K_2GHZ_CH01_11, \
                 ATH9K_2GHZ_CH12_13, \
@@ -66,42 +61,40 @@
 
 /* Can be used by 0x63 and 0x65 */
 static const struct ieee80211_regdomain ath9k_world_regdom_63_65 = {
-    .n_reg_rules = 4,
+    .n_reg_rules = 5,
     .alpha2 =  "99",
     .reg_rules = {
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_2GHZ_CH12_13,
-        ATH9K_5GHZ_NO_MIDBAND,
+        ATH9K_2GHZ_ALL,
+        ATH9K_5GHZ_ALL,
     }
 };
 
 /* Can be used by 0x64 only */
 static const struct ieee80211_regdomain ath9k_world_regdom_64 = {
-    .n_reg_rules = 3,
+    .n_reg_rules = 5,
     .alpha2 =  "99",
     .reg_rules = {
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_5GHZ_NO_MIDBAND,
+        ATH9K_2GHZ_ALL,
+        ATH9K_5GHZ_ALL,
     }
 };
 
 /* Can be used by 0x66 and 0x69 */
 static const struct ieee80211_regdomain ath9k_world_regdom_66_69 = {
-    .n_reg_rules = 3,
+    .n_reg_rules = 5,
     .alpha2 =  "99",
     .reg_rules = {
-        ATH9K_2GHZ_CH01_11,
+        ATH9K_2GHZ_ALL,
         ATH9K_5GHZ_ALL,
     }
 };
 
 /* Can be used by 0x67, 0x6A and 0x68 */
 static const struct ieee80211_regdomain ath9k_world_regdom_67_68_6A = {
-    .n_reg_rules = 4,
+    .n_reg_rules = 5,
     .alpha2 =  "99",
     .reg_rules = {
-        ATH9K_2GHZ_CH01_11,
-        ATH9K_2GHZ_CH12_13,
+        ATH9K_2GHZ_ALL,
         ATH9K_5GHZ_ALL,
     }
 };
@@ -156,7 +149,7 @@
 /* Frequency is one where radar detection is required */
 static bool ath9k_is_radar_freq(u16 center_freq)
 {
-    return (center_freq >= 5260 && center_freq <= 5700);
+    return 0;  /* (center_freq >= 5260 && center_freq <= 5700); */
 }
 
 /*

Here is the result:

root@asus:~# iw list
Wiphy phy0
        Band 1:
                HT capabilities: 0x104e
                         * 20/40 MHz operation
                         * SM PS disabled
                         * 40 MHz short GI
                         * max A-MSDU len 3839
                         * DSSS/CCK 40 MHz
                HT A-MPDU factor: 0x0003 (65535 bytes)
                HT A-MPDU density: 0x0006 (8 usec)
                HT MCS set: ff ff 00 00 00 00 00 00 00 00 00 00 01 00 00 00
                Frequencies:
                        * 2412 MHz [1] (30.0 dBm)
                        * 2417 MHz [2] (30.0 dBm)
                        * 2422 MHz [3] (30.0 dBm)
                        * 2427 MHz [4] (30.0 dBm)
                        * 2432 MHz [5] (30.0 dBm)
                        * 2437 MHz [6] (30.0 dBm)
                        * 2442 MHz [7] (30.0 dBm)
                        * 2447 MHz [8] (30.0 dBm)
                        * 2452 MHz [9] (30.0 dBm)
                        * 2457 MHz [10] (30.0 dBm)
                        * 2462 MHz [11] (30.0 dBm)
                        * 2467 MHz [12] (30.0 dBm)
                        * 2472 MHz [13] (30.0 dBm)
                        * 2484 MHz [14] (30.0 dBm)
                Bitrates:
                        * 1.0 Mbps
                        * 2.0 Mbps (short preamble supported)
                        * 5.5 Mbps (short preamble supported)
                        * 11.0 Mbps (short preamble supported)
                        * 6.0 Mbps
                        * 9.0 Mbps
                        * 12.0 Mbps
                        * 18.0 Mbps
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
        Band 2:
                HT capabilities: 0x104e
                         * 20/40 MHz operation
                         * SM PS disabled
                         * 40 MHz short GI
                         * max A-MSDU len 3839
                         * DSSS/CCK 40 MHz
                HT A-MPDU factor: 0x0003 (65535 bytes)
                HT A-MPDU density: 0x0006 (8 usec)
                HT MCS set: ff ff 00 00 00 00 00 00 00 00 00 00 01 00 00 00
                Frequencies:
                        * 5180 MHz [36] (30.0 dBm)
                        * 5200 MHz [40] (30.0 dBm)
                        * 5220 MHz [44] (30.0 dBm)
                        * 5240 MHz [48] (30.0 dBm)
                        * 5260 MHz [52] (30.0 dBm)
                        * 5280 MHz [56] (30.0 dBm)
                        * 5300 MHz [60] (30.0 dBm)
                        * 5320 MHz [64] (30.0 dBm)
                        * 5500 MHz [100] (30.0 dBm)
                        * 5520 MHz [104] (30.0 dBm)
                        * 5540 MHz [108] (30.0 dBm)
                        * 5560 MHz [112] (30.0 dBm)
                        * 5580 MHz [116] (30.0 dBm)
                        * 5600 MHz [120] (30.0 dBm)
                        * 5620 MHz [124] (30.0 dBm)
                        * 5640 MHz [128] (30.0 dBm)
                        * 5660 MHz [132] (30.0 dBm)
                        * 5680 MHz [136] (30.0 dBm)
                        * 5700 MHz [140] (30.0 dBm)
                        * 5745 MHz [149] (30.0 dBm)
                        * 5765 MHz [153] (30.0 dBm)
                        * 5785 MHz [157] (30.0 dBm)
                        * 5805 MHz [161] (30.0 dBm)
                        * 5825 MHz [165] (30.0 dBm)
                Bitrates:
                        * 6.0 Mbps
                        * 9.0 Mbps
                        * 12.0 Mbps
                        * 18.0 Mbps
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
        Supported interface modes:
                 * IBSS
                 * Station
                 * AP
                 * AP(VLAN)
                 * Monitor

Make sure to set your country_code in hostapd config if you don't want to violate RF regulatory!

The discussion might have continued from here.