Commit Graph

3012 Commits

Author SHA1 Message Date
Pau Espin 8a85b71167 bts-trx: sched: tx_pdtch_fn: Handle PCU idle blocks properly
PCU idle blocks are identified by being 0 length, and hence msg->l2h
being null. Don't try to encode those, but simply discard them silently.

In case there's a missing block in C0, we want to log the event since
the BTS is expected to send something on C0.

Related: SYS#5676
Related: SYS#4919
Fixes: 300e31ed13
Change-Id: I57e215fedeb415db4e67fdc56bf0f1410b5f7130
2021-10-25 15:57:24 +00:00
Pau Espin 991b4f6283 bts-trx: sched_lchan_pdtch: Refactor tx_pdtch_fn to get rid of goto tag
With this change the error case is moved at the end of the function,
which is more usual. At the same time, one goto tag can be removed,
simplifying the function.

This is also a preparation for next patch improvinga bit the logic
around same place.

Related: SYS#5676
Related: SYS#4919
Change-Id: Ifbd95ccbebf4d810b1fe0a162722e63fe69106b8
2021-10-25 15:57:24 +00:00
Vadim Yanitskiy 2e8332d650 [overpower] scheduler: handle {sacch,facch}_enabled flags
The new [bit-]fields in the RSL_IE_OSMO_TEMP_OVP_ACCH_CAP allow
more fine-grained control over the overpower feature, which
can be enabled:

  * for both SACCH and FACCH,
  * for SACCH only, or
  * for FACCH only.

Change-Id: Iaaab675a20bbefece832d913963c8c5ae32ff80c
Depends: Ia28293a12de0af71f55e701fb65c46e905dae217
Related: SYS#5319
2021-10-25 14:51:21 +00:00
Vadim Yanitskiy e50223074e [overpower] lchan_dump_full_vty(): print overpower state
Change-Id: I052f1d68b27b2dc7203835b4a93d40c94b0c8d82
Depends: Ia28293a12de0af71f55e701fb65c46e905dae217
Related: SYS#5319
2021-10-25 14:51:21 +00: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
Harald Welte 430954630b initial support for static userspace probes via systemtap
This adds a --enable-systemtap configure option, which will then
add static tracepoints to the generated osmo-bts-* binary.

At this point, only two sets of tracepoints are supported, and
only in osmo-bts-trx: ul_data_{start,done} and dl_rts_{start,done}.

The probes are intended to be used for analyzing the amount of time
needed for processing of uplink bursts / generation of downlink bursts.

Change-Id: Ibb4962253f1a195dc1a54405bac058ccb2545799
2021-10-25 10:06:09 +00:00
Vadim Yanitskiy 778aaedb95 lchan: introduce and use lchan_is_tch() helper
Change-Id: Icd832667cad1189e3e819c88bde837c4260aa252
2021-10-23 15:42:32 +03:00
Harald Welte 991020c049 rsl: fix handling of REL IND in lapdm_rll_tx_cb()
During the merge of [1] the patch hunk was applied at a slightly
wrong location, so the code path has become unreacheable.

Change-Id: I823c9101bcca72d5792e16379b02d3602ffc2726
Fixes: [1] Ie4f70c75f0137b4bd72d579b3a32575bac2fca3
2021-10-23 01:42:45 +03:00
Vadim Yanitskiy 184fcb8010 lchan_set_state(): also free pending messages if any
A logical channel may have associated messages, which are pending
for transmission until some event occurs.  Do not leak them.

Change-Id: I3264e6caa007e9e9cb9c1c2f8627c408bbb28b9e
2021-10-23 01:42:41 +03:00
Vadim Yanitskiy 5f3d01eed4 osmo-bts-trx: fix potential NULL pointer dereference
Change-Id: Ic9c1f3a3fb9c151bba4f6c3e605746fc8d43f44f
Fixes: CID#240207
2021-10-23 01:18:27 +03:00
Vadim Yanitskiy df6e4533dd measurement: fix wrong operator used in handle_ms_meas_report()
Change-Id: Iad781dde0406d341bf385734ceddf51999558dd3
Fixes: CID#240263
2021-10-23 01:18:27 +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 dffb6fac25 measurement: make sure that DL measurements are valid
In repeated_dl_facch_active_decision() we rely on the Measurement
Report message, that in some cases may not contain valid Downlink
measurements.  In this case, we should simply ignore it.

Change-Id: I0d72b454f2b770d5762303fb70a15a8cdc9d07d7
Related: SYS#5114
2021-10-22 02:51:36 +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 e3818832b0 rsl: send NACK if BTS_FEAT_ACCH_REP is not supported
Change-Id: I7993cf7842ffde561f2bdc50f56516c3a188b2bc
Related: SYS#5114
2021-10-22 02:51:33 +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 d9079b192b gsm_pchan2chan_nr(): Properly assert if unexpected pchan is passed
A bit of archeology, history & recap:
ec1b5a0e9e2b6549e0ede48e803095e569997355 (openbsc.git) Adds assert in gsm_ts2chan_nr()
2f44693fad8505255293d3ed37dbd4e7cabebd37 (openbsc.git) ASSERT is disabled due to reported hit in octphy and
						       litecell in gerrit for ec1b5a0e9e2b6549e0ede48e803095e569997355
5cef0623ef (osmo-bts,git) minor fixes to gsm_ts2chan_nr() regarding the pragma
c9079d9106 (osmo-bts.git) GSM_PCHAN_NONE case is introduced in gsm_ts2chan_nr()

This code has long evolved and robustness has improved, it's not even
part of openbsc.git for several years now. Let's always assert if we
receive an unexpected value there, since they are all internally handled
values and hence we have control over them.

Related: OS#2906
Change-Id: I25e2cf0c922bc9902336e9add75a47535b9355bf
2021-10-19 12:39:55 +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 3cd4745efe lchan: Call lapdm_channel_exit() when state changes to NONE
Fixes crash when TTCN3 BTS_Tests_LAPDm TC_rr_response_frame_loss
runs run after TC_t200_n200.

The BTS was shutdown after TC_t200_n200 failed (drop oml link), and
lchan was moved ACTIVE->NONE without lapdm_channel_exit() being called
on it. Hence, on next test (TC_rr_response_frame_loss), when
lchan_init_lapdm() was called again, some memory corruption was caused.

The lapdm_channel_exit can be dropped from gsm_lchan_release() and
rsl_tx_rf_rel_ack() since it's already called in the same path:
"""
rsl_rx_rf_chan_rel
	gsm_lchan_release(lchan, LCHAN_REL_ACT_RSL);
		l1sap_chan_rel(lchan->ts->trx, gsm_lchan2chan_nr(lchan));
			l1sap_chan_act_dact_modify(trx, chan_nr, PRIM_INFO_DEACTIVATE)
				bts_model_l1sap_down
					bts_model_lchan_deactivate_sacch(lchan);
						-
					lchan_deactivate(lchan);
						bts_model_lchan_deactivate
							lchan_set_state(lchan, LCHAN_S_NONE); <---------
					mph_info_chan_confirm(trx, chan_nr, PRIM_INFO_DEACTIVATE, 0);
						l1sap_info_rel_cnf
							rsl_tx_rf_rel_ack(lchan);
								lapdm_channel_exit(&lchan->lapdm_ch);
		lapdm_channel_exit(&lchan->lapdm_ch);
"""

Related: SYS#5262
Change-Id: If0ec5f0c7be4d15c8d684d33e15e24d68bd5192e
2021-10-14 17:59:28 +02:00
Pau Espin d3e730c61d Move lchan_init_lapdm inside lchan_set_state(LCHAN_S_ACTIVE)
osmo-bts-trx/l1_if.c lchan_init_lapdm() for CCCH is already done when
trx_set_ts_as_pchan() calls:
"lchan_set_state(&ts->lchan[CCCH_LCHAN], LCHAN_S_ACTIVE);"

Change-Id: I7a9c3660b9aab57ff8765e2f1526349599630cd9
2021-10-14 17:48:31 +02:00
Pau Espin 07232521a9 Move lchan_deactivate() to lchan.c
Change-Id: If75ed432fa9dcb10159a0dac9b8ba7efe6958b35
2021-10-14 17:48:31 +02:00
Pau Espin ac81d2789a lchan: Avoid applying transition changes if state new==old
Let's avoid running over state change conditions or even printing log
lines if there's no state change.

Change-Id: I1ca86aa846084f53751076643665cb6dabc26a06
2021-10-14 17:04:24 +02:00
Pau Espin 578b540711 lchan: Update log line level to use macro and level INFO
Change-Id: Idd48fd8fbb13b715096a4765dcb08a18d85098a7
2021-10-14 17:03:45 +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 03cb50f809 lchan: Setup early_rr_ia timer only once during init
There's no need to re-setup it every time.

Mark the cb as static since its private to the module, and move it
above its use point so it can be referenced.

Change-Id: I90324f26d8ca09d425c7523a25b3e6c951fa49d6
2021-10-14 14:41:41 +02:00
Vadim Yanitskiy 72d9981cd0 osmo-bts-trx: refactor 'maxdly' / 'maxdlynb' commands
* Move way too verbose command description to the manuals.
* None of these commands apply immediately, correct the attributes.
** Remove meaningless call to l1if_provision_transceiver_trx().
* Make 'maxdlynb' hidden, so it only appears in the expert mode.
* One GMSK symbol actually corresponds to 550m.

Change-Id: I46839cf56bba2dcdc70303cd393e86d35aa2f3f5
2021-10-13 20:01:08 +00:00
Pau Espin 0e2a20bfb4 bts-trx: Guard call to trx_sched_clean with NULL trx ptr
trx_phy_inst_open() already guards against NULL trx ptr when calling
trx_sched_init(). Later on, in same path, trx_phy_inst_close() can be
called which ends up calling trx_sched_clean(trx), this time not being
guarded against NULL trx. This fixes Coverity CID#240498.

Fixes: CID#240498
Change-Id: I00afc739559d57dd98db68c76f2a85006c15e875
2021-10-13 17:47:25 +02:00
Eric Wild 7643be1d55 osmo-trx: fix maxdly
- one gsm symbol is 0,00000369 seconds
- 2*550m/c = 0,00000366 seconds
-> one ta symbol is a DISTANCE of 550m (or a RTT of 550m*2) between bts and ue.
-> no idea why this was constrained to TA/2.

Change-Id: I8d79080c82411e6427eec37d008614fa5d5e1ace
Related: OS#5140
2021-10-12 16:08:00 +00:00
Pau Espin 3e2b7faed6 rsl: Fix all shadow TS being Chan Act NACKed
The OML NM Channel FSM state only apply to primary timeslots, hence we
need to make sure we pick the primary TS (the non-shadow one).

Due to this bug, all channels on shadow TS where NACKed because the
related state was never "Enabled Ok".

Fixes: c97a7f51e1
Related: OS#5249
Related: OS#5251
Change-Id: If47e4bdd45a05ed1b5709b6e3d541f2830723e37
2021-10-11 13:53:27 +02:00
Pau Espin 074672b604 Make sure lchan allocated memory from shadow_ts is properly freed
Since non-shadow TS are currently not allocated as talloc contexts,
lchan objects tend to allocate their own memory on trx talloc ctx
instead. That's fine for non-shadow TS, since the TS follow trx lifecycle
since they are part of the same talloc context. However, shadow TS are
recreated (re-allocated) each time the BTS reconnects, hence when htey
are freed we need to free substructs (lchan) memory in order to avoid it
being kept in trx talloc ctx.

Related: OS#5248
Change-Id: I73742535eb3c40a6866731acbff782940dab06c3
2021-10-11 11:38: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 8e7d00f1ce trx_sched_clean(): also free() the shadow timeslot
Change-Id: Ic14e9de7487ba8152ffb1aa1bab508a2b9a11ea0
Related: OS#5248
2021-10-11 08:41:56 +00:00
Vadim Yanitskiy 0eb6891259 trx_sched_clean_ts(): also free() the associated 'struct l1sched_ts'
Change-Id: I44a8f18c81dd8bc76ca07dfaae7bcdb2fedc9261
Related: OS#5248
2021-10-11 08:41:56 +00:00
Pau Espin be688f1603 nm_*_fsm: reset mo.nm_attr from previous runs when entering state NOT_INSTALLED
Code in oml.c, upon receiving net attributes, merges the new attributes
with old ones (for some reason I don't really know). Hence, if we
disconnect from a BSC and go to NOT_INSTALLED state, we must free
previous nm_attr in order to avoid mixing them once we connect to a new
(potentially different) BSC upon reconnect.

Related: OS#5248
Change-Id: I45cc22dd68121a7930301581bfd0a8db37879c77
2021-10-08 20:58:50 +00:00
Pau Espin 9419319ab5 nm_*_fsm: Move reset state code to st_op_disabled_notinstalled_on_enter
Let's rather put it there instead of the shutdown code path, since we'll
be adding more and more reset coe there.

Change-Id: I43a136ade731a2c58c0a29d97875088e9b6d4414
2021-10-08 20:58:50 +00:00
Vadim Yanitskiy 556a966952 vty: show interference level / band in 'show lchan'
Change-Id: Ide45a0f7836bf35ffbe88070fa8367022311ca44
Related: SYS#5313
2021-10-08 16:54:20 +06: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 187e099c3b rsl_tx_rf_res(): also report noise levels for PDTCH
This information 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.

Change-Id: I5b4d1da0920e788ac8063cc765fe5b0223c76758
Related: SYS#5313
2021-10-08 10:48:51 +00: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
Vadim Yanitskiy 2e62159c8d .gitignore: add tests/amr/amr_test
Change-Id: Id1f8710f0d6b7511fff6ab221e6ec974a94c6f8b
Fixes: I94a934a6b3b397b4cd0e9da3577325de58814335
2021-10-08 05:21:32 +00:00
Pau Espin 715ff2900a nm_bts_fsm: Reset si_valid bitmask when BTS is shut down
Otherwise after reconnecting some SI are still marked as valid despite
the new BSC conn didn't set them.

Change-Id: I71e2a5cdf4e2e287db7b05df1a165a1e32c958ca
2021-10-07 16:25:19 +02: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