aboutsummaryrefslogtreecommitdiffstats
path: root/src/pdch.cpp
AgeCommit message (Collapse)AuthorFilesLines
2021-02-03nacc: Implement Pkt Cell Change Continue retransmissionPau Espin Pedrol1-0/+14
Use the fact that the MS must answer the RRBP of the Pkt Cell Change Continue with a CTRL ACK to find out whether the message was received successfuly or a retransmission is potentially required. 3GPP TS 44.060: """ When the mobile station receives the PACKET CELL CHANGE ORDER or the PACKET CELL CHANGE CONTINUE message the mobile station shall transmit a PACKET CONTROL ACKNOWLEDGMENT message in the specified uplink radio block if a valid RRBP field is received as part of the message; the mobile station may then switch to a new cell. """ Related: SYS#4909 Change-Id: I7cc28922e71699598da0ef6eb90136a47d3c002f
2021-01-29Introduce NACC supportPau Espin Pedrol1-0/+30
A new nacc_fsm is introduced per MS object, with its partner priv structure struct nacc_fsm_ctx, which exists and is available in the MS object only during the duration of the NACC procedure. The NACC context is created on an MS whenever a Pkt Cell Change Notification is received on Uplink RLCMAC, which asks for neighbor information of a given ARFCN+BSIC. First, the target ARFCN+BSIC needs to be translated into a CGI-PS (RAC+CI) address. That's done by asking the BSC through the Neighbour Resolution Service available in osmo-bsc using the CTRL interface. Once the CGI-PS of the target cell is known, PCU starts a RIM RAN-INFO request against the SGSN (which will route the request as needed), and wait for a response containing the SI bits from the target cell. After the SI are received, the scheduler is instructed to eventually poll a TBF for the MS originating the CCN, so that we can send the SI encapsulated into multiple Packet Neighbor Cell Data messages on the downlink. One all the SI bits are sent, the scheduler is instructed to send a Packet Cell Change Continue message. Once the message above has been sent, the FSM autodestroys itself. Caches are also introduced in this patch which allows for re-using recently known translations ARFCN+BSIC -> CGI-PS and CGI-PS -> SI_INFO respectively. Change-Id: Id35f40d05f3e081f32fddbf1fa34cb338db452ca
2021-01-19Convert osmo_bts_sock.cpp to CPau Espin Pedrol1-0/+4
There's no real point in using C++ there, and using C++ makes the compiler fail to use llist_head in multi-bts patches added later due to: """ 'offsetof' within non-standard-layout type is conditionally-supported """ Change-Id: I8965b5cc5a713e64788b5b6aa183d3035341ddbb
2021-01-19Move tbf::free_all static methods to proper object filesPau Espin Pedrol1-1/+15
Move each method to the object on which they operate, be it a trx or a pdch ts. Change-Id: Ida715cbf384431d37b2b192fbd7882957c93a4d1
2021-01-19Convert gprs_bssgp_pcu.cpp to CPau Espin Pedrol1-2/+2
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-19Rename 'bts_data' leftovers to 'bts'Pau Espin Pedrol1-11/+6
Before, we used tho have a BTs object split into 2 parts, a C gprs_rlcmac_bts struct and a C++ BTS struct, and "bts_data" naming was used to distinguish them in variable names. Nowadays the struct is finally combined into one, so there's no point in using this "bts_data" terminology, we use always "bts". Change-Id: I9852bf439292d1abc70711bea65698b21bde0ee8
2021-01-19Unify BTS into a C usable structurePau Espin Pedrol1-30/+30
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-05Convert GprsMS and helpers classes to CPau Espin Pedrol1-28/+30
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-23pdch: Log hexdump of decde failure for dl rlcmac blockPau Espin Pedrol1-1/+2
Change-Id: I591212a43bf92984348d1992df8c9b4fdddeba3b
2020-11-23pdch: packet_paging_request: Put back non-fitting paging entry where where ↵Pau Espin Pedrol1-1/+1
it was dequeue_paging() dequeues the first paging (at the start of the list). If a paging request is dequeued but later it cannot be added to the message being sent, it has to be re-added to the list for later processing on next message. However, existing code was enqueueing it at the end, which meant that paging request was delayed for no reason. Change-Id: Iad8e7045267d56e32f42db0fbb8448b1b1185f05
2020-11-17Support multiplexing of GPRS and EGPRS TBFs in one PDCHPau Espin Pedrol1-0/+16
There are some restrictions to have both GPRS-only and EGPRS MS attached to the same MS: * Any MS needs to be able to successfully decode a DL block at least every 18 DL blocks (360 ms). That means a Dl block with CS1-4 must be sent at least once during that time. * Any MS needs to be able to decode USF targeting it. GPRS-only MS can successfully decode USF from DL blocks using GMSK: CS1-4 and MCS1-4. In this patch, if USF of a GPRS-only MS is selected, then all DL EGPRS TBFs are discarded from data block selection. However, this logic can be further improved later by still allowing selection of DL EGPRS TBFs and then forcing construction of a DL EGPRS data block using MCS1-4. Sources: * 3GPP TS 03.64 version 8.12.0 "6.6.4.1.1.2 Multiplexing of GPRS and EGPRS MSs" * 3GPP TS 05.08 version 8.23.0 "10.2.2 BTS output power" Related: OS#4544 Change-Id: Ib4991c864eda6864533363443f76ae5d999532ae
2020-11-04pdch: Process received CS1-4 data blocks regardless of egprs_enabledPau Espin Pedrol1-6/+0
EGPRS "enabled" or "not enabled" is a bit of confusing idea, since there are different levels of EGPRS support. For instance we may have been instructed by config to not transmit using MCS5-9 (8PSK), or not use MCS1-9 at all (GMSK+8PSK). However, we cannot control what is sent to us or what we receive on lower layers, so if the BTS PHY/receiver was able to decode+receive, let's try to process it anyway... Related: OS#4544 Change-Id: Ie70ec8e4a2d688762d7d320d6ad58d5a0cc52ea1
2020-10-29cosmetic: Fix ws between if keyword and parenthesisPau Espin Pedrol1-1/+1
Change-Id: I5932f21c58e76552f7187a175b8e281c5846536c
2020-10-24tbf: Make window() available to tbf base classPau Espin Pedrol1-4/+6
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-08-24pdch: rcv pkt meas rep: Allocate MS object early in path and use itPau Espin Pedrol1-9/+12
Let's create the MS object early if doesn't exist and fill in the information, so that we can operate on it in an early way (for instance, logging macros), this way it's easier to trace the lifecycle of subscribers. Change-Id: I3ec7eb970310698dd228ae6ad65ec5ca833bab3f
2020-08-24paging: pass struct osmo_mobile_identity, not encoded IE bytesNeels Hofmeyr1-3/+9
In get_paging_mi(), before this, an encoded buffer of Mobile Identity bytes is returned. Code paths following this repeatedly decode the Mobile Identity bytes, e.g. for logging. Also, in get_paging_mi(), since the TMSI is read in from a different encoding than a typical Mobile Identity IE, the TMSI was manually encoded into a typical Mobile Identity IE. This is essentially a code dup of osmo_mobile_identity_encode(). Stop this madness. Instead, in get_paging_mi(), return a decoded struct osmo_mobile_identity. Code paths after this use the struct osmo_mobile_identity directly without repeated decoding. At the point of finally needing an encoded Mobile Identity IE (in Encoding::write_paging_request()), do a proper osmo_mobile_identity_encode(). Since this may return errors, add an rc check for the caller of write_paging_request(), gprs_rlcmac_paging_request(). A side effect is stricter validation of the Mobile Identity passing through the Paging code path. Before, invalid MI might have passed through unnoticed. Change-Id: Iad845acb0096b75dc453105c9c16b2252879b4ca
2020-08-21use new osmo_mobile_identity api (avoid deprecation)Neels Hofmeyr1-2/+7
Note: subsequent patch Iad845acb0096b75dc453105c9c16b2252879b4ca will change to passing a struct osmo_mobile_identity in the Paging code path, instead of passing the encoded IE data. Change-Id: Ibb03b8e601160427944f434761ca59811d1fc12f
2020-08-18pdch: Drop unneeded notice log message in rcv pkt meas reportPau Espin Pedrol1-9/+2
It's totally fine to receive Packet Measurement Report messages with no SBA present, since the MS also sends measurements on PACCH while transmitting data. Related: OS#4719 Change-Id: I8f642d9cdeb342df7d5f2fa30516ea69554a6270
2020-07-09pdch.cpp: Store TLLI promptly on newly created TLLI in rcv_resource_requestPau Espin Pedrol1-0/+1
The TLLI is tried to be updated later anyway during tbf_alloc_ul(), but this way it's clear that information is stored where it belongs as soon as possible. The change already shows clearer log lines in TbfTest.err. Change-Id: I20ce4eb94ecf85ce2835275d0056d9ecd1b558c3
2020-07-09pdch.cpp: Fix wrong annoying log line about non-scheduled ResourceReq receivedPau Espin Pedrol1-20/+21
It's perfectly fine receiving a Resource Request message under some circumstances (as stated in the comment added in the commit). To print issues only under non-expected circumstances, the function rcv_resource_request need to be refactored: * Destroying older UL_TBF is delayed because it is needed further down. * When the old UL_TBF is FINISHED, it's an acceptable time to receive a Resource request, so we check if that's the case and don't print a warning in that case. Change-Id: I4b4367126d6a16055cd2f45afc4a6b9c15a7c980
2020-07-09pdch.cpp: Avoid resetting (egprs_)ms_class to unknown if not found in MS ↵Pau Espin Pedrol1-13/+6
RadioAccCap If the information is not found in the message, 0 (unknown MS class) will be returned. If the MS already had some previous information on the MS class, let's not lose it by setting it back to 0. Take the opportunity to drop related log lines which are no needed, since set_(egprs_)ms_class() functions already log the value changes. Change-Id: Icd52209fd4395d78dc770e7869d1b1fe45a18ca0
2020-07-09pdch.cpp: Avoid dropping existing DL TBF during rcv_resource_requestPau Espin Pedrol1-8/+0
There's no real good explanation on why the DL TBF is dropped there, since PKT RESOUCE REQUEST is used basically during UL TBF establishment. Also, as decribed by TS 44.060 11.2.16 "Packet Resource Request": """ This message is sent on the PACCH by the mobile station to the network to request a change in the uplink resources assigned. """ Change-Id: Iab4afb66f0d671f7ad54909d2685a1613e12ab4d
2020-06-30pdch.cpp: Fix logging line format in rcv_block wrong lengthPau Espin Pedrol1-2/+2
Change-Id: I2f818021cef41ab6f4569cd87026072811853352
2020-05-20gsmtap: Set signal level and SNR fieldsPau Espin Pedrol1-6/+8
lqual (containing C/I value) is passed instead of SNR, but let's have that better than nothing. Change-Id: Ibe9502d42c8bd1b984069e7fd805dde87ecbab0c
2020-05-20Get rid of class GprsCodingSchemePau Espin Pedrol1-8/+8
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-14bts: Drop specific functions to add values to 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 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-6/+6
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-14Drop unneeded arg 'ta' in tbf_alloc_ul()Pau Espin Pedrol1-5/+3
The function is simply setting the ta on the ms, so simply make sure ta is set on callers before passing the ms object. Change-Id: Iebb9c57f458690e045ddc45c800209ad8cf621e0
2020-05-14pdch: rcv_resource_request(): Clarify tbf_free only needed if MS used to ↵Pau Espin Pedrol1-24/+26
exist beforehand Variable found is used to always call Guard() on MS to avoid possible unexpected freeing regressions. Change-Id: I62f24fe04ca10fca19bedda288fe3ed3ce75413f
2020-05-12Expect ms object to exist before calling tbf_alloc_ul_tbf()Pau Espin Pedrol1-19/+15
It's really non-sense from architectural point of view to pass an optional pointer to the MS holding the TBF and creating it otherwise. TBFs shouldn't be creating MS they belong too. This simple change requiring so many code line changes really exhibits how badly entangled the object relationship is. Another commit will follow doing the same for dl tbf. Change-Id: I010aa5877902816ae246e09ad5ad87946f96855c
2020-04-29pdch: Avoid sending GSMTAP_CHANNEL_UNKOWN for rejected UL EGPRS data blockPau Espin Pedrol1-3/+3
Even if we don't accept it, let's submit GSMTAP with correct channel. We don't return error like in code below, because otherwise the generic UNKNOWN gsmtap message will be sent. Change-Id: I853679ce8907d46fcb84ae4127335c10623f09c9
2020-03-30Move gsm_rlcmac.cpp -> .cPau Espin Pedrol1-1/+2
Original file from wireshark.git (packet-gsm_csn1.c) is being built and maintained as a C file. There's no real need for us to maintain it as a C++, and doing so will make both files derive over time (as already happened). Let's keep it as a C compiler (which btw seems to be more strict) to make it easier to port patches back and forth wireshark.git. Take the chance to move some declarations we added to csn1.h to be able to build it out of wireshark. Let's keep those in a separate header file to ease looking for differences. Change-Id: I818a8ae947f002d35142f9f5473454cfd80e1830
2020-03-27pdch: cosmetic: use GSM_MI_TYPE_* constants from libosmocoreVadim Yanitskiy1-1/+1
Change-Id: I1d85c8eded68bc8aa8e90c33b36d335fa775ded2
2020-03-27pdch: fix packet_paging_request(): properly print paging MIVadim Yanitskiy1-5/+4
This problem problem was discovered by the Undefined Behavior Sanitizer: pdch.cpp:210:4: runtime error: load of misaligned address 0x60c00002abf2 for type 'uint32_t', which requires 4 byte alignment Do not convert TMSI to number, use osmo_mi_name() from libosmocore. Also use this function to print other MI types (IMSI or IMEISV). Change-Id: Icf8836f216793e342b239c8e6645aac1e82bf324
2020-03-26Don't check ul_control_block before decoding into it.Keith1-1/+1
This patch corrects an error introduced in 6fd8ffb6fe62586a6880780678cbee3d9f97e763 That commit allowed us to send the data over GSMTAP even if the Uplink Control Block had invalid content, that is to say, if decode_gsm_rlcmac_uplink() returned error. However the check for ul_control_block->u.MESSAGE_TYPE was place before decode_gsm_rlcmac_uplink() Change-Id: Ic47602e5c6a13571b92c0a939fc3514110b82444
2020-03-26cosmetic: Do not indent header includes inside extern C blockPau Espin Pedrol1-8/+8
Change-Id: I3091d917a13e45b3aef8e52a53dcafa308581652
2020-03-23rlcmac: Introduce MS Radio Access Capabilities 2 to fix related spare bitsPau Espin Pedrol1-3/+3
There's two variants for the Ms Radio Access Capabilities. * The usual encoding with spare bits (usually to fill up to octet boundary) as defined in TS 24.008 Table 10.5.146 And there's too: * MS Radio Access Capabilities 2 IE from TS44.060 section 12.30, which is the same but removing all spare bits, and which is used in messages like Packet Resource Request and Additional MS RAC messages. The later is used basically for messages having extra IEs after the MS Radio Access capabilities IE, since they are encoded immediatelly afterwards. So this patch does: * Adds the expected spare bits (M_PADDING) to MS_Radio_Access_capability_t * Creates a new MS_Radio_Access_capability2_t without padding * Updates code to use the new "2" version where needed. Note RLCMACTest long de/encoding line logs change only because the name of the struct changes (the "2" is added). Change-Id: Ibd756f80a03452a651e2771dbc628d701e55ac4b
2020-03-05Send UL-CTRL Packet to GSMTAP even if we fail to decode.Keith1-5/+6
Move the call to send_gsmtap() before the call to decode_gsm_rlcmac_uplink() as if the latter returns error we return and never get to see the packet on the GSMTAP. Change-Id: Ia6af9f40590f28fcae3fef50d9c601d8435412cd
2020-03-02gsm_rlcmac: fix Packet_Resource_Request_t: s/Slot/I_LEVEL_TN/Pau Espin Pedrol1-4/+4
This is how this field is named in Wireshark. Change-Id: I140443c48af8e4bb1b6279e6de986879b7d9c276
2020-02-05Check return code of rlcmac decode/encode functionsPau Espin Pedrol1-8/+25
Change-Id: Iabcb768bd714680aa768b35c786dea2015d1e451
2020-01-01Split identity_lv param into mi+mi_lenPau Espin Pedrol1-2/+3
It's not really needed to have those together in some function calls, and makes it more difficult to follow the code. Furthermore, new callers not having content already aligned (len+value) will be using these functions in forthcoming commits. Change-Id: Ifb9d3997bfb74b35366c3d1bc51ce458f19abf16
2019-12-31fix typo in log messagePau Espin Pedrol1-1/+1
Change-Id: Ib6fc4625242d855193b62b561624b23b265648b9
2019-11-17PTCCH: implement basic message codec and APIVadim Yanitskiy1-0/+35
Change-Id: Id79e95aafdde4a71977c64385fce48b729a51ca9 Related: OS#1545
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-09-25pdch.cpp: Use pcu_l1_meas previously filled by lower layersPau Espin Pedrol1-17/+14
Otherwise, a new meas object is allocated in the stack in upper layers which doesn't contain the link_qual information (have_link_qual=0), outputting following error: osmo-pcu/src/gprs_ms.cpp:644 Unable to update UL (M)CS CS-2 because we don't have link quality measurements. Change-Id: I1980ca325c8d65f3f6310fa697dd810eec7ab077
2019-09-25pdch.cpp: Refactor bitvec param passing in rcv_control_blockPau Espin Pedrol1-12/+13
Move code in rcv_block_gprs() only needed for rcv_control_block() into the later. This way rcv_block_gprs() is simplified and shows similar code paths with regards to rcv_data_block(). It can now be seen that the main difference between both is the meas param no being passed in the control case. Change-Id: I2a0133463edced93c72ccc743a0cf00d1d6922cf
2019-07-17fix spelling errors detected by lintianThorsten Alteholz1-2/+2
Change-Id: I381618eb55cc513cfa9c2e384c27cead0935c8bf
2019-03-26MCS: add mcs_is_*() helpersMax1-3/+3
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-19MCS: use value_string for conversionMax1-5/+6
Change-Id: I212ebb892ab162821633974d5a6c7e315d308370
2018-02-20TBF: make network counters internalMax1-8/+8
* 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