Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 1 | #ifndef _MEAS_REP_H |
| 2 | #define _MEAS_REP_H |
| 3 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
| 5 | |
Harald Welte | 7ff4f0e | 2013-03-07 18:38:09 +0000 | [diff] [blame] | 6 | #include <osmocom/gsm/meas_rep.h> |
| 7 | |
Harald Welte | 38fe2a6 | 2009-12-21 09:26:17 +0100 | [diff] [blame] | 8 | #define MRC_F_PROCESSED 0x0001 |
| 9 | |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 10 | /* extracted from a L3 measurement report IE */ |
| 11 | struct gsm_meas_rep_cell { |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 12 | uint8_t rxlev; |
| 13 | uint8_t bsic; |
| 14 | uint8_t neigh_idx; |
| 15 | uint16_t arfcn; |
Harald Welte | 38fe2a6 | 2009-12-21 09:26:17 +0100 | [diff] [blame] | 16 | unsigned int flags; |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 17 | }; |
| 18 | |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 19 | #define MEAS_REP_F_UL_DTX 0x01 |
| 20 | #define MEAS_REP_F_DL_VALID 0x02 |
| 21 | #define MEAS_REP_F_BA1 0x04 |
| 22 | #define MEAS_REP_F_DL_DTX 0x08 |
| 23 | #define MEAS_REP_F_MS_TO 0x10 |
| 24 | #define MEAS_REP_F_MS_L1 0x20 |
| 25 | #define MEAS_REP_F_FPC 0x40 |
| 26 | |
| 27 | /* parsed uplink and downlink measurement result */ |
| 28 | struct gsm_meas_rep { |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 29 | /* back-pointer to the logical channel */ |
Harald Welte | dbb1d88 | 2009-11-30 19:16:47 +0100 | [diff] [blame] | 30 | struct gsm_lchan *lchan; |
| 31 | |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 32 | /* number of the measurement report */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 33 | uint8_t nr; |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 34 | /* flags, see MEAS_REP_F_* */ |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 35 | unsigned int flags; |
| 36 | |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 37 | /* uplink and downlink rxlev, rxqual; full and sub */ |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 38 | struct gsm_meas_rep_unidir ul; |
| 39 | struct gsm_meas_rep_unidir dl; |
| 40 | |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 41 | uint8_t bs_power; |
| 42 | uint8_t ms_timing_offset; |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 43 | struct { |
| 44 | int8_t pwr; /* MS power in dBm */ |
Holger Hans Peter Freyther | c42ad8b | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 45 | uint8_t ta; /* MS timing advance */ |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 46 | } ms_l1; |
| 47 | |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 48 | /* neighbor measurement reports for up to 6 cells */ |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 49 | int num_cell; |
| 50 | struct gsm_meas_rep_cell cell[6]; |
| 51 | }; |
| 52 | |
Harald Welte | 38fe2a6 | 2009-12-21 09:26:17 +0100 | [diff] [blame] | 53 | /* obtain an average over the last 'num' fields in the meas reps */ |
| 54 | int get_meas_rep_avg(const struct gsm_lchan *lchan, |
| 55 | enum meas_rep_field field, unsigned int num); |
| 56 | |
| 57 | /* Check if N out of M last values for FIELD are >= bd */ |
| 58 | int meas_rep_n_out_of_m_be(const struct gsm_lchan *lchan, |
| 59 | enum meas_rep_field field, |
| 60 | unsigned int n, unsigned int m, int be); |
| 61 | |
| 62 | unsigned int calc_initial_idx(unsigned int array_size, |
| 63 | unsigned int meas_rep_idx, |
| 64 | unsigned int num_values); |
| 65 | |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 66 | #endif /* _MEAS_REP_H */ |