aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2021-11-24 15:51:29 +0100
committerAaron Rossetto <aaron.rossetto@ni.com>2021-12-03 11:35:04 -0800
commit5df498aeb985b40d72fa5165366e903351369f91 (patch)
tree654ab5906dacb1bd7bc81495b34e5d05d535f474 /host
parentb49e4f1eb62081a035c8d2e1d7b50e65e027ad72 (diff)
downloaduhd-5df498aeb985b40d72fa5165366e903351369f91.tar.gz
uhd-5df498aeb985b40d72fa5165366e903351369f91.tar.bz2
uhd-5df498aeb985b40d72fa5165366e903351369f91.zip
rfnoc: Enable drop counter on chdr_ctrl_endpoint
This class has a member _num_drops, which can be read out using the get_num_drops() API call. However, when dropping packets, this counter was not incremented, which is fixed now. This also includes a very minor optimization from 2 map<> lookups to 1 lookup (they are in O(log N)). Since there are usually a small two-digit number of endpoints connected to the async message receiver, this change is not expected to yield major improvements, but the lookup *is* in a hot loop.
Diffstat (limited to 'host')
-rw-r--r--host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp5
-rw-r--r--host/lib/rfnoc/chdr_ctrl_endpoint.cpp22
2 files changed, 23 insertions, 4 deletions
diff --git a/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp b/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp
index 61358fa2f..65db20e5a 100644
--- a/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp
+++ b/host/lib/include/uhdlib/rfnoc/chdr_ctrl_endpoint.hpp
@@ -42,6 +42,11 @@ public:
const clock_iface& timebase_clk) = 0;
//! Returns the number of dropped packets due to misclassification
+ //
+ // This includes packets that are not valid CHDR as well as packets that
+ // are valid CHDR, but have no known/valid endpoint. Correctly classified
+ // packets may still be invalid, but they don't get counted here, they are
+ // handled in ctrlport_endpoint.
virtual size_t get_num_drops() const = 0;
//! Creates a control endpoint object
diff --git a/host/lib/rfnoc/chdr_ctrl_endpoint.cpp b/host/lib/rfnoc/chdr_ctrl_endpoint.cpp
index 7d9bb8d1b..8194c7a93 100644
--- a/host/lib/rfnoc/chdr_ctrl_endpoint.cpp
+++ b/host/lib/rfnoc/chdr_ctrl_endpoint.cpp
@@ -32,6 +32,7 @@ public:
sep_id_t my_epid)
: _my_epid(my_epid)
, _xport(xport)
+ , _num_drops(0)
, _send_pkt(pkt_factory.make_ctrl())
, _recv_pkt(pkt_factory.make_ctrl())
, _stop_recv_thread(false)
@@ -135,11 +136,23 @@ private:
_recv_pkt->refresh(buff->data());
const ctrl_payload payload = _recv_pkt->get_payload();
ep_map_key_t key{payload.src_epid, payload.dst_port};
- if (_endpoint_map.find(key) != _endpoint_map.end()) {
- _endpoint_map.at(key)->handle_recv(payload);
+ auto ep_iter = _endpoint_map.find(key);
+ if (ep_iter != _endpoint_map.end()) {
+ ep_iter->second->handle_recv(payload);
+ } else {
+ UHD_LOG_WARNING("RFNOC",
+ "chdr_ctrl_endpoint: Received async message for unknown "
+ "destination. Source EPID: "
+ << payload.src_epid
+ << " Destination Port: " << payload.dst_port);
+ _num_drops++;
}
} catch (...) {
// Ignore all errors
+ UHD_LOG_DEBUG("RFNOC",
+ "chdr_ctrl_endpoint: Unidentified error in async message handler "
+ "loop.");
+ _num_drops++;
}
_xport->release_recv_buff(std::move(buff));
} else {
@@ -170,8 +183,9 @@ private:
chdr_ctrl_xport::sptr _xport;
// The curent sequence number for a send packet
size_t _send_seqnum = 0;
- // The number of packets dropped
- size_t _num_drops = 0;
+ // The number of packets dropped due to misclassification. See also
+ // get_num_drops()
+ std::atomic<size_t> _num_drops;
// Packet containers
chdr_ctrl_packet::uptr _send_pkt;
chdr_ctrl_packet::cuptr _recv_pkt;