[PATCH] libosmocore[master]: features: move bts feature related functionality to libosmocore

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/.

dexter gerrit-no-reply at lists.osmocom.org
Thu Mar 1 18:41:40 UTC 2018


Review at  https://gerrit.osmocom.org/7034

features: move bts feature related functionality to libosmocore

osmo-bsc and osmo-bts share enums and value strings to describe
feature data that is exchanged via OML (manufacturer id) on startup.
Also the functions to set and get the respecitive bits in the feature
bitvectors are in osmo-bsc and osmo-bts. This is a code duplication
and should be resolved.

- add enum osmo_bts_features (replaces enum gsm_bts_features)
- add osmo_bts_features_descs (replaces gsm_bts_features_descs)
- add osmo_bts_set_feature (replaces gsm_btsmodel_set_feature)
- add osmo_bts_has_feature (replaces gsm_btsmodel_has_feature)

Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
---
M include/Makefile.am
A include/osmocom/core/features.h
M src/Makefile.am
A src/features.c
4 files changed, 85 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/34/7034/1

diff --git a/include/Makefile.am b/include/Makefile.am
index 8b05f80..93b027c 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -23,6 +23,7 @@
                        osmocom/core/crcgen.h \
                        osmocom/core/endian.h \
                        osmocom/core/defs.h \
+                       osmocom/core/features.h \
                        osmocom/core/fsm.h \
                        osmocom/core/gsmtap.h \
                        osmocom/core/gsmtap_util.h \
diff --git a/include/osmocom/core/features.h b/include/osmocom/core/features.h
new file mode 100644
index 0000000..5e7a87e
--- /dev/null
+++ b/include/osmocom/core/features.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include <osmocom/core/utils.h>
+#include <osmocom/core/bitvec.h>
+
+#define MAX_BTS_FEATURES 128
+
+/* N. B: always add new features to the end of the list (right before _NUM_BTS_FEAT) to avoid breaking compatibility
+   with BTS compiled against earlier version of this header. Also make sure that the description strings
+   gsm_bts_features_descs[] in gsm_data.c are also updated accordingly! */
+enum osmo_bts_features {
+	BTS_FEAT_HSCSD,
+	BTS_FEAT_GPRS,
+	BTS_FEAT_EGPRS,
+	BTS_FEAT_ECSD,
+	BTS_FEAT_HOPPING,
+	BTS_FEAT_MULTI_TSC,
+	BTS_FEAT_OML_ALERTS,
+	BTS_FEAT_AGCH_PCH_PROP,
+	BTS_FEAT_CBCH,
+	BTS_FEAT_SPEECH_F_V1,
+	BTS_FEAT_SPEECH_H_V1,
+	BTS_FEAT_SPEECH_F_EFR,
+	BTS_FEAT_SPEECH_F_AMR,
+	BTS_FEAT_SPEECH_H_AMR,
+	_NUM_BTS_FEAT
+};
+
+extern const struct value_string osmo_bts_features_descs[];
+
+static inline int osmo_bts_set_feature(struct bitvec *features, enum osmo_bts_features feature)
+{
+	OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
+	return bitvec_set_bit_pos(features, feature, 1);
+}
+
+static inline bool osmo_bts_has_feature(const struct bitvec *features, enum osmo_bts_features feature)
+{
+	OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
+	return bitvec_get_bit_pos(features, feature);
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 2641a97..4dc1887 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,7 +22,7 @@
 			 conv.c application.c rbtree.c strrb.c \
 			 loggingrb.c crc8gen.c crc16gen.c crc32gen.c crc64gen.c \
 			 macaddr.c stat_item.c stats.c stats_statsd.c prim.c \
-			 conv_acc.c conv_acc_generic.c sercomm.c prbs.c
+			 conv_acc.c conv_acc_generic.c sercomm.c prbs.c features.c
 
 if HAVE_SSSE3
 libosmocore_la_SOURCES += conv_acc_sse.c
diff --git a/src/features.c b/src/features.c
new file mode 100644
index 0000000..3d9d3d8
--- /dev/null
+++ b/src/features.c
@@ -0,0 +1,42 @@
+/*! \file features.c
+ * osmo-bts features. */
+/*
+ * (C) 2017 by sysmocom s.f.m.c. GmbH
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *  MA  02110-1301, USA.
+ */
+
+#include <osmocom/core/features.h>
+
+const struct value_string osmo_bts_features_descs[] = {
+	{ BTS_FEAT_HSCSD,		"HSCSD" },
+	{ BTS_FEAT_GPRS,		"GPRS" },
+	{ BTS_FEAT_EGPRS,		"EGPRS" },
+	{ BTS_FEAT_ECSD,		"ECSD" },
+	{ BTS_FEAT_HOPPING,		"Frequency Hopping" },
+	{ BTS_FEAT_MULTI_TSC,		"Multi-TSC" },
+	{ BTS_FEAT_OML_ALERTS,		"OML Alerts" },
+	{ BTS_FEAT_AGCH_PCH_PROP,	"AGCH/PCH proportional allocation" },
+	{ BTS_FEAT_CBCH,		"CBCH" },
+	{ BTS_FEAT_SPEECH_F_V1,		"Fullrate speech V1" },
+	{ BTS_FEAT_SPEECH_H_V1,		"Halfrate speech V1" },
+	{ BTS_FEAT_SPEECH_F_EFR,	"Fullrate speech EFR" },
+	{ BTS_FEAT_SPEECH_F_AMR,	"Fullrate speech AMR" },
+	{ BTS_FEAT_SPEECH_H_AMR,	"Halfrate speech AMR" },
+	{ 0, NULL }
+};

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0c35aef11aa49aa40abe7deef1f9dbd12210776
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: dexter <pmaier at sysmocom.de>



More information about the gerrit-log mailing list