aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2013-06-06 13:24:40 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2014-04-06 08:58:05 +0200
commitb6b0a0b103b019a19532c549ab85b5525544a394 (patch)
treec7c67dce6de51e3ebe177a2bb9a020a907e039e1
parent28f7dce971e877b97548bb4c0e002b246ad0c7a3 (diff)
TRX: Report measurements
-rw-r--r--src/osmo-bts-trx/l1_if.c22
-rw-r--r--src/osmo-bts-trx/l1_if.h6
-rw-r--r--src/osmo-bts-trx/scheduler.c35
3 files changed, 55 insertions, 8 deletions
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index 116b4fbb..a09fa199 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -425,6 +425,23 @@ int l1if_mph_time_ind(struct gsm_bts *bts, uint32_t fn)
return l1sap_up(bts->c0, &l1sap);
}
+int l1if_process_meas_res(struct gsm_bts_trx *trx, uint8_t chan_nr, float qta,
+ float ber, float rssi)
+{
+ struct osmo_phsap_prim l1sap;
+
+ memset(&l1sap, 0, sizeof(l1sap));
+ osmo_prim_init(&l1sap.oph, SAP_GSM_PH, PRIM_MPH_INFO,
+ 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 = qta;
+ l1sap.u.info.u.meas_ind.ber10k = (unsigned int) (ber * 100);
+ l1sap.u.info.u.meas_ind.inv_rssi = (uint8_t) (rssi * -1);
+
+ return l1sap_up(trx, &l1sap);
+}
+
/* primitive from common part */
int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
@@ -487,6 +504,8 @@ int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
amr_get_initial_mode(lchan));
/* init lapdm */
lchan_init_lapdm(lchan);
+ /* set lchan active */
+ lchan_set_state(lchan, LCHAN_S_ACTIVE);
/* confirm */
mph_info_chan_confirm(l1h, chan_nr,
PRIM_INFO_ACTIVATE, 0);
@@ -511,6 +530,9 @@ int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap)
}
/* deactivate assoicated channel */
trx_sched_set_lchan(l1h, chan_nr, 0x40, 0);
+ /* set lchan inactive
+ * (also if only sacch, so no meaurement is done) */
+ lchan_set_state(lchan, LCHAN_S_NONE);
/* deactivate dedicated channel */
if (!l1sap->u.info.u.act_req.sacch_only) {
trx_sched_set_lchan(l1h, chan_nr, 0x00, 0);
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h
index deae874c..9e4a3f47 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -55,9 +55,11 @@ struct trx_chan_state {
uint32_t ul_first_fn; /* fn of first burst */
uint8_t ul_mask; /* mask of received bursts */
- /* RSSI */
+ /* RSSI / TOA */
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 */
/* loss detection */
uint8_t lost; /* (SACCH) loss detection */
@@ -164,5 +166,7 @@ int check_transceiver_availability(struct gsm_bts *bts, int avail);
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 chan_nr, float qta,
+ float ber, float rssi);
#endif /* L1_IF_H_TRX */
diff --git a/src/osmo-bts-trx/scheduler.c b/src/osmo-bts-trx/scheduler.c
index 9d6a8a97..20cafade 100644
--- a/src/osmo-bts-trx/scheduler.c
+++ b/src/osmo-bts-trx/scheduler.c
@@ -559,17 +559,19 @@ found_msg:
}
static int compose_ph_data_ind(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
- enum trx_chan_type chan, uint8_t *l2, uint8_t l2_len, float rssi)
+ enum trx_chan_type chan, uint8_t *l2, uint8_t l2_len, float toa,
+ float ber, float rssi)
{
struct msgb *msg;
struct osmo_phsap_prim *l1sap;
+ uint8_t chan_nr = trx_chan_desc[chan].chan_nr | tn;
/* compose primitive */
msg = l1sap_msgb_alloc(l2_len);
l1sap = msgb_l1sap_prim(msg);
osmo_prim_init(&l1sap->oph, SAP_GSM_PH, PRIM_PH_DATA,
PRIM_OP_INDICATION, msg);
- l1sap->u.data.chan_nr = trx_chan_desc[chan].chan_nr | tn;
+ l1sap->u.data.chan_nr = chan_nr;
l1sap->u.data.link_id = trx_chan_desc[chan].link_id;
l1sap->u.data.fn = fn;
l1sap->u.data.rssi = (int8_t) (rssi);
@@ -583,6 +585,12 @@ static int compose_ph_data_ind(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
/* forward primitive */
l1sap_up(l1h->trx, l1sap);
+ /* process measurement */
+ if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id))
+ l1if_process_meas_res(l1h->trx, chan_nr,
+ (l1h->trx->ts[tn].lchan[l1sap_chan2ss(chan_nr)].rqd_ta + toa) * 4,
+ ber, rssi);
+
return 0;
}
@@ -657,7 +665,8 @@ got_msg:
if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id)) {
/* count and send BFI */
if (++(l1h->chan_states[tn][chan].lost) > 1)
- compose_ph_data_ind(l1h, tn, 0, chan, NULL, 0, -128);
+ compose_ph_data_ind(l1h, tn, 0, chan, NULL, 0, 0, 0,
+ -110);
}
/* alloc burst memory, if not already */
@@ -1205,6 +1214,8 @@ static int rx_data_fn(struct trx_l1h *l1h, 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;
+ uint8_t *toa_num = &chan_state->toa_num;
uint8_t l2[23], l2_len;
int rc;
@@ -1225,12 +1236,16 @@ static int rx_data_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
*first_fn = fn;
*rssi_sum = 0;
*rssi_num = 0;
+ *toa_sum = 0;
+ *toa_num = 0;
}
/* update mask + rssi */
*mask |= (1 << bid);
*rssi_sum += rssi;
(*rssi_num)++;
+ *toa_sum += toa;
+ (*toa_num)++;
/* copy burst to buffer of 4 bursts */
burst = *bursts_p + bid * 116;
@@ -1274,7 +1289,7 @@ static int rx_data_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
l2_len = 23;
return compose_ph_data_ind(l1h, tn, *first_fn, chan, l2, l2_len,
- *rssi_sum / *rssi_num);
+ *toa_sum / *toa_num, 0, *rssi_sum / *rssi_num);
}
static int rx_pdtch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
@@ -1286,6 +1301,8 @@ static int rx_pdtch_fn(struct trx_l1h *l1h, 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;
+ uint8_t *toa_num = &chan_state->toa_num;
uint8_t l2[54+1];
int rc;
@@ -1305,12 +1322,16 @@ static int rx_pdtch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
*mask = 0x0;
*rssi_sum = 0;
*rssi_num = 0;
+ *toa_sum = 0;
+ *toa_num = 0;
}
/* update mask + rssi */
*mask |= (1 << bid);
*rssi_sum += rssi;
(*rssi_num)++;
+ *toa_sum += toa;
+ (*toa_num)++;
/* copy burst to buffer of 4 bursts */
burst = *bursts_p + bid * 116;
@@ -1342,7 +1363,7 @@ static int rx_pdtch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
l2[0] = 7; /* valid frame */
return compose_ph_data_ind(l1h, tn, (fn + 2715648 - 3) % 2715648, chan,
- l2, rc + 1, *rssi_sum / *rssi_num);
+ l2, rc + 1, *toa_sum / *toa_num, 0, *rssi_sum / *rssi_num);
}
static int rx_tchf_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
@@ -1447,7 +1468,7 @@ static int rx_tchf_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
/* FACCH */
if (rc == 23) {
compose_ph_data_ind(l1h, tn, (fn + 2715648 - 7) % 2715648, chan,
- tch_data + amr, 23, rssi);
+ tch_data + amr, 23, 0, 0, 0);
bfi:
if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
/* indicate bad frame */
@@ -1601,7 +1622,7 @@ static int rx_tchh_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
chan_state->ul_ongoing_facch = 1;
compose_ph_data_ind(l1h, tn,
(fn + 2715648 - 10 - ((fn % 26) >= 19)) % 2715648, chan,
- tch_data + amr, 23, rssi);
+ tch_data + amr, 23, 0, 0, 0);
bfi:
if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
/* indicate bad frame */