aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/usrp2/usrp2_impl.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/usrp2/usrp2_impl.hpp')
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp86
1 files changed, 58 insertions, 28 deletions
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);
};