Commit 34ce9c8b authored by Felix Fietkau's avatar Felix Fietkau Committed by Johannes Berg

wifi: nl80211: split helper function from nl80211_put_iface_combinations

Create a helper function that puts the data from struct
ieee80211_iface_combination to a nl80211 message.
This will be used for adding per-radio interface combination data.
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
Link: https://patch.msgid.link/22a0eee19dbcf98627239328bc66decd3395122c.1719919832.git-series.nbd@nbd.nameSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 1b431ba4
...@@ -1631,71 +1631,78 @@ static int nl80211_put_iftypes(struct sk_buff *msg, u32 attr, u16 ifmodes) ...@@ -1631,71 +1631,78 @@ static int nl80211_put_iftypes(struct sk_buff *msg, u32 attr, u16 ifmodes)
return -ENOBUFS; return -ENOBUFS;
} }
static int nl80211_put_iface_combinations(struct wiphy *wiphy, static int nl80211_put_ifcomb_data(struct sk_buff *msg, bool large, int idx,
struct sk_buff *msg, const struct ieee80211_iface_combination *c)
bool large)
{ {
struct nlattr *nl_combis; struct nlattr *nl_combi, *nl_limits;
int i, j; int i;
nl_combis = nla_nest_start_noflag(msg, nl_combi = nla_nest_start_noflag(msg, idx);
NL80211_ATTR_INTERFACE_COMBINATIONS); if (!nl_combi)
if (!nl_combis)
goto nla_put_failure; goto nla_put_failure;
for (i = 0; i < wiphy->n_iface_combinations; i++) { nl_limits = nla_nest_start_noflag(msg, NL80211_IFACE_COMB_LIMITS);
const struct ieee80211_iface_combination *c; if (!nl_limits)
struct nlattr *nl_combi, *nl_limits; goto nla_put_failure;
c = &wiphy->iface_combinations[i]; for (i = 0; i < c->n_limits; i++) {
struct nlattr *nl_limit;
nl_combi = nla_nest_start_noflag(msg, i + 1); nl_limit = nla_nest_start_noflag(msg, i + 1);
if (!nl_combi) if (!nl_limit)
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u32(msg, NL80211_IFACE_LIMIT_MAX, c->limits[i].max))
nl_limits = nla_nest_start_noflag(msg,
NL80211_IFACE_COMB_LIMITS);
if (!nl_limits)
goto nla_put_failure; goto nla_put_failure;
if (nl80211_put_iftypes(msg, NL80211_IFACE_LIMIT_TYPES,
c->limits[i].types))
goto nla_put_failure;
nla_nest_end(msg, nl_limit);
}
for (j = 0; j < c->n_limits; j++) { nla_nest_end(msg, nl_limits);
struct nlattr *nl_limit;
nl_limit = nla_nest_start_noflag(msg, j + 1); if (c->beacon_int_infra_match &&
if (!nl_limit) nla_put_flag(msg, NL80211_IFACE_COMB_STA_AP_BI_MATCH))
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u32(msg, NL80211_IFACE_LIMIT_MAX, if (nla_put_u32(msg, NL80211_IFACE_COMB_NUM_CHANNELS,
c->limits[j].max)) c->num_different_channels) ||
goto nla_put_failure; nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
if (nl80211_put_iftypes(msg, NL80211_IFACE_LIMIT_TYPES, c->max_interfaces))
c->limits[j].types)) goto nla_put_failure;
goto nla_put_failure; if (large &&
nla_nest_end(msg, nl_limit); (nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
} c->radar_detect_widths) ||
nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
c->radar_detect_regions)))
goto nla_put_failure;
if (c->beacon_int_min_gcd &&
nla_put_u32(msg, NL80211_IFACE_COMB_BI_MIN_GCD,
c->beacon_int_min_gcd))
goto nla_put_failure;
nla_nest_end(msg, nl_limits); nla_nest_end(msg, nl_combi);
if (c->beacon_int_infra_match && return 0;
nla_put_flag(msg, NL80211_IFACE_COMB_STA_AP_BI_MATCH)) nla_put_failure:
goto nla_put_failure; return -ENOBUFS;
if (nla_put_u32(msg, NL80211_IFACE_COMB_NUM_CHANNELS, }
c->num_different_channels) ||
nla_put_u32(msg, NL80211_IFACE_COMB_MAXNUM,
c->max_interfaces))
goto nla_put_failure;
if (large &&
(nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
c->radar_detect_widths) ||
nla_put_u32(msg, NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
c->radar_detect_regions)))
goto nla_put_failure;
if (c->beacon_int_min_gcd &&
nla_put_u32(msg, NL80211_IFACE_COMB_BI_MIN_GCD,
c->beacon_int_min_gcd))
goto nla_put_failure;
nla_nest_end(msg, nl_combi); static int nl80211_put_iface_combinations(struct wiphy *wiphy,
} struct sk_buff *msg,
bool large)
{
struct nlattr *nl_combis;
int i;
nl_combis = nla_nest_start_noflag(msg,
NL80211_ATTR_INTERFACE_COMBINATIONS);
if (!nl_combis)
goto nla_put_failure;
for (i = 0; i < wiphy->n_iface_combinations; i++)
if (nl80211_put_ifcomb_data(msg, large, i + 1,
&wiphy->iface_combinations[i]))
goto nla_put_failure;
nla_nest_end(msg, nl_combis); nla_nest_end(msg, nl_combis);
......
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