Commit Graph

41 Commits

Author SHA1 Message Date
Vadim Yanitskiy 7d06c78b37 trxcon/scheduler: add TCH/H channel support
Change-Id: Ibb2a0850692c5ff86b13b820af10b12085589e67
2018-09-16 02:12:11 +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 8ae0c13fa9 trxcon/sched_trx.h: add missing parentheses to PRIM_IS_*
Change-Id: Ifa7d9f806b3f18f2dfec931252f5119441b30e8a
2018-08-14 05:00:00 +07:00
Harald Welte 9d90d1907b trxcon: Respect the tch_mode field of DM_EST_REQ
the initial tch_mode is not always 0 (signalling) but can very well
be directly a codec mode, if the initial activation of the channel
is in speech mode as opposed to signalling

Change-Id: I96e4c89da1165e9c5287d863e0e65d811460c606
2018-04-02 19:57:55 +02:00
Vadim Yanitskiy 96a8f288c6 trxcon/scheduler: add CHAN_IS_SACCH macro
Change-Id: I2fc90d4732433f221c628058c9812815edf9c8cb
2018-03-22 23:04:16 +07:00
Vadim Yanitskiy e05f690102 trxcon/scheduler: share lchan link identifiers
Change-Id: Ie1632f274b2ae6147a8e918ebfea60eeeb6a234c
2018-03-22 23:02:25 +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 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 4cf722364b trxcon/scheduler: introduce a new CBTX lchan flag
This new flag is intended to indicate that continuous burst
transmission is assumed on particular logical channel. In other
words, if a logical channel has this flag, but there is nothing
to transmit in a TX buffer, then either a dummy LAPDm frame or
a silence frame shall be sent.

Change-Id: I25fcf9eeb787ffe5378d92532439e67d7d42fa65
2018-03-11 14:59:43 +07:00
Vadim Yanitskiy c00985bf99 trxcon/sched_trx.h: clarify lchan flags meaning
Change-Id: I51b663dd16e46a4523488c3d3000922a7c3640d1
2018-03-11 14:59:43 +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 0192c028e4 trxcon/scheduler: use TCH frame length defs from libosmocodec
Change-Id: I6439d3cadd2dc1fa8fe401eb61c977a12ec844f2
2018-01-05 15:06:48 +07:00
Vadim Yanitskiy bd6e320c08 trxcon/scheduler: use linuxlist API for lchan management
As there is no any order relation between logical channels, it's
better to use the linuxlist API instead of talloc array.

Change-Id: I5a78582c77ed1ab33817d240e065dc4cd4708199
2018-01-05 14:35:37 +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 feec102aea trxcon/scheduler: implement A5/X ciphering support
This change implements the A5/X ciphering support transparently
for the logical channel handlers. In other words, a DL burst is
deciphered before being passed to a handler, and an UL burst is
ciphered before being sent to transceiver.

The implementation mostly relays on the libosmocore's A5 API.

Change-Id: Ib53418d8c0f394fdece09cf5cc240887cb0bb5af
2017-12-18 06:17:50 +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 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
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 9b511668a4 host/trxcon/scheduler: add initial TCH/F channel support
This change implements basic TCH/F lchan handlers for both data
reception and transmission. Only FACCH (signaling), FR and EFR
payloads are supported at the moment.

Change-Id: If6b0eaede2b484484d2a824e7219ff04483266a1
2017-12-16 15:45:38 +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 cd9b850ee4 host/trxcon/scheduler: process frames in advance
In order to get the transceiver more time to process bursts,
the L1 scheduler should process the frames and send the bursts
in advance (a few frames before), like OsmoBTS does. By default,
the advance value is 20 frames, but this can be adjusted using a
new command line option of trxcon '-f'.

Change-Id: Ic258a169f3554f931d6277e18ca060d029b77f32
2017-11-23 20:05:16 +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 7d95f8821e host/trxcon/l1ctl.c: share primitive management code
This change introduces shared primitive management functions,
exposed from the l1ctl_rx_data_req() implementation:

  - sched_trx_init_prim() - allocates memory for a new primitive
    and its payload. Initializes primitive's header, setting
    the logical channel type and the payload length. After
    initialization, the talloc context of a primitive is
    a trx instance, which passed as the first argument.

  - sched_trx_push_prim() - decodes the timeslot index from
    chan_nr and pushes a primitive to its transimt queue.
    The talloc context of primitive is changed to the
    parent trx_ts instance after queuing.

Both functions will be used for handling both L1CTL_TRAFFIC_REQ
and L1CTL_RACH_REQ.

Change-Id: I8169a1ef4ef54d91b50f3e213e4842f54af8b499
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 58c7faf5eb host/trxcon/scheduler: fix chan_nr parsing
Previously, the chan_nr, received from L2, was parsed in a wrong
way, so in some cases only one logical channel was activated or
some messages (such as Measurement Requests) were sent on
incorrect channel (e.g. on SDCCH instead of SACCH).

This change reimplements the sched_trx_chan_nr2lchan_type(), and
introduces a new function sched_trx_set_lchans(), whics will
parse chan_nr and (de)activate required channels.

Change-Id: I480311c65ef93bbc1644ec708dd2a68fd33091e0
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy b4dd3ac9bb host/trxcon/scheduler: use 'tn' instead of 'ts_num'
The new timeslot index designation is more generic for
Osmocom projects, so let's use one.

Change-Id: I8c0118aad439816148490e57938d7e32b6e20877
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 075c1ad738 host/trxcon/scheduler: git rid of sched_trx_find_ts()
After simplification of timeslot management API this
function does not make sense.

Change-Id: I2fc0c68d784c8f01e1452bc46f8e1eaac2917656
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy c045bc4fbe host/trxcon/scheduler: simplify timeslot management
As we know the count of timeslots per GSM TDMA frame, it would
be better to have an array of pointers to trx_ts instances instead
of linux list, which is more usable for lists with unknown length.

Change-Id: I9510a5cddde22950ceb8422e0990d59f05ed4d60
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 2001221d75 host/trxcon/scheduler: optionally reset clock counter
Change-Id: I4565620fc0c5f64133c2674d2c972fc34245cf32
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 74f8595156 host/trxcon/scheduler: implement xCCH TX capability
Change-Id: I4da4816dcecc55eb9b4d2d6c631967026a5e4f68
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 824bfa299d host/trxcon/l1ctl.c: handle L1CTL_DM_{EST,REL}_REQ
Change-Id: Ifdf229a6dd3c73ede313d2bfe384032e3887cc3a
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 2abc7a4998 host/trxcon/scheduler: implement TX queue handling
Change-Id: I2b7bae53901156524134c4904ea1179268d85601
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 85b700421f host/trxcon/scheduler: modify trx_lchan_tx_func definition
Initially, it was assumed that TX lchan handler will only
compose a burst and return a pointer to the buffer. A burst
itself could be sent somewhere outside, e.g. by caller.

It would be better to send bursts exactly from handler, because
in this case it isn't required to have an external buffer.

Change-Id: Ic9dcdd366e68cec38c5840ed8f8cdda8236d67c7
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ec3a1ba2e5 host/trxcon/scheduler: handle bursts from TRX interface
Change-Id: Iff15daf897f30cb98d4ec4c88b9fc259cb44ea4e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 8baa369b23 host/trxcon/scheduler: implement management functions
This change introduces some new functions to configure
TDMA scheduler. They can be grouped as follows:

  - Scheduler management functions
    - sched_trx_init()
    - sched_trx_reset()
    - sched_trx_shutdown()

  - Timeslot management functions
    - sched_trx_add_ts()
    - sched_trx_find_ts()
    - sched_trx_del_ts()
    - sched_trx_reset_ts()
    - sched_trx_configure_ts()

  - Logical channel management functions
    - sched_trx_activate_lchan()
    - sched_trx_deactivate_lchan()
    - sched_trx_find_lchan()

Change-Id: I6d0f437a68f0eb4e22bf635bf899b08673571085
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 2e18fe4631 host/trxcon/scheduler: add basic GSM PHY definitions
Change-Id: I9f4faa15d5ca61af3e3fdbb95952ab4e4e0b7a4b
2017-11-19 17:35:07 +07:00