Skip to content

Commit

Permalink
ath9k: Revamp VAP management
Browse files Browse the repository at this point in the history
Remove the internal VAP management routines
and embed ath_vap in mac80211's driver private area
provided in ieee80211_vif.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Sujith authored and John W. Linville committed Nov 10, 2008
1 parent a37c2c7 commit 5640b08
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 193 deletions.
40 changes: 27 additions & 13 deletions drivers/net/wireless/ath9k/beacon.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,14 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
struct ath_vap *avp;
struct sk_buff *skb;
struct ath_txq *cabq;
struct ieee80211_vif *vif;
struct ieee80211_tx_info *info;
int cabq_depth;

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

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

if (avp->av_bcbuf == NULL) {
Expand All @@ -174,7 +176,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
PCI_DMA_TODEVICE);
}

skb = ieee80211_beacon_get(sc->hw, avp->av_if_data);
skb = ieee80211_beacon_get(sc->hw, vif);
bf->bf_mpdu = skb;
if (skb == NULL)
return NULL;
Expand All @@ -196,7 +198,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
skb_end_pointer(skb) - skb->head,
PCI_DMA_TODEVICE);

skb = ieee80211_get_buffered_bc(sc->hw, avp->av_if_data);
skb = ieee80211_get_buffered_bc(sc->hw, vif);

/*
* if the CABQ traffic from previous DTIM is pending and the current
Expand Down Expand Up @@ -232,7 +234,7 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
*/
while (skb) {
ath_tx_cabq(sc, skb);
skb = ieee80211_get_buffered_bc(sc->hw, avp->av_if_data);
skb = ieee80211_get_buffered_bc(sc->hw, vif);
}

return bf;
Expand All @@ -244,13 +246,16 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
*/
static void ath_beacon_start_adhoc(struct ath_softc *sc, int if_id)
{
struct ieee80211_vif *vif;
struct ath_hal *ah = sc->sc_ah;
struct ath_buf *bf;
struct ath_vap *avp;
struct sk_buff *skb;

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

avp = (void *)vif->drv_priv;

if (avp->av_bcbuf == NULL) {
DPRINTF(sc, ATH_DBG_BEACON, "%s: avp=%p av_bcbuf=%p\n",
Expand Down Expand Up @@ -300,14 +305,17 @@ int ath_beaconq_setup(struct ath_hal *ah)
*/
int ath_beacon_alloc(struct ath_softc *sc, int if_id)
{
struct ieee80211_vif *vif;
struct ath_vap *avp;
struct ieee80211_hdr *hdr;
struct ath_buf *bf;
struct sk_buff *skb;
__le64 tstamp;

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

avp = (void *)vif->drv_priv;

/* Allocate a beacon descriptor if we haven't done so. */
if (!avp->av_bcbuf) {
Expand Down Expand Up @@ -363,7 +371,7 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
* FIXME: Fill avp->av_btxctl.txpower and
* avp->av_btxctl.shortPreamble
*/
skb = ieee80211_beacon_get(sc->hw, avp->av_if_data);
skb = ieee80211_beacon_get(sc->hw, vif);
if (skb == NULL) {
DPRINTF(sc, ATH_DBG_BEACON, "%s: cannot get skb\n",
__func__);
Expand Down Expand Up @@ -652,15 +660,21 @@ void ath_bstuck_process(struct ath_softc *sc)
*/
void ath_beacon_config(struct ath_softc *sc, int if_id)
{
struct ieee80211_vif *vif;
struct ath_hal *ah = sc->sc_ah;
struct ath_beacon_config conf;
struct ath_vap *avp;
enum ath9k_opmode av_opmode;
u32 nexttbtt, intval;

if (if_id != ATH_IF_ID_ANY)
av_opmode = sc->sc_vaps[if_id]->av_opmode;
else
if (if_id != ATH_IF_ID_ANY) {
vif = sc->sc_vaps[if_id];
ASSERT(vif);
avp = (void *)vif->drv_priv;
av_opmode = avp->av_opmode;
} else {
av_opmode = sc->sc_ah->ah_opmode;
}

memset(&conf, 0, sizeof(struct ath_beacon_config));

Expand Down
116 changes: 1 addition & 115 deletions drivers/net/wireless/ath9k/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

/* Implementation of the main "ATH" layer. */

#include "core.h"
#include "regd.h"

Expand Down Expand Up @@ -641,114 +639,6 @@ static void ath_ani_calibrate(unsigned long data)
mod_timer(&sc->sc_ani.timer, jiffies + msecs_to_jiffies(cal_interval));
}

/******************/
/* VAP management */
/******************/

int ath_vap_attach(struct ath_softc *sc,
int if_id,
struct ieee80211_vif *if_data,
enum ath9k_opmode opmode)
{
struct ath_vap *avp;

if (if_id >= ATH_BCBUF || sc->sc_vaps[if_id] != NULL) {
DPRINTF(sc, ATH_DBG_FATAL,
"%s: Invalid interface id = %u\n", __func__, if_id);
return -EINVAL;
}

switch (opmode) {
case ATH9K_M_STA:
case ATH9K_M_IBSS:
case ATH9K_M_MONITOR:
break;
case ATH9K_M_HOSTAP:
/* XXX not right, beacon buffer is allocated on RUN trans */
if (list_empty(&sc->sc_bbuf))
return -ENOMEM;
break;
default:
return -EINVAL;
}

/* create ath_vap */
avp = kmalloc(sizeof(struct ath_vap), GFP_KERNEL);
if (avp == NULL)
return -ENOMEM;

memset(avp, 0, sizeof(struct ath_vap));
avp->av_if_data = if_data;
/* Set the VAP opmode */
avp->av_opmode = opmode;
avp->av_bslot = -1;

if (opmode == ATH9K_M_HOSTAP)
ath9k_hw_set_tsfadjust(sc->sc_ah, 1);

sc->sc_vaps[if_id] = avp;
sc->sc_nvaps++;
/* Set the device opmode */
sc->sc_ah->ah_opmode = opmode;

/* default VAP configuration */
avp->av_config.av_fixed_rateset = IEEE80211_FIXED_RATE_NONE;
avp->av_config.av_fixed_retryset = 0x03030303;

return 0;
}

int ath_vap_detach(struct ath_softc *sc, int if_id)
{
struct ath_hal *ah = sc->sc_ah;
struct ath_vap *avp;

avp = sc->sc_vaps[if_id];
if (avp == NULL) {
DPRINTF(sc, ATH_DBG_FATAL, "%s: invalid interface id %u\n",
__func__, if_id);
return -EINVAL;
}

/*
* Quiesce the hardware while we remove the vap. In
* particular we need to reclaim all references to the
* vap state by any frames pending on the tx queues.
*
* XXX can we do this w/o affecting other vap's?
*/
ath9k_hw_set_interrupts(ah, 0); /* disable interrupts */
ath_draintxq(sc, false); /* stop xmit side */
ath_stoprecv(sc); /* stop recv side */
ath_flushrecv(sc); /* flush recv queue */

kfree(avp);
sc->sc_vaps[if_id] = NULL;
sc->sc_nvaps--;

return 0;
}

int ath_vap_config(struct ath_softc *sc,
int if_id, struct ath_vap_config *if_config)
{
struct ath_vap *avp;

if (if_id >= ATH_BCBUF) {
DPRINTF(sc, ATH_DBG_FATAL,
"%s: Invalid interface id = %u\n", __func__, if_id);
return -EINVAL;
}

avp = sc->sc_vaps[if_id];
ASSERT(avp != NULL);

if (avp)
memcpy(&avp->av_config, if_config, sizeof(avp->av_config));

return 0;
}

/********/
/* Core */
/********/
Expand Down Expand Up @@ -1356,14 +1246,10 @@ void ath_deinit(struct ath_softc *sc)
/* Node Management */
/*******************/

void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta, int if_id)
void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta)
{
struct ath_vap *avp;
struct ath_node *an;

avp = sc->sc_vaps[if_id];
ASSERT(avp != NULL);

an = (struct ath_node *)sta->drv_priv;

if (sc->sc_flags & SC_OP_TXAGGR)
Expand Down
16 changes: 3 additions & 13 deletions drivers/net/wireless/ath9k/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,7 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
int ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
void ath_newassoc(struct ath_softc *sc,
struct ath_node *node, int isnew, int isuapsd);
void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
int if_id);
void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta);
void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta);

/*******************/
Expand Down Expand Up @@ -701,23 +700,14 @@ struct ath_vap_config {

/* driver-specific vap state */
struct ath_vap {
struct ieee80211_vif *av_if_data;
int av_bslot; /* beacon slot index */
enum ath9k_opmode av_opmode; /* VAP operational mode */
struct ath_buf *av_bcbuf; /* beacon buffer */
struct ath_tx_control av_btxctl; /* txctl information for beacon */
int av_bslot; /* beacon slot index */
struct ath_vap_config av_config;/* vap configuration parameters*/
struct ath_rate_node *rc_node;
};

int ath_vap_attach(struct ath_softc *sc,
int if_id,
struct ieee80211_vif *if_data,
enum ath9k_opmode opmode);
int ath_vap_detach(struct ath_softc *sc, int if_id);
int ath_vap_config(struct ath_softc *sc,
int if_id, struct ath_vap_config *if_config);

/*********************/
/* Antenna diversity */
/*********************/
Expand Down Expand Up @@ -925,7 +915,7 @@ struct ath_softc {

u8 sc_nbcnvaps; /* # of vaps sending beacons */
u16 sc_nvaps; /* # of active virtual ap's */
struct ath_vap *sc_vaps[ATH_BCBUF];
struct ieee80211_vif *sc_vaps[ATH_BCBUF];

u8 sc_mcastantenna;
u8 sc_defant; /* current default antenna */
Expand Down
Loading

0 comments on commit 5640b08

Please sign in to comment.