dexter has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/22938 )


Change subject: gsm_data: handle l1_info with structs
......................................................................

gsm_data: handle l1_info with structs

in struct gsm_lchan and also in other places l1_info is handled in its
binary form. Libosmocore now offers structs to handle l1 info, so lets
use those structs to get rid of all the manual decoding of l1_info.

Depends: libosmocore I23c1890b89d5a0574eb05dace9f64cc59d6f6df7
Change-Id: I5eb516d7849750f3dd174d48c9f07dabf2c80515
---
M include/osmo-bts/gsm_data.h
M src/common/l1sap.c
M src/common/rsl.c
M src/osmo-bts-virtual/l1_if.c
4 files changed, 15 insertions(+), 17 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/38/22938/1

diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 05b6cf2..6caad14 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -323,7 +323,7 @@
                uint8_t num_ul_meas;
                struct bts_ul_meas uplink[MAX_NUM_UL_MEAS];
                /* last L1 header from the MS */
-               uint8_t l1_info[2];
+               struct rsl_l1_info l1_info;
                struct gsm_meas_rep_unidir ul_res;
                int16_t ms_toa256;
                /* Frame number of the last measurement indication receceived */
@@ -411,11 +411,6 @@
        struct msgb *rep_sacch;
 };

-static inline uint8_t lchan_get_ta(const struct gsm_lchan *lchan)
-{
-       return lchan->meas.l1_info[1];
-}
-
 extern const struct value_string lchan_ciph_state_names[];
 static inline const char *lchan_ciph_state_name(uint8_t state) {
        return get_value_string(lchan_ciph_state_names, state);
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index ed7b4e7..0a46b23 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -33,6 +33,7 @@
 #include <osmocom/gsm/l1sap.h>
 #include <osmocom/gsm/gsm_utils.h>
 #include <osmocom/gsm/rsl.h>
+#include <osmocom/gsm/protocol/gsm_44_004.h>
 #include <osmocom/core/gsmtap.h>
 #include <osmocom/core/gsmtap_util.h>
 #include <osmocom/core/utils.h>
@@ -979,7 +980,7 @@
        /* When the MS sets the SRR bit in the UL-SACCH L1 header
         * (repeated SACCH requested) then it makes sense to enable
         * FACCH repetition too. */
-       if ((lchan->meas.l1_info[0] >> 1) & 1) {
+       if (lchan->meas.l1_info.srr_sro) {
                lchan->repeated_dl_facch_active = true;
                return;
        }
@@ -1028,7 +1029,7 @@
         * SACCH repetition. */

        if (lchan->rep_sacch) {
-               if (((lchan->meas.l1_info[0] >> 1) & 1) == 0) {
+               if (lchan->meas.l1_info.srr_sro == 0) {
                        /* Toss previous repetition candidate */
                        msgb_free(lchan->rep_sacch);
                        lchan->rep_sacch = NULL;
@@ -1457,6 +1458,7 @@
        uint32_t fn;
        int8_t rssi;
        enum osmo_ph_pres_info_type pr_info = data_ind->pdch_presence_info;
+       struct gsm_sacch_l1_hdr *l1_hdr;

        rssi = data_ind->rssi;
        chan_nr = data_ind->chan_nr;
@@ -1557,10 +1559,11 @@
                 * fields on the Um interface is different from the
                 * order of fields in RSL. See 3GPP TS 44.004 (section 7.2)
                 * vs. 3GPP TS 48.058 (section 9.3.10). */
-               lchan->meas.l1_info[0] = data[0] << 3;
-               lchan->meas.l1_info[0] |= ((data[0] >> 5) & 1) << 2; /* FPC/EPC 
*/
-               lchan->meas.l1_info[0] |= ((data[0] >> 6) & 1) << 1; /* SRR */
-               lchan->meas.l1_info[1] = data[1];
+               l1_hdr = (struct gsm_sacch_l1_hdr*)data;
+               lchan->meas.l1_info.ms_pwr = l1_hdr->ms_pwr;
+               lchan->meas.l1_info.fpc_epc = l1_hdr->fpc_epc;
+               lchan->meas.l1_info.srr_sro = l1_hdr->srr_sro;
+               lchan->meas.l1_info.ta = l1_hdr->ta;
                lchan->meas.flags |= LC_UL_M_F_L1_VALID;

                lchan_ms_pwr_ctrl(lchan, data[0] & 0x1f, data_ind->rssi);
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 3023ffa..525b637 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -3202,8 +3202,8 @@
             lchan->meas.ul_res.sub.rx_lev,
             lchan->meas.ul_res.full.rx_qual,
             lchan->meas.ul_res.sub.rx_qual,
-            lchan->meas.l1_info[0],
-            lchan->meas.l1_info[1], l3_len, ms_to2rsl(lchan, le) - 
MEAS_MAX_TIMING_ADVANCE);
+            lchan->meas.l1_info.ms_pwr,
+            lchan->meas.l1_info.ta, l3_len, ms_to2rsl(lchan, le) - 
MEAS_MAX_TIMING_ADVANCE);

        msgb_tv_put(msg, RSL_IE_MEAS_RES_NR, lchan->meas.res_nr++);
        size_t ie_len = gsm0858_rsl_ul_meas_enc(&lchan->meas.ul_res,
@@ -3222,7 +3222,7 @@
                         * to know the total propagation time between MS and 
BTS, we need to add
                         * the actual TA value applied by the MS plus the 
respective toa256 value in
                         * 1/256 symbol periods. */
-                       int16_t ta256 = lchan_get_ta(lchan) * 256;
+                       int16_t ta256 = lchan->meas.l1_info.ta * 256;
                        smi->toa256_mean = htons(ta256 + lchan->meas.ms_toa256);
                        smi->toa256_min = htons(ta256 + 
lchan->meas.ext.toa256_min);
                        smi->toa256_max = htons(ta256 + 
lchan->meas.ext.toa256_max);
@@ -3234,7 +3234,7 @@
        }
        msgb_tv_put(msg, RSL_IE_BS_POWER, lchan->bs_power_ctrl.current / 2);
        if (lchan->meas.flags & LC_UL_M_F_L1_VALID) {
-               msgb_tv_fixed_put(msg, RSL_IE_L1_INFO, 2, lchan->meas.l1_info);
+               msgb_tv_fixed_put(msg, RSL_IE_L1_INFO, 
sizeof(lchan->meas.l1_info), (uint8_t*)&lchan->meas.l1_info);
                lchan->meas.flags &= ~LC_UL_M_F_L1_VALID;
        }

diff --git a/src/osmo-bts-virtual/l1_if.c b/src/osmo-bts-virtual/l1_if.c
index ed3b601..78da639 100644
--- a/src/osmo-bts-virtual/l1_if.c
+++ b/src/osmo-bts-virtual/l1_if.c
@@ -329,7 +329,7 @@
        DEBUGPFN(DMEAS, fn, "RX L1 frame %s chan_nr=0x%02x MS pwr=%ddBm 
rssi=%.1f dBFS "
                "ber=%.2f%% (%d/%d bits) L1_ta=%d rqd_ta=%d toa=%.2f\n",
                gsm_lchan_name(lchan), chan_nr, 
ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power_ctrl.max),
-               rssi, ber*100, n_errors, n_bits_total, lchan->meas.l1_info[1], 
lchan->rqd_ta, toa);
+               rssi, ber*100, n_errors, n_bits_total, lchan->meas.l1_info.ta, 
lchan->rqd_ta, toa);

        l1if_fill_meas_res(&l1sap, chan_nr, lchan->rqd_ta + toa, ber, rssi, fn);


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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I5eb516d7849750f3dd174d48c9f07dabf2c80515
Gerrit-Change-Number: 22938
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <[email protected]>
Gerrit-MessageType: newchange

Reply via email to