aboutsummaryrefslogtreecommitdiffstats
path: root/src/tbf_dl.cpp
AgeCommit message (Collapse)AuthorFilesLines
2021-01-19Convert gprs_bssgp_pcu.cpp to CPau Espin Pedrol1-5/+5
There's no real use of C++ in that file, and it causes problems when using llist_head entry macros in future patches adding initial support for multiple BTS in PCU object, so let's move it to plain C. Change-Id: Ic771a89fd78b5e66151a5384f0ff6a8895589466
2021-01-19Unify BTS into a C usable structurePau Espin Pedrol1-39/+39
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 llc_* fields from BTS to PCUPau Espin Pedrol1-4/+4
Change-Id: Iffb916e53fdf99164ad07cd19e4b35a64136307e
2021-01-18Move ws_* fields from BTS to PCUPau Espin Pedrol1-1/+1
Change-Id: I997bc52f0d924c8f2a0b1d6cf23af98828ad4258
2021-01-18Move cs_adj* fields from BTS to PCUPau Espin Pedrol1-2/+2
Change-Id: I2b00a83279dccd4feeeeb95e34878c4405e7972c
2021-01-18Move dl_arq_type field from BTS to PCUPau Espin Pedrol1-2/+2
Change-Id: I0b82ab59edd58d60e5581c707dc49f58de0ba203
2021-01-18Move dl_tbf_preemptive_retransmission field from BTS to PCUPau Espin Pedrol1-1/+1
Change-Id: I3ab32fcafe83f3ecb116a5b8a05f58f3fddc5451
2021-01-18Move T_defs_pcu from BTS to PCU objectPau Espin Pedrol1-1/+1
Change-Id: I0cac5c12dff2e90b52d00383a00b4b94a9603a0a
2021-01-05Convert GprsMS and helpers classes to CPau Espin Pedrol1-38/+48
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-12-01Dl TBF: Get rid of LLC UI dummy blocks following other dataPau Espin Pedrol1-5/+25
According to: * 3GPP TS 44.060 version 16.0.0 "9.3.1a Delayed release of downlink Temporary Block Flow" * 3GPP TS 44.064 version 16.0.0 "6.4.2.2 Unconfirmed Information (UI) Dummy command" LLC UI Dummy frames are to be used when there no more data to send, only in order to delay the release of a TBF. Hence, while not incorrect per se, makes no sense to send those LLC UI Dummy frames inserted into rlcmac blocks which already contain other LLC frames, since the MS in that case is already being kept active. It only makes sense to send those LLC UI Dummy frames when we have nothing else to send, that is, alone inside a RLCMAC block without other LLC frames. Related: OS#4849 Change-Id: Ifae1a7b2b3dfad8df19585063088ba0df2749c8f
2020-12-01Implement downgrade to DL MCS1-4 when USF for GPRS_only MSPau Espin Pedrol1-11/+25
In previous status, if USF for GPRS-only MS was selected, then EGPRS TBFs were skipped and either a GPRS TBF was selected or a Dummy Block was sent. That means the behavior was unfair towards EGPRS TBFs, because sometimes they were skipped in favor of GPRS ones. This patch imporves the situation in the above mentioned USF scenario, by first, under specific conditions, allowing selection of an EGPRS TBF and then forcing it to transmit in EGPRS-GMSK (MCS1-4) so that the USF-targeted MS can still decode the USF, while at the same time providing more fairness by allowing the EGPRS TBF to transmit data. The specific conditions mentioned above are, mainly, related to the fact that once a DL data block has been sent, and hence a BSN was assigned to it, it cannot be retransmitted later using another MCS, since lower MCS1-4 wouldn't be able to contain higher MCS RLC payload. The set of conditions could be expanded in the future by also selecting the EGPRS TBF if retransmition is required and the block to be retransmitted was originally transmitted as MCS1-4. Related: OS#4544 Change-Id: I9af23e175435fe9ae7b0e4119ad52fcd4707b9ca
2020-11-04tbf_dl: Don't fake EGPRS MS class when no related info is availablePau Espin Pedrol1-9/+0
For instance if PCU received DL data to be sent to an MS from an SGSN, and the MS is not currently cached in the PCU (because there's no TBF active for it), it will page it and transmit the DL data to it. The SGSN is capable of sending (EGPRS) MS Class information in that same DL data message, so it's the one responsible for providing that information if not available at the PCU. In the PCU if we don't have information about that MS and SGSN didn't provide us information about it, we cannot assume the MS is going to be EGPRS capable and even less expecting a specific EGPRS MS class. So let's drop this code. Related: OS#4544 Change-Id: Icce66cadb51af25ae0c3b3719940eccb548fe33b
2020-10-29tbf_dl: Update (egprs_)ms_class for already known MSPau Espin Pedrol1-23/+11
If SGSN provides us with MS class information upon DL data, let's use it and set it in an already existing MS object if not yet known. Also remove all unneeded code passing ms_class to append_data() which would simply try to (again) set the ms_class. Change-Id: I4979c9344bffd3ba7657bbab94981d233eab801f
2020-10-29tbf: Clean up gprs_rlcmac_dl_tbf::handle()Pau Espin Pedrol1-31/+9
Avoid passing tons of params to internal helper function tbf_nel_dl_assignment() in order to either fetch again the ms object or create a new one. Let's instead create the ms function earlier if needed and fill it with all the discovered information prior to calling the helper function. This provides cleaner code and also better log output. This way we also avoid trying to fill the MS twice and unneeded getter+setter for TA. tbf::imsi(): There' always an ms, so simply forward call to ms()->imsi(). We can also get rid of assign_imsi, since the modified code is the only place where it's used and there's already some code in place there to update the MS. We instead merge it with set_imsi and keep the duplication code to catch possible bugs from callers. Move merge_and_clear_ms from tbf class to GprsMS, where it really belongs. Change-Id: Id18098bac3cff26fc4a8d2f419e21641a1f4c83b
2020-10-24Move dl_tbf allocation code to correct filePau Espin Pedrol1-0/+112
Change-Id: I50d41b1c6f244edcfb78646d0fac4e47c2e3e561
2020-10-24tbf: Set MS during constructor timePau Espin Pedrol1-3/+3
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-10-24tbf: Make window() available to tbf base classPau Espin Pedrol1-1/+1
Return an interface to the window base class so that the tbf base class can access the common window methods, such as set_ws(). It will be used in next commit to get rid of duplicated function enable_egprs in both dl_tbf and ul_tbf subclasses. The user of the function can then decide to access more specific functionaltiites of the window class by static casting it to the specific direction (which is known by the caller since it operates on a ul_tbf or a dl_tbf). Change-Id: Ia2e1decf91be1184668e28297c2126affb9c7ae4
2020-10-24Move constructor gprs_rlcmac_dl_tbf::BandWidth to correct filePau Espin Pedrol1-0/+10
Change-Id: I7587fd2ee97424020a099a8513f95544d6635f3d
2020-07-07tbf_dl: uint8_t is enough to store a TA valuePau Espin Pedrol1-1/+1
According to 3GPP TS 44.018 sec 10.5.2.40, Timing Advance value is 8 bit and range is 0-63 (0-219 on GSM400). So there's no need for 16 bits to store it. uint8_t is used in all other places in the code. Change-Id: I38aa063ae30ca5680fef6252d2cef22cea98c123
2020-06-26tbf: Drop unneeded method set_tlli_from_ulPau Espin Pedrol1-2/+0
Since commit 322456ed474a733094c9f3e240295b469023ad14 (and previous one), it is expected that a tbf object ALWAYS has a MS object referend to it, even if it's a temporary copy which will later be merged when TLLI/IMSI is retrieved and it is found that several MS objects relate to the same MS. The purpose of set_tlli_from_ul was mainly to update TBF's ms() to old_ms before going through usual tbf->update_ms() path. That's not really needed since ms() is already always set and TBFs for old_ms are already freed in update_ms() and children function. Change-Id: Ie8795e7a02032336e53febb65c11f9150c36d2a0
2020-05-20Get rid of class GprsCodingSchemePau Espin Pedrol1-19/+18
We have same kind of object splitted into two layers, in coding_scheme and gprs_coding_scheme. Let's merge them together and get rid of the class, which is not really useful because it's only a set of functions operating on one enum value. This change also fixes gcc 10.1.0 error about memseting a complex type in rlc.h init(). Change-Id: Ie9ce2144ba9e8dbba9704d4e0000a2929e3e41df
2020-05-18rlc: Move prepare() function out of gprs_rlc_data structPau Espin Pedrol1-1/+1
Newer gcc 10.1.0 is erroring due to memset being applied on a complex type, so let's start by removing this only function outside of the struct. Change-Id: I20426557d9b3049ab275fadb92e10ea8a860a119
2020-05-14bts: Drop specific functions to add values to countersPau Espin Pedrol1-2/+2
It's super annoying seeing lots of functions being called everywhere only to find out they are only incrementing a counter. Let's drop all those functions and increment the counter so people looking at code doesn't see dozens of code paths evyerwhere. Most of the commit was generated by following sh snippet: """ #!/bin/bash define_pattern="^CREATE_COUNT_ADD_INLINE" generic_func="do_rate_ctr_add" grep -r -l "${define_pattern}" . | xargs cat | grep "${define_pattern}("| tr -d ",;" | tr "()" " " | awk '{ print $2 " " $3 }' >/tmp/hello while read -r func_name ctr_name do #echo "$func_name -> $ctr_name"; files="$(grep -r -l "${func_name}(" .)" for f in $files; do echo "$f: $func_name -> $ctr_name"; sed -i "s#${func_name}(#${generic_func}(${ctr_name}, #g" $f done; done < /tmp/hello grep -r -l "void ${generic_func}" | xargs sed -i "/void ${generic_func}(CTR/d" grep -r -l "$define_pattern" | xargs sed -i "/$define_pattern/d" """ Change-Id: I966221d6f9fb9bb4f6068bf45ca2978008a0efed
2020-05-14bts: Drop specific functions to increase countersPau Espin Pedrol1-25/+25
It's super annoying seeing lots of functions being called everywhere only to find out they are only incrementing a counter. Let's drop all those functions and increment the counter so people looking at code doesn't see dozens of code paths evyerwhere. Most of the commit was generated by following sh snippet: """ #!/bin/bash grep -r -l ^CREATE_COUNT_INLINE . | xargs cat | grep "^CREATE_COUNT_INLINE("| tr -d ",;" | tr "()" " " | awk '{ print $2 " " $3 }' >/tmp/hello while read -r func_name ctr_name do #echo "$func_name -> $ctr_name" files="$(grep -r -l "${func_name}()" .)" for f in $files; do echo "$f: $func_name -> $ctr_name"; sed -i "s#${func_name}()#do_rate_ctr_inc(${ctr_name})#g" $f done; done < /tmp/hello grep -r -l "void do_rate_ctr_inc" | xargs sed -i "/void do_rate_ctr_inc(CTR/d" grep -r -l "CREATE_COUNT_INLINE" | xargs sed -i "/^CREATE_COUNT_INLINE/d" """ Change-Id: I360e322a30edf639aefb3c0f0e4354d98c9035a3
2020-05-12Expect ms object to exist before calling tbf_alloc_dl_tbf()Pau Espin Pedrol1-5/+7
Same as previous commit, this time for the DL counterpart. Change-Id: I87f6cdf8288a688466020bda0874e68b57aa71c4
2020-03-16Use clock_gettime(CLOCK_MONOTONIC) and timespec everywherePau Espin Pedrol1-11/+11
We should really be using monotonic clock in all places that gettimeofday is used right now. Since clock_gettime() uses timespec, let's move all code to use timespecs instead to avoid having to convert in several places between timespec and timeval. Actually use osmo_clock_gettime() shim everywhere to be able to control the time everywhere from unit tests. Change-Id: Ie265d70f8ffa7dbf7efbef6030505d9fcb5dc338
2020-03-02llc_queue::{dequeue,enqueue}() refactorPau Espin Pedrol1-4/+5
As seen in OS#4420, setting the MetaInfo.recv_time outside of llc_queue before calling llc_queue::enqueue() and later on using that value in llc_queue itself at dequeue time is not a good idea, since it can provoke errors if the recv_time was not set correctly. For instance, LlcTest was not setting the value for recv_time on some test, which ended up with a huge millisec value when substracting now() from it: """ llc.cpp:215:29: runtime error: signed integer overflow: 1582738663 * 1000 cannot be represented in type 'long int' """ This issue only appeared when started building on a raspberrypi4. Let's better set/store the MetaInfo.recv_time internally during llc_queue::enqueue(). Then, enqueue() only needs the MetaInfo.expire_time, so let's change its arg list to only receive that to avoid confusions. Take the chance to move the llc_queue APIs to use osmo_gettimeofday, since we need to fake the time now that the API itself sets that time. Also take the chance during this refactor to disallow passing null pointer by default since no user needs that. Finally, update the LlcTest accordingly with all API/behavior changes. Related: OS#4420 Change-Id: Ief6b1464dc779ff22adc2b02da7a006cd772ebce
2020-01-06Pass paging group instead of imsi where later is not neededPau Espin Pedrol1-1/+4
Change-Id: Id0663a81f439f2d0b893b0d34f85a6db1927ef8e
2019-12-04tbf_dl.cpp: Fix typo in log linePau Espin Pedrol1-1/+1
Change-Id: I9fdea4246c95897f3e72604981597db828a219a3
2019-09-26tbf_dl.cpp: Remove dup call to tbf_update_ms_class() in state ↵Pau Espin Pedrol1-1/+0
GPRS_RLCMAC_WAIT_RELEASE tbf_update_ms_class() is already called two lines above in the common path. Fixes: 409efa1ec84c14aaa43bfac85ba4956e9f3cf16a Change-Id: Icbe3805c72a5c77366215be55128b586e5a00fb7
2019-09-26tbf_dl: Setup m_llc_timer in constructor using osmocom APIPau Espin Pedrol1-5/+1
Change-Id: I3e761b319326e33ab1d56c4fb30cafe3b0f96c29
2019-09-26Move tbf_{dl,ul} child constructors to respective .cpp filesPau Espin Pedrol1-0/+13
Fixes: 9d1cdb1f697057033394590a9b2815efe6c08cd9 Change-Id: Id258589d46de42ad4e27889bc396f930b7f94b79
2019-09-25Move out tbf subclasses from tbf.h to their own headersPau Espin Pedrol1-0/+2
It's a good start towards clearing current mess between parent and the 2 children classes. Change-Id: Ibc22ea2e02609af7ee058b8bc15df2115d4c6f60
2019-09-17Use osmo_tdef to implement dl-tbf-idle-timePau Espin Pedrol1-2/+4
Change-Id: I5e4f0d2f90e643600b7752525d6c2830856c9d3b
2019-09-12tbf_dl: add comments to the schedulerAlexander Couzens1-2/+13
Change-Id: Ib037f9fda30472313c7a82effb1e925c6abebbe5
2019-09-12Introduce osmo_tdef infra and timer VTY commandsPau Espin Pedrol1-4/+3
This will allow for configuration of some of the timers by the user, and allow him to inspect current values being used. It will be also useful for TTCN3 tests which may want to test some of the timers without having to wait for lots of time. Timers are splitted into 2 groups: BTS controlled ones and PCU controlled ones. The BTS controlled ones are read-only by the user (hence no "timer" VTY command is provided to change them). TbfTest.err output changes due to timers being set up correctly as a consequence of changes. Other application such as pcu_emu.cpp and pcu_main.cpp had to previosuly set the initial values by hand (and did so), but apparently TbfTest.c was missing that part, which is now fixed for free. Depends: libosmocore.git Id56a1226d724a374f04231df85fe5b49ffd2c43c Change-Id: I5cfb9ef01706124be262d4536617b9edb4601dd5
2019-09-11tbf_dl: make preemptive retransmission optionalOliver Smith1-1/+1
Since [1], OsmoPCU already starts to retransmit downlink blocks before the MS has had a chance to receive them and/or send the related acknowledgement in uplink. Make this optional with the new VTY option "no dl-tbf-preemptive-retransmission". [1] e25b5b91f60f20f61096bc6199a05b58ee6c6328 ("tbf: Only create dummy frames if necessary") Related: OS#2408 Change-Id: Id08aed513d4033aa0d4324c6ce07cbb2852f2f92
2019-04-08cosmetic: use const pointer for bts_dataMax1-2/+4
It's used several time for logging so let's call it once to make code easier to follow. Change-Id: Icfd9e5603a5d8701f487f17e9c0335d458e9e80b
2019-04-08Update MCS selection for retransmissionMax1-5/+3
In 3GPP TS 44.060 the selection of MCS for retransmissions is defined as separate tables (8.1.1.1 and 8.1.1.2) depending on the value of resegmentation bit (which is opposite to the way EGPRS_ARQ are defined in the source code). Let's follow the same idea and explicitly check for resegmentation bit value and use separate tables. This also makes it easier to add proper support for special cases (MCS-6-9 and MCS-5-7) and padding in future independently for different ARQ types. The code is also moved to c to avoid unnecessary conversions to and from cpp class. Change-Id: Ia73baeefee7a58834f0fc50e3b8bf8d5e3eb7815
2019-03-27TBF-DL: cosmetic update for helper routinesMax1-38/+32
* use enum values where appropriate * reformat to proper code style to improve readability Change-Id: If1d2bc69b0d43fc520e579457007704b7975117e
2019-03-27TBF: update MCS countersMax1-62/+57
* use enum CodingScheme directly instead of converting it to class and back * drop useless mode check * log errorneous update attempt Change-Id: I763136c2f356d63aa3d28d09c57fd5faf5336258
2019-03-26MCS: add mcs_is_*() helpersMax1-4/+4
In preparation for Channel Coding Command encoder in follow-up patches let's add necessary helpers. Those are similar to previously used helpers from GprsCodingScheme class but without CamelCase and with less typo chances between Gprs and Egprs cases. Change-Id: I6699cbc8d7ae766fa4d2b3d37e5f9ff1cf158b7e
2019-03-19TBF-DL: log MCS as stringMax1-5/+5
Log MCS name instead of numeric value. Change-Id: I3e1925a010a6def5fd14da63b73e0b75feddfafc
2019-03-19MCS: use value_string for conversionMax1-5/+6
Change-Id: I212ebb892ab162821633974d5a6c7e315d308370
2019-03-19MCS: move HeaderType enum outside of class definitionMax1-7/+7
Move functions which compute number of blocks or bits depending on header type and corresponding enum outside of GprsCodingScheme class. This will allows us to use standard libosmocore value_sting functions in upcoming patches for IA Rest Octet encoding/decoding. Change-Id: Id0873f85e1f16a72e17e7fbc4ad76b194917067f
2019-03-12MCS: move Coding Scheme enum outside of class definitionMax1-35/+35
Move generic MCS enum to C header file to simplify further modifications to GprsCodingScheme class in follow-up patches. This also allows us to use standard libosmocore value_sting functions in upcoming patches for IA Rest Octet encoding/decoding. Related: OS#3014 Change-Id: I993b49d9a82b8c7ad677d52d11003794aeabe117
2019-02-19Clarify write_immediate_assignment() signatureMax1-1/+1
* remove unused variable * use bool for boolean types * add clarification comments Change-Id: I363445063e2d873d9194b2a5924b9e59b8b7ea53
2018-02-20TBF: make network counters internalMax1-1/+1
* store N310* counters in shared array similar to corresponding timers * add functions to increment/reset counters This avoids direct access to TBF counters from PDCH. Change-Id: I8ffff9c7186f74bde7e6ac5f6e98f0b3e4c35274 Related: OS#1539
2018-02-19Update header includesMax1-2/+12
Many files include unnecessary headers and don't include headers which are actually used. Because of that combined with the fact that OsmoPCU is a mixture of C and C++, it makes it hard to modularize code. Fix this (using iwyu [1] tool): * add missing headers * remove unused headers [1] https://include-what-you-use.org/ Related: OS#1539 Change-Id: I8c9f488a43b099c72b2d30d3245e7ba50872fc00
2018-02-03TBF: add helpers for assignment type handlingMax1-6/+2
* add function to set/unset given assignment type * log assignment type flag changes * update tests output with additional logs This enables us to carefully track the TBF assignment type transitions. Change-Id: I3fe9d52472be8b7f257e8326b2f84e8e7d7bd1f4 Related: OS#1759