Jacob Erlbeck | 62e96a3 | 2015-06-04 09:42:14 +0200 | [diff] [blame] | 1 | /* pcu_vty_functions.cpp |
| 2 | * |
| 3 | * Copyright (C) 2015 by Sysmocom s.f.m.c. GmbH |
| 4 | * Author: Jacob Erlbeck <jerlbeck@sysmocom.de> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | /* OsmoBTS VTY interface */ |
| 21 | |
| 22 | |
| 23 | #include <stdint.h> |
| 24 | #include <stdlib.h> |
| 25 | #include "pcu_vty_functions.h" |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 26 | #include "bts.h" |
| 27 | #include "gprs_ms_storage.h" |
| 28 | #include "gprs_ms.h" |
| 29 | #include "cxx_linuxlist.h" |
Jacob Erlbeck | 62e96a3 | 2015-06-04 09:42:14 +0200 | [diff] [blame] | 30 | |
| 31 | extern "C" { |
| 32 | # include <osmocom/vty/command.h> |
| 33 | # include <osmocom/vty/logging.h> |
| 34 | # include <osmocom/vty/misc.h> |
| 35 | } |
| 36 | |
| 37 | int pcu_vty_config_write_pcu_ext(struct vty *vty) |
| 38 | { |
| 39 | return CMD_SUCCESS; |
| 40 | } |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 41 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 42 | static void tbf_print_vty_info(struct vty *vty, gprs_rlcmac_tbf *tbf) |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 43 | { |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 44 | vty_out(vty, "TBF: TFI=%d TLLI=0x%08x (%s) DIR=%s IMSI=%s%s", tbf->tfi(), |
| 45 | tbf->tlli(), tbf->is_tlli_valid() ? "valid" : "invalid", |
| 46 | tbf->direction == GPRS_RLCMAC_UL_TBF ? "UL" : "DL", |
| 47 | tbf->imsi(), VTY_NEWLINE); |
| 48 | vty_out(vty, " created=%lu state=%08x 1st_TS=%d 1st_cTS=%d ctrl_TS=%d " |
| 49 | "MS_CLASS=%d%s", |
| 50 | tbf->created_ts(), tbf->state_flags, tbf->first_ts, |
| 51 | tbf->first_common_ts, tbf->control_ts, tbf->ms_class(), |
| 52 | VTY_NEWLINE); |
| 53 | vty_out(vty, " TS_alloc="); |
| 54 | for (int i = 0; i < 8; i++) { |
| 55 | if (tbf->pdch[i]) |
| 56 | vty_out(vty, "%d ", i); |
| 57 | } |
| 58 | vty_out(vty, " CS=%d%s%s", tbf->ms() ? tbf->ms()->current_cs_dl() : 1, |
| 59 | VTY_NEWLINE, VTY_NEWLINE); |
| 60 | } |
| 61 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 62 | int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data) |
| 63 | { |
| 64 | BTS *bts = bts_data->bts; |
| 65 | LListHead<gprs_rlcmac_tbf> *ms_iter; |
| 66 | |
| 67 | vty_out(vty, "UL TBFs%s", VTY_NEWLINE); |
| 68 | llist_for_each(ms_iter, &bts->ul_tbfs()) |
| 69 | tbf_print_vty_info(vty, ms_iter->entry()); |
| 70 | |
| 71 | vty_out(vty, "%sDL TBFs%s", VTY_NEWLINE, VTY_NEWLINE); |
| 72 | llist_for_each(ms_iter, &bts->dl_tbfs()) |
| 73 | tbf_print_vty_info(vty, ms_iter->entry()); |
| 74 | |
| 75 | return CMD_SUCCESS; |
| 76 | } |
| 77 | |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 78 | int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data) |
| 79 | { |
| 80 | BTS *bts = bts_data->bts; |
| 81 | LListHead<GprsMs> *ms_iter; |
| 82 | |
| 83 | llist_for_each(ms_iter, &bts->ms_store().ms_list()) { |
| 84 | GprsMs *ms = ms_iter->entry(); |
| 85 | |
Jacob Erlbeck | 159d4de | 2015-08-21 16:02:11 +0200 | [diff] [blame] | 86 | vty_out(vty, "MS TLLI=%08x, TA=%d, CS-UL=%d, CS-DL=%d, LLC=%d, " |
| 87 | "IMSI=%s%s", |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 88 | ms->tlli(), |
| 89 | ms->ta(), ms->current_cs_ul(), ms->current_cs_dl(), |
Jacob Erlbeck | 159d4de | 2015-08-21 16:02:11 +0200 | [diff] [blame] | 90 | ms->llc_queue()->size(), |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 91 | ms->imsi(), |
| 92 | VTY_NEWLINE); |
| 93 | } |
| 94 | return CMD_SUCCESS; |
| 95 | } |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 96 | |
| 97 | static int show_ms(struct vty *vty, GprsMs *ms) |
| 98 | { |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 99 | unsigned i; |
Jacob Erlbeck | c62216b | 2015-08-21 15:46:16 +0200 | [diff] [blame] | 100 | LListHead<gprs_rlcmac_tbf> *i_tbf; |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 101 | |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 102 | vty_out(vty, "MS TLLI=%08x, IMSI=%s%s", ms->tlli(), ms->imsi(), VTY_NEWLINE); |
| 103 | vty_out(vty, " Timing advance (TA): %d%s", ms->ta(), VTY_NEWLINE); |
| 104 | vty_out(vty, " Coding scheme uplink: CS-%d%s", ms->current_cs_ul(), |
| 105 | VTY_NEWLINE); |
| 106 | vty_out(vty, " Coding scheme downlink: CS-%d%s", ms->current_cs_dl(), |
| 107 | VTY_NEWLINE); |
| 108 | vty_out(vty, " MS class: %d%s", ms->ms_class(), VTY_NEWLINE); |
Jacob Erlbeck | c3c5804 | 2015-09-28 17:55:32 +0200 | [diff] [blame] | 109 | vty_out(vty, " EGPRS MS class: %d%s", ms->egprs_ms_class(), VTY_NEWLINE); |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 110 | vty_out(vty, " LLC queue length: %d%s", ms->llc_queue()->size(), |
| 111 | VTY_NEWLINE); |
Jacob Erlbeck | 159d4de | 2015-08-21 16:02:11 +0200 | [diff] [blame] | 112 | vty_out(vty, " LLC queue octets: %d%s", ms->llc_queue()->octets(), |
| 113 | VTY_NEWLINE); |
Jacob Erlbeck | e4bcb62 | 2015-06-08 11:26:38 +0200 | [diff] [blame] | 114 | if (ms->l1_meas()->have_rssi) |
| 115 | vty_out(vty, " RSSI: %d dBm%s", |
| 116 | ms->l1_meas()->rssi, VTY_NEWLINE); |
| 117 | if (ms->l1_meas()->have_ber) |
| 118 | vty_out(vty, " Bit error rate: %d %%%s", |
| 119 | ms->l1_meas()->ber, VTY_NEWLINE); |
| 120 | if (ms->l1_meas()->have_link_qual) |
| 121 | vty_out(vty, " Link quality: %d dB%s", |
| 122 | ms->l1_meas()->link_qual, VTY_NEWLINE); |
| 123 | if (ms->l1_meas()->have_bto) |
| 124 | vty_out(vty, " Burst timing offset: %d/4 bit%s", |
| 125 | ms->l1_meas()->bto, VTY_NEWLINE); |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 126 | if (ms->l1_meas()->have_ms_rx_qual) |
Jacob Erlbeck | 04a1086 | 2015-06-12 16:01:56 +0200 | [diff] [blame] | 127 | vty_out(vty, " Downlink NACK rate: %d %%%s", |
| 128 | ms->nack_rate_dl(), VTY_NEWLINE); |
| 129 | if (ms->l1_meas()->have_ms_rx_qual) |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 130 | vty_out(vty, " MS RX quality: %d %%%s", |
| 131 | ms->l1_meas()->ms_rx_qual, VTY_NEWLINE); |
| 132 | if (ms->l1_meas()->have_ms_c_value) |
| 133 | vty_out(vty, " MS C value: %d dB%s", |
| 134 | ms->l1_meas()->ms_c_value, VTY_NEWLINE); |
| 135 | if (ms->l1_meas()->have_ms_sign_var) |
| 136 | vty_out(vty, " MS SIGN variance: %d dB%s", |
| 137 | ms->l1_meas()->ms_sign_var, VTY_NEWLINE); |
| 138 | for (i = 0; i < ARRAY_SIZE(ms->l1_meas()->ts); ++i) { |
| 139 | if (ms->l1_meas()->ts[i].have_ms_i_level) |
| 140 | vty_out(vty, " MS I level (slot %d): %d dB%s", |
| 141 | i, ms->l1_meas()->ts[i].ms_i_level, VTY_NEWLINE); |
| 142 | } |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 143 | if (ms->ul_tbf()) |
| 144 | vty_out(vty, " Uplink TBF: TFI=%d, state=%s%s", |
| 145 | ms->ul_tbf()->tfi(), |
| 146 | ms->ul_tbf()->state_name(), |
| 147 | VTY_NEWLINE); |
| 148 | if (ms->dl_tbf()) |
| 149 | vty_out(vty, " Downlink TBF: TFI=%d, state=%s%s", |
| 150 | ms->dl_tbf()->tfi(), |
| 151 | ms->dl_tbf()->state_name(), |
| 152 | VTY_NEWLINE); |
| 153 | |
Jacob Erlbeck | c62216b | 2015-08-21 15:46:16 +0200 | [diff] [blame] | 154 | llist_for_each(i_tbf, &ms->old_tbfs()) |
| 155 | vty_out(vty, " Old %-19s TFI=%d, state=%s%s", |
| 156 | i_tbf->entry()->direction == GPRS_RLCMAC_UL_TBF ? |
| 157 | "Uplink TBF:" : "Downlink TBF:", |
| 158 | i_tbf->entry()->tfi(), |
| 159 | i_tbf->entry()->state_name(), |
| 160 | VTY_NEWLINE); |
| 161 | |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 162 | return CMD_SUCCESS; |
| 163 | } |
| 164 | |
| 165 | int pcu_vty_show_ms_by_tlli(struct vty *vty, struct gprs_rlcmac_bts *bts_data, |
| 166 | uint32_t tlli) |
| 167 | { |
| 168 | BTS *bts = bts_data->bts; |
| 169 | GprsMs *ms = bts->ms_store().get_ms(tlli); |
| 170 | if (!ms) { |
| 171 | vty_out(vty, "Unknown TLLI %08x.%s", tlli, VTY_NEWLINE); |
| 172 | return CMD_WARNING; |
| 173 | } |
| 174 | |
| 175 | return show_ms(vty, ms); |
| 176 | } |
| 177 | |
| 178 | int pcu_vty_show_ms_by_imsi(struct vty *vty, struct gprs_rlcmac_bts *bts_data, |
| 179 | const char *imsi) |
| 180 | { |
| 181 | BTS *bts = bts_data->bts; |
| 182 | GprsMs *ms = bts->ms_store().get_ms(0, 0, imsi); |
| 183 | if (!ms) { |
| 184 | vty_out(vty, "Unknown IMSI '%s'.%s", imsi, VTY_NEWLINE); |
| 185 | return CMD_WARNING; |
| 186 | } |
| 187 | |
| 188 | return show_ms(vty, ms); |
| 189 | } |