From da084794a66327bcf55877b7a7cabfdddcf4f1e6 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Tue, 16 Feb 2021 20:58:24 +0100 Subject: 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 --- src/common/l1sap.c | 15 +++++++++------ src/common/rsl.c | 8 ++++---- src/osmo-bts-virtual/l1_if.c | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/common/l1sap.c b/src/common/l1sap.c index ed7b4e75..0a46b23c 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -979,7 +980,7 @@ void repeated_dl_facch_active_decision(struct gsm_lchan *lchan, const uint8_t *l /* 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 @@ static inline struct msgb *lapdm_phsap_dequeue_msg_sacch(struct gsm_lchan *lchan * 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 @@ static int l1sap_ph_data_ind(struct gsm_bts_trx *trx, 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 @@ static int l1sap_ph_data_ind(struct gsm_bts_trx *trx, * 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 3023ffa1..525b6373 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -3202,8 +3202,8 @@ int rsl_tx_meas_res(struct gsm_lchan *lchan, uint8_t *l3, int l3_len, const stru 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 @@ int rsl_tx_meas_res(struct gsm_lchan *lchan, uint8_t *l3, int l3_len, const stru * 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 @@ int rsl_tx_meas_res(struct gsm_lchan *lchan, uint8_t *l3, int l3_len, const stru } 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 ed3b6019..78da639a 100644 --- a/src/osmo-bts-virtual/l1_if.c +++ b/src/osmo-bts-virtual/l1_if.c @@ -329,7 +329,7 @@ static int l1if_process_meas_res(struct gsm_bts_trx *trx, uint8_t tn, uint32_t f 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); -- cgit v1.2.3