Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 1 | /* OsmoBTS VTY interface */ |
| 2 | |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 3 | |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 4 | #include <stdint.h> |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 5 | #include <osmocom/vty/logging.h> |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 6 | #include <osmocom/core/linuxlist.h> |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 7 | #include "pcu_vty.h" |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 8 | #include "gprs_rlcmac.h" |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 9 | |
| 10 | enum node_type pcu_vty_go_parent(struct vty *vty) |
| 11 | { |
| 12 | switch (vty->node) { |
| 13 | #if 0 |
| 14 | case TRX_NODE: |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 15 | vty->node = PCU_NODE; |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 16 | { |
| 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 Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 25 | return (enum node_type) vty->node; |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | int pcu_vty_is_config_node(struct vty *vty, int node) |
| 29 | { |
| 30 | switch (node) { |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 31 | case PCU_NODE: |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 32 | return 1; |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 33 | default: |
| 34 | return 0; |
| 35 | } |
| 36 | } |
| 37 | |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 38 | static struct cmd_node pcu_node = { |
| 39 | (enum node_type) PCU_NODE, |
| 40 | "%s(pcu)#", |
| 41 | 1, |
| 42 | }; |
| 43 | |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 44 | gDEFUN(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 Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 50 | vty->node = PCU_NODE; |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 51 | { |
| 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 | |
| 63 | gDEFUN(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 Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 77 | static 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 Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 82 | vty_out(vty, " flow-control-interval %d%s", bts->fc_interval, |
| 83 | VTY_NEWLINE); |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 84 | if (bts->force_cs) |
Andreas Eversberg | 499ff41 | 2012-10-03 14:21:36 +0200 | [diff] [blame] | 85 | 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 Eversberg | 24131bf | 2012-07-21 11:09:58 +0200 | [diff] [blame] | 91 | 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 Eversberg | a1503fa | 2012-07-22 08:58:09 +0200 | [diff] [blame] | 96 | 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 Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 100 | if (bts->force_two_phase) |
| 101 | vty_out(vty, " two-phase-access%s", VTY_NEWLINE); |
Andreas Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 102 | vty_out(vty, " alpha %d%s", bts->alpha, VTY_NEWLINE); |
| 103 | vty_out(vty, " gamma %d%s", bts->gamma * 2, VTY_NEWLINE); |
Andreas Eversberg | a1503fa | 2012-07-22 08:58:09 +0200 | [diff] [blame] | 104 | |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | /* per-BTS configuration */ |
| 108 | DEFUN(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 Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 118 | DEFUN(cfg_pcu_fc_interval, |
| 119 | cfg_pcu_fc_interval_cmd, |
Andreas Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 120 | "flow-control-interval <1-10>", |
Andreas Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 121 | "Interval between sending subsequent Flow Control PDUs\n" |
Andreas Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 122 | "Interval time in seconds\n") |
Andreas Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 123 | { |
| 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 Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 131 | DEFUN(cfg_pcu_cs, |
| 132 | cfg_pcu_cs_cmd, |
Andreas Eversberg | 499ff41 | 2012-10-03 14:21:36 +0200 | [diff] [blame] | 133 | "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 Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 136 | { |
| 137 | struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts; |
| 138 | uint8_t cs = atoi(argv[0]); |
| 139 | |
| 140 | bts->force_cs = 1; |
Andreas Eversberg | 499ff41 | 2012-10-03 14:21:36 +0200 | [diff] [blame] | 141 | 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 Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 146 | |
| 147 | return CMD_SUCCESS; |
| 148 | } |
| 149 | |
| 150 | DEFUN(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 Eversberg | 24131bf | 2012-07-21 11:09:58 +0200 | [diff] [blame] | 162 | #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 | |
| 166 | DEFUN(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 | |
| 179 | DEFUN(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 | |
| 191 | DEFUN(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 Eversberg | a1503fa | 2012-07-22 08:58:09 +0200 | [diff] [blame] | 204 | DEFUN(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 Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 225 | DEFUN(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 | |
| 237 | DEFUN(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 Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 249 | DEFUN(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 | |
| 263 | DEFUN(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 Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 276 | static const char pcu_copyright[] = |
Harald Welte | d1e340f | 2013-01-17 12:24:29 +0100 | [diff] [blame] | 277 | "Copyright (C) 2012 by Ivan Kluchnikov <kluchnikovi@gmail.com> and \r\n" |
| 278 | " Andreas Eversberg <jolly@eversberg.eu>\r\n" |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 279 | "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 | |
| 283 | struct 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 | |
| 291 | int 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 Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 297 | install_node(&pcu_node, config_write_pcu); |
| 298 | install_element(CONFIG_NODE, &cfg_pcu_cmd); |
| 299 | install_default(PCU_NODE); |
Andreas Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 300 | install_element(PCU_NODE, &cfg_pcu_no_two_phase_cmd); |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 301 | install_element(PCU_NODE, &cfg_pcu_cs_cmd); |
| 302 | install_element(PCU_NODE, &cfg_pcu_no_cs_cmd); |
Andreas Eversberg | 24131bf | 2012-07-21 11:09:58 +0200 | [diff] [blame] | 303 | 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 Eversberg | a1503fa | 2012-07-22 08:58:09 +0200 | [diff] [blame] | 306 | install_element(PCU_NODE, &cfg_pcu_alloc_cmd); |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 307 | install_element(PCU_NODE, &cfg_pcu_two_phase_cmd); |
Andreas Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 308 | install_element(PCU_NODE, &cfg_pcu_fc_interval_cmd); |
Andreas Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 309 | install_element(PCU_NODE, &cfg_pcu_alpha_cmd); |
| 310 | install_element(PCU_NODE, &cfg_pcu_gamma_cmd); |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 311 | install_element(PCU_NODE, &ournode_end_cmd); |
| 312 | |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 313 | return 0; |
| 314 | } |