blob: 66994dedec9b1fe675d1cfdee695c8a61b58e452 [file] [log] [blame]
Jacob Erlbeck62e96a32015-06-04 09:42:14 +02001/* 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 Erlbeckf47f68a2015-06-04 10:23:24 +020026#include "bts.h"
27#include "gprs_ms_storage.h"
28#include "gprs_ms.h"
29#include "cxx_linuxlist.h"
Jacob Erlbeck62e96a32015-06-04 09:42:14 +020030
31extern "C" {
32# include <osmocom/vty/command.h>
33# include <osmocom/vty/logging.h>
34# include <osmocom/vty/misc.h>
35}
36
37int pcu_vty_config_write_pcu_ext(struct vty *vty)
38{
39 return CMD_SUCCESS;
40}
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020041
Jacob Erlbecked2dbf62015-12-28 19:15:40 +010042static void tbf_print_vty_info(struct vty *vty, gprs_rlcmac_tbf *tbf)
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010043{
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010044 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 "
Jacob Erlbeck08c72fb2016-01-19 16:04:30 +010049 "MS_CLASS=%d/%d%s",
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010050 tbf->created_ts(), tbf->state_flags, tbf->first_ts,
51 tbf->first_common_ts, tbf->control_ts, tbf->ms_class(),
Jacob Erlbeck08c72fb2016-01-19 16:04:30 +010052 tbf->ms() ? tbf->ms()->egprs_ms_class() : -1,
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010053 VTY_NEWLINE);
54 vty_out(vty, " TS_alloc=");
55 for (int i = 0; i < 8; i++) {
56 if (tbf->pdch[i])
57 vty_out(vty, "%d ", i);
58 }
Jacob Erlbeck36df7742016-01-19 15:53:30 +010059 vty_out(vty, " CS=%s WS=%d%s%s",
60 tbf->current_cs().name(), tbf->window()->ws(),
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010061 VTY_NEWLINE, VTY_NEWLINE);
62}
63
Jacob Erlbecked2dbf62015-12-28 19:15:40 +010064int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data)
65{
66 BTS *bts = bts_data->bts;
67 LListHead<gprs_rlcmac_tbf> *ms_iter;
68
69 vty_out(vty, "UL TBFs%s", VTY_NEWLINE);
70 llist_for_each(ms_iter, &bts->ul_tbfs())
71 tbf_print_vty_info(vty, ms_iter->entry());
72
73 vty_out(vty, "%sDL TBFs%s", VTY_NEWLINE, VTY_NEWLINE);
74 llist_for_each(ms_iter, &bts->dl_tbfs())
75 tbf_print_vty_info(vty, ms_iter->entry());
76
77 return CMD_SUCCESS;
78}
79
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020080int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data)
81{
82 BTS *bts = bts_data->bts;
83 LListHead<GprsMs> *ms_iter;
84
85 llist_for_each(ms_iter, &bts->ms_store().ms_list()) {
86 GprsMs *ms = ms_iter->entry();
87
Jacob Erlbeckcb728902016-01-05 15:33:03 +010088 vty_out(vty, "MS TLLI=%08x, TA=%d, CS-UL=%s, CS-DL=%s, LLC=%d, "
Jacob Erlbeck159d4de2015-08-21 16:02:11 +020089 "IMSI=%s%s",
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020090 ms->tlli(),
Jacob Erlbeckcb728902016-01-05 15:33:03 +010091 ms->ta(), ms->current_cs_ul().name(),
92 ms->current_cs_dl().name(),
Jacob Erlbeck159d4de2015-08-21 16:02:11 +020093 ms->llc_queue()->size(),
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +020094 ms->imsi(),
95 VTY_NEWLINE);
96 }
97 return CMD_SUCCESS;
98}
Jacob Erlbeck37e896d2015-06-05 16:33:33 +020099
100static int show_ms(struct vty *vty, GprsMs *ms)
101{
Jacob Erlbeck51b11512015-06-11 16:54:50 +0200102 unsigned i;
Jacob Erlbeckc62216b2015-08-21 15:46:16 +0200103 LListHead<gprs_rlcmac_tbf> *i_tbf;
Jacob Erlbeck51b11512015-06-11 16:54:50 +0200104
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200105 vty_out(vty, "MS TLLI=%08x, IMSI=%s%s", ms->tlli(), ms->imsi(), VTY_NEWLINE);
106 vty_out(vty, " Timing advance (TA): %d%s", ms->ta(), VTY_NEWLINE);
Jacob Erlbeckcb728902016-01-05 15:33:03 +0100107 vty_out(vty, " Coding scheme uplink: %s%s", ms->current_cs_ul().name(),
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200108 VTY_NEWLINE);
Jacob Erlbeckcb728902016-01-05 15:33:03 +0100109 vty_out(vty, " Coding scheme downlink: %s%s", ms->current_cs_dl().name(),
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200110 VTY_NEWLINE);
Jacob Erlbeck7b579972016-01-05 15:54:24 +0100111 vty_out(vty, " Mode: %s%s",
112 GprsCodingScheme::modeName(ms->mode()), VTY_NEWLINE);
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200113 vty_out(vty, " MS class: %d%s", ms->ms_class(), VTY_NEWLINE);
Jacob Erlbeckc3c58042015-09-28 17:55:32 +0200114 vty_out(vty, " EGPRS MS class: %d%s", ms->egprs_ms_class(), VTY_NEWLINE);
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200115 vty_out(vty, " LLC queue length: %d%s", ms->llc_queue()->size(),
116 VTY_NEWLINE);
Jacob Erlbeck159d4de2015-08-21 16:02:11 +0200117 vty_out(vty, " LLC queue octets: %d%s", ms->llc_queue()->octets(),
118 VTY_NEWLINE);
Jacob Erlbecke4bcb622015-06-08 11:26:38 +0200119 if (ms->l1_meas()->have_rssi)
120 vty_out(vty, " RSSI: %d dBm%s",
121 ms->l1_meas()->rssi, VTY_NEWLINE);
122 if (ms->l1_meas()->have_ber)
123 vty_out(vty, " Bit error rate: %d %%%s",
124 ms->l1_meas()->ber, VTY_NEWLINE);
125 if (ms->l1_meas()->have_link_qual)
126 vty_out(vty, " Link quality: %d dB%s",
127 ms->l1_meas()->link_qual, VTY_NEWLINE);
128 if (ms->l1_meas()->have_bto)
129 vty_out(vty, " Burst timing offset: %d/4 bit%s",
130 ms->l1_meas()->bto, VTY_NEWLINE);
Jacob Erlbeck51b11512015-06-11 16:54:50 +0200131 if (ms->l1_meas()->have_ms_rx_qual)
Jacob Erlbeck04a10862015-06-12 16:01:56 +0200132 vty_out(vty, " Downlink NACK rate: %d %%%s",
133 ms->nack_rate_dl(), VTY_NEWLINE);
134 if (ms->l1_meas()->have_ms_rx_qual)
Jacob Erlbeck51b11512015-06-11 16:54:50 +0200135 vty_out(vty, " MS RX quality: %d %%%s",
136 ms->l1_meas()->ms_rx_qual, VTY_NEWLINE);
137 if (ms->l1_meas()->have_ms_c_value)
138 vty_out(vty, " MS C value: %d dB%s",
139 ms->l1_meas()->ms_c_value, VTY_NEWLINE);
140 if (ms->l1_meas()->have_ms_sign_var)
141 vty_out(vty, " MS SIGN variance: %d dB%s",
142 ms->l1_meas()->ms_sign_var, VTY_NEWLINE);
143 for (i = 0; i < ARRAY_SIZE(ms->l1_meas()->ts); ++i) {
144 if (ms->l1_meas()->ts[i].have_ms_i_level)
145 vty_out(vty, " MS I level (slot %d): %d dB%s",
146 i, ms->l1_meas()->ts[i].ms_i_level, VTY_NEWLINE);
147 }
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200148 if (ms->ul_tbf())
149 vty_out(vty, " Uplink TBF: TFI=%d, state=%s%s",
150 ms->ul_tbf()->tfi(),
151 ms->ul_tbf()->state_name(),
152 VTY_NEWLINE);
153 if (ms->dl_tbf())
154 vty_out(vty, " Downlink TBF: TFI=%d, state=%s%s",
155 ms->dl_tbf()->tfi(),
156 ms->dl_tbf()->state_name(),
157 VTY_NEWLINE);
158
Jacob Erlbeckc62216b2015-08-21 15:46:16 +0200159 llist_for_each(i_tbf, &ms->old_tbfs())
160 vty_out(vty, " Old %-19s TFI=%d, state=%s%s",
161 i_tbf->entry()->direction == GPRS_RLCMAC_UL_TBF ?
162 "Uplink TBF:" : "Downlink TBF:",
163 i_tbf->entry()->tfi(),
164 i_tbf->entry()->state_name(),
165 VTY_NEWLINE);
166
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200167 return CMD_SUCCESS;
168}
169
170int pcu_vty_show_ms_by_tlli(struct vty *vty, struct gprs_rlcmac_bts *bts_data,
171 uint32_t tlli)
172{
173 BTS *bts = bts_data->bts;
174 GprsMs *ms = bts->ms_store().get_ms(tlli);
175 if (!ms) {
176 vty_out(vty, "Unknown TLLI %08x.%s", tlli, VTY_NEWLINE);
177 return CMD_WARNING;
178 }
179
180 return show_ms(vty, ms);
181}
182
183int pcu_vty_show_ms_by_imsi(struct vty *vty, struct gprs_rlcmac_bts *bts_data,
184 const char *imsi)
185{
186 BTS *bts = bts_data->bts;
187 GprsMs *ms = bts->ms_store().get_ms(0, 0, imsi);
188 if (!ms) {
189 vty_out(vty, "Unknown IMSI '%s'.%s", imsi, VTY_NEWLINE);
190 return CMD_WARNING;
191 }
192
193 return show_ms(vty, ms);
194}