diff options
author | Michael West <michael.west@ettus.com> | 2017-03-27 19:53:57 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-04-05 17:26:28 -0700 |
commit | b32055cbde789fffff78a0311e372ba24f6c8f19 (patch) | |
tree | 414691455d36c468da40349a368a2b3f8c5d4e4f | |
parent | fe1088f9ce5bc6b2b2054a70aed60f62eb6c4c12 (diff) | |
download | uhd-b32055cbde789fffff78a0311e372ba24f6c8f19.tar.gz uhd-b32055cbde789fffff78a0311e372ba24f6c8f19.tar.bz2 uhd-b32055cbde789fffff78a0311e372ba24f6c8f19.zip |
PCIe: Add checks to make sure buffers are page alighed (requirement of
NI-RIO driver)
-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 9ed02a6dc..4212fab42 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)); } |