Commit Graph

2873 Commits

Author SHA1 Message Date
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
Harald Welte 3425527fb7 firmware/rfch.[ch]: Document functions + constify input arguments
Change-Id: I16d5190b3cdc997c5609b52d41203f10264b017c
2020-04-25 19:08:34 +02: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 75ae23674c trx_toolkit/app_common: add options to enable time printing
Change-Id: Ie5d14a261e17af554f7132b03d58549a4831dcdb
2020-04-09 04:44:49 +07:00
Vadim Yanitskiy ec71203e79 trx_toolkit/app_common: introduce auxiliary add_log_handler()
Change-Id: Ied32764cf1c34dc7e0f746f4f085ea20168775cb
2020-04-09 04:42:45 +07:00
Vadim Yanitskiy 67c49ba664 firmware/layer1: introduce experimental PDCH support
This change implements basic (receive only) support of the PDCH
channels that are used in GPRS. Several coding schemes are
defined by 3GPP TS 45.003, however we can only do CS-1
for now, since it's basically an equivalent of xCCH.

In order to support the other schemes (CS2-4), we would need to
know how to configure the DSP (look at Freecalypso code?).

Change-Id: I44531bbe8743c188cc5d4a6ca2a63000e41d6189
2020-04-01 10:18:54 +00:00
Vadim Yanitskiy 930d7240bf trx_toolkit/trx_sniff.py: add options to filter bursts by RSSI
Change-Id: I16dd29d2f1e14e634029195599fa49a9be9219ab
2020-03-30 19:22:47 +07:00
Vadim Yanitskiy b1f0772002 trx_toolkit/trx_sniff.py: add option to ignore NOPE / IDLE indications
Change-Id: If51052af04289f10bfaefd5374049908de05319a
2020-03-30 19:20:32 +07:00
Vadim Yanitskiy bbd1edccae trx_toolkit/trx_sniff.py: pass the whole msg to burst_pass_filter()
Change-Id: I3da62249a4d62078b79ce5e79c86923e59c1e457
2020-03-30 19:00:45 +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
Vadim Yanitskiy 9d3c2d047b trxcon/scheduler: do not abort on incomplete set of bursts
Change-Id: Iea2d1b75b50c2889d4766687ef4fe6ae4ea39a50
2020-03-16 10:32:42 +00:00
Vadim Yanitskiy c86ba06258 trxcon/scheduler: TCH/F: fix Downlink burst completeness check
A TCH/F or FACCH/F frame is interleaved over 8 bursts, not 4.

Change-Id: I2ee4a216a18e9b077b27887235d982481991d9c4
2020-03-16 10:32:42 +00: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 431dcd00f0 trxcon/scheduler: substitute lost TDMA frames on Downlink
It may happen that one or more Downlink bursts are lost on their
way to the MS due to a variety of reasons. Modern transceivers
supporting TRXDv1 protocol would substitute lost bursts with
so-called NOPE indications. Hovewer, neither fake_trx.py nor
grgsm_trx do support this feature at the moment.

We can still detect and compensate TDMA frame loss per logical
channels in the same way as it's already done in osmo-bts-trx.
In short, we should keep TDMA frame number of the last received
burst in the logical channel state, and using the appropriate
multiframe layout, check if there were any gaps between TDMA
frame number of the current burst and the stored one.

Change-Id: I3551d79796a3730565c2c70577e9d134e636f275
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
Harald Welte b9ab7150bf virtphy: Delay response between L1SAP_PM_REQ and L1SAP_PM_CONF
Change-Id: I443b5512c4966c232107aeb73e1fd8b83335d63d
2020-03-10 21:24:04 +01:00
Harald Welte c429e7a1d8 virtphy: Add command line arguments to set multicast netdev + TTL
This allows us to bind the multicast sockets to a given network device
and/or to set the TTL of the multicast frames and hence control their
reach in terms of number of network hops.

Change-Id: Ia74aa381a4c1921cb8c7e263842a864ea8028139
Related: OS#2966
2020-03-10 18:58:55 +01:00
Harald Welte 17a9089452 virtphy: Sync virtual_um.[ch] with osmo-bts
The files are used in both projects, and while the osmo-bts code has
evolved, this copy didn't.  Let's sync again (to libosmocore
change-Id I303f2e616d2d32b5a8005c3dcf0f5fad19ad3445).

Change-Id: I189ee28a85a6d7a7a07b062f6b07012478503e8f
Depends: libosmocore.git Ib52d22710020b56965aefcef09bde8247ace4a9c
Related: OS#2966
2020-03-10 18:58:55 +01:00
Harald Welte 419f617a3c virtphy: Fix GSMTAP ARFCN use with multi-TRX BTS
In case we get assignments to secondary TRXs, the ARFCN of that
TRX must be used, and not the serving cell BCCH ARFCN.

Change-Id: Ief6cf5816969d819ff9506be70bec9b8d0d9d9be
2020-03-09 19:35:49 +01:00
Harald Welte a42563b684 virt_phy: implement GSMTAP_CHANNEL_VOICE
GSMTAP_CHANNEL_VOICE is the mechanism by which GSMTAP can [finally!]
be used to transport circuit-switched voice codec payload, and not
just signalling.

Original patch by Neels Hofmeyr, heavily extended by Harald Welte.

Change-Id: Id72cf23b7c6587efae4cdaa7b50ab4d85b8c8d22
2020-03-09 19:35:49 +01:00
Vadim Yanitskiy 61a06f4d36 trxcon/scheduler: fix n_errors for BFI triggered by FACCH
These BFI (Bad Frame Indications) substitute speech frames stolen
by FACCH/F or FACCH/H frames, so there can be no bit errors in
something that was not even transmitted over the air interface.

Change-Id: Icdb6209f75ead6581e3c18aeee0da9831aaa272a
2020-03-08 22:50:54 +00:00
Vadim Yanitskiy 12357a7d37 trxcon/scheduler: FACCH: ensure fake measurements for BFI
According to 3GPP TS 45.003, clauses 4.2.5 and 4.3.5:

 - one FACCH/F frame steals a single speech frame,
 - one FACCH/H frame steals two speech frames.

A BFI (Bad Frame Indication) needs to be sent for each stolen
speech frame. This does not apply to CSD (data) channels though.

The BFI frames must have measurement data attached to them, and
due to their virtual nature (they do not actually come from the
air interface), the measurements must be crafted by trxcon.

Assigning a negative value to n_errors makes the code below the
'bfi' label craft fake measurement data. Otherwise, the actual
measurements belonging to the FACCH frame will be used.

Change-Id: Ia2f7c3cf7b1ef3737da6b1818cae2f001ee8768f
2020-03-08 22:50:54 +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 d534d43fc1 trxcon/scheduler: TCH/H & FACCH/H: fix notes on interleaving
Change-Id: I16cdd2261b3d0d99286c30584847f93d72d02ac0
2020-03-08 22:50:54 +00:00
Vadim Yanitskiy 03f220ecae trxcon/scheduler: make TDMA_FN_INC(fn) behave like ++fn
Change-Id: I9c2fa26df54b5de836a18f09363a9221c24ae707
2020-03-08 22:50:54 +00:00
Harald Welte a1be0a6b62 cbch_sniff: Use CCCH_MODE_COMBINED_CBCH, not CCCH_MODE_COMBINED
In Change-Id Ia94ebf22a2ec439dfe1f31d703b832ae57b48ef2 we
introduced a new member to the ccch_mode enum: CCCH_MODE_COMBINED_CBCH,
which is to be used to tell the PHY if a CBCH is present on the combined
CCCH+SDCCH/4+CBCH or not (CCCH+SDCCH4).

This was implemented in trxcon + calypso firmware, but cbch_sniff has
not been updated accordingly.

Related: OS#4439
Change-Id: I429d45cfb181da4a2e767e92f1213ccd08c6d440
2020-03-07 16:25:46 +01:00
Harald Welte 90616c1eba virtphy: Don't pass CBCH to L1CTL if not requested by application
Doing so can create a number of warning messages in e.g. 'mobile'
like
<0015> lapd_core.c:1239 Unnumbered frame not allowed. (dl=0x55c632f9f220)
<0015> lapd_core.c:392 sending MDL-ERROR-IND cause 12 from state LAPD_STATE_IDLE (dl=0x55c632f9f220)
<0015> lapdm.c:481 sending MDL-ERROR-IND 12
<0001> gsm48_rr.c:4977 MDL-Error (cause 12) ignoring

Change-Id: I2cf65be5b2f879fe940e08c9f369bc1cada7b0dd
Closes: OS#4439
2020-03-07 16:25:46 +01:00
Harald Welte d32797677d virt_l1_sched_execute: talloc_free() TDMA item after unlinking it
We so far relied on it being free'd once the TDMA item is free'd,
but let's make it more explicit.  After we've unlinked it from the
list, nobody is going to reference it ever again.

Change-Id: I57a596428be10ce720e0b528ecfc44a70e3e3078
2020-03-07 10:31:48 +01:00
Harald Welte ee26ba6e60 cosmetic: Use INIT_LLIST_HEAD() and llist_add_tail()
... instead of manually re-inventing them.

Change-Id: I7e0810aa7fd1daa8f9f3e46a207589a4c6da836b
2020-03-07 10:18:18 +01:00
Neels Hofmeyr 0c77a7f4cf mobile: fix gsm_recv_voice: pull l1ctl header from TCH payload
That function encapsulates the RTP payload in an MNCC header, but the l1ctl dl
header has to be removed first to get only the RTP payload in the MNCC
structure.

Change-Id: Id6ddc9b1da43e88c5b9468d4397a39953bdf533a
2020-03-05 13:32:58 +01:00
Neels Hofmeyr bf4a026db9 remove unused func decl
Change-Id: I94c8fff1557c0ce50cc3072573ef7cda8622fb84
2020-03-05 13:32:56 +01:00
Vadim Yanitskiy 60ce345755 mobile/gsm322: fix use-after-free of cs->si reported by ASan
This pointer cs->si stores an address to the System Information of
a currently selected cell. When we release System Information,
ensure that it does not point to free()d memory.

Change-Id: Ife2ddf7274a48447a9ded9035f9dd01befaf2e6c
2020-03-01 02:22:13 +07:00
Vadim Yanitskiy c083e2ce90 layer23/l1ctl: fix NULL-pointer dereference reported by ASan
Some applications (e.g. ccch_scan) may not initialize ms->cellsel.si,
some (e.g. mobile) may need some time to initialize it. Let's assume
that 'bs_ag_blks_res' is 1 if System Information is not available.

Change-Id: Ie695d9700c01ee1e6778950a2f3c8610b69d2143
2020-03-01 02:22:13 +07: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 2d355c2453 virt_phy/build: add configure option to build with ASan/USBan
Change-Id: I23fc4e38632c02269b3895115ba4e3171cc212d1
2020-02-27 23:46:40 +07:00
Harald Welte 938faa16e4 layer23: Terminate process if L2 socket fails/dissappears
We don't recover from this situation at all, so it's best to
terminate the process.

Change-Id: I487d18e4afe2cae9f777a30864e680b5dc821fc1
2020-02-26 00:13:04 +01:00
Pau Espin 5738e579b2 layer23: Fix build against gpsd >= 3.20
During 3.19->3.20 dev cycle, some fields were transformed from
timestamp_t or double to timespec_t. See for instance gpsd.git
f7c230fceb6d64483757f8c32afb98e6a2cb9413.

Change-Id: Ie8ba19d030b6f46f2d8afc270a732ce8c26c438f
2020-01-13 17:28:25 +01:00
Pau Espin 6970755342 layer23: Avoid sending downlink AGCH/PCH fill frames over GSMTAP
Some bits are taken from osmo-bts l1sap.c.

Change-Id: Id21e9334b620b8ab3ad404708bfd5358e3555ab6
2019-12-31 17:05:50 +00:00
Pau Espin ae431deae4 layer23: Identify AGCH from PCH on tx of GSMTAP downlink messages
Some bits are taken from osmo-bts l1sap.c

Change-Id: I0adab003a4060c9cef730e0432859659c51bd087
2019-12-31 17:05:50 +00:00
Pau Espin 750faef5ba mobile: Send correct ARFCN in UL gsmtap
Change-Id: I9f677866095413a0efeb8a336ce15a2dbca2228c
2019-12-31 17:05:50 +00:00
Vadim Yanitskiy 7a49fc31c1 trx_toolkit/data_dump.py: rewrite unit tests to use unittest framework
Change-Id: I8b934c15ba96d856aa79d10bf296d1446f043dd1
2019-12-31 17:03:12 +00:00
Vadim Yanitskiy 5cee398277 trx_toolkit/data_msg.py: rewrite unit tests to use unittest framework
Change-Id: Ia0cc7447b193a705e994078d16f3902339219916
2019-12-31 17:03:12 +00:00
Vadim Yanitskiy f445db03c7 contrib/jenkins.sh: also run unit tests for TRX Toolkit
Python's unittest module will automatically discover all unit tests
in a given directory (files starting with 'test*.py'). The existing
tests will be rewritten in subsequent changes.

Change-Id: Ia3990dc8e1ff98b83d3ee25fafa5b029f46646cd
2019-12-31 17:03:12 +00:00
Vadim Yanitskiy 5198385533 contrib/jenkins.sh: also verify building the firmware
Change-Id: I4c224ef7855a2ac35476cbdd96c29565151a2830
2019-12-31 17:03:12 +00:00
Pau Espin 4ddb2e61c7 layer23: Fix trailing whitespace
Change-Id: I295f285e5fc3cdc372723f6b4de2415a94d4979a
2019-12-20 16:47:21 +01:00
Pau Espin 5b7fc0a8cc trxcon: Use current MS Power on dummy meas reports
backpointers are added in order to access the TRX, as advised in the
existing comment.

Change-Id: I975cfc5f5d63eb32a7f8932a7f6a544c9a12233c
2019-12-04 14:41:56 +01:00
Vadim Yanitskiy 7069dfc051 trxcon/sched_trx.c: fix potential NULL-pointer dereference
Change-Id: If1ecd9f5a70fa448327c62d38d76c8443b939248
2019-12-01 13:11:42 +00:00