Commit graph

622 commits

Author SHA1 Message Date
Toni Jones
f11fa1bff7 mpm: Create Mock classes for unit testing
Create Mock classes which mimic the behavior of a register interface
and logger to facilitate unit testing needs.
2021-02-18 07:25:34 -06:00
Michael Auchter
5ef29d9396 mpm: deduplicate dboard eeprom handling
The _get_dboard_eeprom_info implementations are the same with the
exception of how the dboard eeprom is actually read. Break that out into
a _read_dboard_eeprom method to reduce code duplication.

The base class now defines a lambda expression for the eeprom reader
which can be changed in subclasses.

Co-authored-by: Lars Amsel <lars.amsel@ni.com>
Co-authored-by: Michael Auchter <michael.auchter@ni.com>
2021-02-11 12:26:10 -06:00
Joerg Hofrichter
9ffdd46974 mpm: added DBFlash class
Class for accessing (mounting) the daughterboard flash
2021-02-11 07:19:14 -06:00
Joerg Hofrichter
3f3006e0b4 mpm: added Mount class
Class for creating a mount point
2021-02-11 07:18:45 -06:00
Michael Auchter
fa6e7a7430 mpm: filesystem_status: tolerate absence of mender
If the mender utility is not installed or exits with a failure, return
NULL for the artifact rather than raising an exception (and disrupting
device initialization).
2021-02-09 07:36:08 -06:00
Lane Kolbly
5471a1f521 mpm: Implement get_sync_source and get_sync_sources. 2021-01-25 15:27:49 -06:00
Aaron Rossetto
7b43614846 sim: Ignore mender artifact file on sim devices 2021-01-21 12:47:54 -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
Joerg Hofrichter
f96ffb2218 fixup! mpm: Use prefs API in logging module 2020-12-04 12:07:16 -08:00
Aaron Rossetto
e9d7100b10 sim: Check for unit test prereqs and disable if unsatisfied 2020-10-28 15:25:48 -05:00
Samuel O'Brien
0003d990bb sim: Move SelectableQueue and SendWrapper
This commit moves these two classes from chdr_stream.py to
chdr_endpoint.py.

ChdrEndpoint needs to be aware of the specific implementation of these
classes, while ChdrInputStream and ChdrOutputStream treats them like
black boxes. Therefore, it makes more sense to have these classes
together with ChdrEndpoint

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
a5091cd526 sim: Support Out of Tree Sources and Sinks
This commit adds the ability to specify a path to an arbitrary python
file in a simulator config file, which will be imported and used to
construct a SampleSink or SampleSource for use with data streaming.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
a56f4f63e2 sim: Implement Sim > UHD Flow Control
This commit adds flow control support when streaming data from the
Simulator to UHD. It no longer ignores STRS packets.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
5df8202c0c sim: Move Hardware Specific to Config File
This commit moves various magic numbers and hardware specific settings
into the configuration file. It also provides default presets for said
configuration files which can be inherited from.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
687ed5bba0 sim: Implement UHD > Simulator Flow Control
When sending data to the simulator, python simply cannot process the
data as fast as UHD can send it. Flow control ensures that uhd doesn't
overwhelm the simulator. Simulator > UHD flow control isn't implemented
yet.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
e4517deef3 sim: Support Timed Streams
The only difference between a standard and timed stream is that the
first data packet of a timed stream contains a timestamp. This commit
adds the necessary fields to StreamSpec to accomplish this.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
00c306d5c4 sim: Integrate simulator into UHD
This commit adds a device::register_device which allows uhd to start up
a simulator when uhd is called with the arguments type=sim. Creating the
device object creates a subprocess using pybind and an embedded
interpreter, and destroying the object cleans up those subprocesses.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
bd278a4b93 sim: Support Configuration Files
This commit adds support for configuration files to the simulator. As of
now, these files only change the source and sink of data samples, but
they are easily extensible to add more configuration to the simulator.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Samuel O'Brien
d42ddc8041 sim: Support Streaming
This commit add support for both Tx and Rx streams to the simulator.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-28 15:25:48 -05:00
Lane Kolbly
31872fa3b9 mpm: Add dependency on pyusrp_periphs to MPM
This change makes it so that changing the USRP periphs will cause a
`make install` to reinstall the libpyusrp_periphs.so library.
2020-10-15 07:51:52 -05:00
Samuel O'Brien
267365c945 sim: Clarify Naming of Streams
ChdrSniffer is renamed to ChdrEndpoint to clarify its function as the
actual destination of chdr packets, rather than just an observer.
TxWorker has been renamed to OutputStream and RxWorker has been renamed
to InputStream to avoid ambiguities regarding Tx and Rx terminology.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-08 07:44:12 -05:00
Samuel O'Brien
ee9085a494 sim: Simulator CHDR Parsing and RFNoC Graph
This commit adds a simulated RFNoC Graph to the simulator. It is also
able to process management and control packets which can traverse the
graph and read from simulated registers. Stub callbacks for creating
streams have been provided but are not implemented yet.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-08 07:44:12 -05:00
Samuel O'Brien
f54a22c60a sim: Embed MPM into libpyuhd
When ENABLE_SIM and ENABLE_PYTHON_API are set, this commit embeds MPM
(Built with -DMPM_DEVICE=sim) into the pyuhd package.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-07 15:29:19 -05:00
Samuel O'Brien
bfff8b79b9 sim: Add Daughterboard Methods
This commit adds daughterboard simulation to the simulator. There is a
sim_dboard class which registers it's methods with the rpc server. These
methods are visible over mpm as well as the mpm_shell.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-07 15:29:19 -05:00
Samuel O'Brien
6394a7c6ea sim: Lay Groundwork for Simulator
At this point, only about half of the mpm methods work on the simulator
    over the mpm shell, and it hasn't been tested with uhd at all.
    If you want to give it a try, first install all of the python
    dependencies of mpm (The simulator doesn't require libusrp or any of
    the C++ deps). In addition, running mpm on a desktop machine requires
    the python lib netifaces. Next, make an /mpm/build directory and open
    it. Run `cmake .. -DMPM_DEVICE=sim`, then `make`. Finally, run
    `python3 python/usrp_hwd.py`. You should be able to open another
    terminal and run `mpm/tools/mpm_shell.py localhost` to connect to the
    mpm server.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-07 15:29:19 -05: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
Joerg Hofrichter
a37413055e mpm: use filesystem_status from sys_utils
Use the utility functions for getting the filesystem version string
and for getting the Mender artifact which are now available in
usrp_mpm.sys_utils.
2020-10-06 15:21:27 -05:00
Joerg Hofrichter
86cadf12c5 mpm: added check-filesystem utility 2020-10-06 15:21:27 -05:00
Steven Koo
be53058a47 mpm: e31x: Accept FF terminated strings in eeprom
Older revisions of the e31x used FF terminated strings in the EEPROM.
The eeprom implementation didn't take this into account and would
fail on ascii conversion. This change resolves mpm bring up on the
older revisions by replacing FF with null. This didn't affect newer
revisions because they used null terminated strings.

Signed-off-by: Steven Koo <steven.koo@ni.com>
2020-09-04 11:38:27 -07:00
mattprost
3d5d136534 mpm: Return 10 Gbs link speed on failure
The sysfs call used to determine link speed occasionally will fail and
return -1. In order to mitigate side effects from this behavior, return
10 Gbs link speed instead of 1 Gbs. This mitigates problems that occur
when this issue is seen on 10GbE ports. This approach was elected over
returning -1 to be handled on the host side in order to avoid breaking
mpm compatibility.

Signed-off-by: ettus <matt.prost@ni.com>
2020-09-01 15:19:30 -05:00
Steven Koo
92b2127909 mpm: exclude internal nic for network hosts
Sometimes the internal nic address is routable in network mode. This
causes mpm find to incorrectly set it as the addr. This commit removes
the internal interfaces from the routable list. This also sets the
forwarding interface as the last resort. mpm will prefer the SFP ports
since they can be higher throughput.

Signed-off-by: Steven Koo <steven.koo@ni.com>
2020-08-19 18:05:10 -05:00
Martin Braun
31cafbb3ed rh: Enable inverse sinc filter for DAC37J82
This enables the inv_sinc_ab and inv_sinc_cd flags for the DAC,
turning on the inverse sinc filter.
2020-08-12 15:19:56 -05:00
Martin Braun
29394e2994 mpm: n3xx: Remove eth1, eth2 from interface list
These interfaces are renamed to sfp0 and sfp1 and thus don't exist. They
were kept in MPM for a while after the rename, but that was many
versions of UHD ago, and the current filesystem (which does the rename)
is not compatible with older versions of UHD anyway (and vice versa).

These aliases are thus dead code and can be removed.
2020-08-07 07:25:30 -05:00
Martin Braun
d05bacf120 mpm: Remove SID class
This class is a remnant of UHD 3, and is no longer used anywhere. SID is
no longer used at all in UHD, in fact, which means the class did not
represent a valid data structure.
2020-08-07 07:25:08 -05:00
Steven Koo
d81816a225 mpm: Reenable forward interfaces for remote hosts
The forward interfaces are able to forward CHDR packets with MPM
iptables routing. This reenables forward interfaces as a CHDR option.
2020-08-04 15:46:22 -05:00
Steve Czabaniuk
5e0cebdc19 mpm: n3xx: bist: Read mboard and dboard eeprom to determine product
The routine to identify products currently only reads the motherboard
EEPROM. The N310 and N320/N321 use the same motherboard so these devices
can't be distinguished using the motherboard EEPROM alone. This change
makes get_product_id() read both the motherboard and daughterboard
EEPROM in order to determine which N3xx it actually is.
2020-07-31 14:32:54 -05:00
Steven Koo
25a0e462dd mpm: Default virtual NIC CHDR IP selection
This change adds detection for setting the correct internal
fpga CHDR IP address when using embedded mode.
2020-07-30 11:39:00 -05:00
Samuel O'Brien
c91cf54766 mpm: Fix more 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. This comes
from trying to block on Process#join inside a gevent signal handler.

This commit resolves this issue by simply triggering an event in the
signal handler which prompts a different non-daemon thread to join the
subprocesses and end the parent process.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-28 16:16:54 -05:00
Martin Braun
31a107747a mpm: Fix documentation and minor issues in sys_utils.GPIOBank
- GPIOBank made the assumption that all bits used where contiguous. This amends
  the documentation to make that more clear, and adds an assert
  statement to check for that.
- reset_all() would reset all pins, regardless of DDR value, rendering
  it useless for any GPIO bank that would want to have readable pins.
  Fixed that by checking DDR value before resetting.
- Minor amendments to various docstrings; improve PyLint score by
  removing superfluous inheritance from object.
2020-07-28 15:57:00 -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
RobertWalstab
54d698e370 fpga, mpm: Bump FPGA compat number 2020-07-24 15:24:14 -05:00
Aaron Rossetto
5023e66b2d mpm: Don't index empty forwarding interface list
If no internal interfaces are found to which to forward CHDR packets,
return after printing the warning instead of attempting to index the
empty list and generating an exception.
2020-07-24 15:24:14 -05:00
Aaron Rossetto
ad707ab22d mpm, mpmd: Bump MPM compat number 2020-07-24 15:24:14 -05:00
RobertWalstab
1d3866bef4 uhd: remove liberio 2020-07-20 16:01:03 -05:00
RobertWalstab
1182144336 mpm: remove class N3xxXportMgrLiberio 2020-07-16 10:00:12 -05:00
RobertWalstab
616bcbc4dd mpm: Fix a logging message 2020-07-16 10:00:12 -05:00
RobertWalstab
dc1ecbb8f0 mpm: Enable internal NIC on the N3xx 2020-07-16 10:00:12 -05:00