aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorAshish Chaudhari <ashish@ettus.com>2019-05-25 00:14:36 -0700
committerMartin Braun <martin.braun@ettus.com>2019-11-26 11:49:20 -0800
commitb4bc85ac972b2e4f3e8e0b092947267f9f8aeee4 (patch)
treef3128013bf71d44ece3b408db6a03177c6fd5f56 /host
parent1e65500d791461be9aa7a2d2646d463f536f49e3 (diff)
downloaduhd-b4bc85ac972b2e4f3e8e0b092947267f9f8aeee4.tar.gz
uhd-b4bc85ac972b2e4f3e8e0b092947267f9f8aeee4.tar.bz2
uhd-b4bc85ac972b2e4f3e8e0b092947267f9f8aeee4.zip
rfnoc: Moved chdr types/packet class out of chdr dir
- Moved chdr_packet and chdr_types from rfnoc/chdr to rfnoc and updated all references - Moved non-CHDR definitions to rfnoc_common.hpp
Diffstat (limited to 'host')
-rw-r--r--host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp2
-rw-r--r--host/lib/include/uhdlib/rfnoc/chdr_packet.hpp (renamed from host/lib/include/uhdlib/rfnoc/chdr/chdr_packet.hpp)10
-rw-r--r--host/lib/include/uhdlib/rfnoc/chdr_types.hpp (renamed from host/lib/include/uhdlib/rfnoc/chdr/chdr_types.hpp)46
-rw-r--r--host/lib/include/uhdlib/rfnoc/ctrlport_endpoint.hpp2
-rw-r--r--host/lib/include/uhdlib/rfnoc/mb_iface.hpp2
-rw-r--r--host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp2
-rw-r--r--host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp59
-rw-r--r--host/lib/rfnoc/CMakeLists.txt3
-rw-r--r--host/lib/rfnoc/chdr/CMakeLists.txt15
-rw-r--r--host/lib/rfnoc/chdr_ctrl_endpoint.cpp6
-rw-r--r--host/lib/rfnoc/chdr_packet.cpp (renamed from host/lib/rfnoc/chdr/chdr_packet.cpp)7
-rw-r--r--host/lib/rfnoc/chdr_types.cpp (renamed from host/lib/rfnoc/chdr/chdr_types.cpp)2
-rw-r--r--host/lib/rfnoc/ctrlport_endpoint.cpp4
-rw-r--r--host/lib/rfnoc/mgmt_portal.cpp2
-rw-r--r--host/tests/CMakeLists.txt8
-rw-r--r--host/tests/rfnoc_chdr_test.cpp4
16 files changed, 99 insertions, 75 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp b/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp
index 29f4da7c2..b50e06d3c 100644
--- a/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp
+++ b/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp
@@ -7,7 +7,7 @@
#ifndef INCLUDED_LIBUHD_RFNOC_CHDR_CTRL_ENDPOINT_HPP
#define INCLUDED_LIBUHD_RFNOC_CHDR_CTRL_ENDPOINT_HPP
-#include <uhdlib/rfnoc/chdr/chdr_packet.hpp>
+#include <uhdlib/rfnoc/chdr_packet.hpp>
#include <uhdlib/rfnoc/ctrlport_endpoint.hpp>
#include <uhdlib/rfnoc/xports.hpp>
#include <functional>
diff --git a/host/lib/include/uhdlib/rfnoc/chdr/chdr_packet.hpp b/host/lib/include/uhdlib/rfnoc/chdr_packet.hpp
index 102a6e104..89b33a66a 100644
--- a/host/lib/include/uhdlib/rfnoc/chdr/chdr_packet.hpp
+++ b/host/lib/include/uhdlib/rfnoc/chdr_packet.hpp
@@ -9,7 +9,7 @@
#include <uhd/types/endianness.hpp>
#include <uhd/utils/byteswap.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
+#include <uhdlib/rfnoc/chdr_types.hpp>
#include <limits>
namespace uhd { namespace rfnoc { namespace chdr {
@@ -213,7 +213,7 @@ public:
payload.deserialize(_chdr_pkt->get_payload_const_ptr_as<uint64_t>(),
_chdr_pkt->get_payload_size() / sizeof(uint64_t),
_chdr_pkt->conv_to_host<uint64_t>());
- return std::move(payload);
+ return payload;
}
//! Fills the CHDR payload into the specified parameter
@@ -255,6 +255,12 @@ class chdr_packet_factory
{
public:
//! A parametrized ctor that takes in all the info required to generate a CHDR packet
+ //
+ // \param chdr_w The CHDR width of the remote device
+ // \param endianness The endianness of the link being used (e.g., Ethernet
+ // typically uses big-endian, PCIe typically uses
+ // little-endian). Note: The host endianness is
+ // automatically derived.
chdr_packet_factory(chdr_w_t chdr_w, endianness_t endianness);
chdr_packet_factory() = delete;
chdr_packet_factory(const chdr_packet_factory& rhs) = default;
diff --git a/host/lib/include/uhdlib/rfnoc/chdr/chdr_types.hpp b/host/lib/include/uhdlib/rfnoc/chdr_types.hpp
index 447e7db91..62b24ab61 100644
--- a/host/lib/include/uhdlib/rfnoc/chdr/chdr_types.hpp
+++ b/host/lib/include/uhdlib/rfnoc/chdr_types.hpp
@@ -9,46 +9,13 @@
#include <uhd/types/endianness.hpp>
#include <uhd/utils/byteswap.hpp>
+#include <uhdlib/rfnoc/rfnoc_common.hpp>
#include <boost/optional.hpp>
#include <list>
#include <memory>
#include <vector>
-namespace uhd { namespace rfnoc {
-
-enum chdr_w_t {
- //! CHDR_W = 64 bits
- CHDR_W_64 = 0,
- //! CHDR_W = 128 bits
- CHDR_W_128 = 1,
- //! CHDR_W = 256 bits
- CHDR_W_256 = 2,
- //! CHDR_W = 512 bits
- CHDR_W_512 = 3
-};
-
-using device_id_t = uint16_t;
-using sep_inst_t = uint16_t;
-using sep_addr_t = std::pair<device_id_t, sep_inst_t>;
-using sep_id_t = uint16_t;
-
-constexpr size_t chdr_w_to_bits(chdr_w_t chdr_w)
-{
- switch (chdr_w) {
- case CHDR_W_64:
- return 64;
- case CHDR_W_128:
- return 128;
- case CHDR_W_256:
- return 256;
- case CHDR_W_512:
- return 512;
- default:
- return 0;
- }
-}
-
-namespace chdr {
+namespace uhd { namespace rfnoc { namespace chdr {
enum packet_type_t {
PKT_TYPE_MGMT = 0x0, //! Management packet
@@ -832,6 +799,12 @@ public:
//! Return a string representation of this object
const std::string to_string() const;
+ //! Return the source EPID for this transaction
+ inline const sep_id_t get_src_epid() const
+ {
+ return _src_epid;
+ }
+
private:
sep_id_t _src_epid = 0;
uint16_t _protover = 0;
@@ -839,7 +812,6 @@ private:
std::vector<mgmt_hop_t> _hops;
};
-} // namespace chdr
-}} // namespace uhd::rfnoc
+}}} // namespace uhd::rfnoc::chdr
#endif /* INCLUDED_RFNOC_CHDR_TYPES_HPP */
diff --git a/host/lib/include/uhdlib/rfnoc/ctrlport_endpoint.hpp b/host/lib/include/uhdlib/rfnoc/ctrlport_endpoint.hpp
index 00ebe38b9..8f54932e5 100644
--- a/host/lib/include/uhdlib/rfnoc/ctrlport_endpoint.hpp
+++ b/host/lib/include/uhdlib/rfnoc/ctrlport_endpoint.hpp
@@ -8,8 +8,8 @@
#define INCLUDED_LIBUHD_RFNOC_CTRLPORT_ENDPOINT_HPP
#include <uhd/rfnoc/register_iface.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
#include <uhdlib/rfnoc/clock_iface.hpp>
+#include <uhdlib/rfnoc/chdr_types.hpp>
#include <memory>
namespace uhd { namespace rfnoc {
diff --git a/host/lib/include/uhdlib/rfnoc/mb_iface.hpp b/host/lib/include/uhdlib/rfnoc/mb_iface.hpp
index 466ec0cbf..60afa92fa 100644
--- a/host/lib/include/uhdlib/rfnoc/mb_iface.hpp
+++ b/host/lib/include/uhdlib/rfnoc/mb_iface.hpp
@@ -7,7 +7,7 @@
#ifndef INCLUDED_LIBUHD_MB_IFACE_HPP
#define INCLUDED_LIBUHD_MB_IFACE_HPP
-#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
+#include <uhdlib/rfnoc/chdr_types.hpp>
#include <memory>
namespace uhd { namespace rfnoc {
diff --git a/host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp b/host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp
index 305f8fb85..09a155fa0 100644
--- a/host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp
+++ b/host/lib/include/uhdlib/rfnoc/mgmt_portal.hpp
@@ -7,7 +7,7 @@
#ifndef INCLUDED_LIBUHD_MGMT_PORTAL_HPP
#define INCLUDED_LIBUHD_MGMT_PORTAL_HPP
-#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
+#include <uhdlib/rfnoc/chdr_types.hpp>
#include <uhdlib/rfnoc/xports.hpp>
#include <memory>
diff --git a/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp b/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp
new file mode 100644
index 000000000..1fee0d40e
--- /dev/null
+++ b/host/lib/include/uhdlib/rfnoc/rfnoc_common.hpp
@@ -0,0 +1,59 @@
+//
+// Copyright 2019 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#ifndef INCLUDED_RFNOC_RFNOC_COMMON_HPP
+#define INCLUDED_RFNOC_RFNOC_COMMON_HPP
+
+#include <memory>
+
+namespace uhd { namespace rfnoc {
+
+//----------------------------------------------
+// Types
+//----------------------------------------------
+
+//! Type that indicates the CHDR Width in bits
+enum chdr_w_t { CHDR_W_64 = 0, CHDR_W_128 = 1, CHDR_W_256 = 2, CHDR_W_512 = 3 };
+//! Conversion from chdr_w_t to a number of bits
+constexpr size_t chdr_w_to_bits(chdr_w_t chdr_w)
+{
+ switch (chdr_w) {
+ case CHDR_W_64:
+ return 64;
+ case CHDR_W_128:
+ return 128;
+ case CHDR_W_256:
+ return 256;
+ case CHDR_W_512:
+ return 512;
+ default:
+ return 0;
+ }
+}
+
+//! Device ID Type
+using device_id_t = uint16_t;
+//! Stream Endpoint Instance Number Type
+using sep_inst_t = uint16_t;
+//! Stream Endpoint Physical Address Type
+using sep_addr_t = std::pair<device_id_t, sep_inst_t>;
+//! Stream Endpoint ID Type
+using sep_id_t = uint16_t;
+
+//! Type of data carried by the stream endpoint
+enum class sep_type_t { CTRL, DATA };
+
+
+//----------------------------------------------
+// Constants
+//----------------------------------------------
+
+constexpr uint16_t RFNOC_PROTO_VER = 0x0100;
+
+
+}} // namespace uhd::rfnoc
+
+#endif /* INCLUDED_RFNOC_RFNOC_COMMON_HPP */
diff --git a/host/lib/rfnoc/CMakeLists.txt b/host/lib/rfnoc/CMakeLists.txt
index 4b36a8db4..45904a572 100644
--- a/host/lib/rfnoc/CMakeLists.txt
+++ b/host/lib/rfnoc/CMakeLists.txt
@@ -20,6 +20,8 @@ LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/block_ctrl_impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/blockdef_xml_impl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/block_id.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/chdr_types.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/chdr_packet.cpp
${CMAKE_CURRENT_SOURCE_DIR}/client_zero.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ctrl_iface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/graph_impl.cpp
@@ -58,5 +60,4 @@ LIBUHD_APPEND_SOURCES(
${CMAKE_CURRENT_SOURCE_DIR}/replay_block_ctrl_impl.cpp
)
-INCLUDE_SUBDIRECTORY(chdr)
INCLUDE_SUBDIRECTORY(nocscript)
diff --git a/host/lib/rfnoc/chdr/CMakeLists.txt b/host/lib/rfnoc/chdr/CMakeLists.txt
deleted file mode 100644
index fca46fe4a..000000000
--- a/host/lib/rfnoc/chdr/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Copyright 2014-2015,2017 Ettus Research LLC
-# Copyright 2018 Ettus Research, a National Instruments Company
-#
-# SPDX-License-Identifier: GPL-3.0-or-later
-#
-
-########################################################################
-# This file included, use CMake directory variables
-########################################################################
-
-LIBUHD_APPEND_SOURCES(
- ${CMAKE_CURRENT_SOURCE_DIR}/chdr_types.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/chdr_packet.cpp
-)
diff --git a/host/lib/rfnoc/chdr_ctrl_endpoint.cpp b/host/lib/rfnoc/chdr_ctrl_endpoint.cpp
index 6ded83c0f..fadba566e 100644
--- a/host/lib/rfnoc/chdr_ctrl_endpoint.cpp
+++ b/host/lib/rfnoc/chdr_ctrl_endpoint.cpp
@@ -8,13 +8,13 @@
#include <uhd/utils/log.hpp>
#include <uhd/utils/safe_call.hpp>
#include <uhd/utils/thread.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_packet.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
#include <uhdlib/rfnoc/chdr_ctrl_endpoint.hpp>
+#include <uhdlib/rfnoc/chdr_packet.hpp>
+#include <uhdlib/rfnoc/chdr_types.hpp>
#include <boost/format.hpp>
+#include <atomic>
#include <mutex>
#include <thread>
-#include <atomic>
using namespace uhd;
using namespace uhd::rfnoc;
diff --git a/host/lib/rfnoc/chdr/chdr_packet.cpp b/host/lib/rfnoc/chdr_packet.cpp
index b058115ab..653181c04 100644
--- a/host/lib/rfnoc/chdr/chdr_packet.cpp
+++ b/host/lib/rfnoc/chdr_packet.cpp
@@ -4,12 +4,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <uhdlib/rfnoc/chdr/chdr_packet.hpp>
+#include <uhdlib/rfnoc/chdr_packet.hpp>
#include <cassert>
#include <functional>
#include <memory>
using namespace uhd;
+using namespace uhd::rfnoc;
using namespace uhd::rfnoc::chdr;
chdr_packet::~chdr_packet() = default;
@@ -17,7 +18,7 @@ chdr_packet::~chdr_packet() = default;
//------------------------------------------------------------
// chdr_packet
//------------------------------------------------------------
-
+// endianness is the link endianness, not the host endianness
template <size_t chdr_w, endianness_t endianness>
class chdr_packet_impl : public chdr_packet
{
@@ -39,7 +40,7 @@ public:
_pkt_buff = reinterpret_cast<uint64_t*>(pkt_buff);
_pkt_buff[0] = u64_from_host(header);
if (_has_timestamp(header)) {
- _pkt_buff[1] = timestamp;
+ _pkt_buff[1] = u64_from_host(timestamp);
}
_compute_mdata_offset();
}
diff --git a/host/lib/rfnoc/chdr/chdr_types.cpp b/host/lib/rfnoc/chdr_types.cpp
index 8920e4fe3..0e30dca7e 100644
--- a/host/lib/rfnoc/chdr/chdr_types.cpp
+++ b/host/lib/rfnoc/chdr_types.cpp
@@ -6,7 +6,7 @@
#include <uhd/exception.hpp>
#include <uhd/types/endianness.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
+#include <uhdlib/rfnoc/chdr_types.hpp>
#include <boost/format.hpp>
#include <cassert>
diff --git a/host/lib/rfnoc/ctrlport_endpoint.cpp b/host/lib/rfnoc/ctrlport_endpoint.cpp
index d5f4ef98c..93236940f 100644
--- a/host/lib/rfnoc/ctrlport_endpoint.cpp
+++ b/host/lib/rfnoc/ctrlport_endpoint.cpp
@@ -6,8 +6,8 @@
#include <uhd/exception.hpp>
#include <uhd/utils/log.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_packet.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
+#include <uhdlib/rfnoc/chdr_packet.hpp>
+#include <uhdlib/rfnoc/chdr_types.hpp>
#include <uhdlib/rfnoc/ctrlport_endpoint.hpp>
#include <condition_variable>
#include <boost/format.hpp>
diff --git a/host/lib/rfnoc/mgmt_portal.cpp b/host/lib/rfnoc/mgmt_portal.cpp
index fcb19997e..76d708a0e 100644
--- a/host/lib/rfnoc/mgmt_portal.cpp
+++ b/host/lib/rfnoc/mgmt_portal.cpp
@@ -7,7 +7,7 @@
#include <uhd/exception.hpp>
#include <uhd/utils/log.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_packet.hpp>
+#include <uhdlib/rfnoc/chdr_packet.hpp>
#include <uhdlib/rfnoc/mgmt_portal.hpp>
#include <unordered_set>
#include <boost/format.hpp>
diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt
index 0c48ae058..bd0964def 100644
--- a/host/tests/CMakeLists.txt
+++ b/host/tests/CMakeLists.txt
@@ -229,11 +229,11 @@ UHD_ADD_NONAPI_TEST(
UHD_ADD_NONAPI_TEST(
TARGET rfnoc_chdr_test.cpp
EXTRA_SOURCES
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/chdr/chdr_types.cpp
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/chdr/chdr_packet.cpp
+ ${CMAKE_SOURCE_DIR}/lib/rfnoc/chdr_types.cpp
+ ${CMAKE_SOURCE_DIR}/lib/rfnoc/chdr_packet.cpp
INCLUDE_DIRS
- ${CMAKE_BINARY_DIR}/lib/rfnoc/chdr/
- ${CMAKE_SOURCE_DIR}/lib/rfnoc/chdr/
+ ${CMAKE_BINARY_DIR}/lib/rfnoc/
+ ${CMAKE_SOURCE_DIR}/lib/rfnoc/
)
UHD_ADD_NONAPI_TEST(
diff --git a/host/tests/rfnoc_chdr_test.cpp b/host/tests/rfnoc_chdr_test.cpp
index 67993cb02..417ed2f96 100644
--- a/host/tests/rfnoc_chdr_test.cpp
+++ b/host/tests/rfnoc_chdr_test.cpp
@@ -6,8 +6,8 @@
#include <uhd/types/endianness.hpp>
#include <uhd/utils/byteswap.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_packet.hpp>
-#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
+#include <uhdlib/rfnoc/chdr_packet.hpp>
+#include <uhdlib/rfnoc/chdr_types.hpp>
#include <boost/format.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>