diff --git a/repos/dde_ipxe/README b/repos/dde_ipxe/README index a568129b68..18902f7a1d 100644 --- a/repos/dde_ipxe/README +++ b/repos/dde_ipxe/README @@ -15,3 +15,10 @@ build directory, for example After successful build the DDE iPXE based ethernet driver is located at 'bin/nic_drv'. + +The driver optionally reports the following information under the +label "devices" if requested in the config as depicted. + +! + +! diff --git a/repos/dde_ipxe/recipes/src/ipxe_nic_drv/used_apis b/repos/dde_ipxe/recipes/src/ipxe_nic_drv/used_apis index 6c0feab87e..d9fdee2a91 100644 --- a/repos/dde_ipxe/recipes/src/ipxe_nic_drv/used_apis +++ b/repos/dde_ipxe/recipes/src/ipxe_nic_drv/used_apis @@ -1,7 +1,8 @@ base -os -nic_session -uplink_session nic_driver +nic_session +os platform_session +report_session timer_session +uplink_session diff --git a/repos/dde_ipxe/src/drivers/nic/main.cc b/repos/dde_ipxe/src/drivers/nic/main.cc index c6c2b3c428..42c5a4f4d3 100644 --- a/repos/dde_ipxe/src/drivers/nic/main.cc +++ b/repos/dde_ipxe/src/drivers/nic/main.cc @@ -19,6 +19,7 @@ #include #include #include +#include /* NIC driver includes */ #include @@ -104,6 +105,8 @@ class Uplink_client : public Uplink_client_base dde_ipxe_nic_unregister_callbacks(); instance = nullptr; } + + Net::Mac_address mac_address() const { return _drv_mac_addr; } }; @@ -116,7 +119,7 @@ struct Main Heap _heap { _env.ram(), _env.rm() }; Attached_rom_dataspace _config_rom { _env, "config" }; Constructible _uplink { }; - + Constructible _reporter { }; Main(Env &env) : _env(env) { @@ -129,6 +132,23 @@ struct Main } _uplink.construct(_env, _heap); + + _config_rom.xml().with_sub_node("report", [&] (Xml_node const &xml) { + bool const report_mac_address = + xml.attribute_value("mac_address", false); + + if (!report_mac_address) + return; + + _reporter.construct(_env, "devices"); + _reporter->enabled(true); + + Reporter::Xml_generator report(*_reporter, [&] () { + report.node("nic", [&] () { + report.attribute("mac_address", String<32>(_uplink->mac_address())); + }); + }); + }); } };