aboutsummaryrefslogtreecommitdiffstats
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2023-04-21ms: Rename field timer -> release_timerPau Espin Pedrol1-1/+1
Rename it so that it becomes clear what the timer is used for. Change-Id: Id4738ea196b232858e1ec9cdc439f9b81839058f
2023-04-21ms: Get rid of ms->delay fieldPau Espin Pedrol4-5/+9
Simply apply the content of the configured timer when the MS goes idle. Having that field is convenient to do tricky stuff in unit tests, but makes the main osmo-pcu app more complex for no good enough reason. Change-Id: I8d44318b37b6605afd84db8ccec0d75e6db293b9
2023-04-21ms: Increase log level when scheduling release timerPau Espin Pedrol1-0/+1
Change-Id: Ie470b5b0c7b01d91f4ad693e52afd51860d6da2d
2023-04-21Add new log category 'ms'Pau Espin Pedrol4-4/+4
This is useful to track the lifecycle of MS objects. The RLCMAC cateogry used so far in those log messages is too broad. Change-Id: Ib4ce88d0f7309ac77c064a94bb0d667e8dbc33dd
2023-04-21ms: Hold a reference during ms_allocPau Espin Pedrol9-93/+217
Make the caller hold a reference to the MS object just allocated, so that it hs to explicitly unref it and, in turn, if no new references were added during its use, trigger release of the MS object. This is useful to avoid leaking MS object if it was allocated and then no TBF is attached to it because allocation of TBF failed. Related: OS#6002 Change-Id: I2088a7ddd76fe9157b6626ef96ae4315e88779ea
2023-04-21tbf: Move enable_egprs() to constructorPau Espin Pedrol1-9/+9
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-20ms: Rewrite MS release lifecyclePau Espin Pedrol8-449/+306
This commit changes lots of stuff in the MS release lifecycle, but there's no really good way to split this into patches which make sense, since all the chaos is intensively entangled. Get rid of the ms_callback complex mess, it is not needed at all. Previous MS release was strange due to the existance of previous ms_callback.idle concept and MS storage: the MS signalled when it went idle (no TBFs attached) and waited for somebody outside to free it, while then arming itself the release timer to release itself if it was not released by whoever. The new lifecycle follows an easier (expected) approach: Whenever all TBFs become detached from the MS and it becomes idle (use_count becomes 0), then it frees its reserved resources (TFI, etc.) and either: * frees itself immediatelly under certain conditions (release timeout configured = 0 or MS garbage with TLLI=GSM_RESERVED_TMSI) * Arms release_timer and frees itself when it triggers. If during release_timer the MS is required again (for instance because a new TBF with TLLI/IMSI of the MS is observed), then a TBF is attached to the MS and it is considered to become active again, hence the release_timer is stopped. OS#6002 Change-Id: Ibe5115bc15bb4d76026918adc1be79469c2f4839
2023-04-20ms: Log detaching tbf log line in proper placePau Espin Pedrol4-129/+129
It is interesting to log that a tbf is being detached *before* it actually happens, so that the reader can see which TBF is being detached. Change-Id: I2008beb9ab8f97f7ea5ed7b45cfb3f23dfe7b27f
2023-04-20ms: Make ms_{attach,detach}_tbf expectancies more robustPau Espin Pedrol2-5/+5
* Make sure that the tbf being attached has already the MS assigned. * Check no re-attaching of alredy attached TBF ever happens. * Document and early skip case where a non-attached TBF detach is attempted. * Avoid recursive call mess to tbf_set_ms(tbf, NULL); during detach. * MsTest needs to be modified since it uses fake TBF objects which use different set of calls than the regular TBFs in osmo-pcu. Since the ul_tbf object is reused, it needs to be assigned ul_tbf->ms again before re-assigning it, as per what happens usually in tbf_set_ms() in osmo-pcu. Change-Id: Ia18fe2de1fb3bf72f530157e5f30de64f2b11e12
2023-04-20ms: Use osmo_use_count to track referencesPau Espin Pedrol6-12/+338
Change-Id: Ib65629224e6bd5683bb9192ba4354e965e8d39ec
2023-04-20Merge bts_alloc_ms() and ms_alloc()Pau Espin Pedrol6-26/+26
gprs_default_cb_ms_idle() is changed to have the same implementation as previous bts_ms_idle_cb(), since that's the only one being used in osmo-pcu code. It makes no sense to use different callback logic in unit tests. This is another step towards simplifying the code and getting rid of the idle/active_cb(). Change-Id: I2a06d17588572a21dc5a14ddbde83766076b446d
2023-04-20ms: store in bts->ms_list during alloc/destroy of ms objectPau Espin Pedrol3-0/+11
With this change the MS no longer is removed from the llist without potentially skipping free() if not idle in bts_ms_idle_cb(). As a result, some unit tests now can free it during bts tear down instead of having them leaked. The tests int MsTest need changes because the tbfs created are fake and cannot be freed using tbf_free(), and hence cannot be detached from MS using regular code paths. Instead first call explicit talloc_free(ms) like other unit tests in the file already do. Change-Id: Id53f8dfb9963366dd4b19a324615bbc83c4f23e7
2023-04-20ms: Merge ms_storage into bts.cppPau Espin Pedrol2-30/+29
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-20bts: Rename bts_ms_by_{tlli,imsi} -> bts_get_ms_by_{tlli,imsi}Pau Espin Pedrol2-25/+25
While at it, put them together and mark bts param as const. This is a preparation for next patch. Change-Id: Iad8aec4424f1f23cd4d02a14c4f9ec1b9fdb1f75
2023-04-20ms: Drop setting (egprs_)ms_class during bts_alloc_ms()Pau Espin Pedrol6-60/+86
That information is not required during allocation of the object, and most times it is not known. Defer setting it only to meaningul values in paths obtaining the information from peers. Change-Id: I36f07dc389f7abe205fc4bcddbde93735f5d5cfc
2023-04-17ms: Drop setting tlli during ms_alloc()Pau Espin Pedrol6-124/+138
Inside osmo-pcu code, the code path is to always call ms_alloc with tlli=GSM_RESERVED_TMSI; a different value is only passed during unit tests. It makes no sense to have unit tests using differnet code paths than ther app itself, since in the app it always desired to go through the ms_set_tlli() and ms_confirm_tlli() which does more stuff. Hence, drop the tlli param in ms_alloc and change the unit tests to use the available APIs used by the application. Change-Id: I730ec911a43b0f4e78faee4eeffb3ca8601564f8
2023-04-17ms: Fix MS without PTMSI not freed immediatellyPau Espin Pedrol1-1/+1
This check (tlli != 0) was added in 2015 in 6d86628e5b6d81afae4ca1f24201ee90bfab1c2a, with the rationale below: """ To avoid dangling entries without a TLLI there (which cannnot be retrieved anyway), the timer in the MS objects is not started after all TBF have been detached, so that they get deleted immediately in that case. """ The rationale makes sense, but through time the MS class was fixed to return GSM_RESERVED_TMSI (0xFFFFFFFF) when no TMSI was available. Hence, the check was wrong, and as a result, free() of MS containing GSM_RESERVED_TMSI would be delayed over time by release timer. Related: OS#6002 Change-Id: I7a694a30f8709c00af774846d7c4925cef253a71
2023-03-31tests: $(BUILT_SOURCES) is not defined, depend on osmo-pcuVadim Yanitskiy1-2/+2
Change-Id: I6620a524b393a0db6201930a1e2795a439785824
2023-03-27pdch_ul_controller: log reserved frame numbersPhilipp Maier2-0/+160
When debugging frame number offset problems betwen l1 and below and the upper layers of the PCU, it may be helpful do know which blocks/frame numbers got reserverd for uplink transmissions. Change-Id: I4277c572a4cc6cbbf3ac4e67442c9036be687627 Related: OS#5198
2023-03-14Update libosmogsm deprecated includePau Espin Pedrol2-2/+2
The previous gprs/protocol/gsm_04_60.h header from libosmogsm was misleading because it was placed in the subdirectory used by libosmogb, and hence was recently deprecated in favour of gsm/protocol/gsm_04_60.h. Let's follow the pragma message advising to move to the new header file. Depends: libosmocore 0158b05337a825352d9fd7f074170b686e9fd1e5 Change-Id: I027abbf3ed4c71331000565af1ef4f08f10cfafc
2023-03-11tests/Makefile.am: do not overwrite global LDFLAGSVadim Yanitskiy1-3/+10
We still want -no-install to be used for these tests. Change-Id: I926df1918fd24ea7be4b390d168a8c76ef9931c0
2023-03-11{src,tests}/Makefile.am: libraries shall not be in AM_LDFLAGSVadim Yanitskiy1-16/+21
Change-Id: Ibd7eb55e2cfe7daed2f8a8d74c6a3ede6f29308f
2023-02-27pcu_l1_if_phy: add new PHY API function to disconnect PDCHPhilipp Maier11-0/+13
There is a function l1if_connect_pdch, but no complementary function like we have it with l1if_open_pdch and l1if_close_pdch. The reason for this is that the PHY implementations that rely on a femtocell DSP do not need to disconnect the pdch explcitly. However, the planned support for the E1 based Ercisson RBS CCU will require an explicit disconnect. So lets add a function call for this. Change-Id: Ied88f3289bda87c48f5f9255c4591470633cc805 Related: OS#5198
2023-01-05bts: log FN jump delta in bts_set_current_frame_number()Philipp Maier1-62/+62
In case of an FN jump the expected value is logged. Lets also log the delta between the expected and the current FN as it may give a better clue what goes wrong Change-Id: Ie361df30852570fe8a47347a42e962db869ccf82
2023-01-05bts: refuse to set invalid frame numbersPhilipp Maier2-14/+14
A valid GSM frame ranges from 0 to 2715647. When using set_current_frame_number() to set the current frame number (source usually is the layer 1 and below) we should not allow invalid frame numbers. Note: this also fixes FnTest which uses invalid frame numbers for testsing. Change-Id: Iaae31b370fababba975d419b0d20ac15618c296e Related: OS#5198
2022-12-19Avoid moving DL-TBF from old_msg to new_ms during ms_merge2023q1Pau Espin Pedrol2-51/+85
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-16Pass gprs_rlcmac_pdch to create_dl_acked_block()Pau Espin Pedrol1-3/+5
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 Pedrol6-51469/+51461
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-16Rename gprs_rlcmac_ts_alloc.cpp -> alloc_algo.cpp & create own .h filePau Espin Pedrol6-0/+7
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 Pedrol2-4/+6
This way it contains full information about the TS, not only the TN. Change-Id: I19373939ec104d371e3e91422f018a8175cb0f89
2022-12-16Refactor code rejecting UL-TBF upon rx of PktResourceReqPau Espin Pedrol1-1/+1
* Make it similar to the already existing TBF allocation procedures * Pass pdch pointer instead of trx and ts numbers Change-Id: I04b3b65942732cc652adeaa507529b849292ff61
2022-12-16Trigger PACCH assignment inside dl_tbf_upgrade_to_multislot()Pau Espin Pedrol2-23560/+47119
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 Pedrol3-4/+4
* 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-16Move first_common_ts from gprs_rlcmac_tbf to GprsMsPau Espin Pedrol1-11/+5
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-13sched: Pass pdch to *_create_rlcmac_msg() functionsPau Espin Pedrol1-12/+9
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-11-18Split tbf_fsm as tbf_{ul,dl}_fsmPau Espin Pedrol3-100353/+554
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-18tbf_fsm: Move osmo_fsm_inst fi out of struct tbf_fsm_ctxPau Espin Pedrol1-4/+4
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-03Improve MS loggingPau Espin Pedrol6-51439/+51439
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 Pedrol6-303562/+303562
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-10-31tbf_fsm: Introduce new event to act upon contention resolution successPau Espin Pedrol1-0/+1
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 Pedrol1-10/+48
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 Pedrol1-0/+3
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 Pedrol2-14/+14
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-31Rename tbf_alloc_ul_tbf -> ul_tbf_allocPau Espin Pedrol3-9/+9
Use proper prefix according to the type being allocated. Change-Id: Ic98c3c852c96c3f52f1c8f531b8d0fd28ce5aef5
2022-10-31Join ms_merge_and_clear_ms() and ms_merge_old_ms()Pau Espin Pedrol1-1/+4
While at it, improve logging of the merge action Change-Id: I39d9eac159448fc3c3a4db9e1b9c5364e906a78f
2022-10-31update_ms(): Set TLLI of new MS object before merge with old MSPau Espin Pedrol1-2/+2
This way it becomes clearer in logs that we are merging MS which contains the same TLLI. Change-Id: Ifd232daa4219e1726c30449d647312a3a226a61d
2022-10-31ul_tbf: Define m_contention_resolution_done as boolPau Espin Pedrol1-1/+1
Change-Id: Ief048cc1b5e8a18ceaeb5432415d14f5ef7ee0ea
2022-10-28Replace tbf->establish_dl_tbf_on_pacch() refactoring GprsMs functionsPau Espin Pedrol1-49/+49
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