diff options
| -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));  }  | 
