Commit Graph

2232 Commits

Author SHA1 Message Date
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 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 345d9ad1b3 Move first_common_ts from gprs_rlcmac_tbf to GprsMs
The field contains a common value between the 2 active TBFs of the MS,
so it makes no sense to have them duplicated on each TBF. It can be
sanely stored in the MS object.

Change-Id: I8df01a99ccbfaf7a442ade5000ee282bd638fbba
2022-12-16 11:05:46 +00:00
Philipp Maier 44347efacd pcuif_proto: use define constant to specify nax number of trx
The array of trx in gsm_pcu_if_info_ind can hold trx 8 items. Lets use a
define constant to specify the size of that array.

Change-Id: I2b12fd562ff867188a37e701bba1ad5de904f9bd
2022-12-14 16:05:02 +00:00
Pau Espin 5ba3ef9a2b sched: Pass pdch to *_create_rlcmac_msg() functions
The pdch pointer contains more info than just timeslot number. For
instance, it contains information about the TRX owning the TS.

Change-Id: Ic31a7360a29e61f70bb1338ddab6f5f31aa8b26e
2022-12-13 12:20:02 +01:00
Pau Espin 106f2a02c5 Move control_ts explicit checks out of the scheduler implementation
Let each subsystem handle that internally.

Change-Id: Ifaf7dde651d56942779d84aa9135fc8c974b6f26
2022-12-13 12:17:07 +01: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 cdc762a591 tbf_ul_fsm_ctx: Properly define tbf backptr as ul_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: I7741d524a14437caf4c92b9c09e19762eb272e30
2022-12-12 20:09:36 +01:00
Pau Espin cefddbc913 encoding::write_immediate_assignment(): Constify tbf param
Change-Id: Ic0b6e81dbeb44f200065dba92cadc33fa52ae75d
2022-12-12 19:48:34 +01:00
Pau Espin 7e1fec20c0 Pass pdch ptr to tbf_compute_priority
Change-Id: Idbac59343c4bac3214ecd8a14c201b4e42c74557
2022-12-12 16:56:32 +01:00
Pau Espin e87576984e Pass gprs_rlcmac_pdch to tbf_is_control_ts
This will allow also validate easily the TRX is the correct one too, not
only the TS number in any random TRX.

Change-Id: Ib1a62b6e7b465253ee7cba63bf5e277f8aa8eaea
2022-12-12 16:18:07 +01:00
Pau Espin b5fa1aad7c pdch_ulc_get_node(): assert if ulc pointer is null
Make crah more obvious if this condition is reached.

Related: SYS#6231
Change-Id: I2689ceaf39009c5e708d5c72e41744658681c917
2022-12-12 12:29:30 +01:00
Pau Espin 586ddda9bc pdch: Initial support Handling PktResReq with ID_TYPE=UL/DL_TFI
This patch refactors rcv_resource_request() in several ways:
* Move the ID_TYPE=DL/UL_TFI  handling at the start of the function, so
  that the function is split in 2 sections: First section gathers a
  GprsMS object from the ID_TYPE in the PktResReq. Second section
  handles the packet for the GprsMS based on the expectd ULC slot.
* Initial handling of PktResReq when transmitted by the MS on the UL-TBF
  as an answer to USF. This case is basically the one where the MS
  wishes to change some parameters of the currently active UL-TBF.
  In order to do so, for now simply delete the current TBF and re-create
  a new one to triger the PktUlAss which is expected by the MS.
  This behavior is not entirely correct since in this case the MS is
  expected to keep using actively the old TBF until the PktUlAss is
  received, so in this case ideally we should be keeping the TBF object
  and simply upgrading it and using itself to trigger a PktUlAss in its
  ul_tbf->ul_ass_fsm. Doing this however requires far more work, so it
  can be done later as an incremental step fix. The current behavior is
  alreday better than the previous one, since the MS has been tested to
  be PKT_CTRL_ACKing the PKT_UL_ASS and continuing to use the new TBF.

Related: OS#4947
Change-Id: Ie6b1b438d26cd977f88ddb4eff6b3041e0739d92
2022-11-29 16:36:54 +01:00
Pau Espin 4f29fe7d1f Convert gprs_debug.cpp to C
Change-Id: I142b870abda36950db5ff296c7c22228b0b11f55
2022-11-21 14:05:26 +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
Pau Espin c6e4aeff95 Refactor tbf_is_tfi_assigned() to avoid accessing tbf->state_fsm
The state_fsm field will be moved to subclass (DL_TBF/UL_TBF) in a
follow up commit when splitting the tbf_fsm.c implementation per
subclass.
Rearrange a bit the code to access the using the subclass pointer in the
only sublcass where it needs to be used (DL_TBF).

Change-Id: I360485c73be8636565f89ba29796d84ac94fd94e
2022-11-18 14:16:56 +01:00
Pau Espin 1e1275faee tbf: Add tbf_as_{ul,dl}_tbf_const func helpers
This way we can easily get the subclass from the parent if the pointer
is const. Similar to what we already have for the opposite direction
{ul,dl}_tbf_as_tbf_const().

Change-Id: I35e650d13ecf3a5020d136e7d8d99837786503e2
2022-11-18 14:16:56 +01:00
Pau Espin ac9ee9aa8d tbf: Drop unused function
Change-Id: I5d4b411585321d94fefdd01f22c62932d4a8f83a
2022-11-18 14:16:56 +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 06abd3ea19 tbf_fsm: Move tbf_fsm_state_chg macro to .c file
It is nowadays only used internally, hence it can be moved to the .c file
to better describe its scope.

Change-Id: I23cfa5b7efbeb6a58855099780749741c9c947e9
2022-11-18 14:16:55 +01:00
Max dc6a860d0a constify pdch_ulc_get_next_free_fn() parameter
Change-Id: I91738f951f57bd171d8cbd66fe5e5c46e6fa953b
2022-11-17 19:32:40 +03:00
Max 36342f4181 cosmetic: drop duplicated comment
Change-Id: Id349fbfe683b7b63ac9076d2e9998f7c3ecea112
2022-11-17 19:32:40 +03:00
Max 477178dc63 cosmetic: drop unused field from struct pdch_ulc
Change-Id: Icf6204d99f91531f5ecad05e3f9f89406e5d12b5
2022-11-17 19:32:40 +03:00
Max 1002c4330d Update and document realtime scheduling priority in service file
Related: OS#5687
Change-Id: I1694af74eee2624709ad6cebbc4fb37320e2ef9d
2022-11-14 10:18:38 +00:00
Harald Welte f94562a622 update horribly outdated copyright statement on VTY
Change-Id: I26cda7826e9d648ea086bb408293e431a9cac206
2022-11-11 18:20:07 +01:00
Vadim Yanitskiy 3cf9d536ed Makefile.am: drop unneeded '-ldl -pthread' from AM_CXXFLAGS
Change-Id: I833864aa51059be9c97c16329bc16913c53e171d
2022-11-09 03:15:59 +07:00
Pau Espin 38a9a25a70 Disable logging fsm addresses
FSM IDs are properly updated now, so there's no need for the pointer
address to properly follow them.

Change-Id: Ia48c6d5afcdd95e32c7c9b327774f78f07342a0f
2022-11-03 18:12:47 +01:00
Pau Espin 94f8258de7 Improve MS logging
Use same formatting similar to what's now used in TBF, which is far more
easy to grep and follow. This way one can easily follow what happens to
a given IMSI, a give TFI, a given TLLI, etc.

Change-Id: If9b325764c8fd540d60b6419f32223fd7f5a5898
2022-11-03 18:12:06 +01:00
Pau Espin 57843c571a Improve TBF logging
use a format in tbf::name() which is sanitized (osmo_sanitize) and hence
can be used both in regular log as well as for its internal FSM ids.
Until now, the FSMs contained a small amount of information with
different formatting than the regular LOGPTFB(), which made it difficult
to grep or follow a TBF through its lifetime looking at logs. The new
unified format makes that a lot easier.

Extra information is now printed if available, such as IMSI.
Furthermore, the TFI is updated to include BTS and TRX, since the TFI is
unique within the scope of a TRX.

Change-Id: I3ce1f53942a2f881d0adadd6e5643f5cdf6e31da
2022-11-03 13:58:57 +01:00
Pau Espin 01dfe04c37 tbf_ul: Assign DL-TBF if needed after UL-TBF has gone over contenion resolution
If data received from SGSN is waiting to be sent to the MS, we may have
created a DL-TBF assignment over PCH if the MS was not in packet-active
mode. If the MS instead reaches back to the PCU asking for an UL-TBF, the
PCU has to wait until Content Resolution of the UL-TBF has succeeded in order
to attempt now to assign the DL-TBF over PACCH.
The delay was already there, but the trigger to attempt the DL-TBF
assignment upon UL-TBF contention reslution success was missing.

Related: OS#5700
Change-Id: Ib8f7ad2390485ce9fd76a9de6cd349a5f4037568
2022-11-01 17:12:34 +01:00
Pau Espin f38a47ee01 tbf_fsm: Introduce new event to act upon contention resolution success
This is a preparation towards fixing MS not recreating a DL-TBF (being
assigned on CCCH) when MS starts an UL-TBF and finishes contention
resolution.

A counter is removed which was counting contention resolution (MS) on
the wrong place.

Change-Id: I8b9555864d3615ce0a024b641c67921f82273a8d
2022-10-31 22:07:31 +01:00
Pau Espin 677bebbe5c Avoid losing DL-TBF during MS merge
It is desired to free pending DL-TBF under some scenarios, which somehow
are related to those where we call the ms_merge() procedure since it's at
time an MS can be identified when coming from packet-idle state.

Until now, the freeing of those DL-TBFs happen because the ms_merge()
procedure doesn't migrate DL-TBF from "old_ms" to "ms". This was done
manually under the cases where it was deemed necessary before calling
the ms_merge() procedure 8because old_ms and its tbfs are gone after
returning from it).
This logic, though convinient for the specific cases at hand, is quite
confusing for readers and program execution since one would expect the
ms merge to, well, merge everything.

Therefore, this patch changes the ms_merge() logic to always merge the
DL-TBF, and only under the specific cases where it makes sense to free
it, do so explicitly after MS merge, where all the info has been updated
and united.
2 code paths are now explicitly freeing the existing DL-TBF when needed:
- TBF_EV_FIRST_UL_DATA_RECVD: 1st data (containing TLLI) is
  received from MS, hence identifyng the MS and potentially having been
  merged with some old MS which used to have a DL-TBF, most probably in
  process of being assigned through CCCH (PCH). This event is triggered
  during MS using 1phase-access, and we should drop the exsitng DL-TBF
  because MS just came from packet-idle mode (CCCH).
- rcv_resource_request(): PktResourceRequest is received at an scheduled
  SBA, meaning the MS is doing 2phase-access, meaning MS also came from
  packet-idle mode (CCCH), so previous DL-TBF can be dropped.

Related: OS#5700
Change-Id: I29f4ffa904d79d58275c6596cc5ef6790b6e68c6
2022-10-31 22:07:31 +01:00
Pau Espin 338a5ae770 tbf_fsm: Introduce new event TBF_EV_FIRST_UL_DATA_RECVD
This allows easier tracking of this event. It will also extended later
on with more logic which is better placed in tbf_fsm.

Change-Id: I5c935914e13db3928c32621ec04eb2760367615d
2022-10-31 22:07:31 +01:00
Pau Espin 8abe13cf75 Rework tbf::update_ms()
That function was pretty confusing since it used a "enum
gprs_rlcmac_tbf_direction dir" param (whose type is expected to describe
the data direction of a TBF) to describe the direction of the the packet
which triggered its call.
The parameter was actually always called with "GPRS_RLCMAC_UL_TBF" which
in this case meant "uplink direction" which meant "TLLI was updated from
the MS, not the SGSN".
The DL direction was only used in unit tests, which can hence be simply
replaced by ms_confirm_tlli(), which this commit does.
So this update_ms() function was actually used in practice in osmo-pcu
to trigger update of TLLI and find duplicates only when an RLCMAC block
(control or data) was received from the MS. Therefore, this function is
renamed in this patch and moved to the gprs_ms class, since it really
does nothing with the TBF.

Related: OS#5700
Change-Id: I1b7c0fde15b9bb8a973068994dbe972285ad0aff
2022-10-31 22:07:31 +01:00
Pau Espin bda7bb7667 Rename tbf_alloc_ul_tbf -> ul_tbf_alloc
Use proper prefix according to the type being allocated.

Change-Id: Ic98c3c852c96c3f52f1c8f531b8d0fd28ce5aef5
2022-10-31 22:07:31 +01:00
Pau Espin b8ff74b37a gprs_ms: Add comment warning the user that a ptr may be freed after call to func
Change-Id: Ifa3d6b38fca89500ef02c9b972f514ceaf8fe83b
2022-10-31 22:07:31 +01:00
Pau Espin 32416fdcde Join ms_merge_and_clear_ms() and ms_merge_old_ms()
While at it, improve logging of the merge action

Change-Id: I39d9eac159448fc3c3a4db9e1b9c5364e906a78f
2022-10-31 22:07:31 +01:00
Pau Espin 76363e4334 update_ms(): Set TLLI of new MS object before merge with old MS
This way it becomes clearer in logs that we are merging MS which
contains the same TLLI.

Change-Id: Ifd232daa4219e1726c30449d647312a3a226a61d
2022-10-31 22:07:31 +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 3f33929119 tbf_fsm: Identify several events as Dl-TBF only
This will help in the future when splitting tbf_fsm into different FSMs
for UL-TBF and DL-TBF, since only some of the events and states are
shared.
That means we can keep a single state and event enum, but the FSMs can
be implemented separately in different files, easing a lot extending and
understanding the logic.

Change-Id: Id97f0d532d2d7ab2791a35c1f836d7c8da050124
2022-10-31 22:07:18 +01:00
Pau Espin 0f85956991 ul_tbf: Define m_contention_resolution_done as bool
Change-Id: Ief048cc1b5e8a18ceaeb5432415d14f5ef7ee0ea
2022-10-31 10:51:20 +01:00
Pau Espin 091642a8f5 Replace tbf->establish_dl_tbf_on_pacch() refactoring GprsMs functions
ms_new_dl_tbf_assignment() is split into 2 functions, one to
allocate+assign on PACCH and another one for PCH.
This makes a lot clearer the aim of each caller of the function.
Once this is done, it becomes obvious tbf->establish_dl_tbf_on_pacch()
is basically doing the same as ms_new_dl_tbf_assigned_on_pacch() so drop
it.

Change-Id: I610210e3120c962d91ce8ff94c66161e086761ba
2022-10-28 18:13:41 +02:00
Pau Espin 8fa3e063f5 Rename function tbf_dl_request_dl_ack() -> dl_tbf_request_dl_ack()
Use the dl_tbf prefix which is usually used to easily distinguish from
"ul_tbf" specific APIs and "tbf" generic (parent class) APIs.

Change-Id: Ibf6ae20da99866af5f2b6e12184f3145d1fc0bbf
2022-10-28 17:40:29 +02:00
Pau Espin ee35008037 Refactor and clarify tbf->triger_ass() code
Split the function into 2 functions, one for assignment on PACCH and one
for assignment on PCH. This makes code calling this API far more clearer
on what is the exact aim when assigning the TBF.

Change-Id: Ic92867e55337b0bd6b5bfc97f13b7982eedb1cb7
2022-10-28 17:35:06 +02:00
Pau Espin 22b26d8a1c Delay ImmAss(PCH, PktDlAss) if waiting for PKT_CTRL_ACK answering UL_ACK_NACK (FinACK=1)
In that state (ul_tbf=TBF_ST_FINISHED), we are unable to reach the MS to
assign a new DL TBF.
* MS Is not available in CCCH because it's attached the PDCH.
* MS won't be able to PKT_CTRL_ACK a PktDlAss on PACCH, because next
  thing it will do is to PKT_CTRL_ACK the UL_ACK_NACK(FINACK=1) we
  already polled it for, and immediatelly after that it will release the
  UL TBF on its side and go back to packet idle mode.

Hence, we must wait for MS to send the PKT_CTRL_ACK to us in order to be
able to assign the DL TBF in PCH (CCCH).

Related: OS#5700
Change-Id: I7a30db9cc7dae70e04054f1a4dba004bd1780d4a
2022-10-28 16:33:45 +02:00
Pau Espin 3a7af57d03 rcv_resource_request(): Update meas before allocating and assigning new UL TBF
Those power params are applied in the Pkt Ul Ass sent to the
MS.
In practice it doesn't matter much because the Pkt Ul Ass message is
created later asynchronously by the scheduler (event CREATE_RLCMAC_MSG).
Still it's much cleaner applying the information before allocating the
UL-TBF, since that's an extra independent step.

Change-Id: I63133aa42dcf27a86437b1bc8dc83c30d6718028
2022-10-28 16:17:54 +02:00
Pau Espin 5c516fdbd2 encoding: Use MT_PACKET_UPLINK_ASSIGNMENT define instead of hardcoded value
Change-Id: I05b39d3183fdf741d648a15ff803d20e324443af
2022-10-28 15:46:41 +02:00
Pau Espin 1e81b2e0a4 rcv_resource_request(): Validate expected message before MS lookup & allocation
There's no sense if doing the lookup and allocation if the message is
not expected, it will be unrefed (freed) afterwards anyway.
Moreover, this way we avoid doing stuff for the WIP code paths which act
on different request ID than TLLI.

Change-Id: I4be8858230a2eebdb33260093d082a005cb9fcd4
2022-10-28 15:39:37 +02:00
Pau Espin 36ada89373 pdch: Use helper function tbf_as_ul_tbf()
Change-Id: Ie2a0af7928578823e944b85781ce284722547661
2022-10-28 15:14:44 +02:00