commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 25/148: cleanup


From: git
Subject: [Commit-gnuradio] [gnuradio] 25/148: cleanup
Date: Mon, 15 Aug 2016 00:47:21 +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 b0ddc0420f037ea725200c68aa89f730a9bbd5f3
Author: Josh Blum <address@hidden>
Date:   Thu Nov 5 16:13:01 2009 -0800

    cleanup
---
 usrp2/firmware/include/usrp2_eth_packet.h |   8 ++
 usrp2/host/lib/eth_ctrl_transport.cc      |   8 --
 usrp2/host/lib/eth_data_transport.cc      |   8 --
 usrp2/host/lib/sbuff.h                    |   3 +-
 usrp2/host/lib/transport.h                |   4 +-
 usrp2/host/lib/usrp2_impl.cc              | 144 +-----------------------------
 usrp2/host/lib/usrp2_impl.h               |  28 ------
 7 files changed, 15 insertions(+), 188 deletions(-)

diff --git a/usrp2/firmware/include/usrp2_eth_packet.h 
b/usrp2/firmware/include/usrp2_eth_packet.h
index a56a1d0..ae66ddc 100644
--- a/usrp2/firmware/include/usrp2_eth_packet.h
+++ b/usrp2/firmware/include/usrp2_eth_packet.h
@@ -134,6 +134,14 @@ u2p_set_timestamp(u2_fixed_hdr_t *p, uint32_t ts)
 }
 
 /*!
+ * \brief consolidated packet: ethernet header + transport header
+ */
+typedef struct {
+  u2_eth_hdr_t         ehdr;
+  u2_transport_hdr_t   thdr;
+} u2_eth_packet_only_t;
+
+/*!
  * \brief consolidated packet: ethernet header + transport header + fixed 
header
  */
 typedef struct {
diff --git a/usrp2/host/lib/eth_ctrl_transport.cc 
b/usrp2/host/lib/eth_ctrl_transport.cc
index cc0f89d..a8bf3e3 100644
--- a/usrp2/host/lib/eth_ctrl_transport.cc
+++ b/usrp2/host/lib/eth_ctrl_transport.cc
@@ -37,14 +37,6 @@ usrp2::eth_ctrl_transport::~eth_ctrl_transport(){
     delete d_eth_ctrl;
 }
 
-//FIXME clean this up, probably when we get vrt headers
-//eth transport is only responsible for eth headers and transport headers
-//that leaves the u2 fixed headers to be handled by the usrp2 impl
-typedef struct {
-  u2_eth_hdr_t         ehdr;
-  u2_transport_hdr_t   thdr;
-} u2_eth_packet_only_t;
-
 int usrp2::eth_ctrl_transport::sendv(const iovec *iov, size_t iovlen){
     //create a new iov array with a space for ethernet header and padding
     // and move the current iovs to the center of the new array
diff --git a/usrp2/host/lib/eth_data_transport.cc 
b/usrp2/host/lib/eth_data_transport.cc
index 81a41c3..6286bfe 100644
--- a/usrp2/host/lib/eth_data_transport.cc
+++ b/usrp2/host/lib/eth_data_transport.cc
@@ -48,14 +48,6 @@ void usrp2::eth_data_transport::init(){
         std::cerr << "usrp2: failed to enable realtime scheduling" << 
std::endl;
 }
 
-//FIXME clean this up, probably when we get vrt headers
-//eth transport is only responsible for eth headers and transport headers
-//that leaves the u2 fixed headers to be handled by the usrp2 impl
-typedef struct {
-  u2_eth_hdr_t         ehdr;
-  u2_transport_hdr_t   thdr;
-} u2_eth_packet_only_t;
-
 int 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
diff --git a/usrp2/host/lib/sbuff.h b/usrp2/host/lib/sbuff.h
index bc6cb42..dc5912a 100644
--- a/usrp2/host/lib/sbuff.h
+++ b/usrp2/host/lib/sbuff.h
@@ -64,11 +64,10 @@ namespace usrp2 {
         }
         sbuff(void *buff, size_t len, cb_t cb)
          : d_buff(buff), d_len(len), d_cb(cb){}
-        ~sbuff(){done();}
+        ~sbuff(){if (d_cb) d_cb();}
         //access methods
         void *buff(){return d_buff;}
         size_t len(){return d_len;}
-        void done(){if (d_cb) d_cb();}
 
     };
 
diff --git a/usrp2/host/lib/transport.h b/usrp2/host/lib/transport.h
index a9c239a..154fe47 100644
--- a/usrp2/host/lib/transport.h
+++ b/usrp2/host/lib/transport.h
@@ -71,8 +71,8 @@ namespace usrp2 {
      */
     virtual int sendv(const iovec *iov, size_t iovlen);
     /*!
-     * \brief receive data into the sbuffer (override in a subclass)
-     * \return a new sbuff, for now, an empty sbuff means nothing was recvd
+     * \brief receive data, possibly multiple buffers (override in a subclass)
+     * \return a new vector of sbuffs, an empty vector is no data
      */
     virtual std::vector<sbuff::sptr> recv();
   };
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index c16ad89..203afac 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -122,19 +122,8 @@ namespace usrp2 {
   }
 
 
-  usrp2::impl::impl(transport::sptr data_transport, transport::sptr 
ctrl_transport, size_t ring_size)
-    : //d_eth_data(new eth_buffer(rx_bufsize)),
-      //d_eth_ctrl(new ethernet()),
-      //d_pf_data(0), 
-      //d_pf_ctrl(0),
-      //d_interface_name(ifc),
-      //d_rx_seqno(-1),
-      //d_tx_seqno(0),
+  usrp2::impl::impl(transport::sptr data_transport, transport::sptr 
ctrl_transport, size_t ring_size) :
       d_next_rid(0),
-      //d_num_rx_frames(0),
-      //d_num_rx_missing(0),
-      //d_num_rx_overruns(0),
-      //d_num_rx_bytes(0), 
       d_num_enqueued(0),
       d_enqueued_mutex(),
       d_data_pending_cond(),
@@ -142,7 +131,6 @@ namespace usrp2 {
       d_tx_interp(0),
       d_rx_decim(0),
       d_dont_enqueue(true),
-      //d_data_running(false),
       d_ctrl_transport(ctrl_transport),
       d_data_transport(data_transport),
       d_ring_size(ring_size)
@@ -153,25 +141,6 @@ namespace usrp2 {
     
d_data_transport->set_callback(boost::bind(&usrp2::impl::handle_data_packet, 
this, _1));
     d_data_transport->start();
 
-    //if (!d_eth_data->open(ifc, htons(U2_DATA_ETHERTYPE)))
-    //  throw std::runtime_error("Unable to open/register USRP2 data 
protocol");
-
-    //d_addr = p->addr;
-
-    // Create a packet filter for U2_DATA_ETHERTYPE packets sourced from 
target USRP2
-    /*u2_mac_addr_t usrp_mac;
-    parse_mac_addr(d_addr, &usrp_mac);
-    d_pf_data = pktfilter::make_ethertype_inbound_target(U2_DATA_ETHERTYPE, 
(const unsigned char*)&(usrp_mac.addr));
-    if (!d_pf_data || !d_eth_data->attach_pktfilter(d_pf_data))
-      throw std::runtime_error("Unable to attach packet filter for data 
packets.");
-    
-    if (USRP2_IMPL_DEBUG)
-      std::cerr << "usrp2 constructor: using USRP2 at " << d_addr << std::endl;
-
-    
-
-    start_data_thread();*/
-
     memset(d_pending_replies, 0, sizeof(d_pending_replies));
 
     // In case the USRP2 was left streaming RX
@@ -228,49 +197,8 @@ namespace usrp2 {
   {
     d_ctrl_transport->stop();
     d_data_transport->stop();
-    /*//thread cleanup
-    stop_data_thread();
-    //socket cleanup
-    delete d_pf_data;
-    d_eth_data->close();
-    delete d_eth_data;*/
-
-    /*if (USRP2_IMPL_DEBUG) {
-      std::cerr << std::endl
-                << "usrp2 destructor: received " << d_num_rx_frames 
-               << " frames, with " << d_num_rx_missing << " lost ("
-               << (d_num_rx_frames == 0 ? 0 : 
(int)(100.0*d_num_rx_missing/d_num_rx_frames))
-               << "%), totaling " << d_num_rx_bytes
-               << " bytes" << std::endl;
-    }*/
   }
   
-  /*bool
-  usrp2::impl::parse_mac_addr(const std::string &s, u2_mac_addr_t *p)
-  {
-    p->addr[0] = 0x00;         // Matt's IAB
-    p->addr[1] = 0x50;
-    p->addr[2] = 0xC2;
-    p->addr[3] = 0x85;
-    p->addr[4] = 0x30;
-    p->addr[5] = 0x00;
-    
-    int len = s.size();
-    
-    switch (len){
-      
-    case 5:
-      return sscanf(s.c_str(), "%hhx:%hhx", &p->addr[4], &p->addr[5]) == 2;
-      
-    case 17:
-      return sscanf(s.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
-                   &p->addr[0], &p->addr[1], &p->addr[2],
-                   &p->addr[3], &p->addr[4], &p->addr[5]) == 6;
-    default:
-      return false;
-    }
-  }*/
-  
   void
   usrp2::impl::init_fx_data_hdrs(u2_fixed_hdr_t *p, int word0_flags, int chan, 
uint32_t timestamp)
   {
@@ -333,63 +261,6 @@ namespace usrp2 {
     return res == 1;
   }
 
-  // ----------------------------------------------------------------
-  //        Background loop for handling data packets
-  // ----------------------------------------------------------------
-
- /* void
-  usrp2::impl::start_data_thread(){
-    d_data_thread = new 
boost::thread(boost::bind(&usrp2::impl::run_data_thread, this));
-  }
-
-  void
-  usrp2::impl::stop_data_thread()
-  {
-    d_data_running = false;
-    d_data_pending_cond.notify_one();
-    d_data_thread->join();
-  }
-  
-  void
-  usrp2::impl::run_data_thread()
-  {
-    boost::this_thread::disable_interruption di;
-    if (gruel::enable_realtime_scheduling(gruel::sys_pri::usrp2_backend()) != 
gruel::RT_OK)
-      std::cerr << "usrp2: failed to enable realtime scheduling" << std::endl;
-    d_data_running = true;
-    while(d_data_running) {
-      DEBUG_LOG(":");
-      // Receive available frames from ethernet buffer.  Handler will
-      // process control frames, enqueue data packets in channel
-      // rings, and signal blocked API threads
-      int res = d_eth_data->rx_frames(this, 100); // FIXME magic timeout
-      if (res == eth_buffer::EB_ERROR)
-       break;  
-
-      // Wait for user API thread(s) to process all enqueued packets.
-      // The channel ring thread that decrements d_num_enqueued to zero 
-      // will signal this thread to continue.
-      {
-        gruel::scoped_lock l(d_enqueued_mutex);
-        while(d_num_enqueued > 0 && d_data_running)
-         d_data_pending_cond.wait(l);
-      }
-    }
-    d_data_running = false;
-  }*/
-  
-  //
-  // passed to eth_buffer::rx_frames
-  //
-  /*data_handler::result
-  usrp2::impl::operator()(const void *base, size_t len)
-  {
-      if (d_dont_enqueue)              // toss packet
-        return data_handler::RELEASE;
-
-      //return handle_data_packet(base, len);
-  }*/
-
   void
   usrp2::impl::handle_control_packet(std::vector<sbuff::sptr> sbs)
   {    
@@ -431,12 +302,7 @@ namespace usrp2 {
   void
   usrp2::impl::handle_data_packet(std::vector<sbuff::sptr> sbs)
   {
-    if (d_dont_enqueue){
-        for (size_t i = 0; i < sbs.size(); i++) {
-            sbs[i]->done();
-        }
-        return;
-    }
+    if (d_dont_enqueue) return;
 
     for (size_t i = 0; i < sbs.size(); i++) {
         sbuff::sptr sb = sbs[i];
@@ -452,7 +318,6 @@ namespace usrp2 {
 
             if (!d_channel_rings[chan]) {
                 DEBUG_LOG("!");
-                sb->done();
                 continue;      // discard packet, no channel handler
             }
 
@@ -461,7 +326,6 @@ namespace usrp2 {
                 DEBUG_LOG("+");
             } else {
                 DEBUG_LOG("!");
-                sb->done();
                 continue;     //discard packet, enqueue failed
             }
         }
@@ -738,7 +602,7 @@ namespace usrp2 {
 
       bool want_more = (*handler)(items, nitems_in_uint32s, &md);
       DEBUG_LOG("-");
-      sb->done(); //make done to call cleanup callback
+      sb.reset(); //reset to call cleanup callback
       dec_enqueued();
 
       if (!want_more)
@@ -770,7 +634,7 @@ namespace usrp2 {
     // Iterate through frames and drop them
     sbuff::sptr sb;
     while (rp->dequeue(&sb)) {
-      sb->done(); //make done to call cleanup callback
+      sb.reset(); //reset to call cleanup callback
       dec_enqueued();
     }
     return true;
diff --git a/usrp2/host/lib/usrp2_impl.h b/usrp2/host/lib/usrp2_impl.h
index 1ec288b..71aafd9 100644
--- a/usrp2/host/lib/usrp2_impl.h
+++ b/usrp2/host/lib/usrp2_impl.h
@@ -60,21 +60,7 @@ namespace usrp2 {
     static const size_t NRIDS = 256;
     static const size_t NCHANS = 32;
 
-    /*eth_buffer    *d_eth_data;       // packet ring buffered data frames
-    ethernet      *d_eth_ctrl;  // unbuffered control frames
-    pktfilter     *d_pf_data;
-    pktfilter     *d_pf_ctrl;*/
-
-    /*std::string    d_interface_name;
-    std::string    d_addr;       // FIXME: use u2_mac_addr_t instead*/
-    
-    /*int            d_rx_seqno;
-    int            d_tx_seqno;*/
     int            d_next_rid;
-    /*unsigned int   d_num_rx_frames; //TODO remove this stuff, its in 
transport data
-    unsigned int   d_num_rx_missing;
-    unsigned int   d_num_rx_overruns;
-    unsigned int   d_num_rx_bytes;*/
 
     unsigned int   d_num_enqueued;
     gruel::mutex   d_enqueued_mutex;
@@ -105,26 +91,17 @@ namespace usrp2 {
         d_data_pending_cond.notify_one();
     }
     
-    //static bool parse_mac_addr(const std::string &s, u2_mac_addr_t *p);
     void init_fx_data_hdrs(u2_fixed_hdr_t *p, int word0_flags, int chan, 
uint32_t timestamp);
     void init_op_ctrl_hdrs(op_fixed_hdr_t *p, int word0_flags, uint32_t 
timestamp);
     void init_config_rx_v2_cmd(op_config_rx_v2_cmd *cmd);
     void init_config_tx_v2_cmd(op_config_tx_v2_cmd *cmd);
     bool transmit_cmd_and_wait(void *cmd, size_t len, pending_reply *p, double 
secs=0.0);
     bool transmit_cmd(void *cmd, size_t len);
-    //virtual data_handler::result operator()(const void *base, size_t len);
     void handle_control_packet(std::vector<sbuff::sptr> sbs);
     void handle_data_packet(std::vector<sbuff::sptr> sbs);
     bool dboard_info();
     bool reset_db();
 
-    //data thread stuff
-   /* volatile bool d_data_running; // TODO: multistate if needed
-    boost::thread *d_data_thread;
-    void start_data_thread();
-    void stop_data_thread();
-    void run_data_thread();*/
-
     transport::sptr d_ctrl_transport;
     transport::sptr d_data_transport;
     size_t d_ring_size;
@@ -133,9 +110,6 @@ namespace usrp2 {
     impl(transport::sptr data_transport, transport::sptr ctrl_transport, 
size_t ring_size);
     ~impl();
 
-    //std::string mac_addr() const { return d_addr; } // FIXME: convert from 
u2_mac_addr_t
-    //std::string interface_name() const { return d_interface_name; }
-
     // Rx
 
     bool set_rx_gain(double gain);
@@ -158,8 +132,6 @@ namespace usrp2 {
     bool rx_samples(unsigned int channel, rx_sample_handler *handler);
     bool flush_rx_samples(unsigned int channel);
     bool stop_rx_streaming(unsigned int channel);
-    //unsigned int rx_overruns() const { return d_num_rx_overruns; }
-    //unsigned int rx_missing() const { return d_num_rx_missing; }
 
     // Tx
 



reply via email to

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