Commit Graph

423 Commits

Author SHA1 Message Date
Vadim Yanitskiy 2b462dd89d {trxcon,virt_phy}: shared GPRS L1 (MAC) implementation
Change-Id: I9567d64f9d00262e36147e8d7e541e5e246bda5f
Related: OS#5500
2023-03-17 12:15:29 +00:00
Vadim Yanitskiy 38ef3280d2 trxcon: do not send DATA.cnf for L1SCHED_DT_TRAFFIC
The event TRXCON_EV_TX_DATA_CNF is not premitted in state
TRXCON_ST_PACKET_DATA, and is not of any use for l1gprs.

Change-Id: Iee5ee404f1eb77091c388a641d0a78d01a8d7e7f
Related: OS#5500
2023-03-13 21:43:45 +00:00
Vadim Yanitskiy 5adc13d69d trxcon: move l1ctl_proto.h to 'include/osmocom/bb/'
The upcoming l1gprs library will be using this header too.

Change-Id: I2101b20637f837038115497873bd905f95a3d0c2
2023-03-08 21:11:27 +00:00
Vadim Yanitskiy 6fe33fd6d4 trxcon: do not crash on receipt of 8-PSK modulated bursts
TRXDv0 PDUs may have 2 additional dummy bytes at the end.  Such
a PDU will crash trxcon if it contains an 8-PSK modulated burst:

  Assert failed phybi->burst_len <= sizeof(bi.burst)

In this case phybi->burst_len would be 444 + 2, while size of the
burst buffer in struct l1sched_burst_ind is limited to the length
of an 8-PSK modulated burst (444).

Change-Id: Icfba986ccf0c696ba019b91575b4d69db001c14f
2023-03-08 09:03:11 +00:00
Vadim Yanitskiy 616949a0be trxcon: use 3GPP TS 45.002 definitions from libosmogsm
Change-Id: Ieb3b502e1e5432e425a55c1217211b77e9ca91c9
Depends: libosmocore.git I1c38ccc2b64ba9046bb3b1221d99cc55ec493802
2023-03-08 09:03:11 +00:00
Vadim Yanitskiy 260025f39f trxcon: move AMR mode setting to l1sched_lchan_set_amr_cfg()
Change-Id: Ia9504d6194a4aac6256f7d4caf73eb42bb58563e
2023-02-14 07:20:31 +07:00
Vadim Yanitskiy d4d296f1ea trxcon: make l1sched_a5_burst_dec() accept l1sched_burst_ind
Change-Id: I5dd16cff1c9730a496748681842f571d25653cb9
2023-02-14 07:01:09 +07:00
Pau Espin 2b11e9e97d trxcon: Fix heap-use-after-free in l1ctl_client
If the peer connected to trxcon restarts the process, read() on the unix
socket in trxcon fails, and triggers closing the conn (l1ctl_client),
which ends up freeing the struct. This all happens during read_cb() of
the l1ctl_client wqueue. If the kernel also flags WRITE event in the
same main loop iteration, the wqueue code would end up using the freed
struct again when running the write_cb.

Make sure the read_cb returns -EBADF in the code branch closing the conn
in read_cb, since it makes no sense to handle a write_cb after that.
This saves the code from accessing the potentially freed struct.

Related: OS#5872
Change-Id: I100a8ba056a09b4e52675e3539640da0c0f8d837
2023-01-30 18:23:55 +01:00
Vadim Yanitskiy 13fe9ccf55 trxcon: TRXCON_EV_DCH_REL_REQ does not switch to TRXCON_ST_RESET
It's not really clear to me how the L1 is supposed to handle the
L1CTL_DM_REL_REQ message, which maps to the TRXCON_EV_DCH_REL_REQ
in our case.  Lookig at the layer23 code I see that it's sent along
with the L1CTL_RESET_REQ (maps to the TRXCON_EV_RESET_SCHED_REQ).
The layer1 firmware does reset some parameters on receipt of the
L1CTL_DM_REL_REQ and some more parameters on the L1CTL_RESET_REQ.

It's clear though that we should not switch to the TRXCON_ST_RESET
on receipt of the L1CTL_DM_REL_REQ.  The layer23 application
(e.g. mobile) may send L1CTL_DM_EST_REQ right after that, and we
won't be able to transition from the TRXCON_ST_RESET directly to
the TRXCON_ST_DEDICATED.  Such transition is neither implemented
nor permitted by 3GPP TS 44.004, Figure 5.1.

Ideally, according to 3GPP TS 44.004, Figure 5.1, we should have
an additional transient state 'TUNING DCH' in the trxcon_fsm and
switch there on reciept of the L1CTL_DM_REL_REQ.  But currently
it's not implemented and adding it would require some effort.

As a temporary solution, let's do not change the current state and
stay in the TRXCON_ST_DEDICATED.  This workaround is needed to make
mobile terminated calls work in the mobile app.

Change-Id: I5bbe6ca4cc6299f9faf343822c992a6872a45081
Related: OS#5599
2022-12-21 15:08:40 +00:00
Vadim Yanitskiy 040bf41028 trxcon: allow extending FBSB timeout (quirks for slow PHYs)
This is needed for SDR based PHYs, because for them it takes longer
to tune, flush the buffers and so on.  Add a field to the trxcon_inst
structure and a command line option (-F) for the trxcon app.

Change-Id: Ia68954c5bdacda45fc871ffea0ccdf2460936408
Related: OS#5599
2022-12-20 23:28:56 +07:00
Vadim Yanitskiy 2c347f9979 trxcon: use strtoul() instead of atoi(), detect errors
Change-Id: I18ec88f1ee30c58d088fe65650d0257b262c1fee
2022-12-20 23:28:56 +07:00
Vadim Yanitskiy f7d5d8d4ff trxcon: move FBSB timeout calculation to the trxcon_fsm
In the upcoming patches I am adding a possibility to enlarge the FBSB
timeout by providing API for that.  This is needed for SDR based PHYs,
because for them it takes longer to tune and so on.  The L1CTL codec
is not the right place for applying PHY specific quirks, so let's
move the TDMA FNs -> ms conversion to the FSM logic.

Change-Id: I685f48cfed000997b0d7c16073c6387bc05d2bbe
Related: OS#5599
2022-12-20 14:38:26 +00:00
Vadim Yanitskiy 0883c25ac5 trxcon: reset the L1 params on TRXCON_EV_RESET_FULL_REQ
Change-Id: Ie94b7977fec857aa5f13f53162816d5fd9f5594c
Related: OS#5599
2022-12-15 04:31:06 +07:00
Vadim Yanitskiy a6d2e1a12b trxcon: fix distcheck: add missing trxcon_fsm.h to noinst_HEADERS
Change-Id: Ib64b15c8ad700a7df71513469df454c74322b998
Fixes: 6fc090593d
2022-12-13 03:18:52 +07:00
Vadim Yanitskiy edfcc28fda trxcon: fix l1ctl_tx_dt_conf(): accept const *cnf
The *cnf param of l1ctl_tx_dt_conf() was already declared as const
in the header file, however it was not in the actual function
definition.  Take a chance to fix formatting in the header.

Change-Id: I842ac717a6959830c536cbf91efdbb6a4ee931ce
2022-12-11 23:13:45 +07:00
Vadim Yanitskiy ebd909b05a trxcon: print TCH mode using gsm48_chan_mode_name()
Change-Id: I6c54ad857b91ef1a32501912ba4c393e1c04eff0
2022-12-06 06:28:56 +07:00
Vadim Yanitskiy 9d9698064c trxcon: add value-string defs for L1CTL Reset / CCCH Mode
Change-Id: I045b2c771b24d301570c9556770e97afedc8274a
2022-12-05 08:13:15 +07:00
Vadim Yanitskiy 564b644a0b trxcon: constify pointers in L1CTL decoding functions
Change-Id: Ife66b3c14f0ee2f29bf934db1f58512d52669b38
2022-12-05 08:13:15 +07:00
Vadim Yanitskiy 974bd15d25 trxcon: trxcon_fsm: permit direct DCH/PDCH transitions
It may happen that the MS needs to go directly from a PDCH to a TCH
or SDCCH, e.g. in case of a Mobile Terminated call.  I don't know
if the opposite transition is needed on practice, but let's simply
allow direct transitions for both TRXCON_ST_{DEDICATED,PACKET_DATA}.

Change-Id: I1a854e4683f102c40f1c174a291b6dc638f49b5c
Related: OS#5599
2022-12-05 08:09:29 +07:00
Vadim Yanitskiy c6fe9c3fa1 trxcon: trxcon_fsm: permit loop [P]DCH transitions
According to 3GPP TS 44.004, Figure 5.1, it's absolutely legal to
perform loop transitions in state 'DCH' (i.e. from 'DCH' to 'DCH').

This kind of transition is needed in the following cases:

* on reciept of RR FREQUENCY REDEFINITION,
* on reciept of RR ASSIGNMENT REQUEST,
* on reciept of RR HANDOVER REQUEST,

when going back from state 'DCH' to state 'BCH' is not required nor
actually desired.  In context of the trxcon_fsm, this applies to
both TRXCON_ST_DEDICATED and TRXCON_ST_PACKET_DATA, as they both
represent what's defined as 'DCH' in the Figure 5.1.

Change-Id: I3b402ec84610a5df744d9b06e5f7dab7a9a3ddad
Related: OS#5599
2022-12-05 08:09:29 +07:00
Vadim Yanitskiy 5f4f632442 trxcon: trxcon_fsm: separate handling of TRXCON_EV_DCH_EST_REQ
This new function will be re-used in a follow up patch implementing
handling of TRXCON_EV_DCH_EST_REQ in TRXCON_ST_{DEDICATED,PACKET_DATA}.

Change-Id: I8db93fcdace7aaa8bc3876b14e441304349a36d5
Related: OS#5599
2022-12-03 15:14:47 +07:00
Vadim Yanitskiy 13cabcb281 trxcon: trxcon_fsm: shorten DCH related event names
Purely cosmetic change, making the lines using these events shorter.

Change-Id: Ie388e251677da63306e9e53d98cbcc7c34777980
Related: OS#5599
2022-12-03 08:11:34 +00:00
Vadim Yanitskiy 93b1884914 trxcon: trxcon_fsm: disallow invalid state transitions
According to 3GPP TS 44.004, Figure 5.1, transitioning from state
'DCH' directly to state 'BCH' is not permitted.  Speaking in terms
of the trxcon_fsm, the following state transitions are invalid:

* TRXCON_ST_DEDICATED -> TRXCON_ST_BCCH_CCCH,
* TRXCON_ST_PACKET_DATA -> TRXCON_ST_BCCH_CCCH.

We never do such transitions anyway, so we are good.

Change-Id: I14ebfc5c86d37765ad06fa91321a469dea46e50f
Related: OS#5599
2022-12-03 08:11:34 +00:00
Vadim Yanitskiy 5780e57dd4 trxcon: link trxcon against libl1sched.la directly
Change-Id: I8a1319077167f118d1909a8ab33d33a73f47541a
Related: OS#5599
2022-12-03 08:10:44 +00:00
Vadim Yanitskiy a4aac5c355 trxcon: implement Ready-to-Receive PHYIF API
This API is going to be used by osmo-trx-ms for inquiring the l1sched
about an lchan state before attempting to demodulate a Downlink burst.

Change-Id: I9a71b8a59733f4dd908b760c5e23ea3d624afb1a
Related: OS#5599
2022-11-29 11:03:11 +00:00
Vadim Yanitskiy b76c330f6d trxcon: implement Ready-to-Send PHYIF API
This API is going to be used by osmo-trx-ms for pulling Uplink bursts
from the scheduler in a synchronous way, without relying on the
timer driven libtrxcon's internal scheduler.

Change-Id: Ic8f74413f5fad277340e007dd4296f890155a2c1
Related: OS#5599
2022-11-29 11:03:11 +00:00
Vadim Yanitskiy b2815c64a6 trxcon: add a spec. reference for the trxcon_fsm
Change-Id: I184abe10f874d97f047a3720c776fdef08d880e6
2022-11-25 22:32:14 +07:00
Vadim Yanitskiy 04b14c49f0 trxcon: trx_data_rx_cb(): support parsing 8-PSK modulated bursts
Change-Id: I78b1a79c329299ab65eb339e9447a47382983cd9
2022-11-25 14:34:55 +00:00
Vadim Yanitskiy 384a8dd3fe trxcon: trx_data_rx_cb(): check TRXD PDU version
Change-Id: If5687d7d87619c0da02cc81ab26d63e61484bc06
2022-11-25 14:34:55 +00:00
Vadim Yanitskiy 6703d5289b trxcon: trx_data_rx_cb(): print strerror(errno) if read() fails
Change-Id: I78658a706e5bfda446e3929e33abcdee3f08845b
2022-11-25 14:34:55 +00:00
Vadim Yanitskiy 0f9d483984 trxcon: trx_data_rx_cb(): properly parse timeslot number
Remove the range check because it makes no sense anymore.

Change-Id: I1010cf39f61b8845acce632c19c74df892fc5acb
2022-11-25 14:34:55 +00:00
Vadim Yanitskiy 7f1b99bc3b fixup: trxcon: make burst pointer in trxcon_phyif_burst_ind const
The for-loop was moved above the initialization of bi and kept using
bi.burst_len, which is indeed uninitialized.  Move it back.

Change-Id: I93a627233beef9157d47b35cafc42c53203619a7
Fixes: 178b92a108
Fixes: CID#300007
2022-11-24 10:57:18 +07:00
Vadim Yanitskiy 178b92a108 trxcon: make burst pointer in trxcon_phyif_burst_ind const
The trx_data_rx_cb() needs to be modified because it's accessing and
modifying the receive buffer via the bi.burst pointer, which
becomes const after this patch.

Change-Id: I68773d247725a6dc2cbbc58b63c0fd19ffdb1a16
Related: OS#5599
2022-11-23 06:26:51 +07:00
Vadim Yanitskiy c568b9cebe trxcon: group Rx burst params into struct l1sched_burst_ind
Change-Id: I3363c38a43d2f54f846527b70cedac8fa57bcb27
Related: OS#5599
2022-11-23 06:26:48 +07:00
Vadim Yanitskiy bd492d830d trxcon: adjust coding style in l1sched_pull_burst()
Change-Id: I96a40fdbea5085999b9aeb98b418ae27132f6fda
Related: OS#5599
2022-11-22 23:22:21 +00:00
Vadim Yanitskiy b387df26c4 trxcon: rework l1sched_trigger(), split l1sched_pull_burst()
The key idea is to allow triggering the scheduler only for a specific
timeslot of a frame, while keeping the API for triggering all together.

Split off the main part from l1sched_trigger() to l1sched_pull_burst().
While at it, rename l1sched_trigger() to l1sched_pull_send_frame().

Change-Id: Ibb7f9d7de26733f21b0753a2c655a250286bf1f0
Related: OS#5599
2022-11-22 23:22:21 +00:00
Vadim Yanitskiy bb2b1d7657 trxcon: rx_sch_fn(): do not use sched->fn_counter_proc
Use the given Fn instead, no need to go that deep for it.  The
sched->fn_counter_proc is an internal field of the scheduler,
which is not necessarily holding a valid value when pulling
Uplink bursts synchronously via the Ready-to-Send PHYIF API.

Change-Id: I56027876b50e53b474c2f54ac216cd141142020e
Related: OS#5599
2022-11-22 23:22:21 +00:00
Vadim Yanitskiy 855d83fc2d trxcon: separate l1sched_clck_handle() from BURST.ind handling
Do not mix up Downlink burst handling with the clock delivery.  Add
a separate PHYIF API function and call it from the TRXC/TRXD PHYIF.

This way calling trxcon_phyif_handle_burst_ind() would not trigger
the internal timer-driven Uplink scheduler in libl1sched, letting
the underlaying PHYIF logic to pull Uplink bursts synchronously.

Change-Id: Ieeee25573d1142aec2fee28d884127f14573b681
Related: OS#5599
2022-11-20 07:24:25 +07:00
Vadim Yanitskiy 1a0ad45a5d trxcon: drop unneeded imports in trxcon_main.c
Change-Id: I2868f83f55a6cbf3efc59f35ab7666671d22cf93
2022-11-18 05:29:49 +07:00
Vadim Yanitskiy ff0b5ed75a trxcon: use 'trxcon_phyif_' prefix for the PHYIF API
Change-Id: Icd2fc41cb3f42a791bf619c5f7b8fa4154371ba4
Related: OS#5599
2022-11-18 05:23:36 +07:00
Vadim Yanitskiy 269fe14045 trxcon: move l1sched/phyif shim API to libtrxcon.la
Change-Id: I56701b471a6f1c30ffd107037c2b1aed65621b2c
Related: OS#5599
2022-11-18 05:16:34 +07:00
Vadim Yanitskiy 54a2ee5cef trxcon: reorganize the core logic into libtrxcon.la
This is needed for the integration with osmo-trx-ms.  It was decided
to run the scheduler within the transceiver process, so that we can
reduce scheduling latency.  The idea is to maintain trxcon as a sub-
module in osmo-trx.git and link osmo-trx-ms against the libtrxcon.

We cannot use hard-coded logging categoris in a library, so add new
API for setting them: trxcon_set_log_cfg().  Use DLGLOBAL by default.

Change-Id: Idf207947f620a7394e0a0e5bf2c37bcd8df64bbe
Related: OS#5599
2022-11-18 04:59:50 +07:00
Vadim Yanitskiy 394793b1c1 trxcon: abstract L1CTL codec from the l1ctl_server API
The L1CTL codec (implemented in l1ctl.c) is going to be part of the
upcoming libtrxcon, so let's uncouple it from the l1ctl_server API.

Change-Id: I8d80af240b0e57f76263907c552288d4184876c0
Related: OS#5599
2022-11-12 22:15:58 +07:00
Vadim Yanitskiy 724502d0f4 trxcon: use L1CTL_HEADROOM in l1ctl_alloc_msg()
The l1ctl_client_read_cb() is using L1CTL_HEADROOM, so let's avoid
inconsistency and use L1CTL_HEADROOM in the l1ctl_alloc_msg() too.

Change-Id: I248f8c662ae0836cba61fb708a5dc73c57131f4c
Related: OS#5599
2022-11-12 22:11:49 +07:00
Vadim Yanitskiy 7d1a2247fa trxcon: move trxcon_inst_{alloc,free}() to a separate file
Both functions are going to be part of the upcoming libtrxcon.

Change-Id: I98963a1da927581597f7a170239dfb8a87cba842
Related: OS#5599
2022-11-12 22:09:55 +07:00
Vadim Yanitskiy a7f399eb95 trxcon: move l1sched_logging_init() from l1sched.h to logging.h
Change-Id: I43e21ca8a14445548e1d359bb6f8a3e36cb65bfa
Related: OS#5599
2022-11-12 02:29:31 +07:00
Vadim Yanitskiy 13046f172d trxcon: cosmetic: s/trx_log_init()/trxcon_logging_init()/
Change-Id: I65ab1e6d3a3bea65aeb13ab286e33795ba57f1f3
Related: OS#5599
2022-11-11 18:26:32 +07:00
Vadim Yanitskiy c3916785d8 trxcon: cosmetic: rename trxcon.c to trxcon_main.c
Change-Id: Idc5f4217dd31b5bdcb364600f7b97d1f60e1ab6f
Related: OS#5599
2022-11-11 13:45:11 +07:00
Vadim Yanitskiy 4cf9004b96 trxcon: maintain full power scan state in the trxcon_fsm
Currently the trxcon_fsm is simply passing start and stop ARFCN values
(as received from the L1CTL peer) over the PHYIF, and expecting the
PHY to perform the measurements within the given range.  This approach
requires the PHY implementation to maintain some state internally.

Let's simplify the job of the PHY implementation(s) by maintaining the
power scan state in the trxcon_fsm and sending a PHYIF_CMDT_MEASURE
command for each ARFCN in the given start/stop boundaries separately.

Change-Id: Ic5f724a11e225b439ec10aed7697e3e03b7929e5
Related: OS#5599
2022-11-11 06:38:00 +00:00
Vadim Yanitskiy 9e1de2359e trxcon: configure.ac: call LT_INIT after setting CFLAGS
If $CFLAGS is empty prior to calling the LT_INIT, this macro will
set $CFLAGS to "-g -O2".  We don't want implicit flags out of
nowhere, so let's simply move the invocation of LT_INIT down below.

Change-Id: I8d8eb1e3428ffcb84ddd53230fada39328337d15
Related: OS#5749
2022-11-10 16:10:10 +00:00