aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-06-06 22:01:51 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:59 -0800
commitbf4ff21ce6341f72b72a217d20063878b1b9ecc0 (patch)
tree99bb7fdf3c78e4e4ab0f10d042ea8a0b57f7f759 /host/lib
parentd6d4ac861e61480d3cd8fe7510bda28d8684198c (diff)
downloaduhd-bf4ff21ce6341f72b72a217d20063878b1b9ecc0.tar.gz
uhd-bf4ff21ce6341f72b72a217d20063878b1b9ecc0.tar.bz2
uhd-bf4ff21ce6341f72b72a217d20063878b1b9ecc0.zip
rfnoc: Added anonymous connections capability to graph
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/rfnoc/graph_impl.cpp73
-rw-r--r--host/lib/rfnoc/graph_impl.hpp14
2 files changed, 87 insertions, 0 deletions
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<rfnoc::source_block_ctrl_base>(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<rfnoc::sink_block_ctrl_base>(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
***********************************************************************/