Commit Graph

2646 Commits

Author SHA1 Message Date
Philipp Maier 6d3da5401f pcu_sock: cosmetic: remove whitespace after type cast
Change-Id: Iddc1bd703b4a200202ffa87d24a167e3fe39da18
2023-03-07 12:54:58 +00:00
Philipp Maier 280ad4d966 pcu_sock: rename rc to fd
The variable rc holds the return code of accept(), which returns a file
descriptor on success. So lets call the variable "fd" to make this
clear.

Change-Id: Ic8d22c2af18477f110a3a9115434314ebca95b25
2023-03-07 12:54:58 +00:00
Philipp Maier 7630b88fb5 pcu_sock: improve logging
In many places we have a pointer to the BTS object, so we can use
LOG_BTS.

Change-Id: I4a3ff23ffccf803b1a97e3f2604d3b422c6d6afd
Related: OS#5198
2023-03-07 12:54:58 +00:00
Philipp Maier 6902fccb1b pcu_sock: use struct to transfer IMMEDIATE ASSIGNMENT for PCH
When the IMMEDIATE ASSIGNMENT is sent from the PCU to the BSC using the
"direct TLLI" method, the TLLI (and the last three digits of the IMSI)
is prepended to the MAC block. Currently we are taking the fields apart
manually using offsets. The code for this is difficult to read and the
method is error prone. Let's define a struct that we can just overlay
to access the fields directly. Let's also transfer the full IMSI.

Change-Id: Id6acbd243adf26169e5e8319dd66bb68dd6a3c22
Related: OS#5198
2023-03-07 12:54:58 +00:00
Philipp Maier ecf825dc08 pcu_sock: activate/deactivate PDCH on pcu reconnect
When the PCU is disconnected while the BSC keeps running the PDCH should
be closed. Also the PDCH should be reopened when the PCU is
reconnected.

Change-Id: I9ea0c53a5e68a51c781ef43bae71f947cdb95678
Related: OS#5198
2023-03-07 12:54:58 +00:00
Oliver Smith a8f5dbce77 check_chan_mode_rate_against…: fix never true cond
Fixes: CID#310958
Fixes: 2150b307 ("assignment_fsm: chan mode check: support CSD")
Change-Id: Icb3d0f977267dca7b52fd05312ccb5237fcaa031
2023-03-07 09:50:01 +01:00
Philipp Maier f85f8dd4a1 pcu_sock: get rid of leaking message buffer
When a data request is received from the PCU, some of the switch cases
allocate a message buffer but the message buffer is only used to pass
its data and length to other functions. The message buffer itself is not
passed anywhere and it is also not freed. Lets get rid of the message
buffer and avoid unnecessary memcopy calls.

Related: OS#5198
Change-Id: Ibfaae177585a4d42d797b6bbd90e402641620140
2023-03-06 15:32:25 +00:00
Oliver Smith d83d22bad3 Cosmetic: channel_mode_from_lchan: remove fixme
Remove the FIXME comment, as the function handles CSD now.

Related: OS#4393
Change-Id: Ic074cb814662d73f52d4401d1cf9cdbf682040a9
2023-03-06 10:23:31 +01:00
Oliver Smith 722220f2dc chan_mode_to_mgcp_codec: support CSD
Related: OS#4393
Change-Id: Ib5876ee4dac9e8000cc3ae0c5dd87aae3d723829
2023-03-06 10:23:30 +01:00
Oliver Smith d5ca920cc3 rsl_tx_ipacc_crcx/mdcx: omit speech mode for CSD
Omit the A-bis/IP specific RSL_IE_IPAC_SPEECH_MODE, as it doesn't make
sense for circuit switched data.

Related: OS#4393
Change-Id: I6641b713177276bcf798f08123e1dd2e88ffdce6
2023-03-06 10:23:30 +01:00
Oliver Smith d5eb0f1b57 lchan_select: chan_mode_to_chan_type: support CSD
Related: OS#4393
Change-Id: I6b02d7edbf268a7f07134b54a7289529b2485122
2023-03-06 10:23:30 +01:00
Oliver Smith 41ede5345c requires_voice_stream -> ch_indctr
Use the full gsm0808_chan_indicator value throughout the lchan related
structs (assignment_fsm_data, gsm_lchan, lchan_activate_info,
lchan_modify_info) instead of reducing it to the boolean
requires_voice_stream.

This is needed so we don't lose the information whether an lchan was
requested for data or speech (both need an rtp stream).

Add a new bsc_chan_ind_requires_rtp_stream function and use it in
conditionals like the previous requires_voice_stream.

Related: OS#4393
Change-Id: I1538c1e6d5cd61559af7c1e2860afd0269dda367
2023-03-06 10:23:30 +01:00
Oliver Smith 2150b307c2 assignment_fsm: chan mode check: support CSD
Replace check_requires_voice_stream, which used to iterate over
ch_mode_rate_list and verify that all entries are either for speech or
signalling. Instead verify in check_chan_mode_rate_against_ch_indctr,
that all entries of ch_mode_rate_list have a chan_mode that matches the
ch_indctr (data, speech, signalling; called "speech / data indicator" in
3GPP TS 48.008 § 3.2.2.11).

This ensures that all of them are either data, speech or signalling and
not mixed.

Related: OS#4393
Change-Id: Iee5cbfee84d7f2ad59ee2d5a19891a2b59bbafff
2023-03-06 10:23:30 +01:00
Oliver Smith 0361b01614 bssmap_handle_ass_req_tp_codec_list: tweak log msg
Remove "speech mode" from the log message, as the log message is
relevant for CSD too. According to 3GPP TS 48.008 § 3.2.1.1 note 13 the
IE shall be included for AoIP unless channel type is signalling.

Related: OS#4393
Change-Id: Idfab0b7f6e97a6b67d140f967ddfe9b29818586e
2023-03-06 10:23:30 +01:00
Oliver Smith b11bf4d651 abis_rsl: ipacc_payload_type: handle CSD
Depends: libsmo-abis Ibf0bfb577faa5c82e10706b42ede8b72dd611655
Change-Id: Ie561d87ecdc161b9a69eb7683889f0395524faa8
2023-03-06 10:23:30 +01:00
Oliver Smith e6e81e09b3 bssmap_handle_ass_req_ct_data: implement
Handle assignment requests for CSD. In this initial version, the code
for non-transparent data mode is a stub.

Related: OS#5763
Depends: libosmocore Ia965cdd9f53af756e5ffaff9b8f389b5ad629969
Change-Id: I350bea15fd2158eb6edc9bc92f2dca48930736e9
2023-03-06 10:23:26 +01:00
Neels Hofmeyr 25947b7aa4 cosmetic: timeslot_fsm.c: move some code to separate function
Cosmetically prepare for patch I9ea0c53a5e68a51c781ef43bae71f947cdb95678

Change-Id: I2c26d937496211e4b876987bac3803f6b2e6c8be
2023-03-06 08:44:02 +00:00
Oliver Smith 17df53ea1a channel_mode_from_lchan: add GSM48_CMODE_DATA_3k6
Related: OS#4393
Change-Id: Id9ec34f77c96d3a209c6f78d2addf1ea0dfa228d
2023-03-05 18:04:41 +00:00
Oliver Smith 5a16fcee93 lchan.h: remove enum lchan_csd_mode
It looks like the idea was to translate the CSD rate from BSSAP to
lchan_csd_mode before translating it to RSL. But instead we can just
directly translate the BSSAP value to the RSL value.

The previous code was not used yet (nothing wrote to csd_mode).

Related: OS#4393
Depends: libosmocore I25bfd02aa1428a35492b20376a31635a442e545f
Change-Id: Ice914744da3a2084e82d125848fb69404b8e8a36
2023-03-05 18:04:41 +00:00
Neels Hofmeyr 220ef9a380 drop gsm_pchan_ids, use sanitized FSM ids instead
gsm_pchan_ids[] exists only to compose osmo_fsm compliant IDs. We do
have osmo_fsm_inst_update_id_f_sanitize() now, rather use that.

This removes some confusion about which value_string array has an effect
on the VTY command 'ts' / 'phys_chan_config'.

Note that tests/bsc_test.ok does not change, hence the new way of
composing FSM IDs is identical to using the old gsm_pchan_ids[].

Change-Id: Ib85b7aa4ea882ae37919dd3ea0c033e949c083e5
2023-03-04 22:44:10 +00:00
Neels Hofmeyr 896d694977 tweak gsm_pchan_ids[]: DYNAMIC/{OSMOCOM,IPACCESS}
This patch affects *only* on osmo_fsm instance IDs, which are visible on
the CTRL and VTY interfaces to identify FSM instances, and in the log.

Why bother: An upcoming patch wants to replace gsm_pchan_ids[] with
osmo_fsm_inst_update_id_f_sanitize(gsm_pchan_name(x)), this is an
explicit step to match gsm_pchan_names[].

Change-Id: I4a540744cced466f0ca4fc605db4d0ec14ee8e87
2023-03-04 22:44:10 +00:00
Neels Hofmeyr 879e7595f0 bsc_test.c: test FSM IDs that contain pchan names
Show the timeslot_fsm, lchan_fsm, assignment_fsm fi->id strings.

The IDs include the current pchan configuration. I want to tweak the
composition of these in an upcoming patch, so the test should show
whether any FSM IDs change from that.

Change-Id: If369f23fa140b9d7792f5a511815cbbd14b371e9
2023-03-04 22:44:10 +00:00
Neels Hofmeyr 76ea8562db stat: change pchan naming to dynamic/{osmocom,ipaccess}
Change names of stat exports to be consistent with VTY,CTRL:
- from "chan_osmo_dyn" to "chan_dynamic_osmocom"
- from "chan_tch_f_pdch" to "chan_dynamic_ipaccess"

Change-Id: I863ad05e892563442041722bcd57f7c987e1f5ab
2023-03-04 22:44:10 +00:00
Neels Hofmeyr 7214e56b49 VTY,CTRL: add pchan dynamic/{osmocom,ipaccess}
We already use "OSMO_DYN" as C name for "fully dynamic" timeslot config,
when working with osmo-bsc.cfg I dearly miss this short name, it is a
pain / has become ridiculous to write 'tch/f_tch/h_sdcch8_pdch'.

Introduce 'dynamic/osmocom' and 'dynamic/ipaccess' as default names for
our dynamic timeslots on VTY and CTRL. The old 'tch/f_tch/h_sdcch8_pdch'
and 'tch/f_pdch' are still supported.

Change-Id: I37719edd867c777d1ce944b8e2f1efffac38f00e
2023-03-04 22:44:10 +00:00
Neels Hofmeyr 71e838ed02 ensure correct phys_chan_config doc string count on VTY
Add a static assert, and comments indicating the importance of the two
value_string arrays defining pchans on the VTY matching up.

Change-Id: I8118bec35400f7f00ca9ae43b603059ed701fa25
2023-03-04 22:44:10 +00:00
Neels Hofmeyr 822b9dca1f vty: msc / codec-list: forbid invalid codec versions
Change-Id: I421c306aa22dfdad0f30c6ba8b482e1eff188a8e
2023-03-04 22:44:10 +00:00
Neels Hofmeyr 72fe0bf142 vty: msc / codec-list: forbid duplicate entries
Change-Id: Ifdc9e04bf1d623da65bfb8a2fddea765601f6d9b
2023-03-04 22:44:10 +00:00
Neels Hofmeyr 89dd152577 simplify storage of bsc_msc_data->audio_support
Make it a plain array, no dynamic allocation needed.

Change-Id: I625cedc4bb040d649fd6e1794ba468f4c6ad6adc
2023-03-04 22:44:10 +00:00
Oliver Smith 5ea91cdae4 test_codec_support_bts_rate: add missing breaks
Fixes: 3db22c61 ("cosmetic: clarify test_codec_support_bts()")
Fixes: CID#310823
Change-Id: I951783b6310f0a6ef5546a36c962def9d6e66285
2023-03-03 09:05:37 +01:00
Neels Hofmeyr c729d82b17 assignment_fsm.c: make two functions static
Change-Id: I33eef9d105bacbb46538dff233502e834f7a3b51
2023-03-02 17:56:48 +01:00
Neels Hofmeyr b599836c7a implicitly register osmo_fsm definitions
I'm going to add a regression test that probes lchan_fsm. I noticed that
I have to call lchan_fsm_init() for osmo_fsm_register(). Let's make this
implicit as we usually do now, to not have to register FSMs in tests.

Change-Id: I58760e743c78a370aedc9720f265c0f8da5c2045
2023-03-02 17:56:48 +01:00
Neels Hofmeyr 7bd795515f select_codecs(): constify ct arg
Change-Id: Icb07374b40629e48d811a036b9a56d026c1d897c
2023-03-02 17:56:48 +01:00
Neels Hofmeyr 89493f76b1 select_codecs(): doc tweak
Change-Id: I52a111b1992db1e335c692d2caee7c5398a6f90e
2023-03-02 17:56:48 +01:00
Neels Hofmeyr 3db22c6116 cosmetic: clarify test_codec_support_bts()
Change-Id: I13d9b158d08f4938c5aa47ef3134819a4b1f7d29
2023-03-02 17:56:48 +01:00
Neels Hofmeyr ce8d39d97c vty: msc / codec-list: tweak error msg
Change-Id: I7ba508cceccb8a25db0936f756f3e4a28ec1333f
2023-03-02 15:03:44 +00:00
Neels Hofmeyr ec6360e005 bsc_vty.c write_msc(): fix weird printf format
Change-Id: I856c2d620b89efcf3239186ef53c6941577dbccc
2023-03-02 15:03:44 +00:00
Neels Hofmeyr f30f630a88 bsc_vty.c: s/bsc/msc for commands under msc node
Change-Id: Id91a82ca8e2eb91b52836e024ccf925245886ae6
2023-03-02 15:03:44 +00:00
Neels Hofmeyr 8196ef5405 vty: improve doc for 'codec-list'
Change-Id: I33e6568997bcb1a9466e1e0c1b00718b703e2904
2023-03-02 15:03:44 +00:00
Neels Hofmeyr 8b55573a73 cosmetic: use i++ instead of ++i in for loop
Change-Id: I9903e54e3eb59db9b9cd22e017bc81b9b86e01e9
2023-03-02 15:03:44 +00:00
Neels Hofmeyr 91ab3fe5a0 cosmetic: use char literals in cfg_net_bsc_codec_list()
Change-Id: I1a29fb54cdcd15c6e9b6447d929db0e9492264f7
2023-03-02 15:03:44 +00:00
Philipp Maier 52b74175dd abis_rsl: guard against over long IMMEDIATE ASSIGNMENT Messages
The length parameter in rsl_imm_assign_cmd_common() may cause a buffer
overflow when it is chosen larger than GSM_MACBLOCK_LEN. Lets make sure
this cannot happen.

Change-Id: I9417b35fb8c0517f2555e17059bf8ac60fa59791
2023-03-02 14:59:41 +01:00
Vadim Yanitskiy 4a61575917 utils: fix incorrect string checks in meas_db_insert()
Comparing an array to null is not useful, since the test will
always evaluate as true (NO_EFFECT).

Change-Id: I8a41078070119bc22d594c0dfff5d98b5d16f970
Fixes: fbead4327 utils: store more fields from meas-feed in db
Fixes: CID#310821
2023-03-01 21:53:24 +00:00
Philipp Maier 111b13f9a2 pcu_sock: print OML alerts from PCU
The PCU is able to send OML alerts via the BTS to the BSC. When the PCU
operates in co-location to the BSC we just print the alerts in the log
directly

Change-Id: Id32553556356c2affe32e47ae1c3ae6a514efdce
Related: OS#5198
2023-03-01 11:21:50 +01:00
Oliver Smith 4e54e16b9f codec_pref: split test_codec_support_bts_rate
Move the check for the rate into an extra function, so it can be used
for CSD without checking a speech codec at the same time.

Related: OS#4393
Change-Id: Iea8a23ef3c66ed556110038fe9f3bc7f6eef3e96
2023-03-01 08:11:15 +00:00
Oliver Smith f597a035fa bssmap_handle_ass_req_ct_speech: refactor
Move the translation from osmo_sockaddr_to_str_and_uint into
bssmap_handle_ass_req_tp_rtp_addr, which will be used by
bssmap_handle_ass_req_ct_data in a future patch too.

Pass pointers to variables in req, instead of duplicating variables and
filling it in later (like in bssmap_handle_ass_req_ct_sign).

Related: OS#4393
Change-Id: I6bb16b26d89056dffa50bd8296fefe9315c587ca
2023-03-01 08:11:15 +00:00
Oliver Smith 71c8bdfc56 bssmap_handle_ass_req_ct_speech: split up
Allow reusing common code in an upcoming bssmap_handle_ass_req_ct_data.
It won't use _osmux for now (maybe in the future?), but splitting it
out as well makes it consistent.

Related: OS#4393
Change-Id: I4d9a4df314b1e56b9c1f90c9d7914332b70b56f8
2023-03-01 08:11:15 +00:00
Oliver Smith 31f81d55fc bssmap_handle_assignm_req: split up
Prepare to implement GSM0808_CHAN_DATA without making this function even
longer.

Related: OS#4393
Change-Id: I8580e75e292cff1b52b6ba1bafd12c155c3bbe93
2023-03-01 08:11:15 +00:00
Michael Iedema fbead43271 utils: store more fields from meas-feed in db
More fields need to be captured from meas-feed
to perform meaningful analysis of data from
multi-bts and multi-trx systems.

This patch adds expands the existing db utils
to record nearly all available fields from
meas-feed.

Change-Id: I509c939524b11a4ee455bcfc3ebee6c5c35b9fba
2023-02-28 18:45:48 +00:00
Oliver Smith 146c228df2 Cosmetic: codec_pref: tweak comments
Remove "Helper function for match_codec_pref()" at the beginning of the
descriptions of these functions, looks like a leftover from before this
was moved to its own c file. Remove a duplicated "received" in a
comment.

Change-Id: I30f0744db9aebf2f05077fef840097c332b9dafd
2023-02-28 11:06:47 +00:00
Oliver Smith 0e552cc9c1 Cosmetic: fix various typos
Change-Id: I9225e733e3afa8171f24253e21eaffc654f689af
2023-02-28 11:06:47 +00:00
Oliver Smith 88133a746d osmo_bsc_main: don't allocate talloc_ctr_ctx
tall_ctr_ctx is not defined or used in osmo-bsc and apparently was only
exported by accident from libosmocore. It's not exported anymore since
libosmocore.map was introduced in I13169c00a59fb59513dfc598de5a71d094492422.

Fix for:
  /usr/bin/ld: osmo_bsc_main.o: in function `main':
  osmo_bsc_main.c:(.text+0x830d): undefined reference to `tall_ctr_ctx'
  /usr/bin/ld: osmo_bsc_main.c:(.text+0x8331): undefined reference to `tall_ctr_ctx'

Change-Id: I558e1ec722f3b1ff1f2e89b3cb97ed1dba9063e3
2023-02-28 09:36:00 +01:00
Oliver Smith 4bcfb7e034 fsms: use configurable timers instead of T23042
T23042 was a placeholder for timers to be filled in later. Replace it
with timers that can be configured via VTY.

Previous timeout for the states was 5s, from using the default of 5 for
undefined timers.

* ASSIGNMENT_ST_WAIT_MGW_ENDPOINT_TO_MSC and
  HO_ST_WAIT_MGW_ENDPOINT_TO_MSC:
  * Runs gscon_connect_mgw_to_msc() on enter, which waits for one MGCP
    CRCX or MDCX response (or changes state immediately)
  * Use existing X9 ("Timeout for availability of MGW endpoint"), 5s,
    which is already being used by lchan_rtp_fsm for a similar purpose

* HO_ST_WAIT_RR_HO_DETECT:
  * Handover initiation as described in 3GPP TS 04.08 § 3.4.4.1:
    "The network initiates the handover procedure by sending a HANDOVER
     COMMAND message to the mobile station on the main DCCH. It then
     starts timer T3103."
  * Use existing but unused timer T3103 ("Handover"), 5s

* HO_ST_WAIT_RR_HO_COMPLETE:
  * Handover completion as described in 3GPP TS 04.08 § 3.4.4.3:
    "When receiving the HANDOVER COMPLETE message, the network stops
     timer T3103 and releases the old channels."
  * Continue using T3103 with keep_timer = true

Closes: OS#5787
Change-Id: Id0d4d0788f609f3272fc81c80a754383dde25c16
2023-02-16 14:49:39 +01:00
Oliver Smith cb3eb23ec2 ho: remove timeout for HO_ST_WAIT_LCHAN_ESTABLISHED
Remove placeholder timer T23042. This handover fsm state waits for both
RSL/RR and RTP/MGW to be complete. I've added TTCN-3 tests to ensure
that both cases are covered by existing timer T3101 in lchan fsm state
LCHAN_ST_WAIT_RLL_RTP_ESTABLISH, which on timeout lets the handover
fail.

Related: OS#5787
Related: osmo-ttcn3-hacks I30e1811f97406cff6ba794fcd6882e2bb0205087
Related: osmo-ttcn3-hacks I2f79e3ff988a4315fbef3538f02403b818fa7839
Change-Id: I53468766c3c5fad7d7e275c0f20b5c20677fe4e8
2023-02-16 14:49:39 +01:00
Oliver Smith 23e3e29b7a ho: remove timeout for HO_ST_WAIT_LCHAN_ACTIVE
Remove placeholder timer T23042.

Neels wrote:
> I think the right thing here is to remove this timeout; this needs
> no timeout at all because we can rely on the lchan_fsm to either
> return HO_EV_LCHAN_ACTIVE or HO_EV_LCHAN_ERROR after the usual
> timeouts set for lchan activation. IOW since it is internal to
> osmo-bsc one of the two events is guaranteed to occur.
>
> If we superimpose a timer on top of the lchan timeouts, configuring
> larger lchan activation timeouts becomes complex, because the user
> has to take care to also allow a larger timeout for the same
> procedure during HO.

Related: OS#5787
Change-Id: Ibf740aaa9bddc2de85cf8087ad90bab47aac12c2
2023-02-16 10:37:17 +00:00
Philipp Maier 329e1cdc22 bsc_subscriber_conn_fsm: use subslot 0 in case of E1 full subslot
In classic E1 based GSM networks the audio is usually transfered through
16bkps I.460 subslots while 4 16kbps subslots are multiplexed into one
E1 timeslot. However, there may be setups where still 16kbps subslots
are used, but with 1 instead of 4 channels per timeslot. In those cases
the bit offset is 0, while the rate is still 16kbps.

Change-Id: I0d2bc44acaa8e5a28cccfdf7cfb945bf14a4ed30
Related: OS#5198
2023-02-13 12:39:22 +01:00
Philipp Maier d4044214ca bts_trx_vty: use define constant E1_SUBSLOT_FULL instead magic number
Change-Id: I0be228d4473215c6bd36c668e0e10e64965732e7
2023-02-13 12:39:22 +01:00
Philipp Maier ec1a0a102f pcu_sock: set direct TLLI flag in info indication
osmo-bsc requires the PCU to tag IMMEDIATE ASSIGNMENTS that shall be
sent via PCU with a TLLI. This is required to confirm the sending of the
IMMEDIATE ASSIGNMENT messages to the PCU.

Related: OS#5198
Change-Id: Ib804143a57824632e5435f7ba68f2e94f5f3fb21
2023-02-13 12:39:22 +01:00
Philipp Maier ee43e37528 pcu_sock: transfer E1 connection information to PCU
The BSC has all information about the E1 line configuration of each
timeslot/channel. The PCU is responsible for opening and managing the
CCU connection. To enable the CCU to do that, we have to transfer the E1
connection information (which TS, SS, rate) to the PCU.

Change-Id: I6d44373336b41009ff4c6e459d32d0a81081676c
Related: OS#5198
2023-02-13 12:39:22 +01:00
Philipp Maier f18e9c36f4 pcu_sock: transfer sysinfo to PCU
The PCU needs to be aware of the current system information in order to
work properly.

Change-Id: Ibbfbfaf588a4e406804c36570010aefdfc14328b
Related: OS#5198
2023-02-13 12:39:22 +01:00
Philipp Maier 8a0572256b abis_rsl: constify parameters of rsl_X_imm_assign_cmd
Related: OS#5198
Change-Id: I1bd2e0c844bf273d2c4381eec9e9bb9562254873
2023-02-13 12:39:22 +01:00
Philipp Maier 107d311d96 pcu_sock: use extract_paging_group() for PCU_IF_SAPI_PCH
We have introduced the function extract_paging_group() with the previous
patch. Lets use it for PCU_IF_SAPI_PCH as well to remove code
duplication

Change-Id: If4ffe8eafd2e54e323cbc075c09d457a74ebe83f
Related: OS#5198
2023-02-13 12:39:22 +01:00
Philipp Maier 7a346a547e abis_rsl: add support for sending IMMEDIATE ASSIGNMENT through PCH
The IMMEDIATE ASSIGNMENT for downlink TBFs needs to be sent through the
PCH instead of the AGCH. Since this method is not specified in RSL, it
is usually a vendor specific extension.

Change-Id: I4452f4973d1ec69c96aad527b057226e8a6edf99
Related: OS#5198
2023-02-13 12:39:22 +01:00
Philipp Maier 84811c901e pcu_sock: cosmetic: remove space before tab
Change-Id: I6f3f96120d8a106f7c9e8b428d89ed14999a10a8
2023-02-11 14:06:44 +01:00
Philipp Maier 3c4320f935 pcuif_proto: rename PCU_IF_SAPI_AGCH_DT to PCU_IF_SAPI_PCH_DT
The current name of PCU_IF_SAPI_AGCH_DT is a bit misleading as it
describes a method to send immediate assignment messages (normally AGCH)
via the PCH. The name in the constant should reflect that correctly

Change-Id: I78abeb62d0267baa31a4727c4bdd027b7230f137
Related: OS#5198
2023-02-11 14:06:44 +01:00
Max 54b7cd5392 doc: correct reference and add deprecation notice
Change-Id: I46f1f070cb00c4c27247593527b0173e1fd5de67
2023-02-10 11:41:23 +00:00
Vadim Yanitskiy dc634a8836 bsc_vty: use gsmnet_from_vty() everywhere, not vty->index
Change-Id: Ic08d1213c3b353bdf9b425e24382b6c5bd229c9c
2023-02-06 17:42:42 +00:00
Vadim Yanitskiy 3b5e469485 fix bsc_vty_go_parent(): add missing case for MGW_NODE
A new VTY node was added in commit [1], but bsc_vty_go_parent() was
not updated.  Because of that, commands following the MGW node may
crash osmo-bsc.  In the example below:

  network
   network country code 901
   mobile network code 70
   ...
   mgw 0
    remote-ip 127.0.0.1
    local-ip 127.0.0.1
   periodic location update 30

the 'periodic location update 30' will trigger a segfault:

  (gdb) bt
  #0  0x00005555555dfc09 in cfg_net_per_loc_upd ()
  #1  0x00007ffff7af6c3f in cmd_execute_command_strict () from /usr/local/lib/libosmovty.so.9
  #2  0x00007ffff7af6f1c in config_from_file () from /usr/local/lib/libosmovty.so.9
  #3  0x00007ffff7afd4e1 in vty_read_config_filep () from /usr/local/lib/libosmovty.so.9
  #4  0x00007ffff7afe375 in vty_read_config_file () from /usr/local/lib/libosmovty.so.9
  #5  0x0000555555579616 in bsc_network_configure ()
  #6  0x000055555557a352 in main ()

because vty->index would be NULL after returning from the MGW node.

Fix this by adding the missing case to bsc_vty_go_parent().

Change-Id: Id3050ff7e2402c33ee76c7bf0cc83603c0cc6dfc
Fixes: [1] 8d22e68706
2023-02-06 17:42:42 +00:00
Philipp Maier 38e4fb4014 timeslot_fsm: remove duplicate TS_ST_BORKEN from out_state_mask
The stete TS_ST_WAIT_PDCH_DEACT has TS_ST_BORKEN twice in
out_state_mask. This is unnecessary.

Change-Id: Ib758150ba7074adbb1b59008f0dfb57766763897
2023-02-06 16:09:17 +00:00
Philipp Maier c206cd7808 pcu_sock: rework log output
The code is easier to read when the log string is in one line

Change-Id: Idc673e0b15869c6966701524db1af7d7847c16ab
Related: OS#5198
2023-02-02 10:58:09 +01:00
Philipp Maier 364f7ec189 pcu_sock: remove unecessary OSMO_ASSERT()s
Change-Id: I8320cbc14361438d65642d15bc225e9960ce925b
Related: OS#5198
2023-02-02 10:55:06 +01:00
Philipp Maier b9558272f2 pcu_sock: Also fill in BSIC in gsm_pcu_if_info_ind
When filling in the info_ind parameters we lack the BSIC

Change-Id: I22158b18f50a7adf4ba1fed25bd7a880dc109e3d
Related: OS#5198
2023-02-02 10:54:32 +01:00
Philipp Maier 16b891ffb9 pcu_sock: fix endianess when populating gsm_pcu_if_info_ind
The intended endienaess for the remote_port member is host byte order,
while the endianess in the nsvc struct is in network byte order.

(see also pcu_sock.c in osmo-bts.git)

Change-Id: Ib62dcceb80fd500e477dd5e1a0e43de47e16eeb0
Related: OS#5198
2023-02-02 10:52:51 +01:00
arehbein 97ed3c8d97 bsc_ctrl_commands: Add GET for bts neighbor-list (local bts numbers)
Related: SYS#6287
Change-Id: I79aeffd93089086f57c66787fe20b439a4d8b6b4
2023-02-01 23:19:55 +00:00
Philipp Maier 3fff53aed7 timeslot_fsm: Warn in case Ercisson RBS uses static PDCH
The Ericsson RBS is a BTS that natively works with dynamic timeslots.
This colides with the current understanding of static PDCH channels
because the BTSs we support so far get thier static PDCH information on
startup and then handle everything related internally. The BSC does not
actively manage the channel in those cases. In the case of Ericsson we
have to activate the PDCH via RSL like any other channel and the timeslot
FSM has to manage it. Lets not add work arouds for this, lets just print
and error message and use the BTS in the dynamic scheme as intended by
the manufacturer.

Change-Id: Icc7c2956fc934691e3bfacb283d896a8767baf27
Related: OS#5198
2023-01-31 15:50:42 +01:00
Philipp Maier 373d4f05f6 pcu_sock: rework check logic for ts
Before filling in the TS in the info indication, it is checked that the
MO opstate is enabled. Also it is checked that the TS serves a PDCH.
Lets restructure this check and move the PDCH check into a helper
function as we need to check for PDCH from other location as well later.

Change-Id: Icaab52ab73c38889dfadb523b89bb54cafacc99a
Related: OS#5198
2023-01-31 12:05:02 +01:00
Philipp Maier cb3140faf6 abis_om2000: send TS_EV_OML_READY when TRX is fully done
We send the TS_EV_OML_READY event early, even though the TRX is not
fully done with all OML initialization steps. Lets complete the TRX
initialization first and then notify each timeslot FSM with
TS_EV_OML_READY.

Change-Id: If5251b102c8aa45dfc8cc4ee4e0223d7dc438938
2023-01-31 12:05:02 +01:00
Philipp Maier 4c680eb798 pcu_sock: clean up logging in info_ind_fill_trx
Change-Id: Ie5c1abcf7b25fe00b6c228c49648e018f94190f0
Related: OS#5198
2023-01-31 10:50:37 +01:00
Philipp Maier f21d423b0c pcu_sock: fix sourcecode formatting
Change-Id: I593c16efa1639aa8d2f90735bfdc9750cf695ecd
Related: OS#5198
2023-01-30 17:45:30 +01:00
Philipp Maier a68cdf57a3 pcu_sock: check trx mo state
Make sure that the TRX MO state is enabled and unlocked before filling
in any TRX information into the info indication

Change-Id: I7a93826e6b0df187425310cb82854e7d7fb47e72
Related: OS#5198
2023-01-30 10:36:08 +00:00
arehbein 2a24613e39 osmo-bsc: Fix 'apply-config-file' CTRL command
Make 'apply-config-file' check the neighbor config, just as is done after config parsing on startup

Related: OS#5866
Change-Id: I24ae8cd7e5e0d15eab9fd04b1858072bf0bad36a
2023-01-26 21:28:57 +00:00
Max 484f0771cd SI: set type 10 length properly
According to 3GPP TS 44.018 §9.1.50 SI10 is 168 bits long.

Related: OS#5783
Change-Id: Ifd76ebb10029b95a80a85bea4d102d5e100c182c
2023-01-23 18:24:18 +00:00
Max 715dc37b10 SI: use defined constant instead of magic number
Related: OS#5783
Change-Id: I2ecac86fb860241bccf56c03d0454f07552fdc9d
2023-01-23 18:23:48 +00:00
arehbein 945e2514ca osmo-bsc: Log error regarding BTS number explicitly
Related: OS#5864
Change-Id: I64d12b3ebadbf550ecb72ccde2845951e3e309ee
2023-01-23 10:39:37 +00:00
arehbein fd6b81a042 vty: Add check against sensible default value for Ny1
Related: OS#5475
Change-Id: If3f96a6bd4f9ae32b6421de43c1c5a5d64482089
2023-01-23 09:59:36 +00:00
arehbein 9ff26123b3 vty: Add support for Ny1 configuration
Related: OS#5475

Change-Id: I6318cceb4ebdce50005e39e2e9323c1c8433250a
2023-01-23 09:59:36 +00:00
Philipp Maier 8c8905302f pcu_sock: move code that fills in trx info to helper function
The function pcu_tx_info_ind() fills the trx information in the info
indication. Since the function is already quite long, move the trx
related part into a sperate helper function.

Change-Id: Ic30185c9364adcc61d0a9d3483b0550ac1cdf894
Related: OS#5198
2023-01-12 15:39:30 +01:00
Philipp Maier a8ad2b1b93 pcu_sock: guard against too many TRX
The pcuif only supports a limited but sufficient number of TRXs. When
filling in the TRX array in info_ind, we must guard against overflowing
the maximum number of TRXs

Change-Id: I351080a112f3d3fdf833ee7fa0d77c4cd1d13e42
Related: OS#5198
2023-01-12 15:39:30 +01:00
Philipp Maier 0b7d9b26b6 abis_rsl: fix sourcecode formatting
Change-Id: I6c4b6bd86c081046e34f51625c86015fc58c55c2
2023-01-12 13:59:22 +00:00
Philipp Maier 9b45d86e5e abis_rsl: fix frame number calculation
The formula that is used to recover the (relative) frame number from the
T1, T2, T3 parameters matches the definition in the spec, but since the
partial term t3-t2 can be negative special precaution is required when
performing the MOD 26 operation.  This is due to the truncated modulo
implementation in C/C++, which has a very specific understanding on how
to deal with negative input parameters.

The libosmocore gsm_gsmtime2fn(() offers a correct implementation, so
lets use it.

Change-Id: I5fb2b0ada8d409730ac22963741fb4ab0026abdd
Related: OS#5198
2023-01-12 13:55:49 +01:00
Philipp Maier 5cd6d86e94 pcu_sock: drop unused variable pcu_direct
The variable pcu_direct is set to one permanently, lets remove it.

Change-Id: I7917ee5abc3347776dc9793cfb4ec3e99df94683
Related: OS#5198
2023-01-10 12:53:42 +01:00
Philipp Maier c5476db6a5 pcu_sock: drop unused function prototype
The function trx_get_hlayer1() is defined as a prototype but it is not
used anywhere and there is also no implementation, lets drop it.

Related: OS#5198
Change-Id: I91ead9379140e971ccabc83cbf2b62b8aa1fc8a2
2023-01-10 12:53:06 +01:00
Philipp Maier 813e083f90 abis_rsl: when doing packet access, log t1,t3,t2 and fn
The (relative) frame number that is forwarded to the PCU is an
important parameter which is computed from t1,t3,t2.

Change-Id: I83d20ba9e0ce6488d458ccf4a85c8445c30e3a89
2023-01-10 12:29:50 +01:00
Philipp Maier f471b3932a abis_rsl: show full request reference in log
When a CHAN RQD is received via RSL, we show ra and other parameters.
Lets also show T1, T3 and T2.

Change-Id: I78499b49ae176b736e384e193fadc0bdd669dffa
2023-01-10 11:27:55 +00:00
Philipp Maier 71a4f1302b abis_rsl: add spec ref for frame number calculation
The frame number calculation in rsl_rx_pchan_rqd() is done using a
specific formula. Lets add a spec reference and also restructure the
code a bit.

Change-Id: I60500c8694dbc2e6e2c4bbffd4ff7057bbc324e6
2023-01-06 16:22:04 +01:00
Pau Espin 22cbe9a332 bsc_compl_l3(): Update documentation regarding no bsc_subscr in conn
TTCN3 have been improved in osmo-ttcn3-hacks.git Change-Id
I6e99ac39f32c9a981420b73f8d7d1568d2fa1c54 to use valid l3 data.

Related: SYS#6280
Change-Id: I4918f1741d465abf8b06a9c65199a44b09778299
2023-01-03 18:23:24 +01:00
Pau Espin c409977031 bsc_subscriber: Allow creating subscribers identified by IMEI
IMEI may be used as MobileIdentity during MO emergency call
establishment if the MS has no valid IMSI assigned.

Related: OS#5849
Change-Id: I586b1ee30cbb26ddf58788168d56c962e03ccd5c
2023-01-03 16:46:05 +01:00
Alexander Couzens 315af2f9ea bts: ipa/osmo-bts/sysmobts: MO: add support for the second NSVC
The second NSVC MO has been explicit skipped and never been interacted with.
osmo-bts is already supporting it for a long time as well the PCU is
supporting it at least since the NS2 code migration.
Fixes the ttcn3 test case BTS_Tests.TC_pcu_socket_two_nsvc.

Closes: OS#5835
Change-Id: I3486a7cc9a424602b73f8adc2fefce169213e46b
2023-01-03 09:13:52 +00:00
Pau Espin 6cc5f08eb8 bsc: Fix crash if PagingResponse with invalid MobileIdentity is received
It was found in a BSC on the field that an MS sending an incorrect
MobileIdentity IE (wrong length) in PagingResponse was generating a
crash on the BSC.

When the MobileIdentity cannot be parsed right now we keep on instead of
rejecting the conn. This should change in the future, but it needs
further improvements in our TTCN3 tests. For now let's simply validate
the subscriber is not NULL; since recently paging optimizations made
paging_request_stop() require the subscriber to be non-null.

Fixes: 27cb5d3e24
Related: SYS#6280
Change-Id: If8b439ff74c5dd690d637d3e3278c75d6cd6b928
2023-01-02 16:58:36 +01:00
arehbein 6c2798c5ce osmo-bsc: Transition to use of 'telnet_init_default'
Related: OS#5809
Change-Id: I9d4dc72f8296f82937d2b97fd40a202f1ac98403
2022-12-23 11:13:42 +00:00
Max c230853446 ctrl: take both address and port from vty config
Change-Id: Ic2c56ffee6237333d919c72bf26076ac24a1fa52
2022-12-20 15:22:23 +00:00
Neels Hofmeyr fc33972530 fix Speech Codec cfg in BSSMAP Assignment Complete
In send_assignment_complete(), obviously return the current channel
configuration from lchan->current_ch_mode_rate, which is the proper
place to get the channel mode after RSL Chan Activ Ack.

It is interesting to look at the history of this line of code.
lchan->current_ch_mode_rate was added later, so now the mistake is very
obvious.

Related: SYS#6229
Change-Id: I3bf8f5ea9ae2a3c12fc5b483818d550a069fe66e
2022-12-19 12:17:35 +00:00
Pau Espin aa292a482c vty: Write amount of timeouts elapsed for a paging request
Related: SYS#6200
Change-Id: I55c84c0d20fc4120b7b4cdd06ed95a8847a6600a
2022-11-30 20:23:39 +01:00
Pau Espin 867e73e96b paging: Optimize retrieving number of request per paging group
This patch caches the counts of initial paging requests for each paging
group. This count is needed to estimate T3113 when a new incoming paging
request is received and it has to be inserted into the queue.
With this there's no need to traverse the whole initial_req_list every
time a new incoming paging request is receiving, potentially saving lots
of iteration and hence lots of CPU when the queue is long.

Related: SYS#6200
Change-Id: I6994127827d120a0b4dd3de51e1ddde39f2fe531
2022-11-30 20:23:39 +01:00
Pau Espin d681b897b6 paging: Replace reqs waiting for retransmission with new incoming inital req if queue is full
If queue size (in transmit delay of requests) is too long (above
threshold) when a new initial incoming request arrives, instead of
directly discarding it, see if we can drop a pending retransmission and
insert the new one instead, in order to avoid losing initial requests.

This is done under the assumption that it is more important to transmit
intial requests than to retransmit already transmitted ones. The
rationale is that there's lower chances that an MS which didn't answer
lately will answer now (aka being reachable at the cell), so it's better
to allocate resources for new requests (new MS) which may be available
in the cell.

Change-Id: Idfd93254ae456b1ee08416e05479488299dd063d
Related: OS#5552
2022-11-30 20:23:34 +01:00
Pau Espin 3b5e898271 paging: Split paging queue into 2 queues: initial and retrans
Initial requests: paging requests which haven't been yet transmitted
Retrans requests: paging requests which have already been transmitted at
least once.
Until now one queue was used (llist) to store both. The initial requests
were stored at the start of the queue in FIFO order. After the last
initial requests, the retrans requests followed also in FIFO.

This ordering was used in order to prioritze scheduling of initial
paging requests over retransmit paging requests.
In the end, having both types in the same list only make code handling
the list more complex.
Hence, this patch splits the shared llist into 2 llists.

Related: SYS#6200
Change-Id: Ib68f2169e3790aea4ac77ec20ad79f242b7c2747
2022-11-30 20:10:35 +01:00
Pau Espin 8c723f5157 paging: Fix wrong count of reqs_before if queue only contains retransmissions
When adding a new incoming request (aka "initial_req"), if the queue is
full only of retransmis (no not-yet-ever-transmitted initial requests
queued), then the new incoming request is inserted at the start of the
queue, in order to take scheduling priority over retransmits.

This was already fine before this patch, but the counting of requests
before it (used to calculate its T3113) was wrong, because it counted all
the retransmissions. This patch fixes it to end up with
reqs_before(_same_group)=0.

Change-Id: Ib2e810b0bcc51eac117713584310272462c58867
2022-11-28 19:01:46 +01:00
Pau Espin 671811f4fc paging: Introduce VTY configurable X3113 (Maximum Paging Request Transmit Delay Threshold)
This allows configuring the maximum delay of paging requests to be
queued according to other parameters, such as MSC paging request
timeouts, etc.

Related: OS#5552
Change-Id: Ia556ef4e474e6a2d0d1618bab680a3330a3c062b
2022-11-28 16:30:12 +01:00
Pau Espin 8ff2931862 vty: Fix lost 'no timer-dynamic T3113' config when writing current config
The default is to have a dynamic T3113. However, if the user wished to
set it statically, it would show up when writing the current VTY config.

Change-Id: If121a97bbb4a0234a0c162ef37c3692d6408404d
2022-11-28 16:03:08 +01:00
Pau Espin 882602cdd8 paging: paging: Drop unneeded extra param in paging_remove_request()
The BTS can be obtained easily from the backpointer in req->bts. Having
the extra param can only lead to confusion and introduction of bugs, as
happened in bug fixed by Change-Id
I8c6828f86b7ccbb2c4a09ca1aec859a2c597b679.

Related: SYS#6200
Change-Id: I545fd853fdffce7f23f0d99203c66c3b39144e4b
2022-11-24 18:24:47 +01:00
Pau Espin 346c6011bc paging: Fix regression stopping active requests on unanswered BTS
When rewriting the loop, the pointer passed all the time to
paging_remove_request() was the one of the BTS which answered the
request, not the one actually handling the related unanwared still
active paging request.

Fixes: 70a1d60a83
Related: SYS#6200
Change-Id: I8c6828f86b7ccbb2c4a09ca1aec859a2c597b679
2022-11-24 18:14:26 +01:00
Pau Espin 5f46039f68 subscriber: constify bsub func param
Change-Id: I8603162abf9df71f94aa1549ea449f29ecd73b6d
2022-11-24 17:46:40 +01:00
Pau Espin 934a9b06c7 paging: constify bts param in some functions
Related: libosmocore.git Change-Id Ib11bfe57f546a5618f70152b9b75115808e54bf6
Change-Id: Icb85fecba142151b05f289adae8894cd50396224
2022-11-24 17:15:36 +01:00
Pau Espin 94951af66a paging: Introduce BTS stat paging:available_slots
This allows analysing the behavior of paging queue at the BTS over time.

Related: SYS#6200
Change-Id: I5f44ac9b9da3ed7120b04d199e52215c0fd3e8a9
2022-11-23 11:09:05 +00:00
Pau Espin a3e5b0db7d paging: Introduce BTS stat paging:request_queue_length
This allows tracking each BTS active paging request queue length over
time, and evaluate CPU load based on the number of active paging
requests queued.

Related: SYS#6200
Change-Id: I6d296cdeba1392ef95fc31f6c04210c73f1b23e5
2022-11-23 11:09:05 +00:00
Pau Espin fd62ac483e paging: Rename stat t3113 -> paging:t3113
This way all paging related stats can be grouped  (more will be added in
follow-up commits).

Related: SYS#6200
Change-Id: Iede1b6f68df468c7a3b3bf5fce7f68bb08b78832
2022-11-23 11:09:05 +00:00
Oliver Smith 1784524392 Cosmetic: fix spaces around timers
Use spaces around equals signs inside structs, as expected from the
kernel coding style we mostly follow.

Neels wrote:
> IIUC "T=123" without spaces is my personal favorite that goes against
> the accepted linter standard, i guess rather than everyone else
> adapting to my weird style, i should start adding spaces in my
> patches.

Change-Id: I01ce986a1b0cdd74d945a04ae62a07f2850d366f
2022-11-23 10:18:32 +00:00
Oliver Smith a68b80eb9e lchan_fsm: fix lchan_fsm_on_error size
Set it to 32, because osmo_fsm allows 32 states.

Change-Id: I62f5e0f380513c52ea6932b270cf0c852930eb9f
2022-11-23 10:18:32 +00:00
Oliver Smith adb55f1fe0 Cosmetic: lchan_fsm: drop obsolete comment
Neels wrote:
> i guess we can drop this comment now, it is a remnant from separating
> osmo-nitb -> osmo-bsc + osmo-ms

Change-Id: I2ce4d691715c1ea5c7c7896693a03b0aefbdb5b9
2022-11-23 10:18:13 +00:00
Pau Espin 27cb5d3e24 paging: Use bsub->active_paging_requests to optimize cancelling based on reason
Prior to this patch the whole paging queue of each BTS was iterated.
After the patch only the active paging_req for a given subscriber are
iterated.

Related: SYS#6200
Change-Id: I225d5e08427c6bb9d92ce6a1dccb6ce36053eab5
2022-11-22 19:55:46 +01:00
Pau Espin ccba3a9e4f lcs: Fix passing NULL bsc_subscr to paging_request_cancel()
This is triggered by BSC_Tests.TC_lcs_loc_req_no_subscriber.
Before, the NULL ptr was not a problem because paging_request_cancel()
only used the pointer to compare it against other pointers, but never
accessing it. A follow-up patch is, however, changing the implementation
to optimize the lookup by using the subscriber pointer, which generates
a crash.

Related: SYS#6200
Change-Id: Id0de43ac5bde0f52f258de6c9bf58b173301c8db
2022-11-22 19:55:46 +01:00
Pau Espin 0ed7700c1e paging: Use bsub->active_paging_requests to allow early loop termination adding paging_req
Before this patch, the entire queue of paging_request had to be iterated
in order to find if the subscriber already had an active paging request
(discarding duplicates).

Now that bsc_subscriber holds a list of its active paging requests, it's
easier to look at its list to find out if it is already active on that
BTS.

As a result, there's no need to unconditionally iterate the whole list
and we can optimize the loop finding the spot to insert the new queue:
- First the potentially way smaller loop over
  bsub->active_paging_requests is done
- Second, only if the first loop allowed, the bts->pending_requests is
  iterated and potentially early terminated.

Related: SYS#6200
Change-Id: I7912275026c4d4983269c8870aa5565c93277c5a
2022-11-22 19:55:10 +01:00
Pau Espin 70a1d60a83 paging: Store list of gsm_paging_request in bsc_subscr
This allows havily decreasing the algorithmic cost of removing all
pending active paging requests for a given subscriber once it answers
on a given BTS.

Beforehand, the whole paging queue of all BTS were iterated. Now, only
the active requests for that subscriber are iterated.

Related: SYS#6200
Change-Id: I831d0fe01d7812c34500362b90f47cd65645b666
2022-11-22 19:53:17 +01:00
Pau Espin 2709614011 paging: Get rid of unneeded count returned
The return count is not used since there's no use for it. Get rid of it
to simplify the code.

Change-Id: I7bf04b94173f0ae7b26caf5d7f9abeeb9abf9b6c
2022-11-22 16:05:09 +01:00
Pau Espin ae07416208 paging: Avoid repeated paging req lookup on BTS receiving paging resp
This saves the BSC from iterating twice the whole paging list of the BTS
which received the paging response.

Related: SYS#6200
Change-Id: I5f9215f31428ce0249cd9ece6d2d4e93155f429f
2022-11-22 12:49:13 +01:00
Alexander Couzens cf3145c966 nm_rcarrier_fsm: fix indention of ENABLED state
Change-Id: I52945babd2b31b20a578ec6818af763b0dd98d1a
2022-11-15 11:32:26 +00:00
Alexander Couzens af189fb786 Add BTS setup ramping to prevent BSC overloading
Prevent BSC overloading in the event of too many BTS try to connect.
E.g. a network outage between the BSC and BTS.
The BSC will accept incoming OML connection, but will delay sending
any BSC originated messages.

Change-Id: Id56dde6d58f3d0d20352f6c306598d2cccc6345d
2022-11-15 11:32:16 +00:00
Harald Welte 55c81a9b61 update very outdated vty copyright statement
Change-Id: I9bf6466a6b7f3347453a89ab754c372f6afa920d
2022-11-11 21:55:58 +00:00
Harald Welte 6c8ca97546 Support building with -Werror=strict-prototypes / -Werror=old-style-definition
Unfortunately "-std=c99" is not sufficient to make gcc ignore cold that
uses constructs of earlier C standards, which were abandoned in C99.

See https://lwn.net/ml/fedora-devel/Y1kvF35WozzGBpc8@redhat.com/ for
some related discussion.

Change-Id: Ic92aa70d569778a776f4c5d24c455f71fd50b61b
2022-11-10 00:28:46 +00:00
Vadim Yanitskiy 2986ee497b bts_vty: fix wrong description used for C/I threshold values
Found this bug when building with CPPFLAGS="-Wunused-macros".

Change-Id: I02828acebe2d607f0e7fd3c61ce45f2af5237e49
2022-11-09 02:46:16 +07:00
Alexander Couzens 4f057d028d bts_ipaccess_nanobts: remove unused assignment
Change-Id: I811f7c596de42eff250b1882a9e2e7cdece6259d
2022-10-30 12:27:40 +00:00
Philipp Maier 79d2f44e65 abis_rsl: be more clear about vendor specif RSL extension
The function rsl_ericsson_imm_assign_cmd has a comment "Chapter 8.5.6"
above it. However, thats only half true. The function implements
ericsson vendor specific RSL IEs, so lets be more clear about this in
the spec reference.

Change-Id: Id27662e208ca8ac0a48851583c11fbacf85f988c
2022-10-28 14:26:02 +00:00
Oliver Smith 2b6c58fddb Cosmetic: fix desc of neighbor_ident_add_neighbor
Change-Id: I6d78220156f8a4a4b246f9fcc5e9d066c2a90bbb
2022-10-27 14:07:40 +02:00
Oliver Smith 5bdc3eca68 gsm48_parse_meas_rep: fix parsing multi-band list
When looking up "BCCH-FREQ-NCELL i" from the measurement report, don't
treat the BCCH channel list as one list sorted by ascending ARFCN.
Instead, treat it as two sub lists, one for the same band, and one for
channels in different bands, as described in 3GPP TS 04.08 § 10.5.2.20.

This fixes getting the wrong ARFCN from measurement reports in
multi-band BSS, which leads to failing handovers.

Fixes: OS#5717
Related: osmo-ttcn3-hacks I4fe6bb9e4b5a69ea6204585ebdf1f157a68a8286
Change-Id: Ic5e4f0531e08685460948b102367825588d839ba
2022-10-27 09:19:52 +00:00
Pau Espin 69db1e9498 vty: Fix and deprecate typo in cmd 'amr-payload bandwith-efficient'
Related: OS#6161
Change-Id: Iefbadea374974587a421ec981e246b87c7b5de59
2022-10-26 18:10:51 +02:00
Pau Espin da4af65a51 sccplite: Use mgwpool config to set up socket forwarding IPA-MGCP from MSC to MGW
In SCCPlite, the BSC receives the CN-side MGCP from the MSC through an
IPA conn, and it then forwards those messages to its co-located MGW
through a rawUDP socket created at startup.

This forwarding UDP socket still relied exclusively on the "mgw.conf"
struct which was filled only by the old VTY interface which was been
deprecated lately.

This patch moves the mgw-pool setup before the msc setup so that if the
VTY config file still uses the old VTY, the single MGW is added to the
MGW pool through mgcp_client_pool_register_single(). It then simply
picks the first available MGW from the pool when creating the raw UDP
MGCP-forwarding socket.

This means SCCPLite is still left with supporting only 1 MGW. If more
than one MGW is defined in the pool, then when the call is being set up
a different MGW could be picked from the pool while the CN-side MGCP
would still be sent to the MGW pool selected at osm-bsc startup.

This limitation coul be removed later on  by adding a new VTY command
under the "msc" to pin calls for an MSC to an MGW with a given "mgw_nr"
from the pool, and that same MGW be looked for in the pool every time a
new call is being established.
Another possibility would be to avoid creating the "connected" UDP
socket at osmo-bsc startup, and rather use it in non-connected mode and
transmit (sendto) using the mgcp_client remote address during call
establishment.
In any case, this is left as future excercise since so far there hasn't
been any need for multiple MGWs in SCCPLite setups.

Related: SYS#5987
Change-Id: If105dee52b8d36161c759f979eaef4579b47d365
2022-10-26 11:42:30 +02:00
Neels Hofmeyr 50c5f50f83 gscon_pre_term: properly clear mgw ep
Commit 53b23c252e introduced a weird line
duplication that instead should have been the way this patch does it.

Change-Id: I5a9a983bb6135059ec01edf054ea3f7165bb6a6f
2022-10-21 17:35:34 +00:00
Pau Espin 9e136f52c1 vty: Make use of new mgcp_client_pool_config_write() API
Let's use the new API available in libosmo-mgcp-client to control more
consciously where the mgw pool config is printed.
Before this patch, the place where the node was printed was defined
based on implementation details on how the enum of nodes are defined and
installed.

Change-Id: Ib2f04d96ca846d2d61af0b0c0ea1924609004952
Related: SYS#5987
Depends: osmo-mgw.git Change-Id I7a620cf47886d8ecab30ce369cf123d98ab842c5
2022-10-18 14:37:17 +02:00
Pau Espin 1b11dd31a3 cosmetic: Fix typo in comment
Change-Id: I6afe7a7a2ae977782e7f13b1ee90b6c8aafe3050
2022-10-17 18:16:27 +02:00
Pau Espin 78e3983526 cosmetic: Fix indentation whitespace
Change-Id: I16f4c8018ac906e865885332fec3912c6e539d4e
2022-10-17 18:00:50 +02:00
Pau Espin 7048d2f0ae gscon_ensure_mgw_endpoint(): Set mgw_enpoint ptr to NULL not needed
The condition prior to this conditional branch already asserts the var is
NULL.

Change-Id: I94c9532045c657fc07e4ad53d567847915bae367
2022-10-17 17:54:32 +02:00
Pau Espin 9d17451a0d vty: Move all MSC_NODE commands to be together
Change-Id: Ib35282bf4f2f671d700560a5284115a39dd695eb
2022-10-17 17:03:24 +02:00
Pau Espin 0690c5bc75 Introduce support for MGW-pinning per BTS
This feature allows pinning each BTS to a specific MGW from the
configured pool. The pinning can be soft or hard (strict). If strict
pinning is not set, the configured MGW is selected with priority, but
other MGWs can still be selected during each call setup if the
preferred MGW is found not available at that time, hence avoiding denial
of service for the entire BTS if that MGW goes down.
If strict mode is selected, the call will be refused if the configured
preferred MGW is not available at the time the call is set up.

It is useful to use this feature when Osmux is configured between
the BTS and the BSC and an MGW pool is in use. This way the BSC is
capable of grouping all the calls of a BTS towards one MGW, hence taking
advantage of the Osmux trunking optimizations to reduce link data usage
(AMR payload of several concurrent calls ending up sharing the same
underlaying UPD packet).
Furthermore, this allows the operator to intelligently spread load over
the MGW pool in order to avoid ending up with more than 256 concurrent
Osmux circuits on any of the co-located MGWs in the pool (maximum supported
at the moment).

Related: SYS#5987
Depends: osmo-mgw.git 5d8b5b093595e1203e288c3175c163c0994b1102
Change-Id: I9a7a5af72795faed0d12d9d73b59951b6a0e9c7d
2022-10-16 22:21:17 +02:00
Philipp Maier ad27ef2b15 abis_rsl: delete CHAN RQD from queue when rach ind was sent
The CHAN REQ entry is not deleted after its information was passed on to
the PCU. This causes the same entry to be used over and over again while
blocking other incoming CHAN RQD.

Change-Id: Ia4abc55fc6fcb1c00991cc84d09529131d014910
Related: OS#5198
2022-10-14 16:08:17 +02:00
Pau Espin 62c13d99d0 vty: Fix indentation in osmux cmd during write-config output
Change-Id: I24b381f5944b0b48b6bb93e2cf1646b22e1b35cf
2022-10-13 18:11:41 +02:00
Pau Espin d9e11fbf41 cosmetic: Fix whitespace indentation
Change-Id: I7d713872220e665e126dee670cdd77f7eb44eba4
2022-10-13 13:42:29 +02:00
Pau Espin f9e5f65eb3 vty: 'hopping arfcn add': succeed if adding arfcn already in set
There's no need to fail, simply make it a noop in that case,
everything's fine and everybody is happy (specially when using CTRL
command "apply-config-file" to load a .cfg file containing
modifications.

Related: SYS#6138
Change-Id: Ia4e70d20d48a28c46a21dd10358577e5c798744c
2022-10-06 19:42:06 +02:00
Pau Espin 52fb5be52a ctrl: Introduce hopping-arfcn-{add,del} commands
Related: SYS#6138
Change-Id: Ib886cff70dd8940aa2f4095b84f9e60056c9588e
2022-10-05 17:25:27 +02:00
Pau Espin 5c7f2602f2 Rearrange ctrl interface code
Current organization is totally mess, there's actually no organization
at all for lots of commands.
Let's organize most commands based on CTRL node where they are applied:
global, bts, trx, etc.
Specific set of commands such as neighbor-related, rf-related, etc.
are left in separate files as subsections inside the same node, so the
hierarchy is still clear.

Change-Id: I51a9b31780a4a8026aafb2d732369cdc10c8bb70
2022-10-05 17:25:23 +02:00
Pau Espin f181f90af4 cosmetic: Fix typo in comment
Change-Id: I935ab303d2234656f8de0dbdb2de9f4254b02dce
2022-10-05 16:36:19 +02:00
Vadim Yanitskiy 6c4859279f vty: fix description of 'nokia_site bts-reset-timer'
Change-Id: I9cd60b84e2f7e7d48e7e0a8167ee0e2ffbae0428
2022-10-04 23:25:42 +07:00
Vadim Yanitskiy 8631189d9e power_control: add CTRL command for sending default params
There exists a VTY command for sending default power control params,
but so far there was no CTRL counterpart for it.  This patch adds a
SET command 'send-power-control-defaults':

  $ osmo_ctrl.py \
	--host 127.0.0.1 -p 4249 \
	--set "bts.0.send-power-control-defaults" 1

Similar to 'send-new-system-informations', this command takes an
arbitrary dummy value (required for SET), which is simply ignored.

Change-Id: Ib370bd97ee2d9f72f8bec553550b1792d1345387
Related: SYS#6138
2022-09-30 01:02:57 +07:00
Philipp Maier 6e9f5e54d2 pcu_sock: add some guard space to message buffer
in osmo-pcu, the message buffer in pcu_sock_read is allocated with 1000
bytes in addition to the true size of the pcu_prim struct. Presumably
this is to avoid compatibility problems in case the primitives slightly
grow due to appending new struct members. Lets do the same in osmo-bts.

Change-Id: I99f5204b0563f72f9da427bb7aa5451552d8c5b5
Related: OS#5198
2022-09-26 13:24:03 +02:00
Philipp Maier 797378af74 pcu_sock: check size of primitive
The pcu_sock interface in osmo-bts does check the size of the primitives
it receives. Lets do the same in osmo-bsc as well.

Change-Id: I247c6f4b5a7a22d17a060a558c4ceb9221ca7351
Related: OS#5198
2022-09-26 12:53:11 +02:00
Pau Espin 9573ccbe2b vty: Print Osmux CID on lchans using Osmux
Related: SYS#5987
Change-Id: I6829949c888c0bcd989311219e10330bc97b2152
2022-09-21 19:29:11 +02:00
Pau Espin 2c4f32b19b cosmetic: vty: Fix formatting of if-else brackets
Change-Id: I7210616bc293913e5efec14eb52aeafb37f1244f
2022-09-21 19:05:30 +02:00
Pau Espin 2627dc07ee Drop Osmux call setup if BTS didn't provide a remote CID
We expect osmo-bts to provide us with a remote CID in order to be able
to set up MGW to send Osmux frames to it.

Related: SYS#5987
Change-Id: Ia90e8e0d18193d64c0fa0788dbd0eb242a359b61
2022-09-21 18:59:26 +02:00
Pau Espin fe5fefa4ac ipaccess-config: Fix writing pcap output to fd=0 (stdin)
It ended up in seeing lots of garbage in my terminal every time I run
the program.

Change-Id: I9ee0a4c51f4f10bf71390f884d67d87b623773df
2022-09-20 10:16:41 +00:00
Pau Espin cb2c6fc0ba ipaccess: Remove unused stub
function on_gsm_ts_init() doesn't exist at all in the repository, so it
can be dropped from here.

Change-Id: I863ccad044960d3ba267fa2bbf3c697abdf596a8
2022-09-20 10:16:41 +00:00
Pau Espin 5ec3eccdf5 ipacces-config: override gsm_bts_check_cfg() to void checking unset bts configuration
the shared code in libbsc checks for sane config being set, but this
doesn't really apply to ipaccess-config, wihich doesn't set such config
fields internally.

Change-Id: I22ff0d22d6dcf9b0f715bfa4e0daeb52c4028308
2022-09-20 10:16:41 +00:00
Pau Espin 0944a4ce91 mgcp: Set up Osmux only when AMR codec is selected
Until now Osmux was selected unconditionally in bss-side CRCX, without
checking if the codec was AMR or not. If Osmux use policy is "on", we
only want to request Osmux use if AMR codec is selected.

Change-Id: I3f53555dd9608f1337365e4f82b492bdf1da05bb
2022-09-19 20:16:22 +02:00
Pau Espin 79701ebd25 ipaccess-config: Exit program with error if OML link is dropped
Change-Id: Ic96635f618f2efbe29ca6c59eedd1dc1f90c1a1d
2022-09-19 14:07:31 +00:00
Pau Espin 13a58385a4 ipaccess-config: use available API to set e1inp_line_ops
Change-Id: Ic0d248fc5d1481ad96f7af20a1a80144137c626a
2022-09-19 14:07:31 +00:00
Pau Espin ea2367f4ab ipaccess-config: Initialize RSL ts driver fd to proper value
ipaccess-config sets up the entire line in a fake way.
That requires also setting the fd of each TS used to -1 in order to
avoid library code interacting with it during tear down if an error
occurs.

Change-Id: I19eb23a46f89b96dd8d63742ca2078ecd5c9ab6b
2022-09-19 14:07:31 +00:00
Pau Espin b87b676fb2 ipaccess-config: Initiate missing IPA osmo_link
Since this is created by osmo-bsc, it is also expected to be there by
ipaccess_drop_oml() in the shared libbsc code. But ipaccess-config was
not creating it, so let's do so.

Let's explicitly assert this condition in the code path expecting the
pointer to be instantiated in shared code, to easily track related
issues in the future.

Change-Id: I3f63f6827f7c5d7a21ac125b7ca6b35244efbb65
2022-09-19 14:07:31 +00:00
Pau Espin ff1038c633 oml: Delay Tx of OPSTART(BBTRANSC) after rx of RSL CONNECT ACK
nanoBTS waits until receiving OPSTART in order to establish the RSL
connection socket against BSC, hence we cannot wait until the socket is
established at the BSC in order to send the OPSTART.
Still this way we make sure the RSL CONNECT is acked before attempting
an OPSTART at the BSC.

Change-Id: Ief46bad5075b656c13d1f09a0724e33283148236
2022-09-19 14:07:31 +00:00
Pau Espin 57c2e68da2 vty: Allow setting LAC as hexadecimal value
The LAC value currently configured is now printed as hexadecimal value
too.
It can still be entered as a decimal value in order to keep backward
compatibility, though the hexadecimal one is now preferred.

Related: OS#5631
Depends: libosmocore.git Ia2b7fbbf5502c28374c21dbff548232680da27d4
Change-Id: I9090d73ae9d39244b79b9dbafa1b164faebabc52
2022-09-19 08:44:25 +00:00
Pau Espin 30bdf9a4c7 oml: Integrate signal S_NM_IPACC_SET_ATTR_ACK inside S_NM_IPACC_ACK
It makes no sense to have duplicate signals. Let's simply clean up
S_NM_IPACC_ACK and pass the required info for higher layers to do
whatever is needed based on the information.
This allows reusing same signal infrastructure for different types of
messages instead of having to implement new signals for each message
(which can be done at a higher point in the stack).

Change-Id: I18ae3d320d00077fc13bb9903903de2a17767302
2022-09-16 13:00:58 +02:00
Philipp Maier e71af5019b pcu_sock: fix memleak
pcu_sock_read() may not free the message buffer in case the recv
returned errno EAGAIN. This is already fixed in osmo-bts, lets fix it in
osmo-bsc as well.

Related: OS#5198
Change-Id: I49eda447fc1912c1f7f25ba07331cb84decf4548
2022-09-15 12:16:30 +02:00
Pau Espin d8b5bf08e8 Add Osmux support on the Abis-side data plane
Related: SYS#5987
Change-Id: I48483b278ff829ee29d3e7fbcab0dd3a54728825
2022-09-13 17:37:35 +02:00
Max 56dc61e3f5 BSSMAP: add assert to reset resending
There seems to be no way for this function to be called with NULL parameter despite unreproducible crash observed in the
past. Let's add assert to show this explicitly.

Fixes: OS#5551
Change-Id: I235bdd42ea82e7b5a1a40f437ca34c49ad239c48
2022-09-05 13:04:31 +00:00
Pau Espin ac673e107c cosmetic: Clean initiating whitespace
Change-Id: Ide2c13cc80dfabbacfbaee97122b000d708cd07a
2022-08-09 08:38:51 +00:00
Pau Espin ba62898cd8 lchan: Move init logic to a specific function
This way it is a lot easier to find out how and when is an lchan
initialized, simply by looking at the lchan.h header, then seeing the
init function and grepping for it.

Change-Id: I043d1c2ee75d4d2a8b323b7960ee490e567f3865
2022-08-09 08:38:51 +00:00
Pau Espin 3d0fbe387f split lchan specific defines and code to its own file
It is really difficult right now to find out where all the different
stuff relative to operation and lifecycle of an lchan is. Let's move
everything to its own file to have all the related defines and logic
together.

Change-Id: Idd855d126c43ac6576c5f3ba7e0b8014127a65e1
2022-08-09 08:38:51 +00:00
Pau Espin 742bb99ed9 Use libosmocore available API to get value_list
This API has been available since 1.0.0, and we actually require
libosmocore >= 1.7.0 nowadays, so it's totally fine using the
libosmocore API and drops the local duplicate.

Change-Id: I95c59b31cf1b08e1d513b589ef386d2dd55f09a2
2022-08-09 08:38:51 +00:00
Philipp Maier 842592c529 bts_trx_vty: prefix bb_trxc mo with [Virtual] for ericsson BTS
The OM2000 model does not have a separate bb_transc MO, however for
compatibilty reasons we have a virtual MO that just mirrors the state of
the TRX mo. We should mark it as [Virtual] in show trx to reflect this
to the user.

Change-Id: I0f5501f6fbc7ce6d5457676b16c7f93f70db5763
Related: OS#5101
2022-08-08 20:09:15 +00:00
Philipp Maier 2b903e2bab abis_om2000: duplicate nmstate of bb_trxc mo to trx mo
In OM2000 a separate bb_trxc MO does not exist to archive better
compatibilty towards classic ABIS and its MOs. Let's mirror the nmstate of
the BB_TRANSC MO to the RCARRIER MO in order to make it look like if it
were present.

Change-Id: I4611d8af16a30725308bd527098b12a356bfde9f
Related: OS#5634
2022-08-08 20:09:15 +00:00
Philipp Maier 9afecf6beb abis_om2000: om2k_trx_s_done_onenter() does not send signal
the function om2k_trx_s_done_onenter() updates the administrative state
of the TRX oml MO but it does not notify the update to other entities
using S_NM_STATECHG

Change-Id: Iabf9f3a1a345c5d53d9a4d02fa2d6d13ddfd86ae
Related: OS#5634
2022-08-08 20:09:15 +00:00
Harald Welte 6545f72981 bts_nokia_site: Implement channel config for CBCH
Thanks to manawyrm for pointing out that the comments of the file
actually contained the numeric codes for the CBCH variants, but the
cases in the switch statements were missing.

Change-Id: Id5b4da6838f9a34db39fff5c23ad18822cd3347b
2022-08-07 22:30:06 +02:00
Philipp Maier eca195469b abis_om2000: update_op_state() does not send signal
The function update_op_state() updates the OML MO, but it does not
notify the update to other entities using S_NM_STATECHG

Change-Id: Id19c6beb2bc79c4db0ec07ef593aacb57fff8b75
Related: OS#5634
2022-08-05 11:55:41 +02:00
Philipp Maier 914e52e73a abis_om2000: constify mo in mo2obj
The function mo2obj does only read only access to mo, so mo can be
const.

Change-Id: Ia09d0c96c8938e287fdbad343b9605cbfd6ff6a1
Related: OS#5101
2022-08-05 11:55:41 +02:00
Philipp Maier cba82e60e8 abis_om2000: move switch-case to function
The switch-case in update_op_state() and update_mo_state() can be split
off into functions. This makes to code better readable.

Change-Id: I41f0d9d0d498f6f698c2c959baac50424f5ac317
Related: OS#5634
2022-08-05 11:32:02 +02:00
Philipp Maier 99262fd447 abis_om2000: fix missing signal
The normal abis nm FSMs are sending S_NM_RUNNING_CHG signals that
include an object class to notify other entities about state changes.
This also includes paging.c, which only starts paging services when it
sees NM_OC_RADIO_CARRIER becoming enabled.

Change-Id: I305df5b2f962473e33e32484c42a79ff96e53e1a
Fixes: I1b5b1a98115b4e9d821eb3330fc5b970a0e78a44
Related: OS#5634
2022-08-04 10:06:25 +02:00
Philipp Maier b46c62a8b7 bsc_subscr_conn_fsm: fix use after free
In cases where the MGCP client endpoint FSM is terminating early the bsc
sbscr conn FSM receives the signal GSCON_EV_FORGET_MGW_ENDPOINT, which
then calls gscon_forget_mgw_endpoint(). However, this only nulls the
conn->user_plane->mgw_endpoint_ci_msc struct pointer, not the others.
This causes the assignment FSM to access
conn->assignment.created_ci_for_msc whle trying to initiate a DLCX. We
must make sure that when the MGCP client endpoint FSM dies, that all
other CI pointers that reference the same CI are also set to NULL.

Change-Id: Ia857e3af6c17282b7e8178b6d249eb0f99ed98e3
Related: OS#5572
2022-08-01 17:36:13 +02:00
Vadim Yanitskiy ac8acc98a3 call osmo_timer_del() unconditionally, without osmo_timer_pending()
osmo_timer_del() does check if a timer is active internally.

Change-Id: I3e42a74d59b8e8d0d46cc4027676149689cc18a3
2022-07-22 03:39:23 +07:00
Pau Espin a7e5f1613a smscb: Tx Failure and Restart Ind for each Bcast Msg Type
As described in 3GPP TS 48.049:

7.8.2: "The RESTART message is sent once per broadcast message type as
  indicated by the Broadcast Message Type IE."
7.9.2: "The FAILURE message is sent once per broadcast message type as
  indicated by the Broadcast Message Type IE."

Related: SYS#5910
Change-Id: I6668b55868cf534a3b59da5e11542abb8131d604
2022-07-14 19:59:27 +02:00
Pau Espin f3a4844f04 smscb: Tx Failure and Restart Ind using CGI as cellID
Let's use CGI instead of LAC+CI, which contains only a subset of the
information.
Furthermore, It was noted that some third party (non-osmocom, non
open source) CBCs don't support/like receiving LAC+CI,
and expect to receive CGI instead.

Related: SYS#5910
Change-Id: I33a6216f89496484cbb3921609fcd3ab90761c69
2022-07-14 19:48:36 +02:00
Vadim Yanitskiy 41481c7090 osmo-bsc/Makefile.am: fix undefined reference to symbol pow()
When trying to build osmo-bsc using clang 14, I am getting this error:

  make[3]: Entering directory 'src/osmo-bsc'
    CCLD     osmo-bsc
  /usr/bin/ld: ./.libs/libbsc.a(handover_decision_2.o): undefined reference to symbol 'pow@@GLIBC_2.29'
  /usr/bin/ld: /usr/lib/libm.so.6: error adding symbols: DSO missing from command line
  clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
  make[3]: *** [Makefile:656: osmo-bsc] Error 1

We need to link with the math library to resolve this.

Change-Id: I4137cad07a3343882ca77d5ebd5137083941dc11
2022-07-04 21:42:42 +07:00
Vadim Yanitskiy 71b7dc03d9 lchan_select: fix 'chan_alloc_reverse' may be used uninitialized
GCC 12.1.0 emits -Wmaybe-uninitialized when building with '-O2'.

In function 'populate_ts_list',
    inlined from 'lchan_avail_by_type' at src/osmo-bsc/lchan_select.c:356:2:
src/osmo-bsc/lchan_select.c:248:12: warning: 'chan_alloc_reverse' may be used
                                             uninitialized [-Wmaybe-uninitialized]
  248 |         if (chan_alloc_reverse) {
      |            ^
src/osmo-bsc/lchan_select.c: In function 'lchan_avail_by_type':
src/osmo-bsc/lchan_select.c:326:14: note: 'chan_alloc_reverse' was declared here
  326 |         bool chan_alloc_reverse;
      |              ^~~~~~~~~~~~~~~~~~

This could only happen if in 'enum lchan_select_reason' we had items
that are not handled in lchan_avail_by_type(), but this is not the
case.  Make GCC happy by initializing chan_alloc_reverse to false.

Change-Id: I3956621a6ec14ca5ff0ba0b11d2c956e2538efd8
2022-07-04 21:24:50 +07:00
Vadim Yanitskiy a019e9af8b lchan_select: implement dynamic selection mode for assignment
This change implements an additional channel allocation mode, which
can be employed during a TCH channel allocation for assignment.
Selection between ascending and descending order is performed
depending on pre-configured parameters:

* Uplink RxLev threshold and number of samples for averaging,
* C0 (BCCH carrier) channel load threshold.

This is useful in setups where Tx power of the RF carriers cannot be
adjusted +dynamically at run-time and thus BS Power Control cannot
be performed.  In such setups the BCCH carrier is transmitting at
relatively higher power than the other RF carriers.  The key idea
is to allocate channels in a smarter way, so that UEs with poor signal
would get channels on carriers with high Tx power, while UEs with good
signal could use carriers with lower Tx power.

Change-Id: I1b7a0d706976b73cc5c30a8714b830811addfe8d
Related: osmo-ttcn3-hacks.git Ia522f37c1c001b3a36f5145b8875fbb88311c2e5
Related: SYS#5460
2022-06-30 16:36:55 +00:00
Vadim Yanitskiy c2928ac269 lchan_select: allow different alloc order for assignment and handover
A follow-up patch implements a special channel allocation mode, which is
only working for assignment (basically TCH selection for a voice call).
This mode cannot be employed for initial CHANNEL REQUEST or handover due
to the absence of an already established lchan.

Adding this mode to the existing VTY command syntax would be confusing:

  channel allocator (ascending|desscending|dynamic)
                                           ^^^^^^^

so this patch extends the VTY syntax in a way that it becomes possible
to configure different channel allocator modes for different cases:

  OsmoBSC(config-net-bts)# channel allocator mode ?
    set-all     Set a single mode for all variants
    chan-req    Channel allocation for CHANNEL REQUEST (RACH)
    assignment  Channel allocation for assignment
    handover    Channel allocation for handover

The old command syntax, which is basically 'set-all', is kept for
backwards compatibility, but marked as deprecated.

Change-Id: I3ae73b36ee9433cc768376b56f0765e5f416162f
Related: SYS#5460
2022-06-30 16:36:41 +00:00
Vadim Yanitskiy ff9d3a64dc lchan_select: prepare a list of timeslots once, iterate over it
The lchan_avail_by_type() attempts to find an unused lchan for the
given GSM_LCHAN_* value: TCH/F, TCH/H, or SDCCH.  This is achieved
by looking up timeslots with compatible GSM_PCHAN_* values.

For instance, finding an unused SDCCH lchan may involve:

* attempt to find a timeslot with pchan=GSM_PCHAN_CCCH_SDCCH4,
* attempt to find a timeslot with pchan=GSM_PCHAN_CCCH_SDCCH4_CBCH,
* attempt to find a timeslot with pchan=GSM_PCHAN_SDCCH8_SACCH8C,
* attempt to find a timeslot with pchan=GSM_PCHAN_SDCCH8_SACCH8C_CBCH,
* attempt to find a timeslot with pchan=GSM_PCHAN_OSMO_DYN (switched),
* attempt to find a timeslot with pchan=GSM_PCHAN_OSMO_DYN (not switched).

Each attempt involves iterating over all timeslots of each TRX,
either in ascending or in descending order (see _lc_dyn_find_bts()
and _lc_find_trx()).

This patch simplifies the lookup logic by preparing a monolithic
array of timeslot pointers once, and then using that array for
each GSM_PCHAN_* lookup attempt.  This change is required for the
upcoming dynamic channel allocation mode, which is fa more complex
than the existing ascending/descending ones.

A side effect of this change is that the interference aware mode
of allocation is not limited by the scope of a single TRX anymore.
Interference levels are now compared within the scope of the whole
BTS, so that lchans on the other TRXes may be picked if they are
better according to the interference reports from the BTS.

Change-Id: I7ccc56856bfd40fd7c63b7437736de60c2b516ff
Related: SYS#5460
2022-06-30 16:36:41 +00:00
Pau Espin 46fe680944 cbsp: Change log level ERROR->INFO on CBSP tx and link down
Let's decrease the logging since it's fine simply discarding the message
if the link is down. This way all code sending messages doesn't need to
care about the link state.

Change-Id: I64356ec6a7b3a4e11a0e66b17efab2788b1ca5cc
2022-06-29 15:14:10 +00:00
Vadim Yanitskiy adc3e36a3e fix uninitialized err pointer passed to osmo_bssap_le_dec()
osmo_bssap_le_dec() dereferences value of the given pointer and
checks it against NULL.  The caller must always initialize it.

Change-Id: Idb0e6565e362ce383c833d6bfec4fb39d2985a6b
Fixes: CID#272982, CID#272944
2022-06-29 11:27:46 +00:00
Pau Espin 6941a14f56 cbsp: Avoid encoding CBSP message if link is down
Change-Id: I25c8681d2ee987ac6ebfce42ee409926eb88301d
2022-06-28 15:19:02 +00:00
Vadim Yanitskiy a12cc72fcd ipaccess-config: check value returned by abis_nm_tlv_parse()
Change-Id: I38cd35506964efb1441555d16cea998f415e9394
Fixes: CID#272995
2022-06-28 18:18:05 +07:00
Vadim Yanitskiy 9a5bca0b0e VTY: fix wrong enum value s/ACTIVATE_FOR_VTY/ASSIGN_FOR_VTY/
Found by clang:

  warning: implicit conversion from enumeration type
           'enum lchan_activate_for' to different enumeration type
           'enum assign_for' [-Wenum-conversion]

This is indeed a bug, because both enum items have different values:

* ACTIVATE_FOR_VTY (from enum lchan_activate_for) is 4,
* ASSIGN_FOR_VTY (from enum assign_for) is 3.

Change-Id: I44544d4577833e0aed62b07d0c7c1c2821b05dd4
2022-06-28 18:14:20 +07:00
Keith Whyte 61cbc5b322 Improve parsing of om2000 fault reports
Fault Reports are commonly oberved with a TLV id 0xd2
as are reports with up to 20 TLVs.
Let's not have these cause logging at level ERROR.

Closes: OS#5593
Change-Id: Ibe0b38835362c59d1576a206b2f64cea4427295f
2022-06-27 21:42:05 -05:00
Vadim Yanitskiy 152f0586c5 gsm_04_08_rr: ensure lchan info is present in all logging messages
Change-Id: Ic34dd0fbefcd60d60fc8f98230f789c1bf134607
Related: OS#5572
2022-06-27 18:21:03 +07:00
Vadim Yanitskiy 1f6a0decee bts_chan_load(): also calculate per-TRX channel load
This is required for the upcoming dynamic channel allocation mode.

Change-Id: I220145238c23135f7e68ca2d474764312ffb66c5
Related: SYS#5460
2022-06-22 05:49:20 +07:00
Vadim Yanitskiy 6411d95a6e VTY: cosmetic: define and use CHAN_ALLOC_{CMD,DESC}
Change-Id: I8e906a9c16247788eec8cd8d99f019b08dc5a8f1
Related: SYS#5460
2022-06-21 08:12:16 +00:00
Michael Iedema 87cf5dacb4 logs: also record which BTS is signaling a SAPI REJECT
Change-Id: I4d25cc4cf55b03c7311ba58cf6feae06c3028a5d
2022-06-20 13:28:46 +00:00
Pau Espin ac63d39a5a smscb: Tx CBSP FAILURE/RESTART for specific cell when it becomes (un)operational
This way the CBSP peers knows the state of specific cells and can avoid
sending messages to unoperative ones, etc.

Related: SYS#5910
Change-Id: I94f0a1ac3c59cffe5af57f972d5d96fc92281d34
2022-06-17 20:27:41 +00:00
Michael Iedema 0dd0f14877 stats: track TCH/SDCCH lchans reaching fully-established state
When calculating average lchan duration based on the new stats for
BTS_CTR_CHAN_{TCH,SDCCH}_ACTIVE_MILLISECONDS_TOTAL there are
discrepancies which emerge. Specificially in bandwidth-constrained
environments, there are still-unknown failure states which can
occur that cause the TCH or SDCCH activity count to increment but
zero milliseconds of activity on the lchan to accumulate. This
portrays a failure as a success.

These new fully-established stats are intended to provide a more
accurate denominator when calculating average lchan duration as
they are incremented in proximity to the duration timestamp
initialization.

Change-Id: I417940ad9479719f5324fb12d45883cd3cb2c578
2022-06-17 20:26:26 +00:00
Pau Espin 2a77f1780f smscb: Base cell operational life cycle on CBCH being operative
This allows running CBCH/ETWS related procedures only when the CBCH
towards MS under that cell is operative.
This also allows providing awarness of per-cell status to the CBSP peer
as required per specs.

Related: SYS#5910
Change-Id: Ia93919be94132fc010acb5bbfef0a6fd51c42981
2022-06-16 19:07:14 +02:00
Michael Iedema 3ef30f3424 Expand VTY option which controls use of TCH for signalling
For statistical clarity and site tuning, it is sometimes
desirable to completely disable the use of TCH for signaling.

In the existing version of this VTY command, there is no way to
accomplish this. We can only restrict TCH for signaling non-voice
related actions.

This patch deprecates 'allow-tch-for-signalling (0|1)' and
adds 'tch-signalling-policy (never|emergency|voice|always)' to
provide more options.

Change-Id: I4459941ddad4e4a3bec8409b180d9a23a735e640
2022-06-15 06:06:26 -07:00
Pau Espin 927c052136 Move all SMSCB/CBC vty code to its own file
This way we separate all the VTY boilerplate from the actual logic, as
we usually do in all other subsystems.

Change-Id: Ifc7d1693d745dd2a3c31e3ee9610d8c634b50812
2022-06-10 11:30:29 +00:00
Oliver Smith 5f2dd6a876 Cosmetic: bsc_vty: tweak msc pooling strings
Drop "to this MSC" from the NRI_STR, as it is not only used for MSC
specific configuration, but also in cfg_net_nri_* which affect all MSCs.

Drop "for this MSC" from the description of cfg_net_nri_null_del, it
affects all MSCs (unlike cfg_msc_nri_del).

Change-Id: Ic8888775a965b6d607af51b9359bd8ffc2834e16
2022-06-10 11:09:25 +02:00
Neels Hofmeyr c1bfc88b6b fix performance for chan_counts and all_allocated stats
The all_allocated_update_bsc() does inefficient iterating to count
active/inactive lchans, which scales badly for high numbers of TRX
managed by osmo-bsc.

We need to update the all_allocated flags immediately (periodic counting
alone would suffer from undersampling), so, until now, we are calling
this inefficient function every time a channel state changes.

Instead of iterating all channels for any chan state changes anywhere,
keep global state of the current channel counts, and on channel state
change only update those ts, trx, bts counts that actually change.

A desirable side effect: for connection stats and handover decision 2,
we can now also use the globally updated channel counts and save a bunch
of inefficient iterations.

To get accurate channel counts at all times, spread around some
chan_counts_ts_update() calls in pivotal places. It re-counts the given
timeslot and cascades counter changes, iff required.

Just in case I missed some channel accounting, still run an inefficient
iterating count regularly that detects errors, logs them and fixes them.
No real harm done if such error appears. None show in ttcn3 BSC_Tests.
It is fine to do the inefficient iteration once per second; channel
state changes can realistically happen hundreds of times per second.

Related: SYS#5976
Change-Id: I580bfae329aac8d4552723164741536af6512011
2022-06-02 14:24:30 +02:00
Neels Hofmeyr 4c89001ccb code cleanup for all_allocated timers, no functional change
Reduce some code dup in all_allocated accounting and cosmetically
prepare for upcoming performance fix.

Have a struct all_allocated, allow easy re-use of function
all_allocated_update().

Rename function to all_allocated_update_bsc(). Upcoming patch will also
add all_allocated_update_bts().

Related: SYS#5976
Change-Id: Id7a82c65d56a87818fc35bbeedf67e2af2f89f11
2022-06-02 14:17:35 +02:00
Neels Hofmeyr 05154b41e6 drop log from ts_is_usable()
ts_is_usable() returns the current state; logging is the job of calling
functions. An upcoming patch adds some calls to ts_is_usable(), this
avoids the log flaring up with useless messages.

Related: SYS#5976
Change-Id: I0635c47609fd7c7d0195b6658b7da231d6527b4b
2022-06-02 14:17:35 +02:00
Pau Espin 7e10af9ab0 nm_rcarrier_fsm: Trigger S_NM_RUNNING_CHG when Admin st changes in op=Enabled
It was described in [1] that the NM FSM failed to trigger the
S_NM_RUNNNG_CHG signal when locking/unlocking the TRX.
That's because current osmo-bts doesn't fully conform to TS 52.021 and
it doesn't go back to Op=Disabled Avail=Dependency when becoming
Admin=Locked. It's true though that TS 52.021 sec 5.3.1 is not really
helpful since it doesn't explicitly state that specific object should go
into Disabled Dependency, despite saying it for most of the other ones.
Hence, let's account for both possibilities at the BSC side.

[1] https://gerrit.osmocom.org/c/osmo-bsc/+/28205

Related: OS#5576
Change-Id: Ifbdc066fd88bdbf826800d14524e74416815b625
2022-06-02 12:51:35 +02:00
Pau Espin b4269f15eb nm_*_fsm: Remove comment no longer applying
Since b7ef6884f9, the state is updated
before triggering the signal S_NM_STATECHG, so the warning does no
longer hold true.

Change-Id: I7b7dd30b4fcdc92febca42e3e6a75e6f98e184ff
2022-06-02 11:44:52 +02:00
Neels Hofmeyr aae8c2513d fix rare segfault in MGCP client handling
Add missing conn->assignment.created_ci_for_msc to
gscon_forget_mgw_endpoint_ci().

Before this patch, when assignment.created_ci_for_msc lingers after a
DLCX, it can cause a use-after-free on assignment_reset(). Possible
scenario is rx BSSMAP Clear Cmd during ongoing Assignment.

In assignment_reset(), locally cache the ci pointer, because
gscon_forget_mgw_endpoint_ci() now NULLs created_ci_for_msc.

Related: OS#5572
Change-Id: If89610020f47fd6517081dd11b83911b043bd0f1
2022-05-31 00:24:08 +02:00
Vadim Yanitskiy 58ac749424 fix gsm_lchan_and_pchan2chan_nr(): log proper lchan_nr value
VAMOS lchans are behind the primary ones in the ts->lchan[] array.
For example, for TCH/F, there is a primary ts->lchan[0] and a VAMOS
ts->lchan[1].  We should print 'ss 0' for both of them.

Change-Id: I8e7a5a2ecc9b9a33e3ddb76cb1bc04d7802fd320
2022-05-27 17:52:20 +06:00
Vadim Yanitskiy 725781d34e bsc_vty: use llist_for_each_entry in lchan_act_all_cmd
Change-Id: Iaa29696c8de268796da118e7ea3384b6186bf688
2022-05-27 17:52:20 +06:00
Michael Iedema a7628d9cf0 stats: new trackers for lchan life duration (v2)
This patch adds two stats which track cummulative lchan lifetime by
type TCH and SDCCH. These new counters will accomplish two things:

1) Provide a glanceable way to see if lchan durations look healthy. When
examining a site, short-lived (<5s) and long-lived (>30s) TCH lchans
are difficult to tell apart. If we only see short-lived TCH lchans,
there is most likely an RF or signaling problem to investigate. This
new counter will expose channel ages in the VTY output

2) Provide a more accurate count for Erlangs per site. Currently, we
are basing Erlangs on active TCH channel counts per stats period. This
method skews high very quickly. Each active TCH in that period
translates into the full 10s of activity. This counter should improve
accuracy by two orders of magnitude.

Change-Id: Ie3771233ecbd4bc24a24fb22c1064a18e7b8b2b0
2022-05-23 02:20:12 -07:00
Harald Welte 35cac4dba8 smscb: "Warning Security Information is always present in ETWS
As per TS 48.049 Table 8.1.3.1.1 the WRITE-REPLACE message always
has a Warning Security Information IE if it relates to ETWS.  This
is also implemented in the libosmocore CBSP parser.

As the previous Change Id369bb3676ba279bafc234378fbe21dbc7b0614b has
pointed out, the CBSP parser structure doesn't even permit any way
of handing a decoded message to us without the warning_sec_info
static struct member.

So as a result, there's also no need to dynamically allocate
bts_etws_state.input.sec_info via talloc.  We can have it in-line
as a static struct member and reduce code complexity and runtime
memory allocations.

Change-Id: Ib1b8e4af37b1f9f9398b81dad29942e82218c70b
2022-05-15 10:11:28 +02:00
Neels Hofmeyr 7111e00ee5 do not BSSMAP Clear on lchan rel when LCS is still ongoing
The proper way to fix this is having a use count on the SCCP conn, one
each for a busy lchan and a busy Location Request. That would require a
bunch more work and testing.

This patch is the least-effort way to avoid the following scenario:

Emergency call is started;
Location Request is started to locate the emergency;
lchan releases early for any reason;
Perfectly fine Location Request gets canceled by Clear Request;
The information was there, but we did not forward the location;
No help at emergency because of my code.

Allow Location Request to complete for these cases:
- rx RLL REL IND (or any other reason for gscon_lchan_releasing())
- rx RSL CONN FAIL

Related: SYS#5912
Related: Idea690a4aa4aecbe4642a16e96d086cc0538564a (osmo-ttcn3-hacks)
Change-Id: Ib44dd05b0adee84234f671313b156ff6625357cc
2022-05-15 08:09:34 +00:00
Pau Espin e6b8b8201a acc: Simplify start/stop by using new signal S_NM_RUNNING_CHG
ACC used to be stared/stopped based on operational/administrative state
changes. The new S_NM_RUNNING_CHG triggers a single boolean based on the
same logic, so we can now simplify the mechanism.

Change-Id: I2e09bcb18a6c3bb2e88bba98579fb4854a6b0699
2022-05-13 14:06:37 +02:00
Pau Espin 9f8137dc73 paging: start/stop credit_timer based on C0 running
This way we avoid triggering timers and doing extra poll loops for each
BTS which is configured but not up. It also has the effect of removing
logging about estimating paging buffers for BTS which are down, which
can be confusing.
Furthermore, since work is delayed until the TRX and cell in general is
configured, the first estimation is properly done now since the correct
configuration is in place at that time.

Related: SYS#5922
Change-Id: I1b5b1a98115b4e9d821eb3330fc5b970a0e78a44
2022-05-13 14:06:37 +02:00
Pau Espin 50a42e7436 Introduce new signal S_NM_RUNNING_CHG and implement it for rcarrier,bbtransc
This allows different parts of the code to hook to some signals which
allow start/stopping processes based, for instance, on whether C0 is
available or not.
This can be later used by paging or CBSP code. Also ACC code can be
ported to this new system (acc_ramp_nm_sig_cb()).
Same signal can be used for other NM objects, but is left unimplemented
until there's use for them.

Change-Id: I206d4c7863a77fbab6a600126742a6a6b8fc3614
2022-05-13 14:06:37 +02:00
Pau Espin b7ef6884f9 Update current NM object state before signalling S_NM_STATECHG
This way code triggered through signal has an updated view of the object
tree when running generic code which queries the current state of
objects.
This way for instance one can use APIs like trx_is_usable() or alike.

Change-Id: Ib46234e3f3e446e866d27b0dfee65edf4af4d2ba
2022-05-13 09:58:58 +00:00
Vadim Yanitskiy f8c8b0d9c5 smscb: fix meaningless condition in etws_primary_to_bts()
Found by GCC 12.1.0:

  smscb.c: In function 'etws_primary_to_bts':
  smscb.c:537:13: warning: the comparison will always evaluate as 'true'
                           for the address of 'warning_sec_info'
                           will never be NULL [-Waddress]
    537 |         if (wrepl->u.emergency.warning_sec_info) {
        |             ^~~~~
  In file included from smscb.c:31:
  /usr/local/include/osmocom/gsm/cbsp.h:99:33: note: 'warning_sec_info' declared here
     99 |                         uint8_t warning_sec_info[50];
        |                                 ^~~~~~~~~~~~~~~~

Indeed, address of &warning_sec_info[0] is always not NULL.

Change-Id: Id369bb3676ba279bafc234378fbe21dbc7b0614b
2022-05-13 06:34:00 +00:00
Oliver Smith 49dd5cfeeb abis_nm: run gsm_bts_check_cfg during oml bring up
Don't wait until RSL link goes up to check the reported features against
the config. Do it in the OML bring up right after the features are
reported.

Related: SYS#5922, OS#5538
Change-Id: I6b1b4ef3e163528ed186050d848ec089a4315a7c
2022-05-13 06:29:14 +00:00
Harald Welte d8017c3533 smscb: Send ETWS PN to BTS if ETWS active before BTS connects
Especially during emergencies / natural disasters, it is particularly
likely that networks become unreliable and BTSs disconnect and
reconnect.  If upon reconnect there still is an active ETWS/PWS
emergency message active for this BTS, send it to the BTS to ensure
it re-starts broadcasting that message until disabled.

Change-Id: I175c33297c08e65bdbf38447e697e37f8a64d527
2022-05-13 06:26:13 +00:00
Pau Espin fa3e40e454 Revert "stats: new trackers for lchan life duration"
This reverts commit 5e2ac29703.

This patch was found to be a troublemaker regarding osmo-bsc
performance, since it's scheduling one timer every 100ms for each
channel. On a BSC with dozens of BTS, each with several TRX, this ends
up in a huge amount of timers scheduled in a tight timeframe, which ends
up in osmo-bsc spending CPU time getting in and out of the poll() main
loop.

Related: SYS#5922
Change-Id: Ibd5123e7f04ae8f4eb8f08b63525527f526f0b2c
2022-05-12 12:49:45 +02:00
Pau Espin 51226c98d5 Revert "fix fallout from: 'stats: new trackers for lchan life duration'"
This reverts commit a09d78faa9.

The whole original patch is also being reverted, so this fix too.

Change-Id: Ic9b89b3030eb8cfedabbf20ec8fcbcc225fe028f
2022-05-12 12:48:52 +02:00
Harald Welte d8cfd2fb24 Add stat_item for per-bts [dynamic] T3113 timer
This allows external monitoring to see where the T3113 timer has been
adjusted to, in case it is set dynamically.

Change-Id: I533f2ca3c8e66c143154cbf03b827c9cbbacccdf
2022-05-09 17:50:38 +02:00
Harald Welte 536390a7be paging: Implement upper bound of 60s for dynamic T3113
Change-Id: Ib8228f8485527d34794048a9927e62b6ec8d802a
Closes: OS#5553
2022-05-09 17:50:38 +02:00
Harald Welte 712a6647b1 paging: Avoid queueing more than 60 second estimated requests
Reaching this point will only make system load (CPU, mem) grow, making
it hard for the process to keep up with work to do, with no benefit
since the requests will anyway be scheduled too late.

Related: SYS#5922
Change-Id: I6523c6816a4d16b71084d004e979be40cf0aeeb0
2022-05-09 17:50:38 +02:00
Harald Welte 52b910ebbd bts.c: prevent signed integer overflow in depends_on code
bts.c:818:37: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

Change-Id: Ic68e6eb11fb70bf68d3f075fe2e467aedcbfaba8
2022-05-07 19:21:00 +00:00
Neels Hofmeyr a09d78faa9 fix fallout from: 'stats: new trackers for lchan life duration'
In lchan_fsm_cleanup(), ensure that the time_cc timer is actually inactive
before deallocating. Do so via lchan_reset(), to also make sure the
timer is stopped in all other situations where the lchan is deactivated.

This fixes an infinite-loop deadlock as described in OS#5554:
- run BSC_Tests.TC_chan_act_ack_est_ind_noreply
- restart the BTS process after the test is done
- osmo-bsc enters infinite loop in osmo_timer_del()

The reason is that lchan_fsm_cleanup() fails to stop a running active_cc
timer upon lchan deallocation. TC_chan_act_ack_est_ind_noreply
incidentally terminates OML while the timer is still active.

Related: OS#5554
Change-Id: I901bb86a78d7d021c8efe751fd9d93e5956ac0e0
2022-05-06 15:47:14 +00:00
Pau Espin 5a2347d4bc paging: Avoid unnecessary immediate polling in mainloop
We have seen an increased CPU load in osmo-bsc recently since the paging
improvements where merged, centered round poll() calls.
It is expected most of them will be fixed with previous patch. In any
case, let's avoid unnecessary poll() calls being called for no reason.

Related: OS#5922
Change-Id: Ie767bdc8d4353aafe375a424e02d698ef7fd3dea
2022-05-06 13:30:17 +00:00
Pau Espin cdd2bbd8b8 paging: Fix recalculate work timer if waiting for retrans
We want to recalculate the timer based on last time the work_timer was
triggered (that is, the time when the worker re-armed the pag req to
retransmit). We don't want to recalculate based on the last time the pag
ret tro retransmit was scheduled.

In loaded paging queue, there's lots of retrans (let's say 200) and it
may take more than 500ms to actually retransmit them. That means in most
cases we could end up in a situation where only pag req to retrans where
in the queue, hitting this recalculate path. Since the 500ms were for
sure elapsed, that would most probably schedule the work_timer at {0,0}
for each new paging request that arrived. As a result, the worker would
be scheduled lots of times per second (once for each new req arriving)
and only submitting 1 pag req (the new one) plus potentially 1 or
serveral pag req to retransmit.

In summary, there was not throthling applied in the scenario where only
pag req to retransmit where in the queue and new pag reqs kept arriving.
This incurrs into augmented paging throughput and also augmented
frequency of polls().

Related: OS#5922
Fixes: 4821c9f4df
Change-Id: I7ce6f436286b50dc31331d218ff256cf7be3f619
2022-05-06 13:30:17 +00:00
Pau Espin 38db714588 paging: Improve logging
Change-Id: I3186f841623cad8ed3296ac4d541e5cf4701132d
2022-05-06 13:30:17 +00:00
Pau Espin f4dca1b53f bts_ipa: Send NM_EV_OML_DOWN following object tree in order
In TS, TRX, BTS, BTS-SM order.

Change-Id: I90a70957dc3fd434ccd82bf2fa8d8c2c59f08059
2022-05-06 14:52:07 +02:00
Pau Espin 51879bbab9 nm_is_running(): Drop duplicate check
NM_AVSTATE_OK is 0xff, so we are checking twice against same value.

Change-Id: Idac56e5eca2b6f6998195ec764fac7edbc8f53e2
2022-05-06 14:52:07 +02:00
Pau Espin b978d1582f nm_statechg_signal_data: Convert state ptr to data
There's no need to use pointers there, it is only asking for errors from
code handling the data structe from the signal by attempting to change
them. Even for mem size point of view it doesn't make sense, since it's
3 byte vs a 4 byte pointer.

Furthermore, this is a preparation for new commit, where the NM object
current state will be updated before emitting the signal. This patch
eases a lot the follow up mentioned patch.

Change-Id: I9b648dfd8392b7b40bfe2b38f3345017481f5129
2022-05-06 14:50:24 +02:00
Pau Espin 7b36d0b0a0 acc: Fix erratic ramping behavior when several BTS configured
One callback function was being registered for each BTS.
That means, when a C0 RCARRIER of one specific BTS changed NM state,
the outcome on whether to trigger/abort ramping would end up being
applied to all BTS.

Change-Id: I56c4dd1809fdcf8441a69bf77ad173e1ccc8eea7
2022-05-06 12:34:59 +00:00
Pau Espin 7d621e0a79 constify state pointers of struct gsm_nm_state
This makes sure code accessing those fields is not changing its values,
since it would make no sense to change those. Follow up commit will make
convert those pointers to be full structs instead, as there's no need to
have pointers there.

Change-Id: I9979e62eac861e25bbe2161ab187ddb2b40fd097
2022-05-05 14:51:13 +02:00
Pau Espin 7cedfd4a44 cosmetic: Fix open brace in same line as func definition
Change-Id: Ibde106ea9ae1aea2b7f8fc6d9ed80eb79579b9e0
2022-05-05 14:51:13 +02:00
Pau Espin 633523167d abis_nm: Merge signals S_NM_STATECHG_ADM and S_NM_STATECHG_OPER
Having 2 signals makes all code handling them more complex, specially
because S_NM_STATE_CHG_OPER could actually provide any change in
admin/oper/availability.
Both signals already provided the same kind of data (the whole
admin/oper/avail state change), so let's simply merge the signals
themselves. Current code really doesn't act differently for those 2
signals anyway.

Change-Id: Ia86d20a42b859063d0327b940ba528ec1438b04a
2022-05-05 14:51:10 +02:00
Pau Espin 5cc9ed5567 ipaccess-config: Use proper define for nm availability value
Change-Id: I368646c54f434094319c72492c616aeda5e09e6a
2022-05-04 15:39:02 +02:00
Pau Espin 35dca11585 abis_nm: Use proper define for avail state 0xff
Change-Id: If5474700d368e99c8242290e3890b751fe1e85c2
2022-05-04 15:30:01 +02:00
Pau Espin 94890021a8 Remove commented out code
This code is not used currently. Furthemore, it makes little sense to
transmit an OPSTART if the BTS already told us it is enabled (because
OPSTART is what moves the BTS into operational enabled state).

Change-Id: I2c65e0803fbde7de9497089b562275baad58936a
2022-05-04 15:16:52 +02:00
Pau Espin 82a18caf11 Drop duplicate function helper
Change-Id: Idac049d07bf105b85a71af2f15f56552c453a370
2022-05-04 11:47:53 +02:00
Pau Espin 780c8a76dc paging: Remove TODO comment
That function is used to get the number of paging groups, so it doesn't
apply here.

Change-Id: I980c0961e86d9464235ea9c403adba6b0eded58e
2022-05-04 11:37:06 +02:00
Michael Iedema 5e2ac29703 stats: new trackers for lchan life duration
This patch adds two stats which track cummulative lchan lifetime by
type TCH and SDCCH. These new counters will accomplish two things:

1) Provide a glanceable way to see if lchan durations look healthy. When
examining a site, short-lived (<5s) and long-lived (>30s) TCH lchans
are difficult to tell apart. If we only see short-lived TCH lchans,
there is most likely an RF or signaling problem to investigate. This
new counter will expose channel ages in the VTY output

2) Provide a more accurate count for Erlangs per site. Currently, we
are basing Erlangs on active TCH channel counts per stats period. This
method skews high very quickly. Each active TCH in that period
translates into the full 10s of activity. This counter should improve
accuracy by two orders of magnitude.

Change-Id: I1b0670c47cb5e0b7776eda89d1e71545ba0e3347
2022-05-03 11:03:28 +00:00
Pau Espin 5f2a4a9fb3 paging: Take into account extra delay of all paging groups in BSC queue
So far we only calculated the expiration time based on the amount of
requests of the same paging group in the BSC queue.
However, also extra time has to be taken into account regarding requests
of other paging groups. This is important because requests of all paging
groups are mixed in the BSC queue, meaning having a lot of requests from
other groups before a certain req will anyway delay transmit of that
req to some extend.

Related: OS#5537
Change-Id: Ib55f947c5d3490b27e1d08d39392992919512f9a
2022-05-03 10:41:22 +02:00
Pau Espin 6b51f3d725 paging: Flush pending paging requests when bts obj freed
Change-Id: I3a81eda48cd44c70a2a690a0814a296ba22eaa8e
2022-05-03 10:27:19 +02:00