From dcd76b9e20b900d2da3ca8d6f32ad99c69e4e40f Mon Sep 17 00:00:00 2001
From: Vidush <vidush.vishwanath@ettus.com>
Date: Mon, 9 Jul 2018 10:36:19 -0700
Subject: B200: Check if recv_frame_size is larger than minimum value

---
 host/lib/usrp/b200/b200_impl.cpp | 8 ++++++++
 host/lib/usrp/b200/b200_impl.hpp | 2 ++
 2 files changed, 10 insertions(+)

(limited to 'host/lib')

diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp
index e435afaad..6642ae0a7 100644
--- a/host/lib/usrp/b200/b200_impl.cpp
+++ b/host/lib/usrp/b200/b200_impl.cpp
@@ -533,6 +533,14 @@ b200_impl::b200_impl(const uhd::device_addr_t& device_addr, usb_device_handle::s
             << "Requested recv_frame_size of " << device_addr["recv_frame_size"]
             << " reduced to " << recv_frame_size << ".";
     }
+    // Check that recv_frame_size was set to a reasonable value.
+    if (recv_frame_size < B200_USB_DATA_MIN_RECV_FRAME_SIZE) {
+        UHD_LOGGER_WARNING("B200")
+            << "Requested recv_frame_size of " << recv_frame_size
+            << " is too small. It will be set to "
+            << B200_USB_DATA_MIN_RECV_FRAME_SIZE << ".";
+        recv_frame_size = B200_USB_DATA_MIN_RECV_FRAME_SIZE;
+    }
     data_xport_args["recv_frame_size"] = std::to_string(recv_frame_size);
     data_xport_args["num_recv_frames"] = device_addr.get("num_recv_frames", "16");
     data_xport_args["send_frame_size"] = device_addr.get("send_frame_size", std::to_string(B200_USB_DATA_DEFAULT_FRAME_SIZE));
diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp
index 5b4a03694..2e7ab176f 100644
--- a/host/lib/usrp/b200/b200_impl.hpp
+++ b/host/lib/usrp/b200/b200_impl.hpp
@@ -82,6 +82,8 @@ static const unsigned char B200_USB_DATA_SEND_ENDPOINT  = 2;
 
 // Default recv_frame_size. Must not be a multiple of 512.
 static const int B200_USB_DATA_DEFAULT_FRAME_SIZE = 8176;
+// recv_frame_size values below this will be upped to this value
+static const int B200_USB_DATA_MIN_RECV_FRAME_SIZE = 40;
 
 /*
  * VID/PID pairs for all B2xx products
-- 
cgit v1.2.3