Commit Graph

2207 Commits

Author SHA1 Message Date
Vadim Yanitskiy c89047d8bc trxcon/scheduler: enrich GSM 05.03 encoding error messages
Change-Id: I35a7c5df4fc0ed2195ba721f92812874011459d9
2019-06-30 17:28:06 +07:00
Vadim Yanitskiy 696fe71ac1 trx_toolkit/data_msg.py: add basic class documentation
Change-Id: I538bc96e5e24d3b7e344e4dbe2877bf60c13c720
Related# OS#4006
2019-06-24 14:18:09 +00:00
Vadim Yanitskiy 1ff9780366 trx_toolkit/data_msg.py: inline both gen_fn() and parse_fn()
Both functions are never used outside of both gen_msg() and parse_msg().
AFAIR, they were more complicated until we started to use struct, but
now they can be easily inlined.

Change-Id: Ie64b271cf502f3df23b32f4b14a1e2b551a0f794
2019-06-24 14:18:09 +00:00
Vadim Yanitskiy 84bd7b2746 trx_toolkit/data_msg.py: drop double field initialization
Those fields are being initialized by __init__().

Change-Id: Ibf71be552a7eb5dab1d096421a8557514294683e
2019-06-24 14:18:09 +00:00
Vadim Yanitskiy 7a007e82a8 trx_toolkit/data_msg.py: tests: use random reference data
Having fn = 1024 and tn = 0 in all tests decreases the chances
to spot encoding / decoding bugs of higher or lower values.
Let's randomize the reference data before all the tests.

Change-Id: Id3c5be9faaf0bef727b975c7182098af0cec6e71
2019-06-24 14:18:09 +00:00
Eric Wild 4269c4d00b trxcon/scheduler: fix bit shift in BSIC / TDMA FN calculation
Ubsan is unhappy about shifts into the sign bit of our implicitly
promoted value.

Change-Id: I4e72db1143a68064ba83668414dc3d60c0e1ad78
2019-06-24 12:55:52 +00:00
Vadim Yanitskiy 924d2412c4 trxcon/l1ctl.c: properly handle handover RACH request
During the handover the MS needs to release the existing dedicated
channel(s), establish the new one(s) as indicated by the network,
and then, depending on the synchronisation state, send one or more
HANDOVER ACCESS messages carried by Access Bursts.

In order to implement this, trxcon needs to be able to transmit
Access Bursts on any TDMA timeslot regardless of the logical
channel type and the associated handler, i.e. != TRXC_RACH.

The controlling side on L1CTL (layer23 or TTCN-3) needs to send
one or more L1CTL_RACH_REQ message(s) with properly populated
UL info header. Otherwise a regular RACH on TS0 is assumed.

Change-Id: Ia967820a536c99966ba2c60b63d2ea9edb093f46
2019-06-02 12:44:12 +00:00
Vadim Yanitskiy 91d5e5e191 trxcon/scheduler: fix: do not ignore SACCH prims with odd length
Before this patch, prim_dequeue_sacch() used to ignore SACCH primitives
with odd length (e.g. 21, when sender forgot to push 2 octets of L1
SACCH header), so neither they were transmitted, nor rejected.

As a result, they would stay in the Tx queue until a dedicated
connection is released. The only way to notice such problem
was looking at the constantly growing talloc's report.

Instead of ignoring the primitives with odd length and keeping them
in the queue, let's pass them to a logical channel handler, so they
would be dequeued and rejected with a proper logging event.

Also, to simplify further debugging, let's print the final decision
of SACCH prioritization: whether it's a Measurement Report or not.

Change-Id: I3149fa518439470b397953306209eb859c83450a
2019-06-02 04:04:08 +07:00
Vadim Yanitskiy 6e9808662f trx_toolkit/data_msg.py: fix: extend RSSI value range to [-47..-120]
Change-Id: I9fce3462db14bd273a1498762cc9293fc888b45a
2019-06-01 01:42:43 +07:00
Vadim Yanitskiy 3655350992 trxcon/sched_mframe.c: mark all stolen CBCH UL slots as TRXC_IDLE
According to 3GPP TS 05.02, section 6.4.1, CBCH replaces
SDCCH number 2 in both V (BCCH+CCCH+SDCCH/4+SACCH/4) and
VII (SDCCH/8+SACCH/8) logical channel combinations.

Unfortunately it is not clear whether we can use stolen UL slots
for RACH or not. For now, we should mark all of them as IDLE.

Somehow TRXC_SDCCH4_2 slots were left in the definition of
combination V (combined CCCH+BCCH). This is not critical,
but may be looking confusing. Let's fix this.

Change-Id: Id30f2fac3274de3edff4ae59f77d9c9cf8059155
2019-05-31 16:51:44 +00:00
Harald Welte 49bec6c478 trxcon/trx_if.c: Dropping UL bursts is a noticeable event
Therefore we should use LOGL_ERROR instead of LOGL_DEBUG.

Change-Id: If5084feb9e847d212530b1a5985390405d91008b
2019-05-31 22:40:55 +07:00
Harald Welte fd6c211eab trxcon: Suppress POWERON to TRX if we're already powered on.
The existing logic unconditionally wants to send a POWERON command
on TRXC whenever L1CTL_FBSB_REQ is received.  That may cause some
problems when sending subsequent L1CTL_FBSB_REQ, e.g. due to signal loss.

Sending POWEROFF when transceiver is not powered on is normal though.
This can happen if trxcon is restarted while fake_trx was running.

The existing FSM state could unfortunately not been used, as it's a
mixture between the TRX connection state and the command/response state.

The current solution is just a work around. We definitely need to
introduce separate state machines for transceiver and its TRXC
interface.

Change-Id: I834e8897b95a2490811319697fc7cab6076db480
2019-05-31 22:35:31 +07:00
Vadim Yanitskiy 1a66c2991c trxcon/scheduler: move PRIM_IS[_EXT]_RACH macros to sched_trx.h
Both PRIM_IS_RACH() and PRIM_IS_EXT_RACH() macros to be used for
handover RACH detection in the follow up changes, thus we need
have them widely available. Let's also give them better names:

  PRIM_IS_EXT_RACH -> PRIM_IS_RACH11
  PRIM_IS_RACH     -> PRIM_IS_RACH8

and introduce a new generic one for checking whether a given
primitive is RACH in general (either 8-bit or 11-bit) or not.

Change-Id: Ibc39c57fda000647be1829786f6423dcf3f435cd
2019-05-30 03:59:16 +07:00
Vadim Yanitskiy 043136937a trxcon/l1ctl.c: on L1CTL_DM_EST_REQ, determine pchan_config first
It makes sense to do this first, before tuning to a different
ARFCN and changing the training sequence. Otherwise, if no
multi-frame configuration is found, trxcon would switch to
a different channel and then remain inactive there.

Change-Id: I274588ce3a9c49372b5da0629930afece46f799c
2019-05-29 18:53:31 +07:00
Vadim Yanitskiy 1efe26f41a trxcon/l1ctl.c: use #define for RSL_CHAN_RACH
Change-Id: Ifdb1703217c7540344cf6772efe812c8a786a0c2
2019-05-28 20:27:42 +07:00
Vadim Yanitskiy 08a1990272 trxcon/sched_mframe.c: do not hard-code lchan combinations
Having magic pre-calculated hex-masks gives one quite high chances
to shoot oneself in the foot, and decreases readability in general.

Let's do this pre-calculation during the compilation process, so
it's much easier to read, extend and spot potential bugs.

Change-Id: If945b3654e35c83fc0220fdd6d99c1c7a0503386
2019-05-28 19:20:38 +07:00
Vadim Yanitskiy 189da79ebb trxcon/sched_lchan_desc.c: fix missing TRX_CH_FLAG_AUTO flag
In I2fc61e1cdca4690a34e2861b9ee3b7c64ea64843 I introduced a regression.
TRXC_SDCCH4_CBCH should have TRX_CH_FLAG_AUTO, because it's a part of
GSM_PCHAN_CCCH_SDCCH4_CBCH multi-frame layout. If the controlling
side on the other end of the L1CTL link requests this particular
multi-frame layout, CBCH channel is expected to be active.

Change-Id: I3ed942106a03220417b5cb9176107af057120fbe
2019-05-28 16:22:15 +07:00
Harald Welte 27b6bb0721 virt_phy: Fix typo in log message
Change-Id: I9291957ef5d7033d46060d07f2aa0a3880612e1a
2019-05-28 06:32:34 +00:00
Harald Welte d5ff9bb1aa layer23: fix tons of compiler warnings, mostly OSMO_DEPRECATED related
Change-Id: I03918bd864c711b377a795186123c85bb6f4dc4a
2019-05-28 06:32:34 +00:00
Vadim Yanitskiy d0588f31f4 trxcon/scheduler: refactor description of TRXC_* lchans
Let's avoid fancy alignment in the description of logical channels
for the benefits of having better readability, the ability to add
more comments and fields without making it look ugly.

Also, let's get rid of field 'chan' of 'trx_lchan_desc' structure
since it's not used anywhere, and not actually needed because the
position of each lchan description is defined by its TRXC_* type.

As a bonus, let's add a human readable description to each
lchan definition, so it can be printed in the VTY some day.

Change-Id: I2fc61e1cdca4690a34e2861b9ee3b7c64ea64843
2019-05-28 07:12:09 +07:00
Vadim Yanitskiy a42f2ef127 trxcon/sched_trx.c: add missing branch for GSM_PCHAN_PDCH
PDCH channel support was introduced quite a while ago, but there
was no way to activate it via L1CTL so far. Let's fix this.

Change-Id: I3b66cab26108ab999a7fe969365ab57dc661399c
2019-05-28 07:12:09 +07:00
Vadim Yanitskiy 923c19a883 firmware/scheduler: Fix CBCH related RSL channel numbers
CBCH support in the firmware has been introduced almost at the same
time it was implemented in trxcon, and the same mistake was made
as described in Ia9a415628c659cbc2dd5dc65b875b7f935d6e211.

Despite Calypso based PHY does not support PDCH (GPRS channels),
let's avoid collisions and use the following cbits values:

  0x19 / 0b11001 - MF_TASK_SDCCH4_CBCH on GSM_DCHAN_SDCCH_4_CBCH,
  0x1a / 0b11010 - MF_TASK_SDCCH8_CBCH on GSM_DCHAN_SDCCH_8_CBCH.

Change-Id: Ibb0f90695460e6ede12016c12a0cfdf9c74dfb24
Related: OS#4027
2019-05-28 06:43:37 +07:00
Harald Welte c1e2ff6525 trxcon: Use RSL channel mode #defines from libosmogsm
Wherever possible, use #defines from libosmogsm as opposed to magic
numbers.  Using magic numbers in several places has the danger of
different programs/repositories having different views on what those
values mean.

Change-Id: I7ab4958801b3422973b67ff0452b90afa8a3f501
Related: OS#4027
Depends: libosmocore Change-Id I93e557358cf1c1b622f77f906959df7ca6d5cb12
2019-05-27 23:34:21 +02:00
Harald Welte 9ba051bae8 trxcon: Fix CBCH related RSL channel numbers
OsmoBTS, BSC and TTCN3 used cbits == 0x18 for dynamic PDCH, while
trxcon wanted to use 0x18 for CBCH on SDCCH/4.  Let's fix this and
bring everyone in agreement.

Related: OS#4027
Change-Id: Ia9a415628c659cbc2dd5dc65b875b7f935d6e211
2019-05-27 23:33:42 +02:00
Harald Welte 00513d65c8 common/sap_fsm.c: fix missing pointer dereference
sap_fsm.c: In function ‘sap_negotiate_msg_size’: sap_fsm.c:103:15:
warning: passing argument 1 of ‘__bswap_16’ makes integer from pointer
without a cast [-Wint-conversion]:

  size = ntohs((uint16_t *) param->value);
               ^~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: Ie58af6162c67ae377809b42daa897ca3f3d72af1
2019-05-23 16:02:16 +03:00
Harald Welte e6a5342272 layer23: Fix 'make distcheck'
Change-Id: Ic48e240ee1484aaa793af23c62a24d2949900b86
2019-05-22 21:39:38 +02:00
Harald Welte 808998c3f8 bcch_scan: Fix compiler warning about undefined functions
Change-Id: I435ef2032b9cefe844c37f395d9087be6af8934a
2019-05-22 21:39:38 +02:00
Vadim Yanitskiy ab7118a2aa trx_toolkit/clck_gen.py: avoid logging \0-terminator
Change-Id: I93da2e8ba9d3fda944b8171bc42e49063c925f9c
2019-05-17 19:40:31 +07:00
Vadim Yanitskiy 507781ee70 common/sim.c: add missing break to sim_apdu_resp()
Change-Id: Id5c325ffcfea8175bc5d5499a0904c0984e00349
Fixes: OS#198542
2019-05-14 20:52:39 +07:00
Vadim Yanitskiy 12a8318153 firmware/Makefile: clarify toolchain configuration include
Change-Id: I77ce68d5904ff623f10f6475309052666bab7742
2019-05-13 02:31:54 +07:00
Harald Welte 01e374d27c firmware/Makefile.inc: fix sections with overlapping VMA
Starting from [1], not only LMA but also VMA areas are now checked
for overlaps (see also [2]). This results into linking errors:

  arm-none-eabi-ld: section .text.exceptions VMA
    [000000000080001c,0000000000800037] overlaps section
    .compal.reservedram VMA [0000000000800000,00000000008000fe]
  arm-none-eabi-ld: section .text.exceptions VMA
    [000000000080001c,0000000000800037] overlaps section
    .compal.loader VMA [0000000000800000,00000000008000ff]

Let's try to work around this.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a87dd97a2098b7e18ff2574a4e81ae521ef7e6f2
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=18452

Change-Id: I098ddd33aabd7ec27981e2f09d8582f167bb649b
Fixes: OS#1917
2019-05-13 02:28:36 +07:00
Vadim Yanitskiy 0f5f76f651 trxcon/trx_if.c: use ssize_t for return value of read()
Change-Id: I4a489be6fafcd057c3edc4f3d5f76d645899f884
2019-05-09 23:53:12 +00:00
Vadim Yanitskiy 4c2d32afe6 trxcon/trx_if.c: print error message if read() call fails
Change-Id: If3aaa730c306e703d1d430a8920284aa592c999c
2019-05-09 23:53:12 +00:00
Vadim Yanitskiy 2d05901cd4 trxcon/trx_if.c: use read() call instead of recv()
According to the man page of recv(), the only difference of this
call from read() is the presence of flags. With a zero flags
argument, recv() is generally equivalent to read().

Change-Id: I6d43bbf8d52c5fbb8ee0592b7d1c1dfd2dd1548e
2019-05-09 23:53:12 +00:00
Vadim Yanitskiy 1f07f3e34a trxcon/l1ctl.c: init DL info header in l1ctl_tx_rach_conf()
Since we only set both ARFCN and TDMA frame number of the DL info
header, other fields remain uninitialized. Let's memset() them.

Change-Id: Ib39c333f1724fefa5d8bd8a2315b77a5612f7fa9
2019-05-09 22:08:42 +07:00
Vadim Yanitskiy 2d94a4b71c trxcon/l1ctl.c: pass band_arfcn to l1ctl_tx_rach_conf()
This would allow to abstract both L1CTL and TRX interfaces
from each other in the upcoming refactoring.

Change-Id: I74a23c73b03bad822272b9cfe76c2501666912b7
2019-05-09 22:01:28 +07:00
Vadim Yanitskiy cb9e020471 mobile/gsm48_mm.c: use proper types for gsm48_rr_hdr
Change-Id: I29ed122b8956260b9f847cc0e3e81a28d6762632
2019-05-03 00:57:50 +02:00
Vadim Yanitskiy 04a46d091b mobile/gsm48_rr.h: mark gsm48_rr_hdr struct as packed
In both gsm48_mm.c and gsm48_rr.c we put / push 'gsm48_rr_hdr'
structure into the message buffers, so then it's retrieved by
the message receivers. The AddressSanitizer complains about
unaligned pointer access and potentially unexpected behaviour.

Change-Id: I8aa2c0074b405afd0e76044ef076b6819fe1083b
2019-05-03 00:48:35 +02:00
Vadim Yanitskiy e8c179a575 mobile/gsm322.c: fix heap-use-after-free in gsm322_unselect_cell()
In gsm322_l1_signal(), if S_L1CTL_FBSB_ERR is received, we free
stored System Information of the current cell, but cs->si may
still point to it. Let's set it to NULL.

Found with AddressSanitizer:

  DL1C ERROR l1ctl.c:96 FBSB RESP: result=255
  DCS INFO gsm322.c:2995 Channel sync error, try again
  DCS INFO gsm322.c:467 Sync to ARFCN=860(DCS) rxlev=-106
  DRR INFO gsm48_rr.c:665 MON: no cell info
  DRR INFO gsm48_rr.c:665 MON: no cell info
  DRR INFO gsm48_rr.c:665 MON: no cell info
  DRR INFO gsm48_rr.c:665 MON: no cell info
  DL1C ERROR l1ctl.c:96 FBSB RESP: result=255
  DCS INFO gsm322.c:3008 Channel sync error.
  DCS DEBUG gsm322.c:3013 free sysinfo ARFCN=860(DCS)
  DCS INFO gsm322.c:3020 Unselect cell due to sync error!
  DCS INFO gsm322.c:509 Unselecting serving cell.
  =================================================================
  ==6014==ERROR: AddressSanitizer: heap-use-after-free on address
                 0x61b0000000e6 at pc 0x00000050d6dd
		 bp 0x7fff7f84aa60 sp 0x7fff7f84aa58

Change-Id: I9cc526c18d69695d810de98703579818408de011
2019-05-03 00:34:40 +02:00
Holger Hans Peter Freyther b4bd78a8ee lua: Add a sentinel for the fd function table
Change-Id: I4fe2fd6584a453a951361e1b67fb986583b176be
2019-04-27 10:15:28 +01:00
Vadim Yanitskiy cca67cfe94 trx_toolkit/data_msg.py: fix TOA256 MIN/MAX constants
The old TOA256 range was bigger than we can actually store:

  struct.error: 'h' format requires -32768 <= number <= 32767

Change-Id: I5d4e1fea9d07f2c49f01e6644d1c0d1dc8cf4e40
2019-04-24 15:12:03 +07:00
Vadim Yanitskiy 4dd92e2520 trxcon: introduce extended (11-bit) RACH support
According to 3GPP TS 05.03, section 5.3, two coding schemes are
specified for access bursts: one for regular 8-bit bursts,
another - for extended 11-bit packet access bursts.

According to 3GPP TS 05.02, section 5.2.7, there are two
additional training (synchronization) sequences for RACH
bursts: TS1 & TS2. By default, TS0 synch. sequence is used,
unless explicitly stated otherwise (see 3GPP TS 04.60).

According to 3GPP TS 04.60, section 11.2.5a, the EGPRS capability
can be indicated by the MS using an alternative training sequence
(i.e. TS1 or TS2) and the 11-bit RACH coding scheme.

Change-Id: I36fd20cd5502ce33c52f644ee4c22abb83350df8
2019-04-22 09:17:23 +00:00
Max e9bedd12f7 trxcon: use static helper to prepare FBSB
Use static helper to prepare l1ctl_fbsb_conf - this simplifies
fbsb-related functions and make difference between timer callback and
regular response more obvious.

Change-Id: I43832d6a912a32ea5795ed0110981e0b714a7a61
2019-03-21 16:58:56 +01:00
Max 25e17a9c7f trxcon: log FBSB timer events
Change-Id: I0168d43951494f4010df891f391ddad4b57493d7
2019-03-21 16:58:56 +01:00
Max 7f024a30a4 trxcon: use helper to add l1ctl_info_dl
Use static helpers to add l1ctl_info_dl to msgb - this simplifies
l1ctl_* routines and reduce code duplication.

Change-Id: I0b5b81f1fcd2984136e553a93735ea5456d2b3df
2019-03-21 15:46:29 +01:00
Max c53cb3ec83 trxcon: use bool for fbsb_conf_sent
It's only used as a boolean value so let's set proper type for it.

Change-Id: Iaf50cdd19ac2139ee2d625671410a486edae2999
2019-03-21 13:16:39 +01:00
Vadim Yanitskiy 803e420a4f trxcon/scheduler: clarify decoding of incomplete xCCH blocks
Inspired by Sylvain's message at #osmocom.
Change-Id: I3f499837413e1dbd0ca62229dc9cb6f0f7475a42
2019-03-10 15:32:29 +07:00
Vadim Yanitskiy 4d3337c9ab target/firmware/tiffs: update copyright statements
In OS#3582, the autor of TIFFS code, Mychaela Falconia, has noted:

  ... all of my code contributions are in the public domain and
  are NOT copyrighted by me, and I strenuously object to anyone
  taking it upon themselves to insert a copyright notice with
  my name in it.

Let's update the copyright statements as recommended by the author.

Change-Id: If115991425372a4cdbcfefa115532c9c410e58c4
2019-03-06 01:50:21 +07:00
Vadim Yanitskiy 4bc4655bd6 trxcon/scheduler: count number of measurements
Instead of counting both RSSI and ToA measurements separately,
let's have a single counter in trx_lchan_state.meas struct.

Change-Id: I45454a3ac92b8cc85dd74092e4ab6eb350f20c9a
2019-02-21 17:20:36 +07:00
Mychaela Falconia 9473699229 firmware/lib: introduce TIFFS filesystem support
All known TI GSM firmwares implement some kind of flash file system, or FFS.
We call it TIFFS (Texas Instruments FFS) because it is TI's invention.

TIFFS is a file system with a hierarchical directory tree structure, and
with Unixy forward-slash-separated, case-sensitive pathnames; the semantics
of "what is a file" and "what is a directory" are exactly the same as in
UNIX; and TIFFS even supports symlinks, although that support is a little
under-developed, and apparently no FFS symlinks were ever used in any
production GSM device. Thus the FFS implemented in TI-based GSM devices
(modems and "dumbphone" handsets) is really no different from, for example,
JFFS2 in embedded Linux systems.

The FFS in a GSM device typically stores two kinds of content:

  - Factory data: IMEI, RF calibration values, device make/model/revision
    ID strings etc.  These files are expected to be programmed on the
    factory production line and not changed afterward.

  - Dynamic data written into the FFS in normal device operation: contacts,
    settings / preferences, call history, received SMS, etc.

It should be noted that both Compal (Mot C1xx) and Foxconn (Pirelli DP-L10)
vendors moved their vital per-unit factory data out of the FFS into their
own ad hoc flash data structures, leaving their FFS only for less
critical data. However, we do enable TIFFS access for them anyway.

The location of TIFFS within the flash memory of a given GSM device is
defined by the firmware design of that device, but is always some integral
number of contiguous flash sectors.

  - On Motorola/Compal C139/140 phones, the FFS used by the original
    proprietary firmware occupies 5 sectors of 64 KiB each (320 KiB
    in total), starting at 0x370000. C11x/123 use smaller FFS
    configurations, whereas C155/156 seem to have switched to some
    other FFS format, different from our familiar TIFFS.

  - On the Pirelli DP-L10, the FFS used by the original proprietary
    firmware occupies 18 sectors of 256 KiB each (for 4.5 MiB in total),
    starting at the beginning of the 2nd flash chip select (0x02000000
    in the ARM7 address space).

  - On FCDEV3B (FreeCalypso hardware), the FFS is located in the first
    8 sectors (of 256 KiB each) in the 2nd flash chip select bank,
    which appears at 0x01800000 in the ARM7 address space.

  - On the GTA01/02 GSM modem, FFS occupies 7 sectors of 64 KiB each,
    starting at flash offset 0x380000.

For more information, please refer to the FreeCalypso project
documentation, from where this great contribution comes from.

Please note that existing MediaTek targets most likely use different
storage format as they have nothing from TI Calypso. Also, we don't
(yet) know the location of TIFFS on SE J100i and Compal E99 targets.

The TIFFS support is needed for the follow-up change, that
implements reading of the factory RF calibration values.

Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
Change-Id: If6e212baeb10953129fb0d5253d263567f5e12d6
Related: OS#3582
2019-02-19 15:18:56 +07:00