Move 'wifi' driver to dde_linux repository

The bulk of the driver code now lives in the 'dde_linux' repository,
which is available on all platforms, from where it can be referenced by
other repositories.

The 'wifi_drv' binary was delegated to a generic harness that includes
all configuration and management functionality shared by all wireless
device driver components, e.g., the wpa_supplicant. The code of the
device driver emulation environment is located in 'src/lib/wifi'. It
is referenced by the platform-specific driver library that resides in
the corresponding platform repository. The runtime configuration needs
to point the driver to proper driver library.

The platform-specific library is in charge of orchestrating the contrib
source utilized by the driver as well as providing the 'source.list'
and 'dep.list' files. It must include the generic library snippet
'repos/dde_linux/lib/wifi.inc' that deals with managing the emulation
environment code.

The 'repos/dde_linux/src/drivers/wifi/README' file contains more
detailed information on how to deploy the driver.

Issue #4861.
This commit is contained in:
Josef Söntgen 2023-05-02 18:17:56 +02:00 committed by Christian Helmuth
parent 6727b5ea49
commit d5710d9de3
60 changed files with 264 additions and 105 deletions

View File

@ -33,6 +33,12 @@ library named 'lxip.lib.so'. The IP stack can be interfaced using Genode's
version of 'libc' by linking your application to 'lxip_libc' plugin in your
'target.mk' file.
Wifi
####
The 'wifi_drv' consists of a port of the mac802.11 stack, platform-specific
drivers and the 'wpa_supplicant' to Genode.
lx_kit
######

View File

@ -0,0 +1,6 @@
include $(REP_DIR)/lib/mk/libnl.inc
INC_DIR += $(LIB_INC_DIR)/spec/32bit
CC_CXX_WARN_STRICT =

View File

@ -0,0 +1,55 @@
WIFI_DRV_DIR := $(call select_from_ports,linux)/src/lib/wifi
ifeq ($(wildcard $(WIFI_DRV_DIR)),)
WIFI_DRV_DIR := $(call select_from_repositories,src/lib/wifi)
endif
INC_DIR += $(WIFI_DRV_DIR)
LD_OPT += --version-script=$(WIFI_DRV_DIR)/symbol.map
vpath %.c $(WIFI_DRV_DIR)
vpath %.cc $(WIFI_DRV_DIR)
$(LIB).lib.so: $(WIFI_DRV_DIR)/symbol.map
#
# Generic driver code shared between all instances
#
SHARED_LIB := yes
LIBS += base jitterentropy
SRC_CC += firmware.cc
SRC_CC += socket_call.cc
SRC_CC += wlan.cc
SRC_C += dummies.c
SRC_C += lx_emul.c
SRC_C += lx_user.c
SRC_C += uplink.c
CC_OPT_dummies += -DKBUILD_MODNAME='"dummies"'
CC_OPT_generated_dummies += -DKBUILD_MODNAME='"generated_dummies"'
CC_OPT_lx_socket_call += -DKBUILD_MODNAME='"lx_socket_call"'
SRC_C += lx_socket_call.c
#
# Generic Linux options
#
CC_C_OPT += -Wno-address-of-packed-member
# need net/rfkill/rfkill.h
CC_OPT_lx_emul += -I$(LX_SRC_DIR)
CC_C_OPT += -DCONFIG_RFKILL_INPUT
#
# Genode C-API backends
#
SRC_CC += genode_c_api/uplink.cc
vpath genode_c_api/uplink.cc $(subst /genode_c_api,,$(call select_from_repositories,src/lib/genode_c_api))

View File

@ -21,7 +21,7 @@ proc router_verbose_domain_state {} {
create_boot_directory
import_from_depot [depot_user]/src/[base_src] \
[depot_user]/pkg/wifi \
[depot_user]/pkg/pc_wifi \
[depot_user]/src/acpi_drv \
[depot_user]/src/dynamic_rom \
[depot_user]/src/init \
@ -111,7 +111,6 @@ install_config {
</start>
<start name="wifi_drv" caps="300" priority="-1">
<binary name="pc_wifi_drv"/>
<resource name="RAM" quantum="32M"/>
<config ld_verbose="no">
<vfs>
@ -128,6 +127,7 @@ install_config {
<service name="Rtc"> <any-child/> </service>
<service name="Report"> <child name="report_rom"/> </service>
<service name="ROM" label="wifi_config"> <child name="config_rom"/> </service>
<service name="ROM" label="wifi.lib.so"> <parent label="pc_wifi.lib.so"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>

View File

@ -1,9 +1,19 @@
The pc_wifi_drv component is a port of the Linux mac802.11 stack, including
the iwlwifi driver as well as libnl and wpa_supplicant, to Genode.
The wifi_drv component is a port of the Linux mac802.11 stack as well as
libnl and wpa_supplicant to Genode. Depending on the used platform it
features a selection of drivers for wireless devices. For example on the
PC platform it contains the ath9k, iwlwifi and rtlwifi drivers for PCI(e)
devices.
To start the component the following configuration snippet can be used:
In contrast to other DDE Linux based drivers the actual driver portion is
confined to its own library to better isolate the various parts of the driver.
The 'wifi_drv' binary is the generic management part that includes the Wifi
configuration interface and the 'wpa_supplicant'. A suitable driver library
is loaded at run-time (see section [Debugging]).
!<start name="pc_wifi_drv" caps="250">
To start the component on the PC platform the following configuration snippet
can be used:
!<start name="wifi_drv" caps="250">
! <resource name="RAM" quantum="32M"/>
! <provides><service name="Nic"/></provides>
! <config>
@ -16,10 +26,44 @@ To start the component the following configuration snippet can be used:
! </vfs>
! </config>
! <route>
! <service name="ROM" label="wifi.lib.so">
! <parent label="pc_wifi.lib.so"/>
! </service>
! <service name="Rtc"> <any-child /> </service>
! <any-service> <parent/> <any-child /> </any-service>
! </route>
!</start
!</start>
On other platforms the wifi library will be different. The following
snippet illustrates the use of the driver on the PinePhone:
!<start name="wifi_drv" caps="250">
! <resource name="RAM" quantum="32M"/>
! <provides><service name="Nic"/></provides>
! <config>
! <libc stdout="/dev/null" stderr="/dev/null" rtc="/dev/rtc"/>
! <vfs>
! <dir name="dev"> <log/> <null/> <rtc/> <wifi/>
! <jitterentropy name="random"/>
! <jitterentropy name="urandom"/>
! </dir>
! </vfs>
! </config>
! <route>
! <service name="ROM" label="wifi.lib.so">
! <parent label="a64_wifi.lib.so"/>
! </service>
! <service name="ROM" label="dtb">
! <parent label="wifi-pinephone.dtb"/>
! </service>
! <service name="Rtc"> <any-child /> </service>
! <any-service> <parent/> <any-child /> </any-service>
! </route>
!</start>
Note the ROM route for the device-tree binary that is essential on
ARM-based platforms. The name of the request DTB can by changed
by setting the 'dtb' attribute in the config node.
The driver will request access to the ROM module 'wifi_config' to
connect to a network:
@ -102,3 +146,19 @@ label "devices" if requested in the config as depicted.
! <config> <report mac_address="true"/> </config>
! <devices> <nic mac_address="02:00:00:00:00:01"/> </devices>
Debugging
~~~~~~~~~
As mentioned in the introduction the 'wifi_drv' component is special in the
regard that the actual driver is provided as a shared-object to better isolate
it from the the driver binary that is a Libc::Component managing the
'wpa_supplicant'. Since this code and in return the binary is the same for each
platform it is linked against an artifical 'wifi' library that only exists as
an ABI stub created via 'lib/symbols/wifi'. In case the driver is integrated
via depot archives this is, besides setting the proper ROM routes, of no
concern. However, when the driver is built without the depot, the boot image
assemble-mechanism tries to include the non-existent 'wifi.lib.so' library. To
prevent that from failing one way is adding a dummy file - the
'repos/pc/run/pc_wifi.run' illustrates how to do that.

View File

@ -1,4 +1,4 @@
TARGET := pc_wifi_drv
TARGET := wifi_drv
SRC_CC := main.cc wpa.cc
LIBS := base wifi
LIBS += libc

View File

@ -0,0 +1,64 @@
/**
* \brief DTB access helper
* \author Josef Soentgen
* \date 2023-04-11
*/
/*
* Copyright (C) 2023 Genode Labs GmbH
*
* This file is distributed under the terms of the GNU General Public License
* version 2.
*/
/* Genode includes */
#include <base/attached_rom_dataspace.h>
#include <util/reconstructible.h>
/* local includes */
#include "dtb_helper.h"
using namespace Genode;
struct Dtb
{
Genode::Env &_env;
Attached_rom_dataspace _config_rom { _env, "config" };
using Dtb_name = Genode::String<64>;
Dtb_name _dtb_name {
_config_rom.xml().attribute_value("dtb", Dtb_name("dtb")) };
Attached_rom_dataspace _dtb_rom { _env, _dtb_name.string() };
Dtb(Genode::Env &env) : _env { env } { }
void *ptr()
{
return _dtb_rom.local_addr<void>();
}
};
static Constructible<Dtb> _dtb { };
Dtb_helper::Dtb_helper(Genode::Env &env) : _env { env }
{
try {
_dtb.construct(env);
} catch (...) {
error("could not access DTB ROM module, driver may not work"
" as expected");
}
}
void *Dtb_helper::dtb_ptr()
{
return _dtb.constructed() ? _dtb->ptr()
: nullptr;
}

View File

@ -1511,7 +1511,7 @@ a free download at [https://genode.org].
! ./tool/depot/download \
! genodelabs/pkg/x86_64/sculpt/2023-04-28 \
! genodelabs/pkg/x86_64/drivers_managed-pc/2023-04-28 \
! genodelabs/pkg/x86_64/wifi/2023-04-27 \
! genodelabs/pkg/x86_64/pc_wifi/2023-04-27 \
! genodelabs/bin/x86_64/ipxe_nic_drv/2023-04-25
# Create a build directory

View File

@ -1,6 +1,6 @@
_/pkg/sculpt
_/pkg/drivers_managed-pc
_/pkg/wifi
_/pkg/pc_wifi
_/pkg/ipxe_nic_drv
_/pkg/vbox6
_/pkg/acpica

View File

@ -157,7 +157,7 @@ proc nic_driver_routes { } {
set result(pc) {
<service name="ROM" label="nic_drv"> <parent label="ipxe_nic_drv"/> </service>
<service name="ROM" label="wifi_drv"> <parent label="pc_wifi_drv"/> </service>
<service name="ROM" label="wifi.lib.so"> <parent label="pc_wifi.lib.so"/> </service>
}
set result(mnt_reform2) {
@ -171,7 +171,7 @@ proc nic_driver_routes { } {
}
set result(pinephone) {
<service name="ROM" label="wifi_drv"> <parent label="a64_wifi_drv"/> </service>
<service name="ROM" label="wifi.lib.so"> <parent label="a64_wifi.lib.so"/> </service>
<service name="ROM" label="wifi_drv.dtb"> <parent label="wifi-pinephone.dtb"/> </service>
}

View File

@ -4,7 +4,7 @@ system: pc
gpu_drv: intel
# supplemental depot content added to the system image
import: pkg/drivers_managed-pc pkg/wifi src/ipxe_nic_drv
import: pkg/drivers_managed-pc pkg/pc_wifi src/ipxe_nic_drv
# selection of launcher-menu entries
launcher: vm_fs shared_fs usb_devices_rom

View File

@ -69,7 +69,6 @@ void Sculpt::gen_wifi_drv_start_content(Xml_generator &xml)
gen_parent_rom_route(xml, "vfs_wifi.lib.so");
gen_parent_rom_route(xml, "libssl.lib.so");
gen_parent_rom_route(xml, "wifi.lib.so");
gen_parent_rom_route(xml, "a64_wifi.lib.so");
gen_parent_rom_route(xml, "wpa_driver_nl80211.lib.so");
gen_parent_rom_route(xml, "wpa_supplicant.lib.so");
gen_parent_rom_route(xml, "iwlwifi-1000-5.ucode");

View File

@ -0,0 +1,31 @@
REQUIRES := x86
include $(call select_from_repositories,lib/mk/wifi.inc)
TARGET_LIB_DIR := $(REP_DIR)/src/lib/pc_wifi
LIBS += pc_linux_generated pc_lx_emul
INC_DIR += $(TARGET_LIB_DIR)
SRC_CC += dtb_helper_no_dtb.cc
SRC_C += lx_emul_pci.c
SRC_CC += lx_emul/random.cc
SRC_C += $(notdir $(wildcard $(TARGET_LIB_DIR)/generated_dummies.c))
SRC_C += lx_emul/common_dummies.c
SRC_C += lx_emul/shadow/lib/kobject_uevent.c
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/intel/iwlwifi
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/realtek/rtlwifi
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl8188ee
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/ath/
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/ath/ath9k
CC_C_OPT += -I$(LX_SRC_DIR)/include/linux
vpath %.c $(REP_DIR)/src/lib/pc
vpath %.cc $(REP_DIR)/src/lib/pc
vpath %.c $(TARGET_LIB_DIR)
vpath %.cc $(TARGET_LIB_DIR)

View File

@ -1,4 +1,4 @@
include $(REP_DIR)/lib/mk/wifi.inc
include $(REP_DIR)/lib/mk/pc_wifi.inc
REQUIRES += 32bit

View File

@ -0,0 +1,3 @@
include $(REP_DIR)/lib/mk/pc_wifi.inc
REQUIRES += 64bit

View File

@ -1,3 +0,0 @@
include $(REP_DIR)/lib/mk/wifi.inc
REQUIRES += 64bit

View File

@ -1,61 +0,0 @@
REQUIRES := x86
TARGET_LIB_DIR := $(REP_DIR)/src/lib/wifi
SHARED_LIB := yes
LD_OPT += --version-script=$(TARGET_LIB_DIR)/symbol.map
LIBS += base jitterentropy pc_linux_generated pc_lx_emul
INC_DIR := $(TARGET_LIB_DIR)
SRC_CC += wlan.cc
SRC_CC += firmware.cc
SRC_CC += socket_call.cc
SRC_CC += lx_emul/random.cc
SRC_CC += dtb_helper.cc
SRC_C += dummies.c
SRC_C += lx_emul.c
SRC_C += lx_emul_pci.c
SRC_C += lx_user.c
SRC_C += uplink.c
CC_OPT_lx_socket_call += -DKBUILD_MODNAME='"lx_socket_call"'
SRC_C += lx_socket_call.c
SRC_C += $(notdir $(wildcard $(TARGET_LIB_DIR)/generated_dummies.c))
SRC_C += lx_emul/common_dummies.c
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/intel/iwlwifi
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/realtek/rtlwifi
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/realtek/rtlwifi/rtl8188ee
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/ath/
CC_C_OPT += -I$(LX_SRC_DIR)/drivers/net/wireless/ath/ath9k
CC_C_OPT += -I$(LX_SRC_DIR)/include/linux
CC_C_OPT += -Wno-address-of-packed-member
# need net/rfkill/rfkill.h
CC_OPT_lx_emul += -I$(LX_SRC_DIR)
CC_C_OPT += -DCONFIG_RFKILL_INPUT
#CC_OPT += -DCONFIG_IWLWIFI_DEBUG
SRC_C += lx_emul/shadow/lib/kobject_uevent.c
vpath %.c $(REP_DIR)/src/lib/pc
vpath %.cc $(REP_DIR)/src/lib/pc
vpath %.c $(TARGET_LIB_DIR)
vpath %.cc $(TARGET_LIB_DIR)
$(LIB).lib.so: $(TARGET_LIB_DIR)/symbol.map
#
# Genode C-API backends
#
SRC_CC += genode_c_api/uplink.cc
vpath genode_c_api/uplink.cc $(subst /genode_c_api,,$(call select_from_repositories,src/lib/genode_c_api))

View File

@ -1 +1 @@
2023-04-25 6d539e0675f0fd3523ad4ca40062b8399d02c1cc
2023-05-02 495f784f5db700f7dbe3583af4b196e9f05b1d9e

View File

@ -0,0 +1,2 @@
Package for bundling pc_wifi_drv and pc_wifi_firmware

View File

@ -3,4 +3,4 @@ _/src/openssl
_/src/vfs
_/src/vfs_jitterentropy
_/src/libc
_/raw/wifi_firmware
_/raw/pc_wifi_firmware

View File

@ -0,0 +1 @@
2023-05-02-c 31f3ef5aa2c7b9778fe2977e112ae28dfe40f8f9

View File

@ -1,2 +0,0 @@
Package for bundling pc_wifi_drv and wifi_firmware

View File

@ -1 +0,0 @@
2023-05-04 4a502a98091bb08186be3c5289b3388c66b37f33

View File

@ -1,40 +1,40 @@
#
# Driver portions
# Specific driver portions
#
LIB_MK := $(addprefix lib/mk/,wifi.inc vfs_wifi.mk) \
$(foreach SPEC,x86_32 x86_64,lib/mk/spec/$(SPEC)/wifi.mk) \
LIB_MK := $(addprefix lib/mk/,pc_wifi.inc) \
$(foreach SPEC,x86_32 x86_64,lib/mk/spec/$(SPEC)/pc_wifi.mk) \
MIRROR_FROM_REP_DIR := src/drivers/wifi/pc \
src/lib/pc/lx_emul \
MIRROR_FROM_REP_DIR := src/lib/pc/lx_emul \
src/include \
$(LIB_MK) \
lib/symbols/wifi \
$(shell cd $(REP_DIR); find src/drivers/wifi -type f) \
$(shell cd $(REP_DIR); find src/lib/wifi -type f) \
$(shell cd $(REP_DIR); find src/lib/vfs/wifi -type f)
$(shell cd $(REP_DIR); find src/lib/pc_wifi -type f) \
#
# Generic driver poritions from dde_linux and os
#
#
MIRROR_FROM_OS_DIR := src/lib/genode_c_api/uplink.cc
#
# DDE Linux portions (wpa_supplicant, libnl)
#
DDE_LINUX_REP_DIR := $(GENODE_DIR)/repos/dde_linux
WS_PORT_DIR := $(call port_dir,$(DDE_LINUX_REP_DIR)/ports/wpa_supplicant)
LIBNL_PORT_DIR := $(call port_dir,$(DDE_LINUX_REP_DIR)/ports/libnl)
DDE_LINUX_LIB_MK := \
$(addprefix lib/mk/,libnl.inc libnl_include.mk) \
$(addprefix lib/mk/,libnl.inc libnl_include.mk wifi.inc vfs_wifi.mk) \
$(foreach SPEC,x86_32 x86_64,lib/mk/spec/$(SPEC)/libnl.mk) \
$(addprefix lib/mk/,wpa_driver_nl80211.mk wpa_supplicant.mk)
MIRROR_FROM_DDE_LINUX_DIR := $(DDE_LINUX_LIB_MK) \
src/drivers/wifi \
lib/import/import-libnl_include.mk \
lib/import/import-libnl.mk \
lib/symbols/wifi \
include/wifi \
$(shell cd $(DDE_LINUX_REP_DIR); find src/lib/libnl -type f) \
$(shell cd $(DDE_LINUX_REP_DIR); find src/lib/vfs/wifi -type f) \
$(shell cd $(DDE_LINUX_REP_DIR); find src/lib/wifi -type f) \
$(shell cd $(DDE_LINUX_REP_DIR); find src/lib/wpa_driver_nl80211 -type f) \
$(shell cd $(DDE_LINUX_REP_DIR); find src/lib/wpa_supplicant -type f)

View File

@ -1 +1 @@
2023-04-25 a0b3d15ad8c29a4b68a061b2139cb1e171e60d35
2023-05-02-c ff18d05ceb7947b70f13bb3cc17247392158d122

View File

@ -64,7 +64,7 @@ assert_spec x86
#
create_boot_directory
import_from_depot [depot_user]/raw/wifi_firmware
import_from_depot [depot_user]/pkg/pc_wifi
set build_components {
core init timer
@ -72,13 +72,11 @@ set build_components {
drivers/acpi
drivers/platform
drivers/rtc
drivers/wifi/pc
server/report_rom
server/dynamic_rom
server/nic_router
test/lwip/http_srv
lib/vfs_wifi
lib/vfs_jitterentropy
lib/vfs_lwip
}
@ -128,7 +126,7 @@ append config {
</start>
<start name="acpi_drv" caps="250">
<resource name="RAM" quantum="4M"/>
<resource name="RAM" quantum="6M"/>
<route>
<service name="IO_MEM"> <parent/> </service>
<service name="LOG"> <parent/> </service>
@ -273,7 +271,6 @@ append config {
</start>
<start name="wifi_drv" caps="250" priority="-1">
<binary name="pc_wifi_drv"/>
<resource name="RAM" quantum="32M"/>
<config ld_verbose="yes">
<report mac_address="true"/>
@ -293,6 +290,7 @@ append config {
<service name="Report" label="state"> <child name="state_report_rom"/> </service>
<service name="Report" label="devices"> <child name="devices_report_rom"/> </service>
<service name="ROM" label="wifi_config"> <child name="config_rom"/> </service>
<service name="ROM" label="wifi.lib.so"> <parent label="pc_wifi.lib.so"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>

View File

@ -156,7 +156,7 @@ append_if $use_usb_driver packages " [depot_user]/pkg/test_usb_host_drv-[board
append_if $use_usb_driver packages " [depot_user]/src/usb_net_drv "
append_if $use_wifi_driver packages " [depot_user]/src/fs_rom "
append_if $use_wifi_driver packages " [depot_user]/src/vfs_import "
append_if $use_wifi_driver packages " [depot_user]/pkg/wifi "
append_if $use_wifi_driver packages " [depot_user]/pkg/pc_wifi "
append_if $use_wifi_driver packages " [depot_user]/src/acpi_drv "
append_if $use_wifi_driver packages " [depot_user]/src/pci_decode "
append_if $use_wifi_driver packages " [depot_user]/src/platform_drv "
@ -278,6 +278,7 @@ append config { </wifi_config>
<service name="Rtc"> <any-child/> </service>
<service name="File_system"> <child name="config_fs"/> </service>
<service name="ROM" label="wifi_config"> <child name="config_rom" /> </service>
<service name="ROM" label="wifi.lib.so"> <parent label="pc_wifi.lib.so"/> </service>
<service name="Report"> <child name="report_rom"/> </service>
<service name="Uplink"> <child name="nic_router"/> </service>
<any-service> <parent/> <any-child /> </any-service>