blob: 39a1b72251c518fcec307c57498a586ee46c1ee2 [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);
82 if (bts->force_cs)
83 vty_out(vty, " cs %d%s", bts->initial_cs, VTY_NEWLINE);
Andreas Eversberg24131bf2012-07-21 11:09:58 +020084 if (bts->force_llc_lifetime == 0xffff)
85 vty_out(vty, " queue lifetime infinite%s", VTY_NEWLINE);
86 else if (bts->force_llc_lifetime)
87 vty_out(vty, " queue lifetime %d%s", bts->force_llc_lifetime,
88 VTY_NEWLINE);
Andreas Eversberga1503fa2012-07-22 08:58:09 +020089 if (bts->alloc_algorithm == alloc_algorithm_a)
90 vty_out(vty, " alloc-algorithm a%s", VTY_NEWLINE);
91 if (bts->alloc_algorithm == alloc_algorithm_b)
92 vty_out(vty, " alloc-algorithm b%s", VTY_NEWLINE);
Andreas Eversberg07e97cf2012-08-07 16:00:56 +020093 if (bts->force_two_phase)
94 vty_out(vty, " two-phase-access%s", VTY_NEWLINE);
Andreas Eversberga1503fa2012-07-22 08:58:09 +020095
Andreas Eversberg8b761a32012-07-20 21:50:31 +020096}
97
98/* per-BTS configuration */
99DEFUN(cfg_pcu,
100 cfg_pcu_cmd,
101 "pcu",
102 "BTS specific configure")
103{
104 vty->node = PCU_NODE;
105
106 return CMD_SUCCESS;
107}
108
109DEFUN(cfg_pcu_cs,
110 cfg_pcu_cs_cmd,
111 "cs <1-4>",
112 "Set the Coding Scheme to be used, (overrides BTS config)\n")
113{
114 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
115 uint8_t cs = atoi(argv[0]);
116
117 bts->force_cs = 1;
118 bts->initial_cs = cs;
119
120 return CMD_SUCCESS;
121}
122
123DEFUN(cfg_pcu_no_cs,
124 cfg_pcu_no_cs_cmd,
125 "no cs",
126 NO_STR "Don't force given Coding Scheme, (use BTS config)\n")
127{
128 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
129
130 bts->force_cs = 0;
131
132 return CMD_SUCCESS;
133}
134
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200135#define QUEUE_STR "Packet queue options\n"
136#define LIFETIME_STR "Set lifetime limit of LLC frame in centi-seconds " \
137 "(overrides the value given by SGSN)\n"
138
139DEFUN(cfg_pcu_queue_lifetime,
140 cfg_pcu_queue_lifetime_cmd,
141 "queue lifetime <1-65534>",
142 QUEUE_STR LIFETIME_STR "Lifetime in centi-seconds")
143{
144 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
145 uint8_t csec = atoi(argv[0]);
146
147 bts->force_llc_lifetime = csec;
148
149 return CMD_SUCCESS;
150}
151
152DEFUN(cfg_pcu_queue_lifetime_inf,
153 cfg_pcu_queue_lifetime_inf_cmd,
154 "queue lifetime infinite",
155 QUEUE_STR LIFETIME_STR "Infinite lifetime")
156{
157 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
158
159 bts->force_llc_lifetime = 0xffff;
160
161 return CMD_SUCCESS;
162}
163
164DEFUN(cfg_pcu_no_queue_lifetime,
165 cfg_pcu_no_queue_lifetime_cmd,
166 "no queue lifetime",
167 NO_STR QUEUE_STR "Disable lifetime limit of LLC frame (use value given "
168 "by SGSN)\n")
169{
170 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
171
172 bts->force_llc_lifetime = 0;
173
174 return CMD_SUCCESS;
175}
176
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200177DEFUN(cfg_pcu_alloc,
178 cfg_pcu_alloc_cmd,
179 "alloc-algorithm (a|b)",
180 "Select slot allocation algorithm to use when assigning timeslots on "
181 "PACCH\nSingle slot is assigned only\nMultiple slots are assigned for "
182 "semi-duplex operation")
183{
184 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
185
186 switch (argv[0][0]) {
187 case 'a':
188 bts->alloc_algorithm = alloc_algorithm_a;
189 break;
190 case 'b':
191 bts->alloc_algorithm = alloc_algorithm_b;
192 break;
193 }
194
195 return CMD_SUCCESS;
196}
197
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200198DEFUN(cfg_pcu_two_phase,
199 cfg_pcu_two_phase_cmd,
200 "two-phase-access",
201 "Force two phase access when MS requests single phase access\n")
202{
203 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
204
205 bts->force_two_phase = 1;
206
207 return CMD_SUCCESS;
208}
209
210DEFUN(cfg_pcu_no_two_phase,
211 cfg_pcu_no_two_phase_cmd,
212 "no two-phase-access",
213 NO_STR "Only use two phase access when requested my MS\n")
214{
215 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
216
217 bts->force_two_phase = 0;
218
219 return CMD_SUCCESS;
220}
221
Andreas Eversberg12942562012-07-12 14:31:57 +0200222static const char pcu_copyright[] =
223 "Copyright (C) 2012 by ...\r\n"
224 "License GNU GPL version 2 or later\r\n"
225 "This is free software: you are free to change and redistribute it.\r\n"
226 "There is NO WARRANTY, to the extent permitted by law.\r\n";
227
228struct vty_app_info pcu_vty_info = {
229 .name = "Osmo-PCU",
230 .version = PACKAGE_VERSION,
231 .copyright = pcu_copyright,
232 .go_parent_cb = pcu_vty_go_parent,
233 .is_config_node = pcu_vty_is_config_node,
234};
235
236int pcu_vty_init(const struct log_info *cat)
237{
238// install_element_ve(&show_pcu_cmd);
239
240 logging_vty_add_cmds(cat);
241
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200242 install_node(&pcu_node, config_write_pcu);
243 install_element(CONFIG_NODE, &cfg_pcu_cmd);
244 install_default(PCU_NODE);
245 install_element(PCU_NODE, &cfg_pcu_cs_cmd);
246 install_element(PCU_NODE, &cfg_pcu_no_cs_cmd);
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200247 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_cmd);
248 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_inf_cmd);
249 install_element(PCU_NODE, &cfg_pcu_no_queue_lifetime_cmd);
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200250 install_element(PCU_NODE, &cfg_pcu_alloc_cmd);
Andreas Eversberg07e97cf2012-08-07 16:00:56 +0200251 install_element(PCU_NODE, &cfg_pcu_two_phase_cmd);
252 install_element(PCU_NODE, &cfg_pcu_no_two_phase_cmd);
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200253 install_element(PCU_NODE, &ournode_end_cmd);
254
Andreas Eversberg12942562012-07-12 14:31:57 +0200255 return 0;
256}