aboutsummaryrefslogtreecommitdiffstats
path: root/CommonLibs
AgeCommit message (Collapse)AuthorFilesLines
2019-09-20radioInterface: Atomically fetch and change underrun variablePau Espin Pedrol2-3/+29
Otherwise, it could happen that underrun events are lost: TxLower (isUnderrun): RxLower (pullBuffer): read(underrun) read(underrun) write(underrun, |val) [maybe underrun becomes TRUE] write(underrun, false) Similary, it could happen the other direction if atomic was only applied to isUnderrun: TxLower (isUnderrun): RxLower (pullBuffer): read(underrun) -> true read(underrun)-> true write(underrun, false) write(underrun, true|val) where val=false So in here isUnderrun would return true twice while it should only return one. Change-Id: I684e0a5d2a9583a161d5a6593559b3a9e7cd57e3
2019-08-01lms: Drop rx_underruns rate ctr, add tx_drop_* rate ctrPau Espin Pedrol4-11/+18
After discussion in [1] and further look at the code, it became obvios rx_underrun events are not happening in general for any SDR (don't exist), so let's drop that counter. Instead, add Tx Dropped Packet counters, which were not accounted prior to this commit. [1] https://github.com/osmocom/osmo-trx/commit/bde55afd29fc9aae10eb11f6515821afa39b772d Change-Id: Iff1535c219a4695a511d383d7c4b06ef6eff959d
2019-07-22Add SPDX annotationPau Espin Pedrol17-1/+52
Related: OS#3515 Change-Id: I3719bd8dc015569ecd81928fc079e27593cdca09
2019-07-22cosmetic: Fix trailing whitespace in several filesPau Espin Pedrol2-5/+5
Change-Id: Ifafb68353960fc5046661854ccfb8d783b0efb14
2019-07-21Timeval: Restore output stream flags after changing themHarald Welte1-1/+2
Change-Id: I866505f29ed56d8f3ba3aaba70c0d82479987c64 Closes: CID#149361
2019-07-19Logger: global Log mutex is now available from C codePau Espin Pedrol3-7/+75
This way the C++ logging API can still be used while allowing for C files to use the same mutex. Change-Id: I473e57479f8ae98a84ad00b76ff338f79f732236
2019-07-02Transceiver: replace UDPSocket with libosmocore socket APIPau Espin Pedrol3-462/+0
We have a good socket API in libosmocore, let's drop osmo-trx socket API and use libosmocore's one instead of maintaining the two of them. Change-Id: Ib19856a3e0a7607f63436c4a80b1381a3f318764
2019-06-25trx_{vty,rate_ctr}: Set proper license AGPLv3+Pau Espin Pedrol2-13/+19
Take the chance to improve text with author, SPDX tag and fix incorrect copyright dates. Related: OS#3515 Change-Id: Ic745312ed07db205b1cdc0f2fa130000319354c5
2019-06-17Add option to set stack size in config file, default == 0 == OS defaultEric Wild4-3/+22
Change-Id: Id752f6b5ce9a96a67cd1ff835687ce0e03d3a50d
2019-06-11Add VTY commands to set error ctr thresholdsPau Espin Pedrol3-7/+287
osmo-trx will validate over time that those thresholds are not reached. If they are reached, osmo-trx will die. As a result, osmo-bts-trx will notice and will end up notifying the BSC about it (for instance because it will also restart its process). For instance: """ ctr-error-threshold rx_drop_events 2 minute ctr-error-threshold rx_underruns 10 second """ In those cases above, osmo-trx will die if rate_ctr rx_drop_events went to a value higher than 2 per minute, or it will die to if rx_underruns went higher than 10 per second. Change-Id: I4bcf44dbf064e2e86dfc3b8a2ad18fea76fbd51a
2019-06-05Rename and move STOP signal from Transceiver to mainPau Espin Pedrol1-4/+4
The callback actually belongs there, since it's the code/thread in main the one actually in charge of stopping everything. It simplifies current code, and more important, allows for new clients of this signal to use it. This callback will also be used in forthcoming commits by code controlling rate_ctr thresholds to stop the process if the VTY configured threshold is used. Change-Id: Id4159e64225c6606fef34a74b24f37c3a071aceb
2019-06-05Add rate_ctr support to store/retrieve SDR errors through VTYPau Espin Pedrol4-0/+205
Introduce a unified implementation-agnostic interface for radioDevice to signal SDR error counters to upper layers and manage them. This patch only implements counters for osmo-trx-lms (other devices will show all counters unchanged during time). Sample use through VTY: """ OsmoTRX> show rate-counters osmo-trx statistics 0: device:rx_underruns: 0 (0/s 0/m 0/h 0/d) Number of Rx underruns device:rx_overruns: 0 (0/s 0/m 0/h 0/d) Number of Rx overruns device:tx_underruns: 0 (0/s 0/m 0/h 0/d) Number of Tx underruns device:rx_drop_events: 4 (0/s 2/m 3/h 0/d) Number of times Rx samples were dropped by HW device:rx_drop_samples: 513 (0/s 196/m 425/h 0/d) Number of Rx samples dropped by HW """ Change-Id: I78b158141697e5714d04db8b9ccc96f31f34f439
2019-05-06Introduce LOGCHAN macro to standarize logging channel infoPau Espin Pedrol1-0/+3
Change-Id: I67d869499aa16af58c863ca7b74c356bcd979936
2019-04-25Move duplicated thread_enable_cancel to CommonLibsPau Espin Pedrol2-0/+7
Change-Id: I1a479b59bdda01233273dfa919bd678edbe34708
2019-04-25cosmetic: Threads.h: Remove trailing whitespacePau Espin Pedrol1-2/+2
Change-Id: I0ae6e435a7f0480c3eaa08dccfe824456f33b015
2019-04-11multi-ARFCN: fix maximum number of carriers limitationTom Tsou2-3/+15
Maximum number of carriers is fixed to 3 channels on a single physical RF channel in multi-ARFCN mode. For some reason, it was limited to 5. Let's fix this, and also follow this limitation in the following VTY command handlers: - cfg_multi_arfcn_cmd, - cfg_chan_cmd. Change-Id: I66a1462f368458afd313ee6f0bc0abc496dde817
2019-01-24VTY: add extended (11-bit) RACH detection toggleVadim Yanitskiy2-0/+19
Since I838c21db29c54f1924dd478c2b34b46b70aab2cd we have both TS1 and TS2 synch. sequences, in addition to "default" TS0. Let's finally introduce the VTY configuration parameter, that can be used to toggle optional detection of both TS1 and TS2. Note: we keep this optional because of potentially bad impact on performance. There's no point in paying the performance penalty unless upper levels (BTS, PCU) actually make use of it. Change-Id: I1aee998d83b06692d76a83f79748f9129a2547e8 Related: OS#3054
2018-12-13Timeval: Move to osmo_clock_gettimePau Espin Pedrol2-1/+10
Change-Id: I24da3e1136c5396062662be1d10b07b4d97cfc2e
2018-12-13Timeval: Move implementation to use clock_gettime and timespecPau Espin Pedrol2-28/+28
According to gettimeofday manual: "Applications should use the clock_gettime() function instead of the obsolescent gettimeofday() function." Furthermore, it may be desirable in the future to use other clocks such as monotonic. Change-Id: I2286998c5eefbf3c3dfb105c223daec7a1083803
2018-12-13Timeval: passed() returns true if time is equalPau Espin Pedrol1-1/+1
Change-Id: I96a9d26657f85447609693bc6932d218d354b84a
2018-12-12osmo-trx.cpp: move comma_delimited_to_vector() to Utils.cppOliver Smith3-0/+62
Make the "opt" argument const. This function will also be used by LMSDevice.cpp in a follow-up commit. Related: OS#3654 Change-Id: If3f0f682ca453c2b0a06175ec9626567932cfce6
2018-12-07Add TRXCTRL log categoryPau Espin Pedrol2-0/+7
This log category is applied to messages related to TRX CTRL socket interface, and it's printed in yellow, same color used in osmo-bts-trx for TRX category (so same messages are printed with same color in both sides). Change-Id: I98ec5e416272783ad3fbadf70478a4e48ae64983
2018-12-05SigProcLib: Improve Vector buffer allocation messPau Espin Pedrol1-12/+31
Original issue: In order to use SSE instructions, 16-byte aligned memory chunks are needed, and C++ version < C++11 doesn't provide for a native new/delete store. For that reason, memalign() must be used in the implementation of convolve_h_alloc() for some buffers. On the other side, The C++ code relies on C++ "new T[]" operator to allocate a chunk of memory containing an array of class instances. As classes are complex types, they cannot be allocated through C structures (calling malloc). Experimentally can be seen too that it's unreliable and the process will crash during startup if malloc() is used and then a Complex<> deferred from it. Previous implementation allowed for use of convolve_h_alloc or new[] based on how the (signal)Vector is called, because then the buffer is not going to be managed internally. But that's unreliable since resize() calling resize() on it could use "delete" operator on a malloc'ed buffer, and end up having a new new[] allocated buffer. It was also found that some of the callers were actually leaking memory through ASan (because the buffer is not managed by the Vector instance). IMHO best option would be to rewrite all this code using C structures and malloc/free exclusively, since it would make all this cod eeasier to maintain. But for now, let's extend the Vector class to allow specifying an external alloc/free function and let the Vector instance take care of the ownership of the buffer in all scenarios. Change-Id: Ie484a4762a7f77fe1b105188ea03a6f025730b82
2018-12-03PointerFIFO: Fix memleak of ListNodePau Espin Pedrol2-0/+20
Found by ASan. when PointerFIFO::release() is called, alloicated node being released is actually stored into an internal list for later-reuse without having to access memory allocator. However, nodes from this list are never freed. Change-Id: I40e5e28603cde67005d9d92772967b05465ea2b8
2018-10-02CommonLibs/Makefile.am: Specify libcommon_la_LIBADDPau Espin Pedrol1-0/+1
This way the dependencies are passed after the .la object, which seems to be the correct order. Some setups may fail to find some symbols from libosmocore otherwise (OBS i586). Change-Id: I22c80055bcffd4179a0a8ca76533ba7aaa38c859
2018-09-28Use pthread_setname_np to name threadsPau Espin Pedrol2-2/+23
osmo-trx can start a considerable amount of threads that can make debugging it challenging at least. By using phtread_setname_np, the system sets a meaningful name to the thread which can be seen while debugging with gdb or by printing /proc/$pid/task/$tid/comm. Now we also log system TID when setting the name so we can identify different tasks in /proc even if pthread_setname_np fails. Change-Id: I84711739c3e224cb383fd12b6db933785b28209e
2018-09-10Vector: Copy arrays in a sane way for non-trivially copyable typesPau Espin Pedrol1-3/+8
Avoids this type of compilation warnings: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class Complex<float>’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] Change-Id: I9724454dfb7b87f74f39074e4004580ac3b5fe5c
2018-09-10cosmetic: Fix trailing whitespace in several filesPau Espin Pedrol1-1/+1
Change-Id: Ibf5a69f0a3a309e87814635fd903b114fe68890c
2018-09-10SigProcLib: Use available copyTo Vector API instead of memcopyPau Espin Pedrol1-1/+1
This change allows to remove some wrong use of code as per compilation warning: osmo-trx/Transceiver52M/sigProcLib.cpp:1266:40: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class Complex<float>’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] midMidamble->size() * sizeof(complex)); Change-Id: Id446711349bec70fa4e7c8efe0f7f9faf7e4f277
2018-09-04osmo-trx: Add osmo_signal to stop whole transceiver chain correctly on errorPau Espin Pedrol2-0/+36
Transceiver::stop() can only be called from either CTRL iface thread or from main thread (running osmocom loop). That's because stop attempts to cancel and then join all the other threads, which would then lock if attempting to stop from some of them. As a result, the best option is to indicate to the user of the transceiver option (osmo-trx.cpp) to stop it in a correct fashion by destroying the object from the main thread. Change-Id: Iac1d2dbe2328e735db2d4b933cb67b1af1babca1
2018-09-03Logger: Disable pthread cancel point inside Logger destructorPau Espin Pedrol1-0/+3
pthread_cancel is implemented in c++ using exception handlers. In destructor of Log object, the log function is called which will eventually call fputs() to write to a file. Since that function is considered a cancelation point, if pthread_cancel has been called the exception handler will start unstacking frames and calling destructors in the process. At some point this will cause a runtime exception in c++ which will call std::terminate() to abort the process. The solution is thus to avoid starting the cancellation process inside the destructor. This behavior was spotted while calling the destructor of Transceiver object in forthcoming patches. See a more detailed example here: https://skaark.wordpress.com/2010/08/26/pthread_cancel-considered-harmful/ Change-Id: I71ca90f3fbc73df58b878a03361f7b7831d838b4
2018-08-27vty: Fix typo in gpsdo clock reference typePau Espin Pedrol1-1/+1
Change-Id: I3f553c2cec9689524728cacb15b7daaff8166925
2018-08-17logging: Introduce new "DDEV" category for device-specific codeHarald Welte2-1/+8
The DMAIN category got too overloaded. Let's have the code in Transceive52M/device/* use the new DDEV category. Also, in some cases the log levels have been adjusted to ensure that enabling INFO level should not result in a complete overflow of messages during normal operation. Change-Id: I844fe4a75bf277cd3cc5bd8fa06e06ad97b2ea95
2018-07-31Fix config file saving of {tx,rx}-path VTY config stringsHarald Welte1-2/+2
We were missing one indent level when writing the rx-path and tx-path Change-Id: I5d5b02c71d39220cabc2a23d059908ef3c6350e0 Closes: OS#3435
2018-06-13lms: Several improvements and compilation/runtime fixesPau Espin Pedrol3-0/+10
Continuation of initial work done on LimeSuite support from Harald. Change-Id: Ib2fca81b76d027b08e2891056fa076d071597783
2018-05-09trx_vty.c: fix: use CONFIG_NODE as parent by defaultVadim Yanitskiy1-1/+3
There are some configuration nodes, which are handled by extenral libraries, such as libosmoctrl. So, when switching back to the parent node, this should be kept in mind. Instead of aborting, let's got to the CONFIG_NODE by default. Fixes: OS#3250 Change-Id: Ia0600a46d19825806e5aed9257b6c57c3907808b
2018-04-27build: Fix make distcheckPau Espin Pedrol1-4/+0
Change-Id: I1fa5e34b44331cd56408ea7ad4483dcf6443b259
2018-04-25Logger: Print correct source file and line numberPau Espin Pedrol2-5/+8
Before this commit, always Logger.cpp:53 was being printed. Change-Id: Ie5c64b4961c7c41d23484784a93eda5e08331f08
2018-03-05vty: Implement VTY cfg parsing for current parametersPau Espin Pedrol2-1/+468
At this stage, osmo-trx still uses the cmdline parameters top run the device, but it is already able to parse all the same parameters from a cfg file through the VTY and filling a trx_ctx structure which will be later used to drive the device. Device config can be printed in the VTY with "show trx". Change-Id: Ie084c1b30b63f91c6e7640832ec1797d9e813832
2018-03-05Move enums required by VTY to a separate headerPau Espin Pedrol2-1/+22
This patch is a preparation for next patches, which add full VTY cfg support. Change-Id: I3d5b0576aa96869756f1629a40306c0043b6304b
2018-02-27Logger: Use libosmocore logging systemPau Espin Pedrol3-112/+29
We still need an intermediate class Logger due to osmo-trx being multi-threaded and requiring to have a lock to use libosmocore, which is not thread safe. Change-Id: I30baac89f53e927f8699d0586b43cccf88ecd493
2018-02-27Add initial support for logging, vty, ctrlPau Espin Pedrol5-2/+208
Up to this point, the logging system, vty and ctrl are initialized and can be used fine, though they don't have a lot of use yet. Depends on libosmocore Change-Id Ib79cdb62d45d8c78445c7b064e58eb7e9faeccf9 Related: OS#2184 Change-Id: I08982c37b4f873966304b3cfb38a10ee86eb3dad
2018-02-20Logger: Remove gLogToConsole flagPau Espin Pedrol2-15/+8
No code is using it and we always lock to console anyways. Change-Id: I5fde99c6af5a845e635b5d27abab855682071f14
2018-02-20Logger: Remove unused includesPau Espin Pedrol1-4/+0
Change-Id: I4d26c0b4f36ee3c66ed1a9e2e9fa2fa8272da16d
2018-02-20Logger: Drop support to log into filePau Espin Pedrol1-19/+1
This feature is currently not being used, so let's simplify current code to move to libosmocore logging system in the future. Change-Id: If2c77c776823f595130edac963be953026049423
2018-02-20Logger: Drop syslog supportPau Espin Pedrol2-39/+12
This feature is currently not being used, so let's drop it to make it easier to integrate into libosmocore logging system in the future. Change-Id: I8282745ef0282d41599eaf94fe460a1d29b18e2a
2018-02-20Logger: get rid of alarm APIsPau Espin Pedrol2-51/+0
It's only used internally inside the Logger module, and in case there's an "alarm" (level more than critical) we still print on cerr, so we can just rely on our system catching stderr instead of stdout to handle it. Change-Id: I6d6df1578c3a4c1a37bd0d69952d443f62eed2ab
2018-02-20Logger: Remove unused logging macrosPau Espin Pedrol1-17/+0
Change-Id: I1133e181183bec8dabe2fa77d0385f783458503f
2018-02-20Logger: Drop unused gLogEarlyPau Espin Pedrol2-35/+0
Change-Id: I2c8f24fbf453e0a94d7a95c3df7cc75f0e4bd456
2018-01-23Remove unneeded libdl dependencyPau Espin Pedrol1-1/+1
Closes: OS#1929 Change-Id: I0caea2a2a8e6bd07432fd73bae72b42b1ce022cd