Commit Graph

287 Commits

Author SHA1 Message Date
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
Max e8284a7f92 Fix typo in logging
DL-TBD was errorneously printed as UL-TBF.

Change-Id: I94a224c0339a062e4c8d5aa6c4c858f3f0298a0d
2017-05-24 22:19:43 +00:00
Alexander Couzens ccde5c9557 remove pcu own bitvector implementation
The osmocore bitvec is exact the same, but use a pointer instead of
a reference.

Change-Id: Id8f797631d89aa12b6e48efb2dc153a3e2f059f7
2017-05-15 12:46:33 +00:00
Max 5dd8d1bbd8 bts.cpp: Fix overloading ambiguity
Fix error introduced in 1275a3f91a by
using signed 32 bit integer which is enough for Frame Number in
GSM. Also, mark parameter constraints more explicitly:
- add assert for expected FN values
- don't perform computation for non-relative FN

The error was:
bts.cpp: In member function ‘uint32_t BTS::rfn_to_fn(uint32_t)’:
bts.cpp:554:25: error: call of overloaded ‘abs(uint32_t)’ is ambiguous
  if (abs(rfn - m_cur_rfn) > RFN_THRESHOLD) {
                         ^
In file included from /usr/include/c++/6/cstdlib:75:0,
                 from /usr/include/c++/6/stdlib.h:36,
                 from /usr/include/osmocom/core/linuxrbtree.h:97,
                 from /usr/include/osmocom/core/timer.h:35,
                 from ./bts.h:29,
                 from bts.cpp:21:
/usr/include/stdlib.h:735:12: note: candidate: int abs(int)
 extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
            ^~~
In file included from /usr/include/c++/6/stdlib.h:36:0,
                 from /usr/include/osmocom/core/linuxrbtree.h:97,
                 from /usr/include/osmocom/core/timer.h:35,
                 from ./bts.h:29,
                 from bts.cpp:21:
/usr/include/c++/6/cstdlib:185:3: note: candidate: __int128 std::abs(__int128)
   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
   ^~~
/usr/include/c++/6/cstdlib:180:3: note: candidate: long long int std::abs(long long int)
   abs(long long __x) { return __builtin_llabs (__x); }
   ^~~
/usr/include/c++/6/cstdlib:172:3: note: candidate: long int std::abs(long int)
   abs(long __i) { return __builtin_labs(__i); }

Change-Id: Ib6d895a97aa35414f245ea4406c6e78f1b4fb5b8
2017-03-13 11:25:14 +00:00
Philipp Maier 1275a3f91a BTS: Convert relative frame numbers to absolute frame numbers
The implementation of the method rcv_rach() in class BTS, restores
the absolute frame number of the incoming RACH-Request by using
the relative frame number (RFn = Fn mod 42432) from the rach
request and the already known internal absolute frame number
m_cur_fn, which is continusly updated by the CCU interface.

In some rare cases, a RACH request might be received by the BTS,
a very short time before the frame number wraps in its 42432.
Depending on the PCU location, RACH request might be received
by the BSC, which forwards it to the PCU. It is then likely
that, while the RACH request is being forwarded to the PCU, the
PCU internal absolute frame number wraps before the RACH
can be processed. The relative frame number from the rach
request would then be interpreted as if it were received after
the wrapping of the internal frame number modulos.

This commit adds logic to detect and resolve this race condition.
Also a unit test is added to check some cornercases.

Change-Id: I74f00c11e5739d49f370ce6c357149e81d9aa759
2017-03-05 12:23:56 +00:00
Philipp Maier 53f0b4deb6 cosmetic: Fix log output
In BTS::rcv_rach() the log output is messed up because of a stray
"\n". This commit removes that.

Change-Id: I40d01c71982ad83589f070cf0047a4ae04695411
2017-02-01 14:19:04 +00:00
Philipp Maier d935d88a8c BTS: accept also relative frame numbers with rach requst
The rach request contains a relative frame number (Fn % 42432),
while BTS::rcv_rach() accepts the full frame number only.

Since the BTS is always aware of the full frame number this is
not a problem. But for BSC co-located PCU schemes it is a problem
since the rach request only contains the relative frame number
as mentioned above.

The pcu continusly receives frame number updates with the GSM time
indication message. It is simple to re-calculate the full frame
number from that information.

This patch makes BTS::rcv_rach() compatible with relative frame
numbers, while not breaking the compatibility for full frame
numbers

Change-Id: Iaa182d8d29c6a0f5fa06064c2eb48b21b1ba2775
2017-01-26 11:19:21 +01: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
Max 127a1e0750 Log additional info for radio errors
Change-Id: I936a07ce87f05d9c3dc351dc3bdc4f00d78265e0
Related: OS#1553
2017-01-16 10:10:01 +01: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
sivasankari 168911b438 Add new BTS level counters
Adds counters for Immediate Assignment Reject, Packet Access Reject,
Channel Request Description and Final Block resend.

Change-Id: I23e326d4ea489aa4967e452fe02773b44ab146f7
2016-11-25 19:55:38 +05:30
Mrinal Mishra f86307e1e4 Add BTS level counters
Adds counters for MCS blocks, 11 bit Rach counters and others.

Change-Id: I605b0d66eb217decd35cbb8f87abfa577760245a
2016-11-14 01:15:16 +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
aravind sirsikar c0c3afd079 Handle Immediate assignment reject
When RACH is received, PCU will generate the Immediate assignment reject
message if no resources are present. The encoding is done based on section
9.1.20 of 44.018 version 11.7.0 Release 11. This patch also includes the
test case to validate the generated Immediate assignment reject message.

This patch is integration tested on Osmo-trx setup with Ettus B210 board
and LG F70 MS with some simulation code changes in Osmo-pcu.

Change-Id: I3d33e2b9746fa4f338fad0e6b63b1c5f07de6f9b
2016-11-09 16:27:00 +05:30
Max d71e8b32e3 Use qbit-TA to update Timing Advance
Separate qbit-TA to TA conversion into separate function and use it for
computing and updating Timing Advance.

Note: the code was tested with TA=0 only to make sure it does not
introduce regressions.

Change-Id: I96fdbb20b09fb85fdd9fb6dcf3c25f6bee7f80e4
Fixes: OS#1531
2016-10-19 08:23:29 +00:00
Neels Hofmeyr 4ea452689d Revert "tbf: Add state WAIT_ASSIGN"
This reverts commit f1a7b8fc66.

Conflicts:
	tests/tbf/TbfTest.err

The commit broke GPRS service at least for osmo-bts-sysmo on a SysmoBTS 1002
with current master of osmo-bts (ef30f50d5d6d5f863fc147d05ccdceb89284934e).

The error observed is the following log output (was viewing both osmo-bts-sysmo
and osmo-pcu logs interleaved):

<0002> tbf.cpp:874 TBF(TFI=0 TLLI=0x00000000 DIR=UL STATE=WAIT ASSIGN) T3169 timeout during transsmission
<0002> tbf.cpp:893 - Assignment was on CCCH
<0002> tbf.cpp:899 - No uplink data received yet
<0007> l1sap.c:904 RACH for packet access
<0001> pcu_l1_if.cpp:311 RACH request received: sapi=1 qta=0, ra=121, fn=13653
[repeat]

When removing this single commit from current osmo-pcu master, GPRS service
works well on SysmoBTS, with current osmo-bts master.

The TbfTest.err expected output needed adjustment after the revert.

Disclaimer: I am not aware of adverse effects this commit may have. I have no
idea what the WAIT_ASSIGN state is used for -- further review is required.

Change-Id: I1532f8e93194368cdc1e3846f82afa6d68cd5fbd
2016-10-18 14:48:36 +02:00
bhargava 465f5bbb6f Update the function immediate assignment for EGPRS
Encode the EGPRS fields of immediate assignment message in uplink
when EGPRS PACKET CHANNEL REQUEST (11 bit RACH) is received.
The series of patches for 11 bit RACH are dependent on libosmocore
and osmo-bts patches for 11 bit RACH.

Change-Id: Ie5e309156e5dbbb6add74a1b4d257c4ee2332e52
2016-09-16 05:55:41 +00:00
bhargava 628dcfbc97 Handle EGPRS 11 bit RACH in osmo-pcu
A function is_single_block is added to get request type of RACH.
EGPRS 11 bit RACH is handled.

Change-Id: I61d74a32f7764644ed86f7fdf97fa3c2f61503f7
2016-09-16 05:54:15 +00:00
Max 9bbe1600cc Fix Timing Advance handling
* initialize with invalid TA instead of making assumption that phone is
  located within 550 meters (TA=0)
* only set valid TA

Change-Id: Idfc40ff0c11bdac13d9e28fbfa4e95dfc6b735b0
Related: OS#1526
2016-09-09 06:37:04 +00:00
bhargava 959d1dee67 Change interface in osmo-pcu for 11 bit RACH
Interface structure between osmo-bts and osmo-pcu is updated with
the parameters to differentiate the type of RACH and further
support 11 bit RACH. The function prototype and definitions are
changed accordingly. Interface version number is increased.

Change-Id: I265c2d92d36d6cbcbeee60cdd8407dafe1da06a4
2016-08-27 01:22:48 +00:00
Neels Hofmeyr d32aa03520 typo in warning
(actually committing just to test gerrit, and if it goes through it's still
a valid change.)

Change-Id: I2ca9a1cc2f250801fbe62f3c50b73dff7101ee08
2016-06-20 18:17:03 +02:00
Aravind Sirsikar 23617c001d Remove GMSK only check in EGPRS UL
Since we are supporting MCS 5-9 in this patch series for EGPRS UL,
This condition is not relevant. So removing it.

Change-Id: I567acc012d8ad49681715f0104ba7e91625e1e7a
Reviewed-on: https://gerrit.osmocom.org/268
Tested-by: Jenkins Builder
Reviewed-by: Harald Welte <laforge@gnumonks.org>
2016-06-16 14:17:17 +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 2fcfc29020 add comments to describe functions
Change-Id: Ie351632001abbeb82008a5eecae0d0323a8ef7d7
Reviewed-on: https://gerrit.osmocom.org/106
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-05-25 20:07:03 +00:00
Alexander Couzens c8fd4b7c42 bts/counter: replace '_' with '-' in counter names
Conform to the convention.

Change-Id: I6162694aae8d354aba318cc1acfdac108239fef0
Reviewed-on: https://gerrit.osmocom.org/103
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-24 10:18:07 +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 543756adbe bts/rate_ctr: replace spaces by tabs
Use tabs like other counters for seperation.
Introduced by 2cb1547

Change-Id: I32eebfe5934c919eccc1e28938ca00c49368297e
Reviewed-on: https://gerrit.osmocom.org/96
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-22 10:44:04 +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
Jacob Erlbeck f1a7b8fc66 tbf: Add state WAIT_ASSIGN
Currently the state on the TBF is set to ASSIGN when it is created
and in general changed to FLOW when it is acknowledged by the MS. The
moment when the assignment is really transmitted to the MS (which can
take some time) is not reflected by the state. A TBF can considered
to be valid, when the assignment is received by the MS.

Add the state WAIT_ASSIGN that is entered when the assigment has been
send to the MS (more precisely: when the corresponding RTS has been
processed or the message has been sent to the BTS).

The TBF, its PDCH(s), and its TFI can be assumed to be valid, when the
TBF has a state of WAIT_ASSIGN or higher (assuming that the TBF
starting time has not been set, which is currently only done for SBA,
which are not associated with a TBF).

Note that due to queuing in the BTS there can still be a invalid
time period for immediate assignments, when the request is lingering
in the AGCH or PCH queues.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:39 +01:00
Jacob Erlbeck 7d5157ee17 tbf: Only free TBF if it was replaced in rcv_control_ack
Currently the TBF whose PACCH has been used to send an assigment
is freed if it is in state WAIT_RELEASE. Sometimes this TBF could
be used for several assignments (e.g. an 'old' DL TBF is used to
assign an UL and then a DL TBF). The second of these assigments will
never be sent in that case. On the other hand, the MS replaces a
TBF of the same direction, so the old one can be freed in that case.

Only free the TBF if it is in state WAIT_RELEASE and has the same
direction like the new one.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:39 +01:00
Jacob Erlbeck 2647a337a8 encoding: Redesign Encoding::write_immediate_assignment API
The EGPRS support will need more information to encode the IMMEDIATE
ASSIGMENT. Instead of adding more parameters pass a pointer to the
TBF unless an SBA shall be done (indicated by tbf == NULL). All
values that can be derived from the TBF and are not needed for an SBA
are removed from the parameter list.

Return a negative value on error.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:38 +01:00
Jacob Erlbeck 9876a3ba5d tbf: Don't change type from CCCH to PACCH without ack
Currently the CCCH flag is cleared and the PACCH flag is set when a
multislot upgrade is scheduled for a downlink TBF, even if the MS has
never confirmed in any way that the PACCH really exists. This can
happen if the MS did not receive the DL IMM.ASS. Since the CCCH flags
gets cleared in that case, the IMM.ASSS is never retried and all
subsequent PACKET DOWNLINK ASSIGNMENTS will fail.

This commit delays the update of these flags until the MS has
responded with a corresponding CONTROL ACK.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:38 +01:00
Jacob Erlbeck 8eb17143f2 tbf: Add and use tbf->poll_ts
Currently tbf->control_ts is used to look up an incoming poll
response. Since that may eventually change, poll timeouts could
theoretically happen in that case.

Store the real poll TS in tbf->poll_ts at all places where
tbf->poll_fn is set. Do not use tbf->control_ts to look up
outstanding polls.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:38 +01:00
Jacob Erlbeck 5f93f855a7 tbf: Do not reuse old TBF after RACH requests
Currently existing TBF can be reused after an MS has sent a RACH
request. Since the MS can be or most probably is in packet idle mode
in that case, the TBF are no longer usable even if they share the
PDCHs and the control TS with the new one.

There are occasional freezes where the MS does no longer react to
messages sent on the PACCH.

This change aborts all pending TBFs if a new TBF is or has been
established via RACH.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:37 +01:00
Jacob Erlbeck 0316dc6e48 tbf: Add counters for aborted TBF in state FLOW
Increment CTR_TBF_DL_ABORTED/CTR_TBF_UL_ABORTED if a TBF gets freed
that is still in state GPRS_RLCMAC_FLOW.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:37 +01:00
Jacob Erlbeck 29e3a2f0f3 Revert "tbf: Use the control TS for Immediate Assignments"
According to spec, the lowest numbered PDCH of the TBF shall be used
for the PACCH, only when concurrent TBF are active, the lowest common
PDCH shall be used. An immediate assigment is in general only sent,
if no TBF is active, so the latter case never applies.

This reverts commit fdd8a1ba2312be3f33576ee994c0b5da6272e815.
2016-02-08 00:45:37 +01:00
Jacob Erlbeck 56d06f3e1e tbf: Use the control TS for Immediate Assignments
Currently the first TS is used, which can be different from the
control TS on downlink TBFs.

Use the control TS instead.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:37 +01:00
Jacob Erlbeck 2ca86afdec tbf: Refactor calls to write_immediate_assignment
Make use of variables, log them to LOGL_DEBUG, and reduce code
duplication.

This should help to narrow down the cause why snd_dl_ass are not
answered by the MS sometimes.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:37 +01:00
Jacob Erlbeck 9b3d7e0159 edge: Disable GPRS/EGPRS mixed mode
Currently the plain 'egprs' command enables EGPRS but doesn't prevent
phones from being served in GPRS mode if they do not support EGPRS.
This involves complex frame allocation implementations in dynamic
mode, especially if 8PSK is being used. This is due to the inability
of non-EGPRS phone to decode 8PSK USF and ES/P altogether. Since
polling has a higher priority than USF, collisions will have to be
prevented by the PCU by never using an GPRS USF if it refers to a FN
that is already being used for polling.

This commit just disables mixed usage by ignoring GPRS-only request
if EGPRS is enabled.

The following VTY command (config-pcu node) is changed:

  egprs     ->   egprs only

Sponsored-by: On-Waves ehf
2016-02-08 00:45:35 +01:00
Jacob Erlbeck d7630f2256 edge: Use bitvec based window methods for EGPRS
Currently a faked 'old' RBB with 64 ACKs is being used.

Use the new bitvec based methods instead.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:35 +01:00
Jacob Erlbeck 419b034975 tbf: Use bitvec based window methods for GPRS
Currently the old fixed 64 bit RBB based implementation is used for
GPRS.

Use the new bitvec based methods instead.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:35 +01:00
Jacob Erlbeck ae9c575d2c edge: Handle EGPRS PACKET DOWNLINK ACK NACK
Currently this message is ignored.

Support decoding and handling of this message. Use a bitvec for the
decoder that just represents a BSN sequence without any encoding
details (first bit -> first BSN). Return the corresponding BSN range
(snsmod(bsn_begin + bits_in_bitvec) = bsn_end), so snsmod(bsn_end-1)
is the last BSN if there is at least 1. If bsn_begin == bsn_end, no
BSNs has been added.

Note that this bitvec is not yet used for RBB handling. It just calls
the old rcvd_dl_ack with a faked (all bits are 1) RBB map.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:34 +01:00
Jacob Erlbeck fc1b3e6c90 edge: Fix RLC message size
Currently the RLC message length that is obtained from the DSP is
reduced by 1 if the last byte of the buffer includes spare bits.
While this worked well with GPRS, these bits are being used to
encode RLC blocks in EGPRS mode. Thus this last byte must not be
chopped off. The functionality of the code is not affected by this,
since the modified length value is not used.

This commit adds GprsCodingScheme::usedSizeDL/UL to return
the number of bytes needed to encode the message block. If there are
single bits at the end that are to be used (EGPRS), the functions
return the number of full bytes plus 1 (which is the buffer size
reported by the DSP and returned by sizeUL/sizeDL). The commit also
removes the len parameter from rcv_data_block_acknowledged.

Sponsored-by: On-Waves ehf
2016-02-05 13:26:33 +01:00
Jacob Erlbeck f2ba4cbf51 edge: Rename gprs_rlc_ul_header_egprs and gprs_rlc_ul_data_block_info
These struct names are more specific than necessary. They are used
for GPRS (uplink) already. In downlink direction, only a few fields
will be added to the header struct. Add addition,
gprs_rlc_ul_header_egprs does not map directly to an encoded
header, like many other 'header' structs do.

Change the names to fit both modes and both directions:

  gprs_rlc_ul_header_egprs    -> gprs_rlc_data_info
  gprs_rlc_ul_data_block_info -> gprs_rlc_data_block_info

Sponsored-by: On-Waves ehf
2016-02-05 13:26:33 +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 aa9daa1b9d tbf: Replace static casts by calls to as_ul_tbf/as_dl_tbf
Currently casts from gprs_rlcmac_tbf to gprs_rlcmac_ul_tbf and
gprs_rlcmac_dl_tbf are done by using static_cast. This doesn't provide
protection against converting a gprs_rlcmac_ul_tbf pointer to a
gprs_rlcmac_dl_tbf pointer and vice versa.

This commit provides two functions as_ul_tbf and as_dl_tbf, that
behave similar like dynamic_cast but use the direction field instead
of RTTI.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:13 +01:00
Jacob Erlbeck d88bb2e825 rlc: Dump RLC data for debugging
Log incoming RLC data messages and RLC data units to LOGL_DEBUG.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:12 +01:00
Jacob Erlbeck c362df25a2 pcu: Fix memory corruption bugs (ASAN)
ASAN has found improper deletion of objects. These only occur
on shutdown but makes it impossible to run the test cases with
full ASAN support.

This commit fixes some of them and deactivates the freeing of the_pcu.bctx
which may cause a corruption in BTS::~BTS() later on.

Note that the latter is only a work-aound and should be fixed
properly. It will leak bctx objects, but this is currently not
critical, since gprs_bssgp_destroy is only called once, immediately
before a call to exit().

Ticket: OW#1572
Sponsored-by: On-Waves ehf
2016-02-01 13:56:32 +01:00
Jacob Erlbeck 845c01ef3f edge: Remove unused GPRS functions
This commit removes the code that is no longer used due to the commit
"Use a single PDCH rcv_data_block method for GPRS and EGPRS".

Sponsored-by: On-Waves ehf
2015-12-16 19:57:13 +01:00
Jacob Erlbeck 554a835e90 edge: Use a single PDCH rcv_data_block method for GPRS and EGPRS
Currently GPRS is handled by the old code path while EGPRS already
uses the unified functions. The rcv_block_egprs is basically not
specific to EGPRS and just needs minor modifications to handle GPRS.

This commit turns gprs_rlcmac_pdch::rcv_block_egprs into a unified
rcv_data_block method and uses it for GPRS, too.

Note that the logging messages of the new parser are different.

Sponsored-by: On-Waves ehf
2015-12-16 19:57:09 +01:00
Jacob Erlbeck 39c6c7f738 edge: Implement gprs_rlcmac_pdch::rcv_block_egprs
This commit replaces the stub by a method that decodes the block
first, and passes it to the TBF object associated with the TFI.

Sponsored-by: On-Waves ehf
2015-12-16 19:55:52 +01:00
Jacob Erlbeck 3b802e3c4a edge: Rename rcv_data_block_acknowledged
This commit renames rcv_data_block_acknowledged to
rcv_data_block_acknowledged_gprs to separate it from EGPRS data block
decoding.

Sponsored-by: On-Waves ehf
2015-12-15 15:19:43 +01:00
Jacob Erlbeck 690a734ebf edge: Add gprs_rlcmac_pdch::rcv_block_egprs stub
This stub function gets called when an EGPRS data package arrives.

Sponsored-by: On-Waves ehf
2015-12-15 15:19:42 +01:00
Jacob Erlbeck 9e862e1e7f edge: Use GprsCodingScheme to adjust the UL RLC block size
Currently the block size is mapped by a switch statement to strip
extra bits that are not used for RLC blocks. That information is
already available via the GprsCodingScheme class.

This commit moves the CS/MCS detection to the rcv_block message and
passes the cs object via rcv_block_gprs, where the length gets
adjusted, to gprs_rlcmac_pdch::rcv_data_block_acknowledged. There the
switch statement is removed.

Note that the TbfTest.err changes due to an additional log message.

Sponsored-by: On-Waves ehf
2015-12-15 15:19:42 +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 c3c58046c7 edge: Get EGPRS multislot class
The EGPRS MS class ist contained in the MS_RA_capability information.
Its presence indicates, that the MS is able (and willing) to use
EGPRS.

This commit implements basic support for retrieving, storing, and
showing it in the VTY. The information is stored in the MS object.

Sponsored-by: On-Waves ehf
2015-11-30 12:20:36 +01:00
Jacob Erlbeck f5898a0528 stat: Add global stat group
Add a global stat_item group for measurement values and a
corresponding macro to get and set the values.
Add a stat_item STAT_MS_PRESET to monitor the number of
MS objects in the storage.

Sponsored-by: On-Waves ehf
2015-11-30 12:11:29 +01:00
Holger Hans Peter Freyther 8df447dc77 stats: Include the header file for the new class identifier 2015-11-07 21:04:40 +01:00
Holger Hans Peter Freyther b8a5426cf0 stats: Attempt to compile fix the new rate_ctr
We wanted to support gcc-4.2 and this didn't allow us to use
the C99 initializers inside C++ code. Attempt to initialize
the class_id correctly.
2015-11-07 21:01:23 +01:00
Jacob Erlbeck 7c8d39a67b poll: Count failed procedures
When a timeout has occured several times, the procedures handled by
poll_timeout are aborted. This happens when the number of repetitions
exceed N3105. Currently only the timeouts themselves are counted.

This commits adds counters that are incremented if a procedure has
really failed.

New counter:
- rlc.ass.failed:   Count failing UL and DL assigments via PACCH
- rlc.ack.failed:   Count failing DL Ack/Nack requests

Sponsored-by: On-Waves ehf
2015-09-07 14:10:35 +02:00
Jacob Erlbeck c8cbfc2c98 bts: Start a DL TBF if needed after establishment of an UL TBF
Currently an existing DL TBF can get lost in the process of
establishing an UL TBF via RACH. This can lead to stalled connections
until the network sends more LLC frames.

This commit adds a check for a non-empty LLC queue after the UL TBF
has been established to rcv_control_ack (GPRS_RLCMAC_UL_ASS_WAIT_ACK
path) to eventually establish a new DL TBF on the UL TBF's PACCH.

Sponsored-by: On-Waves ehf
2015-09-01 12:01:20 +02:00
Jacob Erlbeck ae0a799f44 bts: Release DL TBF instead of killing in rcv_resource_request
Currently an existing DL TBF is freed immediately, when a resource
request is received. This makes sense since the MS might have dropped
it when switching to the PDCH signaled via the AGCH for the SBA. But
if the TBF still is assumed to exist on the MS side, there might be
TFI collisions if the old TBF object is not kept to block its TFI
for some time.

This commit changes rcv_resource_request to call release() instead of
tbf_free() on the DL TBF object (if it exists).

Sponsored-by: On-Waves ehf
2015-09-01 12:00:31 +02:00
Jacob Erlbeck cf6ae9d12f Revert "tbf: Do not kill DL TBF on Packet Resource Request"
This reverts commit e91bd3babd.

That commit seems to cause hanging DL TBFs when there was a RACH
based UL TBF establishment while it that TBF is active. This could be
caused by the use of a different PDCH for the SBA.

Conflicts:
	tests/tbf/TbfTest.cpp
	tests/tbf/TbfTest.err
2015-09-01 11:48:25 +02:00
Jacob Erlbeck af75ce8e15 l1: Use the FN of all data_ind/ra_ind DSP messages
Currently all of these messages are discarded if they are assumend to
be caused by noise. But even in these cases, the FN and TN values
which are added by the DSP are valid. So these can be used to update
the current_frame value.

The osmo-bts sets the fBFILevel of a physical channel to -200dB if it
is used for PDTCH or PACCH which is the case for all PDCH. This way
a data_ind or ra_ind message is already send at least once per block
period (4 frames) per PDCH. These messages are passed to either
handle_ph_data_ind or handle_ph_ra_ind even if they contain garbage
data.

The ra_ind messages are sometimes sent a few frames earlier than
data_ind messages using the same frame.

This commit adds calls to update the current_frame value based on all
of these messages before they are discarded. The FN taken from ra_ind
are passed with an increased max_delay (5) to compensate for early
ra_ind messages.

Sponsored-by: On-Waves ehf
2015-08-28 12:23:07 +02:00
Jacob Erlbeck be4a08b58a poll: Count unexpected block FN values
Currently a log entry is written if FN_data_ind - FN_time_ind <= -13.

This commit adds a counter 'rlc.late-block' that is incremented in
these cases.

Sponsored-by: On-Waves ehf
2015-08-28 12:23:07 +02:00
Jacob Erlbeck 60f77033ad poll: Use the data_ind FN as time source for current frame
The FN of the data_ind taken from the DSP are monotonic, so latency
does not affect the detection of poll timeouts if these FN are used.
If the FN is larger than a poll_fn value, it can safely be assumed
that the poll response will not arrive later on.

Currently a max_delay of 60 frames is used, which has the drawback
that additional ~250ms will pass until a lost ACK is detected.

Using the data_ind's FN alone breaks the poll timeout detection if
there are no other MS sending data blocks.

This commit adds BTS::set_current_block_frame_number that is called
with the FN taken from data_ind messages. The max_delay is set to 0
which removes the additional delay, when this FN is used to detect
poll timeouts. So the average additional delay decreases with the
number of data_ind per time. The current_frame is updated unless it
seems to have been updated already (assumed if 0 < cur_fn - block_fn
< 500). Thus the time_ind has still priority to update the
current_frame value.

Sponsored-by: On-Waves ehf
2015-08-28 12:23:07 +02:00
Jacob Erlbeck e77d49f2a2 poll: Set the max_delay to 60 frames
Currently the max_delay parameter is set to 13, since that is
slightly above maximum number of frames that a time_ind can preceed a
block's data_ind of the same frame. This assumes that these messages
are not reordered after thay have been obtained from the DSP. In the
current implementation, the GPRS data_ind can directly be taken from
the DSP by the PCU while the time_ind messages are provided via the
BTS. So the messages are queued differently in that case, resulting
in a additional delay of the data_ind with respect to the time_ind.
The propability for this raises with a increased CPU load of the PCU.

If this happens, a poll timeout is detected by mistake and the poll
is either retried or cleared.

This commit increases the tolerance to 60 frames, since
values for FN_data_ind - FN_time_ind of up to 50 frames have been
observed under heavy PCU load.

Sponsored-by: On-Waves ehf
2015-08-28 12:23:07 +02:00
Jacob Erlbeck ac49d0943a poll: Add a max_delay parameter to PollController::expireTimedout
Currently the maximum additional delay is hard coded to 13. This
value depends on the source of the frame number value.

This commit adds the max_delay parameter to make it caller dependant.

Sponsored-by: On-Waves ehf
2015-08-28 12:23:07 +02:00
Jacob Erlbeck e91bd3babd tbf: Do not kill DL TBF on Packet Resource Request
Currently all active TBF of an MS are killed if a Packet Resource
Request is received from the MS. In general this happens after a RACH
request. This does not happen after a resource request that has been
included into a Downlink Ack/Nack.

Sometimes an UL TBF is requested by an MS via RACH while a DL TBF is
running for instance to send a TCP Ack. This can happen, if a former
request via PACCH did not work.

This commit removes the killing of the DL TBF from
gprs_rlcmac_pdch::rcv_resource_request().

Sponsored-by: On-Waves ehf
2015-08-21 19:02:18 +02:00
Jacob Erlbeck 537b149828 tbf: Fix typos in log messages concerning UL/DL
The TBF in create_dl_ass can be of any direction. The text in
rcv_resource_request uses DL instead of UL.

Sponsored-by: On-Waves ehf
2015-08-21 18:59:14 +02:00
Jacob Erlbeck 5979fe9d8a alloc: Add counters for successful algo A/B allocations
This adds counters for algorithm A and B with count successful
allocation combined for UL and DL.

Ticket: #1934
Sponsored-by: On-Waves ehf
2015-07-16 19:24:16 +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 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 cc9358f95a tbf: Keep a set of used TFI and USF per PDCH
Currently is is rather expensive to get TFI and USF usage per PDCH,
because the TBFs need to be scanned to get that information.

This commit adds corresponding bit sets which get updated by the
attach_tbf/detach_tbf methods of the gprs_rlcmac_pdch class.

Sponsored-by: On-Waves ehf
2015-07-07 10:35:28 +02:00
Jacob Erlbeck c91c18e6ef tbf: Add Poll Timeout counters
This commits adds three poll timeout counters

  - RLC Assign Timeout
  - RLC Ack Timeout
  - RLC Release Timeout

to help diagnosing to cause for these events. There seems to be an
increased rate of these when a PDCH is shared by multiple TBFs.

Sponsored-by: On-Waves ehf
2015-07-07 09:33:29 +02:00
Jacob Erlbeck 23f93a15ca ms: Add support for slot reservation
In contrast to the slots currently used by existing TBFs, the
reserved slots refer to the time slots that can be used for newly
allocated TBFs without causing conflicts (given that the first common
TS does not change). They correspond to the potential use of the
PDCHs and can be used to achieve a more uniform slot allocation.

This commit adds bit set based methods to GprsMs and gprs_rlcmac_trx
and a counter to gprs_rlcmac_pdch. The current TRX will also be
stored in the MS object.

Sponsored-by: On-Waves ehf
2015-07-03 15:37:16 +02:00
Jacob Erlbeck ccc34e4d30 tbf: Maintain the number of TBF per PDCH
Currently the PDCH object do not know anything about the TBFs using
them. To make the slot allocation load dependant, at least some
numbers are required.

This commit adds TBF counters (one per direction) and the related methods
attach_tbf, detach_tbf, and num_tbfs to gprs_rlcmac_pdch.

Sponsored-by: On-Waves ehf
2015-07-03 13:17:22 +02:00
Jacob Erlbeck cb1b494c89 tbf: Add BTS::ms_alloc method
Currently the code that creates the MS objects with tbf.cpp is
duplicated.

This commit moves the corresponding code into a new method. Since
there is no TLLI available there, the GprsMsStorage::create_ms method
has been refactored into two variants: one with TLLI/direction and
one without.

Sponsored-by: On-Waves ehf
2015-06-29 11:43:17 +02:00
Jacob Erlbeck 6d86628e5b tbf: Always create an MS object on TBF allocation
Currently the MS object are created when the TLLI gets known.
Therefore some information (TA, MS class) must be stored in the TBF
itself and is copied to the MS object later on. This would get even
more complex, if the allocation algorithms were extended based on
this scheme.

This commit ensures, that an MS object will always be created on TBF
allocation, even if the TLLI is not yet known. These 'anonymous'
objects are still managed by the MS storage. To avoid dangling
entries without a TLLI there (which cannnot be retrieved anyway), the
timer in the MS objects is not started after all TBF have been
detached, so that they get deleted immediately in that case.

Note that an MS object can still be removed (e.g. by replacement)
from an existing TBF, so tbf->ms() can be NULL.

Ticket: #1794
Sponsored-by: On-Waves ehf
2015-06-29 10:53:32 +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 ace7b570a0 tbf: Remove update_tlli method
This method does not do anything anymore, it's functionality has been
taken over by update_ms.

This commit removes gprs_rlcmac_tbf::update_tlli completely.

Sponsored-by: On-Waves ehf
2015-06-29 10:53:32 +02:00
Jacob Erlbeck da1a79ef5b l1: Add debug log messages for I_LEVEL
The I_LEVEL values that are obtained now look suspicious. They do not
seem to be contained in messages recorded via gsmtab.

To help debugging this issue, this commit adds related debug messages
that are generated while the encoded values are taken from the
RLC/MAC messages.

Sponsored-by: On-Waves ehf
2015-06-22 10:39:06 +02:00
Jacob Erlbeck 51b1151044 l1: Store measurement values sent by the MS
This commit extends the pcu_l1_meas structure by MS side measurement
values which are transmitted by PACKET DOWNLINK ACK/NACK and
PACKET RESOURCE REQUEST messages. The encoded values are remapped to
dB respectively % values. The values are stored in the corresponding
MS object (if there is one).

Note that the values are store as (rounded) integers, so some
different encodings are mapped to the same decoded value.

Sponsored-by: On-Waves ehf
2015-06-22 10:39:06 +02:00
Jacob Erlbeck 20f6fd1b63 l1: Pass all L1 measurements upwards
Currently only the RSSI value is passed to the upper layers. Other
values like TA and BER which are needed for TA update respectively CS
selection are not propagated.

This commit introduces and passes a struct that contains a set of
measurement values.

Sponsored-by: On-Waves ehf
2015-06-22 10:39:06 +02:00
Jacob Erlbeck 17214bb06d ms: Add back pointer to BTS
Since more functionality will be moved to the GprsMs class, a pointer
to the current BTS object is added to allow access to configuration
data and other methods.

Sponsored-by: On-Waves ehf
2015-06-08 09:39:07 +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 1db67e0a35 tbf: Remove TimingAdvance storage
Currently the TA storage stores up to 30 TLLI->TA mappings, if more
entries are created the oldest one is dropped. In theory this can
lead to missing TA information if many MS are present.

This commit removes the TimingAdvance class completely, since the TA
value is now stored in the GprsMs objects.

Note that the GprsMs objects are currently not kept after the TBFs
have detached from them, so the TA values are now kept for a shorter
time than before.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-28 13:59:25 +02:00
Jacob Erlbeck 9200ce6019 tbf: Store the timing advance (TA) value in the GprsMs object
The TA value rather relates to an MS and not to a single TBF. So all
TBFs share the same TA value. Currently the TA value is stored per
TBF and eventually copied from an old TBF to a new one. It is in
general only passed with an RACH request when the TLLI and thus the
MS is not yet known.

This commit adds a TA member to the GprsMs class and uses that one
when the TBF is associated to an MS object. Since the TBF is not
always associated with an MS object (after RACH or when it has been
replaced by another TBF), the TA value is still stored in each TBF
and that value is used as long as no MS object is being associated.

Sponsored-by: On-Waves ehf
2015-05-28 13:58:23 +02:00
Jacob Erlbeck ddfc0d5763 tbf/test: Add tests for single and two phase access
These tests cover the message exchange from receiving from the first
RACH request to the first data block when establishing an uplink TBF.

This will be used to check, whether TA and other values are passed to
an MS object correctly.

In addition, the RX RACH log message in rcv_rach is extended to
contain the single block fn.

Sponsored-by: On-Waves ehf
2015-05-28 12:29:43 +02:00
Jacob Erlbeck d3eac2867a tbf: Remove TBF chaining (m_new_tbf and m_old_tbf)
Currently a new TBF is chained to an existing older one, either of
the other direction (active or releasing) or of the same direction
(releasing). This does not work properly work if and uplink and a
downlink TBF are being established at the same time while an old TBF
is being released. In that case, one of them is thrown away and the
pending procedure is cancelled.

The chaining is no longer necessary since the GprsMs objects have
been introduced which keep track of the active TBFs.

This commit removes the TBF members m_new_tbf and m_old_tbf and the
related methods and code paths.

Note that a new TBF can replace an older TBF entry of the same
direction within an MS object when it is associated with an MS (e.g.
by TLLI or because it is assigned via another, already associated
TBF). In that case, the old TBF is no longer associated with an MS
object.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-28 12:29:43 +02:00
Jacob Erlbeck 71e55118f5 tbf: Remove IMSI handling from trigger_dl_ass
Currently the BTS::trigger_dl_ass() method assigns the IMSI to the MS
object. This should be (and is already) done earlier where the MS
object is retrieved/created.

This commit removes the corresponding code along with the 'imsi'
parameter from trigger_dl_ass.

Sponsored-by: On-Waves ehf
2015-05-28 12:29:42 +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 fecece0e59 tbf: Add MS object management to TBF code
This commit adds MS object creation and cleanup to the TBF related
code. MS objects are created when a TBF that has been "anonymous" so
far gets associated with a TLLI. When a TBF is replaced by another,
the old TBF is detached and the new one is attached to the MS. When
all TBFs have been detached, the MS object gets deleted.

The TBF related code should not call attach_tbf/detach_tbf directly
but use set_ms instead to make sure, that the references are updated
properly. GprsMs::detach_tbf also calls set_ms(NULL) on the detached
TBF object.

The MS object is not really used yet, the focus is still on object
creation, TBF association, and cleanup.

Ticket: #1674
Sponsored-by: On-Waves ehf
2015-05-20 11:31:07 +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
Jacob Erlbeck 297edf754f tbf: Don't use 'old' DL TBFs after reuse_tbf
Currently two DL TBF objects with the same TLLI exist after reuse_tbf
which make the result of tbf_by_tlli undefined. This leads to several
DL TBFs belonging to the same TLLI.

This commit extends tbf_by_tlli to check the m_tlli_valid flag for
DL, too. That flag is set to 0 in reuse_tbf to mark the 'old' DL TBF
as invalid after its LLC data has been copied to the new one.

Sponsored-by: On-Waves ehf
2015-02-26 16:22:34 +01:00
Daniel Willmann e481815583 tbf,bts: Keep track of new TBF for dl/ul assignment in m_new_tbf
There are a couple of possibilities where one TBF is used to assign a
new one:

1. Assign a DL TBF from a UL TBF
2. Assign a UL TBF from a DL TBF
3. Assign a DL TBF from a DL TBF which is in wait-release state (T3193 is
   running)

In these cases the assignment is sent on the existing TBF and triggers
the assignement of the new TBF (with different TFI/direction).

The current code detects these situations by looking at dl/ul_ass_state
and then chosing the TBF with the opposite direction (DL/UL) that has
the same TLLI. This does not work in the case 3 above where a new DL TBF
is triggered for a DL TBF. The current code reuses the old TBF (and
TFI), but this violates the spec.

This patch introduces a m_new_tbf member which is set to the new TBF to
be assigned. When receiving a control ack the code looks up the
n_new_tbf member of the tbf that requested the control ack and completes
the ul/dl assignment. If the old TBF was in the wait release state
(T3193 is running) it is released.

From 3GPP TS 04.60 9.3.2.6:
"""
If the network has received the PACKET DOWNLINK ACK/NACK message with
the Final Ack Indicator bit set to '1' and has new data to transmit for
the mobile station, the network may establish a new downlink TBF for the
mobile station by sending the PACKET DOWNLINK ASSIGNMENT or PACKET
TIMESLOT RECONFIGURE message with the Control Ack bit set to '1' on
PACCH. In case the network establishes a new downlink TBF for the mobile
station, the network shall stop timer T3193.
"""

reuse_tbf() is modified to allocate a new TBF with a new TFI and trigger
a dl assignment for that TBF on the old TBF. All pending data is moved
to the new TBF.

Ticket: SYS#382
Sponsored-by: On-Waves ehf
2014-09-10 19:04:46 +02:00
Daniel Willmann eb100244b0 tbf, bts: Use tbf set_state method instead of tbf_new_state function
All the function did was add debug output and call the set_state method.
Move the debugging into the method and remove the function.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-08 14:15:24 +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 532a4b54f5 bts: Change parameter in BTS::trigger_dl_ass() to DL TBF
This method is always called with a DL TBF as argument so make it clear.

Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:04 +02:00
Daniel Willmann 1dac2ebb71 bts: Make use of DL TBF explicit in rcv_imm_ass_cnf()
Ticket: SYS#389
Sponsored by: On-Waves ehf
2014-08-07 16:12:04 +02:00
Daniel Willmann 6c813fc9bc bts, tbf: Make rcvd_dl_ack a method of the DL TBF
This method is only userul for DL TBFs so move it. As a result
gprs_rlcmac_pdch::rcv_control_ack needs to work with dl_tbfs.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-08-07 13:03:10 +02:00
Daniel Willmann 057c285cd7 bts: Remove the OSMO_ASSERTs for TBF direction
llist_add is called on the TBF lists in tbf_alloc_ul/dl_tbf or in
rotate_in_list. All three places check the direction/add the new TBF to
the correct list so an ASSERT on entry is not needed.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-08-07 13:03:09 +02:00
Daniel Willmann 1b3864fc47 tbf: Use plain old data structure (PODS) for llist management
The PODS struct has a back pointer to access the actual object.
llist_pods_for_each_entry traverses the list of struct llist_pods and
makes the entry available (through the back pointer).

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-30 18:27:30 +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
Daniel Willmann 0d12a2fa89 bts, tbf: Change the TBF return type of functions to the ul/dl version
Many functions only ever deal with or return a UL or a DL TBF.
Explicitly change the type to reflect which TBF is used where.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-22 12:36:13 +02:00
Daniel Willmann fe6e2e4a08 bts: Return the special type for {ul,dl}_tbf_by_* functions
Start returning the special type instead of the base gprs_rlcmac_tbf
when retrieving a TBF.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-16 22:10:17 +02:00
Daniel Willmann 2207c5e4ef bts: Ensure tbf direction with OSMO_ASSERT()
In the lookup functions make sure that we are actually returning tbfs
with the expected direction.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-16 19:03:36 +02:00
Daniel Willmann febf1a0ac9 bts: Split tbf_by_poll_fn into separate dl and ul functions
rcv_control_dl_ack_nack is only meaningful for dl tbf while
rcv_control_ack can be sent in response to a dl or ul tbf. So
rcv_control_ack still needs to check for ul and dl tbfs.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-03 15:36:52 +02:00
Daniel Willmann 54044b0635 bts: Separate functions for dl/ul tbf_by_tfi lookup
Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-03 15:36:52 +02:00
Daniel Willmann b59d61b4b4 bts, tbf: Separate functions for dl/ul tbf_by_tlli lookup
In the future we want to separate ul and dl tbf into different
classes that inherit from a common base.

Ticket: SYS#389
Sponsored-by: On-Waves ehf
2014-07-03 15:36:46 +02:00
Daniel Willmann 77e58f602d bts: Remove outdated comment
There is no parameter in the function and the bts has a memeber trx
which has a member pdch.

Sponsored-by: On-Waves ehf
2014-06-04 19:01:56 +02:00
Daniel Willmann 17a1d5e162 gprs_rlcmac_pdch: Get rid of ul/dl_tbf
The current code keeps a reference to all tbfs in the bts and another
reference in the pdch. This allows for the possibility of both lists to
go out of sync.

This patch removes the pdch-specific list of ul and dl tbfs and uses the
lists in the bts to lookup tbfs everywhere.

Performance for going through the global list is not an issue yet. We
can optimize this later and in a better way.

Sponsored-by: On-Waves ehf
2014-06-04 17:17:45 +02:00
Daniel Willmann 1e0c61032f gprs_rlcmac_pdch: Don't access private members
This patch introduces methods to get ul and dl tbf by tfi and uses them
in gprs_rlcmac_sched.

Sponsored by: On-Waves ehf
2014-06-04 17:14:22 +02:00
Daniel Willmann 73191a443f tbf/bts, encoding: Keep track of WAIT_RELEASE state for DL assignment
The current code does not properly distinguish between DL assignments to
reuse a tbf (after it was put in state WAIT_RELEASE) and DL assignments
for an active tbf to change the allocation of the PDCH timeslots.

This patch introduces a new variable was_releasing which remembers if
trigger_dl_ass() was called with a tbf in state WAIT_RELEASE. In that
case we have to set the CONTROL_ACK field in the download assignment.

This should allow us to send DL assignments to change PDCH TS allocation
of a tbf before we enter FLOW state.
2014-05-30 18:21:00 +02:00
Daniel Willmann fc03bbe078 tbf/bts: Rename tbf->snd_dl_ack to tbf->rcvd_dl_ack
This function is called to act upon a received DL ACK packet so this
name makes more sense.
2014-05-30 18:19:06 +02:00
Holger Hans Peter Freyther 3d0cc2f97d tbf: Make finding use-after-free more easy and set to NULL or return
Make finding use-after-free more easy by setting things to NULL
or simply return after tbf_free(this) has been called.
2014-01-16 10:09:42 +01:00
Holger Hans Peter Freyther f37e514a96 bts: Rename ts and trx to ts_no and trx_no as we operate on number 2014-01-15 10:34:22 +01:00
Holger Hans Peter Freyther 8f399de135 tbf: Kill the tsc member as it duplicates data
We can just use first_ts and the trx/pdch to extract this information.
Avoid duplication of data.
2014-01-15 10:34:09 +01:00
Holger Hans Peter Freyther 12c039cdb2 debug_diagram: Remove the special debug_diagram compilation mode
This approach is somehow flawed. We need/want to debug problems on
systems with real traffic and re-compiling it with debug_diagram
is not an option. All internal logging needs to be expressive enough
so we can understand what is going on (e.g. create a script to
post-process the output).
2013-11-26 20:57:24 +01:00
Holger Hans Peter Freyther ef93bdb19b tbf: Count how often we re-start a BSN in the send routine
There appears to be a scheduling issue. Even without any NACKs
we are re-transmitting a lot of frames. It might be because of
this.
2013-11-24 00:01:50 +01:00
Holger Hans Peter Freyther 092478f294 rlc: Count nacked frames in the statistics too 2013-11-23 01:01:19 +01:00
Holger Hans Peter Freyther c70aae4697 rlc: Count the window stalls on the RLC level 2013-11-19 17:09:37 +01:00
Holger Hans Peter Freyther e9429b5d3e rlc: Count the sent and resent RLC blocks 2013-11-13 19:36:57 +01:00
Holger Hans Peter Freyther b3d5ee2934 bts: Count the number of llc frames that were "scheduled" to be sent
This does not mean that they have been successfully transferred
to the SGSN/MS but at least that they have reached a certain point
in the message flow.
2013-11-13 16:43:26 +01:00
Holger Hans Peter Freyther aa35ba7584 tbf: Count how often we re-use a TBF that was already being deactivated 2013-11-13 15:02:50 +01:00
Holger Hans Peter Freyther 77e05971b4 tbf: Move the llc handling into the tbf (from the bts)
This will be moved to a LLC class in the future but after this
we can make the sns/ws private now and have little to update
outside the tbf.
2013-11-06 19:16:43 +01:00
Holger Hans Peter Freyther 5464c9baf2 tbf: Have one imsi field and assign it through a function
Have one IMSI field per TBF and assign through a function call.
The IMSI should be used to look-up the TBF on the SGSN->PCU
direction.
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 34f6e5ebe6 tbf: Make tfi private and update the code
All logging code that used tbf->tfi is now using tbf_name to
print the the TBF. External code is now using tfi() which is
inlined and should result in the same code being generated as
before (+debug code that can be stripped).
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 474685e26e tbf: Make the tlli "private" and update the updating code
Now all updates to the tlli/tlli_valid are in one place. If we
implement the policy to update the matching/linked TBF we can
now to do it in a single place. Add a todo item for that as I
am waiting for feedback from the mailinglist.
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther bd449f57a7 tbf: Create tbf_name and use it in log statements
This is like gsm_lchan_name and should be used in log statements.
This way we can easily change the information that is printed and
we know how to search things. The other part is that direct use
of tfi/tlli is removed which will allow us to make them private
and at the same time start to resolve the "tlli" updated in many
places.

Not old log statements are changed yet. This will done whenever
a bad log statement is seen on the console...
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 870c601f1d tbf: TODO:Mark TLLI changes as todo item in the code
The TLLI can change when a new P-TMSI is assigned to the phone,
e.g. during a (periodic) routing area update. When the TLLI
changes we need to update all TBFs and maybe even register the
timing advance for the new TLLI..
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 6b88cddc21 bts: Simplify rcv_resource_request, remove logically dead code
tbf = find
 if (tbf) {
   tbf_free(tbf);
   tbf = NULL;
 }
 if (!tbf) {
   code...
 }

Remove the if (!tbf) and indention as the tbf is always to be
NULL.
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 8021644e9d bts: Kill dead stores of the tlli/tfi, fix the log message again
The code meant to print the tfi and not the tlli. Update it.
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther ec80f82824 tbf: Remove the trx_no field from the tbf, go through the trx object 2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther fc498c9e7b tbf: Go through the trx to get the ARFCN 2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 875fc895a8 bts: Further logging improvements for TFI/TLLI output 2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther e1a075ab59 bts: Pass the Packet_Control_Acknowledgement_t into the recv method 2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 53a336f0e5 bts: Log the TLLI inside the report we get 2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 8d0e489484 tbf: Log the TFI and TLLI so we can try to figure out more from logs
<0002> tbf.cpp:444 Poll timeout for DL TBF=0
<0002> tbf.cpp:513 - Timeout for polling PACKET DOWNLINK ACK.
<0002> tbf.cpp:688 - Assignment was on PACCH
<0002> tbf.cpp:694 - Downlink ACK was received
<0008> gprs_bssgp_pcu.cpp:154 LLC [SGSN -> PCU] = TLLI: 0xd6942c78 IMSI: 274080000004765 len: 506
<0002> bts.cpp:974 PACKET DOWNLINK ACK with unknown FN=2213128 TFI=0 (TRX 0 TS 6)
2013-10-30 21:24:13 +01:00
Holger Hans Peter Freyther 15bb1a2a51 misc: Change the logging for the tbf and what to log
TLLIs got printed as TBF. Fix that but also rename things to
TFI. The TFI is not required to be unique per BTS but it is
the indicator we use right now.
2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 5da2014f13 bts: Use Packet_Downlink_Ack_Nack_t as parameter 2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 7a344716a6 bts: Simplify the code and use Packet_Resource_Request_t* 2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther cb5c49b581 bts: Work with the Packet_Measurement_Report_t 2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 750ca67ce9 bts: Move the MT_PACKET_MEASUREMENT_REPORT handling to a new method 2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 842808848c bts: Move handling of MT_PACKET_RESOURCE_REQUEST to a method
Move the code to a new method
2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 5a9658168a bts: Move handling of MT_PACKET_DOWNLINK_ACK_NACK to separate function
Kill the tlli assignment as it is never used.
2013-10-30 21:24:12 +01:00
Holger Hans Peter Freyther 396f4161cb pdch: Move handling of control_ack to a separate method
Kill the unused tfi parameter
2013-10-30 21:24:12 +01:00