The effect of FUSB_BLOCK_SIZE and FUSB_NBLOCKS

Hi all,

Now I’m working on measuring Round Trip Time (
FPGA(RXFIFO)->USB->PC->USB->FPGA(TXFIFO) ).
Since I’m using 128kbps bitrate and 10 samples per symbol, sample rate
is
1.28Msps.
And I do not give any options about FUSB_BLOCK_SIZE and FUSB_NBLOCKS. So
they might be 0.
In this case, the result is following:

Minimum RTT : 1.96ms
Maximum RTT : 5.12ms

As Thomas S.'s paper, this result is so reasonable. However, if I
use
FUSB_BLOCK_SIZE=2048 and FUSB_NBLOCKS=8 such like paper mentioned, it
starts
to be messed up.

RTT becomes larger and variation is also broaden. Also it gives me lots
of
overrun message.

What is the effect of these two parameters? As I know, in USB bulk
transfer
mode the USB packet size is fixed as 512 bytes. So these two parameters
will
determine the packet size transfered between Linux kernel and user
space. It
does not affect physical USB transaction. Am I correct? If yes, why does
it
make overrun error?

Please give some clues. Thanks in advance!!!


View this message in context:
http://www.nabble.com/The-effect-of-FUSB_BLOCK_SIZE-and-FUSB_NBLOCKS-tp22323564p22323564.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Wednesday 04 March 2009 05:40:36 Yong J. Chang wrote:

Hi all,

Now I’m working on measuring Round Trip Time (
FPGA(RXFIFO)->USB->PC->USB->FPGA(TXFIFO) ).
Since I’m using 128kbps bitrate and 10 samples per symbol, sample rate is
1.28Msps.
And I do not give any options about FUSB_BLOCK_SIZE and FUSB_NBLOCKS. So
they might be 0.
In this case, the result is following:

0 means default. Excerpt from fusb_linux.cc:

static const int MAX_BLOCK_SIZE = fusb_sysconfig::max_block_size();
static const int DEFAULT_BLOCK_SIZE = MAX_BLOCK_SIZE;
static const int DEFAULT_BUFFER_SIZE = 4 * (1L << 20);
if (d_block_size == 0)
d_block_size = DEFAULT_BLOCK_SIZE;
if (d_nblocks == 0)
d_nblocks = std::max (1, DEFAULT_BUFFER_SIZE / d_block_size);

max_block_size() is 16kB

Minimum RTT : 1.96ms
Maximum RTT : 5.12ms

As Thomas S.'s paper, this result is so reasonable. However, if I use
FUSB_BLOCK_SIZE=2048 and FUSB_NBLOCKS=8 such like paper mentioned, it
starts to be messed up.

RTT becomes larger and variation is also broaden. Also it gives me lots of
overrun message.

I have no problem running with a block size of 512, but it is important
to run
with SCHED_FIFO (you have to be root or need appropriate settings in
/etc/security/limits.conf, this has been discussed a few days ago on
this ML).

What is the effect of these two parameters? As I know, in USB bulk transfer
mode the USB packet size is fixed as 512 bytes. So these two parameters
will determine the packet size transfered between Linux kernel and user
space. It does not affect physical USB transaction. Am I correct? If yes,
why does it make overrun error?

As you can see above, with default values the in-kernel buffer is much
larger
(from my experiments it is mostly irrelevant how large the URBs – USB
request
block, the size you set with FUSB_BLOCK_SIZE – are, the total buffer
size is
much more critical). The size of the URB determines how often you get
notified
from the kernel. Another factor is the number of interrupts generated by
the
USB host controller, this is limited to one interrupt per microframe
(125us).

Stefan


Stefan Brüns / Bergstraße 21 / 52062 Aachen
phone: +49 241 53809034 mobile: +49 151 50412019

On Wednesday 04 March 2009 12:26:09 Stefan Bruens wrote:

max_block_size() is 16kB
Just a small correction, usrp_basic.cc sets default values on its own,
taken
from fusb_sysconfig_linux.cc, so it ends up with:
default block size: 4kB
default buffer size: 1MB
number of blocks: 1MB/4kB => 256

so on Linux {0,0} is the same as {4096,256}. Values for OsX/Win/BSD
might be
different.

Stefan


Stefan Brüns / Bergstraße 21 / 52062 Aachen
mailto:lurch at gmx.li http://www.kawo1.rwth-aachen.de/~lurchi/
phone: +49 241 53809034 mobile: +49 151 50412019