aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2022-12-19Avoid moving DL-TBF from old_msg to new_ms during ms_merge2023q1Pau Espin Pedrol4-61/+98
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: 677bebbe5c49d4607322e96053fe14ddd78d9549 Change-Id: Ie8cb49d5492cfc4cbf8340f3f376b0e6105e8c82
2022-12-19tests/TbfTest: reproduce buggy corner case: MS with TBFs on 2 TRXsPau Espin Pedrol2-0/+207
Add a test which showcases a scenario where the PCU ends up with 1 GprsMs object holding a DL-TBF in a weird condition half in one TRX and half in other due to ms_merge(). This test (slightly adapted) used to cause a crash in osmo-pcu.git 586ddda9bc09d60f2d491158de843825cb7c876a (a few versions behind current master). Related: SYS#6231 Change-Id: Ic16b5e96debf91e72684833cd64253687857f3aa
2022-12-16bts: Adapt trx check based on bts->trx[] defined array sizePau Espin Pedrol1-1/+1
This way the code is not hardcoded to 8 TRX. Related: OS#5827 Change-Id: I5ccb5ec27bc189d17c62e7f2a59fae0b3bddf8e3
2022-12-16Pass gprc_rlcmac_pdch to tbf_set_pollingPau Espin Pedrol7-17/+11
Change-Id: I5ecc57c72e7f60e31e64e76e724d7a5a95968c40
2022-12-16Pass gprc_rlcmac_pdch to tbf_check_pollingPau Espin Pedrol7-32/+28
Change-Id: I1c7140b35b7c93d3df4156841e908d3b44d7336d
2022-12-16Pass gprs_rlcmac_pdch to create_dl_acked_block()Pau Espin Pedrol4-15/+17
This allows having full TS information, not only ts_no, which will be needed later on followup patches. Change-Id: I1efccb32c5afa4fe62233bf114ea95b6fbbe1a06
2022-12-16tests/tbf: test_tbf_dl_llc_loss(): Fix wrong param passed and wrong expectanciesPau Espin Pedrol2-6/+10
The DL-TBF in the test gets its TS allocated on TS4 (only that one is enabled through setup_bts(bts, ts_no=4)), and hence it makes no sense to ask it to send data on TS7. Change-Id: Ibe6fc073b7438b8024c4d3ddb0e60c6112752351
2022-12-16Convert tbf->control_ts to be a gprs_rlcmac_pdch*Pau Espin Pedrol10-51491/+51486
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-16tbf: Fix typo in define usedPau Espin Pedrol1-1/+1
Change-Id: I1d85cba17fc1ee70a063ed03c7707876e1349515
2022-12-16pdch: Introduce APIs to print PDCH namePau Espin Pedrol2-3/+17
This will allow printing PDCH with same formatting outside of LOGPDCH. Change-Id: If18cb4a48237751e0dddede6793191b36dfe386d
2022-12-16Rename gprs_rlcmac_ts_alloc.cpp -> alloc_algo.cpp & create own .h filePau Espin Pedrol14-13/+58
First commit towards trying to have alloc algorithm as isolated as possible from others parts of the code trying to avoid state changes on data structures. Change name also because the alloc_algo not only allocated TS, but TFIs and USFs. Change-Id: I33a6c178c64a769f05d3880a69c38acb154afa62
2022-12-16Convert ms_first_common_ts to struct gprs_rlcmac_pdchPau Espin Pedrol8-34/+40
This way it contains full information about the TS, not only the TN. Change-Id: I19373939ec104d371e3e91422f018a8175cb0f89
2022-12-16bts: Adapt slot_mask to trx defined array sizePau Espin Pedrol1-1/+1
struct gprs_rlcmac_bts still hardcodes it to 8, but using ARRAY_SIZE there should aim at seeing the relation between those, and avoid having one updated without the other. Related: OS#5827 Change-Id: I165588ba10d8528a9a496175d8dfe9d902c89e55
2022-12-16Refactor code rejecting UL-TBF upon rx of PktResourceReqPau Espin Pedrol6-12/+27
* Make it similar to the already existing TBF allocation procedures * Pass pdch pointer instead of trx and ts numbers Change-Id: I04b3b65942732cc652adeaa507529b849292ff61
2022-12-16tbf_ul: Fix wrong struct type in fieldPau Espin Pedrol1-1/+1
This typo was harmless so far because both old and new structures have the exact same content. Change-Id: If2e20128a589a25b9dc3fd08340cdb92aad158c3
2022-12-16Trigger PACCH assignment inside dl_tbf_upgrade_to_multislot()Pau Espin Pedrol4-23564/+47122
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-16Refactor code related to DL-TBF upgrade to multislotPau Espin Pedrol8-58/+55
* 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-16Get rid of tbf->first_tsPau Espin Pedrol7-22/+47
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-16Move first_common_ts from gprs_rlcmac_tbf to GprsMsPau Espin Pedrol8-40/+33
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-14pcuif_proto: use define constant to specify nax number of trxPhilipp Maier1-1/+2
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-13sched: Pass pdch to *_create_rlcmac_msg() functionsPau Espin Pedrol12-50/+60
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-13Move control_ts explicit checks out of the scheduler implementationPau Espin Pedrol9-24/+46
Let each subsystem handle that internally. Change-Id: Ifaf7dde651d56942779d84aa9135fc8c974b6f26
2022-12-12tbf_dl_fsm_ctx: Properly define tbf backptr as dl_tbfPau Espin Pedrol5-33/+35
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-12tbf_ul_fsm_ctx: Properly define tbf backptr as ul_tbfPau Espin Pedrol3-21/+24
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-12encoding::write_immediate_assignment(): Constify tbf paramPau Espin Pedrol2-8/+8
Change-Id: Ic0b6e81dbeb44f200065dba92cadc33fa52ae75d
2022-12-12Pass pdch ptr to tbf_compute_priorityPau Espin Pedrol1-6/+6
Change-Id: Idbac59343c4bac3214ecd8a14c201b4e42c74557
2022-12-12Pass gprs_rlcmac_pdch to tbf_is_control_tsPau Espin Pedrol5-18/+12
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-12pdch_ulc_get_node(): assert if ulc pointer is nullPau Espin Pedrol1-0/+1
Make crah more obvious if this condition is reached. Related: SYS#6231 Change-Id: I2689ceaf39009c5e708d5c72e41744658681c917
2022-11-29pdch: Initial support Handling PktResReq with ID_TYPE=UL/DL_TFIPau Espin Pedrol1-142/+169
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-21Convert gprs_debug.cpp to CPau Espin Pedrol4-8/+8
Change-Id: I142b870abda36950db5ff296c7c22228b0b11f55
2022-11-18Split tbf_fsm as tbf_{ul,dl}_fsmPau Espin Pedrol15-100908/+1472
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-18Refactor tbf_is_tfi_assigned() to avoid accessing tbf->state_fsmPau Espin Pedrol3-14/+15
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-18tbf: Add tbf_as_{ul,dl}_tbf_const func helpersPau Espin Pedrol4-0/+18
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-18tbf: Drop unused functionPau Espin Pedrol1-11/+0
Change-Id: I5d4b411585321d94fefdd01f22c62932d4a8f83a
2022-11-18tbf_fsm: Move osmo_fsm_inst fi out of struct tbf_fsm_ctxPau Espin Pedrol9-38/+39
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-18tbf_fsm: Move tbf_fsm_state_chg macro to .c filePau Espin Pedrol2-10/+9
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-17constify pdch_ulc_get_next_free_fn() parameterMax2-2/+2
Change-Id: I91738f951f57bd171d8cbd66fe5e5c46e6fa953b
2022-11-17cosmetic: drop duplicated commentMax1-1/+1
Change-Id: Id349fbfe683b7b63ac9076d2e9998f7c3ecea112
2022-11-17cosmetic: drop unused field from struct pdch_ulcMax1-1/+0
Change-Id: Icf6204d99f91531f5ecad05e3f9f89406e5d12b5
2022-11-14Update and document realtime scheduling priority in service fileMax1-3/+4
Related: OS#5687 Change-Id: I1694af74eee2624709ad6cebbc4fb37320e2ef9d
2022-11-11update horribly outdated copyright statement on VTYHarald Welte1-2/+2
Change-Id: I26cda7826e9d648ea086bb408293e431a9cac206
2022-11-09Makefile.am: drop unneeded '-ldl -pthread' from AM_CXXFLAGSVadim Yanitskiy1-1/+1
Change-Id: I833864aa51059be9c97c16329bc16913c53e171d
2022-11-03Disable logging fsm addressesPau Espin Pedrol1-0/+1
FSM IDs are properly updated now, so there's no need for the pointer address to properly follow them. Change-Id: Ia48c6d5afcdd95e32c7c9b327774f78f07342a0f
2022-11-03Improve MS loggingPau Espin Pedrol7-51446/+51455
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-03Improve TBF loggingPau Espin Pedrol9-303588/+303611
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-01tbf_ul: Assign DL-TBF if needed after UL-TBF has gone over contenion resolutionPau Espin Pedrol1-0/+6
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-10-31tbf_fsm: Introduce new event to act upon contention resolution successPau Espin Pedrol5-9/+22
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-31Avoid losing DL-TBF during MS mergePau Espin Pedrol5-26/+81
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-31tbf_fsm: Introduce new event TBF_EV_FIRST_UL_DATA_RECVDPau Espin Pedrol5-5/+27
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-31Rework tbf::update_ms()Pau Espin Pedrol10-44/+63
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