Commit c4dc0d04 authored by Rajkumar Manoharan's avatar Rajkumar Manoharan Committed by John W. Linville

ath9k: Fetch appropriate operating channel context

Retrieve appropriate operating channel context while switching
between operating and off channels.
Signed-off-by: default avatarRajkumar Manoharan <rmanohar@qti.qualcomm.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 39305635
...@@ -355,6 +355,10 @@ struct ath_offchannel { ...@@ -355,6 +355,10 @@ struct ath_offchannel {
struct ieee80211_vif *roc_vif; struct ieee80211_vif *roc_vif;
int roc_duration; int roc_duration;
}; };
#define ath_for_each_chanctx(_sc, _ctx) \
for (ctx = &sc->chanctx[0]; \
ctx <= &sc->chanctx[ARRAY_SIZE(sc->chanctx) - 1]; \
ctx++)
void ath9k_fill_chanctx_ops(void); void ath9k_fill_chanctx_ops(void);
static inline struct ath_chanctx * static inline struct ath_chanctx *
...@@ -373,7 +377,8 @@ void ath_offchannel_timer(unsigned long data); ...@@ -373,7 +377,8 @@ void ath_offchannel_timer(unsigned long data);
void ath_offchannel_channel_change(struct ath_softc *sc); void ath_offchannel_channel_change(struct ath_softc *sc);
void ath_chanctx_offchan_switch(struct ath_softc *sc, void ath_chanctx_offchan_switch(struct ath_softc *sc,
struct ieee80211_channel *chan); struct ieee80211_channel *chan);
struct ath_chanctx *ath_chanctx_get_oper_chan(struct ath_softc *sc); struct ath_chanctx *ath_chanctx_get_oper_chan(struct ath_softc *sc,
bool active);
int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan); int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan);
int ath_startrecv(struct ath_softc *sc); int ath_startrecv(struct ath_softc *sc);
......
...@@ -293,13 +293,17 @@ void ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx, ...@@ -293,13 +293,17 @@ void ath_chanctx_set_channel(struct ath_softc *sc, struct ath_chanctx *ctx,
ath_set_channel(sc); ath_set_channel(sc);
} }
struct ath_chanctx *ath_chanctx_get_oper_chan(struct ath_softc *sc) struct ath_chanctx *ath_chanctx_get_oper_chan(struct ath_softc *sc, bool active)
{ {
u8 i; struct ath_chanctx *ctx;
ath_for_each_chanctx(sc, ctx) {
if (!ctx->assigned || list_empty(&ctx->vifs))
continue;
if (active && !ctx->active)
continue;
for (i = 0; i < ARRAY_SIZE(sc->chanctx); i++) { return ctx;
if (!list_empty(&sc->chanctx[i].vifs))
return &sc->chanctx[i];
} }
return &sc->chanctx[0]; return &sc->chanctx[0];
......
...@@ -2161,7 +2161,8 @@ ath_scan_next_channel(struct ath_softc *sc) ...@@ -2161,7 +2161,8 @@ ath_scan_next_channel(struct ath_softc *sc)
if (sc->offchannel.scan_idx >= req->n_channels) { if (sc->offchannel.scan_idx >= req->n_channels) {
sc->offchannel.state = ATH_OFFCHANNEL_IDLE; sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc), NULL); ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false),
NULL);
return; return;
} }
...@@ -2184,7 +2185,8 @@ static void ath_offchannel_next(struct ath_softc *sc) ...@@ -2184,7 +2185,8 @@ static void ath_offchannel_next(struct ath_softc *sc)
sc->offchannel.state = ATH_OFFCHANNEL_ROC_START; sc->offchannel.state = ATH_OFFCHANNEL_ROC_START;
ath_chanctx_offchan_switch(sc, sc->offchannel.roc_chan); ath_chanctx_offchan_switch(sc, sc->offchannel.roc_chan);
} else { } else {
ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc), NULL); ath_chanctx_switch(sc, ath_chanctx_get_oper_chan(sc, false),
NULL);
sc->offchannel.state = ATH_OFFCHANNEL_IDLE; sc->offchannel.state = ATH_OFFCHANNEL_IDLE;
if (sc->ps_idle) if (sc->ps_idle)
ath_cancel_work(sc); ath_cancel_work(sc);
...@@ -2310,13 +2312,15 @@ void ath_offchannel_channel_change(struct ath_softc *sc) ...@@ -2310,13 +2312,15 @@ void ath_offchannel_channel_change(struct ath_softc *sc)
void ath_offchannel_timer(unsigned long data) void ath_offchannel_timer(unsigned long data)
{ {
struct ath_softc *sc = (struct ath_softc *)data; struct ath_softc *sc = (struct ath_softc *)data;
struct ath_chanctx *ctx = ath_chanctx_get_oper_chan(sc); struct ath_chanctx *ctx;
switch (sc->offchannel.state) { switch (sc->offchannel.state) {
case ATH_OFFCHANNEL_PROBE_WAIT: case ATH_OFFCHANNEL_PROBE_WAIT:
if (!sc->offchannel.scan_req) if (!sc->offchannel.scan_req)
return; return;
/* get first active channel context */
ctx = ath_chanctx_get_oper_chan(sc, true);
if (ctx->active) { if (ctx->active) {
sc->offchannel.state = ATH_OFFCHANNEL_SUSPEND; sc->offchannel.state = ATH_OFFCHANNEL_SUSPEND;
ath_chanctx_switch(sc, ctx, NULL); ath_chanctx_switch(sc, ctx, NULL);
...@@ -2332,6 +2336,7 @@ void ath_offchannel_timer(unsigned long data) ...@@ -2332,6 +2336,7 @@ void ath_offchannel_timer(unsigned long data)
break; break;
case ATH_OFFCHANNEL_ROC_START: case ATH_OFFCHANNEL_ROC_START:
case ATH_OFFCHANNEL_ROC_WAIT: case ATH_OFFCHANNEL_ROC_WAIT:
ctx = ath_chanctx_get_oper_chan(sc, false);
sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE; sc->offchannel.state = ATH_OFFCHANNEL_ROC_DONE;
ath_chanctx_switch(sc, ctx, NULL); ath_chanctx_switch(sc, ctx, NULL);
break; break;
...@@ -2432,26 +2437,22 @@ static int ath9k_add_chanctx(struct ieee80211_hw *hw, ...@@ -2432,26 +2437,22 @@ static int ath9k_add_chanctx(struct ieee80211_hw *hw,
{ {
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
struct ath_chanctx *ctx, **ptr; struct ath_chanctx *ctx, **ptr;
int i;
mutex_lock(&sc->mutex); mutex_lock(&sc->mutex);
for (i = 0; i < ATH9K_NUM_CHANCTX; i++) {
if (!sc->chanctx[i].assigned) ath_for_each_chanctx(sc, ctx) {
break; if (ctx->assigned)
} continue;
if (i == ATH9K_NUM_CHANCTX) {
ptr = (void *) conf->drv_priv;
*ptr = ctx;
ctx->assigned = true;
ath_chanctx_set_channel(sc, ctx, &conf->def);
mutex_unlock(&sc->mutex); mutex_unlock(&sc->mutex);
return -ENOSPC; return 0;
} }
ctx = &sc->chanctx[i];
ptr = (void *) conf->drv_priv;
*ptr = ctx;
ctx->assigned = true;
ath_chanctx_set_channel(sc, ctx, &conf->def);
mutex_unlock(&sc->mutex); mutex_unlock(&sc->mutex);
return -ENOSPC;
return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment