From 7aa9cf9b373bc22a1a9cd289cd5b27fa8293f744 Mon Sep 17 00:00:00 2001 From: Johannes Schlatow Date: Wed, 26 Jan 2022 16:44:40 +0100 Subject: [PATCH] uplink_client_base: add handlers for zynq_nic_drv The zynq_nic_drv follows a zero-copy approach and thus uses the packet buffers as DMA memory. In order to know when the RX DMA memory can be used for another packet, a custom ack_avail_handler is needed. Similarly, packets received from the Uplink session are not copied to a DMA buffer but to directly passed on as DMA memory. For this purpose, a a custom packet_avail handler is needed. genodelabs/genode#4384 --- .../include/drivers/nic/uplink_client_base.h | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/repos/os/src/drivers/nic/include/drivers/nic/uplink_client_base.h b/repos/os/src/drivers/nic/include/drivers/nic/uplink_client_base.h index 543b47431d..0d3df4ceb8 100644 --- a/repos/os/src/drivers/nic/include/drivers/nic/uplink_client_base.h +++ b/repos/os/src/drivers/nic/include/drivers/nic/uplink_client_base.h @@ -62,6 +62,12 @@ class Genode::Uplink_client_base : Noncopyable if (!_conn.constructed()) { return; } + + if (_custom_conn_tx_ack_avail_handler()) { + _custom_conn_tx_handle_ack_avail(); + return; + } + while (_conn->tx()->ack_avail()) { _conn->tx()->release_packet(_conn->tx()->get_acked_packet()); @@ -73,6 +79,12 @@ class Genode::Uplink_client_base : Noncopyable if (!_conn.constructed()) { return; } + + if (_custom_conn_rx_packet_avail_handler()) { + _custom_conn_rx_handle_packet_avail(); + return; + } + bool drv_ready_to_transmit_pkt { _drv_link_state }; bool pkts_transmitted { false }; @@ -230,6 +242,22 @@ class Genode::Uplink_client_base : Noncopyable _drv_transmit_pkt(const char *conn_rx_pkt_base, size_t conn_rx_pkt_size) = 0; + virtual void _custom_conn_rx_handle_packet_avail() + { + class Unexpected_call { }; + throw Unexpected_call { }; + } + + virtual void _custom_conn_tx_handle_ack_avail() + { + class Unexpected_call { }; + throw Unexpected_call { }; + } + + virtual bool _custom_conn_rx_packet_avail_handler() { return false; } + + virtual bool _custom_conn_tx_ack_avail_handler() { return false; } + public: Uplink_client_base(Env &env,