Commit f4489ebeffa436c8427a20e2f05004e783708cde

Authored by Michal Kazior
Committed by Johannes Berg
1 parent ac800140c2

cfg80211: add channel tracking for AP and mesh

We need to know which channel is used by a running
AP and mesh for channel context accounting and
finding matching/active interface combination.

STA/IBSS have current_bss already which allows us
to check which channel a vif is tuned to.
Non-fixed channel IBSS can be handled with
additional changes.

Monitor mode is going to be handled differently.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Showing 5 changed files with 22 additions and 5 deletions Side-by-side Diff

include/net/cfg80211.h
... ... @@ -2408,6 +2408,9 @@
2408 2408 struct ieee80211_channel *preset_chan;
2409 2409 enum nl80211_channel_type preset_chantype;
2410 2410  
  2411 + /* for AP and mesh channel tracking */
  2412 + struct ieee80211_channel *channel;
  2413 +
2411 2414 bool ps;
2412 2415 int ps_timeout;
2413 2416  
... ... @@ -24,8 +24,10 @@
24 24 return -ENOENT;
25 25  
26 26 err = rdev->ops->stop_ap(&rdev->wiphy, dev);
27   - if (!err)
  27 + if (!err) {
28 28 wdev->beacon_interval = 0;
  29 + wdev->channel = NULL;
  30 + }
29 31  
30 32 return err;
31 33 }
... ... @@ -159,6 +159,7 @@
159 159 if (!err) {
160 160 memcpy(wdev->ssid, setup->mesh_id, setup->mesh_id_len);
161 161 wdev->mesh_id_len = setup->mesh_id_len;
  162 + wdev->channel = setup->channel;
162 163 }
163 164  
164 165 return err;
... ... @@ -184,6 +185,7 @@
184 185 enum nl80211_channel_type channel_type)
185 186 {
186 187 struct ieee80211_channel *channel;
  188 + int err;
187 189  
188 190 channel = rdev_freq_to_chan(rdev, freq, channel_type);
189 191 if (!channel || !cfg80211_can_beacon_sec_chan(&rdev->wiphy,
... ... @@ -205,9 +207,14 @@
205 207  
206 208 if (!netif_running(wdev->netdev))
207 209 return -ENETDOWN;
208   - return rdev->ops->libertas_set_mesh_channel(&rdev->wiphy,
209   - wdev->netdev,
210   - channel);
  210 +
  211 + err = rdev->ops->libertas_set_mesh_channel(&rdev->wiphy,
  212 + wdev->netdev,
  213 + channel);
  214 + if (!err)
  215 + wdev->channel = channel;
  216 +
  217 + return err;
211 218 }
212 219  
213 220 if (wdev->mesh_id_len)
214 221  
... ... @@ -249,8 +256,11 @@
249 256 return -ENOTCONN;
250 257  
251 258 err = rdev->ops->leave_mesh(&rdev->wiphy, dev);
252   - if (!err)
  259 + if (!err) {
253 260 wdev->mesh_id_len = 0;
  261 + wdev->channel = NULL;
  262 + }
  263 +
254 264 return err;
255 265 }
256 266  
... ... @@ -947,6 +947,7 @@
947 947 if (WARN_ON(!chan))
948 948 goto out;
949 949  
  950 + wdev->channel = chan;
950 951 nl80211_ch_switch_notify(rdev, dev, freq, type, GFP_KERNEL);
951 952 out:
952 953 wdev_unlock(wdev);
net/wireless/nl80211.c
... ... @@ -2488,6 +2488,7 @@
2488 2488 wdev->preset_chan = params.channel;
2489 2489 wdev->preset_chantype = params.channel_type;
2490 2490 wdev->beacon_interval = params.beacon_interval;
  2491 + wdev->channel = params.channel;
2491 2492 }
2492 2493 return err;
2493 2494 }