This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/2741 scheduler_trx.c: Avoid code duplication for BER10k computation Use an (inline) function rather than code copy+pasting Change-Id: I42e76a4707968e428cbd2e43d5df71ef445efece --- M src/osmo-bts-trx/scheduler_trx.c 1 file changed, 16 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/41/2741/1 diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c index 843ab39..1ca371d 100644 --- a/src/osmo-bts-trx/scheduler_trx.c +++ b/src/osmo-bts-trx/scheduler_trx.c @@ -61,6 +61,16 @@ /* Maximum size of a EGPRS message in bytes */ #define EGPRS_0503_MAX_BYTES 155 + +/* Compute the bit error rate in 1/10000 units */ +static inline uint16_t compute_ber10k(int n_bits_total, int n_errors) +{ + if (n_bits_total == 0) + return 10000; + else + return 10000 * n_errors / n_bits_total; +} + /* * TX on downlink */ @@ -819,6 +829,7 @@ uint8_t *toa_num = &chan_state->toa_num; uint8_t l2[GSM_MACBLOCK_LEN], l2_len; int n_errors, n_bits_total; + uint16_t ber10k; int rc; /* handle RACH, if handover RACH detection is turned on */ @@ -897,8 +908,7 @@ /* Send uplink measurement information to L2 */ l1if_process_meas_res(l1t->trx, tn, fn, trx_chan_desc[chan].chan_nr | tn, n_errors, n_bits_total, *rssi_sum / *rssi_num, *toa_sum / *toa_num); - uint16_t ber10k = - (n_bits_total == 0) ? 10000 : 10000 * n_errors / n_bits_total; + 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, @@ -920,6 +930,7 @@ uint8_t *toa_num = &chan_state->toa_num; uint8_t l2[EGPRS_0503_MAX_BYTES]; int n_errors, n_bursts_bits, n_bits_total; + uint16_t ber10k; int rc; LOGP(DL1C, LOGL_DEBUG, "PDTCH received %s fn=%u ts=%u trx=%u bid=%u\n", @@ -1001,8 +1012,7 @@ l1ts->mf_period, trx_chan_desc[chan].name); return 0; } - uint16_t ber10k = - (n_bits_total == 0) ? 10000 : 10000 * n_errors / n_bits_total; + 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, ber10k, PRES_INFO_BOTH); @@ -1124,8 +1134,7 @@ /* FACCH */ if (rc == GSM_MACBLOCK_LEN) { - uint16_t ber10k = (n_bits_total == 0) ? 10000 : - 10000 * n_errors / n_bits_total; + 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, ber10k, PRES_INFO_UNKNOWN); @@ -1299,8 +1308,7 @@ /* FACCH */ if (rc == GSM_MACBLOCK_LEN) { chan_state->ul_ongoing_facch = 1; - uint16_t ber10k = - (n_bits_total == 0) ? 10000 : 10000 * n_errors / n_bits_total; + 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, -- To view, visit https://gerrit.osmocom.org/2741 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I42e76a4707968e428cbd2e43d5df71ef445efece Gerrit-PatchSet: 1 Gerrit-Project: osmo-bts Gerrit-Branch: master Gerrit-Owner: Harald Welte <laforge at gnumonks.org>