Commit graph

88 commits

Author SHA1 Message Date
Joerg Hofrichter
11091cb4f7 mpm: rpc_server: cast get_device_info/get_mbeeprom params to n/a
ensure the map contains only string values otherwise it cannot be
casted to std::map<string, string> in C++
2024-05-03 14:34:39 +02:00
Grant Meyerhoff
78156eabfa mpm: move pop_host_tasks to PeriphManagerBase
Move pop_host_tasks function call from just x4xx to all MPM devices so it can be safely called from mpmd_mboard_impl
2023-09-06 10:09:36 -05:00
Martin Anderseck
b3b5e69b02 SelfCal: Trigger if clocking has changed
This change ensures that ADC selfcal is triggered during session start
if the clocking was reconfigured. So it saves time if several
consecutive sessions are opened with always the same settings.
It also makes the ADC self cal run if in an open session either
set_clock_source(), set_time_source() or set_sync_source() are called
and a clock reconfiguration was triggered by that.
2023-07-07 12:35:55 -07:00
Martin Braun
371c4c139c mpm: Add support for X440/FBX
Co-authored-by: Lars Amsel <lars.amsel@ni.com>
Co-authored-by: Martin Anderseck <martin.anderseck@ni.com>
Co-authored-by: Virendra Kakade <virendra.kakade@ni.com>
Co-authored-by: Javier Valenzuela <javier.valenzuela@ni.com>
2023-06-12 10:27:29 -05:00
Martin Braun
e08d827346 mpm: Bump compat number to 5.0
This covers the two recent changes:
- Moving the get-rate API into the daughterboard
- Add the new synchronization procedure
2023-03-24 16:08:30 -07:00
David Raeman
8cb6699772 e320: Allow internal GPSDO to be powered-down via UHD session args
Currently the E320's integrated GPSDO can be disabled using the
"enable_gps" argment at MPM initialization time (e.g. when the radio
powers on and launches the MPM daemon). However, there is no way for
a UHD application to disable the GPSDO at connection time.

This patch allows the existing "enable_gps" arg to be accepted when
initiating an MPM session from UHD, such that an application can pass
the arg "enable_gps=0" at connection time to disable the GPSDO. The
default power state of the GPSDO is restored when the session ends.

Edit: On top of the original commit by draeman-synoptic, the MPM minor
compat number was also increased to denote new non-breaking feature
support.

Co-authored-by: mattprost <matt.prost@ni.com>
Signed-off-by: mattprost <matt.prost@ni.com>
2022-11-16 09:51:57 -06:00
mattprost
ba1d4bfaf7 mpm: Add a lock to the rpc server timer
This prevents any concurrency issues that might arise from killing and
spawning a new timer in the rpc server.

Signed-off-by: mattprost <matt.prost@ni.com>
2022-10-20 10:12:21 -05:00
mattprost
458f73b195 mpm: rpc server: Capture claim token value before releasing state lock
This removes the race condition that can occur by reading the value of
the rpc server's shared state claim token value without a lock. After
the lock is released, it is possible that another process could preempt
and modify the value with a different claim operation. Also, added
timeouts to acquire the shared state lock for claim, reclaim, and
unclaim operations.

Signed-off-by: mattprost <matt.prost@ni.com>
2022-10-20 10:12:21 -05:00
mattprost
cf0c6b5a13 mpm: Fix rpc process shared state and port argument positions
The rpc_server_process was spawning with its parameters reversed. The
calling function also had its parameters reversed, so this is
functionally the same. This change makes sure that the parameters are
aligned with the arguments throughout the callstack.

Signed-off-by: mattprost <matt.prost@ni.com>
2022-10-20 10:12:21 -05:00
Martin Braun
4d6b7263f5 Revert "uhd: Revert Raw UDP Host Changes"
This reverts commit 6cb1dcca83.

Raw UDP support is added back in on both MPM and UHD side.
2022-09-21 15:35:55 -07:00
Steven Koo
6cb1dcca83 uhd: Revert Raw UDP Host Changes
This reverts the Raw UDP host changes which is breaking
multiple interface streaming.

Commits addb81aa5d2d6adcd3a0c7a8d59fcd96af0c1ec4^..b1ca51f97aaa2226ed6ef339fb26fbea54ab7593
are reverted.

Reverts:
doc: Update manual on streaming
examples: Add remote RX streaming example
rfnoc: Enable remote UDP streaming
mpm: e320: Enable raw UDP streaming
mpm: n3xx: Enable raw UDP streaming
mpm: x4xx: Enable transport manager adapter
mpm: Enable opt-in transport adapter control
rfnoc: Transition stream managers and mgmt_portal to topo_graph_t
rfnoc: Add topology graph object
uhd/mpm: Add API to set remote routes
mpm: xports: Add XportAdapterMgr class
2022-09-12 17:00:19 -05:00
Martin Braun
40b66c9e56 uhd/mpm: Add API to set remote routes
This is an addition to both PeriphManagerBase (MPM) and mb_iface (UHD).
Main changes:

- Addition of mb_iface::add_remote_chdr_route() and
  mb_iface::get_chdr_xport_adapters()
- In X3x0, these APIs are stubbed out.
- In mpmd, these APIs are implemented and call the new MPM APIs (see
  below)
- Addition of PeriphManagerBase.add_remote_chdr_route() and
  PeriphManagerBase.get_chdr_xport_adapters()
- The PeriphManagerBase implements these APIs fully when the
  'remote_udp_streaming' FPGA feature is detected.
- The MPM compat number is bumped to 4.3. UHD will continue to work with
  lower compat numbers. It will query the compat number and act
  accordingly.
2022-08-30 13:43:36 -05:00
mattprost
b8acf58798 n310: Add Filter API to n310
Add the Filter API to n3xx specifically for the AD937x device.  The TX
filter is limited to 32 taps, and the RX filter is limited to 48 taps.

This feature requires MPM version 4.2 or later on the device.

Co-authored-by: bpadalino <bpadalino@gmail.com>
Signed-off-by: mattprost <matt.prost@ni.com>
2022-04-07 13:28:02 -07:00
mattprost
a8ad4917d3 n310: Add frontend bandwidth control
Allow users to control the Mykonos frontend bandwidth settings for
Rx and Tx. Note that this operation requires the daughterboard to
re-initialize, so it may take some time. Values for frontend filter
settings were derived using ADI's AD9371 Filter Wizard.

This feature requires MPM version 4.1 or later on the device.

Co-authored-by: bpadalino <bpadalino@gmail.com>
Signed-off-by: mattprost <matt.prost@ni.com>
2022-04-07 13:28:02 -07:00
Lars Amsel
6e2a65e700 mpm: add device name to discovery process
MPM devices currently do not report their device name in the discovery
process. This adds the device name. After the change the device name
is reported, e.g. when using uhd_find_devices, like so:

    $> uhd_find_devices
    --------------------------------------------------
    -- UHD Device 0
    --------------------------------------------------
    Device Address:
        serial: DEADBEEF
        claimed: False
        fpga: X4_200
        mgmt_addr: <mpm device ip>
        name: <mpm device host name>
        product: x410
        type: x4xx
2022-02-08 13:55:35 -06:00
Lane Kolbly
19f55a9d4a mpm: Bump MPM compat version to 4.0 2021-06-24 13:52:15 -05:00
Michael Dickens
93bed45f48 mpm: add FPGA type to the info returned during discovery
Also update this info upon server reset, such as when a new FPGA image is loaded
2021-05-20 14:57:47 -05:00
Martin Braun
bb22f3bebb mpm: Fix minor log formatting issue 2021-04-27 15:01:53 -05:00
Grant Meyerhoff
b1e4e7f4df fixup! mpm: rpc: don't expose reset_mgr call via RPC 2021-04-22 15:09:40 -05:00
Thomas Vogel
2000bbf17e mpm: rpc: don't expose reset_mgr call via RPC 2021-03-11 09:29:31 -06:00
Toni Jones
5fc01186d3 mpm: rpc: Use contextmanager for claim timeouts
Modify the RPC claim timeout mechanism to use a contextmanager
helper function when enabling/disabling timeouts.
2021-03-04 12:13:13 -06:00
Lars Amsel
ecbb24505d MPM: prevent dead lock in timer kill during unclaim
MPM server needs to be reclaimed in regular intervals. This is
monitored by the server using a timer. If the timer hits, the server
unclaims itself assuming the client process died for whatever
reason. In previous versions of `gevent.greenlet` the timer was
killed in a non blocking manner. This changed in version 0.13.0
(see
http://www.gevent.org/api/gevent.greenlet.html#gevent.Greenlet.kill)
which now leads to a dead lock in `timer.kill`. The kill command
is therefore now called explicitly with `block=False`.
2021-02-18 07:26:05 -06:00
Virendra Kakade
91073787b1 mpm: Add support to safely reset peripheral manager from uhd
Provide a way to safely reset the peripheral manager from uhd and as
a result, a mechanism to reload the fpga/dts components.

Signed-off-by: Virendra Kakade <virendra.kakade@ni.com>
2021-02-18 07:25:46 -06:00
Virendra Kakade
fab4a5dd17 mpmd: Add support to delay and trigger fpga/dts load after update
Add a new image_loader argument delay_reload to provide a way to update
components but optionally delay the actual load.
Similarly add a new argument, just_reload, to enable uhd to reload
the fpga/dts components.

Signed-off-by: Virendra Kakade <virendra.kakade@ni.com>
2021-01-11 13:18:22 -06:00
Martin Braun
3b9ced8f07 mpm: rpc server: Fix unclaim sequence
Sequence is now:
1. Get _state lock
2. Kill reclaim timeout
3. Run deinit sequence
4. Clear claim token and session ID
5. Release _state lock

Before, we were not locking the mutex, and the timer was killed after
the deinit sequence. If the deinit sequence stalls for whatever reason,
that doesn't have to cause a claimer loss to be reported. UHD will
already have stopped the reclaim loop before unclaim() is called.

In the stall case, it would also have been possible the to acquire a new
claim while the deinit() is still running. This is prevented with the
combination of actually acquiring the mutex (like claim() and reclaim()
do) and moving the token/session ID clearing to the end.
2020-12-21 15:28:24 -08:00
Martin Braun
d72041827a mpm: rpc server: Remove Python2 compat code
MPM is Python3-only, but contains some remaining compatibility code for
Python2. Because this code requires extra dependencies (like six) and
could become obsolete in the future, we remove it to preempt that.

No functional changes.
2020-12-08 16:08:48 -08:00
Joerg Hofrichter
eaf0062254 mpm: rpc_server: fix get_log_buf for MPM Shell
Fix the issue that the method 'get_log_buf' was not accessible from
MPM Shell.
2020-12-04 12:08:13 -08:00
Samuel O'Brien
1bb603fffd mpm: Cleanup rpc_server.py
This commit fixes a spelling mistake, moves logic for checking if a
connection is local to its own method, and calls gevent.signal.signal
instead of its deprecated alias gevent.signal.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-07 15:29:19 -05:00
Samuel O'Brien
97852aba23 mpm: Fix gevent errors on SIGTERM
Sometimes when running usrp_hwd.py in a terminal and then canceling it
with Ctrl+C, it prints a really large stacktrace into the terminal
resulting from an uncaught gevent BlockingSwitchOutError. It seems like
there was an attempt to catch this in usrp_hwd.py:kill_time(). This
try-except was surrounding a call to Process.join() which, to the best
of my knowledge, can't ever throw this exception.

Based on my troubleshooting, this error comes from the SIGTERM signal
handler of the RPC process. The handler (defined in
rpc_server.py:_rpc_server_process), is just a direct call to
RPCServer.stop(). When the server's backed is a thread pool, this call
may block when joining the thread pool, causing gevent to complain about
execution attempting to block in a signal handler.

This commit resolves this issue by simply triggering an event in the
signal handler which prompts a different thread to clean up the server
and end the process.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-24 15:26:36 -05:00
Aaron Rossetto
ad707ab22d mpm, mpmd: Bump MPM compat number 2020-07-24 15:24:14 -05:00
Joerg Hofrichter
9a45d4449f mpm: rpc_server: set correct default unpacker params for msgpack 0.6.1
msgpack 0.6.1 suggests new default parameters which ensures compatibility
with the upcoming msgpack 1.0 release which will have breaking changes.

The parameter changes are described in
https://github.com/msgpack/msgpack-python/blob/v0.6.1/README.rst

The default parameters for msgpack 1.0 will be:
- packer: use_bin_type=True
- unpacker: raw=False

The packer use_bin_type=True option is already set in the client
(mpm_shell.py) but the unpacker option raw=False needs to be set
in the server (rpc_server.py)

This change allows the usage of a patched version of python3-mprpc
0.1.17 which removes passing the encoding option to the Packer and
Unpacker

Signed-off-by: Joerg Hofrichter <joerg.hofrichter@ni.com>
2020-03-05 12:07:25 -06:00
Andrew Lynch
5e7a2458a8 mpm: explicitly set max buffer size for msgpack unpacker
Msgpack version 0.6 reduced the default max buffer size to 1MB which is
smaller than the bitfiles. This change sets the max buffer size to 50MB
which is larger than the bitfiles.
2020-03-05 12:07:25 -06:00
Toni Jones
f73f608d95 mpm: rpc: Use contextmanager for claim timeouts
Modify the RPC claim timeout mechanism to use a contextmanager
helper function when enabling/disabling timeouts.
2020-03-03 08:52:34 -06:00
Martin Braun
d60e4d87d8 mpm: Clean up code, improve Pylint score
Many small cleanups:
- Fix copyright headers
- Fix superfluous imports
- Pull some constants out of classes where appropriate
- Fix formatting
- Improve/fix some docstrings
- Disable specific Pylint warnings where appropriate
- Global catches use BaseException instead of Exception
- Don't use len() for empty checks
- Make sure to declare all self attributes in __init__ (note: this is
  particularly of interest for E310, becuase its regular init happens
  outside of __init__)
- Compacted some E310 code that had multi-DB checks
2019-11-26 12:21:33 -08:00
Martin Braun
c256b9df65 x300/mpmd: Port all RFNoC devices to the new RFNoC framework
Co-Authored-By: Alex Williams <alex.williams@ni.com>
Co-Authored-By: Sugandha Gupta <sugandha.gupta@ettus.com>
Co-Authored-By: Brent Stapleton <brent.stapleton@ettus.com>
Co-Authored-By: Ciro Nishiguchi <ciro.nishiguchi@ni.com>
2019-11-26 12:16:25 -08:00
Martin Braun
9d75460d36 mpm: rpc_server: Reenable timeouts after components have been updated
When updating a component like the FPGA, the timeouts for reclaiming get
disabled, because the update can potentially take a long time, during
which the RPC server might not be available.
There was a bug that didn't re-enable the timeouts. The most common case
where this causes issues was when the Ethernet connection was severed
during FPGA reloading, which could lead to UHD losing connection with
MPM altogether (for example because SFPs would come up with a different
IP address). In that case, MPM would remain unreachable until the next
reboot.
2019-10-28 14:39:16 -07:00
Sugandha Gupta
178b35569b e310/e320: Move E310 to MPM architecture and refactor
- Turns the E310 into an MPM device (like N3xx, E320)
- Factor out common code between E320 and E310, maximize sharing between
  the two devices
- Remove all pre-MPM E310 code that is no longer needed
- Modify MPM to remove all existing overlays before applying new ones
  (this is necessary to enable idle image mode for E310)

Co-authored-by: Virendra Kakade <virendra.kakade@ni.com>
Signed-off-by: Virendra Kakade <virendra.kakade@ni.com>
2019-05-01 15:17:23 -07:00
Martin Braun
435a1f13b8 mpm: rpc_server: Improve error message on double-claim
The error message will now include the IP address of the client trying
to double-claim a device.
2019-02-22 16:12:23 -08:00
Brent Stapleton
191e250827 mpm: reset the RPC server upon reload
When reloading the Periph Manager (as when we run the image loader),
we need to run the RPCServer `__init__` function in order to reset the
cache of RPC methods. Otherwise, that cache keeps stale references to
old functions (and prevents garbage collection).

It may be possible to reset the method cache some other way, but the
`_methods` attribute of RPCServer is Cython, and doesn't seem to be
accessible in our Python code.
2018-08-27 18:14:23 -07:00
Trung Trang
0f7d3b6f71 mpm: rpc server: Remove disable_commit for init()
The async calls to long C++ methods allows the claimer loop to smoothly
continue during init, so this hack is no longer necessary.
2018-04-30 14:36:29 -07:00
Trung Trang
bd14776500 mpm: rpc server: Increase claim timeout to 5 seconds
Usually, the current timeout is fine, but there are cases when a lot of
RPC traffic could drown out the reclaim calls. 5 seconds is an
experimentally derived safe value.
2018-04-30 14:36:29 -07:00
Trung N Tran
6e66bd7d7b mpm: increase timeout interval for claiming 2018-04-02 14:57:21 -07:00
Trung N Tran
4e34d35ec4 mpm: improve logging on exception 2018-03-30 11:05:53 -07:00
Martin Braun
86b95486ed mpm: Add INFO log statements on MPM reset and component update 2018-03-13 16:19:03 -07:00
Martin Braun
725debb964 mpm: Rename n310 to n3xx
This module (and class) are, in fact, used for all N3xx-derivates so
renaming it is the more correct thing to do.
2018-03-05 15:56:41 -08:00
Martin Braun
d04b6e3a62 mpm: uhd: RPC server reports MPM version, uhd_usrp_probe reads it 2018-03-02 13:48:14 -08:00
Brent Stapleton
94aedfd2d9 mpm: adding get_component_info
Add getter function for updateable component information. This is a
minor compat number bump.
2018-02-19 16:58:52 -08:00
Martin Braun
e9288a439c mpm: Update all license headers
- Fix typo in company name (missing 'a')
- Updated SPDX license identifier to version 3.0
2018-02-19 16:55:08 -08:00
Martin Braun
832cbe095a mpm: Use prefs API for periph manager
- Allow to set default args via config file
- Read them from prefs API
- override-db-pids uses the same APIs now ([overrides] section in
  config file, prefs API, and same dictionary as --default-args when
  used on the command line
2018-02-08 22:18:14 +01:00
Martin Braun
0d73d8ab81 mpm: rpc_server: Declare local connection for *all* local IPs
Before, it was possible to trick the RPC server in believing a
connection was remote when the incoming connection was from a local IP
address that was not 127.0.0.1.
2018-02-07 13:46:53 -08:00