blob: 8d5b47b149d35c89abf39c25ca57ae66c0c44c37 [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 Eversberga1503fa2012-07-22 08:58:09 +020097
Andreas Eversberg8b761a32012-07-20 21:50:31 +020098}
99
100/* per-BTS configuration */
101DEFUN(cfg_pcu,
102 cfg_pcu_cmd,
103 "pcu",
104 "BTS specific configure")
105{
106 vty->node = PCU_NODE;
107
108 return CMD_SUCCESS;
109}
110
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200111DEFUN(cfg_pcu_fc_interval,
112 cfg_pcu_fc_interval_cmd,
113 "flow-control-interval <1..10>",
114 "Interval between sending subsequent Flow Control PDUs\n"
115 "Tiem in seconds\n")
116{
117 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
118
119 bts->fc_interval = atoi(argv[0]);
120
121 return CMD_SUCCESS;
122}
123
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200124DEFUN(cfg_pcu_cs,
125 cfg_pcu_cs_cmd,
126 "cs <1-4>",
127 "Set the Coding Scheme to be used, (overrides BTS config)\n")
128{
129 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
130 uint8_t cs = atoi(argv[0]);
131
132 bts->force_cs = 1;
133 bts->initial_cs = cs;
134
135 return CMD_SUCCESS;
136}
137
138DEFUN(cfg_pcu_no_cs,
139 cfg_pcu_no_cs_cmd,
140 "no cs",
141 NO_STR "Don't force given Coding Scheme, (use BTS config)\n")
142{
143 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
144
145 bts->force_cs = 0;
146
147 return CMD_SUCCESS;
148}
149
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200150#define QUEUE_STR "Packet queue options\n"
151#define LIFETIME_STR "Set lifetime limit of LLC frame in centi-seconds " \
152 "(overrides the value given by SGSN)\n"
153
154DEFUN(cfg_pcu_queue_lifetime,
155 cfg_pcu_queue_lifetime_cmd,
156 "queue lifetime <1-65534>",
157 QUEUE_STR LIFETIME_STR "Lifetime in centi-seconds")
158{
159 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
160 uint8_t csec = atoi(argv[0]);
161
162 bts->force_llc_lifetime = csec;
163
164 return CMD_SUCCESS;
165}
166
167DEFUN(cfg_pcu_queue_lifetime_inf,
168 cfg_pcu_queue_lifetime_inf_cmd,
169 "queue lifetime infinite",
170 QUEUE_STR LIFETIME_STR "Infinite lifetime")
171{
172 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
173
174 bts->force_llc_lifetime = 0xffff;
175
176 return CMD_SUCCESS;
177}
178
179DEFUN(cfg_pcu_no_queue_lifetime,
180 cfg_pcu_no_queue_lifetime_cmd,
181 "no queue lifetime",
182 NO_STR QUEUE_STR "Disable lifetime limit of LLC frame (use value given "
183 "by SGSN)\n")
184{
185 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
186
187 bts->force_llc_lifetime = 0;
188
189 return CMD_SUCCESS;
190}
191
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200192DEFUN(cfg_pcu_alloc,
193 cfg_pcu_alloc_cmd,
194 "alloc-algorithm (a|b)",
195 "Select slot allocation algorithm to use when assigning timeslots on "
196 "PACCH\nSingle slot is assigned only\nMultiple slots are assigned for "
197 "semi-duplex operation")
198{
199 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
200
201 switch (argv[0][0]) {
202 case 'a':
203 bts->alloc_algorithm = alloc_algorithm_a;
204 break;
205 case 'b':
206 bts->alloc_algorithm = alloc_algorithm_b;
207 break;
208 }
209
210 return CMD_SUCCESS;
211}
212
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200213DEFUN(cfg_pcu_two_phase,
214 cfg_pcu_two_phase_cmd,
215 "two-phase-access",
216 "Force two phase access when MS requests single phase access\n")
217{
218 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
219
220 bts->force_two_phase = 1;
221
222 return CMD_SUCCESS;
223}
224
225DEFUN(cfg_pcu_no_two_phase,
226 cfg_pcu_no_two_phase_cmd,
227 "no two-phase-access",
228 NO_STR "Only use two phase access when requested my MS\n")
229{
230 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
231
232 bts->force_two_phase = 0;
233
234 return CMD_SUCCESS;
235}
236
Andreas Eversberg12942562012-07-12 14:31:57 +0200237static const char pcu_copyright[] =
238 "Copyright (C) 2012 by ...\r\n"
239 "License GNU GPL version 2 or later\r\n"
240 "This is free software: you are free to change and redistribute it.\r\n"
241 "There is NO WARRANTY, to the extent permitted by law.\r\n";
242
243struct vty_app_info pcu_vty_info = {
244 .name = "Osmo-PCU",
245 .version = PACKAGE_VERSION,
246 .copyright = pcu_copyright,
247 .go_parent_cb = pcu_vty_go_parent,
248 .is_config_node = pcu_vty_is_config_node,
249};
250
251int pcu_vty_init(const struct log_info *cat)
252{
253// install_element_ve(&show_pcu_cmd);
254
255 logging_vty_add_cmds(cat);
256
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200257 install_node(&pcu_node, config_write_pcu);
258 install_element(CONFIG_NODE, &cfg_pcu_cmd);
259 install_default(PCU_NODE);
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200260 install_element(PCU_NODE, &cfg_pcu_no_two_phase_cmd);
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200261 install_element(PCU_NODE, &cfg_pcu_cs_cmd);
262 install_element(PCU_NODE, &cfg_pcu_no_cs_cmd);
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200263 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_cmd);
264 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_inf_cmd);
265 install_element(PCU_NODE, &cfg_pcu_no_queue_lifetime_cmd);
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200266 install_element(PCU_NODE, &cfg_pcu_alloc_cmd);
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200267 install_element(PCU_NODE, &cfg_pcu_two_phase_cmd);
Andreas Eversbergcd8a83a2012-09-23 06:41:21 +0200268 install_element(PCU_NODE, &cfg_pcu_fc_interval_cmd);
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200269 install_element(PCU_NODE, &ournode_end_cmd);
270
Andreas Eversberg12942562012-07-12 14:31:57 +0200271 return 0;
272}