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 | 9f68670 | 2016-01-19 17:10:07 +0100 | [diff] [blame] | 44 | gprs_rlcmac_ul_tbf *ul_tbf = as_ul_tbf(tbf); |
| 45 | gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(tbf); |
| 46 | |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 47 | vty_out(vty, "TBF: TFI=%d TLLI=0x%08x (%s) DIR=%s IMSI=%s%s", tbf->tfi(), |
| 48 | tbf->tlli(), tbf->is_tlli_valid() ? "valid" : "invalid", |
| 49 | tbf->direction == GPRS_RLCMAC_UL_TBF ? "UL" : "DL", |
| 50 | tbf->imsi(), VTY_NEWLINE); |
| 51 | vty_out(vty, " created=%lu state=%08x 1st_TS=%d 1st_cTS=%d ctrl_TS=%d " |
Jacob Erlbeck | 08c72fb | 2016-01-19 16:04:30 +0100 | [diff] [blame] | 52 | "MS_CLASS=%d/%d%s", |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 53 | tbf->created_ts(), tbf->state_flags, tbf->first_ts, |
Jacob Erlbeck | f2694b7 | 2016-01-26 21:46:26 +0100 | [diff] [blame] | 54 | tbf->first_common_ts, tbf->control_ts, |
| 55 | tbf->ms_class(), |
Jacob Erlbeck | 08c72fb | 2016-01-19 16:04:30 +0100 | [diff] [blame] | 56 | tbf->ms() ? tbf->ms()->egprs_ms_class() : -1, |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 57 | VTY_NEWLINE); |
| 58 | vty_out(vty, " TS_alloc="); |
| 59 | for (int i = 0; i < 8; i++) { |
Jacob Erlbeck | 81a04f7 | 2016-01-28 16:14:58 +0100 | [diff] [blame] | 60 | bool is_ctrl = tbf->is_control_ts(i); |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 61 | if (tbf->pdch[i]) |
Jacob Erlbeck | 81a04f7 | 2016-01-28 16:14:58 +0100 | [diff] [blame] | 62 | vty_out(vty, "%d%s ", i, is_ctrl ? "!" : ""); |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 63 | } |
Jacob Erlbeck | 9f68670 | 2016-01-19 17:10:07 +0100 | [diff] [blame] | 64 | vty_out(vty, " CS=%s WS=%d", |
| 65 | tbf->current_cs().name(), tbf->window()->ws()); |
| 66 | |
| 67 | if (ul_tbf) { |
| 68 | gprs_rlc_ul_window *win = &ul_tbf->m_window; |
| 69 | vty_out(vty, " V(Q)=%d V(R)=%d", |
| 70 | win->v_q(), win->v_r()); |
| 71 | } |
| 72 | if (dl_tbf) { |
| 73 | gprs_rlc_dl_window *win = &dl_tbf->m_window; |
| 74 | vty_out(vty, " V(A)=%d V(S)=%d nBSN=%d%s", |
| 75 | win->v_a(), win->v_s(), win->resend_needed(), |
| 76 | win->window_stalled() ? " STALLED" : ""); |
| 77 | } |
| 78 | vty_out(vty, "%s%s", VTY_NEWLINE, VTY_NEWLINE); |
Jacob Erlbeck | bf49f04 | 2015-12-28 19:06:09 +0100 | [diff] [blame] | 79 | } |
| 80 | |
Jacob Erlbeck | ed2dbf6 | 2015-12-28 19:15:40 +0100 | [diff] [blame] | 81 | int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data) |
| 82 | { |
| 83 | BTS *bts = bts_data->bts; |
| 84 | LListHead<gprs_rlcmac_tbf> *ms_iter; |
| 85 | |
| 86 | vty_out(vty, "UL TBFs%s", VTY_NEWLINE); |
| 87 | llist_for_each(ms_iter, &bts->ul_tbfs()) |
| 88 | tbf_print_vty_info(vty, ms_iter->entry()); |
| 89 | |
| 90 | vty_out(vty, "%sDL TBFs%s", VTY_NEWLINE, VTY_NEWLINE); |
| 91 | llist_for_each(ms_iter, &bts->dl_tbfs()) |
| 92 | tbf_print_vty_info(vty, ms_iter->entry()); |
| 93 | |
| 94 | return CMD_SUCCESS; |
| 95 | } |
| 96 | |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 97 | int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data) |
| 98 | { |
| 99 | BTS *bts = bts_data->bts; |
| 100 | LListHead<GprsMs> *ms_iter; |
| 101 | |
| 102 | llist_for_each(ms_iter, &bts->ms_store().ms_list()) { |
| 103 | GprsMs *ms = ms_iter->entry(); |
| 104 | |
Jacob Erlbeck | cb72890 | 2016-01-05 15:33:03 +0100 | [diff] [blame] | 105 | vty_out(vty, "MS TLLI=%08x, TA=%d, CS-UL=%s, CS-DL=%s, LLC=%d, " |
Jacob Erlbeck | 159d4de | 2015-08-21 16:02:11 +0200 | [diff] [blame] | 106 | "IMSI=%s%s", |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 107 | ms->tlli(), |
Jacob Erlbeck | cb72890 | 2016-01-05 15:33:03 +0100 | [diff] [blame] | 108 | ms->ta(), ms->current_cs_ul().name(), |
| 109 | ms->current_cs_dl().name(), |
Jacob Erlbeck | 159d4de | 2015-08-21 16:02:11 +0200 | [diff] [blame] | 110 | ms->llc_queue()->size(), |
Jacob Erlbeck | f47f68a | 2015-06-04 10:23:24 +0200 | [diff] [blame] | 111 | ms->imsi(), |
| 112 | VTY_NEWLINE); |
| 113 | } |
| 114 | return CMD_SUCCESS; |
| 115 | } |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 116 | |
| 117 | static int show_ms(struct vty *vty, GprsMs *ms) |
| 118 | { |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 119 | unsigned i; |
Jacob Erlbeck | c62216b | 2015-08-21 15:46:16 +0200 | [diff] [blame] | 120 | LListHead<gprs_rlcmac_tbf> *i_tbf; |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 121 | |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 122 | vty_out(vty, "MS TLLI=%08x, IMSI=%s%s", ms->tlli(), ms->imsi(), VTY_NEWLINE); |
| 123 | vty_out(vty, " Timing advance (TA): %d%s", ms->ta(), VTY_NEWLINE); |
Jacob Erlbeck | cb72890 | 2016-01-05 15:33:03 +0100 | [diff] [blame] | 124 | vty_out(vty, " Coding scheme uplink: %s%s", ms->current_cs_ul().name(), |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 125 | VTY_NEWLINE); |
Jacob Erlbeck | cb72890 | 2016-01-05 15:33:03 +0100 | [diff] [blame] | 126 | vty_out(vty, " Coding scheme downlink: %s%s", ms->current_cs_dl().name(), |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 127 | VTY_NEWLINE); |
Jacob Erlbeck | 7b57997 | 2016-01-05 15:54:24 +0100 | [diff] [blame] | 128 | vty_out(vty, " Mode: %s%s", |
| 129 | GprsCodingScheme::modeName(ms->mode()), VTY_NEWLINE); |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 130 | vty_out(vty, " MS class: %d%s", ms->ms_class(), VTY_NEWLINE); |
Jacob Erlbeck | c3c5804 | 2015-09-28 17:55:32 +0200 | [diff] [blame] | 131 | 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] | 132 | vty_out(vty, " LLC queue length: %d%s", ms->llc_queue()->size(), |
| 133 | VTY_NEWLINE); |
Jacob Erlbeck | 159d4de | 2015-08-21 16:02:11 +0200 | [diff] [blame] | 134 | vty_out(vty, " LLC queue octets: %d%s", ms->llc_queue()->octets(), |
| 135 | VTY_NEWLINE); |
Jacob Erlbeck | e4bcb62 | 2015-06-08 11:26:38 +0200 | [diff] [blame] | 136 | if (ms->l1_meas()->have_rssi) |
| 137 | vty_out(vty, " RSSI: %d dBm%s", |
| 138 | ms->l1_meas()->rssi, VTY_NEWLINE); |
| 139 | if (ms->l1_meas()->have_ber) |
| 140 | vty_out(vty, " Bit error rate: %d %%%s", |
| 141 | ms->l1_meas()->ber, VTY_NEWLINE); |
| 142 | if (ms->l1_meas()->have_link_qual) |
| 143 | vty_out(vty, " Link quality: %d dB%s", |
| 144 | ms->l1_meas()->link_qual, VTY_NEWLINE); |
| 145 | if (ms->l1_meas()->have_bto) |
| 146 | vty_out(vty, " Burst timing offset: %d/4 bit%s", |
| 147 | ms->l1_meas()->bto, VTY_NEWLINE); |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 148 | if (ms->l1_meas()->have_ms_rx_qual) |
Jacob Erlbeck | 04a1086 | 2015-06-12 16:01:56 +0200 | [diff] [blame] | 149 | vty_out(vty, " Downlink NACK rate: %d %%%s", |
| 150 | ms->nack_rate_dl(), VTY_NEWLINE); |
| 151 | if (ms->l1_meas()->have_ms_rx_qual) |
Jacob Erlbeck | 51b1151 | 2015-06-11 16:54:50 +0200 | [diff] [blame] | 152 | vty_out(vty, " MS RX quality: %d %%%s", |
| 153 | ms->l1_meas()->ms_rx_qual, VTY_NEWLINE); |
| 154 | if (ms->l1_meas()->have_ms_c_value) |
| 155 | vty_out(vty, " MS C value: %d dB%s", |
| 156 | ms->l1_meas()->ms_c_value, VTY_NEWLINE); |
| 157 | if (ms->l1_meas()->have_ms_sign_var) |
| 158 | vty_out(vty, " MS SIGN variance: %d dB%s", |
| 159 | ms->l1_meas()->ms_sign_var, VTY_NEWLINE); |
| 160 | for (i = 0; i < ARRAY_SIZE(ms->l1_meas()->ts); ++i) { |
| 161 | if (ms->l1_meas()->ts[i].have_ms_i_level) |
| 162 | vty_out(vty, " MS I level (slot %d): %d dB%s", |
| 163 | i, ms->l1_meas()->ts[i].ms_i_level, VTY_NEWLINE); |
| 164 | } |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 165 | if (ms->ul_tbf()) |
| 166 | vty_out(vty, " Uplink TBF: TFI=%d, state=%s%s", |
| 167 | ms->ul_tbf()->tfi(), |
| 168 | ms->ul_tbf()->state_name(), |
| 169 | VTY_NEWLINE); |
| 170 | if (ms->dl_tbf()) |
| 171 | vty_out(vty, " Downlink TBF: TFI=%d, state=%s%s", |
| 172 | ms->dl_tbf()->tfi(), |
| 173 | ms->dl_tbf()->state_name(), |
| 174 | VTY_NEWLINE); |
| 175 | |
Jacob Erlbeck | c62216b | 2015-08-21 15:46:16 +0200 | [diff] [blame] | 176 | llist_for_each(i_tbf, &ms->old_tbfs()) |
| 177 | vty_out(vty, " Old %-19s TFI=%d, state=%s%s", |
| 178 | i_tbf->entry()->direction == GPRS_RLCMAC_UL_TBF ? |
| 179 | "Uplink TBF:" : "Downlink TBF:", |
| 180 | i_tbf->entry()->tfi(), |
| 181 | i_tbf->entry()->state_name(), |
| 182 | VTY_NEWLINE); |
| 183 | |
Jacob Erlbeck | 37e896d | 2015-06-05 16:33:33 +0200 | [diff] [blame] | 184 | return CMD_SUCCESS; |
| 185 | } |
| 186 | |
| 187 | int pcu_vty_show_ms_by_tlli(struct vty *vty, struct gprs_rlcmac_bts *bts_data, |
| 188 | uint32_t tlli) |
| 189 | { |
| 190 | BTS *bts = bts_data->bts; |
| 191 | GprsMs *ms = bts->ms_store().get_ms(tlli); |
| 192 | if (!ms) { |
| 193 | vty_out(vty, "Unknown TLLI %08x.%s", tlli, VTY_NEWLINE); |
| 194 | return CMD_WARNING; |
| 195 | } |
| 196 | |
| 197 | return show_ms(vty, ms); |
| 198 | } |
| 199 | |
| 200 | int pcu_vty_show_ms_by_imsi(struct vty *vty, struct gprs_rlcmac_bts *bts_data, |
| 201 | const char *imsi) |
| 202 | { |
| 203 | BTS *bts = bts_data->bts; |
| 204 | GprsMs *ms = bts->ms_store().get_ms(0, 0, imsi); |
| 205 | if (!ms) { |
| 206 | vty_out(vty, "Unknown IMSI '%s'.%s", imsi, VTY_NEWLINE); |
| 207 | return CMD_WARNING; |
| 208 | } |
| 209 | |
| 210 | return show_ms(vty, ms); |
| 211 | } |