commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 98/148: usrp2 impl finds out max frame size


From: git
Subject: [Commit-gnuradio] [gnuradio] 98/148: usrp2 impl finds out max frame size from the transport
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 c33d6a0bad71d6343789ba6363784e99961acb3d
Author: Josh Blum <address@hidden>
Date:   Fri Dec 18 15:47:57 2009 -0800

    usrp2 impl finds out max frame size from the transport
---
 usrp2/firmware/include/usrp2_eth_packet.h | 11 -----------
 usrp2/host/lib/eth_data_transport.h       |  3 +++
 usrp2/host/lib/transport.h                |  4 ++++
 usrp2/host/lib/usrp2_impl.cc              | 18 ++++++++++--------
 4 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/usrp2/firmware/include/usrp2_eth_packet.h 
b/usrp2/firmware/include/usrp2_eth_packet.h
index 6c8ef12..2a16916 100644
--- a/usrp2/firmware/include/usrp2_eth_packet.h
+++ b/usrp2/firmware/include/usrp2_eth_packet.h
@@ -94,17 +94,6 @@ typedef struct {
 } u2_eth_packet_t;
 
 /*
- * full load of samples:
- *   ethernet header + transport header + fixed header + maximum number of 
samples.
- *   sizeof(u2_eth_samples_t) == 1512
- *   (payload is 1498 bytes, two bytes shorter than 1500 byte MTU)
- *   (sample numbers are made even to force pairwise alignment in the 
interleaved case)
- */
-
-#define U2_MAX_SAMPLES 350
-#define        U2_MIN_SAMPLES   10
-
-/*
  * Opcodes for control channel
  *
  * Reply opcodes are the same as the request opcode with the OP_REPLY_BIT set 
(0x80).
diff --git a/usrp2/host/lib/eth_data_transport.h 
b/usrp2/host/lib/eth_data_transport.h
index 860bb1f..2f0ee87 100644
--- a/usrp2/host/lib/eth_data_transport.h
+++ b/usrp2/host/lib/eth_data_transport.h
@@ -48,6 +48,9 @@ namespace usrp2{
         bool sendv(const iovec *iov, size_t iovlen);
         void recv(data_handler *handler);
         void flush(void);
+        size_t max_bytes(void){
+            return eth_buffer::MAX_PKTLEN - sizeof(u2_eth_packet_t);
+        }
 };
 
 
diff --git a/usrp2/host/lib/transport.h b/usrp2/host/lib/transport.h
index 902fe50..aed1645 100644
--- a/usrp2/host/lib/transport.h
+++ b/usrp2/host/lib/transport.h
@@ -64,6 +64,10 @@ namespace usrp2 {
      * \brief flush any samples in the rx buffers
      */
     virtual void flush(void){};
+    /*!
+     * \brief get the maximum number of bytes that can be passed into sendv
+     */
+    virtual size_t max_bytes(void){return 0;}
   };
   
 } // namespace usrp2
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index 20f5096..9666f8d 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -414,8 +414,10 @@ namespace usrp2 {
     //flush any old samples in the data transport
     d_data_transport->flush();
 
-      if (items_per_frame == 0)
-        items_per_frame = U2_MAX_SAMPLES;              // minimize overhead
+      if (items_per_frame == 0){
+        items_per_frame = d_data_transport->max_bytes()/sizeof(uint32_t) -
+        (vrt::HEADER_MAX_N32_BIT_WORDS + vrt::TRAILER_MAX_N32_BIT_WORDS);
+      }
 
       op_start_rx_streaming_cmd cmd;
       op_generic_t reply;
@@ -673,12 +675,12 @@ namespace usrp2 {
     if (nitems == 0)
       return true;
 
-    // FIXME need to check the transport's max size before fragmenting
-
-    // fragment as necessary then fire away
-
-    size_t nframes = (nitems + U2_MAX_SAMPLES - 1) / U2_MAX_SAMPLES;
+    // fragment as necessary based on the transport's max size
+    size_t max_frames = d_data_transport->max_bytes()/sizeof(uint32_t) -
+        (vrt::HEADER_MAX_N32_BIT_WORDS + vrt::TRAILER_MAX_N32_BIT_WORDS);
+    size_t nframes = (nitems + max_frames - 1) / max_frames;
 
+    // memory and lengths to be filled in by the expanded header
     uint32_t header[vrt::HEADER_MAX_N32_BIT_WORDS];
     size_t n32_bit_words_header;
     uint32_t trailer[vrt::TRAILER_MAX_N32_BIT_WORDS];
@@ -690,7 +692,7 @@ namespace usrp2 {
     for (size_t fn = 0; fn < nframes; fn++){
 
       //calculate the payload length
-      size_t n32_bit_words_payload = std::min((size_t) U2_MAX_SAMPLES, nitems 
- items_sent);
+      size_t n32_bit_words_payload = std::min<size_t>(max_frames, nitems - 
items_sent);
 
       //clear the burst flags and count
       hdr_frag.header &= ~(VRTH_START_OF_BURST | VRTH_END_OF_BURST | 
VRTH_PKT_CNT_MASK);



reply via email to

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