Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 1 | #ifndef _MEAS_REP_H |
| 2 | #define _MEAS_REP_H |
| 3 | |
Harald Welte | 38fe2a6 | 2009-12-21 09:26:17 +0100 | [diff] [blame^] | 4 | #define MRC_F_PROCESSED 0x0001 |
| 5 | |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 6 | /* extracted from a L3 measurement report IE */ |
| 7 | struct gsm_meas_rep_cell { |
| 8 | u_int8_t rxlev; |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 9 | u_int8_t bsic; |
Harald Welte | f1dae19 | 2009-12-14 22:24:28 +0100 | [diff] [blame] | 10 | u_int16_t arfcn; |
Harald Welte | 38fe2a6 | 2009-12-21 09:26:17 +0100 | [diff] [blame^] | 11 | unsigned int flags; |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 12 | }; |
| 13 | |
| 14 | /* RX Level and RX Quality */ |
| 15 | struct gsm_rx_lev_qual { |
| 16 | u_int8_t rx_lev; |
| 17 | u_int8_t rx_qual; |
| 18 | }; |
| 19 | |
| 20 | /* unidirectional measumrement report */ |
| 21 | struct gsm_meas_rep_unidir { |
| 22 | struct gsm_rx_lev_qual full; |
| 23 | struct gsm_rx_lev_qual sub; |
| 24 | }; |
| 25 | |
| 26 | #define MEAS_REP_F_UL_DTX 0x01 |
| 27 | #define MEAS_REP_F_DL_VALID 0x02 |
| 28 | #define MEAS_REP_F_BA1 0x04 |
| 29 | #define MEAS_REP_F_DL_DTX 0x08 |
| 30 | #define MEAS_REP_F_MS_TO 0x10 |
| 31 | #define MEAS_REP_F_MS_L1 0x20 |
| 32 | #define MEAS_REP_F_FPC 0x40 |
| 33 | |
| 34 | /* parsed uplink and downlink measurement result */ |
| 35 | struct gsm_meas_rep { |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 36 | /* back-pointer to the logical channel */ |
Harald Welte | dbb1d88 | 2009-11-30 19:16:47 +0100 | [diff] [blame] | 37 | struct gsm_lchan *lchan; |
| 38 | |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 39 | /* number of the measurement report */ |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 40 | u_int8_t nr; |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 41 | /* flags, see MEAS_REP_F_* */ |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 42 | unsigned int flags; |
| 43 | |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 44 | /* uplink and downlink rxlev, rxqual; full and sub */ |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 45 | struct gsm_meas_rep_unidir ul; |
| 46 | struct gsm_meas_rep_unidir dl; |
| 47 | |
| 48 | u_int8_t bs_power; |
| 49 | u_int8_t ms_timing_offset; |
| 50 | struct { |
| 51 | int8_t pwr; /* MS power in dBm */ |
| 52 | u_int8_t ta; /* MS timing advance */ |
| 53 | } ms_l1; |
| 54 | |
Harald Welte | 7f2d25b | 2009-12-15 21:36:59 +0100 | [diff] [blame] | 55 | /* neighbor measurement reports for up to 6 cells */ |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 56 | int num_cell; |
| 57 | struct gsm_meas_rep_cell cell[6]; |
| 58 | }; |
| 59 | |
Harald Welte | 38fe2a6 | 2009-12-21 09:26:17 +0100 | [diff] [blame^] | 60 | enum meas_rep_field { |
| 61 | MEAS_REP_DL_RXLEV_FULL, |
| 62 | MEAS_REP_DL_RXLEV_SUB, |
| 63 | MEAS_REP_DL_RXQUAL_FULL, |
| 64 | MEAS_REP_DL_RXQUAL_SUB, |
| 65 | MEAS_REP_UL_RXLEV_FULL, |
| 66 | MEAS_REP_UL_RXLEV_SUB, |
| 67 | MEAS_REP_UL_RXQUAL_FULL, |
| 68 | MEAS_REP_UL_RXQUAL_SUB, |
| 69 | }; |
| 70 | |
| 71 | /* obtain an average over the last 'num' fields in the meas reps */ |
| 72 | int get_meas_rep_avg(const struct gsm_lchan *lchan, |
| 73 | enum meas_rep_field field, unsigned int num); |
| 74 | |
| 75 | /* Check if N out of M last values for FIELD are >= bd */ |
| 76 | int meas_rep_n_out_of_m_be(const struct gsm_lchan *lchan, |
| 77 | enum meas_rep_field field, |
| 78 | unsigned int n, unsigned int m, int be); |
| 79 | |
| 80 | unsigned int calc_initial_idx(unsigned int array_size, |
| 81 | unsigned int meas_rep_idx, |
| 82 | unsigned int num_values); |
| 83 | |
Harald Welte | 3c7dc6e | 2009-11-29 19:07:28 +0100 | [diff] [blame] | 84 | #endif /* _MEAS_REP_H */ |