Commit Graph

538 Commits

Author SHA1 Message Date
Vadim Yanitskiy e8f857453d power_control: migrate MS/BS control loops to the new params
In change [1] the new power control structures and default params
were introduced.  In change [2], the existing VTY commands for MS
power control in the BTS were deprecated and changed to use the
new structures as storage.  Finally, in change [3], handling of
the power control parameters on the A-bis/RSL was implemented.

This change is the final logical step in the mentioned chain: it
makes both MS/BS power control loops use the new parameters, and
removes the old structures.  The actual implementation of both
power control loops remains the same, however the expected output
of some unit tests for the Downlink loop needs to be changed:

  - TC_fixed_mode: disabling dynamic power control becomes a separate
    step of the test script since the field 'fixed' is removed;

  - TC_rxlev_target: RxLev thresholds are printed 'as-is'.

Not all of the new parameters are used by the power control loops
yet.  Further improvements to be done in the follow up commits.

[1] I6d41eb238aa6d4f5b77596c5477c2ecbe86de2a8
[2] Icbd9a7d31ce6723294130a31a179a002fccb4612
[3] I5a901eca5a78a0335a6954064e602e65cda85390

Change-Id: Ib18f84c40227841d95a36063a6789bf63054fc2e
Related: SYS#4918
2021-01-08 02:05:27 +01:00
Vadim Yanitskiy 22646cb122 osmo-bts-trx: vty: clarify and improve some deprecation messages
Change-Id: I22b69eccfa50d178bd36bf770f7158ec441c9923
Related: SYS#4918
2021-01-07 00:38:55 +00:00
Vadim Yanitskiy 237ec6194b power_control: clarify units in 'struct bts_power_ctrl_params'
Change-Id: Icb059ca1f555397be116a424800e4536883b9106
Related: SYS#4918
2020-12-06 18:59:05 +01:00
Vadim Yanitskiy af4eec056e struct gsm_bts: move ul_power_{target,hysteresis} to ul_power_ctrl
Change-Id: I3886c7aedf3870536f1750f864cf698302ddf2df
Related: SYS#4918
2020-12-02 13:56:49 +00:00
Vadim Yanitskiy 5b25e8e7de osmo-bts-trx/scheduler: ensure no DL power attenuation on C0
When [baseband] frequency hopping is in use, Downlink bursts from
additional transceivers may end up being transmitted on TRX0/C0.
In this case, we must not apply per-lchan attenuation, because
the BTS shall maintain constant power level on that TRX.

Change-Id: Id171df70447283b00da965e1f81dfac20e35495c
Related: SYS#4918
2020-12-01 21:39:55 +00:00
Philipp Maier 7c87612b42 l1sap: add repeated uplink SACCH
3GPP TS 44.006, section 11 describes a method how the uplink
SACCH transmission can be repeated to increase transmission
reliability.

Change-Id: I7e4cc33cc010866e41e3b594351a7f7bf93e08ac
Related: OS#4795, SYS#5114
2020-11-28 22:35:12 +01:00
Philipp Maier 33dfe2bcec l1sap: add repeated downlink FACCH
3GPP TS 44.006, section 10 describes a method how the downlink
FACCH transmission can be repeated to increase transmission
reliability.

Change-Id: I72f0cf7eaaef9f80fc35e752c90ae0e2d24d0c75
Depends: libosmocore I6dda239e9cd7033297bed1deb5eb1d9f87b8433f
Related: OS#4796 SYS#5114
2020-11-27 16:02:45 +01:00
Vadim Yanitskiy ffbe63f408 fixup: vty: call bts_model_vty_init() from bts_vty_init()
Now bts_model_vty_init() must be called only once, otherwise the
process would crash when bts_model_init() is called from main().

Change-Id: I262c39896b5db86c54ad9aa7042c7ca6657815d9
Related: SYS#4937, OS#3036
2020-11-03 05:44:28 +07:00
Vadim Yanitskiy 5c7b709027 vty: call bts_model_vty_init() from bts_vty_init()
Similar to bts_vty_init(), BTS specific bts_model_vty_init()
requires a pointer to 'struct gsm_bts'.  Not only it's used
as a parent talloc context, but also stored locally, so then
it can be used by some VTY commands.

Let's expose the global 'struct gsm_bts' from main, and pass
the application's talloc context like was done in [1].

This finally makes the BTS model specific options appear in
the automatically generated VTY reference (--vty-ref-xml).

[1] Ic356a950da85de02c82e9882a5fbadaaa6929680

Change-Id: Iee7fee6747dd1e7c0af36f9b27326f651ae37aaf
Related: SYS#4937, OS#3036
2020-11-02 18:08:24 +00:00
Vadim Yanitskiy 850607295c osmo-bts-trx/scheduler: fix comments related to FACCH/H and BFI
Change-Id: I1c1d81ba5a54946089da6c32b0d42141ffe71ed8
Related: OS#4799
2020-10-30 16:45:43 +07:00
Philipp Maier 44fc252381 sched_lchan_tchf: count measurements for FACCH/F only once
When the FACCH is generated (while in SPEECH mode), there is also a
fake speech indication handed up to l1sap.c. We must make sure that only
one of the two indications carry a measurement value, so lets invalidate
the measurement values (RSSI in particular) for the generated TCH
indication.

Change-Id: Ie3f2e620ba2a2ab2fecdbae627ef01c6128fce0b
Related: OS#4799
2020-10-26 15:11:27 +01:00
Pau Espin 22f59cd63a Introduce NM Channel FSM
Change-Id: I288cbfb4730b25a334ef1c3d6b9679d6f1d4cfc5
2020-10-20 13:45:57 +00:00
Pau Espin 7810a91733 Introduce NM Radio Carrier and Baseband Transceiver FSMs
All the Operative State logic to manage a RadioCarrier//BBTransc NM objects is
centralized in these FSM, where other parts of the code simply send
events to it.
This allows keeping state consistent and offloading logic from each bts
backend, since they are only required to submit events now.
The idea in the long run is to also replace other NM objects with
similar FSMs.

This improved logic fixes bug where PHY + RSL link became available before
OPSTART and hence op state changed to Enabled before receiving any OPSTART message.

Change-Id: Ifb249a821c4270918699b6375a72b3a618e8cfbe
2020-10-20 13:45:57 +00:00
Pau Espin ae6e3e8f8b Introduce NM BTS FSM
Change-Id: Iae631bcc7acdf955296b124707e42d5e565af186
2020-10-20 13:45:57 +00:00
Pau Espin 88fe4b079d Introduce NM BTS Site Manager FSM
This fixes old behavior mimicing broken behavior in nanoBTS (according to TS 12.21)
where BTS Site Mgr NM object was announced as Enabled despite no OPSTART
was sent by the BSC.
With this new FSM, BTS SiteManager will be announced as Disabled Offline
during OML startup conversation, instead of Enabled.

The new osmo-bsc OML management FSMs use this change in behavior to find
out whether it should use the old broken management states (without
Offline state, as per nanoBTS) or use the new state transitions (which
allow fixing several race conditions).

Change-Id: Iab2d17c45c9642860cd2d5d523c1baae24502243
2020-10-20 13:45:57 +00:00
Pau Espin 6d117891c9 Change NM Channel availability Dependency->Offline when RadioCarrier becomes enabled
This fix allows osmo-bts to play fine with newer osmo-bsc NM OML FSMs,
which expectes for non-nanoBTS types to follow TS 12.21 guidelines.
Until now, BSC simply waited to received State Event Change Dependency
for each TS and then sent all required commands (Set Chan Attr, Adm
Unlock and Opstart). In newer osmo-bsc FSMs, Opstart is only sent when
in Offline state, so we need to transit to that state. For the above
mentioned reason, since we pass through the Dependency state anyway
after this patch, older osmo-bscs will work correctly too.

Change-Id: Id9e61f8d773e6e6170c68b5b836d276c747d8d69
2020-10-20 13:45:57 +00:00
Philipp Maier 8be3fa6f36 sched_lchan_tchh: initialize meas_avg with zeros
in function rx_tchh_fn() the variable meas_avg is not initalized. This
is not always a problem, since most of the time trx_sched_meas_avg() is
populating the variable properly. In cases where a FACCH is transmitted
(chan_state->ul_ongoing_facch = true) the variable is left unpopulated.
In order to have at least stable values for those cases, initalize the
variable with zeros for the ongoing facch phase.

Change-Id: I5c3c1c41d22f9edaaf6bd4478dd04f090dca12a9
Fixes: CID#214480
2020-10-08 19:55:19 +00:00
Philipp Maier 05549ae252 vty: add attributes to VTY commands indicating when they apply
Change-Id: Ifcdfcd157e5067fa2e4296d7c7e93a74087f49ff
Related: SYS#4937, OS#1601
2020-10-08 07:16:55 +00:00
Philipp Maier c41b94e93b osmo-bts-trx/scheduler: fix measurement handling for SUB frames
Make sure that we pick the correct UL measurements from the
history when we deal with AMR SID frames (SUB frames).

Change-Id: I902bb47d68742d2589156f61099b67a0edbaf40b
Related: OS#2978
2020-10-03 07:05:25 +00:00
Vadim Yanitskiy 64bd96b3f8 vty: make most struct pointers const in show/write commands
Change-Id: Iacc32f7982c150d84ea4df7affa1f9e07806928f
2020-09-28 11:39:04 +07:00
Vadim Yanitskiy 4ded469b0f osmo-bts-trx/scheduler: refactor UL burst measurement processing
Currently the UL measurements (RSSI, ToA256, C/I) of the burst that
concludes a block are passed up to the higher layers. This means
that the measurement values of the other bursts are skipped.

Let's keep record of all UL measurements and average the values
before we pass them up to the higher layers. Use a simple ring
buffer to store the measurement history (up to 8 unique entries
for now). Remove *_num/*_sum variables from l1sched_chan_state.

Change-Id: I2b02b51fea5664f161382a4ddc63dbf14ffc9ac5
Related: OS#3032, OS#2978
2020-09-22 19:34:02 +00:00
Vadim Yanitskiy 0cd8df2184 gsm_data: rename hopping.{ma,ma_len} to hopping.arfcn_{list,num}
MA (Mobile Allocation) is actually a bit-mask indicating those ARFCNs
of the Cell Allocation, which must be used as the hopping sequence.

What we store in struct gsm_bts_trx_ts is the actual list of hopping
channels, so let's name it properly and eliminate possible confusion.

Change-Id: I677d66e428fa0fe119ebc37bc2a4e6cc05c251c4
2020-09-17 15:45:48 +00:00
Pau Espin 666adf6a97 Improve logging around failing to (de)activate chan_nr
Change-Id: Ibc398eb5d50851cbe48f2c92f14e746938a68720
2020-09-16 19:28:38 +02:00
Vadim Yanitskiy 3d085dc6a7 osmo-bts-trx: also print 'txtune-ack' in st_open_poweroff()
Change-Id: Ifa453e101c32ee211844becf4604f3e08198da73
2020-09-10 14:15:31 +07:00
Pau Espin c84b007efb bts-trx: Ensure RFMUTE state is set properly at startup
In general, it is always set to 1 (Locked) in
st_open_poweroff_on_enter() right after initial POWEROFF, and once the
BSC unlocks it (based on VTY cfg "rf_locked (0|1)") by sending an OML
message, the bts_model_chg_adm_state() call will update it sending
RFMUTE.

This basically fixes the case where osmo-bsc.cfg is configured with
"rf_locked 1" to start with a TRX locked until manually unlocked.

Related: SYS#4920
Change-Id: I96b64cdc901d6f216df628d7be57a67af4a21e25
2020-09-07 08:08:09 +00:00
Pau Espin af4015cb91 bts-trx: Use TRXC RFMUTE instead of resetting the scheduler
Since commit 221ee92551,
bts_model_trx_deact_rf() was being called when RF locking the TRX, which
was implemented by resetting the scheduler. This proved to be a messy
and wrong way to emulate disabling RF, since it modifies tate on lots of
structures from which it is later difficult to recover from, causing
bugs and issues like:
82a35a1dbf
be15a12c87
eef420d1ca
https://osmocom.org/issues/4694
https://osmocom.org/issues/4695
https://osmocom.org/issues/4696
https://osmocom.org/issues/4697

So for all these reasons, it is believed a good solution to avoid
resetting the scheduler and simply ask lower layers (osmo-trx) to take
care of disabling RF TX/RX on a given TRX. For TRX implementations not
supporting the newly added RFMUTE command, ramping down to -10dBm still
provides for a way to emulate RF locking. In any case, none of this was
supported until recently so it's not like we are breaking some feature
here.

Related: SYS#4920
Change-Id: I1423ddb390ef327ec7d4a27de2ac5dca663773a5
2020-09-07 08:08:09 +00:00
Vadim Yanitskiy 359ca18374 osmo-bts-trx/trx_provision_fsm: add missing default labels
Change-Id: I494ea9eb64634a03575a52750273cee7c68a8b3a
2020-09-05 21:06:14 +07:00
Vadim Yanitskiy 5a2262da64 osmo-bts-trx: fix trx_init(): do not send OPSTART ACK blindly
It was reported that both osmo-bsc and osmo-bts-trx may end up
running in a half-broken state, when everything looks good and
the UEs can see the network, but all channel requests get
rejected due to "trx not usable" error:

  lchan_select.c:173 (bts=0) lchan_select_by_type(SDCCH)
  lchan_select.c:48 looking for lchan CCCH+SDCCH4: (bts=0,trx=0) trx not usable
  lchan_select.c:48 looking for lchan SDCCH8: (bts=0,trx=0) trx not usable
  lchan_select.c:239 (bts=0) Failed to select SDCCH channel

  lchan_select.c:173 (bts=0) lchan_select_by_type(TCH_H)
  lchan_select.c:48 looking for lchan TCH/H: (bts=0,trx=0) trx not usable
  lchan_select.c:239 (bts=0) Failed to select TCH_H channel

  lchan_select.c:173 (bts=0) lchan_select_by_type(TCH_F)
  lchan_select.c:48 looking for lchan TCH/F: (bts=0,trx=0) trx not usable
  lchan_select.c:239 (bts=0) Failed to select TCH_F channel

As was then figured out, this happens because the Radio Carrier
MO (Managed Object) remains Disabled even after the BSC has
sent OPSTART and the BTS ACKed it:

  oml.c:986 OC=RADIO-CARRIER(02) INST=(00,00,ff): Rx OPSTART
  l1_if.c:614 Rx OPSTART for RADIO-CARRIER MO
  l1_if.c:201 TRX_PROV(phy0-0)[0x1238c0]{OPEN_POWERON}:
              Event TRX_PROV_EV_CFG_ENABLE not permitted
  oml.c:144 OC=RADIO-CARRIER(02) INST=(00,00,ff): Tx Opstart Ack

It remains a mistery why the TRX_PROV FSM is already in state
OPEN_POWERON, while it's expected to be in state OPEN_POWEROFF,
but we definitely should not ACKnowledge the OPSTART if this
happens.  Send a NACK instead with cause NM_NACK_CANT_PERFORM.

Change-Id: I8727460acbf850b84df67a9cbdc25b47dee1fadd
Related: SYS#5063
2020-09-05 20:03:46 +07:00
Vadim Yanitskiy 6f4db8c620 osmo-bts-trx/l1_if: drop redundant logging message
We already get quite informative message originated from oml.c:

  OC=RADIO-CARRIER(02) INST=(00,00,ff): Rx OPSTART

Change-Id: I3d4a4473541327488d3393b1fa7c6391afb3728a
2020-09-05 20:02:14 +07:00
Vadim Yanitskiy 1ac4243a13 osmo-bts-trx/trx_provision_fsm: cosmetic: switch is not a function
Change-Id: I56d2777bcc43c96b9fa1672d3ad29bf9817208bb
2020-09-05 20:01:29 +07:00
Vadim Yanitskiy a12c0b16f4 osmo-bts-trx/trx_provision_fsm: fix misleading comment in header
Change-Id: Iff9f073ce65bc443109107bb895124ec38dbbb10
2020-09-05 18:15:12 +07:00
Daniel Willmann 624b5cdc22 osmo-bts-trx: Use much lower clock advance values towards PCU and TRX
osmotrx fn-advance (which is the clock_advance variable here) and
osmotrx rts-advance together make up the minimum delay the BTS can react
to a channel request, etc.

The default of 20 are around 92ms which is clearly too much. With
modern hardware and using SCHED_RR a lower value should not be an issue.

See OS#4487 for some related measurements on more CPU-limited devices like a
LimeNet-micro3.

Fixes: OS#4487
Fixes: SYS#4885
Related: SYS#4881
Change-Id: I7da3d0948f38e12342fb714b29f8edc5e9d0933d
2020-08-17 19:11:19 +02:00
Vadim Yanitskiy 017f85ab1c osmo-bts-trx: indicate support of BTS_FEAT_HOPPING
Change-Id: I81c35d76d4ca0aa54b18c6fd1909a97b4f5f7b68
Related: SYS#4868, OS#4546
2020-08-07 23:39:01 +07:00
Vadim Yanitskiy cf3635fbaa osmo-bts-trx/scheduler: implement baseband frequency hopping
The idea behind the baseband frequency hopping is quite simple: we
have several RF carriers (transceivers) transmitting and receiving
on fixed frequencies (just like in a regular multi-trx setup), and
an additional burst routing layer between the schedulear and the
transceiver interface (TRXD over UDP).

Speaking in terms of the proposed implementation:

  - on Downlink, dlfh_route_br() calculates the ARFCN corresponding
    to the current TDMA frame number according to the hopping sequence
    parametets, and picks the transceiver with matching ARFCN;

  - on Uplink, ulfh_route_bi() iterates over the transceiver list of
    of the BTS, calculating hopping ARFCNs for equivalent timeslots,
    and picks the one with ARFCN matching the received burst.

In order to avoid frequent transceiver lookups on the Downlink path,
dlfh_route_br() maintains a "cache" in the timeslot state structure.
Unfortunately, this "cache" seems to be useless on the Uplink path,
so ulfh_route_bi() always needs to lookup the matching transceiver
for each burst received over the TRXD interface.

It may also happen that the scheduler will be unable to route an
Uplink or Downlink burst, e.g. due to inconsistent / incorrect
hopping sequence parameters received from the BSC, or in case
if a transceiver gets RF-locked by the BTS operator.

Such events are logged as "FATAL" and aditionally signalled by the
following osmo-bts-trx specific rate counters:

  - trx_sched:dl_fh_no_carrier (Downlink), and
  - trx_sched:ul_fh_no_carrier (Uplink).

Change-Id: I68f4ae09fd0789ad0d8f1c1e17e17dfc4de8e462
Related: SYS#4868, OS#4546
2020-08-07 23:39:01 +07:00
Vadim Yanitskiy 10e64630ce osmo-bts-trx/scheduler: refactor dummy burst scheduling
This change facilitates the upcoming freq. hopping implementation,
in particular scheduling of dummy bursts on C0 with hopping time-
slots.  One problem is that we cannot know in advance, whether to
send a dummy burst on a given timeslot unless all transceivers are
processed.  For example, trx#3 may want to send a normal burst on
ARFCN of trx#0 (C0), while we have already sent a dummy burst...

Another important aspect is that we shall not be sending dummy
bursts on transceivers other than C0.  Scheduling dummy bursts
from _sched_dl_burst() in the context of a single hopping timeslot
of a single transceiver leaves trx_sched_fn() no way to know
whether it's a dummy burst or something else.

Let's solve both problems by moving dummy burst scheduling logic
from _sched_dl_burst() to trx_sched_fn().  Maintain C0 slot-mask
in the inner (per-trx) loop, so that we can fill missing bursts
with dummy bursts afterwards.

Change-Id: I8c3651c27d2991079e83b8abdb7e2c3f95b97a43
Related: SYS#4868, OS#4546
2020-08-04 10:16:36 +00:00
Vadim Yanitskiy 9d5e955ea1 osmo-bts-trx/scheduler: fix CLCK.ind handling during ramping down
On receipt of either SIGTERM or SIGINT the shutdown FSM initiates
ramping down of the transmit power on Downlink.  I noticed that
for some reason osmo-bts-trx stops sending Downlink bursts during
the process of ramping down.

I also noticed the following imporatant message:

  DL1C NOTICE scheduler_trx.c:287 No more clock from transceiver

despite the transceiver is still powered on and keeps sending
the clock indications over the TRXC interface.

As it turned out, the problem is that on receipt of either SIGTERM
or SIGINT, we also raise the global 'quit' flag, so in the scheduler
trx_sched_clock() stealthy stops handling the clock indications.

Let's ensure that clock indications are handled regardless of the
state of 'quit' flag, so the ramping down would work as expected.

Change-Id: Ia71133d6f0b900e5e103595c83303a7cc5c06edf
2020-08-02 20:20:19 +00:00
Vadim Yanitskiy c14f1641c6 Constify the 'trx' argument of trx_get_hlayer1() everywhere
Change-Id: I44523d26f2f564932ea95c17b1041d0ca9cc2828
2020-08-03 02:08:14 +07:00
Pau Espin eef420d1ca bts-trx: Fix assert hit when rf_locked in .cfg and TS TCH/F_PDCH
If TRX is administratively locked during startup, for TS conigured as
TCH/F_PDCH the BSC will send a ACT PDCH message, but osmo-bts-trx won't
apply it by signalling it as available to the PCU, since the TRX is
locked.
That means the ts->flags contains the pending action to activate
it until it is unlocked. As a result, calling trx_set_ts() on it was
hitting the assert inside which expects not to apply the TS until it has
been confirmed by the PCU.
Let's still skip setting the TS and let pcu_tx_info_ind() trigger the
activation confirmation from PCU, since the TRX has just been unlocked.

Fixes following assert:
Assert failed (ts->flags & TS_F_PDCH_PENDING_MASK) == 0 /osmo-bts/src/osmo-bts-trx/l1_if.c:34

Change-Id: Ie3cad15d31870346d03a6e2f6dd32a9d2dd3067e
2020-07-27 16:58:41 +02:00
Pau Espin be15a12c87 bts-trx: Fix handling ADM state change while previous one WIP
Fix power ramping if administrative state changes while previous
opposite change was already ACKED but power ramping was still ongoing.

With previous code, osmo-bts-trx would have sent a NACK and BSc would
drop the BTs link as a result.

Change-Id: I6c5240710ef6d223651dfb4a8db939b5d2f974ca
2020-07-27 12:40:11 +02:00
Pau Espin 742590b5df bts-trx: prov_fsm: Fix mess with 1 event having 2 names
They were both half implemented but named differently, due to myself
adding them during the initial FSM implementation. This prevents
osmo-bts-trx sending a POWEROFF when OML link is dropped.

Related: SYS#4864
Change-Id: Ic2dab864b6d4075dfb9a1e4acfd9af013c9c46fe
2020-07-24 17:28:42 +02:00
Pau Espin 82a35a1dbf bts-trx: Fix osmocom dyn ts assert hit during Adm State Unlock
How to reproduce:
* Configure a TS to be TCH/F_TCH/H_PDCH in osmo-bsc.cfg
* Run the network with osmo-bts-trx, then use osmo-bsc's "rf_locked 1"
* Then, unlock it: "rf_locked 0"
* The following assert will be hit:
Assert failed ts->dyn.pchan_is == ts->dyn.pchan_want /osmo-bts/src/osmo-bts-trx/l1_if.c:349
"""
(gdb) bt
 #0  0x00007ffff5bb9355 in raise () from /usr/lib/libc.so.6
 #1  0x00007ffff5ba2853 in abort () from /usr/lib/libc.so.6
 #2  0x00007ffff6832361 in osmo_panic_default (
    fmt=0x555555814e60 "Assert failed %s %s:%d\n", args=0x7fffffffc6e0)
    at /libosmocore/src/panic.c:49
 #3  0x00007ffff683249d in osmo_panic (
    fmt=0x555555814e60 "Assert failed %s %s:%d\n")
    at /libosmocore/src/panic.c:84
 #4  0x000055555570fdf7 in trx_set_ts (ts=0x7ffff1e6bce8)
    at /osmo-bts/src/osmo-bts-trx/l1_if.c:349
 #5  0x00005555557133c1 in bts_model_chg_adm_state (bts=0x627000000160,
    mo=0x7ffff1e0f8a0, obj=0x7ffff1e0f860, adm_state=2 '\002')
    at /osmo-bts/src/osmo-bts-trx/l1_if.c:681
 #6  0x0000555555769978 in oml_rx_chg_adm_state (bts=0x627000000160,
    msg=0x633000003e00)
    at /osmo-bts/src/common/oml.c:1044
 #7  0x000055555576a8d3 in down_fom (bts=0x627000000160, msg=0x633000003e00)
    at /osmo-bts/src/common/oml.c:1129
 #8  0x0000555555770aed in down_oml (bts=0x627000000160, msg=0x633000003e00)
    at /osmo-bts/src/common/oml.c:1476
 #9  0x00005555557f8174 in sign_link_cb (msg=0x633000003e00)
    at /osmo-bts/src/common/abis.c:188
 #10 0x00007ffff73b5935 in ipaccess_bts_read_cb (link=0x6120000030a0,
--Type <RET> for more, q to quit, c to continue without paging--
    msg=0x633000003e00)
    at /libosmo-abis/src/input/ipaccess.c:980
 #11 0x00007ffff73a1060 in ipa_client_read (link=0x6120000030a0)
    at /libosmo-abis/src/input/ipa.c:72
 #12 0x00007ffff73a2458 in ipa_client_fd_cb (ofd=0x62f000038a50, what=1)
    at /libosmo-abis/src/input/ipa.c:136
 #13 0x00007ffff67ebfa7 in osmo_fd_disp_fds (_rset=0x7fffffffdda0,
    _wset=0x7fffffffde40, _eset=0x7fffffffdee0)
    at /libosmocore/src/select.c:227
 #14 0x00007ffff67ec38c in _osmo_select_main (polling=0)
    at /libosmocore/src/select.c:265
 #15 0x00007ffff67ec46b in osmo_select_main (polling=0)
    at /libosmocore/src/select.c:274
 #16 0x00005555557ef089 in bts_main (argc=7, argv=0x7fffffffe208)
    at /osmo-bts/src/common/main.c:354
 #17 0x00005555556fe621 in main (argc=7, argv=0x7fffffffe208)
    at /osmo-bts/src/osmo-bts-trx/main.c:176
"""

Related: OS#4920
Change-Id: Ia3210e24b921fd0c67f77068b7ef4a65f270cd11
2020-07-23 14:24:15 +02:00
Pau Espin 2ee6de20e2 bts-trx: Delay TRXC POWERON cmd until all TRXs are provisioned
Waiting until all other TRX are provisioned before really sending
POWERON helps avoiding race conditions where TRX!=0 are not yet fully
configured at the TRX side before POWERON is called.
This solves for instance the situation where after POWERON RSP the BTS
started ramping up on all TRX while on some NOMTXPOWER RSP was yet not
received...

Related: SYS#4920
Change-Id: I906be4714807c7a2793971cb6062120e24337d7b
2020-07-22 19:56:45 +02:00
Pau Espin 5c22fa33f7 bts-trx: Integrate TRX provisioning logic more tightly into the FSM
The state of each config required is now tracked through the "acked"
variables, this way the FSM can know when all configs are confirmed by
the TRX and can proceed to submit POWERON command.
With this version each TRX is still totally independent (there's an FSM
per TRX), which means POWERON can be sent on TRX0 before TRX!=0 are
fully configured. As a result, powe ramping may start before we know the
NOMTXPOWER of a TRX. This kind of issue will be fixed in next commit.

Related: SYS#4920
Change-Id: I1b736a4be5ce52a854f5767d8609153e1f4c08d9
2020-07-22 19:01:35 +02:00
Pau Espin 3f4588273d bts-trx: Use bool type for on/off state variables
Change-Id: Icb1b7bd8852417ab7b9a7dbc205aa6f6db97d64d
2020-07-22 18:47:52 +02:00
Pau Espin 1272af4529 bts-trx: introduce TRX provisioning FSM
With prior code state managing the TRXC side of osmo-bts-trx, there are
plenty o cases (race conditions) where things can go wrong/unexpected,
because there's really no infrastructure to wait and synchronize between
different TRXs (eg wait until all are configured to POWERON), or to
simply keep well known per-trx state regarding lower layers.

In order to fix in the future all of those issues and to sanitize
current code, a new per-trx FSM is introduced, which takes care of
submitting TRXC commands and waiting for response when needed to manage
the state of the TRX.

Related: OS#4364
Change-Id: I2a00c23df15840e33fbb232c9e1dd6db128f63f6
2020-07-14 11:44:30 +02:00
Pau Espin 414d649e01 bts-trx: Remove unused function l1if_provision_transceiver()
Change-Id: I509fdbc7883f227cef4b7e46cb68fa2418c63f97
2020-07-14 09:44:06 +00:00
Pau Espin 5432f69f16 bts-trx: Don't set OPSTATE enabled during trx_init
At that time we schedule a POWERON command towards osmo-trx, so let the
callback of RSP POWERON set the OPSTATE in l1if_poweronoff_cb rather
than setting it without waiting for confirmation from osmo-trx.

Change-Id: Ib36a073cae5e1522821a04d8806648562f4e0f5b
2020-07-14 09:44:06 +00:00
Pau Espin 9b47b27d4f Move gsm_bts code gsm-data.* => bts.*
bts.h refers to struct gsm_bts object, but we still had a bunch of stuff
in bulky gsm_data.* from old days. Let's move stuff where it belongs to
start clean up of gsm_data.

Change-Id: I0a4219e3f64f625ee8b364bf408b8d2bcc8085c5
2020-07-05 18:18:16 +02:00
Pau Espin 221ee92551 bts-trx: Implement ramp up/down during ADM state change
Ramp down when BTS is administratevly locked, and ramp up when it
becomes unlocked again.

Af ramping down, bts_model_trx_deact_rf is called to make sure all
channels are released.

power_ramp_start() is dropped from inside bts_model_trx_deact_rf since
it's not the proper place. In there we simply want to instantaneously
drop RF.

Related: SYS#4920
Change-Id: Ib7a7b0a0c24779349f142215f0bb32b72c86ce70
2020-07-05 18:16:08 +02:00
Pau Espin aba8354ed3 bts-trx: Introduce rate counter for scheduler timerfd missed FNs
This should provide a quick way to check if the system is frequently
overloaded over time and hence downlink FNs are scheduled later than
expected.

Change-Id: I0051b9ab18ebc9f92db11374d856de94f155efa4
2020-07-05 18:14:07 +02:00
Vadim Yanitskiy b505ac38e7 osmo-bts-trx/scheduler: cosmetic: move trx_if_powered() check
I believe the modern compilers are smart enough to optimize the
outer (per-timeslot) loop of trx_sched_fn() in a way that TDMA
frame number is advanced after making sure that a transceiver
is powered on.  However, it's still more perspicuous to check
availability of a given transceiver first.

Change-Id: I6a97000c1c84e36096e9ba378a489c82caa4cc5b
2020-06-29 08:51:11 +00:00
Pau Espin f23d835831 tx_power: Support controlling BTS with nominal tx pwr < 0dBm
Related: OS#4583
Change-Id: I88d59d47837105d52e2b4dfb819511cd360c50a1
2020-06-27 14:23:06 +00:00
Vadim Yanitskiy f3f0638066 osmo-bts-trx/scheduler: get rid of _sched_fcch_burst
According to 3GPP 45.002, section 5.2.4, a frequency correction
burst is basically a sequence of zeros.  Since br->burst is already
zero-initialized, there is no need to maintain and memcpy() another
sequence of zeros into it. Just set the length.

Change-Id: Ic4f6d550010da5caf4bc471ff1e184c9fab30c6d
2020-06-26 16:19:30 +00:00
Vadim Yanitskiy cdc5c6f5c5 osmo-bts-trx/scheduler: make mark trx_sched_fn() return void
This function never returns anything else than 0.

Change-Id: I119535fc09d611ef9f903f5d44aa21cecdce19a2
2020-06-25 18:02:10 +00:00
Vadim Yanitskiy f28dc5197e osmo-bts-trx: fix trx_sched_fn(): properly advance frame number
In trx_sched_fn() we schedule Downlink bursts in advance, in order
to give the transceiver some time to process them.  This function
handles all timeslots of all transceivers in a loop.  The problem
is that the given frame number is overwritten on each iteration.

Let's say we have 4 transceivers, each with default fn-advance 20.
The given frame number N will be advanced 4 times, so the resulting
frame number for 4-th transceiver would be (N + 4 * 20) instead of
(N + 20) as expected.  Therefore, all additional transceivers would
be served more and more in the future (depending on their position).

Change-Id: Ie3ab544eac81a675266df09cd2b7740e4183188e
2020-06-25 18:02:10 +00:00
Vadim Yanitskiy 2f18578dcc Use libosmocore's TDMA frame number API (constatns & arithmetic)
Depends: (libosmocore) Ic291fd3644f34964374227a191c7045d79d77e0d
Change-Id: I61c97a62bd5dbbb4a984921ebdfc10ad6ed00f2a
2020-06-25 18:02:10 +00:00
Pau Espin 504eca9d39 bts-trx: Mark 'osmotrx power' VTY cmd as deprecated
There's a standarized way through OML's Administrate State to control
the status of TRX, so let's use and maintain that one rather than this
ad-hoc hack.

Related: SYS#4920
Change-Id: Ia7f190063c35e0ed8e2e734047b3aff608cd3ce3
2020-06-23 14:19:31 +00:00
Pau Espin 8090df2a81 bts_model: Convert bts_model_trx_close() to return asynchronously
Some backends like osmo-bts-trx require exchanging messages like
POWEROFF to close the TRX, and hence need some time. Switch the function
to expect result asynchronously by calling a callback.

This will be used later to wait until all TRX are really powered off
before exiting the process.

Change-Id: I7d76b600fc06e1114b35bf0c2d08eff5bbd1b69a
2020-06-23 14:53:37 +02:00
Pau Espin 0211bd6e79 bts-trx: Split part of bts_model_trx_close() steps into bts_model_deact_rf
bts_model_trx_close is only called during bts_shutdown immediately after
bts_model_deact_rf, so its logic keeps being essentially the same after
this code movement.

On the other hand, bts_model_deact_rf is also called during RSL link
establishment if it failed for whatever reason in
bts.c:trx_link_estab(). In that case, we want to make sure the TRX is
not used so we need to implement bts_model_deact_rf.

Change-Id: Id4eae743da81773a04b82e7b454071b0cc66677a
2020-06-23 14:53:37 +02:00
Pau Espin 34940bdb2a bts-trx: Instruct user to set manually nominal-tx-power if NOMTXPOWER not supported
Using the VTY command will force that value and prevent osmo-bts-trx to
use/send NOMTXPOWER cmd over TRXC.

Change-Id: I496753bc74767a7e18b831768d9d422a738192b7
2020-06-19 20:34:08 +00:00
Pau Espin f5e22703e7 power_ramp: Add support to get callback when ramping process completes
It will be used in forthcoming commits to feed FSM events once the
ramping process completes.

Change-Id: I778dc215cf6055b93658670cc12e78ad2e51f85e
2020-06-18 19:11:55 +02:00
Vadim Yanitskiy 906a9b5e71 osmo-bts-trx: include BS Power reduction in Downlink bursts
For those osmo-bts-trx specific logical channels with a generic
logical channel state associated, let's finally apply the BS Power
reduction (attenuation) value that was received from the BSC.

Change-Id: Ib692ff1a75a80fceccb481839c8514d4b2a547b9
2020-06-15 21:06:52 +07:00
Vadim Yanitskiy b828b32f31 osmo-bts-trx: store pointer to gsm_lchan in l1sched_chan_state
This change simplifies access to generic logical channel state
(struct gsm_lchan) from osmo-bts-trx specific state (struct
l1sched_chan_state), so there is no need to look it up using
get_lchan_by_chan_nr() on receipt of each Uplink burst.

Change-Id: Ic4378020f980845b962f71b9e4b7faea738bc174
2020-06-15 20:55:23 +07:00
Vadim Yanitskiy ae781bc5cd osmo-bts-trx: introduce and use struct trx_dl_burst_req
This change is similar to what we did for Uplink bursts:

  - group all Downlink burst parameters into a single structure,
  - allocate it once and pass a pointer to lchan handlers,
  - pass a pointer to trx_if_send_burst().

Given that the structure is allocated and (zero-)initialized in
trx_sched_fn(), we can get rid of some memset() calls in lchan
handlers and thus improve the overall performance a bit.

Change-Id: If3014e69746559963569b77561dbf7b163c68ffa
2020-06-15 10:42:03 +00:00
Vadim Yanitskiy 36c5ec4881 osmo-bts-trx: move logical channel handlers to separate files
It's easier to maintain the logical channel handlers in separate
files, rather than in a huge one (scheduler_trx.c, ~2k lines).

Change-Id: Ie5663fd90596b4800a4546675a323250bbb24c80
2020-06-15 10:42:03 +00:00
Vadim Yanitskiy 0b92bcc37c osmo-bts-trx: use osmo_store32be() in trx_if_send_burst()
Change-Id: I5000fe61b29d796b9229f921bffcb392b1c6d189
2020-06-15 10:42:03 +00:00
Pau Espin 8c6bc4dbb4 bts-trx: Re-apply tx power if nominal power is received after POWERON
it was perceived that sometimes based on order of events (OML attr setup
and timing of RSL connections, etc.), the NOMTXPOWER for TRX!=0 can come
after the RSP POWERON, and hence the target power level for TRX!=0 is
not done correcty. This can be seen by running any test using the
ttcn3-bts setup of docker-playgrounds.git.

Change-Id: I2ec8dba61393be6edfab9e7e478e096e2d0933ad
2020-06-12 09:59:56 +00:00
Pau Espin 26cecfdea4 bts-trx: Use TRXC cmd NOMTXPOWER to retrieve nominal tx power from osmo-trx
Change-Id: I682211f3d664c21f923ca4a530e0464ca383b6d9
2020-06-12 09:59:56 +00:00
Pau Espin 0a81cfefea bts-trx: Introduce helper func l1if_trx_set_nominal_power
This way we wrap same logic in one place, which will be used more in
next commit.

Change-Id: I929fc50d544a88900d2e22317ec5ced10f15e51c
2020-06-12 09:59:56 +00:00
Pau Espin c854ca14d5 bts-trx: Rename setpower TRXC functions to describe they use power attenuation
Change-Id: Iedbe8e76bce990c2330477157cd886a8fc22063c
2020-06-12 09:59:56 +00:00
Pau Espin adf5d3aed2 bts-trx: Implement power ramping during BTS bring up
The nominal transmit power is still only configurable manually from
osmo-bts-trx VTY interface. Support to retrieve the nominal power
from osmo-trx will come later.

Change-Id: Ia7c353e4c199e0fc3bcab55c45a4abda2c66d2c1
2020-06-12 09:59:56 +00:00
Vadim Yanitskiy f896d64e22 osmo-bts-trx/scheduler: properly handle NOPE.ind during handover
Looking at GSMTAP during handover, I've noticed many packets on
RACH looking pretty much like false positives, all with RA=0x00.
I correlated GSMTAP traces with TRXD traces, and figured out
that they all are triggered by NOPE indications from osmo-trx.

Since a NOPE.ind carries no valid burst, all its bits are set to
zero. Funny enough, this sequence is still decoded just fine as
a valid RACH, so that's why we see it on GSMTAP. Later on it
gets rejected by L1SAP due to bad RSSI, ToA, and/or C/I ratio.

The is a side effect of [1]. In order to ensure proper Uplink
measurement reporting during handover, including the time
before the handover RACH is received, let's treat and handle
NOPE indications as Normal Bursts.

[1] Ice45d5986610d9bcef2a7e41f0a395ec779e3928

Change-Id: Ic69f3bc2b776a23374c28a6884080a54bc16ef5f
Related: OS#4592
2020-06-12 06:55:05 +00:00
Vadim Yanitskiy 578156b815 Do not mix public and private BTS features, use libosmocore's API
It was a very bad idea to mix "public" BTS features, that are
reported to the BSC via OML, and those features, that are used
locally (and exclusively) in osmo-bts.

Why? At least because we already have the BTS feature manipulation
API in libosmocore, that is used by osmo-bsc, but for some reason
not by osmo-bts. New features added to libosmocore would clash
with the existing "internal" ones like BTS_FEAT_MS_PWR_CTRL_DSP.

So what this change does can be described as follows:

  - remove duplicate definition of the "public" features,
  - use libosmocore's API for the "public" features,
  - separate both "internal" and "public" features:
    - the "public" features continue to live in bitvec,
    - the "internal" features become flags,
    - s/BTS_FEAT/BTS_INTERNAL_FLAG/g.

Change-Id: Icf792d02323bb73e3b8d46384c7890cb1eb4731e
2020-06-11 00:36:21 +07:00
Vadim Yanitskiy f1c2d40b2c osmo-bts-trx: indicate BTS_FEAT_EGPRS support to BSC
EGPRS support, in particular MCS channel coding, was introduced
to osmo-bts-trx years ago, but we still report that it's not
supported. Let's stop confusing BSC, and set this feature too.

Change-Id: Iaf92764d266e12efd2350967deffae50fbbb3b9e
2020-06-10 23:22:38 +07:00
Vadim Yanitskiy fe8f13ace3 osmo-bts-trx/trx_if: cosmetic: s/ocommand/command/
Change-Id: I06db72deb78cbab588de2103657b0722b67887a0
2020-06-07 18:59:06 +00:00
Vadim Yanitskiy 79aec05c23 osmo-bts-trx/trx_if: fix memleak in trx_ctrl_cmd_cb()
If we do not enqueue a TRXC message, we should release memory.

Change-Id: Ie2cdf547befbc0fafdb82b10b45ad85a9b188b88
2020-06-07 18:59:06 +00:00
Vadim Yanitskiy 4977e135c8 common/scheduler: use boolean for channel activation state
Change-Id: I0cb1d915db8787050cdec1802894f66e885a9bf3
2020-06-06 19:41:15 +00:00
Vadim Yanitskiy 5a877b37c2 osmo-bts-trx: fix: use noinst_HEADERS instead of EXTRA_DIST
Change-Id: I3c2fa21baae64e6537a2c74b97f1108b84099064
2020-06-06 00:31:52 +07:00
Vadim Yanitskiy 9a413231d6 osmo-bts-trx: prettify Makefile.am: make it git friendly
Change-Id: I0991910e0ffa6140f20c49bd2f0ad9b42cf231ba
2020-06-06 00:31:38 +07:00
Pau Espin dbc8372064 bts-trx: vty: Add 'nominal-tx-power' cmd
This value will be soon acquired automatically by osmo-bts-trx by asking
over TRXC to new versions of osmo-trx which is the nominal tx power for a given trx.
However, to still be able to work correctly against older versions of
osmo-trx or other TRX implementation (older or current) not supporting
this new TRX comamnd, let's allow the user to force a given value
through VTY for Tx power to work correctly.

Change-Id: Ib1b6f80d3b54afc42db9d358a79582cc619c6ce4
2020-06-03 17:33:14 +00:00
Vadim Yanitskiy 71fd083c16 osmo-bts-trx/scheduler: remove a left-over from UL TCH handlers
Change-Id: I58eedd611ecd31cc36017545de2cf29acf49f521
Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
2020-05-12 19:55:05 +07:00
Pau Espin 63920cefa6 Use OSMO_FD_* instead of deprecated BSC_FD_*
New define is available since libosmocore 1.1.0, and we already require
1.3.0, so no need to update dependenices.
Let's change it to avoid people re-using old BSC_FD_READ symbol when
copy-pasting somewhere else.

Change-Id: Id51ccb2c273c5f0fa4986f28bbd69a72d2dbaa0e
2020-05-09 18:59:47 +02:00
Philipp Maier 58b9f11898 dtx: add detection of AMR DTX frames for osmo-bts-trx
Currently we do not detect any of the DTX frames (SID_FIRST, SID_UPDATE
etc.) Detecting and tagging those frames as is_sub is important for
measurement processing. Also the RTP marker bit must be set on each
ONSET frame.

 - Add detection of DTX frames
 - Tag DTX frames as is_sub and set frame type to AMR_SID
 - Set RTP marker bit when ONSET frames are received

Change-Id: I5afe730fff2fa3199a5913b0de4f5c7b23a39f31
Depends: libosmocore I2bbdb39ea20461ca08b2e6f1a33532cb55cd5195
Related: OS#2978
2020-04-25 14:03:06 +00:00
Harald Welte 4e07b83a64 trx: Use NOPE indications from OsmoTRX for TCH/F and TCH/H
Without using the NOPE indication it might happen that we get
into the following situation:
* bursts 0,1,2 of a given block are received
* burst 3 is lost on the radio interface, OsmoTRX sends NOPE
* osmo-bts-trx doesn't pass the NOPE the the rx_tch*_fn()
* we never detect the end of the block, never perform decoding
  and even if the burst could be fully decoded, we loose the block

For voice, it can lead to lost RTP frames in uplink, which is also
problematic.

Let's deal with burst_len=0 in rx_tch*_fn() and use it as nope_fn.

Closes: OS#4661
Related: OS#2975
Change-Id: I0fbf4617daf24bd8aecfd9cfe1efd66cf73a277a
2020-03-22 14:06:47 +01:00
Harald Welte f1efd727fb trx: Fix reported BER for TCH/H
This fixes a regression introduced in I710d0b7cf193afa8515807836ee69b8b7db84a84

We (obviously!) cannot compute the BER before performing convolutional
decoding.

Change-Id: I4e57f45d49cb513e4843e56f50c8de6980958fdc
Related: OS#2977
Related: OS#4667
2020-03-22 14:06:47 +01:00
Pau Espin 6ea3b28321 cosmetic: Fix some typos with codespell
Change-Id: I1bbb4871f764816dcbba86d833194be601fa9228
2020-02-25 18:51:15 +01:00
Pau Espin eba074e081 bts-trx: trx_if.c: Fix some printf formats
Compiler from raspberrypi4 warns/errors about those.

Change-Id: I4f973eb4ffdf8869b522d14e25853357fcd1e984
2020-02-25 18:28:52 +01:00
Philipp Maier d4f67591c7 l1sap: merge MEAS IND into PRIM PH DATA / PRIM TCH
The MPH INFO MEAS IND indication, which contains the uplink measurement
data is sent in parallel to the PH DATA and TCH indications as a
separate indications. This makes the overall uplink measurement data
processing unnecessarly complex. So lets put the data that is relevant
for measurement into the PH DATA and TCH indications directly.

This change only affects osmo-bts-trx at the moment. In order to keep
the upper layers (l1sap.c) compatible we add an autodection to switch
between separate measurement indications and included measurement data.

Related: OS#2977
Depends: libosmocore I2c34b02d329f9df190c5035c396403ca0a4f9c42
Change-Id: I710d0b7cf193afa8515807836ee69b8b7db84a84
2020-01-20 14:35:19 +00:00
Philipp Maier a0403d3769 ta_control: move timing advance code from osmo-bts-trx to common
The timing advance controller that is implemented in loops.c of
osmo-bts-trx only works for osmo-bts-trx and not for any of the phy
based bts. Lets move the timing advance controller into the common part
and make it available for every bts. Also lets add a unit-test.

Change-Id: If7ddf74db3abc9b9872abe620a0aeebe3327e70a
Related: SYS#4567
2020-01-20 14:33:49 +00:00
Philipp Maier 66c17cfc2d rsl: ensure measurement reports are sent
osmo-bts currently does not generate a measurement report in case the
SACCH of the related traffic channel is lost. This is a problem because
the moment when reception gets bad measurmenet reporting is crucial to
carry out handover decisions effectively.

The presence of a SACCH block controls the conclusion of the measurement
interval and the sending of the RSL measurement report. The latter one
not only requires a measurmenet indication, it also requires a fully
intact SACCH block.

Lets use the NOPE / IDLE indications from V1 of the TRXD protocol to
ensure a SACCH block is always reported up to l1sap.c. In cases where
the SACCH is bad, trigger the sending of the RSL measurement report
manually without attaching the measurmenet data from the MS (which we do
not have in this case)

Related: OS#2975
Depends: osmo-ttcn3-hacks Ib2f511991349ab15e02db9c5e45f0df3645835a4
Change-Id: Idfa8ef94e8cf131ff234dac8f93f337051663ae2
2020-01-03 12:56:00 +01:00
Pau Espin e3a4530919 bts-trx: Drop low layer MS Power Control Loop algo
Let's drop it instead of having code duplication from common code in a
lower layer, and maintain only the one in l1sap for all BTS models.
As a result, osmo-bts-trx loses feature BTS_FEAT_MS_PWR_CTRL_DSP and
will only be able to use "ms-power-control osmo" in VTY, which will be
enabled by default (meaning: change of behavior, now MS Power Control is
enabled by default in osmo-bts-trx and can only by disabled by BSC).
Old bts-trx specific VTY command "(no) osmotrx ms-power-loop" is marked
as deprecated but still working for more usual case (1 TRX configured)
to avoid breaking backward compatibility.

TA low level loop is still kept in loops.c and will be moved to l1sap at
some point too.

Related: OS#1851
Change-Id: I0d8b0c981d9ead91d93999df6e45fb06e426aeb9
2019-11-30 18:50:04 +00:00
Pau Espin 0d8cd8ce39 scheduler_trx.c: cast ptrdiff value to fix printf format
On an ARM toolchain:
scheduler_trx.c:294:3: warning: format '%ld' expects argument of type 'long int', but argument 10 has type 'int'

Let's cast it to long int to make sure correct size is applied in all
platforms.

Change-Id: I701b3dbc4e84db21cf02305d374b0df731e70313
2019-11-27 00:19:30 +00:00
Vadim Yanitskiy 595eb576fc osmo-bts-trx/trx_if.c: fix: NOPE.ind also contains C/I field
Change-Id: I201b72d2a6f5307ede252d5d707f1ebadafe6a4b
2019-11-20 13:43:37 +00:00
Philipp Maier 5c5ad3cb4a scheduler_trx.c: avoid division by zero when calculating BER
There is theoretical risk that when calculating the BER that a division
by zero occurrs. Lets add a check to avoid n_errors / n_bits_total when
n_bits_total is zero.

Change-Id: I1c0731b9a60be4b8c0c84b85b4403168120ceacd
Fixes: CID#205696
2019-11-20 13:35:02 +00:00
Vadim Yanitskiy 19857fbdaa osmo-bts-trx/trx_if.c: also print both RSSI and ToA256 for NOPE.ind
Change-Id: I36586ac33757705df16e14cfdd92becb96c8cf70
2019-11-19 13:54:40 +07:00
Vadim Yanitskiy 8a98255fb5 osmo-bts-trx/trx_if.c: fix: always initialize bi->burst_len for NOPE.ind
A NOPE.ind indicates absence of an Uplink burst, thus it does not
carry a burst. Let's init the burst length to avoid uninitialized
memory access in the scheduler code.

Change-Id: I77f686bf7df385215892e71733a28ff0d90d7222
Fixes: CID#205857
2019-11-19 13:54:36 +07:00
Vadim Yanitskiy b37b3263a9 osmo-bts-trx: general handling of NOPE / IDLE indications
Each logical channel can now optionally have an additional handler,
that will be called when a NOPE / IDLE indication is received from
the transceiver. The aim of that handler is to keep the logical
channel state updated in case if one or more Uplink bursts are lost.

Change-Id: I71c552f44c25e56e9779d8b8ef5d4de9f8475637
Related: OS#3428
2019-11-19 01:01:45 +00:00
Pau Espin c693067b7e Introduce BTS feature BTS_FEAT_MS_PWR_CTRL_DSP
It indicates whether BTS model supports managing an MS Power Control
Loop over HW/DSP instead of using the software based osmocom algorithm
present in osmo-bts.
osmo-bts-trx own loop implementation is considered to be a "DSP/HW" one
since it acts on lower layers and interferes with osmocom algorithm
since it controls the same end variable "lchan->ms_power_ctrl.current",
this way we make sure both aren't enabled at the same time.
Old behavior in kept: if common upper-layer algo is not enabled
explicitly in VTY (ms-power-control osmo) and bts-trx specific lower
layer algo is neither enabled (osmotrx ms-power-loop <xyz>), then no
power control is done at all.

Related: OS#1851
Change-Id: I49706926b1e962b18791174627bc3cc0cd0cd9d5
2019-11-14 20:02:45 +01:00
Pau Espin f0e66d90f8 bts-trx: loops.c: Avoid always clamping MS power to MS power class 1
The affirmation written there is not true, since actually it depends on
the band. For instance, for DCS1800 the maximum MS power is provided by
class 3. Let ms_pwr_ctl_lvl() take care of campling instead.

Change-Id: I744e7c315b818a1e7d3dd2579cd483c693d89b73
2019-11-14 16:36:00 +01:00
Pau Espin e717aec2f7 Move and rename gsm_lchan.ms_power field
Make it clear that it contains the maximum MS power level (TS 05.05) and
not the one to be used. The one aimed at is in ms_power_ctrl.current.
Since it's used in related code, move it inside the ms_power_ctrl struct
too.

Related: OS#1851
Change-Id: Ib264ec7dac87355cef6415461ed74bd8e9c8ca52
2019-11-14 16:36:00 +01:00
Pau Espin 80f2bc4855 bts-trx: Implement MS Power control loop calculations using dBm instead of ctl levels
Some bands, such as DCS1800, contain power levels such as 29, 30 and 31 not following same
unified sequence other power levels follow regarding conversion to dBm
values.
This makes extremly complex and prone to error comparing different power
levels. Let's instead use dBm values to calculate and crop desired new
value, and then convert it back to TS 05.05 ms power control level
value.

With this commit the control loop should be able to manage correctly the MS power
levels explained above.

Related: OS#4244
Change-Id: I0160637c5ffa606ee3081ad30be8e6f2a42b725b
2019-11-12 14:19:08 +01:00
Philipp Maier a9d88af594 scheduler_trx: initalize n_errors, n_bursts_bits, n_bits_total
Make sure the variables n_errors, n_bursts_bits, n_bits_total are always
initalized. For example in rx_tchh_fn() the value for n_errors is
defined in a switch statement, where the default lets n_errors
uninitalized, which is in that particular case a theoretical problem,
however, lets make sure that the variables n_errors, n_bursts_bits and
n_bits_total are always initalized with 0

Related: CID#205452
Related: CID#205451
Change-Id: If28ea11cc111c7d73ca47b25e65ce399e5baa4c1
2019-10-31 13:08:57 +01:00
Philipp Maier 132987daf4 scheduler_trx: use gsm0502_fn_remap() to calculate frame number
When sched_compose_tch_ind, sched_compose_ph_data_ind or l1if_process_meas_res
is called from rx_tchf_fn or rx_tchh_fn the frame number of the beginning of
the block is required. At the moment this frame number is calculated
wrongly using strange formulas. Lets use gsm0502_fn_remap() to calculate
the beginning of the block properly

Change-Id: I37601ddd85e4287dd9e41ad4a8cb7d314de1a83d
Depends: libosmocore I3d71c66f8c401f5afbad9b1c86c24580dab9e0ce
Related: OS#3803
2019-10-29 10:16:56 +00:00
Pau Espin 5a60287e44 loops.h: Fix missing include for struct l1sched_trx
Change-Id: I67b63367e46bd43807f61e8f7e63924b8c2427e4
2019-10-28 11:05:47 +01:00
Pau Espin 1e9d4feba5 bts-trx: loops.c: Take into account RSL CHAN ACT ms power level limits
TS 48.058 sec 4.8 MS power control:
"""
TRX then attempts to keep the power control parameters within the limits
set by the MS POWER CONTROL message (or by the CHANNEL ACTIVATION message)
by changing the MS Power Level field of the L1 header sent to MS in each
SACCH block.
"""

Fixes TTCN3 BTS_Tests.TC_rsl_ms_pwr_dyn_max

Change-Id: Ifda92155bd9c277ac150a327a7ab63c854087788
2019-10-28 11:05:29 +01:00
Pau Espin a456f2bd15 cosmetic: bts-trx: document variable power level
Change-Id: Ia4bc291c8213dd6cfe3b13a99b3108532b6907b1
2019-10-28 10:51:49 +01:00
Vadim Yanitskiy be1651bb51 osmo-bts-trx/scheduler: fix: print the last frame number in rx_data_fn()
All other Uplink burst handlers print frame number of the last
(currently received) burst. Let's make rx_data_fn() consistent.

Change-Id: Ie5762a132326be3ef4e4e38cc126f05d51098a20
2019-10-21 11:21:55 +00:00
Martin Hauke b378fccef1 Fix common misspellings and typos
Change-Id: I403b9029f57fec3fdec2c1e2cbeac0f6eab53f24
2019-10-17 08:05:35 +00:00
Pau Espin 8ff35d3c91 bts-trx: Time out if no clock ind recvd after RSP POWERON
Before this patch, if due to whatever reason the TRX started fine (RSP
POWERON 0) and sockets were created but no CLOCK IND was ever received
by the BTS, it wouldn't notice since the timerfd timeouts
(bts_shutdown("no clock")) are only checked after the first CLOCK IND is
sent by the TRX.
As a result, the BTS would be kept on forever saying everything is fine
but it would be sending no DL burst at all to the TRX (tested with a
modfied osmo-trx dropping clock indication).
With this patch, new APIs are added to indicate the scheduler_trx code
the timeframes where clock ind are expected (between RSP POWERON 0 and
RSP POWEROFF 0); if TRX sends clock indications out of that timeframe,
BTs lower layers will drop them (controlled by "powered" bool).
Hence, the scheduler_trx can now place a timeout (reusing same timerfd
because its new use is exclusive in time with its other previous use)
when it is told that CLOCK IND should start appearing, and if none
arrives in considerable time, then the BTS can be shut down to notify
the rest of the network.

Related: OS#4215
Change-Id: Iba5dbe867aff10e70ec73dbf1f7aeeecb15c0a4d
2019-10-16 11:13:21 +00:00
Pau Espin d8284eec63 bts-trx: Log TRXC and TRXD socket recv()/send() failures
Related: OS#4215
Change-Id: Ic3e41d82b43459495d45873d612a3bd349ac174a
2019-10-09 11:57:37 +00:00
Pau Espin b6be055e6b bts-trx: Drop unused func check_transceiver_availability()
After getting rid of transceiver_available, this function is not used
anymore by any code, since its per-trx counterpart
l1if_provision_transceiver_trx() is the one used by other
code.

Change-Id: If5a988eb14658a78dd46234dccc052dc12fb872a
2019-10-05 20:50:13 +00:00
Pau Espin ca574b19d3 bts-trx: Get rid of messy transceiver_available state handler
This variable meaning has been changing its exact meaning over time
until finally not being really clear which kind of state it holds.
Initially it seemed to be used to identfy whether CLOCK IND were being
received. However, over time both osmo-bts and osmo-trx have evolved and
were fixed so that clock indications are only sent by osmo-trx after
POWERON command is sent. As a result, this state can be checked simply by
looking at the "powered" phy_link variable, which is only set to true
once the TRX has confirmed the POWERON command, and hence it is sending
CLOCK IND.
On the other hand, at some point in time "available" started to be set to 1
in bts_model_phy_link_open(), which means available is nowadays almost
always 1 from startup until the end (only dropped during bts_shutdown(),
when we are already exiting the process anyway).
As a result, !available condition in scheduler_trx.c:trx_fn_timer_cb can
almost never happen, because available is set to true already. Only
possibility would be if an old process of osmo-trx (not set up by this
BTS process) is still sending CLOCK INDs, but in that case we for sure
don't want to configure the BTS based on that, but ignore them until
this BTS process has again configured the TRX. So that whole check can
be dropped. We are better checking for "powered" state, which is far
more accurate, and we better do that in trx_if.c before calling
trx_fn_timer_cb().

Other uses of "transceiver_available" being used can be changed to use
plink->state!= PHY_LINK_SHUTDOWN, since available was already being set
to 1 at the same time the plink->state was being set to
PHY_LINK_CONNECTING.

As a result of this state handling re-arrangement, OS#4215 is fixed
since trx_if_powered() is used instead of previous state condition to
check whether data frames should be sent.

Related: OS#4215
Change-Id: I35f4697bd33dbe8a4c76c9500b82c16589c701d4
2019-10-05 20:50:13 +00:00
Pau Espin 9e1f0e1a13 bts-trx: Don't reset transceiver_available in scheduler_trx.c
It can be dropped since bts_shutdown() ends up calling immediatelly
bts_model_trx_close() which in turn calls bts_model_trx_close() which
sets enabled = false and calls l1if_provision_transceiver_trx() to
power off the TRX.

Related: OS#4215
Change-Id: If8b3d2379d7ae102e1c338f4558ac1352de761cc
2019-10-05 20:50:13 +00:00
Pau Espin 96cb0c54a9 bts-trx: Rework code handling poweron state
Use of variables in each code is confusing and mixing configuration with
POWERON/POWEROFF state (which is at least per phy inst and not per TRX,
since those commands are only expected on the 1st phy inst).

* field "poweron" becomes "enabled", and is used as an indicator for
actions to take during TRX provisioning (hether to power it on and
configure it or to power it off).
* poweron/poweroff state becomes "powered", and it is shared by all trx
in same phy_link, and is updated only after confirmation by TRX.
* poweron_set becomes poweronoff_set (because it's used by both POWERON
and POWEROFF), and becomes shared by all trx in same phy_link, since
those CMDs are usually sent by first phy instance of the link (the first
trx).

Related: OS#4215
Change-Id: Icd0b482f1454236432e1952220bbec9d178b8607
2019-10-05 20:50:13 +00:00
Pau Espin 4b72ee924c bts-trx: trx_set_bts(): Avoid double loop by checking current trx
check_transceiver_availability() is a loop over every trx, same to what
trx_set_bts() does, so let's call the per-trx version directly.

Change-Id: I8843c1438c6af700631aba7b7e72aae0bdb7ec3a
2019-10-05 20:50:13 +00:00
Pau Espin 520954cd93 bts-trx: vty: Print phy link state in cmd 'show transceiver'
Change-Id: I8e49f8edad9f9c68d110dbb7faeea5143aa91022
2019-10-05 20:50:13 +00:00
Pau Espin accbf5bc73 bts-trx: Allocate struct osmo_trx_clock_state as part of bts-trx private data
Related: OS#4215
Change-Id: I9b7ffb51423ada74b8be347c57eade08f307f88f
2019-10-05 20:50:13 +00:00
Vadim Yanitskiy 0772cd0460 osmo-bts-trx/scheduler: also detect TSC for Access Bursts on PDCH
If a logical channel, on which an Access Burst has been received,
is not either of RACH, PDTCH or PTCCH, then this is a handover
Access Burst, which is always encoded as 8-bit and shall contain
the generic training sequence (TS0).

Access Bursts on a PDCH time-slot are not related to handover.

Change-Id: If7d6135d6c4d7f9bd71d9fab6f8adc3f8cfd10ea
2019-10-04 15:53:53 +00:00
Pau Espin c91997b2cc bts-trx: vty: Use API to get poweron state
Change-Id: I8b78e1ad34f19d8fe348b9c975742fc0f7112da2
2019-09-27 13:38:51 +02:00
Pau Espin a1f2b6931b bts-trx: Change super verbose IDLE ind not-supported line to DEBUG
It's impossible to see other logging otherwise.

Change-Id: I64ee83b734ecff593ff2a1cf97b192db93228e22
2019-09-19 10:07:32 +00:00
Vadim Yanitskiy b86e9260e8 osmo-bts-trx/scheduler: fix: check rc of osmo_ecu_frame_out()
Change-Id: I32d244f5ddef46c8b8719f5ec27b7456514d407a
Fixes: CID#204005 (CID#204007), CID#204006 (CID#204004)
2019-09-12 22:59:31 +02:00
Pau Espin 3061e1d14a bts-trx: Log case where no SETFORMAT is sent
If VTY cmd "osmotrx trxd-max-version 0" is used, max version 0 is used
(default starting one) and hence no need to send SETFORMAT (this is
useful in order to avoid sending SETFORMAT to old TRX implementations
not supporting the command). In this case, let's inform the user that
indeed osmo-bts won't send SETFORMAT because version 0 is assumed.

Change-Id: I7136ea6745c2275278bc400676b58fb4b10da966
2019-09-10 14:48:19 +00:00
Harald Welte ec228cc08c osmo-bts-trx: migrate to new generic ECU abstraction
libosmocodec has recently introduced a generic ECU abstraction layer
which supports (pluggable) Error Concealment Units for not only the
FR codec, but potentially any other codec, too.

Change-Id: I001005aae6de76d4e045b8dc572239f057bb150d
Depends: libosmocore I4d33c9c7c2d4c7462ff38a49c178b65accae1915
2019-09-10 12:26:21 +00:00
Vadim Yanitskiy e6a72c2b80 osmo-bts-trx/scheduler: add FIXME note about FACCH/H and BFI
Change-Id: Ie006cd46cb574d272fbe3b38595a3087617c79d1
2019-09-07 23:09:09 +00:00
Vadim Yanitskiy 454b034521 osmo-bts-trx/scheduler: fix tx_tch_common(): do not send AMR BFI twice
We call _sched_compose_tch_ind() after the switch statement, so
there is no need to send it from case 'GSM48_CMODE_SPEECH_AMR'.

Change-Id: I0488082494120157ac438d7763b52e3998f0eac7
2019-09-07 23:05:22 +00:00
Harald Welte 9d5acaad5c osmo-bts-trx/scheduler: prevent uninitialized memory access
When sending an AMR BFI, we need to call osmo_amr_rtp_enc() with
AMR_BAD as the last parameter. This function returns the length
of encoded payload, which needs to be at least 2 octets long.

If osmo_amr_rtp_enc() returns a length value lower than 2 octets
(what should not happen in general), we should neither call
memset() on it, nor call _sched_compose_tch_ind().

Change-Id: I70ce98c5697b9ce6fac7ab57a5d70f3201db29d9
Fixes: CID#178648, CID#178637, CID#178651
2019-09-07 23:05:22 +00:00
Harald Welte cb0cb897ad scheduler_trx: Handle negative return of gsm0503_tch_hr_decode()
If gsm0503_tch_hr_decode() returns a negative error, we shouldn't
set the marker bit or pass the negative value as length value into
osmo_hr_check_sid().

Change-Id: If49ca6926c576a2b17507b6a95b6f3ca17877d66
Closes: CID#187645
2019-08-02 07:30:58 +00:00
Harald Welte e8e864b219 osmo-bts-trx: Don't attemtp to adjust MS power if fixed
If the BSC has instructed the BTS via RSL to not autonomously perform
MS power control, we are storing this in lchan->ms_power_ctrl.fixed.

However, osmo-bts-trx would simply ignore that flag in loops.c and
continue to compute new MS power values based on measurement results.

Change-Id: I628d1f4f1094c22248d372c11c2ecc504135b757
2019-07-31 12:10:39 +02:00
Harald Welte 89f06e6c54 osmo-bts-trx: Don't increment rssi_valid_count twice
In the ms_power_val() function, don't increment the number of
valid RSSI values counter twice.

Change-Id: I19d9d933a69f7ad6252cbe51751d5db41790c698
2019-07-31 12:10:12 +02:00
Pau Espin 160b624da8 trx: Use LOGPPHI instead of LOGP in some more messages
This allows to clearly identify the phy instance owning those messages.

Change-Id: I90990e4dbcbb2fb4a3fcb24658bdf53e57030bcf
2019-07-24 19:28:56 +00:00
Pau Espin e6372cff1b bts-trx: Introduce VTY command osmotrx trxd-max-version
This command allows setting a maximum TRXD format version to negotiate
with TRX. osmo-bts-trx will hence end up using that version if supported
by TRX, or a lower one otherwise (or fail if TRX doesn't support any of
them).
Since now the maximum version can be 0, avoid going through SETFORMAT
negotiation in that case, since 0 is the default version. This way we
keep backward compatibility with TRX implementations that exit upon
receival of unknown commands (such as SC5 current one).

The VTY command is located in the "phy" node instead of the "phy
instance" node because instances of same phy are expected to use same
host with same implementation, so TRXD version to use should be the same
for both.

Related: OS#4006
Change-Id: I5eb1fdc002f9d7f4acf475356d8fc998dc8f6326
2019-07-23 17:21:40 +02:00
Vadim Yanitskiy aa54224e56 osmo-bts-trx/scheduler: rx_data_fn(): provide actual C/I ratio to L1SAP
Change-Id: Iea0dad65e9bc511f99375fd3ee2eb44e47a6168f
2019-07-21 21:55:51 +07:00
Vadim Yanitskiy 4ff47ff39a osmo-bts-trx/scheduler: rx_rach_fn(): provide actual C/I ratio to L1SAP
Change-Id: I8d86dec7ebc039cbfd038c4342ff328b11281865
2019-07-21 21:55:51 +07:00
Vadim Yanitskiy b777c0f3ec Move Access Burst link quality handling to L1SAP
Change-Id: I893ec9c6c2ebad71ea68b2dc5f9f5094dfc43b78
Depends: (libosmocore) Ie2a66ebd040b61d6daf49e04bf8a84d3d64764ee
2019-07-21 21:55:51 +07:00
Thorsten Alteholz 2131a7931e fix spelling stuff mentioned by lintian
Change-Id: I3d6cb6fc1b182d8520ba60e431ab9b74e71d5e3c
2019-07-17 10:58:57 +00:00
Vadim Yanitskiy af6f39025f osmo-bts-trx/scheduler: rx_rach_fn(): enrich debug message
Change-Id: I1cb28a9d6c98993705b73937409276994f375dc0
2019-07-16 04:16:13 +00:00
Vadim Yanitskiy 1ea7fd0609 osmo-bts-trx/scheduler: rx_rach_fn(): clarify handover RACH handling
Change-Id: I3da39d48052af1759297f4ad75c220b3046c0691
2019-07-16 04:16:13 +00:00
Vadim Yanitskiy dc48fd8810 osmo-bts-trx/scheduler: rx_rach_fn(): use optional TSC info from TRX
TSC (Training Sequence Code) is an optional parameter of the UL burst
indication. We need this information in order to decide whether an
Access Burst is 11-bit encoded or not (see OS#1854).

If this information is absent, we try to correlate the received synch.
sequence with the known ones (3GPP TS 05.02, section 5.2.7), and
fall-back to the default TS0 if it fails.

Since the new TRXD header version, the training sequence code is
indicated by the transceiver. Let's use it!

Change-Id: I1e654a2e49cb83c5f1e6249c0de688f99bc466b0
Related: OS#1854, OS#4006
2019-07-16 04:16:13 +00:00
Vadim Yanitskiy 54e104496a osmo-bts/scheduler: provide actual C/I values to OsmoPCU
C/I (Carrier-to-Interference ratio) is a value in cB (centiBels),
computed from the training sequence of each received burst,
by comparing the "ideal" training sequence with the actual one.

So far, there was no way to expose more measurements from OsmoTRX,
excluding both RSSI and ToA. Since the new version of TRXD header,
we can receive C/I indications and send the averaged (per 4 bursts)
values to OsmoPCU (as a part of PCUIF_DATA.ind).

Please note that we also need to attach C/I measurements
to the following L1SAP primitives:

  - PRIM_PH_RACH.ind,
  - PRIM_PH_DATA.ind,
  - PRIM_TCH.ind,

but this will be done in the follow up changes.

Change-Id: Ia58043bd2381a4d34d604522e02899ae64ee0d26
Fixes: OS#1855
2019-07-16 04:16:13 +00:00
Vadim Yanitskiy 01cc8c0d21 osmo-bts-trx/scheduler: pass trx_ul_burst_ind to lchan handlers
This change needs to be done in order avoid adding more and more
arguments to the UL logical channel handlers (such as rx_rach_fn).

Since we have different versions of the TRXD header, and may have
other burst-based PHYs in the future, some fields of an Uplink
burst indication have conditional presence.

Change-Id: Iae6b78bafa4b86d0c681684de47320d641d3f7c0
Related: OS#4006, OS#1855
2019-07-16 04:16:13 +00:00
Vadim Yanitskiy 55dbafc497 osmo-bts-trx/trx_if.c: encode actual TRXD header version
Both TRX2L1 (Uplink) and L12TRX (Downlink) messages should use
the same TRXD header format (and version) as was negotiated.

Change-Id: Idbc598ef7c1871ee8da830f3fbe0a5cc386f873d
Related: OS#4006
2019-07-16 04:16:13 +00:00
Vadim Yanitskiy 139b8caa79 osmo-bts-trx/trx_if.c: add TRXD header version negotiation
This change introduces a new command for TRXD header format
negotiation - SETFORMAT. If the transceiver does not support
the format negotiation, it would reject this command with
'RSP ERR 1'. If the requested version is not supported by
the transceiver, status code of the response message should
indicate a preferred (basically, the latest) version.

The format of SETFORMAT command is the following:

  L1 -> TRX: CMD SETFORMAT VER_REQ
  L1 <- TRX: RSP SETFORMAT VER_RSP VER_REQ

where:

  - VER_REQ is the requested version (suggested by the L1),
  - VER_RSP is either the applied version if matches VER_REQ,
    or a preferred version if VER_REQ is not supported.

If the transceiver indicates VER_RSP different than VER_REQ,
OsmoBTS is supposed to reinitiate the version negotiation
using the suggested VER_RSP. For example:

  L1 -> TRX: CMD SETFORMAT 2
  L1 <- TRX: RSP SETFORMAT 1 2

  L1 -> TRX: CMD SETFORMAT 1
  L1 <- TRX: RSP SETFORMAT 1 1

If no suitable VER_RSP is found, or the VER_REQ is incorrect,
the status code in the response would be -1.

As soon as VER_RSP matches VER_REQ in the response, the process
of negotiation is complete. Changing the header version is
supposed to be done before POWERON.

Change-Id: I8afe950bd1ec2afaf3347ff848ee46e69c4f5011
Related: OS#4006
2019-07-16 04:16:13 +00:00
Vadim Yanitskiy 7d1d294807 osmo-bts-trx/trx_if.c: properly describe TRXD messages in logs
Since we may have different versions of the TRXD header, some new
fields of an Uplink burst indication have conditional presence.
Therefore we need a smart function to print them conditionally.

Change-Id: I68729dc98a1840d2aa9e091153d176a103d5a228
Related: OS#4006
2019-07-04 13:37:33 +07:00
Vadim Yanitskiy 3f2283cd3c osmo-bts-trx/trx_if.c: drop RSSI / ToA debugging code
This kind of debugging can be done using trx_sniff.py tool from
the TRX Toolkit [1]. Probably, this code was needed during the
initial development and testing.

[1] https://git.osmocom.org/osmocom-bb/tree/src/target/trx_toolkit

Change-Id: I50e0e5feeba4c3028f55209dd8e41e09ed5f70b1
2019-07-04 01:37:53 +07:00
Vadim Yanitskiy a99c41bac5 osmo-bts-trx/trx_if.c: introduce TRXD header version 0x01 support
The new version adds the following fields to the TRX2L1 message,
keeping the L12TRX message unchanged:

  +------+-----+-----+-----+--------------------+
  | RSSI | ToA | MTS | C/I | soft-bits (254..0) |
  +------+-----+-----+-----+--------------------+

  - MTS (1 octet)  - Modulation and Training Sequence info, and
  - C/I (2 octets) - Carrier-to-Interference ratio (big endian).

== Coding of MTS: Modulation and Training Sequence info

3GPP TS 45.002 version 15.1.0 defines several modulation types,
and a few sets of training sequences for each type. The most
common are GMSK and 8-PSK (which is used in EDGE).

  +-----------------+---------------------------------------+
  | 7 6 5 4 3 2 1 0 | bit numbers (value range)             |
  +-----------------+---------------------------------------+
  | . . . . . X X X | Training Sequence Code (0..7)         |
  +-----------------+---------------------------------------+
  | . X X X X . . . | Modulation, TS set number (see below) |
  +-----------------+---------------------------------------+
  | X . . . . . . . | IDLE / nope frame indication (0 or 1) |
  +-----------------+---------------------------------------+

The bit number 7 (MSB) is set to high when either nothing has been
detected, or during IDLE frames, so we can deliver noise levels,
and avoid clock gaps on the L1 side. Other bits are ignored,
and should be set to low (0) in this case.

== Coding of modulation and TS set number

GMSK has 4 sets of training sequences (see tables 5.2.3a-d),
while 8-PSK (see tables 5.2.3f-g) and the others have 2 sets.
Access and Synchronization bursts also have several synch.
sequences.

  +-----------------+---------------------------------------+
  | 7 6 5 4 3 2 1 0 | bit numbers (value range)             |
  +-----------------+---------------------------------------+
  | . 0 0 X X . . . | GMSK, 4 TS sets (0..3)                |
  +-----------------+---------------------------------------+
  | . 0 1 0 X . . . | 8-PSK, 2 TS sets (0..1)               |
  +-----------------+---------------------------------------+
  | . 0 1 1 X . . . | AQPSK, 2 TS sets (0..1)               |
  +-----------------+---------------------------------------+
  | . 1 0 0 X . . . | 16QAM, 2 TS sets (0..1)               |
  +-----------------+---------------------------------------+
  | . 1 0 1 X . . . | 32QAM, 2 TS sets (0..1)               |
  +-----------------+---------------------------------------+
  | . 1 1 1 X . . . | RESERVED (0)                          |
  +-----------------+---------------------------------------+

== C/I: Carrier-to-Interference ratio

The C/I value is computed from the training sequence of each burst,
where we can compare the "ideal" training sequence with the actual
training sequence, and then express that difference in centiBels.

== Limitations

  - The only supported modulation types are GMSK and 8-PSK.
    Messages with other modulation types will be rejected.

  - IDLE / NOPE indications are not (yet) handled.

  - The logical channel handlers do not (yet) handle optional
    fields, such as TSC and C/I. This will be implemented
    in the follow-up changes.

Change-Id: If61c71d20d590bf07bfd019afb33000a0b6135bd
Related: OS#4006
2019-07-04 01:28:50 +07:00
Vadim Yanitskiy b06cd9f439 osmo-bts-trx/trx_if.c: introduce TRXD header version handling
It may be necessary to extend the message specific header with
more information. Since this is not a TLV-based protocol, we
need to include the header format version.

  +-----------------+---------------------------+
  | 7 6 5 4 3 2 1 0 | bit numbers (value range) |
  +-----------------+---------------------------+
  | X X X X . . . . | header version (0..15)    |
  +-----------------+---------------------------+
  | . . . . . X X X | TDMA TN (0..7)            |
  +-----------------+---------------------------+
  | . . . . X . . . | RESERVED (0)              |
  +-----------------+---------------------------+

Instead of prepending an additional byte, it was decided to use
4 MSB bits of the first octet, which used to be zero-initialized
due to the value range of TDMA TN (0..7). Therefore the current
header format has implicit version 0.

Otherwise Wireshark (or trx_sniff.py) would have to guess the
header version, or alternatively follow the control channel
looking for the version setting command.

This change introduces a new structure 'trx_ul_burst_ind', which
represents an Uplink burst and the corresponding meta info. The
purpose of this structure is to avoid overloading the existing
functions, such as trx_sched_ul_burst(), with more and more
arguments every time we bump the version.

On receipt of a TRXD message, trx_data_read_cb() now parses
the header version, and calls the corresponding dissector
functions, e.g. trx_data_handle_(hdr|burst)_v0().

Change-Id: I171c18229ca3e5cab70de0064a31e47c78602c0c
Related: OS#4006
2019-06-27 12:51:02 +07:00
Vadim Yanitskiy d1e7d0dafa osmo-bts-trx/trx_if.c: rename and clarify TRX_MAX_BURST_LEN
This constant actually defines the maximum TRXD message length,
which includes the header and burst bits, not just burst.

Change-Id: I383125e1c4df039fc6b554833bc8736deacbe731
2019-06-27 05:50:17 +00:00
Vadim Yanitskiy b5c23092c7 osmo-bts-trx/trx_if.c: use osmo_loadXXbe() for TDMA FN and ToA256
Change-Id: Iec0d86f9be7243578ddc1ab322fc313cb5ac5d0b
2019-06-27 05:50:17 +00:00
Pau Espin 8576477de1 bts-trx: trx_if.c: Introduce logging macro LOGPPHI
This way we unify format. We take the chance to add related information
to some log messages which were not printing that information (and was
confusing when using more than one phy instance).

Change-Id: I5b17a01638ade9a6c41da73e550d5947fa92f568
2019-06-04 17:58:46 +02:00
Vadim Yanitskiy 9d083ab236 osmo-bts-trx/l1_if.h: drop unused ho_rach_detect from trx_l1h
Change-Id: I90b6d7fb1bb7ba2f8b1f500043635b0ae5cb4495
2019-06-01 23:10:02 +07:00
Vadim Yanitskiy e50903df9d osmo-bts-trx/trx_if.c: dropping Tx bursts is a noticeable event
Change-Id: Ia954b797a9bb90660b6548ec0ffb218a1dcff37a
2019-06-01 13:43:21 +07:00
Vadim Yanitskiy 5f9e42a891 osmo-bts-trx: distinguish 11-bit Access Bursts by synch. sequence
Thanks to both TC_rach_content and TC_rach_count TTCN-3 test cases,
it was discovered that there are possible collisions when trying
to decode a regular 8-bit Access Burst as an 11-bit one. This is
exactly what we are doing in rx_rach_fn():

  - calling gsm0503_rach_ext_decode_ber() first,
  - if it failed, falling-back to gsm0503_rach_decode_ber().

With default BSIC=63, the following 8-bit RA values are being
misinterpreted as 11-bit Access Bursts:

  Successfully decoded 8-bit (0x00) RACH as 11-bit (0x0000): bsic=0x3f
  Successfully decoded 8-bit (0xbe) RACH as 11-bit (0x0388): bsic=0x3f
  Successfully decoded 8-bit (0xcf) RACH as 11-bit (0x0036): bsic=0x3f

According to 3GPP TS 05.02, section 5.2.7, there are two alternative
synch. (training) sequences for Access Bursts: TS1 & TS2. By default,
TS0 synch. sequence is used, unless explicitly stated otherwise
(see 3GPP TS 04.60).

According to 3GPP TS 04.60, section 11.2.5a, the EGPRS capability
can be indicated by the MS using one of the alternative training
sequences (i.e. TS1 or TS2) and the 11-bit RACH coding scheme.

In other words, knowing the synch. sequence of a received Access
Burst would allow to decide whether it's extended (11-bit)
or a regular (8-bit) one. As a result, we would avoid possible
collisions and save some CPU power.

Unfortunately, due to the limitations of the current TRXD protocol,
there is no easy way to expose such information from the transceiver.
A proper solution would be to extend the TRX protocol, but for now,
let's do the synch. sequence detection in rx_rach_fn(). As soon as
the TRX protocol is extended with info about the synch. sequence,
this code would serve for the backwards-compatibility.

This change makes the both TC_rach_content and TC_rach_count happy,
as well as the new TC_pcu_ext_rach_content() test case aimed to
verify extended (11-bit) Access Burst decoding.

Related (TTCN-3) I8fe156aeac9de3dc1e71a4950821d4942ba9a253
Change-Id: Ibb6d27c6589965c8b59a6d2598a7c43fd860f284
Related: OS#1854
2019-05-09 16:22:20 +00:00
Philipp Maier 12d362fe09 scheduler_trx: use stored fn for pdtch data indications
When the ph-data indications for the PDTCH are passed up to l1sap,
then a forumla is used to calculate the frame number of the beginning of
the block that is just passed up. This is not necessary since the start
frame number of the block is stored in *first_fn when the block arrives.
We should use this frame number instead. (For the measurement indication
it is already done this way).

Change-Id: I6c01987be78203acfa689c6decb2c806f8fff3d6
Related: OS#2977
2019-02-15 17:52:07 +01:00
Max de9e2092c9 osmo-bts-trx: add extended (11-bit) RACH support
Attempt to decode incoming RACH burst as 11-bit first
and fallback to 8-bit if unsuccessful.

Change-Id: Ia28741603636406744e5e22ffff1fb7a9689955a
Related: OS#1854
2019-02-14 15:48:08 +00:00
Harald Welte 9c9232c993 scheduler_trx: Fix erroneous multiply-by-four
Commit acefd0586e introduced the "toa256"
resolution change.

Before the change, _sched_compose_ph_data_ind() used quarter-bits as
units, so multiplying the old "toa" value by four made sense.

However, after said change, the value is in 1/256th of bits, and hence
we need to report the toa256 value without any multiply-by-four.

Change-Id: I9f980236ea1cd635cb229290e187747cc8c86d8d
Related: OS#2977
2019-02-05 17:46:25 +01:00
Harald Welte 5c93677be5 osmo-bts-trx/loops.c: Make code control flow more readable
Use the 'else' construct where applicable to avoid too many return paths
from functions

Change-Id: I819f0c80e90855e8b3252795c837f8e3053b6e87
Related: OS#1622, OS#1851
2018-12-23 10:38:23 +00:00
Harald Welte 5d9cb9f555 osmo-bts-trx/loops.c: Use lchan name based logging
The loops.c code dates back to ancient times when we printed the TRX
number and the raw channel number to identify a logical channel.  We
meanwhile have gsm_lchan_name() and should use it to log messages
related to this lchan in a common format.

This commit introduces the LOGPLCHAN() helper macro [similar to
osmo-bsc], and uses it from loops.c.

As a result, some functions don't need a chan_nr argument anymore,
while some need to add a new lchan argument.

Change-Id: I6976dd7444c26b1f52741bc367b0311ebbef1718
Related: OS#1622, OS#1851
2018-12-23 10:38:23 +00:00
Harald Welte a4f5622408 osmo-bts-trx/loops.[ch]: Make functions "void" if they always return 0
The concept of a return value only makes sense if there's actually ever
something non-constant to return, and if the caller actually processes
that return value.  If we always "return 0" and ignore it on the caller
side, functions should be of "void" type.

Change-Id: I3575a2cef75f3fd4c3f95eddb40719d28a055b54
Related: OS#1622, OS#1851
2018-12-23 10:38:23 +00:00
Harald Welte 3379250b51 osmo-bts-trx/loops.c: Add comments documenting TA + MS power control loop
The loops.c code is not very easily understood, so let's add some
comments to it.

As can be seen, there are functions of integer type which always return
0, and whose callers don't check for the return value.  This will be
adressed in subsequent patches.

Change-Id: Iafea07eb751ed85d29b214576bb0d31ea919cd72
Related: OS#1622, OS#1851
2018-12-23 10:38:23 +00:00
Pau Espin c606103d9f bts-trx: (n)ack PDCH DEACT only after TRX answered SETSLOT
Before this patch, PDCH DEACT was (n)acked to the BSC without taking
into account if TRX succeeded or failed to set the TS:

20181123044720655 DRLL rsl.c:2523 (bts=0,trx=0,ts=0,ss=0) Rx RLL DATA_REQ Abis -> LAPDm
20181123044720700 DRSL rsl.c:2805 (bts=0,trx=0,ts=6,pchan=TCH/F_PDCH as PDCH) ss=0 Rx RSL IPAC_PDCH_DEACT
20181123044720700 DRSL rsl.c:2205 (bts=0,trx=0,ts=6,pchan=TCH/F_PDCH as PDCH) Request to PDCH DEACT, but lchan is still active
20181123044720700 DRSL rsl.c:2131 (bts=0,trx=0,ts=6,ss=0) Tx PDCH DEACT NACK (cause = 0x0f)
20181123044720700 DPCU pcu_sock.c:124 Sending info
20181123044720700 DPCU pcu_sock.c:139 BTS is up
20181123044720700 DPCU pcu_sock.c:232 trx=0 ts=7: available (tsc=7 arfcn=868)
20181123044720703 DPCU pcu_sock.c:608 Deactivate request received: TRX=0 TX=6
20181123044720703 DL1C l1sap.c:1519 deactivating channel chan_nr=TCH/F on TS6 trx=0
20181123044720703 DTRX trx_if.c:242 Enqueuing TRX control command 'CMD NOHANDOVER 6 0'
20181123044720703 DL1C l1sap.c:648 deactivate confirm chan_nr=TCH/F on TS6 trx=0
20181123044720703 DRSL rsl.c:714 (bts=0,trx=0,ts=6,ss=0) not sending REL ACK
20181123044720703 DRSL rsl.c:2264 (bts=0,trx=0,ts=6,ss=0) PDCH DEACT operation: channel disconnected, will reconnect as TCH
20181123044720703 DL1C scheduler.c:593 Configuring multiframe with TCH/F+SACCH trx=0 ts=6
20181123044720703 DTRX trx_if.c:242 Enqueuing TRX control command 'CMD SETSLOT 6 1'
20181123044720703 DL1C l1_if.c:780 (bts=0,trx=0,ts=6) bts_model_ts_connect(as_pchan=TCH/F) success, calling cb_ts_connected()
20181123044720703 DRSL rsl.c:2339 (bts=0,trx=0,ts=6,ss=0) PDCH DEACT operation: timeslot connected as TCH/F
20181123044720703 DRSL rsl.c:2440 (bts=0,trx=0,ts=6,ss=0) TCH/F_PDCH switched to TCH/F mode (ts->flags == 0)
20181123044720703 DRSL rsl.c:2103 (bts=0,trx=0,ts=6,ss=0) Tx PDCH DEACT ACK
20181123044720704 DTRX trx_if.c:492 Response message: 'RSP NOHANDOVER 0 6'
20181123044720705 DTRX trx_if.c:492 Response message: 'RSP SETSLOT 0 6 1'

Change-Id: I888de761b65c3ea8bfe623fcf009f3b2b57c926c
2018-12-04 16:57:52 +00:00
Pau Espin e3cb8715f5 bts_model: Allow TS connect to be processed asynchronously
This commit doesn't change internal logic of any model, only the API to
be able to return result of connect TS asyncrhonously since some models
(like osmo-bts-trx) require some time to process the result. This way
PDCH ACT/DEACT (N)ACK can be sent once the result of this long process
is known. For instance, nowadays in osmo-bts-trx we PDCH (DE)ACT ACK
before getting the result from SETSLOT on the TRX iface.

With this new API, bts_model_ts_connect doesn't return any value
synchronously. Instead, it is expected to always end up calling
cb_ts_connected with the return code from the TS activation process. 0
is considered a successs, while any other value is considered an error.

Change-Id: Ie073a4397dd2f1a691968d12b15b8b42f1e1b0cf
2018-11-26 14:08:14 +01:00
Pau Espin 47c8f37c9f cosmetic: fix whitespace
Change-Id: Iaa4552844db33fe69da5ed7028dbfa0100c33900
2018-11-26 14:08:14 +01:00
Pau Espin 3c12325d28 bts-trx: early return on POWERON success
Later on it's expected to add more rsp parsing, so let's return here and
not depend on generic return further down.

Change-Id: I8ddee46374ab329c47dc68e720e236f13d393f66
2018-11-23 17:44:13 +01:00
Vadim Yanitskiy 70eb683622 Fix deprecated gsm_arfcn2band(), use gsm_arfcn2band_rc()
Change-Id: I45aae70f4bc3f4f85d267dafb757debdef1bb7d7
2018-11-22 15:30:46 +07:00
Pau Espin 36a61df7a6 bts-trx: Allow re-try without exit if POWERON fails in osmo-trx
If POWERON fails, announce to BSC that the TRX is not available, and
announce it as available as soon as POWERON success is received.

Related: OS#3692
Change-Id: Iaa8f497381038fd7f9f779a8211ebc6453837c65
2018-11-20 10:41:43 +01:00
Pau Espin 9d17840f83 bts-trx: setup timer once at creation time
The setup is only needed once, so no need to set it every time we want
to schedule it.
Furthermore, it will ease new code introduced in follow-up patches,
which will schedule this timer under some circumstances without need to
send a message at the same time (because re-try of a cmd after a delay
is wanted).

This commit adds an alloc function and an init function to keep
different parts of the code decoupled and avoid exposing more
implementation details between them (like exposing the trx_if timer).

Change-Id: I3b6461d0130d25284e673c5efce0b3832c48bbb5
2018-11-20 10:37:58 +01:00
Pau Espin 0716a20f98 bts-trx: trx_if: Use struct to store CTRL msg parsed responses
Change-Id: Icb84bce0621042afa4301678ba1cc58d8e3662bb
2018-11-19 10:43:56 +00:00
Max 116ac855cc osmo-bts-trx: print TRX socket addresses in 'show transceiver'
Change-Id: I081305d730cbdb14b5ce1dbfee18673328225b66
2018-11-19 05:44:36 +00:00
Pau Espin eebb6a4216 bts: Allocate TRX for BTS dynamically, deprecate -t
No need to pass -t num_trx anymore to specify number of TRX to use. It
is calculated based on dynamic allocation from VTY config.
Using parameter -t is flagged as deprecated and is transformed into a
NOOP por backward compatibility.

As a result, TRX now are allocated after the BTS is allocated and
initial config (pre-VTY) is applied.
A new function bts_trx_init() is added, to set default config on each
TRX during allocation and before setting VTY config on it.
A new per BTS model function bts_model_trx_init() is added, to allow
per model specific default configuration of each TRX.

Change-Id: Iab1a754ab12a626759f9f90aa66f87bdce65ac9c
2018-11-18 20:29:40 +00:00
Harald Welte 44bfa4c7fd scheduler_trx.c: Switch to osmo_timerfd() of libosmocore >= 0.12.0
Change-Id: I721d493659fde57eca1543b2e63171df1be1279d
Fixes: Coverity CID#178646
2018-10-21 13:05:53 +02:00
Harald Welte b222f6666d CBCH: Fix CBCH implementation for osmo-bts-trx
Unfortunately the code in Icc15603079a1709ec094f400a9bcf0008211890f
was incomplete as it missed a few spots where the CBCH-enabled channel
types weren't yet covered.

Using this patch I can both still perform RACH / Location Update as
well as actually receive SMSCB messages on an attached phone (Galaxy S5).

Change-Id: I311b141668549ef37054cbe74be66bf17ac1d7e6
Closes: OS#1617
Closes: OS#3559
2018-09-17 22:47:45 +02:00
Vadim Yanitskiy 0c1ca01084 osmo-bts-trx/l1_if.c: cosmetic: fix typo in debug msg
There is a big difference between both L1 and L2 frames. In the
first case, a TDMA frame is assumed, while a L2 frame is the
result of decoding a few bursts (e.g. 4 for xCCH) arrived
on a few TDMA frames.

Anyway, the purpose of l1if_process_meas_res() is to handle
measurements, not frames.

Change-Id: Ic4362c2869e658c2f42664b4009a30e777f8048c
2018-09-16 12:27:37 +07:00
Harald Welte d9a1cd994c CBCH: Implement CBCH support for osmo-bts-{trx,virtual}
This patch adds scheduler support for the channel combinations that
substitute SDCCH index 2 for a CBCH in either a SDCCH/8 or SDCCH/4.

Change-Id: Icc15603079a1709ec094f400a9bcf0008211890f
Closes: OS#1617
2018-09-09 15:40:58 +00:00
Neels Hofmeyr 1dcd63d36a fix ip.access dyn TS for osmo-bts-trx
For enabling PDCH on a dynamic timeslot, PDTCH and PTCCH SAPIs shall be
enabled. While osmo-bts-sysmo uses the lchan->type to determine which SAPIs to
enable (see lchan_activate() in osmo-bts-sysmo/oml.c:
sapis_for_lchan[lchan->type]), the osmo-bts-trx code instead relies on the
chan_nr indicating RSL_CHAN_OSMO_PDCH = 0xc0 (see trx_sched_set_lchan() in
common/scheduler.c and the PDTCH,PTCCH entries in trx_chan_desc[]).

The 0xc0 cbits are a non-standard invention specifically used for only Osmocom
style dyn TS, so the chan_nr for IPA style dyn TS will and should never include
this cbits pattern. Hence gsm_lchan2chan_nr() correctly always returns the
TCH/F equivalent chan_nr for IPA dyn TS.

Because trx_chan_desc[] relies on the 0xc0 in the chan_nr to activate the PDTCH
and PTCCH SAPIs, internally patch the 0xc0 cbits over the chan_nr in
osmo-bts-trx/l1_if.c for channel de-/activation, iff lchan->type == PDTCH.

This is technically a convoluted mix-up of the cbits usage. Nevertheless, it is
the simplest way to make IPA dyn TS behave the same as Osmocom dyn TS in
scheduler.c.

Apparently, IPA style dyn TS have never worked for osmo-bts-trx before?

Related: OS#3493
Change-Id: I0eed8a135f2ab7e7c0d15ad5c76430b7fe54df3d
2018-08-28 19:38:55 +00:00
Stefan Sperling 829263afc4 fix timespec subtraction in compute_elapsed_us()
The previous implementation unconditionally subtracted nanosecond
values from different time measurements, causing overflow if the
current measurement was taken in less of a fraction of a second
than the past measurement. Use timespecsub() instead, which
accounts for nanoseconds correctly.
This is a similar bug as fixed in osmo-pcu for issue OS#3225

While here, switch variables which are calculated based on
struct timespec to 64 bit types. While probably not strictly necessary
in practice, this makes the types used in calculations more compatible.

Change-Id: Idfd9c807e35cd7fb5c80625b9746121f81c24599
Related: OS#3467
Related: OS#3225
2018-08-17 14:25:30 +02:00
Vadim Yanitskiy 5d17b97a5b Clarify frame loss counter for l1sched_chan_state
Each logical channel (e.g. SACCH, SDCCH, etc.) has a counter of
lost L2 frames. Let's use a bit better name for it, and correct
its description in the 'l1sched_chan_state' struct definition.

Change-Id: I92ef95f6b3f647170cfd434a970701406b0a7c82
2018-08-01 02:35:07 +07:00
Pau Espin ed9a13e670 trx: scheduler: Keep RTP clock up to date while in DTXu pause
Upper layer requires us to trigger all events coming from lower layers
in order to keep the RTP clock in sync. In this case, this is done by
sending an empty payload to indicate there's no data to send.

Change-Id: I0bdfb529f35253ca7e531bb9984a3839c3bfe7e8
2018-07-20 16:42:24 +02:00
Pau Espin 500b7945f0 Remove unneeded direct libortp dependency
All code in osmo-bts goes through APIs in libosmotrau (osmo_ortp.h),
hence direct dependency is not needed. Fixes OBS warnings:

dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/osmo-bts-trx/usr/bin/osmo-bts-trx was not linked against libortp.so.9 (it uses none of the library's symbols)
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/osmo-bts-virtual/usr/bin/osmo-bts-omldummy debian/osmo-bts-virtual/usr/bin/osmo-bts-virtual were not linked against libortp.so.9 (they use none of the library's symbols)

Change-Id: I96a9b5f0678331dcf66c007928866a124d8700de
2018-07-02 16:36:14 +02:00
Harald Welte 19080d531f scheduler_trx: Add reminders to use libosmocore functions
Let' wait until the just-merged osmo_timerfd_* functions
of Change-Id Ibeffba7c997252c003723bcd5d14122c4ded2fe7 have made it
into the next tagged release, and then replace the implementation
here.

Change-Id: Ic0f0a7437b6acb535177e5ad6ac7a6d336654c66
2018-05-24 06:08:44 +00:00
Harald Welte e152fd2614 osmo-bts-trx: Enable A5/3 cipher support
This actually should have been working since 2015, when the following
patch was merged to libosmcore:

commit f8699ca51eeb4f3d34336501abcaf071b4a95a47
Author: Max <max.suraev@fairwaves.co>
Date:   Wed Mar 25 17:20:31 2015 +0100

    gsm: Add A5/3-4 cipher support

however, it seems nobody so far bothered to actually enable A5/3 for
osmo-bts-trx!

Change-Id: I8192d6d07cdb87783bce997456ead673c600f7c0
Closes: OS#3253
2018-05-09 20:34:52 +00:00
Pau Espin c45a04bf58 scheduler_trx: Fix signed integer overflow in clock calculations
Should fix following observed run time errors:
osmo-bts-trx/scheduler_trx.c:1627:65: runtime error: signed integer overflow: -1081823 * 4615 cannot be represented in type 'int'
osmo-bts-trx/scheduler_trx.c:1627:21: runtime error: signed integer overflow: 1852394502 - -697645849 cannot be represented in type 'int'

Related: OS#3213
Change-Id: I36e0d2d0d0c6e35e963f611135453c4a4c00bc99
2018-04-25 15:00:50 +02:00
Philipp Maier 69d0d50677 osmo-bts-trx: perform error concealment for FR frames
When a bad voice frame is received, it is replaced by
a silence frame. This may cause unpleasant audio effects.

This change implements a functionality to craft a replacement
frame from the last known good frame using ECU implementation
from libosmocodec. At the moment, only FR is supported.

Depends: libosmocore I06a21f60db01bfe1c2b838f93866fad1d53fdcd1
Change-Id: Iae9e69a9578ae305bca42f834694af96a29084e6
2018-04-17 16:34:53 +02:00
Harald Welte d8cd756da4 Get rid of 'struct gsm_bts_role_bts'
gsm_bts_role_bts was introduced at a time when we still shared
gsm_data_shared.[ch] between BSC and BTS, and where we then subsequently
needed a BTS-private structure.  Since that sharing was abandoned quite
some time ago, we can merge gsm_bts_role_bts into gsm_bts and do away
with the bts/btsb dualism in a lot of the code.

Change-Id: I4fdd601ea873d9697f89a748cc77bcf7c978fa3e
2018-03-17 13:40:03 +01:00
Vadim Yanitskiy 8a28868b29 scheduler_trx.c: remove ToA (Time of Arrival) hack
This was useful for software simulation of burst delay, expressed
by ToA (Time of Arrival). Since we have FakeTRX toolkit, ToA value
may be simulated in a more flexible way, so let's remove this code.

Change-Id: Ied0fcfcf58b93efdc6de9666fbbf8fea104e2543
2018-03-05 05:54:32 +07:00
Harald Welte acefd0586e L1SAP: Increase resolution of reported burst timing
Before this patch we had:
* osmo-bts-trx internally using 1/256th bit/symbol period
* osmo-bts-sysmo internally using 1/4 bit/smbol period
* PCU interface using 1/4
* L1SAP interface using 1/4
* measurement processing code on top of L1SAP using 1/256

So for sysmo/lc15/octphy we are not loosing resolution, but for
osmo-bts-trx we're arbitrarily reducing the resolution via L1SAP
only then to compute with higher resolution again.

Let's change L1SAP to use 1/256 bits and hence not loose any resolution.
This requires a corresponding change in libosmocore for l1sap.h, which
is found in Change-Id Ibb58113c2819fe2d6d23ecbcfb8b3fce4055025d

Change-Id: If9b0f617845ba6c4aa47969f521734388197c9a7
2018-02-27 20:00:16 +01:00
Harald Welte d5bbd8ccf7 trx/scheduler: Use integer math for TOA (Timing of Arrival)
There's no need to express TOA as a float:
* We receive it as signed 16bit integer in units 1/256 symbol periods
* We pass it to L1SAP as signed integer in 1/4 symbol periods

So turn it into an int16_t with 1/256 symbol period accuracy throughout
the code to avoid both float arithmetic as well as loosing any precision.

Change-Id: Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec
2018-02-27 19:58:20 +01:00
Harald Welte c2b4c668f3 Move rach_busy counting above L1SAP
In the past, rach_busy counting was performed below L1SAP, while
reporting was handled above.  This lead to subtle differences between
the BTS models, such as osmo-bts-trx missing to increment rach_busy.

Let's move the rach_busy counting above L1SAP to share more code.

This means we need libosmocore Change-Id
I9439810c3a3ad89ea0302753617b850749af887c for the additional required
parameters in ph_rach_ind_param, as well as libosmocore Change-id
I2b1926a37bde860dcfeb0d613eb55a71271928c5 for osmo-bts-trx to determine
the RACH bit error rate.

Change-Id: I3b989580cb38082e3fd8fc50a11fedda13991092
Closes: OS#3003
2018-02-27 17:27:35 +01:00
Harald Welte 6381900677 split scheduler_mframe.c from scheduler.c
There are use cases for the multiframe scheduler tables outside the
context of the entire scheduler. Let's prepare for that.

Related: OS#2978
Change-Id: I6a501e66c47809ae3cdc55bef2cb6390ee0096b1
2018-02-26 15:01:08 +01:00
Harald Welte 815ff00d23 osmo-bts-trx: Add missing frame number to l1if_process_meas_res()
Change-Id: I7f1322b025ce733f78ae2b958c7a2bb38b6aa6f5
2018-02-23 19:58:29 +01:00
Philipp Maier a4bca11555 bts: use feature list instead of speech codec table
osmo-bts has a table of pchan/channel mode combinations for every
bts. This table models the codec capabilitys of the BTS hardware.
However, having the speech codec apabilities modeled inside the
BTS feature list would be much more comfortable and since the
feature list is communicated back to the BSC we would get the
codec capabilities inside the BSC domain as well.

- remove the pchan/channel mode tables
- set speech codec variants for each BTS type
- fix bts_supports_cm so that it queries the feature list

Change-Id: I977dc729ba856631245aedf76afd48eac92166f7
2018-02-22 07:58:26 +00:00
Philipp Maier bfe9af4ae1 octphy: ensure all BTS models set features
Most of the BTS models do not or do register not all of thier
features to the the feature list.

- Update/extend the feature lists for all BTS-Models

Change-Id: I26765a64153368016921c2ac115b1c4aec9bc5e4
2018-02-22 07:58:26 +00:00
Harald Welte df72b1fdbd trx: make l1if_fill_meas_res() static
it's not used anywhere outside of l1_if.c, so make it a static function

Change-Id: If988a7679f3a9253fab1a4d177a276d8ecaf794f
2018-02-19 14:34:01 +01:00
Philipp Maier bf1fea0928 rsl: do not allow MODE MODIFY request with unsupp. codec/rate
When the BSC sends a MODE MODIFY request with an unsupported
codec, the BTS must respond with a negative acknowledge.
Currently the codec parameter is not checked at all, which may
lead into malfunction or crash of the BTS.

- Introduce a mechanism to check the codec/rate against a
  table that is set up in the phy specific code.

- Add tables with supported codec/rate combinations for
  octphy, sysmobts, and trx.

Change-Id: Id9b222b7ab19ece90591718bc562b3a8c5e02023
Related: SYS#3212
2018-02-19 08:38:21 +00:00
Max c2e3ff58bc osmo-bts-trx: init nbits to know value
It seems like some of the functions invoked by _sched_dl_burst()
do not sent nbits properly. This leads to a number of errors on
startup:

trx_if.c:593 Tx burst length 65535 invalid

It happens in conjunction with:

Transceiver.cpp:382:pushRadioVector: dumping STALE burst in TRX->USRP interface

Let's fix this by initializing nbits to 0 to make sure those bursts
are properly ignored.

Change-Id: Iaf85826861163c185925de528c8347ab22779e30
2018-02-08 16:42:48 +01:00
Pau Espin 61da9b3d2c bts-trx: scheduler_trx.c: Fix missing header
It is required for bts_shutdown used in trx_fn_timer_cb, and compiler
warns about implicit declaration.

Change-Id: I274662cd657ce8c36ed1d262d138590808bfafea
2018-02-05 12:36:41 +01:00
Pau Espin 131db780cc Remove unused variables
Change-Id: I3fec7e4b337f3ea4d8cd79f4e7261babc34911cb
2018-02-05 12:36:28 +01:00
Pau Espin e95ad79d6c bts-trx: Detect duplicated responses for retransmitted commands
It was detected that under some conditions, osmo-trx (with limesdr)
may take a long time to answer to CMDs, which means trx_ctrl_timer will
trigger re-transmitting the last sent but yet unacked CMD. Due to the
high latency in osmo-trx, the original AND the rentrasnmited CMD are
handled after a while and RSP messages are sent for both. When
osmo-bts-trx receives the first RSP, it was marking the CMD as acked and
carried on with next one. Then, when the RSP from the retransmited CMD
arrives, it already lost state and doesn't know where does that come
from. As a result, osmo-bts-trx shutdowns.

The issue can be seen in the following truncated log from osmo-bts-trx
with TRX category enabled:
20180117135228175 Enqueuing TRX control command 'CMD RXTUNE 1782000'
20180117135228175 Enqueuing TRX control command 'CMD TXTUNE 1877000'
20180117135228175 Enqueuing TRX control command 'CMD SETTSC 7'
20180117135228175 Enqueuing TRX control command 'CMD POWERON'
20180117135228175 Enqueuing TRX control command 'CMD SETRXGAIN 1'
20180117135228175 Enqueuing TRX control command 'CMD SETPOWER 20'
20180117135228175 Enqueuing TRX control command 'CMD SETSLOT 0 5'
...
20180117135249829 Response message: 'RSP POWEROFF 0'
20180117135249855 Response message: 'RSP RXTUNE 0 1782000'
20180117135249876 Response message: 'RSP TXTUNE 0 1877000'
20180117135249876 Response message: 'RSP SETTSC 0 7'
20180117135250648 Response message: 'RSP POWERON 0'
20180117135251150 Response message: 'RSP SETRXGAIN 0 0'
20180117135253151 No response from transceiver for phy0.0 (CMD SETPOWER 20)
20180117135253777 Response message: 'RSP SETPOWER 0 20'
20180117135254535 Clock indication: fn=2018878
20180117135255777 No response from transceiver for phy0.0 (CMD SETSLOT 0 5)
...
20180117135256858 Response message: 'RSP SETPOWER 0 20'
20180117135256858 Discarding duplicated RSP from old CMD 'RSP SETPOWER 0 20'
20180117135256858 Response message: 'RSP SETSLOT 0 0 5'
20180117135256858 Response message: 'RSP SETSLOT 0 0 5'
20180117135256858 Discarding duplicated RSP from old CMD 'RSP SETSLOT 0 0 5'

Change-Id: I3633cba212edde878f83ed36aef922aaca6f503a
2018-01-19 15:41:19 +01:00
Pau Espin 8c1d157643 bts-trx: trx_if.c: Improve parsing of received RSP messages from TRX
First the cached CMD sent (struct trx_ctrl_msg) is reworked to have the
cmdname and the params in different buffers for easier comparison with
RSP later.

For the receive path (trx_ctrl_read_cb), new function helpers are added
to parse the buffer into cmdname+params+code (parse_rsp) and to compare
if a given RSP matches the current CMD we sent (cmd_matches_rsp).

The reasoning behind this patch is that a way to check for parameters
when receiving a RSP will be needed in future work, as before this patch
checking of parameters is ignored. This commit is a preparation for commit
to check for duplicated responses.

Change-Id: I2474cbc3e4457cf04f78e1c168768295e1132034
2018-01-19 15:41:19 +01:00
Pau Espin 1f80e9815f bts-trx: trx_if.c: trx_ctrl_read_cb: Move error handling to end of func
The move includes a small logic change: If there's a mismatch between
the rsp and the cmd, now we bts_shutdown instead of blindly skipping
expected RSP and continuing with sending the next CMD in the queue. The
change is specially not a problem since next patches are improving the
logic furthermore to account for duplicates, different parameters, etc.

Change-Id: I7018ded23fe51f364f248ade111aaa80ef46187e
2018-01-19 15:41:19 +01:00
Pau Espin 9a57c7bed4 bts-trx: trx_if.c: Log timedout+retransmitted CMD
Change-Id: Ib573c86a1640640c2a61e80fe1f1412b30342b1a
2018-01-19 15:41:19 +01:00