aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-03 18:28:04 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-03 19:23:49 +0100
commitfc6d572c07df78de6066e376e88dfbcee2a62cf9 (patch)
treeed32fecbf0d2bd6d88cafae7d884ad12d85d3e1f
parent6c273dc8e7b020856062aa0d6d8ba5f56638d9d4 (diff)
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
-rw-r--r--src/rlc.cpp27
-rw-r--r--src/rlc.h7
-rw-r--r--tests/edge/EdgeTest.cpp36
3 files changed, 40 insertions, 30 deletions
diff --git a/src/rlc.cpp b/src/rlc.cpp
index efe4261..ca12e91 100644
--- a/src/rlc.cpp
+++ b/src/rlc.cpp
@@ -282,43 +282,52 @@ bool gprs_rlc_ul_window::invalidate_bsn(const uint16_t bsn)
}
static void gprs_rlc_data_header_init(struct gprs_rlc_data_info *rlc,
- GprsCodingScheme cs, unsigned int header_bits)
+ GprsCodingScheme cs, bool with_padding, unsigned int header_bits)
{
unsigned int i;
+ unsigned int padding_bits = with_padding ? cs.optionalPaddingBits() : 0;
memset(rlc, 0, sizeof(*rlc));
rlc->cs = cs;
+ rlc->with_padding = with_padding;
rlc->num_data_blocks = cs.numDataBlocks();
OSMO_ASSERT(rlc->num_data_blocks <= ARRAY_SIZE(rlc->block_info));
for (i = 0; i < rlc->num_data_blocks; i++) {
- gprs_rlc_data_block_info_init(&rlc->block_info[i], cs);
+ gprs_rlc_data_block_info_init(&rlc->block_info[i], cs,
+ with_padding);
rlc->data_offs_bits[i] =
- header_bits +
+ header_bits + padding_bits +
(i+1) * cs.numDataBlockHeaderBits() +
i * 8 * rlc->block_info[0].data_len;
}
}
void gprs_rlc_data_info_init_dl(struct gprs_rlc_data_info *rlc,
- GprsCodingScheme cs)
+ GprsCodingScheme cs, bool with_padding)
{
- return gprs_rlc_data_header_init(rlc, cs, cs.numDataHeaderBitsDL());
+ return gprs_rlc_data_header_init(rlc, cs, with_padding,
+ cs.numDataHeaderBitsDL());
}
void gprs_rlc_data_info_init_ul(struct gprs_rlc_data_info *rlc,
- GprsCodingScheme cs)
+ GprsCodingScheme cs, bool with_padding)
{
- return gprs_rlc_data_header_init(rlc, cs, cs.numDataHeaderBitsUL());
+ return gprs_rlc_data_header_init(rlc, cs, with_padding,
+ cs.numDataHeaderBitsUL());
}
void gprs_rlc_data_block_info_init(struct gprs_rlc_data_block_info *rdbi,
- GprsCodingScheme cs)
+ GprsCodingScheme cs, bool with_padding)
{
- rdbi->data_len = cs.maxDataBlockBytes();
+ unsigned int data_len = cs.maxDataBlockBytes();
+ if (with_padding)
+ data_len -= cs.optionalPaddingBits() / 8;
+
+ rdbi->data_len = data_len;
rdbi->bsn = 0;
rdbi->ti = 0;
rdbi->e = 1;
diff --git a/src/rlc.h b/src/rlc.h
index fcf01ff..dcb1877 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -84,6 +84,7 @@ struct gprs_rlc_data_info {
unsigned int rrbp;
unsigned int pr;
unsigned int num_data_blocks;
+ unsigned int with_padding;
unsigned int data_offs_bits[2];
struct gprs_rlc_data_block_info block_info[2];
};
@@ -102,11 +103,11 @@ struct gprs_rlc_data {
};
void gprs_rlc_data_info_init_dl(struct gprs_rlc_data_info *rlc,
- GprsCodingScheme cs);
+ GprsCodingScheme cs, bool with_padding);
void gprs_rlc_data_info_init_ul(struct gprs_rlc_data_info *rlc,
- GprsCodingScheme cs);
+ GprsCodingScheme cs, bool with_padding);
void gprs_rlc_data_block_info_init(struct gprs_rlc_data_block_info *rdbi,
- GprsCodingScheme cs);
+ GprsCodingScheme cs, bool with_padding);
unsigned int gprs_rlc_mcs_cps(GprsCodingScheme cs, int punct, int punct2,
int with_padding);
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index 39875b0..160a542 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -542,7 +542,7 @@ static void test_rlc_unit_encoder()
/* TS 44.060, B.1 */
cs = GprsCodingScheme::CS4;
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -589,7 +589,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::CS1;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -609,7 +609,7 @@ static void test_rlc_unit_encoder()
OSMO_ASSERT(data[1] == 0);
/* Block 2 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -642,7 +642,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::CS1;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -677,7 +677,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::CS1;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -700,7 +700,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::CS1;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -723,7 +723,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::CS1;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -742,7 +742,7 @@ static void test_rlc_unit_encoder()
OSMO_ASSERT(data[0] == 0);
/* Block 2 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -775,7 +775,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::MCS4;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -827,7 +827,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::MCS2;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -859,7 +859,7 @@ static void test_rlc_unit_encoder()
OSMO_ASSERT(data[1] == 0);
/* Block 2 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -904,7 +904,7 @@ static void test_rlc_unit_encoder()
OSMO_ASSERT(data[3] == 0);
/* Block 3 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -944,7 +944,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::MCS2;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -968,7 +968,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::MCS2;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -993,7 +993,7 @@ static void test_rlc_unit_encoder()
cs = GprsCodingScheme::MCS2;
/* Block 1 */
- gprs_rlc_data_block_info_init(&rdbi, cs);
+ gprs_rlc_data_block_info_init(&rdbi, cs, false);
num_chunks = 0;
write_offset = 0;
memset(data, 0, sizeof(data));
@@ -1045,7 +1045,7 @@ static void test_rlc_unaligned_copy()
block_idx++)
{
struct gprs_rlc_data_info rlc;
- gprs_rlc_data_info_init_dl(&rlc, cs);
+ gprs_rlc_data_info_init_dl(&rlc, cs, false);
memset(bits, pattern, sizeof(bits));
Decoding::rlc_copy_to_aligned_buffer(
@@ -1089,12 +1089,12 @@ static void test_rlc_info_init()
struct gprs_rlc_data_info rlc;
printf("=== start %s ===\n", __func__);
- gprs_rlc_data_info_init_dl(&rlc, GprsCodingScheme(GprsCodingScheme::CS1));
+ gprs_rlc_data_info_init_dl(&rlc, GprsCodingScheme(GprsCodingScheme::CS1), false);
OSMO_ASSERT(rlc.num_data_blocks == 1);
OSMO_ASSERT(rlc.data_offs_bits[0] == 24);
OSMO_ASSERT(rlc.block_info[0].data_len == 20);
- gprs_rlc_data_info_init_dl(&rlc, GprsCodingScheme(GprsCodingScheme::MCS1));
+ gprs_rlc_data_info_init_dl(&rlc, GprsCodingScheme(GprsCodingScheme::MCS1), false);
OSMO_ASSERT(rlc.num_data_blocks == 1);
OSMO_ASSERT(rlc.data_offs_bits[0] == 33);
OSMO_ASSERT(rlc.block_info[0].data_len == 22);