wifi: support for scans in connected state

The 'connected_scan_interval' config attribute specifies the scan
interval in seconds. The commit also removes the deprecated ram_fs
component from the test run script.
This commit is contained in:
Christian Helmuth 2016-10-20 10:17:32 +02:00
parent 9ba7b2edde
commit 104775aa56
6 changed files with 69 additions and 53 deletions

View File

@ -197,14 +197,7 @@ Configuration snippet:
! <jitterentropy name="random"/> ! <jitterentropy name="random"/>
! <jitterentropy name="urandom"/> ! <jitterentropy name="urandom"/>
! </dir> ! </dir>
! <inline name="wpa_supplicant.conf"> ! <dir name="config"> <ram/> </dir>
!network={
! id_str="foobar"
! ssid="foobar"
! key_mgmt=WPA-PSK
! psk="foobarfoobar"
!}
! </inline>
! </vfs> ! </vfs>
! </libc> ! </libc>
! </config> ! </config>
@ -214,6 +207,17 @@ Configuration snippet:
! </route> ! </route>
!</start !</start
Per default, the driver scans for available networks only when not
connected. This can be changed with the 'connected_scan_interval'
config attribute, which specifies the interval for connected scans in
seconds, e.g.
!<config connected_scan_interval="30">...</config>
Also, the driver can be switched to verbose logging with
!<config verbose="yes">...</config>
The wifi_drv creates two distinct reports to communicate its state and The wifi_drv creates two distinct reports to communicate its state and
information about the wireless infrastructure to other components. The information about the wireless infrastructure to other components. The
first one is a list of all available accesspoints. The following examplary first one is a list of all available accesspoints. The following examplary

View File

@ -7,8 +7,7 @@ set build_components {
drivers/timer drivers/wifi drivers/timer drivers/wifi
drivers/rtc drivers/rtc
server/report_rom server/report_rom
server/ram_fs server/dynamic_rom
server/fs_rom
test/lwip/http_srv test/lwip/http_srv
lib/vfs/jitterentropy lib/vfs/jitterentropy
} }
@ -60,55 +59,44 @@ set config {
</start> </start>
<start name="report_rom"> <start name="report_rom">
<resource name="RAM" quantum="2M"/> <resource name="RAM" quantum="2M"/>
<provides> <service name="Report" /> <service name="ROM" /> </provides> <provides> <service name="Report"/> <service name="ROM"/> </provides>
<config> <rom/> </config> <config/>
</start>
<start name="config_fs">
<binary name="ram_fs"/>
<resource name="RAM" quantum="4M"/>
<provides> <service name="File_system"/> </provides>
<config>
<policy label="config_rom" root="/"/>
<policy label="wifi_drv -> config" root="/" writeable="yes"/>
<content>
<inline name="wlan_configuration">}
append config "
<selected_network ssid=\"$::env(GENODE_WIFI_SSID)\" protection=\"WPA-PSK\" psk=\"$::env(GENODE_WIFI_PSK)\"/>"
append config {
</inline>
<inline name="wpa_supplicant.conf"></inline>
</content>
</config>
</start> </start>
<start name="config_rom"> <start name="config_rom">
<binary name="fs_rom"/> <binary name="dynamic_rom"/>
<resource name="RAM" quantum="4M"/> <resource name="RAM" quantum="4M"/>
<provides><service name="ROM"/></provides> <provides><service name="ROM"/></provides>
<route> <config verbose="yes">
<service name="File_system"> <child name="config_fs" /> </service> <rom name="wlan_configuration">
<any-service> <parent/> <any-child/> </any-service> <inline description="DISCONNECT"> <selected_network/> </inline>
</route> <sleep milliseconds="10000"/> <!-- 10 seconds -->
<inline description="CONNECT">}
append config "<selected_network ssid=\"$::env(GENODE_WIFI_SSID)\" protection=\"WPA-PSK\" psk=\"$::env(GENODE_WIFI_PSK)\"/>"
append config {
</inline>
<sleep milliseconds="300000"/> <!-- 5 minutes -->
</rom>
</config>
</start> </start>
<start name="wifi_drv"> <start name="wifi_drv">
<resource name="RAM" quantum="32M"/> <resource name="RAM" quantum="32M"/>
<provides> <service name="Nic"/> </provides> <provides> <service name="Nic"/> </provides>
<config ld_verbose="yes" verbose="yes"> <config ld_verbose="yes" verbose="yes" connected_scan_interval="30">
<libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc"> <libc stdout="/dev/log" stderr="/dev/log" rtc="/dev/rtc">
<vfs> <vfs>
<dir name="dev"> <log/> <rtc/> <dir name="dev"> <log/> <rtc/>
<jitterentropy name="random"/> <jitterentropy name="random"/>
<jitterentropy name="urandom"/> <jitterentropy name="urandom"/>
</dir> </dir>
<dir name="config"> <fs label="config"/> </dir> <dir name="config"> <ram/> </dir>
</vfs> </vfs>
</libc> </libc>
</config> </config>
<route> <route>
<service name="Rtc"> <any-child /> </service> <service name="Rtc"> <any-child/> </service>
<service name="File_system"> <child name="config_fs"/> </service>
<service name="Report"> <child name="report_rom"/> </service> <service name="Report"> <child name="report_rom"/> </service>
<service name="ROM"> <if-arg key="label" value="wlan_configuration" /> <child name="config_rom" /> </service> <service name="ROM" label="wlan_configuration"> <child name="config_rom"/> </service>
<any-service> <parent/> <any-child /> </any-service> <any-service> <parent/> <any-child/> </any-service>
</route> </route>
</start>} </start>}
@ -143,7 +131,7 @@ set firmware_modules {
# generic modules # generic modules
set boot_modules { set boot_modules {
core init timer rtc_drv ram_fs report_rom fs_rom core init timer rtc_drv report_rom dynamic_rom
vfs_jitterentropy.lib.so vfs_jitterentropy.lib.so
ld.lib.so ld.lib.so
libc.lib.so libcrypto.lib.so libssl.lib.so libc.lib.so libcrypto.lib.so libssl.lib.so

View File

@ -230,7 +230,8 @@ struct Main
Main(Genode::Env &env) : env(env) Main(Genode::Env &env) : env(env)
{ {
bool const verbose = config_rom.xml().attribute_value("verbose", false); bool const verbose = config_rom.xml().attribute_value("verbose", false);
long const interval = config_rom.xml().attribute_value("connected_scan_interval", 0L);
/* /*
* Forcefully disable 11n but for convenience the attribute is used the * Forcefully disable 11n but for convenience the attribute is used the
@ -238,7 +239,7 @@ struct Main
*/ */
bool const disable_11n = !config_rom.xml().attribute_value("use_11n", true); bool const disable_11n = !config_rom.xml().attribute_value("use_11n", true);
wpa = new (&heap) Wpa_thread(env, wpa_startup_lock(), verbose); wpa = new (&heap) Wpa_thread(env, wpa_startup_lock(), verbose, interval);
wpa->start(); wpa->start();

View File

@ -18,7 +18,7 @@
#include <base/sleep.h> #include <base/sleep.h>
/* entry function */ /* entry function */
extern "C" int wpa_main(int); extern "C" int wpa_main(int debug_msg, int connected_scan_interval);
extern "C" void wpa_conf_reload(void); extern "C" void wpa_conf_reload(void);
class Wpa_thread : public Genode::Thread class Wpa_thread : public Genode::Thread
@ -28,19 +28,23 @@ class Wpa_thread : public Genode::Thread
Genode::Lock &_lock; Genode::Lock &_lock;
int _exit; int _exit;
bool _debug_msg; bool _debug_msg;
int _connected_scan_interval;
public: public:
Wpa_thread(Genode::Env &env, Genode::Lock &lock, bool debug_msg) Wpa_thread(Genode::Env &env, Genode::Lock &lock,
bool debug_msg, int connected_scan_interval)
: :
Thread(env, "wpa_supplicant", 8*1024*sizeof(long)), Thread(env, "wpa_supplicant", 8*1024*sizeof(long)),
_lock(lock), _exit(-1), _debug_msg(debug_msg) { } _lock(lock), _exit(-1),
_debug_msg(debug_msg), _connected_scan_interval(connected_scan_interval)
{ }
void entry() void entry()
{ {
/* wait until the wifi driver is up and running */ /* wait until the wifi driver is up and running */
_lock.lock(); _lock.lock();
_exit = wpa_main(_debug_msg); _exit = wpa_main(_debug_msg, _connected_scan_interval);
Genode::sleep_forever(); Genode::sleep_forever();
} }
}; };

View File

@ -981,11 +981,9 @@ void __free_page_frag(void *addr)
void __free_pages(struct page *page, unsigned int order) void __free_pages(struct page *page, unsigned int order)
{ {
if (!atomic_dec_and_test(&page->_count)) { if (!atomic_dec_and_test(&page->_count))
Genode::warning("attempting to free page ", page, " with _count: ", /* reference counter did not drop to zero - do not free yet */
atomic_read(&page->_count));
return; return;
}
Addr_to_page_mapping::remove(page); Addr_to_page_mapping::remove(page);

View File

@ -30,14 +30,31 @@
/* local includes */ /* local includes */
#include "includes.h" #include "includes.h"
#include "common.h" #include "common.h"
#include "eloop.h"
#include "wpa_supplicant_i.h" #include "wpa_supplicant_i.h"
#include "driver_i.h"
#include "scan.h"
static char const *conf_file = "/config/wpa_supplicant.conf"; static char const *conf_file = "/config/wpa_supplicant.conf";
static int connected_scan_interval;
int wpa_main(int debug_msg) static void connected_scan_handler(void *eloop_ctx, void *user_ctx)
{ {
struct wpa_supplicant *wpa_s = (struct wpa_supplicant *)eloop_ctx;
if (wpa_s->wpa_state >= WPA_ASSOCIATED)
wpa_supplicant_req_scan(wpa_s, 0, 0);
eloop_register_timeout(connected_scan_interval, 0, connected_scan_handler, wpa_s, 0);
}
int wpa_main(int debug_msg, int interval)
{
connected_scan_interval = interval;
struct wpa_interface iface; struct wpa_interface iface;
int exitcode = 0; int exitcode = 0;
struct wpa_params params; struct wpa_params params;
@ -59,6 +76,10 @@ int wpa_main(int debug_msg)
if (wpa_supplicant_add_iface(global, &iface) == NULL) if (wpa_supplicant_add_iface(global, &iface) == NULL)
exitcode = -1; exitcode = -1;
if (connected_scan_interval > 0)
eloop_register_timeout(connected_scan_interval, 0,
connected_scan_handler, global->ifaces, 0);
if (exitcode == 0) if (exitcode == 0)
exitcode = wpa_supplicant_run(global); exitcode = wpa_supplicant_run(global);
@ -78,7 +99,7 @@ void wpa_conf_reload(void)
int wpa_write_conf(char const *buffer, size_t len) int wpa_write_conf(char const *buffer, size_t len)
{ {
int fd = open(conf_file, O_TRUNC|O_WRONLY); int fd = open(conf_file, O_CREAT|O_TRUNC|O_WRONLY);
if (fd == -1) if (fd == -1)
return -1; return -1;