diff options
| -rw-r--r-- | firmware/microblaze/apps/txrx_uhd.c | 4 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/fw_common.h | 8 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/usrp2_iface.cpp | 2 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.cpp | 4 | ||||
| -rw-r--r-- | host/lib/usrp/usrp2/usrp2_impl.hpp | 6 | 
5 files changed, 13 insertions, 11 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index 7ad4ab110..45e5ff5fe 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -100,7 +100,7 @@ typedef struct{  #define MK_RX_CTRL_WORD(num_words) (((num_words)*sizeof(uint32_t)) | (1 << 16))  // DSP Rx writes ethernet header words -#define DSP_RX_FIRST_LINE 1 //1 = number of control words (see above) +#define DSP_RX_FIRST_LINE ((offsetof(rx_dsp_buff_t, vrt_header))/sizeof(uint32_t))  // receive from DSP  buf_cmd_args_t dsp_rx_recv_args = { @@ -423,7 +423,7 @@ 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]-1; +  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); diff --git a/host/lib/usrp/usrp2/fw_common.h b/host/lib/usrp/usrp2/fw_common.h index 75f5b1779..242d268ec 100644 --- a/host/lib/usrp/usrp2/fw_common.h +++ b/host/lib/usrp/usrp2/fw_common.h @@ -32,9 +32,13 @@ extern "C" {  #define _SINS_  #endif +// define limits on bytes per udp packet +#define USRP2_MTU_BYTES 1500 +#define USRP2_UDP_BYTES ((USRP2_MTU_BYTES) - (2 + 14 + 20 + 8)) //size of headers (pad, eth, ip, udp) +  //defines the protocol version in this shared header  //increment this value when the protocol is changed -#define USRP2_PROTO_VERSION 3 +#define USRP2_PROTO_VERSION 4  //used to differentiate control packets over data port  #define USRP2_INVALID_VRT_HEADER 0 @@ -102,7 +106,7 @@ typedef struct{          struct {              _SINS_ uint8_t addr;              _SINS_ uint8_t bytes; -            _SINS_ uint8_t data[sizeof(_SINS_ uint32_t)]; +            _SINS_ uint8_t data[20];          } i2c_args;          struct {              _SINS_ uint32_t addr; diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index 6e0d3266a..83e98904e 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -146,7 +146,7 @@ public:          _ctrl_transport->send(boost::asio::buffer(&out_copy, sizeof(usrp2_ctrl_data_t)));          //loop until we get the packet or timeout -        boost::uint8_t usrp2_ctrl_data_in_mem[1500]; //allocate MTU bytes for recv +        boost::uint8_t usrp2_ctrl_data_in_mem[USRP2_UDP_BYTES]; //allocate max bytes for recv          usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<usrp2_ctrl_data_t *>(usrp2_ctrl_data_in_mem);          while(true){              size_t len = _ctrl_transport->recv(boost::asio::buffer(usrp2_ctrl_data_in_mem)); diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp index 0837f4ac4..36c264c3c 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.cpp +++ b/host/lib/usrp/usrp2/usrp2_impl.cpp @@ -79,12 +79,12 @@ uhd::device_addrs_t usrp2::find(const device_addr_t &hint){      udp_transport->send(boost::asio::buffer(&ctrl_data_out, sizeof(ctrl_data_out)));      //loop and recieve until the timeout -    boost::uint8_t usrp2_ctrl_data_in_mem[1500]; //allocate MTU bytes for recv +    boost::uint8_t usrp2_ctrl_data_in_mem[USRP2_UDP_BYTES]; //allocate max bytes for recv      usrp2_ctrl_data_t *ctrl_data_in = reinterpret_cast<usrp2_ctrl_data_t *>(usrp2_ctrl_data_in_mem);      while(true){          size_t len = udp_transport->recv(asio::buffer(usrp2_ctrl_data_in_mem));          //std::cout << len << "\n"; -        if (len >= sizeof(usrp2_ctrl_data_t)){ +        if (len > offsetof(usrp2_ctrl_data_t, data)){              //handle the received data              switch(ntohl(ctrl_data_in->id)){              case USRP2_CTRL_ID_WAZZUP_DUDE: diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp index ccc09003e..2126b9565 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.hpp +++ b/host/lib/usrp/usrp2/usrp2_impl.hpp @@ -141,15 +141,13 @@ private:      /*******************************************************************       * Deal with the rx and tx packet sizes       ******************************************************************/ -    static const size_t _mtu = 1500; //FIXME we have no idea -    static const size_t _hdrs = (2 + 14 + 20 + 8); //size of headers (pad, eth, ip, udp)      static const size_t _max_rx_bytes_per_packet = -        _mtu - _hdrs - +        USRP2_UDP_BYTES -          USRP2_HOST_RX_VRT_HEADER_WORDS32*sizeof(boost::uint32_t) -          USRP2_HOST_RX_VRT_TRAILER_WORDS32*sizeof(boost::uint32_t)      ;      static const size_t _max_tx_bytes_per_packet = -        _mtu - _hdrs - +        USRP2_UDP_BYTES -          uhd::transport::vrt::max_header_words32*sizeof(boost::uint32_t)      ;  | 
