ipxe_nic_drv: remove nic_server mode

Issue #4133
This commit is contained in:
Christian Helmuth 2021-05-25 14:12:13 +02:00
parent 583ba0e9db
commit 4abc530974
12 changed files with 10 additions and 153 deletions

View File

@ -1,7 +1,5 @@
<runtime ram="16M" caps="300" binary="ipxe_nic_drv">
<provides> <nic/> </provides>
<config/>
<content>

View File

@ -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 <base/env.h>
#include <base/heap.h>
#include <base/log.h>
#include <nic/component.h>
#include <nic/root.h>
#include <uplink_session/connection.h>
#include <base/attached_rom_dataspace.h>
/* NIC driver includes */
#include <drivers/nic/uplink_client_base.h>
#include <drivers/nic/mode.h>
/* DDE iPXE includes */
#include <dde_ipxe/support.h>
@ -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_client> _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<Ipxe_session_component> &root {
*new (_heap)
Nic::Root<Ipxe_session_component>(_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);
}
};

View File

@ -77,7 +77,6 @@ append config {
<start name="nic_drv" priority="-1" caps="120">
<binary name="ipxe_nic_drv"/>
<resource name="RAM" quantum="8M"/>
<config mode="uplink_client"/>
<route>
<service name="Uplink"> <child name="router"/> </service>
<any-service> <parent/> <any-child/> </any-service>

View File

@ -74,7 +74,6 @@
<start name="nic_drv" caps="120">
<binary name="ipxe_nic_drv"/>
<resource name="RAM" quantum="8M"/>
<config mode="uplink_client"/>
<route>
<service name="Platform"> <child name="platform_drv"/> </service>
<service name="ROM"> <parent/> </service>

View File

@ -75,7 +75,6 @@ set config {
<start name="nic_drv" caps="120">
<binary name="ipxe_nic_drv"/>
<resource name="RAM" quantum="8M"/>
<config mode="uplink_client"/>
<route>
<service name="Uplink"> <child name="nic_router"/> </service>
<any-service> <parent/> <any-child/> </any-service>

View File

@ -71,7 +71,6 @@ set config {
<start name="nic_drv">
<binary name="ipxe_nic_drv"/>
<resource name="RAM" quantum="8M"/>
<config mode="uplink_client"/>
<route>
<service name="Uplink"> <child name="nic_router"/> </service>
<any-service> <parent/> <any-child/> </any-service>

View File

@ -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", [&] () {

View File

@ -375,7 +375,6 @@ append_if $use_nic_session config {
<start name="nic_drv" priority="-2">
<binary name="ipxe_nic_drv"/>
<resource name="RAM" quantum="8M"/>
<config mode="uplink_client"/>
<route>
<service name="Uplink"><child name="nic_router"/></service>
<any-service><parent/><any-child/></any-service>

View File

@ -129,7 +129,6 @@ set config_of_app {
<start name="nic_drv" priority="-1">
<binary name="ipxe_nic_drv"/>
<resource name="RAM" quantum="8M"/>
<config mode="uplink_client"/>
<route>
<service name="Uplink"><child name="nic_router"/></service>
<any-service> <parent/> <any-child/> </any-service>

View File

@ -86,7 +86,6 @@ set config_of_app {
<start name="nic_drv" priority="-1">
<binary name="ipxe_nic_drv"/>
<resource name="RAM" quantum="8M" />
<config mode="uplink_client"/>
<route>
<service name="Uplink"> <child name="nic_router"/> </service>
<any-service> <parent/> <any-child /> </any-service>

View File

@ -100,7 +100,6 @@ append_if [expr $use_net] config {
<start name="nic_drv" priority="-1">
<binary name="ipxe_nic_drv"/>
<resource name="RAM" quantum="8M"/>
<config mode="uplink_client"/>
<route>
<service name="Uplink"> <child name="nic_router"/> </service>
<any-service> <parent/> <any-child /> </any-service>

View File

@ -123,7 +123,6 @@ append_if [expr $use_net] config {
<start name="nic_drv" priority="-1">
<binary name="ipxe_nic_drv"/>
<resource name="RAM" quantum="8M"/>
<config mode="uplink_client"/>
<route>
<service name="Platform"> <child name="drivers"/> </service>
<service name="Uplink"> <child name="nic_router"/> </service>