mac80211/cfg80211: Add BSS configuration options for AP mode
Subsystems (2)
RFC 1/1 mac80211/cfg80211: Add BSS configuration options for AP mode
I've been looking at adding some of the missing configuration options to allow AP mode in mac80211 to remain in sync with hostapd. The patch below introduces a new cfg80211 command for setting BSS parameters and adds three initial attributes for this command (CTS protection, short preamble, short slot time). I would expect CTS protection and short preamble to work as-is, but short slot time will need some more code to notify the driver that it needs to change configuration. Based on a quick test with hostapd, it looks like these parameters can be successfully passed from there to mac80211.
Could you please take a quick look at whether this looks like a correct way of introducing new functionality into cfg80211? I'll finish the short slot time part in mac80211 and post an updated patch as a proper submission later.
include/net/cfg80211.h +22 -0
@@ -270,6 +270,23 @@ struct mpath_info {u8 flags; }; +/** +* struct bss_parameters - BSS parameters +* +* Used to change BSS parameters (mainly for AP mode). +* +* @use_cts_prot: Whether to use CTS protection +* (0 = no, 1 = yes, -1 = do not change) +* @use_short_preamble: Whether the use of short preambles is allowed +* (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) +*/ +struct bss_parameters { +int use_cts_prot; +int use_short_preamble; +int use_short_slot_time; +};/* from net/wireless.h */ struct wiphy ;
@@ -322,6 +339,8 @@ struct wiphy;* @change_station: Modify a given station. * * @set_mesh_cfg: set mesh parameters (by now, just mesh id) +* +* @change_bss: Modify parameters for a given BSS. */ struct cfg80211_ops { int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
@@ -377,6 +396,9 @@ struct cfg80211_ops {int (*dump_mpath)(struct wiphy *wiphy,struct net_device *dev,int idx,u8 *dst,u8 *next_hop,struct mpath_info *pinfo); + +int (*change_bss)(struct wiphy *wiphy,struct net_device *dev, + struct bss_parameters *params); };#endif /* __NET_CFG80211_H */
net/mac80211/cfg.c +30 -0
@@ -1055,6 +1055,35 @@ static int ieee80211_dump_mpath(struct w }#endif +static int ieee80211_change_bss (struct wiphy *wiphy, +struct net_device *dev, +struct bss_parameters *params) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); +struct ieee80211_sub_if_data *sdata; + +if (dev == local->mdev) +return -EOPNOTSUPP ; + + sdata =IEEE80211_DEV_TO_SUB_IF (dev); + +printk (KERN_DEBUG "JKM-%s: cts=%d preamble=%d slot=%d\n" , + __func__, params->use_cts_prot, params->use_short_preamble, + params->use_short_slot_time); +if (params->use_cts_prot >=0 ) + sdata->bss_conf.use_cts_prot = params->use_cts_prot; +if (params->use_short_preamble >=0 ) + sdata->bss_conf.use_short_preamble = + params->use_short_preamble; +#if 0 /* TODO: need to notify low-level driver */ +if (params->use_short_slot_time >=0 ) + sdata->bss_conf.use_short_slot_time = + params->use_short_slot_time; +#endif + +return 0 ; +} +struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -1079,4 +1108,5 @@ struct cfg80211_ops mac80211_config_ops .get_mpath = ieee80211_get_mpath, .dump_mpath = ieee80211_dump_mpath, #endif + .change_bss = ieee80211_change_bss, };
include/linux/nl80211.h +19 -0
@@ -89,6 +89,8 @@* @NL80211_CMD_DEL_PATH: Remove a mesh path identified by %NL80211_ATTR_MAC * or, if no MAC address given, all mesh paths, on the interface identified * by %NL80211_ATTR_IFINDEX. +* @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by +* %NL80211_ATTR_IFINDEX. * * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use
@@ -127,6 +129,8 @@ enum nl80211_commands {NL80211_CMD_NEW_MPATH ,NL80211_CMD_DEL_MPATH , + NL80211_CMD_SET_BSS, +/* add commands here */ /* used to define NL80211_CMD_MAX below */
@@ -134,6 +138,11 @@ enum nl80211_commands { NL80211_CMD_MAX = __NL80211_CMD_AFTER_LAST - 1 }; +/* +* Allow user space programs to use #ifdef on new commands by defining them +* here +*/ +#define NL80211_CMD_SET_BSS NL80211_CMD_SET_BSS/** * enum nl80211_attrs - nl80211 netlink attributes
@@ -192,6 +201,12 @@ enum nl80211_commands {* @NL80211_ATTR_MNTR_FLAGS: flags, nested element with NLA_FLAG attributes of * &enum nl80211_mntr_flags. * +* @NL80211_ATTR_BSS_CTS_PROT: whether CTS protection is enabled (u8, 0 or 1) +* @NL80211_ATTR_BSS_SHORT_PREAMBLE: whether short preamble is enabled +* (u8, 0 or 1) +* @NL80211_ATTR_BSS_SHORT_SLOT_TIME: whether short slot time enabled +* (u8, 0 or 1) +* * @NL80211_ATTR_MAX: highest attribute number currently defined * @__NL80211_ATTR_AFTER_LAST: internal use */
@@ -237,6 +252,10 @@ enum nl80211_attrs {NL80211_ATTR_KEY_DEFAULT_MGMT , +NL80211_ATTR_BSS_CTS_PROT , +NL80211_ATTR_BSS_SHORT_PREAMBLE , +NL80211_ATTR_BSS_SHORT_SLOT_TIME , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
net/wireless/nl80211.c +52 -0
70 lines not on this page · raw message
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerThanks.
Quoted 4 lines
Could you please take a quick look at whether this looks like a correct way of introducing new functionality into cfg80211? I'll finish the short slot time part in mac80211 and post an updated patch as a proper submission later.
I used to have a patch to move the short-slot stuff in mac80211 to the BSS info struct so that drivers that support different slot timing for each frame can use it for different virtual BSSes. It no longer applies though:
net/mac80211/cfg.c static int ieee80211_dump_mpath(struct w · line 1068
Quoted 11 lines
net/mac80211/cfg.c +11
-0+static int ieee80211_change_bss (struct wiphy *wiphy, +struct net_device *dev, +struct bss_parameters *params) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); +struct ieee80211_sub_if_data *sdata; + +if (dev == local->mdev) +return -EOPNOTSUPP ; + + sdata =IEEE80211_DEV_TO_SUB_IF (dev);
I think you may need to handle the case where dev is a VLAN? Or do we want to have these settings per VLAN too? And should we reject them for other modes than AP where the AP controls the settings?
Quoted 2 lines
+ * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
+ * %NL80211_ATTR_IFINDEX.
Maybe we should have a way to retrieve the settings as well, and that could even work in STA mode to see what the AP asked us to do.
Other than that, looks good to me.
johannes
Quoted 6 lines · Johannes Berg
I used to have a patch to move the short-slot stuff in mac80211 to the BSS info struct so that drivers that support different slot timing for each frame can use it for different virtual BSSes. It no longer applies though:
I'll take a look at this. I hoped I would not need to go through all drivers to update the API ;-), but let's see.
Quoted 3 lines
I think you may need to handle the case where dev is a VLAN? Or do we want to have these settings per VLAN too? And should we reject them for other modes than AP where the AP controls the settings?
I was thinking about this a bit, but since ieee80211_sub_if_data had them shared for all types on interfaces and there might be some testing uses for these even outside AP mode, I did not bother adding extra validation here. At least the three parameters added here won't be per-VLAN since they are advertised in Beacon frames. Though, maybe the easiest option would be to limit this for IEEE80211_IF_TYPE_AP for now..
Quoted 5 lines
Quoted 2 lines
+ * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
+ * %NL80211_ATTR_IFINDEX.Maybe we should have a way to retrieve the settings as well, and that could even work in STA mode to see what the AP asked us to do.
I did not see any normal use case for this, i.e., this would be more like debug information. CTS protection is already exported via debugfs and the other parameters could fit in there better, too.
Quoted 1 line
Other than that, looks good to me.
Thanks!
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerQuoted 11 lines · Jouni Malinen
Quoted 6 lines · Johannes Berg
I used to have a patch to move the short-slot stuff in mac80211 to the BSS info struct so that drivers that support different slot timing for each frame can use it for different virtual BSSes. It no longer applies though:
I'll take a look at this. I hoped I would not need to go through all drivers to update the API ;-), but let's see.
Yeah, that was a sticky point... But if you want per-BSS information you really have to because right now it's per-hw.
Quoted 10 lines
Quoted 3 lines
I think you may need to handle the case where dev is a VLAN? Or do we want to have these settings per VLAN too? And should we reject them for other modes than AP where the AP controls the settings?
I was thinking about this a bit, but since
ieee80211_sub_if_datahad them shared for all types on interfaces and there might be some testing uses for these even outside AP mode, I did not bother adding extra validation here. At least the three parameters added here won't be per-VLAN since they are advertised in Beacon frames. Though, maybe the easiest option would be to limit this forIEEE80211_IF_TYPE_APfor now..
Ok, they can't be per VLAN then, true, but then I think we should limit it to _AP just so nobody tries setting them without effect on other devices or overrides, for _STA, what the AP said. For mesh I don't know (adding Luis) and for IBSS I'm not sure either. I suspect you could use it for IBSS too?
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
+ * @NL80211_CMD_SET_BSS: Set BSS attributes for BSS identified by
+ * %NL80211_ATTR_IFINDEX.Maybe we should have a way to retrieve the settings as well, and that could even work in STA mode to see what the AP asked us to do.
I did not see any normal use case for this, i.e., this would be more like debug information. CTS protection is already exported via debugfs and the other parameters could fit in there better, too.
True, there's little value in this information for regular use.
johannes
Quoted 8 lines · Johannes Berg
Quoted 4 lines · Jouni Malinen
Quoted 3 lines · Johannes Berg
I used to have a patch to move the short-slot stuff in mac80211 to the BSS info struct so that drivers that support different slot timing for each frame can use it for different virtual BSSes.
Yeah, that was a sticky point... But if you want per-BSS information you really have to because right now it's per-hw.
Well, I don't actually need it per-BSS for hardware that I'm most likely to work with ;-), but yeah, this is a per-BSS parameter, so in that sense your patch is doing the correct thing.
Quoted 5 lines
Ok, they can't be per VLAN then, true, but then I think we should limit it to
_APjust so nobody tries setting them without effect on other devices or overrides, for_STA, what the AP said. For mesh I don't know (adding Luis) and for IBSS I'm not sure either. I suspect you could use it for IBSS too?
I think I'll just make it _AP only for now and if someone ever really needs it for something else, they can enable it later.. It is possible that new attributes that would be more reasonable for other modes will be added in the future for _SET_BSS.
As far as IBSS is concerned, short slot time is disabled (802.11-2007, 19.4.4). Similarly, it is somewhat difficult to require the STAs in an IBSS to control this type of disable-if-anyone-does-not-support features. It is more likely to end up being first-STA-to-create-IBSS-wins situation. Anyway, we do not have user space IBSS control daemon anyway, so this is something that is not needed yet.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerQuoted 6 lines · Jouni Malinen
Quoted 2 lines
Yeah, that was a sticky point... But if you want per-BSS information you really have to because right now it's per-hw.
Well, I don't actually need it per-BSS for hardware that I'm most likely to work with ;-), but yeah, this is a per-BSS parameter, so in that sense your patch is doing the correct thing.
Yeah, ok, I guess I don't really care, do whichever way you want. It'd be a bit strange to set it with cfg80211 per BSS and have it show up on different BSSes, but that's about it, and a little strangeness hasn't hurt anyone ;)
Quoted 10 lines
Quoted 5 lines
Ok, they can't be per VLAN then, true, but then I think we should limit it to
_APjust so nobody tries setting them without effect on other devices or overrides, for_STA, what the AP said. For mesh I don't know (adding Luis) and for IBSS I'm not sure either. I suspect you could use it for IBSS too?I think I'll just make it
_APonly for now and if someone ever really needs it for something else, they can enable it later.. It is possible that new attributes that would be more reasonable for other modes will be added in the future for_SET_BSS.
Sure, sounds fine.
johannes
Quoted 9 lines · Johannes Berg
Quoted 3 lines · Jouni Malinen
Well, I don't actually need it per-BSS for hardware that I'm most likely to work with ;-), but yeah, this is a per-BSS parameter, so in that sense your patch is doing the correct thing.
Yeah, ok, I guess I don't really care, do whichever way you want. It'd be a bit strange to set it with cfg80211 per BSS and have it show up on different BSSes, but that's about it, and a little strangeness hasn't hurt anyone ;)
It looks like it is easiest to make this a per-BSS parameter now and use bss_info_changed() for it. However, I'm planning on leaving the other parts of your patch out from the initial version. In other words, I will not remove IEEE80211_CONF_SHORT_SLOT_TIME now (I just added a TODO note to get it removed once drivers have been converted; mac80211 was never actually setting this, anyway). This avoids the need to modify all drivers with this change. In addition, I'm leaving out the client MLME stuff for now, but the notification part will be available for it once the MLME code is added.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerinclude/linux/nl80211.h enum nl80211_attrs { · line 257
Quoted 4 lines
include/linux/nl80211.h +3
-0+NL80211_ATTR_BSS_CTS_PROT , +NL80211_ATTR_BSS_SHORT_PREAMBLE , + NL80211_ATTR_BSS_SHORT_SLOT_TIME,
Oh another idea I just had, I suspect we should use these to indicate support for the features too, on the wiphy info query result or something. Only tangentially related to this patch though.
johannes
Quoted 5 lines · Johannes Berg
include/linux/nl80211.h enum nl80211_attrs { · line 257
Quoted 1 line
include/linux/nl80211.h +1
-0+ NL80211_ATTR_BSS_SHORT_SLOT_TIME,Oh another idea I just had, I suspect we should use these to indicate support for the features too, on the wiphy info query result or something. Only tangentially related to this patch though.
Sounds reasonable. So far, I've mainly worked with hardware that supports these, so I have just assumed that everything is fine and haven't bothered dynamically trying to decide what to do in hostapd. Or well, it was possible to configure this in hostapd.conf (though, it looks like that was never actually merged into the open source version completely, so the variable is there, but not a way to enable it; have to fix that at some point, I guess..).
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerQuoted 8 lines · Jouni Malinen
Quoted 5 lines · Johannes Berg
include/linux/nl80211.h enum nl80211_attrs { · line 257
Quoted 1 line
include/linux/nl80211.h +1
-0+ NL80211_ATTR_BSS_SHORT_SLOT_TIME,Oh another idea I just had, I suspect we should use these to indicate support for the features too, on the wiphy info query result or something. Only tangentially related to this patch though.
Quoted 7 lines
Sounds reasonable. So far, I've mainly worked with hardware that supports these, so I have just assumed that everything is fine and haven't bothered dynamically trying to decide what to do in hostapd. Or well, it was possible to configure this in hostapd.conf (though, it looks like that was never actually merged into the open source version completely, so the variable is there, but not a way to enable it; have to fix that at some point, I guess..).
Ok, I think the only hardware we currently support that doesn't have these doesn't support AP mode either, so it's probably not really worth it now...
johannes