Skip to content

Commit

Permalink
mac80211: rt2x00: add support for external LNA on MT7620
Browse files Browse the repository at this point in the history
Reported-by: Tom Psyborg <pozega.tomislav@gmail.com>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  • Loading branch information
dangowrt committed Jan 20, 2017
1 parent 920ee1f commit b367eef
Showing 1 changed file with 9 additions and 3 deletions.
Expand Up @@ -210,7 +210,7 @@
case RT5592:
*txwi_size = TXWI_DESC_SIZE_5WORDS;
*rxwi_size = RXWI_DESC_SIZE_6WORDS;
@@ -3303,6 +3376,312 @@ static void rt2800_config_channel_rf55xx
@@ -3303,6 +3376,318 @@ static void rt2800_config_channel_rf55xx
rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x19 : 0x7F);
}

Expand Down Expand Up @@ -470,13 +470,19 @@
+ bbp = 0x40;
+ rt2800_bbp_write(rt2x00dev, 30, bbp);
+ rt2800_rfcsr_write(rt2x00dev, 39, 0);
+ rt2800_rfcsr_write(rt2x00dev, 42, 0x7b);
+ if (rt2x00_has_cap_external_lna_bg(rt2x00dev))
+ rt2800_rfcsr_write(rt2x00dev, 42, 0xfb);
+ else
+ rt2800_rfcsr_write(rt2x00dev, 42, 0x7b);
+ } else {
+ rt2800_bbp_read(rt2x00dev, 30, &bbp);
+ bbp = 0x1f;
+ rt2800_bbp_write(rt2x00dev, 30, bbp);
+ rt2800_rfcsr_write(rt2x00dev, 39, 0x80);
+ rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
+ if (rt2x00_has_cap_external_lna_bg(rt2x00dev))
+ rt2800_rfcsr_write(rt2x00dev, 42, 0xdb);
+ else
+ rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
+ }
+
+ rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, mac_sys_ctrl);
Expand Down

11 comments on commit b367eef

@kofec
Copy link

@kofec kofec commented on b367eef Jan 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dangowrt
Many people have below issue for this driver (it is not related to your commit). But If you propose changes for this module - probably you know it :-). Do you know any workaround to fix it. Change rate/type N/G/B ? Same specific wifi parameters ? thanks in advance

[54261.009480] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[54261.018927] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[54261.028375] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[54261.037822] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[54261.047248] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[54261.056695] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[73549.515817] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[73549.525305] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[73549.534758] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[73625.146353] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[73625.155824] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[73625.165278] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[73625.174728] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2
[73625.184175] ieee80211 phy1: rt2x00queue_write_tx_frame: Error - Dropping frame due to full tx queue 2

@dangowrt
Copy link
Member Author

@dangowrt dangowrt commented on b367eef Jan 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support for MT7620 is still experimental and there are many known problems. Imho the patch needs to be cleaned-up or re-written and probably there are also quite some bits missing which we didn't discover yet...

@hbl0307106015
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @kofec , do you know how to dynamic debug rt2x00 ? Just echo something to /sys/kernel/debug/control ???

@kofec
Copy link

@kofec kofec commented on b367eef Jan 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @hbl0307106015
I have " Reboot (SNAPSHOT, r3060-b367eef)" probably with your changes (no impact on this issue)
#719
root@ledeXiaomiMini:~# ls -l /sys/kernel/debug/

drwxr-xr-x   14 root     root             0 Jan  1  1970 bdi
-r--r--r--    1 root     root             0 Jan  1  1970 bootrom
drwxr-xr-x    2 root     root             0 Jan  1  1970 f2fs
-rw-r--r--    1 root     root             0 Jan  1  1970 fault_around_bytes
-r--r--r--    1 root     root             0 Jan  1  1970 gpio
drwxr-xr-x    4 root     root             0 Jan 21 09:55 ieee80211
drwxr-xr-x    2 root     root             0 Jan  1  1970 mips
drwxr-xr-x    3 root     root             0 Jan  1  1970 pinctrl
drwxr-xr-x    2 root     root             0 Jan  1  1970 pm_qos
-r--r--r--    1 root     root             0 Jan  1  1970 sleep_time
drwxr-xr-x    3 root     root             0 Jan  1  1970 usb

root@ledeXiaomiMini:~# echo "1" >> /sys/kernel/debug/control
-ash: can't create /sys/kernel/debug/control: Permission denied

Probably I should compile with some debug option. Can you suggest which I should turn on ?

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to enable PACKAGE_RT2X00_LIB_DEBUGFS, that will give you read/write access to registers via /sys/kernel/debug/ieee80211/phy*/rt2x*/

@hbl0307106015
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. make menuconfig->enbale dynamic_debug
  2. kernel module->wireless drivers-> rt2x00-> enable all debug fs
  3. make V=s , and then you can see /sys/kernel/debug/control file is here
    @kofec

@hbl0307106015
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @dangowrt , I have enable all the relevant debugfs, how to make it print all debug message from wireless driver ??
I had try to follow stpes but failed(neither dmesg or logred can work).
echo -n 'module mt76 +p' > /sys/kernel/debug/dynamic_debug/control
echo -n 'module mt760e3 +p' > /sys/kernel/debug/dynamic_debug/control
echo -n 'module mt76x2e +p' > /sys/kernel/debug/dynamic_debug/control
echo -n 'module cfg80211 +p' > /sys/kernel/debug/dynamic_debug/control
echo -n 'module mac80211 +p' > /sys/kernel/debug/dynamic_debug/control

cat /proc/kmsg , just nothing,..

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, looking at the code, there are simply no pr_debug() calls in rt2x00. When enabling the various debugfs options for rt2x00, you'll end up with a populated sysfs directory structure in /sys/kernel/debug/ieee80211/phy*/ which allows for some introspection, see https://github.com/torvalds/linux/blob/master/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c

        /*
         * Debugfs entries for:
         * - driver folder
         *   - driver file
         *   - chipset file
         *   - device state flags file
         *   - device capability flags file
         *   - register folder
         *     - csr offset/value files
         *     - eeprom offset/value files
         *     - bbp offset/value files
         *     - rf offset/value files
         *     - rfcsr offset/value files
         *   - queue folder
         *     - frame dump file
         *     - queue stats file
         *     - crypto stats file
         */

@hbl0307106015
Copy link

@hbl0307106015 hbl0307106015 commented on b367eef Jan 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dangowrt Yes, but it seems there is no queue folder, no frame dump file.... :-(

root@lede:/sys/kernel/debug/ieee80211/phy1# ls fragmentation_threshold keys power rts_threshold total_ps_buffered ht40allow_map long_retry_limit queues short_retry_limit user_power hwflags netdev:wlan1 rc statistics wep_iv

@kofec
Copy link

@kofec kofec commented on b367eef Jan 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dangowrt @hbl0307106015
thanks for your help. So is there any conclusion ? Which debug I should enable ?
@dangowrt
As I understand you have the Xiaomi Mini - so my question - you don't see this issue ? If so maybe you have older openwrt or any other firmware ? If so can you write which one ? thanks

@dangowrt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kofec @hbl0307106015
I decided to pull a kickstarter project, because this is more than what I'm going to do just for the fun of it:
https://www.kickstarter.com/projects/1327597961/better-support-for-mt7620a-n-in-openwrt-lede

Please sign in to comment.