Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <stdbool.h> |
Neels Hofmeyr | 87b5eb6 | 2017-12-07 01:55:58 +0100 | [diff] [blame^] | 4 | #include <string.h> |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 5 | |
| 6 | struct vty; |
| 7 | |
| 8 | /* handover_cfg is an opaque struct to manage several levels of configuration. There is an overall handover |
| 9 | * config on 'network' level and a per-'bts' specific handover config. If the 'bts' level sets no values, |
| 10 | * the defaults from 'network' level are used implicitly, and changes take effect immediately. */ |
| 11 | struct handover_cfg; |
| 12 | |
| 13 | struct handover_cfg *ho_cfg_init(void *ctx, struct handover_cfg *higher_level_cfg); |
| 14 | |
| 15 | #define HO_CFG_STR_HANDOVER "Handover options\n" |
| 16 | #define HO_CFG_STR_WIN HO_CFG_STR_HANDOVER "Measurement averaging settings\n" |
| 17 | #define HO_CFG_STR_WIN_RXLEV HO_CFG_STR_WIN "Received-Level averaging\n" |
| 18 | #define HO_CFG_STR_WIN_RXQUAL HO_CFG_STR_WIN "Received-Quality averaging\n" |
| 19 | #define HO_CFG_STR_POWER_BUDGET HO_CFG_STR_HANDOVER "Neighbor cell power triggering\n" "Neighbor cell power triggering\n" |
| 20 | #define HO_CFG_STR_AVG_COUNT "Number of values to average over\n" |
Neels Hofmeyr | 87b5eb6 | 2017-12-07 01:55:58 +0100 | [diff] [blame^] | 21 | #define HO_CFG_STR_2 " (HO algo 2 only)\n" |
| 22 | #define HO_CFG_STR_MIN "Minimum Level/Quality thresholds before triggering HO" HO_CFG_STR_2 |
| 23 | #define HO_CFG_STR_AFS_BIAS "Configure bias to prefer AFS (AMR on TCH/F) over other codecs" HO_CFG_STR_2 |
| 24 | #define HO_CFG_STR_MIN_TCH "Minimum free TCH timeslots before cell is considered congested" HO_CFG_STR_2 |
| 25 | #define HO_CFG_STR_PENALTY_TIME "Set penalty times to wait between repeated handovers" HO_CFG_STR_2 |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 26 | |
| 27 | #define as_is(x) (x) |
| 28 | |
| 29 | static inline bool a2bool(const char *arg) |
| 30 | { |
| 31 | return (bool)(atoi(arg)); |
| 32 | } |
| 33 | |
| 34 | static inline int bool2i(bool arg) |
| 35 | { |
| 36 | return arg? 1 : 0; |
| 37 | } |
| 38 | |
Neels Hofmeyr | 87b5eb6 | 2017-12-07 01:55:58 +0100 | [diff] [blame^] | 39 | static inline bool a2tdma(const char *arg) |
| 40 | { |
| 41 | if (!strcmp(arg, "full")) |
| 42 | return true; |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | static inline const char *tdma2a(bool val) |
| 47 | { |
| 48 | return val? "full" : "subset"; |
| 49 | } |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 50 | |
| 51 | /* The HO_CFG_ONE_MEMBER macro gets redefined, depending on whether to define struct members, |
| 52 | * function declarations or definitions... It is of the format |
| 53 | * HO_CFG_ONE_MEMBER(TYPE, NAME, DEFAULT_VAL, |
| 54 | * VTY_CMD, VTY_CMD_ARG, VTY_ARG_EVAL, |
| 55 | * VTY_WRITE_FMT, VTY_WRITE_CONV, |
| 56 | * VTY_DOC) |
| 57 | * Then using HO_CFG_ALL_MEMBERS can save a lot of code dup in defining API declaration, API |
| 58 | * definitions, VTY commands and VTY write code. Of course this doesn't prevent us from adding manual |
| 59 | * members as well, in case future additions don't fit in this scheme. |
| 60 | * |
| 61 | * TYPE: a type name like int. |
| 62 | * NAME: a variable name suitable for a struct member. |
| 63 | * DEFAULT_VAL: default value, as passed to the VTY, e.g. '0' or 'foo', without quotes. |
| 64 | * VTY_CMD: a command string for VTY without any arguments. |
| 65 | * VTY_CMD_ARG: VTY value range like '<0-23>' or 'foo|bar', will become '(VTY_CMD_ARG|default)'. |
| 66 | * VTY_ARG_EVAL: function name for parsing the VTY arg[0], e.g. 'atoi'. |
| 67 | * VTY_WRITE_FMT: printf-like string format for vty_out(). |
| 68 | * VTY_WRITE_CONV: function name to convert struct value to VTY_WRITE_FMT, e.g. 'as_is'. |
| 69 | * VTY_DOC: VTY documentation strings to match VTY_CMD and VTY_CMD_ARGs. |
| 70 | */ |
| 71 | #define HO_CFG_ALL_MEMBERS \ |
| 72 | \ |
| 73 | HO_CFG_ONE_MEMBER(bool, ho_active, 0, \ |
| 74 | "handover", "0|1", a2bool, "%d", bool2i, \ |
| 75 | HO_CFG_STR_HANDOVER \ |
| 76 | "Disable in-call handover\n" \ |
| 77 | "Enable in-call handover\n" \ |
| 78 | "Enable/disable handover: ") \ |
| 79 | \ |
Neels Hofmeyr | 87b5eb6 | 2017-12-07 01:55:58 +0100 | [diff] [blame^] | 80 | HO_CFG_ONE_MEMBER(int, algorithm, 1, \ |
| 81 | "handover algorithm", "1|2", atoi, "%d", as_is, \ |
| 82 | HO_CFG_STR_HANDOVER \ |
| 83 | "Choose algorithm for handover decision\n" \ |
| 84 | "Algorithm 1: trigger handover based on comparing current cell and neighbor RxLev and RxQual," \ |
| 85 | " only.\n" \ |
| 86 | "Algorithm 2: trigger handover on RxLev/RxQual, and also to balance the load across several" \ |
| 87 | " cells. Consider available codecs. Prevent repeated handover by penalty timers.\n") \ |
| 88 | \ |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 89 | HO_CFG_ONE_MEMBER(unsigned int, rxlev_avg_win, 10, \ |
| 90 | "handover window rxlev averaging", "<1-10>", atoi, "%u", as_is, \ |
| 91 | HO_CFG_STR_WIN_RXLEV \ |
| 92 | "How many RxLev measurements are used for averaging\n" \ |
| 93 | "RxLev averaging: " HO_CFG_STR_AVG_COUNT) \ |
| 94 | \ |
| 95 | HO_CFG_ONE_MEMBER(unsigned int, rxqual_avg_win, 1, \ |
| 96 | "handover window rxqual averaging", "<1-10>", atoi, "%u", as_is, \ |
| 97 | HO_CFG_STR_WIN_RXQUAL \ |
| 98 | "How many RxQual measurements are used for averaging\n" \ |
| 99 | "RxQual averaging: " HO_CFG_STR_AVG_COUNT) \ |
| 100 | \ |
| 101 | HO_CFG_ONE_MEMBER(unsigned int, rxlev_neigh_avg_win, 10, \ |
| 102 | "handover window rxlev neighbor averaging", "<1-10>", atoi, "%u", as_is, \ |
| 103 | HO_CFG_STR_WIN_RXLEV \ |
| 104 | "How many Neighbor RxLev measurements are used for averaging\n" \ |
| 105 | "How many Neighbor RxLev measurements are used for averaging\n" \ |
| 106 | "Neighbor RxLev averaging: " HO_CFG_STR_AVG_COUNT) \ |
| 107 | \ |
| 108 | HO_CFG_ONE_MEMBER(unsigned int, pwr_interval, 6, \ |
| 109 | "handover power budget interval", "<1-99>", atoi, "%u", as_is, \ |
| 110 | HO_CFG_STR_POWER_BUDGET \ |
| 111 | "How often to check for a better cell (SACCH frames)\n" \ |
| 112 | "Check for stronger neighbor every N number of SACCH frames\n") \ |
| 113 | \ |
| 114 | HO_CFG_ONE_MEMBER(unsigned int, pwr_hysteresis, 3, \ |
| 115 | "handover power budget hysteresis", "<0-999>", atoi, "%u", as_is, \ |
| 116 | HO_CFG_STR_POWER_BUDGET \ |
| 117 | "How many dBm stronger must a neighbor be to become a HO candidate\n" \ |
| 118 | "Neighbor's strength difference in dBm\n") \ |
| 119 | \ |
| 120 | HO_CFG_ONE_MEMBER(unsigned int, max_distance, 9999, \ |
| 121 | "handover maximum distance" , "<0-9999>", atoi, "%u", as_is, \ |
| 122 | HO_CFG_STR_HANDOVER \ |
| 123 | "Maximum Timing-Advance value (i.e. MS distance) before triggering HO\n" \ |
| 124 | "Maximum Timing-Advance value (i.e. MS distance) before triggering HO\n" \ |
| 125 | "Maximum Timing-Advance value (i.e. MS distance) before triggering HO\n") \ |
Neels Hofmeyr | 87b5eb6 | 2017-12-07 01:55:58 +0100 | [diff] [blame^] | 126 | \ |
| 127 | HO_CFG_ONE_MEMBER(bool, as_active, 0, \ |
| 128 | "handover assignment", "0|1", a2bool, "%d", bool2i, \ |
| 129 | HO_CFG_STR_HANDOVER \ |
| 130 | "Enable or disable in-call channel re-assignment" HO_CFG_STR_2 \ |
| 131 | "Disable in-call assignment\n" \ |
| 132 | "Enable in-call assignment\n") \ |
| 133 | \ |
| 134 | HO_CFG_ONE_MEMBER(bool, full_tdma, subset, \ |
| 135 | "handover tdma-measurement", "full|subset", a2tdma, "%s", tdma2a, \ |
| 136 | HO_CFG_STR_HANDOVER \ |
| 137 | "Define measurement set of TDMA frames" HO_CFG_STR_2 \ |
| 138 | "Full set of 102/104 TDMA frames\n" \ |
| 139 | "Sub set of 4 TDMA frames (SACCH)\n") \ |
| 140 | \ |
| 141 | HO_CFG_ONE_MEMBER(int, min_rxlev, -100, \ |
| 142 | "handover min rxlev", "<-110--50>", atoi, "%d", as_is, \ |
| 143 | HO_CFG_STR_HANDOVER \ |
| 144 | HO_CFG_STR_MIN \ |
| 145 | "How weak may RxLev of an MS become before triggering HO\n" \ |
| 146 | "minimum RxLev (dBm)\n") \ |
| 147 | \ |
| 148 | HO_CFG_ONE_MEMBER(int, min_rxqual, 5, \ |
| 149 | "handover min rxqual", "<0-7>", atoi, "%d", as_is, \ |
| 150 | HO_CFG_STR_HANDOVER \ |
| 151 | HO_CFG_STR_MIN \ |
| 152 | "How bad may RxQual of an MS become before triggering HO\n" \ |
| 153 | "minimum RxQual (dBm)\n") \ |
| 154 | \ |
| 155 | HO_CFG_ONE_MEMBER(int, afs_bias_rxlev, 0, \ |
| 156 | "handover afs-bias rxlev", "<0-20>", atoi, "%d", as_is, \ |
| 157 | HO_CFG_STR_HANDOVER \ |
| 158 | HO_CFG_STR_AFS_BIAS \ |
| 159 | "RxLev improvement bias for AFS over other codecs\n" \ |
| 160 | "Virtual RxLev improvement (dBm)\n") \ |
| 161 | \ |
| 162 | HO_CFG_ONE_MEMBER(int, afs_bias_rxqual, 0, \ |
| 163 | "handover afs-bias rxqual", "<0-7>", atoi, "%d", as_is, \ |
| 164 | HO_CFG_STR_HANDOVER \ |
| 165 | HO_CFG_STR_AFS_BIAS \ |
| 166 | "RxQual improvement bias for AFS over other codecs\n" \ |
| 167 | "Virtual RxQual improvement (dBm)\n") \ |
| 168 | \ |
| 169 | HO_CFG_ONE_MEMBER(int, tchf_min_slots, 0, \ |
| 170 | "handover min-free-slots tch/f", "<0-9999>", atoi, "%d", as_is, \ |
| 171 | HO_CFG_STR_HANDOVER \ |
| 172 | HO_CFG_STR_MIN_TCH \ |
| 173 | "Minimum free TCH/F timeslots before cell is considered congested\n" \ |
| 174 | "Number of TCH/F slots\n") \ |
| 175 | \ |
| 176 | HO_CFG_ONE_MEMBER(int, tchh_min_slots, 0, \ |
| 177 | "handover min-free-slots tch/h", "<0-9999>", atoi, "%d", as_is, \ |
| 178 | HO_CFG_STR_HANDOVER \ |
| 179 | HO_CFG_STR_MIN_TCH \ |
| 180 | "Minimum free TCH/H timeslots before cell is considered congested\n" \ |
| 181 | "Number of TCH/H slots\n") \ |
| 182 | \ |
| 183 | HO_CFG_ONE_MEMBER(int, ho_max, 9999, \ |
| 184 | "handover max-handovers", "<1-9999>", atoi, "%d", as_is, \ |
| 185 | HO_CFG_STR_HANDOVER \ |
| 186 | "Maximum number of concurrent handovers allowed per cell" HO_CFG_STR_2 \ |
| 187 | "Number\n") \ |
| 188 | \ |
| 189 | HO_CFG_ONE_MEMBER(int, penalty_max_dist, 300, \ |
| 190 | "handover penalty-time max-distance", "<0-99999>", atoi, "%d", as_is, \ |
| 191 | HO_CFG_STR_HANDOVER \ |
| 192 | HO_CFG_STR_PENALTY_TIME \ |
| 193 | "Time to suspend handovers after leaving this cell due to exceeding max distance\n" \ |
| 194 | "Seconds\n") \ |
| 195 | \ |
| 196 | HO_CFG_ONE_MEMBER(int, penalty_failed_ho, 60, \ |
| 197 | "handover penalty-time failed-ho", "<0-99999>", atoi, "%d", as_is, \ |
| 198 | HO_CFG_STR_HANDOVER \ |
| 199 | HO_CFG_STR_PENALTY_TIME \ |
| 200 | "Time to suspend handovers after handover failure to this cell\n" \ |
| 201 | "Seconds\n") \ |
| 202 | \ |
| 203 | HO_CFG_ONE_MEMBER(int, penalty_failed_as, 60, \ |
| 204 | "handover penalty-time failed-assignment", "<0-99999>", atoi, "%d", as_is, \ |
| 205 | HO_CFG_STR_HANDOVER \ |
| 206 | HO_CFG_STR_PENALTY_TIME \ |
| 207 | "Time to suspend handovers after assignment failure in this cell\n" \ |
| 208 | "Seconds\n") \ |
| 209 | \ |
| 210 | HO_CFG_ONE_MEMBER(int, retries, 0, \ |
| 211 | "handover retries", "<0-9>", atoi, "%d", as_is, \ |
| 212 | HO_CFG_STR_HANDOVER \ |
| 213 | "Immediately retry on handover/assignment failure" HO_CFG_STR_2 \ |
| 214 | "Number of retries\n") \ |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 215 | |
| 216 | |
| 217 | /* Declare public API for handover cfg parameters... */ |
| 218 | |
| 219 | #define HO_CFG_ONE_MEMBER(TYPE, NAME, DEFAULT_VAL, VTY1, VTY2, VTY3, VTY4, VTY5, VTY6) \ |
| 220 | TYPE ho_get_##NAME(struct handover_cfg *ho); \ |
| 221 | void ho_set_##NAME(struct handover_cfg *ho, TYPE val); \ |
| 222 | bool ho_isset_##NAME(struct handover_cfg *ho); \ |
| 223 | void ho_clear_##NAME(struct handover_cfg *ho); \ |
| 224 | bool ho_isset_on_parent_##NAME(struct handover_cfg *ho); |
| 225 | |
| 226 | HO_CFG_ALL_MEMBERS |
| 227 | #undef HO_CFG_ONE_MEMBER |