Commit Graph

2472 Commits

Author SHA1 Message Date
Pau Espin bc6d35f52d abis: Fix line leaked & recreated upon every reconnect
Previous code creating a new line was really a workaroudn to have it
working while previous lines were being stacked internally inside
libosmo-abis.
Let's handle reference counts for the line properly and erase +
re-create it every time.
Recent patches to libosmo-abis fixed a crash happening when refcount
being 0 and destroying the object (object was not removed from a global
llist).

Depends: libosmo-abis Change-Id I1314d6b917ecb622994507475eb894e649a1a2ad
Change-Id: Ic37ae5bf657247e8cce99182c40d9adf890a5e41
2021-09-23 14:07:53 +02:00
Pau Espin 127e8fc416 abis: Fix memory leak of bts->osmo_link upon link going down
Commit below (see "Fixes" section) wrongly erased the code re-introduced
in this commit, due to not spotting different between "oml_link" and
"osmo_link". This commit is hence a revert of such commit, updated to
current code.

Fixes: c2ba34d9c1
Change-Id: Id436116e5cd0bec024b2f9943fbff8d0bdc956ac
2021-09-23 14:07:53 +02:00
Pau Espin 2e90e0f756 Avoid sending Load Indications when BTS is not RSL-connected
Change-Id: I97e8dd7dd58ee2ec90c3a38d45dfd944db44c412
2021-09-23 14:07:53 +02:00
Pau Espin 130e2e59c6 bts_trx: Drop non-executed path in trx_link_estab()
This function is only called during sign_link_up() e1inp callback, hence
only the link!=NULL condition (UP) is ever executed. Let's drop the DOWN
path and make it a function only used to trigger events when link
becomes up, similar to what bts_link_estab() does with OML.

Here it becomes clear the NM_EV_RSL_DOWN was never sent. It's not much
of an issue though since it would only make transition RCARRIER/BBTRANSC
Enabled->DisabledOffline. However, since due to libosmo-abis limitation
we receive a sign_link_down() for the entire line when 1 of its links
goes down, we don't care much since we go for shutdown of the entire BTS
anyway. Ideally, libosmo-abis would support simply telling us 1 of the
links in the line went down and if it was not OML and not RSL TRX==C0,
then we could keep on running and simply disable the related TRX.

Change-Id: Iac553c68339c0da32fd313676995747eb4344087
2021-09-23 12:07:29 +00:00
Pau Espin 49979bb794 abis: Call bts_model_abis_close() when Abis link goes down
This way based on BTS model features it can attempt to reconnect or
simply exit the process.

Change-Id: I42b43a0128bd4b579d9695e6dd2bccf6dc7e1d41
2021-09-23 12:07:29 +00:00
Pau Espin 37f63f12f7 bts_shutdown_fsm: Allow configuring FSM to shutdown without exiting process
This feature is not yet used by any bts_shutdown_fsm caller, but will be
used in the future when Abis link goes down.

Change-Id: I5dc282fdbcf862067be326e72b6183dd544222ae
2021-09-23 12:07:29 +00:00
Pau Espin 4ddc37ce71 nm_bts_fsm: Make sure PHYs are opened when SW_ACTivating it
Since recently we support shutting down phys when BTS goes into shutdown
mode. Let's make sure they are opened again when we connect again to the
BSC.

Change-Id: Ia1df6f4a1e0e6daeffe7303d518776a04b023930
2021-09-23 12:07:29 +00:00
Pau Espin dfedf2cb76 phy_link: Introduce bts_model_phy_link_close() and use it in bts-trx
This step is required while turning off the BTS without killing the
process. Right now only osmo-bts-trx supports this feature, so this
function is only available and used by osmo-bts-trx.
Later on, when the feature is support more generally, we can move call
to this function to common place like bts_shutdown_fsm or alike.

Change-Id: I3253112700a31b85db82dc7ccadec8542bac745e
2021-09-23 12:07:29 +00:00
Pau Espin 192390c797 trx_sched_clean_ts: Clean VAMOS shadow TS too
trx_sched_init_ts does it properly, but apparently it was forgotten to
do the same upon clean up.

Change-Id: Ice751870a46548af42b14846b8482335f636a84a
2021-09-23 11:09:15 +00:00
Pau Espin ce9ec4963c bts-trx: Submit TRX SW_ACT when PHY becomes connected
Once the TRXC link is available, we can signal SW_ACT which will
transit rcarrier and bbtransc NM FSMs to Disabled Offline and announce
availability to be configured to the BSC through transmission of
Software Activated Report.

Change-Id: I6e62ec2fdd4cae58b52d83fa851552f7ed51c821
2021-09-23 11:09:15 +00:00
Pau Espin ddd357f3e3 bts-trx: Avoid race condition configuring TS-specific TSC values
In OML, if Set Attributes comes first for Channel object and then for
BTS object, BSIC will still not be set. Hence, when applying Channel
(TS) specific TSC, the code would compare against an unset value,
enabling use of TRXC extensions (which osmo-trx doesn't support)
without need for it, since actually the TSC of the TS matches the BSIC
of the BTS once both are set.

In order to fix it, don't check for the BSIC when receiving the OML
messages, but rather later when we apply the settings to the the lower
layers once trx_provision_fsm allows for it.

Fixes: 3c1151f945
Change-Id: I49fc7e35acb44ecc4f37ae71acd4c684248548e7
2021-09-23 11:09:15 +00:00
Pau Espin 300e31ed13 l1sap: Support rx of empty rlcmac blocks from PCU
This way the PCU can signal idle RLCMAC blocks (no transmission
required) to the BTS, which can then send dummy/fill blocks aplying
power reduction as needed by TRX.

The block with len=0 is submitted to lower layers up to the scheduler,
which will finally drop it in trx_sched_ph_data_req().

Change-Id: I734c66e236bf3e2015a4571ea1fd84849a9ef02c
Related: SYS#4919
2021-09-23 10:03:23 +00:00
Pau Espin 2f3cd4b697 MS Power Control Loop: Disable threshold comparison on {LOWER,UPPER}_CMP_N=0
This way we provide an effective way to disable C/I based decision
taking in the MS Power Control Loop. With this set up, MS Power Level is
decided only based on RxLev. This allows for working setup in following
scenarios:
* BTS L1 not passing proper C/I values to upper layers (eg. TRXDv0).
* User not willing to spend time configuring proper C/I levels for each
  channel type.

Related: SYS#4917
Change-Id: Ibd10eb96a5d072d5c19f7449a8b11e64aad1cd4c
2021-09-23 10:02:59 +00:00
Pau Espin 137166fd5f bts-trx: Get rid of check_transceiver_availability_trx()
Get rid of this helper function, which is a remain of past epochs
(pre-FSM). In the current uses, there's only 2 real cases: the "if" path
upon SET BTS ATTR received (and even that one should be moved as per
what the code comment states), and the one happening when the TRX is
closed.

it really makes no sense to DISABLE the TRX as a result of SET BTS ATTR.

Change-Id: I48adfeecd722684152c589bcba827079b0a78c3a
2021-09-23 10:00:24 +00:00
Pau Espin 7c466d8cc7 bts-trx: Submit TRX_PROV_EV_CFG_ARFCN for C0 during SetBtsAttr
In oml_rx_set_bts_attr, arfcn for C0 is assigned from NM_ATT_BCCH_ARFCN.
The rest of the TRX get their arfcn from oml_rx_set_radio_attr()
NM_ATT_ARFCN_LIST.

Change-Id: I8aa9652622107fe0a707b2cbcbe8be6c71e19087
2021-09-23 10:00:24 +00:00
Pau Espin 32b51eca7d trx_provision_fsm: Properly reset FSM state upon starting listening for events
Change-Id: If0d078bc0170091efbca351c44ee412dad1e944a
2021-09-23 10:00:24 +00:00
Pau Espin eab7068d58 trx_if: delete retrans timer when flushing the Tx queue
Change-Id: Ic31dc5629ed950f3b4b8feb9917d11779696f6eb
2021-09-23 10:00:24 +00:00
Pau Espin 4444262a6a trx_if: Allow calling trx_if_flush/close from within TRXC callback
Change-Id: Ic3baa95ffe4e6ca95c6d02276ea8eb0cb9fa0064
2021-09-23 09:59:29 +00:00
Philipp Maier 3bf40e4f3a rsl: simplfy parse_repeated_acch_capability
The separate TLVP_PRESENT and TLVP_LEN calls can be replaced by
a single TLVP_PRES_LEN

Change-Id: I6bde1b9df50fdf355e768f5066e86422238b98e9
2021-09-23 08:21:57 +00:00
Pau Espin 03c74baa83 trx_if: Set pointer to null after freeing it
Change-Id: Icd93c9968095a8801aafe9440806cb5786320cbc
2021-09-22 12:57:02 +02:00
Pau Espin 3c56335094 bts_shutdown_fsm: Fix event name
Change-Id: Id042ae37f7c9dbd2edbb76932abb91d605d85e26
2021-09-22 12:57:02 +02:00
Pau Espin 68a39a8617 nm_*fsm: Make FSMs aware of object being properly configured or not
This will allow in the future advertising children objects that the
parent object has been configured. It is useful for instance to let TRX
know that the BTS is configured.

Change-Id: Ie319465fd0e991bab8451ea34ec72ff3702533d2
2021-09-22 12:56:58 +02:00
Pau Espin 5a2d8716ef abis: Drop internal OML msg queue
There's no real use for this queue. If the link is gone, it makes no
sense to keep old messages. Instead, BTS should generate new messages
sharing current state when link becomes established (it actually does
so already).

Change-Id: Iecd3c7cb96f5fff3b4c7e04c74e031df0f7a6987
2021-09-20 16:25:47 +02:00
Pau Espin 92186c672d nm_*_fsm: Move to state Disabled NotInstalled Locked when shtudown proc ends
Change-Id: I5c070adbba6b4abb19467a02d6449a443657ae2b
2021-09-20 16:25:47 +02:00
Pau Espin c56d120b29 MS Power Control Loop: Fix oscillations within good MS Power Levels
Related: SYS#4917
Change-Id: Ib33a94eba92004f9327c91e020a506dfa9a957c3
2021-09-20 14:57:15 +02:00
Pau Espin 43a4a1d5e7 nm_*_fsm: Set adminsitrative state 'shutting down' when shutdown procedure starts
Change-Id: I0d14840a55642812b865687a6cb208e7ffd22829
2021-09-20 12:22:53 +02:00
Pau Espin ea53ad454e Allow setting administrative state through oml_mo_state_chg()
This way it can be changed together with operative/availability state,
and changes announced to the BSC if present.

This commit presents no real change in osmo-bts behavior, since the only
place where adm_state is passed different than -1 is in
st_op_disabled_notinstalled_on_enter(), which is actually never called
(yet) since it's the initial state and no other states transition later
to it.

However, this will change in the future once we support re-connecting to
a (possibly different) BSC, which means objects will need to be moved to
that state to restart the whole OML install procedure on the new BSC.

Change-Id: Ifdc6a1dfb673c0ab915ddf2a9d372928f4f86b4c
2021-09-20 12:22:53 +02:00
Pau Espin 729aff7938 nm_*_fsm: Add missing item in event mask list for state ENABLED
Change-Id: Iebaa7dcfc01978cee2e4b08609503eb4e25598b7
2021-09-20 12:22:53 +02:00
Pau Espin 82275d5eb2 trx_provision_fsm: Add missing state transition OPEN_WAIT_POWEROFF_CNF => OPEN_POWEROFF
Change-Id: I361c1acddfe7ebffb44d886d0545240ef1bbd347
2021-09-20 12:22:53 +02:00
Pau Espin 8dd699e545 abis.c: Loop over list of BSCs until connection succeeds
Do not exit if all BSCs in the list fail to connect, keep trying
forever. This commit still doesn't change the logic after BTS has
successfully connected to a BSC. In that situation, if the link goes
down, BTS will exit in order to reset all state and let the user/system
restart it.

Related: SYS#4971
Change-Id: I67bba3b7e2d9d62b98a59a74987ae55206a3ec51
2021-09-20 12:22:53 +02:00
Pau Espin 3f7bd192a6 abis.c: Fix mess with priv->bsc_oml_host
The pointer was used as "struct bsc_oml_host" sometimes, and other times
as "struct llist_head". It just worked because bsc_oml_host->list is the
first item in the script. The code was really confusing, also because
the bts list of items has a name really similar to the one currently
assigned. Let's rename the currently assigned address to "current_bsc",
store it always as "struct bsc_oml_host*" and finally use llist_entry
helpers when needed.

The related code is also moved to a helper function to enclose there the
logic to get next BSC in list. This change actually changes the logic
where a remote address is removed from VTY, since now the next address
in list is picked at the time, and later when reconnecting the list is
forwarded another time, meaning one address will be skipped.
This could be considered a bug, but this situation is really special
and anyway the entire logic will be changed in new commits where we'll
keep reconnecting in loop without exiting when reaching the end of the
list, so we are fine with it. Think of this commit as a preparation
commit for next ones.

Change-Id: I3cc8a4148b3d63bc185b72dab8108105a6644910
2021-09-20 12:22:53 +02:00
Pau Espin 65c0341f3d abis.c: Transition to CONNECTED state only when OML link is up
This clarifies the different states and transitions between them:
OML LINK UP: CONNECTING->CONNECTED
ANY LINK DOWN: CONNECTING->CONNECTING, CONNECTED->FAILED
In follow up commits, support to reconnect instead of exit after the BTS
has already connected will be added, so only the last transition needs
to be changed.

Related: SYS#4971
Change-Id: I43e83b1b04fbaa1f87818c096e6ad3920801b1f6
2021-09-20 12:22:53 +02:00
Pau Espin 79a92cfc50 abis: Shorten string names of events
Change-Id: I7a5dab3d38e917a8f37c72765e27f263c324ed96
2021-09-20 12:22:53 +02:00
Pau Espin 5831512c2c abis: Move FSM registration to constructor function
We commonly do it this way since there's only need to call it once at
the startup of the program.

Change-Id: I6ee5b89175ee32bc12a8afc9682a8f90d1713291
2021-09-20 12:22:53 +02:00
Pau Espin a09c9a8c32 cosmetic: Fix formatting of conditional operator
Change-Id: Ib0da405d1d9ed30bea97b433b7cf07b1084348ef
2021-09-20 12:20:14 +02:00
Pau Espin 41fe4089a8 power_control: Drop unused param in function
Change-Id: I6c0c2b983e153b06b84664565bd485e748a8af7d
2021-09-16 13:02:11 +02:00
Pau Espin 3f51571a2f abis.c: Convert early return to assert()
This should simply not happen. If other event is received, something is
terribly wrong, so we should exit immediately instead of silently
failing.

Change-Id: I5f4953be735f526bb8b926979233b3c26ba67ce9
2021-09-15 16:17:37 +02:00
Pau Espin daadbc33aa abis.c: Rearrange code to follow logic state order
CONNECTING state comes first in logical order of states (as properly
seen in enum of states), however, the FSM struct definition and state
action functions are swapped. Let's put them in order.

Change-Id: I0cae561926b460dc5882390db969b7c925903e5d
2021-09-15 16:17:37 +02:00
Pau Espin a17043f2b4 cosmetic: fix typo in comment
Change-Id: I0e4fdad66c0bad849a7b960cf78f9f45b56fcb95
2021-09-15 16:17:37 +02:00
Pau Espin c2ba34d9c1 abis: Clear code and drop code not executed
abis_init() sets "g_bts = bts;", hence bts object is the same as g_bts
(since we only have 1 BTS object in osmo-bts). As a result, dropping
checking first bts->... and later g_bts->... makes no sense: the later
condition will always be false.

Change-Id: I5018199221fb3c3329a59d0b91e827f077cef85d
2021-09-15 16:17:37 +02:00
Pau Espin e1dbc616b0 MS Power Control Loop: Fix sub vs full being passed to algo
Fixes: c80abd109b
Change-Id: Ib66ac938e3e71409848927a2972f1f77b9bacde2
2021-09-15 14:30:13 +02:00
Pau Espin c81b41c62e Support configuring TA loop SACCH block rate
Similar to what is already provided for power control loops. However,
there's no existing way to communicate TA control parameters from the
BSC to the BTS, so implement them locally in BTS vty.

Related: SYS#5371
Change-Id: I9fa71f836bb9a79b0ef2567bfcfdf38ff217840b
2021-09-14 11:42:58 +02:00
Pau Espin c85027a510 Power Control Loop: Set P_CON_INTERVAL to 1 by default
TS 45.008 section 4.7.1:
"""
Upon receipt of a command from an SACCH to change its power level on the corresponding uplink channel, the MS
shall change to the new level at a rate of one nominal 2 dB power control step every 60 ms (13 TDMA frames), i.e. a
range change of 15 steps should take about 900 ms. The change shall commence at the first TDMA frame belonging to
the next reporting period (as specified in subclause 8.4). The MS shall change the power one nominal 2 dB step at a
time, at a rate of one step every 60 ms following the initial change, irrespective of whether actual transmission takes
place or not.
"""

Since the reported MS_PWR in L1 SACCH Header is, according to specs, the
one used for the last block of the previous SACCH period, it becomes
clear the first SACCH block after a requested MS Power Level change by
the network may contain mismatches between the announced MS_PWR by the
MS and the measured Rxlev/RxQual. Hence, let's better use a
P_CON_INTERVAL of 1 which retriggers the MS Power Control Loop every second
SACCH block.

Change-Id: If6cb8945645a2031f2b2ee65d9b9f51e75cd9af1
Related: SYS#5371
2021-09-14 11:42:58 +02:00
Pau Espin 132b67a7a0 TA Control Loop: Change toa256 switch threshold to 75% of a symbol
As per 3GPP TS 45.010 sec 5.6.3 Delay assessment error:
"""
the delay shall be assessed in such a way that the assessment error
(due to  noise and interference) is less than 1/2 normal symbol periods
for stationary MS. For MS moving at a speed up to 500  km/h the additional
error shall be less than 1/4 normal symbol period.
"""

Hence, required TA loop calculation should take into account an error of
up to 1/2 + 1/4 = 75% of a symbol. By changing the threshold variable
to that percentage we make sure we take into account bigger deviations
and update TA accordingly.

Related: SYS#5371
Change-Id: I4c5825df4291d3851a113027abf7566de343a190
2021-09-14 11:42:44 +02:00
Pau Espin c80abd109b MS Power Control Loop: Feed UL C/I from correct measurement period
As per 3GPP TS 45.008 sec 4.2, the ms_pwr received in L1 SACCH Header is
the value used over previous measurement period. Hence, we need to feed
the algo with the measurements taken over that same period.

Related: SYS#4917
Change-Id: I13c0014fdd73f823ae5b1256c35bfa7d97cfa334
2021-09-13 17:52:24 +02:00
Pau Espin 8d21891959 MS Power Control Loop: Feed UL RSSI from correct measurement period
As per 3GPP TS 45.008 sec 4.2, the ms_pwr received in L1 SACCH Header is
the value used over previous measurement period. Hence, we need to feed
the algo with the measurements taken over that same period.

Related: SYS#4917
Change-Id: I00852cb37a3613606e37476c169f5a32d6b5d75e
2021-09-13 17:52:24 +02:00
Pau Espin 22a160bd24 lchan: Move TA CTRL param to its own substruct
Field is renamed to look similar to similar fields in power control
loop. This is a preparation commit, next one will add functionality to
skip SACCH blocksi (P_CON_INTERVAL).

Related: SYS#5371
Change-Id: I169ce58ab827e38b64f4b15f935097a9118fa118
2021-09-13 12:53:44 +02:00
Pau Espin f54a7462dd ta_control: Allow switching TA quicker
From TS 45.010 5.6.1 (delay tracking for circuit switched channels):
"""
Restricting the change in timing advance to 1 symbol period at a time
gives the simplest implementation of the BTS.  However the BTS may use
a larger change than this but great care must then be used in the BTS design.
"""

In general 1 TA at a time (every 480ms of SACCH block) should be enough,
since section 5.6.3 states:
"""
The control loop for the timing advance shall be implemented in such a way that it will cope with MSs moving at a
speed up to 500 km/h
"""
Which is ~140 m/s, and 1 TA step around 500m, so most of the time we
should be save and no steps of more than 1 TA should be required.
However, unlikely changes from reflected to direct signal or vice versa
could produce higher increments, so let's increase the maximum step size
allowed to 2 in order to give more room.

Change-Id: I9e48faabf3090588233e274b2b39065cf85fbec7
2021-09-13 12:53:22 +02:00
Pau Espin f21b9231dd TA loop: Take into account UL SACCH 'Actual Timing advance' field
First step improving and reworking TA loop:
Move trigger of the loop to similar place done by BS/MS Power Control
Loop, that is, upon receivial of UL SACCH block, which contains
information about the TA used to transmit the block encode in L1SACCH
Header. Hence, from computed received TOA and TA used when transmitting
from the MS, we can infer the desired TA to be used by the MS, which
will send back to it later during DL SACCH block.

The values taken are actually the ones calculated for the previous SACCH
block and stored in lchan->meas.ms_toa256. That's because L1SACCH
contains the TA used for the previous reporting period, similarly to
what's specified for MS Power Control loop (TS 45.008 sec 4.2):
"""
The MS shall confirm the power control level that it is currently employing
in the SACCH L1 header on each uplink  channel. The indicated value shall
be the power control level actually used by the mobile for the last burst
of the  previous SACCH period.
"""
(The reader may observe that currently this is not properly done for MS
Power Control loop when calling lchan_ms_pwr_ctrl(): this is a bug.)

This new method also permits changing TA quicker, since we have more
confidence that the TA we request is aligned with the one used to
transmit, and we don't simply increment/decrement based on the value we
request to transmit.

Related: SYS#5371
Change-Id: I2d0f128c8dcac93ee382283a1c91fca76623b8fc
2021-09-13 12:25:32 +02:00
Neels Hofmeyr 494b251109 early IA: change default X15 timer to 0 ms
Tests have shown that even a delay of 0, i.e. a simple defer until the
next select() loop, makes the difference from failing to working early
IA. So set the default to 0, achieving such defer.

Related: SYS#5559
Change-Id: I95365649edd51114bcf6028f0dc3bbe4186f96d2
2021-09-11 13:10:33 +00:00
Neels Hofmeyr da7c56ab8e early IMM ASS: add configurable delay for RR IMM ASS
During live testing, it has become apparent that some IMM ASS still fail
when sending the RR IMM ASS directly upon the target channel becoming
active.

Add a bit of delay after activation, to give some time for the channel
to light up for the MS. Default is 50ms.

Related: OS#5559
Change-Id: Ia1e63b98944dc840cde212fc732e20277cdc5585
2021-09-11 13:10:33 +00:00
Pau Espin 314a0db113 l1sap: Take L1SACCH MS_PWR from bitfield instead of manual parsing
Change-Id: Ib2918d5d6b8463c659896f6e535a0c6eaca4bd87
2021-09-06 17:58:38 +02:00
Pau Espin 746d0a7500 comsetic: measurement.c: fix typo in comment
Change-Id: I3ed3486bbc3d55088e3ebe27e4a76f932d6f7a59
2021-09-06 16:19:05 +02:00
Pau Espin 5ed69d0fd5 Power Control Loop: Move skip loop logic to function helper
Let's move duplicate logic to function helper.

Related: SYS#5371
Change-Id: Ic26c17564ec61cdadaab0184c4246b9bf863c69a
2021-09-06 13:17:03 +02:00
Pau Espin e0febb700a MS/BS Power Control Loop: Fix downscaling averaging bug
The bug showed up in previous commit and is fixed in this commit. It can
be seen how rounding error is carried over time in the average
measurement, and affects final values.

Change-Id: I680d1c94bd4bae179b14b26662a819fa1462a5c8
2021-09-03 19:06:22 +02:00
Pau Espin aac12bfd67 MS/BS Power Control Loop: Do RxLEV meas avg & delta calculations directly on RxLevels
Before this comits, averaging and delta calculation was done in RSSI,
but stored the averaging cached state in variables named "rxlev", which
was really confusing. Let's keeping averaging and delta calculations
based on RxLevels.

Some of the tests change results due to test passing RSSI -45, which is
an invalid Rxlev (only up to -47 is supported).
Others fail due to an unrelated bug showing up now. Basically the averaging algo
is doing rounding  the wrong way when downscaling the values. It will be
fixed in a follow-up commit.

Change-Id: I4cff8394f22b5d47789163051364ff594b2bcd74
2021-09-03 19:06:22 +02:00
Pau Espin e2f9abee58 BS Power Control Loop: Increase attenuation if RxQual is better than upper threshold
If RxQual is considered good enough, attenuation can be increased in
order to lower overall cross-channel noise among different MS.

Change-Id: Ie97898980acd152de15f6b4b619d492048855ef4
2021-09-03 19:06:22 +02:00
Pau Espin dd97023388 BS Power Control Loop: Support EWMA average algo for RxQual meas
params->rxqual_meas.upper_thresh is left unchecked in
lchan_bs_pwr_ctrl() on this commit on purpose, to keep this
commit with old behavior wrt to algo logic.

Change-Id: If7e3987df89d680cfa443195ab2f225681d0e6cf
2021-09-03 19:06:14 +02:00
Pau Espin cd11905f64 BS Power Control Loop: refactor lchan_bs_pwr_ctrl() to look similar to lchan_ms_pwr_ctrl()
This commit reworks the code in function lchan_bs_pwr_ctrl()
and logging to look similar to that of lchan_ms_pwr_ctrl(), so that
reader can easily spot similarities between both and add simillar
features more easily.

This commit is also a preparation to add EWMA avg support for RxQual
measurements. Logging is also reworked now to look similar to that of MS
Power Control Loop, because having several parameters driving the algo
(RxLev and RxQual), it becomes more suitable to log all of them together instead
of intermediate info only aplicable to one param such as "delta".

Change-Id: Ida76b55f0da722135eb61ed06ea2b3a1862df600
2021-09-03 19:03:48 +02:00
Pau Espin 160da8ea2b MS Power Control Loop: Improve logging
Change-Id: I8babd42566c41935079fd414d930ebf2d737892e
2021-09-03 19:03:48 +02:00
Pau Espin 085a4cb91e MS Power Control Loop: Support EWMA algorithm for C/I measurements
Change-Id: I52eb0558fd7a215a6ee0b2aced189ae4a37d8a22
Related: SYS#4917
2021-09-03 19:03:48 +02:00
Pau Espin 0617afdb5f MS Power Control Loop: Take C/I into account
This commit extends existing MS Power Control Loop algorithm to take
into account computed C/I values on the UL, received from MS. The
related C/I parameters used by the algorithm are configured at and
provided by the BSC, which transmits them to the BTS similar to already
existing parameters.

Using C/I instead of existing RxQual is preferred due to extended
granularity of C/I (bigger range than RxQual's 0-7).
Furthermore, existing literature (such as "GSM/EDGE: Evolution and Performance"
Table 10.3) provides detailed information about expected target values,
even different values for different channel types. Hence, it was decided
to support setting different MS Power Parameters for different channel
types.

These MS Power Parameters are Osmocom specific, ie. supported only by
newish versions of osmo-bts. Older versions of osmo-bts should ignore
the new IEs added just fine. The new IEs containing the MS POwer
Parameters are not send for non osmo-bts BTSs, hence this commit is
secure with regards to running  osmo-bsc against an ip.access BTS such
as nanoBTS.

Related: SYS#4917
Depends: libosmocore.git Change-Id Iffef0611430ad6c90606149c398d80158633bbca
Change-Id: I5dfd8ff9ab6b499646498b507624758dcc160fb6
2021-09-03 18:57:13 +02:00
Philipp Maier 7c23017806 sched_lchan_tch_x: use ul_cmr and ul_ft when generating RTP bad frame
All generated RTP that originates from the BTS relates to uplink. When
generating AMR BAD frame RTP packets, we must use ul_cmr/ul_ft and not
dl_cmr/dl_ft.

Change-Id: Ifa009819791cf7df2dd8201f442b0dae06f622a4
Related: SYS#5549
2021-09-02 17:43:15 +00:00
Philipp Maier a65cf63619 sched_lchan_tch_x: use functions to determine AMR tranmssion phase
The AMR transmission phase directly depends on the frame number. The
transmission phase is used to tell if a received AMR frame contains a
CMI (frame type that is currently used) or CMR (frame type that the
receiver should use) codec identifier. The formulas in the present
implementation seem to be correct but they do not reflect the numbers in
the spec very well, nor do they have unit-tests. Lets replace them with
more readble functions and test those functions with unit-tests.

Change-Id: I94a934a6b3b397b4cd0e9da3577325de58814335
Related: SYS#5549
2021-09-02 17:43:15 +00:00
Philipp Maier ca41f091fc sched_lchan_tch_x: do not use cmr as ft
CMR and FT are updated each time an AMR voice frame is received from the
radio interface. The transmission phase decides whether the voice frame
contains CMR or FT. The code follows the transmission phase and keeps
ul_cmr and ul_ft up to date.

In contrast to the AMR frames on the radio interface, an AMR RTP packet
always contains the CMR and the FT value.

When generating the RTP payloed, The present implementation uses the CMR
in the position where the FT should be and the FT is ignored. This is not
correct.

Change-Id: I6bb10ff3c76f67b9830787497653b546cf27fe8e
Related: SYS#5549
2021-09-02 17:43:15 +00:00
Pau Espin 298a259b7c rsl: Support parsing up to 3 RSL_IPAC_EIE_MEAS_AVG_CFG IEs
struct ipac_preproc_cfg seems to suggest that there may be up to 3 IEs
in some cases:
"struct ipac_preproc_ave_cfg ms_ave_cfg[3];"

Change-Id: I02633713eb557ee52e790a239f7b13b8c5b2b3bd
Fixes: 9238c3549d
Related: SYS#4918
2021-08-31 08:14:32 +00:00
Harald Welte 6aa959ecf4 l1sap/gsmtap: Don't log UI fill frames [zero information field]
When generating GSMTAP, we are already suppressing generation for
fill frames on PCH and AGCH.  Let's expand that also to dedicated
channels SDCCH, TCH/F and TCH/H.  The fill frames just clog up the
logs without providing much benefit.

SACCH is still being logged, as it contains SI or MEAS REP, so every
active channel still sees GSMTAP traffic every 480ms (SACCH interval).

Change-Id: I0dd37d8848eb0379f84d15f5f006142b16823c6a
2021-08-31 06:55:56 +00:00
Pau Espin 294fa4e061 rsl: Fix rx of multiple RSL_IPAC_EIE_MEAS_AVG_CFG IEs
So far only the first one was applied.

Fixes: 9238c3549d
Related: SYS#4918
Change-Id: Ib4f3c165a988e77b61a8852b254fc0904aa12482
2021-08-30 12:05:24 +00:00
Vadim Yanitskiy c485901d3d osmo-bts-trx: send dummy FACCH in the absense of RTP frames
If for whatever reason the transmit queue of a TCH/{F,H} contains
neither speech frames nor signalling blocks, osmo-bts-trx would
currently transmit garbage.  Of course, this causes decoding
errors at the MS side.

Ideally, we should employ an ECU (Error Concealment Unit) for the
given codec in use.  However, a simpler solution is to transmit
dummy LAPDm frames over FACCH.  This is what e.g. nanoBTS does.

Change-Id: I868afecbcb6890f40c8f146e3ce00e836b794dd3
Related: OS#4823
2021-08-29 08:21:32 +00:00
Neels Hofmeyr f616294d8c add osmo_tdef groups, exposing T timers on VTY config
We have two osmocom specific timers used in the BTS, X1 and X2. Expose
those on the VTY configuration, as timer group 'bts'.

This prepares for a subsequent patch, where I would like to add another
configurable timer. This provides the basic infrastructure for that.

Related: SYS#5559
Change-Id: I0f56f9425134679219884b0c3c2f29e77aff5e64
2021-08-18 17:27:04 +02:00
Neels Hofmeyr 9eb8c9f0d7 add VTY transcript testing
This is not as trivial as with OsmoBSC or OsmoMSC, because normally the
osmo-bts process exits right away when there is no BSC. Hence add
--vty-test option to main.

Use 'osmo-bts-virtual --vty-test' for testing. The other BTS models
require dependencies / configure switches to be built.

Essentially copied from osmo-bsc.git:
configure.ac: add --enable-external-tests
tests/Makefile.am: add 'vty-test' target

Add osmo-bts.vty, some trivial VTY node testing.

This prepares for adding VTY tests for T timer configuration added in a
subsequent patch.

Related: SYS#5559
Change-Id: I730daf548a3a9bb116aa8b6d5772ca9af0ada08f
2021-08-18 17:27:04 +02:00
Neels Hofmeyr f1312f9818 enable Early Immediate Assignment
When an Immediate Assignment comes in targeting an lchan that is not yet
active, then hold back the RR Immediate Assignment until the channel
becomes active.

This allows the BSC to send the Immediate Assignment before first
waiting for the Channel Activation ACK, saving one Abis roundtrip, and
helping avoid double allocation on high latency Abis links.

Related: SYS#5559
Related: I56c25cde152040fb66bdba44399bd37671ae3df2 (osmo-bsc)
Related: Ifb2c62431a91dafa6116b5d6b9410930f00a6e18 (osmo-ttcn3-hacks)
Change-Id: Ie52765b238b01f22fb327fe12327fbf10abcad4c
2021-08-18 17:27:04 +02:00
Neels Hofmeyr 30c838fdfa remove unused LCHAN_S_INACTIVE
Change-Id: Ia738eaa796264fe0a97a2c86d6bbd37eaffe0a59
2021-08-16 20:40:20 +02:00
Philipp Maier 6611e7f305 allow to configure multiple oml remote-ip addresses
At the moment we can only configure a single BSC in the BTS
configuration. This also means that if this single BSC fails for some
reason the BTS has no alternate BSC to connect to. Lets extend the
remote-ip parameter so that it can be used multiple times so that an
operater can configure any number of BSCs that are tried one after
another during BTS startup.

Change-Id: I205f68a3a7f35fee4c38a7cfba2b014237df2727
Related: SYS#4971
2021-07-19 10:39:06 +02:00
Pau Espin ace4e500ed Make gcc 11.1.0 false positivies happy
Make gcc 11.1.0 false positivies happy

After my system's gcc was upgraded, I get false positivies in a couple
places. Let's initialize those to make gcc happy.

"""
//git/osmo-bts/src/common/vty.c: In function ‘lchan_summary’:
//git/osmo-bts/src/common/vty.c:1881:23: error: ‘ts’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1881 |                 lchan = &ts->lchan[lchan_nr];
      |                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
//git/osmo-bts/src/common/vty.c:1869:20: error: ‘trx’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1869 |                 ts = &trx->ts[ts_nr];
      |                 ~~~^~~~~~~~~~~~~~~~~
//git/osmo-bts/src/common/vty.c:1852:34: error: ‘bts’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 1852 |                 if (trx_nr >= bts->num_trx) {
"""

Change-Id: I93477142a5a4b3f3829b7398d6e564c127263596
2021-07-15 13:51:38 +02:00
Philipp Maier dda5cf4bb7 paging: prioritize CS related paging over PS related pagings.
When the paging queue is filled up to a critical level, pagings from the
PCU should be dropped as each immediate assignment paging from the PCU
is worth 4 normal CS pagings. Also the PCU may still issue pagings if the
paginging queue is already full and CS pagings are dropped. In a
congestion situation it is more important to get the CS rather than PS
pagings through.

Change-Id: I30f97672d7a0c369c4a656e878ab8cbbd83e31ea
Related: SYS#5306
2021-07-06 11:35:50 +02:00
Vadim Yanitskiy a5602d593c gsm_lchan_interf_meas_calc_band(): also print number of AVG samples
Change-Id: I4cebb0c5eef16f7e20fce85c506fc271127d7259
2021-07-05 12:07:55 +00:00
Vadim Yanitskiy 454a2516f2 rsl: use tlvp_val16be() in rsl_rx_ipac_XXcx()
Instead of using tlvp_val16_unal() and then doing ntohs() here
and there, convert the remote port to the host byte order once.

Change-Id: Id883a976a03fd3022ed9d66f703b01244df2d9db
2021-07-05 12:07:55 +00:00
Pau Espin ae783bcb0e Support SDCCH8 in osmo dyn ts
Change-Id: Id541dee6c224d2b8d97c07b916085883354cecbc
2021-07-05 08:03:08 +00:00
Pau Espin a4b9073989 Rename osmo dyn ts enums to contain SDCCH8
They will gain support to be activated as SDCCH/8 soon too.

Related: SYS#5309
Depends: libosmocore.git I56dcfe4d17899630b17f80145c3ced72f1e91e68
Change-Id: Ia617d20fc52f09dbab8f4516c06fa1efac08e898
2021-07-05 08:03:08 +00:00
Vadim Yanitskiy 30aea88c2c power_control: constrain BS power reduction on BCCH carrier
BS Power Control is not allowed on the BCCH/CCCH carrier, unless
the BTS is operating in the BCCH carrier power reduction mode.

Allow constrained BS power reduction (up to 6 dB) on active logical
channels iff BCCH carrier power reduction mode is enabled.

Change-Id: I3299b6cdd230d3767321c3d6c64d468b7f5e1d02
Related: SYS#4919, SYS#4918
2021-07-01 02:01:22 +02:00
Vadim Yanitskiy 0e8d68437a osmo-bts-trx: implement BCCH carrier power reduction mode
The BCCH carrier (sometimes called C0) of a BTS shall maintain
discontinuous Downlink transmission at full power in order to
stay 'visible' to the mobile stations.  Because of that, early
versions of 3GPP TS 45.008 prohibited BS power reduction on C0.

However, in the recent 3GPP TS 45.008 there is a feature called
'BCCH carrier power reduction operation'.  This is a special
mode of operation, where the variation of RF level for some
timeslots is relaxed for the purpose of energy saving.

In BCCH carrier power reduction operation, for timeslots on the
C0 carrier, except timeslots carrying BCCH/CCCH, the output power
may be lower than the output power used for timeslots carrying
BCCH/CCCH.  In this case the maximum allowed difference in output
power actually transmitted by the BTS is 6 dB.

The power reduction operation can be controlled by the BSC by
sending BS POWER CONTROL on the A-bis/RSL with the Channel Number
IE set to 0x80 (RSL_CHAN_BCCH).  This makes osmo-bts reduce the
transmission power on inactive timeslots of the BCCH carrier.

This is a non-standard, Osmocom specific extension, so indicate
support of this feature to the BSC in the feature vector.  Also
add a VTY command to allow enabling/disabling the power reduction
locally.  Add some signalling notes to the A-bis/RSL manual.

For more details, see 3GPP TS 45.008, section 7.1.

Change-Id: I3dcee6e910ccc61c5c63c728db9ea04327e2fc98
Depends: I69283b3f35988fc7a1a1dcf1a1ad3b67f08ec716
Related: SYS#4919
2021-07-01 02:01:22 +02:00
Vadim Yanitskiy f50b684594 osmo-bts-omldummy: indicate BTS_FEAT_BCCH_POWER_RED as supported
This is required for ttcn3-bsc-test, see change [1].

Change-Id: I765d5e38cb0746e0458773abf3717ee9bf1cb7d1
Related: [1] I084f7736cd7d09b68ed49f8ba52a14de928d4c01
Related: SYS#4919
2021-06-30 23:45:12 +02:00
Vadim Yanitskiy c3b3ca358a Revert "power_control: BS power shall not be reduced on C0"
This reverts commit cd30a40be1.

As a part of SYS#4919 "BTS energy saving", we want to support
constrained (up to 6 dB) BS power control on BCCH carriers.

Change-Id: I0d2b48c4b2af2d8e94f4ad02fa4774dbd0a0a654
Related: SYS#4919
2021-06-30 23:45:12 +02:00
Pau Espin 8bf5cbea49 Support forwarding proto IPAC_PROTO_EXT_PCU BSC<->PCU
This new extension protocol is used to forward Osmocom PCUIF messages
BSC<->BTS<->PCU.
It will be sent re-using the IPA multiplex of the OML link between
BSC and BTS. BTS is responsible for forwarding the message over the unix
socket to the PCU.

PCUIF existing RX path needs to be reworked in order to accept
variable-size messages, in order to be able to transparently forward
messages without knowing about them (the new container message is
variable-length).

Related: SYS#5303
Change-Id: I73fdb17107494ade9263a62d1f729e67303fce87
2021-06-30 08:13:21 +00:00
Pau Espin 1fe9a89308 gsm_data: Drop unused function gsm_pchan_parse()
Change-Id: I8f49811c1b694c5ef1fb9178d5ff4558172089b0
2021-06-29 16:09:15 +02:00
Eric Wild 4d845ccbb6 osmo-bts-trx: indicate A5/4 support, handle Kc128
Change-Id: Ib8e04fe79f30b443a54c38f395a7a3626ff97c45
Related: SYS#5324
2021-06-23 21:59:31 +02:00
Vadim Yanitskiy f1bdf605b5 scheduler: fix: use ts_pchan() in trx_sched_set_cipher()
Properly handle dynamic timeslots, do not access 'pchan' directly.

Change-Id: Iccb8794253face54164af1ba344204eadab8f98b
Fixes: [1] I7c4379e43a25e9d858d582a99bf6c4b65c9af481
2021-06-22 19:03:47 +02:00
Vadim Yanitskiy a6af31cd44 scheduler: fix wrong union field in trx_sched_tch_req()
I introduced this regression in [1] during a massive refactoring.
Basically, I copy-pasted a chunk from trx_sched_ph_data_req(), but
forgot to change the union field.  This broke voice calls, because
all TCH.req primitives would be enqueued to wrong timeslot.

Change-Id: If841e6ac40a3c6344c304ab970755d6a2d292156
Fixes: [1] I7c4379e43a25e9d858d582a99bf6c4b65c9af481
2021-06-22 18:59:16 +02:00
Vadim Yanitskiy f47fa70b9f osmo-bts-trx: report PDCH interference levels to the PCU
The PDCH multiframe contains 48 data slots, 2 PTCCH slots, and
2 IDLE slots.  The later two can be used for the interference
measurements, since the UEs shall not transmit on them.

bts_report_interf_meas() is called every 104 TDMA frames, what
corresponds to 2 PDCH multiframe periods.  Report interference
levels on PDCH timeslots from this function.

Change-Id: I56f83db5264c246ec1b4b8a973105a4fc09931fb
Related: SYS#5313, OS#1569
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy 54d0931330 osmo-bts-trx: measure interference levels on TRXC_IDLE
We already do the intereference measurements on inactive logical
channels.  For the active channels we can still use the IDLE
slots, on which the UEs shall not transmit Uplink bursts.

Change-Id: Ic3030dba5eb223177298aa4e43559a93dc3d1392
Related: SYS#5313, OS#1569
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy c126870c5f osmo-bts-trx: print timeslot brief info in 'show transceiver'
Change-Id: Ibe624e4b801cae2dc00feb99441b7d606005b846
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy 8a1a74e6ca scheduler: unset TRX_CHAN_FLAG_AUTO_ACTIVE for TRXC_IDLE
Neither we expect any Uplink bursts on IDLE channels, nor we need
to send any Downlink bursts.  Automatic activation of TRXC_IDLE
channels does not make sense.

Change-Id: Ifade0eab0605154196322ff20b1b3a44495f8a2e
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy dded16c4c9 osmo-bts-{trx,virtual}: get rid of dummy tx_idle_fn()
This logical channel handler does nothing more than just logging.

Change-Id: I438705f8dd902193e6c7b499d8ee55c56b6a1c2e
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy 6fd4f77243 osmo-bts-trx: report interference levels to the upper layers
In trx_sched_ul_burst(), treat all BURST.ind and NOPE.ind mapped
to inactive logical channels as interference.  Average the RSSI
values on the fly using a sliding average with constant a=0.5.

Report averaged values for each logical channel every 104 TDMA
frames (SACCH period) by calling gsm_lchan_interf_meas_push().

Change-Id: I4686448e42a40df56c1d27a14fd0a4d43fd144a5
Related: I78b6d8beffa5228a28231b75728e7aebdd3cb23c
Related: SYS#5313, OS#1569
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy d4efc3f9c5 Report interference levels in RSL RF RESource INDication
This change implements general interference averaging logic for
the higher layers.  In l1sap_info_time_ind(), where we receive
TDMA time updates from BTS model, call rsl_tx_rf_res() for each
transceiver according to the interval defined by the Intave
parameter received from the BSC.  In rsl_tx_rf_res() perform
the actual averaging for each inactive logical channel, and
then send everything to the BSC over the A-bis/RSL.

The BTS model specific code needs to report the measurements
for each logical channel every 104 TDMA frames (SACCH period)
by calling gsm_lchan_interf_meas_push().

Change-Id: Id80fdbef087de625149755165c025c0a9563dc85
Related: SYS#5313, OS#1569
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy 64e1c1222e oml: fix handling of NM_ATT_INTERF_BOUND attribute
Looks like this part of the code has never been tested.  The old
code would dereference the same value in the loop and assign it
to all members in array 'bts->interference.boundary'.

Change-Id: I7f83d8e6eb6cc19e3e9529ba06617a902de23e35
Related: SYS#5313, OS#1569
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy 4e8d4d5bb8 osmo-bts-trx: fix copy-pasted comment: s/sysmoBTS/osmo-bts-trx/
Change-Id: If796a8d55f1ad0642e5a81689161c7e7b70f4b5e
2021-06-18 16:48:36 +00:00
Vadim Yanitskiy a556c49114 osmo-bts-trx: fix typo: s/bisc/bsic/ in 'show transceiver'
Change-Id: I39c6138e950ca7d3cda9c52d4e1cdaa218624641
2021-06-18 18:40:53 +02:00
Pau Espin b04ffc11fb pcu_sock: Transmit SI2
OsmoPCU will need this SI2 in order to gain knowledge of the BCCH
Frequency List being broadcasted, in order to build a per-MS specific
Neighbour List using NC_FREQUENCY_LIST bits in Packet Measurement Order.

Related: SYS#5303
Change-Id: If70c64f941f621a9a68aef2c846639b5c7f2f74b
2021-06-11 23:19:59 +02:00
Vadim Yanitskiy ef4a6a0f43 l1sap: fix TDMA frame number arithmetic in fn_ms_adj()
Using the normal arithmetic for TDMA frame numbers is wrong.

Change-Id: Ie17670d150489014a4a2e140cede42086100bbc0
2021-06-10 21:50:48 +00:00
Vadim Yanitskiy 4590b099bf osmo-bts-octphy: drop talloc_replace(), use osmo_talloc_replace_string()
Change-Id: Ied39cc594fedc712d751ab1c7b636bbbff527bd6
2021-06-10 21:50:48 +00:00
Pau Espin 52f6fc5aab rsl: Use switch statement in rsl_rx_bcch_info()
This is a preparation for new commit, which makes it easier to add new
SIs being sent.

Change-Id: I27774ca36d1e740b6a502cfb280aba0ea82b9dbe
2021-06-10 12:58:18 +00:00
Vadim Yanitskiy 5acd0102e4 vty: ensure all warning messages are prefixed with '%%'
Change-Id: I23fc1cd8aa5725de06651f061c9fce6a022adfa8
2021-06-10 11:53:24 +00:00
Vadim Yanitskiy 85c2d641d5 common/vty: facilitate finding duplicate PHY/TRX associations
In cfg_trx_phy_cmd(), use phy_instance_link_to_trx() and ensure
that a PHY instance can be bound to a transceiver only once.

Change-Id: I132e08fc496abef278b94254cebfac7a4285a7c2
2021-06-10 11:53:24 +00:00
Vadim Yanitskiy bd49fd2492 [VAMOS] trx_sched_init_ts(): assign names to per-timeslot counters
Thanks to [1], it's now possible to associate a human-readable
name with a rate counter group.  Before this API, we had to use
weird index values for each timeslot, and with introduction
of the shadow timeslots the situation got even worse.

Change-Id: Ie872ab37661fa5d44f219f59c7daaa1033113289
Depends: [1] I0dc510783dd9ae8436dae8005a7b3330e80d36f3
Related: SYS#4895, OS#4941
2021-06-09 22:45:10 +02:00
Vadim Yanitskiy 43adbe200c measurement: remove over-defensive checks in is_meas_complete()
The timeslot number ts->nr is set in gsm_bts_trx_alloc() and can
never be greater than 7.  Regarding the physical channel type
returned by ts_pchan(), it's also unlikely to be greater than
_GSM_PCHAN_MAX.

Change-Id: I6d20d7cba49cc8b6d1dc2192598ca372b7d2c5bf
2021-06-09 20:20:42 +00:00
Vadim Yanitskiy fc8c9880d9 conf_lchans_as_pchan(): initialize all lchans with GSM_LCHAN_NONE
This function is called during the OML bootstrapping, and also
when a dynamic timeslot switches between PDCH and TCH/{F,H}.
In the later case, after switching from TCH/{F,H} to PDCH, some
lchans might still have the old type assigned.

Let's ensure that all logical channels are properly updated.

Change-Id: I44726f2bfb979c2fa2f5f30c5b11700cf4b3399d
Related: SYS#5313, OS#1569
2021-06-08 02:04:53 +02:00
Vadim Yanitskiy 628853de74 conf_lchans_as_pchan(): fix GSM_LCHAN_{CCCH->CBCH} regression
This regression was introduced (by me) in [1] and broke CCCH.

Change-Id: I403ad06574a8505b69dd06781f7fe0f7cabf416f
Fixes: [1] I1c5a033e89d9ca5fb01ebe9ffb521fd67d159bee
Related: SYS#4895, OS#4941
2021-06-08 01:53:14 +02:00
Vadim Yanitskiy 177799fe7e l1sap: fix TDMA frame number wrap in l1sap_info_time_ind()
Using the normal arithmetic for TDMA frame numbers may result
in getting wrong values.  Consider the following situation:

  'info_time_ind->fn' is 0 (beginning of period)
   'bts->gsm_time.fn' is 2715647 (end of period)

With these input values the following expression:

  info_time_ind->fn - bts->gsm_time.fn

will be equal to:

  0 - 2715647 or -2715647

In this case osmo-bts does not log an error, because:

  if (-2715647 > 0) // is false

As a consequence, we do not increment number of RACH slots that
have passed by since the last time indication:

  for (i = 0; i < -2715647; i++) // is false

This is why we introduced GSM_TDMA_FN_{SUB,SUM,DIFF,INC} API.

Change-Id: I6168dd75daea50bbe2e19338e637185ac9ac87ef
2021-06-07 01:49:16 +02:00
Neels Hofmeyr 68671291f3 [VAMOS] osmo-bts-omldummy: allocate shadow timeslots
Change-Id: I4aa9a8bb35bd828d6f25d5690297e727dace5974
Related: SYS#4895, OS#4941, SYS#5316, OS#4940
2021-06-05 00:34:36 +02:00
Vadim Yanitskiy 6d20a49806 [VAMOS] osmo-bts-trx: schedule bursts on 'shadow' timeslots
Change-Id: I3e0bdf8c03273f66991aa1764029ab1dd3528d7e
Related: SYS#4895, OS#4941
2021-06-05 00:34:36 +02:00
Vadim Yanitskiy 0686ae6128 [VAMOS] Implement the concept of 'shadow' timeslots
Change-Id: I48b44b4df9ffb1cca105aebbd868c29b21f3b1d6
Depends: Ia0bd8695a3f12331b696fe69117189cdd48b584d
Related: SYS#4895, OS#4941
2021-06-05 00:34:36 +02:00
Vadim Yanitskiy d9daa3fd9e [VAMOS] conf_lchans_as_pchan(): improve readability
Change-Id: I1c5a033e89d9ca5fb01ebe9ffb521fd67d159bee
2021-06-05 00:34:36 +02:00
Vadim Yanitskiy b99db695a7 [VAMOS] scheduler: drop meaningless channel number checks
Change-Id: Icc57e58feece51c2d1c421454352bc821e338973
2021-06-05 00:34:36 +02:00
Vadim Yanitskiy 28cd8a318f trx_sched_is_sacch_fn(): fix handling of dynamic timeslots
There is no GSM_PCHAN_TCH_F{_TCH_H}_PDCH in trx_sched_multiframes[],
so find_sched_mframe_idx() would always return -1 for these.  Fix
this by using ts_pchan(), which returns currently active pchan type.

Change-Id: Ia5e337e897b595e7de6e504664c969b583cc02a1
2021-06-04 20:06:58 +00:00
Vadim Yanitskiy 5b8080208a osmo-bts-trx: fix NULL pointer dereference in trx_if_send_burst()
Starting from TRXDv2 [1], trx_if_send_burst() would keep batching
PDUs to the static buffer, unless it's called with br = NULL, so
we cannot dereference br in the logging statement.

Of course, we could also store TDMA frame number in a static
variable, but I don't think it's worth it just for logging.

Change-Id: I4a361777fc40bdedcebbe54df6274bc5573f77a8
Fixes: [1] I9b4cc8e10cd683b28d22e32890569484cd20372d
Fixes: CID#236232
2021-06-04 20:06:58 +00:00
Vadim Yanitskiy 069796bcd8 [VAMOS] oml_rx_set_chan_attr(): clarify NM_ATT_CHAN_COMB handling
Change-Id: I8a4aace97515ca59ac4c6b5d50a9ee242edfe409
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy a02d9e57b0 [VAMOS] l1sap: get_lchan_by_chan_nr() may return NULL
Change-Id: Ic309622d0ee818302dfc66d69fd2914ae28261d6
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy bcdbb6c556 [VAMOS] gsm_data: rework and rename gsm_lchan_name_compute()
Change-Id: Id5cc40db04a654d94f5f75d4aad45439d66528cc
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy 5d888e5064 [VAMOS] rsl_lchan_lookup(): make it more readable
Change-Id: I3160929c739a521fe494716c3da3d3b72370a98a
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy 0704b29d6d [VAMOS] rsl_lchan_lookup(): use ABIS_RSL_CHAN_NR_CBITS_* macros
Change-Id: Iec3250e3a59f8d428d7e7be2ceb71f7086a68e7b
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy 24e5f72f83 [VAMOS] gsm_pchan2chan_nr(): use ABIS_RSL_CHAN_NR_CBITS_* macros
Change-Id: I2b1480d3c330951cccc15333450cf7243b9505fc
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy dd3b7d469e [VAMOS] common/oml: generalize checking BTS_FEAT_MULTI_TSC
Change-Id: Iaa5aced70e166963106c27ebdb09adaae22daea4
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy d8598005ce [VAMOS] l1sap_chan_act(): handle Osmocom specific TSC IE
This is an Osmocom specific RSL IE that, if present, takes
precedence over the values indicated via the A-bis/OML.

Change-Id: I717e5b2a6ca5b4faeaab9cae4bb971907945871b
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy 60fc1d3763 [VAMOS] scheduler: add new GMSK training sequences from 3GPP 45.002
Change-Id: I03fe712da5a3cc1a59f40a98a57f43306c3586c6
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy 3c1151f945 [VAMOS] osmo-bts-trx: properly handle per-timeslot TSC values
Each timeslot can have its own Training Sequence Code value, which
may optionally be included in the NM_MT_SET_CHAN_ATTR message sent
over the A-bis/OML.  If it's not present, then the TSC value for a
timeslot is derived from the BCC part of BSIC, which is always
included in the NM_MT_SET_BTS_ATTR message.

On the TRXC interface, the BTS global TSC value is indicated to the
transceiver using either of the 'SETTSC' or 'SETBSIC' commands.
The transceiver then applies this value for all timeslots by default,
however it can be redefined for each timeslot individually using
additional arguments of the 'SETSLOT' command (see section 25.2.4.1
in the user manual [1] for more details).

Currently, trx_set_ts_as_pchan() sends TRX_PROV_EV_CFG_TSC to the
transceiver provisioning FSM, together with the per-timeslot TSC
value.  This event causes the FSM to modify the global TSC value,
that is going to be or has already been sent to the transceiver.
This is wrong, the global TSC value shall not be overwritten.

Remove the TRX_PROV_EV_CFG_TSC, and include per-timeslot Training
Sequence Code and Set in the data structure that gets passed together
with the TRX_PROV_EV_CFG_TS instead.  Implement handling of the
optional per-timeslot TSC in trx_if_cmd_setslot().

[1] https://downloads.osmocom.org/docs/latest/osmobts-usermanual.pdf

Change-Id: Idc5796151e3e83f42d60c2d4cb7c35890d76a7f5
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy 207d56afe5 [VAMOS] osmo-bts-trx: rework handling of Training Sequence
The TSC (Training Sequence Code) value in 'struct gsm_bts_trx_ts'
is always initialized in oml_rx_set_chan_attr() during the OML
bootstrapping, so there is no need for gsm_ts_tsc() - remove it.

Store the initial TSC value in 'struct gsm_bts_trx_ts', so we can
apply a different TSC value during the RSL CHANnel ACTIVation.

Store the Training Sequence Code/Set in 'struct trx_dl_burst_req'.
These values are indicated to the transceiver (TRXDv2 PDUs, 'MTS'
field) and used by the new TRX_{GMSK,8PSK}_NB_TSC macros.

Change-Id: I3744bc308b99ef941e6e9d139444e414abebc14b
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Pau Espin 163ff40dd5 Use new stat item/ctr getter APIs
Generated with spatch:
"""
@@
expression E1, E2;
@@
- &E2->ctr[E1]
+ rate_ctr_group_get_ctr(E2, E1)
"""

Change-Id: I9b8e31adcbb3142d3d09f1f0e0ae7e435bb2c5ca
2021-06-04 17:59:43 +02:00
Philipp Maier 91054e78ef main,abis: change model name from sysmoBTS to osmo-bts
The model name when used when abis_open() is called is sysmoBTS, since
we recently decided to deprecate the type name "sysmobts" in osmo-bsc we
might consider the same thing here.

Change-Id: I3c61d92f5527ae0145316b5ff92660f8b467a8dc
2021-06-02 17:53:02 +02:00
Vadim Yanitskiy ef5c364bba [VAMOS] common/scheduler: unify symbol names for training sequences
Change-Id: Ice464e5b02b11b0f13df247fe6a01420a29bf1c5
Related: SYS#4895, OS#4941
2021-06-01 02:46:43 +00:00
Vadim Yanitskiy bdef33d527 [VAMOS] bts_supports_cm(): handle RSL_CMOD_CRT_OSMO_TCH_VAMOS_{Bm,Lm}
Change-Id: I61040df30246ff79c9b13055bb1fec92fe64f3dd
Related: SYS#5315, OS#4940
2021-06-01 02:46:43 +00:00
Vadim Yanitskiy c70196240c [VAMOS] rsl: call bts_supports_cm() from rsl_handle_chan_mod_ie()
Ensure that we check the PHY capabilities in both cases:

  * RSL CHANnel ACTIVation, and
  * RSL CHANnel MODE MODIFY,

by calling bts_supports_cm() from rsl_handle_chan_mod_ie().

Modify bts_supports_cm() to accept a 'struct rsl_ie_chan_mode',
so we can handle VAMOS enabled channel modes and CSD later on.

Change-Id: I31a444592436705ec9d6ddade3cbfa7f8cb4bb91
Related: SYS#5315, OS#4940
2021-06-01 02:46:43 +00:00
Vadim Yanitskiy e02612d863 [VAMOS] rsl_rx_mode_modif(): handle Channel Identification IE
For some reason, handling of the Channel Identification IE was done
in l1sap_chan_act().  This function is being called on reciept
of the CHANnel ACTIVation message, but not on MODE MODIFY.

Change-Id: I07f95e69e6230a1daca62cc0a7c64954f191fa8a
Related: SYS#5315, OS#4940
2021-06-01 02:46:43 +00:00
Vadim Yanitskiy 13d595a9ef [VAMOS] osmo-bts-trx: indicate MTS in Downlink TRXDv2 PDUs
Change-Id: I1a17a25883214c068f9b1a6d651128b8f760d1fb
Related: SYS#4895, OS#4941
2021-06-01 02:46:43 +00:00
Vadim Yanitskiy ec1045a01b [VAMOS] osmo-bts-trx: implement and enable PDU batching for TRXDv2
This change implements TRXD PDU batching approach b), which is described
in section 25.3.4 of the user manual [1].  This approach is quite easy
to implement on the transceiver side, so we can enable it by default.

  .Example: datagram structure for combination b)
  ----
  +--------+----------------+---------+------------------------+
  | TRXN=N | TDMA FN=F TN=0 | BATCH=1 | Hard-/Soft-bits        |
  +--------+----------------+---------+------------------------+
  | TRXN=N | TDMA FN=F TN=1 | BATCH=1 | Hard-/Soft-bits        |
  +--------+----------------+---------+------------------------+
  | TRXN=N | TDMA FN=F TN=2 | BATCH=1 | Hard-/Soft-bits        |
  +--------+----------------+---------+------------------------+
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  +--------+----------------+---------+------------------------+
  | TRXN=N | TDMA FN=F TN=7 | BATCH=0 | Hard-/Soft-bits        |
  +--------+----------------+---------+------------------------+
  ----

Other PDU batching approaches can be introduced later.

[1] https://downloads.osmocom.org/docs/latest/osmobts-usermanual.pdf

Change-Id: I9b4cc8e10cd683b28d22e32890569484cd20372d
Related: SYS#4895, OS#4941
2021-06-01 02:46:43 +00:00
Pau Espin 272d474ccb pcuif: Set missing bsic field during Tx of info_ind
Change-Id: I5c0194644083f04799174464445ec21dae82f368
2021-05-31 16:18:13 +02:00
Keith Whyte d89938afa7 sysmobts-mgr: Fix path to hwmon in /sys
The path to the temperature sensor was wrong which
results in the SysmoBTS manager always considering
that the state is critical and hence powering OFF
the PA on startup. (with the default config)

As a further side-effect, the temperatures were not
available in the vty 'show manager' command.

Redacted log previous to this patch:

  sysmobts_misc.c:128 Error reading temperature
  sysmobts_mgr_2050.c:323 Going to enable the PA.
  sysmobts_mgr_temp.c:252 Failed to read the digital temperature. rc=-1
  sysmobts_mgr_temp.c:267 Failed to read the RF temperature. rc=-1
  sysmobts_mgr_temp.c:203 Moving from state NORMAL to CRITICAL.
  sysmobts_mgr_temp.c:185 System has reached critical warning.
  sysmobts_mgr_temp.c:236 OML alert sent: 0

and in the vty:

  Temperature control state: CRITICAL
  Current Temperatures
   Digital: -0.001000 Celsius
   RF:      -0.001000 Celsius

With this patch we correctly enable the PA and now can show in the vty:

  Temperature control state: NORMAL
  Current Temperatures
   Digital: 39.000000 Celsius
   RF:      35.125000 Celsius

Change-Id: Iac8e9a866ad6326874af91bd12a981f39a9a24c7
2021-05-28 17:54:26 +00:00
Vadim Yanitskiy a179a9434a Fix regression in 'osmo-bts-trx: rework and split up bts_sched_fn()'
In [1] I forgot to update tx_fcch_fn(), where we assume that the
burst buffer is already zero-initialized and do not call memset().
This results in sending dummy bursts on FCCH (instead of zeros).

Change-Id: I491b3b5702b3cfca45c12c002b41e60c629b05b9
Fixes: [1] Iec78989517865b3275a9784d1042a5ebd1d2815f
2021-05-27 21:31:09 +02:00
Pau Espin 949874433f Add missing value_string for NM_EV_* introduced recently
Fixes: 0277cddab2
Change-Id: I70266767d4f85e8c14ecf477af7fab0706698067
2021-05-27 18:58:59 +02:00
Pau Espin 1cad2f51c6 Fix regression in 'bts: Clean up TS selection in sign_link_up'
Fixes: 518ada9414
Change-Id: I63af96235eb6e0a7334936f65e1f44d4422198a5
2021-05-26 19:05:58 +02:00
Pau Espin 518ada9414 bts: Clean up TS selection in sign_link_up
Change-Id: I0c92dfd05bf2ae40887980ef10b7e4c679213b6a
2021-05-25 11:36:35 +00:00
Vadim Yanitskiy 97193ced54 [VAMOS] osmo-bts-trx: rework and split up bts_sched_fn()
Currently, in bts_sched_fn() we send a Downlink burst to the PHY
immediately after calling the associated logical channel handler.
Together with the obvious performance advantages, this approach
imposes some serious limitations.  The code has already become
quite complex with the introduction of the baseband frequency
hopping, and now it's not possible anymore to extend it further.

TRXD PDU batching, which is essential for VAMOS implementation,
requires us to make the scheduler more flexible at the expense of
increased memory consumption and additional CPU cycles.  This patch
splits up Downlink burst scheduling into 3 main steps:

  1. bts_sched_init_buffers(): initialization of per-TRX Downlink
     burst buffers allocated by phy_instance_create().  For C0/TRX0
     all timeslots are pre-initialized with dummy burst.
  2. bts_sched_fn(): generating burst bits for all active lchans.
  3. bts_sched_flush_buffers(): sending everything to the PHY.

This approach allows us to a) get rid of the ugly tail in bts_sched_fn()
that was responsible for sending dummy bursts on C0/TRX0;  b) implement
the PDU batching and have several variants of bts_sched_flush_buffers()
providing the alternative batching approaches later on;  c) implement
PDU merging for the upcoming shadow transceivers.

Change-Id: Iec78989517865b3275a9784d1042a5ebd1d2815f
Related: SYS#4895, OS#4941
2021-05-23 12:10:38 +00:00
Vadim Yanitskiy bdc5095368 common: phy_links_open(): warn about dangling PHY instances
Change-Id: I8d84bf7a00da6b985cb3dc314e86cacac8d4f48c
2021-05-23 10:36:05 +00:00
Vadim Yanitskiy d4abdd80fe [VAMOS] gsm_data.h: introduce and use BTS_TSC macro
Change-Id: I0cf915d2d3a640aa1442cf6abe9a314261b4a64e
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 dd9a6f16bc osmo-bts-trx: clarify logging messages in trx_if_{open,close}()
Change-Id: I48e64b5b52fc476f915d3a93535b21f0f192b7a9
2021-05-19 16:28:26 +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 b4c0e43c60 osmo-bts-trx: fix hopping pointer bug in bts_sched_fn()
In change [1] together with the actual implementation I introduced
a serious bug to bts_sched_fn(): if a timeslot is configured to use
frequency hopping, both 'pinst' and 'l1h' pointers are *overwriten*
in the inner loop, so the Downlink burst is re-directed to the
approproate PHY instance.  However, if a subsequent timeslot is not
hopping, the Downlink burst would be re-directed to the wrong PHY
instance because both pointers were overwriten during a previous
iteration.

Let's move the 'struct phy_instance' pointer to the inner loop, so
it's properly re-initialized for each timeslot iteration.

Change-Id: I9afbbef8dc5d885763356470c27d4392dce8e815
Fixes: [1] I68f4ae09fd0789ad0d8f1c1e17e17dfc4de8e462
Related: SYS#4868, OS#4546
2021-05-18 19:11:06 +00:00
Vadim Yanitskiy 98aeaf6fa7 osmo-bts-trx: remove redundant assert() in bts_sched_fn()
trx_phy_instance() does assert() that the given TRX pointer is
not NULL.  In bts_sched_fn() it can never be NULL, so drop it.

Change-Id: I896ff5117588f2229cc54619ce62fd027a9ef25f
2021-05-18 19:11:06 +00:00
Vadim Yanitskiy e728f22136 osmo-bts-trx: cosmetic: s/trx_sched_fn/bts_sched_fn/g
Change-Id: I47e05b5b3f586430aa0b56c3d3c9a1da23077513
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 2dda5d835a osmo-bts-{lc15,oc2g}: drop redundant checks in VTY commands
Change-Id: I4fea6d661b7193c3a04e88c9399a9e2bc402254f
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 9e09441814 rsl: fix wrong value printed in rsl_handle_chan_mod_ie()
Change-Id: I724504a39702393402fae20b0e9775c3486da966
2021-05-05 02:09:26 +02:00
Vadim Yanitskiy c9635b0ad1 osmo-bts-trx: refactor parse_rsp(), fix compilation warnings
For a long time, we see this annoying -Wstringop-truncation warning:

  In function ‘parse_rsp’,
      inlined from ‘trx_ctrl_read_cb’ at trx_if.c:647:6:
  trx_if.c:416:2: warning: ‘strncat’ output may be truncated copying
                  between 0 and 45 bytes from a string of length 1495
    416 |  strncat(rsp->cmd, buf_in + 4, p - buf_in - 4);
        |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There is no real need to use strncat() in parse_rsp(), because we
do not concatenate any strings but simply copy TRXC response parts
from the input buffer to the corresponding 'name' and 'parameters'
buffers.  Let's use memcpy() instead.  This also fixes the warning.

Change-Id: Ia10adf7d76abe9a423b07e828852fbfb53b95125
2021-04-30 21:07:41 +02:00
Vadim Yanitskiy 38cdafd656 common/abis: fix the use of deprecated e1inp_line_get() API
We need curly braces becausee1inp_line_get2() is basically a macro
that calls OSMO_ASSERT(), which in its turn contains an 'if' stmt.

Change-Id: I41a5fd13a7fa40e16bcf1a8099624b654274cee3
2021-04-30 21:07:41 +02:00
Vadim Yanitskiy d2eafadc25 vty: fix the use of deprecated osmo_bts_feature_name()
Change-Id: I67863da286b0fd1ec42088bce12d3c76e4be30ba
Depends: I9dfdb5e81037b6000effbd340af4e5db0dcfd69c
2021-04-30 21:07:02 +02:00
Vadim Yanitskiy f3e3a3ac99 osmo-bts-trx: reduce code nasting in trx_if_send_burst()
If the PHY is not powered on and we are not supposed to send any
bursts to it, then trx_if_send_burst() should just return early.

Change-Id: I578bd5a731ad88ebff283c75bb7eb268d9e7e787
Related: SYS#4895, OS#4941, OS#4006
2021-04-30 19:02:15 +00:00
Vadim Yanitskiy 67b141c567 osmo-bts-trx: assert PDU version in trx_if_send_burst()
If somehow the TRXC logic negotiates a non-supported TRXD PDU version,
then it's a serious bug in the code.  Let's add an assert() for that.

Change-Id: I301377bcebd5e2bbcfc18b3637253ef261bb5b2e
2021-04-30 19:02:15 +00:00
Vadim Yanitskiy 7651b078b1 osmo-bts-trx: enlarge and share TRXD message buffer
Starting from TRXDv2, several PDUs may be batched together and sent in
all together a single datagram.  This requires us to increase the buffer
size that we use for sending and receiving TRXD messages.  Let's use
65536 matching the default MTU value for 'lo' interface on Linux.

Given that 65536 is quite a big number, let's allocate a shared Rx/Tx
buffer statically to avoid [potential] stack overflow.

Change-Id: I729451c8ecdc7ff2631beb423f15523db16b3ee3
Related: SYS#4895, OS#4941, OS#4006
2021-04-30 19:02:15 +00:00
Vadim Yanitskiy 010841644b osmo-bts-trx: refactor handling of version specific TRXD parts
This is a preparatory change for the upcoming TRXDv2 support:

* move common TRXDv0/v1 header parser into a separate function;
* move burst handling into a single, version independent function;
** determine modulation and burst length in trx_data_parse_pdu_v0();

Change-Id: I7aedd85a8d4f6d6191cd3b75272a688208fb2879
Related: SYS#4895, OS#4941, OS#4006
2021-04-30 19:02:15 +00: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
Neels Hofmeyr 9c321b8486 omldummy: add cmdline arg --features
The current usage is to make osmo-bts-omldummy indicate BTS_FEAT_VAMOS
on OML, so that we can test osmo-bsc's behavior when VAMOS is enabled.

Related: SYS#4895
Depends: I699cd27512887d64d824be680303e70fff3677c1 (libosmocore)
Change-Id: Ib50990109f07884ef999ba5a4566f5d1d457b0ae
2021-04-27 13:38:34 +00:00
Vadim Yanitskiy dd8439f889 osmo-bts-trx: pass 'struct phy_instance' to TRXD dissectors
All these functions need the PHY instance pointer for logging,
they don't really need a pointer to 'struct trx_l1h'.

Change-Id: I626b4392a8bc57a3fe5e8c931aa1ce9dd505676c
Related: SYS#4895, OS#4941, OS#4006
2021-04-24 08:48:03 +00:00
Vadim Yanitskiy 8a99365281 osmo-bts-trx: generalize checking of TRXD header length
Change-Id: I7df851c3afb82133f84dc805e0926438a90efe07
Related: SYS#4895, OS#4941, OS#4006
2021-04-24 08:47:56 +00:00
Vadim Yanitskiy ac55dcb5d0 osmo-bts-trx: cosmetic: get rid of TRX_CHDR_LEN macro
The 'CHDR' stands for 'Common Header', but this does not apply to
TRXDv2 because TDMA frame number may not be present in the batched
PDUs.  Let's avoid potential confusion by removing it.

Change-Id: I80495df474c432f4c0a4cfa6f917821d7b35859a
2021-04-24 08:47:00 +00:00
Vadim Yanitskiy 17350e2fd6 osmo-bts-trx: move TDMA frame number check to trx_data_read_cb()
Change-Id: Ib3c4a5ad7f16196dc5c591aa0b4d7e0ec3267f05
Related: SYS#4895, OS#4941, OS#4006
2021-04-24 08:47:00 +00:00
Vadim Yanitskiy 974bf725a4 osmo-bts-trx: discard TRXD PDUs with unexpected version
Change-Id: Icdc3d12a7686428046113f9fa8f21a99569e651a
Related: SYS#4895, OS#4941, OS#4006
2021-04-24 08:47:00 +00:00
Vadim Yanitskiy 16c2998069 osmo-bts-trx: move MTS parser into trx_data_parse_mts()
This would allow to re-use this code from the TRXDv2 parser.

Change-Id: I2de2cb2d58110452d8dedbcacfef28f85f6d67c1
Related: SYS#4895, OS#4941, OS#4006
2021-04-24 08:47:00 +00: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 61fcfa6ae7 osmo-bts-trx: define TRXC/TRXD message buffer size
Change-Id: I4cb05600fa8af33e1c92e93cc1a86c14f21b9fb2
Related: SYS#4895, OS#4941, OS#4006
2021-04-24 08:47:00 +00:00
Neels Hofmeyr 708fca343e omldummy: introduce using getopt_long
Prepare for adding the --features cmdline arg following in a subsequent
patch.

Related: SYS#4895
Change-Id: I72ccf65ba894e87ee7b0f6bed879f94728f34ccc
2021-04-22 20:45:02 +02:00
Vadim Yanitskiy b11012c1f5 osmo-bts-trx: cosmetic: use '#pragma once' in trx_if.h
Change-Id: I78b93a8f5fbbd94141d30518d37c1ce05f8a681f
2021-04-21 01:26:00 +02:00
Vadim Yanitskiy ab5cc5e6c5 osmo-bts-trx: remove outdated TRXD protocol documentation
We do have TRXC/TRXD documentation in osmo-gsm-manuals repository.
This big comment is out of sync with what we have in the manuals,
so let's better remove it to avoid maintaining docs in several places.

Change-Id: Ibfcefcbb5f30fe9b6c691578a93e6fedd5644b30
Related: SYS#4895, OS#4941, OS#4006
2021-04-21 01:26:00 +02: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
Vadim Yanitskiy 0b33ab8ac2 lchan2lch_par(): fix missing default branch in switch
New channel mode values have recently been added with change [1]
to 'enum gsm48_chan_mode'.  The lack of default branch in
lchan2lch_par() caused build failures on Jenkins:

  oml.c:956:2: error: enumeration value ‘GSM48_CMODE_SPEECH_V2_VAMOS’
                      not handled in switch [-Werror=switch]
  oml.c:956:2: error: enumeration value ‘GSM48_CMODE_SPEECH_V3_VAMOS’
                      not handled in switch [-Werror=switch]
  oml.c:956:2: error: enumeration value ‘GSM48_CMODE_SPEECH_V5_VAMOS’
                      not handled in switch [-Werror=switch]

This function is duplicated in osmo-bts-{lc15,oc2g,octphy,sysmo},
so we unfortunately need to apply the same fix to all copy-pasted files.

Change-Id: I557ff8cac6564d22485c101fba9212f5f0e95bb7
Related: [1] Ie0ea592da5610ae70290106d004e549cf3212a89
2021-04-20 22:50:14 +02:00
Vadim Yanitskiy 8de227fd13 rsl: add missing Channel Mode values to rsl_handle_chan_mod_ie()
Change-Id: I125cdaaf5adac0891a964c9834b99eb5a35ce262
Depends-On: I40eca759380c8895d7923b2b4259d37a50978160
Depends-On: Icf4c83fa443b8410f4362c119b0a85419036b9cd
2021-04-19 16:12:20 +02:00
Vadim Yanitskiy aee336eaac rsl: rename, fix and refactor lchan_tchmode_from_cmode()
In change [1] I added the missing 'default' branch to the 'switch'
statement in lchan_tchmode_from_cmode().  This caused massive
regressions in ttcn3-bts-test, because osmo-bts started to NACK
some RSL CHANnel ACTIVation messages.

What caused a lot of regressions in ttcn3-bts-test is actually the
missing branch for RSL_CMOD_SPD_SIGN in the 'switch' statement.
It was not a problem before [1], because the 'default' branch was
not there.  I was about to add the missing 'cause' when I realized
that this function needs to be reworked first...

First of all, lchan_tchmode_from_cmode() does a bit more than just
deriving RR (TS 44.018) channel mode from RSL (TS 48.058) channel
mode.  It additionally stores the 'Speech or data indicator' to
the logical channel state, and also changes some global DTXd related
flags in 'struct gsm_bts'.  Let's use a more precise name.

  lchan_tchmode_from_cmode() -> rsl_handle_chan_mod_ie()

Together with renaming, it becomes logical to have the IE presence
check in rsl_handle_chan_mod_ie(), so that we can reduce code
duplication in the calling functions a bit.

Finally, the main problem is that coding and interpretation of the
6-th octet 'Speech coding algor./data rate + transp ind' depends on
the 4-th octet of the Channel Mode IE.  We cannot handle all values
in one 'switch' statement without proper discrimination:

  a) If octet 4 indicates Speech, then octet 6 shall be interpreted
     as the GSM speech coding algorithm (FR, HR, AMR, etc.).

  b) If octet 4 indicates Signalling, then octet 6 shall be set
     to '00'O, because this is the only value defined in version
     16.0.0 of 3GPP TS 48.058.  All other values are reserved.

  c) If octet 4 indicates Data, then octet 6 shall be interpreted
     as CSD data rate further discriminated by service transparency.

Therefore, we need take both values into account.  This can be
achieved by mixing them together using the bitwise operators,
just like we do in L1SAP code.

Change-Id: Iba967f5bd0cc8ad6cd3ccd40cca38b15ffe96b2c
Related: [1] I67a70132999be6580a29e6b814763309a6df4ae9
Related: SYS#4895, OS#4941
2021-04-19 06:29:29 +02:00
Vadim Yanitskiy 5ac4456173 l1sap: fix incorrect pointer cast in l1sap_chan_act()
In [1] I introduced a regression, so osmo-bts started to complain:

  This PHY does not support lchan TSC 3 != BSIC-TSC 7

on channel activation, despite the TSC in RSL_IE_CHAN_IDENT was 7.

The problem is that this statement:

  cd = (const struct gsm48_chan_desc *) TLVP_VAL(tp, RSL_IE_CHAN_IDENT) + 1;

is basically equivalent to:

  cd = ((const struct gsm48_chan_desc *) TLVP_VAL(tp, RSL_IE_CHAN_IDENT)) + 1;

so we actually shift the pointer by sizeof(struct gsm48_chan_desc)
and skip 3 octets instead of just one (IEI octet).  Fix this.

Change-Id: Ic3a81396b60577e03c541d32839d07dc6d45c838
Fixes: [1] Id100f4c56fd5c1adad5d925d97240bed82981b9b
Fixes: OS#5121
2021-04-18 23:57:20 +02:00
Vadim Yanitskiy 976e7e51e6 rsl: do not blindly ignore unhandled/unknown Channel Mode
Change-Id: I67a70132999be6580a29e6b814763309a6df4ae9
Related: SYS#4895
2021-04-16 20:57:08 +02:00
Vadim Yanitskiy 479ff386ff osmo-bts-trx: correct definition of 'osmotrx rx-gain' command
* Calling l1if_provision_transceiver_trx() yelds nothing.
* It does not apply immediately, full restart required.

Change-Id: I93c9e19d0543f19528cec842b8be332b4d93214e
2021-04-16 15:15:16 +00:00
Vadim Yanitskiy f88f539c77 l1sap: fix wrong IEI and parsing in l1sap_chan_act()
As the prefix in 'GSM48_IE_CHANDESC_2' implies, this IE belongs
to 3GPP TS 04.08 (or TS 44.018), so it can be used in the Radio
Resource assignment messages sent to the MS.  While in this
function we're dealing with 3GPP TS 48.058, and thus the IEI
may be (and actually is) different for the RSL messages.

Also, according to 3GPP TS 48.058, section 9.3.5, the Channel
Description IE is included together with its element identifier,
so we need to skip one byte when doing the pointer casting.

Change-Id: Id100f4c56fd5c1adad5d925d97240bed82981b9b
Related: SYS#4895, OS#4941
2021-04-07 04:55:48 +02:00
Vadim Yanitskiy 2915bbf4c5 l1sap: check BTS_FEAT_MULTI_TSC in l1sap_chan_act()
Instead of blindly assuming what the PHY does support, and what
it does not, let's check the related feature vector.

Change-Id: I699cdddbfab111855998853548d9cfe956f7c60c
Related: SYS#4895, OS#4941
2021-04-07 04:54:04 +02:00
Vadim Yanitskiy 1adcc27eb9 l1sap: use TLVP_PRES_LEN() macro in l1sap_chan_act()
Change-Id: I6793623622fd7303d7dc22117a163a6990497c28
Related: SYS#4895, OS#4941
2021-04-07 04:53:27 +02:00
Vadim Yanitskiy 180ddb0da3 l1sap: use the passed 'trx' pointer in l1sap_chan_act()
Change-Id: Id94363f2a22eb905ae01e68ddfdf48fc8c646aaf
Related: SYS#4895, OS#4941
2021-04-07 04:52:38 +02:00
Vadim Yanitskiy 9dd7e3c907 osmo-bts-trx: fix segfault on trx_phy_inst_open() failure
If for whatever reason it fails to initialize the TRXD or TRXC
interface, trx_phy_inst_open() would return an error.  This
would cause bts_model_phy_link_open() to call trx_if_close()
on each of the PHY links, including those that were never
opened.  This leads to a segfault in trx_if_close().

Make sure that in trx_if_init() we properly init 'struct trx_l1h',
so it's safe to call trx_if_close() at any time and in any state.

Change-Id: I1f128813528f505fede04799e84456f6271058d0
2021-04-01 15:21:44 +00: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
Vadim Yanitskiy ca1628fb7a osmo-bts-trx: fix: do not call trx_if_close() two times
It's called by trx_phy_inst_open() if trx_if_open() fails.

Change-Id: Ic672f865ab513043a58979471a254a59d44daa6d
2021-03-18 07:52:45 +01:00
Pau Espin 29c4f3173f bts-trx: reorder first timerfd schedule to decrease first timeout skew
By reordering the instruction, we scheduler the timerfd prior to
processing the FN on the upper layers. This means the first timerfd
expiration even will happen more inline with the expected time, that is,
CLOCK IND time + GSM_TDMA_FN_DURATION_nS.

Let T(trx_sched_fn) be the time spent executing function trx_sched_fn().
With previous order, the timerfd would have been scheduled later, which
in the end would mean expiration would happen at time CLOCK_IND +
GSM_TDMA_FN_DURATION_nS + T(trx_sched_fn), hence ending up with an extra
skew of T(trx_sched_fn) added by ourselves.
This extra skew added may be important specially at startup time (when
this code path is used), since usually the load in the system is high
and skew is usually already higher, which means helping crossing
unacceptable thresholds which may end up in osmo-bts-trx stopping with
"No clock from osmo-trx" reason.

Change-Id: Ie2ba35cd87f0bd4078ac3b4b5ec2eacad36c4258
2021-03-15 18:33:14 +01:00
Pau Espin 8593b38616 bts-trx: Drop duplicate set of last_clk_ind
These fields are always aready set by the only caller of the function
trx_setup_clock(), so there's no use in re-setting them.

Change-Id: Id8a7141984e07eb11abae08e0c63ae7ebc333511
2021-03-15 18:12:41 +01:00
Pau Espin 7a7beb9b35 bts-trx: Avoid submitting first data_ind with FN=0 to upper layers
It can happen that the first burst we receive after enabling the PDCH
channel (when PCU connects to the BTS) is bid!=0. As a result,
chan_state->ul_first_fn is never set and defautl value 0 in there is
passed to the upper layers. As a result, when the 2nd block is
transmitted, this time with correct FN, the PCU will see a huge jump in
FNs. Since in PDCH the bursts are always consecutive, let's simply use
bi->fn - 3 as a first_fn and be done with the issue.

Related: OS#5020
Change-Id: Ie982caeb29f3ffd880b44e88a89b85ea3e6e6947
2021-03-11 18:42:00 +01:00
Pau Espin 166b10059b bts-trx: Always submit rx PDTCH DATA.ind to l1sap
Similar to what we have been doing for TCH channels, we want to make
sure all MAC blocks get to the upper layers, even if containing invalid
data (flagging it with data_len=0) so that upper layers (osmo-pcu
through PCUIF in this case) can rely on FN clock without gaps due to
Rx errors.

Related: OS#5020
Change-Id: I343c7a721dab72411edbca816c8864926bc329fb
2021-03-11 17:41:48 +00:00
Pau Espin 6a1a5f988b l1sap: Transmit pdtch invalid MAC blocks to PCU
Similar to what we have been doing for TCH channels, we want to make
sure all MAC blocks get to the upper layers, even if containing invalid
data (flagging it with data_len=0) so that upper layers (osmo-pcu
through PCUIF in this case) can rely on FN clock without gaps due to
Rx errors.

Related: OS#5020
Change-Id: I0b04b013b7bad5ff53d6a969ff0128b37f7f62d5
2021-03-11 17:41:48 +00:00
Philipp Maier 3f3cdff773 l1sap: add logging and VTY introspection for ACCH repetition
At the moment osmo-bts is not looging much ACCH repetition related
information. This makes testing ACCH repetition difficult. Lets add some
debug output that informs the user when ACCH repetition is turned on or
off. Lets also add an ACCH repetition status display to the show lchan
VTY command.

Change-Id: I59d11fd03be3d29fb8a4279d9945b03006764c0e
Related: SYS#5114
2021-03-01 19:47:56 +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
Vadim Yanitskiy 8777b63ef8 ta_control: fix Timing Advance control for SDCCH channels
The check in lchan_ms_ta_ctrl() breaks Timing Advance control on
SDCCH channels, because 'num_ul_meas' wraps and never reaches 4.
Neither this check makes any sense for other channel types,
because lchan_ms_ta_ctrl() is always called in the end of the
measurement period.  Let's drop it.

Change-Id: I0b86d49ec00b38d0f309c56b2519e5d487f0b65b
Fixes: If7ddf74db3abc9b9872abe620a0aeebe3327e70a
Related: OS#5024
2021-02-20 22:46:24 +01: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
Philipp Maier db403a4e3e vty: dont put a colon after vty_out in cfg_out macro
The cfg_out macro is used like a function in the code below its
definition. This means a colon will follow after it is used. When
the vty_out call in the macro already has a colon the final result will
be vty_out(...);;. This works fine as long the macro is not used in one
line if/else if/else constructs without curly braces {}. The compiler
will interpret the double colon as two lines of code and run into an
error then. Lets fix this by removing the colon from the vty_cout in the
macro.

Change-Id: I2c23c38ce892067add0f95f3e504a9c559e24519
2021-02-15 17:24:42 +01:00
Philipp Maier b89632cc67 l1sap: fix comment: sapi number is missing
Change-Id: I7922a5da0cd75eddfe019f3f5bd041ad911f1dd2
2021-02-15 11:01:34 +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 7d29ff9345 ta_control: cosmetic: use correct naming for MIN/MAX constraints
Change-Id: I112e0b51df06984e2e3f9b567d6d9897e9f9ba28
2021-02-15 10:58:54 +00:00
Harald Welte 3215344300 add support for sysmoBTS 1003 aka "1002 with GPS and PoE"
There's a minor derivative version of sysmoBTS 1002 which has built-in
GPS and PoE.  We call it 1003 in the EEPROM. Let's treat it identical
to 1002 in the existing code base.

Related: SYS#5327
Change-Id: Ia558587d36a75a1db1951d25b471b3f2e78ef4c9
2021-02-15 10:57:58 +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 9eb37bc3cb GSMTAP: fix wrong naming of per-BTS SAPI commands
Change-Id: Ieb2d74475e4338e9dd5f3962cf14a0448de253f8
2021-02-13 05:11:30 +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 82aeeacd52 main: cosmetic: tweak deprecation warning messages
Change-Id: I0b87502b1af5b8ef8c235923bf966f0c76062993
2021-02-13 03:43:56 +01:00
Philipp Maier 6664f47ad7 l1sap: be sure that UL-SACCH repetition is turned off
At the beginning of repeated_ul_sacch_active_decision() The UL-SACCH
repetition capability is tested. If no UL-SACCH repetition is enabled
the function exits. However, we should also make sure that the struct
member that enabled UL-SACCH repetition on the lower level is set to
false as well. Normally that should be the case because it was never
set to true before, but it is better to be sure.

Change-Id: I76a841514eb955b93f2114470b2c80402cf6883c
Related: SYS#5114
2021-02-11 23:23:20 +01:00
Philipp Maier 76308ab3fb l1sap.c: be sure that FACCH repetition is turned off
At the beginning of repeated_dl_facch_active_decision() the ACCH
repetition capabilitiy flags (command only or all LAPDM frames) are
tested. If no FACCH repetition is enabled, the function exists. However,
we should also make sure that the struct memeber that enables FACCH
repetition on the lower level is set to false as well. Normally that
should be the case because it was never set to true before, but it is
better to be sure.

Change-Id: Id07091cc89352281b41532d583a8bc004477c71a
Related: SYS#5114
2021-02-11 22:58:34 +01:00
Philipp Maier 2b3aa67a7b l1sap: fix repeated_dl_facch_active_decision()
The function checks meas_res->rxqual_sub against the lower threshold
value in order to decide when to turn FACCH repetition off. This is not
correct. It should compare against rxqual instead.

Change-Id: Id4ab101d52f419583c4f4c8a6cf69af6c9097d25
Related: SYS#5114
2021-02-11 22:49:19 +01:00
Vadim Yanitskiy dabe5d0327 oml: ensure that IPA RSL Connect ACK/NACK contains all IEs
All IEs in the BSC originated message are optional, so we assume
default values for them.  Let's reflect them all in the ACK/NACK.

Change-Id: I5c73e83daad0cea07b9cb674c393e0bfc6268a61
Related: OS#3791
2021-02-10 15:06:54 +00:00
Vadim Yanitskiy 522a33fe82 oml: reuse the given msgb in oml_fom_ack_nack()
This would allow to compose ACK/NACK messages with additional IEs
not present in the original message.  Also, this change basically
eliminates unnecessary msgb_copy() / free().

Change-Id: I17f61636e9a144017e2c46b1540d152c21529391
Related: OS#3791
2021-02-10 15:06:54 +00: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
Vadim Yanitskiy 6b36cce2ea power_control: cosmetic: fix swapped {L,U}_RXQUAL_XX_P comments
Change-Id: I2fe198f9275f4e5407ad6fdfa68d4fa7d603e333
Related: SYS#4918
2021-02-07 23:03:04 +01:00
Vadim Yanitskiy bb04495251 oml: use regular TLVP_PRES() in rx_oml_ipa_rsl_connect()
Both NM_ATT_IPACC_DST_IP and NM_ATT_IPACC_DST_IP_PORT are defined
as TLV_TYPE_FIXED, and NM_ATT_IPACC_STREAM_ID is TLV_TYPE_TV, so
the TLV parser already does check the length for us.

Change-Id: I1e493e552bb22bb42bb196ce71214e28d23fd19e
2021-02-07 03:40:32 +00:00
Vadim Yanitskiy 187effa00d oml: make 'struct tlv_parsed' pointer const where possible
Change-Id: I077f5aba50cc4d1a86feff527784de07394c5c0a
2021-02-07 03:39:53 +00:00
Vadim Yanitskiy fe45b4eb1f oml: avoid redundant ntohl() / htonl() conversion
Change-Id: I2ae84dcd2987ff0cee5ca06ced06e65a30847a81
2021-02-07 03:39:53 +00:00
Vadim Yanitskiy a2da0e96e1 vty: register libosmocore's FSM introspection commands
Change-Id: I1eb203673259b455c339784719e288bac14145c0
2021-02-06 16:50:44 +00:00
Vadim Yanitskiy f7afeb1fa9 oml: cosmetic code style changes in rx_oml_ipa_rsl_connect()
Change-Id: I2841e15865596bbb24cfe1f27691404514d3b6f0
2021-02-06 15:14:05 +01:00
Vadim Yanitskiy 5ca7707e85 osmo-bts-trx/scheduler: use DMEAS in trx_sched_meas_avg()
Change-Id: I68a37e17469ec9f8178fd2027b8860dbc643a4f9
Related: OS#5007
2021-02-05 16:41:27 +01:00
Philipp Maier ed7bca6b33 pcu_sock: fix uninitalized returncode value
In function pcu_tx_si_all(), the variable rc is not initalized. If
pcu_tx_si() fails, then rc is populated with value -EINVAL, but if all
si transmissions succeed, which is the normal case, rc remains
uninitalized.

Change-Id: I571fdb4f175fb259b77f989554f569fc2230dfe6
Related: CID#216932
2021-02-04 14:08:42 +00:00
Vadim Yanitskiy f7c7d2baf6 pcu_sock: pcu_tx_si_all(): fix returning ununitialized rc
Change-Id: Ic78614bebade701db14439aa64ecf89c7104a639
Fixes: CID#216932
2021-02-04 13:40:24 +01:00
Vadim Yanitskiy df80385f26 pcu_sock: pcu_tx_si_all(): cosmetic coding style change
Change-Id: I11f60ecdd3cfa2132d58fd3034bfe7419df0edb6
2021-02-04 12:50:19 +01:00
Vadim Yanitskiy ac38cf8e90 pcu_sock: pcu_tx_si_all(): make 'si_types' const
Change-Id: I0a6b0191187af2e14c9264c571afe53fc256d8ce
2021-02-04 12:49:17 +01:00
Harald Welte 6eb98ab25c Use osmo_fd_*_{disable,enable}
Depends: libosmocore.git Idb89ba7bc7c129a6304a76900d17f47daf54d17d
Change-Id: I0da17d851ccb83c28a70c9039d0a4d1fe63da0ec
2021-02-03 10:41:16 +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
Oliver Smith 23ff5f8861 common/measurement.c: fix gcc 4 + -std=gnu11 error
GCC-4 doesn't like static const struct foo bar = (struct foo)...:
  measurement.c:33:1: error: initializer element is not constant

Related: OS#5004
Change-Id: Iec5a4006dfc90abe240fcf8b6c2fefd4f7071a70
2021-02-02 13:33:04 +01:00
Neels Hofmeyr 10272f7702 chan activ: activate DL SACCH only when TA is known
A channel activation for handover to another cell does not know the
Timing Advance until the handover RACH is received. It does not make
much sense to enable downlink SACCH without an accurate TA.

If the BSC omits the Access Delay IE (a.k.a. the Timing Advance), do not
enable downlink SACCH. This is expected to happen only for inter-cell
handover. In all other situations, the TA should be known either from a
Channel Request RACH for Immediate Assignment, or from the previous
lchan on the same cell upon Assignment / intra-cell handover.

Related: OS#4008 OS#4009 SYS#5192
Change-Id: I170b63c9856230d5f1a10654a9d950ada8e730d7
2021-01-28 23:57:10 +01:00
Vadim Yanitskiy f7cf5e2612 power_control: clarify the meaning of 'delta' in logging messages
One part of the algorithm simply provides a _suggested_ 'delta' that
needs to be applied to the current power level, while the other part
ensures that this suggested value does not exceed the limits.  Thus
it's possible that some logging messages would state that the power
reduction value remains unchanged, while the 'detla' != 0.

Change-Id: I7496a158b9ac6074a965056d708d8078a98cb1aa
Related: SYS#4918
2021-01-24 16:21:32 +01:00
Vadim Yanitskiy a81dfdb096 l1sap: include Uplink RSSI in GSMTAP packets
Change-Id: I99a257c0320b08b62270a35796bee7f8e862e3ab
Related: SYS#5073
2021-01-23 17:32:56 +01:00
Vadim Yanitskiy 3992249c64 l1sap: fix gsmtap_ph_{data,pdch,rach}(): use 'const'
Change-Id: If353ba78b59af2b0a62bbd0c812a46990b07776f
2021-01-23 17:30:00 +01:00
Vadim Yanitskiy dc61d6032b vty: add expert commands for MS/BS power control
These new commands are useful for debugging MS/BS power control
loops, e.g. one can change power control mode, overwrite the
current BS power reduction or MS power level at run-time.

Change-Id: I1ebb033b02c2bc3b1fa7de874e0035a07297f266
Related: SYS#4918
2021-01-20 23:54:54 +01:00
Vadim Yanitskiy f416e5a01c vty: make commands related to the loopback mode hidden
The loopback mode was added for testing, and may be dangerous if
enabled in production.  Let's make it appear only in expert mode.

Change-Id: I3f68acd7f2b0231f78516f59fb5e8ef56fb69dbf
2021-01-20 23:54:05 +01:00
Vadim Yanitskiy 510a47818a vty: extend trx / lchan number range in BTS_T_T_L_CMD
Change-Id: I8d8a4c46909daa0f2682d9662db8dffb4fbd8422
2021-01-20 22:06:08 +00:00
Vadim Yanitskiy 66637c68ae vty: add macro for 'bts <0-0> trx <0-0> ts <0-7> lchan <0-1>'
Change-Id: If8e1ee87366a0d301e21161f2d9ddde8383cb744
2021-01-20 22:06:08 +00:00
Vadim Yanitskiy 2627c28188 vty: fix error messages in lchan specific commands
Change-Id: Ic0fba0605fc8a3ffa044f65fdad03b95e7cd8331
2021-01-20 22:06:08 +00:00
Vadim Yanitskiy 66f76223c4 power_control: fix: properly print 'delta' applied to attenuation
Change-Id: I178df05c1a4cb982279b21d07bd69f75b44928da
Related: SYS#4918
2021-01-20 22:04:55 +00:00
Vadim Yanitskiy 3e1dad2a37 power_control: print current RxLev and lower/upper thresholds
This makes the logging messages easier to read and understand.

Change-Id: I5f8c987054b2b01acdb9f525d06ca15bbc577070
Related: SYS#4918
2021-01-20 22:04:55 +00:00
Vadim Yanitskiy bb6765a93c paging: refactor and optimize fill_paging_type_1()
As far as I can see from my perf measurements, bitvec_fill() is called
quite often and takes 0.27% of the CPU.  A more detailed look reveals
that it's indirectly called by fill_paging_type_1() in order to fill
the remaining octets with constant '2B'O padding.

Let's optimize this function:

  - use memset() for padding *before* writing optional P1 Rest Octets;
  - conditionally initialize the bit vector for P1 Rest Octets;
  - use designated initializers instead of memset().

It's generally better to avoid using bitvec_fill() when using memset()
is possible, because the former operates on bits rather than bytes.

Change-Id: I90473356b396e5dd9326598aca025afacca4afc8
2021-01-15 17:36:46 +01:00
Vadim Yanitskiy cd30a40be1 power_control: BS power shall not be reduced on C0
It does not make sense to trigger the BS power control loop on C0,
as it's only allowed to reduce power on additional transceivers.

Change-Id: I4fdfe097ae6f9edde5f39ed4da8a559a14b3b38f
Related: SYS#4918
2021-01-13 09:52:58 +00:00
Philipp Maier 25b11f473a l1sap: use rxlev_full when no DTX was used
At the moment only rxlev_sub is used to decide when the facch repetition
should be activated, regardless if DTX is used. Lets check if DTX is
actually used and use rxlev_full when DTX is not applied.

Change-Id: I01ba57cf661f0e41b8df209c905f8d135013e472
Related: SYS#5114
2021-01-13 00:32:26 +01:00
Philipp Maier b327c9598c l1sap: acch_repetition fix hysthereis threshold table
The table in repeated_ul_sacch_active_decision() is derived from the
second table in GSM 05.08 8.2.4 but the first table would be correct.
Also the lower threshold is not properly choosen. A lower threshold,
that derives from upper threshold shifted by 2 makes sense (BER must
improved by 2 RXQUAL steps before repetition is turned off.)

Change-Id: I1d9b5c8abb79938cdecdafed84ed2e5d47e0bd3a
Related: SYS#5114
2021-01-12 22:35:56 +01:00
Vadim Yanitskiy ef53ffe8bb power_control: rework handling of DL RxQual measurements
This change makes BS power control loop:

  - take the lower RxQual threshold (L_RXQUAL_XX_P) into account, so
    the BS power is increased only if RxQual exceeds this threshold;

  - apply the configured increase step size instead of reducing the
    current attenuation by half.

MS power loop is not affected, it does not even handle RxQual yet.

Change-Id: Ib3c740b9a0f3ba5dfb027e144dc13f456cb26ae2
Related: SYS#4918
2021-01-08 20:14:00 +01:00