Commit Graph

1719 Commits

Author SHA1 Message Date
Harald Welte 5bd6132c04 Add high-accuracy ToA value to Uplink Measurement Reports
Normal Abis RSL MEasurement Results contain only the "MS Timing Offset
IE" in units of full symbols.  In some use cases it is important to have
higher-accuracy timing information exposed to the BSC.

We do this by adding the average timing offset value during the last
measurement interval in 1/256th symbol accuracy to the "Supplementary
MEasuremen Information" part of the TS 48.058 9.3.25 Uplink Measurements
IE.

In order to avoid any compatibility issues, this feature is only enabled
if the new vty config command "supp-meas-info toa256" at the bts node
is enabled.

Change-Id: Ie85e53b47d4041cc4e6d7b78406ae8b79b2d9397
2018-02-27 20:00:16 +01:00
Harald Welte 916d508bf6 measurement: Keep average of high-accurate ToA value in lchan
At the end of a measurement processing window, we currently compute
the ToA / timing offset at 1/256th symbol accuracy, but we only print
it to the log.  Let's store the value in the lchan to make it usable
by other code in follow-up patches.

Change-Id: I5f00a16ac966b627d9452a98b8fa70984bed684a
2018-02-27 20:00:16 +01:00
Harald Welte acefd0586e L1SAP: Increase resolution of reported burst timing
Before this patch we had:
* osmo-bts-trx internally using 1/256th bit/symbol period
* osmo-bts-sysmo internally using 1/4 bit/smbol period
* PCU interface using 1/4
* L1SAP interface using 1/4
* measurement processing code on top of L1SAP using 1/256

So for sysmo/lc15/octphy we are not loosing resolution, but for
osmo-bts-trx we're arbitrarily reducing the resolution via L1SAP
only then to compute with higher resolution again.

Let's change L1SAP to use 1/256 bits and hence not loose any resolution.
This requires a corresponding change in libosmocore for l1sap.h, which
is found in Change-Id Ibb58113c2819fe2d6d23ecbcfb8b3fce4055025d

Change-Id: If9b0f617845ba6c4aa47969f521734388197c9a7
2018-02-27 20:00:16 +01:00
Harald Welte c092f4e1de measurement.c: higher-precision TA/TOA math
Change-Id: I0dc8e78545465dfc5c93691a49b86b6b8b56b432
2018-02-27 19:59:00 +01:00
Harald Welte d5bbd8ccf7 trx/scheduler: Use integer math for TOA (Timing of Arrival)
There's no need to express TOA as a float:
* We receive it as signed 16bit integer in units 1/256 symbol periods
* We pass it to L1SAP as signed integer in 1/4 symbol periods

So turn it into an int16_t with 1/256 symbol period accuracy throughout
the code to avoid both float arithmetic as well as loosing any precision.

Change-Id: Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec
2018-02-27 19:58:20 +01:00
Harald Welte b3a2a3e24f RACH decoding: Use BER threshold for RACH ghost detection
When decoding RACH bursts, we should use a BER threshold in order to
help distinguish 'ghost' RACH bursts from real RACH bursts.

The theoretical ideal threshold according to some papers is 7 out of 41
bits qhich aquals to Eb/N0 of 0 dB = 0.1707 (17.07%)

We add a new 'ber10k' parameter to the RACH indication l1sap primitive
(needs separate change for libosmocore), and then fill this value from
osmo-bts-{sysmo,lc15,trx,octphy}.  The common part above L1SAP then
applies the threshold, which can be changed from vty using the
	"max-ber10k-rach <0-10000>"
command available at the BTS node.  The unit is BER in 1/10000, i.e. a
value of 100 equals 1% bit error rate.

Change-Id: Ic41c11f6312a36baa2738547e8dcec80829457f8
2018-02-27 17:27:46 +01:00
Harald Welte c2b4c668f3 Move rach_busy counting above L1SAP
In the past, rach_busy counting was performed below L1SAP, while
reporting was handled above.  This lead to subtle differences between
the BTS models, such as osmo-bts-trx missing to increment rach_busy.

Let's move the rach_busy counting above L1SAP to share more code.

This means we need libosmocore Change-Id
I9439810c3a3ad89ea0302753617b850749af887c for the additional required
parameters in ph_rach_ind_param, as well as libosmocore Change-id
I2b1926a37bde860dcfeb0d613eb55a71271928c5 for osmo-bts-trx to determine
the RACH bit error rate.

Change-Id: I3b989580cb38082e3fd8fc50a11fedda13991092
Closes: OS#3003
2018-02-27 17:27:35 +01:00
Harald Welte b60d9e9464 scheduler: Add missing \n at end of LOG statement
Change-Id: I55419dfa884b4170dfed696a7e1334940a46ba82
2018-02-26 22:37:03 +01:00
Harald Welte 0d6c3e8110 measurement.c: Don't silently copy "FULL" measurements to "SUB"
The existing code contained an ugly hack that if we didn't have any
"SUB" measurements we would simply use the "FULL" values.  That's wrong
as TS 45.008 contains quite detailed rules on how the "SUB" values are
to be computed.  In some cases, they are identical to "FULL", but in
most they are not.

Let's remove the hack and replace it with an ERROR message, as clearly
something is wrong if we ever encounter a measurement period end in
which no single "SUB" measurement was received.  The only situation in
which this can occur is if the related uplink burst/block was missing,
so let's set BER to 100% and level to lowest possible.

Change-Id: I358f7b97fd4ea19264a77eff7abef13da7d5fbcd
2018-02-26 15:01:08 +01:00
Harald Welte 3a80a56b9b measurement: Compute RX{LEV,QUAL}-SUB for SDCCH and non-AMR TCH
The rules on how to compute RX{LEV,QUAL}-SUB are rather convoluted, and
depend on the detailed channel type and mode.

For SDCCH and TCH/H in signalling mode, it's easy: No DTX is allowed,
and all measurements are used in SUB.

For non-AMR (TCH/F and TCH/H in non-signalling mode), we need to count
the SACCH block measurements, as well as any
SID/SID_UPDATE/L3_FILL/DUMMY blocks received in the blocks of table
8.3 of TS 45.008.

Only AMR (TCH/AFS + TCH/AHS) are more difficult, as there are no fixed
blocks/bursts/frames that always contain uplink messages, but the L1
will have to determine if a valid SID_UPDATE was received or not.

This patch implements the above rules (except AMR related) in the common
part of OsmoBTS.  The AMR specific bits will have to follow as a later
patch, likely in a BTS specific way, i.e. separate changes to
sysmo/lc15/octphy/trx code.

Related: OS#2978
Change-Id: I16eb3747a1c23df935a4c50dafe46abce512a474
2018-02-26 15:01:08 +01:00
Harald Welte 6381900677 split scheduler_mframe.c from scheduler.c
There are use cases for the multiframe scheduler tables outside the
context of the entire scheduler. Let's prepare for that.

Related: OS#2978
Change-Id: I6a501e66c47809ae3cdc55bef2cb6390ee0096b1
2018-02-26 15:01:08 +01:00
Harald Welte bcc20a871c {sysmo,lc15}: Fix RACH reporting in combined CBCH case
Combined CCCH with CBCH is a separate PCHAN type and hence we must
accept it in the list of RACH-carrying pchan types in order to correctly
report the RACH chan_nr when handing RACH requests up to L1SAP.

The bug this fixes likely might have rendered cells with combined CBCH
impossible to use.

Change-Id: I9537463e5eedd2b8b30f298e0d3b308367c5b1fb
2018-02-26 13:48:11 +01:00
Harald Welte 591c8993e9 {sysmo,lc15}: Correctly report BER to L1SAP in INFO_MEAS_IND
L1SAP uses 'ber10k' values, i.e. BER in 1/10000 units, where 10000
is all errors are bit-errors (= 100%).

The PHY on osmo-bts-sysmo and osmo-bts-lc15 is reporting a float fBer
value scaled to 1, i.e. 1.00 = 100% and hence must be 10000 as ber10k.

Before this patch, BER values reported on those BTS models were too
low by a factor of 100, resulting in way too optimistic RxQual values
reported to the BSC.

Closes: OS#3005
Change-Id: I17e2f8fe8055f613da1e554cd36ed13289f56fb3
2018-02-26 13:48:11 +01:00
Harald Welte f100992a20 octphy: Remove code duplication for BER / RSSI conversion
Let's introduce some functions to hide the details of BER and RSSI
conversion from OCTPHY representation to L1SAP representation.

Change-Id: I517669c87a97b2ba164a2812811c8802fe0b92e8
2018-02-26 13:48:11 +01:00
Harald Welte 49a8969bd6 counters: split rach:sent into rach:drop, rach:ho, rach:cs and rach:ps
Change-Id: I51e9938df0e05b8fdb12686b9a9bb6994546deed
2018-02-26 13:48:11 +01:00
Harald Welte de3b4a248e measurement.c: Fix sdcch4_meas_rep_fn102 / sdcch8_meas_rep_fn102
Since Change-Id: I23fba50f48415314da40cf5bf86fce2ed3e66af6 we were not
reporting measurements for SDCCH channel types due to the wrong
encoding of the sdcch{4,8}_meas_rep_fn102 table.

Let's fix the table by encoding the needed information:

 "What is the modulo-102 remainder of the first burst of the last block
  before fn%102 reaches 37?" (SDCCH/4)

 "What is the modulo-102 remainder of the first burst of the last block
  before fn%102 reaches 12?" (SDCCH/8)

The TS 45.002 Clause 7 tables have to be consulted carefully to
determine this information.

Change-Id: Icf02354872670126ab3297b787b216981ca6c309
Related: OS#2965
2018-02-26 12:33:19 +00:00
Harald Welte 989f779cfc RSL IPA DLCX: Avoid another null-pointer dereference
In case a DLCX _with conn-id_ is issued without any CRCX before,
we ran into a NULL pointer dereference in adding the connection
statistics.  Let's handle this gracefully and simply return empty
statistics.

Change-Id: If8b71266c847b90cdc51695b9f47b527c51bd70c
Closes: OS#2996
2018-02-25 12:52:44 +01:00
Harald Welte 9c4ea743fd RSL: Fix encoding of ConnectionID in IPA_DLCX_ACK
Change-Id: Ifdea747e78f191902870af53692f7a70fa7ece93
Closes: OS#2999
2018-02-25 12:52:44 +01:00
Harald Welte 756bfca599 RSL IPA DLCX: Avoid null-pointer dereference
In case a DLCX is issued without any CRCX before, let's handle this
gracefully and simply ack the DLCX anyway.

Change-Id: I7c5bedccfc5a7cf552a9ce3a2dc712081c7ce177
Closes: OS#2996
2018-02-25 02:01:49 +01:00
Harald Welte 681be20a8c paging: Fix encoding of PAGING TYPE 3 Rest Octets
The RR PAGING TYPE 3 Rest Octets IE contains (among other things) the
channel type needed for Mobile Identity 3 + 4 in the paging message.

We did not only "forget" to encode those channel type needed field, but
we have a completely wrong definition of those rest octets in
libosmocore/include/gsm/protocol/gsm04_08.h "struct gsm48_paging3"

Change-Id: I3a0bca6707ce95b68459c89f5b2b07f1590a1ab3
Closes: OS#2994
2018-02-25 00:01:15 +01:00
Harald Welte 42c50727b5 rsl: Improve ERROR REPORTing
Let's make sure all useful optional IEs of the RSL ERROR REPort aare present

Change-Id: I5ecb98f8c72f472ac23c1e4e0f606b75e2cf032c
2018-02-24 19:26:42 +01:00
Harald Welte d3875a8fcb paging.c: Fix encoding of optional Mobile ID RR PAGING TYPE 1 / 2
It seems we have been encoding PAGING REQUEST TYPE 1 and
PAGING REQUEST TYPE 2 erroneously all the time.  The optional last
Mobile Identity in those messages are TLV, not just LV.

This is a quite serious bug in one of the most fundamental parts of
the Radio Resource layer, and it has likely stayed hidden for a long
time as usually in small networks there's a low paging load, reducing
the amount of pressure to put multiple identities in one PAGING REQUEST
message.

Change-Id: Icc320ed130d0c29e9260a6a2aabe52e7346c3888
Closes: OS#2993
2018-02-24 19:26:42 +01:00
Harald Welte 84de287da0 paging: Drop + Log paging requests for non-existant paging groups
Change-Id: Id02c8fea51c1260f1baae8566c67bafc5bdb970e
Related: OS#2992
2018-02-24 19:26:42 +01:00
Harald Welte d7f8a1c16e BTS: add rate_ctr about CCCH (paging, agch, pch)
Change-Id: Id6c833746150a3c2e32b00ea6604669f16b84bc4
2018-02-24 19:26:42 +01:00
Harald Welte c113501513 RSL: Send ERROR REPORT on too short/truncated messages + wrong discriminator
Change-Id: I6a0e63999f39592474064e2f05df450aec8e37fe
2018-02-24 04:35:49 +01:00
Harald Welte 19da7fdea8 RSL: Implement DELETE INDICATION on AGCH overflow
This patch adds generation of a DELETE INDICATION when the BTS AGCH
queue overflows due to too many IMMEDIATE ASSIGN CMDs, as required
by the specs.

The AGCH queue length in OsmoBTS so far is at 1000 entries, which I
consider way too high.  But that is for another patch.

Change-Id: Ied3306e85cbdc6f3476b10dc4bb0463cd728b274
Related: OS#2990
2018-02-24 04:35:49 +01:00
Harald Welte 6e92255cc7 load_indication: Fix start of load indication timer
Starting the timer in bts_init() may result in it expiring already
before the load indication period is set via OML.   Let's make
load_timer_start() safe to call several times and call it from OML
code.

Change-Id: I295d91413542014aa2507d5f09e01243fc3916fa
Fixes: OS#2991
2018-02-24 04:14:03 +01:00
Harald Welte fc169ba7bb scheduler.c: Print message when burst substitution happens
Whenever we receive discontinuous frame numbers from the TRX socket,
osmo-bts-trx is substituting zero-filled bursts for those frame numbers
which we missed.  Don't just do this silently, but actually log about
it, as it is an error.

Note: This [currently] happens when using a virtual air interface with trxcon
as opposed to a real SDR receiver with osmo-trx.

Change-Id: If79eab37c80647c9ab64f399fa4676d97af3e9ad
2018-02-23 23:29:34 +01:00
Harald Welte 815ff00d23 osmo-bts-trx: Add missing frame number to l1if_process_meas_res()
Change-Id: I7f1322b025ce733f78ae2b958c7a2bb38b6aa6f5
2018-02-23 19:58:29 +01:00
Harald Welte aa9ce821a0 l1sap: Pass is_sub from L1 primitive into the Uplink Measurement
info_meas_ind on the L1SAP always allowed the lower layers to pass
in whether a given measurement is part of the "SUB", or not.

However, the existing l1sap code before this patch simply drops this
information, despite the measurement.c code also having "is_sub" state.

Let's make sure this state is passed from L1SAP into measurement
processing as intended.

Fact is, none of our current lower-layers actually set this is_sub flag
for their primitives passed up in L1SAP, but at least now *if* they
would set that flag, the measurement code would process it as intended.

Related: OS#2978
Change-Id: Ibed2e8d7563b471c6b5dd2214ac4765caf31ed2a
2018-02-23 19:57:52 +01:00
Harald Welte 1effad1004 measurement.c: Hand Frame Number into measurement computation
This is currently only used for logging, but will be needed for proper
RX{LEV,QUAL}-SUB reporting in upcoming patches.

Related: OS#2978
Change-Id: I07fd06e8a379cab7c0c2eb111c3f5600037d3c9e
2018-02-23 19:57:44 +01:00
Harald Welte 2de8f6c7ec Revert "measurement: fix measurement computation"
This reverts commit d5fdcfe6d9, which
introduces a new function lchan_meas_update_ordered_TA whose
functionality I still haven't yet managed to fully understand. It
appears to be adjusting the requested timing advance (lchan->rqd_ta) but
outside osmo-bts-trx/loops.c code. This is odd, as rqd_ta is a state
variable of that loops.c code.

So for one part, it is a failure of encapsulation. The TA loop code
should be self-contained, particularly as it is only used for
omso-bts-trx, and not for the other BTS models. The new
lchan_meas_update_ordered_TA() function is used from common code,
applicable to all BTS models.

The resulting interaction between loops.c code and this new (now
reverted) function cause the TA value to only ever grow, despite the MS
never moving at all.

Change-Id: I5a5adac6f18f94a5b51758a5ace8ef6ddfd23e80
Related: OS#2989
2018-02-23 19:57:20 +01:00
Harald Welte b82b81b256 scheduler: add trx_sched_is_sacch_fn() function
For proper measurement processing of RX{LEV,QUAL}-SUB, we will
need this information.

Related: OS#2978
Change-Id: I768fde62452a74dce471ebf946e56eb1e4de1abc
2018-02-23 14:27:45 +00:00
Harald Welte a38deee5f1 scheduler.c: Factor out find_sched_mframe_idx() function
Let's split the look-up of the multiframe scheduler from the asignment
to a given l1ts in trx_sched_set_pchan.

Related: OS#2978
Change-Id: I79548b25aae647ce993a9d83c771d22b08cb1c74
2018-02-23 14:27:33 +00:00
Harald Welte 232f53adf0 osmo-bts-virtual: Make sure PRIM_INFO_MEAS have non-zero frame number
Measurement reports fed into L1SAP so far had their frame number always
set to zero, resulting in higher-layer common code above L1SAP to never
detect the end of the measurement period, which in turn caused no RSL
MEAS REP to be sent.

Related: OS#2978
Change-Id: I67837d19515ea335614928570c12dd5027104c6b
2018-02-23 14:05:51 +00:00
Harald Welte ac0254c000 osmo-bts-virtual: Make use of LOGL1S() macro for context
In Change-Id I5703b46c8a59fe00a3cdc063bcf72872980ec5e5 we introduced
LOGL1S and starte to use in in common/scheduler.c as well as
osmo-bts-trx but somehow we didn't introduce it in osmo-bts-virtual
at the time.  Let's catch up.

Change-Id: I0b5fd3b7982b9119becda844531108f64c68d19f
2018-02-22 12:31:51 +01:00
Harald Welte 6eb3752511 Introduce + use LOG/DEBUGP with frame number prefixing/printing
Let's make sure whenever we do have a frame number, we print it as
context in the related log line

Change-Id: I751d5ddb3322fce489bc241459738cbcc55c890b
2018-02-22 12:31:48 +01:00
Harald Welte 22c07d1f1f osmo-bts-virtual: Generate PRIM_INFO_MEAS (with bogus values)
The problem is that measurement processing above L1SAP requires/expects
those PRIM_INFO_MEAS indications from the bts specific parts.  Otherwise
it will never generate even uplink-only measurement reports to the BSC,
which is a violation of Abis protocol specs.

Change-Id: I48f73293cb4f0ab4c657dfd00e7ddd032a3c030f
2018-02-22 12:11:28 +01:00
Harald Welte 04719d19b9 osmo-bts-virtual: Shut down gracefully on socket creation failure
Don't simply crash if creation of the multicast socket fails

Change-Id: Ie87b6684b3aa7f21742e4cf21533e980485c1230
2018-02-22 12:11:28 +01:00
Philipp Maier a4bca11555 bts: use feature list instead of speech codec table
osmo-bts has a table of pchan/channel mode combinations for every
bts. This table models the codec capabilitys of the BTS hardware.
However, having the speech codec apabilities modeled inside the
BTS feature list would be much more comfortable and since the
feature list is communicated back to the BSC we would get the
codec capabilities inside the BSC domain as well.

- remove the pchan/channel mode tables
- set speech codec variants for each BTS type
- fix bts_supports_cm so that it queries the feature list

Change-Id: I977dc729ba856631245aedf76afd48eac92166f7
2018-02-22 07:58:26 +00:00
Philipp Maier b93748a170 vty: display bts features in vty command show bts
The VTY command show bts does not display the bts specific
features yet.

- Also display the feature list in snow-bts

Change-Id: I509f2a7bbfa96c70bdfea4ff2488ee371e914620
2018-02-22 07:58:26 +00:00
Philipp Maier bfe9af4ae1 octphy: ensure all BTS models set features
Most of the BTS models do not or do register not all of thier
features to the the feature list.

- Update/extend the feature lists for all BTS-Models

Change-Id: I26765a64153368016921c2ac115b1c4aec9bc5e4
2018-02-22 07:58:26 +00:00
Philipp Maier e0bfd675d1 gsm_data_shared: extend bts feature list with speech codecs
The feature list does not cover any speech codec related information.

- Add speech codec related items to feature list.

Change-Id: If6d50c6f4e2348b23f31c3415b0f5577a3f5be50
2018-02-22 07:58:25 +00:00
Harald Welte 4847a1688b RSL: Ensure we don't accept DCHAN messages for CCHAN
If the Channel Number IE points to a common channel, we cannot
accept such messages in code paths that only process dedicated
channels, such as RLL/DCHAN/IPA.

Related: OS#2972, OS#2971
Change-Id: I43a78bec63aeb36dd67043d237b27fe880209349
2018-02-21 16:49:28 +01:00
Harald Welte 5e60186bec RSL: Properly reject RSL CHAN_NR IE for incompatible PCHAN
If we receive a message for a dedicated channel, whose channel number
structure doesn't match with the physical channel (timeslot) type,
we must properly reject this.  For RSL CHAN ACT it means sending a NACK,
and for all other cases it means sending an RSL ERROR REPORT.

Related: OS#2972, OS#2971
Change-Id: Iebd2571726d1284a7431b3f9b23ad3185e832ed1
2018-02-21 16:48:46 +01:00
Harald Welte df72b1fdbd trx: make l1if_fill_meas_res() static
it's not used anywhere outside of l1_if.c, so make it a static function

Change-Id: If988a7679f3a9253fab1a4d177a276d8ecaf794f
2018-02-19 14:34:01 +01:00
Harald Welte 0829a1704e sysmo+lc15: Add missign include for readv/writev
This avoids compiler warnings like this:

../../src/osmo-bts-sysmo/l1_transp_hw.c:130:13: warning: implicit declaration of function ‘writev’; did you mean ‘write’? [-Wimplicit-function-declaration]
   written = writev(fd->fd, iov, count);

Change-Id: Ic67d369a3ca33bfa636ace9f272f1c7257de86e1
2018-02-19 14:33:46 +01:00
Harald Welte 7cf144b27d sysmo: Fix compiler warnings in eeprom.c
This avoids compiler warnings like

../../src/osmo-bts-sysmo/eeprom.c: In function ‘eeprom_WriteSysInfo’:
../../src/osmo-bts-sysmo/eeprom.c:605:58: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
             err = eeprom_write( EEPROM_CFG_START_ADDR + ((uint32_t)&ee.cfg.v1.sysInfo - (uint32_t)&ee), sizeof(ee.cfg.v1.sysInfo), (const char *) &ee.cfg.v1.sysInfo );

Change-Id: Ic748038e6f25ec18ccb4a2f2503ca567fb00a586
2018-02-19 14:33:40 +01:00
Stefan Sperling ca6021fa5d Cosmetic fixes for power ramping code.
Fix typos in 2 comments.

Change-Id: I214bcc8b78446bfea450fe445fa9391898638905
2018-02-19 08:51:25 +00:00
Philipp Maier bf1fea0928 rsl: do not allow MODE MODIFY request with unsupp. codec/rate
When the BSC sends a MODE MODIFY request with an unsupported
codec, the BTS must respond with a negative acknowledge.
Currently the codec parameter is not checked at all, which may
lead into malfunction or crash of the BTS.

- Introduce a mechanism to check the codec/rate against a
  table that is set up in the phy specific code.

- Add tables with supported codec/rate combinations for
  octphy, sysmobts, and trx.

Change-Id: Id9b222b7ab19ece90591718bc562b3a8c5e02023
Related: SYS#3212
2018-02-19 08:38:21 +00:00