aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/rfnoc/chdr_ctrl_xport.cpp
diff options
context:
space:
mode:
authorCiro Nishiguchi <ciro.nishiguchi@ni.com>2019-08-27 16:08:05 -0500
committerMartin Braun <martin.braun@ettus.com>2019-11-26 11:49:43 -0800
commit0e2464ad888230054b04a4f3fb192ea8dc5721b0 (patch)
treec51fa49fa5280437b178244660094a535b7059cc /host/lib/rfnoc/chdr_ctrl_xport.cpp
parent23f4f8cf4ea72d59740afcb5663e4541f93e821a (diff)
downloaduhd-0e2464ad888230054b04a4f3fb192ea8dc5721b0.tar.gz
uhd-0e2464ad888230054b04a4f3fb192ea8dc5721b0.tar.bz2
uhd-0e2464ad888230054b04a4f3fb192ea8dc5721b0.zip
rfnoc: Move data xport sep configuration to static methods
Move the configuration logic for stream endpoints to static methods of the chdr data transports. This separates those interactions from the main transport code, simplifying both. It also makes it easier to use the transports with mock link objects.
Diffstat (limited to 'host/lib/rfnoc/chdr_ctrl_xport.cpp')
-rw-r--r--host/lib/rfnoc/chdr_ctrl_xport.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/host/lib/rfnoc/chdr_ctrl_xport.cpp b/host/lib/rfnoc/chdr_ctrl_xport.cpp
index a6cfda0de..929875dbd 100644
--- a/host/lib/rfnoc/chdr_ctrl_xport.cpp
+++ b/host/lib/rfnoc/chdr_ctrl_xport.cpp
@@ -16,10 +16,11 @@ using namespace uhd::transport;
chdr_ctrl_xport::chdr_ctrl_xport(io_service::sptr io_srv,
send_link_if::sptr send_link,
recv_link_if::sptr recv_link,
+ const chdr::chdr_packet_factory& pkt_factory,
sep_id_t my_epid,
size_t num_send_frames,
size_t num_recv_frames)
- : _my_epid(my_epid)
+ : _my_epid(my_epid), _recv_packet(pkt_factory.make_generic())
{
/* Make dumb send pipe */
send_io_if::send_callback_t send_cb = [this](frame_buff::uptr& buff,
@@ -34,10 +35,10 @@ chdr_ctrl_xport::chdr_ctrl_xport(io_service::sptr io_srv,
recv_link_if* /*recv_link*/,
send_link_if
* /*send_link*/) -> bool {
- uint64_t* data = (uint64_t*)buff->data();
- auto hdr = chdr_header(uhd::ntohx<uint64_t>(*data));
- auto pkt_type = hdr.get_pkt_type();
- auto dst_epid = hdr.get_dst_epid();
+ _recv_packet->refresh(buff->data());
+ auto hdr = _recv_packet->get_chdr_header();
+ auto pkt_type = hdr.get_pkt_type();
+ auto dst_epid = hdr.get_dst_epid();
/* Check type and destination EPID */
if ((pkt_type == PKT_TYPE_CTRL) && (dst_epid == _my_epid)) {
@@ -59,10 +60,10 @@ chdr_ctrl_xport::chdr_ctrl_xport(io_service::sptr io_srv,
recv_link_if* /*recv_link*/,
send_link_if
* /*send_link*/) -> bool {
- uint64_t* data = (uint64_t*)buff->data();
- auto hdr = chdr_header(uhd::ntohx<uint64_t>(*data));
- auto pkt_type = hdr.get_pkt_type();
- auto dst_epid = hdr.get_dst_epid();
+ _recv_packet->refresh(buff->data());
+ auto hdr = _recv_packet->get_chdr_header();
+ auto pkt_type = hdr.get_pkt_type();
+ auto dst_epid = hdr.get_dst_epid();
/* Check type and destination EPID */
if ((pkt_type == PKT_TYPE_MGMT) && (dst_epid == _my_epid)) {