aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-02-20 19:57:04 -0800
committerJosh Blum <josh@joshknows.com>2011-02-20 19:57:04 -0800
commit607f5df7013810e94bbe049e457858ec68f8dd0e (patch)
tree1b607ce8fae00dee527c22e18fb7b15fdb38b79b /host/lib/usrp
parente558283f9ff2550d164d868c8e66a5561c781474 (diff)
downloaduhd-607f5df7013810e94bbe049e457858ec68f8dd0e.tar.gz
uhd-607f5df7013810e94bbe049e457858ec68f8dd0e.tar.bz2
uhd-607f5df7013810e94bbe049e457858ec68f8dd0e.zip
usrp2: code working again in a completed form but did not test dual dsp
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/usrp2/fw_common.h2
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp67
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp24
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp7
4 files changed, 53 insertions, 47 deletions
diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h
index 33c0b728a..6eb047454 100644
--- a/host/lib/usrp/usrp2/fw_common.h
+++ b/host/lib/usrp/usrp2/fw_common.h
@@ -30,7 +30,7 @@ extern "C" {
#endif
//fpga and firmware compatibility numbers
-#define USRP2_FPGA_COMPAT_NUM 4
+#define USRP2_FPGA_COMPAT_NUM 5
#define USRP2_FW_COMPAT_NUM 9
//used to differentiate control packets over data port
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 179c2401d..e931778fa 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -120,18 +120,17 @@ private:
**********************************************************************/
struct usrp2_impl::io_impl{
- io_impl(size_t num_mboards, size_t send_frame_size):
- //the assumption is that all data transports should be identical
+ io_impl(std::vector<zero_copy_if::sptr> &dsp_xports):
+ dsp_xports(dsp_xports), //the assumption is that all data transports should be identical
get_recv_buffs_fcn(boost::bind(&usrp2_impl::io_impl::get_recv_buffs, this, _1)),
get_send_buffs_fcn(boost::bind(&usrp2_impl::io_impl::get_send_buffs, this, _1)),
- packet_handler_recv_state(num_mboards*usrp2_mboard_impl::NUM_RX_DSPS), //max chans
- packet_handler_send_state(num_mboards*usrp2_mboard_impl::NUM_RX_DSPS), //max chans
async_msg_fifo(100/*messages deep*/)
{
- for (size_t i = 0; i < num_mboards; i++){ //only one monitor per mboard (only 1 tx dsp so far)
- fc_mons.push_back(flow_control_monitor::sptr( //OMG TODO this will not be mapped right when a tx is disabled
- new flow_control_monitor(usrp2_impl::sram_bytes/send_frame_size)
- ));
+ size_t num_monitors = dsp_xports.size()/usrp2_mboard_impl::MAX_NUM_DSPS*usrp2_mboard_impl::NUM_TX_DSPS;
+ for (size_t i = 0; i < num_monitors; i++){
+ fc_mons.push_back(flow_control_monitor::sptr(new flow_control_monitor(
+ usrp2_impl::sram_bytes/dsp_xports.front()->get_send_frame_size()
+ )));
//init empty packet infos
vrt::if_packet_info_t packet_info;
packet_info.packet_count = 0xf;
@@ -150,15 +149,15 @@ struct usrp2_impl::io_impl{
}
bool get_send_buffs(vrt_packet_handler::managed_send_buffs_t &buffs){
- UHD_ASSERT_THROW(send_xports.size() == buffs.size());
+ UHD_ASSERT_THROW(send_map.size() == buffs.size());
//calculate the flow control word
const boost::uint32_t fc_word32 = packet_handler_send_state.next_packet_seq;
//grab a managed buffer for each index
for (size_t i = 0; i < buffs.size(); i++){
- if (not fc_mons[i]->check_fc_condition(fc_word32, send_timeout)) return false;
- buffs[i] = send_xports[i]->get_send_buff(send_timeout);
+ if (not fc_mons[send_map[i]]->check_fc_condition(fc_word32, send_timeout)) return false;
+ buffs[i] = dsp_xports[send_map[i]]->get_send_buff(send_timeout);
if (not buffs[i].get()) return false;
buffs[i]->cast<boost::uint32_t *>()[0] = uhd::htonx(fc_word32);
}
@@ -167,8 +166,10 @@ struct usrp2_impl::io_impl{
bool get_recv_buffs(vrt_packet_handler::managed_recv_buffs_t &buffs);
- //vector of send and recv xports to be mapped to channels
- std::vector<zero_copy_if::sptr> recv_xports, send_xports;
+ std::vector<zero_copy_if::sptr> &dsp_xports;
+
+ //mappings from channel index to dsp xport
+ std::vector<size_t> send_map, recv_map;
//timeouts set on calls to recv/send (passed into get buffs methods)
double recv_timeout, send_timeout;
@@ -188,7 +189,7 @@ struct usrp2_impl::io_impl{
vrt_packet_handler::send_state packet_handler_send_state;
//methods and variables for the pirate crew
- void recv_pirate_loop(usrp2_mboard_impl::sptr, size_t);
+ void recv_pirate_loop(usrp2_mboard_impl::sptr, zero_copy_if::sptr, size_t);
boost::thread_group recv_pirate_crew;
bool recv_pirate_crew_raiding;
bounded_buffer<async_metadata_t> async_msg_fifo;
@@ -202,7 +203,7 @@ struct usrp2_impl::io_impl{
* - put async message packets into queue
**********************************************************************/
void usrp2_impl::io_impl::recv_pirate_loop(
- usrp2_mboard_impl::sptr mboard, size_t index
+ usrp2_mboard_impl::sptr mboard, zero_copy_if::sptr err_xport, size_t index
){
set_thread_priority_safe();
recv_pirate_crew_raiding = true;
@@ -210,7 +211,7 @@ void usrp2_impl::io_impl::recv_pirate_loop(
spawn_mutex.unlock();
while(recv_pirate_crew_raiding){
- managed_recv_buffer::sptr buff = mboard->err_xports[0]->get_recv_buff();
+ managed_recv_buffer::sptr buff = err_xport->get_recv_buff();
if (not buff.get()) continue; //ignore timeout/error buffers
try{
@@ -259,7 +260,7 @@ void usrp2_impl::io_impl::recv_pirate_loop(
void usrp2_impl::io_init(void){
//create new io impl
- _io_impl = UHD_PIMPL_MAKE(io_impl, (_mboards.size(), this->send_frame_size));
+ _io_impl = UHD_PIMPL_MAKE(io_impl, (dsp_xports));
//create a new pirate thread for each zc if (yarr!!)
for (size_t i = 0; i < _mboards.size(); i++){
@@ -268,7 +269,7 @@ void usrp2_impl::io_init(void){
//spawn a new pirate to plunder the recv booty
_io_impl->recv_pirate_crew.create_thread(boost::bind(
&usrp2_impl::io_impl::recv_pirate_loop,
- _io_impl.get(), _mboards.at(i), i
+ _io_impl.get(), _mboards.at(i), err_xports.at(i), i
));
//block here until the spawned thread unlocks
_io_impl->spawn_mutex.lock();
@@ -283,21 +284,27 @@ void usrp2_impl::io_init(void){
void usrp2_impl::update_xport_channel_mapping(void){
if (_io_impl.get() == NULL) return; //not inited yet
- _io_impl->recv_xports.clear();
- _io_impl->send_xports.clear();
- BOOST_FOREACH(usrp2_mboard_impl::sptr mboard, _mboards){
+ _io_impl->recv_map.clear();
+ _io_impl->send_map.clear();
+
+ for (size_t i = 0; i < _mboards.size(); i++){
- subdev_spec_t rx_subdev_spec = mboard->get_link()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>();
+ subdev_spec_t rx_subdev_spec = _mboards[i]->get_link()[MBOARD_PROP_RX_SUBDEV_SPEC].as<subdev_spec_t>();
for (size_t j = 0; j < rx_subdev_spec.size(); j++){
- _io_impl->recv_xports.push_back(mboard->dsp_xports.at(j));
+ _io_impl->recv_map.push_back(i*usrp2_mboard_impl::MAX_NUM_DSPS+j);
+ //std::cout << "recv_map.back() " << _io_impl->recv_map.back() << std::endl;
}
- subdev_spec_t tx_subdev_spec = mboard->get_link()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>();
+ subdev_spec_t tx_subdev_spec = _mboards[i]->get_link()[MBOARD_PROP_TX_SUBDEV_SPEC].as<subdev_spec_t>();
for (size_t j = 0; j < tx_subdev_spec.size(); j++){
- _io_impl->send_xports.push_back(mboard->dsp_xports.at(j));
+ _io_impl->send_map.push_back(i*usrp2_mboard_impl::MAX_NUM_DSPS+j);
+ //std::cout << "send_map.back() " << _io_impl->send_map.back() << std::endl;
}
}
+
+ _io_impl->packet_handler_recv_state = vrt_packet_handler::recv_state(_io_impl->recv_map.size());
+ _io_impl->packet_handler_send_state = vrt_packet_handler::send_state(_io_impl->send_map.size());
}
/***********************************************************************
@@ -319,7 +326,7 @@ size_t usrp2_impl::get_max_send_samps_per_packet(void) const{
+ vrt_send_header_offset_words32*sizeof(boost::uint32_t)
- sizeof(vrt::if_packet_info_t().cid) //no class id ever used
;
- const size_t bpp = this->send_frame_size - hdr_size;
+ const size_t bpp = dsp_xports.front()->get_send_frame_size() - hdr_size;
return bpp/_tx_otw_type.get_sample_size();
}
@@ -402,7 +409,7 @@ UHD_INLINE bool usrp2_impl::io_impl::get_recv_buffs(
vrt_packet_handler::managed_recv_buffs_t &buffs
){
if (buffs.size() == 1){
- buffs[0] = recv_xports[0]->get_recv_buff(recv_timeout);
+ buffs[0] = dsp_xports[recv_map[0]]->get_recv_buff(recv_timeout);
if (buffs[0].get() == NULL) return false;
bool clear, msg; time_spec_t time; //unused variables
//call extract_packet_info to handle printing the overflows
@@ -423,7 +430,7 @@ UHD_INLINE bool usrp2_impl::io_impl::get_recv_buffs(
//do an initial pop to load an initial sequence id
size_t index = indexes_to_do.front();
- buff_tmp = recv_xports[index]->get_recv_buff(from_time_dur(exit_time - boost::get_system_time()));
+ buff_tmp = dsp_xports[recv_map[index]]->get_recv_buff(from_time_dur(exit_time - boost::get_system_time()));
if (buff_tmp.get() == NULL) return false;
extract_packet_info(buff_tmp, this->prev_infos[index], expected_time, clear, msg);
if (clear) goto got_clear;
@@ -436,7 +443,7 @@ UHD_INLINE bool usrp2_impl::io_impl::get_recv_buffs(
//pop an element off for this index
index = indexes_to_do.front();
- buff_tmp = recv_xports[index]->get_recv_buff(from_time_dur(exit_time - boost::get_system_time()));
+ buff_tmp = dsp_xports[recv_map[index]]->get_recv_buff(from_time_dur(exit_time - boost::get_system_time()));
if (buff_tmp.get() == NULL) return false;
time_spec_t this_time;
extract_packet_info(buff_tmp, this->prev_infos[index], this_time, clear, msg);
@@ -477,7 +484,7 @@ size_t usrp2_impl::get_max_recv_samps_per_packet(void) const{
+ sizeof(vrt::if_packet_info_t().tlr) //forced to have trailer
- sizeof(vrt::if_packet_info_t().cid) //no class id ever used
;
- const size_t bpp = this->recv_frame_size - hdr_size;
+ const size_t bpp = dsp_xports.front()->get_recv_frame_size() - hdr_size;
return bpp/_rx_otw_type.get_sample_size();
}
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 8db295042..e8e3ecd31 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -78,26 +78,22 @@ usrp2_mboard_impl::usrp2_mboard_impl(
//construct transports for dsp and async errors
std::cout << "Making transport for DSP0..." << std::endl;
- dsp_xports.push_back(udp_zero_copy::make(
+ device.dsp_xports.push_back(udp_zero_copy::make(
device_addr["addr"], boost::lexical_cast<std::string>(USRP2_UDP_DSP0_PORT), dsp_xport_hints
));
- init_xport(dsp_xports.back());
+ init_xport(device.dsp_xports.back());
std::cout << "Making transport for DSP1..." << std::endl;
- dsp_xports.push_back(udp_zero_copy::make(
+ device.dsp_xports.push_back(udp_zero_copy::make(
device_addr["addr"], boost::lexical_cast<std::string>(USRP2_UDP_DSP1_PORT), dsp_xport_hints
));
- init_xport(dsp_xports.back());
+ init_xport(device.dsp_xports.back());
std::cout << "Making transport for ERR0..." << std::endl;
- err_xports.push_back(udp_zero_copy::make(
+ device.err_xports.push_back(udp_zero_copy::make(
device_addr["addr"], boost::lexical_cast<std::string>(USRP2_UDP_ERR0_PORT), device_addr_t()
));
- init_xport(err_xports.back());
-
- //set the frame sizes (assume homogeneous)
- device.recv_frame_size = dsp_xports.front()->get_recv_frame_size();
- device.send_frame_size = dsp_xports.front()->get_send_frame_size();
+ init_xport(device.err_xports.back());
//contruct the interfaces to mboard perifs
_clock_ctrl = usrp2_clock_ctrl::make(_iface);
@@ -119,9 +115,10 @@ usrp2_mboard_impl::usrp2_mboard_impl(
}
//setting the packets per update (enabled by default)
+ size_t send_frame_size = device.dsp_xports[0]->get_send_frame_size();
const double ups_per_fifo = device_args.cast<double>("ups_per_fifo", 8.0);
if (ups_per_fifo > 0.0){
- const size_t packets_per_up = size_t(usrp2_impl::sram_bytes/ups_per_fifo/dsp_xports[0]->get_send_frame_size());
+ const size_t packets_per_up = size_t(usrp2_impl::sram_bytes/ups_per_fifo/send_frame_size);
_iface->poke32(_iface->regs.tx_ctrl_packets_per_up, U2_FLAG_TX_CTRL_UP_ENB | packets_per_up);
}
@@ -160,10 +157,11 @@ usrp2_mboard_impl::usrp2_mboard_impl(
//This is a hack/fix for the lingering packet problem.
stream_cmd_t stream_cmd(stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
for (size_t i = 0; i < NUM_RX_DSPS; i++){
+ size_t index = device.dsp_xports.size() - NUM_RX_DSPS + i;
stream_cmd.num_samps = 1;
this->issue_ddc_stream_cmd(stream_cmd, i);
- dsp_xports[i]->get_recv_buff().get(); //recv with timeout for lingering
- dsp_xports[i]->get_recv_buff().get(); //recv with timeout for expected
+ device.dsp_xports.at(index)->get_recv_buff(0.01).get(); //recv with timeout for lingering
+ device.dsp_xports.at(index)->get_recv_buff(0.01).get(); //recv with timeout for expected
_iface->poke32(_iface->regs.rx_ctrl[i].clear_overrun, 1); //resets sequence
}
}
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 4f68b630e..df55e6a99 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -84,6 +84,7 @@ public:
static const size_t NUM_RX_DSPS = 2;
static const size_t NUM_TX_DSPS = 1;
+ static const size_t MAX_NUM_DSPS = 2;
//structors
usrp2_mboard_impl(
@@ -99,9 +100,6 @@ public:
void handle_overflow(size_t);
- std::vector<uhd::transport::zero_copy_if::sptr> dsp_xports;
- std::vector<uhd::transport::zero_copy_if::sptr> err_xports;
-
private:
size_t _index;
usrp2_impl &_device;
@@ -204,6 +202,9 @@ public:
//public frame sizes, set by mboard, used by io impl
size_t recv_frame_size, send_frame_size;
+ std::vector<uhd::transport::zero_copy_if::sptr> dsp_xports;
+ std::vector<uhd::transport::zero_copy_if::sptr> err_xports;
+
private:
//device properties interface
void get(const wax::obj &, wax::obj &);