dde_ipxe: support dis-/reconnect of clients

Unregister callbacks, so rx packets will not be propated to the deleteted
'Driver' object. Initialize ipxe once in the 'Main' object, thus allowing new
session connections.

Fixes #1595
This commit is contained in:
Sebastian Sumpf 2015-06-18 15:16:17 +02:00 committed by Christian Helmuth
parent d80c1c91be
commit 696e5cbd54
3 changed files with 24 additions and 4 deletions

View File

@ -45,6 +45,12 @@ typedef void (*dde_ipxe_nic_rx_cb)(unsigned if_index, const char *packet, unsign
extern void dde_ipxe_nic_register_callbacks(dde_ipxe_nic_rx_cb rx_cb, extern void dde_ipxe_nic_register_callbacks(dde_ipxe_nic_rx_cb rx_cb,
dde_ipxe_nic_link_cb link_cb); dde_ipxe_nic_link_cb link_cb);
/**
* Clear callbacks
*/
extern void dde_ipxe_nic_unregister_callbacks();
/** /**
* Send packet * Send packet
* *

View File

@ -53,10 +53,6 @@ namespace Ipxe {
Nic::Driver_notification &notify) Nic::Driver_notification &notify)
: _ep(ep), _alloc(alloc), _notify(notify) : _ep(ep), _alloc(alloc), _notify(notify)
{ {
PINF("--- init iPXE NIC");
int cnt = dde_ipxe_nic_init(&ep);
PINF(" number of devices: %d", cnt);
PINF("--- init callbacks"); PINF("--- init callbacks");
dde_ipxe_nic_register_callbacks(_rx_callback, _link_callback); dde_ipxe_nic_register_callbacks(_rx_callback, _link_callback);
@ -67,6 +63,8 @@ namespace Ipxe {
_mac_addr.addr[4] & 0xff, _mac_addr.addr[5] & 0xff); _mac_addr.addr[4] & 0xff, _mac_addr.addr[5] & 0xff);
} }
~Driver() { dde_ipxe_nic_unregister_callbacks(); }
void rx_handler(const char *packet, unsigned packet_len) void rx_handler(const char *packet, unsigned packet_len)
{ {
try { try {
@ -146,6 +144,11 @@ struct Main
root(&ep.rpc_ep(), &sliced_heap, factory) root(&ep.rpc_ep(), &sliced_heap, factory)
{ {
PINF("--- iPXE NIC driver started ---\n"); PINF("--- iPXE NIC driver started ---\n");
PINF("--- init iPXE NIC");
int cnt = dde_ipxe_nic_init(&ep);
PINF(" number of devices: %d", cnt);
Genode::env()->parent()->announce(ep.manage(root)); Genode::env()->parent()->announce(ep.manage(root));
} }
}; };

View File

@ -220,6 +220,17 @@ void dde_ipxe_nic_register_callbacks(dde_ipxe_nic_rx_cb rx_cb,
} }
void dde_ipxe_nic_unregister_callbacks(void)
{
dde_lock_enter();
rx_callback = (dde_ipxe_nic_rx_cb)0;
link_callback = (dde_ipxe_nic_link_cb)0;
dde_lock_leave();
}
int dde_ipxe_nic_link_state(unsigned if_index) int dde_ipxe_nic_link_state(unsigned if_index)
{ {
if (if_index != 1) if (if_index != 1)