diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-04-06 10:40:37 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-04-06 10:40:37 -0700 |
commit | 8ad7324b51eecff5efae5c4cb6fb509da38e8fc0 (patch) | |
tree | 9342c915a3ece559e6e994ffcc943100a914ab7f /host/lib/transport/nirio_zero_copy.cpp | |
parent | af75b87e51a7c555a61f5f40f0d19f2fde04e43b (diff) | |
parent | 748689ae5402b154d78b60d61b67cb96b50d7916 (diff) | |
download | uhd-8ad7324b51eecff5efae5c4cb6fb509da38e8fc0.tar.gz uhd-8ad7324b51eecff5efae5c4cb6fb509da38e8fc0.tar.bz2 uhd-8ad7324b51eecff5efae5c4cb6fb509da38e8fc0.zip |
Merge branch 'maint'
Diffstat (limited to 'host/lib/transport/nirio_zero_copy.cpp')
-rw-r--r-- | host/lib/transport/nirio_zero_copy.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/host/lib/transport/nirio_zero_copy.cpp b/host/lib/transport/nirio_zero_copy.cpp index 3c52e5080..14118d393 100644 --- a/host/lib/transport/nirio_zero_copy.cpp +++ b/host/lib/transport/nirio_zero_copy.cpp @@ -26,6 +26,7 @@ #include <boost/make_shared.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/thread/thread.hpp> //sleep +#include <boost/interprocess/mapped_region.hpp> //get_page_size() #include <vector> #include <algorithm> // std::max //@TODO: Move the register defs required by the class to a common location @@ -350,6 +351,7 @@ nirio_zero_copy::sptr nirio_zero_copy::make( ){ //Initialize xport_params zero_copy_xport_params xport_params = default_buff_args; + size_t page_size = boost::interprocess::mapped_region::get_page_size(); //The kernel buffer for this transport must be (num_frames * frame_size) big. Unlike ethernet, //where the kernel buffer size is independent of the circular buffer size for the transport, @@ -386,6 +388,22 @@ nirio_zero_copy::sptr nirio_zero_copy::make( size_t usr_send_buff_size = static_cast<size_t>( hints.cast<double>("send_buff_size", default_buff_args.num_send_frames)); + if (hints.has_key("send_buff_size")) + { + if (usr_send_buff_size % page_size != 0) + { + throw uhd::value_error((boost::format("send_buff_size must be multiple of %d") % page_size).str()); + } + } + + if (hints.has_key("send_frame_size") and hints.has_key("num_send_frames")) + { + if (usr_num_send_frames * xport_params.send_frame_size % page_size != 0) + { + throw uhd::value_error((boost::format("num_send_frames * send_frame_size must be an even multiple of %d") % page_size).str()); + } + } + if (hints.has_key("num_send_frames") and hints.has_key("send_buff_size")) { if (usr_send_buff_size < xport_params.send_frame_size) throw uhd::value_error("send_buff_size must be equal to or greater than (num_send_frames * send_frame_size)"); @@ -400,6 +418,11 @@ nirio_zero_copy::sptr nirio_zero_copy::make( xport_params.num_send_frames = usr_num_send_frames; } + if (xport_params.num_send_frames * xport_params.send_frame_size % page_size != 0) + { + throw uhd::value_error((boost::format("num_send_frames * send_frame_size must be an even multiple of %d") % page_size).str()); + } + return nirio_zero_copy::sptr(new nirio_zero_copy_impl(fpga_session, instance, xport_params)); } |