wlan-ap-Telecominfraproject/feeds/ipq95xx/iw/patches/609-iw-interface-combination-changes.patch
John Crispin 460050a114 ipq50xx: add CIF WF-198 support
Signed-off-by: John Crispin <john@phrozen.org>
2024-02-28 18:56:21 +01:00

282 lines
10 KiB
Diff

From 9c263bc61d802fab30b3529ebdaace86f564e8f0 Mon Sep 17 00:00:00 2001
From: Harshitha Prem <quic_hprem@quicinc.com>
Date: Fri, 4 Nov 2022 18:51:54 +0530
Subject: [PATCH] iw: interface combination changes
print multi_hw channels
print multi_hw interface combinations
Signed-off-by: Harshitha Prem <quic_hprem@quicinc.com>
---
info.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++-
nl80211.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 170 insertions(+), 2 deletions(-)
--- a/info.c
+++ b/info.c
@@ -390,7 +390,6 @@ next:
if (tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]) {
unsigned char coverage;
-
coverage = nla_get_u8(tb_msg[NL80211_ATTR_WIPHY_COVERAGE_CLASS]);
/* See handle_distance() for an explanation where the '450' comes from */
printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
@@ -436,6 +435,7 @@ next:
struct nlattr *nl_combi;
int rem_combi;
bool have_combinations = false;
+ bool have_combinations_per_hw = false;
nla_for_each_nested(nl_combi, tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], rem_combi) {
static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = {
@@ -444,6 +444,7 @@ next:
[NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG },
[NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 },
[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS] = { .type = NLA_U32 },
+ [NL80211_IFACE_COMB_PER_HW_COMB] = { .type = NLA_NESTED },
};
struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB];
static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
@@ -452,7 +453,15 @@ next:
};
struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT];
struct nlattr *nl_limit;
- int err, rem_limit;
+ static struct nla_policy iface_comb_per_hw_policy[NUM_NL80211_IFACE_COMB_PER_HW_COMB] = {
+ [NL80211_IFACE_COMB_PER_HW_COMB_HW_IDX] = { .type = NLA_U8 },
+ [NL80211_IFACE_COMB_PER_HW_COMB_LIMITS] = { .type = NLA_NESTED },
+ [NL80211_IFACE_COMB_PER_HW_COMB_MAXIMUM] = { .type = NLA_U16 },
+ [NL80211_IFACE_COMB_PER_HW_COMB_NUM_CHANNELS] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb_per_hw[NUM_NL80211_IFACE_COMB_PER_HW_COMB];
+ struct nlattr *nl_per_hw;
+ int err, rem_limit, rem_per_hw;
bool comma = false;
if (!have_combinations) {
@@ -512,6 +521,43 @@ next:
}
}
printf("\n");
+
+ if (!tb_comb[NL80211_IFACE_COMB_PER_HW_COMB])
+ goto broken_combination;
+
+ nla_for_each_nested(nl_per_hw, tb_comb[NL80211_IFACE_COMB_PER_HW_COMB], rem_per_hw) {
+ comma = false;
+ if (!have_combinations_per_hw) {
+ printf("\tvalid interface combo per hw:");
+ have_combinations_per_hw = true;
+ }
+
+ err = nla_parse_nested(tb_per_hw, MAX_NL80211_IFACE_COMB_PER_HW_COMB,
+ nl_per_hw, iface_comb_per_hw_policy);
+ if (err || !tb_per_hw[NL80211_IFACE_COMB_PER_HW_COMB_HW_IDX]) {
+ printf("<failed to parse> at %d %d\n", __LINE__, err);
+ goto broken_combination;
+ }
+ printf("\n\t\thw_idx %d:\n\t\t\t max num of iface: %d, #channels <= %d,",
+ nla_get_u8(tb_per_hw[NL80211_IFACE_COMB_PER_HW_COMB_HW_IDX]),
+ nla_get_u32(tb_per_hw[NL80211_IFACE_COMB_PER_HW_COMB_MAXIMUM]),
+ nla_get_u16(tb_per_hw[NL80211_IFACE_COMB_NUM_CHANNELS]));
+ nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], rem_limit) {
+ err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT,
+ nl_limit, iface_limit_policy);
+ if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) {
+ printf("<failed to parse> at %d %d\n", __LINE__, err);
+ goto broken_combination;
+ }
+ if (comma)
+ printf(", ");
+ comma = true;
+ printf("#{ ");
+ print_iftype_line(tb_limit[NL80211_IFACE_LIMIT_TYPES]);
+ printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX]));
+ }
+ }
+ printf("\n");
broken_combination:
;
}
@@ -762,6 +808,49 @@ broken_combination:
printf("\tMaximum associated stations in AP mode: %u\n",
nla_get_u16(tb_msg[NL80211_ATTR_MAX_AP_ASSOC_STA]));
+ if (tb_msg[NL80211_ATTR_MULTI_HW_MACS]) {
+ struct nlattr *tb_hw[NL80211_MULTI_HW_MAC_ATTR_MAX + 1];
+ struct nlattr *tb_freq[NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_MAX + 1];
+ struct nlattr *nl_hw_macs;
+ struct nlattr *nl_freq_list;
+ int rem_hw_macs, rem_freq_list;
+
+ nla_for_each_nested(nl_hw_macs, tb_msg[NL80211_ATTR_MULTI_HW_MACS],
+ rem_hw_macs) {
+ nla_parse(tb_hw, NL80211_MULTI_HW_MAC_ATTR_MAX,
+ nla_data(nl_hw_macs), nla_len(nl_hw_macs),
+ NULL);
+
+ if (tb_hw[NL80211_MULTI_HW_MAC_ATTR_IDX]) {
+ uint8_t hw_idx;
+ hw_idx = nla_get_u8(tb_hw[NL80211_MULTI_HW_MAC_ATTR_IDX]);
+ printf("\n\thw_idx %d channel list:\n", hw_idx);
+ }
+ if (tb_hw[NL80211_MULTI_HW_MAC_ATTR_CHAN_LIST]) {
+ uint8_t count = 0;
+ printf("\t\t");
+ nla_for_each_nested(nl_freq_list,
+ tb_hw[NL80211_MULTI_HW_MAC_ATTR_CHAN_LIST],
+ rem_freq_list) {
+ if (count == 20) {
+ printf("\n\t\t");
+ count = 0;
+ }
+ nla_parse(tb_freq, NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_MAX,
+ nla_data(nl_freq_list), nla_len(nl_freq_list),
+ NULL);
+ if (tb_freq[NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_FREQ]) {
+ uint32_t freq;
+ freq = nla_get_u32(tb_freq[NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_FREQ]);
+ printf("%d ",ieee80211_frequency_to_channel(freq));
+ count++;
+ }
+ }
+ }
+ }
+ printf("\n");
+ }
+
return NL_SKIP;
}
--- a/nl80211.h
+++ b/nl80211.h
@@ -3217,6 +3217,8 @@ enum nl80211_attrs {
NL80211_ATTR_AP_PS,
+ NL80211_ATTR_MULTI_HW_MACS,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
@@ -5826,6 +5828,10 @@ enum nl80211_iface_limit_attrs {
* @NL80211_IFACE_COMB_BI_MIN_GCD: u32 attribute specifying the minimum GCD of
* different beacon intervals supported by all the interface combinations
* in this group (if not present, all beacon intervals be identical).
+ * @NL80211_IFACE_COMB_PER_HW_COMB: nested attribute specifying the interface
+ * combination for each underlying hardware when multiple hardware are
+ * registered under a single wiphy,
+ * see &enum nl80211_if_combination_per_hw_comb_attrs.
* @NUM_NL80211_IFACE_COMB: number of attributes
* @MAX_NL80211_IFACE_COMB: highest attribute number
*
@@ -5841,6 +5847,16 @@ enum nl80211_iface_limit_attrs {
*
* numbers = [ #{STA} <= 1, #{P2P-client,P2P-GO} <= 3 ], max = 4
* => allows a STA plus three P2P interfaces
+ * When describing per-hw combinations, the first possibility can
+ * further include the finer capabilities like below
+ * hw_chan_idx = 0, numbers = [ #{STA} <= 1, #{AP} <= 1 ],
+ * channels = 1, max = 2
+ * => allows a STA plus an AP interface on the underlying hw mac
+ * advertised at index 0 in wiphy @hw_chans array.
+ * hw_chan_idx = 1, numbers = [ #{STA} <= 1, #{AP} <= 2 ],
+ * channels = 1, max = 3
+ * => allows a STA plus two AP interfaces on the underlying hw mac
+ * advertised at index 1 in wiphy @hw_chans array.
*
* The list of these four possibilities could completely be contained
* within the %NL80211_ATTR_INTERFACE_COMBINATIONS attribute to indicate
@@ -5861,12 +5877,43 @@ enum nl80211_if_combination_attrs {
NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS,
NL80211_IFACE_COMB_RADAR_DETECT_REGIONS,
NL80211_IFACE_COMB_BI_MIN_GCD,
-
+ NL80211_IFACE_COMB_PER_HW_COMB,
/* keep last */
NUM_NL80211_IFACE_COMB,
MAX_NL80211_IFACE_COMB = NUM_NL80211_IFACE_COMB - 1
};
+/**
+ * enum nl80211_if_combination_per_hw_comb_attrs - per-hw iface combination
+ * attributes with multi-hw radios
+ *
+ * @NL80211_IFACE_COMB_PER_HW_COMB_UNSPEC: (reserved)
+ * @NL80211_IFACE_COMB_PER_HW_COMB_HW_IDX: u8 attribute specifying the index
+ * to the wiphy @hw_chans list for which the iface combination is being
+ * described.
+ * @NL80211_IFACE_COMB_PER_HW_COMB_LIMITS: nested attribute containing the
+ * limits for the given interface types, see
+ * &enum nl80211_iface_limit_attrs.
+ * @NL80211_IFACE_COMB_PER_HW_COMB_MAXIMUM: u32 attribute giving the maximum
+ * number of interfaces that can be created in this group. This number
+ * does not apply to the interfaces purely managed in software.
+ * @NL80211_IFACE_COMB_PER_HW_COMB_NUM_CHANNELS: u32 attribute specifying the
+ * number of different channels that can be used in this group.
+ * @NUM_NL80211_IFACE_COMB_PER_HW_COMB: number of attributes
+ * @MAX_NL80211_IFACE_COMB_PER_HW_COMB: highest attribute number
+ */
+enum nl80211_if_combination_per_hw_comb_attrs {
+ NL80211_IFACE_COMB_PER_HW_COMB_UNSPEC,
+ NL80211_IFACE_COMB_PER_HW_COMB_HW_IDX,
+ NL80211_IFACE_COMB_PER_HW_COMB_LIMITS,
+ NL80211_IFACE_COMB_PER_HW_COMB_MAXIMUM,
+ NL80211_IFACE_COMB_PER_HW_COMB_NUM_CHANNELS,
+
+ /* keep last */
+ NUM_NL80211_IFACE_COMB_PER_HW_COMB,
+ MAX_NL80211_IFACE_COMB_PER_HW_COMB =
+ NUM_NL80211_IFACE_COMB_PER_HW_COMB - 1
+};
/**
* enum nl80211_plink_state - state of a mesh peer link finite state machine
@@ -7766,4 +7813,45 @@ enum nl80211_ap_settings_flags {
NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT = 1 << 1,
};
+/**
+ * nl80211_multi_hw_mac_attrs - multi-hw mac attributes
+ *
+ * @NL80211_MULTI_HW_MAC_ATTR_INVALID: invalid
+ * @NL80211_MULTI_HW_MAC_ATTR_IDX: (u8) array index in wiphy @hw_chans to refer an
+ * underlying hw mac for which the supported channel list is advertised.
+ * @NL80211_MULTI_HW_MAC_ATTR_CHAN_LIST: nested attribute specifying list of
+ * supported channels, see &enum nl80211_multi_hw_mac_chan_list_attrs
+ * @__NL80211_MULTI_HW_MAC_ATTR_LAST: internal use
+ * @NL80211_MULTI_HW_MAC_ATTR_MAX: maximum multi-hw mac attribute
+ */
+enum nl80211_multi_hw_mac_attrs {
+ __NL80211_MULTI_HW_MAC_ATTR_INVALID,
+
+ NL80211_MULTI_HW_MAC_ATTR_IDX,
+ NL80211_MULTI_HW_MAC_ATTR_CHAN_LIST,
+
+ /* keep last */
+ __NL80211_MULTI_HW_MAC_ATTR_LAST,
+ NL80211_MULTI_HW_MAC_ATTR_MAX =
+ __NL80211_MULTI_HW_MAC_ATTR_LAST - 1
+};
+
+/**
+ * nl80211_multi_hw_mac_chan_list_attrs - channel attributes for multi-hw
+ *
+ * @__NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_INVALID: invalid
+ * @NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_FREQ: channel center frequency in MHz
+ * @__NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_LAST: internal use
+ * @NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_MAX: maximum channel attribute
+ */
+enum nl80211_multi_hw_mac_chan_list_attrs {
+ __NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_INVALID,
+
+ NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_FREQ,
+
+ /* keep last */
+ __NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_LAST,
+ NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_MAX =
+ __NL80211_MULTI_HW_MAC_CHAN_LIST_ATTR_LAST - 1
+};
#endif /* __LINUX_NL80211_H */