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) |
| 85 | vty_out(vty, " cs %d%s", bts->initial_cs, VTY_NEWLINE); |
Andreas Eversberg | 24131bf | 2012-07-21 11:09:58 +0200 | [diff] [blame] | 86 | 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 Eversberg | a1503fa | 2012-07-22 08:58:09 +0200 | [diff] [blame] | 91 | 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 Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 95 | if (bts->force_two_phase) |
| 96 | vty_out(vty, " two-phase-access%s", VTY_NEWLINE); |
Andreas Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 97 | vty_out(vty, " alpha %d%s", bts->alpha, VTY_NEWLINE); |
| 98 | vty_out(vty, " gamma %d%s", bts->gamma * 2, VTY_NEWLINE); |
Andreas Eversberg | a1503fa | 2012-07-22 08:58:09 +0200 | [diff] [blame] | 99 | |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | /* per-BTS configuration */ |
| 103 | DEFUN(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 Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 113 | DEFUN(cfg_pcu_fc_interval, |
| 114 | cfg_pcu_fc_interval_cmd, |
Andreas Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 115 | "flow-control-interval <1-10>", |
Andreas Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 116 | "Interval between sending subsequent Flow Control PDUs\n" |
Andreas Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 117 | "Interval time in seconds\n") |
Andreas Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 118 | { |
| 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 Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 126 | DEFUN(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 | |
| 140 | DEFUN(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 Eversberg | 24131bf | 2012-07-21 11:09:58 +0200 | [diff] [blame] | 152 | #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 | |
| 156 | DEFUN(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 | |
| 169 | DEFUN(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 | |
| 181 | DEFUN(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 Eversberg | a1503fa | 2012-07-22 08:58:09 +0200 | [diff] [blame] | 194 | DEFUN(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 Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 215 | DEFUN(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 | |
| 227 | DEFUN(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 Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 239 | DEFUN(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 | |
| 253 | DEFUN(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 Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 266 | static 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 | |
| 272 | struct 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 | |
| 280 | int 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 Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 286 | install_node(&pcu_node, config_write_pcu); |
| 287 | install_element(CONFIG_NODE, &cfg_pcu_cmd); |
| 288 | install_default(PCU_NODE); |
Andreas Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 289 | install_element(PCU_NODE, &cfg_pcu_no_two_phase_cmd); |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 290 | install_element(PCU_NODE, &cfg_pcu_cs_cmd); |
| 291 | install_element(PCU_NODE, &cfg_pcu_no_cs_cmd); |
Andreas Eversberg | 24131bf | 2012-07-21 11:09:58 +0200 | [diff] [blame] | 292 | 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 Eversberg | a1503fa | 2012-07-22 08:58:09 +0200 | [diff] [blame] | 295 | install_element(PCU_NODE, &cfg_pcu_alloc_cmd); |
Andreas Eversberg | 07e97cf | 2012-08-07 16:00:56 +0200 | [diff] [blame] | 296 | install_element(PCU_NODE, &cfg_pcu_two_phase_cmd); |
Andreas Eversberg | cd8a83a | 2012-09-23 06:41:21 +0200 | [diff] [blame] | 297 | install_element(PCU_NODE, &cfg_pcu_fc_interval_cmd); |
Andreas Eversberg | aafcbbb | 2012-09-27 09:20:45 +0200 | [diff] [blame] | 298 | install_element(PCU_NODE, &cfg_pcu_alpha_cmd); |
| 299 | install_element(PCU_NODE, &cfg_pcu_gamma_cmd); |
Andreas Eversberg | 8b761a3 | 2012-07-20 21:50:31 +0200 | [diff] [blame] | 300 | install_element(PCU_NODE, &ournode_end_cmd); |
| 301 | |
Andreas Eversberg | 1294256 | 2012-07-12 14:31:57 +0200 | [diff] [blame] | 302 | return 0; |
| 303 | } |