Commit Graph

161 Commits

Author SHA1 Message Date
Pau Espin 9c2512a638 pdch is_enabled: Use API getter instead of accessing field directly
Change-Id: I389f42ef2e95d28643ec51771e46d083d4e20057
2022-04-05 10:43:39 +00:00
Pau Espin 2d92e3937f Fix assert hit if connecting to SGSN fails
"""
DLBSSGP ERROR gprs_bssgp_pcu.c:1278 Failed to connect!
DL1IF ERROR pcu_l1_if.cpp:827 No NSVC available to connect to the SGSN!
DRLCMAC INFO pdch.cpp:185 PDCH(bts=0,trx=0,ts=0) PDCH state: disabled => disabled
Assert failed m_is_enabled == 1 pdch.cpp:186
"""

Change-Id: I36dc64fa807091bf2b565417c1185c4cb399932b
2022-03-30 22:09:12 +02:00
Oliver Smith 8d03c50024 treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I4a49dbeeec89b22624c968152118aecf8886dac6
2021-12-14 12:19:13 +01:00
Pau Espin fef3da24ae pcuif: Submit data_req with len=0 as idle frames
This way PCU always answers DATA.ind and the BTS can still clearly
identify idle frames. It also simplifies testing and verification of
correct behavior.

Related: SYS#4919
Change-Id: Ife718eeed2af011479c03099ea109518f04567bc
2021-10-20 13:35:10 +00:00
Pau Espin eeae776345 PTCCH: skip Tx DL idle blocks when possible
Same was already done for PDTCH in previous commits. Let's now apply
same bits to PTCCH.

Related: SYS#4919
Change-Id: If6617964e67fc35eeee1791b06e13bf63ac88f73
2021-09-20 11:22:32 +02:00
Pau Espin 5557c0af80 Support Neighbor Address Resolution over PCUIF IPA multiplex
While NACC was initially developed, it became clear there was need for
a way to interact PCU<->BSC in order resolve ARFCN+BSIC into CGI-PS
for later RIM usage.
Hence, this resolution was first (until today) implemented using an out
of bands RPC system using the CTRL interface, which required specific
config to be written and matches in osmo-pcu and osmo-bsc VTY (ip+port
of the CTRL interface to use).
However, this has several shortcomings:
* As explained above, specific configuration is required
* Since recently, we do support BSC redundancy in osmo-bts. Hence the BTS
  may switch to a BSC other than first one. If that happened, that'd mean
  the CTRL interface would still point to the initially configured one,
  which may not be the same currently serving the PCU.

During recent development of ANR related features, a similar need for
PCU<->BSC was required, but this time it was decided to extend the IPA
multiplex of the Abis OML connection to pass PCUIF messages,
transparently forwarded to each side by the BTS.
This has the advantage that connection PCU<->BTS is handled by BTS and
both sides send messages transparently.

Let's switch by default to using this new interface, while still
maintaing the old way for a while (announcing them as deprecated) to
avoid breaking existing deployments until they are upgraded to new
versions of osmo-pcu and osmo-bsc.

Related: SYS#4971
Change-Id: I6ad33c7ab10202840cf804dea9ba595978d0e920
2021-09-13 13:31:06 +02:00
Pau Espin 3bbb3cc1f2 Fix crash with dyn TS when using direct pcu
It seems there may be a race conditon where lower layers (direct PCU)
send UL blocks to us while the PDCH was already disabled (due to a call
entering on a dynamic TS).
As the PDCH is disabled, the ULC is NULL and shouldn't be used before
being enabled again.

Related: OS#5222
Change-Id: I4b8931f0cc7cfc787a1cc35196295402524b15c3
2021-08-31 14:36:02 +02:00
Pau Espin 4f67a9bf46 pdch: Fix heap-use-after-free in pdch->ulc
In existing previous code, pdch->ulc would be freed in
gprs_rlcmac_pdch::free_resources() when  it became disabled as per PCUIF
info_ind (for instance, when a DYN TS is switched PDCH->SDCCH8).
However, pdch->ulc was so far only allocated during pdch_init, which is
only called during bts_alloc() time.
Hence, after first info_ind disabling it, if it became again enabled
(again by info_ind re-enabling it after SDCCH8 was not longer in use),
the pdch->ulc would be used again but it would point to freed memory.

Let's rearrange how/when resources are freed to make it more logical.
With this patch, pdch internal resources are freed upon ->disable(), and
re-allocated upon ->enable().

Change-Id: Id51f5f6a54ac9f24b784c17bc360ac38f5726fc7
2021-07-01 13:09:10 +02:00
Pau Espin 1989a19066 Support proto IPAC_PROTO_EXT_PCU BSC<->PCU
Related: SYS#5303
Change-Id: I633db291107883c2e370a9b56606d562a990b714
2021-06-25 17:20:50 +02:00
Vadim Yanitskiy b657213773 pcu_l1_if: ignore PDCH interference reports, do not log errors
Change-Id: I88e5c53131ee94bc3f3ff3f095077feb4ff272a7
Related: SYS#5313, OS#1569
2021-06-22 05:58:23 +00:00
Pau Espin 86f4c093d1 pcuif: Support receiving System Information 2
OsmoPCU will need this SI2 in order to gain knowledge of the BCCH
Frequency List being broadcasted, in order to build a per-MS specific
Neighbour List using NC_FREQUENCY_LIST bits in Packet Measurement Order.

Related: SYS#5303
Change-Id: I4a9c4f70beac6805322a19835a0d30f7247780b4
2021-06-15 19:11:07 +02:00
Pau Espin d65bd9d7b2 bts: Fix typo in field name
Change-Id: I5426ff4ccbc45464888e2246cceb8e861d1e477e
2021-06-01 16:43:41 +02:00
Pau Espin bd54205475 Optimize PAGING-CS PDCH set selection when target MS is known
Before this patch, when a PAGING-GS was received in PCU from SGSN, it
would always forward the paging request to all PDCHs in all TRXs of all
BTS (well, it did some heuristics to avoid sending it in some PDCHs
where onyl repeated TBFs would be listening).

The previous behavior, didn't make much sense in the case where the PCU
is asked to page an MS which it knows (ie in which PDCHs is listening
to). Hence, in that case it makes sense to simply send the paging
request on 1 PDCH where the MS is listening, instead of sending it in a
big set of different PDCHs.

This commit also splits the old get_paging_mi() helper which was
erroneously created to parseboth CS/PS-PAGING requesst, since they
actually use a different set of target subscriber information (for
instance, CS-PAGING provides optionally a TLLI, and one provides P-TMSI
while the other provides TMSI).

In this patch, the handling of CS paging request is split into 2 parts:
1- A new helper "struct paging_req_cs" is introduced, where incoming
CS-PAGING requests (from both SGSN over BSSGP and BTS/BSC over PCUIF)
are parsed and information stored. Then, from available information, it
tries to find a target MS if avaialable
2- bts_add_paging() is called from both BSSGP and PCUIF paths with the
helper struct and the target MS (NULL if not found). If MS exists,
paging is forwarding only on 1 PDCH that MS is attached to. If no MS
exists, then the old heursitics are used to forward the request to all
MS.

Change-Id: Iea46d5321a29d800813b1aa2bf4ce175ce45e2cf
2021-05-19 12:46:00 +02:00
Pau Espin fecab50066 sysmo: fix wrong FN jumps in rx RA.ind
There's no need for setting the FN in RA.ind since we anyway already
receive a DATA.ind beforehand.
Furthermore, the applied delay of 5 in the call is not really used at
all.

Change-Id: I437f4f95d054aea96bec3b9343e495451020ff3c
2021-03-17 15:58:16 +01:00
Pau Espin 15c58ace75 Add new PDCH UL Controller, drop SBAllocator class
Right now we handle different types of UL allocations in different
classes like PollAllocator and SBAllocator, and they usually don't take
into account the other one in most cases. Furthermore, those objects are
usually per-BTS object, instead of per PDCH object.

This is a first step towards having a unified per-PDCH controller which
takes care of controlling what is scheduled and hence expected on the
uplink. Each PDCH has a UL Controller which keeps track of all reserved
uplink frame, be it SB, RRBP poll or USF assigned, all under the same
API.

As a first step, only the SBA part is fully implemented and used (being
it the easiest part to replace); TBF poll+usf will come in follow-up
patches later on. As a result, the SBAllocator per-BTS class dissappears
but some of its code is refactored/reused to provide more features to the
gprs_rlcmac_sba object, which is also further integrated into the new UL
Controller.

Related: OS#5020
Change-Id: I84b24beea4a1aa2c1528f41435f77bd16df2b947
2021-03-15 19:32:26 +01:00
Pau Espin df58ddf6d8 Improve logging in DATA.req and ACT.req
Change-Id: Id57d50d8bf528adfef3713c594102d31ab49c149
2021-03-12 07:40:11 +00:00
Pau Espin c1f31c46ac Improve DATA.ind logging
pdch object is obtained prior in the stack so it is available for
logging.

Change-Id: If51f7bdbd626a44c7b8e182a3460dad49fda6ec3
2021-03-12 07:40:11 +00:00
Pau Espin 30617115ba Track TDMA clock with DATA.ind instead of TIME.ind
Since recently (see Depends below), BTS side submits DATA.ind with len=0
to announce nothing was received on that UL block FN. This will allow
osmo-pcu track time more accurately, and use this information to quickly
find out if a UL block was expected as requested by RRBP or USF poll and
increment counters such as N3101 (finally being able to properly
implement timers such as T3619).

Depends: osmo-bts.git Change-Id I343c7a721dab72411edbca816c8864926bc329fb
Related: OS#5020

Change-Id: Ibc495173119465e74f726ddc36e312334e6dc0fd
2021-03-12 07:40:11 +00:00
Pau Espin Pedrol fe8de457ac Use ALPHA value received in SI13 from PCUIF
The old VTY command is marked as deprecated and still overrides the use
in case it's used.

Related: SYS#5358
Depends: libosmocore.git Change-Id I74fb0a3afc1ac4aadbfc609b882d929401f790eb
Depends: osmo-bsc.git Change-Id I8b97ea11bad5fe05f2f634945b5703ee9abde81d
Change-Id: I46f2a955b157a409055fca7fb917dc4f75482426
2021-02-22 12:29:12 +00:00
Alexander Couzens 94a367f224 gprs_bssgp: rename gprs_ns_config -> gprs_ns_update_config
Improve the naming of the function to match it's purpose.

Related: SYS#5354
Change-Id: Ib8e4ae734503fd6f6695d9d6767d809e1bf79d22
2021-02-16 21:32:47 +00:00
Philipp Maier a58ec61514 gprs_bssgp_rim: add serving BSS NACC application
Answer an incoming RAN INFORMATION REQUEST RIM PDU with RAN INFORMATION
PDU that contains system information type 1, 3 and 13

Depends: osmo-bts I5138ab183793e7eee4dc494318d984e9f1f56932
Change-Id: Id72118120c14984d2fb1b918b41fac4868150d41
Related: SYS#5103
2021-02-02 21:57:09 +01:00
Pau Espin db5e339da4 Get rid of singleton gprs_bssgp_pcu_current_bctx()
Access it from existing pointers instead.

Change-Id: I77455da5221090ebea142ecd49d5dba0065bfc5c
2021-01-21 18:02:57 +01:00
Pau Espin 2e6b60df45 bts: Store RAC+CI from info_ind
Having those values at hand will be needed later for RIM / NACC related
purposes.

Change-Id: Ia3596e9e81cd71443be2cc6f2450bb7f91d2667d
2021-01-20 15:00:38 +01:00
Pau Espin d1049dc8cc Allow multiple bts objects in PCU
This patch doesn't really tests whether osmo-pcu can work on a multi-bts
environment, but it prepares the data structures to be able to do so at
any later point in time.

Change-Id: I6b10913f46c19d438c4e250a436a7446694b725a
2021-01-20 12:36:21 +01:00
Pau Espin 4a5209d8bc Get rid of unused gsm_timer.{cpp,h}
Those files are not really being used other than for calling
get_current_fn() which is just a placeholder to call
bts_current_frame_number on the global bts object.

Change-Id: I6d50a8c15c1de5e2a308a24b313a7776f94ae54f
2021-01-19 16:28:13 +01:00
Pau Espin 0ece97d718 Rename 'bts_data' leftovers to 'bts'
Before, we used tho have a BTs object split into 2 parts, a C
gprs_rlcmac_bts struct and a C++ BTS struct, and "bts_data" naming was
used to distinguish them in variable names. Nowadays the struct is
finally combined into one, so there's no point in using this "bts_data"
terminology, we use always "bts".

Change-Id: I9852bf439292d1abc70711bea65698b21bde0ee8
2021-01-19 16:28:13 +01:00
Pau Espin a45aafd39c Get rid of bts singletons
There's no BTS single global object anymore, get rid of those APIs. Move
users to use "pcu->bts", which will evolve to a linked list in the
future.

Change-Id: I9cf762b0d3cb9e2cc3582727e07fa82c8e183ec5
2021-01-19 16:28:13 +01:00
Pau Espin 2182e627cd Unify BTS into a C usable structure
Previous work on BTS class started to get stuff out of the C++ struct
 into a C struct (BTS -> struct gprs_glcmac_bts) so that some parts of
it were accessible from C code. Doing so, however, ended up being messy
too, since all code needs to be switching from one object to another,
which actually refer to the same logical component.

Let's instead rejoin the structures and make sure the struct is
accessible and usable from both C and C++ code by rewriting all methods
to be C compatible and converting 3 allocated suboject as pointers.
This way BTS can internally still use those C++ objects while providing
a clean APi to both C and C++ code.

Change-Id: I7d12c896c5ded659ca9d3bff4cf3a3fc857db9dd
2021-01-19 16:28:10 +01:00
Pau Espin 793583ea21 Fix configuration mess of initial_cs/mcs between PCUIF and VTY
Both values (optionally) set (forced) by VTY and the values received
from PCUIF were stored in the same variable, meaning that for instance
the PCUIF values wouldn't really be used if someone applied eg "no cs"
during runtime.

This commit does something similar to what was already done for the
max_(m)cs fields. We store PCUIF values in one place and VTY ones in
another place, and then trigger a bts object internal process to find
out exactly which initial CS should it be using.

Change-Id: I80a6ba401f9c0c85bdf6e0cc99a9d2008d31e1b0
2021-01-18 11:57:14 +01:00
Pau Espin ac3fd12026 Split PCU global PCU object from BTS object
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold
both PCU global fields and BTS specific fields, all mangled together.
The BTS is even accessed in lots of places by means of a singleton.

This patch introduces a new struct gprs_pcu object aimed at holding all
global state, and several fields are already moved from BTS to it. The
new object can be accessed as global variable "the_pcu", reusing and
including an already exisitng "the_pcu" global variable only used for
bssgp related purposes so far.

This is only a first step towards having a complete split global pcu and
BTS, some fields are still kept in BTS and will be moved over follow-up
smaller patches in the future (since this patch is already quite big).
So far, the code still only supports one BTS, which can be accessed
using the_pcu->bts. In the future that field will be replaced with a
list, and the BTS singletons will be removed.

The cur_fn output changes in TbfTest are actually a side effect fix,
since the singleton main_bts() now points internally to the_pcu->bts,
hence the same we allocate and assign in the test. Beforehand, "the_bts"
was allocated in the stack while main_bts() still returned an unrelated
singleton BTS object instance.

Related: OS#4935
Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-18 10:37:05 +00:00
Pau Espin 54faf023be Workaround ASan false positive runtime errors under some platforms
Under some platforms (RPI4, ARM) container older ASan, it will log false
positive log errors which will make unit test fail because then output
changes:
"""
pcu_l1_if.cpp:847:2: runtime error: member access within misaligned address 0xb3f0b78c for type 'struct GprsMs', which requires 8 byte alignment
"""

The pointer is indeed misaligned, but it's not actually a bug, because
the pointer is never derreferenced. That happens during
llist_for_each_entry operation where it does cast the pointer but it
only checks if the list has actually reached the end.

To workaround the issue, simply defer casting it by using llist_for_each
instead, where the pointer is assigned only in the case it really points
to a GprsMS struct.

Change-Id: I149fb42706501eb33f9c6fe48f76a03ddee5954a
2021-01-14 12:12:45 +01:00
Pau Espin Pedrol da971ee502 Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).

GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.

Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.

For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.

Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2021-01-05 10:34:25 +00:00
Pau Espin b47b137c66 Fix configuration of initial_(m)cs
Properly clip initial_(m)cs values to be lower-equal than maximum
configured.

Regarding initial_mcs, use values provided by BTS, which were not used
before.

Change-Id: Ifc6bc7c2734d1ae404adc2497afec5366e4f9e50
2020-11-04 21:39:43 +01:00
Pau Espin 87eec1fd74 Get rid of bts->egprs_enabled
BTS simply notifies the PCU about the supported MCS, and PCU is
responsible for providing correct data formatting supported for the BTS
and the target MS.

Related: OS#4544
Change-Id: Ifcf23771bd23afc64ca6fea38948f98f2d134ecb
2020-11-04 21:39:43 +01:00
Pau Espin 270c9ea5d9 Enable egprs support through PCUIF from BTS/BSC
This VTY command was added due to EGPRS being introduced later as an
experimental feature. It's no longer needed and causes more problems
than goodness (since people sometimes forgets to enable it).

Let's rather simply enable EGPRS support based on what BTS/BSC requests
over PCUIF.

Related: OS#4544
Change-Id: Ic80970a136361584da9c912252a07e7c3c9d85d0
2020-11-04 21:39:42 +01:00
Pau Espin 343ec9b9fd Take into account BTS supported (M)CS values when retrieving the maximum
Change-Id: I2d3a8bbae2f9887400ce56d2f8303ea30abaecfa
2020-11-04 21:39:42 +01:00
Pau Espin d87722d03c pcuif: Improve BTS-supported CS/MCS handling
Take into account the MCS values supported by the BTS. In osmo-bts,
in general all MCS are enabled if "mode egprs" is selected in BSC,
and none otherwise.

Change-Id: Ie8f0215ba17da1e545e98bec9325c02f1e8efaea
2020-11-04 21:39:42 +01:00
Alexander Couzens 87c6dd3c26 pcu_l1_if: fix misaligned assignment of remote address
Found-by: asan
Change-Id: I9c87d3fc1b6f03d79b53f1da3a146630061c3459
2020-10-27 15:29:05 +00:00
Alexander Couzens 5bece2a0ed Rework NS configuration over the info indication
Add support of the second NSVC in the info indication.
Add support to update a previous NS configuration.
Allow to update of a NS-VC while the NSE is still available over the
second.

Depends-on: I917f25ebd1239eae5855d973ced15b93731e33a0 (libosmocore)
Depends-on: I3a0cd305fd73b3cb9ec70246ec15ac70b83e57f2 (libosmocore)
Depends-on: I5a2bb95d05d06d909347e2fb084a446ead888cb3 (libosmocore)
Depends-on: I54f110acc3acccb362f6e554324d08cc42b7c328 (libosmocore)
Depends-on: Ia00753a64b7622a0864341f51ea49b6963543755 (libosmocore)
Depends-on: Ic8f6f8aca10da23a18fab8870be7806065a34b47 (libosmocore)
Depends-on: I5f67e6a9bf4cb322bd169061fee0a528012ed54d (libosmocore)
Change-Id: I589ebaa2a2b7de55b7e4e975d8fd6412dd5f214b
2020-10-13 08:45:30 +00:00
Vadim Yanitskiy 781f04a8f8 pcu_l1_if: print NSVC address in more common format
Change-Id: I5aac1b0624d127ef92a7b9c791f6b409e9e6055a
2020-10-09 20:54:03 +07:00
Vadim Yanitskiy 24c643e143 pcu_l1_if: use proper format string specifiers: %d -> %u
Change-Id: Ieb81dcb4096acbc7a308d003c9e653800071e149
2020-10-09 20:34:21 +07:00
Vadim Yanitskiy 19622aee5b pcu_l1_if: cosmetic: make {local,remote}_sockaddr scoped variables
Change-Id: Ib5ddf3622226ac9c612a03ca32d373bcc9b208cf
2020-10-09 20:03:16 +07:00
Vadim Yanitskiy c1a726c573 pcu_l1_if: correct logging level in pcu_rx_info_ind()
Change-Id: Ib4bb9b907fc2bf279cf22a3bb9b95ea1a0fb3db6
2020-10-08 23:03:39 +07:00
Vadim Yanitskiy 5d5b50aaf3 pcu_l1_if: cosmetic: use ARRAY_SIZE() in pcu_rx_info_ind()
Change-Id: Iff11c854b1687f75c1125a5bcd616da95ade69ee
2020-10-08 23:03:36 +07:00
Alexander Couzens 290d9030e9 Use the new NS2 lib
Depends: Id7edb8feb96436ba170383fc62d43ceb16955d53 (libosmocore)
Depends: I2a9dcd14f4ad16211c0f6d98812ad4a13e910c2a (libosmocore)
Change-Id: Ib389925cf5c9f18951af6242c31ea70476218e9a
2020-10-06 16:38:38 +02:00
Pau Espin bd9973a64f Free all MS TBFs when receiving GPRS Suspension Request
Otherwise the TBFs are kept, and hence PCU will continue reserving resources and
DL data queued will still be sent over the air, despite the MS not
listening anymore on the PDCH.

Change-Id: I4ae1c3706b2ed6e4d271cd16f7cd7f8937b84836
2020-09-22 20:46:15 +02:00
Alexander Couzens 9b5c960f55 pcuif_proto: version 10: add support for IPv6 NSVCs
Introduce a address_type in the NSVC configuration pass the given
protocol.  The remote_ip is network byte order, the default
encoding for in_addr and in6_addr.

Change-Id: Ia0852f9f4395f1248b39363ef90f6f5673b24e2f
Related: SYS#4915
2020-09-22 00:49:28 +07:00
Vadim Yanitskiy 8e2bd1e79d pcuif_proto: version 10: add frequency hopping parameters
Change-Id: I6863830883d90954006a7126c22d348aa2a83271
Related: SYS#4868, OS#4547
2020-09-22 00:49:11 +07:00
Alexander Couzens 40a9e603b9 Revert "pcuif_proto: version 0xa: add support for IPv6 NSVCs"
This reverts commit 38aaa10ed4.
It was to early because the frequency hopping wasn't ready to be merged.

Change-Id: Ibf055d5adfd9bffaaf51cb8468c79be597467e0f
2020-09-16 03:24:55 +02:00
Alexander Couzens 38aaa10ed4 pcuif_proto: version 0xa: add support for IPv6 NSVCs
Introduce a address_type in the NSVC configuration pass the given
protocol.
The remote_ip is network byte order, the default encoding for in_addr and in6_addr.

Change-Id: If26958d5b584973dca79159cf9e7f3f266519ce9
2020-09-15 22:21:43 +02:00