Commit Graph

98 Commits

Author SHA1 Message Date
Pau Espin 924aaad4bc Move T_defs_pcu from BTS to PCU object
Change-Id: I0cac5c12dff2e90b52d00383a00b4b94a9603a0a
2021-01-18 10:37:05 +00:00
Pau Espin bed48cc14f ms: Replace struct var with rate_ctr
Let's use usual osmocom rate_ctr instead of having one variable +
setter/getter functions, so we can easily add new counters and also
because it makes code more clear (no need to look at what the "update"
function is doing).

Using rate counter also provides info about how recently the MS has been
interacting with the network.

Related: OS#4907
Change-Id: I744507fde4291955c1dbbb9739b18a12a80145b1
2021-01-12 18:01:53 +00:00
Vadim Yanitskiy 480c8acc8b gprs_rlcmac_sched: fix incorrect SBA frame number assignment
There is a big difference between:

  if ((a = foo() != 0xffffffff)) { ... }

and

  if ((a = foo()) != 0xffffffff) { ... }

In the first case, 'a' is the result of '!=' operation, i.e. either
0 (false) or 1 (true).  In the second case, 'a' will hold the value
returned by foo(), and this is exactly what must have been used in
gprs_rlcmac_rcv_rts_block().

The bug was there since SBA allocation feature was added in 2012.

Change-Id: Ifd607ae8a33382e48f9d9e50a28a4bdf4eaf73a2
Fixes: 07e97cf8a5
Related: CID#215835
2021-01-06 12:34:07 +00:00
Pau Espin Pedrol da971ee502 Convert GprsMS and helpers classes to C
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
2021-01-05 10:34:25 +00:00
Alexander Couzens 86fad1ec4e gprs_rlcmac_sched: don't leak a sched_dummy()
Change-Id: Iea0fc51809c78514c85e45e7f499a531c4ea1bcf
2020-12-30 23:30:16 +01:00
Pau Espin Pedrol d6b913fc39 sched: Convert code handling next_list array to be size independant
Change-Id: Id209fe66f85501437a79f7ca0c8e3cf816177611
2020-12-17 15:27:41 +00:00
Pau Espin Pedrol b77a2c992e gprs_rlcmac_sched: Use helper structure to store several tbf pointer params
The resulting code is cleaner since it becomes clear the relation
between all those pointers, which are set in one function and used in
another one, passed through the caller of the former two.

Moreover, if more tbf candidates are to be added for other type of
actions, having them in a struct is much easier since only one pointer
is passed.

Change-Id: I55482aa5af7be5a176a7b4879a672ad37e618020
2020-12-17 15:27:41 +00:00
Pau Espin 022f9e56e5 Implement downgrade to DL MCS1-4 when USF for GPRS_only MS
In previous status, if USF for GPRS-only MS was selected, then EGPRS
TBFs were skipped and either a GPRS TBF was selected or a Dummy Block
was sent. That means the behavior was unfair towards EGPRS TBFs, because
sometimes they were skipped in favor of GPRS ones.
This patch imporves the situation in the above mentioned USF scenario, by
first, under specific conditions, allowing selection of an EGPRS TBF and
then forcing it to transmit in EGPRS-GMSK (MCS1-4) so that the
USF-targeted MS can still decode the USF, while at the same time
providing more fairness by allowing the EGPRS TBF to transmit data.

The specific conditions mentioned above are, mainly, related to the fact
that once a DL data block has been sent, and hence a BSN was assigned to
it, it cannot be retransmitted later using another MCS, since lower
MCS1-4 wouldn't be able to contain higher MCS RLC payload.

The set of conditions could be expanded in the future by also selecting
the EGPRS TBF if retransmition is required and the block to be
retransmitted was originally transmitted as MCS1-4.

Related: OS#4544
Change-Id: I9af23e175435fe9ae7b0e4119ad52fcd4707b9ca
2020-12-01 11:56:01 +00:00
Pau Espin 228628860f Support multiplexing of GPRS and EGPRS TBFs in one PDCH
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-17 16:42:15 +01:00
Pau Espin daa6c1c645 sched: Use correct GMSTAP category for EGPRS DL data blocks
Change-Id: I3bd8b6a2328e13543b7d4c4a945e86f14ff35bda
2020-11-17 15:05:10 +01:00
Pau Espin 4c5a7d315c sched: Fix sending GSMTAP DL data blocks with unset USF
Change-Id: Ib5ceb83a85b517ee9bf2c59cf27fe818373abe60
2020-11-17 15:05:10 +01:00
Pau Espin b3f239785c tbf: Make window() available to tbf base class
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-10-24 22:14:42 +02:00
Pau Espin a107f8f496 bts: Drop specific functions to add values to counters
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-14 11:19:05 +00:00
Pau Espin 2338e5318e bts: Drop specific functions to increase counters
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-14 11:19:05 +00: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
Pau Espin 488aa29083 cosmetic: fix whitespace
Change-Id: I45bbe4d3c69d573aaff010d16f338c7ec3eaf08a
2019-09-25 17:50:06 +02:00
Pau Espin 2b5c629055 Use osmo_tdef to implement dl-tbf-idle-time
Change-Id: I5e4f0d2f90e643600b7752525d6c2830856c9d3b
2019-09-17 11:11:04 +02:00
Pau Espin 38cfa734f4 Use osmo_tdef to implement T3190
Change-Id: I0c767c526398d98ca47ef98fdaccfc23af11fb0d
2019-09-16 14:21:21 +00:00
Oliver Smith cfb6321b88 Forward ETWS Primary Notification to MS
Receive an Application Information Request from the BTS via PCU
interface. Construct a Packet Application Information message from it
(3GPP TS 44.060 11.2.47) and send it to all MS with active TBF.

The TTCN-3 test infrastructure to test this feature is not quite ready
yet, so I've added C unit tests instead.

Related: OS#4048
Change-Id: Ie35959f833f46bde5f2126314b6f96763f863b36
2019-09-14 15:28:43 +00:00
Max 6dc90b8c86 Move PDCH-related functions into separate files
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-19 17:41:24 +01:00
Max 1187a7719c Update header includes
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-19 08:43:46 +00:00
Max cac6b66638 TBF: make poll state internal
* 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-24 11:06:55 +01:00
Max 088c7df571 TBF: make UL ack state internal
* add functions/macros for setting TBF's UL ack state
* add functions for checking TBF's UL ack state

N. B: this should not be confused with TBF-UL state.

Change-Id: I144483447d4b0b93e775da0e926ee45eb8ab39f3
Related: OS#1539
2018-01-24 11:06:37 +01:00
Max 0e5998087e TBF: make UL/DL state internal
* 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-24 11:06:22 +01:00
Max d0532b53eb TBF-DL: move priority computation into function
Improve readability by moving priority computation into separate
function.

Change-Id: Icdca0106a544036eaa94a25f0d4f84e4282f4568
2018-01-12 15:29:41 +01: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
Harald Welte f7740aa44b GSMTAP: Fix channel type for data blocks: PDTCH instead of PACCH
PACCH is used only for RLC/MAC control messages, while PDTCH is used
for data.

Change-Id: I6c912e17d8c8d4178096679a541e61eeeb4b6643
2017-07-29 13:43:30 +02:00
Harald Welte 717cdf5405 Introduce GSMTAP categories
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-21 22:15:28 +02:00
Max 9dabfa2c2b Cleanup FN scheduling
* replace magic number with defined constant
* move copy-pasted code to inline functions
* remove unused code

Change-Id: I6fee0714453d0c3c3f3f875f88daea2d9c477331
Related: OS#1524
2017-05-26 07:55:52 +00:00
Neels Hofmeyr 3de6d0602f fix PACCH paging: don't return early in case of NULL TBF
Commit b78a4a6dfe tried to fix a NULL dereference
error, but apparently was overly eager to return, because it looked like all
code paths would dereference the tbf.

In fact the code path further above, for msg != NULL, has "always" dereferenced
the tbf, but the lower code path, the one effecting the paging, has only
started to dereference tbf since shortly before the overly eager fix: in
da7250ad2c, to "update the dl ctrl msg counter
for ms". It seems that this tbf dereference in the paging path is bogus and the
cause for the segfault that made me write the early exit fix.

Fix that fix:

Do not exit early if tbf == NULL, stay in there to be able to reach the paging
path below.

In case of a message to be sent, assume that tbf is present, and verify: print
an error message and abort if there is a msg but no tbf, so that we will see
the error if I'm wrong there. If a tbf is missing, free the msg.

In case of no message, go on to send pending pagings, but do not attempt to
count ctrl messages for a tbf -- IIUC there will never be a tbf if we're
paging.

This should avoid segfaults while keeping PACCH paging intact.

Tweak a comment for and add a blank line above the paging section.

Related: OS#2176 CID#158969
Change-Id: Ib79f4a945e211a13ac7d1e511cc37b0940ac6202
2017-05-15 10:40:34 +00:00
aravind sirsikar e9a138e111 Handle packet access reject during packet resource request
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-24 13:11:51 +00:00
Neels Hofmeyr b78a4a6dfe fix segfault: check for NULL tbf in sched_select_ctrl_msg()
Apparently fixes a corrupted stack looking like this on sysmobts:

  (gdb) run
  Starting program: /usr/bin/osmo-pcu -c /etc/osmocom/osmo-pcu.cfg
  [Thread debugging using libthread_db enabled]
  Using host libthread_db library "/lib/libthread_db.so.1".
  <000b> telnet_interface.c:95 telnet at 127.0.0.1 4240
  <0001> osmobts_sock.cpp:227 Opening OsmoPCU L1 interface to OsmoBTS
  <0001> osmobts_sock.cpp:285 osmo-bts PCU socket has been connected
  <0001> pcu_l1_if.cpp:368 BTS available
  <0008> gprs_ns.c:233 NSVCI=65534 Creating NS-VC
  <0008> gprs_ns.c:233 NSVCI=100 Creating NS-VC
  <0008> gprs_ns.c:1568 NSEI=100 RESET procedure based on API request
  <0008> gprs_ns.c:393 NSEI=100 Tx NS RESET (NSVCI=100, cause=O&M intervention)
  <0001> pcu_l1_if.cpp:83 Sending activate request: trx=0 ts=2
  <0001> pcu_l1_if.cpp:495 PDCH: trx=0 ts=2
  <0001> pcu_l1_if.cpp:83 Sending activate request: trx=0 ts=3
  <0001> pcu_l1_if.cpp:495 PDCH: trx=0 ts=3
  <0001> pcu_l1_if.cpp:83 Sending activate request: trx=0 ts=4
  <0001> pcu_l1_if.cpp:495 PDCH: trx=0 ts=4
  <0001> pcu_l1_if.cpp:83 Sending activate request: trx=0 ts=5
  <0001> pcu_l1_if.cpp:495 PDCH: trx=0 ts=5
  <0001> pcu_l1_if.cpp:83 Sending activate request: trx=0 ts=6
  <0001> pcu_l1_if.cpp:495 PDCH: trx=0 ts=6
  <0001> pcu_l1_if.cpp:83 Sending activate request: trx=0 ts=7
  <0001> pcu_l1_if.cpp:495 PDCH: trx=0 ts=7
  <0001> pcu_l1_if.cpp:319 RACH request received: sapi=1 qta=0, ra=120, fn=103198
  <0009> tbf_ul.cpp:373 LLC [PCU -> SGSN] TBF(TFI=0 TLLI=0x7f2dd569 DIR=UL STATE=FLOW) len=6
  <0008> gprs_ns.c:684 All NS-VCs for NSEI 100 are either dead or blocked!

  Program received signal SIGSEGV, Segmentation fault.
  gprs_rlcmac_rcv_rts_block (bts=0x60a08, trx=trx@entry=0 '\000', ts=ts@entry=4 '\004', fn=7, fn@entry=103272,
      block_nr=block_nr@entry=0 '\000') at gprs_rlcmac_sched.cpp:349
  349	gprs_rlcmac_sched.cpp: No such file or directory.
  (gdb) bt
  #0  gprs_rlcmac_rcv_rts_block (bts=0x60a08, trx=trx@entry=0 '\000', ts=ts@entry=4 '\004', fn=7, fn@entry=103272,
      block_nr=block_nr@entry=0 '\000') at gprs_rlcmac_sched.cpp:349
  #1  0x0001151c in pcu_rx_rts_req_pdtch (trx=<optimized out>, ts=<optimized out>, fn=103272, block_nr=<optimized out>)
      at pcu_l1_if.cpp:279
  #2  0x0000bfcc in handle_ph_readytosend_ind (fl1h=0xafa40, rts_ind=0xb03f8) at osmo-bts-sysmo/sysmo_l1_if.c:142
  #3  l1if_handle_l1prim (wq=<optimized out>, fl1h=0xafa40, msg=0xb0330) at osmo-bts-sysmo/sysmo_l1_if.c:259
  #4  0x4fcd6330 in osmo_fd_disp_fds (_eset=0xbefffb68, _wset=0xbefffae8, _rset=0xbefffa68) at select.c:149
  #5  osmo_select_main (polling=<optimized out>) at select.c:189
  #6  0x0000b2a0 in main (argc=<optimized out>, argv=0x66628 <_ZStL8__ioinit>) at pcu_main.cpp:295

Fixes: coverity CID#158969
Related: https://lists.osmocom.org/pipermail/osmocom-net-gprs/2016-December/000785.html
Change-Id: I357492e558e98cfdbf5bb3438b5013029195b02b
2017-01-06 13:54:04 +00:00
sivasankari da7250ad2c Add counter at BTS level And statistics at TBF/MS level.
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-12-22 14:09:04 +00:00
aravind sirsikar ed3413e397 Handle packet access reject during EPDAN/PDAN with channel description
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-11 17:15:10 +05:30
Max 878bd1f296 Remove useless ARFCN parameter
ARFCN is already part of TRX struct so there's no need to supply it
explicitly in a separate parameter. I've tested and those are the same
anyway.

Change-Id: I8e975c52cbc819427880093b1e5371fe1f8ce460
2016-07-26 00:20:23 +00:00
Alexander Couzens 7fdbf89ef3 add KPI counter to count bytes for RLC and LLC frames
rlc.dl_bytes		bytes before sending rlc
rlc.dl_payload_bytes	count data w/o LI
rlc.ul_bytes		bytes when received rlc (only valid)
rlc.ul_payload_bytes	count data fragments w/o LI
llc.dl_bytes		complete encapsulated LLC PDUs
llc.ul_bytes		complete received LLC PDUs

Change-Id: I9a98a5a375d39b3f4990360056c4d6145e755f4d
Reviewed-on: https://gerrit.osmocom.org/145
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Reviewed-by: Holger Freyther <holger@freyther.de>
Tested-by: Jenkins Builder
2016-06-07 10:56:25 +00:00
Alexander Couzens f929e62525 introduce new counter rlc_sent_control
Counts control messages (UL/DL assignment, UL ACKs or page requests)

Change-Id: Ib41031d430beddfb48d54470e632436f2c99c360
Reviewed-on: https://gerrit.osmocom.org/99
Reviewed-by: Holger Freyther <holger@freyther.de>
Tested-by: Jenkins Builder
2016-05-22 11:11:53 +00:00
Alexander Couzens 4acb6b7251 gprs_rlcmac_sched: fix mistype of CONTROL ACK
Change-Id: If37b33f69cd659d913ed81eb6060a42734ba524f
Reviewed-on: https://gerrit.osmocom.org/100
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-22 11:00:29 +00:00
Alexander Couzens 2cb1547993 introduce new counter rlc_sent_dummy
rlc_sent_dummy count the amount of dummy package which are
sent in case no data packet is in the queue.

Change-Id: Ia60eab853d9145980f30d63e4ce4b520b8c51381
Reviewed-on: https://gerrit.osmocom.org/85
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-21 17:59:37 +00:00
Alexander Couzens 9736d00b12 move statistics counter rlc_sent() to gprs_rlcmac_sched
The counter rlc_sent has nothing to do with the TBF.
The RLC packet got sent in the gprs_rlcmac_sched().

Change-Id: I5d2b910ea7cc250f17530406eda3be9b29b051fd
Reviewed-on: https://gerrit.osmocom.org/84
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-20 16:32:06 +00:00
Jacob Erlbeck 1ff70c26e3 sched: Do PACCH assignments for the same direction last
Currently the selection of a pending control message is done round
robin. It can possibly happen, that a DL assigment is sent on a DL
TBF while an UL assignment is pending. The MS will replace the old
DL TBF in that case, so that it can no longer be used for the PACCH
so that the UL assignment is lost.

Give assigment requests for the same direction a lower priority.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:39 +01:00
Jacob Erlbeck 646da1ba8d tbf: Use is_control_ts() instead of comparing TS values directly
Currently there are some places where tbf->control_ts != ts is
evaluated to check, whether ts is a control slot.

Replace these expressions by tbf->is_control_ts(ts) which does
the same whitout exposing internal fields.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:37 +01:00
Jacob Erlbeck 5a3c84d0fd sched: Pass the current TS to the control create functions
Currently the checks in that function are based on the different
internal TS values of a TBF. It is assumed that they match the TS
that the current RTS refers to.

This commit adds a TS parameter to create_ul_ass, create_dl_ass,
and create_ul_ack to make this more explicit.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:37 +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 580edbc326 sched: Assert that the generated message is not empty
Currently the msg data is accessed and index 0 assuming the msg is
not empty. While this should be always the case, the msg can be
empty if there are software errors in the message creation functions.

This commit adds an assertion to catch this kind of bugs.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:13 +01:00
Jacob Erlbeck 6e75bc7fe3 sched: Change next_ctrl_prio increment
Currently the control block scheduler does not seem to be fair in all
cases. At least it happend while testing the EGPRS code, that a
Uplink Ack/Nack message got never be sent, because a Downlink
assignment took over all the times.

This commit changes the round robin code to always increment the
priority offset by 1 instead of (i + 1). The former definitely
ensures that every message type gets the highest priority after some
steps. The latter might be more fair in some situations, but that and
its correctness are not proven.

Sponsored-by: On-Waves ehf
2015-12-16 19:57:13 +01:00
Jacob Erlbeck 2db0f08e08 bssgp: Use measured leak rate for flow control
The leak rate sent to the SGSN does not reflect the current CS level,
lost frames, and control message overhead. So the SGSN cannot do
proper queue control under non-optimal conditions.

This commit computes the leak rate for the last flow control interval
by computing the maximum theoretical leak rate and basically
substracting control blocks, nacked blocks, and reduced block sizes
due to CS downgrade. By using this approach, the value will by more
stable on low load, where the value will tend to be near the value
derived from the configuration. On full load the transmitted value is
completely derived from the measurements.

Note that the MS default values are no adapted to the adapted BVC
leak rate, since a single MS which has a lower link quality would
otherwise be reducing the rate of another MS with good radio
conditions, which would not make much sense if they did not share any
PDCH.

Sponsored-by: On-Waves ehf
2015-09-11 11:52:02 +02:00
Jacob Erlbeck 502bd1feea tbf: Poll MS on idle DL TBFs
If an MS wants to open a new UL TBF, it can either use (P)RACH or
request one in a Ack/Nack message for a DL TBF (PACCH). When a TBF
becomes idle (LCC queue is empty but the TBF is kept open), there
aren't any Ack/Nack requests that can be used by the MS to ask for an
UL TBF, therefore it has to use the RACH. This leads to many RACH
requests even for a single HTTP transaction, so it takes some time to
retrieve even a simple web page.

This commit modifies the scheduler to regularly send Ack/Nack
requests on idle DL TBFs. It does so by extending the priority based
scheduling algorithm to have 5 priority levels (highest priority
first):

  - Control block is pending
  - High age (100%) threshold reached (-> request Ack/Nack)
  - Data is waiting or there are pending Nacks
  - Low age (200ms) threshold reached (-> request Ack/Nack)
  - Pending Nacks that have been resent already
  - None of the above (-> send DL dummy control block)

The 'age' refers to the time since since the last control block has
been sent on the TBF. This high age threshold is set to
dl-tbf-idle-time or to 50% of T3190 (whichever is smaller), aiming
for at least a poll (and TBF shutdown) after the TBF has expired and
to safely prevent expiry of T3190. So if dl-tbf-idle-time > 200ms,
there will be a poll every 200ms and a final poll after
dl-tbf-idle-time. On high load, the interval between polls can get
higher, but the 'high age' poll should be in place.

This commit implements the scheduling with respect to GSM 44.060,
9.3.1a ("Delayed release of downlink TBF").

Ticket: #556
Sponsored-by: On-Waves ehf
2015-03-25 12:34:38 +01:00
Jacob Erlbeck 0eabffdc35 sched: Modify DL scheduling to use different priorities
Currently the DL blocks are scheduled round robin to each TBF that is
either in state FLOW or FINISHED and not waiting for an IMM.ASS
confirmation. This way, if single blocks has been NACK'ed by the MS
and the PCU has already resent the missing packets, the PCU starts
retransmitting them until it has received an ACK/NACK even if other
TBF have RLC blocks that need to be transmitted.

This commit changes sched_select_downlink to select the next TBF with
the highest priority, where blocks that are going to be resent again
have a lower priority unless the window is stalling. If there is only
one TBF the old behaviour is kept, since there is no other TBF that
can have a higher priority.

If there is much packet loss on a single phone, this modification can
lead to a higher latency for that MS.

Sponsored-by: On-Waves ehf
2015-03-06 19:28:10 +01:00