Commit Graph

35 Commits

Author SHA1 Message Date
Vadim Yanitskiy 529d54b13a trxcon/scheduler: introduce and use struct sched_burst_req
Similar to what we do in osmo-bts-trx, group everything related to
an Uplink burst into a structure.  Pass a pointer to this structure
to the logical channel handlers.  This makes the code easier to read,
and facilitates sending NOPE indications to the transceiver
(will be introduced in the upcoming patch).

Get rid of sched_trx_handle_tx_burst(), and instead just call
sched_trx_a5_burst_enc() directly from sched_frame_clck_cb().

Change-Id: Id45b27180c233fdc42ae1ef0b195554dd299a056
Related: SYS#5313, OS#1569
2021-06-16 15:55:32 +02:00
Vadim Yanitskiy d81231672f trxcon/scheduler: align Downlink reception to the first burst
It may happen that the burst reception would start from bid != 0:

  <0005> sched_trx.c:263 (Re)configure TDMA timeslot #2 as TCH/H+SACCH
  <0005> sched_trx.c:420 Activating lchan=TCH/H(0) on ts=2
  <0005> sched_trx.c:420 Activating lchan=SACCH/TH(0) on ts=2
  <0006> sched_lchan_xcch.c:96 Received incomplete data frame at fn=0 (0/104) for SACCH/TH(0)
  <0006> sched_lchan_xcch.c:106 Received bad data frame at fn=0 (0/104) for SACCH/TH(0)

so in that case, both measurement processing and the frame number
calculation would yield incorrect and/or incomplete results. The
Rx burst mask can be used to eliminate this problem.

In particular, if we shift it left instead of cleaning, it would
never be equal 0x00 after at least one burst is received. This
would allow us to skip decoding of an incomplete frame at the
beginning when the logical channel was just activated.

Note that TCH/H handler is not affected because it already uses
the strategy described above, so we keep it unchanged.

Change-Id: Ib8ddf2edd5ef84f2ab12155f7a8874c9fc56d436
Related: OS#3554
2020-03-16 10:32:42 +00:00
Vadim Yanitskiy f5fa7dbd19 trxcon/scheduler: constify Downlink burst bits where possible
Change-Id: Ib3e3a0a5b4551126b1a9439000d4438c58a6a90a
2020-03-16 10:32:42 +00:00
Vadim Yanitskiy 8c760f8f05 trxcon/scheduler: refactor TDMA frame number calculation
Using TDMA frame number of a burst with bid=0 is fine for xCCH,
but not for TCH and FACCH, because they use the block-diagonel
interleaving. A single block on TCH may be interleaved over
8, 4 or even 6 consecutive bursts depending on its type.

Since we now have the measurement history, we can attach TDMA
frame number to each measurement set, and then look up N-th
one when averaging the measurements in sched_trx_meas_avg().

Change-Id: I9221957297a6154edc1767a0e3753f5ee383173f
2020-03-16 10:32:42 +00:00
Vadim Yanitskiy 2060b5b7cc trxcon/scheduler: refactor Downlink measurement processing
So far we used to store the sums of ToA and RSSI measurements in the
logical channel state, and after decoding of a block, we did calculate
the average. This approach works fine for xCCH and PDTCH, but when it
comes to block-diagonal interleaving (which is used on TCH/F and TCH/H
channels), the results are incorrect. The problem is that a burst on
TCH may carry 57 bits of one encoded frame and 57 bits of another.

Instead of calculating the sum of measurements on the fly, let's push
them into a circular buffer (the measurement history), and keep them
there even after decoding of a block. This would allow us to calculate
the average of N last measurements depending on the interleaving type.

A single circular buffer can hold up to 8 unique measurements, so the
recent measurements would basically override the oldest ones.

Change-Id: I211ee3314f0a284112a4deddc0e93028f4a27cef
2020-03-08 22:50:54 +00:00
Vadim Yanitskiy 3f25909e10 trxcon/scheduler: print completeness of the Rx burst buffers
Change-Id: Ife9f5eabc23aa2eea08b190361e10a98e890d608
Related: OS#3554
2020-03-01 01:46:51 +07:00
Vadim Yanitskiy 9731f0d322 host/trxcon: add optional GSMTAP frame logging support
This feature may be useful for our TTCN-3 testing infrastructure.
By default it's disabled, and can be enabled using command line
arguments of the main binary:

  ./trxcon -g 127.0.0.1 ...

Change-Id: Iab4128fee5f18d816830fdca6c5ebebaf7451902
2019-10-05 17:50:20 +07:00
Vadim Yanitskiy c89047d8bc trxcon/scheduler: enrich GSM 05.03 encoding error messages
Change-Id: I35a7c5df4fc0ed2195ba721f92812874011459d9
2019-06-30 17:28:06 +07:00
Vadim Yanitskiy 803e420a4f trxcon/scheduler: clarify decoding of incomplete xCCH blocks
Inspired by Sylvain's message at #osmocom.
Change-Id: I3f499837413e1dbd0ca62229dc9cb6f0f7475a42
2019-03-10 15:32:29 +07:00
Vadim Yanitskiy 4bc4655bd6 trxcon/scheduler: count number of measurements
Instead of counting both RSSI and ToA measurements separately,
let's have a single counter in trx_lchan_state.meas struct.

Change-Id: I45454a3ac92b8cc85dd74092e4ab6eb350f20c9a
2019-02-21 17:20:36 +07:00
Vadim Yanitskiy 1b6be6fc24 trxcon: do not include trxcon.h everywhere
Change-Id: Ia78bd6dac7ab12970838e0b1a2929a106b898d9d
2019-01-17 10:55:41 +07:00
Vadim Yanitskiy 8f6909a94f trxcon/scheduler: fix: check primitive len before encoding
We used to trust (and still doing this) the messages coming from
L1CTL interface too much, and not to check the primitive length
before passing the payload to the libosmocoding API. As was
discovered and described in OS#3415, sending a L1CTL message
(either DATA_REQ, or TRAFFIC_REQ) with an incorrect length
(lower than expected) may cause heap overflow.

Let's explicitly check a primitive before encoding, and drop it
if its length doesn't match the expected value(s).

Change-Id: I258ee9f6d0124b183b1db23a73f1e523fcea89a8
Fixes: OS#3415
2018-07-24 22:24:13 +07:00
Vadim Yanitskiy 40e71126ab trxcon/sched_lchan_xcch.c: always send data indications
We shall always send data frame indications, even if received
frame is incomplete or decoding was failed. This is required
for proper Measurement Reporting.

Change-Id: I7beee7e797f488d04c3b59bee9501ce823717092
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy 47aaf962fb trxcon/scheduler: enforce lchan handlers to set message type
Since this change, each lchan handler shall manually indicate
a type of both message indications and confirmations.

Change-Id: I02e0b87d61c127d2f6f5b9532909af78332bf707
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy c066787fd5 host/trxcon: use integer math for ToA (Timing of Arrival)
There's no need to express ToA value as a float. Let's 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.

Inspired by Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec.

Change-Id: I99c0f38db08a530d5846c474aba352aa0b68fe86
2018-03-02 21:24:57 +07:00
Vadim Yanitskiy f09be8a9af trxcon/scheduler: drop meaningless TODO comment
Since both TA and AGC loops should be implemented in transceiver,
this TODO is meaningless. Let's drop it.

Change-Id: I84979712e2a1b849acaee53d5cd50de4e1e357c2
2018-01-05 14:36:03 +07:00
Vadim Yanitskiy 44838f79a2 trxcon/scheduler: preprocess UL bursts before sending
Having a possibility to preprocess UL burst before sending to
transceiver is required for the further ciphering support
integration and probably some other tasks.

Change-Id: Ia6eead5d4f51d7c0bf277b9d5ebb0a74676df567
2017-12-18 06:04:29 +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 60ff614446 host/trxcon/scheduler: always print error messages
Some error messages previously had incorrect logging level 'debug'.
We aren't going to hide anything, right? Let's print them!

Change-Id: I85fb37292046b667386bfe26b9bbb000600e1c6f
2017-12-16 16:33:17 +07:00
Vadim Yanitskiy a9c2ef2638 host/trxcon/scheduler: inform L2&3 about decoding errors
Previously, we used to drop a frame if decoding wasn't successful.
This way, the higher layers didn't even know about that, so the
local counters and Measurement Reports were incomplete.

This change makes scheduler to forward L2 frames in any case,
setting the num_biterr for each of them. In case of decoding
error, a dummy (payload filled by 0x00) L2 frame will be sent.

Change-Id: I31011d8f3ca8b9a12474cd0bc653faed18391033
2017-12-16 16:21:05 +07:00
Vadim Yanitskiy d2c13e3d20 host/trxcon/scheduler: use GSM_MACBLOCK_LEN definition
Change-Id: Ie3b27ecb62d6f0e84f2e3ec0c1558e32bb213d33
2017-12-16 15:45:12 +07:00
Vadim Yanitskiy 3d872d0eae host/trxcon/scheduler: drop meaningless memset call
Change-Id: I18a938cef350632673cfc820beed5e42f40d89e7
2017-12-16 15:24:54 +07:00
Vadim Yanitskiy 2937cb4c16 host/trxcon/scheduler: clean up the trx_lchan_state
There were some BTS specific variables, which are meaningless.
This change cleans them up, and also groups some measurement,
encryption, and AMR specific variables into sub-structures.

Change-Id: Ie753a7e3e7fa2b433d8319b3a05b85b8583d7be2
2017-12-16 15:24:54 +07:00
Vadim Yanitskiy ac764e78fd host/trxcon/scheduler: separate logging of data messages
Change-Id: I3a33687a688db2a183b546425f71c7a0a7030594
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 863ccb7bd2 host/trxcon/scheduler: share common declarations of lchan handlers
The training sequences, data / traffic indication and confirmation
helpers are used by several lchan handlers, like xCCC and TCH. It
would be better to have them all declared within a shared header.

Change-Id: I71980f09a0c0e023370e1a651afc24fff2491552
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 28088c8910 host/trxcon/l1ctl.c: include DL frame info in L1CTL_DATA_CONF
The l1ctl_info_dl header is expected to be a part of a
L1CTL_DATA_CONF message, but was missing previously.

Change-Id: Ia8dfaed924fd84395ba9ae539164eaa94f52d30b
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 82b8c21b21 host/trxcon/l1ctl.c: don't fill l1ctl_info_ul into a primitive
The UL frame header isn't used by lchan handlers.

Change-Id: Ia1c63b6f17c3802b29f54299da1151a39edf3a03
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 14d0f67064 host/trxcon/scheduler: send stored tx_power to transceiver
Previously a fixed fake value (10) was used.

Change-Id: I8ba70bbda6c8c9249f8eb4294aeb41ab8769a19a
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f9ab2a0b49 host/trxcon/scheduler: clean up some includes
Change-Id: I47e3b953b80f4f822d563579d15498181009ca80
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 0dc5b233e6 host/trxcon/scheduler: share common code for lchan handlers
The training sequences array is currently used by xCCH handlers,
but will be also used for handling both TCH/F and TCH/H bursts.
Moreover the code that forwards decoded L2 payloads to L1CTL
protocol handlers was separated into a new shared function.

Change-Id: I34c3de351362ebd9a070f49bb78d7bd976784b04
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f2179e6763 host/trxcon/l1ctl.c: make l1ctl_tx_data_ind flexible
Now this function can send both DATA and TRAFFIC indications.

Change-Id: I945c10c317155917b6e6ce9d663d9cb46f2e085c
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy c0100cd145 host/trxcon/scheduler: get rid of useless nbits argument
Change-Id: I8508676e2cb347396c6ca6b394f13113f3e63084
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 8fd143ee5a host/trxcon/scheduler: pass trx_lchan_state to lchan handlers
It's better to pass a trx_lchan_state instance directly from
caller to lchan handler instead of passing trx_lchan_type. This
way a handler wouldn't need to find lchan itself.

Change-Id: I47a40542b03ab31da12b0abb1c263c83662ff018
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 18bc7d5e06 host/trxcon/scheduler: ignore incomplete sets of bursts
To be able to decode one xCCH message, it's required to have
all set of bursts collected (4/4). Otherwise we should not
even try to decode an incomplete set.

Change-Id: Iaa63462efe19b8e96102fc8c8d8c968a2df2c70e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 9760a84a6d host/trxcon: split sched_lchan_handlers.c
It would be better to have xCCH, SCH and RACH burst handlers
in separate files, because as much code we add to a single
file, as harder it becomes to read and understand one.

Change-Id: I456a60e68b32b792e63dd03ae97159dc101fd4bf
2017-11-19 17:35:07 +07:00