ipxe nic_drv: do not leak packets on link down/up

On link down toggle the netdev off/on to drain the TX DMA. As long as the link
stays down, do not write packets to TX DMA.
This commit is contained in:
Martin Stein 2018-05-27 23:18:47 +02:00 committed by Christian Helmuth
parent a3905fcf87
commit 136b23cb5e
2 changed files with 15 additions and 3 deletions

View File

@ -65,8 +65,10 @@ class Ipxe_session_component : public Nic::Session_component
return true;
}
if (dde_ipxe_nic_tx(1, _tx.sink()->packet_content(packet), packet.size()))
Genode::warning("Sending packet failed!");
if (link_state()) {
if (dde_ipxe_nic_tx(1, _tx.sink()->packet_content(packet), packet.size()))
Genode::warning("Sending packet failed!");
}
_tx.sink()->acknowledge_packet(packet);
return true;

View File

@ -199,10 +199,20 @@ static void irq_handler(void *p)
dde_lock_leave();
if (link_ok != netdev_link_ok(net_dev))
int const new_link_ok = netdev_link_ok(net_dev);
if (link_ok != new_link_ok) {
/* report link-state changes */
if (link_callback)
link_callback();
/* on link down, drain TX DMA to not leak packets on next link up */
if (!new_link_ok) {
netdev_close(net_dev);
netdev_open(net_dev);
netdev_irq(net_dev, 1);
}
}
}