Commit Graph

85 Commits

Author SHA1 Message Date
Vadim Yanitskiy fbd9aaca66 measurement: pass *mr to lchan_bs_pwr_ctrl()
As a side effect, we have to sacrifice a unit test (TC_inval_dummy)
because it becomes impossible to pass a dummy or invalid SACCH block
to lchan_bs_pwr_ctrl().

Change-Id: I937117cf26fb718d57920382f6972390ad498c51
Related: SYS#4918
2021-11-04 15:46:04 +03:00
Vadim Yanitskiy e714406632 measurement: pass *mr to repeated_dl_facch_active_decision()
Change-Id: Idbf5f95d632aa2270c49b351ad5561ca2182bf9a
Related: SYS#5114
2021-11-04 15:46:04 +03:00
Vadim Yanitskiy 81a4b3c090 measurement: get rid of *le in lchan_meas_handle_sacch()
The current Timing Advance value can be obtained either from the
L1 SACCH header (if received) or from lchan->ta_ctrl.current.

Change-Id: I2b3693a0e49f03f2b4496c9dbd30cf47e9bc86b5
2021-11-04 15:46:04 +03:00
Vadim Yanitskiy 110ec15fe9 lchan_meas_handle_sacch(): check if Measurement Result is valid
We should not rely on measurement data marked as invalid.

Change-Id: I4aaac742674ce3ac15e9a4a32fe7c72db81d32d2
2021-11-04 15:46:04 +03:00
Vadim Yanitskiy c13b325877 l1sap: rework handling of DATA.ind on SACCH
Currently an Uplink SACCH block is being passed to LAPDm first, and
then gets forwareded to the BSC in handle_ms_meas_report(), together
with the Uplink measurements collected so far.

This approach has a serious flaw: handle_ms_meas_report() won't be
called if an Uplink block contains SAPI=3 data (SMS) or was not
decoded at all (len=0) fow whatever reason.  Therefore, no RSL
MEASurement RESult message will be sent to the BSC.

Rename handle_ms_meas_report() to lchan_meas_handle_sacch(), and call
it from l1sap_ph_data_ind().  This way perioduc RSL MEASurement RESult
messages will be sent regardless of what happens on Uplink SACCH.

Change-Id: Ifed91f87fd653debc87a09da3fd31ad64a13f330
Fixes: TC_meas_res_speech_{tchf,tchh}_sapi3
Related: SYS#5319
2021-11-04 15:46:04 +03:00
Vadim Yanitskiy df6e4533dd measurement: fix wrong operator used in handle_ms_meas_report()
Change-Id: Iad781dde0406d341bf385734ceddf51999558dd3
Fixes: CID#240263
2021-10-23 01:18:27 +03:00
Vadim Yanitskiy e0154aa09b struct gsm_lchan: group ACCH repetition state fields
Change-Id: I2680c88f2a51b64f085a92233bc125338622babf
Related: SYS#5114
2021-10-22 02:53:00 +03:00
Vadim Yanitskiy ea0247e26c cosmetic: s/repeated_acch_capability/rep_acch_cap/g
Shorter symbol names are easier to read.

Change-Id: Ib1d51f91139b4c2fe794e37fc8543b2d7a9b9c07
Related: SYS#5114
2021-10-22 02:52:28 +03:00
Vadim Yanitskiy dffb6fac25 measurement: make sure that DL measurements are valid
In repeated_dl_facch_active_decision() we rely on the Measurement
Report message, that in some cases may not contain valid Downlink
measurements.  In this case, we should simply ignore it.

Change-Id: I0d72b454f2b770d5762303fb70a15a8cdc9d07d7
Related: SYS#5114
2021-10-22 02:51:36 +03:00
Vadim Yanitskiy 45094096b1 measurement: move repeated_dl_facch_active_decision() here
For the sake of consistency, call repeated_dl_facch_active_decision()
from handle_ms_meas_report(), so we have all functions using the
measurement results for Downlink executed in a single place.

Change-Id: Ibd5377ce642e49161f320ac8c33e9f966b3ddfaf
Related: SYS#5114, SYS#5319
2021-10-22 02:51:36 +03:00
Vadim Yanitskiy 31637b4673 measurement: handle_ms_meas_report() accepts const gh
Change-Id: Iba37c1a92b8b17a8ba8c958fb6c296747578cb1b
2021-10-22 02:51:36 +03:00
Vadim Yanitskiy 5fa08dee72 fix handle_ms_meas_report(): properly count measurement reports
Each RSL MEASurement RESult message contains a Measurement Number
IE, which is basically a monolithically increasing number.  We
shall not increase this counter if for whatever reason the report
has not been sent to the BSC.

Change-Id: I441adb4b202e94ddee8c0b6777849e36ea644b1d
Fixes: Id67259ec9ac4c2c33bd0eef3f64450affbe3fb9f
Fixes: OS#5243
2021-09-30 11:36:47 +00:00
Pau Espin 0468376c53 Move TA & Power Loops further up the stack, take DTXu flag into account
Only once we receive the Measurement Result on L3 from MS we are able to
find out whether DTXu was used, and hence whether SUB or FULL
measurement set should be used.

Let's move all control loops there to have them in one place together,
and have it at a similar level where it would lay if it was to be
implemented in the BSC.

Related: SYS#4917
Change-Id: Ic152473577ff7c33d30b3f4ee7e321fcb523f723
2021-09-28 12:02:15 +02:00
Pau Espin 3871c1ff0c Decouple handling of Measurement Report from lapdm
This is a preparation commit in order to move power loops up in the
stack in order to have DTXu information available, in order to decide
whether SUB or FULL ul measurements should be used in the MS Power
Control Loop.

Function rsl_tx_meas_res() is stripped from code changing state, and it
simply encodes content and transmits the message.

Change-Id: Id67259ec9ac4c2c33bd0eef3f64450affbe3fb9f
2021-09-28 12:02:03 +02:00
Pau Espin c80abd109b MS Power Control Loop: Feed UL C/I from correct measurement period
As per 3GPP TS 45.008 sec 4.2, the ms_pwr received in L1 SACCH Header is
the value used over previous measurement period. Hence, we need to feed
the algo with the measurements taken over that same period.

Related: SYS#4917
Change-Id: I13c0014fdd73f823ae5b1256c35bfa7d97cfa334
2021-09-13 17:52:24 +02:00
Pau Espin f21b9231dd TA loop: Take into account UL SACCH 'Actual Timing advance' field
First step improving and reworking TA loop:
Move trigger of the loop to similar place done by BS/MS Power Control
Loop, that is, upon receivial of UL SACCH block, which contains
information about the TA used to transmit the block encode in L1SACCH
Header. Hence, from computed received TOA and TA used when transmitting
from the MS, we can infer the desired TA to be used by the MS, which
will send back to it later during DL SACCH block.

The values taken are actually the ones calculated for the previous SACCH
block and stored in lchan->meas.ms_toa256. That's because L1SACCH
contains the TA used for the previous reporting period, similarly to
what's specified for MS Power Control loop (TS 45.008 sec 4.2):
"""
The MS shall confirm the power control level that it is currently employing
in the SACCH L1 header on each uplink  channel. The indicated value shall
be the power control level actually used by the mobile for the last burst
of the  previous SACCH period.
"""
(The reader may observe that currently this is not properly done for MS
Power Control loop when calling lchan_ms_pwr_ctrl(): this is a bug.)

This new method also permits changing TA quicker, since we have more
confidence that the TA we request is aligned with the one used to
transmit, and we don't simply increment/decrement based on the value we
request to transmit.

Related: SYS#5371
Change-Id: I2d0f128c8dcac93ee382283a1c91fca76623b8fc
2021-09-13 12:25:32 +02:00
Pau Espin 746d0a7500 comsetic: measurement.c: fix typo in comment
Change-Id: I3ed3486bbc3d55088e3ebe27e4a76f932d6f7a59
2021-09-06 16:19:05 +02:00
Vadim Yanitskiy 43adbe200c measurement: remove over-defensive checks in is_meas_complete()
The timeslot number ts->nr is set in gsm_bts_trx_alloc() and can
never be greater than 7.  Regarding the physical channel type
returned by ts_pchan(), it's also unlikely to be greater than
_GSM_PCHAN_MAX.

Change-Id: I6d20d7cba49cc8b6d1dc2192598ca372b7d2c5bf
2021-06-09 20:20:42 +00:00
Vadim Yanitskiy d37041b1ea ta_control: make 'struct bts_ul_meas' parameters const
The only reason why it was not 'const' is that in lchan_new_ul_meas()
we may need to overwrite 'ulm->is_sub'.  This can still be done after
memcpy()ing a new set of samples to the destination buffer.

Change-Id: I0cabf75f8e0bf793c01225a4a8433e994c93f562
Related: OS#5024
2021-02-15 10:58:54 +00:00
Oliver Smith 23ff5f8861 common/measurement.c: fix gcc 4 + -std=gnu11 error
GCC-4 doesn't like static const struct foo bar = (struct foo)...:
  measurement.c:33:1: error: initializer element is not constant

Related: OS#5004
Change-Id: Iec5a4006dfc90abe240fcf8b6c2fefd4f7071a70
2021-02-02 13:33:04 +01: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
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 5f95a16ec1 cosmetic: add missing semicolon after OSMO_ASSERT()
Change-Id: Ib886115418939990ecfb6ecc1a4528f7a015b913
2020-10-23 21:46:35 +02: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
Alexander Couzens d5107c0583 measurement: replace u_int64_t with uint64_t
Be consistent and use everywhere uint64_t.

Change-Id: Id6b5df7f5045901109fe1007a5ad54e2f95b95f8
2020-07-14 08:37:33 +00:00
Philipp Maier 59e7773055 measurement: expect at least 1 SUB frame for AMR
The amount of SUB frames that may occur in AMR is not fixed, nor can it
be determined by some formular or lookup table. The reason for this is
that the DTX period may negotiated dynamicly. This means that the lower
layers must make the decision if an AMR sub frame is a SUB frame early
and tag the repective measurement / frame they hand up to the upper
layers accordingly. However, regardles of the occurrence of DTX periods
the amount of SUB frames in AMR must be always 1 or more because SACCH
frames always count as SUB frames as well. Lets make sure that this is
respected in the debug log as well as in the logic that tries to
substitue missing SUB frame measuremnets.

Change-Id: I1fd91b576ff7274caa6d4356bcd7a4fa4311219d
Related: OS#4465
2020-05-16 20:22:48 +00:00
Philipp Maier ee320d5b36 measurement: make measurements more debugable
A debug line is printed whenever a measurement is added and it also
displays if the added measurement is a sub frame or not, lets display
all the other properties too, especially inv_rssi would help a lot as it
shows us the rssi values which are reported by the lower layers

Related: OS#2978
Change-Id: I0299b75e99661e8dd22ad6604a897db4533c3b2b
2020-05-06 19:39:00 +00:00
Philipp Maier 78a1d3a31a measurement: remove unecessary is_amr_sid_update parameter
The function ts45008_83_is_sub rougly decides if a frame is a SUB frame
or not. This works by checking the frame number against against lookup
tables. This works fine for codecs where the occurrence of SUB frames is
fixed. However for AMR this is not the case as the DTX periods are
dynamic. Here it is the responsibility of the lower layers (phy,
frame decoding) to tag SUB frames early since making the decision later
based on the frame number is not possible.

The parameter is_amr_sid_update was probably added as a placeholder. It
is set to falls by the callers of the function. Lets remove this
parameter as a late decision if an AMR frame is a SUB frame will never
work.

Change-Id: I125d5ff592218a9e98130a6a7b6bbc6378ce4132
Related: OS#2978
2020-04-25 14:03:06 +00:00
Philipp Maier 8969adc5d9 measurment: write irssi_full_sum variable correctly
The variable irssi_full_sum is not populated with a dummy value when we
are not able to compute irssi_full_sum. Instead we mistakenly write
MEASUREMENT_DUMMY_IRSSI to ber_full_sum, which is wrong

Change-Id: I44d7cb48e3c68ab1b48c78cceb9381ce3e39d7e8
Related: OS#2987
2020-01-20 14:33:51 +00:00
Philipp Maier a0403d3769 ta_control: move timing advance code from osmo-bts-trx to common
The timing advance controller that is implemented in loops.c of
osmo-bts-trx only works for osmo-bts-trx and not for any of the phy
based bts. Lets move the timing advance controller into the common part
and make it available for every bts. Also lets add a unit-test.

Change-Id: If7ddf74db3abc9b9872abe620a0aeebe3327e70a
Related: SYS#4567
2020-01-20 14:33:49 +00:00
Michael McTernan b54f1bf122 measurement: use signed integer for division of ta256b_sum
The variable ta256b_sum is int32_t and num_ul_meas_actual is unsigned
int. When ta256b_sum is negative the division produces the wrong result.

This is beacuse the division is performed unsigned as the usual
arithmetic conversions promote to unsigned where both both operands are
the same width.

Lets fix this by casting num_ul_meas_actual to signed.

(Note that in the same function there are various other averages
computed in the same pattern, but they have unsigned operands and so are
correct.)

Related: SYS#4728
Change-Id: I37e3f69109c5ca2948bd4cdb7aa017bf2fcb8172
2020-01-06 12:07:23 +01:00
Martin Hauke b378fccef1 Fix common misspellings and typos
Change-Id: I403b9029f57fec3fdec2c1e2cbeac0f6eab53f24
2019-10-17 08:05:35 +00:00
Pau Espin 84f3ec644a lchan_meas_check_compute: Log value during incorrect num of SUB measurementes detected
Change-Id: I5dacbed5517b2aa2a6bbc66ec125f0bdfd1f5b2b
2018-10-10 13:29:27 +02:00
Philipp Maier 27a86005f3 measurement: fix unit-test test_lchan_meas_process_measurement
The unit test that tests lchan_meas_process_measurement() only inputs
test data to lchan_meas_process_measurement() but it is not checked if
the interval end could be detected or not.

- Add a return code to lchan_meas_process_measurement()
- Ensure that the return code is checked in the unit-test

Change-Id: I9e00ce683e8c44528804f65181dbfed9e85e3aed
Related: OS#2975
2018-09-13 14:27:12 +00:00
Philipp Maier c78759055a measurement: remove missed interval end detection
The function is_meas_overdue() was introduced to allow
lchan_meas_process_measurement() to detect when the end of a measurement
interval has been missed. Interval ends may be missed when the SACCH
block of the related measurement interval gets lost. This is due to the
fact that the SACCH block is used as a trigger to start the measurement
result computation.

The idea behind is_meas_overdue() was to check the frame number of the
current measurement against the frame number of the previous measurement
in order to see if there was a measurement for SACCH in between or not.
Unfortunately SACCH and TCH Voice data is not necessarly processed in
order by each phy. Depending on the phy there may be a jitter between
the timing of SACCH and TCH Voice. Depending on the phy this jitter may
be enough to mess up the timing so that we see a SACCH block earlier
than expected. So we can not use the current frame number of TCH Voice
measurements to check for missed SACCH blocks.

Change-Id: Idfdbf64c1f965f35c12559b3995e2b746c74ee9e
Related: OS#3502
Related: OS#2975
2018-09-13 14:27:12 +00:00
Philipp Maier 6d701d0e05 cosmetic: fix typo in comment
Change-Id: I6a1147e2a3858475c99c99ceb33d7d416f3cac6c
2018-09-13 14:27:12 +00:00
Philipp Maier 0b6c1762c5 measurement: display fn_mod when measuremnet is added
When adding a new measurement also log the frame number by the modulus
of the measurement interval to simplify debuggung

Change-Id: I77a4d947dab32de0d5717ebf13bd8de6179dfe6a
2018-09-06 12:33:03 +02:00
Philipp Maier 9680a4746f measurement: substitue missing measurements
At the moment the measurement calculation of osmo-bts works by
collecting the measurement reports the phy emits during a measurement
interval. Normally one would expect a well defind fixed number here, but
some phys will not emit a measurement report for lost blocks. Also
blocks and their reports may get lost because of cpu overload etc.

The computation that is executed at the end of the measurement interval
computes over all received measurement. This evenutally means that
missing measurements will not taken into account and the result will
look better than it is in reality.

To fix this, the interval must be of a defined size and in cases where
less measurements as expected were collected, the algorithm must assume
they have been received with a 100%BER and take that into account.
However, all RSSI and TA/TOA related computations should continue to
rely on actual measurement data.

- make sure the algorithm works over a fixed interval
- replace missing measurements with 100%BER
- fix and extend unit-tests

Change-Id: Idd30fc07603ad7d042c1fb416e247c3bf7d35c8b
Related: OS#2987
2018-08-30 09:12:59 +02:00
Philipp Maier 42495a156d cosmetic: rename *_meas_rep_fn10* to *_meas_rep_fn10*_by_*s
The lookup table that control the measurement interval endings do not
make clear what their indexes refer to. Lets give them more distinct
names.

rename sdcch8_meas_rep_fn102 to sdcch8_meas_rep_fn102_by_ss
rename sdcch4_meas_rep_fn102 to sdcch4_meas_rep_fn102_by_ss
rename tchf_meas_rep_fn104 to tchf_meas_rep_fn104_by_ts
rename tchh0_meas_rep_fn104 to tchh0_meas_rep_fn104_by_ts
rename tchh1_meas_rep_fn104 to tchh1_meas_rep_fn104_by_ts

Change-Id: I3dc891e1860109f803c1bfa46445e8fef35586d9
Related: OS#2975
2018-08-29 17:04:59 +00:00
Philipp Maier 324a3cd66e measurement: fix is_meas_overdue() and increase testcoverage
The tests TC_meas_res_sign_sdcch4 and TC_meas_res_sign_sdcch8 are
failing mainly because lchan->ts->nr is confused with lchan->nr.
There is also a small problem with one of the formulas that compute
fn_missed_end.

- Add explainatory comment to the lookup tables on what the index
  is refering to
- use lchan-nr instead of lchan->ts->nr when dealing with SDCCH/4/8
- simplfy and fix the formula
- increase the testcoverage of the unit tests, give SDCCH/4/8 also
  a thorough check.

Change-Id: I5d555a21003943bf720c53f3a611029ba45339a9
Related: OS#2975
2018-08-29 17:04:59 +00:00
Philipp Maier 9b41b36e97 measurement: add unit tests for ts45008_83_is_sub()
The function ts45008_83_is_sub() is an integral part of the measurement
calculation as it automatically tags incoming measurements as SUB
measurements. This is important in the context of DTX. Unfortunately
there is no unit test for this function yet.

- Add unit test for ts45008_83_is_sub()

Change-Id: Ia26774859f4bf31baee075896905079368bddd42
Related: OS#3502
2018-08-29 17:34:49 +02:00
Philipp Maier 76c292ea5d measurement: fix sub frame table for TCH/H, SS1
The Table that lists the fn%104 frame number masks that define which of
the incoming measurements to be recognized as SUB measurements contains
one wrong number.

For comparison see also:
3GPP TS 05.08, chapter 8.3 Aspects of discontinuous transmission (DTX)

- Change 29 to 20 in ts45008_83_tch_hs1[]

Change-Id: Id3698551d94866f418e662b9fe81429b16e2621c
Related: OS#3502
2018-08-29 17:34:41 +02:00
Philipp Maier 510158256b measurement: add unit tests for is_meas_complete()
We do not test is_meas_complete() individually yet, but it is an
integral part of the measurement processings since this function decides
where a measurement interval ends.

- Add unit tests that test TCH/F, TCH/H, SDCCH/4 and STDCH/8

Change-Id: I8f89d9e7092cd65ba4d5c5649140692dcc20bdd6
Related: OS#2987
2018-08-29 07:35:57 +00:00
Philipp Maier 092e4e85b3 measurement: fix measurement interval end detection
for SDDCH4 channels, the detection is not working correctly since the
function uses the lookup table for SDCCH8 interval endings there. This
needs to be corrected. Also there are two unnecessary assignments in
the code which should be removed.

- use correct table (sdcch4_meas_rep_fn102 instead of
  sdcch8_meas_rep_fn102.
- remove unnecessary assignments to last_fn_mod

Change-Id: If8a269ecd3f9fa4eeadf379114db816ef5c77d77
Related: OS#2975
2018-08-22 19:52:14 +00:00
Philipp Maier 4553890d70 measurement: make sure measurement interval end is detected
the measurement interval end is detected by using the measurement
indication that is related to the SACCH block as a trigger to start the
computation. If the measurement indication for the SACCH gets lost
because the block could not be received then the processing is not
executed. This may cause wrong results or when it happens condecutively
an overflow of the measurement sample buffer.

- Store the frame number of the last received measurement indication
- Use the stored frame number to check if an interval was crossed when
  the next measurement indication is received. If we detect that we
  missed the interval, catch up by running the computation and
  start the next interval.

Change-Id: I3a86cd8185cc6b94258373fe929f0c2f1cf27cfa
Related: OS#2975
2018-08-20 18:27:28 +02:00
Philipp Maier 9feddb7edf measurement: make sure state is reset on chan act.
At the moment only lchan_meas_reset is reset on channel activation.
All other states are not reset. This may lead to irretations in the
first measurement interval if there are still leftover messages from
a previous connection. Lets ensure everything is reset to zero by
zeroing out the whole .meas struct in struct lchan.

- Add a centralized function that does the reset
- Call that function from rsl_tx_chan_act_ack() in rsl.c

Change-Id: I880ae3030df6dcd60c32b7144c3430528429bdea
Related: OS#2975
Related: OS#2987
2018-08-20 12:19:30 +02:00
Philipp Maier b5a28bd967 cosmetic: unify measurement sample handling in one function
In l1sap.c we call lchan_new_ul_meas() and lchan_meas_check_compute()
directly in sequence. Lets unify thos two steps inside measurement.c so
that we only need to call one function from l1sap.c.

Change-Id: If48bc7442dfaab8c36b93949f741de6e836e792a
Related: OS#2975
2018-08-17 16:24:26 +00:00
Harald Welte b7b5c4219c Add min/max/std-dev measurement reporting for TOA256
This patch adds extended processing of the high-resolution TOA256
measurement values.  It adds reporting of the following values
for each RSL MEAS REP for uplink measurements:
* minimum TOA256 value during reporting period
* maximum TOA256 value during reporting period
* standard deviation of  TOA256 value during reporting period

Change-Id: Iea4a4781481f77c6163d82dcd71a844a5be87bf2
2018-06-29 17:53:20 +00:00