Commit Graph

126 Commits

Author SHA1 Message Date
Vadim Yanitskiy cb98894eb1 TLLI 0x00000000 is a valid TLLI, use 0xffffffff instead
The assumption that TLLI 0x00000000 is invalid and can be used
as the initializer is wrong.  Similar to TMSI, 0x00000000 is a
perfectly valid value, while 0xffffffff is reserved - use it.

According to 3GPP TS 23.003, section 2.4, a TMSI/P-TMSI with
all 32 bits equal to 1 is special and shall not be allocated by
the network.  The reason is that it must be stored on the SIM,
where 'ff'O represents the erased state.  According to section
2.6 of the same document, a local/foreign TLLI is derived from
P-TMSI, so the same rule applies to TLLI.

I manually checked and corrected all occurances of 'tlli' in the
code.  The test expectations have been adjusted with this command:

  $ find tests/ -name "*.err" | xargs sed -i "s/0x00000000/0xffffffff/g"

so there should be no behavior change.  The only exception is
the 'TypesTest', where TLLI 0xffffffff is being encoded and
expected in the hexdump, so I regenerated the test output.

Change-Id: Ie89fab75ecc1d8b5e238d3ff214ea7ac830b68b5
Related: OS#4844
2020-11-10 17:06:39 +00:00
Pau Espin 8072e354cc Move EGPRS MS mode set to gprs_ms.cpp
Some tests were wrong (TypesTest) and required modification, since they
were setting a EGPRS MS but then expecting a GPRS assignment.

Change-Id: I9d3ee21c765054a36bd22352e48bde5ffca9225a
2020-11-04 21:39:42 +01:00
Pau Espin e9f77d377b tbf: Set MS during constructor time
This is another step forward towards a more clear data model where a TBF
always has a MS object (which may be lacking some information, and at a
later point when more information is found, it may actually be a
duplicated MS object and hence one duplicate removed and the TBF moved
to the object being kept).

This helps for instance in removing duplicated information stored in
the TBF which is really per MS, like ms_class, ta, etc. Since there's
always a MS object there's no need to keep a duplicate in both classes
in case there's no MS object.

It can already be seen looking at unit test logging that this kind of
data model already provides better information.
Some unit test parts were needed to adapt to the new model too.

Change-Id: I3cdf4d53e222777d5a2bf4c5aad3a7414105f14c
2020-10-24 22:14:42 +02:00
Pau Espin a611b4f6a0 Fix several calls to LOGPAL
In those cases since a string pointer was passed, it always printed
"single" instead of whatever really was being used, since the string
pointer was not NULL.

Change-Id: Idab7d18e8f519e10fc3df4007634661c46f9256d
2020-10-23 17:13:04 +02:00
Philipp Maier de0e558baf gprs_debug: Use only LOGL_NOTICE as default loglevel
The default loglevels of some log categories are configured to
LOGL_INFO. This is still to verbose, lets use LOGL_NOTICE here.

Change-Id: Ibb1cd1a94fb4fdd0147e073f8c1c82562c2c14ef
Related: OS#2577
2020-05-13 16:41:55 +00:00
Pau Espin 322456ed47 Expect ms object to exist before calling tbf_alloc_dl_tbf()
Same as previous commit, this time for the DL counterpart.

Change-Id: I87f6cdf8288a688466020bda0874e68b57aa71c4
2020-05-12 17:09:20 +00:00
Pau Espin 17402a5902 Expect ms object to exist before calling tbf_alloc_ul_tbf()
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-05-12 17:09:20 +00:00
Vadim Yanitskiy 9f62b92258 tests/alloc: fix implicit conversion from 'double' to 'int8_t'
Looks pretty much like a typo. Both '-1' and '.' symbols are
neighbours in QWERTZ keyboard layout, so it must be -1.

Found by Clang [-Wliteral-conversion].

Change-Id: Id4eb2dcc3b44e18096c7b94efb7260e2400c596b
2020-01-29 06:17:50 +07:00
Pau Espin 9d1cdb1f69 Move out tbf subclasses from tbf.h to their own headers
It's a good start towards clearing current mess between parent and the 2
children classes.

Change-Id: Ibc22ea2e02609af7ee058b8bc15df2115d4c6f60
2019-09-25 17:50:06 +02:00
Max 0e6ac799f7 TS alloc: expand tests log
* restructure code for easier reading
* use consistent formatting for output
* log essential allocation parameters on failure

Change-Id: I4b78951a79ddbc0745b39d091080a4e0e247d3c5
Related: OS#2282
2019-03-28 08:58:41 +00:00
Neels Hofmeyr 42f2d61ac9 use osmo_init_logging2() with proper talloc ctx
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-04-01 16:57:42 +02:00
Neels Hofmeyr bdc55fad62 implement support for 3-digit MNC with leading zeros
Receive the mnc_3_digits flag from the PCU interface.

Bump the PCU interface to 9.
This is one part of the three identical pcuif_proto.h patches:
- I49cd762c3c9d7ee6a82451bdf3ffa2a060767947 (osmo-bts)
- I787fed84a7b613158a5618dd5cffafe4e4927234 (osmo-pcu)
- I78f30aef7aa224b2e9db54c3a844d8f520b3aee0 (osmo-bsc)

Add 3-digit flags and use the new RAI and LAI API from libosmocore throughout
the code base to be able to handle an MNC < 100 that has three digits (leading
zeros).

Depends: Id2240f7f518494c9df6c8bda52c0d5092f90f221 (libosmocore),
         Ib7176b1d65a03b76f41f94bc9d3293a8a07d24c6 (libosmocore)

Change-Id: I787fed84a7b613158a5618dd5cffafe4e4927234
2018-03-11 00:47:14 +01:00
Max 731e2bb328 Simplify TS alloc: move slot check into functions
Move timeslot applicability check outside of nested for loop into
separate functions and document them. Add corresponding tests.

This allows us to clarify types used in TS-related computations.

Change-Id: Ic39e848da47dc11357782362fdf6206d2c1457c2
Related: OS#2282
2018-02-21 12:08:40 +00:00
Max 69d585e148 TS alloc: print suggested TRX on allocation errors
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-31 11:21:27 +01:00
Max d000d80968 Simplify TS alloc: use defines for constants
* 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-26 12:57:05 +01:00
Max 92b7a50605 Simplify TS alloc: fix allocation calls
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-26 12:55:59 +01:00
Max e9fe0e3d06 Simplify TS alloc: adjust allocator signatures
* drop unused parameters (from both functions and structs)
* document used parameters and return values
* tighten types used for parameters
* use consistent formatting

Tests are adjusted accordingly but test results are left untouched to
avoid regressions.

Change-Id: I39d81ab64ff790b9c4c2d0312a574485cd83e755
Related: OS#2282
2018-01-26 12:55:29 +01:00
Max 01bd0cc42f Add multislot classes from latest spec
The table B.1 is copy-pasted from 3GPP TS 45.002 and reformatted via
Emacs macros into C struct to avoid typos. The test output expanded
accordingly.

The allocation test expectations and output are adjusted accordingly.

Note: classes 35-45 which need TA offset are not properly supported
yet. This can be extended once we have such devices available for tests.

Change-Id: I1ef2eb99c517f25e7d1e71b985a3e0eb3879eb2c
Related: OS#2282
2018-01-25 16:12:58 +00:00
Max 9f46071409 AllocTest: remove assumption on max MS class
So far the allocation was only tested up to hardcoded MS class 29. Drop
that assumption and test for all supported MS classes. Adjust expected
test output as necessary.

Note: using mslot_class_max() forces allocation for MS classes 30 and 31
for which no actual data is available (will be added in follow-up
patches) which current implementation treats differently depending on
TX/RX direction - see gprs_alloc_max_dl_slots_per_ms(). Because of that
we have to adjust the expected number of allocations in
test_successive_allocation() as well.

Change-Id: I7737f303d97197ef159b14a19c3312a11f07b433
Related: OS#2282
2018-01-25 16:12:57 +00:00
Max c59ef12e51 AllocTest: expand test output
* print MS classes
* unify and print test mode description
* print additional info on test completion

This only changes meta info about test run but not the actual test
output.

Change-Id: I30a4b8f561a9677f4e9ded33a051a249bd15a6a2
Related: OS#2282
2018-01-25 16:12:57 +00:00
Max 2ecf0fdfc2 AllocTest: adjust test_alloc_b()
This function contains 3 independent test cases. Let's split them into
separate functions to simplify further modifications:

* split test cases into separate functions
* use them for mass test as well
* change function names to avoid confusion
* make individual test cases return error instead of failing via assert
  on allocation failure

The top-level test_alloc_b() is used as part of exhaustion tests in
test_all_alloc_b() for example, so it's expected that allocation might
fail (due to TFI or USF exhaustion for example) eventually. In this case
it's better to indicate it to caller instead of failing entire program.

The test output does not require any adjustements because we do not
exhaust to the point of allocation failure yet.

Change-Id: Id7e03a85ce96e7d617cecee963759bae589a3a1a
Related: OS#2282
2018-01-25 16:12:57 +00:00
Max 46fbfceac6 Add tests for find_multi_slots()
* make function public
* add tests

Change-Id: I4174703808335c19341cd5b5f4422496d958967f
2018-01-25 16:12:56 +00:00
Max 0524e38d9e TBF: add dedicated log categories
Previously all TBF-related events were logged as part of DRLCMAC which
is too broad to make it practically useful due to excessive amount of
log messages generated. Introduce dedicated log categories for
TBF-related events. Adjust test output as necessary.

Change-Id: I64d660e5971263d5c63d2ba95d50625c16a594aa
2018-01-19 18:49:16 +01: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
Neels Hofmeyr 78ce59137f main, tests: use msgb_talloc_ctx_init() (new)
msgb_set_talloc_ctx() is deprecated since libosmocore commit
f45334be29016a36594aacc07c90e262e4994525 / change-id
I747fbbf977c4d2c868c8dead64cfc5fd86eb8d4c

Change-Id: I8d40abec428b739460ed545c9983d1b63021bd08
2017-02-08 17:37:55 +01:00
Neels Hofmeyr d34646a865 Fix dozens of compiler warnings across the board
Change-Id: I166109dc05d3323b92cd2a42f0c7e6009950e15d
2017-02-08 17:37:55 +01:00
Aravind Sirsikar e26ee01d56 DL TS allocation: add test case to show TS allocation bug for 2nd DL TBF
This patch adds a test case test_2_consecutive_dl_tbfs which
expects a current bug with TS allocation for 2nd DL TBF.
The test's expectation is corrected along with the bug fix in a
subsequent commit

Related: OS#1792

Change-Id: I890e4fbb2b64037e051433e70082a197e2a929a6
2016-09-14 11:55:32 +00:00
Holger Hans Peter Freyther f3f1bde4fc alloc: Fix UBSAN for accessing the array at -16
This test will check that we exhaust the available TFIs, so the last
TFI is -16 and then we try to store to that address. It is surprising
that it worked!
2016-02-22 15:14:01 +01:00
Jacob Erlbeck ed2dbf6954 tbf: Use LListHead instead of llist_pods
LListHead does basically the same like llist_pods, but more C++ish
and with type safety.

This commit turns the former list field of gprs_rlcmac_tbf into a
private field, provides accessors, moves the related code from
pcu_vty.c to pcu_vty_functions.cpp, and removes the llist_pods
type and related code.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:13 +01:00
Jacob Erlbeck 86b6f05d19 edge: Support EGPRS multislot class handling in tbf_alloc
Add an egprs_ms_class argument to the allocation functions and
set/pass it where necessary.

Sponsored-by: On-Waves ehf
2015-12-15 15:17:51 +01:00
Jacob Erlbeck 77da35515c alloc: Make alloc_algorithm_dynamic stateful
Currently there is no persistent state being used in
alloc_algorithm_dynamic. So algorithm B is even used in persistent
high usage scenarios. If there are many active TBFs, multislot
assigments are not fair, because MS of a "higher" multislot class get
higher troughputs. On the other hand, as long as all PDCH are busy no
bandwidth will be wasted even if all MS use algorithm A.

This commit modifies alloc_algorithm_dynamic to disable algorithm B
when that call fails. It then keeps it disabled until there is a
single PDCH which is idle (it is considered idle, if there is at most
one active DL TBF assigned to it).

Sponsored-by: On-Waves ehf
2015-07-16 19:24:16 +02:00
Jacob Erlbeck 7b3675bf7a alloc/test: Fix trx_no assertion
Currently the value of trx_no2 is used in the assertion, even if the
call to tfi_find_free has failed.

This commit fixes the asserted expression to only compare the trx_no
values if the function call has succeeded.

Sponsored-by: On-Waves ehf
2015-07-16 19:24:16 +02:00
Jacob Erlbeck 0f352a6f22 alloc/test: Free the TBF if the recursion has failed
Currently if both an uplink and a downlink TBF are to be allocated by
alloc_tbfs() and the second allocation fails, the first TBF is not
freed.

This commit changes the recursive function to free the TBF if the ms
variable has been changed to NULL.

Sponsored-by: On-Waves ehf
2015-07-16 19:24:16 +02:00
Jacob Erlbeck bf9042203d alloc/test: Use lower case for slots with TFI shortage
Indicate those slots with lower case letters that do not have a spare
TFI for the other direction if such a TBF has not been attached to
the MS object yet.

Sponsored-by: On-Waves ehf
2015-07-16 19:24:16 +02:00
Jacob Erlbeck 7af53e61f0 alloc: Use a separate usage computation for algo A
Currently algorithm A can select an TBF even when there is no free
TBF in the reverse direction. While this does not necessarily lead to
an allocation failure, the probabily is higher. In addition, the
current slot reservations are not taken into account.

This commit changes the selection algorithm to prefer slots where TFI
are available in both directions and which are less reserved.

Sponsored-by: On-Waves ehf
2015-07-16 19:24:16 +02:00
Jacob Erlbeck 88fb6136fb alloc/test: Show expectation before failure
To simplify debugging, show the actuals value before the assertion
fails in some cases.

Sponsored-by: On-Waves ehf
2015-07-16 19:24:16 +02:00
Jacob Erlbeck 400ec02e8a alloc: Add 'dynamic' allocation algorithm
The idea behind this meta algorithm is to automatically select one of
the other algorithms based on the system state. Basically algorithm B
will be selected if the PDCH usage is low to improve throughput and
latency. Algorithm A will be selected to support more concurrent MS.

This commit adds a first simple state-less version of this algorithm
that always tries B first and only if that fails A is tried
afterwards.

The following VTY command is added to the 'pcu' node:

 - alloc-algorithm dynamic

Ticket: #1934
Sponsored-by: On-Waves ehf
2015-07-16 19:24:15 +02:00
Jacob Erlbeck 5a2b8be3f5 alloc: Refactor alloc algorithms to only apply changes on success
Currently these algorithms modify other objects (MS, TBF, PDCH) even
if the allocation will fail later on. To implement an algorithm that
dynamically tries another algorithm on failure (e.g. A after B), the
first (failing) algorithm should not change or damage anything.

This commit refactors algorithm A and B to delay the actual allocation
until it is known that the allocation will not fail.

Ticket: #1934
Sponsored-by: On-Waves ehf
2015-07-16 19:24:13 +02:00
Jacob Erlbeck a8c2aaf6f0 alloc/test: Add test for interleaved TBF chains
MS iniated TCP connections generally result in a sequence
of short time UL and longer lasting DL TBFs, being interleaved
between several MS. This scenario is not covered by the existing
tests.

This commit adds a test, that allocates as man as possible TBFs
several times with different test modes without clearing the BTS (and
thus the TBF list) in between. The number of allocated DL TBFs in
each round is expected to be constant.

Sponsored-by: On-Waves ehf
2015-07-16 18:51:31 +02:00
Jacob Erlbeck 69c9bfa089 alloc/test: Put TBF allocation loop into alloc_many_tbfs
Currently all TBFs are deleted after the allocation loop finishes.
This make it difficult to interleave the TBF allocation like it
happens with real MS.

This commit refactors the allocation loop into alloc_many_tbfs and
adds support for TLLIs, which are derived from the counter value and
used to retrieve an old MS object if alloc_many_tbfs is called a
second time.

Note that this does not make a difference for the existing tests.

Sponsored-by: On-Waves ehf
2015-07-16 10:25:14 +02:00
Jacob Erlbeck 3a10dbd564 tbf: Put the TFI->TBF mapping into the PDCH objects
Currently the TBFs are registered in a TFI indexed array within the TRX
objects. TBFs can be searched globally by TFI and TRX number. This
conflicts with the use of the same TFI for different TBF on different
PDCH. This use case requires the specification of the PDCH as
additional search dimension.

This commit moves the TFI index TBF arrays into the PDCH objects. The
related methods are updated accordingly.

Ticket: #1793
Sponsored-by: On-Waves ehf
2015-07-16 10:25:14 +02:00
Jacob Erlbeck e0853cdf42 alloc: Allocate TFI per slot (algorithm A)
Currently the TFI are managed per TRX, thus only a maximum of 32 TBF
per direction and per TRX are possible simultaneously.

This commit modifies algorithm_a() to allow the sharing of TFI
between different PDCH. Since algorithm A only assigns a single slot
to each TBF, the TFI of each PDCH can be assigned independently.
This increases the maximum to 32 TBF per direction and per PDCH
concerning the TFI allocation.

Ticket: #1793
Sponsored-by: On-Waves ehf
2015-07-16 10:25:14 +02:00
Jacob Erlbeck 5879c6493f tbf: Move TFI selection into alloc_algorithm
Currently the TFI and the TRX have to be determined before the actual TBF
allocation function is called, passing TFI and TRX number as
parameters. This does fit to TFI reuse for different slots, since
this were tightly coupled with the slot selection.

This commit just moves the TFI selection into the alloc_algorithm
functions. The tfi parameter is removed from the the TFI alloc
functions. The trx parameter is changed into use_trx to optionally
limit the trx selection (same semantics like in tfi_find_free).

Sponsored-by: On-Waves ehf
2015-07-16 10:25:14 +02:00
Jacob Erlbeck 47a57f6f86 pdch: Manage TFIs per direction
Currently a single bit set is used to maintain a set of used TFI
without distinguishing between uplink and downlink. Since the
namespaces of UL and DL TFI are separate, this implementation is
not correct.

This commit changes gprs_rlcmac_pdch to use a separate bit set for
each direction. It also replace the corresponding conditional fprintf
statement in check_tfi_usage (AllocTest.cpp) by an equivalent
OSMO_ASSERT.

Sponsored-by: On-Waves ehf
2015-07-16 10:25:14 +02:00
Jacob Erlbeck 61205a7e65 alloc/test: Check for TFI conflicts
This commit adds the check_tfi_usage function that checks the TFI
usage. It iterates through all TBFs, records on which PDCH it uses
which TFI and check for conflicts. It also checks the bits returned
by pdch->assigned_tfi(). The latter suffers from an bug in that
method (no separation of uplink and downlink), so a conditional
fprintf is used instead of an assertion. The method tfi_find_free
is checked for conflicts after allocations.

Sponsored-by: On-Waves ehf
2015-07-16 10:25:14 +02:00
Jacob Erlbeck 57cf69a18c alloc: Fix MS_B/MS_C interpretation
Currently the handling of MS_B and MS_C is not compliant with TS
45.002, annex B.1. These values may only interpreted as 0, if
frequency hopping is not enabled and if there is no change from Rx to
Tx or vice-versa.

This commit sets Ttb/Trb to 1 if the table entry is MS_B/MS_C, since
only combined down/up access modes are supported.

Sponsored-by: On-Waves ehf
2015-07-16 10:24:37 +02:00
Jacob Erlbeck dd08ac86e6 alloc: Do not use masking for multislot class type 2 MS
Currently the masks are computed equally for each class type. This
does not make much sense for class type 2 MS, since those are capable
to work in full duplex mode.

This commit sets the masks to 0xff for class type 2 MS.

Sponsored-by: On-Waves ehf
2015-07-16 10:24:37 +02:00
Jacob Erlbeck bae33a7001 alloc: Select applicable Tta/Tra
According to TS 45.002, 6.4.2.2 the choice whether Tta or Tra has to
be applied, depends on the medium access mode (currently always
dynamic) and the number of UL/DL slots. Currently either value can be
used which might result in combinations not covered by the spec.

This commit changes find_multi_slots() to skip non-compliant
combinations.

Note that this code will have to be extended, if other medium
access modes are implemented.

Sponsored-by: On-Waves ehf
2015-07-16 10:24:37 +02:00
Jacob Erlbeck efe62a7395 alloc: Use least reserved PDCH for algo A
Currently the slot selection of algorithm A is based on the current
slot usage by active TBF. Especially in the Dl after UL case which
reflects the commen use case "MS initiates TCP connection", the
resulting distribution is not optimal with respect to PDCH usage.

This commit changes the implementation to use the slot reservation
information instead.

Sponsored-by: On-Waves ehf
2015-07-07 11:52:28 +02:00
Jacob Erlbeck 14376a73a5 alloc/test: Delete first TBF after the second is allocated
Currently when using the test modes TEST_MODE_DL_AFTER_UL or
TEST_MODE_UL_AFTER_DL, the first TBF is deleted before the second is
allocated. The far more interesting case were to keep the first TBF a
little bit longer until the second TBF has been created and delete
then. This comes closer the the situation observed with real MS,
where the first TBF takes some time (timeout or waiting for Ack)
before it gets deleted and thus detached from the MS object.

This commit delays the call to tbf_free accordingly.

The effect can be observed in the results of the algo A tests, where
the uniform distribution of the allocated PDCH is lost.

Sponsored-by: On-Waves ehf
2015-07-07 11:51:07 +02:00
Jacob Erlbeck 16c6ecc365 alloc: Skip common TS without free USF when rating
Currently the search of the "best" slot combination is done
separately from the UL slot selection, which can lead to an
allocation failure due to USF exhaustion even if another combination
had been possible.

This commit reduces the probability for this event by skipping UL
slots without free USF while calculation the capacity.

Note that the implementation is rather inefficient which will be
fixed by the following commits.

Sponsored-by: On-Waves ehf
2015-07-07 10:29:12 +02:00
Jacob Erlbeck 5f494b8415 alloc: Only reserve 1 UL slot with algorithm B
Since currently the algorithm B will only allocate a single UL slot
and will have to stick to it (first common TS), the other possible UL
slots will not be allocated while the reservation is kept.

This commit adds code to update the reserved set of UL slots to only
reserve the single common TS when the UL TBF is allocated.

Interestingly this leads to fewer allocated TBF in some cases due to
USF exhaustion. This will be improved by the following commit "alloc:
Skip common TS without free USF".

Sponsored-by: On-Waves ehf
2015-07-07 10:22:18 +02:00
Jacob Erlbeck ed46afda6f alloc: Only use common UL slots when calculating the capacity
Currently al possible UL slots are included in the capacity
calculation which is the base of the slot selection. Nevertheless
UL-only slots will never be used, since only one uplink slot (which
must be a common slot) will be used.

This patch changes the code to only include common slots in the
capacity sum.

Note that this might not be optimal if algorithm B supported
multiple uplink slots.

Sponsored-by: On-Waves ehf
2015-07-07 09:35:26 +02:00
Jacob Erlbeck ea65c72d06 alloc: Replace Algorithm B implementation
The current implementation always starts the downlink slot allocation
with the first possible slot, depending on which channels are enabled
and which multislot class is offered by the MS. So in configurations
with many (>4) PDCH, some PDCH are not really used.

The new implementation introduced by this commit differs as follows:

 - The reservation mechanism provided by GprsMs is used to avoid
   incompatibilities is used in the same way like algo A does. This
   basically means, that the allocation is done once when the first
   TBF is requested and then used until all TBF have been released.

 - All combinations of Rx and Tx slots are checked for compatibility
   with the multiscot class. Basically the combination with the most
   usable PDCH and the least number of reservations is used.

 - Only one UL slots is provided.

 - Tta and Tra are checked.

Sponsored-by: On-Waves ehf
2015-07-07 09:35:26 +02:00
Jacob Erlbeck ec478756cc alloc: Load balancing for algo A
Currently only the first enabled PDCH will be used. Beside the
throughput this will also limit the number of TBFs:

  - number of UL TBFs <= 7
  - number of DL TBFs <= 32

This commit changes the allocation algorithm to use the PDCH with the
least number of attached TBFs. This will improve the troughput in
both directions and the UL limits:

  - number of UL TBFs <= min(32, N_PDCH * 7) UL TBFs

Ticket: #1794
Sponsored-by: On-Waves ehf
2015-07-03 15:37:15 +02:00
Jacob Erlbeck 9ec49e2411 alloc/test: Use LOGL_DEBUG environment variable
When this environment variable is set, the logging level is set to
LOGL_DEBUG to help debugging without putting everything into
AllocTest.err.

Sponsored-by: On-Waves ehf
2015-07-03 12:05:51 +02:00
Jacob Erlbeck fa464bbce9 alloc/test: Enhance test_alloc_a
This commit adds:
 - an assertion to check that count is valid,
 - an assertion the verify that tbf_alloc did not fail
 - a slots parameter to specify the enabled slots
 - additional test invocations with more slots enabled

Sponsored-by: On-Waves ehf
2015-07-03 12:05:51 +02:00
Jacob Erlbeck e565564bc9 alloc/test: Add test for successive allocation
This test allocates as many as possible UL/DL TBF pairs, shows their
PDCH usage, and checks how many of them has been created
successfully.

Sponsored-by: On-Waves ehf
2015-07-03 12:05:46 +02:00
Jacob Erlbeck e2e004e7a9 tbf: Pass the MS object around instead of old_tbf
Currently the old TBF (either uplink or downlink) is passed around at
TBF allocation mainly to get information about the MS. To implement
more complex allocation algorithms, the MS object itself will be
needed anyway.

This commit replaces the old_tbf arguments by MS object arguments.

Sponsored-by: On-Waves ehf
2015-06-29 10:53:32 +02:00
Jacob Erlbeck befc760f86 tbf: Store MS class in GprsMs objects
The ms_class value is a property of the MS and thus belongs to the
GprsMs class. Nevertheless the MS object is created after the TLLI
gets known, so the value still has to be stored in the TBF initially.

This commit add the ms_class value to the GprsMs class and introduces
TBF accessor functions which either access that object or, if that is
not available, the value stored locally.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-06-08 09:38:49 +02:00
Jacob Erlbeck 767193e20b tbf: Remove the TLLI from the TBFs
Currently the TLLI is stored in each TBF. Since each MS is now
represented by a GprsMs object which takes care of TLLI updating,
and each TBF that has been associated with an TLLI also contains a
reference to a GprsMs object, per TBF TLLI handling is no longer
needed. Keeping all TBF m_tlli members up to date is complex and
doesn't currently work correctly in all circumstances.

This commit removes m_tlli and related members from the TBF class and
the tbf_by_tlli functions from the BTS class.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-27 13:29:59 +02:00
Jacob Erlbeck be0cbc1b7e tbf: Explicitly pass the direction to update_ms()
The type of the TBF update_ms() is being called on does not always
reflect whether the TLLI has been signaled by the MS or the SGSN.

This commit adds an additional parameter to tell the method, in which
direction the TLLI has been passed.

Sponsored-by: On-Waves ehf
2015-05-21 17:11:14 +02:00
Jacob Erlbeck e43460b50f ms: Integrate the MS storage
Use the MS storage to find a MS object for a given TLLI instead of
searching the TBF lists. The TBFs are then taken from the MS object,
if one has been found. If all TBF might be temporarily detached from
the MS object, a GprsMs::Guard is added to prevent the deletion of
the object, in case another TBF gets attached later on in the scope.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-20 11:36:12 +02:00
Jacob Erlbeck 1f33294b1c pcu: Fix non-critical warnings
These fixes do not affect the semantics of the code. They either help
gcc by providing default values that won't be used ("may be
uninitialised"), remove unused variables, or change signed to
unsigned variables to avoid comparison warnings.

Addresses:
  bts.cpp:494:32: warning: 'tbf' may be used uninitialized in this
      function
  emu/test_replay_gprs_attach.cpp:81:27: warning: comparison between
      signed and unsigned integer expressions
  emu/test_pdp_activation.cpp:95:23: warning: unused variable ‘budh’
  emu/test_pdp_activation.cpp:97:6: warning: variable ‘rc’ set but
      not used
  emu/pcu_emu.cpp:109:26: warning: unused variable ‘bts’
  alloc/AllocTest.cpp:74:27: warning: unused variable ‘tbf’
  osmocom/core/utils.h:13:50: warning: comparison between signed and
      unsigned integer expressions
  types/TypesTest.cpp:319:7: warning: unused variable ‘count’
  types/TypesTest.cpp:320:11: warning: unused variable ‘rbb’
  alloc/AllocTest.cpp:74:27: warning: unused variable ‘tbf’
  alloc/AllocTest.cpp:132:11: warning: unused variable ‘ts_no’
2015-05-04 10:01:25 +02:00
Daniel Willmann 7e994e392d tbf, ...: Make the fields in the dl/ul struct member variables
There is no need for the union/struct anymore. Make the variable members
of the UL/DL class.

As a result gprs_rlc_dl_window gets a reset() method because
memset(&dir.dl, 0, sizeof(dir.dl)) doesn't work anymore in reuse_tbf().

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:05 +02:00
Daniel Willmann 351a573396 tests/alloc: Use the specific UL/DL TBF classes instead of the base
Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:04 +02:00
Daniel Willmann 48aa0b0d99 bts, tbf: Split alloc_tbf function into separate UL and DL versions
UL and DL tbfs are used in very separate parts and are not the same
thing so split the alloc function and use the UL/DL version throughout
the code.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-22 12:36:31 +02:00
Holger Hans Peter Freyther c2fab7a6ff alloc: Update the test result now that everything is back to working again 2014-01-15 14:42:58 +01:00
Holger Hans Peter Freyther f3eec04655 alloc/test: Add a crazy test that tests each possible combination
Make a crazy test that will test each possible PDCH configuration
and MS Class and verify that the UL/DL assignments work and that
they are on the same first_common_ts.
2014-01-15 10:39:08 +01:00
Holger Hans Peter Freyther c7b998cc73 alloc/test: Go through all possible ms_classes for the allocation
Generate results for all possible classes.
2014-01-15 10:39:08 +01:00
Holger Hans Peter Freyther 4af30533f0 alloc/tests: Create an allocation test for various scenarious
The allocation in the TBF/BTS code is quite complex. In parts this
is due the assignment and requests occuring under differen circumstances.
Attempt to re-create the commono scenarios.

Remove the bogus msclass check in gprs_rlcmac_tbf::update as the
allocation code will check the ms class anyway.
2014-01-15 10:39:07 +01:00
Holger Hans Peter Freyther 70ddde6929 tbf/bts: Move the tfi_find_free into the bts 2013-10-30 21:24:11 +01:00
Holger Hans Peter Freyther 34bd8bdf30 bts/tbf: Move the lists into the BTS and do the look-up from the BTS
The list belongs to the BTS. This makes cleaning this up more easy
and establishes a hierachy of resources that start from the BTS. The
debug_diagram code is now broken.
2013-10-30 21:24:10 +01:00
Holger Hans Peter Freyther 17b0d83a1f pdch: Move enable/disable into the PDCH code
When a PDCH is disabled all resources should be freed. This is
currently not possible as the PDCH does not know where it belongs
to. On top of that the list (and other resources) should be
properly initialized on construction so that disable() is idempotent
and does not check if it was disabled. During the re-factoring I
noticed that during a sysmobts re-start some resources are not
freed. I left a warning in the code to resolve this issue later.
2013-10-30 21:24:09 +01:00
Holger Hans Peter Freyther b6acfdaa24 bts: Introduce a singleton for the BTS and use it in the code
Compared to the previous code there will be a branch to get the
global pointer so the code will be slightly slower than the previous
version but it allows us to start creating objects but still use
the code from C. It is best approach I have found so far.

One downside of C++ is that by default talloc will not be used
(unless we override the new operator to use talloc. Right now
we need to memset the C data structure by hand. The benefit of
enforcing a better structure should is more important though.
2013-10-30 21:20:45 +01:00
Holger Hans Peter Freyther bfdd5f285b alloc: Add very basic test case for the alloc_a algorithm 2013-10-30 21:20:44 +01:00