Skip to content

Commit

Permalink
ath9k: Node cleanup
Browse files Browse the repository at this point in the history
Start removing the internal node list in ath9k, in preparation
for using mac80211's STA list.
Remove lists, locks, routines, flags, functions managing nodes in ath9k.

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 17683c6 commit b5aa9bf
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 326 deletions.
116 changes: 45 additions & 71 deletions drivers/net/wireless/ath9k/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,41 @@ static void bus_read_cachesize(struct ath_softc *sc, int *csz)
*csz = DEFAULT_CACHELINE >> 2; /* Use the default size */
}

static u8 parse_mpdudensity(u8 mpdudensity)
{
/*
* 802.11n D2.0 defined values for "Minimum MPDU Start Spacing":
* 0 for no restriction
* 1 for 1/4 us
* 2 for 1/2 us
* 3 for 1 us
* 4 for 2 us
* 5 for 4 us
* 6 for 8 us
* 7 for 16 us
*/
switch (mpdudensity) {
case 0:
return 0;
case 1:
case 2:
case 3:
/* Our lower layer calculations limit our precision to
1 microsecond */
return 1;
case 4:
return 2;
case 5:
return 4;
case 6:
return 8;
case 7:
return 16;
default:
return 0;
}
}

/*
* Set current operating mode
*
Expand Down Expand Up @@ -1321,98 +1356,38 @@ void ath_deinit(struct ath_softc *sc)
/* Node Management */
/*******************/

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

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

/* mac80211 sta_notify callback is from an IRQ context, so no sleep */
an = kmalloc(sizeof(struct ath_node), GFP_ATOMIC);
if (an == NULL)
return NULL;
memset(an, 0, sizeof(*an));

an->an_sc = sc;
memcpy(an->an_addr, addr, ETH_ALEN);
atomic_set(&an->an_refcnt, 1);
an = (struct ath_node *)sta->drv_priv;

/* set up per-node tx/rx state */
ath_tx_node_init(sc, an);
ath_rx_node_init(sc, an);

an->maxampdu = 1 << (IEEE80211_HTCAP_MAXRXAMPDU_FACTOR +
sta->ht_cap.ampdu_factor);
an->mpdudensity = parse_mpdudensity(sta->ht_cap.ampdu_density);

ath_chainmask_sel_init(sc, an);
ath_chainmask_sel_timerstart(&an->an_chainmask_sel);
list_add(&an->list, &sc->node_list);

return an;
}

void ath_node_detach(struct ath_softc *sc, struct ath_node *an, bool bh_flag)
void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta)
{
unsigned long flags;
struct ath_node *an = (struct ath_node *)sta->drv_priv;

ath_chainmask_sel_timerstop(&an->an_chainmask_sel);
an->an_flags |= ATH_NODE_CLEAN;
ath_tx_node_cleanup(sc, an, bh_flag);
ath_rx_node_cleanup(sc, an);

ath_tx_node_cleanup(sc, an);

ath_tx_node_free(sc, an);
ath_rx_node_free(sc, an);

spin_lock_irqsave(&sc->node_lock, flags);

list_del(&an->list);

spin_unlock_irqrestore(&sc->node_lock, flags);

kfree(an);
}

/* Finds a node and increases the refcnt if found */

struct ath_node *ath_node_get(struct ath_softc *sc, u8 *addr)
{
struct ath_node *an = NULL, *an_found = NULL;

if (list_empty(&sc->node_list)) /* FIXME */
goto out;
list_for_each_entry(an, &sc->node_list, list) {
if (!compare_ether_addr(an->an_addr, addr)) {
atomic_inc(&an->an_refcnt);
an_found = an;
break;
}
}
out:
return an_found;
}

/* Decrements the refcnt and if it drops to zero, detach the node */

void ath_node_put(struct ath_softc *sc, struct ath_node *an, bool bh_flag)
{
if (atomic_dec_and_test(&an->an_refcnt))
ath_node_detach(sc, an, bh_flag);
}

/* Finds a node, doesn't increment refcnt. Caller must hold sc->node_lock */
struct ath_node *ath_node_find(struct ath_softc *sc, u8 *addr)
{
struct ath_node *an = NULL, *an_found = NULL;

if (list_empty(&sc->node_list))
return NULL;

list_for_each_entry(an, &sc->node_list, list)
if (!compare_ether_addr(an->an_addr, addr)) {
an_found = an;
break;
}

return an_found;
}

/*
Expand All @@ -1437,7 +1412,6 @@ void ath_newassoc(struct ath_softc *sc,
ath_rx_aggr_teardown(sc, an, tidno);
}
}
an->an_flags = 0;
}

/**************/
Expand Down
46 changes: 11 additions & 35 deletions drivers/net/wireless/ath9k/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,6 @@ void ath_flushrecv(struct ath_softc *sc);
u32 ath_calcrxfilter(struct ath_softc *sc);
void ath_rx_node_init(struct ath_softc *sc, struct ath_node *an);
void ath_rx_node_free(struct ath_softc *sc, struct ath_node *an);
void ath_rx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
void ath_handle_rx_intr(struct ath_softc *sc);
int ath_rx_init(struct ath_softc *sc, int nbufs);
void ath_rx_cleanup(struct ath_softc *sc);
Expand Down Expand Up @@ -546,8 +545,7 @@ void ath_draintxq(struct ath_softc *sc, bool retry_tx);
void ath_tx_draintxq(struct ath_softc *sc,
struct ath_txq *txq, bool retry_tx);
void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an);
void ath_tx_node_cleanup(struct ath_softc *sc,
struct ath_node *an, bool bh_flag);
void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an);
void ath_tx_node_free(struct ath_softc *sc, struct ath_node *an);
void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq);
int ath_tx_init(struct ath_softc *sc, int nbufs);
Expand All @@ -568,11 +566,6 @@ void ath_tx_cabq(struct ath_softc *sc, struct sk_buff *skb);
/* Node / Aggregation */
/**********************/

/* indicates the node is clened up */
#define ATH_NODE_CLEAN 0x1
/* indicates the node is 80211 power save */
#define ATH_NODE_PWRSAVE 0x2

#define ADDBA_EXCHANGE_ATTEMPTS 10
#define ATH_AGGR_DELIM_SZ 4 /* delimiter size */
#define ATH_AGGR_MINPLEN 256 /* in bytes, minimum packet length */
Expand All @@ -584,6 +577,7 @@ void ath_tx_cabq(struct ath_softc *sc, struct sk_buff *skb);
#define IEEE80211_SEQ_SEQ_SHIFT 4
#define IEEE80211_SEQ_MAX 4096
#define IEEE80211_MIN_AMPDU_BUF 0x8
#define IEEE80211_HTCAP_MAXRXAMPDU_FACTOR 13

/* return whether a bit at index _n in bitmap _bm is set
* _sz is the size of the bitmap */
Expand Down Expand Up @@ -638,15 +632,10 @@ struct ath_node_aggr {

/* driver-specific node state */
struct ath_node {
struct list_head list;
struct ath_softc *an_sc;
atomic_t an_refcnt;
struct ath_chainmask_sel an_chainmask_sel;
struct ath_node_aggr an_aggr;
u8 an_smmode; /* SM Power save mode */
u8 an_flags;
u8 an_addr[ETH_ALEN];

u16 maxampdu;
u8 mpdudensity;
};
Expand All @@ -659,28 +648,17 @@ void ath_tx_aggr_teardown(struct ath_softc *sc,
struct ath_node *an, u8 tidno);
void ath_rx_aggr_teardown(struct ath_softc *sc,
struct ath_node *an, u8 tidno);
int ath_rx_aggr_start(struct ath_softc *sc,
const u8 *addr,
u16 tid,
u16 *ssn);
int ath_rx_aggr_stop(struct ath_softc *sc,
const u8 *addr,
u16 tid);
int ath_tx_aggr_start(struct ath_softc *sc,
const u8 *addr,
u16 tid,
u16 *ssn);
int ath_tx_aggr_stop(struct ath_softc *sc,
const u8 *addr,
u16 tid);
int ath_rx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
u16 tid, u16 *ssn);
int ath_rx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid);
int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta,
u16 tid, u16 *ssn);
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);
struct ath_node *ath_node_attach(struct ath_softc *sc,
u8 addr[ETH_ALEN], int if_id);
void ath_node_detach(struct ath_softc *sc, struct ath_node *an, bool bh_flag);
struct ath_node *ath_node_get(struct ath_softc *sc, u8 addr[ETH_ALEN]);
void ath_node_put(struct ath_softc *sc, struct ath_node *an, bool bh_flag);
struct ath_node *ath_node_find(struct ath_softc *sc, u8 *addr);
void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta,
int if_id);
void ath_node_detach(struct ath_softc *sc, struct ieee80211_sta *sta);

/*******************/
/* Beacon Handling */
Expand Down Expand Up @@ -975,7 +953,6 @@ struct ath_softc {
u8 sc_rxotherant; /* rx's on non-default antenna */

struct ath9k_node_stats sc_halstats; /* station-mode rssi stats */
struct list_head node_list;
struct ath_ht_info sc_ht_info;
enum ath9k_ht_extprotspacing sc_ht_extprotspacing;

Expand Down Expand Up @@ -1036,7 +1013,6 @@ struct ath_softc {
spinlock_t sc_rxbuflock;
spinlock_t sc_txbuflock;
spinlock_t sc_resetlock;
spinlock_t node_lock;

/* LEDs */
struct ath_led radio_led;
Expand Down
Loading

0 comments on commit b5aa9bf

Please sign in to comment.