diff options
-rw-r--r-- | firmware/microblaze/apps/txrx_uhd.c | 34 | ||||
-rwxr-xr-x | host/lib/transport/gen_vrt_if_packet.py | 6 | ||||
-rw-r--r-- | host/lib/transport/vrt_packet_handler.hpp | 3 | ||||
-rw-r--r-- | host/lib/usrp/dsp_utils.hpp | 6 |
4 files changed, 17 insertions, 32 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 99c149d45..b81d32b2d 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -92,15 +92,10 @@ dbsm_t dsp_tx_sm; // the state machine * ================================================================ */ -typedef struct{ - uint32_t control_word; - uint32_t vrt_header[]; -} rx_dsp_buff_t; - -#define MK_RX_CTRL_WORD(num_words) (((num_words)*sizeof(uint32_t)) | (1 << 16)) +static const uint32_t rx_ctrl_word = 1 << 16; // DSP Rx writes ethernet header words -#define DSP_RX_FIRST_LINE ((offsetof(rx_dsp_buff_t, vrt_header))/sizeof(uint32_t)) +#define DSP_RX_FIRST_LINE sizeof(rx_ctrl_word)/sizeof(uint32_t) // receive from DSP buf_cmd_args_t dsp_rx_recv_args = { @@ -423,22 +418,6 @@ static void setup_network(void){ sr_udp_sm->udp_hdr.checksum = UDP_SM_LAST_WORD; // zero UDP checksum } -/* - * This is called when the DSP Rx chain has filled in a packet. - */ -bool -fw_sets_seqno_inspector(dbsm_t *sm, int buf_this) // returns false -{ - // insert the correct length into the control word and vrt header - rx_dsp_buff_t *buff = (rx_dsp_buff_t*)buffer_ram(buf_this); - size_t vrt_len = buffer_pool_status->last_line[buf_this]-DSP_RX_FIRST_LINE; - buff->control_word = MK_RX_CTRL_WORD(vrt_len); - buff->vrt_header[0] = (buff->vrt_header[0] & ~VRTH_PKT_SIZE_MASK) | (vrt_len & VRTH_PKT_SIZE_MASK); - - return false; // we didn't handle the packet -} - - inline static void buffer_irq_handler(unsigned irq) { @@ -479,16 +458,15 @@ main(void) dbsm_init(&dsp_rx_sm, DSP_RX_BUF_0, &dsp_rx_recv_args, &dsp_rx_send_args, - fw_sets_seqno_inspector); - - - // tell app_common that this dbsm could be sending to the ethernet - ac_could_be_sending_to_eth = &dsp_rx_sm; + dbsm_nop_inspector); sr_tx_ctrl->clear_state = 1; bp_clear_buf(DSP_TX_BUF_0); bp_clear_buf(DSP_TX_BUF_1); + buffer_ram(DSP_RX_BUF_0)[0] = rx_ctrl_word; + buffer_ram(DSP_RX_BUF_0)[1] = rx_ctrl_word; + // kick off the state machine dbsm_start(&dsp_tx_sm); diff --git a/host/lib/transport/gen_vrt_if_packet.py b/host/lib/transport/gen_vrt_if_packet.py index 7438f5ff4..dbe026ba3 100755 --- a/host/lib/transport/gen_vrt_if_packet.py +++ b/host/lib/transport/gen_vrt_if_packet.py @@ -141,11 +141,17 @@ void vrt::if_hdr_unpack_$(suffix)( ){ //extract vrt header boost::uint32_t vrt_hdr_word = $(XE_MACRO)(packet_buff[0]); + /* size_t packet_words32 = vrt_hdr_word & 0xffff; //failure case if (if_packet_info.num_packet_words32 < packet_words32) throw std::runtime_error("bad vrt header or packet fragment"); + */ + //Fix for short packets sent from the fpga: + // Use the num_packet_words32 passed in as input, + // and do not use the header bits which could be wrong. + size_t packet_words32 = if_packet_info.num_packet_words32; //extract fields from the header if_packet_info.packet_type = if_packet_info_t::packet_type_t(vrt_hdr_word >> 29); diff --git a/host/lib/transport/vrt_packet_handler.hpp b/host/lib/transport/vrt_packet_handler.hpp index fdcff24b8..bd76cbb8f 100644 --- a/host/lib/transport/vrt_packet_handler.hpp +++ b/host/lib/transport/vrt_packet_handler.hpp @@ -324,7 +324,8 @@ namespace vrt_packet_handler{ ); //commit the samples to the zero-copy interface - if (send_buffs[i]->commit(if_packet_info.num_packet_words32*sizeof(boost::uint32_t)) < ssize_t(num_samps)){ + size_t num_bytes_total = (vrt_header_offset_words32+if_packet_info.num_packet_words32)*sizeof(boost::uint32_t); + if (send_buffs[i]->commit(num_bytes_total) < ssize_t(num_bytes_total)){ std::cerr << "commit to send buffer returned less than commit size" << std::endl; } } diff --git a/host/lib/usrp/dsp_utils.hpp b/host/lib/usrp/dsp_utils.hpp index 3fd5f1811..13186f354 100644 --- a/host/lib/usrp/dsp_utils.hpp +++ b/host/lib/usrp/dsp_utils.hpp @@ -85,13 +85,13 @@ namespace dsp_type1{ UHD_ASSERT_THROW(std::abs(freq) < codec_rate/2.0); static const double scale_factor = std::pow(2.0, 32); - //calculate the freq register word - boost::uint32_t freq_word = boost::math::iround((freq / codec_rate) * scale_factor); + //calculate the freq register word (signed) + boost::int32_t freq_word = boost::math::iround((freq / codec_rate) * scale_factor); //update the actual frequency freq = (double(freq_word) / scale_factor) * codec_rate; - return freq_word; + return boost::uint32_t(freq_word); } /*! |