linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] Ath5k: add AP mode
@ 2008-09-27 12:48 Jiri Slaby
  2008-09-28 10:44 ` [ath5k-devel] " Gregory Nietsky
  2008-09-28 11:06 ` Gregory Nietsky
  0 siblings, 2 replies; 4+ messages in thread
From: Jiri Slaby @ 2008-09-27 12:48 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, linux-kernel, ath5k-devel, Jiri Slaby,
	Nick Kossifidis, Luis R. Rodriguez

Add support for AP mode. This involves:
- enablement in ath5k_beacon_config -- initialize beacon timer
- add AP to the supported modes in ath5k_add_interface
- handle beacon change even for AP in ath5k_config_interface
- remove useless test for IBSS in ath5k_beacon_update

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Nick Kossifidis <mickflemm@gmail.com>
Cc: Luis R. Rodriguez <mcgrof@gmail.com>
---
 drivers/net/wireless/ath5k/base.c |   42 +++++++++++++++----------------------
 1 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
index e09ed2c..d5d8e2d 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -231,8 +231,7 @@ static int ath5k_get_tx_stats(struct ieee80211_hw *hw,
 		struct ieee80211_tx_queue_stats *stats);
 static u64 ath5k_get_tsf(struct ieee80211_hw *hw);
 static void ath5k_reset_tsf(struct ieee80211_hw *hw);
-static int ath5k_beacon_update(struct ieee80211_hw *hw,
-		struct sk_buff *skb);
+static int ath5k_beacon_update(struct ath5k_softc *sc, struct sk_buff *skb);
 
 static struct ieee80211_ops ath5k_hw_ops = {
 	.tx 		= ath5k_tx,
@@ -2104,8 +2103,6 @@ ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf)
  *
  * In IBSS mode we use a self-linked tx descriptor if possible. We enable SWBA
  * interrupts to detect TSF updates only.
- *
- * AP mode is missing.
  */
 static void
 ath5k_beacon_config(struct ath5k_softc *sc)
@@ -2118,7 +2115,8 @@ ath5k_beacon_config(struct ath5k_softc *sc)
 
 	if (sc->opmode == NL80211_IFTYPE_STATION) {
 		sc->imask |= AR5K_INT_BMISS;
-	} else if (sc->opmode == NL80211_IFTYPE_ADHOC) {
+	} else if (sc->opmode == NL80211_IFTYPE_ADHOC ||
+			sc->opmode == NL80211_IFTYPE_AP) {
 		/*
 		 * In IBSS mode we use a self-linked tx descriptor and let the
 		 * hardware send the beacons automatically. We have to load it
@@ -2130,13 +2128,15 @@ ath5k_beacon_config(struct ath5k_softc *sc)
 
 		sc->imask |= AR5K_INT_SWBA;
 
-		if (ath5k_hw_hasveol(ah)) {
-			spin_lock(&sc->block);
-			ath5k_beacon_send(sc);
-			spin_unlock(&sc->block);
-		}
+		if (sc->opmode == IEEE80211_IF_TYPE_IBSS) {
+			if (ath5k_hw_hasveol(ah)) {
+				spin_lock(&sc->block);
+				ath5k_beacon_send(sc);
+				spin_unlock(&sc->block);
+			}
+		} else
+			ath5k_beacon_update_timers(sc, -1);
 	}
-	/* TODO else AP */
 
 	ath5k_hw_set_imr(ah, sc->imask);
 }
@@ -2688,6 +2688,7 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
 	sc->vif = conf->vif;
 
 	switch (conf->type) {
+	case NL80211_IFTYPE_AP:
 	case NL80211_IFTYPE_STATION:
 	case NL80211_IFTYPE_ADHOC:
 	case NL80211_IFTYPE_MONITOR:
@@ -2751,7 +2752,7 @@ ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 		ret = -EIO;
 		goto unlock;
 	}
-	if (conf->bssid) {
+	if (conf->changed & IEEE80211_IFCC_BSSID && conf->bssid) {
 		/* Cache for later use during resets */
 		memcpy(ah->ah_bssid, conf->bssid, ETH_ALEN);
 		/* XXX: assoc id is set to 0 for now, mac80211 doesn't have
@@ -2759,18 +2760,16 @@ ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
 		ath5k_hw_set_associd(ah, ah->ah_bssid, 0);
 		mmiowb();
 	}
-
 	if (conf->changed & IEEE80211_IFCC_BEACON &&
-	    vif->type == NL80211_IFTYPE_ADHOC) {
+			(vif->type == NL80211_IFTYPE_ADHOC ||
+			 vif->type == NL80211_IFTYPE_AP)) {
 		struct sk_buff *beacon = ieee80211_beacon_get(hw, vif);
 		if (!beacon) {
 			ret = -ENOMEM;
 			goto unlock;
 		}
-		/* call old handler for now */
-		ath5k_beacon_update(hw, beacon);
+		ath5k_beacon_update(sc, beacon);
 	}
-
 	mutex_unlock(&sc->lock);
 
 	return ath5k_reset_wake(sc);
@@ -3002,19 +3001,13 @@ ath5k_reset_tsf(struct ieee80211_hw *hw)
 }
 
 static int
-ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
+ath5k_beacon_update(struct ath5k_softc *sc, struct sk_buff *skb)
 {
-	struct ath5k_softc *sc = hw->priv;
 	unsigned long flags;
 	int ret;
 
 	ath5k_debug_dump_skb(sc, skb, "BC  ", 1);
 
-	if (sc->opmode != NL80211_IFTYPE_ADHOC) {
-		ret = -EIO;
-		goto end;
-	}
-
 	spin_lock_irqsave(&sc->block, flags);
 	ath5k_txbuf_free(sc, sc->bbuf);
 	sc->bbuf->skb = skb;
@@ -3027,7 +3020,6 @@ ath5k_beacon_update(struct ieee80211_hw *hw, struct sk_buff *skb)
 		mmiowb();
 	}
 
-end:
 	return ret;
 }
 
-- 
1.6.0.1


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

* Re: [ath5k-devel] [PATCH 1/1] Ath5k: add AP mode
  2008-09-27 12:48 [PATCH 1/1] Ath5k: add AP mode Jiri Slaby
@ 2008-09-28 10:44 ` Gregory Nietsky
  2008-09-28 11:06 ` Gregory Nietsky
  1 sibling, 0 replies; 4+ messages in thread
From: Gregory Nietsky @ 2008-09-28 10:44 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linville, linux-wireless, linux-kernel, ath5k-devel

Gents it is great to see this happen one snippet more and you will be 
able to set the interface into AP mode from userspace hostapd and friends.


diff --git a/drivers/net/wireless/ath5k/base.c 
b/drivers/net/wireless/ath5k/base.c
index e09ed2c..69aad6e 100644
--- a/drivers/net/wireless/ath5k/base.c
+++ b/drivers/net/wireless/ath5k/base.c
@@ -488,6 +488,7 @@ ath5k_pci_probe(struct pci_dev *pdev,

        hw->wiphy->interface_modes =
                BIT(NL80211_IFTYPE_STATION) |
+               BIT(NL80211_IFTYPE_AP) |
                BIT(NL80211_IFTYPE_ADHOC) |
                BIT(NL80211_IFTYPE_MESH_POINT);


i have had it working and no complaints so far.

please note that as with mac80211_hwsim it is dependent on a patch

Documentation/networking/mac80211_hwsim/README

Please note that the current Linux kernel does not enable AP mode, so a
simple patch is needed to enable AP mode selection:
http://johannes.sipsolutions.net/patches/kernel/all/LATEST/006-allow-ap-vlan-modes.patch

-->

Subject: mac80211: allow AP and VLAN modes

This patch allows switching interfaces into AP/VLAN modes using
cfg80211 (nl80211). Don't allow doing it with wext because then
people will just attempt to do it manually (without hostapd) and
complain that it doesn't work.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 net/mac80211/cfg.c |    2 ++
 1 file changed, 2 insertions(+)

--- everything.orig/net/mac80211/cfg.c	2008-09-26 15:07:22.000000000 +0200
+++ everything/net/mac80211/cfg.c	2008-09-26 15:09:06.000000000 +0200
@@ -33,6 +33,8 @@ static bool nl80211_type_check(enum nl80
 #ifdef CONFIG_MAC80211_MESH
 	case NL80211_IFTYPE_MESH_POINT:
 #endif
+	case NL80211_IFTYPE_AP:
+	case NL80211_IFTYPE_AP_VLAN:
 	case NL80211_IFTYPE_WDS:
 		return true;
 	default:


<--


Regards Greg

Jiri Slaby wrote:
> Add support for AP mode. This involves:
> - enablement in ath5k_beacon_config -- initialize beacon timer
> - add AP to the supported modes in ath5k_add_interface
> - handle beacon change even for AP in ath5k_config_interface
> - remove useless test for IBSS in ath5k_beacon_update
>
> Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
> Cc: Nick Kossifidis <mickflemm@gmail.com>
> Cc: Luis R. Rodriguez <mcgrof@gmail.com>
> ---
>  drivers/net/wireless/ath5k/base.c |   42 +++++++++++++++----------------------
>  1 files changed, 17 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
> index e09ed2c..d5d8e2d 100644
> --- a/drivers/net/wireless/ath5k/base.c
> +++ b/drivers/net/wireless/ath5k/base.c
>   

--
This message has been scanned for viruses and
dangerous content by Network Sentry, and 
is believed to be clean.
http://www.dialandsave.co.za


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

* Re: [ath5k-devel] [PATCH 1/1] Ath5k: add AP mode
  2008-09-27 12:48 [PATCH 1/1] Ath5k: add AP mode Jiri Slaby
  2008-09-28 10:44 ` [ath5k-devel] " Gregory Nietsky
@ 2008-09-28 11:06 ` Gregory Nietsky
  2008-09-28 16:14   ` Jiri Slaby
  1 sibling, 1 reply; 4+ messages in thread
From: Gregory Nietsky @ 2008-09-28 11:06 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linville, linux-wireless, linux-kernel, ath5k-devel


Quick Observation  ...

it appears IEEE80211 types have been replaced with NL80211 types in 
kernel ... so would the following not be more correct and is opmode not 
defined as

struct ath5k_softc {
....
        enum nl80211_iftype     opmode;
.....

@@ -2130,14 +2129,15 @@ ath5k_beacon_config(struct ath5k_softc *sc)

                sc->imask |= AR5K_INT_SWBA;

-               if (ath5k_hw_hasveol(ah)) {
-                       spin_lock(&sc->block);
-                       ath5k_beacon_send(sc);
-                       spin_unlock(&sc->block);
-               }
+               if (sc->opmode == NL80211_IFTYPE_ADHOC) {
+                       if (ath5k_hw_hasveol(ah)) {
+                               spin_lock(&sc->block);
+                               ath5k_beacon_send(sc);
+                               spin_unlock(&sc->block);
+                       }
+               } else
+                       ath5k_beacon_update_timers(sc, -1);
        }
-       /* TODO else AP */
-
        ath5k_hw_set_imr(ah, sc->imask);
 }



Jiri Slaby wrote:
> Add support for AP mode. This involves:
> - enablement in ath5k_beacon_config -- initialize beacon timer
> - add AP to the supported modes in ath5k_add_interface
> - handle beacon change even for AP in ath5k_config_interface
> - remove useless test for IBSS in ath5k_beacon_update
>
> Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
> Cc: Nick Kossifidis <mickflemm@gmail.com>
> Cc: Luis R. Rodriguez <mcgrof@gmail.com>
> ---
>  drivers/net/wireless/ath5k/base.c |   42 +++++++++++++++----------------------
>  1 files changed, 17 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/net/wireless/ath5k/base.c b/drivers/net/wireless/ath5k/base.c
> index e09ed2c..d5d8e2d 100644
> --- a/drivers/net/wireless/ath5k/base.c
> +++ b/drivers/net/wireless/ath5k/base.c
> @@ -2130,13 +2128,15 @@ ath5k_beacon_config(struct ath5k_softc *sc)
>  
>  		sc->imask |= AR5K_INT_SWBA;
>  
> -		if (ath5k_hw_hasveol(ah)) {
> -			spin_lock(&sc->block);
> -			ath5k_beacon_send(sc);
> -			spin_unlock(&sc->block);
> -		}
> +		if (sc->opmode == IEEE80211_IF_TYPE_IBSS) {
> +			if (ath5k_hw_hasveol(ah)) {
> +				spin_lock(&sc->block);
> +				ath5k_beacon_send(sc);
> +				spin_unlock(&sc->block);
> +			}
> +		} else
> +			ath5k_beacon_update_timers(sc, -1);
>  	}
> -	/* TODO else AP */
>  
>  	ath5k_hw_set_imr(ah, sc->imask);
>  }
>   

--
This message has been scanned for viruses and
dangerous content by Network Sentry, and 
is believed to be clean.
http://www.dialandsave.co.za


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

* Re: [ath5k-devel] [PATCH 1/1] Ath5k: add AP mode
  2008-09-28 11:06 ` Gregory Nietsky
@ 2008-09-28 16:14   ` Jiri Slaby
  0 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2008-09-28 16:14 UTC (permalink / raw)
  To: Gregory Nietsky; +Cc: linville, linux-wireless, linux-kernel, ath5k-devel

On 09/28/2008 01:06 PM, Gregory Nietsky wrote:
> 
> Quick Observation  ...
> 
> it appears IEEE80211 types have been replaced with NL80211 types in
> kernel ... so would the following not be more correct and is opmode not
> defined as
> 
> struct ath5k_softc {
> ....
>        enum nl80211_iftype     opmode;
> .....

It already is.

> @@ -2130,14 +2129,15 @@ ath5k_beacon_config(struct ath5k_softc *sc)
> 
>                sc->imask |= AR5K_INT_SWBA;
> 
> -               if (ath5k_hw_hasveol(ah)) {
> -                       spin_lock(&sc->block);
> -                       ath5k_beacon_send(sc);
> -                       spin_unlock(&sc->block);
> -               }
> +               if (sc->opmode == NL80211_IFTYPE_ADHOC) {
> +                       if (ath5k_hw_hasveol(ah)) {
> +                               spin_lock(&sc->block);
> +                               ath5k_beacon_send(sc);
> +                               spin_unlock(&sc->block);
> +                       }
> +               } else
> +                       ath5k_beacon_update_timers(sc, -1);

Yeah, that's the correct hunk, thanks. I sent a non-updated version.


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

end of thread, other threads:[~2008-09-28 16:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-27 12:48 [PATCH 1/1] Ath5k: add AP mode Jiri Slaby
2008-09-28 10:44 ` [ath5k-devel] " Gregory Nietsky
2008-09-28 11:06 ` Gregory Nietsky
2008-09-28 16:14   ` Jiri Slaby

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