mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-30 02:28:54 +00:00
bbe3ee8dc5
This patch replaces the formerly fixed 2 KiB data alignment within the packet-stream buffer by a server-defined alignment. This has two benefits. First, when using block servers that provide small block sizes like 512 bytes, we avoid fragmenting the packet-stream buffer, which occurs when aligning 512-byte requests at 2 KiB boundaries. This reduces meta data costs for the packet-stream allocator and also allows fitting more requests into the buffer. Second, block drivers with alignment constraints dictated by the hardware can now pass those constraints to the client, thereby easing the use of zero-copy DMA directly into the packet stream. The alignment is determined by the Block::Session_client at construction time and applied by the Block::Session_client::alloc_packet method. Block-session clients should always use this method, not the 'alloc_packet' method of the packet stream (tx source) directly. The latter merely applies a default alignment of 2 KiB. At the server side, the alignment is automatically checked by block/component.h (old API) and block/request_stream.h (new API). Issue #3274
74 lines
1.7 KiB
C++
74 lines
1.7 KiB
C++
/*
|
|
* \brief Client-side block session interface
|
|
* \author Stefan Kalkowski
|
|
* \date 2010-07-06
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2010-2017 Genode Labs GmbH
|
|
*
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
* under the terms of the GNU Affero General Public License version 3.
|
|
*/
|
|
|
|
#ifndef _INCLUDE__BLOCK_SESSION__CLIENT_H_
|
|
#define _INCLUDE__BLOCK_SESSION__CLIENT_H_
|
|
|
|
#include <base/rpc_client.h>
|
|
#include <block_session/capability.h>
|
|
#include <packet_stream_tx/client.h>
|
|
|
|
namespace Block { class Session_client; }
|
|
|
|
|
|
class Block::Session_client : public Genode::Rpc_client<Session>
|
|
{
|
|
private:
|
|
|
|
Packet_stream_tx::Client<Tx> _tx;
|
|
|
|
Info const _info = info();
|
|
|
|
public:
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* \param session session capability
|
|
* \param tx_buffer_alloc allocator used for managing the
|
|
* transmission buffer
|
|
*/
|
|
Session_client(Session_capability session,
|
|
Genode::Range_allocator &tx_buffer_alloc,
|
|
Genode::Region_map &rm)
|
|
:
|
|
Genode::Rpc_client<Session>(session),
|
|
_tx(tx_cap(), rm, tx_buffer_alloc)
|
|
{ }
|
|
|
|
|
|
/*****************************
|
|
** Block session interface **
|
|
*****************************/
|
|
|
|
Info info() const override { return call<Rpc_info>(); }
|
|
|
|
Tx *tx_channel() override { return &_tx; }
|
|
|
|
Tx::Source *tx() override { return _tx.source(); }
|
|
|
|
void sync() override { call<Rpc_sync>(); }
|
|
|
|
Genode::Capability<Tx> tx_cap() override { return call<Rpc_tx_cap>(); }
|
|
|
|
/**
|
|
* Allocate packet respecting the server's alignment constraints
|
|
*/
|
|
Packet_descriptor alloc_packet(Genode::size_t size)
|
|
{
|
|
return tx()->alloc_packet(size, _info.align_log2);
|
|
}
|
|
};
|
|
|
|
#endif /* _INCLUDE__BLOCK_SESSION__CLIENT_H_ */
|