From 4abc5309741f70ba5ae54e85503894406a2f3667 Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Tue, 25 May 2021 14:12:13 +0200 Subject: [PATCH] ipxe_nic_drv: remove nic_server mode Issue #4133 --- .../dde_ipxe/recipes/pkg/ipxe_nic_drv/runtime | 2 - repos/dde_ipxe/src/drivers/nic/main.cc | 150 ++---------------- repos/dde_linux/run/nic_router_uplinks.run | 1 - .../recipes/raw/drivers_nic-pc/drivers.config | 1 - repos/gems/run/ssh_exec_channel.run | 1 - repos/gems/run/ssh_terminal.run | 1 - .../src/app/sculpt_manager/runtime/nic_drv.cc | 2 +- repos/ports/run/seoul.inc | 1 - repos/ports/run/vbox_share.inc | 1 - repos/ports/run/vbox_win.inc | 1 - repos/ports/run/virtualbox.run | 1 - repos/ports/run/virtualbox6.run | 1 - 12 files changed, 10 insertions(+), 153 deletions(-) diff --git a/repos/dde_ipxe/recipes/pkg/ipxe_nic_drv/runtime b/repos/dde_ipxe/recipes/pkg/ipxe_nic_drv/runtime index 38d1872c7a..3950b1248a 100755 --- a/repos/dde_ipxe/recipes/pkg/ipxe_nic_drv/runtime +++ b/repos/dde_ipxe/recipes/pkg/ipxe_nic_drv/runtime @@ -1,7 +1,5 @@ - - diff --git a/repos/dde_ipxe/src/drivers/nic/main.cc b/repos/dde_ipxe/src/drivers/nic/main.cc index 632abec717..c6c2b3c428 100644 --- a/repos/dde_ipxe/src/drivers/nic/main.cc +++ b/repos/dde_ipxe/src/drivers/nic/main.cc @@ -6,7 +6,7 @@ */ /* - * Copyright (C) 2011-2017 Genode Labs GmbH + * Copyright (C) 2011-2021 Genode Labs GmbH * * This file is distributed under the terms of the GNU General Public License * version 2. @@ -17,14 +17,11 @@ #include #include #include -#include -#include #include #include /* NIC driver includes */ #include -#include /* DDE iPXE includes */ #include @@ -32,118 +29,6 @@ using namespace Genode; -class Ipxe_session_component : public Nic::Session_component -{ - public: - - static Ipxe_session_component *instance; - - private: - - Nic::Mac_address _mac_addr; - - static void _rx_callback(unsigned if_index, - const char *packet, - unsigned packet_len) - { - if (instance) - instance->_receive(packet, packet_len); - } - - static void _link_callback() - { - if (instance) - instance->_link_state_changed(); - } - - bool _send() - { - using namespace Genode; - - if (!_tx.sink()->ready_to_ack()) - return false; - - if (!_tx.sink()->packet_avail()) - return false; - - Packet_descriptor packet = _tx.sink()->get_packet(); - if (!packet.size()) { - warning("Invalid tx packet"); - return true; - } - - if (link_state()) { - if (dde_ipxe_nic_tx(1, _tx.sink()->packet_content(packet), packet.size())) - warning("Sending packet failed!"); - } - - _tx.sink()->acknowledge_packet(packet); - return true; - } - - void _receive(const char *packet, unsigned packet_len) - { - _handle_packet_stream(); - - if (!_rx.source()->ready_to_submit()) - return; - - try { - Nic::Packet_descriptor p = _rx.source()->alloc_packet(packet_len); - memcpy(_rx.source()->packet_content(p), packet, packet_len); - _rx.source()->submit_packet(p); - } catch (...) { - warning(__func__, ": failed to process received packet"); - } - } - - void _handle_packet_stream() override - { - while (_rx.source()->ack_avail()) - _rx.source()->release_packet(_rx.source()->get_acked_packet()); - - while (_send()) ; - } - - public: - - Ipxe_session_component(size_t const tx_buf_size, - size_t const rx_buf_size, - Allocator &rx_block_md_alloc, - Env &env) - : Session_component(tx_buf_size, rx_buf_size, CACHED, - rx_block_md_alloc, env) - { - instance = this; - - dde_ipxe_nic_register_callbacks(_rx_callback, _link_callback); - - dde_ipxe_nic_get_mac_addr(1, _mac_addr.addr); - - log("MAC address ", _mac_addr); - } - - ~Ipxe_session_component() - { - instance = nullptr; - dde_ipxe_nic_unregister_callbacks(); - } - - /************************************** - ** Nic::Session_component interface ** - **************************************/ - - Nic::Mac_address mac_address() override { return _mac_addr; } - - bool link_state() override - { - return dde_ipxe_nic_link_state(1); - } -}; - - -Ipxe_session_component *Ipxe_session_component::instance; - class Uplink_client : public Uplink_client_base { @@ -153,13 +38,13 @@ class Uplink_client : public Uplink_client_base private: - Nic::Mac_address _init_drv_mac_addr() + Net::Mac_address _init_drv_mac_addr() { instance = this; dde_ipxe_nic_register_callbacks( _drv_rx_callback, _drv_link_callback); - Nic::Mac_address mac_addr { }; + Net::Mac_address mac_addr { }; dde_ipxe_nic_get_mac_addr(1, mac_addr.addr); return mac_addr; } @@ -227,40 +112,23 @@ Uplink_client *Uplink_client::instance; struct Main { - Env &_env; - Heap _heap { _env.ram(), _env.rm() }; - Attached_rom_dataspace _config_rom { _env, "config" }; + Env &_env; + Heap _heap { _env.ram(), _env.rm() }; + Attached_rom_dataspace _config_rom { _env, "config" }; + Constructible _uplink { }; + Main(Env &env) : _env(env) { log("--- iPXE NIC driver started ---"); - log("-- init iPXE NIC"); - - /* pass Env to backend */ dde_support_init(_env, _heap); if (!dde_ipxe_nic_init()) { error("could not find usable NIC device"); } - Nic_driver_mode const mode { - read_nic_driver_mode(_config_rom.xml()) }; - switch (mode) { - case Nic_driver_mode::NIC_SERVER: - { - Nic::Root &root { - *new (_heap) - Nic::Root(_env, _heap) }; - - _env.parent().announce(_env.ep().manage(root)); - break; - } - case Nic_driver_mode::UPLINK_CLIENT: - - new (_heap) Uplink_client(_env, _heap); - break; - } + _uplink.construct(_env, _heap); } }; diff --git a/repos/dde_linux/run/nic_router_uplinks.run b/repos/dde_linux/run/nic_router_uplinks.run index b4013e6e48..70400dbf15 100644 --- a/repos/dde_linux/run/nic_router_uplinks.run +++ b/repos/dde_linux/run/nic_router_uplinks.run @@ -77,7 +77,6 @@ append config { - diff --git a/repos/gems/recipes/raw/drivers_nic-pc/drivers.config b/repos/gems/recipes/raw/drivers_nic-pc/drivers.config index ff8a6da96b..07e023fea8 100644 --- a/repos/gems/recipes/raw/drivers_nic-pc/drivers.config +++ b/repos/gems/recipes/raw/drivers_nic-pc/drivers.config @@ -74,7 +74,6 @@ - diff --git a/repos/gems/run/ssh_exec_channel.run b/repos/gems/run/ssh_exec_channel.run index 569bb7172f..f098d17b87 100644 --- a/repos/gems/run/ssh_exec_channel.run +++ b/repos/gems/run/ssh_exec_channel.run @@ -75,7 +75,6 @@ set config { - diff --git a/repos/gems/run/ssh_terminal.run b/repos/gems/run/ssh_terminal.run index 6d32e99195..b570dac8de 100644 --- a/repos/gems/run/ssh_terminal.run +++ b/repos/gems/run/ssh_terminal.run @@ -71,7 +71,6 @@ set config { - diff --git a/repos/gems/src/app/sculpt_manager/runtime/nic_drv.cc b/repos/gems/src/app/sculpt_manager/runtime/nic_drv.cc index f36e3ce468..5a8bbd3251 100644 --- a/repos/gems/src/app/sculpt_manager/runtime/nic_drv.cc +++ b/repos/gems/src/app/sculpt_manager/runtime/nic_drv.cc @@ -22,7 +22,7 @@ void Sculpt::gen_nic_drv_start_content(Xml_generator &xml) gen_named_node(xml, "resource", "CPU", [&] () { xml.attribute("quantum", "50"); }); - xml.node("config", [&] () { xml.attribute("mode", "uplink_client"); }); + xml.node("config", [&] () { }); xml.node("route", [&] () { diff --git a/repos/ports/run/seoul.inc b/repos/ports/run/seoul.inc index 4bcbb7569b..de788a505e 100644 --- a/repos/ports/run/seoul.inc +++ b/repos/ports/run/seoul.inc @@ -375,7 +375,6 @@ append_if $use_nic_session config { - diff --git a/repos/ports/run/vbox_share.inc b/repos/ports/run/vbox_share.inc index 0247c17da5..53ff77510b 100644 --- a/repos/ports/run/vbox_share.inc +++ b/repos/ports/run/vbox_share.inc @@ -129,7 +129,6 @@ set config_of_app { - diff --git a/repos/ports/run/vbox_win.inc b/repos/ports/run/vbox_win.inc index 81c359af7e..142b0665c5 100644 --- a/repos/ports/run/vbox_win.inc +++ b/repos/ports/run/vbox_win.inc @@ -86,7 +86,6 @@ set config_of_app { - diff --git a/repos/ports/run/virtualbox.run b/repos/ports/run/virtualbox.run index a5e997ce36..8cd15801f2 100644 --- a/repos/ports/run/virtualbox.run +++ b/repos/ports/run/virtualbox.run @@ -100,7 +100,6 @@ append_if [expr $use_net] config { - diff --git a/repos/ports/run/virtualbox6.run b/repos/ports/run/virtualbox6.run index 140fed9447..82a2f562a7 100644 --- a/repos/ports/run/virtualbox6.run +++ b/repos/ports/run/virtualbox6.run @@ -123,7 +123,6 @@ append_if [expr $use_net] config { -