mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
wifi: mac80211: refactor ieee80211_nan_try_evacuate
Extract the logic that finds a NAN channel which makes a good evacuation candidate into a separate function. It will be used in a later patch. Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260527224745.589503562912.I9e266da48ceaf85bd0fe1b0487c3fdbeaaf9baaa@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
8facc23dc2
commit
a5b9ebd5c3
|
|
@ -1946,6 +1946,11 @@ ieee80211_vif_get_num_mcast_if(struct ieee80211_sub_if_data *sdata)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
|
||||
{
|
||||
return test_bit(SDATA_STATE_RUNNING, &sdata->state);
|
||||
}
|
||||
|
||||
int ieee80211_hw_config(struct ieee80211_local *local, int radio_idx,
|
||||
u32 changed);
|
||||
int ieee80211_hw_conf_chan(struct ieee80211_local *local);
|
||||
|
|
@ -2055,6 +2060,23 @@ int ieee80211_nan_set_peer_sched(struct ieee80211_sub_if_data *sdata,
|
|||
void ieee80211_nan_free_peer_sched(struct ieee80211_nan_peer_sched *sched);
|
||||
void ieee80211_nan_update_ndi_carrier(struct ieee80211_sub_if_data *ndi_sdata);
|
||||
|
||||
static inline struct ieee80211_sub_if_data *
|
||||
ieee80211_find_nan_sdata(struct ieee80211_local *local)
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
|
||||
lockdep_assert_wiphy(local->hw.wiphy);
|
||||
|
||||
/* Find the NAN interface - there can only be one */
|
||||
list_for_each_entry(sdata, &local->interfaces, list) {
|
||||
if (ieee80211_sdata_running(sdata) &&
|
||||
sdata->vif.type == NL80211_IFTYPE_NAN)
|
||||
return sdata;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* scan/BSS handling */
|
||||
void ieee80211_scan_work(struct wiphy *wiphy, struct wiphy_work *work);
|
||||
int ieee80211_request_ibss_scan(struct ieee80211_sub_if_data *sdata,
|
||||
|
|
@ -2155,11 +2177,6 @@ void ieee80211_recalc_txpower(struct ieee80211_link_data *link,
|
|||
bool update_bss);
|
||||
void ieee80211_recalc_offload(struct ieee80211_local *local);
|
||||
|
||||
static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
|
||||
{
|
||||
return test_bit(SDATA_STATE_RUNNING, &sdata->state);
|
||||
}
|
||||
|
||||
/* link handling */
|
||||
void ieee80211_link_setup(struct ieee80211_link_data *link);
|
||||
void ieee80211_link_init(struct ieee80211_sub_if_data *sdata,
|
||||
|
|
|
|||
|
|
@ -754,33 +754,20 @@ ieee80211_nan_evacuate_channel(struct ieee80211_sub_if_data *sdata,
|
|||
ieee80211_free_chanctx(sdata->local, ctx, false);
|
||||
}
|
||||
|
||||
bool ieee80211_nan_try_evacuate(struct ieee80211_hw *hw,
|
||||
struct ieee80211_chanctx_conf *conf)
|
||||
static struct ieee80211_nan_channel *
|
||||
ieee80211_nan_find_evac_chan(struct ieee80211_local *local,
|
||||
struct ieee80211_sub_if_data *sdata,
|
||||
struct ieee80211_chanctx *ctx)
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata = NULL, *tmp;
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
struct ieee80211_nan_channel *evac_chan = NULL;
|
||||
struct ieee80211_nan_sched_cfg *sched_cfg;
|
||||
struct ieee80211_chanctx *ctx = NULL;
|
||||
struct ieee80211_nan_channel *evac_chan = NULL;
|
||||
int min_slot_count = INT_MAX;
|
||||
int usable_channels = 0;
|
||||
|
||||
lockdep_assert_wiphy(local->hw.wiphy);
|
||||
|
||||
if (conf)
|
||||
ctx = container_of(conf, struct ieee80211_chanctx, conf);
|
||||
|
||||
/* Find the NAN interface - there can only be one */
|
||||
list_for_each_entry(tmp, &local->interfaces, list) {
|
||||
if (ieee80211_sdata_running(tmp) &&
|
||||
tmp->vif.type == NL80211_IFTYPE_NAN) {
|
||||
sdata = tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!sdata)
|
||||
return false;
|
||||
if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_NAN))
|
||||
return NULL;
|
||||
|
||||
sched_cfg = &sdata->vif.cfg.nan_sched;
|
||||
|
||||
|
|
@ -823,10 +810,34 @@ bool ieee80211_nan_try_evacuate(struct ieee80211_hw *hw,
|
|||
|
||||
/* No suitable NAN channel found */
|
||||
if (!evac_chan)
|
||||
return false;
|
||||
return NULL;
|
||||
|
||||
/* NAN needs at least one remaining usable channel after evacuation */
|
||||
if (usable_channels < 2)
|
||||
return NULL;
|
||||
|
||||
return evac_chan;
|
||||
}
|
||||
|
||||
bool ieee80211_nan_try_evacuate(struct ieee80211_hw *hw,
|
||||
struct ieee80211_chanctx_conf *conf)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
struct ieee80211_sub_if_data *sdata =
|
||||
ieee80211_find_nan_sdata(local);
|
||||
struct ieee80211_nan_channel *evac_chan;
|
||||
struct ieee80211_chanctx *ctx = NULL;
|
||||
|
||||
lockdep_assert_wiphy(local->hw.wiphy);
|
||||
|
||||
if (!sdata)
|
||||
return false;
|
||||
|
||||
if (conf)
|
||||
ctx = container_of(conf, struct ieee80211_chanctx, conf);
|
||||
|
||||
evac_chan = ieee80211_nan_find_evac_chan(local, sdata, ctx);
|
||||
if (!evac_chan)
|
||||
return false;
|
||||
|
||||
ieee80211_nan_evacuate_channel(sdata, evac_chan);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user