Commit Graph

358 Commits

Author SHA1 Message Date
Neels Hofmeyr f93970b167 implement support for 3-digit MNC with leading zeros
Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout
the code base to be able to handle an MNC < 100 that has three digits (leading
zeros).

The changes to abis_test and gsm0408_test show that this code now handles
3-digit MNC correctly, by not dropping the leading zero as 0xf in the encoded
PLMN.

Re-implement CTRL commands 'mcc', 'mnc' and 'mcc-mnc-apply' to preserve the
presence of the third digit of the MNC. Always reply with all leading zeros.
Adjust the expected results in ctrl_test_runner.py, to show that it works.

In VTY and CTRL, the parsing of MCC and MNC is inherently made stricter by use
of osmo_{mcc,mnc}_from_str() -- they will no longer allow surplus characters
and detect errno returned by strtol() (in contrast to atoi()).

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore),
	 Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore),
	 I020a4f11791c61742a3d795f782805f7b7e8733e (libosmocore)
Change-Id: I8e722103344186fde118b26d8353db95a4581daa
2018-03-07 15:34:48 +00:00
Neels Hofmeyr f7a6329bbd cosmetic: bsc_network_init(): imply default 001-01 PLMN
All callers pass mcc=1, mnc=1, so just have it as default.
(Prepare for net->country_code etc to be replaced by net->plmn)

Change-Id: Ic16bc0bab3f2d4721e86a1a04f9d9f988d777df2
2018-03-05 05:37:54 +01:00
Neels Hofmeyr 4d358c00e1 gsm48_ra_id_by_bts(): struct gsm48_ra_id* instead of buf
Move from using deprecated gsm48_construct_ra(), which uses a buf, to
gsm48_encode_ra(), which uses a gsm48_ra_id argument. Pass struct gsm48_ra_id
around instead of a buf.

struct gsm48_ra_id is the "encoded" representation of the bytes in a typical
MCC-MNC-LAC-RAC (04.08 Routing Area Id IE, 3GPP TS 24.008 § 10.5.5.15). Using
the struct spares using magic numbers for byte offsets.

In the process, fix a sanitizer warning for unaligned access by using memcpy()
instead of pointer assignment:

  osmo-bsc/src/libbsc/abis_nm.c:2857:27: runtime error: store to misaligned address 0x7ffe8e0d6695 for type 'uint16_t', which requires 2 byte alignment

Note that (besides removing a now unnecessary cast) the gsm0408_test and
abis_test tests of RAI / CGI encoding remain stable, which indicates that the
new code is still correct.

Change-Id: I0d3908fb8ca1e2e669d257b5d59b40675fa85d06
2018-03-05 05:35:54 +01:00
Alexander Couzens 1231ebe031 pcuif_proto.h: add features of version 7 (txt indication)
The txt indication has been introduced with version 7, but
forgotten to sync back to this repo.

Change-Id: Iafef7dae8b84f659a1aca1677b30a38a2e5558dc
2018-02-28 02:53:20 +01:00
Alexander Couzens 50eed420e6 pcuif_proto.h: fix whitespaces and indention
Change-Id: Ic676bb046a8ee254b9ee8d0d126ce79e6057cfb3
2018-02-28 02:52:49 +01:00
Stefan Sperling 6442e4327b Add support for Access Control Class ramping.
Access Control Class (ACC) ramping is used to slowly make the cell
available to an increasing number of MS. This avoids overload at
startup time in cases where a lot of MS would discover the new
cell and try to connect to it all at once.

Ramping behaviour can be configured with new VTY commands:

  [no] access-control-class-ramping
  access-control-class-ramping-step-interval (<30-600>|dynamic)
  access-control-class-ramping-step-size (<1-10>)

(The minimum and maximum values for these parameters are hard-coded,
but could be changed if they are found to be inadequate.)

The VTY command 'show bts' has been extended to display the
current ACC ramping configuration.

By default, ACC ramping is disabled.

When enabled, the default behaviour is to enable one ACC per
ramping step with a 'dynamic' step interval. This means the
ramping interval (time between steps) is scaled to the channel
load average of the BTS, i.e. the number of used vs. available
channels measured over a certain amount of time.

Below is an example of debug log output with ACC ramping enabled,
while many 'mobile' programs are concurrently trying to connect
to the network via an osmo-bts-virtual BTS. Initially, all ACCs
are barred, and then only one class is allowed. Then the current
BTS channel load average is consulted for scheduling the next
ramping step. While the channel load average is low, ramping
proceeds faster, and while it is is high, ramping proceeds slower:

(bts=0) ACC RAMP: barring Access Control Class 0
(bts=0) ACC RAMP: barring Access Control Class 1
(bts=0) ACC RAMP: barring Access Control Class 2
(bts=0) ACC RAMP: barring Access Control Class 3
(bts=0) ACC RAMP: barring Access Control Class 4
(bts=0) ACC RAMP: barring Access Control Class 5
(bts=0) ACC RAMP: barring Access Control Class 6
(bts=0) ACC RAMP: barring Access Control Class 7
(bts=0) ACC RAMP: barring Access Control Class 8
(bts=0) ACC RAMP: barring Access Control Class 9
(bts=0) ACC RAMP: allowing Access Control Class 0
(bts=0) ACC RAMP: step interval set to 30 seconds based on 0% channel load average
(bts=0) ACC RAMP: allowing Access Control Class 1
(bts=0) ACC RAMP: step interval set to 354 seconds based on 59% channel load average
(bts=0) ACC RAMP: allowing Access Control Class 2
(bts=0) ACC RAMP: step interval set to 30 seconds based on 0% channel load average
(bts=0) ACC RAMP: allowing Access Control Class 3
(bts=0) ACC RAMP: step interval set to 30 seconds based on 0% channel load average

Change-Id: I0a5ac3a08f992f326435944f17e0a9171911afb0
Related: OS#2591
2018-02-27 14:29:39 +00:00
Neels Hofmeyr 444f9e2bb0 HO: vty: rename ho decision 1 vty to 'handover1' with 'handover' alias
Handover decision 2 arguments are now configured by 'handover2 foo'. To match
that scheme, rename the previously 'handover foo' args for handover decision 1
to 'handover1 foo'.

For backwards compatibility, still provide aliases of the original VTY
commands. Writing back the config will result in 'handover1' though.

Change-Id: I7305ae7c04cc70082cd80d42b2ba32ffa399f51a
2018-02-19 17:11:47 +01:00
Neels Hofmeyr 909e972787 HO: Implement load based handover, as handover_decision_2.c
Change-Id: Ie597eae82722baf32546331e443dd9d94f1f25e6
2018-02-19 17:11:47 +01:00
Neels Hofmeyr 45e46d2c88 HO: introduce ho decision callbacks
Instead of reacting on S_LCHAN* signals in the handover decision code,
introduce callbacks for the handover decision to be invoked by handover_logic.c
at the appropriate time.

The rationale is explained in a comment to struct handover_decision_callbacks,
quoting:

"
All events that are interesting for handover decision are actually communicated
by S_LCHAN_* signals, so theoretically, each handover algorithm could evaluate
those.  However, handover_logic.c cleans up handover operation state upon
receiving some of these signals. To allow a handover decision algorithm to take
advantage of e.g. the struct bsc_handover before it is discarded, the handover
decision event handler needs to be invoked before handover_logic.c discards the
state. For example, if the handover decision wants to place a penalty timer
upon a handover failure, it still needs to know which target cell the handover
failed for; handover_logic.c erases that knowledge on handover failure, since
it needs to clean up the lchan's handover state.

The most explicit and safest way to ensure the correct order of event handling
is to invoke the handover decision algorithm's actions from handover_logic.c
itself, before cleaning up. This struct provides the callback functions for
this purpose.

For consistency, also handle signals in this way that aren't actually in danger
of interference from handover_logic.c (which also saves repeated lookup of
handover state for lchans). Thus, handover decision algorithms should not
register any signal handler at all.
"

Also:
- Publish struct bsc_handover to use it as argument to above callbacks.
- Add enum hodec_id to struct bsc_handover, to be able to signal the
  appropriate hodec algorithm per event.
- Add hodec_id argument to bsc_handover_start*() to be placed in the
  bsc_handover struct.
- Publish the LOGPHO logging macros in handover.h along with struct
  bsc_handover, convenient for logging in callback implementations.

Replace handover_decision.c's signal handler with a registered
handover_decision_callbacks instance.

(Upcoming handover_decision_2 will use all of the callbacks introduced here.)

Change-Id: Id5b64504007fe03e0406a4b395cd0359232b77d2
2018-02-19 17:11:47 +01:00
Neels Hofmeyr ec42264113 HO: clearly mark conn penalty timer member for hodec2
The conn's penalty timers will be used only for handover decision 2, make it
clear by a sub-struct.

hodec2 will also initialize the penalty timer list on demand only, so no need
to always initialize.

Change-Id: Ie6c2bc2b10dc424dfd94a9e11a9a62f51c48aa10
2018-02-19 17:11:29 +01:00
Neels Hofmeyr 35ba85c37d HO: lchan: store last seen measurement report nr, tweak log
Handover decision 2 will also store the last seen mr nr for neighbor cell
measurements and hence can tell whether a neighbor's measurement is outdated.

Change-Id: Ic1148364597f91b5a55666c80c758b61fa56f582
2018-02-19 15:51:18 +00:00
Neels Hofmeyr dd42eb9f90 HO: cfg: separate hodec1 from hodec2 parameters
Do not share config items between the current handover decision and the
upcoming handover_decision_2.

Rename current handover config items to hodec2_* and duplicate the ones
relevant to handover decision algorithm 1 with name prefix of hodec1_*.

I considered moving hodec2 parameters to an entirely separate .c file and
struct, but that causes considerable code bloat. Rather use the nice
handover_cfg net/bts level mechanism as-is, and simply prefix the names.

In the VTY, the hodec1 parameters are configurable by 'handover foo 23'
commands, while the hodec2 parameters are by 'handover2 foo 23'. The generic
VTY commands to enable/disable handover and to choose the algorithm are still
'handover (0|1)' and 'handover algorithm (1|2)'.

(Note, a subsequent commit will rename the 'handover foo' for hodec1 to
'handover1 foo' and add backwards-compat aliases.)

For example, the 'window rxlev averaging 5' command now exists both for
handover decision 1 and handover decision 2, and its values are independent.
This is valid config:

    network
     # set up handover decision algorithm 1
     # (pending rename of these items to 'handover1 ...')
     handover window rxlev averaging 5
     handover window rxlev neighbor averaging 5

     # set up handover decision algorithm 2
     handover2 window rxlev averaging 7
     handover2 window rxlev neighbor averaging 7
     handover2 penalty-time max-distance 10

     # enable handover
     handover 1

     bts 0
      handover algorithm 1
     bts 1
      handover algorithm 2

In this example, bts 0 uses algo 1 with rxlev averaging of 5, while bts 1 uses
algorithm 2 where rxlev averaging of 7 is in effect.

Change-Id: I6475b2543b18d21710a6d774b214cb484f36ec8e
2018-02-19 15:51:17 +00:00
Harald Welte 51e4bf3298 Permit set of multiple different A5 ciphers
So far, the administrator had to pick one particular cipher which
would then be used throughout all subscribers/phones. This is a bit
impractical, as e.g. not all phones support A5/3.  Extend the VTY
command syntax in a backwards-compatible way to permit for multiple
ciphers.

The bit-mask of permitted ciphers from the MSC (sent in ASSIGNMENT
COMMAND) is intersected with the vty-configured mask a the BSC.
Finally, the best (highest) possible cipher is chosen.

Change-Id: I1d1c8131855bcab2392b4f27f6216bdb2fae10e0
Closes: OS#2461
2018-02-19 11:43:07 +01:00
Harald Welte 86a8031e9c logging: Remove obsolete log categories
About half of our log categories/subsystems were inherited from
OsmoNITB, and are no longer used but may confuse the user.

Change-Id: I8b39429f71c0faefdf8158a82093cfb19f44809e
2018-02-19 10:47:50 +01:00
Harald Welte 519c7e1d42 Structural reform: Get rid of osmo_bsc_sccp_con
There was always a 1:1 correspondence between gsm_subscriber_connection
and osmo_bsc_sccp_con, so there's really no point in having two separate
dynamically allocated data structures with pointers back and forth and
another linked list around.

Let's merge osmo_bsc_sccp_con into gsm_subscriber_connection for
simplicity.

The resulting code might not be elegant in places, but I've tried to
do only the most simple changes in this patch, while further
simplifications can be done in later subsequent patches.

As a side-effect, this patch also fixes lchan clearing if the MSC
(or the local SCCP provider) hard-disconnects the SCCP connection.

Change-Id: Idd2b733477ee90d24dec369755a00f1c39c93f39
2018-02-19 08:20:35 +00:00
Neels Hofmeyr dfd36da120 HO: cfg: tweak vty write
Have expicitly named vty write functions for bts and net levels, so that it is
trivial to add commands that exist only on one of each (like the upcoming
congestion check timer config for hodec2).

Change-Id: Ibea4c20abc50c3d655f6bbb1a643477dfc722c8e
2018-02-16 16:11:16 +01:00
Neels Hofmeyr a60f344212 HO: store speech codec list from BSSMAP Assignment in conn
On BSSMAP Assignment Request received from the MSC, store the Speech Codec List
in the subscr conn, so that we may evaluate available codecs during handover
decision. (Will be used, e.g., by handover_decision_2.)

Change-Id: I8222d73085eb777696e365c94214c05d56e6d129
2018-02-16 16:11:16 +01:00
Neels Hofmeyr cbdfb78f7b HO: move penalty timers to own file as proper API
Separate penalty timers API from specific struct members and move to own .h/.c
file, so that future code may re-use the API arbitrarily.

Change-Id: Ife975a1c7c17a500b1693be620475a8bea72f86f
2018-02-16 16:11:16 +01:00
Neels Hofmeyr 6dff51d583 HO: add new_lchan_type arg to bsc_handover_start()
Upcoming handover_decision_2 will want to be able to handover to a differing
TCH type, hence add a parameter to bsc_handover_start(); adjust current callers
to pass the old lchan type.

Tweak the 'bts' argument to 'new_bts'.

Change-Id: I4478ebcaada00897cc38c5a299e07661139ed3c5
2018-02-16 16:11:16 +01:00
Neels Hofmeyr 91004ab734 gsm_network: drop unused subscr_epxire_timer
Change-Id: I2e34ffb35e244472f8bfc993facc8d6e130f10d9
2018-02-14 12:55:45 +01:00
Neels Hofmeyr 28838e9aaa drop unused common.h
Change-Id: I7cf4076d7e36ae71d88e70a86d5c2d0640c1146f
2018-02-14 12:55:45 +01:00
Neels Hofmeyr d23ce86c25 drop libcommon-cs completely
Change-Id: I07d4a48af3154ee4d904686f230a51b8b8a94ff9
2018-02-14 12:55:45 +01:00
Neels Hofmeyr 92b9f2ecd4 common_cs.h: mv gsm_encr to gsm_data.h
This leaves common_cs.h practically empty. Leave its removal to the next patch,
which removes libcommon-cs entirely
(I07d4a48af3154ee4d904686f230a51b8b8a94ff9).

Change-Id: Ic3233f03580aa8c0ab178dfd33e68ecab5b9f042
2018-02-14 12:55:45 +01:00
Neels Hofmeyr 6dd5a9b017 libcommon-cs: move vty bits to libbsc/bsc_vty.c
The gsm_network VTY was partly shared between libmsc and libbsc in the old
openbsc.git; now osmo-bsc.git has its own copy, so merge all of it into
bsc_vty.c.

This leaves common_cs_vty.c practically empty; leave removal of the file to
later, when we drop the entire libcommon-cs in
I07d4a48af3154ee4d904686f230a51b8b8a94ff9.

Note that gsmnet_from_vty() is also already declared in bsc/vty.h.

Change-Id: I6f3a596f31762b48afed39a85a343c400826300f
2018-02-14 12:55:45 +01:00
Neels Hofmeyr b5400776d8 libcommon_cs: move gsm48 bits to libbsc
These functions were originally shared between libmsc and libbsc in the old
openbsc.git; now osmo-bsc.git has its own copies, so move them into libbsc.

Change-Id: Ie411c2ce8008accee54782a442d6361e50777a54
2018-02-14 12:55:45 +01:00
Neels Hofmeyr d85e4cb711 gsm_network: drop unused trans_list
Change-Id: I7910ce8098d5431e41409bf09429ae4221efb360
2018-02-14 12:55:45 +01:00
Neels Hofmeyr ab1b381d1b libcommon-cs: move gsm_network_init() into bsc_network_init()
Some part of the network init was common between libbsc and libmsc in the old
openbsc.git repository. Now osmo-bsc.git is independent with its own copy of
the gsm_network initialization. So move it over to libbsc.

Change-Id: I8968787a5f0b078619264f0cb42349a9bc7943af
2018-02-14 12:55:45 +01:00
Neels Hofmeyr 104851632d libcommon: join gsm_data_shared.* into gsm_data.*
The separation of gsm_data_shared.* from gsm_data.* historically allowed
compiling parts of it into osmo-bts, which we have dropped since (osmo-bts has
its own copy now). Even though gsm_data.* now becomes rather large by it,
remove the legacy separation to get rid of the "shared" naming, which is no
longer meaningful. A future patch might separate into meaningful smaller bits,
if we get the time.

Change-Id: Ie247bc492efb331871d970c56700595ad3f7e201
2018-02-14 12:15:40 +01:00
Neels Hofmeyr 978f58cd2e libcommon: eliminate socket.c
Replace calls to make_sock() with osmo_sock_init_ofd().
Shame on me for not testing every single one in practice, I hope for peer
review to confirm that this should be correct... Read closely please!

The IPPROTO_GRE define seems to be unused (at least in osmo-bsc.git), drop it
completely.

Change-Id: Ia6e4e0e1eed3328fa25b3b90be376d532ad0e56b
2018-02-14 12:15:40 +01:00
Neels Hofmeyr 7997bf4bed libcommon: eliminate debug.c
Provide concise log categories for each main scope.

Move the complete log categories 1:1 to osmo_bsc_main.c.

In bsc_nat.c, omit obviously unused log categories.

In tests, omit almost all log categories, except for those explicitly tested as
the expected output.

Note: should any logging occur for a log category that is omitted by accident,
such will end up being logged as DLGLOBAL, so it will show up and we can fix
it, and it will not get lost silently.

Change-Id: Ib524e49ec211662e0dfde8161495a72aa8ad76cf
2018-02-14 12:15:40 +01:00
Neels Hofmeyr ec1bb16eef libcommon: eliminate common_vty.c
Move bsc_vty_go_parent() to osmo_bsc_main.c and bsc_nat.c, and drop those nodes
that aren't used in the respective main scope.

Change-Id: I22ebb76742e9c5ab9dd608ac089a5c558aceeb36
2018-02-14 12:15:13 +01:00
Stefan Sperling 73acbca50f Make RSL connection attempts time out.
If a BTS/TRX does not respond to the "IPA RSL Connect" command,
pretend that the BTS has sent a NACK for the connection.

To ensure that osmo_timer_del(&trx->rsl_connection_timeout) is not called
before this timer is initialized with osmo_timer_setup(), the E1 layer now
drops incoming RSL messages from a BTS/TRX in LOCKED administrative state.

We cancel the timeout if we receive an RSL Connect ACK or NACK from the BTS,
and if the underlying E1 link does down.

While here, add a missing message buffer free() in bts_isdn_sign_link().
The callers do not free it.

Change-Id: Ia72b65a0f15f47dcb8a6f944f6c3695a4a64b923
Related: OS#2716
2018-02-13 18:08:28 +01:00
Stefan Sperling 81dc9e7455 Add stat items for the BTS's channel load average and T3122.
In addition to logging the current values of a BTS's channel load
average and T3122 override, maintain stat items for these values.
This allows for plotting these values over time, for instance.

These values show up in the VTY under 'show stats' like this:

base transceiver station:
 Channel load average.:       25 %
 T3122 IMMEDIATE ASSIGNMENT REJECT wait indicator.: 32 s

Change-Id: Icace0176e8b1d23d7c7b4816f7c67c65312844fa
Suggested-by: laforge
2018-02-05 22:36:54 +00:00
Harald Welte d9cc21c48f gsm_data_shared.h: Remove unused sacch_deact member field
Change-Id: I806b957b7f6fbbb1206d29ceeccd401c98c26990
2018-02-05 20:45:15 +01:00
Stefan Sperling 6cee893a0f Make "waiting indicator" of IMMEDIATE ASSIGN REJECT dynamic.
The IMMEDIATE ASSIGN REJECT message contains a wait indicator which
tells an MS requesting a channel to wait for a specified amount of
time before trying to request a channel again, i.e. the wait indicator
controls the T3122 timeout value in the MS.

Previously, the wait indicator was fixed to 10 seconds.
This is not sufficient if there are a lot of MS requesting channels
because the MS will retry too soon. Instead of using a fixed value,
maintain a dynamic wait indicator value based on average channel load.

The load (used vs. available channels on a BTS) is sampled once per
second, and once 8 samples have been collected we update a BTS-specific
T3122 wait indicator based on the measured load.

While the wait indicator could go up to 255 seconds, this initial
implementation keeps it in the range from 10 to 128 seconds.

Further experimentation and testing will show whether higher wait
indicator values are desirable, if the sampling rate needs to change,
or if the function mapping the load measurement to a wait indicator
value should change (currently we map the load average linearly into
the range [10, 128] inclusive).

Change-Id: I57e38f6d6ba3b23cc6e1f9520b90261dbb1f1cec
Related: OS#2592
2018-02-05 13:58:17 +01:00
Harald Welte b794887cab remove obsolete gsm_subscriber_connection.bts member
This member was merely a cache for conn->lchan->ts->trx->bts,
so let's avoid having to keep copies of the same data (which needs
to be kept up to date).

Change-Id: Id3bff8b18425ef5d45eb460ac9eb620023013ba0
2018-01-28 03:23:00 +01:00
Andreas Eversberg 084b421fba HO: Add a penalty timer list to the subscriber connection entity
This penalty timer is used to temporarily block cells where handover
or assignment failed or where handover is not allowed. This is usefull
to prevent repeated handover attempts to broken cells or cells that have
limited allowed distance.

Change-Id: I95cb7e3211b2470b773965e7aa94d8eb6c8c1a3a
2018-01-22 01:57:50 +00:00
Andreas Eversberg 935e5d76dd HO: add queue to cache DTAP messages during handover/assignment
Add ho_dtap_cache to gsm_subscriber_connection, a stock msgb queue to be used
with msgb_enqueue() and msgb_dequeue().

Keep a counter of queue length, to enforce a sane maximum counter for cached
messages. So far a hardcoded maximum of 23 messages will be cached.

Have balanced ho_dtap_cache_add() and ho_dtap_cache_flush() functions.

The original patch was by jolly, but I have basically completely replaced it
with the simpler msgb queue pattern.

Change-Id: I6e4d93628befb3d97e5cee0343cd9f8ba0b8620c
2018-01-19 22:09:19 +00:00
Neels Hofmeyr 2660c0412d HO: make bts_by_arfcn_bsic() public
Change-Id: Ie746f76433f6b46a71a91b7714cc034c4355d993
2018-01-19 22:09:19 +00:00
Andreas Eversberg df65c9afee HO: Count number of free timeslot on a given BTS
This is needed for handover algorithm to balance free slots and to prevent
congestion of one cell, while other cells still have free capacities.

Change-Id: Ic8bee8a515ee8aa9a99af71756fe60b8dd8f868b
2018-01-19 18:19:00 +01:00
Neels Hofmeyr 87b5eb667b HO: add handover algo 2 parameters; skip HO 1 if HO 2 is configured
Change-Id: I8811ee8a75be09048042b511ee4bd9bc1de63976
2018-01-19 16:03:16 +01:00
Neels Hofmeyr c561515ae0 HO: enable handover by initializing at startup; rename init function
Change-Id: I224884c84895ebf6c8cf498c16616214cb2b5779
2018-01-19 16:03:16 +01:00
Andreas Eversberg 9869203f65 HO: fix: increase the number of measurement report history to 10
If we want to average over up to 10 measurement reports (as configurable
at VTY), we need a history of at least 10 measurements.

Change-Id: Ia7cfac073bdc464092ca3e51dec319ac30401dd1
2018-01-19 16:03:16 +01:00
Andreas Eversberg 7df80d38f3 HO: Add handover decision debugging category
Change-Id: Iaf99d4e9ae08c38bf364dbb37d42098f976f6b8c
2018-01-19 16:03:16 +01:00
Andreas Eversberg e0cba56dad HO: If handover logic is used to do assignment, signal assignment result
Change-Id: I465caef03626e67d9b3a21bdf730589b9852c211
2018-01-19 16:03:16 +01:00
Andreas Eversberg 7c41cd1ac5 HO: Changed availablilty of ts_is_usable() from static to extern
Change-Id: I3471e38327c4b98490faed9b604fb76438ba9954
2018-01-19 16:03:16 +01:00
Andreas Eversberg 970b43486f HO: Count the actual meas.rep. get_meas_rep_avg fails if not reached
get_meas_rep_avg will return -EINVAL, if the required number of
measurements are not reached. There will be no handover possible until the
given number of measurements are available.

Change-Id: Ibc4410b4e162cdb6c070128d2c63946bb79d6d65
2018-01-19 16:03:16 +01:00
Andreas Eversberg a91800034e HO: Add function to count currently ongoing handovers to a given BTS
In order to keep processing power at BTS at a defined level, the handover
decision might want to limit maximum number of slots that require RACH
detection.

Change-Id: I8908e37fe0d8d2eda906cc6301ba0969b25a5575
2018-01-19 16:03:16 +01:00
Neels Hofmeyr e25018b8c1 HO prep: introduce per-BTS handover config, with defaults on net node
It is desirable to allow configuring handover for each individual network cell.
At the same time, it is desirable to set global defaults.

Treat the 'network' node handover parameters as global defaults, add another
set of parameters for each individual BTS.

This raises questions on how the 'network' node should affect the individual
BTS. The simplistic solution would have been: on creating a BTS in the config,
just copy the current defaults; with serious drawbacks:
- tweaking any parameter in the telnet VTY on network node will never affect
  any running BTS.
- network node defaults *must* be issued before the bts sections in the config
  file.
- when writing a config back to file, we would copy all net node defaults to
  each BTS node, making the network node configs pointless.

Instead, add a handover_cfg API that tracks whether a given node has a value
set or not. A bts node ho_cfg gets a pointer to the network node config and
returns those values if locally unset. If no value is set on any node, use the
"factory" defaults, which are hardcoded in the API. Only write back exactly
those config items that were actually issued in a config file / on the telnet
VTY. (ho_cfg API wise, we could trivially add another ho_cfg level per TRX if
we so desire in the future.)

Implement ho parameters as an opaque config struct with getters and setters to
ensure the tracking is always heeded. Opaqueness dictates allocating instead of
direct embedding in gsm_network and gsm_bts structs, ctx is gsm_net / bts.

This is 100% backwards compatible to
old configs.
- No VTY command syntax changes (only the online help).
- If a 'bts' sets nothing, it will use the 'network' defaults.
- The 'show network' output only changes in presence of individual BTS configs.

On 'show network', say "Handover: On|Off" as before, iff all BTS reflect
identical behavior. Otherwise, output BTS counts of handover being enabled or
not.

Use the same set of VTY commands (same VTY cmd syntax as before) on network and
BTS nodes, i.e. don't duplicate VTY code. From the current vty->node, figure
out which ho_cfg to modify.

For linking, add handover_cfg.c (the value API) in libcommon, while the
handover_vty.c is in libbsc. This is mainly because some utility programs use
gsm_network and hence suck in the ho stuff, but don't need the VTY commands.

Review the VTY online help strings.

Add VTY transcript test for handover options, testing config propagation from
network to bts nodes, 'show network' output and VTY online help strings.
(Needs recent addition of '... !' wildcard to osmo_interact_common.py.)

I considered leaving parts of this more readable, but in the end decided for
heavy use of macros to define and declare the API, because more values will be
added in upcoming patches and I want to prevent myself from messing them up.

Inspired-by: jolly/new_handover branch, which moves the config to 'bts' level
Depends: I7c1ebb2e7f059047903a53de26a0ec1ce7fa9b98 (osmo-python-tests)
Change-Id: I79d35f6d3c0fbee67904378ad7f216df34fde79a
2018-01-19 16:03:16 +01:00
Neels Hofmeyr be1131df42 HO: fix recovery from failed handover
Do not instruct the MGW to move the RTP to the new lchan before we have
received a HANDOVER DETECT.

Before:

  Chan Activ
  Chan Activ Ack
  IPACC-CRCX
   -ACK
  IPACC-MDCX
   -ACK
  MGCP MDCX --> MGW
  ...
  HANDOVER DETECT
  Call continues on new lchan

In above sequence, if the HANDOVER DETECT times out, the MGW has moved to the
new lchan which never becomes used and is released. Furthermore, from the IPACC
MDCX until the HANDOVER DETECT, the RTP stream would break off momentarily.

After:

  Chan Activ
  Chan Activ Ack
  IPACC-CRCX
   -ACK
  IPACC-MDCX
   -ACK
  ...
  HANDOVER DETECT
  MGCP MDCX --> MGW
  Call continues on new lchan

If the HANDOVER DETECT times out, the call happily continues on the old lchan.

This change is inspired by Ivan Kluchnikov's HO work, who implemented a similar
fix in the openbsc.git codebase (branch fairwaves/master-rebase): his patch
moves ipacc_mdcx() to connect RTP to the new lchan from switch_for_handover()
(which triggered on S_ABISIP_CRCX_ACK, i.e. creation of the new lchan) to later
on in ho_detect() a.k.a. the S_LCHAN_HANDOVER_DETECT signal handler:
http://git.osmocom.org/openbsc/commit/?h=fairwaves/master-rebase&id=9507a7a1ea627e07370c9d264816bb190b3b91b8

This patch does essentially the same: remove the mgcp_handover() call from the
MDCX-ACK handling (creation of the new lchan), and add a signal handler for
S_LCHAN_HANDOVER_DETECT to osmo_bsc_mgcp.c to effect the MGW switchover.

Note, it would have been possible to call mgcp_handover() directly from rx of
the HANDOVER DETECT message, but that produces linking fallout in some utils/
projects, which then need to link the mgcp code as well. That is because those
aren't properly separated from the more complex parts of libbsc. Using the
signal is a bit bloaty, but saves the linking hell for now. I've faced a
similar problem twice recently, it would pay off to separate out the simpler
utils/ and ipaccess/ tools so that they don't need to link all of libbsc and
osmo-bsc, at some point (TM).

Change-Id: Iec58c5fcc5697f1775da7ec0111135108ed1fc8f
2018-01-19 16:03:15 +01:00