From bf4ff21ce6341f72b72a217d20063878b1b9ecc0 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 6 Jun 2017 22:01:51 -0700 Subject: rfnoc: Added anonymous connections capability to graph --- host/include/uhd/rfnoc/graph.hpp | 32 ++++++++++++++++++ host/lib/rfnoc/graph_impl.cpp | 73 ++++++++++++++++++++++++++++++++++++++++ host/lib/rfnoc/graph_impl.hpp | 14 ++++++++ 3 files changed, 119 insertions(+) diff --git a/host/include/uhd/rfnoc/graph.hpp b/host/include/uhd/rfnoc/graph.hpp index 30d6bf87e..cd7ddacc0 100644 --- a/host/include/uhd/rfnoc/graph.hpp +++ b/host/include/uhd/rfnoc/graph.hpp @@ -9,6 +9,7 @@ #include #include +#include namespace uhd { namespace rfnoc { @@ -42,6 +43,37 @@ public: const block_id_t &dst_block ) = 0; + /*! Anonymous connection. + * + * Danger, danger. You use this, you know what you're doing. + * + * \param src_block Source block ID + * \param src_block_port Source block port + * \param dst_sid SID to route traffic to + * \param buf_size_dst_bytes Destination window buffer in bytes + */ + virtual void connect_src( + const block_id_t &src_block, + const size_t src_block_port, + const uhd::sid_t dst_sid, + const size_t buf_size_dst_bytes, + const size_t pkt_size_ + ) = 0; + + /*! Anonymous connection + * + * Danger, danger. You use this, you know what you're doing. + * + * \param sink_block Sink block ID + * \param dst_block_port Destination (sink) block port + * \param pkts_per_ack Flow controlf frequency in packets + */ + virtual void connect_sink( + const block_id_t &sink_block, + const size_t dst_block_port, + const size_t pkts_per_ack + ) = 0; + virtual std::string get_name() const = 0; }; diff --git a/host/lib/rfnoc/graph_impl.cpp b/host/lib/rfnoc/graph_impl.cpp index be2a4c505..f715c0b65 100644 --- a/host/lib/rfnoc/graph_impl.cpp +++ b/host/lib/rfnoc/graph_impl.cpp @@ -160,3 +160,76 @@ void graph_impl::connect( connect(src_block, ANY_PORT, dst_block, ANY_PORT); } +void graph_impl::connect_src( + const block_id_t &src_block, + const size_t src_block_port, + const uhd::sid_t dst_sid, + const size_t buf_size_dst_bytes, + const size_t pkt_size_ +) { + device3::sptr device_ptr = _device_ptr.lock(); + if (not device_ptr) { + throw uhd::runtime_error("Invalid device"); + } + + UHD_LOGGER_DEBUG("RFNOC") + << "[" << _name << "] Connecting " + << src_block << ":" << src_block_port << " --> " + << dst_sid.to_pp_string_hex(); + + uhd::rfnoc::source_block_ctrl_base::sptr src = + device_ptr->get_block_ctrl(src_block); + + src->set_destination(dst_sid.get(), src_block_port); + + size_t pkt_size = (pkt_size_ != 0) + ? pkt_size_ + : src->get_output_signature(src_block_port).packet_size; + if (pkt_size == 0) { // Unspecified packet rate. Assume max packet size. + UHD_LOGGER_WARNING("RFNOC") + << "Assuming max packet size for " << src->get_block_id(); + pkt_size = uhd::rfnoc::MAX_PACKET_SIZE; + } + size_t buf_size_pkts = buf_size_dst_bytes / pkt_size; + if (buf_size_pkts == 0) { + throw uhd::runtime_error(str( + boost::format("Input FIFO for unknown destination is too small " + "(%d kiB) for packets of size %d kiB\n coming from " + "block %s.") + % (buf_size_dst_bytes / 1024) + % (pkt_size / 1024) + % src->get_block_id().get() + )); + } + src->configure_flow_control_out(buf_size_pkts, src_block_port); + +} + +void graph_impl::connect_sink( + const block_id_t &sink_block, + const size_t dst_block_port, + const size_t pkts_per_ack +) { + device3::sptr device_ptr = _device_ptr.lock(); + if (not device_ptr) { + throw uhd::runtime_error("Invalid device"); + } + + UHD_LOGGER_DEBUG("RFNOC") + << "[" << _name << "] Connecting unknown source to" + << sink_block << ":" << dst_block_port; + + uhd::rfnoc::sink_block_ctrl_base::sptr dst = + device_ptr->get_block_ctrl(sink_block); + dst->configure_flow_control_in( + 0, + pkts_per_ack, + dst_block_port + ); + + /******************************************************************** + * 5. Configure error policy + ********************************************************************/ + dst->set_error_policy("next_burst"); + +} diff --git a/host/lib/rfnoc/graph_impl.hpp b/host/lib/rfnoc/graph_impl.hpp index 865298e71..67d3b3839 100644 --- a/host/lib/rfnoc/graph_impl.hpp +++ b/host/lib/rfnoc/graph_impl.hpp @@ -43,6 +43,20 @@ public: const block_id_t &dst_block ); + void connect_src( + const block_id_t &src_block, + const size_t src_block_port, + const uhd::sid_t dst_sid, + const size_t buf_size_dst_bytes, + const size_t pkt_size_ + ); + + void connect_sink( + const block_id_t &sink_block, + const size_t dst_block_port, + const size_t pkts_per_ack + ); + /************************************************************************ * Utilities ***********************************************************************/ -- cgit v1.2.3