blob: f1dd25c4fa23d8a1df8a0fd8e309151b39977e07 [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 Erlbeck9f686702016-01-19 17:10:07 +010044 gprs_rlcmac_ul_tbf *ul_tbf = as_ul_tbf(tbf);
45 gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(tbf);
46
Minh-Quang Nguyen8d555632017-11-01 15:00:08 -040047 vty_out(vty, "TBF: TFI=%d TLLI=0x%08x (%s) TA=%u DIR=%s IMSI=%s%s", tbf->tfi(),
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010048 tbf->tlli(), tbf->is_tlli_valid() ? "valid" : "invalid",
Minh-Quang Nguyen8d555632017-11-01 15:00:08 -040049 tbf->ta(),
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010050 tbf->direction == GPRS_RLCMAC_UL_TBF ? "UL" : "DL",
51 tbf->imsi(), VTY_NEWLINE);
52 vty_out(vty, " created=%lu state=%08x 1st_TS=%d 1st_cTS=%d ctrl_TS=%d "
Jacob Erlbeck08c72fb2016-01-19 16:04:30 +010053 "MS_CLASS=%d/%d%s",
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010054 tbf->created_ts(), tbf->state_flags, tbf->first_ts,
Jacob Erlbeckf2694b72016-01-26 21:46:26 +010055 tbf->first_common_ts, tbf->control_ts,
56 tbf->ms_class(),
Jacob Erlbeck08c72fb2016-01-19 16:04:30 +010057 tbf->ms() ? tbf->ms()->egprs_ms_class() : -1,
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010058 VTY_NEWLINE);
59 vty_out(vty, " TS_alloc=");
60 for (int i = 0; i < 8; i++) {
Jacob Erlbeck81a04f72016-01-28 16:14:58 +010061 bool is_ctrl = tbf->is_control_ts(i);
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010062 if (tbf->pdch[i])
Jacob Erlbeck81a04f72016-01-28 16:14:58 +010063 vty_out(vty, "%d%s ", i, is_ctrl ? "!" : "");
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010064 }
Mrinal Mishrad453eaa2016-10-26 15:41:56 +053065 if (tbf->trx != NULL)
66 vty_out(vty, " TRX_ID=%d", tbf->trx->trx_no);
Jacob Erlbeck9f686702016-01-19 17:10:07 +010067 vty_out(vty, " CS=%s WS=%d",
68 tbf->current_cs().name(), tbf->window()->ws());
69
70 if (ul_tbf) {
71 gprs_rlc_ul_window *win = &ul_tbf->m_window;
72 vty_out(vty, " V(Q)=%d V(R)=%d",
73 win->v_q(), win->v_r());
sivasankarida7250a2016-12-16 12:57:18 +053074 vty_out(vty, "%s", VTY_NEWLINE);
75 vty_out(vty, " TBF Statistics:%s", VTY_NEWLINE);
76 if(GprsCodingScheme::GPRS == tbf->ms()->mode()) {
77 vty_out_rate_ctr_group(vty, " ", ul_tbf->m_ul_gprs_ctrs);
78 } else {
79 vty_out_rate_ctr_group(vty, " ", ul_tbf->m_ul_egprs_ctrs);
80 }
Jacob Erlbeck9f686702016-01-19 17:10:07 +010081 }
82 if (dl_tbf) {
83 gprs_rlc_dl_window *win = &dl_tbf->m_window;
84 vty_out(vty, " V(A)=%d V(S)=%d nBSN=%d%s",
85 win->v_a(), win->v_s(), win->resend_needed(),
86 win->window_stalled() ? " STALLED" : "");
sivasankari53950732016-12-08 17:15:17 +053087 vty_out(vty, "%s", VTY_NEWLINE);
88 vty_out_rate_ctr_group(vty, " ", tbf->m_ctrs);
89 if(GprsCodingScheme::GPRS == tbf->ms()->mode()) {
90 vty_out_rate_ctr_group(vty, " ", dl_tbf->m_dl_gprs_ctrs);
91 } else {
92 vty_out_rate_ctr_group(vty, " ", dl_tbf->m_dl_egprs_ctrs);
93 }
Jacob Erlbeck9f686702016-01-19 17:10:07 +010094 }
95 vty_out(vty, "%s%s", VTY_NEWLINE, VTY_NEWLINE);
Jacob Erlbeckbf49f042015-12-28 19:06:09 +010096}
97
Jacob Erlbecked2dbf62015-12-28 19:15:40 +010098int pcu_vty_show_tbf_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data)
99{
100 BTS *bts = bts_data->bts;
101 LListHead<gprs_rlcmac_tbf> *ms_iter;
102
103 vty_out(vty, "UL TBFs%s", VTY_NEWLINE);
104 llist_for_each(ms_iter, &bts->ul_tbfs())
105 tbf_print_vty_info(vty, ms_iter->entry());
106
107 vty_out(vty, "%sDL TBFs%s", VTY_NEWLINE, VTY_NEWLINE);
108 llist_for_each(ms_iter, &bts->dl_tbfs())
109 tbf_print_vty_info(vty, ms_iter->entry());
110
111 return CMD_SUCCESS;
112}
113
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +0200114int pcu_vty_show_ms_all(struct vty *vty, struct gprs_rlcmac_bts *bts_data)
115{
116 BTS *bts = bts_data->bts;
117 LListHead<GprsMs> *ms_iter;
118
119 llist_for_each(ms_iter, &bts->ms_store().ms_list()) {
120 GprsMs *ms = ms_iter->entry();
121
Max39eb95f2017-12-06 13:13:34 +0100122 vty_out(vty, "MS TLLI=%08x, TA=%d, CS-UL=%s, CS-DL=%s, LLC=%zd, Cl=%d, E-Cl=%d,"
123 " TBF-UL=%s, TBF-DL=%s, IMSI=%s%s",
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +0200124 ms->tlli(),
Jacob Erlbeckcb728902016-01-05 15:33:03 +0100125 ms->ta(), ms->current_cs_ul().name(),
126 ms->current_cs_dl().name(),
Jacob Erlbeck159d4de2015-08-21 16:02:11 +0200127 ms->llc_queue()->size(),
Max39eb95f2017-12-06 13:13:34 +0100128 ms->ms_class(),
129 ms->egprs_ms_class(),
130 ms->ul_tbf() ? ms->ul_tbf()->state_name() : "NA",
131 ms->dl_tbf() ? ms->dl_tbf()->state_name() : "NA",
Jacob Erlbeckf47f68a2015-06-04 10:23:24 +0200132 ms->imsi(),
133 VTY_NEWLINE);
134 }
135 return CMD_SUCCESS;
136}
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200137
138static int show_ms(struct vty *vty, GprsMs *ms)
139{
Jacob Erlbeck51b11512015-06-11 16:54:50 +0200140 unsigned i;
Jacob Erlbeckc62216b2015-08-21 15:46:16 +0200141 LListHead<gprs_rlcmac_tbf> *i_tbf;
Jacob Erlbeck7c72aca2016-01-22 17:06:14 +0100142 uint8_t slots;
Jacob Erlbeck51b11512015-06-11 16:54:50 +0200143
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200144 vty_out(vty, "MS TLLI=%08x, IMSI=%s%s", ms->tlli(), ms->imsi(), VTY_NEWLINE);
145 vty_out(vty, " Timing advance (TA): %d%s", ms->ta(), VTY_NEWLINE);
Jacob Erlbeckcb728902016-01-05 15:33:03 +0100146 vty_out(vty, " Coding scheme uplink: %s%s", ms->current_cs_ul().name(),
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200147 VTY_NEWLINE);
Jacob Erlbeckcb728902016-01-05 15:33:03 +0100148 vty_out(vty, " Coding scheme downlink: %s%s", ms->current_cs_dl().name(),
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200149 VTY_NEWLINE);
Jacob Erlbeck7b579972016-01-05 15:54:24 +0100150 vty_out(vty, " Mode: %s%s",
151 GprsCodingScheme::modeName(ms->mode()), VTY_NEWLINE);
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200152 vty_out(vty, " MS class: %d%s", ms->ms_class(), VTY_NEWLINE);
Jacob Erlbeckc3c58042015-09-28 17:55:32 +0200153 vty_out(vty, " EGPRS MS class: %d%s", ms->egprs_ms_class(), VTY_NEWLINE);
Jacob Erlbeck7c72aca2016-01-22 17:06:14 +0100154 vty_out(vty, " PACCH: ");
155 slots = ms->current_pacch_slots();
156 for (int i = 0; i < 8; i++)
157 if (slots & (1 << i))
158 vty_out(vty, "%d ", i);
159 vty_out(vty, "%s", VTY_NEWLINE);
Harald Welte63d33ad2016-03-30 22:08:18 +0200160 vty_out(vty, " LLC queue length: %zd%s", ms->llc_queue()->size(),
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200161 VTY_NEWLINE);
Harald Welte63d33ad2016-03-30 22:08:18 +0200162 vty_out(vty, " LLC queue octets: %zd%s", ms->llc_queue()->octets(),
Jacob Erlbeck159d4de2015-08-21 16:02:11 +0200163 VTY_NEWLINE);
Jacob Erlbecke4bcb622015-06-08 11:26:38 +0200164 if (ms->l1_meas()->have_rssi)
165 vty_out(vty, " RSSI: %d dBm%s",
166 ms->l1_meas()->rssi, VTY_NEWLINE);
167 if (ms->l1_meas()->have_ber)
168 vty_out(vty, " Bit error rate: %d %%%s",
169 ms->l1_meas()->ber, VTY_NEWLINE);
170 if (ms->l1_meas()->have_link_qual)
171 vty_out(vty, " Link quality: %d dB%s",
172 ms->l1_meas()->link_qual, VTY_NEWLINE);
173 if (ms->l1_meas()->have_bto)
174 vty_out(vty, " Burst timing offset: %d/4 bit%s",
175 ms->l1_meas()->bto, VTY_NEWLINE);
Jacob Erlbeck51b11512015-06-11 16:54:50 +0200176 if (ms->l1_meas()->have_ms_rx_qual)
Jacob Erlbeck04a10862015-06-12 16:01:56 +0200177 vty_out(vty, " Downlink NACK rate: %d %%%s",
178 ms->nack_rate_dl(), VTY_NEWLINE);
179 if (ms->l1_meas()->have_ms_rx_qual)
Jacob Erlbeck51b11512015-06-11 16:54:50 +0200180 vty_out(vty, " MS RX quality: %d %%%s",
181 ms->l1_meas()->ms_rx_qual, VTY_NEWLINE);
182 if (ms->l1_meas()->have_ms_c_value)
183 vty_out(vty, " MS C value: %d dB%s",
184 ms->l1_meas()->ms_c_value, VTY_NEWLINE);
185 if (ms->l1_meas()->have_ms_sign_var)
186 vty_out(vty, " MS SIGN variance: %d dB%s",
187 ms->l1_meas()->ms_sign_var, VTY_NEWLINE);
188 for (i = 0; i < ARRAY_SIZE(ms->l1_meas()->ts); ++i) {
189 if (ms->l1_meas()->ts[i].have_ms_i_level)
190 vty_out(vty, " MS I level (slot %d): %d dB%s",
191 i, ms->l1_meas()->ts[i].ms_i_level, VTY_NEWLINE);
192 }
sivasankarida7250a2016-12-16 12:57:18 +0530193 vty_out(vty, " RLC/MAC DL Control Msg: %d%s", ms->dl_ctrl_msg(),
194 VTY_NEWLINE);
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200195 if (ms->ul_tbf())
196 vty_out(vty, " Uplink TBF: TFI=%d, state=%s%s",
197 ms->ul_tbf()->tfi(),
198 ms->ul_tbf()->state_name(),
199 VTY_NEWLINE);
sivasankari53950732016-12-08 17:15:17 +0530200 if (ms->dl_tbf()) {
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200201 vty_out(vty, " Downlink TBF: TFI=%d, state=%s%s",
202 ms->dl_tbf()->tfi(),
203 ms->dl_tbf()->state_name(),
204 VTY_NEWLINE);
sivasankari53950732016-12-08 17:15:17 +0530205 vty_out(vty, " Current DL Throughput: %d Kbps %s",
206 ms->dl_tbf()->m_bw.dl_throughput,
207 VTY_NEWLINE);
208 }
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200209
Jacob Erlbeckc62216b2015-08-21 15:46:16 +0200210 llist_for_each(i_tbf, &ms->old_tbfs())
211 vty_out(vty, " Old %-19s TFI=%d, state=%s%s",
212 i_tbf->entry()->direction == GPRS_RLCMAC_UL_TBF ?
213 "Uplink TBF:" : "Downlink TBF:",
214 i_tbf->entry()->tfi(),
215 i_tbf->entry()->state_name(),
216 VTY_NEWLINE);
217
Jacob Erlbeck37e896d2015-06-05 16:33:33 +0200218 return CMD_SUCCESS;
219}
220
221int pcu_vty_show_ms_by_tlli(struct vty *vty, struct gprs_rlcmac_bts *bts_data,
222 uint32_t tlli)
223{
224 BTS *bts = bts_data->bts;
225 GprsMs *ms = bts->ms_store().get_ms(tlli);
226 if (!ms) {
227 vty_out(vty, "Unknown TLLI %08x.%s", tlli, VTY_NEWLINE);
228 return CMD_WARNING;
229 }
230
231 return show_ms(vty, ms);
232}
233
234int pcu_vty_show_ms_by_imsi(struct vty *vty, struct gprs_rlcmac_bts *bts_data,
235 const char *imsi)
236{
237 BTS *bts = bts_data->bts;
238 GprsMs *ms = bts->ms_store().get_ms(0, 0, imsi);
239 if (!ms) {
240 vty_out(vty, "Unknown IMSI '%s'.%s", imsi, VTY_NEWLINE);
241 return CMD_WARNING;
242 }
243
244 return show_ms(vty, ms);
245}