Commit Graph

72 Commits

Author SHA1 Message Date
Philipp Maier da084794a6 gsm_data: handle l1_info with structs
in struct gsm_lchan and also in other places l1_info is handled in its
binary form. Libosmocore now offers structs to handle l1 info, so lets
use those structs to get rid of all the manual decoding of l1_info.

Depends: libosmocore I23c1890b89d5a0574eb05dace9f64cc59d6f6df7
Change-Id: I5eb516d7849750f3dd174d48c9f07dabf2c80515
2021-02-16 22:28:18 +00:00
Vadim Yanitskiy ffbe63f408 fixup: vty: call bts_model_vty_init() from bts_vty_init()
Now bts_model_vty_init() must be called only once, otherwise the
process would crash when bts_model_init() is called from main().

Change-Id: I262c39896b5db86c54ad9aa7042c7ca6657815d9
Related: SYS#4937, OS#3036
2020-11-03 05:44:28 +07:00
Vadim Yanitskiy 5c7b709027 vty: call bts_model_vty_init() from bts_vty_init()
Similar to bts_vty_init(), BTS specific bts_model_vty_init()
requires a pointer to 'struct gsm_bts'.  Not only it's used
as a parent talloc context, but also stored locally, so then
it can be used by some VTY commands.

Let's expose the global 'struct gsm_bts' from main, and pass
the application's talloc context like was done in [1].

This finally makes the BTS model specific options appear in
the automatically generated VTY reference (--vty-ref-xml).

[1] Ic356a950da85de02c82e9882a5fbadaaa6929680

Change-Id: Iee7fee6747dd1e7c0af36f9b27326f651ae37aaf
Related: SYS#4937, OS#3036
2020-11-02 18:08:24 +00:00
Pau Espin 22f59cd63a Introduce NM Channel FSM
Change-Id: I288cbfb4730b25a334ef1c3d6b9679d6f1d4cfc5
2020-10-20 13:45:57 +00:00
Pau Espin 7810a91733 Introduce NM Radio Carrier and Baseband Transceiver FSMs
All the Operative State logic to manage a RadioCarrier//BBTransc NM objects is
centralized in these FSM, where other parts of the code simply send
events to it.
This allows keeping state consistent and offloading logic from each bts
backend, since they are only required to submit events now.
The idea in the long run is to also replace other NM objects with
similar FSMs.

This improved logic fixes bug where PHY + RSL link became available before
OPSTART and hence op state changed to Enabled before receiving any OPSTART message.

Change-Id: Ifb249a821c4270918699b6375a72b3a618e8cfbe
2020-10-20 13:45:57 +00:00
Pau Espin ae6e3e8f8b Introduce NM BTS FSM
Change-Id: Iae631bcc7acdf955296b124707e42d5e565af186
2020-10-20 13:45:57 +00:00
Pau Espin 88fe4b079d Introduce NM BTS Site Manager FSM
This fixes old behavior mimicing broken behavior in nanoBTS (according to TS 12.21)
where BTS Site Mgr NM object was announced as Enabled despite no OPSTART
was sent by the BSC.
With this new FSM, BTS SiteManager will be announced as Disabled Offline
during OML startup conversation, instead of Enabled.

The new osmo-bsc OML management FSMs use this change in behavior to find
out whether it should use the old broken management states (without
Offline state, as per nanoBTS) or use the new state transitions (which
allow fixing several race conditions).

Change-Id: Iab2d17c45c9642860cd2d5d523c1baae24502243
2020-10-20 13:45:57 +00:00
Pau Espin 6d117891c9 Change NM Channel availability Dependency->Offline when RadioCarrier becomes enabled
This fix allows osmo-bts to play fine with newer osmo-bsc NM OML FSMs,
which expectes for non-nanoBTS types to follow TS 12.21 guidelines.
Until now, BSC simply waited to received State Event Change Dependency
for each TS and then sent all required commands (Set Chan Attr, Adm
Unlock and Opstart). In newer osmo-bsc FSMs, Opstart is only sent when
in Offline state, so we need to transit to that state. For the above
mentioned reason, since we pass through the Dependency state anyway
after this patch, older osmo-bscs will work correctly too.

Change-Id: Id9e61f8d773e6e6170c68b5b836d276c747d8d69
2020-10-20 13:45:57 +00:00
Harald Welte 629824ac14 use osmo_fd_setup() everywhere
Change-Id: I9be55f791a15fae2362dc431dc778b9b9d8db349
2020-10-19 15:06:08 +00:00
Vadim Yanitskiy 64bd96b3f8 vty: make most struct pointers const in show/write commands
Change-Id: Iacc32f7982c150d84ea4df7affa1f9e07806928f
2020-09-28 11:39:04 +07:00
Pau Espin 666adf6a97 Improve logging around failing to (de)activate chan_nr
Change-Id: Ibc398eb5d50851cbe48f2c92f14e746938a68720
2020-09-16 19:28:38 +02:00
Vadim Yanitskiy c14f1641c6 Constify the 'trx' argument of trx_get_hlayer1() everywhere
Change-Id: I44523d26f2f564932ea95c17b1041d0ca9cc2828
2020-08-03 02:08:14 +07:00
Pau Espin 9b2641ff3d bts-virt: Don't rely on gsmtap_makemsg() returning NULL for GSMTAP_CHANNEL_UNKNOWN
commit d211c490ca avoided sending
GSMTAP packets on the virtual Um interface with type
GSMTAP_CHANNEL_UNKNOWN by relying on gsmtap_makemsg returning NULL.
But that's not the corect approach since it's totally fine to be sending
GSMTAP_CHANNEL_UNKNOWN on some GSMTAP cases (for instance when the
program fails to infer the type when decoding a message), since then
this way one can study pcap files and find the offending encoded
messages which failed to be decoded.

This patch goes togehter with revert patch introduced in libosmocore as
explained in the commit referred above.

Change-Id: I233afd930d3e43f7b120d40192c7c192102e38d9
2020-07-09 11:44:12 +00:00
Vadim Yanitskiy 2f18578dcc Use libosmocore's TDMA frame number API (constatns & arithmetic)
Depends: (libosmocore) Ic291fd3644f34964374227a191c7045d79d77e0d
Change-Id: I61c97a62bd5dbbb4a984921ebdfc10ad6ed00f2a
2020-06-25 18:02:10 +00:00
Pau Espin a08685a576 Fix shutdown in osmo-bts-{omldummy,virtual}
Change-Id: Idadb62ec25181b140d9061dc7470da00d47d8336
2020-06-25 14:12:34 +02:00
Pau Espin ab7f409bff bts-virtual: Implement bts_model_trx_close
Change-Id: Id37562652b1ebc27d808d83342e4961b936dbcad
2020-06-23 14:55:55 +02:00
Pau Espin 8090df2a81 bts_model: Convert bts_model_trx_close() to return asynchronously
Some backends like osmo-bts-trx require exchanging messages like
POWEROFF to close the TRX, and hence need some time. Switch the function
to expect result asynchronously by calling a callback.

This will be used later to wait until all TRX are really powered off
before exiting the process.

Change-Id: I7d76b600fc06e1114b35bf0c2d08eff5bbd1b69a
2020-06-23 14:53:37 +02:00
Vadim Yanitskiy ae781bc5cd osmo-bts-trx: introduce and use struct trx_dl_burst_req
This change is similar to what we did for Uplink bursts:

  - group all Downlink burst parameters into a single structure,
  - allocate it once and pass a pointer to lchan handlers,
  - pass a pointer to trx_if_send_burst().

Given that the structure is allocated and (zero-)initialized in
trx_sched_fn(), we can get rid of some memset() calls in lchan
handlers and thus improve the overall performance a bit.

Change-Id: If3014e69746559963569b77561dbf7b163c68ffa
2020-06-15 10:42:03 +00:00
Vadim Yanitskiy 578156b815 Do not mix public and private BTS features, use libosmocore's API
It was a very bad idea to mix "public" BTS features, that are
reported to the BSC via OML, and those features, that are used
locally (and exclusively) in osmo-bts.

Why? At least because we already have the BTS feature manipulation
API in libosmocore, that is used by osmo-bsc, but for some reason
not by osmo-bts. New features added to libosmocore would clash
with the existing "internal" ones like BTS_FEAT_MS_PWR_CTRL_DSP.

So what this change does can be described as follows:

  - remove duplicate definition of the "public" features,
  - use libosmocore's API for the "public" features,
  - separate both "internal" and "public" features:
    - the "public" features continue to live in bitvec,
    - the "internal" features become flags,
    - s/BTS_FEAT/BTS_INTERNAL_FLAG/g.

Change-Id: Icf792d02323bb73e3b8d46384c7890cb1eb4731e
2020-06-11 00:36:21 +07:00
Vadim Yanitskiy 4977e135c8 common/scheduler: use boolean for channel activation state
Change-Id: I0cb1d915db8787050cdec1802894f66e885a9bf3
2020-06-06 19:41:15 +00:00
Vadim Yanitskiy 031f925ccd osmo-bts-virtual: cosmetic: use LID_{SACCH,DEDIC} macros
Change-Id: Idd37ca9ebf0d483cbea6f0e992211b9c3e2af993
2020-06-06 03:14:24 +07:00
Harald Welte d211c490ca virtual/scheduler: log unknown GSMTAP chan
Related change in libosmocore will let gsmtap_makemsg return NULL if the
channel type is unknown: Ib4147a33a75c3cf425c30da8b0678c7fba8a371d

Related: SYS#4822
Change-Id: Ic22ab71e520ab44429a93724250d349d16250801
2020-05-20 12:55:08 +00:00
Pau Espin 63920cefa6 Use OSMO_FD_* instead of deprecated BSC_FD_*
New define is available since libosmocore 1.1.0, and we already require
1.3.0, so no need to update dependenices.
Let's change it to avoid people re-using old BSC_FD_READ symbol when
copy-pasting somewhere else.

Change-Id: Id51ccb2c273c5f0fa4986f28bbd69a72d2dbaa0e
2020-05-09 18:59:47 +02:00
Harald Welte 7b0da0650d osmo-bts-virtual: Avoid rejecting AMR in uplink
Change-Id: Ib527a9fe02c49f6129c376424480aa1004f9ee8f
2020-04-21 21:03:55 +00:00
Harald Welte e36fbca15f osmo-bts-virtual: Fix "virtual-um net-device NETDEV"
The VTY option to bind the virtual Um multicast to a specific
network interface has existed ever since osmo-bts-virtual was
first merged to the repo.   However, embarrassingly, until today
it never did anything, i.e. the code to actually perform the bind
was missing.

Depends: libosmocore.git Ib52d22710020b56965aefcef09bde8247ace4a9c
Change-Id: I303f2e616d2d32b5a8005c3dcf0f5fad19ad3445
Related: OS#2966
2020-03-10 21:36:00 +01:00
Harald Welte 5914d76d5c osmo-bts-virtual: Add "virtual-um ttl <0-255>" VTY option
This can be used to determine the multicast TTL packet and hence
how far the packet will propagate in the network.  If you want to
operate the virtual Um only on your own machine, a TTL of 0 would
prevent the packets from ever being transmitted on your local
ethernet segment.

Change-Id: I18a9f93b764aee4e1dc68a1c6ac4d078e52ca61d
Related: OS#2966
2020-03-10 21:35:56 +01:00
Harald Welte 58d79e88ad osmo-bts-virtual: 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.

Depends: libosmocore.git I952044a17334f35712e087dc41781805000aebc1
Change-Id: I1cd9a251ce0b87181a0822d7940bbfc9f1428543
2020-03-08 17:56:52 +01:00
Vadim Yanitskiy 3f35ab258d osmo-bts-virtual: do not log GSMTAP message sending failure twice
Change-Id: I39e9edf35240ef31e3432412b459c2b8fb0de054
2020-03-04 20:43:02 +07:00
Vadim Yanitskiy f9e7ccce27 osmo-bts-virtual: do not print redundant info in tx_to_virt_um()
LOGL1S() already prints enough context information.

Change-Id: I29adf9360b96544b7f58766d5cd26d97117884d9
2020-03-02 00:26:33 +07:00
Vadim Yanitskiy 2b948a3d17 osmo-bts-virtual: fix wrong endianness in gsmtap_hdr_stringify()
Change-Id: Ic9e84dc4adc44df735cba102bdace2fb1993ac8e
2020-02-29 18:09:46 +07:00
Harald Welte 24f98a0df9 virtual: Fix VTY commands to specify GSMTAP multicast groups
osmo-bts-virtual uses GSMTAP over multicast groups to communicate
with one or more virtphy instances.  There are some well-known default
multicast groups, but those can also be overridden via the VTY.

The problem is: If you actually try that, osmo-bts-virtual will abort,
as we try to talloc_free() when using osmo_talloc_replace_string()
on the constant default string.

The proper solution is to talloc_strdup() the constant default string
when setting the default value in bts_model_phy_link_set_defaults().

Change-Id: Ia96fea891a22e5a3c47ce658eda130ba8d4fc411
2020-02-26 14:36:58 +01:00
Pau Espin e717aec2f7 Move and rename gsm_lchan.ms_power field
Make it clear that it contains the maximum MS power level (TS 05.05) and
not the one to be used. The one aimed at is in ms_power_ctrl.current.
Since it's used in related code, move it inside the ms_power_ctrl struct
too.

Related: OS#1851
Change-Id: Ib264ec7dac87355cef6415461ed74bd8e9c8ca52
2019-11-14 16:36:00 +01:00
Martin Hauke b378fccef1 Fix common misspellings and typos
Change-Id: I403b9029f57fec3fdec2c1e2cbeac0f6eab53f24
2019-10-17 08:05:35 +00:00
Pau Espin 972c243146 struct gsm_bts: Add model_priv pointer handing bts_model specific data
Currently there's bts-virtual specific fields in gsm_bts which is not used
by other models and are always allocated.
An alternative would be having a union with different structs inside,
one per model, but since we already have the bts_model abstraction, in this
case it makes more sense to use that abstraction instead of filling code
with preprocessor ifdefs to guard against non-defined types, etc.

Existing model specific data is moved there.

This new infra will be user further in forthcoming commits.

Related: OS#4215
Change-Id: Ib17a752cdbaa7d5eb8c5dfa0b197f80a4f38b38e
2019-10-05 20:50:13 +00:00
Oliver Smith fc917d91bf virtual: set link quality for GSMTAP_CHANNEL_RACH
Don't ignore all incoming RACH requests anymore:
000881/00/23/14/09 Ignoring RACH request: link quality (0) below the minimum (50)

Related: OS#3925
Fixes: b777c0f3ec ("Move Access Burst link quality handling to L1SAP")
Change-Id: Ifcd576fed84346688e711a26a05c6d350588e83d
2019-08-23 12:34:48 +02:00
Oliver Smith 258856b329 Cosmetic: virtual: l1sap.c: fix typos
Change-Id: Id24e75812bda17e99f17a37b367462533a5607f9
2019-08-23 11:58:19 +02:00
Vadim Yanitskiy 01cc8c0d21 osmo-bts-trx/scheduler: pass trx_ul_burst_ind to lchan handlers
This change needs to be done in order avoid adding more and more
arguments to the UL logical channel handlers (such as rx_rach_fn).

Since we have different versions of the TRXD header, and may have
other burst-based PHYs in the future, some fields of an Uplink
burst indication have conditional presence.

Change-Id: Iae6b78bafa4b86d0c681684de47320d641d3f7c0
Related: OS#4006, OS#1855
2019-07-16 04:16:13 +00:00
Pau Espin e3cb8715f5 bts_model: Allow TS connect to be processed asynchronously
This commit doesn't change internal logic of any model, only the API to
be able to return result of connect TS asyncrhonously since some models
(like osmo-bts-trx) require some time to process the result. This way
PDCH ACT/DEACT (N)ACK can be sent once the result of this long process
is known. For instance, nowadays in osmo-bts-trx we PDCH (DE)ACT ACK
before getting the result from SETSLOT on the TRX iface.

With this new API, bts_model_ts_connect doesn't return any value
synchronously. Instead, it is expected to always end up calling
cb_ts_connected with the return code from the TS activation process. 0
is considered a successs, while any other value is considered an error.

Change-Id: Ie073a4397dd2f1a691968d12b15b8b42f1e1b0cf
2018-11-26 14:08:14 +01:00
Pau Espin eebb6a4216 bts: Allocate TRX for BTS dynamically, deprecate -t
No need to pass -t num_trx anymore to specify number of TRX to use. It
is calculated based on dynamic allocation from VTY config.
Using parameter -t is flagged as deprecated and is transformed into a
NOOP por backward compatibility.

As a result, TRX now are allocated after the BTS is allocated and
initial config (pre-VTY) is applied.
A new function bts_trx_init() is added, to set default config on each
TRX during allocation and before setting VTY config on it.
A new per BTS model function bts_model_trx_init() is added, to allow
per model specific default configuration of each TRX.

Change-Id: Iab1a754ab12a626759f9f90aa66f87bdce65ac9c
2018-11-18 20:29:40 +00:00
Stefan Sperling e5f4654ee3 prevent potential NULL dereference in virtbts's tx_tchh_fn
If chan_state->ongoing_facch is set, this code's logic
suggests that both msg_facch and msg_tch could be NULL.
Don't dereference msg_tch unconditionally.

Change-Id: Icf5584396c5b925d55ca9380dd4f869ae5d72da3
Related: CID#172047
2018-11-06 15:51:05 +01:00
Harald Welte 3ee09a47c1 sysmo, virtual: properly handle BS-AG-BLKS-RES as received from BSC
Change-Id: Ifd9a3be6189b3288526e12260d68a982b089404e
2018-09-30 15:50:01 +02:00
Harald Welte 173555dab7 Fix computing CCCH block number from frame number
The existing implementation used a simplistic macro, which was wrong
in many ways:

1) it returned a negative value for "fn % 51 < 5" conditions without
   raising any error message or asserting
2) it returned a wrong block number for many different input frame
   numbers, as it didn't account properly for the FCCH/SCH gaps between
   the blocks

Let's replace the simplistic macro with a proper lookup table based on
TS 05.02, and let's OSMO_ASSERT() if this is ever called with non-CCCH
frame numbers.

Change-Id: I11fd6cc558bb61c40c2019e46f56c1fe78ef39f5
Closes: OS#3024
2018-09-30 15:50:01 +02:00
Harald Welte d9a1cd994c CBCH: Implement CBCH support for osmo-bts-{trx,virtual}
This patch adds scheduler support for the channel combinations that
substitute SDCCH index 2 for a CBCH in either a SDCCH/8 or SDCCH/4.

Change-Id: Icc15603079a1709ec094f400a9bcf0008211890f
Closes: OS#1617
2018-09-09 15:40:58 +00:00
Philipp Maier 0e11bea2a7 osmo_mcast_sock: make sure SO_REUSEADDR is applied
osmo-bts-virtual uses UDP multicast to communicate with its virtphy
counterpart. At the momemnt SO_REUSEADDR is not applied for those
multicast connections because OSMO_SOCK_F_UDP_REUSEADDR is not set. This
makes prevents the proper function of UDP multicast.

- Make sure OSMO_SOCK_F_UDP_REUSEADDR is set

Change-Id: I7f27758b7aa786c8dbae669cbcde10baab8e4845
Depends: libosmocore I1399a428467ca12f1564a14eb8ffb294d4f59874
Related: OS#3497
2018-08-23 20:30:05 +02:00
Vadim Yanitskiy 5d17b97a5b Clarify frame loss counter for l1sched_chan_state
Each logical channel (e.g. SACCH, SDCCH, etc.) has a counter of
lost L2 frames. Let's use a bit better name for it, and correct
its description in the 'l1sched_chan_state' struct definition.

Change-Id: I92ef95f6b3f647170cfd434a970701406b0a7c82
2018-08-01 02:35:07 +07:00
Pau Espin 500b7945f0 Remove unneeded direct libortp dependency
All code in osmo-bts goes through APIs in libosmotrau (osmo_ortp.h),
hence direct dependency is not needed. Fixes OBS warnings:

dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/osmo-bts-trx/usr/bin/osmo-bts-trx was not linked against libortp.so.9 (it uses none of the library's symbols)
dpkg-shlibdeps: warning: package could avoid a useless dependency if debian/osmo-bts-virtual/usr/bin/osmo-bts-omldummy debian/osmo-bts-virtual/usr/bin/osmo-bts-virtual were not linked against libortp.so.9 (they use none of the library's symbols)

Change-Id: I96a9b5f0678331dcf66c007928866a124d8700de
2018-07-02 16:36:14 +02:00
Harald Welte 6d0c67684c virtual: Correctly set+report BTS variant in OML attributes
Change-Id: I76dc47427ec26834859fb737bd319dc379ae8697
2018-03-17 15:14:01 +01:00
Harald Welte d8cd756da4 Get rid of 'struct gsm_bts_role_bts'
gsm_bts_role_bts was introduced at a time when we still shared
gsm_data_shared.[ch] between BSC and BTS, and where we then subsequently
needed a BTS-private structure.  Since that sharing was abandoned quite
some time ago, we can merge gsm_bts_role_bts into gsm_bts and do away
with the bts/btsb dualism in a lot of the code.

Change-Id: I4fdd601ea873d9697f89a748cc77bcf7c978fa3e
2018-03-17 13:40:03 +01:00
Harald Welte acefd0586e L1SAP: Increase resolution of reported burst timing
Before this patch we had:
* osmo-bts-trx internally using 1/256th bit/symbol period
* osmo-bts-sysmo internally using 1/4 bit/smbol period
* PCU interface using 1/4
* L1SAP interface using 1/4
* measurement processing code on top of L1SAP using 1/256

So for sysmo/lc15/octphy we are not loosing resolution, but for
osmo-bts-trx we're arbitrarily reducing the resolution via L1SAP
only then to compute with higher resolution again.

Let's change L1SAP to use 1/256 bits and hence not loose any resolution.
This requires a corresponding change in libosmocore for l1sap.h, which
is found in Change-Id Ibb58113c2819fe2d6d23ecbcfb8b3fce4055025d

Change-Id: If9b0f617845ba6c4aa47969f521734388197c9a7
2018-02-27 20:00:16 +01:00
Harald Welte d5bbd8ccf7 trx/scheduler: Use integer math for TOA (Timing of Arrival)
There's no need to express TOA as a float:
* We receive it as signed 16bit integer in units 1/256 symbol periods
* We pass it to L1SAP as signed integer in 1/4 symbol periods

So 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.

Change-Id: Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec
2018-02-27 19:58:20 +01:00