util.c (841577c3d33b8a2bff66d1b506d8198b25900bde) | util.c (e3685e03b40f5ec7926d9a75bf63467fc4071df9) |
---|---|
1/* 2 * Copyright 2002-2005, Instant802 Networks, Inc. 3 * Copyright 2005-2006, Devicescape Software, Inc. 4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 5 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 20 unchanged lines hidden (view full) --- 29#include "driver-ops.h" 30#include "rate.h" 31#include "mesh.h" 32#include "wme.h" 33#include "led.h" 34#include "wep.h" 35 36/* privid for wiphys to determine whether they belong to us or not */ | 1/* 2 * Copyright 2002-2005, Instant802 Networks, Inc. 3 * Copyright 2005-2006, Devicescape Software, Inc. 4 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 5 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as --- 20 unchanged lines hidden (view full) --- 29#include "driver-ops.h" 30#include "rate.h" 31#include "mesh.h" 32#include "wme.h" 33#include "led.h" 34#include "wep.h" 35 36/* privid for wiphys to determine whether they belong to us or not */ |
37const void *const mac80211_wiphy_privid = &mac80211_wiphy_privid; | 37void *mac80211_wiphy_privid = &mac80211_wiphy_privid; |
38 39struct ieee80211_hw *wiphy_to_ieee80211_hw(struct wiphy *wiphy) 40{ 41 struct ieee80211_local *local; 42 BUG_ON(!wiphy); 43 44 local = wiphy_priv(wiphy); 45 return &local->hw; --- 384 unchanged lines hidden (view full) --- 430 431 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 432 __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 433 __skb_queue_tail(&local->pending[queue], skb); 434 __ieee80211_wake_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 435 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 436} 437 | 38 39struct ieee80211_hw *wiphy_to_ieee80211_hw(struct wiphy *wiphy) 40{ 41 struct ieee80211_local *local; 42 BUG_ON(!wiphy); 43 44 local = wiphy_priv(wiphy); 45 return &local->hw; --- 384 unchanged lines hidden (view full) --- 430 431 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 432 __ieee80211_stop_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 433 __skb_queue_tail(&local->pending[queue], skb); 434 __ieee80211_wake_queue(hw, queue, IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 435 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 436} 437 |
438void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local, 439 struct sk_buff_head *skbs, 440 void (*fn)(void *data), void *data) | 438void ieee80211_add_pending_skbs(struct ieee80211_local *local, 439 struct sk_buff_head *skbs) |
441{ 442 struct ieee80211_hw *hw = &local->hw; 443 struct sk_buff *skb; 444 unsigned long flags; 445 int queue, i; 446 447 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 448 while ((skb = skb_dequeue(skbs))) { --- 7 unchanged lines hidden (view full) --- 456 queue = info->hw_queue; 457 458 __ieee80211_stop_queue(hw, queue, 459 IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 460 461 __skb_queue_tail(&local->pending[queue], skb); 462 } 463 | 440{ 441 struct ieee80211_hw *hw = &local->hw; 442 struct sk_buff *skb; 443 unsigned long flags; 444 int queue, i; 445 446 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 447 while ((skb = skb_dequeue(skbs))) { --- 7 unchanged lines hidden (view full) --- 455 queue = info->hw_queue; 456 457 __ieee80211_stop_queue(hw, queue, 458 IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 459 460 __skb_queue_tail(&local->pending[queue], skb); 461 } 462 |
464 if (fn) 465 fn(data); 466 | |
467 for (i = 0; i < hw->queues; i++) 468 __ieee80211_wake_queue(hw, i, 469 IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 470 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 471} 472 473void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw, 474 unsigned long queues, --- 801 unchanged lines hidden (view full) --- 1276 sband->ht_cap.cap); 1277 } 1278 1279 /* 1280 * If adding more here, adjust code in main.c 1281 * that calculates local->scan_ies_len. 1282 */ 1283 | 463 for (i = 0; i < hw->queues; i++) 464 __ieee80211_wake_queue(hw, i, 465 IEEE80211_QUEUE_STOP_REASON_SKB_ADD); 466 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 467} 468 469void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw, 470 unsigned long queues, --- 801 unchanged lines hidden (view full) --- 1272 sband->ht_cap.cap); 1273 } 1274 1275 /* 1276 * If adding more here, adjust code in main.c 1277 * that calculates local->scan_ies_len. 1278 */ 1279 |
1284 /* insert custom IEs that go before VHT */ | 1280 /* add any remaining custom IEs */ |
1285 if (ie && ie_len) { | 1281 if (ie && ie_len) { |
1286 static const u8 before_vht[] = { 1287 WLAN_EID_SSID, 1288 WLAN_EID_SUPP_RATES, 1289 WLAN_EID_REQUEST, 1290 WLAN_EID_EXT_SUPP_RATES, 1291 WLAN_EID_DS_PARAMS, 1292 WLAN_EID_SUPPORTED_REGULATORY_CLASSES, 1293 WLAN_EID_HT_CAPABILITY, 1294 WLAN_EID_BSS_COEX_2040, 1295 WLAN_EID_EXT_CAPABILITY, 1296 WLAN_EID_SSID_LIST, 1297 WLAN_EID_CHANNEL_USAGE, 1298 WLAN_EID_INTERWORKING, 1299 /* mesh ID can't happen here */ 1300 /* 60 GHz can't happen here right now */ 1301 }; 1302 noffset = ieee80211_ie_split(ie, ie_len, 1303 before_vht, ARRAY_SIZE(before_vht), 1304 offset); | 1282 noffset = ie_len; |
1305 if (end - pos < noffset - offset) 1306 goto out_err; 1307 memcpy(pos, ie + offset, noffset - offset); 1308 pos += noffset - offset; | 1283 if (end - pos < noffset - offset) 1284 goto out_err; 1285 memcpy(pos, ie + offset, noffset - offset); 1286 pos += noffset - offset; |
1309 offset = noffset; | |
1310 } 1311 1312 if (sband->vht_cap.vht_supported) { 1313 if (end - pos < 2 + sizeof(struct ieee80211_vht_cap)) 1314 goto out_err; 1315 pos = ieee80211_ie_build_vht_cap(pos, &sband->vht_cap, 1316 sband->vht_cap.cap); 1317 } 1318 | 1287 } 1288 1289 if (sband->vht_cap.vht_supported) { 1290 if (end - pos < 2 + sizeof(struct ieee80211_vht_cap)) 1291 goto out_err; 1292 pos = ieee80211_ie_build_vht_cap(pos, &sband->vht_cap, 1293 sband->vht_cap.cap); 1294 } 1295 |
1319 /* add any remaining custom IEs */ 1320 if (ie && ie_len) { 1321 noffset = ie_len; 1322 if (end - pos < noffset - offset) 1323 goto out_err; 1324 memcpy(pos, ie + offset, noffset - offset); 1325 pos += noffset - offset; 1326 } 1327 | |
1328 return pos - buffer; 1329 out_err: 1330 WARN_ONCE(1, "not enough space for preq IEs\n"); 1331 return pos - buffer; 1332} 1333 1334struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, 1335 u8 *dst, u32 ratemask, --- 61 unchanged lines hidden (view full) --- 1397 } 1398} 1399 1400u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata, 1401 struct ieee802_11_elems *elems, 1402 enum ieee80211_band band, u32 *basic_rates) 1403{ 1404 struct ieee80211_supported_band *sband; | 1296 return pos - buffer; 1297 out_err: 1298 WARN_ONCE(1, "not enough space for preq IEs\n"); 1299 return pos - buffer; 1300} 1301 1302struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata, 1303 u8 *dst, u32 ratemask, --- 61 unchanged lines hidden (view full) --- 1365 } 1366} 1367 1368u32 ieee80211_sta_get_rates(struct ieee80211_sub_if_data *sdata, 1369 struct ieee802_11_elems *elems, 1370 enum ieee80211_band band, u32 *basic_rates) 1371{ 1372 struct ieee80211_supported_band *sband; |
1373 struct ieee80211_rate *bitrates; |
|
1405 size_t num_rates; 1406 u32 supp_rates, rate_flags; 1407 int i, j, shift; 1408 sband = sdata->local->hw.wiphy->bands[band]; 1409 1410 rate_flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef); 1411 shift = ieee80211_vif_get_shift(&sdata->vif); 1412 1413 if (WARN_ON(!sband)) 1414 return 1; 1415 | 1374 size_t num_rates; 1375 u32 supp_rates, rate_flags; 1376 int i, j, shift; 1377 sband = sdata->local->hw.wiphy->bands[band]; 1378 1379 rate_flags = ieee80211_chandef_rate_flags(&sdata->vif.bss_conf.chandef); 1380 shift = ieee80211_vif_get_shift(&sdata->vif); 1381 1382 if (WARN_ON(!sband)) 1383 return 1; 1384 |
1385 bitrates = sband->bitrates; |
|
1416 num_rates = sband->n_bitrates; 1417 supp_rates = 0; 1418 for (i = 0; i < elems->supp_rates_len + 1419 elems->ext_supp_rates_len; i++) { 1420 u8 rate = 0; 1421 int own_rate; 1422 bool is_basic; 1423 if (i < elems->supp_rates_len) --- 338 unchanged lines hidden (view full) --- 1762 1763 mutex_unlock(&local->sta_mtx); 1764 } 1765 1766 ieee80211_wake_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP, 1767 IEEE80211_QUEUE_STOP_REASON_SUSPEND); 1768 1769 /* | 1386 num_rates = sband->n_bitrates; 1387 supp_rates = 0; 1388 for (i = 0; i < elems->supp_rates_len + 1389 elems->ext_supp_rates_len; i++) { 1390 u8 rate = 0; 1391 int own_rate; 1392 bool is_basic; 1393 if (i < elems->supp_rates_len) --- 338 unchanged lines hidden (view full) --- 1732 1733 mutex_unlock(&local->sta_mtx); 1734 } 1735 1736 ieee80211_wake_queues_by_reason(hw, IEEE80211_MAX_QUEUE_MAP, 1737 IEEE80211_QUEUE_STOP_REASON_SUSPEND); 1738 1739 /* |
1740 * Reconfigure sched scan if it was interrupted by FW restart or 1741 * suspend. 1742 */ 1743 mutex_lock(&local->mtx); 1744 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata, 1745 lockdep_is_held(&local->mtx)); 1746 if (sched_scan_sdata && local->sched_scan_req) 1747 /* 1748 * Sched scan stopped, but we don't want to report it. Instead, 1749 * we're trying to reschedule. 1750 */ 1751 if (__ieee80211_request_sched_scan_start(sched_scan_sdata, 1752 local->sched_scan_req)) 1753 sched_scan_stopped = true; 1754 mutex_unlock(&local->mtx); 1755 1756 if (sched_scan_stopped) 1757 cfg80211_sched_scan_stopped(local->hw.wiphy); 1758 1759 /* |
|
1770 * If this is for hw restart things are still running. 1771 * We may want to change that later, however. 1772 */ 1773 if (!local->suspended || reconfig_due_to_wowlan) 1774 drv_restart_complete(local); 1775 1776 if (!local->suspended) 1777 return 0; --- 11 unchanged lines hidden (view full) --- 1789 ieee80211_sta_restart(sdata); 1790 } 1791 1792 mod_timer(&local->sta_cleanup, jiffies + 1); 1793#else 1794 WARN_ON(1); 1795#endif 1796 | 1760 * If this is for hw restart things are still running. 1761 * We may want to change that later, however. 1762 */ 1763 if (!local->suspended || reconfig_due_to_wowlan) 1764 drv_restart_complete(local); 1765 1766 if (!local->suspended) 1767 return 0; --- 11 unchanged lines hidden (view full) --- 1779 ieee80211_sta_restart(sdata); 1780 } 1781 1782 mod_timer(&local->sta_cleanup, jiffies + 1); 1783#else 1784 WARN_ON(1); 1785#endif 1786 |
1797 /* 1798 * Reconfigure sched scan if it was interrupted by FW restart or 1799 * suspend. 1800 */ 1801 mutex_lock(&local->mtx); 1802 sched_scan_sdata = rcu_dereference_protected(local->sched_scan_sdata, 1803 lockdep_is_held(&local->mtx)); 1804 if (sched_scan_sdata && local->sched_scan_req) 1805 /* 1806 * Sched scan stopped, but we don't want to report it. Instead, 1807 * we're trying to reschedule. 1808 */ 1809 if (__ieee80211_request_sched_scan_start(sched_scan_sdata, 1810 local->sched_scan_req)) 1811 sched_scan_stopped = true; 1812 mutex_unlock(&local->mtx); 1813 1814 if (sched_scan_stopped) 1815 cfg80211_sched_scan_stopped(local->hw.wiphy); 1816 | |
1817 return 0; 1818} 1819 1820void ieee80211_resume_disconnect(struct ieee80211_vif *vif) 1821{ 1822 struct ieee80211_sub_if_data *sdata; 1823 struct ieee80211_local *local; 1824 struct ieee80211_key *key; --- 468 unchanged lines hidden (view full) --- 2293 if (status->flag & RX_FLAG_SHORT_GI) 2294 ri.flags |= RATE_INFO_FLAGS_SHORT_GI; 2295 } else if (status->flag & RX_FLAG_VHT) { 2296 ri.flags |= RATE_INFO_FLAGS_VHT_MCS; 2297 ri.mcs = status->rate_idx; 2298 ri.nss = status->vht_nss; 2299 if (status->flag & RX_FLAG_40MHZ) 2300 ri.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; | 1787 return 0; 1788} 1789 1790void ieee80211_resume_disconnect(struct ieee80211_vif *vif) 1791{ 1792 struct ieee80211_sub_if_data *sdata; 1793 struct ieee80211_local *local; 1794 struct ieee80211_key *key; --- 468 unchanged lines hidden (view full) --- 2263 if (status->flag & RX_FLAG_SHORT_GI) 2264 ri.flags |= RATE_INFO_FLAGS_SHORT_GI; 2265 } else if (status->flag & RX_FLAG_VHT) { 2266 ri.flags |= RATE_INFO_FLAGS_VHT_MCS; 2267 ri.mcs = status->rate_idx; 2268 ri.nss = status->vht_nss; 2269 if (status->flag & RX_FLAG_40MHZ) 2270 ri.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; |
2301 if (status->vht_flag & RX_VHT_FLAG_80MHZ) | 2271 if (status->flag & RX_FLAG_80MHZ) |
2302 ri.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; | 2272 ri.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH; |
2303 if (status->vht_flag & RX_VHT_FLAG_80P80MHZ) | 2273 if (status->flag & RX_FLAG_80P80MHZ) |
2304 ri.flags |= RATE_INFO_FLAGS_80P80_MHZ_WIDTH; | 2274 ri.flags |= RATE_INFO_FLAGS_80P80_MHZ_WIDTH; |
2305 if (status->vht_flag & RX_VHT_FLAG_160MHZ) | 2275 if (status->flag & RX_FLAG_160MHZ) |
2306 ri.flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH; 2307 if (status->flag & RX_FLAG_SHORT_GI) 2308 ri.flags |= RATE_INFO_FLAGS_SHORT_GI; 2309 } else { 2310 struct ieee80211_supported_band *sband; 2311 int shift = 0; 2312 int bitrate; 2313 --- 490 unchanged lines hidden --- | 2276 ri.flags |= RATE_INFO_FLAGS_160_MHZ_WIDTH; 2277 if (status->flag & RX_FLAG_SHORT_GI) 2278 ri.flags |= RATE_INFO_FLAGS_SHORT_GI; 2279 } else { 2280 struct ieee80211_supported_band *sband; 2281 int shift = 0; 2282 int bitrate; 2283 --- 490 unchanged lines hidden --- |