blob: d7c2c2cd5e573da93b80007e782cc20ab5bc5ac9 [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)
85 vty_out(vty, " cs %d%s", bts->initial_cs, VTY_NEWLINE);
Andreas Eversberg24131bf2012-07-21 11:09:58 +020086 if (bts->force_llc_lifetime == 0xffff)
87 vty_out(vty, " queue lifetime infinite%s", VTY_NEWLINE);
88 else if (bts->force_llc_lifetime)
89 vty_out(vty, " queue lifetime %d%s", bts->force_llc_lifetime,
90 VTY_NEWLINE);
Andreas Eversberga1503fa2012-07-22 08:58:09 +020091 if (bts->alloc_algorithm == alloc_algorithm_a)
92 vty_out(vty, " alloc-algorithm a%s", VTY_NEWLINE);
93 if (bts->alloc_algorithm == alloc_algorithm_b)
94 vty_out(vty, " alloc-algorithm b%s", VTY_NEWLINE);
Andreas Eversberg07e97cf2012-08-07 16:00:56 +020095 if (bts->force_two_phase)
96 vty_out(vty, " two-phase-access%s", VTY_NEWLINE);
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +020097 vty_out(vty, " alpha %d%s", bts->alpha, VTY_NEWLINE);
98 vty_out(vty, " gamma %d%s", bts->gamma * 2, VTY_NEWLINE);
Andreas Eversberga1503fa2012-07-22 08:58:09 +020099
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200100}
101
102/* per-BTS configuration */
103DEFUN(cfg_pcu,
104 cfg_pcu_cmd,
105 "pcu",
106 "BTS specific configure")
107{
108 vty->node = PCU_NODE;
109
110 return CMD_SUCCESS;
111}
112
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200113DEFUN(cfg_pcu_fc_interval,
114 cfg_pcu_fc_interval_cmd,
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200115 "flow-control-interval <1-10>",
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200116 "Interval between sending subsequent Flow Control PDUs\n"
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200117 "Interval time in seconds\n")
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200118{
119 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
120
121 bts->fc_interval = atoi(argv[0]);
122
123 return CMD_SUCCESS;
124}
125
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200126DEFUN(cfg_pcu_cs,
127 cfg_pcu_cs_cmd,
128 "cs <1-4>",
129 "Set the Coding Scheme to be used, (overrides BTS config)\n")
130{
131 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
132 uint8_t cs = atoi(argv[0]);
133
134 bts->force_cs = 1;
135 bts->initial_cs = cs;
136
137 return CMD_SUCCESS;
138}
139
140DEFUN(cfg_pcu_no_cs,
141 cfg_pcu_no_cs_cmd,
142 "no cs",
143 NO_STR "Don't force given Coding Scheme, (use BTS config)\n")
144{
145 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
146
147 bts->force_cs = 0;
148
149 return CMD_SUCCESS;
150}
151
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200152#define QUEUE_STR "Packet queue options\n"
153#define LIFETIME_STR "Set lifetime limit of LLC frame in centi-seconds " \
154 "(overrides the value given by SGSN)\n"
155
156DEFUN(cfg_pcu_queue_lifetime,
157 cfg_pcu_queue_lifetime_cmd,
158 "queue lifetime <1-65534>",
159 QUEUE_STR LIFETIME_STR "Lifetime in centi-seconds")
160{
161 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
162 uint8_t csec = atoi(argv[0]);
163
164 bts->force_llc_lifetime = csec;
165
166 return CMD_SUCCESS;
167}
168
169DEFUN(cfg_pcu_queue_lifetime_inf,
170 cfg_pcu_queue_lifetime_inf_cmd,
171 "queue lifetime infinite",
172 QUEUE_STR LIFETIME_STR "Infinite lifetime")
173{
174 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
175
176 bts->force_llc_lifetime = 0xffff;
177
178 return CMD_SUCCESS;
179}
180
181DEFUN(cfg_pcu_no_queue_lifetime,
182 cfg_pcu_no_queue_lifetime_cmd,
183 "no queue lifetime",
184 NO_STR QUEUE_STR "Disable lifetime limit of LLC frame (use value given "
185 "by SGSN)\n")
186{
187 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
188
189 bts->force_llc_lifetime = 0;
190
191 return CMD_SUCCESS;
192}
193
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200194DEFUN(cfg_pcu_alloc,
195 cfg_pcu_alloc_cmd,
196 "alloc-algorithm (a|b)",
197 "Select slot allocation algorithm to use when assigning timeslots on "
198 "PACCH\nSingle slot is assigned only\nMultiple slots are assigned for "
199 "semi-duplex operation")
200{
201 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
202
203 switch (argv[0][0]) {
204 case 'a':
205 bts->alloc_algorithm = alloc_algorithm_a;
206 break;
207 case 'b':
208 bts->alloc_algorithm = alloc_algorithm_b;
209 break;
210 }
211
212 return CMD_SUCCESS;
213}
214
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200215DEFUN(cfg_pcu_two_phase,
216 cfg_pcu_two_phase_cmd,
217 "two-phase-access",
218 "Force two phase access when MS requests single phase access\n")
219{
220 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
221
222 bts->force_two_phase = 1;
223
224 return CMD_SUCCESS;
225}
226
227DEFUN(cfg_pcu_no_two_phase,
228 cfg_pcu_no_two_phase_cmd,
229 "no two-phase-access",
230 NO_STR "Only use two phase access when requested my MS\n")
231{
232 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
233
234 bts->force_two_phase = 0;
235
236 return CMD_SUCCESS;
237}
238
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200239DEFUN(cfg_pcu_alpha,
240 cfg_pcu_alpha_cmd,
241 "alpha <0-10>",
242 "Alpha parameter for MS power control in units of 0.1 (see TS 05.08) "
243 "NOTE: Be sure to set Alpha value at System information 13 too.\n"
244 "Alpha in units of 0.1\n")
245{
246 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
247
248 bts->alpha = atoi(argv[0]);
249
250 return CMD_SUCCESS;
251}
252
253DEFUN(cfg_pcu_gamma,
254 cfg_pcu_gamma_cmd,
255 "gamma <0-62>",
256 "Gamma parameter for MS power control in units of dB (see TS 05.08)\n"
257 "Gamma in even unit of dBs\n")
258{
259 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
260
261 bts->gamma = atoi(argv[0]) / 2;
262
263 return CMD_SUCCESS;
264}
265
Andreas Eversberg12942562012-07-12 14:31:57 +0200266static const char pcu_copyright[] =
267 "Copyright (C) 2012 by ...\r\n"
268 "License GNU GPL version 2 or later\r\n"
269 "This is free software: you are free to change and redistribute it.\r\n"
270 "There is NO WARRANTY, to the extent permitted by law.\r\n";
271
272struct vty_app_info pcu_vty_info = {
273 .name = "Osmo-PCU",
274 .version = PACKAGE_VERSION,
275 .copyright = pcu_copyright,
276 .go_parent_cb = pcu_vty_go_parent,
277 .is_config_node = pcu_vty_is_config_node,
278};
279
280int pcu_vty_init(const struct log_info *cat)
281{
282// install_element_ve(&show_pcu_cmd);
283
284 logging_vty_add_cmds(cat);
285
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200286 install_node(&pcu_node, config_write_pcu);
287 install_element(CONFIG_NODE, &cfg_pcu_cmd);
288 install_default(PCU_NODE);
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200289 install_element(PCU_NODE, &cfg_pcu_no_two_phase_cmd);
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200290 install_element(PCU_NODE, &cfg_pcu_cs_cmd);
291 install_element(PCU_NODE, &cfg_pcu_no_cs_cmd);
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200292 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_cmd);
293 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_inf_cmd);
294 install_element(PCU_NODE, &cfg_pcu_no_queue_lifetime_cmd);
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200295 install_element(PCU_NODE, &cfg_pcu_alloc_cmd);
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200296 install_element(PCU_NODE, &cfg_pcu_two_phase_cmd);
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200297 install_element(PCU_NODE, &cfg_pcu_fc_interval_cmd);
Andreas Eversbergaafcbbb2012-09-27 09:20:45 +0200298 install_element(PCU_NODE, &cfg_pcu_alpha_cmd);
299 install_element(PCU_NODE, &cfg_pcu_gamma_cmd);
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200300 install_element(PCU_NODE, &ournode_end_cmd);
301
Andreas Eversberg12942562012-07-12 14:31:57 +0200302 return 0;
303}