mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-19 11:16:57 +00:00
Nic_bridge: Use Nic::Packet_allocator
Calculate TX and RX dataspace sizes correctly.
This commit is contained in:
parent
3207b4eed0
commit
3736b8b2f2
@ -29,19 +29,20 @@ void Net::Address_node<LEN>::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) { }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <base/lock.h>
|
||||
#include <root/component.h>
|
||||
#include <util/arg_string.h>
|
||||
#include <nic/packet_allocator.h>
|
||||
#include <nic_session/rpc_object.h>
|
||||
#include <nic_session/connection.h>
|
||||
#include <net/ipv4.h>
|
||||
@ -38,7 +39,7 @@ namespace Net {
|
||||
private:
|
||||
|
||||
Genode::Allocator_guard _guarded_alloc;
|
||||
Genode::Allocator_avl _range_alloc;
|
||||
Nic::Packet_allocator _range_alloc;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <base/sleep.h>
|
||||
#include <cap_session/connection.h>
|
||||
#include <nic_session/connection.h>
|
||||
#include <nic/packet_allocator.h>
|
||||
|
||||
#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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user