Skip to content

Commit

Permalink
ath10k: Fix 2x2 NICs running on firmware compiled for 3x3.
Browse files Browse the repository at this point in the history
This fixed performance issues on 2x2 988X CT firmware.

Signed-off-by: Ben Greear <greearb@candelatech.com>
  • Loading branch information
greearb committed Jan 19, 2017
1 parent d5d1706 commit e2fb92f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 19 deletions.
4 changes: 4 additions & 0 deletions ath10k/debug.c
Expand Up @@ -1053,6 +1053,10 @@ static ssize_t ath10k_read_debug_level(struct file *file,
"BMI: 0x400\n"
"REGULATORY: 0x800\n"
"TESTMODE: 0x1000\n"
"WMI-PRINT: 0x2000\n"
"PCI-PS: 0x4000\n"
"AHB: 0x8000\n"
"MAC2: 0x20000000\n"
"INFO-AS-DBG: 0x40000000\n"
"FW: 0x80000000\n"
"ALL: 0xFFFFFFFF\n";
Expand Down
1 change: 1 addition & 0 deletions ath10k/debug.h
Expand Up @@ -42,6 +42,7 @@ enum ath10k_debug_mask {
ATH10K_DBG_WMI_PRINT = 0x00002000,
ATH10K_DBG_PCI_PS = 0x00004000,
ATH10K_DBG_AHB = 0x00008000,
ATH10K_DBG_MAC2 = 0x20000000, /* more verbose MAC debugging */
ATH10K_DBG_INFO_AS_DBG = 0x40000000,
ATH10K_DBG_FW = 0x80000000,
ATH10K_DBG_ANY = 0xffffffff,
Expand Down
57 changes: 39 additions & 18 deletions ath10k/mac.c
Expand Up @@ -2278,12 +2278,35 @@ static void ath10k_peer_assoc_h_rate_overrides(struct ath10k *ar,
int i;
int j;
int hw_rix;
int hw_nss = ar->num_rf_chains;

/* So, what we really want here is the max number of chains the firmware
* is compiled for. But, since we can have 3x3 firmware run on 2x2 chips,
* then we need to hack on this in gruesome ways. Better have the hack here
* than try to extend FW's ability to send that value I think.
*/
int hw_nss = ar->num_rf_chains;
if (! test_bit(ATH10K_FW_FEATURE_CT_RATEMASK,
ar->running_fw->fw_file.fw_features))
return;

/* Ignore devices not known to be supported, this is a minor feature and
* not worth breaking systems for users that don't need it.
*/
if (!((ar->dev_id == QCA988X_2_0_DEVICE_ID) ||
(ar->dev_id == QCA99X0_2_0_DEVICE_ID) ||
(ar->dev_id == QCA9984_1_0_DEVICE_ID))) {
ath10k_warn(ar, "rate-override: Skipping un-supported device-id, hw-nss: %d dev-id: 0x%x\n",
hw_nss, ar->dev_id);
return;
}

if (hw_nss < 3) {
/* Maybe 2x2 NIC booting 3x3 988x firmware? */
if (ar->dev_id == QCA988X_2_0_DEVICE_ID) {
hw_nss = 3;
}
}

lockdep_assert_held(&ar->conf_mutex);

if (WARN_ON(ath10k_mac_vif_chan(vif, &def)))
Expand All @@ -2294,8 +2317,8 @@ static void ath10k_peer_assoc_h_rate_overrides(struct ath10k *ar,
ratemask = arvif->bitrate_mask.control[band].legacy;
rates = sband->bitrates;

ath10k_warn(ar, "band: %d ratemask: 0x%x hw-nss: %d\n",
band, ratemask, hw_nss);
ath10k_warn(ar, "band: %d ratemask: 0x%x hw-nss: %d dev-id: 0x%x\n",
band, ratemask, hw_nss, ar->dev_id);

arg->has_rate_overrides = true;

Expand All @@ -2314,9 +2337,9 @@ static void ath10k_peer_assoc_h_rate_overrides(struct ath10k *ar,
/* ofdm rates start at rix 4 */
hw_rix = rates->hw_value + 4;
}
//ath10k_dbg(ar, ATH10K_DBG_MAC,
// "set-enabled, bitrate: %d i: %d hw-value: %d hw-rix: %d\n",
// rates->bitrate, i, rates->hw_value, hw_rix);
ath10k_dbg(ar, ATH10K_DBG_MAC2,
"set-enabled, bitrate: %d i: %d hw-value: %d hw-rix: %d\n",
rates->bitrate, i, rates->hw_value, hw_rix);
ath10k_set_rate_enabled(hw_rix, arg->rate_overrides, 1);
}

Expand All @@ -2327,13 +2350,13 @@ static void ath10k_peer_assoc_h_rate_overrides(struct ath10k *ar,
*/
for (i = 0; i < hw_nss; i++) {
unsigned int mcs = arvif->bitrate_mask.control[band].ht_mcs[i];
//ath10k_warn(ar, "ht-mcs [%i]: 0x%x\n", i, mcs);
ath10k_dbg(ar, ATH10K_DBG_MAC2, "ht-mcs [%i]: 0x%x\n", i, mcs);
for (j = 0; j<8; j++) {
if (mcs & (1<<j)) {
hw_rix = 12 + i * 8 + j;
//ath10k_dbg(ar, ATH10K_DBG_MAC,
// "set-enabled, ht: hw-rix: %d, %d i: %d j: %d\n",
// hw_rix, hw_rix + hw_nss * 8, i, j);
ath10k_dbg(ar, ATH10K_DBG_MAC2,
"set-enabled, ht: hw-rix: %d, %d i: %d j: %d\n",
hw_rix, hw_rix + hw_nss * 8, i, j);
ath10k_set_rate_enabled(hw_rix, arg->rate_overrides, 1);
/* Set HT40 rateset too */
ath10k_set_rate_enabled(hw_rix + hw_nss * 8, arg->rate_overrides, 1);
Expand All @@ -2350,13 +2373,13 @@ static void ath10k_peer_assoc_h_rate_overrides(struct ath10k *ar,
*/
for (i = 0; i < hw_nss; i++) {
unsigned int mcs = arvif->bitrate_mask.control[band].vht_mcs[i];
//ath10k_warn(ar, "vht-mcs [%i]: 0x%x\n", i, mcs);
ath10k_dbg(ar, ATH10K_DBG_MAC2, "vht-mcs [%i]: 0x%x\n", i, mcs);
for (j = 0; j<10; j++) {
if (mcs & (1<<j)) {
hw_rix = 12 + (hw_nss * 2) * 8 + i * 10 + j;
//ath10k_dbg(ar, ATH10K_DBG_MAC,
// "set-enabled, vht: hw-rix: %d, %d, %d i: %d j: %d\n",
// hw_rix, hw_rix + hw_nss * 10, hw_rix + hw_nss * 2 * 10, i, j);
ath10k_dbg(ar, ATH10K_DBG_MAC2,
"set-enabled, vht: hw-rix: %d, %d, %d i: %d j: %d\n",
hw_rix, hw_rix + hw_nss * 10, hw_rix + hw_nss * 2 * 10, i, j);
ath10k_set_rate_enabled(hw_rix, arg->rate_overrides, 1);
/* Set HT40 rateset too */
ath10k_set_rate_enabled(hw_rix + hw_nss * 10, arg->rate_overrides, 1);
Expand All @@ -2366,14 +2389,12 @@ static void ath10k_peer_assoc_h_rate_overrides(struct ath10k *ar,
}
}

#if 0
for (i = 0; i < sizeof(arg->rate_overrides); i++) {
if (arg->rate_overrides[i] != 0xFF) {
ath10k_warn(ar, "vif: %d rate-overrides[%d]: 0x%x\n",
arvif->vdev_id, i, arg->rate_overrides[i]);
ath10k_dbg(ar, ATH10K_DBG_MAC2, "vif: %d rate-overrides[%d]: 0x%x\n",
arvif->vdev_id, i, arg->rate_overrides[i]);
}
}
#endif
}

static u8 get_nss_from_chainmask(u16 chain_mask)
Expand Down
3 changes: 2 additions & 1 deletion ath10k/pci.c
Expand Up @@ -3448,7 +3448,8 @@ static int ath10k_pci_probe(struct pci_dev *pdev,
int (*pci_soft_reset)(struct ath10k *ar);
int (*pci_hard_reset)(struct ath10k *ar);

printk(KERN_INFO "ath10k driver, optimized for CT firmware, probing pci.\n");
printk(KERN_INFO "ath10k driver, optimized for CT firmware, probing pci device: 0x%x.\n",
pci_dev->device);

switch (pci_dev->device) {
case QCA988X_2_0_DEVICE_ID:
Expand Down

17 comments on commit e2fb92f

@klukonin
Copy link

Choose a reason for hiding this comment

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

Looks like 2x2 devices can't work in ibss mode.
I see a lot of debug messages
http://pastebin.com/5pxvyVtA

And very sad picture about bitrates

root@LEDE:~# iwinfo mesh5_0 assoclist
80:2A:A8:D2:98:38 -37 dBm / -102 dBm (SNR 65) 0 ms ago
RX: unknown 16138 Pkts.
TX: 48.0 MBit/s 3911 Pkts.

If I set two nss through iw like iw dev mesh5_0 set bitrates ht-mcs-5 vht-mcs-5 1:0-9 2:0-9 sgi-5

Bitrates stuck at the lowest rate

root@LEDE:~# iwinfo mesh5_0 assoclist
80:2A:A8:D2:98:38 -37 dBm / -102 dBm (SNR 65) 70 ms ago
RX: 6.0 MBit/s 21062 Pkts.
TX: 48.0 MBit/s 4607 Pkts.

And I see a lot of debug information again
http://pastebin.com/7d9QSmYX

Looks like something going wrong.

@klukonin
Copy link

Choose a reason for hiding this comment

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

UPD:
Broadcast messages are OK.

root@LEDE:~# batctl o
[B.A.T.M.A.N. adv 2016.5, MainIF/MAC: mesh5_0/80:2a:a8:d2:97:f3 (bat0/0e:e0:46:45:75:a3 BATMAN_V)]
Originator last-seen ( throughput) Nexthop [outgoingIF]

  • 80:2a:a8:d2:98:38 4.930s ( 1840.2) 80:2a:a8:d2:98:38 [ mesh5_0]

@klukonin
Copy link

Choose a reason for hiding this comment

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

This behavior repeats on every channel bandwidth. I tried 20, 40 and 80 MHZ.
Sometimes two IBSS stations can set right bitrates. This looks like they drop it to 6 mbps and after that bitrate rizes up to the 866.7 mbps.
Other stations can stay with unknown RX and 20 mhz channel bandwidth.

@klukonin
Copy link

Choose a reason for hiding this comment

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

UPD: bitrate negotiation fails when one (any) station tries to send on 48mbps bitrate.
Any other station interpret this as a 6 mbps (why?) or unknown bitrate. And communication fails.

Look's like bug. Really.

@greearb
Copy link
Owner Author

@greearb greearb commented on e2fb92f Mar 13, 2017 via email

Choose a reason for hiding this comment

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

@klukonin
Copy link

@klukonin klukonin commented on e2fb92f Mar 13, 2017

Choose a reason for hiding this comment

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

I don't have 3x3 NIC, sorry.

Yes, I'm using the latest LEDE commit from lede-17.01 branch. With your new version ath10k-ct.

I understand that you have a lot of work, and don't have enough time to debug, but can you give some advice about bitrates?
As I noticed from the sources, ath10k associate stations with legacy bitrates. May be there is a way to avoid it?
To turn off legacy at all and use only HT & VHT.

@greearb
Copy link
Owner Author

@greearb greearb commented on e2fb92f Mar 13, 2017 via email

Choose a reason for hiding this comment

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

@klukonin
Copy link

@klukonin klukonin commented on e2fb92f Mar 13, 2017

Choose a reason for hiding this comment

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

Yes, I can test with the latest one from master. But firmware and driver are the same there.
I use HTT firmware directrly downloaded from the official CT site. May be I need to give a chance to the WMI mgt community firmware.

I'll try also to switch driver from legacy or to set 6 - 36 bitrates only.

Thank you very much.

@greearb
Copy link
Owner Author

@greearb greearb commented on e2fb92f Mar 15, 2017 via email

Choose a reason for hiding this comment

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

@klukonin
Copy link

@klukonin klukonin commented on e2fb92f Mar 15, 2017

Choose a reason for hiding this comment

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

Hello.

For this moment behavior is different.
Bitrate stucks on 6 mbps instead of 48 mbps with packets counter freeze at the cold start (I mean, without any traffic).
Then station switch from 6 mbps to 48 mbps again and stuck like before.
One or two times 48 mbps bitrate was recognized as VHT bitrate by other stations, but without ability to transmit any trafic. Other times it was again recognized as 6 mbps or unknown.

Sometimes reassociation helps, sometimes not.

Cold start looks like that
http://pastebin.com/YdFWeVEx

After reassociation some station can work correct. Also I noticed, that it shouldn't be any broadcast traffic to make it work 50/50.
http://pastebin.com/dK9LBM7s

First station dmesg:
http://pastebin.com/C9Vqyp7a

Second station dmesg
http://pastebin.com/GTvHxuTC

Third station dmesg:
http://pastebin.com/taADGd5p

After all I tried to set bitrates through iw and play with beacon, mcast, broadcast bitrates for last station. with some success.
Here the dmesg log of this manipulations.
http://pastebin.com/9upEv8g0

But when I tried to apply this settings to other stations it was a fail. Every connection was broken.

For every station it was a
80:2A:A8:D2:98:38 -36 dBm / -107 dBm (SNR 71) 100 ms ago
RX: unknown 3026 Pkts.
TX: 24.0 MBit/s 5 Pkts.

Here is the dmesg of this situation
http://pastebin.com/iL69sw8f

@klukonin
Copy link

@klukonin klukonin commented on e2fb92f Mar 15, 2017

Choose a reason for hiding this comment

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

UPD:
After some minutes station can negotiate 80mhz and normal VHT bitrate.
Looks like a hook to make it use 6 mbit in case of stuck. Packet counter begins to work. Then, from 6 mbit rate station can raise directly to VHT bitrates, but not allways. Sometimes bitrate again raises to the 48 mbit value.
dmesg:
http://pastebin.com/LVNK1Qcf

I can provide any log information, ssh access, etc. Everything you need.
So, please feel free to ask me.

@greearb
Copy link
Owner Author

@greearb greearb commented on e2fb92f Mar 17, 2017 via email

Choose a reason for hiding this comment

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

@klukonin
Copy link

Choose a reason for hiding this comment

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

Hello.

Here is my wireless conf file:
http://pastebin.com/6Kj98qSk

As I noticed, it doesn't matter what MTU value was set.
I tried with network option and without it. Behavior is allways the same.

With BSSID it does not working for me.

I didn't try without encryption, because I can't use open adhoc.

Also, with my dirty hack through reassociation it works.

@greearb
Copy link
Owner Author

@greearb greearb commented on e2fb92f Mar 22, 2017 via email

Choose a reason for hiding this comment

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

@klukonin
Copy link

Choose a reason for hiding this comment

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

Hello.

I made a lab with 5 UBNT unifi AP ac lite. It has custom labeled QCA9880 inside.
All things are the same. In most cases devices can normally negotiate a bitrate.
But but "48 mbps TX" allways seems to be decoded as "6mbps/unknown RX" by others (bitrate mismatch). "6 mbps TX" stuck is different and appears rarely.

Things I tried:

  1. Old firmware versions - didn't help
  2. Nrcc firmware versions - crashed
  3. nohwcrypt = 1 - didn't help
  4. rate_ctrl_objs = 0/16/64/127 - didn't help
  5. add supported_bitrates to /etc/config/wireless and play with it. Seems to be firmware ignores basic rates and iw settings.
  6. Set bitrates throug iw - this didn't help and caused VERY low throughput at highest bitrates (about 10-200 kbps).
  7. Set only one antenna for rx/tx to make only one nss work - didn't help
  8. Patch your driver (not a solution) - but I'm not so skilled in driver development. I failed and all was the same.

So. I really can't make this work. Or better to say that I really can't fix this bug or create a workaround.

Please, do you have any Ideas or advices. I really need help.

And please, can you clarify in what cases firmware can't report rx bitrate to the driver, which appears as "unknown" in iwinfo or absent rx bitrate: section in IW output.

I don't know how long can devices travell from Russia. But theoretically I can send them for testing purposes.

Best regards,
Kirill

@klukonin
Copy link

@klukonin klukonin commented on e2fb92f Mar 23, 2017

Choose a reason for hiding this comment

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

UPD.

6mpbs sometimes can also be decoded as unknown (firmware don't report RX bitrate).

@greearb
Copy link
Owner Author

@greearb greearb commented on e2fb92f Mar 23, 2017 via email

Choose a reason for hiding this comment

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

Please sign in to comment.