Commit Graph

381 Commits

Author SHA1 Message Date
Pau Espin 90e33bffd6 cosmetic: Document foce_two_phase feature based on specs
Change-Id: I4f8e3d0dcb721d51838b50aba5b40d0551c8d0c5
2023-07-28 18:03:30 +02:00
Pau Espin ed94d4cbfa Store T3192 value received from SI13, do some sanity checks
Timer T3192 may be used in the future to know wheter a DL TBF assignment
can be sent on PACCH after the last DL TBF has finished (final ACK).

Change-Id: Ie5f6251ee773f56771f9a9507711a20e6282aac6
2023-06-20 09:27:10 +00:00
Pau Espin ac1495e7be bts: Use same default value for T3193 as set in osmo-bts/bsc
That timer is configured by value sent over PCUIF, hence better have it
to the same default value in osmo-bsc/osmo-bts.

Change-Id: I498f05ff4d232164690d177430e90eb99b4eea9d
2023-06-20 09:27:10 +00:00
Pau Espin 84011ef86a Improve logging in bts_snd_dl_ass()
Change macro to LOGPTBFDL since it's assigning a DL TBF. Clarify and
join log lines.

Change-Id: Ic5e01289f97bc113ba0a376a535e0cce5bccc5d1
2023-06-12 18:05:42 +02:00
Pau Espin 7a4428c3ad Abort UL TBF PACCH Ass based on T3168
It makes no sense to continue trying to assign the UL TBF over PACCH
after T3168 * 4 retrans time out.

This helps in releasing the TBF after we got rid of incorrect use of
N3015 in UL TBFs.

While at it, update tbf_ul_fsm to use T3168 instead of X2001, since it
really needs to match T3168. Ideally it would not even have a timer
itself and receive an event from tbf_ul_ass_fsm, but that's left as a
TODO (it was already before) and simply the timer is updated.

Change-Id: I87dff68dedd06b60501e7586d20faf02bb1f0c93
2023-06-12 16:24:10 +02:00
Pau Espin ab571af3f2 Use OSMO_UNLIKELY() in bts_rfn_to_fn()
That case should only happen under really rare conditions, like
receiving a RACH.ind before having received any DATA.ind.

Change-Id: I4c71f3481764b501a4441bc735a87725884a3e75
2023-06-02 14:37:05 +02:00
Pau Espin fe8f4a4c87 Derive FN from RFN once and cache it in struct rach_ind_params
Change-Id: Iaefb9650dfc5083360a4a24b9c17fdbf3115e51f
2023-06-02 14:37:05 +02:00
Pau Espin bd461e62b5 encoding: pass RFN to write_immediate_assignment(_reject)()
Those function don't really require the full FN, hence let's pass only
the required information.
This makes the implementation here less dependent on how/if we are able to calculate
full FNs based on RFN: We get an RFN, and we have to encode so that the RFN can be
derived again, so feels less cumbersome having to go through RFN->FN->RFN which may
only cause possible issues if there's some FN timing bug.

3GPP TS 44.018 10.5.2.30 Request Reference:
"The purpose of the Request Reference information element is to provide the random
access information used in the channel request and the frame number, FN modulo 42432"

3GPP TS 44.018 10.5.2.38 Starting Time:
"The purpose of the Starting Time information element is to provide the start TDMA
frame number, FN modulo 42432."

Change-Id: If9b758434c00f2a3868534d5be84946809c989a9
2023-06-02 14:36:57 +02:00
Pau Espin 636d7fdb72 bts: use RFN directly to calculate fn416
RFN_MODULUS (42432) used to calculate is a multiple of 416:
416 * 102 = 42432

Hence, (X % 42432) % 416 == X % 416.
So, there's no need to derive the full FN.

Change-Id: If7a6a15c373a068bcc757d27937dd6eeac2e0bae
2023-05-31 20:51:26 +02:00
Pau Espin f09056de46 Error trying to obtain FN from RFN if curr_fn not known
This may happen if a RACH.ind is received before any DATA.ind has been
received.
With usual osmo-bts-trx or osmo-bts-sysmo, this shouldn't happen
nowadays, but it is still a problem with osmo-bts-virtual, where lower
layers don't submit NOPE.ind in the absence of data, and hence it won't
sent DATA.ind to osmo-pcu all the time.

This change helps in showcasing confusing scenarios where the RFN
generated in the Imm Ass was wrong.

Change-Id: I29b7ba828fe890f90e35686bbb04d4abfe56b955
2023-05-31 20:49:56 +02:00
Pau Espin 33cb3d6175 Use always RFN when handling RACH indications
The previous code was really confusing, passing full FNs as RFNs under
certain external conditions, and then assuming the RFN input of
rfn_to_fn() function could actually be a FN.

As a result, we had a lot of code behaving slightly different depending
on whether the incomding FN from pcuif was filled in by a BSC or a BTS.
Avoid this b ehavior differentiation and always assume the most
restricted one, aka RFN.

Change-Id: Ib3b5702168195b595711cd0ff32c211b9aba429d
2023-05-31 20:49:56 +02:00
Pau Espin b53230acec ms: Get rid of ms->delay field
Simply apply the content of the configured timer when the MS goes idle.
Having that field is convenient to do tricky stuff in unit tests, but
makes the main osmo-pcu app more complex for no good enough reason.

Change-Id: I8d44318b37b6605afd84db8ccec0d75e6db293b9
2023-04-21 14:36:28 +02:00
Pau Espin eae9147424 ms: Hold a reference during ms_alloc
Make the caller hold a reference to the MS object just allocated, so
that it hs to explicitly unref it and, in turn, if no new references
were added during its use, trigger release of the MS object.
This is useful to avoid leaking MS object if it was allocated and then
no TBF is attached to it because allocation of TBF failed.

Related: OS#6002
Change-Id: I2088a7ddd76fe9157b6626ef96ae4315e88779ea
2023-04-21 14:36:28 +02:00
Pau Espin ac4d4a6d41 ms: Rewrite MS release lifecycle
This commit changes lots of stuff in the MS release lifecycle, but
there's no really good way to split this into patches which make sense,
since all the chaos is intensively entangled.

Get rid of the ms_callback complex mess, it is not needed at all.

Previous MS release was strange due to the existance of previous
ms_callback.idle concept and MS storage: the MS signalled when it went
idle (no TBFs attached) and waited for somebody outside to free it,
while then arming itself the release timer to release itself if it was
not released by whoever.

The new lifecycle follows an easier (expected) approach: Whenever all
TBFs become detached from the MS and it becomes idle (use_count becomes
0), then it frees its reserved resources (TFI, etc.) and either:
* frees itself immediatelly under certain conditions (release timeout
  configured = 0 or MS garbage with TLLI=GSM_RESERVED_TMSI)
* Arms release_timer and frees itself when it triggers.

If during release_timer the MS is required again (for instance because a
new TBF with TLLI/IMSI of the MS is observed), then a TBF is attached to
the MS and it is considered to become active again, hence the release_timer
is stopped.

OS#6002
Change-Id: Ibe5115bc15bb4d76026918adc1be79469c2f4839
2023-04-20 20:40:52 +02:00
Pau Espin 9da0686371 Merge bts_alloc_ms() and ms_alloc()
gprs_default_cb_ms_idle() is changed to have the same implementation as
previous bts_ms_idle_cb(), since that's the only one being used in
osmo-pcu code. It makes no sense to use different callback logic in unit
tests.

This is another step towards simplifying the code and getting rid of the
idle/active_cb().

Change-Id: I2a06d17588572a21dc5a14ddbde83766076b446d
2023-04-20 16:17:39 +02:00
Pau Espin fe7aee9302 ms: store in bts->ms_list during alloc/destroy of ms object
With this change the MS no longer is removed from the llist without
potentially skipping free() if not idle in bts_ms_idle_cb().
As a result, some unit tests now can free it during bts tear down
instead of having them leaked.
The tests int MsTest need changes because the tbfs created are fake and
cannot be freed using tbf_free(), and hence cannot be detached from MS
using regular code paths. Instead first call explicit talloc_free(ms)
like other unit tests in the file already do.

Change-Id: Id53f8dfb9963366dd4b19a324615bbc83c4f23e7
2023-04-20 16:17:39 +02:00
Pau Espin eb0a0527e0 ms: Merge ms_storage into bts.cpp
That class is mostly a C++ class holding a llist plus some callbacks.
Having that in a separate class makes code more complex for no good
reason. This patch moves the llist into bts and allocates stuff directly
from within bts.
This will allow further cleanup of MS lieficyle in future patches.

Change-Id: I627f5db5073189c23ddf2b7f09c90abb24846f62
2023-04-20 16:17:38 +02:00
Pau Espin cde18c5632 bts: Rename bts_ms_by_{tlli,imsi} -> bts_get_ms_by_{tlli,imsi}
While at it, put them together and mark bts param as const.
This is a preparation for next patch.

Change-Id: Iad8aec4424f1f23cd4d02a14c4f9ec1b9fdb1f75
2023-04-20 16:17:38 +02:00
Pau Espin bfc9756c2b ms: Drop setting (egprs_)ms_class during bts_alloc_ms()
That information is not required during allocation of the object, and
most times it is not known.
Defer setting it only to meaningul values in paths obtaining the
information from peers.

Change-Id: I36f07dc389f7abe205fc4bcddbde93735f5d5cfc
2023-04-20 16:17:38 +02:00
Philipp Maier 41e38475ed pcu_l1_if: get rid of strange paging group calculation
The PCU uses a 16 bit integer value as paging group which does in fact
not really resamble the paging group. Instead it encodes the last three
digits of the IMSI from which the paging group can be calculated. The
value is then eventually converted back to Ascii-digits and then sent
over the PCU-IF interface. Lets get rid of this weird conversion and
use the IMSI directly.

Change-Id: I40d7fc14c9591b3de091e425faaf325421c70a0e
2023-03-20 10:54:28 +01:00
Philipp Maier 2353ed403f bts: add IMMEDIATE ASSIGNMENT via PCH transmission
In situations where the PCU is co-located to the BSC, the IMMEDIATE ASSIGNMENT
for downlink TBFs must be sent via RSL and the BSC also must instruct the BTS
to transmit the IMMEDIATE ASSIGNMENT via PCH instead of AGCH. Eventually the
BSC must sent a confirmation message (follow-up patch) where the TLLI is used
as an identifer.

This new method will eventually replace the previous method that uses
the MAC block as an identifier. To remain compatible with older versions
of osmo-bsc, we will keep the old method until osmo-bts is migrated as
well.

This patch also requires new features to be added to the PCU socket
interface the version number of the protocol is incremented from 0x0a to
0x0b. Version 0x0a will remain compatible and use the old method, while
version 0x0b will use the new method introduced with this patch.

Change-Id: I2a78651593323e8b9627c39918d949a33497b70f
Related: OS#5198
2023-03-06 17:39:11 +01:00
Philipp Maier 7c3fd98c90 pcu_l1_if.cpp: handle TLLI based IMMEDIATE ASSIGNMENT confirmation
The IMMEDIATE ASSIGNMENT for downlink TBFs must be confirmed by the
receiving end (BSC/BTS) in order to set the timers in the PCU correctly.

When the PCU is used in a BSC co-located scheme (Ericsson RBS). The TLLI
is used as an identifier to confirm a specific IMMEDIATE ASSIGNMENT.

Change-Id: Icf7ca34500984239ee877ee71fd9c126b5eb3480
Related: OS#5198
2023-02-13 12:46:43 +01:00
Philipp Maier 6a5b1b1f3e bts: log FN jump delta in bts_set_current_frame_number()
In case of an FN jump the expected value is logged. Lets also log the
delta between the expected and the current FN as it may give a better
clue what goes wrong

Change-Id: Ie361df30852570fe8a47347a42e962db869ccf82
2023-01-05 16:58:20 +01:00
Philipp Maier a42521dfbb bts: use GSM_TDMA_FN_ macros and uint32_t in bts_rfn_to_fn
The function bts_rfn_to_fn() uses int32_t for its internal variables and
the input parameter rfn while the callers and everything outside uses
uint32_t to store frame numbers. Lets convert this to uint32_t and use
GSM_TDMA_FN_ macros wherever possible.

Change-Id: Iedd493bb30dd1c342dec031883060c545432e740
Related: OS#5198
2023-01-05 16:58:20 +01:00
Philipp Maier 39f5e27412 bts: refuse to set invalid frame numbers
A valid GSM frame ranges from 0 to 2715647. When using
set_current_frame_number() to set the current frame number (source
usually is the layer 1 and below) we should not allow invalid frame
numbers.

Note: this also fixes FnTest which uses invalid frame numbers for
testsing.

Change-Id: Iaae31b370fababba975d419b0d20ac15618c296e
Related: OS#5198
2023-01-05 16:56:28 +01:00
Pau Espin 0d957d8364 bts: Adapt trx check based on bts->trx[] defined array size
This way the code is not hardcoded to 8 TRX.

Related: OS#5827
Change-Id: I5ccb5ec27bc189d17c62e7f2a59fae0b3bddf8e3
2022-12-16 12:54:46 +01:00
Pau Espin 478c150a09 bts: Adapt slot_mask to trx defined array size
struct gprs_rlcmac_bts still hardcodes it to 8, but using ARRAY_SIZE
there should aim at seeing the relation between those, and avoid having
one updated without the other.

Related: OS#5827

Change-Id: I165588ba10d8528a9a496175d8dfe9d902c89e55
2022-12-16 11:05:46 +00:00
Pau Espin 140c97c318 Get rid of tbf->first_ts
There's no big benefit in keeping it stored since it can be quickly
found. This makes the tbf data structure simplier and easier to
maintain, and discharges the alloc_algorithm functions from an extra
step.

Change-Id: I5d2f665f648f8637466bfdd3bf7b924cb61ede33
2022-12-16 11:05:46 +00:00
Pau Espin 83a0892e61 tbf_dl_fsm_ctx: Properly define tbf backptr as dl_tbf
Since the tbf_fsm was split recently into tbf_dl_fsm and tbf_ul_fsm,
each has now its own ctx strucvture, which can hold the proper tbf
subclass.

Change-Id: Id2571e55e1fea2918207175f2030ec026e880bc1
2022-12-12 20:09:49 +01:00
Pau Espin f197f15b2d tbf_fsm: Move osmo_fsm_inst fi out of struct tbf_fsm_ctx
This is a preparatory step towards splitting tbf_fsm.c into tbf_ul_fsm.c
and tbf_dl_fsm.c.
In order to accomplish it, the struct tbf_fsm_ctx will also be
duplicated (and each one will contain a explicit ul_tbf/dl_tbf pointer).
Hence, a DL_TBF will have a struct tbf_dl_fsm_ctx and a UL_TBF will have
a struct tbf_ul_fsm_ctx, since those hold implementation specific
state. However, the FSM interface will be partly shared (events,
states), and hence we want to keep the "fi" pointer into the "tbf"
parent class so that it can be used regardless of the tbf direction
type.

Change-Id: I03e691ccf6a94431caa55653349158f5b85db017
2022-11-18 14:16:55 +01:00
Pau Espin 9438613792 Move UL allocation&assign functions to gprs_ms.c
Similar structure as what we have with DL-TBF.

Change-Id: I256aeede2a2678c9738539fb6ec4db9766fa85e4
2022-10-31 22:07:31 +01:00
Pau Espin 1e16e1dc92 use new {dl,ul}_tbf_as_tbf(_const) helper functions
Change-Id: I223d9d5823c90ff31089420d35a7bf0fe1ebf870
2022-10-28 15:14:44 +02:00
Pau Espin cc30b052db Rename as_{dl,ul}_tbf -> tbf_as_{dl,ul}_tbf
Prefix the function accordingly to specify the input object.

Change-Id: I225568fe2cb5236817cdd9609354c24c66723606
2022-10-28 15:14:44 +02:00
Vadim Yanitskiy d6bb6190d3 bts: bts_snd_dl_ass(): use GSM_TDMA_FN_SUM() macro
Change-Id: If363e3320372c798b9b16274327fa8041358e350
2022-10-26 20:39:24 +07:00
Vadim Yanitskiy 153cb7f47d bts: bts_snd_dl_ass(): clarify the meaning of last_rts_fn + 21216
Change-Id: I8127e17607426443bb95b42873b580fc9f400af9
2022-10-26 20:39:24 +07:00
Pau Espin 7f360e74b7 Call ms_store->get_ms() with GSM_RESERVED_TMSI instead of 0
That's the special value checked in the implementation of get_ms() to
skip lookups based on TLLI.
This should save some cicles trying to match TLLI 0.

Change-Id: I364d238ff8a82abb14281140fe18b273c0e8f541
2022-10-21 14:31:05 +02:00
Pau Espin 940e5953ed bts_rcv_imm_ass_cnf(): Improve logging
Related: OS#5700
Change-Id: I29a290d1e8b6e237a74ac8fab8dd5e5e5db71796
2022-10-21 11:59:56 +02:00
Pau Espin bee29f46ae Clarify use RR imm_ass msg fields
Change-Id: I814c7d4c1bce3f56852cfb1c7aa69b41588cb245
2022-10-16 22:13:48 +02:00
Vadim Yanitskiy 2cfc8e2c9a bts_set_current_frame_number(): log expected TDMA FN
Change-Id: Id28776fb5f0f85cd35d3918c79f8c8e338156aae
2022-10-05 13:51:31 +07:00
Pau Espin bf5e3cb3a4 bts: Call gprs_bssgp_destroy() in destructor
Change-Id: I7ed7f489f36f88277e2d5e393edcb339bf0cbba0
2022-05-09 16:40:43 +02:00
Pau Espin 56b7c64298 Move T3172 T_defs_bts->T_defs_pcu to have it configurable in VTY
The timers in T_defs_bts are actually set by BTS over PCUIF. That's not
the case for T3172, hence let's move it to T_defs_pcu so it can be
configured over VTY.

Change-Id: If24191b2305007aa5be5b551c913738a97597c77
2021-11-16 11:35:23 +01:00
Pau Espin 0dcbc07682 bts: Add counter availablePDCHAllocatedTime
We basically want to probe whether it's possible to allocate TBFs, or
whether we know it will fail due to all main resources being already in
use (TFI, USF).

Having bts_all_pdch_allocated() return false doesn't mean though that an
MS will be able to allocate a TBF for sure. That's because further
restrictions are applied based on MS: whether it was already attached to
a specific TRX, whether the ms_class allows for a certain multislot
combination, etc. However, it should provide a general idea on whether
for sure the PCU is unable to provide more allocations. More fine
grained state about failures can still be followed by looking at
tbf:alloc:failed:* rate counters.

Related: SYS#4878
Depends: Iabb17a08e6e1a86f168cdb008fba05ecd4776bdd (libosmocore)
Change-Id: Ie0f0c451558817bddc3fe1a0f0df531f14c9f1d3
2021-11-15 11:40:07 +01:00
Pau Espin 5deac1404d Fix MS ending up with assigned imsi 000
The whole paging path and data structre is cleaned up.
New MS helpers ms_imsi_is_valid() and ms_paging_group() are introduced
to help in the process and keep implementation details inside GprsMs
class.

Related: OS#5303
Change-Id: I4c0838b26ede58e4b711410eee2a8e4f71e9414b
2021-11-12 18:38:43 +01:00
Pau Espin ef8a730f6d bts_pch_timer: Avoid resend Paging Request over PCUIF if T3113 is armed
Let's avoid flooding the BTS and taking CCCH resources for no good
reason. If user configures everything correctly, the SGSN should not
attempt a retry after similar timer >= T3113.

Related: OS#5297
Change-Id: I2a77714648d16ccff2a340ce775e83dcc5ffe707
2021-11-08 18:54:12 +00:00
Pau Espin ba5683194a Add counter for successful contention resolution procedures
This counter is related to succPDTCHSeizures,
(3GPP TS 52.402 B.2.1.51 Successful PDTCH seizures).

The relevant event when the first RLC block on the PDCH from the MS is
received is the fact that contention resolution is considered as done in
the network side. Hence, name the counter that way to ease
interpretation.

Related: SYS#4878
Change-Id: I3d67e3e68907921b43f2ca4398ad9578c0b2618c
2021-11-08 18:33:04 +00:00
Pau Espin dff399fa42 bts: Add counters for successful 1,2 phase pkt access
These counters relate to succPDTCHAssProcsPerCause
(B.2.1.50 Successful Packet Channel Assignment Procedures, per cause).

Related: SYS#4878
Change-Id: I494afab337f2557ffa38e4c7ff2c15a1647a1e04
2021-11-08 15:26:49 +00:00
Pau Espin 48df600bfa bts: Count RACH Request with unexpected content
Change-Id: I86420b08a9a634ca2e1f5a1c7e66ec3d3c08ce0b
2021-11-08 12:23:31 +00:00
Pau Espin 812a7d3fa3 bts: Improve logging to clarify RACH req is for 2 phase access
Change-Id: I047b688197a07e3592f19888f0ca71b9c3d2b3fd
2021-11-08 12:23:31 +00:00
Pau Espin 769e28114f bts: Introduce new RACH req counters for one/two phase access
These new counters allow the user to find out which kind of access are
MS requesting.

Related: SYS#4878
Change-Id: Id87c3a53d3acee92499987c843130e358f54742c
2021-11-08 12:23:31 +00:00
Pau Espin 7ce56d7c64 bts: Rename 11bit RACH request counter
This way it fits better the structure where the general one counts all
rachs, and 11bit only the 11 bits. More per-type splitting will be done
in follow-up commits where new types are added.

Change-Id: Ibdfb10dcc65d71e98e2fe8b05001cafea786f071
2021-11-02 16:47:08 +01:00