Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/6993

to look at the new patch set (#3).

gsm_data: use feature list from libosmocore

In order to avoid code duplication the feature list (bit masks) and
the desciptive value strings as well as the function to set and get
the feature bits have been moved to libosmocore.

- use feature list functionality provided by libosmocore

Change-Id: I3e80517539cc5d0e5d8189d434a5e3cc0fdea1a0
Depends: Change-Id Id0c35aef11aa49aa40abe7deef1f9dbd12210776
---
M include/osmocom/bsc/gsm_data.h
M src/libbsc/abis_nm.c
M src/libbsc/bsc_vty.c
M src/libbsc/bts_ericsson_rbs2000.c
M src/libbsc/bts_ipaccess_nanobts.c
M src/libbsc/bts_nokia_site.c
M src/libbsc/bts_siemens_bs11.c
M src/libbsc/bts_sysmobts.c
M src/libbsc/gsm_data.c
9 files changed, 25 insertions(+), 79 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/93/6993/3

diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 3c65c9c..44d4a43 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -12,6 +12,7 @@
 #include <osmocom/core/select.h>
 #include <osmocom/core/stats.h>
 #include <osmocom/core/stat_item.h>
+#include <osmocom/gsm/bts_features.h>
 #include <osmocom/gsm/protocol/gsm_08_08.h>
 
 #include <osmocom/crypt/auth.h>
@@ -210,8 +211,6 @@
 #define HARDCODED_BTS2_TS      11
 
 #define MAX_VERSION_LENGTH 64
-
-#define MAX_BTS_FEATURES 128
 
 enum gsm_hooks {
        GSM_HOOK_NM_SWLOAD,
@@ -613,22 +612,7 @@
        uint8_t _features_data[MAX_BTS_FEATURES/8];
 };
 
-/* 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 */
-enum gsm_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,
-       _NUM_BTS_FEAT
-};
 
-extern const struct value_string gsm_bts_features_descs[];
 
 /*
  * This keeps track of the paging status of one BTS. It
@@ -1017,18 +1001,6 @@
        return lchan->name;
 }
 
-static inline int gsm_bts_set_feature(struct gsm_bts *bts, enum 
gsm_bts_features feat)
-{
-       OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
-       return bitvec_set_bit_pos(&bts->features, feat, 1);
-}
-
-static inline bool gsm_bts_has_feature(const struct gsm_bts *bts, enum 
gsm_bts_features feat)
-{
-       OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
-       return bitvec_get_bit_pos(&bts->features, feat);
-}
-
 void gsm_abis_mo_reset(struct gsm_abis_mo *mo);
 
 struct gsm_nm_state *
@@ -1356,7 +1328,6 @@
 int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts);
 void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts);
 
-int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum 
gsm_bts_features feat);
 int gsm_bts_model_register(struct gsm_bts_model *model);
 
 struct gsm_subscriber_connection *bsc_subscr_con_allocate(struct gsm_lchan 
*lchan);
@@ -1373,7 +1344,6 @@
                   uint8_t e1_ts, uint8_t e1_ts_ss);
 
 void gsm_trx_lock_rf(struct gsm_bts_trx *trx, bool locked, const char *reason);
-bool gsm_btsmodel_has_feature(struct gsm_bts_model *model, enum 
gsm_bts_features feat);
 struct gsm_bts_trx *gsm_bts_trx_by_nr(struct gsm_bts *bts, int nr);
 int gsm_bts_trx_set_system_infos(struct gsm_bts_trx *trx);
 int gsm_bts_set_system_infos(struct gsm_bts *bts);
diff --git a/src/libbsc/abis_nm.c b/src/libbsc/abis_nm.c
index 671c874..970fcf9 100644
--- a/src/libbsc/abis_nm.c
+++ b/src/libbsc/abis_nm.c
@@ -47,6 +47,7 @@
 #include <osmocom/bsc/signal.h>
 #include <osmocom/abis/e1_input.h>
 #include <osmocom/bsc/chan_alloc.h>
+#include <osmocom/gsm/bts_features.h>
 
 #define OM_ALLOC_SIZE          1024
 #define OM_HEADROOM_SIZE       128
@@ -501,11 +502,11 @@
                adjust = m_id_len + 3; /* adjust for parsed TL16V struct */
 
                for (i = 0; i < _NUM_BTS_FEAT; i++)
-                       if (gsm_bts_has_feature(bts, i) != 
gsm_btsmodel_has_feature(bts->model, i))
+                       if (osmo_bts_has_feature(&bts->features, i) != 
osmo_bts_has_feature(&bts->model->features, i))
                                LOGP(DNM, LOGL_NOTICE, "BTS%u feature '%s' 
reported via OML does not match statically "
                                     "set feature: %u != %u. Please fix.\n", 
bts->nr,
-                                    get_value_string(gsm_bts_features_descs, 
i),
-                                    gsm_bts_has_feature(bts, i), 
gsm_btsmodel_has_feature(bts->model, i));
+                                    get_value_string(osmo_bts_features_descs, 
i),
+                                    osmo_bts_has_feature(&bts->features, i), 
osmo_bts_has_feature(&bts->model->features, i));
        }
 
        *data_len -= adjust;
diff --git a/src/libbsc/bsc_vty.c b/src/libbsc/bsc_vty.c
index ae1dd93..be2e559 100644
--- a/src/libbsc/bsc_vty.c
+++ b/src/libbsc/bsc_vty.c
@@ -3971,7 +3971,7 @@
 {
        struct gsm_bts_trx_ts *ts = vty->index;
 
-       if (!gsm_btsmodel_has_feature(ts->trx->bts->model, BTS_FEAT_MULTI_TSC)) 
{
+       if (!osmo_bts_has_feature(&ts->trx->bts->model->features, 
BTS_FEAT_MULTI_TSC)) {
                vty_out(vty, "%% This BTS does not support a TSC != BCC, "
                        "falling back to BCC%s", VTY_NEWLINE);
                ts->tsc = -1;
@@ -3994,7 +3994,7 @@
        struct gsm_bts_trx_ts *ts = vty->index;
        int enabled = atoi(argv[0]);
 
-       if (enabled && !gsm_btsmodel_has_feature(ts->trx->bts->model, 
BTS_FEAT_HOPPING)) {
+       if (enabled && !osmo_bts_has_feature(&ts->trx->bts->model->features, 
BTS_FEAT_HOPPING)) {
                vty_out(vty, "BTS model does not support hopping%s",
                        VTY_NEWLINE);
                return CMD_WARNING;
diff --git a/src/libbsc/bts_ericsson_rbs2000.c 
b/src/libbsc/bts_ericsson_rbs2000.c
index 5ee2760..20b498a 100644
--- a/src/libbsc/bts_ericsson_rbs2000.c
+++ b/src/libbsc/bts_ericsson_rbs2000.c
@@ -186,11 +186,11 @@
        model_rbs2k.features.data = &model_rbs2k._features_data[0];
        model_rbs2k.features.data_len = sizeof(model_rbs2k._features_data);
 
-       gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_GPRS);
-       gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_EGPRS);
-       gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HOPPING);
-       gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_HSCSD);
-       gsm_btsmodel_set_feature(&model_rbs2k, BTS_FEAT_MULTI_TSC);
+       osmo_bts_set_feature(&model_rbs2k.features, BTS_FEAT_GPRS);
+        osmo_bts_set_feature(&model_rbs2k.features, BTS_FEAT_EGPRS);
+        osmo_bts_set_feature(&model_rbs2k.features, BTS_FEAT_HOPPING);
+       osmo_bts_set_feature(&model_rbs2k.features, BTS_FEAT_HSCSD);
+       osmo_bts_set_feature(&model_rbs2k.features, BTS_FEAT_MULTI_TSC);
 
        osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
        osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL);
diff --git a/src/libbsc/bts_ipaccess_nanobts.c 
b/src/libbsc/bts_ipaccess_nanobts.c
index 99e178d..edfe417 100644
--- a/src/libbsc/bts_ipaccess_nanobts.c
+++ b/src/libbsc/bts_ipaccess_nanobts.c
@@ -328,9 +328,9 @@
        bts_model_nanobts.features.data_len =
                                sizeof(bts_model_nanobts._features_data);
 
-       gsm_btsmodel_set_feature(&bts_model_nanobts, BTS_FEAT_GPRS);
-       gsm_btsmodel_set_feature(&bts_model_nanobts, BTS_FEAT_EGPRS);
-       gsm_btsmodel_set_feature(&bts_model_nanobts, BTS_FEAT_MULTI_TSC);
+       osmo_bts_set_feature(&bts_model_nanobts.features, BTS_FEAT_GPRS);
+       osmo_bts_set_feature(&bts_model_nanobts.features, BTS_FEAT_EGPRS);
+       osmo_bts_set_feature(&bts_model_nanobts.features, BTS_FEAT_MULTI_TSC);
 
        return gsm_bts_model_register(&bts_model_nanobts);
 }
diff --git a/src/libbsc/bts_nokia_site.c b/src/libbsc/bts_nokia_site.c
index 392cd17..6221e5f 100644
--- a/src/libbsc/bts_nokia_site.c
+++ b/src/libbsc/bts_nokia_site.c
@@ -1720,9 +1720,9 @@
        model_nokia_site.features.data_len =
            sizeof(model_nokia_site._features_data);
 
-       gsm_btsmodel_set_feature(&model_nokia_site, BTS_FEAT_HOPPING);
-       gsm_btsmodel_set_feature(&model_nokia_site, BTS_FEAT_HSCSD);
-       gsm_btsmodel_set_feature(&model_nokia_site, BTS_FEAT_MULTI_TSC);
+       osmo_bts_set_feature(&model_nokia_site.features, BTS_FEAT_HOPPING);
+       osmo_bts_set_feature(&model_nokia_site.features, BTS_FEAT_HSCSD);
+        osmo_bts_set_feature(&model_nokia_site.features, BTS_FEAT_MULTI_TSC);
 
        osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
        osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL);
diff --git a/src/libbsc/bts_siemens_bs11.c b/src/libbsc/bts_siemens_bs11.c
index e01c258..5701e47 100644
--- a/src/libbsc/bts_siemens_bs11.c
+++ b/src/libbsc/bts_siemens_bs11.c
@@ -586,9 +586,9 @@
        model_bs11.features.data = &model_bs11._features_data[0];
        model_bs11.features.data_len = sizeof(model_bs11._features_data);
 
-       gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_HOPPING);
-       gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_HSCSD);
-       gsm_btsmodel_set_feature(&model_bs11, BTS_FEAT_MULTI_TSC);
+       osmo_bts_set_feature(&model_bs11.features, BTS_FEAT_HOPPING);
+       osmo_bts_set_feature(&model_bs11.features, BTS_FEAT_HSCSD);
+       osmo_bts_set_feature(&model_bs11.features, BTS_FEAT_MULTI_TSC);
 
        osmo_signal_register_handler(SS_L_INPUT, inp_sig_cb, NULL);
        osmo_signal_register_handler(SS_L_GLOBAL, gbl_sig_cb, NULL);
diff --git a/src/libbsc/bts_sysmobts.c b/src/libbsc/bts_sysmobts.c
index 2982074..91d1118 100644
--- a/src/libbsc/bts_sysmobts.c
+++ b/src/libbsc/bts_sysmobts.c
@@ -53,8 +53,8 @@
                                sizeof(model_sysmobts._features_data);
        memset(model_sysmobts.features.data, 0, 
sizeof(model_sysmobts.features.data_len));
 
-       gsm_btsmodel_set_feature(&model_sysmobts, BTS_FEAT_GPRS);
-       gsm_btsmodel_set_feature(&model_sysmobts, BTS_FEAT_EGPRS);
+        osmo_bts_set_feature(&model_sysmobts.features, BTS_FEAT_GPRS);
+       osmo_bts_set_feature(&model_sysmobts.features, BTS_FEAT_EGPRS);
 
        return gsm_bts_model_register(&model_sysmobts);
 }
diff --git a/src/libbsc/gsm_data.c b/src/libbsc/gsm_data.c
index 1594522..248bb02 100644
--- a/src/libbsc/gsm_data.c
+++ b/src/libbsc/gsm_data.c
@@ -146,27 +146,15 @@
 int bts_gprs_mode_is_compat(struct gsm_bts *bts, enum bts_gprs_mode mode)
 {
        if (mode != BTS_GPRS_NONE &&
-           !gsm_btsmodel_has_feature(bts->model, BTS_FEAT_GPRS)) {
+           !osmo_bts_has_feature(&bts->model->features, BTS_FEAT_GPRS)) {
                return 0;
        }
        if (mode == BTS_GPRS_EGPRS &&
-           !gsm_btsmodel_has_feature(bts->model, BTS_FEAT_EGPRS)) {
+           !osmo_bts_has_feature(&bts->model->features, BTS_FEAT_EGPRS)) {
                return 0;
        }
 
        return 1;
-}
-
-int gsm_btsmodel_set_feature(struct gsm_bts_model *model, enum 
gsm_bts_features feat)
-{
-       OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
-       return bitvec_set_bit_pos(&model->features, feat, 1);
-}
-
-bool gsm_btsmodel_has_feature(struct gsm_bts_model *model, enum 
gsm_bts_features feat)
-{
-       OSMO_ASSERT(_NUM_BTS_FEAT < MAX_BTS_FEATURES);
-       return bitvec_get_bit_pos(&model->features, feat);
 }
 
 int gsm_set_bts_type(struct gsm_bts *bts, enum gsm_bts_type type)
@@ -504,19 +492,6 @@
 {
        return get_value_string(bts_type_names, type);
 }
-
-const struct value_string gsm_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" },
-       { 0, NULL }
-};
 
 const struct value_string gsm_chreq_descs[] = {
        { GSM_CHREQ_REASON_EMERG,       "emergency call" },

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I3e80517539cc5d0e5d8189d434a5e3cc0fdea1a0
Gerrit-PatchSet: 3
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: dexter <pma...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pma...@sysmocom.de>

Reply via email to