diff options
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/device3/device3_impl.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/device3/device3_impl.hpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/device3/device3_io_impl.cpp | 8 | ||||
-rw-r--r-- | host/lib/usrp/mboard_eeprom.cpp | 2 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_impl.cpp | 75 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_impl.hpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/x300/x300_radio_ctrl_impl.cpp | 8 |
7 files changed, 76 insertions, 32 deletions
diff --git a/host/lib/usrp/device3/device3_impl.cpp b/host/lib/usrp/device3/device3_impl.cpp index 50598a519..28b7bc34b 100644 --- a/host/lib/usrp/device3/device3_impl.cpp +++ b/host/lib/usrp/device3/device3_impl.cpp @@ -105,8 +105,7 @@ void device3_impl::enumerate_rfnoc_blocks( size_t n_blocks, size_t base_port, const uhd::sid_t &base_sid, - uhd::device_addr_t transport_args, - uhd::endianness_t endianness + uhd::device_addr_t transport_args ) { // entries that are already connected to this block uhd::sid_t ctrl_sid = base_sid; @@ -131,7 +130,7 @@ void device3_impl::enumerate_rfnoc_blocks( ); UHD_DEVICE3_LOG() << str(boost::format("Setting up NoC-Shell Control for port #0 (SID: %s)...") % xport.send_sid.to_pp_string_hex()); uhd::rfnoc::ctrl_iface::sptr ctrl = uhd::rfnoc::ctrl_iface::make( - endianness == ENDIANNESS_BIG, + xport.endianness == uhd::ENDIANNESS_BIG, xport.send, xport.recv, xport.send_sid, @@ -160,7 +159,7 @@ void device3_impl::enumerate_rfnoc_blocks( ); UHD_DEVICE3_LOG() << str(boost::format("Setting up NoC-Shell Control for port #%d (SID: %s)...") % port_number % xport1.send_sid.to_pp_string_hex()); uhd::rfnoc::ctrl_iface::sptr ctrl1 = uhd::rfnoc::ctrl_iface::make( - endianness == ENDIANNESS_BIG, + xport1.endianness == uhd::ENDIANNESS_BIG, xport1.send, xport1.recv, xport1.send_sid, @@ -173,7 +172,6 @@ void device3_impl::enumerate_rfnoc_blocks( make_args.base_address = xport.send_sid.get_dst(); make_args.device_index = device_index; make_args.tree = subtree; - make_args.is_big_endian = (endianness == ENDIANNESS_BIG); _rfnoc_block_ctrl.push_back(uhd::rfnoc::block_ctrl_base::make(make_args, noc_id)); } } diff --git a/host/lib/usrp/device3/device3_impl.hpp b/host/lib/usrp/device3/device3_impl.hpp index 117e4af1c..c496b5105 100644 --- a/host/lib/usrp/device3/device3_impl.hpp +++ b/host/lib/usrp/device3/device3_impl.hpp @@ -134,7 +134,6 @@ protected: virtual uhd::device_addr_t get_tx_hints(size_t) { return uhd::device_addr_t(); }; virtual uhd::device_addr_t get_rx_hints(size_t) { return uhd::device_addr_t(); }; - virtual uhd::endianness_t get_transport_endianness(size_t mb_index) = 0; //! Is called after a streamer is generated virtual void post_streamer_hooks(uhd::direction_t) {}; @@ -167,8 +166,7 @@ protected: size_t n_blocks, size_t base_port, const uhd::sid_t &base_sid, - uhd::device_addr_t transport_args, - uhd::endianness_t endianness + uhd::device_addr_t transport_args ); /*********************************************************************** diff --git a/host/lib/usrp/device3/device3_io_impl.cpp b/host/lib/usrp/device3/device3_io_impl.cpp index c1bfd1606..2f2e778c9 100644 --- a/host/lib/usrp/device3/device3_io_impl.cpp +++ b/host/lib/usrp/device3/device3_io_impl.cpp @@ -565,7 +565,7 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t &args_) //init some streamer stuff std::string conv_endianness; - if (get_transport_endianness(mb_index) == ENDIANNESS_BIG) { + if (xport.endianness == ENDIANNESS_BIG) { my_streamer->set_vrt_unpacker(&vrt::chdr::if_hdr_unpack_be); conv_endianness = "be"; } else { @@ -618,7 +618,7 @@ rx_streamer::sptr device3_impl::get_rx_stream(const stream_args_t &args_) &handle_rx_flowctrl, xport.send_sid, xport.send, - get_transport_endianness(mb_index), + xport.endianness, fc_cache, _1 ), @@ -755,7 +755,7 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t &args_) //init some streamer stuff std::string conv_endianness; - if (get_transport_endianness(mb_index) == ENDIANNESS_BIG) { + if (xport.endianness == ENDIANNESS_BIG) { my_streamer->set_vrt_packer(&vrt::chdr::if_hdr_pack_be); conv_endianness = "be"; } else { @@ -803,7 +803,7 @@ tx_streamer::sptr device3_impl::get_tx_stream(const uhd::stream_args_t &args_) &handle_tx_async_msgs, fc_cache, xport.recv, - get_transport_endianness(mb_index), + xport.endianness, tick_rate_retriever ) ); diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp index 4cf58cd05..0e6cb8574 100644 --- a/host/lib/usrp/mboard_eeprom.cpp +++ b/host/lib/usrp/mboard_eeprom.cpp @@ -600,7 +600,7 @@ template <typename T> static const byte_vector_t to_bytes(const T &item){ } #define sizeof_member(struct_name, member_name) \ - sizeof(reinterpret_cast<struct_name*>(NULL)->member_name) + sizeof(reinterpret_cast<struct_name*>(0)->member_name) static void load_e100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){ const size_t num_bytes = offsetof(e100_eeprom_map, model); diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 374247fea..edf254130 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -381,7 +381,33 @@ static void x300_load_fw(wb_iface::sptr fw_reg_ctrl, const std::string &file_nam UHD_MSG(status) << " done!" << std::endl; } -x300_impl::x300_impl(const uhd::device_addr_t &dev_addr) +static const std::string thread_final_msg = "Finished multi-threaded initialization\n"; + +static void thread_msg_handler(uhd::msg::type_t type, const std::string &msg) +{ + static boost::mutex msg_mutex; + boost::mutex::scoped_lock lock(msg_mutex); + + typedef std::pair<uhd::msg::type_t, std::string> msg_pair_t; + typedef std::map<boost::thread::id, std::vector<msg_pair_t> > thread_map_t; + + static thread_map_t thread_list; + thread_list[boost::this_thread::get_id()].push_back(msg_pair_t(type, msg)); + + if (msg == thread_final_msg) + { + BOOST_FOREACH(const thread_map_t::value_type &thread_pair, thread_list) + { + BOOST_FOREACH(const msg_pair_t &msg_pair, thread_pair.second) + { + // Forward the message to the default handler + uhd::msg::default_msg_handler(msg_pair.first, msg_pair.second); + } + } + } +} + +x300_impl::x300_impl(const uhd::device_addr_t &dev_addr) : device3_impl() , _sid_framer(0) { @@ -391,10 +417,33 @@ x300_impl::x300_impl(const uhd::device_addr_t &dev_addr) const device_addrs_t device_args = separate_device_addr(dev_addr); _mb.resize(device_args.size()); + + // Serialize the initialization process + if (dev_addr.has_key("serialize_init") or device_args.size() == 1) { + for (size_t i = 0; i < device_args.size(); i++) + { + this->setup_mb(i, device_args[i]); + } + return; + } + + // Setup a custom messenger handler + uhd::msg::handler_t current_handler = uhd::msg::get_handler(); + uhd::msg::register_handler(&thread_msg_handler); + + // Thread the initialization process + boost::thread_group setup_threads; for (size_t i = 0; i < device_args.size(); i++) { - this->setup_mb(i, device_args[i]); + setup_threads.create_thread( + boost::bind(&x300_impl::setup_mb, this, i, device_args[i]) + ); } + setup_threads.join_all(); + + // restore the original message handler + UHD_MSG(status) << thread_final_msg; + uhd::msg::register_handler(current_handler); } void x300_impl::mboard_members_t::discover_eth( @@ -505,6 +554,16 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) mboard_members_t &mb = _mb[mb_i]; mb.initialization_done = false; + const std::string thread_id( + boost::lexical_cast<std::string>(boost::this_thread::get_id()) + ); + const std::string thread_msg( + "Thread ID " + thread_id + " for motherboard " + + boost::lexical_cast<std::string>(mb_i) + ); + UHD_MSG(status) << std::endl; + UHD_MSG(status) << thread_msg << std::endl; + std::vector<std::string> eth_addrs; // Not choosing eth0 based on resource might cause user issues std::string eth0_addr = dev_addr.has_key("resource") ? dev_addr["resource"] : dev_addr["addr"]; @@ -886,14 +945,6 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) } //////////////////////////////////////////////////////////////////// - //clear router? - //////////////////////////////////////////////////////////////////// - for (size_t i = 0; i < 512; i++) { - mb.zpu_ctrl->poke32(SR_ADDR(SETXB_BASE, i), 0); - } - - - //////////////////////////////////////////////////////////////////// // setup time sources and properties //////////////////////////////////////////////////////////////////// _tree->create<std::string>(mb_path / "time_source" / "value") @@ -950,8 +1001,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) n_rfnoc_blocks, X300_XB_DST_PCI + 1, /* base port */ uhd::sid_t(X300_SRC_ADDR0, 0, X300_DST_ADDR + mb_i, 0), - dev_addr, - mb.if_pkt_is_big_endian ? ENDIANNESS_BIG : ENDIANNESS_LITTLE + dev_addr ); //////////////// RFNOC ///////////////// @@ -1072,6 +1122,7 @@ uhd::both_xports_t x300_impl::make_transport( zero_copy_xport_params default_buff_args; both_xports_t xports; + xports.endianness = mb.if_pkt_is_big_endian ? ENDIANNESS_BIG : ENDIANNESS_LITTLE; if (mb.xport_path == "nirio") { xports.send_sid = this->allocate_sid(mb, address, X300_SRC_ADDR0, X300_XB_DST_PCI); xports.recv_sid = xports.send_sid.reversed(); diff --git a/host/lib/usrp/x300/x300_impl.hpp b/host/lib/usrp/x300/x300_impl.hpp index 133938daf..d082ab76a 100644 --- a/host/lib/usrp/x300/x300_impl.hpp +++ b/host/lib/usrp/x300/x300_impl.hpp @@ -283,9 +283,6 @@ private: /// More IO stuff uhd::device_addr_t get_tx_hints(size_t mb_index); uhd::device_addr_t get_rx_hints(size_t mb_index); - uhd::endianness_t get_transport_endianness(size_t mb_index) { - return _mb[mb_index].if_pkt_is_big_endian ? uhd::ENDIANNESS_BIG : uhd::ENDIANNESS_LITTLE; - }; void post_streamer_hooks(uhd::direction_t dir); }; diff --git a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp index 0e11cb42c..9bf61f998 100644 --- a/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp +++ b/host/lib/usrp/x300/x300_radio_ctrl_impl.cpp @@ -813,8 +813,8 @@ void x300_radio_ctrl_impl::_self_cal_adc_capture_delay(bool print_status) //and count deviations from the expected value _regs->misc_outs_reg.write(radio_regmap_t::misc_outs_reg_t::ADC_CHECKER_ENABLED, 0); _regs->misc_outs_reg.write(radio_regmap_t::misc_outs_reg_t::ADC_CHECKER_ENABLED, 1); - //10ms @ 200MHz = 2 million samples - boost::this_thread::sleep(boost::posix_time::milliseconds(10)); + //5ms @ 200MHz = 1 million samples + boost::this_thread::sleep(boost::posix_time::milliseconds(5)); if (_regs->misc_ins_reg.read(radio_regmap_t::misc_ins_reg_t::ADC_CHECKER0_I_LOCKED)) { err_code += _regs->misc_ins_reg.get(radio_regmap_t::misc_ins_reg_t::ADC_CHECKER0_I_ERROR); } else { @@ -828,8 +828,8 @@ void x300_radio_ctrl_impl::_self_cal_adc_capture_delay(bool print_status) //and count deviations from the expected value _regs->misc_outs_reg.write(radio_regmap_t::misc_outs_reg_t::ADC_CHECKER_ENABLED, 0); _regs->misc_outs_reg.write(radio_regmap_t::misc_outs_reg_t::ADC_CHECKER_ENABLED, 1); - //10ms @ 200MHz = 2 million samples - boost::this_thread::sleep(boost::posix_time::milliseconds(10)); + //5ms @ 200MHz = 1 million samples + boost::this_thread::sleep(boost::posix_time::milliseconds(5)); if (_regs->misc_ins_reg.read(radio_regmap_t::misc_ins_reg_t::ADC_CHECKER0_Q_LOCKED)) { err_code += _regs->misc_ins_reg.get(radio_regmap_t::misc_ins_reg_t::ADC_CHECKER0_Q_ERROR); } else { |