Commit Graph

163 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 f8c7a52521 devices: add freq/gain override for uhd
This allows using arbitrary gain and frequencies.

Change-Id: I3c1b9a067cafc6d696b9aa2da8ee0480ec1e094f
2023-07-25 18:25:49 +02: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
Oliver Smith a98521ac05 USRPDevice:updateAlignment: remove byteswap code
After upgrading our CI environment to use Debian 12 with GCC 12, the
byteswap code fails the build with the following. I've talked to Eric
about this and he recommended to just remove the code as practically
nobody will use osmo-trx with a big endian system.

USRPDevice.cpp:591:30: error: 'data' is used uninitialized [-Werror=uninitialized]
  591 |   *wordPtr = host_to_usrp_u32(*wordPtr);
      |              ~~~~~~~~~~~~~~~~^~~~~~~~~~

Related: OS#6057
Change-Id: I806d8c1432cb20efca1830a2752a4cbc70384b54
2023-07-13 14:34:59 +02:00
Vadim Yanitskiy 1ddd727bb4 ipc-driver-test: clean up variables in Makefile.am
* AM_CPPFLAGS is for preprocessor flags like '-I' or '-D',
* AM_CFLAGS/AM_CXXFLAGS is for C/C++ compiler flags like '-Wall',
* AM_LDFLAGS is for linker flags like '-no-undefined', not libraries!
* Link ipc-driver-test against libdevice.la,
* Do not put $(UHD_CFLAGS) everywhere.

Change-Id: Iafd68974c9c613fb4e65a01d076b2c687b716c83
2023-03-14 13:16:09 +00:00
Pau Espin 8a4362459d Call osmo_fd_unregister() before closing and changing bfd->fd
Change-Id: Iffc7d89166be1cf3cd1f8c3effe90f04d5c5a9c1
2023-03-14 12:54:20 +00:00
Eric Wild 2ca77d7ff2 ipc: remove old autotools workaround
Closes: OS#5845
Change-Id: I3f8a0204b1fda52d1228add8afde620274b164a5
2022-12-23 15:37:27 +01:00
Eric Wild d3e3bba2cd ipc: add missing override
Change-Id: Ib1493ac10b40d24372075d4cebd67015192675e0
2022-12-23 13:41:36 +00:00
Eric Wild 5561f1129d clean up mutex, scopedlock, and signal classes
This also uncovers very interesting design decisions like the copying of
mutexes and condition vars depending on recursive locks that were
previously hidden by shady c function calls..
We have perfectly good c++11 versions for all of that.

While we're at it, also use the initialization list for the other (still
copy constructable) vectors, which cleans up the radio interfaces.

Change-Id: Idc9e3b1144c5b93f5dad2f8e0e30f1058477aa52
2022-12-23 13:41:30 +00:00
Eric Wild 7d897cb5b0 bladerf xa4 support
This is not really finished, there are multiple reasons to not use this:
1) main clock is not a gsm multiple, so it will continously drift
2) small buffer sizes lead to tx gaps that are hard to detect and break
everything.

Change-Id: I455c34bb9520d5f09eeb1ac76fceb4bdea94d1ac
2022-12-06 09:45:06 +01: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
Vadim Yanitskiy a686277c72 IPCDevice: check value returned from select()
Change-Id: I1c823317659547bb2391c57ac4d7931de1a383e3
Fxies: CID#240744
2021-10-25 13:10:18 +03:00
Vadim Yanitskiy 683f140739 IPCDevice: use thread safe strerror_r() instead of strerror()
Change-Id: Ia51ffa51ec7729572faca0282ae41c1e4968049f
2021-10-25 12:56:44 +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
Eric Wild 5e6b10cd9e uhd: ensure configured clock source is actually used
We wouldn't want to get caught running with unlocked external clock
sources, right?!

Change-Id: Ie38d85617f46eb5ab7d9527ddf6aaab4d3edf6bf
2021-05-29 15:55:28 +00:00
Pau Espin c7930b0b22 ipc: Makefile.am: Clean LDADD variable
Change-Id: I26c942496ab12883a4a1e0d549cb462642570636
2021-03-01 16:35:42 +01:00
Harald Welte e2404f4e41 mark uhddev_ipc.cpp as BUILT_SOURCES
fixes "make dist-bzip2" on a clean checkout

Closes: OS#5052
Change-Id: Ieb4cefb16c8f43e708a96353c13342fe40ffdb54
2021-02-28 11:02:25 +01:00
Pau Espin Pedrol 4a4e607a19 ipc-driver-test: Allow setting dir prefix for UD socket
Change-Id: I35282b38a1d560fb3440fe0aa9a27808d9d116cc
2020-12-10 15:26:32 +00:00
Pau Espin Pedrol 7e83f18bba ipc: Fix wrong reference to BTS in log line
Change-Id: Idd272959e335c46ca88e348dd792e15ddb317d61
2020-12-07 19:28:44 +01:00
Harald Welte 94def47fdf Use osmo_fd_*_{disable,enable}
Change-Id: Ic8c8c418e123fbdff625556a900b19650deefe0b
Depends: libosmocore.git Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2020-11-11 20:15:59 +00: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 bc5263cee1 device/common/Makefile.am: remove $(LMS_CFLAGS) from AM_CXXFLAGS
This is device-independent code, so it should not be here.

Change-Id: I1ffc3431a9a1a46c74c354b3f8a256684bfcbe73
2020-10-24 19:44:21 +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
Harald Welte c5989fe180 Use osmo_fd_setup() wherever applicable
Change-Id: Ie093dea96ec8990368695c0c5824e0fe44fb8540
2020-10-19 12:27:36 +02:00
Harald Welte 08970c562f ipc: Use OSMO_FD_* instead of deprecated BSC_FD_*
Change-Id: I98b3f9525954d6882f7488d650038a8e28f7b769
2020-10-18 22:41:40 +02: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
Vadim Yanitskiy b7c6f1e83f radioDevice: fix set_antennas(): consider MULTI_ARFCN mode
In the multi-ARFCN mode, if the Tx/Rx antenna names are explicitly
set in 'chan N' sections of the configuration file:

  trx
   ...
   multi-arfcn disable
   chan 0
    tx-path TX/RX
    rx-path RX2
   chan 1
    tx-path TX/RX
    rx-path RX2
   chan 2
    tx-path TX/RX
    rx-path RX2

osmo-trx would crash, because radioDevice::set_antennas() would
attempt to configure antenna names for all N physical channels,
while USRP devices usually have 2 or even 1 available.

The easiest approach is to remove both 'tx-path'/'rx-path' from
all 'chan N' sections excluding 'chan 0', so it would work fine.
This makes sense, because in the multi-ARFCN mode we actually
use only one physical channel.

However, let's still make sure that explicit configuration of the
Tx/Rx antenna names would not crash osmo-trx and skip N > 0 in
radioDevice::set_antennas().

Change-Id: I09f316f181cbbc2214e8913b73f7c1fcea4e8c05
Related: OS#4636
2020-09-12 14:47:21 +07:00
Harald Welte 8808fa86f0 Fix build on Debian8
We cannot use C99 or higher features in C code!

Last lines of build log:
[  265s]    for (unsigned int i = 0; i < decoded_region->num_chans; i++)
[  265s]    ^
[  265s] ipc-driver-test.c:473:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile
your code
[  265s] Makefile:580: recipe for target 'ipc_driver_test-ipc-driver-test.o' failed
[  265s] make[5]: *** [ipc_driver_test-ipc-driver-test.o] Error 1

Change-Id: I80c9cbd77f1cdf323ad2b492de7e9a177840c383
2020-08-27 10:08:53 +02:00
Pau Espin 2a0fb962c7 ipc: fix var declaration in for loop
"""
error: 'for' loop initial declarations are only allowed in C99 or C11 mode
"""

Change-Id: I97cb9a0a3ecf64e3e5fcfca75431f8fe2a07bd10
2020-08-26 09:30:41 +00:00
Eric Wild 4080eb76f8 devices: reset internal smart sample buffers upon stop
They are too smart, they keep the timestamps.

Change-Id: Idb4b8f03eb5ffdfd6d3fdbc137b20e3ddc4cfa65
2020-08-25 01:00:19 +02:00
Eric Wild 1e17c4fb0a osmo-trx-ipc
This adds a IPC backend that uses shared memory interface
to communicate with (proprietary) devices.

Requires config file option
dev-args ipc_msock=/path/to/socket
to specify the master socket the ipc backend should connect to.

If UHD is avaialble the ipc-driver-test tool can be used to test the
backend with a uhd device, this was so far only tested with a b2xx.

Change-Id: Ice63d3499026293ade8aad675ff7a883bcdd5756
2020-08-25 01:00:03 +02:00
Pau Espin 553a25033e Use new libosmovty cpu sched config features
Using the new libosmovty features allow for:
* Setting different cpu-affinity masks for each thread in the process,
  both at startup through .cfg file as well as changing it at runtime.
* Unified VTY interface to change the scheduling policy of the process
  inherited by all osmocom processes enabling the feature.

Depends: libosmocore.git Change-Id If76a4bd2cc7b3c7adf5d84790a944d78be70e10a
Depends: osmo-gsm-masnuals.git Change-Id Icd75769ef630c3fa985fc5e2154d5521689cdd3c

Related: SYS#4986
Change-Id: I3798603779b88ea37da03033cf7737a6e4751d6e
2020-07-31 13:54:35 +02:00
Vadim Yanitskiy 68d8db4d8c UHDDevice: catch LookupError/IndexError in set{Rx,Tx}Antenna()
Currently configuring 3 channels in multi-ARFCN mode makes the
process crash during the Rx/Tx antenna configuration due to
uncaught UHD specific LookupError/IndexError exceptions:

  terminate called after throwing an instance of 'uhd::index_error'
    what():  LookupError: IndexError: multi_usrp:
      TX channel 2 out of range for configured TX frontends

Let's catch them and terminate gracefully.

Change-Id: If66305f2787c6292375e4bfbd60c1d3d764cffd4
Related: OS#4636
2020-06-29 12:43:06 +00: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 b899c19f1f UHDDevice: Compute TxGain on UHD API based on expected Tx output power
Right now, according to a few measurements taken on B210, 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.

Change-Id: I6f432465dce5c6ec1f1bc4653f6149efb18c3f43
2020-06-15 10:41:16 +02: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 056ce136e6 UHDDevice: Implement getNominalTxPower() based on TxFrequency
The table with nominal UHD Tx Gains and real transmit power is filled
with values measured experimentally. More information can be found in
OS#4583.

Related: OS#4583

Change-Id: If7ef5bf95ffe4afe5864c0f051853aa38b9639eb
2020-06-09 11:43:24 +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