Skip to content

Commit

Permalink
mac80211: track reserved vifs in chanctx
Browse files Browse the repository at this point in the history
This can be useful. Provides a more straghtforward
way to iterate over interfaces taking part in
chanctx reservation and allows tracking chanctx
usage explicitly.

The structure is protected by local->chanctx_mtx.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Michal Kazior authored and Johannes Berg committed Apr 25, 2014
1 parent 484298a commit e3afb92
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
14 changes: 10 additions & 4 deletions net/mac80211/chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ ieee80211_new_chanctx(struct ieee80211_local *local,
return ERR_PTR(-ENOMEM);

INIT_LIST_HEAD(&ctx->assigned_vifs);
INIT_LIST_HEAD(&ctx->reserved_vifs);
ctx->conf.def = *chandef;
ctx->conf.rx_chains_static = 1;
ctx->conf.rx_chains_dynamic = 1;
Expand Down Expand Up @@ -731,16 +732,19 @@ void ieee80211_vif_copy_chanctx_to_vlans(struct ieee80211_sub_if_data *sdata,

int ieee80211_vif_unreserve_chanctx(struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_chanctx *ctx = sdata->reserved_chanctx;

lockdep_assert_held(&sdata->local->chanctx_mtx);

if (WARN_ON(!sdata->reserved_chanctx))
if (WARN_ON(!ctx))
return -EINVAL;

if (--sdata->reserved_chanctx->refcount == 0)
ieee80211_free_chanctx(sdata->local, sdata->reserved_chanctx);

list_del(&sdata->reserved_chanctx_list);
sdata->reserved_chanctx = NULL;

if (--ctx->refcount == 0)
ieee80211_free_chanctx(sdata->local, ctx);

return 0;
}

Expand Down Expand Up @@ -788,6 +792,7 @@ int ieee80211_vif_reserve_chanctx(struct ieee80211_sub_if_data *sdata,
}
}

list_add(&sdata->reserved_chanctx_list, &new_ctx->reserved_vifs);
new_ctx->refcount++;
sdata->reserved_chanctx = new_ctx;
sdata->reserved_chandef = *chandef;
Expand Down Expand Up @@ -837,6 +842,7 @@ int ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata,
ctx->refcount--;
sdata->reserved_chanctx = NULL;
sdata->radar_required = sdata->reserved_radar_required;
list_del(&sdata->reserved_chanctx_list);

if (old_ctx == ctx) {
/* This is our own context, just change it */
Expand Down
2 changes: 2 additions & 0 deletions net/mac80211/ieee80211_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ struct ieee80211_chanctx {
struct rcu_head rcu_head;

struct list_head assigned_vifs;
struct list_head reserved_vifs;

enum ieee80211_chanctx_mode mode;
int refcount;
Expand Down Expand Up @@ -759,6 +760,7 @@ struct ieee80211_sub_if_data {
struct cfg80211_chan_def csa_chandef;

struct list_head assigned_chanctx_list; /* protected by chanctx_mtx */
struct list_head reserved_chanctx_list; /* protected by chanctx_mtx */

/* context reservation -- protected with chanctx_mtx */
struct ieee80211_chanctx *reserved_chanctx;
Expand Down
1 change: 1 addition & 0 deletions net/mac80211/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,7 @@ static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
INIT_WORK(&sdata->recalc_smps, ieee80211_recalc_smps_work);
INIT_WORK(&sdata->csa_finalize_work, ieee80211_csa_finalize_work);
INIT_LIST_HEAD(&sdata->assigned_chanctx_list);
INIT_LIST_HEAD(&sdata->reserved_chanctx_list);

switch (type) {
case NL80211_IFTYPE_P2P_GO:
Expand Down

0 comments on commit e3afb92

Please sign in to comment.