From d5bbd8ccf79eaf13bc23cc71accbeb3ff638b6dd Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 19 Feb 2018 14:21:36 +0100 Subject: 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 --- include/osmo-bts/scheduler.h | 6 ++-- include/osmo-bts/scheduler_backend.h | 12 +++---- src/common/scheduler.c | 4 +-- src/osmo-bts-trx/l1_if.c | 12 +++---- src/osmo-bts-trx/l1_if.h | 2 +- src/osmo-bts-trx/loops.c | 31 +++++++++--------- src/osmo-bts-trx/loops.h | 2 +- src/osmo-bts-trx/scheduler_trx.c | 54 ++++++++++++++++---------------- src/osmo-bts-trx/trx_if.c | 12 +++---- src/osmo-bts-virtual/scheduler_virtbts.c | 10 +++--- 10 files changed, 74 insertions(+), 71 deletions(-) diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h index 4d34315f..98f38d39 100644 --- a/include/osmo-bts/scheduler.h +++ b/include/osmo-bts/scheduler.h @@ -75,7 +75,7 @@ struct l1sched_chan_state { 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 @@ struct l1sched_chan_state { 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 @@ int trx_sched_clock(struct gsm_bts *bts, uint32_t fn); /*! \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 5e077eff..5f11f9bc 100644 --- a/include/osmo-bts/scheduler_backend.h +++ b/include/osmo-bts/scheduler_backend.h @@ -16,7 +16,7 @@ typedef ubit_t *trx_sched_dl_func(struct l1sched_trx *l1t, uint8_t tn, 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 @@ ubit_t *tx_tchh_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, 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 e6cf541d..edd99d26 100644 --- a/src/common/scheduler.c +++ b/src/common/scheduler.c @@ -846,7 +846,7 @@ no_data: /* 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 @@ int trx_sched_ul_burst(struct l1sched_trx *l1t, uint8_t tn, uint32_t current_fn, } } - 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 a5fbf5ca..4d2558c8 100644 --- a/src/osmo-bts-trx/l1_if.c +++ b/src/osmo-bts-trx/l1_if.c @@ -487,7 +487,7 @@ int l1if_mph_time_ind(struct gsm_bts *bts, uint32_t fn) } -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 @@ static void l1if_fill_meas_res(struct osmo_phsap_prim *l1sap, uint8_t chan_nr, f 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 @@ int l1if_process_meas_res(struct gsm_bts_trx *trx, uint8_t tn, uint32_t fn, uint 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 1974efcc..77c5936c 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_trx(struct trx_l1h *l1h); 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 6f87cd1f..a959a71e 100644 --- a/src/osmo-bts-trx/loops.c +++ b/src/osmo-bts-trx/loops.c @@ -166,12 +166,15 @@ static int ms_power_clock(struct gsm_lchan *lchan, } +/* 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 @@ int ta_val(struct gsm_lchan *lchan, uint8_t chan_nr, 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 @@ int trx_loop_sacch_input(struct l1sched_trx *l1t, uint8_t chan_nr, 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 230cd4fa..f9e69c84 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 43cc30b0..cefde072 100644 --- a/src/osmo-bts-trx/scheduler_trx.c +++ b/src/osmo-bts-trx/scheduler_trx.c @@ -714,7 +714,7 @@ send_burst: 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 @@ int rx_rach_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, 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); @@ -742,9 +742,9 @@ int rx_rach_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, l1sap.u.rach_ind.ra = ra; #ifdef TA_TEST #warning TIMING ADVANCE TEST-HACK IS ENABLED!!! - toa *= 10; + toa256 *= 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 @@ int rx_rach_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, 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_256bits = 256*toa; + l1sap.u.rach_ind.acc_delay_256bits = toa256; /* forward primitive */ l1sap_up(l1t->trx, &l1sap); @@ -763,7 +763,7 @@ int rx_rach_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /*! \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 @@ int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, 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 @@ int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /* 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 @@ int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, *first_fn = fn; *rssi_sum = 0; *rssi_num = 0; - *toa_sum = 0; + *toa256_sum = 0; *toa_num = 0; } @@ -807,7 +807,7 @@ int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, *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 @@ int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /* 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 @@ int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /* 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 @@ int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, 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 @@ int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, *first_fn = fn; *rssi_sum = 0; *rssi_num = 0; - *toa_sum = 0; + *toa256_sum = 0; *toa_num = 0; } @@ -901,7 +901,7 @@ int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, *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 @@ int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /* 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 @@ int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, } 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 @@ int rx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /* 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 @@ int rx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /* 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 @@ int rx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, 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 @@ bfi: /*! \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 @@ int rx_tchh_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /* 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 @@ int rx_tchh_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /* 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 @@ int rx_tchh_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, 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 35698ef5..f3de2453 100644 --- a/src/osmo-bts-trx/trx_if.c +++ b/src/osmo-bts-trx/trx_if.c @@ -520,7 +520,7 @@ static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what) 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 @@ static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what) 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 @@ static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what) 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 2283be1f..5782c0a5 100644 --- a/src/osmo-bts-virtual/scheduler_virtbts.c +++ b/src/osmo-bts-virtual/scheduler_virtbts.c @@ -480,7 +480,7 @@ send_burst: 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 @@ int rx_rach_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn, /*! \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; } -- cgit v1.2.3