aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/include/uhdlib/rfnoc
diff options
context:
space:
mode:
authorAshish Chaudhari <ashish@ettus.com>2019-05-20 17:14:20 -0700
committerMartin Braun <martin.braun@ettus.com>2019-11-26 11:49:15 -0800
commit0b698810a163e3986939341fee5014fc6ad7e7f9 (patch)
tree22e2c122542928e29a2a0a8f6d383ad12e65b6a8 /host/lib/include/uhdlib/rfnoc
parentad4004f1f78d5b64dae50b6e456d0206e824978f (diff)
downloaduhd-0b698810a163e3986939341fee5014fc6ad7e7f9.tar.gz
uhd-0b698810a163e3986939341fee5014fc6ad7e7f9.tar.bz2
uhd-0b698810a163e3986939341fee5014fc6ad7e7f9.zip
rfnoc: Added impl for reg_iface and ctrl_endpoint
- Added new register_iface class that translates high-level peek/poke calls into CHDR control payloads - Added new chdr_ctrl_endpoint class that emulates a control stream endpoint in SW. It can create and handle multiple register interfaces
Diffstat (limited to 'host/lib/include/uhdlib/rfnoc')
-rw-r--r--host/lib/include/uhdlib/rfnoc/chdr/chdr_types.hpp8
-rw-r--r--host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp62
-rw-r--r--host/lib/include/uhdlib/rfnoc/ctrlport_endpoint.hpp61
3 files changed, 131 insertions, 0 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/chdr/chdr_types.hpp b/host/lib/include/uhdlib/rfnoc/chdr/chdr_types.hpp
index 8363e1bcf..447e7db91 100644
--- a/host/lib/include/uhdlib/rfnoc/chdr/chdr_types.hpp
+++ b/host/lib/include/uhdlib/rfnoc/chdr/chdr_types.hpp
@@ -309,6 +309,8 @@ public: // Functions
ctrl_payload(const ctrl_payload& rhs) = default;
ctrl_payload(ctrl_payload&& rhs) = default;
+ ctrl_payload& operator=(const ctrl_payload& rhs) = default;
+
//! Populate the header for this type of packet
void populate_header(chdr_header& header) const;
@@ -422,6 +424,8 @@ public: // Functions
strs_payload(const strs_payload& rhs) = default;
strs_payload(strs_payload&& rhs) = default;
+ strs_payload& operator=(const strs_payload& rhs) = default;
+
//! Populate the header for this type of packet
void populate_header(chdr_header& header) const;
@@ -517,6 +521,8 @@ public: // Functions
strc_payload(const strc_payload& rhs) = default;
strc_payload(strc_payload&& rhs) = default;
+ strc_payload& operator=(const strc_payload& rhs) = default;
+
//! Populate the header for this type of packet
void populate_header(chdr_header& header) const;
@@ -751,6 +757,8 @@ public:
mgmt_payload(const mgmt_payload& rhs) = default;
mgmt_payload(mgmt_payload&& rhs) = default;
+ mgmt_payload& operator=(const mgmt_payload& rhs) = default;
+
inline void set_header(sep_id_t src_epid, uint16_t protover, chdr_w_t chdr_w)
{
_src_epid = src_epid;
diff --git a/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp b/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp
new file mode 100644
index 000000000..c13955888
--- /dev/null
+++ b/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp
@@ -0,0 +1,62 @@
+//
+// Copyright 2019 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#ifndef INCLUDED_LIBUHD_RFNOC_CHDR_CTRL_ENDPOINT_HPP
+#define INCLUDED_LIBUHD_RFNOC_CHDR_CTRL_ENDPOINT_HPP
+
+#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
+#include <uhdlib/rfnoc/ctrlport_endpoint.hpp>
+#include <uhdlib/rfnoc/xports.hpp>
+#include <functional>
+#include <memory>
+
+namespace uhd { namespace rfnoc {
+
+/*! A software interface that represents a CHDR control endpoint
+ *
+ * The endpoint is capable of sending/receiving CHDR packets
+ * and creating multiple ctrlport_endpoint interfaces
+ */
+class chdr_ctrl_endpoint
+{
+public:
+ using uptr = std::unique_ptr<chdr_ctrl_endpoint>;
+
+ virtual ~chdr_ctrl_endpoint() = 0;
+
+ //! Creates a new register interface for the specified port
+ //
+ // \param port The port number on the control crossbar
+ // \param buff_capacity The buffer capacity of the downstream buff in 32-bit words
+ // \param max_outstanding_async_msgs Max outstanding async messages allowed
+ // \param ctrl_clk_freq Frequency of the clock driving the ctrlport logic
+ // \param timebase_freq Frequency of the timebase (for timed commands)
+ //
+ virtual ctrlport_endpoint::sptr get_ctrlport_ep(uint16_t port,
+ size_t buff_capacity,
+ size_t max_outstanding_async_msgs,
+ double ctrl_clk_freq,
+ double timebase_freq) = 0;
+
+ //! Returns the number of dropped packets due to misclassification
+ virtual size_t get_num_drops() const = 0;
+
+ //! Creates a control endpoint object
+ //
+ // \param xports The transports used to send and recv packets
+ // \param pkt_factor An instance of the CHDR packet factory
+ // \param my_epid The endpoint ID of this software endpoint
+ //
+ static uptr make(const both_xports_t& xports,
+ const chdr::chdr_packet_factory& pkt_factory,
+ sep_id_t dst_epid,
+ sep_id_t my_epid);
+
+}; // class chdr_ctrl_endpoint
+
+}} /* namespace uhd::rfnoc */
+
+#endif /* INCLUDED_LIBUHD_RFNOC_CHDR_CTRL_ENDPOINT_HPP */
diff --git a/host/lib/include/uhdlib/rfnoc/ctrlport_endpoint.hpp b/host/lib/include/uhdlib/rfnoc/ctrlport_endpoint.hpp
new file mode 100644
index 000000000..d135f284c
--- /dev/null
+++ b/host/lib/include/uhdlib/rfnoc/ctrlport_endpoint.hpp
@@ -0,0 +1,61 @@
+//
+// Copyright 2019 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#ifndef INCLUDED_LIBUHD_RFNOC_CTRLPORT_ENDPOINT_HPP
+#define INCLUDED_LIBUHD_RFNOC_CTRLPORT_ENDPOINT_HPP
+
+#include <uhd/rfnoc/register_iface.hpp>
+#include <uhdlib/rfnoc/chdr/chdr_types.hpp>
+#include <memory>
+
+namespace uhd { namespace rfnoc {
+
+/*! A software interface that represents a ControlPort endpoint
+ *
+ * This interface supports the following:
+ * - All capabilities of register_iface
+ * - A function to handle received packets
+ * - A static factory class to create these endpoints
+ */
+class ctrlport_endpoint : public register_iface
+{
+public:
+ using sptr = std::shared_ptr<ctrlport_endpoint>;
+
+ //! The function to call when sending a packet to a remote device
+ using send_fn_t = std::function<void(const chdr::ctrl_payload&, double)>;
+
+ virtual ~ctrlport_endpoint() = 0;
+
+ //! Handles an incoming control packet (request and response)
+ //
+ // \param rx_ctrl The control payload of the received packet
+ //
+ virtual void handle_recv(const chdr::ctrl_payload& rx_ctrl) = 0;
+
+ //! Creates a new register interface (ctrl_portendpoint)
+ //
+ // \param handle_send The function to call to send a control packet
+ // \param my_epid The endpoint ID of the SW control stream endpoint
+ // \param port The port number on the control crossbar
+ // \param buff_capacity The buffer capacity of the downstream buff in 32-bit words
+ // \param max_outstanding_async_msgs Max outstanding async messages allowed
+ // \param ctrl_clk_freq Frequency of the clock driving the ctrlport logic
+ // \param timebase_freq Frequency of the timebase (for timed commands)
+ //
+ static sptr make(const send_fn_t& handle_send,
+ sep_id_t my_epid,
+ uint16_t local_port,
+ size_t buff_capacity,
+ size_t max_outstanding_async_msgs,
+ double ctrl_clk_freq,
+ double timebase_freq);
+
+}; // class ctrlport_endpoint
+
+}} /* namespace uhd::rfnoc */
+
+#endif /* INCLUDED_LIBUHD_RFNOC_CTRLPORT_ENDPOINT_HPP */