diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-10-22 01:18:58 +0300 |
---|---|---|
committer | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2021-10-22 02:51:36 +0300 |
commit | 45094096b13e1dae2d7d697a3b220321322cca0e (patch) | |
tree | fc990ceac41eb35ec733b0b317c4761f69982731 | |
parent | 31637b467325dd456bfb0d23666648db49711305 (diff) |
measurement: move repeated_dl_facch_active_decision() here
For the sake of consistency, call repeated_dl_facch_active_decision()
from handle_ms_meas_report(), so we have all functions using the
measurement results for Downlink executed in a single place.
Change-Id: Ibd5377ce642e49161f320ac8c33e9f966b3ddfaf
Related: SYS#5114, SYS#5319
-rw-r--r-- | include/osmo-bts/l1sap.h | 3 | ||||
-rw-r--r-- | src/common/l1sap.c | 74 | ||||
-rw-r--r-- | src/common/measurement.c | 76 | ||||
-rw-r--r-- | src/common/rsl.c | 1 |
4 files changed, 76 insertions, 78 deletions
diff --git a/include/osmo-bts/l1sap.h b/include/osmo-bts/l1sap.h index f78d1143..93c532f8 100644 --- a/include/osmo-bts/l1sap.h +++ b/include/osmo-bts/l1sap.h @@ -144,7 +144,4 @@ int bts_check_for_first_ciphrd(struct gsm_lchan *lchan, int is_ccch_for_agch(struct gsm_bts_trx *trx, uint32_t fn); -void repeated_dl_facch_active_decision(struct gsm_lchan *lchan, - const uint8_t *l3, size_t l3_len); - #endif /* L1SAP_H */ diff --git a/src/common/l1sap.c b/src/common/l1sap.c index f5d23646..a6cd21d7 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -1026,80 +1026,6 @@ static inline struct msgb *lapdm_phsap_dequeue_msg_facch(struct gsm_lchan *lchan return msg; } -/* Decide if repeated FACCH should be applied or not. If RXQUAL level, that the - * MS reports is high enough, FACCH repetition is not needed. */ -void repeated_dl_facch_active_decision(struct gsm_lchan *lchan, const uint8_t *l3, - size_t l3_len) -{ - const struct gsm48_meas_res *meas_res; - uint8_t upper; - uint8_t lower; - uint8_t rxqual; - bool prev_repeated_dl_facch_active = lchan->repeated_dl_facch_active; - - /* This is an optimization so that we exit as quickly as possible if - * there are no FACCH repetition capabilities present. However If the - * repeated FACCH capabilities vanish for whatever reason, we must be - * sure that FACCH repetition is disabled. */ - if (!lchan->repeated_acch_capability.dl_facch_cmd - && !lchan->repeated_acch_capability.dl_facch_all) { - lchan->repeated_dl_facch_active = false; - goto out; - } - - /* Threshold disabled (always on) */ - if (lchan->repeated_acch_capability.rxqual == 0) { - lchan->repeated_dl_facch_active = true; - goto out; - } - - /* When the MS sets the SRR bit in the UL-SACCH L1 header - * (repeated SACCH requested) then it makes sense to enable - * FACCH repetition too. */ - if (lchan->meas.l1_info.srr_sro) { - lchan->repeated_dl_facch_active = true; - goto out; - } - - /* Parse MS measurement results */ - if (l3_len <= sizeof(struct gsm48_meas_res *) + 2) - goto out; - if (l3[0] != GSM48_PDISC_RR) - goto out; - if (l3[1] != GSM48_MT_RR_MEAS_REP) - goto out; - l3 += 2; - meas_res = (struct gsm48_meas_res *)l3; - - /* If the RXQUAL level at the MS drops under a certain threshold - * we enable FACCH repetition. */ - upper = lchan->repeated_acch_capability.rxqual; - if (upper > 2) - lower = lchan->repeated_acch_capability.rxqual - 2; - else - lower = 0; - - /* When downlink DTX is applied, use RXQUAL-SUB, otherwise use - * RXQUAL-FULL. */ - if (meas_res->dtx_used) - rxqual = meas_res->rxqual_sub; - else - rxqual = meas_res->rxqual_full; - - if (rxqual >= upper) - lchan->repeated_dl_facch_active = true; - else if (rxqual <= lower) - lchan->repeated_dl_facch_active = false; - -out: - if (lchan->repeated_dl_facch_active == prev_repeated_dl_facch_active) - return; - if (lchan->repeated_dl_facch_active) - LOGPLCHAN(lchan, DL1P, LOGL_DEBUG, "DL-FACCH repetition: inactive => active\n"); - else - LOGPLCHAN(lchan, DL1P, LOGL_DEBUG, "DL-FACCH repetition: active => inactive\n"); -} - /* Special dequeueing function with SACCH repetition (3GPP TS 44.006, section 11) */ static inline struct msgb *lapdm_phsap_dequeue_msg_sacch(struct gsm_lchan *lchan, struct lapdm_entity *le) { diff --git a/src/common/measurement.c b/src/common/measurement.c index 0a8a1825..3a178691 100644 --- a/src/common/measurement.c +++ b/src/common/measurement.c @@ -789,6 +789,80 @@ static inline bool ms_to_valid(const struct gsm_lchan *lchan) return (lchan->ms_t_offs >= 0) || (lchan->p_offs >= 0); } +/* Decide if repeated FACCH should be applied or not. If RXQUAL level, that the + * MS reports is high enough, FACCH repetition is not needed. */ +static void repeated_dl_facch_active_decision(struct gsm_lchan *lchan, + const struct gsm48_hdr *gh) +{ + const struct gsm48_meas_res *meas_res; + uint8_t upper; + uint8_t lower; + uint8_t rxqual; + bool prev_repeated_dl_facch_active = lchan->repeated_dl_facch_active; + + /* This is an optimization so that we exit as quickly as possible if + * there are no FACCH repetition capabilities present. However If the + * repeated FACCH capabilities vanish for whatever reason, we must be + * sure that FACCH repetition is disabled. */ + if (!lchan->repeated_acch_capability.dl_facch_cmd + && !lchan->repeated_acch_capability.dl_facch_all) { + lchan->repeated_dl_facch_active = false; + goto out; + } + + /* Threshold disabled (always on) */ + if (lchan->repeated_acch_capability.rxqual == 0) { + lchan->repeated_dl_facch_active = true; + goto out; + } + + /* When the MS sets the SRR bit in the UL-SACCH L1 header + * (repeated SACCH requested) then it makes sense to enable + * FACCH repetition too. */ + if (lchan->meas.l1_info.srr_sro) { + lchan->repeated_dl_facch_active = true; + goto out; + } + + /* Parse MS measurement results */ + if (gh == NULL) + goto out; + /* Check if this is a Measurement Report */ + if (gh->proto_discr != GSM48_PDISC_RR) + goto out; + if (gh->msg_type != GSM48_MT_RR_MEAS_REP) + goto out; + meas_res = (const struct gsm48_meas_res *) gh->data; + + /* If the RXQUAL level at the MS drops under a certain threshold + * we enable FACCH repetition. */ + upper = lchan->repeated_acch_capability.rxqual; + if (upper > 2) + lower = lchan->repeated_acch_capability.rxqual - 2; + else + lower = 0; + + /* When downlink DTX is applied, use RXQUAL-SUB, otherwise use + * RXQUAL-FULL. */ + if (meas_res->dtx_used) + rxqual = meas_res->rxqual_sub; + else + rxqual = meas_res->rxqual_full; + + if (rxqual >= upper) + lchan->repeated_dl_facch_active = true; + else if (rxqual <= lower) + lchan->repeated_dl_facch_active = false; + +out: + if (lchan->repeated_dl_facch_active == prev_repeated_dl_facch_active) + return; + if (lchan->repeated_dl_facch_active) + LOGPLCHAN(lchan, DL1P, LOGL_DEBUG, "DL-FACCH repetition: inactive => active\n"); + else + LOGPLCHAN(lchan, DL1P, LOGL_DEBUG, "DL-FACCH repetition: active => inactive\n"); +} + /* Called every time a Measurement Result (TS 08.58 8.4.8) is received from * lower layers and has to be forwarded to BSC */ int handle_ms_meas_report(struct gsm_lchan *lchan, @@ -853,6 +927,8 @@ int handle_ms_meas_report(struct gsm_lchan *lchan, if (gh) lchan_bs_pwr_ctrl(lchan, gh); + repeated_dl_facch_active_decision(lchan, gh); + /* Reset state for next iteration */ lchan->tch.dtx.dl_active = false; lchan->meas.flags &= ~LC_UL_M_F_OSMO_EXT_VALID; diff --git a/src/common/rsl.c b/src/common/rsl.c index 3cbfff63..11f2f862 100644 --- a/src/common/rsl.c +++ b/src/common/rsl.c @@ -3586,7 +3586,6 @@ int lapdm_rll_tx_cb(struct msgb *msg, struct lapdm_entity *le, void *ctx) return 0; } - repeated_dl_facch_active_decision(lchan, msgb_l3(msg), msgb_l3len(msg)); rc = handle_ms_meas_report(lchan, (struct gsm48_hdr *)msgb_l3(msg), msgb_l3len(msg)); msgb_free(msg); return rc; |