aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2021-11-02 11:25:56 +0100
committerAaron Rossetto <aaron.rossetto@ni.com>2021-12-02 05:49:53 -0800
commit9f9c75ecd6e4a318dad5c378fbf260c8fd8c2922 (patch)
treec63b3439e6580e7f25ccaf142829bd5733d7f50a /host/tests
parent38825f4e562b1eda1129b0f02f82c0bf4cf77276 (diff)
downloaduhd-9f9c75ecd6e4a318dad5c378fbf260c8fd8c2922.tar.gz
uhd-9f9c75ecd6e4a318dad5c378fbf260c8fd8c2922.tar.bz2
uhd-9f9c75ecd6e4a318dad5c378fbf260c8fd8c2922.zip
rfnoc: Clarify usage of MTU vs. max payload size, remove DEFAULT_SPP
These two values where being mixed up in the code. To summarize: - The MTU is the max CHDR packet size, including header & timestamp. - The max payload is the total number of bytes regular payload plus metadata that can be fit into into a CHDR packet. It is strictly smaller than the MTU. For example, for 64-bit CHDR widths, if a timestamp is desired, the max payload is 16 bytes smaller than the MTU. The other issue was that we were using a magic constant (DEFAULT_SPP) which was causing conflicts with MTUs and max payloads. This constant was harmful in multiple ways: - The explanatory comment was incorrect (it stated it would cap packets to 1500 bytes, which it didn't) - It imposed random, hardcoded values that interfered with an 'spp discovery', i.e., the ability to derive a good spp value from MTUs - The current value capped packet sizes to 8000 bytes CHDR packets, even when we wanted to use bigger ones This patch changes the following: - noc_block_base now has improved docs for MTU, and additional APIs (get_max_payload_size(), get_chdr_hdr_len()) which return the current payload size given MTU and CHDR width, and the CHDR header length. - The internally used graph nodes for TX and RX streamers also get equipped with the same new two API calls. - The radio, siggen, and replay block all where doing different calculations for their spp/ipp values. Now, they all use the max payload value to calculate spp/ipp. Unit tests where adapted accordingly. Usage of DEFAULT_SPP was removed. - The replay block used a hardcoded 16 bytes for header lengths, which was replaced by get_chdr_hdr_len() - The TX and RX streamers where discarding the MTU value and using the max payload size as the MTU, which then propagated throughout the graph. Now, both values are stored and can be used where appropriate.
Diffstat (limited to 'host/tests')
-rw-r--r--host/tests/rfnoc_block_tests/replay_block_test.cpp18
-rw-r--r--host/tests/rfnoc_block_tests/siggen_block_test.cpp14
-rw-r--r--host/tests/rx_streamer_test.cpp12
-rw-r--r--host/tests/streamer_benchmark.cpp25
-rw-r--r--host/tests/tx_streamer_test.cpp13
5 files changed, 64 insertions, 18 deletions
diff --git a/host/tests/rfnoc_block_tests/replay_block_test.cpp b/host/tests/rfnoc_block_tests/replay_block_test.cpp
index f84b98ac8..db9f8c177 100644
--- a/host/tests/rfnoc_block_tests/replay_block_test.cpp
+++ b/host/tests/rfnoc_block_tests/replay_block_test.cpp
@@ -157,7 +157,7 @@ BOOST_FIXTURE_TEST_CASE(replay_test_construction, replay_block_fixture)
BOOST_CHECK_EQUAL(reg_iface->write_memory[reg_play_base_addr], 0);
BOOST_CHECK_EQUAL(reg_iface->write_memory[reg_play_base_addr + 4], 0);
BOOST_CHECK_EQUAL(reg_iface->write_memory[reg_words_per_pkt],
- (DEFAULT_MTU - CHDR_MAX_LEN_HDR) / word_size);
+ (DEFAULT_MTU - test_replay->get_chdr_hdr_len()) / word_size);
BOOST_CHECK_EQUAL(reg_iface->write_memory[reg_play_item_size], default_item_size);
}
}
@@ -353,18 +353,20 @@ BOOST_FIXTURE_TEST_CASE(replay_test_configure_play, replay_block_fixture)
}
/*
- * This test case ensures that the hardware is programmed correctly throough the playback
+ * This test case ensures that the hardware is programmed correctly through the playback
* packet API calls.
*/
BOOST_FIXTURE_TEST_CASE(replay_test_packet_size, replay_block_fixture)
{
for (size_t port = 0; port < num_output_ports; port++) {
// Test the defaults
- const uint32_t default_ipp = DEFAULT_SPP;
- BOOST_CHECK_EQUAL(test_replay->get_max_items_per_packet(port), default_ipp);
-
- const uint32_t item_size = test_replay->get_play_item_size(port);
- const uint32_t default_packet_size = default_ipp * item_size + CHDR_MAX_LEN_HDR;
+ const uint32_t item_size = test_replay->get_play_item_size(port);
+ const uint32_t expected_ipp =
+ test_replay->get_max_payload_size({res_source_info::OUTPUT_EDGE, port})
+ / item_size;
+ BOOST_CHECK_EQUAL(test_replay->get_max_items_per_packet(port), expected_ipp);
+ const uint32_t default_packet_size =
+ expected_ipp * item_size + test_replay->get_chdr_hdr_len();
BOOST_CHECK_EQUAL(test_replay->get_max_packet_size(port), default_packet_size);
}
@@ -374,7 +376,7 @@ BOOST_FIXTURE_TEST_CASE(replay_test_packet_size, replay_block_fixture)
BOOST_CHECK_EQUAL(test_replay->get_max_items_per_packet(port), ipp);
const uint32_t item_size = test_replay->get_play_item_size(port);
- const uint32_t packet_size = ipp * item_size + CHDR_MAX_LEN_HDR;
+ const uint32_t packet_size = ipp * item_size + test_replay->get_chdr_hdr_len();
BOOST_CHECK_EQUAL(test_replay->get_max_packet_size(port), packet_size);
const uint32_t wpp = ipp * item_size / word_size;
diff --git a/host/tests/rfnoc_block_tests/siggen_block_test.cpp b/host/tests/rfnoc_block_tests/siggen_block_test.cpp
index ea52530e0..d453e898e 100644
--- a/host/tests/rfnoc_block_tests/siggen_block_test.cpp
+++ b/host/tests/rfnoc_block_tests/siggen_block_test.cpp
@@ -191,7 +191,10 @@ BOOST_FIXTURE_TEST_CASE(siggen_test_construction, siggen_block_fixture)
BOOST_CHECK_EQUAL(reg_iface->phase_increments.at(port), siggen_mock_reg_iface_t::phase_increment_to_register(1.0));
BOOST_CHECK_EQUAL(reg_iface->phasors.at(port),
siggen_mock_reg_iface_t::phasor_to_register({0.0, 0.0}));
- BOOST_CHECK_EQUAL(reg_iface->spps.at(port), DEFAULT_SPP);
+ constexpr int bpi = 4; // sc16 has 4 bytes per item
+ const int expected_spp =
+ test_siggen->get_max_payload_size({res_source_info::OUTPUT_EDGE, port}) / bpi;
+ BOOST_CHECK_EQUAL(reg_iface->spps.at(port), expected_spp);
}
}
@@ -315,10 +318,11 @@ BOOST_FIXTURE_TEST_CASE(siggen_test_ranges, siggen_block_fixture)
*/
BOOST_FIXTURE_TEST_CASE(siggen_test_spp_coercion, siggen_block_fixture)
{
- constexpr size_t mtu_in_samps = DEFAULT_MTU / 4 /* bytes/samp */;
- size_t high_spp = mtu_in_samps + 10;
- test_siggen->set_samples_per_packet(high_spp, 0);
- BOOST_CHECK_EQUAL(test_siggen->get_samples_per_packet(0), mtu_in_samps);
+ const size_t max_samps =
+ (DEFAULT_MTU - test_siggen->get_chdr_hdr_len()) / 4 /* bytes/samp */;
+ const size_t too_high_spp = max_samps + 10;
+ test_siggen->set_samples_per_packet(too_high_spp, 0);
+ BOOST_CHECK_EQUAL(test_siggen->get_samples_per_packet(0), max_samps);
}
/*
diff --git a/host/tests/rx_streamer_test.cpp b/host/tests/rx_streamer_test.cpp
index 03ab3f456..a2969d608 100644
--- a/host/tests/rx_streamer_test.cpp
+++ b/host/tests/rx_streamer_test.cpp
@@ -95,9 +95,19 @@ public:
_recv_link->release_recv_buff(std::move(buff));
}
+ size_t get_mtu() const
+ {
+ return _recv_link->get_recv_frame_size();
+ }
+
+ size_t get_chdr_hdr_len() const
+ {
+ return sizeof(mock_header_t);
+ }
+
size_t get_max_payload_size() const
{
- return _recv_link->get_recv_frame_size() - sizeof(packet_info_t);
+ return get_mtu() - get_chdr_hdr_len();
}
private:
diff --git a/host/tests/streamer_benchmark.cpp b/host/tests/streamer_benchmark.cpp
index a11db3e68..b180e7393 100644
--- a/host/tests/streamer_benchmark.cpp
+++ b/host/tests/streamer_benchmark.cpp
@@ -76,11 +76,21 @@ public:
_buff = std::move(buff);
}
- size_t get_max_payload_size() const
+ size_t get_mtu() const
{
return _buff_size;
}
+ size_t get_chdr_hdr_len() const
+ {
+ return sizeof(packet_info_t);
+ }
+
+ size_t get_max_payload_size() const
+ {
+ return get_mtu() - sizeof(packet_info_t);
+ }
+
private:
size_t _buff_size;
buff_t::uptr _buff;
@@ -137,11 +147,22 @@ public:
_buff = std::move(buff);
}
+ size_t get_mtu() const
+ {
+ return _buff_size;
+ }
+
+ size_t get_chdr_hdr_len() const
+ {
+ return sizeof(packet_info_t);
+ }
+
size_t get_max_payload_size() const
{
- return _buff_size - sizeof(packet_info_t);
+ return get_mtu() - sizeof(packet_info_t);
}
+
private:
size_t _buff_size;
buff_t::uptr _buff;
diff --git a/host/tests/tx_streamer_test.cpp b/host/tests/tx_streamer_test.cpp
index 75511c329..11e33d413 100644
--- a/host/tests/tx_streamer_test.cpp
+++ b/host/tests/tx_streamer_test.cpp
@@ -53,10 +53,19 @@ public:
_send_link->release_send_buff(std::move(buff));
}
+ size_t get_mtu() const
+ {
+ return _send_link->get_send_frame_size();
+ }
+
+ size_t get_chdr_hdr_len() const
+ {
+ return sizeof(packet_info_t);
+ }
+
size_t get_max_payload_size() const
{
- return _send_link->get_send_frame_size() - sizeof(packet_info_t);
- ;
+ return get_mtu() - get_chdr_hdr_len();
}
private: