Bug 240473

Summary: Ralink RT5390R Wireless Card does not work
Product: Base System Reporter: Usama Khan <usama.cit>
Component: wirelessAssignee: freebsd-wireless (Nobody) <wireless>
Status: Closed FIXED    
Severity: Affects Many People CC: mizhka, usama.cit
Priority: ---    
Version: 12.0-RELEASE   
Hardware: amd64   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241192

Description Usama Khan 2019-09-10 14:17:42 UTC
Ralink RT5390R wireless card does not work under (all versions of) FreeBSD. The manpage of "ral" mentions that it supports RT5390, but RT5390R does not work under "ral". I have created a thread at:
https://forums.freebsd.org/threads/ralink-rt5390r-wifi-in-freebsd.72224/#post-438804
but the end result was that this device does not work under FreeBSD.
Kindly add support for Wireless Card Ralink RT5390R.
Comment 1 Michael Zhilin freebsd_committer freebsd_triage 2019-09-10 14:38:57 UTC
Is there any cheap equipment available for testing?
Comment 2 Usama Khan 2019-09-10 14:47:19 UTC
I can test packages/patches on my system (FreeBSD-12.0-RELEASE). And can provide necessary hardware information.
Comment 3 Michael Zhilin freebsd_committer freebsd_triage 2019-09-10 14:59:10 UTC
Ok, but it could be long process...

Please provide dmesg command output

pciconf -lvbce command output

devinfo -vr command output
Comment 4 Usama Khan 2019-09-10 15:18:02 UTC
I will be more than happy to provide all necessary info.

Kindly check following link for 'devinfo'
https://pastebin.com/aXGDJTx7

and following link for 'dmesg'
https://pastebin.com/aXGDJTx7

and following link for 'pciconf'
https://pastebin.com/eGuJjr8t
Comment 5 Michael Zhilin freebsd_committer freebsd_triage 2019-09-10 15:33:26 UTC
Thanks! I see ral0 is in outputs. 
OK, please share output of /etc/rc.conf. 
Also, try following command (called "clone"):
 ifconfig wlan0 create wlandev ral0

Thanks!
Comment 6 Usama Khan 2019-09-10 17:08:44 UTC
It is working now. The system has recognized the wireless card and showing as 'wlan0' in 'ifconfig' output. 
Is it possible to make this detection process automatic in future FreeBSD releases?
Thanks
Comment 7 Michael Zhilin freebsd_committer freebsd_triage 2019-09-11 08:20:12 UTC
Please check:
https://www.freebsd.org/doc/handbook/network-wireless.html

All network cards are not visible in ifconfig output. To configure wlan interface, you can use rc.conf (best way) or manual (mostly for troubleshooting). 

I agree that it's not-friendly way, but it's better than was before. Automatic cloning of WLAN devices is good idea, so if you can drive it further, please send email with idea to freebsd-wireless mailing list (https://lists.freebsd.org/mailman/listinfo/freebsd-wireless)

As well, your card PCI ID is missing in if_ral_pci.c. It's easy to add it if you can provide patch (optionally) and test results (mandatory). 

If card works fine, I will commit your card support into source code. 

Thank you!
Comment 8 Usama Khan 2019-09-11 08:29:32 UTC
Thanks for reply. 
Yes, kindly add my card to if_ral_pci.c file. I can test and provide whatever information you need. 
Just let me know what you need.
Comment 9 Michael Zhilin freebsd_committer freebsd_triage 2019-09-11 08:54:52 UTC
Patch is published on reviews.freebsd.org:
https://reviews.freebsd.org/D21604

Please check it, compile, test and use device during day. The most interesting tests are:
 - stability. Is it working fine during day (no hangs, no drops, no network lost)
 - supported mode. I expect 11b and 11g works fine, 11n - may be not. Please provide which modes work. 
 - network speed. Please measure it as you can. If you're familiar with iperf, please use iperf. If not, you can use online services like fast.com. 

Thanks!
Comment 10 Usama Khan 2019-09-11 09:40:59 UTC
There is an issue:
Before reporting this bug, I created a thread at (forums.freebsds.org)
Here at following message:
https://forums.freebsd.org/threads/ralink-rt5390r-wifi-in-freebsd.72224/#post-438740
"T-Daemon" asked me to manually put:
{ 0x1814, 0x539b, "Ralink Technology RT5392R" },
in /usr/src/sys/dev/ral/if_ral_pci.c
and build kernel "make -j4 kernel, which I did. 
So, my question is: as I have put this entry manually, will the patch be effective any more?
Comment 11 Michael Zhilin freebsd_committer freebsd_triage 2019-09-11 10:46:59 UTC
Don't apply patch, please proceed with testing :)
Comment 12 Usama Khan 2019-09-11 10:49:05 UTC
Kindly give me required commands, and I will post their outputs.
Comment 13 Usama Khan 2019-09-11 15:04:57 UTC
Stability is good. I am now connected to internet for 3-4 hours without any disconnection.

Speed is good, downloading file at maximum speed (of my network) of 450KB/s.
Comment 14 Usama Khan 2019-09-11 15:07:20 UTC
fast.com says my internet speed is 3.5MB/sec.
Comment 15 Usama Khan 2019-09-11 16:36:25 UTC
"supported mode. I expect 11b and 11g works fine, 11n - may be not. Please provide which modes work."

Kindly guide me that how can I check it? Thanks
Comment 16 Michael Zhilin freebsd_committer freebsd_triage 2019-09-12 18:38:18 UTC
Thank you! 

Committed into head under revision 352260, MFC after 5 days.
Comment 17 Usama Khan 2019-09-13 04:49:50 UTC
what about the other test about "11b and 11g". Don't I have to provide data about these also? Thanks
Comment 18 Usama Khan 2019-10-05 14:13:32 UTC
Please check following link:
https://svnweb.freebsd.org/base/head/sys/dev/ral/if_ral_pci.c?view=markup&pathrev=352260#l104
It mentions following code:
        { 0x1814, 0x539f, "Ralink Technology RT5390" },
However, my discussion in following thread:
https://forums.freebsd.org/threads/ralink-rt5390r-wifi-in-freebsd.72224/#post-440002
shows that the suggested code (by a developer) is following:
 { 0x1814, 0x539b, "Ralink Technology RT5390R" }
Kindly look into this.
Comment 19 Usama Khan 2019-10-07 10:46:39 UTC
The wifi card stops working after every system update. Then I have to recompile kernel by:
make -j4 kernel
to compile:
 { 0x1814, 0x539b, "Ralink Technology RT5390R" }
So, I think correct code needs to be inserted in:
/usr/sr/sys/dev/ral/if_ral_pci.c
Comment 20 Usama Khan 2021-02-23 09:30:17 UTC
*** Bug 241192 has been marked as a duplicate of this bug. ***