Skip to contentSkip to conversation

eliminate some ath9k_htc code

PATCH New Oleksij Rempel 1 participant 7 messages Jan 20, 2014 – Jan 26, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover eliminate some ath9k_htc code

Ath9k_htc has too match outdated copy/paste from ath9k.

This patch set trying to remove some of it and make some function common to both drivers.

Oleksij Rempel (5):
ath: add last_rssi to ath_common
ath9k: move ath9k_process_rssi to common.c
ath9k: move ath9k_process_rate to common.c
ath9k: move ath9k_rx_accept to common.c
ath9k_htc: rework ath9k_rx_prepare and make use of common funcs

 drivers/net/wireless/ath/ath.h                |   2 +
 drivers/net/wireless/ath/ath9k/ath9k.h        |   1 -
 drivers/net/wireless/ath/ath9k/common.c       | 192 +++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/common.h       |  14 ++
 drivers/net/wireless/ath/ath9k/htc.h          |   1 -
 drivers/net/wireless/ath/ath9k/htc_drv_init.c |   1 +
 drivers/net/wireless/ath/ath9k/htc_drv_main.c |   1 +
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 149 ++++++------------
 drivers/net/wireless/ath/ath9k/init.c         |   2 +-
 drivers/net/wireless/ath/ath9k/mac.h          |   9 +-
 drivers/net/wireless/ath/ath9k/main.c         |   2 +-
 drivers/net/wireless/ath/ath9k/recv.c         | 211 ++------------------------
 12 files changed, 270 insertions(+), 315 deletions(-)
Signature · 1 line
1.8.5.2
#1 lore raw

PATCH 1/5 ath: add last_rssi to ath_common

we need access to this variable from common functions.

---
 drivers/net/wireless/ath/ath.h | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/wireless/ath/ath.h +2 -0
index b59cfbe..6260b83 100644
@@ -161,6 +161,8 @@ struct ath_common {
 	bool btcoex_enabled;
 	bool disable_ani;
 	bool bt_ant_diversity;
+
+	int last_rssi;
 };
 
 struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
Signature · 1 line
1.8.5.3
#2 lore raw

PATCH 2/5 ath9k: move ath9k_process_rssi to common.c

In reply to Oleksij Rempel

we can reuse this fucntion on ath9k_htc.
Now we will need to use common version last_rssi, so switch it too.

---
 drivers/net/wireless/ath/ath9k/ath9k.h  |  1 -
 drivers/net/wireless/ath/ath9k/common.c | 62 ++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/common.h |  4 +++
 drivers/net/wireless/ath/ath9k/init.c   |  2 +-
 drivers/net/wireless/ath/ath9k/main.c   |  2 +-
 drivers/net/wireless/ath/ath9k/recv.c   | 64 +--------------------------------
 6 files changed, 69 insertions(+), 66 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +0 -1
index b5ac32c..4ce3787 100644
@@ -757,7 +757,6 @@ struct ath_softc {
 #endif
 
 	struct ath9k_hw_cal_data caldata;
-	int last_rssi;
 
 #ifdef CONFIG_ATH9K_DEBUGFS
 	struct ath9k_debug debug;
drivers/net/wireless/ath/ath9k/common.c +62 -0

68 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/common.h +4 -0
index eb85e1b..aaf4a9b5 100644
@@ -42,6 +42,10 @@
 #define ATH_EP_RND(x, mul) 						\
 	(((x) + ((mul)/2)) / (mul))
 
+void ath9k_cmn_process_rssi(struct ath_common *common,
+			    struct ieee80211_hw *hw,
+			    struct ath_rx_status *rx_stats,
+			    struct ieee80211_rx_status *rxs);
 int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
 struct ath9k_channel *ath9k_cmn_get_channel(struct ieee80211_hw *hw,
 					    struct ath_hw *ah,
drivers/net/wireless/ath/ath9k/init.c +1 -1
index c36de30..00e0f60 100644
@@ -534,7 +534,7 @@ static void ath9k_init_misc(struct ath_softc *sc)
 
 	setup_timer(&common->ani.timer, ath_ani_calibrate, (unsigned long)sc);
 
-	sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
+	common->last_rssi = ATH_RSSI_DUMMY_MARKER;
 	sc->config.txpowlimit = ATH_TXPOWER_MAX;
 	memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN);
 	sc->beacon.slottime = ATH9K_SLOT_TIME_9;
drivers/net/wireless/ath/ath9k/main.c +1 -1
index 73a3655..16b3ecb 100644
@@ -1609,7 +1609,7 @@ static void ath9k_set_assoc_state(struct ath_softc *sc,
 	common->curaid = bss_conf->aid;
 	ath9k_hw_write_associd(sc->sc_ah);
 
-	sc->last_rssi = ATH_RSSI_DUMMY_MARKER;
+	common->last_rssi = ATH_RSSI_DUMMY_MARKER;
 	sc->sc_ah->stats.avgbrssi = ATH_RSSI_DUMMY_MARKER;
 
 	spin_lock_irqsave(&sc->sc_pm_lock, flags);
drivers/net/wireless/ath/ath9k/recv.c +1 -63

76 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#3 lore raw

PATCH 3/5 ath9k: move ath9k_process_rate to common.c

we can reuse this function in ath9k_htc

---
 drivers/net/wireless/ath/ath9k/common.c | 42 +++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/common.h |  4 +++
 drivers/net/wireless/ath/ath9k/recv.c   | 59 +++++----------------------------
 3 files changed, 54 insertions(+), 51 deletions(-)
drivers/net/wireless/ath/ath9k/common.c +42 -0
index 7028c52..120fd46 100644
@@ -27,6 +27,48 @@ MODULE_AUTHOR("Atheros Communications");
 MODULE_DESCRIPTION("Shared library for Atheros wireless 802.11n LAN cards.");
 MODULE_LICENSE("Dual BSD/GPL");
 
+int ath9k_cmn_process_rate(struct ath_common *common,
+			   struct ieee80211_hw *hw,
+			   struct ath_rx_status *rx_stats,
+			   struct ieee80211_rx_status *rxs)
+{
+	struct ieee80211_supported_band *sband;
+	enum ieee80211_band band;
+	unsigned int i = 0;
+	struct ath_hw *ah = common->ah;
+
+	band = ah->curchan->chan->band;
+	sband = hw->wiphy->bands[band];
+
+	if (IS_CHAN_QUARTER_RATE(ah->curchan))
+		rxs->flag |= RX_FLAG_5MHZ;
+	else if (IS_CHAN_HALF_RATE(ah->curchan))
+		rxs->flag |= RX_FLAG_10MHZ;
+
+	if (rx_stats->rs_rate & 0x80) {
+		/* HT rate */
+		rxs->flag |= RX_FLAG_HT;
+		rxs->flag |= rx_stats->flag;
+		rxs->rate_idx = rx_stats->rs_rate & 0x7f;
+		return 0;
+	}
+
+	for (i = 0; i < sband->n_bitrates; i++) {
+		if (sband->bitrates[i].hw_value == rx_stats->rs_rate) {
+			rxs->rate_idx = i;
+			return 0;
+		}
+		if (sband->bitrates[i].hw_value_short == rx_stats->rs_rate) {
+			rxs->flag |= RX_FLAG_SHORTPRE;
+			rxs->rate_idx = i;
+			return 0;
+		}
+	}
+
+	return -EINVAL;
+}
+EXPORT_SYMBOL(ath9k_cmn_process_rate);
+
 void ath9k_cmn_process_rssi(struct ath_common *common,
 			    struct ieee80211_hw *hw,
 			    struct ath_rx_status *rx_stats,
drivers/net/wireless/ath/ath9k/common.h +4 -0
index aaf4a9b5..729482f 100644
@@ -42,6 +42,10 @@
 #define ATH_EP_RND(x, mul) 						\
 	(((x) + ((mul)/2)) / (mul))
 
+int ath9k_cmn_process_rate(struct ath_common *common,
+			   struct ieee80211_hw *hw,
+			   struct ath_rx_status *rx_stats,
+			   struct ieee80211_rx_status *rxs);
 void ath9k_cmn_process_rssi(struct ath_common *common,
 			    struct ieee80211_hw *hw,
 			    struct ath_rx_status *rx_stats,
drivers/net/wireless/ath/ath9k/recv.c +8 -51

71 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#4 lore raw

PATCH 4/5 ath9k: move ath9k_rx_accept to common.c

In reply to Oleksij Rempel

we can reuse it on ath9k_htc

---
 drivers/net/wireless/ath/ath9k/common.c | 88 +++++++++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/common.h |  6 +++
 drivers/net/wireless/ath/ath9k/recv.c   | 88 +--------------------------------
 3 files changed, 95 insertions(+), 87 deletions(-)
drivers/net/wireless/ath/ath9k/common.c +88 -0
index 120fd46..5c0d949 100644
@@ -27,6 +27,94 @@ MODULE_AUTHOR("Atheros Communications");
 MODULE_DESCRIPTION("Shared library for Atheros wireless 802.11n LAN cards.");
 MODULE_LICENSE("Dual BSD/GPL");
 
+/* Assumes you've already done the endian to CPU conversion */
+bool ath9k_cmn_rx_accept(struct ath_common *common,
+			 struct ieee80211_hdr *hdr,
+			 struct ieee80211_rx_status *rxs,
+			 struct ath_rx_status *rx_stats,
+			 bool *decrypt_error,
+			 unsigned int rxfilter)
+{
+	struct ath_hw *ah = common->ah;
+	bool is_mc, is_valid_tkip, strip_mic, mic_error;
+	__le16 fc;
+
+	fc = hdr->frame_control;
+
+	is_mc = !!is_multicast_ether_addr(hdr->addr1);
+	is_valid_tkip = rx_stats->rs_keyix != ATH9K_RXKEYIX_INVALID &&
+		test_bit(rx_stats->rs_keyix, common->tkip_keymap);
+	strip_mic = is_valid_tkip && ieee80211_is_data(fc) &&
+		ieee80211_has_protected(fc) &&
+		!(rx_stats->rs_status &
+		(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_CRC | ATH9K_RXERR_MIC |
+		 ATH9K_RXERR_KEYMISS));
+
+	/*
+	 * Key miss events are only relevant for pairwise keys where the
+	 * descriptor does contain a valid key index. This has been observed
+	 * mostly with CCMP encryption.
+	 */
+	if (rx_stats->rs_keyix == ATH9K_RXKEYIX_INVALID ||
+	    !test_bit(rx_stats->rs_keyix, common->ccmp_keymap))
+		rx_stats->rs_status &= ~ATH9K_RXERR_KEYMISS;
+
+	mic_error = is_valid_tkip && !ieee80211_is_ctl(fc) &&
+		!ieee80211_has_morefrags(fc) &&
+		!(le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG) &&
+		(rx_stats->rs_status & ATH9K_RXERR_MIC);
+
+	/*
+	 * The rx_stats->rs_status will not be set until the end of the
+	 * chained descriptors so it can be ignored if rs_more is set. The
+	 * rs_more will be false at the last element of the chained
+	 * descriptors.
+	 */
+	if (rx_stats->rs_status != 0) {
+		u8 status_mask;
+
+		if (rx_stats->rs_status & ATH9K_RXERR_CRC) {
+			rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
+			mic_error = false;
+		}
+
+		if ((rx_stats->rs_status & ATH9K_RXERR_DECRYPT) ||
+		    (!is_mc && (rx_stats->rs_status & ATH9K_RXERR_KEYMISS))) {
+			*decrypt_error = true;
+			mic_error = false;
+		}
+
+
+		/*
+		 * Reject error frames with the exception of
+		 * decryption and MIC failures. For monitor mode,
+		 * we also ignore the CRC error.
+		 */
+		status_mask = ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
+			      ATH9K_RXERR_KEYMISS;
+
+		if (ah->is_monitoring && (rxfilter & FIF_FCSFAIL))
+			status_mask |= ATH9K_RXERR_CRC;
+
+		if (rx_stats->rs_status & ~status_mask)
+			return false;
+	}
+
+	/*
+	 * For unicast frames the MIC error bit can have false positives,
+	 * so all MIC error reports need to be validated in software.
+	 * False negatives are not common, so skip software verification
+	 * if the hardware considers the MIC valid.
+	 */
+	if (strip_mic)
+		rxs->flag |= RX_FLAG_MMIC_STRIPPED;
+	else if (is_mc && mic_error)
+		rxs->flag |= RX_FLAG_MMIC_ERROR;
+
+	return true;
+}
+EXPORT_SYMBOL(ath9k_cmn_rx_accept);
+
 int ath9k_cmn_process_rate(struct ath_common *common,
 			   struct ieee80211_hw *hw,
 			   struct ath_rx_status *rx_stats,
drivers/net/wireless/ath/ath9k/common.h +6 -0
index 729482f..c59d3f5 100644
@@ -42,6 +42,12 @@
 #define ATH_EP_RND(x, mul) 						\
 	(((x) + ((mul)/2)) / (mul))
 
+bool ath9k_cmn_rx_accept(struct ath_common *common,
+			 struct ieee80211_hdr *hdr,
+			 struct ieee80211_rx_status *rxs,
+			 struct ath_rx_status *rx_stats,
+			 bool *decrypt_error,
+			 unsigned int rxfilter);
 int ath9k_cmn_process_rate(struct ath_common *common,
 			   struct ieee80211_hw *hw,
 			   struct ath_rx_status *rx_stats,
drivers/net/wireless/ath/ath9k/recv.c +1 -87

100 lines not on this page · raw message

Signature · 1 line
1.8.5.3
#5 lore raw

PATCH 5/5 ath9k_htc: rework ath9k_rx_prepare and make use of common funcs

In reply to Oleksij Rempel
---
 drivers/net/wireless/ath/ath9k/htc.h          |   1 -
 drivers/net/wireless/ath/ath9k/htc_drv_init.c |   1 +
 drivers/net/wireless/ath/ath9k/htc_drv_main.c |   1 +
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 149 ++++++++------------------
 drivers/net/wireless/ath/ath9k/mac.h          |   9 +-
 5 files changed, 50 insertions(+), 111 deletions(-)
drivers/net/wireless/ath/ath9k/htc.h +0 -1
index 58da346..c75493f 100644
@@ -275,7 +275,6 @@ struct ath9k_htc_rxbuf {
 };
 
 struct ath9k_htc_rx {
-	int last_rssi; /* FIXME: per-STA */
 	struct list_head rxbuf;
 	spinlock_t rxbuflock;
 };
drivers/net/wireless/ath/ath9k/htc_drv_init.c +1 -0
index f4e1de2..9db8aef 100644
@@ -607,6 +607,7 @@ static void ath9k_init_misc(struct ath9k_htc_priv *priv)
 
 	memcpy(common->bssidmask, ath_bcast_mac, ETH_ALEN);
 
+	common->last_rssi = ATH_RSSI_DUMMY_MARKER;
 	priv->ah->opmode = NL80211_IFTYPE_STATION;
 }
 
drivers/net/wireless/ath/ath9k/htc_drv_main.c +1 -0
index 608d739..228549a 100644
@@ -1457,6 +1457,7 @@ static void ath9k_htc_bss_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
 
 	if ((vif->type == NL80211_IFTYPE_STATION) && bss_conf->assoc) {
 		common->curaid = bss_conf->aid;
+		common->last_rssi = ATH_RSSI_DUMMY_MARKER;
 		memcpy(common->curbssid, bss_conf->bssid, ETH_ALEN);
 	}
 }
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +45 -104

181 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/mac.h +3 -6
index 1027137..89df634 100644
@@ -155,12 +155,8 @@ struct ath_htc_rx_status {
 	u8 rs_status;
 	u8 rs_phyerr;
 	int8_t rs_rssi;
-	int8_t rs_rssi_ctl0;
-	int8_t rs_rssi_ctl1;
-	int8_t rs_rssi_ctl2;
-	int8_t rs_rssi_ext0;
-	int8_t rs_rssi_ext1;
-	int8_t rs_rssi_ext2;
+	int8_t rs_rssi_ctl[3];
+	int8_t rs_rssi_ext[3];
 	u8 rs_keyix;
 	u8 rs_rate;
 	u8 rs_antenna;
@@ -170,6 +166,7 @@ struct ath_htc_rx_status {
 	u8 rs_num_delims;
 	u8 rs_flags;
 	u8 rs_dummy;
+	/* FIXME: evm* never used? */
 	__be32 evm0;
 	__be32 evm1;
 	__be32 evm2;
Signature · 1 line
1.8.5.3
#6 lore raw

cover eliminate some ath9k_htc code

In reply to Oleksij Rempel

Please do not apply this patch set, it will need some changes.

Am 20.01.2014 19:48, schrieb Oleksij Rempel:

Quoted 26 lines

Ath9k_htc has too match outdated copy/paste from ath9k.

This patch set trying to remove some of it and make some function common to both drivers.

Oleksij Rempel (5):
ath: add last_rssi to ath_common
ath9k: move ath9k_process_rssi to common.c
ath9k: move ath9k_process_rate to common.c
ath9k: move ath9k_rx_accept to common.c
ath9k_htc: rework ath9k_rx_prepare and make use of common funcs

 drivers/net/wireless/ath/ath.h                |   2 +
 drivers/net/wireless/ath/ath9k/ath9k.h        |   1 -
 drivers/net/wireless/ath/ath9k/common.c       | 192 +++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/common.h       |  14 ++
 drivers/net/wireless/ath/ath9k/htc.h          |   1 -
 drivers/net/wireless/ath/ath9k/htc_drv_init.c |   1 +
 drivers/net/wireless/ath/ath9k/htc_drv_main.c |   1 +
 drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 149 ++++++------------
 drivers/net/wireless/ath/ath9k/init.c         |   2 +-
 drivers/net/wireless/ath/ath9k/mac.h          |   9 +-
 drivers/net/wireless/ath/ath9k/main.c         |   2 +-
 drivers/net/wireless/ath/ath9k/recv.c         | 211 ++------------------------
 12 files changed, 270 insertions(+), 315 deletions(-)
Signature · 10 lines
Regards,
Oleksij

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 295 bytes
Desc: OpenPGP digital signature
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20140126/b4124e3e/attachment.pgp