aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2016-01-13 10:51:25 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-05 13:46:21 +0100
commit5058bd6e9e8335ca5cd8ad586de3843447c859bf (patch)
treedcbd39ff0c1904b3b6d70d0a682dd3804aeff517
parentfec94d1c5c57e328e27a9b0208706a0a54d3da56 (diff)
edge: Select implementation by mode in rlc_data_to_dl_append
Currently the GPRS data block encoding is applied to every coding scheme, even if an MCS is selected. This commit renames the actual encoding function to rlc_data_to_dl_append_gprs (not exported) and puts selection code into Encoding::rlc_data_to_dl_append. This requires an additional cs argument. Sponsored-by: On-Waves ehf
-rw-r--r--src/encoding.cpp30
-rw-r--r--src/encoding.h3
-rw-r--r--src/tbf_dl.cpp2
-rw-r--r--tests/edge/EdgeTest.cpp26
4 files changed, 39 insertions, 22 deletions
diff --git a/src/encoding.cpp b/src/encoding.cpp
index eb424cb..4c0ecf9 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -752,7 +752,7 @@ unsigned int Encoding::rlc_copy_from_aligned_buffer(
return rdbi->data_len;
}
-Encoding::AppendResult Encoding::rlc_data_to_dl_append(
+static Encoding::AppendResult rlc_data_to_dl_append_gprs(
struct gprs_rlc_data_block_info *rdbi,
gprs_llc *llc, int *offset, int *num_chunks,
uint8_t *data_block,
@@ -784,7 +784,7 @@ Encoding::AppendResult Encoding::rlc_data_to_dl_append(
/* return data block as message */
*offset = rdbi->data_len;
(*num_chunks)++;
- return AR_NEED_MORE_BLOCKS;
+ return Encoding::AR_NEED_MORE_BLOCKS;
}
/* if FINAL chunk would fit precisely in space left */
if (chunk == space && is_final)
@@ -801,7 +801,7 @@ Encoding::AppendResult Encoding::rlc_data_to_dl_append(
*offset = rdbi->data_len;
(*num_chunks)++;
rdbi->cv = 0;
- return AR_COMPLETED_BLOCK_FILLED;
+ return Encoding::AR_COMPLETED_BLOCK_FILLED;
}
/* if chunk would fit exactly in space left */
if (chunk == space) {
@@ -828,7 +828,7 @@ Encoding::AppendResult Encoding::rlc_data_to_dl_append(
/* return data block as message */
*offset = rdbi->data_len;
(*num_chunks)++;
- return AR_NEED_MORE_BLOCKS;
+ return Encoding::AR_NEED_MORE_BLOCKS;
}
LOGP(DRLCMACDL, LOGL_DEBUG, "-- Chunk with length %d is less "
@@ -856,7 +856,7 @@ Encoding::AppendResult Encoding::rlc_data_to_dl_append(
/* if we have more data and we have space left */
if (space > 0 && !is_final) {
li->m = 1; /* we indicate more frames to follow */
- return AR_COMPLETED_SPACE_LEFT;
+ return Encoding::AR_COMPLETED_SPACE_LEFT;
}
/* if we don't have more LLC frames */
if (is_final) {
@@ -864,11 +864,27 @@ Encoding::AppendResult Encoding::rlc_data_to_dl_append(
"done.\n");
li->e = 1; /* we cannot extend */
rdbi->cv = 0;
- return AR_COMPLETED_BLOCK_FILLED;
+ return Encoding::AR_COMPLETED_BLOCK_FILLED;
}
/* we have no space left */
LOGP(DRLCMACDL, LOGL_DEBUG, "-- No space left, so we are "
"done.\n");
li->e = 1; /* we cannot extend */
- return AR_COMPLETED_BLOCK_FILLED;
+ return Encoding::AR_COMPLETED_BLOCK_FILLED;
+}
+
+Encoding::AppendResult Encoding::rlc_data_to_dl_append(
+ struct gprs_rlc_data_block_info *rdbi, GprsCodingScheme cs,
+ gprs_llc *llc, int *offset, int *num_chunks,
+ uint8_t *data_block,
+ bool is_final)
+{
+ if (cs.isGprs())
+ return rlc_data_to_dl_append_gprs(rdbi,
+ llc, offset, num_chunks, data_block, is_final);
+
+ LOGP(DRLCMACDL, LOGL_ERROR, "%s data block encoding not implemented\n",
+ cs.name());
+
+ return AR_NEED_MORE_BLOCKS;
}
diff --git a/src/encoding.h b/src/encoding.h
index 9b4b09e..4c35757 100644
--- a/src/encoding.h
+++ b/src/encoding.h
@@ -22,6 +22,7 @@
#include <stdint.h>
#include <gsm_rlcmac.h>
+#include <gprs_coding_scheme.h>
struct gprs_rlcmac_bts;
struct gprs_rlcmac_tbf;
@@ -86,7 +87,7 @@ public:
};
static AppendResult rlc_data_to_dl_append(
- struct gprs_rlc_data_block_info *rdbi,
+ struct gprs_rlc_data_block_info *rdbi, GprsCodingScheme cs,
gprs_llc *llc, int *offset, int *num_chunks,
uint8_t *data,
bool is_final);
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 35c3ccb..5607e9e 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -484,7 +484,7 @@ struct msgb *gprs_rlcmac_dl_tbf::create_new_bsn(const uint32_t fn, const uint8_t
is_final = llc_queue()->size() == 0 && !keep_open(fn);
- ar = Encoding::rlc_data_to_dl_append(rdbi,
+ ar = Encoding::rlc_data_to_dl_append(rdbi, cs,
&m_llc, &write_offset, &num_chunks, data, is_final);
if (ar == Encoding::AR_NEED_MORE_BLOCKS)
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index 70e99d5..c405b4b 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -509,7 +509,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 11);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT);
@@ -520,7 +520,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 26);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT);
@@ -531,7 +531,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 99);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS);
@@ -556,7 +556,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 20);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS);
@@ -575,7 +575,7 @@ static void test_rlc_unit_encoder()
OSMO_ASSERT(llc.chunk_size() == 1);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT);
@@ -586,7 +586,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 99);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS);
@@ -609,7 +609,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 7);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT);
@@ -620,7 +620,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 11);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_BLOCK_FILLED);
@@ -644,7 +644,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 99);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS);
@@ -667,7 +667,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 20);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, true);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_BLOCK_FILLED);
@@ -690,7 +690,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 30);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS);
@@ -708,7 +708,7 @@ static void test_rlc_unit_encoder()
OSMO_ASSERT(llc.chunk_size() == 10);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_COMPLETED_SPACE_LEFT);
@@ -719,7 +719,7 @@ static void test_rlc_unit_encoder()
llc.reset();
llc.put_frame(llc_data, 99);
- ar = Encoding::rlc_data_to_dl_append(&rdbi,
+ ar = Encoding::rlc_data_to_dl_append(&rdbi, cs,
&llc, &write_offset, &num_chunks, data, false);
OSMO_ASSERT(ar == Encoding::AR_NEED_MORE_BLOCKS);