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

Commit 9fc9ab0a authored by Sujith's avatar Sujith Committed by John W. Linville
Browse files

ath9k: Scrub beacon.c



Remove useless comments, fix indentation.
Also, remove all occurrences of ASSERT(vif) which are not needed.

Signed-off-by: default avatarSujith <Sujith.Manoharan@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 0c98de65
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -453,7 +453,7 @@ struct ath_beacon {
	struct list_head bbuf;
	struct list_head bbuf;
};
};


void ath9k_beacon_tasklet(unsigned long data);
void ath_beacon_tasklet(unsigned long data);
void ath_beacon_config(struct ath_softc *sc, int if_id);
void ath_beacon_config(struct ath_softc *sc, int if_id);
int ath_beaconq_setup(struct ath_hw *ah);
int ath_beaconq_setup(struct ath_hw *ah);
int ath_beacon_alloc(struct ath_softc *sc, int if_id);
int ath_beacon_alloc(struct ath_softc *sc, int if_id);
+53 −124
Original line number Original line Diff line number Diff line
@@ -44,15 +44,14 @@ static int ath_beaconq_config(struct ath_softc *sc)
			"unable to update h/w beacon queue parameters\n");
			"unable to update h/w beacon queue parameters\n");
		return 0;
		return 0;
	} else {
	} else {
		ath9k_hw_resettxqueue(ah, sc->beacon.beaconq); /* push to h/w */
		ath9k_hw_resettxqueue(ah, sc->beacon.beaconq);
		return 1;
		return 1;
	}
	}
}
}


static void ath_bstuck_process(struct ath_softc *sc)
static void ath_bstuck_process(struct ath_softc *sc)
{
{
	DPRINTF(sc, ATH_DBG_BEACON,
	DPRINTF(sc, ATH_DBG_BEACON, "stuck beacon; resetting (bmiss count %u)\n",
		"stuck beacon; resetting (bmiss count %u)\n",
		sc->beacon.bmisscnt);
		sc->beacon.bmisscnt);
	ath_reset(sc, false);
	ath_reset(sc, false);
}
}
@@ -62,24 +61,18 @@ static void ath_bstuck_process(struct ath_softc *sc)
 *  up all required antenna switch parameters, rate codes, and channel flags.
 *  up all required antenna switch parameters, rate codes, and channel flags.
 *  Beacons are always sent out at the lowest rate, and are not retried.
 *  Beacons are always sent out at the lowest rate, and are not retried.
*/
*/
static void ath_beacon_setup(struct ath_softc *sc,
static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp,
			     struct ath_vif *avp, struct ath_buf *bf)
			     struct ath_buf *bf)
{
{
	struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
	struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
	struct ath_hw *ah = sc->sc_ah;
	struct ath_hw *ah = sc->sc_ah;
	struct ath_desc *ds;
	struct ath_desc *ds;
	struct ath9k_11n_rate_series series[4];
	struct ath9k_11n_rate_series series[4];
	struct ath_rate_table *rt;
	struct ath_rate_table *rt;
	int flags, antenna;
	int flags, antenna, ctsrate = 0, ctsduration = 0;
	u8 rix, rate;
	u8 rate;
	int ctsrate = 0;
	int ctsduration = 0;

	DPRINTF(sc, ATH_DBG_BEACON, "m %p len %u\n", skb, skb->len);


	/* setup descriptors */
	ds = bf->bf_desc;
	ds = bf->bf_desc;

	flags = ATH9K_TXDESC_NOACK;
	flags = ATH9K_TXDESC_NOACK;


	if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC &&
	if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC &&
@@ -92,53 +85,39 @@ static void ath_beacon_setup(struct ath_softc *sc,
		ds->ds_link = 0;
		ds->ds_link = 0;
		/*
		/*
		 * Switch antenna every beacon.
		 * Switch antenna every beacon.
		 * Should only switch every beacon period, not for every
		 * Should only switch every beacon period, not for every SWBA
		 * SWBA's
		 * XXX assumes two antennae
		 * XXX assumes two antenna
		 */
		 */
		antenna = ((sc->beacon.ast_be_xmit / sc->nbcnvifs) & 1 ? 2 : 1);
		antenna = ((sc->beacon.ast_be_xmit / sc->nbcnvifs) & 1 ? 2 : 1);
	}
	}


	ds->ds_data = bf->bf_buf_addr;
	ds->ds_data = bf->bf_buf_addr;


	/*
	 * Calculate rate code.
	 * XXX everything at min xmit rate
	 */
	rix = 0;
	rt = sc->cur_rate_table;
	rt = sc->cur_rate_table;
	rate = rt->info[rix].ratecode;
	rate = rt->info[0].ratecode;
	if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
	if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
		rate |= rt->info[rix].short_preamble;
		rate |= rt->info[0].short_preamble;


	ath9k_hw_set11n_txdesc(ah, ds,
	ath9k_hw_set11n_txdesc(ah, ds, skb->len + FCS_LEN,
			       skb->len + FCS_LEN,     /* frame length */
			       ATH9K_PKT_TYPE_BEACON,
			       ATH9K_PKT_TYPE_BEACON,  /* Atheros packet type */
			       MAX_RATE_POWER,
			       MAX_RATE_POWER,         /* FIXME */
			       ATH9K_TXKEYIX_INVALID,
			       ATH9K_TXKEYIX_INVALID,  /* no encryption */
			       ATH9K_KEY_TYPE_CLEAR,
			       ATH9K_KEY_TYPE_CLEAR,   /* no encryption */
			       flags);
			       flags                   /* no ack,
							  veol for beacons */
		);


	/* NB: beacon's BufLen must be a multiple of 4 bytes */
	/* NB: beacon's BufLen must be a multiple of 4 bytes */
	ath9k_hw_filltxdesc(ah, ds,
	ath9k_hw_filltxdesc(ah, ds, roundup(skb->len, 4),
			    roundup(skb->len, 4), /* buffer length */
			    true, true, ds);
			    true,                 /* first segment */
			    true,                 /* last segment */
			    ds                    /* first descriptor */
		);


	memset(series, 0, sizeof(struct ath9k_11n_rate_series) * 4);
	memset(series, 0, sizeof(struct ath9k_11n_rate_series) * 4);
	series[0].Tries = 1;
	series[0].Tries = 1;
	series[0].Rate = rate;
	series[0].Rate = rate;
	series[0].ChSel = sc->tx_chainmask;
	series[0].ChSel = sc->tx_chainmask;
	series[0].RateFlags = (ctsrate) ? ATH9K_RATESERIES_RTS_CTS : 0;
	series[0].RateFlags = (ctsrate) ? ATH9K_RATESERIES_RTS_CTS : 0;
	ath9k_hw_set11n_ratescenario(ah, ds, ds, 0,
	ath9k_hw_set11n_ratescenario(ah, ds, ds, 0, ctsrate, ctsduration,
		ctsrate, ctsduration, series, 4, 0);
				     series, 4, 0);
}
}


/* Generate beacon frame and queue cab data for a VIF */
static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
{
{
	struct ath_buf *bf;
	struct ath_buf *bf;
@@ -150,8 +129,6 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
	int cabq_depth;
	int cabq_depth;


	vif = sc->vifs[if_id];
	vif = sc->vifs[if_id];
	ASSERT(vif);

	avp = (void *)vif->drv_priv;
	avp = (void *)vif->drv_priv;
	cabq = sc->beacon.cabq;
	cabq = sc->beacon.cabq;


@@ -161,15 +138,18 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
		return NULL;
		return NULL;
	}
	}


	/* Release the old beacon first */

	bf = avp->av_bcbuf;
	bf = avp->av_bcbuf;
	skb = (struct sk_buff *)bf->bf_mpdu;
	skb = (struct sk_buff *)bf->bf_mpdu;
	if (skb) {
	if (skb) {
		dma_unmap_single(sc->dev, bf->bf_dmacontext,
		dma_unmap_single(sc->dev, bf->bf_dmacontext,
				 skb->len,
				 skb->len, DMA_TO_DEVICE);
				 DMA_TO_DEVICE);
		dev_kfree_skb_any(skb);
		dev_kfree_skb_any(skb);
	}
	}


	/* Get a new beacon from mac80211 */

	skb = ieee80211_beacon_get(sc->hw, vif);
	skb = ieee80211_beacon_get(sc->hw, vif);
	bf->bf_mpdu = skb;
	bf->bf_mpdu = skb;
	if (skb == NULL)
	if (skb == NULL)
@@ -189,13 +169,11 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)


	bf->bf_buf_addr = bf->bf_dmacontext =
	bf->bf_buf_addr = bf->bf_dmacontext =
		dma_map_single(sc->dev, skb->data,
		dma_map_single(sc->dev, skb->data,
			       skb->len,
			       skb->len, DMA_TO_DEVICE);
			       DMA_TO_DEVICE);
	if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
	if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
		dev_kfree_skb_any(skb);
		dev_kfree_skb_any(skb);
		bf->bf_mpdu = NULL;
		bf->bf_mpdu = NULL;
		DPRINTF(sc, ATH_DBG_CONFIG,
		DPRINTF(sc, ATH_DBG_FATAL, "dma_mapping_error on beaconing\n");
			"dma_mapping_error() on beaconing\n");
		return NULL;
		return NULL;
	}
	}


@@ -214,25 +192,15 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
	spin_unlock_bh(&cabq->axq_lock);
	spin_unlock_bh(&cabq->axq_lock);


	if (skb && cabq_depth) {
	if (skb && cabq_depth) {
		/*
		 * Unlock the cabq lock as ath_tx_draintxq acquires
		 * the lock again which is a common function and that
		 * acquires txq lock inside.
		 */
		if (sc->nvifs > 1) {
		if (sc->nvifs > 1) {
			ath_draintxq(sc, cabq, false);
			DPRINTF(sc, ATH_DBG_BEACON,
			DPRINTF(sc, ATH_DBG_BEACON,
				"flush previous cabq traffic\n");
				"Flushing previous cabq traffic\n");
			ath_draintxq(sc, cabq, false);
		}
		}
	}
	}


	/* Construct tx descriptor. */
	ath_beacon_setup(sc, avp, bf);
	ath_beacon_setup(sc, avp, bf);


	/*
	 * Enable the CAB queue before the beacon queue to
	 * insure cab frames are triggered by this beacon.
	 */
	while (skb) {
	while (skb) {
		ath_tx_cabq(sc, skb);
		ath_tx_cabq(sc, skb);
		skb = ieee80211_get_buffered_bc(sc->hw, vif);
		skb = ieee80211_get_buffered_bc(sc->hw, vif);
@@ -254,19 +222,14 @@ static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id)
	struct sk_buff *skb;
	struct sk_buff *skb;


	vif = sc->vifs[if_id];
	vif = sc->vifs[if_id];
	ASSERT(vif);

	avp = (void *)vif->drv_priv;
	avp = (void *)vif->drv_priv;


	if (avp->av_bcbuf == NULL) {
	if (avp->av_bcbuf == NULL)
		DPRINTF(sc, ATH_DBG_BEACON, "avp=%p av_bcbuf=%p\n",
			avp, avp != NULL ? avp->av_bcbuf : NULL);
		return;
		return;
	}

	bf = avp->av_bcbuf;
	bf = avp->av_bcbuf;
	skb = (struct sk_buff *) bf->bf_mpdu;
	skb = (struct sk_buff *) bf->bf_mpdu;


	/* Construct tx descriptor. */
	ath_beacon_setup(sc, avp, bf);
	ath_beacon_setup(sc, avp, bf);


	/* NB: caller is known to have already stopped tx dma */
	/* NB: caller is known to have already stopped tx dma */
@@ -298,8 +261,6 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
	__le64 tstamp;
	__le64 tstamp;


	vif = sc->vifs[if_id];
	vif = sc->vifs[if_id];
	ASSERT(vif);

	avp = (void *)vif->drv_priv;
	avp = (void *)vif->drv_priv;


	/* Allocate a beacon descriptor if we haven't done so. */
	/* Allocate a beacon descriptor if we haven't done so. */
@@ -344,17 +305,12 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
	if (bf->bf_mpdu != NULL) {
	if (bf->bf_mpdu != NULL) {
		skb = (struct sk_buff *)bf->bf_mpdu;
		skb = (struct sk_buff *)bf->bf_mpdu;
		dma_unmap_single(sc->dev, bf->bf_dmacontext,
		dma_unmap_single(sc->dev, bf->bf_dmacontext,
				 skb->len,
				 skb->len, DMA_TO_DEVICE);
				 DMA_TO_DEVICE);
		dev_kfree_skb_any(skb);
		dev_kfree_skb_any(skb);
		bf->bf_mpdu = NULL;
		bf->bf_mpdu = NULL;
	}
	}


	/*
	/* NB: the beacon data buffer must be 32-bit aligned. */
	 * NB: the beacon data buffer must be 32-bit aligned.
	 * FIXME: Fill avp->av_btxctl.txpower and
	 * avp->av_btxctl.shortPreamble
	 */
	skb = ieee80211_beacon_get(sc->hw, vif);
	skb = ieee80211_beacon_get(sc->hw, vif);
	if (skb == NULL) {
	if (skb == NULL) {
		DPRINTF(sc, ATH_DBG_BEACON, "cannot get skb\n");
		DPRINTF(sc, ATH_DBG_BEACON, "cannot get skb\n");
@@ -403,13 +359,12 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
	bf->bf_mpdu = skb;
	bf->bf_mpdu = skb;
	bf->bf_buf_addr = bf->bf_dmacontext =
	bf->bf_buf_addr = bf->bf_dmacontext =
		dma_map_single(sc->dev, skb->data,
		dma_map_single(sc->dev, skb->data,
			       skb->len,
			       skb->len, DMA_TO_DEVICE);
			       DMA_TO_DEVICE);
	if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
	if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
		dev_kfree_skb_any(skb);
		dev_kfree_skb_any(skb);
		bf->bf_mpdu = NULL;
		bf->bf_mpdu = NULL;
		DPRINTF(sc, ATH_DBG_CONFIG,
		DPRINTF(sc, ATH_DBG_FATAL,
			"dma_mapping_error() on beacon alloc\n");
			"dma_mapping_error on beacon alloc\n");
		return -ENOMEM;
		return -ENOMEM;
	}
	}


@@ -430,8 +385,7 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp)
		if (bf->bf_mpdu != NULL) {
		if (bf->bf_mpdu != NULL) {
			struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
			struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
			dma_unmap_single(sc->dev, bf->bf_dmacontext,
			dma_unmap_single(sc->dev, bf->bf_dmacontext,
					 skb->len,
					 skb->len, DMA_TO_DEVICE);
					 DMA_TO_DEVICE);
			dev_kfree_skb_any(skb);
			dev_kfree_skb_any(skb);
			bf->bf_mpdu = NULL;
			bf->bf_mpdu = NULL;
		}
		}
@@ -441,18 +395,15 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vif *avp)
	}
	}
}
}


void ath9k_beacon_tasklet(unsigned long data)
void ath_beacon_tasklet(unsigned long data)
{
{
	struct ath_softc *sc = (struct ath_softc *)data;
	struct ath_softc *sc = (struct ath_softc *)data;
	struct ath_hw *ah = sc->sc_ah;
	struct ath_hw *ah = sc->sc_ah;
	struct ath_buf *bf = NULL;
	struct ath_buf *bf = NULL;
	int slot, if_id;
	int slot, if_id;
	u32 bfaddr;
	u32 bfaddr, show_cycles = 0, bc = 0, tsftu;
	u32 rx_clear = 0, rx_frame = 0, tx_frame = 0;
	u32 rx_clear = 0, rx_frame = 0, tx_frame = 0;
	u32 show_cycles = 0;
	u32 bc = 0; /* beacon count */
	u64 tsf;
	u64 tsf;
	u32 tsftu;
	u16 intval;
	u16 intval;


	if (sc->sc_flags & SC_OP_NO_RESET) {
	if (sc->sc_flags & SC_OP_NO_RESET) {
@@ -627,7 +578,6 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)


	if (if_id != ATH_IF_ID_ANY) {
	if (if_id != ATH_IF_ID_ANY) {
		vif = sc->vifs[if_id];
		vif = sc->vifs[if_id];
		ASSERT(vif);
		avp = (void *)vif->drv_priv;
		avp = (void *)vif->drv_priv;
		opmode = avp->av_opmode;
		opmode = avp->av_opmode;
	} else {
	} else {
@@ -757,30 +707,11 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
		bs.bs_tsfoor_threshold = ATH9K_TSFOOR_THRESHOLD;
		bs.bs_tsfoor_threshold = ATH9K_TSFOOR_THRESHOLD;


		DPRINTF(sc, ATH_DBG_BEACON,
		DPRINTF(sc, ATH_DBG_BEACON,
			"tsf %llu "
			"tsf: %llu tsftu: %u\n", tsf, tsftu);
			"tsf:tu %u "
		DPRINTF(sc, ATH_DBG_BEACON,
			"intval %u "
			"bmiss: %u sleep: %u cfp-period: %u maxdur: %u next: %u\n",
			"nexttbtt %u "
			bs.bs_bmissthreshold, bs.bs_sleepduration,
			"dtim %u "
			bs.bs_cfpperiod, bs.bs_cfpmaxduration, bs.bs_cfpnext);
			"nextdtim %u "
			"bmiss %u "
			"sleep %u "
			"cfp:period %u "
			"maxdur %u "
			"next %u "
			"timoffset %u\n",
			(unsigned long long)tsf, tsftu,
			bs.bs_intval,
			bs.bs_nexttbtt,
			bs.bs_dtimperiod,
			bs.bs_nextdtim,
			bs.bs_bmissthreshold,
			bs.bs_sleepduration,
			bs.bs_cfpperiod,
			bs.bs_cfpmaxduration,
			bs.bs_cfpnext,
			bs.bs_timoffset
			);


		ath9k_hw_set_interrupts(ah, 0);
		ath9k_hw_set_interrupts(ah, 0);
		ath9k_hw_set_sta_beacon_timers(ah, &bs);
		ath9k_hw_set_sta_beacon_timers(ah, &bs);
@@ -789,12 +720,10 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
	} else {
	} else {
		u64 tsf;
		u64 tsf;
		u32 tsftu;
		u32 tsftu;

		ath9k_hw_set_interrupts(ah, 0);
		ath9k_hw_set_interrupts(ah, 0);
		if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) {
		if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) {
			/*
			/* Pull nexttbtt forward to reflect the current TSF */
			 * Pull nexttbtt forward to reflect the current
			 * TSF
			 */
#define FUDGE 2
#define FUDGE 2
			if (!(intval & ATH9K_BEACON_RESET_TSF)) {
			if (!(intval & ATH9K_BEACON_RESET_TSF)) {
				tsf = ath9k_hw_gettsf64(ah);
				tsf = ath9k_hw_gettsf64(ah);
@@ -807,8 +736,7 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
#undef FUDGE
#undef FUDGE
			DPRINTF(sc, ATH_DBG_BEACON,
			DPRINTF(sc, ATH_DBG_BEACON,
				"IBSS nexttbtt %u intval %u (%u)\n",
				"IBSS nexttbtt %u intval %u (%u)\n",
				nexttbtt,
				nexttbtt, intval & ~ATH9K_BEACON_RESET_TSF,
				intval & ~ATH9K_BEACON_RESET_TSF,
				conf.beacon_interval);
				conf.beacon_interval);


			/*
			/*
@@ -825,18 +753,19 @@ void ath_beacon_config(struct ath_softc *sc, int if_id)
		} else if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) {
		} else if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) {
			if (nexttbtt == intval)
			if (nexttbtt == intval)
				intval |= ATH9K_BEACON_RESET_TSF;
				intval |= ATH9K_BEACON_RESET_TSF;

			/*
			/*
			 * In AP mode we enable the beacon timers and
			 * In AP mode we enable the beacon timers and
			 * SWBA interrupts to prepare beacon frames.
			 * SWBA interrupts to prepare beacon frames.
			 */
			 */
			intval |= ATH9K_BEACON_ENA;
			intval |= ATH9K_BEACON_ENA;
			sc->imask |= ATH9K_INT_SWBA;   /* beacon prepare */
			sc->imask |= ATH9K_INT_SWBA;
			ath_beaconq_config(sc);
			ath_beaconq_config(sc);
		}
		}

		ath9k_hw_beaconinit(ah, nexttbtt, intval);
		ath9k_hw_beaconinit(ah, nexttbtt, intval);
		sc->beacon.bmisscnt = 0;
		sc->beacon.bmisscnt = 0;
		ath9k_hw_set_interrupts(ah, sc->imask);
		ath9k_hw_set_interrupts(ah, sc->imask);

		/*
		/*
		 * When using a self-linked beacon descriptor in
		 * When using a self-linked beacon descriptor in
		 * ibss mode load it once here.
		 * ibss mode load it once here.
+1 −1
Original line number Original line Diff line number Diff line
@@ -1374,7 +1374,7 @@ static int ath_init(u16 devid, struct ath_softc *sc)
	spin_lock_init(&sc->sc_resetlock);
	spin_lock_init(&sc->sc_resetlock);
	mutex_init(&sc->mutex);
	mutex_init(&sc->mutex);
	tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
	tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc);
	tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet,
	tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet,
		     (unsigned long)sc);
		     (unsigned long)sc);


	/*
	/*