aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/device3
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2016-11-08 08:41:46 -0800
committerMartin Braun <martin.braun@ettus.com>2016-11-08 08:41:46 -0800
commit9b852f5f243e5cf68662b7152b5fa331a83e55fb (patch)
tree159ffe0761f78dd87e2ecc97abea14494abab4ff /host/lib/usrp/device3
parentc66cb1bad0d881394f3519bd94f4693cceab4c64 (diff)
parent99c2730bc9db270560671f2d7d173768465ed51f (diff)
downloaduhd-9b852f5f243e5cf68662b7152b5fa331a83e55fb.tar.gz
uhd-9b852f5f243e5cf68662b7152b5fa331a83e55fb.tar.bz2
uhd-9b852f5f243e5cf68662b7152b5fa331a83e55fb.zip
Merge branch 'maint'
Diffstat (limited to 'host/lib/usrp/device3')
-rw-r--r--host/lib/usrp/device3/device3_impl.cpp1
-rw-r--r--host/lib/usrp/device3/device3_impl.hpp16
-rw-r--r--host/lib/usrp/device3/device3_io_impl.cpp106
3 files changed, 74 insertions, 49 deletions
diff --git a/host/lib/usrp/device3/device3_impl.cpp b/host/lib/usrp/device3/device3_impl.cpp
index 7fcbc01b2..50598a519 100644
--- a/host/lib/usrp/device3/device3_impl.cpp
+++ b/host/lib/usrp/device3/device3_impl.cpp
@@ -17,6 +17,7 @@
#include "device3_impl.hpp"
#include "graph_impl.hpp"
+#include "ctrl_iface.hpp"
#include <uhd/utils/msg.hpp>
#include <uhd/rfnoc/block_ctrl_base.hpp>
#include <boost/make_shared.hpp>
diff --git a/host/lib/usrp/device3/device3_impl.hpp b/host/lib/usrp/device3/device3_impl.hpp
index 0d94ae21c..117e4af1c 100644
--- a/host/lib/usrp/device3/device3_impl.hpp
+++ b/host/lib/usrp/device3/device3_impl.hpp
@@ -32,18 +32,6 @@
#include <uhd/utils/tasks.hpp>
#include <uhd/device3.hpp>
#include "xports.hpp"
-// Common FPGA cores:
-#include "ctrl_iface.hpp"
-#include "rx_dsp_core_3000.hpp"
-#include "tx_dsp_core_3000.hpp"
-#include "rx_vita_core_3000.hpp"
-#include "tx_vita_core_3000.hpp"
-#include "rx_frontend_core_200.hpp"
-#include "tx_frontend_core_200.hpp"
-#include "time_core_3000.hpp"
-#include "gpio_atr_3000.hpp"
-// RFNoC-specific includes:
-#include "radio_ctrl_impl.hpp"
namespace uhd { namespace usrp {
@@ -54,8 +42,8 @@ static const size_t DEVICE3_RX_FC_REQUEST_FREQ = 32; //per flow-contr
static const size_t DEVICE3_TX_FC_RESPONSE_FREQ = 8;
static const size_t DEVICE3_TX_FC_RESPONSE_CYCLES = 0; // Cycles: Off.
-static const size_t DEVICE3_TX_MAX_HDR_LEN = uhd::transport::vrt::chdr::max_if_hdr_words64 * sizeof(boost::uint64_t); // Bytes
-static const size_t DEVICE3_RX_MAX_HDR_LEN = uhd::transport::vrt::chdr::max_if_hdr_words64 * sizeof(boost::uint64_t); // Bytes
+static const size_t DEVICE3_TX_MAX_HDR_LEN = uhd::transport::vrt::chdr::max_if_hdr_words64 * sizeof(uint64_t); // Bytes
+static const size_t DEVICE3_RX_MAX_HDR_LEN = uhd::transport::vrt::chdr::max_if_hdr_words64 * sizeof(uint64_t); // Bytes
class device3_impl : public uhd::device3, public boost::enable_shared_from_this<device3_impl>
{
diff --git a/host/lib/usrp/device3/device3_io_impl.cpp b/host/lib/usrp/device3/device3_io_impl.cpp
index af8ce772f..4ec14c43b 100644
--- a/host/lib/usrp/device3/device3_io_impl.cpp
+++ b/host/lib/usrp/device3/device3_io_impl.cpp
@@ -39,7 +39,7 @@ using namespace uhd::usrp;
using namespace uhd::transport;
//! CVITA uses 12-Bit sequence numbers
-static const boost::uint32_t HW_SEQ_NUM_MASK = 0xfff;
+static const uint32_t HW_SEQ_NUM_MASK = 0xfff;
/***********************************************************************
@@ -103,34 +103,47 @@ void generate_channel_list(
std::vector<device_addr_t> &chan_args
) {
uhd::stream_args_t args = args_;
- BOOST_FOREACH(const size_t chan_idx, args.channels) {
- //// Find block ID for this channel:
- if (args.args.has_key(str(boost::format("block_id%d") % chan_idx))) {
- chan_list.push_back(
- uhd::rfnoc::block_id_t(
- args.args.pop(str(boost::format("block_id%d") % chan_idx))
- )
- );
- chan_args.push_back(args.args);
+ std::vector<uhd::rfnoc::block_id_t> chan_list_(args.channels.size());
+ std::vector<device_addr_t> chan_args_(args.channels.size());
+
+ for (size_t i = 0; i < args.channels.size(); i++)
+ {
+ // Extract block ID
+ size_t chan_idx = args.channels[i];
+ std::string key = str(boost::format("block_id%d") % chan_idx);
+ if (args.args.has_key(key)) {
+ chan_list_[i] = args.args.pop(key);
} else if (args.args.has_key("block_id")) {
- chan_list.push_back(args.args.get("block_id"));
- chan_args.push_back(args.args);
- chan_args.back().pop("block_id");
+ chan_list[i] = args.args["block_id"];
} else {
throw uhd::runtime_error(str(
boost::format("Cannot create streamers: No block_id specified for channel %d.")
% chan_idx
));
}
- //// Find block port for this channel
- if (args.args.has_key(str(boost::format("block_port%d") % chan_idx))) {
- chan_args.back()["block_port"] = args.args.pop(str(boost::format("block_port%d") % chan_idx));
- } else if (args.args.has_key("block_port")) {
- // We have to write it again, because the chan args from the
- // property tree might have overwritten this
- chan_args.back()["block_port"] = args.args.get("block_port");
+
+ // Split off known channel specific args
+ key = str(boost::format("block_port%d") % chan_idx);
+ if (args.args.has_key(key)) {
+ chan_args_[i]["block_port"] = args.args.pop(key);
}
+ key = str(boost::format("radio_id%d") % chan_idx);
+ if (args.args.has_key(key)) {
+ chan_args_[i]["radio_id"] = args.args.pop(key);
+ }
+ key = str(boost::format("radio_port%d") % chan_idx);
+ if (args.args.has_key(key)) {
+ chan_args_[i]["radio_port"] = args.args.pop(key);
+ }
+ }
+
+ // Add all remaining args to all channel args
+ BOOST_FOREACH(device_addr_t &chan_arg, chan_args_) {
+ chan_arg = chan_arg.to_string() + "," + args.args.to_string();
}
+
+ chan_list = chan_list_;
+ chan_args = chan_args_;
}
@@ -223,7 +236,7 @@ static void handle_rx_flowctrl(
if (not buff) {
throw uhd::runtime_error("handle_rx_flowctrl timed out getting a send buffer");
}
- boost::uint32_t *pkt = buff->cast<boost::uint32_t *>();
+ uint32_t *pkt = buff->cast<uint32_t *>();
// Recover sequence number. The sequence numbers handled by the streamers
// are 12 Bits, but we want to know the 32-Bit sequence number.
@@ -242,7 +255,7 @@ static void handle_rx_flowctrl(
vrt::if_packet_info_t packet_info;
packet_info.packet_type = vrt::if_packet_info_t::PACKET_TYPE_FC;
packet_info.num_payload_words32 = RXFC_PACKET_LEN_IN_WORDS;
- packet_info.num_payload_bytes = packet_info.num_payload_words32*sizeof(boost::uint32_t);
+ packet_info.num_payload_bytes = packet_info.num_payload_words32*sizeof(uint32_t);
packet_info.packet_count = seq32;
packet_info.sob = false;
packet_info.eob = false;
@@ -257,14 +270,14 @@ static void handle_rx_flowctrl(
// Load Header:
vrt::chdr::if_hdr_pack_be(pkt, packet_info);
// Load Payload: (the sequence number)
- pkt[packet_info.num_header_words32+RXFC_CMD_CODE_OFFSET] = uhd::htonx<boost::uint32_t>(0);
- pkt[packet_info.num_header_words32+RXFC_SEQ_NUM_OFFSET] = uhd::htonx<boost::uint32_t>(seq32);
+ pkt[packet_info.num_header_words32+RXFC_CMD_CODE_OFFSET] = uhd::htonx<uint32_t>(0);
+ pkt[packet_info.num_header_words32+RXFC_SEQ_NUM_OFFSET] = uhd::htonx<uint32_t>(seq32);
} else {
// Load Header:
vrt::chdr::if_hdr_pack_le(pkt, packet_info);
// Load Payload: (the sequence number)
- pkt[packet_info.num_header_words32+RXFC_CMD_CODE_OFFSET] = uhd::htowx<boost::uint32_t>(0);
- pkt[packet_info.num_header_words32+RXFC_SEQ_NUM_OFFSET] = uhd::htowx<boost::uint32_t>(seq32);
+ pkt[packet_info.num_header_words32+RXFC_CMD_CODE_OFFSET] = uhd::htowx<uint32_t>(0);
+ pkt[packet_info.num_header_words32+RXFC_SEQ_NUM_OFFSET] = uhd::htowx<uint32_t>(seq32);
}
//std::cout << " SID=" << std::hex << sid << " hdr bits=" << packet_info.packet_type << " seq32=" << seq32 << std::endl;
@@ -277,7 +290,7 @@ static void handle_rx_flowctrl(
//}
//send the buffer over the interface
- buff->commit(sizeof(boost::uint32_t)*(packet_info.num_packet_words32));
+ buff->commit(sizeof(uint32_t)*(packet_info.num_packet_words32));
}
/***********************************************************************
@@ -371,11 +384,11 @@ static void handle_tx_async_msgs(
//extract packet info
vrt::if_packet_info_t if_packet_info;
- if_packet_info.num_packet_words32 = buff->size()/sizeof(boost::uint32_t);
- const boost::uint32_t *packet_buff = buff->cast<const boost::uint32_t *>();
+ if_packet_info.num_packet_words32 = buff->size()/sizeof(uint32_t);
+ const uint32_t *packet_buff = buff->cast<const uint32_t *>();
//unpacking can fail
- boost::uint32_t (*endian_conv)(boost::uint32_t) = uhd::ntohx;
+ uint32_t (*endian_conv)(uint32_t) = uhd::ntohx;
try
{
if (endianness == ENDIANNESS_BIG)
@@ -803,11 +816,34 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t &args_)
blk_ctrl->sr_write(uhd::rfnoc::SR_RESP_IN_DST_SID, xport.recv_sid.get_dst(), block_port);
UHD_STREAMER_LOG() << "[TX Streamer] resp_in_dst_sid == " << boost::format("0x%04X") % xport.recv_sid.get_dst() << std::endl;
- // Find all downstream radio nodes and set their response in SID to the host
- std::vector<boost::shared_ptr<uhd::rfnoc::radio_ctrl> > downstream_radio_nodes = blk_ctrl->find_downstream_node<uhd::rfnoc::radio_ctrl>();
- UHD_STREAMER_LOG() << "[TX Streamer] Number of downstream radio nodes: " << downstream_radio_nodes.size() << std::endl;
- BOOST_FOREACH(const boost::shared_ptr<uhd::rfnoc::radio_ctrl> &node, downstream_radio_nodes) {
- node->sr_write(uhd::rfnoc::SR_RESP_IN_DST_SID, xport.send_sid.get_src(), block_port);
+
+ // FIXME: Once there is a better way to map the radio block and port
+ // to the channel or another way to receive asynchronous messages that
+ // is not in-band, this should be removed.
+ if (args.args.has_key("radio_id") and args.args.has_key("radio_port"))
+ {
+ // Find downstream radio node and set the response SID to the host
+ uhd::rfnoc::block_id_t radio_id(args.args["radio_id"]);
+ size_t radio_port = args.args.cast<size_t>("radio_port", 0);
+ std::vector<boost::shared_ptr<uhd::rfnoc::radio_ctrl> > downstream_radio_nodes = blk_ctrl->find_downstream_node<uhd::rfnoc::radio_ctrl>();
+ UHD_STREAMER_LOG() << "[TX Streamer] Number of downstream radio nodes: " << downstream_radio_nodes.size() << std::endl;
+ BOOST_FOREACH(const boost::shared_ptr<uhd::rfnoc::radio_ctrl> &node, downstream_radio_nodes) {
+ if (node->get_block_id() == radio_id) {
+ node->sr_write(uhd::rfnoc::SR_RESP_IN_DST_SID, xport.send_sid.get_src(), radio_port);
+ }
+ }
+ } else {
+ // FIXME: This block is preserved for legacy behavior where the
+ // radio_id and radio_port are not provided. It fails if more
+ // than one radio is visible downstream or the port on the radio
+ // is not the same as the block_port. It should be removed as
+ // soon as possible.
+ // Find all downstream radio nodes and set their response SID to the host
+ std::vector<boost::shared_ptr<uhd::rfnoc::radio_ctrl> > downstream_radio_nodes = blk_ctrl->find_downstream_node<uhd::rfnoc::radio_ctrl>();
+ UHD_STREAMER_LOG() << "[TX Streamer] Number of downstream radio nodes: " << downstream_radio_nodes.size() << std::endl;
+ BOOST_FOREACH(const boost::shared_ptr<uhd::rfnoc::radio_ctrl> &node, downstream_radio_nodes) {
+ node->sr_write(uhd::rfnoc::SR_RESP_IN_DST_SID, xport.send_sid.get_src(), block_port);
+ }
}
//Give the streamer a functor to get the send buffer