Commit Graph

1257 Commits

Author SHA1 Message Date
Max 869c0c2e55 Fix llc_queue_size() type
It either returns 0 or LLC queue size() which has size_t return
type. This means it can never be negative - hence it's better to use
size_t as return type.

Change-Id: I2a6e849d349ab12854976bd0d68537a370a9c83d
Fixes: CID181478
2018-01-03 12:00:36 +01:00
Max 0bc982e714 TBF: bail out for unknown timers
Return right after logging error if attempting to start or stop unknown
timer.

Change-Id: Ie6ae564d41a5e03270685c6bafb3504278eb3551
Fixes: CID181512, CID181514
2018-01-02 07:26:05 +00:00
Max 467f633b16 TBF: log timer invocation source
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-02 07:26:05 +00:00
Max b2de1f7888 TBF: unify timer handling
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
2018-01-02 07:26:04 +00:00
Max effdec6e13 Add optional profiling support
This facilitates the use of programs like uftrace. It's disabled by
default due to associated overhead.

Change-Id: I5c16988cefa46e0b958030c0f3bff9efc5b4979d
2017-12-28 14:18:02 +01:00
Max 20c7c46bce Add tests for pcu_lsb()
This utility functions is used by TBF allocation routines and only
tested indirectly through allocation test. Let's add proper exhaustive
test which checks all uint8_t values.

This also requires adding missing include to pcu_utils.h

Change-Id: If08a7f0d31f0e5ad8a5efa5885880aed19c329ab
2017-12-22 14:20:05 +01:00
Max 406a1f0acf Enable sanitize for CI test
Change-Id: Ia33ffb9b25df587706367bc24925cf9cead3b9a0
2017-12-21 17:34:19 +01:00
Max b2f0b62cd4 Add --enable-sanitize configure option
Change-Id: Idb2c1d6057012ed2f032e7504387a0767d02d75b
2017-12-21 17:27:34 +01:00
Max 327e121a0f Add function to get max supported MS class
It's useful for allocation tests.

Change-Id: I31d503af700ec3364042ff7e661710953cacf9f8
Related: OS#2282
2017-12-21 15:13:25 +01:00
Max 1714aeaa67 Fix warnings
Fix warnings detected by compiler and coverity scan.

Change-Id: If463c7f8769e18d3df74837f0cb0f545cca9b23e
Fixes: CID181479
2017-12-21 11:19:39 +01:00
Max 59e4a4fee1 TBF: add N3101 counter
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-20 18:01:55 +01:00
Max ee5be3a009 TBF: implement independent T31xx timers
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-20 17:49:25 +01:00
Max c21f007277 Introduce LOGTBF* for consistent logging
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-20 14:14:40 +00:00
Max ea9968f685 Fix tests after rate_ctr change
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-18 22:58:28 +00:00
Max ef784e4e9e Remove unused includes and forward declarations
Change-Id: I59da04edd1b8ff965bbfbe00ccae1f7c9b6e5301
2017-12-18 22:05:22 +00:00
Max 912131803b TBF: remove unused variable
The num_T_exp is write-only so it can be safely dropped.

Change-Id: I94d83ca8c9b2f0732b53fdf42b17ba93cd7f1c15
2017-12-15 17:44:47 +01:00
Max 1a11d1db09 TBF-DL: fix misleading idle time check
The dl_tbf_idle_msec is uint32_t so it cannot be < 0.

Change-Id: Ic88cb4698bcb9be52a5179529f81b8728bf4f93f
2017-12-15 14:28:34 +00:00
Max 25a3ca4e59 TBF: move EGPRS enablement into (U|D)L-TBF
This is preparation patch for transition to separate UL/DL window
variables instead of current shared generic window. The setting of
window parameters is performed in functions specific to UL/DL TBFs but
the general EGPRS flag remains the same and is set via the same function
which is now marked as protected since it's only meant to be used by
UL/DL subclasses.

Related: OS#1759
Change-Id: I6056194b28a1eb9d69093d1dfdc65a11bc1fc579
2017-12-14 12:20:53 +01:00
Max ead08aae35 DL window: constify resend_needed() function
It doesn't change any state so mark it as const.

Change-Id: I5d672bfd654198aebb187772de464c52b3209435
2017-12-13 18:25:36 +01:00
Max 39eb95f130 vty: print class and TBFs for each MS
It's handy for troubleshooting to get quick overview of per-MS TBF
allocations and MS [EGPRS] classes.

Change-Id: Ie79c20f86da6db4565654b0f5856f4fddd83ef96
2017-12-06 13:15:32 +01:00
Max cea806e5b9 TBF: expand timer logging
* 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-12-05 18:47:22 +00:00
Max b4d368b576 TBF: fix compiler warning in test
tbf/TbfTest.cpp: In function ‘void egprs_spb_to_normal_validation(BTS*, unsigned int, unsigned int)’:
tbf/TbfTest.cpp:2788:26: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
  bsn1 = (egprs2->bsn1_hi << 9) || (egprs2->bsn1_mid << 1)
         ~~~~~~~~~~~~~~~~~^~~~~
tbf/TbfTest.cpp:2788:53: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
  bsn1 = (egprs2->bsn1_hi << 9) || (egprs2->bsn1_mid << 1)
                                   ~~~~~~~~~~~~~~~~~~^~~~~
tbf/TbfTest.cpp:2825:26: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
  bsn2 = (egprs3->bsn1_hi << 9) || (egprs3->bsn1_mid << 1) ||
         ~~~~~~~~~~~~~~~~~^~~~~
tbf/TbfTest.cpp:2825:53: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
  bsn2 = (egprs3->bsn1_hi << 9) || (egprs3->bsn1_mid << 1) ||
                                   ~~~~~~~~~~~~~~~~~~^~~~~
tbf/TbfTest.cpp:2844:26: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
  bsn3 = (egprs2->bsn1_hi << 9) || (egprs2->bsn1_mid << 1) ||
         ~~~~~~~~~~~~~~~~~^~~~~
tbf/TbfTest.cpp:2844:53: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
  bsn3 = (egprs2->bsn1_hi << 9) || (egprs2->bsn1_mid << 1) ||
                                   ~~~~~~~~~~~~~~~~~~^~~~~

Change-Id: Idf9e5f15faa7810411ed9d68ed43cf907eea2545
2017-12-05 18:47:21 +00:00
Pau Espin da0a194b57 Print error cause of pcu socket connect failure
This log is useful to quickly debug scenarions in which pcu never
connects to bts. For instance, if bts is started as root and pcu is not,
pcu will fail to connect to the socket and will fail with "Permission
Denied".

Change-Id: I6fd5736b5916cbad72b96f064929bb667ff97ded
2017-12-05 18:44:06 +01:00
Max 59f50c2718 TBF: log timer override
Currently TBF support only single Txxxx timer so scheduling another
timer will cancel out the one which is already running. Until the proper
fix is in place, let's at least log this situation as error.

Note: cosmetic adjustement to test output is required - we do not report
restart of the same timer twice because "restarting" assumes it anyway.

Change-Id: I462464a1e6df937b72cad65d19cd48e95dc4db45
Related: OS#2407
2017-12-04 10:55:47 +01:00
Max 701afa4b3a Fix compiler warning
Move function declarations which use gprs_rlcmac_ul_tbf into tbf.h to
avoid compiler warning:

In file included from pcu_vty.c:15:0:
bts.h:166:27: warning: ‘struct gprs_rlcmac_ul_tbf’ declared inside parameter list will not be visible outside of this definition or declaration
 void update_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, int8_t ta_delta);
                           ^~~~~~~~~~~~~~~~~~
bts.h:167:24: warning: ‘struct gprs_rlcmac_ul_tbf’ declared inside parameter list will not be visible outside of this definition or declaration
 void set_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, uint8_t ta);
                        ^~~~~~~~~~~~~~~~~~

Change-Id: Ic34c72c8bff6d7c775f56bb6026fec5425f7dcb4
2017-12-01 17:19:04 +01:00
Max a5eb67d91c Replace '.' in counter names with ':'
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-21 20:24:54 +01:00
Max 842d781b5e Move multislot table to separate file
To facilitate testing and addition of support for new multislot classes,
hide multislot class struct internals:

* introduce mslot_class_get_*() functions
* use those functions instead of direct access to array of structs
* use ms_class as a parameter to find_multi_slot() instead of entire
  object

Change-Id: Id796bcff1322b1e273a0e3236c66c23b9da8fac6
2017-11-21 10:45:24 +00:00
Max b709144f1b Remove unused parameter
Change-Id: Ifd6e04a29e27b1862cf9e98dec7481d3e0efcd48
2017-11-21 10:45:22 +00:00
Minh-Quang Nguyen 8d55563523 PCU: display TA information in TBF stats
Change-Id: I26886224c2ad6d5a29e92203635b8bf7459730a2
2017-11-16 10:06:58 -05:00
Minh-Quang Nguyen 1bcfa9aacf PCU: Fix TA adjustment
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-11-16 10:06:41 -05:00
Neels Hofmeyr bfc54b551b vty: skip installing cmds now always installed by default
vty_install_default() and install_default() will soon be deprecated.

Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b
Change-Id: I6c9f928f4a4d7fd6bf37c64a64ee5d843ad5bb7a
2017-11-01 00:51:51 +01:00
Neels Hofmeyr 49beba49eb jenkins: use osmo-clean-workspace.sh before and after build
See osmo-ci change I2409b2928b4d7ebbd6c005097d4ad7337307dd93 for rationale.

Depends: I2409b2928b4d7ebbd6c005097d4ad7337307dd93
Change-Id: If8aa657c4bf62ef62549fbe9dc15ce3fb018d8d9
2017-10-30 04:22:10 +00:00
Harald Welte d34ec1b969 Tag/Release Version 0.4.0
Change-Id: I8559585a4513dddf1516c2a2b08968556c69b7ec
2017-10-29 12:10:13 +01:00
Harald Welte 47c682937c Debian: upgrade to debhelper 9 / Standards 3.9.8
Change-Id: I1fd274d85b8fd344517d62dd9e6adc4af6de3e26
2017-10-29 12:10:13 +01:00
Harald Welte e64917a932 Debian: migrate from DEB_BUILD_HARDENING to DEB_BUILD_MAINT_OPTIONS
Change-Id: Ic400c509ecd0c6e8485e9433f144528f6abc600d
2017-10-29 12:10:13 +01:00
Harald Welte 9dab1baef8 Debian: print test results in case of failure + clean-up autotest
Change-Id: Id912a106d42bbd9d2ad89b67d16d52cb2344eb6d
2017-10-29 12:10:13 +01:00
Harald Welte f826e8ab2b Debian: Cosmetic changes to control file; add better Description
Change-Id: I0a8bf134757f6ed754bfefd45a9fdac255447e43
2017-10-29 12:10:13 +01:00
Harald Welte 3e51d3e5bd Call osmo_init_logging() before static BTS constructor
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-10-29 11:02:34 +01:00
Harald Welte ac0490ad2a tests: Don't use private version of log_info but global gprs_log_info
There's no need for each test case to carry their own log_info and
filter function.  They can simply use the global gprs_log_info and
configure the stderr log verbosity according to their needs.

Change-Id: I8706a624e5d06e062d1198711aa197fbd0860769
2017-10-29 11:02:34 +01:00
Philipp Maier 4c9ec22546 gb: allow only packets from a specific SGSN
Each PCU has a specifically assigned SGSN, which may send
packets to the PCU. Ensure that no one else except the
configured SGSN can send packets to the PCU.

Change-Id: Ic2009039fab7cf0fba916556239747ae5b410366
Depends: libosmocore Ifeb201d9006eec275a46708007ff342cdfc14e45
2017-10-24 10:50:17 +00:00
Max a4f4822784 cosmetic: reformat multislot classes table
Add header similar to the one used in the standard, reformat to
facilitate further extention.

Change-Id: I786df6b154c0668d2cefa0ea84d7dea336b0da1d
Related: OS#2282
2017-10-10 19:02:43 +02:00
Max 5b0df1f1c5 TS alloc: properly count UL slots
Add cycle to mark multiple allocated UL slots similar to the way we
count DL slots in AllocTest. Until multislot UL allocation is
implemented it does not affect test output.

Change-Id: I2705405119421da3066c6c6bdd5830df4c133a36
Related: OS#2282
2017-09-12 11:58:29 +02:00
Max 5759a19020 TBF-DL: extend index check for RLC block copy
Log number of RLC blocks to copy and assert if trying to copy too many
blocks.

Change-Id: I01cbc26ec67400a44e9fff3f9a30d729320380f9
Fixes: CID143069
2017-09-08 12:58:28 +00:00
Max 1962136a33 Assert valid CS
The coding scheme converted to number make sense only if it's
valid. This is implicitly assumed by the code using this conversion as
non-zero value. Make those assumptions explicit with OSMO_ASSERT().

Change-Id: I8f62627b7b7b89dfa1b0d1a7e71b95b2c40fdffa
Fixes: CID70466
2017-09-08 12:51:03 +02:00
Max 5a6bcfb797 cosmetic: convert explicit warnings to fixme/todo
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-09-04 13:06:01 +00:00
Max 8bfa659087 Move gsmtap and accounting into separate function
Change-Id: I3609da1850244f25bd4611c9d25795ca379d6325
2017-09-01 11:08:06 +02:00
Max 84bf0faed9 Support receiving SI13 from BTS
* store SI13 in BTS struct
* check and handle BCCH SAPI

Change-Id: I610a93ce23725b182ec14e3507331295bd542f74
Related: OS#2400
2017-09-01 11:08:06 +02:00
Max b216c6b165 cosmetic: tighten direct-phy related code
* move the code to related SAPI case
* get rid of 'unused variable' warning if direct-phy is not used

Change-Id: If8cae6f3579cfdecc25bbe1d08fa88a4f664a03b
2017-09-01 11:08:06 +02:00
Max 10e37a5089 Use value string check from osmo-ci
Change-Id: Ib9c595ef80cb6b0d126d4da8244f6435e0526095
2017-08-24 19:04:44 +00:00
Max d78adfb577 Facilitate future releases
* use release helper from libosmocore
* use semantic versioning

Change-Id: Ie0a7f5977550bd0a1ba8b03bdb7e2d619a398e4e
Related: OS#1861
2017-08-24 13:53:25 +02:00