From d71e8b32e3e2f9c3856997e945df2eb3afe2937c Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 19 Sep 2016 16:17:06 +0200 Subject: Use qbit-TA to update Timing Advance Separate qbit-TA to TA conversion into separate function and use it for computing and updating Timing Advance. Note: the code was tested with TA=0 only to make sure it does not introduce regressions. Change-Id: I96fdbb20b09fb85fdd9fb6dcf3c25f6bee7f80e4 Fixes: OS#1531 --- src/bts.cpp | 27 ++++++++++++++++++--------- src/bts.h | 9 +++++++++ src/osmo-bts-litecell15/lc15_l1_if.c | 26 +++++--------------------- src/osmo-bts-sysmo/sysmo_l1_if.c | 26 +++++--------------------- src/pcu_l1_if.h | 9 +++++++++ 5 files changed, 46 insertions(+), 51 deletions(-) diff --git a/src/bts.cpp b/src/bts.cpp index 35da3076..4aa5c2c2 100644 --- a/src/bts.cpp +++ b/src/bts.cpp @@ -478,8 +478,7 @@ int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, int rc; int plen; uint8_t usf = 7; - uint8_t tsc; - uint16_t ta; + uint8_t tsc, ta = qta2ta(qta); uint16_t ms_class = 0; uint16_t priority = 0; @@ -490,13 +489,6 @@ int BTS::rcv_rach(uint16_t ra, uint32_t Fn, int16_t qta, uint8_t is_11bit, sb = is_single_block(ra, burst_type, is_11bit, &ms_class, &priority); - if (qta < 0) - qta = 0; - if (qta > 252) - qta = 252; - - ta = qta >> 2; - if (sb) { rc = sba()->alloc(&trx_no, &ts_no, &sb_fn, ta); if (rc < 0) @@ -1475,6 +1467,23 @@ int gprs_rlcmac_pdch::rcv_block_gprs(uint8_t *data, uint32_t fn, return rc; } +void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, + uint8_t ta) +{ + struct gprs_rlcmac_ul_tbf *tbf = + bts_main_data()->bts->ul_tbf_by_poll_fn(fn, trx_no, ts); + if (!tbf) + LOGP(DL1IF, LOGL_DEBUG, "[%s] update TA = %u ignored due to " + "unknown UL TBF on TRX = %d, TS = %d, FN = %d\n", + p, ta, trx_no, ts, fn); + else if (tbf->ta() != ta) { + LOGP(DL1IF, LOGL_INFO, "[%s] Updating TA %u -> %u on " + "TRX = %d, TS = %d, FN = %d\n", + p, tbf->ta(), ta, trx_no, ts, fn); + tbf->set_ta(ta); + } +} + gprs_rlcmac_tbf *gprs_rlcmac_pdch::tbf_from_list_by_tfi( LListHead *tbf_list, uint8_t tfi, enum gprs_rlcmac_tbf_direction dir) diff --git a/src/bts.h b/src/bts.h index ba6fc4d0..8bea371f 100644 --- a/src/bts.h +++ b/src/bts.h @@ -143,6 +143,15 @@ struct gprs_rlcmac_trx { #endif }; +#ifdef __cplusplus +extern "C" { +#endif +void bts_update_tbf_ta(const char *p, uint32_t fn, uint8_t trx_no, uint8_t ts, + uint8_t ta); +#ifdef __cplusplus +} +#endif + /** * This is the data from C. As soon as our minimal compiler is gcc 4.7 * we can start to compile pcu_vty.c with c++ and remove the split. diff --git a/src/osmo-bts-litecell15/lc15_l1_if.c b/src/osmo-bts-litecell15/lc15_l1_if.c index a6358ba5..12a977ba 100644 --- a/src/osmo-bts-litecell15/lc15_l1_if.c +++ b/src/osmo-bts-litecell15/lc15_l1_if.c @@ -32,6 +32,7 @@ #include #include #include +#include extern void *tall_pcu_ctx; @@ -204,6 +205,8 @@ static int handle_ph_data_ind(struct lc15l1_hdl *fl1h, data_ind->msgUnitParam.u8Size-1); get_meas(&meas, &data_ind->measParam); + bts_update_tbf_ta("PH-DATA", data_ind->u32Fn, fl1h->trx_no, + data_ind->u8Tn, qta2ta(meas.bto)); switch (data_ind->sapi) { case GsmL1_Sapi_Pdtch: @@ -235,31 +238,12 @@ static int handle_ph_data_ind(struct lc15l1_hdl *fl1h, static int handle_ph_ra_ind(struct lc15l1_hdl *fl1h, GsmL1_PhRaInd_t *ra_ind) { - uint8_t acc_delay; - if (ra_ind->measParam.fLinkQuality < MIN_QUAL_RACH) return 0; DEBUGP(DL1IF, "Rx PH-RA.ind"); - - /* check for under/overflow / sign */ - if (ra_ind->measParam.i16BurstTiming < 0) - acc_delay = 0; - else - acc_delay = ra_ind->measParam.i16BurstTiming >> 2; - - LOGP(DL1IF, LOGL_NOTICE, "got (P)RACH request, TA = %u (ignored)\n", - acc_delay); - -#warning "The (P)RACH request is just dropped here" - -#if 0 - if (acc_delay > bts->max_ta) { - LOGP(DL1C, LOGL_INFO, "ignoring RACH request %u > max_ta(%u)\n", - acc_delay, btsb->max_ta); - return 0; - } -#endif + bts_update_tbf_ta("PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn, + qta2ta(ra_ind->measParam.i16BurstTiming)); return 0; } diff --git a/src/osmo-bts-sysmo/sysmo_l1_if.c b/src/osmo-bts-sysmo/sysmo_l1_if.c index 75a2d5f3..8994ac30 100644 --- a/src/osmo-bts-sysmo/sysmo_l1_if.c +++ b/src/osmo-bts-sysmo/sysmo_l1_if.c @@ -13,6 +13,7 @@ #include #include #include +#include extern void *tall_pcu_ctx; @@ -189,6 +190,8 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1h, data_ind->msgUnitParam.u8Size-1); get_meas(&meas, &data_ind->measParam); + bts_update_tbf_ta("PH-DATA", data_ind->u32Fn, fl1h->trx_no, + data_ind->u8Tn, qta2ta(meas.bto)); switch (data_ind->sapi) { case GsmL1_Sapi_Pdtch: @@ -220,33 +223,14 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1h, static int handle_ph_ra_ind(struct femtol1_hdl *fl1h, GsmL1_PhRaInd_t *ra_ind) { - uint8_t acc_delay; - pcu_rx_ra_time(ra_ind->u16Arfcn, ra_ind->u32Fn, ra_ind->u8Tn); if (ra_ind->measParam.fLinkQuality < MIN_QUAL_RACH) return 0; DEBUGP(DL1IF, "Rx PH-RA.ind"); - - /* check for under/overflow / sign */ - if (ra_ind->measParam.i16BurstTiming < 0) - acc_delay = 0; - else - acc_delay = ra_ind->measParam.i16BurstTiming >> 2; - - LOGP(DL1IF, LOGL_NOTICE, "got (P)RACH request, TA = %u (ignored)\n", - acc_delay); - -#warning "The (P)RACH request is just dropped here" - -#if 0 - if (acc_delay > bts->max_ta) { - LOGP(DL1C, LOGL_INFO, "ignoring RACH request %u > max_ta(%u)\n", - acc_delay, btsb->max_ta); - return 0; - } -#endif + bts_update_tbf_ta("PH-RA", ra_ind->u32Fn, fl1h->trx_no, ra_ind->u8Tn, + qta2ta(ra_ind->measParam.i16BurstTiming)); return 0; } diff --git a/src/pcu_l1_if.h b/src/pcu_l1_if.h index b2a9832e..d9d970da 100644 --- a/src/pcu_l1_if.h +++ b/src/pcu_l1_if.h @@ -33,6 +33,15 @@ extern "C" { } #endif +static inline uint8_t qta2ta(int16_t qta) +{ + if (qta < 0) + return 0; + if (qta > 252) + qta = 252; + return qta >> 2; +} + /* * L1 Measurement values */ -- cgit v1.2.3