commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 47/148: Handled the case of short packets i


From: git
Subject: [Commit-gnuradio] [gnuradio] 47/148: Handled the case of short packets in eth data transport by using padding.
Date: Mon, 15 Aug 2016 00:47:23 +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 70591620684d20437505352c3590898bd80c486e
Author: Josh Blum <address@hidden>
Date:   Fri Nov 20 14:54:12 2009 -0800

    Handled the case of short packets in eth data transport by using padding.
---
 usrp2/host/lib/eth_ctrl_transport.cc |  2 +-
 usrp2/host/lib/eth_data_transport.cc | 12 +++++++++++-
 usrp2/host/lib/usrp2_impl.cc         | 14 ++------------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/usrp2/host/lib/eth_ctrl_transport.cc 
b/usrp2/host/lib/eth_ctrl_transport.cc
index 72f13e9..8f7c418 100644
--- a/usrp2/host/lib/eth_ctrl_transport.cc
+++ b/usrp2/host/lib/eth_ctrl_transport.cc
@@ -68,7 +68,7 @@ bool usrp2::eth_ctrl_transport::sendv(const iovec *iov, 
size_t iovlen){
     uint8_t padding[ethernet::MIN_PKTLEN];
     memset(padding, 0, ethernet::MIN_PKTLEN);
     all_iov[all_iov_len-1].iov_base = padding;
-    all_iov[all_iov_len-1].iov_len = std::max(ethernet::MIN_PKTLEN-num_bytes, 
0);
+    all_iov[all_iov_len-1].iov_len = 
std::max(int(ethernet::MIN_PKTLEN)-num_bytes, 0);
     return d_eth_ctrl->write_packetv(all_iov, all_iov_len) > 0;
 }
 
diff --git a/usrp2/host/lib/eth_data_transport.cc 
b/usrp2/host/lib/eth_data_transport.cc
index 0c28dc5..88e7b4f 100644
--- a/usrp2/host/lib/eth_data_transport.cc
+++ b/usrp2/host/lib/eth_data_transport.cc
@@ -51,7 +51,7 @@ void usrp2::eth_data_transport::init(){
 bool usrp2::eth_data_transport::sendv(const iovec *iov, size_t iovlen){
     //create a new iov array with a space for ethernet header
     // and move the current iovs to the center of the new array
-    size_t all_iov_len = iovlen + 1;
+    size_t all_iov_len = iovlen + 2;
     iovec all_iov[all_iov_len];
     for (size_t i = 0; i < iovlen; i++){
         all_iov[i+1] = iov[i];
@@ -67,6 +67,16 @@ bool usrp2::eth_data_transport::sendv(const iovec *iov, 
size_t iovlen){
     //feed the first iov the header
     all_iov[0].iov_base = &hdr;
     all_iov[0].iov_len = sizeof(hdr);
+    //get number of bytes in current iovs
+    int num_bytes = 0;
+    for (size_t i = 0; i < all_iov_len-1; i++){
+        num_bytes += all_iov[i].iov_len;
+    }
+    //handle padding, must be at least minimum length
+    uint8_t padding[eth_buffer::MIN_PKTLEN];
+    memset(padding, 0, eth_buffer::MIN_PKTLEN);
+    all_iov[all_iov_len-1].iov_base = padding;
+    all_iov[all_iov_len-1].iov_len = 
std::max(int(eth_buffer::MIN_PKTLEN)-num_bytes, 0);
     return (d_eth_data->tx_framev(all_iov, all_iov_len) == eth_buffer::EB_OK)? 
true : false;
 }
 
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index 3e51eb9..23f0841 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -779,7 +779,6 @@ namespace usrp2 {
     if (nitems == 0)
       return true;
 
-    // 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
@@ -812,12 +811,7 @@ namespace usrp2 {
       u2p_set_word0(&fixed_hdr, flags, channel);
       u2p_set_timestamp(&fixed_hdr, timestamp);
 
-      // 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);
+      size_t i = std::min((size_t) U2_MAX_SAMPLES, nitems - n);
 
       eth_iovec iov[2];
       iov[0].iov_base = &fixed_hdr;
@@ -825,12 +819,8 @@ namespace usrp2 {
       iov[1].iov_base = const_cast<uint32_t *>(&items[n]);
       iov[1].iov_len = i * sizeof(uint32_t);
 
-      size_t total = iov[0].iov_len + iov[1].iov_len;
-      if (total < 64)
-       fprintf(stderr, "usrp2::tx_raw: FIXME: short packet: %zd items (%zd 
bytes)\n", i, total);
-
       if (not d_data_transport->sendv(iov, 2)){
-       return false;
+        return false;
       }
 
       n += i;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]