aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2014-11-25 13:48:13 +0100
committerMartin Braun <martin.braun@ettus.com>2014-12-02 15:27:20 +0100
commit3ed7d3460e7b8669b27e4ae1b615f0c60dfa12eb (patch)
treef230af2c6c40765addeb74c89c955f6dc0f469c1
parentc2f3a590b5217dd1a6d035bc90e9de5d57a20976 (diff)
downloaduhd-3ed7d3460e7b8669b27e4ae1b615f0c60dfa12eb.tar.gz
uhd-3ed7d3460e7b8669b27e4ae1b615f0c60dfa12eb.tar.bz2
uhd-3ed7d3460e7b8669b27e4ae1b615f0c60dfa12eb.zip
x300: Fixed FC window issue (was off by one)
-rw-r--r--host/lib/usrp/x300/x300_io_impl.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/host/lib/usrp/x300/x300_io_impl.cpp b/host/lib/usrp/x300/x300_io_impl.cpp
index 04042049d..334ae8168 100644
--- a/host/lib/usrp/x300/x300_io_impl.cpp
+++ b/host/lib/usrp/x300/x300_io_impl.cpp
@@ -244,6 +244,12 @@ struct x300_tx_fc_guts_t
#define X300_ASYNC_EVENT_CODE_FLOW_CTRL 0
+/*!
+ * If the return value of this function is F, the last tx'd packet
+ * has index N and the last ack'd packet has index M, the amount of
+ * FC credit we have is C = F + M - N (i.e. we can send C more packets
+ * before getting another ack).
+ */
static size_t get_tx_flow_control_window(size_t frame_size, const device_addr_t& tx_args)
{
double hw_buff_size = tx_args.cast<double>("send_buff_size", X300_TX_HW_BUFF_SIZE);
@@ -318,9 +324,12 @@ static managed_send_buffer::sptr get_tx_buff_with_flowctrl(
){
while (true)
{
+ // delta is the amount of FC credit we've used up
const size_t delta = (guts->last_seq_out & 0xfff) - (guts->last_seq_ack & 0xfff);
- if ((delta & 0xfff) <= fc_pkt_window) break;
+ // If we want to send another packet, we must have FC credit left
+ if ((delta & 0xfff) < fc_pkt_window) break;
+ // If credit is all used up, we check seq_queue for more.
const bool ok = guts->seq_queue.pop_with_timed_wait(guts->last_seq_ack, timeout);
if (not ok) return managed_send_buffer::sptr(); //timeout waiting for flow control
}