mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-20 14:13:09 +00:00
cf72d1aac3
Adds new Uplink session interface, the corresponding client side (Client, Connection), and the corresponding API archives. An Uplink session is almost the same as a NIC session with the difference that the roles of the end points are swapped. An Uplink client is the one that provides a network interface (for instance, a NIC driver) whereas an Uplink server is the one that uses that network interface (for instance, a networking stack). Therefore, in contrast to the NIC session, MAC address and link state come from the Uplink client. The link state is reflected through the lifetime of an Uplink session: The client requests the session only when the link state is "UP" and closes it whenever the link state becomes "DOWN" again. The MAC address is transmitted from the Uplink client to the Uplink server as an argument of the session request. Ref #3961
111 lines
2.9 KiB
C++
111 lines
2.9 KiB
C++
/*
|
|
* \brief Uplink session interface
|
|
* \author Martin Stein
|
|
* \date 2020-11-30
|
|
*/
|
|
|
|
/*
|
|
* Copyright (C) 2020 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 _UPLINK_SESSION__UPLINK_SESSION_H_
|
|
#define _UPLINK_SESSION__UPLINK_SESSION_H_
|
|
|
|
/* Genode includes */
|
|
#include <session/session.h>
|
|
#include <packet_stream_tx/packet_stream_tx.h>
|
|
#include <packet_stream_rx/packet_stream_rx.h>
|
|
|
|
namespace Uplink {
|
|
|
|
struct Session;
|
|
|
|
using Genode::Packet_stream_sink;
|
|
using Genode::Packet_stream_source;
|
|
|
|
typedef Genode::Packet_descriptor Packet_descriptor;
|
|
}
|
|
|
|
|
|
/*
|
|
* Uplink session interface
|
|
*
|
|
* An Uplink session corresponds to a network adaptor, which can be used to
|
|
* transmit and receive network packets. Payload is communicated over the
|
|
* packet-stream interface set up between 'Session_client' and
|
|
* 'Session_server'.
|
|
*
|
|
* Even though the methods 'tx', 'tx_channel', 'rx', and 'rx_channel' are
|
|
* specific for the client side of the Uplink session interface, they are part of
|
|
* the abstract 'Session' class to enable the client-side use of the Uplink
|
|
* interface via a pointer to the abstract 'Session' class. This way, we can
|
|
* transparently co-locate the packet-stream server with the client in same
|
|
* program.
|
|
*/
|
|
struct Uplink::Session : Genode::Session
|
|
{
|
|
enum { QUEUE_SIZE = 1024 };
|
|
|
|
/*
|
|
* Types used by the client stub code and server implementation
|
|
*
|
|
* The acknowledgement queue has always the same size as the submit
|
|
* queue. We access the packet content as a char pointer.
|
|
*/
|
|
typedef Genode::Packet_stream_policy<Genode::Packet_descriptor,
|
|
QUEUE_SIZE, QUEUE_SIZE, char> Policy;
|
|
|
|
typedef Packet_stream_tx::Channel<Policy> Tx;
|
|
typedef Packet_stream_rx::Channel<Policy> Rx;
|
|
|
|
/**
|
|
* \noapi
|
|
*/
|
|
static const char *service_name() { return "Uplink"; }
|
|
|
|
/*
|
|
* An Uplink session consumes a dataspace capability for the server-side
|
|
* session object, a session capability, two packet-stream dataspaces for
|
|
* rx and tx, and four signal context capabilities for the data-flow
|
|
* signals.
|
|
*/
|
|
enum { CAP_QUOTA = 8 };
|
|
|
|
virtual ~Session() { }
|
|
|
|
/**
|
|
* Request packet-transmission channel
|
|
*/
|
|
virtual Tx *tx_channel() { return 0; }
|
|
|
|
/**
|
|
* Request packet-reception channel
|
|
*/
|
|
virtual Rx *rx_channel() { return 0; }
|
|
|
|
/**
|
|
* Request client-side packet-stream interface of tx channel
|
|
*/
|
|
virtual Tx::Source *tx() { return 0; }
|
|
|
|
/**
|
|
* Request client-side packet-stream interface of rx channel
|
|
*/
|
|
virtual Rx::Sink *rx() { return 0; }
|
|
|
|
|
|
/*******************
|
|
** RPC interface **
|
|
*******************/
|
|
|
|
GENODE_RPC(Rpc_tx_cap, Genode::Capability<Tx>, _tx_cap);
|
|
GENODE_RPC(Rpc_rx_cap, Genode::Capability<Rx>, _rx_cap);
|
|
|
|
GENODE_RPC_INTERFACE(Rpc_tx_cap, Rpc_rx_cap);
|
|
};
|
|
|
|
#endif /* _UPLINK_SESSION__UPLINK_SESSION_H_ */
|