linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath6kl:link speed is 0Mbps sometimes
@ 2012-08-28  7:33 Dengke Qiu
  2012-08-30  9:17 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Dengke Qiu @ 2012-08-28  7:33 UTC (permalink / raw)
  To: kvalo; +Cc: ath6kl-devel, linux-wireless

The MSB of rate index from FW is used for sgi. But the ath6kl_wmi_get_rate
doesn't handle it. The access to wmi_rate_tbl array may be out of range
if sgi is 1. This may cause the return value of ath6kl_wmi_get_rate()
function is incorrect link rate. We add sgi adjustment to avoid such case.

Signed-off-by: Dengke Qiu <dqiu@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath6kl/wmi.c |   13 ++++++++++++-
 drivers/net/wireless/ath/ath6kl/wmi.h |    3 +++
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
index 0950b92..a67c57a 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.c
+++ b/drivers/net/wireless/ath/ath6kl/wmi.c
@@ -3120,10 +3120,21 @@ int ath6kl_wmi_sta_bmiss_enhance_cmd(struct wmi *wmi, u8 if_idx, bool enhance)
 
 s32 ath6kl_wmi_get_rate(s8 rate_index)
 {
+	u8 sgi = 0;
+
 	if (rate_index == RATE_AUTO)
 		return 0;
 
-	return wmi_rate_tbl[(u32) rate_index][0];
+	/* SGI is stored as the MSB of the rate_index */
+	if (rate_index & RATE_INDEX_MSB) {
+		rate_index &= RATE_INDEX_WITHOUT_SGI_MASK;
+		sgi = 1;
+	}
+
+	if (WARN_ON(rate_index > RATE_MCS_7_40))
+		rate_index = RATE_MCS_7_40;
+
+	return wmi_rate_tbl[(u32) rate_index][sgi];
 }
 
 static int ath6kl_wmi_get_pmkid_list_event_rx(struct wmi *wmi, u8 *datap,
diff --git a/drivers/net/wireless/ath/ath6kl/wmi.h b/drivers/net/wireless/ath/ath6kl/wmi.h
index 49d0177..cad135b 100644
--- a/drivers/net/wireless/ath/ath6kl/wmi.h
+++ b/drivers/net/wireless/ath/ath6kl/wmi.h
@@ -1730,6 +1730,9 @@ struct rx_stats {
 	a_sle32 ucast_rate;
 } __packed;
 
+#define RATE_INDEX_WITHOUT_SGI_MASK     0x7f
+#define RATE_INDEX_MSB     0x80
+
 struct tkip_ccmp_stats {
 	__le32 tkip_local_mic_fail;
 	__le32 tkip_cnter_measures_invoked;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ath6kl:link speed is 0Mbps sometimes
  2012-08-28  7:33 [PATCH] ath6kl:link speed is 0Mbps sometimes Dengke Qiu
@ 2012-08-30  9:17 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2012-08-30  9:17 UTC (permalink / raw)
  To: Dengke Qiu; +Cc: ath6kl-devel, linux-wireless

On 08/28/2012 10:33 AM, Dengke Qiu wrote:
> The MSB of rate index from FW is used for sgi. But the ath6kl_wmi_get_rate
> doesn't handle it. The access to wmi_rate_tbl array may be out of range
> if sgi is 1. This may cause the return value of ath6kl_wmi_get_rate()
> function is incorrect link rate. We add sgi adjustment to avoid such case.
> 
> Signed-off-by: Dengke Qiu <dqiu@qca.qualcomm.com>

Thanks, applied. But I changed the title to better reflect what's changed:

ath6kl: fix link speed when using sgi

Kalle

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-08-30  9:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-28  7:33 [PATCH] ath6kl:link speed is 0Mbps sometimes Dengke Qiu
2012-08-30  9:17 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).