diff options
author | Andrew Lynch <andrew.lynch@ni.com> | 2020-06-10 17:15:46 -0500 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-06-26 14:34:13 -0500 |
commit | 5c1771cc68edca442d870611ef8d9662b5d00d8b (patch) | |
tree | 33c4c2dbf82259a4bc6ce4bd11f40e2384260d32 /host/tests/rfnoc_chdr_test.cpp | |
parent | 9318323b769200ee328456b0ef92ea19c1b96b6e (diff) | |
download | uhd-5c1771cc68edca442d870611ef8d9662b5d00d8b.tar.gz uhd-5c1771cc68edca442d870611ef8d9662b5d00d8b.tar.bz2 uhd-5c1771cc68edca442d870611ef8d9662b5d00d8b.zip |
CHDR: support multiple CHDR widths
Support management payloads on busses over 64 bits
Automatically set CHDR width for mpmd_link_if_ctrl_udp
Diffstat (limited to 'host/tests/rfnoc_chdr_test.cpp')
-rw-r--r-- | host/tests/rfnoc_chdr_test.cpp | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/host/tests/rfnoc_chdr_test.cpp b/host/tests/rfnoc_chdr_test.cpp index 747b3c6a4..27b883543 100644 --- a/host/tests/rfnoc_chdr_test.cpp +++ b/host/tests/rfnoc_chdr_test.cpp @@ -74,6 +74,17 @@ strc_payload populate_strc_payload() return pyld; } +mgmt_payload populate_mgmt_payload(const chdr_w_t chdr_w) +{ + mgmt_payload pyld; + pyld.set_header(sep_id_t(rand64() & 0xFFFF), uint16_t(rand64() & 0xFFFF), chdr_w); + mgmt_hop_t hop; + // management op payloads are 48 bits + hop.add_op(mgmt_op_t(mgmt_op_t::MGMT_OP_NOP, rand64() & 0xFFFFFFFFFFFF)); + pyld.add_hop(hop); + return pyld; +} + void byte_swap(uint64_t* buff) { for (size_t i = 0; i < MAX_BUF_SIZE_WORDS; i++) { @@ -264,3 +275,98 @@ BOOST_AUTO_TEST_CASE(chdr_generic_packet_calculate_pyld_offset_64) test_pyld_offset(pkt, PKT_TYPE_DATA_WITH_TS, 2); } } + + +BOOST_AUTO_TEST_CASE(chdr_mgmt_packet_no_swap_64) +{ + uint64_t buff[MAX_BUF_SIZE_WORDS]; + + chdr_mgmt_packet::uptr tx_pkt = chdr64_be_factory.make_mgmt(); + chdr_mgmt_packet::cuptr rx_pkt = chdr64_be_factory.make_mgmt(); + + for (size_t i = 0; i < NUM_ITERS; i++) { + chdr_header hdr = chdr_header(rand64()); + mgmt_payload pyld = populate_mgmt_payload(CHDR_W_64); + + memset(buff, 0, MAX_BUF_SIZE_BYTES); + tx_pkt->refresh(buff, hdr, pyld); + BOOST_CHECK(tx_pkt->get_chdr_header() == hdr); + BOOST_CHECK(tx_pkt->get_payload() == pyld); + + rx_pkt->refresh(buff); + BOOST_CHECK(rx_pkt->get_chdr_header() == hdr); + BOOST_CHECK(rx_pkt->get_payload() == pyld); + + std::cout << pyld.to_string(); + } +} + +BOOST_AUTO_TEST_CASE(chdr_mgmt_packet_no_swap_256) +{ + uint64_t buff[MAX_BUF_SIZE_WORDS]; + + chdr_mgmt_packet::uptr tx_pkt = chdr256_be_factory.make_mgmt(); + chdr_mgmt_packet::cuptr rx_pkt = chdr256_be_factory.make_mgmt(); + + for (size_t i = 0; i < NUM_ITERS; i++) { + chdr_header hdr = chdr_header(rand64()); + mgmt_payload pyld = populate_mgmt_payload(CHDR_W_256); + + memset(buff, 0, MAX_BUF_SIZE_BYTES); + tx_pkt->refresh(buff, hdr, pyld); + BOOST_CHECK(tx_pkt->get_chdr_header() == hdr); + BOOST_CHECK(tx_pkt->get_payload() == pyld); + + rx_pkt->refresh(buff); + BOOST_CHECK(rx_pkt->get_chdr_header() == hdr); + BOOST_CHECK(rx_pkt->get_payload() == pyld); + } +} + +BOOST_AUTO_TEST_CASE(chdr_mgmt_packet_swap_64) +{ + uint64_t buff[MAX_BUF_SIZE_WORDS]; + + chdr_mgmt_packet::uptr tx_pkt = chdr64_be_factory.make_mgmt(); + chdr_mgmt_packet::cuptr rx_pkt = chdr64_le_factory.make_mgmt(); + + for (size_t i = 0; i < NUM_ITERS; i++) { + chdr_header hdr = chdr_header(rand64()); + mgmt_payload pyld = populate_mgmt_payload(CHDR_W_64); + + memset(buff, 0, MAX_BUF_SIZE_BYTES); + tx_pkt->refresh(buff, hdr, pyld); + BOOST_CHECK(tx_pkt->get_chdr_header() == hdr); + BOOST_CHECK(tx_pkt->get_payload() == pyld); + + byte_swap(buff); + + rx_pkt->refresh(buff); + BOOST_CHECK(rx_pkt->get_chdr_header() == hdr); + BOOST_CHECK(rx_pkt->get_payload() == pyld); + } +} + +BOOST_AUTO_TEST_CASE(chdr_mgmt_packet_swap_256) +{ + uint64_t buff[MAX_BUF_SIZE_WORDS]; + + chdr_mgmt_packet::uptr tx_pkt = chdr256_be_factory.make_mgmt(); + chdr_mgmt_packet::cuptr rx_pkt = chdr256_le_factory.make_mgmt(); + + for (size_t i = 0; i < NUM_ITERS; i++) { + chdr_header hdr = chdr_header(rand64()); + mgmt_payload pyld = populate_mgmt_payload(CHDR_W_256); + + memset(buff, 0, MAX_BUF_SIZE_BYTES); + tx_pkt->refresh(buff, hdr, pyld); + BOOST_CHECK(tx_pkt->get_chdr_header() == hdr); + BOOST_CHECK(tx_pkt->get_payload() == pyld); + + byte_swap(buff); + + rx_pkt->refresh(buff); + BOOST_CHECK(rx_pkt->get_chdr_header() == hdr); + BOOST_CHECK(rx_pkt->get_payload() == pyld); + } +} |