summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp35
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp38
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp2
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp86
4 files changed, 88 insertions, 73 deletions
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 8b1864e2d..0c92c33b2 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -95,16 +95,6 @@ void usrp2_impl::io_impl::recv_pirate_loop(zero_copy_if::sptr zc_if, size_t inde
* Helper Functions
**********************************************************************/
void usrp2_impl::io_init(void){
- //setup rx otw type
- _rx_otw_type.width = 16;
- _rx_otw_type.shift = 0;
- _rx_otw_type.byteorder = otw_type_t::BO_BIG_ENDIAN;
-
- //setup tx otw type
- _tx_otw_type.width = 16;
- _tx_otw_type.shift = 0;
- _tx_otw_type.byteorder = otw_type_t::BO_BIG_ENDIAN;
-
//send a small data packet so the usrp2 knows the udp source port
for(size_t i = 0; i < _data_transports.size(); i++){
managed_send_buffer::sptr send_buff = _data_transports[i]->get_send_buff();
@@ -113,11 +103,6 @@ void usrp2_impl::io_init(void){
send_buff->commit(sizeof(data));
}
- //setup VRT RX DSP regs
- for(size_t i = 0; i < _mboards.size(); i++){
- _mboards[i]->setup_vrt_recv_regs(get_max_recv_samps_per_packet());
- }
-
std::cout << "RX samples per packet: " << get_max_recv_samps_per_packet() << std::endl;
std::cout << "TX samples per packet: " << get_max_send_samps_per_packet() << std::endl;
@@ -147,11 +132,11 @@ size_t usrp2_impl::send(
send_mode_t send_mode
){
return vrt_packet_handler::send(
- _io_impl->packet_handler_send_state, //last state of the send handler
- buffs, num_samps, //buffer to fill
- metadata, send_mode, //samples metadata
- io_type, _tx_otw_type, //input and output types to convert
- get_master_clock_freq(), //master clock tick rate
+ _io_impl->packet_handler_send_state, //last state of the send handler
+ buffs, num_samps, //buffer to fill
+ metadata, send_mode, //samples metadata
+ io_type, _io_helper.get_tx_otw_type(), //input and output types to convert
+ _mboards.front()->get_master_clock_freq(), //master clock tick rate
uhd::transport::vrt::if_hdr_pack_be,
boost::bind(&get_send_buffs, _data_transports, _1),
get_max_send_samps_per_packet()
@@ -169,11 +154,11 @@ size_t usrp2_impl::recv(
recv_mode_t recv_mode
){
return vrt_packet_handler::recv(
- _io_impl->packet_handler_recv_state, //last state of the recv handler
- buffs, num_samps, //buffer to fill
- metadata, recv_mode, //samples metadata
- io_type, _rx_otw_type, //input and output types to convert
- get_master_clock_freq(), //master clock tick rate
+ _io_impl->packet_handler_recv_state, //last state of the recv handler
+ buffs, num_samps, //buffer to fill
+ metadata, recv_mode, //samples metadata
+ io_type, _io_helper.get_rx_otw_type(), //input and output types to convert
+ _mboards.front()->get_master_clock_freq(), //master clock tick rate
uhd::transport::vrt::if_hdr_unpack_be,
boost::bind(&usrp2_impl::io_impl::get_recv_buffs, _io_impl, _1)
);
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index 903d5da86..28a346be7 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -33,9 +33,12 @@ using namespace uhd::usrp;
* Structors
**********************************************************************/
usrp2_mboard_impl::usrp2_mboard_impl(
- size_t index, transport::udp_simple::sptr ctrl_transport
+ size_t index,
+ transport::udp_simple::sptr ctrl_transport,
+ const usrp2_io_helper &io_helper
):
- _index(index)
+ _index(index),
+ _io_helper(io_helper)
{
//make a new interface for usrp2 stuff
_iface = usrp2_iface::make(ctrl_transport);
@@ -57,6 +60,19 @@ usrp2_mboard_impl::usrp2_mboard_impl(
_allowed_decim_and_interp_rates.push_back(i);
}
+ //setup the vrt rx registers
+ _iface->poke32(U2_REG_RX_CTRL_NSAMPS_PER_PKT, _io_helper.get_max_recv_samps_per_packet());
+ _iface->poke32(U2_REG_RX_CTRL_NCHANNELS, 1);
+ _iface->poke32(U2_REG_RX_CTRL_CLEAR_OVERRUN, 1); //reset
+ _iface->poke32(U2_REG_RX_CTRL_VRT_HEADER, 0
+ | (0x1 << 28) //if data with stream id
+ | (0x1 << 26) //has trailer
+ | (0x3 << 22) //integer time other
+ | (0x1 << 20) //fractional time sample count
+ );
+ _iface->poke32(U2_REG_RX_CTRL_VRT_STREAM_ID, 0);
+ _iface->poke32(U2_REG_RX_CTRL_VRT_TRAILER, 0);
+
//init the ddc
init_ddc_config();
@@ -77,22 +93,6 @@ usrp2_mboard_impl::~usrp2_mboard_impl(void){
/***********************************************************************
* Helper Methods
**********************************************************************/
-void usrp2_mboard_impl::setup_vrt_recv_regs(size_t num_samps){
- _max_recv_samps_per_packet = num_samps;
-
- _iface->poke32(U2_REG_RX_CTRL_NSAMPS_PER_PKT, _max_recv_samps_per_packet);
- _iface->poke32(U2_REG_RX_CTRL_NCHANNELS, 1);
- _iface->poke32(U2_REG_RX_CTRL_CLEAR_OVERRUN, 1); //reset
- _iface->poke32(U2_REG_RX_CTRL_VRT_HEADER, 0
- | (0x1 << 28) //if data with stream id
- | (0x1 << 26) //has trailer
- | (0x3 << 22) //integer time other
- | (0x1 << 20) //fractional time sample count
- );
- _iface->poke32(U2_REG_RX_CTRL_VRT_STREAM_ID, 0);
- _iface->poke32(U2_REG_RX_CTRL_VRT_TRAILER, 0);
-}
-
void usrp2_mboard_impl::init_clock_config(void){
//setup the clock configuration settings
_clock_config.ref_source = clock_config_t::REF_INT;
@@ -167,7 +167,7 @@ void usrp2_mboard_impl::issue_ddc_stream_cmd(const stream_cmd_t &stream_cmd){
//issue the stream command
_iface->poke32(U2_REG_RX_CTRL_STREAM_CMD, U2_REG_RX_CTRL_MAKE_CMD(
- (inst_samps)? stream_cmd.num_samps : ((inst_chain)? _max_recv_samps_per_packet : 1),
+ (inst_samps)? stream_cmd.num_samps : ((inst_chain)? _io_helper.get_max_recv_samps_per_packet() : 1),
(stream_cmd.stream_now)? 1 : 0,
(inst_chain)? 1 : 0,
(inst_reload)? 1 : 0
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index af496bf69..436146a48 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -173,7 +173,7 @@ usrp2_impl::usrp2_impl(
//create a new mboard handler for each control transport
for(size_t i = 0; i < ctrl_transports.size(); i++){
_mboards.push_back(usrp2_mboard_impl::sptr(
- new usrp2_mboard_impl(i, ctrl_transports[i])
+ new usrp2_mboard_impl(i, ctrl_transports[i], _io_helper)
));
//use an empty name when there is only one mboard
std::string name = (ctrl_transports.size() > 1)? boost::lexical_cast<std::string>(i) : "";
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index ccda5e3d8..719cf3f16 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -70,6 +70,55 @@ private:
};
/*!
+ * The io helper class encapculates the max packet sizes and otw types.
+ * The otw types are read-only for now, this will be reimplemented
+ * when it becomes possible to change the otw type in the usrp2.
+ */
+class usrp2_io_helper{
+public:
+ usrp2_io_helper(void){
+ //setup rx otw type
+ _rx_otw_type.width = 16;
+ _rx_otw_type.shift = 0;
+ _rx_otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN;
+
+ //setup tx otw type
+ _tx_otw_type.width = 16;
+ _tx_otw_type.shift = 0;
+ _tx_otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN;
+ }
+
+ inline size_t get_max_send_samps_per_packet(void) const{
+ return _max_tx_bytes_per_packet/_tx_otw_type.get_sample_size();
+ }
+
+ inline size_t get_max_recv_samps_per_packet(void) const{
+ return _max_rx_bytes_per_packet/_rx_otw_type.get_sample_size();
+ }
+
+ inline const uhd::otw_type_t &get_rx_otw_type(void) const{
+ return _rx_otw_type;
+ }
+
+ inline const uhd::otw_type_t &get_tx_otw_type(void) const{
+ return _tx_otw_type;
+ }
+
+private:
+ uhd::otw_type_t _rx_otw_type, _tx_otw_type;
+ static const size_t _max_rx_bytes_per_packet =
+ USRP2_UDP_BYTES -
+ USRP2_HOST_RX_VRT_HEADER_WORDS32*sizeof(boost::uint32_t) -
+ USRP2_HOST_RX_VRT_TRAILER_WORDS32*sizeof(boost::uint32_t)
+ ;
+ static const size_t _max_tx_bytes_per_packet =
+ USRP2_UDP_BYTES -
+ uhd::transport::vrt::max_if_hdr_words32*sizeof(boost::uint32_t) -
+ sizeof(uhd::transport::vrt::if_packet_info_t::cid) //no class id ever used
+ ;
+};
+
+/*!
* USRP2 mboard implementation guts:
* The implementation details are encapsulated here.
* Handles properties on the mboard, dboard, dsps...
@@ -79,23 +128,21 @@ public:
typedef boost::shared_ptr<usrp2_mboard_impl> sptr;
//structors
- usrp2_mboard_impl(size_t index, uhd::transport::udp_simple::sptr);
+ usrp2_mboard_impl(size_t index, uhd::transport::udp_simple::sptr, const usrp2_io_helper &);
~usrp2_mboard_impl(void);
- void setup_vrt_recv_regs(size_t num_samps);
-
inline double get_master_clock_freq(void){
return _clock_ctrl->get_master_clock_rate();
}
+private:
+ size_t _index;
+ const usrp2_io_helper &_io_helper;
+
//properties for this mboard
void get(const wax::obj &, wax::obj &);
void set(const wax::obj &, const wax::obj &);
-private:
- size_t _index;
- size_t _max_recv_samps_per_packet;
-
//interfaces
usrp2_iface::sptr _iface;
usrp2_clock_ctrl::sptr _clock_ctrl;
@@ -172,7 +219,7 @@ public:
//the io interface
size_t get_max_send_samps_per_packet(void) const{
- return _max_tx_bytes_per_packet/_tx_otw_type.get_sample_size();
+ return _io_helper.get_max_send_samps_per_packet();
}
size_t send(
const std::vector<const void *> &, size_t,
@@ -181,7 +228,7 @@ public:
uhd::device::send_mode_t
);
size_t get_max_recv_samps_per_packet(void) const{
- return _max_rx_bytes_per_packet/_rx_otw_type.get_sample_size();
+ return _io_helper.get_max_recv_samps_per_packet();
}
size_t recv(
const std::vector<void *> &, size_t,
@@ -191,10 +238,6 @@ public:
);
private:
- inline double get_master_clock_freq(void){
- return _mboards.front()->get_master_clock_freq();
- }
-
//device properties interface
void get(const wax::obj &, wax::obj &);
void set(const wax::obj &, const wax::obj &);
@@ -203,22 +246,9 @@ private:
std::vector<usrp2_mboard_impl::sptr> _mboards;
uhd::dict<std::string, usrp2_mboard_impl::sptr> _mboard_dict;
- /*******************************************************************
- * Deal with the rx and tx packet sizes
- ******************************************************************/
- static const size_t _max_rx_bytes_per_packet =
- USRP2_UDP_BYTES -
- USRP2_HOST_RX_VRT_HEADER_WORDS32*sizeof(boost::uint32_t) -
- USRP2_HOST_RX_VRT_TRAILER_WORDS32*sizeof(boost::uint32_t)
- ;
- static const size_t _max_tx_bytes_per_packet =
- USRP2_UDP_BYTES -
- uhd::transport::vrt::max_if_hdr_words32*sizeof(boost::uint32_t) -
- sizeof(uhd::transport::vrt::if_packet_info_t::cid) //no class id ever used
- ;
-
+ //io impl methods and members
std::vector<uhd::transport::udp_zero_copy::sptr> _data_transports;
- uhd::otw_type_t _rx_otw_type, _tx_otw_type;
+ const usrp2_io_helper _io_helper;
UHD_PIMPL_DECL(io_impl) _io_impl;
void io_init(void);
};