Commit ff276691 authored by Johannes Berg's avatar Johannes Berg

cfg80211: unify station WME parsing

Instead of copying the code, create a new function
to parse the station's WME information.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 984c311b
...@@ -3359,21 +3359,13 @@ nl80211_sta_wme_policy[NL80211_STA_WME_MAX + 1] __read_mostly = { ...@@ -3359,21 +3359,13 @@ nl80211_sta_wme_policy[NL80211_STA_WME_MAX + 1] __read_mostly = {
[NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 }, [NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 },
}; };
static int nl80211_set_station_tdls(struct genl_info *info, static int nl80211_parse_sta_wme(struct genl_info *info,
struct station_parameters *params) struct station_parameters *params)
{ {
struct nlattr *tb[NL80211_STA_WME_MAX + 1]; struct nlattr *tb[NL80211_STA_WME_MAX + 1];
struct nlattr *nla; struct nlattr *nla;
int err; int err;
/* Dummy STA entry gets updated once the peer capabilities are known */
if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
params->ht_capa =
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
if (info->attrs[NL80211_ATTR_VHT_CAPABILITY])
params->vht_capa =
nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]);
/* parse WME attributes if present */ /* parse WME attributes if present */
if (!info->attrs[NL80211_ATTR_STA_WME]) if (!info->attrs[NL80211_ATTR_STA_WME])
return 0; return 0;
...@@ -3401,6 +3393,20 @@ static int nl80211_set_station_tdls(struct genl_info *info, ...@@ -3401,6 +3393,20 @@ static int nl80211_set_station_tdls(struct genl_info *info,
return 0; return 0;
} }
static int nl80211_set_station_tdls(struct genl_info *info,
struct station_parameters *params)
{
/* Dummy STA entry gets updated once the peer capabilities are known */
if (info->attrs[NL80211_ATTR_HT_CAPABILITY])
params->ht_capa =
nla_data(info->attrs[NL80211_ATTR_HT_CAPABILITY]);
if (info->attrs[NL80211_ATTR_VHT_CAPABILITY])
params->vht_capa =
nla_data(info->attrs[NL80211_ATTR_VHT_CAPABILITY]);
return nl80211_parse_sta_wme(info, params);
}
static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info)
{ {
struct cfg80211_registered_device *rdev = info->user_ptr[0]; struct cfg80211_registered_device *rdev = info->user_ptr[0];
...@@ -3674,31 +3680,10 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) ...@@ -3674,31 +3680,10 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
return -EINVAL; return -EINVAL;
} }
if (info->attrs[NL80211_ATTR_STA_WME]) { err = nl80211_parse_sta_wme(info, &params);
struct nlattr *tb[NL80211_STA_WME_MAX + 1];
struct nlattr *nla;
nla = info->attrs[NL80211_ATTR_STA_WME];
err = nla_parse_nested(tb, NL80211_STA_WME_MAX, nla,
nl80211_sta_wme_policy);
if (err) if (err)
return err; return err;
if (tb[NL80211_STA_WME_UAPSD_QUEUES])
params.uapsd_queues =
nla_get_u8(tb[NL80211_STA_WME_UAPSD_QUEUES]);
if (params.uapsd_queues & ~IEEE80211_WMM_IE_STA_QOSINFO_AC_MASK)
return -EINVAL;
if (tb[NL80211_STA_WME_MAX_SP])
params.max_sp = nla_get_u8(tb[NL80211_STA_WME_MAX_SP]);
if (params.max_sp & ~IEEE80211_WMM_IE_STA_QOSINFO_SP_MASK)
return -EINVAL;
params.sta_modify_mask |= STATION_PARAM_APPLY_UAPSD;
}
if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params)) if (parse_station_flags(info, dev->ieee80211_ptr->iftype, &params))
return -EINVAL; return -EINVAL;
......
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