aboutsummaryrefslogtreecommitdiffstats
path: root/include/openbsc/meas_rep.h
blob: f235df6aa07e72ec889593a6f6906767da0d17ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef _MEAS_REP_H
#define _MEAS_REP_H

#include <stdint.h>

#define MRC_F_PROCESSED	0x0001

/* extracted from a L3 measurement report IE */
struct gsm_meas_rep_cell {
	uint8_t rxlev;
	uint8_t bsic;
	uint8_t neigh_idx;
	uint16_t arfcn;
	unsigned int flags;
};

/* RX Level and RX Quality */
struct gsm_rx_lev_qual {
	uint8_t rx_lev;
	uint8_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 {
	/* back-pointer to the logical channel */
	struct gsm_lchan *lchan;

	/* number of the measurement report */
	uint8_t nr;
	/* flags, see MEAS_REP_F_* */
	unsigned int flags;

	/* uplink and downlink rxlev, rxqual; full and sub */
	struct gsm_meas_rep_unidir ul;
	struct gsm_meas_rep_unidir dl;

	uint8_t bs_power;
	uint8_t ms_timing_offset;
	struct {
		int8_t pwr;	/* MS power in dBm */
		uint8_t ta;	/* MS timing advance */
	} ms_l1;

	/* neighbor measurement reports for up to 6 cells */
	int num_cell;
	struct gsm_meas_rep_cell cell[6];
};

enum meas_rep_field {
	MEAS_REP_DL_RXLEV_FULL,
	MEAS_REP_DL_RXLEV_SUB,
	MEAS_REP_DL_RXQUAL_FULL,
	MEAS_REP_DL_RXQUAL_SUB,
	MEAS_REP_UL_RXLEV_FULL,
	MEAS_REP_UL_RXLEV_SUB,
	MEAS_REP_UL_RXQUAL_FULL,
	MEAS_REP_UL_RXQUAL_SUB,
};

/* obtain an average over the last 'num' fields in the meas reps */
int get_meas_rep_avg(const struct gsm_lchan *lchan,
		     enum meas_rep_field field, unsigned int num);

/* Check if N out of M last values for FIELD are >= bd */
int meas_rep_n_out_of_m_be(const struct gsm_lchan *lchan,
			enum meas_rep_field field,
			unsigned int n, unsigned int m, int be);

unsigned int calc_initial_idx(unsigned int array_size,
			      unsigned int meas_rep_idx,
			      unsigned int num_values);

#endif /* _MEAS_REP_H */