Commit bee7f586 authored by Johannes Berg's avatar Johannes Berg

mac80211: handle operating mode notif in beacon/assoc response

In beacons and association response frames an AP may include an
operating mode notification element to advertise changes in the
number of spatial streams it can receive. Handle this using the
existing function that handles the action frame, but only handle
NSS changes, not bandwidth changes which aren't allowed here.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 18942d3b
...@@ -1197,6 +1197,7 @@ struct ieee802_11_elems { ...@@ -1197,6 +1197,7 @@ struct ieee802_11_elems {
u8 *pwr_constr_elem; u8 *pwr_constr_elem;
u8 *quiet_elem; /* first quite element */ u8 *quiet_elem; /* first quite element */
u8 *timeout_int; u8 *timeout_int;
u8 *opmode_notif;
/* length of them, respectively */ /* length of them, respectively */
u8 ssid_len; u8 ssid_len;
...@@ -1435,7 +1436,7 @@ enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta); ...@@ -1435,7 +1436,7 @@ enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw(struct sta_info *sta);
void ieee80211_sta_set_rx_nss(struct sta_info *sta); void ieee80211_sta_set_rx_nss(struct sta_info *sta);
void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
struct sta_info *sta, u8 opmode, struct sta_info *sta, u8 opmode,
enum ieee80211_band band); enum ieee80211_band band, bool nss_only);
/* Spectrum management */ /* Spectrum management */
void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata, void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
......
...@@ -2217,6 +2217,21 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, ...@@ -2217,6 +2217,21 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata,
elems.ht_operation, elems.ht_operation,
cbss->bssid, false); cbss->bssid, false);
/*
* If an operating mode notification IE is present, override the
* NSS calculation (that would be done in rate_control_rate_init())
* and use the # of streams from that element.
*/
if (elems.opmode_notif &&
!(*elems.opmode_notif & IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF)) {
u8 nss;
nss = *elems.opmode_notif & IEEE80211_OPMODE_NOTIF_RX_NSS_MASK;
nss >>= IEEE80211_OPMODE_NOTIF_RX_NSS_SHIFT;
nss += 1;
sta->sta.rx_nss = nss;
}
rate_control_rate_init(sta); rate_control_rate_init(sta);
if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED)
...@@ -2489,6 +2504,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, ...@@ -2489,6 +2504,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct ieee80211_chanctx_conf *chanctx_conf; struct ieee80211_chanctx_conf *chanctx_conf;
struct ieee80211_channel *chan; struct ieee80211_channel *chan;
struct sta_info *sta;
u32 changed = 0; u32 changed = 0;
bool erp_valid; bool erp_valid;
u8 erp_value = 0; u8 erp_value = 0;
...@@ -2728,14 +2744,18 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, ...@@ -2728,14 +2744,18 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
le16_to_cpu(mgmt->u.beacon.capab_info), le16_to_cpu(mgmt->u.beacon.capab_info),
erp_valid, erp_value); erp_valid, erp_value);
mutex_lock(&local->sta_mtx); mutex_lock(&local->sta_mtx);
sta = sta_info_get(sdata, bssid);
if (elems.ht_cap_elem && elems.ht_operation && elems.wmm_param && if (elems.ht_cap_elem && elems.ht_operation && elems.wmm_param &&
!(ifmgd->flags & IEEE80211_STA_DISABLE_HT)) !(ifmgd->flags & IEEE80211_STA_DISABLE_HT))
changed |= ieee80211_config_ht_tx(sdata, changed |= ieee80211_config_ht_tx(sdata, sta,
sta_info_get(sdata, bssid),
elems.ht_operation, elems.ht_operation,
bssid, true); bssid, true);
if (sta && elems.opmode_notif)
ieee80211_vht_handle_opmode(sdata, sta, *elems.opmode_notif,
rx_status->band, true);
mutex_unlock(&local->sta_mtx); mutex_unlock(&local->sta_mtx);
if (elems.country_elem && elems.pwr_constr_elem && if (elems.country_elem && elems.pwr_constr_elem &&
......
...@@ -2459,7 +2459,8 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx) ...@@ -2459,7 +2459,8 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
opmode = mgmt->u.action.u.vht_opmode_notif.operating_mode; opmode = mgmt->u.action.u.vht_opmode_notif.operating_mode;
ieee80211_vht_handle_opmode(rx->sdata, rx->sta, ieee80211_vht_handle_opmode(rx->sdata, rx->sta,
opmode, status->band); opmode, status->band,
false);
goto handled; goto handled;
} }
default: default:
......
...@@ -787,6 +787,12 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len, ...@@ -787,6 +787,12 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
else else
elem_parse_failed = true; elem_parse_failed = true;
break; break;
case WLAN_EID_OPMODE_NOTIF:
if (elen > 0)
elems->opmode_notif = pos;
else
elem_parse_failed = true;
break;
case WLAN_EID_MESH_ID: case WLAN_EID_MESH_ID:
elems->mesh_id = pos; elems->mesh_id = pos;
elems->mesh_id_len = elen; elems->mesh_id_len = elen;
......
...@@ -141,7 +141,7 @@ void ieee80211_sta_set_rx_nss(struct sta_info *sta) ...@@ -141,7 +141,7 @@ void ieee80211_sta_set_rx_nss(struct sta_info *sta)
void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
struct sta_info *sta, u8 opmode, struct sta_info *sta, u8 opmode,
enum ieee80211_band band) enum ieee80211_band band, bool nss_only)
{ {
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
...@@ -164,6 +164,9 @@ void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, ...@@ -164,6 +164,9 @@ void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
changed |= IEEE80211_RC_NSS_CHANGED; changed |= IEEE80211_RC_NSS_CHANGED;
} }
if (nss_only)
goto change;
switch (opmode & IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK) { switch (opmode & IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK) {
case IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ: case IEEE80211_OPMODE_NOTIF_CHANWIDTH_20MHZ:
sta->cur_max_bandwidth = IEEE80211_STA_RX_BW_20; sta->cur_max_bandwidth = IEEE80211_STA_RX_BW_20;
...@@ -185,6 +188,7 @@ void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata, ...@@ -185,6 +188,7 @@ void ieee80211_vht_handle_opmode(struct ieee80211_sub_if_data *sdata,
changed |= IEEE80211_RC_NSS_CHANGED; changed |= IEEE80211_RC_NSS_CHANGED;
} }
change:
if (changed) if (changed)
rate_control_rate_update(local, sband, sta, changed); rate_control_rate_update(local, sband, sta, changed);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment