Support for WAVE 300 Wi-Fi chip

T9.User-Manual-3606265.pdf

Thanks for the manual. I didn't find it when I was researching wave300 materials.

TP-LINK TD-W9980B(DE) V1.0 firmware updates contain GPL'ed modules of 3.4 version, but no sources. I've asked tp-link to update tarball with GPL source from TD-W9980 (3.1 version I think), but they said it will take some time (and resources) to do that as the device is a few years old now.

A D6100 owner could probably ask somebody in netgear to do that too btw.

NetGear D6100 has the driver of version 3.4 compiled in folder package

https://kb.netgear.com/2649/NETGEAR-Open-Source-Code-for-Programmers-GPL

in https://www.downloads.netgear.com/files/GPL/D6100-V1.0.0.38_0.0.38_with_toolchain_src.zip exists OpenSource code and Lantiq Drivers for UGW-5.4.0 release. This software is part of CPE Software Suite distributed by Lantiq.

I looked there and there seems to be only a build system with compiled object files and kernel modules under GPL version (grep for "GPL"), but no C source codes. You could not make a working driver with object files only, because there will be most likely API+ABI changes in current 4.14 kernel version (and I think these modules are for 2.6, which is really old).

IANAL but you are eligible to obtain GPL source codes as there is GPLed kernel module.

I think my problem seems to be the firmware you mentioned. If you have the firmware, can you share it?

It just crashes the system giving a kernel panic. I am not sure why but it could be firmware related.

Hmm it seems I deleted my copy of firmware when I regenerated my openwrt build :-/ but all I did was just extracting the firmware from zip file from here combined with 9980 versions of the modem, D6100 GPL zip and copies from the modem itself (you can copy the files to a usb stick in shell on uart console).

I was able to only scan network without any association to AP, but no kernel panic.

Tp link website does not offer the 131012 firmware anymore, it has only newer versions of firmware. I cant find the above firmware that you mentioned before. I don't think that newer firmware versions would work with this driver.

In my case I cant even bring up the wifi interface, it crashes the system while giving a kernel panic when I load the modules. I think it should be related to firmware mismatch between driver and other ProgModel etc files.

I will try to look at that but really I'm pretty sure I didn't had the 131012 firmware either. I've just used a newer one. I'm gonna look at it in the future, but any other 5G AP device I've got now is the second wave300 :-/ . And I'm still waiting on the 3.4 drivers from tp-link anyway :smiley:

An Update:

I compiled the driver with v18.06.1 and I am again seeing the Kernel Panic. This time I know how to use the gdb to debug it.

So here is the actual output of the log:

Log for WAVE300 5Ghz
root@AP254:/# insmod /usb/mtlkroot.ko cdebug=9
[ 1129.661931] mtlkroot: module license 'Proprietary' taints kernel.
[ 1129.666692] Disabling lock debugging due to kernel taint
[ 1129.675774] [0000829612] mtlk0(mtlk_cdev_init:316): Max nodex set to 1048575
root@AP254:/# 
root@AP254:/# insmod /usb/mtlkroot.ko cdebug=9.ko ap=1
[ 1139.264008] [0000839200] mtlk0(__mtlk_print_endianess:3867): The system is Big endian (0xbeadfeed, 0xedfeadbe)
[ 1139.272708] [0000839208] mtlk1(mtlk_df_proc_node_create:125): Proc node root/ created
[ 1139.280571] [0000839216] mtlk1(mtlk_df_proc_node_create:127): Proc node root/mtlk created
[ 1139.288708] [0000839224] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry mtlk/version created
[ 1139.297851] [0000839232] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry mtlk/topology created
[ 1139.307296] [0000839244] mtlk0(mtlk_fast_mem_print_info:105): Using normal memory for hot context
[ 1139.315924] PCI: Enabling device 0000:00:0e.0 (0000 -> 0002)
[ 1139.321735] [0000839256] mtlk0(_mtlk_df_user_alloc_devname:6511): NDEV Name pattern: wlan%d
[ 1139.330084] [0000839264] mtlk1(mtlk_df_proc_node_create:127): Proc node mtlk/wlan1 created
[ 1139.338275] [0000839272] mtlk1(mtlk_df_proc_node_create:127): Proc node wlan1/Debug created
[ 1139.346614] [0000839280] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry wlan1/hw_limits created
[ 1139.356011] [0000839292] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry wlan1/reg_limits created
[ 1139.365506] [0000839300] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry wlan1/antenna_gain created
[ 1139.375209] [0000839312] mtlk1(_mtlk_df_proc_node_add_entry:229): Proc entry wlan1/do_debug_assert created
[ 1139.384814] [0000839320] mtlk1(_mtlk_df_proc_node_add_entry:229): Proc entry wlan1/lm created
[ 1139.393385] [0000839328] mtlk1(_mtlk_df_proc_node_add_entry:229): Proc entry wlan1/um created
[ 1139.401889] [0000839336] mtlk1(_mtlk_df_proc_node_add_entry:229): Proc entry wlan1/shram created
[ 1139.410665] [0000839344] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry Debug/General created
[ 1139.419900] [0000839356] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry Debug/MACStats created
[ 1139.429207] [0000839364] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry wlan1/igmp created
[ 1139.438186] [0000839372] mtlk1(_mtlk_df_proc_node_add_entry:229): Proc entry Debug/ResetStats created
[ 1139.447406] [0000839384] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry wlan1/aocs_history created
[ 1139.457057] [0000839392] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry wlan1/aocs_table created
[ 1139.466559] [0000839400] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry wlan1/aocs_channels created
[ 1139.476303] [0000839412] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry wlan1/aocs_penalties created
[ 1139.486133] [0000839420] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry Debug/L2NAT created
[ 1139.495208] [0000839432] mtlk1(_mtlk_df_proc_node_add_entry:229): Proc entry Debug/L2NAT_ClearTable created
[ 1139.504943] [0000839440] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry Debug/ReorderingStats created
[ 1139.514855] [0000839448] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry wlan1/EECaps created
[ 1139.523994] [0000839460] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry Debug/SendQueue created
[ 1139.533403] [0000839468] mtlk1(mtlk_df_proc_node_add_seq_entry:438): Proc entry Debug/serializer_dump created
[ 1139.543315] [0000839480] mtlk1(mtlk_print_drv_info:8042): *********************************************************
[ 1139.553730] [0000839488] mtlk1(mtlk_print_drv_info:8043): * Driver Compilation Details:
[ 1139.561758] [0000839496] mtlk1(mtlk_print_drv_info:8044): *********************************************************
[ 1139.572237] [0000839508] mtlk1(mtlk_print_drv_info:8046): * CONFIG=PLATFORM_UGW51_VRX288 COMPONENTS LIN_DRV LIN_RTLOG_COMPONENTS BUS_PCI_PCIE LINDRV_HW LINDRV_HW_PCIE LINDRV_HW_PCIG3 RF_MANAGEMENT_MTLK TXMM_HISTORY_LENGTH=0 RT_LOGGER_FUNCTIONS MAX_DLEVEL=1 USE_GENL_DEF USE_GENL ENVIRONMENT_NAME="ugw5.1-vrx288" HOST_TYPE="mips-linux" 
[ 1139.601806] [0000839536] mtlk1(mtlk_print_drv_info:8046): * CFLAGS=
[ 1139.608043] [0000839544] mtlk1(mtlk_print_drv_info:8046): * MTLK_KERNEL_CFLAGS=-mlong-calls
[ 1139.616415] [0000839552] mtlk1(mtlk_print_drv_info:8046): * KERNELDIR=/home/ahmar/src/openwrt/build_dir/target-mips_24kc_musl/linux-lantiq_xrx200/linux-4.9.151
[ 1139.630692] [0000839564] mtlk1(mtlk_print_drv_info:8046): * CROSS_COMPILE=/home/ahmar/src/WAVE300/driver/builds/ugw5.1-vrx288/../../support/mtlkfront.sh /home/ahmar/src/openwrt/staging_dir/toolchain-mips_24kc_gcc-7.3.0_musl/bin/mips-openwrt-linux-
[ 1139.652646] [0000839588] mtlk1(mtlk_print_drv_info:8046): * HOSTNAME=
[ 1139.659045] [0000839592] mtlk1(mtlk_print_drv_info:8049): *********************************************************
[ 1139.669516] [0000839604] mtlk0(mtlk_core_pdb_fast_handles_open:33): Open Hot-path parameters
[ 1139.678022] [0000839612] mtlk1(mtlk_qos_set_map:152): Set 802.11 TID-to-AC mapping
[ 1139.685539] [0000839620] mtlk4(_mtlk_core_get_max_stas_supported_by_fw:3227): Cannot get MAX STAs supported by FW. Forcing default
[ 1139.697368] [0000839632] mtlk1(_mtlk_core_get_max_stas_supported_by_fw:3231): MAX STAs supported by FW: 32
[ 1139.847788] [0000839784] mtlk1(_mtlk_mmb_init_fw_capabilities:2735): FW supports 32 STAs 5 VAPs
[ 1139.879753] [0000839816] mtlk0(_mtlk_core_start:9001): CID-0000: Driver version: 3.2.1.1.48..PciG3.PcieG3.Release
[ 1139.879753] MAC/PHY versions:
[ 1139.879753] ap_upper.bin: @@@ VERSION INFO @@@ version number: FW_3.2.1_r5437 MIPS:  Upper CPU(TMC AGG AP) interface: PCI  phy type: real phy on Mar 28 2012 at 11:00:01@@@ END @@@
[ 1139.879753] contr_lm.bin: @@@ VERSION INFO @@@ version number: FW_3.2.1_r5437 MIPS:  Lower MAC  interface: --  phy type: real phy on Mar 28 2012 at 10:59:46@@@ END @@@
[ 1139.879753] 
[ 1139.924449] [0000839860] mtlk1(mtlk_core_set_net_state:681): Going from NET_STATE_HALTED to NET_STATE_IDLE
[ 1139.933903] [0000839868] mtlk1(mtlk_flctrl_register:67): mtlk_flctrl_register id = 0x1
[ 1141.037763] [0000840972] mtlk1(mtlk_pdb_set_mac:401): << set MAC param: id(2) MAC(00:09:86:00:00:00) 
[ 1141.045663] [0000840980] mtlk1(_mtlk_core_set_mac_addr:3557): CID-0000: New MAC: 00:09:86:00:00:00
[ 1141.054615] [0000840988] mtlk0(mtlk_eeprom_check_ee_data:2094): Options mask is 0x00
[ 1141.062644] [0000840996] mtlk1(mtlk_pdb_set_int:353): << set param: id(13) value(0)
[ 1141.070066] [0000841004] mtlk1(_mtlk_core_country_code_set_default:11828): CID-0000: Country is set to (on init): ??(0x00)
[ 1141.081277] [0000841016] mtlk4(load_default_hw_table:1768): No HW limits is available for this platform (0x1a30:0x0700, type 0x38 rev 0x41)
[ 1141.093722] [0000841028] mtlk1(mtlk_pdb_set_binary:385): << set binary param: res(0) id(36) 
[ 1141.102166] [0000841036] mtlk1(mtlk_pdb_set_binary:385): << set binary param: res(0) id(37) 
[ 1141.111134] [0000841048] mtlk1(mtlk_flctrl_register:67): mtlk_flctrl_register id = 0x2
[ 1141.118507] [0000841052] mtlk1(mtlk_flctrl_register:67): mtlk_flctrl_register id = 0x4
[ 1141.126450] [0000841060] mtlk1(mtlk_pdb_set_int:353): << set param: id(24) value(0)
[ 1141.134102] [0000841068] mtlk1(mtlk_pdb_set_int:353): << set param: id(25) value(0)
[ 1141.141748] [0000841076] mtlk1(mtlk_pdb_set_int:353): << set param: id(23) value(8)
[ 1141.149415] [0000841084] mtlk1(mtlk_pdb_set_int:353): << set param: id(22) value(8)
[ 1141.157494] [0000841092] mtlk1(mtlk_core_set_net_state:681): Going from NET_STATE_IDLE to NET_STATE_READY
[ 1141.166651] Kernel bug detected[#1]:
[ 1141.170118] CPU: 1 PID: 2600 Comm: insmod Tainted: P                4.9.120 #0
[ 1141.177338] task: 83980000 task.stack: 8284c000
[ 1141.181854] $ 0   : 00000000 0080010c 00000001 00000001
[ 1141.187071] $ 4   : 82a5d000 804f0000 00000000 ffffff00
[ 1141.192283] $ 8   : 805270a0 00010000 0000010c 0000c800
[ 1141.197506] $12   : af89aea5 1c51043c 00000000 6e672066
[ 1141.202729] $16   : 82a5d000 81d80000 00000000 00000000
[ 1141.207954] $20   : 82aa7a80 0000abce 829a1010 8043b740
[ 1141.213175] $24   : 00000000 8005d4b8                  
[ 1141.218396] $28   : 8284c000 8284dab0 00000000 80325694
[ 1141.223630] Hi    : 0035e1b1
[ 1141.226492] Lo    : 49800000
[ 1141.229375] epc   : 803256c0 0x803256c0
[ 1141.233202] ra    : 80325694 0x80325694
[ 1141.237030] Status: 1100c303KERNEL EXL IE 
[ 1141.241204] Cause : 10800034 (ExcCode 0d)
[ 1141.245212] PrId  : 00019556 (MIPS 34Kc)
[ 1141.249123] Modules linked in: mtlk(P+) mtlkroot(P) ath9k ath9k_common ath9k_hw ath pppoe nf_conntrack_ipv6 mac80211 iptable_nat ipt_REJECT ipt_MASQUERADE cfg80211 xt_time xt_tcpudp xt_state xt_nat xt_multiport xt_mark xt_mac xt_limit xt_conntrack xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_CT pppox ppp_async owl_loader nf_reject_ipv4 nf_nat_redirect nf_nat_masquerade_ipv4 nf_conntrack_ipv4 nf_nat_ipv4 nf_nat nf_log_ipv4 nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache nf_conntrack ltq_deu_vr9 iptable_mangle iptable_filter ip_tables crc_ccitt compat drv_dsl_cpe_api ledtrig_usbport drv_mei_cpe ip6t_REJECT nf_reject_ipv6 nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables x_tables pppoatm ppp_generic slhc cifs br2684 atm drv_ifxos sha256_generic md5 md4 hmac ecb des_generic usb_storage dwc2 uhci_hcd ohci_platform ohci_hcd ehci_platform sd_mod scsi_mod ehci_hcd gpio_button_hotplug ext4 jbd2 mbcache crc32c_generic
Process insmod (pid: 2600, threadinfo=8284c000, task=83980000, tls=7771fdc0)
[ 1141.338251] Stack : 82a5d804 00000004 000001ff 80032d30 81d7454c 0000abce 82a5d000 81d80000
[ 1141.346604]         00000000 00000000 82aa7a80 80325c48 82e3ca00 81d193d0 81d74ec4 81d7454c
[ 1141.354962]         82a5d4a0 81d2fde4 82a5d804 00000000 81d80000 82e3ca00 81d80000 81d16f6c
[ 1141.363315]         82aa7a00 82aa7a80 82850000 82e24104 00000000 00000000 81d80000 81d1f7e4
[ 1141.371672]         8043b740 00098600 00001950 83a2f004 82e3ca34 82aa7a00 82a5d804 81d0d0b0
[ 1141.380028]         ...
[ 1141.382463] Call Trace:[ 1141.384785] [<80032d30>] 0x80032d30
[ 1141.388279] [<80325c48>] 0x80325c48
[ 1141.391733] [<81d193d0>] 0x81d193d0 [mtlk@81d00000+0x82310]
[ 1141.397294] [<81d2fde4>] 0x81d2fde4 [mtlk@81d00000+0x82310]
[ 1141.402886] [<81d16f6c>] 0x81d16f6c [mtlk@81d00000+0x82310]
[ 1141.408518] [<81d1f7e4>] 0x81d1f7e4 [mtlk@81d00000+0x82310]
[ 1141.414043] [<81d0d0b0>] 0x81d0d0b0 [mtlk@81d00000+0x82310]
[ 1141.419590] [<81d35368>] 0x81d35368 [mtlk@81d00000+0x82310]
[ 1141.425169] [<81d34db4>] 0x81d34db4 [mtlk@81d00000+0x82310]
[ 1141.430738] [<81dff7d0>] 0x81dff7d0 [mtlk@81d00000+0x82310]
[ 1141.436340] [<80244f84>] 0x80244f84
[ 1141.439750] [<8026e928>] 0x8026e928
[ 1141.443257] [<8026f10c>] 0x8026f10c
[ 1141.446704] [<800cb128>] 0x800cb128
[ 1141.450217] [<8026f29c>] 0x8026f29c
[ 1141.453677] [<8026d328>] 0x8026d328
[ 1141.457175] [<8026f218>] 0x8026f218
[ 1141.460639] [<8026d3e0>] 0x8026d3e0
[ 1141.464133] [<8042d33c>] 0x8042d33c
[ 1141.467606] [<8026d22c>] 0x8026d22c
[ 1141.471099] [<8026e714>] 0x8026e714
[ 1141.474572] [<81d20720>] 0x81d20720 [mtlk@81d00000+0x82310]
[ 1141.480162] [<8026f874>] 0x8026f874
[ 1141.483636] [<8026fa38>] 0x8026fa38
[ 1141.487108] [<81dff84c>] 0x81dff84c [mtlk@81d00000+0x82310]
[ 1141.492696] [<81dff938>] 0x81dff938 [mtlk@81d00000+0x82310]
[ 1141.498284] [<81dff84c>] 0x81dff84c [mtlk@81d00000+0x82310]
[ 1141.503812] [<800025f4>] 0x800025f4
[ 1141.507310] [<80041690>] 0x80041690
[ 1141.510874] [<800ab0a8>] 0x800ab0a8
[ 1141.514296] [<800e5804>] 0x800e5804
[ 1141.517752] [<8009b9f8>] 0x8009b9f8
[ 1141.521238] [<80099900>] 0x80099900
[ 1141.524708] [<800241dc>] 0x800241dc
[ 1141.528181] [<8009bbe0>] 0x8009bbe0
[ 1141.531670] [<8009bc68>] 0x8009bc68
[ 1141.535177] [<800195f8>] 0x800195f8
[ 1141.538626] [<802054f8>] 0x802054f8
[ 1141.542108] 
[ 1141.543578] Code: 00000000  92020310  0002102b <00020336> 3c138054  2672c560  2e420001  00020336  ae000198 
[ 1141.553325] 
[ 1141.555053] ---[ end trace 373327e32ee128ed ]---
[ 1141.566164] Kernel panic - not syncing: Fatal exception
[ 1141.574550] Rebooting in 3 seconds..

I was also able to debug the error code 0x81d as the stack-trace shows and the output is this:

(gdb) list *0x81d
0x81d is in _mtlk_core_set_wep_key_blocked (/home/ahmar/src/WAVE300/driver/builds/ugw5.1-vrx288/wireless/driver/linux/wireless/driver/linux/core.c:7504).
7499    }
7500
7501    static int
7502    _mtlk_core_set_wep_key_blocked (struct nic      *nic,
7503                                    const IEEE_ADDR *addr)
7504    {
7505      int               res             = MTLK_ERR_UNKNOWN;
7506      mtlk_txmm_msg_t   man_msg;
7507      mtlk_txmm_data_t *man_entry       = NULL;
7508      uint16            default_key_idx = nic->slow_ctx->default_key;

It seems to me the driver is loading and trying to start the interface but it fails around the authentication methods. Correct me here if needed but I think it's trying to load WEP security protocol and the Key that is being inserted (if any) is not correct and that is why it's failing.

A newer version of WAVE 300 has been found: lq-wave-300-03.02.03.01.25.3b077c8ba5b3.gpl.wls.src.tar.bz2, mirror. The root LICENSE file is GPL, there is MODULE_LICENSE("GPL"); in wireless/driver/linux/mtlk_mmb_drv.c. Seems to be ~1 year younger version than the current one from vittorio88's repository.

I have never run into this error, are you enabling WEP?
I wouldn't bother with encryption until we get further with the driver.

Excellent find!

Remember to also get the rflib that is next to it!
lq-wave-300-03.02.03.01.25.3b077c8ba5b3.rflib.wls.bin.tar.bz2

You should then untar them together in the same path, so the rflib is not missing when you try to build the driver.

Sorry for not getting back to you about this sooner.

Yes, the latest branch is the master one you found on my repository.

Something changed in OpenWRT in the trunk with respect to the latest release, and I also was getting a similar errror when it came to stripping the modules. Something about: illegal characters during strip of logmacro that is used in many places. I got past this issue by checking out 18.06.2 and issuing a git clean -dfx and wiping and re-downloading all feeds ( they do not get wiped because they are different repositories then the top-level openwrt one.

thanks

Sadly it seems to be only a prebuild archive file :-/ but the source codes for rflib are in your repository. Hmm it could be even possible to correlate them with a source code a mark the changes :smiley: . BTW what the rflib is exactly, something which is communicating directly to the firmware?

The building system of the driver is crazy if I will obtain 3.4 driver from tplink I will probably try to rewrite it.

BTW I managed to build (probably not working) driver, there is bunch of old kernel API which needs to be patched, it seems to be patched in your repo already (mostly /proc file creation API).

No I am not enabling anything apart from the chip itself. This error shows up in gdb but the kernel panic was from the insmod command with ap=1. I think I'll give a try to the new driver. Maybe it can be hooked up and starts to work.

Mmm didn't notice it was prebuilt. I am pretty sure it is distributed like that due to it being under a different license. That sucks, but it may be because it has proprietary RF code that is not licensed under GPL. I believe the code won't build w/o it. Make menuconfig provides a configuration option to provide a prebuilt rflib, so I believe that is the way we should go for now.

I agree, it's pretty crazy. It is not meant to be integrated into OpenWRT or linux, rather, be a platform to build drivers for many different distros.

I hope you do obtain a newer version of the driver, but it may not be in a useful timeframe.

Yeah, me and Mandrake up-ported proc-fs to latest kernels... (surely with a bug or two somewhere, so keep your eyes peeled!)

The other major portion that required updating was the netlink layer, which required work in order to define and allocate generic netlink groups.

Good luck!

I think this may be your problem...

0x81d and 0x81d00000 are not the same number. You are jumping into some random function.

FYI: 0x81d = 0x0000081d

Good luck!

If you still have those binaries, in gdb, try:

list *0x82310

It doesn't output anything so there's no errors or no function is related to this error. It's also possible that error lies somewhere else but I don't know where.

There is MIT+GPL license in the rfkill tarball, but (IANAL) that doesn't matter as it gets statically linked with GPLed code.

Yeah I've run autoreconf and lost make menuconfig ability :smiley:

Do you want me to send the patches (probably during the next week)?

Yeah it's in binary format, so I believe it's fine to use.

If you have pull requests, feel free to submit them if they fix things.

I probably won't get back to you immediately, because I have been moving, but I should get back to work on it in a month or so.