Commit Graph

653 Commits

Author SHA1 Message Date
Mychaela N. Falconia c18f9f256c all models, HR1 codec: select RTP output format via vty option
The new vty option "rtp hr-format (rfc5993|ts101318)" selects the
RTP output format to be used for HR1 codec, consistently across
all models.  The default is set to match legacy behavior: ts101318
on osmo-bts-{lc15,oc2g,sysmo} and rfc5993 on osmo-bts-trx.
On models where no legacy behavior is applicable, the default is
set to rfc5993 as a forward-looking measure - see OS#6036.

Closes: OS#5688
Change-Id: I168191874a062429a57904511a1e89e3f588732e
2023-05-27 10:24:09 +00:00
Mychaela N. Falconia 208127986e refactor: replace rtppayload_is_valid() with preening before enqueue
Up until now, our approach to validating incoming RTP payloads and
dropping invalid ones has been to apply the preening function inside
l1sap_tch_rts_ind(), at the point of dequeueing from the DL input queue.
However, there are some RTP formats where we need to strip one byte
of header from the payload before passing the rest to our innards:
there is RFC 5993 for HR codec, and there also exists a non-standard
extension (rtp_traulike) that does a similar deal for FR and EFR.
Because of alignment issues, it will be more efficient (avoids memmove)
if we can do this header octet stripping before we copy the payload
into msgb - but doing so requires that we move this preening logic
to the point of RTP input before enqueueing.  Make this change.

Related: OS#5688
Change-Id: I7fc99aeecba8303b56d397b8952de5eea82b301e
2023-05-26 16:05:23 +00:00
Vadim Yanitskiy 2c511d5755 copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
Change-Id: Ib0bed7a4196305e2b413ca657f4fa8fb6f0d39f6
2023-05-19 08:50:18 +00:00
Philipp Maier 0eb90a0a98 paging: cosmetic: rename all IMM.ASS references to MAC block
The paging interface towards the PCU has a confusing API. In fact what
the PCU does when it wants to page or do an immediate assignment is
sending a ready formatted MAC block to the BTS. The BTS then puts this
MAC block in the paging queue and then eventually it justs sends it
without looking at the contents. For the code in paging.c it is not
imortant if the MAC block is an immediate assignment, it only cares if
the paging record contains a MAC block or paging parameters.

Related: OS#5927
Change-Id: Ifab37fdedaba98b160718113767e4ef6ee7d16ad
2023-05-16 11:38:56 +02:00
arehbein cf8736e916 gsm_objclass2obj(): Change signature/set NACK cause
- Add out-parameter to enable returning a NACK cause (ignored if NULL)
 - Return appropriate NACK cause if TRX number is unknown (fixes OS#5967
   together with change I37e6b23ed95260a8188910cf9754faffcba519c5)

Change-Id: If734ea2c8cae4c1f99b02520dffa4e3862a67745
Related: OS#5961, OS#5967
2023-04-29 02:51:12 +07:00
arehbein 204cd4d7e3 gsm_objclass2mo(): Change signature/set NACK cause
- Add out-parameter to enable returning a NACK cause (ignored if NULL)
 - Return appropriate NACK cause if TRX number is unknown (part of fix
   for OS#5967)

Change-Id: I37e6b23ed95260a8188910cf9754faffcba519c5
Related: OS#5961, OS#5967
2023-04-29 02:51:12 +07:00
Vadim Yanitskiy 1d7133e936 fixup: common: Remove unused function gsm_objclass2nmstate()
Change-Id: I31b948f2aeb18ac8069fc019285be7991cffe064
2023-04-29 02:49:34 +07:00
Vadim Yanitskiy 11ec99d419 flags: group BTS_INTERNAL_FLAG_* into an enum
Change-Id: I4c7d9f6dce61f7690b86c3973b13ddb63cdace04
2023-04-21 17:07:33 +07:00
Pau Espin 38491d813b Move pcu_sock_state to gprs section of bts_sm
Change-Id: I7d739287fd11f81ce657bac362e55fa822fb0ef5
2023-04-11 11:35:34 +02:00
Pau Espin b07e19d185 Properly report all states through NM FSM upon OML link up
Change-Id: Ic3358629d17baab46f467a1ab82eea1837ad7390
2023-04-11 11:16:21 +02:00
Pau Espin 36ef885a6c Drop NM_EV_BBTRANSC_INSTALLED in favour of generic NM_EV_SW_ACT
All the other objects already use that one; there's no need to have a
specific one for the NM Channel FSM.

Change-Id: Ic5fd37367b500c75a0a53b1d868ba2aed3edef1b
2023-04-11 11:16:21 +02:00
Pau Espin 7cd45a7cfe Move GPRS NSE under BTS SiteMgr
As per ipaccess expectancies and following TS 12.21.

Change-Id: If44d8f256cab7b2660900cedfb0ed9fe67eb3420
2023-04-11 11:15:07 +02:00
Pau Espin 6be13437b7 Merge gsm_network into gsm_bts_sm and place gsm_bts under it
This way the data model in TS 12.21 (Figure 1) is followed, where
there's a BTS Site Manager containing one or more BTS. In our case we
only support 1 BTS (cell) so far.

Change-Id: Ideb0d458ec631008223f861cf8b46d09524a1a21
Related: OS#5994
2023-04-11 11:11:45 +02:00
Pau Espin 66543fe422 Introduce NM FSM for GPRS NSVC object
Change-Id: I684482064136a461d01cace3cd37afc8b68458cc
Related: OS#5994
2023-04-11 08:11:43 +00:00
Harald Welte c3d839be9e cosmetic: Change LOGPLCFN argument order
As it has come up during code review of Change-ID
I214af0448652a9f321ccbab77977b67663ba28f9 introducing LOGPLCNF, my
approach to the strict preserval of argument order (lchan first from
LOGPLCHAN and fn *after* loglevel from LOGPFN) was considered
sub-optimal.

I used the following spatch rule to clean this up:

@@
expression lc, ss, logl, fn;
expression list trailer;
@@

-LOGPLCFN(lc, ss, logl, fn, trailer);
+LOGPLCFN(lc, fn, ss, logl, trailer);

Change-Id: Iba4a8416545673d03cb057e4855f8b1ecae3e1ec
2023-04-09 14:10:09 +00:00
Pau Espin 9c4b472179 Move NSVC structs to be part of NSE
The NSVCs exist inside an NSE. Rearrange data model to have proper
relations.

Change-Id: I1cfe9366594836c622673d461ab8b2edd1a2b58a
2023-04-06 10:28:22 +00:00
Pau Espin 10d5499d03 Rearrange declaration of struct gsm_bts_gprs_nsvc
Move it together with the other similar objects like gprs_nse and
gprs_cell.
Move the "mo" field to the start of the struct, similar to the other
types.

Change-Id: I5dc020a6bab8c94ab831b6ca506bc5cb681d07a3
2023-04-06 10:28:22 +00:00
Pau Espin d50d239914 Introduce NM FSM for GPRS Cell object
Change-Id: I5fd1d17da09a5f0eee3d69fcb4788c106a240e21
Related: OS#5994
2023-04-06 10:28:22 +00:00
Pau Espin 633bbf174a Introduce NM FSM for GPRS NSE object
Related: OS#5994
Change-Id: I01eadc63214a2eb5e1bce455c7e5b62bd41905ea
2023-04-06 10:28:22 +00:00
Pau Espin cea6c230ad nm: Apply OPSTART through NM FSMs
This way we have further control on how to handle the OPSTART messages
received. For instance, NACK them if the NM object FSMs are not at the
expected correct state.

Related: OS#5992
Change-Id: I5df0bfb4cc812c11c7a00a8ffa882ae1915d562f
2023-04-06 10:28:22 +00:00
Pau Espin 91a1295a5a bts_model_apply_oml(): Improve definition of parameter
The param is usually called obj_class, but here it is called kind.
In any case, change the param to pass the related struct gsm_abis_mo
(which still contains mo->obj_class), similar to what's done in other
bts_model functions such as bts_model_opstart().

Change-Id: Ife2e98a791455d5f7e7052356d559af2f1d4d185
2023-04-06 10:28:22 +00:00
Pau Espin 8894fe6f4c oml: Get rid of unused tlv_parsed param in bts_model_apply_oml()
This way we simplify the common lower level interface. It can be added
in the future again if it is really required at any point to pass/use
specific TLV values in the device-specific code.

Change-Id: I64c6c6834e277b1d75a97d6f408e7e1b7ca85832
2023-04-06 10:28:22 +00:00
Pau Espin aebd2a21b5 nm: Drop NM_EV_SETATTR_{ACK/NACK}
Simply return error codes from lower layer implementations, and do
the OML handling in the common NM TS 12.21 FSMs.

As a result, we simplify the logic in the lower layers.

Change-Id: I281c07bb5ad88ee03542f092141cebe036d10aee
2023-04-06 10:28:22 +00:00
Harald Welte 8c397da917 logging: Introduce LOGPLCGT()
We have LOGPLCHAN and LOGPGT, but not a combined version for logging
both the lchan and the gsm_time.  Let's resolve this.

Log messages without indicating the lchan name are pretty useless if you
have multiple concurrently active lchans...

Change-Id: I4bf3363f92acdf67d8e7333e30ac2209e31cb287
2023-04-05 17:56:00 +00:00
Pau Espin c4a17d35ec nm: Apply BTS/TRX/TS OML Attributes through NM FSMs
This way we have further control on how to handle the SetAttr meessages
received. For instance, NACK them if the NM object FSMs are not at the expected
correct state.

The originating msgs are now kept owned and freed by the OML layer
(oml.c), and the NM FSMs only uses them and create new OML msgb when
answering with ACK/NACK.

Related: OS#5992
Change-Id: Id68868e25bbf96227ab6459fcd3c9181852ed28e
2023-04-05 13:21:14 +02:00
Pau Espin 914e55caf3 Clarify configuration of TSC on each timeslot
Related: OS#5856
Change-Id: Ief21daf63ba76725de9117cbe14ada8b75f147df
2023-04-04 12:50:20 +02:00
Mychaela N. Falconia c29ca5eb7d common: implement rtp continuous-streaming mode
In some environments it is highly desirable for the RTP stream
coming from each GSM call UL on a BTS to be fully continuous,
without any gaps, with _some_ RTP packet emitted every 20 ms,
even if there is no speech or SID frame to be sent in that frame
time window.  The present change adds an rtp continuous-streaming
vty option which, when enabled, causes the BTS to emit RTP packets
with a zero-length payload, instead of producing gaps in the RTP
stream, when it has nothing else to send.

Related: OS#5975
Change-Id: Ic0e2edf2ed90ba0ac6bee5e7d9629bf0255e256d
2023-03-29 12:01:26 +00:00
Harald Welte a563640f86 Introduce LOGPLCFN() for logging lchan-name + frame number
So far, we've had LOGPLCHAN() and LOGPFN().  This resulted in a number
of log lines containing frame numbers *not* containing the lchan
context, which makes it difficult to deterine which of potentially many
concurrently active lchans is logging.

Let's introduce LOGPLCFN() for a FN-extended version of LOGPLCHAN(),
and convert all callers that have the related context.

Change-Id: I214af0448652a9f321ccbab77977b67663ba28f9
2023-03-28 15:12:10 +02:00
Vadim Yanitskiy 8e04613e4f osmo-bts-trx: properly activate [CBCH/]BCCH/CCCH
The timeslot carrying BCCH/CCCH on C0 is a bit special in a way that
it's being activated implicitly - there is no explicit RSL CHANnel
ACTIVation for that.  This is why we have TRX_CHAN_FLAG_AUTO_ACTIVE,
which marks sub-channels of BCCH/CCCH in the trx_chan_desc[].

The upcoming patch changes the burst buffer allocation strategy, so
that the memory is allocated on channel activation and then free()d
on channel release.  This patch facilitates that by making the
activation/deactivation logic consistent for all sub-channels.

Change-Id: Id0c70d6a2b777a5117c85149bfa1b3a997299d1d
Related: OS#1572
2023-03-22 12:14:25 +00:00
Pau Espin 48b00783f8 cosmetic: bts_trx.h: Fix whitespace
Change-Id: Ibcc3578cce23767445e53149796d0bd79f81ead8
2023-03-17 15:47:49 +01:00
Max f19f533139 GSMTAP: allow configuring local address
Change-Id: If047cbaf95b343ee115690bf7a724a8edc5df735
2023-03-04 11:24:37 +00:00
Vadim Yanitskiy dfe96b786f paging_add_imm_ass(): remove meaningless from_pcu argument
A request to send an Immediate Assignment over the PCH (not AGCH)
is always coming from the PCU.  It's used for DL TBF assignment.

Change-Id: If4b0aa01532ab65b96201ff8829e724c67df6993
2023-03-01 03:01:46 +07:00
Max 6a6a47f554 ctrl: take both address and port from vty config
Change-Id: Ieca05004255c40287e6427560c2636b39529cf07
2022-12-22 09:40:08 +00:00
Daniel Willmann 63baf960c6 shutdown_fsm: Add power_ramp_force() to jump straight to the tgt power
Both power_ramp_start() and power_ramp_force() are now small macros
around _power_ramp_start()

The new behavior is:
* ramp down power when stopping bts through Ctrl-C
* the other shutdown causes skip power ramping

This will cause the bts to reconnect faster when the oml link is
dropped and power ramping is enabled.

Change-Id: Ida1d7bbf094958b9142af306dbf84206729a609e
Related: SYS#6237
2022-12-21 23:51:51 +00:00
Daniel Willmann 300b72b44c Revert "shutdown_fsm: Only ramp down power when stopping bts through Ctrl-C"
This reverts commit c96d34f828.

Reason for revert: This breaks ramping up power since the power ramp logic still assumes the output is full power.

Change-Id: I47a16a4b3ba02d74473569c0f4350a41fc12a464
2022-12-17 13:21:17 +00:00
Daniel Willmann c96d34f828 shutdown_fsm: Only ramp down power when stopping bts through Ctrl-C
For the other shutdown causes power ramping doesn't make sense. Instead
shutdown quickly so we can reconnect faster

Change-Id: I71c46478b8f3b236dba3e959fc75e58c0409517f
Related: SYS#6237
2022-12-15 11:26:22 +01:00
Philipp Maier c2261bb62e pcuif_proto: use define constant to specify nax number of trx
The array of trx in gsm_pcu_if_info_ind can hold trx 8 items. Lets use a
define constant to specify the size of that array.

Change-Id: I5fdd5b9e59865fabd0340650ecb347d52208ebe9
2022-12-14 12:43:50 +01:00
Philipp Maier aa8779b824 pcuif_proto: cosmetic: add constant PCU_IF_NUM_NSVC and replace magic numbers
The number of NSVCs is fixed but lets not use magic numbers to define
the sizes of the arrays that hold the config values. In osmo-pcu there
is already a define constant, so lets use a define here as well.

Change-Id: If7fa44abb86c18900110d7ee81fe6140c8c4635b
2022-10-31 10:22:17 +00:00
Philipp Maier ea35b26b35 rsl: use unsigned int
The parameter l3_len in rsl_tx_meas_res() is defined as int, even though
it can't be negative. Lets use unsigned int for l3_len.

Change-Id: I99068a36e74a557000f406154dce32300615086c
2022-10-12 18:20:14 +07:00
Vadim Yanitskiy 2950c0363d osmo-bts-trx: handle MTS 0b0110 indicating an Access Burst
The PCU may poll the MS requesting an ACKnowledgment message to be
sent in form of four Access Bursts instead of Normal Bursts.  The
BTS has no prior knowledge of the Uplink burst type, so a new MTS
value was specified in order to prevent the BTS from trying to
decode Access Bursts as a PDTCH block.

This patch implements parsing of the new MTS value 0b0110.
Signalling RACH.ind to the PCU is to be implemented.

Change-Id: I0fbb63006797e6be386d1f76ed97fff098c036fc
Related: OS#4006, SYS#4794
2022-10-04 16:33:10 +00:00
Philipp Maier ae6ae89a19 pcu_sock: fix sourcecode formatting
Change-Id: Ib88173363fc11ad44a5bdbcd85ea8ca075db7997
2022-09-26 13:02:34 +02:00
Pau Espin 2201900f94 Introduce Osmux support
Related: SYS#5987
Requires: libosmo-netif.git Change-Id I632654221826340423e1e97b0f8ed9a2baf6c6c3
Change-Id: Ib80be434c06d07b3611bd18ae25dff8b14a7aad9
2022-09-13 17:32:22 +02:00
Pau Espin 755546028e Move lchan_dl_tch_queue_enqueue to lchan.c and make it public
It will be used too by osmux code present in another file. This is a
preparation commit to simplify the one adding osmux support.

Change-Id: Ie7fa57bb04db9ad9b03971467e12ee7b8e4c190a
2022-08-11 23:04:46 +02:00
Pau Espin 7593cc743d Use libosmocore API msgb_queue_free() to free lists
There's no need to maintain a duplicate msgb_queue_flush(), which
returns the amount of freed messages (feature not used at all by the
callers).

Change-Id: I9841e18ca0b7b852130bbb02a510e43a3b3fd93f
2022-08-11 23:04:46 +02:00
Pau Espin 9ea93c7e20 Avoid counting lchan->dl_tch_queue length every time a msg is enqueued
The queue_limit_to method iterates the entire list of messages every
time a new message is added. Let's use msgb_{enqueue,dequeue}_count()
APIs to do that in constant time. It is true that since the queue is
limited to 1, there's usually at most 1 item in the queue so it's not a
real problem. However, when we add Osmux in the future, we may need to
tweak the amount of messages which can be in the list, due to Osmux
batching mechansim which may be more bursty sometimes.
In any case, this change doesn't make things worse for sure.

The patch also takes the chance to group the queue_limit_to + enqueue
into one function to avoid having the code spread several times.

Change-Id: I61818a3bb521c27bd21a8b6fa70581d27638ec9b
2022-08-11 23:04:35 +02:00
Pau Espin 5a1b14fa4f Split out lchan rtp socket creation from rsl handling code
This makes the code more clear, as well as allows adding Osmux in the
future.

Change-Id: Iade43fde7f6113f9d68539f7d6cc9843783c2b3f
2022-08-11 21:02:06 +02:00
Vadim Yanitskiy 541b7525ae osmo-bts-trx: amr_loop: trigger the loop unconditionally
The logic responsible for enabling and disabling the loop appears
to be broken: during my experiments trx_loop_amr_set() was never
called with loop=1.  It's not clear what's the motivation behind
this breaker, so I propose to rip it out for now.  This patch
finally makes the loop work (confirmed with a TEMS phone).

Change-Id: I09b649973d4269c4082a4fafa493c37825f95a9c
Related: SYS#5917, OS#4984
2022-08-08 05:43:20 +00:00
Vadim Yanitskiy 523b6de593 struct bts_ul_meas: reflect C/I units in field name s/c_i/ci_cb/
Change-Id: If07f7f2a3ea996cbfc6a9087fa34402e38a7fd9f
Related: SYS#5853
2022-05-10 01:19:17 +03:00
Vadim Yanitskiy cf09b0cb50 scheduler: trx_sched_is_sacch_fn(): make ts pointer const
Change-Id: I48a1a549d7c1553bccaa01cdc818873a4c6cdf0a
2022-05-10 01:19:17 +03:00
Vadim Yanitskiy 8aab8d484b osmo-bts-trx: drop Uplink loss detection from Downlink path
Attempting to detect missing Uplink frames in the *Downlink* path
is an ugly hack, that was needed before we had proper per-lchan
detection of missing bursts and NOPE indications in TRXDv1.

* [1] per-lchan detection of missing bursts was fixed in Aug 2018.
* [2] TRXDv1 support was introduced in Jul 2019.

Today is 2022 and it makes no sense to keep this hack.  Even if
the transceiver does not support TRXDv1, per-lchan detection
will compensate the missing Uplink bursts.

Change-Id: Ic292d180ba64206fb4d88adb284f9f9d058b4587
Related: [1] I70d05b67a35ddcbdd1b6394dbd7198404a440e76
Related: [2] If61c71d20d590bf07bfd019afb33000a0b6135bd
2022-05-06 12:55:18 +00:00
Vadim Yanitskiy 44cb0113cf osmo-bts-trx: use C/I in the AMR link adaptation loop
Change-Id: Ide84bf864f56020c0265cfb9731615d4f7bad7f5
Related: SYS#5917, OS#4984
2022-04-20 12:18:08 +00:00
Vadim Yanitskiy fe21e88630 struct amr_multirate_conf: remove ms_mode[], raname bts_mode[]
Looks like this structure was copied from openbsc/osmo-bsc as-is.
The ms_mode[] makes no sense in the context of BTS, so remove it
and rename bts_mode[] to mode[] for the sake of brevity.

Change-Id: I7442360ed857554440a0b9854f2d2bbab9dc5a71
Related: SYS#5917, OS#4984
2022-04-17 13:14:59 +00:00
Vadim Yanitskiy cf3d314501 rsl: use hard-coded defaults if the MultiRate conf IE is absent
This configuration will be used as a fall-back when the MultiRate
configuration IE is not included in the CHAN ACT/MODIFY messages.

Change-Id: Ie96af636105ee1ffe2d9a0bd9eea375faebad149
Related: osmo-bsc.git Ic5f8d55d250976d8d4c9cae2d89480fd52326717
Related: SYS#5917, OS#4984
2022-04-13 18:04:20 +03:00
Vadim Yanitskiy bab872cc0d l1sap: l1sap_chan_act(): remove unused *tp argument
Change-Id: I2030f05b55fc9370e71ff12b26ffe1142f4acfc8
2022-04-13 15:03:20 +00:00
Vadim Yanitskiy 12b3921a4a osmo-bts-trx: rx_{tchf,tchh}_fn(): get TDMA FN from meas history
Once we have an Uplink speech or FACCH frame decoded, we need to
hand it over to the upper layers indicating TDMA frame number of
the *first* burst corresponding to the beginning of a block.

Currently we use libosmogsm's gsm0502_fn_remap() API to calculate
the first TDMA frame number from the given last frame number.
This API involves iterating over the pre-calculated offset tables
for different channel and payload types, and thus imposes some
additional CPU cycles.  Another downside of the current approach
is that we have to perform such lookups several times for each
decoded L2 frame, e.g. for FACCH on TCH/AHS we do it three times!

In this patch I propose an alternative approach of storing TDMA
frame numbers in the measurement history, together with the
associated samples.  This way we can easily get N-th frame number
from there without performing any additional computations, other
than what we already do during the measurement processing.

Change-Id: Id9a2b7b0f1a1ad7cfbbab862faf521e135c90605
2022-04-05 13:45:31 +00:00
Vadim Yanitskiy da433bba7b osmo-bts-trx: rx_tchh_fn(): get rid of chan_state->meas_avg_facch
FACCH/H takes out two speech frames, so we send two BFIs once we
have received it in rx_tchh_fn().  The upper layers responsible
for handling of the Uplink measurements expect a fixed amount of
measurement samples, so currently we do:

* send a FACCH frame with the associated measurememnts (S6N6),
* send the 1st BFI with invalidated measurements (RSSI=0),
* send the 2nd BFI with the stored measurememnts of FACCH.

This is achieved by preserving a copy of the FACCH measurememnts
in chan_state->meas_avg_facch and then using it two bursts later.

The same goal can be achieved a lot easier by sending the associated
measurements with both BFIs as if no FACCH was received:

* send a FACCH frame with invalidated measurememnts (RSSI=0),
* send the 1st BFI with the associated measurememnts (S6N4),
* send the 2nd BFI with the associated measurememnts (S6N4).

This eliminates the need to store anything outside of the existing
measurement history and simplifies the code a lot.  Also, this
eliminates the need for using a dedicated averaging mode S6N6.

Varified by running BTS_Tests.TC_meas_res_speech_tchh_facch.

Change-Id: I7902b4709bc3f418174e8373f52e87bb31cdc826
Related: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91
2022-04-05 13:45:31 +00:00
Vadim Yanitskiy bd7ef4101b osmo-bts-trx: rx_tchh_fn(): indicate BER10k=0 for FACCH BFIs
It makes no sense to store BER10k value of an Uplink FACCH frame
in order to indicate it in a BFI later on.  Given that these BFIs
are generated artificially, it's fine to indicate BER10k=0.

Change-Id: I24d12892760dca0ad0a5c2abca9fc66523d9e614
Related: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91
2022-04-05 13:45:31 +00:00
Vadim Yanitskiy 35e601a322 osmo-bts-trx: rx_tchh_fn(): use proper meas averaging mode
Compared to TCH/F, TCH/H is a bit special in a way that:

* speech frames are interleaved over 4 consecutive bursts,
* while FACCH frames are interleaved over 6 consecutive bursts.

This is why in rx_tchh_fn() we allocate a buffer large enough to
store up to 6 bursts.  Let's say we have that buffer filled up
completely with all 6 bursts (from 'a' to 'f').  Now attempting
to decode them may yield either a speech frame or a FACCH frame:

  +---+---+---+---+---+---+
  | a | b | c | d | e | f |  Burst 'a' received first, 'f' last
  +---+---+---+---+---+---+
   ^^^^^^^^^^^^^^^           Speech frame (bursts 'a' .. 'd')
   ^^^^^^^^^^^^^^^^^^^^^^^   FACCH frame  (bursts 'a' .. 'f')

For FACCH we use measurement averaging mode SCHED_MEAS_AVG_M_S6N6,
so that 6 last samples are averaged - so far so good.  For speech
we use SCHED_MEAS_AVG_M_S4N4, so that 4 last samples corresponding
to bursts 'c', 'd', 'e', 'f' are averaged - this is wrong.

We actually need to average the *first* 4 samples corresponding to
bursts 'a', 'b', 'c', 'd' in the case of speech.  Let's add and use
a new averaging mode SCHED_MEAS_AVG_M_S6N4 for that.

Change-Id: Iea6f4e5471550f4c2b57aaebeac83c80e879489d
2022-03-18 03:53:08 +03:00
Vadim Yanitskiy 2de4d9baa8 osmo-bts-trx: use consistent naming for 'enum sched_meas_avg_mode'
This is a purely cosmetic change.  The new naming clearly indicates
how deep to go back in the measurement history (S) and how many
samples to average (N).  For example:

* SCHED_MEAS_AVG_M_S4N4 - go S=4 steps back and average N=4 samples;
* SCHED_MEAS_AVG_M_S6N2 - go S=6 steps back and average N=2 samples.

Change-Id: I96a8dd08084c7c179f879fc00e75c5edcfb11caa
2022-03-18 03:53:02 +03:00
Vadim Yanitskiy df505a503f logging: get rid of logging category DSUM
DSUM is somewhat similar to DMAIN, generic logging category used
in other Osmocom projects.  This category is rarely used in a few
places, where the other categories could fit better.  Remove it.

Change-Id: Ia9db783bc92b23ba87b4fdf1e4ed07d59ea6bbce
2022-02-08 14:31:58 +06:00
Pau Espin 02532bafb8 bts_shutdown_fsm.h: Remove wrong comment describing enum
Change-Id: I963234255ce5a648a842ae6dbfd9966a694d0c09
2021-11-23 14:32:26 +01:00
Vadim Yanitskiy 9833a4e198 [overpower] Turn it on and off depending on DL RxQual
Change-Id: Iaa812d4661ee17c4cd4a8c4ae4bd3e94c1a2e6cc
Depends: Ia28293a12de0af71f55e701fb65c46e905dae217
Related: SYS#5319
2021-11-04 16:05:33 +03:00
Vadim Yanitskiy fbd9aaca66 measurement: pass *mr to lchan_bs_pwr_ctrl()
As a side effect, we have to sacrifice a unit test (TC_inval_dummy)
because it becomes impossible to pass a dummy or invalid SACCH block
to lchan_bs_pwr_ctrl().

Change-Id: I937117cf26fb718d57920382f6972390ad498c51
Related: SYS#4918
2021-11-04 15:46:04 +03:00
Vadim Yanitskiy c13b325877 l1sap: rework handling of DATA.ind on SACCH
Currently an Uplink SACCH block is being passed to LAPDm first, and
then gets forwareded to the BSC in handle_ms_meas_report(), together
with the Uplink measurements collected so far.

This approach has a serious flaw: handle_ms_meas_report() won't be
called if an Uplink block contains SAPI=3 data (SMS) or was not
decoded at all (len=0) fow whatever reason.  Therefore, no RSL
MEASurement RESult message will be sent to the BSC.

Rename handle_ms_meas_report() to lchan_meas_handle_sacch(), and call
it from l1sap_ph_data_ind().  This way perioduc RSL MEASurement RESult
messages will be sent regardless of what happens on Uplink SACCH.

Change-Id: Ifed91f87fd653debc87a09da3fd31ad64a13f330
Fixes: TC_meas_res_speech_{tchf,tchh}_sapi3
Related: SYS#5319
2021-11-04 15:46:04 +03:00
Vadim Yanitskiy c5f75f0bcf [overpower] rsl: store full content of RSL_IE_OSMO_TEMP_OVP_ACCH_CAP
The new fields in 'struct abis_rsl_osmo_temp_ovp_acch_cap' allow:

  * selectively enabling SACCH and/or FACCH,
  * setting the RxQual (BER) threshold.

Both features are implemented in the follow-up commits.

Change-Id: I370c8f95fb64eceb60a9dc2eae1412f8a0df0f4e
Depends: Ia28293a12de0af71f55e701fb65c46e905dae217
Related: SYS#5319
2021-10-25 14:51:21 +00:00
Vadim Yanitskiy 778aaedb95 lchan: introduce and use lchan_is_tch() helper
Change-Id: Icd832667cad1189e3e819c88bde837c4260aa252
2021-10-23 15:42:32 +03:00
Vadim Yanitskiy de8e202d83 struct gsm_lchan: move tch.rep_facch to rep_acch.dl_facch
Finally we have all ACCH repetition state variables in one place.

Change-Id: I1469619528bb69c78c2fdc25bc1db208ead936d0
Related: SYS#5114
2021-10-22 02:53:00 +03:00
Vadim Yanitskiy e0154aa09b struct gsm_lchan: group ACCH repetition state fields
Change-Id: I2680c88f2a51b64f085a92233bc125338622babf
Related: SYS#5114
2021-10-22 02:53:00 +03:00
Vadim Yanitskiy ea0247e26c cosmetic: s/repeated_acch_capability/rep_acch_cap/g
Shorter symbol names are easier to read.

Change-Id: Ib1d51f91139b4c2fe794e37fc8543b2d7a9b9c07
Related: SYS#5114
2021-10-22 02:52:28 +03:00
Vadim Yanitskiy 45094096b1 measurement: move repeated_dl_facch_active_decision() here
For the sake of consistency, call repeated_dl_facch_active_decision()
from handle_ms_meas_report(), so we have all functions using the
measurement results for Downlink executed in a single place.

Change-Id: Ibd5377ce642e49161f320ac8c33e9f966b3ddfaf
Related: SYS#5114, SYS#5319
2021-10-22 02:51:36 +03:00
Vadim Yanitskiy 31637b4673 measurement: handle_ms_meas_report() accepts const gh
Change-Id: Iba37c1a92b8b17a8ba8c958fb6c296747578cb1b
2021-10-22 02:51:36 +03:00
Vadim Yanitskiy 26417d4574 rsl: rsl_tx_meas_res() does not change l3, make it const
Change-Id: Ie60a34f90f7872464e503dc7b56935aee95f0f80
2021-10-22 01:32:27 +03:00
Pau Espin ae606d69a4 Reset CBCH state after BTS shutdown
Related: OS#5273
Change-Id: Ib01d38c59ba9fa083fcc0682009c13d2db3664fe
2021-10-20 16:13:03 +02:00
Pau Espin 3b02b9ad53 bts_shutdown_fsm: Make sure pending power ramping are aborted before closing TRX
It can happen when using several TRX that all of them go alreadyunder
shutdown target tx power level, but that due to configuration the BTS
still may want to keep pushing the tx power level even lower. Hence, we
end up in a situation where the FSM is trying to close all the TRX while the
power ramp procedure is ongoing for some of them. As a result, race
conditions can happen where for instance the power ramping procedure for
one TRX ends and calls the cb to send SETPOWER after the TRX PHY has
been closed (and hence TRXC link is unavaialble).
If that happens, the trx_if lower layers store the SETPOWER and attempt
a later retransmit, which may take up to 2 seconds after TRX becomes
active if BTS reconnects immediatelly.
Hence, we end up in some test cases where BTS reconnects and configures
some TRX while others are kep unconfigured for a while due to the
mentioned delay, hence the test attempting to use the TS while it hasn't
been yet configured.

The solution is to avoid this kind of unexpected events with ongoing
powe ramp once we have decided tx power is lower enough to shutdown the
TRX completely. Hence we abort the pending power ramp procedure.

Change-Id: Ibca581131eb142d7c38c917a0d6990efec03123c
2021-10-18 18:45:37 +02:00
Pau Espin 07232521a9 Move lchan_deactivate() to lchan.c
Change-Id: If75ed432fa9dcb10159a0dac9b8ba7efe6958b35
2021-10-14 17:48:31 +02:00
Pau Espin fd051b0f5c Move lchan related code to lchan.{c,h}
Change-Id: I17ebe6af69e31d1b4dbad7656bbf043f4c9243c1
2021-10-14 14:55:35 +02:00
Pau Espin 33b4b15f75 Add new gsm_bts_trx_free_shadow_ts() function
Use it as a counterpart of gsm_bts_trx_init_shadow_ts()

Change-Id: I38baa2b2cfcf6221325d45860b3c7dd53235b8ff
2021-10-11 11:19:11 +02:00
Vadim Yanitskiy ee5eb61694 l1sap: check if BTS model supports interference reporting
Currently, only osmo-bts-trx is capable of reporting the interference
levels to L1SAP.  Thus it does not make sense to trigger the averaging
logic and send empty reports over the A-bis/RSL and the PCUIF.

Change-Id: Ic17eb46bdca3c33ac4d6e560a093b635b75424a5
Related: SYS#5313
2021-10-08 16:54:20 +06:00
Vadim Yanitskiy 605cb85afd osmo-bts-trx: report PDCH interference levels to L1SAP
Starting from [1], interference levels on PDCH timeslots are also
reported over the A-bis/RSL.  They may be useful for the BSC to
determine whether dynamic PDCH timeslots might be better used for
new circuit switched connections, or whether alternative PDCH slots
should be allocated for interference reasons.

 * Handle GSM_LCHAN_PDTCH in lchan_report_interf_meas().
 * Rework pcu_tx_interf_ind() to accept 'struct gsm_bts_trx'.
 * Call pcu_tx_interf_ind() from l1sap_interf_meas_report().

Regarding pcu_tx_interf_ind(), it's better to call this function
from the upper layers once, rather than calling it from various
places in the model specific code.

[1] I5b4d1da0920e788ac8063cc765fe5b0223c76758

Change-Id: I3fbaad5dbc3bbd305b3ad4cb4bfb431a42cfbffc
Related: SYS#5313
2021-10-08 16:54:20 +06:00
Vadim Yanitskiy e73516ed00 rsl_tx_rf_res(): separate interference AVG / band calculation
It's cleaner from the architectural point of view to have the
interference measurements processed in a separate function.

Change-Id: I3981608e01a50585359cad673c38c8a305027d30
Related: SYS#5313
2021-10-08 10:48:51 +00:00
Vadim Yanitskiy 7726d23327 rsl: prevent race condition during timeslot re-configuration
It may happen that the BSC requests logical channel activation on a
dynamic timeslot, which is in a process of switching from one pchan
type to another due to a preceding channel activation request.

In this case 'struct gsm_bts_trx_ts' already holds an msgb with the
preceding RSL CHANnel ACTIVation message, that is normally handled
once the PHY completes the process of timeslot re-configuration.

On receipt of subsequent RSL CHANnel ACTIVation messages, in function
dyn_ts_l1_reconnect() we overwrite the preceeding msgb (memleak), by
the most recent one.  And once the timeslot re-configuration is done,
only the most recent CHANnel ACTIVation message gets ACKed.

In order to avoid this, let's move the msgb ownership to 'struct
gsm_lchan', so it cannot be overwritten by the CHANnel ACTIVation
message that is related to a different lchan on the same timeslot.

Change-Id: Ia625c2827fca883ea712076706d5ef21ed793ba6
Related: I3b602ac9dbe0ab3e80eb30de573c9b48a79872d8
Fixes: OS#5245
2021-10-08 05:23:08 +00:00
Pau Espin 15c23179dc nm_channel_fsm: Release lchans after BTS shutdown
This fixes some TTCN3 tests where some lchan resources were kept from
previous tests.

Change-Id: I78dca32cd061fba86cc88c4c4f323b33d51c58d0
2021-10-07 14:16:41 +02:00
Pau Espin b1409015fa Introduce gsm_lchan_release function helper
Change-Id: I0525beaba3c833f8d7adf9701fe373761a7720d3
2021-10-07 12:11:52 +00:00
Pau Espin db5bf829cd lchan.h: Add related ticket info to FIXME comment
Change-Id: I09ea92e843383d65c8033196814d345135ff918e
2021-10-07 12:11:52 +00:00
Pau Espin e525584f3a Move lchan,power_ctrl specific code from gsm_data.h to their own files
Let's split all lchan and power_control specific stuff into their own headers,
it helps finding out data and operations available related to them.

We already have similar classification in osmo-bsc.

Change-Id: I6424dcbd2e329fc1a516f8886359554ed7e9487e
2021-10-07 12:11:52 +00:00
Pau Espin 3c32cce087 MS Power Control Loop: Use P_CON_INTERVAL=2 by default
Have a more stable loop with less temporary oscillations at the expense
of increased reaction time.

4 SACCH blocks (P_CON_INTERVAL=2) is the minimum interval to get stable
measurements for the last requested MS Power level. With P_CON_INTERVAL=1,
are also made during a period with stable power being use to transmit,
but the MS Power level used (and announced in MR) is not the last one
requested by the BTS, but the one requested in the previous loop
iteration. This can make the MS and BTS bounce 2 values forth and back,
and create some temporary oscillation.

See osmo-bsc User manual section "Power Control" for more information.

Related: SYS#5371
Change-Id: I91c505447f68714239a4f033d4f06e91893df201
2021-10-07 10:47:00 +00:00
Pau Espin 77e014f061 Introduce gsm_lchan_init() function helper
Let's move lchan specific struct stuff into lchan.c

Change-Id: I9cb96707c63b8b7d76591d25fe906f02e34bb76b
2021-10-07 10:26:24 +00:00
Pau Espin 0d8f51f1a5 trx_provision_fsm: poweronoff_sent flag: track POWERON and POWEROFF separately
It helps better understanding the code, and will allow handling
situations where for instance a POWERON in in transit while the BTS is
instructed to shutdown, hence a POWEROFF needs to be sent.

Change-Id: Iaf62217ceab7420afa4140cba61e1c2f983c61b4
2021-10-04 14:33:09 +00:00
Pau Espin 1c3431db95 Delay abis reconnect while bts is shutting down
Avoid re-connecting to a new BSC while BTS is in shutting down. All the
FSMs are complex enough to even try to re-start when stopping has not
yet finished...

Change-Id: I1727828a16f4ec8043b00cc6b2e02a4c35f71377
2021-09-30 13:15:24 +02:00
Pau Espin d17beeacde bts-trx: Delay power ramp up until RCARRIER is ENABLED
Prior to this patch, the power ramping started when the PHY is
available, but that doesn't necessarily mean the RCARRIER is enabled.

Due to this, it was spotted a situation where BTS bootstrap failed after
PHY turning up, when RSL connection establishment failed. Hence
bts_shutdown_fsm triggered a shutdown while an active power ramping up
was ongoing...

Change-Id: I17208b74ea2649b1bbb717aee0aa355e42b7e860
2021-09-30 13:14:08 +02:00
Pau Espin d680a62975 scheduler: Fix lqual_cb not populated for TCH.ind
Change-Id: I79c83b974149b1e94155bc61172b57de8003891e
2021-09-28 12:02:15 +02:00
Pau Espin 3871c1ff0c Decouple handling of Measurement Report from lapdm
This is a preparation commit in order to move power loops up in the
stack in order to have DTXu information available, in order to decide
whether SUB or FULL ul measurements should be used in the MS Power
Control Loop.

Function rsl_tx_meas_res() is stripped from code changing state, and it
simply encodes content and transmits the message.

Change-Id: Id67259ec9ac4c2c33bd0eef3f64450affbe3fb9f
2021-09-28 12:02:03 +02:00
Vadim Yanitskiy d6ef2bf12f osmo-bts-trx: implement Temporary Overpower for SACCH/FACCH
GSM/EDGE Evolution and Performance, Section 12.3 suggests Temporary
Overpower as another solution to improve SACCH/FACCH performance in
case of bad C/I. The idea here is that you increment the DL transmit
power by 2..4dB only for FACCH/SACCH bursts, while keeping all voice
bursts at the lower (normal) level as determined by BS power control.

SACCH blocks can be recognized by the channel type, since they're
always transmitted in specific frames of a multiframe.  FACCH blocks,
however, are not predictable and can substitute voice blocks at
(almost) any time.  Thus we need to mark FACCH bursts as such in
the logical channel handlers (using TRX_BR_F_FACCH).

Change-Id: Ie8a626fefccf1eb07271058e5126ec106cb1abcf
Related: SYS#5319
2021-09-27 16:02:26 +00:00
Vadim Yanitskiy e51fb333ae gsm_lchan2chan_nr(): separate RSL specific variant of this API
The ip.access style dynamic timeslots are a bit special in a way that
on the A-bis/RSL we always use the Channel Number value of TCH/F,
even in PDCH mode.  This is why gsm_lchan2chan_nr() would always
return values corresponding to TCH/F for TCH/F_PDCH.

This behavior is only acceptable in the context of RSL messages, while
other parts of the code base may not work properly due to this trick.
A good example is the scheduler in osmo-bts-trx, where we have to
patch Channel Number value to make channel activation work.

  DPCU INFO pcu_sock.c:853 Activate request received: TRX=0 TS=5
  DL1C INFO l1sap.c:2043 (bts=0,trx=0,ts=5,ss=0) Activating channel TCH/F on TS5
  DL1C NOTICE scheduler.c:1097 (bts=0,trx=0,ts=5,ss=0) Activating PDTCH
  DL1C NOTICE scheduler.c:1097 (bts=0,trx=0,ts=5,ss=0) Activating PTCCH

In the code branch responsible for channel deactivation, we somehow
forgot to add the same workaround, so deactivation does not work:

  DL1C INFO l1sap.c:2076 (bts=0,trx=0,ts=5,ss=0) Deactivating channel TCH/F on TS5
  DTRX INFO trx_if.c:255 phy0.0: Enqueuing TRX control command 'CMD NOHANDOVER 5 0'
  DRSL NOTICE rsl.c:1286 (bts=0,trx=0,ts=5,ss=0) (bts=0,trx=0,ts=5,ss=0) not sending REL ACK

Because of that, TCH/F_PDCH timeslots actually remain active after
deactivation, so the scheduler keeps producing L1SAP DATA.ind.

  DL1P NOTICE l1sap.c:126 (bts=0,trx=0,ts=5,ss=0) assuming active lchan, but state is NONE
  DL1P ERROR l1sap.c:732 1583426/1194/00/29/14 No lchan for DATA MEAS IND (chan_nr=PDCH on TS5)
  DPCU NOTICE pcu_sock.c:973 PCU socket not connected, dropping message
  DL1P NOTICE l1sap.c:126 (bts=0,trx=0,ts=5,ss=0) assuming active lchan, but state is NONE
  DPCU NOTICE pcu_sock.c:973 PCU socket not connected, dropping message
  DL1P NOTICE l1sap.c:126 (bts=0,trx=0,ts=5,ss=0) assuming active lchan, but state is NONE
  DL1P ERROR l1sap.c:732 1583430/1194/04/33/18 No lchan for DATA MEAS IND (chan_nr=PDCH on TS5)
  DPCU NOTICE pcu_sock.c:973 PCU socket not connected, dropping message
  DL1P NOTICE l1sap.c:126 (bts=0,trx=0,ts=5,ss=0) assuming active lchan, but state is NONE
  DPCU NOTICE pcu_sock.c:973 PCU socket not connected, dropping message

Instead of patching Channel Number in various places, let's rather
make the RSL specific behavior configurable by having two variants
of gsm_lchan2chan_nr().

Change-Id: I01680140c7201bf5284b278bceaea8ae01c122b2
Fixes: OS#5238
2021-09-26 13:23:41 +06:00
Pau Espin e12f911bbb Revert "abis: Fix line leaked & recreated upon every reconnect"
This reverts commit bc6d35f52d.

Change-Id: I15063f0156ed8910795cd5ffe045e2d0cbca6276
2021-09-23 22:48:41 +02:00
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 2e90e0f756 Avoid sending Load Indications when BTS is not RSL-connected
Change-Id: I97e8dd7dd58ee2ec90c3a38d45dfd944db44c412
2021-09-23 14:07:53 +02: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 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 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