diff options
author | Josh Blum <josh@joshknows.com> | 2010-10-11 18:09:56 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-10-11 18:09:56 -0700 |
commit | 1314feb429b8c2713d9fd0e9da077825d0a9c3bc (patch) | |
tree | a5ba6e1396fe0f444f6e0f1287f8740deecf9da6 /host | |
parent | 453b450aa2f40f1ab3689855654fd2167f554ccc (diff) | |
download | uhd-1314feb429b8c2713d9fd0e9da077825d0a9c3bc.tar.gz uhd-1314feb429b8c2713d9fd0e9da077825d0a9c3bc.tar.bz2 uhd-1314feb429b8c2713d9fd0e9da077825d0a9c3bc.zip |
usrp2: use 32-bit flow control sequence numbers
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/types/metadata.hpp | 4 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/fw_common.h | 2 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/io_impl.cpp | 29 |
3 files changed, 15 insertions, 20 deletions
diff --git a/host/include/uhd/types/metadata.hpp b/host/include/uhd/types/metadata.hpp index 65952941c..96c4ad0d3 100644 --- a/host/include/uhd/types/metadata.hpp +++ b/host/include/uhd/types/metadata.hpp @@ -130,7 +130,7 @@ namespace uhd{ /*! * Event codes: - * - success: a packet was successfully transmitted + * - eob ack: an eob packet was successfully transmitted * - underflow: an internal send buffer has emptied * - sequence error: packet loss between host and device * - time error: packet had time that was late (or too early) @@ -138,7 +138,7 @@ namespace uhd{ * - sequence error in burst: packet loss within a burst */ enum event_code_t { - EVENT_CODE_SUCCESS = 0x1, + EVENT_CODE_EOB_ACK = 0x1, EVENT_CODE_UNDERFLOW = 0x2, EVENT_CODE_SEQ_ERROR = 0x4, EVENT_CODE_TIME_ERROR = 0x8, diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h index 783e5c772..2cd3ee595 100644 --- a/host/lib/usrp/usrp2/fw_common.h +++ b/host/lib/usrp/usrp2/fw_common.h @@ -33,7 +33,7 @@ extern "C" { #endif //fpga and firmware compatibility numbers -#define USRP2_FPGA_COMPAT_NUM 2 +#define USRP2_FPGA_COMPAT_NUM 3 #define USRP2_FW_COMPAT_NUM 7 //used to differentiate control packets over data port diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index 6d5eb488c..2d1ebe57b 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -49,13 +49,14 @@ static const size_t vrt_send_header_offset_words32 = 1; **********************************************************************/ class flow_control_monitor{ public: + typedef boost::uint32_t seq_type; typedef boost::shared_ptr<flow_control_monitor> sptr; /*! * Make a new flow control monitor. * \param max_seqs_out num seqs before throttling */ - flow_control_monitor(size_t max_seqs_out){ + flow_control_monitor(seq_type max_seqs_out){ _last_seq_out = 0; _last_seq_ack = 0; _max_seqs_out = max_seqs_out; @@ -67,7 +68,7 @@ public: * \param timeout the timeout in seconds * \return false on timeout */ - UHD_INLINE bool check_fc_condition(boost::uint16_t seq, double timeout){ + UHD_INLINE bool check_fc_condition(seq_type seq, double timeout){ boost::unique_lock<boost::mutex> lock(_fc_mutex); _last_seq_out = seq; return _fc_cond.timed_wait( @@ -81,7 +82,7 @@ public: * Update the flow control condition. * \param seq the last sequence number to be ACK'd */ - UHD_INLINE void update_fc_condition(boost::uint16_t seq){ + UHD_INLINE void update_fc_condition(seq_type seq){ boost::unique_lock<boost::mutex> lock(_fc_mutex); _last_seq_ack = seq; lock.unlock(); @@ -90,17 +91,12 @@ public: private: bool ready(void){ - //return true; - //std::cout << "_last_seq_out " << _last_seq_out << std::endl; - //std::cout << "_last_seq_ack " << _last_seq_ack << std::endl; - //std::cout << "boost::uint16_t(_last_seq_out -_last_seq_ack) " << boost::uint16_t(_last_seq_out -_last_seq_ack) << std::endl; - return boost::uint16_t(_last_seq_out -_last_seq_ack) < boost::uint16_t(_max_seqs_out); + return seq_type(_last_seq_out -_last_seq_ack) < _max_seqs_out; } boost::mutex _fc_mutex; boost::condition _fc_cond; - boost::uint16_t _last_seq_out, _last_seq_ack; - size_t _max_seqs_out; + seq_type _last_seq_out, _last_seq_ack, _max_seqs_out; }; /*********************************************************************** @@ -141,16 +137,15 @@ struct usrp2_impl::io_impl{ ){ UHD_ASSERT_THROW(trans.size() == buffs.size()); - //calculate the 16-bit sequence number for the special header - const boost::uint16_t seq_num = boost::uint16_t(packet_handler_send_state.next_packet_seq & 0xffff); - const boost::uint32_t fc_word32 = uhd::htonx(boost::uint32_t(seq_num)); + //calculate the flow control word + const boost::uint32_t fc_word32 = packet_handler_send_state.next_packet_seq; //grab a managed buffer for each index for (size_t i = 0; i < buffs.size(); i++){ - if (not fc_mons[i]->check_fc_condition(seq_num, timeout)) return false; + if (not fc_mons[i]->check_fc_condition(fc_word32, timeout)) return false; buffs[i] = trans[i]->get_send_buff(timeout); if (not buffs[i].get()) return false; - buffs[i]->cast<boost::uint32_t *>()[0] = fc_word32; + buffs[i]->cast<boost::uint32_t *>()[0] = uhd::htonx(fc_word32); } return true; } @@ -209,8 +204,8 @@ void usrp2_impl::io_impl::recv_pirate_loop( //catch the flow control packets and react if (metadata.event_code == 0){ - boost::uint32_t fc_word32 = uhd::ntohx((vrt_hdr + if_packet_info.num_header_words32)[1]); - this->fc_mons[index]->update_fc_condition(fc_word32 & 0xffff); + boost::uint32_t fc_word32 = (vrt_hdr + if_packet_info.num_header_words32)[1]; + this->fc_mons[index]->update_fc_condition(uhd::ntohx(fc_word32)); continue; } |