blob: 3ab6865ce75c7af76756f308a398f8c3efd560e6 [file] [log] [blame]
Andreas Eversberg12942562012-07-12 14:31:57 +02001/* OsmoBTS VTY interface */
2
Andreas Eversberg12942562012-07-12 14:31:57 +02003
Andreas Eversberg8b761a32012-07-20 21:50:31 +02004#include <stdint.h>
Andreas Eversberg12942562012-07-12 14:31:57 +02005#include <osmocom/vty/logging.h>
Andreas Eversberg8b761a32012-07-20 21:50:31 +02006#include <osmocom/core/linuxlist.h>
Andreas Eversberg12942562012-07-12 14:31:57 +02007#include "pcu_vty.h"
Andreas Eversberg8b761a32012-07-20 21:50:31 +02008#include "gprs_rlcmac.h"
Andreas Eversberg12942562012-07-12 14:31:57 +02009
10enum node_type pcu_vty_go_parent(struct vty *vty)
11{
12 switch (vty->node) {
13#if 0
14 case TRX_NODE:
Andreas Eversberg8b761a32012-07-20 21:50:31 +020015 vty->node = PCU_NODE;
Andreas Eversberg12942562012-07-12 14:31:57 +020016 {
17 struct gsm_bts_trx *trx = vty->index;
18 vty->index = trx->bts;
19 }
20 break;
21#endif
22 default:
23 vty->node = CONFIG_NODE;
24 }
Andreas Eversberg8b761a32012-07-20 21:50:31 +020025 return (enum node_type) vty->node;
Andreas Eversberg12942562012-07-12 14:31:57 +020026}
27
28int pcu_vty_is_config_node(struct vty *vty, int node)
29{
30 switch (node) {
Andreas Eversberg8b761a32012-07-20 21:50:31 +020031 case PCU_NODE:
Andreas Eversberg12942562012-07-12 14:31:57 +020032 return 1;
Andreas Eversberg12942562012-07-12 14:31:57 +020033 default:
34 return 0;
35 }
36}
37
Andreas Eversberg8b761a32012-07-20 21:50:31 +020038static struct cmd_node pcu_node = {
39 (enum node_type) PCU_NODE,
40 "%s(pcu)#",
41 1,
42};
43
Andreas Eversberg12942562012-07-12 14:31:57 +020044gDEFUN(ournode_exit, ournode_exit_cmd, "exit",
45 "Exit current node, go down to provious node")
46{
47 switch (vty->node) {
48#if 0
49 case TRXV_NODE:
Andreas Eversberg8b761a32012-07-20 21:50:31 +020050 vty->node = PCU_NODE;
Andreas Eversberg12942562012-07-12 14:31:57 +020051 {
52 struct gsm_bts_trx *trx = vty->index;
53 vty->index = trx->bts;
54 }
55 break;
56#endif
57 default:
58 break;
59 }
60 return CMD_SUCCESS;
61}
62
63gDEFUN(ournode_end, ournode_end_cmd, "end",
64 "End current mode and change to enable mode")
65{
66 switch (vty->node) {
67 default:
68 vty_config_unlock(vty);
69 vty->node = ENABLE_NODE;
70 vty->index = NULL;
71 vty->index_sub = NULL;
72 break;
73 }
74 return CMD_SUCCESS;
75}
76
Andreas Eversberg8b761a32012-07-20 21:50:31 +020077static int config_write_pcu(struct vty *vty)
78{
79 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
80
81 vty_out(vty, "pcu%s", VTY_NEWLINE);
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +020082 vty_out(vty, " flow-control-interval %d%s", bts->fc_interval,
83 VTY_NEWLINE);
Andreas Eversberg8b761a32012-07-20 21:50:31 +020084 if (bts->force_cs)
Andreas Eversberg499ff412012-10-03 14:21:36 +020085 if (bts->initial_cs_ul == bts->initial_cs_dl)
86 vty_out(vty, " cs %d%s", bts->initial_cs_dl,
87 VTY_NEWLINE);
88 else
89 vty_out(vty, " cs %d %d%s", bts->initial_cs_dl,
90 bts->initial_cs_ul, VTY_NEWLINE);
Andreas Eversberg24131bf2012-07-21 11:09:58 +020091 if (bts->force_llc_lifetime == 0xffff)
92 vty_out(vty, " queue lifetime infinite%s", VTY_NEWLINE);
93 else if (bts->force_llc_lifetime)
94 vty_out(vty, " queue lifetime %d%s", bts->force_llc_lifetime,
95 VTY_NEWLINE);
Andreas Eversberga1503fa2012-07-22 08:58:09 +020096 if (bts->alloc_algorithm == alloc_algorithm_a)
97 vty_out(vty, " alloc-algorithm a%s", VTY_NEWLINE);
98 if (bts->alloc_algorithm == alloc_algorithm_b)
99 vty_out(vty, " alloc-algorithm b%s", VTY_NEWLINE);
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200100 if (bts->force_two_phase)
101 vty_out(vty, " two-phase-access%s", VTY_NEWLINE);
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200102 vty_out(vty, " alpha %d%s", bts->alpha, VTY_NEWLINE);
103 vty_out(vty, " gamma %d%s", bts->gamma * 2, VTY_NEWLINE);
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200104
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200105}
106
107/* per-BTS configuration */
108DEFUN(cfg_pcu,
109 cfg_pcu_cmd,
110 "pcu",
111 "BTS specific configure")
112{
113 vty->node = PCU_NODE;
114
115 return CMD_SUCCESS;
116}
117
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200118DEFUN(cfg_pcu_fc_interval,
119 cfg_pcu_fc_interval_cmd,
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200120 "flow-control-interval <1-10>",
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200121 "Interval between sending subsequent Flow Control PDUs\n"
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200122 "Interval time in seconds\n")
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200123{
124 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
125
126 bts->fc_interval = atoi(argv[0]);
127
128 return CMD_SUCCESS;
129}
130
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200131DEFUN(cfg_pcu_cs,
132 cfg_pcu_cs_cmd,
Andreas Eversberg499ff412012-10-03 14:21:36 +0200133 "cs <1-4> [<1-4>]",
134 "Set the Coding Scheme to be used, (overrides BTS config)\n"
135 "Initial CS used\nAlternative uplink CS")
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200136{
137 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
138 uint8_t cs = atoi(argv[0]);
139
140 bts->force_cs = 1;
Andreas Eversberg499ff412012-10-03 14:21:36 +0200141 bts->initial_cs_dl = cs;
142 if (argc > 1)
143 bts->initial_cs_ul = atoi(argv[1]);
144 else
145 bts->initial_cs_ul = cs;
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200146
147 return CMD_SUCCESS;
148}
149
150DEFUN(cfg_pcu_no_cs,
151 cfg_pcu_no_cs_cmd,
152 "no cs",
153 NO_STR "Don't force given Coding Scheme, (use BTS config)\n")
154{
155 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
156
157 bts->force_cs = 0;
158
159 return CMD_SUCCESS;
160}
161
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200162#define QUEUE_STR "Packet queue options\n"
163#define LIFETIME_STR "Set lifetime limit of LLC frame in centi-seconds " \
164 "(overrides the value given by SGSN)\n"
165
166DEFUN(cfg_pcu_queue_lifetime,
167 cfg_pcu_queue_lifetime_cmd,
168 "queue lifetime <1-65534>",
169 QUEUE_STR LIFETIME_STR "Lifetime in centi-seconds")
170{
171 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
172 uint8_t csec = atoi(argv[0]);
173
174 bts->force_llc_lifetime = csec;
175
176 return CMD_SUCCESS;
177}
178
179DEFUN(cfg_pcu_queue_lifetime_inf,
180 cfg_pcu_queue_lifetime_inf_cmd,
181 "queue lifetime infinite",
182 QUEUE_STR LIFETIME_STR "Infinite lifetime")
183{
184 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
185
186 bts->force_llc_lifetime = 0xffff;
187
188 return CMD_SUCCESS;
189}
190
191DEFUN(cfg_pcu_no_queue_lifetime,
192 cfg_pcu_no_queue_lifetime_cmd,
193 "no queue lifetime",
194 NO_STR QUEUE_STR "Disable lifetime limit of LLC frame (use value given "
195 "by SGSN)\n")
196{
197 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
198
199 bts->force_llc_lifetime = 0;
200
201 return CMD_SUCCESS;
202}
203
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200204DEFUN(cfg_pcu_alloc,
205 cfg_pcu_alloc_cmd,
206 "alloc-algorithm (a|b)",
207 "Select slot allocation algorithm to use when assigning timeslots on "
208 "PACCH\nSingle slot is assigned only\nMultiple slots are assigned for "
209 "semi-duplex operation")
210{
211 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
212
213 switch (argv[0][0]) {
214 case 'a':
215 bts->alloc_algorithm = alloc_algorithm_a;
216 break;
217 case 'b':
218 bts->alloc_algorithm = alloc_algorithm_b;
219 break;
220 }
221
222 return CMD_SUCCESS;
223}
224
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200225DEFUN(cfg_pcu_two_phase,
226 cfg_pcu_two_phase_cmd,
227 "two-phase-access",
228 "Force two phase access when MS requests single phase access\n")
229{
230 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
231
232 bts->force_two_phase = 1;
233
234 return CMD_SUCCESS;
235}
236
237DEFUN(cfg_pcu_no_two_phase,
238 cfg_pcu_no_two_phase_cmd,
239 "no two-phase-access",
240 NO_STR "Only use two phase access when requested my MS\n")
241{
242 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
243
244 bts->force_two_phase = 0;
245
246 return CMD_SUCCESS;
247}
248
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200249DEFUN(cfg_pcu_alpha,
250 cfg_pcu_alpha_cmd,
251 "alpha <0-10>",
252 "Alpha parameter for MS power control in units of 0.1 (see TS 05.08) "
253 "NOTE: Be sure to set Alpha value at System information 13 too.\n"
254 "Alpha in units of 0.1\n")
255{
256 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
257
258 bts->alpha = atoi(argv[0]);
259
260 return CMD_SUCCESS;
261}
262
263DEFUN(cfg_pcu_gamma,
264 cfg_pcu_gamma_cmd,
265 "gamma <0-62>",
266 "Gamma parameter for MS power control in units of dB (see TS 05.08)\n"
267 "Gamma in even unit of dBs\n")
268{
269 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
270
271 bts->gamma = atoi(argv[0]) / 2;
272
273 return CMD_SUCCESS;
274}
275
Andreas Eversberg12942562012-07-12 14:31:57 +0200276static const char pcu_copyright[] =
Harald Welted1e340f2013-01-17 12:24:29 +0100277 "Copyright (C) 2012 by Ivan Kluchnikov <kluchnikovi@gmail.com> and \r\n"
278 " Andreas Eversberg <jolly@eversberg.eu>\r\n"
Andreas Eversberg12942562012-07-12 14:31:57 +0200279 "License GNU GPL version 2 or later\r\n"
280 "This is free software: you are free to change and redistribute it.\r\n"
281 "There is NO WARRANTY, to the extent permitted by law.\r\n";
282
283struct vty_app_info pcu_vty_info = {
284 .name = "Osmo-PCU",
285 .version = PACKAGE_VERSION,
286 .copyright = pcu_copyright,
287 .go_parent_cb = pcu_vty_go_parent,
288 .is_config_node = pcu_vty_is_config_node,
289};
290
291int pcu_vty_init(const struct log_info *cat)
292{
293// install_element_ve(&show_pcu_cmd);
294
295 logging_vty_add_cmds(cat);
296
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200297 install_node(&pcu_node, config_write_pcu);
298 install_element(CONFIG_NODE, &cfg_pcu_cmd);
299 install_default(PCU_NODE);
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200300 install_element(PCU_NODE, &cfg_pcu_no_two_phase_cmd);
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200301 install_element(PCU_NODE, &cfg_pcu_cs_cmd);
302 install_element(PCU_NODE, &cfg_pcu_no_cs_cmd);
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200303 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_cmd);
304 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_inf_cmd);
305 install_element(PCU_NODE, &cfg_pcu_no_queue_lifetime_cmd);
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200306 install_element(PCU_NODE, &cfg_pcu_alloc_cmd);
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200307 install_element(PCU_NODE, &cfg_pcu_two_phase_cmd);
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200308 install_element(PCU_NODE, &cfg_pcu_fc_interval_cmd);
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200309 install_element(PCU_NODE, &cfg_pcu_alpha_cmd);
310 install_element(PCU_NODE, &cfg_pcu_gamma_cmd);
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200311 install_element(PCU_NODE, &ournode_end_cmd);
312
Andreas Eversberg12942562012-07-12 14:31:57 +0200313 return 0;
314}