Commit Graph

62 Commits

Author SHA1 Message Date
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
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 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
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
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
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
Neels Hofmeyr 8700803fa8 for linter: s/while(0)/while (0)
Change-Id: Ib422e7d1a7d543dcd8738581839ce55bb8fc29d2
2021-11-06 17:01:58 +01:00
Neels Hofmeyr be32e93513 hodec2: add low-rxqual-assignment penalty timer (2/2)
Hold off re-assignment after an intra-cell re-assignment due to low
rxqual.

Adjust test_amr_tch_h_to_f_rxqual.ho_vty to show the changed behaviour.

Related: SYS#5198
Change-Id: Id00a07313fe04eec509b336c0637b59c707760e0
2021-07-15 09:28:18 +00:00
Neels Hofmeyr 71526043ea ensure trigger_ho() returns zero only when HO or AS was indeed triggered
In an upcoming patch, handover_decision_2.c will use this indicator to
decide whether to start a penalty timer:
"hodec2: add low-rxqual-assignment penalty timer (2/2)"
Id00a07313fe04eec509b336c0637b59c707760e0

Related: SYS#5198
Change-Id: I5de385e0666f716184a62e6e70d656545ac5d2ee
2021-07-15 09:28:18 +00:00
Neels Hofmeyr 9d4865ecae hodec2: [2/2] implement automatic choice between FULL and SUBSET measurements
Add TDMA_MEAS_SET_AUTO to indicate automatic choice between FULL and
SUBSET measurements depending on DTX. So far use only in hodec2.

TDMA_MEAS_SET_AUTO looks at each individual measurement report's DTX
flag and for each report chooses FULL if DTX is not used, or SUB if DTX
is used.

The default setting for 'handover2 tdma-measurement' is still 'subset'.
To use the automatic choice, users need configure
  handover2 tdma-measurement auto

Change-Id: I67dce55ccf892c8679272ee5dfedc25620f0f725
2021-07-09 11:51:40 +00:00
Neels Hofmeyr 7225fe4902 hodec2: [1/2] implement automatic choice between FULL and SUBSET measurements
Cosmetic preparation for enabling automatic choice between FULL and
SUBSET measurements depending on DTX in handover decision 2.

Change the internal API to pass separate enums for the choices {RXLEV,
RXQUAL}, {UL, DL} and {FULL, SUB}.

Change-Id: I283e03126a6bc1f5f1b35f9801e841053edd2947
2021-07-09 11:51:40 +00:00
Pau Espin cc75145131 Rename osmo dyn ts enums to contain SDCCH8
They will gain support to be activated as SDCCH/8 soon too.

Related: OS#5309
Depends: libosmocore.git I56dcfe4d17899630b17f80145c3ced72f1e91e68
Change-Id: Id5b89fe589a52ff88486435ac43809edb4b80f98
2021-07-06 07:16:15 +00:00
Neels Hofmeyr c44a27c672 hodec2: fix low rxqual tch/h<->tch/f oscillation
Related: SYS#5198
Change-Id: I96cd5a494e661ba3bb0b6d22d25a9968d2a6813c
2021-06-29 22:24:24 +02:00
Neels Hofmeyr 4011c54620 handover_decision_2.c: add current_rxqual()
Pre-empt code dup: this will be also used by an upcoming patch, so first
put it in a function.

Change-Id: I0d5bdaa9605f2bd4241cdd47ccf1ce1c697818a8
2021-06-29 22:24:24 +02:00
Neels Hofmeyr 4cff729353 hodec2: fix low rxlev tch/h<->tch/f oscillation
Related: SYS#5365
Change-Id: Ibc3ac7ce6190b4e854fa42d5376a7038ddfbd6e5
2021-06-29 22:24:24 +02:00
Neels Hofmeyr 26ce6b3aa4 handover_decision_2.c: add is_low_rxlev()
Remove code dup. Also this will be used another time by an upcoming
patch.

Change-Id: I4aaeb8bc35a142962ac8ca6401a76b0733f7979e
2021-06-29 22:24:24 +02:00
Neels Hofmeyr 56c91b09b1 hodec2: don't apply AFS bias to same-cell lchans
The AFS bias actually should not apply to local cell lchans, because it
makes no sense for intra-cell considerations:

- same-cell lchans obviously have identical rxlev;
- any nonzero AFS bias thus always raises the TCH/F above the TCH/H;
- for intra-cell reassignment, the power budget hysteresis is,
  naturally, not applied.

So, before this patch, setting AFS bias even to only 1 would
unconditionally move all (AMR) TCH/H lchans over to free TCH/F lchans in
the same cell.

Recent patch Id40d1cf8b58410c7d4eb87407fe8b8106e352438 implements
explicit upgrade from TCH/H to TCH/F *if* the TCH/H is experiencing low
rxqual or low rxlev, as a proper replacement for intra-cell AFS bias.

Related: SYS#5198 SYS#5365
Change-Id: I315f24123ae016887ab91666870ce252e096f90f
2021-06-18 09:40:27 +00:00
Neels Hofmeyr a32431972d hodec2: implement upgrade TCH/H -> TCH/F (without AFS bias)
Pass flag into find_alternative_lchan() indicating that a TCH/H channel
has low ratings (rxqual or rxlev, doesn't matter).

Heed this flag in the last round, the requirement A check, and allow
candidates that have equal rxlev, if they result in an upgrade from
TCH/H to TCH/F. This allows intra-cell upgrades to TCH/F.

An important point is that this patch allows upgrade to TCH/F *without*
the AFS bias setting. See also I315f24123ae016887ab91666870ce252e096f90f.

Related: SYS#5198 SYS#5365
Change-Id: Id40d1cf8b58410c7d4eb87407fe8b8106e352438
2021-06-13 15:55:03 +00:00
Neels Hofmeyr 9da036fe6e hodec2: fix is_upgrade_to_tchf() for requirement A
Add missing REQUIREMENT_A_TCHF to form a full REQUIREMENT_TCHF_MASK.
That allows detecting TCH/F -> TCH/H upgrades also in the requirement A
flags, where we look for any viable lchan.

Prepares for upcoming patch Id40d1cf8b58410c7d4eb87407fe8b8106e352438
which implements TCH/H to TCH/F upgrades within the same cell.

Related: SYS#5198 SYS#5365
Change-Id: Ic44615b314782423bab0ceef5810311776f92754
2021-06-08 03:02:01 +02:00
Neels Hofmeyr 9f913bec2c cosmetic prep: hodec2: move is_upgrade_to_tchf() further up
Preparation for Id40d1cf8b58410c7d4eb87407fe8b8106e352438

Related: SYS#5198 SYS#5365
Change-Id: I3fd0e257e033c573017ce62e3efc19b094acf73c
2021-06-08 03:01:58 +02:00
Neels Hofmeyr e24da2ef95 ensure chan_mode comparisons in non-VAMOS mode
Both VAMOS- and non-VAMOS speech modes should result in indentical voice
handling. So make sure that all chan_modes are converted to non-vamos
before comparing / evaluating in switch statements.

Change-Id: I791e7966b1f8eaa3299a8a46abeb313cf5136e0b
2021-05-31 05:20:03 +00:00
Neels Hofmeyr 27c07690d9 replace ts_*_for_each_lchan() with ts_for_n_lchans()
So far we have a couple of macros iterating a specific number of lchans,
depending on dynamic timeslot state etc. With addition of VAMOS lchans,
this would become more complex and bloated.

Instead of separate iteration macros for each situation, only have one
that takes a number of lchans as argument. That allows to more clearly
pick the number of lchans, especially for non-trivial VAMOS scenarios.

Related: SYS#5315 OS#4940
Change-Id: Ib2c6baf73a81ba371143ba5adc912aef6f79238d
2021-05-31 05:20:03 +00:00
Neels Hofmeyr 69def1f97e hodec 2: do intra-cell congestion resolution by Assignment
So far we do all channel reassignments by Handover Command. Since
osmo-bsc now supports rassignment of ongoing voice calls, do intra-cell
congestion resolution by Assignment Command.

In effect, add support for expecting an Assignment Command in
handover_test, and expect assignments instead of handovers for
intra-cell congestion resolution test cases.

Related: SYS#5330 OS#3277
Change-Id: Id56a890106b93fcee67ac9401b890e7b63bba421
2021-05-28 17:22:59 +00:00
Neels Hofmeyr 0951d75665 make sure channel mode and s15_s0 are updated only after an ACK
I noticed during testing that an lchan used as TCH/F in fact still had
its channel mode set to Signalling -- because on Assignment, the Speech
mode used to be placed in the *previous* lchan and the new lchan was
never updated after the Activ ACK. This is unbearable confusion which I
complained about numerous times, so far mostly for cosmetic reasons. But
implementing re-assignment properly actually requires this to be cleaned
up.

Keep all volatile chan mode settings in lchan->activate.* or
lchan->modify.*, and only update lchan->* members when an ACK has been
received for those settings. So a failed request keeps a sane state.

Make sure that those settings are in fact updated in the proper lchan,
upon an ACK, so that subsequent re-assignment or mode-modify know the
accurate lchan state.

Related are upcoming patches that sort out the AMR multirate
configuration in a similar fashion, see
Iebac2dc26412d877e5364f90d6f2ed7a7952351e
Ia7519d2fa9e7f0b61b222d27d077bde4660c40b9
Ie57f9d0e3912632903d9740291225bfd1634ed47.

Related: SYS#5315 OS#4940 OS#3787 OS#3833
Change-Id: Ie0da36124d73efc28a8809b63d7c96e2167fc412
2021-05-27 17:06:21 +02:00
Neels Hofmeyr d514f639fc hodec2: remove code dup of rxlev averaging
Change-Id: Ic49b94ea243898535c82018c14df8a3ba216ea83
2021-05-26 22:01:46 +02:00
Neels Hofmeyr 764449ec2e fix/refactor neighbor config
The neighbor configuration storage is fundamentally broken: it requires
all local cells to be configured before being able to list them as
neighbors of each other. Upon config write-back, the neighbor config
however is placed back inline with the other config, and hence a
written-out neighbor config no longer works on program restart.

The cause of this problem is that the config is stored as explicit
pointers between local cells (struct gsm_bts), which of course requires
the pointer to exist before being able to reference it.

Instead, store the actual configuration that the user entered as-is,
without pointers or references to objects that need to be ready. Resolve
the neighbors every time a neighbor is needed.

Hence the user may enter any config at any place in the config file,
even non-working config (like a BTS number that doesn't exist), and the
relation to actual local or remote neighbor cells is made at runtime.

Abort program startup if the initial neighbor configuration contains
errors.

Related: OS#5018
Change-Id: I9ed992f8bfff888b3933733c0576f92d50f2625b
2021-03-24 21:22:21 +01:00
Neels Hofmeyr d88f9a5384 refactor handover penalty timers
So far the list of penalty timers was stored for an opaque target
pointer. That was either a gsm_bts pointer for a local BTS, or a cell
identifier list pointer for a remote-BSS cell.

Reasons to refactor penalty timers:

- The cell identifier list pointer came from the neighbor configuration
  storage, but the way cell neighbor config is stored will change in a
  subsequent patch. There will be no more cell identifier lists there.

- Storing object pointers is inherently unsafe -- if an object gets
  removed and another gets allocated, the penalty timer could
  theoretically remain in force for an unrelated object.

Rather store penalty timers for specific Cell IDs. Since remote-BSS
neighbors can be requested by a cell identifier *list*, use a
gsm0808_cell_id_list2 as key in the list of penalty timers.

Fix handover_test.c: have different CI for each local BTS. So far it was
the same LAC+CI for all BTSes, which now would make the test fail,
because any penalty timer would appear to apply to all local cells.

Related: OS#5018
Change-Id: I72dd6226a6d69c3f653a3174c6f55bf4eecc6885
2021-03-24 10:02:29 +01:00
Neels Hofmeyr 980a28fdcb rename lchan->rqd_ta to last_ta
Originally, the lchan stored only the Timing Advance from the initial
channel request, hence it was called rqd_ta.

Since quite a while now, rqd_ta also stores the most recent Timing
Advance from each received Measurement Report. So rename to last_ta.

This is cosmetic preparation for an upcoming patch that clarifies
whether the Timing Advance is already known for Channel Activation.

Change-Id: I1049526a173819baeb4978db5bf018ba3f1006a0
2021-02-05 20:24:43 +01:00
Neels Hofmeyr b4364a4adc hodec2: fix intra-cell congestion balancing with source lchan on dyn TS
Related: SYS#5301
Change-Id: I332477cbddf32cf6f057007b45cda8477227f0b1
2021-02-02 21:53:53 +01:00
Neels Hofmeyr f7e25a1010 hodec2: fix congestion balancing on dyn TS
When balancing congestion, not only look at TCH/F or TCH/H separately,
but also to take into account the effects on the other TCH kind from
using/freeing dynamic TS.

Related: OS#5298
Change-Id: I433df6f343650f9056b1bab926bc19ac1d867ad5
2021-01-19 11:49:07 +01:00
Neels Hofmeyr 2eeef70310 lchan_avail(): omit logging for handover decision 2
Add bool log argument to lchan_avail_by_type() and omit logging when
passed as false. From handover_decision_2.c, pass 'log' as false, from
all other callers pass true, i.e. for unchanged behavior.

Rationale:

Usually, we use lchan_avail_by_type() to select a new lchan to initiate
actual service. For that, it is interesting to see how osmo-bsc decides
which lchan will be used.

For handover decision 2, we since recently call lchan_avail_by_type()
for each and every handover candidate, to determine whether it will
occupy a dynamic timeslot or not (to know whether we would congest the
other TCH kind). So this happens for each permutation of source lchan
and target cell. That produces a lot of logging, out of proportion of
being useful to the maintainer.

Change-Id: Ia403f8fc853ca9ea9e81f7a7395df6b23845ebed
2021-01-19 11:49:07 +01:00
Neels Hofmeyr 3025e69814 hodec2: fix congestion resolution on dyn TS
For handover algorithm 2, properly figure out what effects the target
cell will see for the *other* TCH kind when a handover would occupy a
dynamic timeslot.

Before this, only TCH/F or TCH/H would be regarded at a time. This
introduces detection of whether a dynamic timeslot would be occupied by
a handover, and how losing one unused dynamic timeslot affects the
congestion situation for the TCH kind that is not targeted by the
handover.

In other words, if a handover to TCH/F causes congestion in TCH/H
because of a dynamic timeslot becoming occupied, the handover will not
be performed. Before this, oscillation situations could occur.

A subsequent patch will do the same for congestion balancing.

Related: SYS#5297
Change-Id: I1536b60f03cb0aeb6ba14a72b518aec82fa572fe
2021-01-19 11:49:07 +01:00
Neels Hofmeyr 8e830dd136 hodec2: to balance congestion, use overload percent
For balancing load across congested cells and across congested TCH/*
kinds, instead of comparing the number of lchans above the configured
congestion threshold, compare the percent of lchans of overload.

In short, using a percentage prevents cells with less min-free-slots to
fill up 100% while neighbor cells still may have several free lchans
available.

An obvious example of why this is desirable is illustrated by
test_balance_congestion_by_percentage.ho_vty:

Cell A has min-free-slots 2, and has all slots occupied.
Cell B has min-free-slots 4, and has 2 slots remaining free.

If we count congested lchans as in current master: cell A has a
congestion count of 2: two more lchans in use than "allowed". If we move
one lchan over to cell B, it ends up with a congestion count of 3, which
is worse than 2. So when counting lchans, we decide that cell A should
remain full.

Instead, when comparing percentage of remaining lchans, we would see
that cell A is loaded 100% above congestion (2 of 2 remaining lchans in
use), but when moving one lchan to cell B, that would only be 75% loaded
above its treshold (3 of 4 remaining lchans in use). So a percentage
comparison would cause a handover to cell B.

Related: SYS#5259
Change-Id: I55234c6c99eb02ceee52be0d7388bea14304930f
2021-01-14 06:24:57 +00:00
Neels Hofmeyr 0096f27b61 hodec2: fix congestion oscillation bug
When evenly distributing congestion across cells, count the number of
occupied lchans surpassing congestion, and not the overall number of
free lchans -- which disregards congestion thresholds.

Fix the bugs shown by
 test_congestion_no_oscillation.ho_vty
 test_balance_congestion_tchf_tchh.ho_vty

This implements a simple calculation for congestion load by counting
lchans in use above congestion. An improvement of this calculation
using percent follows in I55234c6c99eb02ceee52be0d7388bea14304930f.

Related: SYS#5259
Change-Id: Icb373dc6bfc9819446db5e96f71921781fe2026d
2021-01-12 09:36:12 +01:00
Neels Hofmeyr d946e5b280 hodec2: add ho_candidate.{current,target}.free_tch
Store the number of free lchans and the min-free-slots settings in
ho_candidate, instead of figuring those out in various places, to make
it easier to read.

Prepare for upcoming patch which also requires these values to fix a
bug.

Change-Id: Ie6ca5af5e8d0ebb8deaaaa637e2728008ecba517
2021-01-12 08:30:15 +00:00
Neels Hofmeyr 1dc9a7f53d hodec2: reduce check_requirements() args
Instead of passing single args, pass the ho_candidate struct.

No functional change.

Change-Id: I086aef9cc47ad8a5376f18179024c486f6f8b779
2021-01-12 08:30:15 +00:00
Neels Hofmeyr d4f8a8bca1 hodec2: cosmetic: clarify ho_candidate.{current,target}
So far it is often confusing which cell a specific member refers to.
Clarify lchan, bts, ... to current.lchan, target.bts, ...

Also move the rxlev_{current,target} to {current,target}.rxlev.

Eliminate numerous local variables to make it easier to read which side
is being used (e.g. "c->target.bts" instead of just "bts").

No functional change.

Change-Id: I06898eb745a5be548df0b76fa760ce790cfab3ed
2021-01-12 08:30:15 +00:00
Neels Hofmeyr 3f1c43e74b hodec2: fix candidate choices in congestion check
Fix flaws in picking a candidate for congestion resolution, shown in
recently added tests.

- For TCH/H->TCH/F upgrading, do not favor moving to a weaker neighbor
  cell.

- When comparing dynamic timeslots on the same cell, favor a dynamic
  timeslot that frees an entire dyn TS even though the target rxlev
  differs.

Do not separate the passes for inter-cell and intra-cell candidates:
before, the inter-cell pass would already pick a candidate and start
handover, even though the subsequent intra-cell pass would have revealed
a better candidate. Join the intra-cell considerations into
pick_better_lchan_to_move().

The intra-cell pass was separate, because it would find the *weakest*
current rxlev, to give a TCH/H to TCH/F upgrade to the currently weakest
lchan.

Instead of the separate pass for weakest rxlev, in addition to the
target cell's rxlev, also consider the rxlev *change* in
pick_better_lchan_to_move(): For candidates that do not change the rxlev
(usually those that stay in the same cell) and that upgrade to TCH/F,
favor a candidate with weaker current rxlev.

Completely revisit the conditions in pick_better_lchan_to_move() to
yield the desired prioritization of candidate preferences.

In three handover tests, remove the "FAIL" comments and adjust to now
expect the actually desired behavior.

Related: SYS#5032
Change-Id: I2704899c85c35dfd4eba43468452483f40016ca2
2021-01-11 14:35:34 +00:00
Neels Hofmeyr 305f21f9dc hodec2: cosmetic: clarify afs_bias, simplify pick_better_lchan_to_move()
Instead of passing the TCH/H -> TCH/F bias (AFS bias) in local
variables, rather store it in the ho_candidate struct next to the other
rxlev related values.

Add the AFS bias to the compared rxlev in pick_better_lchan_to_move().

Modify pick_better_lchan_to_move() to simpler semantics of returning
either a or b.

No functional change.

Change-Id: I73860abdf2a77270ca4851ad58c09767d1bb08f1
2021-01-05 23:27:26 +01:00
Neels Hofmeyr 0c01ab6cbb hodec2: clarify current and target rxlev per candidate
Store the rxlev of the current lchan and the target BTS in the
ho_candidate, to clarify the code.

No functional change, cosmetically prepare for
I2704899c85c35dfd4eba43468452483f40016ca2.

Change-Id: Ie6c165e17bb3c99eebc967a6bb02529db8bdfc98
2021-01-05 23:27:26 +01:00
Neels Hofmeyr d15d672427 hodec2: code dup / cosmetics
In handover_decision_2.c, instead of repeating a similar loop four
times, put that loop in a function and parameterize it.

Prepare for a fix of two problems in handover decision 2, see
I2704899c85c35dfd4eba43468452483f40016ca2.

Change-Id: I7c32d08e490a88a7f044b0a71dc4b07d748dd572
2021-01-05 23:27:26 +01:00
Neels Hofmeyr 23da99ddda hodec2: cosmetic: add dBm unit to rxval logging
Change-Id: I58a5ae721b674576339360b1f03e91b015a1bf46
2021-01-05 23:27:26 +01:00
Neels Hofmeyr ef65d3ddb4 hodec 2: prefer moving TCH/H from half-used dyn TS
Change-Id: I427dc9faa3790c24119127ae227d8cc802dd50e6
2020-12-09 11:35:16 +00:00
Neels Hofmeyr dc69da17ad hodec 2: favor moving dyn TS
When a used timeslot gets moved to another timeslot for load balancing, prefer
moving a dynamic timeslot, as illustrated by handover_test.c test 30.

Rationale: freeing up a dynamic timeslot is better for PDCH availability, as
well as for flexibility in timeslots. Test 30 shows that when freeing a static
TCH/F even though a dynamic one with identical ratings is in use, later
handovers to a TCH/H may become impossible, because no more dynamic timeslots
are available to switch to TCH/H. A freed dynamic timeslot allows congestion
resolution to continue and reduce more TCH/F to TCH/H.

The scope of this preference is per-TRX, where the RXLEV ratings used for
picking a target lchan are the same by definition. In other words, this never
overrules picking another lchan that has better RXLEV.

Among lchans on dynamic timeslots that could be moved, this code favors moving
later lchans; mainly because it makes for a simpler condition in the code.

Change-Id: Ic221b8d2687cdec0bf94410c84a4da43853f0900
2020-11-18 14:50:25 +01:00
Neels Hofmeyr 829db22eeb hodec 2: prep: common pick_better_lchan_to_move() function
There are four places deciding which of 2 lchans to move, depending on average
db ratings. Upcoming patches will enrich that decision for better handling of
dynamic timeslots, so have one common function for these to avoid code dup.

Change-Id: I745dc95cf564dd330295cecb4d64dccebf55163f
2020-11-18 14:50:11 +01:00
Neels Hofmeyr bd6a4c3e40 hodec2: log requirements of best candidate, log rxlev in dBm
Instead of logging a hex value for the met requirements, fully expand the "ABC"
flags for both TCH/F and TCH/H.

From HO_CANDIDATE_FMT/_ARGS, split off into REQUIREMENTS_FMT/_ARGS and use that
when logging the chosen HO candidates.

Also change the RX level to dBm, to match general logging and reduce confusion
between rxlev number variants in the log.

Change-Id: I1b30a6e98bdb4bd92e72864fafdd2f4f3ae3134c
2020-08-10 21:25:57 +02:00
Neels Hofmeyr 9ed0d17d53 hodec2: do not keep candidates with zero requirements met
When check_requirements() returns zero, do not keep such an entry in the
candidates list at all. This removes logging confusion, where some "candidates"
are still listed even though not meeting any handover requirements.

Change-Id: I12e48292d5731cb601165c870b9570003bc488ec
2020-08-10 21:25:57 +02:00
Neels Hofmeyr f5dab9a2c8 hodec2 congestion: consider only congested pchan types
If no TCH/H need to be moved, then don't collect TCH/H candidates.
Same for TCH/F.

Examining a specific congestion scenario, I realized that ho decision 2
collects candidates of pchan types that are not actually considered congested:

- handover decision 2 wants to move 2 TCH/F only; TCH/H is fine.
- still it collects active TCH/H lchans as candidates.

  (BTS 0) Congestion check: (free/want-free) TCH/F=0/2 TCH/H=12/0
  (BTS 0) Attempting to resolve congestion...
  (BTS 0) congested: 2 TCH/F and 0 TCH/H should be moved
  [...]
  (BTS 0) Considering 8 candidates to solve congestion:
  (lchan 0.020 TCH_F SPEECH_V1)->(BTS 0) (subscr unknown) #0: req=0x0 avg-rxlev=42
  (lchan 0.030 TCH_F SPEECH_V1)->(BTS 0) (subscr unknown) #1: req=0x0 avg-rxlev=42
  (lchan 0.040 TCH_F SPEECH_V1)->(BTS 0) (subscr unknown) #2: req=0x0 avg-rxlev=42
  (lchan 0.050 TCH_F SPEECH_V1)->(BTS 0) (subscr unknown) #3: req=0x0 avg-rxlev=42
  (lchan 0.160 TCH_H SPEECH_V1)->(BTS 0) (subscr IMSI:9017000000xxxxx) #4: req=0x0 avg-rxlev=42
  (lchan 0.161 TCH_H SPEECH_V1)->(BTS 0) (subscr IMSI:9017000000xxxxx) #5: req=0x0 avg-rxlev=42
  (lchan 0.170 TCH_H SPEECH_V1)->(BTS 0) (subscr IMSI:9017000000xxxxx) #6: req=0x0 avg-rxlev=42
  (lchan 0.171 TCH_H SPEECH_V1)->(BTS 0) (subscr IMSI:9017000000xxxxx) #7: req=0x0 avg-rxlev=42

Change-Id: I5077a62c6d77838513eecf3f0e4810c3d3d3a247
2020-08-10 21:25:57 +02:00
Neels Hofmeyr dfc2d84005 hodec2: fix logging of requirements flags
Fix typo to log the "C" requirements accurately.

Change-Id: I15ce607f354918167ba81192230db63a5948c742
2020-08-10 21:25:57 +02:00
Pau Espin 388ed58482 Move struct gsm_bts: gsm_data.* => bts.*
Place all code related to the object into the related file.

Having all the data model in one file made sense in early stage of
development to make progress quickly, but nowadays it hurts more than
helps, due to constantly growing size and more and more bits being
added to the model, gaining in complexity.

Currently, having lots of different objects mixed up in gsm_data.h is a hole
of despair, where nobody can make any sense were to properly put new stuff
in, ending up with functions related to same object in different files
or with wrong prefixes, declarations of non-existing functions, etc.
because people cannot make up their mind on strict relation to objects
in the data model.
Splitting them in files really helps finding code operating on a
specific object and helping with logically splitting in the future.

Change-Id: I00c15f5285b5c1a0109279b7ab192d5467a04ece
2020-07-18 21:45:32 +00:00