Commit Graph

1179 Commits

Author SHA1 Message Date
Vadim Yanitskiy 2308b58250 trxcon/scheduler: unify and enrich decoding error messages
Regarding the removal of burst_mask2str() from the TCH/H handler,
it does not make sense to print it because the mask is already
shifted and an earlier logging should already contain this info.

Change-Id: I42d20e2da73c21ca366dd246244cd716c8ccb459
Related: OS#4823
2021-07-04 20:02:53 +02:00
Vadim Yanitskiy f8bc28505f trxcon/trx_if: send NOPE indications if there is no burst
In a typical setup operating on the real radio interface, it's
the duty of the transceiver (e.g. osmo-trx) to send NOPE.ind to
the L1 implementation (e.g. osmo-bts-trx).  However, in a
virtual environment for ttcn3-bts-test we use a fake transceiver,
which due to its simplicity cannot send NOPE indications itself.

The lack of queues and buffering does not allow us to implement
NOPE indications in fake_trx.py, so the easiest approach is to
generate them from trxcon.  Send TRXD PDUs without the burst bits,
and fake_trx.py will tranform them info NOPE.ind for us.

Change-Id: I1c7f1315b8ef44f651efd6a22fb5b854f65c0946
Related: SYS#5313, OS#1569
2021-06-16 15:55:38 +02:00
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 c652349b4a trxcon/scheduler: cosmetic: move TDMA frame number calculation
Change-Id: I79efdfa543d37889dc6749eb25aab4e1639749c6
2021-06-16 15:05:51 +02:00
Vadim Yanitskiy 825716851e host/layer23/ccch_scan: skip CCCH frames with wrong length
It's not clear why do we get frames with unexpected length, but
we definitely should not crash.  Just log and ignore them.

Change-Id: I85392becbffdb3ba7365decfd8f3769abe3c02c7
Related: OS#5171
2021-06-09 22:51:07 +02:00
Vadim Yanitskiy e9b0d7488f trxcon: fix legacy length expectations for TRXDv0 Rx PDUs
158 is basically: 8 + 148 + 2, where the last two are padding bytes
sent by legacy TRXDv0 transceivers.  We don't need them, so do not
drop PDUs without these leggacy padding bytes.

Change-Id: I6c0734bc4669ccde2a93940c9cf50fdbbd67cb00
2021-04-29 14:33:25 +02:00
Pau Espin 5c3c28cc1d tests: Replace deprecated API log_set_print_filename
Change-Id: I9d24365d2be528477f1c190c698a81bfc7f2d2df
2021-02-19 14:16:53 +01: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 e5a9077dbd mobile: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: Ied0f47378a5d348b857424adb5c874c1c093b485
Fixes: OS#4865
2020-11-25 18:45:26 +01:00
Pau Espin efb88bf5ff trxcon: generate coredump and exit upon SIGABRT received
Previous code relied on abort() switching sigaction to SIG_FDL +
retriggering SIGABRT in case the signal handler returns, which would
then generate the coredump + terminate the process.
However, if a SIGABRT is received from somewhere else (kill -SIGABRT),
then the process would print the talloc report and continue running,
which is not desired.

Change-Id: I6d80f3f2742d397e47f4f2970c951f2cf6d58172
Fixes: OS#4865
2020-11-25 18:44:46 +01:00
Pau Espin 581cfbeba9 trxcon: Handle signal SIGABRT
The signal handler was coded as if it was handling SIGABRT, but the
signal handler was not overwritten so it is actually used.

Change-Id: I5c597f3410fc97be138db6f3976df59f393819b6
2020-11-25 18:42:09 +01:00
Harald Welte c6fb802252 Use osmo_fd_*_{disable,enable}
Change-Id: If4c7f946852d153bd472e5c704f8d517d26ca22e
Depends: libosmocore.git Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2020-11-11 20:14:58 +00:00
Harald Welte 00d1223d05 Use osmo_fd_*_{disable,enable}
Change-Id: I65d37821873767e61a7eca029f9b30938a299683
Depends: libosmocore.git Idb89ba7bc7c129a6304a76900d17f47daf54d17d
2020-11-11 20:14:45 +00:00
Vadim Yanitskiy 082b618ea4 trxcon/l1ctl_link: use osmo_store16be() in l1ctl_link_send()
Change-Id: I96ca1c581d028a1f3c89c83a575fd8dbc9751962
2020-11-05 13:36:43 +07:00
Harald Welte 7c34854880 osmocon: More decoding of tpu_debug (on compal/rffe_dualband)
Let's give a more human-readable decode of the TPU instructions,
naming the TSPACT pin names as well as the device_id/strobe.

Change-Id: Iac1ac74ac3e41cff9d3d347a167b43af58cc6e59
2020-10-25 09:38:08 +01:00
Harald Welte 46cf9b1043 gsm48_rr: Don't swap ber with snr in "MON:" log line
I was quite confused why I constantly see a bit error rate reported
by gsm48_rr, while at the same time the actual L1CTL_DATA_IND did
all state num_biterr == 0.

So the log statement was broken ...

Change-Id: I09bb6c606a8437b213bb444949c78a7c8a10542c
2020-10-23 23:32:10 +02:00
Harald Welte d90ae30caa mobile: Use osmo_fd_setup() in script_lua.c
Change-Id: Ib6f97b9b8f3af63b81b92071b7fdb1fd55da89a5
2020-10-21 11:56:43 +00:00
Vadim Yanitskiy 2c0d9cdcc2 trxcon/l1ctl: fix: send confirmation for TCH mode request
Both REQ and CNF share the same message structure, so we can
cheat a bit by changing the message type and sending it back.

Change-Id: I6f403ed0506b4b1872361d9976d3186bfe514b52
Related: OS#4799
2020-10-19 21:07:26 +07:00
Harald Welte de31aa3af7 Use osmo_fd_setup() whenever applicable.
Change-Id: If9b636c295fc6b5349a54c70662f09efa616ee63
2020-10-18 23:34:46 +02:00
Harald Welte 508d8523c0 Use OSMO_FD_* instead of deprecated BSC_FD_*
Change-Id: Ibf64b18288b9109927035f650d6ef7ad9f15d688
2020-10-18 22:43:05 +02:00
Vadim Yanitskiy 39264cc3a8 fix trx_if_tx_burst(): do not drop Uplink bursts in TRX_STATE_RSP_WAIT
Some commands, such as SETTA or SETPOWER, are expected to be sent
when the transceiver is powered on.  We should not drop Uplink
bursts while waiting TRXC response.

For now it's easier to comment out the state check completely,
because the existing TRXC state machine is quite messy.

Change-Id: Iefe6030200b11b29a5790d1f4aa4070ed1d9a493
2020-10-16 23:08:38 +07:00
Vadim Yanitskiy e42e5a0789 layer23/cbch-sniff: fix: use Osmocom specific RSL channel number
This way the layer1 can activate proper CBCH task and send us
CBCH block with proper RSL channel number, so they do not end
up being routed to LAPDm and rejected there.

Change-Id: Ib1d5c99587202a9d94aeb7b63de7ae8c4fb15af0
2020-10-13 08:46:11 +00:00
Vadim Yanitskiy 3c39ba4b94 layer23/cbch-sniff: fix: do not blindly assume presence of CBCH
We cannot blindly assume that CBCH is present on TS0/SDCCH4 before
decoding CBCH Channel Description in System Information Type 4.

Change-Id: Ie8ce572df292d0b03c0f743bcf26184619176321
2020-10-13 08:46:11 +00:00
Vadim Yanitskiy 8194febb09 layer23/mobile: implement handling of TCH test loop commands
For more information, see 3GPP TS 44.014, sections:

  - 5.1 "Single-slot TCH loops", and
  - 8 "Message definitions and contents".

This feature has nothing to do with the Mobility Management, so
let's handle GSM48_PDISC_TEST messages in the Radio Resources
layer implementation (gsm48_mm.c -> gsm48_rr.c).

Change-Id: If8efc57c7017aa8ea47b37c472d1bbb1914389ca
2020-07-31 00:48:06 +07:00
Vadim Yanitskiy 8208a336ab layer23/mobile: fix a memory leak (msgb) in gsm48_rr_data_ind()
Change-Id: I55dcccf5b7d27d012908759954182eaec434d26b
2020-07-30 16:46:50 +07:00
Vadim Yanitskiy df2b46471d layer23/mobile: fix wrong message type in gsm48_rr_tx_rr_status()
Change-Id: I57c6a4e1e725da52c50e2a28e56627a3f3827c62
2020-07-30 16:07:27 +07:00
Vadim Yanitskiy e7e4d86f0e layer23/mobile: cosmetic: use GSM48_PDISC_TEST from gsm_04_08.h
Change-Id: Ie1f14b37f6138f5a019a25bdbc8a3531418df6c2
2020-07-29 03:58:23 +07:00
Vadim Yanitskiy 9d24c54f82 trxcon/scheduler: reduce default Uplink burst scheduling advance
In general, premature scheduling of to be transmitted bursts
inevitably increases the time delay between Uplink and Downlink.
The more we advance TDMA frame number, the greater gets this
delay.  20 TDMA frames is definitely more than a regular
transceiver needs to pre-process a burst before transmission.

Change-Id: Ia9b142b59d95f2cd7b2394596cf72c0bcd36d711
Related: OS#4487
2020-07-13 05:00:23 +07:00
Vadim Yanitskiy d39b841059 trxcon/scheduler: check TDMA frame order, drop out of order bursts
When running together with fake_trx.py (mostly used back-end), it
is currently possible that Downlink bursts are received in a wrong
order if more than one transceiver is configured (multi-trx mode).

This is how it looks like:

  DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=629 rssi=-86 toa=0
  DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=629 ts=3 bid=1
  DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=630 rssi=-86 toa=0
  DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=630 ts=3 bid=2
  DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=631 rssi=-86 toa=0
  DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=631 ts=3 bid=3

  DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=633 (!) rssi=-86 toa=0
  DSCHD NOTICE sched_trx.c:663 Substituting (!) lost TDMA frame 632 on TCH/F
  DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=632 ts=3 bid=0
  DSCHD DEBUG sched_lchan_tchf.c:60 Traffic received on TCH/F: fn=633 ts=3 bid=1

  DTRXD DEBUG trx_if.c:612 RX burst tn=3 fn=632 (!) rssi=-86 toa=0
  DTRXD NOTICE sched_trx.c:640 Too many (>104) contiguous TDMA frames elapsed (2715647)
                               since the last processed fn=633 (current fn=632)

so here a burst with TDMA fn=633 was received earlier than a burst
with TDMA fn=632.  The burst loss detection logic considered the
latter one as lost, and substituted it with a dummy burst.  When
finally the out-of-order burst with TDMA fn=632 was received, we
got the large number of allegedly elapsed frames:

  ((632 + 2715648) - 633) % 2715648 == 2715647

Given that late bursts get substituted, the best thing we can do
is to reject them and log an error.  Passing them to the logical
channel handler (again) might lead to undefined behaviour.

Change-Id: I873c8555ea2ca190b1689227bb0fdcba87188772
Related: OS#4658, OS#4546
2020-07-12 21:43:46 +07:00
Vadim Yanitskiy bb0609ed48 trxcon/scheduler: fix subst_frame_loss(): do not compensate too much
It's not something that we should be trying to fix, if the whole
TDMA multi-frame is lost.  For some yet unknown reason, sometimes
the difference between the last processed TDMA frame number and
the current one is so huge, so trxcon eats a lot of CPU trying
to compensate nearly the whole TDMA hyper-frame:

  sched_trx.c:640 Too many (>104) contiguous TDMA frames elapsed (2715647)
                  since the last processed fn=633 (current fn=632)

Let's just print a warning and do not compensate more than one
TDMA multi-frame period corresponding to the current layout.

Change-Id: I56251d0d2f6fa19195ff105d3bdfbc22df6db8cd
2020-07-08 15:55:05 +07:00
Vadim Yanitskiy a29277278b trxcon/scheduler: subst_frame_loss(): print current TDMA fn
Change-Id: I3d769ba3cbadc19bac0b25224460af8f06d0d776
2020-07-07 04:05:50 +07:00
Vadim Yanitskiy 3fea4de64e trxcon: use libosmocore's TDMA frame number API
Depends: (libosmocore) Ic291fd3644f34964374227a191c7045d79d77e0d
Change-Id: I49a043d8483e116cf2d91820edb511846175173f
2020-06-19 20:46:45 +00:00
Vadim Yanitskiy cf72753e6a trxcon/scheduler: cosmetic: clarify lost frame counter description
Change-Id: Ied5ea8524f2ec6c324e9fd37256111d099c23e6c
2020-06-18 11:52:06 +00:00
Vadim Yanitskiy 1c0dab9c95 trxcon/scheduler: cosmetic: use enumerated type instead of uint8_t
Change-Id: Idde328d176b4cbd89c62712e4a247095dd596105
2020-06-18 11:52:06 +00:00
Vadim Yanitskiy 55a63b1759 trxcon: use osmo_{store,load}32be() to pack / unpack TDMA fn
Change-Id: I9eff9b8e4b8ce9e0563a1ec3c485ab8b0f306491
2020-06-14 15:27:27 +07:00
Vadim Yanitskiy f8a3959cb2 trxcon: fix potential buffer overflow in l1ctl_proc_est_req_h1()
Change-Id: I10f03ca66412a4a7094b0f4a7319411d5d5818ef
2020-06-10 17:04:54 +00:00
Vadim Yanitskiy 0ed7c0ee5f trxcon: fix l1ctl_proc_est_req_h0(): convert to host byte order
L1CTL is using the network byte order, because this protocol is
spoken between different devices and architectures.  Somehow I
forgot about this while adding SETFH command back in 2018.

Change-Id: Ia2f70f0d5e35b6bf05e1fa6fb51a15c1bbe3ca4c
Related: OS#4546
2020-05-28 16:53:51 +07:00
Vadim Yanitskiy 4f677e6ba8 trxcon: refactor trx_if_cmd_setfh(): send Rx/Tx frequencies
It would make sense to send the ARFCN list in parameters of SETFH
command, if there was a clear distinction between transceivers in
fake_trx.py, i.e. which one is an MS and which is a BTS.

Right now, every Transceiver is an abstract entity that emits
and receives bursts. So when you convert an ARFCN to a pair of
Downlink/Uplink frequencies, you don't know whether it maps
as Rx/Tx or as Tx/Rx for a given Transceiver.

Of course, we could assume that this is an MS specific feature,
and a pair of Downlink/Uplink frequencies always corresponds to
Rx/Tx, but what if some day we would need to implement and test
a similar approach for the BTS side? Also, by sending frequency
values in kHz (rather than ARFCNs) we can avoid inconsistency
with the existing RXTUNE / TXTUNE commands.

Change-Id: Ia2bf08797f1a37b56cf47945694b901f92765b58
Related: I587e4f5da67c7b7f28e010ed46b24622c31a3fdd
Related: OS#4546
2020-05-17 14:46:41 +07:00
Vadim Yanitskiy d8d71f6d24 trxcon: use buffer size macros for TRXC/TRXD messages
Change-Id: I6f2b8682c4691ed3da1bf804e302a7169f33e283
2020-05-17 14:36:32 +07:00
Harald Welte e607f7ef18 virt_phy: tweak log levels
Related: SYS#4822
Change-Id: Ia7e368cda8e016a4141b21e5219697420a503124
2020-05-15 08:58:21 +02:00
Oliver Smith 901ac89735 mobile: loopback: support EFR
Related: SYS#4924
Change-Id: I73d1f88b0865ad97b85418ff76739febf2e128a7
2020-05-05 12:22:32 +02:00
Oliver Smith 8f04fa9758 mobile: traffic req check: support EFR
L1CTL handling code should not be involved in such high level checks, so
while at it, move the check into a separate function in gsm48_rr.c and
add a length check. gsm48_rr_tx_voice() is the only caller of
l1ctl_tx_traffic_req().

Related: SYS#4924
Change-Id: Iba84f5d60ff5b1a2db8fb6af5131e185965df7c9
2020-05-05 12:22:26 +02:00
Neels Hofmeyr 3622522664 mobile: implement 'loopback' TCH frame I/O handler
Use newly added audio / loopback config vty node to provide audio
loopback from mobile app. Only FR is supported for now.

Change-Id: Icd0b8d00c855db1a6ff5e35e10c8ff67b7ad5c83
2020-05-05 12:19:58 +07:00
Neels Hofmeyr 785450c4bf mobile: add audio config, with unused audio loopback setting
The aim is to add configurable audio loopback to mobile. An existing patch on a
branch from fixeria [1] adds the audio config section. Add a reduced version of
this audio config to be compatible with the future merge.

Add the audio loopback setting, so far without functionality.
Subsequent patch adds the actual loopback.

[1] osmocom-bb branch fixeria/audio,
    patch "mobile/vty_interface.c: add new 'audio' section"
    Change-id I62cd5ef22ca2290fcafe65c78537ddbcb39fb8c6

Change-Id: Ie03e4a6c6f81ea3925266dd22e87506d722a6e1a
2020-05-05 12:02:31 +07:00
Vadim Yanitskiy b217b9b3e5 trxcon/logging: print category, level and extended timestamp
Since we're heavily using trxcon in ttcn3-bts-test, the logging
output should contain as much information as possible. Ideally
we should introduce the VTY interface (see OS#3666) and get
logging configuration options as a bonus. But let's just use
some beneficial hard-coded defaults for now:

  - print category and level (huh, we use NOTICE everywhere?),
  - do not print category-hex (who needs it anyway?),
  - print extended timestamp, so we're in synce with other logs.

P.S. This configuration is based on my own debugging experience.

Change-Id: Ie3d259f3255d8af80e6780f850b808fa243f97b4
2020-04-09 05:13:59 +07:00
Vadim Yanitskiy 4162b27dae layer23/l1ctl: fix: do not pass PDCH and CBCH frames to LAPDm
GPRS (PDCH) and CBCH related frames have nothing to do with LAPDm.
The former uses LLC for the user-plane data, while CBCH involves
its own segmentation described in 3GPP TS 23.041 and TS 44.012.

There is currently no code for handling these kinds of frames, so
let's just send them to GSMTAP and release the memory (msgb).

Change-Id: I59b4acbe22217f8989f73b79b128a43e8bcdfa2f
Related: OS#4439
2020-03-17 18:25:04 +07:00
Vadim Yanitskiy f889e916a9 trxcon/scheduler: print TDMA statistics on lchan deactivation
Change-Id: If8688ca331a7b1f841aa21f7a5ebc9750327b90a
2020-03-16 10:32:42 +00:00
Vadim Yanitskiy d944f1d89d trxcon/scheduler: be safe against a theoretical integer overflow
As was noted by Pau Espin Pedrol, there is a theoretical chance
that lchan->tdma.num_proc would overflow, so as a consequence,
subst_frame_loss() will be unable to compensate one
(potentionally lost) Downlink burst.

On practice, given the size of unsigned long and duration of a
single TDMA frame, it would only happen once in roughly ~6 years.

  FRAME_DURATION = 4615 * 10e-6
  ULONG_MAX = 2 ** 32 - 1

  FRAME_DURATION * ULONG_MAX -> ~198212740 seconds
                             -> ~55059 hours
                             -> ~2294 days
                             -> ~6 years.

Chances are that trxcon would crash much earlier, or even GSM
would be completely forgotten after such a long time run, but
let's work this around and simply start counting from 1
if that overflow eventually happens.

Change-Id: I3d40ef09b06039a85df52af06ab38de314e1a434
2020-03-16 10:32:42 +00:00