From 83dd47dc882421f96830fa55bd86405d1d80907f Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Wed, 3 Jan 2018 15:05:48 -0800 Subject: mpmd: Allow user-overrides for MPM ports Adds two device args: discovery_port and rpc_port. Both are integers which override the respective constants. Reviewed-by: Ashish Chaudhari --- host/lib/usrp/mpmd/mpmd_impl.cpp | 12 +++++++++++- host/lib/usrp/mpmd/mpmd_impl.hpp | 14 ++++++++++---- host/lib/usrp/mpmd/mpmd_mboard_impl.cpp | 6 +++++- host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp | 8 ++++++-- 4 files changed, 32 insertions(+), 8 deletions(-) (limited to 'host/lib/usrp/mpmd') diff --git a/host/lib/usrp/mpmd/mpmd_impl.cpp b/host/lib/usrp/mpmd/mpmd_impl.cpp index 8586aa3a9..ff1e0498d 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_impl.cpp @@ -309,6 +309,10 @@ namespace { /***************************************************************************** * Static class attributes ****************************************************************************/ +const size_t mpmd_impl::MPM_DISCOVERY_PORT = 49600; +const std::string mpmd_impl::MPM_DISCOVERY_PORT_KEY = "discovery_port"; +const size_t mpmd_impl::MPM_RPC_PORT = 49601; +const std::string mpmd_impl::MPM_RPC_PORT_KEY = "rpc_port"; const std::string mpmd_impl::MPM_RPC_GET_LAST_ERROR_CMD = "get_last_error"; const std::string mpmd_impl::MPM_DISCOVERY_CMD = "MPM-DISC"; const std::string mpmd_impl::MPM_ECHO_CMD = "MPM-ECHO"; @@ -532,10 +536,16 @@ size_t mpmd_impl::allocate_xbar_local_addr() device_addrs_t mpmd_find_with_addr(const std::string& mgmt_addr, const device_addr_t& hint_) { UHD_ASSERT_THROW(not mgmt_addr.empty()); + const std::string mpm_discovery_port = hint_.get( + mpmd_impl::MPM_DISCOVERY_PORT_KEY, + std::to_string(mpmd_impl::MPM_DISCOVERY_PORT) + ); + UHD_LOG_DEBUG("MPMD", + "Discovering MPM devices on port " << mpm_discovery_port); device_addrs_t addrs; transport::udp_simple::sptr comm = transport::udp_simple::make_broadcast( - mgmt_addr, std::to_string(mpmd_impl::MPM_DISCOVERY_PORT)); + mgmt_addr, mpm_discovery_port); comm->send( boost::asio::buffer( mpmd_impl::MPM_DISCOVERY_CMD.c_str(), diff --git a/host/lib/usrp/mpmd/mpmd_impl.hpp b/host/lib/usrp/mpmd/mpmd_impl.hpp index 14051c922..79ab18aa3 100644 --- a/host/lib/usrp/mpmd/mpmd_impl.hpp +++ b/host/lib/usrp/mpmd/mpmd_impl.hpp @@ -146,10 +146,16 @@ class mpmd_mboard_impl class mpmd_impl : public uhd::usrp::device3_impl { public: - //! Port on which the discovery process is listening - static const size_t MPM_DISCOVERY_PORT = 49600; - //! Port on which the RPC process is listening - static const size_t MPM_RPC_PORT = 49601; + //! Port on which the discovery process is listening (default value, it is + // user-overridable) + static const size_t MPM_DISCOVERY_PORT; + //! Device arg key to override the discovery port + static const std::string MPM_DISCOVERY_PORT_KEY; + //! Port on which the RPC process is listening (default value, it is user- + // overridable) + static const size_t MPM_RPC_PORT; + //! Device arg key to override the RPC port + static const std::string MPM_RPC_PORT_KEY; //! This is the command that needs to be sent to the discovery port to // trigger a response. static const std::string MPM_DISCOVERY_CMD; diff --git a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp index 087cb1373..3702c15a1 100644 --- a/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp +++ b/host/lib/usrp/mpmd/mpmd_mboard_impl.cpp @@ -96,6 +96,7 @@ namespace { using namespace uhd; using namespace uhd::mpmd; + /***************************************************************************** * Structors ****************************************************************************/ @@ -105,7 +106,10 @@ mpmd_mboard_impl::mpmd_mboard_impl( ) : mb_args(mb_args_) , rpc(uhd::rpc_client::make( rpc_server_addr, - mpmd_impl::MPM_RPC_PORT, + mb_args_.cast( + mpmd_impl::MPM_RPC_PORT_KEY, + mpmd_impl::MPM_RPC_PORT + ), mpmd_impl::MPM_RPC_GET_LAST_ERROR_CMD)) , _xport_mgr(xport::mpmd_xport_mgr::make(mb_args)) { diff --git a/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp b/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp index 4d1306f82..3b02073c5 100644 --- a/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp +++ b/host/lib/usrp/mpmd/mpmd_xport_ctrl_udp.cpp @@ -159,10 +159,14 @@ mpmd_xport_ctrl_udp::mpmd_xport_ctrl_udp( , _available_addrs(get_addrs_from_mb_args(mb_args)) , _mtu(MPMD_10GE_DATA_FRAME_MAX_SIZE) { - auto discover_mtu_for_ip = [](const std::string &ip_addr){ + const std::string mpm_discovery_port = _mb_args.get( + mpmd_impl::MPM_DISCOVERY_PORT_KEY, + std::to_string(mpmd_impl::MPM_DISCOVERY_PORT) + ); + auto discover_mtu_for_ip = [mpm_discovery_port](const std::string &ip_addr){ return discover_mtu( ip_addr, - std::to_string(mpmd_impl::MPM_DISCOVERY_PORT), + mpm_discovery_port, IP_PROTOCOL_MIN_MTU_SIZE-IP_PROTOCOL_UDP_PLUS_IP_HEADER, MPMD_10GE_DATA_FRAME_MAX_SIZE, MPMD_MTU_DISCOVERY_TIMEOUT -- cgit v1.2.3