Commit Graph

2648 Commits

Author SHA1 Message Date
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
Pau Espin 1ddafb3781 bts: Properly free ctr/stat when bts object is freed
This was so far workarounded in tests by manually freeing the fields.
However, in follow-up patch the paging queue will also be properly
freed, so free of the counters needs to be previously fixed too so that
counters are freed at the right point of time.
Otherwise, during paging queue flush, counters are used and would crash
because they were freed before the BTS object in each test's bts_del().

Change-Id: Id213e21cf9bfc5439021e459c22ba4704d8cae2b
2022-05-03 10:25:15 +02:00
Pau Espin 36595ea7c5 abis_rsl: Use proper struct in rsl_paging_cmd
Use the same one as used to decode the message in osmo-bts.

This patch doesn't cause a change in logic since both headers are binary
identical.

Change-Id: Ideb863fdaedf77caac1a320de6696ba4f507a398
2022-05-03 10:23:16 +02:00
Pau Espin 48a428084e abis_rsl.c: Drop unused function
Change-Id: I14457608aba799eccf9db6983d72fe0a5343be5c
2022-05-03 08:10:58 +00:00
Oliver Smith 159246f94f Check VTY config against features reported by BTS
* Don't copy features for osmo-bts and nanobts initially, wait until
  BTS reported its features
* Checks for BTS features in VTY cmds: pass if features are not known
  (not yet reported by the BTS), fail if the feature is missing
* Once BTS reports its features, check relevant VTY config parts again

Related: SYS#5922, OS#5538
Change-Id: I7fca42a39a4bc98a6ea8b9cfab28c4bad3a6a0aa
2022-05-02 15:21:28 +02:00
Oliver Smith aa6404f3f8 abis_nm: add bts model features to reported ones
As pointed out in code review, for nanobts we need to be able to combine
the reported features with a list of features we assume that the bts
model supports. This is because the enum of features is based on what
nanobts is able to report, but was extended for osmo-bts.

Related: SYS#5922, OS#5538
Change-Id: I7bdbf28c148877275048e070dce7f503ca5e6226
2022-05-02 15:14:05 +02:00
Pau Espin ad1f436512 paging: Document 'ccch_load_ind_period * 2' value
Change-Id: Ie88bb0f9859bcf4b3b4a07ccf3b1791cb50163f1
2022-04-29 17:10:57 +02:00
Pau Espin 4821c9f4df paging: Recalculate work timer if waiting for retrans
If the queue is only holding requests in retransmition state, when we
add a new one, we have to re-calculate the work timer to a lower value
instead of letting it wait for the first retransmit to be ready.

Change-Id: Ibd4f8921c92f7481f0b9943041c141640ab812c8
2022-04-28 16:04:04 +02:00
Pau Espin e731301c25 paging: Early stop work_timer when paging queue becomes empty
There's no need to keep the timer running, since anyway upon next
trigger it will simply early exit in paging_handle_pending_requests()
becuase there's no more work to do.

Change-Id: I096ab7231f52c741c5fded37acd5b309e1de06e3
2022-04-28 16:04:04 +02:00
Pau Espin 26d55777fa paging: Increase T3113 based on paging group load in BSC queue
Related: OS#5536
Change-Id: I904c008222ddc3d92843d87fb3182c30b484c8a2
2022-04-28 16:04:04 +02:00
Pau Espin 98ff9bbb2a paging: Improve logging
Change-Id: I8a83352d6f2370bafa5acb0caba6b2f352263b5c
2022-04-28 16:04:04 +02:00
Pau Espin 5cfb63f4b0 paging: Improve calculate_timer_3113()
Depends: libosmocore.git Change-Id I6ef085ee92b2064cb46fa5ec3ae98a0ca59ad599
Change-Id: Id7d6bf93537bcef6658ec72e3ebedcedf64690ed
2022-04-28 16:04:04 +02:00
Pau Espin 1e79745e80 paging: Decouple retransmit period from regular worker interval
Before this patch, on each BTS a 500ms timer was used to schedule some
work, sending up to 20 paging requests verytime.

This means, however, for an initial paging request it may take up to
500ms delay to be scheduled to the BTS, which is huge.

While we still want to maintain this 500ms interval for retransmits, it
doesn't make sense to wait that much for other cases. It's far better
sending less requests (10 instead of 20) every half time (250ms instead
of 500ms), since it will spread the load and paging more over time,
allowing for other work to be done in the middle.

Change-Id: I7a1297452cc4734b6ee8c38fb94cf32f38d57c3d
2022-04-28 16:04:04 +02:00
Pau Espin a6474172e4 paging: Check C0 RSL link instead of OML link
PAging happens over C0 RSL link, not over OML, so let's actually
validate that the C0 RSL link is up before paging instead of the OML
one.

Change-Id: I11e5bb6f952534763935aa01470e514d4af247ed
2022-04-28 16:04:04 +02:00
Pau Espin 525567de74 paging: Rework timer lifecycle logic
Decouple credit_timer from event "available_slots became 0".
Let's actually relate credit_timer to the fact of not receiving CCCH
Load Indication: If no CCCH Load Indication is received (cch_load_ind_period * 2),
then assume we are below CCH Load Indication threshold (10% load) and
start estimating the available_slots in a cch_load_ind_period*2 time
frame.

Moreover, in paging_schedule_if_needed(), there's no use in delaying
start of processing work if the work_timer is not already doing work.

Related: OS#5537
Change-Id: I6a0da03c408270044079e81d431f6641527c00cd
2022-04-28 16:04:04 +02:00
Pau Espin c9ac7cb91f paging: Estimate available_slots based on BTS config when no CCCH Load Ind received
Related: OS#5537
Change-Id: I2df68e10eb549d62765ad3b25429f7fe2d5bb0b9
2022-04-28 16:04:04 +02:00
Harald Welte 24567cfeed cbsp: Reject CBSP WRITE for emergency if emergency already active
From 3GPP TS 48.018:

If only the New Serial Number IE, and not the Old Serial Number IE, is
included in the WRITE-REPLACE message,then the BSC shall interpret the
message as a write request, i.e. a broadcast request of a new emergency
message without replacing an ongoing emergency message broadcast.

Only one emergency message at the time can be broadcasted in a cell. If
a write request is received for a cell where an emergency message
broadcast is currently ongoing, the write request is considered as
failed.

Change-Id: I376c9e796f3a2d26b22d0451f15ef1debbd7f656
Closes: OS#5539
Related: SYS#5906
2022-04-28 13:48:20 +00:00
Harald Welte 7a982712ac cbsp: Implement KILL for Emergency Broadcast
So far, we only implemented KILL for CBS, but not for Emergency
broadcasts.  This patch adds KILL support for Emergency, by which
a CBC can terminate broadcast of a previously-started Emergency
message before its scheduled period ends.

Change-Id: Ie91939b93de6847eeb5d00c97a137c43721c2711
Closes: OS#5540
Related: SYS#5906
2022-04-28 13:48:20 +00:00
Harald Welte bcd0f63dce smscb: Always start ETWS timer even in cells without ETWS support
ETWS is sent over both dedicated channels and broadcast channels.
Some BTS models may not support the latter, but it is still useful
to start the related timer to ensure bts->etws.active gets set to
false after the emergency period has concluded.

Change-Id: I448be9fd75b87c1f7333a5bfa4f6ba238569fdc3
2022-04-28 13:48:20 +00:00
Harald Welte 484f535c50 smscb: Store ETWS input state from CBSP
Only if we store data like the CBSP message_id and serial_number
we are able to later (in a subsequent patch) match a CBSP KILL
for ETWS/PWS and stop emergency broadcast.

Change-Id: Ide74638880d7e3c6a7c774bf6320d3dce4b11c74
Related: OS#5540
2022-04-28 13:48:20 +00:00
Harald Welte 5e7458cbd8 smscb: Don't include extraneous IEs in CBSP KILL COMPLETE / FAILURE
TS 48.049 states the following rules for the KILL COMPLETE / FAILURE
messages:

The Number of Broadcasts Completed List IE, if present, contains for
each cell the total number of broadcasts of the killed CBS message.

The Cell List IE, if present, contains the cells in which the emergency
message is successfully terminated.

As any message can only be either emergency or CBS, this means that
we can (at maximum) have only one of those two IEs in the message.

As there is no explicit indication in the KILL whether it relates
to CBS or Emergency, we use the "Channel Indicator" IE, which is
specified as "only included if the message refers to a CBS message".

Related: SYS#5906
Closes: OS#5541
Change-Id: I9a43d386da01f085663d231a555b8b5acc99faca
2022-04-28 13:48:20 +00:00
Oliver Smith 41aa1feb15 bts_model_*_start: move set_feature calls to _init
With previous patch Idf2d933aa8b03b1f708e56a08707fe6c620a97aa, the
features get copied from the BTS model to the BTS. For rbs2000, bs11 and
nokia_site, an empty feature set was copied because the features weren't
set at this point. Fix this by moving the set_feature calls to _init().

Notably the set_feature calls had been moved for osmo-bts and nanobts
from _start to _init already in 2013 in the patch e84dd98d
("sysmobts: Avoid a crash when trying to look-up a BTS").

Fixes: 2d818b9f ("Always use reported features if available")
Related: SYS#5922, OS#5538
Change-Id: I43389ae48d5e0f01381602751f6bad902011b158
2022-04-28 12:14:28 +00:00
Oliver Smith 3eb14ee7c7 abis_nm_ipaccess_rsl_connect: initialize ia
Fix access to uninitialized value from inet_ntoa(ia) inside the log
message, found with valgrind.

Change-Id: I6c04fdc329bb56b82087c817e2fbe5a6504bf1dc
2022-04-28 12:14:28 +00:00
Vadim Yanitskiy a985e3370d utils/meas_pcap2db: fix -Wpointer-sign in pcap_cb()
When building with CFLAGS="-flto -Wall", I get the following:

  meas_pcap2db.c: In function ‘pcap_cb’:
  meas_pcap2db.c:64:27: warning: pointer targets in initialization of
                                 ‘const char *’ from ‘const u_char *’
                                 {aka ‘const unsigned char *’} differ
                                 in signedness [-Wpointer-sign]
     64 |         const char *cur = bytes;

Change-Id: I84d8e6f290bda0f03476f182f292ecc7a9e520f2
2022-04-27 12:41:24 +00:00
Vadim Yanitskiy 8951197447 utils/meas_db: fix -Wunused-variable warnings
When building with CFLAGS="-flto -Wall", I get the following:

  meas_db.c: In function ‘_insert_ud’:
  meas_db.c:62:23: warning: unused variable ‘rowid’ [-Wunused-variable]
     62 |         unsigned long rowid;
  meas_db.c: In function ‘meas_db_insert’:
  meas_db.c:89:13: warning: unused variable ‘rc’ [-Wunused-variable]
     89 |         int rc;
  meas_db.c: In function ‘check_create_tbl’:
  meas_db.c:260:16: warning: unused variable ‘rc’ [-Wunused-variable]
    260 |         int i, rc;

Change-Id: Id12958f67a47b6b3ebece7252e4f7c0835d4bb96
2022-04-27 12:41:24 +00:00
Pau Espin 0bcd47f014 bts: Make sure paging timers are deleted when struct gsm_bts is freed
Change-Id: If8dffc948a3a9d8bdd9237f644e7f10f41c64853
2022-04-27 10:03:01 +00:00
Pau Espin c3487dd19d Introduce VTY command 'ccch load-indication-period <0-255>'
Change-Id: Id9d23238863c02a72bcf32942f6b0d40be127904
2022-04-27 10:03:01 +00:00
Oliver Smith 2d818b9f2e Always use reported features if available
Instead of sometimes checking against hardcoded BTS model features, and
sometimes against features reported at runtime (which only some BTS
models do):
* copy the hardcoded BTS model features to BTS features initially
* do all checks against BTS features

Related: SYS#5922, OS#5538
Change-Id: Idf2d933aa8b03b1f708e56a08707fe6c620a97aa
2022-04-26 12:06:47 +00:00
Oliver Smith d055493071 gsm_data: add gsm_set_bts_model
Let all changes of the bts model go through this function, so we can in
a future patch copy over the bts model's features to the bts.

Related: SYS#5922, OS#5538
Change-Id: I8475c8c20eb72411e8ca820181d1c8603c22a56d
2022-04-26 12:06:47 +00:00
Oliver Smith 5586149d73 abis_nm: don't compare assumed/reported features
Just log all reported features, instead of comparing them against an
expected set of features and logging mismatches. The point of reporting
features from the BTS at runtime is that the BSC can support various BTS
versions with various feature sets.

Related: SYS#5922, OS#5538
Change-Id: Ibd79bc7ef802d8e95e05d746df182ff974b78e29
2022-04-26 12:06:47 +00:00
Neels Hofmeyr 7dc3048759 emerg call: send BSSMAP Clear Req cause as preemption
After the lchan release, the gscon would go into the Clear dance with an
arbitrary cause value. Instead, explicitly ask for a Clear upon
pre-emption, with the proper cause value.

Related: OS#5535
Change-Id: I20108f7b4769400b89b7b0d65c8dab883bf87c46
2022-04-25 21:19:10 +00:00
Neels Hofmeyr 5bad630fb5 emerg call deny: log on LOGL_ERROR
Change-Id: Id6ea25484479bfc1728124df8fe8e2e03bcee3ec
2022-04-25 21:19:10 +00:00
Neels Hofmeyr 43f46d3b3a emerg call deny: fix RR release cause
So far the we indicated pre-emption in the release cause of denying an
emergency setup, instead indicate protocol error.

When emergency calls are disallowed, it is not pre-emption (making room
for an emergency call) but a protocol error (MS asks for emergency call
when the network does not allow it).

Related: OS#5534
Change-Id: Ia195621165cb7bbe33e6c2e915abc42ab16a2a4f
2022-04-25 21:19:10 +00:00
Neels Hofmeyr 96f4ff310e emerg call: tweak log, comments
Change-Id: I01e457ae6a9a951a2525c2159cb5979a0cb8bd95
2022-04-25 21:19:10 +00:00
Pau Espin 201eb29616 Rename functions generating OML SetAttr messages
Its name is totally misleading, since they seem to be related to
GetAttributes messages rather than SetAttributes.

Change-Id: I306cb407dbd9b98e301b5d93046bdadcb466b82b
2022-04-25 17:06:22 +02:00
Pau Espin 3a46ae5962 cosmetic:: Document TLVs in nanobts_attr_bts_get()
Change-Id: I7e9cbf84edb6bdcbaf38f03552103236ea1cef6c
2022-04-25 16:58:59 +02:00
Pau Espin 08446e5b89 paging: Prioritize requests for new subscribers over retransmitions
Currently, the Tx paging_req queue at the BSC always has new paging
requests adding at the end (as long as the subscriber is not already in
the queue).
That means, if the queue is full of retransmitions, it will take a long
time until the first paging_req is sent towards that subscriber.
The rationale here is that it makes sense to attempt the first paging
ASAP, and give lower prio to paging_req retransmitions, since it may
well be that those other subsribers are not available/reachable and
won't answer.

Related: SYS#5922
Change-Id: I1ae6d97152c458247bc538233b97c2d245196359
2022-04-25 14:12:59 +00:00
Pau Espin 7ed160afd2 paging: Submit up to 20 paging requests in a single work iteration
Having one paging request being sent every PAGING_TIMER (500msec) is too
slow in case BSC is serving lots of subscribers on a BTS. Hence, we want
to send many paging requests at once while still trying not to fill the
BTS buffer.
Morever, we don't want to send tons of paging requests at once, hence we
limit the amount of paging requests sent in one timer iteration
(MAX_PAGE_REQ_PER_ITER) in order to avoid the BSC doing lots of work
there at once, keeping it busy from processing other tasks.

Related: SYS#5922
Change-Id: I609fa67834b426456f48f6fb2acb601c5905f178
2022-04-25 14:12:59 +00:00
Vadim Yanitskiy 5339e3abb2 abis_nm: always check return value of tlv_parse()
Change-Id: Iecba34a96f71922ddd25028e7d3404f89b1106de
2022-04-25 16:09:25 +03:00
Vadim Yanitskiy c6043c8877 bssap: always check return value of tlv_parse()
Also take a chance to replace tlv_parse() with osmo_bssap_tlv_parse().

Change-Id: I90a732d26b4e674d9f7f10197105f7bf9860261d
2022-04-25 16:09:25 +03:00
Oliver Smith 265a04791f Cosmetic: bts_model_osmobts_init: update comment
Mention bts_init too.

Related: SYS#5922, OS#5538
Change-Id: I885c7e294051627064a763fca6dae08daca4b650
2022-04-25 13:06:20 +00:00
Vadim Yanitskiy 462628ebd9 gsm_data: use llist_for_each_entry() in gsm_bts_by_lac()
Change-Id: I55c8067dc377aaccb63e8d5f8d2ca89cbb74b11a
2022-04-25 13:05:33 +00:00
Vadim Yanitskiy 2641f5c3a7 abis_rsl: fix NULL pointer dereference in abis_rsl_rx_rll()
Found with GCC's static analyzer (-fanalyzer).

Change-Id: I620538388f6971418980b03a6a1b2384e7c87e15
2022-04-25 13:05:33 +00:00
Pau Espin 63f9a04bcc paging: Log skip paging due to not enough free channels
Change-Id: I311f90be99c4561b45f99ce98533aab5909301d0
2022-04-25 11:31:16 +02:00
Pau Espin 35778138a8 paging: Use llist_first_entry() macro
Change-Id: I83e88de6f48cc8aad18ed80ab981b0b438e72b1a
2022-04-25 11:31:16 +02:00
Pau Espin fc90e56178 paging: Avoid setting up credit_timer every time
Change-Id: Id4da0ab094ffe939cad9ff5708721e25b5a1a984
2022-04-25 11:31:16 +02:00
Pau Espin 2f281f1e90 rsl_rx_ccch_load: Use UINT16_MAX instead of -1
The variables are unsigned, so -1 gets actually translated to UNIT16_MAX
when the value is casted to uint16_t. Let's do that explicitly so that
readers don't think those are signed variables.

Change-Id: I02ad80e5d10f1a47cdf712f7f7c576a2e20fe607
2022-04-25 11:29:35 +02:00
Pau Espin 81abce68a6 paging: Use define available in libosmogsm
Change-Id: I6425a9cb1100391404d79ead66dfb1337bbcbcab
2022-04-25 08:35:57 +00:00
Pau Espin 8ba95b4d5a Move struct gsm_bts_paging_state to paging.h
Change-Id: I8c058d308fc816828b5e6a86e7c5a1f629a2d7c4
2022-04-25 08:35:57 +00:00
Neels Hofmeyr 7857b0969e emerg call: fix RR release cause for pre-emption
If an lchan needs to be released to make room for an emergency call,
send the proper release cause ("pre-emption").

Related: OS#5534
Change-Id: I0423621d15ace11a53ae1653e5e7f5cb93605edb
2022-04-24 00:34:17 +02:00
Pau Espin e11910a8cf bts: Simplify bts->paging initialization
Related: SYS#5922
Change-Id: Id103d5f3d437065abcd32788caef339343b1e96
2022-04-21 16:08:40 +00:00
Pau Espin 304485ac8d bsc_vty: Add missing header
Change-Id: I83c6dc786ed07703da5eeb3c89df66cc6c4f2033
2022-04-21 16:08:40 +00:00
Oliver Smith f72b07e5da bts_model_osmobts_init: order feats alphabetically
Order the features and add a comment that reminds of updating OsmoBTS
to actually report the new features that are assumed to be supported
here.

Related: SYS#5922, OS#5538
Change-Id: I6f041648990db4ae479538cf3970c826bc6703ed
2022-04-21 17:21:55 +02:00
Harald Welte e053f9a492 Fix compile errors on #warning with '-Wall' on gcc-11.2
pcu_sock.c: In function ‘pcu_tx_info_ind’:
pcu_sock.c:197:2: error: #warning "isn't dl_tbf_ext wrong?: * 10 and no ntohs" [-Werror=cpp]
  197 | #warning        "isn't dl_tbf_ext wrong?: * 10 and no ntohs"
      |  ^~~~~~~
pcu_sock.c:199:2: error: #warning "isn't ul_tbf_ext wrong?: * 10 and no ntohs" [-Werror=cpp]
  199 | #warning        "isn't ul_tbf_ext wrong?: * 10 and no ntohs"
      |  ^~~~~~~

they made it here from osmo-bts.git
(b4999b60d4 states that the PCUIF support
was copied from there). The gitlog shows that these warnings were added
in 744f745d7a508605254afa8f78412ad410d153b0 by jolly (in 2012!)
together with the PCUIF support, and before
c1368d4ebe49f8e01f1f5fff3bc3583cb5960c1d these warnings were in German:
"ist dl_tbf_ext nicht falsch?"

As nobody has bothered for the past ten years, degrade them to comments.

Change-Id: I9ef7e18f56aa86b48f0ffeec58406260736170f3
2022-04-20 21:49:50 +02:00
Harald Welte 83ac4b26be lchan_fsm.c: Fix misleading comment
From Vadim in https://gerrit.osmocom.org/c/osmo-bsc/+/27818

By checking !(link_id & 0xc0) we actually make sure that this is not
SACCH. So the comment "but not if the link_id contains a TCH flag" is
wrong, there is simply no such thing like "a TCH flag".

Change-Id: I8f0f6d7bf952426fd2f27802f1499d6ee8981982
2022-04-20 21:46:58 +02:00
Harald Welte e0e4941098 lchan_fsm: Ignore other SAPIs of RLL_REL_IND for SAPI=0 is received
If the BTS tells us SAPI=0 is gone, there is no point in trying to keep
the lchan around for SAPI=3, as it is not possible to operate GSM with
SAPI=0 gone.

This occurred with RBS6000, which don't seem to send RLL REL IND for
SAPI3 after doing so for SAPI0.  However, rather than an
ericsson-specific hack, let's make this the general rule: If SAPI=0
is gone, don't stop the lchan from being released.

Change-Id: Ia9caa5b0a5efdc459d94621367376927959a6e65
Related: OS#5530
2022-04-20 19:44:51 +00:00
Harald Welte 0c93a3390a Handle unknown rllr_ind enum values in rll_ind_cb()
If we receive something unexpected, log it (and free the msgb!)

Change-Id: I43fab6a3a1c5e7a6545d6ef848636f5ba1be1576
Related: OS#5530 (only tangentially related)
2022-04-20 15:04:09 +00:00
Neels Hofmeyr c68096c2c3 hodec2: apply penalty_low_rxqual_as only on assignment
The penalty timer low_rxqual_as() is only supposed to apply on an
intra-cell re-assignment. However, a segfault has been reported that
apparently applies it to inter-BSC handover.

Make sure that this timer applies only to re-assignment. In effect this
makes sure that the target bts is non-NULL and avoids the segfault.

Related: OS#5525
Change-Id: Ifdb9891fbe7e3f3423a96371def4fcbf2fc0bc0d
2022-04-18 12:04:42 +00:00
Harald Welte 249700add7 abis_rsl: Fix typo in log message
Change-Id: Ia614541ccb02beddc7a869b9fb9151393959844c
2022-04-18 08:17:25 +02:00
Harald Welte 592c8ec29d smscb: Populate "Number of Broadcasts Completed" to KILL COMPLETE
When responding to a CBSP KILL with a CBSP KILL COMPLETE, make sure
we include the optional "Number of Broadcasts Completed List" IE
in order to inform the CBC about how many times the just-killed
message had been broadcast before it was killed.

It seems some CBCs expect this IE to be present, while 3GPP TS 48.049
lists it as optional.  Since we alrady have code to encode it, let's
just always add it - it certainly won't hurt.

Change-Id: I47aebd613dfc6dd9261ea9019a51aff0cd6470d8
Closes: SYS#5906
2022-04-14 12:44:56 +02:00
Vadim Yanitskiy 5f2d30f0ea bts: gsm_bts_alloc(): use reasonable multi-rate config defaults
The current multi-rate configuration uses the same threshold and
the same hysteresis values for all modes: 32 and 8, respectively.
This basically forces the AMR link adoptation loop in the BTS to
stick to the initial codec mode during an lchan's lifetime.

Let's use more reasonable default values from 3GPP TS 51.010-1
(version 13.11.0), sections 14.2.19.4.1 and 14.2.20.4.1 for
AMR-FR and AMR-HR, respectively.

                  ^ C/I (dB)             |  FR  /  HR  |
           |      |
           |      |
  MODE4    |      |
         = |  ----+----  THR_MX_Up(3)    | 20.5 / 18.0 |
         | |      |
         | =  ----+----  THR_MX_Dn(4)    | 18.5 / 16.0 |
  MODE3  |        |
         | =  ----+----  THR_MX_Up(2)    | 14.5 / 14.0 |
         | |      |
         = |  ----+----  THR_MX_Dn(3)    | 12.5 / 12.0 |
  MODE2    |      |
         = |  ----+----  THR_MX_Up(1)    |  8.5 / 10.0 |
         | |      |
         | =  ----+----  THR_MX_Dn(2)    |  6.5 /  8.0 |
  MODE1  |        |
         |        |
         |        |

Change-Id: Ic5f8d55d250976d8d4c9cae2d89480fd52326717
Related: SYS#5917, OS#4984
2022-04-12 13:22:54 +03:00
Vadim Yanitskiy ec51e40607 bts: gsm_bts_alloc(): rework default multi-rate configuration
This is cosmetic change making the default multi-rate configuration
easier to read/understand and modify.

Change-Id: I3d03c2188d007a60a86961a346744400bc81d4e6
Related: SYS#5917, OS#4984
2022-04-12 13:22:48 +03:00
Vadim Yanitskiy 7f3705742f VTY: clarify help for the Adaptive Multi Rate settings
* Always say 'codec mode', not just 'codec'.
* Suggest proper modes in AMR_{TH,HY}_HELP_STR.
* Use 3GPP's definition of threshold and hysteresis.
* Clarify that threshold and hysteresis values are in 0.5 dB steps.

Change-Id: I996eae8aafeb2850e5e1a6f5a7764d745e1289b5
Related: SYS#5917, OS#4984
2022-04-12 09:53:34 +03:00
Vadim Yanitskiy 6a97cd39b6 Move power control related definitions to power_control.h
Now that we have separate header/code files for the power control,
let's move the related definitions there.  This change makes the
code consistent with osmo-bts, where it's already done this way.

Change-Id: I1cb3f6bfba0306e8f371dcd5162d1813beb3a088
2022-04-08 01:23:04 +03:00
Vadim Yanitskiy 6c33014bb9 power_ctrl_params_def_reset(): set .ctrl_interval for both UL/DL
For the sake of consistency and code readability, initialize the
power loop control interval (P_Con_INTERVAL) for both Uplink and
Downlink directions in the same function.

Change-Id: Ie3d4b481cbfacf27004787616e22b6f8a863b47b
2022-04-08 01:12:17 +03:00
Neels Hofmeyr 18334d506d assignment_fsm: always update RTP info
When the assignment succeeds, the assignment_request has taken effect
and whatever it requested should now be in effect.

Hence copy the new RTP information from the assignment_request to the
conn's storage indicating what is currently used, always, not only when
lchan_changed == true. The RTP information may have changed also from a
Mode Modify where the lchan stays the same but changes its mode of use,
e.g. from signalling to voice.

When there is no RTP involved, this data is zero or empty, so there is
no harm in copying it, always.

Related: SYS#5916
Change-Id: I0788d1f013b8f820f559b6ed58a5f9bb8a02e0b4
2022-04-07 00:04:27 +02:00
Neels Hofmeyr a5cf45a3dc assignment_fsm: always mark MGCP ci as completed
When the assignment fails, we roll back the MSC side RTP endpoint at the
MGW that may have been created before the failure occured. On success,
we clear the mgcp_ci pointer so it is not rolled back.

Always clear this, not only when lchan_changed == true. That is because
a channel Mode Modify may also have added a voice stream that should
retain the newly created RTP endpoint at the MGW.

If no voice stream is involved, the pointer should already be NULL.
There is no reason to have a condition for clearing this pointer.
Just always clear it.

This fixes all voice calls that modify a TCH lchan from signalling-only
to voice mode. Before this patch, their MSC side RTP endpoint was DLCX'd
right on assignment success.

In particular, this fixes Emergency Calls (which usually get a TCH lchan
assigned right from the start, and hence do a Mode Modify to add voice).

Related: SYS#5916
Change-Id: I5ab10ee7fd9c5d7608e8a06893881d990943feed
2022-04-07 00:04:27 +02:00
Vadim Yanitskiy 108d5dee74 abis_rsl: always check return value of rsl_tlv_parse()
Change-Id: Id022628934e7d51ce66cb255baa88f24bf5c918a
Related: SYS#5905
2022-03-31 21:29:17 +03:00
Harald Welte 9dfe6cb3d5 abis_rsl: Ensure message length is sufficient for respective header
Change-Id: I63b64f1f241de3a76f9b66ed2cf524cc88933062
2022-03-31 21:29:17 +03:00
Vadim Yanitskiy 041411cb70 fix gsm_bts_get_cbch(): CBCH can be allocated on Cn
According to 3GPP TS 45.002, table 3, unlike the CCCH+SDCCH/4+CBCH
combination, which can only be allocated on C0/TS0, the SDCCH/8+CBCH
can be allocated on C0..n/TS0..3.  In other words, having CBCH on
e.g. TRX1/C1 is perfectly legal.  This is why in gsm_bts_get_cbch()
we should check all transceivers, not just the C0.

Change-Id: Ie79ccff4f8f0f1134757ec0c35e18b58081cc158
Related: SYS#5905
2022-03-31 17:37:31 +00:00
Vadim Yanitskiy 79d2af9b31 cbch_scheduler: cosmetic: s/bts_cbch_timer/bts_cbch_timer_cb/
Change-Id: Ibff3045d8066b644b437e46330848ebadfb373fd
2022-03-31 17:37:31 +00:00
Neels Hofmeyr a0c4a06371 hodec2: add penalty-time low-rxqual-ho
When bad RxQual causes handover to a cell with weaker RxLev, then
handover oscillation *will* happen, as shown in test_rxqual.ho_vty.
Introduce a penalty timer for a cell where we had bad RxQual.

This delays handover back to the cell with stronger RxLev by the penalty
timeout; hopefully the interference is gone after the timeout.

Usually, we set new configuration elements so that osmo-bsc behaves the
same as before the config item was added. In this instance, this makes
no sense, because no-one ever wants handover oscillation from bad
RxQual, which is guaranteed to happen without the new penalty timer. Set
it to 60 seconds by default, same as other penalty timers.

Related: SYS#5911
Change-Id: I057b156604a104a26a7ce45d1c7adadbf452c932
2022-03-31 14:43:48 +00:00
Harald Welte 968367caec CBSP: implement MESSAGE STATUS QUERY
This add support for handling inbound MESSAGE STATUS QUERY from the CBC,
and responding with MESSAGE STATUS QUERY COMPLETE or MESSAGE STATUS
QUERY FAILURE, as applicable.

Change-Id: I3b738dc29d0ead4f735abeeb6960d3675cb05ae2
Related: SYS#5909
2022-03-29 14:25:15 +00:00
Vadim Yanitskiy 7fb4817b78 struct gsm_encr: store alg_id in human-readable format
I find it weird that we store the A5 algorithm ID in a format that
is used on the wire: N + 1 (valid for both A-bis and A interfaces).
What confused me even more is that in some functions we print it
as if it was in a normal, human-readable format.  And this is
also why one can see weird constructions like:

  if (lchan->encr.alg_id > ALG_A5_NR_TO_RSL(0)) { ... }

Let's ensure that our internal structures use the A5/N format:

  alg_id=0: A5/0   (0x01 on the A-bis/A interface)
  alg_id=1: A5/1   (0x02 on the A-bis/A interface)
  alg_id=2: A5/2   (0x03 on the A-bis/A interface)
  ...
  alg_id=7: A5/7   (0x08 on the A-bis/A interface)

so that we can print and compare the value of alg_id without using
additional arithmetics.  Let's also rename 'alg_id' to 'alg_a5_n'
as it most clearly indicates which representation it is storing.

This is how the above code snippet would look like:

  if (lchan->encr.alg_a5_n > 0) { ... }

Change-Id: Ieb50c9a352cfa5481aebac2379e0a461663543ec
2022-03-29 11:50:12 +00:00
Harald Welte eba0a02017 SMSCB: Preserve padding at end of page in CBSP -> RSL conversion
When copying the CBS page content from CBSP to RSL data structures, we
use the User Information Length as length argument in the memcpy.  The
logic for that is that only this part of the message contains valid
data.

However, as the user information length is not passed on via RSL or
transmitted over the air, the receiving MS will get a  page with
zero-initialized padding, rather than whatever the originator of the
message has specified.  As zero bytes in the 8bit domain might get
translated into @-characters in the 7bit domain, this creates problems.

So instead, let's always copy the entire page (82 bytes) to ensure
transparency when passing on information from CBSP to RSL.

Change-Id: Iffcf1f6a7d41a08a2feffc6f2ac5634d940b63aa
Closes: SYS#5904
2022-03-28 18:48:08 +02:00
Vadim Yanitskiy 0d327979ee BSSMAP LE: handle optional LCS {Client Type, QoS} IEs
On receipt of the Perform Location Request message, the BSC needs
to forward it to the SMLC.  If the abovementioned IEs are present
in the original message, they must be delivered to the SMLC too.

Change-Id: Ifeb359b0468845da0b4fed9e2e4b79256067fa81
Depends: libosmocore.git I8775a93cf4089b1752d040e43d2cba6b8997f955
Related: SYS#5891
2022-03-22 19:17:44 +03:00
Vadim Yanitskiy b7f6623f60 BSSMAP LE: fix handling of LCS Client Type IE
On receipt of the Perform Location Request message, the BSC needs
to forward it to the SMLC.  If the LCS Client Type IE is present
in the original message, it must be delivered to the SMLC too.

Change-Id: Id3262e67c3dc25cb93fbd52a40689c5529ca2d41
Related: SYS#5891
2022-03-22 19:16:07 +03:00
Vadim Yanitskiy bd4a7dafd5 parse_bssmap_perf_loc_req(): make 'struct tlv_p_entry' pointer const
Change-Id: Ieba7f65667c5a1f9c0d7d2a350ec736994b1866e
2022-03-22 16:17:07 +03:00
Pau Espin 36fe6e4421 SI13: Get rid of si13_default
It's really confusing having a "default" struct whose inner values are
changing based on previous state. Furthermore, it's only used in
generate_si13() so there's no need to keep it outside the function.

Let's move it inside the function and rename it to avoid confusion.

Change-Id: I3ae4dd017dd4dad10c0365d21727666dd8e9fd41
2022-03-19 22:52:23 +01:00
Pau Espin 3ec2b8349c system_information: Move all si13 specific val update to generate_si13()
Change-Id: I6e920d1c8d8e1673194c88929586e8a1f22e09c5
2022-03-18 20:11:22 +01:00
Pau Espin 07fba2b629 SI13: Avoid enabling use_egprs_p_ch_req if egprs not supported
It makes no sense to enable that field if the ext_info.egprs_supported
field marks EGPRS as disabled.

From TS 44.060 11.2.5a:
"""
This message may be sent by an EGPRS capable mobile station
*in a cell supporting EGPRS* and where the EGPRS_PACKET_CHANNEL_REQUEST
parameter indicates that this message shall be used.
"""

Related: SYS#5891
Change-Id: I5ac173116f8681d7340b75b2baff110158fab9fd
2022-03-18 20:11:22 +01:00
Pau Espin 4501ed413c SI13: Make sure egprs_supported field is always updated
If "bts->gprs.mode" was changed dynamically at runtime (VTY or CTRL), it
could happen that the egprs_supported was kept as "1" if the dynamic
change was EGPRS->GPRS.

In summary, if EGPRS support was set, it couldn't be unset until BSC was
restarted.

Related: SYS#5894
Change-Id: Id2c2319044da474642c4cc710baa27cfee4fb592
2022-03-18 20:11:22 +01:00
Pau Espin 6dec88682f SI13: Always send ext_info
Values in ext_info are modified in several places, so it's difficult
validating whether we deviate from default. Let's always send it so that
we always have a clear view on what the MS uses.

This fixes a bug where paging_coordination or ccn_active would not be
announced if GPRS was not enabled.

Related: SYS#5894
Change-Id: If96de3e0d77503cf6344dfbc611f9260ac3281aa
2022-03-18 20:11:14 +01:00
Pau Espin 789d4e92c3 bts_vty.c: Fix typo in comment
Change-Id: Id4c49e93fe5b4eaa4efdac116df34853f359dd98
2022-03-18 20:00:25 +01:00
Vadim Yanitskiy c1f7452c16 System Information Type 3: allow updating T3212 at run-time
The value in bts->si_common.chan_desc may get out of sync with the
actual value in net->T_defs (e.g. after changing it via the VTY),
so we need to sync it in generate_si3().

Note that synchronizing the values in cfg_net_per_loc_upd_cmd is
a bad idea, because the value of T3212 may also be changed using
generic timer management commands.

Change-Id: Iee291623c2825505eeb5175adcedadfe35375b9e
Related: SYS#5888
2022-03-16 22:33:55 +03:00
Vadim Yanitskiy a76c9dcc3b gsm_bts_trx_set_system_infos(): cosmetic: improve readability
Change-Id: Ic63ee79c7509ec57ad72f85442b5756ae31c0a52
Related: SYS#5888
2022-03-16 22:33:04 +03:00
Vadim Yanitskiy 7c14a12a78 fixup: gsm48_make_ho_cmd(): optionally add Synchronization Indication IE
This was overlooked during the code review.  GCC does not complain
because internally both 'enum handover_scope' and 'bool' are
interpreted as 'int'.  Found this while running my WIP testcase
TC_srvcc_eutran_to_geran_a5_3.  This change makes it pass.

Change-Id: I807fd4a0e700e54c67ca3547d9c0c1b442dd1c54
Fixes: I4e5b1163a71443d706f14ce4bfd5c2294c320432
Related: SYS#5838
2022-03-14 17:26:16 +03:00
Vadim Yanitskiy 53d05951a5 gsm48_make_ho_cmd(): optionally add Synchronization Indication IE
Change-Id: I4e5b1163a71443d706f14ce4bfd5c2294c320432
Related: SYS#5838
2022-03-14 14:07:39 +03:00
Vadim Yanitskiy 2902d91d69 gsm48_make_ho_cmd(): optionally add Cipher Mode Setting IE
According to 3GPP TS 44.018, section 9.1.15, the RR Handover Command
message may optionally contain the Cipher Mode Setting IE (10.5.2.9).
Section 9.1.15.10 states that this IE may be omitted in case of the
intra-RAT GERAN-to-GERAN handover, however in case of the inter-RAT
handover (e.g. EUTRAN-to-GERAN), this IE *shall* always be included.

Change-Id: I1d270e82d0a9b12897fc94dae4e8999aa132a22f
Related: SYS#5838
2022-03-13 18:20:40 +03:00
Vadim Yanitskiy 798a71eb30 gsm48_make_ho_cmd(): make 'struct gsm_lchan' pointer const
Change-Id: I731179bf7f5d711ca114e36af661faccf0caa19f
2022-03-13 17:50:19 +03:00
Vadim Yanitskiy a0033f5da7 gsm48_make_ho_cmd(): cosmetic: use existing BTS pointer
Change-Id: I98abe2e43af1f8fa7e70fcf7155478b39751fced
2022-03-13 14:15:39 +03:00
Vadim Yanitskiy 0a01573bc1 gsm48_send_ho_cmd(): this function is not used, remove it
Change-Id: I9771d7e1f2073ebf6d900c067885485e54790bca
2022-03-13 14:15:39 +03:00
Vadim Yanitskiy 663d6fed0c system_information: fix DCS/PCS band indicator in generate_si6()
Change-Id: Iaa8377919a144e7f3799b76249f579c8f3874145
2022-03-10 15:54:29 +00:00
Vadim Yanitskiy be5a6c949e system_information: use is_ipaccess_bts() helper
Change-Id: Id14f39f50a6d7644f81b21c0b89e10f44901348b
2022-03-10 15:54:29 +00:00
Vadim Yanitskiy ef919cb8c1 fix inp_sig_cb(): dispatch TS_EV_OML_DOWN to all transceivers
When running a multi-trx setup, upon stopping osmo-bts one can see:

  DCHAN ERROR lchan_fsm.c:80 lchan(0-1-7-TCH_F-0)[0x612000010120]{UNUSED}:
              (type=NONE) lchan allocation failed in state UNUSED: LCHAN_EV_TS_ERROR
  DCHAN ERROR lchan_fsm.c:144 lchan(0-1-7-TCH_F-0)[0x612000010120]{UNUSED}:
              (type=NONE) lchan activation failed
              (lchan allocation failed in state UNUSED: LCHAN_EV_TS_ERROR)

These messages show up when the following conditions are met:

  * BTS model speaks A-bis over IP (ip.access, e.g. nanoBTS), and
  * BTS has more than one transceiver configured.

The problem is that unlike traditional E1 based BTS models, ip.access
ones have a single global A-bis/OML link for all transceivers.  Thus
when it goes down, in inp_sig_cb() we need to notify all timeslots
*of all TRXes*, not just TRX0.

Change-Id: I3dc657ac5a2c5334747bd4f4db1a658acb323942
Fixes: OS#5479
2022-03-09 08:30:40 +00:00
Neels Hofmeyr 9d0af34fc5 fix typo in name of BSS_MAP_MSG_ASSIGNMENT_RQST
Historically, we first only had
  BSS_MAP_MSG_ASSIGMENT_RQST
                   ^
with missing N. libosmocore has this renamed a long time ago and
provides a shim #define that makes the typo version still work.
Having the typo is bad for grepping, so rather use the non-typo name.

Also rename the constant for the ass req counter which so far has a
similar typo, and fix the same typo in the counter description.

The counter name exposed on CTRL luckily doesn't have this typo in it.

Change-Id: Ieaa4f4e6e6f7e1563b1bd15a83f0c1a9112d2312
2022-03-09 07:15:51 +00:00
Neels Hofmeyr c60fabb62b fix extraneous newlines in ho_fail() invocations
The ho_fail() macro includes a newline, so the callers should not add
one. Fix these cases where the extra '\n' fragments the logged message.

Related: SYS#5839
Change-Id: Ifdbce98be70c1aa127ae008d7a77b9795fd250d3
2022-03-09 07:15:51 +00:00
Neels Hofmeyr 826ec9ff75 inter-BSC incoming HO: store Codec List (MSC Preferred)
So far we completely ignore the codec list from the MSC in Handover
Request messages. This leads to error messages in subsequent handovers
because there is no Codec List stored on the conn:

  DHODEC ERROR handover_decision_2.c:390 [...] No Speech Codec List present, accepting all codecs

Besides the error log, in hodec2 we may subsequently take bogus or
unexpected codec decisions, ignoring the MSC's choice of codecs, or in
the worst case picking an unsupported codec.

This also has implications on what type of lchan we choose for handover
target in hodec2: say, if no half rate codec is supported as per the
MSC's request, we normally avoid handover to a TCH/H, etc.

Intra-BSC HO after an Inter-BSC incoming HO is the only case where this
problem occurs, in every other scenario there is an Assignment Request
from the MSC, from which we properly store the MSC's codec list.

3GPP TS 48.008 does indicate that on AoIP this codec list shall be
included. So reject HO Request with missing Codec List, as we already do
for Assignment Request on AoIP.

This makes TTCN3 BSC_Tests for inter-BSC incoming HO fail, because our
tests so far omit the Codec List (MSC Preferred) on AoIP. The related
fix of the tests is If06de9c9b43d79f749447a4e2a340176eef75c79.

Related: SYS#5839
Depends: If06de9c9b43d79f749447a4e2a340176eef75c79 (osmo-ttcn3-hacks)
Change-Id: I117cc29d6d11db77d160de654f43f5993db6ee21
2022-03-09 07:15:51 +00:00
Neels Hofmeyr 49a4820fc6 tweak error msg: s/inter-BSC MT/inter-BSC incoming
"inter-BSC MT" was the terminology of an early development stage of
inter-BSC handover, code review requested "incoming" instead. This one
was missed when applying code review.

Same in a code comment.

Related: SYS#5864
Change-Id: I1ca810542e89980ffda11876fd30626467e452d1
2022-03-09 00:01:06 +01:00
Neels Hofmeyr 908f014f09 support "empty" SCCP N-Connect from MSC
Teach osmo-bsc to handle empty N-Connect. So far we were always
expecting user data in an SCCP N-Connect from an MSC. However, it is
perfectly valid for an initial BSSMAP request to follow later.

This is relevant for:
- Handover Request (incoming inter-BSC handover)
- Perform Location Request (query physical location of the MS)

Add state WAIT_INITIAL_USER_DATA with new timeout net X25. Always enter
this state so that we don't have two separate code paths for handling
initial user data.

Related: SYS#5864
Change-Id: I535c791fa01e99a2226392eb05f676ba6c3cc16e
2022-03-09 00:01:06 +01:00
Neels Hofmeyr bdead6e87a add counter for inter-BSC incoming Handover Request
Related: SYS#5864
Change-Id: Icdde2bb339a5e367a4d297802214a1ef3f36eefa
2022-03-09 00:01:06 +01:00
Neels Hofmeyr d10d07b6e3 add missing counter increment for Perform Location Request
Also increment message counter for the case that a Perform Location
Request came in the initial SCCP N-Connect message.

Related: SYS#5864
Change-Id: I3f78ce73eb16fdff1f19359963405b2235000fc4
2022-03-08 23:00:21 +00:00
Vadim Yanitskiy 66a46ffa6a Fix description of BTS_CTR_BTS_RSL_FAIL: s/OML/RSL/
Change-Id: Icc3e603b08ab81869955ffa5b16ddfb458e83c78
Related: OS#4848
2022-03-06 20:20:47 +03:00
Neels Hofmeyr 1f089842a8 silence bogus error: event not permitted: READY_TO_SWITCH_RTP
During inter-BSC incoming handover, there is no previous lchan to be
switched, so this event always comes in the READY state of
lchan_rtp_fsm. No need to complain about that and confuse log readers.

Related: SYS#5864
Change-Id: I96fd53b8c8da621a40bd65f85070eabd030cc875
2022-03-03 23:19:46 +00:00
Neels Hofmeyr e761affc6a tweak logl to ERROR for invalid initial BSSMAP
Related: SYS#5864
Change-Id: Idd7d763129a5acdf19cd0ae86e82b77ee0073f2f
2022-03-03 22:22:12 +00:00
Vadim Yanitskiy df58a69bde bitvec2freq_list(): fix handling of E-GSM ARFCNs
According to 3GPP TS 44.018, section 10.5.2.1b.2, only ARFCN values
in range 1..124 can be encoded using the 'bit map 0' format.  Before
this patch, ARFCN values belonging to E-GSM band (0, 975..1023) were
ignored in bitvec2freq_list(), and thus not present in the resulting
Cell Channel Description IE.

Change-Id: I17739e6845cd84e2a81bc406dd532541f7c52cb6
Related: SYS#5854
2022-03-03 09:43:27 +00:00
Vadim Yanitskiy d1cacced51 bitvec2freq_list(): determine empty set by checking the ARFCN count
I find it cleaner to relay on the counter ('arfcns' in this case) to
check if the set is empty, rather than checking one of the resulting
values ('max').  There is just a cosmetic change.

Change-Id: I29ca51461beec053bcb8b8210f0ad24bb8c7765f
Related: SYS#5854
2022-03-03 09:43:27 +00:00
Vadim Yanitskiy 82aebfeacf system_information: fix unused 'mask' parameter in list_arfcn()
The callers of this function do pass different mask values, which
should be passed to gsm48_decode_freq_list().  Instead, 0xce was
passed regardless of the given mask value.

Change-Id: I47f2eab54ef8487b14992fd7a69d5c9ccbb3f5cf
2022-03-03 09:43:27 +00:00
Pau Espin 8f1597135d ipa oml: Fix encoding of T3105
As the comment above the fix suggest, the encoding is in 10ms units.
osmo-bts is also doing the proper:
"""
uint8_t t3105 = *TLVP_VAL(&tp, NM_ATT_BTS_AIR_TIMER);
bts->t3105_ms = t3105 * 10;
"""

Related: SYS#5838
Change-Id: Ie190514ee35d1ca81b70e9180bf7393b973d3504
2022-03-02 17:34:43 +01:00
Neels Hofmeyr 9972978365 inter-BSC HO in: add Codec List (BSS Supported) IE to HO Req Ack
Related: SYS#5839
Depends: Iab0a7b4d81592157fc111d1adb9e9f4cb53a94e9 (libosmocore)
Change-Id: I3c0576505a3ceb3cd5cc31dc69c5bc4a86a4ea08
2022-02-28 11:53:37 +01:00
Neels Hofmeyr c9c90cda71 inter-BSC HO in: add Speech Codec (Chosen) IE to HO Req Ack
Related: SYS#5839
Change-Id: I1d0b395c97145b5aa1af4ef67aec9338d2f8f43b
2022-02-28 11:53:25 +01:00
Neels Hofmeyr 0a704ee857 inter-BSC HO in: add speech IEs only on speech mode lchans
Related: SYS#5839
Change-Id: I830654f419e6f0a196dc6d3e58422e00b324af9e
2022-02-23 16:23:38 +01:00
Neels Hofmeyr ec8c1dd11e cosmetics around select_best_cipher()
Improve the function doc. Remove a comment at a caller, because that
information is what the function doc is for.

Rename the array to codec_by_strength, because it is not the codec
strength but the codec number listed in the array.

Related: SYS#5839
Change-Id: Iaed6b97c31e4ccb1f28ca7e64596d5e20563b392
2022-02-22 11:26:51 +00:00
Neels Hofmeyr 8bacb71c90 fix inter-BSC-in handover encryption
In the field we saw Handover Requests without any Chosen Encryption
Algorithm IE, and osmo-bsc completely failed on those. This made me
understand my mistake from when I wrote this handover code.

So far, from a BSSMAP Handover Request, we (I) used only the Chosen
Encryption Algorithm IE to pick the encryption to use on the target
lchan. That is very wrong.

Instead, figure out the intersection of permitted algorithms MSC & BSC,
and pick the best of those. Which means, actually, completely ignore the
Chosen Encryption Algorithm IE.

In the message, the permitted algorithms are passed as a bitmask. The
current code using gsm0808_dec_encrypt_info() passes this on as an
array. In order to select_best_cipher(), I could convert that array back
to a bitmask. Instead pass the bitmask on from message decoding
alongside the struct gsm0808_encrypt_info in req->ei_as_bitmask.

In handover_end(), change the condition so that we can also pass
HO_RESULT_FAIL_RR_HO_FAIL to emit a Handover Failure.

Related: SYS#5839
Change-Id: Iffedc981b60d309ed2e5decd5efedee07a757b53
2022-02-22 11:26:45 +00:00
Neels Hofmeyr a0fb37906d rename RSL_ENC_ALG_A5 to ALG_A5_NR_TO_RSL, clarify
The naming confused me so that I wrote buggy code again. Hopefully this
clarifies which representations the code paths are using.

In the macro code, highlight the error case of n <= -1 explicitly.

Also add ALG_A5_NR_TO_PERM_ALG_BITS. I need the 1<<n case in an
upcoming patch.

Related: SYS#5839
Change-Id: I7557ae97764bba09c906748a18e9031dfb362611
2022-02-18 13:21:56 +01:00
Pau Espin 3900aae7a3 bts: Add explicit switch case for Cell Id SAI
This patch imposes no logical change in the code on itself, but makes
sure people compiling osmo-bsc uses an old enough libosmocore
implementing Cell Identifier SAI. This is important since adding the SAI
ID (CELL_IDENT_SAI) displaced CELL_IDENT_WHOLE_GLOBAL_PS to a new
number outside of the 3GPP range for cell IDS (4 bits, this way we
garantee we won't have the same problem again).

This means there was an ABI breakage (see Depends below).
As a result, using an osmo-bsc compiled against an older libosmocore
, and then using at runtime against a newer version of libosmocore, will
most probably provoke some RIM features to not work properly, since
libosmocore will handle CGI-PS cell ids sent by osmo-bsc as SAI ones,
and most probably do wrong comparisons when matching (they only match up
to LAI included).

ABI break analysis:
osmo-bsc uses CELL_IDENT_WHOLE_GLOBAL_PS in:
* gsm0808_dec_cell_id_list2() -> this is called on stuff received from the
				 network, so it's actually fine handling it
				correctly as CELL_IDENT_UTRAN_SAI instead
				of CGI_PS.
* gsm0808_cell_id_list_add
	same_cell_id_list_entries
		gsm0808_enc_cell_id_list2
			cell_id_to_cgi-> On old osmo-bsc, When
					 CELL_IDENT_WHOLE_GLOBAL_PS is passed
					 to be encoded as CGI, RAC byte is
					 taken for encoding instead of 2nd CI byte.
* gsm0808_cell_ids_match
	gsm0808_cell_id_u_match
		cell_id_to_cgi -> If CELL_IDENT_WHOLE_GLOBAL_PS as 0x11
				  (CELL_IDENT_UTRAN_SAI), 1 byte offset when
				  comparing (1 byte of RAC is taken converting to
				  CGI instead of the 2nd byte of CI). That means
				  match would be wrong if 2nd byte of CI differs.

Related: SYS#5838
Depends: libosmocore.git Change-Id Id25e563febdb7640174540136225f399515a0089
Change-Id: I70972efffefd57fd36332fab539683696c32f4a5
2022-02-16 18:55:21 +01:00
Philipp Maier 49865023c9 bssmap_reset: make T4 user configurable
The timer (T4) that controls the re-sending of the BSSMAP RESET can not
be changed via the VTY, althrough it is defined via a tdef struct. Lets
add a description along with default values to make it configurable via
the VTY.

Change-Id: I1fb5699220ab8a643a168567a89c6f381fe433a7
Related: SYS#5796
2022-02-08 11:51:42 +01:00
Philipp Maier 99f97ee90f nm_bts_fsm: fix sourcecode formatting
Change-Id: If7db7f5611e0ebf69d66b135515c0a08c6edfb11
2022-01-17 11:29:02 +01:00
Pau Espin 326ee2ea49 Fix DLCI CC bits transmitted in SAPI "n" REJECT
The SAPI "n" REJECT messages were being sent with DLCI keeping the RSL
LINK ID format, which is not the same for CC bits.

With this patch, TTCN3 test BSC_Tests.TC_rll_sapi_n_reject_dlci_cc
passes again.

Related: OS#4728
Related: SYS#5047

Change-Id: Icc187f594743040a3d9b8beff7d9cfc21dd6eb08
2022-01-13 06:08:02 +00:00
Neels Hofmeyr 47d38f9967 gscon clear: without SCCP conn, no need to wait for RLSD timeout
Skip the BSSMAP Clear and SCCP RLSD parts and immediately deallocate the
gscon when there is no SCCP connection present. Before this patch, such
conn would stick around for a minute before a timeout deallocates it.

Related: OS#5337
Change-Id: I8c8537acf6b47b121903197608636c43ae601a57
2022-01-12 22:42:16 +06:00
Neels Hofmeyr 53b23c252e fix gscon clear 3/n: separate state for SCCP RLSD
Properly implement the separate conn release stages in separate FSM
states:

x) sent Clear Request, wait for a Clear Command from the MSC.
   Timeout after a configurable 60s.

y) after a Clear Command and sending a Clear Complete, wait for the SCCP
   RLSD. Timeout after a configurable 60s.

z) terminate after the RLSD is received / after timeout.

handover_test.c needs a little tweak to make the MGCP release work with
its fake MGCP client, because cleanup now ensures to invoke
gscon_forget_mgw_endpoint() in all cases.

Related: I680ec4ed866aa5f0b1ff29e7e98322615cfb288d (osmo-ttcn3-hacks)
Related: OS#5337
Change-Id: Ie975117d37f38ba853589dc7f8d3e94f8f9586b2
2022-01-12 22:41:33 +06:00
Neels Hofmeyr c2dba7c5b9 fix gscon clear 2/n: proper state transition to ST_CLEARING
The way the ST_CLEARING is entered before this patch has various
symptoms of how I / we used osmo_fsm when we were still FSM amateurs in
Osmocom. Patch that up:

- In gscon_bssmap_clear(), ask for a state transition to ST_CLEARING
  first. Go ahead only if it is allowed.

- move the Clear Request messaging to ST_CLEARING's onenter function.

- Fix the timeout behavior: by using conn_fsm_state_chg(), use the
  actual proper X4 timer value for ST_CLEARING from VTY configuration
  instead of hardcoded magic numbers.

Related: OS#5337
Change-Id: I234b2a754d0c98031056981823cdbc187e977741
2022-01-04 13:33:26 +00:00
Neels Hofmeyr c984dc1a86 fix gscon clear 1/n: store clear cause in gscon
Allow returning a context sensitive cause instead of a hardcoded one in
gscon pre_term().

Also, the conn->cause is needed to move message dispatch to an "onenter"
function in patch I234b2a754d0c98031056981823cdbc187e977741. I Split
this part off as a separate patch for better readability.

Related: OS#5337
Change-Id: Ib6432746040899129d1d73ae8dc59add2d88a915
2022-01-04 13:33:26 +00:00
Neels Hofmeyr bd1eac2fb2 lcs: fix bsc_subscr use_count leak
In lcs_ta_req_wait_ta_onenter(), fix use count leak of 'start-paging':
get() the use count only after the early exits.

osmo-ttcn3-hacks patch I69d4c5c6f8d499bb7f0b96a48af045361433c57b
introduces testing against this leak in various LCS tests (e.g.
BSC_Tests.TC_lcs_loc_req_for_active_ms_ta_req).

Related: OS#5355
Change-Id: Ibbfbfe766eafe42c78048ec5b3b503a11ef5535d
2022-01-04 13:33:26 +00:00
Neels Hofmeyr 3b4b7c1efd lchan/gscon: always clear both cross ref pointers
During specific release scenarios, it became clear that an lchan still
pointed at a conn even after it had been deallocated. That was due to
setting conn->lchan = NULL but not lchan->conn = NULL. Fix that.

Do lchan_forget_conn() first, because during gscon_forget_lchan() we may
enter the gscon clearing dance, which in case of no SCCP conn being
present will soon / should immediately deallocate the conn.

Related: OS#5337
Related: I8c8537acf6b47b121903197608636c43ae601a57 (osmo-bsc)
Change-Id: Idbfe4672233ba8105eff5ba77ee07fd871358255
2022-01-04 13:33:26 +00:00
Neels Hofmeyr 9aed5f541f log: always include timeouts in FSM transition logging
Before:
  state_chg to ACTIVE
  state_chg to WAIT_RLL_RTP_RELEASED
  state_chg to WAIT_SCCP_RLSD

After:
  State change to ACTIVE (no timeout)
  State change to WAIT_RLL_RTP_RELEASED (T3109, 5s)
  State change to WAIT_SCCP_RLSD (X4, 60s)

Change-Id: I94b7dc4d9e5e45dc731bcb3a843ede9fb6cc0839
2022-01-04 13:33:26 +00:00
Harald Welte d3b0db5515 om2000: Don't print "should not generate any message" on FAULT_REP
Change-Id: I65184ef5aa90a993491f9393614bb499c6998169
Closes: OS#4643
2022-01-04 13:08:20 +00:00
Harald Welte 9f53838c58 om2000: Don't print "should not generate any message" on CAL_TIME_REQ
Change-Id: Ic6f576250d56707cf325886d70209a3744163d79
Closes: OS#4670
2022-01-04 13:04:22 +00:00
Harald Welte 6e250bbf82 om2000: Fix memory leak in OM2000 message handling
Change-Id: I7a94320f3b3af65003df67c11fe7221dfc7d7d62
2022-01-02 15:15:25 +01:00
Philipp Maier 9b844df27b bts: fix sourcecode formatting (excess whitespace)
Change-Id: Ie4fad0426d1d089156481806a05982a24375b766
2021-12-20 15:29:52 +01:00
Philipp Maier 2544c1058c bts: add missing return -EINVAL statements
The checks that make sure that an ARFCN falls in the correct range do
not return with -EINVAL as they should, instead nothing happens. (Only
the check for GSM1800 is corrct)

Change-Id: Iddadafe3fbc47e2f980d8e4ab4f320998cb454ff
Related: SYS#5369
2021-12-20 15:29:25 +01:00
Oliver Smith 260eb1d256 treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: Ifbbafe185931c0f508ff8148ef244f25a9620fd8
2021-12-14 12:51:44 +00:00
Philipp Maier 3ba9bd7c35 abis_nm: actively block BTSs with invalid configuration
At the moment the BTS configuration is checked, but the check does not
have much consequence other than that some initialization that is not
executed. The BTS will go into the OML bootstrap phase anyway and most
likely fail at some later point due to the invalid configuration. To
reduce noise and unexpected behaviour of the BTS lets make sure that the
OML boostrap phase can only proceed when the BSC conciders the
configuration as valid.

Change-Id: I42c1c26a9b800600787b1266a871f95f2114c26e
Related: SYS#5369
2021-12-13 18:03:12 +01:00
Neels Hofmeyr 67fb8b7c17 fix assignment success counters: count *before* cleanup of fsm state
Counting the Assignment success after osmo_fsm_inst_term() meant that we
were counting a cleared out channel mode, which always yielded
signalling mode.

Count the Assignment success *before* terminating, so that we correctly
count the successful assignment as speech mode.

Related: SYS#4878
Related: Icb1386ec2ccd70eb3c026301b9b08ad7177278f7 (osmo-ttcn3-hacks)
Change-Id: Ie9fcd1e86f27ecb2f11e2e8813faac365cb470b8
2021-11-30 14:19:11 +01:00
Neels Hofmeyr c309754ff9 dbg log: also log assignment counters on BTS level
Change-Id: I68b3e794ddf97c80f647c3536ec466217b338af9
2021-11-30 14:19:07 +01:00
Neels Hofmeyr fdf2262968 fix chreq:* counters: typos in chreq:successful_* constants
Related: SYS#4878
Related: I17a7702b151ac03fd9f7ecd6927ef42133aad953 (osmo-ttcn3-hacks)
Change-Id: I1fde77d5d5920093ab037184eb3518876804353d
2021-11-30 14:19:05 +01:00
Neels Hofmeyr 33e687a97e dbg log: abis_rsl print_meas_rep(): clarify rxlev
Change-Id: Ia2c1d59eac556b8f6a56c39abf12b35a3ba807eb
2021-11-29 15:10:49 +00:00
Oliver Smith 2df65db3da stats: add bsc.paging:expired
Similar to paging:attempted, count paging:expired not only per BTS, but
also for the whole BSC. Add active_paging_requests to struct bsc_subscr,
to increase the counter only once if paging expires, and not once per
BTS where paging expired.

Related: SYS#4878
Change-Id: I9c118e7e3d61ed8c9f1951111255b196905eba4d
2021-11-29 11:33:34 +01:00
Oliver Smith 61e041d92a Cosmetic: osmo-bsc/osmo_bsc_bssap: fix formatting
Change-Id: Icc4947e68fa46aab180f2047231e51b997cca71b
2021-11-29 11:28:10 +01:00
Vadim Yanitskiy cc7bdbe62e ipaccess-config: request and print NM_ATT_IPACC_NV_FLAGS
Below is an example output:

"""
  Received SIGNAL S_NM_GET_ATTR_REP
  {
      "primary_oml_ip": "192.168.100.100",
      "primary_oml_port": "0",
      "unit_id": "6969/0/0",
      "nv_flags": {
          "static-ip": "no",
          "static-gw": "no",
          "no-dhcp-vsi": "no",
          "dhcp-enabled": "yes",
          "led-enabled": "yes",
          "secondary-oml-enabled": "yes",
          "diag-enabled": "yes",
          "cli-enabled": "yes",
          "http-enabled": "no",
          "post-enabled": "yes",
          "snmp-enabled": "yes"
      }
  }
"""

Change-Id: Ic901910878529e6d8b152b3417463bae60644b82
2021-11-27 04:51:09 +03:00
Vadim Yanitskiy d260020aa6 ipaccess-config: improve readability of printed attribute response
Change-Id: If99ec89081af4ebd65152fc0a31ebdec491f3876
2021-11-27 04:34:42 +03:00
Pau Espin 90b689b577 Disable C/I based MS Power Control Loop by default
osmo-trx-uhd with a B200 has proven to provide bad (lower than usually
considered good) C/I values due to high noise (even with band filters in
place). Hence, default thresholds (gathered from literature on the topic)
are too high and end up in bad algorithm output decisions.
Furthermore, most users of Osmocom don't use it in densely populated
areas, hence RXLEV based algorithm used when C/I based one is disabled
is good enough.
Let's disable C/I based one by default, and let advanced users which
specific needs to enable and confiure thresholds specifically for their
needs (hardware, cell surrounding conditions, etc.).

Related: SYS#4917
Change-Id: If1a73c60695379bcfcd0f44c6ec6dd659563e279
2021-11-25 14:50:04 +01:00
Neels Hofmeyr 88f3c05202 hodec2: fix segv for inter-BSC ho target
Related: OS#5324 SYS#5259
Change-Id: I5a3345ab0005a73597f5c27207480912a2f5aae6
2021-11-24 19:22:34 +00:00
Oliver Smith 80afda444e bsc_subscr_conn_fsm: fix crash if !conn
Do not crash in gscon_ensure_mgw_endpoint() if conn is NULL.

Related: SYS#5728
Change-Id: Id579243cc9ebbe8f315cd11754166970329dc9cf
2021-11-24 14:38:10 +01:00
Philipp Maier 72bbdfcd35 abis_nm: use struct sdp_firmware from libosmocore
abis_nm locally declares its own struct for the ipaccess firmware
header, even though libosmocore defines it as well. Lets use the
definition from libosmocore.

Change-Id: I69cb45fc40bd20ea2533cc8cd6a68363b59cc408
2021-11-19 11:43:07 +01:00
Philipp Maier 0505e35cb7 abis_nm: fix typo
Change-Id: I2cb7b986db9d394db2c912247db861704d2c7c23
2021-11-19 11:43:00 +01:00
Neels Hofmeyr d13ef633d2 move time_cc to libosmocore osmo_time_cc
Related: SYS#4878
Depends: Iabb17a08e6e1a86f168cdb008fba05ecd4776bdd (libosmocore)
Change-Id: Ica9f908a1a30f334a24c59471affa11225117e12
2021-11-16 12:06:53 +01:00
Philipp Maier 7f7c83a7de osmo_bsc_main: move generate_ma_for_bts() into bootstrap_bts()
The function generate_ma_for_bts() is called when the OML TEI comes up.
In the same code path boostrap_bts() is called as well. It would be more
logical to call generate_ma_for_bts() from boostrap_bts() since it is
also part of the bootstrapping process.

Change-Id: Ib2ed5b1eac3701cfb3a3e8dd478488ba5404d1fd
Related: SYS#5369
2021-11-15 13:34:15 +01:00
Philipp Maier 4b706fa15d osmo_bsc_main: call bootstrap_bts when OML TEI comes up
At the moment check_bts and bootstrap_bts is called only once on startup.
When a new BTS is set up during runtime bootstrap_bts, nor check_bts is
called. This means that some parameters of the BTS stay uninitalized
until osmo-bsc is restarted. Lets rather call check_bts() and then
bootstrap_bts() when the OML TEI of the BTS comes up.

Change-Id: Ie599f809623efd6ea4ab3f39294195fc1ef84b85
Related: SYS#5369
2021-11-15 13:34:15 +01:00
Vadim Yanitskiy c122c10f34 [overpower] By default, permit only for speech channels using AMR
Change-Id: I087025f9db59348f2f70d4a291f8d887644d6b17
Related: SYS#5319
2021-11-15 11:59:03 +00:00
Vadim Yanitskiy 335361fbeb [overpower] Allow configuring specific channel mode(s)
Change-Id: I34d29d7d0f66c629367f3d6e8a660e199ecbe080
Related: SYS#5319
2021-11-15 11:59:03 +00:00
Vadim Yanitskiy 820b30d8c6 abis_rsl: s/*_acch_cap_for_bts/put_*_acch_cap_ie/g
Change-Id: I663023adb4f2381d4b8debb01786801803b3d741
2021-11-15 11:59:03 +00:00
Vadim Yanitskiy 92442c9309 abis_rsl: {rep,top}_acch_cap_for_bts(): make *lchan const
Change-Id: I3e71bb88db7b1eadff5a73fdb98fe7eee2fc2540
2021-11-15 11:59:03 +00:00
Vadim Yanitskiy f59abedb24 struct gsm_bts: s/temporary_overpower/top_acch_cap/g
Let's have a short and consistent naming for both ACCH repetition
and temporary ACCH overpower structures, like it's done in osmo-bts.

Change-Id: I39b98dcd14219402959646524315d5afea7c08cf
Related: Ib1d51f91139b4c2fe794e37fc8543b2d7a9b9c07
2021-11-15 11:59:03 +00:00
Vadim Yanitskiy c8bd1eeaca struct gsm_bts: s/repeated_acch_policy/rep_acch_cap/g
Let's have a short and consistent naming for both ACCH repetition
and temporary ACCH overpower structures, like it's done in osmo-bts.

Change-Id: Ia12c83ad1af4744ce28ba655ac806784f746e88a
Related: Ib1d51f91139b4c2fe794e37fc8543b2d7a9b9c07
2021-11-15 11:59:03 +00:00
Vadim Yanitskiy e0b9a7fb6c bts_vty: fix tabs-vs-spaces issues in cfg_bts_rep_dl_facch
The linter (executed by Jenkins) complains:

  src/osmo-bsc/bts_vty.c:653: ERROR:CODE_INDENT: code indent should use tabs where possible
  src/osmo-bsc/bts_vty.c:654: ERROR:CODE_INDENT: code indent should use tabs where possible
  src/osmo-bsc/bts_vty.c:656: ERROR:CODE_INDENT: code indent should use tabs where possible
  src/osmo-bsc/bts_vty.c:657: ERROR:CODE_INDENT: code indent should use tabs where possible

and blocks changes, adding V-1 when I am changing the related code.

Change-Id: If3c8c09ddff7cb945425e74344ceb4da989ddffc
2021-11-15 11:59:03 +00:00
Vadim Yanitskiy 508058ee28 abis_rsl: cosmetic: fix coding style rep_acch_cap_for_bts()
The linter (executed by Jenkins) complains:

  src/osmo-bsc/abis_rsl.c:543: ERROR:POINTER_LOCATION: "(foo*)" should be "(foo *)"

and blocks changes, adding V-1 when I am changing the related code.

Change-Id: I0cf00ff898e69734850659e8ba0e2ff023f9b2dd
2021-11-15 11:59:03 +00:00
Vadim Yanitskiy 836947918c abis_rsl: simplify checking if channel mode is AMR
Change-Id: If933ce0fa0a162c4518ddab840f186ebaa1bcff9
2021-11-15 11:59:03 +00:00
Pau Espin c672ed8428 Properly handle dyn TS TCH with vamos after updating subslots_per_pchan
In the case of ts->pchan_from_config=GSM_PCHAN_OSMO_DYN,
ts->max_primary_lchans will be 8 due to SDCCH8 support, and we don't
want to set lchan->vamos.is_secondary=true for lchans at the end of the
array.

Related: OS#5278
Change-Id: If86af5fafe059d5e830c1f6d37034f7325d9a96c
2021-11-15 09:49:41 +00:00
Philipp Maier 9a310f818f osmo_bsc_ctrl: make sure strtok results are checked
The function set_bts_loc does not check the string pointers resturned by
strtok_r. In this particular case this is not a problem because the
function set_bts_lock will only see verfied input. However, lets check
the results anyway to avoid creating false positives in coverity scan.

Change-Id: Ie21c392e0405fc45811c6d55bf5508e9eb6784de
Fixes: CID#240849
2021-11-11 09:00:39 +00:00
Neels Hofmeyr a249babf20 implement bts.N.cm_serv_rej:<cause> rate counters
Related: I0214b27da18af87eca9715ebf7eeeff945e3e12a (osmo-ttcn3-hacks)
Related: SYS#4878
Change-Id: I79b1261e5a281d9797eaaf9c27d90edd8e27c78b
2021-11-10 17:53:44 +00:00
Philipp Maier c5b16956a7 osmo_bsc_main: move inp_sig_cb() below check_bts and bootstrap_bts
In order to be able to call check_bts() and bootstrap_bts() from
inp_sig_cb(), we must move it below bootstrap_bts.

Change-Id: I1a365bc2278368ec1f5c0db3f3e466b124b16e83
Related: SYS#5369
2021-11-10 15:35:09 +01:00
Philipp Maier 1140216a88 osmo_bsc_main: separate checks from bootstrap_bts
The function bootstrap_bts does a few checks before it does the actual
initialization. To make the code more modular, lets split the function
into two functions, check_bts and bootstrap_bts. Also be sure that we
print the BTS number when the check failes.

Change-Id: Id2b26f147d2f35e156e2da8ee58d2bbbb93de4ac
Related: SYS#5369
2021-11-10 14:33:26 +00:00
Philipp Maier c2a10a739b osmo_bsc_main: bootstrap_bts: print errornous ARFCN number
The function bootstrap_bts verifies that the ARFCN number is within the
valid range of the current band. In case of error it prints that the
ARFCN is out of range, but it does not print the BTS number, nor the
ARFCN number.

Change-Id: I432448b4bd5ea1a209838a6c5105cc1e9f7d80ee
2021-11-10 14:32:58 +00:00
Neels Hofmeyr aa09938d2c implement all_allocated:{static_sdcch,static_tch} rate counters
Same as all_allocated:{sdcch,tch}, but already trigger when all
non-dynamic timeslots are allocated.

Related: SYS#4878
Related: Ib3997a827c9cc43d1361bb0cf3bfab9f6d91bf82 (osmo-ttcn3-hacks)
Change-Id: I2fa14531f16d3f07085620f1c50eb839c420da6a
2021-11-10 13:27:43 +00:00
Neels Hofmeyr 41f143827d implement all_allocated:{sdcch,tch} rate counters
Based on allAvailable{SDCCH,TCH}Allocated performance indicators, see
3GPP TS 52.402.

Related: SYS#4878
Related: Ib3997a827c9cc43d1361bb0cf3bfab9f6d91bf82 (osmo-ttcn3-hacks)
Change-Id: I8b06e435a224c8708cd6c67e97ee5413718fc1ed
2021-11-10 13:27:43 +00:00
Neels Hofmeyr e0458c2e00 add time_cc API: cumlative counter for time, reported as rate_ctr
This is a candidate for adding to libosmocore (as osmo_time_cc), but
let's first use this in osmo-bsc to make sure that it works as intended.

I started out expecting to be done with this in half an hour, but I
found out that accumulating elapsed time to an integer counter has a
staggering amount of complexity to it, and a million pitfalls.

The intended use is to report allAvailableSDCCHAllocated and
allAvailableTCHAllocated performance indicators in OsmoBSC. Hopefully
this will also be generally useful elsewhere, to be worth the effort.

Related: SYS#4878
Change-Id: Icdd36f27cb54b2e1b940c9e6404ba9dd3692a310
2021-11-10 13:27:43 +00:00
Neels Hofmeyr e455f0ab02 refactor lchan counting
Add chan_counts_for_trx() and chan_counts_for_bts(). Drop
bts_count_free_ts() and trx_count_free_ts().

Rationale:

The bts_count_free_ts() and trx_count_free_ts() always returned the
number of free lchans, not timeslots. Hence, passing the pchan type as
argument never really matched the semantics.

Especially, when looking for free SDCCH, there is no clear match on a
gsm_phys_chan_config enum value: SDCCH8_SACCH8C, CCCH_SDCCH4,
CCCH_SDCCH4_CBCH, SDCCH8_SACCH8C_CBCH? -- GSM_LCHAN_SDCCH is clear.

==> Rather count free lchans by enum gsm_chan_t.

Counting lchans of distinct types required separate iterations for each
lchan type.

==> Rather compose an array of counts for all types, in one go.

I need to count the amount of free SDCCH lchans in an upcoming patch to
implement the performance indicator allAvailableAllocatedSDCCH (cumulate
time for which no SDCCH are available).

To implement allAvailableAllocated{SDCCH,TCH}, I need a count of both
the used as well as the total lchans for a type: it does not make sense
to flag "all available allocated" if none are ever available.

To properly count dynamic ts, I need the maximum total that can be
possible at any time. And to count currently free lchans, I need the
current total. This may seem counter intuitive, but consider, e.g.:

- Obviously, if a cell has only static TCH/F timeslots, it does not make
  sense to flag that all available TCH/H are occupied, because no TCH/H
  are available ever. Just stating this as contrast to dyn TS.

- If a cell has OSMO_DYN timeslots, I *do* want to flag that all TCH/H
  are occupied when all dyn timeslots are fully occupied.

- If those OSMO_DYN however are all used as TCH/F, the current total of
  TCH/H becomes zero, and it seems like TCH/H should not be considered.

- To count the nr of currently free lchans, I need the currently
  possible total of lchans and the nr of occupied lchans.

So return both a maximum total and a current total of lchans. In above
example, the maximum total shows that there would be TCH/H possible.

BTW, it would be nice to keep a chan_counts array on trx, bts and bsc
level and update as channels are allocated and released, instead of
counting them all over periodically. But it's less error prone this way.

Related: SYS#4878
Change-Id: I2fb48c549186db812b1e9d6b735a92e80f27b8d3
2021-11-10 13:27:43 +00:00
Vadim Yanitskiy 5944ff07a8 gsm_data: use ascending order for interference boundaries
It's more logical to have the boundaries sorted in ascending order:

  * band 1 represents lowest interference levels,
  * band 5 represents highest interference levels.

Change-Id: Ie9bf4bf0c89418685b8ea5096332d22cfba7c521
Related: SYS#5313
2021-11-10 14:45:12 +03:00
Vadim Yanitskiy 16b3b50830 ipaccess-config: warn about unknown flag name
Change-Id: Iab3bae3af9e1cac992b1f8947cda25fcff647992
2021-11-08 18:32:43 +00:00
Vadim Yanitskiy dd4af6ac0b ipaccess-config: fix wrong flag name in ipa_nvflag_strs[]
Change-Id: Idf8e3a9ee6d9a8801d53254c772548586d4a9c60
2021-11-08 18:32:43 +00:00
Vadim Yanitskiy 148e00a991 ipaccess-config: reduce verbosity of the OML logging
Change-Id: Ie52db9236da15da540e14cad56e01c2246b3e82e
2021-11-08 18:32:43 +00:00
Vadim Yanitskiy 3b0858f36b abis_rsl: permit simultaneous ACCH repetition and overpower
As stated in "GSM/EDGE Evolution and Performance", section 12.3,
both features *can* be enabled simultaneously.

Change-Id: I2189f01bd78625dab3d642597240338ee581fc98
Related: SYS#5319
2021-11-08 18:30:06 +00:00
Vadim Yanitskiy 447ca13616 abis_rsl: print_meas_rep_{buf,uni}() accept const *mr
Change-Id: I5c3e27a00cd84f102558499072965ec538f5a87f
2021-11-07 21:28:18 +03:00
Vadim Yanitskiy 70ab41e9cd abis_rsl: do not pass lchan to print_meas_rep_buf()
Change-Id: If965c7dc6b989ee758ddec0190ec1cce8363b240
2021-11-07 21:28:18 +03:00
Neels Hofmeyr d5a6dca2f9 implement incoming_intra_bsc_ho:* rate counters
We have lots of counters for intra-BSC handover *away from* a given BTS,
but still missing are counters indicating how many handovers *targeted*
a given BTS. Also count incoming HO.

Related: SYS#4878
Related: Iba229313d73fa20266f6d4eac5820579fb14c604 (osmo-ttcn3-hacks)
Change-Id: Id9f2c6e2865ebe680879018fff08d283ce24c983
2021-11-06 17:02:38 +01:00
Neels Hofmeyr a521a3fa39 tweak intra-bsc ho counter descriptions
Related: SYS#4878
Change-Id: I00eaf42fcd705cf3f4e06e8c7434fd05dbad4b84
2021-11-06 17:02:38 +01:00
Neels Hofmeyr 1d63b925f4 cosmetic tweaks on handover counting code
I was a bit confused that grep did not find HO counters being used, so
let's add some comments to better explain and provide a grep hook.

Related: SYS#4878
Change-Id: I242de13e657286e09428a8ca6e583d8b5155faa2
2021-11-06 17:02:37 +01:00
Neels Hofmeyr 8700803fa8 for linter: s/while(0)/while (0)
Change-Id: Ib422e7d1a7d543dcd8738581839ce55bb8fc29d2
2021-11-06 17:01:58 +01:00
Neels Hofmeyr 0887442c20 drop unused gsm48_tx_mm_serv_ack()
Related: SYS#4878
Change-Id: Ia9d841a8243adca347e7ea79d31e3cd65eab27ea
2021-11-05 12:01:27 +01:00
Neels Hofmeyr 96887554f9 add chreq:successful_<reason> rate counters
Related: SYS#4878
Change-Id: I32c2c197a6199617a82986480b686c515fa40d62
2021-11-05 12:01:27 +01:00
Pau Espin 5dbed8160f lchan_fsm: Fix possible NULL ptr dereference in _lchan_on_mode_modify_failure()
_lchan_on_activation_failure(), which calls lchan_on_mode_modify_failure(),
already checks for !for_conn in other paths. Hence, it can be that
for_conn being passed to _lchan_on_mode_modify_failure() may be null.

"""
 Stack trace of thread 7077:
 #0  0x000055d25a463842 _lchan_on_mode_modify_failure (osmo-bsc)
 #1  0x000055d25a46b57c _lchan_on_activation_failure (osmo-bsc)
 #2  0x00007fe8b2083be4 state_chg (libosmocore.so.17)
 #3  0x00007fe8b208409d _osmo_fsm_inst_state_chg (libosmocore.so.17)
 #4  0x000055d25a46825a lchan_fsm_wait_rll_rtp_establish (osmo-bsc)
 #5  0x00007fe8b2084239 _osmo_fsm_inst_dispatch (libosmocore.so.17)
 #6  0x00007fe8b2083be4 state_chg (libosmocore.so.17)
 #7  0x00007fe8b208409d _osmo_fsm_inst_state_chg (libosmocore.so.17)
 #8  0x000055d25a46dbdc lchan_rtp_fsm_wait_ipacc_mdcx_ack (osmo-bsc)
 #9  0x00007fe8b2084239 _osmo_fsm_inst_dispatch (libosmocore.so.17)
 #10 0x000055d25a411d69 abis_rsl_rx_ipacc_mdcx_ack (osmo-bsc)
"""

Related: SYS#5698
Change-Id: If8b2895feef6e30f9c1db97394dd16d892b277f2
2021-11-05 10:26:39 +00:00
Pau Espin 93d84380e9 assignment_fsm: Log modified lchan in assignment_fsm_allstate_action()
Change-Id: I579c265e9d18402ce806e4d0ea836042185dedaa
2021-11-05 10:26:39 +00:00
Vadim Yanitskiy 140aa51ea1 rsl_tx_chan_activ(): fix manual channel activation for nanoBTS
nanoBTS would NACK a CHANnel ACTIVation message for an 'intra cell
channel change' if it does not contain the Timing Advance IE.  And
this is right, because according to 3GPP TS 48.058, section 8.4.1,
point '4)', it *must* be included.

Indeed, the actual Timing Advance value is not known during the
manual channel activation triggered from the VTY interface.  So
let's merely indicate 0 if it's not known.

Change-Id: Iee7ddb4cf1a9a7bb9b34e6c9f6f9899da480fbd0
2021-11-05 01:58:45 +03:00
Vadim Yanitskiy e74269bbe2 lchan_fsm: cosmetic: move a 'case' below the 'default' branch
It's unusual to have 'case' statements below the 'default' statement.

Change-Id: I523a6d55d9a103ba69351d9dc6d0c000a422a765
2021-11-05 01:25:00 +03:00
Oliver Smith ed10dc446d bsc_ctrl_commands: fix uninitialized value (mode)
Fixes: CID#240848
Change-Id: I571055b350d343318ef1ae469ae92475925d1910
2021-11-04 09:51:26 +01:00
Philipp Maier 3ca2ae1d0a bsc_ctrl_commands: change neighbor-list mode/arfcn via control interface
It is possible to change the neighbor-list mode via the VTY from
automatic mode to manual neighbor-list configuration. In the manual
mode, the user can add ARFCN values manually. This command can be found
under the bts node. Lets add pendant of this command on the control
interface as well.

Change-Id: Id97bc0d31a358db6221c385761773fb48670c921
Related: SYS#5641
2021-11-03 17:25:28 +00:00
Philipp Maier 085a92584f heighbor_ident: add/del neighbor cells via ctrl interface
The VTY allows flexible control over the neighbor cell information via
the neighbor command, which can be found in the configure terminal under
the bts node. Lets add pendant of this command on the control interface
as well.

Change-Id: I343a40e18fa9b91e6c381912c0426a002841e079
Related: SYS#5641
2021-11-03 17:25:28 +00:00
Philipp Maier fdcd49b081 neighbor_ident: add comment about Neighbor Address Resolution Service
The Neighbor Address Resolution Service is using the control interface
API as well. Lets add a comment to indicate that this service is not
related to the normal control interface.

Change-Id: Iec86f72548bfc54a2c86dadec69dd1c64813d852
2021-11-01 11:30:03 +01:00
Philipp Maier 298f6bff86 bsc_subscr_conn_fsm: fix mgw-pool ref counting
When the gsm_subscr_conn_fsm (GSCO) terminates abormally it might not go
through the forget-mgw-endpoint mechanism. It might be terminated
forcefully, which means only the pre_term callback runs. The pre_term
callback clears the endpoint, but it does not put the mgcp_client
reference back into the pool. This results into a wrong ref-count in the
mgw-pool.

Change-Id: I5a7ce6a1880a1060df74d03dd4eb38b51fd85c69
Related: SYS#5675
2021-10-29 05:48:43 +00:00
Philipp Maier 2537ddd23c osmo_bsc_main: remove unused option -t --testmode
The option -t --testmode is defined, but not evaluated. It seems that
the code of this option was removed long ago. Lets remove it now.

Change-Id: Ie11173f5a7aab568b9a25102ad7dcf37fd49f318
2021-10-28 12:10:38 +02:00
Pau Espin 7be36cfde6 Set subslots_per_pchan_vamos[GSM_PCHAN_OSMO_DYN] = 0
VAMOS secondary lchans are to be used specifically when the osmocom dyn
TS is set to pchan_is=TCH_{F,H}. Setting secondary subslots for
OSMO_DYN TS is not needed since it's only used to initialize the TS, and
OSMO DYN already initializes 8 subslots
(subslots_per_pchan[GSM_PCHAN_OSMO_DYN]=8). Otherwise, ts_setup_lchans()
will try to initialize 8+2 lchans on the TS, which is more than needed
and will access out of bounds in the array.

Related: OS#5278
Change-Id: I8727d5b446179c0ebcd8738507efe5a50afaf1e2
2021-10-25 19:17:51 +02:00
Pau Espin f147b5f617 timeslot_fsm: Add assert to make sure we never go out of bounds in ts->lchan array
Related: OS#5278
Change-Id: I23a5349838e0c540fbb54cad10f2af42268d7729
2021-10-25 19:17:40 +02:00
Pau Espin 410a1be79e Set subslots_per_pchan[GSM_PCHAN_OSMO_DYN] = 8
Since a while ago, osmocom types dynamic TS supports being configured as
SDCCH8, hence the maximum subslots is 8. This fixes issue where only up
to 2 subslots where being used on those TS.

Related: OS#5278
Related: SYS#5309
Fixes: 52b9912ef9
Change-Id: I50e6530284ef49cfd77d1944d4a183c5df345820
2021-10-25 13:43:48 +02:00
Vadim Yanitskiy b599a8baac [overpower] VTY: add more ACCH overpower related parameters
The new fields in 'struct abis_rsl_osmo_temp_ovp_acch_cap' allow:

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

Change-Id: Ia2e01e11d718ea0ba2a7e49ae2b871d57991f31c
Depends: Ia28293a12de0af71f55e701fb65c46e905dae217
Related: SYS#5319
2021-10-24 13:55:51 +03:00
Vadim Yanitskiy 014f6232d5 [overpower] VTY: fix copy-pasted warning message
Change-Id: Ie0bc0b503c7c7e893b5c94597c84c47fa881874d
Related: SYS#5319
2021-10-21 18:12:04 +00:00
Vadim Yanitskiy 63cc810acc [overpower] VTY: cosmetic: fix lower case in command description
Change-Id: Iadce870b599b4af4269b9026bd8fbe746f1f4979
Related: SYS#5319
2021-10-21 18:12:04 +00:00
Philipp Maier 72c735603e osmo_bsc_main: remove not longer needed fixme note
It is not possible to operate a cell that has secondary TRXs in
different bands. Especially considering that DCS1800 and PCS1900 have
overlapping ARFCN numbers it would be hard for the MS to tell to which
band it should switch. Also the ImmAss. message only contains the ARFCN
number. It is impractical to have TRXs in different bands and probably
this also violates the sepec.

Change-Id: Icc2af9e2a9bca3897dbbb34d7b2c0fe6f843bedd
2021-10-13 11:47:05 +02:00
Philipp Maier d24d34aff0 bts: set ncc_permitted from bts_alloc
The value ncc_permitted is preset in osmo_bsc_main.c from
bootstrap_bts(). It is a constant value that also cannot be changed via
the VTY. Therefore it should be set from bts_alloc(). This also fixes
the problem that when the BTS is added at runtime from the VTY. BTSs
added at runtime would have an all zero ncc_permitted until the next
restart of osmo_bsc.

Change-Id: I9f02277d7b4b4bcb383e749435416a0b22efd5e8
Related: SYS#5369
2021-10-13 11:47:01 +02:00