Commit Graph

24 Commits

Author SHA1 Message Date
Vadim Yanitskiy b7335dfe79 trxcon: group header files into 'include/osmocom/bb/trxcon'
This is the first step towards the goal of moving the scheduler
into a separate library.

Change-Id: Ifa6137c239c215a3d323213ee74d34b419622be4
Related: OS#5599, OS#3761
2022-07-02 19:02:49 +07:00
Oliver Smith 1741372556 treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I73be012c01c0108fb6951dbff91d50eb19b40c51
2021-12-14 12:52:04 +00:00
Vadim Yanitskiy a7298e316f trxcon/scheduler: invalidate hard-coded Measurement results
This is what trxcon sends to the network before the first SACCH
block is received from the higher layers.  The indicated values
are of course invalid because they're hard-coded.

According to 3GPP TS 44.018, table 10.5.2.20.1:

  0  The measurement results are valid
  1  The measurement results are not valid

Change-Id: I7da767e146aec7cef1de71e4d735d6a02b6c5642
Related: SYS#4918
2020-11-30 16:06:48 +01:00
Vadim Yanitskiy 1ae959fe25 trxcon/scheduler: clarify the content of Measurement results
Change-Id: I26546dcbc853166e351d00260936b1b9d584ae03
2020-11-30 16:00:13 +01:00
Vadim Yanitskiy a7b6dea829 trxcon/scheduler: clarify Measurement results padding
Table 10.5.2.20.0 "Measurement Results Contents" in 3GPP TS 44.018
is clear on what should be used as padding - '0**', i.e. zeroes.

Change-Id: I4db6845c98aded10291134f416da98fd0f4f58e3
2020-11-30 14:33:07 +01:00
Pau Espin 5b7fc0a8cc trxcon: Use current MS Power on dummy meas reports
backpointers are added in order to access the TRX, as advised in the
existing comment.

Change-Id: I975cfc5f5d63eb32a7f8932a7f6a544c9a12233c
2019-12-04 14:41:56 +01:00
Vadim Yanitskiy 91d5e5e191 trxcon/scheduler: fix: do not ignore SACCH prims with odd length
Before this patch, prim_dequeue_sacch() used to ignore SACCH primitives
with odd length (e.g. 21, when sender forgot to push 2 octets of L1
SACCH header), so neither they were transmitted, nor rejected.

As a result, they would stay in the Tx queue until a dedicated
connection is released. The only way to notice such problem
was looking at the constantly growing talloc's report.

Instead of ignoring the primitives with odd length and keeping them
in the queue, let's pass them to a logical channel handler, so they
would be dequeued and rejected with a proper logging event.

Also, to simplify further debugging, let's print the final decision
of SACCH prioritization: whether it's a Measurement Report or not.

Change-Id: I3149fa518439470b397953306209eb859c83450a
2019-06-02 04:04:08 +07:00
Vadim Yanitskiy 0cd4252ab5 trxcon/scheduler: fix Measurement Reporting on SACCH
According to 3GPP TS 04.08, section 3.4.1, SACCH logical channel
accompanies either a traffic or a signaling channel. It has the
particularity that continuous transmission must occur in both
directions, so on the Uplink direction measurement result messages
are sent at each possible occasion when nothing else has to be sent.
The LAPDm fill frames (0x01, 0x03, 0x01, 0x2b, ...) are not
applicable on SACCH channels!

Unfortunately, 3GPP TS 04.08 doesn't clearly state which "else
messages" besides Measurement Reports can be send by the MS on
SACCH channels. However, in sub-clause 3.4.1 it's stated that
the interval between two successive measurement result messages
shall not exceed one L2 frame.

This change introduces a separate handler for SACCH primitives,
which dequeues a SACCH primitive from transmit queue, if present.
Otherwise it dequeues a cached Measurement Report (the last
received one). Finally, if the cache is empty, a "dummy"
measurement report is used. When it's possible,
a non-MR primitive is prioritized.

Change-Id: If1b8dc74ced746d6270676fdde75fcda32f91a3d
Related: OS#2988
2018-09-28 23:15:58 +00:00
Vadim Yanitskiy 9a545c777d trxcon/sched_prim.c: drop redundant tn validation
Change-Id: I553b4cc39b2efd7b60346160c57f01ee4cf066be
2018-09-28 18:25:25 +07:00
Vadim Yanitskiy 195fe9b84c trxcon/scheduler: pass talloc ctx directly to sched_prim_init()
Enforcing pointer to a 'trx_instance' structure is not flexible,
because it is used as parent talloc context only.

Change-Id: I5ab2ef5cea76f955bf72ef54541b3b75cdc2d23f
2018-09-28 05:31:26 +07:00
Vadim Yanitskiy bde71c180a trxcon/scheduler: pass lchan state to sched_prim_dequeue()
Having access to a logical channel state is required by the
follow-up change, which will introduce a separate function
for dequeuing SACCH primitives.

Change-Id: Ibde0acf8e6be224b1007be707a636eaad68c8d36
2018-09-28 02:47:54 +07:00
Vadim Yanitskiy 1bffe899d9 trxcon/scheduler: introduce TCH/H TDMA frame mapping helpres
Unlike xCCH, TCH/H channels are using block diagonal interleaving,
so every single burst carries 57 bits of one traffic frame, and 57
bits of another one. Moreover, unlike TCH/F where both traffic
and FACCH/F frames are interleaved over 8 bursts, a FACCH/H is
interleaved over 6 bursts, while a traffic frame is interleaved
over 4 bursts.

This is why a TCH/H burst transmission can't be initiated on
an arbitrary TDMA frame number. It shall be aligned as of
stated in GSM 05.02, clause 7, table 1.

This change introduces two basic functions:

  - sched_tchh_block_map_fn - checks if a TCH/H block transmission
    can be initiated / finished on a given frame number
    and a given channel type;

  - sched_tchh_block_dl_first_fn - calculates TDMA frame number of
    the first burst using given frame number of the last burst;

and some auxiliary wrappers to simplify the usage of
sched_tchh_block_map_fn().

Change-Id: Iaf4cb33f1b79df23f8a90c8b14ebe0cd9907fbb9
2018-09-16 02:12:09 +07:00
Vadim Yanitskiy 347406cee7 trxcon/scheduler: get rid of useless lchan->rsl_mode
This field of the logical channel state structure was not used at
all as there is nothing related to A-bis / RSL in trxcon itself.

Change-Id: Iec1abf777a74cf57deadafa95e2337cba5d02842
2018-08-15 09:32:08 +07:00
Vadim Yanitskiy 3cbbe81b63 trxcon/scheduler: pass lchan to sched_bad_frame_ind()
Instead of passing the information about a logical channel, it
makes sense to pass the pointer to its state where everything
is stored. This approach would allow to avoid adding more
arguments every time, e.g. in case of AMR.

Change-Id: I91fe86fef43aac68776a58c9acc37ef2a9ee8042
2018-08-15 08:20:41 +07:00
Vadim Yanitskiy 0f2b894580 trxcon/sched_prim.c: properly handle both TCH/H and FACCH/H prims
Initially it was assumed that FACCH prioritization should be done
in the same way for both TCH/F and TCH/H. Moreover, it was not
possible to confirm this, because TCH/H was (and still) not
implemented yet. But according to the specs:

  - unlike FACCH/F, FACCH/H transmissions shall be aligned
    within a multiframe, i.e. can only be initiated on
    particular frame numbers (see GSM 05.02, clause 7);

  - unlike FACCH/F, a FACCH/H frame steals two TCH/F frames;

so the TCH/H (including FACCH/H) primitives should be handled
separately from the TCH/F (including FACCH/F) primitives.

Change-Id: I9b59f60e1cbac8fb8fd557b6c67b5e376c0a6bbb
2018-08-14 06:22:04 +07:00
Vadim Yanitskiy 799f26c075 trxcon/sched_prim.c: refactor prim dequeuing logic
The previous primitive dequeuing logic (especially for TCH/F
channels) was a bit complicated, and it could not be possible
to reuse the existing code parts in the upcoming implementation
of both TCH/H and FACCH/H channels without changing anything.

In particular, this change introduces two internal functions:

  - prim_dequeue_one(), which merely dequeues a primitive
    of a given channel type (e.g. TRXC_SDCCH4_0);

  - prim_dequeue_tch(), which dequeues either a FACCH,
    or a speech TCH primitive of a given channel
    type (Lm or Bm).

So the logic of the TCH/F prim dequeuing function has become
cleaner, and the upcoming TCH/H prim dequeuing function, where
FACCH/H prioritization is more complex than FACCH/F, will
reuse the introduced functions.

Change-Id: Ib82ad2480ab1bc6b1df9576eb2bf5acbd398bf66
2018-08-14 05:46:59 +07:00
Harald Welte 9abc5f7982 trxcon: Prefix SACCH fill frame with L1 header
The main problem here is that the existing implementatin missing the L1
header in this message.  A SACCH message doesn't have a 23byte LAPDm
message, but only a 21 byte LAPDm message prefixed by a 2-byte Layer1
header. So on the receiver in the BTS, right now the first two bytes of
the UL SACCH frame are misinterpreted as L1 header.

This it what causes RLL ERROR INDICATION on the Abis side, which is why
our BTS_Tests fail.

Change-Id: Id7776bf3604d0e8a32e04547e01b8bd377903272
Related: OS#3170
2018-04-15 11:09:25 +02:00
Vadim Yanitskiy 02abbe5420 trxcon/sched_prim.c: fix: correct the first padding byte
According to TS 144.006, section 5.2, the first octet containing
fill bits shall be set to the binary value "00101011" == 0x2b.

Change-Id: I8f0304bf84613a2dc07cb78aff0cb8bb4c5adf6c
2018-03-22 20:54:23 +07:00
Vadim Yanitskiy 5eae19098a trxcon/scheduler: transmit dummy frames on CBTX lchans
If at the moment of transmission there are no frames in TX buffer,
then either a dummy LAPDm frame (0x01, 0x03, 0x01, 0x2b ...) or a
silence frame (depending on a codec in use) shall be transmitted.
This is required for proper measurements on the BTS side.

Change-Id: Ie590990f2274ea476678f6b2079f90eeadab6501
2018-03-11 15:03:35 +07:00
Vadim Yanitskiy 96da00d457 trxcon/scheduler: share chan / prim identification helpers
Because they would be also used outside.

Change-Id: Ic8af9d7c72fdb124caef82e35170f92b84e16eb9
2018-01-05 14:34:49 +07:00
Vadim Yanitskiy 6c0b1261a3 trxcon/scheduler: FIX: return NULL from TCH dequeue function
Initially it was expected that a TCH transmit queue could contain
TCH and FACCH primitives only. But there are also SACCH primitives,
which are also being stored there.

So, let's drop the assertations from the sched_prim_dequeue_tch(),
and return NULL if nothing was found.

Change-Id: Iae37057d35883c09a76f0612e52c2d14d9ff91cb
2018-01-04 00:10:18 +01:00
Vadim Yanitskiy 32c2a1d74c trxcon/scheduler: prioritize FACCH correctly
Previously we used to compare two consecutive first primitives,
taken from a transmit queue. This approach may cause some delay,
which is critical for FACCH e.g. in case of handover.

Let's walk through a whole transmit queue to find a pair of
both FACCH frames, and only then decide what to do.

Change-Id: I925cca77bfaa255dd095bc882c901d41c9bc4633
2017-12-18 05:26:57 +07:00
Vadim Yanitskiy a403215bea trxcon/scheduler: move prim management outside lchan handlers
Previously, each lchan handler used to obtain and delete primitives
from a timeslot's tranmit queue itself. This approach entails many
potential problems and bugs:

  - The lchan handlers shall not do that by definition, they
    should encode and decode frames according to GSM 05.03.

  - In some cases (e.g. TCH), a single transmit queue may contain
    primitives of different types (e.g. TCH, FACCH and SACCH). At
    the same time, the lchan handlers don't care and don't even
    know about each other. So, this could cause an unexpected
    behaviour in some cases.

This change separates all primitive management routines,
providing a new API for obtaining and dropping them.

"Write programs that do one thing and do it well."

Change-Id: I29503ece51903784bc53541015285234471c8d15
2017-12-18 05:26:48 +07:00
Vadim Yanitskiy 15d512d301 trxcon/scheduler: separate primitive management code
It's good to write, keep and make the source code as much modular
as possible. So, Tte primitive management code was separated to
the 'sched_prim.c' and going to be extended in the near future.

Change-Id: Ifec8c9e4f2c95c72b00772688bcb5dc9c11d6de7
2017-12-18 05:20:25 +07:00