laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/18837 )

Change subject: A-bis/OML: handle hopping params in Set Channel Attributes
......................................................................

A-bis/OML: handle hopping params in Set Channel Attributes

Change-Id: Ieac26c7aca118c16889cdde2565a514681dc137b
Related: OS#4546
---
M include/osmo-bts/gsm_data.h
M src/common/gsm_data.c
M src/common/oml.c
3 files changed, 42 insertions(+), 21 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 255c871..7b4d456 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -350,17 +350,13 @@
        uint8_t nm_chan_comb;
        int tsc;                /* -1 == use BTS TSC */

+       /* Frequency hopping parameters (configured via OML) */
        struct {
-               /* Parameters below are configured by VTY */
-               int enabled;
+               bool enabled;
                uint8_t maio;
                uint8_t hsn;
-               struct bitvec arfcns;
-               uint8_t arfcns_data[1024/8];
-               /* This is the pre-computed MA for channel assignments */
-               struct bitvec ma;
-               uint8_t ma_len; /* part of ma_data that is used */
-               uint8_t ma_data[8];     /* 10.5.2.21: max 8 bytes value part */
+               uint16_t ma[64];
+               uint8_t ma_len;
        } hopping;

        struct gsm_lchan lchan[TS_MAX_LCHAN];
diff --git a/src/common/gsm_data.c b/src/common/gsm_data.c
index ae604ec..7239440 100644
--- a/src/common/gsm_data.c
+++ b/src/common/gsm_data.c
@@ -228,11 +228,6 @@
                gsm_mo_init(&ts->mo, bts, NM_OC_CHANNEL,
                            bts->nr, trx->nr, ts->nr);

-               ts->hopping.arfcns.data_len = sizeof(ts->hopping.arfcns_data);
-               ts->hopping.arfcns.data = ts->hopping.arfcns_data;
-               ts->hopping.ma.data_len = sizeof(ts->hopping.ma_data);
-               ts->hopping.ma.data = ts->hopping.ma_data;
-
                for (l = 0; l < TS_MAX_LCHAN; l++) {
                        struct gsm_lchan *lchan;
                        char *name;
diff --git a/src/common/oml.c b/src/common/oml.c
index 28fa066..5f64d52 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -872,7 +872,7 @@
        struct abis_om_fom_hdr *foh = msgb_l3(msg);
        struct gsm_bts *bts = ts->trx->bts;
        struct tlv_parsed tp, *tp_merged;
-       int rc;
+       int rc, i;

        DEBUGPFOH(DOML, foh, "Rx SET CHAN ATTR\n");

@@ -883,11 +883,39 @@
                return oml_fom_ack_nack(msg, NM_NACK_INCORR_STRUCT);
        }

-       /* 9.4.21 HSN... */
-       /* 9.4.27 MAIO */
+       /* Check frequency hopping parameters (HSN, MAIO, ARFCN list) */
        if (TLVP_PRESENT(&tp, NM_ATT_HSN) || TLVP_PRESENT(&tp, NM_ATT_MAIO)) {
-               LOGPFOH(DOML, LOGL_NOTICE, foh, "SET CHAN ATTR: Frequency 
hopping not supported.\n");
-               return oml_fom_ack_nack(msg, NM_NACK_SPEC_IMPL_NOTSUPP);
+               if (!osmo_bts_has_feature(bts->features, BTS_FEAT_HOPPING)) {
+                       LOGPFOH(DOML, LOGL_ERROR, foh, "SET CHAN ATTR: 
Frequency hopping not supported.\n");
+                       return oml_fom_ack_nack(msg, NM_NACK_SPEC_IMPL_NOTSUPP);
+               }
+
+               if (!TLVP_PRES_LEN(&tp, NM_ATT_HSN, 1) || !TLVP_PRES_LEN(&tp, 
NM_ATT_MAIO, 1)) {
+                       LOGPFOH(DOML, LOGL_ERROR, foh, "SET CHAN ATTR: HSN 
and/or MAIO is missing: "
+                               "hsn=%u, maio=%u\n", TLVP_LEN(&tp, NM_ATT_HSN), 
TLVP_LEN(&tp, NM_ATT_MAIO));
+                       return oml_fom_ack_nack(msg, 
NM_NACK_ATTRLIST_INCONSISTENT);
+               }
+
+               if (!TLVP_PRES_LEN(&tp, NM_ATT_ARFCN_LIST, 2)) { /* At least 
one ARFCN */
+                       LOGPFOH(DOML, LOGL_ERROR, foh, "SET CHAN ATTR: ARFCN 
list is missing\n");
+                       return oml_fom_ack_nack(msg, 
NM_NACK_ATTRLIST_INCONSISTENT);
+               }
+
+               if (TLVP_LEN(&tp, NM_ATT_ARFCN_LIST) > sizeof(ts->hopping.ma)) {
+                       LOGPFOH(DOML, LOGL_ERROR, foh, "SET CHAN ATTR: ARFCN 
list is too long\n");
+                       return oml_fom_ack_nack(msg, 
NM_NACK_ATTRLIST_INCONSISTENT);
+               } else if (TLVP_LEN(&tp, NM_ATT_ARFCN_LIST) % 2 != 0) {
+                       LOGPFOH(DOML, LOGL_ERROR, foh, "SET CHAN ATTR: ARFCN 
list has odd length\n");
+                       return oml_fom_ack_nack(msg, 
NM_NACK_ATTRLIST_INCONSISTENT);
+               }
+
+               ts->hopping.enabled = true;
+               ts->hopping.hsn = *TLVP_VAL(&tp, NM_ATT_HSN);
+               ts->hopping.maio = *TLVP_VAL(&tp, NM_ATT_MAIO);
+
+               ts->hopping.ma_len = TLVP_LEN(&tp, NM_ATT_ARFCN_LIST) / 
sizeof(uint16_t);
+               for (i = 0; i < ts->hopping.ma_len; i++)
+                       ts->hopping.ma[i] = osmo_load16be(TLVP_VAL(&tp, 
NM_ATT_ARFCN_LIST) + i * 2);
        }

        /* 9.4.52 Starting Time */
@@ -928,8 +956,6 @@
                }
        }

-       /* 9.4.5 ARFCN List */
-
        /* 9.4.60 TSC */
        if (TLVP_PRES_LEN(&tp, NM_ATT_TSC, 1)) {
                ts->tsc = *TLVP_VAL(&tp, NM_ATT_TSC);
@@ -937,8 +963,12 @@
                /* If there is no TSC specified, use the BCC */
                ts->tsc = BSIC2BCC(bts->bsic);
        }
-       LOGPFOH(DOML, LOGL_INFO, foh, "SET CHAN ATTR (TSC=%u pchan=%s)\n",
+       LOGPFOH(DOML, LOGL_INFO, foh, "SET CHAN ATTR (TSC=%u pchan=%s",
                ts->tsc, gsm_pchan_name(ts->pchan));
+       if (ts->hopping.enabled)
+               LOGPC(DOML, LOGL_INFO, " hsn=%u maio=%u ma_len=%u",
+                     ts->hopping.hsn, ts->hopping.maio, ts->hopping.ma_len);
+       LOGPC(DOML, LOGL_INFO, ")\n");

        /* call into BTS driver to apply new attributes to hardware */
        return bts_model_apply_oml(bts, msg, tp_merged, NM_OC_CHANNEL, ts);

--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/18837
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ieac26c7aca118c16889cdde2565a514681dc137b
Gerrit-Change-Number: 18837
Gerrit-PatchSet: 4
Gerrit-Owner: fixeria <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to