Commit Graph

446 Commits

Author SHA1 Message Date
Pau Espin c1b0a37610 tbf: Log poll timeout reason
Change-Id: Ie0339b55e6d617a3e788972c3b226eef64124d2b
2023-09-15 10:04:30 +00:00
Pau Espin e5ba83d3f7 Change several log lines to start with capital letter
Change-Id: I98c59dd833b3d0ada5b1ffdba7a5fc2e8cbf6241
2023-06-13 17:20:38 +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 bb34ffaaf7 Move GPRS_RLCMAC_FLAG_TO_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: I6b44121bbe185b58f3a77be8c12b4ef1f3180a30
2023-06-13 13:30:45 +02:00
Pau Espin 365728d579 Avoid using N3105 in UL TBFs
This counter is only used in DL TBFs as per TS 44.060.
section 13.4 "N3105":
"When the network after sending a RRBP field in the _downlink RLC data block_ ..."
(DL data blocks are only sent in DL TBFs).

section 8.1.2.1:
"If N3105 = N3105max, the network shall release the downlink TBF internally
and start timer T3195 for that TBF. When T3195 expires, the network may reuse
the TFI"

Change-Id: I4d4f4d4d3e6e0539ea8ec2395bed00d059b84e04
2023-06-09 18:38:28 +02:00
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 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
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 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 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 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 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 8bb176fdcb tbf: Increase log level if polling requested in wrong TS
Change-Id: I641bddcb4027ecc9cc1ec66d4d6b9b483c94c617
2023-03-07 17:08:47 +01:00
Pau Espin 5b7eeecac2 Pass gprc_rlcmac_pdch to tbf_set_polling
Change-Id: I5ecc57c72e7f60e31e64e76e724d7a5a95968c40
2022-12-16 12:11:31 +01:00
Pau Espin fd74e79ab3 Pass gprc_rlcmac_pdch to tbf_check_polling
Change-Id: I1c7140b35b7c93d3df4156841e908d3b44d7336d
2022-12-16 12:11:31 +01:00
Pau Espin e2ed40d02b Convert tbf->control_ts to be a gprs_rlcmac_pdch*
This allows having full information on the control TS easily reachable
(like TRX ofthe PDCH), and makes it easy to compare TS by simply
matching the pointer address.

Change-Id: I6a97b6528b2f9d78dfbca8fb97ab7c621f777fc7
2022-12-16 12:11:31 +01:00
Pau Espin 02aeba47df tbf: Fix typo in define used
Change-Id: I1d85cba17fc1ee70a063ed03c7707876e1349515
2022-12-16 12:11:31 +01:00
Pau Espin 9935d0d21d Convert ms_first_common_ts to struct gprs_rlcmac_pdch
This way it contains full information about the TS, not only the TN.

Change-Id: I19373939ec104d371e3e91422f018a8175cb0f89
2022-12-16 12:08:07 +01: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
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 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 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 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 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 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 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 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 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
Pau Espin bd1f01fd27 Fix mess with struct tbf types passed to LOGPTBF macro
It is quite common in all osmo-pcu code to have to convert between
parent class "tbf" and children "dl_tbf"/"ul_tbf", or other way around.
This commit adds new helper static inline functions to cast between
those while doing type checks.
This is used by new LOGPTBFDL and LOGPTBFUL macros to now expect the
proper subclass and cast securely inside the macro itself, hence sparing
all code calling those macros to have to cast explicitly the pointer to
the parent "tbf" class.

Change-Id: I7e4489ad4b93c9c8442213947e53c10b61fdc5e9
2022-10-28 15:14:44 +02:00
Pau Espin 8757384aec Rename tbf_alloc_dl_tbf() -> dl_tbf_alloc()
Rename it so that it follows the usual prefix for the type it allocates.

Change-Id: I7d30a85fefaa61d100fbd51af4601a3cf7de2159
2022-10-27 13:53:03 +02:00
Pau Espin 14beef6cfe Move LLC enqueuing and retransmit timer to MS object
The LLC queue is already in the MS object. The LLC timer and most
of the logic to enqueue its data is independent from the TBF.

Change-Id: I56b89fcac838d8eb732b629734d5e458e9c806d1
2022-10-27 13:52:59 +02: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 de8eb7bb33 cosmetic: Update reference to func renamed in the past
Fixes: 8a35e640a3
Change-Id: I86d1fa1f3ea96ca06f3e8c8f07b8d5b14cf098c7
2022-10-21 13:20:01 +02:00
Pau Espin 4f8384bfbb llc: Convert to C
There's no real reason (other than historical) why code in llc should be
kept as c++ code. Let's rewrite it as C so that it can be included by
existing C code without having to add C->C++ shim, ifdefs all around,
etc.
This simplifies code and easies modification/improvement of the related
objects.

Change-Id: I250680ba581167d7398b2f734769c756cbb61c48
2022-03-31 19:42:15 +02:00
Oliver Smith 8d03c50024 treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I4a49dbeeec89b22624c968152118aecf8886dac6
2021-12-14 12:19:13 +01:00
Pau Espin f61acd75c4 cosmetic: Add parenthesis around expression to clarify it
Change-Id: I621ef02868aff2bd23d82c8bc70e5cdbc391fbc2
2021-11-08 16:34:17 +01:00
Pau Espin dbd3b78a9b tbf_ul: Update FSM names for dummy reject TBFs
This allows easily identifying dummt TBFs created to send assignment
rejects.

Change-Id: I73a197795a9c8e9cd8dc06bf46ddb8f275d2c289
2021-11-08 16:33:51 +01:00
Pau Espin a02f945479 tbf: Set tfi to initial special value
This allows distinguishing when a TBF didn't set the TFI. Useful to
identify dummy reject TBFs, etc, and make sure a non-dummy TBF set its
TFI properly.

Change-Id: Iecf54a24041bd14f4ef5b86e57c3732e1b69d463
2021-11-08 13:24:20 +01:00
Pau Espin d3d46de278 tbf: Mark initial first_(common_)ts with special value
This way it's easier to distinguish when this value was not properly
filled when debugging or looking at logs.

Change-Id: I0c9c9fdcfca9eb15125ea49efcbb76711850052e
2021-11-08 13:24:20 +01:00
Pau Espin de0eeafd2e tbf: Set m_created_ts in constructor
This way the timestamp is also set for dummy reject TBFs. For other
TBFs, setup() is called immediatelly after calling the constructor, so
we are fine too.

Change-Id: I2966ec7f3f9161d528a173d94797b72d1398c747
2021-11-08 13:24:20 +01:00
Pau Espin b6babc39dc tbf: Increase log level of line about unable to allocate poll for TBF
Change-Id: I0bd972d3b68017f12a0816a27162e3a409b1893a
2021-11-08 13:24:19 +01:00
Pau Espin affd6a7f7a tbf: Drop unneeded braces in one line condition
Change-Id: Ief5e0ea0b7146d3330a17d5f0d171755b576fca3
2021-10-18 16:44:19 +02:00