Commit Graph

2071 Commits

Author SHA1 Message Date
Vadim Yanitskiy e920902e25 power_control: properly track the first initial state
Change-Id: I16e7474b5affbd90855a2e407b305e9dec581dfa
Related: SYS#4918, SYS#4917
2021-01-08 02:30:46 +01:00
Vadim Yanitskiy 834ba05cd2 power_control: generalize measurement pre-processing state
This way EWMA based filtering can also be applied to RxQual.

Change-Id: I439c00b394da670e314f217b3246cc85ce8213c6
Related: SYS#4918, SYS#4917
2021-01-08 02:23:56 +01:00
Vadim Yanitskiy e8f857453d power_control: migrate MS/BS control loops to the new params
In change [1] the new power control structures and default params
were introduced.  In change [2], the existing VTY commands for MS
power control in the BTS were deprecated and changed to use the
new structures as storage.  Finally, in change [3], handling of
the power control parameters on the A-bis/RSL was implemented.

This change is the final logical step in the mentioned chain: it
makes both MS/BS power control loops use the new parameters, and
removes the old structures.  The actual implementation of both
power control loops remains the same, however the expected output
of some unit tests for the Downlink loop needs to be changed:

  - TC_fixed_mode: disabling dynamic power control becomes a separate
    step of the test script since the field 'fixed' is removed;

  - TC_rxlev_target: RxLev thresholds are printed 'as-is'.

Not all of the new parameters are used by the power control loops
yet.  Further improvements to be done in the follow up commits.

[1] I6d41eb238aa6d4f5b77596c5477c2ecbe86de2a8
[2] Icbd9a7d31ce6723294130a31a179a002fccb4612
[3] I5a901eca5a78a0335a6954064e602e65cda85390

Change-Id: Ib18f84c40227841d95a36063a6789bf63054fc2e
Related: SYS#4918
2021-01-08 02:05:27 +01:00
Vadim Yanitskiy 4a0a6fd014 vty: add a command to show GPRS related info
Here is a sample output:

  OsmoBTS# show bts 0 gprs
  BTS 0, RAC 0, NSEI 101, BVCI 2
    Cell NM state: Oper 'Enabled', Admin 'Unlocked', Avail 'OK'
    NSE NM state: Oper 'Enabled', Admin 'Unlocked', Avail 'OK'
    NSVC0 (NSVCI 101) NM state: Oper 'Enabled', Admin 'Unlocked', Avail 'OK'
      Address: r=127.0.0.1:23010<->l=0.0.0.0:55385
    NSVC1 (NSVCI 0) NM state: Oper 'Disabled', Admin 'Locked', Avail 'Off line'

This command is useful for debugging NS connection problems.

Change-Id: I149eea0b1c109020406eb67c9082c335a77aab06
2021-01-07 13:58:21 +01:00
Vadim Yanitskiy 9238c3549d power_control: handle MS/BS Power control params on A-bis/RSL
Change-Id: I5a901eca5a78a0335a6954064e602e65cda85390
Depends: I2f4ed56837dd479dbbd10c0a7df0ed7565d3946a
Related: SYS#4918
2021-01-07 00:38:55 +00:00
Vadim Yanitskiy f0089a8495 power_control: vty: deprecate 'uplink-power-control' commands
MS/BS Power Control parameters have been recently moved to the BSC
and now signaled to the BTS over the A-bis/RSL link.  Let's make
sure that the existing VTY commands for Uplink Power Control do:

  - trigger deprecation warnings if present in the config file,
  - not show up in the online VTY help nor VTY reference,
  - affect the fall-back parameters in 'struct gsm_bts',
  - still get printed by 'show running-config' command.

Change-Id: Icbd9a7d31ce6723294130a31a179a002fccb4612
Related: SYS#4918
2021-01-07 00:38:55 +00:00
Vadim Yanitskiy 7a8c9dbad7 power_control: vty: re-use cfg_bts_ul_power_target()
This reduces code duplication by defining an alias.

Change-Id: I37f51d426fcf008c9d9e933827de70ab7b072a94
Related: SYS#4918
2021-01-07 00:38:55 +00:00
Vadim Yanitskiy 22646cb122 osmo-bts-trx: vty: clarify and improve some deprecation messages
Change-Id: I22b69eccfa50d178bd36bf770f7158ec441c9923
Related: SYS#4918
2021-01-07 00:38:55 +00:00
Vadim Yanitskiy 9b6c149e42 sysinfo: fix less-than-zero comparison of an unsigned value
size_t is an unsigned type, while get_si4_ro_offset() returns int.

Change-Id: I3b216b70fbcc653ced734835ccb2c7f1932d9f0a
Fixes: CID#215888
2021-01-05 14:12:06 +00:00
Vadim Yanitskiy e476629bcf l1sap: fix: enable UL SACCH repetition if RxQual threshold is 0
It is expected that setting RxQual threshold to 0 would make the
L1SAP logic enable repetition for both Uplink SACCH and Downlink
FACCH unconditionally.  However, this was only valid for the
later.  Let's add the missing check and make it consistent.

Change-Id: Ia44a134e7f28ea990798d1b79c87b644504c0876
Related: SYS#5114
2021-01-05 12:21:23 +01:00
Vadim Yanitskiy 763ce0627a power_control: add VTY introspection commands for MS/BS params
Change-Id: I34095673bf49deb390d5e8383c4ee05a6915b82f
Related: SYS#4918
2021-01-04 21:49:21 +00:00
Vadim Yanitskiy 5f909b45c5 power_control: check-in new parameters and default values
For the sake of simplicity, the old structures that are still used
by MS/BS power control loops are kept in place.  Migration to the
new structures requires additional changes to the existing power
control logic, so it will be done in the follow-up changes.

The new parameters are integrated as follows:

  + struct gsm_bts - a BTS instance:
  |   Hard-coded default (fall-back) parameters for all transceivers.
  |
  +-+-> struct gsm_bts_trx - a TRX instance (transceiver):
    |     Default parameters for all logical channels inherited from
    |     'struct gsm_bts' at start-up.  May be overwritten by the
    |     BSC using ip.access specific 'Measurement Pre-processing
    |     Defaults' message on the A-bis/RSL interface.
    |
    +---> struct gsm_lchan - a logical channel (e.g. TCH or SDCCH):
            Connection specific parameters inherited from 'struct
            gsm_bts_trx'.  May be overwritten by parameters sent
            by the BSC in CHANnel ACTIVation and other messages.

Change-Id: I6d41eb238aa6d4f5b77596c5477c2ecbe86de2a8
Related: SYS#4918
2021-01-04 21:49:21 +00:00
Pau Espin Pedrol 20cbf7bc67 cosmetic: sysmobts-mgr: fix whitespace indentation
Change-Id: I8449a34998808f7e13cc5d1eafb5420b1cc0a9d4
2021-01-04 18:07:23 +01:00
Harald Welte ecf4879403 fix-up missed review comment in CBCH SI4 patching fix
This is a follow-up fix for I0ee0cf736e2fb74a6759a68101f699b4ec2ef54e

get_si4_ro_offset() itself already checks if it's less than GSM_MACBLOCK_LEN,
so we must check if it's not negative.

Change-Id: Iba99e5de625af6bed6720a38fec26c2acc6251c0
2021-01-03 10:28:55 +01:00
Harald Welte 129cb51597 sysinfo.c: Fix SI4 GPRS patching which overwrote CBCH IE
In Change-Id I1fd513ea03297918d15d4b28ed454f9b6dd6ebfa we introduced
patching of SI4 to indicate GPRS presence in terms of PCU connection
status.  Unfortauntely this didn't account for optional IEs being
present in SI4, and hence overwrote any CBCH related information
elements, if present.

This in turn meant that since the above-mentioned commit, you could
have either a GPRS-capable, network, or a Cell Broadcast capable one.

Change-Id: I0ee0cf736e2fb74a6759a68101f699b4ec2ef54e
Related: OS#3075
2021-01-03 00:46:16 +01:00
Vadim Yanitskiy f158bb614c rsl: remove redundant boolean flag in rsl_rx_chan_activ()
Checking if a given RSL IE is present is a straightforward task,
so there is no need for a special boolean flag.

Change-Id: I6a12930314c79b9c3efabfa575b17f78105fea4c
2020-12-30 18:33:40 +01:00
Vadim Yanitskiy 538c56ef34 vty: fix dump_lchan_trx_ts(): dump dedicated channels only
It does not make sense to dump CCCH/CBCH as dedicated channels:

  OsmoBTS# show lchan
  BTS 0, TRX 0, Timeslot 0, Lchan 4: Type CCCH
    State: ACTIVE
    BS (Downlink) Power Control (autonomous):
      Channel reduction: 0 dB (max 0 dB)
      TRX reduction: 0 dB
      Actual / Nominal power: 13 dBm / 13 dBm
    MS (Uplink) Power Control (autonomous):
      Current power level: 0, -39 dBm (max 0, -39 dBm)
    Channel Mode / Codec: SIGNALLING
    LAPDm SAPIs: DCCH --, SACCH --
    Valid System Information: 0x00000060
    MS Timing Offset: 0, propagation delay: 0 symbols
    Radio Link Failure Counter 'S': 0

so let's only dump SDCCH, TCH/F, and TCH/H.

Change-Id: Id7880de56a93cc9fa4ca576b094cef35ee269822
2020-12-10 15:27:37 +00:00
Neels Hofmeyr 7233fa8623 log: rsl_rx_chan_activ: show chan type as human readable string
Change-Id: I3acf6c18309d3b4093dbc295be622363cb6dbcdc
2020-12-10 15:23:42 +00:00
Vadim Yanitskiy 6904d7dd5d vty: resurrect per-lchan BS/MS Power Control information
Change-Id: I48812383ef0a125e83b9b3761f3f15873d3b37b4
Related: SYS#4918
2020-12-09 21:39:52 +00:00
Vadim Yanitskiy 675618b4f8 power_control: make raise/lower step limitation configurable
Change-Id: Ic37742f46f533865043b3dbcf16ea702e1746f98
Related: SYS#4918
2020-12-09 21:39:52 +00:00
Pau Espin Pedrol 2b416d6d2b nm_channel_fsm: Fix several FSM internal transitions not being made
During the initial implementation I used the wrong function to change
state. As a result, from BSC point of view the BTS was changing state
but the FSM internally was not. "Fortunately", while in state Dependency
the BTS still could cope with that in order to still be operative with
older osmo-bsc, so there was no major breakage, only some error log
message being printed.

Related: OS#4873
Change-Id: Ifd2eefc362fca0aa9e6ae102c7e6dbc1b4f295d6
2020-12-09 14:04:19 +01:00
Vadim Yanitskiy 75162427ad rsl: properly initialize MS/BS Power Control state
struct lchan_power_ctrl_state actually contains more fields,
which also must be initialized on CHANnel ACTIVation.

Change-Id: Id9719088fc6e9479c13e9b327a3466d9e2810a3a
Related: SYS#4918
2020-12-08 13:10:46 +01:00
Vadim Yanitskiy 237ec6194b power_control: clarify units in 'struct bts_power_ctrl_params'
Change-Id: Icb059ca1f555397be116a424800e4536883b9106
Related: SYS#4918
2020-12-06 18:59:05 +01:00
Vadim Yanitskiy 63c1838c7a power_control: cosmetic: fix weird spacing
Change-Id: Ia5661e82372f958e7cda4041d7b5a1cfb1d64afe
2020-12-06 18:58:11 +01:00
Vadim Yanitskiy 0698c58ebe power_control: implement BS (Downlink) Power Control
We already have MS Power Control, which according to 3GPP 45.008
shall be implemented in the MS to minimize the transmit power in
the Uplink direction.  The BS Power Control may optionally be
implemented by the network side for the same purpose.

Using Downlink signal measurements reported by the MS, the BSS
(either BSC, or BTS) may control Downlink attenuation in a way
that the transmit power remains as low as possible, or remains
in a specific range corresponding to good RxLev values on the
MS side.  This change implements autonomous BS Power Control,
that can optionally be enabled by the BSC.

BS Power Control re-uses parts of the MS Power Control code,
so all parameters can be configured in the same way - via the
VTY interface or a configuration file.  This basically means
that features like hysteresis and EWMA based filtering are
also available for BS Power Control.

The only difference is that RxQual values higher than 0 would
trigger the logic to reduce the current attenuation twice.

Note that one of the unit tests ('TC_rxlev_max_min') fails,
as the power step limitations for raising and lowering look
wrong to me, and the related discussion is still ongoing.

Change-Id: I5b509e71d5f668b6b8b2abf8053c27f2a7c78451
Related: SYS#4918
2020-12-06 18:57:43 +01:00
Vadim Yanitskiy 0ced8dd03e power_control: derive calc_delta() from lchan_ms_pwr_ctrl()
This function will also be used by the BS Power Control logic.

Change-Id: I2525eb2c3f1fdb3d0847a8ad50b30a44d7741a55
Related: SYS#4918
2020-12-04 09:27:48 +01:00
Vadim Yanitskiy 2f53fae01f power_control: do not log averaged RSSI values as 'rx-current'
Similar to I3c07cb6e14acd5a988761bbc51a9c3b60fb22d87, this change
is another step towards separating the common delta calculation
logic from lchan_ms_pwr_ctrl(), since this function will loose
access to the averaged values.

On the one hand, the affected logging statements are getting
less precise; on the other, logging the averaged value as the
actual value ('rx-current') may be even more confusing.

Change-Id: I07007e45c859b4080fbbe520ffb5ccc0bb9c4244
Related: SYS#4918
2020-12-04 09:27:48 +01:00
Vadim Yanitskiy 567ea2a079 power_control: remove a logging statement and early return
This change would allow to separate the common logic from
lchan_ms_pwr_ctrl() and re-use it for Downlink power control.

The logging statement was quite useful during early stages
of development and testing of hysteresis and filtering,
but now we can sacrifice it.

Change-Id: I3c07cb6e14acd5a988761bbc51a9c3b60fb22d87
Related: SYS#4918
2020-12-04 09:27:48 +01:00
Vadim Yanitskiy 2b59a625e8 power_control: lchan_ms_pwr_ctrl(): make use of params/state pointers
Change-Id: I177d82cd61d59256976007fed2f7da400b814789
Related: SYS#4918
2020-12-04 09:27:48 +01:00
Vadim Yanitskiy 08f3eafd02 power_control: generalize and rename lchan_ul_pf_ewma()
This way EWMA based filtering logic can be used not only for
MS Power Control, but also for BS Power Control.

Change-Id: I16c2e1b997f2b8af44d47809420293f072335bbd
Related: SYS#4918
2020-12-04 09:27:48 +01:00
Vadim Yanitskiy f15c44df52 power_control: lchan_ms_pwr_ctrl(): use existing 'trx' pointer
Change-Id: Idf46e47f20f031ff9dded1be1e6c4337d7b423e7
Related: SYS#4918
2020-12-04 09:27:48 +01:00
Vadim Yanitskiy 0e24ace2f1 power_control: lchan_ul_pf_ewma(): do not use lchan->meas.res_nr
This would allow to pass only two pointers:

  - 'struct bts_power_ctrl_params', and
  - 'struct lchan_power_ctrl_state',

and get rid of 'struct gsm_lchan' dependency.  The later is
exactly where all state variables are supposed to be kept.

Change-Id: Idfefca30f4944bc722b4e9d8f1685eb77670a9db
Related: SYS#4918
2020-12-04 09:27:48 +01:00
Vadim Yanitskiy 9381576e18 power_control: generalize power control state structure
Change-Id: I8c6ad8d14349e8a05084c2912644c5202f951f52
Related: SYS#4918
2020-12-04 09:27:48 +01:00
Vadim Yanitskiy 3b1e66af9e l1sap: make sure that UL SACCH is always 23 octets long
Change-Id: I1c8a43337fbc1acfab3c0f0713c75ded95d69512
Related: SYS#4918
2020-12-02 15:01:10 +01:00
Vadim Yanitskiy 369c852022 bts: add Downlink power control parameters
Change-Id: I724f661e9ce5dd75f95fb7b270a89b2e2a73c951
Related: SYS#4918
2020-12-02 13:56:49 +00:00
Vadim Yanitskiy ca9ab523e1 bts: rename MS_UL_PF_ALGO_{NONE,EWMA} to BTS_PF_ALGO_{NONE,EWMA}
Change-Id: I580512eea1d329a4d25ccbd6fc2ab98b083ec51d
Related: SYS#4918
2020-12-02 13:56:49 +00:00
Vadim Yanitskiy af4eec056e struct gsm_bts: move ul_power_{target,hysteresis} to ul_power_ctrl
Change-Id: I3886c7aedf3870536f1750f864cf698302ddf2df
Related: SYS#4918
2020-12-02 13:56:49 +00:00
Vadim Yanitskiy 5b25e8e7de osmo-bts-trx/scheduler: ensure no DL power attenuation on C0
When [baseband] frequency hopping is in use, Downlink bursts from
additional transceivers may end up being transmitted on TRX0/C0.
In this case, we must not apply per-lchan attenuation, because
the BTS shall maintain constant power level on that TRX.

Change-Id: Id171df70447283b00da965e1f81dfac20e35495c
Related: SYS#4918
2020-12-01 21:39:55 +00:00
Philipp Maier 7c87612b42 l1sap: add repeated uplink SACCH
3GPP TS 44.006, section 11 describes a method how the uplink
SACCH transmission can be repeated to increase transmission
reliability.

Change-Id: I7e4cc33cc010866e41e3b594351a7f7bf93e08ac
Related: OS#4795, SYS#5114
2020-11-28 22:35:12 +01:00
Philipp Maier a36d6832a1 l1sap: add repeated downlink SACCH
3GPP TS 44.006, section 11 describes a method how the downlink
SACCH transmission can be repeated to increase transmission
reliability.

Change-Id: I00806f936b15fbaf6a4e7bbd61f3bec262cdbb28
Related: OS#4794, SYS#5114
2020-11-27 16:02:45 +01:00
Philipp Maier 7e38cf4e66 l1sap: also include SRR bit in RSL l1 info field.
The SRR bit, which got specified in 3gpp release 6 to support repeated
ACCH capability is not yet included in the L1 Information IE on RSL
level. Also lets update the spec reference to more modern 3gpp spec ref
numbers.

Change-Id: I987c61608b737521ba36756dabf2f6215b34c2d6
Related: OS#4796 SYS#5114
2020-11-27 16:02:45 +01:00
Philipp Maier 33dfe2bcec l1sap: add repeated downlink FACCH
3GPP TS 44.006, section 10 describes a method how the downlink
FACCH transmission can be repeated to increase transmission
reliability.

Change-Id: I72f0cf7eaaef9f80fc35e752c90ae0e2d24d0c75
Depends: libosmocore I6dda239e9cd7033297bed1deb5eb1d9f87b8433f
Related: OS#4796 SYS#5114
2020-11-27 16:02:45 +01:00
Neels Hofmeyr def24f0d9a part 5 of: fix SAPIs for handover, osmo-bts-oc2g
Change-Id: I2f1fd6e4620eec198912148cdc59fb4f02786c4d
2020-11-26 09:22:38 +00:00
Neels Hofmeyr 4ee4d6be2a part 4 of: fix SAPIs for handover, osmo-bts-lc15
Change-Id: I2ac6b0d498edb8facfac4feea7fccbba725d16e8
2020-11-26 09:22:38 +00:00
Neels Hofmeyr 6158525433 part 3 of: fix SAPIs for handover, osmo-bts-trx
Change-Id: I0b34855f0374e9ee7071ce14c1472eb3ead50970
2020-11-26 09:22:38 +00:00
Neels Hofmeyr 1c05ef15ec part 2 of: fix SAPIs for handover, osmo-bts-sysmo
Change-Id: I30e2ca003a3b15766d9d9dcf529fb2157523758f
2020-11-26 09:22:38 +00:00
Neels Hofmeyr f733cf8263 part 1 of: fix SAPIs for handover to match 48.058 4.1.{3,4}
This part adds the common lchan flags to indicate whether DL SACCH
should be activated.

Note that currently, osmo-bsc *always* sends the MS Power IE as well as
the TA IE, also for inter-cell HO, so in the osmoverse, nothing will
change until we also adjust osmo-bsc. See OS#4858.

Change-Id: Ibea973ccadf5d424213f141f97a61395856b76de
2020-11-26 09:22:38 +00:00
Neels Hofmeyr da680071a6 rename to release_sapi_ul_rach(), simplify
The sapis_for_ho have only one member, so it's silly to iterate. A
subsequent commit will drop sapis_for_ho.

Change-Id: I896fbca9876fd274ff9c426250b18b50faebfa89
2020-11-26 09:22:38 +00:00
Pau Espin 090f1cebe8 lc15-mgr: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: I6ddc04c5815858c7dfab04ffdac52bce2e7940a1
Fixes: OS#4865
2020-11-25 20:21:21 +01:00
Pau Espin 44d72333ad oc2g-mgr: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: I7a5756e106ac1061d37b42c22cc127fdacd87ce7
Fixes: OS#4865
2020-11-25 19:07:49 +01:00
Pau Espin 28d0a1db79 sysmobts-mgr: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: I35ae930b59c48892e5ad9a2826e05d6c5d415abc
Fixes: OS#4865
2020-11-25 19:05:25 +01:00
Pau Espin 48ffeb8139 common: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: Ic3b7c223046a80b51f0bd70ef1b15e12e6487ad0
Fixes: OS#4865
2020-11-25 19:03:35 +01:00
Pau Espin 251fc3c06c common: Enable SIGABRT signal handler
The signal handler function was coded to expect SIGABRT but the signal
handler itself was never enabled for this signal.

Change-Id: Id95d64efe8765fcf19eb09cd3db7895166c6adab
2020-11-25 19:02:55 +01:00
Philipp Maier 2edf5cf47f l1sap: pre-initalize pointer with NULL to avoid gcc warning
Change-Id: Ibfd18ed5268740cc73fffdb950b96c7f0fad3164
2020-11-19 17:32:16 +01:00
Vadim Yanitskiy ef1671c6ed osmo-bts-lc15: use consistent name for containing directory
The binary is called 'osmo-bts-lc15', while the containing folder
is named 'osmo-bts-litecell15'.  This inconsistency complicates
automatic generation of the XML VTY reference - fix it.

Change-Id: I55c073fbd01aee42871101401d76d87e7c91832e
Related: SYS#4937, OS#3036
2020-11-05 03:39:50 +07:00
Vadim Yanitskiy 44d25af9cd main: do not print asciiart to stdout, use stderr instead
Otherwise it ends up in the generated XML VTY reference:

  $ head doc/manuals/vty/bts_trx_vty_reference.xml
    ((*))
      |
     / \ OsmoBTS
    <vtydoc xmlns='urn:osmocom:xml:libosmocore:vty:doc:1.0'>
      <node id='_common_cmds_'>
        <name>Common Commands</name>

Also, take a chance to move it below handle_options(), so it
will only be printed if all arguments are parsed successfully.

Change-Id: I5c35f36fdd2a8a80bd501b996f0b161c388d3510
Related: SYS#4937, OS#3036
2020-11-04 19:33:57 +00:00
Vadim Yanitskiy ffbe63f408 fixup: vty: call bts_model_vty_init() from bts_vty_init()
Now bts_model_vty_init() must be called only once, otherwise the
process would crash when bts_model_init() is called from main().

Change-Id: I262c39896b5db86c54ad9aa7042c7ca6657815d9
Related: SYS#4937, OS#3036
2020-11-03 05:44:28 +07:00
Vadim Yanitskiy 5c7b709027 vty: call bts_model_vty_init() from bts_vty_init()
Similar to bts_vty_init(), BTS specific bts_model_vty_init()
requires a pointer to 'struct gsm_bts'.  Not only it's used
as a parent talloc context, but also stored locally, so then
it can be used by some VTY commands.

Let's expose the global 'struct gsm_bts' from main, and pass
the application's talloc context like was done in [1].

This finally makes the BTS model specific options appear in
the automatically generated VTY reference (--vty-ref-xml).

[1] Ic356a950da85de02c82e9882a5fbadaaa6929680

Change-Id: Iee7fee6747dd1e7c0af36f9b27326f651ae37aaf
Related: SYS#4937, OS#3036
2020-11-02 18:08:24 +00:00
Philipp Maier 484952a3e5 measurement.c: fix integer overflow problem
The variables num_meas_sub_expect - num_meas_sub must not be subtracted
without prior checking. Depending on the input (which might be
errornous), num_meas_sub might be greater then num_meas_sub_expect. This
eventually leads into odd behavior, which can be difficult to debug.

Change-Id: I381cc637d1c125f279ccf88db114609946fe24fe
Related: OS#4799
2020-11-02 15:46:10 +01:00
Vadim Yanitskiy 90e01e47cb vty: fix missing / wrong documentation for some commands
Change-Id: Ie2f9e401c0f8f55307d98fa5afe5eb4182add43a
Related: SYS#4937, OS#3036
2020-11-02 12:34:54 +00:00
Vadim Yanitskiy 9076b3947b vty: fix double '%' in description of some commands
Command description is not a format string => no need to escape.

Change-Id: Ib2e339efccec1fc5416ab4b9460a27fa1f8e8044
2020-11-02 12:33:42 +00:00
Vadim Yanitskiy fa3e22bc17 main: move general options from bts_vty_init()
These are not BTS specific options, so register them in main().

Change-Id: Ib6be66537791d489cb709d4d653c4cb434896f77
Related: SYS#4937, OS#3036
2020-11-02 11:17:05 +00:00
Vadim Yanitskiy a72a0765a4 main: register VTY commands before handle_options()
Otherwise only those commands that are registered by libosmocore
appear in the generated XML VTY reference - change the order.

Instead of a pointer to 'struct gsm_bts', pass the application's
talloc context, as it's only used for dynamic command allocation.

Change-Id: Ic356a950da85de02c82e9882a5fbadaaa6929680
Related: SYS#4937, OS#3036
2020-11-02 11:16:59 +00:00
Vadim Yanitskiy 850607295c osmo-bts-trx/scheduler: fix comments related to FACCH/H and BFI
Change-Id: I1c1d81ba5a54946089da6c32b0d42141ffe71ed8
Related: OS#4799
2020-10-30 16:45:43 +07:00
Philipp Maier 07aa8927e1 measurement: fix expected number of measurements
The logic in measurement.c checks the amount of collected measurement
values. This is done for the total amount of measurements and the amount
of SUB blocks measurements.

The functions that return the expected number of measurement values
currently do not take into account that the mode of a TCH/F or TCH/H has
an effect on the number of expected SUB blocks. (In signalling channels
all blocks count as SUB). Also a TCH/H in signalling mode generates only
half the amount of measurements because the blocks in signalling mode
are sepreded over 6 bursts instead of 4. This also needs to be taken
into account.

Change-Id: I01c7b6cc908c647263ab88f6b6281c4732f88779
Related: OS#4799
2020-10-26 17:53:57 +01:00
Philipp Maier 79294134dd measurement: count all blocks as SUB for TCH/F in signalling mode
SUB frames exist only in voice (or CSD) channels. When a TCH/F is in
signalling mode, all blocks must be counted as SUB blocks. (for TCH/H
the current implementation is correct.)

Change-Id: I04be21200afa1d03afa0d7e476c66fa79cf42249
Related: OS#4799
2020-10-26 15:11:27 +01:00
Philipp Maier 44fc252381 sched_lchan_tchf: count measurements for FACCH/F only once
When the FACCH is generated (while in SPEECH mode), there is also a
fake speech indication handed up to l1sap.c. We must make sure that only
one of the two indications carry a measurement value, so lets invalidate
the measurement values (RSSI in particular) for the generated TCH
indication.

Change-Id: Ie3f2e620ba2a2ab2fecdbae627ef01c6128fce0b
Related: OS#4799
2020-10-26 15:11:27 +01:00
Vadim Yanitskiy 1325443dc3 main: add --vty-ref-mode, use vty_dump_xml_ref_mode()
Change-Id: I744520199ef448ff095d0fe703d79ac08f08f7fe
Depends: Ie2022a7f9e167e5ceacf15350c037dd43768ff40
Related: SYS#4910
2020-10-24 05:08:49 +07:00
Vadim Yanitskiy 91652c8dbe main: separate model-specific arguments in help
Change-Id: I9646a45d61153499ad3d580a03d930ed20e23cda
2020-10-24 05:08:42 +07:00
Vadim Yanitskiy 0b6e568d05 main: increase spacing between commands and description
Otherwise it's hard to fit new options with long names.

Change-Id: If9a418545abff6d22602ba07cfd4447f5ace7742
Related: SYS#4910
2020-10-24 05:00:33 +07:00
Vadim Yanitskiy c3a293fde1 main: do not print deprecated '-r' / '--realtime' in help
Change-Id: I516a71124a49f6d6adb6db939a91da07576e63e7
2020-10-24 04:42:53 +07:00
Philipp Maier 5f95a16ec1 cosmetic: add missing semicolon after OSMO_ASSERT()
Change-Id: Ib886115418939990ecfb6ecc1a4528f7a015b913
2020-10-23 21:46:35 +02:00
Pau Espin 4d7c6ad860 oml: Set NM_OPSTATE_DISABLED by default
Otherwise, some objects are announced at startup of osmo-bts towards BSC
during State Changed Report as being "NULL".

According to TS 12.21:
"NULL(Operat. state not supported) FF"

Which doesn't make much sense in startup situation. They are in known
state Disabled until they are OPSTARTed.

Change-Id: I5ba6756ea069d0f995f453ee4b27e6839c914eb1
2020-10-21 18:32:08 +02:00
Pau Espin 26cc8580f6 bts_trx.c: Dispatch missing NM_EV_RSL_UP/DOWN to the bb_transc object
Previous commit 7810a91733 forgot to
introduce this line, though it was planned to be there.

Most of the time it worked fine anyway because the RSL link is not the last
event bb_transc waits for before switching to Enabled, so later events
would trigger inside the bb_transc fsm a recheck (polling) which wuld
allow to advance to Enabled state.
However, in the situation where RSL link UP is the last event to happen,
no more inside-FSM checks are triggered and hence BB Transeiver never
goes to Enabled state, and as a result no event is triggered towards
each RadioChannel which in turn don't go to Enabled state.

Fixes: 7810a91733
Change-Id: I8c777b946e7abcb4b607ec4d136c981a0716b120
2020-10-21 16:03:47 +02:00
Vadim Yanitskiy 6e27523d11 power_control: fix default EWMA smoothing coefficient (80% -> 50%)
80% (alpha=0.2) is clearly too much, let's use 50% (alpha=0.5).

Change-Id: Ib7aec6c7223ffb2d4a312eee77247925beb8c905
Fixes: Ib6dcadbf14ef59696c6a546bd323bda92d399f17
Related: SYS#4916
2020-10-20 22:42:24 +07:00
Pau Espin 22f59cd63a Introduce NM Channel FSM
Change-Id: I288cbfb4730b25a334ef1c3d6b9679d6f1d4cfc5
2020-10-20 13:45:57 +00:00
Pau Espin 7810a91733 Introduce NM Radio Carrier and Baseband Transceiver FSMs
All the Operative State logic to manage a RadioCarrier//BBTransc NM objects is
centralized in these FSM, where other parts of the code simply send
events to it.
This allows keeping state consistent and offloading logic from each bts
backend, since they are only required to submit events now.
The idea in the long run is to also replace other NM objects with
similar FSMs.

This improved logic fixes bug where PHY + RSL link became available before
OPSTART and hence op state changed to Enabled before receiving any OPSTART message.

Change-Id: Ifb249a821c4270918699b6375a72b3a618e8cfbe
2020-10-20 13:45:57 +00:00
Pau Espin ae6e3e8f8b Introduce NM BTS FSM
Change-Id: Iae631bcc7acdf955296b124707e42d5e565af186
2020-10-20 13:45:57 +00:00
Pau Espin 88fe4b079d Introduce NM BTS Site Manager FSM
This fixes old behavior mimicing broken behavior in nanoBTS (according to TS 12.21)
where BTS Site Mgr NM object was announced as Enabled despite no OPSTART
was sent by the BSC.
With this new FSM, BTS SiteManager will be announced as Disabled Offline
during OML startup conversation, instead of Enabled.

The new osmo-bsc OML management FSMs use this change in behavior to find
out whether it should use the old broken management states (without
Offline state, as per nanoBTS) or use the new state transitions (which
allow fixing several race conditions).

Change-Id: Iab2d17c45c9642860cd2d5d523c1baae24502243
2020-10-20 13:45:57 +00:00
Pau Espin 6d117891c9 Change NM Channel availability Dependency->Offline when RadioCarrier becomes enabled
This fix allows osmo-bts to play fine with newer osmo-bsc NM OML FSMs,
which expectes for non-nanoBTS types to follow TS 12.21 guidelines.
Until now, BSC simply waited to received State Event Change Dependency
for each TS and then sent all required commands (Set Chan Attr, Adm
Unlock and Opstart). In newer osmo-bsc FSMs, Opstart is only sent when
in Offline state, so we need to transit to that state. For the above
mentioned reason, since we pass through the Dependency state anyway
after this patch, older osmo-bscs will work correctly too.

Change-Id: Id9e61f8d773e6e6170c68b5b836d276c747d8d69
2020-10-20 13:45:57 +00:00
Harald Welte cf7a7fcebf remove dead oml_router code
We originally wanted to intrdouce an OML router which would permit
external proceses to implement certain OML MOs.  However, that code
was never completed, and all the existing implementation (in three
copies) does is to create a unix domain socket and discard what
is received there.

Change-Id: I7fcbbd5d6b64ddc666ca836dc49abb430be0d5cb
2020-10-19 18:17:36 +02:00
Harald Welte 629824ac14 use osmo_fd_setup() everywhere
Change-Id: I9be55f791a15fae2362dc431dc778b9b9d8db349
2020-10-19 15:06:08 +00:00
Vadim Yanitskiy 1b5b629624 scheduler: remove pending Tx prims on lchan deactivation
Sometimes the following messages appear in the logging output:

  TCH/F: Prim has wrong chan_nr=0xc5 link_id=00, expecting chan_nr=0x0d link_id=00
  TCH/F: Prim has wrong chan_nr=0xc2 link_id=00, expecting chan_nr=0x0a link_id=00

when a dynamic timeslot is switched from PDCH to TCH/F (or to TCH/H).

This means that the transmit queue of a timeslot still contains
PDCH frames, that were not properly cleaned on PDCH deactivation.

Let's finally do this in trx_sched_set_lchan().

Change-Id: Ic6560c660c658f36b84e7efa2f1d93e3a870962b
Related: SYS#5108, OS#4804
2020-10-19 15:04:22 +00:00
Vadim Yanitskiy debfbb6965 scheduler: join conditions in trx_sched_set_lchan()
Change-Id: If2b68e3c7bf01badaaa4666198a4a4c5709f0040
2020-10-19 15:04:22 +00:00
Vadim Yanitskiy 4cc38b8a72 scheduler: treat subsequent lchan (de)activation as error
Trying to (de)activate logical channels that are already (de)activated
is not something that we normally expect.  Treat this as error.

Change-Id: I6256280cae35b2b4d7a8ba4b3913ca69cde22611
2020-10-19 15:04:22 +00:00
Vadim Yanitskiy 2e28b3859d scheduler: reduce nesting in trx_sched_set_lchan()
Change-Id: I476dabb059325058a4327bb96430ce6ade199580
2020-10-19 15:04:22 +00:00
Vadim Yanitskiy fc1976e1a0 scheduler: get rid of useless TRX_CHAN_FLAG_PDCH
Change-Id: I951ec9b02be674936fbd0bf2e75b004813e25197
2020-10-19 15:04:22 +00:00
Vadim Yanitskiy 66be4b6785 scheduler: drop redundant check in trx_sched_set_cipher()
In this function we already do check that a given timeslot is not
a PDCH slot, so checking if TRX_CHAN_FLAG_PDCH is redundant.

Change-Id: Ie73bdaf0f6bc76ed8d2e95d1fb995333bf617e7e
2020-10-19 15:04:22 +00:00
Vadim Yanitskiy 46aa8465be scheduler: drop meaningless check in trx_sched_set_lchan()
Both TRXC_PDTCH or TRXC_PTCCH are described in 'trx_chan_desc'
(defined as 'const'), and both have TRX_CHAN_FLAG_PDCH set. So
indeed, this condition can never be true.

Change-Id: Ie185a939b48eb859ac1c8ffa0a4f667fda0cb82b
2020-10-19 15:04:22 +00:00
Vadim Yanitskiy 68323527e7 scheduler: use RSL_CHAN_NR_MASK in trx_sched_set_cipher()
Change-Id: I26fb115ce0a7c33453b05c8fcee8a21d1a2a97d5
2020-10-19 15:04:22 +00:00
Vadim Yanitskiy bdea34165b power_control: tolerate small deviations from 'rx-target'
Recently we've introduced EWMA based uplink power filtering, that
should reduce Uplink power oscillations.  However, the power loop
is still quite sensitive to small deviations from the target power
level: even such an insignificant deviation like 2-5 dBm triggers
the loop to increase or decrease the MS power level.  Even if the
EWMA based filtering is enabled with 80% smoothing (alpha = 0.2).

This change introduces a new configuration parameter - 'hysteresis':

  uplink-power-target <-110-0> hysteresis <1-25>

that together with the 'uplink-power-target' defines a range:

  [target - hysteresis .. target + hysteresis]

in which the MS power loop would not trigger any power changes.

This feature is now *enabled* by default, so given that:

  - default 'uplink-power-target' is -75 dBm, and
  - default 'hysteresis' is 3 dBm,

the default target Uplink power range is: -78 dBm ... -72 dBm.

Change-Id: Iacedbd4d69d3d74e2499af5622a07a8af0423da0
Related: SYS#4916
2020-10-19 17:30:33 +07:00
Vadim Yanitskiy 284e4c4437 power_control: do nothing if 'rx-current' equals 'rx-target'
It makes no sense to do further calculations if the actual Uplink
signal strength equals the target value configured in the VTY.

Change-Id: Id99c7013a722403e773df8367b1a9d7a856e639b
Related: SYS#4916
2020-10-19 17:29:46 +07:00
Vadim Yanitskiy 17fd344249 measurement: use LOGPLCHAN() macro in lchan_meas_check_compute()
Change-Id: Ia73fd766ddce3fd03d0f45b72cb2d056fae781fc
2020-10-18 18:26:12 +07:00
Vadim Yanitskiy 79eab9689f measurement: remove redundant 'break' statements in modulus_by_lchan()
Change-Id: I24597dbdaa692f855be014c536f5758b8e503688
2020-10-18 18:26:12 +07:00
Vadim Yanitskiy e20baa31bf scheduler: use RSL_CHAN_NR_MASK in trx_sched_set_lchan()
Change-Id: I3dd2c90f510444cda38516bd9a1a207877bebadc
2020-10-17 15:07:33 +07:00
Vadim Yanitskiy cf2226093f scheduler: _sched_dequeue_prim(): make 'l1sap' a scoped pointer
Change-Id: Ia2d1098e25d0bbe39fd7e98eb7c96d43a32073df
2020-10-17 15:07:33 +07:00
Vadim Yanitskiy 52aa451ae2 scheduler: ensure PRIM_OP_REQUEST when adding to the queue
Change-Id: I709ba2394862fcb0f86484792b5f8d3b338b42cc
2020-10-17 15:07:33 +07:00
Vadim Yanitskiy ae09c8acb4 fix pcu_if_signal_cb(): do not send INFO.ind if PCU is not connected
Sending INFO.ind unconditionally in pcu_if_signal_cb() provokes
a lot of warnings during OML bootstrapping / termination:

  DPCU INFO pcu_sock.c:247 Sending info
  DPCU INFO pcu_sock.c:262 BTS is up
  DPCU INFO pcu_sock.c:205 (bts=0,trx=0) unavailable for PCU (op=Disabled adm=Unlocked)
  DPCU INFO pcu_sock.c:205 (bts=0,trx=1) unavailable for PCU (op=Disabled adm=Unlocked)

Do not call pcu_tx_info_ind() if the PCU is not connected.

Change-Id: If8bc8bec5ad808be8d40e91278a4a4fde84920b0
2020-10-16 19:43:14 +07:00
Vadim Yanitskiy 967bca7b9e power_control: implement EWMA based Uplink power filtering
So far the Uplink power control loop did not filter the Uplink RSSI
measurements (reported by the BTS) at all.  The lack of filtering
makes our implementation too quick on the trigger, so in the real
deployments there will be unneeded Tx power oscillations.

In order to reduce this effect, let's implement a very simple EWMA
(also known as Single Pole IIR) filtering that is defined as follows:

  Avg[n] = a * Pwr[n] + (1 - a) * Avg[n - 1]

where parameter 'a' determines how much weight of the latest UL RSSI
measurement result 'Pwr[n]' carries vs the weight of the average
'Avg[n - 1]'.  The value of 'a' is usually a float in range 0 .. 1, so:

  - value 0.5 gives equal weight to both 'Pwr[n]' and 'Avg[n - 1]';
  - value 1.0 means no filtering at all (pass through);
  - value 0.0 makes no sense.

This formula was further optimized with the use of '+=' operator.
The floating point math was also eliminated by scaling everything
up (by 100).  For more details, see:

https://en.wikipedia.org/wiki/Moving_average
https://en.wikipedia.org/wiki/Low-pass_filter#Simple_infinite_impulse_response_filter
https://tomroelandts.com/articles/low-pass-single-pole-iir-filter

The EWMA filtering is now *enabled by default*, but can be disabled
or (re-)configured over the VTY at any time:

  ! Completely disable filtering
  no uplink-power-filtering

  ! Enable EWMA smoothing with the given parameters
  uplink-power-filtering algo ewma beta <1-99>

Note that the VTY command expects 'beta' instead of 'alpha':

  alpha = (100 - beta)

and the value must be in %.  This is done for simplicity:

  1% means lowest smoothing,
  99% means highest smoothing.

Let's say we have EWMA filtering enabled with alpha = 0.4, and get
-98 dBm on the input, while the last output value was -60 dBm.
The new output would be:

  Avg[n] = 0.4 * Pwr[n] + 0.6 * Avg[n - 1]
  Avg[n] = (0.4 * -98) + (0.6 * -60)
  Avg[n] = -75.2 => around -75

Of course, this is not a silver bullet, but better than nothing.

Change-Id: Ib6dcadbf14ef59696c6a546bd323bda92d399f17
Related: SYS#4916
2020-10-15 19:46:11 +07:00
Harald Welte 9a7acc1744 sysinfo: Don't broadcast SI4 GPRS INDICATOR if PCU is disconnected
Depends: libosmocore.git I9d6ed06731ae15fdcef1a1f397d6ac2b7b1ca980
Change-Id: I1fd513ea03297918d15d4b28ed454f9b6dd6ebfa
Related: OS#3075
2020-10-15 11:29:29 +00:00