aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp54
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp6
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp6
3 files changed, 41 insertions, 25 deletions
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index eba704059..b7585afe9 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -18,11 +18,11 @@
#include "../../transport/vrt_packet_handler.hpp"
#include "usrp2_impl.hpp"
#include "usrp2_regs.hpp"
+#include <uhd/utils/byteswap.hpp>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/transport/convert_types.hpp>
#include <uhd/transport/alignment_buffer.hpp>
#include <boost/format.hpp>
-#include <boost/asio.hpp> //htonl and ntohl
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <iostream>
@@ -32,7 +32,12 @@ using namespace uhd::usrp;
using namespace uhd::transport;
namespace asio = boost::asio;
-static const int underflow_flags = async_metadata_t::EVENT_CODE_UNDERFLOW | async_metadata_t::EVENT_CODE_UNDERFLOW_IN_PACKET;
+static const int underflow_flags = 0
+ | async_metadata_t::EVENT_CODE_UNDERFLOW
+ | async_metadata_t::EVENT_CODE_UNDERFLOW_IN_PACKET
+;
+
+static const size_t vrt_send_header_offset_words32 = 1;
/***********************************************************************
* io impl details (internal to this file)
@@ -63,6 +68,27 @@ struct usrp2_impl::io_impl{
return recv_pirate_booty->pop_elems_with_timed_wait(buffs, timeout);
}
+ bool get_send_buffs(
+ const std::vector<zero_copy_if::sptr> &trans,
+ vrt_packet_handler::managed_send_buffs_t &buffs,
+ double timeout
+ ){
+ UHD_ASSERT_THROW(trans.size() == buffs.size());
+
+ //calculate the 16-bit sequence number for the special header
+ const boost::uint32_t next_seq = uhd::htonx(boost::uint32_t(
+ packet_handler_send_state.next_packet_seq & 0xffff
+ ));
+
+ //grab a managed buffer for each index
+ for (size_t i = 0; i < buffs.size(); i++){
+ buffs[i] = trans[i]->get_send_buff(timeout);
+ if (not buffs[i].get()) return false;
+ buffs[i]->cast<boost::uint32_t *>()[0] = next_seq;
+ }
+ return true;
+ }
+
//state management for the vrt packet handler code
vrt_packet_handler::recv_state packet_handler_recv_state;
vrt_packet_handler::send_state packet_handler_send_state;
@@ -146,7 +172,9 @@ void usrp2_impl::io_init(void){
//send a small data packet so the usrp2 knows the udp source port
BOOST_FOREACH(zero_copy_if::sptr data_transport, _data_transports){
managed_send_buffer::sptr send_buff = data_transport->get_send_buff();
- static const boost::uint32_t data = htonl(USRP2_INVALID_VRT_HEADER);
+ static const boost::uint32_t data = uhd::htonx(
+ boost::uint32_t(USRP2_INVALID_VRT_HEADER)
+ );
std::memcpy(send_buff->cast<void*>(), &data, sizeof(data));
send_buff->commit(sizeof(data));
//drain the recv buffers (may have junk)
@@ -183,23 +211,10 @@ bool usrp2_impl::recv_async_msg(
/***********************************************************************
* Send Data
**********************************************************************/
-static bool get_send_buffs(
- const std::vector<udp_zero_copy::sptr> &trans,
- vrt_packet_handler::managed_send_buffs_t &buffs,
- double timeout
-){
- UHD_ASSERT_THROW(trans.size() == buffs.size());
- bool good = true;
- for (size_t i = 0; i < buffs.size(); i++){
- buffs[i] = trans[i]->get_send_buff(timeout);
- good = good and (buffs[i].get() != NULL);
- }
- return good;
-}
-
size_t usrp2_impl::get_max_send_samps_per_packet(void) const{
static const size_t hdr_size = 0
+ vrt::max_if_hdr_words32*sizeof(boost::uint32_t)
+ + 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 = _data_transports.front()->get_send_frame_size() - hdr_size;
@@ -218,8 +233,9 @@ size_t usrp2_impl::send(
io_type, _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, timeout),
- get_max_send_samps_per_packet()
+ boost::bind(&usrp2_impl::io_impl::get_send_buffs, _io_impl.get(), _data_transports, _1, timeout),
+ get_max_send_samps_per_packet(),
+ vrt_send_header_offset_words32
);
}
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index a680708ad..8429a2593 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -17,7 +17,7 @@
#include "usrp2_impl.hpp"
#include <uhd/transport/if_addrs.hpp>
-#include <uhd/transport/udp_simple.hpp>
+#include <uhd/transport/udp_zero_copy.hpp>
#include <uhd/usrp/device_props.hpp>
#include <uhd/utils/assert.hpp>
#include <uhd/utils/static.hpp>
@@ -128,7 +128,7 @@ static device::sptr usrp2_make(const device_addr_t &device_addr){
//create a ctrl and data transport for each address
std::vector<udp_simple::sptr> ctrl_transports;
- std::vector<udp_zero_copy::sptr> data_transports;
+ std::vector<zero_copy_if::sptr> data_transports;
BOOST_FOREACH(const std::string &addr, std::split_string(device_addr["addr"])){
ctrl_transports.push_back(udp_simple::make_connected(
@@ -154,7 +154,7 @@ UHD_STATIC_BLOCK(register_usrp2_device){
**********************************************************************/
usrp2_impl::usrp2_impl(
std::vector<udp_simple::sptr> ctrl_transports,
- std::vector<udp_zero_copy::sptr> data_transports
+ std::vector<zero_copy_if::sptr> data_transports
):
_data_transports(data_transports)
{
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 558726a2b..6d35e925d 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -33,7 +33,7 @@
#include <boost/function.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
#include <uhd/transport/udp_simple.hpp> //mtu
-#include <uhd/transport/udp_zero_copy.hpp>
+#include <uhd/transport/zero_copy.hpp>
#include <uhd/usrp/dboard_manager.hpp>
#include <uhd/usrp/subdev_spec.hpp>
@@ -178,7 +178,7 @@ public:
*/
usrp2_impl(
std::vector<uhd::transport::udp_simple::sptr> ctrl_transports,
- std::vector<uhd::transport::udp_zero_copy::sptr> data_transports
+ std::vector<uhd::transport::zero_copy_if::sptr> data_transports
);
~usrp2_impl(void);
@@ -208,7 +208,7 @@ private:
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;
+ std::vector<uhd::transport::zero_copy_if::sptr> _data_transports;
uhd::otw_type_t _rx_otw_type, _tx_otw_type;
UHD_PIMPL_DECL(io_impl) _io_impl;
void io_init(void);