Review at  https://gerrit.osmocom.org/2412

measurement: fix measurement computation

Timing advance is currently not taken into account when computing
the measurement results, this commit fixes that

Change-Id: I2e0dfd13b53e8aa2822985f12bf2985e683ab553
---
M include/osmo-bts/measurement.h
M src/common/measurement.c
2 files changed, 68 insertions(+), 0 deletions(-)


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

diff --git a/include/osmo-bts/measurement.h b/include/osmo-bts/measurement.h
index 2efe40f..87c8109 100644
--- a/include/osmo-bts/measurement.h
+++ b/include/osmo-bts/measurement.h
@@ -1,6 +1,9 @@
 #ifndef OSMO_BTS_MEAS_H
 #define OSMO_BTS_MEAS_H
 
+#define MEAS_MAX_TIMING_ADVANCE 63
+#define MEAS_MIN_TIMING_ADVANCE 0
+
 int lchan_new_ul_meas(struct gsm_lchan *lchan, struct bts_ul_meas *ulm);
 
 int trx_meas_check_compute(struct gsm_bts_trx *trx, uint32_t fn);
diff --git a/src/common/measurement.c b/src/common/measurement.c
index 79f6ae4..5613894 100644
--- a/src/common/measurement.c
+++ b/src/common/measurement.c
@@ -196,6 +196,53 @@
        return 7;
 }
 
+/* Update order  TA at end of meas period */
+static void lchan_meas_update_ordered_TA(struct gsm_lchan *lchan,
+                                        int32_t taqb_sum)
+{
+       int32_t ms_timing_offset = 0;
+       uint8_t l1_info_valid;
+
+       l1_info_valid = lchan->meas.flags & LC_UL_M_F_L1_VALID;
+
+       if (l1_info_valid) {
+               DEBUGP(DMEAS,
+                      "Update TA TimingOffset_Mean:%d, UL RX TA:%d, DL ordered 
TA:%d, flags:%d \n",
+                      taqb_sum, lchan->meas.l1_info[1], lchan->rqd_ta,
+                      lchan->meas.flags);
+
+               ms_timing_offset =
+                   taqb_sum + (lchan->meas.l1_info[1] - lchan->rqd_ta);
+
+               if (ms_timing_offset > 0) {
+                       if (lchan->rqd_ta < MEAS_MAX_TIMING_ADVANCE) {
+                               /* MS is moving away from BTS.
+                                * So increment Ordered TA by 1 */
+                               lchan->rqd_ta++;
+                       }
+               } else if (ms_timing_offset < 0) {
+                       if (lchan->rqd_ta > MEAS_MIN_TIMING_ADVANCE) {
+                               /* MS is moving toward BTS. So decrement
+                                * Ordered TA by 1 */
+                               lchan->rqd_ta--;
+                       }
+               } else {
+                       /*MS is not moving so don't change Ordered TA */
+               }
+
+               DEBUGP(DMEAS,
+                      "New Update TA--> TimingOff_diff:%d, UL RX TA:%d, DL 
ordered TA:%d \n",
+                      ms_timing_offset, lchan->meas.l1_info[1], lchan->rqd_ta);
+       } else {
+               /*Do Nothing */
+       }
+
+       /*Clear L1 INFO valid flag at Meas period end */
+       lchan->meas.flags &= ~LC_UL_M_F_L1_VALID;
+
+       return;
+}
+
 int lchan_meas_check_compute(struct gsm_lchan *lchan, uint32_t fn)
 {
        struct gsm_meas_rep_unidir *mru;
@@ -206,6 +253,7 @@
        int32_t taqb_sum = 0;
        unsigned int num_meas_sub = 0;
        int i;
+       int32_t ms_timing_offset = 0;
 
        /* if measurement period is not complete, abort */
        if (!is_meas_complete(ts_pchan(lchan->ts), lchan->ts->nr,
@@ -241,6 +289,9 @@
        if (num_meas_sub) {
                ber_sub_sum = ber_sub_sum / num_meas_sub;
                irssi_sub_sum = irssi_sub_sum / num_meas_sub;
+       } else {
+               ber_sub_sum = ber_full_sum;
+               irssi_sub_sum = irssi_full_sum;
        }
 
        DEBUGP(DMEAS, "%s Computed TA(% 4dqb) BER-FULL(%2u.%02u%%), 
RSSI-FULL(-%3udBm), "
@@ -249,6 +300,20 @@
                ber_full_sum%100, irssi_full_sum, ber_sub_sum/100, 
ber_sub_sum%100,
                irssi_sub_sum);
 
+       /*Update ordered TA for DL SACCH L1 Header */
+       lchan_meas_update_ordered_TA(lchan, taqb_sum);
+
+       /* As per 3gpp spec-45.010 sec-1.2, An MS with a round trip
+        * propagation delay of P symbols, but with a timing advance of T
+        * symbols, the reported timing offset will be (P-T) quantized to
+        * the nearest symbol. */
+
+       ms_timing_offset = taqb_sum + (lchan->meas.l1_info[1] - lchan->rqd_ta);
+
+       /* 0->(-63), 1->(-62)... etc. */
+       lchan->meas.ms_timing_offset =
+               ms_timing_offset + MEAS_MAX_TIMING_ADVANCE;
+
        /* store results */
        mru = &lchan->meas.ul_res;
        mru->full.rx_lev = dbm2rxlev((int)irssi_full_sum * -1);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2e0dfd13b53e8aa2822985f12bf2985e683ab553
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pma...@sysmocom.de>

Reply via email to