[MERGED] libosmocore[master]: coding: Add BER-reporting RACH decode functions

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Feb 26 12:32:23 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: coding: Add BER-reporting RACH decode functions
......................................................................


coding: Add BER-reporting RACH decode functions

For all other decode operations we report the BER, but not for the
RACH.  This results in osmo-bts-trx not being able to report BER
to the higher layers, which is possible on other BTS backends.

Let's close this gap by introducing gsm0503_rach_ext_decode_ber()
and gsm0503_rach_decode_ber() with the usual n_errors / n_bits_total
arguments.

Change-Id: I2b1926a37bde860dcfeb0d613eb55a71271928c5
---
M include/osmocom/coding/gsm0503_coding.h
M src/coding/gsm0503_coding.c
M src/coding/libosmocoding.map
M tests/coding/coding_test.c
4 files changed, 54 insertions(+), 8 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/coding/gsm0503_coding.h b/include/osmocom/coding/gsm0503_coding.h
index 86610ba..98038f8 100644
--- a/include/osmocom/coding/gsm0503_coding.h
+++ b/include/osmocom/coding/gsm0503_coding.h
@@ -68,8 +68,14 @@
 int gsm0503_rach_ext_encode(ubit_t *burst, uint16_t ra, uint8_t bsic, bool is_11bit);
 int gsm0503_rach_encode(ubit_t *burst, const uint8_t *ra, uint8_t bsic) OSMO_DEPRECATED("Use gsm0503_rach_ext_encode() instead");
 
-int gsm0503_rach_decode(uint8_t *ra, const sbit_t *burst, uint8_t bsic);
-int gsm0503_rach_ext_decode(uint16_t *ra, const sbit_t *burst, uint8_t bsic);
+int gsm0503_rach_decode(uint8_t *ra, const sbit_t *burst, uint8_t bsic)
+	OSMO_DEPRECATED("Use gsm0503_rach_decode_ber() instead");
+int gsm0503_rach_decode_ber(uint8_t *ra, const sbit_t *burst, uint8_t bsic,
+			    int *n_errors, int *n_bits_total);
+int gsm0503_rach_ext_decode(uint16_t *ra, const sbit_t *burst, uint8_t bsic)
+	OSMO_DEPRECATED("Use gsm0503_rach_ext_decode_ber() instead");
+int gsm0503_rach_ext_decode_ber(uint16_t *ra, const sbit_t *burst, uint8_t bsic,
+				int *n_errors, int *n_bits_total);
 
 int gsm0503_sch_encode(ubit_t *burst, const uint8_t *sb_info);
 int gsm0503_sch_decode(uint8_t *sb_info, const sbit_t *burst);
diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c
index c94bca7..215cc6d 100644
--- a/src/coding/gsm0503_coding.c
+++ b/src/coding/gsm0503_coding.c
@@ -2826,13 +2826,15 @@
 		d[start + i] ^= ((bsic >> (5 - i)) & 1);
 }
 
-static inline int16_t rach_decode(const sbit_t *burst, uint8_t bsic, bool is_11bit)
+static inline int16_t rach_decode_ber(const sbit_t *burst, uint8_t bsic, bool is_11bit,
+				      int *n_errors, int *n_bits_total)
 {
 	ubit_t conv[17];
 	uint8_t ra[2] = { 0 }, nbits = is_11bit ? 11 : 8;
 	int rv;
 
-	osmo_conv_decode(is_11bit ? &gsm0503_rach_ext : &gsm0503_rach, burst, conv);
+	osmo_conv_decode_ber(is_11bit ? &gsm0503_rach_ext : &gsm0503_rach, burst, conv,
+			     n_errors, n_bits_total);
 
 	rach_apply_bsic(conv, bsic, nbits);
 
@@ -2852,7 +2854,7 @@
  *  \returns 0 on success; negative on error (e.g. CRC error) */
 int gsm0503_rach_ext_decode(uint16_t *ra, const sbit_t *burst, uint8_t bsic)
 {
-	int16_t r = rach_decode(burst, bsic, true);
+	int16_t r = rach_decode_ber(burst, bsic, true, NULL, NULL);
 
 	if (r < 0)
 		return r;
@@ -2869,7 +2871,43 @@
  *  \returns 0 on success; negative on error (e.g. CRC error) */
 int gsm0503_rach_decode(uint8_t *ra, const sbit_t *burst, uint8_t bsic)
 {
-	int16_t r = rach_decode(burst, bsic, false);
+	int16_t r = rach_decode_ber(burst, bsic, false, NULL, NULL);
+	if (r < 0)
+		return r;
+
+	*ra = r;
+	return 0;
+}
+
+/*! Decode the Extended (11-bit) RACH according to 3GPP TS 45.003
+ *  \param[out] ra output buffer for RACH data
+ *  \param[in] burst Input burst data
+ *  \param[in] bsic BSIC used in this cell
+ *  \param[out] n_errors Number of detected bit errors
+ *  \param[out] n_bits_total Total number of bits
+ *  \returns 0 on success; negative on error (e.g. CRC error) */
+int gsm0503_rach_ext_decode_ber(uint16_t *ra, const sbit_t *burst, uint8_t bsic,
+				int *n_errors, int *n_bits_total)
+{
+	int16_t r = rach_decode_ber(burst, bsic, true, n_errors, n_bits_total);
+	if (r < 0)
+		return r;
+
+	*ra = r;
+	return 0;
+}
+
+/*! Decode the (8-bit) RACH according to TS 05.03
+ *  \param[out] ra output buffer for RACH data
+ *  \param[in] burst Input burst data
+ *  \param[in] bsic BSIC used in this cell
+ *  \param[out] n_errors Number of detected bit errors
+ *  \param[out] n_bits_total Total number of bits
+ *  \returns 0 on success; negative on error (e.g. CRC error) */
+int gsm0503_rach_decode_ber(uint8_t *ra, const sbit_t *burst, uint8_t bsic,
+			    int *n_errors, int *n_bits_total)
+{
+	int16_t r = rach_decode_ber(burst, bsic, false, n_errors, n_bits_total);
 
 	if (r < 0)
 		return r;
diff --git a/src/coding/libosmocoding.map b/src/coding/libosmocoding.map
index 95953cf..87b3886 100644
--- a/src/coding/libosmocoding.map
+++ b/src/coding/libosmocoding.map
@@ -110,8 +110,10 @@
 gsm0503_tch_ahs_decode;
 gsm0503_rach_ext_encode;
 gsm0503_rach_ext_decode;
+gsm0503_rach_ext_decode_ber;
 gsm0503_rach_encode;
 gsm0503_rach_decode;
+gsm0503_rach_decode_ber;
 gsm0503_sch_encode;
 gsm0503_sch_decode;
 
diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c
index 660f51f..7b4f2a5 100644
--- a/tests/coding/coding_test.c
+++ b/tests/coding/coding_test.c
@@ -123,7 +123,7 @@
 	memset(bursts_s + 6, 0, 8);
 
 	/* Decode, correcting errors */
-	gsm0503_rach_decode(&result, bursts_s, bsic);
+	gsm0503_rach_decode_ber(&result, bursts_s, bsic, NULL, NULL);
 	printf("Decoded: %02x\n", result);
 
 	if (ra != result)
@@ -153,7 +153,7 @@
 	memset(bursts_s + 9, 0, 8);
 
 	/* Decode, correcting errors */
-	gsm0503_rach_ext_decode(&result, bursts_s, bsic);
+	gsm0503_rach_ext_decode_ber(&result, bursts_s, bsic, NULL, NULL);
 	printf("Decoded: %02x\n", result);
 
 	if (ra != result)

-- 
To view, visit https://gerrit.osmocom.org/6925
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2b1926a37bde860dcfeb0d613eb55a71271928c5
Gerrit-PatchSet: 3
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list