lxip: support wakeup remote and socket_info

* instead of sending packet-stream signals for each possible rx/tx packet
  via genode_nic_client_notify_peers, call the wakeup_remote callback
  which implements the Vfs::Remote_io interface in vfs/ip.
  genode_nic_client_notify_peers will only be called in case the vfs goes idle.

  measured speed up: TX x9.1, RX x1.6

* retrieve genode_socket_info from Linux ipconfig.c

issue #5471
This commit is contained in:
Sebastian Sumpf 2025-01-19 19:17:17 +01:00 committed by Norman Feske
parent 14ae2cc846
commit 6a0c9f50ea
5 changed files with 76 additions and 10 deletions

View File

@ -35,6 +35,9 @@ struct Main
Io_signal_handler<Main> nic_client_handler { env.ep(), *this,
&Main::handle_nic_client };
Io_signal_handler<Main> link_state_handler { env.ep(), *this,
&Main::handle_link_state };
Main(Env &env, genode_socket_io_progress *io_progress)
: env(env), io_progress(io_progress)
{ }
@ -63,11 +66,17 @@ struct Main
io_progress->callback(io_progress->data);
}
void handle_link_state()
{
Genode::error("handle_link_state: not implemented");
}
void init()
{
genode_nic_client_init(genode_env_ptr(env),
genode_allocator_ptr(Lx_kit::env().heap),
genode_signal_handler_ptr(nic_client_handler));
genode_signal_handler_ptr(nic_client_handler),
genode_signal_handler_ptr(link_state_handler));
}
Main(const Main&) = delete;

View File

@ -17,6 +17,7 @@
#include <genode_c_api/nic_client.h>
#include "net_driver.h"
static struct genode_nic_client *dev_nic_client(struct net_device *dev)
{
@ -81,7 +82,7 @@ static int driver_net_xmit(struct sk_buff *skb, struct net_device *dev)
stats->tx_packets++;
stats->tx_bytes += skb->len;
genode_nic_client_notify_peers();
lx_nic_client_schedule_peer();
return NETDEV_TX_OK;
}
@ -154,7 +155,7 @@ static int rx_task_function(void *arg)
&ctx)) {
progress = true; }
if (progress) genode_nic_client_notify_peers();
if (progress) lx_nic_client_schedule_peer();
}
return 0;

View File

@ -20,6 +20,7 @@ extern "C" {
#endif
struct task_struct;
struct task_struct *lx_nic_client_rx_task(void);
void lx_nic_client_schedule_peer(void);
#ifdef __cplusplus
}
#endif

View File

@ -19,12 +19,14 @@
#include <base/log.h>
#include <util/fifo.h>
#include <genode_c_api/nic_client.h>
#include <lx_kit/env.h>
#include <lx_emul/task.h>
#include "lx_socket.h"
#include "lx_user.h"
#include "net_driver.h"
using namespace Genode;
@ -33,6 +35,20 @@ struct Lx_call;
using Socket_queue = Fifo<Lx_call>;
struct Statics
{
genode_socket_wakeup *wakeup_remote;
};
static Statics &statics()
{
static Statics instance { };
return instance;
}
struct genode_socket_handle
{
struct socket *sock { nullptr };
@ -78,6 +94,7 @@ struct Lx_call : private Socket_queue::Element
while (!finished) {
if (may_block == false)
warning("socket interface call blocked (this should not happen)");
genode_socket_wakeup_remote();
genode_socket_wait_for_progress();
}
}
@ -483,6 +500,24 @@ void genode_socket_config_address(struct genode_socket_config *config)
}
extern "C" unsigned int ic_myaddr;
extern "C" unsigned int ic_netmask;
extern "C" unsigned int ic_gateway;
extern "C" unsigned int ic_nameservers[1];
//XXX: implement link state
bool ic_link_state = true;
void genode_socket_config_info(struct genode_socket_info *info)
{
if (!info) return;
info->ip_addr = ic_myaddr;
info->netmask = ic_netmask;
info->gateway = ic_gateway;
info->nameserver = ic_nameservers[0];
info->link_state = ic_link_state;
}
void genode_socket_configure_mtu(unsigned mtu)
{
genode_socket_handle handle = {
@ -658,3 +693,26 @@ enum Errno genode_socket_release(struct genode_socket_handle *handle)
_destroy_handle(handle);
return release.err;
}
void genode_socket_wakeup_remote(void)
{
genode_nic_client_notify_peers();
}
void genode_socket_register_wakeup(struct genode_socket_wakeup *remote)
{
statics().wakeup_remote = remote;
}
/*
* Called by net_driver.c
*/
void lx_nic_client_schedule_peer(void)
{
if (statics().wakeup_remote && statics().wakeup_remote->callback) {
statics().wakeup_remote->callback(statics().wakeup_remote->data);
}
}

View File

@ -10,24 +10,21 @@
genode_socket_getpeername;
genode_socket_getsockname;
genode_socket_getsockopt;
genode_socket_config_info;
genode_socket_init;
genode_socket_listen;
genode_socket_poll;
genode_socket_pollex_set;
genode_socket_pollin_set;
genode_socket_pollout_set;
genode_socket_register_wakeup;
genode_socket_recvmsg;
genode_socket_release;
genode_socket_sendmsg;
genode_socket_setsockopt;
genode_socket_shutdown;
genode_socket_wait_for_progress;
/* dhcp */
ic_myaddr;
ic_netmask;
ic_gateway;
ic_nameservers;
genode_socket_wakeup_remote;
local: