aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/ibss.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/ibss.c')
-rw-r--r--net/mac80211/ibss.c81
1 files changed, 79 insertions, 2 deletions
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 6da4e72f8178..8f8391e008ed 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -1270,7 +1270,7 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata)
1270 1270
1271 scan_width = cfg80211_chandef_to_scan_width(&ifibss->chandef); 1271 scan_width = cfg80211_chandef_to_scan_width(&ifibss->chandef);
1272 ieee80211_request_ibss_scan(sdata, ifibss->ssid, ifibss->ssid_len, 1272 ieee80211_request_ibss_scan(sdata, ifibss->ssid, ifibss->ssid_len,
1273 NULL, scan_width); 1273 NULL, 0, scan_width);
1274} 1274}
1275 1275
1276static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) 1276static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
@@ -1307,6 +1307,76 @@ static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
1307 capability, 0, true); 1307 capability, 0, true);
1308} 1308}
1309 1309
1310static unsigned ibss_setup_channels(struct wiphy *wiphy,
1311 struct ieee80211_channel **channels,
1312 unsigned int channels_max,
1313 u32 center_freq, u32 width)
1314{
1315 struct ieee80211_channel *chan = NULL;
1316 unsigned int n_chan = 0;
1317 u32 start_freq, end_freq, freq;
1318
1319 if (width <= 20) {
1320 start_freq = center_freq;
1321 end_freq = center_freq;
1322 } else {
1323 start_freq = center_freq - width / 2 + 10;
1324 end_freq = center_freq + width / 2 - 10;
1325 }
1326
1327 for (freq = start_freq; freq <= end_freq; freq += 20) {
1328 chan = ieee80211_get_channel(wiphy, freq);
1329 if (!chan)
1330 continue;
1331 if (n_chan >= channels_max)
1332 return n_chan;
1333
1334 channels[n_chan] = chan;
1335 n_chan++;
1336 }
1337
1338 return n_chan;
1339}
1340
1341static unsigned int
1342ieee80211_ibss_setup_scan_channels(struct wiphy *wiphy,
1343 const struct cfg80211_chan_def *chandef,
1344 struct ieee80211_channel **channels,
1345 unsigned int channels_max)
1346{
1347 unsigned int n_chan = 0;
1348 u32 width, cf1, cf2 = 0;
1349
1350 switch (chandef->width) {
1351 case NL80211_CHAN_WIDTH_40:
1352 width = 40;
1353 break;
1354 case NL80211_CHAN_WIDTH_80P80:
1355 cf2 = chandef->center_freq2;
1356 /* fall through */
1357 case NL80211_CHAN_WIDTH_80:
1358 width = 80;
1359 break;
1360 case NL80211_CHAN_WIDTH_160:
1361 width = 160;
1362 break;
1363 default:
1364 width = 20;
1365 break;
1366 }
1367
1368 cf1 = chandef->center_freq1;
1369
1370 n_chan = ibss_setup_channels(wiphy, channels, channels_max, cf1, width);
1371
1372 if (cf2)
1373 n_chan += ibss_setup_channels(wiphy, &channels[n_chan],
1374 channels_max - n_chan, cf2,
1375 width);
1376
1377 return n_chan;
1378}
1379
1310/* 1380/*
1311 * This function is called with state == IEEE80211_IBSS_MLME_SEARCH 1381 * This function is called with state == IEEE80211_IBSS_MLME_SEARCH
1312 */ 1382 */
@@ -1372,11 +1442,18 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
1372 /* Selected IBSS not found in current scan results - try to scan */ 1442 /* Selected IBSS not found in current scan results - try to scan */
1373 if (time_after(jiffies, ifibss->last_scan_completed + 1443 if (time_after(jiffies, ifibss->last_scan_completed +
1374 IEEE80211_SCAN_INTERVAL)) { 1444 IEEE80211_SCAN_INTERVAL)) {
1445 struct ieee80211_channel *channels[8];
1446 unsigned int num;
1447
1375 sdata_info(sdata, "Trigger new scan to find an IBSS to join\n"); 1448 sdata_info(sdata, "Trigger new scan to find an IBSS to join\n");
1376 1449
1450 num = ieee80211_ibss_setup_scan_channels(local->hw.wiphy,
1451 &ifibss->chandef,
1452 channels,
1453 ARRAY_SIZE(channels));
1377 scan_width = cfg80211_chandef_to_scan_width(&ifibss->chandef); 1454 scan_width = cfg80211_chandef_to_scan_width(&ifibss->chandef);
1378 ieee80211_request_ibss_scan(sdata, ifibss->ssid, 1455 ieee80211_request_ibss_scan(sdata, ifibss->ssid,
1379 ifibss->ssid_len, chan, 1456 ifibss->ssid_len, channels, num,
1380 scan_width); 1457 scan_width);
1381 } else { 1458 } else {
1382 int interval = IEEE80211_SCAN_INTERVAL; 1459 int interval = IEEE80211_SCAN_INTERVAL;