aboutsummaryrefslogtreecommitdiffstats
path: root/src/bts.cpp
AgeCommit message (Collapse)AuthorFilesLines
2018-04-01use osmo_init_logging2() with proper talloc ctxNeels Hofmeyr1-1/+4
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-02-19Move PDCH-related functions into separate filesMax1-899/+1
The PDCH class and corresponding functions are rather self-contained and independent from BTS implementation. Let's move them into separate file to make bts.cpp more manageable. As additional benefit it allow us to somewhat untangle all the different cross-dependent includes. Change-Id: Ie05e25361e6741a81b024679f9675c98d4923683 Related: OS#1539
2018-02-19Update header includesMax1-3/+6
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-19Move paging generation into PDCHMax1-11/+13
Previously paging was prepared inside BTS function and than handed over to PDCH function. Move the actual preparation into PDCH to better decouple PDCH from BTS. Related: OS#1539 Change-Id: I389fb16b6e54040770c21f88edbcb8e045636928
2018-02-07RACH: improve single block detectionMax1-44/+28
Replace unreadable if-else ladder in is_single_block() with regular switch-case. This enables implementation of 11-bit RACH support in follow-up patches. Related: OS#1548 Change-Id: I9180478152f9341f11bb3dffe61671da683f24d8
2018-02-03TBF: add helpers for assignment type handlingMax1-2/+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
2018-01-31TS alloc: print suggested TRX on allocation errorsMax1-1/+1
If TS allocation fails due to unavailable TFI, print TRX which was suggested to allocator. This simplifies allocator debugging but requires cosmetic modifications to test output. Change-Id: Icaf97d71d71985d52dc0bda448c26b19fe5645e7 Related: OS#2282
2018-01-26Simplify TS alloc: adjust function signaturesMax1-3/+2
* document used parameters and return values * use consistent formatting * constify function parameters where appropriate (adjusting parameter types if necessary) Change-Id: I211b10b4da59c73d509b719346774515c761886a Related: OS#2282
2018-01-26Simplify TS alloc: use defines for constantsMax1-1/+1
* define and use constant for occupied TFI instead copying the same magic number all over the place * use libosmocore's define for bit pretty-printer Change-Id: I2699ceebf0cbec01652a02fa68ccc9e9419d0293 Related: OS#2282
2018-01-26Simplify TS alloc: fix allocation callsMax1-1/+1
Using the semantic patch below, adjust allocation-related calls to match updated allocator signatures. // spatch --c++ --dir src -I src --sp-file callfix.spatch --in-place --recursive-includes // spatch --c++ --dir tests -I src --sp-file callfix.spatch --in-place --recursive-includes @@ expression A, B, C, D, E; @@ tbf_alloc_ul_tbf(A, B, C, D, E, ( - 1 + true | - 0 + false ) ) @@ expression A, B, C, D, E; @@ tbf_alloc_dl_tbf(A, B, C, D, E, ( - 1 + true | - 0 + false ) ) Change-Id: I43c76cb49093b40eb854d324e898e821270053dc Related: OS#2282
2018-01-24TBF: make poll state internalMax1-2/+2
* add functions/macros for setting TBF's poll state * add function for checking TBF's poll state Change-Id: I6db1c4e7bd0a49aeb5e391afe371c36b96c6a702 Related: OS#1539
2018-01-24TBF: make UL/DL state internalMax1-7/+7
* add functions/macros for setting TBF's UL/DL state * add functions for checking TBF's UL/DL state * move pre-free check into separate function N. B: this should not be confused with TBF-UL or TBF-DL state. Change-Id: Idcbf5775d17b1247f2ed01788f9b0788ce66e871 Related: OS#1539
2018-01-17TBF: log source of state transitionsMax1-3/+3
We use the same approach for osmo_fsm: when state transition happens, it's not very useful to always log the transition function itself, it's much more useful to see where the actual transition comes from. Change-Id: I348ba89bdda2b44c7019e9c893c764ee08c80bec Related: OS#1759
2018-01-12TBF: move window parameters to UL/DL levelMax1-4/+4
The UL and DL TBF use different classes implementing window management. Hence it's better to use it explicitly instead of using the common window management superclass inside common TBF superclass. While at it, also remove the direct access to window class - use accessor functions instead. Related: OS#1759 Change-Id: I0b55aa8947db65f7206adcf53ea32b74a831d9e6
2018-01-12Clarify RACH-related interfacesMax1-79/+86
* make is_11bit parameter into bool * remove is_single_block() from public interface and mark it as static * move logging outside of if ladder * move side-effects from is_single_block() into separate static functions * simplify UL-TBF allocation in case of 11-bit RACH This immediately makes it obvious that priority is never actually used despite being computed - seems like a leftover from merge of incomplete patch series. Change-Id: If189b7166a29a87ffb17a7a9bc560f674851fd53 Related: OS#1548
2018-01-12TBF: cleanup state flag handlingMax1-12/+5
* introduce generic function to check whether particular flag was set for'a TBF and clear it if necessary. Use this instead of clear_poll_timeout_flag() * add function to explicitly set assignment and appropriate state flags Overall this makes the code easier to read and debug. Related: OS#1759 Change-Id: Ic4560280c72f91700f2e19c6c7f6658dc29625c2
2018-01-02TBF: log timer invocation sourceMax1-2/+2
When troubleshooting TBF timers we're not only interested in timer duration but also in the code which triggered it. Let's use LOGPSRC to log it: wrap t_start() in a macro for convenience. Change-Id: If5f883ae52c469e5158bad24da9904fdc455582f Related: OS#2407
2018-01-02TBF: unify timer handlingMax1-2/+2
Use generic timer handling infrastracture to handle assignment/reject internal timer. Rename timer array accordingly. Use defines with explicit second/microsecond values to make it more readable. Change-Id: I63fb7e6f0695383a83472c836a381a055f64690b
2017-12-21Fix warningsMax1-2/+2
Fix warnings detected by compiler and coverity scan. Change-Id: If463c7f8769e18d3df74837f0cb0f545cca9b23e Fixes: CID181479
2017-12-20TBF: add N3101 counterMax1-0/+19
Properly reset the counter when receiving valid RLCMAC block and update it when no data is received as per 3GPP TS 44.060 §8.1.1.1 Change-Id: I2f79c6153dc4073c9d293b2824979e6381576682 Fixes: OS#2407
2017-12-20TBF: implement independent T31xx timersMax1-1/+1
Previously TBF got single timer so the pending timer was automatically cancelled when new one was scheduled. Let's make it more robust by implementing independent T31 xx timers from 3GPP TS 44.060 §13.2 with corresponding start/stop functions and counters. The semantics of the timers is preserved as before: pending timers are restarted unconditionally. It might be neecessary to change this later on after spec review. N. B. T0: used for assign/reject timeouts, have to be properly attributed and documented first. Change-Id: I0305873ca47534f53441247217881da59625e1f7 Related: OS#2407
2017-12-20Introduce LOGTBF* for consistent loggingMax1-47/+33
When troubleshooting complex issues with TBF lifecycle, it's much easier to follow the logs which are consistently formatted. Add LOGTBF*() macro similar to struct-specific log routines we use in other Osmocom project and use it to log TBF-related messages in a unified way. Tweak test output accordingly. Related: OS#2407 Change-Id: I388249afefc32d2f6e5cb5e5abc6daf4dbd284ea
2017-12-18Fix tests after rate_ctr changeMax1-1/+9
Recent change lin libosmocore disallow registering rate_ctr with the same name and indexing multiple times. To accommodate to this check if rate counters arealready allocated (by static allocator of BTS singleton for example) and register rate counter with different index. This fixes the tests for now but eventually we'll remove the BTS singleton which will allow us to remove this hack. Change-Id: I7c552ce653b44ec3a31049641728926adc07361d Related: OS#2757
2017-12-05TBF: expand timer loggingMax1-3/+3
* log timer values * log start/stop cause * update test output as necessary This simplifies debugging issues with TBF timers. Related: OS#2407 Change-Id: Ib8e537416af9bec5d447356286f44e9e8bbf1b7a
2017-11-21Replace '.' in counter names with ':'Max1-85/+85
The '.' is an illegal character in counter names, as they are exported via CTRL interface, where '.' has a special meaning that cannot be used by strings comprising the variable name. Change-Id: I5ef60152a31dea25cb839c47edc93d5337ec3a3e
2017-11-16PCU: Fix TA adjustmentMinh-Quang Nguyen1-7/+49
Promblem: TA provided from L1 PH-DATA-IND is a relative amount of TA adjustment to actual TA being used for given TBF. The current TA update algorithm in PCU simply applies the relative amount of TA to given TBF but does not take into account of current TA. As a result, the PCU will request wrong TA jump for given TBF if the MS is moving away from BTS more than 2 km. Related issue: http://osmocom.org/issues/2611 Fixes: - The PCU needs increase or decrease current TA of given TBF on receiving of relative amount of TA adjustment provided by PH-DATA-IND from L1 - The PCU needs to set absolute TA of given TBF on receiving absolute TA provided by PH-RA-IND from L1. Change-Id: I65212f8203f1a35278890f51db038d689b2493d5
2017-10-29Call osmo_init_logging() before static BTS constructorHarald Welte1-0/+11
The BTS constructor uses functions of libosmocore that could in turn want to log something. This requires the logging to be initialized before. The only way to achieve this is to add an __attribute__((constructor)) function *before* the BTS constructor is being run. This solution might not be elegant, but I guess it's the only way to initialize a C library before calling C++ constructors of global static instance of a class. In case anyone comes up with a better / cleaner approach, we can always change later. This change requires libosmocore >= 0.10.1, as only that permits multiple calls to osmo_init_logging() which may now occur. Change-Id: I28dc4f0db229518348c92413959fed5ae85d753d
2017-09-04cosmetic: convert explicit warnings to fixme/todoMax1-1/+1
We do not use this style (#warning as an issue tracker replacement) in any other Osmocom project. Also those warnings clutter compiler output making it harder to spot warnings for the actual code. Change-Id: I72070e2a027e60e8b80c12ccfa23ff075434689f
2017-08-14Simplify polling troubleshootingMax1-1/+3
* introduce enum describing poll kind and use it in set_polling() * move state change into set_polling() * move logging into set_polling() and unify output * move duplicated code into static function * adjust tests to match unified logging output Change-Id: I14074207f8bbc18b3ebd60875bb99a0a3a4b399d Related: OS#1524
2017-08-14Move DL assignment to TBF-DLMax1-34/+0
This function does not really belongs to BTS and it heavily relies on direct access to TBF-DL members anyway. Change-Id: I04584103018675a2f35cfb565473bfd81a208d7c Closes: OS#1540
2017-08-14Move common code into functionsMax1-57/+36
* separate channel request responder into inline function * move generic TBF poll check into inline function Change-Id: I9ec3ab8de100f0bc75044f55ac769d1083d52806 Related: OS#1539
2017-08-14Encapsulate handling of UL ACK timeoutMax1-9/+6
Use helper methods instead checking and manipulating flag directly. Change-Id: Ia3f009c52118db95b38a077e08eecda844e7f8d1 Related: OS#1539
2017-07-29GSMTAP: Fix channel type for data blocks: PDTCH instead of PACCHHarald Welte1-2/+2
PACCH is used only for RLC/MAC control messages, while PDTCH is used for data. Change-Id: I6c912e17d8c8d4178096679a541e61eeeb4b6643
2017-07-21Introduce GSMTAP categoriesHarald Welte1-7/+34
When looking at GSMTAP output so far, one is easily overwhelmed by way too much information being presented. A lot of is consists of DUMMY frames, which are probably of lowest interest, ever. A concept similar to the "gsmtap-sapi" of OsmoBTS is introduced, by which the user can configure which particular categories (uplink or downlink control or data, gprs or egprs, ...) he actually wants to see in his logs. Change-Id: I297183690e98a7234dfc1608c18847d8981306e4
2017-07-12check for missing result of rate_ctr_group_alloc()Harald Welte1-0/+2
In case the counter group allocation fails, we must handle this gracefully and fail the allocation of the parent object, too. Change-Id: Id6d780c67b4af15aaa5c6f2b8b00f2a0b70a7385 Related: OS#2361
2017-07-10Remove TBF knowledge from rcv_control*dl_ack_nackMax1-20/+8
Do not access TBF internals directly from rcv_control*dl_ack_nack() - wrap corresponding code into TBF-DL method. Change-Id: I3d1b5782001e45617b4a960612fcfc249904b37c Related: OS#1539
2017-05-26Cleanup FN schedulingMax1-4/+8
* replace magic number with defined constant * move copy-pasted code to inline functions * remove unused code Change-Id: I6fee0714453d0c3c3f3f875f88daea2d9c477331 Related: OS#1524
2017-05-24Fix typo in loggingMax1-1/+1
DL-TBD was errorneously printed as UL-TBF. Change-Id: I94a224c0339a062e4c8d5aa6c4c858f3f0298a0d
2017-05-15remove pcu own bitvector implementationAlexander Couzens1-4/+4
The osmocore bitvec is exact the same, but use a pointer instead of a reference. Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7
2017-03-13bts.cpp: Fix overloading ambiguityMax1-5/+10
Fix error introduced in 1275a3f91a744e011b0dba82b09124d249c7abb5 by using signed 32 bit integer which is enough for Frame Number in GSM. Also, mark parameter constraints more explicitly: - add assert for expected FN values - don't perform computation for non-relative FN The error was: bts.cpp: In member function ‘uint32_t BTS::rfn_to_fn(uint32_t)’: bts.cpp:554:25: error: call of overloaded ‘abs(uint32_t)’ is ambiguous if (abs(rfn - m_cur_rfn) > RFN_THRESHOLD) { ^ In file included from /usr/include/c++/6/cstdlib:75:0, from /usr/include/c++/6/stdlib.h:36, from /usr/include/osmocom/core/linuxrbtree.h:97, from /usr/include/osmocom/core/timer.h:35, from ./bts.h:29, from bts.cpp:21: /usr/include/stdlib.h:735:12: note: candidate: int abs(int) extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; ^~~ In file included from /usr/include/c++/6/stdlib.h:36:0, from /usr/include/osmocom/core/linuxrbtree.h:97, from /usr/include/osmocom/core/timer.h:35, from ./bts.h:29, from bts.cpp:21: /usr/include/c++/6/cstdlib:185:3: note: candidate: __int128 std::abs(__int128) abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } ^~~ /usr/include/c++/6/cstdlib:180:3: note: candidate: long long int std::abs(long long int) abs(long long __x) { return __builtin_llabs (__x); } ^~~ /usr/include/c++/6/cstdlib:172:3: note: candidate: long int std::abs(long int) abs(long __i) { return __builtin_labs(__i); } Change-Id: Ib6d895a97aa35414f245ea4406c6e78f1b4fb5b8
2017-03-05BTS: Convert relative frame numbers to absolute frame numbersPhilipp Maier1-14/+57
The implementation of the method rcv_rach() in class BTS, restores the absolute frame number of the incoming RACH-Request by using the relative frame number (RFn = Fn mod 42432) from the rach request and the already known internal absolute frame number m_cur_fn, which is continusly updated by the CCU interface. In some rare cases, a RACH request might be received by the BTS, a very short time before the frame number wraps in its 42432. Depending on the PCU location, RACH request might be received by the BSC, which forwards it to the PCU. It is then likely that, while the RACH request is being forwarded to the PCU, the PCU internal absolute frame number wraps before the RACH can be processed. The relative frame number from the rach request would then be interpreted as if it were received after the wrapping of the internal frame number modulos. This commit adds logic to detect and resolve this race condition. Also a unit test is added to check some cornercases. Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759
2017-02-01cosmetic: Fix log outputPhilipp Maier1-2/+2
In BTS::rcv_rach() the log output is messed up because of a stray "\n". This commit removes that. Change-Id: I40d01c71982ad83589f070cf0047a4ae04695411
2017-01-26BTS: accept also relative frame numbers with rach requstPhilipp1-0/+15
The rach request contains a relative frame number (Fn % 42432), while BTS::rcv_rach() accepts the full frame number only. Since the BTS is always aware of the full frame number this is not a problem. But for BSC co-located PCU schemes it is a problem since the rach request only contains the relative frame number as mentioned above. The pcu continusly receives frame number updates with the GSM time indication message. It is simple to re-calculate the full frame number from that information. This patch makes BTS::rcv_rach() compatible with relative frame numbers, while not breaking the compatibility for full frame numbers Change-Id: Iaa182d8d29c6a0f5fa06064c2eb48b21b1ba2775
2017-01-24Handle packet access reject during packet resource requestaravind sirsikar1-1/+5
When Packet resource request is received, PCU will generate the packet access reject if no resources are present. The encoding is done based on section 7.1.3.2.1 and 8.1.2.5 of 44.060 version 7.27.0 Release 7. This patch also includes the test case to validate the generated packet access reject message. This patch is integration tested on Osmo-trx setup with Ettus B210 board and LG F70 MS with some simulation code changes in Osmo-pcu. Change-Id: I05ff25124b58905586caa0c0c37023d69724f121
2017-01-16Log additional info for radio errorsMax1-2/+11
Change-Id: I936a07ce87f05d9c3dc351dc3bdc4f00d78265e0 Related: OS#1553
2016-12-22Add counter at BTS level And statistics at TBF/MS level.sivasankari1-0/+4
Adds spb counters at BTS level(show bts statistics). Adds RLC/MAC downlink control msg at ms level(show ms imsi <imsi_val>). Adds the number of coding schemes counter for UL at TBF level. Change-Id: Icbe4ba95e34bea89ee36f532d099db68204b7c38
2016-11-25Add new BTS level counterssivasankari1-1/+11
Adds counters for Immediate Assignment Reject, Packet Access Reject, Channel Request Description and Final Block resend. Change-Id: I23e326d4ea489aa4967e452fe02773b44ab146f7
2016-11-14Add BTS level countersMrinal Mishra1-2/+51
Adds counters for MCS blocks, 11 bit Rach counters and others. Change-Id: I605b0d66eb217decd35cbb8f87abfa577760245a
2016-11-11Handle packet access reject during EPDAN/PDAN with channel descriptionaravind sirsikar1-10/+24
When PDAN/EPDAN with channel description is received, PCU will generate the packet access reject if no resources are present. The encoding is done based on section 7.1.3.2.1 and 8.1.2.5 of 44.060 version 7.27.0 Release 7. This patch also includes the test case to validate the generated packet access reject message. This patch is integration tested on Osmo-trx setup with Ettus B210 board and LG F70 MS with some simulation code changes in Osmo-pcu. Change-Id: I096a3bb44a65533b9e9b091925dd5f70a8696d6
2016-11-09Handle Immediate assignment rejectaravind sirsikar1-42/+65
When RACH is received, PCU will generate the Immediate assignment reject message if no resources are present. The encoding is done based on section 9.1.20 of 44.018 version 11.7.0 Release 11. This patch also includes the test case to validate the generated Immediate assignment reject message. This patch is integration tested on Osmo-trx setup with Ettus B210 board and LG F70 MS with some simulation code changes in Osmo-pcu. Change-Id: I3d33e2b9746fa4f338fad0e6b63b1c5f07de6f9b