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

trx/scheduler: Use integer math for TOA (Timing of Arrival)

There's no need to express TOA as a float:
* We receive it as signed 16bit integer in units 1/256 symbol periods
* We pass it to L1SAP as signed integer in 1/4 symbol periods

So turn it into an int16_t with 1/256 symbol period accuracy throughout
the code to avoid both float arithmetic as well as loosing any precision.

Change-Id: Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec
---
M include/osmo-bts/scheduler.h
M include/osmo-bts/scheduler_backend.h
M src/common/scheduler.c
M src/osmo-bts-trx/l1_if.c
M src/osmo-bts-trx/l1_if.h
M src/osmo-bts-trx/loops.c
M src/osmo-bts-trx/loops.h
M src/osmo-bts-trx/scheduler_trx.c
M src/osmo-bts-trx/trx_if.c
M src/osmo-bts-virtual/scheduler_virtbts.c
10 files changed, 73 insertions(+), 70 deletions(-)


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

diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index 4d34315..98f38d3 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -75,7 +75,7 @@
        uint8_t                 rssi_num;       /* number of RSSI values */
        float                   rssi_sum;       /* sum of RSSI values */
        uint8_t                 toa_num;        /* number of TOA values */
-       float                   toa_sum;        /* sum of TOA values */
+       int32_t                 toa256_sum;     /* sum of TOA values (1/256 
symbol) */
 
        /* loss detection */
        uint8_t                 lost;           /* (SACCH) loss detection */
@@ -113,7 +113,7 @@
                int             rssi_count;     /* received RSSI values */
                int             rssi_valid_count; /* number of stored value */
                int             rssi_got_burst; /* any burst received so far */
-               float           toa_sum;        /* sum of TOA values */
+               int32_t         toa256_sum;     /* sum of TOA values (1/256 
symbol) */
                int             toa_num;        /* number of TOA value */
        } meas;
 
@@ -165,7 +165,7 @@
 
 /*! \brief handle an UL burst received by PHY */
 int trx_sched_ul_burst(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
-        sbit_t *bits, uint16_t nbits, int8_t rssi, float toa);
+        sbit_t *bits, uint16_t nbits, int8_t rssi, int16_t toa);
 
 /*! \brief set multiframe scheduler to given physical channel config */
 int trx_sched_set_pchan(struct l1sched_trx *l1t, uint8_t tn,
diff --git a/include/osmo-bts/scheduler_backend.h 
b/include/osmo-bts/scheduler_backend.h
index 5e077ef..5f11f9b 100644
--- a/include/osmo-bts/scheduler_backend.h
+++ b/include/osmo-bts/scheduler_backend.h
@@ -16,7 +16,7 @@
 typedef int trx_sched_ul_func(struct l1sched_trx *l1t, uint8_t tn,
                              uint32_t fn, enum trx_chan_type chan,
                              uint8_t bid, sbit_t *bits, uint16_t nbits,
-                             int8_t rssi, float toa);
+                             int8_t rssi, int16_t toa256);
 
 struct trx_chan_desc {
        /*! \brief Is this on a PDCH (PS) ? */
@@ -74,19 +74,19 @@
        enum trx_chan_type chan, uint8_t bid, uint16_t *nbits);
 int rx_rach_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa);
+       int8_t rssi, int16_t toa256);
 int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa);
+       int8_t rssi, int16_t toa256);
 int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa);
+       int8_t rssi, int16_t toa256);
 int rx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa);
+       int8_t rssi, int16_t toa256);
 int rx_tchh_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa);
+       int8_t rssi, int16_t toa256);
 
 const ubit_t *_sched_dl_burst(struct l1sched_trx *l1t, uint8_t tn,
                              uint32_t fn, uint16_t *nbits);
diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index e6cf541..edd99d2 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -846,7 +846,7 @@
 
 /* process uplink burst */
 int trx_sched_ul_burst(struct l1sched_trx *l1t, uint8_t tn, uint32_t 
current_fn,
-       sbit_t *bits, uint16_t nbits, int8_t rssi, float toa)
+       sbit_t *bits, uint16_t nbits, int8_t rssi, int16_t toa256)
 {
        struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
        struct l1sched_chan_state *l1cs;
@@ -907,7 +907,7 @@
                                }
                        }
 
-                       func(l1t, tn, fn, chan, bid, bits, nbits, rssi, toa);
+                       func(l1t, tn, fn, chan, bid, bits, nbits, rssi, toa256);
                } else if (chan != TRXC_RACH && !l1cs->ho_rach_detect) {
                        sbit_t spare[GSM_BURST_LEN];
                        memset(spare, 0, GSM_BURST_LEN);
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index a5fbf5c..4d2558c 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -487,7 +487,7 @@
 }
 
 
-static void l1if_fill_meas_res(struct osmo_phsap_prim *l1sap, uint8_t chan_nr, 
float ta,
+static void l1if_fill_meas_res(struct osmo_phsap_prim *l1sap, uint8_t chan_nr, 
int16_t toa256,
        float ber, float rssi, uint32_t fn)
 {
        memset(l1sap, 0, sizeof(*l1sap));
@@ -495,14 +495,14 @@
                PRIM_OP_INDICATION, NULL);
        l1sap->u.info.type = PRIM_INFO_MEAS;
        l1sap->u.info.u.meas_ind.chan_nr = chan_nr;
-       l1sap->u.info.u.meas_ind.ta_offs_qbits = (int16_t)(ta*4);
+       l1sap->u.info.u.meas_ind.ta_offs_qbits = toa256/64;
        l1sap->u.info.u.meas_ind.ber10k = (unsigned int) (ber * 10000);
        l1sap->u.info.u.meas_ind.inv_rssi = (uint8_t) (rssi * -1);
        l1sap->u.info.u.meas_ind.fn = fn;
 }
 
 int l1if_process_meas_res(struct gsm_bts_trx *trx, uint8_t tn, uint32_t fn, 
uint8_t chan_nr,
-       int n_errors, int n_bits_total, float rssi, float toa)
+       int n_errors, int n_bits_total, float rssi, int16_t toa256)
 {
        struct gsm_lchan *lchan = &trx->ts[tn].lchan[l1sap_chan2ss(chan_nr)];
        struct osmo_phsap_prim l1sap;
@@ -510,11 +510,11 @@
        float ber = n_bits_total==0 ? 1.0 : (float)n_errors / 
(float)n_bits_total;
 
        LOGPFN(DMEAS, LOGL_DEBUG, fn, "RX L1 frame %s fn=%u chan_nr=0x%02x MS 
pwr=%ddBm rssi=%.1f dBFS "
-               "ber=%.2f%% (%d/%d bits) L1_ta=%d rqd_ta=%d toa=%.2f\n",
+               "ber=%.2f%% (%d/%d bits) L1_ta=%d rqd_ta=%d toa256=%d\n",
                gsm_lchan_name(lchan), fn, chan_nr, 
ms_pwr_dbm(lchan->ts->trx->bts->band, lchan->ms_power_ctrl.current),
-               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[1], 
lchan->rqd_ta, toa256);
 
-       l1if_fill_meas_res(&l1sap, chan_nr, lchan->rqd_ta + toa, ber, rssi, fn);
+       l1if_fill_meas_res(&l1sap, chan_nr, toa256, ber, rssi, fn);
 
        return l1sap_up(trx, &l1sap);
 }
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h
index 1974efc..77c5936 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -69,7 +69,7 @@
 int l1if_provision_transceiver(struct gsm_bts *bts);
 int l1if_mph_time_ind(struct gsm_bts *bts, uint32_t fn);
 int l1if_process_meas_res(struct gsm_bts_trx *trx, uint8_t tn, uint32_t fn, 
uint8_t chan_nr,
-       int n_errors, int n_bits_total, float rssi, float toa);
+       int n_errors, int n_bits_total, float rssi, int16_t toa256);
 
 static inline struct l1sched_trx *trx_l1sched_hdl(struct gsm_bts_trx *trx)
 {
diff --git a/src/osmo-bts-trx/loops.c b/src/osmo-bts-trx/loops.c
index 6f87cd1..a959a71 100644
--- a/src/osmo-bts-trx/loops.c
+++ b/src/osmo-bts-trx/loops.c
@@ -166,12 +166,15 @@
 }
 
 
+/* 90% of one bit duration in 1/256 symbols: 256*0.9 */
+#define TOA256_9OPERCENT       230
+
 /*
  * Timing Advance loop
  */
 
 int ta_val(struct gsm_lchan *lchan, uint8_t chan_nr,
-       struct l1sched_chan_state *chan_state, float toa)
+       struct l1sched_chan_state *chan_state, int16_t toa256)
 {
        struct gsm_bts_trx *trx = lchan->ts->trx;
 
@@ -180,39 +183,39 @@
                return 0;
 
        /* sum measurement */
-       chan_state->meas.toa_sum += toa;
+       chan_state->meas.toa256_sum += toa256;
        if (++(chan_state->meas.toa_num) < 16)
                return 0;
 
        /* complete set */
-       toa = chan_state->meas.toa_sum / chan_state->meas.toa_num;
+       toa256 = chan_state->meas.toa256_sum / chan_state->meas.toa_num;
 
        /* check for change of TOA */
-       if (toa < -0.9F && lchan->rqd_ta > 0) {
+       if (toa256 < -TOA256_9OPERCENT && lchan->rqd_ta > 0) {
                LOGP(DLOOP, LOGL_INFO, "TOA of trx=%u chan_nr=0x%02x is too "
-                       "early (%.2f), now lowering TA from %d to %d\n",
-                       trx->nr, chan_nr, toa, lchan->rqd_ta,
+                       "early (%d), now lowering TA from %d to %d\n",
+                       trx->nr, chan_nr, toa256, lchan->rqd_ta,
                        lchan->rqd_ta - 1);
                lchan->rqd_ta--;
-       } else if (toa > 0.9F && lchan->rqd_ta < 63) {
+       } else if (toa256 > TOA256_9OPERCENT && lchan->rqd_ta < 63) {
                LOGP(DLOOP, LOGL_INFO, "TOA of trx=%u chan_nr=0x%02x is too "
-                       "late (%.2f), now raising TA from %d to %d\n",
-                       trx->nr, chan_nr, toa, lchan->rqd_ta,
+                       "late (%d), now raising TA from %d to %d\n",
+                       trx->nr, chan_nr, toa256, lchan->rqd_ta,
                        lchan->rqd_ta + 1);
                lchan->rqd_ta++;
        } else
                LOGP(DLOOP, LOGL_INFO, "TOA of trx=%u chan_nr=0x%02x is "
-                       "correct (%.2f), keeping current TA of %d\n",
-                       trx->nr, chan_nr, toa, lchan->rqd_ta);
+                       "correct (%d), keeping current TA of %d\n",
+                       trx->nr, chan_nr, toa256, lchan->rqd_ta);
 
        chan_state->meas.toa_num = 0;
-       chan_state->meas.toa_sum = 0;
+       chan_state->meas.toa256_sum = 0;
 
        return 0;
 }
 
 int trx_loop_sacch_input(struct l1sched_trx *l1t, uint8_t chan_nr,
-       struct l1sched_chan_state *chan_state, int8_t rssi, float toa)
+       struct l1sched_chan_state *chan_state, int8_t rssi, int16_t toa256)
 {
        struct gsm_lchan *lchan = &l1t->trx->ts[L1SAP_CHAN2TS(chan_nr)]
                                        .lchan[l1sap_chan2ss(chan_nr)];
@@ -222,7 +225,7 @@
                ms_power_val(chan_state, rssi);
 
        if (pinst->phy_link->u.osmotrx.trx_ta_loop)
-               ta_val(lchan, chan_nr, chan_state, toa);
+               ta_val(lchan, chan_nr, chan_state, toa256);
 
        return 0;
 }
diff --git a/src/osmo-bts-trx/loops.h b/src/osmo-bts-trx/loops.h
index 230cd4f..f9e69c8 100644
--- a/src/osmo-bts-trx/loops.h
+++ b/src/osmo-bts-trx/loops.h
@@ -14,7 +14,7 @@
  */
 
 int trx_loop_sacch_input(struct l1sched_trx *l1t, uint8_t chan_nr,
-       struct l1sched_chan_state *chan_state, int8_t rssi, float toa);
+       struct l1sched_chan_state *chan_state, int8_t rssi, int16_t toa);
 
 int trx_loop_sacch_clock(struct l1sched_trx *l1t, uint8_t chan_nr,
         struct l1sched_chan_state *chan_state);
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 7e6f8cb..a680a18 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -714,7 +714,7 @@
 
 int rx_rach_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        uint8_t chan_nr;
        struct osmo_phsap_prim l1sap;
@@ -724,7 +724,7 @@
 
        chan_nr = trx_chan_desc[chan].chan_nr | tn;
 
-       LOGL1S(DL1P, LOGL_DEBUG, l1t, tn, chan, fn, "Received RACH toa=%.2f\n", 
toa);
+       LOGL1S(DL1P, LOGL_DEBUG, l1t, tn, chan, fn, "Received RACH toa=%d\n", 
toa256);
 
        /* decode */
        rc = gsm0503_rach_decode_ber(&ra, bits + 8 + 41, l1t->trx->bts->bsic, 
&n_errors, &n_bits_total);
@@ -744,7 +744,7 @@
 #warning TIMING ADVANCE TEST-HACK IS ENABLED!!!
        toa *= 10;
 #endif
-       l1sap.u.rach_ind.acc_delay = (toa >= 0) ? toa : 0;
+       l1sap.u.rach_ind.acc_delay = (toa256 >= 0) ? toa256/256 : 0;
        l1sap.u.rach_ind.fn = fn;
 
        /* 11bit RACH is not supported for osmo-trx */
@@ -752,7 +752,7 @@
        l1sap.u.rach_ind.burst_type = GSM_L1_BURST_TYPE_ACCESS_0;
        l1sap.u.rach_ind.rssi = rssi;
        l1sap.u.rach_ind.ber10k = compute_ber10k(n_bits_total, n_errors);
-       l1sap.u.rach_ind.acc_delay_qbits = 4*toa;
+       l1sap.u.rach_ind.acc_delay_qbits = toa256/(256/4);
 
        /* forward primitive */
        l1sap_up(l1t->trx, &l1sap);
@@ -763,7 +763,7 @@
 /*! \brief a single (SDCCH/SACCH) burst was received by the PHY, process it */
 int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
@@ -772,7 +772,7 @@
        uint8_t *mask = &chan_state->ul_mask;
        float *rssi_sum = &chan_state->rssi_sum;
        uint8_t *rssi_num = &chan_state->rssi_num;
-       float *toa_sum = &chan_state->toa_sum;
+       int32_t *toa256_sum = &chan_state->toa256_sum;
        uint8_t *toa_num = &chan_state->toa_num;
        uint8_t l2[GSM_MACBLOCK_LEN], l2_len;
        int n_errors, n_bits_total;
@@ -781,7 +781,7 @@
 
        /* handle RACH, if handover RACH detection is turned on */
        if (chan_state->ho_rach_detect == 1)
-               return rx_rach_fn(l1t, tn, fn, chan, bid, bits, GSM_BURST_LEN, 
rssi, toa);
+               return rx_rach_fn(l1t, tn, fn, chan, bid, bits, GSM_BURST_LEN, 
rssi, toa256);
 
        LOGL1S(DL1P, LOGL_DEBUG, l1t, tn, chan, fn, "Received Data, bid=%u\n", 
bid);
 
@@ -799,7 +799,7 @@
                *first_fn = fn;
                *rssi_sum = 0;
                *rssi_num = 0;
-               *toa_sum = 0;
+               *toa256_sum = 0;
                *toa_num = 0;
        }
 
@@ -807,7 +807,7 @@
        *mask |= (1 << bid);
        *rssi_sum += rssi;
        (*rssi_num)++;
-       *toa_sum += toa;
+       *toa256_sum += toa256;
        (*toa_num)++;
 
        /* copy burst to buffer of 4 bursts */
@@ -818,7 +818,7 @@
        /* send burst information to loops process */
        if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id)) {
                trx_loop_sacch_input(l1t, trx_chan_desc[chan].chan_nr | tn,
-                       chan_state, rssi, toa);
+                       chan_state, rssi, toa256);
        }
 
        /* wait until complete set of bursts */
@@ -849,18 +849,18 @@
 
        /* Send uplink measurement information to L2 */
        l1if_process_meas_res(l1t->trx, tn, *first_fn, 
trx_chan_desc[chan].chan_nr | tn,
-               n_errors, n_bits_total, *rssi_sum / *rssi_num, *toa_sum / 
*toa_num);
+               n_errors, n_bits_total, *rssi_sum / *rssi_num, *toa256_sum / 
*toa_num);
        ber10k = compute_ber10k(n_bits_total, n_errors);
        return _sched_compose_ph_data_ind(l1t, tn, *first_fn, chan, l2, l2_len,
                                          *rssi_sum / *rssi_num,
-                                         4 * (*toa_sum) / *toa_num, 0, ber10k,
+                                         4 * (*toa256_sum) / *toa_num, 0, 
ber10k,
                                          PRES_INFO_UNKNOWN);
 }
 
 /*! \brief a single PDTCH burst was received by the PHY, process it */
 int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
@@ -869,7 +869,7 @@
        uint8_t *mask = &chan_state->ul_mask;
        float *rssi_sum = &chan_state->rssi_sum;
        uint8_t *rssi_num = &chan_state->rssi_num;
-       float *toa_sum = &chan_state->toa_sum;
+       int32_t *toa256_sum = &chan_state->toa256_sum;
        uint8_t *toa_num = &chan_state->toa_num;
        uint8_t l2[EGPRS_0503_MAX_BYTES];
        int n_errors, n_bursts_bits, n_bits_total;
@@ -893,7 +893,7 @@
                *first_fn = fn;
                *rssi_sum = 0;
                *rssi_num = 0;
-               *toa_sum = 0;
+               *toa256_sum = 0;
                *toa_num = 0;
        }
 
@@ -901,7 +901,7 @@
        *mask |= (1 << bid);
        *rssi_sum += rssi;
        (*rssi_num)++;
-       *toa_sum += toa;
+       *toa256_sum += toa256;
        (*toa_num)++;
 
        /* copy burst to buffer of 4 bursts */
@@ -945,7 +945,7 @@
 
        /* Send uplink measurement information to L2 */
        l1if_process_meas_res(l1t->trx, tn, *first_fn, 
trx_chan_desc[chan].chan_nr | tn,
-               n_errors, n_bits_total, *rssi_sum / *rssi_num, *toa_sum / 
*toa_num);
+               n_errors, n_bits_total, *rssi_sum / *rssi_num, *toa256_sum / 
*toa_num);
 
        if (rc <= 0) {
                LOGL1S(DL1P, LOGL_DEBUG, l1t, tn, chan, fn, "Received bad PDTCH 
(%u/%u)\n",
@@ -954,14 +954,14 @@
        }
        ber10k = compute_ber10k(n_bits_total, n_errors);
        return _sched_compose_ph_data_ind(l1t, tn, (fn + GSM_HYPERFRAME - 3) % 
GSM_HYPERFRAME, chan,
-               l2, rc, *rssi_sum / *rssi_num, 4 * (*toa_sum) / *toa_num, 0,
+               l2, rc, *rssi_sum / *rssi_num, 4 * (*toa256_sum) / *toa_num, 0,
                                          ber10k, PRES_INFO_BOTH);
 }
 
 /*! \brief a single TCH/F burst was received by the PHY, process it */
 int rx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
@@ -978,7 +978,7 @@
 
        /* handle rach, if handover rach detection is turned on */
        if (chan_state->ho_rach_detect == 1)
-               return rx_rach_fn(l1t, tn, fn, chan, bid, bits, GSM_BURST_LEN, 
rssi, toa);
+               return rx_rach_fn(l1t, tn, fn, chan, bid, bits, GSM_BURST_LEN, 
rssi, toa256);
 
        LOGL1S(DL1P, LOGL_DEBUG, l1t, tn, chan, fn, "Received TCH/F, bid=%u\n", 
bid);
 
@@ -1057,7 +1057,7 @@
 
        /* Send uplink measurement information to L2 */
        l1if_process_meas_res(l1t->trx, tn, *first_fn, 
trx_chan_desc[chan].chan_nr|tn,
-               n_errors, n_bits_total, rssi, toa);
+               n_errors, n_bits_total, rssi, toa256);
 
        /* Check if the frame is bad */
        if (rc < 0) {
@@ -1075,7 +1075,7 @@
        if (rc == GSM_MACBLOCK_LEN) {
                uint16_t ber10k = compute_ber10k(n_bits_total, n_errors);
                _sched_compose_ph_data_ind(l1t, tn, (fn + GSM_HYPERFRAME - 7) % 
GSM_HYPERFRAME, chan,
-                       tch_data + amr, GSM_MACBLOCK_LEN, rssi, 4 * toa, 0,
+                       tch_data + amr, GSM_MACBLOCK_LEN, rssi, 4 * toa256, 0,
                                           ber10k, PRES_INFO_UNKNOWN);
 bfi:
                if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
@@ -1121,7 +1121,7 @@
 /*! \brief a single TCH/H burst was received by the PHY, process it */
 int rx_tchh_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
@@ -1143,7 +1143,7 @@
 
        /* handle RACH, if handover RACH detection is turned on */
        if (chan_state->ho_rach_detect == 1)
-               return rx_rach_fn(l1t, tn, fn, chan, bid, bits, GSM_BURST_LEN, 
rssi, toa);
+               return rx_rach_fn(l1t, tn, fn, chan, bid, bits, GSM_BURST_LEN, 
rssi, toa256);
 
        LOGL1S(DL1P, LOGL_DEBUG, l1t, tn, chan, fn, "Received TCH/H, bid=%u\n", 
bid);
 
@@ -1233,7 +1233,7 @@
 
        /* Send uplink measurement information to L2 */
        l1if_process_meas_res(l1t->trx, tn, *first_fn, 
trx_chan_desc[chan].chan_nr|tn,
-               n_errors, n_bits_total, rssi, toa);
+               n_errors, n_bits_total, rssi, toa256);
 
        /* Check if the frame is bad */
        if (rc < 0) {
@@ -1253,7 +1253,7 @@
                uint16_t ber10k = compute_ber10k(n_bits_total, n_errors);
                _sched_compose_ph_data_ind(l1t, tn,
                        (fn + GSM_HYPERFRAME - 10 - ((fn % 26) >= 19)) % 
GSM_HYPERFRAME, chan,
-                       tch_data + amr, GSM_MACBLOCK_LEN, rssi, 4 * toa, 0,
+                       tch_data + amr, GSM_MACBLOCK_LEN, rssi, toa256/64, 0,
                                           ber10k, PRES_INFO_UNKNOWN);
 bfi:
                if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index 35698ef..f3de245 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -520,7 +520,7 @@
        int len;
        uint8_t tn;
        int8_t rssi;
-       float toa = 0.0;
+       int16_t toa256 = 0;
        uint32_t fn;
        sbit_t bits[EGPRS_BURST_LEN];
        int i, burst_len = GSM_BURST_LEN;
@@ -539,7 +539,7 @@
        tn = buf[0];
        fn = (buf[1] << 24) | (buf[2] << 16) | (buf[3] << 8) | buf[4];
        rssi = -(int8_t)buf[5];
-       toa = ((int16_t)(buf[6] << 8) | buf[7]) / 256.0F;
+       toa256 = ((int16_t)(buf[6] << 8) | buf[7]);
 
        /* copy and convert bits {254..0} to sbits {-127..127} */
        for (i = 0; i < burst_len; i++) {
@@ -558,20 +558,20 @@
                return -EINVAL;
        }
 
-       LOGP(DTRX, LOGL_DEBUG, "RX burst tn=%u fn=%u rssi=%d toa=%.2f\n",
-               tn, fn, rssi, toa);
+       LOGP(DTRX, LOGL_DEBUG, "RX burst tn=%u fn=%u rssi=%d toa256=%d\n",
+               tn, fn, rssi, toa256);
 
 #ifdef TOA_RSSI_DEBUG
        char deb[128];
 
        sprintf(deb, "|                                0              "
-               "                 | rssi=%4d  toa=%4.2f fn=%u", rssi, toa, fn);
+               "                 | rssi=%4d  toa=%5d fn=%u", rssi, toa256, fn);
        deb[1 + (128 + rssi) / 4] = '*';
        fprintf(stderr, "%s\n", deb);
 #endif
 
        /* feed received burst into scheduler code */
-       trx_sched_ul_burst(&l1h->l1s, tn, fn, bits, burst_len, rssi, toa);
+       trx_sched_ul_burst(&l1h->l1s, tn, fn, bits, burst_len, rssi, toa256);
 
        return 0;
 }
diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c 
b/src/osmo-bts-virtual/scheduler_virtbts.c
index 2283be1..5782c0a 100644
--- a/src/osmo-bts-virtual/scheduler_virtbts.c
+++ b/src/osmo-bts-virtual/scheduler_virtbts.c
@@ -480,7 +480,7 @@
 
 int rx_rach_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        return 0;
 }
@@ -488,28 +488,28 @@
 /*! \brief a single burst was received by the PHY, process it */
 int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        return 0;
 }
 
 int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        return 0;
 }
 
 int rx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        return 0;
 }
 
 int rx_tchh_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
        enum trx_chan_type chan, uint8_t bid, sbit_t *bits, uint16_t nbits,
-       int8_t rssi, float toa)
+       int8_t rssi, int16_t toa256)
 {
        return 0;
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <lafo...@gnumonks.org>

Reply via email to