Skip to content

Commit 31559f3

Browse files
dziedjanjmberg-intel
authored andcommitted
cfg80211: DFS get CAC time from regulatory database
Send Channel Availability Check time as a parameter of start_radar_detection() callback. Get CAC time from regulatory database. Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 089027e commit 31559f3

6 files changed

Lines changed: 76 additions & 7 deletions

File tree

‎include/net/cfg80211.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,8 @@ struct cfg80211_ops {
25052505

25062506
int (*start_radar_detection)(struct wiphy *wiphy,
25072507
struct net_device *dev,
2508-
struct cfg80211_chan_def *chandef);
2508+
struct cfg80211_chan_def *chandef,
2509+
u32 cac_time_ms);
25092510
int (*update_ft_ies)(struct wiphy *wiphy, struct net_device *dev,
25102511
struct cfg80211_update_ft_ies_params *ftie);
25112512
int (*crit_proto_start)(struct wiphy *wiphy,
@@ -3182,6 +3183,7 @@ struct cfg80211_cached_keys;
31823183
* @p2p_started: true if this is a P2P Device that has been started
31833184
* @cac_started: true if DFS channel availability check has been started
31843185
* @cac_start_time: timestamp (jiffies) when the dfs state was entered.
3186+
* @cac_time_ms: CAC time in ms
31853187
* @ps: powersave mode is enabled
31863188
* @ps_timeout: dynamic powersave timeout
31873189
* @ap_unexpected_nlportid: (private) netlink port ID of application
@@ -3237,6 +3239,7 @@ struct wireless_dev {
32373239

32383240
bool cac_started;
32393241
unsigned long cac_start_time;
3242+
unsigned int cac_time_ms;
32403243

32413244
#ifdef CONFIG_CFG80211_WEXT
32423245
/* wext data */

‎net/mac80211/cfg.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,11 +2914,11 @@ static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
29142914

29152915
static int ieee80211_start_radar_detection(struct wiphy *wiphy,
29162916
struct net_device *dev,
2917-
struct cfg80211_chan_def *chandef)
2917+
struct cfg80211_chan_def *chandef,
2918+
u32 cac_time_ms)
29182919
{
29192920
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
29202921
struct ieee80211_local *local = sdata->local;
2921-
unsigned long timeout;
29222922
int err;
29232923

29242924
mutex_lock(&local->mtx);
@@ -2937,9 +2937,9 @@ static int ieee80211_start_radar_detection(struct wiphy *wiphy,
29372937
if (err)
29382938
goto out_unlock;
29392939

2940-
timeout = msecs_to_jiffies(IEEE80211_DFS_MIN_CAC_TIME_MS);
29412940
ieee80211_queue_delayed_work(&sdata->local->hw,
2942-
&sdata->dfs_cac_timer_work, timeout);
2941+
&sdata->dfs_cac_timer_work,
2942+
msecs_to_jiffies(cac_time_ms));
29432943

29442944
out_unlock:
29452945
mutex_unlock(&local->mtx);

‎net/wireless/chan.c‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,62 @@ static bool cfg80211_chandef_dfs_available(struct wiphy *wiphy,
490490
return r;
491491
}
492492

493+
static unsigned int cfg80211_get_chans_dfs_cac_time(struct wiphy *wiphy,
494+
u32 center_freq,
495+
u32 bandwidth)
496+
{
497+
struct ieee80211_channel *c;
498+
u32 start_freq, end_freq, freq;
499+
unsigned int dfs_cac_ms = 0;
500+
501+
start_freq = cfg80211_get_start_freq(center_freq, bandwidth);
502+
end_freq = cfg80211_get_end_freq(center_freq, bandwidth);
503+
504+
for (freq = start_freq; freq <= end_freq; freq += 20) {
505+
c = ieee80211_get_channel(wiphy, freq);
506+
if (!c)
507+
return 0;
508+
509+
if (c->flags & IEEE80211_CHAN_DISABLED)
510+
return 0;
511+
512+
if (!(c->flags & IEEE80211_CHAN_RADAR))
513+
continue;
514+
515+
if (c->dfs_cac_ms > dfs_cac_ms)
516+
dfs_cac_ms = c->dfs_cac_ms;
517+
}
518+
519+
return dfs_cac_ms;
520+
}
521+
522+
unsigned int
523+
cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy,
524+
const struct cfg80211_chan_def *chandef)
525+
{
526+
int width;
527+
unsigned int t1 = 0, t2 = 0;
528+
529+
if (WARN_ON(!cfg80211_chandef_valid(chandef)))
530+
return 0;
531+
532+
width = cfg80211_chandef_get_width(chandef);
533+
if (width < 0)
534+
return 0;
535+
536+
t1 = cfg80211_get_chans_dfs_cac_time(wiphy,
537+
chandef->center_freq1,
538+
width);
539+
540+
if (!chandef->center_freq2)
541+
return t1;
542+
543+
t2 = cfg80211_get_chans_dfs_cac_time(wiphy,
544+
chandef->center_freq2,
545+
width);
546+
547+
return max(t1, t2);
548+
}
493549

494550
static bool cfg80211_secondary_chans_ok(struct wiphy *wiphy,
495551
u32 center_freq, u32 bandwidth,

‎net/wireless/core.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ void cfg80211_set_dfs_state(struct wiphy *wiphy,
402402

403403
void cfg80211_dfs_channels_update_work(struct work_struct *work);
404404

405+
unsigned int
406+
cfg80211_chandef_dfs_cac_time(struct wiphy *wiphy,
407+
const struct cfg80211_chan_def *chandef);
405408

406409
static inline int
407410
cfg80211_can_change_interface(struct cfg80211_registered_device *rdev,

‎net/wireless/mlme.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ void cfg80211_cac_event(struct net_device *netdev,
778778
switch (event) {
779779
case NL80211_RADAR_CAC_FINISHED:
780780
timeout = wdev->cac_start_time +
781-
msecs_to_jiffies(IEEE80211_DFS_MIN_CAC_TIME_MS);
781+
msecs_to_jiffies(wdev->cac_time_ms);
782782
WARN_ON(!time_after_eq(jiffies, timeout));
783783
cfg80211_set_dfs_state(wiphy, chandef, NL80211_DFS_AVAILABLE);
784784
break;

‎net/wireless/nl80211.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5779,6 +5779,7 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
57795779
struct wireless_dev *wdev = dev->ieee80211_ptr;
57805780
struct cfg80211_chan_def chandef;
57815781
enum nl80211_dfs_regions dfs_region;
5782+
unsigned int cac_time_ms;
57825783
int err;
57835784

57845785
dfs_region = reg_get_dfs_region(wdev->wiphy);
@@ -5814,11 +5815,17 @@ static int nl80211_start_radar_detection(struct sk_buff *skb,
58145815
if (err)
58155816
return err;
58165817

5817-
err = rdev->ops->start_radar_detection(&rdev->wiphy, dev, &chandef);
5818+
cac_time_ms = cfg80211_chandef_dfs_cac_time(&rdev->wiphy, &chandef);
5819+
if (WARN_ON(!cac_time_ms))
5820+
cac_time_ms = IEEE80211_DFS_MIN_CAC_TIME_MS;
5821+
5822+
err = rdev->ops->start_radar_detection(&rdev->wiphy, dev, &chandef,
5823+
cac_time_ms);
58185824
if (!err) {
58195825
wdev->chandef = chandef;
58205826
wdev->cac_started = true;
58215827
wdev->cac_start_time = jiffies;
5828+
wdev->cac_time_ms = cac_time_ms;
58225829
}
58235830
return err;
58245831
}

0 commit comments

Comments
 (0)