[PATCH 3/9] si: Use range 512 encoding format whenever possible

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/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Tue Jan 14 13:24:17 UTC 2014


The current code only implements the bit packing for the range 512
encoding format.

This patch prefers the (implemenented) range512 above the (not yet
implemented) other encodings. This means that range512 is used
whenever possible, not only when it is optimal. Thus the encoding
will only fail, when it not *possible* to use range512.

The patch has a similar effect like commit 10eb96e6b1e and replaces
it.

Ticket: OW#1061
Sponsored-by: On-Waves ehf
---
 openbsc/src/libbsc/arfcn_range_encode.c |    6 ++++--
 openbsc/tests/si/si_test.c              |    4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/openbsc/src/libbsc/arfcn_range_encode.c b/openbsc/src/libbsc/arfcn_range_encode.c
index c52743e..d12c907 100644
--- a/openbsc/src/libbsc/arfcn_range_encode.c
+++ b/openbsc/src/libbsc/arfcn_range_encode.c
@@ -160,12 +160,14 @@ int range_enc_determine_range(const int *arfcns, const int size, int *f0)
 	max = arfcns[size - 1] - arfcns[0];
 	*f0 = arfcns[0];
 
+	if (max < 512 && size <= 18)
+		return ARFCN_RANGE_512;
+
+	/* The following are nyi, so they are checked last */
 	if (max < 128 && size <= 29)
 		return ARFCN_RANGE_128;
 	if (max < 256 && size <= 22)
 		return ARFCN_RANGE_256;
-	if (max < 512 && size <= 18)
-		return ARFCN_RANGE_512;
 	if (max < 1024 && size <= 17)
 		return ARFCN_RANGE_1024;
 
diff --git a/openbsc/tests/si/si_test.c b/openbsc/tests/si/si_test.c
index fd840f3..695ae6d 100644
--- a/openbsc/tests/si/si_test.c
+++ b/openbsc/tests/si/si_test.c
@@ -137,11 +137,11 @@ int main(int argc, char **argv)
 	}
 
 	i = range_enc_determine_range(range128, ARRAY_SIZE(range128), &f0);
-	VERIFY(i, ==, ARFCN_RANGE_128);
+	VERIFY(i, ==, ARFCN_RANGE_512);
 	VERIFY(f0, ==, 1);
 
 	i = range_enc_determine_range(range256, ARRAY_SIZE(range256), &f0);
-	VERIFY(i, ==, ARFCN_RANGE_256);
+	VERIFY(i, ==, ARFCN_RANGE_512);
 	VERIFY(f0, ==, 1);
 
 	i = range_enc_determine_range(range512, ARRAY_SIZE(range512), &f0);
-- 
1.7.9.5





More information about the OpenBSC mailing list