Commit Graph

128 Commits

Author SHA1 Message Date
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 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 523598e655 osmo-bts-trx: use a lookup table in trx_sched_meas_avg()
This should be better performance-wise and would also allow to avoid
having the same switch statement duplicated in functions added later.

Change-Id: If8124dcd38e7c8408a9f3b9a574d9e3181a2eb15
2022-03-18 03:53:06 +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 d84567779c osmo-bts-trx: new rate counter 'trx_sched:dl_fh_cache_miss'
This new rate counter allows to monitor the efficiency of the
radio carrier cache used for routing Downlink bursts when
baseband frequency hopping is in use.

Change-Id: Ie6da829e47298476267c8df2dcedafad564cbbb4
Related: SYS#5855
2022-03-09 07:22:27 +00:00
Vadim Yanitskiy ff30ca63a9 osmo-bts-trx: cosmetic: use rate_ctr_inc2() instead of rate_ctr_inc()
Change-Id: Id4c5999876ff284b80a021e075bf46eb9d4670a2
Related: SYS#5855
2022-03-09 07:22:27 +00:00
Pau Espin ad8426e40c bts-trx: Log lchan if avaialble in Meas Avg
Change-Id: I1460715fa46c4195c5aaac91be776ad770d8099e
2022-03-03 19:03:07 +01:00
Harald Welte 430954630b initial support for static userspace probes via systemtap
This adds a --enable-systemtap configure option, which will then
add static tracepoints to the generated osmo-bts-* binary.

At this point, only two sets of tracepoints are supported, and
only in osmo-bts-trx: ul_data_{start,done} and dl_rts_{start,done}.

The probes are intended to be used for analyzing the amount of time
needed for processing of uplink bursts / generation of downlink bursts.

Change-Id: Ibb4962253f1a195dc1a54405bac058ccb2545799
2021-10-25 10:06:09 +00:00
Vadim Yanitskiy 605cb85afd osmo-bts-trx: report PDCH interference levels to L1SAP
Starting from [1], interference levels on PDCH timeslots are also
reported over the A-bis/RSL.  They may be useful for the BSC to
determine whether dynamic PDCH timeslots might be better used for
new circuit switched connections, or whether alternative PDCH slots
should be allocated for interference reasons.

 * Handle GSM_LCHAN_PDTCH in lchan_report_interf_meas().
 * Rework pcu_tx_interf_ind() to accept 'struct gsm_bts_trx'.
 * Call pcu_tx_interf_ind() from l1sap_interf_meas_report().

Regarding pcu_tx_interf_ind(), it's better to call this function
from the upper layers once, rather than calling it from various
places in the model specific code.

[1] I5b4d1da0920e788ac8063cc765fe5b0223c76758

Change-Id: I3fbaad5dbc3bbd305b3ad4cb4bfb431a42cfbffc
Related: SYS#5313
2021-10-08 16:54:20 +06:00
Vadim Yanitskiy 0e8d68437a osmo-bts-trx: implement BCCH carrier power reduction mode
The BCCH carrier (sometimes called C0) of a BTS shall maintain
discontinuous Downlink transmission at full power in order to
stay 'visible' to the mobile stations.  Because of that, early
versions of 3GPP TS 45.008 prohibited BS power reduction on C0.

However, in the recent 3GPP TS 45.008 there is a feature called
'BCCH carrier power reduction operation'.  This is a special
mode of operation, where the variation of RF level for some
timeslots is relaxed for the purpose of energy saving.

In BCCH carrier power reduction operation, for timeslots on the
C0 carrier, except timeslots carrying BCCH/CCCH, the output power
may be lower than the output power used for timeslots carrying
BCCH/CCCH.  In this case the maximum allowed difference in output
power actually transmitted by the BTS is 6 dB.

The power reduction operation can be controlled by the BSC by
sending BS POWER CONTROL on the A-bis/RSL with the Channel Number
IE set to 0x80 (RSL_CHAN_BCCH).  This makes osmo-bts reduce the
transmission power on inactive timeslots of the BCCH carrier.

This is a non-standard, Osmocom specific extension, so indicate
support of this feature to the BSC in the feature vector.  Also
add a VTY command to allow enabling/disabling the power reduction
locally.  Add some signalling notes to the A-bis/RSL manual.

For more details, see 3GPP TS 45.008, section 7.1.

Change-Id: I3dcee6e910ccc61c5c63c728db9ea04327e2fc98
Depends: I69283b3f35988fc7a1a1dcf1a1ad3b67f08ec716
Related: SYS#4919
2021-07-01 02:01:22 +02:00
Vadim Yanitskiy f47fa70b9f osmo-bts-trx: report PDCH interference levels to the PCU
The PDCH multiframe contains 48 data slots, 2 PTCCH slots, and
2 IDLE slots.  The later two can be used for the interference
measurements, since the UEs shall not transmit on them.

bts_report_interf_meas() is called every 104 TDMA frames, what
corresponds to 2 PDCH multiframe periods.  Report interference
levels on PDCH timeslots from this function.

Change-Id: I56f83db5264c246ec1b4b8a973105a4fc09931fb
Related: SYS#5313, OS#1569
2021-06-18 18:56:57 +02:00
Vadim Yanitskiy dded16c4c9 osmo-bts-{trx,virtual}: get rid of dummy tx_idle_fn()
This logical channel handler does nothing more than just logging.

Change-Id: I438705f8dd902193e6c7b499d8ee55c56b6a1c2e
2021-06-18 18:56:57 +02: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 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
Pau Espin 163ff40dd5 Use new stat item/ctr getter APIs
Generated with spatch:
"""
@@
expression E1, E2;
@@
- &E2->ctr[E1]
+ rate_ctr_group_get_ctr(E2, E1)
"""

Change-Id: I9b8e31adcbb3142d3d09f1f0e0ae7e435bb2c5ca
2021-06-04 17:59:43 +02: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 97193ced54 [VAMOS] osmo-bts-trx: rework and split up bts_sched_fn()
Currently, in bts_sched_fn() we send a Downlink burst to the PHY
immediately after calling the associated logical channel handler.
Together with the obvious performance advantages, this approach
imposes some serious limitations.  The code has already become
quite complex with the introduction of the baseband frequency
hopping, and now it's not possible anymore to extend it further.

TRXD PDU batching, which is essential for VAMOS implementation,
requires us to make the scheduler more flexible at the expense of
increased memory consumption and additional CPU cycles.  This patch
splits up Downlink burst scheduling into 3 main steps:

  1. bts_sched_init_buffers(): initialization of per-TRX Downlink
     burst buffers allocated by phy_instance_create().  For C0/TRX0
     all timeslots are pre-initialized with dummy burst.
  2. bts_sched_fn(): generating burst bits for all active lchans.
  3. bts_sched_flush_buffers(): sending everything to the PHY.

This approach allows us to a) get rid of the ugly tail in bts_sched_fn()
that was responsible for sending dummy bursts on C0/TRX0;  b) implement
the PDU batching and have several variants of bts_sched_flush_buffers()
providing the alternative batching approaches later on;  c) implement
PDU merging for the upcoming shadow transceivers.

Change-Id: Iec78989517865b3275a9784d1042a5ebd1d2815f
Related: SYS#4895, OS#4941
2021-05-23 12:10:38 +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 b4c0e43c60 osmo-bts-trx: fix hopping pointer bug in bts_sched_fn()
In change [1] together with the actual implementation I introduced
a serious bug to bts_sched_fn(): if a timeslot is configured to use
frequency hopping, both 'pinst' and 'l1h' pointers are *overwriten*
in the inner loop, so the Downlink burst is re-directed to the
approproate PHY instance.  However, if a subsequent timeslot is not
hopping, the Downlink burst would be re-directed to the wrong PHY
instance because both pointers were overwriten during a previous
iteration.

Let's move the 'struct phy_instance' pointer to the inner loop, so
it's properly re-initialized for each timeslot iteration.

Change-Id: I9afbbef8dc5d885763356470c27d4392dce8e815
Fixes: [1] I68f4ae09fd0789ad0d8f1c1e17e17dfc4de8e462
Related: SYS#4868, OS#4546
2021-05-18 19:11:06 +00:00
Vadim Yanitskiy 98aeaf6fa7 osmo-bts-trx: remove redundant assert() in bts_sched_fn()
trx_phy_instance() does assert() that the given TRX pointer is
not NULL.  In bts_sched_fn() it can never be NULL, so drop it.

Change-Id: I896ff5117588f2229cc54619ce62fd027a9ef25f
2021-05-18 19:11:06 +00:00
Vadim Yanitskiy e728f22136 osmo-bts-trx: cosmetic: s/trx_sched_fn/bts_sched_fn/g
Change-Id: I47e05b5b3f586430aa0b56c3d3c9a1da23077513
2021-05-18 19:00: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 b6d3e2c360 [VAMOS] struct gsm_bts_trx: fix the PHY instance pointer
First of all, there is no reason to use a void pointer because
it's always 'struct phy_instance'.  Also, no need to encapsulate
this pointer into 'role_bts' because there are no other roles in
osmo-bts (we used to have shared headers years ago).

This commit also fixes a bug in test_sysmobts_auto_band(), where a
pointer to 'struct femtol1_hdl' was directly assigned to trx.pinst.

Change-Id: I9bd6f0921e0c6bf824d38485486ad78864cbe17e
2021-05-09 02:05:48 +02:00
Pau Espin 29c4f3173f bts-trx: reorder first timerfd schedule to decrease first timeout skew
By reordering the instruction, we scheduler the timerfd prior to
processing the FN on the upper layers. This means the first timerfd
expiration even will happen more inline with the expected time, that is,
CLOCK IND time + GSM_TDMA_FN_DURATION_nS.

Let T(trx_sched_fn) be the time spent executing function trx_sched_fn().
With previous order, the timerfd would have been scheduled later, which
in the end would mean expiration would happen at time CLOCK_IND +
GSM_TDMA_FN_DURATION_nS + T(trx_sched_fn), hence ending up with an extra
skew of T(trx_sched_fn) added by ourselves.
This extra skew added may be important specially at startup time (when
this code path is used), since usually the load in the system is high
and skew is usually already higher, which means helping crossing
unacceptable thresholds which may end up in osmo-bts-trx stopping with
"No clock from osmo-trx" reason.

Change-Id: Ie2ba35cd87f0bd4078ac3b4b5ec2eacad36c4258
2021-03-15 18:33:14 +01:00
Pau Espin 8593b38616 bts-trx: Drop duplicate set of last_clk_ind
These fields are always aready set by the only caller of the function
trx_setup_clock(), so there's no use in re-setting them.

Change-Id: Id8a7141984e07eb11abae08e0c63ae7ebc333511
2021-03-15 18:12:41 +01:00
Vadim Yanitskiy 5ca7707e85 osmo-bts-trx/scheduler: use DMEAS in trx_sched_meas_avg()
Change-Id: I68a37e17469ec9f8178fd2027b8860dbc643a4f9
Related: OS#5007
2021-02-05 16:41:27 +01: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 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
Vadim Yanitskiy 0cd8df2184 gsm_data: rename hopping.{ma,ma_len} to hopping.arfcn_{list,num}
MA (Mobile Allocation) is actually a bit-mask indicating those ARFCNs
of the Cell Allocation, which must be used as the hopping sequence.

What we store in struct gsm_bts_trx_ts is the actual list of hopping
channels, so let's name it properly and eliminate possible confusion.

Change-Id: I677d66e428fa0fe119ebc37bc2a4e6cc05c251c4
2020-09-17 15:45:48 +00: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 10e64630ce osmo-bts-trx/scheduler: refactor dummy burst scheduling
This change facilitates the upcoming freq. hopping implementation,
in particular scheduling of dummy bursts on C0 with hopping time-
slots.  One problem is that we cannot know in advance, whether to
send a dummy burst on a given timeslot unless all transceivers are
processed.  For example, trx#3 may want to send a normal burst on
ARFCN of trx#0 (C0), while we have already sent a dummy burst...

Another important aspect is that we shall not be sending dummy
bursts on transceivers other than C0.  Scheduling dummy bursts
from _sched_dl_burst() in the context of a single hopping timeslot
of a single transceiver leaves trx_sched_fn() no way to know
whether it's a dummy burst or something else.

Let's solve both problems by moving dummy burst scheduling logic
from _sched_dl_burst() to trx_sched_fn().  Maintain C0 slot-mask
in the inner (per-trx) loop, so that we can fill missing bursts
with dummy bursts afterwards.

Change-Id: I8c3651c27d2991079e83b8abdb7e2c3f95b97a43
Related: SYS#4868, OS#4546
2020-08-04 10:16:36 +00:00
Vadim Yanitskiy 9d5e955ea1 osmo-bts-trx/scheduler: fix CLCK.ind handling during ramping down
On receipt of either SIGTERM or SIGINT the shutdown FSM initiates
ramping down of the transmit power on Downlink.  I noticed that
for some reason osmo-bts-trx stops sending Downlink bursts during
the process of ramping down.

I also noticed the following imporatant message:

  DL1C NOTICE scheduler_trx.c:287 No more clock from transceiver

despite the transceiver is still powered on and keeps sending
the clock indications over the TRXC interface.

As it turned out, the problem is that on receipt of either SIGTERM
or SIGINT, we also raise the global 'quit' flag, so in the scheduler
trx_sched_clock() stealthy stops handling the clock indications.

Let's ensure that clock indications are handled regardless of the
state of 'quit' flag, so the ramping down would work as expected.

Change-Id: Ia71133d6f0b900e5e103595c83303a7cc5c06edf
2020-08-02 20:20:19 +00:00
Pau Espin aba8354ed3 bts-trx: Introduce rate counter for scheduler timerfd missed FNs
This should provide a quick way to check if the system is frequently
overloaded over time and hence downlink FNs are scheduled later than
expected.

Change-Id: I0051b9ab18ebc9f92db11374d856de94f155efa4
2020-07-05 18:14:07 +02:00
Vadim Yanitskiy b505ac38e7 osmo-bts-trx/scheduler: cosmetic: move trx_if_powered() check
I believe the modern compilers are smart enough to optimize the
outer (per-timeslot) loop of trx_sched_fn() in a way that TDMA
frame number is advanced after making sure that a transceiver
is powered on.  However, it's still more perspicuous to check
availability of a given transceiver first.

Change-Id: I6a97000c1c84e36096e9ba378a489c82caa4cc5b
2020-06-29 08:51:11 +00:00
Vadim Yanitskiy cdc5c6f5c5 osmo-bts-trx/scheduler: make mark trx_sched_fn() return void
This function never returns anything else than 0.

Change-Id: I119535fc09d611ef9f903f5d44aa21cecdce19a2
2020-06-25 18:02:10 +00:00
Vadim Yanitskiy f28dc5197e osmo-bts-trx: fix trx_sched_fn(): properly advance frame number
In trx_sched_fn() we schedule Downlink bursts in advance, in order
to give the transceiver some time to process them.  This function
handles all timeslots of all transceivers in a loop.  The problem
is that the given frame number is overwritten on each iteration.

Let's say we have 4 transceivers, each with default fn-advance 20.
The given frame number N will be advanced 4 times, so the resulting
frame number for 4-th transceiver would be (N + 4 * 20) instead of
(N + 20) as expected.  Therefore, all additional transceivers would
be served more and more in the future (depending on their position).

Change-Id: Ie3ab544eac81a675266df09cd2b7740e4183188e
2020-06-25 18:02:10 +00:00
Vadim Yanitskiy 2f18578dcc Use libosmocore's TDMA frame number API (constatns & arithmetic)
Depends: (libosmocore) Ic291fd3644f34964374227a191c7045d79d77e0d
Change-Id: I61c97a62bd5dbbb4a984921ebdfc10ad6ed00f2a
2020-06-25 18:02:10 +00:00
Vadim Yanitskiy 906a9b5e71 osmo-bts-trx: include BS Power reduction in Downlink bursts
For those osmo-bts-trx specific logical channels with a generic
logical channel state associated, let's finally apply the BS Power
reduction (attenuation) value that was received from the BSC.

Change-Id: Ib692ff1a75a80fceccb481839c8514d4b2a547b9
2020-06-15 21:06:52 +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 36c5ec4881 osmo-bts-trx: move logical channel handlers to separate files
It's easier to maintain the logical channel handlers in separate
files, rather than in a huge one (scheduler_trx.c, ~2k lines).

Change-Id: Ie5663fd90596b4800a4546675a323250bbb24c80
2020-06-15 10:42:03 +00:00
Vadim Yanitskiy f896d64e22 osmo-bts-trx/scheduler: properly handle NOPE.ind during handover
Looking at GSMTAP during handover, I've noticed many packets on
RACH looking pretty much like false positives, all with RA=0x00.
I correlated GSMTAP traces with TRXD traces, and figured out
that they all are triggered by NOPE indications from osmo-trx.

Since a NOPE.ind carries no valid burst, all its bits are set to
zero. Funny enough, this sequence is still decoded just fine as
a valid RACH, so that's why we see it on GSMTAP. Later on it
gets rejected by L1SAP due to bad RSSI, ToA, and/or C/I ratio.

The is a side effect of [1]. In order to ensure proper Uplink
measurement reporting during handover, including the time
before the handover RACH is received, let's treat and handle
NOPE indications as Normal Bursts.

[1] Ice45d5986610d9bcef2a7e41f0a395ec779e3928

Change-Id: Ic69f3bc2b776a23374c28a6884080a54bc16ef5f
Related: OS#4592
2020-06-12 06:55:05 +00:00
Vadim Yanitskiy 71fd083c16 osmo-bts-trx/scheduler: remove a left-over from UL TCH handlers
Change-Id: I58eedd611ecd31cc36017545de2cf29acf49f521
Signed-off-by: Vadim Yanitskiy <axilirator@gmail.com>
2020-05-12 19:55:05 +07:00
Pau Espin 63920cefa6 Use OSMO_FD_* instead of deprecated BSC_FD_*
New define is available since libosmocore 1.1.0, and we already require
1.3.0, so no need to update dependenices.
Let's change it to avoid people re-using old BSC_FD_READ symbol when
copy-pasting somewhere else.

Change-Id: Id51ccb2c273c5f0fa4986f28bbd69a72d2dbaa0e
2020-05-09 18:59:47 +02: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
Harald Welte 4e07b83a64 trx: Use NOPE indications from OsmoTRX for TCH/F and TCH/H
Without using the NOPE indication it might happen that we get
into the following situation:
* bursts 0,1,2 of a given block are received
* burst 3 is lost on the radio interface, OsmoTRX sends NOPE
* osmo-bts-trx doesn't pass the NOPE the the rx_tch*_fn()
* we never detect the end of the block, never perform decoding
  and even if the burst could be fully decoded, we loose the block

For voice, it can lead to lost RTP frames in uplink, which is also
problematic.

Let's deal with burst_len=0 in rx_tch*_fn() and use it as nope_fn.

Closes: OS#4661
Related: OS#2975
Change-Id: I0fbf4617daf24bd8aecfd9cfe1efd66cf73a277a
2020-03-22 14:06:47 +01:00
Harald Welte f1efd727fb trx: Fix reported BER for TCH/H
This fixes a regression introduced in I710d0b7cf193afa8515807836ee69b8b7db84a84

We (obviously!) cannot compute the BER before performing convolutional
decoding.

Change-Id: I4e57f45d49cb513e4843e56f50c8de6980958fdc
Related: OS#2977
Related: OS#4667
2020-03-22 14:06:47 +01:00
Pau Espin 6ea3b28321 cosmetic: Fix some typos with codespell
Change-Id: I1bbb4871f764816dcbba86d833194be601fa9228
2020-02-25 18:51:15 +01:00
Philipp Maier d4f67591c7 l1sap: merge MEAS IND into PRIM PH DATA / PRIM TCH
The MPH INFO MEAS IND indication, which contains the uplink measurement
data is sent in parallel to the PH DATA and TCH indications as a
separate indications. This makes the overall uplink measurement data
processing unnecessarly complex. So lets put the data that is relevant
for measurement into the PH DATA and TCH indications directly.

This change only affects osmo-bts-trx at the moment. In order to keep
the upper layers (l1sap.c) compatible we add an autodection to switch
between separate measurement indications and included measurement data.

Related: OS#2977
Depends: libosmocore I2c34b02d329f9df190c5035c396403ca0a4f9c42
Change-Id: I710d0b7cf193afa8515807836ee69b8b7db84a84
2020-01-20 14:35:19 +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