From bab20adbb4f7db28007dd2e65b9ab36d01d40615 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 18 Feb 2022 12:13:09 +0100 Subject: rfnoc: replay: Add action handler for stream commands When connecting an Rx streamer to a replay block, this now allows requesting data from the replay block using a stream command. This will automatically request data from all ports the streamer is connected to, and even if there are blocks in between (depending on their action forwarding policies). --- host/lib/rfnoc/replay_block_control.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'host') diff --git a/host/lib/rfnoc/replay_block_control.cpp b/host/lib/rfnoc/replay_block_control.cpp index ce431ba80..43a5ff43b 100644 --- a/host/lib/rfnoc/replay_block_control.cpp +++ b/host/lib/rfnoc/replay_block_control.cpp @@ -91,6 +91,8 @@ public: get_unique_id(), false /* Let it slide if minors mismatch */ ); + RFNOC_LOG_TRACE( + "Initializing replay block with num ports=" << get_num_input_ports()); // Properties and actions can't propagate through this block, as we // treat source and sink of this block like the radio (they terminate // the graph). @@ -98,6 +100,30 @@ public: set_action_forwarding_policy(forwarding_policy_t::DROP); // Same for MTU set_mtu_forwarding_policy(forwarding_policy_t::DROP); + // Register action handler + register_action_handler(ACTION_KEY_STREAM_CMD, + [this](const res_source_info& src, action_info::sptr action) { + stream_cmd_action_info::sptr stream_cmd_action = + std::dynamic_pointer_cast(action); + if (!stream_cmd_action) { + RFNOC_LOG_WARNING("Received invalid stream command action!"); + return; + } + RFNOC_LOG_TRACE("Received stream command: " + << stream_cmd_action->stream_cmd.stream_mode << " to " + << src.to_string()); + if (src.type != res_source_info::OUTPUT_EDGE) { + RFNOC_LOG_WARNING( + "Received stream command, but not to output port! Ignoring."); + return; + } + const size_t port = src.instance; + if (port >= get_num_output_ports()) { + RFNOC_LOG_WARNING("Received stream command to invalid output port!"); + return; + } + issue_stream_cmd(stream_cmd_action->stream_cmd, port); + }); // Initialize record properties _record_type.reserve(_num_input_ports); -- cgit v1.2.3