aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/cfg.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r--net/mac80211/cfg.c118
1 files changed, 105 insertions, 13 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 9cd73b11506e..44049733c4ea 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -316,6 +316,17 @@ static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
316 return 0; 316 return 0;
317} 317}
318 318
319static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx)
320{
321 if (!(rate->flags & RATE_INFO_FLAGS_MCS)) {
322 struct ieee80211_supported_band *sband;
323 sband = sta->local->hw.wiphy->bands[
324 sta->local->hw.conf.channel->band];
325 rate->legacy = sband->bitrates[idx].bitrate;
326 } else
327 rate->mcs = idx;
328}
329
319static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) 330static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
320{ 331{
321 struct ieee80211_sub_if_data *sdata = sta->sdata; 332 struct ieee80211_sub_if_data *sdata = sta->sdata;
@@ -330,6 +341,7 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
330 STATION_INFO_TX_RETRIES | 341 STATION_INFO_TX_RETRIES |
331 STATION_INFO_TX_FAILED | 342 STATION_INFO_TX_FAILED |
332 STATION_INFO_TX_BITRATE | 343 STATION_INFO_TX_BITRATE |
344 STATION_INFO_RX_BITRATE |
333 STATION_INFO_RX_DROP_MISC; 345 STATION_INFO_RX_DROP_MISC;
334 346
335 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); 347 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
@@ -355,15 +367,16 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
355 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH; 367 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
356 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI) 368 if (sta->last_tx_rate.flags & IEEE80211_TX_RC_SHORT_GI)
357 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI; 369 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
370 rate_idx_to_bitrate(&sinfo->txrate, sta, sta->last_tx_rate.idx);
358 371
359 if (!(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)) { 372 sinfo->rxrate.flags = 0;
360 struct ieee80211_supported_band *sband; 373 if (sta->last_rx_rate_flag & RX_FLAG_HT)
361 sband = sta->local->hw.wiphy->bands[ 374 sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS;
362 sta->local->hw.conf.channel->band]; 375 if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
363 sinfo->txrate.legacy = 376 sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
364 sband->bitrates[sta->last_tx_rate.idx].bitrate; 377 if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
365 } else 378 sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
366 sinfo->txrate.mcs = sta->last_tx_rate.idx; 379 rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx);
367 380
368 if (ieee80211_vif_is_mesh(&sdata->vif)) { 381 if (ieee80211_vif_is_mesh(&sdata->vif)) {
369#ifdef CONFIG_MAC80211_MESH 382#ifdef CONFIG_MAC80211_MESH
@@ -821,6 +834,10 @@ static int ieee80211_change_station(struct wiphy *wiphy,
821 834
822 rcu_read_unlock(); 835 rcu_read_unlock();
823 836
837 if (sdata->vif.type == NL80211_IFTYPE_STATION &&
838 params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))
839 ieee80211_recalc_ps(local, -1);
840
824 return 0; 841 return 0;
825} 842}
826 843
@@ -1215,6 +1232,9 @@ static int ieee80211_set_channel(struct wiphy *wiphy,
1215{ 1232{
1216 struct ieee80211_local *local = wiphy_priv(wiphy); 1233 struct ieee80211_local *local = wiphy_priv(wiphy);
1217 struct ieee80211_sub_if_data *sdata = NULL; 1234 struct ieee80211_sub_if_data *sdata = NULL;
1235 struct ieee80211_channel *old_oper;
1236 enum nl80211_channel_type old_oper_type;
1237 enum nl80211_channel_type old_vif_oper_type= NL80211_CHAN_NO_HT;
1218 1238
1219 if (netdev) 1239 if (netdev)
1220 sdata = IEEE80211_DEV_TO_SUB_IF(netdev); 1240 sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
@@ -1232,13 +1252,23 @@ static int ieee80211_set_channel(struct wiphy *wiphy,
1232 break; 1252 break;
1233 } 1253 }
1234 1254
1235 local->oper_channel = chan; 1255 if (sdata)
1256 old_vif_oper_type = sdata->vif.bss_conf.channel_type;
1257 old_oper_type = local->_oper_channel_type;
1236 1258
1237 if (!ieee80211_set_channel_type(local, sdata, channel_type)) 1259 if (!ieee80211_set_channel_type(local, sdata, channel_type))
1238 return -EBUSY; 1260 return -EBUSY;
1239 1261
1240 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); 1262 old_oper = local->oper_channel;
1241 if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) 1263 local->oper_channel = chan;
1264
1265 /* Update driver if changes were actually made. */
1266 if ((old_oper != local->oper_channel) ||
1267 (old_oper_type != local->_oper_channel_type))
1268 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
1269
1270 if ((sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR) &&
1271 old_vif_oper_type != sdata->vif.bss_conf.channel_type)
1242 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT); 1272 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
1243 1273
1244 return 0; 1274 return 0;
@@ -1274,8 +1304,11 @@ static int ieee80211_scan(struct wiphy *wiphy,
1274 case NL80211_IFTYPE_P2P_GO: 1304 case NL80211_IFTYPE_P2P_GO:
1275 if (sdata->local->ops->hw_scan) 1305 if (sdata->local->ops->hw_scan)
1276 break; 1306 break;
1277 /* FIXME: implement NoA while scanning in software */ 1307 /*
1278 return -EOPNOTSUPP; 1308 * FIXME: implement NoA while scanning in software,
1309 * for now fall through to allow scanning only when
1310 * beaconing hasn't been configured yet
1311 */
1279 case NL80211_IFTYPE_AP: 1312 case NL80211_IFTYPE_AP:
1280 if (sdata->u.ap.beacon) 1313 if (sdata->u.ap.beacon)
1281 return -EOPNOTSUPP; 1314 return -EOPNOTSUPP;
@@ -1471,6 +1504,8 @@ int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
1471 enum ieee80211_smps_mode old_req; 1504 enum ieee80211_smps_mode old_req;
1472 int err; 1505 int err;
1473 1506
1507 lockdep_assert_held(&sdata->u.mgd.mtx);
1508
1474 old_req = sdata->u.mgd.req_smps; 1509 old_req = sdata->u.mgd.req_smps;
1475 sdata->u.mgd.req_smps = smps_mode; 1510 sdata->u.mgd.req_smps = smps_mode;
1476 1511
@@ -1784,6 +1819,33 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
1784 1819
1785 *cookie = (unsigned long) skb; 1820 *cookie = (unsigned long) skb;
1786 1821
1822 if (is_offchan && local->ops->offchannel_tx) {
1823 int ret;
1824
1825 IEEE80211_SKB_CB(skb)->band = chan->band;
1826
1827 mutex_lock(&local->mtx);
1828
1829 if (local->hw_offchan_tx_cookie) {
1830 mutex_unlock(&local->mtx);
1831 return -EBUSY;
1832 }
1833
1834 /* TODO: bitrate control, TX processing? */
1835 ret = drv_offchannel_tx(local, skb, chan, channel_type, wait);
1836
1837 if (ret == 0)
1838 local->hw_offchan_tx_cookie = *cookie;
1839 mutex_unlock(&local->mtx);
1840
1841 /*
1842 * Allow driver to return 1 to indicate it wants to have the
1843 * frame transmitted with a remain_on_channel + regular TX.
1844 */
1845 if (ret != 1)
1846 return ret;
1847 }
1848
1787 if (is_offchan && local->ops->remain_on_channel) { 1849 if (is_offchan && local->ops->remain_on_channel) {
1788 unsigned int duration; 1850 unsigned int duration;
1789 int ret; 1851 int ret;
@@ -1847,6 +1909,7 @@ static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
1847 1909
1848 wk->type = IEEE80211_WORK_OFFCHANNEL_TX; 1910 wk->type = IEEE80211_WORK_OFFCHANNEL_TX;
1849 wk->chan = chan; 1911 wk->chan = chan;
1912 wk->chan_type = channel_type;
1850 wk->sdata = sdata; 1913 wk->sdata = sdata;
1851 wk->done = ieee80211_offchan_tx_done; 1914 wk->done = ieee80211_offchan_tx_done;
1852 wk->offchan_tx.frame = skb; 1915 wk->offchan_tx.frame = skb;
@@ -1869,6 +1932,18 @@ static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
1869 1932
1870 mutex_lock(&local->mtx); 1933 mutex_lock(&local->mtx);
1871 1934
1935 if (local->ops->offchannel_tx_cancel_wait &&
1936 local->hw_offchan_tx_cookie == cookie) {
1937 ret = drv_offchannel_tx_cancel_wait(local);
1938
1939 if (!ret)
1940 local->hw_offchan_tx_cookie = 0;
1941
1942 mutex_unlock(&local->mtx);
1943
1944 return ret;
1945 }
1946
1872 if (local->ops->cancel_remain_on_channel) { 1947 if (local->ops->cancel_remain_on_channel) {
1873 cookie ^= 2; 1948 cookie ^= 2;
1874 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie); 1949 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
@@ -1939,6 +2014,21 @@ static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
1939 return drv_get_antenna(local, tx_ant, rx_ant); 2014 return drv_get_antenna(local, tx_ant, rx_ant);
1940} 2015}
1941 2016
2017static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
2018{
2019 struct ieee80211_local *local = wiphy_priv(wiphy);
2020
2021 return drv_set_ringparam(local, tx, rx);
2022}
2023
2024static void ieee80211_get_ringparam(struct wiphy *wiphy,
2025 u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
2026{
2027 struct ieee80211_local *local = wiphy_priv(wiphy);
2028
2029 drv_get_ringparam(local, tx, tx_max, rx, rx_max);
2030}
2031
1942struct cfg80211_ops mac80211_config_ops = { 2032struct cfg80211_ops mac80211_config_ops = {
1943 .add_virtual_intf = ieee80211_add_iface, 2033 .add_virtual_intf = ieee80211_add_iface,
1944 .del_virtual_intf = ieee80211_del_iface, 2034 .del_virtual_intf = ieee80211_del_iface,
@@ -1996,4 +2086,6 @@ struct cfg80211_ops mac80211_config_ops = {
1996 .mgmt_frame_register = ieee80211_mgmt_frame_register, 2086 .mgmt_frame_register = ieee80211_mgmt_frame_register,
1997 .set_antenna = ieee80211_set_antenna, 2087 .set_antenna = ieee80211_set_antenna,
1998 .get_antenna = ieee80211_get_antenna, 2088 .get_antenna = ieee80211_get_antenna,
2089 .set_ringparam = ieee80211_set_ringparam,
2090 .get_ringparam = ieee80211_get_ringparam,
1999}; 2091};