Commit Graph

2071 Commits

Author SHA1 Message Date
Vadim Yanitskiy 49ad9f9375 vty: clarify documentation of '[no] gsmtap-sapi' command
Change-Id: I2030992da604f27fc8cd6f9695a8095fda801f82
2020-09-04 12:26:01 +07:00
Vadim Yanitskiy eecb97146e osmo-bts-omldummy: enable BTS_FEAT_{CBCH,HOPPING} support
Otherwise osmo-bts-omldummy would reject OML Set Channel Attributes
containing the hopping parameters.  This change is needed for the
new BSC_Tests.TC_fh_params_* test cases.

Change-Id: I38692252baa7a9fc23078121db0a17557950e4d4
Related: SYS#4868, OS#4545
2020-09-02 16:36:01 +07:00
Pau Espin 063eaa80a4 pcu_sock: Fix typo in log message
Change-Id: I63f0ba277318e254cfd9ad571899f3a45529ff16
2020-08-26 13:49:30 +02:00
Pau Espin 67e5a72a51 common: tx_power: Fix bug in power ramp up below max-initial value
See previous commit adding the unit test about the error description and
expected behavior.

The wrong behavior appeared due to step_size_mdB being unsigned and the
whole addition at the left side of the comparison being turned too as
unsigned, hence a small negative value turning into a big positive
value, and tpp->p_total_cur_mdBm not being updated to speed up the power
ramping.

Change-Id: I36a34362ebc90226fd8e1e190f898c3718fd923a
2020-08-18 17:22:38 +02: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
Pau Espin c131ce45ba common: Support setting rt prio through new libosmovty sched VTY cmds
We gain other features from libosmovty for free, like configuring
cpu-affinity of the only thread in the process.

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

Related: SYS#4986
Change-Id: Ice46e406b84fa11afcc7ba31e521e7677df73cf3
2020-08-10 20:10:50 +00:00
Vadim Yanitskiy 30458c83e5 rsl: constify the 'lchan' argument of rsl_tx_conn_fail()
Change-Id: Icec43d7c1f3b99292fa87462ad65b2c19fdd3b5f
2020-08-07 18:31:10 +00:00
Vadim Yanitskiy 4fa40f5913 l1sap: radio_link_timeout(): bad_frame is a boolean
Change-Id: Id173f69705948aafe861ec36450b147deda95246
2020-08-08 01:29:16 +07:00
Vadim Yanitskiy 089e4baef3 l1sap: radio_link_timeout(): use LOGPLCHAN() macro
Change-Id: Icc642599d85a751a750b382674dea5614b6f9ee4
2020-08-08 01:29:16 +07:00
Vadim Yanitskiy dc27771205 l1sap: radio_link_timeout(): clarify logging messages
Change-Id: Iafb190454c65cebe3de3c212fa8b10a86ec7eb67
2020-08-07 18:26:42 +00: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 dc232c137b pcu_sock: use LOGPTRX() in info_ind_fill_trx()
Change-Id: I91410b32199780e41e0111b480e7611cdae7e022
2020-08-06 16:44:28 +00:00
Vadim Yanitskiy bebf458385 pcu_sock: separate trx / ts filling from pcu_tx_info_ind()
This would allow to avoid further nasting in 'for' loops.

Change-Id: Idb102c77751ccf77fd246f538e62fd7acf6ee88b
2020-08-06 16:44:28 +00:00
Vadim Yanitskiy dcfec2d993 pcu_sock: warn about maximum transceiver number constraints
Change-Id: I600860b12758a73e1bba6d9d508cf67c3d88cf34
2020-08-06 16:44:28 +00:00
Vadim Yanitskiy 2c331ee908 pcu_sock: use a 'switch' statement in ts_should_be_pdch()
Change-Id: I628c2c5198c52fb82309dfe4a31a59aeebc00f09
2020-08-06 16:44:28 +00:00
Vadim Yanitskiy 4d61c67392 oml: fix ARFCN range check in oml_rx_set_bts_attr()
Change-Id: I52c15de3c59cd654207599ae410a4c1fed48ee58
2020-08-04 14:28:56 +00:00
Vadim Yanitskiy 48ff5313cd oml: fix ARFCN range check in oml_rx_set_radio_attr()
Change-Id: I11c8203dfe26175632974e5c6859eeaea962e878
2020-08-04 14:28:56 +00: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 fc3909a0b1 pcu_sock: constify the argument of ts_should_be_pdch()
Change-Id: I636bb05d67a43e0385449d0234577c1390bed350
2020-08-03 02:08:14 +07:00
Vadim Yanitskiy 60e2919ff4 common: constify the argument of trx_ms_pwr_ctrl_is_osmo()
Change-Id: Ic7be19ed1560eae0a56ed30520ee9af1e949d71d
2020-08-03 02:08:14 +07: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 57fc9fa782 tx_power: Take into account max-initial when ramping up bigger power lvl intervals
Until now, power-ramp max-initial was only taken into account in order
to skip ramping if the desired target level was below it, in order to
forbid growin too quickly or applying directly to much power given power
amplifier requirements.
However, in the event that a higher tx power level is desired,
max-initial was not taking into account and ramping simply started from
current tx power level, which could be a lot lower than max-initial.
Allow shortcutting the ramping in that case so that max-initial is
applied directly, and ramping continues from there, in order to have a
more expected behavior (max-initial applied the same).

Since max-initial can since a few commits before handle a negative
value, this means One can for instance set max-initial to -10 and still
keep the old behavior of ramping step by step from -10 (rf-locked in
osmo-bts-trx) to 0 or 7 or whatever is the nominal power
(max_power_red).

Change-Id: I4e5742ecdbf66d77ff9445999f6fff43bbf4856a
2020-07-27 17:34:34 +02: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 f30440553c vty: Allow setting power-ramp max-initial to negative values
This allows for instance ramping up from -10 dBm -> -4 dBm if NOMTXPOWER
of SDR is really low (below 0dBm) or because the max_power_red is >=
NOMTXPOWER.

Related: SYS#4920
Change-Id: I0f27fb7b86b58c5a80f5342b66ff4f5d1b775498
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 912ff0d759 common: Avoid call to bts_model_chg_adm_state() if there's no ADM state change
Let's handle it in common code to simplify and avoid duplication in
model specific code.

Change-Id: Icea3ea1108d360193cac478f366be97ff38246d4
2020-07-27 12:19:22 +02:00
Pau Espin 4134bdf009 bts_shutdown_fsm: Fix switching too quickly to state WAIT_TRX_CLOSED
Ramping down was set up with a target of -10 dBm, but then the code only
waited for all TRXs to be at least 0dBm, meaning that if operating more
than 1 TRX, the FSM could transit to state ST_WAIT_TRX_CLOSED when one
TRX reached -10 and other were already equal or below 0 (but not yet
-10). As a result, later on, when other TRXs reached -10 dBm they would
trigger EV_TRX_RAMP_COMPL which was not expected (no use) in
ST_WAIT_TRX_CLOSED.

Related: SYS#4864
Change-Id: If7af0b138efe78ec591c199a19fc22b304416a13
2020-07-24 18:23:16 +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 4479c94fd1 rsl: Fix wrong param passed to gsm_pchan_name() in log line
Change-Id: I42b7a79b85e8750a12166dbfc66ad06f7cb713a6
2020-07-23 12:52:54 +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 22a949f38e common: Avoid changing OPSTATE to Enabled upon RSL up
the RSL link has nothing to do regarding the state of the Radio Carrier,
as in it being up is not enough to have a working (enabled) Radio
Carrier.

Change-Id: Iefb5c4e1097233b5c31e4d621c544d51516af678
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 122ff83dd0 Move struct gsm_bts_trx: gsm_data.* & bts.* => bts_trx.*
Move all struct gsm_bts_trx references from bulky gsm_data to its own
file containing all related definitions and implementations. Also move a
few functions clearly related to that object which were placed in bts.*

Change-Id: Iebaf5b221c48b571f45408af867ce6f9c0cd9f4a
2020-07-14 09:44:06 +00:00
Alexander Couzens d5107c0583 measurement: replace u_int64_t with uint64_t
Be consistent and use everywhere uint64_t.

Change-Id: Id6b5df7f5045901109fe1007a5ad54e2f95b95f8
2020-07-14 08:37:33 +00:00
Pau Espin 9b2641ff3d bts-virt: Don't rely on gsmtap_makemsg() returning NULL for GSMTAP_CHANNEL_UNKNOWN
commit d211c490ca avoided sending
GSMTAP packets on the virtual Um interface with type
GSMTAP_CHANNEL_UNKNOWN by relying on gsmtap_makemsg returning NULL.
But that's not the corect approach since it's totally fine to be sending
GSMTAP_CHANNEL_UNKNOWN on some GSMTAP cases (for instance when the
program fails to infer the type when decoding a message), since then
this way one can study pcap files and find the offending encoded
messages which failed to be decoded.

This patch goes togehter with revert patch introduced in libosmocore as
explained in the commit referred above.

Change-Id: I233afd930d3e43f7b120d40192c7c192102e38d9
2020-07-09 11:44:12 +00:00
Vadim Yanitskiy 3daccb151f l1sap: do not print redundant info in l1sap_chan_act()
LOGPLCHAN() prepends the BTS/TRX/TS numbers itself.

Change-Id: I8a1dd7da7098fe8c8a015459608d9134821fb322
2020-07-09 10:43:33 +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 23fd316dea Move nm_state and Mo related code gsm_data.* => oml.*
Change-Id: I57ea9c4ddbe5443b9b6afe3f8e6b38170d0e5a0e
2020-07-05 18:17:46 +02:00
Pau Espin 8ca8a26ce9 gsm_data.h: Use enum type for NM state fields
Change-Id: I21fa1688a0c8a3788a5ecedd5912f596a69a1beb
2020-07-05 18:16:08 +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 a470d016b1 pcu_sock: Avoid presenting TS from disabled TRX as available to PCU
Change-Id: I4b24faf3a8fe5846b9394fea8faf9d37cc0ac9ff
2020-07-05 18:16:01 +02:00
Pau Espin 0a6bdb024f bts_shutdown: Speed up shutdown if no TRX is operational
This change avoids waiting for full ramp down if TRXs are already non
operational.

Change-Id: Ie1c7c3a969e7968075b89edcd1ab2227b178a869
2020-07-05 18:14:16 +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
Vadim Yanitskiy 842e4fab44 A-bis/OML: handle hopping params in Set Channel Attributes
Change-Id: Ieac26c7aca118c16889cdde2565a514681dc137b
Related: OS#4546
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 2931fc337f vty: fix missing separator in help for power ramp commands
Change-Id: Id83fa562ba8496be8915573d2222dd64c7ca5eb9
2020-06-26 01:46:43 +07: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 7a7168f0a8 bts-omldummy: Speed up shutdown (instantaneous ramp)
Change-Id: I4d4e7a5bfb899787605b3b25dcdc9e9470c438d9
2020-06-25 14:19:12 +02:00
Pau Espin 3612920ce7 bts-omldummy: Implement bts_model_trx_close
Change-Id: I13221e5dffe3290fc791f8866f25141fcc0821ff
2020-06-25 14:19:08 +02:00
Pau Espin a08685a576 Fix shutdown in osmo-bts-{omldummy,virtual}
Change-Id: Idadb62ec25181b140d9061dc7470da00d47d8336
2020-06-25 14:12:34 +02: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 ab7f409bff bts-virtual: Implement bts_model_trx_close
Change-Id: Id37562652b1ebc27d808d83342e4961b936dbcad
2020-06-23 14:55:55 +02:00
Pau Espin a6386ea64d bts_shutdown: Wait until all TRX are closed
Setting the phy link of a trx to SHUTDOWN sets operative state to
DISABLED, so we use operative state as a condition to know whether all
TRX are already powered off properly and we can exit.

Change-Id: I2bcd211d7edcc8486461a555d6c470a94b166ed7
2020-06-23 14:55:51 +02: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 ceb80fc6b6 bts_shutdown: First deact RF on all TRX, finally close them
It makes more sense to first deactive RF on all TRX and finally close
them totally. This way we keep consistency between all TRXs and it's
easier for lower layers which may need to close them all at once. Also
in the event that we want to turn bts_model_trx_deact_rf to return
asynchronously.

Change-Id: Ib62358384e37a5cef692926439462042fab0138c
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 69299114f8 Implement tx power ramp down during BTS shutdown
Upon BTS shutdown (for instance because the Abis link against BSC was
lost), stop the operation in an ordered manner (cell soft lock). This
means slowly decrease tx power so that MS have time to handover to other
neighbour cells.

Related: SYS#4920
Change-Id: I70e34dda8974ebd94aea33bd9fb1d99f9063cc55
2020-06-23 14:53:33 +02:00
Pau Espin fee04adc75 Introduce bts_shutdown FSM
Using an FSM here will allow for more complex ordered shutdown
procedures, like power ramp down, waiting for TRX deact asyncrhonously,
etc.

Current commit leaves everything in place already prepared to implement
ramp down, which will be implemented in next commit in the series.

Related: SYS#4920
Change-Id: I8f48f17e61c3b9b86342eaf5b8a2b1ac9758bde5
2020-06-23 12:49:11 +00:00
Pau Espin 580a27e97c abis.c: Use LOGPIL when logging signalling link down
Change-Id: Icedd533046853f67da5da84aae28b895a8cdb0bf
2020-06-23 13:18:38 +02:00
Pau Espin 7afdccdff2 bts.c: Fix typo in log line and improve it
Change-Id: I44d079893d01946da703c4338a686795ced3cb00
2020-06-22 20:30:53 +00:00
Pau Espin 4e01d8e709 tx_power: Log bypass param in power_ramp_start
Change-Id: I72559a50570cf447b5930f8995b1f345baeb1ee5
2020-06-19 20:36:31 +00: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
Pau Espin d819a57c60 Introduce LOGPTRX macro and use it in tx_power.c
Rename OCTPHY specific LOPGTRX macro to avoid redefine conflicts.

Change-Id: I02878611501aca51039e2ac7e35784ccb93b1db6
2020-06-18 19:11:55 +02:00
Pau Espin cec19e6324 Fix missing bts_model implementations in stubs.c and bts_model.c
These will be required by compiler/linker after next changes.

Change-Id: Icd20d64cf973f4cf4425b46d4102747db53d8990
2020-06-18 19:11:55 +02:00
Pau Espin 492c7c50aa cosmetic: {oc2g,lc15}bts_bty.c: Fix trailing whitespace
Change-Id: I1a9cf84ae0120c6ce9068efeb0e9824e4726564e
2020-06-18 16:03:38 +02:00
Pau Espin 7a58aa9bc4 scheduler: Add rate_ctr informing about Dl block not found
Together with previous counter L1SCHED_TS_CTR_DL_LATE, it allows
understanding which dl blocks are really lost (never queued) and which
were simply queued too late.

Change-Id: I456d0cfbef1e03b147ce7d968a3ec42dd728fe74
2020-06-18 11:48:49 +00:00
Pau Espin 1240ea8b83 scheduler: Add rate_ctr informing about too low rts-advance
Change-Id: I76c3dd4020c6d74192b03b1d42413ae536da5f05
2020-06-18 11:48:49 +00:00
Pau Espin 871f624f40 Merge gsm_data_shared.h into gsm_data.h
Old _shared one comes from time where we shared header with other
componenets. It's no longer the case sine a logn time ago.
The gsm_data_shared.h is only being included by gsm_data.h nowadays, so
let's simply merge it to simplify header dependency and struct
definitions.

Similarly, gsm_data_shared.c is renamed to gsm_data.c

Change-Id: Id60e7582e3a32dbc5e3531b87b2b49f07aee734d
2020-06-17 17:50:07 +02:00
Pau Espin 44d91846f0 cosmetic: common/Makefile.am: split each source file in one line
Change-Id: I9c4d78fb80446fa4142950d947dad20856573275
2020-06-17 17:24:46 +02:00
Pau Espin b56161f4e6 scheduler: _sched_dequeue_prim(): Refactor found_msg goto path
Change-Id: Icf7414d9fb17bbc3eb384329f587b3042ba0fcd5
2020-06-16 16:39:40 +02:00
Pau Espin 1e63317e29 scheduler: _sched_dequeue_prim(): Refactor goto paths
Change-Id: Ia0b1674ac3dfbe89c9eb0e6d6426848ec64320d9
2020-06-16 16:39:11 +02:00
Pau Espin 2772cabbd0 scheduler: Early return in _sched_dequeue_prim() and clarify FN cases
We should always expect the msgb queue to be ordered by FN, so there's
no use in continue traversing the queue after we found a later primitive
than the one at current time, since next onews will be even more in the
future.

Change-Id: If57fc3d89a74e6cbc79fce80dae7bf4f77e9364d
2020-06-16 14:34:27 +02:00
Pau Espin 5f71aab35f scheduler: Improve logging about prim being out of range
Change-Id: Ie7ea210fee1f59ece3abe171b64cdc04670c344b
2020-06-16 13:54:35 +02:00
Vadim Yanitskiy c3fdee43dd A-bis/OML: fix logging: do not print A-bis MO name twice
LOGPFOH() itself prepends A-bis MO name to the logging message.

Change-Id: I513efeb441a69e9eee1ad7bbd8cb0b552b7195eb
2020-06-15 22:51:24 +07:00
Vadim Yanitskiy df26770d41 A-bis/RSL: refactor handling of BS Power IE (power reduction)
According to 3GPP TS 08.58, section 9.3.4, BS Power IE indicates
the transmission power attenuation on a particular channel:

  +--------------+---------+-----------------+
  | Reserved (3) | FPC (1) | Power level (4) |
  +--------------+---------+-----------------+

so let's change handling of this IE as follows:

  - s/bs_power/bs_power_red/g, so it reflects 'reduction';
  - store power attenuation value in dB, not in 2 db steps;
  - get rid of ms_power_ctrl.bts_tx_pwr, it's always 0 anyway;
    - fix rsl_tx_meas_res(): use lchan->bs_power_red;
  - always check if FPC (Fast Power Control) flag is set;
    - we don't support it, so reject messages containing it;
    - fix rsl_rx_chan_activ(): properly apply the bitmask.

Change-Id: I16cc50dfca102030380a06e16c234d5f6698f38f
2020-06-15 22:51:20 +07: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 c8086c317e abis.c: Grab reference to e1inp_line_get if already created
Since we are returning the pointer, it should always be grabbing a
reference (find doesn't do it).
In practice it's not much important since it is always created and not
found.

Change-Id: Ib84636663be2df33d497131c780b010b57f17e32
2020-06-12 15:16:41 +02:00
Pau Espin 0bf87ccc3e scheduler: Fix reading out of buffer during tx of dummy burst on PDCH TS with EGPRS enabled
If for whatever reason (eg fn-advance too small) there's no burst
available for a PDCH TS where EGPRS is enabled, a dummy burst of size GSM_BURST_LEN
would be selected in _sched_dl_burst(), but the nbits length would still be set to
EGPRS_BURST_LEN above by func() pointer (tx_pdtch_fn()).
As a result, trx_if_send_burst() would later read EGPRS_BURST_LEN from the
dummy burst of size GSM_BURST_LEN.

The issue was found by ASan. See OS#4606 for more info.

Fixes: OS#4606
Change-Id: Iba6ccceed5c0f1db810259768678f174d39cbf8b
2020-06-12 10:01:46 +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
Pau Espin c579e674c7 pcu_sock: Change log about tx PCH confirm INFO->DEBUG
It's not something useful to see unless someone's really debugging that
part, and it shows up quite frequently.

Change-Id: I3c0dee36c7d34e6b1341b517ce3bcd1b275e69c1
2020-06-12 09:59:31 +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 ba0e5c7d50 gsm_data_shared: use bitvec API to allocate the feature vector
Change-Id: I19ecfc619c0dc2bfd14f054d17e222c4e16f6238
2020-06-11 00:35:51 +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 46aa972411 oml: fix TL16V length calculation in add_bts_feat()
An additional octet is only needed if total number of features
cannot be devided by 8 without the remainder. Fix this.

Change-Id: Ie501e5a635493830e0597f7b2fa287b6448e660d
2020-06-10 23:21:28 +07:00
Pau Espin 8f8d3a7e07 scheduler.c: Fix trailing whitespace
Change-Id: I9842470fcad074863bd30550ac63640754de1d37
2020-06-09 17:56:34 +02:00
Pau Espin 66564ed696 oml.c: Log ADM STATE change locked/unlocked
Use same forma tuse for other OMl states, like OPER and AVAIL states.

Change-Id: Icb176e2215841509bf15a6dfc163ceddcb602954
2020-06-09 08:46:32 +00:00
Pau Espin 5969988754 oml.c: Fix whitespace in log line
Change-Id: I5e9b07303dda374e9196d7d4503ad652970ab6c5
2020-06-09 07:37:37 +00:00
Harald Welte a003fec7cd Ensure we include lchan name in all LAPDm log lines
This makes use of the newly-introduced lapdm_channel_init3() API,
which provides the user (BTS in this case) to provide a human-readable
string identifier for each LAPDm channel.  This identifier is
subsequently used in all related log lines to provide context.

This means we will now get context information about which specific
SAPI in which sub-channel (ACCH/DCCH) on which lchan/ts/trx/bts a given
message originated from.

Example:
DLLAPD <0011> lapd_core.c:829 ((bts=0,trx=0,ts=0,ss=0)[DCCH][0]) SABM(E) received in state LAPD_STATE_IDLE

Change-Id: I17e3d4797ec71e31d0775330ae36d2e1fd70423f
Depends: libosmocore.git Ie6742843fff809edffcac24c4dce4edf66bc71be
Related: OS#1938
2020-06-07 22:31:19 +02: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 b8200203d8 common/scheduler: fix unreachable code in trx_sched_set_lchan()
Change-Id: Ie9d8f8ca86195be4408db717cd3194a7d2ddc918
2020-06-06 19:41:15 +00:00
Pau Espin 897aa786c2 bts-trx: phy_link: Improve logging fmt in phy_link_state_set()
Change-Id: I4633dd81d0b4cc104ca9e0803993ba766cb23790
2020-06-05 20:57:08 +00:00
Vadim Yanitskiy 031f925ccd osmo-bts-virtual: cosmetic: use LID_{SACCH,DEDIC} macros
Change-Id: Idd37ca9ebf0d483cbea6f0e992211b9c3e2af993
2020-06-06 03:14:24 +07: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
Vadim Yanitskiy ffe5a8d8b8 rsl: refactor handling of RSL_IE_MR_CONFIG
- get rid of gsm_lchan::mr_bts_lv, it's never used anyway,
  - check IE length in amr_parse_mr_conf() before parsing,
  - check return code of amr_parse_mr_conf().

Change-Id: Ibfd5845ea429945b352dd14421e86562998d65ca
2020-06-05 18:40:42 +07:00
Vadim Yanitskiy 301b218509 vty: fix bts_dump_vty(): properly print OML stream ID (TEI)
Change-Id: I80ceba60e4b48d5bc68de71a2b2a2036b1e78f57
2020-06-05 18:38:38 +07:00
Vadim Yanitskiy fccd944bd7 gsm_data_shared: drop force_combined_si & bcch_change_mark
Change-Id: I997ab5e9801af50708ce6dc35004da5e11cb926b
2020-06-05 18:38:38 +07:00
Vadim Yanitskiy b8bdefc33b gsm_data_shared: drop unused rach_b_thresh & rach_ldavg_slots
Change-Id: I75ffc5c0c1f683adf0632bfe71ac51d1adfd97bd
2020-06-05 18:38:38 +07:00
Vadim Yanitskiy 1851781d99 gsm_data_shared: drop unused sacch_deact from struct gsm_lchan
Change-Id: I93c6bebbf715076c774248596089c77511733acc
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy f5f614b86d gsm_data_shared: drop unused channel request reason definitions
Change-Id: I9a680d4a60dbdd82dc31fbd06c6ecd2240945c68
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy 14819d8053 vty: use gsm48_chan_mode_name() from libosmocore
Change-Id: I18cdaa26a674bd9279a4ea1946aefc6969404139
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy 0a8642ab5c vty: cosmetic: make an error message more informative
Change-Id: I9aeb1780b6a64f7bec80ecb243bd01b47cf4ef24
2020-06-05 02:14:48 +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 9daa67d0e7 osmo-bts-omldummy: make number of transceivers configurable
Change-Id: I712988a289c446c76dc4d9de0189fe448ae08e4d
Related: OS#4570
2020-06-02 22:29:56 +07:00
Vadim Yanitskiy 94dee95120 osmo-bts-omldummy: print a brief usage statement if argc < 3
Change-Id: Iff2e3c47ed12f02f75589e7bd0cccb5dab32d040
2020-06-02 22:18:53 +07:00
Vadim Yanitskiy e82c8436cb fix typo in osmo_bts_variant_names: s/omso/osmo/g
Accidentally noticed this typo while working on osmo-bsc:

  DNM ERROR abis_nm.c:525 BTS0 reported unknown variant
                          'omso-bts-trx' (expected 'osmo-bts-trx')

Change-Id: I45b0fb7b940ee4267e6ee315d18e5b95c9231894
2020-05-31 03:44:26 +07:00
Pau Espin f0171a9974 vty: Fix misleading define name
define contains strings about dB vs mdB, not dB vs dBm.

Change-Id: Ib2f1f9429d7d5ead585fb93195a890abd568e65c
2020-05-28 19:00:48 +02:00
Harald Welte d211c490ca virtual/scheduler: log unknown GSMTAP chan
Related change in libosmocore will let gsmtap_makemsg return NULL if the
channel type is unknown: Ib4147a33a75c3cf425c30da8b0678c7fba8a371d

Related: SYS#4822
Change-Id: Ic22ab71e520ab44429a93724250d349d16250801
2020-05-20 12:55:08 +00:00
Pau Espin d4a53017e1 l1_utils.h: Avoid redefinition of global vars defined in l1_utils.c
Change-Id: Idd40433fee22aeb1e86708c132929bb69e626334
2020-05-19 20:31:50 +00:00
Philipp Maier 59e7773055 measurement: expect at least 1 SUB frame for AMR
The amount of SUB frames that may occur in AMR is not fixed, nor can it
be determined by some formular or lookup table. The reason for this is
that the DTX period may negotiated dynamicly. This means that the lower
layers must make the decision if an AMR sub frame is a SUB frame early
and tag the repective measurement / frame they hand up to the upper
layers accordingly. However, regardles of the occurrence of DTX periods
the amount of SUB frames in AMR must be always 1 or more because SACCH
frames always count as SUB frames as well. Lets make sure that this is
respected in the debug log as well as in the logic that tries to
substitue missing SUB frame measuremnets.

Change-Id: I1fd91b576ff7274caa6d4356bcd7a4fa4311219d
Related: OS#4465
2020-05-16 20:22:48 +00:00
Vadim Yanitskiy 7726eaa477 oml: fix oml_mo_tx_sw_act_rep(): do not allocate FOM header twice
This redundant call to msgb_put() appends five '00'O octets to the
"Software Activated Report" message, so they look like an unknown
attribute(s). I accidentally noticed this in Wireshark.

Change-Id: I7377575135f4a154572891d1b5b39ff814b97f38
2020-05-16 19:22:19 +07: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 ee320d5b36 measurement: make measurements more debugable
A debug line is printed whenever a measurement is added and it also
displays if the added measurement is a sub frame or not, lets display
all the other properties too, especially inv_rssi would help a lot as it
shows us the rssi values which are reported by the lower layers

Related: OS#2978
Change-Id: I0299b75e99661e8dd22ad6604a897db4533c3b2b
2020-05-06 19:39:00 +00:00
Vadim Yanitskiy 40fb4b7614 osmo-bts-{sysmo,oc2g,lc15}: fix segfault on 'dsp-trace-flag'
== How to reproduce?

  phy 0
    instance 0
      dsp-trace-flag error
      dsp-trace-flag debug

== What happens?

  Program received signal SIGSEGV, Segmentation fault.
  0x432dbe64 in strcasecmp () from /lib/libc.so.6
  (gdb)
  (gdb) bt
  #00x432dbe64 in strcasecmp () from /lib/libc.so.6
  #10xb6ed69ec in get_string_value () from /usr/lib/libosmocore.so.12
  #20x0001bcf0 in cfg_phy_dsp_trace_f ()
  #30xb6fc1080 in ?? () from /usr/lib/libosmovty.so.4
  Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Change-Id: I23137930f81bfa8adbb62828f341470c11202b5e
2020-04-26 23:22:25 +07:00
Philipp Maier 78a1d3a31a measurement: remove unecessary is_amr_sid_update parameter
The function ts45008_83_is_sub rougly decides if a frame is a SUB frame
or not. This works by checking the frame number against against lookup
tables. This works fine for codecs where the occurrence of SUB frames is
fixed. However for AMR this is not the case as the DTX periods are
dynamic. Here it is the responsibility of the lower layers (phy,
frame decoding) to tag SUB frames early since making the decision later
based on the frame number is not possible.

The parameter is_amr_sid_update was probably added as a placeholder. It
is set to falls by the callers of the function. Lets remove this
parameter as a late decision if an AMR frame is a SUB frame will never
work.

Change-Id: I125d5ff592218a9e98130a6a7b6bbc6378ce4132
Related: OS#2978
2020-04-25 14:03:06 +00: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
Pau Espin 557ca0f468 oc2g: Fix mismatching signature in callback provided
Similar to what's done for lc15 in
Id80d5a52cbccce54456205dec230a0b546b8b310.

Change-Id: I06747d5992d09a506d26089391ef130418506333
2020-04-25 13:51:16 +00:00
Pau Espin fd6584b179 oc2g: Fix returning values on void function
Similar to what's done in I7a944c0636933c0389db9aabd8b5e6c173052f12 for
lc15.

Change-Id: I6f5e976969af994011bc9282ede115606f0f0d20
2020-04-25 13:51:16 +00:00
Pau Espin 5a618186a1 lc15: Fix mismatching signature in callback provided
Fixes following compilation warning:

/osmo-bts/src/osmo-bts-litecell15/l1_if.c: In function ‘dsp_alive_timer_cb’:
/osmo-bts/src/osmo-bts-litecell15/l1_if.c:1643:33: warning: passing argument 3 of ‘l1if_req_compl’ from incompatible pointer type [-Wincompatible-pointer-types]
 1643 |  rc = l1if_req_compl(fl1h, msg, dsp_alive_compl_cb, NULL);
      |                                 ^~~~~~~~~~~~~~~~~~
      |                                 |
      |                                 void (*)(struct gsm_bts_trx *, struct msgb *, void *)
/osmo-bts/src/osmo-bts-litecell15/l1_if.c:220:21: note: expected ‘int (*)(struct gsm_bts_trx *, struct msgb *, void *)’ but argument is of type ‘void (*)(struct gsm_bts_trx *, struct msgb *, void *)’
  220 |      l1if_compl_cb *cb, void *data)
      |      ~~~~~~~~~~~~~~~^~

Change-Id: Id80d5a52cbccce54456205dec230a0b546b8b310
2020-04-25 13:51:16 +00:00
Pau Espin 321d69f4fd lc15: Fix returning values on void function
Fixes following warnings:
/osmo-bts/src/osmo-bts-litecell15/l1_if.c:1722:36: warning: assignment to ‘void (*)(void *)’ from incompatible pointer type ‘int (*)(void *)’ [-Wincompatible-pointer-types]
 1722 |  fl1h->hw_alive.dsp_alive_timer.cb = dsp_alive_timer_cb;
      |                                    ^

Change-Id: I7a944c0636933c0389db9aabd8b5e6c173052f12
2020-04-25 13:51:16 +00:00
Rafael Diniz 4f3e3db8d1 osmo-bts-litecell15: Implement missing features.
Many hardware parameters of the LC 1.5 were not exposed to the user.
This change introduces most of the features, being very similar
to osmo-bts-oc2g code. Mostly based on commit
653e974fec00414ba85baf258ccc46ea778a53bd from NuRAN's osmo-bts fork
at: https://gitlab.com/nrw_noa/osmo-bts

Change-Id: Ib16e7d423fc7030573acd86fbd356ae96697ed5d
2020-04-25 13:51:16 +00:00
Harald Welte 7b0da0650d osmo-bts-virtual: Avoid rejecting AMR in uplink
Change-Id: Ib527a9fe02c49f6129c376424480aa1004f9ee8f
2020-04-21 21:03:55 +00:00
Harald Welte 187f7c8713 fix compilation with gcc-10
/usr/bin/ld: /home/laforge/projects/git/osmo-bts/tests/sysmobts/../../src/osmo-bts-sysmo/tch.c:584: undefined reference to `femtobts_tch_pl_names'
/usr/bin/ld: l1_transp_hw.o:/home/laforge/projects/git/osmo-bts/src/osmo-bts-sysmo/femtobts.h:108: multiple definition of `pdch_msu_size'; main.o:/home/laforge/projects/git/osmo-bts/src/osmo-bts-sysmo/femtobts.h:108: first defined here
/usr/bin/ld: l1_transp_hw.o:/home/laforge/projects/git/osmo-bts/src/osmo-bts-sysmo/femtobts.h:71: multiple definition of `femtobts_l1prim_type'; main.o:/home/laforge/projects/git/osmo-bts/src/osmo-bts-sysmo/femtobts.h:71: first defined here

see also: https://alioth-lists.debian.net/pipermail/debian-mobcom-maintainers/Week-of-Mon-20200413/000651.html

Change-Id: I4a9896153876fcda496365776883827746205f00
2020-04-20 20:09:24 +02:00
Philipp Maier 731683cd62 logging: use only LOGL_NOTICE as defualt loglevel
some of the log categories in logging.c are set to LOGL_INFO or even to
LOGL_DEBUG. This is too verbose. Lets set those categories to
LOGL_NOTICE. Also the BTS manager programs (...bts_mgr.c) use LOGL_INFO
by default. This should be set to LOGL_NOTICE as well

Related: OS#2577
Change-Id: I6e7a635f9b4a93529661dafc591d512d7b7e8c75
2020-04-14 13:20:21 +00:00
Philipp Maier 7f1800832f scheduler: always call Uplink burst handler on NOPE.ind
When a NOPE indication is received from the TRX normally a separate
handler (.nope_fn) is called. It turned out that calling the Uplink
handler (.ul_fn) on NOPE indications is the usual case, so let's
remove the .nope_fn member and call the Uplink handler directly.

Since a NOPE.ind comes without burst bits, the Uplink handlers must
check bi->burst_len to avoid uninitialized memory access. For some
logical channels (in particular RACH, PDTCH/U, and PTCCH/U) it does
not make sense to call the Uplink handler, so we ignore them.

Change-Id: Ice45d5986610d9bcef2a7e41f0a395ec779e3928
Related: OS#4461
2020-04-04 20:27:52 +07:00
Harald Welte 085872fe85 cosmetic: remove dead code from logging.c
Change-Id: Ib70313d8f837ebac39ed8caaa80b01ffafe879d5
2020-04-03 19:33:17 +00:00
Vadim Yanitskiy c4744ac24c l1sap: fix gsmtap_ph_rach(): properly pack 8-bit and 11-bit RA
According to 3GPP TS 44.004, section 7.4a, two alternative RACH
block formats are specified: 8 bit (1 octet) and 11 bit. The
bit order is little-endian (right to left).

In L1SAP PH-RACH.ind structure (see ph_rach_ind_param) we use
a field of type uint16_t to store RA values regardles of the
block format. Thus when packing it to bytes, we cannot just
cast uint16_t* to uint8_t*, we need to do some bit shifting.

Change-Id: I0e91d825bb2e1897647dd5403c311d833a89ff2e
2020-04-01 01:46:44 +07:00
Oliver Smith ae4d85d891 VTY: add "test send-failure-event-report"
Send test failure event report OML message to the BSC. I found this
useful while manually testing related handling code in OsmoBSC.

Related: OS#1605
Change-Id: I0c4eba1636d8faf5012db26643bdf1d9fb6bfa1e
2020-03-24 08:01:05 +00:00
Harald Welte e2f9d0eabe trx: Use NOPE indications on SDCCH
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

Related: OS#4661
Related: OS#2975
Change-Id: Idfc5c9a23db808c5f87ef5646c7e1d1cd3127371
2020-03-22 14:06:56 +01: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
Harald Welte e36fbca15f osmo-bts-virtual: Fix "virtual-um net-device NETDEV"
The VTY option to bind the virtual Um multicast to a specific
network interface has existed ever since osmo-bts-virtual was
first merged to the repo.   However, embarrassingly, until today
it never did anything, i.e. the code to actually perform the bind
was missing.

Depends: libosmocore.git Ib52d22710020b56965aefcef09bde8247ace4a9c
Change-Id: I303f2e616d2d32b5a8005c3dcf0f5fad19ad3445
Related: OS#2966
2020-03-10 21:36:00 +01:00
Harald Welte 5914d76d5c osmo-bts-virtual: Add "virtual-um ttl <0-255>" VTY option
This can be used to determine the multicast TTL packet and hence
how far the packet will propagate in the network.  If you want to
operate the virtual Um only on your own machine, a TTL of 0 would
prevent the packets from ever being transmitted on your local
ethernet segment.

Change-Id: I18a9f93b764aee4e1dc68a1c6ac4d078e52ca61d
Related: OS#2966
2020-03-10 21:35:56 +01:00
Oliver Smith cb4340b8a4 rsl: make IP DSCP configurable
Related: OS#4438
Depends: libosmo-abis I41603db8c1286660ad57ac1c78a8fb393a2b080b
Change-Id: Icdef5d40243fefdeae23f3bcf9c6702e8487928a
2020-03-08 17:56:52 +01:00
Harald Welte 58d79e88ad osmo-bts-virtual: implement GSMTAP_CHANNEL_VOICE
GSMTAP_CHANNEL_VOICE is the mechanism by which GSMTAP can [finally!]
be used to transport circuit-switched voice codec payload, and not
just signalling.

Original patch by Neels Hofmeyr, heavily extended by Harald Welte.

Depends: libosmocore.git I952044a17334f35712e087dc41781805000aebc1
Change-Id: I1cd9a251ce0b87181a0822d7940bbfc9f1428543
2020-03-08 17:56:52 +01:00
Harald Welte 6a5039674f l1sap: Use msgb_pull_l2() and unify l1sap_tch_ind + l1sap_ph_data_ind
In l1sap_ph_data_ind() we can use msgb_pull_l2() which is an exact
implementation of the functionality there.

In l1sap_tch_ind(), the existing code is actually wrong by making the
assumption that the msgb contains exactly an entire osmo_phsap_prim.
Better to also dynamically compute the number of bytes to ensure
we only pull those ahead of the L2 header, no matter what their exact
count.

Change-Id: I13f7f8ba93795e40b1fb4a306fe765e059f642cf
2020-03-08 17:12:15 +01:00
Vadim Yanitskiy 3f35ab258d osmo-bts-virtual: do not log GSMTAP message sending failure twice
Change-Id: I39e9edf35240ef31e3432412b459c2b8fb0de054
2020-03-04 20:43:02 +07:00
Vadim Yanitskiy f9e7ccce27 osmo-bts-virtual: do not print redundant info in tx_to_virt_um()
LOGL1S() already prints enough context information.

Change-Id: I29adf9360b96544b7f58766d5cd26d97117884d9
2020-03-02 00:26:33 +07:00
Vadim Yanitskiy 2b948a3d17 osmo-bts-virtual: fix wrong endianness in gsmtap_hdr_stringify()
Change-Id: Ic9e84dc4adc44df735cba102bdace2fb1993ac8e
2020-02-29 18:09:46 +07:00
Vadim Yanitskiy 1f932689fc common/sysinfo: reduce criticality of a logging message
During the process of bootstrapping, it may happen that System
Information Type 3 is not yet received from the BSC, while the
BTS already needs to transmit a block on AGCH or PCH.

Since the RSL link is established later than the OML link, it's
kind of expected, so we should not log it as error.

Change-Id: I41aa3dbe375cf42c39032bafa80dba94d6219d35
2020-02-29 14:29:27 +07:00
Vadim Yanitskiy 7364ef15d9 vty: fix left shift by 31 cannot be represented in type 'int'
Change-Id: I3e5940e8f360bf6563f4c1b5ebd09579f9108c81
2020-02-27 23:35:09 +07:00
Harald Welte 24f98a0df9 virtual: Fix VTY commands to specify GSMTAP multicast groups
osmo-bts-virtual uses GSMTAP over multicast groups to communicate
with one or more virtphy instances.  There are some well-known default
multicast groups, but those can also be overridden via the VTY.

The problem is: If you actually try that, osmo-bts-virtual will abort,
as we try to talloc_free() when using osmo_talloc_replace_string()
on the constant default string.

The proper solution is to talloc_strdup() the constant default string
when setting the default value in bts_model_phy_link_set_defaults().

Change-Id: Ia96fea891a22e5a3c47ce658eda130ba8d4fc411
2020-02-26 14:36:58 +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 5184576572 osmo-bts-sysmo: merge measurement data and payload
For osmo-bts-sysmo the MPH INFO MEAS IND indication is still sent
separately. Lets merge the measurement information into the PH DATA

Change-Id: Iffe7865727fbf9bca8eb32a96e8ea05cf718a948
Related: OS#2977
2020-02-17 12:40:07 +01:00
Philipp Maier ac61baed2e Do not depend on pcu_direct flag when populating ph_data_ind
The struct members ber10k, ta_offs_256bits and lqual_cb in ph_data_ind
are only populated when the pcu_direct flag is not set.

The pcu_direct flag is set when the pcu is directly attached to the phy
and all pcu related traffic (pdtch) is handled without sending it through
osmo-bts-sysmo. For those cases osmo_bts_sysmo will not make use of
those struct members, even if they were populated. When the PCU is not
directly attached the data is needed because it is sent through the
pcu_sock to the PCU.

Lets remove the check because it is not required. Also in future patches
where measurement indications and data / tch indicatins are merged the
struct members are also needed to carry the measurement information for
SACCH as well.

Change-Id: Iaa37bb62af4f5eb4b6e684cb754e68d11e6fd676
2020-02-17 12:11:43 +01:00
Pau Espin aea29c7249 l1sap: Change loglevel of Rx TCH.ind INFO->DEBUG
This line appears tens of times per second when a call is ongoing,
making it impossible to follow logs on INFO level.

Change-Id: Iadb1baf55df2f6d96f85260f2e8d03627fef7e66
2020-02-12 16:01:47 +01:00
Pau Espin 52d7eafcea l1_if: Fix strange formatting of Meas info logging
Some use LOGPC, but were used after a LOGP with a trailing newline.
Let's simply add some defines/macros to be able to include it into a
normal LOGP easily insted of having a function.

Change-Id: Ie082b11c9d6d00ff2206184f03f6e3647c3da18c
2020-02-12 14:29:38 +01:00
Vadim Yanitskiy cb69d607c9 osmo-bts-sysmo/Makefile.am: fix: do not overwrite bin_PROGRAMS
src/osmo-bts-sysmo/Makefile.am:25: warning: bin_PROGRAMS was already
				   defined in condition TRUE, which
				   includes condition ENABLE_SYSMOBTS_CALIB
src/osmo-bts-sysmo/Makefile.am:10: ... 'bin_PROGRAMS' previously defined here

Change-Id: Ib2334dccefd507eaaa6d33e58d4c1e029d7fd540
2020-01-21 18:52:08 +07: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 8969adc5d9 measurment: write irssi_full_sum variable correctly
The variable irssi_full_sum is not populated with a dummy value when we
are not able to compute irssi_full_sum. Instead we mistakenly write
MEASUREMENT_DUMMY_IRSSI to ber_full_sum, which is wrong

Change-Id: I44d7cb48e3c68ab1b48c78cceb9381ce3e39d7e8
Related: OS#2987
2020-01-20 14:33:51 +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
Vadim Yanitskiy e7d835ca8c L1SAP: use LOGL_DEBUG for logging from rach_pass_filter()
Due to relatively small training sequence of Access Bursts, there
can be frequent false-positives (basically noise). Fortunately,
we can distinguish them from the real Access Bursts by checking
the signal measurements attached to them (BER, ToA and C/I).

Let's reduce verbosity of logging messages as they are mostly
useful for debugging and may confuse the users / operators.

Change-Id: I7ab6727ffff00140a7f9e762b299b711481393f1
2020-01-14 03:51:08 +07:00
Harald Welte 113712c728 rsl.c: Fix compiler error on gcc-9.2.1
rsl.c: In function ‘rsl_rx_ipac_XXcx’:
rsl.c:2147:39: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 28 [-Werror=format-truncation=]
 2147 |   snprintf(cname, sizeof(cname), "bts@%s", ipstr);
      |                                       ^~
rsl.c:2147:3: note: ‘snprintf’ output between 5 and 260 bytes into a destination of size 32
 2147 |   snprintf(cname, sizeof(cname), "bts@%s", ipstr);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: Id982a814f401e304327d25c77666f039bc156c1f
2020-01-12 16:11:12 +01:00
Vadim Yanitskiy e5711efbb5 common/abis.c: make use of RSL TEI from OML IPA RSL Connect
Change-Id: I5927f59a49724170a63e87be604973f7c9d5d8be
2020-01-11 00:51:43 +01:00
Vadim Yanitskiy f9115ae67a common/vty.c: get rid of generic exit / end commands
Those commands are now handled by libosmovty itself.

Change-Id: I425f9058ae15de929e2ba0283d4057bdf767aeeb
2020-01-11 00:17:10 +01:00
Michael McTernan b54f1bf122 measurement: use signed integer for division of ta256b_sum
The variable ta256b_sum is int32_t and num_ul_meas_actual is unsigned
int. When ta256b_sum is negative the division produces the wrong result.

This is beacuse the division is performed unsigned as the usual
arithmetic conversions promote to unsigned where both both operands are
the same width.

Lets fix this by casting num_ul_meas_actual to signed.

(Note that in the same function there are various other averages
computed in the same pattern, but they have unsigned operands and so are
correct.)

Related: SYS#4728
Change-Id: I37e3f69109c5ca2948bd4cdb7aa017bf2fcb8172
2020-01-06 12:07:23 +01:00
Philipp Maier 24e702b7d0 l1sap.c: ensure ms power control loop is running
When a bad SACCH frame is received the processing of the frame is ended
early and lchan_ms_pwr_ctrl() is not called. This means that the power
control loop does not get informed about a situation where the signal
level is very weak and increasing the ms power would make sense. In
order to ensure that the power control keeps working on lost SACCH
frames, lets call lchan_ms_pwr_ctrl() with the current RSSI and the
requested (BSC) power setting.

Related: OS#4281
Change-Id: I4fb85754b1a69376b02da7f4b175c6e8ec9cc35c
2020-01-03 13:03:49 +01: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
Vadim Yanitskiy a2392f0f9e osmo-bts-trx/vty: ensure backwards compatibility with older config files
osmo-bts-trx used to have its own (low-level) MS Power Control loop,
but recently it has been ripped out. Since [1], the process fails to
start if the configuration file still contains 'ms-power-control dsp'.

Let's be more tolerant: override 'dsp' by 'osmo' and print a warning.

[1] I49706926b1e962b18791174627bc3cc0cd0cd9d5

Change-Id: I4facd21bca3d8cb80d21e83ea267bc013e474533
2019-12-31 17:03:38 +00:00
Pau Espin e1766f1b7d l1sap: is_fille_frame(): verify len of data compared
Change-Id: Id3d1725ff36091ed5c57927caad09a8baea6f52e
2019-12-23 18:27:47 +01:00
Pau Espin 7544f5a45b power_control.c: Clarify loop algo vars and use correct ones during log
Rename some variables so that:
* Variables containing power control levels end up with "_lvl".
* Variables containing power levels end up with _dbm.
* Move old current_dbm var to be ms_dbm, to match its power control
level counterpart ms_power_lvl, and add current_dbm to match its
counterpart ns_power_ctrl.current.

Now that variables are more clear, it also becomes clear that old "diff >
0" condition, apart from difficult, was currently wrong, since in order
to print the raise/low verb we want to compare between old and new
values, not between received and new values. Let's fix that in this same
commit.

Change-Id: I4e279a6b93fbcc5da25bf8c9213310939fd493ce
2019-12-05 12:58:08 +01:00
Pau Espin 99ba515985 power_control.c: Log maximum allowed MS Power Level
Change-Id: I983ff824ef6f54f1e800819d622158d5e2a51f04
2019-12-05 11:22:09 +00:00
Pau Espin 397a43c38a rsl: Clarify when autnonoums MS Power Ctrl Loop is used
Simplify when the fixed field is set in rsl_rx_chan_activ.

Comment talks about enabling autonoumous control loop, but it is
actually describing it when disabling it, which is confusing.

Change-Id: Id6b444a33ab062f6dab11a0ce62d8aecaea87591
2019-12-05 11:22:09 +00:00
Harald Welte e571fd60e6 rach_pass_filter(): Add information about channel type
When logging about filtering access bursts, let's indicate if this is
on a CCCH, PDCH or handover related.

Change-Id: I03f21f2b54cbe5aad36ac71a614d5df98867df80
2019-12-04 16:40:30 +01:00
Pau Espin 80f9b84a64 rsl_rx_chan_act: Apply bitmask when parsing IE MS_POWER
Change-Id: I99c6a4d353f405582d5e4f9d12c01c25c7bb4dff
2019-12-03 18:34:40 +01:00
Vadim Yanitskiy bd3eabc13e common/abis.c: use tall_bts_ctx as talloc-context for libosmo_abis_init()
This way it's much easier to introspect the library internal
talloc allocations from the VTY interface.

Change-Id: Ic8d9fc7ce3da8abf0ea73d2b20366133cd801c37
2019-12-02 23:21:27 +00:00
Vadim Yanitskiy 6bb700e9d2 common/abis.c: pass gsm_bts_trx to e1inp_sign_link_create()
Change-Id: I8a6242d3e02f9bd19d287ecad18e001a5991175f
2019-12-02 08:46:43 +00: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 3cb61d902c common/vty.c: fix: properly assert() the result of get_string_value()
Change-Id: I6ecd46371e601ad0fb629f9756b36c9c4758a958
Fixes: CID#205067, CID#205068
2019-11-26 17:14:39 +07:00
Vadim Yanitskiy a070e863e2 pcuif_proto.h: extend RACH.ind with TRX and timeslot number fields
Since there can be multiple PDCH channels configured on different
timeslots, different TRXes, and BTSes, the PTCCH/U handling code
in OsmoPCU needs to know the exact origin of a given RACH.ind.

Otherwise, it is not known which subscriber originated a given
PTCCH/U indication, and hence it is impossible to send PTCCH/D
Timing Advance notification properly.

Fortunately, we can extend the RACH.ind message without even
bumping the protocol version, because every single PDU has a
fixed size defined by the largest message - INFO.ind. In case
if the actual message payload is smaller, the rest is filled
with a constant padding byte (0x00).

Older versions of OsmoPCU will consider the new fields as padding,
while the messages from older OsmoBTS versions will always have
both fields set to 0x00. Since C0/TS0 cannot be configured to
PDCH, this can be easily detected on the other end.

Change-Id: Iff38934a108b6b1cd298669834263a7d5296c3f6
Related: OS#4102, OS#1545
2019-11-22 17:38:07 +00:00
Pau Espin 1d9f6efccb power_control.c: Limit speed of announced MS Power Level value changes
It's not a good idea to request big changes in MS Power based on
sporadic bad signal received, let's instead change announced MS power
levels more smoothly to avoid possible big signal strength fluctations,
similar to what is already done in osmo-bts-trx specific loop (loops.c).

Related: OS#1851
Change-Id: Iecc4ec7e21471ec853ad2d5659af4052aba5444c
2019-11-20 20:27:04 +01:00
Pau Espin 522fc939e0 power_control.c: Don't use announced MS Power level as input for loop calculations
Use instead the received MS Power currently in use by the MS matching
the measured signal. This way there's no need to wait for the MS to
reach the announced MS power level or add checks in case the MS doesn't
support that specific power level. Furthermore, more fine grained
announced power level value can be obtained faster due to more input
iterations not being dropped while waiting.

osmo-bts-trx specific algo was not following this approach and using
announced MS power instead because it's wowrking at a lower level and
henche was not using the transmitted MS Power level value by the MS as
input for the calculation.

The "if (diff < 2 && diff > -2))" condition is dropped since equal
signal strength may still result in a different MS power level announced
(the one currently used by the MS during tx of last SACCH block).

Related: OS#1851
Change-Id: I4494dc27a295a3dca1d3331d4ff712d486643e13
2019-11-20 19:35:08 +01: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 d0a2caa021 power_control.c: Fix ms pwr ctrl skipped if MS doesn't support announced MS Power Level
Related: OS#1851
Change-Id: I1a9c00fe4eb3fa1eaa7997a9ec20716ddfe180a7
2019-11-14 20:02:45 +01:00
Pau Espin 38c12e9df9 power_control.c: Log rx current and target signal levels
Change-Id: I31ce7930a1daa20a2ff81f31a37df94298c877d6
2019-11-14 20:02:45 +01:00
Pau Espin 2149b0ff47 power_control.c: Apply latests improvements from loops.c
Several improvements have been made lately to MS Power Control loop from
osmo-bts-trx in loops.c. Let's port these to the common algorithm.

Related: OS#1851
Change-Id: I579967cc8bb69dc76a315c6c9d3a351f5961d92f
2019-11-14 20:01:58 +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 869091011c rsl: Remove unneeded duplicate reset on some lchan fields
Both ms_power and ms_power_ctrl are reset to 0 again further below.

Change-Id: Ia2a5da068d440232361d57bd5ac33eddebf05ebe
2019-11-14 16:36:00 +01:00
Pau Espin 18bfa91a26 Change gsm_lchan field fixed to bool
Change-Id: I715ef151b67a21e325c574585a257e71b4b0ce2a
2019-11-14 16:36:00 +01:00
Pau Espin e5e1226301 Change gsm_bts_trx field to bool and rename it
Thies field is used to store and retrieve whether MS power needs to be
calculated and updated by osmo-bts software or autonomously by lower
layers. Previous name was not clear
and may have been understood as indicating whether MS Power Control loop
is done or not in general, and the responsible for that is located under
lchan's ms_power_ctrl.fixed.

Related: OS#1851
Change-Id: Ic690ab69866a7377f1597e24aa7b0214831c1cbe
2019-11-14 16:36:00 +01:00
Pau Espin d8d459c7e2 cosmetic: Fix trailing whitespace
Change-Id: I7b9a091226e3c7dd60b3921ab0d53688f42d1a4d
2019-11-14 16:36:00 +01:00
Pau Espin d93669289b rsl: Fix logged value in rx MS Power Control
The interesting value in this case is the incoming new ms max power.

Change-Id: Ib6fcb21b1b4bdbc8b749a1b8543d97331699ef3b
2019-11-12 17:46:38 +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
Pau Espin 000b13ef52 rsl: Assign recv pwr to lchan's max ms power
Otherwise older ms_power value will be kept and used as a maximum.

From TS 08.58 sec 4.8 "MS power control":
"""
If power control is supported by BTS and it is to be used,
this is indicated by optional parameters in the MS POWER CONTROL
message (or the CHANNEL ACTIVATION message). Based on the
measurements performed on the uplink, 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).
"""

Change-Id: I0583eef477c33279ee5bfcda80141f365413a276
2019-11-12 14:17:24 +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 3533c3f6ad cosmetic: l1sap.c: Fix typo
Change-Id: I9fee7be915546cfd11810c74d511beb8ec10d044
2019-10-28 18:28:33 +00:00
Pau Espin 725b3158e2 power_control.c: Take into account RSL CHAN ACT ms power level limits
This is similar commit to Ifda92155bd9c277ac150a327a7ab63c854087788,
which previously fixed same issue for osmo-bts-trx specific power
control loop code.

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.
"""

Should fix TTCN3 BTS_Tests.TC_rsl_ms_pwr_dyn_max for non-bts-trx BTS
models.

Related: OS#1622
Change-Id: I376b52d7bee44132993a69cf532bd418171d0ca2
2019-10-28 16:59:42 +01: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
Oliver Smith e4abc63e42 vty.c: avoid coverity BAD_SHIFT issues
Make it obvious for compilers and for coverity, that the sapi value used
to shift a bit for the sapi_mask is always <= 31. The sapi value is an
index of the value string l1sap_common_sapi_names, which has 24 entries.

Fixes: CID#205067, CID#205068
Change-Id: Id8be0ab67479b1f76a4f624bd3a5242e4fe59f4b
2019-10-21 11:09:08 +02:00
Oliver Smith 583f2b86c9 vty.c: don't ignore get_string_value() errors
Change uint8_t sapi to int, so we can properly assert on errors from
get_string_value().

Fixes: CID#205066, CID#205069
Change-Id: I4d30afacfab93051868ae8f462cee9ad3dbc7fd0
2019-10-21 11:08:50 +02:00
Martin Hauke fc5f20a713 Rename variable: CALIB_SUCESS -> CALIB_SUCCESS
Correct the name of this variable.

Change-Id: I75cb6404d772b79933d1d9d694abf8eff1fad020
2019-10-17 08:05:35 +00:00
Martin Hauke b378fccef1 Fix common misspellings and typos
Change-Id: I403b9029f57fec3fdec2c1e2cbeac0f6eab53f24
2019-10-17 08:05:35 +00:00
Oliver Smith b58fb35754 vty: add "logging filter l1-sapi"
Add VTY commands to filter by L1 SAPI. Allow to filter by multiple SAPIs
by running the filter command multiple times:

OsmoBTS> logging filter l1-sapi agch
OsmoBTS> logging filter l1-sapi pch

Related: OS#2356
Change-Id: I32d86d3d34757135b4cce59919c2fc2b67f0a889
2019-10-17 08:04:27 +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
Oliver Smith 5fee4d1ff5 log: set L1 SAPI log context
Add a new common L1 SAPI enum, to unify all the BTS specific SAPIs.
Translate to this enum, and set the context for uplink messages in
each BTS specific implementation.

Set the context for downlink messages in the common l1sap code, by
converting the osmo_phsap_prim back to the SAPI value (mostly looking at
chan_nr). The new functions for doing this conversion,
get_common_sapi_by_trx_prim() and get_common_sapi_ph_data(), are based
on the existing to_gsmtap() and gsmtap_ph_data() functions.

Note that we can't set the uplink SAPI context in the common code,
because then we can't set it as early as possible. In this patch, the
SAPI context is set for the PHYs where the SAPI is readily available.
With additional conversion from the RSL channel, the SAPI context could
be set for osmo-bts-trx in a follow up patch.

Related: OS#2356
Depends: (libosmocore) I814cb3328d99faca9220adb5a80ffb934f219d7d
Change-Id: I6b7bb2e1d61502b61214f854a4ec5cbb7267545b
2019-10-11 10:46:02 +00:00
Vadim Yanitskiy df51be6329 L1SAP: there can be no DATA.ind primitives on PTCCH/U, reject them
Change-Id: Ib846a9b8e619c7da56b5f0a54d16f629913af80d
2019-10-09 16:45:48 +00:00
Vadim Yanitskiy d73832bc35 L1SAP: use GSMTAP_CHANNEL_PDTCH for PDTCH blocks by default
We don't know whether a data block on PDCH belongs to PDTCH or PACCH
without parsing it, because the latter one is being allocated on
demand. Let's use GSMTAP_CHANNEL_PDTCH by default, rather than
GSMTAP_CHANNEL_PACCH.

Change-Id: I7639215ef936a8ac05ca417a91f4e12755f318d4
2019-10-09 16:45:48 +00:00
Vadim Yanitskiy 2cbdeba5cf L1SAP: fix gsmtap_pdch(): there can be no DATA.ind on PTCCH/U
Change-Id: Id69010ffa8c697e8c01bbb21509253c330f95343
2019-10-09 16:45:48 +00:00
Vadim Yanitskiy 43a8ed2b55 L1SAP: use the actual ARFCN for outgoing PCUIF messages
Change-Id: I07b3aac97603d85fb6cf077d3a342b12b0643171
2019-10-09 16:45:48 +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
Vadim Yanitskiy eb43c947c1 L1SAP: properly handle 11-bit encoded RACH.ind in gsmtap_ph_rach()
Change-Id: Id263c2b716fd282d37d705a1c5f430ce7c0edaf0
2019-10-09 03:18:30 +07:00
Vadim Yanitskiy 29e47ffc20 L1SAP: refactor handling of Access Bursts on PDCH
First of all, we also need to apply the same filtering to Access
Bursts on PDCH as for the normal ones on RACH, i.e. filter them
by ToA (Timing of Arrival) and BER (Bit Error Rate).

Secondly, we shall not interpret Access Bursts on PDTCH/U as
handover related ones. Instead, let's print a warning and
ignore them since they are not (yet) supported by OsmoBTS.

Finally, in gsmtap_pdch() we need to set a proper channel type
for Access Bursts received on PDCH (PDTCH/U or PTCCH/U).

Change-Id: I461fde9f4543c45c42b591cd3fd0ff3d98673cec
2019-10-09 03:13:31 +07:00
Vadim Yanitskiy d7103f9172 L1SAP: do not pass unused parameter to l1sap_handover_rach()
Change-Id: I7f2d909f1bde09cbec106240df290381b3418e46
2019-10-09 03:01:58 +07:00
Vadim Yanitskiy 91fc2b9e30 L1SAP: clarify debug messages in rach_pass_filter()
RACH stands for Random Access CHannel, while in rach_pass_filter()
we're dealing with Access Bursts, that may be received on other
logical channels too (e.g. PTCCH, PDTCH or any other).

Change-Id: I1e5ca9930ab491a6916c972865154d54530cbf51
2019-10-09 03:01:43 +07: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
Pau Espin 972c243146 struct gsm_bts: Add model_priv pointer handing bts_model specific data
Currently there's bts-virtual specific fields in gsm_bts which is not used
by other models and are always allocated.
An alternative would be having a union with different structs inside,
one per model, but since we already have the bts_model abstraction, in this
case it makes more sense to use that abstraction instead of filling code
with preprocessor ifdefs to guard against non-defined types, etc.

Existing model specific data is moved there.

This new infra will be user further in forthcoming commits.

Related: OS#4215
Change-Id: Ib17a752cdbaa7d5eb8c5dfa0b197f80a4f38b38e
2019-10-05 20:50:13 +00:00
Vadim Yanitskiy 41c7b05283 common/l1sap: increase ToA precision for packet Access Bursts
QTA is a Timing Advance value in units of 1/4 of a symbol. Let's
use ToA256 (1/256 of a symbol) field of L1SAP RACH.ind as a base
for QTA calculation in order to achieve better precision.

Change-Id: I6e6fa7985c430a9bdbd12af2a8b2a5a66f11a41c
2019-10-04 15:53:53 +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