summaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-10-13 13:08:12 -0700
committerJosh Blum <josh@joshknows.com>2011-11-03 20:37:12 -0700
commit00b6d8359de6ea616f7bd6573d7f87d635d78a79 (patch)
treecaea2fa1178dd5dac722f1395480539474c47b57 /host/lib/transport
parent522bc87d9f61668f3d22e067c39a98e5f33fc6c5 (diff)
downloaduhd-00b6d8359de6ea616f7bd6573d7f87d635d78a79.tar.gz
uhd-00b6d8359de6ea616f7bd6573d7f87d635d78a79.tar.bz2
uhd-00b6d8359de6ea616f7bd6573d7f87d635d78a79.zip
uhd: added trailer parsing for occupancy
Diffstat (limited to 'host/lib/transport')
-rwxr-xr-xhost/lib/transport/gen_vrt_if_packet.py51
-rw-r--r--host/lib/transport/super_recv_packet_handler.hpp11
-rw-r--r--host/lib/transport/super_send_packet_handler.hpp3
3 files changed, 39 insertions, 26 deletions
diff --git a/host/lib/transport/gen_vrt_if_packet.py b/host/lib/transport/gen_vrt_if_packet.py
index 5f048d8c7..245a7ddbd 100755
--- a/host/lib/transport/gen_vrt_if_packet.py
+++ b/host/lib/transport/gen_vrt_if_packet.py
@@ -70,6 +70,10 @@ static pred_table_type get_pred_unpack_table(void){
static const pred_table_type pred_unpack_table(get_pred_unpack_table());
+//maps trailer bits to num empty bytes
+//maps num empty bytes to trailer bits
+static const size_t occ_table[] = {0, 2, 1, 3};
+
########################################################################
#def gen_code($XE_MACRO, $suffix)
########################################################################
@@ -122,14 +126,6 @@ void vrt::if_hdr_pack_$(suffix)(
#set $num_header_words += 1
#set $flags |= (0x1 << 20);
#end if
- ########## Trailer ##########
- #if $pred & $tlr_p
- //packet_buff[$num_header_words+if_packet_info.num_payload_words32] = $(XE_MACRO)(if_packet_info.tlr);
- #set $flags |= (0x1 << 26);
- #set $num_trailer_words = 1;
- #else
- #set $num_trailer_words = 0;
- #end if
########## Burst Flags ##########
#if $pred & $eob_p
#set $flags |= (0x1 << 24);
@@ -137,6 +133,18 @@ void vrt::if_hdr_pack_$(suffix)(
#if $pred & $sob_p
#set $flags |= (0x1 << 25);
#end if
+ ########## Trailer ##########
+ #if $pred & $tlr_p
+ {
+ const size_t empty_bytes = if_packet_info.num_payload_words32*sizeof(boost::uint32_t) - if_packet_info.num_payload_bytes;
+ if_packet_info.tlr |= (0x3 << 22) | (occ_table[empty_bytes & 0x3] << 10);
+ }
+ packet_buff[$num_header_words+if_packet_info.num_payload_words32] = $(XE_MACRO)(if_packet_info.tlr);
+ #set $flags |= (0x1 << 26);
+ #set $num_trailer_words = 1;
+ #else
+ #set $num_trailer_words = 0;
+ #end if
########## Variables ##########
if_packet_info.num_header_words32 = $num_header_words;
if_packet_info.num_packet_words32 = $($num_header_words + $num_trailer_words) + if_packet_info.num_payload_words32;
@@ -172,6 +180,8 @@ void vrt::if_hdr_unpack_$(suffix)(
const pred_type pred = pred_unpack_table[pred_table_index(vrt_hdr_word)];
+ size_t empty_bytes = 0;
+
switch(pred){
#for $pred in range(2**7)
case $pred:
@@ -211,15 +221,6 @@ void vrt::if_hdr_unpack_$(suffix)(
#else
if_packet_info.has_tsf = false;
#end if
- ########## Trailer ##########
- #if $pred & $tlr_p
- if_packet_info.has_tlr = true;
- if_packet_info.tlr = $(XE_MACRO)(packet_buff[packet_words32-1]);
- #set $num_trailer_words = 1;
- #else
- if_packet_info.has_tlr = false;
- #set $num_trailer_words = 0;
- #end if
########## Burst Flags ##########
#if $pred & $eob_p
if_packet_info.eob = true;
@@ -231,12 +232,28 @@ void vrt::if_hdr_unpack_$(suffix)(
#else
if_packet_info.sob = false;
#end if
+ ########## Trailer ##########
+ #if $pred & $tlr_p
+ if_packet_info.has_tlr = true;
+ if_packet_info.tlr = $(XE_MACRO)(packet_buff[packet_words32-1]);
+ #set $num_trailer_words = 1;
+ {
+ const int indicators = (if_packet_info.tlr >> 20) & (if_packet_info.tlr >> 8);
+ if ((indicators & (1 << 0)) != 0) if_packet_info.eob = true;
+ if ((indicators & (1 << 1)) != 0) if_packet_info.sob = true;
+ empty_bytes = occ_table[(indicators >> 2) & 0x3];
+ }
+ #else
+ if_packet_info.has_tlr = false;
+ #set $num_trailer_words = 0;
+ #end if
########## Variables ##########
//another failure case
if (packet_words32 < $($num_header_words + $num_trailer_words))
throw uhd::value_error("bad vrt header or invalid packet length");
if_packet_info.num_header_words32 = $num_header_words;
if_packet_info.num_payload_words32 = packet_words32 - $($num_header_words + $num_trailer_words);
+ if_packet_info.num_payload_bytes = if_packet_info.num_payload_words32*sizeof(boost::uint32_t) - empty_bytes;
break;
#end for
}
diff --git a/host/lib/transport/super_recv_packet_handler.hpp b/host/lib/transport/super_recv_packet_handler.hpp
index 2310d6aea..48b0acdb9 100644
--- a/host/lib/transport/super_recv_packet_handler.hpp
+++ b/host/lib/transport/super_recv_packet_handler.hpp
@@ -327,7 +327,7 @@ private:
info.alignment_time = info[index].time;
info.indexes_todo.set();
info.indexes_todo.reset(index);
- info.data_bytes_to_copy = info[index].ifpi.num_payload_words32*sizeof(boost::uint32_t);
+ info.data_bytes_to_copy = info[index].ifpi.num_payload_bytes;
}
//if the sequence id matches:
@@ -471,13 +471,8 @@ private:
curr_info.metadata.time_spec = curr_info[0].time;
curr_info.metadata.more_fragments = false;
curr_info.metadata.fragment_offset = 0;
- /* TODO SOB on RX not supported in hardware
- static const int tlr_sob_flags = (1 << 21) | (1 << 9); //enable and indicator bits
- curr_info.metadata.start_of_burst = curr_info[0].ifpi.has_tlr and (int(curr_info[0].ifpi.tlr & tlr_sob_flags) != 0);
- */
- curr_info.metadata.start_of_burst = false;
- static const int tlr_eob_flags = (1 << 20) | (1 << 8); //enable and indicator bits
- curr_info.metadata.end_of_burst = curr_info[0].ifpi.has_tlr and (int(curr_info[0].ifpi.tlr & tlr_eob_flags) != 0);
+ curr_info.metadata.start_of_burst = curr_info[0].ifpi.sob;
+ curr_info.metadata.end_of_burst = curr_info[0].ifpi.eob;
curr_info.metadata.error_code = rx_metadata_t::ERROR_CODE_NONE;
}
diff --git a/host/lib/transport/super_send_packet_handler.hpp b/host/lib/transport/super_send_packet_handler.hpp
index 779259d4f..5696b5d39 100644
--- a/host/lib/transport/super_send_packet_handler.hpp
+++ b/host/lib/transport/super_send_packet_handler.hpp
@@ -219,7 +219,8 @@ private:
const size_t buffer_offset_bytes = 0
){
//load the rest of the if_packet_info in here
- if_packet_info.num_payload_words32 = (nsamps_per_buff*_io_buffs.size()*_bytes_per_otw_item)/sizeof(boost::uint32_t);
+ if_packet_info.num_payload_bytes = nsamps_per_buff*_io_buffs.size()*_bytes_per_otw_item;
+ if_packet_info.num_payload_words32 = (if_packet_info.num_payload_bytes + 3/*round up*/)/sizeof(boost::uint32_t);
if_packet_info.packet_count = _next_packet_seq;
size_t buff_index = 0;