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.hpp198
1 files changed, 119 insertions, 79 deletions
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 2126b9565..42630a3e4 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -22,7 +22,7 @@
#include "clock_ctrl.hpp"
#include "codec_ctrl.hpp"
#include "serdes_ctrl.hpp"
-#include <uhd/usrp/usrp2.hpp>
+#include <uhd/device.hpp>
#include <uhd/utils/pimpl.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/types/otw_type.hpp>
@@ -31,7 +31,7 @@
#include <uhd/usrp/dboard_eeprom.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
-#include <uhd/transport/vrt.hpp>
+#include <uhd/transport/vrt_if_packet.hpp>
#include <uhd/transport/udp_zero_copy.hpp>
#include <uhd/usrp/dboard_manager.hpp>
@@ -62,73 +62,84 @@ public:
return sptr(new wax_obj_proxy(get, set));
}
- ~wax_obj_proxy(void){
- /* NOP */
+private:
+ get_t _get; set_t _set;
+ wax_obj_proxy(const get_t &get, const set_t &set): _get(get), _set(set){};
+ void get(const wax::obj &key, wax::obj &val){return _get(key, val);}
+ void set(const wax::obj &key, const wax::obj &val){return _set(key, val);}
+};
+
+/*!
+ * 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;
}
-private:
- get_t _get;
- set_t _set;
+ inline size_t get_max_send_samps_per_packet(void) const{
+ return _max_tx_bytes_per_packet/_tx_otw_type.get_sample_size();
+ }
- wax_obj_proxy(const get_t &get, const set_t &set){
- _get = get;
- _set = set;
- };
+ inline size_t get_max_recv_samps_per_packet(void) const{
+ return _max_rx_bytes_per_packet/_rx_otw_type.get_sample_size();
+ }
- void get(const wax::obj &key, wax::obj &val){
- return _get(key, val);
+ inline const uhd::otw_type_t &get_rx_otw_type(void) const{
+ return _rx_otw_type;
}
- void set(const wax::obj &key, const wax::obj &val){
- return _set(key, val);
+ 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 implementation guts:
+ * USRP2 mboard implementation guts:
* The implementation details are encapsulated here.
* Handles properties on the mboard, dboard, dsps...
*/
-class usrp2_impl : public uhd::device{
+class usrp2_mboard_impl : public wax::obj{
public:
- /*!
- * Create a new usrp2 impl base.
- * \param ctrl_transport the udp transport for control
- * \param data_transport the udp transport for data
- */
- usrp2_impl(
- uhd::transport::udp_simple::sptr ctrl_transport,
- uhd::transport::udp_zero_copy::sptr data_transport
- );
+ typedef boost::shared_ptr<usrp2_mboard_impl> sptr;
- ~usrp2_impl(void);
+ //structors
+ usrp2_mboard_impl(size_t index, uhd::transport::udp_simple::sptr, const usrp2_io_helper &);
+ ~usrp2_mboard_impl(void);
- //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();
- }
- size_t send(
- const boost::asio::const_buffer &,
- const uhd::tx_metadata_t &,
- const uhd::io_type_t &,
- 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();
- }
- size_t recv(
- const boost::asio::mutable_buffer &,
- uhd::rx_metadata_t &,
- const uhd::io_type_t &,
- uhd::device::recv_mode_t
- );
-
-private:
inline double get_master_clock_freq(void){
return _clock_ctrl->get_master_clock_rate();
}
- //device properties interface
+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 &);
@@ -138,25 +149,10 @@ private:
usrp2_codec_ctrl::sptr _codec_ctrl;
usrp2_serdes_ctrl::sptr _serdes_ctrl;
- /*******************************************************************
- * 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_header_words32*sizeof(boost::uint32_t)
- ;
-
- uhd::otw_type_t _rx_otw_type, _tx_otw_type;
- UHD_PIMPL_DECL(io_impl) _io_impl;
- void io_init(void);
-
- //udp transports for control and data
- uhd::transport::udp_zero_copy::sptr _data_transport;
+ //rx and tx dboard methods and objects
+ uhd::usrp::dboard_manager::sptr _dboard_manager;
+ uhd::usrp::dboard_iface::sptr _dboard_iface;
+ void dboard_init(void);
//methods and shadows for clock configuration
uhd::clock_config_t _clock_config;
@@ -164,17 +160,6 @@ private:
void update_clock_config(void);
void set_time_spec(const uhd::time_spec_t &time_spec, bool now);
- //rx and tx dboard methods and objects
- uhd::usrp::dboard_manager::sptr _dboard_manager;
- uhd::usrp::dboard_iface::sptr _dboard_iface;
- void dboard_init(void);
-
- //properties for the mboard
- void mboard_init(void);
- void mboard_get(const wax::obj &, wax::obj &);
- void mboard_set(const wax::obj &, const wax::obj &);
- wax_obj_proxy::sptr _mboard_proxy;
-
//properties interface for rx dboard
void rx_dboard_get(const wax::obj &, wax::obj &);
void rx_dboard_set(const wax::obj &, const wax::obj &);
@@ -213,4 +198,59 @@ private:
};
+/*!
+ * USRP2 implementation guts:
+ * The implementation details are encapsulated here.
+ * Handles device properties and streaming...
+ */
+class usrp2_impl : public uhd::device{
+public:
+ /*!
+ * Create a new usrp2 impl base.
+ * \param ctrl_transports the udp transports for control
+ * \param data_transports the udp transports for data
+ */
+ usrp2_impl(
+ std::vector<uhd::transport::udp_simple::sptr> ctrl_transports,
+ std::vector<uhd::transport::udp_zero_copy::sptr> data_transports
+ );
+
+ ~usrp2_impl(void);
+
+ //the io interface
+ size_t get_max_send_samps_per_packet(void) const{
+ return _io_helper.get_max_send_samps_per_packet();
+ }
+ size_t send(
+ const std::vector<const void *> &, size_t,
+ const uhd::tx_metadata_t &,
+ const uhd::io_type_t &,
+ uhd::device::send_mode_t
+ );
+ size_t get_max_recv_samps_per_packet(void) const{
+ return _io_helper.get_max_recv_samps_per_packet();
+ }
+ size_t recv(
+ const std::vector<void *> &, size_t,
+ uhd::rx_metadata_t &,
+ const uhd::io_type_t &,
+ uhd::device::recv_mode_t
+ );
+
+private:
+ //device properties interface
+ void get(const wax::obj &, wax::obj &);
+ void set(const wax::obj &, const wax::obj &);
+
+ //pointers to mboards on this device (think mimo setup)
+ std::vector<usrp2_mboard_impl::sptr> _mboards;
+ uhd::dict<std::string, usrp2_mboard_impl::sptr> _mboard_dict;
+
+ //io impl methods and members
+ std::vector<uhd::transport::udp_zero_copy::sptr> _data_transports;
+ const usrp2_io_helper _io_helper;
+ UHD_PIMPL_DECL(io_impl) _io_impl;
+ void io_init(void);
+};
+
#endif /* INCLUDED_USRP2_IMPL_HPP */