nixos: move Nic drivers to core children
This commit is contained in:
parent
07645a3930
commit
b5d42cc711
|
@ -120,14 +120,28 @@ in {
|
||||||
lib.mapAttrsToList (name: value: ", `${name}` = ${value.configFile}")
|
lib.mapAttrsToList (name: value: ", `${name}` = ${value.configFile}")
|
||||||
cfg.children;
|
cfg.children;
|
||||||
|
|
||||||
|
nicRoutes = lib.mapAttrsToList (child: value:
|
||||||
|
(map (label: ''
|
||||||
|
, { service =
|
||||||
|
{ name = "Nic"
|
||||||
|
, label = Genode.Init.LabelSelector.prefix "${child}"
|
||||||
|
}
|
||||||
|
, route = Genode.Init.Route.parent (None Text)
|
||||||
|
}
|
||||||
|
'') value.routeToNics)) config.genode.init.children;
|
||||||
|
|
||||||
in pkgs.writeText "init.dhall" ''
|
in pkgs.writeText "init.dhall" ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
let baseConfig = ${cfg.baseConfig}
|
let baseConfig = ${cfg.baseConfig}
|
||||||
|
|
||||||
in baseConfig // {
|
in baseConfig // {
|
||||||
, verbose = ${if config.genode.init.verbose then "True" else "False"}
|
, verbose = ${if config.genode.init.verbose then "True" else "False"}
|
||||||
, children = baseConfig.children # toMap {${toString children} }
|
, children = baseConfig.children # toMap {${toString children} }
|
||||||
}
|
, routes = baseConfig.routes # [${
|
||||||
|
toString nicRoutes
|
||||||
|
}] : List Genode.Init.ServiceRoute.Type
|
||||||
|
} : Genode.Init.Type
|
||||||
'';
|
'';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,7 @@ with lib;
|
||||||
};
|
};
|
||||||
policyCheck = name: interface:
|
policyCheck = name: interface:
|
||||||
let
|
let
|
||||||
clientList = filter (x x != null) (lib.mapAttrsToList
|
clientList = filter (x: x != null) (lib.mapAttrsToList
|
||||||
(childName: value:
|
(childName: value:
|
||||||
if any (nic: nic == name) value.routeToNics then
|
if any (nic: nic == name) value.routeToNics then
|
||||||
childName
|
childName
|
||||||
|
@ -74,52 +74,51 @@ with lib;
|
||||||
}
|
}
|
||||||
'') (builtins.attrNames config.networking.interfaces);
|
'') (builtins.attrNames config.networking.interfaces);
|
||||||
|
|
||||||
genode.init.children = let
|
genode.core.children = mapAttrs' (name: interface:
|
||||||
|
let name' = name + ".driver";
|
||||||
nics = mapAttrs' (name: interface:
|
in {
|
||||||
let name' = name + ".driver";
|
name = name';
|
||||||
|
value = let
|
||||||
|
binary = with pkgs.genodePackages;
|
||||||
|
{
|
||||||
|
ipxe = ipxe_nic_drv;
|
||||||
|
virtio = virtio_nic_drv;
|
||||||
|
}.${interface.genode.driver};
|
||||||
in {
|
in {
|
||||||
name = name';
|
inputs = [ binary ];
|
||||||
value = let
|
configFile = let
|
||||||
binary = with pkgs.genodePackages;
|
policy = lib.mapAttrsToList (childName: value:
|
||||||
{
|
if any (nic: nic == name) value.routeToNics then ''
|
||||||
ipxe = ipxe_nic_drv;
|
Init.Config.Policy::{
|
||||||
virtio = virtio_nic_drv;
|
, service = "Nic"
|
||||||
}.${interface.genode.driver};
|
, label = Init.LabelSelector.prefix "nixos -> ${childName}"
|
||||||
in {
|
}
|
||||||
inputs = [ binary ];
|
'' else
|
||||||
configFile = let
|
"") config.genode.init.children;
|
||||||
policy = lib.mapAttrsToList (childName: value:
|
|
||||||
if any (nic: nic == name) value.routeToNics then ''
|
|
||||||
Init.Config.Policy::{
|
|
||||||
, service = "Nic"
|
|
||||||
, label = Init.LabelSelector.prefix "${childName}"
|
|
||||||
}
|
|
||||||
'' else
|
|
||||||
"") config.genode.init.children;
|
|
||||||
|
|
||||||
in pkgs.writeText "${name'}.dhall" ''
|
in pkgs.writeText "${name'}.dhall" ''
|
||||||
let Genode = env:DHALL_GENODE
|
let Genode = env:DHALL_GENODE
|
||||||
|
|
||||||
let Init = Genode.Init
|
let Init = Genode.Init
|
||||||
|
|
||||||
in Init.Child.flat
|
in Init.Child.flat
|
||||||
Init.Child.Attributes::{
|
Init.Child.Attributes::{
|
||||||
, binary = "${binary.pname}"
|
, binary = "${binary.pname}"
|
||||||
, provides = [ "Nic" ]
|
, provides = [ "Nic" ]
|
||||||
, resources = Init.Resources::{ caps = 128, ram = Genode.units.MiB 4 }
|
, resources = Init.Resources::{ caps = 128, ram = Genode.units.MiB 4 }
|
||||||
, routes = [ Init.ServiceRoute.parent "IO_MEM" ]
|
, routes = [ Init.ServiceRoute.parent "IO_MEM" ]
|
||||||
, config = Init.Config::{
|
, config = Init.Config::{
|
||||||
, attributes = toMap { verbose = "true" }
|
, attributes = toMap { verbose = "true" }
|
||||||
, policies = [ ${
|
, policies = [ ${
|
||||||
toString policy
|
toString policy
|
||||||
} ] : List Init.Config.Policy.Type
|
} ] : List Init.Config.Policy.Type
|
||||||
}
|
|
||||||
}
|
}
|
||||||
'';
|
}
|
||||||
};
|
'';
|
||||||
}) config.networking.interfaces;
|
};
|
||||||
|
}) config.networking.interfaces;
|
||||||
|
|
||||||
|
genode.init.children = let
|
||||||
sockets = mapAttrs' (name: interface:
|
sockets = mapAttrs' (name: interface:
|
||||||
let name' = name + ".sockets";
|
let name' = name + ".sockets";
|
||||||
in {
|
in {
|
||||||
|
@ -142,7 +141,10 @@ with lib;
|
||||||
lxip = 32;
|
lxip = 32;
|
||||||
}.${interface.genode.stack};
|
}.${interface.genode.stack};
|
||||||
settings = with builtins;
|
settings = with builtins;
|
||||||
lib.optionals (interface.ipv4.addresses != [ ])
|
[{
|
||||||
|
name = "label";
|
||||||
|
value = name;
|
||||||
|
}] ++ lib.optionals (interface.ipv4.addresses != [ ])
|
||||||
(let addr = head interface.ipv4.addresses;
|
(let addr = head interface.ipv4.addresses;
|
||||||
in [
|
in [
|
||||||
{
|
{
|
||||||
|
@ -204,7 +206,7 @@ with lib;
|
||||||
};
|
};
|
||||||
}) config.networking.interfaces;
|
}) config.networking.interfaces;
|
||||||
|
|
||||||
in nics // (lib.filterAttrs (n: v: v != null) sockets);
|
in lib.filterAttrs (n: v: v != null) sockets;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
Child.Attributes::{
|
Child.Attributes::{
|
||||||
, binary = "ping"
|
, binary = "ping"
|
||||||
, resources = Init.Resources::{ ram = Genode.units.MiB 8 }
|
, resources = Init.Resources::{ ram = Genode.units.MiB 8 }
|
||||||
, routes = [ Init.ServiceRoute.child "Nic" "eth1.driver" ]
|
|
||||||
, config = Init.Config::{
|
, config = Init.Config::{
|
||||||
, attributes = toMap
|
, attributes = toMap
|
||||||
{ interface = "${ipA.address}/${
|
{ interface = "${ipA.address}/${
|
||||||
|
@ -47,7 +46,9 @@
|
||||||
|
|
||||||
};
|
};
|
||||||
testScript = ''
|
testScript = ''
|
||||||
start_all()
|
a.start()
|
||||||
|
a.wait_until_serial_output('lwIP Nic interface up address=192.168.1.1')
|
||||||
|
b.start()
|
||||||
b.wait_until_serial_output('child "ping" exited with exit value 0')
|
b.wait_until_serial_output('child "ping" exited with exit value 0')
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue