d80211: Add support for user space client MLME
Subsystems (3)
PATCH 1/1 d80211: Add support for user space client MLME
Add a configuration option for disabling client MLME in kernel code. This is used to enable user space MLME for client mode (e.g., with wpa_supplicant). The kernel MLME implementation is unmodified, but it could be removed or at least made optional in build configuration in the future.
net/d80211/hostapd_ioctl.h +1 -0
@@ -91,6 +91,7 @@ enum {PRISM2_PARAM_KEY_MGMT =1040 ,PRISM2_PARAM_RADAR_DETECT =1043 ,PRISM2_PARAM_SPECTRUM_MGMT =1044 , +PRISM2_PARAM_USER_SPACE_MLME =1045 ,/* NOTE: Please try to coordinate with other active development * branches before allocating new param numbers so that each new param * will be unique within all branches and the allocated number will not
net/d80211/ieee80211.c +3 -2
@@ -3116,8 +3116,9 @@ ieee80211_rx_h_mgmt(struct ieee80211_txr {struct ieee80211_sub_if_data *sdata; sdata =IEEE80211_DEV_TO_SUB_IF (rx->dev); -if (sdata->type ==IEEE80211_IF_TYPE_STA || - sdata->type ==IEEE80211_IF_TYPE_IBSS ) { +if ((sdata->type ==IEEE80211_IF_TYPE_STA || + sdata->type ==IEEE80211_IF_TYPE_IBSS ) && + !rx->local->user_space_mlme) {ieee80211_sta_rx_mgmt (rx->dev, rx->skb, rx->u.rx.status); }else {/* Management frames are sent to hostapd for processing */
net/d80211/ieee80211_ioctl.c +34 -1
@@ -1048,10 +1048,14 @@ static int ieee80211_ioctl_scan_req(stru struct prism2_hostapd_param *param, int param_len) { +struct ieee80211_local *local = dev->priv;u8 *pos = param->u.scan_req.ssid;int left = param_len - ((u8 *) pos - (u8 *) param);int len = param->u.scan_req.ssid_len; +if (local->user_space_mlme) +return -EOPNOTSUPP ; +if (left < len || len >IEEE80211_MAX_SSID_LEN )return -EINVAL ;
@@ -1076,8 +1080,12 @@ static int ieee80211_ioctl_sta_get_statestatic int ieee80211_ioctl_mlme (struct net_device *dev,struct prism2_hostapd_param *param) { +struct ieee80211_local *local = dev->priv;struct ieee80211_sub_if_data *sdata; +if (local->user_space_mlme) +return -EOPNOTSUPP ; + sdata =IEEE80211_DEV_TO_SUB_IF (dev);if (sdata->type !=IEEE80211_IF_TYPE_STA && sdata->type !=IEEE80211_IF_TYPE_IBSS )
@@ -1136,6 +1144,10 @@ static int ieee80211_ioctl_set_sta_vlan(static int ieee80211_set_gen_ie (struct net_device *dev,u8 *ie,size_t len) {struct ieee80211_sub_if_data *sdata; +struct ieee80211_local *local = dev->priv; + +if (local->user_space_mlme) +return -EOPNOTSUPP ; sdata =IEEE80211_DEV_TO_SUB_IF (dev); if (sdata->type == IEEE80211_IF_TYPE_STA ||
@@ -1745,6 +1757,7 @@ static int ieee80211_ioctl_siwessid(strustruct iw_request_info *info, struct iw_point *data, char *ssid) { + struct ieee80211_local *local = dev->priv;struct ieee80211_sub_if_data *sdata;size_t len = data->length;
@@ -1754,8 +1767,16 @@ static int ieee80211_ioctl_siwessid(stru sdata =IEEE80211_DEV_TO_SUB_IF (dev);if (sdata->type ==IEEE80211_IF_TYPE_STA || - sdata->type ==IEEE80211_IF_TYPE_IBSS ) + sdata->type ==IEEE80211_IF_TYPE_IBSS ) { +if (local->user_space_mlme) { +if (len >IEEE80211_MAX_SSID_LEN ) +return -EINVAL ; +memcpy (sdata->u.sta.ssid, ssid, len); + sdata->u.sta.ssid_len = len; +return 0 ; + }return ieee80211_sta_set_ssid (dev, ssid, len); + }if (sdata->type ==IEEE80211_IF_TYPE_AP ) {memcpy (sdata->u.ap.ssid, ssid, len);
@@ -1804,11 +1825,17 @@ static int ieee80211_ioctl_siwap(structstruct iw_request_info *info, struct sockaddr *ap_addr, char *extra) { + struct ieee80211_local *local = dev->priv;struct ieee80211_sub_if_data *sdata; sdata =IEEE80211_DEV_TO_SUB_IF (dev);if (sdata->type ==IEEE80211_IF_TYPE_STA || sdata->type ==IEEE80211_IF_TYPE_IBSS ) { +if (local->user_space_mlme) { +memcpy (sdata->u.sta.bssid, (u8 *) &ap_addr->sa_data, +ETH_ALEN ); +return 0 ; + }return ieee80211_sta_set_bssid (dev, (u8 *) &ap_addr->sa_data); }else if (sdata->type ==IEEE80211_IF_TYPE_WDS ) { if (memcmp(sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data,
@@ -2469,6 +2496,9 @@ static int ieee80211_ioctl_prism2_param(case PRISM2_PARAM_SPECTRUM_MGMT : local->conf.spect_mgmt = value;break ; +case PRISM2_PARAM_USER_SPACE_MLME : + local->user_space_mlme = value; +break ;default : ret = -EOPNOTSUPP ;break ;
@@ -2651,6 +2681,9 @@ static int ieee80211_ioctl_get_prism2_paelse *param = !!sdata->u.sta.wmm_enabled;break ; +case PRISM2_PARAM_USER_SPACE_MLME : + *param = local->user_space_mlme; +break ;default : ret = -EOPNOTSUPP ;
net/d80211/ieee80211_i.h +2 -0
@@ -502,6 +502,8 @@ struct ieee80211_local {unsigned int hw_modes;/* bitfield of allowed hardware modes; * (1 << MODE_*) */ + +int user_space_mlme; };
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Quoted 5 lines · Jouni Malinen
Add a configuration option for disabling client MLME in kernel code. This is used to enable user space MLME for client mode (e.g., with
wpa_supplicant). The kernel MLME implementation is unmodified, but it could be removed or at least made optional in build configuration in the future.
It is too early for this. We need to implement some better communication interface between kernel and hostapd (or what will implement userspace MLME) first. The current solution, where there is some special net_device interface (wmaster0ap) abused to dump informations to userspace, is ugly and confusing for users.
There is no userspace MLME implementation yet. And if one is going to be written, I'm really convinced it should be written in a clean way. I think Simon said he would examine a possibility to convert this stuff to netlink - is there some progress there?
Also, I'm not sure how fullmac cards could be (potentially) supported with this approach.
Thanks,
Jiri
Signature · 2 lines
Jiri Benc SUSE Labs
Quoted 5 lines · Jiri Benc
It is too early for this. We need to implement some better communication interface between kernel and hostapd (or what will implement userspace MLME) first. The current solution, where there is some special
net_deviceinterface (wmaster0ap) abused to dump informations to userspace, is ugly and confusing for users.
Why do you think that this would be too early now? I agree that the interface between kernel and user space MLME can be improved, but I see no point in making client MLME implementation wait for that to happen. Personally, I don't think that the wmaster#ap interface is really that ugly, but I have nothing against this being improved if someone has time for doing it. I just don't see it as the highest priority.
Quoted 4 lines
There is no userspace MLME implementation yet. And if one is going to be written, I'm really convinced it should be written in a clean way. I think Simon said he would examine a possibility to convert this stuff to netlink - is there some progress there?
But there is.. I committed changes to the wpa_supplicant devel branch for this yesterday. It seems to work fine with net/d80211 and bcm43xx with this small patch to d80211 to allow the functionality to be moved into user space.
I have not yet heard of anyone working with details of converting the management frame communication to use netlink.
Quoted 2 lines
Also, I'm not sure how fullmac cards could be (potentially) supported with this approach.
In the same way as with the kernel space MLME implementation.. This does not really change regardless of where the MLME code is implemented. Some time ago, I sent a preliminary patch showing what kind of changes are needed and this was mainly avoiding calls to some ieee80211_sta.c functions.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Quoted 6 lines · Jouni Malinen
Why do you think that this would be too early now? I agree that the interface between kernel and user space MLME can be improved, but I see no point in making client MLME implementation wait for that to happen. Personally, I don't think that the wmaster#ap interface is really that ugly, but I have nothing against this being improved if someone has time for doing it. I just don't see it as the highest priority.
On the other hand, I'm afraid it will be hard to explain to users why there are all these network interfaces (wmaster0, wmaster0ap) they shouldn't touch at all. I'm trying to reduce those interfaces as much as possible. We cannot avoid wmaster0, but we can avoid wmaster0ap. So I see the new kernel->hostapd (wpa_supplicant) interface as a rather high priority.
Quoted 4 lines
But there is.. I committed changes to the
wpa_supplicantdevel branch for this yesterday. It seems to work fine with net/d80211 and bcm43xx with this small patch to d80211 to allow the functionality to be moved into user space.
Oh, sorry, didn't know that.
If you really feel this is a necessary feature (although I think we should focus more on putting the stack to a form suitable for inclusion in the kernel than on adding new features now), what about making the wmaster0ap interface appear only when the device is switched to user space MLME? Should I make a patch?
Quoted 2 lines
I have not yet heard of anyone working with details of converting the management frame communication to use netlink.
With details - no, neither have I.
Quoted 5 lines
Quoted 2 lines
Also, I'm not sure how fullmac cards could be (potentially) supported with this approach.
In the same way as with the kernel space MLME implementation.. This does not really change regardless of where the MLME code is implemented.
I had in mind cards with large parts of MLME implemented in their firmware, when MLME is moved from the stack fully to userspace. Such cards probably won't allow you to handle e. g. scanning by switching channels and sending probe requests. I know, we're not going to support them soon, but isn't this something that will disallow the suppport at all?
Or do I understand it wrong?
Quoted 3 lines
Some time ago, I sent a preliminary patch showing what kind of changes are needed and this was mainly avoiding calls to some
ieee80211_sta.cfunctions.
Hm, I probably missed that patch (or maybe just can't remember). Could you post a link or something?
Thanks,
Jiri
Signature · 2 lines
Jiri Benc SUSE Labs
Quoted 5 lines · Jiri Benc
If you really feel this is a necessary feature (although I think we should focus more on putting the stack to a form suitable for inclusion in the kernel than on adding new features now), what about making the wmaster0ap interface appear only when the device is switched to user space MLME? Should I make a patch?
I think it would be nice to get this in so that both client and AP modes can use the same mechanism (user space MLME); hostapd already needs this wmaster0ap interface. In other words, if we do not want to see that interface by default, we could just add a generic mechanism for registering wmaster0ap that both hostapd and wpa_supplicant could use. The Host AP driver (driver/net/wireless/hostap) is doing this with PRISM2_PARAM_HOSTAPD parameter. I don't care how it's done, but some simple mechanism would be preferred.
Quoted 6 lines
I had in mind cards with large parts of MLME implemented in their firmware, when MLME is moved from the stack fully to userspace. Such cards probably won't allow you to handle e. g. scanning by switching channels and sending probe requests. I know, we're not going to support them soon, but isn't this something that will disallow the suppport at all?
No, move of MLME to user space should not change this at all. As an example, wpa_supplicant supports both cases and the patch I'm working on for getting Prism2 (full MAC for client mode) working with d80211 is modifying the kernel side to allow this to be done. Both changes are touching the same areas in the code, but there is no major change in whether fullmac can be supported or not.
Quoted 6 lines
Quoted 3 lines
Some time ago, I sent a preliminary patch showing what kind of changes are needed and this was mainly avoiding calls to some
ieee80211_sta.cfunctions.Hm, I probably missed that patch (or maybe just can't remember). Could you post a link or something?
http://hostap.epitest.fi/releases/testing/jkm-wireless-dev-patches.tar.gz
That is not up-to-date with wireless-dev.git anymore, though. The key patch is d80211_fullmac_client.diff which is small enough to include here. Please note that this is not yet complete, so consider it more an example on what type of changes are needed.
d80211: Add support for hardware-based client MLME (fullmac)
Add support for using hardware/firmware-based client MLME (fullmac) into the Devicescape IEEE 802.11 stack. This adds a new flag, hw_client_mlme, for the low-level drivers to indicate that the client MLME (management frame processing) is implemented in hardware/firmware. This disables host-based MLME implementation for client mode.
In addition to changes in net/d80211, this patch fixes client mode for the Prism2/2.5/3 driver in drivers/net/wireless/d80211 by using the new mode of implementing client MLME in firmware. AP mode (Host AP) is still using host-based MLME.
drivers/net/wireless/d80211/prism3_hw.c +1 -0
@@ -2931,6 +2931,7 @@ static struct ieee80211_hw prism3_hw = { .version = IEEE80211_VERSION, .name = "prism3", .host_broadcast_ps_buffering = 1, + .hw_client_mlme = 1, .num_modes = 1, .num_modes = NUM_ENTRIES(prism3_hw_modes), .modes = prism3_hw_modes,
include/net/d80211.h +5 -1
@@ -441,7 +441,11 @@ struct ieee80211_hw {/* 1 = low-level driver supports skb fraglist (NETIF_F_FRAGLIST), i.e., * more than one skb per frame */ -unsigned int fraglist; + unsigned int fraglist:1; + +/* 0 = client MLME in host software (softmac) +* 1 = client MLME in hardware/firmware (fullmac) */ + unsigned int hw_client_mlme:1;/* This is the time in us to change channels */
net/d80211/ieee80211_ioctl.c +39 -3
110 lines not on this page · raw message
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Quoted 8 lines · Jouni Malinen
I think it would be nice to get this in so that both client and AP modes can use the same mechanism (user space MLME); hostapd already needs this wmaster0ap interface. In other words, if we do not want to see that interface by default, we could just add a generic mechanism for registering wmaster0ap that both hostapd and
wpa_supplicantcould use. The Host AP driver (driver/net/wireless/hostap) is doing this withPRISM2_PARAM_HOSTAPDparameter. I don't care how it's done, but some simple mechanism would be preferred.
Ok. So what about PRISM2_HOSTAPD_MGMT_IF ioctl that will add management interface (if not added yet) and return its ifindex? It would accept a boolean parameter (like PRISM2_PARAM_HOSTAPD) to add/remove that interface. If you agree with this, I will make a patch.
Of course, both hostapd and wpa_supplicant needs to be changed for that. This should not be a problem now as the d80211 stack is not in a common use yet.
Quoted 6 lines
No, move of MLME to user space should not change this at all. As an example,
wpa_supplicantsupports both cases and the patch I'm working on for getting Prism2 (full MAC for client mode) working with d80211 is modifying the kernel side to allow this to be done. Both changes are touching the same areas in the code, but there is no major change in whether fullmac can be supported or not.
So wpa_supplicant needs to know if the card is softmac or fullmac and behave accordingly, right?
Quoted 4 lines
That is not up-to-date with wireless-dev.git anymore, though. The key patch is d80211_fullmac_client.diff which is small enough to include here. Please note that this is not yet complete, so consider it more an example on what type of changes are needed.
Oh, thanks, now I remember, I have seen that.
Thanks,
Jiri
Signature · 2 lines
Jiri Benc SUSE Labs
Johannes Berg
maintainerQuoted 4 lines · Jouni Malinen
But there is.. I committed changes to the
wpa_supplicantdevel branch for this yesterday. It seems to work fine with net/d80211 and bcm43xx with this small patch to d80211 to allow the functionality to be moved into user space.
Cool, do you have a list of things that we need to support for it to work on a 'softmac' based driver (iow removing softmac in favour of this)?
Quoted 2 lines
I have not yet heard of anyone working with details of converting the management frame communication to use netlink.
I have an interest in this, as soon as I can I'll try writing up something.
johannes
Quoted 4 lines · Jiri Benc
Ok. So what about
PRISM2_HOSTAPD_MGMT_IFioctl that will add management interface (if not added yet) and return its ifindex? It would accept a boolean parameter (likePRISM2_PARAM_HOSTAPD) to add/remove that interface. If you agree with this, I will make a patch.
Yes, that would be fine.
Quoted 3 lines
Of course, both hostapd and
wpa_supplicantneeds to be changed for that. This should not be a problem now as the d80211 stack is not in a common use yet.
Sure, no problems with that at the moment.
Quoted 2 lines
So
wpa_supplicantneeds to know if the card is softmac or fullmac and behave accordingly, right?
Yes. Currently, I'm just using a configuration file parameter for this, but this information should eventually be exported by the kernel code to allow wpa_supplicant to select which mode to use without requiring user configuration.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerQuoted 4 lines · Jouni Malinen
Yes. Currently, I'm just using a configuration file parameter for this, but this information should eventually be exported by the kernel code to allow
wpa_supplicantto select which mode to use without requiring user configuration.
For the upcoming netlink interface, I'd suggest having a group of calls that are needed for full-mac devices (similar to the current wext) and a second group that are needed for soft-mlme, that way you simply try out one for the soft-mlme and if not implemented fall back to hard, or the other way around. Maybe.
johannes
PATCH 1/1 d80211: switching management interface on/off
In reply to Jouni MalinenDefault management interface (wmasterXap) confuses users. This patch removes it and gives userspace tools (such as hostapd or wpa_supplicant) possibility to switch it on/off as needed.
To do this, a new PRISM2_PARAM_MGMT_IF iwpriv ioctl is introduced. When set, it accepts one parameter: 1 for enabling the interface, 0 for disabling it. When read, it returns ifindex of the management interface or -ENOENT when the management interface is switched off.
---
net/d80211/hostapd_ioctl.h | 1 net/d80211/ieee80211.c | 101 ++++++++++++++++++------------------------- net/d80211/ieee80211_i.h | 3 + net/d80211/ieee80211_iface.c | 66 ++++++++++++++++++++++++++-- net/d80211/ieee80211_ioctl.c | 16 ++++++ 5 files changed, 127 insertions(+), 60 deletions(-)
net/d80211/hostapd_ioctl.h +1 -0
@@ -91,6 +91,7 @@ enum {PRISM2_PARAM_KEY_MGMT =1040 ,PRISM2_PARAM_RADAR_DETECT =1043 ,PRISM2_PARAM_SPECTRUM_MGMT =1044 , +PRISM2_PARAM_MGMT_IF =1045 ,/* NOTE: Please try to coordinate with other active development * branches before allocating new param numbers so that each new param * will be unique within all branches and the allocated number will not
net/d80211/ieee80211.c +44 -57
210 lines not on this page · raw message
net/d80211/ieee80211_i.h +3 -0
@@ -518,6 +518,7 @@ void ieee80211_prepare_rates(struct net_void ieee80211_tx_set_iswep (struct ieee80211_txrx_data *tx);int ieee80211_if_update_wds (struct net_device *dev,u8 *remote_addr);void ieee80211_if_setup (struct net_device *dev); +void ieee80211_if_mgmt_setup (struct net_device *dev);/* ieee80211_ioctl.c */ int ieee80211_ioctl (struct net_device *dev,struct ifreq *rq,int cmd);
@@ -595,6 +596,8 @@ int ieee80211_if_remove(struct net_devicvoid ieee80211_if_free (struct net_device *dev);void ieee80211_if_flush (struct net_device *dev);void ieee80211_if_sdata_init (struct ieee80211_sub_if_data *sdata); +int ieee80211_if_add_mgmt (struct net_device *dev); +void ieee80211_if_del_mgmt (struct net_device *dev);/* ieee80211_sysfs.c */ int ieee80211_register_sysfs (struct ieee80211_local *local);
net/d80211/ieee80211_iface.c +63 -3
89 lines not on this page · raw message
net/d80211/ieee80211_ioctl.c +16 -0
@@ -2471,6 +2471,16 @@ static int ieee80211_ioctl_prism2_param(case PRISM2_PARAM_SPECTRUM_MGMT : local->conf.spect_mgmt = value;break ; +case PRISM2_PARAM_MGMT_IF : +if (value ==1 ) { +if (local->apdev ==NULL ) + ret =ieee80211_if_add_mgmt (local->mdev); + }else if (value ==0 ) { +if (local->apdev) +ieee80211_if_del_mgmt (local->mdev); + }else + ret = -EINVAL ; +break ;default : ret = -EOPNOTSUPP ;break ;
@@ -2653,6 +2663,12 @@ static int ieee80211_ioctl_get_prism2_paelse *param = !!sdata->u.sta.wmm_enabled;break ; +case PRISM2_PARAM_MGMT_IF : +if (local->apdev) + *param = local->apdev->ifindex; +else + ret = -ENOENT ; +break ;default : ret = -EOPNOTSUPP ;
Re: [PATCH wireless-dev] d80211: Add support for user space clientMLME
In reply to Johannes BergQuoted 9 lines · Johannes Berg
Quoted 4 lines · Jouni Malinen
But there is.. I committed changes to the
wpa_supplicantdevel branch for this yesterday. It seems to work fine with net/d80211 and bcm43xx with this small patch to d80211 to allow the functionality to be moved into user space.Cool, do you have a list of things that we need to support for it to work on a 'softmac' based driver (iow removing softmac in favour of this)?
This is still somewhat open, but at minimum, there needs to be a mechanism for receiving and sending management frames from user space. d80211 uses a "management netdev" for this currently (the same one that was used before with hostapd for AP mode). In addition to that, wpa_supplicant expect to be able to read list of support channels and TX rates (get_hw_feature_data handler in driver wrapper) and to be able to add and remove STA entries (e.g., for TX rate control and association status validation in kernel code).
Currently, scanning is done simply by setting the channel with SIOCSIWFREQ and listening for management frames. However, the goal is to provide simple atomic operations that user space programs can request the kernel code to do. This would cover not only scanning, but also some other needs like IEEE 802.11k radio measurements. These operations could be something like "stop transmit, move to channel 5, report received management frames, record noise level, do this for 5 ms, return to operational channel, enable transmit".
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerRe: [PATCH wireless-dev] d80211: Add support for user space clientMLME
Quoted 8 lines · Jouni Malinen
This is still somewhat open, but at minimum, there needs to be a mechanism for receiving and sending management frames from user space. d80211 uses a "management netdev" for this currently (the same one that was used before with hostapd for AP mode). In addition to that,
wpa_supplicantexpect to be able to read list of support channels and TX rates (get_hw_feature_datahandler in driver wrapper) and to be able to add and remove STA entries (e.g., for TX rate control and association status validation in kernel code).
Right.
Quoted 8 lines
Currently, scanning is done simply by setting the channel with SIOCSIWFREQ and listening for management frames. However, the goal is to provide simple atomic operations that user space programs can request the kernel code to do. This would cover not only scanning, but also some other needs like IEEE 802.11k radio measurements. These operations could be something like "stop transmit, move to channel 5, report received management frames, record noise level, do this for 5 ms, return to operational channel, enable transmit".
Yeah, we talked about that. I suppose softmac will never support the current interface, we'll just design a new one and use that.
johannes