ath5k: add antenna statistics and debugfs file for antenna settings

keep statistics about which antenna was used for TX and RX. this is used only
for debugging right now, but might have other applications later.

add a new file 'antenna' in debugfs (/sys/kernel/debug/ath5k/phy0/antenna) to show
antenna use statistics and antenna diversity related register values. it can
also be used to set the antenna mode until we have proper support for that in
iw:
  - echo diversity > antenna: use default antenna mode (RX and TX diversity)
  - echo fixed-a > antenna: use fixed antenna A for RX and TX
  - echo fixed-b > antenna: use fixed antenna B for RX and TX
  - echo clear > antenna: reset antenna statistics

Signed-off-by: Bruno Randolf <br1@einfach.org>
Acked-by: Nick Kossifidis <mickflemm@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c
index 7c08434..e7a989c 100644
--- a/drivers/net/wireless/ath/ath5k/base.c
+++ b/drivers/net/wireless/ath/ath5k/base.c
@@ -1997,6 +1997,12 @@
 		rxs->signal = rxs->noise + rs.rs_rssi;
 
 		rxs->antenna = rs.rs_antenna;
+
+		if (rs.rs_antenna > 0 && rs.rs_antenna < 5)
+			sc->stats.antenna_rx[rs.rs_antenna]++;
+		else
+			sc->stats.antenna_rx[0]++; /* invalid */
+
 		rxs->rate_idx = ath5k_hw_to_driver_rix(sc, rs.rs_rate);
 		rxs->flag |= ath5k_rx_decrypted(sc, ds, skb, &rs);
 
@@ -2090,6 +2096,11 @@
 		 */
 		ath5k_remove_padding(skb);
 
+		if (ts.ts_antenna > 0 && ts.ts_antenna < 5)
+			sc->stats.antenna_tx[ts.ts_antenna]++;
+		else
+			sc->stats.antenna_tx[0]++; /* invalid */
+
 		ieee80211_tx_status(sc->hw, skb);
 
 		spin_lock(&sc->txbuflock);