Skip to contentSkip to conversation

ath9k: Fix up hardware mode and beacons with multiple vifs.

PATCH New greearb at candelatech.com 1 participant 2 messages Jan 15, 2011 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 ath9k: Fix up hardware mode and beacons with multiple vifs.

From: Ben Greear <[email protected]>

When using a mixture of AP and Station interfaces, the hardware mode was using the type of the last VIF registered. Instead, we should keep track of the number of different types of vifs and set the mode accordingly.

In addtion, use the vif type instead of hardware opmode when dealing with beacons.

Attempt to move some of the common setup code into smaller methods so we can re-use it when changing vif mode as well as adding/deleting vifs.

---

v3: Remove vif counters and use iterator to build current
state for all interfaces as needed. Move bssid mask setting logic to 'main.c', and combine with other summary state setting.

:100644 100644 3108699... dab0271... M drivers/net/wireless/ath/ath9k/ath9k.h
:100644 100644 385ba03... 8de591e... M drivers/net/wireless/ath/ath9k/beacon.c
:100644 100644 0452580... e91d927... M drivers/net/wireless/ath/ath9k/main.c
:100644 100644 ea2f67c... 8def8c2... M drivers/net/wireless/ath/ath9k/recv.c
:100644 100644 2dc7095... d205c66... M drivers/net/wireless/ath/ath9k/virtual.c

 drivers/net/wireless/ath/ath9k/ath9k.h   |   23 ++-
 drivers/net/wireless/ath/ath9k/beacon.c  |   14 +-
 drivers/net/wireless/ath/ath9k/main.c    |  308 +++++++++++++++++++++---------
 drivers/net/wireless/ath/ath9k/recv.c    |   16 ++-
 drivers/net/wireless/ath/ath9k/virtual.c |   48 -----
 5 files changed, 263 insertions(+), 146 deletions(-)
drivers/net/wireless/ath/ath9k/ath9k.h +21 -2
index 3108699..dab0271 100644
@@ -568,6 +568,20 @@ struct ath_ant_comb {
 struct ath_wiphy;
 struct ath_rate_table;
 
+struct ath9k_vif_iter_data {
+	const u8 *hw_macaddr; /* phy's hardware address, set
+			       * before starting iteration for
+			       * valid bssid mask.
+			       */
+	u8 mask[ETH_ALEN]; /* bssid mask */
+	int naps;      /* number of AP vifs */
+	int nmeshes;   /* number of mesh vifs */
+	int nstations; /* number of station vifs */
+	int nwds;      /* number of nwd vifs */
+	int nadhocs;   /* number of adhoc vifs */
+	int nothers;   /* number of vifs not specified above. */
+};
+
 struct ath_softc {
 	struct ieee80211_hw *hw;
 	struct device *dev;
@@ -607,10 +621,10 @@ struct ath_softc {
 	u32 sc_flags; /* SC_OP_* */
 	u16 ps_flags; /* PS_* */
 	u16 curtxpow;
-	u8 nbcnvifs;
-	u16 nvifs;
 	bool ps_enabled;
 	bool ps_idle;
+	short nbcnvifs;
+	short nvifs;
 	unsigned long ps_usecount;
 
 	struct ath_config config;
@@ -694,6 +708,7 @@ int ath_set_channel(struct ath_softc *sc, struct ieee80211_hw *hw,
 void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw);
 void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw);
 bool ath9k_setpower(struct ath_softc *sc, enum ath9k_power_mode mode);
+bool ath9k_uses_beacons(int type);
 
 #ifdef CONFIG_PCI
 int ath_pci_init(void);
@@ -738,5 +753,9 @@ bool ath_mac80211_start_queue(struct ath_softc *sc, u16 skb_queue);
 
 void ath_start_rfkill_poll(struct ath_softc *sc);
 extern void ath9k_rfkill_poll_state(struct ieee80211_hw *hw);
+void ath9k_calculate_iter_data(struct ieee80211_hw *hw,
+			       struct ieee80211_vif *vif,
+			       struct ath9k_vif_iter_data *iter_data);
+
 
 #endif /* ATH9K_H */
drivers/net/wireless/ath/ath9k/beacon.c +6 -8
index 385ba03..8de591e 100644
@@ -244,9 +244,7 @@ int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
 						 struct ath_buf, list);
 		list_del(&avp->av_bcbuf->list);
 
-		if (sc->sc_ah->opmode == NL80211_IFTYPE_AP ||
-		    sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC ||
-		    sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) {
+		if (ath9k_uses_beacons(vif->type)) {
 			int slot;
 			/*
 			 * Assign the vif to a beacon xmit slot. As
@@ -282,7 +280,7 @@ int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
 	/* NB: the beacon data buffer must be 32-bit aligned. */
 	skb = ieee80211_beacon_get(sc->hw, vif);
 	if (skb == NULL) {
-		ath_dbg(common, ATH_DBG_BEACON, "cannot get skb\n");
+		ath_err(common, "ieee80211_beacon_get failed\n");
 		return -ENOMEM;
 	}
 
@@ -720,10 +718,10 @@ void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif)
 		iftype = sc->sc_ah->opmode;
 	}
 
-		cur_conf->listen_interval = 1;
-		cur_conf->dtim_count = 1;
-		cur_conf->bmiss_timeout =
-			ATH_DEFAULT_BMISS_LIMIT * cur_conf->beacon_interval;
+	cur_conf->listen_interval = 1;
+	cur_conf->dtim_count = 1;
+	cur_conf->bmiss_timeout =
+		ATH_DEFAULT_BMISS_LIMIT * cur_conf->beacon_interval;
 
 	/*
 	 * It looks like mac80211 may end up using beacon interval of zero in
drivers/net/wireless/ath/ath9k/main.c +222 -86

383 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/recv.c +14 -2
index ea2f67c..8def8c2 100644
@@ -589,8 +589,14 @@ static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb)
 		return;
 
 	mgmt = (struct ieee80211_mgmt *)skb->data;
-	if (memcmp(common->curbssid, mgmt->bssid, ETH_ALEN) != 0)
+	if (memcmp(common->curbssid, mgmt->bssid, ETH_ALEN) != 0) {
+		/* TODO:  This doesn't work well if you have stations
+		 * associated to two different APs because curbssid
+		 * is just the last AP that any of the stations associated
+		 * with.
+		 */
 		return; /* not from our current AP */
+	}
 
 	sc->ps_flags &= ~PS_WAIT_FOR_BEACON;
 
@@ -985,8 +991,14 @@ static void ath9k_process_rssi(struct ath_common *common,
 
 	fc = hdr->frame_control;
 	if (!ieee80211_is_beacon(fc) ||
-	    compare_ether_addr(hdr->addr3, common->curbssid))
+	    compare_ether_addr(hdr->addr3, common->curbssid)) {
+		/* TODO:  This doesn't work well if you have stations
+		 * associated to two different APs because curbssid
+		 * is just the last AP that any of the stations associated
+		 * with.
+		 */
 		return;
+	}
 
 	if (rx_stats->rs_rssi != ATH9K_RSSI_BAD && !rx_stats->rs_moreaggr)
 		ATH_RSSI_LPF(aphy->last_rssi, rx_stats->rs_rssi);
drivers/net/wireless/ath/ath9k/virtual.c +0 -48

54 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#1 lore raw

PATCH v3 2/2 ath9k: Add 'misc' file to debugfs, fix queue indexes.

From: Ben Greear <[email protected]>

Add a misc file to show hardware op-mode, irq setup, number of various types of VIFs and more.

Also, previous patches were using the wrong xmit queue indexes. Change to use the internal ath9k indexes instead of the mac80211 queue indexes.

---

v3: Update to use iterator to gather vif stats. Print
calculated bssid mask as well.

This patch requires previous debugfs patches that I have posted.

:100644 100644 b0cb792... 5005621... M drivers/net/wireless/ath/ath9k/debug.c

 drivers/net/wireless/ath/ath9k/debug.c |  128 +++++++++++++++++++++++++++++---
 1 files changed, 116 insertions(+), 12 deletions(-)
drivers/net/wireless/ath/ath9k/debug.c +116 -12
index b0cb792..5005621 100644
@@ -595,10 +595,10 @@ static const struct file_operations fops_wiphy = {
 do {									\
 	len += snprintf(buf + len, size - len,				\
 			"%s%13u%11u%10u%10u\n", str,			\
-			(unsigned int)(sc->tx.txq[WME_AC_BE].elem),	\
-			(unsigned int)(sc->tx.txq[WME_AC_BK].elem),	\
-			(unsigned int)(sc->tx.txq[WME_AC_VI].elem),	\
-			(unsigned int)(sc->tx.txq[WME_AC_VO].elem));	\
+			(unsigned int)(sc->tx.txq[ATH_TXQ_AC_BE].elem),	\
+			(unsigned int)(sc->tx.txq[ATH_TXQ_AC_BK].elem),	\
+			(unsigned int)(sc->tx.txq[ATH_TXQ_AC_VI].elem),	\
+			(unsigned int)(sc->tx.txq[ATH_TXQ_AC_VO].elem));	\
 	if (len >= size)						\
 		goto done;						\
 } while(0)
@@ -607,10 +607,10 @@ do {									\
 do {									\
 	len += snprintf(buf + len, size - len,				\
 			"%s%13i%11i%10i%10i\n", str,			\
-			list_empty(&sc->tx.txq[WME_AC_BE].elem),	\
-			list_empty(&sc->tx.txq[WME_AC_BK].elem),	\
-			list_empty(&sc->tx.txq[WME_AC_VI].elem),	\
-			list_empty(&sc->tx.txq[WME_AC_VO].elem));	\
+			list_empty(&sc->tx.txq[ATH_TXQ_AC_BE].elem),	\
+			list_empty(&sc->tx.txq[ATH_TXQ_AC_BK].elem),	\
+			list_empty(&sc->tx.txq[ATH_TXQ_AC_VI].elem),	\
+			list_empty(&sc->tx.txq[ATH_TXQ_AC_VO].elem));	\
 	if (len >= size)						\
 		goto done;						\
 } while (0)
@@ -657,10 +657,10 @@ static ssize_t read_file_xmit(struct file *file, char __user *user_buf,
 	PR("hw-tx-proc-desc: ", txprocdesc);
 	len += snprintf(buf + len, size - len,
 			"%s%11p%11p%10p%10p\n", "txq-memory-address:",
-			&(sc->tx.txq[WME_AC_BE]),
-			&(sc->tx.txq[WME_AC_BK]),
-			&(sc->tx.txq[WME_AC_VI]),
-			&(sc->tx.txq[WME_AC_VO]));
+			&(sc->tx.txq[ATH_TXQ_AC_BE]),
+			&(sc->tx.txq[ATH_TXQ_AC_BK]),
+			&(sc->tx.txq[ATH_TXQ_AC_VI]),
+			&(sc->tx.txq[ATH_TXQ_AC_VO]));
 	if (len >= size)
 		goto done;
 
@@ -777,6 +777,99 @@ done:
 	return retval;
 }
 
+static ssize_t read_file_misc(struct file *file, char __user *user_buf,
+			      size_t count, loff_t *ppos)
+{
+	struct ath_softc *sc = file->private_data;
+	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
+	struct ath_hw *ah = sc->sc_ah;
+	char *buf;
+	unsigned int len = 0, size = 8000;
+	ssize_t retval = 0;
+	const char *tmp;
+	unsigned int reg;
+
+	buf = kzalloc(size, GFP_KERNEL);
+	if (buf == NULL)
+		return -ENOMEM;
+
+	switch (sc->sc_ah->opmode) {
+	case  NL80211_IFTYPE_ADHOC:
+		tmp = "ADHOC";
+		break;
+	case  NL80211_IFTYPE_MESH_POINT:
+		tmp = "MESH";
+		break;
+	case  NL80211_IFTYPE_AP:
+		tmp = "AP";
+		break;
+	case  NL80211_IFTYPE_STATION:
+		tmp = "STATION";
+		break;
+	default:
+		tmp = "???";
+		break;
+	}
+
+	len += snprintf(buf + len, size - len,
+			"curbssid: %pM\n"
+			"OP-Mode: %s(%i)\n"
+			"Beacon-Timer-Register: 0x%x\n",
+			common->curbssid,
+			tmp, (int)(sc->sc_ah->opmode),
+			REG_READ(ah, AR_BEACON_PERIOD));
+
+	reg = REG_READ(ah, AR_TIMER_MODE);
+	len += snprintf(buf + len, size - len, "Timer-Mode-Register: 0x%x (",
+			reg);
+	if (reg & AR_TBTT_TIMER_EN)
+		len += snprintf(buf + len, size - len, "TBTT ");
+	if (reg & AR_DBA_TIMER_EN)
+		len += snprintf(buf + len, size - len, "DBA ");
+	if (reg & AR_SWBA_TIMER_EN)
+		len += snprintf(buf + len, size - len, "SWBA ");
+	if (reg & AR_HCF_TIMER_EN)
+		len += snprintf(buf + len, size - len, "HCF ");
+	if (reg & AR_TIM_TIMER_EN)
+		len += snprintf(buf + len, size - len, "TIM ");
+	if (reg & AR_DTIM_TIMER_EN)
+		len += snprintf(buf + len, size - len, "DTIM ");
+	len += snprintf(buf + len, size - len, ")\n");
+
+	reg = sc->sc_ah->imask;
+	len += snprintf(buf + len, size - len, "imask: 0x%x (", reg);
+	if (reg & ATH9K_INT_SWBA)
+		len += snprintf(buf + len, size - len, "SWBA ");
+	if (reg & ATH9K_INT_BMISS)
+		len += snprintf(buf + len, size - len, "BMISS ");
+	if (reg & ATH9K_INT_CST)
+		len += snprintf(buf + len, size - len, "CST ");
+	if (reg & ATH9K_INT_RX)
+		len += snprintf(buf + len, size - len, "RX ");
+	if (reg & ATH9K_INT_RXHP)
+		len += snprintf(buf + len, size - len, "RXHP ");
+	if (reg & ATH9K_INT_RXLP)
+		len += snprintf(buf + len, size - len, "RXLP ");
+	if (reg & ATH9K_INT_BB_WATCHDOG)
+		len += snprintf(buf + len, size - len, "BB_WATCHDOG ");
+	/* there are other IRQs if one wanted to add them. */
+	len += snprintf(buf + len, size - len, ")\n");
+
+	len += snprintf(buf + len, size - len,
+			"VIF Counts: AP: %hi STA: %hi MESH: %hi WDS: %hi"
+			" ADHOC: %hi nvifs: %hi beacon-vifs: %hi\n",
+			sc->naps, sc->nstations, sc->nmeshes, sc->nwds,
+			sc->nadhocs, sc->nvifs, sc->nbcnvifs);
+
+	if (len > size)
+		len = size;
+
+	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	kfree(buf);
+
+	return retval;
+}
+
 void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf,
 		       struct ath_tx_status *ts)
 {
@@ -822,6 +915,13 @@ static const struct file_operations fops_stations = {
 	.llseek = default_llseek,
 };
 
+static const struct file_operations fops_misc = {
+	.read = read_file_misc,
+	.open = ath9k_debugfs_open,
+	.owner = THIS_MODULE,
+	.llseek = default_llseek,
+};
+
 static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 			      size_t count, loff_t *ppos)
 {
@@ -1063,6 +1163,10 @@ int ath9k_init_debug(struct ath_hw *ah)
 			sc, &fops_stations))
 		goto err;
 
+	if (!debugfs_create_file("misc", S_IRUSR, sc->debug.debugfs_phy,
+			sc, &fops_misc))
+		goto err;
+
 	if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy,
 			sc, &fops_recv))
 		goto err;
Signature · 1 line
1.7.2.3