aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ms
AgeCommit message (Collapse)AuthorFilesLines
2024-03-25Make sure GprsMs free() also frees its tbfsPau Espin Pedrol3-12/+12
This fixes TBF objects leaking and ending up alive when the MS object is explicitly freed through talloc_free (and sporadically crashing TbfTest once a timeout for them occur). This mostly affects unit tests, where most of the explicit free() happens. In osmo-pcu, in general, the GprsMs object only gets _free() called when its resource count reaches 0, aka no more TBFs are attached to it. Hence in general GprsMs object is freed() only when no TBFs (to be leaked) are present. However, in the unit tests it's usual that we want to wipe the entire context by eg. feeing the PCU, the BTS or MS object, which should also free the related TBFs. When running osmo-pcu this may only be an issue when the MS object is freed explicitly, which could happen for instance when a BTS is torn down, ie. PCUIF going down, moment at which all GprsMs of that BTS are freed. But in there actually it iterates over PDCHs to free all TBFs, so it's fine. If we iterated over MS, this could have ended up in a crash, like it happened in TbfTest sporadically, but it's not a bit problem if we crash + restart at that time since anyway the BTS is gone ore just getting up around that time. Related: OS#6359 Change-Id: Ibbdec94acb8132be20508d3178d88da44bfaf91d
2023-05-31tbf: Improve TBF name description in logsPau Espin Pedrol1-22/+22
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-03pcu_l1_if_phy: fix API function namesPhilipp Maier1-2/+2
The functions l1if_open_pdch and l1if_close_pdch have a misleading naming since what they actually do is opening and closing the TRX since they return and accept a context (obj) that is valid for a whole TRX. This also explains why the other functions accept a timeslot as parameter in addition to the context. Let's rename those functions so that it is clear what they do. Related: OS#6022 Change-Id: I395a60b2fba39bac4facec78989bac20f0cef0d3
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 Pedrol1-1/+4
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 Pedrol1-1/+1
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 Pedrol2-15/+29
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-20ms: Rewrite MS release lifecyclePau Espin Pedrol3-163/+22
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 Pedrol1-12/+12
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 Pedrol1-0/+28
Change-Id: Ib65629224e6bd5683bb9192ba4354e965e8d39ec
2023-04-20Merge bts_alloc_ms() and ms_alloc()Pau Espin Pedrol1-1/+1
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 Pedrol2-0/+9
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 Pedrol1-19/+19
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-17ms: Drop setting tlli during ms_alloc()Pau Espin Pedrol2-21/+33
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-02-27pcu_l1_if_phy: add new PHY API function to disconnect PDCHPhilipp Maier1-0/+1
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
2022-11-03Improve MS loggingPau Espin Pedrol1-32/+32
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 Pedrol1-24/+24
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-21Call ms_store->get_ms() with GSM_RESERVED_TMSI instead of 0Pau Espin Pedrol1-4/+4
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
2021-11-08tbf: Set tfi to initial special valuePau Espin Pedrol1-24/+24
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-10-12tbf_fsm: rename state NULL -> NEWPau Espin Pedrol1-24/+24
This helps distinguishing the case where a TBF is in the initial state and the unexpected case where osmo_fsm_inst_state_name reports "NULL" due to fi pointer being NULL. Change-Id: Ieaabfc9fa0dedb299bcf4541783cf80e366a88c3
2021-05-19MsTest: Set up tbf talloc destructorPau Espin Pedrol1-24/+42
This is right now not an issue, but it will be whenever talloc destructor contains extra steps like freeing an FSM. Change-Id: I096ff56321c8ae5e66634537aae8b95804282c65
2021-03-03gprs_ms: Use standarized logging on more messagesPau Espin Pedrol1-31/+31
Change-Id: If7f471f4932c2347cd857cd59f761a36d9e735d1
2021-03-03ms: clarify delayed MS release process related code and loggingPau Espin Pedrol1-1/+1
Change-Id: Ieaea6ab07b4b2822bcf394f2d0e9298b9f3c5854
2021-02-19tests: Replace deprecated API log_set_print_filenamePau Espin Pedrol1-1/+1
Change-Id: Idcc4875592c81f17ac98c4f6098492b3d9dd33d2
2021-02-19tests: Explicitly drop category from logPau Espin Pedrol1-0/+2
Let's disable category here since we don't care about its formatting here. In any case, every test relying on logging output validation should always explicitly state the config to avoid issues in the future if default values change. Change-Id: I7f9c56313cfaa74ebe666f44763a83d8102f5484 Related: OS#5034
2021-01-25Fix Dl EGPRS data blocks being generated occasionally on GPRS TBFsPau Espin Pedrol1-3/+3
Under some circumstances, it could happen that a DL TBF is created as a GPRS TBF due to not yet having enough information of the MS, and only after the TBF is created the PCU gains that information and upgrades the MS mode to "EGPRS". Hence, there's the possibility to run into a situation where a GPRS TBF is attached to a EGPRS MS. It may also happen sometimes that despite the TBF and the MS be EGPRS, there's need to further limit the DL MCS to use, eg. MCS1-4 (GMSK). As a result, when asking for the current DL (M)CS to use, we must tell the MS which kind of limitations we want to apply. The later reasoning was already implemented when GPRS+EGPRS multiplexing was added, but the former was not being checked. Hence, by further spreading through the call stack the "req_kind_mode" we match both cases. Related: OS#4973 Change-Id: Ic0276ce045660713129f0c72f1158a3321c5977f
2021-01-25ms: Properly handle EGPRS_GMSK mode in ms_max_cs_dl/ul()Pau Espin Pedrol1-2/+2
Change-Id: Ied3e02a12145112fafa12282ed7aefa5b0fa6eb6
2021-01-25ms: Set proper initial MCS values setting mode EGPRS_GMSKPau Espin Pedrol1-2/+2
Before this patch, shared logic with EGPRS case would allow keeping MCS>4. Change-Id: I94cbf0c120fd37deb2dfd077d35b3811c7da0675
2021-01-20Allow multiple bts objects in PCUPau Espin Pedrol1-8/+8
This patch doesn't really tests whether osmo-pcu can work on a multi-bts environment, but it prepares the data structures to be able to do so at any later point in time. Change-Id: I6b10913f46c19d438c4e250a436a7446694b725a
2021-01-19Unify BTS into a C usable structurePau Espin Pedrol1-39/+37
Previous work on BTS class started to get stuff out of the C++ struct into a C struct (BTS -> struct gprs_glcmac_bts) so that some parts of it were accessible from C code. Doing so, however, ended up being messy too, since all code needs to be switching from one object to another, which actually refer to the same logical component. Let's instead rejoin the structures and make sure the struct is accessible and usable from both C and C++ code by rewriting all methods to be C compatible and converting 3 allocated suboject as pointers. This way BTS can internally still use those C++ objects while providing a clean APi to both C and C++ code. Change-Id: I7d12c896c5ded659ca9d3bff4cf3a3fc857db9dd
2021-01-18Move cs_downgrade_threshold field from BTS to PCUPau Espin Pedrol1-3/+3
Change-Id: I3e1c65eb3cccff565d5d84588bdce93a47909a0f
2021-01-18Move cs_adj* fields from BTS to PCUPau Espin Pedrol1-1/+1
Change-Id: I2b00a83279dccd4feeeeb95e34878c4405e7972c
2021-01-18Split PCU global PCU object from BTS objectPau Espin Pedrol1-8/+12
Currently the BTS object (and gprs_rlcmac_bts struct) are used to hold both PCU global fields and BTS specific fields, all mangled together. The BTS is even accessed in lots of places by means of a singleton. This patch introduces a new struct gprs_pcu object aimed at holding all global state, and several fields are already moved from BTS to it. The new object can be accessed as global variable "the_pcu", reusing and including an already exisitng "the_pcu" global variable only used for bssgp related purposes so far. This is only a first step towards having a complete split global pcu and BTS, some fields are still kept in BTS and will be moved over follow-up smaller patches in the future (since this patch is already quite big). So far, the code still only supports one BTS, which can be accessed using the_pcu->bts. In the future that field will be replaced with a list, and the BTS singletons will be removed. The cur_fn output changes in TbfTest are actually a side effect fix, since the singleton main_bts() now points internally to the_pcu->bts, hence the same we allocate and assign in the test. Beforehand, "the_bts" was allocated in the stack while main_bts() still returned an unrelated singleton BTS object instance. Related: OS#4935 Change-Id: I88e3c6471b80245ce3798223f1a61190f14aa840
2021-01-05Convert GprsMS and helpers classes to CPau Espin Pedrol1-240/+234
As we integrate osmo-pcu more and more with libosmocore features, it becomes really hard to use them since libosmocore relies heavily on C specific compilation features, which are not available in old C++ compilers (such as designated initializers for complex types in FSMs). GprsMs is right now a quite simple object since initial design of osmo-pcu made it optional and most of the logic was placed and stored duplicated in TBF objects. However, that's changing as we introduce more features, with the GprsMS class getting more weight. Hence, let's move it now to be a C struct in order to be able to easily use libosmocore features there, such as FSMs. Some helper classes which GprsMs uses are also mostly move to C since they are mostly structs with methods, so there's no point in having duplicated APIs for C++ and C for such simple cases. For some more complex classes, like (ul_,dl_)tbf, C API bindings are added where needed so that GprsMs can use functionalitites from that class. Most of those APIs can be kept afterwards and drop the C++ ones since they provide no benefit in general. Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-11-10TLLI 0x00000000 is a valid TLLI, use 0xffffffff insteadVadim Yanitskiy1-6/+6
The assumption that TLLI 0x00000000 is invalid and can be used as the initializer is wrong. Similar to TMSI, 0x00000000 is a perfectly valid value, while 0xffffffff is reserved - use it. According to 3GPP TS 23.003, section 2.4, a TMSI/P-TMSI with all 32 bits equal to 1 is special and shall not be allocated by the network. The reason is that it must be stored on the SIM, where 'ff'O represents the erased state. According to section 2.6 of the same document, a local/foreign TLLI is derived from P-TMSI, so the same rule applies to TLLI. I manually checked and corrected all occurances of 'tlli' in the code. The test expectations have been adjusted with this command: $ find tests/ -name "*.err" | xargs sed -i "s/0x00000000/0xffffffff/g" so there should be no behavior change. The only exception is the 'TypesTest', where TLLI 0xffffffff is being encoded and expected in the hexdump, so I regenerated the test output. Change-Id: Ie89fab75ecc1d8b5e238d3ff214ea7ac830b68b5 Related: OS#4844
2020-11-04Move BTS initial values inside bts.cppPau Espin Pedrol2-7/+8
This way everytime any program or test initiates a BTS object, the bts_data structure has the same values. Change-Id: Iffd6eecb1f08bda0091f45e2ef7c9c63b42e10b3
2020-10-26tests: ms: Pass correct pointer in constructor instead of NULLPau Espin Pedrol1-1/+1
The BTS field will be used in code paths after next patch changes, otherwise the test fails accessing the NULL pointer. Change-Id: I5098292bdafa9f4f70fef1a053b80a33deca722c
2020-10-24tbf: Set MS during constructor timePau Espin Pedrol2-41/+46
This is another step forward towards a more clear data model where a TBF always has a MS object (which may be lacking some information, and at a later point when more information is found, it may actually be a duplicated MS object and hence one duplicate removed and the TBF moved to the object being kept). This helps for instance in removing duplicated information stored in the TBF which is really per MS, like ms_class, ta, etc. Since there's always a MS object there's no need to keep a duplicate in both classes in case there's no MS object. It can already be seen looking at unit test logging that this kind of data model already provides better information. Some unit test parts were needed to adapt to the new model too. Change-Id: I3cdf4d53e222777d5a2bf4c5aad3a7414105f14c
2020-03-27tbf.cpp: Include c++ <new> header required for new operator's replacement typePau Espin Pedrol1-0/+2
Including the <new> header is required as explained by the c++ specs [1] osmo-pcu/src/tbf.cpp: In function ‘gprs_rlcmac_ul_tbf* tbf_alloc_ul_tbf(gprs_rlcmac_bts*, GprsMs*, int8_t, uint8_t, uint8_t, bool)’: osmo-pcu/src/tbf.cpp:1002:39: error: no matching function for call to ‘operator new(sizetype, gprs_rlcmac_ul_tbf*&)’ 1002 | new (tbf) gprs_rlcmac_ul_tbf(bts->bts); | ^ Most of the times this issue is not detected because other STL headers are already including <new>. [1] http://www.cplusplus.com/reference/new/operator%20new/ Change-Id: Ie5fb536ae29dcf40e2a0dbe67432bebd61b8c7aa
2019-09-25Move out tbf subclasses from tbf.h to their own headersPau Espin Pedrol1-0/+1
It's a good start towards clearing current mess between parent and the 2 children classes. Change-Id: Ibc22ea2e02609af7ee058b8bc15df2115d4c6f60
2019-08-05Remove undefined param passed to {logging,osmo_stats}_vty_add_cmdsPau Espin Pedrol1-1/+1
Since March 15th 2017, libosmocore API logging_vty_add_cmds() had its parameter removed (c65c5b4ea075ef6cef11fff9442ae0b15c1d6af7). However, definition in C file doesn't contain "(void)", which means number of parameters is undefined and thus compiler doesn't complain. Let's remove parameters from all callers before enforcing "(void)" on it. API osmo_stats_vty_add_cmds never had a param list but has seem problem (no "void"), so some users decided to pass a parameter to it. Related: OS#4138 Change-Id: Ic1ac815eafab49577ff883a5d700ecca5936d216
2019-04-11Add test for MS mode and (M)CS settingsMax3-0/+86
Right now set_mode() on GprsMs behaves in pretty counter-intuitive way: * it's possible to set current DL MCS higher than max value * EGPRS and EGPRS_GMSK have the same max DL MCS * setting EGPRS* mode drops current/max MCS values to unknown Let's capture this in a unit-test before attempting any further modifications. Change-Id: Ibf917f4b49d927a21cbd467775806fa6ea06a6a6
2019-03-27MCS: add Channel Coding Command encoderMax1-2/+2
Add function to encode MCS value as proper EDGE or GPRS Channel Coding value according to 3GPP TS 44.060 and corresponding helpers. Use it for everything except IA Rest Octet encoding which is done in a follow-up patches to make sure that we distinguish between encoding-related changes to test output and unrelated changes. Change-Id: I127fb29f5aaf77a7f6c4c565dfeb3b711af9845d
2019-03-19MS store: move test helper to unit testMax1-2/+18
It's confusing to have test-specific helper with the same name as tested function directly inside the GprsMsStorage class. Let's convert it into static function and move to the unit test. Change-Id: Ia2a5b90779051af894fe15d957c1d26f0a142f33
2018-04-01use osmo_init_logging2() with proper talloc ctxNeels Hofmeyr1-1/+1
There is a duality of initialization: early_init() in bts.cpp wants to init logging even before static instances get initialized. Make sure that tall_pcu_ctx is initialized during early_init() as well. There is a build context that does not seem to include bts.cpp (osmo-pcu-remote), so to be sure, init tall_pcu_ctx as NULL and both in early_init() as well as pcu_main.cpp, init both tall_pcu_ctx and logging if it is still NULL. Change-Id: I2199b62d0270bd35dec2283e8f5b364b7c63915b
2018-03-11implement support for 3-digit MNC with leading zerosNeels Hofmeyr1-0/+1
Receive the mnc_3_digits flag from the PCU interface. Bump the PCU interface to 9. This is one part of the three identical pcuif_proto.h patches: - I49cd762c3c9d7ee6a82451bdf3ffa2a060767947 (osmo-bts) - I787fed84a7b613158a5618dd5cffafe4e4927234 (osmo-pcu) - I78f30aef7aa224b2e9db54c3a844d8f520b3aee0 (osmo-bsc) Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout the code base to be able to handle an MNC < 100 that has three digits (leading zeros). Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore), Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore) Change-Id: I787fed84a7b613158a5618dd5cffafe4e4927234
2017-10-29tests: Don't use private version of log_info but global gprs_log_infoHarald Welte1-18/+3
There's no need for each test case to carry their own log_info and filter function. They can simply use the global gprs_log_info and configure the stderr log verbosity according to their needs. Change-Id: I8706a624e5d06e062d1198711aa197fbd0860769
2017-02-08main, tests: use msgb_talloc_ctx_init() (new)Neels Hofmeyr1-1/+1
msgb_set_talloc_ctx() is deprecated since libosmocore commit f45334be29016a36594aacc07c90e262e4994525 / change-id I747fbbf977c4d2c868c8dead64cfc5fd86eb8d4c Change-Id: I8d40abec428b739460ed545c9983d1b63021bd08