Partial fix for ticket:378. Merged eb/t378 -r10682:10688 to trunk.
authoreb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Thu, 26 Mar 2009 18:52:38 +0000 (18:52 +0000)
committereb <eb@221aa14e-8319-0410-a670-987f0aec2ac5>
Thu, 26 Mar 2009 18:52:38 +0000 (18:52 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@10689 221aa14e-8319-0410-a670-987f0aec2ac5

usrp2/firmware/include/usrp2_eth_packet.h
usrp2/host/lib/usrp2_impl.cc

index 98e2123ed2f5d81f7ba09503e8f8a3947cc3b4db..a118c1b550a12476bf2efa4e45d68af045624ad1 100644 (file)
@@ -150,6 +150,7 @@ typedef struct {
  */
 
 #define U2_MAX_SAMPLES 371
+#define        U2_MIN_SAMPLES    9
 
 typedef struct {
   u2_eth_packet_t      hdrs;
index 98c3eb7cfdaef7846819e33c669fa18fdbc2012d..9c30bce924a3d4d28db2404388395e0dfbf243f6 100644 (file)
@@ -932,10 +932,8 @@ namespace usrp2 {
     if (nitems == 0)
       return true;
 
-    // FIXME there's the possibility that we send fewer than 9 items in a frame.
-    // That would end up glitching the transmitter, since the ethernet will pad to
-    // 64-bytes total (9 items).  We really need some part of the stack to
-    // carry the real length (thdr?).
+    // FIXME can't deal with nitems < U2_MIN_SAMPLES (will be fixed in VRT)
+    // FIXME need to check the MTU instead of assuming 1500 bytes
 
     // fragment as necessary then fire away
 
@@ -965,7 +963,12 @@ namespace usrp2 {
 
       init_etf_hdrs(&hdrs, d_addr, flags, channel, timestamp);
 
-      size_t i = std::min((size_t) U2_MAX_SAMPLES, nitems - n);
+      // Avoid short packet by splitting last two packets if reqd
+      size_t i;
+      if ((nitems - n) > U2_MAX_SAMPLES && (nitems - n) < (U2_MAX_SAMPLES + U2_MIN_SAMPLES))
+       i = (nitems - n) / 2;
+      else
+       i = std::min((size_t) U2_MAX_SAMPLES, nitems - n);
 
       eth_iovec iov[2];
       iov[0].iov_base = &hdrs;