Harald Welte has submitted this change and it was merged.

Change subject: octphy: Remove code duplication for BER / RSSI conversion
......................................................................


octphy: Remove code duplication for BER / RSSI conversion

Let's introduce some functions to hide the details of BER and RSSI
conversion from OCTPHY representation to L1SAP representation.

Change-Id: I517669c87a97b2ba164a2812811c8802fe0b92e8
---
M src/osmo-bts-octphy/l1_if.c
1 file changed, 22 insertions(+), 18 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index cb0ea05..ddaa9b3 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -846,6 +846,21 @@
        return (fn - fn_mod) + new_fn_mod;
 }
 
+static unsigned int oct_meas2ber10k(const tOCTVC1_GSM_MEASUREMENT_INFO *m)
+{
+       if (m->usBERTotalBitCnt != 0) {
+               return (unsigned int)((m->usBERCnt * BER_10K) / 
m->usBERTotalBitCnt);
+       } else {
+               return 0;
+       }
+}
+
+static int oct_meas2rssi_dBm(const tOCTVC1_GSM_MEASUREMENT_INFO *m)
+{
+       /* rssi is in q8 format */
+       return (m->sRSSIDbm >> 8);
+}
+
 static void process_meas_res(struct gsm_bts_trx *trx, uint8_t chan_nr,
                             uint32_t fn, uint32_t data_len,
                             tOCTVC1_GSM_MEASUREMENT_INFO * m)
@@ -872,16 +887,10 @@
                l1sap.u.info.u.meas_ind.ta_offs_qbits = 0;
        }
 
-       if (m->usBERTotalBitCnt != 0) {
-               l1sap.u.info.u.meas_ind.ber10k =
-                   (unsigned int)((m->usBERCnt * BER_10K) /
-                                  m->usBERTotalBitCnt);
-       } else {
-               l1sap.u.info.u.meas_ind.ber10k = 0;
-       }
+       l1sap.u.info.u.meas_ind.ber10k = oct_meas2ber10k(m);
 
        /* rssi is in q8 format */
-       l1sap.u.info.u.meas_ind.inv_rssi = (uint8_t) ((m->sRSSIDbm >> 8) * -1);
+       l1sap.u.info.u.meas_ind.inv_rssi = (uint8_t) oct_meas2rssi_dBm(m);
 
        /* copy logical frame number to MEAS IND data structure */
        l1sap.u.info.u.meas_ind.fn = translate_tch_meas_rep_fn104_reverse(fn);
@@ -1060,9 +1069,8 @@
        struct osmo_phsap_prim *l1sap;
        uint32_t fn;
        uint8_t *data;
-       uint16_t len, b_total, b_error;
+       uint16_t len;
        int16_t snr;
-       int8_t rssi;
        int rc;
 
        uint8_t sapi = (uint8_t) data_ind->LchId.bySAPI;
@@ -1104,8 +1112,6 @@
                return rc;
        }
 
-       /* get rssi, rssi is in q8 format */
-       rssi = (int8_t) (data_ind->MeasurementInfo.sRSSIDbm >> 8);
        /* get data pointer and length */
        data = data_ind->Data.abyDataContent;
        len = data_ind->Data.ulDataLength;
@@ -1135,13 +1141,11 @@
        l1sap->u.data.fn = fn;
 #endif
 
-       l1sap->u.data.rssi = rssi;
-       b_total = data_ind->MeasurementInfo.usBERTotalBitCnt;
-       b_error =data_ind->MeasurementInfo.usBERCnt;
-       l1sap->u.data.ber10k = b_total ? BER_10K * b_error / b_total : 0;
+       l1sap->u.data.rssi = oct_meas2rssi_dBm(&data_ind->MeasurementInfo);
+       l1sap->u.data.ber10k = oct_meas2ber10k(&data_ind->MeasurementInfo);
 
-       /* FIXME::burst timing  in 1x but PCU is expecting 4X */
-       l1sap->u.data.ta_offs_qbits = (data_ind->MeasurementInfo.sBurstTiming * 
4);
+       /* burst timing  in 1x but PCU is expecting 4X */
+       l1sap->u.data.ta_offs_qbits = data_ind->MeasurementInfo.sBurstTiming4x;
        snr = data_ind->MeasurementInfo.sSNRDb;
        /* FIXME: better converion formulae for SnR -> C / I?
        l1sap->u.data.lqual_cb = (snr ? snr : (snr - 65536)) * 10 / 256;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I517669c87a97b2ba164a2812811c8802fe0b92e8
Gerrit-PatchSet: 2
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder

Reply via email to