mac80211_hwsim - simulator of 802.11 radios for mac80211
hostapd and wpa_supplicant include a test driver interface that allows them to be tested on a single host without any wireless hardware for development purposes. I have found this very valuable both for developing new functionality and for testing existing code.
In order to provide similar mechanism for mac80211 developers and to extend the scope of suitable test cases for hostapd/wpa_supplicant, I've written a Linux kernel module that provides a similar test interface at a lower layer. mac80211_hwsim simulates WLAN hardware and the air interface between the radios by acting as a low-level radio driver for mac80211. Neither mac80211 nor user space programs need any changes to work with the simulated radios.
The initial version of mac80211_hwsim is available from the mac80211_hwsim subdirectory of my hostap Git tree:git://w1.fi/srv/git/hostap.git
http://w1.fi/gitweb/gitweb.cgi?p=hostap.git;a=tree;f=mac80211_hwsim
If there is interest in moving mac80211_hwsim module into the Linux kernel tree, I'm open to doing that, too.
I've included some more information about the code in the README file (see below) and there are also example configuration files for hostapd and wpa_supplicant to show how a WPA2-Personal connection can be opened with mac80211_hwsim.
mac80211_hwsim is still very minimal, but I have added couple of TODO comments to the source code to indicate areas that I'm hoping to add for more complete support of mac80211 features. I would also be interested in feedback from other mac80211 developers on what kind of functionality would be useful to have in this kind of simulated test setup. I'm first looking into using this to develop IEEE 802.11w (management frame protection) support into mac80211 and I would expect that the current minimal design is enough for that, but there is certainly room for much more, e.g., in the area of simulating signal strength and packet loss for testing TX rate control, retransmission, and power save functionality.
README:
Introduction
mac80211_hwsim is a Linux kernel module that can be used to simulate arbitrary number of IEEE 802.11 radios for mac80211 on a single device. It can be used to test most of the mac80211 functionality and user space tools (e.g., hostapd and wpa_supplicant) in a way that matches very closely with the normal case of using real WLAN hardware. From the mac80211 view point, mac80211_hwsim is yet another hardware driver, i.e., no changes to mac80211 are needed to use this testing tool.
The main goal for mac80211_hwsim is to make it easier for developers to test their code and work with new features to mac80211, hostapd, and wpa_supplicant. The simulated radios do not have the limitations of real hardware, so it is easy to generate an arbitrary test setup and always reproduce the same setup for future tests. In addition, since all radio operation is simulated, any channel can be used in tests regardless of regulatory rules.
mac80211_hwsim kernel module has a parameter 'radios' that can be used to select how many radios are simulates (default 2). This allows configuration of both very simply setups (e.g., just a single access point and a station) or large scale tests (multiple access points with hundreds of stations).
mac80211_hwsim works by tracking the current channel of each virtual radio and copying all transmitted frames to all other radios that are currently enabled and on the same channel as the transmitting radio. Software encryption in mac80211 is used so that the frames are actually encrypted over the virtual air interface to allow more complete testing of encryption.
Simple example
This example shows how to use mac80211_hwsim to simulate two radios:
one to act as an access point and the other as a station that associates with the AP. hostapd and wpa_supplicant are used to take care of WPA2-PSK authentication. In addition, hostapd is also processing access point side of association.
Please note that the currently released Linux kernel (2.6.25) does not enable AP mode, so a simple patch is needed to enable AP mode selection:
http://johannes.sipsolutions.net/patches/kernel/all/LATEST/006-allow-ap-vlan-modes.patch
# Build mac80211_hwsim:
make
# Load the module
insmod ./mac80211_hwsim.ko
# Run hostapd (AP) for wlan0
hostapd hostapd.conf
# Run wpa_supplicant (station) for wlan1 wpa_supplicant -Dwext -iwlan1 -c wpa_supplicant.conf
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerQuoted 5 lines · Jouni Malinen
hostapd and
wpa_supplicantinclude a test driver interface that allows them to be tested on a single host without any wireless hardware for development purposes. I have found this very valuable both for developing new functionality and for testing existing code.
Quoted 7 lines
In order to provide similar mechanism for mac80211 developers and to extend the scope of suitable test cases for hostapd/wpa_supplicant, I've written a Linux kernel module that provides a similar test interface at a lower layer.
mac80211_hwsimsimulates WLAN hardware and the air interface between the radios by acting as a low-level radio driver for mac80211. Neither mac80211 nor user space programs need any changes to work with the simulated radios.
Way cool!
Quoted 7 lines
The initial version of
mac80211_hwsimis available from themac80211_hwsimsubdirectory of my hostap Git tree:git://w1.fi/srv/git/hostap.git
http://w1.fi/gitweb/gitweb.cgi?p=hostap.git;a=tree;f=mac80211_hwsimIf there is interest in moving
mac80211_hwsimmodule into the Linux kernel tree, I'm open to doing that, too.
I think that would make sense, yes, especially since one look at the code already tells me that it needs to follow large API changes to work with the current mac80211.
One thing caught my eye: you use GFP_KERNEL in the tx routine, that's not good, it is running under a spinlock.
One thing that I'd like to add is a having a "global" monitor interface that is registered by the hwsim module and not mac80211 and shows all frames, regardless of channel etc.
johannes
Quoted 7 lines · Johannes Berg
Quoted 2 lines · Jouni Malinen
If there is interest in moving
mac80211_hwsimmodule into the Linux kernel tree, I'm open to doing that, too.I think that would make sense, yes, especially since one look at the code already tells me that it needs to follow large API changes to work with the current mac80211.
I'm currently running Linux 2.6.25 on my laptop and as such, this is indeed not based on the latest changes. I'll fix couple of issues in the current code with 2.6.25-based version and then look into making a submission against wireless-testing (or if there are large, pending patches that are not yet there, against something including those changes).
Quoted 2 lines
One thing caught my eye: you use
GFP_KERNELin the tx routine, that's not good, it is running under a spinlock.
Thanks, I'll fix that. I was trying to follow the documentation in net/mac80211.h to verify that it is correct, but clearly I missed the comment on tx() about the handler having to be atomic.
Quoted 3 lines
One thing that I'd like to add is a having a "global" monitor interface that is registered by the hwsim module and not mac80211 and shows all frames, regardless of channel etc.
Yes, I've been thinking of something similar, too. I'll add a netdev that gets all frames with radiotap header.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Quoted 14 lines · Johannes Berg
Quoted 5 lines · Jouni Malinen
hostapd and
wpa_supplicantinclude a test driver interface that allows them to be tested on a single host without any wireless hardware for development purposes. I have found this very valuable both for developing new functionality and for testing existing code.Quoted 7 lines
In order to provide similar mechanism for mac80211 developers and to extend the scope of suitable test cases for hostapd/wpa_supplicant, I've written a Linux kernel module that provides a similar test interface at a lower layer.
mac80211_hwsimsimulates WLAN hardware and the air interface between the radios by acting as a low-level radio driver for mac80211. Neither mac80211 nor user space programs need any changes to work with the simulated radios.
Quoted 1 line
Way cool!
Yes, awesome!
Quoted 11 lines
Quoted 7 lines
The initial version of
mac80211_hwsimis available from themac80211_hwsimsubdirectory of my hostap Git tree:git://w1.fi/srv/git/hostap.git
http://w1.fi/gitweb/gitweb.cgi?p=hostap.git;a=tree;f=mac80211_hwsimIf there is interest in moving
mac80211_hwsimmodule into the Linux kernel tree, I'm open to doing that, too.I think that would make sense, yes, especially since one look at the code already tells me that it needs to follow large API changes to work with the current mac80211.
ACK
Quoted 3 lines
One thing that I'd like to add is a having a "global" monitor interface that is registered by the hwsim module and not mac80211 and shows all frames, regardless of channel etc.
That sounds like a great idea. A mechanism for injecting frames from an external source might be useful as well...?
Jouni this looks great. Let's get this into the kernel.
John
Signature · 2 lines
John W. Linville [email protected]
Johannes Berg
maintainerQuoted 7 lines
I'm currently running Linux 2.6.25 on my laptop and as such, this is indeed not based on the latest changes. I'll fix couple of issues in the current code with 2.6.25-based version and then look into making a submission against wireless-testing (or if there are large, pending patches that are not yet there, against something including those changes).
I don't think there are large pending changes, but there were large changes in the way channels are registered, tx control works etc.
Quoted 6 lines
Quoted 2 lines
One thing caught my eye: you use
GFP_KERNELin the tx routine, that's not good, it is running under a spinlock.Thanks, I'll fix that. I was trying to follow the documentation in
net/mac80211.hto verify that it is correct, but clearly I missed the comment ontx()about the handler having to be atomic.
You should probably use the _irqsafe versions of rx and txstatus too.
Quoted 6 lines
Quoted 3 lines
One thing that I'd like to add is a having a "global" monitor interface that is registered by the hwsim module and not mac80211 and shows all frames, regardless of channel etc.
Yes, I've been thinking of something similar, too. I'll add a netdev that gets all frames with radiotap header.
Maybe it could support injection on that too, so you can test against a userspace agent.
The design I had come up with a long time ago allowed userspace to control each radio by having each _radio_ have a raw netdev like this and not doing forwarding in the kernel but relying on some userspace tool, but I guess that much more complicated.
johannes
Johannes Berg
maintainerQuoted 7 lines
Quoted 4 lines
One thing that I'd like to add is a having a "global" monitor interface that is registered by the hwsim module and not mac80211 and shows all frames, regardless of channel etc.
That sounds like a great idea. A mechanism for injecting frames from an external source might be useful as well...?
Using the same interface maybe? We can work on it.
Quoted 1 line
Jouni this looks great. Let's get this into the kernel.
I wonder where to stick it. net/mac80211/virtual-hw.c? Or drivers/net/wireless/mac80211-virt.c? Heh. Not that it matters :)
johannes
Johannes Berg
maintainerQuoted 5 lines
The design I had come up with a long time ago allowed userspace to control each radio by having each _radio_ have a raw netdev like this and not doing forwarding in the kernel but relying on some userspace tool, but I guess that much more complicated.
I should mention that I have notes on that:
http://kernelnewbies.org/KernelProjects/Mac80211TestDriver
johannes
Quoted 5 lines · Jouni Malinen
hostapd and
wpa_supplicantinclude a test driver interface that allows them to be tested on a single host without any wireless hardware for development purposes. I have found this very valuable both for developing new functionality and for testing existing code.
Quoted 7 lines
In order to provide similar mechanism for mac80211 developers and to extend the scope of suitable test cases for hostapd/wpa_supplicant, I've written a Linux kernel module that provides a similar test interface at a lower layer.
mac80211_hwsimsimulates WLAN hardware and the air interface between the radios by acting as a low-level radio driver for mac80211. Neither mac80211 nor user space programs need any changes to work with the simulated radios.
Awesome. I was going to write a basic WEXT driver so I could get some better tests going for NetworkManager, but you've beaten me to it :)
Thanks!
Dan
Quoted 87 lines
The initial version of
mac80211_hwsimis available from themac80211_hwsimsubdirectory of my hostap Git tree:git://w1.fi/srv/git/hostap.git
http://w1.fi/gitweb/gitweb.cgi?p=hostap.git;a=tree;f=mac80211_hwsimIf there is interest in moving
mac80211_hwsimmodule into the Linux kernel tree, I'm open to doing that, too.I've included some more information about the code in the README file (see below) and there are also example configuration files for hostapd and
wpa_supplicantto show how a WPA2-Personal connection can be opened withmac80211_hwsim.
mac80211_hwsimis still very minimal, but I have added couple of TODO comments to the source code to indicate areas that I'm hoping to add for more complete support of mac80211 features. I would also be interested in feedback from other mac80211 developers on what kind of functionality would be useful to have in this kind of simulated test setup. I'm first looking into using this to develop IEEE 802.11w (management frame protection) support into mac80211 and I would expect that the current minimal design is enough for that, but there is certainly room for much more, e.g., in the area of simulating signal strength and packet loss for testing TX rate control, retransmission, and power save functionality.README:
Introduction
mac80211_hwsimis a Linux kernel module that can be used to simulate arbitrary number of IEEE 802.11 radios for mac80211 on a single device. It can be used to test most of the mac80211 functionality and user space tools (e.g., hostapd andwpa_supplicant) in a way that matches very closely with the normal case of using real WLAN hardware. From the mac80211 view point,mac80211_hwsimis yet another hardware driver, i.e., no changes to mac80211 are needed to use this testing tool.The main goal for
mac80211_hwsimis to make it easier for developers to test their code and work with new features to mac80211, hostapd, andwpa_supplicant. The simulated radios do not have the limitations of real hardware, so it is easy to generate an arbitrary test setup and always reproduce the same setup for future tests. In addition, since all radio operation is simulated, any channel can be used in tests regardless of regulatory rules.
mac80211_hwsimkernel module has a parameter 'radios' that can be used to select how many radios are simulates (default 2). This allows configuration of both very simply setups (e.g., just a single access point and a station) or large scale tests (multiple access points with hundreds of stations).
mac80211_hwsimworks by tracking the current channel of each virtual radio and copying all transmitted frames to all other radios that are currently enabled and on the same channel as the transmitting radio. Software encryption in mac80211 is used so that the frames are actually encrypted over the virtual air interface to allow more complete testing of encryption.Simple example
This example shows how to use
mac80211_hwsimto simulate two radios:
one to act as an access point and the other as a station that associates with the AP. hostapd andwpa_supplicantare used to take care of WPA2-PSK authentication. In addition, hostapd is also processing access point side of association.Please note that the currently released Linux kernel (2.6.25) does not enable AP mode, so a simple patch is needed to enable AP mode selection:
http://johannes.sipsolutions.net/patches/kernel/all/LATEST/006-allow-ap-vlan-modes.patch# Build
mac80211_hwsim:
make# Load the module
insmod ./mac80211_hwsim.ko# Run hostapd (AP) for wlan0
hostapd hostapd.conf# Run
wpa_supplicant(station) for wlan1wpa_supplicant-Dwext -iwlan1 -c wpa_supplicant.conf
Quoted 2 lines · Johannes Berg
I don't think there are large pending changes, but there were large changes in the way channels are registered, tx control works etc.
OK.
Quoted 1 line
You should probably use the
_irqsafeversions of rx and txstatus too.
Hmm.. That was interesting.. Changing txstatus to use _irqsafe is was fine, but changing ieee80211_rx to ieee80211_rx_irqsafe triggers something bad.. Loadavg jumps sky high the moment I kill hostapd and ksoftirqd/0 and rmmod (which I ran after killing hostapd) are taking all CPU.. I can hardly type a command at that point. Looks like something goes horribly wrong with the extra queuing with ieee80211_rx_irqsafe. Maybe sending something to a netdev that is down ends up in a busy loop with a frame or something. In other words, I did not change to use _irqsafe yet, but will do once I have more time to figure out what on earth is going on here.
Quoted 5 lines
Quoted 2 lines
Yes, I've been thinking of something similar, too. I'll add a netdev that gets all frames with radiotap header.
Maybe it could support injection on that too, so you can test against a userspace agent.
Yes, I added the global radiotap monitor to hwsim (ifname=hwsim#) and left the hard_xmit function empty with a TODO comment.. The netdev from outside mac80211 is quite useful since it can be set up before any of the mac80211 netdevs and it is possible to capture all frames from the beginning.. If needed, we could add some more flags to the radiotap header for indicating what was done with the frame, but that is something that can easily be added later.
Quoted 4 lines
The design I had come up with a long time ago allowed userspace to control each radio by having each _radio_ have a raw netdev like this and not doing forwarding in the kernel but relying on some userspace tool, but I guess that much more complicated.
That might be useful for some of the tests. I was interested in adding some kind of interface to make it easy to design test cases from user space, but the current code was so simple that I did not want to make it any more complex in the first version. Anyway, it might make sense to provide option mechanism to allow more user space control since I'm also interested in things like testing rate control with a programmable signal strength/channel quality and I do not really want to see the controller for that simulation in the kernel..
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerQuoted 13 lines
Quoted 2 lines
You should probably use the
_irqsafeversions of rx and txstatus too.Hmm.. That was interesting.. Changing txstatus to use
_irqsafeis was fine, but changingieee80211_rxtoieee80211_rx_irqsafetriggers something bad.. Loadavg jumps sky high the moment I kill hostapd and ksoftirqd/0 and rmmod (which I ran after killing hostapd) are taking all CPU.. I can hardly type a command at that point. Looks like something goes horribly wrong with the extra queuing withieee80211_rx_irqsafe. Maybe sending something to a netdev that is down ends up in a busy loop with a frame or something. In other words, I did not change to use_irqsafeyet, but will do once I have more time to figure out what on earth is going on here.
Hmm. I suspect you called rx_irqsafe _after_ the radio was stopped (via mac80211's stop callback), and at stop time we also disable the tasklet, so something probably goes haywire if you tasklet_schedule a disabled tasklet.
Quoted 7 lines
Yes, I added the global radiotap monitor to hwsim (ifname=hwsim#) and left the
hard_xmitfunction empty with a TODO comment.. The netdev from outside mac80211 is quite useful since it can be set up before any of the mac80211 netdevs and it is possible to capture all frames from the beginning.. If needed, we could add some more flags to the radiotap header for indicating what was done with the frame, but that is something that can easily be added later.
Yeah, true, good to have the simpler code in place first anyway.
Quoted 5 lines
Quoted 4 lines
The design I had come up with a long time ago allowed userspace to control each radio by having each _radio_ have a raw netdev like this and not doing forwarding in the kernel but relying on some userspace tool, but I guess that much more complicated.
Quoted 8 lines
That might be useful for some of the tests. I was interested in adding some kind of interface to make it easy to design test cases from user space, but the current code was so simple that I did not want to make it any more complex in the first version. Anyway, it might make sense to provide option mechanism to allow more user space control since I'm also interested in things like testing rate control with a programmable signal strength/channel quality and I do not really want to see the controller for that simulation in the kernel..
Heh, yeah. I'd like to have it more dynamically configurable too, but we can add that later as well. Maybe some debugfs stuff or so that allows disconnecting a radio from the "virtual air" at which point a hwsim per-radio netdev shows up for that one. Anyway, future, when needed.
johannes
Quoted 4 lines · Johannes Berg
Quoted 1 line
Jouni this looks great. Let's get this into the kernel.
I wonder where to stick it.
net/mac80211/virtual-hw.c? Ordrivers/net/wireless/mac80211-virt.c? Heh. Not that it matters :)
drivers/net/wireless seems appropriate to me.
Signature · 2 lines
John W. Linville [email protected]
Quoted 4 lines · Johannes Berg
Hmm. I suspect you called
rx_irqsafe_after_ the radio was stopped (via mac80211's stop callback), and at stop time we also disable the tasklet, so something probably goes haywire if youtasklet_schedulea disabled tasklet.
Yes, that caused it. I added a new flag based on start/stop for determining which interface are ready to accept new frames. I was already doing this based on radio_enabled flag, but apparently that is left set when setting the interface down.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
RFC PATCH 1/1 mac80211_hwsim
In reply to John W. LinvilleQuoted 1 line · John W. Linville
drivers/net/wirelessseems appropriate to me.
Here's a completely untested (well, it compiles) patch against wireless-test. I'll try to do some testing tomorrow, but if someone is interested in taking a closer look at a version that is converted to use the new data structures for channel/rate configuration, here's a preliminary version. All comments are welcome.
As far as functionality is concerned, this is supposed to match with the 2.6.25-based version I have in hostap.git, i.e., the only changes are to convert the newer version of mac80211 API. Since I'm frequently using the latest 2.6.x release kernel instead of wireless-test (and would assume I'm not the only one doing that), I'm thinking of maintaining two versions of the module. One would be in wireless-test and maintained just like any other in-tree driver. The other one is in my hostap.git repository and is maintained as an out-of-tree version that is based on the latest (or well, relatively close to the latest, i.e., whatever I happen to be using ;-) released kernel. Of course, once the in-tree version hits a released kernel, out-of-tree version can die.
PS.
The URL in Kconfig is just a placeholder and I'll add the information in README and hostapd/wpa_supplicant example configuration files there before this gets submitted properly.
drivers/net/wireless/Kconfig +13 -0
@@ -681,6 +681,19 @@ config ADM8211 Thanks to Infineon-ADMtek for their support of this driver. +config MAC80211_HWSIM + tristate "Simulated radio testing tool for mac80211" + depends on MAC80211 && WLAN_80211 + ---help--- + This driver is a developer testing tool that can be used to test + IEEE 802.11 networking stack (mac80211) functionality. This is not + needed for normal wireless LAN usage and is only for testing. See + http://w1.fi/mac80211_hwsim/ for more information on how to use + this tool. + + To compile this driver as a module, choose M here: the module will be + called mac80211_hwsim. If unsure, say N. + source "drivers/net/wireless/p54/Kconfig" source "drivers/net/wireless/ath5k/Kconfig" source "drivers/net/wireless/iwlwifi/Kconfig"
drivers/net/wireless/Makefile +2 -0
@@ -64,3 +64,5 @@ obj-$(CONFIG_RT2X00) += rt2x00/ obj-$(CONFIG_P54_COMMON) += p54/ obj-$(CONFIG_ATH5K) += ath5k/ + +obj-$(CONFIG_MAC80211_HWSIM) += mac80211_hwsim.o
drivers/net/wireless/mac80211_hwsim.c new file +536 -0
536 lines not on this page · raw message
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerRe: [PATCH RFC] mac80211_hwsim
Quoted 7 lines
Here's a completely untested (well, it compiles) patch against wireless-test. I'll try to do some testing tomorrow, but if someone is interested in taking a closer look at a version that is converted to use the new data structures for channel/rate configuration, here's a preliminary version. All comments are welcome.
Quoted 11 lines
As far as functionality is concerned, this is supposed to match with the 2.6.25-based version I have in hostap.git, i.e., the only changes are to convert the newer version of mac80211 API. Since I'm frequently using the latest 2.6.x release kernel instead of wireless-test (and would assume I'm not the only one doing that), I'm thinking of maintaining two versions of the module. One would be in wireless-test and maintained just like any other in-tree driver. The other one is in my hostap.git repository and is maintained as an out-of-tree version that is based on the latest (or well, relatively close to the latest, i.e., whatever I happen to be using ;-) released kernel. Of course, once the in-tree version hits a released kernel, out-of-tree version can die.
Sounds good to me.
Quoted 5 lines
PS.
The URL in
Kconfigis just a placeholder and I'll add the information in README and hostapd/wpa_supplicant example configuration files there before this gets submitted properly.
Should we add it to Documentation/networking/ instead? Don't care much, but it might be easier to track version changes that way.
drivers/net/wireless/mac80211_hwsim.c line 60
Quoted 6 lines
drivers/net/wireless/mac80211_hwsim.c new file +6
-0+static const struct ieee80211_rate hwsim_rates[] = { + { .bitrate =10 }, + { .bitrate =20 , .flags =IEEE80211_RATE_SHORT_PREAMBLE }, + { .bitrate =55 , .flags =IEEE80211_RATE_SHORT_PREAMBLE }, + { .bitrate =110 , .flags =IEEE80211_RATE_SHORT_PREAMBLE }, + { .bitrate =60 , .flags =IEEE80211_RATE_ERP_G },
You don't need to add the ERP flag manually, it'll be added based on the rate automatically.
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (is_multicast_ether_addr(hdr->addr1)) + ack = 1;
That seems a bit weird to me. mac80211 shouldn't request an ACK for mcast, but why fake one?
Review
Quoted 3 lines
... beacon ...
(quoted diff) +2
-0+ if (vif->type != IEEE80211_IF_TYPE_AP) + return;
That could support mesh as well, in mesh-beacon-like-AP mode rather than mesh-beacon-like-IBSS.
Review
Quoted 2 lines
(quoted diff) +2
-0+ data->channel->band != data2->channel->band || + data->channel->center_freq != data2->channel->center_freq)
The band check is useless since the frequency is in MHz, it's mostly to know which band table to look up things in if necessary.
drivers/net/wireless/mac80211_hwsim.c line 315
Quoted 9 lines
drivers/net/wireless/mac80211_hwsim.c new file +9
-0+static void mac80211_hwsim_beacon (unsigned long arg) +{ +struct ieee80211_hw *hw = (struct ieee80211_hw *) arg; +struct mac80211_hwsim_data *data = hw->priv; + +if (!data->started || !data->radio_enabled) +return ; + +ieee80211_iterate_active_interfaces (hw, mac80211_hwsim_beacon_tx, hw);
Cool, another user of this API :)
drivers/net/wireless/mac80211_hwsim.c line 363
Quoted 7 lines
drivers/net/wireless/mac80211_hwsim.c new file +7
-0+ data->rx_filter =0 ; +if (*total_flags &FIF_PROMISC_IN_BSS ) + data->rx_filter |=FIF_PROMISC_IN_BSS ; +if (*total_flags &FIF_ALLMULTI ) + data->rx_filter |=FIF_ALLMULTI ; + + *total_flags = data->rx_filter;
You don't actually seem to use these flags though. Should be added at some point, I think.
drivers/net/wireless/mac80211_hwsim.c line 478
Quoted 6 lines
drivers/net/wireless/mac80211_hwsim.c new file +6
-0+memcpy (data->channels, hwsim_channels,sizeof (hwsim_channels)); +memcpy (data->rates, hwsim_rates,sizeof (hwsim_rates)); + data->band.channels = data->channels; + data->band.n_channels =ARRAY_SIZE (hwsim_channels); + data->band.bitrates = data->rates; + data->band.n_bitrates =ARRAY_SIZE (hwsim_rates);
You shouldn't need to memcpy these, just point to the static allocations.
drivers/net/wireless/mac80211_hwsim.c line 479
Quoted 1 line
drivers/net/wireless/mac80211_hwsim.c new file +1
-0+ hw->wiphy->bands[IEEE80211_BAND_2GHZ ] = &data->band;
You can even allocate the band struct statically.
johannes
Re: [PATCH RFC] mac80211_hwsim
Quoted 2 lines · Johannes Berg
Should we add it to
Documentation/networking/instead? Don't care much, but it might be easier to track version changes that way.
That's fine, too. I'll add a subdirectory there for the readme and example configuration files.
Quoted 5 lines
drivers/net/wireless/mac80211_hwsim.c line 60
Quoted 2 lines
drivers/net/wireless/mac80211_hwsim.c new file +2
-0+static const struct ieee80211_rate hwsim_rates[] = { + { .bitrate =60 , .flags =IEEE80211_RATE_ERP_G },You don't need to add the ERP flag manually, it'll be added based on the rate automatically.
That sounds better. net/wireless.h was bit confusing on this part since it has the "filled by the core" notice only for IEEE80211_RATE_MANDATORY_* flags, not for IEEE80211_RATE_ERP_G. Looks like this should be added to the ERP flag, too.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (is_multicast_ether_addr(hdr->addr1)) + ack = 1;That seems a bit weird to me. mac80211 shouldn't request an ACK for mcast, but why fake one?
That was leftover from the previous version that did not check whether IEEE80211_TX_CTL_NO_ACK was used. I'll remove it.
Quoted 7 lines
Review
Quoted 4 lines
... beacon ...
(quoted diff) +2
-0+ if (vif->type != IEEE80211_IF_TYPE_AP) + return;That could support mesh as well, in mesh-beacon-like-AP mode rather than mesh-beacon-like-IBSS.
Yes. I'm not yet very familiar with the mesh implementation in mac80211 and did not want to enable things before having had chance to test them.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ data->channel->band != data2->channel->band || + data->channel->center_freq != data2->channel->center_freq)The band check is useless since the frequency is in MHz, it's mostly to know which band table to look up things in if necessary.
OK, I'll remove it. With the current bands this seems to be fine, but how would that work with 10 MHz and 5 MHz channels? I haven't verified, but I would assume they could use same center frequency with 20 MHz channels..
Quoted 3 lines
drivers/net/wireless/mac80211_hwsim.c line 315
Quoted 1 line
drivers/net/wireless/mac80211_hwsim.c new file +1
-0+ieee80211_iterate_active_interfaces (hw, mac80211_hwsim_beacon_tx, hw);Cool, another user of this API :)
I was first assuming that I have to implement some sort of data structure to store all vifs in the driver code to do this, but this one came in quite handy..
Quoted 6 lines
drivers/net/wireless/mac80211_hwsim.c line 359
Quoted 3 lines
drivers/net/wireless/mac80211_hwsim.c new file +3
-0+ data->rx_filter =0 ; +if (*total_flags &FIF_PROMISC_IN_BSS ) + data->rx_filter |=FIF_PROMISC_IN_BSS ;You don't actually seem to use these flags though. Should be added at some point, I think.
Yes, I left it there for future implementation of the actually filtering logic.
Quoted 8 lines
drivers/net/wireless/mac80211_hwsim.c line 473
Quoted 1 line
drivers/net/wireless/mac80211_hwsim.c new file +1
-0+memcpy (data->channels, hwsim_channels,sizeof (hwsim_channels));You shouldn't need to memcpy these, just point to the static allocations.
drivers/net/wireless/mac80211_hwsim.c line 479
Quoted 1 line
drivers/net/wireless/mac80211_hwsim.c new file +1
-0+ hw->wiphy->bands[IEEE80211_BAND_2GHZ ] = &data->band;You can even allocate the band struct statically.
Hmm.. Aren't the channel and rate structures being modified by mac80211/wireless code? Sharing the same global data area for all radios might not be desired if there will be different "hw" capabilities as far as supported channels/rates/bands are concerned. In addition, the static data structures were marked 'const' which would at least be somewhat confusing if the data ends up changing.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Johannes Berg
maintainerRe: [PATCH RFC] mac80211_hwsim
Quoted 4 lines · Jouni Malinen
That sounds better.
net/wireless.hwas bit confusing on this part since it has the "filled by the core" notice only for IEEE80211_RATE_MANDATORY_* flags, not forIEEE80211_RATE_ERP_G. Looks like this should be added to the ERP flag, too.
good point.
Quoted 4 lines
OK, I'll remove it. With the current bands this seems to be fine, but how would that work with 10 MHz and 5 MHz channels? I haven't verified, but I would assume they could use same center frequency with 20 MHz channels..
Yeah... that isn't really supported yet.
Quoted 6 lines
Hmm.. Aren't the channel and rate structures being modified by mac80211/wireless code? Sharing the same global data area for all radios might not be desired if there will be different "hw" capabilities as far as supported channels/rates/bands are concerned. In addition, the static data structures were marked 'const' which would at least be somewhat confusing if the data ends up changing.
They're only modified all the same, so it's fine to share unless you have different capabilities. Yeah, you should removed the const then.
johannes
Re: [PATCH RFC] mac80211_hwsim
Quoted 6 lines · Johannes Berg
Quoted 4 lines · Jouni Malinen
That sounds better.
net/wireless.hwas bit confusing on this part since it has the "filled by the core" notice only for IEEE80211_RATE_MANDATORY_* flags, not forIEEE80211_RATE_ERP_G. Looks like this should be added to the ERP flag, too.
Quoted 9 lines
good point.
Quoted 4 lines
OK, I'll remove it. With the current bands this seems to be fine, but how would that work with 10 MHz and 5 MHz channels? I haven't verified, but I would assume they could use same center frequency with 20 MHz channels..
Yeah... that isn't really supported yet.
We've added support for FAT channels 40Mhz, but that uses negative logic i.e. whether it's not supported. This is due to fact that FAT channel may expand to above or bellow channel.
Isn't usage of 10Mhz and 5Mz being slowly deprecated anyway?
Tomas.