Commit Graph

104 Commits

Author SHA1 Message Date
Pau Espin fb904fbbd9 pdch: Log DL TBF originating the new UL TBF
Change-Id: Ie4257a2468d589464d0d56882e4408e4bcfe340f
2021-11-09 14:01:40 +01:00
Pau Espin 304b10a8b5 pdch: Log TS enable/disable transitions
Change-Id: I6780634de4791382ccd25bf7b74f5286420e2c52
2021-11-09 12:22:48 +01:00
Pau Espin 20dfa54508 pdch: Log line detaching TBF at start of the function
Log before the action is done ("Detaching", not "Detached"). This way,
if something crashes we see that last line.

Change-Id: I6811d3772e2ac850741d3db5ec32be5c0812e81a
2021-11-09 12:15:23 +01: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 10b29153b7 pdch::rcv_resource_request(): Use local var to store bts pointer
Change-Id: Ica727c4b70cecc0ddb5d2a235bfc416735754b61
2021-11-08 18:33:04 +00:00
Pau Espin 92cbe4aee0 pdch: Improve log line and increase log level
Change-Id: Ie593331a69f6b8ec3b21e2b274a1aa060b2dc439
2021-11-08 13:24:19 +01:00
Pau Espin 196f36b75a pdch: Log reason of expected POLL when receiving unexpected UL data
Change-Id: I914e38154029f57cbf38120495220cd860877c45
2021-10-18 12:37:51 +02:00
Pau Espin 592239630b pdch: Simplify code path allocating UL TBF
There's no real need to pass a tlli per separate, the information is
already contained in the MS. Furthermore, when doing so, it becomes
clear the TLLI was only passed to set it again on the MS, so actually
that ms_update() can be totally dropped since it will act as a no-op.

Change-Id: Ie761c3c7c222458ab0514117ae637ad3267139a0
2021-10-18 12:24:42 +02:00
Pau Espin ffa2918bc5 pdch: rcv_data_block: Avoid releasing ULC entry if expecting something else on UL
Let's only release PDCH ULC entry if it was indeed what we expected.
In other case, time it out.

Change-Id: I1537587f5ee801c633784691b576ebb1ed521e95
2021-10-12 20:07:19 +02:00
Pau Espin ffe998ce9d tbf: Document temporary change of control_ts and move code assigning it back to FSM
Change-Id: I1b7eb7802060778487e5729ee789b2323b6636f8
2021-10-12 19:32:28 +02:00
Pau Espin 7a2b65ed2c Handle Final UL ACK/NACK Confirmation in tbf_fsm
Pass the event over the FSM for better understading of the entire
lifecycle of the TBF.

Change-Id: If30d881037209d33b2b41ecf8bb8419caf36e367
2021-10-12 12:41:53 +02:00
Pau Espin 201dbe04f7 pdch: PktResReq: Avoid releasing ULC entry if expecting something else on UL
Let's only release PDCH ULC entry if it was indeed what we expected.
In other case, time it out.

Move the case in the switch statement to the start to easy function
readibility (early return style).

Change-Id: I3d8749acca8e7859295d73cce556b2083169f726
2021-10-12 12:41:18 +02:00
Pau Espin 8318d9c25d pdch: Validate poll reason matches in rcv_control_(egprs)_dl_ack_nack()
If we didn't expect this kind of UL messages according to pdch ULC, then
we shouldn't allow going forward and releasing the ULC entry: let it
time out instead so that TBF runs whatever appopiate action is needed in
this case, be it retransamission, releasing itself, etc.

Change-Id: I8ab3f5e4f2f802944269453db13a80c9ede67714
2021-10-11 18:22:01 +02:00
Pau Espin 0dbf6f2a54 pdch: Only release ULC entry if rx ul block matches the expected one
If it doesn't match out expectancies, it means we early return and hence
don't push forward / update whatever state was requested upon receival
of the UL message for the expected TBF. Hence, we shall not remove the
allocated ULC entry: in this scenario we need to keep it so that timeout
procedure times out and the tbf applies whatever measures are required,
be it retransmission, releasing itself, etc.

Change-Id: Ia69a7d92c4b5c98ec71a75605c8dc3a755e63a35
2021-10-11 18:14:32 +02:00
Pau Espin e9db5c7387 assert if tbf pointer for POLL event is NULL
The tbf pointer should always point to a valid TBF.

Change-Id: Ib607a38459802f780826f46c20a1696ec98408fb
2021-09-28 16:38:30 +02:00
Pau Espin a27fb3fce3 cosmetic: Fix missing space
Change-Id: Ib64cbf1d95dd0a881f6ace0cf9a4f517eb58ae0f
2021-09-28 16:38:30 +02:00
Pau Espin c8d2166b86 pdch: refactor rcv_control_ack() with a switch statement
This clarifies the different paths and uniforms them. Makes code far
easier to read and debug.

New improved verification already found some misehavior in some tests.

Change-Id: I7e4a88d6e004bbb7974595320ed73742162c7ad7
2021-09-28 16:05:27 +02:00
Pau Espin c276e4996d nacc: Introduce helper function nacc_fsm_exp_ctrl_ack()
Move FSM internal state checks to its own file. Re-use the helper
function in the 2 places where same stuff is checked.

Change-Id: I9ded6e1c80e6cd7bcf6883bc2e853b6dafb33f7c
2021-09-28 12:53:37 +02:00
Oliver Smith fce67bc7fa pdch: has_gprs_only_tb_attached: use m_num_tbfs
Make use of the separate GPRS counters added in previous patch
I0c0a1121b4ae5f031782e7e63a0c28eb0b6c8b42 to shorten
has_gprs_only_tb_attached.

Related: SYS#4878
Change-Id: I1dd7df2c740ea604f07c65bebcb7c0051aebf9ae
2021-09-21 10:28:52 +00:00
Oliver Smith 402451b308 Add stats: pcu.bts.N.pdch.occupied.gprs/egprs
Add stats needed for performance measurements in
3GPP TS 52.402 § B.2.1.54-55.

Split m_num_tbfs to count GPRS and EGPRS TBFs separately. Move the code
that updates m_num_tbfs and sets the PDCH_OCCUPIED stats to a separate
function, as it's mostly the same in the TBF attach and detach.

Related: SYS#4878
Change-Id: I0c0a1121b4ae5f031782e7e63a0c28eb0b6c8b42
2021-09-17 17:28:03 +02:00
Oliver Smith 35d51ca4e3 Add stats: pcu.bts.N.pdch.available/occupied
Count available PDCHs (3GPP TS 52.402 § B.2.1.38) as well as occupied
PDCHs (§ B.2.1.42-44).

Related: SYS#4878
Change-Id: I74760a68ee055510a79e80854ec7bf1521669119
2021-09-06 09:11:47 +00:00
Pau Espin 1d663d9277 pdch: Make sure pending ImmAssRej scheduled for disabled pdch are dropped
When a PDCH TS becomes disabled (eg due to dyn TS being used for a
call), we are currently freeing all attached PDCHs in order to avoid
further use of it. However, pdch_free_all_tbf() was only freeing TBFs
attached to the PDCH, that is, TBFs having a valid TFI assigned.
There are some cases where temporary dummy TBFs are created which have
no TFI assigned, such as when creating an ImmAssReject. Let's take those
into account too, and make sure they are freed.

Related: OS#5226
Change-Id: Ibfe78448ebdedc8b049c80664711e166d910f9b7
2021-09-03 16:01:37 +00:00
Pau Espin ea8dbddab1 Move tbf ul_ack_state to osmocom FSM
Related: OS#2709
Change-Id: Icf23bf5a4b85fbcbf1542cebceb76b9ba7185d30
2021-08-23 17:14:23 +02:00
Pau Espin 3225290d77 Move timer X2002 to tbf_fsm
Related: OS#2709
Change-Id: I94b71c60ed49d51ebdf6d6b428056b4b94354676
2021-08-23 17:14:23 +02:00
Pau Espin fbc1baa139 tbf: Merge handle_ack_nack() into rcvd_dl_ack()
There's no real use in having those 2 methods separately, and only adds
complexity. Let's merge it to have 1 TBF code path handling DL ACK/NACK.

Change-Id: I546d2e46bda96a2f551b28673464e57831c71828
2021-08-23 17:14:23 +02:00
Pau Espin 5bc6560efc tbf: Drop unuseful flag GPRS_RLCMAC_FLAG_TO_DL_ASS
The flag is only used to print some non interesting stuff, let's drop it
in order to simplify code. We can add later whatever we want in the new
shiny FSM.

Change-Id: I13f92f058c219f230d57b3c00b8ae1d187603813
2021-08-23 17:14:22 +02:00
Pau Espin 49a2f404e8 replace dl_ass_state with osmocom FSM
Related: OS#2709
Change-Id: Ia33418478e17986a316ffda48b091030f53fa371
2021-08-23 17:14:22 +02:00
Pau Espin 432d4f3b89 tbf: Drop unuseful flag GPRS_RLCMAC_FLAG_TO_UL_ASS
The flag is only used to print some uninteresting stuff, let's drop it
in order to simplify code. We can add later whatever we want in the new
shiny FSM.

Change-Id: I20aa7f83cc4f32de129e64c74a91745b983a7b16
2021-08-23 17:14:22 +02:00
Pau Espin 6ad11a6990 Replace ul_ass_state with osmocom FSM
Related: OS#2709
Change-Id: Id414eafe9c04a9a8759c6fb1a483bf2ee093a4d2
2021-08-23 17:14:22 +02:00
Pau Espin 720e19e7f3 Move FLOW tbf_state transition to tbf_fsm.
Related: OS#2709
Change-Id: Ia8c7de759c195d09263fb1f083fbf6cfa3087f8d
2021-08-23 17:14:21 +02:00
Pau Espin 33e8007100 Move NULL and ASSIGN tbf_state transition to tbf_fsm
At some point later in time the state_flags will most probably be split
into different variables, one ending up in a different FSM. It is moved
so far to the exsiting FSM from the C++ class since it's easier to
access it from C and C++ code, and anyway that kind of information
belongs to the FSM.

Related: OS#2709
Change-Id: I3c62e9e83965cb28065338733f182863e54d7474
2021-08-23 17:14:21 +02:00
Pau Espin b5fece959f Revert "fix: handle NULL return of as_dl_tbf() and as_ul_tbf()"
This reverts commit d8e8ea9c8f.

Change-Id: I8000e78515b25b9be5c28a249bde330dac915dcb
2021-08-23 17:14:17 +02:00
Neels Hofmeyr d8e8ea9c8f fix: handle NULL return of as_dl_tbf() and as_ul_tbf()
Go through all callers of as_dl_tbf() and as_ul_tbf(), and make sure
they can handle the possible NULL return value.

OS#5205 reports a NULL deref crash of osmo-pcu at pdch.cpp:525. The
immediate cause is that as_dl_tbf() may well return NULL, which this
caller does not handle and instead dereferences immediately.
This is a code path that apparently assumes that a DL-TBF should always
be present. The higher level cause for the NULL DL-TBF has not been
identified.

Related: OS#5205 SYS#5561
Change-Id: I8ce21be6836549b47a606c00b793d6f005964c5c
2021-08-17 12:17:13 +00: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 ab178903d4 pdch: Fix null MS access gprs_rlcmac_pdch::rcv_control_ack
If bts_ms_by_tlli() at the start of the function fails, ms could be
NULL. As a result "ms->nacc" access at the end of the function would
crash.
Solution:
In the function, we get the related expected TBF from pdch_ulc, and we only
continue if a TBF is found. Since tbf objects are always expected to
have a GprsMs, simply gather it from there.

Change-Id: I666ed5d157f42e74956fa49fc9eea85d27e63d44
2021-06-23 13:50:35 +02:00
Pau Espin c6e911cf22 pdch: Log pdch_ulc reason upon rx of pkt ctrl ack
Change-Id: I7c7a421b1e9189e2814e9a28698d66655fc9ba60
2021-06-07 18:16:55 +02:00
Pau Espin dc2aaac29f tbf: Move existing tbf_state implementation to osmo_fsm
This is only an initial implementation, where all state changes are
still done outside the FSM itself.
The idea is to do the move in several commits so that they can be
digested better in logical steps and avoid major break up.

Related: OS#2709
Change-Id: I6bb4baea2dee191ba5bbcbec2ea9dcf681aa1237
2021-05-19 12:50:25 +02:00
Pau Espin c48d27b57b pdch: Use llist_first_entry() API
Change-Id: I96e7188ecf7d2cfc54598975f8d538e7aa94401a
2021-05-13 15:58:55 +02:00
Pau Espin c6571b5581 Rename function s/tbf_alloc_ul/tbf_alloc_ul_pacch/
Change-Id: I70ca0b5be0a29a05c6e65b9c92cc6d3b5c43d3dc
2021-05-11 11:32:38 +02:00
Pau Espin 54742f287c ul_tbf: Clean up handle_tbf_reject()
Document the function, make it look similar to usual TBF creation path
tbf_alloc_ul()->tbf_alloc_ul_tbf->tbf::setup(), which it mimics with
some differences.
Get rid of unneeded stuff like creating MS and settings its TLLI (that's
already done in only caller of the function). There's no need for
calling update_ms() either.

Change-Id: I61df2e4f0f0df1f8db941741a2d35a2319252c5e
2021-04-26 17:19:07 +02:00
Pau Espin 710e0e9ad8 pdch: tbf_by_tfi(): Allow returning TBFs in state RELEASING
During RELEASING state the TFI, USFs, etc. are still reserved and
assigned to the TBF, and hence the TBF may still use it.
If callers of this function rely on not taking TBFs under RELEASING
state, they should check that explicitly.

It still makes sense being to operate on RELEASING TBFs, since under
some circumstances the TBF may go under a previous state. See for
instance 3GPP TS 44.060 sec 8.1.1.3a.2:

"""
If N3101 reaches the value N3101max, the network shall stop sending
PACKET UPLINK ACK/NACK messages to the mobile station for that TBF
and shall start timer T3169 for the TBF. If an RLC/MAC block is received
from the TBF when timer T3169 is running, the network shall stop timer
T3169 and resume sending PACKET UPLINK ACK/NACK messages to the TBF.
When T3169 expires, the network may consider the TBF as released and
reuse the TFI value.
"""

Change-Id: Ibb471e727388512d42794d3faa26597e2545b852
2021-04-22 21:07:06 +02:00
Pau Espin 434799720c pdch: rcv_resource_request: Improve robustness
Use recently added PDCH UL Controller to verify expectancies.

Test test_packet_access_rej_prr is rewritten since it didn't make sense
as it was before, since it relied on osmo-pcu not checking stuff
properly to trigger the reject. The RACH requests are changed to
allocate 8 SBAs (maximum of 7 concurrent USFs). Allocating the SBA
doesn't reserve a USF, that happens at PKT RESOURCE REQUEST, hence we
end up exhausting resources there and triggering the REJECT at that
point.
Previous version of the patch allocated TBFs directly through RACH req,
and then submitted an extra PKT RESOURCE REQUEST which PCU didn't expect
to trigger the reject.

Change-Id: I157e72160317340ee7742c78c62a25d3d98fc01e
2021-04-22 20:28:40 +02:00
Pau Espin 127e7392f6 tbf: get rid of poll_state completely
The poll_state logic was part of previous implementation (prior to pdch
ul controller) where the ssumption was that TBF could only had 1 POLL
request in transit, which is really not true. With current
infrastructure we don't need this state tracking at all.

Change-Id: Ie5b807ccd38aa736ae11b3310ca61ad0156ca4d4
2021-03-31 17:39:50 +02:00
Pau Espin 86580e1966 pdch_ulc: Store TBF poll reason
This allows easily checking the initial reason to trigger the poll when
either it is received or times out.

Later on this reason can be transformed into an FSM event and sent to
the related FSM.

Related: OS#5020
Change-Id: Ie8fefd1f47ad674ce597a8065b15284088956bde
2021-03-31 17:39:50 +02:00
Pau Espin c1f38c7f0b Track scheduled UL blocks through USF
This way PCU can now detect whether scheduled UL blocks through USF
were never received. This allows in a follow-up patch to start
increasing N3101 properly.

Related: OS#5033
Change-Id: Ia99c9edad6e5bd837e9baeb4fb2683b227887957
2021-03-24 17:14:19 +01:00
Pau Espin 9a6f0b191a pdch: Add mising pdch_ulc_release_node in Rx Cell Change Notif
All other RX CTRL block paths have it, this one was missing.

Change-Id: Ief315d7b6d4fea946d43e5bd87cf8a0394adc855
2021-03-24 17:12:01 +01:00
Pau Espin 99360a304f Replace PollController with newly added PDCH UL Controller
TbfTest is updated to submit empty blocks to have somehow meaningful
output (at least as meaningful test results as before, not much). That's
because we must update bts->curr_fn to have polls expire.

Related: OS#5020
Change-Id: I683ca738ce5a133c49c36a1d94439a942d64a831
2021-03-15 19:32:36 +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 68bfdff3f0 pdch: Log FN when decoding UL Ctrl block
Change-Id: I5a44ebf49f7489211a77607052db6d9731f38704
2021-03-12 07:40:11 +00:00
Pau Espin 702ebee751 Introduce init() APIs for PDCH and TRX objects
This will make it easier to keep object specific initializations in
expected place.

Change-Id: Idf1dbdf8bc0b1e16d86eeeffb1193fdf3a57d6ef
2021-03-12 07:40:11 +00:00