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.
This commit is contained in:
Stefan Kalkowski 2013-05-27 14:58:44 +02:00 committed by Norman Feske
parent 973efe945b
commit 8fae7131c8
5 changed files with 13 additions and 22 deletions

View File

@ -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;

View File

@ -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<Packet_descriptor,
TX_QUEUE_SIZE, TX_QUEUE_SIZE,
char> Tx_policy;
typedef Packet_stream_policy<Packet_descriptor, QUEUE_SIZE, QUEUE_SIZE,
char> Policy;
typedef Packet_stream_policy<Packet_descriptor,
RX_QUEUE_SIZE, RX_QUEUE_SIZE,
char> Rx_policy;
typedef Packet_stream_tx::Channel<Tx_policy> Tx;
typedef Packet_stream_rx::Channel<Rx_policy> Rx;
typedef Packet_stream_tx::Channel<Policy> Tx;
typedef Packet_stream_rx::Channel<Policy> Rx;
static const char *service_name() { return "Nic"; }

View File

@ -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);

View File

@ -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");

View File

@ -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;