aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--firmware/microblaze/apps/txrx.c28
-rw-r--r--firmware/microblaze/lib/net_common.c11
-rw-r--r--firmware/microblaze/lib/net_common.h1
-rw-r--r--host/lib/usrp/usrp2/dsp_impl.cpp7
-rw-r--r--host/lib/usrp/usrp2/io_impl.cpp11
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.hpp7
6 files changed, 41 insertions, 24 deletions
diff --git a/firmware/microblaze/apps/txrx.c b/firmware/microblaze/apps/txrx.c
index e4e40e7e0..9c3caa4f2 100644
--- a/firmware/microblaze/apps/txrx.c
+++ b/firmware/microblaze/apps/txrx.c
@@ -158,19 +158,10 @@ static struct ip_addr get_my_ip_addr(void){
return addr;
}
-static bool _is_data;
-
void handle_udp_data_packet(
struct socket_address src, struct socket_address dst,
unsigned char *payload, int payload_len
){
- //forward this data to the dsp when the payload is sufficient
- //the small payload is used to give the device the udp source port
- if (payload_len > sizeof(uint32_t)){
- _is_data = true;
- return;
- }
-
//its a tiny payload, load the fast-path variables
fp_mac_addr_src = get_my_eth_mac_addr();
arp_cache_lookup_mac(&src.addr, &fp_mac_addr_dst);
@@ -513,9 +504,18 @@ void handle_udp_ctrl_packet(
static bool
eth_pkt_inspector(dbsm_t *sm, int bufno)
{
- _is_data = false;
- handle_eth_packet(buffer_ram(bufno), buffer_pool_status->last_line[bufno] - 3);
- return !_is_data;
+ //extract buffer point and length
+ uint32_t *buff = (uint32_t *)buffer_ram(bufno);
+ size_t len = buffer_pool_status->last_line[bufno] - 3;
+
+ //treat this as fast-path data?
+ if (is_udp_packet_with_vrt(buff, len, USRP2_UDP_DATA_PORT)){
+ return false;
+ }
+
+ //pass it to the slow-path handler
+ handle_eth_packet(buff, len);
+ return true;
}
//------------------------------------------------------------------
@@ -751,6 +751,10 @@ main(void)
// tell app_common that this dbsm could be sending to the ethernet
ac_could_be_sending_to_eth = &dsp_rx_sm;
+ sr_tx_ctrl->clear_state = 1;
+ bp_clear_buf(DSP_TX_BUF_0);
+ bp_clear_buf(DSP_TX_BUF_1);
+
// kick off the state machine
dbsm_start(&dsp_tx_sm);
diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c
index 693502d18..ab7aadca9 100644
--- a/firmware/microblaze/lib/net_common.c
+++ b/firmware/microblaze/lib/net_common.c
@@ -378,6 +378,17 @@ handle_arp_packet(struct arp_eth_ipv4 *p, size_t size)
}
}
+bool is_udp_packet_with_vrt(uint32_t *p, size_t nlines, int port){
+ struct ip_hdr *ip = (struct ip_hdr *)(p + 4);
+ struct udp_hdr *udp = (struct udp_hdr *)(((char *)ip) + IP_HLEN);
+ uint32_t *payload = (uint32_t *)(((char *)udp) + UDP_HLEN);
+ return \
+ (p[3] & 0xffff) == ETHERTYPE_IPV4 &&
+ IPH_PROTO(ip) == IP_PROTO_UDP &&
+ udp->dest == port &&
+ payload[0] != 0; //must be non zero vrt header
+}
+
void
handle_eth_packet(uint32_t *p, size_t nlines)
{
diff --git a/firmware/microblaze/lib/net_common.h b/firmware/microblaze/lib/net_common.h
index cfba43412..1a7052f71 100644
--- a/firmware/microblaze/lib/net_common.h
+++ b/firmware/microblaze/lib/net_common.h
@@ -56,5 +56,6 @@ void send_udp_pkt(int src_port, struct socket_address dst,
void handle_eth_packet(uint32_t *p, size_t nlines);
+bool is_udp_packet_with_vrt(uint32_t *p, size_t nlines, int port);
#endif /* INCLUDED_NET_COMMON_H */
diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp
index a57f5ff2d..8fdfd685f 100644
--- a/host/lib/usrp/usrp2/dsp_impl.cpp
+++ b/host/lib/usrp/usrp2/dsp_impl.cpp
@@ -82,12 +82,7 @@ void usrp2_impl::update_ddc_enabled(void){
out_data.data.streaming.enabled = (_ddc_enabled)? 1 : 0;
out_data.data.streaming.secs = htonl(_ddc_stream_at.secs);
out_data.data.streaming.ticks = htonl(_ddc_stream_at.ticks);
- out_data.data.streaming.samples = htonl(
- _mtu/sizeof(uint32_t) -
- USRP2_HOST_RX_VRT_HEADER_WORDS32 -
- USRP2_HOST_RX_VRT_TRAILER_WORDS32 -
- ((2 + 14 + 20 + 8)/sizeof(uint32_t)) //size of headers (pad, eth, ip, udp)
- );
+ out_data.data.streaming.samples = htonl(_max_samples_per_packet);
//send and recv
usrp2_ctrl_data_t in_data = ctrl_send_and_recv(out_data);
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp
index 8b45a708a..0ca2409c3 100644
--- a/host/lib/usrp/usrp2/io_impl.cpp
+++ b/host/lib/usrp/usrp2/io_impl.cpp
@@ -127,12 +127,11 @@ size_t usrp2_impl::send_raw(
}
vrt_hdr_flags |= (metadata.start_of_burst)? (0x1 << 25) : 0;
vrt_hdr_flags |= (metadata.end_of_burst)? (0x1 << 24) : 0;
- num_vrt_hdr_words += asio::buffer_size(buff)/sizeof(uint32_t);
//fill in complete header word
vrt_hdr[0] = htonl(vrt_hdr_flags |
((_tx_stream_id_to_packet_seq[metadata.stream_id]++ & 0xf) << 16) |
- (num_vrt_hdr_words & 0xffff)
+ ((num_vrt_hdr_words + asio::buffer_size(buff)/sizeof(uint32_t)) & 0xffff)
);
//load the buffer vector
@@ -151,6 +150,8 @@ size_t usrp2_impl::recv_raw(
const boost::asio::mutable_buffer &buff,
uhd::metadata_t &metadata
){
+ metadata = metadata_t(); //clear metadata
+
//handle the case where there is spillover
if (asio::buffer_size(_splillover_buff) != 0){
size_t bytes_to_copy = std::min(
@@ -198,9 +199,9 @@ size_t usrp2_impl::recv_raw(
_rx_stream_id_to_packet_seq[metadata.stream_id] = my_seq;
//extract the number of bytes received
- size_t num_words = (vrt_header & 0xffff);
- num_words -= USRP2_HOST_RX_VRT_HEADER_WORDS32;
- num_words -= USRP2_HOST_RX_VRT_TRAILER_WORDS32;
+ size_t num_words = (vrt_header & 0xffff) -
+ USRP2_HOST_RX_VRT_HEADER_WORDS32 -
+ USRP2_HOST_RX_VRT_TRAILER_WORDS32;
size_t num_bytes = num_words*sizeof(uint32_t);
//handle the case where spillover memory was used
diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp
index 43f32c6e6..037aed477 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.hpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.hpp
@@ -108,7 +108,12 @@ private:
uhd::dict<uint32_t, size_t> _tx_stream_id_to_packet_seq;
uhd::dict<uint32_t, size_t> _rx_stream_id_to_packet_seq;
static const size_t _mtu = 1500; //FIXME we have no idea
- static const size_t _max_samples_per_packet = _mtu/sizeof(uint32_t);
+ static const size_t _max_samples_per_packet =
+ _mtu/sizeof(uint32_t) -
+ USRP2_HOST_RX_VRT_HEADER_WORDS32 -
+ USRP2_HOST_RX_VRT_TRAILER_WORDS32 -
+ ((2 + 14 + 20 + 8)/sizeof(uint32_t)) //size of headers (pad, eth, ip, udp)
+ ;
uint32_t _tmp_send_mem[_mtu/sizeof(uint32_t)];
uint32_t _tmp_recv_mem[_mtu/sizeof(uint32_t)];
uint32_t _spillover_mem[_mtu/sizeof(uint32_t)];