Commit Graph

101 Commits

Author SHA1 Message Date
Eric Wild 242ceb25d1 devices: fix wrong gain to power mapping
The dev type was set too early, but the actual dev is only being
discovered during open, so update it. This broke the gain to power
mapping by defaulting to a wrong device.

Change-Id: I1dda6023ca6f15bc063c3dfbc704db2410ff7c98
2023-11-09 09:51:07 +00:00
Eric Wild c0f78a37ed devices: unify band handling
This is basically common, but optional code.

Change-Id: I64f5a462451e967d4750d8e4f1d5832cbab41cff
2023-07-25 18:25:49 +02:00
Eric Wild 19e134a626 transceiver: pass cfg struct instead of args
Passing 7 args is a bit much, just pass the config struct instead.

Change-Id: I48386900d15ff4d770c70a4efc246d32f921904b
2023-07-25 18:25:49 +02:00
Vadim Yanitskiy 019d698126 LMSDevice: LMS_GetDeviceList() may return a negative number
Change-Id: I855bd8ea6d9cb0f285f4dbbf3bcd09bff4e71044
Fixes: CID#240718
2021-10-25 13:12:51 +03:00
Pau Espin bb2cb9d54b lms,uhd: Allow changing band between poweroff & poweron
Before this patch, reconnecting to osmo-trx and attempting to configure it for
another band is not going to work without restarting the process.
The new variable is added in order to still allow POWEROFF followed by a
POWERON without need to reconfigure the device. In that case, previous
configuration is kept.

Change-Id: I43e5e1e4dcb36be605c6bd25dd6a5f3649e244e7
2021-09-21 17:24:18 +02:00
Pau Espin b9423b25b6 lms,uhd: Skip re-assigning same band
There's no need to spend time looking up again the same band
description.

Change-Id: I6f5631c9e64b9c261d52a856d757d08d2f336947
2021-09-21 17:24:18 +02:00
Pau Espin 069f5cd857 lms,uhd: Validate band of RxFreq too
So far the validation is only done on TxFreq for all TRX. Let's also do
it for RxFreq.

Change-Id: I30eef2727ee96b1344aa1416edd66e2302b88964
2021-09-21 17:24:11 +02:00
Pau Espin c90b207803 lms: Drop duplicated check
Same check is already done by set_band().

Change-Id: I48d14f35e83fa17d1a8f4154479f0a5cee0f816d
2021-09-21 13:48:20 +02:00
Eric Wild ecea734b97 lms: init band
Gain setting without a band was apparently led to a very low output
level, thanks to defog for pointing this out.

Change-Id: I8b59d38dd7b0781776c9e61226185879541fdc53
Related: OS#3342
2021-07-11 21:12:04 +02:00
Vadim Yanitskiy 24cb0c9948 device: drop unreasonable LIBOSMO{CTRL,VTY}_{CFLAGS,LIBS}
Neither VTY nor CTRL API is used in device specific code, excluding
the 'uhd' where osmo_cpu_sched_vty_apply_localthread() is called.

Change-Id: I568b443da4b96c005734d749faa22b9c7440f951
2020-10-24 23:41:57 +00:00
Vadim Yanitskiy 6b4acc12f7 device/lms: get rid of 'using namespace std'
Change-Id: I4329801c502db73efa946f15c103b2c081cee5a7
2020-10-24 19:25:32 +07:00
Vadim Yanitskiy d1ca287d83 device/lms: fix missing semicolon in LMSDevice::assign_band_desc()
Change-Id: I6aedb72306461ebb944fc13a795b0bf3121ea275
2020-10-24 19:25:32 +07:00
Vadim Yanitskiy a0d862ba1d device/lms: fix: 'trx_vty.h' header requires C linkage
Otherwise, the linker fails to produce osmo-trx-lms binary:

  LMSDevice.cpp:493: undefined reference to
    `get_value_string(value_string const*, unsigned int)'

  LMSDevice.cpp:237: undefined reference to
    `osmo_panic(char const*, ...)'

Change-Id: I2fef166c13136af7b7aaa744d39427d76ad11769
Fixes: OS#4828
2020-10-24 19:25:32 +07:00
Pau Espin e91544d740 Calculate RSSI offset based on RxGain configuration
Prior to this patch, osmo-trx relied totally on proper VTY configuration
being set in "rssi-offset" together with the RxGain set through TRXC in
order to provide correct Uplink RSSI measurements to bts-trx.

With this patch, RSSI is now by default calculated (in LMS and UHD
backends) based on the currently set RxGain, by providing empirically
discovered values. Still, for backward compatibility, the old
"rssi-offset" command will overwrite completely the per-default
calculated rssi offset.
A new optional parameter "relative" is added at the end of the
"rssi-offset" VTY command to flag the value as relative to the newly
per-default calculated value. This way specific setups (like adding a
LNA / RF fronted) can still be expressed while still keeping the
automatic per-default offset.

Related: OS#4468
Change-Id: I8ef78fd20c22c60d61bfb18d80a4a36df4fd6c20
2020-10-14 12:53:04 +02:00
Pau Espin 58d80a014e {UHD,LMS}Dervice: Log expected resulting TxPower when setting device specific TxGain
Change-Id: I3c54c61cd6dd7e40bb2831fd4962ff72130b390d
2020-06-25 13:07:22 +02:00
Pau Espin 5bd3d4263b Drop old TxGain APIs from parent radioDevice abstract class
All radioDevice subclasses except USRPDevice have already been reworked
to use the new SetPowerAttenuation() methods, hence we can drop the
compatibility layer that was added to transition from the old API to the
new one, and move those functions to USRPDevice.

This way we simplify the parent abstract class with methods not needed
by most devices and not used anymore by external users of those classes.

Change-Id: Ice005cd0a07c49b6e212c06f1228ef93c24db727
2020-06-25 13:07:22 +02:00
Pau Espin f68f19b110 LMSDevice: Compute TxGain on LimeSuite API based on expected Tx output power
Right now, according to a few measurements taken on LimeMicro devices, we
expect the Tx Gain at UHD level to relate 1:1 with the slope in Tx output
power given a specific band.

If more fine-grained results are wanted or some device doesn't follow a
1:1 slope relationship, functions TxGain2TxPower and TxPower2TxGain need
to be adapted/improved.

This patch is basically doing the same thing as was done previously for
UHDDevice in 992c9bd1ce.

Related: OS#4583
Change-Id: If154fe4d4cd118aa30ea43c22ee7119117b77da6
2020-06-25 11:05:36 +00:00
Pau Espin 992c9bd1ce radioInterface: Operate on real Tx power attenuation rather than on device specific gains
All the Tx gain related APIs are left out of reach from radioInterface,
and in there we simply interact with radioDevice passing the attenuation
received from TRXC.

Prior gain logic is moved in base radiodevice class, with the idea that
the setTxGain() and related functions will be dropped over time in each
sublcass in favour of an specific implementation of the
SetPowerAttenuation API.

Change-Id: I4f8a1bcbed74aa9310306b97b0b1bfb02f7855e6
2020-06-09 11:43:32 +02:00
Pau Espin 0e09e7c98a Transceiver: Implement TRXC cmd NOMTXPOWER
It allows the BTS to retrieve the nominal transmit output power value of
each TRX in order to compute attenuation later on and apply it through
SETPOWER or ADJPOWER TRXC commands.

Change-Id: I1d7efe56e008d8d60e23f9a85aa40809f7f84d9c
2020-06-08 15:49:36 +02:00
Pau Espin dfc6e5ffc7 radioDevice: Drop unused isControl param from WriteSamples API
The out "isControl" parameter is only used by internal callers of
USRPDevice, and not used at all by any user of the generic API
(radioInterface*.cpp). Hence, we can get rid of it and keep it as a flag
for an internal API of USRPDevice.

Change-Id: I843384e24b76cdd28a95f9ee4e95e6157098e4a3
2020-03-12 19:35:47 +01:00
Pau Espin f8c0c464b8 radioDevice: Drop unused RSSI param from readSamples API
The out "RSSI" parameter is only filled by USRPDevice, and not used at
all by any user of the API (radioInterface*.cpp).

RSSI seems to be computed nowadays in the common path in
Transceiver::pullRadioVector().

Change-Id: I06c2ea5a9891d170bc468f952bbf2a7e64d95784
2020-03-12 19:34:28 +01:00
Pau Espin 0569845a08 lms: Initial multi-arfcn support
With current state multi-arfcn can be used (eg. I can place a call
between 2 phones using TRX1 and sustain for as long as wanted), but from
time to time (around every 20seconds), a burst of Tx packed dropped
events from LimeSuite appears.

LimeNet-micro coefficients have yet not been tested.

Related: OS#4362
Change-Id: I7e67d90a8126546eeeeba376f816ec5d158d4712
2020-01-15 15:46:14 +01:00
Pau Espin c69b87f9bd lms: Make ts_offset and smpl rate coefs device-specific
Right now the values are the same for all devices, but they will differ
in forthcoming commits once multi-arfcn support is added.

Change-Id: I262d3a71848fc3070473e29e42820848e7591d02
2020-01-15 15:46:14 +01:00
Pau Espin a7bf6cd8a4 lms: Store device type specific parameters in one place
Add an enum containing each supported device type (LimeSDR-USB,
LimeSDR-Mini and LimeNet-Micro) plus "unknown", to leave some room for
yet-to-come devices to run with some generic parameters without
rebuilding osmo-trx.

Each device type is assigned a dev_desc structure, and all of them are
put in HashMap, similar to what's already done in UHDDevice.cpp.

Device type is infered from string provided by LMS_GetDeviceInfo(), as
it was already done before in several places. From now on, we only need
to parse the string once since we store the device type after first
during open time.

Later on, more fields will be moved to device-type specific structure,
such as Tx timing offset, clock rate, etc.

Change-Id: I7658615787c5bc41c365bab9c11733b701ac2ae5
2020-01-15 15:45:29 +01:00
Pau Espin e7f6a27ab6 lms: Move rx_buffers allocation to constructor
Release is done in destructor, so let's move allocation to constructor
since there's really no need to have them in open() which is already
quite complex and large.

Change-Id: I8a4fd973590c4c165abd8f2837b2da8fc14a2066
2020-01-15 15:35:01 +01:00
Pau Espin a979f5f32b lms: Make reference to std::vector unambiguous
Change-Id: Ieebdbd3d5082a02aea2441e6737783370511cbc1
2020-01-15 15:34:49 +01:00
Pau Espin b0e54265ad lms: Change radioDevice constructor arg name to avoid masking instance attr
channel number mangling based on multi-arfcn feature being enabled was
moved to generic radioDevice() to reuse code. Hence, the generic parent
constructor sets this->chans to 1 if multi-arfcn feature is requested.
However, LMSDevice constructor argument had same name as the class
instance attribute, taking preference. As a result, if multi-arfcn is
enabled in LMSDevice, the generic constructor first sets this->chans=1
but afterwards LMSDEvice constructor keeps calling .resize() with the
argument value "chans" instead of using this->chans.

Let's rename the argument in all radioDevice child class constructors to
avoid potential future bugs in all of them.

Change-Id: Id6c837e9133f22783dd92a81dfcc493e51bf2d21
2020-01-13 16:13:28 +01:00
Pau Espin 62c9280590 lms: Improve smpl_buf error logging
Change-Id: I511abe2c333443b978a3767bd7b7e320e07c4930
2020-01-13 14:35:06 +01:00
Pau Espin dccc82491c lms: Drop unused define
Change-Id: Iaf3361ed29dd552e5e52b62bc738fa20c6b583fe
2020-01-07 16:21:12 +01:00
Pau Espin bf58370675 lms: Move initialization of field started to constructor
Change-Id: I135a2ff4a419775169452be1128c7b30f7d638ad
2020-01-07 16:10:34 +01:00
Pau Espin aebbfe0ee7 Make logging category DLMS generic and reusable for other backends
Make sure old configs using "logging level lms <level>" are still accepted.
Initialization order of VTY componenets need to be resorted since newly
introduced command requires logging VTY node to be already setup
beforehand.

Change-Id: Ia195a74a62a8a3dd6267fb1359acaa5628208d8e
2020-01-07 16:04:04 +01:00
Martin Hauke 066fd04f47 Fix common misspellings and typos
Change-Id: I4ec7accb1912c052b446be7c399bed32a8c62253
2019-10-17 08:06:19 +00:00
Pau Espin 2ab921812e radioDevice: Introduce getTxGain() API
It will be used in later commits by radioInterfaceMulti.

Change-Id: Ie3caca8971ed1e5370dfed6fb60716a24e7d82a5
2019-09-13 17:34:46 +02:00
Pau Espin 705a348326 LMSDevice: Return previous txGain/rxGain if setting value failed
Change-Id: I11e853e11bec99fc88e81642f9b2cd87d5815398
2019-09-13 17:33:14 +02:00
Pau Espin e0010fa425 lms: Log available antennas if requested antenna fails
Related: OS#3343
Change-Id: Icd328e85b0a75ef67f371a7ed72638053b1854f9
2019-08-26 17:13:17 +02:00
Pau Espin 67aa91b2c0 Drop old setPriority related code
This code is not needed anymore since we are setting SCHED_RR scheduler
with a real time priority in main thread during startup, so all threads
will inherit same rt priority, which should be enough to keep the
process working reliably even on high system loads (from non rt
processes).

osmo-trx was tested to be reliable during test with stress-ng as
explained in related ticket below.

Related: OS#2344
Change-Id: I3a88946dd71e9aeeaac9d19d396e2236c302b608
2019-08-21 13:00:41 +02:00
Pau Espin 68a78099a0 lms: Drop rx_underruns rate ctr, add tx_drop_* rate ctr
After discussion in [1] and further look at the code, it became obvios
rx_underrun events are not happening in general for any SDR (don't
exist), so let's drop that counter. Instead, add Tx Dropped Packet counters,
which were not accounted prior to this commit.

[1] bde55afd29

Change-Id: Iff1535c219a4695a511d383d7c4b06ef6eff959d
2019-08-01 13:45:55 +02:00
Pau Espin 21d03d3912 Add SPDX annotation
Related: OS#3515
Change-Id: I3719bd8dc015569ecd81928fc079e27593cdca09
2019-07-22 12:06:26 +02:00
Pau Espin bde55afd29 lms: Fix stream_stats checks with overrun/underrun
It was initially thought that underruns/overrun fields were
increasing-over-time values.
However, after reading LimeSuite code, it seems overrun and
underrun fields are actually reset upon every call to
LMS_GetStreamStatus().

Related: osmo-trx.git 9281771256
Related: https://github.com/myriadrf/LimeSuite/issues/265
Change-Id: I677232a7b12ee83d26aa34d92f76a91d4b5a63a6
2019-06-09 06:55:13 +00:00
Pau Espin 4c50bf435b lms: Drop unusued variable masterClockRate
Change-Id: I19192925d008046f474615a0476b52ddee9a9d78
2019-06-06 19:44:22 +00:00
Pau Espin 4456b6f132 Add rate_ctr support to store/retrieve SDR errors through VTY
Introduce a unified implementation-agnostic interface for radioDevice to
signal SDR error counters to upper layers and manage them.
This patch only implements counters for osmo-trx-lms (other devices will
show all counters unchanged during time).

Sample use through VTY:
"""
OsmoTRX> show rate-counters
osmo-trx statistics 0:
   device:rx_underruns:          0 (0/s 0/m 0/h 0/d) Number of Rx underruns
    device:rx_overruns:          0 (0/s 0/m 0/h 0/d) Number of Rx overruns
   device:tx_underruns:          0 (0/s 0/m 0/h 0/d) Number of Tx underruns
 device:rx_drop_events:          4 (0/s 2/m 3/h 0/d) Number of times Rx samples were dropped by HW
device:rx_drop_samples:        513 (0/s 196/m 425/h 0/d) Number of Rx samples dropped by HW
"""

Change-Id: I78b158141697e5714d04db8b9ccc96f31f34f439
2019-06-05 12:50:38 +02:00
Pau Espin 9281771256 lms: Fix stream_stats checks with droppedPackets
Existing code had a typo (value was assigned from wrong variable).
Furthermore, it was experimentally found that:
while underrun/overrun are documented as "FIFO overrun
count" in LimeSuite.h, it seems droppedPackets ("Number of dropped
packets by HW") is not actually an incrementing counter like the others,
but simply a value set every time LMS_RecvStream() is called. Since we
are actually interested in keeping the count over time, adjust code to
achieve that.

Change-Id: Id93d33400e11360b9536f56a31904328549cfbbf
2019-05-24 17:01:13 +02:00
Pau Espin dcbcfa58e4 lms: Use smpl_buf to recover from timestamp jumps
Also take the chance to make sure we handle properly short reads (keep
reading again).

Both scenarios can be tested by running osmo-trx-lms and then using
on a terminal:
sudo kill -STOP `pidof osmo-trx-lms`; sleep 0.5; sudo kill -CONT `pidof osmo-trx-lms`

Fixes: OS#3339
Change-Id: Idfc4e69acc30afb11440b6b9cbdcfa09ff920265
2019-05-06 11:23:36 +02:00
Pau Espin b5def414b8 smpl_buf: Move it to device/common and create libdevice_common.la
Since in next commit osmo-trx-lms starts using smpl_buf.cpp, it seems
some automake step doesn't like including a cpp file twice from a
different directory, since race conditions can occur building it.
Instead we define the dependency by first building a static lib and then
using it on each libdevice.la (one per device type).

We already do the similar under arch/ subdir, where we have a common/
subdir and then one subdir and lib per architecture.

Change-Id: I465ad0f6d5569bb3006d711c8fd0df14391fcf35
2019-05-06 11:23:18 +02:00
Pau Espin fc73c073a1 Introduce LOGCHAN macro to standarize logging channel info
Change-Id: I67d869499aa16af58c863ca7b74c356bcd979936
2019-05-06 11:21:43 +02:00
Pau Espin 7214fde085 device: Drop unused numberRead/numberWritten APIs
It's really not used, so let's drop unused code and simplify work for
new to come device drivers implementation.

Change-Id: I0d18f9c2584771e2f7b3d5c6b016e764e02855ff
2019-05-03 13:50:50 +02:00
Pau Espin 2876785f50 lms: Catch and log dropped packets by HW during recv
Change-Id: I23554d95b0aff585024610fc12920c9da4f3ba9e
2019-04-25 20:16:10 +02:00
Pau Espin 713b4d81cd lms: Remove unused var m_last_tx_overruns
Change-Id: I2104205b2af7cd6c86075d5cc4f0f36bde5e5311
2019-04-25 20:16:10 +02:00
Pau Espin b96d9ddee3 lms: Remove references to ALERT loglevel
ALERT log level is not Osmocom standard level, it's just a define in
osmo-trx to keep compatibility with old code.

Same goes for one reference to "ERR" intead of "ERROR".

Change-Id: I0e171a8ac8a8bfa804ac97fba3d73efcfa6424b4
2019-04-25 20:16:10 +02:00
Pau Espin 048c3ba300 lms: Log underrun/overrun events
Change-Id: I8c6b1d3e8515153e5d4079cc6620901ef8ce2449
2019-04-25 20:16:10 +02:00