From 56831a247fe10691a748468c434e0e9c02a1221c Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Tue, 26 Apr 2022 11:24:12 +0200 Subject: [PATCH] usb_net_drv: remove deprecated server mode Ref genodelabs/genode#3961 --- repos/dde_linux/run/usb_net.run | 2 +- .../src/drivers/usb_net/component.cc | 127 ------------------ .../dde_linux/src/drivers/usb_net/component.h | 109 --------------- repos/dde_linux/src/drivers/usb_net/driver.h | 24 +--- repos/dde_linux/src/drivers/usb_net/main.cc | 3 - repos/dde_linux/src/drivers/usb_net/target.mk | 2 +- repos/ports/run/netperf.inc | 2 +- 7 files changed, 7 insertions(+), 262 deletions(-) delete mode 100644 repos/dde_linux/src/drivers/usb_net/component.cc delete mode 100644 repos/dde_linux/src/drivers/usb_net/component.h diff --git a/repos/dde_linux/run/usb_net.run b/repos/dde_linux/run/usb_net.run index 0db4ae1ce1..d9e2c32342 100644 --- a/repos/dde_linux/run/usb_net.run +++ b/repos/dde_linux/run/usb_net.run @@ -77,7 +77,7 @@ append config { - + diff --git a/repos/dde_linux/src/drivers/usb_net/component.cc b/repos/dde_linux/src/drivers/usb_net/component.cc deleted file mode 100644 index 6f131c5c9a..0000000000 --- a/repos/dde_linux/src/drivers/usb_net/component.cc +++ /dev/null @@ -1,127 +0,0 @@ -/* - * \brief Freescale ethernet driver component - * \author Stefan Kalkowski - * \date 2017-11-01 - */ - -/* - * Copyright (C) 2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#include -#include - -extern "C" { -#include -}; - - -bool Session_component::_send() -{ - using namespace Genode; - - /* - * We must not be called from another task, just from the - * packet stream dispatcher. - */ - if (Lx::scheduler().active()) { - warning("scheduler active"); - return false; - } - - 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() || !_tx.sink()->packet_valid(packet)) { - warning("invalid tx packet"); - return true; - } - - struct sk_buff *skb = lxc_alloc_skb(packet.size() + HEAD_ROOM, HEAD_ROOM); - - unsigned char *data = lxc_skb_put(skb, packet.size()); - Genode::memcpy(data, _tx.sink()->packet_content(packet), packet.size()); - - _tx_data.ndev = _ndev; - _tx_data.skb = skb; - - _tx_task.unblock(); - Lx::scheduler().schedule(); - - _tx.sink()->acknowledge_packet(packet); - - return true; -} - - -void Session_component::_handle_rx() -{ - while (_rx.source()->ack_avail()) - _rx.source()->release_packet(_rx.source()->get_acked_packet()); -} - - -void Session_component::_handle_packet_stream() -{ - _handle_rx(); - - while (_send()) continue; -} - - -Nic::Mac_address Session_component::mac_address() -{ - return _ndev ? Nic::Mac_address(_ndev->dev_addr) : Nic::Mac_address(); -} - - -void Session_component::receive(struct sk_buff *skb) -{ - _handle_rx(); - - if (!_rx.source()->ready_to_submit()) { - Genode::warning("not ready to receive packet"); - return; - } - - Skb s = skb_helper(skb); - - try { - Nic::Packet_descriptor p = _rx.source()->alloc_packet(s.packet_size + s.frag_size); - void *buffer = _rx.source()->packet_content(p); - memcpy(buffer, s.packet, s.packet_size); - - if (s.frag_size) - memcpy((char *)buffer + s.packet_size, s.frag, s.frag_size); - - _rx.source()->submit_packet(p); - } catch (...) { - Genode::warning("failed to process received packet"); - } -} - - -void Session_component::link_state(bool link) -{ - if (link == _has_link) return; - - _has_link = link; - _link_state_changed(); -} - - -Session_component::Session_component(Genode::size_t const tx_buf_size, - Genode::size_t const rx_buf_size, - Genode::Allocator &rx_block_md_alloc, - Genode::Env &env, - Genode::Session_label const &label) -: - Nic::Session_component { tx_buf_size, rx_buf_size, Genode::CACHED, - rx_block_md_alloc, env }, - Linux_network_session_base { label }, - _has_link { _read_link_state_from_ndev() } -{ } diff --git a/repos/dde_linux/src/drivers/usb_net/component.h b/repos/dde_linux/src/drivers/usb_net/component.h deleted file mode 100644 index 55ab7c8139..0000000000 --- a/repos/dde_linux/src/drivers/usb_net/component.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * \brief Freescale ethernet driver component - * \author Stefan Kalkowski - * \date 2017-11-01 - */ - -/* - * Copyright (C) 2017 Genode Labs GmbH - * - * This file is distributed under the terms of the GNU General Public License - * version 2. - */ - -#ifndef _SRC__DRIVERS__NIC__FEC__COMPONENT_H_ -#define _SRC__DRIVERS__NIC__FEC__COMPONENT_H_ - -/* Genode includes */ -#include -#include - -/* local includes */ -#include - - -class Session_component : public Nic::Session_component, - public Linux_network_session_base -{ - private: - - bool _has_link = false; - - bool _send(); - void _handle_rx(); - void _handle_packet_stream() override; - - public: - - Session_component(Genode::size_t const tx_buf_size, - Genode::size_t const rx_buf_size, - Genode::Allocator &rx_block_md_alloc, - Genode::Env &env, - Genode::Session_label const &label); - - - /**************************** - ** Nic::Session_component ** - ****************************/ - - Nic::Mac_address mac_address() override; - bool link_state() override { return _has_link; } - - - /******************************** - ** Linux_network_session_base ** - ********************************/ - - void link_state(bool link) override; - void receive(struct sk_buff *skb) override; -}; - - -class Root : public Genode::Root_component -{ - private: - - Genode::Env &_env; - Genode::Allocator &_md_alloc; - - protected: - - Session_component *_create_session(const char *args) - { - using namespace Genode; - - Session_label const label = label_from_args(args); - - size_t ram_quota = Arg_string::find_arg(args, "ram_quota" ).ulong_value(0); - size_t tx_buf_size = Arg_string::find_arg(args, "tx_buf_size").ulong_value(0); - size_t rx_buf_size = Arg_string::find_arg(args, "rx_buf_size").ulong_value(0); - - /* deplete ram quota by the memory needed for the session structure */ - size_t session_size = max(4096UL, (unsigned long)sizeof(Session_component)); - - /* - * Check if donated ram quota suffices for both communication - * buffers and check for overflow - */ - if ((ram_quota < session_size) || - (tx_buf_size + rx_buf_size < tx_buf_size || - tx_buf_size + rx_buf_size > ram_quota - session_size)) { - Genode::error("insufficient 'ram_quota', got ", ram_quota, ", " - "need ", tx_buf_size + rx_buf_size + session_size); - throw Genode::Insufficient_ram_quota(); - } - - return new (Root::md_alloc()) - Session_component(tx_buf_size, rx_buf_size, - _md_alloc, _env, label); - } - - public: - - Root(Genode::Env &env, Genode::Allocator &md_alloc) - : Genode::Root_component(&env.ep().rpc_ep(), &md_alloc), - _env(env), _md_alloc(md_alloc) - { } -}; - -#endif /* _SRC__DRIVERS__NIC__FEC__COMPONENT_H_ */ diff --git a/repos/dde_linux/src/drivers/usb_net/driver.h b/repos/dde_linux/src/drivers/usb_net/driver.h index 0458602e18..3505117f13 100644 --- a/repos/dde_linux/src/drivers/usb_net/driver.h +++ b/repos/dde_linux/src/drivers/usb_net/driver.h @@ -23,14 +23,10 @@ /* local includes */ #include -#include /* Linux emulation environment includes */ #include -/* NIC driver includes */ -#include - struct usb_device_id; struct usb_interface; struct usb_device; @@ -101,10 +97,8 @@ struct Driver Genode::Env &env; Genode::Entrypoint &ep { env.ep() }; Genode::Attached_rom_dataspace config_rom { env, "config" }; - Genode::Nic_driver_mode const mode { read_nic_driver_mode(config_rom.xml()) }; Genode::Heap heap { env.ram(), env.rm() }; Genode::Allocator_avl alloc { &heap }; - Genode::Constructible root { }; Genode::Constructible uplink_client { }; Genode::Constructible main_task; Genode::Constructible report_rom; @@ -113,20 +107,10 @@ struct Driver void activate_network_session() { - switch (mode) { - case Genode::Nic_driver_mode::NIC_SERVER: - - env.parent().announce(ep.manage(*root)); - break; - - case Genode::Nic_driver_mode::UPLINK_CLIENT: - - uplink_client.construct( - env, heap, - config_rom.xml().attribute_value( - "uplink_label", Genode::Session_label::String { "" })); - break; - } + uplink_client.construct( + env, heap, + config_rom.xml().attribute_value( + "uplink_label", Genode::Session_label::String { "" })); } static void main_task_entry(void *); diff --git a/repos/dde_linux/src/drivers/usb_net/main.cc b/repos/dde_linux/src/drivers/usb_net/main.cc index 3989b47b59..52c528b25c 100644 --- a/repos/dde_linux/src/drivers/usb_net/main.cc +++ b/repos/dde_linux/src/drivers/usb_net/main.cc @@ -195,9 +195,6 @@ Driver::Driver(Genode::Env &env) : env(env) { Genode::log("--- USB net driver ---"); - if (mode == Genode::Nic_driver_mode::NIC_SERVER) { - root.construct(env, heap); - } Lx_kit::construct_env(env); Lx::scheduler(&env); Lx::malloc_init(env, heap); diff --git a/repos/dde_linux/src/drivers/usb_net/target.mk b/repos/dde_linux/src/drivers/usb_net/target.mk index c3ead71000..1c85626d29 100644 --- a/repos/dde_linux/src/drivers/usb_net/target.mk +++ b/repos/dde_linux/src/drivers/usb_net/target.mk @@ -1,6 +1,6 @@ TARGET := usb_net_drv SRC_C := dummies.c lxc.c -SRC_CC := main.cc lx_emul.cc component.cc linux_network_session_base.cc +SRC_CC := main.cc lx_emul.cc linux_network_session_base.cc SRC_CC += printf.cc bug.cc timer.cc scheduler.cc malloc.cc env.cc work.cc SRC_CC += uplink_client.cc diff --git a/repos/ports/run/netperf.inc b/repos/ports/run/netperf.inc index 705a7a1143..c91cdc93b5 100644 --- a/repos/ports/run/netperf.inc +++ b/repos/ports/run/netperf.inc @@ -305,7 +305,7 @@ append config { - +