Commit Graph

562 Commits

Author SHA1 Message Date
Vadim Yanitskiy a344db979f [VAMOS] gsm_data.h: fix wrong bit-mask in BSIC2BCC macro
BCC takes 3 LSB bits of the BSIC, so we should apply 0b111 or 0x07.
The BSIC is specified in 3GPP TS 03.03 section 4.3.2.

Change-Id: Id24ad64e6c6de080ab43faa272daf844fbba6954
Related: SYS#5315, OS#4940
2021-05-23 10:09:27 +00:00
Vadim Yanitskiy d7323d6f1f [VAMOS] common: make 'struct gsm_bts_trx_ts' pointers const
Change-Id: I0369ef4ae603a4afed0661a5894df6a7135b1919
2021-05-23 10:09:27 +00:00
Vadim Yanitskiy e24279508d common: make the arguments of phy_{link,instance}_name() const
Change-Id: Ic01d131148065c9143d3a90f8020e2e133941292
Related: CID#236092 "Dereference before null check"
2021-05-19 16:53:06 +02:00
Vadim Yanitskiy 6ad89f2f58 osmo-bts-{trx,virtual}: fix: pinst->trx may be NULL
We assume that it's legal to have dangling PHY instances that are
not associated with any TRX instances in the configuration file.
Obviously, such PHY instances have pinst->trx set to NULL.

The DSP based models seem to handle dangling PHY instances without
any problems, so let's ensure that we always check pinst->trx
against NULL in the osmo-bts-{trx,virtual} specific code.

Change-Id: Ib7d9cb7ae47fead723fa46454cd64bf6e88756bb
Fixes: CID#236092 "Dereference before null check"
2021-05-19 16:53:06 +02:00
Vadim Yanitskiy 462bf0952a [VAMOS] Re-organize osmo-bts-trx specific structures
Together with the 'generic' structures which used to be shared between
osmo-bsc and osmo-bts some time ago, we also have the following
osmo-bts-trx specific structures (in hierarchical order):

  - struct l1sched_trx (struct gsm_bts_trx),
  - struct l1sched_ts (struct gsm_bts_trx_ts),
  - struct l1sched_chan_state (struct gsm_lchan).

These structures are not integrated into the tree of the generic
structures, but maintained in a _separate tree_ instead.  Until
recently, only the 'l1sched_trx' had a pointer to generic
'gsm_bts_trx', so in order to find the corresponding 'gsm_lchan' for
'l1sched_chan_state' one would need to traverse all the way up to
'l1sched_trx' and then tracerse another three backwards.

                                 + gsm_network
                                 |
                                 --+ gsm_bts (0..255)
                                   |
  --+ l1sched_trx --------------------> gsm_bts_trx (0..255)
    |                                |
    --+ l1sched_trx_ts               --+ gsm_bts_trx_ts (8)
      |                                |
      --+ l1sched_chan_state           --+ gsm_lchan (up to 8)

I find this architecture a bit over-complicated, especially given
that 'l1sched_trx' is kind of a dummy node containing nothing else
than a pointer to 'gsm_bts_trx' and the list of 'l1sched_trx_ts'.

In this path I slightly change the architecture as follows:

                                 + gsm_network
                                 |
                                 --+ gsm_bts (0..255)
                                   |
                                   --+ gsm_bts_trx (0..255)
                                     |
    --+ l1sched_trx_ts <----------------> gsm_bts_trx_ts (8)
      |                                |
      --+ l1sched_chan_state           --+ gsm_lchan (up to 8)

Note that unfortunately we cannot 1:1 map 'l1sched_chan_state' to
'gsm_lchan' (like we do for 'l1sched_trx_ts' and 'gsm_bts_trx_ts')
because there is no direct mapping.  The former is a higl-level
representation of a logical channel, while the later represents
one specific logical channel type like FCCH, SDCCH/0 or SACCH/0.

osmo-bts-virtual re-uses the osmo-bts-trx hierarchy, so it's also
affected by this change.

Change-Id: I7c4379e43a25e9d858d582a99bf6c4b65c9af481
2021-05-18 19:11:06 +00:00
Vadim Yanitskiy 641ffaaef3 scheduler.h: cosmetic: use #pragma once
Change-Id: I551ce74f8cec8ec8d80768ec6c0559a203a8143c
2021-05-18 19:00:55 +00:00
Pau Espin 0277cddab2 sysmo,oc2g,lc15: Make RadioChannel MO depend on RadioCarrier MO
lower layer specific APIs require first to enable the TRX object
(GsmL1_PrimId_MphInitReq, which requires ARFCN received during Set
Radio Carrier Attributes) before enabling the per-TS structure.
Hence, OPSTART must happen in RCARRIER MO before OPSTART can be sent to
the Radio Channel MOs, otherwise the initialization of the TS objet will
fail and OPSTART for the RadioChannel MO will send back a NACK.
In order to avoid this, we need to keep the RadioChannel MO announced as
"Disabled Dependency" until RCARRIER is OPSTARTed.

Related: OS#5157
Change-Id: I8c6e5ff98c32a3cd5006f5e5ed6875bcabb1d85f
2021-05-17 14:23:30 +02:00
Vadim Yanitskiy 4733b099f5 osmo-bts-trx: implement TRXDv2 protocol support
Change-Id: I3532a6693bb335043ec390049138308991083e66
Related: SYS#4895, OS#4941, OS#4006
2021-05-11 10:55:55 +00:00
Vadim Yanitskiy 05493ca810 [VAMOS] osmo-bts-trx: move {chan,bid} to trx_{dl,ul}_burst_{req,ind}
Historically the logical channel handlers like rx_data_fn() used to accept
quite a lot of arguments.  With the introduction of additional measurement
parameters it has become clear that we need to group the arguments into
structures.  This is why both 'trx_{dl,ul}_burst_{req,ind}' structures
were introduced.

However, both channel type and burst ID were kept untouched, so until
now we had them being passed between the scheduler functions here and
there.  This change is a logical conclusion of the original change
mentioned above.

As a part of this change, the new LOGL1SB() macro is introduced.  It
does accept a pointer to 'trx_{dl,ul}_burst_{req,ind}' and expands the
context information for the old LOGL1S() macro.

Change-Id: Ic5a02b074662b3e429bf18e05a982f3f3e7b7444
2021-05-11 04:00:37 +02:00
Vadim Yanitskiy c74f25bdcc [VAMOS] Merge bts_trx_init() into gsm_bts_trx_alloc()
gsm_bts_trx_alloc() already does initialize some fields of the
allocated 'struct gsm_bts_trx' instance, and having an additional
function for initializing the other fields makes no sense.

Note that I intentionally didn't merge a call to bts_model_trx_init()
into gsm_bts_trx_alloc(), because this would break some assumptions
regarding the order of initialization and cause regressions.

This also allows us to not call bts_model_trx_init() from tests.

Change-Id: I4aefaf47b05a67ec0c4774c1ee7abcc95e04cc13
2021-05-11 03:54:07 +02:00
Vadim Yanitskiy b6d3e2c360 [VAMOS] struct gsm_bts_trx: fix the PHY instance pointer
First of all, there is no reason to use a void pointer because
it's always 'struct phy_instance'.  Also, no need to encapsulate
this pointer into 'role_bts' because there are no other roles in
osmo-bts (we used to have shared headers years ago).

This commit also fixes a bug in test_sysmobts_auto_band(), where a
pointer to 'struct femtol1_hdl' was directly assigned to trx.pinst.

Change-Id: I9bd6f0921e0c6bf824d38485486ad78864cbe17e
2021-05-09 02:05:48 +02:00
Vadim Yanitskiy 0dcaf34927 common/sysinfo: make struct gsm_bts_trx const in num_agch()
Change-Id: I776defc7e9699a378c9a03304c63e15d023476d0
2021-05-08 17:41:02 +02:00
Vadim Yanitskiy 57ebf04171 struct gsm_bts_trx: remove unused leftovers from openbsc
Change-Id: I667fc1d6a5eaccb69b45197da71d4a699f52fcfc
2021-05-06 01:10:16 +02:00
Harald Welte b1b100ce59 Introduce ability to set socket priority of RTP sockets
This significantly simplifies setups in which not only the IP DSCP
but also the IEEE 802.1Q PCP is to be set for RTP packets.

Depends: libosmo-abis.git I52c08f4b2a46981d002ef0c21e6549445d845a6e
Change-Id: Ia3a91e6788285be3e2e73defee63e6bd79c6258e
Related: SYS#5427
2021-04-30 08:23:56 +02:00
Vadim Yanitskiy b619da5e72 osmo-bts-trx: 'burst type' is actually modulation type
Burst type and modulation type are actually different things.

Change-Id: Ic06c96434ad32dd3770b88cb1fefcbefb2fc3928
Related: SYS#4895, OS#4941, OS#4006
2021-04-24 08:47:00 +00:00
Vadim Yanitskiy 32ef94cac0 osmo-bts-trx: cosmetic: TRXD 'header version' -> 'PDU version'
TRXDv2 brings significant changes to the whole PDU structure, not
just the header.  Let's highlight this in the code / strings.

Change-Id: Id0274bd1ae5c419548596ed1852e6a28ec62b713
Related: SYS#4895, OS#4941, OS#4006
2021-04-21 01:26:00 +02:00
Philipp Maier fd5151668c sched_lchan_tchh: fix frame number and fill FACCH gap
The measurement results / TCH indications that are handed when decoding
the TCH/H are off by two bursts. Since a measurement result / TCH block
is expected every two bursts anyway the problem can only be noticed when
a FACCH transmission is going on and the frame numbers of the BFI TCH
blocks appear to be missaligned towards the FACCH block.

The reason is that the incoming bursts are shifted into a 6 burst wide
buffer. The decoding functions always look at the beginning of that
buffer while the bursts are shifted into the buffer from the end. A
facch will always fit exactly in that buffer but TCH/H blocks are only
4 bursts wide and thereofre they need two additional bursts until they
reach the coverage of the decoding function. Lets fix this by putting
the correct frame number (from two bursts before) into the remap
functions in order to get the correct beginning of the block.

Since the FACCH transmission uses six blocks it takes out two TCH
blocks. This means that if we count the FACCH block we end up with a gap
of one TCH voice block. Lets generate a dummy measurement to compensate
the gap. This will also match the behavior of the osmo-bts-sysmo phy.

Change-Id: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91
Related: OS#4799
2021-03-27 18:37:55 +00:00
Philipp Maier 6940d34ee5 l1sap: Store status of SRR in an lchan struct memeber
The MS sets the SRR bit in the L1 SACCH header to request DL-SACCH
repetition from the BTS. At the moment we access the l1_info stored in
tle lchan struct each time we want to check the status of the SRR bit.
However, it is more convinient to do this once at reception and store
the status of the status of the flag in a separate struct member.

Change-Id: Ieddd45d7890343d64db14b9c726f6fa2f25714f6
Related: SYS#5114
2021-03-01 19:47:56 +00:00
Philipp Maier da084794a6 gsm_data: handle l1_info with structs
in struct gsm_lchan and also in other places l1_info is handled in its
binary form. Libosmocore now offers structs to handle l1 info, so lets
use those structs to get rid of all the manual decoding of l1_info.

Depends: libosmocore I23c1890b89d5a0574eb05dace9f64cc59d6f6df7
Change-Id: I5eb516d7849750f3dd174d48c9f07dabf2c80515
2021-02-16 22:28:18 +00:00
Neels Hofmeyr f8f806ff2a GSMTAP: make remote host for Um logging configurable via VTY
So far, the only way to configure GSMTAP Um logging is to use the
cmdline argument '-i'.  Let's deprecate it, and add a VTY command
to allow setting the remote host from configuration file.

The legacy '-i' option, if provided, overrides the configuration
file option, and will also appear in 'write file'.

Change-Id: I17676a21c4e0c9cbc88f2c5c53a39c6c6c473ca1
Tweaked by: Vadim Yanitskiy <vyanitskiy@sysmocom.de>
2021-02-16 17:35:47 +00:00
Vadim Yanitskiy d37041b1ea ta_control: make 'struct bts_ul_meas' parameters const
The only reason why it was not 'const' is that in lchan_new_ul_meas()
we may need to overwrite 'ulm->is_sub'.  This can still be done after
memcpy()ing a new set of samples to the destination buffer.

Change-Id: I0cabf75f8e0bf793c01225a4a8433e994c93f562
Related: OS#5024
2021-02-15 10:58:54 +00:00
Vadim Yanitskiy 6b93f0f366 GSMTAP: move 'struct gsmtap_inst' and masks to 'struct gsm_bts'
Change-Id: I1c5cb8561dfdcbfd1b23ab28cf95aea7a18c7481
2021-02-13 05:15:37 +01:00
Vadim Yanitskiy 58952ac2b4 GSMTAP: move 'gsmtap_sapi_names' from l1sap.c to vty.c
There is no point in having it there, as VTY is the only user.

Change-Id: If919bc1b2d456559ae9ff1ce5dd27d34742ee51c
2021-02-13 04:55:55 +01:00
Vadim Yanitskiy b1485cd590 power_control: implement handling of P_Con_INTERVAL parameter
Change-Id: Ibf9956b2c6d829b38e9fda7d1f29790036219f42
Related: SYS#4918
2021-02-07 23:08:57 +01:00
Philipp Maier 98c7b44f8d pcu_sock: send SI1, SI3 and SI13 via PCUIF
This patch PCUIF extends the SAPI 4 that is used
to transfer SI13 only, so that it can transfer SI1 and SI3 as well.

The system information SI1, SI3 and SI13 is needed by the NACC RIM
application which runs inside osmo-pcu.

Depends: osmo-pcu I5138ab183793e7eee4dc494318d984e9f1f56932
Change-Id: Ib7aeb41e634ad6fcab3766a4667b0267c749436a
Related: SYS#5103
2021-02-03 08:26:25 +00:00
Vadim Yanitskiy ef99e36626 power_control: use more reasonable reduce step size
It makes more sense to use a reduce step size that is smaller than
the increase step size.  This way both MS/BS power control loops
would be able to react quickly of the signal gets weaker, while
the good signal would not trigger radical power reduction.

Change-Id: Ie358fd828a68bfa1d23559197e8df8478fb4535e
Related: SYS#4918
2021-01-08 19:42:22 +01:00
Vadim Yanitskiy e920902e25 power_control: properly track the first initial state
Change-Id: I16e7474b5affbd90855a2e407b305e9dec581dfa
Related: SYS#4918, SYS#4917
2021-01-08 02:30:46 +01:00
Vadim Yanitskiy 834ba05cd2 power_control: generalize measurement pre-processing state
This way EWMA based filtering can also be applied to RxQual.

Change-Id: I439c00b394da670e314f217b3246cc85ce8213c6
Related: SYS#4918, SYS#4917
2021-01-08 02:23:56 +01:00
Vadim Yanitskiy e8f857453d power_control: migrate MS/BS control loops to the new params
In change [1] the new power control structures and default params
were introduced.  In change [2], the existing VTY commands for MS
power control in the BTS were deprecated and changed to use the
new structures as storage.  Finally, in change [3], handling of
the power control parameters on the A-bis/RSL was implemented.

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

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

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

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

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

Change-Id: Ib18f84c40227841d95a36063a6789bf63054fc2e
Related: SYS#4918
2021-01-08 02:05:27 +01:00
Vadim Yanitskiy 5f909b45c5 power_control: check-in new parameters and default values
For the sake of simplicity, the old structures that are still used
by MS/BS power control loops are kept in place.  Migration to the
new structures requires additional changes to the existing power
control logic, so it will be done in the follow-up changes.

The new parameters are integrated as follows:

  + struct gsm_bts - a BTS instance:
  |   Hard-coded default (fall-back) parameters for all transceivers.
  |
  +-+-> struct gsm_bts_trx - a TRX instance (transceiver):
    |     Default parameters for all logical channels inherited from
    |     'struct gsm_bts' at start-up.  May be overwritten by the
    |     BSC using ip.access specific 'Measurement Pre-processing
    |     Defaults' message on the A-bis/RSL interface.
    |
    +---> struct gsm_lchan - a logical channel (e.g. TCH or SDCCH):
            Connection specific parameters inherited from 'struct
            gsm_bts_trx'.  May be overwritten by parameters sent
            by the BSC in CHANnel ACTIVation and other messages.

Change-Id: I6d41eb238aa6d4f5b77596c5477c2ecbe86de2a8
Related: SYS#4918
2021-01-04 21:49:21 +00:00
Harald Welte 129cb51597 sysinfo.c: Fix SI4 GPRS patching which overwrote CBCH IE
In Change-Id I1fd513ea03297918d15d4b28ed454f9b6dd6ebfa we introduced
patching of SI4 to indicate GPRS presence in terms of PCU connection
status.  Unfortauntely this didn't account for optional IEs being
present in SI4, and hence overwrote any CBCH related information
elements, if present.

This in turn meant that since the above-mentioned commit, you could
have either a GPRS-capable, network, or a Cell Broadcast capable one.

Change-Id: I0ee0cf736e2fb74a6759a68101f699b4ec2ef54e
Related: OS#3075
2021-01-03 00:46:16 +01:00
Vadim Yanitskiy 675618b4f8 power_control: make raise/lower step limitation configurable
Change-Id: Ic37742f46f533865043b3dbcf16ea702e1746f98
Related: SYS#4918
2020-12-09 21:39:52 +00:00
Vadim Yanitskiy 36743255cd power_control: clarify units in 'struct lchan_power_ctrl_state'
Change-Id: I934f2d1e1064eed7587bc5693ef981bf449a1b81
Related: SYS#4918
2020-12-06 18:59:07 +01:00
Vadim Yanitskiy 237ec6194b power_control: clarify units in 'struct bts_power_ctrl_params'
Change-Id: Icb059ca1f555397be116a424800e4536883b9106
Related: SYS#4918
2020-12-06 18:59:05 +01:00
Vadim Yanitskiy 0698c58ebe power_control: implement BS (Downlink) Power Control
We already have MS Power Control, which according to 3GPP 45.008
shall be implemented in the MS to minimize the transmit power in
the Uplink direction.  The BS Power Control may optionally be
implemented by the network side for the same purpose.

Using Downlink signal measurements reported by the MS, the BSS
(either BSC, or BTS) may control Downlink attenuation in a way
that the transmit power remains as low as possible, or remains
in a specific range corresponding to good RxLev values on the
MS side.  This change implements autonomous BS Power Control,
that can optionally be enabled by the BSC.

BS Power Control re-uses parts of the MS Power Control code,
so all parameters can be configured in the same way - via the
VTY interface or a configuration file.  This basically means
that features like hysteresis and EWMA based filtering are
also available for BS Power Control.

The only difference is that RxQual values higher than 0 would
trigger the logic to reduce the current attenuation twice.

Note that one of the unit tests ('TC_rxlev_max_min') fails,
as the power step limitations for raising and lowering look
wrong to me, and the related discussion is still ongoing.

Change-Id: I5b509e71d5f668b6b8b2abf8053c27f2a7c78451
Related: SYS#4918
2020-12-06 18:57:43 +01:00
Vadim Yanitskiy 9381576e18 power_control: generalize power control state structure
Change-Id: I8c6ad8d14349e8a05084c2912644c5202f951f52
Related: SYS#4918
2020-12-04 09:27:48 +01:00
Vadim Yanitskiy 369c852022 bts: add Downlink power control parameters
Change-Id: I724f661e9ce5dd75f95fb7b270a89b2e2a73c951
Related: SYS#4918
2020-12-02 13:56:49 +00:00
Vadim Yanitskiy e9b6648761 bts: generalize a struct for UL/DL power control parameters
Change-Id: I504de17fb3c1300c2a3faa6d7d3a9eb1b74b214b
Related: SYS#4918
2020-12-02 13:56:49 +00:00
Vadim Yanitskiy ca9ab523e1 bts: rename MS_UL_PF_ALGO_{NONE,EWMA} to BTS_PF_ALGO_{NONE,EWMA}
Change-Id: I580512eea1d329a4d25ccbd6fc2ab98b083ec51d
Related: SYS#4918
2020-12-02 13:56:49 +00:00
Vadim Yanitskiy af4eec056e struct gsm_bts: move ul_power_{target,hysteresis} to ul_power_ctrl
Change-Id: I3886c7aedf3870536f1750f864cf698302ddf2df
Related: SYS#4918
2020-12-02 13:56:49 +00:00
Philipp Maier 7c87612b42 l1sap: add repeated uplink SACCH
3GPP TS 44.006, section 11 describes a method how the uplink
SACCH transmission can be repeated to increase transmission
reliability.

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

Change-Id: I00806f936b15fbaf6a4e7bbd61f3bec262cdbb28
Related: OS#4794, SYS#5114
2020-11-27 16:02:45 +01:00
Philipp Maier 33dfe2bcec l1sap: add repeated downlink FACCH
3GPP TS 44.006, section 10 describes a method how the downlink
FACCH transmission can be repeated to increase transmission
reliability.

Change-Id: I72f0cf7eaaef9f80fc35e752c90ae0e2d24d0c75
Depends: libosmocore I6dda239e9cd7033297bed1deb5eb1d9f87b8433f
Related: OS#4796 SYS#5114
2020-11-27 16:02:45 +01:00
Neels Hofmeyr f733cf8263 part 1 of: fix SAPIs for handover to match 48.058 4.1.{3,4}
This part adds the common lchan flags to indicate whether DL SACCH
should be activated.

Note that currently, osmo-bsc *always* sends the MS Power IE as well as
the TA IE, also for inter-cell HO, so in the osmoverse, nothing will
change until we also adjust osmo-bsc. See OS#4858.

Change-Id: Ibea973ccadf5d424213f141f97a61395856b76de
2020-11-26 09:22:38 +00:00
Vadim Yanitskiy 5c7b709027 vty: call bts_model_vty_init() from bts_vty_init()
Similar to bts_vty_init(), BTS specific bts_model_vty_init()
requires a pointer to 'struct gsm_bts'.  Not only it's used
as a parent talloc context, but also stored locally, so then
it can be used by some VTY commands.

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

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

[1] Ic356a950da85de02c82e9882a5fbadaaa6929680

Change-Id: Iee7fee6747dd1e7c0af36f9b27326f651ae37aaf
Related: SYS#4937, OS#3036
2020-11-02 18:08:24 +00:00
Vadim Yanitskiy a72a0765a4 main: register VTY commands before handle_options()
Otherwise only those commands that are registered by libosmocore
appear in the generated XML VTY reference - change the order.

Instead of a pointer to 'struct gsm_bts', pass the application's
talloc context, as it's only used for dynamic command allocation.

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

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

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

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

Change-Id: Iab2d17c45c9642860cd2d5d523c1baae24502243
2020-10-20 13:45:57 +00:00
Vadim Yanitskiy fc1976e1a0 scheduler: get rid of useless TRX_CHAN_FLAG_PDCH
Change-Id: I951ec9b02be674936fbd0bf2e75b004813e25197
2020-10-19 15:04:22 +00:00
Vadim Yanitskiy bdea34165b power_control: tolerate small deviations from 'rx-target'
Recently we've introduced EWMA based uplink power filtering, that
should reduce Uplink power oscillations.  However, the power loop
is still quite sensitive to small deviations from the target power
level: even such an insignificant deviation like 2-5 dBm triggers
the loop to increase or decrease the MS power level.  Even if the
EWMA based filtering is enabled with 80% smoothing (alpha = 0.2).

This change introduces a new configuration parameter - 'hysteresis':

  uplink-power-target <-110-0> hysteresis <1-25>

that together with the 'uplink-power-target' defines a range:

  [target - hysteresis .. target + hysteresis]

in which the MS power loop would not trigger any power changes.

This feature is now *enabled* by default, so given that:

  - default 'uplink-power-target' is -75 dBm, and
  - default 'hysteresis' is 3 dBm,

the default target Uplink power range is: -78 dBm ... -72 dBm.

Change-Id: Iacedbd4d69d3d74e2499af5622a07a8af0423da0
Related: SYS#4916
2020-10-19 17:30:33 +07:00
Vadim Yanitskiy 967bca7b9e power_control: implement EWMA based Uplink power filtering
So far the Uplink power control loop did not filter the Uplink RSSI
measurements (reported by the BTS) at all.  The lack of filtering
makes our implementation too quick on the trigger, so in the real
deployments there will be unneeded Tx power oscillations.

In order to reduce this effect, let's implement a very simple EWMA
(also known as Single Pole IIR) filtering that is defined as follows:

  Avg[n] = a * Pwr[n] + (1 - a) * Avg[n - 1]

where parameter 'a' determines how much weight of the latest UL RSSI
measurement result 'Pwr[n]' carries vs the weight of the average
'Avg[n - 1]'.  The value of 'a' is usually a float in range 0 .. 1, so:

  - value 0.5 gives equal weight to both 'Pwr[n]' and 'Avg[n - 1]';
  - value 1.0 means no filtering at all (pass through);
  - value 0.0 makes no sense.

This formula was further optimized with the use of '+=' operator.
The floating point math was also eliminated by scaling everything
up (by 100).  For more details, see:

https://en.wikipedia.org/wiki/Moving_average
https://en.wikipedia.org/wiki/Low-pass_filter#Simple_infinite_impulse_response_filter
https://tomroelandts.com/articles/low-pass-single-pole-iir-filter

The EWMA filtering is now *enabled by default*, but can be disabled
or (re-)configured over the VTY at any time:

  ! Completely disable filtering
  no uplink-power-filtering

  ! Enable EWMA smoothing with the given parameters
  uplink-power-filtering algo ewma beta <1-99>

Note that the VTY command expects 'beta' instead of 'alpha':

  alpha = (100 - beta)

and the value must be in %.  This is done for simplicity:

  1% means lowest smoothing,
  99% means highest smoothing.

Let's say we have EWMA filtering enabled with alpha = 0.4, and get
-98 dBm on the input, while the last output value was -60 dBm.
The new output would be:

  Avg[n] = 0.4 * Pwr[n] + 0.6 * Avg[n - 1]
  Avg[n] = (0.4 * -98) + (0.6 * -60)
  Avg[n] = -75.2 => around -75

Of course, this is not a silver bullet, but better than nothing.

Change-Id: Ib6dcadbf14ef59696c6a546bd323bda92d399f17
Related: SYS#4916
2020-10-15 19:46:11 +07:00
Harald Welte 9a7acc1744 sysinfo: Don't broadcast SI4 GPRS INDICATOR if PCU is disconnected
Depends: libosmocore.git I9d6ed06731ae15fdcef1a1f397d6ac2b7b1ca980
Change-Id: I1fd513ea03297918d15d4b28ed454f9b6dd6ebfa
Related: OS#3075
2020-10-15 11:29:29 +00:00
Vadim Yanitskiy 8d62d66ed5 power_control: clarify argument names of lchan_ms_pwr_ctrl()
Change-Id: I821120bf5c3690f5b4c6b96c879e675b3d271c90
2020-10-15 15:50:43 +07:00
Vadim Yanitskiy 7b239f40cb gsm_data: check in and use enum lchan_rel_act_kind
Change-Id: If7a7e90dda77a1989420e329c5d60805b28360c7
2020-10-15 15:20:10 +07:00
Pau Espin ca5d1e6ba6 Drop unused param in oml_init()
Change-Id: I96d8359f4ae13c9f47cc87d87fde6d2047169a49
2020-10-13 08:54:36 +00:00
Philipp Maier 05549ae252 vty: add attributes to VTY commands indicating when they apply
Change-Id: Ifcdfcd157e5067fa2e4296d7c7e93a74087f49ff
Related: SYS#4937, OS#1601
2020-10-08 07:16:55 +00:00
Alexander Couzens 650a0c31a7 Introduce the new OML NM_ATT_OSMO_NS_LINK_CFG to configure IPv6 NSVC for PCU
With PCU interface version 10 it supports IPv6 NSVC. The new OML IE
NM_ATT_OSMO_NS_LINK_CFG allows to configure IPv6 NSVC.

Change-Id: I310699fabbfec4255f0474f31717f215c1201eca
2020-10-06 11:36:45 +00:00
Harald Welte 90e0c205b5 bts: Add VTY command to manually override Radio Link Timeout
There are some situations where it is useful to be able to change the
Radio Link Timeout at runtime, without restarting the BTS.

This adds a new (hidden) command for this:
	"bts <0-255> radio-link-timeout (oml|infinite|<4-64>)"

Change-Id: I64674a432cf7751b16d5d0b52f66766fa6e37028
2020-10-05 18:23:06 +02:00
Philipp Maier c41b94e93b osmo-bts-trx/scheduler: fix measurement handling for SUB frames
Make sure that we pick the correct UL measurements from the
history when we deal with AMR SID frames (SUB frames).

Change-Id: I902bb47d68742d2589156f61099b67a0edbaf40b
Related: OS#2978
2020-10-03 07:05:25 +00:00
Pau Espin b62612fbde gsm_data.h: Drop unused struct field
Probably a leftover from openbsc times.

Change-Id: I0b62c41bcb992df376668c6feb6ac7ada35d471d
2020-10-01 14:47:24 +00:00
Vadim Yanitskiy 64bd96b3f8 vty: make most struct pointers const in show/write commands
Change-Id: Iacc32f7982c150d84ea4df7affa1f9e07806928f
2020-09-28 11:39:04 +07:00
Vadim Yanitskiy 4785fe7622 tx_power: make trx/lchan struct pointers const where possible
Change-Id: I1b290af115730ba16f4f9887fe316e2ed15659a2
2020-09-28 11:39:04 +07:00
Vadim Yanitskiy 0c7e9354fe bts: cosmetic: make param 'net' of gsm_bts_num() const
Change-Id: I378fea4aefb2cc4253cdd99ebc9c4f01b21faf95
2020-09-25 09:24:17 +07:00
Vadim Yanitskiy 4ded469b0f osmo-bts-trx/scheduler: refactor UL burst measurement processing
Currently the UL measurements (RSSI, ToA256, C/I) of the burst that
concludes a block are passed up to the higher layers. This means
that the measurement values of the other bursts are skipped.

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

Change-Id: I2b02b51fea5664f161382a4ddc63dbf14ffc9ac5
Related: OS#3032, OS#2978
2020-09-22 19:34:02 +00:00
Alexander Couzens 27c5fd9369 pcuif_proto: version 10: add support for IPv6 NSVCs
Introduce a address_type in the NSVC configuration pass the given
protocol.  The remote_ip is network byte order, the default
encoding for in_addr and in6_addr.

Change-Id: I6d60277eb5b8d938d9f38114c933d58ee1b884c9
Related: Iae854875a45dbc29cd46a267ccaf60f1f2ac2973
Related: SYS#4915
2020-09-22 00:05:02 +07:00
Vadim Yanitskiy 2302cb162c pcuif_proto: version 10: add frequency hopping parameters
Change-Id: I04782222b499d0488269544910fbd4ed9929c05d
Related: Idf11bc4ba3ff0b00b32f2beab8fd020c67119d05
Related: SYS#4868, OS#4546, OS#4547
2020-09-22 00:05:02 +07:00
Vadim Yanitskiy 0cd8df2184 gsm_data: rename hopping.{ma,ma_len} to hopping.arfcn_{list,num}
MA (Mobile Allocation) is actually a bit-mask indicating those ARFCNs
of the Cell Allocation, which must be used as the hopping sequence.

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

Change-Id: I677d66e428fa0fe119ebc37bc2a4e6cc05c251c4
2020-09-17 15:45:48 +00:00
Vadim Yanitskiy 9b6000c6fa struct gsm_bts_trx[_ts]: remove unused parsed NM attribute list
This list is already a part of struct gsm_abis_mo.

Change-Id: I19b907bea500569c6e7e1b64b50e1c2ee2014f1c
2020-09-17 15:45:48 +00:00
Vadim Yanitskiy 86c8d2f81c struct gsm_bts_trx: remove unused per-TRX OML Link pointer
Most likely, this part of the structure was copy-pasted from the
corresponding definition in osmo-bsc.  In osmo-bts we always
establish a single per-BTS OML link, not per-TRX.

Change-Id: I1792372de484608e04211c9de4294b3c76173ead
2020-09-17 15:45:48 +00:00
Alexander Couzens f1222fc724 Revert "pcuif_proto: version 0xa: add support for IPv6 NSVCs"
This reverts commit df93a448b7.
It was to early because the frequency hopping wasn't ready to be merged.

Change-Id: I6e67f4cd9828afa53ed4e783b83b039ee6a1d570
2020-09-16 03:24:18 +02:00
Alexander Couzens 9ad00d1c28 pcuif_proto: fix typo in comment
Change-Id: Iec7c41741ed093df8c60a3cda548662492f56116
2020-09-15 23:38:14 +00:00
Alexander Couzens df93a448b7 pcuif_proto: version 0xa: add support for IPv6 NSVCs
Introduce a address_type in the NSVC configuration pass the given
protocol.
The remote_ip is network byte order, the default encoding for in_addr and in6_addr.

Change-Id: I4067b1af041b2cdad60d6fb16c9caee98bc218dd
2020-09-15 23:37:55 +00:00
Pau Espin 2ff4592ffc Fix RadioCarrier OML Operative State Change report not sent on some scenarios
Operative state is mainly maintained based on 2 requirements:
* phy_link being in CONNECTED state
* RSL connection being up and ready

However, state change report triggered over OMl towards BSC was only
done upon the first event of the two. That means that if for whatever
reason the RSL connection was established AFTER the phy_link became
CONNECTED (ie receiving RSP POWERON in osmo-bts-trx), then the status
towards the BSC would not be updated and hence the BSC would still see
the Radio Carrier object as DISABLED.

The trx_set_available() function is renamed to trx_operability_update()
to keep the logic conditions in one place, and different events
triggering a change in state simply call the function and let it handle
the new state.

Related: SYS#5063
Change-Id: Ic00df9e7278d42bc10c1e1a1c0edde7e13199299
2020-09-15 14:03:29 +02:00
Pau Espin 81251bdbe8 scheduler: Drop unused function trx_sched_reset()
Change-Id: Id31e82b6bbfdd8030612c78737c0aa7dd7e20bd0
2020-09-07 10:23:25 +02: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 cf3635fbaa osmo-bts-trx/scheduler: implement baseband frequency hopping
The idea behind the baseband frequency hopping is quite simple: we
have several RF carriers (transceivers) transmitting and receiving
on fixed frequencies (just like in a regular multi-trx setup), and
an additional burst routing layer between the schedulear and the
transceiver interface (TRXD over UDP).

Speaking in terms of the proposed implementation:

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

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

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

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

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

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

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

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

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

Change-Id: I8c3651c27d2991079e83b8abdb7e2c3f95b97a43
Related: SYS#4868, OS#4546
2020-08-04 10:16:36 +00:00
Vadim Yanitskiy 60e2919ff4 common: constify the argument of trx_ms_pwr_ctrl_is_osmo()
Change-Id: Ic7be19ed1560eae0a56ed30520ee9af1e949d71d
2020-08-03 02:08:14 +07: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
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
Vadim Yanitskiy 4dfd43bb51 osmo-bts-trx/scheduler: get rid of unused 'meas' in l1sched_chan_state
Change-Id: I4337cfdc393ec44df9bb9824ba4981eaf5b45f0b
2020-06-30 06:10:57 +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
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 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 a08685a576 Fix shutdown in osmo-bts-{omldummy,virtual}
Change-Id: Idadb62ec25181b140d9061dc7470da00d47d8336
2020-06-25 14:12:34 +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 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 c08d927085 phy_link.h: Drop unimplemented function definition
Change-Id: Ib306a80bd8ea3434a49806ec73a1cfe9a82b9122
2020-06-22 13:17:53 +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 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 600ab79e7d cosmetic: include/osmo-bts/Makefile.am: split each header file in one line
Change-Id: I58d86a8c2e8846f683d4414fcd2a3bf7f89049ce
2020-06-17 17:27:24 +02: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 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
Pau Espin adf5d3aed2 bts-trx: Implement power ramping during BTS bring up
The nominal transmit power is still only configurable manually from
osmo-bts-trx VTY interface. Support to retrieve the nominal power
from osmo-trx will come later.

Change-Id: Ia7c353e4c199e0fc3bcab55c45a4abda2c66d2c1
2020-06-12 09:59:56 +00:00
Vadim Yanitskiy 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 4977e135c8 common/scheduler: use boolean for channel activation state
Change-Id: I0cb1d915db8787050cdec1802894f66e885a9bf3
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 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 759a12e8aa scheduler: drop non-existing extern declarations
Change-Id: Ifa6fc5947e8fb7ec071a6567c275f5db5ab385f9
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 24454fc2f8 gsm_data_shared: drop unused ctrl_ack_type_use_block & net_ctrl_ord
Change-Id: I7c8ddc4a9cfbbd1983e89fa261eaf4f32e15c6bd
2020-06-05 18:38:38 +07:00
Vadim Yanitskiy 0d25f9c94c gsm_data_shared: drop unused dtxu from struct gsm_bts
Change-Id: Ic2ddbf04bac7ced900a4e5e532206652dae64059
2020-06-05 18:38:38 +07:00
Vadim Yanitskiy 79ad26cabf gsm_data_shared: drop unused *nmh from struct gsm_bts
Change-Id: I57e9146cfc3274847b50caa44b09b5f06f0cf00b
2020-06-05 18:38:38 +07:00
Vadim Yanitskiy d7fa003686 gsm_data_shared: drop forward declaration of struct vty
Change-Id: I12b178d73e19761d16a6ef8e2a16243a23e1bf04
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 c966253aad gsm_data_shared: drop meaningless comments
Change-Id: I8bf88249ef88c283df16fd21a0ad5613801a826f
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy a44a8f469e gsm_data_shared: drop unused struct bts_codec_conf
Change-Id: Ic7187eeb252b327a4d8d1d593758587007d8b891
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy f106db2e37 gsm_data_shared: drop unused LCHAN_SAPI_{UNUSED,MS,NET,REL}
Change-Id: I431844fa69245fca43b1acdaf91229a172878db0
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy 936ed22bd9 gsm_data_shared: drop unused MAX_EARFCN_LIST
Change-Id: I8927ee178fe204c3598d574391e1cabfe5d6334a
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy 308d252795 gsm_data_shared: drop unused A38_XOR_{MIN,MAX,COMP128}_KEY_LEN
Change-Id: If4802d30f7c40a359c4d130a754dd762181f122e
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy 4fa3598639 gsm_data_shared: drop declaration of non-existing gsm_parse_reg()
Change-Id: I2a53ec4b599a7845e49d484f4cd061d7e67c3a28
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy 36e2b55a9e gsm_data_shared: get rid of unused enum gsm_hooks
Change-Id: Ib35fc7772babd3bf09dedf1a44e16a07bcc089f0
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy f53e4aafc7 gsm_data_shared: get rid of unused HARDCODED_BTS{0,1,2}_TS
Change-Id: I8f91681d9102f9a2ab09e75c4f8b44c37dd8c0d4
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy 5ad8db2a19 gsm_data_shared: get rid of unused HARDCODED_{ARFCN,BSIC}
Change-Id: I7e7298bc661d3d3160f03c32d36e98484c8aa79c
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 5de50a598b gsm_data_shared: drop unused enum bts_gprs_mode
Change-Id: Ied91acd3ae480c2e7c85f8d5436babf5a8329a04
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy 53a9c98737 gsm_data_shared: drop unused supports_egprs_11bit_rach
Change-Id: I5fa3aa1cb384f72a9deb3715ba78c199307dd6ec
2020-06-05 02:14:48 +07:00
Vadim Yanitskiy 633de1fb88 vty: get rid of unused ournode_{exit,end}_cmd declarations
Change-Id: Id6fde5976d31dff4cee72473c597638b3c08dbb2
2020-06-04 23:53:04 +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
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 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 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 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
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 d4f67591c7 l1sap: merge MEAS IND into PRIM PH DATA / PRIM TCH
The MPH INFO MEAS IND indication, which contains the uplink measurement
data is sent in parallel to the PH DATA and TCH indications as a
separate indications. This makes the overall uplink measurement data
processing unnecessarly complex. So lets put the data that is relevant
for measurement into the PH DATA and TCH indications directly.

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

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

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

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

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

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

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

Related: OS#1851
Change-Id: I0d8b0c981d9ead91d93999df6e45fb06e426aeb9
2019-11-30 18:50:04 +00:00
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 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 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 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 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