Linux-Wireless Archive mirror
 help / color / mirror / Atom feed
* [PATCH 12/23] ath9k_htc: Maintain individual counters for interfaces
@ 2011-02-21  2:19 Sujith
  2011-02-22  5:03 ` Rajkumar Manoharan
  0 siblings, 1 reply; 4+ messages in thread
From: Sujith @ 2011-02-21  2:19 UTC (permalink / raw
  To: linville; +Cc: linux-wireless, Sujith.Manoharan

From: Sujith Manoharan <Sujith.Manoharan@atheros.com>

This is required for allowing only one IBSS interface to be
configured.

Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
---
 drivers/net/wireless/ath/ath9k/htc.h          |   28 +++++++++++++++++++++++++
 drivers/net/wireless/ath/ath9k/htc_drv_main.c |   14 ++++++++++-
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 97f7ae0..0088c6e 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -206,6 +206,32 @@ struct ath9k_htc_target_stats {
 
 #define ATH9K_HTC_MAX_VIF 2
 
+#define INC_VIF(_priv, _type) do {		\
+		switch (_type) {		\
+		case NL80211_IFTYPE_STATION:	\
+			_priv->num_sta_vif++;	\
+			break;			\
+		case NL80211_IFTYPE_ADHOC:	\
+			_priv->num_ibss_vif++;	\
+			break;			\
+		default:			\
+			break;			\
+		}				\
+	} while (0)
+
+#define DEC_VIF(_priv, _type) do {		\
+		switch (_type) {		\
+		case NL80211_IFTYPE_STATION:	\
+			_priv->num_sta_vif--;	\
+			break;			\
+		case NL80211_IFTYPE_ADHOC:	\
+			_priv->num_ibss_vif--;	\
+			break;			\
+		default:			\
+			break;			\
+		}				\
+	} while (0)
+
 struct ath9k_htc_vif {
 	u8 index;
 	u16 seq_no;
@@ -367,6 +393,8 @@ struct ath9k_htc_priv {
 	u8 mon_vif_idx;
 	u8 sta_slot;
 	u8 vif_sta_pos[ATH9K_HTC_MAX_VIF];
+	u8 num_ibss_vif;
+	u8 num_sta_vif;
 
 	u16 op_flags;
 	u16 curtxpow;
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 04cb243..39074fc 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -1193,9 +1193,15 @@ static int ath9k_htc_add_interface(struct ieee80211_hw *hw,
 	mutex_lock(&priv->mutex);
 
 	if (priv->nvifs >= ATH9K_HTC_MAX_VIF) {
-		ret = -ENOBUFS;
 		mutex_unlock(&priv->mutex);
-		return ret;
+		return -ENOBUFS;
+	}
+
+	if (priv->num_ibss_vif ||
+	    (priv->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) {
+		ath_err(common, "IBSS coexistence with other modes is not allowed\n");
+		mutex_unlock(&priv->mutex);
+		return -ENOBUFS;
 	}
 
 	ath9k_htc_ps_wakeup(priv);
@@ -1240,6 +1246,8 @@ static int ath9k_htc_add_interface(struct ieee80211_hw *hw,
 	priv->nvifs++;
 	priv->vif = vif;
 
+	INC_VIF(priv, vif->type);
+
 	ath_dbg(common, ATH_DBG_CONFIG,
 		"Attach a VIF of type: %d at idx: %d\n", vif->type, avp->index);
 
@@ -1273,6 +1281,8 @@ static void ath9k_htc_remove_interface(struct ieee80211_hw *hw,
 	ath9k_htc_remove_station(priv, vif, NULL);
 	priv->vif = NULL;
 
+	DEC_VIF(priv, vif->type);
+
 	ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface at idx: %d\n", avp->index);
 
 	ath9k_htc_ps_restore(priv);
-- 
1.7.4.1


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

* Re: [PATCH 12/23] ath9k_htc: Maintain individual counters for interfaces
  2011-02-21  2:19 [PATCH 12/23] ath9k_htc: Maintain individual counters for interfaces Sujith
@ 2011-02-22  5:03 ` Rajkumar Manoharan
  2011-02-22 13:03   ` Sujith
  0 siblings, 1 reply; 4+ messages in thread
From: Rajkumar Manoharan @ 2011-02-22  5:03 UTC (permalink / raw
  To: Sujith
  Cc: linville@tuxdriver.com, linux-wireless@vger.kernel.org,
	Sujith Manoharan

On Mon, Feb 21, 2011 at 07:49:15AM +0530, Sujith wrote:
> From: Sujith Manoharan <Sujith.Manoharan@atheros.com>
> 
> This is required for allowing only one IBSS interface to be
> configured.
> 
> Signed-off-by: Sujith Manoharan <Sujith.Manoharan@atheros.com>
> ---
>  drivers/net/wireless/ath/ath9k/htc.h          |   28 +++++++++++++++++++++++++
>  drivers/net/wireless/ath/ath9k/htc_drv_main.c |   14 ++++++++++-
>  2 files changed, 40 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
> index 97f7ae0..0088c6e 100644
> --- a/drivers/net/wireless/ath/ath9k/htc.h
> +++ b/drivers/net/wireless/ath/ath9k/htc.h
> @@ -206,6 +206,32 @@ struct ath9k_htc_target_stats {
>  
>  #define ATH9K_HTC_MAX_VIF 2
>  
> +#define INC_VIF(_priv, _type) do {		\
> +		switch (_type) {		\
> +		case NL80211_IFTYPE_STATION:	\
> +			_priv->num_sta_vif++;	\
> +			break;			\
> +		case NL80211_IFTYPE_ADHOC:	\
> +			_priv->num_ibss_vif++;	\
> +			break;			\
> +		default:			\
> +			break;			\
> +		}				\
> +	} while (0)
> +
> +#define DEC_VIF(_priv, _type) do {		\
> +		switch (_type) {		\
> +		case NL80211_IFTYPE_STATION:	\
> +			_priv->num_sta_vif--;	\
> +			break;			\
> +		case NL80211_IFTYPE_ADHOC:	\
> +			_priv->num_ibss_vif--;	\
> +			break;			\
> +		default:			\
> +			break;			\
> +		}				\
> +	} while (0)
> +
>  struct ath9k_htc_vif {
>  	u8 index;
>  	u16 seq_no;
> @@ -367,6 +393,8 @@ struct ath9k_htc_priv {
>  	u8 mon_vif_idx;
>  	u8 sta_slot;
>  	u8 vif_sta_pos[ATH9K_HTC_MAX_VIF];
> +	u8 num_ibss_vif;
> +	u8 num_sta_vif;
>  
>  	u16 op_flags;
>  	u16 curtxpow;
> diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> index 04cb243..39074fc 100644
> --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> @@ -1193,9 +1193,15 @@ static int ath9k_htc_add_interface(struct ieee80211_hw *hw,
>  	mutex_lock(&priv->mutex);
>  
>  	if (priv->nvifs >= ATH9K_HTC_MAX_VIF) {
> -		ret = -ENOBUFS;
>  		mutex_unlock(&priv->mutex);
> -		return ret;
> +		return -ENOBUFS;
> +	}
> +
> +	if (priv->num_ibss_vif ||
> +	    (priv->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) {
> +		ath_err(common, "IBSS coexistence with other modes is not allowed\n");
> +		mutex_unlock(&priv->mutex);
> +		return -ENOBUFS;
>  	}
Need to handle IBSS interface if vifs are already present.
>  
>  	ath9k_htc_ps_wakeup(priv);
> @@ -1240,6 +1246,8 @@ static int ath9k_htc_add_interface(struct ieee80211_hw *hw,
>  	priv->nvifs++;
>  	priv->vif = vif;
>  
> +	INC_VIF(priv, vif->type);
> +
>  	ath_dbg(common, ATH_DBG_CONFIG,
>  		"Attach a VIF of type: %d at idx: %d\n", vif->type, avp->index);
>  
> @@ -1273,6 +1281,8 @@ static void ath9k_htc_remove_interface(struct ieee80211_hw *hw,
>  	ath9k_htc_remove_station(priv, vif, NULL);
>  	priv->vif = NULL;
>  
> +	DEC_VIF(priv, vif->type);
> +
>  	ath_dbg(common, ATH_DBG_CONFIG, "Detach Interface at idx: %d\n", avp->index);
>  
>  	ath9k_htc_ps_restore(priv);
> -- 
> 1.7.4.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 12/23] ath9k_htc: Maintain individual counters for interfaces
  2011-02-22  5:03 ` Rajkumar Manoharan
@ 2011-02-22 13:03   ` Sujith
  2011-02-22 17:36     ` Rajkumar Manoharan
  0 siblings, 1 reply; 4+ messages in thread
From: Sujith @ 2011-02-22 13:03 UTC (permalink / raw
  To: Rajkumar Manoharan; +Cc: linville@tuxdriver.com, linux-wireless@vger.kernel.org

Rajkumar Manoharan wrote:
> > +	if (priv->num_ibss_vif ||
> > +	    (priv->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) {
> > +		ath_err(common, "IBSS coexistence with other modes is not allowed\n");
> > +		mutex_unlock(&priv->mutex);
> > +		return -ENOBUFS;
> >  	}
> Need to handle IBSS interface if vifs are already present.

I don't understand, addition of a new IBSS interface is denied if we
already have an ADHOC interface present, or any other type, for that matter.
This could be simplified, but this behavior might change in the future ...

Sujith

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

* Re: [PATCH 12/23] ath9k_htc: Maintain individual counters for interfaces
  2011-02-22 13:03   ` Sujith
@ 2011-02-22 17:36     ` Rajkumar Manoharan
  0 siblings, 0 replies; 4+ messages in thread
From: Rajkumar Manoharan @ 2011-02-22 17:36 UTC (permalink / raw
  To: Sujith
  Cc: Rajkumar Manoharan, linville@tuxdriver.com,
	linux-wireless@vger.kernel.org

On Tue, Feb 22, 2011 at 06:33:27PM +0530, Sujith wrote:
> Rajkumar Manoharan wrote:
> > > +	if (priv->num_ibss_vif ||
> > > +	    (priv->nvifs && vif->type == NL80211_IFTYPE_ADHOC)) {
> > > +		ath_err(common, "IBSS coexistence with other modes is not allowed\n");
> > > +		mutex_unlock(&priv->mutex);
> > > +		return -ENOBUFS;
> > >  	}
> > Need to handle IBSS interface if vifs are already present.
> 
> I don't understand, addition of a new IBSS interface is denied if we
> already have an ADHOC interface present, or any other type, for that matter.
> This could be simplified, but this behavior might change in the future ...
>
Yeah. I misunderstood. 

--
Rajkumar

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

end of thread, other threads:[~2011-02-22 17:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-21  2:19 [PATCH 12/23] ath9k_htc: Maintain individual counters for interfaces Sujith
2011-02-22  5:03 ` Rajkumar Manoharan
2011-02-22 13:03   ` Sujith
2011-02-22 17:36     ` Rajkumar Manoharan

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 read-only IMAP folder(s) and NNTP newsgroup(s).