aboutsummaryrefslogtreecommitdiffstats
path: root/src/llc.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-03-31llc: Convert to CPau Espin Pedrol1-252/+0
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-31llc: Convert to C: s/m_//gPau Espin Pedrol1-32/+32
Change-Id: Ia5272841392110b87725e87a7e6824c17a70d6d1
2021-12-14treewide: remove FSF address2021q4Oliver Smith1-4/+0
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-03-02llc: use memset to fill llc dummy frame paddingPau Espin Pedrol1-2/+4
Change-Id: Iaa55549f979ca23dad0bddd308c1144aa4b17255
2021-01-19Unify BTS into a C usable structurePau Espin Pedrol1-3/+3
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-2/+2
Change-Id: Iffb916e53fdf99164ad07cd19e4b35a64136307e
2021-01-05Convert GprsMS and helpers classes to CPau Espin Pedrol1-15/+15
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-05-14bts: Drop specific functions to increase countersPau Espin Pedrol1-1/+1
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-03-16Use clock_gettime(CLOCK_MONOTONIC) and timespec everywherePau Espin Pedrol1-18/+19
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-6/+7
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
2017-12-18Remove unused includes and forward declarationsMax1-1/+0
Change-Id: I59da04edd1b8ff965bbfbe00ccae1f7c9b6e5301
2015-08-21llc: Add move_and_merge method to llc_queueJacob Erlbeck1-0/+53
This methods takes all LLC frames from the old LLC queue and moves them into the current. If both queues are ordered chronologically (recv_time), the resulting queue is also ordered. Sponsored-by: On-Waves ehf
2015-07-14llc: Fix comparison warningJacob Erlbeck1-1/+1
Fixes: Jenkins build #609 warning Addresses: llc.cpp:56, GNU C Compiler 3 (gcc), Priority: Normal comparison between signed and unsigned integer expressions Sponsored-by: On-Waves ehf
2015-06-22llc: Move storage of timestamps into gprs_llc_queueJacob Erlbeck1-6/+20
Currently the receive and expiry timestamps are prepended to the LLC msgb before it is passed to gprs_llc_queue::enqueue(). Since this meta information should not be counted as LLC octets, the gprs_llc_queue needs to known about this (unless the correction was done in the LLC layer). This commit moves the meta information storage code into gprs_llc_queue. The meta data is now stored in the control block (cb) area of the msgb. Note that the info pointer that is returned from the dequeue method is only valid if that method returns a (non-NULL) msgb. It must not be used after that msgb has been modified or freed. Sponsored-by: On-Waves ehf
2015-06-22llc: Make timeval arguments constJacob Erlbeck1-1/+2
Some struct timeval pointer arguments do not have the const qualifier, albeit the methods do not write to the structures. The next commit will change related pointers to const, so this commit provides the required constness. Sponsored-by: On-Waves ehf
2015-06-22llc: Keep track of the number of stored LLC octetsJacob Erlbeck1-0/+4
To get the number of LLC octets that are stored in the queue, this commit adds a m_queue_octets member along with a octets() method. This value is updated similarly to m_queue_size on each modifying method call. Sponsored-by: On-Waves ehf
2015-06-11llc: Fix LLC UI frame detection (Coverity)Jacob Erlbeck1-2/+2
Currently the wrong nibble is masked out, so the conditional expression always yields true. Therefore gprs_llc::is_user_data_frame() always returns true. As a consequence, the low watermark feature of gprs_rlcmac_dl_tbf::llc_dequeue() is not being used in fact. This commit fixes the mask value. Fixes: Coverity CID 1292834, 1292835 Sponsored-by: On-Waves ehf
2015-06-08llc: Separate LLC queue handling from gprs_llcJacob Erlbeck1-36/+40
Currently the gprs_llc class handles both LLC queueing and the partition into smaller pieces for RLC/MAC encapsulation. This hinders the separation of TBF and MS related data, since LLC queueing belongs to the MS related code while the RLC/MAC encoding/decoding belongs to the TBF layer. This commits takes the LLC queueing related methods and members and puts them into a new class gprs_llc_queue. It puts the queueing object into gprs_rlcmac_tbf and adds accessor functions. The implementation in tbf.cpp and tbf_dl.cpp is adapted accordingly. Ticket: #1674 Sponsored-by: On-Waves ehf
2015-04-02tbf: Use a hysteresis when discarding DL LLC framesJacob Erlbeck1-0/+15
Currently single LLC blocks are discarded when the PDU lifetime expires. If an IP packet has been fragmented either on the IP or on the LLC layer and is therefore distributed over several LLC frames, the kept fragments are transmitted and then discarded by the MS because of the missing PDU. This can cause massive IP packet loss when there are many fragmented packets (e.g. when trying 'ping -s1800' or if the GGSN chops downlink IP packets into several SNDCP packets). On the other hand, discarding too many packets might disturb the congestion handling of TCP. Dropping plain TCP ACKs might also hinder flow control and congestion avoidance. This commit adds a hysteresis algorithm to the LLC discard loop. If an LLC message's age reaches the high water mark, further message's with an age above the low water mark are discarded, too. This is aborted, if a GMM, a non-UI, or a small message is detected. In these cases, that message is kept. The following VTY commands are added (pcu config node): - queue hysteresis <1-65535> set the difference between high (lifetime) and low watermark in centiseconds - no queue hysteresis disable this feature (default) Since the SGSN will most probably send all fragments of a single N-PDU without much delay between them, a value slightly above the average transmission delay jitter between SGSN and PCU is probably a sensible value to discard all fragments of a single IP packet. This is an experimental feature that might be replaced by more advanced means of active queue management in the future. Sponsored-by: On-Waves ehf
2015-03-20llc: Add put_dummy_frame to create an LLC dummy commandJacob Erlbeck1-0/+20
The LLC dummy command is needed for RLC block stuffing, e.g. when a TBF should be kept open if no LLC data is available. The RLC block headers do not support stuffing, only the last block of a TBF can be used partially. LLC dummy commands are discarded by the receiver immediately, because the have an invalid FCS checksum. This commit adds the function put_dummy_frame, which puts a LLC dummy command into the frame buffer. The requested length is given as an argument, but the real length might be adjusted according to the specification (see GSM 44.064, 6.4.2.2). Sponsored-by: On-Waves ehf
2013-12-25llc: Calculate the average queuing delay of the LLC queuesDaniel Willmann1-3/+23
Use a formula like it is used with TCP. This can help to make decisions about if frames should be dropped or not at the time we enqueue them. This code will store two timeval structs in fron the of the actual data and compute the average at the time of the dequeue.
2013-12-25llc: Initialize the LLC frame with garbage to detect wrong usageHolger Hans Peter Freyther1-0/+2
2013-12-18llc: Count the number of frames queued inside the LLC queueHolger Hans Peter Freyther1-0/+6
2013-11-21llc: FIx a typo in the messageHolger Hans Peter Freyther1-1/+1
2013-11-21types: Add a simple testcase for basic types and fix the LLC codeHolger Hans Peter Freyther1-1/+2
* Make append_data, remaining_space and fits_in_current.. work on m_length and not the index. This ways things can't overflow. * The current API consumer was moving the m_index so it should have worked okay.
2013-11-13llc: Move the decision if a frame has expired into the LLCHolger Hans Peter Freyther1-0/+9
This way the generation of the expiry information and the check is at the same place. This should make reading the code more easy.
2013-11-13llc: Make the index 'private' by appending a m_ to it.Holger Hans Peter Freyther1-4/+4
At some point in the future we can start using the private/protected keywords in this struct.
2013-11-13llc: Move some more secrets from the TBF into the LLCHolger Hans Peter Freyther1-4/+8
Introduce a method to append data to a TBF and then reset the read pointer when the frame has been sent.
2013-11-13bts: Count the number of llc frames that were "scheduled" to be sentHolger Hans Peter Freyther1-1/+1
This does not mean that they have been successfully transferred to the SGSN/MS but at least that they have reached a certain point in the message flow.
2013-11-13llc: Use timeradd and timercmp and fix for < 1s PDU llc timeoutsHolger Hans Peter Freyther1-7/+6
2013-11-13llc: Change the flow. Exit early for the special case and initialize the tvHolger Hans Peter Freyther1-9/+12
2013-11-13llc: Move the timeout calculation into the TBFHolger Hans Peter Freyther1-0/+22
2013-11-13llc: Remove one of the two variants to put data into the frameHolger Hans Peter Freyther1-8/+6
2013-11-07llc: Move all direct accesses to the frame into the llc structureHolger Hans Peter Freyther1-2/+1
Add some todo items where we could add assertions now that I see the constraints and invariants of this code.
2013-11-07llc: Move the llc code out of the tbf.cpp into a new dedicated oneHolger Hans Peter Freyther1-0/+79