Commit Graph

62 Commits

Author SHA1 Message Date
Vadim Yanitskiy 28b8759465 osmo-bts-trx: eliminate ul_bursts_prev, use the primary buffer
When adding support for Circuit Switched Data calls, we had to enlarge
the burst buffer size to accommodate bits for a maximum of 24 bursts.

Let's take advantage of this by utilizing the currently unused part of
the Uplink burst buffer for storing bits of previously decoded blocks.
This eliminates the need to allocate additional memory for SACCH.

Change-Id: I15047cd1df4476054b36f05616e41f5297d9bfe5
Related: SYS#5114, OS#4794, OS#4795, OS#4796
2023-11-14 12:22:32 +00:00
Andreas Eversberg d88cc624ed ASCI: Add control of uplink access to osmo-bts-trx
An MPH-INFO message is used to turn detection of uplink access bursts on
or off. This is required for voice group/broadcast channels.

Related: OS#4851
Depends: libosmocore.git Ibd6a1d468a70126a8f67e944fcb916969cc3c36b
Change-Id: I9045437d52984b7abe00fbc815d7f83c62c0fb5a
2023-10-27 10:35:21 +00:00
Vadim Yanitskiy 98e5d6f7c6 osmo-bts-trx: document/clarify the meaning of BUFMAX=24
Change-Id: I95d4e4ee3938cfabc1695959cc82a1efbbf0d7ed
Related: OS#1572
2023-07-21 11:12:50 +00:00
Vadim Yanitskiy 95407f3f63 osmo-bts-trx: implement CSD scheduling support
* enlarge the maximum burst buffer size to 24 * (2 * 58) bytes;
* enlarge per-l1cs Uplink burst mask to hold up to 32 bits;
* enlarge per-l1cs Uplink meas ring buffer to 24 entries;
* add new meas modes: SCHED_MEAS_AVG_M_{S22N22,S24N22};

Change-Id: I08ffbf8e79ce76a586d61f5463890c6e72a6d9b9
Depends: libosmocore.git Ib482817b5f6a4e3c7299f6e0b3841143b60fc93d
Related: OS#1572
2023-07-13 03:42:29 +07:00
Vadim Yanitskiy 282c87ab2d osmo-bts-trx: fix recent regression in Tx lchan handlers
In my recent patch a0770250, among with the new burst buffer
allocation/release strategy, I introduced a regression:

        /* send burst, if we already got a frame */
-       if (br->bid > 0) {
-               if (!*bursts_p)
-                       return -ENODEV;
+       if (br->bid > 0)
                goto send_burst;
-       }

We used to allocate the burst buffers in Rx/Tx lchan handlers, and
release them in case of an error, e.g. when no block is available
for transmission.  In the case of Tx burst buffers, the state of
Tx burst buffer was additionally used to check if we have a valid
Tx block for transmission, as can be seen in the code snippet above.

As a side effect of my patch, osmo-bts-trx now keeps transmitting
3 out of 4 bursts (br->bid > 0) of the last valid block, until the
next valid Tx block is available for transmission.

This problem was not affecting the CS domain, where it's expected to
have a more or less constant pressure of Tx blocks.  However it did
show up in the PS domain, where in the absence of active TBFs the
PCU may omit DL blocks.

Add a new field 'dl_mask' to struct l1sched_chan_state, similar to
the existing 'ul_mask', and use it to reconstruct the removed logic.

Change-Id: I4538a8fe6b29f8d6eca33ad27d4a9852e3a3e86c
Fixes: a0770250 "osmo-bts-trx: alloc/free burst buffers in trx_sched_set_lchan()"
2023-06-03 14:56:42 +07:00
Vadim Yanitskiy 8e04613e4f osmo-bts-trx: properly activate [CBCH/]BCCH/CCCH
The timeslot carrying BCCH/CCCH on C0 is a bit special in a way that
it's being activated implicitly - there is no explicit RSL CHANnel
ACTIVation for that.  This is why we have TRX_CHAN_FLAG_AUTO_ACTIVE,
which marks sub-channels of BCCH/CCCH in the trx_chan_desc[].

The upcoming patch changes the burst buffer allocation strategy, so
that the memory is allocated on channel activation and then free()d
on channel release.  This patch facilitates that by making the
activation/deactivation logic consistent for all sub-channels.

Change-Id: Id0c70d6a2b777a5117c85149bfa1b3a997299d1d
Related: OS#1572
2023-03-22 12:14:25 +00:00
Vadim Yanitskiy 2950c0363d osmo-bts-trx: handle MTS 0b0110 indicating an Access Burst
The PCU may poll the MS requesting an ACKnowledgment message to be
sent in form of four Access Bursts instead of Normal Bursts.  The
BTS has no prior knowledge of the Uplink burst type, so a new MTS
value was specified in order to prevent the BTS from trying to
decode Access Bursts as a PDTCH block.

This patch implements parsing of the new MTS value 0b0110.
Signalling RACH.ind to the PCU is to be implemented.

Change-Id: I0fbb63006797e6be386d1f76ed97fff098c036fc
Related: OS#4006, SYS#4794
2022-10-04 16:33:10 +00:00
Vadim Yanitskiy 541b7525ae osmo-bts-trx: amr_loop: trigger the loop unconditionally
The logic responsible for enabling and disabling the loop appears
to be broken: during my experiments trx_loop_amr_set() was never
called with loop=1.  It's not clear what's the motivation behind
this breaker, so I propose to rip it out for now.  This patch
finally makes the loop work (confirmed with a TEMS phone).

Change-Id: I09b649973d4269c4082a4fafa493c37825f95a9c
Related: SYS#5917, OS#4984
2022-08-08 05:43:20 +00:00
Vadim Yanitskiy cf09b0cb50 scheduler: trx_sched_is_sacch_fn(): make ts pointer const
Change-Id: I48a1a549d7c1553bccaa01cdc818873a4c6cdf0a
2022-05-10 01:19:17 +03:00
Vadim Yanitskiy 8aab8d484b osmo-bts-trx: drop Uplink loss detection from Downlink path
Attempting to detect missing Uplink frames in the *Downlink* path
is an ugly hack, that was needed before we had proper per-lchan
detection of missing bursts and NOPE indications in TRXDv1.

* [1] per-lchan detection of missing bursts was fixed in Aug 2018.
* [2] TRXDv1 support was introduced in Jul 2019.

Today is 2022 and it makes no sense to keep this hack.  Even if
the transceiver does not support TRXDv1, per-lchan detection
will compensate the missing Uplink bursts.

Change-Id: Ic292d180ba64206fb4d88adb284f9f9d058b4587
Related: [1] I70d05b67a35ddcbdd1b6394dbd7198404a440e76
Related: [2] If61c71d20d590bf07bfd019afb33000a0b6135bd
2022-05-06 12:55:18 +00:00
Vadim Yanitskiy 44cb0113cf osmo-bts-trx: use C/I in the AMR link adaptation loop
Change-Id: Ide84bf864f56020c0265cfb9731615d4f7bad7f5
Related: SYS#5917, OS#4984
2022-04-20 12:18:08 +00:00
Vadim Yanitskiy 12b3921a4a osmo-bts-trx: rx_{tchf,tchh}_fn(): get TDMA FN from meas history
Once we have an Uplink speech or FACCH frame decoded, we need to
hand it over to the upper layers indicating TDMA frame number of
the *first* burst corresponding to the beginning of a block.

Currently we use libosmogsm's gsm0502_fn_remap() API to calculate
the first TDMA frame number from the given last frame number.
This API involves iterating over the pre-calculated offset tables
for different channel and payload types, and thus imposes some
additional CPU cycles.  Another downside of the current approach
is that we have to perform such lookups several times for each
decoded L2 frame, e.g. for FACCH on TCH/AHS we do it three times!

In this patch I propose an alternative approach of storing TDMA
frame numbers in the measurement history, together with the
associated samples.  This way we can easily get N-th frame number
from there without performing any additional computations, other
than what we already do during the measurement processing.

Change-Id: Id9a2b7b0f1a1ad7cfbbab862faf521e135c90605
2022-04-05 13:45:31 +00:00
Vadim Yanitskiy da433bba7b osmo-bts-trx: rx_tchh_fn(): get rid of chan_state->meas_avg_facch
FACCH/H takes out two speech frames, so we send two BFIs once we
have received it in rx_tchh_fn().  The upper layers responsible
for handling of the Uplink measurements expect a fixed amount of
measurement samples, so currently we do:

* send a FACCH frame with the associated measurememnts (S6N6),
* send the 1st BFI with invalidated measurements (RSSI=0),
* send the 2nd BFI with the stored measurememnts of FACCH.

This is achieved by preserving a copy of the FACCH measurememnts
in chan_state->meas_avg_facch and then using it two bursts later.

The same goal can be achieved a lot easier by sending the associated
measurements with both BFIs as if no FACCH was received:

* send a FACCH frame with invalidated measurememnts (RSSI=0),
* send the 1st BFI with the associated measurememnts (S6N4),
* send the 2nd BFI with the associated measurememnts (S6N4).

This eliminates the need to store anything outside of the existing
measurement history and simplifies the code a lot.  Also, this
eliminates the need for using a dedicated averaging mode S6N6.

Varified by running BTS_Tests.TC_meas_res_speech_tchh_facch.

Change-Id: I7902b4709bc3f418174e8373f52e87bb31cdc826
Related: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91
2022-04-05 13:45:31 +00:00
Vadim Yanitskiy bd7ef4101b osmo-bts-trx: rx_tchh_fn(): indicate BER10k=0 for FACCH BFIs
It makes no sense to store BER10k value of an Uplink FACCH frame
in order to indicate it in a BFI later on.  Given that these BFIs
are generated artificially, it's fine to indicate BER10k=0.

Change-Id: I24d12892760dca0ad0a5c2abca9fc66523d9e614
Related: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91
2022-04-05 13:45:31 +00:00
Vadim Yanitskiy 35e601a322 osmo-bts-trx: rx_tchh_fn(): use proper meas averaging mode
Compared to TCH/F, TCH/H is a bit special in a way that:

* speech frames are interleaved over 4 consecutive bursts,
* while FACCH frames are interleaved over 6 consecutive bursts.

This is why in rx_tchh_fn() we allocate a buffer large enough to
store up to 6 bursts.  Let's say we have that buffer filled up
completely with all 6 bursts (from 'a' to 'f').  Now attempting
to decode them may yield either a speech frame or a FACCH frame:

  +---+---+---+---+---+---+
  | a | b | c | d | e | f |  Burst 'a' received first, 'f' last
  +---+---+---+---+---+---+
   ^^^^^^^^^^^^^^^           Speech frame (bursts 'a' .. 'd')
   ^^^^^^^^^^^^^^^^^^^^^^^   FACCH frame  (bursts 'a' .. 'f')

For FACCH we use measurement averaging mode SCHED_MEAS_AVG_M_S6N6,
so that 6 last samples are averaged - so far so good.  For speech
we use SCHED_MEAS_AVG_M_S4N4, so that 4 last samples corresponding
to bursts 'c', 'd', 'e', 'f' are averaged - this is wrong.

We actually need to average the *first* 4 samples corresponding to
bursts 'a', 'b', 'c', 'd' in the case of speech.  Let's add and use
a new averaging mode SCHED_MEAS_AVG_M_S6N4 for that.

Change-Id: Iea6f4e5471550f4c2b57aaebeac83c80e879489d
2022-03-18 03:53:08 +03:00
Vadim Yanitskiy 2de4d9baa8 osmo-bts-trx: use consistent naming for 'enum sched_meas_avg_mode'
This is a purely cosmetic change.  The new naming clearly indicates
how deep to go back in the measurement history (S) and how many
samples to average (N).  For example:

* SCHED_MEAS_AVG_M_S4N4 - go S=4 steps back and average N=4 samples;
* SCHED_MEAS_AVG_M_S6N2 - go S=6 steps back and average N=2 samples.

Change-Id: I96a8dd08084c7c179f879fc00e75c5edcfb11caa
2022-03-18 03:53:02 +03:00
Vadim Yanitskiy d6ef2bf12f osmo-bts-trx: implement Temporary Overpower for SACCH/FACCH
GSM/EDGE Evolution and Performance, Section 12.3 suggests Temporary
Overpower as another solution to improve SACCH/FACCH performance in
case of bad C/I. The idea here is that you increment the DL transmit
power by 2..4dB only for FACCH/SACCH bursts, while keeping all voice
bursts at the lower (normal) level as determined by BS power control.

SACCH blocks can be recognized by the channel type, since they're
always transmitted in specific frames of a multiframe.  FACCH blocks,
however, are not predictable and can substitute voice blocks at
(almost) any time.  Thus we need to mark FACCH bursts as such in
the logical channel handlers (using TRX_BR_F_FACCH).

Change-Id: Ie8a626fefccf1eb07271058e5126ec106cb1abcf
Related: SYS#5319
2021-09-27 16:02:26 +00:00
Vadim Yanitskiy 6fd4f77243 osmo-bts-trx: report interference levels to the upper layers
In trx_sched_ul_burst(), treat all BURST.ind and NOPE.ind mapped
to inactive logical channels as interference.  Average the RSSI
values on the fly using a sliding average with constant a=0.5.

Report averaged values for each logical channel every 104 TDMA
frames (SACCH period) by calling gsm_lchan_interf_meas_push().

Change-Id: I4686448e42a40df56c1d27a14fd0a4d43fd144a5
Related: I78b6d8beffa5228a28231b75728e7aebdd3cb23c
Related: SYS#5313, OS#1569
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy a484742793 scheduler: reorder enum trx_chan_type, add TRX_CHAN_IS_DEDIC()
With the new ordering, all TRXC_* values starting from TRXC_TCHF
belong to dedicated channels.  This is useful for the interference
reporting logic, where we're not interested in broadcast channels.

Change-Id: I7148f4d0bd1abbfe309bc5477e32a56d884533ea
Related: SYS#5313, OS#1569
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy 6d20a49806 [VAMOS] osmo-bts-trx: schedule bursts on 'shadow' timeslots
Change-Id: I3e0bdf8c03273f66991aa1764029ab1dd3528d7e
Related: SYS#4895, OS#4941
2021-06-05 00:34:36 +02:00
Vadim Yanitskiy 60fc1d3763 [VAMOS] scheduler: add new GMSK training sequences from 3GPP 45.002
Change-Id: I03fe712da5a3cc1a59f40a98a57f43306c3586c6
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy 207d56afe5 [VAMOS] osmo-bts-trx: rework handling of Training Sequence
The TSC (Training Sequence Code) value in 'struct gsm_bts_trx_ts'
is always initialized in oml_rx_set_chan_attr() during the OML
bootstrapping, so there is no need for gsm_ts_tsc() - remove it.

Store the initial TSC value in 'struct gsm_bts_trx_ts', so we can
apply a different TSC value during the RSL CHANnel ACTIVation.

Store the Training Sequence Code/Set in 'struct trx_dl_burst_req'.
These values are indicated to the transceiver (TRXDv2 PDUs, 'MTS'
field) and used by the new TRX_{GMSK,8PSK}_NB_TSC macros.

Change-Id: I3744bc308b99ef941e6e9d139444e414abebc14b
Related: SYS#4895, OS#4941
2021-06-04 20:04:13 +00:00
Vadim Yanitskiy 13d595a9ef [VAMOS] osmo-bts-trx: indicate MTS in Downlink TRXDv2 PDUs
Change-Id: I1a17a25883214c068f9b1a6d651128b8f760d1fb
Related: SYS#4895, OS#4941
2021-06-01 02:46:43 +00:00
Vadim Yanitskiy ec1045a01b [VAMOS] osmo-bts-trx: implement and enable PDU batching for TRXDv2
This change implements TRXD PDU batching approach b), which is described
in section 25.3.4 of the user manual [1].  This approach is quite easy
to implement on the transceiver side, so we can enable it by default.

  .Example: datagram structure for combination b)
  ----
  +--------+----------------+---------+------------------------+
  | TRXN=N | TDMA FN=F TN=0 | BATCH=1 | Hard-/Soft-bits        |
  +--------+----------------+---------+------------------------+
  | TRXN=N | TDMA FN=F TN=1 | BATCH=1 | Hard-/Soft-bits        |
  +--------+----------------+---------+------------------------+
  | TRXN=N | TDMA FN=F TN=2 | BATCH=1 | Hard-/Soft-bits        |
  +--------+----------------+---------+------------------------+
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  +--------+----------------+---------+------------------------+
  | TRXN=N | TDMA FN=F TN=7 | BATCH=0 | Hard-/Soft-bits        |
  +--------+----------------+---------+------------------------+
  ----

Other PDU batching approaches can be introduced later.

[1] https://downloads.osmocom.org/docs/latest/osmobts-usermanual.pdf

Change-Id: I9b4cc8e10cd683b28d22e32890569484cd20372d
Related: SYS#4895, OS#4941
2021-06-01 02:46:43 +00:00
Vadim Yanitskiy 462bf0952a [VAMOS] Re-organize osmo-bts-trx specific structures
Together with the 'generic' structures which used to be shared between
osmo-bsc and osmo-bts some time ago, we also have the following
osmo-bts-trx specific structures (in hierarchical order):

  - struct l1sched_trx (struct gsm_bts_trx),
  - struct l1sched_ts (struct gsm_bts_trx_ts),
  - struct l1sched_chan_state (struct gsm_lchan).

These structures are not integrated into the tree of the generic
structures, but maintained in a _separate tree_ instead.  Until
recently, only the 'l1sched_trx' had a pointer to generic
'gsm_bts_trx', so in order to find the corresponding 'gsm_lchan' for
'l1sched_chan_state' one would need to traverse all the way up to
'l1sched_trx' and then tracerse another three backwards.

                                 + gsm_network
                                 |
                                 --+ gsm_bts (0..255)
                                   |
  --+ l1sched_trx --------------------> gsm_bts_trx (0..255)
    |                                |
    --+ l1sched_trx_ts               --+ gsm_bts_trx_ts (8)
      |                                |
      --+ l1sched_chan_state           --+ gsm_lchan (up to 8)

I find this architecture a bit over-complicated, especially given
that 'l1sched_trx' is kind of a dummy node containing nothing else
than a pointer to 'gsm_bts_trx' and the list of 'l1sched_trx_ts'.

In this path I slightly change the architecture as follows:

                                 + gsm_network
                                 |
                                 --+ gsm_bts (0..255)
                                   |
                                   --+ gsm_bts_trx (0..255)
                                     |
    --+ l1sched_trx_ts <----------------> gsm_bts_trx_ts (8)
      |                                |
      --+ l1sched_chan_state           --+ gsm_lchan (up to 8)

Note that unfortunately we cannot 1:1 map 'l1sched_chan_state' to
'gsm_lchan' (like we do for 'l1sched_trx_ts' and 'gsm_bts_trx_ts')
because there is no direct mapping.  The former is a higl-level
representation of a logical channel, while the later represents
one specific logical channel type like FCCH, SDCCH/0 or SACCH/0.

osmo-bts-virtual re-uses the osmo-bts-trx hierarchy, so it's also
affected by this change.

Change-Id: I7c4379e43a25e9d858d582a99bf6c4b65c9af481
2021-05-18 19:11:06 +00:00
Vadim Yanitskiy 641ffaaef3 scheduler.h: cosmetic: use #pragma once
Change-Id: I551ce74f8cec8ec8d80768ec6c0559a203a8143c
2021-05-18 19:00:55 +00:00
Vadim Yanitskiy 4733b099f5 osmo-bts-trx: implement TRXDv2 protocol support
Change-Id: I3532a6693bb335043ec390049138308991083e66
Related: SYS#4895, OS#4941, OS#4006
2021-05-11 10:55:55 +00:00
Vadim Yanitskiy 05493ca810 [VAMOS] osmo-bts-trx: move {chan,bid} to trx_{dl,ul}_burst_{req,ind}
Historically the logical channel handlers like rx_data_fn() used to accept
quite a lot of arguments.  With the introduction of additional measurement
parameters it has become clear that we need to group the arguments into
structures.  This is why both 'trx_{dl,ul}_burst_{req,ind}' structures
were introduced.

However, both channel type and burst ID were kept untouched, so until
now we had them being passed between the scheduler functions here and
there.  This change is a logical conclusion of the original change
mentioned above.

As a part of this change, the new LOGL1SB() macro is introduced.  It
does accept a pointer to 'trx_{dl,ul}_burst_{req,ind}' and expands the
context information for the old LOGL1S() macro.

Change-Id: Ic5a02b074662b3e429bf18e05a982f3f3e7b7444
2021-05-11 04:00:37 +02:00
Vadim Yanitskiy b619da5e72 osmo-bts-trx: 'burst type' is actually modulation type
Burst type and modulation type are actually different things.

Change-Id: Ic06c96434ad32dd3770b88cb1fefcbefb2fc3928
Related: SYS#4895, OS#4941, OS#4006
2021-04-24 08:47:00 +00:00
Philipp Maier fd5151668c sched_lchan_tchh: fix frame number and fill FACCH gap
The measurement results / TCH indications that are handed when decoding
the TCH/H are off by two bursts. Since a measurement result / TCH block
is expected every two bursts anyway the problem can only be noticed when
a FACCH transmission is going on and the frame numbers of the BFI TCH
blocks appear to be missaligned towards the FACCH block.

The reason is that the incoming bursts are shifted into a 6 burst wide
buffer. The decoding functions always look at the beginning of that
buffer while the bursts are shifted into the buffer from the end. A
facch will always fit exactly in that buffer but TCH/H blocks are only
4 bursts wide and thereofre they need two additional bursts until they
reach the coverage of the decoding function. Lets fix this by putting
the correct frame number (from two bursts before) into the remap
functions in order to get the correct beginning of the block.

Since the FACCH transmission uses six blocks it takes out two TCH
blocks. This means that if we count the FACCH block we end up with a gap
of one TCH voice block. Lets generate a dummy measurement to compensate
the gap. This will also match the behavior of the osmo-bts-sysmo phy.

Change-Id: I1ad9fa3815feb2b4da608ab7df716a87ba1f2f91
Related: OS#4799
2021-03-27 18:37: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
Vadim Yanitskiy fc1976e1a0 scheduler: get rid of useless TRX_CHAN_FLAG_PDCH
Change-Id: I951ec9b02be674936fbd0bf2e75b004813e25197
2020-10-19 15:04:22 +00:00
Philipp Maier c41b94e93b osmo-bts-trx/scheduler: fix measurement handling for SUB frames
Make sure that we pick the correct UL measurements from the
history when we deal with AMR SID frames (SUB frames).

Change-Id: I902bb47d68742d2589156f61099b67a0edbaf40b
Related: OS#2978
2020-10-03 07:05:25 +00:00
Vadim Yanitskiy 4ded469b0f osmo-bts-trx/scheduler: refactor UL burst measurement processing
Currently the UL measurements (RSSI, ToA256, C/I) of the burst that
concludes a block are passed up to the higher layers. This means
that the measurement values of the other bursts are skipped.

Let's keep record of all UL measurements and average the values
before we pass them up to the higher layers. Use a simple ring
buffer to store the measurement history (up to 8 unique entries
for now). Remove *_num/*_sum variables from l1sched_chan_state.

Change-Id: I2b02b51fea5664f161382a4ddc63dbf14ffc9ac5
Related: OS#3032, OS#2978
2020-09-22 19:34:02 +00:00
Pau Espin 81251bdbe8 scheduler: Drop unused function trx_sched_reset()
Change-Id: Id31e82b6bbfdd8030612c78737c0aa7dd7e20bd0
2020-09-07 10:23:25 +02:00
Vadim Yanitskiy cf3635fbaa osmo-bts-trx/scheduler: implement baseband frequency hopping
The idea behind the baseband frequency hopping is quite simple: we
have several RF carriers (transceivers) transmitting and receiving
on fixed frequencies (just like in a regular multi-trx setup), and
an additional burst routing layer between the schedulear and the
transceiver interface (TRXD over UDP).

Speaking in terms of the proposed implementation:

  - on Downlink, dlfh_route_br() calculates the ARFCN corresponding
    to the current TDMA frame number according to the hopping sequence
    parametets, and picks the transceiver with matching ARFCN;

  - on Uplink, ulfh_route_bi() iterates over the transceiver list of
    of the BTS, calculating hopping ARFCNs for equivalent timeslots,
    and picks the one with ARFCN matching the received burst.

In order to avoid frequent transceiver lookups on the Downlink path,
dlfh_route_br() maintains a "cache" in the timeslot state structure.
Unfortunately, this "cache" seems to be useless on the Uplink path,
so ulfh_route_bi() always needs to lookup the matching transceiver
for each burst received over the TRXD interface.

It may also happen that the scheduler will be unable to route an
Uplink or Downlink burst, e.g. due to inconsistent / incorrect
hopping sequence parameters received from the BSC, or in case
if a transceiver gets RF-locked by the BTS operator.

Such events are logged as "FATAL" and aditionally signalled by the
following osmo-bts-trx specific rate counters:

  - trx_sched:dl_fh_no_carrier (Downlink), and
  - trx_sched:ul_fh_no_carrier (Uplink).

Change-Id: I68f4ae09fd0789ad0d8f1c1e17e17dfc4de8e462
Related: SYS#4868, OS#4546
2020-08-07 23:39:01 +07:00
Vadim Yanitskiy 4dfd43bb51 osmo-bts-trx/scheduler: get rid of unused 'meas' in l1sched_chan_state
Change-Id: I4337cfdc393ec44df9bb9824ba4981eaf5b45f0b
2020-06-30 06:10:57 +00:00
Pau Espin 1240ea8b83 scheduler: Add rate_ctr informing about too low rts-advance
Change-Id: I76c3dd4020c6d74192b03b1d42413ae536da5f05
2020-06-18 11:48:49 +00:00
Vadim Yanitskiy b828b32f31 osmo-bts-trx: store pointer to gsm_lchan in l1sched_chan_state
This change simplifies access to generic logical channel state
(struct gsm_lchan) from osmo-bts-trx specific state (struct
l1sched_chan_state), so there is no need to look it up using
get_lchan_by_chan_nr() on receipt of each Uplink burst.

Change-Id: Ic4378020f980845b962f71b9e4b7faea738bc174
2020-06-15 20:55:23 +07:00
Vadim Yanitskiy ae781bc5cd osmo-bts-trx: introduce and use struct trx_dl_burst_req
This change is similar to what we did for Uplink bursts:

  - group all Downlink burst parameters into a single structure,
  - allocate it once and pass a pointer to lchan handlers,
  - pass a pointer to trx_if_send_burst().

Given that the structure is allocated and (zero-)initialized in
trx_sched_fn(), we can get rid of some memset() calls in lchan
handlers and thus improve the overall performance a bit.

Change-Id: If3014e69746559963569b77561dbf7b163c68ffa
2020-06-15 10:42:03 +00:00
Vadim Yanitskiy 4977e135c8 common/scheduler: use boolean for channel activation state
Change-Id: I0cb1d915db8787050cdec1802894f66e885a9bf3
2020-06-06 19:41:15 +00:00
Vadim Yanitskiy 759a12e8aa scheduler: drop non-existing extern declarations
Change-Id: Ifa6fc5947e8fb7ec071a6567c275f5db5ab385f9
2020-06-05 18:38:38 +07:00
Philipp Maier 58b9f11898 dtx: add detection of AMR DTX frames for osmo-bts-trx
Currently we do not detect any of the DTX frames (SID_FIRST, SID_UPDATE
etc.) Detecting and tagging those frames as is_sub is important for
measurement processing. Also the RTP marker bit must be set on each
ONSET frame.

 - Add detection of DTX frames
 - Tag DTX frames as is_sub and set frame type to AMR_SID
 - Set RTP marker bit when ONSET frames are received

Change-Id: I5afe730fff2fa3199a5913b0de4f5c7b23a39f31
Depends: libosmocore I2bbdb39ea20461ca08b2e6f1a33532cb55cd5195
Related: OS#2978
2020-04-25 14:03:06 +00:00
Pau Espin e3a4530919 bts-trx: Drop low layer MS Power Control Loop algo
Let's drop it instead of having code duplication from common code in a
lower layer, and maintain only the one in l1sap for all BTS models.
As a result, osmo-bts-trx loses feature BTS_FEAT_MS_PWR_CTRL_DSP and
will only be able to use "ms-power-control osmo" in VTY, which will be
enabled by default (meaning: change of behavior, now MS Power Control is
enabled by default in osmo-bts-trx and can only by disabled by BSC).
Old bts-trx specific VTY command "(no) osmotrx ms-power-loop" is marked
as deprecated but still working for more usual case (1 TRX configured)
to avoid breaking backward compatibility.

TA low level loop is still kept in loops.c and will be moved to l1sap at
some point too.

Related: OS#1851
Change-Id: I0d8b0c981d9ead91d93999df6e45fb06e426aeb9
2019-11-30 18:50:04 +00:00
Pau Espin 8ff35d3c91 bts-trx: Time out if no clock ind recvd after RSP POWERON
Before this patch, if due to whatever reason the TRX started fine (RSP
POWERON 0) and sockets were created but no CLOCK IND was ever received
by the BTS, it wouldn't notice since the timerfd timeouts
(bts_shutdown("no clock")) are only checked after the first CLOCK IND is
sent by the TRX.
As a result, the BTS would be kept on forever saying everything is fine
but it would be sending no DL burst at all to the TRX (tested with a
modfied osmo-trx dropping clock indication).
With this patch, new APIs are added to indicate the scheduler_trx code
the timeframes where clock ind are expected (between RSP POWERON 0 and
RSP POWEROFF 0); if TRX sends clock indications out of that timeframe,
BTs lower layers will drop them (controlled by "powered" bool).
Hence, the scheduler_trx can now place a timeout (reusing same timerfd
because its new use is exclusive in time with its other previous use)
when it is told that CLOCK IND should start appearing, and if none
arrives in considerable time, then the BTS can be shut down to notify
the rest of the network.

Related: OS#4215
Change-Id: Iba5dbe867aff10e70ec73dbf1f7aeeecb15c0a4d
2019-10-16 11:13:21 +00:00
Vadim Yanitskiy 54e104496a osmo-bts/scheduler: provide actual C/I values to OsmoPCU
C/I (Carrier-to-Interference ratio) is a value in cB (centiBels),
computed from the training sequence of each received burst,
by comparing the "ideal" training sequence with the actual one.

So far, there was no way to expose more measurements from OsmoTRX,
excluding both RSSI and ToA. Since the new version of TRXD header,
we can receive C/I indications and send the averaged (per 4 bursts)
values to OsmoPCU (as a part of PCUIF_DATA.ind).

Please note that we also need to attach C/I measurements
to the following L1SAP primitives:

  - PRIM_PH_RACH.ind,
  - PRIM_PH_DATA.ind,
  - PRIM_TCH.ind,

but this will be done in the follow up changes.

Change-Id: Ia58043bd2381a4d34d604522e02899ae64ee0d26
Fixes: OS#1855
2019-07-16 04:16:13 +00:00
Vadim Yanitskiy a99c41bac5 osmo-bts-trx/trx_if.c: introduce TRXD header version 0x01 support
The new version adds the following fields to the TRX2L1 message,
keeping the L12TRX message unchanged:

  +------+-----+-----+-----+--------------------+
  | RSSI | ToA | MTS | C/I | soft-bits (254..0) |
  +------+-----+-----+-----+--------------------+

  - MTS (1 octet)  - Modulation and Training Sequence info, and
  - C/I (2 octets) - Carrier-to-Interference ratio (big endian).

== Coding of MTS: Modulation and Training Sequence info

3GPP TS 45.002 version 15.1.0 defines several modulation types,
and a few sets of training sequences for each type. The most
common are GMSK and 8-PSK (which is used in EDGE).

  +-----------------+---------------------------------------+
  | 7 6 5 4 3 2 1 0 | bit numbers (value range)             |
  +-----------------+---------------------------------------+
  | . . . . . X X X | Training Sequence Code (0..7)         |
  +-----------------+---------------------------------------+
  | . X X X X . . . | Modulation, TS set number (see below) |
  +-----------------+---------------------------------------+
  | X . . . . . . . | IDLE / nope frame indication (0 or 1) |
  +-----------------+---------------------------------------+

The bit number 7 (MSB) is set to high when either nothing has been
detected, or during IDLE frames, so we can deliver noise levels,
and avoid clock gaps on the L1 side. Other bits are ignored,
and should be set to low (0) in this case.

== Coding of modulation and TS set number

GMSK has 4 sets of training sequences (see tables 5.2.3a-d),
while 8-PSK (see tables 5.2.3f-g) and the others have 2 sets.
Access and Synchronization bursts also have several synch.
sequences.

  +-----------------+---------------------------------------+
  | 7 6 5 4 3 2 1 0 | bit numbers (value range)             |
  +-----------------+---------------------------------------+
  | . 0 0 X X . . . | GMSK, 4 TS sets (0..3)                |
  +-----------------+---------------------------------------+
  | . 0 1 0 X . . . | 8-PSK, 2 TS sets (0..1)               |
  +-----------------+---------------------------------------+
  | . 0 1 1 X . . . | AQPSK, 2 TS sets (0..1)               |
  +-----------------+---------------------------------------+
  | . 1 0 0 X . . . | 16QAM, 2 TS sets (0..1)               |
  +-----------------+---------------------------------------+
  | . 1 0 1 X . . . | 32QAM, 2 TS sets (0..1)               |
  +-----------------+---------------------------------------+
  | . 1 1 1 X . . . | RESERVED (0)                          |
  +-----------------+---------------------------------------+

== C/I: Carrier-to-Interference ratio

The C/I value is computed from the training sequence of each burst,
where we can compare the "ideal" training sequence with the actual
training sequence, and then express that difference in centiBels.

== Limitations

  - The only supported modulation types are GMSK and 8-PSK.
    Messages with other modulation types will be rejected.

  - IDLE / NOPE indications are not (yet) handled.

  - The logical channel handlers do not (yet) handle optional
    fields, such as TSC and C/I. This will be implemented
    in the follow-up changes.

Change-Id: If61c71d20d590bf07bfd019afb33000a0b6135bd
Related: OS#4006
2019-07-04 01:28:50 +07:00
Vadim Yanitskiy b06cd9f439 osmo-bts-trx/trx_if.c: introduce TRXD header version handling
It may be necessary to extend the message specific header with
more information. Since this is not a TLV-based protocol, we
need to include the header format version.

  +-----------------+---------------------------+
  | 7 6 5 4 3 2 1 0 | bit numbers (value range) |
  +-----------------+---------------------------+
  | X X X X . . . . | header version (0..15)    |
  +-----------------+---------------------------+
  | . . . . . X X X | TDMA TN (0..7)            |
  +-----------------+---------------------------+
  | . . . . X . . . | RESERVED (0)              |
  +-----------------+---------------------------+

Instead of prepending an additional byte, it was decided to use
4 MSB bits of the first octet, which used to be zero-initialized
due to the value range of TDMA TN (0..7). Therefore the current
header format has implicit version 0.

Otherwise Wireshark (or trx_sniff.py) would have to guess the
header version, or alternatively follow the control channel
looking for the version setting command.

This change introduces a new structure 'trx_ul_burst_ind', which
represents an Uplink burst and the corresponding meta info. The
purpose of this structure is to avoid overloading the existing
functions, such as trx_sched_ul_burst(), with more and more
arguments every time we bump the version.

On receipt of a TRXD message, trx_data_read_cb() now parses
the header version, and calls the corresponding dissector
functions, e.g. trx_data_handle_(hdr|burst)_v0().

Change-Id: I171c18229ca3e5cab70de0064a31e47c78602c0c
Related: OS#4006
2019-06-27 12:51:02 +07:00
Vadim Yanitskiy 01c539284e common/scheduler.c: refactor description of TRXC_* lchans
Let's avoid fancy alignment in the description of logical channels
for the benefits of having better readability, the ability to add
more comments and fields without making it look ugly.

Get rid of value-string array 'trx_chan_type_names', since each
logical channel has its name defined in 'trx_chan_desc'.

Get rid of field 'chan' of 'trx_lchan_desc' structure since it's
not used anywhere, and not actually needed because the position
of each lchan description is defined by its TRXC_* type.

Replace both 'pdch' and 'auto_active' fields with more generic
bitmask field called 'flags', and define the following flags:

  - TRX_CHAN_FLAG_AUTO_ACTIVE,
  - TRX_CHAN_FLAG_PDCH.

Use RSL channel mode #defines from libosmogsm instead of having
hard-coded numbers. This increases readability.

As a bonus, let's add a human readable description to each lchan
definition, so it can be printed in the VTY some day.

Change-Id: I9d5d49ec569f133d37b8164b22607d4700474315
Backported from: I2fc61e1cdca4690a34e2861b9ee3b7c64ea64843
		 I7ab4958801b3422973b67ff0452b90afa8a3f501
2019-06-08 10:09:42 +00:00
Vadim Yanitskiy 8ec940ce9a osmo-bts/scheduler.h: cosmetic: use bool for ho_rach_detect
Change-Id: Id357e4ed38cbdca2082322da12b93d556056e916
2019-06-01 23:10:02 +07:00