blob: 024bc974feb324fd39f33e6f787a4989837ed3c1 [file] [log] [blame]
Neels Hofmeyre25018b2017-11-27 21:29:33 +01001#pragma once
2
3#include <stdbool.h>
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +01004#include <string.h>
Neels Hofmeyre25018b2017-11-27 21:29:33 +01005
6struct 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. */
11struct handover_cfg;
12
Neels Hofmeyr909e9722017-12-07 03:54:01 +010013#define HO_CFG_CONGESTION_CHECK_DEFAULT 10
14
Neels Hofmeyre25018b2017-11-27 21:29:33 +010015struct handover_cfg *ho_cfg_init(void *ctx, struct handover_cfg *higher_level_cfg);
16
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +010017#define HO_CFG_STR_HANDOVER1 "Handover options for handover decision algorithm 1\n"
18#define HO_CFG_STR_HANDOVER2 "Handover options for handover decision algorithm 2\n"
19#define HO_CFG_STR_WIN "Measurement averaging settings\n"
Neels Hofmeyre25018b2017-11-27 21:29:33 +010020#define HO_CFG_STR_WIN_RXLEV HO_CFG_STR_WIN "Received-Level averaging\n"
21#define HO_CFG_STR_WIN_RXQUAL HO_CFG_STR_WIN "Received-Quality averaging\n"
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +010022#define HO_CFG_STR_POWER_BUDGET "Neighbor cell power triggering\n" "Neighbor cell power triggering\n"
Neels Hofmeyre25018b2017-11-27 21:29:33 +010023#define HO_CFG_STR_AVG_COUNT "Number of values to average over\n"
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +010024#define HO_CFG_STR_2 " (HO algo 2 only)\n"
25#define HO_CFG_STR_MIN "Minimum Level/Quality thresholds before triggering HO" HO_CFG_STR_2
26#define HO_CFG_STR_AFS_BIAS "Configure bias to prefer AFS (AMR on TCH/F) over other codecs" HO_CFG_STR_2
27#define HO_CFG_STR_MIN_TCH "Minimum free TCH timeslots before cell is considered congested" HO_CFG_STR_2
28#define HO_CFG_STR_PENALTY_TIME "Set penalty times to wait between repeated handovers" HO_CFG_STR_2
Neels Hofmeyre25018b2017-11-27 21:29:33 +010029
30#define as_is(x) (x)
31
32static inline bool a2bool(const char *arg)
33{
34 return (bool)(atoi(arg));
35}
36
37static inline int bool2i(bool arg)
38{
39 return arg? 1 : 0;
40}
41
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +010042static inline bool a2tdma(const char *arg)
43{
44 if (!strcmp(arg, "full"))
45 return true;
46 return false;
47}
48
49static inline const char *tdma2a(bool val)
50{
51 return val? "full" : "subset";
52}
Neels Hofmeyre25018b2017-11-27 21:29:33 +010053
54/* The HO_CFG_ONE_MEMBER macro gets redefined, depending on whether to define struct members,
55 * function declarations or definitions... It is of the format
56 * HO_CFG_ONE_MEMBER(TYPE, NAME, DEFAULT_VAL,
57 * VTY_CMD, VTY_CMD_ARG, VTY_ARG_EVAL,
58 * VTY_WRITE_FMT, VTY_WRITE_CONV,
59 * VTY_DOC)
60 * Then using HO_CFG_ALL_MEMBERS can save a lot of code dup in defining API declaration, API
61 * definitions, VTY commands and VTY write code. Of course this doesn't prevent us from adding manual
62 * members as well, in case future additions don't fit in this scheme.
63 *
64 * TYPE: a type name like int.
65 * NAME: a variable name suitable for a struct member.
66 * DEFAULT_VAL: default value, as passed to the VTY, e.g. '0' or 'foo', without quotes.
67 * VTY_CMD: a command string for VTY without any arguments.
68 * VTY_CMD_ARG: VTY value range like '<0-23>' or 'foo|bar', will become '(VTY_CMD_ARG|default)'.
69 * VTY_ARG_EVAL: function name for parsing the VTY arg[0], e.g. 'atoi'.
70 * VTY_WRITE_FMT: printf-like string format for vty_out().
71 * VTY_WRITE_CONV: function name to convert struct value to VTY_WRITE_FMT, e.g. 'as_is'.
72 * VTY_DOC: VTY documentation strings to match VTY_CMD and VTY_CMD_ARGs.
73 */
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +010074#define HO_GENERAL_CFG_ALL_MEMBERS \
Neels Hofmeyre25018b2017-11-27 21:29:33 +010075 \
76 HO_CFG_ONE_MEMBER(bool, ho_active, 0, \
77 "handover", "0|1", a2bool, "%d", bool2i, \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +010078 "Handover general config\n" \
Neels Hofmeyre25018b2017-11-27 21:29:33 +010079 "Disable in-call handover\n" \
80 "Enable in-call handover\n" \
81 "Enable/disable handover: ") \
82 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +010083 HO_CFG_ONE_MEMBER(int, algorithm, 1, \
84 "handover algorithm", "1|2", atoi, "%d", as_is, \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +010085 "Handover general config\n" \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +010086 "Choose algorithm for handover decision\n" \
87 "Algorithm 1: trigger handover based on comparing current cell and neighbor RxLev and RxQual," \
88 " only.\n" \
89 "Algorithm 2: trigger handover on RxLev/RxQual, and also to balance the load across several" \
90 " cells. Consider available codecs. Prevent repeated handover by penalty timers.\n") \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +010091
92
93#define HODEC1_CFG_ALL_MEMBERS \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +010094 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +010095 HO_CFG_ONE_MEMBER(unsigned int, hodec1_rxlev_avg_win, 10, \
Neels Hofmeyre25018b2017-11-27 21:29:33 +010096 "handover window rxlev averaging", "<1-10>", atoi, "%u", as_is, \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +010097 HO_CFG_STR_HANDOVER1 \
Neels Hofmeyre25018b2017-11-27 21:29:33 +010098 HO_CFG_STR_WIN_RXLEV \
99 "How many RxLev measurements are used for averaging\n" \
100 "RxLev averaging: " HO_CFG_STR_AVG_COUNT) \
101 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100102 HO_CFG_ONE_MEMBER(unsigned int, hodec1_rxqual_avg_win, 1, \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100103 "handover window rxqual averaging", "<1-10>", atoi, "%u", as_is, \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100104 HO_CFG_STR_HANDOVER1 \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100105 HO_CFG_STR_WIN_RXQUAL \
106 "How many RxQual measurements are used for averaging\n" \
107 "RxQual averaging: " HO_CFG_STR_AVG_COUNT) \
108 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100109 HO_CFG_ONE_MEMBER(unsigned int, hodec1_rxlev_neigh_avg_win, 10, \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100110 "handover window rxlev neighbor averaging", "<1-10>", atoi, "%u", as_is, \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100111 HO_CFG_STR_HANDOVER1 \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100112 HO_CFG_STR_WIN_RXLEV \
113 "How many Neighbor RxLev measurements are used for averaging\n" \
114 "How many Neighbor RxLev measurements are used for averaging\n" \
115 "Neighbor RxLev averaging: " HO_CFG_STR_AVG_COUNT) \
116 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100117 HO_CFG_ONE_MEMBER(unsigned int, hodec1_pwr_interval, 6, \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100118 "handover power budget interval", "<1-99>", atoi, "%u", as_is, \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100119 HO_CFG_STR_HANDOVER1 \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100120 HO_CFG_STR_POWER_BUDGET \
121 "How often to check for a better cell (SACCH frames)\n" \
122 "Check for stronger neighbor every N number of SACCH frames\n") \
123 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100124 HO_CFG_ONE_MEMBER(unsigned int, hodec1_pwr_hysteresis, 3, \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100125 "handover power budget hysteresis", "<0-999>", atoi, "%u", as_is, \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100126 HO_CFG_STR_HANDOVER1 \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100127 HO_CFG_STR_POWER_BUDGET \
128 "How many dBm stronger must a neighbor be to become a HO candidate\n" \
129 "Neighbor's strength difference in dBm\n") \
130 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100131 HO_CFG_ONE_MEMBER(unsigned int, hodec1_max_distance, 9999, \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100132 "handover maximum distance" , "<0-9999>", atoi, "%u", as_is, \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100133 HO_CFG_STR_HANDOVER1 \
134 "Maximum Timing-Advance value (i.e. MS distance) before triggering HO\n" \
135 "Maximum Timing-Advance value (i.e. MS distance) before triggering HO\n" \
136 "Maximum Timing-Advance value (i.e. MS distance) before triggering HO\n") \
137
138
139#define HODEC2_CFG_ALL_MEMBERS \
140 \
141 HO_CFG_ONE_MEMBER(unsigned int, hodec2_rxlev_avg_win, 10, \
142 "handover2 window rxlev averaging", "<1-10>", atoi, "%u", as_is, \
143 HO_CFG_STR_HANDOVER2 \
144 HO_CFG_STR_WIN_RXLEV \
145 "How many RxLev measurements are used for averaging\n" \
146 "RxLev averaging: " HO_CFG_STR_AVG_COUNT) \
147 \
148 HO_CFG_ONE_MEMBER(unsigned int, hodec2_rxqual_avg_win, 1, \
149 "handover2 window rxqual averaging", "<1-10>", atoi, "%u", as_is, \
150 HO_CFG_STR_HANDOVER2 \
151 HO_CFG_STR_WIN_RXQUAL \
152 "How many RxQual measurements are used for averaging\n" \
153 "RxQual averaging: " HO_CFG_STR_AVG_COUNT) \
154 \
155 HO_CFG_ONE_MEMBER(unsigned int, hodec2_rxlev_neigh_avg_win, 10, \
156 "handover2 window rxlev neighbor averaging", "<1-10>", atoi, "%u", as_is, \
157 HO_CFG_STR_HANDOVER2 \
158 HO_CFG_STR_WIN_RXLEV \
159 "How many Neighbor RxLev measurements are used for averaging\n" \
160 "How many Neighbor RxLev measurements are used for averaging\n" \
161 "Neighbor RxLev averaging: " HO_CFG_STR_AVG_COUNT) \
162 \
163 HO_CFG_ONE_MEMBER(unsigned int, hodec2_pwr_interval, 6, \
164 "handover2 power budget interval", "<1-99>", atoi, "%u", as_is, \
165 HO_CFG_STR_HANDOVER2 \
166 HO_CFG_STR_POWER_BUDGET \
167 "How often to check for a better cell (SACCH frames)\n" \
168 "Check for stronger neighbor every N number of SACCH frames\n") \
169 \
170 HO_CFG_ONE_MEMBER(unsigned int, hodec2_pwr_hysteresis, 3, \
171 "handover2 power budget hysteresis", "<0-999>", atoi, "%u", as_is, \
172 HO_CFG_STR_HANDOVER2 \
173 HO_CFG_STR_POWER_BUDGET \
174 "How many dBm stronger must a neighbor be to become a HO candidate\n" \
175 "Neighbor's strength difference in dBm\n") \
176 \
177 HO_CFG_ONE_MEMBER(unsigned int, hodec2_max_distance, 9999, \
178 "handover2 maximum distance" , "<0-9999>", atoi, "%u", as_is, \
179 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100180 "Maximum Timing-Advance value (i.e. MS distance) before triggering HO\n" \
181 "Maximum Timing-Advance value (i.e. MS distance) before triggering HO\n" \
182 "Maximum Timing-Advance value (i.e. MS distance) before triggering HO\n") \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100183 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100184 HO_CFG_ONE_MEMBER(bool, hodec2_as_active, 0, \
185 "handover2 assignment", "0|1", a2bool, "%d", bool2i, \
186 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100187 "Enable or disable in-call channel re-assignment" HO_CFG_STR_2 \
188 "Disable in-call assignment\n" \
189 "Enable in-call assignment\n") \
190 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100191 HO_CFG_ONE_MEMBER(bool, hodec2_full_tdma, subset, \
192 "handover2 tdma-measurement", "full|subset", a2tdma, "%s", tdma2a, \
193 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100194 "Define measurement set of TDMA frames" HO_CFG_STR_2 \
195 "Full set of 102/104 TDMA frames\n" \
196 "Sub set of 4 TDMA frames (SACCH)\n") \
197 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100198 HO_CFG_ONE_MEMBER(int, hodec2_min_rxlev, -100, \
199 "handover2 min rxlev", "<-110--50>", atoi, "%d", as_is, \
200 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100201 HO_CFG_STR_MIN \
202 "How weak may RxLev of an MS become before triggering HO\n" \
203 "minimum RxLev (dBm)\n") \
204 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100205 HO_CFG_ONE_MEMBER(int, hodec2_min_rxqual, 5, \
206 "handover2 min rxqual", "<0-7>", atoi, "%d", as_is, \
207 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100208 HO_CFG_STR_MIN \
209 "How bad may RxQual of an MS become before triggering HO\n" \
210 "minimum RxQual (dBm)\n") \
211 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100212 HO_CFG_ONE_MEMBER(int, hodec2_afs_bias_rxlev, 0, \
213 "handover2 afs-bias rxlev", "<0-20>", atoi, "%d", as_is, \
214 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100215 HO_CFG_STR_AFS_BIAS \
216 "RxLev improvement bias for AFS over other codecs\n" \
217 "Virtual RxLev improvement (dBm)\n") \
218 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100219 HO_CFG_ONE_MEMBER(int, hodec2_afs_bias_rxqual, 0, \
220 "handover2 afs-bias rxqual", "<0-7>", atoi, "%d", as_is, \
221 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100222 HO_CFG_STR_AFS_BIAS \
223 "RxQual improvement bias for AFS over other codecs\n" \
224 "Virtual RxQual improvement (dBm)\n") \
225 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100226 HO_CFG_ONE_MEMBER(int, hodec2_tchf_min_slots, 0, \
227 "handover2 min-free-slots tch/f", "<0-9999>", atoi, "%d", as_is, \
228 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100229 HO_CFG_STR_MIN_TCH \
230 "Minimum free TCH/F timeslots before cell is considered congested\n" \
231 "Number of TCH/F slots\n") \
232 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100233 HO_CFG_ONE_MEMBER(int, hodec2_tchh_min_slots, 0, \
234 "handover2 min-free-slots tch/h", "<0-9999>", atoi, "%d", as_is, \
235 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100236 HO_CFG_STR_MIN_TCH \
237 "Minimum free TCH/H timeslots before cell is considered congested\n" \
238 "Number of TCH/H slots\n") \
239 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100240 HO_CFG_ONE_MEMBER(int, hodec2_ho_max, 9999, \
241 "handover2 max-handovers", "<1-9999>", atoi, "%d", as_is, \
242 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100243 "Maximum number of concurrent handovers allowed per cell" HO_CFG_STR_2 \
244 "Number\n") \
245 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100246 HO_CFG_ONE_MEMBER(int, hodec2_penalty_max_dist, 300, \
247 "handover2 penalty-time max-distance", "<0-99999>", atoi, "%d", as_is, \
248 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100249 HO_CFG_STR_PENALTY_TIME \
250 "Time to suspend handovers after leaving this cell due to exceeding max distance\n" \
251 "Seconds\n") \
252 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100253 HO_CFG_ONE_MEMBER(int, hodec2_penalty_failed_ho, 60, \
254 "handover2 penalty-time failed-ho", "<0-99999>", atoi, "%d", as_is, \
255 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100256 HO_CFG_STR_PENALTY_TIME \
257 "Time to suspend handovers after handover failure to this cell\n" \
258 "Seconds\n") \
259 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100260 HO_CFG_ONE_MEMBER(int, hodec2_penalty_failed_as, 60, \
261 "handover2 penalty-time failed-assignment", "<0-99999>", atoi, "%d", as_is, \
262 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100263 HO_CFG_STR_PENALTY_TIME \
264 "Time to suspend handovers after assignment failure in this cell\n" \
265 "Seconds\n") \
266 \
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100267 HO_CFG_ONE_MEMBER(int, hodec2_retries, 0, \
268 "handover2 retries", "<0-9>", atoi, "%d", as_is, \
269 HO_CFG_STR_HANDOVER2 \
Neels Hofmeyr87b5eb62017-12-07 01:55:58 +0100270 "Immediately retry on handover/assignment failure" HO_CFG_STR_2 \
271 "Number of retries\n") \
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100272
Neels Hofmeyrdd42eb92018-02-14 19:56:23 +0100273#define HO_CFG_ALL_MEMBERS \
274 HO_GENERAL_CFG_ALL_MEMBERS \
275 HODEC1_CFG_ALL_MEMBERS \
276 HODEC2_CFG_ALL_MEMBERS \
277
Neels Hofmeyre25018b2017-11-27 21:29:33 +0100278
279/* Declare public API for handover cfg parameters... */
280
281#define HO_CFG_ONE_MEMBER(TYPE, NAME, DEFAULT_VAL, VTY1, VTY2, VTY3, VTY4, VTY5, VTY6) \
282 TYPE ho_get_##NAME(struct handover_cfg *ho); \
283 void ho_set_##NAME(struct handover_cfg *ho, TYPE val); \
284 bool ho_isset_##NAME(struct handover_cfg *ho); \
285 void ho_clear_##NAME(struct handover_cfg *ho); \
286 bool ho_isset_on_parent_##NAME(struct handover_cfg *ho);
287
288HO_CFG_ALL_MEMBERS
289#undef HO_CFG_ONE_MEMBER