aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/x300/x300_impl.cpp
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-08-13 15:28:13 -0700
committerMartin Braun <martin.braun@ettus.com>2019-08-16 13:42:02 -0700
commit3d157e09f642caa7a5d48c71468b444d0566cf8d (patch)
treeb29219cb40d3f887d97a068d4a6e45c5ce2b5a65 /host/lib/usrp/x300/x300_impl.cpp
parentbbb869ca80fa299f7888b35134218229521dd0c0 (diff)
downloaduhd-3d157e09f642caa7a5d48c71468b444d0566cf8d.tar.gz
uhd-3d157e09f642caa7a5d48c71468b444d0566cf8d.tar.bz2
uhd-3d157e09f642caa7a5d48c71468b444d0566cf8d.zip
x300: Introduce conn_manager
This is a superclass to eth_manager and pcie_manager, since they usually do the same thing. This saves storing and passing multiple pointers. Also, x300_impl now stores a shared_ptr of the conn_manager, because we'll need to pass it around in the future.
Diffstat (limited to 'host/lib/usrp/x300/x300_impl.cpp')
-rw-r--r--host/lib/usrp/x300/x300_impl.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp
index 59ba1153b..0283cf659 100644
--- a/host/lib/usrp/x300/x300_impl.cpp
+++ b/host/lib/usrp/x300/x300_impl.cpp
@@ -8,9 +8,11 @@
#include "x300_impl.hpp"
#include "x300_claim.hpp"
+#include "x300_eth_mgr.hpp"
#include "x300_mb_eeprom.hpp"
#include "x300_mb_eeprom_iface.hpp"
#include "x300_mboard_type.hpp"
+#include "x300_pcie_mgr.hpp"
#include <uhd/transport/if_addrs.hpp>
#include <uhd/types/sid.hpp>
#include <uhd/usrp/subdev_spec.hpp>
@@ -216,14 +218,11 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t& dev_addr)
UHD_LOGGER_DEBUG("X300") << "Setting up basic communication...";
if (mb.xport_path == xport_path_t::NIRIO) {
- mb.pcie_mgr =
- std::unique_ptr<pcie_manager>(new pcie_manager(mb.args, _tree, mb_path));
- mb.zpu_ctrl = mb.pcie_mgr->get_ctrl_iface();
+ mb.conn_mgr = std::make_shared<pcie_manager>(mb.args, _tree, mb_path);
} else {
- mb.eth_mgr =
- std::unique_ptr<eth_manager>(new eth_manager(mb.args, _tree, mb_path));
- mb.zpu_ctrl = mb.eth_mgr->get_ctrl_iface();
+ mb.conn_mgr = std::make_shared<eth_manager>(mb.args, _tree, mb_path);
}
+ mb.zpu_ctrl = mb.conn_mgr->get_ctrl_iface();
// Claim device
if (not try_to_claim(mb.zpu_ctrl)) {
@@ -330,9 +329,10 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t& dev_addr)
// discover interfaces, frame sizes, and link rates
////////////////////////////////////////////////////////////////////
if (mb.xport_path == xport_path_t::NIRIO) {
- mb.pcie_mgr->init_link();
+ std::dynamic_pointer_cast<pcie_manager>(mb.conn_mgr)->init_link();
} else if (mb.xport_path == xport_path_t::ETH) {
- mb.eth_mgr->init_link(mb_eeprom, mb.loaded_fpga_image);
+ std::dynamic_pointer_cast<eth_manager>(mb.conn_mgr)
+ ->init_link(mb_eeprom, mb.loaded_fpga_image);
}
////////////////////////////////////////////////////////////////////
@@ -537,7 +537,8 @@ x300_impl::~x300_impl(void)
// kill the claimer task and unclaim the device
mb.claimer_task.reset();
if (mb.xport_path == xport_path_t::NIRIO) {
- mb.pcie_mgr->release_ctrl_iface([&mb]() { release(mb.zpu_ctrl); });
+ std::dynamic_pointer_cast<pcie_manager>(mb.conn_mgr)
+ ->release_ctrl_iface([&mb]() { release(mb.zpu_ctrl); });
} else {
release(mb.zpu_ctrl);
}
@@ -565,16 +566,19 @@ uhd::both_xports_t x300_impl::make_transport(const uhd::sid_t& address,
xports.send_sid =
this->allocate_sid(mb, address, x300::SRC_ADDR0, x300::XB_DST_PCI);
xports.recv_sid = xports.send_sid.reversed();
- return mb.pcie_mgr->make_transport(xports, xport_type, args, send_mtu, recv_mtu);
+ std::dynamic_pointer_cast<pcie_manager>(mb.conn_mgr)
+ ->make_transport(xports, xport_type, args, send_mtu, recv_mtu);
} else if (mb.xport_path == xport_path_t::ETH) {
- xports = mb.eth_mgr->make_transport(xports,
- xport_type,
- args,
- send_mtu,
- recv_mtu,
- [this, &mb, address](const uint32_t src_addr, const uint32_t src_dst) {
- return this->allocate_sid(mb, address, src_addr, src_dst);
- });
+ xports = std::dynamic_pointer_cast<eth_manager>(mb.conn_mgr)
+ ->make_transport(xports,
+ xport_type,
+ args,
+ send_mtu,
+ recv_mtu,
+ [this, &mb, address](
+ const uint32_t src_addr, const uint32_t src_dst) {
+ return this->allocate_sid(mb, address, src_addr, src_dst);
+ });
// reprogram the ethernet dispatcher's udp port (should be safe to always set)
UHD_LOGGER_TRACE("X300")
@@ -818,10 +822,7 @@ bool x300_impl::is_pps_present(mboard_members_t& mb)
size_t x300_impl::get_mtu(const size_t mb_index, const uhd::direction_t dir)
{
auto& mb = _mb.at(mb_index);
- if (mb.xport_path == xport_path_t::NIRIO) {
- return mb.pcie_mgr->get_mtu(dir);
- }
- return mb.eth_mgr->get_mtu(dir);
+ return mb.conn_mgr->get_mtu(dir);
}
/***********************************************************************