Commit Graph

2356 Commits

Author SHA1 Message Date
Pau Espin 89fbf87abf Avoid using N3103 in DL TBFs
N3103 counts retransmits of PACKET UPLINK ACK/NACK with FinalACK=1. As a
consequence, this counter only applies to UL TBFs.

Current code is only using it in UL TBF, but add an assert to clarify
and make sure it is not used unproperly in the future.

Change-Id: I026d6145249ef19694f673ec7b4928af9d401dd6
2023-06-09 18:38:28 +02:00
Pau Espin d8c38777a1 Avoid using N3101 in DL TBFs
TS 44.060 13.4 "N3101" clearly states this counter relates to UL TBFs,
since it only applies to TBFs for which USFs are set:
"When the network after setting USF for a given TBF, receives a valid data block of this TBF from
the mobile station in a block assigned for this USF, it will reset
counter N3101.  If PS Handover is not ongoing, the network will increment counter N3101 for each
USF for which no data is received for this TBF."

Furthermore, N3101 must only be reset for data blocks, so drop all rx
CTRL block patches on UL TBF resetting the counter.

Change-Id: I207f3906d13fc6feea2282e261f468a09db37d86
2023-06-09 18:38:28 +02:00
Pau Espin 74f6dd7a00 tbf_{ul,dl}_fsm: remove impossible dst state transitions
There's no code path triggering change to those states.

Change-Id: I05b3019e12ec37e11ac2561a94b2eacec8718755
2023-06-09 18:38:28 +02:00
Pau Espin 637bcdf80e tbf_{ul,dl}_fsm: Remove unneeded asserts
Those are leftovers from the time where we had a single tbf_fsm for both
UL and DL TBF.

Change-Id: I99359b8cb655b26ac2058f457423fdec178744ea
2023-06-09 18:38:11 +02:00
Pau Espin 49b144847f tbf_dl_fsm: Apply T3193 using FSM infrastructure instead of manually
Change-Id: Ic2a9d4b3c812c1533b2b7f97f27799b28b636c21
2023-06-09 16:44:35 +02:00
Pau Espin 08b6a00afd Log MS information in error message using usual MS API
Also, drop duplicated TRX+TS info which is already displayed as part of
LOGPDCH.

Change-Id: I66211f4fa8a139ddd109623d90a926a53f180cfd
2023-06-06 10:59:24 +00:00
Pau Espin 2549c1e696 Document pcu_lsb() function
While at it, fix a typo in the test output.

This function is nowadays only used in ms_current_pacch_slots(), which
is used only to print the PACCH TS (the first common UL & DL TS).

Change-Id: Id1d0b681f6866618f9f3a8c64d6a6c809ca50ea7
2023-06-03 12:46:26 +00:00
Pau Espin ba8918aae8 pcu_utils.h: Replace software based bitcount impl with gcc builtin
The cast for different types it's not really needed, simply use the
unsigned long long version to make sure we don't drop 1s, in any case
__builtin_popcountll() will be quicker than what we used to have.

Change-Id: I80ae72d34d53564fc3da1601ee48c8b2ffe79735
2023-06-03 12:46:26 +00: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 d0fd37c449 Move call to bts_set_current_frame_number() earlier in the code path
The FN time counter is not really PDCH specific, but to the whole BTS,
and all other calls t the bts_set_current_frame_number() are already
laced in pcu_l1_if.cpp; move it there.

Change-Id: If36f22a1067c904fa7fda87bed5062b6738f0dd1
2023-06-02 14:37:05 +02:00
Pau Espin 53eaf74ffa Use fn_valid() helper in pcu_rx_time_ind()
Change-Id: I5b1f1d4cd621d81fb99b87761a878af242227a10
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 96b7a3ec72 cosmetic: tbf_ul_ack_fsm: Clean up use of ul_tbf and tbf pointers
Change-Id: I51ebe8174006380821eb978bbd78f600c10b02e7
2023-05-31 13:36:05 +02:00
Pau Espin a9b844d346 tbf: Improve TBF name description in logs
Change format to print the state at the end, to resemble more the same
format used by FSMs.
Furthermore, by moving it at the end, print it only when "enclousure" is
requested, aka when not requested by FSM to update its internal name.
The consequence of this logc is that log lines printed from FSM don't
end up with the same state string printed twice in different places.

While at it, shorten the EGPRS/GPRS indicator to one character, which
should be understandable enough since it matches what's usually seen in
mobile phones to signal one or another.

Change-Id: I86b5f042fae77721b22fc026228677bd56768ba9
2023-05-31 12:54:14 +02:00
Oliver Smith 2fc67e252c systemd: depend on networking-online.target
Related: SYS#6400
Change-Id: Ifbac18a38e086e42c67499b7818cdf08629d0000
2023-05-26 14:10:46 +02:00
Philipp Maier 98e5910ed8 gprs_rlcmac: also use PCU_IF_SAPI_PCH_DT for paging MAC blocks
In the current code we still send PAGING COMMAND MAC blocks via SAPI
PCU_IF_SAPI_PCH, which technically belongs to the older PCUIF version
(v.10), which we are going to deprecate soon.

Let's change this so that PAGING COMMAND MAC blocks will also be sent
through PCU_IF_SAPI_PCH_DT. Since PAGING COMMAND messages require no
confirmation by the receiving end we may set the TLLI field to
GSM_RESERVED_TMSI.

Depends: osmo-bsc.git I82443f2b402aa2416469c8c50b1c050323ef3b8f
Related: OS#5927
Change-Id: I99cfe373fa157cfb32b74c113ad9935347653a71
2023-05-22 12:35:09 +02:00
Vadim Yanitskiy 5fd0022b62 copyright: fix typo: sysmocom s/s.m.f.c./s.f.m.c./ GmbH
Change-Id: If51895e67271c0913e000ff9d28db8d8fe761201
2023-05-18 17:22:26 +07:00
Max 3d462354e5 ctrl: drop deprecated neighbor resolution interface
Related: OS#5809
Change-Id: Iff008c77ab49dd8855d54d2d44198475086012e4
2023-05-12 15:22:03 +00:00
Philipp Maier 8984afa5d0 pcu_l1_if: replace magic numbers with IMSI_DIGITS_FOR_PAGING
we have defined IMSI_DIGITS_FOR_PAGING but some parts of the code still
use magic numbers (3), let's replace those as well.

Change-Id: I9a1b6ba4578e2a8875d8d1a9e56c36dc2b33fe0d
2023-05-10 12:41:17 +00:00
Philipp Maier 6ee8d136d3 pcu_l1_if_phy: fix API function names
The functions l1if_open_pdch and l1if_close_pdch have a misleading
naming since what they actually do is opening and closing the TRX since
they return and accept a context (obj) that is valid for a whole TRX.
This also explains why the other functions accept a timeslot as
parameter in addition to the context. Let's rename those functions so
that it is clear what they do.

Related: OS#6022
Change-Id: I395a60b2fba39bac4facec78989bac20f0cef0d3
2023-05-03 09:57:38 +02:00
Philipp Maier 5e024342c4 er_ccu_l1_if: use one ccu_desr per timeslot
At the moment only allocate one CCU descriptor and use it as context for
the whole TRX. This is fine when running with one PDCH only but as soon
as multiple PDCHs are used the CCU descriptor gets messed up. Let's fix
this by introducing a TRX descriptor that contains an array of 8 CCU
descriptors, one for each timeslot.

Related: OS#6022
Change-Id: I09a51f34ce0edef79a797c4686c7b1d27c376e49
2023-05-03 07:56:47 +00:00
Pau Espin e1a8915936 cosmetic: ms: fix formatting of function comment
Change-Id: I717c0ebd6e9af5388e94482842f5638777758b32
2023-04-28 14:46:32 +02:00
Pau Espin 7a491b9d5f ms: Fix unsafe iterating freeing items in list
Change-Id: I35cba6d617b3356515769405c7d05ba28cd5132b
2023-04-28 14:45:39 +02:00
Pau Espin 5faedf3432 ms: Mark ms_reset() as static
Change-Id: Idc42be62f9911b7e2fad3dade884e72e5c2965f4
2023-04-28 14:29:40 +02:00
Oliver Smith 96a3e7f48c debian: set compat level to 10
Related: OS#5958
Change-Id: Icdb0f4107fa426afb1e7c2bb4a808ea6f9cc46a8
2023-04-27 12:29:37 +00:00
Philipp Maier c564ce8965 pcu_l1_if: cosmetic: reformat comment
Change-Id: Ib4ae65e1bc118572135fbec02e64dbec35f208b4
2023-04-26 12:24:51 +00:00
Pau Espin 4d3639144d Move resource allocation outside of tbf allocation
This patch finally decouples TBF allocation from resource allocation.
This will allow in the future reserving resources without having to
require a TBF object to exist.

Change-Id: I2856c946cb62d6e5372a1099b60e5f3456eb8fd4
2023-04-26 13:29:03 +02:00
Pau Espin d6c555ebd6 Move out of alloc_algo code modifying the data model
This way the alloc_algo() becomes idempotent, simplifying implementation
of new alloc_algos as well as rolling back if allocation fails (for
instance because some resource is exhausted at the time).

For now the code applying the results is moved to tbf::alloc_algo(), but
it will eventually get out of tbf code, so that the MS object is
responsible for running it. As a result, there's no even need to create
TBF object before trying to allocate resources, which will help furher in
rollback operations described above.

Change-Id: I5ffd00f5f80bde4b73b78db44896f65e70e12b20
2023-04-26 13:28:55 +02:00
Pau Espin a42b174bec alloc_algo: Move printing outside of update_ms_reserved_slots()
Change-Id: I0d8838829c519bb6da8a68d62947b98bab35a39f
2023-04-21 14:43:30 +02:00
Pau Espin a6a972e11e alloc_algo: Pass a struct containing all req params
This is a first step towards isolating the allocation algorithm from
applying changes on PCU state.
In next steps the tbf pointer will be dropped and the allocation
algorithm will only result a "result" struct which then the caller can
apply to whatever TBF object it requires.

Change-Id: Ie4d9ace526ad012d97738bc55bdb5cc1472c632d
2023-04-21 14:43:30 +02:00
Pau Espin 51c903e1bb vty: Several improvements to 'show ms' output format
* Use UL/DL acronyms to decrease output verbosity
* Keep more stable MS properties at the top, move link quality changing
  entries to the bottom putting them together.

Change-Id: If9f4c6ba1a4a6f9060222cc04254054ad03d7a96
2023-04-21 14:42:10 +02:00
Pau Espin 4673eb0b76 ms: Log MS active/idle state in 'show ms' VTY commands
Change-Id: Ibcd34055c9ae390510c5c3ba26621fd96d2368fd
2023-04-21 14:36:28 +02:00
Pau Espin f086fede93 ms: Rename field timer -> release_timer
Rename it so that it becomes clear what the timer is used for.

Change-Id: Id4738ea196b232858e1ec9cdc439f9b81839058f
2023-04-21 14:36:28 +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 c5104b7f30 meas: Improve logging formatting
Change-Id: I15d66da3f41a9f14a542b96436d65a0581bbb45a
2023-04-21 14:36:28 +02:00
Pau Espin 4fdf79e0b3 ms: Increase log level when scheduling release timer
Change-Id: Ie470b5b0c7b01d91f4ad693e52afd51860d6da2d
2023-04-21 14:36:28 +02:00
Pau Espin fe4d2f7dca Add new log category 'ms'
This is useful to track the lifecycle of MS objects. The RLCMAC cateogry
used so far in those log messages is too broad.

Change-Id: Ib4ce88d0f7309ac77c064a94bb0d667e8dbc33dd
2023-04-21 14:36:28 +02:00
Pau Espin 8456a3642b dl_tbf: Set BandWidth timestamps to current time directly
Change-Id: I01654534aef5255c6d1c3ba0c553190a0319e8e1
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 84b0ebc902 cosmetic: Fix indentation in comment
Change-Id: I15063346e4ff0367c0bf04f6b48ac62b9bdf2929
2023-04-21 14:36:28 +02:00
Pau Espin 759724ca74 tbf: Move enable_egprs() to constructor
Whether the TBF is GPRS or EGPRS is known at allocation time since it
comes from the information known in the MS object used to create it.
Hence, no need to delay calling it to later steps such as setup().

So far it was probably left in setup() due to the constrains about
requiring the subclass to be constructed (use of window() virtual API).

Change-Id: I2e9d2a98c666a930333d52fb6c0463d7593c2615
2023-04-21 14:36:15 +02:00
Pau Espin e0e4251a5b tbf_ul: Move rate_ctr allocation to constructor
Change-Id: I818eb05fe062e0610e86cb34273bde99b379aa3f
2023-04-21 14:35:52 +02:00
Pau Espin e1c84579cc tbf: Move m_ctrs alloc to constructor
Move rate_ctr allocation to the constructor since it's expected not to
fail. This simplifies further tbf::setup() function.

Change-Id: If64443c38624d159e68eec3a07d8e8caf369467b
2023-04-21 14:35:37 +02:00
Pau Espin f9783c58f7 tbf: Store initial timestamp during constructor
Like already done for other timestamps.
This helps in simplifying the setup() call.

Change-Id: Ia0c2d0f5456b211169fb6c71f5f3c2e2b8760a28
2023-04-20 20:40:52 +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 df6684fe50 ms: Log detaching tbf log line in proper place
It is interesting to log that a tbf is being detached *before* it
actually happens, so that the reader can see which TBF is being
detached.

Change-Id: I2008beb9ab8f97f7ea5ed7b45cfb3f23dfe7b27f
2023-04-20 20:40:52 +02:00