mt7612u AP mode ?
Opened this issue · 9 comments
Hi Lorenzo,
Thank you for your hard work getting the USB mode of the mt7612 working, it is quite usable!
I was wondering how it is possible to enable AP mode in your driver? I don't mind getting my hands dirty and coding, but some direction would be great.
Cheers,
Damien
Hi Lorenzo,
That code looks very different to your code set. Is there a mt76 variant that works with AP, so I can use that as a code base ? (so we keep all the functions named the same etc).
Cheers,
Damien
That is mtk reference code for mt76x2u chipsets. It supports AP/STA/IBSS/MESH
The following patch allows the mt76x2u to "listen" as an AP, and it broadcasts it's SSID.
diff -u mt76-2018-07-01-2efb7b3e.orig/mt76x2u_init.c mt76-2018-07-01-2efb7b3e/mt76x2u_init.c
--- mt76-2018-07-01-2efb7b3e.orig/mt76x2u_init.c 2018-07-01 03:04:32.000000000 +1000
+++ mt76-2018-07-01-2efb7b3e/mt76x2u_init.c 2018-07-28 12:48:25.245832304 +1000
@@ -156,6 +156,43 @@
return dev;
}
+static void mt76x2u_regd_notifier(struct wiphy *wiphy,
+ struct regulatory_request *request)
+{
+ //struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy);
+ //struct mt76x2_dev *dev = hw->priv;
+
+ //mt76x2_dfs_set_domain(dev, request->dfs_region);
+}
+
+static const struct ieee80211_iface_limit if_limits[] = {
+ {
+ .max = 1,
+ .types = BIT(NL80211_IFTYPE_ADHOC)
+ }, {
+ .max = 8,
+ .types = BIT(NL80211_IFTYPE_STATION) |
+#ifdef CONFIG_MAC80211_MESH
+ BIT(NL80211_IFTYPE_MESH_POINT) |
+#endif
+ BIT(NL80211_IFTYPE_AP)
+ },
+};
+
+static const struct ieee80211_iface_combination if_comb[] = {
+ {
+ .limits = if_limits,
+ .n_limits = ARRAY_SIZE(if_limits),
+ .max_interfaces = 8,
+ .num_different_channels = 1,
+ .beacon_int_infra_match = true,
+ .radar_detect_widths = BIT(NL80211_CHAN_WIDTH_20_NOHT) |
+ BIT(NL80211_CHAN_WIDTH_20) |
+ BIT(NL80211_CHAN_WIDTH_40) |
+ BIT(NL80211_CHAN_WIDTH_80),
+ }
+};
+
static void mt76x2u_init_beacon_offsets(struct mt76x2_dev *dev)
{
mt76_wr(dev, MT_BCN_OFFSET(0), 0x18100800);
@@ -276,7 +313,20 @@
if (err < 0)
goto fail;
- wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+ wiphy->iface_combinations = if_comb;
+ wiphy->n_iface_combinations = ARRAY_SIZE(if_comb);
+
+ wiphy->reg_notifier = mt76x2u_regd_notifier;
+
+ wiphy->interface_modes =
+ BIT(NL80211_IFTYPE_STATION) |
+ BIT(NL80211_IFTYPE_AP) |
+#ifdef CONFIG_MAC80211_MESH
+ BIT(NL80211_IFTYPE_MESH_POINT) |
+#endif
+ BIT(NL80211_IFTYPE_ADHOC);
+
+ wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
err = mt76_register_device(&dev->mt76, true, mt76x2_rates,
ARRAY_SIZE(mt76x2_rates));
The log shows the following, so it looks like things are working to some degree:
Sat Jul 28 02:57:47 2018 kern.info kernel: [ 506.887029] IPv6: ADDRCONF(NETDEV_UP): wlan2: link is not ready
Sat Jul 28 02:57:47 2018 kern.info kernel: [ 506.893919] br-lan: port 2(wlan2) entered blocking state
Sat Jul 28 02:57:47 2018 kern.info kernel: [ 506.899255] br-lan: port 2(wlan2) entered disabled state
Sat Jul 28 02:57:47 2018 daemon.notice hostapd: wlan2: interface state UNINITIALIZED->HT_SCAN
Sat Jul 28 02:57:47 2018 kern.info kernel: [ 506.904703] device wlan2 entered promiscuous mode
Sat Jul 28 02:57:47 2018 daemon.err hostapd: Using interface wlan2 with hwaddr e8:4e:06:40:d3:17 and ssid "mascordwifi"
Sat Jul 28 02:57:48 2018 kern.info kernel: [ 507.409108] IPv6: ADDRCONF(NETDEV_CHANGE): wlan2: link becomes ready
Sat Jul 28 02:57:48 2018 kern.info kernel: [ 507.415556] br-lan: port 2(wlan2) entered blocking state
Sat Jul 28 02:57:48 2018 kern.info kernel: [ 507.420902] br-lan: port 2(wlan2) entered forwarding state
Sat Jul 28 02:57:48 2018 daemon.notice hostapd: wlan2: interface state HT_SCAN->ENABLED
Sat Jul 28 02:57:48 2018 daemon.notice hostapd: wlan2: AP-ENABLED
Sat Jul 28 02:57:48 2018 daemon.notice netifd: Network device 'wlan2' link is up
Sat Jul 28 02:58:15 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: authenticated
Sat Jul 28 02:58:15 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: associated (aid 1)
Sat Jul 28 02:58:15 2018 daemon.notice hostapd: wlan2: AP-STA-CONNECTED b0:72:bf:4e:e0:0f
Sat Jul 28 02:58:15 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f RADIUS: starting accounting session 7FA1FDA7AB44A9DE
Sat Jul 28 02:58:15 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: pairwise key handshake completed (RSN)
Sat Jul 28 02:58:17 2018 daemon.notice hostapd: wlan2: AP-STA-DISCONNECTED b0:72:bf:4e:e0:0f
Sat Jul 28 02:58:17 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: disassociated
Sat Jul 28 02:58:18 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: deauthenticated due to inactivity (timer DEAUTH/REMOVE)
Sat Jul 28 02:58:21 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: authenticated
Sat Jul 28 02:58:21 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: associated (aid 1)
Sat Jul 28 02:58:21 2018 daemon.notice hostapd: wlan2: AP-STA-CONNECTED b0:72:bf:4e:e0:0f
Sat Jul 28 02:58:21 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f RADIUS: starting accounting session FD1E991124AEA6C3
Sat Jul 28 02:58:21 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: pairwise key handshake completed (RSN)
Sat Jul 28 02:58:23 2018 daemon.notice hostapd: wlan2: AP-STA-DISCONNECTED b0:72:bf:4e:e0:0f
Sat Jul 28 02:58:23 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: disassociated
Sat Jul 28 02:58:24 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: deauthenticated due to inactivity (timer DEAUTH/REMOVE)
OK, this seems to only work with Windows 10 (with an Intel Centrino Advanced-N 6205), with or without DHCP.
MacOSX, Android both go in the cycles of getting an IP and dropping due to timer DEAUTH/REMOVE.
I have tried with and without authentication too, and it shows the same behaviour.
If I am using the mt7612u as an STA on Windows or even MacosX, I can connect to the other mt7612u that is running as AP:
Station e8:4e:06:5f:48:07 (on wlan2)
inactive time: 1900 ms
rx bytes: 51291
rx packets: 244
tx bytes: 1115
tx packets: 12
tx retries: 0
tx failed: 1
rx drop misc: 3
signal: -36 [-36, -42] dBm
signal avg: -34 [-34, -42] dBm
tx bitrate: 6.5 MBit/s MCS 0
rx bitrate: 585.0 MBit/s VHT-MCS 7 80MHz VHT-NSS 2
authorized: yes
authenticated: yes
associated: yes
preamble: short
WMM/WME: yes
MFP: no
TDLS peer: no
DTIM period: 2
beacon interval:100
short preamble: yes
short slot time:yes
connected time: 76 seconds
Intel card:
Station 60:67:20:a7:1f:a0 (on wlan2)
inactive time: 110 ms
rx bytes: 131445
rx packets: 614
tx bytes: 22294
tx packets: 218
tx retries: 0
tx failed: 1
rx drop misc: 1
signal: -42 [-42, -42] dBm
signal avg: -42 [-42, -42] dBm
tx bitrate: 60.0 MBit/s MCS 9 40MHz short GI
rx bitrate: 300.0 MBit/s MCS 15 40MHz short GI
expected throughput: 37.994Mbps
authorized: yes
authenticated: yes
associated: yes
preamble: short
WMM/WME: yes
MFP: no
TDLS peer: no
DTIM period: 2
beacon interval:100
short preamble: yes
short slot time:yes
connected time: 16 seconds
Android that can't connect:
Station b0:72:bf:4e:e0:0f (on wlan2)
inactive time: 40 ms
rx bytes: 776
rx packets: 9
tx bytes: 566
tx packets: 6
tx retries: 1
tx failed: 0
rx drop misc: 1
signal: -34 [-34, -44] dBm
signal avg: -34 [-34, -44] dBm
tx bitrate: 6.0 MBit/s
rx bitrate: 6.5 MBit/s VHT-MCS 0 VHT-NSS 1
authorized: yes
authenticated: yes
associated: yes
preamble: long
WMM/WME: yes
MFP: no
TDLS peer: no
DTIM period: 2
beacon interval:100
short preamble: yes
short slot time:yes
connected time: 0 seconds
MacOS X Broadcom card that can't connect
Station e4:ce:8f:03:0f:da (on wlan2)
inactive time: 180 ms
rx bytes: 12884
rx packets: 103
tx bytes: 944
tx packets: 11
tx retries: 0
tx failed: 1
rx drop misc: 2
signal: -39 [-39, -46] dBm
signal avg: -37 [-37, -45] dBm
tx bitrate: 6.5 MBit/s MCS 0
rx bitrate: 6.0 MBit/s
expected throughput: 4.394Mbps
authorized: yes
authenticated: yes
associated: yes
preamble: long
WMM/WME: yes
MFP: no
TDLS peer: no
DTIM period: 2
beacon interval:100
short slot time:yes
connected time: 10 seconds
@dmascord this patch is incomplete since beacon tx/rx datapath is completely missing. Please take a look to beacon datapath for pci code. Moreover do not use c++ style comments
I'm not sure what you mean about tx/rx datapath, since how can any STA work without it?
Are you talking about the following, which is missing in the 76x2u implementation:
tasklet_init(&dev->pre_tbtt_tasklet, mt76x2_pre_tbtt_tasklet,
(unsigned long) dev);
Cheers,
Damien
I have added all of the missing "ops" into mt76x2u_ops, as per the attached patch, and the behaviour doesn't change:
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: authentication OK (open system)
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-AUTHENTICATE.indication(b0:72:bf:4e:e0:0f, OPEN_SYSTEM)
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-DELETEKEYS.request(b0:72:bf:4e:e0:0f)
Thu Aug 9 02:13:17 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: authenticated
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: association OK (aid 1)
Thu Aug 9 02:13:17 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: associated (aid 1)
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-ASSOCIATE.indication(b0:72:bf:4e:e0:0f)
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-DELETEKEYS.request(b0:72:bf:4e:e0:0f)
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: binding station to interface 'wlan2'
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: event 1 notification
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: start authentication
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.1X: unauthorizing port
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: sending 1/4 msg of 4-Way Handshake
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: received EAPOL-Key frame (2/4 Pairwise)
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: sending 3/4 msg of 4-Way Handshake
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: received EAPOL-Key frame (4/4 Pairwise)
Thu Aug 9 02:13:17 2018 daemon.notice hostapd: wlan2: AP-STA-CONNECTED b0:72:bf:4e:e0:0f
Thu Aug 9 02:13:17 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.1X: authorizing port
Thu Aug 9 02:13:17 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f RADIUS: starting accounting session AAED5778519269B9
Thu Aug 9 02:13:17 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: pairwise key handshake completed (RSN)
Thu Aug 9 02:13:19 2018 daemon.notice hostapd: wlan2: AP-STA-DISCONNECTED b0:72:bf:4e:e0:0f
Thu Aug 9 02:13:19 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: event 2 notification
Thu Aug 9 02:13:19 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.1X: unauthorizing port
Thu Aug 9 02:13:19 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: disassociated
Thu Aug 9 02:13:19 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-DISASSOCIATE.indication(b0:72:bf:4e:e0:0f, 8)
Thu Aug 9 02:13:19 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-DELETEKEYS.request(b0:72:bf:4e:e0:0f)
Thu Aug 9 02:13:20 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: deauthenticated due to inactivity (timer DEAUTH/REMOVE)
Thu Aug 9 02:13:20 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-DEAUTHENTICATE.indication(b0:72:bf:4e:e0:0f, 2)
Thu Aug 9 02:13:20 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-DELETEKEYS.request(b0:72:bf:4e:e0:0f)
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: authentication OK (open system)
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-AUTHENTICATE.indication(b0:72:bf:4e:e0:0f, OPEN_SYSTEM)
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-DELETEKEYS.request(b0:72:bf:4e:e0:0f)
Thu Aug 9 02:13:23 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: authenticated
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: association OK (aid 1)
Thu Aug 9 02:13:23 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: associated (aid 1)
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-ASSOCIATE.indication(b0:72:bf:4e:e0:0f)
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f MLME: MLME-DELETEKEYS.request(b0:72:bf:4e:e0:0f)
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: binding station to interface 'wlan2'
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: event 1 notification
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: start authentication
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.1X: unauthorizing port
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: sending 1/4 msg of 4-Way Handshake
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: received EAPOL-Key frame (2/4 Pairwise)
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: sending 3/4 msg of 4-Way Handshake
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: received EAPOL-Key frame (4/4 Pairwise)
Thu Aug 9 02:13:23 2018 daemon.notice hostapd: wlan2: AP-STA-CONNECTED b0:72:bf:4e:e0:0f
Thu Aug 9 02:13:23 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.1X: authorizing port
Thu Aug 9 02:13:23 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f RADIUS: starting accounting session 8DF86BE21DA0AE43
Thu Aug 9 02:13:23 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: pairwise key handshake completed (RSN)
Thu Aug 9 02:13:25 2018 daemon.notice hostapd: wlan2: AP-STA-DISCONNECTED b0:72:bf:4e:e0:0f
Thu Aug 9 02:13:25 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f WPA: event 2 notification
Thu Aug 9 02:13:25 2018 daemon.debug hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.1X: unauthorizing port
Thu Aug 9 02:13:25 2018 daemon.info hostapd: wlan2: STA b0:72:bf:4e:e0:0f IEEE 802.11: disassociated
It looks like something is going on with the association that confuses some drivers. The following logs are from my laptop attempting to connect to the mt76x2u:
[42244.086003] wlp4s0: authenticate with e8:4e:06:40:d3:17
[42244.088946] wlp4s0: send auth to e8:4e:06:40:d3:17 (try 1/3)
[42244.089992] wlp4s0: authenticated
[42244.090351] wlp4s0: associate with e8:4e:06:40:d3:17 (try 1/3)
[42244.091489] wlp4s0: RX AssocResp from e8:4e:06:40:d3:17 (capab=0x11 status=0 aid=1)
[42244.092547] wlp4s0: associated
[42244.296092] userif-2: sent link down event.
[42244.296097] userif-2: sent link up event.
[42244.702900] iwlwifi 0000:04:00.0: No association and the time event is over already...
[42244.702953] wlp4s0: Connection to AP e8:4e:06:40:d3:17 lost
[42244.738425] wlp4s0: failed to remove key (1, ff:ff:ff:ff:ff:ff) from hardware (-22)
A working AP using the same STA shows up differently:
[42247.271850] wlp4s0: authenticate with 26:f5:a2:27:99:a9
[42247.274216] wlp4s0: send auth to 26:f5:a2:27:99:a9 (try 1/3)
[42247.276967] wlp4s0: authenticated
[42247.277383] wlp4s0: associate with 26:f5:a2:27:99:a9 (try 1/3)
[42247.296334] wlp4s0: RX AssocResp from 26:f5:a2:27:99:a9 (capab=0x431 status=0 aid=4)
the capab and aid are different.
From what I can see the size of the key exchange between a working example, and a non working example:
EAPOL message 3 in the working case shows 177 packet length, where as the message 3 from the mt76x2u shows 169 bytes. The difference being in the WPA Key Data Length. 64 for the working case, and 56 for the non working case.
Any clues ?