Commit Graph

3284 Commits

Author SHA1 Message Date
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 92d1d1582b Simplify implementation of bts_model_opstart() in all bts types
Use mo->fi directly to avoid repeating code paths for each obj_class.

Change-Id: I54632201afe87eb3e02bc75cbade163917239ab6
2023-04-06 10:28:22 +00:00
Pau Espin f4505f6caf lc15,oc2g,sysmo: Update GPRS NM object state at the right time
Change-Id: I2f331954835496504f1fafa572bd46ee83b03a63
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 c12bc93db8 oml.c: Remove dot character at the end of log lines
Change-Id: Iaf061bb752f9808a6ab31049b9e87920a6b07f3d
2023-04-05 13:10:05 +02:00
Pau Espin 7a646f963b bts_model_apply_oml(): Drop unneded code
Calls to bts_model_apply_oml() are done only for BTS, RCARRIER and
RCHANNEL NM Objects in their respective Rx code paths (and they will
be moved to respective FSMs in follow up patches). This function is
never called with any of the GPRS NM objects.

These NM Objectes have the NM_MT_IPACC_SET_ATTR msg ACKED/NACKED in its
own path:
oml_ipa_set_attr()
	rc = oml_ipa_mo_set_attr()
	return oml_fom_ack_nack(msg, rc);

Change-Id: I1a0d38a122f50ffe749ebc4f1cc11235ca516586
2023-04-04 20:26:23 +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
Pau Espin 0350824203 bts-trx: Drop unused param to internal function
Change-Id: Id7ad7629ec13bcec618055c41083cdac0a3102be
2023-04-04 12:50:19 +02:00
Mychaela N. Falconia 4ff6888a81 bts-{lc15,oc2g,sysmo}: support EFR in repeat_last_sid()
The function repeat_last_sid() is implemented in the common part,
but is only used by osmo-bts-{lc15,oc2g,sysmo} models.  These BTS
models call this function when they are looking to see if a
previously cached SID frame needs to retransmitted on the DL
because it is that time according to the SACCH multiframe.
Out of non-AMR codecs, this function previously supported only
FR1 and HR1, but failed to support EFR.  Fix that omission.

Change-Id: Iebcd28e65af889254740757eed9c579392eb1c33
2023-04-03 15:15:48 +00:00
Vadim Yanitskiy 5f556af232 tests: $(BUILT_SOURCES) is not defined, depend on osmo-bts-virtual
Change-Id: I4ace06e115a2689bde9afd9f99ecee99d796360b
2023-04-03 13:33:25 +00:00
Pau Espin 909d943fe8 contrib/ber: Avoid regenerating codec_bit_class.h every build
Automatic generation of a header file using a C program built during
build of osmo-bts creates several problems when cross-compiling.

The generated header file is only 59 lines long, so let's have it
generated in order to avoid having to call the helper program every
time.

A Makefile target is added to easily regenerate the file manually in
case it's needed:
make -C contrib/ber/ update_codec_bit_class_h

Fixes: acf0f0f0bb
Change-Id: I97efdb4ee00537fcae191b4267d0211d582ef372
2023-04-01 21:18:25 +00:00
Harald Welte 1266c068d7 Replace explicit gsm_lchan_name() calls with LOGPLCHAN
There was a surprising number of explicit gsm_lchan_name() calls
from within log message code.  Let's avoid that whenever possible and
use a LOGPLCHAN() or related macro.

Change-Id: If4f4f555f5ca61dfa624b298805f5375efc0b137
2023-03-31 11:56:35 +00:00
Mychaela N. Falconia 61e7fdbb3f sysmo: emit empty RTP ticks during FACCH stealing on TCH/F
When FACCH stealing occurs and sysmoBTS L1 delivers GsmL1_Sapi_FacchF
instead of GsmL1_Sapi_TchF, that 20 ms unit still needs to be
accounted for in the RTP timestamp cadence, and if we run with
rtp continuous-streaming enabled, then an actual BFI packet needs
to be emitted.  The original code failed to do either; the present
change implements correct behavior for TCH/F.

The present patch only covers the case of TCH/F; handling of TCH/H
is left as a FIXME for other/later developers.

Related: OS#5974
Change-Id: I39d15faade28fb7d670493a99a0e0bdb654e2a4a
2023-03-30 17:30:53 +00:00
Mychaela N. Falconia 50710f4e8e rtp continuous-streaming: fix BFI in the quality-suppressed case
The check for (tch_ind->lqual_cb >= bts->min_qual_norm) in
l1sap_tch_ind() has the intent of suppressing valid-seeming
speech frame output from lower layers when the link quality is
too low; this check is particularly important for FR1 codec
where the intrinsic validity check is only a 3-bit CRC which has
1/8 probability of indicating "correct" when decoding radio noise
during DTXu silence.

However, this check is effectively defeated in the current
implementation of rtp continuous-streaming: the RTP packet being
output is the presumed-bogus speech frame from lower layers,
rather than the intended zero-length payload.  Fix this bug.

Related: OS#5975
Change-Id: Icee0f57be289a0592a0197469432a012d15f224c
2023-03-30 17:30:53 +00:00
Sylvain Munaut acf0f0f0bb contrib: Add BER testing tool
This implements RTP based GSM BER testing for osmo-bts, implementing
ideas described in https://osmocom.org/projects/osmobts/wiki/BER_Testing

In short: The command transmits a PRBS sequence encapsulated in RTP
frames, which are sent to the BTS, which transmits that data in the
(unimpaired) downlink.  The mobile station receives the data and is
instructed to loop it back in the (possibly impaired) uplink.  The BTS
receives that uplink, puts in in RTP frames which end up being received
back by this very tool.  By correlating the received RTP with the PRBS
sequence, this tool can compute the BER (Bit Error Rate) of the
(possibly impaired) uplink.  Doing this with different RF channel model
simulators in the uplink allows to establish BER at different levels and
channel conditions.

Original code by Sylvain Munaut extended with some comments and Automake
integration by Harald Welte.

Change-Id: I1cffa0ae959e29ec61775b13185fd1057ed7485a
2023-03-30 12:56:14 +02:00
Harald Welte f06b959c7d lc15: fix compiler warning about unused variable cell_size
oml.c: In function ‘bts_model_apply_oml’:
oml.c:1814:17: error: variable ‘cell_size’ set but not used [-Werror=unused-but-set-variable]
 1814 |         uint8_t cell_size;
      |                 ^~~~~~~~~

Change-Id: I0bf1542f613f613d03609d50836137ff440401af
2023-03-29 14:02:50 +02:00
Harald Welte 2551882c1c cosmetic: Remove "FIXME?" from Odd AMR CMI phase
This default phase of the Codec Mode Indication in downlink direction is
called "odd", which is defined by starting with CMC in every 26
multiframe.

At call set-up, after every successful handover and after a channel mode
modify, the default phase (odd) shall be used in downlink direction.
During a call, the phase of Codec Mode Indication may be changed in
downlink by using a RATSCCH message.

As we don't implement RATSCCH, odd is always correct.

Change-Id: Ia64767fbfdc3fb067d72dbf5eabb1d84e3868ce5
2023-03-29 12:02:10 +00:00
Harald Welte 96263aa908 oc2g: Fix 'unused variable' compiler warning
oml.c: In function ‘bts_model_opstart’:
oml.c:1883:32: warning: variable ‘ts’ set but not used [-Wunused-but-set-variable]
 1883 |         struct gsm_bts_trx_ts *ts;
      |                                ^~

Change-Id: Ifd5552f2dd56f4f9bf4c17d25b741f694f4f2168
2023-03-29 12:02:10 +00:00
Harald Welte 362f2e50c2 lc15/oc2g: remove unused variables
oml.c: In function ‘l1if_rsl_chan_mod’:
oml.c:1980:22: error: unused variable ‘i’ [-Werror=unused-variable]
 1980 |         unsigned int i;
      |                      ^
oml.c:1979:35: error: unused variable ‘s4l’ [-Werror=unused-variable]
 1979 |         const struct lchan_sapis *s4l = &sapis_for_lchan[lchan->type];
      |                                   ^~~

oml.c: In function ‘l1if_rsl_chan_mod’:
oml.c:1985:22: warning: unused variable ‘i’ [-Wunused-variable]
 1985 |         unsigned int i;
      |                      ^
oml.c:1984:35: warning: unused variable ‘s4l’ [-Wunused-variable]
 1984 |         const struct lchan_sapis *s4l = &sapis_for_lchan[lchan->type];
      |                                   ^~~

Change-Id: Ieb8882bbade7f6d6628c9c00150bcf54e3a9dc75
2023-03-29 12:02:10 +00:00
Harald Welte 3d2c107922 lc15: Remove unused warning
l1_if.c: In function ‘activate_rf_compl_cb’:
l1_if.c:1251:22: error: unused variable ‘i’ [-Werror=unused-variable]
 1251 |         unsigned int i;
      |                      ^

Change-Id: I23270dfe6779321e514c71184b3c71f52a9b4c4a
2023-03-29 12:02:10 +00:00
Harald Welte 9584980ea2 lc15: fix compiler warning about wrong indent
l1_if.c: In function ‘activate_rf_compl_cb’:
l1_if.c:1280:17: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
 1280 |                 if (bts_lc15->led_ctrl_mode == LC15_LED_CONTROL_BTS)
      |                 ^~
In file included from ../../include/osmo-bts/dtx_dl_amr_fsm.h:3,
                 from ../../include/osmo-bts/msg_utils.h:8,
                 from l1_if.c:55:
l1_if.c:1282:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
 1282 |                         osmo_fsm_inst_dispatch(trx->mo.fi, NM_EV_DISABLE, NULL);
      |                         ^~~~~~~~~~~~~~~~~~~~~~

Change-Id: I00ae3faf0f85fecf6e15e71dff071165725e547c
2023-03-29 12:02:10 +00:00
Harald Welte 80c605dd0b cosmetic: use __func__ instead of __FUNCTION__
Our linter would complain about this these days:

	__func__ should be used instead of gcc specific __FUNCTION__

Change-Id: I80bf6d0a89ce6454ae063759d6088a28b04670c0
2023-03-29 12:02:10 +00: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
Mychaela N. Falconia 32682c63f6 sysmo: fix handling of SID in EFR
Handling of SID in EFR mode was broken in osmo-bts-sysmo.
l1_to_rtppayload_efr(), the function for UL Rx, was using completely
bogus logic (passing bits in ETSI TS 101 318 EFR format to an AMR
decoding function), whereas l1if_tch_encode(), the function for
DL Tx, had missing SID logic for EFR while supporting SID detection
for all other codecs.  The fix is to use the new osmo_efr_check_sid()
function in libosmocodec.

Change-Id: Ia56c1bb7432968685110456961d24a907b0a201f
2023-03-29 11:59:28 +00:00
Mychaela N. Falconia e1e204fae3 trx: detect UL SID in EFR just like in FR
The TCH/F Rx code in osmo-bts-trx uses osmo_fr_check_sid() to detect
when the MS sends SID, and passes the flag to lchan_set_marker().
However, equivalent logic was missing for EFR, as until recently
there was no EFR SID check function in libosmocodec.  Now that
we have osmo_efr_check_sid(), use it.

Change-Id: Ib043e00dbf92145c2a6c32f6365517244472a922
2023-03-29 11:59:28 +00:00
Harald Welte ac23ce2e03 bts-{sysmo,oc2g,lc15}: Dump logical channel params during MPH-ACTIVATE.req
So far we only printed it during later modification.  Let's print
it also during initial activation of a logical channel.

Change-Id: I6982a52905e4719e2e9c40630252ffef2ff9fbed
2023-03-28 15:13:34 +02:00
Harald Welte c17697d337 common/vty: Print AMR MultiRate Configuration in "show lchan"
It can be useful to introspect the current active AMR mode set.

Related: OS#5944
Change-Id: I630af8c3835c2fcbea325c07db269d25e4e18f62
2023-03-28 15:12:10 +02:00
Harald Welte bb3ed23e71 bts-{sysmo,oc2g,lc15}: Fix RTP of AMR SID_FIRST_P1
When we receive a SID_FIRST_P1 frame from the PHY (during AMR/HR DTXu),
we must generate a SID frame on the RTP side.

The existing code
* ignored that the Amr_SidFirstP1 PHYIF message actually contains the
  RTP payload
* manually generated the same content using osmo_amr_rtp_enc()
* forgot to prefix that with the AMR CMR+TOC
* in the end, sent a completely broken (too short) AMR SID frame over RTP

Let's fix this by simply using the 7-byte RTP payload with CMR+TOC that
the PHY is providing to us.

Change-Id: I90479efcc002d497648a71e73847af54e6208358
Related: OS#5944
2023-03-28 15:12:10 +02: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
Harald Welte 61b005193c cosmetic: Replace %i with %d
Our linter will fail on %i, so let's replace any legacy occurrences with %d

Change-Id: Ic302915bd5576d3e1f77668918f005d651daf21a
2023-03-28 12:44:22 +00:00
Harald Welte d47d288630 DTX: bts-{sysmo,oc2g,lc15}: Print DEBUG messages about ONSET
We're printing DEBUG messages for all other DTX frames, but not for
ONSET.  This made me think that we never received any ONSET frames
when looking at log output.

Let's add ONSET for completeness.

Related: OS#5944
Change-Id: I9a1511d9929444cef96388492d907e8f3a082311
2023-03-27 20:00:00 +02:00
Vadim Yanitskiy e464ef6524 osmo-bts-{sysmo,lc15,oc2g}: fix segfault in ph_tch_req()
ph_tch_req() is a recursive function and conditionally calls itself at
the very bottom.  The recursive call happens iff all of the following
conditions are met:

* DTXd is enabled,
* AMR codec is in use,
* DTX DL AMR FSM state is recursive.

The problem is that ph_tch_req() may pull sizeof(*lsap) from the given
msgb twice: during the initial and the recursive calls.  The second
attempt to pull sizeof(*lsap) causes the process to abort, because
the remaining room is less than it's attempting to pull.

AFAICT, doing msgb_pull() is not really necessary, given that
l1sap_tch_rts_ind() thankfully does set msg->l2h before pushing
the lsap header in front of the actual frame.

Update osmo-bts-sysmo and its copy-pasted siblings, which are likely
affected too, except osmo-bts-octphy which does not do the recursion.

Change-Id: Ib349b74a9e4bd48c902286f872d3b0e9a068256c
Related: OS#5925
2023-03-24 18:24:01 +00:00
Vadim Yanitskiy dbd70bca75 rsl: rsl_handle_chan_mod_ie(): add missing GSM48_CMODE_* values
Change-Id: Iec397f1ef4cb5ac1c48abf869f54e272ed0fbb55
Depends: libosmocore.git I6adda28698c0e479ef20f5d090c1f7f76a2ec97e
Depends: libosmocore.git Ia6b428e5b6aaecf151cbfa980b89eff6d0fe6006
Related: OS#1572
2023-03-23 20:09:49 +00:00
Pau Espin 8fe6479358 bts-trx: Avoid pushing interf_meas for disabled TRX
It makes no sense to push interference meas results for those TRX since
they are disabled, unused and hence won't be reported in RSL RF Res Ind.

Related: SYS#6370
Change-Id: Ie3fd80970585cb30808b0644568dbc8936a57721
2023-03-23 12:38:26 +01: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
Vadim Yanitskiy e7085d1699 contrib/osmo-bts.spec.in: do not depend on libosmogb
The header file <osmocom/gprs/protocol/gsm_04_60.h> was recently
deprecated and moved to <osmocom/gsm/protocol/gsm_44_060.h>, so
it's now part of libosmogsn and depending libosmogb is not needed.

Change-Id: I823de7ebac2fe5dfddb88d533f1a9419f4a605db
Related: libosmocore.git I70cc21bf25a7081070738abacb409ed19094c3b2
Related: OS#5312
2023-03-21 12:26:21 +00:00
Vadim Yanitskiy ef9b27526c osmo-bts-virtual: properly handle dynamic TS in vbts_set_ts()
This change fixes a problem that prevents osmo-bts-virtual from
starting when dynamic (ipa/osmo) timeslots are in use.

Change-Id: I5db5b7dd6a8e84cf9a0d84f04a650c2ed8a4e368
2023-03-20 23:08:33 +07:00
Vadim Yanitskiy 4bdc5a74cc scheduler: log pchan value in trx_sched_set_pchan()
Change-Id: Ia31e53552208a9d57e2fc5473440840d38945d00
2023-03-20 03:59:11 +07:00
Pau Espin 767f690f05 Avoid tx RF Resource Ind for disabled TRX
Related: SYS#6370
Change-Id: I887e0cb03b2a5654accccf7a55fac51319981bfb
2023-03-17 17:02:47 +01:00
Pau Espin 48b00783f8 cosmetic: bts_trx.h: Fix whitespace
Change-Id: Ibcc3578cce23767445e53149796d0bd79f81ead8
2023-03-17 15:47:49 +01:00
Pau Espin c88ed31d9e cosmetic: gsm_pchan2chan_nr(): Update spec documentation
Change-Id: If1de230f022c69f3dfce8a7c66d494a984e7f3f9
2023-03-17 15:29:17 +01:00
Pau Espin 149de0c113 lchan: Improve error path logging in gsm_pchan2chan_nr()
Change-Id: I8d9da8e8433feb1f022dc2f5199f9c15c01e9312
2023-03-17 15:14:19 +01:00
Pau Espin ca72961bbd Rewrite pcu_sock_write()
The code in that function is pretty rotten:
* osmo_fd_write_disable() is called for each message in the queue,
  there's no need for that. Let's simply call it at the end if the queue
  is empty.
* Asserting for obvious stuff like dequeue returning the first entry in
  the list.
* Having error code path for empty message: That shouldn't happen, abort
  immediately.

With all thse changes, the function is way simpler, easy to read and
more efficient.

Change-Id: I7ffff98cd8cdf2041bff486c3fde6f16365028d5
2023-03-15 17:45:35 +01:00
Vadim Yanitskiy 50de553a1f tests: use -no-install libtool flag to avoid ./lt-* scripts
This option should be used for any executables which are used only
for testing, or for generating other files and are consequently never
installed.  By specifying this option, we are telling Libtool that
the executable it links will only ever be executed from where it is
built in the build tree.  Libtool is usually able to considerably
speed up the link process for such executables.

Change-Id: I06d3d5ab1dd21400a72f76eecc508886617ef4c6
2023-03-14 20:09:44 +00:00
Vadim Yanitskiy c1909e7258 rsl: reduce logging verbosity on some messages
These two messages indicate that no ACK/NACK message is going to be
sent to the BSC because activation/deactivation was requested by the
PCU.  This is absolutely normal and requires no attention from the
user/operator, so better use LOGL_INFO.

Change-Id: I6eaf3a6c07fb30b31c045729c935c8ad6735e5c8
2023-03-14 21:14:54 +07:00
Vadim Yanitskiy 729037de0a rsl: remove redundant gsm_lchan_name() in rsl_tx_rf_rel_ack()
Change-Id: I69dc11c66a774ddb7364d6ecd9bdb2e94e6cad66
2023-03-14 21:10:27 +07:00