void xport_benchmarker::_initialize_chdr(zero_copy_if::sptr tx_transport,
    zero_copy_if::sptr rx_transport,
    uint32_t sid,
    vrt::if_packet_info_t& pkt_info)
{
    _tx_timeout = 0.5;
    _rx_timeout = 0.5;

    size_t frame_size = std::min(
        tx_transport->get_send_frame_size(), rx_transport->get_recv_frame_size());

    pkt_info.link_type           = vrt::if_packet_info_t::LINK_TYPE_CHDR;
    pkt_info.packet_type         = vrt::if_packet_info_t::PACKET_TYPE_DATA;
    pkt_info.num_packet_words32  = (frame_size / sizeof(uint32_t));
    pkt_info.num_payload_words32 = pkt_info.num_packet_words32 - 2;
    pkt_info.num_payload_bytes   = pkt_info.num_payload_words32 * sizeof(uint32_t);
    pkt_info.packet_count        = 0;
    pkt_info.sob                 = false;
    pkt_info.eob                 = false;
    pkt_info.sid                 = sid;
    pkt_info.has_sid             = true;
    pkt_info.has_cid             = false;
    pkt_info.has_tsi             = false;
    pkt_info.has_tsf             = false;
    pkt_info.has_tlr             = false;
}
Beispiel #2
0
/***********************************************************************
 * Receive Pirate Loop
 * - while raiding, loot for message packet
 * - update flow control condition count
 * - put async message packets into queue
 **********************************************************************/
void usrp2_impl::io_impl::recv_pirate_loop(
    zero_copy_if::sptr err_xport, size_t index
){
    set_thread_priority_safe();

    //store a reference to the flow control monitor (offset by max dsps)
    flow_control_monitor &fc_mon = *(this->fc_mons[index]);

    while (not boost::this_thread::interruption_requested()){
        managed_recv_buffer::sptr buff = err_xport->get_recv_buff();
        if (not buff.get()) continue; //ignore timeout/error buffers

        try{
            //extract the vrt header packet info
            vrt::if_packet_info_t if_packet_info;
            if_packet_info.num_packet_words32 = buff->size()/sizeof(boost::uint32_t);
            const boost::uint32_t *vrt_hdr = buff->cast<const boost::uint32_t *>();
            vrt::if_hdr_unpack_be(vrt_hdr, if_packet_info);

            //handle a tx async report message
            if (if_packet_info.sid == USRP2_TX_ASYNC_SID and if_packet_info.packet_type != vrt::if_packet_info_t::PACKET_TYPE_DATA){

                //fill in the async metadata
                async_metadata_t metadata;
                metadata.channel = index;
                metadata.has_time_spec = if_packet_info.has_tsi and if_packet_info.has_tsf;
                metadata.time_spec = time_spec_t(
                    time_t(if_packet_info.tsi), size_t(if_packet_info.tsf), tick_rate
                );
                metadata.event_code = async_metadata_t::event_code_t(sph::get_context_code(vrt_hdr, if_packet_info));

                //catch the flow control packets and react
                if (metadata.event_code == 0){
                    boost::uint32_t fc_word32 = (vrt_hdr + if_packet_info.num_header_words32)[1];
                    fc_mon.update_fc_condition(uhd::ntohx(fc_word32));
                    continue;
                }
                //else UHD_MSG(often) << "metadata.event_code " << metadata.event_code << std::endl;
                async_msg_fifo.push_with_pop_on_full(metadata);

                if (metadata.event_code &
                    ( async_metadata_t::EVENT_CODE_UNDERFLOW
                    | async_metadata_t::EVENT_CODE_UNDERFLOW_IN_PACKET)
                ) UHD_MSG(fastpath) << "U";
                else if (metadata.event_code &
                    ( async_metadata_t::EVENT_CODE_SEQ_ERROR
                    | async_metadata_t::EVENT_CODE_SEQ_ERROR_IN_BURST)
                ) UHD_MSG(fastpath) << "S";
                else if (metadata.event_code &
                    async_metadata_t::EVENT_CODE_TIME_ERROR
                ) UHD_MSG(fastpath) << "L";
            }
            else{
                //TODO unknown received packet, may want to print error...
            }
        }catch(const std::exception &e){
            UHD_MSG(error) << "Error in recv pirate loop: " << e.what() << std::endl;
        }
    }
}
Beispiel #3
0
 io_impl(zero_copy_if::sptr data_transport):
     data_transport(data_transport),
     curr_buff(offset_send_buffer(data_transport->get_send_buff())),
     omsb(boost::bind(&usrp1_impl::io_impl::commit_send_buff, this, _1, _2, _3))
 {
     /* NOP */
 }
Beispiel #4
0
/***********************************************************************
 * Receive Pirate Loop
 * - while raiding, loot for message packet
 * - update flow control condition count
 * - put async message packets into queue
 **********************************************************************/
void usrp2_impl::io_impl::recv_pirate_loop(
    zero_copy_if::sptr err_xport, size_t index
){
    set_thread_priority_safe();

    //store a reference to the flow control monitor (offset by max dsps)
    flow_control_monitor &fc_mon = *(this->fc_mons[index]);

    while (not boost::this_thread::interruption_requested()){
        managed_recv_buffer::sptr buff = err_xport->get_recv_buff();
        if (not buff.get()) continue; //ignore timeout/error buffers

        try{
            //extract the vrt header packet info
            vrt::if_packet_info_t if_packet_info;
            if_packet_info.num_packet_words32 = buff->size()/sizeof(uint32_t);
            const uint32_t *vrt_hdr = buff->cast<const uint32_t *>();
            vrt::if_hdr_unpack_be(vrt_hdr, if_packet_info);

            //handle a tx async report message
            if (if_packet_info.sid == USRP2_TX_ASYNC_SID and if_packet_info.packet_type != vrt::if_packet_info_t::PACKET_TYPE_DATA){

                //fill in the async metadata
                async_metadata_t metadata;
                load_metadata_from_buff(uhd::ntohx<uint32_t>, metadata, if_packet_info, vrt_hdr, tick_rate, index);

                //catch the flow control packets and react
                if (metadata.event_code == 0){
                    uint32_t fc_word32 = (vrt_hdr + if_packet_info.num_header_words32)[1];
                    fc_mon.update_fc_condition(uhd::ntohx(fc_word32));
                    continue;
                }
                //else UHD_MSG(often) << "metadata.event_code " << metadata.event_code << std::endl;
                async_msg_fifo.push_with_pop_on_full(metadata);

                standard_async_msg_prints(metadata);
            }
            else{
                //TODO unknown received packet, may want to print error...
            }
        }catch(const std::exception &e){
            UHD_MSG(error) << "Error in recv pirate loop: " << e.what() << std::endl;
        }
    }
}