Search Linux Wireless

[PATCH 7/7] zd1211rw-mac80211: return hardware specific tx rate code for rx status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



zd1211rw-mac80211 uses different hardware-specific codings to talk about
rates when doing transmit and receive.  Because mac80211 looks up the rx
rate against the rates table used for selecting hardware-specific coding for
tx, the rate returned in the rx_status struct needs to be adjusted to use the
coding used to hardware-specific tx rates.  This patch performs this adjustment.

From: Andy Green <andy@xxxxxxxxxxx>
Signed-off-by: Andy Green <andy@xxxxxxxxxxx>

diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c
index 4d226dc..30684e3 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.c
@@ -1563,6 +1563,28 @@ u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status)
 	return rate;
 }
 
+int zd_rx_rate_using_tx_format(const void *rx_frame,
+   const struct rx_status *status)
+{
+	if (status->frame_status & ZD_RX_OFDM) {
+		return ZD_CS_OFDM | (zd_ofdm_plcp_header_rate(rx_frame) & 0xf);
+	}
+
+	switch (zd_cck_plcp_header_rate(rx_frame)) {
+	case ZD_CCK_SIGNAL_1M:
+		return ZD_CS_CCK_RATE_1M;
+	case ZD_CCK_SIGNAL_2M:
+		return ZD_CS_CCK_RATE_2M;
+	case ZD_CCK_SIGNAL_5M5:
+		return ZD_CS_CCK_RATE_5_5M;
+	case ZD_CCK_SIGNAL_11M:
+		return ZD_CS_CCK_RATE_11M;
+	default:
+		return 0;
+	}
+
+}
+
 int zd_chip_switch_radio_on(struct zd_chip *chip)
 {
 	int r;
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h
index a4dc06c..4f4fe8c 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_chip.h
@@ -873,6 +873,8 @@ u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size,
 u8 zd_rx_strength_percent(u8 rssi);
 
 u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status);
+int zd_rx_rate_using_tx_format(const void *rx_frame,
+   const struct rx_status *status);
 
 struct zd_mc_hash {
 	u32 low;
diff --git a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
index 65eabfa..bfaa923 100644
--- a/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/mac80211/zd1211rw/zd_mac.c
@@ -411,7 +411,7 @@ static int fill_rx_stats(struct ieee80211_rx_status *stats,
 	stats->signal = zd_rx_qual_percent(buffer,
 		                          length - sizeof(struct rx_status),
 		                          status);
-	stats->rate = zd_rx_rate(buffer, status);
+	stats->rate = zd_rx_rate_using_tx_format(buffer, status);
 
 	return 0;
 }

-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux