提交 0fabfaaf 编写于 作者: A Arik Nemtsov 提交者: Johannes Berg

mac80211: upgrade BW of TDLS peers when possible

Define a station chandef, to be used for wider-bw TDLS peers. When both
peers support the feature, upgrade the channel bandwidth to the maximum
allowed by both peers and regulatory. Currently widths up to 80MHz are
supported in the 5GHz band.

When a TDLS peer connects/disconnects recalculate the channel type of the
current chanctx.
Make the chanctx width calculation consider wider-bw TDLS peers and
similarly fix the max_required_bw calculation for the chanctx min_def.
Since the sta->bandwidth is calculated only later on, take
bss_conf.chandef.width as the minimal width for station interface.

Set the upgraded channel width in the VHT-operation set during TDLS setup.
Signed-off-by: NArik Nemtsov <arikx.nemtsov@intel.com>
Signed-off-by: NEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: NJohannes Berg <johannes.berg@intel.com>
上级 b98fb44f
...@@ -190,7 +190,7 @@ ieee80211_find_reservation_chanctx(struct ieee80211_local *local, ...@@ -190,7 +190,7 @@ ieee80211_find_reservation_chanctx(struct ieee80211_local *local,
return NULL; return NULL;
} }
static enum nl80211_chan_width ieee80211_get_sta_bw(struct ieee80211_sta *sta) enum nl80211_chan_width ieee80211_get_sta_bw(struct ieee80211_sta *sta)
{ {
switch (sta->bandwidth) { switch (sta->bandwidth) {
case IEEE80211_STA_RX_BW_20: case IEEE80211_STA_RX_BW_20:
...@@ -264,9 +264,17 @@ ieee80211_get_chanctx_max_required_bw(struct ieee80211_local *local, ...@@ -264,9 +264,17 @@ ieee80211_get_chanctx_max_required_bw(struct ieee80211_local *local,
case NL80211_IFTYPE_AP_VLAN: case NL80211_IFTYPE_AP_VLAN:
width = ieee80211_get_max_required_bw(sdata); width = ieee80211_get_max_required_bw(sdata);
break; break;
case NL80211_IFTYPE_STATION:
/*
* The ap's sta->bandwidth is not set yet at this
* point, so take the width from the chandef, but
* account also for TDLS peers
*/
width = max(vif->bss_conf.chandef.width,
ieee80211_get_max_required_bw(sdata));
break;
case NL80211_IFTYPE_P2P_DEVICE: case NL80211_IFTYPE_P2P_DEVICE:
continue; continue;
case NL80211_IFTYPE_STATION:
case NL80211_IFTYPE_ADHOC: case NL80211_IFTYPE_ADHOC:
case NL80211_IFTYPE_WDS: case NL80211_IFTYPE_WDS:
case NL80211_IFTYPE_MESH_POINT: case NL80211_IFTYPE_MESH_POINT:
...@@ -554,12 +562,13 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local, ...@@ -554,12 +562,13 @@ static void ieee80211_free_chanctx(struct ieee80211_local *local,
kfree_rcu(ctx, rcu_head); kfree_rcu(ctx, rcu_head);
} }
static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local, void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx) struct ieee80211_chanctx *ctx)
{ {
struct ieee80211_chanctx_conf *conf = &ctx->conf; struct ieee80211_chanctx_conf *conf = &ctx->conf;
struct ieee80211_sub_if_data *sdata; struct ieee80211_sub_if_data *sdata;
const struct cfg80211_chan_def *compat = NULL; const struct cfg80211_chan_def *compat = NULL;
struct sta_info *sta;
lockdep_assert_held(&local->chanctx_mtx); lockdep_assert_held(&local->chanctx_mtx);
...@@ -581,6 +590,20 @@ static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local, ...@@ -581,6 +590,20 @@ static void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
if (WARN_ON_ONCE(!compat)) if (WARN_ON_ONCE(!compat))
break; break;
} }
/* TDLS peers can sometimes affect the chandef width */
list_for_each_entry_rcu(sta, &local->sta_list, list) {
if (!sta->uploaded ||
!test_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW) ||
!test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
!sta->tdls_chandef.chan)
continue;
compat = cfg80211_chandef_compatible(&sta->tdls_chandef,
compat);
if (WARN_ON_ONCE(!compat))
break;
}
rcu_read_unlock(); rcu_read_unlock();
if (!compat) if (!compat)
......
...@@ -2033,6 +2033,9 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, ...@@ -2033,6 +2033,9 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata,
enum ieee80211_chanctx_mode chanmode, enum ieee80211_chanctx_mode chanmode,
u8 radar_detect); u8 radar_detect);
int ieee80211_max_num_channels(struct ieee80211_local *local); int ieee80211_max_num_channels(struct ieee80211_local *local);
enum nl80211_chan_width ieee80211_get_sta_bw(struct ieee80211_sta *sta);
void ieee80211_recalc_chanctx_chantype(struct ieee80211_local *local,
struct ieee80211_chanctx *ctx);
/* TDLS */ /* TDLS */
int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
......
...@@ -403,6 +403,8 @@ struct mesh_sta { ...@@ -403,6 +403,8 @@ struct mesh_sta {
* @rx_msdu: MSDUs received from this station, using IEEE80211_NUM_TID * @rx_msdu: MSDUs received from this station, using IEEE80211_NUM_TID
* entry for non-QoS frames * entry for non-QoS frames
* @fast_tx: TX fastpath information * @fast_tx: TX fastpath information
* @tdls_chandef: a TDLS peer can have a wider chandef that is compatible to
* the BSS one.
*/ */
struct sta_info { struct sta_info {
/* General information, mostly static */ /* General information, mostly static */
...@@ -511,6 +513,8 @@ struct sta_info { ...@@ -511,6 +513,8 @@ struct sta_info {
u8 reserved_tid; u8 reserved_tid;
struct cfg80211_chan_def tdls_chandef;
/* keep last! */ /* keep last! */
struct ieee80211_sta sta; struct ieee80211_sta sta;
}; };
......
...@@ -291,6 +291,60 @@ static void ieee80211_tdls_add_wmm_param_ie(struct ieee80211_sub_if_data *sdata, ...@@ -291,6 +291,60 @@ static void ieee80211_tdls_add_wmm_param_ie(struct ieee80211_sub_if_data *sdata,
} }
} }
static void
ieee80211_tdls_chandef_vht_upgrade(struct ieee80211_sub_if_data *sdata,
struct sta_info *sta)
{
/* IEEE802.11ac-2013 Table E-4 */
u16 centers_80mhz[] = { 5210, 5290, 5530, 5610, 5690, 5775 };
struct cfg80211_chan_def uc = sta->tdls_chandef;
enum nl80211_chan_width max_width = ieee80211_get_sta_bw(&sta->sta);
int i;
/* only support upgrading non-narrow channels up to 80Mhz */
if (max_width == NL80211_CHAN_WIDTH_5 ||
max_width == NL80211_CHAN_WIDTH_10)
return;
if (max_width > NL80211_CHAN_WIDTH_80)
max_width = NL80211_CHAN_WIDTH_80;
if (uc.width == max_width)
return;
/*
* Channel usage constrains in the IEEE802.11ac-2013 specification only
* allow expanding a 20MHz channel to 80MHz in a single way. In
* addition, there are no 40MHz allowed channels that are not part of
* the allowed 80MHz range in the 5GHz spectrum (the relevant one here).
*/
for (i = 0; i < ARRAY_SIZE(centers_80mhz); i++)
if (abs(uc.chan->center_freq - centers_80mhz[i]) <= 30) {
uc.center_freq1 = centers_80mhz[i];
uc.width = NL80211_CHAN_WIDTH_80;
break;
}
if (!uc.center_freq1)
return;
/* proceed to downgrade the chandef until usable or the same */
while (uc.width > max_width &&
!cfg80211_reg_can_beacon(sdata->local->hw.wiphy,
&uc, sdata->wdev.iftype))
ieee80211_chandef_downgrade(&uc);
if (!cfg80211_chandef_identical(&uc, &sta->tdls_chandef)) {
tdls_dbg(sdata, "TDLS ch width upgraded %d -> %d\n",
sta->tdls_chandef.width, uc.width);
/*
* the station is not yet authorized when BW upgrade is done,
* locking is not required
*/
sta->tdls_chandef = uc;
}
}
static void static void
ieee80211_tdls_add_setup_start_ies(struct ieee80211_sub_if_data *sdata, ieee80211_tdls_add_setup_start_ies(struct ieee80211_sub_if_data *sdata,
struct sk_buff *skb, const u8 *peer, struct sk_buff *skb, const u8 *peer,
...@@ -358,15 +412,17 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_sub_if_data *sdata, ...@@ -358,15 +412,17 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_sub_if_data *sdata,
offset = noffset; offset = noffset;
} }
rcu_read_lock(); mutex_lock(&local->sta_mtx);
/* we should have the peer STA if we're already responding */ /* we should have the peer STA if we're already responding */
if (action_code == WLAN_TDLS_SETUP_RESPONSE) { if (action_code == WLAN_TDLS_SETUP_RESPONSE) {
sta = sta_info_get(sdata, peer); sta = sta_info_get(sdata, peer);
if (WARN_ON_ONCE(!sta)) { if (WARN_ON_ONCE(!sta)) {
rcu_read_unlock(); mutex_unlock(&local->sta_mtx);
return; return;
} }
sta->tdls_chandef = sdata->vif.bss_conf.chandef;
} }
ieee80211_tdls_add_oper_classes(sdata, skb); ieee80211_tdls_add_oper_classes(sdata, skb);
...@@ -456,9 +512,16 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_sub_if_data *sdata, ...@@ -456,9 +512,16 @@ ieee80211_tdls_add_setup_start_ies(struct ieee80211_sub_if_data *sdata,
pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2); pos = skb_put(skb, sizeof(struct ieee80211_vht_cap) + 2);
ieee80211_ie_build_vht_cap(pos, &vht_cap, vht_cap.cap); ieee80211_ie_build_vht_cap(pos, &vht_cap, vht_cap.cap);
/*
* if both peers support WIDER_BW, we can expand the chandef to
* a wider compatible one, up to 80MHz
*/
if (test_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW))
ieee80211_tdls_chandef_vht_upgrade(sdata, sta);
} }
rcu_read_unlock(); mutex_unlock(&local->sta_mtx);
/* add any remaining IEs */ /* add any remaining IEs */
if (extra_ies_len) { if (extra_ies_len) {
...@@ -482,15 +545,17 @@ ieee80211_tdls_add_setup_cfm_ies(struct ieee80211_sub_if_data *sdata, ...@@ -482,15 +545,17 @@ ieee80211_tdls_add_setup_cfm_ies(struct ieee80211_sub_if_data *sdata,
enum ieee80211_band band = ieee80211_get_sdata_band(sdata); enum ieee80211_band band = ieee80211_get_sdata_band(sdata);
u8 *pos; u8 *pos;
rcu_read_lock(); mutex_lock(&local->sta_mtx);
sta = sta_info_get(sdata, peer); sta = sta_info_get(sdata, peer);
ap_sta = sta_info_get(sdata, ifmgd->bssid); ap_sta = sta_info_get(sdata, ifmgd->bssid);
if (WARN_ON_ONCE(!sta || !ap_sta)) { if (WARN_ON_ONCE(!sta || !ap_sta)) {
rcu_read_unlock(); mutex_unlock(&local->sta_mtx);
return; return;
} }
sta->tdls_chandef = sdata->vif.bss_conf.chandef;
/* add any custom IEs that go before the QoS IE */ /* add any custom IEs that go before the QoS IE */
if (extra_ies_len) { if (extra_ies_len) {
static const u8 before_qos[] = { static const u8 before_qos[] = {
...@@ -538,12 +603,19 @@ ieee80211_tdls_add_setup_cfm_ies(struct ieee80211_sub_if_data *sdata, ...@@ -538,12 +603,19 @@ ieee80211_tdls_add_setup_cfm_ies(struct ieee80211_sub_if_data *sdata,
/* only include VHT-operation if not on the 2.4GHz band */ /* only include VHT-operation if not on the 2.4GHz band */
if (band != IEEE80211_BAND_2GHZ && sta->sta.vht_cap.vht_supported) { if (band != IEEE80211_BAND_2GHZ && sta->sta.vht_cap.vht_supported) {
/*
* if both peers support WIDER_BW, we can expand the chandef to
* a wider compatible one, up to 80MHz
*/
if (test_sta_flag(sta, WLAN_STA_TDLS_WIDER_BW))
ieee80211_tdls_chandef_vht_upgrade(sdata, sta);
pos = skb_put(skb, 2 + sizeof(struct ieee80211_vht_operation)); pos = skb_put(skb, 2 + sizeof(struct ieee80211_vht_operation));
ieee80211_ie_build_vht_oper(pos, &sta->sta.vht_cap, ieee80211_ie_build_vht_oper(pos, &sta->sta.vht_cap,
&sdata->vif.bss_conf.chandef); &sta->tdls_chandef);
} }
rcu_read_unlock(); mutex_unlock(&local->sta_mtx);
/* add any remaining IEs */ /* add any remaining IEs */
if (extra_ies_len) { if (extra_ies_len) {
...@@ -1154,6 +1226,22 @@ int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev, ...@@ -1154,6 +1226,22 @@ int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
return ret; return ret;
} }
static void iee80211_tdls_recalc_chanctx(struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_local *local = sdata->local;
struct ieee80211_chanctx_conf *conf;
struct ieee80211_chanctx *ctx;
mutex_lock(&local->chanctx_mtx);
conf = rcu_dereference_protected(sdata->vif.chanctx_conf,
lockdep_is_held(&local->chanctx_mtx));
if (conf) {
ctx = container_of(conf, struct ieee80211_chanctx, conf);
ieee80211_recalc_chanctx_chantype(local, ctx);
}
mutex_unlock(&local->chanctx_mtx);
}
int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
const u8 *peer, enum nl80211_tdls_operation oper) const u8 *peer, enum nl80211_tdls_operation oper)
{ {
...@@ -1190,6 +1278,8 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, ...@@ -1190,6 +1278,8 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
break; break;
} }
iee80211_tdls_recalc_chanctx(sdata);
rcu_read_lock(); rcu_read_lock();
sta = sta_info_get(sdata, peer); sta = sta_info_get(sdata, peer);
if (!sta) { if (!sta) {
...@@ -1221,6 +1311,7 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, ...@@ -1221,6 +1311,7 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
ieee80211_flush_queues(local, sdata, false); ieee80211_flush_queues(local, sdata, false);
ret = sta_info_destroy_addr(sdata, peer); ret = sta_info_destroy_addr(sdata, peer);
iee80211_tdls_recalc_chanctx(sdata);
break; break;
default: default:
ret = -ENOTSUPP; ret = -ENOTSUPP;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册