aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2016-01-11 09:58:11 +0100
committerJacob Erlbeck <jerlbeck@sysmocom.de>2016-02-05 13:26:33 +0100
commitfc1b3e6c9076ddc38e07715b2cc30319bac19b9c (patch)
treeb7d6086f12afc017750e358ed68977c7519fc8d7
parentf2ba4cbf51ba5ec4183a9153ba2ce51df9050881 (diff)
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
-rw-r--r--src/bts.cpp6
-rw-r--r--src/gprs_coding_scheme.cpp20
-rw-r--r--src/gprs_coding_scheme.h2
-rw-r--r--src/tbf.h2
-rw-r--r--src/tbf_dl.cpp2
-rw-r--r--src/tbf_ul.cpp2
-rw-r--r--tests/edge/EdgeTest.cpp8
7 files changed, 30 insertions, 12 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index 1ef735b4..18bee665 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1138,7 +1138,7 @@ int gprs_rlcmac_pdch::rcv_block(uint8_t *data, uint8_t len, uint32_t fn,
}
LOGP(DRLCMACUL, LOGL_DEBUG, "Got RLC block, coding scheme: %s, "
- "length: %d (%d))\n", cs.name(), len, cs.maxBytesUL());
+ "length: %d (%d))\n", cs.name(), len, cs.usedSizeUL());
if (cs.isGprs())
return rcv_block_gprs(data, fn, meas, cs);
@@ -1158,7 +1158,7 @@ int gprs_rlcmac_pdch::rcv_data_block(uint8_t *data, uint32_t fn,
int rc;
struct gprs_rlc_data_info rlc_dec;
struct gprs_rlcmac_ul_tbf *tbf;
- unsigned len = cs.maxBytesUL();
+ unsigned len = cs.sizeUL();
/* These are always data blocks, since EGPRS still uses CS-1 for
* control blocks (see 44.060, section 10.3, 1st par.)
@@ -1208,7 +1208,7 @@ int gprs_rlcmac_pdch::rcv_data_block(uint8_t *data, uint32_t fn,
return 0;
}
- return tbf->rcv_data_block_acknowledged(&rlc_dec, data, len, meas);
+ return tbf->rcv_data_block_acknowledged(&rlc_dec, data, meas);
}
int gprs_rlcmac_pdch::rcv_block_gprs(uint8_t *data, uint32_t fn,
diff --git a/src/gprs_coding_scheme.cpp b/src/gprs_coding_scheme.cpp
index 4ba55c30..629ba4a0 100644
--- a/src/gprs_coding_scheme.cpp
+++ b/src/gprs_coding_scheme.cpp
@@ -73,7 +73,15 @@ GprsCodingScheme GprsCodingScheme::getBySizeUL(unsigned size)
unsigned int GprsCodingScheme::sizeUL() const
{
- return maxBytesUL() + (spareBitsUL() ? 1 : 0);
+ return mcs_info[m_scheme].uplink.bytes + (spareBitsUL() ? 1 : 0);
+}
+
+unsigned int GprsCodingScheme::usedSizeUL() const
+{
+ if (mcs_info[m_scheme].data_hdr == HEADER_GPRS_DATA)
+ return mcs_info[m_scheme].uplink.bytes;
+ else
+ return sizeUL();
}
unsigned int GprsCodingScheme::maxBytesUL() const
@@ -88,7 +96,15 @@ unsigned int GprsCodingScheme::spareBitsUL() const
unsigned int GprsCodingScheme::sizeDL() const
{
- return maxBytesDL() + (spareBitsDL() ? 1 : 0);
+ return mcs_info[m_scheme].downlink.bytes + (spareBitsDL() ? 1 : 0);
+}
+
+unsigned int GprsCodingScheme::usedSizeDL() const
+{
+ if (mcs_info[m_scheme].data_hdr == HEADER_GPRS_DATA)
+ return mcs_info[m_scheme].downlink.bytes;
+ else
+ return sizeDL();
}
unsigned int GprsCodingScheme::maxBytesDL() const
diff --git a/src/gprs_coding_scheme.h b/src/gprs_coding_scheme.h
index c26d12a7..854deb67 100644
--- a/src/gprs_coding_scheme.h
+++ b/src/gprs_coding_scheme.h
@@ -72,6 +72,8 @@ public:
unsigned int sizeUL() const;
unsigned int sizeDL() const;
+ unsigned int usedSizeUL() const;
+ unsigned int usedSizeDL() const;
unsigned int maxBytesUL() const;
unsigned int maxBytesDL() const;
unsigned int spareBitsUL() const;
diff --git a/src/tbf.h b/src/tbf.h
index c0fee0e9..7c3fba8d 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -414,7 +414,7 @@ struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf {
/* blocks were acked */
int rcv_data_block_acknowledged(
const struct gprs_rlc_data_info *rlc,
- uint8_t *data, uint8_t len, struct pcu_l1_meas *meas);
+ uint8_t *data, struct pcu_l1_meas *meas);
/* TODO: extract LLC class? */
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 73d8a3bc..ac1c253f 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -441,7 +441,7 @@ struct msgb *gprs_rlcmac_dl_tbf::create_new_bsn(const uint32_t fn, const uint8_t
/* total length of block, including spare bits */
const uint8_t block_length = cs.sizeDL();
- /* length of usable data of block, w/o spare bits, inc. MAC */
+ /* length of usable data of block, w/o spare bits (GPRS), inc. MAC */
const uint8_t block_data_len = cs.maxBytesDL();
/* now we still have untransmitted LLC data, so we fill mac block */
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index e81cd4bd..1d0b1681 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -138,7 +138,7 @@ struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn)
int gprs_rlcmac_ul_tbf::rcv_data_block_acknowledged(
const struct gprs_rlc_data_info *rlc,
- uint8_t *data, uint8_t len, struct pcu_l1_meas *meas)
+ uint8_t *data, struct pcu_l1_meas *meas)
{
int8_t rssi = meas->have_rssi ? meas->rssi : 0;
diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp
index dffd009d..b26262ca 100644
--- a/tests/edge/EdgeTest.cpp
+++ b/tests/edge/EdgeTest.cpp
@@ -49,15 +49,15 @@ static void check_coding_scheme(GprsCodingScheme& cs, GprsCodingScheme::Mode mod
OSMO_ASSERT(cs.isCompatible(mode));
/* Check static getBySizeUL() */
- expected_size = cs.maxBytesUL();
- if (cs.spareBitsUL() > 0)
+ expected_size = cs.usedSizeUL();
+ if (cs.spareBitsUL() > 0 && cs.isGprs())
expected_size += 1;
OSMO_ASSERT(expected_size == cs.sizeUL());
OSMO_ASSERT(cs == GprsCodingScheme::getBySizeUL(expected_size));
/* Check static sizeUL() */
- expected_size = cs.maxBytesDL();
- if (cs.spareBitsDL() > 0)
+ expected_size = cs.usedSizeDL();
+ if (cs.spareBitsDL() > 0 && cs.isGprs())
expected_size += 1;
OSMO_ASSERT(expected_size == cs.sizeDL());