diff options
author | Andreas Eversberg <jolly@eversberg.eu> | 2013-03-16 16:46:13 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2015-09-22 16:41:27 +0200 |
commit | 5e2341411f25f4faa66ff9b4506e77d897b97daf (patch) | |
tree | c6bc4b0e7cf9cf9fd0b2aa6347eec61fa0fbc440 /src | |
parent | 917cf7018b6a9ec778add719fcec1692f0e35931 (diff) |
Get RSSI from received uplink data and send to PCU
Diffstat (limited to 'src')
-rw-r--r-- | src/common/pcu_sock.c | 1 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/l1_if.c | 5 | ||||
-rw-r--r-- | src/osmo-bts-trx/l1_if.h | 4 | ||||
-rw-r--r-- | src/osmo-bts-trx/scheduler.c | 28 |
4 files changed, 30 insertions, 8 deletions
diff --git a/src/common/pcu_sock.c b/src/common/pcu_sock.c index a4ca25f1..577cfcfa 100644 --- a/src/common/pcu_sock.c +++ b/src/common/pcu_sock.c @@ -330,6 +330,7 @@ int pcu_tx_data_ind(struct gsm_bts_trx_ts *ts, uint8_t is_ptcch, uint32_t fn, data_ind = &pcu_prim->u.data_ind; data_ind->sapi = (is_ptcch) ? PCU_IF_SAPI_PTCCH : PCU_IF_SAPI_PDTCH; + data_ind->rssi = rssi; data_ind->fn = fn; data_ind->arfcn = arfcn; data_ind->trx_nr = ts->trx->nr; diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index e2ad500f..12749dd3 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -841,6 +841,7 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1, GsmL1_PhDataInd_t *data_i uint32_t fn; uint8_t *data, len; int rc = 0; + int8_t rssi; chan_nr = chan_nr_by_sapi(trx->ts[data_ind->u8Tn].pchan, data_ind->sapi, data_ind->subCh, data_ind->u8Tn, data_ind->u32Fn); @@ -877,6 +878,8 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1, GsmL1_PhDataInd_t *data_i return rc; } + /* get rssi */ + rssi = (int8_t) (data_ind->measParam.fRssi); /* get data pointer and length */ data = data_ind->msgUnitParam.u8Buffer; len = data_ind->msgUnitParam.u8Size; @@ -893,10 +896,10 @@ static int handle_ph_data_ind(struct femtol1_hdl *fl1, GsmL1_PhDataInd_t *data_i l1sap = msgb_l1sap_prim(l1p_msg); osmo_prim_init(&l1sap->oph, SAP_GSM_PH, PRIM_PH_DATA, PRIM_OP_INDICATION, l1p_msg); - l1sap->u.data.rssi = data_ind->measParam.fRssi; l1sap->u.data.link_id = link_id; l1sap->u.data.chan_nr = chan_nr; l1sap->u.data.fn = fn; + l1sap->u.data.rssi = rssi; return l1sap_up(trx, l1sap); } diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h index 459496f6..ff5c3913 100644 --- a/src/osmo-bts-trx/l1_if.h +++ b/src/osmo-bts-trx/l1_if.h @@ -55,6 +55,10 @@ struct trx_chan_state { uint32_t ul_first_fn; /* fn of first burst */ uint8_t ul_mask; /* mask of received bursts */ + /* RSSI */ + uint8_t rssi_num; /* number of RSSI values */ + float rssi_sum; /* sum of RSSI values */ + /* loss detection */ uint8_t lost; /* (SACCH) loss detection */ diff --git a/src/osmo-bts-trx/scheduler.c b/src/osmo-bts-trx/scheduler.c index f1a0b629..6a40f97d 100644 --- a/src/osmo-bts-trx/scheduler.c +++ b/src/osmo-bts-trx/scheduler.c @@ -556,7 +556,7 @@ 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) + enum trx_chan_type chan, uint8_t *l2, uint8_t l2_len, float rssi) { struct msgb *msg; struct osmo_phsap_prim *l1sap; @@ -569,6 +569,7 @@ static int compose_ph_data_ind(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, l1sap->u.data.chan_nr = trx_chan_desc[chan].chan_nr | tn; l1sap->u.data.link_id = trx_chan_desc[chan].link_id; l1sap->u.data.fn = fn; + l1sap->u.data.rssi = (int8_t) (rssi); msg->l2h = msgb_put(msg, l2_len); if (l2_len) memcpy(msg->l2h, l2, l2_len); @@ -653,7 +654,7 @@ 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); + compose_ph_data_ind(l1h, tn, 0, chan, NULL, 0, -128); } /* alloc burst memory, if not already */ @@ -1023,6 +1024,8 @@ static int rx_data_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, sbit_t *burst, **bursts_p = &chan_state->ul_bursts; uint32_t *first_fn = &chan_state->ul_first_fn; uint8_t *mask = &chan_state->ul_mask; + float *rssi_sum = &chan_state->rssi_sum; + uint8_t *rssi_num = &chan_state->rssi_num; uint8_t l2[23], l2_len; int rc; @@ -1041,10 +1044,14 @@ static int rx_data_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, memset(*bursts_p, 0, 464); *mask = 0x0; *first_fn = fn; + *rssi_sum = 0; + *rssi_num = 0; } - /* update mask */ + /* update mask + rssi */ *mask |= (1 << bid); + *rssi_sum += rssi; + (*rssi_num)++; /* copy burst to buffer of 4 bursts */ burst = *bursts_p + bid * 116; @@ -1087,7 +1094,8 @@ static int rx_data_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, } else l2_len = 23; - return compose_ph_data_ind(l1h, tn, *first_fn, chan, l2, l2_len); + return compose_ph_data_ind(l1h, tn, *first_fn, chan, l2, l2_len, + *rssi_sum / *rssi_num); } static int rx_pdtch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, @@ -1097,6 +1105,8 @@ static int rx_pdtch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, struct trx_chan_state *chan_state = &l1h->chan_states[tn][chan]; sbit_t *burst, **bursts_p = &chan_state->ul_bursts; uint8_t *mask = &chan_state->ul_mask; + float *rssi_sum = &chan_state->rssi_sum; + uint8_t *rssi_num = &chan_state->rssi_num; uint8_t l2[54+1]; int rc; @@ -1114,10 +1124,14 @@ static int rx_pdtch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, if (bid == 0) { memset(*bursts_p, 0, 464); *mask = 0x0; + *rssi_sum = 0; + *rssi_num = 0; } - /* update mask */ + /* update mask + rssi */ *mask |= (1 << bid); + *rssi_sum += rssi; + (*rssi_num)++; /* copy burst to buffer of 4 bursts */ burst = *bursts_p + bid * 116; @@ -1149,7 +1163,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); + l2, rc + 1, *rssi_sum / *rssi_num); } static int rx_tchf_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn, @@ -1232,7 +1246,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, 23); + tch_data, 23, rssi); bfi: if (rsl_cmode == RSL_CMOD_SPD_SPEECH) { /* indicate bad frame */ |