Commit Graph

23 Commits

Author SHA1 Message Date
Pau Espin 09dc6b21e2 tbf_dl_fsm: Fix assert hit due to EV_MAX_N3105 received in ST_RELEASING
That code path was incorrectly removed a few commits back, re-add it.

Fixes: 40a297f3b0
Change-Id: I27e61dc4b3396360327dcd377d171daa30684d23
2023-09-15 00:06:57 +02:00
Pau Espin e4e53adc9c tbf_dl_fsm: Fix '{FLOW}: Event ASSIGN_PCUIF_CNF not permitted'
As seen during manual testing:
20230628140439674 DTBF tbf_dl.cpp:116 MS(IMSI-901700000015256:TLLI-0xd4d57c9d:TA-0:MSCLS-12-12) Allocating DL TBF
...
20230628140439674 DTBFDL tbf_dl.cpp:489 DL_TBF(DL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){NEW}: Received Event ASSIGN_ADD_CCCH
20230628140439674 DTBFDL bts.cpp:1108 TBF(DL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){ASSIGN} Tx CCCH (PCH) Immediate Assignment [PktDlAss=PDCH(bts=0,trx=0,ts=5)] TA=0
...
20230628140440238 DMS pdch.cpp:681 MS(IMSI-901700000015256:TLLI-0xd4d57c9d:TA-0:MSCLS-12-12:DL): + rcv_resource_request: now used by 2 (tbf,rcv_resource_request)
20230628140440238 DTBFDL pdch.cpp:738 TBF(DL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){ASSIGN} Got PACKET RESOURCE REQ while DL-TBF pending, killing it
20230628140440238 DTBF tbf.cpp:271 TBF(DL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){ASSIGN} free
...
20230628140440377 DTBFUL tbf_ul_fsm.c:169 UL_TBF(UL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){ASSIGN}: state_chg to FLOW
20230628140440377 DTBF tbf_dl.cpp:116 MS(IMSI-901700000015256:TLLI-0xd4d57c9d:TA-0:MSCLS-12-12:UL) Allocating DL TBF
20230628140440377 DTBFDL tbf_dl.cpp:475 DL_TBF(DL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){NEW}: Received Event ASSIGN_ADD_PACCH
20230628140440387 DTBF tbf_dl_ass_fsm.c:105 TBF(UL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){FLOW} start Packet Downlink Assignment (PACCH) for TBF(DL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){ASSIGN}
...
20230628140440816 DTBFDL bts.cpp:737 DL_TBF(DL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){FLOW}: Received Event ASSIGN_PCUIF_CNF
20230628140440816 DTBFDL bts.cpp:737 DL_TBF(DL:TFI-0-0-0:E:IMSI-901700000015256:TLLI-0xd4d57c9d){FLOW}: Event ASSIGN_PCUIF_CNF not permitted

Change-Id: I042b0117552acae25c750e762f5cc254399da64f
2023-06-29 14:53:37 +02:00
Pau Espin 11627ffaae tbf_dl_fsm: Ignore DL_ACKNACK_MISS events in WAIT_{RELEASE,REUSE_TFI} states
If in those states, we already left the FINISHED step which means we
already received a FinalACk previously, hence it means we are missing
requested retransmissions of the last DL ACK/NACK due to fn-advance
(several DL blocks in transit before receiving UL response).

Change-Id: Ib0f23a9cc3c614fe428b682e01502930cd2e478f
2023-06-29 14:46:40 +02:00
Pau Espin 747761f924 Avoid re-assigning DL TBF over PACCH upon duplicate FinalACKs received
Due to the fn-advance feature, we schedule DL blocks in advance, which
may make several retransmitted DL ACK/NACK [RRBP] be in flight, and
hence several of them may be answered by the MS.
When the first one is received, we attempt to initiate a PktDlAss over
PACCH if new DL data was received meanwhile from SGSN.
However, if we receive duplicates of that final PKT CTRL ACK, we don't
want to re-initiate it again, since it is already ongoing.

Related: OS#5471
Change-Id: Idc204aba61ad98f75853dcd46200f5dcc4139203
2023-06-29 14:42:33 +02:00
Pau Espin 40a297f3b0 Differentiate between T3192 and T3193
T3192 on the MS side (boadcasted by the network on SI13) is used for the
MS to stay monitoring the PDCH of a DL TBF after sending PKT DL ACK/NACK
for the last DL data block (FinalAck=1).
T3193 is the counterpart in the network, defined as >T3192, which is
used to make sure the TFI is no longer used by the MS and hence can be
reused/re-assigned again.

Hence, we want to differentiate between those 2 timers, since the first
one gives us information on how late can we still tx PktDlAss on PACCH
on that DL TBF, while the later only provides info on when to free the
DL TBF in order to reuse the TFI.

Change-Id: I7421342461bf159d945651037e6fe690f88c6fae
2023-06-20 12:07:45 +02:00
Pau Espin 95ec50c9e4 tbf_dl_fsm: Drop impossible event
When sending the last DL block, the FSM moves FLOW->FINISHED. Hence, it
is impossible to receive the FINAL_ACK in state flow, when we didn't yet
sent the last DL block (it's only possible if there's a bug in the MS).

TbfTest need to be adapted since they where acting wrong.

Change-Id: I3288743ff01ff84c3d345b6efb7c3fb6ca934791
2023-06-20 09:27:10 +00:00
Pau Espin 93b16ae02b Move call to bts_snd_dl_ass() from tbf_dl.cpp to tbf_dl_fsm.c
It makes more sense to have it there, where it is transmitted with more
control depending on current state. Furthermore, it's
counterpart/continuation TBF_EV_ASSIGN_PCUIF_CNF logic is already there,
so it makes sense to have the whole logic together.

Change-Id: I8af39d3087ccf197321f0c71cb29b67adbe1f36e
2023-06-13 13:31:10 +02:00
Pau Espin 9c46591682 cosmetic: tbf_dl_fsm: Fix a couple comment typos
Change-Id: I1bcb199f3ba9564870b82ab67218ffbf72da4824
2023-06-13 13:31:10 +02:00
Pau Espin 6d7167658e Move GPRS_RLCMAC_FLAG_DL_ACK from state_fsm to dl_tbf
That flag was still in state_fsm for historical reasons (refactoring
steps), but it's not really the best place for it, since it's really
specific to dl_tbf and to transmit of data and DL ACK/NACK not the
overall state of the TBF.

Change-Id: I12c28c1a52f363f2d17a8bc24bbdf379543fc7a6
2023-06-13 13:31:10 +02:00
Pau Espin 40b8dd55f1 tbf_{ul,dl}_fsm.c: Rearrange code/logs in mod_ass_type()
First print what is going to be attempted, later alarm about the
possible error, finally early return.

Change-Id: I417e9689f60e7f5d3c8ef67543e56fea87c8eebd
2023-06-13 12:53:11 +02:00
Pau Espin d4075bd1b8 tbf_{ul,dl}_fsm: Abort on unexpected path
That path should not really happen. It happening would mean a totally wrong
code being used. Hence, just abort() to simplify the code.

Change-Id: Iaf65e909e45cc279e5be4b045c15174f910ffc12
2023-06-13 12:53:01 +02:00
Pau Espin c41fb6eb7c tbf_dl_fsm: Fix wrong lchan specified in log line
Change-Id: I30111989c85001b0d9b98bf6f19c2247ab144433
2023-06-12 18:11:41 +02:00
Pau Espin e656c210a1 Remove unused GPRS_RLCMAC_FLAG_TO_MASK
We are no longer making use of the 4 high bits in state_flags, so we can
safely drop masking them.

Change-Id: I1402310919578a09669530786296f34bf3b23ef2
2023-06-12 17:28:27 +02:00
Pau Espin d8ad8ffbe5 tbf_dl_fsm: Remove T3169 references, simplify T3195 set up as consequence
T3169 is triggered as consequence of N3101 and N3103 reaching MAX. Those
counters are related to UL TBF only, and hence T3169 also only applies
to UL TBFs. The references to T3169 were there as a remains from time
where we had a single tbf_fsm for both UL and DL TBFs. It can now be
further simplified.

Change-Id: I02f7654518da617ce6704d807d34761dbadecf07
2023-06-09 18:39:00 +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 76ef66698c Mark several fsm related internal symbols as static
After some earlier refactoring, those fields are only used internally in
the module, and hence can be marked as static.

Change-Id: Ibf2a6ee5636ae7102ffd13b7497769652bcc3202
2023-01-30 10:42:44 +01:00
Pau Espin d1058b9445 Avoid moving DL-TBF from old_msg to new_ms during ms_merge
The DL-TBF assigned to another MS object may have a totally different
set of reserved resources (TS set, TRX, etc.), so one cannot simply move
those to the new MS. To start with, if the 2 MS are on different TRX it
is clear that one of them will not be really in operation. That's most
probably the DL-TBF being in ASSIGN state on CCCH waiting for PCUIF_CNF
and later X2002 to trigger to start sending DL blocks, but without
confirmation whether the MS is really there. Since the other new MS
object probably has a UL-TBF, that's the one probably operative, and
hence a new DL-TBF can be created at that same time and assigned through
UL-TBF's PACCH.

Unit test test_ms_merge_dl_tbf_different_trx showcases the above
scenario.

Related: SYS#6231
Related: OS#5700
Related: 677bebbe5c
Change-Id: Ie8cb49d5492cfc4cbf8340f3f376b0e6105e8c82
2022-12-19 12:32:44 +01:00
Pau Espin 4a09054dc0 Trigger PACCH assignment inside dl_tbf_upgrade_to_multislot()
The triggering of the assignment for the new TBF allocation is part of
the "upgrade to multislot" process, hence move that inside the function.

Change-Id: Ic2b959f2476b900cb263ccd8f6698ed843bafd29
2022-12-16 11:05:46 +00:00
Pau Espin b7a2b59c68 Refactor code related to DL-TBF upgrade to multislot
* Make clear the code relates to DL-TBF and not UL-TBF.
* Change wording to "upgrade" to match the existing field and API
  "tbf_can_upgrade_to_multislot()".
* Free the TBF if we cannot allocate new resources.

Change-Id: I0e4f8d7e46235a471b2124b280c81ff07b6967a4
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 343c0ee8d9 Split tbf_fsm as tbf_{ul,dl}_fsm
The 2 types of TBF share some parts of the implementation, but actually
half of the code is specific to one direction or another.
Since FSM are becoming (and will become even) more complex, split the
FSM implementation into 2 separate FSMs, one for each direction.
The FSM interface is kept compatible (events and states), hence code can
still operate on the tbfs on events and states which are shared.

Test output changes are mainly due to:
* FSM instance now created in subclass constructor, so order of log
  lines during constructor of parent class and subclass slightly
  changes.
* osmo_fsm doesn't allow having 2 FSM types with same name registered,
  hence the "TBF" name has to be changed to "DL_TBF" and "UL_TBF" for
  each FSM class.
* FSM classes now use DTBFUL and DTBFDL instead of DTBF for logging. Some
  tests don't have those categories enabled, hence some log lines
  dissappear (it's actually fine we don't care about those in the test
  cases).

Change-Id: I879af3f4b3e330687d498cd59f5f4933d6ca56f0
2022-11-18 16:54:20 +01:00