aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2009-11-29 19:07:28 +0100
committerHarald Welte <laforge@gnumonks.org>2009-11-29 19:07:28 +0100
commit3c7dc6ed50e8baa05a8aea26c72319530e747317 (patch)
tree252c7c938f2bda82ac690447200a7c4c71bbec9d /openbsc
parenta5312fdd2b444b363c36fa7b6e78a1bbe03c9e20 (diff)
New complete measurement result/report handling
This patch extends struct gsm_meas_rep into a complete structure containing all information from both uplink and downlink measurement results/reports. This is a first step to provide this complete measurement data as a C structure into a to-be-implemented handover decision algorithm.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/gsm_04_08.h28
-rw-r--r--openbsc/include/openbsc/meas_rep.h50
-rw-r--r--openbsc/src/abis_rsl.c112
-rw-r--r--openbsc/src/gsm_04_08.c60
4 files changed, 165 insertions, 85 deletions
diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h
index b7c8a2662..cd85dff8f 100644
--- a/openbsc/include/openbsc/gsm_04_08.h
+++ b/openbsc/include/openbsc/gsm_04_08.h
@@ -1,6 +1,8 @@
#ifndef _GSM_04_08_H
#define _GSM_04_08_H
+#include <openbsc/meas_rep.h>
+
/* GSM TS 04.08 definitions */
struct gsm_lchan;
@@ -618,30 +620,6 @@ enum gsm48_reject_value {
GSM48_REJECT_MSC_TMP_NOT_REACHABLE = 16,
};
-
-/* extracted from a L3 measurement report IE */
-struct gsm_meas_rep_cell {
- u_int8_t rxlev;
- u_int8_t bcch_freq; /* fixme: translate to ARFCN */
- u_int8_t bsic;
-};
-
-struct gsm_meas_rep {
- unsigned int flags;
- u_int8_t rxlev_full;
- u_int8_t rxqual_full;
- u_int8_t rxlev_sub;
- u_int8_t rxqual_sub;
- int num_cell;
- struct gsm_meas_rep_cell cell[6];
-};
-#define MEAS_REP_F_DTX 0x01
-#define MEAS_REP_F_VALID 0x02
-#define MEAS_REP_F_BA1 0x04
-
-void gsm48_parse_meas_rep(struct gsm_meas_rep *rep, const u_int8_t *data,
- int len);
-
enum chreq_type {
CHREQ_T_EMERG_CALL,
CHREQ_T_CALL_REEST_TCH_F,
@@ -782,5 +760,7 @@ int gsm48_handle_paging_resp(struct msgb *msg, struct gsm_subscriber *subscr);
int gsm48_lchan_modify(struct gsm_lchan *lchan, u_int8_t lchan_mode);
int gsm48_rx_rr_modif_ack(struct msgb *msg);
+int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg);
+
#endif
diff --git a/openbsc/include/openbsc/meas_rep.h b/openbsc/include/openbsc/meas_rep.h
new file mode 100644
index 000000000..0c2bdabde
--- /dev/null
+++ b/openbsc/include/openbsc/meas_rep.h
@@ -0,0 +1,50 @@
+#ifndef _MEAS_REP_H
+#define _MEAS_REP_H
+
+/* extracted from a L3 measurement report IE */
+struct gsm_meas_rep_cell {
+ u_int8_t rxlev;
+ u_int8_t bcch_freq; /* FIXME: translate to ARFCN */
+ u_int8_t bsic;
+};
+
+/* RX Level and RX Quality */
+struct gsm_rx_lev_qual {
+ u_int8_t rx_lev;
+ u_int8_t rx_qual;
+};
+
+/* unidirectional measumrement report */
+struct gsm_meas_rep_unidir {
+ struct gsm_rx_lev_qual full;
+ struct gsm_rx_lev_qual sub;
+};
+
+#define MEAS_REP_F_UL_DTX 0x01
+#define MEAS_REP_F_DL_VALID 0x02
+#define MEAS_REP_F_BA1 0x04
+#define MEAS_REP_F_DL_DTX 0x08
+#define MEAS_REP_F_MS_TO 0x10
+#define MEAS_REP_F_MS_L1 0x20
+#define MEAS_REP_F_FPC 0x40
+
+/* parsed uplink and downlink measurement result */
+struct gsm_meas_rep {
+ u_int8_t nr;
+ unsigned int flags;
+
+ struct gsm_meas_rep_unidir ul;
+ struct gsm_meas_rep_unidir dl;
+
+ u_int8_t bs_power;
+ u_int8_t ms_timing_offset;
+ struct {
+ int8_t pwr; /* MS power in dBm */
+ u_int8_t ta; /* MS timing advance */
+ } ms_l1;
+
+ int num_cell;
+ struct gsm_meas_rep_cell cell[6];
+};
+
+#endif /* _MEAS_REP_H */
diff --git a/openbsc/src/abis_rsl.c b/openbsc/src/abis_rsl.c
index 219b01aa0..743dc5f2b 100644
--- a/openbsc/src/abis_rsl.c
+++ b/openbsc/src/abis_rsl.c
@@ -38,6 +38,7 @@
#include <openbsc/tlv.h>
#include <openbsc/paging.h>
#include <openbsc/signal.h>
+#include <openbsc/meas_rep.h>
#define RSL_ALLOC_SIZE 1024
#define RSL_ALLOC_HEADROOM 128
@@ -949,47 +950,102 @@ static int rsl_rx_conn_fail(struct msgb *msg)
return rsl_rf_chan_release(msg->lchan);
}
+static void print_meas_rep_uni(struct gsm_meas_rep_unidir *mru,
+ const char *prefix)
+{
+ DEBUGPC(DMEAS, "RXL-FULL-%s=%d RXL-SUB-%s=%d ",
+ prefix, mru->full.rx_lev, prefix, mru->sub.rx_lev);
+ DEBUGPC(DMEAS, "RXQ-FULL-%s=%d RXQ-SUB-%s=%d ",
+ prefix, mru->full.rx_qual, prefix, mru->sub.rx_qual);
+}
+
+static void print_meas_rep(struct gsm_meas_rep *mr)
+{
+ DEBUGP(DMEAS, "MEASUREMENT RESULT NR=%d ", mr->nr);
+
+ if (mr->flags & MEAS_REP_F_DL_DTX)
+ DEBUGPC(DMEAS, "DTXd ");
+
+ print_meas_rep_uni(&mr->ul, "ul");
+ DEBUGPC(DMEAS, "BS_POWER=%d ", mr->bs_power);
+ if (mr->flags & MEAS_REP_F_MS_TO)
+ DEBUGPC(DMEAS, "MS_TO=%d ", mr->ms_timing_offset);
+
+ if (mr->flags & MEAS_REP_F_MS_L1) {
+ DEBUGPC(DMEAS, "L1_MS_PWR=%ddBm ", mr->ms_l1.pwr);
+ DEBUGPC(DMEAS, "L1_FPC=%u ",
+ mr->flags & MEAS_REP_F_FPC ? 1 : 0);
+ DEBUGPC(DMEAS, "L1_TA=%u ", mr->ms_l1.ta);
+ }
+
+ if (mr->flags & MEAS_REP_F_UL_DTX)
+ DEBUGPC(DMEAS, "DTXu ");
+ if (mr->flags & MEAS_REP_F_BA1)
+ DEBUGPC(DMEAS, "BA1 ");
+ if (!(mr->flags & MEAS_REP_F_DL_VALID))
+ DEBUGPC(DMEAS, "NOT VALID ");
+ else
+ print_meas_rep_uni(&mr->dl, "dl");
+
+ DEBUGPC(DMEAS, "NUM_NEIGH=%u\n", mr->num_cell);
+}
+
static int rsl_rx_meas_res(struct msgb *msg)
{
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
struct tlv_parsed tp;
+ struct gsm_meas_rep mr;
+ u_int8_t len;
+ const u_int8_t *val;
+ int rc;
+
+ memset(&mr, 0, sizeof(mr));
- DEBUGPC(DMEAS, "MEASUREMENT RESULT ");
rsl_tlv_parse(&tp, dh->data, msgb_l2len(msg)-sizeof(*dh));
- if (TLVP_PRESENT(&tp, RSL_IE_MEAS_RES_NR))
- DEBUGPC(DMEAS, "NR=%d ", *TLVP_VAL(&tp, RSL_IE_MEAS_RES_NR));
- if (TLVP_PRESENT(&tp, RSL_IE_UPLINK_MEAS)) {
- u_int8_t len = TLVP_LEN(&tp, RSL_IE_UPLINK_MEAS);
- const u_int8_t *val = TLVP_VAL(&tp, RSL_IE_UPLINK_MEAS);
- if (len >= 3) {
- if (val[0] & 0x40)
- DEBUGPC(DMEAS, "DTXd ");
- DEBUGPC(DMEAS, "RXL-FULL-up=%d RXL-SUB-up=%d ",
- val[0] & 0x3f, val[1] & 0x3f);
- DEBUGPC(DMEAS, "RXQ-FULL-up=%d RXQ-SUB-up=%d ",
- val[2]>>3 & 0x7, val[2] & 0x7);
- }
+ if (!TLVP_PRESENT(&tp, RSL_IE_MEAS_RES_NR) ||
+ !TLVP_PRESENT(&tp, RSL_IE_UPLINK_MEAS) ||
+ !TLVP_PRESENT(&tp, RSL_IE_BS_POWER))
+ return -EIO;
+
+ /* Mandatory Parts */
+ mr.nr = *TLVP_VAL(&tp, RSL_IE_MEAS_RES_NR);
+
+ len = TLVP_LEN(&tp, RSL_IE_UPLINK_MEAS);
+ val = TLVP_VAL(&tp, RSL_IE_UPLINK_MEAS);
+ if (len >= 3) {
+ if (val[0] & 0x40)
+ mr.flags |= MEAS_REP_F_DL_DTX;
+ mr.ul.full.rx_lev = val[0] & 0x3f;
+ mr.ul.sub.rx_lev = val[1] & 0x3f;
+ mr.ul.full.rx_qual = val[2]>>3 & 0x7;
+ mr.ul.sub.rx_qual = val[2] & 0x7;
}
- if (TLVP_PRESENT(&tp, RSL_IE_BS_POWER))
- DEBUGPC(DMEAS, "BS_POWER=%d ", *TLVP_VAL(&tp, RSL_IE_BS_POWER));
+
+ mr.bs_power = *TLVP_VAL(&tp, RSL_IE_BS_POWER);
+
+ /* Optional Parts */
if (TLVP_PRESENT(&tp, RSL_IE_MS_TIMING_OFFSET))
- DEBUGPC(DMEAS, "MS_TO=%d ",
- *TLVP_VAL(&tp, RSL_IE_MS_TIMING_OFFSET));
+ mr.ms_timing_offset =
+ *TLVP_VAL(&tp, RSL_IE_MS_TIMING_OFFSET);
+
if (TLVP_PRESENT(&tp, RSL_IE_L1_INFO)) {
- const u_int8_t *val = TLVP_VAL(&tp, RSL_IE_L1_INFO);
- u_int8_t pwr_lvl = val[0] >> 3;
- DEBUGPC(DMEAS, "L1_MS_PWR=%ddBm ",
- ms_pwr_dbm(msg->trx->bts->band, pwr_lvl));
- DEBUGPC(DMEAS, "L1_FPC=%u ", val[0] & 0x04 ? 1 : 0);
- DEBUGPC(DMEAS, "L1_TA=%u ", val[1]);
+ val = TLVP_VAL(&tp, RSL_IE_L1_INFO);
+ mr.flags |= MEAS_REP_F_MS_L1;
+ mr.ms_l1.pwr = ms_pwr_dbm(msg->trx->bts->band, val[0] >> 3);
+ if (val[0] & 0x04)
+ mr.flags |= MEAS_REP_F_FPC;
+ mr.ms_l1.ta = val[1];
}
if (TLVP_PRESENT(&tp, RSL_IE_L3_INFO)) {
- DEBUGPC(DMEAS, "L3\n");
msg->l3h = (u_int8_t *) TLVP_VAL(&tp, RSL_IE_L3_INFO);
- return gsm0408_rcvmsg(msg, 0);
- } else
- DEBUGPC(DMEAS, "\n");
+ rc = gsm48_parse_meas_rep(&mr, msg);
+ if (rc < 0)
+ return rc;
+ }
+
+ /* FIXME: do something with the actual result*/
+ print_meas_rep(&mr);
return 0;
}
diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c
index 1f8235411..c9e543378 100644
--- a/openbsc/src/gsm_04_08.c
+++ b/openbsc/src/gsm_04_08.c
@@ -166,25 +166,30 @@ static const char *rr_cause_name(u_int8_t cause)
return strbuf;
}
-static void parse_meas_rep(struct gsm_meas_rep *rep, const u_int8_t *data,
- int len)
+int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
{
- memset(rep, 0, sizeof(*rep));
+ struct gsm48_hdr *gh = msgb_l3(msg);
+ unsigned int payload_len = msgb_l3len(msg) - sizeof(*gh);
+ u_int8_t *data = gh->data;
+
+ if (gh->msg_type != GSM48_MT_RR_MEAS_REP)
+ return -EINVAL;
if (data[0] & 0x80)
rep->flags |= MEAS_REP_F_BA1;
if (data[0] & 0x40)
- rep->flags |= MEAS_REP_F_DTX;
+ rep->flags |= MEAS_REP_F_UL_DTX;
if ((data[1] & 0x40) == 0x00)
- rep->flags |= MEAS_REP_F_VALID;
+ rep->flags |= MEAS_REP_F_DL_VALID;
+
+ rep->dl.full.rx_lev = data[0] & 0x3f;
+ rep->dl.sub.rx_lev = data[1] & 0x3f;
+ rep->dl.full.rx_qual = (data[3] >> 4) & 0x7;
+ rep->dl.sub.rx_qual = (data[3] >> 1) & 0x7;
- rep->rxlev_full = data[0] & 0x3f;
- rep->rxlev_sub = data[1] & 0x3f;
- rep->rxqual_full = (data[3] >> 4) & 0x7;
- rep->rxqual_sub = (data[3] >> 1) & 0x7;
rep->num_cell = data[4] >> 6 | ((data[3] & 0x01) << 2);
if (rep->num_cell < 1)
- return;
+ return 0;
/* an encoding nightmare in perfection */
@@ -192,35 +197,37 @@ static void parse_meas_rep(struct gsm_meas_rep *rep, const u_int8_t *data,
rep->cell[0].bcch_freq = data[5] >> 2;
rep->cell[0].bsic = ((data[5] & 0x03) << 3) | (data[6] >> 5);
if (rep->num_cell < 2)
- return;
+ return 0;
rep->cell[1].rxlev = ((data[6] & 0x1f) << 1) | (data[7] >> 7);
rep->cell[1].bcch_freq = (data[7] >> 2) & 0x1f;
rep->cell[1].bsic = ((data[7] & 0x03) << 4) | (data[8] >> 4);
if (rep->num_cell < 3)
- return;
+ return 0;
rep->cell[2].rxlev = ((data[8] & 0x0f) << 2) | (data[9] >> 6);
rep->cell[2].bcch_freq = (data[9] >> 1) & 0x1f;
rep->cell[2].bsic = ((data[9] & 0x01) << 6) | (data[10] >> 3);
if (rep->num_cell < 4)
- return;
+ return 0;
rep->cell[3].rxlev = ((data[10] & 0x07) << 3) | (data[11] >> 5);
rep->cell[3].bcch_freq = data[11] & 0x1f;
rep->cell[3].bsic = data[12] >> 2;
if (rep->num_cell < 5)
- return;
+ return 0;
rep->cell[4].rxlev = ((data[12] & 0x03) << 4) | (data[13] >> 4);
rep->cell[4].bcch_freq = ((data[13] & 0xf) << 1) | (data[14] >> 7);
rep->cell[4].bsic = (data[14] >> 1) & 0x3f;
if (rep->num_cell < 6)
- return;
+ return 0;
rep->cell[5].rxlev = ((data[14] & 0x01) << 5) | (data[15] >> 3);
rep->cell[5].bcch_freq = ((data[15] & 0x07) << 2) | (data[16] >> 6);
rep->cell[5].bsic = data[16] & 0x3f;
+
+ return 0;
}
int gsm0408_loc_upd_acc(struct gsm_lchan *lchan, u_int32_t tmsi);
@@ -1528,26 +1535,13 @@ static int gsm48_rx_rr_status(struct msgb *msg)
static int gsm48_rx_rr_meas_rep(struct msgb *msg)
{
- struct gsm48_hdr *gh = msgb_l3(msg);
- unsigned int payload_len = msgb_l3len(msg) - sizeof(*gh);
static struct gsm_meas_rep meas_rep;
- DEBUGP(DMEAS, "MEASUREMENT REPORT ");
- parse_meas_rep(&meas_rep, gh->data, payload_len);
- if (meas_rep.flags & MEAS_REP_F_DTX)
- DEBUGPC(DMEAS, "DTX ");
- if (meas_rep.flags & MEAS_REP_F_BA1)
- DEBUGPC(DMEAS, "BA1 ");
- if (!(meas_rep.flags & MEAS_REP_F_VALID))
- DEBUGPC(DMEAS, "NOT VALID ");
- else
- DEBUGPC(DMEAS, "FULL(lev=%u, qual=%u) SUB(lev=%u, qual=%u) ",
- meas_rep.rxlev_full, meas_rep.rxqual_full, meas_rep.rxlev_sub,
- meas_rep.rxqual_sub);
-
- DEBUGPC(DMEAS, "NUM_NEIGH=%u\n", meas_rep.num_cell);
-
- /* FIXME: put the results somwhere */
+ /* This shouldn't actually end up here, as RSL treats
+ * L3 Info of 08.58 MEASUREMENT REPORT different by calling
+ * directly into gsm48_parse_meas_rep */
+ DEBUGP(DMEAS, "DIRECT GSM48 MEASUREMENT REPORT ?!? ");
+ gsm48_parse_meas_rep(&meas_rep, msg);
return 0;
}