[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 92/148: Added unparse capability to the vrt
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 92/148: Added unparse capability to the vrt expanded header. Unparse can fill in a vrt header and trailer from an expanded header. |
Date: |
Mon, 15 Aug 2016 00:47:28 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
nwest pushed a commit to annotated tag old_usrp_devel_udp
in repository gnuradio.
commit a5316f6ac23d76e45b4d85772e314fd1bbb93282
Author: Josh Blum <address@hidden>
Date: Thu Dec 17 16:48:54 2009 -0800
Added unparse capability to the vrt expanded header.
Unparse can fill in a vrt header and trailer from an expanded header.
---
vrt/include/vrt/expanded_header.h | 15 +-
vrt/lib/Makefile.am | 6 +-
vrt/lib/expanded_header.cc | 18 +-
..._body.h => expanded_header_parse_switch_body.h} | 0
vrt/lib/expanded_header_unparse_switch_body.h | 272 +++++++++++++++++++++
...gen_switch_body.py => gen_parse_switch_body.py} | 0
...n_switch_body.py => gen_unparse_switch_body.py} | 25 +-
7 files changed, 319 insertions(+), 17 deletions(-)
diff --git a/vrt/include/vrt/expanded_header.h
b/vrt/include/vrt/expanded_header.h
index 0cfca04..b3333a7 100644
--- a/vrt/include/vrt/expanded_header.h
+++ b/vrt/include/vrt/expanded_header.h
@@ -27,6 +27,9 @@
namespace vrt {
+ static const size_t HEADER_MAX_N32_BIT_WORDS = 7;
+ static const size_t TRAILER_MAX_N32_BIT_WORDS = 1;
+
/*!
* \brief All headers and trailer for VRT IF-Data, Extension-Data,
* IF-Context and Extension-Context packets.
@@ -73,7 +76,17 @@ namespace vrt {
bool trailer_p() const { return (header & VRTH_HAS_TRAILER) != 0 &&
data_p(); }
- // parser
+ /*!
+ * \brief unparse expanded header, fill-in the words of a vrt packet
header and trailer
+ * This method is only intended to fill the buffers with header and
trailer information.
+ * The actual handling of the separate header, payload, trailer buffers is
up to the caller.
+ */
+ static void unparse(const expanded_header *hdr, // in
+ size_t n32_bit_words_payload, // in
+ uint32_t *header, // out
+ size_t *n32_bit_words_header, // out
+ uint32_t *trailer, // out
+ size_t *n32_bit_words_trailer);// out
/*!
* \brief parse packet, fill-in expanded header, start of payload and len
of payload
diff --git a/vrt/lib/Makefile.am b/vrt/lib/Makefile.am
index 3a758ee..f2fcce0 100644
--- a/vrt/lib/Makefile.am
+++ b/vrt/lib/Makefile.am
@@ -42,9 +42,11 @@ libvrt_la_LIBADD =
noinst_HEADERS = \
data_handler.h \
expanded_header_cw_tables.h \
- expanded_header_switch_body.h \
+ expanded_header_parse_switch_body.h \
+ expanded_header_unparse_switch_body.h \
socket_rx_buffer.h
EXTRA_DIST = \
gen_cw_tables.py \
- gen_switch_body.py
+ gen_parse_switch_body.py \
+ gen_unparse_switch_body.py
diff --git a/vrt/lib/expanded_header.cc b/vrt/lib/expanded_header.cc
index bd1d92e..64e97ef 100644
--- a/vrt/lib/expanded_header.cc
+++ b/vrt/lib/expanded_header.cc
@@ -71,6 +71,22 @@ namespace vrt {
return cw;
}
+ void expanded_header::unparse(const expanded_header *h, // in
+ size_t n32_bit_words_payload, // in
+ uint32_t *header, // out
+ size_t *n32_bit_words_header, // out
+ uint32_t *trailer, // out
+ size_t *n32_bit_words_trailer){// out
+ int cw = compute_codeword(*h);
+ //fills in the header (except word0), header length, trailer, trailer
length
+ switch (cw & 0x1f){
+#include "expanded_header_unparse_switch_body.h"
+ }
+ //fill in the header word 0 with the calculated length
+ size_t n32_bit_words_packet = *n32_bit_words_header +
n32_bit_words_payload + *n32_bit_words_trailer;
+ header[0] = htonl((h->header & ~VRTH_PKT_SIZE_MASK) |
(n32_bit_words_packet & VRTH_PKT_SIZE_MASK));
+ }
+
bool
expanded_header::parse(const uint32_t *packet, // in
size_t n32_bit_words_packet, // in
@@ -109,7 +125,7 @@ namespace vrt {
// h->header, cw, cw_header_len(cw), cw_trailer_len(cw));
switch (cw & 0x1f){
-#include "expanded_header_switch_body.h"
+#include "expanded_header_parse_switch_body.h"
}
return true;
diff --git a/vrt/lib/expanded_header_switch_body.h
b/vrt/lib/expanded_header_parse_switch_body.h
similarity index 100%
rename from vrt/lib/expanded_header_switch_body.h
rename to vrt/lib/expanded_header_parse_switch_body.h
diff --git a/vrt/lib/expanded_header_unparse_switch_body.h
b/vrt/lib/expanded_header_unparse_switch_body.h
new file mode 100644
index 0000000..ca6e149
--- /dev/null
+++ b/vrt/lib/expanded_header_unparse_switch_body.h
@@ -0,0 +1,272 @@
+ case 0:
+ *n32_bit_words_header = 1;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 1:
+ header[1] = htonl(h->stream_id);
+ *n32_bit_words_header = 2;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 2:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ *n32_bit_words_header = 3;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 3:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 4:
+ header[1] = htonl(h->integer_secs);
+ *n32_bit_words_header = 2;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 5:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl(h->integer_secs);
+ *n32_bit_words_header = 3;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 6:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl(h->integer_secs);
+ *n32_bit_words_header = 4;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 7:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl(h->integer_secs);
+ *n32_bit_words_header = 5;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 8:
+ header[1] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 3;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 9:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 10:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 5;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 11:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 6;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 12:
+ header[1] = htonl(h->integer_secs);
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 13:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl(h->integer_secs);
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 5;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 14:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl(h->integer_secs);
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 6;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 15:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl(h->integer_secs);
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[6] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 7;
+ *n32_bit_words_trailer = 0;
+ break;
+
+ case 16:
+ *n32_bit_words_header = 1;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 17:
+ header[1] = htonl(h->stream_id);
+ *n32_bit_words_header = 2;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 18:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ *n32_bit_words_header = 3;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 19:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 20:
+ header[1] = htonl(h->integer_secs);
+ *n32_bit_words_header = 2;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 21:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl(h->integer_secs);
+ *n32_bit_words_header = 3;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 22:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl(h->integer_secs);
+ *n32_bit_words_header = 4;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 23:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl(h->integer_secs);
+ *n32_bit_words_header = 5;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 24:
+ header[1] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 3;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 25:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 26:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 5;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 27:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 6;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 28:
+ header[1] = htonl(h->integer_secs);
+ header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 4;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 29:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl(h->integer_secs);
+ header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 5;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 30:
+ header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[3] = htonl(h->integer_secs);
+ header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 6;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
+ case 31:
+ header[1] = htonl(h->stream_id);
+ header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff));
+ header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff));
+ header[4] = htonl(h->integer_secs);
+ header[5] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff));
+ header[6] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff));
+ *n32_bit_words_header = 7;
+ trailer[0] = htonl(h->trailer);
+ *n32_bit_words_trailer = 1;
+ break;
+
diff --git a/vrt/lib/gen_switch_body.py b/vrt/lib/gen_parse_switch_body.py
similarity index 100%
copy from vrt/lib/gen_switch_body.py
copy to vrt/lib/gen_parse_switch_body.py
diff --git a/vrt/lib/gen_switch_body.py b/vrt/lib/gen_unparse_switch_body.py
similarity index 74%
rename from vrt/lib/gen_switch_body.py
rename to vrt/lib/gen_unparse_switch_body.py
index 105fa76..6c7cd01 100755
--- a/vrt/lib/gen_switch_body.py
+++ b/vrt/lib/gen_unparse_switch_body.py
@@ -31,30 +31,28 @@ HAS_TRAILER = 1 << 4;
def do_case(f, cw):
def do32(name, mask, index):
- f.write(" ")
if cw & mask:
- f.write("h->%s = ntohl(p[%d]);\n" % (name, index))
+ f.write(" header[%d] = htonl(h->%s);\n" % (index, name))
return 1
- else:
- f.write("h->%s = 0;\n" % (name,))
- return 0
+ return 0
def do64(name, mask, index):
- f.write(" ")
if cw & mask:
- f.write("h->%s = ((uint64_t)(ntohl(p[%d])) << 32) |
ntohl(p[%d]);\n" % (name, index, index+1))
+ f.write(" header[%d] = htonl((uint32_t)((h->%s >> 32) &
0xffffffff));\n" % (index, name))
+ f.write(" header[%d] = htonl((uint32_t)((h->%s >> 0) &
0xffffffff));\n" % (index+1, name))
return 2
- else:
- f.write("h->%s = 0;\n" % (name,))
- return 0
+ return 0
+
+ def dolength(index):
+ f.write(" *n32_bit_words_header = %d;\n"%index)
def dotrailer(name, mask):
- f.write(" ")
if cw & mask:
- f.write("h->%s = ntohl(p[len-1]);\n" % (name,))
+ f.write(" trailer[%d] = htonl(h->%s);\n" % (0, name))
+ f.write(" *n32_bit_words_trailer = 1;\n")
return 1
else:
- f.write("h->%s = 0;\n" % (name,))
+ f.write(" *n32_bit_words_trailer = 0;\n")
return 0
f.write(" case %d:\n" % (cw,))
@@ -64,6 +62,7 @@ def do_case(f, cw):
index += do64("class_id", HAS_CLASS_ID, index)
index += do32("integer_secs", HAS_INTEGER_SECS, index)
index += do64("fractional_secs", HAS_FRACTIONAL_SECS, index)
+ dolength(index)
dotrailer("trailer", HAS_TRAILER)
f.write(" break;\n\n")
- [Commit-gnuradio] [gnuradio] 61/148: Merge branch 'vita_rx' of gnuradio.org:matt into vita_rx, (continued)
- [Commit-gnuradio] [gnuradio] 61/148: Merge branch 'vita_rx' of gnuradio.org:matt into vita_rx, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 59/148: WIP host mods to send vrt packets, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 76/148: Merge branch 'master' of http://gnuradio.org/git/gnuradio into vita_rx, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 64/148: put new setting reg into the address space in the right place, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 74/148: Merge branch 'wip/usrp2' of address@hidden:jblum into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 78/148: Merge branch 'vita_rx' of gnuradio.org:matt into vita_rx, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 83/148: added timeout to ring wait calls, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 60/148: fixed typo in u2_core.v resulting in unconnected net. added debug pins, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 99/148: removed unused copy handler, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 95/148: added documentation for handling of the expanded headers in the transmit calls, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 92/148: Added unparse capability to the vrt expanded header. Unparse can fill in a vrt header and trailer from an expanded header.,
git <=
- [Commit-gnuradio] [gnuradio] 89/148: Replaced tx metadata with vrt expanded header., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 75/148: dsp_core_tx now has setting reg base settable from u2_core. underrun bug in vrt fixed, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 98/148: usrp2 impl finds out max frame size from the transport, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 96/148: Merge branch 'vrt' of address@hidden:jblum into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 128/148: yet more debug lines, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 118/148: more typo fixes., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 112/148: Merge branch 'wip/usrp2' of http://vps.gnuradio.org/git/jblum into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 115/148: place udp core in the memory space, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 120/148: make it match the 36 bit wide version, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 108/148: renamed tics to ticks to be more pc, git, 2016/08/14