Commit Graph

82 Commits

Author SHA1 Message Date
Pau Espin ff33597e4b Split rlc_{dl_,ul_,}window out of rlc.{h,cpp}
This new structure was already used when porting existing osmo-pcu code
to libosmo-gprs-rlcmac, and proved to be much more clear.
It makes no sense to keep both ul and dl window code mixed, since the
code base is mostly different between them, and the developer usually is
only interested in reading/debugging one side at a time.

Change-Id: If21b6f48ef190a718502389cbfde8cbdfc8d7f7a
2023-07-26 16:55:22 +02:00
Pau Espin 61f64c39a0 gprs_rlc_ul_window: Make sure V(N) array is cleared during reset_state()
Otherwise unit tests (the only real used of that API so far) would end
up with v_r and v_q variables reset, but with previous state in v_n
array, which is not good.

Let's make sure everything is reset in
gprs_rlc_ul_window::reset_state(), and simply call that method during
constructor time.

Change-Id: I007b672527664b05353077b9208722056799f43f
2023-07-25 18:05:50 +02:00
Oliver Smith 83ee452ddb Run struct_endianness.py
Ensure there is no diff to prepare to run this in CI.

Related: OS#5884
Change-Id: I1c82acd09497371938a2d9ae12a80382d20189ff
2023-02-20 10:50:17 +01:00
Pau Espin 08523c2286 rlc.h: Fix typo in param name
The function definition in rlc.cpp already uses the correct param name.

Change-Id: Ifd55fca3c04b72cef3a8f27d6826bc8529e85ec7
2023-02-01 19:51:42 +01:00
Oliver Smith 8d03c50024 treewide: remove FSF address
Remove the paragraph about writing to the Free Software Foundation's
mailing address. The FSF has changed addresses in the past, and may do
so again. In 2021 this is not useful, let's rather have a bit less
boilerplate at the start of source files.

Change-Id: I4a49dbeeec89b22624c968152118aecf8886dac6
2021-12-14 12:19:13 +01:00
Pau Espin 55aca83098 rlc.h: Fix struct bit fields on big endian systems
Related: OS#5003
Change-Id: I534539cdf197ce5c038752a177aff7efeefc9883
2021-02-04 12:59:40 +01:00
Pau Espin Pedrol 05be90367a Update TS 04.60 references to new TS 44.060
Change-Id: Ib7c3a74b502b2251da2f7b9d6d711f3e32133bc3
2021-02-01 13:06:45 +01:00
Pau Espin 8a35e640a3 Convert gprs_bssgp_pcu.cpp to C
There's no real use of C++ in that file, and it causes problems when
using llist_head entry macros in future patches adding initial support
for multiple BTS in PCU object, so let's move it to plain C.

Change-Id: Ic771a89fd78b5e66151a5384f0ff6a8895589466
2021-01-19 16:28:13 +01:00
Pau Espin 2182e627cd Unify BTS into a C usable structure
Previous work on BTS class started to get stuff out of the C++ struct
 into a C struct (BTS -> struct gprs_glcmac_bts) so that some parts of
it were accessible from C code. Doing so, however, ended up being messy
too, since all code needs to be switching from one object to another,
which actually refer to the same logical component.

Let's instead rejoin the structures and make sure the struct is
accessible and usable from both C and C++ code by rewriting all methods
to be C compatible and converting 3 allocated suboject as pointers.
This way BTS can internally still use those C++ objects while providing
a clean APi to both C and C++ code.

Change-Id: I7d12c896c5ded659ca9d3bff4cf3a3fc857db9dd
2021-01-19 16:28:10 +01:00
Pau Espin 2ae8337669 Get rid of class GprsCodingScheme
We have same kind of object splitted into two layers, in coding_scheme
and gprs_coding_scheme. Let's merge them together and get rid of the
class, which is not really useful because it's only a set of functions
operating on one enum value.

This change also fixes gcc 10.1.0 error about memseting a complex type
in rlc.h init().

Change-Id: Ie9ce2144ba9e8dbba9704d4e0000a2929e3e41df
2020-05-20 11:07:07 +00:00
Pau Espin 5bb87b83d1 rlc: Move prepare() function out of gprs_rlc_data struct
Newer gcc 10.1.0 is erroring due to memset being applied on a complex
type, so let's start by removing this only function outside of the
struct.

Change-Id: I20426557d9b3049ab275fadb92e10ea8a860a119
2020-05-18 11:07:03 +02:00
Pau Espin c68e97012c rlc: Drop unused function gprs_rlc_data::put_data
Change-Id: I10eb93a1aa6ac1eac15c8e64da300caf2e6ccc44
2020-05-18 11:07:03 +02:00
Pau Espin 0b0748a4be tbf: Fix memset(0) on object with no trivial copy-assignment
As warned by gcc 8.1.0:
osmo-pcu/src/tbf.cpp: In constructor ‘gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS*, gprs_rlcmac_tbf_direction)’:
osmo-pcu/src/tbf.cpp:222:33: error: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct gprs_rlc’ with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess]
  memset(&m_rlc, 0, sizeof(m_rlc));
                                 ^
In file included from osmo-pcu/src/tbf.h:24,
                 from osmo-pcu/src/bts.h:37,
                 from osmo-pcu/src/tbf.cpp:22:
osmo-pcu/src/rlc.h:234:8: note: ‘struct gprs_rlc’ declared here
 struct gprs_rlc {
        ^~~~~~~~

Change-Id: Ifb0529b9ae6cd4300e5cbbd9151054792edbfe06
2018-05-16 15:20:43 +02:00
Max d81b3bf360 Set V_N and V_B to known initial state
Reset V_N and V_B in UL/DL window class constructors to make sure we
always start from known initial state.

Related: OS#1759
Change-Id: I8e14ffa913b49c5394229220de9165cdfaabdf19
Fixes: CID70468, CID70469.
2018-01-17 15:57:26 +00:00
Max 2617bf2016 TBF-UL: add simpler test helper
Add function to set both V_R and V_Q values to 0 which is useful for TBF
test.
Related: OS#1759
Change-Id: I719abfbd5b88c694cbbd69d5c4dcb42baaca91b2
2018-01-12 14:26:28 +00:00
Max b3a17d6074 cosmetic: clarify coding scheme and puncturing
* use appropriate types for coding scheme parameters
* add comment regarding possible number of RLCMAC blocks

The code in create_dl_acked_block() has underlying assumption that
rlc.num_data_blocks can never be more than 2, which is true and is
enforced by appropriate asserts but is not obvious when looking at the
function code alone. It's equally hard for Coverity which leads to false
positives in scan.

Lets' make this assumption explicit by putting it into for(;;) condition
alongside with corresponding comment.

Fixes: CID143070
Change-Id: If599a6c8a6ef56d847604fcf41bb71decccd8a78
2018-01-04 16:35:55 +00:00
Max ef784e4e9e Remove unused includes and forward declarations
Change-Id: I59da04edd1b8ff965bbfbe00ccae1f7c9b6e5301
2017-12-18 22:05:22 +00:00
Max ead08aae35 DL window: constify resend_needed() function
It doesn't change any state so mark it as const.

Change-Id: I5d672bfd654198aebb187772de464c52b3209435
2017-12-13 18:25:36 +01:00
sivasankari 1d8744ce96 Add test case for testing PUAN
This test case is for testing generation of
EGPRS PUAN. Corresponding log files .ok and .err
are modified.

Change-Id: I18e6d4a9e90fd6453fe14187beab27dfeae8dbe9
2017-01-24 15:53:35 +05:30
sivasankari 8adfcd06a1 Add compression support in EGPRS PUAN
This adds compression of bitmap in PUAN. The compressed bitmap
is used only if the number of bits in the bitmap does not fit in
the message and there is a gain after compression.
The algorithm is part of libosmocore and so there is dependency
on the libosmocore for compilation.
The algorithm is tested on integration setup by forcing compression.

Change-Id: Id2eec4b5eb6da0ebd24054b541b09b700b9b40ba
2017-01-23 12:26:09 +00:00
aravind sirsikar 9434e52af9 Modify return type of gprs_rlc_dl_window::distance to uint16_t
Since there is a "&mod_sns()" present in this function, the outcome
is always unsigned.

Change-Id: I66f3db4dc27a6cbef146c832bf8b43f1492358a4
2016-11-02 15:43:10 +05:30
Aravind Sirsikar 50b097003b Modify EGPRS DL TBF flow to support SPB
Modify the EGPRS DL TBF flow to support Split block during
Retx. This patch will also Upgrade the test suite with test cases
to validate the EGPRS Downlink SPB for Retransmission

Scenarios like MCS6->MCS3, MCS4->MCS1, MCS5->MCS2, MCS9->MCS3
MCS7->MCS2, MCS8->MCS3 have been simulated and Integration tested
in NuRAN 1.0 hardware thoroughly.

Change-Id: I242afdd8ae7622dec8593b26382ad66bad5b9516
2016-08-25 10:41:33 +00:00
Aravind Sirsikar e6cadb4e3c Add data structure to handle SPB for EGPRS DL
Modify the header files with necessary data structure to handle
Split block for EGPRS DL TBF.

The EGPRS resegmentation feature allows PCU to retransmit
RLC blocks of HeaderType1, HeaderType2 by segmenting
them to 2 HeaderType3 blocks(Example MCS5 will be
retransmitted as 2 MCS2 blocks). Table 10.4.8b.2 of 44.060
explains the possible values of SPB in HeadrType3 for DL
direction. The PCU decides to retransmit the
blocks by resegmenting it based on Table 8.1.1.1 of 44.060.
The retransmission MCS is calculated based on current MCS of
the Block and demanded MCS by PCU. Section 10.3a.3.3 of 44.060
shows the HeadrType3 with SPB field present in it

Change-Id: I57673e53a9da2affa7e8aaa6551ac4b271c3d525
2016-08-25 10:34:00 +00:00
Aravind Sirsikar 36bdc5f7a4 Add data structure for SPB in EGPRS UL
Modify header files with data structures required
to support split blocks for EGPRS UL TBF

This feature provides provision for MS to retransmit
RLC blocks of HeaderType1, HeaderType2 by segmenting
them to 2 HeaderType3 blocks(Example MCS5 will be
retransmitted as 2 MCS2 blocks). Table 10.4.8b.1 of 44.060
explains the possible values of SPB in HeadrType3 for UL
direction. When the MCS is changed at the PCU, PCU directs the
changed MCS to MS by PUAN or UPLINK ASSIGNMENT message along
with RESEGMENT flag, Then MS may decide to retransmit the
blocks by resegmenting it based on Table 8.1.1.1 of 44.060.
The retransmission MCS is calculated based on current MCS of
the Block and demanded MCS by PCU. Section 10.3a.4.3 of 44.060
shows the HeadrType3 with SPB field present in it.

Change-Id: I83ccd136bb361adcfd511c57c5a9d95ed72c36c2
2016-08-02 06:58:57 +00:00
Tom Tsou df69809b82 egprs: Use RLC/MAC headers from libosmocore
EGPRS Type 1, 2, and 3 headers are used by OsmoPCU and OsmoBTS.
Move the header definitions to libosmocore to be shared by both
packages.

Modify the struct variable naming to use *_hi/*_lo instead of
*_a/*_b in order to be consistent with existing naming used in
libosmocore.

Change-Id: I98687ad981d27502aec42729611937ba1caf207c
2016-07-14 06:56:19 +00:00
Aravind Sirsikar 914955209e Add data structure for ARQ-II in EGPRS DL
Modify the existing data structure to support ARQ-II for Retx in EGPRS DL.
This will also hadle compilation issue related to renaming the variable.

Change-Id: I734b1024bb32f2daa43af4adf59f4a17f2294afe
2016-07-12 14:17:12 +05:30
Alexander Couzens 68e2c6375e rlc.h: correct gprs_rlc_data comment
It's the block data, not the history.
Also add including LI headers.

Change-Id: Id4d99d1d21c7fa372771fd569d87bbcf2c6b6d22
Reviewed-on: https://gerrit.osmocom.org/144
Reviewed-by: Harald Welte <laforge@gnumonks.org>
Tested-by: Jenkins Builder
2016-06-01 13:38:28 +00:00
Alexander Couzens c1c9d6a9d8 rlc.h: remove duplicated define RLC_EGPRS_SNS
The second #define RLC_EGPRS_SNS is 3 lines below of the first one.

Change-Id: Ibb718ba9be21831c56c5949e730fab5acd691d7c
Reviewed-on: https://gerrit.osmocom.org/107
Tested-by: Jenkins Builder
Reviewed-by: Holger Freyther <holger@freyther.de>
2016-05-25 19:44:29 +00:00
Aravind Sirsikar 7952282b78 Support puncturing scheme selection for EGPRS DL
Adds support to find the puncturing scheme for retransmission
with MCS change, retransmission with no MCS change, transmission
case. Puncturing scheme selection for retransmission case with
MCS change is aligned with TS 44.060 9.3.2.1. Puncturing scheme
selection for retransmission without MCS change, fresh transmission
is aligned with TS 44.060 10.4.8a.3.1, 10.4.8a.2.1, 10.4.8a.1.1
2016-03-30 22:02:48 +02:00
Aravind Sirsikar a859a21800 Update CPS calculation with new data structures
Update existing CPS calculation function to align with new data
structure introduced
2016-03-30 22:02:47 +02:00
Aravind Sirsikar 7a05b039c8 Add data structure for CPS calculation in DL
Define new data structure with respect to TS 44.060
10.4.8a.3.1, 10.4.8a.2.1, 10.4.8a.1.1 for puncturing scheme values
and initialize the variable introduced
2016-03-30 22:02:47 +02:00
Aravind Sirsikar 5a5d2b7a27 Introduce EGPRS header type1 and type2 in UL
Defines new structures for UL EGPRS header type1 and type2 for
supporting MCS5-MCS9
2016-03-16 15:02:54 +01:00
Jacob Erlbeck d6752491e1 edge: Send a second BSN block in an RLC message if possible
Currently only one BSN block is encoded in each RLC data message,
even if MSC7-9 are used, which transport two independant (except for a
max BSN delta of 512) BSN blocks. In that case, the same block is
just put twice into the same message.

The current create_dl_acked_block(fn, ts) method handles
block selection (resend, new BSN, dummy block, ...) and restart
handling in one method and is too complex to extend it accordingly.

Therefore this commit move the block selection/creation handling into
a new method (take_next_bsn) which delivers the next BSN along with a
hint, whether it may be combined with another block. In that case,
the function can be called a second time (this time with a valid
previous BSN, that's the one returned by the first call) to get the
second BSN. The real block generation method
create_dl_acked_block(fn, ts, index, index2) is then called with both
BSNs as indices (the second must be -1, if there is only one BSN).

Note that every BSN returned by take_next_bsn should be passed to
create_dl_acked_block to avoid state inconsistencies.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:40 +01:00
Jacob Erlbeck fbd82e4e9f rlc: Add gprs_rlc_mcs_cps_decode
To access EGPRS data blocks, the optional padding must be taken into
account. Whether padding has been used must be dervied from the CPS
field in the header of the RLC EGPRS data message.

Add this function to decode the CPS value and extract that
information.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:39 +01:00
Jacob Erlbeck b55f313735 rlc: Add with_padding argument to gprs_rlc_data_info_init_dl/ul
The offsets of the data areas change when padding is used (see TS
44.060, 9.3.2.1 and Annex J for details).

Extend the parameter lists to pass the with_padding flag and use
that information to compute the correct offsets.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:39 +01:00
Jacob Erlbeck 9e8593917f rlc: Support encoding of EGPRS header type 1 + 2
Currently only header type 3 (MCS-1 to MCS-4) is supported.

Add header structs to rlc.h and extend
Encoding::rlc_write_dl_data_header accordingly.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:39 +01:00
Jacob Erlbeck db88380b76 rlc: Add unified gprs_rlc_window parent class
Currently gprs_rlc_ul_window and gprs_rlc_dl_window are completely
separate classes, containing several identical members and methods.

This commit add a shared parent class containing WS and SNS handling.

Sponsored-by: On-Waves ehf
2016-02-08 00:45:35 +01:00
Jacob Erlbeck eb08f86c02 edge: Add bitvec based DL window updating methods
The current methods are based on the GRPS specific RBB and SSN values
and formats which are not compatible with EGPRS.

Add a second set of similar methods with the same semantics but
which are based on a bitvec and the first BSN instead.

The following methods are affected:

- gprs_rlc_dl_window::update
- gprs_rlcmac_dl_tbf::rcvd_dl_ack
- gprs_rlcmac_dl_tbf::update_window

Sponsored-by: On-Waves ehf
2016-02-08 00:45:34 +01:00
Jacob Erlbeck 70955c765c edge: Provide and use CS -> CPS conversion
The MS' RLC receiver needs a valid CPS field to decode the block.

Add the function gprs_rlc_mcs_cps to generate the CPS value based on
coding scheme, puncturing, and padding.

Sponsored-by: On-Waves ehf
2016-02-05 18:27:10 +01:00
Jacob Erlbeck f0e403911d edge: Add encoder for downlink RLC data blocks
Currently the (GPRS) RLC block encoding is done by setting the
header fields directly in gprs_rlcmac_dl_tbf::create_new_bsn.
This is much more complex with EGPRS, since the data fields are
not byte aligned, the header formats depend on the header type,
and the mapping of bits to bytes is LSB first.

This commit adds Encoding::rlc_write_dl_data_header which writes
the header according to the given gprs_rlc_data_header structure.
Encoding::rlc_copy_from_aligned_buffer is also added to copy
byte sequences into the message.

Note that the actual encoding of data units is not yet present.

Sponsored-by: On-Waves ehf
2016-02-05 13:26:34 +01:00
Jacob Erlbeck 6e9f9c20e9 edge: Add init functions for gprs_rlc_data_info
Add the functions gprs_rlc_data_info_init_dl/ul which initialise a
gprs_rlc_data_info structure depending on the coding scheme. The
fields num_data_blocks, data_offs_bits, cs, and the data_blocks are
valid after this call. The other fields are set to 0.

The data blocks are initialised to the correct data_len, e == 1
(no extension header field), cv == 15 (not a final block). The other
data block fields are set to 0.

The gprs_rlc_data_block_info can also be initialised separately
by using the gprs_rlc_data_block_info_init function.

Sponsored-by: On-Waves ehf
2016-02-05 13:26:34 +01:00
Jacob Erlbeck cc34a5b43f rlc: Add info fields for downlink
This commit extends gprs_rlc_data_info and gprs_rlc_data_block_info
by the fields required for downlink RLC data messages.

Sponsored-by: On-Waves ehf
2016-02-05 13:26:34 +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 8f8197f3fd rlc: Make WS and SNS variable
Currently the values for WS and SNS are fixed to 64 (WS) and 128
(SNS) which are the only values that can be used with GPRS. On the
other hand, EGPRS requires an SNS of 2014 and a WS in the range of
64 to 1024.

This commit adds member variables and setters to both window
classes. By default, the GPRS values are being used.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:12 +01:00
Jacob Erlbeck a3a567e765 rlc: Add constructor to window classes
Currently the gprs_rlc_dl_window and gprs_rlc_ul_window do not have
constructors, but need to get initialized explicitly.

This commit adds constructors to both classes and removes explicit
external initialization code.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:12 +01:00
Jacob Erlbeck e1ca87f057 rlc/edge: Consistently use uint16_t for BSNs and SSNs
Currently in some places uint8_t is being used to encode BSNs and
SSNs. This is inconsistent and (even worse) not enough for EPGRS
which uses an SNS of 2014.

This commit changes these to uint16_t.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:12 +01:00
Jacob Erlbeck 93c55d04e5 rlc: Add and use mod_sns(bsn) method
Currently there is only a mod_sns() method which is being used in
expression like bsn_expr & win.mod_sns(). This only works, because
it is known that mod_sns() is (sns() - 1) where sns() in turn is
always 2^n. This is error prone, hard to read, and relies on window
specifics that should be kept inside the respective module.

This commit adds a mod_sns(uint bsn) method to gprs_rlc_ul_window and
gprs_rlc_dl_window, that encapsulates and hides this optimized
computation.

Sponsored-by: On-Waves ehf
2016-02-01 13:58:12 +01:00
Jacob Erlbeck b3100e187b edge: Add methods for unified GPRS/EGPRS UL data block handling
The current rcv_data_block_acknowledged_gprs method is tightly
coupled to GPRS.

This commit adds variants of the involved methods that support
EGPRS and GPRS RLC encodings likewise.

Sponsored-by: On-Waves ehf
2015-12-16 19:55:18 +01:00
Jacob Erlbeck ce1beb423c edge: Store GprsCodingScheme in gprs_rlc_data
Currently the coding scene is stored as number N, where there scheme
is CS-N.

This commit replaces this by a GprsCodingScheme type cs value. The
gprs_rlcmac_cs table is no longer needed and thus removed.

Sponsored-by: On-Waves ehf
2015-12-16 19:37:08 +01:00