From 8fae7131c82d08e475d713cc16ba161f8e9dda9d Mon Sep 17 00:00:00 2001 From: Stefan Kalkowski Date: Mon, 27 May 2013 14:58:44 +0200 Subject: [PATCH] Unify buffer sizes of RX and TX in nic_session In fact, the sizes were the same the whole time, but by using the same enum in both cases to instantiate the Packet_stream_tx and Packet_stream_rx members of the e.g. RPC object, it allows for more flexible generalization between e.g. source or, sink objects, when programming event-driven, and implementing generic handlers for their signals. --- libports/src/lib/lwip/platform/nic.cc | 5 ++--- os/include/nic_session/nic_session.h | 15 +++++---------- os/src/server/nic_bridge/main.cc | 5 ++--- os/src/test/nic_raw/main.cc | 5 ++--- ports-foc/src/lib/l4lx/genode_net.cc | 5 ++--- 5 files changed, 13 insertions(+), 22 deletions(-) diff --git a/libports/src/lib/lwip/platform/nic.cc b/libports/src/lib/lwip/platform/nic.cc index 0dd0fa4a3..778371080 100644 --- a/libports/src/lib/lwip/platform/nic.cc +++ b/libports/src/lib/lwip/platform/nic.cc @@ -246,8 +246,7 @@ extern "C" { /* Initialize nic-session */ enum { PACKET_SIZE = Nic::Packet_allocator::DEFAULT_PACKET_SIZE, - RX_BUF_SIZE = Nic::Session::RX_QUEUE_SIZE * PACKET_SIZE, - TX_BUF_SIZE = Nic::Session::TX_QUEUE_SIZE * PACKET_SIZE, + BUF_SIZE = Nic::Session::QUEUE_SIZE * PACKET_SIZE, }; Nic::Packet_allocator *tx_block_alloc = new (env()->heap()) @@ -255,7 +254,7 @@ extern "C" { Nic::Connection *nic = 0; try { - nic = new (env()->heap()) Nic::Connection(tx_block_alloc, TX_BUF_SIZE, RX_BUF_SIZE); + nic = new (env()->heap()) Nic::Connection(tx_block_alloc, BUF_SIZE, BUF_SIZE); } catch (Parent::Service_denied) { destroy(env()->heap(), tx_block_alloc); return ERR_IF; diff --git a/os/include/nic_session/nic_session.h b/os/include/nic_session/nic_session.h index ddce42403..a7549154b 100644 --- a/os/include/nic_session/nic_session.h +++ b/os/include/nic_session/nic_session.h @@ -39,7 +39,7 @@ namespace Nic { struct Session : Genode::Session { - enum { TX_QUEUE_SIZE = 256, RX_QUEUE_SIZE = 256 }; + enum { QUEUE_SIZE = 256 }; /* * Types used by the client stub code and server implementation @@ -47,16 +47,11 @@ namespace Nic { * The acknowledgement queue has always the same size as the submit * queue. We access the packet content as a char pointer. */ - typedef Packet_stream_policy Tx_policy; + typedef Packet_stream_policy Policy; - typedef Packet_stream_policy Rx_policy; - - typedef Packet_stream_tx::Channel Tx; - typedef Packet_stream_rx::Channel Rx; + typedef Packet_stream_tx::Channel Tx; + typedef Packet_stream_rx::Channel Rx; static const char *service_name() { return "Nic"; } diff --git a/os/src/server/nic_bridge/main.cc b/os/src/server/nic_bridge/main.cc index f2f7e7d19..7afae9e03 100644 --- a/os/src/server/nic_bridge/main.cc +++ b/os/src/server/nic_bridge/main.cc @@ -36,8 +36,7 @@ int main(int, char **) enum { PACKET_SIZE = Nic::Packet_allocator::DEFAULT_PACKET_SIZE, - RX_BUF_SIZE = Nic::Session::RX_QUEUE_SIZE * PACKET_SIZE, - TX_BUF_SIZE = Nic::Session::TX_QUEUE_SIZE * PACKET_SIZE + BUF_SIZE = Nic::Session::QUEUE_SIZE * PACKET_SIZE, }; /* read MAC address prefix from config file */ @@ -50,7 +49,7 @@ int main(int, char **) Root_capability nic_root_cap; try { - static Nic::Connection nic(&tx_block_alloc, TX_BUF_SIZE, RX_BUF_SIZE); + static Nic::Connection nic(&tx_block_alloc, BUF_SIZE, BUF_SIZE); static Net::Rx_handler rx_handler(&nic); static Net::Root nic_root(&ep, env()->heap(), &nic); diff --git a/os/src/test/nic_raw/main.cc b/os/src/test/nic_raw/main.cc index ae54dff77..b06480afb 100644 --- a/os/src/test/nic_raw/main.cc +++ b/os/src/test/nic_raw/main.cc @@ -97,15 +97,14 @@ static void net_init() /* Initialize nic-session */ enum { PACKET_SIZE = Nic::Packet_allocator::DEFAULT_PACKET_SIZE, - RX_BUF_SIZE = Nic::Session::RX_QUEUE_SIZE * PACKET_SIZE, - TX_BUF_SIZE = Nic::Session::TX_QUEUE_SIZE * PACKET_SIZE, + BUF_SIZE = Nic::Session::QUEUE_SIZE * PACKET_SIZE, }; Nic::Packet_allocator *tx_block_alloc = new (env()->heap()) Nic::Packet_allocator(env()->heap()); Nic::Connection *nic = 0; try { - nic = new (env()->heap()) Nic::Connection(tx_block_alloc, TX_BUF_SIZE, RX_BUF_SIZE); + nic = new (env()->heap()) Nic::Connection(tx_block_alloc, BUF_SIZE, BUF_SIZE); } catch (Parent::Service_denied) { destroy(env()->heap(), tx_block_alloc); PERR("could not start Nic service"); diff --git a/ports-foc/src/lib/l4lx/genode_net.cc b/ports-foc/src/lib/l4lx/genode_net.cc index 40191424e..19397d8d3 100644 --- a/ports-foc/src/lib/l4lx/genode_net.cc +++ b/ports-foc/src/lib/l4lx/genode_net.cc @@ -70,8 +70,7 @@ static Nic::Connection *nic() { enum { PACKET_SIZE = Nic::Packet_allocator::DEFAULT_PACKET_SIZE, - RX_BUF_SIZE = Nic::Session::RX_QUEUE_SIZE * PACKET_SIZE, - TX_BUF_SIZE = Nic::Session::TX_QUEUE_SIZE * PACKET_SIZE, + BUF_SIZE = Nic::Session::QUEUE_SIZE * PACKET_SIZE, }; static Nic::Connection *n = 0; @@ -83,7 +82,7 @@ static Nic::Connection *nic() { try { Linux::Irq_guard guard; static Nic::Packet_allocator tx_block_alloc(Genode::env()->heap()); - static Nic::Connection nic(&tx_block_alloc, TX_BUF_SIZE, RX_BUF_SIZE); + static Nic::Connection nic(&tx_block_alloc, BUF_SIZE, BUF_SIZE); n = &nic; } catch(...) { } initialized = true;