mac80211/cfg80211/hwsim: Basic rate and TXQ params
cover mac80211/cfg80211/hwsim: Basic rate and TXQ params
These patches add cfg80211/nl80211 attributes for configuring basic rate set and TX queue parameters for AP mode. The current hostapd development has matching userspace code for using the new attributes. In addition, mac80211_hwsim is extended to show more detailed debug information on BSS and TXQ changes.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
PATCH 1/4 mac80211_hwsim: Debug info for BSS config changes
Provide detailed information on BSS configuration changes to make it easier to debug mac80211 functionality.
drivers/net/wireless/mac80211_hwsim.c +31 -0
@@ -415,6 +415,37 @@ static void mac80211_hwsim_bss_info_chan u32 changed) {hwsim_check_magic (vif); +printk (KERN_DEBUG "%s:%s(changed=0x%x)\n" , +wiphy_name (hw->wiphy), __func__, changed); + +if (changed &BSS_CHANGED_ASSOC ) { +printk (KERN_DEBUG " ASSOC: assoc=%d aid=%d\n" , + info->assoc, info->aid); + } + +if (changed &BSS_CHANGED_ERP_CTS_PROT ) { +printk (KERN_DEBUG " ERP_CTS_PROT: %d\n" , info->use_cts_prot); + } + +if (changed &BSS_CHANGED_ERP_PREAMBLE ) { +printk (KERN_DEBUG " ERP_PREAMBLE: %d\n" , + info->use_short_preamble); + } + +if (changed &BSS_CHANGED_ERP_SLOT ) { +printk (KERN_DEBUG " ERP_SLOT: %d\n" , info->use_short_slot); + } + +if (changed &BSS_CHANGED_HT ) { +printk (KERN_DEBUG " HT: sec_ch_offs=%d width_40_ok=%d " +"op_mode=%d\n" , info->ht.secondary_channel_offset, + info->ht.width_40_ok, info->ht.operation_mode); + } + +if (changed &BSS_CHANGED_BASIC_RATES ) { +printk (KERN_DEBUG " BASIC_RATES: 0x%llx\n" , + info->basic_rates); + } } static void mac80211_hwsim_sta_notify(struct ieee80211_hw *hw,
--
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerRe: [PATCH 1/4] mac80211_hwsim: Debug info for BSS config changes
drivers/net/wireless/mac80211_hwsim.c static void mac80211_hwsim_bss_info_chan · line 419
Quoted 3 lines
drivers/net/wireless/mac80211_hwsim.c +2
-0+printk (KERN_DEBUG "%s:%s(changed=0x%x)\n" , +wiphy_name (hw->wiphy), __func__, changed);
Should we print the wiphy name for each line below too so we can parse this more easily with some validation tools?
drivers/net/wireless/mac80211_hwsim.c static void mac80211_hwsim_bss_info_chan · line 447
Quoted 3 lines
drivers/net/wireless/mac80211_hwsim.c +3
-0+if (changed &BSS_CHANGED_BASIC_RATES ) { +printk (KERN_DEBUG " BASIC_RATES: 0x%llx\n" , + info->basic_rates);
That'll need an (unsigned long long) cast.
johannes
PATCH 2/4 nl80211: Add basic rate configuration for AP mode
In reply to Jouni MalinenAdd a new attribute, NL80211_ATTR_BSS_BASIC_RATES, that can be used with NL80211_CMD_SET_BSS for userspace (e.g., hostapd) to set which rates are in the basic rate set.
include/linux/nl80211.h +6 -0
@@ -243,6 +243,9 @@ enum nl80211_commands {* (u8, 0 or 1) * @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled * (u8, 0 or 1) +* @NL80211_ATTR_BSS_BASIC_RATES: basic rates, array of basic +* rates in format defined by IEEE 802.11 7.3.2.2 but without the length +* restriction (at most %NL80211_MAX_SUPP_RATES). * * @NL80211_ATTR_HT_CAPABILITY: HT Capability information element (from * association request when used with NL80211_CMD_NEW_STATION)
@@ -307,6 +310,8 @@ enum nl80211_attrs {NL80211_ATTR_MESH_PARAMS , +NL80211_ATTR_BSS_BASIC_RATES , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -318,6 +323,7 @@ enum nl80211_attrs {* here */ #define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY +#define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES#define NL80211_MAX_SUPP_RATES 32#define NL80211_MAX_SUPP_REG_RULES 32
include/net/cfg80211.h +5 -0
@@ -280,11 +280,16 @@ struct mpath_info {* (0 = no, 1 = yes, -1 = do not change) * @use_short_slot_time: Whether the use of short slot time is allowed * (0 = no, 1 = yes, -1 = do not change) +* @basic_rates: basic rates in IEEE 802.11 format +* (or NULL for no change) +* @basic_rates_len: number of basic rates */ struct bss_parameters {int use_cts_prot;int use_short_preamble;int use_short_slot_time; +u8 *basic_rates; +u8 basic_rates_len; };/**
net/mac80211/cfg.c +18 -0
@@ -1046,6 +1046,24 @@ static int ieee80211_change_bss(struct w changed |=BSS_CHANGED_ERP_SLOT ; } +if (params->basic_rates) { +int i, j; +u32 rates =0 ; +struct ieee80211_local *local =wiphy_priv (wiphy); +struct ieee80211_supported_band *sband = + wiphy->bands[local->oper_channel->band]; + +for (i =0 ; i < params->basic_rates_len; i++) { +int rate = (params->basic_rates[i] &0x7f ) *5 ; +for (j =0 ; j < sband->n_bitrates; j++) { +if (sband->bitrates[j].bitrate == rate) + rates |=BIT (j); + } + } + sdata->vif.bss_conf.basic_rates = rates; + changed |=BSS_CHANGED_BASIC_RATES ; + } +ieee80211_bss_info_change_notify (sdata, changed);return 0 ;
net/wireless/nl80211.c +8 -0
@@ -95,6 +95,8 @@ static struct nla_policy nl80211_policy[ [NL80211_ATTR_BSS_CTS_PROT] = { .type = NLA_U8 }, [NL80211_ATTR_BSS_SHORT_PREAMBLE] = { .type = NLA_U8 }, [NL80211_ATTR_BSS_SHORT_SLOT_TIME] = { .type = NLA_U8 }, + [NL80211_ATTR_BSS_BASIC_RATES] = { .type = NLA_BINARY, + .len = NL80211_MAX_SUPP_RATES }, [NL80211_ATTR_MESH_PARAMS] = { .type = NLA_NESTED },
@@ -1613,6 +1615,12 @@ static int nl80211_set_bss(struct sk_bufif (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME ]) params.use_short_slot_time =nla_get_u8 (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME ]); +if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES ]) { + params.basic_rates = +nla_data (info->attrs[NL80211_ATTR_BSS_BASIC_RATES ]); + params.basic_rates_len = +nla_len (info->attrs[NL80211_ATTR_BSS_BASIC_RATES ]); + } err =get_drv_dev_by_info_ifindex (info->attrs, &drv, &dev);if (err)
--
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Re: [PATCH 2/4] nl80211: Add basic rate configuration for AP mode
Quoted 4 lines · Jouni Malinen
plain text document attachment (basic_rate_config.patch)
Add a new attribute,NL80211_ATTR_BSS_BASIC_RATES, that can be used withNL80211_CMD_SET_BSSfor userspace (e.g., hostapd) to set which rates are in the basic rate set.
Looks good to me, thanks.
Quoted 1 line
Signed-off-by Jouni Malinen <[email protected]>
Quoted 113 lines
Index:
wireless-testing/include/linux/nl80211.h
===================================================================include/linux/nl80211.h +6
-0@@ -243,6 +243,9 @@ enum nl80211_commands {* (u8, 0 or 1) * @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled * (u8, 0 or 1) +* @NL80211_ATTR_BSS_BASIC_RATES: basic rates, array of basic +* rates in format defined by IEEE 802.11 7.3.2.2 but without the length +* restriction (at most %NL80211_MAX_SUPP_RATES). * * @NL80211_ATTR_HT_CAPABILITY: HT Capability information element (from * association request when used with NL80211_CMD_NEW_STATION) @@ -307,6 +310,8 @@ enum nl80211_attrs {NL80211_ATTR_MESH_PARAMS , +NL80211_ATTR_BSS_BASIC_RATES , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,@@ -318,6 +323,7 @@ enum nl80211_attrs {* here */ #define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY +#define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES#define NL80211_MAX_SUPP_RATES 32#define NL80211_MAX_SUPP_REG_RULES 32Index:
wireless-testing/include/net/cfg80211.h
===================================================================include/net/cfg80211.h +5
-0@@ -280,11 +280,16 @@ struct mpath_info {* (0 = no, 1 = yes, -1 = do not change) * @use_short_slot_time: Whether the use of short slot time is allowed * (0 = no, 1 = yes, -1 = do not change) +* @basic_rates: basic rates in IEEE 802.11 format +* (or NULL for no change) +* @basic_rates_len: number of basic rates */ struct bss_parameters {int use_cts_prot;int use_short_preamble;int use_short_slot_time; +u8 *basic_rates; +u8 basic_rates_len; };/** Index:
wireless-testing/net/mac80211/cfg.c
===================================================================net/mac80211/cfg.c +18
-0@@ -1046,6 +1046,24 @@ static int ieee80211_change_bss(struct w changed |=BSS_CHANGED_ERP_SLOT ; } +if (params->basic_rates) { +int i, j; +u32 rates =0 ; +struct ieee80211_local *local =wiphy_priv (wiphy); +struct ieee80211_supported_band *sband = + wiphy->bands[local->oper_channel->band]; + +for (i =0 ; i < params->basic_rates_len; i++) { +int rate = (params->basic_rates[i] &0x7f ) *5 ; +for (j =0 ; j < sband->n_bitrates; j++) { +if (sband->bitrates[j].bitrate == rate) + rates |=BIT (j); + } + } + sdata->vif.bss_conf.basic_rates = rates; + changed |=BSS_CHANGED_BASIC_RATES ; + } +ieee80211_bss_info_change_notify (sdata, changed);return 0 ;Index:
wireless-testing/net/wireless/nl80211.c
===================================================================net/wireless/nl80211.c +8
-1@@ -95,6 +95,8 @@ static struct nla_policy nl80211_policy[ [NL80211_ATTR_BSS_CTS_PROT] = { .type = NLA_U8 }, [NL80211_ATTR_BSS_SHORT_PREAMBLE] = { .type = NLA_U8 }, [NL80211_ATTR_BSS_SHORT_SLOT_TIME] = { .type = NLA_U8 }, + [NL80211_ATTR_BSS_BASIC_RATES] = { .type = NLA_BINARY, + .len = NL80211_MAX_SUPP_RATES }, [NL80211_ATTR_MESH_PARAMS] = { .type = NLA_NESTED },@@ -1613,6 +1615,12 @@ static int nl80211_set_bss(struct sk_bufif (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME ]) params.use_short_slot_time =nla_get_u8 (info->attrs[NL80211_ATTR_BSS_SHORT_SLOT_TIME ]); +if (info->attrs[NL80211_ATTR_BSS_BASIC_RATES ]) { + params.basic_rates = +nla_data (info->attrs[NL80211_ATTR_BSS_BASIC_RATES ]); + params.basic_rates_len = +nla_len (info->attrs[NL80211_ATTR_BSS_BASIC_RATES ]); + } err =get_drv_dev_by_info_ifindex (info->attrs, &drv, &dev);if (err) --Signature · 2 lines
-- Jouni Malinen PGP id EFC895FA
PATCH 3/4 mac80211_hwsim: Debug info for TX queue parameters
In reply to Jouni MalinenProvide detailed information on TX queue parameter changes to make it easier to debug mac80211 functionality.
drivers/net/wireless/mac80211_hwsim.c +12 -0
@@ -468,6 +468,17 @@return 0 ; } +static int mac80211_hwsim_conf_tx ( +struct ieee80211_hw *hw,u16 queue, +const struct ieee80211_tx_queue_params *params) +{ +printk (KERN_DEBUG "%s:%s (queue=%d txop=%d cw_min=%d cw_max=%d " +"aifs=%d)\n" , +wiphy_name (hw->wiphy), __func__, queue, + params->txop, params->cw_min, params->cw_max, params->aifs); +return 0 ; +} +static const struct ieee80211_ops mac80211_hwsim_ops = { .tx = mac80211_hwsim_tx,
@@ -481,6 +492,7 @@ .bss_info_changed = mac80211_hwsim_bss_info_changed, .sta_notify = mac80211_hwsim_sta_notify, .set_tim = mac80211_hwsim_set_tim, + .conf_tx = mac80211_hwsim_conf_tx, };
--
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Re: [PATCH 3/4] mac80211_hwsim: Debug info for TX queue parameters
Quoted 5 lines · Jouni Malinen
plain text document attachment (hwsim_tx_conf.patch) Provide detailed information on TX queue parameter changes to make it easier to debug mac80211 functionality.
Signed-off-by Jouni Malinen <[email protected]>
Quoted 33 lines
Index:
wireless-testing/drivers/net/wireless/mac80211_hwsim.c
===================================================================drivers/net/wireless/mac80211_hwsim.c +12
-1@@ -468,6 +468,17 @@return 0 ; } +static int mac80211_hwsim_conf_tx ( +struct ieee80211_hw *hw,u16 queue, +const struct ieee80211_tx_queue_params *params) +{ +printk (KERN_DEBUG "%s:%s (queue=%d txop=%d cw_min=%d cw_max=%d " +"aifs=%d)\n" , +wiphy_name (hw->wiphy), __func__, queue, + params->txop, params->cw_min, params->cw_max, params->aifs); +return 0 ; +} +static const struct ieee80211_ops mac80211_hwsim_ops = { .tx = mac80211_hwsim_tx,@@ -481,6 +492,7 @@ .bss_info_changed = mac80211_hwsim_bss_info_changed, .sta_notify = mac80211_hwsim_sta_notify, .set_tim = mac80211_hwsim_set_tim, + .conf_tx = mac80211_hwsim_conf_tx, }; --
PATCH 4/4 nl80211: Add TX queue parameter configuration
In reply to Jouni MalinenAdd a new attribute, NL80211_ATTR_WIPHY_TXQ_PARAMS, that can be used with NL80211_CMD_SET_WIPHY for userspace (e.g., hostapd) to set TX queue parameters (txop, cwmin, cwmax, aifs).
include/linux/nl80211.h +38 -2
@@ -25,8 +25,9 @@* * @NL80211_CMD_GET_WIPHY: request information about a wiphy or dump request * to get a list of all present wiphys. -* @NL80211_CMD_SET_WIPHY: set wiphy name, needs %NL80211_ATTR_WIPHY and -* %NL80211_ATTR_WIPHY_NAME. +* @NL80211_CMD_SET_WIPHY: set wiphy parameters, needs %NL80211_ATTR_WIPHY or +* %NL80211_ATTR_IFINDEX; can be used to set %NL80211_ATTR_WIPHY_NAME +* and/or %NL80211_ATTR_WIPHY_TXQ_PARAMS. * @NL80211_CMD_NEW_WIPHY: Newly created wiphy, response to get request * or rename notification. Has attributes %NL80211_ATTR_WIPHY and * %NL80211_ATTR_WIPHY_NAME.
@@ -178,6 +179,7 @@ enum nl80211_commands {* @NL80211_ATTR_WIPHY: index of wiphy to operate on, cf. * /sys/class/ieee80211/<phyname>/index * @NL80211_ATTR_WIPHY_NAME: wiphy name (used for renaming) +* @NL80211_ATTR_WIPHY_TXQ_PARAMS: a nested array of TX queue parameters * * @NL80211_ATTR_IFINDEX: network interface index of the device to operate on * @NL80211_ATTR_IFNAME: network interface name
@@ -312,6 +314,8 @@ enum nl80211_attrs {NL80211_ATTR_BSS_BASIC_RATES , +NL80211_ATTR_WIPHY_TXQ_PARAMS , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -324,6 +328,7 @@ enum nl80211_attrs {*/ #define NL80211_ATTR_HT_CAPABILITY NL80211_ATTR_HT_CAPABILITY#define NL80211_ATTR_BSS_BASIC_RATES NL80211_ATTR_BSS_BASIC_RATES +#define NL80211_ATTR_WIPHY_TXQ_PARAMS NL80211_ATTR_WIPHY_TXQ_PARAMS#define NL80211_MAX_SUPP_RATES 32#define NL80211_MAX_SUPP_REG_RULES 32
@@ -698,4 +703,35 @@ enum nl80211_meshconf_params {NL80211_MESHCONF_ATTR_MAX = __NL80211_MESHCONF_ATTR_AFTER_LAST -1 }; +/** +* enum nl80211_txq_attr - TX queue parameter attributes +* @NL80211_TXQ_ATTR_QUEUE: TX queue identifier (NL80211_TXQ_Q_*) +* @NL80211_TXQ_ATTR_TXOP: Maximum burst time in units of 32 usecs, 0 meaning +* disabled +* @NL80211_TXQ_ATTR_CWMIN: Minimum contention window [a value of the form +* 2^n-1 in the range 1..32767] +* @NL80211_TXQ_ATTR_CWMAX: Maximum contention window [a value of the form +* 2^n-1 in the range 1..32767] +* @NL80211_TXQ_ATTR_AIFS: Arbitration interframe space [0..255] +*/ +enum nl80211_txq_attr { + __NL80211_TXQ_ATTR_INVALID, +NL80211_TXQ_ATTR_QUEUE , +NL80211_TXQ_ATTR_TXOP , +NL80211_TXQ_ATTR_CWMIN , +NL80211_TXQ_ATTR_CWMAX , +NL80211_TXQ_ATTR_AIFS , + +/* keep last */ + __NL80211_TXQ_ATTR_AFTER_LAST, +NL80211_TXQ_ATTR_MAX = __NL80211_TXQ_ATTR_AFTER_LAST -1 +}; + +enum nl80211_txq_q { +NL80211_TXQ_Q_VO , +NL80211_TXQ_Q_VI , +NL80211_TXQ_Q_BE , +NL80211_TXQ_Q_BK +}; +#endif /* __LINUX_NL80211_H */
include/net/cfg80211.h +13 -0
@@ -371,6 +371,14 @@ struct mesh_config {u16 dot11MeshHWMPnetDiameterTraversalTime; }; +struct ieee80211_txq_params { +u8 queue; +u16 txop; +u16 cwmin; +u16 cwmax; +u8 aifs; +}; +/* from net/wireless.h */ struct wiphy ;
@@ -430,6 +438,8 @@ struct wiphy;* @set_mesh_cfg: set mesh parameters (by now, just mesh id) * * @change_bss: Modify parameters for a given BSS. +* +* @set_txq_params: Set TX queue parameters */ struct cfg80211_ops { int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
@@ -490,6 +500,9 @@ struct cfg80211_ops { const struct mesh_config *nconf, u32 mask);int (*change_bss)(struct wiphy *wiphy,struct net_device *dev,struct bss_parameters *params); + +int (*set_txq_params)(struct wiphy *wiphy, + struct ieee80211_txq_params *params); };#endif /* __NET_CFG80211_H */
net/mac80211/cfg.c +25 -0
@@ -1069,6 +1069,30 @@ static int ieee80211_change_bss(struct wreturn 0 ; } +static int ieee80211_set_txq_params (struct wiphy *wiphy, +struct ieee80211_txq_params *params) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); +struct ieee80211_tx_queue_params p; + +if (!local->ops->conf_tx) +return -EOPNOTSUPP ; + +memset (&p,0 ,sizeof (p)); + p.aifs = params->aifs; + p.cw_max = params->cwmax; + p.cw_min = params->cwmin; + p.txop = params->txop; +if (local->ops->conf_tx (local_to_hw (local), params->queue, &p)) { +printk (KERN_DEBUG "%s: failed to set TX queue " +"parameters for queue %d\n" , local->mdev->name, + params->queue); +return -EINVAL ; + } + +return 0 ; +} +struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -1095,4 +1119,5 @@ struct cfg80211_ops mac80211_config_ops .get_mesh_params = ieee80211_get_mesh_params, #endif .change_bss = ieee80211_change_bss, + .set_txq_params = ieee80211_set_txq_params, };
net/wireless/nl80211.c +62 -5
88 lines not on this page · raw message
--
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerRe: [PATCH 4/4] nl80211: Add TX queue parameter configuration
Quoted 9 lines · Jouni Malinen
+ * enum
nl80211_txq_attr- TX queue parameter attributes
+ * @NL80211_TXQ_ATTR_QUEUE: TX queue identifier (NL80211_TXQ_Q_*)
+ * @NL80211_TXQ_ATTR_TXOP: Maximum burst time in units of 32 usecs, 0 meaning
+ * disabled
+ * @NL80211_TXQ_ATTR_CWMIN: Minimum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_CWMAX: Maximum contention window [a value of the form
+ * 2^n-1 in the range 1..32767]
+ * @NL80211_TXQ_ATTR_AIFS: Arbitration interframe space [0..255]
You have to add the invalid, after_last and max to the kernel-doc too otherwise it'll warn about it.
include/net/cfg80211.h struct mesh_config { · line 380
Quoted 8 lines
include/net/cfg80211.h +7
-0+struct ieee80211_txq_params { +u8 queue; +u16 txop; +u16 cwmin; +u16 cwmax; +u8 aifs; +};
Maybe add some kernel-doc describing the units etc.? And describing which values are valid for 'queue' (or should that use the enum VO/VI/...?)
Quoted 9 lines
net/wireless/nl80211.c +9
-0+if (info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS ]) { +struct ieee80211_txq_params txq_params; +struct nlattr *tb[NL80211_TXQ_ATTR_MAX +1 ]; + +nla_for_each_nested (nl_txq_params, + info->attrs[NL80211_ATTR_WIPHY_TXQ_PARAMS ], + rem_txq_params) { + nla_parse(tb, NL80211_TXQ_ATTR_MAX, + nla_data(nl_txq_params),
net/wireless/nl80211.c static int nl80211_get_wiphy(struct sk_b · line 350
Quoted 10 lines
net/wireless/nl80211.c +10
-0+nla_len (nl_txq_params), + txq_params_policy); + result =parse_txq_params (tb, &txq_params); +if (result) + goto bad_res; + +if (!rdev->ops->set_txq_params) { + result = -EOPNOTSUPP ; + goto bad_res; + }
Seems you could do that check outside the loop?
Otherwise looks good to me, thanks.
johannes