linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [ath9k] ath9k:  Expose virtual wiphy indexes to debugfs.
@ 2010-07-05 19:52 greearb
  2010-07-06  4:59 ` Vasanthakumar Thiagarajan
  0 siblings, 1 reply; 4+ messages in thread
From: greearb @ 2010-07-05 19:52 UTC (permalink / raw)
  To: linux-wireless; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

It is very difficult to map phyX devices to real/virtual
entities because the phyX devices change on module
reload.  This patch makes it slightly easier to
associate virtual phy devices with phyX entities.

 # echo add=5 > /debug/ath9k/phy0/wiphy
 # cat /debug/ath9k/phy0/wiphy
primary: phy0 (ACTIVE chan=0 ht=0)
secondary[5]: phy1 (ACTIVE chan=0 ht=0)
addr: ef:be:ad:de:ef:be
addrmask: ef:be:ad:de:ef:be

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 6e486a5... a58ff60... M	drivers/net/wireless/ath/ath9k/ath9k.h
:100644 100644 54aae93... f63423c... M	drivers/net/wireless/ath/ath9k/debug.c
:100644 100644 89423ca... 03fd64d... M	drivers/net/wireless/ath/ath9k/virtual.c
 drivers/net/wireless/ath/ath9k/ath9k.h   |    2 +-
 drivers/net/wireless/ath/ath9k/debug.c   |   12 ++++++++----
 drivers/net/wireless/ath/ath9k/virtual.c |   26 ++++++++++++++++++++------
 3 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h
index 6e486a5..a58ff60 100644
--- a/drivers/net/wireless/ath/ath9k/ath9k.h
+++ b/drivers/net/wireless/ath/ath9k/ath9k.h
@@ -670,7 +670,7 @@ void ath9k_ps_wakeup(struct ath_softc *sc);
 void ath9k_ps_restore(struct ath_softc *sc);
 
 void ath9k_set_bssid_mask(struct ieee80211_hw *hw);
-int ath9k_wiphy_add(struct ath_softc *sc);
+int ath9k_wiphy_add(struct ath_softc *sc, const char* id);
 int ath9k_wiphy_del(struct ath_wiphy *aphy);
 void ath9k_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb);
 int ath9k_wiphy_pause(struct ath_wiphy *aphy);
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 54aae93..f63423c 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -503,8 +503,8 @@ static ssize_t read_file_wiphy(struct file *file, char __user *user_buf,
 		if (aphy == NULL)
 			continue;
 		len += snprintf(buf + len, sizeof(buf) - len,
-				"secondary: %s (%s chan=%d ht=%d)\n",
-				wiphy_name(aphy->hw->wiphy),
+				"secondary[%i]: %s (%s chan=%d ht=%d)\n",
+				i, wiphy_name(aphy->hw->wiphy),
 				ath_wiphy_state_str(aphy->state),
 				aphy->chan_idx, aphy->chan_is_ht);
 	}
@@ -589,8 +589,12 @@ static ssize_t write_file_wiphy(struct file *file, const char __user *user_buf,
 	if (len > 0 && buf[len - 1] == '\n')
 		buf[len - 1] = '\0';
 
-	if (strncmp(buf, "add", 3) == 0) {
-		int res = ath9k_wiphy_add(sc);
+	if (strncmp(buf, "add=", 4) == 0) {
+		int res = ath9k_wiphy_add(sc, buf + 4);
+		if (res < 0)
+			return res;
+	} else if (strncmp(buf, "add", 3) == 0) {
+		int res = ath9k_wiphy_add(sc, NULL);
 		if (res < 0)
 			return res;
 	} else if (strncmp(buf, "del=", 4) == 0) {
diff --git a/drivers/net/wireless/ath/ath9k/virtual.c b/drivers/net/wireless/ath/ath9k/virtual.c
index 89423ca..03fd64d 100644
--- a/drivers/net/wireless/ath/ath9k/virtual.c
+++ b/drivers/net/wireless/ath/ath9k/virtual.c
@@ -99,9 +99,10 @@ void ath9k_set_bssid_mask(struct ieee80211_hw *hw)
 	ath_hw_setbssidmask(common);
 }
 
-int ath9k_wiphy_add(struct ath_softc *sc)
+int ath9k_wiphy_add(struct ath_softc *sc, const char* id)
 {
 	int i, error;
+	int nid = 0;
 	struct ath_wiphy *aphy;
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	struct ieee80211_hw *hw;
@@ -112,16 +113,26 @@ int ath9k_wiphy_add(struct ath_softc *sc)
 		return -ENOMEM;
 
 	spin_lock_bh(&sc->wiphy_lock);
-	for (i = 0; i < sc->num_sec_wiphy; i++) {
+	if (id && id[0]) {
+		nid = simple_strtoul(id, NULL, 0);
+		if (nid < 0 || nid > 10000) { /* 10,000 should be plenty! */
+			printk("ath9k: id out of range in wiphy_add:"
+                               " %i, ignoring.", nid);
+			nid = 0;
+		}
+	}
+	
+	for (i = nid; i < sc->num_sec_wiphy; i++) {
 		if (sc->sec_wiphy[i] == NULL)
 			break;
 	}
 
-	if (i == sc->num_sec_wiphy) {
+	if (i >= sc->num_sec_wiphy) {
 		/* No empty slot available; increase array length */
 		struct ath_wiphy **n;
+		int q;
 		n = krealloc(sc->sec_wiphy,
-			     (sc->num_sec_wiphy + 1) *
+			     (i + 1) *
 			     sizeof(struct ath_wiphy *),
 			     GFP_ATOMIC);
 		if (n == NULL) {
@@ -129,9 +140,12 @@ int ath9k_wiphy_add(struct ath_softc *sc)
 			ieee80211_free_hw(hw);
 			return -ENOMEM;
 		}
-		n[i] = NULL;
+		// Null out any new memory allocated.
+		for (q = sc->num_sec_wiphy; q <= i; q++) {
+			n[q] = NULL;
+		}
 		sc->sec_wiphy = n;
-		sc->num_sec_wiphy++;
+		sc->num_sec_wiphy = i+1;
 	}
 
 	SET_IEEE80211_DEV(hw, sc->dev);
-- 
1.7.0.1


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

* Re: [ath9k] ath9k:  Expose virtual wiphy indexes to debugfs.
  2010-07-05 19:52 [ath9k] ath9k: Expose virtual wiphy indexes to debugfs greearb
@ 2010-07-06  4:59 ` Vasanthakumar Thiagarajan
  2010-07-06  5:15   ` Ben Greear
  0 siblings, 1 reply; 4+ messages in thread
From: Vasanthakumar Thiagarajan @ 2010-07-06  4:59 UTC (permalink / raw)
  To: greearb@gmail.com; +Cc: linux-wireless@vger.kernel.org, Ben Greear

On Tue, Jul 06, 2010 at 01:22:25AM +0530, greearb@gmail.com wrote:
> From: Ben Greear <greearb@candelatech.com>
> 
> It is very difficult to map phyX devices to real/virtual
> entities because the phyX devices change on module
> reload.  This patch makes it slightly easier to
> associate virtual phy devices with phyX entities.
> 

It does not make much sense to give an index while creating a new
virtual wiphy interface. This is unncessary, only wiphy name
matters.

Vasanth

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

* Re: [ath9k] ath9k:  Expose virtual wiphy indexes to debugfs.
  2010-07-06  4:59 ` Vasanthakumar Thiagarajan
@ 2010-07-06  5:15   ` Ben Greear
  2010-07-06  6:18     ` Vasanthakumar Thiagarajan
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Greear @ 2010-07-06  5:15 UTC (permalink / raw)
  To: Vasanthakumar Thiagarajan
  Cc: greearb@gmail.com, linux-wireless@vger.kernel.org

On 07/05/2010 09:59 PM, Vasanthakumar Thiagarajan wrote:
> On Tue, Jul 06, 2010 at 01:22:25AM +0530, greearb@gmail.com wrote:
>> From: Ben Greear<greearb@candelatech.com>
>>
>> It is very difficult to map phyX devices to real/virtual
>> entities because the phyX devices change on module
>> reload.  This patch makes it slightly easier to
>> associate virtual phy devices with phyX entities.
>>
>
> It does not make much sense to give an index while creating a new
> virtual wiphy interface. This is unncessary, only wiphy name
> matters.

Will the underlying code allow you to specify a phy name though?  It
seems to me that once a phyX is used, you cannot have a new phy
with that name again, even if the old one has been unloaded:

modprobe ath9k
rmmod ath9k
modprobe ath9k, and the now it's using phy1 instead of phy0,
and you cannot even rename the phy1 to phy0 with 'iw'.

It would be great if phy names were reusable like network
device names, but I'm guessing that must be difficult or
it would already be like that.

For virtual PHYs at least, the parent phy and index is a unique
identifier, so it sort of helps work around the phy naming
issues.

Thanks,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

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

* Re: [ath9k] ath9k:  Expose virtual wiphy indexes to debugfs.
  2010-07-06  5:15   ` Ben Greear
@ 2010-07-06  6:18     ` Vasanthakumar Thiagarajan
  0 siblings, 0 replies; 4+ messages in thread
From: Vasanthakumar Thiagarajan @ 2010-07-06  6:18 UTC (permalink / raw)
  To: Ben Greear
  Cc: Vasanth Thiagarajan, greearb@gmail.com,
	linux-wireless@vger.kernel.org

On Tue, Jul 06, 2010 at 10:45:32AM +0530, Ben Greear wrote:
> On 07/05/2010 09:59 PM, Vasanthakumar Thiagarajan wrote:
> > On Tue, Jul 06, 2010 at 01:22:25AM +0530, greearb@gmail.com wrote:
> >> From: Ben Greear<greearb@candelatech.com>
> >>
> >> It is very difficult to map phyX devices to real/virtual
> >> entities because the phyX devices change on module
> >> reload.  This patch makes it slightly easier to
> >> associate virtual phy devices with phyX entities.
> >>
> >
> > It does not make much sense to give an index while creating a new
> > virtual wiphy interface. This is unncessary, only wiphy name
> > matters.
> 
> Will the underlying code allow you to specify a phy name though?  It
> seems to me that once a phyX is used, you cannot have a new phy
> with that name again, even if the old one has been unloaded

Driver has nothing to do with assigning phy names. This is done in
cfg80211.


Vasanth

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

end of thread, other threads:[~2010-07-06  6:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-05 19:52 [ath9k] ath9k: Expose virtual wiphy indexes to debugfs greearb
2010-07-06  4:59 ` Vasanthakumar Thiagarajan
2010-07-06  5:15   ` Ben Greear
2010-07-06  6:18     ` Vasanthakumar Thiagarajan

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).