diff --git a/os/src/server/nic_bridge/address_node.cc b/os/src/server/nic_bridge/address_node.cc index 8002ec273..68bc77e4b 100644 --- a/os/src/server/nic_bridge/address_node.cc +++ b/os/src/server/nic_bridge/address_node.cc @@ -29,19 +29,20 @@ void Net::Address_node::receive_packet(void *addr, Genode::size_t size) Nic::Session::Rx::Source *source = _component->rx_source(); - /* flush remaining acknowledgements */ - while (source->ack_avail()) - source->release_packet(source->get_acked_packet()); + while (true) { + /* flush remaining acknowledgements */ + while (source->ack_avail()) + source->release_packet(source->get_acked_packet()); - try { - /* allocate packet in rx channel */ - Packet_descriptor rx_packet = source->alloc_packet(size); + try { + /* allocate packet in rx channel */ + Packet_descriptor rx_packet = source->alloc_packet(size); - Genode::memcpy((void*)source->packet_content(rx_packet), - (void*)addr, size); - source->submit_packet(rx_packet); - } catch (Nic::Session::Rx::Source::Packet_alloc_failed) { - PWRN("Couldn't transmit packet to client"); + Genode::memcpy((void*)source->packet_content(rx_packet), + (void*)addr, size); + source->submit_packet(rx_packet); + return; + } catch (Nic::Session::Rx::Source::Packet_alloc_failed) { } } } diff --git a/os/src/server/nic_bridge/component.h b/os/src/server/nic_bridge/component.h index 9b46b2a60..7945bd8d0 100644 --- a/os/src/server/nic_bridge/component.h +++ b/os/src/server/nic_bridge/component.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -38,7 +39,7 @@ namespace Net { private: Genode::Allocator_guard _guarded_alloc; - Genode::Allocator_avl _range_alloc; + Nic::Packet_allocator _range_alloc; public: diff --git a/os/src/server/nic_bridge/main.cc b/os/src/server/nic_bridge/main.cc index 8bda67ba9..62ca97c42 100644 --- a/os/src/server/nic_bridge/main.cc +++ b/os/src/server/nic_bridge/main.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include "packet_handler.h" #include "component.h" @@ -29,11 +30,17 @@ int main(int, char **) static Cap_connection cap; static Rpc_entrypoint ep(&cap, STACK_SIZE, "nic_bridge_ep"); - static Genode::Allocator_avl tx_block_alloc(env()->heap()); + static Nic::Packet_allocator tx_block_alloc(env()->heap()); + + 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 + }; Root_capability nic_root_cap; try { - static Nic::Connection nic(&tx_block_alloc); + static Nic::Connection nic(&tx_block_alloc, TX_BUF_SIZE, RX_BUF_SIZE); static Net::Rx_handler rx_handler(&nic); static Net::Root nic_root(&ep, env()->heap(), &nic);