Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0df8359a authored by Sujith Manoharan's avatar Sujith Manoharan Committed by John W. Linville
Browse files

ath9k_htc: Maintain individual counters for interfaces



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

Signed-off-by: default avatarSujith Manoharan <Sujith.Manoharan@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 87df8957
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -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;
+12 −2
Original line number Diff line number Diff line
@@ -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);