blob: e5d37658d4f620a4b9529d06dd40a5f9f6a1b7dc [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);
93
Andreas Eversberg8b761a32012-07-20 21:50:31 +020094}
95
96/* per-BTS configuration */
97DEFUN(cfg_pcu,
98 cfg_pcu_cmd,
99 "pcu",
100 "BTS specific configure")
101{
102 vty->node = PCU_NODE;
103
104 return CMD_SUCCESS;
105}
106
107DEFUN(cfg_pcu_cs,
108 cfg_pcu_cs_cmd,
109 "cs <1-4>",
110 "Set the Coding Scheme to be used, (overrides BTS config)\n")
111{
112 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
113 uint8_t cs = atoi(argv[0]);
114
115 bts->force_cs = 1;
116 bts->initial_cs = cs;
117
118 return CMD_SUCCESS;
119}
120
121DEFUN(cfg_pcu_no_cs,
122 cfg_pcu_no_cs_cmd,
123 "no cs",
124 NO_STR "Don't force given Coding Scheme, (use BTS config)\n")
125{
126 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
127
128 bts->force_cs = 0;
129
130 return CMD_SUCCESS;
131}
132
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200133#define QUEUE_STR "Packet queue options\n"
134#define LIFETIME_STR "Set lifetime limit of LLC frame in centi-seconds " \
135 "(overrides the value given by SGSN)\n"
136
137DEFUN(cfg_pcu_queue_lifetime,
138 cfg_pcu_queue_lifetime_cmd,
139 "queue lifetime <1-65534>",
140 QUEUE_STR LIFETIME_STR "Lifetime in centi-seconds")
141{
142 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
143 uint8_t csec = atoi(argv[0]);
144
145 bts->force_llc_lifetime = csec;
146
147 return CMD_SUCCESS;
148}
149
150DEFUN(cfg_pcu_queue_lifetime_inf,
151 cfg_pcu_queue_lifetime_inf_cmd,
152 "queue lifetime infinite",
153 QUEUE_STR LIFETIME_STR "Infinite lifetime")
154{
155 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
156
157 bts->force_llc_lifetime = 0xffff;
158
159 return CMD_SUCCESS;
160}
161
162DEFUN(cfg_pcu_no_queue_lifetime,
163 cfg_pcu_no_queue_lifetime_cmd,
164 "no queue lifetime",
165 NO_STR QUEUE_STR "Disable lifetime limit of LLC frame (use value given "
166 "by SGSN)\n")
167{
168 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
169
170 bts->force_llc_lifetime = 0;
171
172 return CMD_SUCCESS;
173}
174
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200175DEFUN(cfg_pcu_alloc,
176 cfg_pcu_alloc_cmd,
177 "alloc-algorithm (a|b)",
178 "Select slot allocation algorithm to use when assigning timeslots on "
179 "PACCH\nSingle slot is assigned only\nMultiple slots are assigned for "
180 "semi-duplex operation")
181{
182 struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
183
184 switch (argv[0][0]) {
185 case 'a':
186 bts->alloc_algorithm = alloc_algorithm_a;
187 break;
188 case 'b':
189 bts->alloc_algorithm = alloc_algorithm_b;
190 break;
191 }
192
193 return CMD_SUCCESS;
194}
195
Andreas Eversberg12942562012-07-12 14:31:57 +0200196static const char pcu_copyright[] =
197 "Copyright (C) 2012 by ...\r\n"
198 "License GNU GPL version 2 or later\r\n"
199 "This is free software: you are free to change and redistribute it.\r\n"
200 "There is NO WARRANTY, to the extent permitted by law.\r\n";
201
202struct vty_app_info pcu_vty_info = {
203 .name = "Osmo-PCU",
204 .version = PACKAGE_VERSION,
205 .copyright = pcu_copyright,
206 .go_parent_cb = pcu_vty_go_parent,
207 .is_config_node = pcu_vty_is_config_node,
208};
209
210int pcu_vty_init(const struct log_info *cat)
211{
212// install_element_ve(&show_pcu_cmd);
213
214 logging_vty_add_cmds(cat);
215
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200216 install_node(&pcu_node, config_write_pcu);
217 install_element(CONFIG_NODE, &cfg_pcu_cmd);
218 install_default(PCU_NODE);
219 install_element(PCU_NODE, &cfg_pcu_cs_cmd);
220 install_element(PCU_NODE, &cfg_pcu_no_cs_cmd);
Andreas Eversberg24131bf2012-07-21 11:09:58 +0200221 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_cmd);
222 install_element(PCU_NODE, &cfg_pcu_queue_lifetime_inf_cmd);
223 install_element(PCU_NODE, &cfg_pcu_no_queue_lifetime_cmd);
Andreas Eversberga1503fa2012-07-22 08:58:09 +0200224 install_element(PCU_NODE, &cfg_pcu_alloc_cmd);
Andreas Eversberg8b761a32012-07-20 21:50:31 +0200225 install_element(PCU_NODE, &ournode_end_cmd);
226
Andreas Eversberg12942562012-07-12 14:31:57 +0200227 return 0;
228}