From 012d333c8ef61f5bf53559d00d984a82d608c1d6 Mon Sep 17 00:00:00 2001
From: Laurent <laurent.thomas@open-cells.com>
Date: Fri, 10 Feb 2017 17:08:28 +0100
Subject: [PATCH] tune USRP/USB packet size

---
 targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
index 2ac70b2d826..b2b386ba7d1 100644
--- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
+++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
@@ -662,14 +662,18 @@ extern "C" {
         // create tx & rx streamer
         uhd::stream_args_t stream_args_rx("sc16", "sc16");
         int samples=openair0_cfg[0].sample_rate;
-        //while ( samples > s->rx_stream->get_max_num_samps())
-        samples/=24000;
-        stream_args_rx.args["spp"] = str(boost::format("%d") % samples );
+	int max=s->usrp->get_rx_stream(stream_args_rx)->get_max_num_samps();
+        samples/=10000;
+	LOG_I(PHY,"RF board max packet size %u, size for 100µs jitter %d \n", max, samples);
+	if ( samples < max )
+	  stream_args_rx.args["spp"] = str(boost::format("%d") % samples );
+	LOG_I(PHY,"rx_max_num_samps %u\n",
+	      s->usrp->get_rx_stream(stream_args_rx)->get_max_num_samps());
+
         for (int i = 0; i<openair0_cfg[0].rx_num_channels; i++)
             stream_args_rx.channels.push_back(i);
         s->rx_stream = s->usrp->get_rx_stream(stream_args_rx);
-        LOG_I(PHY,"rx_max_num_samps %u\n",s->rx_stream->get_max_num_samps());
-
+	
         uhd::stream_args_t stream_args_tx("sc16", "sc16");
         for (int i = 0; i<openair0_cfg[0].tx_num_channels; i++)
             stream_args_tx.channels.push_back(i);
-- 
GitLab