Commit Graph

334 Commits

Author SHA1 Message Date
Vadim Yanitskiy 4ccb2261b1 trxcon/sched_lchan_tchf.c: always send traffic indications
We shall always send traffic frame indications, even if received
frame is incomplete or decoding was failed. This is required
for proper Measurement Reporting.

Change-Id: I99e134699796c7075299459e96b2f2d462636619
2018-03-11 17:38:29 +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 caebbebd16 trxcon/sched_lchan_common.c: use static memory allocation
There is no need to allocate the DL header for each new message.

Change-Id: Id7ad815c6b403f5c3d15fc02022397188f1d87fd
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy 633c806a2b trxcon: clean up DATA / TRAFFIC indication API
- change 'l1ctl_tx_data_ind' symbol to 'l1ctl_tx_dt_ind' in
    order to indicate that it's used for both DATA and TRAFFIC;

  - introduce a 'traffic' flag, which is used to define either
    TRAFFIC or DATA indication type;

  - pass L2 payload and its length separately from the
    Downlink info header.

Change-Id: I9fe65ee9b2d772576b86b7bc85d53518530d1579
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy ddddf9e0c4 trxcon: clean up DATA / TRAFFIC confirmation API
- change 'l1ctl_tx_data_conf' symbol to 'l1ctl_tx_dt_conf' in
    order to indicate that it's used for both DATA and TRAFFIC;

  - introduce a 'traffic' flag, which is used to define either
    TRAFFIC or DATA confirmation type;

Change-Id: Iedd569086a264dc7d8740abea5c6e5ca21e299f6
2018-03-11 17:38:29 +07:00
Vadim Yanitskiy d316b84413 trxcon/l1ctl.c: combine both DATA and TRAFFIC REQ handlers
Both functions are almost identical, and the only difference is
the message type they set. Let's combine them into a single
function and introduce a 'traffic' flag, which can be
used to define a message type.

Change-Id: I288f5d7b6cd242c4793973dcb3d2b1b6925d61a7
2018-03-11 10:34:28 +00:00
Vadim Yanitskiy eb3a1cde8c trxcon/l1ctl_link.c: allocate msgb after its length is read
Change-Id: I2b941c5ed91097c4ed2d859634bbe89f44546061
2018-03-11 10:05:48 +00:00
Vadim Yanitskiy 2136891b7b trxcon: clarify L1CTL message length field
Each L1CTL message gets its own length pushed in front before
sending. This isn't specified in the 'l1ctl_proto.h', but
assumed in the code. Let's clarify this.

Change-Id: I118d00613aeaf5ff0bad1188fa5f7450d4ca8122
2018-03-11 10:05:48 +00:00
Vadim Yanitskiy a92fd3388c trxcon: use meaningful names for L1CTL messages
There are two types of L1CTL messages: received and to be
transmitted. Let's use proper names to indicate this.

Change-Id: I7c17687579282fa389bca35dc7edbc3582e55701
2018-03-11 10:05:46 +00: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 2778e4ef43 trxcon/sched_trx.c: fix: omit inactive logical channels
The sched_frame_clck_cb() is responsible for UL burst transmission.
Iterating over each timeslot, it chooses a proper lchan handler
according to a current frame number and a multiframe layout in use,
takes a L2 UL frame from a TX buffer, and finally calls the chosen
handler in order to to encode and transmit a taken frame.

A handler should be called only for activated logical channels...
but for some long time, there was a bug, so each lchan was
processed, including inactive ones. It's time to fix this.

Change-Id: I33e3ecc14be3ae64dfd02789c7f0970c945582c9
2018-03-11 14:59:38 +07:00
Vadim Yanitskiy f06f31fdf7 trxcon/sched_trx.c: fix: properly deallocate lchans
The llist_for_each_entry_safe() should be used instead of the
llist_for_each_entry(), because it's safe against removal
of llist entry.

Found using Valgrind's memcheck tool.

Change-Id: I65234971ec152df038c5388da537a503060c215b
2018-03-11 14:18:22 +07:00
Vadim Yanitskiy cbf818d4dc trxcon/configure.ac: add --enable-sanitize option
Change-Id: I099de726f9d67213c56d996039b4207f80a727c6
2018-03-11 14:14:51 +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
Harald Welte 0d3030c764 trxcon: Fix '-i' to specify the "TRX IP address"
The command line help states '-i' is for 'TRX IP address', which is
the remote IP address at which the TRX is to be found.  Hoewever, it
was used as the local (bind) IP address of the socket used towards
the TRX.  This is my attempt at fixing this.  A more complete solution
probably allows to specify both local (bind) and remote (connect)
address, just to be clear.

Change-Id: If0252b15e9c7942687c6dc470951d777f7af651c
2018-03-01 14:42:25 +01:00
Harald Welte b1b1162019 trxcon: Define event names for osmo_fsm's
Change-Id: Id3279e99966a0ab236923c497ac0abbc9ed2c93c
2018-02-28 23:18:09 +01:00
Harald Welte 05ea7248f8 trxcon|fake_trx: change default TRX port number to 6700
In order to avoid clashes with OsmoTRX, which may be also
running on the same host, let's use a different port range
starting from 6700 by default.

This idea was introduced as a result of OS#2984.

Change-Id: I66b5f25aaba3b836448ed29839c39869b5622bed
Related: OS#2984
2018-02-23 17:02:20 +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 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 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 0c201abbff trxcon/scheduler: deactivate lchans when resetting / deleting TS
Previously, when resetting or deleting a timeslot, we did not
deactivate the logical channels, relaying on talloc hierarchical
nature. This approach may cause some problems, e.g. on embedded
systems with emulated talloc API.

Change-Id: I8c34c793df87bd8c79b7bf1f05b949faf10520e8
2018-01-05 14:35:37 +07:00
Vadim Yanitskiy 5c70e48077 trxcon/scheduler: reset lchan state after deactivation
Let's assume that a logical channel, which was already in use,
is activated again for a new connection. As we don't reset the
state variables, such as burst masks or ciphering data, it may
cause an unexpected behaviour.

In order to avoid this, let's always reset the logical channel
state after deactivation.

Change-Id: I91e736a97cb05b167614cb488a00d847a9a859e0
2018-01-05 14:35:29 +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 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 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
Vadim Yanitskiy e17bb11c3b trxcon/scheduler: BUGFIX: distinguish between SACCH and FACCH
Both SACCH and FACCH messages have the same 23-byte length, both
are being queued together within a single transimt queue. So,
previously a SACCH frame could be picked by TCH burst handler,
and then sent as a FACCH frame. Let's fix this.

A FACCH primitive may have one of the TRXC_TCH* logical channel
types, while SACCH primitives have one of the TRXC_SACCH*.

Change-Id: Ia7090384f3ff74c9d94997265135acbceffa0ffe
2017-12-18 05:18:07 +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 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 21049e5fc4 host/trxcon/l1ctl.c: handle L1CTL_TRAFFIC_REQ
Change-Id: Ibdf2d4f6aa464250a4c6951af86c06eb3fd3b98b
2017-12-16 15:45:17 +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 ab566a7aef host/trxcon/scheduler: use new libosmocoding API for RACH
Since the 32e5641d, the gsm0503_rach_encode() is deprecated, and
the library provides new API with extended (11-bit) RACH support.

Change-Id: I1955fe46eebd173d6eddd1d47ee9f7318b9b4e2d
2017-12-16 15:24:54 +07:00
Vadim Yanitskiy 8ed6f42772 host/trxcon: forward Timing Advance value to transceiver
The time at which the phone is allowed to transmit a burst of
traffic within a timeslot must be adjusted accordingly to prevent
collisions with adjacent users. Timing Advance (TA) is the
variable controlling this adjustment. The TA value is normally
between 0 and 63, with each step representing an advance of
one bit period (approximately 3.69 microseconds).

As trxcon doesn't perform actual burst transmission, this value
needs to be forwarded to the transceiver, which will take care
about the timings.

Change-Id: Ia8c0848827ab2b4cd7cf1efe128b28d5c06ec84e
2017-12-05 01:16:44 +07:00
Vadim Yanitskiy 0d9680e88a host/trxcon/trx_if.c: get rid of useless commands
The 'SETMAXDLY' command is used on the BTS side to limit maximal
Time of Arrival for access bursts. As we don't receive RACH
bursts on the MS side, the command is useless.

The 'SETRXGAIN' command is used on the BTS side to set initial
receive gain value for TRX. On the MS side it's possible to set
that parameter via command-line options of TRX.

Change-Id: I3e61b4b48193004cdcb241cefabb44c12db93120
2017-12-04 23:59:55 +07:00
Vadim Yanitskiy c5d9507b5d host/trxcon/trx_ic.c: use osmo_ubit2sbit() from libosmocore
No need to reimplement the existing functions...

Change-Id: Ic9b232c8561609d42dac10e6249a3e1c58c4edc1
2017-12-04 23:59:49 +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 e8cf6c4eef host/trxcon: fix: use valid names for FSM instances
Since 8c4f5457 in libosmocore there are some limitations on FSM
and FSM instance names. This change adjusts the names of both
l1ctl_fsm and trx_fsm instances.

Change-Id: Icaaac3f51bdcfe4f7723060179b8730c3a06529b
2017-11-19 17:35:07 +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 5e9959cf6a host/trxcon/trx_if.c: separate logging of data messages
Change-Id: I74ebe0441aeb41c324eafb6b586b2edd9ef4fd1a
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 3641fe6123 host/trxcon: use LOGP instead of fprintf
There is no (performance) reason to use fprintf instead of LOGP.
Second one provides more useful information, such as a file name
and a line number.

Change-Id: I86dda5b3d746c7802442e4226578a06c04941721
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f979d44a72 host/trxcon/trx_if.c: fix wrong logging category
Change-Id: I0df0205e160fd9ea5811852077db7c49cddc7e8a
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy e38b500794 host/trxcon/scheduler: fix prim queue flushing function
For some reasons, the function, which is used to flush a queue of
transmit primitives, was intended to flush a list of msgb instances
instead of trx_ts_prim, so memory was being cleaned incorrectly.
Moreover, the items weren't actually removed from queue.

Change-Id: Ia84b57350a5c2eee0afebc65f62e30eaddb141d4
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 fd9aaaf3d0 host/trxcon/l1ctl.c: handle L1CTL_TCH_MODE_REQ
Change-Id: Ib2332e1610fa873755cdfa745153c7b7d4a72a62
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 3b1a03c310 host/trxcon/l1ctl.c: use primitive management API for RACH
Change-Id: I956ddfc4d1b47575715375c08f46c55953ec5fb6
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 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 8e13093c88 host/trxcon/l1ctl.c: retune TRX only if current ARFCN differs
Change-Id: I797dc284bd92d07ad4859f851a44d048407db86d
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 17a773c734 host/trxcon/l1ctl.c: fix wrong log level
Change-Id: I0ac65d94b0ae3dd370675318a26a65d11c49cbbe
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f5bbe5ebfe host/trxcon: separate logging of L1 Control and L1 Data
L1 Data is quite verbose, while Control is typically limited.
And if you would need to debug some Control message handling,
the Data messages wont overflow your terminal anymore. This
change introduces a new logging category named 'DL1D'.

Change-Id: Id830c8bf913f7a8ddc87c47f70a337ee4623abd8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 2e062039b6 host/trxcon/l1ctl.c: do nothing if CCCH mode matches
When the L1CTL_CCCH_MODE_REQ is received, we don't need to
reconfigure anything if the current mode matches requested.

Change-Id: Ib8a511e4edd7210b1806f47e83f316be00a8cbb1
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 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 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 5629699996 host/trxcon/scheduler: drop a meaningless FIXME label
Change-Id: If5497f4fdce22e986f46725cc1575a1e809ccdab
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 6aa6690277 host/trxcon/scheduler: fix possible NULL deference
We should make sure that required timeslot is not only allocated,
but also configured, i.e. has a correct multiframe layout.

Change-Id: I1d0b870c389802b51c709d089b80ac3fb3565fa8
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 026ed14c4b host/trxcon: adjust default verbosity level
Change-Id: I91258091b59e5cdd30b767364fb48c3d67980eb7
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 00bb1d5a79 host/trxcon/scheduler: implement sched_clck_reset()
It's better to have the clock management API inside a single file.

Change-Id: I92772f3db404e70fdffd530779613196afec61c9
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy e6acd7bd07 host/trxcon: get rid of useless TRX_EVENT_RESET_IND
Change-Id: I2aa4c000b37f64c351a806711b2d19bf27ef82bd
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 806e528bd1 host/trxcon: don't flush trx control messages on reset
Change-Id: I0851f168adeb012a933c796c4180ef507b1c57ec
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy b30031356c host/trxcon: get rid of useless trxcon fsm events
Both SCH_EVENT_CLCK_IND and SCH_EVENT_CLCK_LOSS were not handled,
moreover there is no purpose to keep them.

Change-Id: I8efac459a40f4287e3325890809991d5ef46e9b1
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 10fd43e586 host/trxcon/l1ctl.c: reset FBSB expire timer on shutdown
Change-Id: If3c8a34f0c1105c6acbfe4f9233482a31f6558de
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 6c3ce20d75 host/trxcon/l1ctl.c: handle L1CTL_PARAM_REQ
Change-Id: I5c23520dc0f19147b41ad2e13681bf0a62e9facd
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 17481e2b88 host/trxcon/trx_if.c: get rid of CLCK interface
Local clock counter can be corrected using frame number values,
obtained from burst header on DATA interface.

Change-Id: I5a813e3dc1b960831343b8ecb80718291f20e80d
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
Vadim Yanitskiy f604869944 host/trxcon: share trxcon fsm and talloc ctx via trxcon.h
Change-Id: I9ef558f84a6dc1c9b8fc394c48e108676fa169f8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 77b6833146 host/trxcon/scheduler: add a reference to GSM 05.02
Change-Id: I067af9c114bcbc5bd74515d5008e21a07fd0167e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f2af7d2953 host/trxcon/scheduler: confirm xCCH data sending
Change-Id: I40994e7046c25306a0a323910a65e195d2d8fbd0
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f21f7036e8 host/trxcon/scheduler: implement TSC selection
Change-Id: I004cc71aafe0a26e5141a4b2ffa90063e961be31
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy b5e4f26f6f host/trxcon/l1ctl.c: handle L1CTL_DATA_REQ
Change-Id: Ia72fd3d55c86697ff144446bbae94f76839eb5a1
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 283fb5879c host/trxcon/scheduler: fix TS index in sched_trx_configure_ts()
TS index was not assigned after allocation of a new one.

Change-Id: I1b62218f863acf27fb1d1f46b273b345b97d33d8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ae62021dc9 host/trxcon/l1ctl.c: implement FBSB expire timer
Change-Id: I27f96cbe951de164fcecaf19f8305db5e5b20229
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ff72b0724d host/trxcon/l1ctl.c: fix L1CTL_RACH_{REQ,CONF} handling
Previously, L1CTL_RACH_REQ / L1CTL_RACH_CONF messages were
handled without l1ctl_info_ul / l1ctl_info_dl header, what
caused incorrect data parsing.

Change-Id: I145d137f2cc7de234965e4fe64d9367ed6ccb999
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 4de3591a30 host/trxcon/l1ctl.c: fix incomplete msg in l1ctl_tx_fbsb_conf()
Previously, all L1CTL_FBSB_CONF messages were sent without
required l1ctl_info_dl header, what caused unpredictable
behavior on higher layers (L2 & L3). Let's fix it.

Change-Id: I8dae597bb4c09df36f80944434ce3624569f2cf8
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 656e31f762 host/trxcon/scheduler: notify transceiver about TS state
Change-Id: I5783066e7c1b01e4ebb28d10b03f3290ff8a0f37
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 924107d0d8 host/trxcon/l1ctl.c: handle L1CTL_PM_REQ correctly
Change-Id: Ib5a2198f21e747b6169ef141817ef22b241ef9fa
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 794deea3ec host/trxcon/trx_if.c: add power measurement command
Change-Id: Ib947b60248cafad4edeb7e49c2bd3a1f81696239
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ca5eee6e3f host/trxcon/trx_if.c: simplify response matching
Previously, we had both length and string matching of request and
response. To be able to implement commands with additional params
in the future, this change drops the length matching part.

Change-Id: Id4c50115f5f1b1da450ff8b8dcfd6ccf572d23f5
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy d28f65917f host/trxcon/scheduler: confirm successful RACH requests
Change-Id: I079ecebbeeb3843288118fbb55fa520af22859bb
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy b91cdc6a4a host/trxcon/l1ctl.c: handle L1CTL_RACH_REQ
Change-Id: I4c06bcf987120c6271b6e2ad94454fa69689a03e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 46b47f5a5f host/trxcon/scheduler: implement RACH handler
Change-Id: I496dd682549570e37e63e7edcfc83a064c13a57f
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 59c98b14ac host/trxcon/scheduler: store BSIC in trx_instance
We need to know BSIC value, before sending RACH requests.
So, let's store it in trx_instance and update as soon as
the first SCH burst is received after L1CTL_FBSB_REQ.

Change-Id: I49574c3661f79f3b4941db6c651baebab2665c1b
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 417183b78e host/trxcon/trx_if.c: expose the trx_if_tx_burst()
Change-Id: Iebd644879e2e9067a94cb638b4ec5b75f806923f
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy f437a3bebd host/trxcon/trx_if.c: use proper names for burst handlers
Change-Id: I3d36e6d80fcf6353379aa308415c306e1a256a7d
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 0f227d802b host/trxcon/trx_if.c: fix compatibility with OsmoTRX
For some reasons, OsmoTRX sends 158-byte long sequences on DATA
interface, where the latest two bytes aren't used.

Change-Id: Ie9295e9b0d8956d9e87e2ced8cca9d5e68040f88
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 92aca364f7 host/trxcon: reset scheduler when L1CTL is lost
Change-Id: I1fd8a610085c8591a820e784b7122de7b3032d15
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy ca1d021c83 host/trxcon/scheduler: drop resolved FIXME label
Change-Id: I5e6b30300a457422b2deb10ff4c051c86beb7cd2
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 3afd469a9a host/trxcon/l1ctl.c: implement L1CTL_CCCH_MODE_{REQ/CONF}
Change-Id: I72f36a99aebcbafd657ceb475fd1c50cc79e2094
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy cc4282f5be host/trxcon/l1ctl.c: implement L1CTL_FBSB_CONF
Change-Id: I33e4702d590a8d67285410fc8f1241bb9d4c50fc
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 99f8aea905 host/trxcon/scheduler: fix channel deactivation
Change-Id: I7c99b7bd99619084727af290b388f7492ba58531
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 7ce986c638 host/trxcon: send L1CTL_DATA_IND directly from lchan handler
Change-Id: Idfc86a59469c7a0bba1c16177502844e59ed8887
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy e738f7827e host/trxcon: handle L1CTL_RESET_REQ inside l1ctl.c
Change-Id: Ie5930dec800885784fb38ce6188c9c969cd2ad4e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy c457cbf712 host/trxcon: handle L1CTL_FBSB_REQ inside l1ctl.c
Change-Id: I5bcf39a20f1c6d3a2472e5e95725c6bb1c77bf5d
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 705fedceeb host/trxcon: bind L1CTL link with TRX and vice versa
Change-Id: I575f8699bf06fd5e86f7935c6ab3216db5a26ec5
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 6ab67cc587 host/trxcon/scheduler: implement SCH decoding
Change-Id: Ic5e7416271d647752cd1aaf90de51fa48286798e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 228d42bc30 host/trxcon/scheduler: implement xCCH decoding
Change-Id: Ieb71e3727b525e85d161855973f63042366ccb05
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy cf5c10f92a host/trxcon: link trxcon against libosmocoding
Change-Id: I9bb45428e6617bd6936d24340e688aef4aeafc8f
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 604ac30825 host/trxcon: handle ccch_mode from L1CTL_FBSB_REQ
Previously, the content of L1CTL_FBSB_REQ message was only used
to obtain a new ARFCN and retune transceiver. Now, since we have
working TDMA scheduler, some other params (like ccch_mode) may be
used too.

Change-Id: Iccabba376d67e091b55a604a2ae87f2aa86362e5
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 62328cb088 host/trxcon: store arfcn and band in trx_instance
Change-Id: I95414ff1033d77f11e231178b7721b70bc45e6df
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
Vadim Yanitskiy 789040f914 host/trxcon/trx_if.c: handle clock indications
Change-Id: I333c1c44578eb62c52d2d059b798dd5feae3e444
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 9b1d398685 host/trxcon/scheduler: add basic clock counter
The core of scheduler is a simple clock counter, which relays
on system time for now. One was a bit simplified and migrated
from OsmoBTS.

Due to system time is not an ideal clock source, the counter
should be periodically corrected by clock indications from BTS.

Change-Id: I27d85bd3e2c8bca3f876f73517027b9fe43c9825
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 90a0d3c78d host/trxcon: initial release of L1CTL handlers
Now it's possible to handle the following requests
from layer23 apps:

- L1CTL_FBSB_REQ
- L1CTL_PM_REQ
- L1CTL_RESET_REQ
- L1CTL_ECHO_REQ

It should be noted, that the L1CTL_PM_REQ isn't
handled correctly yet, due to required task isn't
implemented on the TRX side yet. Instead of this,
temporary we are sending some fake responses.

Change-Id: I343eca3e20922ddd83e06231811200b26da442f3
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 423aeefc40 host/trxcon: integrate osmo-fsm framework
This change introduces the following state machines:

  - trxcon_app_fsm - main application state machine.

    This state machine handles different events, raised
    from program modules (such as trx_if.c or l1ctl.c).

  - l1ctl_link_fsm - L1CTL server state machine.

  - trx_interface_fsm - TRX interface state machine.

The program modules (such as trx_if.c or l1ctl.c) should be as
much independent from each other as possible. In other words,
one module should not call methods from another, e.g. L1CTL
handlers are not able to send any command to transceiver directly.

Instead of that, they should use shared event set to notify the
main state machine about something. Depending on current state
and received event, main state machine 'decides' what to do. This
approach would allow to easily reuse the source code almost 'as is'
anywhere outside the project.

Change-Id: I7ee6fc891abe5f775f5b7ebbf093181a97950dea
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 83a9c9ef50 host/trxcon/trx_if.c: add ECHO command
This command should be used to check transceiver availability.

Change-Id: I6af2d5e413ff7ab751cb34e1659742b0f59b6cca
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 65664d088d host/trxcon: fix NULL-pointer deference
Change-Id: Idc036d4ea32b4aa3f4841d39144ef1733414728e
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 48f2cb4b3b host/trxcon: initial release of transceiver interface
This is the second side of the 'OsmocomBB <-> SDR' bridge.
Most of source code taken from the OsmoBTS project.

Change-Id: I96fa3ada05d010f31af419a4950fd8ae2b62ef34
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 9f5fefe792 host/trxcon: initial release of L1CTL interface
There are two sides of the 'OsmocomBB <-> SDR' bridge. One of
them is the L1CTL interface, which is used by existing layer23
applications to drive GSM L1. Exactly this interface is provided
by the osmocon application, but instead of forwarding messages
between both host software and firmware we need to handle incoming
messages from layer23 applications, perform some GSM L1 specific
conversations (coding, mapping, interleaving, etc.), then finally
forward them to transceiver through the scheduler. And vice versa.

This code is just a basic implementation of UNIX socket handlers,
so currently we can only accept and drop connections from layer23
applications.

Change-Id: I58d069bcc7742b42c0bf95e52063933bf2c352ff
2017-11-19 17:35:07 +07:00
Vadim Yanitskiy 8975b437ed host/trxcon: introduce a new 'trxcon' application
This app is similar to the osmocon, but designed to
connect L2 & L3 apps with SDR transceiver insted of
obsolete Calypso based hardware.

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